decocms 4.102.0 → 4.104.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/assets/{AlertCircle-C_nk91tH.js → AlertCircle-BRqx3xep.js} +1 -1
- package/dist/client/assets/{AreaChart-CmrBd_oc.js → AreaChart-CTIAAql6.js} +1 -1
- package/dist/client/assets/{ArrowRight-x5eFsUyE.js → ArrowRight-BvfxmFPm.js} +1 -1
- package/dist/client/assets/{ArrowUp-B_NkVhQy.js → ArrowUp-D9gId7O2.js} +1 -1
- package/dist/client/assets/{ArrowUpRight-Bjz3wM7_.js → ArrowUpRight-i87r5MHo.js} +1 -1
- package/dist/client/assets/{Check-CmXcFUFA.js → Check-CKEgzuW7.js} +1 -1
- package/dist/client/assets/{CheckCircle-GzoutZzh.js → CheckCircle-DUFed_ZY.js} +1 -1
- package/dist/client/assets/{ChevronDown-BU2ru4r_.js → ChevronDown-BtwsJF3q.js} +1 -1
- package/dist/client/assets/{ChevronRight-BLHTQ9Db.js → ChevronRight-NUnWKoQ_.js} +1 -1
- package/dist/client/assets/{ChevronUp-3FMqPib6.js → ChevronUp-DihHtLht.js} +1 -1
- package/dist/client/assets/{Copy01-BzXUnxIt.js → Copy01-C5bN0aQx.js} +1 -1
- package/dist/client/assets/{DotsVertical-BXRC3vMY.js → DotsVertical-hq3t58jm.js} +1 -1
- package/dist/client/assets/{Eye-DZiWXjzc.js → Eye-D6wgl9MG.js} +1 -1
- package/dist/client/assets/{FilterLines-Dw3b3U6U.js → FilterLines-kzf7tlKR.js} +1 -1
- package/dist/client/assets/{Globe01-Ct1oKJdh.js → Globe01-BryNz0dd.js} +1 -1
- package/dist/client/assets/{Globe04-BiqYhKIv.js → Globe04-DUBgGRbs.js} +1 -1
- package/dist/client/assets/{HardDrive-DV_SLLYZ.js → HardDrive-B-Cz-BH_.js} +1 -1
- package/dist/client/assets/{Image01-BoP1xUXy.js → Image01-C-5icdHD.js} +1 -1
- package/dist/client/assets/{Key01-C1HipuOz.js → Key01-zw1UNPHV.js} +1 -1
- package/dist/client/assets/{LayoutLeft-CxYJNTGI.js → LayoutLeft-ClXrwu6i.js} +1 -1
- package/dist/client/assets/{LinkExternal01-CGrGeU4Q.js → LinkExternal01-CUrTcP_i.js} +1 -1
- package/dist/client/assets/{Monitor01-C6zpq4qC.js → Monitor01-BntiOroW.js} +1 -1
- package/dist/client/assets/{Package-nklzvxt3.js → Package-CyI3pPtY.js} +1 -1
- package/dist/client/assets/{Palette-vt3KT1N3.js → Palette-Bf9UBt-Z.js} +1 -1
- package/dist/client/assets/{Play-C8mWR1Az.js → Play-cf98mvjp.js} +1 -1
- package/dist/client/assets/{Plus-7RPIQWLb.js → Plus-6kDymf85.js} +1 -1
- package/dist/client/assets/{SearchLg-CWLjZme7.js → SearchLg-Ca6Gs9PO.js} +1 -1
- package/dist/client/assets/{SearchMd-4O6fg9oW.js → SearchMd-Bq5ma3BB.js} +1 -1
- package/dist/client/assets/{Settings02-DU8SxETa.js → Settings02-DJcNlPiV.js} +1 -1
- package/dist/client/assets/{Shield01-oWOP2zLR.js → Shield01-BOWKmWSM.js} +1 -1
- package/dist/client/assets/{Star01-kfwc8V_o.js → Star01-4luDViOK.js} +1 -1
- package/dist/client/assets/{Stars01-C1l0RlUa.js → Stars01-DbhvFj37.js} +1 -1
- package/dist/client/assets/{Stars02-C3tFxKGI.js → Stars02-CSMCax45.js} +1 -1
- package/dist/client/assets/{Sun-CkVbwhKo.js → Sun-BS_t5Sm5.js} +1 -1
- package/dist/client/assets/{SwitchHorizontal01-BP51S8DS.js → SwitchHorizontal01-B78Wff9t.js} +1 -1
- package/dist/client/assets/{Tool01-DE3j460t.js → Tool01-CSTeisaV.js} +1 -1
- package/dist/client/assets/{Tool02-BQUR2DKB.js → Tool02-BFPH6-tL.js} +1 -1
- package/dist/client/assets/{Trash01-cB1sS901.js → Trash01-D6SSf8SM.js} +1 -1
- package/dist/client/assets/{TrendUp01-Ddu99xHU.js → TrendUp01-uCNtQJGh.js} +1 -1
- package/dist/client/assets/{Upload01-CYVHio4I.js → Upload01-IWZGSkQD.js} +1 -1
- package/dist/client/assets/{User01-CtR14f1U.js → User01-h19-qQKE.js} +1 -1
- package/dist/client/assets/{Users01-BqyJARKJ.js → Users01-BVosV5Zq.js} +1 -1
- package/dist/client/assets/{Users03-CQdAxDaw.js → Users03-BnKaYSKo.js} +1 -1
- package/dist/client/assets/{X-CAmHDMPk.js → X-Cl_lyAjH.js} +1 -1
- package/dist/client/assets/{XCircle-CANBtGHI.js → XCircle-DrkKVisl.js} +1 -1
- package/dist/client/assets/{XClose-BAfFl7aF.js → XClose-Bqw0j4zC.js} +1 -1
- package/dist/client/assets/{Zap-YiLxlwec.js → Zap-CRHRXn7z.js} +1 -1
- package/dist/client/assets/{ZapSquare-DkWTs6ms.js → ZapSquare-BNsFa87S.js} +1 -1
- package/dist/client/assets/{ZoomOut-C_3JH0WD.js → ZoomOut-Bdun-ybj.js} +1 -1
- package/dist/client/assets/{access-gate-D9ZNkrgA.js → access-gate-BqRQWMeI.js} +1 -1
- package/dist/client/assets/{add-section-modal-D-r-HB6h.js → add-section-modal-DmyUgFgN.js} +1 -1
- package/dist/client/assets/{agent-icon-VQci6jYK.js → agent-icon-gGMqm39Y.js} +1 -1
- package/dist/client/assets/{agents-list-BBAnTAXz.js → agents-list-DJkGR1B7.js} +1 -1
- package/dist/client/assets/{ai-providers-CfWuGi9h.js → ai-providers-FXkuA6xr.js} +1 -1
- package/dist/client/assets/{alert-DqafSjaL.js → alert-EqBw_yIC.js} +1 -1
- package/dist/client/assets/{alert-dialog-GMDN2a2p.js → alert-dialog-BhTFO1xE.js} +3 -3
- package/dist/client/assets/app-editor-CLJXkmZ1.js +1 -0
- package/dist/client/assets/{auth-D3hjVX0I.js → auth-CC0hVF1j.js} +1 -1
- package/dist/client/assets/{auth-catchall-DCIWbV2r.js → auth-catchall-qFVbHjsU.js} +1 -1
- package/dist/client/assets/{auth-entry-CzwaudQl.js → auth-entry-B0eRh6Z1.js} +1 -1
- package/dist/client/assets/{auth-split-layout-B15UCYf9.js → auth-split-layout-Dps5LnFV.js} +1 -1
- package/dist/client/assets/{authenticate-and-persist-oauth-B6DLU1uJ.js → authenticate-and-persist-oauth-CHxJhIDr.js} +1 -1
- package/dist/client/assets/{automation-list-row-C69OPCMn.js → automation-list-row-DDcgXspJ.js} +1 -1
- package/dist/client/assets/{automation-runs-jf4CQyxT.js → automation-runs-C-RCLuKF.js} +14 -14
- package/dist/client/assets/{automations-38lwJ0Pb.js → automations-CYBxh7wL.js} +1 -1
- package/dist/client/assets/{autosend-CrLNAcK4.js → autosend-B9JChviy.js} +1 -1
- package/dist/client/assets/{avatar-DGoq0KTj.js → avatar-D2Ibs6zj.js} +1 -1
- package/dist/client/assets/{badge-ICotptLx.js → badge-WaoanX2u.js} +1 -1
- package/dist/client/assets/{block-document-_k2vMK-w.js → block-document-DxcFxi9r.js} +1 -1
- package/dist/client/assets/{brand-context-B9pILASi.js → brand-context-NxGH-6zR.js} +1 -1
- package/dist/client/assets/{buckets-DwIjpZ7F.js → buckets-cqrj_dAj.js} +1 -1
- package/dist/client/assets/bulk-category-panel-Ca_By5bp.js +1 -0
- package/dist/client/assets/{calendar-BFIHiiFD.js → calendar-yjvySUql.js} +1 -1
- package/dist/client/assets/{capability-load-error-CghFcLQ5.js → capability-load-error-CoZ48QgK.js} +1 -1
- package/dist/client/assets/{card-DeRX92PE.js → card-gNDjFGep.js} +1 -1
- package/dist/client/assets/category-editor-BH2HxeFP.js +1 -0
- package/dist/client/assets/{chat-context-B9cQc_h3.js → chat-context-B5rz213z.js} +1 -1
- package/dist/client/assets/{checkbox-CvYv_Km6.js → checkbox-D4JNeDbC.js} +1 -1
- package/dist/client/assets/{cli-auth-success-DbrcSaQM.js → cli-auth-success-BIuDb680.js} +1 -1
- package/dist/client/assets/{collection-detail-D_jZAWBQ.js → collection-detail-TexT8fDE.js} +1 -1
- package/dist/client/assets/{collection-display-button-C91SGRBy.js → collection-display-button-BmTCVJk9.js} +1 -1
- package/dist/client/assets/{collection-search-tV8cd3K2.js → collection-search-OxgUuTDC.js} +1 -1
- package/dist/client/assets/{collection-table-wrapper-B0sW2nuq.js → collection-table-wrapper-6MozrKcJ.js} +1 -1
- package/dist/client/assets/{collection-tabs-CORSMF6h.js → collection-tabs-wFROlbKE.js} +1 -1
- package/dist/client/assets/{command-BOlKzV0V.js → command-CPJ3-fx9.js} +1 -1
- package/dist/client/assets/commerce-onboarding-CKbgdpWn.js +1 -0
- package/dist/client/assets/{companions-core-oBQaybV8.js → companions-core-Cpw1YNEa.js} +1 -1
- package/dist/client/assets/{connect-DoEAuWku.js → connect-PjtNV5Et.js} +1 -1
- package/dist/client/assets/{connect-desktop-dialog-dbCJQTWC.js → connect-desktop-dialog-D1LywKPY.js} +1 -1
- package/dist/client/assets/{connection-card-NrIXzO1v.js → connection-card-BTp_Mexf.js} +1 -1
- package/dist/client/assets/{connection-detail-DJ_6dzel.js → connection-detail-h2UhV5I3.js} +1 -1
- package/dist/client/assets/{connection-form-helpers-Dq97qH29.js → connection-form-helpers-pJAJWYOQ.js} +1 -1
- package/dist/client/assets/{connections-DJIWkSt4.js → connections-I0rMCbY8.js} +1 -1
- package/dist/client/assets/{decopilot-sse-pool-DNUfg0HV.js → decopilot-sse-pool-BKYCROku.js} +1 -1
- package/dist/client/assets/{dialog-CtcL8Rge.js → dialog-ZqiHDqPF.js} +1 -1
- package/dist/client/assets/{domain-settings-CENW7GQu.js → domain-settings-BrXjZEu1.js} +1 -1
- package/dist/client/assets/{drawer-C31EzZAL.js → drawer-DQaSiCfP.js} +1 -1
- package/dist/client/assets/{dropdown-menu-BqJxwxsq.js → dropdown-menu-Def3XQ2r.js} +1 -1
- package/dist/client/assets/{empty-state-BoA_YW3D.js → empty-state-Bv0o4pop.js} +1 -1
- package/dist/client/assets/{extract-connection-data--_aU5sYg.js → extract-connection-data-DliliWWi.js} +1 -1
- package/dist/client/assets/file-explorer-CgJTQxdk.js +2 -0
- package/dist/client/assets/{file-type-icon-BqEXVrTQ.js → file-type-icon-K2dXxjrg.js} +1 -1
- package/dist/client/assets/{files-Bye5Bbv6.js → files-BpUaRdzk.js} +1 -1
- package/dist/client/assets/{form-B5plGGFv.js → form-hSS6YV_K.js} +1 -1
- package/dist/client/assets/{general-Jd2yB-b8.js → general-mfcsqfrX.js} +1 -1
- package/dist/client/assets/github-repo-picker-gznstzb9.js +1 -0
- package/dist/client/assets/{hooks-v_4liDIo.js → hooks-C3cd-7It.js} +1 -1
- package/dist/client/assets/{index-DA5rV0RV.js → index-0_RcfZs5.js} +1 -1
- package/dist/client/assets/{index-BnE6Altg.js → index-5q66t9__.js} +1 -1
- package/dist/client/assets/{index-BAxO0Mwx.js → index-B9cuRTAq.js} +1 -1
- package/dist/client/assets/{index-Dt1PB5Sc.js → index-Bs1Iy52V.js} +1 -1
- package/dist/client/assets/{index-Chb0IZth.js → index-CPmAFNBC.js} +1 -1
- package/dist/client/assets/index-CriTplNU.js +1 -0
- package/dist/client/assets/{index-yINFUQcR.js → index-DV5sb8rn.js} +1 -1
- package/dist/client/assets/{index-Bpt5-Vj-.js → index-DawtOaQW.js} +1 -1
- package/dist/client/assets/index-DxLKWgfK.js +517 -0
- package/dist/client/assets/{index-BzyW0JhV.js → index-NnDGnKWr.js} +1 -1
- package/dist/client/assets/index-bQ7eQRAG.js +8 -0
- package/dist/client/assets/{index-82forbXV.js → index-raAj8hl6.js} +1 -1
- package/dist/client/assets/{index-redirect--8WvwlkD.js → index-redirect-D2qMNgI3.js} +1 -1
- package/dist/client/assets/{index-CmUMOI85.js → index-zLQ_KwUp.js} +4 -4
- package/dist/client/assets/{input-Cf6f3BmN.js → input-_d3dZcaj.js} +1 -1
- package/dist/client/assets/{integration-icon-dAGuZlLn.js → integration-icon-BW4ZUBDF.js} +1 -1
- package/dist/client/assets/{invite-member-dialog-DHMIvCZa.js → invite-member-dialog-B4i_qrPG.js} +1 -1
- package/dist/client/assets/{label-VkdXgHd7.js → label-BSqo1nfb.js} +1 -1
- package/dist/client/assets/{layout-Ci8_KpkR.js → layout-Du_0a-mS.js} +1 -1
- package/dist/client/assets/{login-DYMzVGTT.js → login-C1sweMWO.js} +1 -1
- package/dist/client/assets/{mcp-oauth-DUnhZRN8.js → mcp-oauth-CJiL395p.js} +1 -1
- package/dist/client/assets/{members-C_dKp9cE.js → members-zHaMXlc4.js} +1 -1
- package/dist/client/assets/{monaco-editor-Du7tJEjc.js → monaco-editor-B__egIpZ.js} +2 -2
- package/dist/client/assets/{monitoring-stats-row-CGa_Hf8X.js → monitoring-stats-row-COOk7YGw.js} +1 -1
- package/dist/client/assets/{multi-select-CKCzXjXB.js → multi-select-C-FSYlSF.js} +1 -1
- package/dist/client/assets/{oauth-callback-YH1uSwt3.js → oauth-callback-BL-L6UI-.js} +1 -1
- package/dist/client/assets/{oauth-callback-ai-provider-CfCAwFe_.js → oauth-callback-ai-provider-C_HMNOh9.js} +1 -1
- package/dist/client/assets/{onboarding-BOzlNnjb.js → onboarding-tsx5LMke.js} +1 -1
- package/dist/client/assets/{org-install-Bh_jspMI.js → org-install-D_rzgEnE.js} +1 -1
- package/dist/client/assets/{org-layout-phPHQXN7.js → org-layout-CYcTViI4.js} +1 -1
- package/dist/client/assets/{organization-choice-b-1zF0V4.js → organization-choice-DXt7QQPT.js} +1 -1
- package/dist/client/assets/{orgs-BNj-B7ZU.js → orgs-BIM3XY2Q.js} +1 -1
- package/dist/client/assets/{page-seo-form-DEBPMXNg.js → page-seo-form-VLW_NzAm.js} +1 -1
- package/dist/client/assets/page-seo-sheet-D75ZAusC.js +1 -0
- package/dist/client/assets/{popover-RUk1Jxx9.js → popover-BLlzoM5T.js} +1 -1
- package/dist/client/assets/post-editor-MhFXsnxa.js +1 -0
- package/dist/client/assets/{primitives-DjhzqWF2.js → primitives-BwYP-BE9.js} +1 -1
- package/dist/client/assets/{profile-zgo76jeb.js → profile-C0nTmLiS.js} +1 -1
- package/dist/client/assets/project-app-view-CRipBtzb.js +1 -0
- package/dist/client/assets/record-editor-DwE3lAwY.js +1 -0
- package/dist/client/assets/redirect-editor-BGHY1mAE.js +1 -0
- package/dist/client/assets/registry-CllMiCFB.js +2 -0
- package/dist/client/assets/{registry-layout-BYEc0-pE.js → registry-layout-0J0a2Ujw.js} +1 -1
- package/dist/client/assets/{reports-DKgwgjGZ.js → reports-BDrtR7vy.js} +1 -1
- package/dist/client/assets/{require-capability-tPbQgnBt.js → require-capability-iEGLG_o_.js} +1 -1
- package/dist/client/assets/{required-auth-layout-Bw_23wtD.js → required-auth-layout-BBQqJQ3M.js} +1 -1
- package/dist/client/assets/{reset-password-C_05Hu8v.js → reset-password-B2OeOUDh.js} +1 -1
- package/dist/client/assets/{roles-BVMrqSER.js → roles-ZGYesZ44.js} +1 -1
- package/dist/client/assets/{search-input-D1vvih4b.js → search-input-jKTRliwf.js} +1 -1
- package/dist/client/assets/{secrets-BLPRuVeZ.js → secrets-B2GJpjmZ.js} +1 -1
- package/dist/client/assets/{sections-editor-qd7Dwqwc.js → sections-editor-B9WQ_qSW.js} +2 -2
- package/dist/client/assets/{select-DQl8Nkd-.js → select-LJtxIB-u.js} +1 -1
- package/dist/client/assets/{select-model-DDvi29I3.js → select-model-BxAY6ZVn.js} +1 -1
- package/dist/client/assets/self-tool-result-B4zU4shH.js +1 -0
- package/dist/client/assets/seo-editor-Cv-AlrO0.js +1 -0
- package/dist/client/assets/{settings-layout-Bn989CC7.js → settings-layout-Bqxe7Le8.js} +1 -1
- package/dist/client/assets/{settings-section-BUqk0nQQ.js → settings-section-DiO-ilon.js} +1 -1
- package/dist/client/assets/{shell-controls-B8ZbVsnA.js → shell-controls-BO1iBU8O.js} +1 -1
- package/dist/client/assets/{shell-layout-_h-q07bi.js → shell-layout-B-ggkJxp.js} +1 -1
- package/dist/client/assets/{sidebar-CCp56Env.js → sidebar-CMBLFeKd.js} +1 -1
- package/dist/client/assets/{skeleton-BOpN06w4.js → skeleton-CK77xki0.js} +1 -1
- package/dist/client/assets/{sso-BkvAY4e8.js → sso-20c3PF9y.js} +1 -1
- package/dist/client/assets/{store-CMf550pL.js → store-fph_z5c6.js} +1 -1
- package/dist/client/assets/store-registry-ePKba1tj.js +2 -0
- package/dist/client/assets/{studio-tools-BVRXDcEz.js → studio-tools-BDPy4sbt.js} +1 -1
- package/dist/client/assets/{switch-BM-HDdky.js → switch-DAZLVlwZ.js} +1 -1
- package/dist/client/assets/{table-zJH1gBbm.js → table-DpElKEEr.js} +1 -1
- package/dist/client/assets/{tabs-CELqSRxW.js → tabs-BTnvaiWr.js} +1 -1
- package/dist/client/assets/{textarea-PL3tBRfL.js → textarea-Ci575ef_.js} +1 -1
- package/dist/client/assets/{toggle-group-DSJnwILX.js → toggle-group-j1ezUTaN.js} +1 -1
- package/dist/client/assets/{toolbar-XFnqI6aL.js → toolbar-_ubtVWm6.js} +1 -1
- package/dist/client/assets/{toolbar-icon-button-Drpylp7y.js → toolbar-icon-button-CzwvD8BJ.js} +1 -1
- package/dist/client/assets/{tooltip-DLvHocW9.js → tooltip-y2P8oLl6.js} +1 -1
- package/dist/client/assets/{use-ai-providers-DB0PWqc_.js → use-ai-providers-B8Bw0Tf-.js} +1 -1
- package/dist/client/assets/{use-api-keys-dCJwGqEj.js → use-api-keys-BhyKb5WG.js} +1 -1
- package/dist/client/assets/{use-automations-DHjQTH3C.js → use-automations-_qY82s9O.js} +1 -1
- package/dist/client/assets/{use-autosave-BbOXI1wB.js → use-autosave-DsJinH0F.js} +1 -1
- package/dist/client/assets/{use-capability-ZRZyXZT2.js → use-capability-BaUd0xWe.js} +1 -1
- package/dist/client/assets/{use-clock-tick-DeftYEin.js → use-clock-tick-gdHsdqwN.js} +1 -1
- package/dist/client/assets/{use-connection-BvbWEpu1.js → use-connection-BA0SHZq4.js} +1 -1
- package/dist/client/assets/{use-copy-_PBbl_ae.js → use-copy-Cn6MReyw.js} +1 -1
- package/dist/client/assets/{use-create-virtual-mcp-CsZebPFO.js → use-create-virtual-mcp-qP-tA4jh.js} +1 -1
- package/dist/client/assets/{use-debounced-autosave-DpFFxhds.js → use-debounced-autosave-BDgaG6ie.js} +1 -1
- package/dist/client/assets/{use-debounced-value-RZv6Czrq.js → use-debounced-value-Z46cTfvU.js} +1 -1
- package/dist/client/assets/{use-deco-credits-CPmWdsys.js → use-deco-credits-eJFjSf8h.js} +1 -1
- package/dist/client/assets/{use-decopilot-events-Bp76K5aB.js → use-decopilot-events-DIb8-xa4.js} +1 -1
- package/dist/client/assets/{use-delete-connection-DM4ddJG8.js → use-delete-connection-BRgvmH64.js} +1 -1
- package/dist/client/assets/{use-deployment-admin-CzIxD_pk.js → use-deployment-admin-CFSaL5ar.js} +1 -1
- package/dist/client/assets/{use-file-configs-CIAOsadi.js → use-file-configs-CXDDq-eK.js} +1 -1
- package/dist/client/assets/{use-infinite-scroll-UBZNLC2q.js → use-infinite-scroll-CSB5LAvZ.js} +1 -1
- package/dist/client/assets/{use-join-requests-Df1KaVAV.js → use-join-requests-CVHRtviB.js} +1 -1
- package/dist/client/assets/{use-mcp-auth-status-xCpfo047.js → use-mcp-auth-status-CMaGVn6x.js} +1 -1
- package/dist/client/assets/{use-mcp-client-FpSZFiJp.js → use-mcp-client-MwuAGCP0.js} +1 -1
- package/dist/client/assets/{use-mcp-tools-Bfgi1tbs.js → use-mcp-tools-BLLnaQRh.js} +1 -1
- package/dist/client/assets/{use-members-CUYuiUkk.js → use-members-DJzFLRoA.js} +1 -1
- package/dist/client/assets/{use-mobile-Bwjx_QMs.js → use-mobile-C13C4uh-.js} +1 -1
- package/dist/client/assets/{use-navigate-to-agent-Dlk0IC9Q.js → use-navigate-to-agent-CDRQ3LGW.js} +1 -1
- package/dist/client/assets/{use-org-auth-client-B6uCBHg4.js → use-org-auth-client-B3ECJOc5.js} +1 -1
- package/dist/client/assets/{use-org-sso-BhLu2IJL.js → use-org-sso-DwM8K-hN.js} +1 -1
- package/dist/client/assets/{use-organization-roles-DRWNxAn0.js → use-organization-roles-BoQYsJwI.js} +1 -1
- package/dist/client/assets/{use-organization-settings-CNDPvDWL.js → use-organization-settings-BxFrc-MV.js} +1 -1
- package/dist/client/assets/{use-registry-app-8Rk9qQRz.js → use-registry-app-F_eDYFGU.js} +1 -1
- package/dist/client/assets/{use-registry-connections-Bp9WZcYU.js → use-registry-connections-DRdZgjEN.js} +1 -1
- package/dist/client/assets/{use-secrets-C2xWkrG-.js → use-secrets-JzPHoSYH.js} +1 -1
- package/dist/client/assets/{use-status-sounds-Cil-9RHI.js → use-status-sounds-CRrS5x2x.js} +1 -1
- package/dist/client/assets/{use-view-mode-Dtt2tGe0.js → use-view-mode-BLv7KScm.js} +1 -1
- package/dist/client/assets/{use-virtual-mcp-BO12Buo0.js → use-virtual-mcp-DkfSN5A7.js} +1 -1
- package/dist/client/assets/useInfiniteQuery-Bulr5qLo.js +1 -0
- package/dist/client/assets/useQueries-Daf1r_8_.js +1 -0
- package/dist/client/assets/{useRouterState-Sf-Gnpuq.js → useRouterState-id8js3QE.js} +1 -1
- package/dist/client/assets/useSuspenseInfiniteQuery-CbOAXJqn.js +1 -0
- package/dist/client/assets/{users-C1aTmE5Y.js → users-BKPEAP3d.js} +1 -1
- package/dist/client/assets/{variant-calendar-D_jp21Fc.js → variant-calendar-BlplYmKq.js} +1 -1
- package/dist/client/assets/{view-mode-toggle-CdCRem0B.js → view-mode-toggle-BMwXmXt9.js} +1 -1
- package/dist/client/index.html +1 -1
- package/dist/server/cli.js +3 -3
- package/dist/server/server.js +3 -3
- package/package.json +1 -1
- package/dist/client/assets/app-editor-CdS1tGJ2.js +0 -1
- package/dist/client/assets/bulk-category-panel-7Z7LJBC2.js +0 -1
- package/dist/client/assets/category-editor-DHD2RkWu.js +0 -1
- package/dist/client/assets/commerce-onboarding-BkltthW8.js +0 -1
- package/dist/client/assets/file-explorer-Dd9gHOUu.js +0 -2
- package/dist/client/assets/github-repo-picker-Cy6gXTqi.js +0 -1
- package/dist/client/assets/index-Bnc4IoFE.js +0 -517
- package/dist/client/assets/index-BqJMq6o8.js +0 -1
- package/dist/client/assets/index-C-7MA5rL.js +0 -8
- package/dist/client/assets/page-seo-sheet-CMU3RR2I.js +0 -1
- package/dist/client/assets/post-editor-BYA6kioK.js +0 -1
- package/dist/client/assets/project-app-view-CaeNKaZB.js +0 -1
- package/dist/client/assets/record-editor-3_i-4UK5.js +0 -1
- package/dist/client/assets/redirect-editor-C87YqCVU.js +0 -1
- package/dist/client/assets/registry-Xj97xqvk.js +0 -2
- package/dist/client/assets/self-tool-result-DgDO0CYL.js +0 -1
- package/dist/client/assets/seo-editor-wLb7dDyd.js +0 -1
- package/dist/client/assets/store-registry-DwtUD-KU.js +0 -2
- package/dist/client/assets/useInfiniteQuery-C3F84whK.js +0 -1
- package/dist/client/assets/useSuspenseInfiniteQuery-CHz5LFPW.js +0 -1
|
@@ -1,517 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/sections-editor-qd7Dwqwc.js","assets/index-CmUMOI85.js","assets/index-BfpiUr3Z.css","assets/ChevronDown-BU2ru4r_.js","assets/agent-icon-VQci6jYK.js","assets/AlertCircle-C_nk91tH.js","assets/Tool01-DE3j460t.js","assets/ArrowUp-B_NkVhQy.js","assets/Settings02-DU8SxETa.js","assets/Tool02-BQUR2DKB.js","assets/ArrowRight-x5eFsUyE.js","assets/ArrowUpRight-Bjz3wM7_.js","assets/TrendUp01-Ddu99xHU.js","assets/ZapSquare-DkWTs6ms.js","assets/ZoomOut-C_3JH0WD.js","assets/Users03-CQdAxDaw.js","assets/CheckCircle-GzoutZzh.js","assets/Check-CmXcFUFA.js","assets/ChevronRight-BLHTQ9Db.js","assets/ChevronUp-3FMqPib6.js","assets/DotsVertical-BXRC3vMY.js","assets/Stars02-C3tFxKGI.js","assets/Copy01-BzXUnxIt.js","assets/Globe01-Ct1oKJdh.js","assets/Eye-DZiWXjzc.js","assets/FilterLines-Dw3b3U6U.js","assets/Star01-kfwc8V_o.js","assets/Globe04-BiqYhKIv.js","assets/SwitchHorizontal01-BP51S8DS.js","assets/HardDrive-DV_SLLYZ.js","assets/Image01-BoP1xUXy.js","assets/Key01-C1HipuOz.js","assets/LayoutLeft-CxYJNTGI.js","assets/XCircle-CANBtGHI.js","assets/LinkExternal01-CGrGeU4Q.js","assets/Monitor01-C6zpq4qC.js","assets/Sun-CkVbwhKo.js","assets/Package-nklzvxt3.js","assets/Palette-vt3KT1N3.js","assets/Play-C8mWR1Az.js","assets/Plus-7RPIQWLb.js","assets/SearchLg-CWLjZme7.js","assets/SearchMd-4O6fg9oW.js","assets/Shield01-oWOP2zLR.js","assets/Stars01-C1l0RlUa.js","assets/Trash01-cB1sS901.js","assets/Upload01-CYVHio4I.js","assets/User01-CtR14f1U.js","assets/Users01-BqyJARKJ.js","assets/XClose-BAfFl7aF.js","assets/X-CAmHDMPk.js","assets/Zap-YiLxlwec.js","assets/automation-runs-jf4CQyxT.js","assets/select-DQl8Nkd-.js","assets/tooltip-DLvHocW9.js","assets/useInfiniteQuery-C3F84whK.js","assets/use-infinite-scroll-UBZNLC2q.js","assets/use-connection-BvbWEpu1.js","assets/use-mcp-client-FpSZFiJp.js","assets/auth-D3hjVX0I.js","assets/use-virtual-mcp-BO12Buo0.js","assets/card-DeRX92PE.js","assets/sidebar-CCp56Env.js","assets/use-mobile-Bwjx_QMs.js","assets/table-zJH1gBbm.js","assets/empty-state-BoA_YW3D.js","assets/use-members-CUYuiUkk.js","assets/use-org-auth-client-B6uCBHg4.js","assets/use-clock-tick-DeftYEin.js","assets/use-automations-DHjQTH3C.js","assets/studio-tools-BVRXDcEz.js","assets/useSuspenseInfiniteQuery-CHz5LFPW.js","assets/avatar-DGoq0KTj.js","assets/format-time-BnbuEtat.js","assets/differenceInSeconds-NQ4PDo0z.js","assets/use-copy-_PBbl_ae.js","assets/file-type-icon-BqEXVrTQ.js","assets/dialog-CtcL8Rge.js","assets/tab-id-BijBBRwE.js","assets/hooks-v_4liDIo.js","assets/decopilot-sse-pool-DNUfg0HV.js","assets/backoff-CrEUbyZT.js","assets/delay-CnY5UFtP.js","assets/chat-context-B9cQc_h3.js","assets/autosend-CrLNAcK4.js","assets/use-ai-providers-DB0PWqc_.js","assets/location-BpLtHjTZ.js","assets/use-decopilot-events-Bp76K5aB.js","assets/use-organization-settings-CNDPvDWL.js","assets/monaco-editor-Du7tJEjc.js","assets/index-Bpt5-Vj-.js","assets/index-DA5rV0RV.js","assets/calendar-BFIHiiFD.js","assets/shell-layout-_h-q07bi.js","assets/required-auth-layout-Bw_23wtD.js","assets/use-org-sso-BhLu2IJL.js","assets/integration-icon-dAGuZlLn.js","assets/use-navigate-to-agent-Dlk0IC9Q.js","assets/reusable-new-chat-CouMjkYR.js","assets/AreaChart-CmrBd_oc.js","assets/form-B5plGGFv.js","assets/label-VkdXgHd7.js","assets/input-Cf6f3BmN.js","assets/dropdown-menu-BqJxwxsq.js","assets/page-seo-form-DEBPMXNg.js","assets/switch-BM-HDdky.js","assets/add-section-modal-D-r-HB6h.js","assets/drawer-C31EzZAL.js","assets/collection-search-tV8cd3K2.js","assets/index-C-7MA5rL.js","assets/get-initials-D-f_fDFw.js","assets/popover-RUk1Jxx9.js","assets/use-registry-app-8Rk9qQRz.js","assets/use-mcp-tools-Bfgi1tbs.js","assets/github-repo-scope-DjMZbiKa.js","assets/authenticate-and-persist-oauth-B6DLU1uJ.js","assets/mcp-oauth-DUnhZRN8.js","assets/extract-connection-data--_aU5sYg.js","assets/command-BOlKzV0V.js","assets/index-82forbXV.js","assets/companions-core-oBQaybV8.js","assets/tabs-CELqSRxW.js","assets/toggle-group-DSJnwILX.js","assets/use-deco-credits-CPmWdsys.js","assets/connection-card-NrIXzO1v.js","assets/use-registry-connections-Bp9WZcYU.js","assets/retry-CErkP7V6.js","assets/connection-slug-eyAPH6o3.js","assets/textarea-PL3tBRfL.js","assets/connection-form-helpers-Dq97qH29.js","assets/collection-tabs-CORSMF6h.js","assets/badge-ICotptLx.js","assets/connect-desktop-dialog-dbCJQTWC.js","assets/select-model-DDvi29I3.js","assets/checkbox-CvYv_Km6.js","assets/skeleton-BOpN06w4.js","assets/ai-providers-logos-DD3qZ33J.js","assets/settings-section-BUqk0nQQ.js","assets/index-Dt1PB5Sc.js","assets/alert-dialog-GMDN2a2p.js","assets/toolbar-XFnqI6aL.js","assets/use-debounced-value-RZv6Czrq.js","assets/question-004-sINsf4GQ.js","assets/use-status-sounds-Cil-9RHI.js","assets/use-capability-ZRZyXZT2.js","assets/toolbar-icon-button-Drpylp7y.js","assets/pt-BR-CLy76QW2.js","assets/use-mcp-auth-status-xCpfo047.js","assets/use-debounced-autosave-DpFFxhds.js","assets/index-BnE6Altg.js","assets/search-input-D1vvih4b.js","assets/github-repo-picker-Cy6gXTqi.js","assets/provision-repo-scoped-github-connection-2iDn-wQ1.js","assets/use-secrets-C2xWkrG-.js","assets/use-file-configs-CIAOsadi.js","assets/automation-list-row-C69OPCMn.js","assets/page-seo-sheet-CMU3RR2I.js","assets/file-explorer-Dd9gHOUu.js","assets/app-editor-CdS1tGJ2.js","assets/post-editor-BYA6kioK.js","assets/multi-select-CKCzXjXB.js","assets/block-document-_k2vMK-w.js","assets/primitives-DjhzqWF2.js","assets/use-autosave-BbOXI1wB.js","assets/record-editor-3_i-4UK5.js","assets/category-editor-DHD2RkWu.js","assets/bulk-category-panel-7Z7LJBC2.js","assets/seo-editor-wLb7dDyd.js","assets/variant-calendar-D_jp21Fc.js","assets/view-mode-toggle-CdCRem0B.js","assets/redirect-editor-C87YqCVU.js","assets/project-app-view-CaeNKaZB.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{o as Ls,r as A,a1 as P5,$ as R5,c as F,F as Oe,m as ie,j as r,E as ys,b as re,t as ge,J as tn,ae as D5,M as rs,af as M0,B as le,R as O0,P as em,ag as I5,ah as M5,v as ni,ai as _s,aj as no,ak as Mu,d as St,e as Ys,q as Me,al as O5,z as Sr,am as B5,an as tm,ad as sm,K as at,ao as zl,a as Di,ap as $5,aq as nm,ar as F5,as as hn,at as Rc,au as tr,av as z5,aw as Dc,ax as K5,ay as U5,az as H5,aA as W5,aB as q5,aC as G5,aD as Y5,aE as J5,aF as im,aG as go,n as Mt,k as et,y as B0,u as wr,f as Kl,I as X5,G as Q5,x as rm,aH as Z5,L as om,aI as ex,aJ as am,aK as tx,aL as Ul,aM as dr,aN as it,aO as ur,aP as lm,aQ as sx,aR as nx,aS as cm,aT as ix,aU as rx,aV as ox,aW as ax,aX as io,aY as Bs,Z as lx}from"./index-CmUMOI85.js";import{i as $0,n as cx}from"./ArrowUp-B_NkVhQy.js";import{a as Ts,b as Js,S as wi,c as Ii,u as dm,d as Zt,e as um,s as dx,f as ux,g as hx,p as hm,h as F0,A as fx,i as mx,j as px,t as gx,k as xx,l as vx}from"./chat-context-B9cQc_h3.js";import{s as jr,g as pn,P as No,d as z0,a as bx,M as _x,i as yx,b as Lx,F as Sx,c as fm,e as mm,S as wx,u as jx,f as Cx,h as kx,j as Ou,k as Vx,l as pm,O as Nx,m as ii,T as Tx,n as gm,R as Ax,C as Ex,G as Px,o as Rx,p as Dx,q as Ix,A as Mx}from"./automation-runs-jf4CQyxT.js";import{c as ji,T as ze,a as Ke,b as Ue}from"./tooltip-DLvHocW9.js";import{a as ms,b as ps,d as es,e as ts,h as ri,c as Mi}from"./dialog-CtcL8Rge.js";import{c as Ox,b as xm,a as vm,D as bm}from"./drawer-C31EzZAL.js";import{C as Bx}from"./collection-search-tV8cd3K2.js";import{u as Cr}from"./use-mobile-Bwjx_QMs.js";import{a as Yo,u as ht,S as Jo,i as el,c as $x,d as Fx,W as zx,e as Kx,C as Bu,g as tl,f as _m,b as $u,m as Ux}from"./use-mcp-client-FpSZFiJp.js";import{u as ym,g as Xo,l as kd,X as Hx,C as Wx,a as qx,A as Gx,b as Yx,c as Jx}from"./AreaChart-CmrBd_oc.js";import{c as K0,t as Ci,P as Xx,a as Qx,i as hr,g as Zx,b as ev,u as Lm,E as tv,d as U0,M as sv,e as Sm,f as nv,h as iv,C as rv}from"./calendar-BFIHiiFD.js";import{t as ss}from"./ChevronDown-BU2ru4r_.js";import{i as ks}from"./X-CAmHDMPk.js";import{t as ov,z as av,u as Hl,b as wm}from"./hooks-v_4liDIo.js";import{K as lv,i as jm,u as Qo,r as cv,a as Cm}from"./shell-layout-_h-q07bi.js";import{u as Zo,a as gs,b as H0,c as dv}from"./use-virtual-mcp-BO12Buo0.js";import{w as km,A as uv}from"./autosend-CrLNAcK4.js";import{u as hv,S as fv,a as mv,b as pv,r as Fu,i as gv,c as xv,w as vv,H as bv,d as _v,e as yv,f as Lv,g as Vm,h as Sv,j as wv,T as jv,k as Cv,P as kv,l as Vv,m as Nv}from"./index-C-7MA5rL.js";import{n as fr,b as Nm}from"./ZapSquare-DkWTs6ms.js";import{i as zt}from"./Check-CmXcFUFA.js";import{s as gn}from"./Star01-kfwc8V_o.js";import{a as En}from"./Image01-BoP1xUXy.js";import{t as Wl,l as Tm,m as W0,n as Tv,o as Zs,p as q0,q as G0,r as Am,u as Av,A as Xn,v as Em,w as Pm,x as Ev,y as Pv,d as Rm,z as zu,f as Dm,B as Rv,C as Im,D as Dv,E as ql,F as Oi,G as Iv,H as Y0,I as Mm,J as Om,K as Vd,L as Ic,M as Ku,N as Mv,O as Ov,P as Bv,Q as $v,R as Fv,S as zv,T as J0,U as Bm,V as oi,W as X0,X as $m,h as Q0,k as Fm,Y as Z0,Z as Kv,_ as Uv,$ as Hv,a0 as Uu,a1 as Wv,a2 as qv,a3 as Gv,a4 as Yv,a5 as Nn,a6 as sl,a7 as ea,a8 as zm,a9 as nl,aa as Km,ab as Jv,ac as Xv,ad as Qv,ae as Zv,af as e6,ag as t6,ah as s6,ai as n6,aj as i6,ak as Hu,al as r6,am as o6,an as a6,ao as l6,ap as c6,aq as d6,b as u6,ar as Um,as as Hm,at as Wm}from"./agent-icon-VQci6jYK.js";import{i as Bi}from"./Upload01-CYVHio4I.js";import{i as wn}from"./AlertCircle-C_nk91tH.js";import{a as Os}from"./Copy01-BzXUnxIt.js";import{a as Nd,b as e9,d as t9,f as s9,F as qm}from"./form-B5plGGFv.js";import{d as vt,a as Jt,b as as,c as Xt,S as Qt}from"./select-DQl8Nkd-.js";import{b as Gl,a as h6,i as f6}from"./Settings02-DU8SxETa.js";import{i as kr}from"./ArrowRight-x5eFsUyE.js";import{T as _i,a as Vr,b as ta,c as xn}from"./tabs-CELqSRxW.js";import{t as Td}from"./Tool02-BQUR2DKB.js";import{a as n9,T as To}from"./toggle-group-DSJnwILX.js";import{I as rt}from"./input-Cf6f3BmN.js";import{u as i9,b as sa,g as r9,A as o9,c as Gm,a as sn,r as m6,f as p6,d as g6}from"./use-deco-credits-CPmWdsys.js";import{u as $s}from"./studio-tools-BVRXDcEz.js";import{i as Nr}from"./Monitor01-C6zpq4qC.js";import{C as x6,l as v6,a as b6,b as _6}from"./connect-desktop-dialog-dbCJQTWC.js";import{s as Pn}from"./XClose-BAfFl7aF.js";import{m as Yl,i as y6,g as Ym,a as L6,N as S6,M as w6}from"./select-model-DDvi29I3.js";import{u as j6,a as Jm}from"./use-members-CUYuiUkk.js";import{g as C6}from"./get-initials-D-f_fDFw.js";import{A as ir}from"./avatar-DGoq0KTj.js";import{C as Qn,e as Ms,a as Vs,f as Wu,d as Tr,b as $i,c as Fi,g as k6}from"./command-BOlKzV0V.js";import{b as As,P as Es,a as Ps}from"./popover-RUk1Jxx9.js";import{u as Xm}from"./useInfiniteQuery-C3F84whK.js";import{u as na,a as a9,b as Qm}from"./use-mcp-tools-Bfgi1tbs.js";import{D as ds,c as us,d as ro,b as hs,a as Xe,e as Ao,f as Eo,g as Po,h as Ad,i as Ro,j as rr}from"./dropdown-menu-BqJxwxsq.js";import{t as qn}from"./Stars01-C1l0RlUa.js";import{f as V6,a as N6,s as T6,u as A6,b as E6,c as P6,d as R6,g as D6,e as Zm,h as I6,R as e2,i as il,j as t2,k as M6,F as O6,l as B6,m as $6,n as F6,o as z6,p as K6,q as U6,H as H6,L as W6,r as q6,S as G6,B as Y6,t as Jl,T as l9,v as J6}from"./index-Dt1PB5Sc.js";import{a as s2,i as X6}from"./XCircle-CANBtGHI.js";import{s as kt}from"./Plus-7RPIQWLb.js";import{p as Q6,q as Z6}from"./question-004-sINsf4GQ.js";import{i as bn}from"./ChevronRight-BLHTQ9Db.js";import{u as n2}from"./use-ai-providers-DB0PWqc_.js";import{i as Xl}from"./CheckCircle-GzoutZzh.js";import{I as an}from"./integration-icon-dAGuZlLn.js";import{u as eb}from"./use-status-sounds-Cil-9RHI.js";import{E as ki}from"./empty-state-BoA_YW3D.js";import{r as rl,a as tb,p as i2,f as Fa,b as r2,c as o2,d as a2,e as sb,F as nb,g as ib,h as rb,i as ob,j as ab,k as lb,O as cb,l as db,m as ub}from"./tab-id-BijBBRwE.js";import{T as ol}from"./toolbar-XFnqI6aL.js";import{a as Zn,b as ia,i as l2,c as mr,d as hb,e as fb}from"./ZoomOut-C_3JH0WD.js";import{u as Ql,a as c2,b as d2}from"./use-organization-settings-CNDPvDWL.js";import{i as ai,n as mb}from"./Globe01-Ct1oKJdh.js";import{u as Rn,a as c9,b as u2}from"./use-connection-BvbWEpu1.js";import{g as Zl,M as pb}from"./index-DA5rV0RV.js";import{e as h2}from"./backoff-CrEUbyZT.js";import{F as pr,M as d9,O as gb}from"./file-type-icon-BqEXVrTQ.js";import{u as xb}from"./use-capability-ZRZyXZT2.js";import{T as gr}from"./textarea-PL3tBRfL.js";import{s as u9}from"./Eye-DZiWXjzc.js";import{l as vb,w as bb}from"./index-Bpt5-Vj-.js";import{T as Ed}from"./toolbar-icon-button-Drpylp7y.js";import{p as _b,f as yb}from"./pt-BR-CLy76QW2.js";import{g as Lb}from"./extract-connection-data--_aU5sYg.js";import{a as Sb,i as qu}from"./mcp-oauth-DUnhZRN8.js";import{f as al,e as ll,b as cl,A as dl,a as ul,d as hl,c as fl,g as ml}from"./alert-dialog-GMDN2a2p.js";import{C as pl,a as Do}from"./card-DeRX92PE.js";import{I as wb,R as jb,a as Cb,T as f2,u as m2}from"./use-mcp-auth-status-xCpfo047.js";import{i as kb,a as p2}from"./DotsVertical-BXRC3vMY.js";import{i as Vi}from"./Play-C8mWR1Az.js";import{s as Ns}from"./Trash01-cB1sS901.js";import{u as gl}from"./use-debounced-autosave-DpFFxhds.js";import{i as Io}from"./SearchMd-4O6fg9oW.js";import{P as en}from"./index-BnE6Altg.js";import{C as Ar}from"./checkbox-CvYv_Km6.js";import{S as h9}from"./search-input-D1vvih4b.js";import{C as g2}from"./collection-tabs-CORSMF6h.js";import{g as Vb,s as x2}from"./connection-slug-eyAPH6o3.js";import{L as lt}from"./label-VkdXgHd7.js";import{S as xr}from"./switch-BM-HDdky.js";import{i as Nb}from"./LayoutLeft-CxYJNTGI.js";import{i as f9}from"./Key01-C1HipuOz.js";import{G as Mo}from"./use-registry-app-8Rk9qQRz.js";import{G as v2}from"./github-repo-picker-Cy6gXTqi.js";import{S as Rt}from"./skeleton-BOpN06w4.js";import{s as Tb}from"./User01-CtR14f1U.js";import{t as ec}from"./Users01-BqyJARKJ.js";import{u as Ab,a as Eb}from"./use-secrets-C2xWkrG-.js";import{a as b2}from"./format-time-BnbuEtat.js";import{i as _2}from"./ArrowUpRight-Bjz3wM7_.js";import{c as m9,s as p9,b as Pb}from"./TrendUp01-Ddu99xHU.js";import{g as Rb}from"./github-repo-scope-DjMZbiKa.js";import{f as y2}from"./provision-repo-scoped-github-connection-2iDn-wQ1.js";import{m as Db,n as Ib,o as Mb,p as Ob,q as Bb}from"./sidebar-CCp56Env.js";import{n as Dn}from"./LinkExternal01-CGrGeU4Q.js";import{i as g9}from"./SearchLg-CWLjZme7.js";import{i as x9,a as $b,b as v9,c as b9}from"./Tool01-DE3j460t.js";import{d as Fb}from"./delay-CnY5UFtP.js";import{c as L2,i as zb}from"./SwitchHorizontal01-BP51S8DS.js";import{i as Ni}from"./Zap-YiLxlwec.js";import{M as ra}from"./monaco-editor-Du7tJEjc.js";import{u as Kb}from"./use-debounced-value-RZv6Czrq.js";import{u as Ub,a as S2}from"./use-file-configs-CIAOsadi.js";import{i as Hb}from"./FilterLines-Dw3b3U6U.js";import{B as Wb}from"./badge-ICotptLx.js";import{u as oa,a as qb,b as Gb,c as Yb,d as Jb}from"./use-automations-DHjQTH3C.js";import{s as xo}from"./Stars02-C3tFxKGI.js";import{A as Xb}from"./automation-list-row-C69OPCMn.js";function Qb(t,e){const s=Ls(e);return Zb({filters:{...t,status:"pending"}},s).length}function Gu(t,e){return t.findAll(e.filters).map(s=>e.select?e.select(s):s.state)}function Zb(t={},e){const s=Ls(e).getMutationCache(),n=A.useRef(t),i=A.useRef(null);return i.current===null&&(i.current=Gu(s,t)),A.useEffect(()=>{n.current=t}),A.useSyncExternalStore(A.useCallback(o=>s.subscribe(()=>{const a=P5(i.current,Gu(s,n.current));i.current!==a&&(i.current=a,R5.schedule(o))}),[s]),()=>i.current,()=>i.current)}const Yu=3,w2="inline-flex items-center gap-2 px-5 py-2.5 rounded-full bg-muted text-muted-foreground text-sm font-medium transition-colors cursor-pointer",e8="flex flex-col gap-1.5 p-4 rounded-xl bg-accent/40 text-sm leading-snug transition-colors cursor-pointer text-left";function j2(t){const e=F.c(46),{item:s,onSelect:n,isLoading:i,isDisabled:o,variant:a}=t,l=a===void 0?"pill":a,{prompt:c}=s;let d;if(e[0]!==c._meta||e[1]!==c.name||e[2]!==c.title){const j=pn(c._meta);d=c.title??z0(c.name,j),e[0]=c._meta,e[1]=c.name,e[2]=c.title,e[3]=d}else d=e[3];const h=d,u=c.description||null;if(l==="card"){let j;e[4]!==n||e[5]!==c?(j=()=>n(c),e[4]=n,e[5]=c,e[6]=j):j=e[6];const S=o||i,C=i&&"bg-accent/40",N=(o||i)&&"cursor-not-allowed opacity-50";let V;e[7]!==C||e[8]!==N?(V=ie(e8,"hover:bg-accent/60 text-foreground",C,N),e[7]=C,e[8]=N,e[9]=V):V=e[9];let E;e[10]!==h?(E=r.jsx("span",{className:"font-medium truncate capitalize",children:h}),e[10]=h,e[11]=E):E=e[11];let T;e[12]!==i?(T=i&&r.jsx(wi,{size:"xs"}),e[12]=i,e[13]=T):T=e[13];let k;e[14]!==E||e[15]!==T?(k=r.jsxs("div",{className:"flex items-center justify-between gap-2",children:[E,T]}),e[14]=E,e[15]=T,e[16]=k):k=e[16];let R;e[17]!==u?(R=u&&r.jsx("span",{className:"text-xs text-muted-foreground line-clamp-2",children:u}),e[17]=u,e[18]=R):R=e[18];let P;return e[19]!==k||e[20]!==R||e[21]!==j||e[22]!==S||e[23]!==V?(P=r.jsxs("button",{type:"button",onClick:j,disabled:S,className:V,children:[k,R]}),e[19]=k,e[20]=R,e[21]=j,e[22]=S,e[23]=V,e[24]=P):P=e[24],P}let f;e[25]!==n||e[26]!==c?(f=()=>n(c),e[25]=n,e[26]=c,e[27]=f):f=e[27];const m=o||i,p=i&&"bg-muted/50",g=(o||i)&&"cursor-not-allowed opacity-50";let x;e[28]!==p||e[29]!==g?(x=ie(w2,"hover:bg-muted/70 hover:text-foreground",p,g),e[28]=p,e[29]=g,e[30]=x):x=e[30];let v;e[31]!==h?(v=r.jsx("span",{className:"capitalize",children:h}),e[31]=h,e[32]=v):v=e[32];let b;e[33]!==i?(b=i&&r.jsx(wi,{size:"xs"}),e[33]=i,e[34]=b):b=e[34];let y;e[35]!==f||e[36]!==m||e[37]!==x||e[38]!==v||e[39]!==b?(y=r.jsx(ze,{asChild:!0,children:r.jsxs("button",{type:"button",onClick:f,disabled:m,className:x,children:[v,b]})}),e[35]=f,e[36]=m,e[37]=x,e[38]=v,e[39]=b,e[40]=y):y=e[40];const _=u??h;let L;e[41]!==_?(L=r.jsx(Ke,{side:"top",className:"max-w-xs",children:r.jsx("p",{className:"text-xs",children:_})}),e[41]=_,e[42]=L):L=e[42];let w;return e[43]!==y||e[44]!==L?(w=r.jsxs(Ue,{delayDuration:400,children:[y,L]}),e[43]=y,e[44]=L,e[45]=w):w=e[45],w}function t8(t){const e=F.c(61),{items:s,open:n,onOpenChange:i,onSelect:o,loadingPrompt:a}=t,l=re(),[c,d]=A.useState(""),h=!!a;let u;e[0]!==s||e[1]!==c?(u=c.trim()?s.filter(E=>{const T=c.toLowerCase();return E.prompt.name.toLowerCase().includes(T)||(E.prompt.title??"").toLowerCase().includes(T)||(E.prompt.description??"").toLowerCase().includes(T)}):s,e[0]=s,e[1]=c,e[2]=u):u=e[2];const f=u,m=Cr();let p;e[3]!==f.length||e[4]!==c||e[5]!==l?(p=f.length===0&&r.jsx("p",{className:"col-span-4 text-sm text-muted-foreground text-center py-8",children:l("chat.iceBreakers.noPromptsMatch",{search:c})}),e[3]=f.length,e[4]=c,e[5]=l,e[6]=p):p=e[6];let g;if(e[7]!==f||e[8]!==h||e[9]!==a?.name||e[10]!==i||e[11]!==o){let E;e[13]!==h||e[14]!==a?.name||e[15]!==i||e[16]!==o?(E=T=>r.jsx(j2,{item:T,variant:"card",onSelect:k=>{i(!1),o(k)},isLoading:a?.name===T.prompt.name,isDisabled:h&&a?.name!==T.prompt.name},T.prompt.name),e[13]=h,e[14]=a?.name,e[15]=i,e[16]=o,e[17]=E):E=e[17],g=f.map(E),e[7]=f,e[8]=h,e[9]=a?.name,e[10]=i,e[11]=o,e[12]=g}else g=e[12];let x;e[18]!==p||e[19]!==g?(x=r.jsx("div",{className:"flex-1 overflow-y-auto [scrollbar-gutter:stable]",children:r.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 gap-3 p-5",children:[p,g]})}),e[18]=p,e[19]=g,e[20]=x):x=e[20];const v=x;let b;e[21]!==l?(b=l("chat.iceBreakers.searchPromptsPlaceholder"),e[21]=l,e[22]=b):b=e[22];let y;e[23]===Symbol.for("react.memo_cache_sentinel")?(y=E=>{E.key==="Escape"&&d("")},e[23]=y):y=e[23];let _;e[24]!==c||e[25]!==b?(_=r.jsx(Bx,{value:c,onChange:d,placeholder:b,onKeyDown:y}),e[24]=c,e[25]=b,e[26]=_):_=e[26];const L=_;if(m){let E;e[27]!==l?(E=l("chat.iceBreakers.allPromptsTitle"),e[27]=l,e[28]=E):E=e[28];let T;e[29]!==E?(T=r.jsx(Ox,{className:"sr-only",children:r.jsx(xm,{children:E})}),e[29]=E,e[30]=T):T=e[30];let k;e[31]!==l?(k=l("chat.iceBreakers.promptsLabel"),e[31]=l,e[32]=k):k=e[32];let R;e[33]!==k?(R=r.jsx("div",{className:"flex items-center h-12 border-b border-border px-4 shrink-0",children:r.jsx("span",{className:"text-sm font-medium text-foreground",children:k})}),e[33]=k,e[34]=R):R=e[34];let P;e[35]!==v||e[36]!==L||e[37]!==R||e[38]!==T?(P=r.jsxs(vm,{className:"h-[85vh] flex flex-col p-0 gap-0",children:[T,R,L,v]}),e[35]=v,e[36]=L,e[37]=R,e[38]=T,e[39]=P):P=e[39];let D;return e[40]!==i||e[41]!==n||e[42]!==P?(D=r.jsx(ji,{delayDuration:400,children:r.jsx(bm,{open:n,onOpenChange:i,children:P})}),e[40]=i,e[41]=n,e[42]=P,e[43]=D):D=e[43],D}let w;e[44]!==l?(w=l("chat.iceBreakers.allPromptsTitle"),e[44]=l,e[45]=w):w=e[45];let j;e[46]!==w?(j=r.jsx(ms,{className:"sr-only",children:r.jsx(ps,{children:w})}),e[46]=w,e[47]=j):j=e[47];let S;e[48]!==l?(S=l("chat.iceBreakers.promptsLabel"),e[48]=l,e[49]=S):S=e[49];let C;e[50]!==S?(C=r.jsx("div",{className:"flex items-center h-12 border-b border-border px-4 shrink-0",children:r.jsx("span",{className:"text-sm font-medium text-foreground",children:S})}),e[50]=S,e[51]=C):C=e[51];let N;e[52]!==v||e[53]!==L||e[54]!==C||e[55]!==j?(N=r.jsxs(es,{className:"sm:max-w-[1100px] h-[680px] p-0 gap-0 overflow-hidden flex flex-col",children:[j,C,L,v]}),e[52]=v,e[53]=L,e[54]=C,e[55]=j,e[56]=N):N=e[56];let V;return e[57]!==i||e[58]!==n||e[59]!==N?(V=r.jsx(ji,{delayDuration:400,children:r.jsx(ts,{open:n,onOpenChange:i,children:N})}),e[57]=i,e[58]=n,e[59]=N,e[60]=V):V=e[60],V}function s8(t){const e=F.c(30),{items:s,onSelect:n,loadingPrompt:i,className:o}=t,a=re(),[l,c]=A.useState(!1);if(s.length===0)return null;let d,h,u,f,m;if(e[0]!==o||e[1]!==s||e[2]!==i||e[3]!==n||e[4]!==a){const v=s.slice(0,Yu),b=s.slice(Yu),y=!!i;let _;e[10]!==y||e[11]!==i?.name||e[12]!==n?(_=w=>r.jsx(j2,{item:w,onSelect:n,isLoading:i?.name===w.prompt.name,isDisabled:y&&i?.name!==w.prompt.name},w.prompt.name),e[10]=y,e[11]=i?.name,e[12]=n,e[13]=_):_=e[13];const L=v.map(_);d=ji,m=400,e[14]!==o?(h=ie("w-full flex flex-wrap gap-2 justify-center",o),e[14]=o,e[15]=h):h=e[15],u=L,f=b.length>0&&r.jsx("button",{type:"button",disabled:y,onClick:()=>c(!0),className:ie(w2,"hover:bg-muted/70 hover:text-foreground",y&&"opacity-50 cursor-not-allowed"),children:a("chat.iceBreakers.moreButton",{count:b.length})}),e[0]=o,e[1]=s,e[2]=i,e[3]=n,e[4]=a,e[5]=d,e[6]=h,e[7]=u,e[8]=f,e[9]=m}else d=e[5],h=e[6],u=e[7],f=e[8],m=e[9];let p;e[16]!==h||e[17]!==u||e[18]!==f?(p=r.jsxs("div",{className:h,children:[u,f]}),e[16]=h,e[17]=u,e[18]=f,e[19]=p):p=e[19];let g;e[20]!==s||e[21]!==i||e[22]!==l||e[23]!==n?(g=r.jsx(t8,{items:s,open:l,onOpenChange:c,onSelect:n,loadingPrompt:i}),e[20]=s,e[21]=i,e[22]=l,e[23]=n,e[24]=g):g=e[24];let x;return e[25]!==d||e[26]!==m||e[27]!==p||e[28]!==g?(x=r.jsxs(d,{delayDuration:m,children:[p,g]}),e[25]=d,e[26]=m,e[27]=p,e[28]=g,e[29]=x):x=e[29],x}function n8(){return null}function i8(t,e){switch(e.type){case"SELECT_PROMPT":return!e.prompt.arguments||e.prompt.arguments.length===0?{stage:"loading",prompt:e.prompt}:{stage:"idle"};case"START_LOADING":return{stage:"loading",prompt:e.prompt,arguments:e.arguments};case"RESET":return{stage:"idle"};default:return t}}function r8(t){const e=F.c(31),{connectionId:s}=t,n=re(),{sendMessage:i}=Js(),{org:o}=Oe();let a;e[0]!==s||e[1]!==o.id||e[2]!==o.slug?(a={connectionId:s,orgId:o.id,orgSlug:o.slug},e[0]=s,e[1]=o.id,e[2]=o.slug,e[3]=a):a=e[3];const l=ht(a);let c;e[4]!==l?(c={client:l,staleTime:6e4},e[4]=l,e[5]=c):c=e[5];const{data:d}=ym(c);let h;e[6]!==d?.prompts?(h=d?.prompts??[],e[6]=d?.prompts,e[7]=h):h=e[7];const u=h;let f;e[8]!==u?(f=u.map(o8),e[8]=u,e[9]=f):f=e[9];const m=f;let p;e[10]===Symbol.for("react.memo_cache_sentinel")?(p={stage:"idle"},e[10]=p):p=e[10];const[g,x]=A.useReducer(i8,p),[v,b]=A.useState(null);let y;e[11]!==l||e[12]!==i||e[13]!==n?(y=async(k,R)=>{if(!l){ge.error(n("chat.iceBreakers.mcpClientNotAvailable")),x({type:"RESET"});return}try{const P=await Xo(l,k.name,R);x({type:"RESET"});const D={type:"doc",content:[{type:"paragraph",content:[K0({id:k.name,name:jr(k.name,pn(k._meta)),metadata:P.messages,char:"/",kind:"prompt",args:R}),{type:"text",text:" "}]}]};await i(D)}catch(P){console.error("[ice-breakers] Failed to fetch prompt:",P),ge.error(n("chat.iceBreakers.failedToLoadPrompt")),x({type:"RESET"})}},e[11]=l,e[12]=i,e[13]=n,e[14]=y):y=e[14];const _=y;let L;e[15]!==_?(L=async k=>{if(k.arguments&&k.arguments.length>0){x({type:"SELECT_PROMPT",prompt:k}),b(k);return}x({type:"START_LOADING",prompt:k}),await _(k)},e[15]=_,e[16]=L):L=e[16];const w=L;let j;e[17]!==v||e[18]!==_?(j=async k=>{v&&(x({type:"START_LOADING",prompt:v,arguments:k}),b(null),await _(v,k))},e[17]=v,e[18]=_,e[19]=j):j=e[19];const S=j;if(m.length===0)return null;const C=g.stage==="loading"?g.prompt:null;let N;e[20]!==w||e[21]!==m||e[22]!==C?(N=r.jsx(s8,{items:m,onSelect:w,loadingPrompt:C}),e[20]=w,e[21]=m,e[22]=C,e[23]=N):N=e[23];let V;e[24]===Symbol.for("react.memo_cache_sentinel")?(V=()=>{b(null),x({type:"RESET"})},e[24]=V):V=e[24];let E;e[25]!==v||e[26]!==S?(E=r.jsx(No,{prompt:v,setPrompt:V,onSubmit:S}),e[25]=v,e[26]=S,e[27]=E):E=e[27];let T;return e[28]!==N||e[29]!==E?(T=r.jsxs(r.Fragment,{children:[N,E]}),e[28]=N,e[29]=E,e[30]=T):T=e[30],T}function o8(t){return{prompt:t}}function a8(t){const e=F.c(13),{className:s}=t,{selectedVirtualMcp:n}=Ts(),{org:i}=Oe();let o;e[0]!==i.id?(o=Yo(i.id),e[0]=i.id,e[1]=o):o=e[1];const a=o.id,l=n?.id??a;let c;e[2]!==s?(c=ie("w-full @container",s),e[2]=s,e[3]=c):c=e[3];const d=l??"default";let h;e[4]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx(n8,{}),e[4]=h):h=e[4];let u;e[5]!==l?(u=r.jsx(r8,{connectionId:l}),e[5]=l,e[6]=u):u=e[6];let f;e[7]!==d||e[8]!==u?(f=r.jsx(ys,{fallback:null,children:r.jsx(A.Suspense,{fallback:h,children:u},d)}),e[7]=d,e[8]=u,e[9]=f):f=e[9];let m;return e[10]!==c||e[11]!==f?(m=r.jsx("div",{className:c,children:f}),e[10]=c,e[11]=f,e[12]=m):m=e[12],m}const Mc="cubic-bezier(0.645, 0.045, 0.355, 1)",l8=44,c8={default:"",error:"isolate after:content-[''] after:absolute after:inset-0 after:rounded-xl after:bg-destructive/5 after:pointer-events-none after:-z-10",warning:"isolate after:content-[''] after:absolute after:inset-0 after:rounded-xl after:bg-warning/5 after:pointer-events-none after:-z-10"},d8={default:"border-border",error:"border-destructive/30",warning:"border-warning/30"},u8={default:"text-muted-foreground",error:"text-destructive",warning:"text-warning"};function ei(t){const e=F.c(69),{icon:s,label:n,count:i,title:o,footerLeft:a,footerRight:l,children:c,defaultExpanded:d,variant:h,onClose:u}=t,f=h===void 0?"default":h,m=re(),[p,g]=A.useState(d),[x,v]=A.useState(!1);let b;e[0]!==u?(b=()=>{v(!0),u?.()},e[0]=u,e[1]=b):b=e[1];const y=b;if(x)return null;const _=d8[f],L=c8[f];let w;e[2]!==_||e[3]!==L?(w=ie("relative flex flex-col rounded-xl bg-background border shadow-md","w-[calc(100%-16px)] max-w-[640px] mx-auto mb-2",_,L),e[2]=_,e[3]=L,e[4]=w):w=e[4];let j;e[5]===Symbol.for("react.memo_cache_sentinel")?(j=()=>g(h8),e[5]=j):j=e[5];const S=p&&"rounded-b-none",C=!p&&"rounded-b-xl";let N;e[6]!==S||e[7]!==C?(N=ie("flex items-center gap-2 w-full px-3 py-2 text-sm text-left","hover:bg-accent/50 transition-colors rounded-t-xl",S,C),e[6]=S,e[7]=C,e[8]=N):N=e[8];const V=u8[f];let E;e[9]!==V?(E=ie("shrink-0",V),e[9]=V,e[10]=E):E=e[10];let T;e[11]!==s||e[12]!==E?(T=r.jsx("span",{className:E,children:s}),e[11]=s,e[12]=E,e[13]=T):T=e[13];let k;e[14]!==n?(k=r.jsx("span",{className:"flex-1 min-w-0 truncate",children:n}),e[14]=n,e[15]=k):k=e[15];let R;e[16]!==i?(R=i?r.jsx("span",{className:"text-xs text-muted-foreground shrink-0",children:i}):null,e[16]=i,e[17]=R):R=e[17];const P=p?"rotate(180deg)":"rotate(0deg)";let D;e[18]!==P?(D=r.jsx("span",{"aria-hidden":"true",className:"text-muted-foreground shrink-0 flex items-center justify-center",children:r.jsx(ss,{size:16,style:{transform:P,transition:`transform 180ms ${Mc}`}})}),e[18]=P,e[19]=D):D=e[19];let I;e[20]!==m?(I=m("chat.collapsibleHighlight.closeLabel"),e[20]=m,e[21]=I):I=e[21];let M;e[22]!==m?(M=m("chat.collapsibleHighlight.closeTitle"),e[22]=m,e[23]=M):M=e[23];let O,$;e[24]!==y?(O=se=>{se.stopPropagation(),y()},$=se=>{(se.key==="Enter"||se.key===" ")&&(se.preventDefault(),se.stopPropagation(),y())},e[24]=y,e[25]=O,e[26]=$):(O=e[25],$=e[26]);let B;e[27]===Symbol.for("react.memo_cache_sentinel")?(B=r.jsx(ks,{size:16}),e[27]=B):B=e[27];let z;e[28]!==I||e[29]!==M||e[30]!==O||e[31]!==$?(z=r.jsx("span",{role:"button",tabIndex:0,"data-testid":"collapsible-highlight-close","aria-label":I,title:M,onClick:O,onKeyDown:$,className:"text-muted-foreground hover:text-foreground transition-colors shrink-0 flex items-center justify-center -mr-1 ml-1 p-1 rounded-md hover:bg-accent",children:B}),e[28]=I,e[29]=M,e[30]=O,e[31]=$,e[32]=z):z=e[32];let K;e[33]!==p||e[34]!==T||e[35]!==k||e[36]!==R||e[37]!==D||e[38]!==z||e[39]!==N?(K=r.jsxs("button",{type:"button","data-testid":"collapsible-highlight-chip","aria-expanded":p,onClick:j,className:N,children:[T,k,R,D,z]}),e[33]=p,e[34]=T,e[35]=k,e[36]=R,e[37]=D,e[38]=z,e[39]=N,e[40]=K):K=e[40];const G=p?"1fr":"0fr";let Y;e[41]!==G?(Y={display:"grid",gridTemplateRows:G,transition:`grid-template-rows 180ms ${Mc}`},e[41]=G,e[42]=Y):Y=e[42];let U;e[43]===Symbol.for("react.memo_cache_sentinel")?(U={overflow:"hidden",minHeight:0},e[43]=U):U=e[43];const W=p?1:0;let H;e[44]!==W?(H={opacity:W,transition:`opacity 120ms ${Mc}`,maxHeight:"60vh"},e[44]=W,e[45]=H):H=e[45];let X;e[46]!==o?(X=o?r.jsx("div",{className:"flex items-start gap-2 px-4 pt-4 pb-5 border-t border-dashed border-border/60",children:r.jsx("p",{className:"flex-1 text-base font-medium text-foreground min-w-0",children:o})}):r.jsx("div",{className:"border-t border-dashed border-border/60"}),e[46]=o,e[47]=X):X=e[47];let q;e[48]!==c||e[49]!==o?(q=c?r.jsx("div",{className:ie("pb-4",!o&&"pt-4"),children:c}):null,e[48]=c,e[49]=o,e[50]=q):q=e[50];let Z;e[51]!==X||e[52]!==q?(Z=r.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto",children:[X,q]}),e[51]=X,e[52]=q,e[53]=Z):Z=e[53];let Q;e[54]!==a||e[55]!==l?(Q=a||l?r.jsx("div",{className:"shrink-0 border-t border-border px-3 py-3 pb-6",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("div",{children:a}),r.jsx("div",{className:"flex items-center gap-2",children:l})]})}):null,e[54]=a,e[55]=l,e[56]=Q):Q=e[56];let ee;e[57]!==H||e[58]!==Z||e[59]!==Q?(ee=r.jsx("div",{style:U,children:r.jsxs("div",{className:"flex flex-col",style:H,children:[Z,Q]})}),e[57]=H,e[58]=Z,e[59]=Q,e[60]=ee):ee=e[60];let J;e[61]!==Y||e[62]!==ee?(J=r.jsx("div",{"data-testid":"collapsible-highlight-body",style:Y,children:ee}),e[61]=Y,e[62]=ee,e[63]=J):J=e[63];let te;return e[64]!==K||e[65]!==J||e[66]!==w||e[67]!==f?(te=r.jsxs("div",{"data-testid":"collapsible-highlight","data-variant":f,className:w,children:[K,J]}),e[64]=K,e[65]=J,e[66]=w,e[67]=f,e[68]=te):te=e[68],te}function h8(t){return!t}const f8=tn({content:rs().min(1).describe("Imperative form, e.g. 'Implement the login flow'"),status:M0(["pending","in_progress","completed"]),activeForm:rs().min(1).describe("Present-continuous form shown in the UI while the todo is in progress, e.g. 'Implementing the login flow'")}),C2=tn({todos:D5(f8)}),m8="Plan and track multi-step work. Call with the FULL todo list every time — this replaces the prior list. Call at the start of every multi-step request. Skip only for true one-shots (a single tool call or a direct answer). Mark exactly one todo `in_progress` at a time. Flip a todo to `in_progress` before starting it and to `completed` the moment it finishes — do not batch completions. Your prior tool-call inputs are your current state — read your last call to see where you are.";ov({description:m8,inputSchema:av(C2),execute:async({todos:t})=>({ok:!0,count:t.length})});const p8="tool-todo_write",g8=new Set(["input-available","output-available"]);function x8(t){for(let e=t.length-1;e>=0;e--){const s=t[e];if(s.role!=="assistant")continue;const n=s.parts;if(Array.isArray(n))for(let i=n.length-1;i>=0;i--){const o=n[i];if(o.type!==p8||typeof o.state!="string"||!g8.has(o.state))continue;const a=C2.safeParse(o.input);if(a.success)return a.data.todos}}return[]}function k2(t){const e=[];for(const s of t)if("state"in s&&s.state==="approval-requested"&&"approval"in s&&s.approval?.id&&"toolCallId"in s&&s.toolCallId){const n="toolName"in s&&typeof s.toolName=="string"?s.toolName:s.type.startsWith("tool-")?s.type.replace("tool-",""):"Tool";e.push({approvalId:s.approval.id,toolCallId:s.toolCallId,toolName:n,friendlyName:Ci(bx(n)),input:s.input})}return e}function V2(t){return t.at(-1)}function N2(t){const e=[];for(const s of t)s.type==="tool-propose_plan"&&s.state==="input-available"&&e.push({toolCallId:s.toolCallId,plan:s.input.plan,state:s.state});return e}function v8(t){return t?t.message.startsWith("[CREDITS]"):!1}const b8={isCreditExhausted:!1,hasTodos:!1,showError:!1,showWarning:!1,hasApprovals:!1,hasPlans:!1,isWaitingForUserInput:!1,todos:[]};function _8(t){const{messages:e,error:s,finishReason:n,isStreaming:i,isWaitingForApprovals:o}=t;if(!i&&s&&v8(s))return{...b8,isCreditExhausted:!0};const a=e.at(-1),l=a?.role==="assistant"?a.parts:[],c=l,h=!!c.filter(y=>y.type==="tool-user_ask").filter(y=>y.state!=="output-available").length,u=N2(l),f=k2(c),m=x8(e),p=!i&&!!s,g=f.length>0||i&&o,x=u.length>0,b=!i&&!!n&&n!=="stop"&&!(n==="tool-calls"&&(h||g||x))&&!p;return{isCreditExhausted:!1,hasTodos:m.length>0,showError:p,showWarning:b,hasApprovals:g,hasPlans:x,isWaitingForUserInput:h,todos:m}}function T2(){const t=F.c(6),{messages:e,error:s,finishReason:n,isStreaming:i,isWaitingForApprovals:o}=Js(),a=s??null,l=n??null;let c;return t[0]!==i||t[1]!==o||t[2]!==e||t[3]!==a||t[4]!==l?(c=_8({messages:e,error:a,finishReason:l,isStreaming:i,isWaitingForApprovals:o}),t[0]=i,t[1]=o,t[2]=e,t[3]=a,t[4]=l,t[5]=c):c=t[5],c}function y8(){const t=T2();return t.isCreditExhausted?0:Number(t.hasTodos)+Number(t.showError)+Number(t.showWarning)+Number(t.hasApprovals)+Number(t.hasPlans)+Number(t.isWaitingForUserInput)}function L8(t){const e=F.c(30),{current:s,total:n,onPrev:i,onNext:o}=t,a=re();if(n<=1)return null;const l=s===0,c=s===0?"opacity-30 cursor-not-allowed":"hover:text-foreground cursor-pointer";let d;e[0]!==c?(d=ie("p-0.5 rounded transition-colors",c),e[0]=c,e[1]=d):d=e[1];let h;e[2]!==a?(h=a("chat.pagination.previousLabel"),e[2]=a,e[3]=h):h=e[3];let u;e[4]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx(Gl,{size:14}),e[4]=u):u=e[4];let f;e[5]!==i||e[6]!==l||e[7]!==d||e[8]!==h?(f=r.jsx("button",{type:"button",onClick:i,disabled:l,className:d,"aria-label":h,children:u}),e[5]=i,e[6]=l,e[7]=d,e[8]=h,e[9]=f):f=e[9];const m=s+1;let p;e[10]!==a||e[11]!==m||e[12]!==n?(p=a("chat.pagination.counter",{current:m,total:n}),e[10]=a,e[11]=m,e[12]=n,e[13]=p):p=e[13];let g;e[14]!==p?(g=r.jsx("span",{className:"tabular-nums text-xs",children:p}),e[14]=p,e[15]=g):g=e[15];const x=s===n-1,v=s===n-1?"opacity-30 cursor-not-allowed":"hover:text-foreground cursor-pointer";let b;e[16]!==v?(b=ie("p-0.5 rounded transition-colors",v),e[16]=v,e[17]=b):b=e[17];let y;e[18]!==a?(y=a("chat.pagination.nextLabel"),e[18]=a,e[19]=y):y=e[19];let _;e[20]===Symbol.for("react.memo_cache_sentinel")?(_=r.jsx(kr,{size:14}),e[20]=_):_=e[20];let L;e[21]!==o||e[22]!==x||e[23]!==b||e[24]!==y?(L=r.jsx("button",{type:"button",onClick:o,disabled:x,className:b,"aria-label":y,children:_}),e[21]=o,e[22]=x,e[23]=b,e[24]=y,e[25]=L):L=e[25];let w;return e[26]!==L||e[27]!==f||e[28]!==g?(w=r.jsxs("div",{className:"flex items-center gap-1 text-sm text-muted-foreground",children:[f,g,L]}),e[26]=L,e[27]=f,e[28]=g,e[29]=w):w=e[29],w}function A2(t){const e=F.c(8),{currentIndex:s,total:n,onPrev:i,onNext:o,extraLeft:a}=t;let l;e[0]!==s||e[1]!==o||e[2]!==i||e[3]!==n?(l=r.jsx(L8,{current:s,total:n,onPrev:i,onNext:o}),e[0]=s,e[1]=o,e[2]=i,e[3]=n,e[4]=l):l=e[4];let c;return e[5]!==a||e[6]!==l?(c=r.jsxs("div",{className:"flex items-center gap-2",children:[l,a]}),e[5]=a,e[6]=l,e[7]=c):c=e[7],c}function S8(t){const e=F.c(17),{isStreaming:s,isAllAnswered:n,isCurrentAnswered:i,onAdvanceOrSubmit:o,submitLabel:a,nextLabel:l}=t,h=n?a===void 0?"Submit":a:l===void 0?"Next":l,u=n?s:!i,f=u?n?"Waiting for the assistant to finish…":"Answer this item to continue":null;let m;e[0]!==u||e[1]!==o?(m=()=>{u||o()},e[0]=u,e[1]=o,e[2]=m):m=e[2];const p=u&&"opacity-50 cursor-not-allowed";let g;e[3]!==p?(g=ie("h-7 px-2.5 text-xs",p),e[3]=p,e[4]=g):g=e[4];let x;e[5]!==u||e[6]!==h||e[7]!==m||e[8]!==g?(x=r.jsx(le,{type:"button",size:"sm","aria-disabled":u,onClick:m,className:g,children:h}),e[5]=u,e[6]=h,e[7]=m,e[8]=g,e[9]=x):x=e[9];const v=x;if(!f)return v;let b;e[10]!==v?(b=r.jsx(ze,{asChild:!0,children:v}),e[10]=v,e[11]=b):b=e[11];let y;e[12]!==f?(y=r.jsx(Ke,{children:f}),e[12]=f,e[13]=y):y=e[13];let _;return e[14]!==b||e[15]!==y?(_=r.jsxs(Ue,{children:[b,y]}),e[14]=b,e[15]=y,e[16]=_):_=e[16],_}function E2(t,e,s){return t.findIndex(n=>e(n)===s)}function Ju(t,e,s,n){return t.length===0?!1:t.every(i=>n(s[e(i)]))}function Xu(t,e,s,n,i){if(t.length===0)return null;const o=E2(t,e,i);for(let a=1;a<=t.length;a++){const l=t[(o+a)%t.length];if(!l)continue;const c=e(l);if(c!==i&&!n(s[c]))return c}return null}function w8(t){return!t.isStreaming&&t.allAnswered}function P2(t){const{parts:e,partKey:s,schema:n,defaultValues:i,isStreaming:o,hasAnswer:a,onSubmit:l}=t,c=e[0]?s(e[0]):"",[d,h]=A.useState(c),[u,f]=A.useState(!1),m=O0({resolver:em(n),defaultValues:i}),p=m.watch(),g=E2(e,s,d),x=g>=0?e[g]:void 0,v=a(p[d]),b=Ju(e,s,p,a),y=w8({isStreaming:o,allAnswered:b}),_=()=>{if(g>0){const V=e[g-1];V&&h(s(V))}},L=()=>{if(g>=0&&g<e.length-1){const V=e[g+1];V&&h(s(V))}},w=()=>{const V=m.getValues(),E=Xu(e,s,V,a,d);E&&h(E)},j=()=>{m.handleSubmit(V=>{const E=V;for(const T of e)l(T,E[s(T)])})()},S=A.useRef(j);S.current=j;const C=()=>{y&&(f(!1),S.current())},N=()=>{const V=m.getValues();if(Ju(e,s,V,a)){if(o){f(!0);return}f(!1),S.current()}else{const E=Xu(e,s,V,a,d);E&&h(E)}};return A.useEffect(()=>{if(u&&!o){if(!b){f(!1);return}f(!1),S.current()}},[u,o,b]),{form:m,activeKey:d,setActiveKey:h,currentIndex:g,currentPart:x,isCurrentAnswered:v,isAllAnswered:b,canSubmit:y,goPrev:_,goNext:L,advanceToNextUnanswered:w,submit:C,submitOrAdvance:N}}const R2="chat.approval.defaultDenyReason";function D2(t){const e=F.c(13),{onYolo:s}=t,n=re(),[i,o]=ni();let a;e[0]!==s||e[1]!==i||e[2]!==o?(a=m=>{const p=m,g=i.toolApprovalLevel??"readonly";o({...i,toolApprovalLevel:p}),p==="auto"&&s(g)},e[0]=s,e[1]=i,e[2]=o,e[3]=a):a=e[3];const l=a,c=i.toolApprovalLevel;let d;e[4]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(Jt,{size:"xs",className:"text-xs text-muted-foreground border-border/60 bg-transparent hover:bg-accent/60 h-7 gap-1",onClick:j8,children:r.jsx(as,{})}),e[4]=d):d=e[4];let h;e[5]!==n?(h=no.map(m=>r.jsx(vt,{value:m.value,children:n(m.labelKey)},m.value)),e[5]=n,e[6]=h):h=e[6];let u;e[7]!==h?(u=r.jsx(Xt,{children:h}),e[7]=h,e[8]=u):u=e[8];let f;return e[9]!==l||e[10]!==i.toolApprovalLevel||e[11]!==u?(f=r.jsxs(Qt,{value:c,onValueChange:l,children:[d,u]}),e[9]=l,e[10]=i.toolApprovalLevel,e[11]=u,e[12]=f):f=e[12],f}function j8(t){return t.stopPropagation()}function I2(t){const e=F.c(8),{input:s}=t,n=re();if(s==null){let a;e[0]!==n?(a=n("chat.approval.noInput"),e[0]=n,e[1]=a):a=e[1];let l;return e[2]!==a?(l=r.jsx("div",{className:"px-4 text-xs text-muted-foreground",children:a}),e[2]=a,e[3]=l):l=e[3],l}let i;try{let a;e[4]!==s?(a=JSON.stringify(s,null,2),e[4]=s,e[5]=a):a=e[5],i=a}catch{i=String(s)}let o;return e[6]!==i?(o=r.jsx("div",{className:"px-4",children:r.jsx("pre",{className:"text-xs font-mono text-muted-foreground/70 whitespace-pre-wrap wrap-break-word max-h-32 overflow-y-auto rounded-md bg-muted/30 px-3 py-2",children:i})}),e[6]=i,e[7]=o):o=e[7],o}function C8(t){const e=F.c(38),{approval:s,onRespond:n}=t,i=re(),[o]=ni(),a=o.toolApprovalLevel??"readonly";let l;e[0]!==s.approvalId||e[1]!==a||e[2]!==n||e[3]!==i?(l=()=>n(s.approvalId,!1,i(R2),a),e[0]=s.approvalId,e[1]=a,e[2]=n,e[3]=i,e[4]=l):l=e[4];const c=l;let d;e[5]!==s.approvalId||e[6]!==a||e[7]!==n?(d=()=>n(s.approvalId,!0,void 0,a),e[5]=s.approvalId,e[6]=a,e[7]=n,e[8]=d):d=e[8];const h=d;let u;e[9]!==s.approvalId||e[10]!==n?(u=C=>n(s.approvalId,!0,void 0,C),e[9]=s.approvalId,e[10]=n,e[11]=u):u=e[11];const f=u;let m;e[12]!==f?(m=r.jsx("div",{className:"flex items-center gap-2",children:r.jsx(D2,{onYolo:f})}),e[12]=f,e[13]=m):m=e[13];const p=m;let g;e[14]!==i?(g=i("chat.approval.denyButton"),e[14]=i,e[15]=g):g=e[15];let x;e[16]!==c||e[17]!==g?(x=r.jsx(le,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2.5 text-xs text-muted-foreground [@media(hover:hover)]:hover:text-foreground active:scale-[0.97] transition-transform",onClick:c,children:g}),e[16]=c,e[17]=g,e[18]=x):x=e[18];let v;e[19]!==i?(v=i("chat.approval.acceptButton"),e[19]=i,e[20]=v):v=e[20];let b;e[21]!==h||e[22]!==v?(b=r.jsx(le,{type:"button",size:"sm",className:"h-7 px-2.5 text-xs active:scale-[0.97] transition-transform",onClick:h,children:v}),e[21]=h,e[22]=v,e[23]=b):b=e[23];let y;e[24]!==x||e[25]!==b?(y=r.jsxs(r.Fragment,{children:[x,b]}),e[24]=x,e[25]=b,e[26]=y):y=e[26];const _=y;let L;e[27]===Symbol.for("react.memo_cache_sentinel")?(L=r.jsx(Wl,{size:14}),e[27]=L):L=e[27];let w;e[28]!==i?(w=i("chat.approval.needsApproval"),e[28]=i,e[29]=w):w=e[29];let j;e[30]!==s.input?(j=r.jsx(I2,{input:s.input}),e[30]=s.input,e[31]=j):j=e[31];let S;return e[32]!==s.friendlyName||e[33]!==p||e[34]!==_||e[35]!==w||e[36]!==j?(S=r.jsx(ei,{icon:L,label:w,title:s.friendlyName,defaultExpanded:!0,footerLeft:p,footerRight:_,children:j}),e[32]=s.friendlyName,e[33]=p,e[34]=_,e[35]=w,e[36]=j,e[37]=S):S=e[37],S}const k8=I5(rs(),tn({approved:M5().optional(),levelOverride:M0(["auto","readonly"]).optional()}));function V8(t){const e=F.c(46),{approvals:s,isStreaming:n,onRespond:i}=t,o=re(),[a]=ni(),l=a.toolApprovalLevel??"readonly";let c;e[0]!==s?(c=Object.fromEntries(s.map(A8)),e[0]=s,e[1]=c):c=e[1];const d=c;let h;e[2]!==l||e[3]!==i||e[4]!==o?(h=(E,T)=>{const k=T;typeof k?.approved=="boolean"&&i(E.approvalId,k.approved,k.approved===!1?o(R2):void 0,k.levelOverride??l)},e[2]=l,e[3]=i,e[4]=o,e[5]=h):h=e[5];let u;e[6]!==s||e[7]!==d||e[8]!==n||e[9]!==h?(u={parts:s,partKey:T8,schema:k8,defaultValues:d,isStreaming:n,hasAnswer:N8,onSubmit:h},e[6]=s,e[7]=d,e[8]=n,e[9]=h,e[10]=u):u=e[10];const f=P2(u);let m;e[11]!==s||e[12]!==f?(m=E=>{f.form.reset(Object.fromEntries(s.map(T=>[T.approvalId,{approved:!0,levelOverride:E}]))),f.submitOrAdvance()},e[11]=s,e[12]=f,e[13]=m):m=e[13];const p=m,g=f.currentPart,x=f.form;let v;e[14]!==f?(v=E=>{E.preventDefault(),f.submit()},e[14]=f,e[15]=v):v=e[15];let b;e[16]===Symbol.for("react.memo_cache_sentinel")?(b=r.jsx(Wl,{size:14}),e[16]=b):b=e[16];let y;e[17]!==s.length||e[18]!==o?(y=o("chat.approval.batchedLabel",{count:s.length}),e[17]=s.length,e[18]=o,e[19]=y):y=e[19];const _=g?.friendlyName??"";let L;e[20]!==p?(L=r.jsx(D2,{onYolo:p}),e[20]=p,e[21]=L):L=e[21];let w;e[22]!==s.length||e[23]!==f.currentIndex||e[24]!==f.goNext||e[25]!==f.goPrev||e[26]!==L?(w=r.jsx(A2,{currentIndex:f.currentIndex,total:s.length,onPrev:f.goPrev,onNext:f.goNext,extraLeft:L}),e[22]=s.length,e[23]=f.currentIndex,e[24]=f.goNext,e[25]=f.goPrev,e[26]=L,e[27]=w):w=e[27];let j;e[28]!==g||e[29]!==f.form.control||e[30]!==f.submitOrAdvance?(j=g?r.jsx(E8,{approvalId:g.approvalId,control:f.form.control,onChange:f.submitOrAdvance}):null,e[28]=g,e[29]=f.form.control,e[30]=f.submitOrAdvance,e[31]=j):j=e[31];let S;e[32]!==g?(S=g?r.jsx(I2,{input:g.input}):null,e[32]=g,e[33]=S):S=e[33];let C;e[34]!==w||e[35]!==j||e[36]!==S||e[37]!==y||e[38]!==_?(C=r.jsx(ei,{icon:b,label:y,title:_,defaultExpanded:!0,footerLeft:w,footerRight:j,children:S}),e[34]=w,e[35]=j,e[36]=S,e[37]=y,e[38]=_,e[39]=C):C=e[39];let N;e[40]!==C||e[41]!==v?(N=r.jsx("form",{onSubmit:v,children:C}),e[40]=C,e[41]=v,e[42]=N):N=e[42];let V;return e[43]!==f.form||e[44]!==N?(V=r.jsx(Nd,{...x,children:N}),e[43]=f.form,e[44]=N,e[45]=V):V=e[45],V}function N8(t){return typeof t?.approved=="boolean"}function T8(t){return t.approvalId}function A8(t){return[t.approvalId,{approved:void 0}]}function E8(t){const e=F.c(7),{approvalId:s,control:n,onChange:i}=t,o=re(),a=`${s}.approved`;let l;e[0]!==i||e[1]!==o?(l=d=>{const{field:h}=d,u=h.value===!0,f=h.value===!1;return r.jsxs(r.Fragment,{children:[r.jsx(le,{type:"button",variant:f?"secondary":"ghost",size:"sm",className:"h-7 px-2.5 text-xs",onClick:()=>{h.onChange(!1),i()},"aria-pressed":f,children:o("chat.approval.denyButton")}),r.jsx(le,{type:"button",variant:u?"default":"outline",size:"sm",className:"h-7 px-2.5 text-xs",onClick:()=>{h.onChange(!0),i()},"aria-pressed":u,children:o("chat.approval.acceptButton")})]})},e[0]=i,e[1]=o,e[2]=l):l=e[2];let c;return e[3]!==n||e[4]!==a||e[5]!==l?(c=r.jsx(_s,{control:n,name:a,render:l}),e[3]=n,e[4]=a,e[5]=l,e[6]=c):c=e[6],c}function P8(){const t=F.c(5),e=re();let s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(Wl,{className:"size-5 text-muted-foreground shimmer"}),t[0]=s):s=t[0];let n;t[1]!==e?(n=e("chat.approval.preparingRequest"),t[1]=e,t[2]=n):n=t[2];let i;return t[3]!==n?(i=r.jsxs("div",{className:"flex items-center gap-2 p-4 border border-dashed rounded-lg bg-accent/50 w-[calc(100%-16px)] max-w-[640px] mx-auto mb-2",children:[s,r.jsx("span",{className:"text-sm text-muted-foreground shimmer",children:n})]}),t[3]=n,t[4]=i):i=t[4],i}function R8(t){const e=F.c(8),{approvals:s,isStreaming:n,onRespond:i}=t;if(n&&s.length===0){let a;return e[0]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx(P8,{}),e[0]=a):a=e[0],a}if(s.length===0)return null;if(s.length===1){const a=s[0];if(!a)return null;let l;return e[1]!==i||e[2]!==a?(l=r.jsx(C8,{approval:a,onRespond:i}),e[1]=i,e[2]=a,e[3]=l):l=e[3],l}let o;return e[4]!==s||e[5]!==n||e[6]!==i?(o=r.jsx(V8,{approvals:s,isStreaming:n,onRespond:i}),e[4]=s,e[5]=n,e[6]=i,e[7]=o):o=e[7],o}function D8(t){const e=F.c(28),{plan:s,onApprove:n,onDismiss:i}=t,o=re();let a;e[0]!==n||e[1]!==s.plan?(a=()=>{n(s.plan)},e[0]=n,e[1]=s.plan,e[2]=a):a=e[2];const l=a;let c;e[3]!==o?(c=o("chat.proposePlan.keepIterating"),e[3]=o,e[4]=c):c=e[4];let d;e[5]!==i||e[6]!==c?(d=r.jsx(le,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2.5 text-xs text-muted-foreground [@media(hover:hover)]:hover:text-foreground active:scale-[0.97] transition-transform",onClick:i,children:c}),e[5]=i,e[6]=c,e[7]=d):d=e[7];let h;e[8]!==o?(h=o("chat.proposePlan.letsGo"),e[8]=o,e[9]=h):h=e[9];let u;e[10]!==l||e[11]!==h?(u=r.jsx(le,{type:"button",size:"sm",className:"h-7 px-2.5 text-xs bg-purple-600 hover:bg-purple-700 text-white active:scale-[0.97] transition-transform",onClick:l,children:h}),e[10]=l,e[11]=h,e[12]=u):u=e[12];let f;e[13]!==d||e[14]!==u?(f=r.jsxs(r.Fragment,{children:[d,u]}),e[13]=d,e[14]=u,e[15]=f):f=e[15];const m=f;let p;e[16]===Symbol.for("react.memo_cache_sentinel")?(p=r.jsx(Tm,{size:14}),e[16]=p):p=e[16];let g;e[17]!==o?(g=o("chat.proposePlan.planReady"),e[17]=o,e[18]=g):g=e[18];let x;e[19]!==o?(x=o("chat.proposePlan.implementationPlan"),e[19]=o,e[20]=x):x=e[20];let v;e[21]!==s.plan?(v=r.jsx("div",{className:"px-4 max-h-64 overflow-y-auto",children:r.jsx("div",{className:"prose prose-sm max-w-none text-sm",children:r.jsx(_x,{id:"plan-preview",part:{type:"text",text:s.plan}})})}),e[21]=s.plan,e[22]=v):v=e[22];let b;return e[23]!==m||e[24]!==v||e[25]!==g||e[26]!==x?(b=r.jsx(ei,{icon:p,label:g,title:x,defaultExpanded:!0,footerRight:m,children:v}),e[23]=m,e[24]=v,e[25]=g,e[26]=x,e[27]=b):b=e[27],b}function I8(t){const e=F.c(6),{plans:s,onApprove:n,onDismiss:i}=t;let o;e[0]!==s?(o=V2(s),e[0]=s,e[1]=o):o=e[1];const a=o;if(!a)return null;let l;return e[2]!==a||e[3]!==n||e[4]!==i?(l=r.jsx(D8,{plan:a,onApprove:n,onDismiss:i}),e[2]=a,e[3]=n,e[4]=i,e[5]=l):l=e[5],l}function M2(t){return t?"response"in t?t.response:t.option??t.draft:""}const Qu=tn({response:rs().min(1,"Response is required")}),M8=tn({option:rs().nullable(),draft:rs()}).refine(t=>(t.option??t.draft).length>0,{message:"Please select or enter an option"}),O8=tn({response:M0(["yes","no"])});function B8(t){switch(t.type){case"text":return Qu;case"choice":return M8;case"confirm":return O8;default:return Qu}}function $8(t){const e={};for(const s of t)e[s.toolCallId]=B8(s.input);return tn(e)}function F8(t){const e=F.c(7),{control:s,name:n,placeholder:i}=t,o=re();let a;e[0]!==i||e[1]!==o?(a=c=>{const{field:d}=c,h=d.value??"";return r.jsxs(e9,{children:[r.jsx(t9,{children:r.jsx("div",{className:"px-2",children:r.jsxs("div",{className:"flex items-center gap-3 px-2 py-3 rounded-lg bg-accent/50",children:[r.jsx("span",{className:"flex items-center justify-center size-6 rounded-md bg-muted shrink-0",children:r.jsx(W0,{size:16,className:"text-muted-foreground"})}),r.jsx("input",{...d,value:h,type:"text",placeholder:i||o("chat.userAskQuestion.typeResponse"),autoFocus:!0,"aria-label":o("chat.userAskQuestion.textResponseInputAriaLabel"),className:"flex-1 text-sm bg-transparent outline-none placeholder:text-foreground/25 text-foreground min-w-0"})]})})}),r.jsx(s9,{})]})},e[0]=i,e[1]=o,e[2]=a):a=e[2];let l;return e[3]!==s||e[4]!==n||e[5]!==a?(l=r.jsx(qm,{control:s,name:n,render:a}),e[3]=s,e[4]=n,e[5]=a,e[6]=l):l=e[6],l}function O2(t,e){const s=F.c(4);let n,i;s[0]!==t||s[1]!==e?(n=()=>{const o=a=>{const l=a.target.tagName;if(l==="INPUT"||l==="TEXTAREA"||a.metaKey||a.ctrlKey||a.altKey)return;const c=Number.parseInt(a.key,10);c>=1&&c<=t&&(a.preventDefault(),e(c-1))};return document.addEventListener("keydown",o),()=>document.removeEventListener("keydown",o)},i=[t,e],s[0]=t,s[1]=e,s[2]=n,s[3]=i):(n=s[2],i=s[3]),A.useEffect(n,i)}function z8(t){const e=F.c(51),{control:s,name:n,options:i}=t,o=re(),a=`${n}.option`;let l;e[0]!==s||e[1]!==a?(l={control:s,name:a,defaultValue:null},e[0]=s,e[1]=a,e[2]=l):l=e[2];const{field:c}=Mu(l),d=`${n}.draft`;let h;e[3]!==s||e[4]!==d?(h={control:s,name:d,defaultValue:""},e[3]=s,e[4]=d,e[5]=h):h=e[5];const{field:u}=Mu(h),f=c.value,m=u.value??"";let p;if(e[6]!==c||e[7]!==i?(p=P=>{const D=i[P];D!=null&&c.onChange(D)},e[6]=c,e[7]=i,e[8]=p):p=e[8],O2(i.length,p),i.length===0)return null;const g=f===null;let x;e[9]!==o?(x=o("chat.userAskQuestion.choiceOptionsAriaLabel"),e[9]=o,e[10]=x):x=e[10];let v;if(e[11]!==c||e[12]!==f||e[13]!==i||e[14]!==o){let P;e[16]!==c||e[17]!==f||e[18]!==o?(P=(D,I)=>{const M=f===D;return r.jsxs("button",{type:"button",onClick:()=>c.onChange(D),className:ie("flex items-start gap-3 px-2 py-3 rounded-lg text-left transition-colors w-full",M&&"bg-accent/50",!M&&"hover:bg-accent/30"),"aria-label":o("chat.userAskQuestion.selectOption",{option:D}),children:[r.jsx("span",{className:ie("flex items-center justify-center size-6 rounded-md text-sm shrink-0 mt-0.5",M?"bg-chart-1 text-white":"bg-muted text-foreground"),children:I+1}),r.jsx("span",{className:"text-sm text-foreground min-w-0 break-words",children:D})]},`${I}-${D}`)},e[16]=c,e[17]=f,e[18]=o,e[19]=P):P=e[19],v=i.map(P),e[11]=c,e[12]=f,e[13]=i,e[14]=o,e[15]=v}else v=e[15];const b=g&&"bg-accent/50",y=!g&&"hover:bg-accent/30";let _;e[20]!==b||e[21]!==y?(_=ie("flex items-center gap-3 px-2 py-3 rounded-lg transition-colors w-full cursor-text",b,y),e[20]=b,e[21]=y,e[22]=_):_=e[22];let L;e[23]===Symbol.for("react.memo_cache_sentinel")?(L=r.jsx("span",{className:"flex items-center justify-center size-6 rounded-md bg-muted shrink-0",children:r.jsx(W0,{size:16,className:"text-muted-foreground"})}),e[23]=L):L=e[23];const w=g?m:"";let j;e[24]!==u||e[25]!==c||e[26]!==f?(j=P=>{u.onChange(P.target.value),f!==null&&c.onChange(null)},e[24]=u,e[25]=c,e[26]=f,e[27]=j):j=e[27];let S;e[28]!==c||e[29]!==f?(S=()=>{f!==null&&c.onChange(null)},e[28]=c,e[29]=f,e[30]=S):S=e[30];let C;e[31]!==o?(C=o("chat.userAskQuestion.somethingElsePlaceholder"),e[31]=o,e[32]=C):C=e[32];let N;e[33]!==o?(N=o("chat.userAskQuestion.customChoiceInputAriaLabel"),e[33]=o,e[34]=N):N=e[34];let V;e[35]!==w||e[36]!==j||e[37]!==S||e[38]!==C||e[39]!==N?(V=r.jsx("input",{type:"text",value:w,onChange:j,onFocus:S,placeholder:C,"aria-label":N,className:"flex-1 text-sm bg-transparent outline-none placeholder:text-foreground/25 text-foreground min-w-0"}),e[35]=w,e[36]=j,e[37]=S,e[38]=C,e[39]=N,e[40]=V):V=e[40];let E;e[41]!==_||e[42]!==V?(E=r.jsxs("label",{className:_,children:[L,V]}),e[41]=_,e[42]=V,e[43]=E):E=e[43];let T;e[44]!==E||e[45]!==x||e[46]!==v?(T=r.jsx(t9,{children:r.jsxs("div",{className:"flex flex-col px-2",role:"group","aria-label":x,children:[v,E]})}),e[44]=E,e[45]=x,e[46]=v,e[47]=T):T=e[47];let k;e[48]===Symbol.for("react.memo_cache_sentinel")?(k=r.jsx(s9,{}),e[48]=k):k=e[48];let R;return e[49]!==T?(R=r.jsxs(e9,{children:[T,k]}),e[49]=T,e[50]=R):R=e[50],R}function K8(t){const e=F.c(8),{control:s,name:n}=t,i=re();let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=["yes","no"],e[0]=o):o=e[0];const a=o,l=A.useRef(null);let c;e[1]===Symbol.for("react.memo_cache_sentinel")?(c=u=>{l.current?.onChange(a[u]??"")},e[1]=c):c=e[1],O2(a.length,c);let d;e[2]!==i?(d=u=>{const{field:f}=u;return l.current=f,r.jsxs(e9,{children:[r.jsx(t9,{children:r.jsx("div",{className:"flex gap-2 px-2",role:"group","aria-label":i("chat.userAskQuestion.confirmationOptionsAriaLabel"),children:a.map(m=>{const p=f.value===m;return r.jsxs("button",{type:"button",onClick:()=>f.onChange(m),className:ie("flex items-center gap-3 px-4 py-3 rounded-lg text-left transition-colors flex-1",p&&"bg-accent/50",!p&&"hover:bg-accent/30"),"aria-label":i("chat.userAskQuestion.confirmValue",{value:i(`chat.userAskQuestion.confirm${m==="yes"?"Yes":"No"}`)}),children:[r.jsx("span",{className:ie("flex items-center justify-center size-6 rounded-md text-sm shrink-0",p?"bg-chart-1 text-white":"bg-muted text-foreground"),children:m==="yes"?1:2}),r.jsx("span",{className:"text-sm text-foreground capitalize",children:i(`chat.userAskQuestion.confirm${m==="yes"?"Yes":"No"}`)})]},m)})})}),r.jsx(s9,{})]})},e[2]=i,e[3]=d):d=e[3];let h;return e[4]!==s||e[5]!==n||e[6]!==d?(h=r.jsx(qm,{control:s,name:n,render:d}),e[4]=s,e[5]=n,e[6]=d,e[7]=h):h=e[7],h}function Zu(t){const e=F.c(13),{input:s,control:n,toolCallId:i}=t;switch(s.type){case"text":{const o=`${i}.response`;let a;return e[0]!==n||e[1]!==s.default||e[2]!==o?(a=r.jsx(F8,{control:n,name:o,placeholder:s.default}),e[0]=n,e[1]=s.default,e[2]=o,e[3]=a):a=e[3],a}case"choice":{let o;e[4]!==s.options?(o=s.options?.filter(Boolean)??[],e[4]=s.options,e[5]=o):o=e[5];const a=o;let l;return e[6]!==n||e[7]!==a||e[8]!==i?(l=r.jsx(z8,{control:n,name:i,options:a}),e[6]=n,e[7]=a,e[8]=i,e[9]=l):l=e[9],l}case"confirm":{const o=`${i}.response`;let a;return e[10]!==n||e[11]!==o?(a=r.jsx(K8,{control:n,name:o}),e[10]=n,e[11]=o,e[12]=a):a=e[12],a}default:return null}}function U8(t){const e=F.c(91),{parts:s,isStreaming:n,onSubmit:i}=t;let o;e[0]!==s?(o=$8(s.map(G8)),e[0]=s,e[1]=o):o=e[1];const a=o;let l;e[2]!==s?(l=Object.fromEntries(s.map(q8)),e[2]=s,e[3]=l):l=e[3];const c=l;let d;e[4]!==i?(d=($,B)=>{const z=M2(B);z&&i($,z)},e[4]=i,e[5]=d):d=e[5];let h;e[6]!==c||e[7]!==n||e[8]!==s||e[9]!==a||e[10]!==d?(h={parts:s,partKey:W8,schema:a,defaultValues:c,isStreaming:n,hasAnswer:H8,onSubmit:d},e[6]=c,e[7]=n,e[8]=s,e[9]=a,e[10]=d,e[11]=h):h=e[11];const u=P2(h),f=u.currentPart,m=re();let p;e[12]!==f||e[13]!==u||e[14]!==m?(p=()=>{const $=f;if(!$)return;const B=m("chat.userAskQuestion.skipMessage"),z=$.toolCallId;$.input?.type==="choice"?(u.form.setValue(`${z}.option`,null),u.form.setValue(`${z}.draft`,B)):u.form.setValue(`${z}.response`,B),u.advanceToNextUnanswered()},e[12]=f,e[13]=u,e[14]=m,e[15]=p):p=e[15];const g=p;let x;e[16]!==u.currentIndex||e[17]!==u.goNext||e[18]!==u.goPrev||e[19]!==s.length?(x=r.jsx(A2,{currentIndex:u.currentIndex,total:s.length,onPrev:u.goPrev,onNext:u.goNext}),e[16]=u.currentIndex,e[17]=u.goNext,e[18]=u.goPrev,e[19]=s.length,e[20]=x):x=e[20];const v=x;let b;e[21]!==m?(b=m("chat.userAskQuestion.skip"),e[21]=m,e[22]=b):b=e[22];let y;e[23]!==g||e[24]!==b?(y=r.jsx(le,{type:"button",variant:"outline",size:"sm",onClick:g,className:"h-7",children:b}),e[23]=g,e[24]=b,e[25]=y):y=e[25];let _;e[26]!==u.isAllAnswered||e[27]!==u.isCurrentAnswered||e[28]!==u.submitOrAdvance||e[29]!==n?(_=r.jsx(S8,{isStreaming:n,isAllAnswered:u.isAllAnswered,isCurrentAnswered:u.isCurrentAnswered,onAdvanceOrSubmit:u.submitOrAdvance}),e[26]=u.isAllAnswered,e[27]=u.isCurrentAnswered,e[28]=u.submitOrAdvance,e[29]=n,e[30]=_):_=e[30];let L;e[31]!==y||e[32]!==_?(L=r.jsxs(r.Fragment,{children:[y,_]}),e[31]=y,e[32]=_,e[33]=L):L=e[33];const w=L;if(s.length===1){const $=s[0];if(!$?.input)return null;const B=u.form;let z;e[34]!==u?(z=Z=>{Z.preventDefault(),u.submit()},e[34]=u,e[35]=z):z=e[35];let K;e[36]===Symbol.for("react.memo_cache_sentinel")?(K=r.jsx(Td,{size:14}),e[36]=K):K=e[36];let G;e[37]!==m?(G=m("chat.userAskQuestion.questionPending"),e[37]=m,e[38]=G):G=e[38];let Y;e[39]!==$.input?.prompt||e[40]!==m?(Y=$.input?.prompt??m("chat.userAskQuestion.question"),e[39]=$.input?.prompt,e[40]=m,e[41]=Y):Y=e[41];const U=$.input;let W;e[42]!==u.form.control||e[43]!==$.toolCallId||e[44]!==U?(W=r.jsx(Zu,{input:U,control:u.form.control,toolCallId:$.toolCallId}),e[42]=u.form.control,e[43]=$.toolCallId,e[44]=U,e[45]=W):W=e[45];let H;e[46]!==w||e[47]!==G||e[48]!==Y||e[49]!==W?(H=r.jsx(ei,{icon:K,label:G,title:Y,defaultExpanded:!0,footerRight:w,children:W}),e[46]=w,e[47]=G,e[48]=Y,e[49]=W,e[50]=H):H=e[50];let X;e[51]!==z||e[52]!==H?(X=r.jsx("form",{onSubmit:z,autoComplete:"off",children:H}),e[51]=z,e[52]=H,e[53]=X):X=e[53];let q;return e[54]!==u.form||e[55]!==X?(q=r.jsx(Nd,{...B,children:X}),e[54]=u.form,e[55]=X,e[56]=q):q=e[56],q}const j=u.form;let S;e[57]!==u?(S=$=>{$.preventDefault(),u.submit()},e[57]=u,e[58]=S):S=e[58];let C;e[59]===Symbol.for("react.memo_cache_sentinel")?(C=r.jsx(Td,{size:14}),e[59]=C):C=e[59];let N;e[60]!==m?(N=m("chat.userAskQuestion.questionPending"),e[60]=m,e[61]=N):N=e[61];const V=u.currentIndex+1;let E;e[62]!==s.length||e[63]!==m||e[64]!==V?(E=m("chat.userAskQuestion.questionCount",{current:V,total:s.length}),e[62]=s.length,e[63]=m,e[64]=V,e[65]=E):E=e[65];let T;e[66]!==f?.input?.prompt||e[67]!==m?(T=f?.input?.prompt??m("chat.userAskQuestion.question"),e[66]=f?.input?.prompt,e[67]=m,e[68]=T):T=e[68];const k=u.activeKey,R=u.setActiveKey;let P;if(e[69]!==u.form||e[70]!==s){let $;e[72]!==u.form?($=B=>r.jsx(_i,{value:B.toolCallId,className:"mt-0",children:r.jsx(Zu,{input:B.input,control:u.form.control,toolCallId:B.toolCallId})},B.toolCallId),e[72]=u.form,e[73]=$):$=e[73],P=s.map($),e[69]=u.form,e[70]=s,e[71]=P}else P=e[71];let D;e[74]!==u.activeKey||e[75]!==u.setActiveKey||e[76]!==P?(D=r.jsx(Vr,{value:k,onValueChange:R,children:P}),e[74]=u.activeKey,e[75]=u.setActiveKey,e[76]=P,e[77]=D):D=e[77];let I;e[78]!==v||e[79]!==w||e[80]!==N||e[81]!==E||e[82]!==T||e[83]!==D?(I=r.jsx(ei,{icon:C,label:N,count:E,title:T,defaultExpanded:!0,footerLeft:v,footerRight:w,children:D}),e[78]=v,e[79]=w,e[80]=N,e[81]=E,e[82]=T,e[83]=D,e[84]=I):I=e[84];let M;e[85]!==S||e[86]!==I?(M=r.jsx("form",{onSubmit:S,autoComplete:"off",children:I}),e[85]=S,e[86]=I,e[87]=M):M=e[87];let O;return e[88]!==u.form||e[89]!==M?(O=r.jsx(Nd,{...j,children:M}),e[88]=u.form,e[89]=M,e[90]=O):O=e[90],O}function H8(t){return!!M2(t)}function W8(t){return t.toolCallId}function q8(t){return t.input?.type==="choice"?[t.toolCallId,{option:null,draft:""}]:[t.toolCallId,{response:""}]}function G8(t){return{toolCallId:t.toolCallId,input:t.input}}function Y8(){const t=F.c(5),e=re();let s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(Td,{className:"size-5 text-muted-foreground shimmer"}),t[0]=s):s=t[0];let n;t[1]!==e?(n=e("chat.userAskQuestion.preparingQuestion"),t[1]=e,t[2]=n):n=t[2];let i;return t[3]!==n?(i=r.jsxs("div",{className:"flex items-center gap-2 p-4 border border-dashed rounded-lg bg-accent/50 w-[calc(100%-16px)] max-w-[640px] mx-auto mb-2",children:[s,r.jsx("span",{className:"text-sm text-muted-foreground shimmer",children:n})]}),t[3]=n,t[4]=i):i=t[4],i}function B2(t){const e=F.c(7),{userAskParts:s,isStreaming:n,onSubmit:i}=t;let o;e[0]!==s?(o=s.filter(J8),e[0]=s,e[1]=o):o=e[1];const a=o;if(a.length===0){if(n){let c;return e[2]===Symbol.for("react.memo_cache_sentinel")?(c=r.jsx(Y8,{}),e[2]=c):c=e[2],c}return null}let l;return e[3]!==n||e[4]!==i||e[5]!==a?(l=r.jsx(U8,{parts:a,isStreaming:n,onSubmit:i}),e[3]=n,e[4]=i,e[5]=a,e[6]=l):l=e[6],l}function J8(t){return t.state==="input-available"}function X8(t){const e=t.filter(o=>o.status==="in_progress"),s=t.filter(o=>o.status==="completed").length,n=t.length;if(n>0&&s===n)return{icon:"completed",activity:"All done",progress:`${n}/${n}`};const[i]=e;return i&&e.length===1?{icon:"in_progress",activity:i.activeForm,progress:`${s}/${n} done`}:e.length>1?{icon:"in_progress",activity:`${e.length} in progress`,progress:`${s}/${n} done`}:s>0?{icon:"pending",activity:`${n-s} pending`,progress:`${s}/${n} done`}:{icon:"pending",activity:`${n} todos`,progress:"not started"}}function Q8(t){const e=F.c(13),{todos:s}=t;if(s.length===0)return null;let n;e[0]!==s?(n=X8(s),e[0]=s,e[1]=n):n=e[1];const i=n;let o;e[2]!==i.icon?(o=r.jsx(s_,{status:i.icon}),e[2]=i.icon,e[3]=o):o=e[3];const a=i.activity,l=i.progress;let c;e[4]!==s?(c=s.map(Z8),e[4]=s,e[5]=c):c=e[5];let d;e[6]!==c?(d=r.jsx("ul",{"data-testid":"todos-list",className:"flex flex-col px-2 max-h-[40vh] overflow-y-auto",children:c}),e[6]=c,e[7]=d):d=e[7];let h;return e[8]!==i.activity||e[9]!==i.progress||e[10]!==o||e[11]!==d?(h=r.jsx(ei,{icon:o,label:a,count:l,defaultExpanded:!1,children:d}),e[8]=i.activity,e[9]=i.progress,e[10]=o,e[11]=d,e[12]=h):h=e[12],h}function Z8(t,e){return r.jsx(e_,{todo:t},e)}function e_(t){const e=F.c(14),{todo:s}=t,n=s.status==="completed",o=s.status==="in_progress"?s.activeForm:s.content;let a;e[0]!==s.status?(a=r.jsx(t_,{status:s.status}),e[0]=s.status,e[1]=a):a=e[1];const l=n&&"text-muted-foreground";let c;e[2]!==l?(c=ie("relative text-sm leading-snug pt-px select-none",l),e[2]=l,e[3]=c):c=e[3];const d=n?"100%":"0%",h=n?"width 300ms ease 200ms":"width 150ms ease";let u;e[4]!==d||e[5]!==h?(u=r.jsx("span",{"aria-hidden":"true",style:{position:"absolute",left:0,top:"50%",height:"1px",background:"currentColor",width:d,transition:h}}),e[4]=d,e[5]=h,e[6]=u):u=e[6];let f;e[7]!==o||e[8]!==c||e[9]!==u?(f=r.jsxs("span",{className:c,children:[o,u]}),e[7]=o,e[8]=c,e[9]=u,e[10]=f):f=e[10];let m;return e[11]!==a||e[12]!==f?(m=r.jsxs("li",{className:"flex items-start gap-2.5 px-2 py-1.5 rounded-lg hover:bg-accent/50 transition-colors",children:[a,f]}),e[11]=a,e[12]=f,e[13]=m):m=e[13],m}function t_(t){const e=F.c(4),{status:s}=t,n=s==="completed"?"true":void 0,i=s==="in_progress"?"true":void 0;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx("svg",{viewBox:"0 0 21 21",children:r.jsx("path",{d:"M5,10.75 L8.5,14.25 L19.4,2.3 C18.8333333,1.43333333 18.0333333,1 17,1 L4,1 C2.35,1 1,2.35 1,4 L1,17 C1,18.65 2.35,20 4,20 L17,20 C18.65,20 20,18.65 20,17 L20,7.99769186"})}),e[0]=o):o=e[0];let a;return e[1]!==n||e[2]!==i?(a=r.jsx("div",{className:"todo-cb mt-0.5","data-checked":n,"data-progress":i,"aria-hidden":"true",children:o}),e[1]=n,e[2]=i,e[3]=a):a=e[3],a}function s_(t){const e=F.c(3),{status:s}=t;if(s==="completed"){let i;return e[0]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx("span",{"aria-label":"completed",className:"inline-flex items-center justify-center w-3.5 h-3.5 rounded-sm bg-primary",children:r.jsx("svg",{viewBox:"0 0 10 8",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",className:"w-2 h-2 text-primary-foreground",style:{strokeWidth:2},children:r.jsx("path",{d:"M1 4l2.5 2.5L9 1"})})}),e[0]=i):i=e[0],i}if(s==="in_progress"){let i;return e[1]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx("span",{"aria-label":"in progress",className:"inline-block w-2 h-2 rounded-full bg-primary animate-pulse shrink-0"}),e[1]=i):i=e[1],i}let n;return e[2]===Symbol.for("react.memo_cache_sentinel")?(n=r.jsx("span",{"aria-label":"pending",className:"inline-block w-3.5 h-3.5 rounded-sm border-[1.5px] border-muted-foreground/50 shrink-0"}),e[2]=n):n=e[2],n}const n_={usd:[{dollars:10,labelKey:"chat.creditsExhaustedBanner.tierStarter"},{dollars:20,labelKey:"chat.creditsExhaustedBanner.tierPopular"},{dollars:100,labelKey:"chat.creditsExhaustedBanner.tierBestValue"}],brl:[{dollars:50,labelKey:"chat.creditsExhaustedBanner.tierStarter"},{dollars:100,labelKey:"chat.creditsExhaustedBanner.tierPopular"},{dollars:500,labelKey:"chat.creditsExhaustedBanner.tierBestValue"}]},i_=["chat.creditsExhaustedBanner.benefit1","chat.creditsExhaustedBanner.benefit2","chat.creditsExhaustedBanner.benefit3"];function $2(t){const e=F.c(65),{onDismiss:s}=t,{org:n}=Oe(),i=St(),{decoKeyId:o}=i9(),a=$s(),l=re(),[c,d]=A.useState(""),[h,u]=A.useState(!1),[f,m]=A.useState("usd"),p=f==="brl"?"R$":"$";let g,x;e[0]!==n.id?(g=()=>{Me("credits_exhausted_shown",{organization_id:n.id})},x=[n.id],e[0]=n.id,e[1]=g,e[2]=x):(g=e[1],x=e[2]),A.useEffect(g,x);let v;e[3]!==f||e[4]!==a?(v=async U=>{const{url:W}=await a.call("AI_PROVIDER_TOPUP_URL",{providerId:"deco",amountCents:U,currency:f});return W},e[3]=f,e[4]=a,e[5]=v):v=e[5];let b;e[6]!==s?(b=U=>{U&&window.open(U,"_blank","noopener,noreferrer"),s?.()},e[6]=s,e[7]=b):b=e[7];let y;e[8]!==l?(y=U=>{ge.error(l("chat.creditsExhaustedBanner.topupError",{error:U.message}))},e[8]=l,e[9]=y):y=e[9];let _;e[10]!==v||e[11]!==b||e[12]!==y?(_={mutationFn:v,onSuccess:b,onError:y},e[10]=v,e[11]=b,e[12]=y,e[13]=_):_=e[13];const{mutate:L,isPending:w}=Ys(_),j=parseFloat(c),S=!isNaN(j)&&j>=1;let C;e[14]!==s?(C=U=>!U&&s?.(),e[14]=s,e[15]=C):C=e[15];let N;e[16]===Symbol.for("react.memo_cache_sentinel")?(N=["radial-gradient(ellipse 40% 200% at -5% 100%, rgba(165,149,255,0.5) 0%, transparent 100%)","radial-gradient(ellipse 40% 200% at 105% -10%, rgba(208,236,26,0.45) 0%, transparent 100%)"],e[16]=N):N=e[16];let V;e[17]===Symbol.for("react.memo_cache_sentinel")?(V=r.jsx("div",{className:"absolute inset-x-0 top-0 h-36 pointer-events-none",style:{backgroundImage:N.join(", "),maskImage:"linear-gradient(to bottom, black 0%, transparent 100%)",WebkitMaskImage:"linear-gradient(to bottom, black 0%, transparent 100%)"}}),e[17]=V):V=e[17];let E;e[18]===Symbol.for("react.memo_cache_sentinel")?(E=r.jsx("img",{src:"/logos/deco%20logo.svg",alt:"Deco AI Gateway",className:"size-9 rounded-lg object-contain dark:bg-white dark:p-0.5"}),e[18]=E):E=e[18];let T;e[19]!==l?(T=l("chat.creditsExhaustedBanner.title"),e[19]=l,e[20]=T):T=e[20];let k;e[21]!==T?(k=r.jsx(ps,{className:"text-xl font-semibold tracking-tight",children:T}),e[21]=T,e[22]=k):k=e[22];let R;e[23]!==l?(R=l("chat.creditsExhaustedBanner.description"),e[23]=l,e[24]=R):R=e[24];let P;e[25]!==R?(P=r.jsx(ri,{className:"mt-1.5 text-sm leading-relaxed",children:R}),e[25]=R,e[26]=P):P=e[26];let D;e[27]!==k||e[28]!==P?(D=r.jsxs("div",{className:"relative px-8 pt-8 pb-2 overflow-hidden",children:[V,r.jsxs(ms,{className:"relative gap-4",children:[E,r.jsxs("div",{children:[k,P]})]})]}),e[27]=k,e[28]=P,e[29]=D):D=e[29];let I;e[30]!==f||e[31]!==p||e[32]!==c||e[33]!==j||e[34]!==o||e[35]!==S||e[36]!==w||e[37]!==h||e[38]!==l||e[39]!==L?(I=o&&r.jsxs("div",{className:"px-8 pt-5 pb-6",children:[r.jsx("div",{className:"mb-4",children:r.jsxs(n9,{type:"single",variant:"outline",size:"sm",value:f,onValueChange:U=>{U&&m(U)},children:[r.jsx(To,{value:"usd",className:"h-8 px-3 text-xs",children:"USD"}),r.jsx(To,{value:"brl",className:"h-8 px-3 text-xs",children:"BRL"})]})}),r.jsxs("div",{className:"rounded-xl border border-border p-5",children:[r.jsx("div",{className:"grid grid-cols-3 gap-2.5",children:n_[f].map(U=>{const{dollars:W,labelKey:H}=U;return r.jsxs("button",{type:"button",disabled:w,onClick:()=>{Me("credits_topup_clicked",{amount_cents:W*100,currency:f,tier_label:H,source:"exhausted_banner"}),L(W*100)},className:ie("relative flex flex-col items-center gap-1 py-5 rounded-xl border transition-all duration-150 cursor-pointer","disabled:opacity-50 disabled:cursor-wait","border-border hover:border-foreground/20 hover:bg-muted/30"),children:[r.jsxs("span",{className:"text-2xl font-semibold tabular-nums text-foreground",children:[p,W]}),r.jsx("span",{className:"text-xs text-muted-foreground",children:l(H)})]},W)})}),h?r.jsxs("div",{className:"flex gap-2 mt-3",children:[r.jsxs("div",{className:"relative flex-1",children:[r.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-sm text-muted-foreground select-none",children:p}),r.jsx(rt,{type:"number",min:"1",step:"1",placeholder:l("chat.creditsExhaustedBanner.customPlaceholder"),value:c,onChange:U=>d(U.target.value),className:"h-10 text-sm pl-7",autoFocus:!0})]}),r.jsx(le,{className:"h-10",disabled:!S||w,onClick:()=>{Me("credits_topup_clicked",{amount_cents:Math.round(j*100),currency:f,tier_label:"custom",source:"exhausted_banner"}),L(Math.round(j*100))},children:l(w?"chat.creditsExhaustedBanner.opening":"chat.creditsExhaustedBanner.add")})]}):r.jsx("button",{type:"button",className:"w-full mt-3 text-xs text-muted-foreground hover:text-foreground transition-colors py-1",onClick:()=>u(!0),children:l("chat.creditsExhaustedBanner.enterCustom")})]}),r.jsx("div",{className:"mt-5 rounded-xl bg-muted/25 border border-border/50 p-4 space-y-3",children:i_.map(U=>r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"flex items-center justify-center size-5 rounded-full bg-[hsl(var(--chart-1))]/15 shrink-0",children:r.jsx(zt,{size:12,className:"text-[hsl(var(--chart-1))]"})}),r.jsx("span",{className:"text-sm text-foreground/80",children:l(U)})]},U))})]}),e[30]=f,e[31]=p,e[32]=c,e[33]=j,e[34]=o,e[35]=S,e[36]=w,e[37]=h,e[38]=l,e[39]=L,e[40]=I):I=e[40];let M;e[41]!==l?(M=l("chat.creditsExhaustedBanner.dismiss"),e[41]=l,e[42]=M):M=e[42];let O;e[43]!==s||e[44]!==M?(O=r.jsx(le,{variant:"ghost",size:"sm",onClick:s,children:M}),e[43]=s,e[44]=M,e[45]=O):O=e[45];let $;e[46]!==i||e[47]!==s||e[48]!==n.slug?($=()=>{i({to:"/$org/settings/ai-providers",params:{org:n.slug}}),s?.()},e[46]=i,e[47]=s,e[48]=n.slug,e[49]=$):$=e[49];let B;e[50]!==l?(B=l("chat.creditsExhaustedBanner.manageProviders"),e[50]=l,e[51]=B):B=e[51];let z;e[52]!==$||e[53]!==B?(z=r.jsx("button",{type:"button",className:"text-xs text-muted-foreground hover:text-foreground transition-colors",onClick:$,children:B}),e[52]=$,e[53]=B,e[54]=z):z=e[54];let K;e[55]!==O||e[56]!==z?(K=r.jsxs("div",{className:"px-8 py-4 border-t border-border bg-muted/30 flex items-center justify-between",children:[O,z]}),e[55]=O,e[56]=z,e[57]=K):K=e[57];let G;e[58]!==D||e[59]!==I||e[60]!==K?(G=r.jsxs(es,{className:"sm:max-w-[520px] gap-0 p-0 overflow-hidden",onOpenAutoFocus:r_,children:[D,I,K]}),e[58]=D,e[59]=I,e[60]=K,e[61]=G):G=e[61];let Y;return e[62]!==G||e[63]!==C?(Y=r.jsx(ts,{open:!0,onOpenChange:C,children:G}),e[62]=G,e[63]=C,e[64]=Y):Y=e[64],Y}function r_(t){return t.preventDefault()}function o_(){const t=F.c(24),e=re(),s=Ii(),n=dm(),[i,o]=A.useState(!1);if(!(s?.lockedSandbox==="user-desktop")||!n.ready||n.online)return null;let l;t[0]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(Nr,{size:14}),t[0]=l):l=t[0];let c;t[1]!==e?(c=e("chat.desktopOfflineBanner.label"),t[1]=e,t[2]=c):c=t[2];let d;t[3]!==e?(d=e("chat.desktopOfflineBanner.title"),t[3]=e,t[4]=d):d=t[4];let h;t[5]===Symbol.for("react.memo_cache_sentinel")?(h=()=>o(!0),t[5]=h):h=t[5];let u;t[6]!==e?(u=e("chat.desktopOfflineBanner.reconnectButton"),t[6]=e,t[7]=u):u=t[7];let f;t[8]!==u?(f=r.jsx(le,{size:"sm",variant:"outline",className:"h-7 text-xs",onClick:h,children:u}),t[8]=u,t[9]=f):f=t[9];let m;t[10]!==e?(m=e("chat.desktopOfflineBanner.instructions"),t[10]=e,t[11]=m):m=t[11];let p;t[12]!==m?(p=r.jsx("p",{className:"mx-4 text-xs text-muted-foreground",children:m}),t[12]=m,t[13]=p):p=t[13];let g;t[14]!==c||t[15]!==d||t[16]!==f||t[17]!==p?(g=r.jsx(ei,{icon:l,label:c,title:d,defaultExpanded:!0,variant:"warning",footerRight:f,children:p}),t[14]=c,t[15]=d,t[16]=f,t[17]=p,t[18]=g):g=t[18];let x;t[19]!==i?(x=r.jsx(x6,{open:i,onOpenChange:o}),t[19]=i,t[20]=x):x=t[20];let v;return t[21]!==g||t[22]!==x?(v=r.jsxs(r.Fragment,{children:[g,x]}),t[21]=g,t[22]=x,t[23]=v):v=t[23],v}function a_(t){const e=t.trim(),s=e.startsWith("<")&&/<[a-z][\s\S]*>/i.test(e),n=/cloudflare|cf-[a-z-]+|error[\s_-]?code[\s_-]?5\d\d/i.test(e),i=/failed to fetch|networkerror|load failed|offline/i.test(e),o=/timeout|timed out|aborted|deadline/i.test(e),a=e.length>240,l=/sandbox failed to start(?::\s*(.+))?/is.exec(e);if(l){const c=l[1]?.trim().replace(/\.$/,"");return{summary:c?`Your sandbox didn't finish starting up (${c}). Try again.`:"Your sandbox didn't finish starting up. Try again.",rawDetails:t}}return/link_unavailable|user_desktop_link_/i.test(e)?/user_desktop_link_capability_missing/i.test(e)?{summary:"Your desktop is connected, but the CLI this chat uses wasn't detected there. Install it and sign in on your desktop, then try again.",rawDetails:t}:{summary:"Your desktop is offline. Run `bunx decocms@latest link` in a terminal on it, then try again.",rawDetails:t}:n||s&&a?{summary:"Our servers are having a moment. Try sending again in a few seconds.",rawDetails:t}:i?{summary:"Lost connection. Check your network and try again.",rawDetails:t}:o?{summary:"That took longer than expected. Try again.",rawDetails:t}:s||a?{summary:"Something unexpected came back from the server. Try again.",rawDetails:t}:{summary:t,rawDetails:null}}const l_={length:"chat.highlight.warningDescriptionLength","content-filter":"chat.highlight.warningDescriptionContentFilter","tool-calls":"chat.highlight.warningDescriptionToolCalls"};function xl(t){const e=F.c(29),s=re(),{variant:n,onDismiss:i}=t,o=n==="error";let a;e[0]!==o||e[1]!==s?(a=s(o?"chat.highlight.errorOccurred":"chat.highlight.responseIncomplete"),e[0]=o,e[1]=s,e[2]=a):a=e[2];const l=a,c=o?wn:Sr;let d;e[3]!==t.error||e[4]!==t.finishReason||e[5]!==t.variant||e[6]!==s?(d=t.variant==="error"?t.error.message:(()=>{const b=l_[t.finishReason];return b?s(b):s("chat.highlight.responseStoppedUnexpectedly",{reason:t.finishReason})})(),e[3]=t.error,e[4]=t.finishReason,e[5]=t.variant,e[6]=s,e[7]=d):d=e[7];const h=d;let u;e[8]!==o||e[9]!==h?(u=o?a_(h):{summary:h,rawDetails:null},e[8]=o,e[9]=h,e[10]=u):u=e[10];const{summary:f,rawDetails:m}=u;let p;e[11]!==c?(p=r.jsx(c,{size:14}),e[11]=c,e[12]=p):p=e[12];let g;e[13]!==o||e[14]!==t.onContinue||e[15]!==t.onFixInChat||e[16]!==s?(g=o?r.jsx(le,{size:"sm",variant:"outline",onClick:t.onFixInChat,className:"h-7 text-xs",children:s("chat.highlight.fixInChat")}):r.jsx(le,{size:"sm",variant:"outline",onClick:t.onContinue,className:"h-7 text-xs",children:s("chat.highlight.continue")}),e[13]=o,e[14]=t.onContinue,e[15]=t.onFixInChat,e[16]=s,e[17]=g):g=e[17];let x;e[18]!==m||e[19]!==s?(x=m?r.jsxs("details",{className:"group mx-4",children:[r.jsxs("summary",{className:"flex cursor-pointer list-none items-center gap-1.5 text-xs text-muted-foreground transition-colors hover:text-foreground [&::-webkit-details-marker]:hidden",children:[r.jsx("svg",{"aria-hidden":"true",className:"size-3 transition-transform group-open:rotate-90",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("path",{d:"m4.5 3 3 3-3 3"})}),r.jsx("span",{className:"group-open:hidden",children:s("chat.highlight.showTechnicalDetails")}),r.jsx("span",{className:"hidden group-open:inline",children:s("chat.highlight.hideTechnicalDetails")})]}),r.jsxs("div",{className:"relative mt-2",children:[r.jsx("button",{type:"button",onClick:()=>{navigator.clipboard.writeText(m).then(()=>ge.success(s("chat.highlight.copiedToClipboard"))).catch(()=>ge.error(s("chat.highlight.couldNotCopy")))},"aria-label":s("chat.highlight.copyErrorDetails"),title:s("chat.highlight.copy"),className:"absolute right-1.5 top-1.5 z-10 flex h-6 w-6 items-center justify-center rounded-md bg-background/80 text-muted-foreground backdrop-blur-sm transition-colors hover:bg-background hover:text-foreground",children:r.jsx(Os,{className:"size-3.5"})}),r.jsx("pre",{className:"max-h-40 overflow-auto rounded-md border border-border/60 bg-background px-3 py-2 pr-8 font-mono text-xs text-foreground/80 whitespace-pre-wrap break-all",children:m})]})]}):null,e[18]=m,e[19]=s,e[20]=x):x=e[20];let v;return e[21]!==l||e[22]!==i||e[23]!==f||e[24]!==p||e[25]!==g||e[26]!==x||e[27]!==n?(v=r.jsx(ei,{icon:p,label:l,title:f,defaultExpanded:!0,variant:n,onClose:i,footerRight:g,children:x}),e[21]=l,e[22]=i,e[23]=f,e[24]=p,e[25]=g,e[26]=x,e[27]=n,e[28]=v):v=e[28],v}function tc(){const t=F.c(67),e=re(),{error:s,clearError:n,finishReason:i,clearFinishReason:o,messages:a,isStreaming:l,submit:c,sendMessage:d}=Js(),[h,u]=ni(),{virtualMcpId:f,createTaskWithMessage:m}=Zt(),{chatMode:p,simpleModeTier:g}=Ts();let x;t[0]!==p||t[1]!==g||t[2]!==f?(x=J=>({tier:g,mode:p,toolApprovalLevel:J,agent:f?{id:f}:void 0}),t[0]=p,t[1]=g,t[2]=f,t[3]=x):x=t[3];const v=x;let b;t[4]!==h.toolApprovalLevel?(b=h.toolApprovalLevel??O5(),t[4]=h.toolApprovalLevel,t[5]=b):b=t[5];const y=b,_=a.at(-1),L=_?.role==="assistant"?_.parts:[],w=L.filter(h_),j=N2(L),S=k2(L);let C;t[6]!==s||t[7]!==d||t[8]!==e?(C=()=>{if(s){const te={type:"doc",content:[{type:"paragraph",content:[{type:"text",text:e("chat.highlight.fixInChatMessage",{error:s.message})}]}]};d(te)}},t[6]=s,t[7]=d,t[8]=e,t[9]=C):C=t[9];const N=C;let V;t[10]!==d||t[11]!==e?(V=()=>{const J={type:"doc",content:[{type:"paragraph",content:[{type:"text",text:e("chat.highlight.pleaseContinue")}]}]};d(J)},t[10]=d,t[11]=e,t[12]=V):V=t[12];const E=V;let T;t[13]!==v||t[14]!==y||t[15]!==c?(T=(J,te)=>{c({kind:"toolOutput",toolCallId:J.toolCallId,output:{response:te}},v(y))},t[13]=v,t[14]=y,t[15]=c,t[16]=T):T=t[16];const k=T;let R;t[17]!==m||t[18]!==h||t[19]!==u||t[20]!==e||t[21]!==f?(R=J=>{u({...h,toolApprovalLevel:"auto"}),m({virtualMcpId:f,message:{parts:[{type:"text",text:e("chat.highlight.implementPlanMessage",{plan:J})}]}})},t[17]=m,t[18]=h,t[19]=u,t[20]=e,t[21]=f,t[22]=R):R=t[22];const P=R,D=u_;let I;t[23]!==v||t[24]!==c?(I=(J,te,se,ne)=>{c({kind:"approval",approvalId:J,approved:te,...se?{reason:se}:{}},v(ne))},t[23]=v,t[24]=c,t[25]=I):I=t[25];const M=I,O=T2();if(O.isCreditExhausted){let J;return t[26]!==n?(J=r.jsx($2,{onDismiss:n}),t[26]=n,t[27]=J):J=t[27],J}const{showError:$,showWarning:B,hasApprovals:z}=O,K=w.map(d_).join("|"),G=V2(j)?.toolCallId??"",Y=S.map(c_).join("|");let U;t[28]!==O.todos?(U=r.jsx(Q8,{todos:O.todos}),t[28]=O.todos,t[29]=U):U=t[29];let W;t[30]===Symbol.for("react.memo_cache_sentinel")?(W=r.jsx(o_,{}),t[30]=W):W=t[30];let H;t[31]!==n||t[32]!==s||t[33]!==N||t[34]!==$?(H=$&&r.jsx(xl,{variant:"error",error:s,onDismiss:n,onFixInChat:N}),t[31]=n,t[32]=s,t[33]=N,t[34]=$,t[35]=H):H=t[35];let X;t[36]!==o||t[37]!==i||t[38]!==E||t[39]!==B?(X=B&&r.jsx(xl,{variant:"warning",finishReason:i,onDismiss:o,onContinue:E}),t[36]=o,t[37]=i,t[38]=E,t[39]=B,t[40]=X):X=t[40];let q;t[41]!==Y||t[42]!==M||t[43]!==z||t[44]!==l||t[45]!==S?(q=z&&r.jsx(R8,{approvals:S,isStreaming:l,onRespond:M},Y),t[41]=Y,t[42]=M,t[43]=z,t[44]=l,t[45]=S,t[46]=q):q=t[46];let Z;t[47]!==O.hasPlans||t[48]!==P||t[49]!==D||t[50]!==l||t[51]!==j||t[52]!==G?(Z=O.hasPlans&&r.jsx(I8,{plans:j,isStreaming:l,onApprove:P,onDismiss:D},G),t[47]=O.hasPlans,t[48]=P,t[49]=D,t[50]=l,t[51]=j,t[52]=G,t[53]=Z):Z=t[53];let Q;t[54]!==O.isWaitingForUserInput||t[55]!==k||t[56]!==l||t[57]!==K||t[58]!==w?(Q=O.isWaitingForUserInput&&r.jsx(B2,{userAskParts:w,isStreaming:l,onSubmit:k},K),t[54]=O.isWaitingForUserInput,t[55]=k,t[56]=l,t[57]=K,t[58]=w,t[59]=Q):Q=t[59];let ee;return t[60]!==X||t[61]!==q||t[62]!==Z||t[63]!==Q||t[64]!==U||t[65]!==H?(ee=r.jsxs("div",{className:"absolute bottom-full left-0 right-0",children:[U,W,H,X,q,Z,Q]}),t[60]=X,t[61]=q,t[62]=Z,t[63]=Q,t[64]=U,t[65]=H,t[66]=ee):ee=t[66],ee}function c_(t){return t.approvalId}function d_(t){return t.toolCallId}function u_(){document.querySelector("[data-chat-input]")?.focus()}function h_(t){return t.type==="tool-user_ask"}tc.Error=function(e){return r.jsx(xl,{variant:"error",error:e.error,onDismiss:e.onDismiss,onFixInChat:e.onFixInChat})};tc.Warning=function(e){return r.jsx(xl,{variant:"warning",finishReason:e.finishReason,onDismiss:e.onDismiss,onContinue:e.onContinue})};tc.UserAskQuestion=B2;function f_(t){const e=F.c(17),{taskId:s}=t,n=re(),i=um(s),o=dx(i),a=ux(),{stop:l,removeLocalMessage:c}=Js();if(o.length===0)return null;let d;e[0]!==l?(d=()=>{l()},e[0]=l,e[1]=d):d=e[1];let h;e[2]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx($0,{size:14}),e[2]=h):h=e[2];let u;e[3]!==d?(u=r.jsx(ze,{asChild:!0,children:r.jsx(le,{type:"button",variant:"ghost",size:"icon-sm",onClick:d,children:h})}),e[3]=d,e[4]=u):u=e[4];let f;e[5]!==n?(f=n("chat.queueTray.sendNow"),e[5]=n,e[6]=f):f=e[6];let m;e[7]!==f?(m=r.jsx(Ke,{side:"top",children:r.jsx("p",{className:"text-xs",children:f})}),e[7]=f,e[8]=m):m=e[8];let p;e[9]!==u||e[10]!==m?(p=r.jsxs(Ue,{delayDuration:400,children:[u,m]}),e[9]=u,e[10]=m,e[11]=p):p=e[11];let g;return e[12]!==a||e[13]!==c||e[14]!==n||e[15]!==s?(g=(x,v)=>r.jsxs("div",{className:"group/queuerow flex items-center gap-2 px-3 py-1.5",children:[r.jsx("span",{className:"flex size-[18px] shrink-0 items-center justify-center rounded-full bg-muted text-[10px] font-semibold text-muted-foreground dark:bg-background",children:v+1}),r.jsx("span",{className:"min-w-0 flex-1 truncate text-sm text-foreground",children:x.text}),r.jsx("div",{className:"flex shrink-0 items-center gap-1 opacity-0 transition-opacity group-hover/queuerow:opacity-100",children:r.jsx(le,{type:"button",variant:"ghost",size:"icon-sm",title:n("chat.queueTray.removeFromQueue"),onClick:()=>{a.cancel(s,x.messageId).then(b=>{b&&(hx(s,x.messageId),c(x.messageId))})},children:r.jsx(Pn,{className:"size-3.5"})})})]},x.messageId),e[12]=a,e[13]=c,e[14]=n,e[15]=s,e[16]=g):g=e[16],r.jsxs("div",{className:"mb-1 overflow-hidden rounded-2xl border border-border bg-card dark:bg-muted",children:[r.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-border py-1.5 pr-2 pl-3 text-xs text-muted-foreground",children:[r.jsx("span",{children:n("chat.queueTray.queuedMessages",{count:o.length})}),p]}),o.map(g)]})}function m_(t){return(t??"").normalize("NFKD").replace(/[̀-ͯ]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"user"}function F2(t){const e=m_(t),s=Date.now().toString(36).split("").reverse().join("");return`${e}-${s}`}const p_={amp:"&",lt:"<",gt:">",quot:'"',apos:"'",nbsp:" "};function vr(t){return t?t.replace(/&(#x?[0-9a-fA-F]+|[a-zA-Z]+);/g,(e,s)=>{if(s.startsWith("#x")||s.startsWith("#X")){const n=Number.parseInt(s.slice(2),16);return Number.isFinite(n)?String.fromCodePoint(n):e}if(s.startsWith("#")){const n=Number.parseInt(s.slice(1),10);return Number.isFinite(n)?String.fromCodePoint(n):e}return p_[s]??e}):""}const g_=10080*60*1e3;function x_({sandboxMap:t,userId:e,rawBranches:s,now:n}){const i=new Map;for(const[u,f]of Object.entries(t??{}))for(const[m,p]of Object.entries(f??{})){let g=i.get(m);g||(g={userIds:new Set,lastActiveAt:0},i.set(m,g)),g.userIds.add(u);for(const x of Object.values(p??{})){const v=x?.createdAt??0;v>g.lastActiveAt&&(g.lastActiveAt=v)}}const o=n-g_,a=[...i.entries()].filter(([,u])=>u.lastActiveAt>=o).sort((u,f)=>f[1].lastActiveAt-u[1].lastActiveAt).map(([u,f])=>({name:u,source:"recent",contributors:[...f.userIds],lastActiveAt:f.lastActiveAt})),l=new Set(a.map(u=>u.name)),c=new Set(Object.keys(t?.[e]??{})),d=[...c].filter(u=>!l.has(u)).sort().map(u=>({name:u,source:"yours"})),h=s.filter(u=>!c.has(u.name)&&!l.has(u.name)).map(u=>({name:u.name,source:"other",author:u.author??null}));return{recent:a,yours:d,others:h}}const za=100;function v_(t,e,s){const n=e.trim().toLowerCase();return n?(t??[]).some(i=>i.branches.some(o=>typeof o.name=="string"&&!s.has(o.name)&&o.name.toLowerCase().includes(n))):!0}function b_(t,e){const s=e.trim().toLowerCase();return s?[...t].some(n=>n.toLowerCase().includes(s)):!0}function __(t){const e=t;if(e.structuredContent)return e.structuredContent;const s=e.content?.find(n=>n.type==="text")?.text;if(s)try{return JSON.parse(s)}catch{return[]}return[]}function y_(t){const e=F.c(47),{orgId:s,orgSlug:n,userId:i,connectionId:o,sandboxMap:a,owner:l,repo:c,enabled:d}=t,h=d===void 0?!0:d,u=o??null;let f;e[0]!==s||e[1]!==n||e[2]!==u?(f={connectionId:u,orgId:s,orgSlug:n},e[0]=s,e[1]=n,e[2]=u,e[3]=f):f=e[3];const m=ht(f);let p;e[4]!==o||e[5]!==s||e[6]!==n||e[7]!==l||e[8]!==c?(p=B5.githubBranches(s,n,o,l,c),e[4]=o,e[5]=s,e[6]=n,e[7]=l,e[8]=c,e[9]=p):p=e[9];const g=h&&!!o&&!!l&&!!c;let x;e[10]!==m||e[11]!==l||e[12]!==c?(x=async O=>{const{pageParam:$,signal:B}=O,z=Number($),K=await m.callTool({name:"list_branches",arguments:{owner:l,repo:c,page:z,perPage:za}},void 0,{signal:B}),G=__(K);return{branches:Array.isArray(G)?G:G.branches??[],default_branch:Array.isArray(G)?null:G.default_branch??null,page:z}},e[10]=m,e[11]=l,e[12]=c,e[13]=x):x=e[13];let v;e[14]!==p||e[15]!==g||e[16]!==x?(v={queryKey:p,enabled:g,staleTime:3e4,retry:!1,initialPageParam:1,queryFn:x,getNextPageParam:k_},e[14]=p,e[15]=g,e[16]=x,e[17]=v):v=e[17];const{data:b,isLoading:y,isError:_,hasNextPage:L,isFetchingNextPage:w,fetchNextPage:j}=Xm(v);let S,C,N,V;if(e[18]!==b?.pages||e[19]!==a||e[20]!==i){const O=new Map;for(const B of b?.pages??[])for(const z of B.branches)typeof z.name=="string"&&O.set(z.name,z);const $=[...O.values()].filter(C_).map(j_);({recent:C,yours:V,others:S}=x_({sandboxMap:a,userId:i,rawBranches:$,now:Date.now()})),N=new Set([...C,...V].map(w_)),e[18]=b?.pages,e[19]=a,e[20]=i,e[21]=S,e[22]=C,e[23]=N,e[24]=V}else S=e[21],C=e[22],N=e[23],V=e[24];const E=N;let T;e[25]!==b?.pages?(T=b?.pages.find(S_)?.default_branch??null,e[25]=b?.pages,e[26]=T):T=e[26];const k=T;let R;e[27]!==b?.pages||e[28]!==j||e[29]!==w||e[30]!==E?(R=async(O,$)=>{const B=$===void 0?L_:$;if(!B()||b_(E,O)||w)return;let z=b?.pages??[];for(;B()&&!v_(z,O,E)&&(z.at(-1)?.branches.length??za)>=za;){const K=await j();if(!B())break;const G=K.data?.pages??z;if(G.length===z.length)break;z=G}},e[27]=b?.pages,e[28]=j,e[29]=w,e[30]=E,e[31]=R):R=e[31];const P=R,D=L??!1;let I;e[32]!==j||e[33]!==L||e[34]!==w?(I=()=>{L&&!w&&j()},e[32]=j,e[33]=L,e[34]=w,e[35]=I):I=e[35];let M;return e[36]!==k||e[37]!==P||e[38]!==_||e[39]!==w||e[40]!==y||e[41]!==S||e[42]!==C||e[43]!==D||e[44]!==I||e[45]!==V?(M={recent:C,yours:V,others:S,defaultBase:k,isLoading:y,isError:_,hasMore:D,isFetchingMore:w,fetchMore:I,fetchUntilMatch:P},e[36]=k,e[37]=P,e[38]=_,e[39]=w,e[40]=y,e[41]=S,e[42]=C,e[43]=D,e[44]=I,e[45]=V,e[46]=M):M=e[46],M}function L_(){return!0}function S_(t){return t.default_branch}function w_(t){return t.name}function j_(t){return{name:t.name,author:typeof t.commit?.author=="string"?t.commit.author:t.commit?.author?.login??null}}function C_(t){return typeof t.name=="string"}function k_(t){if(!(t.branches.length<za))return t.page+1}function V_(t){try{return JSON.parse(t)}catch{return null}}function N_(t){if(!t||typeof t!="object")return null;const e=t,s=e.content?.find(o=>o.type==="text")?.text,n=s?V_(s):null,i=e.structuredContent;return i==null?n:typeof i=="object"&&!Array.isArray(i)&&Object.keys(i).length===0?n??i:i}function zi(t){const e=N_(t);return e===null?null:e}function _9(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 T_(t){if(!t||typeof t!="object")return null;const e=t.content?.find(i=>i.type==="text")?.text;if(!e)return null;const s=e.match(/https:\/\/github\.com\/[^\s"]+\/pull\/\d+/)?.[0],n=_9(s);return!n||!s?null:{number:n,htmlUrl:s}}const eh=/[\r\n<>]/,A_=/^[^\s@<>]+@[^\s@<>]+\.[^\s@<>]+$/;function aa(t){const e=t?.userName?.trim();if(!e||eh.test(e))return null;const s=t?.userEmail?.trim();return!s||eh.test(s)?{userName:e}:A_.test(s)?{userName:e,userEmail:s}:{userName:e}}function E_(t){return t.split(`
|
|
3
|
-
`).filter(e=>!/^Co-authored-by:\s/i.test(e)).join(`
|
|
4
|
-
`).trimEnd()}function P_(t){const e=t.userName.trim(),s=t.userEmail?.trim();return s?`Co-authored-by: ${e} <${s}>`:`Co-authored-by: ${e}`}function z2(t,e){const s=aa(e);if(!s)return t;const n=E_(t),i=P_(s);if(n.includes(i))return n;const o=n.trimEnd();return o.length>0?`${o}
|
|
5
|
-
|
|
6
|
-
${i}`:i}function K2(t,e){const s=t?.trim();return s?z2(s,e):s||void 0}const R_=["dev","start"];function D_(t){if(!t||typeof t!="object")return null;const e=t;return e.isError?e.content?.find(n=>n.type==="text")?.text?.trim()||"GitHub MCP tool returned an error":null}function y9(t){const e=D_(t);if(e)throw new Error(e)}function U2(t,e){for(const s of e){const n=t[s];if(typeof n=="string"&&n.length>0)return n}}function H2(t,e){for(const s of e){const n=t[s];if(typeof n=="number"&&Number.isFinite(n)&&n>0)return n;if(typeof n=="string"&&/^\d+$/.test(n)){const i=Number(n);if(i>0)return i}}}function I_(t){const s=t.head?.ref;return typeof s=="string"&&s.length>0?s:null}function M_(t,e){return I_(t)===e}function sc(t){const e=zi(t);if(Array.isArray(e))return e.filter(s=>s!=null&&typeof s=="object");if(e&&typeof e=="object"){const s=e;for(const n of["pull_requests","items","data"]){const i=s[n];if(Array.isArray(i))return i.filter(o=>o!=null&&typeof o=="object")}}return[]}function O_(t){const e=U2(t,["html_url","htmlUrl","url","URL"]),s=H2(t,["number","pullNumber"])??_9(e);return!s||!e?null:{number:s,htmlUrl:e}}function B_(t){y9(t);const e=T_(t);if(e)return e;const s=zi(t);if(s&&typeof s=="object"){const n=U2(s,["url","URL","html_url","htmlUrl"]),i=H2(s,["number","pullNumber"])??_9(n);if(i&&n)return{number:i,htmlUrl:n}}throw new Error("Failed to open pull request")}function $_(t){return/already exists|pull request already/i.test(t)}async function F_(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 y9(s),sc(s)}async function th(t,e){const s=[`${e.owner}:${e.branch}`,e.branch];for(const n of s){const o=(await F_(t,{owner:e.owner,repo:e.repo,head:n})).find(l=>M_(l,e.branch)),a=o?O_(o):null;if(a)return a}return null}async function z_(t,e){const s=K2(e.body,aa(e.coAuthor));if(s)try{await t.callTool({name:"update_pull_request",arguments:{owner:e.owner,repo:e.repo,pullNumber:e.pullNumber,body:s}})}catch{}}async function K_(t,e){const s=K2(e.body,aa(e.coAuthor)),n=await t.callTool({name:"create_pull_request",arguments:{owner:e.owner,repo:e.repo,title:e.title,body:s||void 0,head:e.head,base:e.base}});return B_(n)}async function sh(t,e){const s=await th(t,{owner:e.owner,repo:e.repo,branch:e.branch});if(s)return await z_(t,{owner:e.owner,repo:e.repo,pullNumber:s.number,body:e.body,coAuthor:e.coAuthor}),s;try{return await K_(t,{owner:e.owner,repo:e.repo,title:e.title,body:e.body,head:e.branch,base:e.base,coAuthor:e.coAuthor})}catch(n){const i=n instanceof Error?n.message:String(n);if(!$_(i))throw n;const o=await th(t,{owner:e.owner,repo:e.repo,branch:e.branch});if(o)return o;throw n}}async function W2(t,e){const s=aa(e.coAuthor),n=s?z2(e.commitMessage?.trim()??"",s):e.commitMessage?.trim()||void 0,i=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}:{},...n?{commit_message:n}:{}}});y9(i);const o=zi(i);if(!o||o.merged!==!0)throw new Error(o?.message??"Failed to merge pull request");return{merged:!0,message:o.message??"Pull request merged"}}const L9=6e4,nc=3e4;function q2(t){const e=t.base,s=t.head,n=s?.repo,i=t.user;return{number:t.number??0,title:t.title??"",body:t.body??"",state:t.state==="closed"?"closed":"open",merged:t.merged_at!=null,mergedAt:t.merged_at??null,base:e?.ref??"main",head:s?.ref??"",headSha:s?.sha??"",headRepoFullName:n?.full_name??null,htmlUrl:t.html_url??"",author:i?.login??""}}function S9(t){const e=F.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 n=ht(s);let i;e[4]!==t.branch||e[5]!==t.owner?(i=t.branch?{head:`${t.owner}:${t.branch}`}:{},e[4]=t.branch,e[5]=t.owner,e[6]=i):i=e[6];let o;e[7]!==t.owner||e[8]!==t.repo||e[9]!==i?(o={owner:t.owner,repo:t.repo,state:"all",...i,perPage:1},e[7]=t.owner,e[8]=t.repo,e[9]=i,e[10]=o):o=e[10];const a=!!t.branch&&!!t.connectionId&&!!t.owner&&!!t.repo;let l;return e[11]!==n||e[12]!==o||e[13]!==a?(l={client:n,toolName:"list_pull_requests",toolArguments:o,enabled:a,refetchInterval:L9,refetchIntervalInBackground:!1,staleTime:nc,select:U_},e[11]=n,e[12]=o,e[13]=a,e[14]=l):l=e[14],na(l)}function U_(t){const e=sc(t);return e.length===0?null:q2(e[0])}const H_=50;function W_(t){const e=F.c(11);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 n=ht(s);let i;e[4]!==t.owner||e[5]!==t.repo?(i={owner:t.owner,repo:t.repo,state:"open",perPage:H_},e[4]=t.owner,e[5]=t.repo,e[6]=i):i=e[6];const o=(t.enabled??!0)&&!!t.connectionId&&!!t.owner&&!!t.repo;let a;return e[7]!==n||e[8]!==i||e[9]!==o?(a={client:n,toolName:"list_pull_requests",toolArguments:i,enabled:o,staleTime:nc,select:q_},e[7]=n,e[8]=i,e[9]=o,e[10]=a):a=e[10],na(a)}function q_(t){return sc(t).map(q2)}function G2(t){const e=F.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 n=ht(s),i=t.prNumber??0;let o;e[4]!==t.owner||e[5]!==t.repo||e[6]!==i?(o={method:"get_check_runs",owner:t.owner,repo:t.repo,pullNumber:i},e[4]=t.owner,e[5]=t.repo,e[6]=i,e[7]=o):o=e[7];const a=!!t.prNumber;let l;return e[8]!==n||e[9]!==o||e[10]!==a?(l={client:n,toolName:"pull_request_read",toolArguments:o,enabled:a,refetchInterval:L9,refetchIntervalInBackground:!1,staleTime:nc,select:G_},e[8]=n,e[9]=o,e[10]=a,e[11]=l):l=e[11],na(l)}function G_(t){const e=zi(t);return(Array.isArray(e)?e:e?.check_runs??[]).map(Y_)}function Y_(t){const e=t.started_at,s=t.completed_at,n=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:n}}function J_(t){const e=F.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 n=ht(s),i=t.prNumber??0;let o;e[4]!==t.owner||e[5]!==t.repo||e[6]!==i?(o={method:"get_comments",owner:t.owner,repo:t.repo,pullNumber:i},e[4]=t.owner,e[5]=t.repo,e[6]=i,e[7]=o):o=e[7];const a=!!t.prNumber;let l;return e[8]!==n||e[9]!==o||e[10]!==a?(l={client:n,toolName:"pull_request_read",toolArguments:o,enabled:a,refetchInterval:L9,refetchIntervalInBackground:!1,staleTime:nc,select:X_},e[8]=n,e[9]=o,e[10]=a,e[11]=l):l=e[11],na(l)}function X_(t){const e=zi(t);return Array.isArray(e)?e.map(Q_):[]}function Q_(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 Z_(t){const e=F.c(137),{orgId:s,orgSlug:n,userId:i,userLabel:o,connectionId:a,owner:l,repo:c,sandboxMap:d,value:h,onChange:u,disabled:f,placement:m}=t,p=f===void 0?!1:f,g=m===void 0?"chat":m,x=re(),v=g==="header",[b,y]=A.useState(!1),[_,L]=A.useState("branches"),[w,j]=A.useState(""),[S,C]=A.useState(!1),N=A.useRef(0);let V;e[0]!==a||e[1]!==b||e[2]!==s||e[3]!==n||e[4]!==l||e[5]!==c||e[6]!==d||e[7]!==i?(V={orgId:s,orgSlug:n,userId:i,connectionId:a,sandboxMap:d,owner:l,repo:c,enabled:b},e[0]=a,e[1]=b,e[2]=s,e[3]=n,e[4]=l,e[5]=c,e[6]=d,e[7]=i,e[8]=V):V=e[8];const{recent:E,yours:T,others:k,isLoading:R,isError:P,hasMore:D,isFetchingMore:I,fetchMore:M,fetchUntilMatch:O}=y_(V);let $;e[9]!==b?($={enabled:b},e[9]=b,e[10]=$):$=e[10];const{data:B}=j6($);let z;e[11]!==B?.data?.members?(z=new Map((B?.data?.members??[]).map(ey)),e[11]=B?.data?.members,e[12]=z):z=e[12];const K=z,G=a??"",Y=b&&_==="prs";let U;e[13]!==s||e[14]!==n||e[15]!==l||e[16]!==c||e[17]!==G||e[18]!==Y?(U={orgId:s,orgSlug:n,connectionId:G,owner:l,repo:c,enabled:Y},e[13]=s,e[14]=n,e[15]=l,e[16]=c,e[17]=G,e[18]=Y,e[19]=U):U=e[19];const{data:W,isLoading:H,isError:X}=W_(U);let q,Z,Q,ee,J,te,se,ne,de,xe,ue,ce,oe;if(e[20]!==p||e[21]!==M||e[22]!==O||e[23]!==D||e[24]!==P||e[25]!==I||e[26]!==v||e[27]!==R||e[28]!==S||e[29]!==K||e[30]!==u||e[31]!==b||e[32]!==k||e[33]!==l||e[34]!==X||e[35]!==H||e[36]!==E||e[37]!==c||e[38]!==w||e[39]!==x||e[40]!==W||e[41]!==_||e[42]!==o||e[43]!==h||e[44]!==T){const Fe=W===void 0?[]:W,je=`${l}/${c}`;let Ie;e[58]!==je?(Ie=je.toLowerCase(),e[58]=je,e[59]=Ie):Ie=e[59];const Pe=Ie;let Ye;e[60]!==Pe?(Ye=He=>He.headRepoFullName?.toLowerCase()===Pe,e[60]=Pe,e[61]=Ye):Ye=e[61];const _e=Fe.filter(Ye),Ae=Fe.length-_e.length;let Re;e[62]!==u?(Re=He=>{u(He),y(!1)},e[62]=u,e[63]=Re):Re=e[63];const ye=Re;let ve;e[64]!==x||e[65]!==h?(ve=h??x("thread.branchPicker.selectBranch"),e[64]=x,e[65]=h,e[66]=ve):ve=e[66];const Le=ve;let $e;e[67]!==O||e[68]!==_?($e=He=>{j(He),N.current=N.current+1;const ae=N.current,Te=He.trim();if(!Te||_!=="branches"){C(!1);return}C(!0),O(Te,()=>ae===N.current).finally(()=>{ae===N.current&&C(!1)})},e[67]=O,e[68]=_,e[69]=$e):$e=e[69];const ke=$e;let Se;e[70]!==M||e[71]!==_?(Se=He=>{const ae=He.currentTarget,Te=ae.scrollHeight-ae.scrollTop-ae.clientHeight;_==="branches"&&Te<48&&M()},e[70]=M,e[71]=_,e[72]=Se):Se=e[72];const Be=Se;ee=As,ue=b,ce=p?void 0:y;const nt=v?"outline":"ghost",pt=v?"sm":"default";let Je;e[73]!==p||e[74]!==v?(Je=ie("font-mono shrink min-w-0 max-w-[200px]",v?"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[73]=p,e[74]=v,e[75]=Je):Je=e[75];let gt;e[76]===Symbol.for("react.memo_cache_sentinel")?(gt=r.jsx(Zs,{className:"h-3.5 w-3.5 shrink-0"}),e[76]=gt):gt=e[76];const dt=v?"":"transition-[max-width,opacity] duration-200 ease-out max-w-0 opacity-0 @[320px]/chat-bottom:max-w-[200px] @[320px]/chat-bottom:opacity-100";let st;e[77]!==dt?(st=ie("min-w-0 truncate",dt),e[77]=dt,e[78]=st):st=e[78];let ft;e[79]!==Le||e[80]!==st?(ft=r.jsx("span",{className:st,children:Le}),e[79]=Le,e[80]=st,e[81]=ft):ft=e[81];let me;e[82]!==p||e[83]!==v?(me=!p&&r.jsx(ss,{size:12,className:ie("opacity-60 shrink-0",v?"":"hidden @[320px]/chat-bottom:inline-block")}),e[82]=p,e[83]=v,e[84]=me):me=e[84];let De;e[85]!==p||e[86]!==Le||e[87]!==nt||e[88]!==pt||e[89]!==Je||e[90]!==ft||e[91]!==me?(De=r.jsx(ze,{asChild:!0,children:r.jsx("span",{className:"inline-flex min-w-0 shrink",children:r.jsx(Es,{asChild:!0,children:r.jsxs(le,{variant:nt,size:pt,"aria-label":Le,disabled:p,className:Je,children:[gt,ft,me]})})})}),e[85]=p,e[86]=Le,e[87]=nt,e[88]=pt,e[89]=Je,e[90]=ft,e[91]=me,e[92]=De):De=e[92];let Qe;e[93]!==Le?(Qe=r.jsx(Ke,{children:Le}),e[93]=Le,e[94]=Qe):Qe=e[94],e[95]!==De||e[96]!==Qe?(oe=r.jsxs(Ue,{children:[De,Qe]}),e[95]=De,e[96]=Qe,e[97]=oe):oe=e[97],Q=Ps,de="w-[min(420px,calc(100vw-2rem))] p-0",xe="start",Z=Tr;let xt;e[98]!==x||e[99]!==_?(xt=_==="branches"?x("thread.branchPicker.searchLoadedBranches"):"Search pull requests…",e[98]=x,e[99]=_,e[100]=xt):xt=e[100];let ls;e[101]!==ke||e[102]!==w||e[103]!==xt?(ls=r.jsx($i,{placeholder:xt,value:w,onValueChange:ke}),e[101]=ke,e[102]=w,e[103]=xt,e[104]=ls):ls=e[104];let Vt;e[105]!==ye||e[106]!==x||e[107]!==_||e[108]!==o?(Vt=_==="branches"&&r.jsx(le,{variant:"outline",size:"sm",className:"h-7 shrink-0",onClick:()=>ye(F2(o)),children:x("thread.branchPicker.new")}),e[105]=ye,e[106]=x,e[107]=_,e[108]=o,e[109]=Vt):Vt=e[109],e[110]!==ls||e[111]!==Vt?(se=r.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:[ls,Vt]}),e[110]=ls,e[111]=Vt,e[112]=se):se=e[112];let Ut;e[113]===Symbol.for("react.memo_cache_sentinel")?(Ut=He=>{L(He),j("")},e[113]=Ut):Ut=e[113];let is;e[114]===Symbol.for("react.memo_cache_sentinel")?(is=r.jsxs(ta,{className:"h-auto w-fit justify-start gap-1 bg-accent p-1",variant:"pill",children:[r.jsx(xn,{value:"branches",className:"h-6 px-2.5 text-xs",children:"Branches"}),r.jsx(xn,{value:"prs",className:"h-6 px-2.5 text-xs",children:"PRs"})]}),e[114]=is):is=e[114],e[115]!==_?(ne=r.jsx(Vr,{className:"px-2 pt-2 pb-1",value:_,onValueChange:Ut,children:is}),e[115]=_,e[116]=ne):ne=e[116],q=Fi,J=Be,te=_==="prs"?r.jsxs(r.Fragment,{children:[X&&r.jsx("div",{className:"p-3 text-xs text-muted-foreground",children:"Couldn't load pull requests from GitHub."}),H&&r.jsx("div",{className:"p-3 text-xs text-muted-foreground",children:"Loading pull requests…"}),!X&&!H&&r.jsx(Qn,{children:w.trim()?"No pull requests match your search.":"No open pull requests."}),_e.length>0&&r.jsx(Ms,{heading:"Open pull requests",children:_e.map(He=>r.jsxs(Vs,{value:`#${He.number} ${He.title} ${He.head}`,className:"cursor-pointer",onSelect:()=>ye(He.head),children:[r.jsx(Tv,{className:"mr-2 h-4 w-4 shrink-0 text-muted-foreground"}),r.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[r.jsx("span",{className:"truncate",children:vr(He.title)}),r.jsxs("span",{className:"truncate text-xs text-muted-foreground",children:["#",He.number," · ",He.head,He.author?` · @${He.author}`:""]})]})]},He.number))}),Ae>0&&r.jsxs("div",{className:"border-t p-2 text-center text-xs text-muted-foreground",children:[Ae," PR",Ae>1?"s":""," from forks hidden — open on a branch in this repo"]})]}):r.jsxs(r.Fragment,{children:[P&&r.jsx("div",{className:"p-3 text-xs text-muted-foreground",children:x("thread.branchPicker.couldntLoadBranches")}),!P&&!R&&r.jsx(Qn,{children:x(D?"thread.branchPicker.lookingThroughMoreBranches":"thread.branchPicker.noBranchesFound")}),E.length>0&&r.jsx(Ms,{heading:"Last 7 days",children:E.map(He=>r.jsxs(Vs,{value:He.name,className:"cursor-pointer",onSelect:()=>ye(He.name),children:[r.jsx(Zs,{className:"mr-2 h-4 w-4 shrink-0"}),r.jsx("span",{className:"flex-1 truncate",children:He.name}),r.jsx(ty,{userIds:He.contributors??[],memberById:K})]},He.name))}),T.length>0&&r.jsxs(r.Fragment,{children:[E.length>0&&r.jsx(Wu,{}),r.jsx(Ms,{heading:x("thread.branchPicker.yourBranches"),children:T.map(He=>r.jsxs(Vs,{value:He.name,className:"cursor-pointer",onSelect:()=>ye(He.name),children:[r.jsx(Zs,{className:"mr-2 h-4 w-4 shrink-0"}),r.jsx("span",{className:"flex-1 truncate",children:He.name})]},He.name))})]}),k.length>0&&r.jsxs(r.Fragment,{children:[r.jsx(Wu,{}),r.jsx(Ms,{heading:x("thread.branchPicker.otherBranchesInRepo"),children:k.map(He=>r.jsxs(Vs,{value:He.name,className:"cursor-pointer",onSelect:()=>ye(He.name),children:[r.jsx(Zs,{className:"mr-2 h-4 w-4"}),r.jsx("span",{className:"flex-1 truncate",children:He.name}),He.author&&r.jsxs("span",{className:"text-xs text-muted-foreground",children:["@",He.author]})]},He.name))})]}),D&&r.jsx("div",{className:"border-t p-2",children:r.jsx(le,{variant:"ghost",size:"sm",className:"h-7 w-full text-xs",disabled:I,onClick:M,children:x(I||S?"thread.branchPicker.loadingMore":"thread.branchPicker.loadMoreBranches")})}),!D&&k.length>0&&r.jsx("div",{className:"border-t p-2 text-center text-xs text-muted-foreground",children:x("thread.branchPicker.allLoaded")})]}),e[20]=p,e[21]=M,e[22]=O,e[23]=D,e[24]=P,e[25]=I,e[26]=v,e[27]=R,e[28]=S,e[29]=K,e[30]=u,e[31]=b,e[32]=k,e[33]=l,e[34]=X,e[35]=H,e[36]=E,e[37]=c,e[38]=w,e[39]=x,e[40]=W,e[41]=_,e[42]=o,e[43]=h,e[44]=T,e[45]=q,e[46]=Z,e[47]=Q,e[48]=ee,e[49]=J,e[50]=te,e[51]=se,e[52]=ne,e[53]=de,e[54]=xe,e[55]=ue,e[56]=ce,e[57]=oe}else q=e[45],Z=e[46],Q=e[47],ee=e[48],J=e[49],te=e[50],se=e[51],ne=e[52],de=e[53],xe=e[54],ue=e[55],ce=e[56],oe=e[57];let fe;e[117]!==q||e[118]!==J||e[119]!==te?(fe=r.jsx(q,{onScroll:J,children:te}),e[117]=q,e[118]=J,e[119]=te,e[120]=fe):fe=e[120];let pe;e[121]!==Z||e[122]!==se||e[123]!==ne||e[124]!==fe?(pe=r.jsxs(Z,{children:[se,ne,fe]}),e[121]=Z,e[122]=se,e[123]=ne,e[124]=fe,e[125]=pe):pe=e[125];let we;e[126]!==Q||e[127]!==de||e[128]!==xe||e[129]!==pe?(we=r.jsx(Q,{className:de,align:xe,children:pe}),e[126]=Q,e[127]=de,e[128]=xe,e[129]=pe,e[130]=we):we=e[130];let Ne;return e[131]!==ee||e[132]!==ue||e[133]!==ce||e[134]!==oe||e[135]!==we?(Ne=r.jsxs(ee,{open:ue,onOpenChange:ce,children:[oe,we]}),e[131]=ee,e[132]=ue,e[133]=ce,e[134]=oe,e[135]=we,e[136]=Ne):Ne=e[136],Ne}function ey(t){return[t.userId,t.user]}function ty(t){const e=F.c(13),{userIds:s,memberById:n}=t;if(s.length===0)return null;let i,o,a;if(e[0]!==n||e[1]!==s){const d=s.slice(0,3);i=s.length-d.length,o="ml-2 flex shrink-0 items-center -space-x-1.5";let h;e[5]!==n?(h=u=>{const f=n.get(u);return r.jsx(ir,{url:f?.image??void 0,fallback:C6(f?.name??void 0),shape:"circle",size:"xs",className:"ring-2 ring-background"},u)},e[5]=n,e[6]=h):h=e[6],a=d.map(h),e[0]=n,e[1]=s,e[2]=i,e[3]=o,e[4]=a}else i=e[2],o=e[3],a=e[4];let l;e[7]!==i?(l=i>0&&r.jsxs("span",{className:"flex h-6 w-6 items-center justify-center rounded-full bg-muted text-[9px] font-semibold text-muted-foreground ring-2 ring-background",children:["+",i]}),e[7]=i,e[8]=l):l=e[8];let c;return e[9]!==o||e[10]!==a||e[11]!==l?(c=r.jsxs("span",{className:o,children:[a,l]}),e[9]=o,e[10]=a,e[11]=l,e[12]=c):c=e[12],c}function sy(t){const e=F.c(25);let s,n,i,o;e[0]!==t?({locked:s,placement:n,value:o,...i}=t,e[0]=t,e[1]=s,e[2]=n,e[3]=i,e[4]=o):(s=e[1],n=e[2],i=e[3],o=e[4]);const a=n==="header";if(s){const c=o??"(no branch)",d=a?"h-8 gap-1.5 border border-input bg-background px-2.5":"h-9 gap-0 px-2";let h;e[5]!==d?(h=ie("inline-flex items-center rounded-md font-mono text-xs","text-muted-foreground cursor-default min-w-0 max-w-[200px]",d),e[5]=d,e[6]=h):h=e[6];let u;e[7]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx(Zs,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":"true"}),e[7]=u):u=e[7];const f=a?"":"max-w-0 opacity-0";let m;e[8]!==f?(m=ie("min-w-0 truncate",f),e[8]=f,e[9]=m):m=e[9];let p;e[10]!==c||e[11]!==m?(p=r.jsx("span",{className:m,children:c}),e[10]=c,e[11]=m,e[12]=p):p=e[12];let g;e[13]!==h||e[14]!==p?(g=r.jsx(ze,{asChild:!0,children:r.jsxs("span",{"data-testid":"branch-picker-locked","aria-disabled":"true",className:h,children:[u,p]})}),e[13]=h,e[14]=p,e[15]=g):g=e[15];let x;e[16]!==c?(x=r.jsxs(Ke,{children:["This chat is using branch ",c,". Start a new chat to use a different branch."]}),e[16]=c,e[17]=x):x=e[17];let v;return e[18]!==g||e[19]!==x?(v=r.jsxs(Ue,{children:[g,x]}),e[18]=g,e[19]=x,e[20]=v):v=e[20],v}let l;return e[21]!==n||e[22]!==i||e[23]!==o?(l=r.jsx(Z_,{...i,value:o,placement:n}),e[21]=n,e[22]=i,e[23]=o,e[24]=l):l=e[24],l}function ic(){const t=F.c(11),e=dm(),s=tm();let n;t[0]!==e.capabilities||t[1]!==e.online?(n=e.online&&e.capabilities.includes("claude-code"),t[0]=e.capabilities,t[1]=e.online,t[2]=n):n=t[2];let i;t[3]!==e.capabilities||t[4]!==e.online?(i=e.online&&e.capabilities.includes("codex"),t[3]=e.capabilities,t[4]=e.online,t[5]=i):i=t[5];let o;return t[6]!==e.online||t[7]!==s.runtime.agentSandbox||t[8]!==n||t[9]!==i?(o={agentSandbox:s.runtime.agentSandbox,userDesktop:e.online,claudeCode:n,codex:i},t[6]=e.online,t[7]=s.runtime.agentSandbox,t[8]=n,t[9]=i,t[10]=o):o=t[10],o}function Y2(t){const e=Object.values(t),[s]=e;return s?e.find(n=>n.sandboxProviderKind!=="user-desktop")??s:null}async function ny(t,e,s){const n=await t.callTool({name:e,arguments:s});if(n.isError){const i=n.content?.[0]?.text??`Tool ${e} failed without a message`;throw new Error(i)}return n}const J2=["SANDBOX_START"],xa=new Map,iy=t=>`${t.virtualMcpId}::${t.branch??""}`,Oc=new Set,vl={mark:(t,e)=>Oc.add(`${t}::${e}`),clear:(t,e)=>Oc.delete(`${t}::${e}`),isStopped:(t,e)=>Oc.has(`${t}::${e}`)};function w9(t){const e=Ls();return Ys({mutationKey:J2,mutationFn:async s=>{s.branch&&vl.clear(s.virtualMcpId,s.branch);const n=iy(s),i=xa.get(n);if(i)return i;const o=(async()=>(await ny(t,"SANDBOX_START",s)).structuredContent)();xa.set(n,o);try{return await o}finally{xa.get(n)===o&&xa.delete(n)}},onSuccess:()=>{sm(e)}})}function ry(t,e){const s=F.c(3);let n;return s[0]!==e||s[1]!==t?(n={mutationKey:J2,predicate:o=>{if(!t)return!1;const a=o.state.variables;return!a||a.virtualMcpId!==t?!1:(a.branch??"")===(e??"")}},s[0]=e,s[1]=t,s[2]=n):n=s[2],Qb(n)>0}const oy={phase:null,lifecycle:{phase:"idle"},status:{state:"running"},branch:{kind:"unknown"},notFound:!1,scripts:[],activeProcesses:[],getBuffer:()=>"",hasData:()=>!1,subscribeChunks:()=>()=>{},subscribeReload:()=>()=>{},subscribeReloadStart:()=>()=>{}},X2=A.createContext(oy),nh=16384;class ay{data="";append(e){this.data+=e,this.data.length>nh&&(this.data=this.data.slice(this.data.length-nh))}get(){return this.data}clear(){this.data=""}}const ly=1e3,cy=3e4,dy=3e3,ih=["lifecycle","status","tasks","scripts","branch","reload","file-changed"],rh="log";function uy(t,e,s,n){return t[0]==="live-meta"&&t[1]===e&&t[2]===s&&t[3]===n}function hy(t){if(!t)return null;try{return new URL("/_sandbox/events",t).href}catch{return null}}function fy(t){return t===404}async function my(t){try{const e=await fetch(t,{headers:{Accept:"text/event-stream"},cache:"no-store",signal:AbortSignal.timeout(dy)});return await e.body?.cancel().catch(()=>{}),fy(e.status)}catch{return!1}}function py({virtualMcpId:t,branch:e,previewUrl:s=null,enabled:n=!0,children:i}){const{org:o}=Oe(),a=Ls(),[l,c]=A.useState(null),[d,h]=A.useState({phase:"idle"}),[u,f]=A.useState({state:"running"}),[m,p]=A.useState({kind:"unknown"}),[g,x]=A.useState(!1),[v,b]=A.useState([]),[y,_]=A.useState([]),[,L]=A.useState(0),w=A.useRef(new Map),j=A.useRef(new Set),S=A.useRef(new Set),C=A.useRef(new Set),N=A.useRef(null),V=hy(s),E=k=>{let R=w.current.get(k);return R||(R=new ay,w.current.set(k,R)),R};A.useEffect(()=>{if(c(null),h({phase:"idle"}),f({state:"running"}),p({kind:"unknown"}),N.current=null,x(!1),b([]),_([]),w.current.clear(),!t||!e||!n)return;const k=`/api/${encodeURIComponent(o.slug)}/sandbox/${encodeURIComponent(t)}/${encodeURIComponent(e)}/events`;let R=!1,P=0,D=null,I=null,M=null,O=null,$=null,B=null;const z=q=>{try{const Z=JSON.parse(q.data);c(Z),Z.kind!=="failed"&&(x(!1),P=0),Z.kind==="ready"&&W()}catch(Z){console.warn("[vm-events] bad phase payload",Z)}},K=()=>{x(!0),c(null),h({phase:"idle"}),f({state:"running"}),p({kind:"unknown"}),b([]),_([]),w.current.clear()},G=q=>{try{const Z=JSON.parse(q.data);if(typeof Z.data!="string")return;P=0;const Q=Z.data.replace(/\r?\n/g,`\r
|
|
7
|
-
`);E(Z.source).append(Q);for(const ee of j.current)try{ee(Z.source,Q)}catch{}L(ee=>ee+1)}catch{}},Y=q=>{const Z=q.type;try{const Q=JSON.parse(q.data);switch(P=0,Z){case"lifecycle":{const ee=Q;if(h(ee.state),ee.state.phase==="running"&&B!=="running"){const se=`${o.slug}/${t}/${e}`;a.invalidateQueries({queryKey:at.decofile(se)}),a.invalidateQueries({predicate:ne=>ne.queryKey[0]==="live-meta"&&typeof ne.queryKey[1]=="string"&&ne.queryKey[1].startsWith(`${se}/`)})}B=ee.state.phase;const J=ee.state.phase==="running"?ee.state.port:null,te=N.current;if(N.current=J,te!==null&&J!==null&&te!==J)for(const se of S.current)try{se()}catch{}return}case"status":f(Q);return;case"tasks":{const J=Q.active.map(te=>te.logName??"").filter(Boolean);_(J);return}case"scripts":b(Q.scripts);return;case"branch":{const ee=Q.meta;p(ee);return}case"reload":for(const ee of S.current)try{ee()}catch{}return;case"file-changed":{const{path:ee}=Q,J=`${o.slug}/${t}/${e}`;if(ee.startsWith(".deco/")||ee.includes("/.deco/")){if(B!=="running")return;for(const se of C.current)try{se()}catch{}M&&clearTimeout(M),M=setTimeout(()=>{M=null,a.invalidateQueries({queryKey:at.decofile(J)});for(const se of S.current)try{se()}catch{}},500)}else I&&clearTimeout(I),I=setTimeout(()=>{I=null,a.invalidateQueries({predicate:se=>uy(se.queryKey,o.slug,t,e)})},1e3);return}}}catch{}};function U(){if(R)return;const q=new EventSource(k);O=q,q.onopen=()=>{},q.onerror=()=>{O===q&&q.readyState===EventSource.CLOSED&&X("studio")},q.addEventListener("phase",z),q.addEventListener("gone",K),q.addEventListener(rh,G);for(const Z of ih)q.addEventListener(Z,Y)}function W(){if(R||!V||$)return;const q=new EventSource(V);$=q;let Z=!1;q.onopen=()=>{if(R||$!==q)return;Z=!0,P=0;const Q=O;O=null,Q?.close()},q.onerror=()=>{$===q&&q.readyState===EventSource.CLOSED&&H(q,Z)},q.addEventListener(rh,G);for(const Q of ih)q.addEventListener(Q,Y)}async function H(q,Z){const Q=V?await my(V):!1;if(!(R||$!==q)){if(q.close(),$=null,Q){K(),O||U();return}Z&&X("direct")}}function X(q){if(R||D)return;const Z=Math.min(ly*2**P,cy);P++,D=setTimeout(()=>{if(D=null,!R){if(q==="direct"){$?.close(),$=null,W();return}O?.close(),O=null,U()}},Z)}return U(),()=>{R=!0,O?.close(),$?.close(),D&&clearTimeout(D),I&&clearTimeout(I),M&&clearTimeout(M)}},[t,e,o.slug,n,V,a]);const T={phase:l,lifecycle:d,status:u,branch:m,notFound:g,scripts:v,activeProcesses:y,getBuffer:k=>w.current.get(k)?.get()??"",hasData:k=>(w.current.get(k)?.get().length??0)>0,subscribeChunks:k=>(j.current.add(k),()=>{j.current.delete(k)}),subscribeReload:k=>(S.current.add(k),()=>{S.current.delete(k)}),subscribeReloadStart:k=>(C.current.add(k),()=>{C.current.delete(k)})};return r.jsx(X2,{value:T,children:i})}function Fs(){return A.use(X2)}function Q2(t){const{subscribeChunks:e}=Fs(),s=A.useRef(t);s.current=t,A.useEffect(()=>e((o,a)=>{s.current?.(o,a)}),[e])}function gy(t){const{subscribeReload:e}=Fs(),s=A.useRef(t);s.current=t,A.useEffect(()=>e(()=>{s.current?.()}),[e])}function xy(t){const{subscribeReloadStart:e}=Fs(),s=A.useRef(t);s.current=t,A.useEffect(()=>e(()=>{s.current?.()}),[e])}function Z2(t){return t.othersThreadGate&&!t.previewUrl?{kind:"othersThread",label:t.othersThreadGate.label}:t.appPaused||t.userStopped?{kind:"suspended"}:t.startError&&!t.previewUrl?{kind:"errored",error:t.startError}:t.previewUrl?{kind:"iframe",previewUrl:t.previewUrl}:{kind:"starting"}}const ep={githubNotAuthenticated:"GITHUB_NOT_AUTHENTICATED"},oh="::";function tp(t){const e=t.indexOf(oh);if(e>0){const s=t.slice(0,e);if(Object.values(ep).includes(s))return{code:s,message:t.slice(e+oh.length)}}return{code:null,message:t}}function vy(t){return t.hasActiveGithubRepo&&!!t.userId&&!t.vmEntry&&!t.userStopped&&!t.isPending&&!t.attempted&&!t.autoStartBlocked}function by(t){return t.notFound&&!!t.deadVmId&&!t.isPending&&!t.userStopped&&!t.autoStartBlocked&&t.deadVmId!==t.lastDeadVmId}function _y(t){return!!t.userId&&!!t.createdBy&&t.createdBy!==t.userId?t.branch??t.title??null:null}function yy(t){const e=t.acknowledgedThreadId!==null&&t.acknowledgedThreadId===t.threadId;return{autoStartBlocked:!!t.othersThreadLabel&&!e}}function Bc(t,e,s){const n={virtualMcpId:t};return e&&(n.branch=e),s&&(n.sandboxProviderKind=s),n}function Ly(t){switch(t.kind){case"suspended":return"suspended";case"iframe":return"running";case"starting":return"starting";case"errored":return"errored";case"othersThread":return"idle"}}const Sy={branch:null,previewState:{kind:"starting"},status:"idle",vmEntry:null,previewUrl:null,userStopped:!1,start:()=>{},stop:async()=>{},restart:async()=>{},retry:()=>{},resume:()=>{},acknowledgeOthersThread:()=>{}},sp=A.createContext(Sy);function Er(){return A.use(sp)}function wy({virtualMcpId:t,branch:e,userId:s,hasActiveGithubRepo:n,sandboxMap:i,sandboxProviderKind:o,othersThreadLabel:a,othersThreadId:l,children:c}){const{org:d}=Oe(),{setCurrentTaskBranch:h}=Zt(),u=Fs(),f=Ls(),[m,p]=A.useState(null),{autoStartBlocked:g}=yy({othersThreadLabel:a,acknowledgedThreadId:m,threadId:l}),x=ht({connectionId:Jo,orgId:d.id,orgSlug:d.slug}),v=w9(x),{mutate:b,reset:y}=v,_=A.useRef(new Set),L=A.useRef(null),w=s&&e?zl(i?.[s]?.[e]):{},j=o?w[o]??null:Y2(w),S=j?.previewUrl??null,C=!!t&&!!e&&vl.isStopped(t,e),N=u.status.state==="paused",V=v.isError&&v.error?tp(v.error.message):null,E=Z2({previewUrl:S,appPaused:N,userStopped:C,startError:V,othersThreadGate:g&&a?{label:a}:null}),T=Ly(E),k=e??"",R=_.current.has(k),P=vy({hasActiveGithubRepo:n,userId:s,vmEntry:j,userStopped:C,isPending:v.isPending,attempted:R,autoStartBlocked:g});A.useEffect(()=>{if(!P||!t)return;_.current.add(k);const Y=Bc(t,e,o);b(Y,{onSuccess:U=>{U?.branch&&!e&&h(U.branch)},onError:U=>{console.error("[sandbox-lifecycle] auto-start failed:",U)}})},[P,k,e,t,o,b,h]);const D=u.notFound?j?.sandboxHandle??null:null,I=by({notFound:u.notFound,deadVmId:D,lastDeadVmId:L.current,isPending:v.isPending,userStopped:C,autoStartBlocked:g});A.useEffect(()=>{if(!I||!D||!t)return;L.current=D;const Y=Bc(t,e,o);b(Y,{onSuccess:U=>{U?.branch&&!e&&h(U.branch)},onError:U=>{console.error("[sandbox-lifecycle] self-heal failed:",U)}})},[I,D,t,e,o,b,h]);const M=()=>{if(!t)return;const Y=Bc(t,e,o);b(Y,{onSuccess:U=>{U?.branch&&!e&&h(U.branch)},onError:U=>{console.error("[sandbox-lifecycle] user start failed:",U)}})},O=async()=>{if(!t||!e)return;const Y=j?.sandboxProviderKind;if(Y){vl.mark(t,e);try{await x.callTool({name:"SANDBOX_DELETE",arguments:{virtualMcpId:t,branch:e,sandboxProviderKind:Y}})}catch{}sm(f)}},$=async()=>{await O(),M()},B=()=>{_.current=new Set,L.current=null,y(),M()},G={branch:e,previewState:E,status:T,vmEntry:j,previewUrl:S,userStopped:C,start:M,stop:O,restart:$,retry:B,resume:B,acknowledgeOthersThread:()=>p(l)};return r.jsx(sp,{value:G,children:c})}function jy(t,e){return t==="user-desktop"?{key:"local",label:e("chat.runtimeSwitcher.thisDevice"),Icon:Nr}:{key:"cloud",label:e("chat.runtimeSwitcher.cloudSandbox"),Icon:q0}}function ah(t){const e=F.c(20),{icon:s,label:n,description:i,active:o,available:a,disabledHint:l,onSelect:c}=t,d=!a,h=a?"cursor-pointer hover:bg-accent":"cursor-not-allowed opacity-50";let u;e[0]!==h?(u=ie("flex w-full items-start gap-2 rounded-md px-2 py-1.5 text-left transition-colors",h),e[0]=h,e[1]=u):u=e[1];let f;e[2]!==s?(f=r.jsx("span",{className:"mt-0.5 shrink-0 text-muted-foreground",children:s}),e[2]=s,e[3]=f):f=e[3];let m;e[4]!==o?(m=o&&r.jsx(zt,{size:13,className:"text-muted-foreground"}),e[4]=o,e[5]=m):m=e[5];let p;e[6]!==n||e[7]!==m?(p=r.jsxs("span",{className:"flex items-center gap-1.5 text-[13px] font-medium text-foreground",children:[n,m]}),e[6]=n,e[7]=m,e[8]=p):p=e[8];const g=a?i:l;let x;e[9]!==g?(x=r.jsx("span",{className:"block text-xs text-muted-foreground",children:g}),e[9]=g,e[10]=x):x=e[10];let v;e[11]!==p||e[12]!==x?(v=r.jsxs("span",{className:"min-w-0 flex-1",children:[p,x]}),e[11]=p,e[12]=x,e[13]=v):v=e[13];let b;return e[14]!==c||e[15]!==d||e[16]!==u||e[17]!==f||e[18]!==v?(b=r.jsxs("button",{type:"button",disabled:d,onClick:c,className:u,children:[f,v]}),e[14]=c,e[15]=d,e[16]=u,e[17]=f,e[18]=v,e[19]=b):b=e[19],b}function Cy(t){return t.toLowerCase()}function ky(t){const e=F.c(71);let s;e[0]!==t?(s=t===void 0?{}:t,e[0]=t,e[1]=s):s=e[1];const{showLabel:n}=s,i=n===void 0?!1:n,o=re(),{pendingSandboxProviderKind:a,setPendingAgentOption:l}=Ts(),{isThreadLocked:c}=Zt(),{vmEntry:d}=Er(),h=ic();if(c)return null;let u;e[2]!==h?(u=hm(h),e[2]=h,e[3]=u):u=e[3];const f=u,m=d?.sandboxProviderKind??a??(h.agentSandbox?"agent-sandbox":f?"user-desktop":null);let p,g,x,v,b,y,_;if(e[4]!==m||e[5]!==i||e[6]!==o){v=jy(m,o);const U=v.Icon;x=us,g=Ue;const W=o("chat.runtimeSwitcher.runtime",{label:v.label}),H=i?"h-9 gap-1.5 px-2 text-xs font-medium":"size-9";let X;e[14]!==H?(X=ie("text-muted-foreground hover:text-foreground",H),e[14]=H,e[15]=X):X=e[15];const q=r.jsx(ds,{asChild:!0,children:r.jsxs(le,{variant:"ghost",size:i?"sm":"icon","aria-label":W,className:X,children:[r.jsx(U,{size:16}),i&&r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"truncate",children:v.label}),r.jsx(ss,{size:12,className:"shrink-0 opacity-70"})]})]})});e[16]!==q?(_=r.jsx(ze,{asChild:!0,children:q}),e[16]=q,e[17]=_):_=e[17],p=Ke,b="bottom",y=o("chat.runtimeSwitcher.runningOn",{label:Cy(v.label)}),e[4]=m,e[5]=i,e[6]=o,e[7]=p,e[8]=g,e[9]=x,e[10]=v,e[11]=b,e[12]=y,e[13]=_}else p=e[7],g=e[8],x=e[9],v=e[10],b=e[11],y=e[12],_=e[13];let L;e[18]!==p||e[19]!==b||e[20]!==y?(L=r.jsx(p,{side:b,children:y}),e[18]=p,e[19]=b,e[20]=y,e[21]=L):L=e[21];let w;e[22]!==g||e[23]!==_||e[24]!==L?(w=r.jsxs(g,{children:[_,L]}),e[22]=g,e[23]=_,e[24]=L,e[25]=w):w=e[25];let j;e[26]!==o?(j=o("chat.runtimeSwitcher.runOn"),e[26]=o,e[27]=j):j=e[27];let S;e[28]!==j?(S=r.jsx(ro,{className:"text-xs font-normal text-muted-foreground",children:j}),e[28]=j,e[29]=S):S=e[29];let C;e[30]===Symbol.for("react.memo_cache_sentinel")?(C=r.jsx(q0,{size:14}),e[30]=C):C=e[30];let N;e[31]!==o?(N=o("chat.runtimeSwitcher.cloudSandbox"),e[31]=o,e[32]=N):N=e[32];let V;e[33]!==o?(V=o("chat.runtimeSwitcher.runsInDecosCloud"),e[33]=o,e[34]=V):V=e[34];const E=v.key==="cloud",T=h.agentSandbox;let k;e[35]!==o?(k=o("chat.runtimeSwitcher.notAvailableOnThisDeployment"),e[35]=o,e[36]=k):k=e[36];let R;e[37]!==l?(R=()=>l("decopilot"),e[37]=l,e[38]=R):R=e[38];let P;e[39]!==h.agentSandbox||e[40]!==N||e[41]!==V||e[42]!==E||e[43]!==k||e[44]!==R?(P=r.jsx(ah,{icon:C,label:N,description:V,active:E,available:T,disabledHint:k,onSelect:R}),e[39]=h.agentSandbox,e[40]=N,e[41]=V,e[42]=E,e[43]=k,e[44]=R,e[45]=P):P=e[45];let D;e[46]===Symbol.for("react.memo_cache_sentinel")?(D=r.jsx(Nr,{size:14}),e[46]=D):D=e[46];let I;e[47]!==o?(I=o("chat.runtimeSwitcher.thisDevice"),e[47]=o,e[48]=I):I=e[48];let M;e[49]!==o?(M=o("chat.runtimeSwitcher.runsOnYourMachineViaDecoLink"),e[49]=o,e[50]=M):M=e[50];const O=v.key==="local",$=f!==null;let B;e[51]!==o?(B=o("chat.runtimeSwitcher.runDecocmsLinkOnYourDesktop"),e[51]=o,e[52]=B):B=e[52];let z;e[53]!==f||e[54]!==l?(z=()=>f&&l(f),e[53]=f,e[54]=l,e[55]=z):z=e[55];let K;e[56]!==I||e[57]!==M||e[58]!==O||e[59]!==$||e[60]!==B||e[61]!==z?(K=r.jsx(ah,{icon:D,label:I,description:M,active:O,available:$,disabledHint:B,onSelect:z}),e[56]=I,e[57]=M,e[58]=O,e[59]=$,e[60]=B,e[61]=z,e[62]=K):K=e[62];let G;e[63]!==S||e[64]!==P||e[65]!==K?(G=r.jsxs(hs,{align:"start",className:"w-64 p-1",children:[S,P,K]}),e[63]=S,e[64]=P,e[65]=K,e[66]=G):G=e[66];let Y;return e[67]!==x||e[68]!==G||e[69]!==w?(Y=r.jsxs(x,{children:[w,G]}),e[67]=x,e[68]=G,e[69]=w,e[70]=Y):Y=e[70],Y}function Vy(t){const e=F.c(2),{branchPill:s}=t;if(!s)return null;let n;return e[0]!==s?(n=r.jsx(r.Fragment,{children:s}),e[0]=s,e[1]=n):n=e[1],n}function np(t){const e=F.c(27),{virtualMcp:s,currentBranch:n,showRuntimeLabel:i}=t,o=i===void 0?!1:i,a=F0(),l=Ii();let c;e[0]!==a?.messages||e[1]!==l?.isThreadLocked?(c=(a?.messages??[]).length>0||(l?.isThreadLocked??!1),e[0]=a?.messages,e[1]=l?.isThreadLocked,e[2]=c):c=e[2];const d=c,h=l?.setCurrentTaskBranch;let u;e[3]!==s?(u=sa(s),e[3]=s,e[4]=u):u=e[4];const f=u,m=f?.connectionId,p=!!f,{data:g}=Di.useSession(),x=g?.user?.id??"";let v;e[5]!==g?.user?.email||e[6]!==g?.user?.name?(v=g?.user?.name??g?.user?.email?.split("@")[0],e[5]=g?.user?.email,e[6]=g?.user?.name,e[7]=v):v=e[7];const b=v,{org:y}=Oe();let _;e[8]!==m||e[9]!==n||e[10]!==f||e[11]!==d||e[12]!==y||e[13]!==h||e[14]!==x||e[15]!==b||e[16]!==s?.id||e[17]!==s?.metadata?.sandboxMap?(_=f&&m?r.jsx(sy,{orgId:y.id,orgSlug:y.slug,userId:x,userLabel:b,virtualMcpId:s?.id??"",connectionId:m,owner:f.owner,repo:f.name,sandboxMap:s?.metadata?.sandboxMap,value:n,onChange:C=>{h&&h(C)},locked:d,placement:"chat"}):null,e[8]=m,e[9]=n,e[10]=f,e[11]=d,e[12]=y,e[13]=h,e[14]=x,e[15]=b,e[16]=s?.id,e[17]=s?.metadata?.sandboxMap,e[18]=_):_=e[18];const L=_;let w;e[19]!==p||e[20]!==o?(w=p&&r.jsx(ky,{showLabel:o}),e[19]=p,e[20]=o,e[21]=w):w=e[21];let j;e[22]!==L?(j=r.jsx(Vy,{branchPill:L}),e[22]=L,e[23]=j):j=e[23];let S;return e[24]!==w||e[25]!==j?(S=r.jsxs(r.Fragment,{children:[w,j]}),e[24]=w,e[25]=j,e[26]=S):S=e[26],S}const Ny={fast:{modelId:"claude-code:haiku",label:"Haiku 4.5"},smart:{modelId:"claude-code:sonnet",label:"Sonnet 5"},thinking:{modelId:"claude-code:opus-1m",label:"Opus 4.8 1M"}},Ty={fast:{modelId:"codex:gpt-5.6-luna",label:"GPT-5.6 Luna"},smart:{modelId:"codex:gpt-5.6-terra",label:"GPT-5.6 Terra"},thinking:{modelId:"codex:gpt-5.6-sol",label:"GPT-5.6 Sol"}};function Ay(t){return t==="claude-code"?Ny:t==="codex"?Ty:null}function lh(t,e){return Ay(t)?.[e]??null}const Ey={decopilot:"cloud-decopilot","claude-code-desktop":"local-claude-code","codex-desktop":"local-codex"};function Py(t){return t===null?"cloud-decopilot":Ey[t]}function Ry(){const t=F.c(2),{pendingAgentOption:e}=Ts();let s;return t[0]!==e?(s=Py(e),t[0]=e,t[1]=s):s=t[1],s}function Dy(){return Ts().simpleModeTier}function Iy(){return Ts().setSimpleModeTier}const My={fast:"Quicker responses",smart:"Balanced quality",thinking:"Deeper reasoning"};function ip(t,e){return t==="local-claude-code"?lh("claude-code",e)?.label??null:t==="local-codex"?lh("codex",e)?.label??null:My[e]}const rp=["fast","smart","thinking"];function Oy(t){const e=F.c(33),{tier:s,pillIcon:n,pillLabel:i,groups:o,header:a}=t,l=re();let c;e[0]!==l?(c={fast:l("chat.tierTrigger.tierFast"),smart:l("chat.tierTrigger.tierSmart"),thinking:l("chat.tierTrigger.tierThinking")},e[0]=l,e[1]=c):c=e[1];const d=c,[h,u]=A.useState(!1);let f;e[2]===Symbol.for("react.memo_cache_sentinel")?(f=E=>{E.onSelect(),u(!1)},e[2]=f):f=e[2];const m=f,p=i??d[s];let g;e[3]===Symbol.for("react.memo_cache_sentinel")?(g=ie("text-muted-foreground hover:text-foreground transition-[gap] duration-200 shrink min-w-0","gap-0 @[320px]/chat-bottom:gap-1.5"),e[3]=g):g=e[3];let x;e[4]===Symbol.for("react.memo_cache_sentinel")?(x=ie("min-w-0 truncate transition-[max-width,opacity] duration-200 ease-out max-w-0 opacity-0","@[320px]/chat-bottom:max-w-24 @[320px]/chat-bottom:opacity-100"),e[4]=x):x=e[4];const v=d[s];let b;e[5]!==v?(b=r.jsx("span",{className:x,children:v}),e[5]=v,e[6]=b):b=e[6];let y;e[7]===Symbol.for("react.memo_cache_sentinel")?(y=r.jsx(ss,{size:12,className:"opacity-60 hidden @[320px]/chat-bottom:inline-block"}),e[7]=y):y=e[7];let _;e[8]!==n||e[9]!==p||e[10]!==b?(_=r.jsx(ze,{asChild:!0,children:r.jsx("span",{className:"inline-flex min-w-0 shrink",children:r.jsx(Es,{asChild:!0,children:r.jsxs(le,{type:"button",variant:"ghost",size:"default","aria-label":p,className:g,children:[n,b,y]})})})}),e[8]=n,e[9]=p,e[10]=b,e[11]=_):_=e[11];let L;e[12]!==p?(L=r.jsx(Ke,{children:p}),e[12]=p,e[13]=L):L=e[13];let w;e[14]!==_||e[15]!==L?(w=r.jsxs(Ue,{children:[_,L]}),e[14]=_,e[15]=L,e[16]=w):w=e[16];let j;e[17]!==a?(j=a&&r.jsx("div",{className:"mb-1 border-b border-border/60 pb-1",children:a}),e[17]=a,e[18]=j):j=e[18];let S;if(e[19]!==o||e[20]!==l){let E;e[22]!==l?(E=T=>r.jsxs("div",{className:"flex flex-col",children:[T.label&&r.jsx("div",{className:"flex items-center gap-1.5 px-2 pt-1.5 pb-0.5 text-xs font-medium text-muted-foreground",children:r.jsx("span",{className:"truncate",children:T.label})}),T.rows.map(k=>r.jsxs("button",{type:"button",role:"menuitem","aria-label":T.label?`${T.label} ${k.title}`:k.title,onClick:()=>m(k),className:ie("flex items-start gap-2 px-2 py-1.5 rounded-md text-left","hover:bg-muted"),children:[k.icon&&r.jsx("span",{className:"shrink-0 text-muted-foreground mt-0.5",children:k.icon}),r.jsxs("div",{className:"flex-1",children:[r.jsx("div",{className:"text-sm",children:k.title}),k.subtitle&&r.jsx("div",{className:"text-xs text-muted-foreground",children:k.subtitle})]}),k.active&&r.jsx("span",{title:l("chat.tierTrigger.selected"),children:r.jsx(zt,{size:14,className:"text-foreground mt-0.5"})})]},k.key))]},T.key),e[22]=l,e[23]=E):E=e[23],S=o.map(E),e[19]=o,e[20]=l,e[21]=S}else S=e[21];let C;e[24]!==S?(C=r.jsx("div",{role:"menu",className:"flex flex-col",children:S}),e[24]=S,e[25]=C):C=e[25];let N;e[26]!==j||e[27]!==C?(N=r.jsxs(Ps,{align:"end",className:"p-1 w-64",children:[j,C]}),e[26]=j,e[27]=C,e[28]=N):N=e[28];let V;return e[29]!==h||e[30]!==w||e[31]!==N?(V=r.jsxs(As,{open:h,onOpenChange:u,children:[w,N]}),e[29]=h,e[30]=w,e[31]=N,e[32]=V):V=e[32],V}function ch(t){return t==="fast"?r.jsx(G0,{size:16}):t==="thinking"?r.jsx(Am,{size:16}):r.jsx(qn,{size:16})}const By="flex items-center justify-center gap-1.5 flex-1 rounded-md px-2 py-1.5 text-xs font-medium transition-colors min-w-0",$y="bg-background text-foreground shadow-sm",Fy="text-muted-foreground hover:text-foreground";function zy(t){const e=F.c(7),{options:s}=t,n=re();let i;if(e[0]!==s||e[1]!==n){let a;e[3]!==n?(a=l=>r.jsxs("button",{type:"button",onClick:l.onSelect,className:ie(By,l.active?$y:Fy),title:l.active?n("chat.tierTrigger.selected"):void 0,children:[l.icon,r.jsx("span",{className:"truncate",children:l.label})]},l.key),e[3]=n,e[4]=a):a=e[4],i=s.map(a),e[0]=s,e[1]=n,e[2]=i}else i=e[2];let o;return e[5]!==i?(o=r.jsx("div",{className:"flex items-center gap-1 p-1 rounded-lg bg-muted",children:i}),e[5]=i,e[6]=o):o=e[6],o}function Ky(){const t=F.c(24),e=re(),{pendingHarnessId:s,setPendingAgentOption:n}=Ts(),i=ic(),o=s==="claude-code"||s==="codex";let a;t[0]!==i?(a=hm(i)??"claude-code-desktop",t[0]=i,t[1]=a):a=t[1];const l=a;let c;t[2]===Symbol.for("react.memo_cache_sentinel")?(c=r.jsx(q0,{size:14}),t[2]=c):c=t[2];let d;t[3]!==e?(d=e("chat.tierTrigger.runtimeCloud"),t[3]=e,t[4]=d):d=t[4];const h=!o;let u;t[5]!==n?(u=()=>n("decopilot"),t[5]=n,t[6]=u):u=t[6];let f;t[7]!==d||t[8]!==h||t[9]!==u?(f={key:"cloud",icon:c,label:d,active:h,onSelect:u},t[7]=d,t[8]=h,t[9]=u,t[10]=f):f=t[10];let m;t[11]===Symbol.for("react.memo_cache_sentinel")?(m=r.jsx(Nr,{size:14}),t[11]=m):m=t[11];let p;t[12]!==e?(p=e("chat.tierTrigger.runtimeThisDevice"),t[12]=e,t[13]=p):p=t[13];let g;t[14]!==l||t[15]!==n?(g=()=>n(l),t[14]=l,t[15]=n,t[16]=g):g=t[16];let x;t[17]!==o||t[18]!==p||t[19]!==g?(x={key:"local",icon:m,label:p,active:o,onSelect:g},t[17]=o,t[18]=p,t[19]=g,t[20]=x):x=t[20];let v;return t[21]!==f||t[22]!==x?(v=r.jsx("div",{className:"p-1",children:r.jsx(zy,{options:[f,x]})}),t[21]=f,t[22]=x,t[23]=v):v=t[23],v}function dh(t){return{key:t.key,label:t.label,rows:rp.map(e=>({key:`${t.key}-${e}`,icon:t.icon,title:t.tierLabels[e],subtitle:ip(t.mode,e),active:t.isActiveRuntime&&t.currentTier===e,onSelect:()=>{t.setOption(t.option),t.setTier(e)}}))}}function Uy(){const t=F.c(37),e=re(),s=Dy(),n=Iy(),i=Ry(),{pendingHarnessId:o,setPendingAgentOption:a}=Ts(),l=ic(),d=Ii()?.isThreadLocked??!1,h=l.claudeCode||l.codex,u=i!=="cloud-decopilot";let f;t[0]!==e?(f=()=>({fast:e("chat.tierTrigger.tierFast"),smart:e("chat.tierTrigger.tierSmart"),thinking:e("chat.tierTrigger.tierThinking")}),t[0]=e,t[1]=f):f=t[1];const m=f;let p,g;if(t[2]!==l.claudeCode||t[3]!==l.codex||t[4]!==m||t[5]!==u||t[6]!==d||t[7]!==o||t[8]!==a||t[9]!==n||t[10]!==e||t[11]!==s){if(g=m(),u){const w=d?o==="claude-code":l.claudeCode||o==="claude-code",j=d?o==="codex":l.codex||o==="codex",S=w&&j,C=[];if(w){let N;t[14]===Symbol.for("react.memo_cache_sentinel")?(N=r.jsx(b6,{size:16}),t[14]=N):N=t[14],C.push(dh({key:"claude-code",label:S?e("chat.tierTrigger.runtimeClaudeCode"):void 0,icon:N,mode:"local-claude-code",option:"claude-code-desktop",isActiveRuntime:o==="claude-code",currentTier:s,setOption:a,setTier:n,tierLabels:g}))}if(j){let N;t[15]===Symbol.for("react.memo_cache_sentinel")?(N=r.jsx(_6,{size:16}),t[15]=N):N=t[15],C.push(dh({key:"codex",label:S?e("chat.tierTrigger.runtimeCodex"):void 0,icon:N,mode:"local-codex",option:"codex-desktop",isActiveRuntime:o==="codex",currentTier:s,setOption:a,setTier:n,tierLabels:g}))}p=C}else{const w={key:"cloud",rows:rp.map(S=>({key:`cloud-${S}`,icon:ch(S),title:g[S],subtitle:ip("cloud-decopilot",S),active:s===S,onSelect:()=>n(S)}))};let j;t[16]!==w?(j=[w],t[16]=w,t[17]=j):j=t[17],p=j}t[2]=l.claudeCode,t[3]=l.codex,t[4]=m,t[5]=u,t[6]=d,t[7]=o,t[8]=a,t[9]=n,t[10]=e,t[11]=s,t[12]=p,t[13]=g}else p=t[12],g=t[13];let x,v,b,y;if(t[18]!==u||t[19]!==o||t[20]!==e||t[21]!==s||t[22]!==g){const w=u?v6(o):null,j=w?.Icon;x=Oy,v=s,b=j?r.jsx(j,{size:16}):ch(s),y=w?`${e(w.labelKey)} ${g[s]}`:g[s],t[18]=u,t[19]=o,t[20]=e,t[21]=s,t[22]=g,t[23]=x,t[24]=v,t[25]=b,t[26]=y}else x=t[23],v=t[24],b=t[25],y=t[26];let _;t[27]!==h||t[28]!==d?(_=h&&!d?r.jsx(Ky,{}):void 0,t[27]=h,t[28]=d,t[29]=_):_=t[29];let L;return t[30]!==x||t[31]!==p||t[32]!==v||t[33]!==b||t[34]!==y||t[35]!==_?(L=r.jsx(x,{tier:v,pillIcon:b,pillLabel:y,groups:p,header:_}),t[30]=x,t[31]=p,t[32]=v,t[33]=b,t[34]=y,t[35]=_,t[36]=L):L=t[36],L}async function j9(t,e,s,n,i,o){if(!Yl(e)){ge.error("Selected model does not support file uploads");return}const a=s.type||"application/octet-stream";if(!y6(a,e)){const c=Ym(e).parts.map(h=>o(h)).join(", "),d=e?.title??"This model";i?i({fileName:s.name,modelName:d,accepted:c}):ge.error(`"${s.name}" can't be attached`,{description:`${d} accepts ${c}.`});return}const l=10*1024*1024;if(s.size>l){ge.error(`File "${s.name}" exceeds 10MB limit`);return}try{const c=new FileReader,d=new Promise((f,m)=>{c.onload=()=>{const p=c.result;if(typeof p!="string"){m(new Error("Failed to read file as data URL"));return}const g=p.includes(",")?p.split(",")[1]??p:p;f(g)},c.onerror=m});c.readAsDataURL(s);const h=await d,u={id:crypto.randomUUID(),name:s.name,mimeType:s.type||"application/octet-stream",size:s.size,data:h};yx(t,{from:n,to:n},u)}catch(c){console.error("Failed to process file:",c),ge.error(`Failed to load file "${s.name}"`)}}function Hy(t){const e=F.c(9),{editor:s,selectedModel:n,onUnsupportedFile:i}=t,o=re(),a=A.useRef(qy);let l,c;e[0]!==s||e[1]!==i||e[2]!==n||e[3]!==o?(l=()=>{a.current=async(u,f)=>{await j9(s,n,u,f,i,o)}},c=[s,n,i,o],e[0]=s,e[1]=i,e[2]=n,e[3]=o,e[4]=l,e[5]=c):(l=e[4],c=e[5]),A.useEffect(l,c);let d,h;return e[6]!==s?(d=()=>{if(s?.isDestroyed)return;const u=new Xx("fileDropHandler");s.state.plugins.find(p=>p.spec.key===u)&&s.unregisterPlugin(u);const m=new Qx({key:u,props:{handleDrop:(p,g,x,v)=>{if(v)return!1;const b=g.dataTransfer?.files;if(!b||b.length===0)return!1;g.preventDefault();const y=p.posAtCoords({left:g.clientX,top:g.clientY});if(!y)return!1;const _=Array.from(b);return(async()=>{let L=y.pos;for(const w of _)await a.current?.(w,L),L=p.state.selection.to})(),!0},handlePaste:(p,g)=>{const x=g.clipboardData?.items;if(!x)return!1;const v=Array.from(x).filter(Wy);return v.length===0?!1:(g.preventDefault(),(async()=>{let b=p.state.selection.from;for(const y of v){const _=y.getAsFile();_&&(await a.current?.(_,b),b=p.state.selection.to)}})(),!0)}}});return s.registerPlugin(m),()=>{s?.isDestroyed||s.unregisterPlugin(u)}},h=[s],e[6]=s,e[7]=d,e[8]=h):(d=e[7],h=e[8]),A.useEffect(d,h),null}function Wy(t){return t.kind==="file"}function qy(){return Promise.resolve()}function Gy(t){const e=F.c(43),{info:s,onClose:n}=t,i=re(),o=s!==null;let a;e[0]!==n?(a=E=>!E&&n(),e[0]=n,e[1]=a):a=e[1];let l;e[2]===Symbol.for("react.memo_cache_sentinel")?(l=["radial-gradient(ellipse 40% 200% at -5% 100%, rgba(251,191,36,0.35) 0%, transparent 100%)","radial-gradient(ellipse 40% 200% at 105% -10%, rgba(244,114,182,0.25) 0%, transparent 100%)"],e[2]=l):l=e[2];let c;e[3]===Symbol.for("react.memo_cache_sentinel")?(c=r.jsx("div",{className:"absolute inset-x-0 top-0 h-36 pointer-events-none",style:{backgroundImage:l.join(", "),maskImage:"linear-gradient(to bottom, black 0%, transparent 100%)",WebkitMaskImage:"linear-gradient(to bottom, black 0%, transparent 100%)"}}),e[3]=c):c=e[3];let d;e[4]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx("div",{className:"flex items-center justify-center size-9 rounded-lg bg-warning/15 text-warning",children:r.jsx(Sr,{size:18})}),e[4]=d):d=e[4];let h;e[5]!==i?(h=i("chat.uploader.fileTypeNotSupported"),e[5]=i,e[6]=h):h=e[6];let u;e[7]!==h?(u=r.jsx(ps,{className:"text-xl font-semibold tracking-tight",children:h}),e[7]=h,e[8]=u):u=e[8];const f=s?.fileName;let m;e[9]!==f?(m=r.jsxs("span",{className:"font-medium text-foreground",children:["“",f,"”"]}),e[9]=f,e[10]=m):m=e[10];let p;e[11]!==i?(p=i("chat.uploader.cantAttachToChat"),e[11]=i,e[12]=p):p=e[12];let g;e[13]!==p||e[14]!==m?(g=r.jsxs(ri,{className:"mt-1.5 text-sm leading-relaxed",children:[m," ",p]}),e[13]=p,e[14]=m,e[15]=g):g=e[15];let x;e[16]!==g||e[17]!==u?(x=r.jsxs("div",{className:"relative px-8 pt-8 pb-2 overflow-hidden",children:[c,r.jsxs(ms,{className:"relative gap-4",children:[d,r.jsxs("div",{children:[u,g]})]})]}),e[16]=g,e[17]=u,e[18]=x):x=e[18];const v=s?.modelName??"";let b;e[19]!==i||e[20]!==v?(b=i("chat.uploader.accepts",{modelName:v}),e[19]=i,e[20]=v,e[21]=b):b=e[21];let y;e[22]!==b?(y=r.jsx("div",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground mb-2",children:b}),e[22]=b,e[23]=y):y=e[23];let _;e[24]===Symbol.for("react.memo_cache_sentinel")?(_=r.jsx(Av,{size:14,className:"text-muted-foreground"}),e[24]=_):_=e[24];const L=s?.accepted;let w;e[25]!==L?(w=r.jsxs("div",{className:"flex items-center gap-2 text-sm text-foreground",children:[_,r.jsx("span",{className:"capitalize",children:L})]}),e[25]=L,e[26]=w):w=e[26];let j;e[27]!==y||e[28]!==w?(j=r.jsx("div",{className:"px-8 pt-3 pb-6 space-y-3",children:r.jsxs("div",{className:"rounded-xl border border-border p-4",children:[y,w]})}),e[27]=y,e[28]=w,e[29]=j):j=e[29];let S;e[30]!==i?(S=i("chat.uploader.gotIt"),e[30]=i,e[31]=S):S=e[31];let C;e[32]!==n||e[33]!==S?(C=r.jsx("div",{className:"px-8 py-4 border-t border-border bg-muted/30 flex items-center justify-end",children:r.jsx(le,{onClick:n,children:S})}),e[32]=n,e[33]=S,e[34]=C):C=e[34];let N;e[35]!==x||e[36]!==j||e[37]!==C?(N=r.jsxs(es,{className:"sm:max-w-[480px] gap-0 p-0 overflow-hidden",onOpenAutoFocus:Yy,children:[x,j,C]}),e[35]=x,e[36]=j,e[37]=C,e[38]=N):N=e[38];let V;return e[39]!==o||e[40]!==a||e[41]!==N?(V=r.jsx(ts,{open:o,onOpenChange:a,children:N}),e[39]=o,e[40]=a,e[41]=N,e[42]=V):V=e[42],V}function Yy(t){return t.preventDefault()}function Jy(){const t=F.c(3),[e,s]=A.useState(null);let n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n=()=>s(null),t[0]=n):n=t[0];let i;return t[1]!==e?(i={unsupportedFile:e,onUnsupportedFile:s,clearUnsupportedFile:n},t[1]=e,t[2]=i):i=t[2],i}var Xy=Lx;var Qy=["input:not([inert]):not([inert] *)","select:not([inert]):not([inert] *)","textarea:not([inert]):not([inert] *)","a[href]:not([inert]):not([inert] *)","button:not([inert]):not([inert] *)","[tabindex]:not(slot):not([inert]):not([inert] *)","audio[controls]:not([inert]):not([inert] *)","video[controls]:not([inert]):not([inert] *)",'[contenteditable]:not([contenteditable="false"]):not([inert]):not([inert] *)',"details>summary:first-of-type:not([inert]):not([inert] *)","details:not([inert]):not([inert] *)"],Pd=Qy.join(","),op=typeof Element>"u",Oo=op?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,bl=!op&&Element.prototype.getRootNode?function(t){var e;return t==null||(e=t.getRootNode)===null||e===void 0?void 0:e.call(t)}:function(t){return t?.ownerDocument},_l=function(e,s){var n;s===void 0&&(s=!0);var i=e==null||(n=e.getAttribute)===null||n===void 0?void 0:n.call(e,"inert"),o=i===""||i==="true",a=o||s&&e&&(typeof e.closest=="function"?e.closest("[inert]"):_l(e.parentNode));return a},Zy=function(e){var s,n=e==null||(s=e.getAttribute)===null||s===void 0?void 0:s.call(e,"contenteditable");return n===""||n==="true"},e7=function(e,s,n){if(_l(e))return[];var i=Array.prototype.slice.apply(e.querySelectorAll(Pd));return s&&Oo.call(e,Pd)&&i.unshift(e),i=i.filter(n),i},Rd=function(e,s,n){for(var i=[],o=Array.from(e);o.length;){var a=o.shift();if(!_l(a,!1))if(a.tagName==="SLOT"){var l=a.assignedElements(),c=l.length?l:a.children,d=Rd(c,!0,n);n.flatten?i.push.apply(i,d):i.push({scopeParent:a,candidates:d})}else{var h=Oo.call(a,Pd);h&&n.filter(a)&&(s||!e.includes(a))&&i.push(a);var u=a.shadowRoot||typeof n.getShadowRoot=="function"&&n.getShadowRoot(a),f=!_l(u,!1)&&(!n.shadowRootFilter||n.shadowRootFilter(a));if(u&&f){var m=Rd(u===!0?a.children:u.children,!0,n);n.flatten?i.push.apply(i,m):i.push({scopeParent:a,candidates:m})}else o.unshift.apply(o,a.children)}}return i},ap=function(e){return!isNaN(parseInt(e.getAttribute("tabindex"),10))},lp=function(e){if(!e)throw new Error("No node provided");return e.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(e.tagName)||Zy(e))&&!ap(e)?0:e.tabIndex},t7=function(e,s){var n=lp(e);return n<0&&s&&!ap(e)?0:n},s7=function(e,s){return e.tabIndex===s.tabIndex?e.documentOrder-s.documentOrder:e.tabIndex-s.tabIndex},cp=function(e){return e.tagName==="INPUT"},n7=function(e){return cp(e)&&e.type==="hidden"},i7=function(e){var s=e.tagName==="DETAILS"&&Array.prototype.slice.apply(e.children).some(function(n){return n.tagName==="SUMMARY"});return s},r7=function(e,s){for(var n=0;n<e.length;n++)if(e[n].checked&&e[n].form===s)return e[n]},o7=function(e){if(!e.name)return!0;var s=e.form||bl(e),n=function(l){return s.querySelectorAll('input[type="radio"][name="'+l+'"]')},i;if(typeof window<"u"&&typeof window.CSS<"u"&&typeof window.CSS.escape=="function")i=n(window.CSS.escape(e.name));else try{i=n(e.name)}catch(a){return console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s",a.message),!1}var o=r7(i,e.form);return!o||o===e},a7=function(e){return cp(e)&&e.type==="radio"},l7=function(e){return a7(e)&&!o7(e)},c7=function(e){var s,n=e&&bl(e),i=(s=n)===null||s===void 0?void 0:s.host,o=!1;if(n&&n!==e){var a,l,c;for(o=!!((a=i)!==null&&a!==void 0&&(l=a.ownerDocument)!==null&&l!==void 0&&l.contains(i)||e!=null&&(c=e.ownerDocument)!==null&&c!==void 0&&c.contains(e));!o&&i;){var d,h,u;n=bl(i),i=(d=n)===null||d===void 0?void 0:d.host,o=!!((h=i)!==null&&h!==void 0&&(u=h.ownerDocument)!==null&&u!==void 0&&u.contains(i))}}return o},uh=function(e){var s=e.getBoundingClientRect(),n=s.width,i=s.height;return n===0&&i===0},d7=function(e,s){var n=s.displayCheck,i=s.getShadowRoot;if(n==="full-native"&&"checkVisibility"in e){var o=e.checkVisibility({checkOpacity:!1,opacityProperty:!1,contentVisibilityAuto:!0,visibilityProperty:!0,checkVisibilityCSS:!0});return!o}if(getComputedStyle(e).visibility==="hidden")return!0;var a=Oo.call(e,"details>summary:first-of-type"),l=a?e.parentElement:e;if(Oo.call(l,"details:not([open]) *"))return!0;if(!n||n==="full"||n==="full-native"||n==="legacy-full"){if(typeof i=="function"){for(var c=e;e;){var d=e.parentElement,h=bl(e);if(d&&!d.shadowRoot&&i(d)===!0)return uh(e);e.assignedSlot?e=e.assignedSlot:!d&&h!==e.ownerDocument?e=h.host:e=d}e=c}if(c7(e))return!e.getClientRects().length;if(n!=="legacy-full")return!0}else if(n==="non-zero-area")return uh(e);return!1},u7=function(e){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(e.tagName))for(var s=e.parentElement;s;){if(s.tagName==="FIELDSET"&&s.disabled){for(var n=0;n<s.children.length;n++){var i=s.children.item(n);if(i.tagName==="LEGEND")return Oo.call(s,"fieldset[disabled] *")?!0:!i.contains(e)}return!0}s=s.parentElement}return!1},h7=function(e,s){return!(s.disabled||n7(s)||d7(s,e)||i7(s)||u7(s))},hh=function(e,s){return!(l7(s)||lp(s)<0||!h7(e,s))},f7=function(e){var s=parseInt(e.getAttribute("tabindex"),10);return!!(isNaN(s)||s>=0)},dp=function(e){var s=[],n=[];return e.forEach(function(i,o){var a=!!i.scopeParent,l=a?i.scopeParent:i,c=t7(l,a),d=a?dp(i.candidates):l;c===0?a?s.push.apply(s,d):s.push(l):n.push({documentOrder:o,tabIndex:c,item:i,isScope:a,content:d})}),n.sort(s7).reduce(function(i,o){return o.isScope?i.push.apply(i,o.content):i.push(o.content),i},[]).concat(s)},up=function(e,s){s=s||{};var n;return s.getShadowRoot?n=Rd([e],s.includeContainer,{filter:hh.bind(null,s),flatten:!1,getShadowRoot:s.getShadowRoot,shadowRootFilter:f7}):n=e7(e,s.includeContainer,hh.bind(null,s)),dp(n)};function m7(){return/apple/i.test(navigator.vendor)}const fh="data-floating-ui-focusable";function p7(t){let e=t.activeElement;for(;((s=e)==null||(s=s.shadowRoot)==null?void 0:s.activeElement)!=null;){var s;e=e.shadowRoot.activeElement}return e}function Dd(t,e){if(!t||!e)return!1;const s=e.getRootNode==null?void 0:e.getRootNode();if(t.contains(e))return!0;if(s&&$5(s)){let n=e;for(;n;){if(t===n)return!0;n=n.parentNode||n.host}}return!1}function Ur(t){return"composedPath"in t?t.composedPath()[0]:t.target}function $c(t,e){if(e==null)return!1;if("composedPath"in t)return t.composedPath().includes(e);const s=t;return s.target!=null&&e.contains(s.target)}function g7(t){return t.matches("html,body")}function Bo(t){return t?.ownerDocument||document}function x7(t){return t?t.hasAttribute(fh)?t:t.querySelector("["+fh+"]")||t:null}function Ka(t,e,s){return s===void 0&&(s=!0),t.filter(i=>{var o;return i.parentId===e&&(!s||((o=i.context)==null?void 0:o.open))}).flatMap(i=>[i,...Ka(t,i.id,s)])}function v7(t){return"nativeEvent"in t}var b7=typeof document<"u",_7=function(){},yi=b7?A.useLayoutEffect:_7;const y7={...nm},L7=y7.useInsertionEffect,S7=L7||(t=>t());function Zi(t){const e=A.useRef(()=>{});return S7(()=>{e.current=t}),A.useCallback(function(){for(var s=arguments.length,n=new Array(s),i=0;i<s;i++)n[i]=arguments[i];return e.current==null?void 0:e.current(...n)},[])}const hp=()=>({getShadowRoot:!0,displayCheck:typeof ResizeObserver=="function"&&ResizeObserver.toString().includes("[native code]")?"full":"none"});function fp(t,e){const s=up(t,hp()),n=s.length;if(n===0)return;const i=p7(Bo(t)),o=s.indexOf(i),a=o===-1?e===1?0:n-1:o+e;return s[a]}function w7(t){return fp(Bo(t).body,1)||t}function j7(t){return fp(Bo(t).body,-1)||t}function Fc(t,e){const s=e||t.currentTarget,n=t.relatedTarget;return!n||!Dd(s,n)}function C7(t){up(t,hp()).forEach(s=>{s.dataset.tabindex=s.getAttribute("tabindex")||"",s.setAttribute("tabindex","-1")})}function mh(t){t.querySelectorAll("[data-tabindex]").forEach(s=>{const n=s.dataset.tabindex;delete s.dataset.tabindex,n?s.setAttribute("tabindex",n):s.removeAttribute("tabindex")})}const k7="data-floating-ui-focusable",ph="active",gh="selected",V7={...nm};let xh=!1,N7=0;const vh=()=>"floating-ui-"+Math.random().toString(36).slice(2,6)+N7++;function T7(){const[t,e]=A.useState(()=>xh?vh():void 0);return yi(()=>{t==null&&e(vh())},[]),A.useEffect(()=>{xh=!0},[]),t}const A7=V7.useId,C9=A7||T7;function E7(){const t=new Map;return{emit(e,s){var n;(n=t.get(e))==null||n.forEach(i=>i(s))},on(e,s){t.has(e)||t.set(e,new Set),t.get(e).add(s)},off(e,s){var n;(n=t.get(e))==null||n.delete(s)}}}const P7=A.createContext(null),R7=A.createContext(null),mp=()=>{var t;return((t=A.useContext(P7))==null?void 0:t.id)||null},pp=()=>A.useContext(R7);function k9(t){return"data-floating-ui-"+t}const D7={border:0,clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:0,position:"fixed",whiteSpace:"nowrap",width:"1px",top:0,left:0},bh=A.forwardRef(function(e,s){const[n,i]=A.useState();yi(()=>{m7()&&i("button")},[]);const o={ref:s,tabIndex:0,role:n,"aria-hidden":n?void 0:!0,[k9("focus-guard")]:"",style:D7};return r.jsx("span",{...e,...o})}),I7={clipPath:"inset(50%)",position:"fixed",top:0,left:0},gp=A.createContext(null),_h=k9("portal");function M7(t){t===void 0&&(t={});const{id:e,root:s}=t,n=C9(),i=B7(),[o,a]=A.useState(null),l=A.useRef(null);return yi(()=>()=>{o?.remove(),queueMicrotask(()=>{l.current=null})},[o]),yi(()=>{if(!n||l.current)return;const c=e?document.getElementById(e):null;if(!c)return;const d=document.createElement("div");d.id=n,d.setAttribute(_h,""),c.appendChild(d),l.current=d,a(d)},[e,n]),yi(()=>{if(s===null||!n||l.current)return;let c=s||i?.portalNode;c&&!W5(c)&&(c=c.current),c=c||document.body;let d=null;e&&(d=document.createElement("div"),d.id=e,c.appendChild(d));const h=document.createElement("div");h.id=n,h.setAttribute(_h,""),c=d||c,c.appendChild(h),l.current=h,a(h)},[e,s,n,i]),o}function O7(t){const{children:e,id:s,root:n,preserveTabOrder:i=!0}=t,o=M7({id:s,root:n}),[a,l]=A.useState(null),c=A.useRef(null),d=A.useRef(null),h=A.useRef(null),u=A.useRef(null),f=a?.modal,m=a?.open,p=!!a&&!a.modal&&a.open&&i&&!!(n||o);return A.useEffect(()=>{if(!o||!i||f)return;function g(x){o&&Fc(x)&&(x.type==="focusin"?mh:C7)(o)}return o.addEventListener("focusin",g,!0),o.addEventListener("focusout",g,!0),()=>{o.removeEventListener("focusin",g,!0),o.removeEventListener("focusout",g,!0)}},[o,i,f]),A.useEffect(()=>{o&&(m||mh(o))},[m,o]),r.jsxs(gp.Provider,{value:A.useMemo(()=>({preserveTabOrder:i,beforeOutsideRef:c,afterOutsideRef:d,beforeInsideRef:h,afterInsideRef:u,portalNode:o,setFocusManagerState:l}),[i,o]),children:[p&&o&&r.jsx(bh,{"data-type":"outside",ref:c,onFocus:g=>{if(Fc(g,o)){var x;(x=h.current)==null||x.focus()}else{const v=a?a.domReference:null,b=j7(v);b?.focus()}}}),p&&o&&r.jsx("span",{"aria-owns":o.id,style:I7}),o&&tr.createPortal(e,o),p&&o&&r.jsx(bh,{"data-type":"outside",ref:d,onFocus:g=>{if(Fc(g,o)){var x;(x=u.current)==null||x.focus()}else{const v=a?a.domReference:null,b=w7(v);b?.focus(),a?.closeOnFocusOut&&a?.onOpenChange(!1,g.nativeEvent,"focus-out")}}})]})}const B7=()=>A.useContext(gp),$7={pointerdown:"onPointerDown",mousedown:"onMouseDown",click:"onClick"},F7={pointerdown:"onPointerDownCapture",mousedown:"onMouseDownCapture",click:"onClickCapture"},yh=t=>{var e,s;return{escapeKey:typeof t=="boolean"?t:(e=t?.escapeKey)!=null?e:!1,outsidePress:typeof t=="boolean"?t:(s=t?.outsidePress)!=null?s:!0}};function z7(t,e){e===void 0&&(e={});const{open:s,onOpenChange:n,elements:i,dataRef:o}=t,{enabled:a=!0,escapeKey:l=!0,outsidePress:c=!0,outsidePressEvent:d="pointerdown",referencePress:h=!1,referencePressEvent:u="pointerdown",ancestorScroll:f=!1,bubbles:m,capture:p}=e,g=pp(),x=Zi(typeof c=="function"?c:()=>!1),v=typeof c=="function"?x:c,b=A.useRef(!1),{escapeKey:y,outsidePress:_}=yh(m),{escapeKey:L,outsidePress:w}=yh(p),j=A.useRef(!1),S=Zi(k=>{var R;if(!s||!a||!l||k.key!=="Escape"||j.current)return;const P=(R=o.current.floatingContext)==null?void 0:R.nodeId,D=g?Ka(g.nodesRef.current,P):[];if(!y&&(k.stopPropagation(),D.length>0)){let I=!0;if(D.forEach(M=>{var O;if((O=M.context)!=null&&O.open&&!M.context.dataRef.current.__escapeKeyBubbles){I=!1;return}}),!I)return}n(!1,v7(k)?k.nativeEvent:k,"escape-key")}),C=Zi(k=>{var R;const P=()=>{var D;S(k),(D=Ur(k))==null||D.removeEventListener("keydown",P)};(R=Ur(k))==null||R.addEventListener("keydown",P)}),N=Zi(k=>{var R;const P=o.current.insideReactTree;o.current.insideReactTree=!1;const D=b.current;if(b.current=!1,d==="click"&&D||P||typeof v=="function"&&!v(k))return;const I=Ur(k),M="["+k9("inert")+"]",O=Bo(i.floating).querySelectorAll(M);let $=hn(I)?I:null;for(;$&&!Dc($);){const G=K5($);if(Dc(G)||!hn(G))break;$=G}if(O.length&&hn(I)&&!g7(I)&&!Dd(I,i.floating)&&Array.from(O).every(G=>!Dd($,G)))return;if(U5(I)&&T){const G=Dc(I),Y=H5(I),U=/auto|scroll/,W=G||U.test(Y.overflowX),H=G||U.test(Y.overflowY),X=W&&I.clientWidth>0&&I.scrollWidth>I.clientWidth,q=H&&I.clientHeight>0&&I.scrollHeight>I.clientHeight,Z=Y.direction==="rtl",Q=q&&(Z?k.offsetX<=I.offsetWidth-I.clientWidth:k.offsetX>I.clientWidth),ee=X&&k.offsetY>I.clientHeight;if(Q||ee)return}const B=(R=o.current.floatingContext)==null?void 0:R.nodeId,z=g&&Ka(g.nodesRef.current,B).some(G=>{var Y;return $c(k,(Y=G.context)==null?void 0:Y.elements.floating)});if($c(k,i.floating)||$c(k,i.domReference)||z)return;const K=g?Ka(g.nodesRef.current,B):[];if(K.length>0){let G=!0;if(K.forEach(Y=>{var U;if((U=Y.context)!=null&&U.open&&!Y.context.dataRef.current.__outsidePressBubbles){G=!1;return}}),!G)return}n(!1,k,"outside-press")}),V=Zi(k=>{var R;const P=()=>{var D;N(k),(D=Ur(k))==null||D.removeEventListener(d,P)};(R=Ur(k))==null||R.addEventListener(d,P)});A.useEffect(()=>{if(!s||!a)return;o.current.__escapeKeyBubbles=y,o.current.__outsidePressBubbles=_;let k=-1;function R(O){n(!1,O,"ancestor-scroll")}function P(){window.clearTimeout(k),j.current=!0}function D(){k=window.setTimeout(()=>{j.current=!1},z5()?5:0)}const I=Bo(i.floating);l&&(I.addEventListener("keydown",L?C:S,L),I.addEventListener("compositionstart",P),I.addEventListener("compositionend",D)),v&&I.addEventListener(d,w?V:N,w);let M=[];return f&&(hn(i.domReference)&&(M=Rc(i.domReference)),hn(i.floating)&&(M=M.concat(Rc(i.floating))),!hn(i.reference)&&i.reference&&i.reference.contextElement&&(M=M.concat(Rc(i.reference.contextElement)))),M=M.filter(O=>{var $;return O!==(($=I.defaultView)==null?void 0:$.visualViewport)}),M.forEach(O=>{O.addEventListener("scroll",R,{passive:!0})}),()=>{l&&(I.removeEventListener("keydown",L?C:S,L),I.removeEventListener("compositionstart",P),I.removeEventListener("compositionend",D)),v&&I.removeEventListener(d,w?V:N,w),M.forEach(O=>{O.removeEventListener("scroll",R)}),window.clearTimeout(k)}},[o,i,l,v,d,s,n,f,a,y,_,S,L,C,N,w,V]),A.useEffect(()=>{o.current.insideReactTree=!1},[o,v,d]);const E=A.useMemo(()=>({onKeyDown:S,...h&&{[$7[u]]:k=>{n(!1,k.nativeEvent,"reference-press")},...u!=="click"&&{onClick(k){n(!1,k.nativeEvent,"reference-press")}}}}),[S,n,h,u]),T=A.useMemo(()=>{function k(R){R.button===0&&(b.current=!0)}return{onKeyDown:S,onMouseDown:k,onMouseUp:k,[F7[d]]:()=>{o.current.insideReactTree=!0}}},[S,d,o]);return A.useMemo(()=>a?{reference:E,floating:T}:{},[a,E,T])}function K7(t){const{open:e=!1,onOpenChange:s,elements:n}=t,i=C9(),o=A.useRef({}),[a]=A.useState(()=>E7()),l=mp()!=null,[c,d]=A.useState(n.reference),h=Zi((m,p,g)=>{o.current.openEvent=m?p:void 0,a.emit("openchange",{open:m,event:p,reason:g,nested:l}),s?.(m,p,g)}),u=A.useMemo(()=>({setPositionReference:d}),[]),f=A.useMemo(()=>({reference:c||n.reference||null,floating:n.floating||null,domReference:n.reference}),[c,n.reference,n.floating]);return A.useMemo(()=>({dataRef:o,open:e,onOpenChange:h,elements:f,events:a,floatingId:i,refs:u}),[e,h,f,a,i,u])}function U7(t){t===void 0&&(t={});const{nodeId:e}=t,s=K7({...t,elements:{reference:null,floating:null,...t.elements}}),n=t.rootContext||s,i=n.elements,[o,a]=A.useState(null),[l,c]=A.useState(null),h=i?.domReference||o,u=A.useRef(null),f=pp();yi(()=>{h&&(u.current=h)},[h]);const m=F5({...t,elements:{...i,...l&&{reference:l}}}),p=A.useCallback(y=>{const _=hn(y)?{getBoundingClientRect:()=>y.getBoundingClientRect(),getClientRects:()=>y.getClientRects(),contextElement:y}:y;c(_),m.refs.setReference(_)},[m.refs]),g=A.useCallback(y=>{(hn(y)||y===null)&&(u.current=y,a(y)),(hn(m.refs.reference.current)||m.refs.reference.current===null||y!==null&&!hn(y))&&m.refs.setReference(y)},[m.refs]),x=A.useMemo(()=>({...m.refs,setReference:g,setPositionReference:p,domReference:u}),[m.refs,g,p]),v=A.useMemo(()=>({...m.elements,domReference:h}),[m.elements,h]),b=A.useMemo(()=>({...m,...n,refs:x,elements:v,nodeId:e}),[m,x,v,e,n]);return yi(()=>{n.dataRef.current.floatingContext=b;const y=f?.nodesRef.current.find(_=>_.id===e);y&&(y.context=b)}),A.useMemo(()=>({...m,context:b,refs:x,elements:v}),[m,x,v,b])}function zc(t,e,s){const n=new Map,i=s==="item";let o=t;if(i&&t){const{[ph]:a,[gh]:l,...c}=t;o=c}return{...s==="floating"&&{tabIndex:-1,[k7]:""},...o,...e.map(a=>{const l=a?a[s]:null;return typeof l=="function"?t?l(t):null:l}).concat(t).reduce((a,l)=>(l&&Object.entries(l).forEach(c=>{let[d,h]=c;if(!(i&&[ph,gh].includes(d)))if(d.indexOf("on")===0){if(n.has(d)||n.set(d,[]),typeof h=="function"){var u;(u=n.get(d))==null||u.push(h),a[d]=function(){for(var f,m=arguments.length,p=new Array(m),g=0;g<m;g++)p[g]=arguments[g];return(f=n.get(d))==null?void 0:f.map(x=>x(...p)).find(x=>x!==void 0)}}}else a[d]=h}),a),{})}}function H7(t){t===void 0&&(t=[]);const e=t.map(l=>l?.reference),s=t.map(l=>l?.floating),n=t.map(l=>l?.item),i=A.useCallback(l=>zc(l,t,"reference"),e),o=A.useCallback(l=>zc(l,t,"floating"),s),a=A.useCallback(l=>zc(l,t,"item"),n);return A.useMemo(()=>({getReferenceProps:i,getFloatingProps:o,getItemProps:a}),[i,o,a])}const W7=new Map([["select","listbox"],["combobox","listbox"],["label",!1]]);function q7(t,e){var s,n;e===void 0&&(e={});const{open:i,elements:o,floatingId:a}=t,{enabled:l=!0,role:c="dialog"}=e,d=C9(),h=((s=o.domReference)==null?void 0:s.id)||d,u=A.useMemo(()=>{var b;return((b=x7(o.floating))==null?void 0:b.id)||a},[o.floating,a]),f=(n=W7.get(c))!=null?n:c,p=mp()!=null,g=A.useMemo(()=>f==="tooltip"||c==="label"?{["aria-"+(c==="label"?"labelledby":"describedby")]:i?u:void 0}:{"aria-expanded":i?"true":"false","aria-haspopup":f==="alertdialog"?"dialog":f,"aria-controls":i?u:void 0,...f==="listbox"&&{role:"combobox"},...f==="menu"&&{id:h},...f==="menu"&&p&&{role:"menuitem"},...c==="select"&&{"aria-autocomplete":"none"},...c==="combobox"&&{"aria-autocomplete":"list"}},[f,u,p,i,h,c]),x=A.useMemo(()=>{const b={id:u,...f&&{role:f}};return f==="tooltip"||c==="label"?b:{...b,...f==="menu"&&{"aria-labelledby":h}}},[f,u,h,c]),v=A.useCallback(b=>{let{active:y,selected:_}=b;const L={role:"option",...y&&{id:u+"-fui-option"}};switch(c){case"select":case"combobox":return{...L,"aria-selected":_}}return{}},[u,c]);return A.useMemo(()=>l?{reference:g,floating:x,item:v}:{},[l,g,x,v])}function G7({children:t}){const{state:e,dispatch:s}=mv(),{open:n,element:i}=e,o=()=>{s({type:"ON_EXIT"})},{refs:a,floatingStyles:l,context:c}=U7({placement:"bottom-start",open:n,onOpenChange:f=>{f||o()},elements:{reference:i},middleware:[q5(10),G5(),Y5()],whileElementsMounted:J5}),d=z7(c,{outsidePress:f=>!(f.target instanceof Element&&f.target.closest(".ProseMirror"))}),h=q7(c,{role:"listbox"}),{getFloatingProps:u}=H7([d,h]);return n?r.jsx(O7,{children:r.jsx("div",{ref:a.setFloating,style:l,...u(),className:"z-50 w-auto min-w-[360px] max-w-[520px] rounded-lg border bg-popover p-0 text-popover-foreground shadow-md outline-hidden overflow-hidden",children:t})}):null}const Y7=t=>{const e=F.c(29),{item:s,isSelected:n,onSelect:i,isLoading:o,ref:a}=t;let l;if(e[0]!==s){const w=pn(s._meta);l=s.title||z0(s.name,w),e[0]=s,e[1]=l}else l=e[1];const c=l,d=s.description||null,h=s.icon,u=n&&"bg-accent text-accent-foreground",f=o&&"pointer-events-none opacity-50";let m;e[2]!==u||e[3]!==f?(m=ie("relative flex w-full cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors","hover:bg-accent hover:text-accent-foreground","focus:bg-accent focus:text-accent-foreground",u,f),e[2]=u,e[3]=f,e[4]=m):m=e[4];let p;e[5]!==h||e[6]!==c?(p=h!==void 0&&r.jsx(Xn,{icon:h,name:c,size:"xs",className:"mr-2"}),e[5]=h,e[6]=c,e[7]=p):p=e[7];let g;e[8]!==c?(g=r.jsx("span",{className:"font-medium flex items-center truncate capitalize",children:c}),e[8]=c,e[9]=g):g=e[9];let x;e[10]!==o?(x=o&&r.jsx(wi,{size:"xs"}),e[10]=o,e[11]=x):x=e[11];let v;e[12]!==g||e[13]!==x?(v=r.jsxs("div",{className:"flex items-center justify-between gap-2",children:[g,x]}),e[12]=g,e[13]=x,e[14]=v):v=e[14];let b;e[15]!==d?(b=d&&r.jsx("div",{className:"text-xs text-muted-foreground line-clamp-1",children:d}),e[15]=d,e[16]=b):b=e[16];let y;e[17]!==v||e[18]!==b?(y=r.jsxs("div",{className:"flex flex-col gap-0.5 flex-1 min-w-0",children:[v,b]}),e[17]=v,e[18]=b,e[19]=y):y=e[19];let _;e[20]!==s.drillable?(_=s.drillable&&r.jsx("kbd",{className:"shrink-0 ml-2 px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground bg-muted border border-border rounded",children:"↵"}),e[20]=s.drillable,e[21]=_):_=e[21];let L;return e[22]!==i||e[23]!==a||e[24]!==y||e[25]!==_||e[26]!==m||e[27]!==p?(L=r.jsxs("div",{ref:a,onClick:i,className:m,children:[p,y,_]}),e[22]=i,e[23]=a,e[24]=y,e[25]=_,e[26]=m,e[27]=p,e[28]=L):L=e[28],L},J7=t=>{const e=F.c(21),{editor:s,queryKey:n,queryFn:i,onSelect:o}=t,a=re();let l;e[0]!==s||e[1]!==o||e[2]!==i||e[3]!==n?(l={editor:s,queryKey:n,queryFn:i,onSelect:o},e[0]=s,e[1]=o,e[2]=i,e[3]=n,e[4]=l):l=e[4];const{items:c,selectedIndex:d,onSelect:h,selectedItem:u}=pv(l);if(!c.length){let g;e[5]!==a?(g=a("chat.mention.noItemsFound"),e[5]=a,e[6]=g):g=e[6];let x;return e[7]!==g?(x=r.jsx("div",{className:"min-w-[360px] max-w-[520px] bg-popover text-popover-foreground rounded-md border shadow-md p-3 text-sm",children:g}),e[7]=g,e[8]=x):x=e[8],x}let f;e[9]===Symbol.for("react.memo_cache_sentinel")?(f={maxHeight:"min(320px, var(--radix-popover-content-available-height, 320px))"},e[9]=f):f=e[9];let m;if(e[10]!==h||e[11]!==c||e[12]!==d||e[13]!==u?.name){let g;e[15]!==h||e[16]!==d||e[17]!==u?.name?(g=(x,v)=>r.jsx(Y7,{item:x,isSelected:v===d,ref:v===d?Z7:void 0,onSelect:()=>h(x,v),isLoading:u?.name===x.name},`${x.kind??"item"}:${x.name}`),e[15]=h,e[16]=d,e[17]=u?.name,e[18]=g):g=e[18],m=c.map(g),e[10]=h,e[11]=c,e[12]=d,e[13]=u?.name,e[14]=m}else m=e[14];let p;return e[19]!==m?(p=r.jsx("div",{className:"min-w-[360px] max-w-[520px] bg-popover text-popover-foreground rounded-md overflow-y-auto",style:f,children:r.jsx("div",{className:"p-1",children:m})}),e[19]=m,e[20]=p):p=e[20],p};function X7(){const t=F.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx("div",{className:"p-1",children:[...Array(3)].map(Q7)}),t[0]=e):e=t[0],e}function Q7(t,e){return r.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1.5 animate-pulse",children:[r.jsx("div",{className:"h-4 w-24 bg-muted rounded"}),r.jsx("div",{className:"h-3 w-32 bg-muted rounded"})]},e)}function xp(t){const e=F.c(18),{editor:s,char:n,pluginKey:i,queryKey:o,queryFn:a,onSelect:l,allow:c,onOpenChange:d}=t;let h;e[0]!==c||e[1]!==n||e[2]!==s||e[3]!==d||e[4]!==i?(h={editor:s,char:n,pluginKey:i,allow:c,onOpenChange:d},e[0]=c,e[1]=n,e[2]=s,e[3]=d,e[4]=i,e[5]=h):h=e[5];const{state:u,dispatch:f}=hv(h);let m;e[6]!==f||e[7]!==u?(m={state:u,dispatch:f},e[6]=f,e[7]=u,e[8]=m):m=e[8];let p;e[9]===Symbol.for("react.memo_cache_sentinel")?(p=r.jsx(X7,{}),e[9]=p):p=e[9];let g;e[10]!==s||e[11]!==l||e[12]!==a||e[13]!==o?(g=r.jsx(G7,{children:r.jsx(A.Suspense,{fallback:p,children:r.jsx(J7,{editor:s,queryKey:o,queryFn:a,onSelect:l})})}),e[10]=s,e[11]=l,e[12]=a,e[13]=o,e[14]=g):g=e[14];let x;return e[15]!==m||e[16]!==g?(x=r.jsx(fv.Provider,{value:m,children:g}),e[15]=m,e[16]=g,e[17]=x):x=e[17],x}function Z7(t){t&&t.scrollIntoView({block:"center",behavior:"smooth"})}const eL=t=>{const e=F.c(53),{editor:s,virtualMcpId:n,suggestionOpenRef:i}=t,o=re(),a=Ls(),{org:l}=Oe(),c=Zo();let d;e[0]!==c?(d=r9(c),e[0]=c,e[1]=d):d=e[1];const h=d;let u;e[2]!==l.id||e[3]!==l.slug||e[4]!==n?(u={connectionId:n,orgId:l.id,orgSlug:l.slug},e[2]=l.id,e[3]=l.slug,e[4]=n,e[5]=u):u=e[5];const f=ht(u);let m;e[6]!==l.id||e[7]!==n?(m=at.virtualMcpResources(n,l.id),e[6]=l.id,e[7]=n,e[8]=m):m=e[8];const p=m,[g,x]=A.useState("categories");let v;e[9]!==g?(v=()=>g,e[9]=g,e[10]=v):v=e[10];const b=A.useEffectEvent(v),y=A.useRef(null),_=A.useRef(!1),L=n??"default";let w;e[11]!==g||e[12]!==l.id||e[13]!==L?(w=["at-mention",l.id,L,g],e[11]=g,e[12]=l.id,e[13]=L,e[14]=w):w=e[14];const j=w;let S;e[15]!==o?(S=o("chat.mentionAt.agentsTitle"),e[15]=o,e[16]=S):S=e[16];let C;e[17]!==o?(C=o("chat.mentionAt.agentsDescription"),e[17]=o,e[18]=C):C=e[18];let N;e[19]!==S||e[20]!==C?(N={name:"agents",title:S,description:C,kind:"category",drillable:!0},e[19]=S,e[20]=C,e[21]=N):N=e[21];let V;e[22]!==o?(V=o("chat.mentionAt.resourcesTitle"),e[22]=o,e[23]=V):V=e[23];let E;e[24]!==o?(E=o("chat.mentionAt.resourcesDescription"),e[24]=o,e[25]=E):E=e[25];let T;e[26]!==V||e[27]!==E?(T={name:"resources",title:V,description:E,kind:"category",drillable:!0},e[26]=V,e[27]=E,e[28]=T):T=e[28];let k;e[29]!==T||e[30]!==N?(k=[N,T],e[29]=T,e[30]=N,e[31]=k):k=e[31];const R=k;let P;e[32]!==f||e[33]!==s||e[34]!==o?(P=async z=>{const{item:K,range:G}=z;if(Me("chat_picker_item_selected",{picker:"@",item_kind:K.kind,item_name:K.name}),K.kind!=="category"&&(_.current=!0),K.kind==="category")return x(K.name==="agents"?"agents":"resources"),!1;if(K.kind==="agent"&&K.agentId){hr(s,G,{id:K.agentId,name:K.name,metadata:{agentId:K.agentId,title:K.name},char:"@"}),x("categories");return}if(K.kind==="resource"&&K.uri&&f){try{const Y=await im(f,K.uri);hr(s,G,{id:K.uri,name:K.uri,metadata:Y.contents,char:"@"})}catch(Y){console.error("[at-mention] Failed to fetch resource:",Y),ge.error(o("chat.mentionAt.failedToLoadResource"))}x("categories");return}},e[32]=f,e[33]=s,e[34]=o,e[35]=P):P=e[35];const D=P;let I;e[36]!==c||e[37]!==R||e[38]!==f||e[39]!==h||e[40]!==b||e[41]!==a||e[42]!==p||e[43]!==n?(I=async z=>{const{query:K}=z,G=b();if(G==="categories"){if(!K.trim())return R;const W=K.toLowerCase(),H=c.filter(q=>q.status==="active"&&(!q.id||!el(q.id))&&!h.has(q.id)&&q.id!==n&&(q.title.toLowerCase().includes(W)||q.description?.toLowerCase().includes(W))).map(tL),X=await(async()=>{if(!f)return[];let q=a.getQueryData(p);return q||(q=await a.fetchQuery({queryKey:p,queryFn:()=>go(f),staleTime:6e4})),(q?.resources??[]).filter(Z=>Z.uri.toLowerCase().includes(W)||Z.name?.toLowerCase().includes(W)||Z.description?.toLowerCase().includes(W)).map(sL)})();return[...H,...X]}if(G==="agents"){let W=c.filter(H=>H.status==="active"&&(!H.id||!el(H.id))&&!h.has(H.id)&&H.id!==n);if(K.trim()){const H=K.toLowerCase();W=W.filter(X=>X.title.toLowerCase().includes(H)||X.description?.toLowerCase().includes(H))}return W.map(nL)}if(!f)return[];let Y=a.getQueryData(p);Y?a.fetchQuery({queryKey:p,queryFn:()=>go(f),staleTime:6e4}).catch(iL):Y=await a.fetchQuery({queryKey:p,queryFn:()=>go(f),staleTime:6e4});let U=Y?.resources??[];if(K.trim()){const W=K.toLowerCase();U=U.filter(H=>H.uri.toLowerCase().includes(W)||H.name?.toLowerCase().includes(W)||H.description?.toLowerCase().includes(W))}return U.map(rL)},e[36]=c,e[37]=R,e[38]=f,e[39]=h,e[40]=b,e[41]=a,e[42]=p,e[43]=n,e[44]=I):I=e[44];const M=I;let O;e[45]!==i?(O=z=>{if(i&&(i.current=z),z)y.current=Date.now(),_.current=!1,Me("chat_picker_opened",{picker:"@"});else{const K=y.current;Me("chat_picker_closed",{picker:"@",outcome:_.current?"selected":"dismissed",duration_ms:K?Date.now()-K:null}),y.current=null,x("categories")}},e[45]=i,e[46]=O):O=e[46];const $=O;let B;return e[47]!==s||e[48]!==M||e[49]!==D||e[50]!==$||e[51]!==j?(B=r.jsx(xp,{editor:s,char:"@",pluginKey:"atDropdownMenu",queryKey:j,queryFn:M,onSelect:D,onOpenChange:$}),e[47]=s,e[48]=M,e[49]=D,e[50]=$,e[51]=j,e[52]=B):B=e[52],B};function tL(t){return{name:t.title,title:t.title,description:t.description??void 0,icon:t.icon??null,kind:"agent",agentId:t.id}}function sL(t){return{name:t.name??t.uri,title:t.name,description:t.description,kind:"resource",uri:t.uri}}function nL(t){return{name:t.title,title:t.title,description:t.description??void 0,icon:t.icon??null,kind:"agent",agentId:t.id}}function iL(){}function rL(t){return{name:t.name??t.uri,title:t.name,description:t.description,kind:"resource",uri:t.uri}}async function Lh(t,e,s,n,i,o,a){try{const l=await Xo(s,n,o);hr(t,e,{id:n,name:jr(n,i),metadata:l.messages,char:"/",kind:"prompt",args:o})}catch(l){console.error("[slash] Failed to fetch prompt:",l),ge.error(a.t("chat.mentionSlash.failedLoadPrompt"))}}async function oL(t,e,s,n,i){try{const o=await im(s,n);hr(t,e,{id:n,name:n,metadata:o.contents,char:"/",kind:"resource"})}catch(o){console.error("[slash] Failed to fetch resource:",o),ge.error(i.t("chat.mentionSlash.failedLoadResource"))}}async function aL(t,e,s,n,i){try{const{files:o,omittedPaths:a}=await V6(s,n.volume,n.path),l={sandboxPath:n.sandboxPath,files:o,omittedPaths:a};hr(t,e,{id:n.id,name:n.name,metadata:l,char:"/",kind:"skill"})}catch(o){console.error("[slash] Failed to fetch skill:",o),ge.error(i.t("chat.mentionSlash.failedLoadSkill"))}}const lL=({editor:t,virtualMcpId:e,suggestionOpenRef:s})=>{const n=re(),i=Ls(),{org:o}=Oe(),a=ht({connectionId:e,orgId:o.id,orgSlug:o.slug}),l=at.virtualMcpPrompts(e,o.id),c=at.virtualMcpResources(e,o.id),d=at.slashSkills(o.id),h=["slash-mention",o.id,e??"default"],[u,f]=A.useState(null),[m,p]=A.useState(null),g=Zx(t);g&&(g.onEditChip=async j=>{if(a)try{const C=(await Sh(i,l,a)).find(N=>N.name===j.promptId);if(!C?.arguments||C.arguments.length===0)return;p({...j,prompt:C})}catch(S){console.error("[slash] Failed to load prompt for editing:",S),ge.error(n("chat.mentionSlash.failedLoadPrompt"))}});const x=A.useRef(null),v=A.useRef(!1),b=async({item:j,range:S})=>{if(Me("chat_picker_item_selected",{picker:"/",item_kind:j.kind,item_name:j.name}),v.current=!0,!!a)if(j.kind==="prompt"){if(j.arguments&&j.arguments.length>0){f({range:S,item:j});return}const C=pn(j._meta);await Lh(t,S,a,j.name,C,void 0,{t:n})}else j.kind==="skill"?j.skill&&await aL(t,S,o.slug,j.skill,{t:n}):j.uri&&await oL(t,S,a,j.uri,{t:n})},y=async j=>{if(!u||!a)return;const{range:S,item:C}=u,N=pn(C._meta);await Lh(t,S,a,C.name,N,j,{t:n}),f(null)},_=async j=>{if(!(!m||!a)){if(!ev(t,m.pos,m.promptId)){ge.error(n("chat.mentionSlash.failedUpdatePrompt")),p(null);return}try{const S=await Xo(a,m.promptId,j),C=pn(m.prompt._meta);t.chain().focus().setNodeSelection(m.pos).deleteSelection().insertContentAt(m.pos,K0({id:m.promptId,name:jr(m.promptId,C),metadata:S.messages,char:"/",kind:"prompt",args:j})).run(),Me("chat_picker_item_selected",{picker:"/edit",item_kind:"prompt",item_name:m.promptId})}catch(S){console.error("[slash] Failed to update prompt:",S),ge.error(n("chat.mentionSlash.failedUpdatePrompt"))}p(null)}},L=async j=>{const{query:S}=j;if(!a)return[];const[C,N,V]=await Promise.all([Sh(i,l,a),dL(i,c,a),cL(i,d,o.slug)]),E=S.trim().toLowerCase(),T=(C??[]).filter(P=>!E||P.name.toLowerCase().includes(E)||P.title?.toLowerCase().includes(E)||P.description?.toLowerCase().includes(E)).map(P=>({name:P.name,title:P.title,description:P.description,kind:"prompt",arguments:P.arguments,_meta:P._meta})),k=(N??[]).filter(P=>!E||P.uri.toLowerCase().includes(E)||P.name?.toLowerCase().includes(E)||P.description?.toLowerCase().includes(E)).map(P=>({name:P.name??P.uri,title:P.name,description:P.description,kind:"resource",uri:P.uri})),R=(V??[]).filter(P=>!E||P.name.toLowerCase().includes(E)||P.id.toLowerCase().includes(E)||P.description?.toLowerCase().includes(E)).map(P=>({name:P.name,title:P.name,description:P.description??void 0,kind:"skill",skill:P}));return[...T,...k,...R]},w=u?.item.kind==="prompt"?{name:u.item.name,title:u.item.title,arguments:u.item.arguments,description:u.item.description,_meta:u.item._meta}:null;return r.jsxs(r.Fragment,{children:[r.jsx(xp,{editor:t,char:"/",pluginKey:"slashDropdownMenu",queryKey:h,queryFn:L,onSelect:b,onOpenChange:j=>{if(s&&(s.current=j),j)x.current=Date.now(),v.current=!1,Me("chat_picker_opened",{picker:"/"});else{const S=x.current;Me("chat_picker_closed",{picker:"/",outcome:v.current?"selected":"dismissed",duration_ms:S?Date.now()-S:null}),x.current=null}}}),r.jsx(No,{prompt:w,setPrompt:()=>f(null),onSubmit:y}),r.jsx(No,{prompt:m?.prompt??null,setPrompt:()=>p(null),onSubmit:_,defaultValues:m?.args},m?`edit-${m.promptId}-${m.pos}`:"edit-idle")]})};async function Sh(t,e,s){let n=t.getQueryData(e);return n?t.fetchQuery({queryKey:e,queryFn:()=>kd(s),staleTime:6e4}).catch(()=>{}):n=await t.fetchQuery({queryKey:e,queryFn:()=>kd(s),staleTime:6e4}),n?.prompts??[]}async function cL(t,e,s){const n=t.getQueryData(e),i=()=>t.fetchQuery({queryKey:e,queryFn:()=>N6(s),staleTime:6e4});return n?(i().catch(()=>{}),n):i().catch(()=>[])}async function dL(t,e,s){let n=t.getQueryData(e);return n?t.fetchQuery({queryKey:e,queryFn:()=>go(s),staleTime:6e4}).catch(()=>{}):n=await t.fetchQuery({queryKey:e,queryFn:()=>go(s),staleTime:6e4}),n?.resources??[]}function uL(t){return[fm.configure({heading:!1,blockquote:!1,codeBlock:!1,horizontalRule:!1,dropcursor:!1}),Xy.configure({placeholder:()=>t.current??"Ask anything, / for prompts & skills, @ for agents & resources...",showOnlyWhenEditable:!1}),sv,Sx]}function vp({tiptapDoc:t,setTiptapDoc:e,disabled:s=!1,enterToSubmit:n=!1,placeholder:i,onSubmit:o,suggestionOpenRef:a,children:l}){const c=A.useRef(o),d=A.useRef(e),h=A.useRef(n),u=A.useRef(i),f=Lm({extensions:uL(u),content:t||"",editorProps:{attributes:{"data-chat-input":"true",class:"prose prose-sm max-w-none focus:outline-none w-full h-full text-[15px] p-[18px]"},handleKeyDown:(m,p)=>p.key==="Enter"&&!p.shiftKey&&h.current&&!a?.current?(p.preventDefault(),c.current?.(),!0):!1},onUpdate:({editor:m})=>{d.current(m?.getJSON())}});return A.useEffect(()=>{f?.setEditable(!s)},[f,s]),A.useEffect(()=>{c.current=o},[o]),A.useEffect(()=>{d.current=e},[e]),A.useEffect(()=>{h.current=n},[n]),A.useEffect(()=>{u.current=i},[i]),A.useEffect(()=>{if(!f||f.isDestroyed)return;const m=JSON.stringify(f.getJSON()),p=JSON.stringify(t||{type:"doc",content:[]});m!==p&&f.commands.setContent(t||{type:"doc",content:[]})},[f,t]),r.jsx(tv.Provider,{value:{editor:f},children:l})}function bp(t){const e=F.c(29),{disabled:s,virtualMcpId:n,showFileUploader:i,selectedModel:o,onUnsupportedFile:a,suggestionOpenRef:l,ref:c,className:d}=t,h=s===void 0?!1:s,u=i===void 0?!1:i,{editor:f}=U0();let m,p;if(e[0]!==f?(m=()=>({focus:()=>{f?.commands.focus()},clear:()=>{f?.commands.clearContent(!0)},appendText:C=>{if(!f)return;const N=f.state.doc.textContent.trim()==="";f.commands.focus("end"),N||f.commands.insertContent(" "),f.commands.insertContent(C)},syncVoiceText:(C,N)=>{if(f&&(f.commands.setContent(C||{type:"doc",content:[]}),N)){f.commands.focus("end");const V=f.state.doc.textContent.trim().length>0;f.commands.insertContent({type:"text",text:V?" "+N:N})}},restoreContent:C=>{f&&f.commands.setContent(C||{type:"doc",content:[]})}}),p=[f],e[0]=f,e[1]=m,e[2]=p):(m=e[1],p=e[2]),A.useImperativeHandle(c??null,m,p),!f)return null;const g=h&&"cursor-not-allowed opacity-70",x=h&&"[&_.ProseMirror]:cursor-not-allowed";let v;e[3]!==d||e[4]!==g||e[5]!==x?(v=ie("overflow-y-auto relative flex-1 max-h-[164px] min-h-[20px] w-full flex flex-col",d,"[&_.ProseMirror]:outline-none [&_.ProseMirror]:min-h-[20px] [&_.ProseMirror]:flex-1","[&_.ProseMirror_p.is-editor-empty:first-child::before]:content-[attr(data-placeholder)]","[&_.ProseMirror_p.is-editor-empty:first-child::before]:text-muted-foreground","[&_.ProseMirror_p.is-editor-empty:first-child::before]:opacity-50","[&_.ProseMirror_p.is-editor-empty:first-child::before]:float-left","[&_.ProseMirror_p.is-editor-empty:first-child::before]:pointer-events-none","[&_.ProseMirror_p.is-editor-empty:first-child::before]:h-0",g,x),e[3]=d,e[4]=g,e[5]=x,e[6]=v):v=e[6];let b;e[7]!==f||e[8]!==v?(b=r.jsx(Sm,{editor:f,className:v}),e[7]=f,e[8]=v,e[9]=b):b=e[9];const y=n??null;let _;e[10]!==f||e[11]!==l||e[12]!==y?(_=r.jsx(A.Suspense,{fallback:null,children:r.jsx(lL,{editor:f,virtualMcpId:y,suggestionOpenRef:l})}),e[10]=f,e[11]=l,e[12]=y,e[13]=_):_=e[13];const L=n??null;let w;e[14]!==f||e[15]!==l||e[16]!==L?(w=r.jsx(A.Suspense,{fallback:null,children:r.jsx(eL,{editor:f,virtualMcpId:L,suggestionOpenRef:l})}),e[14]=f,e[15]=l,e[16]=L,e[17]=w):w=e[17];let j;e[18]!==h||e[19]!==f||e[20]!==a||e[21]!==o||e[22]!==u?(j=u&&o&&!h?r.jsx(Hy,{editor:f,selectedModel:o,onUnsupportedFile:a}):null,e[18]=h,e[19]=f,e[20]=a,e[21]=o,e[22]=u,e[23]=j):j=e[23];let S;return e[24]!==_||e[25]!==w||e[26]!==j||e[27]!==b?(S=r.jsxs(r.Fragment,{children:[b,_,w,j]}),e[24]=_,e[25]=w,e[26]=j,e[27]=b,e[28]=S):S=e[28],S}function _p(t){const e=F.c(3),[s]=ni();let n;return e[0]!==s.enableSounds||e[1]!==t?(n=()=>{s.enableSounds&&Q6(t.dataUri).catch(o=>{console.warn(`[sound] ${t.name} playback failed:`,o)})},e[0]=s.enableSounds,e[1]=t,e[2]=n):n=e[2],n}const hL={name:"switch-005",dataUri:"data:audio/mpeg;base64,SUQzBAAAAAAAIlRTU0VAAAAOAAADTGF2ZjYyLjMuMTAwAAAAAAAAAAAAAAD/+1DAAAAAAAAAAAAAAAAAAAAAAABJbmZvAAAADwAAABkAABU4ABMTEx0dHR0nJycnMTExMTs7OztERERETk5OTlhYWFhiYmJibGxsbHZ2dnZ/f39/iYmJiZOTk5OdnZ2dp6enp7GxsbG7u7u7xMTExM7Ozs7Y2NjY4uLi4uzs7Oz29vb2/////wAAAABMYXZjNjIuMTEAAAAAAAAAAAAAAAAkBVYAAAAAAAAVOPCP8KUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//tQxAAACEwDXvQRAAG8Ii93HtACUCAABAKCJwfaCEHwfeoEAQdEAYygIHBOCAIAgCAJh9QIOg+D5/ygPh/wfB8DuKAgCHyn9QPh/5SCDv+CEHAQdxOD4B27c39tbckkqYbBAYAN9bNJLB+aXAf5wQAKdzxfbmrVIRQ4xNx3HwnoDmLhfMhgJiiw/HREXNCHqjvHEPEG8QjBYlxQNepJAT0kC8ip6JzSWj1TasoG+iyycbf2Uil1ovf1f/oUtR1qP+s1WSBFKoAAU02BDjMhuP/7UsQEgws8bRpd8YABJYPeBf9wCGXTGxBYcw5AJFMFMAmQQAhGAxgLBgHIAMYAAALhgAchipbe/91aU1VV4zcZj1Vf1XgYCIMBNrsBAIGs9/Ue4i/xFPeqCqwViI9/UeLf///rOngdA3OPHFjmOBv+EQnGahgaZxVplmkAH5JadDTQlNCEuGNiWYbCCONWdUJg6HXNazFdu1T+VgaEpOP70exv7f2/4b/yH//2/4cqCX/zWRUrIw+IPNMNlDnjAXQas/I4AzmYifA0tMSCgQDF//tSxBCDSzzi3k/sQwEyCtjJ/rBZAk+Uqj1YhA5YMCAAMwgOUchTkK7OR7LbMl0W1H6SvzG0Q2ZzfKUhnmTobv9DNhS1v7P8h//8Gv8gTRt1jReZ7YEjmMQg9hhwwMycHooasFmZyjcZGBKJD+IwbMCQQLoi+IQXCcIoydKoilI2MWFS5uJdDEu2taRrYI2ZSqKY50pJLv2NfjUAAuQAMfqVQ/T3PDQgMJMeEZ45hJzY6MNoFMxqTj1zNGQKJjAxEsSCBgQJBSIL0mcKYQJfVAn/+1LEGwLKlEKrD3MiYcuMkVa/wABB8Vh6M1q1epbvXwWBURhkyEhWZ/////////////9gjZ/Wt4w+4MNMCpE4TBYQl4w1IHvMDdA2zBngBMwc8COMDhCpDAfgOAAgrBgNYU+YC0FBGAkAMpgWoSCYAGESGBGAKBgXgJOdiOJmMCmNwCYNDJhYRPykRCJhTBnEUzlsjv4UNLj/z97n3Mv/7z1nZqyitYAZIqErIwMwJAqEw0GAAMFptJMaqFwB8CQIWlhuhuDAwNjfuwrQFAYXCf/7UsQVAA+9PTP42gYRdiIu9zBwAPbFUCi0DAhgNcS+7cDwVgM05A9bUDeuQMyE/u3CygVISgZhpIau/9PhdQG2C9DpxZZJmn/dn/Psmt0EFm////l84ThUTopE4VD/9JkubOGasTvN30C20G21qgUCkVCoUCgPMywrPCGly27V5q5t24vl/8jSlSAPCxzNseNCw3oh3NGBu4BZJ5hv7DRSfR/+eWG7nA8IKh2Olv5iz3q5m3//Joxo3JqNyYkSuGt/k6D4DeoBOHmHdl0dkZYA//tSxAUAC4B1Z/2DADEcA17Z/uhI4Yoik/TrZo+ww7UtmpW4LDWu2IacoJKJJeTSM+ZmAYBEiU+ZnnAwCn1VVVV6JUJQVnioKhrgqdKgqGpUFeCp0sDR3ztQNREDRUFioKuxKCpYGQBlRIBk+aLwb8KblGQVDdphPYTUdBOGbVpAaTF6ZdjEV0iRUZRCYkA4oUQDx5zqDugtXvza/7fuNNvfZ+j9v+T/2f//J/4cAAOTpE5K4zksR9MfIB+TDcQTI4gNs1XKAzEFUrGkxABYEBb/+1LEEYNKrEjgT/TCwYYVmUX+mHoKgWhKU5Eiw9SFIRmppw+3fYo4siPhUFeexM8KgIO6wVuPDDy01qeRaVbw357//y3+o8M0pBNlNLCGBzGKwyYw2IIFOE1WNTjRM6x8MlA1AxDhUHTAkEiyKpnbWrLcaOBotBUKbk1pypcWDAIK00AhKLGkUco6q9VWvM53mcaq3tVa8zjTM/tX//EDP//////////XAAmrwAAPoKwcw0ShDCZD/BQlhzinxQdorsOuXTEIC01ZkJyu4k/qPP/7UsQUAEjkrrkvZaPBIRXUoe5QObfMhYKX9RVgTPqCSCaSCaSC0XVdV1f/////6IAlguuAJSiDRNloNBsZg+0+Ts8MMCn81WUTRAlIi+GHECD0y8AWDIqswYsxGOSKVV7MqOni8tkVOip0fZX/////9HrMCbAz2EHGS4GKAAiRAAAYAcDdKd4G6Z/nwYgJ0ZAIgZyC8aPAs/iPBhwMpWDQNARltNS5Y61v//9i8Yl4SkFkIGTkAc0UBrIYLPA4MYBEy+YLMRuY4nhTC3hZA68H//tSxCoAyQC6mY6CkWDJBIsBz/QUrgNmahSzcrYw0/HhfnMAZBojDsgTFkDR5MDkG/DZEbk2FCmowqdqv2TYABiJwqqYjaQRGZ1URZ1DhSsdiHX/GBu0QpzIBNSaLqZ0ARkwFARxMrpt/Eh47mbQAhhU6sisFUxBTUUzLjEwMFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVX/+1LESoHHJCRaj/dmYAIAQAAQAARVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVTEFNRTMuMTAwVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVf/7UsSLg8AAAaQAAAAgAAA0gAAABFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVTEFNRTMuMTAwVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//tSxKGDwAABpAAAACAAADSAAAAEVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVMQU1FMy4xMDBVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//tSxKGDwAABpAAAACAAADSAAAAEVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVMQU1FMy4xMDBVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//tSxKGDwAABpAAAACAAADSAAAAEVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVMQU1FMy4xMDBVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVX/+1LEoYPAAAGkAAAAIAAANIAAAARVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVUxBTUUzLjEwMFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVf/7UsShg8AAAaQAAAAgAAA0gAAABFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVTEFNRTMuMTAwVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//tSxKGDwAABpAAAACAAADSAAAAEVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVMQU1FMy4xMDBVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVX/+1LEoYPAAAGkAAAAIAAANIAAAARVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVUxBTUUzLjEwMFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//tSxKGDwAABpAAAACAAADSAAAAEVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVMQU1FMy4xMDBVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//tSxKGDwAABpAAAACAAADSAAAAEVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVMQU1FMy4xMDBVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//tSxKGDwAABpAAAACAAADSAAAAEVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVMQU1FMy4xMDBVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//tSxKGDwAABpAAAACAAADSAAAAEVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVMQU1FMy4xMDBVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//tSxKGDwAABpAAAACAAADSAAAAEVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVMQU1FMy4xMDBVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV",duration:.609,format:"mp3",license:"CC0",author:"Kenney"},fL=lv.togglePlanMode.keys.map(t=>t==="Shift"?"⇧":t).join(""),mL=[{src:"/connections/gmail.png",name:"Gmail"},{src:"/connections/perplexity.png",name:"Perplexity"},{src:"/connections/github.png",name:"GitHub"}];function pL(){const t=F.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx("div",{className:"flex items-center -space-x-1.5",children:mL.map(gL)}),t[0]=e):e=t[0],e}function gL(t){return r.jsx("img",{src:t.src,alt:t.name,className:"size-5 rounded-sm ring-1 ring-border object-cover bg-white"},t.name)}function xL({disabled:t,onOpenConnections:e,virtualMcpId:s,selectedModel:n,isStreaming:i,onUnsupportedFile:o}){const a=re(),[l,c]=A.useState(!1),d=_p(hL),{org:h}=Oe(),{editor:u}=U0(),f=A.useRef(null),m=Yl(n),p=()=>{!m||i||(c(!1),f.current?.click())},g=async U=>{const W=U.target.files;if(!W||W.length===0||!u)return;const H=Array.from(W),{from:X}=u.state.selection;try{for(const q of H)await j9(u,n??null,q,X,o,a)}finally{f.current&&(f.current.value="")}},x=ht({connectionId:s,orgId:h.id,orgSlug:h.slug}),v=at.virtualMcpPrompts(s,h.id),{data:b,isLoading:y}=Mt({queryKey:v,queryFn:()=>kd(x),staleTime:6e4,enabled:l&&!!x}),_=b?.prompts??[],[L,w]=A.useState(null),{chatMode:j,setChatMode:S}=Ts(),[C,N]=ni(),V=no.find(U=>U.value===C.toolApprovalLevel)??no[0],E=a(V.shortKey),T=U=>{const W=no.find(H=>H.value===U);if(W){if(W.value===C.toolApprovalLevel){c(!1);return}d(),Me("chat_approval_level_changed",{from_level:C.toolApprovalLevel,to_level:W.value,source:"tools_popover"}),N({...C,toolApprovalLevel:W.value}),c(!1)}},k=j==="plan",R=()=>{d();const U=k?"default":"plan";Me("chat_mode_changed",{from_mode:j,to_mode:U,source:"tools_popover"}),S(U),c(!1)},P=()=>{e(),c(!1)},D=async(U,W)=>{if(!u||!x)return;const H=pn(U._meta),X={from:u.state.selection.from,to:u.state.selection.to};try{const q=await Xo(x,U.name,W);hr(u,X,{id:U.name,name:jr(U.name,H),metadata:q.messages,char:"/",kind:"prompt",args:W})}catch{ge.error(a("chat.toolsPopover.failedLoadPrompt"))}},I=async U=>{c(!1);const W=!!(U.arguments&&U.arguments.length>0);if(Me("chat_prompt_inserted",{prompt_name:U.name,with_arguments:W}),W){w(U);return}await D(U)},M=async U=>{L&&(await D(L,U),w(null))},O=()=>{d();const U=j==="gen-image"?"default":"gen-image";Me("chat_mode_changed",{from_mode:j,to_mode:U,source:"tools_popover"}),S(U),c(!1)},$=()=>{d();const U=j==="web-search"?"default":"web-search";Me("chat_mode_changed",{from_mode:j,to_mode:U,source:"tools_popover"}),S(U),c(!1)},B=()=>{d();const U=j==="deep-research"?"default":"deep-research";Me("chat_mode_changed",{from_mode:j,to_mode:U,source:"tools_popover"}),S(U),c(!1)},z=j==="gen-image",K=j==="web-search",G=j==="deep-research",Y=r.jsx("input",{ref:f,type:"file",multiple:!0,accept:L6(n??null),className:"hidden",onChange:g,disabled:i});return r.jsxs(r.Fragment,{children:[Y,r.jsxs(us,{open:l,onOpenChange:U=>{U&&!l&&Me("chat_tools_popover_opened",{chat_mode:j}),c(U)},children:[r.jsx(ds,{asChild:!0,children:r.jsxs(le,{type:"button",variant:"ghost",size:"default",disabled:t,title:a("chat.toolsPopover.tools"),"aria-label":a("chat.toolsPopover.tools"),className:ie("text-muted-foreground hover:text-foreground transition-[gap] duration-200 shrink min-w-0","gap-0 @[320px]/chat-bottom:gap-1.5"),children:[r.jsx(Em,{size:14}),r.jsx("span",{className:ie("min-w-0 truncate transition-[max-width,opacity] duration-200 ease-out max-w-0 opacity-0","@[320px]/chat-bottom:max-w-24 @[320px]/chat-bottom:opacity-100"),children:a("chat.toolsPopover.tools")})]})}),r.jsxs(hs,{align:"start",className:"w-56 p-1.5 space-y-1",children:[m?r.jsxs(Xe,{onClick:p,disabled:i,children:[r.jsx(kt,{size:16}),r.jsx("span",{className:"flex-1",children:a("chat.toolsPopover.addFile")})]}):r.jsxs(Ue,{children:[r.jsx(ze,{asChild:!0,children:r.jsxs(Xe,{"aria-disabled":"true",className:"opacity-50 cursor-not-allowed",onSelect:U=>U.preventDefault(),children:[r.jsx(kt,{size:16}),r.jsx("span",{className:"flex-1",children:a("chat.toolsPopover.addFile")})]})}),r.jsx(Ke,{side:"right",children:a("chat.toolsPopover.modelNoFileSupport")})]}),r.jsxs(Xe,{onClick:R,className:ie(k&&"text-special"),children:[r.jsx(fr,{size:16,className:ie(k&&"text-special")}),r.jsx("span",{className:"flex-1 whitespace-nowrap",children:a("chat.toolsPopover.planMode")}),r.jsx("span",{className:ie("text-xs text-muted-foreground",k&&"text-special font-medium"),children:fL})]}),r.jsxs(Xe,{onClick:O,className:ie(z&&"text-special"),children:[r.jsx(En,{size:16,className:ie(z&&"text-special")}),r.jsx("span",{className:"flex-1",children:a("chat.toolsPopover.createImage")}),z&&r.jsx("span",{className:"text-xs text-special font-medium",children:a("chat.toolsPopover.on")})]}),r.jsxs(Xe,{onClick:$,className:ie(K&&"text-special"),children:[r.jsx(gn,{size:16,className:ie(K&&"text-special")}),r.jsx("span",{className:"flex-1",children:a("chat.toolsPopover.webSearch")}),K&&r.jsx("span",{className:"text-xs text-special font-medium",children:a("chat.toolsPopover.on")})]}),r.jsxs(Xe,{onClick:B,className:ie(G&&"text-special"),children:[r.jsx(Pm,{size:16,className:ie(G&&"text-special")}),r.jsx("span",{className:"flex-1",children:a("chat.toolsPopover.deepResearch")}),G&&r.jsx("span",{className:"text-xs text-special font-medium",children:a("chat.toolsPopover.on")})]}),r.jsxs(Ao,{children:[r.jsxs(Eo,{className:"gap-2",children:[r.jsx("span",{className:"flex size-4 items-center justify-center text-base font-medium text-muted-foreground",children:"/"}),r.jsx("span",{className:"flex-1",children:a("chat.toolsPopover.prompts")})]}),r.jsx(Po,{className:"w-80 max-h-72 overflow-y-auto p-1.5",children:y?r.jsxs("div",{className:"flex items-center gap-2 px-2 py-3 text-sm text-muted-foreground",children:[r.jsx(et,{size:14,className:"animate-spin"}),a("chat.toolsPopover.loadingPrompts")]}):_.length===0?r.jsx("div",{className:"px-2 py-3 text-sm text-muted-foreground",children:a("chat.toolsPopover.noPromptsAvailable")}):_.map(U=>r.jsxs(Xe,{onClick:()=>I(U),className:"flex flex-col items-start gap-0.5",children:[r.jsx("span",{className:"font-medium text-sm capitalize",children:U.title||z0(U.name,pn(U._meta))}),U.description&&r.jsx("span",{className:"text-xs text-muted-foreground line-clamp-2",children:U.description})]},U.name))})]}),r.jsxs(Ao,{children:[r.jsxs(Eo,{className:"gap-2",children:[r.jsx(Wl,{size:16}),r.jsx("span",{className:"flex-1",children:a("chat.toolsPopover.approval")}),r.jsx("span",{className:"text-xs text-muted-foreground",children:E})]}),r.jsx(Po,{className:"w-48 p-1.5",children:r.jsx(Ad,{value:C.toolApprovalLevel,onValueChange:T,children:no.map(U=>r.jsx(Ro,{value:U.value,children:a(U.labelKey)},U.value))})})]}),r.jsxs(Xe,{onClick:P,children:[r.jsx(s2,{size:16}),r.jsx("span",{className:"flex-1",children:a("chat.toolsPopover.connections")}),r.jsx(A.Suspense,{children:r.jsx(pL,{})})]})]})]}),r.jsx(No,{prompt:L,setPrompt:w,onSubmit:M})]})}const vL=[{src:"/connections/github.png",name:"GitHub"},{src:"/connections/gmail.png",name:"Gmail"},{src:"/connections/linear.png",name:"Linear"},{src:"/connections/shopify.png",name:"Shopify"},{src:"/connections/firecrawl.png",name:"Firecrawl"},{src:"/connections/perplexity.png",name:"Perplexity"}];function bL(){const t=F.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx("div",{className:"flex items-center -space-x-1",children:vL.map(_L)}),t[0]=e):e=t[0],e}function _L(t){return r.jsx("img",{src:t.src,alt:t.name,className:"size-5 rounded-sm ring-2 ring-muted object-cover bg-white"},t.name)}function yL(t){const e=F.c(6),{onClick:s}=t;let n,i,o,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=ie("group relative z-10 flex items-center gap-3 w-full px-4 py-3","rounded-b-2xl","cursor-pointer"),i=r.jsx("p",{className:"flex-1 text-xs text-muted-foreground truncate text-left",children:"Connect tools and get more done"}),o=r.jsx(bL,{}),a=r.jsx(bn,{size:14,className:"shrink-0 text-muted-foreground/60 group-hover:text-muted-foreground transition-colors"}),e[0]=n,e[1]=i,e[2]=o,e[3]=a):(n=e[0],i=e[1],o=e[2],a=e[3]);let l;return e[4]!==s?(l=r.jsxs("button",{type:"button",onClick:s,className:n,children:[i,o,a]}),e[4]=s,e[5]=l):l=e[5],l}const oo=48;function LL(){const t=F.c(9),[e,s]=A.useState("idle"),[n,i]=A.useState(""),[o,a]=A.useState(""),[l,c]=A.useState(jL),d=A.useRef(null),h=A.useRef(null),u=A.useRef(null),f=A.useRef(null),m=A.useRef(0),p=A.useRef(!1),g=A.useRef(""),x=A.useRef(""),v=typeof window<"u"&&!!(window.SpeechRecognition||window.webkitSpeechRecognition);let b;t[0]===Symbol.for("react.memo_cache_sentinel")?(b=()=>{m.current&&(cancelAnimationFrame(m.current),m.current=0),h.current?.close().catch(wL),f.current?.getTracks().forEach(SL),u.current=null,h.current=null,f.current=null},t[0]=b):b=t[0];const y=b;let _;if(t[1]===Symbol.for("react.memo_cache_sentinel")){const V=E=>{f.current=E;const T=new AudioContext;h.current=T;const k=T.createMediaStreamSource(E),R=T.createAnalyser();R.fftSize=128,R.smoothingTimeConstant=.8,k.connect(R),u.current=R;const P=new Uint8Array(R.frequencyBinCount),D=()=>{if(!u.current)return;u.current.getByteFrequencyData(P);const I=[];for(let M=0;M<oo;M++){const O=Math.floor(M/oo*P.length);I.push(Math.max(.04,(P[O]??0)/255))}c(I),m.current=requestAnimationFrame(D)};D()};_=async()=>{const E=window.SpeechRecognition||window.webkitSpeechRecognition;if(!E)return s("unsupported"),"unsupported";let T;try{T=await navigator.mediaDevices.getUserMedia({audio:!0})}catch{return s("permission-denied"),"permission-denied"}i(""),a(""),x.current="",g.current="",p.current=!0,s("recording"),V(T);const k=new E;d.current=k,k.interimResults=!0,k.continuous=!0,k.lang=navigator.language||"en-US",k.onresult=R=>{let P="",D="";for(let I=R.resultIndex;I<R.results.length;I++){const M=R.results[I],O=M?.[0]?.transcript??"";M?.isFinal?D=D+O:P=P+O}D&&(g.current=g.current+D,i(g.current)),x.current=P,a(P)},k.onend=()=>{if(p.current)try{k.start()}catch{}};try{k.start()}catch{return p.current=!1,d.current=null,y(),s("idle"),"idle"}return"recording"},t[1]=_}else _=t[1];const L=_;let w;t[2]===Symbol.for("react.memo_cache_sentinel")?(w=()=>{p.current=!1,d.current?.stop(),y(),s("idle"),c(Array(oo).fill(.05)),a("");const V=(g.current+(x.current?" "+x.current:"")).trim();return i(""),g.current="",x.current="",V},t[2]=w):w=t[2];const j=w;let S;t[3]===Symbol.for("react.memo_cache_sentinel")?(S=()=>{p.current=!1,d.current?.abort(),y(),s("idle"),i(""),a(""),c(Array(oo).fill(.05)),g.current="",x.current=""},t[3]=S):S=t[3];const C=S;let N;return t[4]!==o||t[5]!==e||t[6]!==n||t[7]!==l?(N={status:e,transcript:n,interimTranscript:o,waveformData:l,isSupported:v,startRecording:L,stopRecording:j,cancelRecording:C},t[4]=o,t[5]=e,t[6]=n,t[7]=l,t[8]=N):N=t[8],N}function SL(t){return t.stop()}function wL(){}function jL(){return Array(oo).fill(.05)}function CL(t){const e=F.c(4),{data:s}=t;let n;e[0]!==s?(n=s.map(kL),e[0]=s,e[1]=n):n=e[1];let i;return e[2]!==n?(i=r.jsx("div",{className:"flex items-center justify-center gap-[2px] h-10 overflow-hidden","aria-hidden":"true",children:n}),e[2]=n,e[3]=i):i=e[3],i}function kL(t,e){return r.jsx("div",{className:"w-[2px] shrink-0 rounded-full bg-chart-2 transition-[height] duration-75 ease-out",style:{height:`${Math.max(4,Math.round(t*40))}px`}},e)}function VL({messageCount:t,showConnectionsBanner:e}){return t>0||e}function NL(t){return t.hasDraft?"send":t.isStreaming||t.isRunInProgress?"stop":"disabled"}function TL(t){const e=F.c(3),{message:s}=t;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=r.jsx(B0,{size:14,className:"shrink-0"}),e[0]=n):n=e[0];const i=s??"";let o;return e[1]!==i?(o=r.jsxs("div",{className:"flex w-full items-center gap-2 px-3 py-2.5 rounded-xl border border-border bg-muted/40 text-muted-foreground",children:[n,r.jsx("span",{className:"text-sm",children:i})]}),e[1]=i,e[2]=o):o=e[2],o}function AL(t,e,s){const n=F.c(7),{editor:i}=U0(),o=re(),[a,l]=A.useState(!1),c=A.useRef(0);let d,h;return n[0]!==s||n[1]!==i||n[2]!==e||n[3]!==t||n[4]!==o?(d=()=>{const u=g=>{g.dataTransfer?.types.includes("Files")&&(g.preventDefault(),c.current=c.current+1,l(!0))},f=g=>{g.preventDefault(),c.current=Math.max(0,c.current-1),c.current===0&&l(!1)},m=EL,p=g=>{if(g.preventDefault(),c.current=0,l(!1),s||!i||!t||!Yl(t))return;const x=g.dataTransfer?.files;if(!x||x.length===0)return;const{from:v}=i.state.selection;for(const b of Array.from(x))j9(i,t,b,v,e,o)};return window.addEventListener("dragenter",u),window.addEventListener("dragleave",f),window.addEventListener("dragover",m),window.addEventListener("drop",p),()=>{window.removeEventListener("dragenter",u),window.removeEventListener("dragleave",f),window.removeEventListener("dragover",m),window.removeEventListener("drop",p)}},h=[i,t,e,o,s],n[0]=s,n[1]=i,n[2]=e,n[3]=t,n[4]=o,n[5]=d,n[6]=h):(d=n[5],h=n[6]),A.useEffect(d,h),a}function EL(t){t.dataTransfer?.types.includes("Files")&&t.preventDefault()}function PL(t){const e=F.c(14),{selectedModel:s}=t,n=re();let i,o,a;if(e[0]!==s||e[1]!==n){const{parts:d}=Ym(s);e[5]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx(Bi,{size:24}),e[5]=a):a=e[5],i="text-sm font-medium";let h;e[6]!==n?(h=u=>n(u),e[6]=n,e[7]=h):h=e[7],o=n("chat.input.dropFilesHere",{fileTypes:d.map(h).join(", ")}),e[0]=s,e[1]=n,e[2]=i,e[3]=o,e[4]=a}else i=e[2],o=e[3],a=e[4];let l;e[8]!==i||e[9]!==o?(l=r.jsx("span",{className:i,children:o}),e[8]=i,e[9]=o,e[10]=l):l=e[10];let c;return e[11]!==a||e[12]!==l?(c=r.jsxs(r.Fragment,{children:[a,l]}),e[11]=a,e[12]=l,e[13]=c):c=e[13],c}function RL(){const t=F.c(5),e=re();let s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(B0,{size:24}),t[0]=s):s=t[0];let n;t[1]!==e?(n=e("chat.input.modelCannotReadAttachments"),t[1]=e,t[2]=n):n=t[2];let i;return t[3]!==n?(i=r.jsxs(r.Fragment,{children:[s,r.jsx("span",{className:"text-sm font-medium",children:n})]}),t[3]=n,t[4]=i):i=t[4],i}function DL(t){const e=F.c(11),{selectedModel:s,onUnsupportedFile:n,disabled:i}=t,o=AL(s,n,i);let a;e[0]!==s?(a=Yl(s),e[0]=s,e[1]=a):a=e[1];const l=a,c=o?"opacity-100":"opacity-0 pointer-events-none",d=l?"border-primary/40 text-primary/70":"border-destructive/30 text-destructive/70";let h;e[2]!==c||e[3]!==d?(h=ie("absolute inset-0 z-20 rounded-xl flex flex-col items-center justify-center gap-2 bg-muted border-2 border-dashed transition-opacity",c,d),e[2]=c,e[3]=d,e[4]=h):h=e[4];let u;e[5]!==s||e[6]!==l?(u=l?r.jsx(PL,{selectedModel:s}):r.jsx(RL,{}),e[5]=s,e[6]=l,e[7]=u):u=e[7];let f;return e[8]!==h||e[9]!==u?(f=r.jsx("div",{className:h,children:u}),e[8]=h,e[9]=u,e[10]=f):f=e[10],f}function IL(){const t=F.c(6),e=St(),{org:s,locator:n}=Oe(),{create:i}=Hl();let o;return t[0]!==i||t[1]!==n||t[2]!==e||t[3]!==s.id||t[4]!==s.slug?(o=async a=>{const{tiptapDoc:l,virtualMcp:c}=a,d=crypto.randomUUID(),h=c?.id??Yo(s.id).id;km(sessionStorage,n,d,{tiptapDoc:l});try{await i({id:d,virtual_mcp_id:h})}catch{}const u={virtualmcpid:h,autosend:uv};e({to:"/$org/$taskId",params:{org:s.slug,taskId:d},search:u})},t[0]=i,t[1]=n,t[2]=e,t[3]=s.id,t[4]=s.slug,t[5]=o):o=t[5],o}function ML({onOpenContextPanel:t,showConnectionsBanner:e=!1}){const s=re(),n=F0(),i=Ii(),o=n?.messages??[],a=n?.isStreaming??!1,l=n?.isRunInProgress??!1,c=n?.stop??(()=>{}),d=i?.taskId??"",h=d||bv,u=IL(),{selectedModel:f,selectedVirtualMcp:m,isModelsLoading:p,tiptapDocRef:g,imageModel:x,webSearchModel:v,deepResearchModel:b,chatMode:y,setChatMode:_}=Ts(),{data:L}=Di.useSession(),w=L?.user?.id,{org:j,locator:S}=Oe(),C=Yo(j.id).id,N=gs(m?.id??C),V=_p(Z6),[E,T]=A.useState(!1),{unsupportedFile:k,onUnsupportedFile:R,clearUnsupportedFile:P}=Jy(),D=LL(),I=A.useRef(void 0),M=async()=>{I.current=z;const ue=await D.startRecording();Me("chat_voice_started",{thread_id:d,outcome:ue==="recording"?"started":ue==="unsupported"?"unsupported":ue==="permission-denied"?"permission_denied":"unknown"})},O=()=>{Me("chat_voice_confirmed",{thread_id:d});const ue=D.stopRecording();H.current?.syncVoiceText(I.current,ue),H.current?.focus()},$=()=>{Me("chat_voice_cancelled",{thread_id:d}),D.cancelRecording(),H.current?.restoreContent(I.current)};A.useEffect(()=>{if(D.status!=="recording")return;const ue=(D.transcript+(D.interimTranscript?" "+D.interimTranscript:"")).trim();H.current?.syncVoiceText(I.current,ue)},[D.transcript,D.interimTranscript,D.status]);const B=i?.activeTask??null,[z,K]=A.useState(()=>Fu(sessionStorage,S,h)??void 0),G=ue=>{K(ue),g.current=ue,vv(sessionStorage,S,h,ue,{onQuotaExceeded:({docSizeBytes:ce})=>{Me("chat_draft_quota_exceeded",{thread_id:d||null,doc_size_bytes:ce}),console.warn("[chat-draft] sessionStorage quota exceeded; draft not saved")}})},Y=A.useRef(d);if(Y.current!==d){Y.current=d;const ue=Fu(sessionStorage,S,h)??void 0;K(ue),g.current=ue}const W=[...o].reverse().find(ue=>ue.role==="assistant")?.metadata?.modelLimits?.contextWindow??f?.limits?.contextWindow,H=A.useRef(null),X=A.useRef(!1),q=y==="plan";A.useEffect(()=>{const ue=ce=>{jm(ce)&&ce.code==="KeyL"&&(ce.preventDefault(),ce.shiftKey&&_(y==="plan"?"default":"plan"),H.current?.focus())};return document.addEventListener("keydown",ue),()=>document.removeEventListener("keydown",ue)},[y,_]);const Z=mm(o),ee=[...o].reverse().find(ue=>ue.role==="assistant"&&ue.metadata?.usage)?.metadata?.usage?.contextTokens??0,J=!p&&!gv(z),te=NL({hasDraft:J,isStreaming:a,isRunInProgress:l}),se=te==="send",ne=te==="stop",de=VL({messageCount:o.length,showConnectionsBanner:e}),xe=ue=>{if(ue?.preventDefault(),te==="send"&&z){if(Me("chat_message_sent",{thread_id:d||null,mode:y,model_id:f?.modelId??null,model_provider:f?.providerId??null,virtual_mcp_id:m?.id??null,submission:ue?"button_or_enter":"programmatic"}),n){if(n.isSendInFlight()){ge.info(s("chat.input.stillSendingPreviousMessage"));return}n.sendMessage(z)}else u({tiptapDoc:z,virtualMcp:m});xv(sessionStorage,S,h),G(void 0)}else te==="stop"&&(Me("chat_message_stopped",{thread_id:d}),c())};return w&&B?.created_by&&B.created_by!==w?r.jsx(TL,{message:s("chat.input.readOnlyOthersChat")}):r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"flex flex-col w-full justify-end",children:r.jsxs("div",{className:"relative rounded-2xl w-full flex flex-col",children:[e&&r.jsx("div",{className:"absolute inset-0 rounded-2xl pointer-events-none bg-muted/50"}),n&&i&&r.jsx(tc,{}),n&&i&&d?r.jsx(f_,{taskId:d}):null,r.jsx(vp,{tiptapDoc:z,setTiptapDoc:G,disabled:D.status==="recording",enterToSubmit:!0,placeholder:s("chat.input.placeholder"),onSubmit:xe,suggestionOpenRef:X,children:r.jsxs("form",{onSubmit:xe,className:ie("w-full relative rounded-2xl min-h-[110px] md:min-h-[130px] flex flex-col bg-card dark:bg-muted card-shadow overflow-hidden"),children:[r.jsx(DL,{selectedModel:f,onUnsupportedFile:R,disabled:D.status==="recording"}),r.jsx("div",{className:"group/input relative flex flex-col gap-2 flex-1",children:r.jsx(bp,{ref:H,disabled:D.status==="recording",virtualMcpId:m?.id??C,showFileUploader:!0,selectedModel:f,onUnsupportedFile:R,suggestionOpenRef:X})}),r.jsx("div",{className:"@container/chat-bottom flex items-center justify-between p-2.5 gap-1",children:D.status==="recording"?r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"flex-1"}),r.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[r.jsx(CL,{data:D.waveformData.slice(0,28)}),r.jsx("button",{type:"button",onClick:$,className:"flex items-center justify-center size-8 rounded-lg hover:bg-muted text-muted-foreground hover:text-foreground transition-colors","aria-label":s("chat.input.cancelRecording"),children:r.jsx(ks,{size:16})}),r.jsx("button",{type:"button",onClick:O,className:"flex items-center justify-center size-8 rounded-lg bg-foreground text-background hover:opacity-80 transition-opacity","aria-label":s("chat.input.useTranscription"),children:r.jsx(zt,{size:16})})]})]}):r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[r.jsx(xL,{disabled:!1,onOpenConnections:()=>{Me("connections_dialog_opened",{source:"tools_popover",mode:"add"}),T(!0)},virtualMcpId:m?.id??C,selectedModel:f,isStreaming:a,onUnsupportedFile:R}),q&&r.jsxs("button",{type:"button",onClick:()=>{V(),Me("chat_mode_changed",{from_mode:"plan",to_mode:"default",source:"pill_dismiss"}),_("default")},title:s("chat.input.planMode"),"aria-label":s("chat.input.planMode"),className:"flex items-center gap-1.5 h-8 rounded-lg px-2.5 text-sm font-medium text-violet-600 dark:text-violet-400 hover:bg-violet-500/10 group min-w-0 shrink animate-in fade-in duration-200",children:[r.jsx(fr,{size:14,className:"shrink-0"}),r.jsx("span",{className:"min-w-0 truncate transition-[max-width,opacity] duration-200 ease-out max-w-0 opacity-0 @[320px]/chat-bottom:max-w-32 @[320px]/chat-bottom:opacity-100",children:s("chat.input.planMode")}),r.jsx(ks,{size:14,className:"shrink-0 hidden group-hover:block group-disabled:hidden"})]}),y==="gen-image"&&x&&r.jsxs("button",{type:"button",onClick:()=>{V(),Me("chat_mode_changed",{from_mode:"gen-image",to_mode:"default",source:"pill_dismiss"}),_("default")},title:s("chat.input.createImage"),"aria-label":s("chat.input.createImage"),className:"flex items-center gap-1.5 h-8 rounded-lg px-2.5 text-sm font-medium text-pink-600 dark:text-pink-400 hover:bg-pink-500/10 group min-w-0 shrink animate-in fade-in duration-200 disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:bg-transparent",children:[r.jsx(En,{size:14,className:"shrink-0"}),r.jsx("span",{className:"min-w-0 truncate transition-[max-width,opacity] duration-200 ease-out max-w-0 opacity-0 @[320px]/chat-bottom:max-w-[120px] @[320px]/chat-bottom:opacity-100",children:s("chat.input.createImage")}),r.jsx(ks,{size:14,className:"shrink-0 hidden group-hover:block group-disabled:hidden"})]}),y==="web-search"&&v&&r.jsxs("button",{type:"button",onClick:()=>{V(),Me("chat_mode_changed",{from_mode:"web-search",to_mode:"default",source:"pill_dismiss"}),_("default")},title:s("chat.input.webSearch"),"aria-label":s("chat.input.webSearch"),className:"flex items-center gap-1.5 h-8 rounded-lg px-2.5 text-sm font-medium text-blue-600 dark:text-blue-400 hover:bg-blue-500/10 group min-w-0 shrink animate-in fade-in duration-200 disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:bg-transparent",children:[r.jsx(gn,{size:14,className:"shrink-0"}),r.jsx("span",{className:"min-w-0 truncate transition-[max-width,opacity] duration-200 ease-out max-w-0 opacity-0 @[320px]/chat-bottom:max-w-[120px] @[320px]/chat-bottom:opacity-100",children:s("chat.input.webSearch")}),r.jsx(ks,{size:14,className:"shrink-0 hidden group-hover:block group-disabled:hidden"})]}),y==="deep-research"&&b&&r.jsxs("button",{type:"button",onClick:()=>{V(),Me("chat_mode_changed",{from_mode:"deep-research",to_mode:"default",source:"pill_dismiss"}),_("default")},title:s("chat.input.deepResearch"),"aria-label":s("chat.input.deepResearch"),className:"flex items-center gap-1.5 h-8 rounded-lg px-2.5 text-sm font-medium text-blue-600 dark:text-blue-400 hover:bg-blue-500/10 group min-w-0 shrink animate-in fade-in duration-200 disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:bg-transparent",children:[r.jsx(Pm,{size:14,className:"shrink-0"}),r.jsx("span",{className:"min-w-0 truncate transition-[max-width,opacity] duration-200 ease-out max-w-0 opacity-0 @[320px]/chat-bottom:max-w-[120px] @[320px]/chat-bottom:opacity-100",children:s("chat.input.deepResearch")}),r.jsx(ks,{size:14,className:"shrink-0 hidden group-hover:block group-disabled:hidden"})]}),W&&ee>0&&r.jsx(wx,{usage:Z,totalTokens:ee,contextWindow:W,onOpenContextPanel:t})]}),r.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[de&&r.jsx(np,{virtualMcp:N,currentBranch:i?.currentBranch??null}),r.jsx(Uy,{}),D.isSupported&&r.jsx(le,{type:"button",onClick:M,disabled:!1,variant:"ghost",size:"icon",className:ie("size-8 rounded-lg transition-colors",D.status==="permission-denied"?"text-destructive hover:text-destructive hover:bg-destructive/10":"text-muted-foreground hover:text-foreground"),title:D.status==="permission-denied"?s("chat.input.microphoneAccessDenied"):s("chat.input.voiceInput"),"aria-label":D.status==="permission-denied"?s("chat.input.microphoneAccessDenied"):s("chat.input.voiceInput"),children:r.jsx(Ev,{size:18})}),r.jsx(le,{type:ne?"button":"submit",onClick:ue=>{ne&&(ue.preventDefault(),ue.stopPropagation(),c())},variant:se||ne?"default":"ghost",size:"icon",disabled:!se&&!ne,className:ie("size-8 rounded-lg transition-all",!se&&!ne&&"bg-muted text-muted-foreground hover:bg-muted hover:text-muted-foreground cursor-not-allowed"),title:s(te==="stop"?a?"chat.input.stopGenerating":"chat.input.cancelRun":"chat.input.sendMessageEnter"),"aria-label":s(te==="stop"?a?"chat.input.stopGenerating":"chat.input.cancelRun":"chat.input.sendMessage"),children:ne?r.jsx(Pv,{size:20}):r.jsx($0,{size:20})})]})]})})]})},d),e&&r.jsx(yL,{onClick:()=>{Me("connections_banner_clicked",{source:"home_chat_input"}),Me("connections_dialog_opened",{source:"home_banner",mode:"add"}),T(!0)}})]})}),r.jsx(o9,{mode:"browse",open:E,onOpenChange:T,defaultTab:"all"}),r.jsx(Gy,{info:k,onClose:P})]})}function OL(){const t=F.c(7),e=St(),s=F0()?.messages??[],n=Ii()?.taskId??null;let i;t[0]!==s?(i=s.some($L),t[0]=s,t[1]=i):i=t[1];const o=i,a=A.useRef(null);let l,c;t[2]!==e||t[3]!==o||t[4]!==n?(l=()=>{!o||!n||a.current===n||(a.current=n,e({to:".",search:BL,replace:!0}))},c=[o,n,e],t[2]=e,t[3]=o,t[4]=n,t[5]=l,t[6]=c):(l=t[5],c=t[6]),A.useEffect(l,c)}function BL(t){return{...t,main:"preview"}}function $L(t){return t.parts?.some(FL)}function FL(t){const e=t;return e.type==="tool-load_repo"&&e.state==="output-available"&&e.output?.success===!0}const zL={usd:[{dollars:10,labelKey:"chat.creditsEmptyState.starterLabel"},{dollars:20,labelKey:"chat.creditsEmptyState.popularLabel"},{dollars:100,labelKey:"chat.creditsEmptyState.bestValueLabel"}],brl:[{dollars:50,labelKey:"chat.creditsEmptyState.starterLabel"},{dollars:100,labelKey:"chat.creditsEmptyState.popularLabel"},{dollars:500,labelKey:"chat.creditsEmptyState.bestValueLabel"}]};function yp(t){return`deco-credits-empty-dismissed:${t}`}function KL(t){try{return localStorage.getItem(yp(t))==="1"}catch{return!1}}function UL(){const t=F.c(68),e=re(),{org:s}=Oe(),n=St(),{decoKeyId:i}=i9(),o=$s(),[a,l]=A.useState(!0),[c,d]=A.useState(""),[h,u]=A.useState(!1),[f,m]=A.useState("usd"),p=f==="brl"?"R$":"$";let g;t[0]!==s.id?(g=()=>{Me("credits_empty_state_dismissed",{organization_id:s.id}),l(!1);try{localStorage.setItem(yp(s.id),"1")}catch{}},t[0]=s.id,t[1]=g):g=t[1];const x=g;let v,b;t[2]!==a||t[3]!==s.id?(v=()=>{a&&Me("credits_empty_state_shown",{organization_id:s.id})},b=[a,s.id],t[2]=a,t[3]=s.id,t[4]=v,t[5]=b):(v=t[4],b=t[5]),A.useEffect(v,b);let y;t[6]!==f||t[7]!==o?(y=async H=>{const{url:X}=await o.call("AI_PROVIDER_TOPUP_URL",{providerId:"deco",amountCents:H,currency:f});return X},t[6]=f,t[7]=o,t[8]=y):y=t[8];let _;t[9]!==x?(_=H=>{H&&window.open(H,"_blank","noopener,noreferrer"),x()},t[9]=x,t[10]=_):_=t[10];let L;t[11]!==e?(L=H=>{ge.error(e("chat.creditsEmptyState.topUpFailed",{message:H.message}))},t[11]=e,t[12]=L):L=t[12];let w;t[13]!==y||t[14]!==_||t[15]!==L?(w={mutationFn:y,onSuccess:_,onError:L},t[13]=y,t[14]=_,t[15]=L,t[16]=w):w=t[16];const{mutate:j,isPending:S}=Ys(w),C=parseFloat(c),N=!isNaN(C)&&C>=1;if(!a)return null;let V;t[17]!==x?(V=H=>!H&&x(),t[17]=x,t[18]=V):V=t[18];let E;t[19]===Symbol.for("react.memo_cache_sentinel")?(E=r.jsx("div",{className:"absolute inset-x-0 top-0 h-24 bg-gradient-to-b from-warning/8 to-transparent pointer-events-none rounded-t-lg"}),t[19]=E):E=t[19];let T;t[20]===Symbol.for("react.memo_cache_sentinel")?(T=r.jsx("div",{className:"flex items-center justify-center size-11 rounded-full bg-warning/10 border border-warning/20 mx-auto",children:r.jsx(Rm,{size:20,className:"text-warning"})}),t[20]=T):T=t[20];let k;t[21]!==e?(k=e("chat.creditsEmptyState.title"),t[21]=e,t[22]=k):k=t[22];let R;t[23]!==k?(R=r.jsx(ps,{className:"text-lg font-semibold",children:k}),t[23]=k,t[24]=R):R=t[24];let P;t[25]!==e?(P=e("chat.creditsEmptyState.description"),t[25]=e,t[26]=P):P=t[26];let D;t[27]!==P?(D=r.jsx(ri,{className:"mt-2 text-[13px] leading-relaxed max-w-[320px] mx-auto",children:P}),t[27]=P,t[28]=D):D=t[28];let I;t[29]!==R||t[30]!==D?(I=r.jsxs("div",{className:"relative px-6 pt-7 pb-5",children:[E,r.jsxs(ms,{className:"relative gap-3",children:[T,r.jsxs("div",{className:"text-center",children:[R,D]})]})]}),t[29]=R,t[30]=D,t[31]=I):I=t[31];let M;t[32]!==f||t[33]!==p||t[34]!==c||t[35]!==C||t[36]!==i||t[37]!==N||t[38]!==S||t[39]!==h||t[40]!==e||t[41]!==j?(M=i&&r.jsxs("div",{className:"px-6 pb-5",children:[r.jsx("div",{className:"mb-4",children:r.jsxs(n9,{type:"single",variant:"outline",size:"sm",value:f,onValueChange:H=>{H&&m(H)},children:[r.jsx(To,{value:"usd",className:"h-8 px-3 text-xs",children:"USD"}),r.jsx(To,{value:"brl",className:"h-8 px-3 text-xs",children:"BRL"})]})}),r.jsx("div",{className:"grid grid-cols-3 gap-2.5",children:zL[f].map(H=>{const{dollars:X,labelKey:q}=H;return r.jsxs("button",{type:"button",disabled:S,onClick:()=>{Me("credits_topup_clicked",{amount_cents:X*100,currency:f,tier_label:q,source:"empty_state"}),j(X*100)},className:ie("relative flex flex-col items-center gap-1 py-6 rounded-xl border transition-all duration-150 cursor-pointer","disabled:opacity-50 disabled:cursor-wait","border-border hover:border-foreground/20 hover:bg-muted/30"),children:[r.jsxs("span",{className:"text-2xl font-semibold tabular-nums text-foreground",children:[p,X]}),r.jsx("span",{className:"text-xs text-muted-foreground",children:e(q)})]},X)})}),h?r.jsxs("div",{className:"flex gap-2 mt-3",children:[r.jsxs("div",{className:"relative flex-1",children:[r.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-sm text-muted-foreground select-none",children:p}),r.jsx(rt,{type:"number",min:"1",step:"1",placeholder:"50",value:c,onChange:H=>d(H.target.value),className:"h-10 text-sm pl-7",autoFocus:!0})]}),r.jsx(le,{className:"h-10",disabled:!N||S,onClick:()=>{Me("credits_topup_clicked",{amount_cents:Math.round(C*100),currency:f,tier_label:"custom",source:"empty_state"}),j(Math.round(C*100))},children:e(S?"chat.creditsEmptyState.opening":"chat.creditsEmptyState.add")})]}):r.jsx("button",{type:"button",className:"w-full mt-2.5 text-xs text-muted-foreground hover:text-foreground transition-colors py-1",onClick:()=>u(!0),children:e("chat.creditsEmptyState.enterCustomAmount")})]}),t[32]=f,t[33]=p,t[34]=c,t[35]=C,t[36]=i,t[37]=N,t[38]=S,t[39]=h,t[40]=e,t[41]=j,t[42]=M):M=t[42];let O;t[43]!==x||t[44]!==n||t[45]!==s.slug?(O=()=>{n({to:"/$org/settings/ai-providers",params:{org:s.slug}}),x()},t[43]=x,t[44]=n,t[45]=s.slug,t[46]=O):O=t[46];let $;t[47]!==e?($=e("chat.creditsEmptyState.useYourOwnProvider"),t[47]=e,t[48]=$):$=t[48];let B;t[49]===Symbol.for("react.memo_cache_sentinel")?(B=r.jsx(kr,{size:12,className:"transition-transform duration-150 group-hover:translate-x-0.5"}),t[49]=B):B=t[49];let z;t[50]!==O||t[51]!==$?(z=r.jsxs("button",{type:"button",className:"group flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors",onClick:O,children:[$,B]}),t[50]=O,t[51]=$,t[52]=z):z=t[52];let K;t[53]!==e?(K=e("chat.creditsEmptyState.skipForNow"),t[53]=e,t[54]=K):K=t[54];let G;t[55]!==x||t[56]!==K?(G=r.jsx(le,{variant:"ghost",size:"sm",className:"text-xs text-muted-foreground",onClick:x,children:K}),t[55]=x,t[56]=K,t[57]=G):G=t[57];let Y;t[58]!==z||t[59]!==G?(Y=r.jsxs("div",{className:"px-6 py-3.5 border-t border-border bg-muted/30 flex items-center justify-between",children:[z,G]}),t[58]=z,t[59]=G,t[60]=Y):Y=t[60];let U;t[61]!==I||t[62]!==M||t[63]!==Y?(U=r.jsxs(es,{className:"sm:max-w-[500px] gap-0 p-0 overflow-hidden",onOpenAutoFocus:HL,children:[I,M,Y]}),t[61]=I,t[62]=M,t[63]=Y,t[64]=U):U=t[64];let W;return t[65]!==U||t[66]!==V?(W=r.jsx(ts,{open:!0,onOpenChange:V,children:U}),t[65]=U,t[66]=V,t[67]=W):W=t[67],W}function HL(t){return t.preventDefault()}function WL(t){const e=F.c(6),{balanceDollars:s}=t;let n;e[0]!==s?(n=s.toFixed(2),e[0]=s,e[1]=n):n=e[1];const i=n;let o,a;e[2]===Symbol.for("react.memo_cache_sentinel")?(o=ie("inline-flex items-center gap-1.5 px-3 py-1 rounded-full","bg-success/10 border border-success/20","animate-in fade-in-0 slide-in-from-bottom-2 duration-300"),a=r.jsx(Rm,{size:13,className:"text-success"}),e[2]=o,e[3]=a):(o=e[2],a=e[3]);let l;return e[4]!==i?(l=r.jsxs("div",{className:o,children:[a,r.jsxs("span",{className:"text-xs font-medium text-success tabular-nums",children:["$",i," in credits to get started"]})]}),e[4]=i,e[5]=l):l=e[5],l}function qL(){const t=F.c(8),{org:e}=Oe(),s=St();let n;t[0]!==s||t[1]!==e.slug?(n=()=>s({to:"/$org/settings/ai-providers",params:{org:e.slug}}),t[0]=s,t[1]=e.slug,t[2]=n):n=t[2];let i,o,a;t[3]===Symbol.for("react.memo_cache_sentinel")?(i=ie("inline-flex items-center gap-1.5 px-3 py-1 rounded-full cursor-pointer","bg-warning/10 border border-warning/20","hover:bg-warning/15","transition-colors duration-150","animate-in fade-in-0 slide-in-from-bottom-2 duration-300"),o=r.jsx(wn,{size:13,className:"text-warning"}),a=r.jsx("span",{className:"text-xs font-medium text-warning",children:"No credits remaining · Add more"}),t[3]=i,t[4]=o,t[5]=a):(i=t[3],o=t[4],a=t[5]);let l;return t[6]!==n?(l=r.jsxs("button",{type:"button",onClick:n,className:i,children:[o,a]}),t[6]=n,t[7]=l):l=t[7],l}function GL(t){const e=F.c(11),{className:s}=t;let n;e[0]!==s?(n=ie("flex h-full w-full flex-col bg-background",s),e[0]=s,e[1]=n):n=e[1];let i;e[2]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx("div",{className:"size-6 rounded-lg bg-muted animate-pulse"}),e[2]=i):i=e[2];let o;e[3]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsxs("div",{className:"flex items-center gap-3",children:[i,r.jsxs("div",{className:"flex flex-col gap-2",children:[r.jsx("div",{className:"h-3.5 w-28 rounded bg-muted animate-pulse"}),r.jsx("div",{className:"h-3 w-40 rounded bg-muted/60 animate-pulse"})]})]}),e[3]=o):o=e[3];let a;e[4]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx("div",{className:"flex items-center h-12 flex-none border-b border-border/80 px-4",children:r.jsxs("div",{className:"flex items-center justify-between gap-3 w-full",children:[o,r.jsxs("div",{className:"flex items-end gap-2",children:[r.jsx("div",{className:"h-6 w-6 rounded-full bg-muted animate-pulse"}),r.jsx("div",{className:"h-6 w-6 rounded-lg bg-muted animate-pulse"})]})]})}),e[4]=a):a=e[4];let l;e[5]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx("div",{className:"flex-1 overflow-hidden px-4 py-4",children:r.jsxs("div",{className:"mx-auto flex w-full max-w-2xl flex-col gap-4",children:[r.jsx(va,{align:"right",width:"w-3/4"}),r.jsx(va,{align:"left",width:"w-full",lines:3}),r.jsx(va,{align:"right",width:"w-2/3"}),r.jsx(va,{align:"left",width:"w-5/6",lines:2})]})}),e[5]=l):l=e[5];let c;e[6]===Symbol.for("react.memo_cache_sentinel")?(c=r.jsx("div",{className:"relative flex flex-1 flex-col gap-2 p-2.5",children:r.jsx("div",{className:"relative flex-1",children:r.jsxs("div",{className:"space-y-2 p-2",children:[r.jsx("div",{className:"h-3 w-full rounded bg-muted/40 animate-pulse"}),r.jsx("div",{className:"h-3 w-4/5 rounded bg-muted/40 animate-pulse"})]})})}),e[6]=c):c=e[6];let d;e[7]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx("div",{className:"flex items-center gap-1",children:r.jsx("div",{className:"size-8 rounded-full bg-muted/60 animate-pulse"})}),e[7]=d):d=e[7];let h;e[8]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx("div",{className:"px-4 py-4",children:r.jsx("div",{className:"mx-auto w-full max-w-2xl",children:r.jsxs("div",{className:"relative flex min-h-[130px] flex-col rounded-xl bg-background card-shadow",children:[c,r.jsxs("div",{className:"flex items-center justify-between px-2.5 pb-2.5",children:[d,r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx("div",{className:"h-8 w-32 rounded-lg bg-muted/60 animate-pulse"}),r.jsx("div",{className:"size-8 rounded-full bg-muted animate-pulse"})]})]})]})})}),e[8]=h):h=e[8];let u;return e[9]!==n?(u=r.jsxs("div",{className:n,children:[a,l,h]}),e[9]=n,e[10]=u):u=e[10],u}function va(t){const e=F.c(22),{align:s,width:n,lines:i}=t,o=n===void 0?"w-full":n,a=i===void 0?1:i,l=s==="right"?"flex-row-reverse":"flex-row";let c;e[0]!==l?(c=ie("flex w-full gap-4 px-4 py-2",l),e[0]=l,e[1]=c):c=e[1];const d=s==="right"?"ml-auto max-w-3/4 items-end":"w-full items-start";let h;e[2]!==d?(h=ie("flex min-w-0 flex-col gap-2",d),e[2]=d,e[3]=h):h=e[3];let u;e[4]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx("div",{className:"h-3 w-16 rounded bg-muted/40 animate-pulse"}),e[4]=u):u=e[4];const f=s==="right"?"bg-muted":"bg-transparent border border-border/40";let m;e[5]!==f||e[6]!==o?(m=ie("min-w-0 rounded-2xl p-4",f,o),e[5]=f,e[6]=o,e[7]=m):m=e[7];let p;e[8]!==a?(p=Array.from({length:a}),e[8]=a,e[9]=p):p=e[9];let g;e[10]!==a||e[11]!==p?(g=r.jsx("div",{className:"space-y-2",children:p.map((y,_)=>r.jsx("div",{className:ie("h-3 rounded bg-muted-foreground/20 animate-pulse",_===a-1?"w-3/4":"w-full"),style:{animationDelay:`${_*.1}s`}},_))}),e[10]=a,e[11]=p,e[12]=g):g=e[12];let x;e[13]!==g||e[14]!==m?(x=r.jsx("div",{className:m,children:g}),e[13]=g,e[14]=m,e[15]=x):x=e[15];let v;e[16]!==x||e[17]!==h?(v=r.jsxs("div",{className:h,children:[u,x]}),e[16]=x,e[17]=h,e[18]=v):v=e[18];let b;return e[19]!==v||e[20]!==c?(b=r.jsx("div",{className:c,children:v}),e[19]=v,e[20]=c,e[21]=b):b=e[21],b}function YL(t){const e=F.c(7),{scrollRef:s,sentinelRef:n,hasMoreOlder:i,isFetchingOlder:o,fetchOlderMessages:a}=t;let l,c;e[0]!==a||e[1]!==i||e[2]!==o||e[3]!==s||e[4]!==n?(l=()=>{const d=n.current,h=s.current;if(!d||!h||!i)return;const u=new IntersectionObserver(async f=>{if(!f[0]?.isIntersecting||o||!i)return;const p=h.scrollHeight,g=h.scrollTop;await a(),requestAnimationFrame(()=>{const x=h.scrollHeight;h.scrollTop=g+(x-p)})},{root:h,rootMargin:"200px 0px 0px 0px"});return u.observe(d),()=>u.disconnect()},c=[s,n,i,o,a],e[0]=a,e[1]=i,e[2]=o,e[3]=s,e[4]=n,e[5]=l,e[6]=c):(l=e[5],c=e[6]),A.useEffect(l,c)}function JL(t){const e=F.c(5),{className:s,children:n}=t;let i;e[0]!==s?(i=ie("flex flex-col h-full w-full bg-background transform-[translateZ(0)]",s),e[0]=s,e[1]=i):i=e[1];let o;return e[2]!==n||e[3]!==i?(o=r.jsx("div",{className:i,children:n}),e[2]=n,e[3]=i,e[4]=o):o=e[4],o}function XL(t){const e=F.c(5),{children:s,className:n}=t;let i;e[0]!==n?(i=ie("flex-1 min-h-0 overflow-y-auto isolate",n),e[0]=n,e[1]=i):i=e[1];let o;return e[2]!==s||e[3]!==i?(o=r.jsx("div",{className:i,children:s}),e[2]=s,e[3]=i,e[4]=o):o=e[4],o}function QL(t){const e=F.c(2),{children:s}=t;let n;return e[0]!==s?(n=r.jsx("div",{className:"min-h-full shrink-0 w-full flex items-center justify-center max-w-2xl mx-auto py-10",children:s}),e[0]=s,e[1]=n):n=e[1],n}function ZL(){const t=re(),{messages:e,status:s,hasMoreOlder:n,isFetchingOlder:i,fetchOlderMessages:o}=Js(),{taskId:a}=Zt();OL();const l=um(a??""),c=px(l),d=c.size===0?e:e.filter(b=>!c.has(b.id)),h=jx(d),u=h.at(-1),m=y8()*l8+16,p=A.useRef(null),g=A.useRef(null);YL({scrollRef:p,sentinelRef:g,hasMoreOlder:n,isFetchingOlder:i,fetchOlderMessages:o});const x=Cx({initial:!1}),v=b=>{p.current=b,x.scrollRef(b)};return r.jsx(kx,{messages:e,children:r.jsxs("div",{className:"relative h-full w-full min-w-0",children:[r.jsx("div",{ref:v,"data-chat-scroller":!0,className:"w-full min-w-0 max-w-full overflow-y-auto h-full [container-type:size]",style:{paddingBottom:m},children:r.jsxs("div",{ref:x.contentRef,className:"overflow-x-clip",children:[r.jsxs("div",{className:"flex flex-col min-w-0 max-w-2xl mx-auto w-full",children:[r.jsx("div",{ref:g,"aria-hidden":!0,className:"h-px"}),i&&r.jsx("div",{className:"flex items-center justify-center py-3 text-xs text-muted-foreground",children:t("chat.chat.loadingOlderMessages")}),h.slice(0,-1).map((b,y)=>r.jsx(Ou,{pair:b,isLastPair:!1,status:y===h.length-1?s:void 0},`pair-${b.user?.id??b.assistant?.id}`))]}),u&&r.jsx("div",{className:"min-h-[100cqh] min-w-0 max-w-2xl mx-auto w-full",children:r.jsx(Ou,{pair:u,isLastPair:!0,status:s},`pair-${u.user?.id??u.assistant?.id}`)})]})}),!x.isAtBottom&&r.jsx(le,{type:"button",variant:"outline",size:"icon-sm","aria-label":t("chat.chat.jumpToLatest"),className:"absolute left-1/2 z-50 -translate-x-1/2 rounded-full shadow-md animate-in fade-in duration-200 dark:bg-background dark:hover:bg-accent",style:{bottom:m+8},onClick:()=>{x.scrollToBottom()},children:r.jsx(cx,{size:14})})]})})}function eS(t){const e=F.c(5),{children:s,className:n}=t;let i;e[0]!==n?(i=ie("flex-none w-full mx-auto p-2 pt-0","max-w-2xl min-w-0",n),e[0]=n,e[1]=i):i=e[1];let o;return e[2]!==s||e[3]!==i?(o=r.jsx("div",{className:i,children:s}),e[2]=s,e[3]=i,e[4]=o):o=e[4],o}const yt=Object.assign(JL,{Main:XL,Messages:ZL,EmptyState:QL,Footer:eS,Input:ML,Provider:mx,ActiveTaskProvider:fx,Skeleton:GL,IceBreakers:a8,NoAiProviderEmptyState:S6,CreditsEmptyState:UL,CreditsEyebrow:WL,NoCreditsEyebrow:qL,CreditsExhaustedBanner:$2});function tS(){const t=n2(),{pendingAgentOption:e}=Ts(),s=ic();if(Ii()?.isThreadLocked)return!1;const i=e==="claude-code-desktop"&&s.claudeCode||e==="codex-desktop"&&s.codex;return t.length===0&&!i}function Hr(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}k`:String(t)}function Kc(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 sS(t){return t?t.replace(/-\d{8}(?:-[a-z0-9]+)*$/i,"").replace(/-/g," "):"—"}function nS(t){const e=F.c(4),{items:s}=t;let n;e[0]!==s?(n=s.map(iS),e[0]=s,e[1]=n):n=e[1];let i;return e[2]!==n?(i=r.jsx("div",{className:"grid grid-cols-2 gap-x-8 gap-y-6",children:n}),e[2]=n,e[3]=i):i=e[3],i}function iS(t){return r.jsxs("div",{className:"flex flex-col gap-1 min-w-0",children:[r.jsx("span",{className:"text-xs text-muted-foreground truncate",children:t.label}),r.jsx("span",{className:"text-sm text-foreground tabular-nums truncate",children:t.value})]},t.label)}function rS(t){const e=F.c(33),{userTokens:s,assistantTokens:n,otherTokens:i}=t,o=re(),a=s+n+i,l=a>0?s/a*100:0,c=a>0?n/a*100:0,d=a>0?i/a*100:0;let h;e[0]!==l?(h=l>0&&r.jsx("div",{className:"h-full bg-chart-1",style:{width:`${l}%`}}),e[0]=l,e[1]=h):h=e[1];let u;e[2]!==c?(u=c>0&&r.jsx("div",{className:"h-full bg-chart-2",style:{width:`${c}%`}}),e[2]=c,e[3]=u):u=e[3];let f;e[4]!==d?(f=d>0&&r.jsx("div",{className:"h-full bg-muted-foreground/30",style:{width:`${d}%`}}),e[4]=d,e[5]=f):f=e[5];let m;e[6]!==h||e[7]!==u||e[8]!==f?(m=r.jsxs("div",{className:"flex h-2 w-full overflow-hidden rounded-full bg-muted",children:[h,u,f]}),e[6]=h,e[7]=u,e[8]=f,e[9]=m):m=e[9];let p;e[10]===Symbol.for("react.memo_cache_sentinel")?(p=r.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-chart-1 shrink-0"}),e[10]=p):p=e[10];let g;e[11]!==o||e[12]!==l?(g=o("chat.contextPanel.userPercent",{pct:l.toFixed(1)}),e[11]=o,e[12]=l,e[13]=g):g=e[13];let x;e[14]!==g?(x=r.jsxs("div",{className:"flex items-center gap-1.5",children:[p,r.jsx("span",{className:"text-xs text-muted-foreground",children:g})]}),e[14]=g,e[15]=x):x=e[15];let v;e[16]===Symbol.for("react.memo_cache_sentinel")?(v=r.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-chart-2 shrink-0"}),e[16]=v):v=e[16];let b;e[17]!==c||e[18]!==o?(b=o("chat.contextPanel.assistantPercent",{pct:c.toFixed(1)}),e[17]=c,e[18]=o,e[19]=b):b=e[19];let y;e[20]!==b?(y=r.jsxs("div",{className:"flex items-center gap-1.5",children:[v,r.jsx("span",{className:"text-xs text-muted-foreground",children:b})]}),e[20]=b,e[21]=y):y=e[21];let _;e[22]!==d||e[23]!==i||e[24]!==o?(_=i>0&&r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-muted-foreground/30 shrink-0"}),r.jsx("span",{className:"text-xs text-muted-foreground",children:o("chat.contextPanel.otherPercent",{pct:d.toFixed(1)})})]}),e[22]=d,e[23]=i,e[24]=o,e[25]=_):_=e[25];let L;e[26]!==y||e[27]!==_||e[28]!==x?(L=r.jsxs("div",{className:"flex flex-wrap gap-x-3 gap-y-1",children:[x,y,_]}),e[26]=y,e[27]=_,e[28]=x,e[29]=L):L=e[29];let w;return e[30]!==L||e[31]!==m?(w=r.jsxs("div",{className:"flex flex-col gap-2",children:[m,L]}),e[30]=L,e[31]=m,e[32]=w):w=e[32],w}function oS(t){const e=F.c(11),{agentId:s,isError:n}=t,i=gs(s),o=i?.title??"Subtask",a=i?.icon??null;let l;e[0]!==a||e[1]!==o?(l=r.jsx(an,{icon:a,name:o,size:"xs",className:"size-6 rounded-md shrink-0"}),e[0]=a,e[1]=o,e[2]=l):l=e[2];const c=n?"text-destructive":"text-foreground";let d;e[3]!==c?(d=ie("shrink-0 font-medium",c),e[3]=c,e[4]=d):d=e[4];let h;e[5]!==o||e[6]!==d?(h=r.jsx("span",{className:d,children:o}),e[5]=o,e[6]=d,e[7]=h):h=e[7];let u;return e[8]!==l||e[9]!==h?(u=r.jsxs(r.Fragment,{children:[l,h]}),e[8]=l,e[9]=h,e[10]=u):u=e[10],u}function aS(t){const e=F.c(12),{isError:s}=t,n=re();let i;e[0]!==n?(i=n("chat.contextPanel.subtask"),e[0]=n,e[1]=i):i=e[1];const o=i;let a;e[2]!==o?(a=r.jsx(an,{icon:null,name:o,size:"xs",className:"size-6 rounded-md shrink-0"}),e[2]=o,e[3]=a):a=e[3];const l=s?"text-destructive":"text-foreground";let c;e[4]!==l?(c=ie("shrink-0 font-medium",l),e[4]=l,e[5]=c):c=e[5];let d;e[6]!==o||e[7]!==c?(d=r.jsx("span",{className:c,children:o}),e[6]=o,e[7]=c,e[8]=d):d=e[8];let h;return e[9]!==a||e[10]!==d?(h=r.jsxs(r.Fragment,{children:[a,d]}),e[9]=a,e[10]=d,e[11]=h):h=e[11],h}function lS(t){const e=F.c(18),{part:s}=t,n=s.input?.agent_id,i=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=r.jsx(aS,{isError:o}),e[0]=o,e[1]=l):l=e[1];let c;e[2]!==n||e[3]!==o?(c=r.jsx(oS,{agentId:n,isError:o}),e[2]=n,e[3]=o,e[4]=c):c=e[4];let d;e[5]!==l||e[6]!==c?(d=r.jsx(A.Suspense,{fallback:l,children:c}),e[5]=l,e[6]=c,e[7]=d):d=e[7];let h;e[8]!==s.input?(h=s.input?.prompt&&r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"text-muted-foreground/50",children:"·"}),r.jsx("span",{className:"truncate text-muted-foreground",children:s.input.prompt})]}),e[8]=s.input,e[9]=h):h=e[9];let u;e[10]!==a||e[11]!==o||e[12]!==i?(u=r.jsx("span",{className:"ml-auto shrink-0",children:i?r.jsx(et,{size:12,className:"animate-spin text-muted-foreground"}):o?r.jsx(X6,{size:12,className:"text-destructive"}):a?r.jsx(wn,{size:12,className:"text-warning"}):r.jsx(Xl,{size:12,className:"text-success"})}),e[10]=a,e[11]=o,e[12]=i,e[13]=u):u=e[13];let f;return e[14]!==d||e[15]!==h||e[16]!==u?(f=r.jsxs("div",{className:"flex items-center gap-2 text-xs min-w-0",children:[d,h,u]}),e[14]=d,e[15]=h,e[16]=u,e[17]=f):f=e[17],f}function cS(t){const e=F.c(78),{onClose:s,back:n,className:i}=t,o=re(),[a,l]=A.useState(null),{messages:c}=Js(),{activeTask:d}=Zt(),{selectedModel:h,selectedVirtualMcp:u}=Ts();let f,m,p,g,x,v,b,y;if(e[0]!==d||e[1]!==n||e[2]!==i||e[3]!==c||e[4]!==s||e[5]!==a?.id||e[6]!==h||e[7]!==u?.title||e[8]!==o){y=Symbol.for("react.early_return_sentinel");e:{const w=mm(c),j=[...c].reverse().find(_S),S=j?.metadata?.usage,C=j?.metadata?.modelLimits?.contextWindow??h?.limits?.contextWindow??null,N=S?.contextTokens??0,V=C&&C>0?(N/C*100).toFixed(1):null,E=c;let T;e[17]!==E?(T=E.filter(bS).reduce(vS,0),e[17]=E,e[18]=T):T=e[18];const k=T,R=c;let P;e[19]!==R?(P=R.filter(xS).reduce(gS,0),e[19]=R,e[20]=P):P=e[20];const D=P,I=Math.max(0,w.totalTokens-k-D),M=c[0],O=c.at(-1),$=M?.metadata?.created_at??d?.created_at,B=O?.metadata?.created_at??d?.updated_at,z=c.filter(pS),K=c.flatMap(fS),G=h?.modelId?sS(h.modelId):"—",Y=u?.title??"Super Agent",U=[{label:o("chat.contextPanel.sessionLabel"),value:d?.title??o("chat.contextPanel.newChat")},{label:o("chat.contextPanel.messagesLabel"),value:z.length},{label:o("chat.contextPanel.agentLabel"),value:Y},{label:o("chat.contextPanel.modelLabel"),value:G},{label:o("chat.contextPanel.contextLimitLabel"),value:C?Hr(C):"—"},{label:o("chat.contextPanel.sessionTokensLabel"),value:w.totalTokens>0?Hr(w.totalTokens):"0"},{label:o("chat.contextPanel.usageLabel"),value:V!==null?`${V}%`:"—"},{label:o("chat.contextPanel.inputTokensLabel"),value:w.inputTokens>0?Hr(w.inputTokens):"0"},{label:o("chat.contextPanel.outputTokensLabel"),value:w.outputTokens>0?Hr(w.outputTokens):"0"},{label:o("chat.contextPanel.reasoningTokensLabel"),value:w.reasoningTokens>0?Hr(w.reasoningTokens):"0"},{label:o("chat.contextPanel.costLabel"),value:w.cost>0?`$${w.cost<.001?w.cost.toFixed(6):w.cost.toFixed(4)}`:"$0.00"},{label:o("chat.contextPanel.sessionCreatedLabel"),value:Kc($)},{label:o("chat.contextPanel.lastActivityLabel"),value:Kc(B)}];if(!d&&z.length===0){let J;e[21]!==i?(J=ie("flex flex-col h-full w-full border-l border-border bg-background",i),e[21]=i,e[22]=J):J=e[22];let te;e[23]!==o?(te=o("chat.contextPanel.title"),e[23]=o,e[24]=te):te=e[24];let se;e[25]!==te?(se=r.jsx("span",{className:"text-sm font-medium text-foreground",children:te}),e[25]=te,e[26]=se):se=e[26];let ne;e[27]!==n?(ne=n?r.jsx(zu,{size:14,className:"text-muted-foreground"}):r.jsx(Pn,{size:14,className:"text-muted-foreground"}),e[27]=n,e[28]=ne):ne=e[28];let de;e[29]!==s||e[30]!==ne?(de=r.jsx("button",{type:"button",onClick:s,className:"flex size-6 items-center justify-center rounded hover:bg-accent transition-colors",children:ne}),e[29]=s,e[30]=ne,e[31]=de):de=e[31];let xe;e[32]!==se||e[33]!==de?(xe=r.jsxs("div",{className:"h-11 px-4 flex items-center justify-between shrink-0 border-b border-border/50",children:[se,de]}),e[32]=se,e[33]=de,e[34]=xe):xe=e[34];let ue;e[35]!==o?(ue=o("chat.contextPanel.emptyState"),e[35]=o,e[36]=ue):ue=e[36];let ce;e[37]!==ue?(ce=r.jsx("div",{className:"flex-1 flex items-center justify-center px-4 text-center",children:r.jsx("p",{className:"text-xs text-muted-foreground",children:ue})}),e[37]=ue,e[38]=ce):ce=e[38];let oe;e[39]!==J||e[40]!==xe||e[41]!==ce?(oe=r.jsxs("div",{className:J,children:[xe,ce]}),e[39]=J,e[40]=xe,e[41]=ce,e[42]=oe):oe=e[42],y=oe;break e}e[43]!==i?(v=ie("flex flex-col h-full w-full border-l border-border bg-background overflow-y-auto",i),e[43]=i,e[44]=v):v=e[44];let W;e[45]!==o?(W=o("chat.contextPanel.title"),e[45]=o,e[46]=W):W=e[46];let H;e[47]!==W?(H=r.jsx("span",{className:"text-sm font-medium text-foreground",children:W}),e[47]=W,e[48]=H):H=e[48];let X;e[49]!==n?(X=n?r.jsx(zu,{size:14}):r.jsx(Pn,{size:14}),e[49]=n,e[50]=X):X=e[50];let q;e[51]!==s||e[52]!==X?(q=r.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:X}),e[51]=s,e[52]=X,e[53]=q):q=e[53],e[54]!==H||e[55]!==q?(b=r.jsxs("div",{className:"flex h-11 shrink-0 items-center justify-between border-b border-border/50 px-4",children:[H,q]}),e[54]=H,e[55]=q,e[56]=b):b=e[56],f="flex flex-col gap-8 p-6",m=K.length>0&&r.jsxs("div",{className:"flex flex-col gap-3",children:[r.jsx("span",{className:"text-xs text-muted-foreground",children:o("chat.contextPanel.subtasksSection")}),r.jsx("div",{className:"flex flex-col gap-1",children:K.map(hS)})]}),p=r.jsx(nS,{items:U});let Z;e[57]!==o?(Z=o("chat.contextPanel.contextBreakdownSection"),e[57]=o,e[58]=Z):Z=e[58];let Q;e[59]!==Z?(Q=r.jsx("span",{className:"text-xs text-muted-foreground",children:Z}),e[59]=Z,e[60]=Q):Q=e[60];let ee;e[61]!==D||e[62]!==I||e[63]!==k?(ee=r.jsx(rS,{userTokens:k,assistantTokens:D,otherTokens:I}),e[61]=D,e[62]=I,e[63]=k,e[64]=ee):ee=e[64],e[65]!==Q||e[66]!==ee?(g=r.jsxs("div",{className:"flex flex-col gap-3",children:[Q,ee]}),e[65]=Q,e[66]=ee,e[67]=g):g=e[67],x=z.length>0&&r.jsxs("div",{className:"flex flex-col gap-3",children:[r.jsx("span",{className:"text-xs text-muted-foreground",children:o("chat.contextPanel.rawMessagesSection")}),r.jsx("div",{className:"flex flex-col gap-1",children:z.map(J=>{const te=J.metadata?.created_at,se=a?.id===J.id;return r.jsxs("div",{className:"rounded-md border border-border/50 overflow-hidden",children:[r.jsxs("button",{type:"button",onClick:()=>l(se?null:J),className:"flex items-center justify-between gap-2 px-3 py-2 text-xs hover:bg-accent/50 w-full text-left cursor-pointer",children:[r.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[r.jsx("span",{className:ie("shrink-0 font-medium",J.role==="user"?"text-chart-1":"text-chart-2"),children:J.role}),r.jsx("span",{className:"text-muted-foreground",children:"•"}),r.jsx("span",{className:"truncate text-muted-foreground font-mono",children:J.id})]}),te&&r.jsx("span",{className:"shrink-0 text-muted-foreground tabular-nums",children:Kc(te)})]}),se&&r.jsxs(r.Fragment,{children:[J.role==="assistant"&&(()=>{const ne=J.metadata?._request;if(!ne)return null;const de=ne.systemSections??[],xe=Math.max(1,...de.map(uS)),ue=de.reduce(dS,0);return r.jsxs("div",{className:"border-t border-border/50 px-3 py-2.5 text-xs space-y-2.5",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"font-medium text-foreground",children:o("chat.contextPanel.requestLabel")}),r.jsxs("span",{className:"text-muted-foreground tabular-nums",children:[ne.activeTools??0," / ",ne.tools??0," ",o("chat.contextPanel.toolsActive")]})]}),de.length>0&&r.jsxs("div",{className:"space-y-1.5",children:[r.jsxs("div",{className:"text-muted-foreground",children:[o("chat.contextPanel.systemPromptLabel")," ",r.jsxs("span",{className:"tabular-nums",children:["~",Math.round(ue/4).toLocaleString()," ",o("chat.contextPanel.tokAbbrev")]})]}),de.map((ce,oe)=>{const fe=ce.preview.match(/^<([a-z-]+)/i)?.[1]??`section ${oe}`,pe=ce.chars/xe*100,we=Math.round(ce.chars/4);return r.jsxs("div",{className:"space-y-0.5",children:[r.jsxs("div",{className:"flex items-center justify-between gap-2",children:[r.jsx("span",{className:"font-mono text-foreground truncate",children:fe}),r.jsxs("span",{className:"text-muted-foreground tabular-nums shrink-0",children:["~",we.toLocaleString()," ",o("chat.contextPanel.tokAbbrev")]})]}),r.jsx("div",{className:"h-1 w-full rounded-full bg-muted overflow-hidden",children:r.jsx("div",{className:"h-full rounded-full bg-chart-3",style:{width:`${pe}%`}})})]},oe)})]})]})})(),r.jsx("pre",{className:"text-xs font-mono bg-muted px-3 py-2 overflow-auto whitespace-pre-wrap break-all border-t border-border/50 max-h-64",children:JSON.stringify(J,null,2)})]})]},J.id)})})]})}e[0]=d,e[1]=n,e[2]=i,e[3]=c,e[4]=s,e[5]=a?.id,e[6]=h,e[7]=u?.title,e[8]=o,e[9]=f,e[10]=m,e[11]=p,e[12]=g,e[13]=x,e[14]=v,e[15]=b,e[16]=y}else f=e[9],m=e[10],p=e[11],g=e[12],x=e[13],v=e[14],b=e[15],y=e[16];if(y!==Symbol.for("react.early_return_sentinel"))return y;let _;e[68]!==f||e[69]!==m||e[70]!==p||e[71]!==g||e[72]!==x?(_=r.jsxs("div",{className:f,children:[m,p,g,x]}),e[68]=f,e[69]=m,e[70]=p,e[71]=g,e[72]=x,e[73]=_):_=e[73];let L;return e[74]!==v||e[75]!==b||e[76]!==_?(L=r.jsxs("div",{className:v,children:[b,_]}),e[74]=v,e[75]=b,e[76]=_,e[77]=L):L=e[77],L}function dS(t,e){return t+e.chars}function uS(t){return t.chars}function hS(t,e){return r.jsx(lS,{part:t},e)}function fS(t){return(t.parts??[]).filter(mS)}function mS(t){return t.type==="tool-subtask"}function pS(t){return t.role!=="system"}function gS(t,e){const s=e.metadata?.usage;return t+(s?.outputTokens??0)}function xS(t){return t.role==="assistant"}function vS(t,e){const s=e.metadata?.usage;return t+(s?.inputTokens??0)}function bS(t){return t.role==="user"}function _S(t){return t.role==="assistant"&&t.metadata?.usage}function yS(t){const e=F.c(27),{onOpenContextPanel:s}=t,{org:n}=Oe(),{selectedVirtualMcp:i}=Ts(),{currentBranch:o}=Zt();let a;e[0]!==n.id?(a=Yo(n.id),e[0]=n.id,e[1]=a):a=e[1];const c=i??a,d=gs(c.id),h=d??c,u=h.title??"Super Agent",f=h.icon??null,m=h.description??null;let p;e[2]!==f||e[3]!==u?(p=r.jsx(Xn,{icon:f,name:u,size:"lg"}),e[2]=f,e[3]=u,e[4]=p):p=e[4];let g;e[5]!==u?(g=r.jsx("h2",{className:"text-2xl font-semibold tracking-tight text-foreground",children:u}),e[5]=u,e[6]=g):g=e[6];let x;e[7]!==m?(x=m?r.jsx("p",{className:"text-sm text-muted-foreground max-w-md text-balance",children:m}):null,e[7]=m,e[8]=x):x=e[8];let v;e[9]!==g||e[10]!==x?(v=r.jsxs("div",{className:"space-y-1.5",children:[g,x]}),e[9]=g,e[10]=x,e[11]=v):v=e[11];let b;e[12]!==p||e[13]!==v?(b=r.jsxs("div",{className:"flex-1 min-h-0 flex flex-col items-center justify-center gap-4 px-6 text-center overflow-hidden",children:[p,v]}),e[12]=p,e[13]=v,e[14]=b):b=e[14];let y;e[15]===Symbol.for("react.memo_cache_sentinel")?(y=r.jsx(yt.IceBreakers,{className:"pb-3"}),e[15]=y):y=e[15];let _;e[16]!==o||e[17]!==d?(_=r.jsx("div",{"data-chat-above-row":"true",className:"@container/chat-bottom pb-1 flex justify-start gap-1",children:r.jsx(np,{virtualMcp:d,currentBranch:o,showRuntimeLabel:!0})}),e[16]=o,e[17]=d,e[18]=_):_=e[18];let L;e[19]!==s?(L=r.jsx(yt.Input,{onOpenContextPanel:s}),e[19]=s,e[20]=L):L=e[20];let w;e[21]!==_||e[22]!==L?(w=r.jsxs(yt.Footer,{children:[y,_,L]}),e[21]=_,e[22]=L,e[23]=w):w=e[23];let j;return e[24]!==w||e[25]!==b?(j=r.jsxs(r.Fragment,{children:[b,w]}),e[24]=w,e[25]=b,e[26]=j):j=e[26],j}function wh(t){const e=F.c(17),{outputs:s,collapsed:n,onToggle:i,variant:o}=t,a=o==="card"?"rounded-xl border border-border bg-muted/95 shadow-sm backdrop-blur-sm":"border-b border-border bg-background";let l;e[0]!==a?(l=ie(a),e[0]=a,e[1]=l):l=e[1];let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=r.jsx("span",{className:"text-sm font-medium text-foreground",children:"Files in this task"}),e[2]=c):c=e[2];const d=n&&"-rotate-90";let h;e[3]!==d?(h=ie("size-4 text-muted-foreground transition-transform",d),e[3]=d,e[4]=h):h=e[4];let u;e[5]!==h?(u=r.jsx(ss,{className:h}),e[5]=h,e[6]=u):u=e[6];let f;e[7]!==i||e[8]!==u?(f=r.jsxs("button",{type:"button",onClick:i,className:"flex w-full items-center justify-between px-3 py-2.5 text-left",children:[c,u]}),e[7]=i,e[8]=u,e[9]=f):f=e[9];let m;e[10]!==n||e[11]!==s?(m=!n&&r.jsx("div",{className:"flex max-h-72 flex-col gap-1.5 overflow-y-auto px-2 pb-2",children:s.map(LS)}),e[10]=n,e[11]=s,e[12]=m):m=e[12];let p;return e[13]!==l||e[14]!==f||e[15]!==m?(p=r.jsxs("div",{className:l,children:[f,m]}),e[13]=l,e[14]=f,e[15]=m,e[16]=p):p=e[16],p}function LS(t){return r.jsx(Nx,{file:t},t.key)}function SS(){const t=F.c(13),e=Ii()?.taskId??null,s=Vx();let n;t[0]!==s?(n={enabled:s},t[0]=s,t[1]=n):n=t[1];const{data:i}=pm(e,n),[o,a]=A.useState(!1),[l,c]=A.useState(!0);if(!e||!i||i.length===0)return null;let d;t[2]===Symbol.for("react.memo_cache_sentinel")?(d=()=>a(jS),t[2]=d):d=t[2];let h;t[3]!==o||t[4]!==i?(h=r.jsx("div",{className:"absolute top-2 right-2 z-10 hidden w-72 @[1280px]:block",children:r.jsx(wh,{variant:"card",outputs:i,collapsed:o,onToggle:d})}),t[3]=o,t[4]=i,t[5]=h):h=t[5];let u;t[6]===Symbol.for("react.memo_cache_sentinel")?(u=()=>c(wS),t[6]=u):u=t[6];let f;t[7]!==l||t[8]!==i?(f=r.jsx("div",{className:"shrink-0 @[1280px]:hidden",children:r.jsx(wh,{variant:"bar",outputs:i,collapsed:l,onToggle:u})}),t[7]=l,t[8]=i,t[9]=f):f=t[9];let m;return t[10]!==h||t[11]!==f?(m=r.jsxs(r.Fragment,{children:[h,f]}),t[10]=h,t[11]=f,t[12]=m):m=t[12],m}function wS(t){return!t}function jS(t){return!t}function CS(){const t=F.c(27),{org:e}=Oe(),{isChatEmpty:s}=Js(),{openTab:n}=Qo(),[i,o]=A.useState("chat"),a=i9();if(tS()){let _;return t[0]!==n?(_=r.jsx(yt,{className:"animate-in fade-in-0 duration-200",children:r.jsx(yt.Main,{className:"flex flex-col items-center",children:r.jsx(yt.EmptyState,{children:r.jsx(yt.NoAiProviderEmptyState,{onLocalRuntimePicked:()=>n("overview")})})})}),t[0]=n,t[1]=_):_=t[1],_}let c;t[2]!==a.hasDecoKey||t[3]!==a.hasOnlyDecoProvider||t[4]!==a.isLoading||t[5]!==a.isZeroBalance||t[6]!==s||t[7]!==e?(c=a.hasDecoKey&&a.isZeroBalance&&a.hasOnlyDecoProvider&&!a.isLoading&&s&&!KL(e.id),t[2]=a.hasDecoKey,t[3]=a.hasOnlyDecoProvider,t[4]=a.isLoading,t[5]=a.isZeroBalance,t[6]=s,t[7]=e,t[8]=c):c=t[8];const d=c;let h;t[9]!==d?(h=d&&r.jsx(yt.CreditsEmptyState,{}),t[9]=d,t[10]=h):h=t[10];const u=i!=="chat"?"opacity-0 pointer-events-none":"opacity-100";let f;t[11]!==u?(f=ie("absolute inset-0 flex flex-col transition-opacity duration-100 ease-out",u),t[11]=u,t[12]=f):f=t[12];let m;t[13]!==s?(m=s?r.jsx(yS,{onOpenContextPanel:()=>o("context")}):r.jsxs(r.Fragment,{children:[r.jsxs(yt.Main,{className:"relative flex flex-col overflow-hidden @container",children:[r.jsx(SS,{}),r.jsx("div",{className:"min-h-0 flex-1",children:r.jsx(yt.Messages,{})})]}),r.jsx(yt.Footer,{children:r.jsx(yt.Input,{onOpenContextPanel:()=>o("context")})})]}),t[13]=s,t[14]=m):m=t[14];let p;t[15]!==f||t[16]!==m?(p=r.jsx("div",{className:f,children:m}),t[15]=f,t[16]=m,t[17]=p):p=t[17];const g=i==="context"?"opacity-100":"opacity-0 pointer-events-none";let x;t[18]!==g?(x=ie("absolute inset-0 flex flex-col transition-opacity duration-100 ease-out",g),t[18]=g,t[19]=x):x=t[19];let v;t[20]===Symbol.for("react.memo_cache_sentinel")?(v=r.jsx(cS,{back:!0,onClose:()=>o("chat")}),t[20]=v):v=t[20];let b;t[21]!==x?(b=r.jsx("div",{className:x,children:v}),t[21]=x,t[22]=b):b=t[22];let y;return t[23]!==h||t[24]!==p||t[25]!==b?(y=r.jsxs(yt,{className:"relative overflow-hidden animate-in fade-in-0 duration-200",children:[h,p,b]}),t[23]=h,t[24]=p,t[25]=b,t[26]=y):y=t[26],y}function Lp(){const t=F.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx(yt.Skeleton,{}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(ys,{fallback:e,children:r.jsx(A.Suspense,{fallback:r.jsx(yt.Skeleton,{}),children:r.jsx(CS,{})})}),t[1]=s):s=t[1],s}function jh(t,e){return+(e.sidePanel!==null)+Number(e.mainOpen)<=1?!1:t==="side"?e.sidePanel!==null:e.mainOpen}function kS(t){return t.sidePanel!==null||t.mainOpen?t:{...t,sidePanel:"chat"}}function VS(t){const e=t.mainParamValue===0?"0":t.mainParamValue,s=t.entityMetadata?.defaultMainView??null,n=s==null||s.type==="chat",i=t.mainParamPresent?e!=="0":!n,o=n||t.entityMetadata?.chatDefaultOpen?"chat":null,a=t.sidePanelParamPresent?t.sidePanelParamValue===0?null:t.sidePanelParamValue??null:o;return kS({sidePanel:a,mainOpen:i})}function Uc(t,e){switch(t.type){case"toggleSidePanel":return e.sidePanel===t.sidePanel?jh("side",e)?{sidepanel:0}:null:{sidepanel:t.sidePanel};case"toggleMain":return e.mainOpen?jh("main",e)?{main:0}:null:{main:t.openMainValue};case"openSidePanel":return e.sidePanel===t.sidePanel?null:{sidepanel:t.sidePanel}}}function NS(t){return t.sidePanel!==null&&t.mainOpen?{side:33,main:67}:t.sidePanel!==null?{side:100,main:0}:t.mainOpen?{side:0,main:100}:{side:0,main:0}}function TS(t,e){return t==="main"?{sidepanel:0,main:e}:{sidepanel:t,main:0}}function AS(t,e){const s=St(),n=wr({strict:!1}),i=Kl({strict:!1}),{create:o}=Hl(),{locator:a}=Oe(),{virtualMcpId:l,orgSlug:c,isAgentRoute:d}=e,h=n.main===0?"0":n.main,{sidePanel:u,mainOpen:f}=VS({entityMetadata:t,mainParamPresent:n.main!==void 0,mainParamValue:h,sidePanelParamPresent:n.sidepanel!==void 0,sidePanelParamValue:n.sidepanel}),m={sidePanel:u,mainOpen:f},p=A.useRef(crypto.randomUUID()),g=i.taskId??p.current,x="/$org/$taskId",v=V=>({org:c,taskId:V}),b=d?{virtualmcpid:l}:{},y=(V,E)=>{s({to:x,params:v(g),search:T=>({...T,...V}),replace:E?.replace??!1})};return{taskId:g,sidePanel:u,mainOpen:f,mainParam:h,setTaskId:(V,E)=>{s({to:x,params:v(V),search:T=>{const k={};return E?k.virtualmcpid=E:d&&(k.virtualmcpid=l),k}})},toggleMain:()=>{const V=Uc({type:"toggleMain",openMainValue:rl(t)},m);V&&y(V,{replace:!0})},toggleSidePanel:V=>{const E=Uc({type:"toggleSidePanel",sidePanel:V},m);E&&y(E,{replace:!0})},setMobileSurface:V=>{const E=h&&h!=="0"?h:rl(t);y(TS(V,E),{replace:!0})},openSidePanel:V=>{const E=Uc({type:"openSidePanel",sidePanel:V},m);E&&y(E,{replace:!0})},createNewTask:async()=>{const V=crypto.randomUUID(),E=cv(c,a,g);try{await o({id:V,virtual_mcp_id:l,...E?{branch:E}:{}})}catch{}s({to:x,params:v(V),search:T=>({...b,sidepanel:"chat"})})},openTab:V=>{y({main:V==="0"?0:V},{replace:!0})}}}function Ch(t,e){const s=typeof t=="number"?t:Number(t);return!Number.isFinite(s)||s<=0||s>=100?e:s}function ES(t,e){const s=F.c(8);let n;s[0]!==e?(n=c=>Ch(c,e),s[0]=e,s[1]=n):n=s[1];const[i,o]=X5(t,n);let a;s[2]!==e||s[3]!==i?(a=Ch(i,e),s[2]=e,s[3]=i,s[4]=a):a=s[4];let l;return s[5]!==o||s[6]!==a?(l=[a,o],s[5]=o,s[6]=a,s[7]=l):l=s[7],l}const PS=33;function RS(){const t=F.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=Q5.sidePanelWidth(),t[0]=e):e=t[0],ES(e,PS)}function Pr(t,e){const s=(t??"").trim().replace(/^[/\\]+|[/\\]+$/g,"");return s?`${s}/${e}`:e}function Sp(t){try{const{hostname:e}=new URL(t);return e==="localhost"||e.endsWith(".localhost")||e==="127.0.0.1"||e==="::1"}catch{return!1}}function DS(){if(typeof document>"u")return null;const t=Array.from(document.querySelectorAll("iframe"));for(const e of t){const s=e.getAttribute("src");if(s&&Sp(s))return s}return null}function IS(t){const e=t.previewUrl??t.getFallbackPreviewUrl?.()??DS();if(e&&Sp(e))return new URL("/.decofile",e).toString();const s=new URLSearchParams({path:"/.decofile"});return`/api/${t.orgSlug}/sandbox/${encodeURIComponent(t.virtualMcpId)}/${encodeURIComponent(t.branch)}/preview-fetch?${s.toString()}`}async function wp(t,e){const s=`/api/${t.orgSlug}/sandbox/${encodeURIComponent(t.virtualMcpId)}/${encodeURIComponent(t.branch)}/read`,n=await fetch(s,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({path:e,full:!0})});if(n.status===400)return null;if(!n.ok){const o=new Error(`Failed to read ${e}: ${n.status}`);throw o.status=n.status,o}const i=await n.json();if(typeof i.content!="string")return null;try{return JSON.parse(T6(i.content))}catch{return null}}function rc(t,e){const s=F.c(10),n=t?`${t.orgSlug}/${t.virtualMcpId}/${t.branch}`:"",i=e?.fetchEnabled??!0,o=gs(t?.virtualMcpId)?.metadata?.runtime?.path??null;let a;s[0]!==n?(a=at.decofile(n),s[0]=n,s[1]=a):a=s[1];let l;s[2]!==i||s[3]!==o||s[4]!==t?(l=async()=>{const h=()=>wp(t,Pr(o,".deco/blocks.gen.json"));if(i){const m=await fetch(IS(t),{cache:"no-store"}).catch(BS);if(m?.ok)return await m.json();const p=await h();if(p)return p;const g=new Error(`Failed to fetch decofile: ${m?.status??"network error"}`);throw g.status=m?.status??502,g}const u=await h();if(u)return u;const f=new Error("decofile unavailable (preview down, no committed snapshot)");throw f.status=502,f},s[2]=i,s[3]=o,s[4]=t,s[5]=l):l=s[5];const c=!!t;let d;return s[6]!==a||s[7]!==l||s[8]!==c?(d={queryKey:a,queryFn:l,enabled:c,staleTime:3e4,retry:OS,retryDelay:MS},s[6]=a,s[7]=l,s[8]=c,s[9]=d):d=s[9],Mt(d)}function MS(t){return h2(5e3,1e3,t,2,0)}function OS(t,e){return e.status!==502&&t<2}function BS(){return null}function oc(t,e){const s=F.c(13),n=e?.fetchEnabled??!0,i=t?.previewUrl,o=gs(t?.virtualMcpId)?.metadata?.runtime?.path??null;let a;s[0]!==t||s[1]!==i?(a=t?at.liveMeta(t.orgSlug,t.virtualMcpId,t.branch,i??""):at.liveMeta(""),s[0]=t,s[1]=i,s[2]=a):a=s[2];let l;s[3]!==n||s[4]!==o||s[5]!==t||s[6]!==i?(l=async()=>{const u=()=>wp(t,Pr(o,".deco/meta.gen.json"));if(n&&i){const p=new URL("/live/_meta",i).href,g=await fetch(p,{cache:"no-store"}).catch(zS);if(g?.ok)return await g.json();const x=await u();if(x)return x;const v=new Error(`Failed to fetch live meta: ${g?.status??"network error"}`);throw v.status=g?.status??502,v}const f=await u();if(f)return f;const m=new Error("live meta unavailable (preview down, no committed snapshot)");throw m.status=502,m},s[3]=n,s[4]=o,s[5]=t,s[6]=i,s[7]=l):l=s[7];const c=!!t,d=e?.refetchInterval;let h;return s[8]!==a||s[9]!==l||s[10]!==c||s[11]!==d?(h={queryKey:a,queryFn:l,enabled:c,refetchInterval:d,refetchIntervalInBackground:!1,staleTime:3e5,retry:FS,retryDelay:$S},s[8]=a,s[9]=l,s[10]=c,s[11]=d,s[12]=h):h=s[12],Mt(h)}function $S(t){return h2(5e3,1e3,t,2,0)}function FS(t,e){return e.status!==502&&t<3}function zS(){return null}function kh(t){if(!t.startsWith("#")||!t.includes("@"))return null;const e=t.indexOf("@");return{moduleResolveType:t.slice(1,e),blockId:t.slice(e+1)}}function vo(t){return t.includes("@")}function Id(t){const e=t.lastIndexOf("@");return e<0||e===t.length-1?null:t.slice(e+1)}function Vh(t,e){if(t===e)return!0;const s=Id(t);return s?e===s||Id(e)===s:!1}function V9(t,e){const s=t.manifest?.blocks??{};for(const[n,i]of Object.entries(s))if(e in i)return n;return null}function jp(t,e){const s=V9(t,e);return s!==null&&s.includes("sections")}function KS(t,e){const s=V9(t,e);return s!==null&&s.includes("apps")}function US(t,e){const s=V9(t,e);return s!==null&&s.includes("matchers")}function _n(t){return!(/\.\w+$/.test(t)||t==="__proto__"||t==="constructor")}function ac(t){try{return decodeURIComponent(t).startsWith("Preview ")}catch{return t.startsWith("Preview ")}}const N9="oklch(0.7278 0.151 289)",Cp="website/matchers/always.ts",Rr="website/matchers/never.ts",Ki="website/flags/multivariate.ts",Dr="website/flags/multivariate/section.ts";function br(){return{__resolveType:Cp}}function Tt(t){const e=t.split("/");return(e[e.length-1]??t).replace(/\.(tsx?|jsx?)$/,"").replace(/[-_]/g," ").replace(/\b\w/g,n=>n.toUpperCase())||t}const HS=12,ba=8,WS=40;function qS(t){const e=t.type;return e==="array"||Array.isArray(e)&&e.includes("array")}function GS(t,e){let s=t.items;if(!s)return!1;if(typeof s.$ref=="string"&&(s=e(s.$ref)),Array.isArray(s.anyOf)||Array.isArray(s.oneOf))return!0;const i=s.properties?.__resolveType?.enum;return Array.isArray(i)&&typeof i[0]=="string"}const YS="VideoWidget";function kp(t){return typeof btoa=="function"?btoa(t):Buffer.from(t).toString("base64")}function T9(t){const e=t.match(/^site\/apps\/([^/]+)\/([^/.]+)\.tsx?$/);return e?{vendor:e[1],app:e[2]}:null}function A9(t){const e=t.match(/^([^/]+)\/apps\/([^/.]+)\.tsx?$/);return e?{vendor:e[1],app:e[2]}:null}function Vp(t,e){return[`site/apps/${t}/${e}.ts`,`site/apps/${t}/${e}.tsx`,`${t}/apps/${e}.ts`,`${t}/apps/${e}.tsx`]}function E9(t,e){const s=e.manifest?.blocks??{};for(const l of Object.values(s))if(l[t])return l[t];const n=T9(t)??A9(t);if(n){for(const l of Vp(n.vendor,n.app))for(const c of Object.values(s))if(c[l])return c[l]}const i=kp(t);for(const l of Object.values(s))if(l[i])return l[i];const o=e.schema??{};return(o.$defs??o.definitions??{})[i]?{$ref:`#/definitions/${i}`}:{}}function Np(t,e){if(KS(t,e))return!0;const s=T9(e)??A9(e);if(!s)return!1;const n=t.manifest?.blocks?.apps??{};if(Vp(s.vendor,s.app).some(a=>a in n))return!0;const i=kp(e),o=t.schema?.$defs??t.schema?.definitions??{};return i in o}function Tp(t){return t==="site/apps/site.ts"?!1:T9(t)!==null||A9(t)!==null}function yn(t,e){const s=e.schema??{},n=E9(t,e),i=s.$defs??s.definitions??{},o=s.root??{},a=v=>{if(v.startsWith("#/root/")){const y=v.slice(7);return o[y]??{}}const b=v.split("/").pop()??"";return i[b]??{}};let l;typeof n.$ref=="string"?l=a(n.$ref):Object.keys(n).length>0?l=n:l=s;const c=v=>typeof v.$ref=="string"?a(v.$ref):v,d=v=>{const y=c(v).properties?.type;if(y){if(typeof y.const=="string")return y.const;if(typeof y.default=="string")return y.default;if(Array.isArray(y.enum)&&typeof y.enum[0]=="string")return y.enum[0]}},h=(v,b)=>{const y=c(v);return typeof y.title=="string"&&!y.title.startsWith("#")?y.title:b},u=(v,b=new Set)=>{if(typeof v.$ref!="string"||v.properties||v.anyOf||v.allOf||v.oneOf||v.type)return v;const y=v.$ref.split("/").pop()??"";return!y||b.has(y)?v:u(a(v.$ref),new Set([...b,y]))},f=v=>{const b=v.hide;return b===!0||b==="true"},m=(v,b=new Set,y=0)=>{if(y>HS)return{};if(typeof v.$ref=="string"){const L=v.$ref.split("/").pop()??"";return b.has(L)?{}:m(a(v.$ref),new Set([...b,L]),y+1)}let _={};if(v.properties&&typeof v.properties=="object"&&(_={..._,...v.properties}),Array.isArray(v.required)){const L=Array.isArray(_.__required)?_.__required:[];_.__required=[...L,...v.required]}for(const L of["allOf","anyOf","oneOf"]){const w=v[L];if(Array.isArray(w))for(const j of w)_={..._,...m(j,b,y+1)}}return _},p=(v,b=0,y=new Set)=>{let _=v,L;if(typeof v.$ref=="string"){_=a(v.$ref);const P=v.$ref.split("/").pop()??"";L=P,P===YS&&!_.format&&(_={..._,format:"video-uri"})}_=u(_);const w=L!==void 0&&y.has(L),j=L!==void 0?new Set([...y,L]):y,S=(P,D,I,M=!0)=>!w&&(!M||I<=WS)&&D<ba?p(P,D,j):void 0;let C;{const P=_.anyOf??_.oneOf;if(Array.isArray(P)){const D=P.filter(M=>!(M.type==="null"||M.type===null)),I=M=>{if(typeof M.const=="string"||typeof M.const=="number")return M.const;if(Array.isArray(M.enum)&&M.enum.length===1&&(typeof M.enum[0]=="string"||typeof M.enum[0]=="number"))return M.enum[0]};D.length>0&&D.every(M=>I(M)!==void 0)&&(C=D.map(M=>I(M)))}}let N,V;if(_.type)N=Array.isArray(_.type)?String(_.type.find(P=>P!=="null")??_.type[0]):String(_.type);else if(_.anyOf||_.allOf||_.oneOf){const D=(_.anyOf??_.allOf??_.oneOf).filter(I=>!(I.type==="null"||I.type===null));if(D.length===0)N="null";else if(D.length===1){const I=D[0];V=I,N=I.type?Array.isArray(I.type)?String(I.type[0]):String(I.type):typeof I.$ref=="string"?"object":"string"}else{if(C){const W=H=>typeof v[H]=="string"?v[H]:typeof _[H]=="string"?_[H]:void 0;return{type:"string",title:typeof _.title=="string"?_.title:void 0,description:typeof _.description=="string"?_.description:void 0,enum:C,format:W("format"),options:W("options")}}const I=D.filter(W=>{const H=W.properties?.__resolveType?.enum;return Array.isArray(H)&&typeof H[0]=="string"}),M=D.find(qS),O=I.some(W=>{const H=W.properties?.__resolveType?.enum;return Array.isArray(H)&&H[0]===Ki});if(M){if(!GS(M,a)&&D.length>1){const H=p(M,b+1,j);return{...H,type:"array",title:typeof _.title=="string"?_.title:H.title,description:typeof _.description=="string"?_.description:H.description}}if(O){const H=p(M,b+1,j);return{...H,type:"array",title:typeof _.title=="string"?_.title:H.title,description:typeof _.description=="string"?_.description:H.description}}}if(I.length>0){const W=I.map(ee=>{const te=ee.properties?.__resolveType?.enum??[],se=String(te[0]);return{resolveType:se,title:typeof ee.title=="string"?ee.title:Tt(se),description:typeof ee.description=="string"?ee.description:void 0,schema:S(ee,b+1,D.length)}}),H=[];for(const ee of D){if(I.includes(ee)||typeof ee.$ref!="string")continue;const J=a(ee.$ref);let te;const se=J.properties?.__resolveType;if(Array.isArray(se?.enum)&&typeof se.enum[0]=="string"&&(te=se.enum[0]),!te&&Array.isArray(J.allOf))for(const ne of J.allOf){const de=ne.properties?.__resolveType?.enum;if(Array.isArray(de)&&typeof de[0]=="string"){te=de[0];break}}te&&H.push({resolveType:te,title:typeof J.title=="string"&&!J.title.startsWith("#")?J.title:Tt(te),description:typeof J.description=="string"?J.description:void 0,schema:S(J,b+1,D.length)})}const X=new Set(W.map(ee=>ee.resolveType)),q=[...W,...H.filter(ee=>!X.has(ee.resolveType))],Z=D.filter(ee=>!I.includes(ee)),Q=Z.length===1?S(Z[0],b+1,D.length):void 0;return{type:"block-ref",title:typeof _.title=="string"?_.title:void 0,description:typeof _.description=="string"?_.description:void 0,anyOfRefs:q,plainSchema:Q,hidden:f(_)||f(v)?!0:void 0}}const $=D.map(W=>d(W));if(D.length>1&&$.every(W=>typeof W=="string")){const W=D.map((H,X)=>{const q=c(H),Z=$[X];return{resolveType:Z,title:h(H,Z),description:typeof q.description=="string"?q.description:void 0,discriminatorValue:Z,schema:S(q,b+1,D.length,!1)}});return{type:"block-ref",title:typeof v.title=="string"?v.title:typeof _.title=="string"?_.title:void 0,description:typeof v.description=="string"?v.description:typeof _.description=="string"?_.description:void 0,discriminatorKey:"type",anyOfRefs:W,hidden:f(_)||f(v)?!0:void 0}}const z=W=>{const H=c(W);if(typeof H.title=="string"&&kh(H.title))return!0;const X=H.properties?.__resolveType?.enum;if(Array.isArray(X)&&typeof X[0]=="string")return!0;if(Array.isArray(H.allOf))for(const q of H.allOf){const Z=q.properties?.__resolveType?.enum;if(Array.isArray(Z)&&typeof Z[0]=="string")return!0}return!1},K=W=>{if(z(W))return!1;const H=c(W);return H.type==="object"||!!H.properties},Y=(Array.isArray(_.anyOf)||Array.isArray(_.oneOf))&&b<ba&&D.every(K);if(D.every(W=>typeof W.$ref=="string")&&!Y){const W=[];for(const H of D){const X=a(H.$ref);let q,Z;if(typeof X.title=="string"){const ee=kh(X.title);ee&&(q=ee.blockId,Z=ee.blockId)}if(!q&&Array.isArray(X.allOf))for(const ee of X.allOf){const se=((ee.properties??{}).__resolveType??{}).enum;if(Array.isArray(se)&&typeof se[0]=="string"){q=se[0];break}}if(!q){const J=X.properties?.__resolveType?.enum;Array.isArray(J)&&typeof J[0]=="string"&&(q=J[0])}q||(q=H.$ref.split("/").pop()??"");const Q=d(H);!Q&&!q.includes("/")||W.push({resolveType:Q??q,title:Z??(typeof X.title=="string"&&!X.title.startsWith("#")?X.title:Tt(q)),description:typeof X.description=="string"?X.description:void 0,discriminatorValue:Q,schema:S(X,b+1,D.length)})}return{type:"block-ref",title:typeof _.title=="string"?_.title:void 0,description:typeof _.description=="string"?_.description:void 0,anyOfRefs:W,hidden:f(_)||f(v)?!0:void 0}}if(Y){const W=X=>{if(typeof X.const=="string"||typeof X.const=="number"||typeof X.const=="boolean")return X.const;if(Array.isArray(X.enum)&&X.enum.length===1&&(typeof X.enum[0]=="string"||typeof X.enum[0]=="number"||typeof X.enum[0]=="boolean"))return X.enum[0]},H=D.map((X,q)=>{const Z=c(X).properties??{},Q={};for(const[ee,J]of Object.entries(Z)){const te=W(J);te!==void 0&&(Q[ee]=te)}return{title:h(X,`Option ${q+1}`),schema:p(X,b+1),discriminators:Object.keys(Q).length?Q:void 0}});return{type:"inline-union",title:typeof v.title=="string"?v.title:typeof _.title=="string"?_.title:void 0,description:typeof _.description=="string"?_.description:void 0,inlineUnionBranches:H,hidden:f(_)||f(v)?!0:void 0}}N="object"}}else typeof v.$ref=="string"&&(N="object");let E;if(b<ba){const P=m(_),D=Object.entries(P).filter(([I])=>!I.startsWith("__")&&I!=="@type");if(D.length>0){E={};for(const[I,M]of D)E[I]=p(M,b+1,j)}}let T;if((N==="array"||_.type==="array")&&b<ba){let P=_.items;P&&(typeof P.$ref=="string"&&(P=a(P.$ref)),T=p(P,b+1,j),typeof P.title=="string"&&P.title.includes("{{")&&(T.titleBy=P.title))}const k=P=>{const D=V?.[P];return typeof D=="string"?D:void 0},R=()=>{if("default"in v)return v.default;if("default"in _)return _.default;if(V&&"default"in V)return V.default};return{type:N??"string",title:typeof v.title=="string"?v.title:typeof _.title=="string"?_.title:k("title"),description:typeof v.description=="string"?v.description:typeof _.description=="string"?_.description:k("description"),default:R(),enum:Array.isArray(_.enum)?_.enum:C??void 0,format:typeof v.format=="string"?v.format:typeof _.format=="string"?_.format:k("format"),properties:E,items:T,hidden:f(_)||f(v)?!0:void 0,titleBy:typeof _.titleBy=="string"?_.titleBy:k("titleBy"),image:typeof _.image=="string"?_.image:k("image"),options:typeof v.options=="string"?v.options:typeof _.options=="string"?_.options:k("options")}},g=m(l),x={};for(const[v,b]of Object.entries(g))v.startsWith("__")||v==="@type"||(x[v]=p(b,0));return Object.keys(x).length===0?null:{type:"object",title:typeof l.title=="string"?l.title:void 0,properties:x}}function JS(t,e){const s=e.schema??{},n=E9(t,e),i=s.$defs??s.definitions??{},o=typeof n.$ref=="string"?i[n.$ref.split("/").pop()??""]??{}:n,a=o.properties??{};if(Object.keys(a).some(d=>!d.startsWith("__")))return!1;if(o.additionalProperties===!0)return!0;const c=a.__resolveType;return!!c&&Array.isArray(c.enum)&&c.enum[0]===t}function XS(t){const e=n=>{switch(typeof n){case"number":return{type:"number"};case"boolean":return{type:"boolean"};case"object":{if(n===null)return{type:"string"};if(Array.isArray(n))return{type:"array",items:e(n[0])};const i={};for(const[o,a]of Object.entries(n))o.startsWith("__")||(i[o]=e(a));return{type:"object",properties:i}}default:return{type:"string"}}},s={};for(const[n,i]of Object.entries(t))n.startsWith("__")||(s[n]=e(i));return Object.keys(s).length===0?null:{type:"object",properties:s}}function li(t,e){const s=e.schema??{},n=E9(t,e),i=s.$defs??s.definitions??{},o=typeof n.$ref=="string"?i[n.$ref.split("/").pop()??""]??{}:Object.keys(n).length>0?n:{...s,...n},a=o.icon,l=o.logo,c=o,d=u=>u===!0||u==="true",h=d(c.hide)||d(c.ignore)||d(c.unlisted);return{title:typeof o.title=="string"?o.title:void 0,description:typeof o.description=="string"?o.description:void 0,icon:typeof a=="string"?a:void 0,logo:typeof l=="string"?l:void 0,hidden:h||void 0}}function Gn(t){return t.replace(/\/+$/,"")||"/"}function QS(t){const e=t.trim();return!(!e.startsWith("/")||e.startsWith("//")||e.includes("..")||e.includes("\\"))}function P9(t){const e=t.trim();return e?QS(e)?null:"Path must start with / and must not contain .. or //.":"Path is required."}const Ap=/:([A-Za-z0-9_-]+)|\*/g;function Ep(t){return t.replace(/\{([^{}]*)\}\?/g,"$1")}function yl(t){t=Ep(t);const e=[];let s=0;for(const n of t.matchAll(Ap))n.index>s&&e.push({type:"text",text:t.slice(s,n.index)}),e.push({type:"param",name:n[1]??"*"}),s=n.index+n[0].length;return s<t.length&&e.push({type:"text",text:t.slice(s)}),e}function pi(t,e){return Ep(t).replace(Ap,(s,n)=>{const i=e[n??"*"]?.trim();return i?n!==void 0?encodeURIComponent(i):i.split("/").filter(Boolean).map(encodeURIComponent).join("/")||s:s})}const ZS=["website/sections/Rendering/Lazy.tsx","website/sections/Rendering/SingleDeferred.tsx"],Nh="website/sections/Rendering/Lazy.tsx";function fs(t){return ZS.some(e=>t.endsWith(e))}const Pp=["website/pages/Page.tsx","$live/pages/LivePage.tsx"],Rp=new Set(Pp),ew=new Set(["site/sections/Theme/Theme.tsx"]);function lc(t){return!!(ew.has(t)||fs(t)||t.toLowerCase().includes("preview"))}function Md(t){const e=t.manifest?.blocks??{};for(const s of Object.values(e))for(const n of Object.keys(s))if(Rp.has(n))return n;return Pp[0]}function Od(t){if(!t)return[];if(t.anyOfRefs?.length)return t.anyOfRefs;if(t.items)return Od(t.items);if(t.properties){const e=[];for(const s of Object.values(t.properties))e.push(...Od(s));return e}return[]}function tw(t){const e=t.manifest?.blocks??{},s=[];for(const[n,i]of Object.entries(e))if(n.includes("sections"))for(const o of Object.keys(i)){if(lc(o))continue;const a=li(o,t);s.push({resolveType:o,title:a.title??Tt(o),description:a.description,previewBlock:o,isSavedBlock:!1})}return s}function sw(t){const e=t.manifest?.blocks??{},s=[];for(const[n,i]of Object.entries(e))if(n.includes("sections"))for(const o of Object.keys(i))lc(o)||s.push({resolveType:o,title:Tt(o)});return s.sort((n,i)=>n.title.localeCompare(i.title))}function Dp(t,e){const s=[];for(const[n,i]of Object.entries(e)){if(n.includes("/")||ac(n)||!i||typeof i!="object"||Array.isArray(i))continue;const o=i,a=o.__resolveType;typeof a=="string"&&(Rp.has(a)||typeof o.path!="string"&&(lc(a)||jp(t,a)&&s.push({resolveType:n,title:n,description:typeof o.name=="string"?o.name:void 0,previewBlock:n,isSavedBlock:!0})))}return s}function nw(t,e){const s=_n(e.resolveType),n=s?{}:li(e.resolveType,t);return{resolveType:e.resolveType,title:e.title||n.title||Tt(e.resolveType),description:e.description??n.description,previewBlock:e.resolveType,isSavedBlock:s}}function bH(t,e){const s=Md(t),n=yn(s,t),i=Od(n?.properties?.sections),o=new Map,a=l=>{if(!lc(l.resolveType)){if(_n(l.resolveType)){ac(l.resolveType)||o.set(l.resolveType,l);return}jp(t,l.resolveType)&&(o.has(l.resolveType)||o.set(l.resolveType,l))}};for(const l of tw(t))a(l);for(const l of i)a(nw(t,l));for(const l of Dp(t,e))a(l);return[...o.values()].sort((l,c)=>l.title.localeCompare(c.title))}function _H(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}const R9="website/loaders/redirect.ts",Ip=new Set([R9,"website/loaders/redirects.ts"]),iw={temporary:307,permanent:301},Th=t=>typeof t=="string"?t:"",rw=t=>t==="permanent"?"permanent":"temporary";function Mp(t){const e=t&&typeof t.redirect=="object"&&t.redirect!==null&&!Array.isArray(t.redirect)?t.redirect:{};return{from:Th(e.from),to:Th(e.to),type:rw(e.type),discardQueryParameters:e.discardQueryParameters===!0}}function Op(t){const e=[];for(const[s,n]of Object.entries(t)){if(!n||typeof n!="object"||Array.isArray(n))continue;const i=n;if(i.__resolveType!==R9)continue;const{from:o,to:a,type:l,discardQueryParameters:c}=Mp(i);e.push({key:s,from:o,to:a,type:l,discardQueryParameters:c})}return e}function yH(t){return Mp(t)}function ow(t){const e={from:t.from,to:t.to,type:t.type};return t.discardQueryParameters&&(e.discardQueryParameters=!0),{redirect:e,__resolveType:R9}}function aw(t){return(t.split(/[?#]/)[0]??"").replace(/^\/+/,"").replace(/[^a-zA-Z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,32)||"redirect"}const lw=1e3;function cw(t,e){const s=aw(e);for(let n=0;n<lw;n++){const i=`redirects-${s}-${crypto.randomUUID()}`;if(!Object.hasOwn(t,i))return i}throw new Error("Could not generate a unique redirect block key")}function dw(t){let e=t;e.startsWith("pages-")&&(e=e.slice(6)),e=e.replace(/-[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,""),e=e.replace(/-[0-9a-f]{8,}$/i,"");try{return decodeURIComponent(e)}catch{return e}}function uw(t,e,s){const n=Gn;if(s){const o=t.find(a=>a.key===s);if(o)return o}const i=t.filter(o=>n(o.path)===n(e));return i.length===0?null:i.length===1?i[0]??null:[...i].sort((o,a)=>o.key.localeCompare(a.key))[0]??null}const Bp=new Set(["website/pages/Page.tsx","$live/pages/LivePage.tsx"]),ao="site",D9="site/apps/site.ts";function Ll(t,e){return t===ao?!0:e.__resolveType===D9}function I9(t,e){return t?M9(t).length>0||Op(t).length>0?!0:e?O9(t,e).length>0||Bd(t,e)?!0:hw(t,e).length>0:!1:!1}function M9(t){const e=[];for(const[s,n]of Object.entries(t))if(n&&typeof n=="object"&&!Array.isArray(n)){const i=n;typeof i.__resolveType=="string"&&Bp.has(i.__resolveType)&&typeof i.path=="string"&&e.push({key:s,name:typeof i.name=="string"?i.name:dw(s),path:i.path})}return e}function cc(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 Sl(t,e,s){const n=typeof e.__resolveType=="string"?e.__resolveType:"",i=n?li(n,s):{};if(i.title)return i.title;if(typeof e.name=="string"){const o=e.name.trim();if(o)return o}return t.replace(/[-_]/g," ").replace(/\b\w/g,o=>o.toUpperCase())}function Bd(t,e){const s=t[ao];if(s&&typeof s=="object"&&!Array.isArray(s)){const n=s,i=n.__resolveType;if(typeof i=="string"&&(Ll(ao,n)||Np(e,i)))return{key:ao,name:Sl(ao,n,e),resolveType:i}}for(const[n,i]of Object.entries(t)){if(n.includes("/")||!i||typeof i!="object"||Array.isArray(i))continue;const o=i;if(!Ll(n,o))continue;const a=typeof o.__resolveType=="string"?o.__resolveType:D9;return{key:n,name:Sl(n,o,e),resolveType:a}}return null}function hw(t,e){const s=[];for(const[n,i]of Object.entries(t)){if(n.includes("/")||!i||typeof i!="object"||Array.isArray(i))continue;const o=i,a=o.__resolveType;typeof a=="string"&&(Bp.has(a)||typeof o.path!="string"&&(Ll(n,o)||!Np(e,a)&&!Tp(a)||s.push({key:n,name:Sl(n,o,e),resolveType:a})))}return s.sort((n,i)=>n.name.localeCompare(i.name))}function O9(t,e){return Dp(e,t).map(s=>{const n=t[s.resolveType],i=typeof n.__resolveType=="string"?n.__resolveType:"";return{key:s.resolveType,name:s.description??cc(s.resolveType,n),resolveType:i}}).sort((s,n)=>s.name.localeCompare(n.name))}const fw={overview:Dv,settings:Im,automations:G0,preview:ai,code:Rv,content:Dm,git:Zs,files:Zn};function Ah(t){const e=ql(t);if(e.type==="icon"){const s=Oi(e.name);return s?{kind:"component",Component:s}:null}return e.type==="url"?{kind:"url",src:e.url}:null}function _a(t){if(t.kind==="system")return{kind:"component",Component:fw[t.tabId]};const e=Ah(t.iconUrl);if(e)return e;if(!t.appId)return{kind:"fallback"};const s=t.connections.find(i=>i.id===t.appId);if(!s)return{kind:"fallback"};const n=Ah(s.icon);return n||{kind:"fallback"}}const mw=[{id:"preview",title:"Preview"},{id:"code",title:"Code"}];function pw(t){return t?[...mw]:[]}function $p(t){return t.reportsOnly&&!t.onReportAgent&&(t.tabId==="preview"||t.tabId==="code")}function gw(t){const{org:e}=Oe(),s=$s(),n=wm(),i=A.useSyncExternalStore(n.threads.subscribe,n.threads.get),o=t?i.find(l=>l.id===t)??null:null,{data:a}=rm({queryKey:at.ensureTask(e.id,t),queryFn:async()=>{if(!t)return null;try{const{item:l}=await s.call("COLLECTION_THREADS_GET",{id:t});return l??null}catch{return null}},select:l=>l?.metadata??null,staleTime:3e4});return o?.metadata??a??null}function B9(t){const e=F.c(35),s=re(),n=St();let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={strict:!1},e[0]=i):i=e[0];const o=wr(i),a=gs(t.virtualMcpId),l=gw(t.taskId),{org:c}=Oe(),{currentBranch:d}=Zt();let h;e[1]!==a?(h=sa(a),e[1]=a,e[2]=h):h=e[2];const u=h,f=u?.connectionId??"",m=u?.owner??"",p=u?.name??"",g=u?d:null;let x;e[3]!==c.id||e[4]!==c.slug||e[5]!==f||e[6]!==m||e[7]!==p||e[8]!==g?(x={orgId:c.id,orgSlug:c.slug,connectionId:f,owner:m,repo:p,branch:g},e[3]=c.id,e[4]=c.slug,e[5]=f,e[6]=m,e[7]=p,e[8]=g,e[9]=x):x=e[9];const v=S9(x),b=v.data?.state==="open",y=a?.metadata?.ui??null,_=y?.layout??null,L=_?.tabs??[],w=a?.id?$x(a.id):null,j=l?.expanded_tools??[],S=Gm(a),C=sn(a?.metadata)||sn(l),{granted:N}=xb("agents:manage"),V=Ql();let E;e[10]===Symbol.for("react.memo_cache_sentinel")?(E={includeVirtual:!0},e[10]=E):E=e[10];const T=Rn(E),k=Fs(),{vmEntry:R,previewUrl:P}=Er(),D=k.lifecycle.phase==="running";let I;e[11]!==P||e[12]!==R?.sandboxProviderKind?(I=R?.sandboxProviderKind==="user-desktop"&&P?`${P.replace(/\/+$/,"")}/api/mcp`:void 0,e[11]=P,e[12]=R?.sandboxProviderKind,e[13]=I):I=e[13];const M=I,O=Fx({connectionId:w??void 0,orgId:c.id,orgSlug:c.slug,mcpUrl:M}),$=O,B=!!O&&D;let z;e[14]!==B||e[15]!==$?(z={client:$,enabled:B},e[14]=B,e[15]=$,e[16]=z):z=e[16];const{data:K}=a9(z),G=w&&D?(K?.tools??[]).filter(bw).map(Se=>({connectionId:w,toolName:Se.name,label:Ci(Se.name),icon:null})):[],Y=G[0],U=Y?G:y?.pinnedViews??[],W=Y&&w?{type:"ext-apps",id:w,toolName:Y.toolName}:_?.defaultMainView??null,H=C&&a?.id&&d?{orgSlug:c.slug,virtualMcpId:a.id,branch:d,previewUrl:P}:null;let X;e[17]!==D?(X={fetchEnabled:D},e[17]=D,e[18]=X):X=e[18];const{data:q}=rc(H,X);let Z;e[19]!==D?(Z={fetchEnabled:D},e[19]=D,e[20]=Z):Z=e[20];const{data:Q}=oc(H,Z),ee=I9(q,Q),{activeTab:J,mainOpen:te}=tb({mainParam:o.main,metadata:W||_?{defaultMainView:W,tabs:L.map(vw)}:null}),se=S&&(b||v.isPending&&J==="git"),ne=W||_?{defaultMainView:W,tabs:L.map(xw)}:null,de=J==="git"&&!se&&!v.isPending?rl(ne):J==="content"&&!ee?rl(ne):J,xe=J==="git"&&!se&&!v.isPending?!1:te,ue=i2(de),ce=[];(W?.type==="overview"||V)&&ce.push({id:"overview",title:s("common.mainPanelTabs.overview")});let oe;e[21]!==s?(oe=Se=>({id:Se.id,title:Se.id==="preview"?s("common.mainPanelTabs.preview"):Se.id==="code"?s("common.mainPanelTabs.code"):Se.title}),e[21]=s,e[22]=oe):oe=e[22],ce.push(...pw(C||V).map(oe));const fe=[];C&&ee&&fe.push({id:"content",title:s("common.mainPanelTabs.content")}),se&&fe.push({id:"git",title:s("common.mainPanelTabs.reviewChanges")}),V||(fe.push({id:"automations",title:s("common.mainPanelTabs.automations")}),N&&fe.push({id:"settings",title:s("common.mainPanelTabs.settings")}));const pe=new Map;for(const Se of j){const Be=Fa(Se.appId,Se.toolName);pe.set(Be,{id:Be,title:Se.toolName,appId:Se.appId,iconKey:Se.toolName})}for(const Se of U){const Be=Fa(Se.connectionId,Se.toolName);pe.set(Be,{id:Be,title:Se.label||Se.toolName,appId:Se.connectionId,iconKey:Se.toolName,iconUrl:Se.icon??null})}if(V){const Se=zx.COMMERCE_DISCOVERY(c.id),Be=Fa(Se,Bu);pe.has(Be)||pe.set(Be,{id:Be,title:s("common.mainPanelTabs.report"),appId:Se,iconKey:Bu,iconUrl:Kx})}const we=r2(de),Ne=we?we.key.split("/").pop()??we.key:null,Fe=Ne?[{id:de,title:Ne,kind:"file",icon:{kind:"component",Component:Se=>A.createElement(pr,{filename:Ne,...Se})}}]:[],je=o2(de),Ie=je?[{id:de,title:(je.path.split("/").pop()??je.path).replace(/\.html$/i,""),kind:"file",icon:{kind:"component",Component:Se=>A.createElement(je.path.startsWith("pages/")?ai:Nr,Se)}}]:[],Pe=a2(de),Ye=Pe?Pe.path.split("/").pop()??Pe.path:null,_e=Ye?[{id:de,title:Ye,kind:"file",icon:{kind:"component",Component:Se=>A.createElement(pr,{filename:Ye,...Se})}}]:[];let Ae;e[23]!==T?(Ae=Se=>({id:Se.id,title:Se.title,kind:"agent",icon:_a({tabId:Se.id,kind:"agent",appId:Se.view.appId,connections:T})}),e[23]=T,e[24]=Ae):Ae=e[24];const Re=[...ce.map(Se=>({id:Se.id,title:Se.title,kind:"system",icon:_a({tabId:Se.id,kind:"system",connections:T})})),...Fe,...Ie,..._e,...L.map(Ae),...Array.from(pe.values()).map(Se=>({id:Se.id,title:Se.title,kind:"expanded",icon:_a({tabId:Se.iconKey,kind:"expanded",appId:Se.appId,iconUrl:Se.iconUrl,connections:T})})),...fe.map(Se=>({id:Se.id,title:Se.title,kind:"system",icon:_a({tabId:Se.id,kind:"system",connections:T})}))],ye=t.virtualMcpId;let ve;e[25]!==c.id?(ve=tl(c.id),e[25]=c.id,e[26]=ve):ve=e[26];const Le=ye===ve;let $e;return e[27]!==de||e[28]!==xe||e[29]!==n||e[30]!==Le||e[31]!==c.id||e[32]!==c.slug||e[33]!==V?($e=Se=>{if($p({reportsOnly:V,onReportAgent:Le,tabId:Se})){n({to:"/$org/$taskId",params:{org:c.slug,taskId:crypto.randomUUID()},search:{virtualmcpid:tl(c.id),main:Se}});return}const Be=sb({clickedId:Se,activeTab:de,mainOpen:xe});n({to:".",search:nt=>({...nt,main:Be}),replace:!0})},e[27]=de,e[28]=xe,e[29]=n,e[30]=Le,e[31]=c.id,e[32]=c.slug,e[33]=V,e[34]=$e):$e=e[34],{activeTab:de,mainOpen:xe,setActiveTab:$e,systemTabs:[...ce,...fe],layoutTabs:L,expandedTools:j,automationTabParsed:ue,tabs:Re}}function xw(t){return{id:t.id}}function vw(t){return{id:t.id}}function bw(t){return!!Zl(t._meta)}function Fp(t){const{managerAgentId:e,managerName:s,kind:n,id:i,instructions:o}=t,a=` to improve the instructions of ${n} "${i}". Here are its current instructions.
|
|
8
|
-
<current_instructions>${o}</current_instructions>`;return{type:"doc",content:[{type:"paragraph",content:[{type:"text",text:"Use "},{type:"mention",attrs:{id:e,name:s,char:"@",metadata:{agentId:e,title:s}}},{type:"text",text:a}]}]}}function _w(t){const e=F.c(9),s=$s();let n;e[0]!==t?(n=at.user(t),e[0]=t,e[1]=n):n=e[1];let i;e[2]!==s||e[3]!==t?(i=async()=>{const{user:l}=await s.call("USER_GET",{id:t});return l},e[2]=s,e[3]=t,e[4]=i):i=e[4];const o=!!t;let a;return e[5]!==n||e[6]!==i||e[7]!==o?(a={queryKey:n,queryFn:i,staleTime:3e5,retry:1,enabled:o},e[5]=n,e[6]=i,e[7]=o,e[8]=a):a=e[8],Mt(a)}function zp(t){const e=F.c(37),{id:s,size:n,showEmail:i,avatarOnly:o,className:a}=t,l=n===void 0?"xs":n,c=i===void 0?!1:i,d=o===void 0?!1:o,h=re(),{data:u,isLoading:f,isError:m}=_w(s);if(f){let y;e[0]!==a?(y=ie("flex items-center gap-2",a),e[0]=a,e[1]=y):y=e[1];let _;e[2]!==l?(_=r.jsx(ir.Skeleton,{shape:"circle",size:l}),e[2]=l,e[3]=_):_=e[3];let L;e[4]!==d||e[5]!==c?(L=!d&&r.jsxs("div",{className:"flex flex-col gap-1",children:[r.jsx("div",{className:"h-3 w-24 bg-muted animate-pulse rounded"}),c&&r.jsx("div",{className:"h-2 w-32 bg-muted animate-pulse rounded"})]}),e[4]=d,e[5]=c,e[6]=L):L=e[6];let w;return e[7]!==y||e[8]!==_||e[9]!==L?(w=r.jsxs("div",{className:y,children:[_,L]}),e[7]=y,e[8]=_,e[9]=L,e[10]=w):w=e[10],w}if(m||!u){let y;e[11]!==a?(y=ie("flex items-center gap-2",a),e[11]=a,e[12]=y):y=e[12];let _;e[13]!==l?(_=r.jsx(ir,{shape:"circle",size:l,fallback:"?",muted:!0}),e[13]=l,e[14]=_):_=e[14];let L;e[15]!==d||e[16]!==h?(L=!d&&r.jsx("div",{className:"flex flex-col",children:r.jsx("div",{className:"text-sm text-muted-foreground",children:h("user.user.unknownUser")})}),e[15]=d,e[16]=h,e[17]=L):L=e[17];let w;return e[18]!==y||e[19]!==_||e[20]!==L?(w=r.jsxs("div",{className:y,children:[_,L]}),e[18]=y,e[19]=_,e[20]=L,e[21]=w):w=e[21],w}let p;e[22]!==a?(p=ie("flex items-center gap-2",a),e[22]=a,e[23]=p):p=e[23];const g=u.image??void 0;let x;e[24]!==l||e[25]!==g||e[26]!==u.name?(x=r.jsx(ir,{shape:"circle",size:l,url:g,fallback:u.name}),e[24]=l,e[25]=g,e[26]=u.name,e[27]=x):x=e[27];let v;e[28]!==d||e[29]!==c||e[30]!==u.email||e[31]!==u.name?(v=!d&&r.jsxs("div",{className:"flex flex-col",children:[r.jsx("div",{className:"text-sm font-medium",children:u.name}),c&&r.jsx("div",{className:"text-xs text-muted-foreground",children:u.email})]}),e[28]=d,e[29]=c,e[30]=u.email,e[31]=u.name,e[32]=v):v=e[32];let b;return e[33]!==p||e[34]!==x||e[35]!==v?(b=r.jsxs("div",{className:p,children:[x,v]}),e[33]=p,e[34]=x,e[35]=v,e[36]=b):b=e[36],b}function yw(t){const e=F.c(8);let s,n;e[0]!==t?({className:s,...n}=t,e[0]=t,e[1]=s,e[2]=n):(s=e[1],n=e[2]);let i;e[3]!==s?(i=ie("grid gap-3",s),e[3]=s,e[4]=i):i=e[4];let o;return e[5]!==n||e[6]!==i?(o=r.jsx(jb,{"data-slot":"radio-group",className:i,...n}),e[5]=n,e[6]=i,e[7]=o):o=e[7],o}function Lw(t){const e=F.c(9);let s,n;e[0]!==t?({className:s,...n}=t,e[0]=t,e[1]=s,e[2]=n):(s=e[1],n=e[2]);let i;e[3]!==s?(i=ie("border-input text-primary focus-visible:border-ring focus-visible:ring-ring/20 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 aspect-square size-4 shrink-0 rounded-full border shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[2px] disabled:opacity-50",s),e[3]=s,e[4]=i):i=e[4];let o;e[5]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx(Cb,{"data-slot":"radio-group-indicator",className:"relative flex items-center justify-center",children:r.jsx(kb,{className:"fill-primary absolute top-1/2 left-1/2 size-2 -translate-x-1/2 -translate-y-1/2"})}),e[5]=o):o=e[5];let a;return e[6]!==n||e[7]!==i?(a=r.jsx(wb,{"data-slot":"radio-group-item",className:i,...n,children:o}),e[6]=n,e[7]=i,e[8]=a):a=e[8],a}function Sw(t){const e=F.c(82),{value:s,onChange:n,onColorChange:i,name:o,size:a,className:l,avatarClassName:c,showHoverOverlay:d,disabled:h}=t,u=a===void 0?"lg":a,f=d===void 0?!0:d,m=h===void 0?!1:h,p=re(),[g,x]=A.useState(!1),[v,b]=A.useState("icons"),[y,_]=A.useState(""),[L,w]=A.useState("blue");let j;e[0]!==s?(j=ql(s),e[0]=s,e[1]=j):j=e[1];const S=j,C=S.type==="icon"||S.type==="url"&&S.color?S.color:L;let N;e[2]!==n||e[3]!==C?(N=pe=>{n(Ic(pe,C))},e[2]=n,e[3]=C,e[4]=N):N=e[4];const V=N;let E;e[5]!==n||e[6]!==i||e[7]!==S.name||e[8]!==S.type||e[9]!==S.url?(E=pe=>{w(pe),i?.(pe),S.type==="icon"?n(Ic(S.name,pe)):S.type==="url"&&n(Ku(S.url,pe))},e[5]=n,e[6]=i,e[7]=S.name,e[8]=S.type,e[9]=S.url,e[10]=E):E=e[10];const T=E;let k;e[11]!==n||e[12]!==C?(k=pe=>{n(Ku(pe,C)),x(!1)},e[11]=n,e[12]=C,e[13]=k):k=e[13];const R=k;let P;e[14]!==n||e[15]!==C?(P=()=>{const pe=Y0(),we=pe[Math.floor(Math.random()*pe.length)];n(Ic(we,C))},e[14]=n,e[15]=C,e[16]=P):P=e[16];const D=P,I=m?!1:g,M=m?"cursor-default opacity-50":"cursor-pointer";let O;e[17]!==l||e[18]!==u||e[19]!==M?(O=ie("relative group overflow-hidden",M,Iv(u),l),e[17]=l,e[18]=u,e[19]=M,e[20]=O):O=e[20];let $;e[21]!==c||e[22]!==o||e[23]!==u||e[24]!==s?($=r.jsx(Xn,{icon:s,name:o,size:u,className:c}),e[21]=c,e[22]=o,e[23]=u,e[24]=s,e[25]=$):$=e[25];let B;e[26]!==m||e[27]!==f?(B=f&&!m&&r.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/50 opacity-0 group-hover:opacity-100 transition-opacity",children:r.jsx(Dm,{size:16,className:"text-white"})}),e[26]=m,e[27]=f,e[28]=B):B=e[28];let z;e[29]!==m||e[30]!==O||e[31]!==$||e[32]!==B?(z=r.jsx(Es,{asChild:!0,children:r.jsxs("button",{type:"button","data-testid":"icon-picker-trigger","aria-label":"Change icon",disabled:m,className:O,children:[$,B]})}),e[29]=m,e[30]=O,e[31]=$,e[32]=B,e[33]=z):z=e[33];let K;e[34]!==o||e[35]!==s?(K=r.jsx("div",{className:"flex items-center justify-center py-4",children:r.jsx(Xn,{icon:s,name:o,size:"xl"})}),e[34]=o,e[35]=s,e[36]=K):K=e[36];let G;e[37]!==v?(G=pe=>{if(pe.key!=="ArrowLeft"&&pe.key!=="ArrowRight")return;pe.preventDefault();const we=v==="icons"?"upload":"icons";b(we),document.getElementById(`icon-picker-tab-${we}`)?.focus()},e[37]=v,e[38]=G):G=e[38];const Y=v==="icons",U=v==="icons"?0:-1;let W;e[39]===Symbol.for("react.memo_cache_sentinel")?(W=()=>b("icons"),e[39]=W):W=e[39];const H=v==="icons"?"border-foreground text-foreground":"border-transparent text-muted-foreground hover:text-foreground";let X;e[40]!==H?(X=ie("px-3 py-2 text-sm font-medium border-b-2 -mb-px transition-colors",H),e[40]=H,e[41]=X):X=e[41];let q;e[42]!==p?(q=p("common.iconPicker.iconsTab"),e[42]=p,e[43]=q):q=e[43];let Z;e[44]!==Y||e[45]!==U||e[46]!==X||e[47]!==q?(Z=r.jsx("button",{id:"icon-picker-tab-icons",type:"button",role:"tab","aria-selected":Y,"aria-controls":"icon-picker-panel-icons",tabIndex:U,onClick:W,className:X,children:q}),e[44]=Y,e[45]=U,e[46]=X,e[47]=q,e[48]=Z):Z=e[48];const Q=v==="upload",ee=v==="upload"?0:-1;let J;e[49]===Symbol.for("react.memo_cache_sentinel")?(J=()=>b("upload"),e[49]=J):J=e[49];const te=v==="upload"?"border-foreground text-foreground":"border-transparent text-muted-foreground hover:text-foreground";let se;e[50]!==te?(se=ie("px-3 py-2 text-sm font-medium border-b-2 -mb-px transition-colors",te),e[50]=te,e[51]=se):se=e[51];let ne;e[52]!==p?(ne=p("common.iconPicker.uploadTab"),e[52]=p,e[53]=ne):ne=e[53];let de;e[54]!==Q||e[55]!==ee||e[56]!==se||e[57]!==ne?(de=r.jsx("button",{id:"icon-picker-tab-upload",type:"button",role:"tab","aria-selected":Q,"aria-controls":"icon-picker-panel-upload",tabIndex:ee,onClick:J,className:se,children:ne}),e[54]=Q,e[55]=ee,e[56]=se,e[57]=ne,e[58]=de):de=e[58];let xe;e[59]===Symbol.for("react.memo_cache_sentinel")?(xe=r.jsx("div",{className:"flex-1"}),e[59]=xe):xe=e[59];let ue;e[60]!==G||e[61]!==Z||e[62]!==de?(ue=r.jsxs("div",{role:"tablist","aria-label":"Icon source",className:"flex items-center border-b border-border px-3",onKeyDown:G,children:[Z,de,xe]}),e[60]=G,e[61]=Z,e[62]=de,e[63]=ue):ue=e[63];let ce;e[64]!==T||e[65]!==D||e[66]!==V||e[67]!==R||e[68]!==S.name||e[69]!==S.type||e[70]!==y||e[71]!==C||e[72]!==v?(ce=v==="icons"?r.jsx("div",{id:"icon-picker-panel-icons",role:"tabpanel","aria-labelledby":"icon-picker-tab-icons",children:r.jsx(kw,{search:y,onSearchChange:_,selectedColor:C,onColorChange:T,onSelectIcon:V,onRandom:D,currentIconName:S.type==="icon"?S.name:null})}):r.jsx("div",{id:"icon-picker-panel-upload",role:"tabpanel","aria-labelledby":"icon-picker-tab-upload",children:r.jsx(Vw,{onUpload:R})}),e[64]=T,e[65]=D,e[66]=V,e[67]=R,e[68]=S.name,e[69]=S.type,e[70]=y,e[71]=C,e[72]=v,e[73]=ce):ce=e[73];let oe;e[74]!==K||e[75]!==ue||e[76]!==ce?(oe=r.jsx(Ps,{align:"start",className:"w-80 p-0",onOpenAutoFocus:ww,children:r.jsxs("div",{className:"flex flex-col",children:[K,ue,ce]})}),e[74]=K,e[75]=ue,e[76]=ce,e[77]=oe):oe=e[77];let fe;return e[78]!==z||e[79]!==oe||e[80]!==I?(fe=r.jsxs(As,{open:I,onOpenChange:x,children:[z,oe]}),e[78]=z,e[79]=oe,e[80]=I,e[81]=fe):fe=e[81],fe}function ww(t){return t.preventDefault()}function jw(t){const e=F.c(33),{selectedColor:s,onColorChange:n}=t,i=re(),[o,a]=A.useState(!1);let l,c,d,h,u,f,m;if(e[0]!==o||e[1]!==s){const L=Mm(s);c=As,f=o,m=a,l=Es,u=!0,d="button",h=ie("h-6 w-6 rounded-full shrink-0 ring-2 ring-offset-2 ring-offset-background transition-all cursor-pointer hover:scale-110",L.dot,"ring-foreground/20"),e[0]=o,e[1]=s,e[2]=l,e[3]=c,e[4]=d,e[5]=h,e[6]=u,e[7]=f,e[8]=m}else l=e[2],c=e[3],d=e[4],h=e[5],u=e[6],f=e[7],m=e[8];let p;e[9]!==i?(p=i("common.iconPicker.changeColor"),e[9]=i,e[10]=p):p=e[10];let g;e[11]!==i?(g=i("common.iconPicker.changeColor"),e[11]=i,e[12]=g):g=e[12];let x;e[13]!==d||e[14]!==h||e[15]!==p||e[16]!==g?(x=r.jsx("button",{type:d,className:h,title:p,"aria-label":g}),e[13]=d,e[14]=h,e[15]=p,e[16]=g,e[17]=x):x=e[17];let v;e[18]!==l||e[19]!==u||e[20]!==x?(v=r.jsx(l,{asChild:u,children:x}),e[18]=l,e[19]=u,e[20]=x,e[21]=v):v=e[21];let b;e[22]!==n||e[23]!==s?(b=Ov.map(L=>r.jsx("button",{type:"button",onClick:()=>{n(L.name),a(!1)},className:ie("h-5 w-5 rounded-full transition-all shrink-0 cursor-pointer",L.dot,s===L.name?"ring-2 ring-offset-1 ring-offset-background ring-foreground/30 scale-110":"hover:scale-110"),title:L.name,"aria-label":L.name},L.name)),e[22]=n,e[23]=s,e[24]=b):b=e[24];let y;e[25]!==b?(y=r.jsx(Ps,{align:"start",side:"right",sideOffset:8,className:"w-auto p-2",onOpenAutoFocus:Cw,children:r.jsx("div",{className:"grid grid-cols-4 gap-1",children:b})}),e[25]=b,e[26]=y):y=e[26];let _;return e[27]!==c||e[28]!==y||e[29]!==f||e[30]!==m||e[31]!==v?(_=r.jsxs(c,{open:f,onOpenChange:m,children:[v,y]}),e[27]=c,e[28]=y,e[29]=f,e[30]=m,e[31]=v,e[32]=_):_=e[32],_}function Cw(t){return t.preventDefault()}function kw(t){const e=F.c(55),{search:s,onSearchChange:n,selectedColor:i,onColorChange:o,onSelectIcon:a,onRandom:l,currentIconName:c}=t,d=re();let h,u,f,m,p,g,x;if(e[0]!==c||e[1]!==o||e[2]!==l||e[3]!==n||e[4]!==a||e[5]!==s||e[6]!==i||e[7]!==d){const L=Y0(),w=Mm(i);u=Om(L,s),g="flex flex-col";let j;e[15]===Symbol.for("react.memo_cache_sentinel")?(j=r.jsx(Io,{size:14,className:"absolute left-2 top-1/2 -translate-y-1/2 text-muted-foreground pointer-events-none"}),e[15]=j):j=e[15];let S;e[16]!==n?(S=P=>n(P.target.value),e[16]=n,e[17]=S):S=e[17];let C;e[18]!==d?(C=d("common.iconPicker.filterPlaceholder"),e[18]=d,e[19]=C):C=e[19];let N;e[20]!==s||e[21]!==S||e[22]!==C?(N=r.jsxs("div",{className:"relative flex-1",children:[j,r.jsx(rt,{value:s,onChange:S,placeholder:C,className:"h-8 text-xs pl-7"})]}),e[20]=s,e[21]=S,e[22]=C,e[23]=N):N=e[23];let V;e[24]!==d?(V=d("common.iconPicker.randomIcon"),e[24]=d,e[25]=V):V=e[25];let E;e[26]!==d?(E=d("common.iconPicker.randomIcon"),e[26]=d,e[27]=E):E=e[27];let T;e[28]===Symbol.for("react.memo_cache_sentinel")?(T=r.jsx(Mv,{size:14,className:"text-muted-foreground"}),e[28]=T):T=e[28];let k;e[29]!==l||e[30]!==V||e[31]!==E?(k=r.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:V,"aria-label":E,children:T}),e[29]=l,e[30]=V,e[31]=E,e[32]=k):k=e[32];let R;e[33]!==o||e[34]!==i?(R=r.jsx(jw,{selectedColor:i,onColorChange:o}),e[33]=o,e[34]=i,e[35]=R):R=e[35],e[36]!==k||e[37]!==R||e[38]!==N?(x=r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",children:[N,k,R]}),e[36]=k,e[37]=R,e[38]=N,e[39]=x):x=e[39],h=ii,p="h-56",f="grid grid-cols-9 gap-0.5 px-2 pb-2",m=u.map(P=>{const D=Oi(P);return D?r.jsx("button",{type:"button",onClick:()=>a(P),className:ie("h-8 w-8 flex items-center justify-center rounded-md transition-colors cursor-pointer",c===P?ie(w.bg,w.text):ie(w.text,"hover:bg-accent")),title:P,"aria-label":Vd(P),children:r.jsx(D,{size:18})},P):null}),e[0]=c,e[1]=o,e[2]=l,e[3]=n,e[4]=a,e[5]=s,e[6]=i,e[7]=d,e[8]=h,e[9]=u,e[10]=f,e[11]=m,e[12]=p,e[13]=g,e[14]=x}else h=e[8],u=e[9],f=e[10],m=e[11],p=e[12],g=e[13],x=e[14];let v;e[40]!==f||e[41]!==m?(v=r.jsx("div",{className:f,children:m}),e[40]=f,e[41]=m,e[42]=v):v=e[42];let b;e[43]!==u.length||e[44]!==d?(b=u.length===0&&r.jsx("div",{className:"flex items-center justify-center py-8 text-sm text-muted-foreground",children:d("common.iconPicker.noIconsFound")}),e[43]=u.length,e[44]=d,e[45]=b):b=e[45];let y;e[46]!==h||e[47]!==p||e[48]!==v||e[49]!==b?(y=r.jsxs(h,{className:p,children:[v,b]}),e[46]=h,e[47]=p,e[48]=v,e[49]=b,e[50]=y):y=e[50];let _;return e[51]!==g||e[52]!==x||e[53]!==y?(_=r.jsxs("div",{className:g,children:[x,y]}),e[51]=g,e[52]=x,e[53]=y,e[54]=_):_=e[54],_}function Vw(t){const e=F.c(46),{onUpload:s}=t,n=re(),i=A.useRef(null);let o;e[0]!==s||e[1]!==n?(o=k=>{const R=k.target.files?.[0];if(!R)return;if(R.size>2097152){ge.error(n("common.iconPicker.imageTooLarge")),k.target.value="";return}const P=new FileReader;P.onerror=()=>{ge.error(n("common.iconPicker.failedToReadImage")),i.current&&(i.current.value="")},P.onloadend=()=>{P.readyState===FileReader.DONE&&P.result&&s(P.result),i.current&&(i.current.value="")},P.readAsDataURL(R)},e[0]=s,e[1]=n,e[2]=o):o=e[2];const a=o,[l,c]=A.useState("");let d;e[3]!==s||e[4]!==l?(d=()=>{const k=l.trim();k&&(s(k),c(""))},e[3]=s,e[4]=l,e[5]=d):d=e[5];const h=d;let u;e[6]!==a?(u=r.jsx("input",{type:"file",ref:i,className:"hidden",accept:"image/*",onChange:a}),e[6]=a,e[7]=u):u=e[7];let f;e[8]===Symbol.for("react.memo_cache_sentinel")?(f=()=>i.current?.click(),e[8]=f):f=e[8];let m;e[9]===Symbol.for("react.memo_cache_sentinel")?(m=r.jsx(Bi,{size:20}),e[9]=m):m=e[9];let p;e[10]!==n?(p=n("common.iconPicker.uploadHint"),e[10]=n,e[11]=p):p=e[11];let g;e[12]!==p?(g=r.jsxs("button",{type:"button",onClick:f,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:[m,r.jsx("span",{className:"text-xs",children:p})]}),e[12]=p,e[13]=g):g=e[13];let x;e[14]!==n?(x=n("common.iconPicker.or"),e[14]=n,e[15]=x):x=e[15];let v;e[16]!==x?(v=r.jsx("span",{className:"text-xs text-muted-foreground",children:x}),e[16]=x,e[17]=v):v=e[17];let b;e[18]===Symbol.for("react.memo_cache_sentinel")?(b=r.jsx("div",{className:"flex-1 h-px bg-border"}),e[18]=b):b=e[18];let y;e[19]!==v?(y=r.jsxs("div",{className:"flex items-center gap-2",children:[v,b]}),e[19]=v,e[20]=y):y=e[20];let _;e[21]===Symbol.for("react.memo_cache_sentinel")?(_=k=>c(k.target.value),e[21]=_):_=e[21];let L;e[22]!==n?(L=n("common.iconPicker.pasteUrlPlaceholder"),e[22]=n,e[23]=L):L=e[23];let w;e[24]!==h?(w=k=>{k.key==="Enter"&&(k.preventDefault(),h())},e[24]=h,e[25]=w):w=e[25];let j;e[26]!==l||e[27]!==L||e[28]!==w?(j=r.jsx(rt,{value:l,onChange:_,placeholder:L,className:"h-8 text-xs flex-1",onKeyDown:w}),e[26]=l,e[27]=L,e[28]=w,e[29]=j):j=e[29];let S;e[30]!==l?(S=l.trim(),e[30]=l,e[31]=S):S=e[31];const C=!S;let N;e[32]!==n?(N=n("common.iconPicker.apply"),e[32]=n,e[33]=N):N=e[33];let V;e[34]!==h||e[35]!==C||e[36]!==N?(V=r.jsx(le,{variant:"outline",size:"sm",className:"h-8 px-3 text-xs shrink-0",onClick:h,disabled:C,children:N}),e[34]=h,e[35]=C,e[36]=N,e[37]=V):V=e[37];let E;e[38]!==j||e[39]!==V?(E=r.jsxs("div",{className:"flex items-center gap-1.5",children:[j,V]}),e[38]=j,e[39]=V,e[40]=E):E=e[40];let T;return e[41]!==y||e[42]!==E||e[43]!==u||e[44]!==g?(T=r.jsxs("div",{className:"flex flex-col gap-3 p-4",children:[u,g,y,E]}),e[41]=y,e[42]=E,e[43]=u,e[44]=g,e[45]=T):T=e[45],T}const Nw=25*1024*1024,Hc="home",Wc="knowledge";function Eh(t){return t==null?"":t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(0)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function ui(t){return t.split("/").pop()??t}function Tw(t){const e=F.c(64),{form:s}=t,n=re(),{upload:i}=A6(Hc),o=E6(),a=A.useRef(null),[l,c]=A.useState(!1),[d,h]=A.useState(""),[u,f]=A.useState(!1);let m;e[0]!==l?(m={enabled:l},e[0]=l,e[1]=m):m=e[1];const{data:p}=P6(60,m),g=p===void 0?[]:p;let x;e[2]!==l?(x={enabled:l},e[2]=l,e[3]=x):x=e[3];const{data:v}=R6(x),b=v===void 0?[]:v;let y;e[4]!==s?(y=()=>s.getValues("metadata.knowledge")??[],e[4]=s,e[5]=y):y=e[5];const[_,L]=A.useState(y);let w;e[6]!==s?(w=oe=>{L(oe),s.setValue("metadata.knowledge",oe,{shouldDirty:!0})},e[6]=s,e[7]=w):w=e[7];const j=w;let S;e[8]!==o||e[9]!==_||e[10]!==j||e[11]!==n||e[12]!==i?(S=async oe=>{if(!oe||oe.length===0)return;const fe=Array.from(oe).filter(Dw);if(fe.length!==0){try{await i.mutateAsync({dir:Wc,files:fe})}catch(pe){const we=pe;ge.error(we instanceof Error?we.message:n("virtualMcp.filesSection.failedUploadFile"));return}j([..._,...fe.map(pe=>({id:crypto.randomUUID(),name:pe.name,volume:Hc,path:`${Wc}/${pe.name}`,url:o(Hc,`${Wc}/${pe.name}`),contentType:pe.type||null,size:pe.size,addedAt:new Date().toISOString()}))])}},e[8]=o,e[9]=_,e[10]=j,e[11]=n,e[12]=i,e[13]=S):S=e[13];const C=S;let N;e[14]!==o||e[15]!==_||e[16]!==j?(N=oe=>{_.some(fe=>fe.volume===oe.volume&&fe.path===oe.path)||(j([..._,{id:crypto.randomUUID(),name:ui(oe.path),volume:oe.volume,path:oe.path,url:o(oe.volume,oe.path),contentType:null,size:oe.size??null,addedAt:new Date().toISOString()}]),c(!1))},e[14]=o,e[15]=_,e[16]=j,e[17]=N):N=e[17];const V=N;let E;e[18]!==o||e[19]!==_||e[20]!==j?(E=oe=>{_.some(fe=>fe.volume===oe.volume&&fe.path===oe.path)||(j([..._,{id:crypto.randomUUID(),name:ui(oe.path),kind:"skill",volume:oe.volume,path:oe.path,url:o(oe.volume,oe.path),contentType:null,size:null,addedAt:new Date().toISOString()}]),c(!1))},e[18]=o,e[19]=_,e[20]=j,e[21]=E):E=e[21];const T=E;let k;e[22]!==_||e[23]!==j?(k=oe=>{j(_.filter(fe=>fe.id!==oe))},e[22]=_,e[23]=j,e[24]=k):k=e[24];const R=k;let P;e[25]===Symbol.for("react.memo_cache_sentinel")?(P=oe=>{c(oe),oe&&h("")},e[25]=P):P=e[25];const D=P;let I;e[26]!==_?(I=new Set(_.map(Rw)),e[26]=_,e[27]=I):I=e[27];const M=I,O=d.toLowerCase();let $;e[28]!==M?($=oe=>!M.has(`${oe.volume}/${oe.path}`),e[28]=M,e[29]=$):$=e[29];const B=g.filter(Pw).filter($).filter(oe=>ui(oe.path).toLowerCase().includes(O)).slice(0,5);let z;e[30]!==M?(z=oe=>!M.has(`${oe.volume}/${oe.path}`),e[30]=M,e[31]=z):z=e[31];const K=b.filter(z).filter(oe=>ui(oe.path).toLowerCase().includes(O)).slice(0,5),G=oe=>r.jsxs(us,{open:l,onOpenChange:D,children:[r.jsx(ds,{asChild:!0,children:oe}),r.jsxs(hs,{align:"end",className:"w-56",children:[r.jsxs(Xe,{onSelect:()=>{a.current?.click()},children:[r.jsx(Bv,{size:16}),n("virtualMcp.filesSection.uploadFile")]}),r.jsxs(Ao,{children:[r.jsxs(Eo,{className:"gap-2 [&_svg:not([class*='text-'])]:text-muted-foreground",children:[r.jsx(Zn,{size:16}),n("virtualMcp.filesSection.selectFileOrFolder")]}),r.jsxs(Po,{className:"w-72 p-0",children:[r.jsxs("div",{className:"flex items-center gap-2 border-b px-3",children:[r.jsx(Io,{size:16,className:"shrink-0 text-muted-foreground"}),r.jsx("input",{value:d,onChange:fe=>h(fe.target.value),onKeyDown:Ew,placeholder:n("virtualMcp.filesSection.searchFilesPlaceholder"),className:"h-10 w-full bg-transparent text-sm outline-none placeholder:text-muted-foreground"})]}),r.jsx("div",{className:"max-h-64 overflow-y-auto p-1",children:B.length===0?r.jsx("p",{className:"px-2 py-3 text-center text-sm text-muted-foreground",children:n("virtualMcp.filesSection.noFilesFound")}):B.map(fe=>r.jsxs(Xe,{onSelect:()=>V(fe),children:[r.jsx(pr,{filename:ui(fe.path),className:"h-5 w-4 shrink-0"}),r.jsx("span",{className:"flex-1 truncate",children:ui(fe.path)}),fe.size!=null&&r.jsx("span",{className:"text-xs text-muted-foreground",children:Eh(fe.size)})]},`${fe.volume}/${fe.path}`))})]})]}),r.jsxs(Ao,{children:[r.jsxs(Eo,{className:"gap-2 [&_svg:not([class*='text-'])]:text-muted-foreground",children:[r.jsx(qn,{size:16}),n("virtualMcp.filesSection.selectSkill")]}),r.jsxs(Po,{className:"w-72 p-0",children:[r.jsxs("div",{className:"flex items-center gap-2 border-b px-3",children:[r.jsx(Io,{size:16,className:"shrink-0 text-muted-foreground"}),r.jsx("input",{value:d,onChange:fe=>h(fe.target.value),onKeyDown:Aw,placeholder:n("virtualMcp.filesSection.searchSkillsPlaceholder"),className:"h-10 w-full bg-transparent text-sm outline-none placeholder:text-muted-foreground"})]}),r.jsx("div",{className:"max-h-64 overflow-y-auto p-1",children:K.length===0?r.jsx("p",{className:"px-2 py-3 text-center text-sm text-muted-foreground",children:n("virtualMcp.filesSection.noSkillsFound")}):K.map(fe=>r.jsxs(Xe,{onSelect:()=>T(fe),children:[r.jsx(qn,{size:16,className:"shrink-0"}),r.jsx("span",{className:"flex-1 truncate",children:ui(fe.path)})]},`${fe.volume}/${fe.path}`))})]})]})]})]}),Y="flex flex-col gap-3";let U;e[32]!==n?(U=n("virtualMcp.filesSection.filesAndSkills"),e[32]=n,e[33]=U):U=e[33];let W;e[34]!==U?(W=r.jsx("h2",{className:"text-sm font-medium text-foreground",children:U}),e[34]=U,e[35]=W):W=e[35];let H;e[36]!==n?(H=n("virtualMcp.filesSection.description"),e[36]=n,e[37]=H):H=e[37];let X;e[38]!==H?(X=r.jsx("p",{className:"text-sm text-muted-foreground",children:H}),e[38]=H,e[39]=X):X=e[39];let q;e[40]!==W||e[41]!==X?(q=r.jsxs("div",{className:"flex flex-col gap-1",children:[W,X]}),e[40]=W,e[41]=X,e[42]=q):q=e[42];const Z=_.length>0&&G(r.jsxs(le,{variant:"outline",size:"sm",disabled:i.isPending,children:[i.isPending?r.jsx(wi,{size:"xs"}):r.jsx(kt,{size:14}),n("virtualMcp.filesSection.add")]}));let Q;e[43]!==q||e[44]!==Z?(Q=r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[q,Z]}),e[43]=q,e[44]=Z,e[45]=Q):Q=e[45];let ee;e[46]!==C?(ee=r.jsx("input",{ref:a,type:"file",multiple:!0,className:"hidden",onChange:oe=>{C(oe.target.files),oe.target.value=""}}),e[46]=C,e[47]=ee):ee=e[47];let J,te;e[48]===Symbol.for("react.memo_cache_sentinel")?(J=oe=>{oe.preventDefault(),f(!0)},te=()=>f(!1),e[48]=J,e[49]=te):(J=e[48],te=e[49]);let se;e[50]!==C?(se=oe=>{oe.preventDefault(),f(!1),C(oe.dataTransfer.files)},e[50]=C,e[51]=se):se=e[51];const ne=u&&"outline outline-2 outline-dashed outline-primary";let de;e[52]!==ne?(de=ie("flex flex-col gap-2 rounded-lg",ne),e[52]=ne,e[53]=de):de=e[53];const xe=_.length===0?G(r.jsxs("button",{type:"button",className:"flex items-center gap-3 px-3 py-2.5 rounded-lg border border-dashed border-border hover:bg-accent/50 transition-colors w-full text-left cursor-pointer",children:[r.jsx("div",{className:"flex items-center justify-center size-8 rounded-md text-muted-foreground/75 border border-dashed border-border shrink-0",children:r.jsx(kt,{size:16})}),r.jsx("span",{className:"text-sm text-muted-foreground flex-1",children:n("virtualMcp.filesSection.noFilesOrSkillsYet")})]})):_.map(oe=>r.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 rounded-xl border bg-card",children:[oe.kind==="skill"?r.jsx("div",{className:"flex items-center justify-center h-8 w-6.5 shrink-0 rounded-md bg-muted text-muted-foreground",children:r.jsx(qn,{size:16})}):r.jsx(pr,{filename:oe.name,className:"h-8 w-6.5 shrink-0"}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("p",{className:"text-sm font-medium truncate",children:oe.name}),r.jsx("p",{className:"text-xs text-muted-foreground",children:oe.kind==="skill"?n("virtualMcp.filesSection.kindSkill"):oe.size!=null?Eh(oe.size):n("virtualMcp.filesSection.kindFile")})]}),r.jsx(le,{variant:"ghost",size:"icon",onClick:()=>R(oe.id),"aria-label":n("virtualMcp.filesSection.removeAriaLabel",{name:oe.name}),children:r.jsx(Ns,{size:16})})]},oe.id));let ue;e[54]!==J||e[55]!==te||e[56]!==se||e[57]!==de||e[58]!==xe?(ue=r.jsx("div",{onDragOver:J,onDragLeave:te,onDrop:se,className:de,children:xe}),e[54]=J,e[55]=te,e[56]=se,e[57]=de,e[58]=xe,e[59]=ue):ue=e[59];let ce;return e[60]!==Q||e[61]!==ee||e[62]!==ue?(ce=r.jsxs("section",{className:Y,children:[Q,ee,ue]}),e[60]=Q,e[61]=ee,e[62]=ue,e[63]=ce):ce=e[63],ce}function Aw(t){return t.stopPropagation()}function Ew(t){return t.stopPropagation()}function Pw(t){return t.kind!=="dir"}function Rw(t){return`${t.volume}/${t.path}`}function Dw(t){return t.size<=Nw}function Iw(t){return t==null?"all":t.length===0?"self":"selected"}function Mw(t){const e=F.c(88),{form:s,currentAgentId:n}=t,i=re(),{org:o}=Oe(),a=Zo(),[l,c]=A.useState(!1);let d;e[0]!==s?(d=s.getValues("metadata.subAgents")??null,e[0]=s,e[1]=d):d=e[1];const h=d;let u;e[2]!==h?(u=()=>Iw(h),e[2]=h,e[3]=u):u=e[3];const[f,m]=A.useState(u);let p;e[4]!==h?(p=h??[],e[4]=h,e[5]=p):p=e[5];const[g,x]=A.useState(p);let v,b,y,_,L,w;if(e[6]!==a||e[7]!==n||e[8]!==s||e[9]!==f||e[10]!==o||e[11]!==g||e[12]!==i){let N;e[19]!==n||e[20]!==o?(N=J=>J.id!==n&&J.id!==o.id&&J.status==="active",e[19]=n,e[20]=o,e[21]=N):N=e[21],v=a.filter(N);let V;e[22]!==g?(V=J=>g.includes(J.id),e[22]=g,e[23]=V):V=e[23];const E=v.filter(V);let T;e[24]!==s?(T=(J,te)=>s.setValue("metadata.subAgents",J==="all"?null:J==="self"?[]:te,{shouldDirty:!0}),e[24]=s,e[25]=T):T=e[25];const k=T;let R;e[26]!==k||e[27]!==g?(R=J=>{m(J),k(J,g)},e[26]=k,e[27]=g,e[28]=R):R=e[28];const P=R;let D;e[29]!==k||e[30]!==g?(D=J=>{const te=g.includes(J)?g.filter(se=>se!==J):[...g,J];x(te),k("selected",te)},e[29]=k,e[30]=g,e[31]=D):D=e[31],b=D,L="flex flex-col gap-3";let I;e[32]!==i?(I=i("virtualMcp.subAgentsSection.title"),e[32]=i,e[33]=I):I=e[33];let M;e[34]!==I?(M=r.jsx("h2",{className:"text-sm font-medium text-foreground",children:I}),e[34]=I,e[35]=M):M=e[35];let O;e[36]!==f||e[37]!==i?(O=f==="all"&&r.jsx("p",{className:"text-sm text-muted-foreground",children:i("virtualMcp.subAgentsSection.canDelegateToAnyAgent")}),e[36]=f,e[37]=i,e[38]=O):O=e[38];let $;e[39]!==f||e[40]!==i?($=f==="self"&&r.jsx("p",{className:"text-sm text-muted-foreground",children:i("virtualMcp.subAgentsSection.canOnlyDelegateToItself")}),e[39]=f,e[40]=i,e[41]=$):$=e[41];let B;e[42]!==M||e[43]!==O||e[44]!==$?(B=r.jsxs("div",{className:"flex flex-col gap-1",children:[M,O,$]}),e[42]=M,e[43]=O,e[44]=$,e[45]=B):B=e[45];const z=f==="selected"&&E.length>0&&r.jsxs(le,{variant:"outline",size:"sm",onClick:()=>c(!0),children:[r.jsx(kt,{size:14}),i("virtualMcp.subAgentsSection.addSubAgent")]});let K;e[46]!==P?(K=J=>P(J),e[46]=P,e[47]=K):K=e[47];let G;e[48]===Symbol.for("react.memo_cache_sentinel")?(G=r.jsx(Jt,{size:"sm",className:"w-auto",children:r.jsx(as,{})}),e[48]=G):G=e[48];let Y;e[49]!==i?(Y=i("virtualMcp.subAgentsSection.anyAgent"),e[49]=i,e[50]=Y):Y=e[50];let U;e[51]!==Y?(U=r.jsx(vt,{value:"all",children:Y}),e[51]=Y,e[52]=U):U=e[52];let W;e[53]!==i?(W=i("virtualMcp.subAgentsSection.specificAgents"),e[53]=i,e[54]=W):W=e[54];let H;e[55]!==W?(H=r.jsx(vt,{value:"selected",children:W}),e[55]=W,e[56]=H):H=e[56];let X;e[57]!==i?(X=i("virtualMcp.subAgentsSection.onlyItself"),e[57]=i,e[58]=X):X=e[58];let q;e[59]!==X?(q=r.jsx(vt,{value:"self",children:X}),e[59]=X,e[60]=q):q=e[60];let Z;e[61]!==U||e[62]!==H||e[63]!==q?(Z=r.jsxs(Xt,{align:"end",children:[U,H,q]}),e[61]=U,e[62]=H,e[63]=q,e[64]=Z):Z=e[64];let Q;e[65]!==f||e[66]!==K||e[67]!==Z?(Q=r.jsxs(Qt,{value:f,onValueChange:K,children:[G,Z]}),e[65]=f,e[66]=K,e[67]=Z,e[68]=Q):Q=e[68];let ee;e[69]!==z||e[70]!==Q?(ee=r.jsxs("div",{className:"flex items-center gap-2",children:[z,Q]}),e[69]=z,e[70]=Q,e[71]=ee):ee=e[71],e[72]!==B||e[73]!==ee?(w=r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[B,ee]}),e[72]=B,e[73]=ee,e[74]=w):w=e[74],y="flex flex-col gap-2",_=f==="selected"&&(E.length>0?E.map(J=>r.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 rounded-xl border bg-background",children:[r.jsx(an,{icon:J.icon,name:J.title,size:"sm",className:"shrink-0"}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("p",{className:"text-sm font-medium truncate",children:J.title}),J.description&&r.jsx("p",{className:"text-xs text-muted-foreground truncate",children:J.description})]}),r.jsx(le,{variant:"ghost",size:"icon",onClick:()=>b(J.id),children:r.jsx(Pn,{size:16})})]},J.id)):r.jsxs("button",{type:"button",onClick:()=>c(!0),className:"flex items-center gap-3 px-3 py-2.5 rounded-lg border border-dashed border-border hover:bg-accent/50 transition-colors w-full text-left cursor-pointer",children:[r.jsx("div",{className:"flex items-center justify-center size-8 rounded-md text-muted-foreground/75 border border-dashed border-border shrink-0",children:r.jsx(kt,{size:16})}),r.jsx("span",{className:"text-sm text-muted-foreground",children:i("virtualMcp.subAgentsSection.emptyStateMessage")})]})),e[6]=a,e[7]=n,e[8]=s,e[9]=f,e[10]=o,e[11]=g,e[12]=i,e[13]=v,e[14]=b,e[15]=y,e[16]=_,e[17]=L,e[18]=w}else v=e[13],b=e[14],y=e[15],_=e[16],L=e[17],w=e[18];let j;e[75]!==y||e[76]!==_?(j=r.jsx("div",{className:y,children:_}),e[75]=y,e[76]=_,e[77]=j):j=e[77];let S;e[78]!==v||e[79]!==b||e[80]!==l||e[81]!==g?(S=r.jsx(Ow,{open:l,onOpenChange:c,candidates:v,selectedIds:g,onToggle:b}),e[78]=v,e[79]=b,e[80]=l,e[81]=g,e[82]=S):S=e[82];let C;return e[83]!==L||e[84]!==w||e[85]!==j||e[86]!==S?(C=r.jsxs("section",{className:L,children:[w,j,S]}),e[83]=L,e[84]=w,e[85]=j,e[86]=S,e[87]=C):C=e[87],C}function Ow(t){const e=F.c(39),{open:s,onOpenChange:n,candidates:i,selectedIds:o,onToggle:a}=t,l=re(),[c,d]=A.useState("");let h,u,f,m,p,g,x,v,b;if(e[0]!==i||e[1]!==n||e[2]!==a||e[3]!==s||e[4]!==c||e[5]!==o||e[6]!==l){const w=c.toLowerCase(),j=i.filter(N=>N.title.toLowerCase().includes(w)||N.description?.toLowerCase().includes(w));u=ts,v=s,b=n,h=es,p="max-w-md";let S;e[16]!==l?(S=l("virtualMcp.subAgentsSection.title"),e[16]=l,e[17]=S):S=e[17],e[18]!==S?(g=r.jsx(ms,{children:r.jsx(ps,{children:S})}),e[18]=S,e[19]=g):g=e[19];let C;e[20]!==l?(C=l("virtualMcp.subAgentsSection.searchPlaceholder"),e[20]=l,e[21]=C):C=e[21],e[22]!==c||e[23]!==C?(x=r.jsx(h9,{value:c,onChange:d,placeholder:C,className:"w-full"}),e[22]=c,e[23]=C,e[24]=x):x=e[24],f="flex flex-col gap-1 max-h-80 overflow-y-auto",m=j.length===0?r.jsx("p",{className:"text-sm text-muted-foreground px-1 py-4 text-center",children:l("virtualMcp.subAgentsSection.noAgentsFound")}):j.map(N=>r.jsxs("button",{type:"button",onClick:()=>a(N.id),className:"flex items-center gap-3 px-2 py-2 rounded-lg hover:bg-accent/50 transition-colors cursor-pointer w-full text-left",children:[r.jsx(Ar,{checked:o.includes(N.id),className:"pointer-events-none",tabIndex:-1}),r.jsx(an,{icon:N.icon,name:N.title,size:"sm",className:"shrink-0"}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("p",{className:"text-sm font-medium truncate",children:N.title}),N.description&&r.jsx("p",{className:"text-xs text-muted-foreground truncate",children:N.description})]})]},N.id)),e[0]=i,e[1]=n,e[2]=a,e[3]=s,e[4]=c,e[5]=o,e[6]=l,e[7]=h,e[8]=u,e[9]=f,e[10]=m,e[11]=p,e[12]=g,e[13]=x,e[14]=v,e[15]=b}else h=e[7],u=e[8],f=e[9],m=e[10],p=e[11],g=e[12],x=e[13],v=e[14],b=e[15];let y;e[25]!==f||e[26]!==m?(y=r.jsx("div",{className:f,children:m}),e[25]=f,e[26]=m,e[27]=y):y=e[27];let _;e[28]!==h||e[29]!==p||e[30]!==g||e[31]!==x||e[32]!==y?(_=r.jsxs(h,{className:p,children:[g,x,y]}),e[28]=h,e[29]=p,e[30]=g,e[31]=x,e[32]=y,e[33]=_):_=e[33];let L;return e[34]!==u||e[35]!==v||e[36]!==b||e[37]!==_?(L=r.jsx(u,{open:v,onOpenChange:b,children:_}),e[34]=u,e[35]=v,e[36]=b,e[37]=_,e[38]=L):L=e[38],L}function lo(){const t=F.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx("div",{className:"flex items-center justify-center h-32",children:r.jsx(et,{className:"animate-spin text-muted-foreground",size:24})}),t[0]=e):e=t[0],e}function ya(t,e){return({error:s})=>s?.message?.includes("Method not found")||s?.code===-32601?r.jsx("div",{className:"flex-1 overflow-auto px-4 py-3 space-y-1",children:r.jsx("div",{className:"flex items-center justify-center h-32 text-sm text-muted-foreground",children:t})}):r.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center h-full p-6 text-center space-y-4",children:[r.jsx("div",{className:"bg-destructive/10 p-3 rounded-full",children:r.jsx(Sr,{className:"h-6 w-6 text-destructive"})}),r.jsxs("div",{className:"space-y-2",children:[r.jsx("h3",{className:"text-lg font-medium",children:e("virtualMcp.dependencySelectionDialog.somethingWentWrong")}),r.jsx("p",{className:"text-sm text-muted-foreground max-w-xs mx-auto",children:s?.message?s.message.length>200?`${s.message.slice(0,200)}...`:s.message:e("virtualMcp.dependencySelectionDialog.unexpectedError")})]})]})}function Kp(t){const e=F.c(23),{item:s,isSelected:n,onToggle:i,disabled:o}=t,a=o?"cursor-not-allowed opacity-50":"cursor-pointer",l=n?"bg-accent/25":"hover:bg-muted/50";let c;e[0]!==a||e[1]!==l?(c=ie("flex items-start gap-3 p-4 rounded-lg transition-colors",a,l),e[0]=a,e[1]=l,e[2]=c):c=e[2];let d;e[3]!==s.name?(d=r.jsx("p",{className:"text-sm font-medium leading-none truncate",children:s.name}),e[3]=s.name,e[4]=d):d=e[4];let h;e[5]!==s.tags?(h=s.tags&&r.jsx("span",{className:"shrink-0",children:s.tags}),e[5]=s.tags,e[6]=h):h=e[6];let u;e[7]!==d||e[8]!==h?(u=r.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[d,h]}),e[7]=d,e[8]=h,e[9]=u):u=e[9];let f;e[10]!==s.description?(f=s.description&&r.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2",children:s.description}),e[10]=s.description,e[11]=f):f=e[11];let m;e[12]!==u||e[13]!==f?(m=r.jsxs("div",{className:"flex-1 min-w-0 space-y-2",children:[u,f]}),e[12]=u,e[13]=f,e[14]=m):m=e[14];let p;e[15]!==o||e[16]!==n||e[17]!==i?(p=r.jsx(Ar,{checked:n,onCheckedChange:i,disabled:o,className:"mt-0.5"}),e[15]=o,e[16]=n,e[17]=i,e[18]=p):p=e[18];let g;return e[19]!==c||e[20]!==m||e[21]!==p?(g=r.jsxs("label",{className:c,children:[m,p]}),e[19]=c,e[20]=m,e[21]=p,e[22]=g):g=e[22],g}function Bw(t){const e=F.c(35),{activeTab:s,onTabChange:n,showSelectAll:i,isAllSelected:o,handleSelectAll:a}=t,l=re();let c;e[0]!==l?(c=l("virtualMcp.dependencySelectionDialog.tabTools"),e[0]=l,e[1]=c):c=e[1];let d;e[2]!==c?(d={id:"tools",label:c},e[2]=c,e[3]=d):d=e[3];let h;e[4]!==l?(h=l("virtualMcp.dependencySelectionDialog.tabActive"),e[4]=l,e[5]=h):h=e[5];let u;e[6]!==h?(u={id:"active",label:h},e[6]=h,e[7]=u):u=e[7];let f;e[8]!==l?(f=l("virtualMcp.dependencySelectionDialog.tabResources"),e[8]=l,e[9]=f):f=e[9];let m;e[10]!==f?(m={id:"resources",label:f},e[10]=f,e[11]=m):m=e[11];let p;e[12]!==l?(p=l("virtualMcp.dependencySelectionDialog.tabPrompts"),e[12]=l,e[13]=p):p=e[13];let g;e[14]!==p?(g={id:"prompts",label:p},e[14]=p,e[15]=g):g=e[15];let x;e[16]!==d||e[17]!==u||e[18]!==m||e[19]!==g?(x=[d,u,m,g],e[16]=d,e[17]=u,e[18]=m,e[19]=g,e[20]=x):x=e[20];let v;e[21]!==n?(v=L=>n(L),e[21]=n,e[22]=v):v=e[22];let b;e[23]!==s||e[24]!==v||e[25]!==x?(b=r.jsx(g2,{tabs:x,activeTab:s,onTabChange:v}),e[23]=s,e[24]=v,e[25]=x,e[26]=b):b=e[26];let y;e[27]!==a||e[28]!==o||e[29]!==i||e[30]!==l?(y=i&&r.jsx("button",{type:"button",onClick:a,className:"text-xs text-muted-foreground hover:text-foreground transition-colors",children:l(o?"virtualMcp.dependencySelectionDialog.deselectAll":"virtualMcp.dependencySelectionDialog.selectAll")}),e[27]=a,e[28]=o,e[29]=i,e[30]=l,e[31]=y):y=e[31];let _;return e[32]!==b||e[33]!==y?(_=r.jsxs("div",{className:"flex items-center justify-between px-6 py-3 border-t border-border shrink-0",children:[b,y]}),e[32]=b,e[33]=y,e[34]=_):_=e[34],_}function $9(t){const e=F.c(13),{items:s,selections:n,onToggle:i,emptyMessage:o,disabled:a}=t;let l,c,d;if(e[0]!==a||e[1]!==o||e[2]!==s||e[3]!==i||e[4]!==n){d=Symbol.for("react.early_return_sentinel");e:{const u=s.map($w);if(s.length===0){let f;e[8]!==o?(f=r.jsx("div",{className:"flex-1 overflow-auto px-4 py-3 space-y-1",children:r.jsx("div",{className:"flex items-center justify-center h-32 text-sm text-muted-foreground",children:o})}),e[8]=o,e[9]=f):f=e[9],d=f;break e}l="flex-1 overflow-auto px-4 py-3 space-y-1",c=s.map(f=>r.jsx(Kp,{item:f,isSelected:n===null||n?.includes(f.id),onToggle:()=>i(f.id,u),disabled:a},f.id))}e[0]=a,e[1]=o,e[2]=s,e[3]=i,e[4]=n,e[5]=l,e[6]=c,e[7]=d}else l=e[5],c=e[6],d=e[7];if(d!==Symbol.for("react.early_return_sentinel"))return d;let h;return e[10]!==l||e[11]!==c?(h=r.jsx("div",{className:l,children:c}),e[10]=l,e[11]=c,e[12]=h):h=e[12],h}function $w(t){return t.id}function Fw(t){const e=F.c(22),{connectionId:s,toolSelections:n,onToggleTool:i}=t,o=re(),{org:a}=Oe();let l;e[0]!==s||e[1]!==a.id||e[2]!==a.slug?(l={connectionId:s,orgId:a.id,orgSlug:a.slug},e[0]=s,e[1]=a.id,e[2]=a.slug,e[3]=l):l=e[3];const c=ht(l);let d;e[4]!==c?(d={client:c},e[4]=c,e[5]=d):d=e[5];const{data:h}=Qm(d),u=h.tools;let f,m,p;if(e[6]!==h.tools||e[7]!==i||e[8]!==o||e[9]!==n){p=Symbol.for("react.early_return_sentinel");e:{const x=u.map(Kw);let v;e[13]!==n?(v=_=>n===null||n.includes(_.name),e[13]=n,e[14]=v):v=e[14];const y=h.tools.filter(v).map(zw);if(y.length===0){let _;e[15]!==o?(_=o("virtualMcp.dependencySelectionDialog.noActiveToolsSelected"),e[15]=o,e[16]=_):_=e[16];let L;e[17]!==_?(L=r.jsx("div",{className:"flex-1 overflow-auto px-4 py-3 space-y-1",children:r.jsx("div",{className:"flex items-center justify-center h-32 text-sm text-muted-foreground",children:_})}),e[17]=_,e[18]=L):L=e[18],p=L;break e}f="flex-1 overflow-auto px-4 py-3 space-y-1",m=y.map(_=>r.jsx(Kp,{item:_,isSelected:!0,onToggle:()=>i(_.id,x)},_.id))}e[6]=h.tools,e[7]=i,e[8]=o,e[9]=n,e[10]=f,e[11]=m,e[12]=p}else f=e[10],m=e[11],p=e[12];if(p!==Symbol.for("react.early_return_sentinel"))return p;let g;return e[19]!==f||e[20]!==m?(g=r.jsx("div",{className:f,children:m}),e[19]=f,e[20]=m,e[21]=g):g=e[21],g}function zw(t){return{id:t.name,name:t.name,description:t.description,tags:r.jsx(f2,{annotations:t.annotations,_meta:t._meta})}}function Kw(t){return t.name}function Uw(t){const e=F.c(16),{connectionId:s,selections:n,onToggle:i,disabled:o}=t,{org:a}=Oe();let l;e[0]!==s||e[1]!==a.id||e[2]!==a.slug?(l={connectionId:s,orgId:a.id,orgSlug:a.slug},e[0]=s,e[1]=a.id,e[2]=a.slug,e[3]=l):l=e[3];const c=ht(l);let d;e[4]!==c?(d={client:c},e[4]=c,e[5]=d):d=e[5];const{data:h}=Qm(d);let u;e[6]!==h.tools?(u=h.tools.map(Hw),e[6]=h.tools,e[7]=u):u=e[7];const f=u,m=re();let p;e[8]!==m?(p=m("virtualMcp.dependencySelectionDialog.noToolsAvailable"),e[8]=m,e[9]=p):p=e[9];let g;return e[10]!==o||e[11]!==f||e[12]!==i||e[13]!==n||e[14]!==p?(g=r.jsx($9,{items:f,selections:n,onToggle:i,emptyMessage:p,disabled:o}),e[10]=o,e[11]=f,e[12]=i,e[13]=n,e[14]=p,e[15]=g):g=e[15],g}function Hw(t){return{id:t.name,name:t.name,description:t.description,tags:r.jsx(f2,{annotations:t.annotations,_meta:t._meta})}}function Ww(t){const e=F.c(16),{connectionId:s,selections:n,onToggle:i,disabled:o}=t,{org:a}=Oe();let l;e[0]!==s||e[1]!==a.id||e[2]!==a.slug?(l={connectionId:s,orgId:a.id,orgSlug:a.slug},e[0]=s,e[1]=a.id,e[2]=a.slug,e[3]=l):l=e[3];const c=ht(l);let d;e[4]!==c?(d={client:c},e[4]=c,e[5]=d):d=e[5];const{data:h}=Z5(d);let u;e[6]!==h.resources?(u=h.resources.map(qw),e[6]=h.resources,e[7]=u):u=e[7];const f=u,m=re();let p;e[8]!==m?(p=m("virtualMcp.dependencySelectionDialog.noResourcesAvailable"),e[8]=m,e[9]=p):p=e[9];let g;return e[10]!==o||e[11]!==f||e[12]!==i||e[13]!==n||e[14]!==p?(g=r.jsx($9,{items:f,selections:n,onToggle:i,emptyMessage:p,disabled:o}),e[10]=o,e[11]=f,e[12]=i,e[13]=n,e[14]=p,e[15]=g):g=e[15],g}function qw(t){return{id:t.name||t.uri,name:t.name||t.uri,description:t.description}}function Gw(t){const e=F.c(16),{connectionId:s,selections:n,onToggle:i,disabled:o}=t,{org:a}=Oe();let l;e[0]!==s||e[1]!==a.id||e[2]!==a.slug?(l={connectionId:s,orgId:a.id,orgSlug:a.slug},e[0]=s,e[1]=a.id,e[2]=a.slug,e[3]=l):l=e[3];const c=ht(l);let d;e[4]!==c?(d={client:c},e[4]=c,e[5]=d):d=e[5];const{data:h}=ym(d);let u;e[6]!==h.prompts?(u=h.prompts.map(Yw),e[6]=h.prompts,e[7]=u):u=e[7];const f=u,m=re();let p;e[8]!==m?(p=m("virtualMcp.dependencySelectionDialog.noPromptsAvailable"),e[8]=m,e[9]=p):p=e[9];let g;return e[10]!==o||e[11]!==f||e[12]!==i||e[13]!==n||e[14]!==p?(g=r.jsx($9,{items:f,selections:n,onToggle:i,emptyMessage:p,disabled:o}),e[10]=o,e[11]=f,e[12]=i,e[13]=n,e[14]=p,e[15]=g):g=e[15],g}function Yw(t){return{id:t.name,name:t.name,description:t.description}}function Jw(t){const e=F.c(58),{currentConnection:s,activeTab:n,selectedId:i,formData:o,toggleTool:a,toggleResource:l,togglePrompt:c,toggleAllTools:d,toggleAllResources:h,toggleAllPrompts:u,onTabChange:f}=t,m=re(),p=o[i],g=n==="tools"?p?.tools===null:n==="resources"?p?.resources===null:n==="prompts"?p?.prompts===null:!1,x=n!=="active";let v;e[0]!==n||e[1]!==i||e[2]!==u||e[3]!==h||e[4]!==d?(v=()=>{n==="tools"?d(i):n==="resources"?h(i):n==="prompts"&&u(i)},e[0]=n,e[1]=i,e[2]=u,e[3]=h,e[4]=d,e[5]=v):v=e[5];const b=v;let y;e[6]!==s.icon||e[7]!==s.title?(y=r.jsx(an,{icon:s.icon,name:s.title,size:"sm",className:"shrink-0"}),e[6]=s.icon,e[7]=s.title,e[8]=y):y=e[8];let _;e[9]!==s.title?(_=r.jsx("h2",{className:"text-base font-semibold truncate",children:s.title}),e[9]=s.title,e[10]=_):_=e[10];let L;e[11]!==s.description?(L=s.description&&r.jsx("p",{className:"text-xs text-muted-foreground truncate",children:s.description}),e[11]=s.description,e[12]=L):L=e[12];let w;e[13]!==_||e[14]!==L?(w=r.jsxs("div",{className:"flex-1 min-w-0",children:[_,L]}),e[13]=_,e[14]=L,e[15]=w):w=e[15];let j;e[16]!==y||e[17]!==w?(j=r.jsx("div",{className:"px-6 pt-5 pb-4 shrink-0",children:r.jsxs("div",{className:"flex items-center gap-3",children:[y,w]})}),e[16]=y,e[17]=w,e[18]=j):j=e[18];let S;e[19]!==n||e[20]!==b||e[21]!==g||e[22]!==f||e[23]!==x?(S=r.jsx(Bw,{activeTab:n,onTabChange:f,showSelectAll:x,isAllSelected:g,handleSelectAll:b}),e[19]=n,e[20]=b,e[21]=g,e[22]=f,e[23]=x,e[24]=S):S=e[24];let C;e[25]!==n||e[26]!==o||e[27]!==i||e[28]!==m||e[29]!==a?(C=n==="active"&&r.jsx(ys,{fallback:ya("Tools not supported by this server",m),children:r.jsx(A.Suspense,{fallback:r.jsx(lo,{}),children:r.jsx(Fw,{connectionId:i,toolSelections:o[i]?o[i].tools:[],onToggleTool:(R,P)=>a(i,R,P)})})}),e[25]=n,e[26]=o,e[27]=i,e[28]=m,e[29]=a,e[30]=C):C=e[30];let N;e[31]!==n||e[32]!==o||e[33]!==i||e[34]!==m||e[35]!==a?(N=n==="tools"&&r.jsx(ys,{fallback:ya("Tools not supported by this server",m),children:r.jsx(A.Suspense,{fallback:r.jsx(lo,{}),children:r.jsx(Uw,{connectionId:i,selections:o[i]?o[i].tools:[],onToggle:(R,P)=>a(i,R,P)})})}),e[31]=n,e[32]=o,e[33]=i,e[34]=m,e[35]=a,e[36]=N):N=e[36];let V;e[37]!==n||e[38]!==o||e[39]!==i||e[40]!==m||e[41]!==l?(V=n==="resources"&&r.jsx(ys,{fallback:ya("Resources not supported by this server",m),children:r.jsx(A.Suspense,{fallback:r.jsx(lo,{}),children:r.jsx(Ww,{connectionId:i,selections:o[i]?o[i].resources:[],onToggle:(R,P)=>l(i,R,P)})})}),e[37]=n,e[38]=o,e[39]=i,e[40]=m,e[41]=l,e[42]=V):V=e[42];let E;e[43]!==n||e[44]!==o||e[45]!==i||e[46]!==m||e[47]!==c?(E=n==="prompts"&&r.jsx(ys,{fallback:ya("Prompts not supported by this server",m),children:r.jsx(A.Suspense,{fallback:r.jsx(lo,{}),children:r.jsx(Gw,{connectionId:i,selections:o[i]?o[i].prompts:[],onToggle:(R,P)=>c(i,R,P)})})}),e[43]=n,e[44]=o,e[45]=i,e[46]=m,e[47]=c,e[48]=E):E=e[48];let T;e[49]!==V||e[50]!==E||e[51]!==C||e[52]!==N?(T=r.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[C,N,V,E]}),e[49]=V,e[50]=E,e[51]=C,e[52]=N,e[53]=T):T=e[53];let k;return e[54]!==T||e[55]!==j||e[56]!==S?(k=r.jsxs(r.Fragment,{children:[j,S,T]}),e[54]=T,e[55]=j,e[56]=S,e[57]=k):k=e[57],k}function Xw(t){const e=F.c(7),{onClose:s}=t,n=re();let i;e[0]!==s?(i=()=>s(!1),e[0]=s,e[1]=i):i=e[1];let o;e[2]!==n?(o=n("virtualMcp.dependencySelectionDialog.done"),e[2]=n,e[3]=o):o=e[3];let a;return e[4]!==i||e[5]!==o?(a=r.jsx(Mi,{className:"px-6 py-4 border-t border-border shrink-0",children:r.jsx(le,{variant:"outline",onClick:i,children:o})}),e[4]=i,e[5]=o,e[6]=a):a=e[6],a}function Qw(t){const e=F.c(23),{connectionId:s,onAuthenticate:n,children:i}=t,o=re();let a;e[0]!==s?(a={connectionId:s},e[0]=s,e[1]=a):a=e[1];const l=m2(a);if(l.supportsOAuth&&!l.isAuthenticated){let h;e[2]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx("div",{className:"flex items-center justify-center size-12 rounded-full bg-muted",children:r.jsx($v,{size:22,className:"text-muted-foreground"})}),e[2]=h):h=e[2];let u;e[3]!==o?(u=o("virtualMcp.dependencySelectionDialog.authorizationRequired"),e[3]=o,e[4]=u):u=e[4];let f;e[5]!==u?(f=r.jsx("p",{className:"text-sm font-medium",children:u}),e[5]=u,e[6]=f):f=e[6];let m;e[7]!==o?(m=o("virtualMcp.dependencySelectionDialog.authorizationDescription"),e[7]=o,e[8]=m):m=e[8];let p;e[9]!==m?(p=r.jsx("p",{className:"text-xs text-muted-foreground max-w-xs",children:m}),e[9]=m,e[10]=p):p=e[10];let g;e[11]!==f||e[12]!==p?(g=r.jsxs("div",{className:"space-y-1",children:[f,p]}),e[11]=f,e[12]=p,e[13]=g):g=e[13];let x;e[14]!==s||e[15]!==n||e[16]!==o?(x=n&&r.jsx(le,{variant:"outline",size:"sm",onClick:()=>n(s),children:o("virtualMcp.dependencySelectionDialog.authorize")}),e[14]=s,e[15]=n,e[16]=o,e[17]=x):x=e[17];let v;return e[18]!==g||e[19]!==x?(v=r.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-4 p-8 text-center",children:[h,g,x]}),e[18]=g,e[19]=x,e[20]=v):v=e[20],v}let d;return e[21]!==i?(d=r.jsx(r.Fragment,{children:i}),e[21]=i,e[22]=d):d=e[22],d}function Zw(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 Ph(t){return Object.entries(t).map(([e,s])=>({connection_id:e,selected_tools:s.tools,selected_resources:s.resources,selected_prompts:s.prompts}))}function Rh(t,e,s,n){const i=t[e]??{tools:null,resources:null,prompts:null};return{...t,[e]:{...i,[s]:n}}}function ej(t,e){return e.type==="SET_ACTIVE_TAB"?{...t,activeTab:e.payload}:t}function tj(t){const e=F.c(49),{open:s,onOpenChange:n,selectedId:i,form:o,connections:a,onAuthenticate:l}=t;let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c={activeTab:"tools"},e[0]=c):c=e[0];const[d,h]=A.useReducer(ej,c),u=c9(i??"");let f;e[1]!==a?(f=a??[],e[1]=a,e[2]=f):f=e[2];let m;e[3]!==f?(m=Zw(f),e[3]=f,e[4]=m):m=e[4];const p=m;let g;e[5]!==o||e[6]!==p?(g=(B,z,K,G)=>{const Y=p[B]?.[z];let U;Y===null?U=G.filter(W=>W!==K):Y?.includes(K)?U=Y.filter(W=>W!==K):(U=[...Y??[],K],U.length===G.length&&(U=null)),o.setValue("connections",Ph(Rh(p,B,z,U)),{shouldDirty:!0,shouldTouch:!0})},e[5]=o,e[6]=p,e[7]=g):g=e[7];const x=g;let v;e[8]!==o||e[9]!==p?(v=(B,z)=>{const G=p[B]?.[z]===null?[]:null;o.setValue("connections",Ph(Rh(p,B,z,G)),{shouldDirty:!0,shouldTouch:!0})},e[8]=o,e[9]=p,e[10]=v):v=e[10];const b=v;let y;e[11]!==x?(y=(B,z,K)=>x(B,"tools",z,K),e[11]=x,e[12]=y):y=e[12];const _=y;let L;e[13]!==x?(L=(B,z,K)=>x(B,"resources",z,K),e[13]=x,e[14]=L):L=e[14];const w=L;let j;e[15]!==x?(j=(B,z,K)=>x(B,"prompts",z,K),e[15]=x,e[16]=j):j=e[16];const S=j;let C;e[17]!==b?(C=B=>b(B,"tools"),e[17]=b,e[18]=C):C=e[18];const N=C;let V;e[19]!==b?(V=B=>b(B,"resources"),e[19]=b,e[20]=V):V=e[20];const E=V;let T;e[21]!==b?(T=B=>b(B,"prompts"),e[21]=b,e[22]=T):T=e[22];const k=T;if(!i||!u)return null;let R;e[23]===Symbol.for("react.memo_cache_sentinel")?(R=r.jsx(lo,{}),e[23]=R):R=e[23];let P;e[24]===Symbol.for("react.memo_cache_sentinel")?(P=B=>h({type:"SET_ACTIVE_TAB",payload:B}),e[24]=P):P=e[24];let D;e[25]!==u||e[26]!==d.activeTab||e[27]!==p||e[28]!==i||e[29]!==k||e[30]!==E||e[31]!==N||e[32]!==S||e[33]!==w||e[34]!==_?(D=r.jsx(Jw,{currentConnection:u,activeTab:d.activeTab,selectedId:i,formData:p,toggleTool:_,toggleResource:w,togglePrompt:S,toggleAllTools:N,toggleAllResources:E,toggleAllPrompts:k,onTabChange:P},i),e[25]=u,e[26]=d.activeTab,e[27]=p,e[28]=i,e[29]=k,e[30]=E,e[31]=N,e[32]=S,e[33]=w,e[34]=_,e[35]=D):D=e[35];let I;e[36]!==l||e[37]!==i||e[38]!==D?(I=r.jsx(A.Suspense,{fallback:R,children:r.jsx(Qw,{connectionId:i,onAuthenticate:l,children:D})}),e[36]=l,e[37]=i,e[38]=D,e[39]=I):I=e[39];let M;e[40]!==n?(M=r.jsx(Xw,{onClose:n}),e[40]=n,e[41]=M):M=e[41];let O;e[42]!==I||e[43]!==M?(O=r.jsxs(es,{className:"sm:max-w-2xl h-[75vh] max-h-[75vh] flex flex-col p-0 gap-0 overflow-hidden w-[95vw]",children:[I,M]}),e[42]=I,e[43]=M,e[44]=O):O=e[44];let $;return e[45]!==n||e[46]!==s||e[47]!==O?($=r.jsx(ts,{open:s,onOpenChange:n,children:O}),e[45]=n,e[46]=s,e[47]=O,e[48]=$):$=e[48],$}const Dh="__new_instance__";function sj(t){const e=F.c(23),{connection_id:s,usedConnectionIds:n,onOpenSettings:i,onRemove:o,onAuthenticate:a,onSwitchInstance:l,onNewInstance:c}=t,d=c9(s),{org:h}=Oe();if(!d)return null;let u;e[0]!==d?(u=Vb(d),e[0]=d,e[1]=u):u=e[1];const f=u;let m;e[2]!==s?(m=r.jsx(rj,{connection_id:s}),e[2]=s,e[3]=m):m=e[3];let p;e[4]!==d.app_name||e[5]!==d.connection_type||e[6]!==d.description||e[7]!==d.icon||e[8]!==d.status||e[9]!==d.title||e[10]!==s||e[11]!==a||e[12]!==c||e[13]!==i||e[14]!==o||e[15]!==l||e[16]!==h.slug||e[17]!==f||e[18]!==n?(p=r.jsx(ij,{connection_id:s,connectionTitle:d.title,connectionDescription:d.description,connectionIcon:d.icon,connectionType:d.connection_type,connectionStatus:d.status,slug:f,orgSlug:h.slug,appName:d.app_name,usedConnectionIds:n,onOpenSettings:i,onRemove:o,onAuthenticate:a,onSwitchInstance:l,onNewInstance:c}),e[4]=d.app_name,e[5]=d.connection_type,e[6]=d.description,e[7]=d.icon,e[8]=d.status,e[9]=d.title,e[10]=s,e[11]=a,e[12]=c,e[13]=i,e[14]=o,e[15]=l,e[16]=h.slug,e[17]=f,e[18]=n,e[19]=p):p=e[19];let g;return e[20]!==m||e[21]!==p?(g=r.jsx(A.Suspense,{fallback:m,children:p}),e[20]=m,e[21]=p,e[22]=g):g=e[22],g}function nj(t){const e=F.c(24),{appName:s,connectionId:n,usedConnectionIds:i,onSwitchInstance:o,onNewInstance:a}=t,l=re();let c;e[0]!==s?(c={filters:[{column:"app_name",value:s}]},e[0]=s,e[1]=c):c=e[1];const d=Rn(c);if(d.length<=1)return null;let h;e[2]!==n||e[3]!==a||e[4]!==o?(h=x=>{x===Dh?a?.():o(n,x)},e[2]=n,e[3]=a,e[4]=o,e[5]=h):h=e[5];let u;e[6]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx(Jt,{size:"sm",className:"w-auto text-xs gap-1 px-2 shadow-none",children:r.jsx(as,{})}),e[6]=u):u=e[6];let f;if(e[7]!==n||e[8]!==d||e[9]!==i){let x;e[11]!==n||e[12]!==i?(x=v=>r.jsx(vt,{value:v.id,className:"text-xs",disabled:v.id!==n&&i.has(v.id),children:v.title},v.id),e[11]=n,e[12]=i,e[13]=x):x=e[13],f=d.map(x),e[7]=n,e[8]=d,e[9]=i,e[10]=f}else f=e[10];let m;e[14]!==a||e[15]!==l?(m=a&&r.jsxs(vt,{value:Dh,className:"text-xs text-muted-foreground",children:["+ ",l("virtualMcp.connectionItem.newInstance")]}),e[14]=a,e[15]=l,e[16]=m):m=e[16];let p;e[17]!==f||e[18]!==m?(p=r.jsxs(Xt,{children:[f,m]}),e[17]=f,e[18]=m,e[19]=p):p=e[19];let g;return e[20]!==n||e[21]!==h||e[22]!==p?(g=r.jsxs(Qt,{value:n,onValueChange:h,children:[u,p]}),e[20]=n,e[21]=h,e[22]=p,e[23]=g):g=e[23],g}function ij({connection_id:t,connectionTitle:e,connectionDescription:s,connectionIcon:n,connectionType:i,connectionStatus:o,slug:a,orgSlug:l,appName:c,usedConnectionIds:d,onOpenSettings:h,onRemove:u,onAuthenticate:f,onSwitchInstance:m,onNewInstance:p}){const g=m2({connectionId:t}),x=u2(),b=!(i==="VIRTUAL")&&g.supportsOAuth&&!g.isAuthenticated,y=o!=="active",_=re(),L=async w=>{try{await x.update.mutateAsync({id:t,data:{status:w}}),ge.success(_(w==="active"?"virtualMcp.connectionItem.connectionEnabled":"virtualMcp.connectionItem.connectionDisabled"))}catch{ge.error(_("virtualMcp.connectionItem.failedToUpdateConnection"))}};return r.jsxs("div",{className:ie("rounded-xl border overflow-hidden transition-colors",b||y?"border-destructive/50 bg-destructive/5":"border-border bg-card"),children:[r.jsxs(om,{to:"/$org/settings/connections/$appSlug",params:{org:l,appSlug:a},className:"flex items-center gap-3 px-4 py-3 cursor-pointer hover:bg-muted/50 transition-colors",children:[r.jsx(an,{icon:n,name:e,size:"sm",className:"shrink-0"}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("p",{className:"text-sm font-medium truncate",children:e}),b?r.jsx("span",{className:"text-xs text-destructive font-medium",children:_("virtualMcp.connectionItem.needsAuthorization")}):y?r.jsx("span",{className:"text-xs text-destructive font-medium",children:_(o==="error"?"virtualMcp.connectionItem.disabledError":"virtualMcp.connectionItem.disabled")}):s&&r.jsx("p",{className:"text-xs text-muted-foreground truncate",children:s})]}),b?r.jsx(le,{variant:"outline",size:"sm",className:"h-7 text-xs shrink-0",onClick:w=>{w.preventDefault(),w.stopPropagation(),f(t)},children:_("virtualMcp.connectionItem.authorize")}):y?r.jsxs(le,{variant:"outline",size:"sm",className:"h-7 text-xs gap-1.5 shrink-0",onClick:w=>{w.preventDefault(),w.stopPropagation(),L("active")},children:[r.jsx(Fv,{size:13}),_("virtualMcp.connectionItem.enable")]}):r.jsxs(Ue,{delayDuration:0,children:[r.jsx(ze,{asChild:!0,children:r.jsx("span",{className:"inline-flex items-center justify-center rounded-md h-7 w-7 hover:bg-accent text-muted-foreground shrink-0 transition-colors",children:r.jsx(h6,{size:16})})}),r.jsx(Ke,{side:"bottom",children:_("virtualMcp.connectionItem.connectionSettings")})]})]}),r.jsxs("div",{className:"flex items-center gap-3 px-4 py-2 border-t border-border bg-muted/25",children:[c&&r.jsx(nj,{appName:c,connectionId:t,usedConnectionIds:d,onSwitchInstance:m,onNewInstance:p}),r.jsxs("div",{className:"flex items-center gap-0.5 ml-auto",children:[r.jsxs(Ue,{delayDuration:0,children:[r.jsx(ze,{asChild:!0,children:r.jsx(le,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:h,"aria-label":_("virtualMcp.connectionItem.configureResources"),children:r.jsx(Em,{size:13})})}),r.jsx(Ke,{side:"bottom",children:_("virtualMcp.connectionItem.configureResources")})]}),!y&&r.jsxs(Ue,{delayDuration:0,children:[r.jsx(ze,{asChild:!0,children:r.jsx(le,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground",onClick:()=>L("inactive"),"aria-label":_("virtualMcp.connectionItem.disableConnection"),children:r.jsx(zv,{size:13})})}),r.jsx(Ke,{side:"bottom",children:_("virtualMcp.connectionItem.disable")})]}),r.jsxs(Ue,{delayDuration:0,children:[r.jsx(ze,{asChild:!0,children:r.jsx(le,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-destructive",onClick:u,"aria-label":_("virtualMcp.connectionItem.removeConnection"),children:r.jsx(Pn,{size:13})})}),r.jsx(Ke,{side:"bottom",children:_("virtualMcp.connectionItem.remove")})]})]})]})]})}function rj(t){const e=F.c(17),{connection_id:s}=t,n=c9(s);if(!n){let u;return e[0]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx(Up,{}),e[0]=u):u=e[0],u}let i;e[1]!==n.icon||e[2]!==n.title?(i=r.jsx(an,{icon:n.icon,name:n.title,size:"sm",className:"shrink-0"}),e[1]=n.icon,e[2]=n.title,e[3]=i):i=e[3];let o;e[4]!==n.title?(o=r.jsx("p",{className:"text-sm font-medium truncate",children:n.title}),e[4]=n.title,e[5]=o):o=e[5];let a;e[6]!==n.description?(a=n.description&&r.jsx("p",{className:"text-xs text-muted-foreground truncate",children:n.description}),e[6]=n.description,e[7]=a):a=e[7];let l;e[8]!==o||e[9]!==a?(l=r.jsxs("div",{className:"flex-1 min-w-0",children:[o,a]}),e[8]=o,e[9]=a,e[10]=l):l=e[10];let c;e[11]!==i||e[12]!==l?(c=r.jsxs("div",{className:"flex items-center gap-3 px-4 py-3",children:[i,l]}),e[11]=i,e[12]=l,e[13]=c):c=e[13];let d;e[14]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx("div",{className:"flex items-center px-4 py-2 border-t border-border bg-muted/25",children:r.jsx("div",{className:"h-5 w-20 rounded bg-muted animate-pulse"})}),e[14]=d):d=e[14];let h;return e[15]!==c?(h=r.jsxs("div",{className:"rounded-xl border border-border overflow-hidden",children:[c,d]}),e[15]=c,e[16]=h):h=e[16],h}function Up(){const t=F.c(3);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx("div",{className:"size-8 rounded-md bg-muted animate-pulse shrink-0"}),t[0]=e):e=t[0];let s;t[1]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsxs("div",{className:"flex items-center gap-3 px-4 py-3",children:[e,r.jsxs("div",{className:"flex-1 space-y-1.5",children:[r.jsx("div",{className:"h-4 w-32 rounded bg-muted animate-pulse"}),r.jsx("div",{className:"h-3 w-48 rounded bg-muted animate-pulse"})]})]}),t[1]=s):s=t[1];let n;return t[2]===Symbol.for("react.memo_cache_sentinel")?(n=r.jsxs("div",{className:"rounded-xl border border-border overflow-hidden",children:[s,r.jsx("div",{className:"flex items-center px-4 py-2 border-t border-border bg-muted/25",children:r.jsx("div",{className:"h-5 w-20 rounded bg-muted animate-pulse"})})]}),t[2]=n):n=t[2],n}function oj(t){const e=F.c(5),{value:s}=t;let n;if(e[0]!==s){n=Symbol.for("react.early_return_sentinel");e:{const o=ql(s);if(o.type==="icon"){const a=Oi(o.name);if(a){let l;e[2]!==a?(l=r.jsx(a,{size:16,className:"text-muted-foreground"}),e[2]=a,e[3]=l):l=e[3],n=l;break e}}}e[0]=s,e[1]=n}else n=e[1];if(n!==Symbol.for("react.early_return_sentinel"))return n;let i;return e[4]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(Nb,{size:16,className:"text-muted-foreground"}),e[4]=i):i=e[4],i}function aj(t){const e=F.c(71),{value:s,onChange:n,className:i,disabled:o}=t,a=re(),[l,c]=A.useState(!1),[d,h]=A.useState("");let u;e[0]!==s?(u=ql(s),e[0]=s,e[1]=u):u=e[1];const f=u,m=f.type==="icon"?f.name:null;let p,g,x,v,b,y,_,L,w,j,S,C,N,V,E;if(e[2]!==i||e[3]!==m||e[4]!==o||e[5]!==n||e[6]!==l||e[7]!==d||e[8]!==a||e[9]!==s){const M=Y0();v=Om(M,d),x=As,b=o?!1:l,y=c;const O=o?"cursor-default opacity-50":"cursor-pointer hover:bg-accent";let $;e[25]!==i||e[26]!==O?($=ie("size-7 shrink-0 rounded-md transition-colors flex items-center justify-center",O,i),e[25]=i,e[26]=O,e[27]=$):$=e[27];let B;e[28]!==s?(B=r.jsx(oj,{value:s}),e[28]=s,e[29]=B):B=e[29],e[30]!==o||e[31]!==$||e[32]!==B?(_=r.jsx(Es,{asChild:!0,children:r.jsx("button",{type:"button",disabled:o,"aria-label":"Change icon",className:$,children:B})}),e[30]=o,e[31]=$,e[32]=B,e[33]=_):_=e[33],g=Ps,N="start",V="w-64 p-0",E=lj,S="flex flex-col";let z;e[34]===Symbol.for("react.memo_cache_sentinel")?(z=r.jsx(Io,{size:14,className:"absolute left-2 top-1/2 -translate-y-1/2 text-muted-foreground pointer-events-none"}),e[34]=z):z=e[34];let K;e[35]===Symbol.for("react.memo_cache_sentinel")?(K=U=>h(U.target.value),e[35]=K):K=e[35];let G;e[36]!==a?(G=a("common.simpleIconPicker.filterPlaceholder"),e[36]=a,e[37]=G):G=e[37],e[38]!==d||e[39]!==G?(C=r.jsx("div",{className:"px-2 py-2",children:r.jsxs("div",{className:"relative",children:[z,r.jsx(rt,{value:d,onChange:K,placeholder:G,className:"h-7 text-xs pl-7"})]})}),e[38]=d,e[39]=G,e[40]=C):C=e[40],p=ii,j="h-48",L="grid grid-cols-8 gap-0.5 px-2 pb-2";let Y;e[41]!==m||e[42]!==n?(Y=U=>{const W=Oi(U);return W?r.jsx("button",{type:"button",onClick:()=>{n(`icon://${U}`),c(!1)},className:ie("h-7 w-7 flex items-center justify-center rounded-md transition-colors cursor-pointer",m===U?"bg-accent text-foreground":"text-muted-foreground hover:bg-accent hover:text-foreground"),title:Vd(U),"aria-label":Vd(U),children:r.jsx(W,{size:16})},U):null},e[41]=m,e[42]=n,e[43]=Y):Y=e[43],w=v.map(Y),e[2]=i,e[3]=m,e[4]=o,e[5]=n,e[6]=l,e[7]=d,e[8]=a,e[9]=s,e[10]=p,e[11]=g,e[12]=x,e[13]=v,e[14]=b,e[15]=y,e[16]=_,e[17]=L,e[18]=w,e[19]=j,e[20]=S,e[21]=C,e[22]=N,e[23]=V,e[24]=E}else p=e[10],g=e[11],x=e[12],v=e[13],b=e[14],y=e[15],_=e[16],L=e[17],w=e[18],j=e[19],S=e[20],C=e[21],N=e[22],V=e[23],E=e[24];let T;e[44]!==L||e[45]!==w?(T=r.jsx("div",{className:L,children:w}),e[44]=L,e[45]=w,e[46]=T):T=e[46];let k;e[47]!==v.length||e[48]!==a?(k=v.length===0&&r.jsx("div",{className:"flex items-center justify-center py-6 text-xs text-muted-foreground",children:a("common.simpleIconPicker.noIconsFound")}),e[47]=v.length,e[48]=a,e[49]=k):k=e[49];let R;e[50]!==p||e[51]!==T||e[52]!==k||e[53]!==j?(R=r.jsxs(p,{className:j,children:[T,k]}),e[50]=p,e[51]=T,e[52]=k,e[53]=j,e[54]=R):R=e[54];let P;e[55]!==R||e[56]!==S||e[57]!==C?(P=r.jsxs("div",{className:S,children:[C,R]}),e[55]=R,e[56]=S,e[57]=C,e[58]=P):P=e[58];let D;e[59]!==g||e[60]!==P||e[61]!==N||e[62]!==V||e[63]!==E?(D=r.jsx(g,{align:N,className:V,onOpenAutoFocus:E,children:P}),e[59]=g,e[60]=P,e[61]=N,e[62]=V,e[63]=E,e[64]=D):D=e[64];let I;return e[65]!==x||e[66]!==b||e[67]!==y||e[68]!==_||e[69]!==D?(I=r.jsxs(x,{open:b,onOpenChange:y,children:[_,D]}),e[65]=x,e[66]=b,e[67]=y,e[68]=_,e[69]=D,e[70]=I):I=e[70],I}function lj(t){return t.preventDefault()}function cj({virtualMcpId:t,form:e,flushAndSave:s}){const n=re(),i=$s(),o=gs(t),a=(o?.connections??[]).map(T=>T.connection_id).sort(),{data:l}=Mt({queryKey:at.projectConnectionDetails(t,a),enabled:a.length>0,queryFn:async()=>await Promise.all(a.map(async k=>{try{const{item:R}=await i.call("COLLECTION_CONNECTIONS_GET",{id:k}),P=(R?.tools??[]).flatMap(D=>{const I=Zl(D._meta);return I?[{name:D.name,title:D.title,description:D.description,resourceUri:I}]:[]});return{fetchOk:!0,id:k,title:R?.title??k,icon:R?.icon??null,uiTools:P}}catch{return{fetchOk:!1,id:k,title:k,icon:null,uiTools:[]}}}))}),c=(l??[]).filter(T=>T.uiTools.length>0),d=new Set(nb),h=e.watch("metadata.ui.pinnedViews")??[],u=e.watch("metadata.ui.layout")??null,f=u?.defaultMainView??null,m=u?.chatDefaultOpen??!1,p=!f||f.type==="chat"?"chat":f.type==="instructions"||f.type==="connections"||f.type==="layout"?"settings":d.has(f.type)?f.type:`${f.type}:${f.id??""}:${f.toolName??""}`,g=T=>{const[k,R,P]=T.split(":");return k?k==="chat"?{type:k}:d.has(k)?{type:k}:k==="ext-apps"&&R?{type:"ext-apps",id:R,toolName:P||void 0}:null:null},x=T=>{e.setValue("metadata.ui.pinnedViews",T,{shouldDirty:!0})},v=T=>{e.setValue("metadata.ui.layout",{...u,...T},{shouldDirty:!0})},b=A.useRef(!1);if(l&&l.length>0&&!b.current){b.current=!0;const T=new Set((l??[]).filter(P=>P.fetchOk).map(P=>P.id)),k=new Set(c.flatMap(P=>P.uiTools.map(D=>`${P.id}:${D.name}`))),R=h.filter(P=>!T.has(P.connectionId)||k.has(`${P.connectionId}:${P.toolName}`));R.length!==h.length&&(x(R),f?.type==="ext-apps"&&!R.some(P=>P.connectionId===f.id&&P.toolName===f.toolName)&&v({defaultMainView:{type:"chat"}}))}const y=(T,k)=>{if(h.some(P=>P.connectionId===T&&P.toolName===k)){const P=h.filter(I=>!(I.connectionId===T&&I.toolName===k));x(P);const D=`ext-apps:${T}:${k}`;p===D&&v({defaultMainView:{type:"chat"}})}else{const P=c.find(D=>D.id===T)?.uiTools.find(D=>D.name===k)?.title;x([...h,{connectionId:T,toolName:k,label:P??Ci(k),icon:null}])}s()},_=(T,k,R)=>{x(h.map(P=>P.connectionId===T&&P.toolName===k?{...P,label:R}:P))},L=()=>{s()},w=(T,k,R)=>{x(h.map(P=>P.connectionId===T&&P.toolName===k?{...P,icon:R}:P)),s()},j=T=>{v({defaultMainView:g(T)}),s()},S=a.length===0,C=l&&c.length===0,N=sn(o?.metadata),V=[{value:"chat",label:n("virtualMcp.layoutTabContent.chat")},{value:"settings",label:n("virtualMcp.layoutTabContent.settings")},{value:"automations",label:n("virtualMcp.layoutTabContent.automations")}];N&&V.push({value:"preview",label:n("virtualMcp.layoutTabContent.preview")});for(const T of h)V.push({value:`ext-apps:${T.connectionId}:${T.toolName}`,label:T.label||T.toolName});const E=c.length>0||S||C;return r.jsxs("div",{className:"flex flex-col gap-3",children:[r.jsx("div",{className:"flex items-center justify-between gap-3",children:r.jsx("h2",{className:"text-sm font-medium text-foreground",children:n("virtualMcp.layoutTabContent.layout")})}),r.jsxs(pl,{className:"p-6 gap-5",children:[r.jsxs(Do,{className:"p-0 space-y-5",children:[r.jsxs("div",{className:"flex items-center justify-between gap-4",children:[r.jsxs("div",{className:"space-y-0.5 min-w-0",children:[r.jsx(lt,{className:"font-normal text-foreground",children:n("virtualMcp.layoutTabContent.mainView")}),r.jsx("p",{className:"text-xs text-muted-foreground",children:n("virtualMcp.layoutTabContent.mainViewDescription")})]}),r.jsxs(Qt,{value:p,onValueChange:j,children:[r.jsx(Jt,{className:"w-44 h-8 text-sm capitalize shrink-0",children:r.jsx(as,{})}),r.jsx(Xt,{children:V.map(T=>r.jsx(vt,{value:T.value,className:"capitalize",children:T.label},T.value))})]})]}),r.jsxs("div",{className:"flex items-center justify-between gap-4",children:[r.jsxs("div",{className:"space-y-0.5 min-w-0",children:[r.jsx(lt,{className:"font-normal text-foreground",children:n("virtualMcp.layoutTabContent.showChat")}),r.jsx("p",{className:"text-xs text-muted-foreground",children:n("virtualMcp.layoutTabContent.showChatDescription")})]}),r.jsxs(Ue,{delayDuration:0,children:[r.jsx(ze,{asChild:!0,children:r.jsx("span",{className:"shrink-0",children:r.jsx(xr,{checked:p==="chat"?!0:m,disabled:p==="chat",onCheckedChange:T=>{v({chatDefaultOpen:T}),s()}})})}),p==="chat"&&r.jsx(Ke,{side:"top",children:n("virtualMcp.layoutTabContent.chatAlwaysShown")})]})]})]}),E&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"border-t border-border -mx-6"}),r.jsxs(Do,{className:"p-0 space-y-3",children:[r.jsx("div",{className:"flex items-center justify-between gap-4",children:r.jsxs("div",{className:"space-y-0.5 min-w-0",children:[r.jsx(lt,{className:"font-normal text-foreground",children:n("virtualMcp.layoutTabContent.pinnedViews")}),r.jsx("p",{className:"text-xs text-muted-foreground",children:n("virtualMcp.layoutTabContent.pinnedViewsDescription")})]})}),S&&r.jsx("p",{className:"text-xs text-muted-foreground",children:n("virtualMcp.layoutTabContent.addConnectionMessage")}),C&&!S&&r.jsx("p",{className:"text-xs text-muted-foreground",children:n("virtualMcp.layoutTabContent.noInteractiveTools")}),c.length>0&&r.jsx("div",{className:"space-y-4 pt-1",children:c.map((T,k)=>r.jsxs("div",{children:[k>0&&r.jsx("div",{className:"border-t border-border -mx-6 mb-4"}),r.jsxs("div",{className:"flex items-center gap-2 mb-2.5",children:[r.jsx(an,{icon:T.icon,name:T.title,size:"xs",className:"shrink-0"}),r.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:T.title})]}),r.jsx("div",{className:"space-y-1.5",children:T.uiTools.map(R=>{const P=h.some(I=>I.connectionId===T.id&&I.toolName===R.name),D=h.find(I=>I.connectionId===T.id&&I.toolName===R.name);return r.jsxs("div",{className:ie("flex items-center justify-between gap-3 px-3 py-2 rounded-lg border transition-colors",P?"bg-accent/40 border-border":"bg-transparent border-border"),children:[r.jsxs("div",{className:"min-w-0 flex-1 flex items-center gap-2",children:[r.jsx(aj,{value:D?.icon??null,onChange:I=>w(T.id,R.name,I),disabled:!P}),r.jsx(rt,{value:P&&D?D.label:R.title??Ci(R.name),onChange:I=>_(T.id,R.name,I.target.value),onBlur:L,className:"h-7 text-sm w-40",disabled:!P,readOnly:!P})]}),r.jsx(xr,{checked:P,onCheckedChange:()=>y(T.id,R.name)})]},R.name)})})]},T.id))})]})]})]})]})}const qc={tools:null,resources:null,prompts:null},dj=ex.pick({status:!0,title:!0,description:!0,icon:!0,metadata:!0,connections:!0});function uj(t){const s=new TextEncoder().encode(t),n=Array.from(s,i=>String.fromCharCode(i)).join("");return btoa(n)}function hj(t){const e=F.c(15),{url:s,agentId:n}=t,i=re(),[o,a]=A.useState(!1);let l;e[0]!==n||e[1]!==i||e[2]!==s?(l=async()=>{Me("agent_connect_action",{agent_id:n,action:"copy_url"}),await navigator.clipboard.writeText(s),a(!0),ge.success(i("virtualMcp.virtualMcpShareModal.agentUrlCopied")),setTimeout(()=>a(!1),2e3)},e[0]=n,e[1]=i,e[2]=s,e[3]=l):l=e[3];const c=l;let d;e[4]!==o?(d=o?r.jsx(zt,{size:20,className:"text-success"}):r.jsx(Os,{size:20}),e[4]=o,e[5]=d):d=e[5];let h;e[6]!==o||e[7]!==i?(h=i(o?"virtualMcp.virtualMcpShareModal.copied":"virtualMcp.virtualMcpShareModal.copyUrl"),e[6]=o,e[7]=i,e[8]=h):h=e[8];let u;e[9]!==h?(u=r.jsx("span",{className:"text-xs font-medium",children:h}),e[9]=h,e[10]=u):u=e[10];let f;return e[11]!==c||e[12]!==d||e[13]!==u?(f=r.jsxs(le,{type:"button",variant:"outline",onClick:c,className:"h-auto py-3 px-4 flex flex-col items-center gap-2",children:[d,u]}),e[11]=c,e[12]=d,e[13]=u,e[14]=f):f=e[14],f}function fj(t){const e=F.c(13),{url:s,serverName:n,agentId:i}=t,o=re();let a;e[0]!==i||e[1]!==n||e[2]!==o||e[3]!==s?(a=()=>{Me("agent_connect_action",{agent_id:i,action:"install_cursor"});const f=x2(n),p=uj(JSON.stringify({type:"http",url:s,headers:{"x-mesh-client":"Cursor"}},null,2)),g=`cursor://anysphere.cursor-deeplink/mcp/install?name=${encodeURIComponent(f)}&config=${encodeURIComponent(p)}`;window.open(g,"_blank"),ge.success(o("virtualMcp.virtualMcpShareModal.openingCursor"))},e[0]=i,e[1]=n,e[2]=o,e[3]=s,e[4]=a):a=e[4];const l=a;let c;e[5]===Symbol.for("react.memo_cache_sentinel")?(c=r.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%)"}}),e[5]=c):c=e[5];let d;e[6]!==o?(d=o("virtualMcp.virtualMcpShareModal.installOnCursor"),e[6]=o,e[7]=d):d=e[7];let h;e[8]!==d?(h=r.jsx("span",{className:"text-xs font-medium",children:d}),e[8]=d,e[9]=h):h=e[9];let u;return e[10]!==l||e[11]!==h?(u=r.jsxs(le,{type:"button",variant:"outline",onClick:l,className:"h-auto py-3 px-4 flex flex-col items-center gap-2",children:[c,h]}),e[10]=l,e[11]=h,e[12]=u):u=e[12],u}function mj(t){const e=F.c(16),{url:s,serverName:n,agentId:i}=t,o=re(),[a,l]=A.useState(!1);let c;e[0]!==i||e[1]!==n||e[2]!==o||e[3]!==s?(c=async()=>{Me("agent_connect_action",{agent_id:i,action:"install_claude_code"});const p=x2(n),x=JSON.stringify({type:"http",url:s,headers:{"x-mesh-client":"Claude Code"}},null,2),v=`claude mcp add-json "${p}" '${x.replace(/'/g,"'\\''")}' --scope user`;await navigator.clipboard.writeText(v),l(!0),ge.success(o("virtualMcp.virtualMcpShareModal.claudeCodeCommandCopied")),setTimeout(()=>l(!1),2e3)},e[0]=i,e[1]=n,e[2]=o,e[3]=s,e[4]=c):c=e[4];const d=c;let h;e[5]!==a?(h=a?r.jsx(zt,{size:20,className:"text-success"}):r.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[5]=a,e[6]=h):h=e[6];let u;e[7]!==a||e[8]!==o?(u=o(a?"virtualMcp.virtualMcpShareModal.copied":"virtualMcp.virtualMcpShareModal.installOnClaudeCode"),e[7]=a,e[8]=o,e[9]=u):u=e[9];let f;e[10]!==u?(f=r.jsx("span",{className:"text-xs font-medium",children:u}),e[10]=u,e[11]=f):f=e[11];let m;return e[12]!==d||e[13]!==h||e[14]!==f?(m=r.jsxs(le,{type:"button",variant:"outline",onClick:d,className:"h-auto py-3 px-4 flex flex-col items-center gap-2",children:[h,f]}),e[12]=d,e[13]=h,e[14]=f,e[15]=m):m=e[15],m}function pj({virtualMcp:t}){const e=re(),s=$s(),[n,i]=A.useState(null),[o,a]=A.useState(!1),[l,c]=A.useState(!1),d=t.id,h=t.title||`agent-${d.slice(0,8)}`,u=n?`bunx @decocms/typegen@latest --mcp ${d} --key ${n} --output client.ts`:`bunx @decocms/typegen@latest --mcp ${d} --key <api-key> --output client.ts`,f=async()=>{a(!0);try{const{key:p}=await s.call("API_KEY_CREATE",{name:`typegen-${h}`,permissions:{[d]:["*"]}});if(!p)throw new Error("No key in response");i(p),Me("agent_typegen_key_generated",{agent_id:d})}catch{Me("agent_typegen_key_failed",{agent_id:d}),ge.error(e("virtualMcp.virtualMcpShareModal.failedGenerateApiKey"))}finally{a(!1)}},m=async()=>{Me("agent_connect_action",{agent_id:d,action:"typegen_copy_command",has_api_key:!!n}),await navigator.clipboard.writeText(u),c(!0),ge.success(e("virtualMcp.virtualMcpShareModal.commandCopied")),setTimeout(()=>c(!1),2e3)};return r.jsxs("div",{className:"flex min-w-0 flex-col gap-3",children:[r.jsxs("div",{className:"flex items-start justify-between gap-3",children:[r.jsxs("div",{className:"flex flex-col gap-0.5",children:[r.jsx("h4",{className:"text-sm font-medium text-foreground",children:e("virtualMcp.virtualMcpShareModal.generateTypedClient")}),r.jsx("p",{className:"text-xs text-muted-foreground",children:e("virtualMcp.virtualMcpShareModal.generateTypedClientDescription")})]}),!n&&r.jsxs(le,{type:"button",variant:"outline",size:"sm",className:"shrink-0 gap-1.5",onClick:f,disabled:o,children:[o?r.jsx(et,{size:14,className:"animate-spin"}):r.jsx(f9,{size:14}),r.jsx("span",{children:e(o?"virtualMcp.virtualMcpShareModal.generating":"virtualMcp.virtualMcpShareModal.generateApiKey")})]})]}),n&&r.jsx("p",{className:"rounded-md border border-warning/20 bg-warning/10 px-3 py-2 text-xs text-warning",children:e("virtualMcp.virtualMcpShareModal.storeKeySecurely")}),r.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:e("virtualMcp.virtualMcpShareModal.generateClientLabel")}),r.jsx("div",{className:"rounded-md border border-input bg-muted/50 px-3 py-2.5",children:r.jsxs("div",{className:"flex items-start gap-2",children:[r.jsx("code",{className:"min-w-0 flex-1 break-all font-mono text-xs text-muted-foreground",children:u}),r.jsx(le,{type:"button",variant:"ghost",size:"icon",className:"size-6 shrink-0",onClick:m,children:l?r.jsx(zt,{size:12,className:"text-success"}):r.jsx(Os,{size:12})})]})}),r.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:e("virtualMcp.virtualMcpShareModal.runtimeVariables")}),r.jsx(gj,{apiKey:n,agentId:d})]})}function gj(t){const e=F.c(21),{apiKey:s,agentId:n}=t,[i,o]=A.useState(!1),a=window.location.origin,l=s?`MESH_API_KEY=${s}`:"MESH_API_KEY=<api-key>",c=`MESH_BASE_URL=${a}`,d=`${l}
|
|
9
|
-
${c}`;let h;e[0]!==n||e[1]!==s||e[2]!==d?(h=async()=>{Me("agent_connect_action",{agent_id:n,action:"typegen_copy_env",has_api_key:!!s}),await navigator.clipboard.writeText(d),o(!0),setTimeout(()=>o(!1),2e3)},e[0]=n,e[1]=s,e[2]=d,e[3]=h):h=e[3];const u=h,f=!s;let m;e[4]!==f?(m=ie({"opacity-50":f}),e[4]=f,e[5]=m):m=e[5];let p;e[6]!==l||e[7]!==m?(p=r.jsx("span",{className:m,children:l}),e[6]=l,e[7]=m,e[8]=p):p=e[8];let g,x;e[9]===Symbol.for("react.memo_cache_sentinel")?(g=r.jsx("br",{}),x=r.jsx("span",{children:c}),e[9]=g,e[10]=x):(g=e[9],x=e[10]);let v;e[11]!==p?(v=r.jsxs("code",{className:"min-w-0 flex-1 font-mono text-xs text-muted-foreground",children:[p,g,x]}),e[11]=p,e[12]=v):v=e[12];let b;e[13]!==i?(b=i?r.jsx(zt,{size:12,className:"text-success"}):r.jsx(Os,{size:12}),e[13]=i,e[14]=b):b=e[14];let y;e[15]!==u||e[16]!==b?(y=r.jsx(le,{type:"button",variant:"ghost",size:"icon",className:"size-6 shrink-0",onClick:u,children:b}),e[15]=u,e[16]=b,e[17]=y):y=e[17];let _;return e[18]!==v||e[19]!==y?(_=r.jsx("div",{className:"rounded-md border border-input bg-muted/50 px-3 py-2.5",children:r.jsxs("div",{className:"flex items-start gap-2",children:[v,y]})}),e[18]=v,e[19]=y,e[20]=_):_=e[20],_}function xj(t){const e=F.c(3),{virtualMcp:s}=t;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=r.jsx("div",{className:"h-20 animate-pulse rounded-md bg-muted"}),e[0]=n):n=e[0];let i;return e[1]!==s?(i=r.jsx(A.Suspense,{fallback:n,children:r.jsx(pj,{virtualMcp:s})}),e[1]=s,e[2]=i):i=e[2],i}const vj={self:["COLLECTION_THREADS_CREATE","COLLECTION_THREADS_GET","COLLECTION_THREAD_MESSAGES_LIST","COLLECTION_THREADS_LIST"]},bj=3600*24*90;function _j({virtualMcp:t}){const e=re(),s=$s(),{org:n}=Oe(),[i,o]=A.useState(null),[a,l]=A.useState(!1),[c,d]=A.useState(!1),h=t.id,u=t.title||`agent-${h.slice(0,8)}`,m=[`MESH_BASE_URL=${window.location.origin}`,`MESH_ORG=${n.slug}`,`MESH_AGENT_ID=${h}`,`MESH_API_KEY=${i??"<api-key>"}`].join(`
|
|
10
|
-
`),p=async()=>{l(!0);try{const{key:x}=await s.call("API_KEY_CREATE",{name:`chat-bridge-${u}`,permissions:vj,expiresIn:bj});if(!x)throw new Error("No key in response");o(x),Me("agent_chat_bridge_key_generated",{agent_id:h})}catch{Me("agent_chat_bridge_key_failed",{agent_id:h}),ge.error(e("virtualMcp.virtualMcpShareModal.failedCreateApiKey"))}finally{l(!1)}},g=async()=>{Me("agent_connect_action",{agent_id:h,action:"chat_bridge_copy_env",has_api_key:!!i}),await navigator.clipboard.writeText(m),d(!0),ge.success(e("virtualMcp.virtualMcpShareModal.connectionDetailsCopied")),setTimeout(()=>d(!1),2e3)};return r.jsxs("div",{className:"flex min-w-0 flex-col gap-3",children:[r.jsxs("div",{className:"flex items-start justify-between gap-3",children:[r.jsxs("div",{className:"flex flex-col gap-0.5",children:[r.jsx("h4",{className:"text-sm font-medium text-foreground",children:e("virtualMcp.virtualMcpShareModal.callFromYourApp")}),r.jsx("p",{className:"text-xs text-muted-foreground",children:e("virtualMcp.virtualMcpShareModal.callFromYourAppDescription")})]}),!i&&r.jsxs(le,{type:"button",variant:"outline",size:"sm",className:"shrink-0 gap-1.5",onClick:p,disabled:a,children:[a?r.jsx(et,{size:14,className:"animate-spin"}):r.jsx(f9,{size:14}),r.jsx("span",{children:e(a?"virtualMcp.virtualMcpShareModal.creating":"virtualMcp.virtualMcpShareModal.createApiKey")})]})]}),i&&r.jsx("p",{className:"rounded-md border border-warning/20 bg-warning/10 px-3 py-2 text-xs text-warning",children:e("virtualMcp.virtualMcpShareModal.storeKeySecurely")}),r.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:e("virtualMcp.virtualMcpShareModal.connectionDetails")}),r.jsx("div",{className:"rounded-md border border-input bg-muted/50 px-3 py-2.5",children:r.jsxs("div",{className:"flex items-start gap-2",children:[r.jsx("code",{className:"min-w-0 flex-1 whitespace-pre-wrap break-all font-mono text-xs text-muted-foreground",children:m}),r.jsx(le,{type:"button",variant:"ghost",size:"icon",className:"size-6 shrink-0",onClick:g,children:c?r.jsx(zt,{size:12,className:"text-success"}):r.jsx(Os,{size:12})})]})})]})}function yj(t){const e=F.c(3),{virtualMcp:s}=t;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=r.jsx("div",{className:"h-20 animate-pulse rounded-md bg-muted"}),e[0]=n):n=e[0];let i;return e[1]!==s?(i=r.jsx(A.Suspense,{fallback:n,children:r.jsx(_j,{virtualMcp:s})}),e[1]=s,e[2]=i):i=e[2],i}function Lj(t){const e=F.c(49),{open:s,onOpenChange:n,virtualMcp:i}=t,o=re(),{org:a}=Oe(),l=`/api/${a.slug}/mcp/virtual-mcp/${i.id}`;let c;e[0]!==l?(c=new URL(l,window.location.origin),e[0]=l,e[1]=c):c=e[1];const d=c;let h;e[2]!==i.id||e[3]!==i.title?(h=i.title||`agent-${i.id?.slice(0,8)??"default"}`,e[2]=i.id,e[3]=i.title,e[4]=h):h=e[4];const u=h,f=Cr();let m;e[5]!==i.id||e[6]!==d.href?(m=r.jsx(hj,{url:d.href,agentId:i.id}),e[5]=i.id,e[6]=d.href,e[7]=m):m=e[7];let p,g;e[8]!==u||e[9]!==i.id||e[10]!==d.href?(p=r.jsx(fj,{url:d.href,serverName:u,agentId:i.id}),g=r.jsx(mj,{url:d.href,serverName:u,agentId:i.id}),e[8]=u,e[9]=i.id,e[10]=d.href,e[11]=p,e[12]=g):(p=e[11],g=e[12]);let x;e[13]!==m||e[14]!==p||e[15]!==g?(x=r.jsx("div",{className:"flex flex-col gap-3 pt-2",children:r.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[m,p,g]})}),e[13]=m,e[14]=p,e[15]=g,e[16]=x):x=e[16];let v;e[17]===Symbol.for("react.memo_cache_sentinel")?(v=r.jsx("div",{className:"border-t border-border"}),e[17]=v):v=e[17];let b;e[18]!==i?(b=r.jsx(xj,{virtualMcp:i}),e[18]=i,e[19]=b):b=e[19];let y;e[20]===Symbol.for("react.memo_cache_sentinel")?(y=r.jsx("div",{className:"border-t border-border"}),e[20]=y):y=e[20];let _;e[21]!==i?(_=r.jsx(yj,{virtualMcp:i}),e[21]=i,e[22]=_):_=e[22];let L;e[23]!==_||e[24]!==x||e[25]!==b?(L=r.jsxs("div",{className:"flex flex-col gap-6",children:[x,v,b,y,_]}),e[23]=_,e[24]=x,e[25]=b,e[26]=L):L=e[26];const w=L;if(f){let V;e[27]!==o?(V=o("virtualMcp.virtualMcpShareModal.connect"),e[27]=o,e[28]=V):V=e[28];let E;e[29]!==V?(E=r.jsx(xm,{className:"mt-4 mb-4 text-base font-semibold",children:V}),e[29]=V,e[30]=E):E=e[30];let T;e[31]!==w||e[32]!==E?(T=r.jsx(vm,{children:r.jsxs("div",{className:"flex-1 overflow-y-auto px-4 pb-6 [touch-action:pan-y]",children:[E,w]})}),e[31]=w,e[32]=E,e[33]=T):T=e[33];let k;return e[34]!==n||e[35]!==s||e[36]!==T?(k=r.jsx(bm,{open:s,onOpenChange:n,children:T}),e[34]=n,e[35]=s,e[36]=T,e[37]=k):k=e[37],k}let j;e[38]!==o?(j=o("virtualMcp.virtualMcpShareModal.connect"),e[38]=o,e[39]=j):j=e[39];let S;e[40]!==j?(S=r.jsx(ms,{children:r.jsx(ps,{children:j})}),e[40]=j,e[41]=S):S=e[41];let C;e[42]!==w||e[43]!==S?(C=r.jsxs(es,{className:"max-h-[80vh] overflow-y-auto sm:max-w-2xl",children:[S,w]}),e[42]=w,e[43]=S,e[44]=C):C=e[44];let N;return e[45]!==n||e[46]!==s||e[47]!==C?(N=r.jsx(ts,{open:s,onOpenChange:n,children:C}),e[45]=n,e[46]=s,e[47]=C,e[48]=N):N=e[48],N}function Sj(t){const e=F.c(50),{virtualMcp:s}=t,n=re(),i=Zo(),o=H0(),[a,l]=A.useState(!1);let c,d,h,u,f,m,p,g,x;if(e[0]!==o||e[1]!==i||e[2]!==n||e[3]!==s.id||e[4]!==s.metadata){x=Symbol.for("react.early_return_sentinel");e:{const j=r9(i);if(el(s.id)||sn(s.metadata)||j.has(s.id)){x=null;break e}let S;e[14]!==i||e[15]!==s.id?(S=(i??[]).find(I=>I.metadata?.liveAgentId===s.id)??null,e[14]=i,e[15]=s.id,e[16]=S):S=e[16];const C=S,N=C?.id??null;let V;e[17]!==o.update?(V=(I,M)=>o.update.mutateAsync({id:I,data:{metadata:{liveAgentId:M}}}).catch(jj),e[17]=o.update,e[18]=V):V=e[18];const E=V;let T;e[19]!==E||e[20]!==s.id?(T=I=>{E(I,s.id)},e[19]=E,e[20]=s.id,e[21]=T):T=e[21],h=T;let k;e[22]!==N||e[23]!==E?(k=()=>{N&&E(N,null)},e[22]=N,e[23]=E,e[24]=k):k=e[24];const R=k,P=(i??[]).filter(I=>I.id!==s.id&&sn(I.metadata)&&!j.has(I.id));p="flex flex-col gap-3";let D;e[25]!==n?(D=n("devAgent.devAgentSetup.title"),e[25]=n,e[26]=D):D=e[26],e[27]!==D?(g=r.jsx("h2",{className:"text-sm font-medium text-foreground",children:D}),e[27]=D,e[28]=g):g=e[28],d=pl,m="p-6 gap-4",c=Do,u="p-0 space-y-4",f=N?r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[r.jsxs("div",{className:"flex flex-col gap-0.5 min-w-0",children:[r.jsx("span",{className:"text-sm text-foreground truncate",children:C?C.title:N}),r.jsx("span",{className:"text-xs text-muted-foreground",children:n("devAgent.devAgentSetup.linkedDescription")})]}),r.jsx(le,{variant:"outline",size:"sm",className:"shrink-0",onClick:R,children:n("devAgent.devAgentSetup.unlinkButton")})]}):r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"text-xs text-muted-foreground",children:n("devAgent.devAgentSetup.linkDescription")}),r.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[r.jsxs(le,{variant:"outline",size:"sm",className:"gap-2",onClick:()=>l(!0),children:[r.jsx(Mo,{className:"size-4"}),n("devAgent.devAgentSetup.importButton")]}),P.length>0?r.jsxs(Qt,{onValueChange:h,children:[r.jsx(Jt,{size:"sm",className:"w-56",children:r.jsx(as,{placeholder:n("devAgent.devAgentSetup.selectPlaceholder")})}),r.jsx(Xt,{children:P.map(wj)})]}):null]})]})}e[0]=o,e[1]=i,e[2]=n,e[3]=s.id,e[4]=s.metadata,e[5]=c,e[6]=d,e[7]=h,e[8]=u,e[9]=f,e[10]=m,e[11]=p,e[12]=g,e[13]=x}else c=e[5],d=e[6],h=e[7],u=e[8],f=e[9],m=e[10],p=e[11],g=e[12],x=e[13];if(x!==Symbol.for("react.early_return_sentinel"))return x;let v;e[29]!==c||e[30]!==u||e[31]!==f?(v=r.jsx(c,{className:u,children:f}),e[29]=c,e[30]=u,e[31]=f,e[32]=v):v=e[32];let b;e[33]!==d||e[34]!==m||e[35]!==v?(b=r.jsx(d,{className:m,children:v}),e[33]=d,e[34]=m,e[35]=v,e[36]=b):b=e[36];let y;e[37]!==n?(y=n("devAgent.devAgentSetup.importDialogTitle"),e[37]=n,e[38]=y):y=e[38];let _;e[39]!==h?(_=j=>{const{virtualMcpId:S}=j;l(!1),h(S)},e[39]=h,e[40]=_):_=e[40];let L;e[41]!==a||e[42]!==_||e[43]!==y?(L=r.jsx(v2,{open:a,onOpenChange:l,title:y,onImportComplete:_}),e[41]=a,e[42]=_,e[43]=y,e[44]=L):L=e[44];let w;return e[45]!==L||e[46]!==p||e[47]!==g||e[48]!==b?(w=r.jsxs("div",{className:p,children:[g,b,L]}),e[45]=L,e[46]=p,e[47]=g,e[48]=b,e[49]=w):w=e[49],w}function wj(t){return r.jsx(vt,{value:t.id,children:t.title},t.id)}function jj(){}const Cj=/^[A-Za-z_][A-Za-z0-9_]*$/;function kj(t){const e={},s=t.split(/\r?\n/);for(let n=0;n<s.length;n++){let i=(s[n]??"").trim();if(!i||i.startsWith("#"))continue;i.startsWith("export ")&&(i=i.slice(7).trim());const o=i.indexOf("=");if(o<0)throw new Error(`Line ${n+1}: missing '='`);const a=i.slice(0,o).trim();if(!Cj.test(a))throw new Error(`Line ${n+1}: invalid key "${a}"`);let l=i.slice(o+1).trim();l.length>=2&&(l.startsWith('"')&&l.endsWith('"')||l.startsWith("'")&&l.endsWith("'"))&&(l=l.slice(1,-1)),e[a]=l}return e}const Vj=/^[A-Za-z0-9_.-]+$/;function Nj(t){const e=F.c(27),{control:s,form:n,virtualMcpId:i,orgSlug:o}=t,a=re();let l;e[0]!==a?(l=a("sandbox.envVarsField.title"),e[0]=a,e[1]=l):l=e[1];let c;e[2]!==l?(c=r.jsx("div",{className:"flex items-baseline justify-between gap-2",children:r.jsx(lt,{className:"font-normal text-foreground",children:l})}),e[2]=l,e[3]=c):c=e[3];let d;e[4]!==a?(d=a("sandbox.envVarsField.description"),e[4]=a,e[5]=d):d=e[5];let h;e[6]!==d?(h=r.jsx("p",{className:"text-xs text-muted-foreground",children:d}),e[6]=d,e[7]=h):h=e[7];let u;e[8]!==s||e[9]!==n||e[10]!==o||e[11]!==i?(u=r.jsx(Tj,{control:s,form:n,virtualMcpId:i,orgSlug:o}),e[8]=s,e[9]=n,e[10]=o,e[11]=i,e[12]=u):u=e[12];let f;e[13]!==a?(f=v=>{const{error:b}=v;return r.jsx("div",{className:"rounded-md border border-destructive/40 bg-destructive/5 px-3 py-2 text-xs text-destructive",children:b?.message??a("sandbox.envVarsField.failedToLoadSecrets")})},e[13]=a,e[14]=f):f=e[14];let m;e[15]===Symbol.for("react.memo_cache_sentinel")?(m=r.jsx(Rt,{className:"h-9 w-full"}),e[15]=m):m=e[15];let p;e[16]!==s||e[17]!==n?(p=r.jsx(A.Suspense,{fallback:m,children:r.jsx(Ej,{control:s,form:n})}),e[16]=s,e[17]=n,e[18]=p):p=e[18];let g;e[19]!==f||e[20]!==p?(g=r.jsx(ys,{fallback:f,children:p}),e[19]=f,e[20]=p,e[21]=g):g=e[21];let x;return e[22]!==c||e[23]!==h||e[24]!==u||e[25]!==g?(x=r.jsxs("div",{className:"space-y-2",children:[c,h,u,g]}),e[22]=c,e[23]=h,e[24]=u,e[25]=g,e[26]=x):x=e[26],x}function Tj(t){const e=F.c(35),{control:s,form:n,virtualMcpId:i,orgSlug:o}=t,a=re(),c=Di.useSession().data?.user?.id,d="metadata.runtime.env",h="metadata.sandboxMap";let u;e[0]!==n?(u=()=>JSON.stringify(Ih(n.getValues(d))),e[0]=n,e[1]=u):u=e[1];const[f,m]=A.useState(u);let p;e[2]!==s?(p={control:s,name:d},e[2]=s,e[3]=p):p=e[3];const g=am(p);let x;e[4]!==g?(x=JSON.stringify(Ih(g)),e[4]=g,e[5]=x):x=e[5];const v=x,b=v!==f;let y;e[6]!==n?(y=n.getValues(h),e[6]=n,e[7]=y):y=e[7];const _=y;let L;e[8]!==_||e[9]!==c?(L=c?Object.keys(_?.[c]??{}):[],e[8]=_,e[9]=c,e[10]=L):L=e[10];const w=L,j=w.length>0,[S,C]=A.useState(!1);if(!b||!j)return null;let N;e[11]!==v||e[12]!==o||e[13]!==a||e[14]!==w||e[15]!==i?(N=async()=>{C(!0);const M=await Promise.allSettled(w.map(async $=>{const B=`/api/${encodeURIComponent(o)}/sandbox/${encodeURIComponent(i)}/${encodeURIComponent($)}/setup/start`,z=await fetch(B,{method:"POST"});if(!z.ok){const K=await z.text().catch(()=>z.statusText);throw new Error(K||z.statusText)}}));C(!1);const O=M.filter(Aj).length;O===0?(m(v),ge.success(w.length===1?a("sandbox.envVarsField.restartedSingle"):a("sandbox.envVarsField.restartedMultiple",{count:w.length}))):ge.error(a("sandbox.envVarsField.restartFailed",{failed:O,total:w.length}))},e[11]=v,e[12]=o,e[13]=a,e[14]=w,e[15]=i,e[16]=N):N=e[16];const V=N;let E;e[17]===Symbol.for("react.memo_cache_sentinel")?(E=r.jsx(Sr,{className:"size-3.5 shrink-0"}),e[17]=E):E=e[17];let T;e[18]!==a?(T=a("sandbox.envVarsField.sandboxRunningNotice"),e[18]=a,e[19]=T):T=e[19];let k;e[20]!==T?(k=r.jsxs("div",{className:"flex min-w-0 items-center gap-2 text-warning",children:[E,r.jsx("span",{className:"truncate",children:T})]}),e[20]=T,e[21]=k):k=e[21];let R;e[22]!==S?(R=S?r.jsx(et,{className:"size-3.5 animate-spin"}):r.jsx(dr,{className:"size-3.5"}),e[22]=S,e[23]=R):R=e[23];let P;e[24]!==S||e[25]!==a?(P=a(S?"sandbox.envVarsField.restarting":"sandbox.envVarsField.restartDev"),e[24]=S,e[25]=a,e[26]=P):P=e[26];let D;e[27]!==V||e[28]!==S||e[29]!==R||e[30]!==P?(D=r.jsxs(le,{type:"button",variant:"outline",size:"sm",onClick:V,disabled:S,className:"shrink-0",children:[R,P]}),e[27]=V,e[28]=S,e[29]=R,e[30]=P,e[31]=D):D=e[31];let I;return e[32]!==D||e[33]!==k?(I=r.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-md border border-warning/20 bg-warning/10 px-3 py-2 text-xs",children:[k,D]}),e[32]=D,e[33]=k,e[34]=I):I=e[34],I}function Aj(t){return t.status==="rejected"}function Ej(t){const e=F.c(62),{control:s,form:n}=t,i=re(),o="metadata.runtime.env";let a;e[0]!==s?(a={control:s,name:o},e[0]=s,e[1]=a):a=e[1];const l=tx(a),{fields:c,append:d,remove:h}=l;let u;e[2]!==n?(u=(O,$)=>{n.setValue(`${o}.${O}`,$,{shouldDirty:!0,shouldTouch:!0})},e[2]=n,e[3]=u):u=e[3];const f=u,m=Ab();let p;if(e[4]!==m){p=new Map;for(const O of m)p.set(O.id,O);e[4]=m,e[5]=p}else p=e[5];const[g,x]=A.useState(null);let v;e[6]!==d?(v=()=>{d({key:"",kind:"literal",value:""})},e[6]=d,e[7]=v):v=e[7];const b=v;let y;e[8]!==d||e[9]!==n||e[10]!==i?(y=async()=>{let O;try{O=await navigator.clipboard.readText()}catch{ge.error(i("sandbox.envVarsField.clipboardReadFailed"));return}if(!O.trim()){ge.error(i("sandbox.envVarsField.clipboardEmpty"));return}let $;try{$=kj(O)}catch(U){const W=U;ge.error(W.message);return}const B=Object.entries($);if(B.length===0){ge.error(i("sandbox.envVarsField.nothingToAdd"));return}const z=n.getValues(o)??[],K=new Set;for(const U of z){const W=(U.key??"").trim();W&&K.add(W)}let G=0,Y=0;for(const[U,W]of B){if(K.has(U)){Y++;continue}d({key:U,kind:"literal",value:W}),K.add(U),G++}G===0&&Y>0?ge.message(i("sandbox.envVarsField.allKeysExist",{count:Y})):ge.success(Y>0?i("sandbox.envVarsField.addedWithSkipped",{added:G,skipped:Y}):i("sandbox.envVarsField.added",{added:G}))},e[8]=d,e[9]=n,e[10]=i,e[11]=y):y=e[11];const _=y;let L;if(e[12]!==s||e[13]!==c||e[14]!==n||e[15]!==h||e[16]!==p||e[17]!==m||e[18]!==f){let O;e[20]!==s||e[21]!==n||e[22]!==h||e[23]!==p||e[24]!==m||e[25]!==f?(O=($,B)=>r.jsx("li",{className:"rounded-md border border-border bg-background",children:r.jsx(Pj,{index:B,control:s,form:n,onUpdateEntry:f,fieldPath:o,secrets:m,secretById:p,onSaveAsSecret:(z,K)=>x({kind:"save-literal",index:B,presetKey:z,presetValue:K}),onCreateNewSecret:z=>x({kind:"create-new",index:B,presetKey:z}),onRemove:()=>h(B)})},$.id),e[20]=s,e[21]=n,e[22]=h,e[23]=p,e[24]=m,e[25]=f,e[26]=O):O=e[26],L=c.map(O),e[12]=s,e[13]=c,e[14]=n,e[15]=h,e[16]=p,e[17]=m,e[18]=f,e[19]=L}else L=e[19];let w;e[27]!==L?(w=r.jsx("ul",{className:"space-y-2",children:L}),e[27]=L,e[28]=w):w=e[28];let j;e[29]===Symbol.for("react.memo_cache_sentinel")?(j=r.jsx(kt,{className:"size-3.5"}),e[29]=j):j=e[29];let S;e[30]!==i?(S=i("sandbox.envVarsField.addEnvVar"),e[30]=i,e[31]=S):S=e[31];let C;e[32]!==b||e[33]!==S?(C=r.jsxs(le,{type:"button",variant:"outline",size:"sm",onClick:b,className:"flex-1",children:[j,S]}),e[32]=b,e[33]=S,e[34]=C):C=e[34];let N;e[35]!==i?(N=i("sandbox.envVarsField.pasteDotenvAriaLabel"),e[35]=i,e[36]=N):N=e[36];let V;e[37]===Symbol.for("react.memo_cache_sentinel")?(V=r.jsx(Tm,{className:"size-3.5"}),e[37]=V):V=e[37];let E;e[38]!==i?(E=i("sandbox.envVarsField.pasteDotenv"),e[38]=i,e[39]=E):E=e[39];let T;e[40]!==_||e[41]!==N||e[42]!==E?(T=r.jsx(ze,{asChild:!0,children:r.jsxs(le,{type:"button",variant:"outline",size:"sm",onClick:_,"aria-label":N,children:[V,E]})}),e[40]=_,e[41]=N,e[42]=E,e[43]=T):T=e[43];let k;e[44]!==i?(k=i("sandbox.envVarsField.pasteDotenvTooltip"),e[44]=i,e[45]=k):k=e[45];let R;e[46]!==k?(R=r.jsx(Ke,{children:k}),e[46]=k,e[47]=R):R=e[47];let P;e[48]!==T||e[49]!==R?(P=r.jsxs(Ue,{children:[T,R]}),e[48]=T,e[49]=R,e[50]=P):P=e[50];let D;e[51]!==P||e[52]!==C?(D=r.jsxs("div",{className:"flex items-center gap-2",children:[C,P]}),e[51]=P,e[52]=C,e[53]=D):D=e[53];let I;e[54]!==g||e[55]!==n||e[56]!==f?(I=g!==null?r.jsx(Ij,{mode:g,onClose:()=>x(null),onSaved:O=>{const $=n.getValues(`${o}.${g.index}.key`)?.trim()??"";f(g.index,{key:$,kind:"secret",secretId:O}),x(null)}}):null,e[54]=g,e[55]=n,e[56]=f,e[57]=I):I=e[57];let M;return e[58]!==D||e[59]!==I||e[60]!==w?(M=r.jsxs("div",{className:"space-y-2",children:[w,D,I]}),e[58]=D,e[59]=I,e[60]=w,e[61]=M):M=e[61],M}function Pj(t){const e=F.c(77),{index:s,control:n,form:i,onUpdateEntry:o,fieldPath:a,secrets:l,secretById:c,onSaveAsSecret:d,onCreateNewSecret:h,onRemove:u}=t,f=re(),m=`${a}.${s}.key`,p=`${a}.${s}.value`,g=`${a}.${s}.secretId`,x=`${a}.${s}.kind`;let v;e[0]!==n||e[1]!==x?(v={control:n,name:x},e[0]=n,e[1]=x,e[2]=v):v=e[2];const y=am(v)==="secret"?"secret":"literal";let _;e[3]!==i||e[4]!==s||e[5]!==m||e[6]!==d||e[7]!==o||e[8]!==p?(_=W=>{const H=i.getValues(m)?.trim()??"";if(W==="literal"){o(s,{key:H,kind:"literal",value:""});return}const X=i.getValues(p)??"";if(X.length>0){d(H,X);return}o(s,{key:H,kind:"secret",secretId:""})},e[3]=i,e[4]=s,e[5]=m,e[6]=d,e[7]=o,e[8]=p,e[9]=_):_=e[9];const L=_;let w;e[10]!==s||e[11]!==f?(w=W=>{const{field:H}=W,X=(H.value??"").trim(),q=X.length>0&&!Ul.test(X);return r.jsxs("div",{className:"space-y-1",children:[r.jsx(rt,{...H,value:H.value??"",placeholder:f("sandbox.envVarsField.keyPlaceholder"),spellCheck:!1,autoComplete:"off",autoCapitalize:"off",autoCorrect:"off",className:ie("font-mono",q&&"border-destructive focus-visible:ring-destructive"),"aria-invalid":q,"aria-label":f("sandbox.envVarsField.envVarKeyLabel",{index:s+1}),onBlur:Z=>{const Q=Z.target.value.trim();H.onChange(Q),H.onBlur()}}),q?r.jsx("p",{className:"text-[11px] text-destructive",children:f("sandbox.envVarsField.invalidKeyMessage")}):null]})},e[10]=s,e[11]=f,e[12]=w):w=e[12];let j;e[13]!==n||e[14]!==m||e[15]!==w?(j=r.jsx("div",{className:"flex-1 min-w-0",children:r.jsx(_s,{control:n,name:m,render:w})}),e[13]=n,e[14]=m,e[15]=w,e[16]=j):j=e[16];let S;e[17]!==L?(S=W=>L(W),e[17]=L,e[18]=S):S=e[18];let C;e[19]===Symbol.for("react.memo_cache_sentinel")?(C=r.jsx(Jt,{className:"h-9 w-[110px]",children:r.jsx(as,{})}),e[19]=C):C=e[19];let N;e[20]===Symbol.for("react.memo_cache_sentinel")?(N=r.jsx(f9,{className:"size-3.5"}),e[20]=N):N=e[20];let V;e[21]!==f?(V=f("sandbox.envVarsField.literal"),e[21]=f,e[22]=V):V=e[22];let E;e[23]!==V?(E=r.jsx(vt,{value:"literal",children:r.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[N,V]})}),e[23]=V,e[24]=E):E=e[24];let T;e[25]===Symbol.for("react.memo_cache_sentinel")?(T=r.jsx(B0,{className:"size-3.5"}),e[25]=T):T=e[25];let k;e[26]!==f?(k=f("sandbox.envVarsField.secret"),e[26]=f,e[27]=k):k=e[27];let R;e[28]!==k?(R=r.jsx(vt,{value:"secret",children:r.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[T,k]})}),e[28]=k,e[29]=R):R=e[29];let P;e[30]!==R||e[31]!==E?(P=r.jsxs(Xt,{children:[E,R]}),e[30]=R,e[31]=E,e[32]=P):P=e[32];let D;e[33]!==y||e[34]!==P||e[35]!==S?(D=r.jsx("div",{className:"shrink-0",children:r.jsxs(Qt,{value:y,onValueChange:S,children:[C,P]})}),e[33]=y,e[34]=P,e[35]=S,e[36]=D):D=e[36];let I;e[37]!==n||e[38]!==i||e[39]!==s||e[40]!==m||e[41]!==y||e[42]!==h||e[43]!==c||e[44]!==g||e[45]!==l||e[46]!==f||e[47]!==p?(I=r.jsx("div",{className:"flex flex-[2] min-w-0 items-center gap-1",children:y==="literal"?r.jsx(_s,{control:n,name:p,render:W=>{const{field:H}=W;return r.jsx(rt,{...H,value:H.value??"",type:"password",placeholder:f("sandbox.envVarsField.valuePlaceholder"),spellCheck:!1,autoComplete:"off",className:"font-mono","aria-label":f("sandbox.envVarsField.envVarValueLabel",{index:s+1}),onBlur:X=>{H.onChange(X.target.value),H.onBlur()}})}}):r.jsxs(r.Fragment,{children:[r.jsx(_s,{control:n,name:g,render:W=>{const{field:H}=W;return r.jsxs(Qt,{value:H.value||"",onValueChange:X=>H.onChange(X),children:[r.jsx(Jt,{className:ie("h-9 w-full",!H.value&&"text-muted-foreground"),children:r.jsx(as,{placeholder:f("sandbox.envVarsField.pickSecretPlaceholder"),children:r.jsx(Dj,{field:H,secretById:c})})}),r.jsx(Xt,{children:l.length===0?r.jsx("div",{className:"px-2 py-2 text-xs text-muted-foreground",children:f("sandbox.envVarsField.noSecretsYet")}):l.map(Rj)})]})}}),r.jsxs(Ue,{children:[r.jsx(ze,{asChild:!0,children:r.jsx(le,{type:"button",variant:"ghost",size:"icon","aria-label":f("sandbox.envVarsField.createNewSecretAriaLabel"),onClick:()=>{const W=i.getValues(m)?.trim()??"";h(W)},children:r.jsx(kt,{className:"size-3.5"})})}),r.jsx(Ke,{children:f("sandbox.envVarsField.createNewSecret")})]})]})}),e[37]=n,e[38]=i,e[39]=s,e[40]=m,e[41]=y,e[42]=h,e[43]=c,e[44]=g,e[45]=l,e[46]=f,e[47]=p,e[48]=I):I=e[48];let M;e[49]!==i||e[50]!==m||e[51]!==y||e[52]!==d||e[53]!==f||e[54]!==p?(M=y==="literal"?r.jsxs(Ue,{children:[r.jsx(ze,{asChild:!0,children:r.jsx(le,{type:"button",variant:"ghost",size:"icon","aria-label":f("sandbox.envVarsField.saveAsSecretAriaLabel"),onClick:()=>{const W=i.getValues(m)?.trim()??"",H=i.getValues(p)??"";d(W,H)},children:r.jsx(J0,{className:"size-3.5"})})}),r.jsx(Ke,{children:f("sandbox.envVarsField.saveAsSecret")})]}):null,e[49]=i,e[50]=m,e[51]=y,e[52]=d,e[53]=f,e[54]=p,e[55]=M):M=e[55];let O;e[56]!==f?(O=f("sandbox.envVarsField.removeEnvVarAriaLabel"),e[56]=f,e[57]=O):O=e[57];let $;e[58]===Symbol.for("react.memo_cache_sentinel")?($=r.jsx(Ns,{className:"size-3.5"}),e[58]=$):$=e[58];let B;e[59]!==u||e[60]!==O?(B=r.jsx(ze,{asChild:!0,children:r.jsx(le,{type:"button",variant:"ghost",size:"icon","aria-label":O,onClick:u,children:$})}),e[59]=u,e[60]=O,e[61]=B):B=e[61];let z;e[62]!==f?(z=f("sandbox.envVarsField.remove"),e[62]=f,e[63]=z):z=e[63];let K;e[64]!==z?(K=r.jsx(Ke,{children:z}),e[64]=z,e[65]=K):K=e[65];let G;e[66]!==B||e[67]!==K?(G=r.jsxs(Ue,{children:[B,K]}),e[66]=B,e[67]=K,e[68]=G):G=e[68];let Y;e[69]!==M||e[70]!==G?(Y=r.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[M,G]}),e[69]=M,e[70]=G,e[71]=Y):Y=e[71];let U;return e[72]!==D||e[73]!==I||e[74]!==Y||e[75]!==j?(U=r.jsxs("div",{className:"flex flex-col gap-2 p-2 sm:flex-row sm:items-center",children:[j,D,I,Y]}),e[72]=D,e[73]=I,e[74]=Y,e[75]=j,e[76]=U):U=e[76],U}function Rj(t){return r.jsx(vt,{value:t.id,children:r.jsxs("span",{className:"inline-flex items-center gap-2",children:[r.jsx(Hp,{scope:t.scope}),r.jsx("span",{className:"font-mono",children:t.name})]})},t.id)}function Dj(t){const e=F.c(15),{field:s,secretById:n}=t,i=re(),o=s.value||"";if(!o)return null;let a;e[0]!==o||e[1]!==n?(a=n.get(o),e[0]=o,e[1]=n,e[2]=a):a=e[2];const l=a;if(!l){let u;e[3]!==o||e[4]!==i?(u=i("sandbox.envVarsField.missingSecret",{id:o}),e[3]=o,e[4]=i,e[5]=u):u=e[5];let f;return e[6]!==u?(f=r.jsx("span",{className:"text-destructive",children:u}),e[6]=u,e[7]=f):f=e[7],f}let c;e[8]!==l.scope?(c=r.jsx(Hp,{scope:l.scope}),e[8]=l.scope,e[9]=c):c=e[9];let d;e[10]!==l.name?(d=r.jsx("span",{className:"truncate font-mono",children:l.name}),e[10]=l.name,e[11]=d):d=e[11];let h;return e[12]!==c||e[13]!==d?(h=r.jsxs("span",{className:"inline-flex items-center gap-1.5 truncate",children:[c,d]}),e[12]=c,e[13]=d,e[14]=h):h=e[14],h}function Hp(t){const e=F.c(2),{scope:s}=t,n=s==="user"?Tb:ec;let i;return e[0]!==n?(i=r.jsx(n,{className:"size-3 text-muted-foreground"}),e[0]=n,e[1]=i):i=e[1],i}function Ij({mode:t,onClose:e,onSaved:s}){const n=re(),i=t.kind==="save-literal"?t.presetValue:"",o=t.presetKey,[a,l]=A.useState(()=>Mj(o)),[c,d]=A.useState("organization"),[h,u]=A.useState(i),[f,m]=A.useState(""),p=Eb(),g=a.trim(),x=h.length>0&&g.length>0&&Vj.test(g),v=async _=>{if(_.preventDefault(),!!x)try{const L=await p.mutateAsync({scope:c,name:g,value:h,description:f.trim()||void 0});ge.success(n("sandbox.envVarsField.secretSaved",{name:L.name})),s(L.id)}catch(L){ge.error(L instanceof Error?L.message:n("sandbox.envVarsField.failedToSaveSecret"))}},b=t.kind==="save-literal"?n("sandbox.envVarsField.saveValueAsSecretTitle"):n("sandbox.envVarsField.createNewSecretTitle"),y=t.kind==="save-literal"?n("sandbox.envVarsField.saveValueAsSecretDescription"):n("sandbox.envVarsField.createNewSecretDescription");return r.jsx(ts,{open:!0,onOpenChange:_=>{_||e()},children:r.jsxs(es,{className:"sm:max-w-md",children:[r.jsxs(ms,{children:[r.jsx(ps,{children:b}),r.jsx(ri,{children:y})]}),r.jsxs("form",{onSubmit:v,className:"space-y-4",children:[r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(lt,{htmlFor:"save-secret-scope",children:n("sandbox.envVarsField.scopeLabel")}),r.jsxs(Qt,{value:c,onValueChange:_=>d(_),children:[r.jsx(Jt,{id:"save-secret-scope",children:r.jsx(as,{})}),r.jsxs(Xt,{children:[r.jsx(vt,{value:"organization",children:n("sandbox.envVarsField.scopeOrganization")}),r.jsx(vt,{value:"user",children:n("sandbox.envVarsField.scopePrivate")})]})]})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(lt,{htmlFor:"save-secret-name",children:n("sandbox.envVarsField.nameLabel")}),r.jsx(rt,{id:"save-secret-name",value:a,onChange:_=>l(_.target.value),placeholder:n("sandbox.envVarsField.namePlaceholder"),autoComplete:"off",required:!0}),r.jsx("p",{className:"text-xs text-muted-foreground",children:n("sandbox.envVarsField.nameHelperText")})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(lt,{htmlFor:"save-secret-value",children:n("sandbox.envVarsField.valueLabel")}),r.jsx(rt,{id:"save-secret-value",type:"password",value:h,onChange:_=>u(_.target.value),placeholder:n("sandbox.envVarsField.secretValuePlaceholder"),autoComplete:"new-password",required:!0})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(lt,{htmlFor:"save-secret-description",children:n("sandbox.envVarsField.descriptionLabel")}),r.jsx(gr,{id:"save-secret-description",value:f,onChange:_=>m(_.target.value),rows:2,placeholder:n("sandbox.envVarsField.descriptionPlaceholder")})]}),r.jsxs(Mi,{children:[r.jsx(le,{type:"button",variant:"outline",onClick:e,disabled:p.isPending,children:n("sandbox.envVarsField.cancel")}),r.jsx(le,{type:"submit",disabled:!x||p.isPending,children:p.isPending?n("sandbox.envVarsField.saving"):n("sandbox.envVarsField.saveSecret")})]})]})]})})}function Ih(t){if(!Array.isArray(t))return[];const e=[];for(const s of t){if(!s||typeof s!="object")continue;const n=s,i=(n.key??"").trim();if(!(!i||!Ul.test(i))){if(n.kind==="literal"){e.push({key:i,kind:"literal",value:n.value??""});continue}n.kind==="secret"&&n.secretId&&e.push({key:i,kind:"secret",secretId:n.secretId})}}return e}function Mj(t){const e=t.trim();return e&&Ul.test(e)?e:""}function Oj(t){const e=F.c(21),{repo:s,className:n}=t,i=re();let o;e[0]!==n?(o=ie("space-y-2",n),e[0]=n,e[1]=o):o=e[1];let a;e[2]!==i?(a=i("sandbox.repoRow.label"),e[2]=i,e[3]=a):a=e[3];let l;e[4]!==a?(l=r.jsx(lt,{children:a}),e[4]=a,e[5]=l):l=e[5];let c;e[6]===Symbol.for("react.memo_cache_sentinel")?(c=r.jsx(Mo,{size:20,className:"shrink-0 text-foreground/60"}),e[6]=c):c=e[6];let d;e[7]!==s||e[8]!==i?(d=r.jsx(ze,{asChild:!0,children:r.jsxs("div",{className:"flex items-center gap-3 rounded-lg border border-border bg-background px-4 py-3",tabIndex:0,children:[c,r.jsx("div",{className:"min-w-0 flex-1",children:s?r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"truncate text-sm font-medium",children:[s.owner,"/",s.name]}),r.jsx("div",{className:"truncate text-xs text-muted-foreground",children:s.url})]}):r.jsx("div",{className:"text-sm text-muted-foreground",children:i("sandbox.repoRow.noRepositoryConnected")})})]})}),e[7]=s,e[8]=i,e[9]=d):d=e[9];let h;e[10]!==i?(h=i("sandbox.repoRow.tooltipContent"),e[10]=i,e[11]=h):h=e[11];let u;e[12]!==h?(u=r.jsx(Ke,{children:h}),e[12]=h,e[13]=u):u=e[13];let f;e[14]!==d||e[15]!==u?(f=r.jsxs(Ue,{children:[d,u]}),e[14]=d,e[15]=u,e[16]=f):f=e[16];let m;return e[17]!==o||e[18]!==l||e[19]!==f?(m=r.jsxs("div",{className:o,children:[l,f]}),e[17]=o,e[18]=l,e[19]=f,e[20]=m):m=e[20],m}const Bj={npm:{install:"npm install",run:t=>`npm run ${t}`,runtime:"node"},pnpm:{install:"pnpm install",run:t=>`pnpm run ${t}`,runtime:"node"},yarn:{install:"yarn install",run:t=>`yarn run ${t}`,runtime:"node"},bun:{install:"bun install",run:t=>`bun run ${t}`,runtime:"bun"},deno:{install:"deno install",run:t=>`deno task ${t}`,runtime:"deno"}};function $j(t){const e=t.trim();if(e==="")return{ok:!0,value:null};if(!/^\d+$/.test(e))return{ok:!1};const s=Number(e);return s<1||s>65535?{ok:!1}:{ok:!0,value:String(s)}}const Fj=Object.keys(Bj),Gc="__none__";function zj(t){const e=F.c(47),{control:s}=t,n=re(),i=A.useRef(null);let o;e[0]!==n?(o=n("sandbox.runtimeFields.packageManager"),e[0]=n,e[1]=o):o=e[1];let a;e[2]!==o?(a=r.jsx(lt,{htmlFor:"runtime-pm",children:o}),e[2]=o,e[3]=a):a=e[3];let l;e[4]!==n?(l=S=>{const{field:C}=S;return r.jsxs(Qt,{value:C.value??Gc,onValueChange:N=>C.onChange(N===Gc?null:N),children:[r.jsx(Jt,{id:"runtime-pm",children:r.jsx(as,{placeholder:n("sandbox.runtimeFields.autoDetect")})}),r.jsxs(Xt,{children:[r.jsx(vt,{value:Gc,children:n("sandbox.runtimeFields.autoDetect")}),Fj.map(Uj)]})]})},e[4]=n,e[5]=l):l=e[5];let c;e[6]!==s||e[7]!==l?(c=r.jsx(_s,{control:s,name:"metadata.runtime.selected",render:l}),e[6]=s,e[7]=l,e[8]=c):c=e[8];let d;e[9]!==a||e[10]!==c?(d=r.jsxs("div",{className:"space-y-2",children:[a,c]}),e[9]=a,e[10]=c,e[11]=d):d=e[11];let h;e[12]!==n?(h=n("sandbox.runtimeFields.packagePath"),e[12]=n,e[13]=h):h=e[13];let u;e[14]!==h?(u=r.jsx(lt,{htmlFor:"runtime-path",children:h}),e[14]=h,e[15]=u):u=e[15];let f;e[16]!==s?(f=r.jsx(_s,{control:s,name:"metadata.runtime.path",render:Kj}),e[16]=s,e[17]=f):f=e[17];let m;e[18]!==n?(m=n("sandbox.runtimeFields.packagePathDescription"),e[18]=n,e[19]=m):m=e[19];let p;e[20]!==m?(p=r.jsx("p",{className:"text-xs text-muted-foreground",children:m}),e[20]=m,e[21]=p):p=e[21];let g;e[22]!==p||e[23]!==u||e[24]!==f?(g=r.jsxs("div",{className:"space-y-2",children:[u,f,p]}),e[22]=p,e[23]=u,e[24]=f,e[25]=g):g=e[25];let x;e[26]!==n?(x=n("sandbox.runtimeFields.devServerPort"),e[26]=n,e[27]=x):x=e[27];let v;e[28]!==x?(v=r.jsx(lt,{htmlFor:"runtime-port",children:x}),e[28]=x,e[29]=v):v=e[29];let b;e[30]!==n?(b=S=>{const{field:C}=S;return r.jsx(rt,{ref:i,id:"runtime-port",inputMode:"numeric",placeholder:n("sandbox.runtimeFields.auto"),defaultValue:C.value??"",onBlur:N=>{const V=$j(N.target.value);V.ok?C.onChange(V.value):i.current&&(i.current.value=C.value??"")}})},e[30]=n,e[31]=b):b=e[31];let y;e[32]!==s||e[33]!==b?(y=r.jsx(_s,{control:s,name:"metadata.runtime.port",render:b}),e[32]=s,e[33]=b,e[34]=y):y=e[34];let _;e[35]!==n?(_=n("sandbox.runtimeFields.devServerPortDescription"),e[35]=n,e[36]=_):_=e[36];let L;e[37]!==_?(L=r.jsx("p",{className:"text-xs text-muted-foreground",children:_}),e[37]=_,e[38]=L):L=e[38];let w;e[39]!==v||e[40]!==y||e[41]!==L?(w=r.jsxs("div",{className:"space-y-2",children:[v,y,L]}),e[39]=v,e[40]=y,e[41]=L,e[42]=w):w=e[42];let j;return e[43]!==g||e[44]!==w||e[45]!==d?(j=r.jsxs("div",{className:"space-y-5",children:[d,g,w]}),e[43]=g,e[44]=w,e[45]=d,e[46]=j):j=e[46],j}function Kj(t){const{field:e}=t;return r.jsx(rt,{id:"runtime-path",placeholder:".",defaultValue:e.value??"",onBlur:s=>{const n=s.target.value.trim();e.onChange(n===""?null:n)}})}function Uj(t){return r.jsx(vt,{value:t,children:t},t)}function Hj(t,e){switch(e.type){case"SET_SHARE_DIALOG_OPEN":return{...t,shareDialogOpen:e.payload};case"SET_ADD_DIALOG_OPEN":return{...t,addDialogOpen:e.payload};case"OPEN_SETTINGS":return{...t,settingsDialogOpen:!0,settingsConnectionId:e.payload};case"CLOSE_SETTINGS":return{...t,settingsDialogOpen:!1,settingsConnectionId:null};default:return t}}function Wj(t,e){switch(e.type){case"accumulate":{const s=t??{start:e.now,fields:new Set,saveCount:0,instructionsLength:null},n=new Set(s.fields);for(const i of e.fields)n.add(i);return{...s,fields:n,saveCount:s.saveCount+1,instructionsLength:e.instructionsLength??s.instructionsLength}}case"reset":return null}}function qj(t){const e=t.metadata?.runtime?.env;if(!e||e.length===0)return t;const s=e.filter(n=>{if(!n||typeof n!="object")return!1;const i=(n.key??"").trim();return!i||!Ul.test(i)?!1:n.kind==="literal"?!0:n.kind==="secret"?!!n.secretId:!1});return s.length===e.length?t:{...t,metadata:{...t.metadata,runtime:{...t.metadata?.runtime??{},env:s}}}}async function Gj(t,e){const s=t?.idToken??null;if(s){const i=Mh(s);if(i)return i}const n=t?.userinfoEndpoint??null;if(n)try{const i=await fetch(n,{headers:{Authorization:`Bearer ${e}`}});if(i.ok){const o=await i.json(),a=typeof o.email=="string"?o.email:typeof o.upn=="string"?o.upn:typeof o.preferred_username=="string"?o.preferred_username:null;if(a)return a}}catch{}return Mh(e)}function Mh(t){try{const e=t.split(".");if(e.length===3&&e[1]){const s=JSON.parse(atob(e[1].replace(/-/g,"+").replace(/_/g,"/")));if(typeof s.email=="string")return s.email;if(typeof s.upn=="string")return s.upn;if(typeof s.preferred_username=="string")return s.preferred_username}}catch{}return null}function Yj({virtualMcp:t,hideOwnTitle:e}){const s=re(),[n]=ni(),i=n.language==="pt-BR"?_b:void 0,{org:o}=Oe(),a=H0(),{data:l}=dv([t.id]),c=l?.get(t.id)?.last_used_at,d=u2(),h=Ls(),u=$s(),f=O0({resolver:em(dj),defaultValues:t}),m=f.watch("connections"),p=Gm(t),g=sa(t),x=g?{owner:g.owner,name:g.name,url:g.url}:null,[v,b]=A.useReducer(Hj,{shareDialogOpen:!1,addDialogOpen:!1,settingsDialogOpen:!1,settingsConnectionId:null}),[y,_]=A.useState(!1),[L,w]=A.useState(!1),{createNewTask:j,openSidePanel:S}=Qo(),{sendMessage:C}=Js(),N=async()=>{if(L)return;const Q=f.getValues("metadata.instructions");if(Q?.trim()){w(!0);try{P(),Me("agent_instructions_improve_clicked",{agent_id:t.id,instructions_length:Q.length}),S("chat"),await C({tiptapDoc:Fp({managerAgentId:_m.AGENT_MANAGER(o.id),managerName:"Agent Manager",kind:"agent",id:t.id,instructions:Q})})}finally{w(!1)}}},V=()=>{P(),Me("agent_test_clicked",{agent_id:t.id}),j()},[E,T]=A.useReducer(Wj,null),k=()=>{E!==null&&(Me("agent_updated",{agent_id:t.id,fields:Array.from(E.fields),instructions_length:E.instructionsLength,save_count:E.saveCount,edit_duration_ms:Date.now()-E.start}),T({type:"reset"}))},{schedule:R,flush:P}=gl({delayMs:3e4,save:async()=>k()}),D=async()=>{const Q=Object.keys(f.control._formState.dirtyFields);if(Q.length===0)return;const ee=Q.includes("metadata"),J=f.getValues();f.reset(J,{keepValues:!0});const te=qj(J);await a.update.mutateAsync({id:t.id,data:te}),T({type:"accumulate",now:Date.now(),fields:Q,instructionsLength:ee?J.metadata?.instructions?.length??0:null}),R()},{schedule:I,flush:M}=gl({save:D});A.useEffect(()=>{const Q=f.watch(()=>I());return()=>Q.unsubscribe()},[]);const O=()=>{Me("connections_dialog_opened",{source:"agent_settings",mode:"add"}),b({type:"SET_ADD_DIALOG_OPEN",payload:!0})},$=async Q=>{const ee=f.getValues("connections");if(ee.some(se=>se.connection_id===Q))return;f.setValue("connections",[...ee,{connection_id:Q,selected_tools:qc.tools,selected_resources:qc.resources,selected_prompts:qc.prompts}],{shouldDirty:!0}),b({type:"SET_ADD_DIALOG_OPEN",payload:!1});const J=new URL(`/api/${o.slug}/mcp/${Q}`,window.location.origin),te=await qu({url:J.href,token:null,orgId:o.id});te.supportsOAuth&&!te.isAuthenticated&&await Y(Q)},B=Q=>{const J=f.getValues("connections").filter(te=>te.connection_id!==Q);f.setValue("connections",J,{shouldDirty:!0})},z=(Q,ee)=>{const J=f.getValues("connections");if(J.some(te=>te.connection_id===ee)){ge.error(s("virtualMcp.virtualMcp.instanceAlreadyAdded"));return}f.setValue("connections",J.map(te=>te.connection_id===Q?{...te,connection_id:ee}:te),{shouldDirty:!0})},K=async Q=>{if(f.getValues("connections").find(J=>J.connection_id===Q))try{const{item:J}=await u.call("COLLECTION_CONNECTIONS_GET",{id:Q});if(!J)return;const te=J.title.replace(/\s*\(.*?\)\s*$/,""),se=Lb("conn"),ne=`${te} (${Date.now().toString(36).slice(-4)})`;await d.create.mutateAsync({id:se,title:ne,description:J.description??null,connection_type:J.connection_type,connection_url:J.connection_url??null,connection_token:null,icon:J.icon??null,app_name:J.app_name??null,app_id:J.app_id??null,connection_headers:J.connection_headers??null});const de=new URL(`/api/${o.slug}/mcp/${se}`,window.location.origin),xe=await qu({url:de.href,token:null,orgId:o.id});if(xe.supportsOAuth&&!xe.isAuthenticated){const ue=await Y(se);if(!ue){await d.delete.mutateAsync(se);return}await d.update.mutateAsync({id:se,data:{title:`${te} (${ue})`}})}z(Q,se),ge.success(s("virtualMcp.virtualMcp.newInstanceCreated"))}catch(J){console.error("Failed to create instance:",J),ge.error(s("virtualMcp.virtualMcp.failedToCreateInstance"))}},G=Q=>{b({type:"OPEN_SETTINGS",payload:Q})},Y=async Q=>{const{token:ee,tokenInfo:J,error:te}=await Sb({connectionId:Q,orgSlug:o.slug,scope:"offline_access"});if(te||!ee)return ge.error(s("virtualMcp.virtualMcp.authenticationFailed",{error:te??""})),null;if(J)try{const ne=await fetch(`/api/${o.slug}/connections/${Q}/oauth-token`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({accessToken:J.accessToken,refreshToken:J.refreshToken,expiresIn:J.expiresIn,scope:J.scope,clientId:J.clientId,clientSecret:J.clientSecret,tokenEndpoint:J.tokenEndpoint})});if(!ne.ok)console.error("Failed to save OAuth token:",await ne.text()),await d.update.mutateAsync({id:Q,data:{connection_token:ee}});else try{await d.update.mutateAsync({id:Q,data:{}})}catch(de){console.warn("Failed to refresh connection tools after OAuth:",de)}}catch(ne){console.error("Error saving OAuth token:",ne),await d.update.mutateAsync({id:Q,data:{connection_token:ee}})}else await d.update.mutateAsync({id:Q,data:{connection_token:ee}});const se=new URL(`/api/${o.slug}/mcp/${Q}`,window.location.origin);return await h.invalidateQueries({queryKey:at.isMCPAuthenticated(se.href,null)}),ge.success(s("virtualMcp.virtualMcp.authenticationSuccessful")),Gj(J,ee)},U=()=>{const Q=f.getValues("metadata.instructions")??"",ee=`<role>
|
|
11
|
-
Define who this agent is and what it specializes in.
|
|
12
|
-
Example: You are a support triage agent for B2B merchants.
|
|
13
|
-
</role>
|
|
14
|
-
|
|
15
|
-
<capabilities>
|
|
16
|
-
List what this agent can do using its connected tools.
|
|
17
|
-
- Investigate issues using connected data sources.
|
|
18
|
-
- Summarize findings and recommend next steps.
|
|
19
|
-
</capabilities>
|
|
20
|
-
|
|
21
|
-
<constraints>
|
|
22
|
-
Set clear boundaries on what the agent must not do.
|
|
23
|
-
- Do not perform destructive actions without confirmation.
|
|
24
|
-
- Escalate to a human when the request is outside your expertise.
|
|
25
|
-
</constraints>
|
|
26
|
-
|
|
27
|
-
<workflows>
|
|
28
|
-
Define step-by-step how the agent should handle requests.
|
|
29
|
-
|
|
30
|
-
## Default workflow
|
|
31
|
-
1. Read the user's request and gather context.
|
|
32
|
-
2. Use the appropriate tools to investigate or act.
|
|
33
|
-
3. Summarize the result and propose next steps.
|
|
34
|
-
4. Ask for confirmation before making any changes.
|
|
35
|
-
</workflows>`,J=Q.trim()?`${Q}
|
|
36
|
-
|
|
37
|
-
${ee}`:ee;f.setValue("metadata.instructions",J,{shouldDirty:!0})},W=new Set(m.map(Q=>Q.connection_id)),H=St(),[X,q]=A.useState(!1),Z=async()=>{P();try{await a.delete.mutateAsync(t.id),Me("agent_deleted",{agent_id:t.id,source:"agent_detail"}),ge.success(s("virtualMcp.virtualMcp.agentDeleted",{title:t.title})),H({to:"/$org",params:{org:o.slug}})}catch{}};return r.jsxs(en,{children:[r.jsx(en.Content,{children:r.jsx(en.Body,{children:r.jsxs("div",{className:"flex flex-col gap-10",children:[!e&&r.jsx(en.Title,{actions:r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs(le,{variant:"outline",size:"sm",onClick:V,children:[r.jsx(Vi,{size:14,className:"size-[14px]!"}),s("virtualMcp.virtualMcp.testAgent")]}),r.jsx(le,{variant:"ghost",size:"icon",className:"text-muted-foreground hover:text-destructive",onClick:()=>q(!0),children:r.jsx(Ns,{size:14})})]}),children:s("virtualMcp.virtualMcp.settings")}),r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx(_s,{name:"icon",control:f.control,render:({field:Q})=>r.jsx(Sw,{value:Q.value??null,onChange:ee=>{Q.onChange(ee),M()},onColorChange:ee=>{f.setValue("metadata.ui.themeColor",ee,{shouldDirty:!0}),M()},name:f.watch("title")||"Agent",size:"md",className:"shrink-0",avatarClassName:"[&_svg]:w-1/2 [&_svg]:h-1/2"})}),r.jsxs("div",{className:"flex flex-col flex-1 min-w-0",children:[r.jsx(_s,{name:"title",control:f.control,render:({field:Q})=>r.jsx("input",{...Q,type:"text",value:Q.value??"",onChange:ee=>{Q.onChange(ee)},onBlur:()=>{Q.onBlur(),M()},disabled:p,placeholder:s("virtualMcp.virtualMcp.agentNamePlaceholder"),className:"text-lg font-medium leading-tight text-foreground bg-transparent border-none outline-none px-1 -mx-1 rounded hover:bg-input/25 focus:bg-input/25 transition-colors w-full truncate disabled:hover:bg-transparent disabled:focus:bg-transparent disabled:opacity-50"})}),r.jsx(_s,{name:"description",control:f.control,render:({field:Q})=>r.jsx("input",{...Q,type:"text",value:Q.value??"",onChange:ee=>{Q.onChange(ee)},onBlur:()=>{Q.onBlur(),M()},disabled:p,placeholder:s("virtualMcp.virtualMcp.descriptionPlaceholder"),className:"text-sm text-muted-foreground bg-transparent border-none outline-none px-1 -mx-1 rounded hover:bg-input/25 focus:bg-input/25 transition-colors w-full truncate disabled:hover:bg-transparent disabled:focus:bg-transparent disabled:opacity-50"})})]}),r.jsxs(le,{variant:"outline",size:"sm",className:"shrink-0",onClick:()=>{Me("agent_connect_modal_opened",{agent_id:t.id}),b({type:"SET_SHARE_DIALOG_OPEN",payload:!0})},children:[r.jsxs("span",{className:"flex items-center -space-x-1.5 mr-0.5",children:[r.jsx("span",{className:"inline-flex items-center justify-center size-4 rounded-full bg-black ring-1 ring-white/20 shrink-0",children:r.jsx("img",{src:"/logos/cursor.svg",alt:"Cursor",className:"size-2.5 brightness-0 invert"})}),r.jsx("span",{className:"relative z-10 inline-flex items-center justify-center size-4 rounded-full ring-1 ring-background shrink-0",style:{backgroundColor:"#D97757"},children:r.jsx("img",{src:"/logos/Claude Code.svg",alt:"Claude",className:"size-2.5 brightness-0 invert"})})]}),s("virtualMcp.virtualMcp.connect")]})]}),r.jsxs("div",{className:"flex items-center gap-2 -mt-6 text-sm text-muted-foreground",children:[r.jsx(zp,{id:t.created_by,size:"2xs",className:"text-sm text-muted-foreground"}),r.jsx("span",{className:"text-muted-foreground/50",children:"·"}),r.jsxs("span",{children:[s("virtualMcp.virtualMcp.created")," ",new Date(t.created_at).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})]}),r.jsx("span",{className:"text-muted-foreground/50",children:"·"}),r.jsx("span",{children:c?s("virtualMcp.virtualMcp.lastUsed",{time:yb(new Date(c),{addSuffix:!0,locale:i})}):s("virtualMcp.virtualMcp.neverUsed")})]}),r.jsxs("section",{className:"flex flex-col gap-3",children:[r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[r.jsx("h2",{className:"text-sm font-medium text-foreground",children:s("virtualMcp.virtualMcp.connections")}),m.length>0&&r.jsxs(le,{variant:"outline",size:"sm",onClick:O,children:[r.jsx(kt,{size:14}),s("virtualMcp.virtualMcp.addConnection")]})]}),r.jsx("div",{className:"flex flex-col gap-2",children:m.length===0?r.jsxs("button",{type:"button",onClick:O,className:"flex items-center gap-3 px-3 py-2.5 rounded-lg border border-dashed border-border hover:bg-accent/50 transition-colors w-full text-left cursor-pointer",children:[r.jsx("div",{className:"flex items-center justify-center size-8 rounded-md text-muted-foreground/75 border border-dashed border-border shrink-0",children:r.jsx(kt,{size:16})}),r.jsx("span",{className:"text-sm text-muted-foreground",children:s("virtualMcp.virtualMcp.noConnectionsYet")})]}):m.map(Q=>r.jsx(ys,{fallback:()=>null,children:r.jsx(A.Suspense,{fallback:r.jsx(Up,{}),children:r.jsx(sj,{connection_id:Q.connection_id,usedConnectionIds:W,onOpenSettings:()=>G(Q.connection_id),onRemove:()=>B(Q.connection_id),onAuthenticate:Y,onSwitchInstance:z,onNewInstance:()=>K(Q.connection_id)})})},Q.connection_id))})]}),r.jsxs("section",{className:"flex flex-col gap-3",children:[r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[r.jsx("h2",{className:"text-sm font-medium text-foreground",children:s("virtualMcp.virtualMcp.instructions")}),r.jsxs("div",{className:"flex items-center gap-2",children:[!f.watch("metadata.instructions")?.trim()&&r.jsx(le,{variant:"outline",size:"sm",onClick:U,children:s("virtualMcp.virtualMcp.promptTemplate")}),r.jsxs(le,{variant:"outline",size:"sm",disabled:L||!f.watch("metadata.instructions")?.trim(),onClick:N,children:[r.jsx(qn,{size:13}),s("virtualMcp.virtualMcp.improve")]})]})]}),r.jsx(_s,{name:"metadata.instructions",control:f.control,render:({field:Q})=>r.jsxs("div",{className:"relative rounded-xl card-shadow bg-card focus-within:ring-1 focus-within:ring-ring",children:[r.jsx(gr,{...Q,value:Q.value??"",onChange:ee=>{Q.onChange(ee)},onBlur:()=>{Q.onBlur(),M()},placeholder:s("virtualMcp.virtualMcp.instructionsPlaceholder"),className:"min-h-[200px] max-h-[360px] overflow-auto resize-none text-base text-muted-foreground placeholder:text-muted-foreground/40 leading-relaxed border-0 shadow-none px-4 py-3 pr-11 focus-visible:ring-0 focus-visible:ring-offset-0 bg-transparent",style:{boxShadow:"none"}}),r.jsxs(Ue,{delayDuration:0,children:[r.jsx(ze,{asChild:!0,children:r.jsx(le,{type:"button",variant:"ghost",size:"icon",className:"absolute top-2 right-2 h-7 w-7 text-muted-foreground",onClick:()=>_(!0),"aria-label":s("virtualMcp.virtualMcp.openFullscreenEditor"),children:r.jsx(Bm,{size:14})})}),r.jsx(Ke,{side:"left",children:s("virtualMcp.virtualMcp.fullscreen")})]})]})})]}),r.jsx(Tw,{form:f}),r.jsx(ys,{fallback:()=>null,children:r.jsx(A.Suspense,{fallback:r.jsxs("section",{className:"flex flex-col gap-3",children:[r.jsx("h2",{className:"text-sm font-medium text-foreground",children:s("virtualMcp.virtualMcp.subAgents")}),r.jsx("div",{className:"h-16 rounded-lg border border-dashed border-border animate-pulse"})]}),children:r.jsx(Mw,{form:f,currentAgentId:t.id})})}),r.jsx(cj,{virtualMcpId:t.id,form:f,flushAndSave:M}),r.jsx(Sj,{virtualMcp:t}),p&&r.jsxs("div",{className:"flex flex-col gap-3",children:[r.jsxs("div",{className:"flex flex-col gap-1",children:[r.jsx("h2",{className:"text-sm font-medium text-foreground",children:s("virtualMcp.virtualMcp.publishing")}),r.jsx("p",{className:"text-sm text-muted-foreground",children:s("virtualMcp.virtualMcp.publishingDescription")})]}),r.jsx(pl,{className:"p-6",children:r.jsx(Do,{className:"p-0",children:r.jsx(_s,{name:"metadata.publishPolicy",control:f.control,render:({field:Q})=>r.jsx(yw,{value:Q.value??"smart",onValueChange:ee=>{Q.onChange(ee),M()},className:"gap-4",children:[{value:"smart",label:s("virtualMcp.virtualMcp.publishPolicySmart"),description:s("virtualMcp.virtualMcp.publishPolicySmartDescription")},{value:"code-review",label:s("virtualMcp.virtualMcp.publishPolicyCodeReview"),description:s("virtualMcp.virtualMcp.publishPolicyCodeReviewDescription")},{value:"open",label:s("virtualMcp.virtualMcp.publishPolicyOpen"),description:s("virtualMcp.virtualMcp.publishPolicyOpenDescription")}].map(ee=>r.jsxs("label",{htmlFor:`publish-policy-${ee.value}`,className:"flex cursor-pointer items-start gap-3",children:[r.jsx(Lw,{id:`publish-policy-${ee.value}`,value:ee.value,className:"mt-0.5"}),r.jsxs("div",{className:"flex flex-col gap-0.5",children:[r.jsx("span",{className:"text-sm font-medium text-foreground",children:ee.label}),r.jsx("span",{className:"text-sm text-muted-foreground",children:ee.description})]})]},ee.value))})})})})]}),r.jsxs("div",{className:"flex flex-col gap-3",children:[r.jsx("div",{className:"flex items-center justify-between gap-3",children:r.jsx("h2",{className:"text-sm font-medium text-foreground",children:s("virtualMcp.virtualMcp.sandbox")})}),r.jsx(pl,{className:"p-6 gap-5",children:r.jsxs(Do,{className:"p-0 space-y-5",children:[r.jsx(Oj,{repo:x}),r.jsx(zj,{control:f.control}),r.jsx(Nj,{control:f.control,form:f,virtualMcpId:t.id,orgSlug:o.slug})]})})]}),r.jsxs("section",{className:"flex items-center justify-between border-t border-border pt-6",children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-sm font-medium",children:s("virtualMcp.virtualMcp.deleteAgent")}),r.jsx("p",{className:"text-sm text-muted-foreground",children:s("virtualMcp.virtualMcp.deleteAgentDescription")})]}),r.jsxs(le,{variant:"outline",size:"sm",className:"text-destructive border-destructive/40 hover:bg-destructive/10 hover:text-destructive shrink-0",onClick:()=>q(!0),children:[r.jsx(Ns,{size:14}),s("virtualMcp.virtualMcp.deleteAgent")]})]})]})})}),r.jsx(al,{open:X,onOpenChange:q,children:r.jsxs(ll,{children:[r.jsxs(cl,{children:[r.jsx(dl,{children:s("virtualMcp.virtualMcp.deleteAgentConfirm")}),r.jsx(ul,{children:s("virtualMcp.virtualMcp.deleteAgentConfirmDescription",{title:t.title})})]}),r.jsxs(hl,{children:[r.jsx(fl,{children:s("virtualMcp.virtualMcp.cancel")}),r.jsx(ml,{onClick:Z,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:s("virtualMcp.virtualMcp.delete")})]})]})}),r.jsx(o9,{open:v.addDialogOpen,onOpenChange:Q=>b({type:"SET_ADD_DIALOG_OPEN",payload:Q}),agentId:t.id,addedConnectionIds:W,onAdd:$}),r.jsx(tj,{open:v.settingsDialogOpen,onOpenChange:Q=>{Q||b({type:"CLOSE_SETTINGS"})},selectedId:v.settingsConnectionId,form:f,connections:m,onAuthenticate:Y}),r.jsx(Lj,{open:v.shareDialogOpen,onOpenChange:Q=>b({type:"SET_SHARE_DIALOG_OPEN",payload:Q}),virtualMcp:t}),r.jsx(ts,{open:y,onOpenChange:_,children:r.jsxs(es,{className:"w-[90vw] sm:max-w-6xl h-[85vh] flex flex-col p-0 gap-0",children:[r.jsx(ms,{className:"px-6 pt-6 pb-3 border-b border-border shrink-0",children:r.jsx(ps,{children:s("virtualMcp.virtualMcp.instructions")})}),r.jsx("div",{className:"flex-1 min-h-0 p-6",children:r.jsx(_s,{name:"metadata.instructions",control:f.control,render:({field:Q})=>r.jsx(gr,{...Q,value:Q.value??"",onChange:ee=>{Q.onChange(ee)},onBlur:()=>{Q.onBlur(),M()},disabled:p,placeholder:s("virtualMcp.virtualMcp.instructionsPlaceholder"),className:"w-full h-full resize-none text-base text-muted-foreground placeholder:text-muted-foreground/40 leading-relaxed rounded-xl card-shadow px-4 py-3 focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-0 bg-card border-0",style:{boxShadow:"none"}})})})]})})]})}function Jj(t){const e=F.c(22),{virtualMcpId:s,hideOwnTitle:n}=t,i=re(),o=St(),{org:a}=Oe(),l=gs(s);if(!l){let h;e[0]!==i?(h=i("virtualMcp.virtualMcp.spaceNotFound"),e[0]=i,e[1]=h):h=e[1];let u;e[2]!==i?(u=i("virtualMcp.virtualMcp.spaceNotFoundDescription"),e[2]=i,e[3]=u):u=e[3];let f;e[4]!==o||e[5]!==a.slug?(f=()=>o({to:"/$org",params:{org:a.slug}}),e[4]=o,e[5]=a.slug,e[6]=f):f=e[6];let m;e[7]!==i?(m=i("virtualMcp.virtualMcp.backToSpaces"),e[7]=i,e[8]=m):m=e[8];let p;e[9]!==f||e[10]!==m?(p=r.jsx(le,{variant:"outline",onClick:f,children:m}),e[9]=f,e[10]=m,e[11]=p):p=e[11];let g;return e[12]!==h||e[13]!==u||e[14]!==p?(g=r.jsx("div",{className:"flex h-full w-full bg-background",children:r.jsx(ki,{title:h,description:u,actions:p})}),e[12]=h,e[13]=u,e[14]=p,e[15]=g):g=e[15],g}let c;e[16]!==l?(c=sa(l)?.connectionId??"",e[16]=l,e[17]=c):c=e[17];let d;return e[18]!==n||e[19]!==c||e[20]!==l?(d=r.jsx(Yj,{virtualMcp:l,hideOwnTitle:n},c),e[18]=n,e[19]=c,e[20]=l,e[21]=d):d=e[21],d}function Oh(t){const e=F.c(2),{virtualMcpId:s}=t;let n;return e[0]!==s?(n=r.jsx(Jj,{virtualMcpId:s,hideOwnTitle:!0}),e[0]=s,e[1]=n):n=e[1],n}const _r=1,Wp=`home-board.layout.v${_r}`;function qp(t){return`home-board.layout.v${_r}.${t}`}const Gp={version:_r,tiles:{},hidden:[],shown:[]};function $d(t){return!t||t.version!==_r?Gp:{version:_r,tiles:t.tiles??{},hidden:Array.isArray(t.hidden)?t.hidden:[],shown:Array.isArray(t.shown)?t.shown:[]}}function Xj(t){return Object.keys(t.tiles).length>0||t.hidden.length>0||(t.shown?.length??0)>0}function Qj(t){try{const e=localStorage.getItem(qp(t));return e?$d(JSON.parse(e)):void 0}catch{return}}function Bh(t,e){try{localStorage.setItem(qp(t),JSON.stringify(e))}catch{}}async function $h(t,e){if(!(await fetch(`/api/${t}/kv/${Wp}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).ok)throw new Error("Failed to save board layout")}function Zj(t){const e=F.c(24),s=Ls();let n;e[0]!==t?(n=at.boardLayout(t),e[0]=t,e[1]=n):n=e[1];const i=n;let o;e[2]!==t?(o=Qj(t),e[2]=t,e[3]=o):o=e[3];const a=o;let l;e[4]!==a||e[5]!==t?(l=async()=>{const v=await fetch(`/api/${t}/kv/${Wp}`);if(v.status===404)return a&&Xj(a)?(await $h(t,a),a):Gp;if(!v.ok)throw new Error("Failed to load board layout");const b=await v.json(),y=$d(b.value);return Bh(t,y),y},e[4]=a,e[5]=t,e[6]=l):l=e[6];let c;e[7]!==a||e[8]!==i||e[9]!==l?(c={queryKey:i,queryFn:l,initialData:a,staleTime:0,refetchOnWindowFocus:!1},e[7]=a,e[8]=i,e[9]=l,e[10]=c):c=e[10];const{data:d,isLoading:h}=Mt(c);let u;e[11]!==t?(u={mutationFn:v=>$h(t,v)},e[11]=t,e[12]=u):u=e[12];const f=Ys(u);let m;e[13]!==f||e[14]!==t||e[15]!==s||e[16]!==i?(m=v=>{Bh(t,v),s.setQueryData(i,v),f.mutate(v)},e[13]=f,e[14]=t,e[15]=s,e[16]=i,e[17]=m):m=e[17];const p=m;let g;e[18]!==d?(g=$d(d),e[18]=d,e[19]=g):g=e[19];let x;return e[20]!==h||e[21]!==p||e[22]!==g?(x={layout:g,isLoading:h,save:p},e[20]=h,e[21]=p,e[22]=g,e[23]=x):x=e[23],x}const Yp=A.createContext(null);function eC(t){const e=F.c(24),{children:s}=t,{org:n}=Oe(),i=Zj(n.slug),[o,a]=A.useState(!1),[l,c]=A.useState(null);let d;e[0]!==i.layout?(d=()=>{c(i.layout),a(!0)},e[0]=i.layout,e[1]=d):d=e[1];const h=d;let u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{c(null),a(!1)},e[2]=u):u=e[2];const f=u;let m;e[3]!==l||e[4]!==i?(m=()=>{l&&i.save(l),c(null),a(!1)},e[3]=l,e[4]=i,e[5]=m):m=e[5];const p=m,g=o&&l!==null,x=g?l:i.layout;let v;e[6]!==l||e[7]!==g||e[8]!==i.layout?(v=g?JSON.stringify(l)!==JSON.stringify(i.layout):!1,e[6]=l,e[7]=g,e[8]=i.layout,e[9]=v):v=e[9];const b=v;let y;e[10]!==o||e[11]!==i?(y=j=>{o?c(j):i.save(j)},e[10]=o,e[11]=i,e[12]=y):y=e[12];const _=y;let L;e[13]!==_||e[14]!==h||e[15]!==b||e[16]!==o||e[17]!==x||e[18]!==p||e[19]!==i.isLoading?(L={isEditMode:o,enter:h,cancel:f,save:p,hasChanges:b,layout:x,isLayoutLoading:i.isLoading,commitLayout:_},e[13]=_,e[14]=h,e[15]=b,e[16]=o,e[17]=x,e[18]=p,e[19]=i.isLoading,e[20]=L):L=e[20];let w;return e[21]!==s||e[22]!==L?(w=r.jsx(Yp.Provider,{value:L,children:s}),e[21]=s,e[22]=L,e[23]=w):w=e[23],w}function F9(){const t=A.useContext(Yp);if(!t)throw new Error("useHomeEdit must be used within a HomeEditProvider");return t}function tC(t){const e=F.c(30),{generating:s}=t;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=ie("pointer-events-none absolute -bottom-14 left-6 hidden h-48 w-36 -rotate-6 rounded-xl border border-border bg-background shadow-lg sm:block","transition-transform duration-500 ease-out group-hover:-translate-y-2 group-hover:-rotate-3"),e[0]=n):n=e[0];let i;e[1]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx("circle",{cx:"16",cy:"16",r:"12",fill:"none",strokeWidth:"4",className:"stroke-muted"}),e[1]=i):i=e[1];const o=s?"75.4":"22",a=s?"stroke-muted":"stroke-success";let l;e[2]!==a?(l=ie("transition-[stroke-dashoffset] duration-1000 ease-out",a),e[2]=a,e[3]=l):l=e[3];let c;e[4]!==o||e[5]!==l?(c=r.jsxs("svg",{viewBox:"0 0 32 32",className:"size-9 shrink-0 -rotate-90",children:[i,r.jsx("circle",{cx:"16",cy:"16",r:"12",fill:"none",strokeWidth:"4",strokeLinecap:"round",strokeDasharray:"75.4",strokeDashoffset:o,className:l})]}),e[4]=o,e[5]=l,e[6]=c):c=e[6];const d=s&&"animate-pulse";let h;e[7]!==d?(h=ie("h-1.5 w-full rounded-full bg-muted",d),e[7]=d,e[8]=h):h=e[8];let u;e[9]!==h?(u=r.jsx("div",{className:h}),e[9]=h,e[10]=u):u=e[10];const f=s&&"animate-pulse";let m;e[11]!==f?(m=ie("h-1.5 w-2/3 rounded-full bg-muted",f),e[11]=f,e[12]=m):m=e[12];let p;e[13]!==m?(p=r.jsx("div",{className:m}),e[13]=m,e[14]=p):p=e[14];let g;e[15]!==p||e[16]!==u?(g=r.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-1.5",children:[u,p]}),e[15]=p,e[16]=u,e[17]=g):g=e[17];let x;e[18]!==g||e[19]!==c?(x=r.jsxs("div",{className:"flex items-center gap-2.5",children:[c,g]}),e[18]=g,e[19]=c,e[20]=x):x=e[20];let v;e[21]===Symbol.for("react.memo_cache_sentinel")?(v=[7,10,5,9,6,8],e[21]=v):v=e[21];let b;e[22]!==s?(b=r.jsx("div",{className:"flex h-10 items-end gap-1.5",children:v.map((L,w)=>r.jsx("div",{style:{height:`${L*4}px`},className:ie("flex-1 rounded-sm",s?"animate-pulse bg-muted":w%2===0?"bg-success/70":"bg-success/30")},`bar-${w}`))}),e[22]=s,e[23]=b):b=e[23];let y;e[24]!==s?(y=r.jsx("div",{className:"flex flex-col gap-1.5",children:["w-full","w-5/6","w-full","w-2/3","w-full"].map((L,w)=>r.jsx("div",{className:ie("h-1.5 rounded-full bg-muted",L,s&&"animate-pulse")},`line-${w}`))}),e[24]=s,e[25]=y):y=e[25];let _;return e[26]!==x||e[27]!==b||e[28]!==y?(_=r.jsx("div",{"aria-hidden":!0,className:n,children:r.jsxs("div",{className:"flex h-full flex-col gap-3 p-4",children:[x,b,y]})}),e[26]=x,e[27]=b,e[28]=y,e[29]=_):_=e[29],_}function sC(t){const e=F.c(25),{status:s,host:n,onOpen:i}=t,o=s==="generating",a=n??"sua loja";let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=ie("group relative block w-full cursor-pointer overflow-hidden rounded-3xl border border-border bg-card card-shadow text-left","transition-colors duration-300 hover:bg-accent/30","animate-in fade-in slide-in-from-bottom-2 duration-500"),e[0]=l):l=e[0];const c=o?"bg-warning/15":"bg-success/15";let d;e[1]!==c?(d=ie("absolute -bottom-24 -left-10 size-64 rounded-full blur-3xl transition-colors duration-700",c),e[1]=c,e[2]=d):d=e[2];let h;e[3]!==d?(h=r.jsx("div",{"aria-hidden":!0,className:d}),e[3]=d,e[4]=h):h=e[4];let u;e[5]!==o?(u=r.jsx(tC,{generating:o}),e[5]=o,e[6]=u):u=e[6];const f=o?"Gerando seu diagnóstico":"Seu relatório está pronto";let m;e[7]!==f?(m=r.jsx("span",{className:"text-base font-medium leading-6 text-foreground sm:text-lg",children:f}),e[7]=f,e[8]=m):m=e[8];const p=o?`Analisando ${a}. Isso leva alguns minutos.`:`Veja a análise completa de ${a}.`;let g;e[9]!==p?(g=r.jsx("span",{className:"truncate text-sm text-muted-foreground",children:p}),e[9]=p,e[10]=g):g=e[10];let x;e[11]!==m||e[12]!==g?(x=r.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:[m,g]}),e[11]=m,e[12]=g,e[13]=x):x=e[13];let v;e[14]===Symbol.for("react.memo_cache_sentinel")?(v=ie("flex size-11 shrink-0 items-center justify-center rounded-full border border-border bg-background","transition-transform duration-300 group-hover:translate-x-1"),e[14]=v):v=e[14];let b;e[15]!==o?(b=r.jsx("div",{className:v,children:o?r.jsxs("span",{className:"relative flex size-2.5",children:[r.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-warning opacity-60"}),r.jsx("span",{className:"relative inline-flex size-2.5 rounded-full bg-warning"})]}):r.jsx(kr,{size:18,className:"text-foreground","aria-hidden":!0})}),e[15]=o,e[16]=b):b=e[16];let y;e[17]!==x||e[18]!==b?(y=r.jsxs("div",{className:"relative flex min-h-28 items-center gap-4 px-5 py-5 sm:h-36 sm:gap-6 sm:pr-6 sm:pl-52",children:[x,b]}),e[17]=x,e[18]=b,e[19]=y):y=e[19];let _;return e[20]!==i||e[21]!==y||e[22]!==h||e[23]!==u?(_=r.jsxs("button",{type:"button",onClick:i,className:l,children:[h,u,y]}),e[20]=i,e[21]=y,e[22]=h,e[23]=u,e[24]=_):_=e[24],_}function nC(){const t=F.c(13),{org:e}=Oe(),s=St(),{diagnostic:n,isSuccess:i,host:o,connectionId:a}=_v();let l;t[0]!==n||t[1]!==i?(l=i?yv(n):"none",t[0]=n,t[1]=i,t[2]=l):l=t[2];const c=l;if(c==="none")return null;let d;t[3]!==a||t[4]!==o||t[5]!==s||t[6]!==e||t[7]!==c?(d=()=>{Me("home_report_banner_clicked",{organization_id:e.id,status:c,domain:o??void 0}),s(Lv(e,a))},t[3]=a,t[4]=o,t[5]=s,t[6]=e,t[7]=c,t[8]=d):d=t[8];const h=d;let u;return t[9]!==o||t[10]!==h||t[11]!==c?(u=r.jsx(sC,{status:c,host:o,onOpen:h}),t[9]=o,t[10]=h,t[11]=c,t[12]=u):u=t[12],u}function iC(){const t=F.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx(ys,{fallback:null,children:r.jsx(nC,{})}),t[0]=e):e=t[0],e}function rC({agentId:t}){const e=re(),{org:s,locator:n}=Oe(),i=ht({connectionId:t,orgId:s.id,orgSlug:s.slug}),{create:o}=Hl(),{setTaskId:a}=Qo(),[l,c]=A.useState(null),[d,h]=A.useState(!1),u=A.useRef(!1),f=async(v,b)=>{if(!i){ge.error(e("common.useStartThreadFromPrompt.mcpClientNotAvailable"));return}if(!u.current){u.current=!0,h(!0);try{const y=await Xo(i,v.name,b),_={type:"doc",content:[{type:"paragraph",content:[K0({id:v.name,name:jr(v.name,pn(v._meta)),metadata:y.messages,char:"/",kind:"prompt",args:b}),{type:"text",text:" "}]}]},L=crypto.randomUUID();km(sessionStorage,n,L,{tiptapDoc:_}),await o({id:L,virtual_mcp_id:t}),a(L,t,{autosend:!0})}catch(y){console.error("[start-thread-from-prompt] failed",y),ge.error(e("common.useStartThreadFromPrompt.failedToStartChat"))}finally{u.current=!1,h(!1)}}},m=async v=>{if(!u.current){if(v.arguments&&v.arguments.length>0){c(v);return}await f(v)}},p=async v=>{if(!l)return;const b=l;c(null),await f(b,v)};return{start:m,startBlank:async v=>{if(!u.current){u.current=!0,h(!0);try{const b=crypto.randomUUID();await o({id:b,virtual_mcp_id:t}),a(b,t,v?.main?{main:v.main}:void 0)}catch(b){console.error("[start-thread-from-prompt] startBlank failed",b),ge.error(e("common.useStartThreadFromPrompt.failedToStartChat"))}finally{u.current=!1,h(!1)}}},dialog:r.jsx(No,{prompt:l,setPrompt:v=>c(v),onSubmit:p}),dialogPrompt:l,starting:d}}function oC(){for(var t=arguments.length,e=new Array(t),s=0;s<t;s++)e[s]=arguments[s];return A.useMemo(()=>n=>{e.forEach(i=>i(n))},e)}const dc=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Ir(t){const e=Object.prototype.toString.call(t);return e==="[object Window]"||e==="[object global]"}function z9(t){return"nodeType"in t}function Ss(t){var e,s;return t?Ir(t)?t:z9(t)&&(e=(s=t.ownerDocument)==null?void 0:s.defaultView)!=null?e:window:window}function K9(t){const{Document:e}=Ss(t);return t instanceof e}function la(t){return Ir(t)?!1:t instanceof Ss(t).HTMLElement}function Jp(t){return t instanceof Ss(t).SVGElement}function Mr(t){return t?Ir(t)?t.document:z9(t)?K9(t)?t:la(t)||Jp(t)?t.ownerDocument:document:document:document}const nn=dc?A.useLayoutEffect:A.useEffect;function uc(t){const e=A.useRef(t);return nn(()=>{e.current=t}),A.useCallback(function(){for(var s=arguments.length,n=new Array(s),i=0;i<s;i++)n[i]=arguments[i];return e.current==null?void 0:e.current(...n)},[])}function aC(){const t=A.useRef(null),e=A.useCallback((n,i)=>{t.current=setInterval(n,i)},[]),s=A.useCallback(()=>{t.current!==null&&(clearInterval(t.current),t.current=null)},[]);return[e,s]}function $o(t,e){e===void 0&&(e=[t]);const s=A.useRef(t);return nn(()=>{s.current!==t&&(s.current=t)},e),s}function ca(t,e){const s=A.useRef();return A.useMemo(()=>{const n=t(s.current);return s.current=n,n},[...e])}function wl(t){const e=uc(t),s=A.useRef(null),n=A.useCallback(i=>{i!==s.current&&e?.(i,s.current),s.current=i},[]);return[s,n]}function jl(t){const e=A.useRef();return A.useEffect(()=>{e.current=t},[t]),e.current}let Yc={};function da(t,e){return A.useMemo(()=>{if(e)return e;const s=Yc[t]==null?0:Yc[t]+1;return Yc[t]=s,t+"-"+s},[t,e])}function Xp(t){return function(e){for(var s=arguments.length,n=new Array(s>1?s-1:0),i=1;i<s;i++)n[i-1]=arguments[i];return n.reduce((o,a)=>{const l=Object.entries(a);for(const[c,d]of l){const h=o[c];h!=null&&(o[c]=h+t*d)}return o},{...e})}}const or=Xp(1),Fo=Xp(-1);function lC(t){return"clientX"in t&&"clientY"in t}function hc(t){if(!t)return!1;const{KeyboardEvent:e}=Ss(t.target);return e&&t instanceof e}function cC(t){if(!t)return!1;const{TouchEvent:e}=Ss(t.target);return e&&t instanceof e}function Cl(t){if(cC(t)){if(t.touches&&t.touches.length){const{clientX:e,clientY:s}=t.touches[0];return{x:e,y:s}}else if(t.changedTouches&&t.changedTouches.length){const{clientX:e,clientY:s}=t.changedTouches[0];return{x:e,y:s}}}return lC(t)?{x:t.clientX,y:t.clientY}:null}const Ln=Object.freeze({Translate:{toString(t){if(!t)return;const{x:e,y:s}=t;return"translate3d("+(e?Math.round(e):0)+"px, "+(s?Math.round(s):0)+"px, 0)"}},Scale:{toString(t){if(!t)return;const{scaleX:e,scaleY:s}=t;return"scaleX("+e+") scaleY("+s+")"}},Transform:{toString(t){if(t)return[Ln.Translate.toString(t),Ln.Scale.toString(t)].join(" ")}},Transition:{toString(t){let{property:e,duration:s,easing:n}=t;return e+" "+s+"ms "+n}}}),Fh="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function dC(t){return t.matches(Fh)?t:t.querySelector(Fh)}const uC={display:"none"};function hC(t){let{id:e,value:s}=t;return it.createElement("div",{id:e,style:uC},s)}function fC(t){let{id:e,announcement:s,ariaLiveType:n="assertive"}=t;const i={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return it.createElement("div",{id:e,style:i,role:"status","aria-live":n,"aria-atomic":!0},s)}function mC(){const[t,e]=A.useState("");return{announce:A.useCallback(n=>{n!=null&&e(n)},[]),announcement:t}}const Qp=A.createContext(null);function pC(t){const e=A.useContext(Qp);A.useEffect(()=>{if(!e)throw new Error("useDndMonitor must be used within a children of <DndContext>");return e(t)},[t,e])}function gC(){const[t]=A.useState(()=>new Set),e=A.useCallback(n=>(t.add(n),()=>t.delete(n)),[t]);return[A.useCallback(n=>{let{type:i,event:o}=n;t.forEach(a=>{var l;return(l=a[i])==null?void 0:l.call(a,o)})},[t]),e]}const xC={draggable:`
|
|
38
|
-
To pick up a draggable item, press the space bar.
|
|
39
|
-
While dragging, use the arrow keys to move the item.
|
|
40
|
-
Press space again to drop the item in its new position, or press escape to cancel.
|
|
41
|
-
`},vC={onDragStart(t){let{active:e}=t;return"Picked up draggable item "+e.id+"."},onDragOver(t){let{active:e,over:s}=t;return s?"Draggable item "+e.id+" was moved over droppable area "+s.id+".":"Draggable item "+e.id+" is no longer over a droppable area."},onDragEnd(t){let{active:e,over:s}=t;return s?"Draggable item "+e.id+" was dropped over droppable area "+s.id:"Draggable item "+e.id+" was dropped."},onDragCancel(t){let{active:e}=t;return"Dragging was cancelled. Draggable item "+e.id+" was dropped."}};function bC(t){let{announcements:e=vC,container:s,hiddenTextDescribedById:n,screenReaderInstructions:i=xC}=t;const{announce:o,announcement:a}=mC(),l=da("DndLiveRegion"),[c,d]=A.useState(!1);if(A.useEffect(()=>{d(!0)},[]),pC(A.useMemo(()=>({onDragStart(u){let{active:f}=u;o(e.onDragStart({active:f}))},onDragMove(u){let{active:f,over:m}=u;e.onDragMove&&o(e.onDragMove({active:f,over:m}))},onDragOver(u){let{active:f,over:m}=u;o(e.onDragOver({active:f,over:m}))},onDragEnd(u){let{active:f,over:m}=u;o(e.onDragEnd({active:f,over:m}))},onDragCancel(u){let{active:f,over:m}=u;o(e.onDragCancel({active:f,over:m}))}}),[o,e])),!c)return null;const h=it.createElement(it.Fragment,null,it.createElement(hC,{id:n,value:i.draggable}),it.createElement(fC,{id:l,announcement:a}));return s?tr.createPortal(h,s):h}var $t;(function(t){t.DragStart="dragStart",t.DragMove="dragMove",t.DragEnd="dragEnd",t.DragCancel="dragCancel",t.DragOver="dragOver",t.RegisterDroppable="registerDroppable",t.SetDroppableDisabled="setDroppableDisabled",t.UnregisterDroppable="unregisterDroppable"})($t||($t={}));function kl(){}function ti(t,e){return A.useMemo(()=>({sensor:t,options:e??{}}),[t,e])}function fc(){for(var t=arguments.length,e=new Array(t),s=0;s<t;s++)e[s]=arguments[s];return A.useMemo(()=>[...e].filter(n=>n!=null),[...e])}const rn=Object.freeze({x:0,y:0});function Zp(t,e){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function _C(t,e){const s=Cl(t);if(!s)return"0 0";const n={x:(s.x-e.left)/e.width*100,y:(s.y-e.top)/e.height*100};return n.x+"% "+n.y+"%"}function e3(t,e){let{data:{value:s}}=t,{data:{value:n}}=e;return s-n}function yC(t,e){let{data:{value:s}}=t,{data:{value:n}}=e;return n-s}function zh(t){let{left:e,top:s,height:n,width:i}=t;return[{x:e,y:s},{x:e+i,y:s},{x:e,y:s+n},{x:e+i,y:s+n}]}function t3(t,e){if(!t||t.length===0)return null;const[s]=t;return s[e]}function Kh(t,e,s){return e===void 0&&(e=t.left),s===void 0&&(s=t.top),{x:e+t.width*.5,y:s+t.height*.5}}const U9=t=>{let{collisionRect:e,droppableRects:s,droppableContainers:n}=t;const i=Kh(e,e.left,e.top),o=[];for(const a of n){const{id:l}=a,c=s.get(l);if(c){const d=Zp(Kh(c),i);o.push({id:l,data:{droppableContainer:a,value:d}})}}return o.sort(e3)},LC=t=>{let{collisionRect:e,droppableRects:s,droppableContainers:n}=t;const i=zh(e),o=[];for(const a of n){const{id:l}=a,c=s.get(l);if(c){const d=zh(c),h=i.reduce((f,m,p)=>f+Zp(d[p],m),0),u=Number((h/4).toFixed(4));o.push({id:l,data:{droppableContainer:a,value:u}})}}return o.sort(e3)};function SC(t,e){const s=Math.max(e.top,t.top),n=Math.max(e.left,t.left),i=Math.min(e.left+e.width,t.left+t.width),o=Math.min(e.top+e.height,t.top+t.height),a=i-n,l=o-s;if(n<i&&s<o){const c=e.width*e.height,d=t.width*t.height,h=a*l,u=h/(c+d-h);return Number(u.toFixed(4))}return 0}const wC=t=>{let{collisionRect:e,droppableRects:s,droppableContainers:n}=t;const i=[];for(const o of n){const{id:a}=o,l=s.get(a);if(l){const c=SC(l,e);c>0&&i.push({id:a,data:{droppableContainer:o,value:c}})}}return i.sort(yC)};function jC(t,e,s){return{...t,scaleX:e&&s?e.width/s.width:1,scaleY:e&&s?e.height/s.height:1}}function s3(t,e){return t&&e?{x:t.left-e.left,y:t.top-e.top}:rn}function CC(t){return function(s){for(var n=arguments.length,i=new Array(n>1?n-1:0),o=1;o<n;o++)i[o-1]=arguments[o];return i.reduce((a,l)=>({...a,top:a.top+t*l.y,bottom:a.bottom+t*l.y,left:a.left+t*l.x,right:a.right+t*l.x}),{...s})}}const kC=CC(1);function n3(t){if(t.startsWith("matrix3d(")){const e=t.slice(9,-1).split(/, /);return{x:+e[12],y:+e[13],scaleX:+e[0],scaleY:+e[5]}}else if(t.startsWith("matrix(")){const e=t.slice(7,-1).split(/, /);return{x:+e[4],y:+e[5],scaleX:+e[0],scaleY:+e[3]}}return null}function VC(t,e,s){const n=n3(e);if(!n)return t;const{scaleX:i,scaleY:o,x:a,y:l}=n,c=t.left-a-(1-i)*parseFloat(s),d=t.top-l-(1-o)*parseFloat(s.slice(s.indexOf(" ")+1)),h=i?t.width/i:t.width,u=o?t.height/o:t.height;return{width:h,height:u,top:d,right:c+h,bottom:d+u,left:c}}const NC={ignoreTransform:!1};function Or(t,e){e===void 0&&(e=NC);let s=t.getBoundingClientRect();if(e.ignoreTransform){const{transform:d,transformOrigin:h}=Ss(t).getComputedStyle(t);d&&(s=VC(s,d,h))}const{top:n,left:i,width:o,height:a,bottom:l,right:c}=s;return{top:n,left:i,width:o,height:a,bottom:l,right:c}}function Uh(t){return Or(t,{ignoreTransform:!0})}function TC(t){const e=t.innerWidth,s=t.innerHeight;return{top:0,left:0,right:e,bottom:s,width:e,height:s}}function AC(t,e){return e===void 0&&(e=Ss(t).getComputedStyle(t)),e.position==="fixed"}function EC(t,e){e===void 0&&(e=Ss(t).getComputedStyle(t));const s=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(i=>{const o=e[i];return typeof o=="string"?s.test(o):!1})}function mc(t,e){const s=[];function n(i){if(e!=null&&s.length>=e||!i)return s;if(K9(i)&&i.scrollingElement!=null&&!s.includes(i.scrollingElement))return s.push(i.scrollingElement),s;if(!la(i)||Jp(i)||s.includes(i))return s;const o=Ss(t).getComputedStyle(i);return i!==t&&EC(i,o)&&s.push(i),AC(i,o)?s:n(i.parentNode)}return t?n(t):s}function i3(t){const[e]=mc(t,1);return e??null}function Jc(t){return!dc||!t?null:Ir(t)?t:z9(t)?K9(t)||t===Mr(t).scrollingElement?window:la(t)?t:null:null}function r3(t){return Ir(t)?t.scrollX:t.scrollLeft}function o3(t){return Ir(t)?t.scrollY:t.scrollTop}function Fd(t){return{x:r3(t),y:o3(t)}}var Wt;(function(t){t[t.Forward=1]="Forward",t[t.Backward=-1]="Backward"})(Wt||(Wt={}));function a3(t){return!dc||!t?!1:t===document.scrollingElement}function l3(t){const e={x:0,y:0},s=a3(t)?{height:window.innerHeight,width:window.innerWidth}:{height:t.clientHeight,width:t.clientWidth},n={x:t.scrollWidth-s.width,y:t.scrollHeight-s.height},i=t.scrollTop<=e.y,o=t.scrollLeft<=e.x,a=t.scrollTop>=n.y,l=t.scrollLeft>=n.x;return{isTop:i,isLeft:o,isBottom:a,isRight:l,maxScroll:n,minScroll:e}}const PC={x:.2,y:.2};function RC(t,e,s,n,i){let{top:o,left:a,right:l,bottom:c}=s;n===void 0&&(n=10),i===void 0&&(i=PC);const{isTop:d,isBottom:h,isLeft:u,isRight:f}=l3(t),m={x:0,y:0},p={x:0,y:0},g={height:e.height*i.y,width:e.width*i.x};return!d&&o<=e.top+g.height?(m.y=Wt.Backward,p.y=n*Math.abs((e.top+g.height-o)/g.height)):!h&&c>=e.bottom-g.height&&(m.y=Wt.Forward,p.y=n*Math.abs((e.bottom-g.height-c)/g.height)),!f&&l>=e.right-g.width?(m.x=Wt.Forward,p.x=n*Math.abs((e.right-g.width-l)/g.width)):!u&&a<=e.left+g.width&&(m.x=Wt.Backward,p.x=n*Math.abs((e.left+g.width-a)/g.width)),{direction:m,speed:p}}function DC(t){if(t===document.scrollingElement){const{innerWidth:o,innerHeight:a}=window;return{top:0,left:0,right:o,bottom:a,width:o,height:a}}const{top:e,left:s,right:n,bottom:i}=t.getBoundingClientRect();return{top:e,left:s,right:n,bottom:i,width:t.clientWidth,height:t.clientHeight}}function c3(t){return t.reduce((e,s)=>or(e,Fd(s)),rn)}function IC(t){return t.reduce((e,s)=>e+r3(s),0)}function MC(t){return t.reduce((e,s)=>e+o3(s),0)}function d3(t,e){if(e===void 0&&(e=Or),!t)return;const{top:s,left:n,bottom:i,right:o}=e(t);i3(t)&&(i<=0||o<=0||s>=window.innerHeight||n>=window.innerWidth)&&t.scrollIntoView({block:"center",inline:"center"})}const OC=[["x",["left","right"],IC],["y",["top","bottom"],MC]];class H9{constructor(e,s){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const n=mc(s),i=c3(n);this.rect={...e},this.width=e.width,this.height=e.height;for(const[o,a,l]of OC)for(const c of a)Object.defineProperty(this,c,{get:()=>{const d=l(n),h=i[o]-d;return this.rect[c]+h},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class bo{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(s=>{var n;return(n=this.target)==null?void 0:n.removeEventListener(...s)})},this.target=e}add(e,s,n){var i;(i=this.target)==null||i.addEventListener(e,s,n),this.listeners.push([e,s,n])}}function BC(t){const{EventTarget:e}=Ss(t);return t instanceof e?t:Mr(t)}function Xc(t,e){const s=Math.abs(t.x),n=Math.abs(t.y);return typeof e=="number"?Math.sqrt(s**2+n**2)>e:"x"in e&&"y"in e?s>e.x&&n>e.y:"x"in e?s>e.x:"y"in e?n>e.y:!1}var Hs;(function(t){t.Click="click",t.DragStart="dragstart",t.Keydown="keydown",t.ContextMenu="contextmenu",t.Resize="resize",t.SelectionChange="selectionchange",t.VisibilityChange="visibilitychange"})(Hs||(Hs={}));function Hh(t){t.preventDefault()}function $C(t){t.stopPropagation()}var ot;(function(t){t.Space="Space",t.Down="ArrowDown",t.Right="ArrowRight",t.Left="ArrowLeft",t.Up="ArrowUp",t.Esc="Escape",t.Enter="Enter",t.Tab="Tab"})(ot||(ot={}));const u3={start:[ot.Space,ot.Enter],cancel:[ot.Esc],end:[ot.Space,ot.Enter,ot.Tab]},FC=(t,e)=>{let{currentCoordinates:s}=e;switch(t.code){case ot.Right:return{...s,x:s.x+25};case ot.Left:return{...s,x:s.x-25};case ot.Down:return{...s,y:s.y+25};case ot.Up:return{...s,y:s.y-25}}};class Br{constructor(e){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=e;const{event:{target:s}}=e;this.props=e,this.listeners=new bo(Mr(s)),this.windowListeners=new bo(Ss(s)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Hs.Resize,this.handleCancel),this.windowListeners.add(Hs.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Hs.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:e,onStart:s}=this.props,n=e.node.current;n&&d3(n),s(rn)}handleKeyDown(e){if(hc(e)){const{active:s,context:n,options:i}=this.props,{keyboardCodes:o=u3,coordinateGetter:a=FC,scrollBehavior:l="smooth"}=i,{code:c}=e;if(o.end.includes(c)){this.handleEnd(e);return}if(o.cancel.includes(c)){this.handleCancel(e);return}const{collisionRect:d}=n.current,h=d?{x:d.left,y:d.top}:rn;this.referenceCoordinates||(this.referenceCoordinates=h);const u=a(e,{active:s,context:n.current,currentCoordinates:h});if(u){const f=Fo(u,h),m={x:0,y:0},{scrollableAncestors:p}=n.current;for(const g of p){const x=e.code,{isTop:v,isRight:b,isLeft:y,isBottom:_,maxScroll:L,minScroll:w}=l3(g),j=DC(g),S={x:Math.min(x===ot.Right?j.right-j.width/2:j.right,Math.max(x===ot.Right?j.left:j.left+j.width/2,u.x)),y:Math.min(x===ot.Down?j.bottom-j.height/2:j.bottom,Math.max(x===ot.Down?j.top:j.top+j.height/2,u.y))},C=x===ot.Right&&!b||x===ot.Left&&!y,N=x===ot.Down&&!_||x===ot.Up&&!v;if(C&&S.x!==u.x){const V=g.scrollLeft+f.x,E=x===ot.Right&&V<=L.x||x===ot.Left&&V>=w.x;if(E&&!f.y){g.scrollTo({left:V,behavior:l});return}E?m.x=g.scrollLeft-V:m.x=x===ot.Right?g.scrollLeft-L.x:g.scrollLeft-w.x,m.x&&g.scrollBy({left:-m.x,behavior:l});break}else if(N&&S.y!==u.y){const V=g.scrollTop+f.y,E=x===ot.Down&&V<=L.y||x===ot.Up&&V>=w.y;if(E&&!f.x){g.scrollTo({top:V,behavior:l});return}E?m.y=g.scrollTop-V:m.y=x===ot.Down?g.scrollTop-L.y:g.scrollTop-w.y,m.y&&g.scrollBy({top:-m.y,behavior:l});break}}this.handleMove(e,or(Fo(u,this.referenceCoordinates),m))}}}handleMove(e,s){const{onMove:n}=this.props;e.preventDefault(),n(s)}handleEnd(e){const{onEnd:s}=this.props;e.preventDefault(),this.detach(),s()}handleCancel(e){const{onCancel:s}=this.props;e.preventDefault(),this.detach(),s()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}Br.activators=[{eventName:"onKeyDown",handler:(t,e,s)=>{let{keyboardCodes:n=u3,onActivation:i}=e,{active:o}=s;const{code:a}=t.nativeEvent;if(n.start.includes(a)){const l=o.activatorNode.current;return l&&t.target!==l?!1:(t.preventDefault(),i?.({event:t.nativeEvent}),!0)}return!1}}];function Wh(t){return!!(t&&"distance"in t)}function qh(t){return!!(t&&"delay"in t)}class W9{constructor(e,s,n){var i;n===void 0&&(n=BC(e.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=e,this.events=s;const{event:o}=e,{target:a}=o;this.props=e,this.events=s,this.document=Mr(a),this.documentListeners=new bo(this.document),this.listeners=new bo(n),this.windowListeners=new bo(Ss(a)),this.initialCoordinates=(i=Cl(o))!=null?i:rn,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:e,props:{options:{activationConstraint:s,bypassActivationConstraint:n}}}=this;if(this.listeners.add(e.move.name,this.handleMove,{passive:!1}),this.listeners.add(e.end.name,this.handleEnd),e.cancel&&this.listeners.add(e.cancel.name,this.handleCancel),this.windowListeners.add(Hs.Resize,this.handleCancel),this.windowListeners.add(Hs.DragStart,Hh),this.windowListeners.add(Hs.VisibilityChange,this.handleCancel),this.windowListeners.add(Hs.ContextMenu,Hh),this.documentListeners.add(Hs.Keydown,this.handleKeydown),s){if(n!=null&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(qh(s)){this.timeoutId=setTimeout(this.handleStart,s.delay),this.handlePending(s);return}if(Wh(s)){this.handlePending(s);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(e,s){const{active:n,onPending:i}=this.props;i(n,e,this.initialCoordinates,s)}handleStart(){const{initialCoordinates:e}=this,{onStart:s}=this.props;e&&(this.activated=!0,this.documentListeners.add(Hs.Click,$C,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Hs.SelectionChange,this.removeTextSelection),s(e))}handleMove(e){var s;const{activated:n,initialCoordinates:i,props:o}=this,{onMove:a,options:{activationConstraint:l}}=o;if(!i)return;const c=(s=Cl(e))!=null?s:rn,d=Fo(i,c);if(!n&&l){if(Wh(l)){if(l.tolerance!=null&&Xc(d,l.tolerance))return this.handleCancel();if(Xc(d,l.distance))return this.handleStart()}if(qh(l)&&Xc(d,l.tolerance))return this.handleCancel();this.handlePending(l,d);return}e.cancelable&&e.preventDefault(),a(c)}handleEnd(){const{onAbort:e,onEnd:s}=this.props;this.detach(),this.activated||e(this.props.active),s()}handleCancel(){const{onAbort:e,onCancel:s}=this.props;this.detach(),this.activated||e(this.props.active),s()}handleKeydown(e){e.code===ot.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}}const zC={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class $r extends W9{constructor(e){const{event:s}=e,n=Mr(s.target);super(e,zC,n)}}$r.activators=[{eventName:"onPointerDown",handler:(t,e)=>{let{nativeEvent:s}=t,{onActivation:n}=e;return!s.isPrimary||s.button!==0?!1:(n?.({event:s}),!0)}}];const KC={move:{name:"mousemove"},end:{name:"mouseup"}};var zd;(function(t){t[t.RightClick=2]="RightClick"})(zd||(zd={}));class UC extends W9{constructor(e){super(e,KC,Mr(e.event.target))}}UC.activators=[{eventName:"onMouseDown",handler:(t,e)=>{let{nativeEvent:s}=t,{onActivation:n}=e;return s.button===zd.RightClick?!1:(n?.({event:s}),!0)}}];const Qc={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class HC extends W9{constructor(e){super(e,Qc)}static setup(){return window.addEventListener(Qc.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(Qc.move.name,e)};function e(){}}}HC.activators=[{eventName:"onTouchStart",handler:(t,e)=>{let{nativeEvent:s}=t,{onActivation:n}=e;const{touches:i}=s;return i.length>1?!1:(n?.({event:s}),!0)}}];var _o;(function(t){t[t.Pointer=0]="Pointer",t[t.DraggableRect=1]="DraggableRect"})(_o||(_o={}));var Vl;(function(t){t[t.TreeOrder=0]="TreeOrder",t[t.ReversedTreeOrder=1]="ReversedTreeOrder"})(Vl||(Vl={}));function WC(t){let{acceleration:e,activator:s=_o.Pointer,canScroll:n,draggingRect:i,enabled:o,interval:a=5,order:l=Vl.TreeOrder,pointerCoordinates:c,scrollableAncestors:d,scrollableAncestorRects:h,delta:u,threshold:f}=t;const m=GC({delta:u,disabled:!o}),[p,g]=aC(),x=A.useRef({x:0,y:0}),v=A.useRef({x:0,y:0}),b=A.useMemo(()=>{switch(s){case _o.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case _o.DraggableRect:return i}},[s,i,c]),y=A.useRef(null),_=A.useCallback(()=>{const w=y.current;if(!w)return;const j=x.current.x*v.current.x,S=x.current.y*v.current.y;w.scrollBy(j,S)},[]),L=A.useMemo(()=>l===Vl.TreeOrder?[...d].reverse():d,[l,d]);A.useEffect(()=>{if(!o||!d.length||!b){g();return}for(const w of L){if(n?.(w)===!1)continue;const j=d.indexOf(w),S=h[j];if(!S)continue;const{direction:C,speed:N}=RC(w,S,b,e,f);for(const V of["x","y"])m[V][C[V]]||(N[V]=0,C[V]=0);if(N.x>0||N.y>0){g(),y.current=w,p(_,a),x.current=N,v.current=C;return}}x.current={x:0,y:0},v.current={x:0,y:0},g()},[e,_,n,g,o,a,JSON.stringify(b),JSON.stringify(m),p,d,L,h,JSON.stringify(f)])}const qC={x:{[Wt.Backward]:!1,[Wt.Forward]:!1},y:{[Wt.Backward]:!1,[Wt.Forward]:!1}};function GC(t){let{delta:e,disabled:s}=t;const n=jl(e);return ca(i=>{if(s||!n||!i)return qC;const o={x:Math.sign(e.x-n.x),y:Math.sign(e.y-n.y)};return{x:{[Wt.Backward]:i.x[Wt.Backward]||o.x===-1,[Wt.Forward]:i.x[Wt.Forward]||o.x===1},y:{[Wt.Backward]:i.y[Wt.Backward]||o.y===-1,[Wt.Forward]:i.y[Wt.Forward]||o.y===1}}},[s,e,n])}function YC(t,e){const s=e!=null?t.get(e):void 0,n=s?s.node.current:null;return ca(i=>{var o;return e==null?null:(o=n??i)!=null?o:null},[n,e])}function JC(t,e){return A.useMemo(()=>t.reduce((s,n)=>{const{sensor:i}=n,o=i.activators.map(a=>({eventName:a.eventName,handler:e(a.handler,n)}));return[...s,...o]},[]),[t,e])}var zo;(function(t){t[t.Always=0]="Always",t[t.BeforeDragging=1]="BeforeDragging",t[t.WhileDragging=2]="WhileDragging"})(zo||(zo={}));var Kd;(function(t){t.Optimized="optimized"})(Kd||(Kd={}));const Gh=new Map;function XC(t,e){let{dragging:s,dependencies:n,config:i}=e;const[o,a]=A.useState(null),{frequency:l,measure:c,strategy:d}=i,h=A.useRef(t),u=x(),f=$o(u),m=A.useCallback(function(v){v===void 0&&(v=[]),!f.current&&a(b=>b===null?v:b.concat(v.filter(y=>!b.includes(y))))},[f]),p=A.useRef(null),g=ca(v=>{if(u&&!s)return Gh;if(!v||v===Gh||h.current!==t||o!=null){const b=new Map;for(let y of t){if(!y)continue;if(o&&o.length>0&&!o.includes(y.id)&&y.rect.current){b.set(y.id,y.rect.current);continue}const _=y.node.current,L=_?new H9(c(_),_):null;y.rect.current=L,L&&b.set(y.id,L)}return b}return v},[t,o,s,u,c]);return A.useEffect(()=>{h.current=t},[t]),A.useEffect(()=>{u||m()},[s,u]),A.useEffect(()=>{o&&o.length>0&&a(null)},[JSON.stringify(o)]),A.useEffect(()=>{u||typeof l!="number"||p.current!==null||(p.current=setTimeout(()=>{m(),p.current=null},l))},[l,u,m,...n]),{droppableRects:g,measureDroppableContainers:m,measuringScheduled:o!=null};function x(){switch(d){case zo.Always:return!1;case zo.BeforeDragging:return s;default:return!s}}}function q9(t,e){return ca(s=>t?s||(typeof e=="function"?e(t):t):null,[e,t])}function QC(t,e){return q9(t,e)}function ZC(t){let{callback:e,disabled:s}=t;const n=uc(e),i=A.useMemo(()=>{if(s||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:o}=window;return new o(n)},[n,s]);return A.useEffect(()=>()=>i?.disconnect(),[i]),i}function pc(t){let{callback:e,disabled:s}=t;const n=uc(e),i=A.useMemo(()=>{if(s||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:o}=window;return new o(n)},[s]);return A.useEffect(()=>()=>i?.disconnect(),[i]),i}function ek(t){return new H9(Or(t),t)}function Yh(t,e,s){e===void 0&&(e=ek);const[n,i]=A.useState(null);function o(){i(c=>{if(!t)return null;if(t.isConnected===!1){var d;return(d=c??s)!=null?d:null}const h=e(t);return JSON.stringify(c)===JSON.stringify(h)?c:h})}const a=ZC({callback(c){if(t)for(const d of c){const{type:h,target:u}=d;if(h==="childList"&&u instanceof HTMLElement&&u.contains(t)){o();break}}}}),l=pc({callback:o});return nn(()=>{o(),t?(l?.observe(t),a?.observe(document.body,{childList:!0,subtree:!0})):(l?.disconnect(),a?.disconnect())},[t]),n}function tk(t){const e=q9(t);return s3(t,e)}const Jh=[];function sk(t){const e=A.useRef(t),s=ca(n=>t?n&&n!==Jh&&t&&e.current&&t.parentNode===e.current.parentNode?n:mc(t):Jh,[t]);return A.useEffect(()=>{e.current=t},[t]),s}function nk(t){const[e,s]=A.useState(null),n=A.useRef(t),i=A.useCallback(o=>{const a=Jc(o.target);a&&s(l=>l?(l.set(a,Fd(a)),new Map(l)):null)},[]);return A.useEffect(()=>{const o=n.current;if(t!==o){a(o);const l=t.map(c=>{const d=Jc(c);return d?(d.addEventListener("scroll",i,{passive:!0}),[d,Fd(d)]):null}).filter(c=>c!=null);s(l.length?new Map(l):null),n.current=t}return()=>{a(t),a(o)};function a(l){l.forEach(c=>{const d=Jc(c);d?.removeEventListener("scroll",i)})}},[i,t]),A.useMemo(()=>t.length?e?Array.from(e.values()).reduce((o,a)=>or(o,a),rn):c3(t):rn,[t,e])}function Xh(t,e){e===void 0&&(e=[]);const s=A.useRef(null);return A.useEffect(()=>{s.current=null},e),A.useEffect(()=>{const n=t!==rn;n&&!s.current&&(s.current=t),!n&&s.current&&(s.current=null)},[t]),s.current?Fo(t,s.current):rn}function ik(t){A.useEffect(()=>{if(!dc)return;const e=t.map(s=>{let{sensor:n}=s;return n.setup==null?void 0:n.setup()});return()=>{for(const s of e)s?.()}},t.map(e=>{let{sensor:s}=e;return s}))}function rk(t,e){return A.useMemo(()=>t.reduce((s,n)=>{let{eventName:i,handler:o}=n;return s[i]=a=>{o(a,e)},s},{}),[t,e])}function h3(t){return A.useMemo(()=>t?TC(t):null,[t])}const Qh=[];function ok(t,e){e===void 0&&(e=Or);const[s]=t,n=h3(s?Ss(s):null),[i,o]=A.useState(Qh);function a(){o(()=>t.length?t.map(c=>a3(c)?n:new H9(e(c),c)):Qh)}const l=pc({callback:a});return nn(()=>{l?.disconnect(),a(),t.forEach(c=>l?.observe(c))},[t]),i}function f3(t){if(!t)return null;if(t.children.length>1)return t;const e=t.children[0];return la(e)?e:t}function ak(t){let{measure:e}=t;const[s,n]=A.useState(null),i=A.useCallback(d=>{for(const{target:h}of d)if(la(h)){n(u=>{const f=e(h);return u?{...u,width:f.width,height:f.height}:f});break}},[e]),o=pc({callback:i}),a=A.useCallback(d=>{const h=f3(d);o?.disconnect(),h&&o?.observe(h),n(h?e(h):null)},[e,o]),[l,c]=wl(a);return A.useMemo(()=>({nodeRef:l,rect:s,setRef:c}),[s,l,c])}const lk=[{sensor:$r,options:{}},{sensor:Br,options:{}}],ck={current:{}},Ua={draggable:{measure:Uh},droppable:{measure:Uh,strategy:zo.WhileDragging,frequency:Kd.Optimized},dragOverlay:{measure:Or}};class yo extends Map{get(e){var s;return e!=null&&(s=super.get(e))!=null?s:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(e=>{let{disabled:s}=e;return!s})}getNodeFor(e){var s,n;return(s=(n=this.get(e))==null?void 0:n.node.current)!=null?s:void 0}}const dk={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new yo,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:kl},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Ua,measureDroppableContainers:kl,windowRect:null,measuringScheduled:!1},m3={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:kl,draggableNodes:new Map,over:null,measureDroppableContainers:kl},ua=A.createContext(m3),p3=A.createContext(dk);function uk(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new yo}}}function hk(t,e){switch(e.type){case $t.DragStart:return{...t,draggable:{...t.draggable,initialCoordinates:e.initialCoordinates,active:e.active}};case $t.DragMove:return t.draggable.active==null?t:{...t,draggable:{...t.draggable,translate:{x:e.coordinates.x-t.draggable.initialCoordinates.x,y:e.coordinates.y-t.draggable.initialCoordinates.y}}};case $t.DragEnd:case $t.DragCancel:return{...t,draggable:{...t.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case $t.RegisterDroppable:{const{element:s}=e,{id:n}=s,i=new yo(t.droppable.containers);return i.set(n,s),{...t,droppable:{...t.droppable,containers:i}}}case $t.SetDroppableDisabled:{const{id:s,key:n,disabled:i}=e,o=t.droppable.containers.get(s);if(!o||n!==o.key)return t;const a=new yo(t.droppable.containers);return a.set(s,{...o,disabled:i}),{...t,droppable:{...t.droppable,containers:a}}}case $t.UnregisterDroppable:{const{id:s,key:n}=e,i=t.droppable.containers.get(s);if(!i||n!==i.key)return t;const o=new yo(t.droppable.containers);return o.delete(s),{...t,droppable:{...t.droppable,containers:o}}}default:return t}}function fk(t){let{disabled:e}=t;const{active:s,activatorEvent:n,draggableNodes:i}=A.useContext(ua),o=jl(n),a=jl(s?.id);return A.useEffect(()=>{if(!e&&!n&&o&&a!=null){if(!hc(o)||document.activeElement===o.target)return;const l=i.get(a);if(!l)return;const{activatorNode:c,node:d}=l;if(!c.current&&!d.current)return;requestAnimationFrame(()=>{for(const h of[c.current,d.current]){if(!h)continue;const u=dC(h);if(u){u.focus();break}}})}},[n,e,i,a,o]),null}function g3(t,e){let{transform:s,...n}=e;return t!=null&&t.length?t.reduce((i,o)=>o({transform:i,...n}),s):s}function mk(t){return A.useMemo(()=>({draggable:{...Ua.draggable,...t?.draggable},droppable:{...Ua.droppable,...t?.droppable},dragOverlay:{...Ua.dragOverlay,...t?.dragOverlay}}),[t?.draggable,t?.droppable,t?.dragOverlay])}function pk(t){let{activeNode:e,measure:s,initialRect:n,config:i=!0}=t;const o=A.useRef(!1),{x:a,y:l}=typeof i=="boolean"?{x:i,y:i}:i;nn(()=>{if(!a&&!l||!e){o.current=!1;return}if(o.current||!n)return;const d=e?.node.current;if(!d||d.isConnected===!1)return;const h=s(d),u=s3(h,n);if(a||(u.x=0),l||(u.y=0),o.current=!0,Math.abs(u.x)>0||Math.abs(u.y)>0){const f=i3(d);f&&f.scrollBy({top:u.y,left:u.x})}},[e,a,l,n,s])}const gc=A.createContext({...rn,scaleX:1,scaleY:1});var Kn;(function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Initializing=1]="Initializing",t[t.Initialized=2]="Initialized"})(Kn||(Kn={}));const xc=A.memo(function(e){var s,n,i,o;let{id:a,accessibility:l,autoScroll:c=!0,children:d,sensors:h=lk,collisionDetection:u=wC,measuring:f,modifiers:m,...p}=e;const g=A.useReducer(hk,void 0,uk),[x,v]=g,[b,y]=gC(),[_,L]=A.useState(Kn.Uninitialized),w=_===Kn.Initialized,{draggable:{active:j,nodes:S,translate:C},droppable:{containers:N}}=x,V=j!=null?S.get(j):null,E=A.useRef({initial:null,translated:null}),T=A.useMemo(()=>{var Be;return j!=null?{id:j,data:(Be=V?.data)!=null?Be:ck,rect:E}:null},[j,V]),k=A.useRef(null),[R,P]=A.useState(null),[D,I]=A.useState(null),M=$o(p,Object.values(p)),O=da("DndDescribedBy",a),$=A.useMemo(()=>N.getEnabled(),[N]),B=mk(f),{droppableRects:z,measureDroppableContainers:K,measuringScheduled:G}=XC($,{dragging:w,dependencies:[C.x,C.y],config:B.droppable}),Y=YC(S,j),U=A.useMemo(()=>D?Cl(D):null,[D]),W=Se(),H=QC(Y,B.draggable.measure);pk({activeNode:j!=null?S.get(j):null,config:W.layoutShiftCompensation,initialRect:H,measure:B.draggable.measure});const X=Yh(Y,B.draggable.measure,H),q=Yh(Y?Y.parentElement:null),Z=A.useRef({activatorEvent:null,active:null,activeNode:Y,collisionRect:null,collisions:null,droppableRects:z,draggableNodes:S,draggingNode:null,draggingNodeRect:null,droppableContainers:N,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),Q=N.getNodeFor((s=Z.current.over)==null?void 0:s.id),ee=ak({measure:B.dragOverlay.measure}),J=(n=ee.nodeRef.current)!=null?n:Y,te=w?(i=ee.rect)!=null?i:X:null,se=!!(ee.nodeRef.current&&ee.rect),ne=tk(se?null:X),de=h3(J?Ss(J):null),xe=sk(w?Q??Y:null),ue=ok(xe),ce=g3(m,{transform:{x:C.x-ne.x,y:C.y-ne.y,scaleX:1,scaleY:1},activatorEvent:D,active:T,activeNodeRect:X,containerNodeRect:q,draggingNodeRect:te,over:Z.current.over,overlayNodeRect:ee.rect,scrollableAncestors:xe,scrollableAncestorRects:ue,windowRect:de}),oe=U?or(U,C):null,fe=nk(xe),pe=Xh(fe),we=Xh(fe,[X]),Ne=or(ce,pe),Fe=te?kC(te,ce):null,je=T&&Fe?u({active:T,collisionRect:Fe,droppableRects:z,droppableContainers:$,pointerCoordinates:oe}):null,Ie=t3(je,"id"),[Pe,Ye]=A.useState(null),_e=se?ce:or(ce,we),Ae=jC(_e,(o=Pe?.rect)!=null?o:null,X),Re=A.useRef(null),ye=A.useCallback((Be,nt)=>{let{sensor:pt,options:Je}=nt;if(k.current==null)return;const gt=S.get(k.current);if(!gt)return;const dt=Be.nativeEvent,st=new pt({active:k.current,activeNode:gt,event:dt,options:Je,context:Z,onAbort(me){if(!S.get(me))return;const{onDragAbort:Qe}=M.current,xt={id:me};Qe?.(xt),b({type:"onDragAbort",event:xt})},onPending(me,De,Qe,xt){if(!S.get(me))return;const{onDragPending:Vt}=M.current,Ut={id:me,constraint:De,initialCoordinates:Qe,offset:xt};Vt?.(Ut),b({type:"onDragPending",event:Ut})},onStart(me){const De=k.current;if(De==null)return;const Qe=S.get(De);if(!Qe)return;const{onDragStart:xt}=M.current,ls={activatorEvent:dt,active:{id:De,data:Qe.data,rect:E}};tr.unstable_batchedUpdates(()=>{xt?.(ls),L(Kn.Initializing),v({type:$t.DragStart,initialCoordinates:me,active:De}),b({type:"onDragStart",event:ls}),P(Re.current),I(dt)})},onMove(me){v({type:$t.DragMove,coordinates:me})},onEnd:ft($t.DragEnd),onCancel:ft($t.DragCancel)});Re.current=st;function ft(me){return async function(){const{active:Qe,collisions:xt,over:ls,scrollAdjustedTranslate:Vt}=Z.current;let Ut=null;if(Qe&&Vt){const{cancelDrop:is}=M.current;Ut={activatorEvent:dt,active:Qe,collisions:xt,delta:Vt,over:ls},me===$t.DragEnd&&typeof is=="function"&&await Promise.resolve(is(Ut))&&(me=$t.DragCancel)}k.current=null,tr.unstable_batchedUpdates(()=>{v({type:me}),L(Kn.Uninitialized),Ye(null),P(null),I(null),Re.current=null;const is=me===$t.DragEnd?"onDragEnd":"onDragCancel";if(Ut){const He=M.current[is];He?.(Ut),b({type:is,event:Ut})}})}}},[S]),ve=A.useCallback((Be,nt)=>(pt,Je)=>{const gt=pt.nativeEvent,dt=S.get(Je);if(k.current!==null||!dt||gt.dndKit||gt.defaultPrevented)return;const st={active:dt};Be(pt,nt.options,st)===!0&&(gt.dndKit={capturedBy:nt.sensor},k.current=Je,ye(pt,nt))},[S,ye]),Le=JC(h,ve);ik(h),nn(()=>{X&&_===Kn.Initializing&&L(Kn.Initialized)},[X,_]),A.useEffect(()=>{const{onDragMove:Be}=M.current,{active:nt,activatorEvent:pt,collisions:Je,over:gt}=Z.current;if(!nt||!pt)return;const dt={active:nt,activatorEvent:pt,collisions:Je,delta:{x:Ne.x,y:Ne.y},over:gt};tr.unstable_batchedUpdates(()=>{Be?.(dt),b({type:"onDragMove",event:dt})})},[Ne.x,Ne.y]),A.useEffect(()=>{const{active:Be,activatorEvent:nt,collisions:pt,droppableContainers:Je,scrollAdjustedTranslate:gt}=Z.current;if(!Be||k.current==null||!nt||!gt)return;const{onDragOver:dt}=M.current,st=Je.get(Ie),ft=st&&st.rect.current?{id:st.id,rect:st.rect.current,data:st.data,disabled:st.disabled}:null,me={active:Be,activatorEvent:nt,collisions:pt,delta:{x:gt.x,y:gt.y},over:ft};tr.unstable_batchedUpdates(()=>{Ye(ft),dt?.(me),b({type:"onDragOver",event:me})})},[Ie]),nn(()=>{Z.current={activatorEvent:D,active:T,activeNode:Y,collisionRect:Fe,collisions:je,droppableRects:z,draggableNodes:S,draggingNode:J,draggingNodeRect:te,droppableContainers:N,over:Pe,scrollableAncestors:xe,scrollAdjustedTranslate:Ne},E.current={initial:te,translated:Fe}},[T,Y,je,Fe,S,J,te,z,N,Pe,xe,Ne]),WC({...W,delta:C,draggingRect:Fe,pointerCoordinates:oe,scrollableAncestors:xe,scrollableAncestorRects:ue});const $e=A.useMemo(()=>({active:T,activeNode:Y,activeNodeRect:X,activatorEvent:D,collisions:je,containerNodeRect:q,dragOverlay:ee,draggableNodes:S,droppableContainers:N,droppableRects:z,over:Pe,measureDroppableContainers:K,scrollableAncestors:xe,scrollableAncestorRects:ue,measuringConfiguration:B,measuringScheduled:G,windowRect:de}),[T,Y,X,D,je,q,ee,S,N,z,Pe,K,xe,ue,B,G,de]),ke=A.useMemo(()=>({activatorEvent:D,activators:Le,active:T,activeNodeRect:X,ariaDescribedById:{draggable:O},dispatch:v,draggableNodes:S,over:Pe,measureDroppableContainers:K}),[D,Le,T,X,v,O,S,Pe,K]);return it.createElement(Qp.Provider,{value:y},it.createElement(ua.Provider,{value:ke},it.createElement(p3.Provider,{value:$e},it.createElement(gc.Provider,{value:Ae},d)),it.createElement(fk,{disabled:l?.restoreFocus===!1})),it.createElement(bC,{...l,hiddenTextDescribedById:O}));function Se(){const Be=R?.autoScrollEnabled===!1,nt=typeof c=="object"?c.enabled===!1:c===!1,pt=w&&!Be&&!nt;return typeof c=="object"?{...c,enabled:pt}:{enabled:pt}}}),gk=A.createContext(null),Zh="button",xk="Draggable";function x3(t){let{id:e,data:s,disabled:n=!1,attributes:i}=t;const o=da(xk),{activators:a,activatorEvent:l,active:c,activeNodeRect:d,ariaDescribedById:h,draggableNodes:u,over:f}=A.useContext(ua),{role:m=Zh,roleDescription:p="draggable",tabIndex:g=0}=i??{},x=c?.id===e,v=A.useContext(x?gc:gk),[b,y]=wl(),[_,L]=wl(),w=rk(a,e),j=$o(s);nn(()=>(u.set(e,{id:e,key:o,node:b,activatorNode:_,data:j}),()=>{const C=u.get(e);C&&C.key===o&&u.delete(e)}),[u,e]);const S=A.useMemo(()=>({role:m,tabIndex:g,"aria-disabled":n,"aria-pressed":x&&m===Zh?!0:void 0,"aria-roledescription":p,"aria-describedby":h.draggable}),[n,m,g,x,p,h.draggable]);return{active:c,activatorEvent:l,activeNodeRect:d,attributes:S,isDragging:x,listeners:n?void 0:w,node:b,over:f,setNodeRef:y,setActivatorNodeRef:L,transform:v}}function v3(){return A.useContext(p3)}const vk="Droppable",bk={timeout:25};function _k(t){let{data:e,disabled:s=!1,id:n,resizeObserverConfig:i}=t;const o=da(vk),{active:a,dispatch:l,over:c,measureDroppableContainers:d}=A.useContext(ua),h=A.useRef({disabled:s}),u=A.useRef(!1),f=A.useRef(null),m=A.useRef(null),{disabled:p,updateMeasurementsFor:g,timeout:x}={...bk,...i},v=$o(g??n),b=A.useCallback(()=>{if(!u.current){u.current=!0;return}m.current!=null&&clearTimeout(m.current),m.current=setTimeout(()=>{d(Array.isArray(v.current)?v.current:[v.current]),m.current=null},x)},[x]),y=pc({callback:b,disabled:p||!a}),_=A.useCallback((S,C)=>{y&&(C&&(y.unobserve(C),u.current=!1),S&&y.observe(S))},[y]),[L,w]=wl(_),j=$o(e);return A.useEffect(()=>{!y||!L.current||(y.disconnect(),u.current=!1,y.observe(L.current))},[L,y]),A.useEffect(()=>(l({type:$t.RegisterDroppable,element:{id:n,key:o,disabled:s,node:L,rect:f,data:j}}),()=>l({type:$t.UnregisterDroppable,key:o,id:n})),[n]),A.useEffect(()=>{s!==h.current.disabled&&(l({type:$t.SetDroppableDisabled,id:n,key:o,disabled:s}),h.current.disabled=s)},[n,o,s,l]),{active:a,rect:f,isOver:c?.id===n,node:L,over:c,setNodeRef:w}}function yk(t){let{animation:e,children:s}=t;const[n,i]=A.useState(null),[o,a]=A.useState(null),l=jl(s);return!s&&!n&&l&&i(l),nn(()=>{if(!o)return;const c=n?.key,d=n?.props.id;if(c==null||d==null){i(null);return}Promise.resolve(e(d,o)).then(()=>{i(null)})},[e,n,o]),it.createElement(it.Fragment,null,s,n?A.cloneElement(n,{ref:a}):null)}const Lk={x:0,y:0,scaleX:1,scaleY:1};function Sk(t){let{children:e}=t;return it.createElement(ua.Provider,{value:m3},it.createElement(gc.Provider,{value:Lk},e))}const wk={position:"fixed",touchAction:"none"},jk=t=>hc(t)?"transform 250ms ease":void 0,Ck=A.forwardRef((t,e)=>{let{as:s,activatorEvent:n,adjustScale:i,children:o,className:a,rect:l,style:c,transform:d,transition:h=jk}=t;if(!l)return null;const u=i?d:{...d,scaleX:1,scaleY:1},f={...wk,width:l.width,height:l.height,top:l.top,left:l.left,transform:Ln.Transform.toString(u),transformOrigin:i&&n?_C(n,l):void 0,transition:typeof h=="function"?h(n):h,...c};return it.createElement(s,{className:a,style:f,ref:e},o)}),kk=t=>e=>{let{active:s,dragOverlay:n}=e;const i={},{styles:o,className:a}=t;if(o!=null&&o.active)for(const[l,c]of Object.entries(o.active))c!==void 0&&(i[l]=s.node.style.getPropertyValue(l),s.node.style.setProperty(l,c));if(o!=null&&o.dragOverlay)for(const[l,c]of Object.entries(o.dragOverlay))c!==void 0&&n.node.style.setProperty(l,c);return a!=null&&a.active&&s.node.classList.add(a.active),a!=null&&a.dragOverlay&&n.node.classList.add(a.dragOverlay),function(){for(const[c,d]of Object.entries(i))s.node.style.setProperty(c,d);a!=null&&a.active&&s.node.classList.remove(a.active)}},Vk=t=>{let{transform:{initial:e,final:s}}=t;return[{transform:Ln.Transform.toString(e)},{transform:Ln.Transform.toString(s)}]},Nk={duration:250,easing:"ease",keyframes:Vk,sideEffects:kk({styles:{active:{opacity:"0"}}})};function Tk(t){let{config:e,draggableNodes:s,droppableContainers:n,measuringConfiguration:i}=t;return uc((o,a)=>{if(e===null)return;const l=s.get(o);if(!l)return;const c=l.node.current;if(!c)return;const d=f3(a);if(!d)return;const{transform:h}=Ss(a).getComputedStyle(a),u=n3(h);if(!u)return;const f=typeof e=="function"?e:Ak(e);return d3(c,i.draggable.measure),f({active:{id:o,data:l.data,node:c,rect:i.draggable.measure(c)},draggableNodes:s,dragOverlay:{node:a,rect:i.dragOverlay.measure(d)},droppableContainers:n,measuringConfiguration:i,transform:u})})}function Ak(t){const{duration:e,easing:s,sideEffects:n,keyframes:i}={...Nk,...t};return o=>{let{active:a,dragOverlay:l,transform:c,...d}=o;if(!e)return;const h={x:l.rect.left-a.rect.left,y:l.rect.top-a.rect.top},u={scaleX:c.scaleX!==1?a.rect.width*c.scaleX/l.rect.width:1,scaleY:c.scaleY!==1?a.rect.height*c.scaleY/l.rect.height:1},f={x:c.x-h.x,y:c.y-h.y,...u},m=i({...d,active:a,dragOverlay:l,transform:{initial:c,final:f}}),[p]=m,g=m[m.length-1];if(JSON.stringify(p)===JSON.stringify(g))return;const x=n?.({active:a,dragOverlay:l,...d}),v=l.node.animate(m,{duration:e,easing:s,fill:"forwards"});return new Promise(b=>{v.onfinish=()=>{x?.(),b()}})}}let ef=0;function Ek(t){return A.useMemo(()=>{if(t!=null)return ef++,ef},[t])}const G9=it.memo(t=>{let{adjustScale:e=!1,children:s,dropAnimation:n,style:i,transition:o,modifiers:a,wrapperElement:l="div",className:c,zIndex:d=999}=t;const{activatorEvent:h,active:u,activeNodeRect:f,containerNodeRect:m,draggableNodes:p,droppableContainers:g,dragOverlay:x,over:v,measuringConfiguration:b,scrollableAncestors:y,scrollableAncestorRects:_,windowRect:L}=v3(),w=A.useContext(gc),j=Ek(u?.id),S=g3(a,{activatorEvent:h,active:u,activeNodeRect:f,containerNodeRect:m,draggingNodeRect:x.rect,over:v,overlayNodeRect:x.rect,scrollableAncestors:y,scrollableAncestorRects:_,transform:w,windowRect:L}),C=q9(f),N=Tk({config:n,draggableNodes:p,droppableContainers:g,measuringConfiguration:b}),V=C?x.setRef:void 0;return it.createElement(Sk,null,it.createElement(yk,{animation:N},u&&j?it.createElement(Ck,{key:j,id:u.id,ref:V,as:l,activatorEvent:h,adjustScale:e,className:c,transition:o,rect:C,style:{zIndex:d,...i},transform:S},s):null))}),on=6,Vn=100,tf=12,Pk=5,Rk={w:3,h:2};class Ud extends A.Component{state={hasError:!1,t:void 0};static getDerivedStateFromError(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error"}}componentDidCatch(e,s){console.error("[home-tiles] tile crashed:",e,s.componentStack)}render(){return this.state.hasError?r.jsx(Ik,{message:this.state.message}):r.jsx(Dk,{children:this.props.children})}}function Dk(t){const e=F.c(2),{children:s}=t;let n;return e[0]!==s?(n=r.jsx(r.Fragment,{children:s}),e[0]=s,e[1]=n):n=e[1],n}function Ik(t){const e=F.c(13),{message:s}=t,n=re();let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx("span",{className:"flex size-8 items-center justify-center rounded-md bg-destructive/10 text-destructive",children:r.jsx(Sr,{size:16})}),e[0]=i):i=e[0];let o;e[1]!==n?(o=n("home.tileErrorBoundary.tileCrashed"),e[1]=n,e[2]=o):o=e[2];let a;e[3]!==o?(a=r.jsx("p",{className:"text-sm font-medium text-foreground",children:o}),e[3]=o,e[4]=a):a=e[4];let l;e[5]!==s||e[6]!==n?(l=s??n("home.tileErrorBoundary.defaultError"),e[5]=s,e[6]=n,e[7]=l):l=e[7];let c;e[8]!==l?(c=r.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2",children:l}),e[8]=l,e[9]=c):c=e[9];let d;return e[10]!==a||e[11]!==c?(d=r.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 p-4 text-center",children:[i,a,c]}),e[10]=a,e[11]=c,e[12]=d):d=e[12],d}function Mk(t){const e=F.c(72),{tiles:s,isEditMode:n,renderTile:i,onMove:o,onResize:a,onRemove:l}=t,c=Cr(),d=A.useRef(null),[h,u]=A.useState(null),[f,m]=A.useState(null);let p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p={activationConstraint:{distance:4}},e[0]=p):p=e[0];const g=fc(ti($r,p),ti(Br)),x=s.reduce(Ok,0),v=n?Math.max(x+2,4):Math.max(x,1);let b;e[1]===Symbol.for("react.memo_cache_sentinel")?(b=()=>{const M=d.current?.getBoundingClientRect();return M?{cellWidth:M.width/on,cellHeight:Vn}:null},e[1]=b):b=e[1];const y=b;let _;e[2]===Symbol.for("react.memo_cache_sentinel")?(_=M=>{u(String(M.active.id)),m(y())},e[2]=_):_=e[2];const L=_;let w;e[3]!==f||e[4]!==o||e[5]!==s?(w=M=>{const O=String(M.active.id),$=f??y();if(u(null),m(null),!$||$.cellWidth<=0)return;const B=s.find(G=>G.id===O);if(!B)return;const z=Math.round(M.delta.x/$.cellWidth),K=Math.round(M.delta.y/$.cellHeight);z===0&&K===0||o(O,{x:B.x+z,y:B.y+K})},e[3]=f,e[4]=o,e[5]=s,e[6]=w):w=e[6];const j=w;if(c){let M;if(e[7]!==i||e[8]!==s){let $;e[10]!==i?($=B=>r.jsx("div",{className:"group bg-card card-shadow rounded-2xl overflow-hidden",style:{minHeight:Vn},children:r.jsx(Ud,{children:i(B)})},B.id),e[10]=i,e[11]=$):$=e[11],M=s.map($),e[7]=i,e[8]=s,e[9]=M}else M=e[9];let O;return e[12]!==M?(O=r.jsx("div",{className:"flex flex-col gap-3 px-4 pb-8",children:M}),e[12]=M,e[13]=O):O=e[13],O}let S,C,N,V,E,T,k,R,P;if(e[14]!==h||e[15]!==f||e[16]!==n||e[17]!==j||e[18]!==l||e[19]!==a||e[20]!==i||e[21]!==g||e[22]!==s||e[23]!==v){const M=h?s.find(U=>U.id===h):null;C=xc,R=g,P=L,N=j;const O=v*Vn,$=n?Vn*4:Vn;let B;e[33]!==O||e[34]!==$?(B={height:O,minHeight:$},e[33]=O,e[34]=$,e[35]=B):B=e[35];let z;e[36]!==n||e[37]!==s||e[38]!==v?(z=n&&r.jsx(Bk,{rows:v,tiles:s}),e[36]=n,e[37]=s,e[38]=v,e[39]=z):z=e[39];let K;if(e[40]!==h||e[41]!==n||e[42]!==l||e[43]!==a||e[44]!==i||e[45]!==s){let U;e[47]!==h||e[48]!==n||e[49]!==l||e[50]!==a||e[51]!==i?(U=W=>r.jsx(Fk,{tile:W,isEditMode:n,isDragging:h===W.id,onResize:a,onRemove:l,children:i(W)},W.id),e[47]=h,e[48]=n,e[49]=l,e[50]=a,e[51]=i,e[52]=U):U=e[52],K=s.map(U),e[40]=h,e[41]=n,e[42]=l,e[43]=a,e[44]=i,e[45]=s,e[46]=K}else K=e[46];e[53]!==B||e[54]!==z||e[55]!==K?(V=r.jsxs("div",{ref:d,className:"relative w-full",style:B,children:[z,K]}),e[53]=B,e[54]=z,e[55]=K,e[56]=V):V=e[56],S=G9,E=null;const G=M&&f?M.w*f.cellWidth-tf:void 0,Y=M&&f?M.h*f.cellHeight-tf:void 0;e[57]!==G||e[58]!==Y?(T={width:G,height:Y},e[57]=G,e[58]=Y,e[59]=T):T=e[59],k=M&&r.jsx("div",{className:"bg-card card-shadow rounded-2xl shadow-2xl ring-2 ring-primary/40 h-full overflow-hidden opacity-95",children:r.jsx(Ud,{children:i(M)})}),e[14]=h,e[15]=f,e[16]=n,e[17]=j,e[18]=l,e[19]=a,e[20]=i,e[21]=g,e[22]=s,e[23]=v,e[24]=S,e[25]=C,e[26]=N,e[27]=V,e[28]=E,e[29]=T,e[30]=k,e[31]=R,e[32]=P}else S=e[24],C=e[25],N=e[26],V=e[27],E=e[28],T=e[29],k=e[30],R=e[31],P=e[32];let D;e[60]!==S||e[61]!==E||e[62]!==T||e[63]!==k?(D=r.jsx(S,{dropAnimation:E,style:T,children:k}),e[60]=S,e[61]=E,e[62]=T,e[63]=k,e[64]=D):D=e[64];let I;return e[65]!==C||e[66]!==N||e[67]!==V||e[68]!==D||e[69]!==R||e[70]!==P?(I=r.jsxs(C,{sensors:R,onDragStart:P,onDragEnd:N,children:[V,D]}),e[65]=C,e[66]=N,e[67]=V,e[68]=D,e[69]=R,e[70]=P,e[71]=I):I=e[71],I}function Ok(t,e){return Math.max(t,e.y+e.h)}function Bk(t){const e=F.c(7),{rows:s,tiles:n}=t;let i;e[0]!==n?(i=(c,d)=>n.some(h=>c>=h.x&&c<h.x+h.w&&d>=h.y&&d<h.y+h.h),e[0]=n,e[1]=i):i=e[1];const o=i;let a;if(e[2]!==o||e[3]!==s){a=[];for(let c=0;c<s;c++)for(let d=0;d<on;d++)o(d,c)||a.push({x:d,y:c});e[2]=o,e[3]=s,e[4]=a}else a=e[4];let l;return e[5]!==a?(l=r.jsx("div",{className:"absolute inset-0 pointer-events-none",children:a.map($k)}),e[5]=a,e[6]=l):l=e[6],l}function $k(t){return r.jsx("div",{className:"absolute p-1",style:{left:`${t.x/on*100}%`,top:t.y*Vn,width:`${1/on*100}%`,height:Vn},children:r.jsx("div",{className:"h-full w-full rounded-2xl border border-dashed border-border/60"})},`${t.x}-${t.y}`)}function Fk(t){const e=F.c(32),{tile:s,isEditMode:n,isDragging:i,onResize:o,onRemove:a,children:l}=t,c=re(),d=!n;let h;e[0]!==d||e[1]!==s.id?(h={id:s.id,disabled:d},e[0]=d,e[1]=s.id,e[2]=h):h=e[2];const{setNodeRef:u,attributes:f,listeners:m,isDragging:p}=x3(h),g=`${s.x/on*100}%`,x=`${s.w/on*100}%`,v=s.y*Vn,b=s.h*Vn,y=p||i,_=!y&&"transition-[left,top,width,height,opacity] duration-200 ease-out",L=y&&"opacity-30";let w;e[3]!==_||e[4]!==L?(w=ie("absolute p-1 will-change-[left,top,width,height,opacity]",_,L),e[3]=_,e[4]=L,e[5]=w):w=e[5];let j;e[6]!==b||e[7]!==g||e[8]!==v||e[9]!==x?(j={left:g,top:v,width:x,height:b},e[6]=b,e[7]=g,e[8]=v,e[9]=x,e[10]=j):j=e[10];const S=n&&"outline outline-1 outline-transparent hover:outline-primary/40";let C;e[11]!==S?(C=ie("group relative h-full bg-card card-shadow rounded-2xl overflow-hidden",S),e[11]=S,e[12]=C):C=e[12];let N;e[13]!==f||e[14]!==n||e[15]!==m||e[16]!==a||e[17]!==o||e[18]!==c||e[19]!==s?(N=n&&r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button",...f,...m,className:"absolute top-2 left-2 z-10 flex size-8 items-center justify-center rounded-md bg-background/90 border border-border text-muted-foreground hover:text-foreground hover:bg-muted cursor-grab active:cursor-grabbing","aria-label":c("home.tileBoard.dragTileAriaLabel"),children:r.jsx(ia,{size:16})}),r.jsx("div",{className:"absolute top-2 right-2 z-10 flex items-center gap-1",children:r.jsx(zk,{tile:s,onResize:o,onRemove:a})})]}),e[13]=f,e[14]=n,e[15]=m,e[16]=a,e[17]=o,e[18]=c,e[19]=s,e[20]=N):N=e[20];let V;e[21]!==l?(V=r.jsx("div",{className:"h-full overflow-hidden",children:r.jsx(Ud,{children:l})}),e[21]=l,e[22]=V):V=e[22];let E;e[23]!==V||e[24]!==C||e[25]!==N?(E=r.jsxs("div",{className:C,children:[N,V]}),e[23]=V,e[24]=C,e[25]=N,e[26]=E):E=e[26];let T;return e[27]!==u||e[28]!==E||e[29]!==w||e[30]!==j?(T=r.jsx("div",{ref:u,className:w,style:j,children:E}),e[27]=u,e[28]=E,e[29]=w,e[30]=j,e[31]=T):T=e[31],T}function zk(t){const e=F.c(28),{tile:s,onResize:n,onRemove:i}=t,[o,a]=A.useState(!1),l=re();let c;e[0]!==l?(c=l("home.tileBoard.tileOptionsAriaLabel"),e[0]=l,e[1]=c):c=e[1];let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(oi,{size:16}),e[2]=d):d=e[2];let h;e[3]!==c?(h=r.jsx(ds,{asChild:!0,children:r.jsx("button",{type:"button",className:"flex size-8 items-center justify-center rounded-md bg-background/90 border border-border text-muted-foreground hover:text-foreground hover:bg-muted","aria-label":c,children:d})}),e[3]=c,e[4]=h):h=e[4];let u;e[5]!==n||e[6]!==s.id?(u=_=>{n(s.id,_),a(!1)},e[5]=n,e[6]=s.id,e[7]=u):u=e[7];let f;e[8]!==u||e[9]!==s?(f=r.jsx(Kk,{tile:s,onPick:u}),e[8]=u,e[9]=s,e[10]=f):f=e[10];let m;e[11]===Symbol.for("react.memo_cache_sentinel")?(m=r.jsx(rr,{}),e[11]=m):m=e[11];let p;e[12]!==i||e[13]!==s.id?(p=()=>i(s.id),e[12]=i,e[13]=s.id,e[14]=p):p=e[14];let g;e[15]===Symbol.for("react.memo_cache_sentinel")?(g=r.jsx(Ns,{size:14,className:"mr-2"}),e[15]=g):g=e[15];let x;e[16]!==l?(x=l("home.tileBoard.removeTile"),e[16]=l,e[17]=x):x=e[17];let v;e[18]!==p||e[19]!==x?(v=r.jsxs(Xe,{onSelect:p,className:"text-destructive focus:text-destructive",children:[g,x]}),e[18]=p,e[19]=x,e[20]=v):v=e[20];let b;e[21]!==v||e[22]!==f?(b=r.jsxs(hs,{align:"end",className:"w-auto",children:[f,m,v]}),e[21]=v,e[22]=f,e[23]=b):b=e[23];let y;return e[24]!==o||e[25]!==b||e[26]!==h?(y=r.jsxs(us,{open:o,onOpenChange:a,children:[h,b]}),e[24]=o,e[25]=b,e[26]=h,e[27]=y):y=e[27],y}function Kk(t){const e=F.c(26),{tile:s,onPick:n}=t,i=s.minW??1,o=s.minH??1,[a,l]=A.useState(null);let c;e[0]!==a||e[1]!==s.h||e[2]!==s.w?(c=a??{w:s.w,h:s.h},e[0]=a,e[1]=s.h,e[2]=s.w,e[3]=c):c=e[3];const d=c,h=re();let u;e[4]!==h?(u=h("home.tileBoard.sizeLabel"),e[4]=h,e[5]=u):u=e[5];let f;e[6]!==u?(f=r.jsx("span",{className:"text-xs text-muted-foreground",children:u}),e[6]=u,e[7]=f):f=e[7];let m;e[8]!==d.h||e[9]!==d.w?(m=r.jsxs("span",{className:"text-xs font-medium tabular-nums",children:[d.w," × ",d.h]}),e[8]=d.h,e[9]=d.w,e[10]=m):m=e[10];let p;e[11]!==f||e[12]!==m?(p=r.jsxs("div",{className:"mb-2 flex items-center justify-between gap-4",children:[f,m]}),e[11]=f,e[12]=m,e[13]=p):p=e[13];let g,x;e[14]===Symbol.for("react.memo_cache_sentinel")?(g={gridTemplateColumns:`repeat(${on}, 1.25rem)`},x=()=>l(null),e[14]=g,e[15]=x):(g=e[14],x=e[15]);let v;e[16]!==d.h||e[17]!==d.w||e[18]!==o||e[19]!==i||e[20]!==n||e[21]!==h?(v=r.jsx("div",{className:"grid w-max gap-1",style:g,onPointerLeave:x,children:Array.from({length:Pk},(y,_)=>Array.from({length:on},(L,w)=>{const j=w+1,S=_+1,C=j<i||S<o,N=j<=d.w&&S<=d.h;return r.jsx("button",{type:"button",disabled:C,"aria-label":h("home.tileBoard.sizeGridCellAriaLabel",{w:j,h:S}),onPointerEnter:()=>l({w:j,h:S}),onClick:()=>n({w:j,h:S}),className:ie("size-5 rounded-sm border transition-colors",N?"border-primary bg-primary/30":"border-border bg-muted",C?"cursor-not-allowed opacity-40":"cursor-pointer hover:border-primary/60")},`${j}x${S}`)}))}),e[16]=d.h,e[17]=d.w,e[18]=o,e[19]=i,e[20]=n,e[21]=h,e[22]=v):v=e[22];let b;return e[23]!==p||e[24]!==v?(b=r.jsxs("div",{className:"px-2 py-1.5",children:[p,v]}),e[23]=p,e[24]=v,e[25]=b):b=e[25],b}function Uk(t,e,s){return t.some(n=>e>=n.x&&e<n.x+n.w&&s>=n.y&&s<n.y+n.h)}function Hd(t,e,s){for(let n=0;n<100;n++)for(let i=0;i<=on-e;i++){let o=!0;for(let a=0;a<s&&o;a++)for(let l=0;l<e&&o;l++)Uk(t,i+l,n+a)&&(o=!1);if(o)return{x:i,y:n}}return{x:0,y:0}}function Zc(t,e,s={w:1,h:1}){const n=Math.max(s.w,Math.min(on,t)),i=Math.max(s.h,Math.min(6,e));return{w:n,h:i}}function ed(t,e,s){const n=Math.max(0,Math.min(on-s,t)),i=Math.max(0,e);return{x:n,y:i}}function Hk(t,e,s){const n=t.find(c=>c.id===e);if(!n)return t;const i=t.filter(c=>c.id!==e),o=i.find(c=>s.x>=c.x&&s.x<c.x+c.w&&s.y>=c.y&&s.y<c.y+c.h);if(o&&o.w===n.w&&o.h===n.h)return t.map(c=>c.id===e?{...c,x:o.x,y:o.y}:c.id===o.id?{...c,x:n.x,y:n.y}:c);const l=[{...n,x:s.x,y:s.y}];for(const c of i){const d=Hd(l,c.w,c.h);l.push({...c,x:d.x,y:d.y})}return l}function Wk(t){const e=F.c(42),{layout:s,isLayoutLoading:n,commitLayout:i}=F9();let o;e[0]!==s.hidden?(o=new Set(s.hidden),e[0]=s.hidden,e[1]=o):o=e[1];const a=o;let l;e[2]!==s.shown?(l=s.shown??[],e[2]=s.shown,e[3]=l):l=e[3];let c;e[4]!==l?(c=new Set(l),e[4]=l,e[5]=c):c=e[5];const d=c;let h,u;if(e[6]!==t||e[7]!==a||e[8]!==s.tiles||e[9]!==d){u=[];let L;e[12]!==a||e[13]!==d?(L=j=>j.pinned?!0:j.defaultHidden?d.has(j.id)&&!a.has(j.id):!a.has(j.id),e[12]=a,e[13]=d,e[14]=L):L=e[14];const w=t.filter(L);h=new Map;for(const j of t)j.minSize&&h.set(j.id,j.minSize);for(const j of w){const S=s.tiles[j.id];if(!S)continue;const C=h.get(j.id),{w:N,h:V}=Zc(S.w,S.h,C),{x:E,y:T}=ed(S.x,S.y,N);u.push({id:j.id,x:E,y:T,w:N,h:V,minW:C?.w,minH:C?.h})}for(const j of w){if(u.some(T=>T.id===j.id))continue;const S=j.defaultSize??Rk,C=h.get(j.id),{w:N,h:V}=Zc(S.w,S.h,C),E=Hd(u,N,V);u.push({id:j.id,x:E.x,y:E.y,w:N,h:V,minW:C?.w,minH:C?.h})}e[6]=t,e[7]=a,e[8]=s.tiles,e[9]=d,e[10]=h,e[11]=u}else h=e[10],u=e[11];let f;e[15]!==t?(f=new Set(t.map(qk)),e[15]=t,e[16]=f):f=e[16];const m=f;let p;e[17]!==m||e[18]!==i||e[19]!==s?(p=(L,w)=>{const j={};for(const S of L)j[S.id]={x:S.x,y:S.y,w:S.w,h:S.h};i({version:_r,tiles:j,hidden:w.filter(S=>m.has(S)),shown:(s.shown??[]).filter(S=>m.has(S))})},e[17]=m,e[18]=i,e[19]=s,e[20]=p):p=e[20];const g=p;let x;e[21]!==u?(x={visible:u},e[21]=u,e[22]=x):x=e[22];let v;e[23]!==g||e[24]!==s||e[25]!==u?(v=(L,w)=>{const j=u.find(N=>N.id===L);if(!j)return;const S=ed(w.x,w.y,j.w);if(S.x===j.x&&S.y===j.y)return;const C=Hk(u,L,S);g(C,s.hidden)},e[23]=g,e[24]=s,e[25]=u,e[26]=v):v=e[26];let b;e[27]!==g||e[28]!==s||e[29]!==h||e[30]!==u?(b=(L,w)=>{const j=u.find(k=>k.id===L);if(!j)return;const S=h.get(L),{w:C,h:N}=Zc(w.w,w.h,S);if(C===j.w&&N===j.h)return;const V={...j,w:C,h:N,x:ed(j.x,j.y,C).x},E=u.filter(k=>k.id!==L),T=[V];for(const k of E){const R=Hd(T,k.w,k.h);T.push({...k,x:R.x,y:R.y})}g(T,s.hidden)},e[27]=g,e[28]=s,e[29]=h,e[30]=u,e[31]=b):b=e[31];let y;e[32]!==g||e[33]!==s||e[34]!==u?(y=L=>{const w=u.filter(j=>j.id!==L);g(w,Array.from(new Set([...s.hidden,L])))},e[32]=g,e[33]=s,e[34]=u,e[35]=y):y=e[35];let _;return e[36]!==n||e[37]!==x||e[38]!==v||e[39]!==b||e[40]!==y?(_={snapshot:x,isLoading:n,moveTile:v,resizeTile:b,hideTile:y},e[36]=n,e[37]=x,e[38]=v,e[39]=b,e[40]=y,e[41]=_):_=e[41],_}function qk(t){return t.id}const Gk=3,Yk=5;function Jk(t){const e=F.c(17),{org:s}=Oe();let n;e[0]!==s.id||e[1]!==s.slug?(n={connectionId:Jo,orgId:s.id,orgSlug:s.slug},e[0]=s.id,e[1]=s.slug,e[2]=n):n=e[2];const i=ht(n);let o;e[3]!==t||e[4]!==s.id||e[5]!==s.slug?(o={connectionId:t,orgId:s.id,orgSlug:s.slug},e[3]=t,e[4]=s.id,e[5]=s.slug,e[6]=o):o=e[6];const a=ht(o);let l;e[7]!==t||e[8]!==s.id?(l=at.homeGithubRecentPrs(s.id,t),e[7]=t,e[8]=s.id,e[9]=l):l=e[9];let c;e[10]!==t||e[11]!==a||e[12]!==i?(c=async()=>{const{installations:h}=await y2(b=>i.callTool(b),t),u=h[0];if(!u)return{repos:[]};const f=u.type==="User"?"user":"org",p=(await a.callTool({name:"search_repositories",arguments:{query:`${f}:${u.login}`,page:1,perPage:30}})).content?.[0]?.text,x=[...p?JSON.parse(p).items??[]:[]].sort(tV).filter(eV).slice(0,Gk);return x.length===0?{repos:[]}:{repos:(await Promise.all(x.map(async b=>{const[y,_]=b.full_name.split("/"),L=await a.callTool({name:"list_pull_requests",arguments:{owner:y,repo:_,state:"all",perPage:Yk}}),w=sc(L).map(Zk).filter(Qk);return{repo:b.full_name,prs:w}}))).filter(Xk)}},e[10]=t,e[11]=a,e[12]=i,e[13]=c):c=e[13];let d;return e[14]!==l||e[15]!==c?(d={queryKey:l,queryFn:c,staleTime:6e4,retry:!1},e[14]=l,e[15]=c,e[16]=d):d=e[16],Mt(d)}function Xk(t){return t.prs.length>0}function Qk(t){return t.number>0}function Zk(t){return{number:t.number??0,title:t.title??"",merged:t.merged_at!=null,state:t.state==="closed"?"closed":"open",htmlUrl:t.html_url??""}}function eV(t){return t.full_name}function tV(t,e){return(e.updated_at??"").localeCompare(t.updated_at??"")}const ar=26,sV=7;function nV(t){const e=F.c(17),{org:s}=Oe();let n;e[0]!==s.id||e[1]!==s.slug?(n={connectionId:Jo,orgId:s.id,orgSlug:s.slug},e[0]=s.id,e[1]=s.slug,e[2]=n):n=e[2];const i=ht(n);let o;e[3]!==t||e[4]!==s.id||e[5]!==s.slug?(o={connectionId:t,orgId:s.id,orgSlug:s.slug},e[3]=t,e[4]=s.id,e[5]=s.slug,e[6]=o):o=e[6];const a=ht(o);let l;e[7]!==t||e[8]!==s.id?(l=at.homeGithubContributions(s.id,t),e[7]=t,e[8]=s.id,e[9]=l):l=e[9];let c;e[10]!==t||e[11]!==a||e[12]!==i?(c=async()=>{const{installations:h}=await y2(C=>i.callTool(C),t),u=h[0];if(!u)return td();const f=u.type==="User"?"user":"org",p=(await a.callTool({name:"search_repositories",arguments:{query:`${f}:${u.login}`,page:1,perPage:30}})).content?.[0]?.text,x=[...p?JSON.parse(p).items??[]:[]].sort(iV)[0];if(!x?.full_name)return td();const[v,b]=x.full_name.split("/"),y=new Date(Date.now()-ar*7*864e5),L=(await a.callTool({name:"list_commits",arguments:{owner:v,repo:b,since:y.toISOString(),perPage:100}})).content?.[0]?.text,w=L?JSON.parse(L):[],j=td(),S=Date.now();for(const C of w){const N=C.commit?.committer?.date??C.commit?.author?.date??"",V=new Date(N);if(isNaN(V.getTime()))continue;const E=Math.floor((S-V.getTime())/864e5);if(E<0||E>=ar*7)continue;const T=ar-1-Math.floor(E/7),k=V.getDay(),R=j[T];R&&(R[k]=(R[k]??0)+1)}return j},e[10]=t,e[11]=a,e[12]=i,e[13]=c):c=e[13];let d;return e[14]!==l||e[15]!==c?(d={queryKey:l,queryFn:c,staleTime:3e5,retry:!1},e[14]=l,e[15]=c,e[16]=d):d=e[16],Mt(d)}function iV(t,e){return(e.updated_at??"").localeCompare(t.updated_at??"")}function td(){return Array.from({length:ar},()=>Array.from({length:sV},()=>0))}const b3="pageviews",_3="sessions",y3="orders",L3="coding",S3="revenue",w3="recent-conversations",Y9=[{id:b3,titleKey:"home.nativeTiles.pageviews",defaultSize:{w:2,h:3},minSize:{w:1,h:2}},{id:_3,titleKey:"home.nativeTiles.sessions",defaultSize:{w:2,h:3},minSize:{w:1,h:2}},{id:y3,titleKey:"home.nativeTiles.orders",defaultSize:{w:2,h:3},minSize:{w:1,h:2}},{id:S3,titleKey:"home.nativeTiles.revenue",defaultSize:{w:3,h:3},minSize:{w:2,h:2}},{id:L3,titleKey:"home.nativeTiles.coding",defaultSize:{w:3,h:3},minSize:{w:2,h:2}},{id:w3,titleKey:"home.nativeTiles.recentConversations",defaultSize:{w:6,h:4},minSize:{w:2,h:2},defaultHidden:!0}];function j3(t){return`native:${t}`}function C3(t){const e=F.c(21),{points:s,metricLabel:n}=t,i=A.useId();let o;if(e[0]!==i){let b;e[2]===Symbol.for("react.memo_cache_sentinel")?(b=/:/g,e[2]=b):b=e[2],o=i.replace(b,""),e[0]=i,e[1]=o}else o=e[1];const a=o;let l;e[3]!==n?(l={value:{label:n,color:"var(--success)"}},e[3]=n,e[4]=l):l=e[4];let c;e[5]===Symbol.for("react.memo_cache_sentinel")?(c={top:6,right:0,bottom:0,left:0},e[5]=c):c=e[5];let d;e[6]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx("line",{x1:0,y1:0,x2:0,y2:8,stroke:"var(--success)",strokeOpacity:.22,strokeWidth:4}),e[6]=d):d=e[6];let h;e[7]!==a?(h=r.jsx("defs",{children:r.jsx("pattern",{id:a,width:6,height:8,patternUnits:"userSpaceOnUse",children:d})}),e[7]=a,e[8]=h):h=e[8];let u;e[9]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx(Hx,{dataKey:"label",hide:!0}),e[9]=u):u=e[9];let f;e[10]===Symbol.for("react.memo_cache_sentinel")?(f=r.jsx(Wx,{cursor:{stroke:"var(--border)"},content:r.jsx(qx,{indicator:"line"})}),e[10]=f):f=e[10];const m=`url(#${a})`;let p;e[11]===Symbol.for("react.memo_cache_sentinel")?(p={r:4,fill:"var(--success)",stroke:"var(--background)",strokeWidth:2},e[11]=p):p=e[11];let g;e[12]!==m?(g=r.jsx(Gx,{type:"monotone",dataKey:"value",stroke:"var(--success)",strokeWidth:2,fill:m,fillOpacity:1,animationDuration:350,dot:!1,activeDot:p}),e[12]=m,e[13]=g):g=e[13];let x;e[14]!==s||e[15]!==g||e[16]!==h?(x=r.jsxs(Yx,{data:s,margin:c,children:[h,u,f,g]}),e[14]=s,e[15]=g,e[16]=h,e[17]=x):x=e[17];let v;return e[18]!==x||e[19]!==l?(v=r.jsx(Jx,{config:l,className:"h-full w-full",children:x}),e[18]=x,e[19]=l,e[20]=v):v=e[20],v}const k3={pageviews:{value:"12.2k",delta:"+1.9%",series:[9800,10100,9950,10600,10400,11e3,11200,11500,11900,12200]},sessions:{value:"3.2k",delta:"+25.6%",series:[2100,2250,2200,2500,2600,2750,2900,3e3,3100,3200]},orders:{value:"142",delta:"+8.4%",series:[96,102,99,110,108,118,124,131,137,142]},revenue:{value:"$8,240",delta:"+12.0%",series:[6100,6400,6250,6800,6700,7100,7400,7700,8e3,8240]}};function V3(t,e){return t.map((s,n)=>{const i=t.length-1-n;return{label:i===0?e("home.nativeTiles.today"):i===1?e("home.nativeTiles.yesterday"):e("home.nativeTiles.daysAgo",{days:i}),value:s}})}function N3(t){const e=F.c(8),{value:s,delta:n}=t;let i;e[0]!==s?(i=r.jsx("span",{className:"text-2xl font-medium tabular-nums text-foreground",children:s}),e[0]=s,e[1]=i):i=e[1];let o;e[2]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx(_2,{className:"size-4"}),e[2]=o):o=e[2];let a;e[3]!==n?(a=r.jsxs("span",{className:"inline-flex items-center gap-1 text-sm font-medium tabular-nums text-success",children:[o,n]}),e[3]=n,e[4]=a):a=e[4];let l;return e[5]!==i||e[6]!==a?(l=r.jsxs("div",{className:"mt-3 flex items-center gap-2.5",children:[i,a]}),e[5]=i,e[6]=a,e[7]=l):l=e[7],l}function rV(t,e){const s=(t*31+e*17+7)%100;return s<38?0:s<60?1+s%2:s<80?3+s%3:s<93?6+s%3:9+s%4}function oV(t){return t===0?"bg-muted-foreground/15":t<=2?"bg-success/25":t<=5?"bg-success/45":t<=8?"bg-success/70":"bg-success"}function T3(t){const e=F.c(4),{grid:s}=t,n=re();let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={gridTemplateColumns:`repeat(${ar}, 1fr)`},e[0]=i):i=e[0];let o;return e[1]!==s||e[2]!==n?(o=r.jsx(ji,{delayDuration:0,children:r.jsx("div",{className:"grid w-full gap-1",style:i,children:Array.from({length:ar},(a,l)=>r.jsx("div",{className:"flex flex-col gap-1",children:Array.from({length:5},(c,d)=>{const h=s?s[l]?.[d]??0:rV(l,d);return r.jsxs(Ue,{children:[r.jsx(ze,{asChild:!0,children:r.jsx("div",{className:ie("aspect-square rounded-[2px]",oV(h))})}),r.jsx(Ke,{children:h===0?n("home.nativeTiles.noCommits"):n("home.nativeTiles.commits",{count:h})})]},d)})},l))})}),e[1]=s,e[2]=n,e[3]=o):o=e[3],o}function J9(t){const e=F.c(8),{label:s,icon:n,onConnect:i,pending:o}=t;let a;e[0]!==n||e[1]!==o?(a=o?r.jsx(et,{className:"size-4 animate-spin"}):n,e[0]=n,e[1]=o,e[2]=a):a=e[2];let l;return e[3]!==s||e[4]!==i||e[5]!==o||e[6]!==a?(l=r.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-background/30 backdrop-blur-[2px]",children:r.jsxs(le,{size:"sm",onClick:i,disabled:o,className:"gap-2 shadow-sm",children:[a,s]})}),e[3]=s,e[4]=i,e[5]=o,e[6]=a,e[7]=l):l=e[7],l}function A3(t){const e=F.c(6),{label:s}=t,n=re();let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(Xl,{className:"size-6 text-success/60"}),e[0]=i):i=e[0];let o;e[1]!==s||e[2]!==n?(o=n("home.nativeTiles.connectedSoon",{label:s}),e[1]=s,e[2]=n,e[3]=o):o=e[3];let a;return e[4]!==o?(a=r.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 text-center",children:[i,r.jsx("p",{className:"text-xs text-muted-foreground",children:o})]}),e[4]=o,e[5]=a):a=e[5],a}function sf(t){const e=F.c(22),{metricKey:s}=t,n=re();let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={slug:"google-analytics"},e[0]=i):i=e[0];const o=Rn(i).length>0,{connect:a,isConnecting:l}=Vm("deco/google-analytics"),c=k3[s];if(o||!c){let x;return e[1]===Symbol.for("react.memo_cache_sentinel")?(x=r.jsx(A3,{label:"Analytics"}),e[1]=x):x=e[1],x}let d;e[2]!==c.series||e[3]!==n?(d=V3(c.series,n),e[2]=c.series,e[3]=n,e[4]=d):d=e[4];let h;e[5]!==s||e[6]!==d?(h=r.jsx("div",{className:"min-h-0 flex-1",children:r.jsx(C3,{points:d,metricLabel:s})}),e[5]=s,e[6]=d,e[7]=h):h=e[7];let u;e[8]!==c.delta||e[9]!==c.value?(u=r.jsx(N3,{value:c.value,delta:c.delta}),e[8]=c.delta,e[9]=c.value,e[10]=u):u=e[10];let f;e[11]!==n?(f=n("home.nativeTiles.connectGoogleAnalytics"),e[11]=n,e[12]=f):f=e[12];let m;e[13]===Symbol.for("react.memo_cache_sentinel")?(m=r.jsx(Nm,{className:"size-4"}),e[13]=m):m=e[13];let p;e[14]!==a||e[15]!==l||e[16]!==f?(p=r.jsx(J9,{label:f,icon:m,onConnect:a,pending:l}),e[14]=a,e[15]=l,e[16]=f,e[17]=p):p=e[17];let g;return e[18]!==h||e[19]!==u||e[20]!==p?(g=r.jsxs("div",{className:"relative flex h-full flex-col",children:[h,u,p]}),e[18]=h,e[19]=u,e[20]=p,e[21]=g):g=e[21],g}function nf(t){const e=F.c(27),{metricKey:s}=t,n=re();let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={slug:"vtex"},e[0]=i):i=e[0];const o=Rn(i);let a;e[1]===Symbol.for("react.memo_cache_sentinel")?(a={slug:"shopify"},e[1]=a):a=e[1];const l=Rn(a),c=o.length>0||l.length>0,[d,h]=A.useState(!1),u=k3[s];if(c||!u){let w;return e[2]===Symbol.for("react.memo_cache_sentinel")?(w=r.jsx(A3,{label:"Commerce"}),e[2]=w):w=e[2],w}let f;e[3]!==u.series||e[4]!==n?(f=V3(u.series,n),e[3]=u.series,e[4]=n,e[5]=f):f=e[5];let m;e[6]!==s||e[7]!==f?(m=r.jsx("div",{className:"min-h-0 flex-1",children:r.jsx(C3,{points:f,metricLabel:s})}),e[6]=s,e[7]=f,e[8]=m):m=e[8];let p;e[9]!==u.delta||e[10]!==u.value?(p=r.jsx(N3,{value:u.value,delta:u.delta}),e[9]=u.delta,e[10]=u.value,e[11]=p):p=e[11];let g;e[12]!==n?(g=n("home.nativeTiles.connectCommercePlatform"),e[12]=n,e[13]=g):g=e[13];let x,v;e[14]===Symbol.for("react.memo_cache_sentinel")?(x=r.jsx(m9,{className:"size-4"}),v=()=>h(!0),e[14]=x,e[15]=v):(x=e[14],v=e[15]);let b;e[16]!==g?(b=r.jsx(J9,{label:g,icon:x,onConnect:v}),e[16]=g,e[17]=b):b=e[17];let y;e[18]!==m||e[19]!==p||e[20]!==b?(y=r.jsxs("div",{className:"relative flex h-full flex-col",children:[m,p,b]}),e[18]=m,e[19]=p,e[20]=b,e[21]=y):y=e[21];let _;e[22]!==d?(_=r.jsx(o9,{mode:"browse",open:d,onOpenChange:h,defaultTab:"all",initialSearch:"shopify vtex"}),e[22]=d,e[23]=_):_=e[23];let L;return e[24]!==y||e[25]!==_?(L=r.jsxs(r.Fragment,{children:[y,_]}),e[24]=y,e[25]=_,e[26]=L):L=e[26],L}function aV(){const t=F.c(5);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={slug:"mcp-github"},t[0]=e):e=t[0];const s=Rn(e);let n;t[1]!==s?(n=Rb(s),t[1]=s,t[2]=n):n=t[2];const i=n[0];let o;return t[3]!==i?(o=i?r.jsx(cV,{connectionId:i.id}):r.jsx(lV,{}),t[3]=i,t[4]=o):o=t[4],o}function lV(){const t=F.c(8),e=re(),{connect:s,isConnecting:n}=Vm("deco/mcp-github");let i;t[0]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:r.jsx(T3,{})}),t[0]=i):i=t[0];let o;t[1]!==e?(o=e("home.nativeTiles.connectGithub"),t[1]=e,t[2]=o):o=t[2];let a;t[3]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx(Mo,{className:"size-4"}),t[3]=a):a=t[3];let l;return t[4]!==s||t[5]!==n||t[6]!==o?(l=r.jsxs("div",{className:"relative flex h-full flex-col",children:[i,r.jsx(J9,{label:o,icon:a,onConnect:s,pending:n})]}),t[4]=s,t[5]=n,t[6]=o,t[7]=l):l=t[7],l}function cV(t){const e=F.c(9),{connectionId:s}=t,n=re(),{data:i,isLoading:o}=Jk(s),{data:a}=nV(s);let l;e[0]!==a?(l=r.jsx(T3,{grid:a}),e[0]=a,e[1]=l):l=e[1];let c;e[2]!==i||e[3]!==o||e[4]!==n?(c=o?r.jsx("div",{className:"flex flex-col gap-1.5",children:Array.from({length:3},uV)}):!i||i.repos.length===0?r.jsx("p",{className:"text-xs text-muted-foreground",children:n("home.nativeTiles.noRecentPullRequests")}):r.jsx("div",{className:"flex min-h-0 flex-1 flex-col gap-3 overflow-y-auto",children:i.repos.map(dV)}),e[2]=i,e[3]=o,e[4]=n,e[5]=c):c=e[5];let d;return e[6]!==l||e[7]!==c?(d=r.jsxs("div",{className:"flex h-full flex-col gap-3 overflow-hidden",children:[l,c]}),e[6]=l,e[7]=c,e[8]=d):d=e[8],d}function dV(t){return r.jsxs("div",{className:"flex flex-col gap-0.5",children:[r.jsx("div",{className:"truncate text-xs text-muted-foreground",children:t.repo}),t.prs.map(e=>r.jsxs("a",{href:e.htmlUrl,target:"_blank",rel:"noreferrer",className:"flex items-center gap-2 rounded-md px-1.5 py-1.5 text-sm transition-colors hover:bg-accent/60",children:[r.jsx(Zs,{className:"size-4 shrink-0 text-muted-foreground"}),r.jsx("span",{className:"truncate text-foreground",children:e.title}),r.jsxs("span",{className:ie("ml-auto shrink-0 rounded-full px-1.5 py-0.5 text-xs font-medium",e.merged?"bg-success/10 text-success":"bg-muted text-muted-foreground"),children:["#",e.number]})]},`${t.repo}#${e.number}`))]},t.repo)}function uV(t,e){return r.jsx("div",{className:"h-5 w-full animate-pulse rounded-md bg-muted/40"},`pr-skeleton-${e}`)}const hV={completed:{labelKey:"home.nativeTiles.statusCompleted",className:"text-success"},in_progress:{labelKey:"home.nativeTiles.statusRunning",className:"text-foreground"},requires_action:{labelKey:"home.nativeTiles.statusNeedsInput",className:"text-foreground"},failed:{labelKey:"home.nativeTiles.statusFailed",className:"text-destructive"},expired:{labelKey:"home.nativeTiles.statusExpired",className:"text-muted-foreground"}};function fV(){const t=F.c(14),e=re(),{org:s,locator:n}=Oe(),i=$s(),o=St(),{data:a}=Jm(),l=a?.data?.members??[],c=new Map(l.map(mV));let d;t[0]!==n?(d=at.overviewThreads(n),t[0]=n,t[1]=d):d=t[1];let h;t[2]!==i?(h=async()=>(await i.call("COLLECTION_THREADS_LIST",{limit:12})).items??[],t[2]=i,t[3]=h):h=t[3];let u;t[4]!==d||t[5]!==h?(u={queryKey:d,queryFn:h,staleTime:3e4},t[4]=d,t[5]=h,t[6]=u):u=t[6];const{data:f}=rm(u);if(f.length===0){let x;t[7]===Symbol.for("react.memo_cache_sentinel")?(x=r.jsx(X0,{className:"size-6 text-muted-foreground/50"}),t[7]=x):x=t[7];let v;t[8]!==e?(v=e("home.nativeTiles.noConversationsYet"),t[8]=e,t[9]=v):v=t[9];let b;return t[10]!==v?(b=r.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-2 text-center",children:[x,r.jsx("p",{className:"text-xs text-muted-foreground",children:v})]}),t[10]=v,t[11]=b):b=t[11],b}const m="flex h-full flex-col gap-0.5 overflow-y-auto",p=f.map(x=>{const v=c.get(x.created_by),b=v?.user?.name??v?.user?.email?.split("@")[0]??"Someone",y=x.status?hV[x.status]:void 0,_=x.updated_at?b2(new Date(x.updated_at)):null;return r.jsxs("button",{type:"button",onClick:()=>o({to:"/$org/$taskId",params:{org:s.slug,taskId:x.id},search:x.virtual_mcp_id?{virtualmcpid:x.virtual_mcp_id}:{}}),className:"flex items-center gap-2.5 rounded-lg px-2.5 py-2 text-left transition-colors hover:bg-accent/60",children:[r.jsx(ir,{shape:"circle",size:"xs",url:v?.user?.image??void 0,fallback:b.slice(0,2).toUpperCase()}),r.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[r.jsx("span",{className:"truncate text-sm font-medium text-foreground",children:x.title||e("home.nativeTiles.untitledConversation")}),r.jsxs("span",{className:"truncate text-xs text-muted-foreground",children:[b,_?` · ${_}`:""]})]}),y&&r.jsx("span",{className:ie("shrink-0 text-xs",y.className),children:e(y.labelKey)})]},x.id)});let g;return t[12]!==p?(g=r.jsx("div",{className:m,children:p}),t[12]=p,t[13]=g):g=t[13],g}function mV(t){return[t.userId,t]}function pV(t){const e=F.c(6),{nativeId:s}=t;switch(s){case b3:{let n;return e[0]===Symbol.for("react.memo_cache_sentinel")?(n=r.jsx(sf,{metricKey:"pageviews"}),e[0]=n):n=e[0],n}case _3:{let n;return e[1]===Symbol.for("react.memo_cache_sentinel")?(n=r.jsx(sf,{metricKey:"sessions"}),e[1]=n):n=e[1],n}case y3:{let n;return e[2]===Symbol.for("react.memo_cache_sentinel")?(n=r.jsx(nf,{metricKey:"orders"}),e[2]=n):n=e[2],n}case S3:{let n;return e[3]===Symbol.for("react.memo_cache_sentinel")?(n=r.jsx(nf,{metricKey:"revenue"}),e[3]=n):n=e[3],n}case L3:{let n;return e[4]===Symbol.for("react.memo_cache_sentinel")?(n=r.jsx(aV,{}),e[4]=n):n=e[4],n}case w3:{let n;return e[5]===Symbol.for("react.memo_cache_sentinel")?(n=r.jsx(A.Suspense,{fallback:r.jsx("div",{className:"h-full animate-pulse bg-muted/30"}),children:r.jsx(fV,{})}),e[5]=n):n=e[5],n}default:return null}}function gV(t){const e=F.c(16),{nativeId:s}=t,n=re();let i,o,a;if(e[0]!==s||e[1]!==n){let h;e[5]!==s?(h=f=>f.id===s,e[5]=s,e[6]=h):h=e[6];const u=Y9.find(h);a="flex h-full flex-col overflow-hidden p-4",i="shrink-0 text-xs font-medium text-muted-foreground",o=u?.titleKey?n(u.titleKey):n("home.nativeTiles.tile"),e[0]=s,e[1]=n,e[2]=i,e[3]=o,e[4]=a}else i=e[2],o=e[3],a=e[4];let l;e[7]!==i||e[8]!==o?(l=r.jsx("span",{className:i,children:o}),e[7]=i,e[8]=o,e[9]=l):l=e[9];let c;e[10]!==s?(c=r.jsx("div",{className:"relative mt-2 min-h-0 flex-1",children:r.jsx(pV,{nativeId:s})}),e[10]=s,e[11]=c):c=e[11];let d;return e[12]!==a||e[13]!==l||e[14]!==c?(d=r.jsxs("div",{className:a,children:[l,c]}),e[12]=a,e[13]=l,e[14]=c,e[15]=d):d=e[15],d}const xV={w:3,h:4},vV={w:1,h:2},bV={w:2,h:1};function _V(t){return`prompt:${t.agentId}:${t.promptName||"blank"}`}function yV(t){return t.tileId?`tile:${t.tileId}`:`tile:${t.agentId}:${t.resourceUri}`}function LV(t){return t.promptName?t.agentName:t.description}function SV(t){return{name:t.promptName,title:t.title,description:t.description,arguments:t.arguments,_meta:t._meta}}function E3(t){const e=F.c(14),{org:s}=Oe();let n;e[0]!==s.id||e[1]!==s.slug||e[2]!==t.connectionId?(n=Ux({connectionId:t.connectionId,orgId:s.id,orgSlug:s.slug}),e[0]=s.id,e[1]=s.slug,e[2]=t.connectionId,e[3]=n):n=e[3];const{data:i}=Mt(n),o=!!i&&!t.toolName;let a;e[4]!==i||e[5]!==o?(a={client:i,enabled:o},e[4]=i,e[5]=o,e[6]=a):a=e[6];const{data:l}=a9(a);let c;e[7]!==t.resourceUri||e[8]!==t.toolName||e[9]!==l?.tools?(c=t.toolName??l?.tools.find(u=>Zl(u._meta)===t.resourceUri)?.name,e[7]=t.resourceUri,e[8]=t.toolName,e[9]=l?.tools,e[10]=c):c=e[10];const d=c;let h;return e[11]!==t.connectionId||e[12]!==d?(h=d?Fa(t.connectionId,d):void 0,e[11]=t.connectionId,e[12]=d,e[13]=h):h=e[13],h}function X9(t){const e=F.c(10);let s;e[0]!==t?(s={agentId:t},e[0]=t,e[1]=s):s=e[1];const{start:n,startBlank:i,dialog:o,starting:a}=rC(s);let l;e[2]!==n||e[3]!==i?(l=h=>{if(!h.promptName){i();return}n(SV(h))},e[2]=n,e[3]=i,e[4]=l):l=e[4];const c=l;let d;return e[5]!==o||e[6]!==c||e[7]!==i||e[8]!==a?(d={open:c,startBlank:i,dialog:o,starting:a},e[5]=o,e[6]=c,e[7]=i,e[8]=a,e[9]=d):d=e[9],d}function wV(t){const e=F.c(32),{entry:s,isEditMode:n}=t,{open:i,dialog:o,starting:a}=X9(s.agentId);let l;e[0]!==s||e[1]!==i?(l=()=>i(s),e[0]=s,e[1]=i,e[2]=l):l=e[2];const c=a||n,d=!n&&"cursor-pointer transition-colors hover:bg-accent/40",h=n&&"cursor-default pl-12",u=a&&"opacity-60";let f;e[3]!==d||e[4]!==h||e[5]!==u?(f=ie("group/tile relative flex h-full w-full items-center gap-3 px-4 py-3 text-left bg-card",d,h,u),e[3]=d,e[4]=h,e[5]=u,e[6]=f):f=e[6];let m;e[7]!==s.agentIcon||e[8]!==s.agentName?(m=r.jsx(Xn,{icon:s.agentIcon,name:s.agentName,size:"sm+"}),e[7]=s.agentIcon,e[8]=s.agentName,e[9]=m):m=e[9];let p;e[10]!==s.title?(p=r.jsx("div",{className:"line-clamp-2 text-sm font-medium text-foreground leading-snug",children:s.title}),e[10]=s.title,e[11]=p):p=e[11];let g;e[12]!==s?(g=LV(s),e[12]=s,e[13]=g):g=e[13];let x;e[14]!==g?(x=r.jsx("div",{className:"truncate text-xs text-muted-foreground mt-0.5",children:g}),e[14]=g,e[15]=x):x=e[15];let v;e[16]!==x||e[17]!==p?(v=r.jsxs("div",{className:"min-w-0 flex-1",children:[p,x]}),e[16]=x,e[17]=p,e[18]=v):v=e[18];let b;e[19]!==n?(b=!n&&r.jsx(kr,{size:16,className:"shrink-0 text-muted-foreground opacity-0 -translate-x-1 transition-all duration-200 group-hover/tile:opacity-100 group-hover/tile:translate-x-0","aria-hidden":!0}),e[19]=n,e[20]=b):b=e[20];let y;e[21]!==a||e[22]!==l||e[23]!==v||e[24]!==b||e[25]!==c||e[26]!==f||e[27]!==m?(y=r.jsxs("button",{type:"button",onClick:l,disabled:c,"aria-busy":a,className:f,children:[m,v,b]}),e[21]=a,e[22]=l,e[23]=v,e[24]=b,e[25]=c,e[26]=f,e[27]=m,e[28]=y):y=e[28];let _;return e[29]!==o||e[30]!==y?(_=r.jsxs(r.Fragment,{children:[y,o]}),e[29]=o,e[30]=y,e[31]=_):_=e[31],_}function jV(){const t=F.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx("div",{className:"mt-4 grid w-full grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-3",children:Array.from({length:3},CV)}),t[0]=e):e=t[0],e}function CV(t,e){return r.jsxs("div",{className:"flex w-full items-center gap-3 rounded-2xl bg-card card-shadow px-3 py-2.5",children:[r.jsx(Rt,{className:"size-10 rounded-xl"}),r.jsxs("div",{className:"flex-1 space-y-1.5",children:[r.jsx(Rt,{className:"h-3 w-2/3"}),r.jsx(Rt,{className:"h-2.5 w-1/3"})]})]},`chip-skeleton-${e}`)}function kV(t){const e=F.c(18),{tile:s,prompts:n,isEditMode:i,tileWidth:o}=t,{org:a}=Oe(),{open:l,startBlank:c,dialog:d,starting:h}=X9(s.agentId),u=n.filter(VV),f=E3(s),m=re(),p="relative flex h-full w-full flex-col p-3";let g;e[0]!==i||e[1]!==f||e[2]!==c||e[3]!==h||e[4]!==m?(g=!i&&r.jsx("button",{type:"button",onClick:()=>{c(f?{main:f}:void 0)},disabled:h,"aria-busy":h,className:"mb-1 self-start rounded-md px-2 py-1 text-[10px] text-muted-foreground transition-colors hover:bg-accent/60 hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-progress disabled:opacity-60",children:m("home.homeGrid.openChat")}),e[0]=i,e[1]=f,e[2]=c,e[3]=h,e[4]=m,e[5]=g):g=e[5];const x="flex min-h-0 flex-1 gap-3 overflow-hidden";let v;e[6]===Symbol.for("react.memo_cache_sentinel")?(v=r.jsx(TV,{}),e[6]=v):v=e[6];let b;e[7]!==a.id||e[8]!==a.slug||e[9]!==s?(b=r.jsx("div",{className:"min-h-0 flex-1 overflow-hidden rounded-lg border border-border",children:r.jsx(A.Suspense,{fallback:v,children:r.jsx(NV,{tile:s,orgId:a.id,orgSlug:a.slug})})}),e[7]=a.id,e[8]=a.slug,e[9]=s,e[10]=b):b=e[10];const y=u.length>0&&!i&&o>=2&&r.jsx("div",{className:"flex w-44 shrink-0 flex-col gap-2 overflow-hidden",children:u.map(w=>r.jsx("button",{type:"button",onClick:()=>l(w),disabled:h,className:"shrink-0 rounded-lg border border-border bg-background px-2.5 py-2 text-left text-xs leading-snug text-foreground transition-colors hover:bg-accent/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-progress disabled:opacity-60",children:r.jsx("span",{className:"line-clamp-2",children:w.title})},w.promptName))});let _;e[11]!==b||e[12]!==y?(_=r.jsxs("div",{className:x,children:[b,y]}),e[11]=b,e[12]=y,e[13]=_):_=e[13];let L;return e[14]!==d||e[15]!==g||e[16]!==_?(L=r.jsxs("div",{className:p,children:[g,_,d]}),e[14]=d,e[15]=g,e[16]=_,e[17]=L):L=e[17],L}function VV(t){return!!t.promptName}function NV(t){const e=F.c(13),{tile:s,orgId:n,orgSlug:i}=t;let o;e[0]!==n||e[1]!==i||e[2]!==s.connectionId?(o={connectionId:s.connectionId,orgId:n,orgSlug:i},e[0]=n,e[1]=i,e[2]=s.connectionId,e[3]=o):o=e[3];const a=ht(o),l=s.minHeight??200,c=s.maxHeight??4e3;let d;return e[4]!==a||e[5]!==n||e[6]!==i||e[7]!==l||e[8]!==c||e[9]!==s.connectionId||e[10]!==s.resourceUri||e[11]!==s.toolInput?(d=r.jsx(pb,{resourceURI:s.resourceUri,orgId:n,orgSlug:i,connectionId:s.connectionId,client:a,toolInput:s.toolInput,displayMode:"fullscreen",minHeight:l,maxHeight:c,className:"h-full"}),e[4]=a,e[5]=n,e[6]=i,e[7]=l,e[8]=c,e[9]=s.connectionId,e[10]=s.resourceUri,e[11]=s.toolInput,e[12]=d):d=e[12],d}function TV(){const t=F.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsxs("div",{className:"flex h-full w-full flex-col gap-2 p-4",children:[r.jsx(Rt,{className:"h-3 w-2/3"}),r.jsx(Rt,{className:"h-3 w-1/2"}),r.jsx(Rt,{className:"mt-1 h-full w-full rounded-md"})]}),t[0]=e):e=t[0],e}function AV(t){const e=F.c(18),{icon:s,name:n}=t,i=re();let o;e[0]!==s||e[1]!==n?(o=r.jsx(Xn,{icon:s,name:n,size:"sm+"}),e[0]=s,e[1]=n,e[2]=o):o=e[2];let a;e[3]!==n?(a=r.jsx("div",{className:"truncate text-sm font-medium text-foreground",children:n}),e[3]=n,e[4]=a):a=e[4];let l;e[5]!==i?(l=i("home.homeGrid.loadingTile"),e[5]=i,e[6]=l):l=e[6];let c;e[7]!==l?(c=r.jsx("div",{className:"truncate text-xs text-muted-foreground",children:l}),e[7]=l,e[8]=c):c=e[8];let d;e[9]!==a||e[10]!==c?(d=r.jsxs("div",{className:"min-w-0 flex-1",children:[a,c]}),e[9]=a,e[10]=c,e[11]=d):d=e[11];let h;e[12]!==o||e[13]!==d?(h=r.jsxs("div",{className:"flex items-center gap-2.5",children:[o,d]}),e[12]=o,e[13]=d,e[14]=h):h=e[14];let u;e[15]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsxs("div",{className:"flex flex-1 flex-col gap-2 pt-1",children:[r.jsx(Rt,{className:"h-3 w-3/4"}),r.jsx(Rt,{className:"h-3 w-1/2"}),r.jsx(Rt,{className:"h-3 w-2/3"})]}),e[15]=u):u=e[15];let f;return e[16]!==h?(f=r.jsxs("div",{className:"flex h-full w-full flex-col gap-3 p-5 opacity-60",children:[h,u]}),e[16]=h,e[17]=f):f=e[17],f}function EV(t){const e=F.c(13),{tile:s,prompts:n,isEditMode:i}=t,o=re(),{open:a,startBlank:l,dialog:c,starting:d}=X9(s.agentId),h=n.filter(PV),u=E3(s),f="flex h-full w-full flex-col gap-3 p-4";let m;e[0]!==u||e[1]!==l?(m=()=>{l(u?{main:u}:void 0)},e[0]=u,e[1]=l,e[2]=m):m=e[2];const p=d||i;let g;e[3]!==o?(g=o("home.homeGrid.openChat"),e[3]=o,e[4]=g):g=e[4];let x;e[5]!==m||e[6]!==p||e[7]!==g?(x=r.jsx("button",{type:"button",onClick:m,disabled:p,className:"mb-1 self-start rounded-md px-2 py-1 text-[10px] text-muted-foreground transition-colors hover:bg-accent/60 hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-progress disabled:opacity-60",children:g}),e[5]=m,e[6]=p,e[7]=g,e[8]=x):x=e[8];const v=h.length>0&&!i&&r.jsx("div",{className:"grid grid-cols-1 gap-2 overflow-hidden sm:grid-cols-2",children:h.map(y=>r.jsx("button",{type:"button",onClick:()=>!i&&a(y),disabled:d,className:"rounded-lg border border-border bg-background px-2.5 py-2 text-left text-xs leading-snug text-foreground transition-colors hover:bg-accent/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-progress disabled:opacity-60",children:r.jsx("span",{className:"line-clamp-2",children:y.title})},y.promptName))});let b;return e[9]!==c||e[10]!==x||e[11]!==v?(b=r.jsxs("div",{className:f,children:[x,v,c]}),e[9]=c,e[10]=x,e[11]=v,e[12]=b):b=e[12],b}function PV(t){return!!t.promptName}function RV({isEditMode:t}){const e=re(),{org:s}=Oe(),{isLoading:n,prompts:i,tiles:o}=Cm(s.slug),a=i.filter(S=>!$u(S.agentId)),l=o.filter(S=>!$u(S.agentId)),c=c2()?.ids??[],d=new Set(c),h=d2(),u=$s(),f=Ls(),m=new Set(l.map(S=>S.agentId)),p=new Map;for(const S of a){const C=p.get(S.agentId);C?C.push(S):p.set(S.agentId,[S])}const g=a.filter(S=>!m.has(S.agentId)),x=[...l.map(S=>({kind:"tile",id:yV(S),data:S})),...g.map(S=>({kind:"prompt",id:_V(S),data:S})),...Y9.map(S=>({kind:"native",id:j3(S.id),data:S}))],v=new Map(x.map(S=>[S.id,S])),b=Wk(x.map(S=>S.kind==="native"?{id:S.id,defaultSize:S.data.defaultSize,minSize:S.data.minSize,defaultHidden:S.data.defaultHidden}:{id:S.id,defaultSize:S.kind==="tile"?xV:bV,minSize:S.kind==="tile"?vV:void 0,pinned:d.has(S.data.agentId)})),y=S=>{h.apply(C=>C.filter(N=>N!==S)).catch(()=>ge.error(e("home.homeGrid.couldntRemoveFromHome")))},_=async S=>{if(l.filter(N=>N.agentId===S.agentId).length<=1){y(S.agentId);return}try{const V=(await u.call("COLLECTION_VIRTUAL_MCP_GET",{id:S.agentId})).item;if(!V)throw new Error("Agent not found");const E=ur(V.metadata?.ui),T=S.tileId?E.filter(k=>k.tileId!==S.tileId):E.filter(k=>k.connectionId!==S.connectionId||k.resourceUri!==S.resourceUri);await u.call("COLLECTION_VIRTUAL_MCP_UPDATE",{id:S.agentId,data:{metadata:{...V.metadata??{},ui:{...V.metadata?.ui??{},homeTile:null,homeTiles:T}}}}),f.invalidateQueries({queryKey:at.homeNextActions(s.slug)})}catch{ge.error(e("home.homeGrid.couldntRemoveTile"))}},L=S=>{const C=v.get(S);if(C){if(C.kind==="native"){b.hideTile(S);return}if(!d.has(C.data.agentId)){b.hideTile(S);return}C.kind==="tile"?_(C.data):y(C.data.agentId)}},w=S=>{const C=v.get(S.id);if(!C)return null;if(C.kind==="native")return r.jsx(gV,{nativeId:C.data.id});if(C.kind==="tile"){const N=p.get(C.data.agentId)??[];return r.jsx(ys,{fallback:r.jsx(EV,{tile:C.data,prompts:N,isEditMode:t}),children:r.jsx(A.Suspense,{fallback:r.jsx(AV,{icon:C.data.agentIcon,name:C.data.agentName}),children:r.jsx(kV,{tile:C.data,prompts:N,isEditMode:t,tileWidth:S.w})})})}return r.jsx(wV,{entry:C.data,isEditMode:t})};return n||b.isLoading?r.jsx(jV,{}):b.snapshot.visible.length===0&&!t?null:r.jsx("div",{className:"mt-4 flex w-full max-w-7xl flex-col gap-4",children:r.jsx(Mk,{tiles:b.snapshot.visible,isEditMode:t,renderTile:w,onMove:b.moveTile,onResize:b.resizeTile,onRemove:L})})}function yr(t,e,s){const n=t.slice();return n.splice(s<0?n.length+s:s,0,n.splice(e,1)[0]),n}function DV(t,e){return t.reduce((s,n,i)=>{const o=e.get(n);return o&&(s[i]=o),s},Array(t.length))}function La(t){return t!==null&&t>=0}function IV(t,e){if(t===e)return!0;if(t.length!==e.length)return!1;for(let s=0;s<t.length;s++)if(t[s]!==e[s])return!1;return!0}function MV(t){return typeof t=="boolean"?{draggable:t,droppable:t}:t}const P3=t=>{let{rects:e,activeIndex:s,overIndex:n,index:i}=t;const o=yr(e,n,s),a=e[i],l=o[i];return!l||!a?null:{x:l.left-a.left,y:l.top-a.top,scaleX:l.width/a.width,scaleY:l.height/a.height}},Sa={scaleX:1,scaleY:1},Q9=t=>{var e;let{activeIndex:s,activeNodeRect:n,index:i,rects:o,overIndex:a}=t;const l=(e=o[s])!=null?e:n;if(!l)return null;if(i===s){const d=o[a];return d?{x:0,y:s<a?d.top+d.height-(l.top+l.height):d.top-l.top,...Sa}:null}const c=OV(o,i,s);return i>s&&i<=a?{x:0,y:-l.height-c,...Sa}:i<s&&i>=a?{x:0,y:l.height+c,...Sa}:{x:0,y:0,...Sa}};function OV(t,e,s){const n=t[e],i=t[e-1],o=t[e+1];return n?s<e?i?n.top-(i.top+i.height):o?o.top-(n.top+n.height):0:o?o.top-(n.top+n.height):i?n.top-(i.top+i.height):0:0}const R3="Sortable",D3=it.createContext({activeIndex:-1,containerId:R3,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:P3,disabled:{draggable:!1,droppable:!1}});function Z9(t){let{children:e,id:s,items:n,strategy:i=P3,disabled:o=!1}=t;const{active:a,dragOverlay:l,droppableRects:c,over:d,measureDroppableContainers:h}=v3(),u=da(R3,s),f=l.rect!==null,m=A.useMemo(()=>n.map(w=>typeof w=="object"&&"id"in w?w.id:w),[n]),p=a!=null,g=a?m.indexOf(a.id):-1,x=d?m.indexOf(d.id):-1,v=A.useRef(m),b=!IV(m,v.current),y=x!==-1&&g===-1||b,_=MV(o);nn(()=>{b&&p&&h(m)},[b,m,p,h]),A.useEffect(()=>{v.current=m},[m]);const L=A.useMemo(()=>({activeIndex:g,containerId:u,disabled:_,disableTransforms:y,items:m,overIndex:x,useDragOverlay:f,sortedRects:DV(m,c),strategy:i}),[g,u,_.draggable,_.droppable,y,m,x,c,f,i]);return it.createElement(D3.Provider,{value:L},e)}const BV=t=>{let{id:e,items:s,activeIndex:n,overIndex:i}=t;return yr(s,n,i).indexOf(e)},$V=t=>{let{containerId:e,isSorting:s,wasDragging:n,index:i,items:o,newIndex:a,previousItems:l,previousContainerId:c,transition:d}=t;return!d||!n||l!==o&&i===a?!1:s?!0:a!==i&&e===c},FV={duration:200,easing:"ease"},I3="transform",zV=Ln.Transition.toString({property:I3,duration:0,easing:"linear"}),KV={roleDescription:"sortable"};function UV(t){let{disabled:e,index:s,node:n,rect:i}=t;const[o,a]=A.useState(null),l=A.useRef(s);return nn(()=>{if(!e&&s!==l.current&&n.current){const c=i.current;if(c){const d=Or(n.current,{ignoreTransform:!0}),h={x:c.left-d.left,y:c.top-d.top,scaleX:c.width/d.width,scaleY:c.height/d.height};(h.x||h.y)&&a(h)}}s!==l.current&&(l.current=s)},[e,s,n,i]),A.useEffect(()=>{o&&a(null)},[o]),o}function eu(t){let{animateLayoutChanges:e=$V,attributes:s,disabled:n,data:i,getNewIndex:o=BV,id:a,strategy:l,resizeObserverConfig:c,transition:d=FV}=t;const{items:h,containerId:u,activeIndex:f,disabled:m,disableTransforms:p,sortedRects:g,overIndex:x,useDragOverlay:v,strategy:b}=A.useContext(D3),y=HV(n,m),_=h.indexOf(a),L=A.useMemo(()=>({sortable:{containerId:u,index:_,items:h},...i}),[u,i,_,h]),w=A.useMemo(()=>h.slice(h.indexOf(a)),[h,a]),{rect:j,node:S,isOver:C,setNodeRef:N}=_k({id:a,data:L,disabled:y.droppable,resizeObserverConfig:{updateMeasurementsFor:w,...c}}),{active:V,activatorEvent:E,activeNodeRect:T,attributes:k,setNodeRef:R,listeners:P,isDragging:D,over:I,setActivatorNodeRef:M,transform:O}=x3({id:a,data:L,attributes:{...KV,...s},disabled:y.draggable}),$=oC(N,R),B=!!V,z=B&&!p&&La(f)&&La(x),K=!v&&D,G=K&&z?O:null,U=z?G??(l??b)({rects:g,activeNodeRect:T,activeIndex:f,overIndex:x,index:_}):null,W=La(f)&&La(x)?o({id:a,items:h,activeIndex:f,overIndex:x}):_,H=V?.id,X=A.useRef({activeId:H,items:h,newIndex:W,containerId:u}),q=h!==X.current.items,Z=e({active:V,containerId:u,isDragging:D,isSorting:B,id:a,index:_,items:h,newIndex:X.current.newIndex,previousItems:X.current.items,previousContainerId:X.current.containerId,transition:d,wasDragging:X.current.activeId!=null}),Q=UV({disabled:!Z,index:_,node:S,rect:j});return A.useEffect(()=>{B&&X.current.newIndex!==W&&(X.current.newIndex=W),u!==X.current.containerId&&(X.current.containerId=u),h!==X.current.items&&(X.current.items=h)},[B,W,u,h]),A.useEffect(()=>{if(H===X.current.activeId)return;if(H!=null&&X.current.activeId==null){X.current.activeId=H;return}const J=setTimeout(()=>{X.current.activeId=H},50);return()=>clearTimeout(J)},[H]),{active:V,activeIndex:f,attributes:k,data:L,rect:j,index:_,newIndex:W,items:h,isOver:C,isSorting:B,isDragging:D,listeners:P,node:S,overIndex:x,over:I,setNodeRef:$,setActivatorNodeRef:M,setDroppableNodeRef:N,setDraggableNodeRef:R,transform:Q??U,transition:ee()};function ee(){if(Q||q&&X.current.newIndex===_)return zV;if(!(K&&!hc(E)||!d)&&(B||Z))return Ln.Transition.toString({...d,property:I3})}}function HV(t,e){var s,n;return typeof t=="boolean"?{draggable:t,droppable:!1}:{draggable:(s=t?.draggable)!=null?s:e.draggable,droppable:(n=t?.droppable)!=null?n:e.droppable}}function Nl(t){if(!t)return!1;const e=t.data.current;return!!(e&&"sortable"in e&&typeof e.sortable=="object"&&"containerId"in e.sortable&&"items"in e.sortable&&"index"in e.sortable)}const WV=[ot.Down,ot.Right,ot.Up,ot.Left],tu=(t,e)=>{let{context:{active:s,collisionRect:n,droppableRects:i,droppableContainers:o,over:a,scrollableAncestors:l}}=e;if(WV.includes(t.code)){if(t.preventDefault(),!s||!n)return;const c=[];o.getEnabled().forEach(u=>{if(!u||u!=null&&u.disabled)return;const f=i.get(u.id);if(f)switch(t.code){case ot.Down:n.top<f.top&&c.push(u);break;case ot.Up:n.top>f.top&&c.push(u);break;case ot.Left:n.left>f.left&&c.push(u);break;case ot.Right:n.left<f.left&&c.push(u);break}});const d=LC({collisionRect:n,droppableRects:i,droppableContainers:c});let h=t3(d,"id");if(h===a?.id&&d.length>1&&(h=d[1].id),h!=null){const u=o.get(s.id),f=o.get(h),m=f?i.get(f.id):null,p=f?.node.current;if(p&&m&&u&&f){const x=mc(p).some((w,j)=>l[j]!==w),v=M3(u,f),b=qV(u,f),y=x||!v?{x:0,y:0}:{x:b?n.width-m.width:0,y:b?n.height-m.height:0},_={x:m.left,y:m.top};return y.x&&y.y?_:Fo(_,y)}}}};function M3(t,e){return!Nl(t)||!Nl(e)?!1:t.data.current.sortable.containerId===e.data.current.sortable.containerId}function qV(t,e){return!Nl(t)||!Nl(e)||!M3(t,e)?!1:t.data.current.sortable.index<e.data.current.sortable.index}function su(t){const e=F.c(11),{isPinned:s,submitting:n,onClick:i,label:o}=t,a=s?"text-muted-foreground hover:bg-destructive/10 hover:text-destructive":"bg-foreground text-background hover:opacity-90";let l;e[0]!==a?(l=ie("inline-flex size-7 shrink-0 items-center justify-center rounded-md text-xs transition-colors disabled:opacity-50 disabled:cursor-progress",a),e[0]=a,e[1]=l):l=e[1];let c;e[2]!==s||e[3]!==n?(c=n?r.jsx(et,{size:12,className:"animate-spin"}):s?r.jsx($m,{size:14}):r.jsx(kt,{size:14}),e[2]=s,e[3]=n,e[4]=c):c=e[4];let d;return e[5]!==o||e[6]!==i||e[7]!==n||e[8]!==l||e[9]!==c?(d=r.jsx("button",{type:"button",onClick:i,disabled:n,"aria-label":o,title:o,className:l,children:c}),e[5]=o,e[6]=i,e[7]=n,e[8]=l,e[9]=c,e[10]=d):d=e[10],d}function GV(t){const e=F.c(32),{agent:s,home:n,curated:i}=t,{org:o}=Oe();let a;e[0]!==s.id||e[1]!==o.id||e[2]!==o.slug?(a={connectionId:s.id,orgId:o.id,orgSlug:o.slug},e[0]=s.id,e[1]=o.id,e[2]=o.slug,e[3]=a):a=e[3];const l=ht(a);let c;e[4]!==s.id||e[5]!==o.id?(c=at.agentPrompts(o.id,s.id),e[4]=s.id,e[5]=o.id,e[6]=c):c=e[6];let d;e[7]!==l?(d=async()=>{const{prompts:L}=await l.listPrompts();return L.map(QV)},e[7]=l,e[8]=d):d=e[8];let h;e[9]!==c||e[10]!==d?(h={queryKey:c,queryFn:d,staleTime:3e4,retry:!1},e[9]=c,e[10]=d,e[11]=h):h=e[11];const{data:u,isLoading:f,error:m}=Mt(h),p=Cm(o.slug);let g,x;if(e[12]!==s.id||e[13]!==u||e[14]!==p.prompts){let L;e[17]!==s.id?(L=j=>j.agentId===s.id&&j.promptName,e[17]=s.id,e[18]=L):L=e[18],g=p.prompts.filter(L).map(XV);let w;e[19]!==u?(w=u??[],e[19]=u,e[20]=w):w=e[20],x=[...w];for(const j of g)x.some(S=>S.name===j.name)||x.push(j);e[12]=s.id,e[13]=u,e[14]=p.prompts,e[15]=g,e[16]=x}else g=e[15],x=e[16];if(f&&g.length===0){let L;return e[21]===Symbol.for("react.memo_cache_sentinel")?(L=r.jsxs("div",{className:"flex flex-col gap-1",children:[r.jsx(Rt,{className:"h-7 w-full"}),r.jsx(Rt,{className:"h-7 w-2/3"})]}),e[21]=L):L=e[21],L}if(m&&g.length===0)return console.error("[home-tiles] listPrompts failed for agent",s.id,m),null;if(x.length===0)return null;let v;e[22]!==i||e[23]!==x?(v=i??x.map(JV),e[22]=i,e[23]=x,e[24]=v):v=e[24];let b;e[25]!==v?(b=new Set(v),e[25]=v,e[26]=b):b=e[26];const y=b;let _;return e[27]!==s||e[28]!==n||e[29]!==x||e[30]!==y?(_=r.jsx("div",{className:"flex flex-col gap-0.5",children:x.map(L=>r.jsx(ZV,{agent:s,home:n,prompt:L,allPromptNames:x.map(YV),isPinned:y.has(L.name)},L.name))}),e[27]=s,e[28]=n,e[29]=x,e[30]=y,e[31]=_):_=e[31],_}function YV(t){return t.name}function JV(t){return t.name}function XV(t){return{name:t.promptName,title:t.title,description:t.description}}function QV(t){return{name:t.name,title:t.title,description:t.description}}function ZV({agent:t,home:e,prompt:s,allPromptNames:n,isPinned:i}){const o=re(),[a,l]=A.useState(!1),c=async()=>{if(!i&&!e.isOnHome(t.id)&&e.atLimit){ge.error(o("home.agentPromptList.homeIsFull",{limit:ha}));return}l(!0);try{const d=t.metadata?.ui?.homePrompts;let h;Array.isArray(d)?h=i?d.filter(f=>f!==s.name):[...d,s.name]:h=i?n.filter(f=>f!==s.name):n;const u={...t.metadata??{},ui:{...t.metadata?.ui??{},homePrompts:h}};await e.saveAgentMetadata(t,u)}catch(d){console.error("[home-tiles] failed to toggle prompt",d),ge.error(o("home.agentPromptList.couldntUpdateHome"))}finally{l(!1)}};return r.jsxs("div",{className:"flex items-center gap-2.5 rounded-md px-2 py-1 hover:bg-accent/40",children:[r.jsx("div",{className:"min-w-0 flex-1 truncate text-sm text-foreground",children:s.title??Ci(s.name)}),r.jsx(su,{isPinned:i,submitting:a,onClick:c,label:o(i?"home.agentPromptList.removeFromHome":"home.agentPromptList.addToHome")})]})}function nu(t){const e=F.c(7),{title:s,hint:n}=t;let i;e[0]!==s?(i=r.jsx("span",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:s}),e[0]=s,e[1]=i):i=e[1];let o;e[2]!==n?(o=n&&r.jsx("span",{className:"text-xs text-muted-foreground",children:n}),e[2]=n,e[3]=o):o=e[3];let a;return e[4]!==i||e[5]!==o?(a=r.jsxs("div",{className:"flex items-center justify-between px-1",children:[i,o]}),e[4]=i,e[5]=o,e[6]=a):a=e[6],a}const eN={tasks:Xl,coding:Zs,analytics:Nm,sales:m9,"recent-conversations":X0};function tN(){const t=F.c(19),e=re(),{layout:s,commitLayout:n}=F9();let i;t[0]!==s.hidden?(i=new Set(s.hidden),t[0]=s.hidden,t[1]=i):i=t[1];const o=i;let a;t[2]!==s.shown?(a=s.shown??[],t[2]=s.shown,t[3]=a):a=t[3];let l;t[4]!==a?(l=new Set(a),t[4]=a,t[5]=l):l=t[5];const c=l;let d;t[6]!==e?(d=e("home.nativeTilesSection.builtInTiles"),t[6]=e,t[7]=d):d=t[7];let h;t[8]!==d?(h=r.jsx(nu,{title:d}),t[8]=d,t[9]=h):h=t[9];let u;t[10]!==n||t[11]!==o||t[12]!==s||t[13]!==c||t[14]!==e?(u=Y9.map(m=>{const p=j3(m.id),g=m.defaultHidden?c.has(p)&&!o.has(p):!o.has(p),x=eN[m.id]??X0,v=()=>{if(m.defaultHidden){n({...s,hidden:s.hidden.filter(b=>b!==p),shown:g?(s.shown??[]).filter(b=>b!==p):[...s.shown??[],p]});return}n({...s,hidden:g?[...s.hidden,p]:s.hidden.filter(b=>b!==p)})};return r.jsxs("div",{className:"flex items-center gap-3 rounded-lg border border-border/60 px-3 py-2.5",children:[r.jsx("span",{className:"flex size-8 shrink-0 items-center justify-center rounded-md bg-muted text-muted-foreground",children:r.jsx(x,{size:16})}),r.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-medium text-foreground",children:e(m.titleKey)}),r.jsxs(le,{type:"button",size:"sm",variant:g?"outline":"special",className:"h-8 gap-1.5",onClick:v,children:[g?r.jsx($m,{size:14}):r.jsx(kt,{size:14}),e(g?"home.nativeTilesSection.remove":"home.nativeTilesSection.add")]})]},m.id)}),t[10]=n,t[11]=o,t[12]=s,t[13]=c,t[14]=e,t[15]=u):u=t[15];let f;return t[16]!==h||t[17]!==u?(f=r.jsxs("div",{className:"flex flex-col gap-1.5",children:[h,u]}),t[16]=h,t[17]=u,t[18]=f):f=t[18],f}function sN(t,e,s){const n={};for(const[i,o]of Object.entries(t)){const a=e[i]?.type;if((a==="object"||a==="array")&&typeof o=="string"){if(!o.trim())continue;try{n[i]=JSON.parse(o)}catch{return null}}else if((a==="number"||a==="integer")&&(typeof o=="string"||typeof o=="number")){if(typeof o=="string"&&!o.trim())continue;const l=typeof o=="string"?Number(o):o;if(!Number.isFinite(l)||a==="integer"&&!Number.isInteger(l))return null;n[i]=l}else if(typeof o=="string"){if(!o.trim())continue;n[i]=o}else o!=null&&(n[i]=o)}return s?.some(i=>!(i in n))?null:n}function nN(t,e){if(!t||!e)return{};const s={};for(const[n,i]of Object.entries(t)){const o=e[n]?.type;(o==="object"||o==="array")&&i!=null&&typeof i!="string"?s[n]=JSON.stringify(i,null,2):s[n]=i}return s}function iN(t){if(!t)return"";const e=Object.entries(t).filter(([,s])=>s!=null&&s!=="");return e.length===0?"":e.slice(0,3).map(([s,n])=>{const i=typeof n=="object"?JSON.stringify(n):String(n);return`${s}=${i.length>20?`${i.slice(0,20)}…`:i}`}).join(", ")}function rN(t){const e=F.c(11),{properties:s,required:n,values:i,onChange:o}=t;let a;e[0]!==n?(a=n??[],e[0]=n,e[1]=a):a=e[1];let l;e[2]!==a?(l=new Set(a),e[2]=a,e[3]=l):l=e[3];const c=l;let d;e[4]!==s?(d=Object.entries(s),e[4]=s,e[5]=d):d=e[5];let h;return e[6]!==o||e[7]!==c||e[8]!==d||e[9]!==i?(h=r.jsx("div",{className:"flex flex-col gap-2",children:d.map(u=>{const[f,m]=u;return r.jsxs("div",{className:"flex flex-col gap-0.5",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("label",{className:"text-xs font-medium leading-none flex items-center gap-1",children:[f,c.has(f)&&r.jsx("span",{className:"text-destructive text-[10px]",children:"*"})]}),r.jsx("span",{className:"text-[10px] text-muted-foreground font-mono",children:m.type})]}),m.description&&r.jsx("p",{className:"text-[10px] text-muted-foreground leading-snug",children:m.description}),r.jsx(oN,{type:m.type,fieldKey:f,value:i[f],onChange:p=>o(f,p)})]},f)})}),e[6]=o,e[7]=c,e[8]=d,e[9]=i,e[10]=h):h=e[10],h}function oN(t){const e=F.c(40),{type:s,fieldKey:n,value:i,onChange:o}=t,a=re();if(s==="object"||s==="array"){const u=i??"";let f;e[0]!==o?(f=g=>o(g.target.value),e[0]=o,e[1]=f):f=e[1];let m;e[2]!==n||e[3]!==a?(m=a("common.toolInputForm.jsonPlaceholder",{fieldKey:n}),e[2]=n,e[3]=a,e[4]=m):m=e[4];let p;return e[5]!==u||e[6]!==f||e[7]!==m?(p=r.jsx(gr,{className:"font-mono text-xs h-16",value:u,onChange:f,placeholder:m,rows:2}),e[5]=u,e[6]=f,e[7]=m,e[8]=p):p=e[8],p}if(s==="boolean"){const u=i!=null?String(i):"";let f;e[9]!==o?(f=L=>o(L==="true"),e[9]=o,e[10]=f):f=e[10];let m;e[11]!==a?(m=a("common.toolInputForm.selectPlaceholder"),e[11]=a,e[12]=m):m=e[12];let p;e[13]!==m?(p=r.jsx(Jt,{className:"h-7 text-xs",children:r.jsx(as,{placeholder:m})}),e[13]=m,e[14]=p):p=e[14];let g;e[15]!==a?(g=a("common.toolInputForm.true"),e[15]=a,e[16]=g):g=e[16];let x;e[17]!==g?(x=r.jsx(vt,{value:"true",children:g}),e[17]=g,e[18]=x):x=e[18];let v;e[19]!==a?(v=a("common.toolInputForm.false"),e[19]=a,e[20]=v):v=e[20];let b;e[21]!==v?(b=r.jsx(vt,{value:"false",children:v}),e[21]=v,e[22]=b):b=e[22];let y;e[23]!==x||e[24]!==b?(y=r.jsxs(Xt,{children:[x,b]}),e[23]=x,e[24]=b,e[25]=y):y=e[25];let _;return e[26]!==u||e[27]!==f||e[28]!==p||e[29]!==y?(_=r.jsxs(Qt,{value:u,onValueChange:f,children:[p,y]}),e[26]=u,e[27]=f,e[28]=p,e[29]=y,e[30]=_):_=e[30],_}const l=i??"";let c;e[31]!==o?(c=u=>o(u.target.value),e[31]=o,e[32]=c):c=e[32];let d;e[33]!==n||e[34]!==a?(d=a("common.toolInputForm.enterPlaceholder",{fieldKey:n}),e[33]=n,e[34]=a,e[35]=d):d=e[35];let h;return e[36]!==l||e[37]!==c||e[38]!==d?(h=r.jsx(rt,{className:"h-7 text-xs",value:l,onChange:c,placeholder:d}),e[36]=l,e[37]=c,e[38]=d,e[39]=h):h=e[39],h}const ha=8;function aN(t){const e=F.c(29),{open:s,onOpenChange:n}=t,[i,o]=A.useState(""),a=re();let l;e[0]!==a?(l=a("home.addTileDrawer.title"),e[0]=a,e[1]=l):l=e[1];let c;e[2]!==l?(c=r.jsx(Db,{children:l}),e[2]=l,e[3]=c):c=e[3];let d;e[4]!==a?(d=a("home.addTileDrawer.description"),e[4]=a,e[5]=d):d=e[5];let h;e[6]!==d?(h=r.jsx(Ib,{children:d}),e[6]=d,e[7]=h):h=e[7];let u;e[8]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx(Q0,{size:14,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-muted-foreground pointer-events-none","aria-hidden":!0}),e[8]=u):u=e[8];let f;e[9]===Symbol.for("react.memo_cache_sentinel")?(f=_=>o(_.target.value),e[9]=f):f=e[9];let m;e[10]!==a?(m=a("home.addTileDrawer.searchPlaceholder"),e[10]=a,e[11]=m):m=e[11];let p;e[12]!==i||e[13]!==m?(p=r.jsxs("div",{className:"relative mt-3",children:[u,r.jsx(rt,{value:i,onChange:f,placeholder:m,className:"pl-8 h-8 text-sm"})]}),e[12]=i,e[13]=m,e[14]=p):p=e[14];let g;e[15]!==c||e[16]!==h||e[17]!==p?(g=r.jsxs(Mb,{className:"px-5 py-4 border-b border-border",children:[c,h,p]}),e[15]=c,e[16]=h,e[17]=p,e[18]=g):g=e[18];let x;e[19]===Symbol.for("react.memo_cache_sentinel")?(x=r.jsx(NN,{}),e[19]=x):x=e[19];let v;e[20]!==i?(v=r.jsx(ii,{className:"flex-1 min-h-0 [&_[data-slot=scroll-area-viewport]>div]:!block",children:r.jsx("div",{className:"p-3 flex flex-col gap-4",children:r.jsx(A.Suspense,{fallback:x,children:r.jsx(cN,{search:i})})})}),e[20]=i,e[21]=v):v=e[21];let b;e[22]!==v||e[23]!==g?(b=r.jsxs(Ob,{side:"right",className:"w-full sm:max-w-md p-0 flex flex-col",children:[g,v]}),e[22]=v,e[23]=g,e[24]=b):b=e[24];let y;return e[25]!==n||e[26]!==s||e[27]!==b?(y=r.jsx(Bb,{open:s,onOpenChange:n,children:b}),e[25]=n,e[26]=s,e[27]=b,e[28]=y):y=e[28],y}function lN(t){const e=F.c(32),{org:s}=Oe(),n=c2();let i;e[0]!==n?.ids?(i=n?.ids??[],e[0]=n?.ids,e[1]=i):i=e[1];const o=i,a=d2(),l=H0(),c=Ls();let d;e[2]!==s||e[3]!==c?(d=()=>c.refetchQueries({queryKey:at.homeNextActions(s.slug),type:"active"}),e[2]=s,e[3]=c,e[4]=d):d=e[4];const h=d;let u;e[5]!==o?(u=C=>o.includes(C),e[5]=o,e[6]=u):u=e[6];const f=u;let m;e[7]!==o||e[8]!==t?(m=t?o.filter(C=>t.has(C)).length:o.length,e[7]=o,e[8]=t,e[9]=m):m=e[9];const g=m>=ha;let x;e[10]!==g||e[11]!==f||e[12]!==a?(x=C=>f(C)||g?Promise.resolve():a.apply(N=>N.includes(C)?null:[...N,C]),e[10]=g,e[11]=f,e[12]=a,e[13]=x):x=e[13];const v=x;let b;e[14]!==a?(b=C=>a.apply(N=>N.filter(V=>V!==C)),e[14]=a,e[15]=b):b=e[15];const y=b;let _;e[16]!==a?(_=C=>a.apply(()=>C),e[16]=a,e[17]=_):_=e[17];const L=_;let w;e[18]!==l||e[19]!==g||e[20]!==f||e[21]!==h||e[22]!==a?(w=async(C,N)=>{await l.update.mutateAsync({id:C.id,data:{metadata:N}}),!f(C.id)&&!g&&await a.apply(V=>V.includes(C.id)?null:[...V,C.id]),await h()},e[18]=l,e[19]=g,e[20]=f,e[21]=h,e[22]=a,e[23]=w):w=e[23];const j=w;let S;return e[24]!==v||e[25]!==g||e[26]!==o||e[27]!==f||e[28]!==y||e[29]!==L||e[30]!==j?(S={homeIds:o,isOnHome:f,atLimit:g,addAgent:v,removeAgent:y,reorder:L,saveAgentMetadata:j},e[24]=v,e[25]=g,e[26]=o,e[27]=f,e[28]=y,e[29]=L,e[30]=j,e[31]=S):S=e[31],S}function cN(t){const e=F.c(24),{search:s}=t;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n={pageSize:1e3},e[0]=n):n=e[0];const i=Zo(n);let o;e[1]!==i?(o=new Set(i.map(mN)),e[1]=i,e[2]=o):o=e[2];const a=lN(o);let l,c,d;if(e[3]!==i||e[4]!==a||e[5]!==s){const x=new Map(i.map(fN));l=s.trim().toLowerCase();const v=_=>!l||_.title?.toLowerCase().includes(l);c=a.homeIds.map(_=>x.get(_)).filter(hN).filter(v);const b=r9(i);let y;e[9]!==a?(y=_=>!a.isOnHome(_.id),e[9]=a,e[10]=y):y=e[10],d=i.filter(uN).filter(_=>!b.has(_.id)).filter(y).filter(v).sort(dN),e[3]=i,e[4]=a,e[5]=s,e[6]=l,e[7]=c,e[8]=d}else l=e[6],c=e[7],d=e[8];const h=d;let u;e[11]!==a||e[12]!==c?(u=r.jsx(pN,{home:a,agents:c}),e[11]=a,e[12]=c,e[13]=u):u=e[13];let f;e[14]!==l?(f=!l&&r.jsx(tN,{}),e[14]=l,e[15]=f):f=e[15];const m=!!l;let p;e[16]!==h||e[17]!==a||e[18]!==m?(p=r.jsx(xN,{home:a,agents:h,hasSearch:m}),e[16]=h,e[17]=a,e[18]=m,e[19]=p):p=e[19];let g;return e[20]!==u||e[21]!==f||e[22]!==p?(g=r.jsxs(r.Fragment,{children:[u,f,p]}),e[20]=u,e[21]=f,e[22]=p,e[23]=g):g=e[23],g}function dN(t,e){return(t.title??"").localeCompare(e.title??"")}function uN(t){return t.id&&!el(t.id)}function hN(t){return!!t}function fN(t){return[t.id,t]}function mN(t){return t.id}function pN(t){const e=F.c(19),{home:s,agents:n}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={activationConstraint:{distance:5}},e[0]=i):i=e[0];let o;e[1]===Symbol.for("react.memo_cache_sentinel")?(o={coordinateGetter:tu},e[1]=o):o=e[1];const a=fc(ti($r,i),ti(Br,o)),l=re();let c;e[2]!==s||e[3]!==l?(c=g=>{const{active:x,over:v}=g;if(!v||x.id===v.id)return;const b=s.homeIds,y=b.indexOf(x.id),_=b.indexOf(v.id);y===-1||_===-1||s.reorder(yr([...b],y,_)).catch(()=>ge.error(l("home.addTileDrawer.reorderError")))},e[2]=s,e[3]=l,e[4]=c):c=e[4];const d=c;let h;e[5]!==l?(h=l("home.addTileDrawer.onHomeTitle"),e[5]=l,e[6]=h):h=e[6];const u=`${s.homeIds.length}/${ha}`;let f;e[7]!==h||e[8]!==u?(f=r.jsx(nu,{title:h,hint:u}),e[7]=h,e[8]=u,e[9]=f):f=e[9];let m;e[10]!==n||e[11]!==d||e[12]!==s||e[13]!==a||e[14]!==l?(m=n.length===0?r.jsx("p",{className:"px-3 py-4 text-center text-xs text-muted-foreground",children:l("home.addTileDrawer.noAgentsOnHome")}):r.jsx(xc,{sensors:a,collisionDetection:U9,onDragEnd:d,children:r.jsx(Z9,{items:n.map(gN),strategy:Q9,children:r.jsx("div",{className:"flex flex-col gap-1",children:n.map(g=>r.jsx(_N,{agent:g,home:s},g.id))})})}),e[10]=n,e[11]=d,e[12]=s,e[13]=a,e[14]=l,e[15]=m):m=e[15];let p;return e[16]!==f||e[17]!==m?(p=r.jsxs("div",{className:"flex flex-col gap-1.5",children:[f,m]}),e[16]=f,e[17]=m,e[18]=p):p=e[18],p}function gN(t){return t.id}function xN(t){const e=F.c(7),{home:s,agents:n,hasSearch:i}=t,[o,a]=A.useState(20),l=n.slice(0,o),c=re(),d="flex flex-col gap-1.5";let h;e[0]!==c?(h=c("home.addTileDrawer.addToHomeTitle"),e[0]=c,e[1]=h):h=e[1];let u;e[2]!==h?(u=r.jsx(nu,{title:h}),e[2]=h,e[3]=u):u=e[3];const f=n.length===0?r.jsx("p",{className:"px-3 py-4 text-center text-xs text-muted-foreground",children:c(i?"home.addTileDrawer.noAgentsMatch":"home.addTileDrawer.allAgentsOnHome")}):r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"flex flex-col gap-1",children:l.map(p=>r.jsx(LN,{agent:p,home:s},p.id))}),n.length>o&&r.jsx("button",{type:"button",onClick:()=>a(vN),className:"mt-1 self-center rounded-md px-3 py-1.5 text-xs text-muted-foreground hover:bg-accent/40 hover:text-foreground",children:c("home.addTileDrawer.loadMore",{count:n.length-o})})]});let m;return e[4]!==u||e[5]!==f?(m=r.jsxs("div",{className:d,children:[u,f]}),e[4]=u,e[5]=f,e[6]=m):m=e[6],m}function vN(t){return t+20}function O3(t){const e=F.c(14),s=re();let n;e[0]!==t.metadata?.ui?(n=ur(t.metadata?.ui).filter(bN),e[0]=t.metadata?.ui,e[1]=n):n=e[1];const i=n.length,o=t.metadata?.ui?.homePrompts,a=Array.isArray(o)?o.length:null;let l;if(e[2]!==a||e[3]!==s||e[4]!==i){if(l=[],i>0){let c;e[6]!==s||e[7]!==i?(c=s("home.addTileDrawer.tileCountLabel",{count:i}),e[6]=s,e[7]=i,e[8]=c):c=e[8],l.push(c)}if(a!==null&&a>0){let c;e[9]!==a||e[10]!==s?(c=s("home.addTileDrawer.promptCountLabel",{count:a}),e[9]=a,e[10]=s,e[11]=c):c=e[11],l.push(c)}if(a===0){let c;e[12]!==s?(c=s("home.addTileDrawer.promptsOffLabel"),e[12]=s,e[13]=c):c=e[13],l.push(c)}e[2]=a,e[3]=s,e[4]=i,e[5]=l}else l=e[5];return l.join(" · ")}function bN(t){return!!t.resourceUri}function _N(t){const e=F.c(70),{agent:s,home:n}=t,[i,o]=A.useState(!1),a=re();let l;e[0]!==s.id?(l={id:s.id},e[0]=s.id,e[1]=l):l=e[1];const{attributes:c,listeners:d,setNodeRef:h,transform:u,transition:f,isDragging:m}=eu(l),p=O3(s)||a("home.addTileDrawer.quickAccess"),g=`home-agent-expansion-${s.id}`;let x;e[2]!==u?(x=Ln.Transform.toString(u),e[2]=u,e[3]=x):x=e[3];const v=m?.5:void 0,b=m?100:void 0;let y;e[4]!==x||e[5]!==v||e[6]!==b||e[7]!==f?(y={transform:x,transition:f,opacity:v,zIndex:b},e[4]=x,e[5]=v,e[6]=b,e[7]=f,e[8]=y):y=e[8];const _=y,L=m&&"shadow-lg";let w;e[9]!==L?(w=ie("rounded-lg border border-border bg-card",L),e[9]=L,e[10]=w):w=e[10];const j=s.title??s.id;let S;e[11]!==a||e[12]!==j?(S=a("home.addTileDrawer.dragToReorder",{name:j}),e[11]=a,e[12]=j,e[13]=S):S=e[13];let C;e[14]===Symbol.for("react.memo_cache_sentinel")?(C=r.jsx(ia,{size:14}),e[14]=C):C=e[14];let N;e[15]!==c||e[16]!==d||e[17]!==S?(N=r.jsx("button",{type:"button",...c,...d,className:"shrink-0 text-muted-foreground hover:text-foreground cursor-grab active:cursor-grabbing outline-none focus-visible:ring-2 focus-visible:ring-ring rounded","aria-label":S,children:C}),e[15]=c,e[16]=d,e[17]=S,e[18]=N):N=e[18];let V;e[19]===Symbol.for("react.memo_cache_sentinel")?(V=()=>o(yN),e[19]=V):V=e[19];const E=s.title??s.id;let T;e[20]!==s.icon||e[21]!==E?(T=r.jsx(Xn,{icon:s.icon,name:E,size:"sm"}),e[20]=s.icon,e[21]=E,e[22]=T):T=e[22];const k=s.title??s.id;let R;e[23]!==k?(R=r.jsx("div",{className:"truncate text-sm font-medium text-foreground",children:k}),e[23]=k,e[24]=R):R=e[24];let P;e[25]!==p?(P=r.jsx("div",{className:"truncate text-xs text-muted-foreground",children:p}),e[25]=p,e[26]=P):P=e[26];let D;e[27]!==R||e[28]!==P?(D=r.jsxs("div",{className:"min-w-0 flex-1",children:[R,P]}),e[27]=R,e[28]=P,e[29]=D):D=e[29];const I=i&&"rotate-180";let M;e[30]!==I?(M=ie("shrink-0 text-muted-foreground transition-transform",I),e[30]=I,e[31]=M):M=e[31];let O;e[32]!==M?(O=r.jsx(ss,{size:16,className:M}),e[32]=M,e[33]=O):O=e[33];let $;e[34]!==i||e[35]!==g||e[36]!==T||e[37]!==D||e[38]!==O?($=r.jsxs("button",{type:"button",onClick:V,className:"flex min-w-0 flex-1 items-center gap-2.5 text-left outline-none","aria-expanded":i,"aria-controls":g,children:[T,D,O]}),e[34]=i,e[35]=g,e[36]=T,e[37]=D,e[38]=O,e[39]=$):$=e[39];let B;e[40]!==s.id||e[41]!==n||e[42]!==a?(B=()=>n.removeAgent(s.id).catch(()=>ge.error(a("home.addTileDrawer.removeError"))),e[40]=s.id,e[41]=n,e[42]=a,e[43]=B):B=e[43];const z=s.title??s.id;let K;e[44]!==a||e[45]!==z?(K=a("home.addTileDrawer.removeAgentFromHome",{name:z}),e[44]=a,e[45]=z,e[46]=K):K=e[46];const G=s.title??s.id;let Y;e[47]!==a||e[48]!==G?(Y=a("home.addTileDrawer.removeAgentFromHome",{name:G}),e[47]=a,e[48]=G,e[49]=Y):Y=e[49];let U;e[50]===Symbol.for("react.memo_cache_sentinel")?(U=r.jsx(ks,{size:14}),e[50]=U):U=e[50];let W;e[51]!==B||e[52]!==K||e[53]!==Y?(W=r.jsx("button",{type:"button",onClick:B,"aria-label":K,title:Y,className:"shrink-0 inline-flex size-7 items-center justify-center rounded-md text-muted-foreground hover:bg-destructive/10 hover:text-destructive",children:U}),e[51]=B,e[52]=K,e[53]=Y,e[54]=W):W=e[54];let H;e[55]!==N||e[56]!==$||e[57]!==W?(H=r.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-2.5",children:[N,$,W]}),e[55]=N,e[56]=$,e[57]=W,e[58]=H):H=e[58];let X;e[59]!==s||e[60]!==i||e[61]!==g||e[62]!==n?(X=i&&r.jsx(B3,{id:g,agent:s,home:n}),e[59]=s,e[60]=i,e[61]=g,e[62]=n,e[63]=X):X=e[63];let q;return e[64]!==h||e[65]!==_||e[66]!==H||e[67]!==X||e[68]!==w?(q=r.jsxs("div",{ref:h,style:_,className:w,children:[H,X]}),e[64]=h,e[65]=_,e[66]=H,e[67]=X,e[68]=w,e[69]=q):q=e[69],q}function yN(t){return!t}function LN({agent:t,home:e}){const[s,n]=A.useState(!1),[i,o]=A.useState(!1),a=O3(t),l=re(),c=`available-agent-expansion-${t.id}`,d=async()=>{if(!e.atLimit){o(!0);try{await e.addAgent(t.id)}catch{ge.error(l("home.addTileDrawer.addError"))}finally{o(!1)}}};return r.jsxs("div",{className:"rounded-lg border border-border bg-card",children:[r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2.5",children:[r.jsxs("button",{type:"button",onClick:()=>n(h=>!h),className:"flex min-w-0 flex-1 items-center gap-3 text-left outline-none","aria-expanded":s,"aria-controls":c,children:[r.jsx(Xn,{icon:t.icon,name:t.title??t.id,size:"sm"}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("div",{className:"truncate text-sm font-medium text-foreground",children:t.title??t.id}),a&&r.jsx("div",{className:"truncate text-xs text-muted-foreground",children:a})]}),r.jsx(ss,{size:16,className:ie("shrink-0 text-muted-foreground transition-transform",s&&"rotate-180")})]}),r.jsx("button",{type:"button",onClick:d,disabled:i||e.atLimit,"aria-label":l("home.addTileDrawer.addToHomeTitle"),title:e.atLimit?l("home.addTileDrawer.homeFullMessage",{limit:ha}):l("home.addTileDrawer.addToHomeTitle"),className:"shrink-0 inline-flex size-7 items-center justify-center rounded-md bg-foreground text-background text-xs hover:opacity-90 disabled:opacity-40 disabled:cursor-not-allowed",children:i?r.jsx(et,{size:12,className:"animate-spin"}):r.jsx(kt,{size:14})})]}),s&&r.jsx(B3,{id:c,agent:t,home:e})]})}function B3(t){const e=F.c(18),{id:s,agent:n,home:i}=t,o=n.metadata?.ui;let a;e[0]!==o?(a=ur(o),e[0]=o,e[1]=a):a=e[1];const l=a;let c;e[2]!==n.connections?(c=(n.connections??[]).map(SN).sort(),e[2]=n.connections,e[3]=c):c=e[3];const d=c,h=n.metadata?.ui?.homePrompts;let u;e[4]!==n||e[5]!==d||e[6]!==i||e[7]!==l?(u=r.jsx(jN,{agent:n,home:i,connectionIds:d,pinnedTiles:l}),e[4]=n,e[5]=d,e[6]=i,e[7]=l,e[8]=u):u=e[8];let f;e[9]===Symbol.for("react.memo_cache_sentinel")?(f=r.jsx(wN,{}),e[9]=f):f=e[9];const m=h??null;let p;e[10]!==n||e[11]!==i||e[12]!==m?(p=r.jsx(A.Suspense,{fallback:f,children:r.jsx(GV,{agent:n,home:i,curated:m})}),e[10]=n,e[11]=i,e[12]=m,e[13]=p):p=e[13];let g;return e[14]!==s||e[15]!==u||e[16]!==p?(g=r.jsxs("div",{id:s,className:"border-t border-border px-3 py-2 flex flex-col gap-3",children:[u,p]}),e[14]=s,e[15]=u,e[16]=p,e[17]=g):g=e[17],g}function SN(t){return t.connection_id}function wN(){const t=F.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsxs("div",{className:"flex flex-col gap-2 py-1",children:[r.jsx(Rt,{className:"h-8 w-full"}),r.jsx(Rt,{className:"h-8 w-2/3"})]}),t[0]=e):e=t[0],e}function jN({agent:t,home:e,connectionIds:s,pinnedTiles:n}){const i=re(),o=$s(),{data:a,isLoading:l}=Mt({queryKey:at.projectConnectionDetails(t.id,s),enabled:s.length>0,queryFn:async()=>(await Promise.all(s.map(async f=>{try{const{item:m}=await o.call("COLLECTION_CONNECTIONS_GET",{id:f}),p=(m?.tools??[]).flatMap(g=>{const x=Zl(g._meta);return x?[{name:g.name,description:g.description,resourceUri:x,inputSchema:g.inputSchema}]:[]});return{id:f,title:m?.title??f,icon:m?.icon??null,uiTools:p}}catch{return{id:f,title:f,icon:null,uiTools:[]}}}))).filter(f=>f.uiTools.length>0)});if(s.length===0)return null;if(l)return r.jsxs("div",{className:"flex flex-col gap-1 py-0.5",children:[r.jsx(Rt,{className:"h-7 w-full"}),r.jsx(Rt,{className:"h-7 w-2/3"})]});if(!a||a.length===0)return null;const c=new Map;for(const u of a)for(const f of u.uiTools)c.set(`${u.id}:${f.name}`,{conn:u,tool:f});const d=u=>{if(u.toolName&&u.connectionId)return c.get(`${u.connectionId}:${u.toolName}`);for(const[,f]of c)if(f.conn.id===u.connectionId&&f.tool.resourceUri===u.resourceUri)return f},h=n.some(u=>!!d(u));return r.jsxs("div",{className:"flex flex-col gap-2",children:[h&&r.jsxs("div",{className:"flex flex-col gap-0.5",children:[r.jsx("span",{className:"text-[10px] font-medium uppercase tracking-wide text-muted-foreground px-2",children:i("home.addTileDrawer.pinnedTiles")}),n.map(u=>{const f=d(u);return f?r.jsx(CN,{agent:t,home:e,connection:f.conn,tool:f.tool,tile:u},u.tileId??`${u.connectionId}:${u.resourceUri}:${u.toolName}`):null})]}),r.jsxs("div",{className:"flex flex-col gap-0.5",children:[r.jsx("span",{className:"text-[10px] font-medium uppercase tracking-wide text-muted-foreground px-2",children:i("home.addTileDrawer.addTileLabel")}),a.map(u=>u.uiTools.map(f=>r.jsx(VN,{agent:t,home:e,connection:u,tool:f},`add:${u.id}:${f.name}`)))]})]})}function Wd(t,e){return{...t.metadata??{},ui:{...t.metadata?.ui??{},homeTile:null,homeTiles:e}}}async function qd(t,e,s){try{await e()}catch(n){console.error(`[home-tiles] failed to ${t} tile`,n),ge.error(s("home.addTileDrawer.updateError"))}}function $3(t,e,s,n){if(!e||Object.keys(e).length===0)return{};const i=sN(t,e,s);if(!i){ge.error(n("home.addTileDrawer.invalidFieldError"));return}return Object.keys(i).length>0?{toolInput:i}:{}}function F3(t){const e=F.c(23),{properties:s,required:n,values:i,onChange:o,onCancel:a,onSubmit:l,submitting:c,submitLabel:d}=t,h=re();let u;e[0]!==o||e[1]!==s||e[2]!==n||e[3]!==i?(u=r.jsx(rN,{properties:s,required:n,values:i,onChange:o}),e[0]=o,e[1]=s,e[2]=n,e[3]=i,e[4]=u):u=e[4];let f;e[5]!==h?(f=h("home.addTileDrawer.cancel"),e[5]=h,e[6]=f):f=e[6];let m;e[7]!==a||e[8]!==f?(m=r.jsx(le,{variant:"ghost",size:"sm",className:"h-7 text-xs",onClick:a,children:f}),e[7]=a,e[8]=f,e[9]=m):m=e[9];let p;e[10]!==d||e[11]!==c?(p=c?r.jsx(et,{size:12,className:"animate-spin"}):d,e[10]=d,e[11]=c,e[12]=p):p=e[12];let g;e[13]!==l||e[14]!==c||e[15]!==p?(g=r.jsx(le,{size:"sm",className:"h-7 text-xs",disabled:c,onClick:l,children:p}),e[13]=l,e[14]=c,e[15]=p,e[16]=g):g=e[16];let x;e[17]!==m||e[18]!==g?(x=r.jsxs("div",{className:"flex items-center gap-2 justify-end",children:[m,g]}),e[17]=m,e[18]=g,e[19]=x):x=e[19];let v;return e[20]!==u||e[21]!==x?(v=r.jsxs("div",{className:"px-3 pb-2 pt-1 flex flex-col gap-2",children:[u,x]}),e[20]=u,e[21]=x,e[22]=v):v=e[22],v}function CN(t){const e=F.c(57),{agent:s,home:n,connection:i,tool:o,tile:a}=t,[l,c]=A.useState(!1),[d,h]=A.useState(!1),u=re();let f;e[0]!==o.inputSchema?(f=o.inputSchema?.properties&&Object.keys(o.inputSchema.properties).length>0,e[0]=o.inputSchema,e[1]=f):f=e[1];const m=f;let p;e[2]!==a.toolInput||e[3]!==o.inputSchema?.properties?(p=()=>nN(a.toolInput,o.inputSchema?.properties),e[2]=a.toolInput,e[3]=o.inputSchema?.properties,e[4]=p):p=e[4];const[g,x]=A.useState(p);let v;e[5]!==s||e[6]!==n||e[7]!==u||e[8]!==a?(v=async()=>{c(!0),await qd("remove",async()=>{const I=ur(s.metadata?.ui),M=a.tileId?I.filter(O=>O.tileId!==a.tileId):I.filter(O=>O!==a);await n.saveAgentMetadata(s,Wd(s,M)),h(!1)},u),c(!1)},e[5]=s,e[6]=n,e[7]=u,e[8]=a,e[9]=v):v=e[9];const b=v;let y;e[10]!==s||e[11]!==g||e[12]!==n||e[13]!==u||e[14]!==a||e[15]!==o.inputSchema?.properties||e[16]!==o.inputSchema?.required?(y=async()=>{const I=$3(g,o.inputSchema?.properties,o.inputSchema?.required,u);if(!I)return;const{toolInput:M}=I;c(!0),await qd("save",async()=>{const $=ur(s.metadata?.ui).map(B=>(a.tileId?B.tileId===a.tileId:B===a)?{...B,toolInput:M}:B);await n.saveAgentMetadata(s,Wd(s,$)),h(!1)},u),c(!1)},e[10]=s,e[11]=g,e[12]=n,e[13]=u,e[14]=a,e[15]=o.inputSchema?.properties,e[16]=o.inputSchema?.required,e[17]=y):y=e[17];const _=y;let L;e[18]!==a.toolInput?(L=iN(a.toolInput),e[18]=a.toolInput,e[19]=L):L=e[19];const w=L;let j;e[20]!==i.icon||e[21]!==i.title?(j=r.jsx(an,{icon:i.icon,name:i.title,size:"xs"}),e[20]=i.icon,e[21]=i.title,e[22]=j):j=e[22];let S;e[23]!==o.name?(S=Ci(o.name),e[23]=o.name,e[24]=S):S=e[24];let C;e[25]!==S?(C=r.jsx("div",{className:"truncate text-sm text-foreground",children:S}),e[25]=S,e[26]=C):C=e[26];let N;e[27]!==w?(N=w&&r.jsx("div",{className:"truncate text-[10px] text-muted-foreground font-mono",children:w}),e[27]=w,e[28]=N):N=e[28];let V;e[29]!==C||e[30]!==N?(V=r.jsxs("div",{className:"min-w-0 flex-1",children:[C,N]}),e[29]=C,e[30]=N,e[31]=V):V=e[31];let E;e[32]!==m||e[33]!==u?(E=m&&r.jsx("button",{type:"button",onClick:()=>h(kN),"aria-label":u("home.addTileDrawer.configureTile"),title:u("home.addTileDrawer.configureTile"),className:"inline-flex size-7 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-accent/60",children:r.jsx(Fm,{size:14})}),e[32]=m,e[33]=u,e[34]=E):E=e[34];let T;e[35]!==u?(T=u("home.addTileDrawer.removeFromHome"),e[35]=u,e[36]=T):T=e[36];let k;e[37]!==b||e[38]!==l||e[39]!==T?(k=r.jsx(su,{isPinned:!0,submitting:l,onClick:b,label:T}),e[37]=b,e[38]=l,e[39]=T,e[40]=k):k=e[40];let R;e[41]!==V||e[42]!==E||e[43]!==k||e[44]!==j?(R=r.jsxs("div",{className:"flex items-center gap-2.5 px-2 py-1",children:[j,V,E,k]}),e[41]=V,e[42]=E,e[43]=k,e[44]=j,e[45]=R):R=e[45];let P;e[46]!==g||e[47]!==_||e[48]!==m||e[49]!==d||e[50]!==l||e[51]!==u||e[52]!==o.inputSchema?(P=d&&m&&o.inputSchema?.properties&&r.jsx(F3,{properties:o.inputSchema.properties,required:o.inputSchema.required,values:g,onChange:(I,M)=>x(O=>({...O,[I]:M})),onCancel:()=>h(!1),onSubmit:_,submitting:l,submitLabel:u("home.addTileDrawer.save")}),e[46]=g,e[47]=_,e[48]=m,e[49]=d,e[50]=l,e[51]=u,e[52]=o.inputSchema,e[53]=P):P=e[53];let D;return e[54]!==R||e[55]!==P?(D=r.jsxs("div",{className:"flex flex-col rounded-md bg-accent/20",children:[R,P]}),e[54]=R,e[55]=P,e[56]=D):D=e[56],D}function kN(t){return!t}function VN(t){const e=F.c(44),{agent:s,home:n,connection:i,tool:o}=t,[a,l]=A.useState(!1),[c,d]=A.useState(!1),h=re();let u;e[0]!==o.inputSchema?(u=o.inputSchema?.properties&&Object.keys(o.inputSchema.properties).length>0,e[0]=o.inputSchema,e[1]=u):u=e[1];const f=u;let m;e[2]===Symbol.for("react.memo_cache_sentinel")?(m={},e[2]=m):m=e[2];const[p,g]=A.useState(m);let x,v;e[3]!==s||e[4]!==i.id||e[5]!==p||e[6]!==f||e[7]!==n||e[8]!==c||e[9]!==h||e[10]!==o.inputSchema?.properties||e[11]!==o.inputSchema?.required||e[12]!==o.name||e[13]!==o.resourceUri?(x=async()=>{if(f&&!c){d(!0);return}if(!n.isOnHome(s.id)&&n.atLimit){ge.error(h("home.addTileDrawer.homeFullMessage",{limit:ha}));return}await v()},v=async()=>{const N=$3(p,o.inputSchema?.properties,o.inputSchema?.required,h);if(!N)return;const{toolInput:V}=N;l(!0),await qd("add",async()=>{const T=[...ur(s.metadata?.ui),{tileId:crypto.randomUUID(),connectionId:i.id,resourceUri:o.resourceUri,toolName:o.name,...V?{toolInput:V}:{}}];await n.saveAgentMetadata(s,Wd(s,T)),d(!1),g({})},h),l(!1)},e[3]=s,e[4]=i.id,e[5]=p,e[6]=f,e[7]=n,e[8]=c,e[9]=h,e[10]=o.inputSchema?.properties,e[11]=o.inputSchema?.required,e[12]=o.name,e[13]=o.resourceUri,e[14]=x,e[15]=v):(x=e[14],v=e[15]);let b;e[16]!==i.icon||e[17]!==i.title?(b=r.jsx(an,{icon:i.icon,name:i.title,size:"xs"}),e[16]=i.icon,e[17]=i.title,e[18]=b):b=e[18];let y;e[19]!==o.name?(y=Ci(o.name),e[19]=o.name,e[20]=y):y=e[20];let _;e[21]!==y?(_=r.jsx("div",{className:"min-w-0 flex-1 truncate text-sm text-foreground",children:y}),e[21]=y,e[22]=_):_=e[22];let L;e[23]!==h?(L=h("home.addTileDrawer.addToHomeTitle"),e[23]=h,e[24]=L):L=e[24];let w;e[25]!==x||e[26]!==a||e[27]!==L?(w=r.jsx(su,{isPinned:!1,submitting:a,onClick:x,label:L}),e[25]=x,e[26]=a,e[27]=L,e[28]=w):w=e[28];let j;e[29]!==b||e[30]!==_||e[31]!==w?(j=r.jsxs("div",{className:"flex items-center gap-2.5 px-2 py-1",children:[b,_,w]}),e[29]=b,e[30]=_,e[31]=w,e[32]=j):j=e[32];let S;e[33]!==p||e[34]!==f||e[35]!==v||e[36]!==c||e[37]!==a||e[38]!==h||e[39]!==o.inputSchema?(S=c&&f&&o.inputSchema?.properties&&r.jsx(F3,{properties:o.inputSchema.properties,required:o.inputSchema.required,values:p,onChange:(N,V)=>g(E=>({...E,[N]:V})),onCancel:()=>{d(!1),g({})},onSubmit:v,submitting:a,submitLabel:h("home.addTileDrawer.pin")}),e[33]=p,e[34]=f,e[35]=v,e[36]=c,e[37]=a,e[38]=h,e[39]=o.inputSchema,e[40]=S):S=e[40];let C;return e[41]!==j||e[42]!==S?(C=r.jsxs("div",{className:"flex flex-col rounded-md hover:bg-accent/40",children:[j,S]}),e[41]=j,e[42]=S,e[43]=C):C=e[43],C}function NN(){const t=F.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx("div",{className:"flex flex-col gap-2 p-2",children:Array.from({length:4},TN)}),t[0]=e):e=t[0],e}function TN(t,e){return r.jsxs("div",{className:"flex items-center gap-3 rounded-lg border border-border p-2.5",children:[r.jsx(Rt,{className:"size-8 rounded-md"}),r.jsxs("div",{className:"flex-1 space-y-1.5",children:[r.jsx(Rt,{className:"h-3 w-1/2"}),r.jsx(Rt,{className:"h-2.5 w-1/3"})]})]},e)}const AN=[{id:"all",labelKey:"home.homeTasks.tabAll"},{id:"in_progress",labelKey:"home.homeTasks.tabInProgress"},{id:"in_review",labelKey:"home.homeTasks.tabInReview"},{id:"done",labelKey:"home.homeTasks.tabDone"}],EN=4;function PN(t){const e=F.c(64),{task:s,assignee:n,onOpen:i}=t,o=Cv[s.status],a=o.icon,l=kv[s.priority];let c,d,h,u,f,m,p,g,x,v,b,y,_,L;if(e[0]!==a||e[1]!==n?.user?.email||e[2]!==n?.user?.image||e[3]!==n?.user?.name||e[4]!==i||e[5]!==o.iconClassName||e[6]!==s.dueDate||e[7]!==s.title||e[8]!==s.updatedAt){const k=n?.user?.name??n?.user?.email?.split("@")[0]??null;let R;e[23]!==s.updatedAt?(R=b2(new Date(s.updatedAt)),e[23]=s.updatedAt,e[24]=R):R=e[24],L=R;let P;e[25]!==s.dueDate?(P=s.dueDate?{label:new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric"}).format(new Date(s.dueDate)),overdue:new Date(s.dueDate).getTime()<Date.now()}:null,e[25]=s.dueDate,e[26]=P):P=e[26],d=P,b="button",y=i,_="flex w-full items-center gap-3 rounded-2xl bg-card px-4 py-3.5 text-left card-shadow transition-colors hover:bg-accent/60";let D;e[27]!==o.iconClassName?(D=ie("size-4 shrink-0",o.iconClassName),e[27]=o.iconClassName,e[28]=D):D=e[28],e[29]!==a||e[30]!==D?(u=r.jsx(a,{className:D}),e[29]=a,e[30]=D,e[31]=u):u=e[31],e[32]!==s.title?(f=r.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-medium text-foreground",children:s.title}),e[32]=s.title,e[33]=f):f=e[33],v="flex shrink-0 items-center gap-3 text-xs text-muted-foreground",x="hidden @2xl:inline-flex",c=ir,h="circle",m="2xs",p=n?.user?.image??void 0,g=(k??"?").slice(0,2).toUpperCase(),e[0]=a,e[1]=n?.user?.email,e[2]=n?.user?.image,e[3]=n?.user?.name,e[4]=i,e[5]=o.iconClassName,e[6]=s.dueDate,e[7]=s.title,e[8]=s.updatedAt,e[9]=c,e[10]=d,e[11]=h,e[12]=u,e[13]=f,e[14]=m,e[15]=p,e[16]=g,e[17]=x,e[18]=v,e[19]=b,e[20]=y,e[21]=_,e[22]=L}else c=e[9],d=e[10],h=e[11],u=e[12],f=e[13],m=e[14],p=e[15],g=e[16],x=e[17],v=e[18],b=e[19],y=e[20],_=e[21],L=e[22];let w;e[34]!==c||e[35]!==h||e[36]!==m||e[37]!==p||e[38]!==g?(w=r.jsx(c,{shape:h,size:m,url:p,fallback:g}),e[34]=c,e[35]=h,e[36]=m,e[37]=p,e[38]=g,e[39]=w):w=e[39];let j;e[40]!==w||e[41]!==x?(j=r.jsx("span",{className:x,children:w}),e[40]=w,e[41]=x,e[42]=j):j=e[42];let S;e[43]!==l.flagClassName?(S=ie("size-3.5 shrink-0",l.flagClassName),e[43]=l.flagClassName,e[44]=S):S=e[44];let C;e[45]!==S?(C=r.jsx(p9,{className:S}),e[45]=S,e[46]=C):C=e[46];let N;e[47]!==d?(N=d&&r.jsxs("span",{className:ie("hidden items-center gap-1 @xl:inline-flex",d.overdue?"text-red-600":""),children:[r.jsx(Z0,{className:"size-3"}),d.label]}),e[47]=d,e[48]=N):N=e[48];let V;e[49]!==L?(V=r.jsx("span",{className:"hidden @xl:inline",children:L}),e[49]=L,e[50]=V):V=e[50];let E;e[51]!==j||e[52]!==C||e[53]!==N||e[54]!==V||e[55]!==v?(E=r.jsxs("div",{className:v,children:[j,C,N,V]}),e[51]=j,e[52]=C,e[53]=N,e[54]=V,e[55]=v,e[56]=E):E=e[56];let T;return e[57]!==u||e[58]!==f||e[59]!==E||e[60]!==b||e[61]!==y||e[62]!==_?(T=r.jsxs("button",{type:b,onClick:y,className:_,children:[u,f,E]}),e[57]=u,e[58]=f,e[59]=E,e[60]=b,e[61]=y,e[62]=_,e[63]=T):T=e[63],T}function RN(t,e){const s=t.filter(h=>h.status!=="done");if(s.length===0)return"";const n=s.filter(h=>h.status==="in_progress").length,i=s.filter(h=>h.status==="in_review").length,o=s.filter(h=>h.priority==="urgent"||h.priority==="high").length,a=s.filter(h=>h.dueDate&&new Date(h.dueDate).getTime()<Date.now()).length,l=[];n>0&&l.push(e("home.homeTasks.breakdownInProgress",{count:n})),i>0&&l.push(e("home.homeTasks.breakdownNeedsReview",{count:i}));let c=e("home.homeTasks.summaryLead",{count:s.length});l.length>0&&(c+=` — ${l.join(", ")}`),c+=".";const d=[];return o>0&&d.push(e("home.homeTasks.noteHighPriority",{count:o})),a>0&&d.push(e("home.homeTasks.noteOverdue",{count:a})),d.length>0?`${c} ${d.join(" ")}`:c}function DN(t){const e=F.c(49),{afterSummary:s}=t,n=re(),i=St(),{items:o,error:a}=Sv(),l=wv(),{data:c}=Jm();let d;if(e[0]!==c?.data?.members){const N=c?.data?.members??[];d=new Map(N.map(ON)),e[0]=c?.data?.members,e[1]=d}else d=e[1];const h=d,[u,f]=A.useState("all"),[m,p]=A.useState(!1);let g,x,v,b,y,_;if(e[2]!==s||e[3]!==a||e[4]!==o||e[5]!==h||e[6]!==i||e[7]!==n||e[8]!==u){const N=a?[]:o,V=[...N].sort(MN);let E;e[15]!==n?(E=(B,z)=>n(B,z),e[15]=n,e[16]=E):E=e[16];const T=RN(N,E),k=u==="all"?V:V.filter(B=>B.status===u);let R;e[17]!==i?(R=()=>i({to:".",search:IN}),e[17]=i,e[18]=R):R=e[18];const P=R;b="flex flex-col gap-10";let D;e[19]===Symbol.for("react.memo_cache_sentinel")?(D=r.jsx(Vv,{size:24,className:"mt-0.5"}),e[19]=D):D=e[19],y=r.jsxs("div",{className:"flex items-start gap-4 animate-in fade-in slide-in-from-top-1 duration-300",children:[D,r.jsx("p",{className:"max-w-3xl text-lg font-medium leading-snug text-foreground",children:T})]}),_=s,g="flex flex-col gap-4";let I;e[20]!==n?(I=n("home.homeTasks.tasksHeading"),e[20]=n,e[21]=I):I=e[21];let M;e[22]!==I?(M=r.jsx("h2",{className:"text-base font-medium text-foreground",children:I}),e[22]=I,e[23]=M):M=e[23];let O;e[24]!==n||e[25]!==u?(O=AN.map(B=>r.jsx("button",{type:"button",onClick:()=>f(B.id),className:ie("rounded-md px-2.5 py-1 text-xs font-medium transition-colors",u===B.id?"bg-accent text-foreground":"text-muted-foreground hover:text-foreground"),children:n(B.labelKey)},B.id)),e[24]=n,e[25]=u,e[26]=O):O=e[26];let $;e[27]!==O?($=r.jsx("div",{className:"flex items-center gap-1",children:O}),e[27]=O,e[28]=$):$=e[28],e[29]!==M||e[30]!==$?(x=r.jsxs("div",{className:"flex items-center gap-3",children:[M,$]}),e[29]=M,e[30]=$,e[31]=x):x=e[31],v=k.length===0?r.jsxs("div",{className:"flex flex-col items-center gap-3 rounded-2xl bg-card px-4 py-10 text-center card-shadow",children:[r.jsx("p",{className:"text-sm text-muted-foreground",children:u==="all"?n("home.homeTasks.emptyStateNoTasks"):n("home.homeTasks.emptyStateNothing",{status:n(u==="in_progress"?"home.homeTasks.statusInProgress":u==="in_review"?"home.homeTasks.statusInReview":"home.homeTasks.statusDone")})}),u==="all"&&r.jsxs(le,{variant:"outline",size:"sm",onClick:()=>p(!0),className:"gap-2",children:[r.jsx(kt,{className:"size-4"}),n("home.homeTasks.createNewTask")]})]}):r.jsxs("div",{className:"flex flex-col gap-2",children:[k.slice(0,EN).map(B=>r.jsx(PN,{task:B,assignee:B.assigneeId?h.get(B.assigneeId):void 0,onOpen:P},B.id)),r.jsxs("button",{type:"button",onClick:P,className:"flex w-full items-center justify-center gap-1.5 rounded-2xl bg-card px-4 py-3 text-sm font-medium text-muted-foreground card-shadow transition-colors hover:bg-accent/60 hover:text-foreground",children:[n("home.homeTasks.seeAllTasks"),r.jsx(_2,{className:"size-3.5"})]})]}),e[2]=s,e[3]=a,e[4]=o,e[5]=h,e[6]=i,e[7]=n,e[8]=u,e[9]=g,e[10]=x,e[11]=v,e[12]=b,e[13]=y,e[14]=_}else g=e[9],x=e[10],v=e[11],b=e[12],y=e[13],_=e[14];let L;e[32]!==g||e[33]!==x||e[34]!==v?(L=r.jsxs("section",{className:g,children:[x,v]}),e[32]=g,e[33]=x,e[34]=v,e[35]=L):L=e[35];let w;e[36]===Symbol.for("react.memo_cache_sentinel")?(w=()=>p(!1),e[36]=w):w=e[36];let j;e[37]!==l.create?(j=N=>{l.create.mutate(N),p(!1)},e[37]=l.create,e[38]=j):j=e[38];let S;e[39]!==l.create.isPending||e[40]!==m||e[41]!==j?(S=r.jsx(jv,{open:m,onClose:w,isSaving:l.create.isPending,onSubmit:j}),e[39]=l.create.isPending,e[40]=m,e[41]=j,e[42]=S):S=e[42];let C;return e[43]!==S||e[44]!==b||e[45]!==y||e[46]!==_||e[47]!==L?(C=r.jsxs("div",{className:b,children:[y,_,L,S]}),e[43]=S,e[44]=b,e[45]=y,e[46]=_,e[47]=L,e[48]=C):C=e[48],C}function IN(t){return{...t,main:"board"}}function MN(t,e){return(e.updatedAt??"").localeCompare(t.updatedAt??"")}function ON(t){return[t.userId,t]}function BN(t){const e=F.c(29),{isEditMode:s,hasChanges:n,onEnter:i,onSave:o,onCancel:a,onAddTile:l}=t,c=re();if(!s){let _;e[0]===Symbol.for("react.memo_cache_sentinel")?(_=r.jsx(Im,{size:14}),e[0]=_):_=e[0];let L;e[1]!==c?(L=c("home.customizeToolbar.label"),e[1]=c,e[2]=L):L=e[2];let w;return e[3]!==i||e[4]!==L?(w=r.jsxs(le,{type:"button",size:"sm",variant:"ghost",onClick:i,className:"h-8 gap-1.5 text-muted-foreground",children:[_,L]}),e[3]=i,e[4]=L,e[5]=w):w=e[5],w}let d;e[6]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(kt,{size:14}),e[6]=d):d=e[6];let h;e[7]!==c?(h=c("home.customizeToolbar.addTile"),e[7]=c,e[8]=h):h=e[8];let u;e[9]!==l||e[10]!==h?(u=r.jsxs(le,{type:"button",size:"sm",variant:"ghost",onClick:l,className:"h-8 gap-1.5",children:[d,h]}),e[9]=l,e[10]=h,e[11]=u):u=e[11];let f;e[12]===Symbol.for("react.memo_cache_sentinel")?(f=r.jsx(ks,{size:14}),e[12]=f):f=e[12];let m;e[13]!==c?(m=c("home.customizeToolbar.cancel"),e[13]=c,e[14]=m):m=e[14];let p;e[15]!==a||e[16]!==m?(p=r.jsxs(le,{type:"button",size:"sm",variant:"ghost",onClick:a,className:"h-8 gap-1.5",children:[f,m]}),e[15]=a,e[16]=m,e[17]=p):p=e[17];const g=!n;let x;e[18]===Symbol.for("react.memo_cache_sentinel")?(x=r.jsx(zt,{size:14}),e[18]=x):x=e[18];let v;e[19]!==c?(v=c("home.customizeToolbar.save"),e[19]=c,e[20]=v):v=e[20];let b;e[21]!==o||e[22]!==g||e[23]!==v?(b=r.jsxs(le,{type:"button",size:"sm",onClick:o,disabled:g,className:"h-8 gap-1.5",children:[x,v]}),e[21]=o,e[22]=g,e[23]=v,e[24]=b):b=e[24];let y;return e[25]!==b||e[26]!==u||e[27]!==p?(y=r.jsxs("div",{className:"flex items-center gap-1",children:[u,p,b]}),e[25]=b,e[26]=u,e[27]=p,e[28]=y):y=e[28],y}function $N(){const t=F.c(18),{isEditMode:e,enter:s,save:n,cancel:i,hasChanges:o}=F9(),[a,l]=A.useState(!1),c=Ql();let d;t[0]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(DN,{afterSummary:r.jsx(iC,{})}),t[0]=d):d=t[0];let h;t[1]!==i||t[2]!==s||t[3]!==o||t[4]!==e||t[5]!==c||t[6]!==n?(h=!c&&r.jsx("div",{className:"flex justify-end",children:r.jsx(BN,{isEditMode:e,hasChanges:o,onEnter:s,onSave:n,onCancel:i,onAddTile:()=>l(!0)})}),t[1]=i,t[2]=s,t[3]=o,t[4]=e,t[5]=c,t[6]=n,t[7]=h):h=t[7];let u;t[8]!==e?(u=r.jsx(RV,{isEditMode:e}),t[8]=e,t[9]=u):u=t[9];let f;t[10]!==h||t[11]!==u?(f=r.jsxs("div",{className:"@container mx-auto flex max-w-5xl flex-col gap-10 px-6 py-8",children:[d,r.jsxs("div",{className:"flex flex-col gap-4",children:[h,u]})]}),t[10]=h,t[11]=u,t[12]=f):f=t[12];let m;t[13]!==a?(m=r.jsx(aN,{open:a,onOpenChange:l}),t[13]=a,t[14]=m):m=t[14];let p;return t[15]!==f||t[16]!==m?(p=r.jsxs("div",{className:"h-full overflow-y-auto",children:[f,m]}),t[15]=f,t[16]=m,t[17]=p):p=t[17],p}function FN(){const t=F.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx(eC,{children:r.jsx($N,{})}),t[0]=e):e=t[0],e}const zN=10,rf=100,KN=30;function UN(t){const e=t;if(e.isError)return null;const s=e.content?.find(i=>i.type==="resource"),n=s?.resource?.text??s?.text;if(!n)return null;try{const i=JSON.parse(n);return typeof i=="string"?i:i&&typeof i=="object"&&"content"in i&&typeof i.content=="string"?i.content:JSON.stringify(i,null,2)}catch{return n}}async function wa(t,e,s){try{const n=await t.callTool({name:"get_file_contents",arguments:{owner:e.owner,repo:e.repo,path:e.path,...s}});return UN(n)}catch{return null}}function HN(t){const e=zi(t);return Array.isArray(e)?e.map(s=>{const n=Number(s.additions??0),i=Number(s.changes??n),o=Number(s.deletions??Math.max(0,i-n));return{filename:String(s.filename??""),status:s.status??"modified",additions:n,deletions:o,blobUrl:typeof s.blob_url=="string"?s.blob_url:null,previousFilename:typeof s.previous_filename=="string"?s.previous_filename:null}}):[]}async function WN(t,e,s){if(t.length===0)return;let n=0;async function i(){for(;n<t.length;){const o=n++;await s(t[o])}}await Promise.all(Array.from({length:Math.min(e,t.length)},()=>i()))}async function qN(t,e){const s=[];for(let n=1;n<=KN;n++){const i=await t.callTool({name:"pull_request_read",arguments:{method:"get_files",owner:e.owner,repo:e.repo,pullNumber:e.pullNumber,page:n,perPage:rf}}),o=HN(i);if(s.push(...o),o.length<rf)break}return s}async function of(t,e){const n=(await qN(t,e)).filter(a=>a.filename.length>0),i={},o=e.mergeBaseSha?{sha:e.mergeBaseSha}:{ref:e.base};return await WN(n,zN,async a=>{const l=a.filename;if(a.status==="added"){i[l]={from:null,to:await wa(t,{owner:e.owner,repo:e.repo,path:l},{sha:e.headSha})};return}if(a.status==="removed"){i[l]={from:await wa(t,{owner:e.owner,repo:e.repo,path:l},o),to:null};return}const c=a.previousFilename??l,[d,h]=await Promise.all([wa(t,{owner:e.owner,repo:e.repo,path:c},o),wa(t,{owner:e.owner,repo:e.repo,path:l},{sha:e.headSha})]);i[l]={from:d,to:h}}),{diffs:i}}function z3(t){return t?Object.keys(t.diffs).length:0}function Ui(t,e,s,n){return`/api/${t}/sandbox/${encodeURIComponent(e)}/${encodeURIComponent(s)}/git/${n}`}class K3 extends Error{constructor(e,s){super(e),this.status=s,this.name="SandboxGitError"}status}function iu(t){return t instanceof K3&&(t.status===503||t.status===410||t.status===404)}async function Hi(t){const e=await t.json();if(!t.ok)throw new K3(typeof e.error=="string"?e.error:`Request failed (${t.status})`,t.status);return e}function Wi(t,e){return fetch(t,{cache:"no-store",...e})}async function Ha(t,e,s){const n=await Wi(Ui(t,e,s,"status"));return Hi(n)}async function lr(t,e,s,n){const i=n?.base||n?.headSha?{...n.base?{base:n.base}:{},...n.headSha?{headSha:n.headSha}:{}}:void 0,o=await Wi(Ui(t,e,s,"diff"),{method:"POST",headers:i?{"content-type":"application/json"}:void 0,body:i?JSON.stringify(i):void 0});return Hi(o)}function U3(t){const e={};for(const[s,n]of Object.entries(t.diffs))H3(s)||W3(s)||(e[s]=n);return{...t,diffs:e}}async function af(t,e,s,n){const i=n?{status:n.status,diff:U3(n.diff)}:{},o=await Wi(Ui(t,e,s,"suggest-commit"),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(i)});return Hi(o)}async function lf(t,e,s,n){const i=await Wi(Ui(t,e,s,"publish"),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({message:n})});await Hi(i)}async function GN(t,e,s,n){const i=await Wi(Ui(t,e,s,"rebase"),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({base:n})});await Hi(i)}function H3(t){return t==="blocks.gen.json"||t.endsWith("/blocks.gen.json")}function W3(t){return t==="static/tailwind.css"||t.endsWith("/static/tailwind.css")}function YN(t){return t===".deco"||t.endsWith("/.deco")||t.startsWith(".deco/")||t.includes("/.deco/")}function q3(t){if(!t)return!1;const e=Object.keys(t.diffs);return e.length===0?!1:e.every(s=>YN(s)||H3(s)||W3(s))}const JN="smart";function XN(t){return t==="code-review"||t==="open"||t==="smart"?t:JN}function QN(t){let e=5381;const s=n=>{for(let i=0;i<n.length;i++)e=(e<<5)+e+n.charCodeAt(i)|0};for(const n of Object.keys(t.diffs).sort()){const i=t.diffs[n];s(n),s("\0from:"),s(i?.from??""),s("\0to:"),s(i?.to??""),s("\0\0")}return(e>>>0).toString(36)}async function ZN(t,e,s,n){const i=await Wi(Ui(t,e,s,"judge-review"),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({status:n.status,diff:U3(n.diff),...n.language?{language:n.language}:{}})});return Hi(i)}async function cf(t,e,s,n){const i=await Wi(Ui(t,e,s,"discard"),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({filepaths:n})});await Hi(i)}const eT="current";function tT(t){return t?.[eT]??null}function LH(t,e,s){return["sandbox-git-status",t,e,s]}function G3(t){return t?t.modified.length+t.created.length+t.deleted.length+t.not_added.length+t.renamed.length:0}function vc(t){return t?G3(t)>0||t.staged.length>0||t.conflicted.length>0:!1}function Y3(t){return t?vc(t)||t.ahead>0||(t.unpushed??0)>0?!0:t.unpushed===void 0&&(t.aheadOfBase??0)>0&&t.tracking==null:!1}function sT(t,e){return t?Y3(t)||e!=null&&Object.keys(e.diffs).length>0:!1}function nT(t,e){return vc(t)?!1:e.openPrFromCommits||!e.commitToOpenPr&&(t?.aheadOfBase??0)>0}function J3(t,e){return{diffs:{...t?.diffs??{},...e?.diffs??{}},...t?.mergeBaseSha?{mergeBaseSha:t.mergeBaseSha}:{}}}function iT(t,e="code-review"){return e==="open"?{allowed:!0,reason:null}:q3(t)?{allowed:!0,reason:null}:{allowed:!1,reason:null}}function rT(t,e){return e!=="smart"||!t||Object.keys(t.diffs).length===0?!1:!q3(t)}function oT(t,e){if(e)return{allowed:!1,reason:null,pending:!0};if(!t)return{allowed:!0,reason:null};if(!t.requiresReview)return{allowed:!0,reason:null};const s=t.reason?.trim();return{allowed:!1,reason:s||null}}function aT(t,e,s,n,i,o,a){return["pr-diff",t,e,s,n,i,o,a]}function lT(t){const e=F.c(26),{orgSlug:s,orgId:n,virtualMcpId:i,branch:o,base:a,headSha:l,pullNumber:c,connectionId:d,owner:h,repo:u,enabled:f}=t,m=f===void 0?!0:f;let p;e[0]!==d||e[1]!==n||e[2]!==s?(p={connectionId:d,orgId:n,orgSlug:s},e[0]=d,e[1]=n,e[2]=s,e[3]=p):p=e[3];const g=ht(p);let x;e[4]!==a||e[5]!==o||e[6]!==d||e[7]!==l||e[8]!==s||e[9]!==c||e[10]!==i?(x=aT(s,i,o,a,l,c,d),e[4]=a,e[5]=o,e[6]=d,e[7]=l,e[8]=s,e[9]=c,e[10]=i,e[11]=x):x=e[11];let v;e[12]!==a||e[13]!==o||e[14]!==g||e[15]!==l||e[16]!==s||e[17]!==h||e[18]!==c||e[19]!==u||e[20]!==i?(v=async()=>{try{const _=await lr(s,i,o,{base:a,headSha:l});return z3(_)>0?_:of(g,{owner:h,repo:u,pullNumber:c,base:a,headSha:l,mergeBaseSha:_.mergeBaseSha})}catch{return of(g,{owner:h,repo:u,pullNumber:c,base:a,headSha:l})}},e[12]=a,e[13]=o,e[14]=g,e[15]=l,e[16]=s,e[17]=h,e[18]=c,e[19]=u,e[20]=i,e[21]=v):v=e[21];const b=m&&!!o&&!!l&&!!d;let y;return e[22]!==x||e[23]!==v||e[24]!==b?(y={queryKey:x,queryFn:v,enabled:b,refetchInterval:3e4,staleTime:1e4},e[22]=x,e[23]=v,e[24]=b,e[25]=y):y=e[25],Mt(y)}vb.config({paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.52.0/min/vs"}});function cT(){return document.documentElement.classList.contains("dark")?"vs-dark":"vs"}function X3(t){const e=F.c(9),{diff:s,emptyMessage:n,rowClassName:i,onDiscardFile:o}=t,a=n===void 0?"No file changes in the working tree":n,l=i===void 0?"px-6":i,[c,d]=A.useState(null),[h,u]=A.useState(null);let f;e[0]===Symbol.for("react.memo_cache_sentinel")?(f=cT(),e[0]=f):f=e[0];const m=f;if(!s||Object.keys(s.diffs).length===0){let g;return e[1]!==a?(g=r.jsx("div",{className:"flex items-center justify-center py-10 text-sm text-muted-foreground",children:a}),e[1]=a,e[2]=g):g=e[2],g}let p;return e[3]!==s.diffs||e[4]!==h||e[5]!==c||e[6]!==o||e[7]!==l?(p=r.jsx("div",{className:"divide-y",children:Object.entries(s.diffs).map(g=>{const[x,v]=g,{from:b,to:y}=v,_=c===x,L=b===null,w=y===null,j=x.startsWith("/")?x.slice(1):x,S=j.lastIndexOf("/"),C=S>=0?j.slice(S+1):j,N=S>=0?j.slice(0,S):null,V=D6(x),E=L?"bg-success":w?"bg-destructive":"bg-warning";return r.jsxs("div",{children:[r.jsxs("div",{className:ie("flex items-center gap-3 py-3 hover:bg-muted/30",l),children:[r.jsx("button",{type:"button",className:"flex h-4 w-4 shrink-0 items-center justify-center text-muted-foreground transition-transform hover:text-foreground",onClick:()=>d(_?null:x),children:r.jsx(bn,{className:ie("h-3.5 w-3.5 transition-transform",_&&"rotate-90")})}),r.jsx("div",{className:ie("h-2.5 w-2.5 shrink-0 rounded-full",E)}),r.jsx(l2,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),r.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-medium",children:C}),N&&r.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:N}),o?r.jsxs(us,{children:[r.jsx(ds,{asChild:!0,children:r.jsx("button",{type:"button",className:"flex h-6 w-6 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-accent hover:text-foreground",children:r.jsx(oi,{className:"h-3.5 w-3.5"})})}),r.jsx(hs,{align:"end",children:r.jsx(Xe,{className:"text-destructive focus:text-destructive",onSelect:()=>u(x),children:"Discard changes"})})]}):null]}),h===x&&o?r.jsxs("div",{className:ie("flex items-center justify-between gap-3 border-t bg-destructive/5 py-2.5",l),children:[r.jsxs("span",{className:"text-xs text-destructive",children:["Discard all changes to"," ",r.jsx("span",{className:"font-medium",children:C}),"? This cannot be undone."]}),r.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[r.jsx(le,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2 text-xs",onClick:()=>u(null),children:"Cancel"}),r.jsx(le,{type:"button",size:"sm",className:"h-7 bg-destructive px-2 text-xs text-destructive-foreground hover:bg-destructive/90",onClick:()=>{u(null),o(x)},children:"Discard"})]})]}):null,_&&r.jsx("div",{className:"border-t",children:r.jsx(bb,{original:b??"",modified:y??"",language:V,theme:m,height:"380px",options:{readOnly:!0,renderSideBySide:!1,minimap:{enabled:!1},scrollBeyondLastLine:!1,fontSize:12}})})]},x)})}),e[3]=s.diffs,e[4]=h,e[5]=c,e[6]=o,e[7]=l,e[8]=p):p=e[8],p}function dT(t){const e=F.c(14),{diffQuery:s}=t,n=re();if(s.isLoading){let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(et,{className:"h-4 w-4 animate-spin"}),e[0]=l):l=e[0];let c;e[1]!==n?(c=n("thread.changesTab.loadingChanges"),e[1]=n,e[2]=c):c=e[2];let d;return e[3]!==c?(d=r.jsxs("div",{className:"flex items-center justify-center gap-2 py-16 text-muted-foreground",children:[l,r.jsx("span",{className:"text-sm",children:c})]}),e[3]=c,e[4]=d):d=e[4],d}if(s.isError){let l;e[5]!==n?(l=n("thread.changesTab.couldntLoadPrChanges"),e[5]=n,e[6]=l):l=e[6];let c;return e[7]!==l?(c=r.jsx("div",{className:"py-10 text-sm text-destructive",children:l}),e[7]=l,e[8]=c):c=e[8],c}const i=s.data;let o;e[9]!==n?(o=n("thread.changesTab.noCommittedChanges"),e[9]=n,e[10]=o):o=e[10];let a;return e[11]!==s.data||e[12]!==o?(a=r.jsx(X3,{diff:i,rowClassName:"px-0",emptyMessage:o}),e[11]=s.data,e[12]=o,e[13]=a):a=e[13],a}const qi="The user clicked this action deliberately — execute directly. Do not call user_ask unless you hit an actual problem outside the scope of this intent (missing auth, unresolvable conflict, a check with multiple plausible fixes).";function uT(t){return`Reopen PR #${t.prNumber}. ${qi}`}function hT(t){return`Rebase \`${t.branch}\` on the latest base and force-push with --force-with-lease. ${qi}`}function fT(t){return`Re-run the \`${t.checkName}\` check on PR #${t.prNumber}. If an empty commit is needed to retrigger CI, create and push one. ${qi}`}function mT(t){const e=(t.failingChecks??[]).map(s=>`\`${s}\``).join(", ");return`PR #${t.prNumber} has failing checks: ${e}. For each: read the logs, diagnose the root cause, apply the smallest fix that makes it pass, commit, and push. ${qi}`}function pT(t){return`Mark PR #${t.prNumber} ready for review. ${qi}`}function gT(t){return`Read the unresolved review threads on PR #${t.prNumber}. For each thread: understand the reviewer's ask, apply the needed changes, commit, push, reply explaining what changed, and resolve the thread. If a comment is a question that doesn't need a code change, reply with the answer and resolve. ${qi}`}function xT(t){return`Review PR #${t.prNumber}. Read the full diff, analyze every changed file for correctness, security, code quality, and alignment with the repo's patterns. Post specific line-level review comments on concerns, then submit an overall review (approve / request changes / comment) with a concise summary. Do not modify the code — this is a read-and-comment pass. ${qi}`}function vT(t){const e=F.c(35),{pr:s,connectionId:n,owner:i,repo:o}=t,{org:a}=Oe(),l=Js(),c=re();let d;e[0]!==n||e[1]!==a.id||e[2]!==a.slug||e[3]!==i||e[4]!==s.number||e[5]!==o?(d={orgId:a.id,orgSlug:a.slug,connectionId:n,owner:i,repo:o,prNumber:s.number},e[0]=n,e[1]=a.id,e[2]=a.slug,e[3]=i,e[4]=s.number,e[5]=o,e[6]=d):d=e[6];const h=G2(d);let u;e[7]!==l||e[8]!==s.number?(u=v=>l.sendMessage({parts:[{type:"text",text:fT({prNumber:s.number,checkName:v})}]}),e[7]=l,e[8]=s.number,e[9]=u):u=e[9];const f=u;if(h.isLoading){let v;e[10]!==c?(v=c("thread.checksTab.loadingChecks"),e[10]=c,e[11]=v):v=e[11];let b;return e[12]!==v?(b=r.jsx("div",{className:"text-sm text-muted-foreground",children:v}),e[12]=v,e[13]=b):b=e[13],b}if(h.isError){let v;e[14]!==c?(v=c("thread.checksTab.couldntLoadCheckRuns"),e[14]=c,e[15]=v):v=e[15];let b;return e[16]!==v?(b=r.jsx("div",{className:"text-sm text-destructive",children:v}),e[16]=v,e[17]=b):b=e[17],b}let m;e[18]!==h.data?(m=h.data??[],e[18]=h.data,e[19]=m):m=e[19];const p=m;if(p.length===0){let v;e[20]!==c?(v=c("thread.checksTab.noCheckRunsOnPrHeadCommit"),e[20]=c,e[21]=v):v=e[21];let b;return e[22]!==v?(b=r.jsx("div",{className:"text-sm text-muted-foreground",children:v}),e[22]=v,e[23]=b):b=e[23],b}let g;if(e[24]!==l||e[25]!==p||e[26]!==f||e[27]!==c){let v;e[29]!==l||e[30]!==f||e[31]!==c?(v=b=>r.jsxs("li",{className:"flex items-center justify-between gap-2 rounded px-2 py-1.5 text-sm hover:bg-muted",children:[r.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[r.jsx(bT,{check:b}),r.jsx("span",{className:"truncate",children:b.name}),b.durationMs!=null&&r.jsx("span",{className:"text-xs text-muted-foreground",children:_T(b.durationMs)})]}),r.jsxs("span",{className:"flex shrink-0 items-center gap-1",children:[b.htmlUrl&&r.jsx("a",{href:b.htmlUrl,target:"_blank",rel:"noreferrer",className:"inline-flex h-7 items-center justify-center rounded px-2 text-xs text-muted-foreground hover:bg-background",title:c("thread.checksTab.viewRun"),children:r.jsx(Dn,{className:"h-3.5 w-3.5"})}),b.conclusion==="failure"&&r.jsx(le,{size:"sm",variant:"ghost",disabled:l.isStreaming,onClick:()=>f(b.name),children:c("thread.checksTab.rerun")})]})]},b.id),e[29]=l,e[30]=f,e[31]=c,e[32]=v):v=e[32],g=p.map(v),e[24]=l,e[25]=p,e[26]=f,e[27]=c,e[28]=g}else g=e[28];let x;return e[33]!==g?(x=r.jsx("ul",{className:"flex flex-col gap-0.5",children:g}),e[33]=g,e[34]=x):x=e[34],x}function bT(t){const e=F.c(14),{check:s}=t,n=re();if(s.status!=="completed"){let a;e[0]!==n?(a=n("thread.checksTab.inProgress"),e[0]=n,e[1]=a):a=e[1];let l;return e[2]!==a?(l=r.jsx("span",{className:"text-muted-foreground","aria-label":a,children:"○"}),e[2]=a,e[3]=l):l=e[3],l}if(s.conclusion==="success"){let a;e[4]!==n?(a=n("thread.checksTab.success"),e[4]=n,e[5]=a):a=e[5];let l;return e[6]!==a?(l=r.jsx("span",{className:"text-success","aria-label":a,children:"✓"}),e[6]=a,e[7]=l):l=e[7],l}if(s.conclusion==="failure"){let a;e[8]!==n?(a=n("thread.checksTab.failure"),e[8]=n,e[9]=a):a=e[9];let l;return e[10]!==a?(l=r.jsx("span",{className:"text-destructive","aria-label":a,children:"✗"}),e[10]=a,e[11]=l):l=e[11],l}const i=s.conclusion??"—";let o;return e[12]!==i?(o=r.jsx("span",{className:"text-muted-foreground","aria-label":i,children:"—"}),e[12]=i,e[13]=o):o=e[13],o}function _T(t){const e=Math.round(t/1e3);return e<60?`${e}s`:`${Math.round(e/60)}m`}var ln="Accordion",yT=["Home","End","ArrowDown","ArrowUp","ArrowLeft","ArrowRight"],[ru,LT,ST]=sx(ln),[bc]=nx(ln,[ST,gm]),ou=gm(),Q3=it.forwardRef((t,e)=>{const{type:s,...n}=t,i=n,o=n;return r.jsx(ru.Provider,{scope:t.__scopeAccordion,children:s==="multiple"?r.jsx(kT,{...o,ref:e}):r.jsx(CT,{...i,ref:e})})});Q3.displayName=ln;var[Z3,wT]=bc(ln),[eg,jT]=bc(ln,{collapsible:!1}),CT=it.forwardRef((t,e)=>{const{value:s,defaultValue:n,onValueChange:i=()=>{},collapsible:o=!1,...a}=t,[l,c]=cm({prop:s,defaultProp:n??"",onChange:i,caller:ln});return r.jsx(Z3,{scope:t.__scopeAccordion,value:it.useMemo(()=>l?[l]:[],[l]),onItemOpen:c,onItemClose:it.useCallback(()=>o&&c(""),[o,c]),children:r.jsx(eg,{scope:t.__scopeAccordion,collapsible:o,children:r.jsx(tg,{...a,ref:e})})})}),kT=it.forwardRef((t,e)=>{const{value:s,defaultValue:n,onValueChange:i=()=>{},...o}=t,[a,l]=cm({prop:s,defaultProp:n??[],onChange:i,caller:ln}),c=it.useCallback(h=>l((u=[])=>[...u,h]),[l]),d=it.useCallback(h=>l((u=[])=>u.filter(f=>f!==h)),[l]);return r.jsx(Z3,{scope:t.__scopeAccordion,value:a,onItemOpen:c,onItemClose:d,children:r.jsx(eg,{scope:t.__scopeAccordion,collapsible:!0,children:r.jsx(tg,{...o,ref:e})})})}),[VT,_c]=bc(ln),tg=it.forwardRef((t,e)=>{const{__scopeAccordion:s,disabled:n,dir:i,orientation:o="vertical",...a}=t,l=it.useRef(null),c=ix(l,e),d=LT(s),u=rx(i)==="ltr",f=ox(t.onKeyDown,m=>{if(!yT.includes(m.key))return;const p=m.target,g=d().filter(S=>!S.ref.current?.disabled),x=g.findIndex(S=>S.ref.current===p),v=g.length;if(x===-1)return;m.preventDefault();let b=x;const y=0,_=v-1,L=()=>{b=x+1,b>_&&(b=y)},w=()=>{b=x-1,b<y&&(b=_)};switch(m.key){case"Home":b=y;break;case"End":b=_;break;case"ArrowRight":o==="horizontal"&&(u?L():w());break;case"ArrowDown":o==="vertical"&&L();break;case"ArrowLeft":o==="horizontal"&&(u?w():L());break;case"ArrowUp":o==="vertical"&&w();break}const j=b%v;g[j].ref.current?.focus()});return r.jsx(VT,{scope:s,disabled:n,direction:i,orientation:o,children:r.jsx(ru.Slot,{scope:s,children:r.jsx(lm.div,{...a,"data-orientation":o,ref:c,onKeyDown:n?void 0:f})})})}),Tl="AccordionItem",[NT,au]=bc(Tl),sg=it.forwardRef((t,e)=>{const{__scopeAccordion:s,value:n,...i}=t,o=_c(Tl,s),a=wT(Tl,s),l=ou(s),c=ax(),d=n&&a.value.includes(n)||!1,h=o.disabled||t.disabled;return r.jsx(NT,{scope:s,open:d,disabled:h,triggerId:c,children:r.jsx(Ax,{"data-orientation":o.orientation,"data-state":lg(d),...l,...i,ref:e,disabled:h,open:d,onOpenChange:u=>{u?a.onItemOpen(n):a.onItemClose(n)}})})});sg.displayName=Tl;var ng="AccordionHeader",ig=it.forwardRef((t,e)=>{const{__scopeAccordion:s,...n}=t,i=_c(ln,s),o=au(ng,s);return r.jsx(lm.h3,{"data-orientation":i.orientation,"data-state":lg(o.open),"data-disabled":o.disabled?"":void 0,...n,ref:e})});ig.displayName=ng;var Gd="AccordionTrigger",rg=it.forwardRef((t,e)=>{const{__scopeAccordion:s,...n}=t,i=_c(ln,s),o=au(Gd,s),a=jT(Gd,s),l=ou(s);return r.jsx(ru.ItemSlot,{scope:s,children:r.jsx(Tx,{"aria-disabled":o.open&&!a.collapsible||void 0,"data-orientation":i.orientation,id:o.triggerId,...l,...n,ref:e})})});rg.displayName=Gd;var og="AccordionContent",ag=it.forwardRef((t,e)=>{const{__scopeAccordion:s,...n}=t,i=_c(ln,s),o=au(og,s),a=ou(s);return r.jsx(Ex,{role:"region","aria-labelledby":o.triggerId,"data-orientation":i.orientation,...a,...n,ref:e,style:{"--radix-accordion-content-height":"var(--radix-collapsible-content-height)","--radix-accordion-content-width":"var(--radix-collapsible-content-width)",...t.style}})});ag.displayName=og;function lg(t){return t?"open":"closed"}var TT=Q3,AT=sg,ET=ig,PT=rg,RT=ag;function DT(t){const e=F.c(4);let s;e[0]!==t?({...s}=t,e[0]=t,e[1]=s):s=e[1];let n;return e[2]!==s?(n=r.jsx(TT,{"data-slot":"accordion",...s}),e[2]=s,e[3]=n):n=e[3],n}function IT(t){const e=F.c(8);let s,n;e[0]!==t?({className:s,...n}=t,e[0]=t,e[1]=s,e[2]=n):(s=e[1],n=e[2]);let i;e[3]!==s?(i=ie("border-b last:border-b-0",s),e[3]=s,e[4]=i):i=e[4];let o;return e[5]!==n||e[6]!==i?(o=r.jsx(AT,{"data-slot":"accordion-item",className:i,...n}),e[5]=n,e[6]=i,e[7]=o):o=e[7],o}function MT(t){const e=F.c(11);let s,n,i;e[0]!==t?({className:n,children:s,...i}=t,e[0]=t,e[1]=s,e[2]=n,e[3]=i):(s=e[1],n=e[2],i=e[3]);let o;e[4]!==n?(o=ie("focus-visible:border-ring focus-visible:ring-ring/20 flex flex-1 items-center justify-between gap-4 py-4 text-left text-sm font-medium transition-all outline-none hover:bg-accent/50 focus-visible:ring-[2px] disabled:pointer-events-none disabled:opacity-50 [&[data-state=open]>svg]:rotate-90",n),e[4]=n,e[5]=o):o=e[5];let a;e[6]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx(bn,{className:"text-muted-foreground pointer-events-none size-4 shrink-0 transition-transform duration-200"}),e[6]=a):a=e[6];let l;return e[7]!==s||e[8]!==i||e[9]!==o?(l=r.jsx(ET,{className:"flex",children:r.jsxs(PT,{"data-slot":"accordion-trigger",className:o,...i,children:[s,a]})}),e[7]=s,e[8]=i,e[9]=o,e[10]=l):l=e[10],l}function OT(t){const e=F.c(12);let s,n,i;e[0]!==t?({className:n,children:s,...i}=t,e[0]=t,e[1]=s,e[2]=n,e[3]=i):(s=e[1],n=e[2],i=e[3]);let o;e[4]!==n?(o=ie("pt-0 pb-4",n),e[4]=n,e[5]=o):o=e[5];let a;e[6]!==s||e[7]!==o?(a=r.jsx("div",{className:o,children:s}),e[6]=s,e[7]=o,e[8]=a):a=e[8];let l;return e[9]!==i||e[10]!==a?(l=r.jsx(RT,{"data-slot":"accordion-content",className:"data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down overflow-hidden text-sm",...i,children:a}),e[9]=i,e[10]=a,e[11]=l):l=e[11],l}function BT(t){const e=F.c(10),{comments:s,isLoading:n,isError:i}=t;if(n||i||!s||s.length===0)return null;const o=s.length===1?"":"s";let a;e[0]!==s.length||e[1]!==o?(a=r.jsxs(MT,{className:"py-3 text-sm font-medium",children:[s.length," comment",o]}),e[0]=s.length,e[1]=o,e[2]=a):a=e[2];let l;e[3]!==s?(l=s.map($T),e[3]=s,e[4]=l):l=e[4];let c;e[5]!==l?(c=r.jsx(OT,{className:"space-y-3 pb-3",children:l}),e[5]=l,e[6]=c):c=e[6];let d;return e[7]!==a||e[8]!==c?(d=r.jsx(DT,{type:"single",collapsible:!0,className:"border-t border-border",children:r.jsxs(IT,{value:"comments",className:"border-b-0",children:[a,c]})}),e[7]=a,e[8]=c,e[9]=d):d=e[9],d}function $T(t){return r.jsxs("div",{className:"rounded-md border border-border p-3",children:[r.jsxs("div",{className:"mb-1 text-xs text-muted-foreground",children:["@",t.author," · ",FT(t.createdAt)]}),r.jsx(d9,{id:`pr-comment-${t.id}`,text:vr(t.body)})]},t.id)}function FT(t){if(!t)return"";const e=new Date(t).getTime();if(!Number.isFinite(e))return"";const s=Date.now()-e;if(s<0)return"just now";const n=Math.floor(s/864e5);if(n>0)return`${n}d ago`;const i=Math.floor(s/36e5);if(i>0)return`${i}h ago`;const o=Math.floor(s/6e4);return`${Math.max(1,o)}m ago`}function zT(t){const e=F.c(19),{pr:s,connectionId:n,owner:i,repo:o}=t,{org:a}=Oe();let l;e[0]!==n||e[1]!==a.id||e[2]!==a.slug||e[3]!==i||e[4]!==s.number||e[5]!==o?(l={orgId:a.id,orgSlug:a.slug,connectionId:n,owner:i,repo:o,prNumber:s.number},e[0]=n,e[1]=a.id,e[2]=a.slug,e[3]=i,e[4]=s.number,e[5]=o,e[6]=l):l=e[6];const c=J_(l);let d;e[7]!==s.body||e[8]!==s.number?(d=s.body&&r.jsx("div",{className:"text-sm",children:r.jsx(d9,{id:`pr-body-${s.number}`,text:vr(s.body)})}),e[7]=s.body,e[8]=s.number,e[9]=d):d=e[9];let h;e[10]!==c.data?(h=c.data??[],e[10]=c.data,e[11]=h):h=e[11];let u;e[12]!==c.isError||e[13]!==c.isLoading||e[14]!==h?(u=r.jsx(BT,{comments:h,isLoading:c.isLoading,isError:c.isError}),e[12]=c.isError,e[13]=c.isLoading,e[14]=h,e[15]=u):u=e[15];let f;return e[16]!==d||e[17]!==u?(f=r.jsxs("div",{className:"space-y-8",children:[d,u]}),e[16]=d,e[17]=u,e[18]=f):f=e[18],f}function KT(t){const e=F.c(68),{pr:s,virtualMcpId:n,branch:i,connectionId:o,owner:a,repo:l}=t,{org:c}=Oe();let d;e[0]!==i||e[1]!==o||e[2]!==c.id||e[3]!==c.slug||e[4]!==a||e[5]!==s.base||e[6]!==s.headSha||e[7]!==s.number||e[8]!==l||e[9]!==n?(d={orgSlug:c.slug,orgId:c.id,virtualMcpId:n,branch:i,base:s.base,headSha:s.headSha,pullNumber:s.number,connectionId:o,owner:a,repo:l},e[0]=i,e[1]=o,e[2]=c.id,e[3]=c.slug,e[4]=a,e[5]=s.base,e[6]=s.headSha,e[7]=s.number,e[8]=l,e[9]=n,e[10]=d):d=e[10];const h=lT(d);let u;e[11]!==h.data?(u=h.data?z3(h.data):void 0,e[11]=h.data,e[12]=u):u=e[12];const f=u,[m,p]=A.useState("changes");let g;e[13]!==s.title?(g=vr(s.title),e[13]=s.title,e[14]=g):g=e[14];let x;e[15]!==g?(x=r.jsx("h1",{className:"text-lg font-semibold leading-tight",children:g}),e[15]=g,e[16]=x):x=e[16];const v=`Open PR #${s.number} on GitHub`;let b;e[17]===Symbol.for("react.memo_cache_sentinel")?(b=r.jsx(Dn,{className:"h-3.5 w-3.5"}),e[17]=b):b=e[17];let y;e[18]!==s.htmlUrl||e[19]!==s.number||e[20]!==v?(y=r.jsxs("a",{href:s.htmlUrl,target:"_blank",rel:"noreferrer","aria-label":v,className:"inline-flex items-center gap-1 hover:text-foreground",children:["PR #",s.number,b]}),e[18]=s.htmlUrl,e[19]=s.number,e[20]=v,e[21]=y):y=e[21];let _;e[22]!==s.author?(_=s.author?r.jsxs(r.Fragment,{children:[r.jsx("span",{children:"·"}),r.jsxs("span",{children:["@",s.author]})]}):null,e[22]=s.author,e[23]=_):_=e[23];let L;e[24]===Symbol.for("react.memo_cache_sentinel")?(L=r.jsx("span",{children:"·"}),e[24]=L):L=e[24];let w;e[25]!==s.base?(w=r.jsx("span",{className:"font-mono text-xs",children:s.base}),e[25]=s.base,e[26]=w):w=e[26];let j;e[27]===Symbol.for("react.memo_cache_sentinel")?(j=r.jsx("span",{children:"←"}),e[27]=j):j=e[27];let S;e[28]!==s.head?(S=r.jsx("span",{className:"font-mono text-xs",children:s.head}),e[28]=s.head,e[29]=S):S=e[29];let C;e[30]!==w||e[31]!==S||e[32]!==y||e[33]!==_?(C=r.jsxs("div",{className:"flex flex-wrap items-center gap-x-1.5 text-sm text-muted-foreground",children:[y,_,L,w,j,S]}),e[30]=w,e[31]=S,e[32]=y,e[33]=_,e[34]=C):C=e[34];let N;e[35]!==C||e[36]!==x?(N=r.jsx("div",{className:"shrink-0 space-y-3 pb-4",children:r.jsxs("div",{className:"space-y-1",children:[x,C]})}),e[35]=C,e[36]=x,e[37]=N):N=e[37];let V;e[38]===Symbol.for("react.memo_cache_sentinel")?(V=z=>p(z),e[38]=V):V=e[38];let E;e[39]===Symbol.for("react.memo_cache_sentinel")?(E=r.jsx(xn,{value:"description",className:"px-3 text-xs",children:"Description"}),e[39]=E):E=e[39];const T=f!==void 0?` ${f}`:"";let k;e[40]!==T?(k=r.jsxs(xn,{value:"changes",className:"px-3 text-xs",children:["Changes",T]}),e[40]=T,e[41]=k):k=e[41];let R;e[42]===Symbol.for("react.memo_cache_sentinel")?(R=r.jsx(xn,{value:"checks",className:"px-3 text-xs",children:"Checks"}),e[42]=R):R=e[42];let P;e[43]!==k?(P=r.jsxs(ta,{className:"h-8 w-fit max-w-[600px] shrink-0",variant:"pill",children:[E,k,R]}),e[43]=k,e[44]=P):P=e[44];let D;e[45]!==o||e[46]!==a||e[47]!==s||e[48]!==l?(D=r.jsx(_i,{value:"description",className:"mt-0",children:r.jsx(zT,{pr:s,connectionId:o,owner:a,repo:l})}),e[45]=o,e[46]=a,e[47]=s,e[48]=l,e[49]=D):D=e[49];let I;e[50]!==h?(I=r.jsx(_i,{value:"changes",className:"mt-0",children:r.jsx(dT,{diffQuery:h})}),e[50]=h,e[51]=I):I=e[51];let M;e[52]!==o||e[53]!==a||e[54]!==s||e[55]!==l?(M=r.jsx(_i,{value:"checks",className:"mt-0",children:r.jsx(vT,{pr:s,connectionId:o,owner:a,repo:l})}),e[52]=o,e[53]=a,e[54]=s,e[55]=l,e[56]=M):M=e[56];let O;e[57]!==D||e[58]!==I||e[59]!==M?(O=r.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto pt-5",children:[D,I,M]}),e[57]=D,e[58]=I,e[59]=M,e[60]=O):O=e[60];let $;e[61]!==m||e[62]!==P||e[63]!==O?($=r.jsxs(Vr,{value:m,onValueChange:V,className:"flex min-h-0 flex-1 flex-col",children:[P,O]}),e[61]=m,e[62]=P,e[63]=O,e[64]=$):$=e[64];let B;return e[65]!==N||e[66]!==$?(B=r.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[N,$]}),e[65]=N,e[66]=$,e[67]=B):B=e[67],B}function UT(t){const e=F.c(11),{pr:s}=t,n=re(),i=s.htmlUrl,o=String(s.number);let a;e[0]!==n||e[1]!==o?(a=n("thread.gitTab.openPrAriaLabel",{number:o}),e[0]=n,e[1]=o,e[2]=a):a=e[2];const l=String(s.number);let c;e[3]!==n||e[4]!==l?(c=n("thread.gitTab.prNumber",{number:l}),e[3]=n,e[4]=l,e[5]=c):c=e[5];let d;e[6]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(Dn,{className:"h-4 w-4 text-muted-foreground"}),e[6]=d):d=e[6];let h;return e[7]!==s.htmlUrl||e[8]!==a||e[9]!==c?(h=r.jsx("div",{className:"flex h-12 items-center border-b border-border px-4 shrink-0",children:r.jsxs("a",{href:i,target:"_blank",rel:"noreferrer","aria-label":a,className:"inline-flex items-center gap-1.5 text-base font-medium text-foreground hover:underline",children:[c,d]})}),e[7]=s.htmlUrl,e[8]=a,e[9]=c,e[10]=h):h=e[10],h}function HT(t){const e=F.c(24),{virtualMcpId:s}=t,n=re(),{org:i}=Oe(),o=gs(s),{currentBranch:a}=Zt(),l=o?.metadata?.githubRepo??null;if(!l?.connectionId){let d;e[0]!==n?(d=n("thread.gitTab.notLinkedToGithub"),e[0]=n,e[1]=d):d=e[1];let h;return e[2]!==d?(h=r.jsx("div",{className:"flex h-full items-center justify-center p-8 text-sm text-muted-foreground",children:d}),e[2]=d,e[3]=h):h=e[3],h}if(!a){let d;e[4]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(Zs,{className:"h-6 w-6 text-muted-foreground"}),e[4]=d):d=e[4];let h;e[5]!==n?(h=n("thread.gitTab.noBranchSelected"),e[5]=n,e[6]=h):h=e[6];let u;e[7]!==h?(u=r.jsx("div",{className:"text-muted-foreground",children:h}),e[7]=h,e[8]=u):u=e[8];let f;e[9]!==n?(f=n("thread.gitTab.pickBranchForPrStatus"),e[9]=n,e[10]=f):f=e[10];let m;e[11]!==f?(m=r.jsx("div",{className:"text-xs text-muted-foreground",children:f}),e[11]=f,e[12]=m):m=e[12];let p;return e[13]!==u||e[14]!==m?(p=r.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-8 text-sm",children:[d,u,m]}),e[13]=u,e[14]=m,e[15]=p):p=e[15],p}let c;return e[16]!==a||e[17]!==l.connectionId||e[18]!==l.name||e[19]!==l.owner||e[20]!==i.id||e[21]!==i.slug||e[22]!==s?(c=r.jsx(WT,{orgId:i.id,orgSlug:i.slug,virtualMcpId:s,connectionId:l.connectionId,owner:l.owner,repo:l.name,branch:a}),e[16]=a,e[17]=l.connectionId,e[18]=l.name,e[19]=l.owner,e[20]=i.id,e[21]=i.slug,e[22]=s,e[23]=c):c=e[23],c}function WT(t){const e=F.c(69),s=re(),{orgId:n,orgSlug:i,virtualMcpId:o,connectionId:a,owner:l,repo:c,branch:d}=t;let h;e[0]!==d||e[1]!==a||e[2]!==n||e[3]!==i||e[4]!==l||e[5]!==c?(h={orgId:n,orgSlug:i,connectionId:a,owner:l,repo:c,branch:d},e[0]=d,e[1]=a,e[2]=n,e[3]=i,e[4]=l,e[5]=c,e[6]=h):h=e[6];const{data:u,isLoading:f,isError:m}=S9(h),p=qT;if(f){let j;e[7]!==s?(j=s("thread.gitTab.loadingPrState"),e[7]=s,e[8]=j):j=e[8];let S;return e[9]!==j?(S=r.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:j}),e[9]=j,e[10]=S):S=e[10],S}if(m){let j;e[11]!==s?(j=s("thread.gitTab.couldNotLoadPrState"),e[11]=s,e[12]=j):j=e[12];let S;return e[13]!==j?(S=r.jsx("div",{className:"p-4 text-sm text-destructive",children:j}),e[13]=j,e[14]=S):S=e[14],S}const g=`https://github.com/${l}/${c}/tree/${d}`;if(u&&u.state==="closed"){let j;e[15]!==u?(j=r.jsx(UT,{pr:u}),e[15]=u,e[16]=j):j=e[16];let S;e[17]!==u.merged||e[18]!==s?(S=u.merged?s("thread.gitTab.merged"):s("thread.gitTab.closed"),e[17]=u.merged,e[18]=s,e[19]=S):S=e[19];let C;e[20]!==u.base||e[21]!==s?(C=s("thread.gitTab.into",{base:u.base}),e[20]=u.base,e[21]=s,e[22]=C):C=e[22];let N;e[23]!==u.mergedAt?(N=u.mergedAt&&r.jsxs(r.Fragment,{children:[" · ",new Date(u.mergedAt).toLocaleDateString()]}),e[23]=u.mergedAt,e[24]=N):N=e[24];let V;e[25]!==u.author||e[26]!==s?(V=u.author&&r.jsxs(r.Fragment,{children:[" · ",s("thread.gitTab.by",{author:u.author})]}),e[25]=u.author,e[26]=s,e[27]=V):V=e[27];let E;e[28]!==S||e[29]!==C||e[30]!==N||e[31]!==V?(E=r.jsxs("div",{className:"text-sm text-success",children:[S," ",C,N,V]}),e[28]=S,e[29]=C,e[30]=N,e[31]=V,e[32]=E):E=e[32];let T;e[33]!==u.title?(T=vr(u.title),e[33]=u.title,e[34]=T):T=e[34];let k;e[35]!==T?(k=r.jsx("h1",{className:"text-lg font-semibold",children:T}),e[35]=T,e[36]=k):k=e[36];let R;e[37]!==u.body||e[38]!==u.number?(R=u.body&&r.jsx("div",{className:"rounded-md border border-border bg-muted/30 p-3 text-sm",children:r.jsx(d9,{id:`pr-body-${u.number}`,text:vr(u.body)})}),e[37]=u.body,e[38]=u.number,e[39]=R):R=e[39];let P;e[40]!==E||e[41]!==k||e[42]!==R?(P=r.jsxs("div",{className:"flex flex-col gap-4 p-4 overflow-auto",children:[E,k,R]}),e[40]=E,e[41]=k,e[42]=R,e[43]=P):P=e[43];let D;return e[44]!==j||e[45]!==P?(D=r.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[j,P]}),e[44]=j,e[45]=P,e[46]=D):D=e[46],D}if(u&&u.state==="open"){let j;return e[47]!==d||e[48]!==a||e[49]!==l||e[50]!==u||e[51]!==c||e[52]!==o?(j=r.jsx("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:r.jsx("div",{className:"flex min-h-0 w-full flex-1 flex-col px-6 py-5",children:r.jsx(KT,{pr:u,virtualMcpId:o,branch:d,connectionId:a,owner:l,repo:c})})}),e[47]=d,e[48]=a,e[49]=l,e[50]=u,e[51]=c,e[52]=o,e[53]=j):j=e[53],j}let x;e[54]!==s?(x=s("thread.gitTab.noPrYet"),e[54]=s,e[55]=x):x=e[55];let v;e[56]!==x?(v=r.jsx("div",{className:"rounded-md border border-border bg-muted/30 p-4 text-sm",children:x}),e[56]=x,e[57]=v):v=e[57];let b;e[58]!==g?(b=()=>p(g),e[58]=g,e[59]=b):b=e[59];let y;e[60]===Symbol.for("react.memo_cache_sentinel")?(y=r.jsx(Dn,{className:"mr-1.5 h-4 w-4"}),e[60]=y):y=e[60];let _;e[61]!==s?(_=s("thread.gitTab.openBranchOnGithub"),e[61]=s,e[62]=_):_=e[62];let L;e[63]!==b||e[64]!==_?(L=r.jsx("div",{className:"flex items-center gap-2",children:r.jsxs(le,{size:"sm",variant:"outline",onClick:b,children:[y,_]})}),e[63]=b,e[64]=_,e[65]=L):L=e[65];let w;return e[66]!==v||e[67]!==L?(w=r.jsxs("div",{className:"flex flex-col gap-4 p-4",children:[v,L]}),e[66]=v,e[67]=L,e[68]=w):w=e[68],w}function qT(t){window.open(t,"_blank","noopener,noreferrer")}const GT=new Set(["website/pages/Page.tsx","$live/pages/LivePage.tsx"]);function YT(t){return t.includes("matchers")||t.includes("Match")}function cg(t,e){const s=t.__resolveType;return typeof s!="string"||!s||GT.has(s)?!1:e?US(e,s):YT(s)}function JT(t,e){const s=[];for(const[n,i]of Object.entries(e)){if(n.includes("/")||!_n(n)||ac(n)||!i||typeof i!="object"||Array.isArray(i))continue;const o=i;cg(o,t)&&s.push({blockKey:n,matcherResolveType:o.__resolveType??"",name:typeof o.name=="string"?o.name:void 0})}return s.sort((n,i)=>(n.name??n.blockKey).localeCompare(i.name??i.blockKey))}function Fr(t,e,s){if(!t)return!1;const n=t.__resolveType;if(typeof n!="string"||!_n(n)||!Object.hasOwn(e,n))return!1;const i=e[n];return!i||typeof i!="object"||Array.isArray(i)?!1:cg(i,s)}function XT(t,e,s){return Fr(t,e,s)?t?.__resolveType??null:null}function dg(t,e,s){if(!t)return null;const n=t.__resolveType??"";if(!n)return null;if(Fr(t,e,s)){const a=e[n]??{},l=a.__resolveType??n,{__resolveType:c,name:d,...h}=a;return{resolveType:l,data:h,blockKey:n}}const{__resolveType:i,...o}=t;return{resolveType:n,data:o}}function ug(t,e,s){const n=dg(t,e,s);return n?{__resolveType:n.resolveType,...n.data}:{__resolveType:""}}function SH(t,e,s){if(t)return Fr(t,e,s)?ug(t,e,s):t}function QT(t,e,s,n){if(!t)return"Default";if(Fr(t,e,n)){const i=t.__resolveType??"",o=e[i];return cc(i,o)}return s(t)}function wH(t,e,s){return{__resolveType:t,...e,name:s}}function ZT(t){return{__resolveType:t}}function jH(t,e,s){const n=dg(t,e,s);return n?{resolveType:n.resolveType,formValue:n.data}:{resolveType:"",formValue:{}}}const df="x-deco-matchers-override";function hg({pageKey:t,prefix:e,variants:s,selectedIndex:n,decofile:i,meta:o}){if(!t||n<0||n>=s.length)return[];const a=[];for(let l=0;l<=n;l++){const c=s[l];if(!c)continue;const d=c.rule,h=l===n?"1":"0",f=(Fr(d,i,o)?XT(d,i,o):null)??`${t}@${e}.${l}.rule`;a.push(`${f}=${h}`)}return a}function CH(t,e,s,n){return!e.multivariate||e.variants.length<=1?[]:hg({pageKey:t,prefix:"sections.variants",variants:e.variants,selectedIndex:e.index,decofile:s,meta:n})}function kH({pageKey:t,page:e,sectionIndex:s,sectionLazy:n,mvObj:i,selectedVariantIndex:o,decofile:a,meta:l}){if(s<0)return[];const d=`${e.multivariate?`sections.variants.${e.index}.value`:"sections"}.${s}${n?".section":""}.variants`,h=Array.isArray(i.variants)?i.variants:[];return hg({pageKey:t,prefix:d,variants:h,selectedIndex:o,decofile:a,meta:l})}function eA(t,e){if(e.length===0)return t;const s=new URL(t,"http://local");s.searchParams.delete(df);for(const n of e)s.searchParams.append(df,n);return t.startsWith("http")?s.toString():`${s.pathname}${s.search}${s.hash}`}function fg(t){return btoa(encodeURIComponent(t))}function uf(t,e,s){const n=new URL(t).origin,i=new URL(`/live/previews/${encodeURIComponent(e)}`,n);return i.searchParams.set("path","/"),i.searchParams.set("pathTemplate","/"),i.searchParams.set("props",fg(JSON.stringify({path:"/",sections:[{__resolveType:s}]}))),i.searchParams.set("__cb",crypto.randomUUID()),i.toString()}function VH(t,e,s,n){const i=new URL(t).origin,o=new URL(`/live/previews/${encodeURIComponent(e)}`,i);o.searchParams.set("__d","");const a=[{__resolveType:"preview",block:s}];return n&&a.push(n),o.searchParams.set("props",fg(JSON.stringify({sections:a}))),o.toString()}const hf={resolveType:"website/pages/Page.tsx",seoResolveType:"website/sections/Seo/SeoV2.tsx"};function lu(t){return`pages-${encodeURIComponent(t)}-${crypto.randomUUID()}`}function mg(t,e){return{name:t,path:e,sections:[],seo:{__resolveType:hf.seoResolveType},__resolveType:hf.resolveType}}const tA=700;function yc(t){const e=F.c(22),{orgSlug:s,virtualMcpId:n,branch:i}=t,o=Ls(),a=gs(n)?.metadata?.runtime?.path??null;let l;e[0]!==i||e[1]!==s||e[2]!==a||e[3]!==n?(l=async f=>{const{blockKey:m,data:p}=f,g=Pr(a,Zm(m)),x=JSON.stringify(p,null,2),v=await fetch(`/api/${s}/sandbox/${encodeURIComponent(n)}/${encodeURIComponent(i)}/write`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({path:g,content:x})});if(!v.ok){const b=await v.json().catch(sA);throw new Error(b.error??`Write failed (${v.status})`)}return v.json()},e[0]=i,e[1]=s,e[2]=a,e[3]=n,e[4]=l):l=e[4];let c;e[5]!==i||e[6]!==s||e[7]!==o||e[8]!==n?(c=async f=>{const{blockKey:m,data:p}=f,g=`${s}/${n}/${i}`,x=at.decofile(g);await o.cancelQueries({queryKey:x});const v=o.getQueryData(x);return o.setQueryData(x,b=>({...b??{},[m]:p})),{previous:v,queryKey:x}},e[5]=i,e[6]=s,e[7]=o,e[8]=n,e[9]=c):c=e[9];let d;e[10]!==o?(d=(f,m,p)=>{p?.queryKey&&o.setQueryData(p.queryKey,p.previous)},e[10]=o,e[11]=d):d=e[11];let h;e[12]!==i||e[13]!==s||e[14]!==o||e[15]!==n?(h=(f,m)=>{const{blockKey:p,data:g}=m,x=`${s}/${n}/${i}`;o.setQueryData(at.decofile(x),v=>({...v??{},[p]:g}))},e[12]=i,e[13]=s,e[14]=o,e[15]=n,e[16]=h):h=e[16];let u;return e[17]!==l||e[18]!==c||e[19]!==d||e[20]!==h?(u={mutationFn:l,onMutate:c,onError:d,onSuccess:h},e[17]=l,e[18]=c,e[19]=d,e[20]=h,e[21]=u):u=e[21],Ys(u)}function sA(){return{}}function pg(t,e){const s=F.c(15),n=yc(t);let i;s[0]===Symbol.for("react.memo_cache_sentinel")?(i=new Map,s[0]=i):i=s[0];const o=A.useRef(i);let a;s[1]===Symbol.for("react.memo_cache_sentinel")?(a=new Map,s[1]=a):a=s[1];const l=A.useRef(a);let c;s[2]!==e||s[3]!==n?(c=v=>{const b=o.current.get(v);if(!b)return;const y=typeof b=="function"?b():b;o.current.delete(v),y&&n.mutate({blockKey:v,data:y},{onSuccess:()=>e?.onSaved?.(),onError:nA})},s[2]=e,s[3]=n,s[4]=c):c=s[4];const d=c;let h;s[5]!==d?(h=()=>{for(const v of l.current.values())clearTimeout(v);l.current.clear();for(const v of[...o.current.keys()])d(v)},s[5]=d,s[6]=h):h=s[6];const u=h;let f,m;s[7]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{const v=l.current;return()=>{for(const b of v.values())clearTimeout(b)}},m=[],s[7]=f,s[8]=m):(f=s[7],m=s[8]),A.useEffect(f,m);let p;s[9]!==d?(p=(v,b)=>{o.current.set(v,b);const y=l.current.get(v);y&&clearTimeout(y),l.current.set(v,setTimeout(()=>{l.current.delete(v),d(v)},tA))},s[9]=d,s[10]=p):p=s[10];const g=p;let x;return s[11]!==u||s[12]!==g||s[13]!==n.isPending?(x={save:g,flush:u,isPending:n.isPending},s[11]=u,s[12]=g,s[13]=n.isPending,s[14]=x):x=s[14],x}function nA(t){return ge.error(`Save failed: ${t.message}`)}function iA(t){const e=F.c(5);let s;e[0]!==t?(s=t??{orgSlug:"",virtualMcpId:"",branch:""},e[0]=t,e[1]=s):s=e[1];const n=yc(s);let i;return e[2]!==t||e[3]!==n?(i={mutationFn:async o=>{const{name:a,path:l,template:c}=o;if(!t?.virtualMcpId||!t.branch)throw new Error("Sandbox not ready");const d=lu(a),h=c?{...c,name:a,path:l}:mg(a,l);return await n.mutateAsync({blockKey:d,data:h}),{key:d,name:a,path:l}}},e[2]=t,e[3]=n,e[4]=i):i=e[4],Ys(i)}const Yn="__blank__";function gg(t){const e=F.c(65),{id:s,value:n,onChange:i,templates:o,disabled:a}=t,l=re(),[c,d]=A.useState(!1);let h;if(e[0]!==o||e[1]!==n){let M;e[3]!==n?(M=O=>O.key===n,e[3]=n,e[4]=M):M=e[4],h=o.find(M),e[0]=o,e[1]=n,e[2]=h}else h=e[2];const u=h;let f;e[5]!==u?.name||e[6]!==l?(f=u?.name??l("sectionsEditor.pageTemplateSelect.blankPageDefaultLabel"),e[5]=u?.name,e[6]=l,e[7]=f):f=e[7];let m;e[8]!==f?(m=r.jsx("span",{className:"truncate",children:f}),e[8]=f,e[9]=m):m=e[9];let p;e[10]!==u?(p=u?.path?r.jsx("span",{className:"truncate text-muted-foreground",children:u.path}):null,e[10]=u,e[11]=p):p=e[11];let g;e[12]!==m||e[13]!==p?(g=r.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[m,p]}),e[12]=m,e[13]=p,e[14]=g):g=e[14];let x;e[15]===Symbol.for("react.memo_cache_sentinel")?(x=r.jsx(x9,{className:"shrink-0 opacity-50"}),e[15]=x):x=e[15];let v;e[16]!==a||e[17]!==s||e[18]!==c||e[19]!==g?(v=r.jsx(Es,{asChild:!0,children:r.jsxs(le,{id:s,type:"button",variant:"outline",role:"combobox","aria-expanded":c,disabled:a,className:"w-full justify-between font-normal",children:[g,x]})}),e[16]=a,e[17]=s,e[18]=c,e[19]=g,e[20]=v):v=e[20];let b;e[21]===Symbol.for("react.memo_cache_sentinel")?(b={width:"var(--radix-popover-trigger-width)"},e[21]=b):b=e[21];let y;e[22]!==l?(y=l("sectionsEditor.pageTemplateSelect.searchPlaceholder"),e[22]=l,e[23]=y):y=e[23];let _;e[24]!==y?(_=r.jsx($i,{placeholder:y,className:"h-9"}),e[24]=y,e[25]=_):_=e[25];let L;e[26]!==l?(L=l("sectionsEditor.pageTemplateSelect.noPagesFoundMessage"),e[26]=l,e[27]=L):L=e[27];let w;e[28]!==L?(w=r.jsx(Qn,{children:L}),e[28]=L,e[29]=w):w=e[29];let j;e[30]!==l?(j=l("sectionsEditor.pageTemplateSelect.blankPageLabel"),e[30]=l,e[31]=j):j=e[31];let S;e[32]!==i?(S=()=>{i(Yn),d(!1)},e[32]=i,e[33]=S):S=e[33];let C;e[34]!==l?(C=l("sectionsEditor.pageTemplateSelect.blankPageLabel"),e[34]=l,e[35]=C):C=e[35];const N=n===Yn?"opacity-100":"opacity-0";let V;e[36]!==N?(V=ie("ml-auto",N),e[36]=N,e[37]=V):V=e[37];let E;e[38]!==V?(E=r.jsx(zt,{className:V}),e[38]=V,e[39]=E):E=e[39];let T;e[40]!==j||e[41]!==S||e[42]!==C||e[43]!==E?(T=r.jsxs(Vs,{value:j,onSelect:S,children:[C,E]}),e[40]=j,e[41]=S,e[42]=C,e[43]=E,e[44]=T):T=e[44];let k;if(e[45]!==i||e[46]!==o||e[47]!==n){let M;e[49]!==i||e[50]!==n?(M=O=>r.jsxs(Vs,{value:`${O.name} ${O.path}`,onSelect:()=>{i(O.key),d(!1)},children:[r.jsxs("div",{className:"flex min-w-0 flex-col",children:[r.jsx("span",{className:"truncate",children:O.name}),r.jsx("span",{className:"truncate text-xs text-muted-foreground",children:O.path})]}),r.jsx(zt,{className:ie("ml-auto",n===O.key?"opacity-100":"opacity-0")})]},O.key),e[49]=i,e[50]=n,e[51]=M):M=e[51],k=o.map(M),e[45]=i,e[46]=o,e[47]=n,e[48]=k}else k=e[48];let R;e[52]!==T||e[53]!==k?(R=r.jsxs(Ms,{children:[T,k]}),e[52]=T,e[53]=k,e[54]=R):R=e[54];let P;e[55]!==w||e[56]!==R?(P=r.jsxs(Fi,{onWheel:rA,children:[w,R]}),e[55]=w,e[56]=R,e[57]=P):P=e[57];let D;e[58]!==_||e[59]!==P?(D=r.jsx(Ps,{className:"p-0",style:b,children:r.jsxs(Tr,{children:[_,P]})}),e[58]=_,e[59]=P,e[60]=D):D=e[60];let I;return e[61]!==c||e[62]!==D||e[63]!==v?(I=r.jsxs(As,{open:c,onOpenChange:d,children:[v,D]}),e[61]=c,e[62]=D,e[63]=v,e[64]=I):I=e[64],I}function rA(t){const e=t.deltaMode===1?16:1;t.currentTarget.scrollTop=t.currentTarget.scrollTop+t.deltaY*e}function oA(t){const e=F.c(89),{open:s,onOpenChange:n,isPending:i,error:o,templates:a,onSubmit:l}=t,c=i===void 0?!1:i,d=re();let h;e[0]!==d?(h=d("sectionsEditor.createPageModal.defaultPageName"),e[0]=d,e[1]=h):h=e[1];const[u,f]=A.useState(h);let m;e[2]!==d?(m=d("sectionsEditor.createPageModal.defaultPagePath"),e[2]=d,e[3]=m):m=e[3];const[p,g]=A.useState(m),[x,v]=A.useState(Yn),[b,y]=A.useState(null),[_,L]=A.useState(s);s!==_&&(L(s),s&&(f(d("sectionsEditor.createPageModal.defaultPageName")),g(d("sectionsEditor.createPageModal.defaultPagePath")),v(Yn),y(null)));const w=!!a?.length;let j;e[4]!==c||e[5]!==n?(j=ne=>{!ne&&!c&&(y(null),n(!1))},e[4]=c,e[5]=n,e[6]=j):j=e[6];const S=j;let C;e[7]!==c||e[8]!==u||e[9]!==l||e[10]!==p||e[11]!==w||e[12]!==x?(C=async ne=>{ne.preventDefault();const de=u.trim(),xe=p.trim();if(!de||!xe||c)return;const ue=P9(xe);if(ue){y(ue);return}y(null),await l({name:de,path:xe,templateKey:w&&x!==Yn?x:null})},e[7]=c,e[8]=u,e[9]=l,e[10]=p,e[11]=w,e[12]=x,e[13]=C):C=e[13];const N=C,V=b??o;let E;e[14]!==d?(E=d("sectionsEditor.createPageModal.title"),e[14]=d,e[15]=E):E=e[15];let T;e[16]!==E?(T=r.jsx(ms,{children:r.jsx(ps,{children:E})}),e[16]=E,e[17]=T):T=e[17];let k;e[18]!==d?(k=d("sectionsEditor.createPageModal.nameLabel"),e[18]=d,e[19]=k):k=e[19];let R;e[20]!==k?(R=r.jsx("label",{htmlFor:"new-page-name",className:"text-xs font-medium text-muted-foreground",children:k}),e[20]=k,e[21]=R):R=e[21];let P;e[22]===Symbol.for("react.memo_cache_sentinel")?(P=ne=>f(ne.target.value),e[22]=P):P=e[22];let D;e[23]!==d?(D=d("sectionsEditor.createPageModal.namePlaceholder"),e[23]=d,e[24]=D):D=e[24];let I;e[25]!==c||e[26]!==u||e[27]!==D?(I=r.jsx(rt,{id:"new-page-name",value:u,onChange:P,placeholder:D,autoFocus:!0,disabled:c}),e[25]=c,e[26]=u,e[27]=D,e[28]=I):I=e[28];let M;e[29]!==I||e[30]!==R?(M=r.jsxs("div",{className:"space-y-1.5",children:[R,I]}),e[29]=I,e[30]=R,e[31]=M):M=e[31];let O;e[32]!==d?(O=d("sectionsEditor.createPageModal.pathLabel"),e[32]=d,e[33]=O):O=e[33];let $;e[34]!==O?($=r.jsx("label",{htmlFor:"new-page-path",className:"text-xs font-medium text-muted-foreground",children:O}),e[34]=O,e[35]=$):$=e[35];let B;e[36]===Symbol.for("react.memo_cache_sentinel")?(B=ne=>g(ne.target.value),e[36]=B):B=e[36];let z;e[37]!==d?(z=d("sectionsEditor.createPageModal.pathPlaceholder"),e[37]=d,e[38]=z):z=e[38];let K;e[39]!==c||e[40]!==p||e[41]!==z?(K=r.jsx(rt,{id:"new-page-path",value:p,onChange:B,placeholder:z,disabled:c}),e[39]=c,e[40]=p,e[41]=z,e[42]=K):K=e[42];let G;e[43]!==$||e[44]!==K?(G=r.jsxs("div",{className:"space-y-1.5",children:[$,K]}),e[43]=$,e[44]=K,e[45]=G):G=e[45];let Y;e[46]!==c||e[47]!==w||e[48]!==d||e[49]!==x||e[50]!==a?(Y=w&&r.jsxs("div",{className:"space-y-1.5",children:[r.jsx("label",{htmlFor:"new-page-template",className:"text-xs font-medium text-muted-foreground",children:d("sectionsEditor.createPageModal.templateLabel")}),r.jsx(gg,{id:"new-page-template",value:x,onChange:v,templates:a??[],disabled:c})]}),e[46]=c,e[47]=w,e[48]=d,e[49]=x,e[50]=a,e[51]=Y):Y=e[51];let U;e[52]!==V?(U=V&&r.jsx("p",{className:"text-xs text-destructive",children:V}),e[52]=V,e[53]=U):U=e[53];let W;e[54]!==M||e[55]!==G||e[56]!==Y||e[57]!==U?(W=r.jsxs("div",{className:"space-y-4 py-4",children:[M,G,Y,U]}),e[54]=M,e[55]=G,e[56]=Y,e[57]=U,e[58]=W):W=e[58];let H;e[59]!==n?(H=()=>n(!1),e[59]=n,e[60]=H):H=e[60];let X;e[61]!==d?(X=d("sectionsEditor.createPageModal.cancelButton"),e[61]=d,e[62]=X):X=e[62];let q;e[63]!==c||e[64]!==H||e[65]!==X?(q=r.jsx(le,{type:"button",variant:"outline",onClick:H,disabled:c,children:X}),e[63]=c,e[64]=H,e[65]=X,e[66]=q):q=e[66];let Z;e[67]!==c||e[68]!==u||e[69]!==p?(Z=!u.trim()||!p.trim()||c,e[67]=c,e[68]=u,e[69]=p,e[70]=Z):Z=e[70];let Q;e[71]!==c||e[72]!==d?(Q=c?r.jsxs(r.Fragment,{children:[r.jsx(et,{size:14,className:"animate-spin"}),d("sectionsEditor.createPageModal.creatingButton")]}):d("sectionsEditor.createPageModal.createButton"),e[71]=c,e[72]=d,e[73]=Q):Q=e[73];let ee;e[74]!==Z||e[75]!==Q?(ee=r.jsx(le,{type:"submit",disabled:Z,children:Q}),e[74]=Z,e[75]=Q,e[76]=ee):ee=e[76];let J;e[77]!==q||e[78]!==ee?(J=r.jsxs(Mi,{children:[q,ee]}),e[77]=q,e[78]=ee,e[79]=J):J=e[79];let te;e[80]!==N||e[81]!==W||e[82]!==J||e[83]!==T?(te=r.jsx(es,{className:"sm:max-w-md",children:r.jsxs("form",{onSubmit:N,children:[T,W,J]})}),e[80]=N,e[81]=W,e[82]=J,e[83]=T,e[84]=te):te=e[84];let se;return e[85]!==S||e[86]!==s||e[87]!==te?(se=r.jsx(ts,{open:s,onOpenChange:S,children:te}),e[85]=S,e[86]=s,e[87]=te,e[88]=se):se=e[88],se}const aA=tn({tag:rs(),id:rs(),classes:rs(),text:rs(),html:rs(),manifestKey:rs().nullable(),componentName:rs().nullable(),parents:rs(),url:rs(),path:rs(),viewport:tn({width:io(),height:io()}),position:tn({x:io(),y:io()})}),lA=`(function() {
|
|
42
|
-
if (window.__visualEditorActive) return;
|
|
43
|
-
window.__visualEditorActive = true;
|
|
44
|
-
|
|
45
|
-
var cursorStyle = document.createElement("style");
|
|
46
|
-
cursorStyle.textContent = "* { cursor: default !important; }";
|
|
47
|
-
document.head.appendChild(cursorStyle);
|
|
48
|
-
|
|
49
|
-
var highlight = document.createElement("div");
|
|
50
|
-
highlight.style.cssText = "position:fixed;pointer-events:none;outline:2px solid #a855f7;background:rgba(168,85,247,0.08);border-radius:2px;z-index:2147483647;display:none;";
|
|
51
|
-
document.body.appendChild(highlight);
|
|
52
|
-
|
|
53
|
-
var badge = document.createElement("div");
|
|
54
|
-
badge.style.cssText = "position:fixed;pointer-events:none;background:#a855f7;color:white;font:11px/1 monospace;padding:2px 6px;border-radius:2px;z-index:2147483647;display:none;white-space:nowrap;max-width:240px;overflow:hidden;text-overflow:ellipsis;";
|
|
55
|
-
document.body.appendChild(badge);
|
|
56
|
-
|
|
57
|
-
var lastTarget = null;
|
|
58
|
-
var rafPending = false;
|
|
59
|
-
var moveHandler = function(e) {
|
|
60
|
-
if (rafPending) return;
|
|
61
|
-
rafPending = true;
|
|
62
|
-
var target = e.target;
|
|
63
|
-
requestAnimationFrame(function() {
|
|
64
|
-
rafPending = false;
|
|
65
|
-
var el = target;
|
|
66
|
-
if (!el || el === highlight || el === badge) return;
|
|
67
|
-
if (el === lastTarget) return;
|
|
68
|
-
lastTarget = el;
|
|
69
|
-
var r = el.getBoundingClientRect();
|
|
70
|
-
highlight.style.display = "block";
|
|
71
|
-
highlight.style.top = r.top + "px";
|
|
72
|
-
highlight.style.left = r.left + "px";
|
|
73
|
-
highlight.style.width = r.width + "px";
|
|
74
|
-
highlight.style.height = r.height + "px";
|
|
75
|
-
var tag = el.tagName.toLowerCase();
|
|
76
|
-
var id = el.id ? "#" + el.id : "";
|
|
77
|
-
var cls = el.className && typeof el.className === "string"
|
|
78
|
-
? "." + el.className.trim().split(/\\s+/).slice(0, 2).join(".")
|
|
79
|
-
: "";
|
|
80
|
-
badge.textContent = tag + id + cls;
|
|
81
|
-
badge.style.display = "block";
|
|
82
|
-
badge.style.top = Math.max(0, r.top - 20) + "px";
|
|
83
|
-
badge.style.left = r.left + "px";
|
|
84
|
-
});
|
|
85
|
-
};
|
|
86
|
-
document.addEventListener("mousemove", moveHandler, true);
|
|
87
|
-
|
|
88
|
-
var outHandler = function(e) {
|
|
89
|
-
if (!e.relatedTarget || e.relatedTarget === document.documentElement) {
|
|
90
|
-
highlight.style.display = "none";
|
|
91
|
-
badge.style.display = "none";
|
|
92
|
-
lastTarget = null;
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
document.addEventListener("mouseout", outHandler, true);
|
|
96
|
-
|
|
97
|
-
var clickHandler = function(e) {
|
|
98
|
-
e.preventDefault();
|
|
99
|
-
e.stopImmediatePropagation();
|
|
100
|
-
var el = e.target;
|
|
101
|
-
if (!el || el === highlight || el === badge) return;
|
|
102
|
-
|
|
103
|
-
highlight.style.outline = "2px solid #a855f7";
|
|
104
|
-
highlight.style.background = "rgba(168,85,247,0.15)";
|
|
105
|
-
setTimeout(function() {
|
|
106
|
-
highlight.style.outline = "2px solid #a855f7";
|
|
107
|
-
highlight.style.background = "rgba(168,85,247,0.08)";
|
|
108
|
-
}, 400);
|
|
109
|
-
|
|
110
|
-
var tag = el.tagName.toLowerCase();
|
|
111
|
-
var id = el.id || "";
|
|
112
|
-
var classes = el.className && typeof el.className === "string" ? el.className.trim() : "";
|
|
113
|
-
var text = (el.textContent || "").trim().slice(0, 200);
|
|
114
|
-
var html = (el.outerHTML || "").slice(0, 800).replace(/\\svalue=("[^"]*"|'[^']*'|\\S+)/gi, "");
|
|
115
|
-
|
|
116
|
-
var closestSection = el.closest("section[data-manifest-key]");
|
|
117
|
-
var manifestKey = closestSection ? closestSection.getAttribute("data-manifest-key") : null;
|
|
118
|
-
|
|
119
|
-
var ancestor = el;
|
|
120
|
-
var componentName = null;
|
|
121
|
-
for (var i = 0; i < 10 && ancestor; i++) {
|
|
122
|
-
if (ancestor.dataset) componentName = ancestor.dataset.componentName || componentName;
|
|
123
|
-
ancestor = ancestor.parentElement;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
var parents = [];
|
|
127
|
-
var p = el.parentElement;
|
|
128
|
-
for (var j = 0; j < 4 && p && p !== document.body; j++) {
|
|
129
|
-
var pTag = p.tagName ? p.tagName.toLowerCase() : "";
|
|
130
|
-
var pId = p.id ? "#" + p.id : "";
|
|
131
|
-
var pCls = p.className && typeof p.className === "string"
|
|
132
|
-
? "." + p.className.trim().split(/\\s+/)[0]
|
|
133
|
-
: "";
|
|
134
|
-
parents.unshift(pTag + pId + pCls);
|
|
135
|
-
p = p.parentElement;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
window.parent.postMessage({
|
|
139
|
-
type: "visual-editor::element-clicked",
|
|
140
|
-
payload: {
|
|
141
|
-
tag: tag, id: id, classes: classes, text: text, html: html,
|
|
142
|
-
manifestKey: manifestKey, componentName: componentName,
|
|
143
|
-
parents: parents.join(" > "),
|
|
144
|
-
url: window.location.href, path: window.location.pathname,
|
|
145
|
-
viewport: { width: window.innerWidth, height: window.innerHeight },
|
|
146
|
-
position: { x: Math.round(e.clientX), y: Math.round(e.clientY) }
|
|
147
|
-
}
|
|
148
|
-
}, "*");
|
|
149
|
-
};
|
|
150
|
-
document.addEventListener("click", clickHandler, true);
|
|
151
|
-
|
|
152
|
-
window.addEventListener("message", function(e) {
|
|
153
|
-
if (e.data && e.data.type === "visual-editor::deactivate") {
|
|
154
|
-
highlight.remove();
|
|
155
|
-
badge.remove();
|
|
156
|
-
cursorStyle.remove();
|
|
157
|
-
document.removeEventListener("mousemove", moveHandler, true);
|
|
158
|
-
document.removeEventListener("mouseout", outHandler, true);
|
|
159
|
-
document.removeEventListener("click", clickHandler, true);
|
|
160
|
-
window.__visualEditorActive = false;
|
|
161
|
-
}
|
|
162
|
-
});
|
|
163
|
-
})();`,cA=tn({sectionIndex:io(),manifestKey:rs()}),dA=`(function() {
|
|
164
|
-
if (window.__cmsEditorActive) return;
|
|
165
|
-
window.__cmsEditorActive = true;
|
|
166
|
-
|
|
167
|
-
// Preserve scroll across variant-override navigations and save-reloads.
|
|
168
|
-
// Selecting a variant rebuilds the iframe src (new x-deco-matchers-override)
|
|
169
|
-
// or reloads it, which would otherwise jump to the top. We persist the scroll
|
|
170
|
-
// offset to sessionStorage (survives reload, same-origin) keyed by pathname
|
|
171
|
-
// (the override only changes the query, so the key is stable), then restore it
|
|
172
|
-
// on the next load — retried for ~1s so it outlasts re-hydration and lazy
|
|
173
|
-
// sections that grow the page after load. The recency guard avoids restoring a
|
|
174
|
-
// stale offset on a genuinely fresh visit.
|
|
175
|
-
var SCROLL_KEY = "__cms_preview_scroll:" + location.pathname;
|
|
176
|
-
var saveScroll = function() {
|
|
177
|
-
try {
|
|
178
|
-
sessionStorage.setItem(SCROLL_KEY, JSON.stringify({
|
|
179
|
-
x: window.scrollX, y: window.scrollY, t: Date.now()
|
|
180
|
-
}));
|
|
181
|
-
} catch (_) {}
|
|
182
|
-
};
|
|
183
|
-
var saveScrollPending = false;
|
|
184
|
-
window.addEventListener("scroll", function() {
|
|
185
|
-
if (saveScrollPending) return;
|
|
186
|
-
saveScrollPending = true;
|
|
187
|
-
requestAnimationFrame(function() { saveScrollPending = false; saveScroll(); });
|
|
188
|
-
}, { passive: true });
|
|
189
|
-
(function restoreScroll() {
|
|
190
|
-
var raw = null;
|
|
191
|
-
try { raw = sessionStorage.getItem(SCROLL_KEY); } catch (_) {}
|
|
192
|
-
if (!raw) return;
|
|
193
|
-
var saved = null;
|
|
194
|
-
try { saved = JSON.parse(raw); } catch (_) { return; }
|
|
195
|
-
if (!saved || (Date.now() - saved.t) > 10000) return;
|
|
196
|
-
if (!saved.x && !saved.y) return;
|
|
197
|
-
var attempts = 0;
|
|
198
|
-
var apply = function() {
|
|
199
|
-
attempts++;
|
|
200
|
-
window.scrollTo(saved.x || 0, saved.y || 0);
|
|
201
|
-
if (attempts < 8) setTimeout(apply, 120);
|
|
202
|
-
};
|
|
203
|
-
apply();
|
|
204
|
-
})();
|
|
205
|
-
|
|
206
|
-
var highlight = document.createElement("div");
|
|
207
|
-
highlight.style.cssText = "position:absolute;pointer-events:none;outline:2px solid #06b6d4;background:rgba(6,182,212,0.06);border-radius:2px;z-index:2147483647;display:none;";
|
|
208
|
-
document.body.appendChild(highlight);
|
|
209
|
-
|
|
210
|
-
var badge = document.createElement("div");
|
|
211
|
-
badge.style.cssText = "position:absolute;pointer-events:none;background:#06b6d4;color:white;font:11px/1 monospace;padding:2px 6px;border-radius:2px;z-index:2147483647;display:none;white-space:nowrap;max-width:240px;overflow:hidden;text-overflow:ellipsis;";
|
|
212
|
-
document.body.appendChild(badge);
|
|
213
|
-
|
|
214
|
-
var isTopLevelSection = function(el) {
|
|
215
|
-
return el && el.parentElement
|
|
216
|
-
? !el.parentElement.closest("section[data-manifest-key]")
|
|
217
|
-
: true;
|
|
218
|
-
};
|
|
219
|
-
|
|
220
|
-
// All top-level page sections in DOM order (deco renders page sections as
|
|
221
|
-
// <section data-manifest-key>; nested islands/sections carry the attribute
|
|
222
|
-
// too, hence the top-level filter). This is the full DOM run, framework
|
|
223
|
-
// sections included — getAllSections() narrows it to the editable window.
|
|
224
|
-
var topLevelSections = function() {
|
|
225
|
-
return Array.from(document.querySelectorAll("section[data-manifest-key]"))
|
|
226
|
-
.filter(isTopLevelSection);
|
|
227
|
-
};
|
|
228
|
-
|
|
229
|
-
// Candidate manifest keys per editable section, sent by the editor. Each
|
|
230
|
-
// entry is an array of acceptable DOM keys: [] = wildcard (e.g. multivariate,
|
|
231
|
-
// whose rendered key we can't predict); null = renders NOTHING (hidden
|
|
232
|
-
// section — multivariate whose variants are all gated by never), so the
|
|
233
|
-
// alignment must not consume a DOM node for it; a Lazy lists both its loader
|
|
234
|
-
// key and the inner section's key, since the classic runtime keeps the Lazy
|
|
235
|
-
// wrapper at top level while TanStack renders the inner section directly.
|
|
236
|
-
var sectionCandidates = [];
|
|
237
|
-
|
|
238
|
-
// Best in-order assignment of editable sections to DOM sections, maximizing
|
|
239
|
-
// key matches (DP / LCS-style). deco injects framework sections (SEO, Theme,
|
|
240
|
-
// Session, …) that may lead, trail, OR interleave with the editable run; this
|
|
241
|
-
// skips whichever don't match, on any runtime — no hardcoded list. Hidden
|
|
242
|
-
// sections (null candidates) have no DOM node: only visible entries are
|
|
243
|
-
// aligned, then scattered back to their decofile positions (null-filled), so
|
|
244
|
-
// returned indexes still match the decofile array.
|
|
245
|
-
var computeAlignment = function(tops) {
|
|
246
|
-
var visible = [], k;
|
|
247
|
-
for (k = 0; k < sectionCandidates.length; k++) {
|
|
248
|
-
if (sectionCandidates[k] !== null) visible.push(k);
|
|
249
|
-
}
|
|
250
|
-
var N = visible.length, M = tops.length;
|
|
251
|
-
var res = new Array(sectionCandidates.length).fill(null);
|
|
252
|
-
if (!N) return res;
|
|
253
|
-
if (M < N) return tops.slice();
|
|
254
|
-
var domKeys = tops.map(function(s) { return s.getAttribute("data-manifest-key"); });
|
|
255
|
-
var match = function(i, j) {
|
|
256
|
-
var c = sectionCandidates[visible[i]];
|
|
257
|
-
if (!c || !c.length) return 1;
|
|
258
|
-
return c.indexOf(domKeys[j]) >= 0 ? 1 : 0;
|
|
259
|
-
};
|
|
260
|
-
var dp = [], bt = [], i, j;
|
|
261
|
-
for (i = 0; i <= N; i++) { dp.push(new Array(M + 1).fill(0)); bt.push(new Array(M + 1).fill(0)); }
|
|
262
|
-
for (i = 1; i <= N; i++) {
|
|
263
|
-
for (j = i; j <= M; j++) {
|
|
264
|
-
var assign = dp[i - 1][j - 1] + match(i - 1, j - 1);
|
|
265
|
-
var skip = dp[i][j - 1];
|
|
266
|
-
if (j - 1 >= i && skip >= assign) { dp[i][j] = skip; bt[i][j] = 0; }
|
|
267
|
-
else { dp[i][j] = assign; bt[i][j] = 1; }
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
i = N; j = M;
|
|
271
|
-
while (i > 0) {
|
|
272
|
-
if (bt[i][j] === 1) { res[visible[i - 1]] = tops[j - 1]; i--; j--; }
|
|
273
|
-
else { j--; }
|
|
274
|
-
}
|
|
275
|
-
return res;
|
|
276
|
-
};
|
|
277
|
-
|
|
278
|
-
// Editable sections, indexed to match the decofile array the panel uses.
|
|
279
|
-
// Recomputed from the live DOM each call (cheap, rAF-throttled) so it
|
|
280
|
-
// self-heals as client-rendered/lazy sections mount. Until the editor sends
|
|
281
|
-
// candidates, fall back to the full top-level run.
|
|
282
|
-
var getAllSections = function() {
|
|
283
|
-
var tops = topLevelSections();
|
|
284
|
-
return sectionCandidates.length ? computeAlignment(tops) : tops;
|
|
285
|
-
};
|
|
286
|
-
|
|
287
|
-
// Resolve to the OUTERMOST page-level section (clicking nested content still
|
|
288
|
-
// maps to the top-level section the panel indexes); null if it isn't in the
|
|
289
|
-
// aligned editable set (a framework section deco injected).
|
|
290
|
-
var findSection = function(el) {
|
|
291
|
-
var node = el;
|
|
292
|
-
var found = null;
|
|
293
|
-
while (node && node !== document.body) {
|
|
294
|
-
if (node.tagName === "SECTION" && node.hasAttribute && node.hasAttribute("data-manifest-key")) {
|
|
295
|
-
found = node;
|
|
296
|
-
}
|
|
297
|
-
node = node.parentElement;
|
|
298
|
-
}
|
|
299
|
-
if (!found) return null;
|
|
300
|
-
return getAllSections().indexOf(found) >= 0 ? found : null;
|
|
301
|
-
};
|
|
302
|
-
|
|
303
|
-
// Lazy sections async-render their real section inside a wrapper, so the
|
|
304
|
-
// wrapper's key is just the loader. Show the inner section's key instead
|
|
305
|
-
// (falling back to the wrapper while the content hasn't loaded yet).
|
|
306
|
-
var LAZY_KEY = "website/sections/Rendering/Lazy.tsx";
|
|
307
|
-
var displayKey = function(section) {
|
|
308
|
-
var key = section.getAttribute("data-manifest-key") || "section";
|
|
309
|
-
if (key === LAZY_KEY) {
|
|
310
|
-
var inner = section.querySelector("section[data-manifest-key]");
|
|
311
|
-
if (inner) return inner.getAttribute("data-manifest-key") || key;
|
|
312
|
-
}
|
|
313
|
-
return key;
|
|
314
|
-
};
|
|
315
|
-
|
|
316
|
-
// Per-section metadata sent by the editor, aligned by index with
|
|
317
|
-
// getAllSections(). labels: names the DOM can't carry (a global section or a
|
|
318
|
-
// global inside async rendering); kinds: section type that drives the color.
|
|
319
|
-
var sectionLabels = [];
|
|
320
|
-
var sectionKinds = [];
|
|
321
|
-
var labelFor = function(section) {
|
|
322
|
-
var idx = getAllSections().indexOf(section);
|
|
323
|
-
if (idx >= 0 && sectionLabels[idx]) return sectionLabels[idx];
|
|
324
|
-
return displayKey(section);
|
|
325
|
-
};
|
|
326
|
-
var kindFor = function(section) {
|
|
327
|
-
var idx = getAllSections().indexOf(section);
|
|
328
|
-
return (idx >= 0 && sectionKinds[idx]) || "normal";
|
|
329
|
-
};
|
|
330
|
-
|
|
331
|
-
// Highlight palette by section kind: global = light purple, variant = green,
|
|
332
|
-
// normal = blue.
|
|
333
|
-
var COLORS = {
|
|
334
|
-
normal: { solid: "#06b6d4", bg: "rgba(6,182,212,0.06)", active: "rgba(6,182,212,0.18)" },
|
|
335
|
-
global: { solid: "#c084fc", bg: "rgba(192,132,252,0.10)", active: "rgba(192,132,252,0.22)" },
|
|
336
|
-
variant: { solid: "#22c55e", bg: "rgba(34,197,94,0.08)", active: "rgba(34,197,94,0.20)" }
|
|
337
|
-
};
|
|
338
|
-
var applyColor = function(kind) {
|
|
339
|
-
var c = COLORS[kind] || COLORS.normal;
|
|
340
|
-
highlight.style.outline = "2px solid " + c.solid;
|
|
341
|
-
highlight.style.background = c.bg;
|
|
342
|
-
badge.style.background = c.solid;
|
|
343
|
-
};
|
|
344
|
-
|
|
345
|
-
var lastSection = null;
|
|
346
|
-
var lastLabel = "";
|
|
347
|
-
var lastKind = "normal";
|
|
348
|
-
var rafPending = false;
|
|
349
|
-
|
|
350
|
-
// Document-relative coordinates (rect + scroll) on absolutely-positioned
|
|
351
|
-
// nodes, so the browser scrolls the highlight together with the page
|
|
352
|
-
// natively — no per-frame JS repositioning, no scroll lag.
|
|
353
|
-
var positionHighlight = function(section) {
|
|
354
|
-
var r = section.getBoundingClientRect();
|
|
355
|
-
var top = r.top + window.scrollY;
|
|
356
|
-
var left = r.left + window.scrollX;
|
|
357
|
-
highlight.style.display = "block";
|
|
358
|
-
highlight.style.top = top + "px";
|
|
359
|
-
highlight.style.left = left + "px";
|
|
360
|
-
highlight.style.width = r.width + "px";
|
|
361
|
-
highlight.style.height = r.height + "px";
|
|
362
|
-
badge.textContent = lastLabel || displayKey(section);
|
|
363
|
-
badge.style.display = "block";
|
|
364
|
-
badge.style.top = Math.max(0, top - 20) + "px";
|
|
365
|
-
badge.style.left = left + "px";
|
|
366
|
-
};
|
|
367
|
-
|
|
368
|
-
var moveHandler = function(e) {
|
|
369
|
-
if (rafPending) return;
|
|
370
|
-
rafPending = true;
|
|
371
|
-
var target = e.target;
|
|
372
|
-
requestAnimationFrame(function() {
|
|
373
|
-
rafPending = false;
|
|
374
|
-
if (!target || target === highlight || target === badge) return;
|
|
375
|
-
var section = findSection(target);
|
|
376
|
-
if (section === lastSection) return;
|
|
377
|
-
lastSection = section;
|
|
378
|
-
if (!section) {
|
|
379
|
-
highlight.style.display = "none";
|
|
380
|
-
badge.style.display = "none";
|
|
381
|
-
return;
|
|
382
|
-
}
|
|
383
|
-
lastLabel = labelFor(section);
|
|
384
|
-
lastKind = kindFor(section);
|
|
385
|
-
applyColor(lastKind);
|
|
386
|
-
positionHighlight(section);
|
|
387
|
-
});
|
|
388
|
-
};
|
|
389
|
-
document.addEventListener("mousemove", moveHandler, true);
|
|
390
|
-
|
|
391
|
-
// Window scroll is handled natively by the absolute positioning above; this
|
|
392
|
-
// only re-syncs on resize and on scrolls inside nested scroll containers
|
|
393
|
-
// (capture=true catches those), where document coordinates do shift.
|
|
394
|
-
var reposition = function() {
|
|
395
|
-
if (!lastSection || highlight.style.display === "none") return;
|
|
396
|
-
if (rafPending) return;
|
|
397
|
-
rafPending = true;
|
|
398
|
-
requestAnimationFrame(function() {
|
|
399
|
-
rafPending = false;
|
|
400
|
-
if (lastSection && highlight.style.display !== "none") positionHighlight(lastSection);
|
|
401
|
-
});
|
|
402
|
-
};
|
|
403
|
-
window.addEventListener("scroll", reposition, { capture: true, passive: true });
|
|
404
|
-
window.addEventListener("resize", reposition, { passive: true });
|
|
405
|
-
|
|
406
|
-
var outHandler = function(e) {
|
|
407
|
-
if (!e.relatedTarget || e.relatedTarget === document.documentElement) {
|
|
408
|
-
highlight.style.display = "none";
|
|
409
|
-
badge.style.display = "none";
|
|
410
|
-
lastSection = null;
|
|
411
|
-
}
|
|
412
|
-
};
|
|
413
|
-
document.addEventListener("mouseout", outHandler, true);
|
|
414
|
-
|
|
415
|
-
var clickHandler = function(e) {
|
|
416
|
-
e.preventDefault();
|
|
417
|
-
e.stopImmediatePropagation();
|
|
418
|
-
var target = e.target;
|
|
419
|
-
if (!target || target === highlight || target === badge) return;
|
|
420
|
-
var section = findSection(target);
|
|
421
|
-
if (!section) return;
|
|
422
|
-
|
|
423
|
-
var sections = getAllSections();
|
|
424
|
-
var sectionIndex = sections.indexOf(section);
|
|
425
|
-
var manifestKey = section.getAttribute("data-manifest-key") || "";
|
|
426
|
-
|
|
427
|
-
var c = COLORS[lastKind] || COLORS.normal;
|
|
428
|
-
highlight.style.outline = "2px solid " + c.solid;
|
|
429
|
-
highlight.style.background = c.active;
|
|
430
|
-
setTimeout(function() {
|
|
431
|
-
highlight.style.background = c.bg;
|
|
432
|
-
}, 400);
|
|
433
|
-
|
|
434
|
-
window.parent.postMessage({
|
|
435
|
-
type: "cms-editor::section-clicked",
|
|
436
|
-
payload: { sectionIndex: sectionIndex, manifestKey: manifestKey }
|
|
437
|
-
}, "*");
|
|
438
|
-
};
|
|
439
|
-
document.addEventListener("click", clickHandler, true);
|
|
440
|
-
|
|
441
|
-
window.addEventListener("message", function(e) {
|
|
442
|
-
if (e.data && e.data.type === "cms-editor::set-labels" && Array.isArray(e.data.labels)) {
|
|
443
|
-
sectionLabels = e.data.labels;
|
|
444
|
-
if (Array.isArray(e.data.kinds)) sectionKinds = e.data.kinds;
|
|
445
|
-
if (Array.isArray(e.data.keys)) sectionCandidates = e.data.keys;
|
|
446
|
-
if (lastSection) {
|
|
447
|
-
lastLabel = labelFor(lastSection);
|
|
448
|
-
lastKind = kindFor(lastSection);
|
|
449
|
-
applyColor(lastKind);
|
|
450
|
-
if (highlight.style.display !== "none") positionHighlight(lastSection);
|
|
451
|
-
}
|
|
452
|
-
return;
|
|
453
|
-
}
|
|
454
|
-
if (e.data && e.data.type === "cms-editor::deactivate") {
|
|
455
|
-
highlight.remove();
|
|
456
|
-
badge.remove();
|
|
457
|
-
document.removeEventListener("mousemove", moveHandler, true);
|
|
458
|
-
document.removeEventListener("mouseout", outHandler, true);
|
|
459
|
-
document.removeEventListener("click", clickHandler, true);
|
|
460
|
-
window.removeEventListener("scroll", reposition, { capture: true });
|
|
461
|
-
window.removeEventListener("resize", reposition);
|
|
462
|
-
window.__cmsEditorActive = false;
|
|
463
|
-
}
|
|
464
|
-
});
|
|
465
|
-
})();`;function xg(t,e){return t.map((s,n)=>{const i=s.__resolveType??"",o=fs(i);if(!o&&i!==""&&_n(i)&&i in e){const d=e[i],h=typeof d?.name=="string"&&d.name||i.replace(/[-_]/g," ").replace(/\b\w/g,u=>u.toUpperCase())||`Section ${n+1}`;return{index:n,resolveType:i,label:h,isLazy:!1,isSavedBlock:!0}}const a=o?s.section:void 0,l=o?a?.__resolveType??"":i;if(l===Ki||l===Dr){const d=o?a:s,h=Array.isArray(d?.variants)?d.variants:[];if(h.length===1&&(h[0]?.rule?.__resolveType??"")===Rr){const m=h[0]?.value??{};let p=m.__resolveType??"";const g=fs(p);return g&&(p=m.section?.__resolveType??p),{index:n,resolveType:i,label:Tt(p)||`Section ${n+1}`,isHidden:!0,isLazy:g}}const u=h[0]?.value?.__resolveType,f=u?Tt(u):"Section";return{index:n,resolveType:i,label:`Variants of ${f}`,isMultivariate:!0,isLazy:o}}const c=o?s.section?.__resolveType??i:i;if(o&&c!==""&&_n(c)&&c in e){const d=e[c],h=typeof d?.name=="string"&&d.name||c.replace(/[-_]/g," ").replace(/\b\w/g,u=>u.toUpperCase())||`Section ${n+1}`;return{index:n,resolveType:i,label:h,isLazy:!0,isSavedBlock:!0}}return{index:n,resolveType:i,label:Tt(c)||`Section ${n+1}`,isLazy:o}})}const uA="website/sections/Rendering/Lazy.tsx";function Yd(t,e){let s=t,n=typeof s?.__resolveType=="string"?s.__resolveType:"";for(let i=0;n&&i<5;i++){const o=e[n];if(o&&typeof o=="object"&&"__resolveType"in o){const a=o.__resolveType;if(typeof a=="string"&&a&&a!==n){s=o,n=a;continue}}break}if(!n)return[];if(n.includes("flags/multivariate")){const i=Array.isArray(s.variants)?s.variants:[];if(i.length===0||i.every(l=>l?.rule?.__resolveType===Rr))return null;const a=[];for(const l of i){const c=l?.value;if(c&&typeof c=="object")for(const d of Yd(c,e)??[])a.includes(d)||a.push(d)}return a}if(n===uA){const i=s.section&&typeof s.section=="object"?Yd(s.section,e):[];return i===null?null:i.length?[n,...i]:[n]}return[n]}function vg(t){const e=t.__resolveType??"";return fs(e)?t.section??t:t}function Al(t){const i=(fs(t.__resolveType??"")?t.section:t)?.variants?.[0];return i?.rule?.__resolveType!==Rr?null:i?.value??null}function NH(t){const e=vg(t);return{__resolveType:Dr,variants:[{value:e,rule:{__resolveType:Rr}}]}}function TH(t){const e=t.__resolveType??"";if(!e)return null;if(fs(e))return t.section??null;const s=Al(t);return s?fs(s.__resolveType??"")?s:{__resolveType:Nh,section:vg(s)}:{__resolveType:Nh,section:t}}function ja(t){const e=t.__resolveType??"";if(!e)return null;if(fs(e)){const s=t.section,n=s?.__resolveType??"";return!n||!s?null:{resolveType:n,data:s}}return{resolveType:e,data:t}}function AH(t){const e=Al(t);if(e)return ja(e);if(fs(t.__resolveType??"")){const n=t.section;if(!n)return null;const i=Al(n);return ja(i||n)}return ja(t)}function EH(t){return Al(t)}const hA=["website/matchers/always.ts","$live/matchers/MatchAlways.ts"];function cu(t){if(!t)return!1;const e=t.__resolveType??"";return e===""?Object.keys(t).length===0:hA.includes(e)||e.includes("always")}function fA(t){const e=t.variants??[];if(e.length===0)return-1;const s=e.findIndex(n=>cu(n.rule));return s!==-1?s:e.length-1}function PH(t,e,s){const n=s.variants??[];if(n.length===0)return null;const i=fA(s),o=n[i]?.value;if(!o)return null;const a=structuredClone(o);return e.isLazy?{...t,section:a}:a}function bg(t,e){return e.isMultivariate?e.isLazy?t.section??null:t:null}function RH(t,e){return Array.isArray(t.variants)?t.variants.map((s,n)=>({label:e(s.rule)||`Variant ${n+1}`,value:s.value??{},rule:s.rule})):[]}function DH(t,e){const s=t.__resolveType??"";if(!s)return null;if(fs(s)){const n=t.section??t,i=n.__resolveType??s;if(!i.includes("/")&&i in e){const o=e[i]??{};return{data:{...o},resolveType:o.__resolveType??i}}return{data:{...n},resolveType:i}}if(!s.includes("/")&&s in e){const n=e[s]??{};return{data:{...n},resolveType:n.__resolveType??s}}return{data:{...t},resolveType:s}}function mA(t,e){const s=t.__resolveType??"";return fs(s)?{...t,section:e}:e}function pA(t,e,s){return e.isLazy?{...t,section:s}:s}function IH(t,e,s){const n=[...t.variants??[]],i=n[e];if(!i)return t;const o=i.value??{};return n[e]={...i,value:mA(o,s)},{...t,variants:n}}function MH(t,e,s){const n=[...t.variants??[]];return n[e]?(n[e]={...n[e],rule:s},{...t,variants:n}):t}function OH(t,e){const s=[...t.variants??[]],n=s[e];return n?(s.splice(e+1,0,structuredClone(n)),{...t,variants:s}):t}function BH(t,e,s){const n=[...t.variants??[]];if(e===s||e<0||s<0||e>=n.length||s>=n.length)return t;const[i]=n.splice(e,1);return i?(n.splice(s,0,i),{...t,variants:n}):t}function $H(t,e){const s=[...t.variants??[]];return s.length<=1?null:(s.splice(e,1),{...t,variants:s})}function Jd(t){return{rule:br(),value:structuredClone(t)}}function _g(t,e){return{...e,__resolveType:Dr,variants:t}}function FH(t){return t.isHidden!==!0&&t.isSavedBlock!==!0}function gA(t,e){if(e.isHidden)return null;if(e.isMultivariate){const n=bg(t,e)?.variants??[],i=n[n.length-1]?.value;return i?structuredClone(i):null}if(e.isLazy){const s=t.section;return s?structuredClone(s):null}return structuredClone(t)}function xA(t,e,s){if(e.isMultivariate||e.isHidden)return null;const n=gA(t,e);if(!n)return null;const i=_g([Jd(n),Jd(n)]);return e.isLazy?{...t,section:i}:i}function zH(t,e,s){if(e.isHidden||e.isSavedBlock)return null;if(e.isMultivariate){const i=bg(t,e);if(!i)return null;const o=i.variants??[],a=o[o.length-1]?.value;if(!a)return null;const l=_g([...o,Jd(a)],i);return{section:pA(t,e,l),newVariantIndex:o.length}}const n=xA(t,e);return n?{section:n,newVariantIndex:1}:null}const vA=new Set(["website/pages/Page.tsx","$live/pages/LivePage.tsx"]);function Lc(t){return t.anyOfRefs?.some(e=>e.resolveType!==Ki?!1:e.schema?.properties?.variants?.items?.properties?.value?.type==="array")??!1}function bA(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;const e=t;return e.__resolveType===Dr&&Array.isArray(e.variants)}function El(t){return!t||typeof t!="object"||Array.isArray(t)?!1:t.__resolveType===Ki}function _A(t){if(!El(t))return null;const e=t.variants;if(!Array.isArray(e))return null;const s=e[0]?.value;return Array.isArray(s)?s:null}function yA(t,e){if(!El(t))return e;const s=structuredClone(t),n=[...s.variants??[]];return n.length===0?n.push({rule:br(),value:e}):n[0]={...n[0],value:e},{...s,variants:n}}function LA(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;const e=t;return typeof e.__resolveType=="string"&&vA.has(e.__resolveType)&&typeof e.path=="string"}function yg(t,e){const n=t[e]?.sections;if(!n||Array.isArray(n))return 1;const i=n;return Array.isArray(i.variants)?i.variants.length:1}function Lg(t,e,s){const i=t[e]?.sections;if(Array.isArray(i))return s===0?i:[];if(i&&typeof i=="object"){const o=i.variants;if(Array.isArray(o)){const a=o[s];return Array.isArray(a?.value)?a.value:[]}}return[]}function KH(t,e,s){if(Array.isArray(t))return[{label:"Default",sections:t}];if(t&&typeof t=="object"){const n=t;if(Array.isArray(n.variants)){const i=n.variants,o=i.map(c=>QT(c.rule,e,s)),a=o.reduce((c,d)=>(c[d]=(c[d]??0)+1,c),{}),l={};return i.map((c,d)=>{const h=o[d]??`Variant ${d+1}`,u=a[h]??1;let f=h;return u>1&&(l[h]=(l[h]??0)+1,f=`${h} ${l[h]}`),{label:f||`Variant ${d+1}`,sections:Array.isArray(c.value)?c.value:[],rule:c.rule}})}}return[]}function Wr(t){return{rule:br(),value:t}}function cr(t,e){return{...e,__resolveType:Ki,variants:t}}function SA(t,e){const s=structuredClone(e);if(Array.isArray(t))return cr([Wr(t),Wr(s)]);if(t&&typeof t=="object"){const n=t;return Array.isArray(n.variants)?cr([...n.variants,Wr(s)],n):null}return cr([Wr([]),Wr(s)])}function UH(t){const e=t.variants;return Array.isArray(e)?e.length-1:1}function HH(t,e){const s=t[e];if(!s)return null;const n=[...t];return n.splice(e+1,0,structuredClone(s)),n}function WH(t,e){if(e.length===0)return cr([],t);if(e.length===1){const s=e[0],n=s?.rule;if(!cu(n))return cr(e,t);if(Array.isArray(s?.value))return s.value}return cr(e,t)}function wA(t,e){for(const[s,n]of Object.entries(t)){if(!LA(n))continue;const i=n.sections;if(Array.isArray(i)){e(void 0,s,0);continue}if(!i||typeof i!="object")continue;const o=i.variants;if(Array.isArray(o))for(let a=0;a<o.length;a++){const l=o[a];e(l?.rule,s,a)}}}function qH(t,e,s){let n=0;return wA(t,i=>{if(!i)return;(i.__resolveType??"")===e&&Fr(i,t,s)&&n++}),n}function Yi(t){return t.replace(/[`*_]/g,"\\$&")}function jA(t,e){const s=[`The user selected an element on the live preview and asked: **"${Yi(e.trim())}"**`,"","For text content changes, locate the correct source file and apply the change.","For code and CSS changes, understand which component the user is referring to and apply changes to the correct component.",""];t.manifestKey&&s.push(`**Section resolveType:** \`${Yi(t.manifestKey)}\``,"","This is a Deco resolveType, not a literal file path. The leading segment is the app name, not a directory — the actual source file lives under a sections directory whose root varies by site (commonly `sections/`, `src/sections/`, or `site/sections/`). Locate the file by searching for the trailing path (e.g. the component filename), don't assume the resolveType is a valid path on disk.","");const n=`<${t.tag}${t.classes?` class="${Yi(t.classes)}"`:""}>`;s.push(`**Clicked element:** \`${n}\``),t.parents&&s.push(`**DOM breadcrumb:** ${Yi(t.parents)} > ${t.tag}`),t.text&&s.push(`**Text content:** "${Yi(t.text)}"`),t.componentName&&s.push(`**Component name:** ${Yi(t.componentName)}`);const i=t.html.replace(/```/g,"`` `");return s.push("","**HTML snippet:**","```html",i,"```"),s.push("","Please read the source file, locate the element, and apply the requested change."),s.join(`
|
|
466
|
-
`)}function CA(t,e,s=320,n=44,i=12){const{x:o,y:a}=t,{width:l,height:c}=e,d=Math.max(i,Math.min(o-s/2,l-s-i)),u=a/c>.68?Math.max(i,a-n-18):Math.min(a+18,c-n-i);return{leftPct:d/l*100,topPct:u/c*100}}function kA(t){const e=F.c(45),{element:s,onDismiss:n}=t,[i,o]=A.useState(""),a=A.useRef(null),{sendMessage:l}=Js(),{openSidePanel:c}=Qo(),d=re();let h;e[0]!==s||e[1]!==i||e[2]!==n||e[3]!==c||e[4]!==l?(h=()=>{if(!i.trim())return;const P=jA(s,i);c("chat"),l({parts:[{type:"text",text:P}]}),n()},e[0]=s,e[1]=i,e[2]=n,e[3]=c,e[4]=l,e[5]=h):h=e[5];const u=h;let f;e[6]!==s.position||e[7]!==s.viewport?(f=CA(s.position,s.viewport),e[6]=s.position,e[7]=s.viewport,e[8]=f):f=e[8];const m=f,p=`${m.leftPct}%`,g=`${m.topPct}%`;let x;e[9]!==p||e[10]!==g?(x={left:p,top:g,width:"320px"},e[9]=p,e[10]=g,e[11]=x):x=e[11];let v;e[12]!==u?(v=P=>{P.preventDefault(),u()},e[12]=u,e[13]=v):v=e[13];let b;e[14]===Symbol.for("react.memo_cache_sentinel")?(b=P=>o(P.target.value),e[14]=b):b=e[14];let y;e[15]!==n?(y=P=>{P.key==="Escape"&&n()},e[15]=n,e[16]=y):y=e[16];let _;e[17]!==d?(_=d("sandbox.visualEditorPrompt.inputPlaceholder"),e[17]=d,e[18]=_):_=e[18];let L;e[19]!==i||e[20]!==y||e[21]!==_?(L=r.jsx("input",{ref:a,autoFocus:!0,type:"text",value:i,onChange:b,onKeyDown:y,placeholder:_,className:"min-w-0 flex-1 bg-transparent text-sm outline-none placeholder:text-muted-foreground"}),e[19]=i,e[20]=y,e[21]=_,e[22]=L):L=e[22];let w;e[23]!==i?(w=i.trim(),e[23]=i,e[24]=w):w=e[24];const j=!w;let S;e[25]!==d?(S=d("sandbox.visualEditorPrompt.sendButton"),e[25]=d,e[26]=S):S=e[26];let C;e[27]!==d?(C=d("sandbox.visualEditorPrompt.sendButton"),e[27]=d,e[28]=C):C=e[28];let N;e[29]!==C?(N=r.jsx("title",{children:C}),e[29]=C,e[30]=N):N=e[30];let V;e[31]===Symbol.for("react.memo_cache_sentinel")?(V=r.jsx("path",{d:"M5 9V1M1 5l4-4 4 4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),e[31]=V):V=e[31];let E;e[32]!==N?(E=r.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none","aria-hidden":"true",children:[N,V]}),e[32]=N,e[33]=E):E=e[33];let T;e[34]!==j||e[35]!==S||e[36]!==E?(T=r.jsx("button",{type:"submit",disabled:j,className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-foreground text-background transition-opacity disabled:opacity-30",title:S,children:E}),e[34]=j,e[35]=S,e[36]=E,e[37]=T):T=e[37];let k;e[38]!==L||e[39]!==T||e[40]!==v?(k=r.jsxs("form",{className:"pointer-events-auto flex w-full items-center gap-1.5 rounded-xl border border-border bg-background/95 px-3 py-1.5 shadow-lg backdrop-blur",onSubmit:v,children:[L,T]}),e[38]=L,e[39]=T,e[40]=v,e[41]=k):k=e[41];let R;return e[42]!==k||e[43]!==x?(R=r.jsx("div",{className:"absolute z-30 pointer-events-none",style:x,children:k}),e[42]=k,e[43]=x,e[44]=R):R=e[44],R}const Sg={claiming:{long:"Reserving sandbox",short:"Reserving sandbox"},"waiting-for-capacity":{long:"Waiting for cluster capacity",short:"Waiting for capacity"},"pulling-image":{long:"Downloading sandbox image",short:"Downloading image"},"starting-container":{long:"Starting your sandbox",short:"Starting container"},"warming-daemon":{long:"Connecting to your sandbox",short:"Connecting to sandbox"}},VA=["provision","cloning","install","dev"];function wg(t){switch(t.lifecycle.phase){case"cloning":case"checking-out":return{step:"cloning",status:"doing"};case"clone-failed":return{step:"cloning",status:"failed"};case"installing":return{step:"install",status:"doing"};case"install-failed":return{step:"install",status:"failed"};case"starting":return{step:"dev",status:"doing"};case"running":return{step:"dev",status:"done"};case"start-failed":return{step:"dev",status:"failed"};case"crashed":return{step:"dev",status:"failed"};case"idle":return t.claimPhase&&t.claimPhase.kind!=="ready"&&t.claimPhase.kind!=="failed"?{step:"provision",status:"doing"}:{step:"cloning",status:"doing"}}}function ff(t){switch(t){case"starting":return"Starting your sandbox";case"suspended":return"Sandbox is paused";case"errored":return"Couldn't start the sandbox"}}function NA(t){return VA.indexOf(t.step)}const mf=48,jg=28,Cg=3,TA=(()=>{const t=[];let e=0;for(let s=0;s<mf;s++)s===jg?t.push(null):(t.push(e/(mf-1)*Cg),e++);return t})(),AA={provision:"Reserving sandbox",cloning:"Cloning your repo",install:"Installing packages",dev:"Starting your preview"};function EA(t,e){return t.step==="provision"&&e!=null&&e.kind!=="ready"&&e.kind!=="failed"?Sg[e.kind].long:AA[t.step]}const fn="bg-foreground/[0.05]",Ws="bg-foreground/[0.09]",PA=Array.from({length:35},()=>Math.random()*1.8),RA=Array.from({length:35},()=>Math.random()<.4);function DA(t){const e=F.c(30),{progress:s,claimPhase:n}=t;let i;e[0]!==s?(i=NA(s),e[0]=s,e[1]=i):i=e[1];const o=i;let a;e[2]!==n||e[3]!==s?(a=EA(s,n),e[2]=n,e[3]=s,e[4]=a):a=e[4];const l=a;let c;e[5]===Symbol.for("react.memo_cache_sentinel")?(c=r.jsx(Px,{}),e[5]=c):c=e[5];const d=`${s.step}-${l}`;let h;e[6]!==l||e[7]!==d?(h=r.jsxs("div",{className:"flex items-center gap-2 rounded-full border border-foreground/10 bg-background px-3.5 py-1.5 shadow-[0_4px_20px_-4px_rgb(0_0_0_/_0.12)]",children:[c,r.jsxs("span",{className:"animate-in fade-in text-[13px] font-medium text-foreground/85 duration-500",children:[l,"…"]},d)]}),e[6]=l,e[7]=d,e[8]=h):h=e[8];let u;e[9]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx(IA,{}),e[9]=u):u=e[9];let f;e[10]!==o?(f=r.jsx(Ca,{phase:0,current:o,children:u}),e[10]=o,e[11]=f):f=e[11];let m;e[12]===Symbol.for("react.memo_cache_sentinel")?(m=r.jsx(OA,{}),e[12]=m):m=e[12];let p;e[13]!==o?(p=r.jsx(Ca,{phase:1,current:o,children:m}),e[13]=o,e[14]=p):p=e[14];let g;e[15]===Symbol.for("react.memo_cache_sentinel")?(g=r.jsx(BA,{}),e[15]=g):g=e[15];let x;e[16]!==o?(x=r.jsx(Ca,{phase:2,current:o,children:g}),e[16]=o,e[17]=x):x=e[17];let v;e[18]===Symbol.for("react.memo_cache_sentinel")?(v=r.jsx(FA,{}),e[18]=v):v=e[18];let b;e[19]!==o?(b=r.jsx(Ca,{phase:3,current:o,children:v}),e[19]=o,e[20]=b):b=e[20];let y;e[21]!==x||e[22]!==b||e[23]!==f||e[24]!==p?(y=r.jsxs("div",{className:"relative aspect-[4/3] w-[min(78%,560px)]",children:[f,p,x,b]}),e[21]=x,e[22]=b,e[23]=f,e[24]=p,e[25]=y):y=e[25];let _;e[26]===Symbol.for("react.memo_cache_sentinel")?(_=r.jsx("style",{children:`
|
|
467
|
-
@keyframes vm-pulse-soft {
|
|
468
|
-
0%, 100% { opacity: 0.25; }
|
|
469
|
-
50% { opacity: 1; }
|
|
470
|
-
}
|
|
471
|
-
@keyframes vm-breathe {
|
|
472
|
-
0%, 100% { opacity: 0.5; }
|
|
473
|
-
50% { opacity: 1; }
|
|
474
|
-
}
|
|
475
|
-
@keyframes vm-rack-scan {
|
|
476
|
-
0%, 100% { opacity: 0; }
|
|
477
|
-
8% { opacity: 1; }
|
|
478
|
-
22% { opacity: 0; }
|
|
479
|
-
}
|
|
480
|
-
`}),e[26]=_):_=e[26];let L;return e[27]!==y||e[28]!==h?(L=r.jsxs("div",{className:"relative flex w-full flex-col items-center justify-center gap-12 select-none [clip-path:inset(-24px_0_-200px_0)]",children:[h,y,_]}),e[27]=y,e[28]=h,e[29]=L):L=e[29],L}function Ca(t){const e=F.c(10),{phase:s,current:n,children:i}=t,o=s-n,a=o<0,l=o===0,c=a?90:o*-22,d=a?.94:1-Math.max(o,0)*.04,h=a?0:l?1:o===1?.8:.55,u=a?10:30-o,f=!l;let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m=ie("absolute inset-0 overflow-hidden rounded-xl border border-foreground/10 bg-background shadow-[0_20px_60px_-20px_rgb(0_0_0_/_0.35)] transition-all ease-[cubic-bezier(0.22,1,0.36,1)]"),e[0]=m):m=e[0];const p=`translateY(${c}px) scale(${d})`,g=l?"auto":"none";let x;e[1]!==h||e[2]!==p||e[3]!==g||e[4]!==u?(x={transform:p,opacity:h,zIndex:u,transitionDuration:"1000ms",pointerEvents:g},e[1]=h,e[2]=p,e[3]=g,e[4]=u,e[5]=x):x=e[5];let v;return e[6]!==i||e[7]!==f||e[8]!==x?(v=r.jsx("div",{"aria-hidden":f,className:m,style:x,children:i}),e[6]=i,e[7]=f,e[8]=x,e[9]=v):v=e[9],v}function Sc(t){const e=F.c(7),{showUrl:s}=t,n=s===void 0?!1:s;let i,o,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx("div",{className:ie("size-2.5 rounded-full",Ws)}),o=r.jsx("div",{className:ie("size-2.5 rounded-full",Ws)}),a=r.jsx("div",{className:ie("size-2.5 rounded-full",Ws)}),e[0]=i,e[1]=o,e[2]=a):(i=e[0],o=e[1],a=e[2]);let l;e[3]!==n?(l=n&&r.jsx("div",{className:ie("ml-3 h-3.5 max-w-[220px] flex-1 rounded-sm",fn)}),e[3]=n,e[4]=l):l=e[4];let c;return e[5]!==l?(c=r.jsxs("div",{className:"flex h-7 shrink-0 items-center gap-1.5 px-3",children:[i,o,a,l]}),e[5]=l,e[6]=c):c=e[6],c}function IA(){const t=F.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx(Sc,{}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsxs("div",{className:"flex h-full flex-col",children:[e,r.jsx("div",{className:"flex flex-1 px-8 py-5",children:r.jsx("div",{className:"grid h-full w-full grid-cols-8 grid-rows-6 gap-2",children:TA.map(MA)})})]}),t[1]=s):s=t[1],s}function MA(t,e){if(e===jg)return r.jsx("div",{className:"rounded-md bg-chart-1/[0.55]",style:{animation:"vm-breathe 2.4s ease-in-out infinite"}},e);const s=t;return r.jsx("div",{className:ie("relative rounded-md",Ws),children:r.jsx("div",{className:"absolute inset-0 rounded-md bg-chart-1/40 opacity-0",style:{animation:`vm-rack-scan ${Cg}s ease-in-out infinite`,animationDelay:`${s}s`}})},e)}function OA(){const t=F.c(5);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx(Sc,{}),t[0]=e):e=t[0];let s;t[1]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx("div",{className:ie("w-[18%] rounded-md",fn),style:{animation:"vm-breathe 3s ease-in-out infinite"}}),t[1]=s):s=t[1];let n;t[2]===Symbol.for("react.memo_cache_sentinel")?(n=r.jsx("div",{className:"h-[42%] shrink-0 rounded-md bg-chart-3/[0.12]",style:{animation:"vm-breathe 3s ease-in-out 0.4s infinite"}}),t[2]=n):n=t[2];let i;t[3]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx("div",{className:"col-span-3 rounded-md bg-chart-3/[0.12]",style:{animation:"vm-breathe 3s ease-in-out 0.8s infinite"}}),t[3]=i):i=t[3];let o;return t[4]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsxs("div",{className:"flex h-full flex-col",children:[e,r.jsxs("div",{className:"flex min-h-0 flex-1 gap-1.5 p-3",children:[s,r.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-1.5",children:[n,r.jsxs("div",{className:"grid min-h-0 flex-1 grid-cols-5 gap-1.5",children:[i,r.jsxs("div",{className:"col-span-2 grid grid-rows-2 gap-1.5",children:[r.jsx("div",{className:ie("rounded-md",fn),style:{animation:"vm-breathe 3s ease-in-out 1.2s infinite"}}),r.jsx("div",{className:ie("rounded-md",fn),style:{animation:"vm-breathe 3s ease-in-out 1.6s infinite"}})]})]})]})]})]}),t[4]=o):o=t[4],o}function BA(){const t=F.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx(Sc,{}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsxs("div",{className:"flex h-full flex-col",children:[e,r.jsx("div",{className:"relative flex flex-1 items-center justify-center px-8 py-5",children:r.jsx("div",{className:"grid w-full gap-2",style:{gridTemplateColumns:"repeat(7, minmax(0, 1fr))"},children:PA.map($A)})})]}),t[1]=s):s=t[1],s}function $A(t,e){return r.jsx("div",{className:ie("aspect-square rounded-md",RA[e]?"bg-chart-2/70":Ws),style:{animation:`vm-pulse-soft 2.2s ease-in-out ${t}s infinite`}},e)}function FA(){const t=F.c(11);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx(Sc,{showUrl:!0}),t[0]=e):e=t[0];let s,n,i,o,a;t[1]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx("div",{className:"mb-2 h-5 rounded-md bg-chart-1/[0.10]"}),n=r.jsx("div",{className:ie("h-1.5 w-[70%] rounded-sm",Ws)}),i=r.jsx("div",{className:ie("h-1.5 w-[55%] rounded-sm",Ws)}),o=r.jsx("div",{className:ie("h-1.5 w-[80%] rounded-sm",Ws)}),a=r.jsx("div",{className:ie("h-1.5 w-[50%] rounded-sm",Ws)}),t[1]=s,t[2]=n,t[3]=i,t[4]=o,t[5]=a):(s=t[1],n=t[2],i=t[3],o=t[4],a=t[5]);let l;t[6]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsxs("div",{className:"flex w-[18%] shrink-0 flex-col gap-1.5 bg-chart-1/[0.05] p-2.5",children:[s,n,i,o,a,r.jsx("div",{className:"mt-auto",children:r.jsx("div",{className:ie("h-4 rounded-md",Ws)})})]}),t[6]=l):l=t[6];let c;t[7]===Symbol.for("react.memo_cache_sentinel")?(c=r.jsx("div",{className:"relative h-[42%] shrink-0 overflow-hidden bg-chart-1/[0.10]",children:r.jsxs("div",{className:"absolute right-3 bottom-3 left-3 space-y-1.5",children:[r.jsx("div",{className:"h-3 w-[35%] rounded-sm bg-chart-1/[0.15]"}),r.jsx("div",{className:ie("h-1.5 w-[55%] rounded-sm",fn)})]})}),t[7]=c):c=t[7];let d;t[8]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsxs("div",{className:"flex shrink-0 gap-1.5",children:[r.jsx("div",{className:"h-4 w-12 rounded-full bg-chart-1/[0.12]"}),r.jsx("div",{className:ie("h-4 w-10 rounded-full",fn)}),r.jsx("div",{className:ie("h-4 w-14 rounded-full",fn)})]}),t[8]=d):d=t[8];let h;t[9]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsxs("div",{className:ie("col-span-3 flex flex-col justify-end gap-1 rounded-md p-2",fn),children:[r.jsx("div",{className:ie("h-1.5 w-[50%] rounded-sm",Ws)}),r.jsx("div",{className:ie("h-1 w-[75%] rounded-sm",Ws)})]}),t[9]=h):h=t[9];let u;return t[10]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsxs("div",{className:"flex h-full flex-col",children:[e,r.jsxs("div",{className:"flex min-h-0 flex-1",children:[l,r.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[c,r.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-2.5 p-3",children:[d,r.jsxs("div",{className:"grid min-h-0 flex-1 grid-cols-5 gap-2",children:[h,r.jsxs("div",{className:"col-span-2 grid grid-rows-2 gap-2",children:[r.jsx("div",{className:ie("rounded-md",fn)}),r.jsx("div",{className:ie("rounded-md",fn)})]})]})]})]})]})]}),t[10]=u):u=t[10],u}function gi(t){const e=F.c(71),s=re();if(t.kind==="othersThread"){let f;e[0]===Symbol.for("react.memo_cache_sentinel")?(f=r.jsx(ec,{className:"size-12 text-muted-foreground"}),e[0]=f):f=e[0];let m;e[1]!==s?(m=s("sandbox.stateCard.othersThreadTitle"),e[1]=s,e[2]=m):m=e[2];let p;e[3]!==m?(p=r.jsx("h3",{className:"text-lg font-medium",children:m}),e[3]=m,e[4]=p):p=e[4];let g;e[5]!==t.label||e[6]!==s?(g=s("sandbox.stateCard.othersThreadMessage",{label:t.label}),e[5]=t.label,e[6]=s,e[7]=g):g=e[7];let x;e[8]!==g?(x=r.jsx("p",{className:"max-w-sm text-sm text-muted-foreground",children:g}),e[8]=g,e[9]=x):x=e[9];const v=t.onContinue;let b;e[10]===Symbol.for("react.memo_cache_sentinel")?(b=r.jsx(u9,{className:"size-4"}),e[10]=b):b=e[10];let y;e[11]!==s?(y=s("sandbox.stateCard.othersThreadContinue"),e[11]=s,e[12]=y):y=e[12];let _;e[13]!==t.onContinue||e[14]!==y?(_=r.jsxs(le,{variant:"outline",onClick:v,children:[b," ",y]}),e[13]=t.onContinue,e[14]=y,e[15]=_):_=e[15];const L=t.onStartNewThread;let w;e[16]===Symbol.for("react.memo_cache_sentinel")?(w=r.jsx(kt,{className:"size-4"}),e[16]=w):w=e[16];let j;e[17]!==s?(j=s("sandbox.stateCard.othersThreadNewChat"),e[17]=s,e[18]=j):j=e[18];let S;e[19]!==t.onStartNewThread||e[20]!==j?(S=r.jsxs(le,{onClick:L,children:[w," ",j]}),e[19]=t.onStartNewThread,e[20]=j,e[21]=S):S=e[21];let C;e[22]!==S||e[23]!==_?(C=r.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[_,S]}),e[22]=S,e[23]=_,e[24]=C):C=e[24];let N;return e[25]!==C||e[26]!==p||e[27]!==x?(N=r.jsx("div",{className:"flex h-full w-full items-center justify-center bg-background p-6",children:r.jsxs("div",{className:"flex w-full max-w-md flex-col items-center gap-4 text-center",children:[f,p,x,C]})}),e[25]=C,e[26]=p,e[27]=x,e[28]=N):N=e[28],N}if(t.kind==="starting"){let f;return e[29]!==t.claimPhase||e[30]!==t.progress?(f=r.jsx("div",{className:"flex h-full w-full items-center justify-center bg-background p-6",children:r.jsx(DA,{progress:t.progress,claimPhase:t.claimPhase})}),e[29]=t.claimPhase,e[30]=t.progress,e[31]=f):f=e[31],f}if(t.kind==="errored"){const f=t.error.code===ep.githubNotAuthenticated;let m;e[32]===Symbol.for("react.memo_cache_sentinel")?(m=r.jsx(Sr,{className:"size-12 text-destructive"}),e[32]=m):m=e[32];let p;e[33]===Symbol.for("react.memo_cache_sentinel")?(p=r.jsx("h3",{className:"text-lg font-medium",children:ff("errored")}),e[33]=p):p=e[33];let g;e[34]!==f||e[35]!==t.error.message||e[36]!==s?(g=f?s("sandbox.stateCard.githubNotAuthenticatedMessage"):t.error.message,e[34]=f,e[35]=t.error.message,e[36]=s,e[37]=g):g=e[37];let x;e[38]!==g?(x=r.jsx("p",{className:"max-w-sm text-sm text-muted-foreground",children:g}),e[38]=g,e[39]=x):x=e[39];let v;e[40]!==f||e[41]!==t.connectionsHref||e[42]!==s?(v=f&&t.connectionsHref&&r.jsx(le,{asChild:!0,children:r.jsx("a",{href:t.connectionsHref,children:s("sandbox.stateCard.reconnectGithub")})}),e[40]=f,e[41]=t.connectionsHref,e[42]=s,e[43]=v):v=e[43];const b=t.onRetry;let y;e[44]===Symbol.for("react.memo_cache_sentinel")?(y=r.jsx(dr,{className:"size-4"}),e[44]=y):y=e[44];let _;e[45]!==s?(_=s("sandbox.stateCard.retry"),e[45]=s,e[46]=_):_=e[46];let L;e[47]!==t.onRetry||e[48]!==_?(L=r.jsxs(le,{variant:"outline",onClick:b,children:[y," ",_]}),e[47]=t.onRetry,e[48]=_,e[49]=L):L=e[49];let w;e[50]!==v||e[51]!==L?(w=r.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[v,L]}),e[50]=v,e[51]=L,e[52]=w):w=e[52];let j;return e[53]!==x||e[54]!==w?(j=r.jsx("div",{className:"flex h-full w-full items-center justify-center bg-background p-6",children:r.jsxs("div",{className:"flex w-full max-w-md flex-col items-center gap-4 text-center",children:[m,p,x,w]})}),e[53]=x,e[54]=w,e[55]=j):j=e[55],j}let n;e[56]===Symbol.for("react.memo_cache_sentinel")?(n=r.jsx(Kv,{className:"size-12 text-blue-500"}),e[56]=n):n=e[56];let i;e[57]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx("h3",{className:"text-lg font-medium",children:ff("suspended")}),e[57]=i):i=e[57];let o;e[58]!==s?(o=s("sandbox.stateCard.resumeToContinue"),e[58]=s,e[59]=o):o=e[59];let a;e[60]!==o?(a=r.jsx("p",{className:"max-w-sm text-sm text-muted-foreground",children:o}),e[60]=o,e[61]=a):a=e[61];const l=t.onResume;let c;e[62]===Symbol.for("react.memo_cache_sentinel")?(c=r.jsx(Vi,{className:"size-4"}),e[62]=c):c=e[62];let d;e[63]!==s?(d=s("sandbox.stateCard.resume"),e[63]=s,e[64]=d):d=e[64];let h;e[65]!==t.onResume||e[66]!==d?(h=r.jsxs(le,{onClick:l,className:"mt-2",children:[c," ",d]}),e[65]=t.onResume,e[66]=d,e[67]=h):h=e[67];let u;return e[68]!==a||e[69]!==h?(u=r.jsx("div",{className:"flex h-full w-full items-center justify-center bg-background p-6",children:r.jsxs("div",{className:"flex w-full max-w-md flex-col items-center gap-4 text-center",children:[n,i,a,h]})}),e[68]=a,e[69]=h,e[70]=u):u=e[70],u}function kg(t,e,s){return`deco:preview:last-page:${t}:${e}:${s}`}function zA(t){if(!t)return null;try{const e=JSON.parse(t);if(!e||typeof e!="object"||Array.isArray(e)||typeof e.path!="string"||!e.path.startsWith("/"))return null;const s=typeof e.pageKey=="string"?e.pageKey:null,n={};if(e.params&&typeof e.params=="object")for(const[i,o]of Object.entries(e.params))typeof o=="string"&&(n[i]=o);return{path:e.path,pageKey:s,params:n}}catch{return null}}function Vg(t){try{return zA(localStorage.getItem(t))}catch{return null}}function KA(t,e){try{localStorage.setItem(t,JSON.stringify(e))}catch{}}function Pl(t,e){const n=e.replace(/\\/g,"/").replace(/^(?!\/)/,"/").split("/").map(i=>encodeURIComponent(i).replace(/%3A/gi,":")).join("/");return`${t}://file${n}?windowId=_blank`}const UA=/details?page|\bpdp\b/i,HA=/listingpage|\bplp\b/i;function WA(t,e,s){const n=new Set;for(const l of s)UA.test(l)&&n.add("product"),HA.test(l)&&n.add("category");const i=yl(Gn(t)),o=i[i.length-1],a=i[i.length-2];return o?.type==="text"&&o.text==="/p"&&a?.type==="param"&&a.name===e&&n.add("product"),e==="*"&&i.some(l=>l.type==="param"&&l.name==="*")&&n.add("category"),n}function qA(t,e){const s=e.trim(),n=[];/^\d+$/.test(s)&&n.push({resolveType:t,props:{ids:[s]}});const o=s.includes("-")&&!/\s/.test(s)?s.replace(/-+/g," "):s;return n.push({resolveType:t,props:{query:o,count:10}}),n}const Ng=new Set(["vtex","shopify","shopify-mcp","magento","wake","linx","linx-impulse","nuvemshop","vnda","wap","salesforce"]);function du(t){return t.split("/")[0]??""}function GA(t){const e=new Set;for(const s of t){const n=du(s);Ng.has(n)&&e.add(n)}return e}function YA(t,e){const s=du(t);return!Ng.has(s)||e.size===0?!0:e.has(s)}const JA=[{kind:"product",test:t=>t==="vtex/loaders/intelligentSearch/productList.ts",clientFilter:!1,buildRequests:qA,optionsFromPayload:ka},{kind:"product",test:t=>/magento\/.*products?\/list(\.tsx?)?$/i.test(t),clientFilter:!1,buildRequests:(t,e)=>[{resolveType:t,props:{props:{search:e.trim(),pageSize:10,currentPage:1}}}],optionsFromPayload:ka},{kind:"product",test:t=>/algolia\/.*products?\/(list|suggestions)(\.tsx?)?$/i.test(t),clientFilter:!1,buildRequests:(t,e)=>[{resolveType:t,props:{term:e.trim(),hitsPerPage:10}}],optionsFromPayload:ka},{kind:"product",test:t=>/products?\/list(\.tsx?)?$/i.test(t),clientFilter:!1,buildRequests:(t,e)=>[{resolveType:t,props:{query:e.trim(),term:e.trim(),count:10,hitsPerPage:10}}],optionsFromPayload:ka},{kind:"category",test:t=>t==="vtex/loaders/categories/tree.ts"||/categor(y|ies).*tree/i.test(t),clientFilter:!0,buildRequests:t=>[{resolveType:t,props:{}}],optionsFromPayload:iE}];function XA(t,e,s=new Set){const n=[...e],i=[];for(const o of["product","category"]){if(!t.has(o))continue;const a=[];for(const h of JA){if(h.kind!==o)continue;const u=n.find(f=>h.test(f)&&YA(f,s));u&&a.push({cand:h,resolveType:u})}const l=a.find(h=>s.has(du(h.resolveType)))??a[0];if(!l)continue;const{cand:c,resolveType:d}=l;i.push({kind:o,id:`${o}:${d}`,resolveType:d,clientFilter:c.clientFilter,buildRequests:h=>c.buildRequests(d,h),optionsFromPayload:c.optionsFromPayload})}return i}function xi(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:null}function QA(t,e,s){const n=new Set,i=new Set,o=a=>{if(Array.isArray(a)){for(const d of a)o(d);return}const l=xi(a);if(!l)return;const c=l.__resolveType;if(typeof c=="string"){if(s(c))n.add(c);else if(c in e&&!i.has(c)){i.add(c);const d=xi(e[c])?.__resolveType;typeof d=="string"&&s(d)&&n.add(c),o(e[c])}}for(const d of Object.values(l))o(d)};return o(t),n}function ZA(t){const e=new Set,s=[];for(const n of t)for(const i of n)e.has(i.value)||(e.add(i.value),s.push(i));return s}function Tg(t){try{return decodeURIComponent(t)}catch{return t}}function eE(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function tE(t){const e=[];let s="^";for(const n of t)n.type==="text"?s+=eE(n.text):(e.push(n.name),s+=n.name==="*"?"(.+)":"([^/]+)");return{pattern:new RegExp(`${s}$`),order:e}}function sE(t,e,s){if(typeof t!="string"||!t)return null;let n;try{n=new URL(t,"https://placeholder.invalid").pathname}catch{return null}n=n.replace(/\/+$/,"");const i=yl(Gn(e)),{pattern:o,order:a}=tE(i),l=a.indexOf(s);if(l===-1)return null;const c=n.match(o);if(!c)return null;const d=c[l+1]?.replace(/^\/+|\/+$/g,"");return d?Tg(d):null}function ka(t,e){const s=xi(t),n=Array.isArray(t)?t:Array.isArray(s?.products)?s.products:Array.isArray(s?.list)?s.list:[],i=[],o=new Set;for(const a of n){const l=xi(a);if(!l)continue;const c=sE(l.url,e.template,e.paramName);if(!c||o.has(c))continue;o.add(c);const d=xi(l.isVariantOf),h=typeof d?.name=="string"&&d.name||typeof l.name=="string"&&l.name||c,u=Array.isArray(l.image)?xi(l.image[0]):null,f=typeof u?.url=="string"?u.url:void 0;i.push({value:c,label:h,image:f})}return i}function nE(t){if(typeof t!="string"||!t)return null;let e;try{e=new URL(t,"https://placeholder.invalid").pathname}catch{return null}const s=e.replace(/^\/+|\/+$/g,"");return s?Tg(s):null}function iE(t){const e=[],s=new Set,n=(i,o)=>{const a=xi(i);if(!a)return;const l=typeof a.name=="string"&&a.name?a.name:"",c=l?[...o,l]:o,d=nE(a.url);if(d&&!s.has(d)&&(s.add(d),e.push({value:d,label:c.join(" › ")||d})),Array.isArray(a.children))for(const h of a.children)n(h,c)};if(Array.isArray(t))for(const i of t)n(i,[]);return e}function rE(t,e,s=50){const n=e.trim().toLowerCase();return(n?t.filter(o=>o.label.toLowerCase().includes(n)||o.value.toLowerCase().includes(n)):t).slice(0,s)}const pf=3e4;function Ag(t){return`/api/${t.orgSlug}/sandbox/${encodeURIComponent(t.virtualMcpId)}/${encodeURIComponent(t.branch)}/preview-invoke`}function oE(t,e,s,n){const i=new URL(`/deco/invoke/${e}`,t);return i.searchParams.set("__cb",n.toString(36)),i.searchParams.set("__decoFBT","0"),i.searchParams.set("__d",`run-${n.toString(36)}`),i.searchParams.set("props",btoa(encodeURIComponent(JSON.stringify(s)))),i.href}async function aE(t,{resolveType:e,props:s}){let n;try{n=await fetch(Ag(t),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({__resolveType:e,...s}),signal:AbortSignal.timeout(pf)})}catch(l){throw l instanceof DOMException&&l.name==="TimeoutError"?new Error(`Run timed out after ${pf/1e3}s — the block may be slow or the preview unresponsive.`):l}const i=await n.text();let o=null,a=!1;try{o=i?JSON.parse(i):null,a=!0}catch{}if(!n.ok){const l=a&&o&&typeof o=="object"&&"error"in o&&typeof o.error=="string"?o.error:i||`Run failed (${n.status})`;throw new Error(l)}return a?o:i}function lE(t){const e=F.c(2);let s;return e[0]!==t?(s={mutationFn:n=>aE(t,n)},e[0]=t,e[1]=s):s=e[1],Ys(s)}const cE=1e4;function Eg(t){return{product:{noun:t("sandbox.pathParamPickerChip.kindProductNoun"),heading:t("sandbox.pathParamPickerChip.kindProductHeading")},category:{noun:t("sandbox.pathParamPickerChip.kindCategoryNoun"),heading:t("sandbox.pathParamPickerChip.kindCategoryHeading")}}}async function dE(t,{resolveType:e,props:s}){const n=await fetch(Ag(t),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({__resolveType:e,...s}),signal:AbortSignal.timeout(cE)});if(!n.ok)throw new Error(`Failed to fetch options: ${n.status}`);return n.json()}function Pg(t,e,s){return at.sandboxInvoke(`${t.orgSlug}/${t.virtualMcpId}/${t.branch}`,`path-param-${e.id}:${e.clientFilter?"":s}`)}async function Rg(t,e,s,n){const i=e.buildRequests(s);if(i.length===0)return[];const o=await Promise.allSettled(i.map(l=>dE(t,l))),a=o.filter(l=>l.status==="fulfilled").map(l=>l.value);if(a.length===0){const l=o.find(c=>c.status==="rejected");throw l?l.reason:new Error("Failed to fetch options")}return ZA(a.map(l=>e.optionsFromPayload(l,n)))}function uE(t){const e=F.c(39),{source:s,sandboxRef:n,template:i,paramName:o,open:a,search:l,debouncedSearch:c,showHeading:d,onSelect:h}=t,u=re();let f;e[0]!==c||e[1]!==n||e[2]!==s?(f=Pg(n,s,c),e[0]=c,e[1]=n,e[2]=s,e[3]=f):f=e[3];let m;e[4]!==c||e[5]!==o||e[6]!==n||e[7]!==s||e[8]!==i?(m=()=>Rg(n,s,c,{template:i,paramName:o}),e[4]=c,e[5]=o,e[6]=n,e[7]=s,e[8]=i,e[9]=m):m=e[9];let p;e[10]!==a||e[11]!==f||e[12]!==m?(p={queryKey:f,queryFn:m,enabled:a,staleTime:6e4,retry:1},e[10]=a,e[11]=f,e[12]=m,e[13]=p):p=e[13];const g=Mt(p);let x,v,b;if(e[14]!==g.data||e[15]!==g.isError||e[16]!==g.isLoading||e[17]!==l||e[18]!==s.clientFilter||e[19]!==s.kind||e[20]!==u){const{noun:j,heading:S}=Eg(u)[s.kind];x=S;let C;e[24]!==g.data||e[25]!==l||e[26]!==s.clientFilter?(C=s.clientFilter?rE(g.data??[],l):g.data??[],e[24]=g.data,e[25]=l,e[26]=s.clientFilter,e[27]=C):C=e[27],v=C,b=g.isLoading?u("sandbox.pathParamPickerChip.loading",{noun:j}):g.isError?u("sandbox.pathParamPickerChip.couldNotLoad"):null,e[14]=g.data,e[15]=g.isError,e[16]=g.isLoading,e[17]=l,e[18]=s.clientFilter,e[19]=s.kind,e[20]=u,e[21]=x,e[22]=v,e[23]=b}else x=e[21],v=e[22],b=e[23];const y=b;if(!y&&v.length===0)return null;const _=d?x:void 0;let L;e[28]!==h||e[29]!==v||e[30]!==o||e[31]!==s.id||e[32]!==s.kind||e[33]!==y||e[34]!==i?(L=y?r.jsx("div",{className:"px-2 py-2 text-xs text-muted-foreground",children:y}):v.map(j=>r.jsxs(Vs,{value:`${s.id}:${j.value}`,className:"gap-3 py-2",onSelect:()=>h(j.value),children:[s.kind==="product"&&r.jsx("span",{className:"flex h-10 w-10 shrink-0 items-center justify-center overflow-hidden rounded-md border border-border bg-muted",children:j.image?r.jsx("img",{src:j.image,alt:"",referrerPolicy:"no-referrer",className:"h-full w-full object-cover"}):r.jsx(Q0,{size:14,className:"text-muted-foreground"})}),r.jsxs("span",{className:"min-w-0 flex-1",children:[r.jsx("span",{className:"block truncate text-sm",children:j.label}),r.jsx("span",{className:"block truncate text-xs text-muted-foreground",children:pi(i,{[o]:j.value})})]})]},`${s.id}:${j.value}`)),e[28]=h,e[29]=v,e[30]=o,e[31]=s.id,e[32]=s.kind,e[33]=y,e[34]=i,e[35]=L):L=e[35];let w;return e[36]!==_||e[37]!==L?(w=r.jsx(Ms,{heading:_,children:L}),e[36]=_,e[37]=L,e[38]=w):w=e[38],w}function hE(t){const e=F.c(104),{sources:s,template:n,paramName:i,value:o,sandboxRef:a,onCommit:l}=t,c=re(),[d,h]=A.useState(!1),[u,f]=A.useState(""),[m,p]=A.useState(""),g=A.useRef(null),x=i==="*"?"path":`:${i}`;let v;if(e[0]!==s||e[1]!==c){const q=Eg(c);v=new Set(s.map(Z=>q[Z.kind].noun)),e[0]=s,e[1]=c,e[2]=v}else v=e[2];let b;e[3]!==v?(b=[...v],e[3]=v,e[4]=b):b=e[4];const _=b.join(" or ");let L;e[5]!==c||e[6]!==_?(L=c("sandbox.pathParamPickerChip.searchPlaceholder",{options:_}),e[5]=c,e[6]=_,e[7]=L):L=e[7];const w=L;let j,S,C,N,V,E,T,k,R,P,D,I,M,O,$,B,z,K;if(e[8]!==l||e[9]!==d||e[10]!==x||e[11]!==i||e[12]!==w||e[13]!==u||e[14]!==c||e[15]!==n||e[16]!==o){const q=ce=>{h(ce),g.current&&clearTimeout(g.current),f(ce?o:""),p(ce?o:"")};let Z;e[35]===Symbol.for("react.memo_cache_sentinel")?(Z=ce=>{f(ce),g.current&&clearTimeout(g.current),g.current=setTimeout(()=>{p(ce)},300)},e[35]=Z):Z=e[35];const Q=Z;V=ce=>{l(ce),q(!1)};const ee=u.trim().replace(/^\/+|\/+$/g,""),J=pi(n,{[i]:ee});let te;e[36]!==x||e[37]!==c?(te=c("sandbox.pathParamPickerChip.buttonTitle",{paramLabel:x}),e[36]=x,e[37]=c,e[38]=te):te=e[38],M=r.jsx("button",{type:"button",title:te,className:"max-w-64 shrink-0 cursor-pointer truncate rounded-sm bg-violet-500/15 px-1 py-0.5 text-[12px] text-violet-600 hover:bg-violet-500/25 dark:text-violet-400",onClick:ce=>{ce.stopPropagation(),q(!0)},children:o||x}),N=ts,D=d,I=q,C=es,T="flex h-[85svh] flex-col gap-0 overflow-hidden p-0 sm:h-[520px] sm:max-w-[560px]",k=fE;let se;e[39]!==x||e[40]!==c?(se=c("sandbox.pathParamPickerChip.pickValueTitle",{paramLabel:x}),e[39]=x,e[40]=c,e[41]=se):se=e[41],e[42]!==se?(R=r.jsx(ms,{className:"sr-only",children:r.jsx(ps,{children:se})}),e[42]=se,e[43]=R):R=e[43];let ne;e[44]===Symbol.for("react.memo_cache_sentinel")?(ne=r.jsx(Q0,{size:16,className:"shrink-0 text-foreground"}),e[44]=ne):ne=e[44];let de;e[45]!==c?(de=c("sandbox.pathParamPickerChip.pickValueHeading"),e[45]=c,e[46]=de):de=e[46];let xe;e[47]!==x?(xe=r.jsx("span",{className:"rounded-sm bg-violet-500/15 px-1 py-0.5 font-mono text-[12px] text-violet-600 dark:text-violet-400",children:x}),e[47]=x,e[48]=xe):xe=e[48],e[49]!==de||e[50]!==xe?(P=r.jsxs("div",{className:"flex h-12 shrink-0 items-center gap-3 border-b border-border px-4",children:[ne,r.jsxs("span",{className:"text-sm font-medium text-foreground",children:[de," ",xe]})]}),e[49]=de,e[50]=xe,e[51]=P):P=e[51],S=Tr,z=!1,K="min-h-0 flex-1",e[52]!==w||e[53]!==u?(E=r.jsx($i,{autoFocus:!0,placeholder:w,value:u,onValueChange:Q}),e[52]=w,e[53]=u,e[54]=E):E=e[54],j=Fi,O="max-h-none flex-1";let ue;e[55]!==c?(ue=c("sandbox.pathParamPickerChip.noResults"),e[55]=c,e[56]=ue):ue=e[56],e[57]!==ue?($=r.jsx(Qn,{children:ue}),e[57]=ue,e[58]=$):$=e[58],B=ee&&r.jsx(Ms,{children:r.jsxs(Vs,{value:`__raw__:${ee}`,className:"gap-3 py-2",onSelect:()=>V(ee),children:[r.jsx("span",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-md border border-dashed border-border bg-muted",children:r.jsx(kr,{size:14,className:"text-muted-foreground"})}),r.jsxs("span",{className:"min-w-0 flex-1",children:[r.jsx("span",{className:"block truncate text-sm",children:c("sandbox.pathParamPickerChip.useRawValue",{rawTerm:ee,paramLabel:x})}),r.jsx("span",{className:"block truncate text-xs text-muted-foreground",children:J})]})]})}),e[8]=l,e[9]=d,e[10]=x,e[11]=i,e[12]=w,e[13]=u,e[14]=c,e[15]=n,e[16]=o,e[17]=j,e[18]=S,e[19]=C,e[20]=N,e[21]=V,e[22]=E,e[23]=T,e[24]=k,e[25]=R,e[26]=P,e[27]=D,e[28]=I,e[29]=M,e[30]=O,e[31]=$,e[32]=B,e[33]=z,e[34]=K}else j=e[17],S=e[18],C=e[19],N=e[20],V=e[21],E=e[22],T=e[23],k=e[24],R=e[25],P=e[26],D=e[27],I=e[28],M=e[29],O=e[30],$=e[31],B=e[32],z=e[33],K=e[34];let G;if(e[59]!==V||e[60]!==m||e[61]!==d||e[62]!==i||e[63]!==a||e[64]!==u||e[65]!==s||e[66]!==n){let q;e[68]!==V||e[69]!==m||e[70]!==d||e[71]!==i||e[72]!==a||e[73]!==u||e[74]!==s.length||e[75]!==n?(q=Z=>r.jsx(uE,{source:Z,sandboxRef:a,template:n,paramName:i,open:d,search:u,debouncedSearch:m,showHeading:s.length>1,onSelect:V},Z.id),e[68]=V,e[69]=m,e[70]=d,e[71]=i,e[72]=a,e[73]=u,e[74]=s.length,e[75]=n,e[76]=q):q=e[76],G=s.map(q),e[59]=V,e[60]=m,e[61]=d,e[62]=i,e[63]=a,e[64]=u,e[65]=s,e[66]=n,e[67]=G}else G=e[67];let Y;e[77]!==j||e[78]!==G||e[79]!==O||e[80]!==$||e[81]!==B?(Y=r.jsxs(j,{className:O,children:[$,B,G]}),e[77]=j,e[78]=G,e[79]=O,e[80]=$,e[81]=B,e[82]=Y):Y=e[82];let U;e[83]!==S||e[84]!==E||e[85]!==Y||e[86]!==z||e[87]!==K?(U=r.jsxs(S,{shouldFilter:z,className:K,children:[E,Y]}),e[83]=S,e[84]=E,e[85]=Y,e[86]=z,e[87]=K,e[88]=U):U=e[88];let W;e[89]!==C||e[90]!==T||e[91]!==k||e[92]!==R||e[93]!==P||e[94]!==U?(W=r.jsxs(C,{className:T,onClick:k,children:[R,P,U]}),e[89]=C,e[90]=T,e[91]=k,e[92]=R,e[93]=P,e[94]=U,e[95]=W):W=e[95];let H;e[96]!==N||e[97]!==D||e[98]!==I||e[99]!==W?(H=r.jsx(N,{open:D,onOpenChange:I,children:W}),e[96]=N,e[97]=D,e[98]=I,e[99]=W,e[100]=H):H=e[100];let X;return e[101]!==M||e[102]!==H?(X=r.jsxs(r.Fragment,{children:[M,H]}),e[101]=M,e[102]=H,e[103]=X):X=e[103],X}function fE(t){return t.stopPropagation()}function mE(t){const e=F.c(11),{source:s,template:n,paramName:i,sandboxRef:o,onFill:a}=t;let l;e[0]!==o||e[1]!==s?(l=Pg(o,s,""),e[0]=o,e[1]=s,e[2]=l):l=e[2];let c;e[3]!==i||e[4]!==o||e[5]!==s||e[6]!==n?(c=()=>Rg(o,s,"",{template:n,paramName:i}),e[3]=i,e[4]=o,e[5]=s,e[6]=n,e[7]=c):c=e[7];let d;e[8]!==l||e[9]!==c?(d={queryKey:l,queryFn:c,staleTime:6e4,retry:1},e[8]=l,e[9]=c,e[10]=d):d=e[10];const h=Mt(d),[u,f]=A.useState(!1);if(!u&&h.data&&h.data.length>0){f(!0);const m=h.data[0].value;queueMicrotask(()=>a(m))}return null}function pE(t){const e=F.c(28),{name:s,value:n,onCommit:i}=t,o=re(),[a,l]=A.useState(n),[c,d]=A.useState(!1),h=A.useRef(!1),u=s==="*"?"path":`:${s}`,f=a||u;let m;e[0]!==f?(m=r.jsx("span",{"aria-hidden":!0,className:"invisible whitespace-pre px-1 py-0.5 text-[12px]",children:f}),e[0]=f,e[1]=m):m=e[1];let p;e[2]!==u||e[3]!==o?(p=o("sandbox.preview.valueForParam",{label:u}),e[2]=u,e[3]=o,e[4]=p):p=e[4];let g,x;e[5]===Symbol.for("react.memo_cache_sentinel")?(g=j=>l(j.target.value),x=()=>d(!0),e[5]=g,e[6]=x):(g=e[5],x=e[6]);let v;e[7]!==n?(v=j=>{j.key==="Enter"&&j.currentTarget.blur(),j.key==="Escape"&&(h.current=!0,l(n),j.currentTarget.blur())},e[7]=n,e[8]=v):v=e[8];let b;e[9]!==a||e[10]!==i||e[11]!==n?(b=()=>{if(d(!1),h.current){h.current=!1;return}const j=a.trim();l(j),j!==n&&i(j)},e[9]=a,e[10]=i,e[11]=n,e[12]=b):b=e[12];let y;e[13]!==a||e[14]!==u||e[15]!==p||e[16]!==v||e[17]!==b?(y=r.jsx("input",{type:"text",value:a,placeholder:u,title:p,spellCheck:!1,className:"absolute inset-0 rounded-sm bg-violet-500/15 px-1 text-[12px] text-violet-600 outline-none placeholder:text-violet-500/60 focus:bg-violet-500/25 dark:text-violet-400",onClick:gE,onChange:g,onFocus:x,onKeyDown:v,onBlur:b}),e[13]=a,e[14]=u,e[15]=p,e[16]=v,e[17]=b,e[18]=y):y=e[18];let _;e[19]!==m||e[20]!==y?(_=r.jsxs("span",{className:"relative inline-flex max-w-64 shrink-0 items-center overflow-hidden",children:[m,y]}),e[19]=m,e[20]=y,e[21]=_):_=e[21];let L;e[22]!==c||e[23]!==o?(L=c&&r.jsxs("span",{className:"pointer-events-none ml-1.5 flex shrink-0 items-center gap-1 whitespace-nowrap rounded-sm border border-border bg-muted px-1 py-0.5 text-[10px] text-muted-foreground",children:[r.jsx(Uv,{size:10}),o("sandbox.preview.enterToGo")]}),e[22]=c,e[23]=o,e[24]=L):L=e[24];let w;return e[25]!==_||e[26]!==L?(w=r.jsxs(r.Fragment,{children:[_,L]}),e[25]=_,e[26]=L,e[27]=w):w=e[27],w}function gE(t){return t.stopPropagation()}const xE={loaders:"loader",actions:"action"},Dg=new Set(["workflows"]);function Ig(t){return xE[t]}function vE(t,e,s){const n=t.manifest?.blocks??{};for(const[i,o]of Object.entries(n))if(i.includes(s)&&e in o)return!0;return!1}function bE(t,e){const s=new Set,n=t.manifest?.blocks??{};for(const[i,o]of Object.entries(n))if(i.includes(e))for(const a of Object.keys(o))s.add(a);return s}function _E(t,e){return/\.tsx?$/.test(t)?!1:e.has(`${t}.ts`)||e.has(`${t}.tsx`)}function Mg(t,e){const s=t.manifest?.blocks??{},n=[],i=new Set;for(const[o,a]of Object.entries(s))if(o.includes(e))for(const l of Object.keys(a))i.add(l);for(const o of i){if(o.toLowerCase().includes("preview")||Ip.has(o)||Dg.has(uu(o))||_E(o,i))continue;const a=li(o,t);if(a.hidden)continue;const l=a.title&&a.title!==o?a.title:Tt(o);n.push({resolveType:o,title:l})}return n.sort((o,a)=>o.title.localeCompare(a.title))}function gf(t,e){return Mg(t,e).length}function uu(t){return t.startsWith("deco-sites/")?t.split("/")[1]||"site":t.startsWith("$live")||t.startsWith("deco/")?"deco":t.split("/")[0]||"other"}const yE={deco:"Deco",std:"Deco Standard",website:"Website"};function LE(t){return yE[t]??t}function Og(t){const e=uu(t);let n=t.split("/").filter(Boolean).slice(t.startsWith("deco-sites/")?2:1);return(n[0]==="loaders"||n[0]==="actions")&&(n=n.slice(1)),[e,...n.slice(0,-1)]}function SE(t,e,s){const n=[];for(const[i,o]of Object.entries(e)){if(i.includes("/")||ac(i)||!o||typeof o!="object"||Array.isArray(o))continue;const a=o,l=a.__resolveType;typeof l=="string"&&(Ip.has(l)||Dg.has(uu(l))||vE(t,l,s)&&n.push({key:i,resolveType:l,title:typeof a.name=="string"&&a.name?a.name:i}))}return n.sort((i,o)=>i.title.localeCompare(o.title))}function Bg(t){const e=F.c(12),{orgSlug:s,virtualMcpId:n,branch:i,enabled:o}=t,a=o===void 0?!0:o;let l;e[0]!==i||e[1]!==s||e[2]!==n?(l=at.sandboxRepoDir(s,n,i),e[0]=i,e[1]=s,e[2]=n,e[3]=l):l=e[3];let c;e[4]!==i||e[5]!==s||e[6]!==n?(c=async()=>{const u=`/api/${s}/sandbox/${encodeURIComponent(n)}/${encodeURIComponent(i)}/config`,f=await fetch(u);return f.ok?(await f.json()).repoDir??null:null},e[4]=i,e[5]=s,e[6]=n,e[7]=c):c=e[7];let d;return e[8]!==a||e[9]!==l||e[10]!==c?(d={queryKey:l,queryFn:c,enabled:a,staleTime:1/0},e[8]=a,e[9]=l,e[10]=c,e[11]=d):d=e[11],Mt(d).data??null}const wE={target:null,editSeoPageKey:null,variantOverride:null};function jE(t,e){switch(e.type){case"select":return{...t,target:e.target,variantOverride:null};case"edit-seo":return{...t,target:e.target,editSeoPageKey:e.target.key};case"consume-edit-seo":return{...t,editSeoPageKey:null};case"variant-override":return{...t,variantOverride:e.params}}}const $g=A.createContext(null);function CE(t){const e=F.c(9),{children:s}=t,[n,i]=A.useReducer(jE,wE);let o,a,l,c;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=u=>i({type:"select",target:u}),a=u=>i({type:"edit-seo",target:u}),l=()=>i({type:"consume-edit-seo"}),c=u=>i({type:"variant-override",params:u}),e[0]=o,e[1]=a,e[2]=l,e[3]=c):(o=e[0],a=e[1],l=e[2],c=e[3]);let d;e[4]!==n?(d={state:n,selectTarget:o,editSeo:a,consumeEditSeo:l,setVariantOverride:c},e[4]=n,e[5]=d):d=e[5];let h;return e[6]!==s||e[7]!==d?(h=r.jsx($g,{value:d,children:s}),e[6]=s,e[7]=d,e[8]=h):h=e[8],h}function hu(){const t=A.use($g);if(!t)throw new Error("useBlocksPreviewWorkspace must be used inside BlocksPreviewWorkspaceProvider");return t}function kE(t){switch(t){case"clone-failed":case"install-failed":case"start-failed":return"terminal-error";case"idle":case"cloning":return"booting";case"checking-out":case"installing":case"starting":case"running":case"crashed":return"snapshot-readable"}}function VE(t){const e=kE(t.lifecyclePhase);return e==="terminal-error"?{kind:"error",source:"sandbox"}:e==="booting"?{kind:"loading"}:[t.decofile,t.meta].some(i=>i.status==="error"&&!i.hasData&&i.errorStatus===404)?{kind:"empty"}:t.decofile.status==="error"&&!t.decofile.hasData||t.meta.status==="error"&&!t.meta.hasData?t.lifecyclePhase==="running"||t.lifecyclePhase==="crashed"?{kind:"error",source:"data"}:{kind:"loading"}:!t.decofile.hasData||!t.meta.hasData?{kind:"loading"}:t.hasEditableContent?{kind:"content"}:{kind:"empty"}}const NE="https://github.com/decocms/blocks";function TE(){const t=F.c(14),e=re();let s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(Hv,{size:48,className:"text-muted-foreground"}),t[0]=s):s=t[0];let n;t[1]!==e?(n=e("mainPanelTabs.blocksTabStates.emptyStateTitle"),t[1]=e,t[2]=n):n=t[2];let i;t[3]!==e?(i=e("mainPanelTabs.blocksTabStates.emptyStateDescription"),t[3]=e,t[4]=i):i=t[4];let o;t[5]!==e?(o=e("mainPanelTabs.blocksTabStates.setupContentEditing"),t[5]=e,t[6]=o):o=t[6];let a;t[7]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx(Dn,{size:14}),t[7]=a):a=t[7];let l;t[8]!==o?(l=r.jsx(le,{size:"sm",asChild:!0,children:r.jsxs("a",{href:NE,target:"_blank",rel:"noreferrer",children:[o,a]})}),t[8]=o,t[9]=l):l=t[9];let c;return t[10]!==n||t[11]!==i||t[12]!==l?(c=r.jsx(ki,{className:"h-full w-full",image:s,title:n,description:i,actions:l}),t[10]=n,t[11]=i,t[12]=l,t[13]=c):c=t[13],c}function AE(t){const e=F.c(15),{source:s,onRetry:n}=t,i=re();let o;e[0]!==s||e[1]!==i?(o=i(s==="sandbox"?"mainPanelTabs.blocksTabStates.errorStateSandbox":"mainPanelTabs.blocksTabStates.errorStateData"),e[0]=s,e[1]=i,e[2]=o):o=e[2];const a=o;let l;e[3]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(wn,{size:48,className:"text-muted-foreground"}),e[3]=l):l=e[3];let c;e[4]!==i?(c=i("mainPanelTabs.blocksTabStates.errorStateTitle"),e[4]=i,e[5]=c):c=e[5];let d;e[6]!==i?(d=i("mainPanelTabs.blocksTabStates.retry"),e[6]=i,e[7]=d):d=e[7];let h;e[8]!==n||e[9]!==d?(h=r.jsx(le,{variant:"outline",size:"sm",onClick:n,children:d}),e[8]=n,e[9]=d,e[10]=h):h=e[10];let u;return e[11]!==a||e[12]!==c||e[13]!==h?(u=r.jsx(ki,{image:l,title:c,description:a,actions:h}),e[11]=a,e[12]=c,e[13]=h,e[14]=u):u=e[14],u}function Ti(){const t=F.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx("div",{"data-testid":"main-panel-loading",className:"flex h-full w-full items-center justify-center",children:r.jsx(et,{size:20,className:"animate-spin text-muted-foreground"})}),t[0]=e):e=t[0],e}const EE=A.lazy(()=>Bs(()=>import("./sections-editor-qd7Dwqwc.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155])).then(t=>({default:t.SectionsEditor})));function xf(t){if(t instanceof Error&&"status"in t&&typeof t.status=="number")return t.status}function vf(t){const e=F.c(47),{virtualMcpId:s,externalSelectedIndex:n}=t,i=n===void 0?null:n,{org:o}=Oe(),{currentBranch:a}=Zt(),l=Fs(),c=Er(),d=hu(),h=l.lifecycle.phase==="running",u=c.previewUrl;let f;e[0]!==a||e[1]!==o||e[2]!==u||e[3]!==s?(f=a?{orgSlug:o.slug,virtualMcpId:s,branch:a,previewUrl:u}:null,e[0]=a,e[1]=o,e[2]=u,e[3]=s,e[4]=f):f=e[4];const m=f;let p;e[5]!==h?(p={fetchEnabled:h},e[5]=h,e[6]=p):p=e[6];const g=rc(m,p);let x;e[7]!==h?(x={fetchEnabled:h},e[7]=h,e[8]=x):x=e[8];const v=oc(m,x),b=g.data!==void 0;let y;e[9]!==g.data||e[10]!==g.error||e[11]!==g.status||e[12]!==v.data||e[13]!==v.error||e[14]!==v.status||e[15]!==l.lifecycle.phase||e[16]!==b?(y=VE({lifecyclePhase:l.lifecycle.phase,decofile:{status:g.status,hasData:b,errorStatus:xf(g.error)},meta:{status:v.status,hasData:v.data!==void 0,errorStatus:xf(v.error)},hasEditableContent:I9(g.data,v.data)}),e[9]=g.data,e[10]=g.error,e[11]=g.status,e[12]=v.data,e[13]=v.error,e[14]=v.status,e[15]=l.lifecycle.phase,e[16]=b,e[17]=y):y=e[17];const _=y;if(_.kind==="loading"){let I;return e[18]===Symbol.for("react.memo_cache_sentinel")?(I=r.jsx(Ti,{}),e[18]=I):I=e[18],I}if(_.kind==="empty"){let I;return e[19]===Symbol.for("react.memo_cache_sentinel")?(I=r.jsx(TE,{}),e[19]=I):I=e[19],I}if(_.kind==="error"){let I;e[20]!==g||e[21]!==c||e[22]!==v||e[23]!==_.source?(I=()=>{if(_.source==="sandbox"){c.retry();return}Promise.all([g.refetch(),v.refetch()])},e[20]=g,e[21]=c,e[22]=v,e[23]=_.source,e[24]=I):I=e[24];const M=I;let O;return e[25]!==M||e[26]!==_.source?(O=r.jsx(AE,{source:_.source,onRetry:M}),e[25]=M,e[26]=_.source,e[27]=O):O=e[27],O}const L=d.state.target;let w;e[28]!==a||e[29]!==o.slug||e[30]!==L||e[31]!==s?(w=L||!a?null:Vg(kg(o.slug,s,a)),e[28]=a,e[29]=o.slug,e[30]=L,e[31]=s,e[32]=w):w=e[32];const j=w;let S="/",C=null,N=null;L?.kind==="page"?(S=L.path,C=L.key):L?.kind==="section"?N=L.key:j&&(S=j.path,C=j.pageKey);const V=C?`page:${C}`:N?`section:${N}`:`path:${S}`;let E;e[33]===Symbol.for("react.memo_cache_sentinel")?(E=r.jsx("div",{className:"h-full flex items-center justify-center",children:r.jsx(et,{size:20,className:"animate-spin text-muted-foreground"})}),e[33]=E):E=e[33];const T=a??"",k=u??void 0,R=N?null:i,P=!!C&&d.state.editSeoPageKey===C;let D;return e[34]!==N||e[35]!==C||e[36]!==S||e[37]!==V||e[38]!==o.slug||e[39]!==k||e[40]!==R||e[41]!==P||e[42]!==T||e[43]!==s||e[44]!==d.consumeEditSeo||e[45]!==d.setVariantOverride?(D=r.jsx("div",{"data-testid":"blocks-panel",className:"h-full min-h-0 overflow-hidden",children:r.jsx(A.Suspense,{fallback:E,children:r.jsx(EE,{orgSlug:o.slug,virtualMcpId:s,branch:T,previewReady:!0,previewUrl:k,currentPath:S,activePageBlockKey:C,activeGlobalBlockKey:N,externalSelectedIndex:R,initialEditSeo:P,onExitSeo:d.consumeEditSeo,onVariantPreviewOverride:d.setVariantOverride},V)})}),e[34]=N,e[35]=C,e[36]=S,e[37]=V,e[38]=o.slug,e[39]=k,e[40]=R,e[41]=P,e[42]=T,e[43]=s,e[44]=d.consumeEditSeo,e[45]=d.setVariantOverride,e[46]=D):D=e[46],D}function PE(t,e){return t===e?"preview":e}const RE="https://decoims.com/decocms/01b321bd-4613-4b2c-9348-35058444d210/Visual_Studio_Code_1.35_icon.svg.png",DE="https://decoims.com/decocms/7583d3b5-81d0-4afb-becf-6a59bbb3a68e/cursor-logo-icon-freelogovectors.net_.png",IE=A.lazy(()=>Bs(()=>import("./page-seo-sheet-CMU3RR2I.js"),__vite__mapDeps([156,1,2,62,32,63,50,54,52,53,17,3,19,55,56,57,58,59,60,61,64,65,66,67,68,5,16,20,4,6,7,8,9,10,11,12,13,14,15,18,21,22,23,24,25,26,27,28,29,30,31,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,51,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,104,105,107,108,109,110,111,112,113,114,115,116,117,103,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155])).then(t=>({default:t.SeoSheet}))),bf=500,ME={mobile:375,tablet:768,desktop:null},sd=["desktop","mobile","tablet"],_f={mobile:"sandbox.preview.deviceMobile",tablet:"sandbox.preview.deviceTablet",desktop:"sandbox.preview.deviceDesktop"};function OE(t,e){const s=new URL(t,window.location.href);return s.searchParams.set("deviceHint",e),s.href}function qr(t){if(!t)return null;try{return new URL(t,window.location.href).origin}catch{return null}}function yf(t,e){try{t.contentWindow?.location.reload()}catch{e&&(t.src=e)}}function BE({virtualMcpId:t}){const e=re(),s=Cr(),n=St(),{currentBranch:i}=Zt(),o=hu(),a=he=>{n({to:".",search:Ve=>({...Ve,main:he}),replace:!0})},[l,c]=A.useState("preview"),[d,h]=A.useState("desktop"),[u,f]=A.useState(null),[m,p]=A.useState(null),g=A.useRef(null),x=A.useRef(null),[v,b]=A.useState(!1),[y,_]=A.useState(""),L=A.useRef(null),[w,j]=A.useState(!1),[S,C]=A.useState(),[N,V]=A.useState(null),[E,T]=A.useState(null),[k,R]=A.useState("/"),[P,D]=A.useState(null),[I,M]=A.useState({}),[O,$]=A.useState(!1),B=A.useRef(null),z=()=>{$(!0),B.current&&clearTimeout(B.current),B.current=setTimeout(()=>$(!1),15e3)},K=()=>{B.current&&(clearTimeout(B.current),B.current=null),$(!1)},[G,Y]=A.useState(!1),{org:U}=Oe(),W=Fs(),H=Er(),X=H.vmEntry,q=H.previewUrl,Z=W.lifecycle.phase,Q=Z==="running",ee=X?.sandboxProviderKind==="user-desktop",J=Bg({orgSlug:U.slug,virtualMcpId:t??"",branch:i??"",enabled:ee&&Q&&!!t&&!!i}),te=ee?J:null,se=t&&i?{orgSlug:U.slug,virtualMcpId:t,branch:i,previewUrl:q}:null,{data:ne}=rc(se,{fetchEnabled:Q}),{data:de}=oc(se,{fetchEnabled:Q}),xe=t&&i?{orgSlug:U.slug,virtualMcpId:t,branch:i}:null,ue=iA(xe),ce=ne?M9(ne).sort((he,Ve)=>he.name.localeCompare(Ve.name)):[],oe=ne&&de?O9(ne,de):[],fe=Gn,pe=ce.filter(he=>{if(!y)return!0;const Ve=y.toLowerCase();return he.name.toLowerCase().includes(Ve)||he.path.toLowerCase().includes(Ve)}),we=oe.filter(he=>{if(!y)return!0;const Ve=y.toLowerCase();return he.name.toLowerCase().includes(Ve)||he.key.toLowerCase().includes(Ve)||he.resolveType.toLowerCase().includes(Ve)}),Ne=N?null:uw(ce,k,P),Fe=N?N.name:Ne?.name,je=Ne?.key??null,Ie=Ne?.path??null,Pe=(je?I[je]:void 0)??{},Ye=pi(k,Pe),_e={};if(Q&&q&&de&&ne){const he=bE(de,"loaders"),Ve=je?ne[je]:void 0,ct=QA(Ve,ne,xs=>he.has(xs)),bt=GA(ct);for(const xs of yl(k)){if(xs.type!=="param")continue;const jn=WA(k,xs.name,ct),Xs=XA(jn,he,bt);Xs.length>0&&(_e[xs.name]=Xs)}}const Ae=t&&i?{orgSlug:U.slug,virtualMcpId:t,branch:i}:null,Re=ne&&je?Lg(ne,je,0):[],ye=ne?xg(Re,ne):[],ve=ye.map(he=>he.isSavedBlock?he.label:""),Le=ye.map(he=>he.isSavedBlock?"global":he.isMultivariate?"variant":"normal"),$e=Re.map(he=>Yd(he,ne??{})),ke=A.useRef(null),Se=A.useRef(null),Be=W.status.state==="paused",nt=W.phase,pt=wg({claimPhase:nt,lifecycle:W.lifecycle}),Je=H.previewState,gt=H.userStopped,dt=Je.kind==="starting"||Je.kind==="iframe"&&pt.status==="doing",st=Je.kind==="iframe"?eA(OE(E??new URL(Ye,Je.previewUrl).href,d),o.state.variantOverride??[]):null,ft=t&&i?kg(U.slug,t,i):null,me=he=>{ft&&KA(ft,he)},De=o.state.target;A.useEffect(()=>{if(!(!De||!q||!de))if(De.kind==="page"){const he=I[De.key]??{};Se.current=pi(De.path,he),V(null),T(null),D(De.key),R(De.path),me({path:De.path,pageKey:De.key,params:he})}else{const he=oe.find(Ve=>Ve.key===De.key);if(he){Se.current=null;const Ve=Md(de);V(he),T(uf(q,Ve,he.key))}}},[De,q,de,I]),A.useEffect(()=>{!je||Ie===null||De?.kind==="page"&&De.key===je&&De.path===Ie||o.selectTarget({kind:"page",key:je,path:Ie})},[je,Ie,De]);const[Qe,xt]=A.useState(null);if(Je.kind==="iframe"&&Qe!==Je.previewUrl){const he=Qe!==null;xt(Je.previewUrl);const Ve=ft?Vg(ft):null;if(Ve){if(Se.current=pi(Ve.path,Ve.params),R(Ve.path),D(Ve.pageKey),T(null),V(null),Ve.pageKey&&Object.keys(Ve.params).length>0){const ct=Ve.pageKey;M(bt=>({...bt,[ct]:Ve.params}))}}else he&&(Se.current=null,R("/"),T(null),D(null),V(null))}ke.current=st;const ls=!!t&&!!i&&!W.notFound&&!gt&&!Be&&(nt?.kind==="ready"||Z!=="idle"),Vt=Je.kind!=="iframe"&&l==="visual"?"preview":l;A.useEffect(()=>{const he=qr(q);if(!he)return;const Ve=ct=>{if(ct.origin===he){if(ct.data?.type==="visual-editor::element-clicked"){const bt=aA.safeParse(ct.data.payload);bt.success&&f(bt.data)}else if(ct.data?.type==="cms-editor::section-clicked"){const bt=cA.safeParse(ct.data.payload);bt.success&&p(bt.data.sectionIndex)}}};return window.addEventListener("message",Ve),()=>window.removeEventListener("message",Ve)},[q]),A.useEffect(()=>{if(!v)return;const he=Ve=>{L.current?.contains(Ve.target)||(b(!1),_(""))};return document.addEventListener("pointerdown",he),()=>document.removeEventListener("pointerdown",he)},[v]);const Ut=()=>{const he=g.current?.contentWindow,Ve=qr(q);!he||!Ve||he.postMessage({type:"visual-editor::activate",script:lA},Ve)},is=()=>{const he=g.current?.contentWindow,Ve=qr(q);!he||!Ve||he.postMessage({type:"visual-editor::deactivate"},Ve)},He=()=>{const he=g.current?.contentWindow,Ve=qr(q);!he||!Ve||(he.postMessage({type:"visual-editor::activate",script:dA},Ve),he.postMessage({type:"cms-editor::set-labels",labels:ve,kinds:Le,keys:$e},Ve))},ae=()=>{const he=g.current?.contentWindow,Ve=qr(q);!he||!Ve||he.postMessage({type:"cms-editor::deactivate"},Ve)},Te=he=>{const Ve=l;!s&&he!==Ve&&(he==="blocks"?x.current?.resize(30):x.current?.collapse()),c(he),f(null),p(null),Ve==="visual"&&is(),he==="visual"&&Ut(),Ve==="blocks"&&he!=="blocks"&&ae(),he==="blocks"&&He()},We=he=>{Te(PE(l,he))},Ge=()=>{if(!g.current||!st)return;const he=g.current;he.src=st},mt=()=>{const he=g.current;if(!he)return;z();const Ve=document.activeElement,ct=he.tabIndex;he.tabIndex=-1,he.style.pointerEvents="none",he.blur(),yf(he,ke.current);let bt;const xs=()=>{clearTimeout(bt),he.tabIndex=ct,he.style.pointerEvents="";const jn=document.activeElement;(!jn||jn===document.body||jn===he)&&Ve?.focus(),he.removeEventListener("load",xs)};he.addEventListener("load",xs),bt=setTimeout(xs,3e3)};gy(()=>{mt()}),xy(()=>{z()});const wt=()=>{if(!g.current||!st)return;const he=st.includes("?")?"&":"?";g.current.src=`${st}${he}_r=${Date.now()}`},Bn=()=>{const he=sd.indexOf(d);h(sd[(he+1)%sd.length])},di=async()=>{let he=null;try{he=g.current?.contentWindow?.location?.href??null}catch{}const Ve=he??st??q;if(Ve)try{await navigator.clipboard.writeText(Ve),ge.success(e("sandbox.preview.urlCopiedToClipboard"))}catch{ge.error(e("sandbox.preview.failedToCopyUrl"))}},T5=(()=>{if(!q)return e("sandbox.preview.noServerRunning");if(N)return N.name;try{const he=new URL(q),Ve=Ye==="/"?"":Ye;return`${he.host}${Ve}`}catch{return q}})(),Ac=he=>{const Ve=I[he.key]??{},ct=pi(he.path,Ve);(N||fe(ct)!==fe(Ye))&&z(),Se.current=ct,V(null),T(null),p(null),D(he.key),R(he.path),me({path:he.path,pageKey:he.key,params:Ve}),o.selectTarget({kind:"page",key:he.key,path:he.path})},Ec=(he,Ve)=>{if(!je)return;const ct=je,bt={...Pe,[he]:Ve};Se.current=pi(k,bt),M(xs=>({...xs,[ct]:bt})),me({path:k,pageKey:ct,params:bt})},A5=he=>{if(!q||!de){ge.error(e("sandbox.preview.previewMetadataNotReady"));return}z(),Se.current=null;const Ve=Md(de),ct=uf(q,Ve,he.key);V(he),T(ct),p(null),o.selectTarget({kind:"section",key:he.key})},E5=async({name:he,path:Ve,templateKey:ct})=>{if(!t||!i)return;const bt=P9(Ve);if(bt){C(bt);return}const xs=Ve.trim().startsWith("/")?Ve.trim():`/${Ve.trim()}`;if(ce.some(Xs=>fe(Xs.path)===fe(xs))){C(e("sandbox.preview.pageAlreadyExists",{path:xs}));return}let jn;if(ct&&(jn=ne?.[ct],!jn)){C(e("sandbox.preview.templateNoLongerExists"));return}C(void 0);try{const Xs=await ue.mutateAsync({name:he,path:xs,template:jn});j(!1),ge.success(e("sandbox.preview.pageCreated",{name:he})),await Fb(bf),Ac({key:Xs.key,name:Xs.name,path:Xs.path}),Te("blocks")}catch(Xs){C(Xs instanceof Error?Xs.message:e("sandbox.preview.failedToCreatePage"))}},Pc=Je.kind==="iframe",Iu=Pc?r.jsx("div",{className:"absolute bottom-4 left-1/2 z-20 -translate-x-1/2",children:r.jsxs("div",{className:"flex items-center gap-0.5 rounded-full border bg-background/90 p-1 shadow-lg backdrop-blur-sm",children:[r.jsxs(Ue,{children:[r.jsx(ze,{asChild:!0,children:r.jsx(Ed,{onClick:()=>We("visual"),"aria-pressed":l==="visual","aria-label":e("sandbox.preview.visualEditor"),active:l==="visual",disabled:!Pc,children:r.jsx(Uu,{size:16})})}),r.jsx(Ke,{side:"top",children:e("sandbox.preview.visualEditor")})]}),r.jsx("div",{className:"mx-0.5 h-5 w-px bg-border"}),r.jsxs(Ue,{children:[r.jsx(ze,{asChild:!0,children:r.jsx(Ed,{onClick:Bn,"aria-label":e(_f[d]),disabled:!Pc,children:r.jsxs("span",{className:"flex items-center justify-center animate-device-icon-pop",children:[d==="mobile"&&r.jsx(Wv,{size:16}),d==="tablet"&&r.jsx(qv,{size:16}),d==="desktop"&&r.jsx(Gv,{size:16})]},d)})}),r.jsx(Ke,{side:"top",children:e(_f[d])})]})]})}):null;return r.jsxs("div",{className:"flex flex-col w-full h-full",children:[Ae&&Object.entries(_e).map(([he,Ve])=>(Pe[he]??"")===""?r.jsx(mE,{source:Ve[0],template:k,paramName:he,sandboxRef:Ae,onFill:ct=>Ec(he,ct)},`${je}:${he}`):null),ls&&Je.kind==="iframe"&&r.jsx("div",{className:"relative flex h-12 shrink-0 items-center gap-4 border-b border-border/60 px-3 md:px-4",children:Je.kind==="iframe"&&r.jsxs("div",{className:"flex h-full w-full items-center justify-between gap-2",children:[r.jsxs(le,{variant:"outline",size:"sm","data-testid":"preview-blocks-toggle",onClick:()=>We("blocks"),"aria-pressed":l==="blocks","aria-label":e("sandbox.preview.blocksEditor"),children:[r.jsx(Yv,{size:14}),e("sandbox.preview.blocks")]}),r.jsxs("div",{className:"flex w-full min-w-0 max-w-[500px] items-center gap-0.5",children:[r.jsxs(Ue,{children:[r.jsx(ze,{asChild:!0,children:r.jsx(le,{variant:"ghost",size:"icon",onClick:Ge,"aria-label":e("sandbox.preview.refresh"),children:r.jsx(dr,{size:14})})}),r.jsx(Ke,{side:"bottom",children:e("sandbox.preview.refresh")})]}),r.jsxs("div",{ref:L,className:"relative min-w-0 flex-1",children:[r.jsxs("div",{className:"flex h-8 w-full min-w-0 items-center rounded-md border border-border bg-background transition-colors duration-200 hover:bg-accent",children:[r.jsxs("div",{className:"flex h-full min-w-0 flex-1 cursor-pointer items-center gap-1 pl-2 pr-1",onClick:()=>b(he=>!he),children:[N&&r.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:[r.jsx(gn,{size:11}),"Global"]}),r.jsx("span",{className:ie("text-[13px] font-medium text-foreground",Fe==null?"min-w-0 flex-1 truncate":"shrink-0"),children:Fe??T5}),!N&&Fe!=null&&k&&r.jsx("span",{className:"flex min-w-0 flex-1 items-center overflow-hidden whitespace-nowrap text-[12px] text-muted-foreground",children:yl(k).map((he,Ve)=>{if(he.type==="text")return r.jsx("span",{className:ie(Ve===0?"min-w-0 truncate":"shrink-0"),children:he.text},`text-${Ve}`);const ct=_e[he.name];return ct&&Ae?r.jsx(hE,{sources:ct,template:k,paramName:he.name,value:Pe[he.name]??"",sandboxRef:Ae,onCommit:bt=>Ec(he.name,bt)},`${je}:${he.name}`):r.jsx(pE,{name:he.name,value:Pe[he.name]??"",onCommit:bt=>Ec(he.name,bt)},`${je}:${he.name}`)})})]}),r.jsx("button",{type:"button",className:"flex h-full shrink-0 items-center pl-1 pr-2",onClick:()=>b(he=>!he),"aria-label":e("sandbox.preview.choosePage"),children:r.jsx(ss,{size:12,className:ie("shrink-0 text-muted-foreground transition-transform",v&&"rotate-180")})})]}),v&&r.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:[r.jsxs("div",{className:"px-2 h-10 flex items-center gap-2 border-b",children:[r.jsx(g9,{size:14,className:"shrink-0 text-muted-foreground","aria-hidden":!0}),r.jsx("input",{type:"text",value:y,onChange:he=>_(he.target.value),onKeyDown:he=>{if(he.key!=="Enter")return;const Ve=y.trim();if(!Ve)return;const ct=pe.find(bt=>fe(bt.path)===fe(Ve));ct&&(he.preventDefault(),b(!1),_(""),Ac(ct))},placeholder:e("sandbox.preview.searchPagesAndComponents"),className:"w-full bg-transparent text-sm outline-none placeholder:text-muted-foreground",autoFocus:!0})]}),r.jsx("div",{className:"p-1.5 border-b",children:r.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:he=>{he.preventDefault(),b(!1),_(""),C(void 0),j(!0)},children:[r.jsx(kt,{size:16,className:"shrink-0 text-muted-foreground"}),r.jsx("span",{className:"flex-1 font-medium",children:e("sandbox.preview.createNewPage")})]})}),pe.length===0&&we.length===0?r.jsx("div",{className:"px-4 py-5 text-center text-xs text-muted-foreground",children:ce.length===0&&oe.length===0?e("sandbox.preview.noPagesFound"):e("sandbox.preview.noSearchResults")}):r.jsxs("div",{className:"max-h-80 overflow-y-auto overscroll-contain",children:[pe.length>0&&r.jsx("div",{className:"p-1.5",children:pe.map(he=>r.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:Ve=>{Ve.preventDefault(),b(!1),_(""),Ac(he)},children:[r.jsx(Nn,{size:16,className:"shrink-0 text-muted-foreground"}),r.jsx("span",{className:"min-w-0 flex-1 truncate font-medium",children:he.name}),r.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:he.path})]},he.key))}),we.length>0&&r.jsxs("div",{className:ie("p-1.5",pe.length>0&&"border-t"),children:[r.jsx("div",{className:"px-3 py-2 text-xs font-medium text-muted-foreground",children:e("sandbox.preview.globalComponents")}),we.map(he=>r.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:Ve=>{Ve.preventDefault(),b(!1),_(""),A5(he)},children:[r.jsx(gn,{size:16,className:"shrink-0 text-muted-foreground"}),r.jsx("span",{className:"min-w-0 flex-1 truncate font-medium",children:he.name}),r.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:he.resolveType.split("/").pop()?.replace(/\.tsx?$/,"")})]},he.key))]})]})]})]}),r.jsxs(Ue,{children:[r.jsx(ze,{asChild:!0,children:r.jsx(le,{variant:"ghost",size:"icon",onClick:()=>{const he=st??Je.previewUrl;he&&window.open(he,"_blank","noopener")},"aria-label":e("sandbox.preview.openInNewTab"),children:r.jsx(Dn,{size:14})})}),r.jsx(Ke,{side:"bottom",children:e("sandbox.preview.openInNewTab")})]})]}),r.jsx("div",{className:"flex shrink-0 items-center",children:r.jsxs(us,{children:[r.jsx(ds,{asChild:!0,children:r.jsx(le,{variant:"ghost",size:"icon","aria-label":e("sandbox.preview.moreOptions"),children:r.jsx(oi,{size:14})})}),r.jsxs(hs,{align:"end",className:"w-44",children:[r.jsx(Xe,{onClick:wt,children:e("sandbox.preview.hardReload")}),r.jsx(Xe,{onClick:di,children:e("sandbox.preview.copyCurrentUrl")}),ne&&de&&r.jsxs(r.Fragment,{children:[r.jsx(rr,{}),je&&r.jsxs(Xe,{onClick:()=>{o.editSeo({kind:"page",key:je,path:k}),Te("blocks")},children:[r.jsx(sl,{size:14}),e("sandbox.preview.editSeo")]}),je&&r.jsxs(Xe,{onClick:()=>{try{a(ib(I6(je)))}catch{ge.error(e("sandbox.preview.invalidPageBlockKey"))}},children:[r.jsx(ea,{size:14}),e("sandbox.preview.viewJson")]}),r.jsxs(Xe,{onClick:()=>Y(!0),children:[r.jsx(sl,{size:14}),e("sandbox.preview.siteSeo")]})]}),te&&r.jsxs(r.Fragment,{children:[r.jsx(rr,{}),r.jsxs(Xe,{onClick:()=>window.open(Pl("vscode",te)),children:[r.jsx("img",{src:RE,alt:"VSCode",width:14,height:14}),e("sandbox.preview.openInVscode")]}),r.jsxs(Xe,{onClick:()=>window.open(Pl("cursor",te)),children:[r.jsx("img",{src:DE,alt:"Cursor",width:14,height:14}),e("sandbox.preview.openInCursor")]})]})]})]})})]})}),r.jsx("div",{className:"flex-1 overflow-hidden",children:s&&Vt==="blocks"?r.jsxs("div",{className:"relative h-full min-h-0 overflow-hidden",children:[r.jsx(vf,{virtualMcpId:t,externalSelectedIndex:m}),Iu]}):r.jsxs(e2,{direction:"horizontal",children:[r.jsx(il,{ref:x,id:"preview-blocks-editor",order:1,defaultSize:Vt==="blocks"?30:0,minSize:20,collapsible:!0,collapsedSize:0,className:"min-w-0 overflow-hidden",children:Vt==="blocks"&&r.jsx(vf,{virtualMcpId:t,externalSelectedIndex:m})}),r.jsx(t2,{withHandle:!0,className:ie(Vt!=="blocks"&&"hidden")}),r.jsx(il,{id:"preview-canvas",order:2,defaultSize:Vt==="blocks"?60:100,minSize:35,className:"min-w-0 overflow-hidden",children:r.jsxs("div",{className:ie("h-full relative overflow-hidden",d!=="desktop"&&Je.kind==="iframe"&&"flex justify-center bg-muted/30"),children:[O&&Je.kind==="iframe"&&r.jsx("div",{className:"absolute inset-x-0 top-0 z-40 h-0.5 overflow-hidden bg-primary/15",children:r.jsx("div",{className:"absolute inset-y-0 w-2/5 rounded-full bg-primary animate-preview-nav"})}),dt&&r.jsx("div",{className:"absolute inset-0 z-30",children:r.jsx(gi,{kind:"starting",progress:pt,claimPhase:nt})}),Je.kind==="othersThread"&&r.jsx("div",{className:"absolute inset-0 z-30",children:r.jsx(gi,{kind:"othersThread",label:Je.label,onContinue:H.acknowledgeOthersThread,onStartNewThread:()=>n({to:"/$org/$taskId",params:{org:U.slug,taskId:crypto.randomUUID()},search:he=>({...he,sidepanel:"chat"})})})}),Je.kind==="suspended"&&r.jsx("div",{className:"absolute inset-0 z-30",children:r.jsx(gi,{kind:"suspended",onResume:H.resume})}),Je.kind==="errored"&&r.jsx("div",{className:"absolute inset-0 z-30",children:r.jsx(gi,{kind:"errored",error:Je.error,onRetry:H.retry,connectionsHref:`/${U.slug}/settings/connections`})}),Vt==="visual"&&!u&&r.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:[r.jsx(Uu,{size:12}),e("sandbox.preview.clickElementToAsk")]}),Vt==="visual"&&u&&r.jsx(kA,{element:u,onDismiss:()=>f(null)}),Iu,Je.kind==="iframe"&&st&&r.jsx("div",{className:ie("h-full transition-[width] duration-250 [transition-timing-function:var(--ease-in-out-cubic)]",d!=="desktop"&&"w-full max-w-full border-x border-border bg-background shadow-sm"),style:{width:d==="desktop"?"100%":`${ME[d]}px`},children:r.jsx("iframe",{ref:g,src:st,className:"w-full h-full border-0",title:e("sandbox.preview.devServerPreviewTitle"),onLoad:()=>{if(K(),Me("vm_preview_loaded",{view_mode:l,vm_id:X?.sandboxHandle??null}),!N)try{const he=g.current?.contentWindow?.location?.pathname;if(!he)return;const Ve=Se.current;if(Ve!==null&&(Se.current=null,fe(he)!==fe(Ve))||fe(he)===fe(Ye))return;R(he),me({path:he,pageKey:P,params:Pe})}catch{}l==="visual"&&Ut(),l==="blocks"&&He()}},Je.previewUrl)})]})})]})}),r.jsx(oA,{open:w,onOpenChange:j,isPending:ue.isPending,error:S,templates:ce,onSubmit:E5}),G&&ne&&de&&r.jsx(A.Suspense,{fallback:null,children:r.jsx(IE,{open:G,onOpenChange:Y,orgSlug:U.slug,virtualMcpId:t??"",branch:i??"",decofile:ne,meta:de,onSaved:()=>{setTimeout(()=>{const he=g.current;he&&yf(he,ke.current)},bf)},target:{kind:"site"}})})]})}function $E(t){const e=F.c(22),{virtualMcpId:s}=t,n=re(),i=gs(s),{activeTask:o}=Zt(),[a,l]=A.useState(!1);if(!(sn(i?.metadata)||sn(o?.metadata))){let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx("div",{className:"flex size-14 items-center justify-center rounded-full bg-muted",children:r.jsx(Mo,{className:"size-7 text-foreground"})}),e[0]=h):h=e[0];let u;e[1]!==n?(u=n("mainPanelTabs.previewTab.noSourceToPreview"),e[1]=n,e[2]=u):u=e[2];let f;e[3]!==n?(f=n("mainPanelTabs.previewTab.connectGithubDescription"),e[3]=n,e[4]=f):f=e[4];let m,p;e[5]===Symbol.for("react.memo_cache_sentinel")?(m=()=>l(!0),p=r.jsx(Mo,{className:"size-4"}),e[5]=m,e[6]=p):(m=e[5],p=e[6]);let g;e[7]!==n?(g=n("mainPanelTabs.previewTab.connectGithub"),e[7]=n,e[8]=g):g=e[8];let x;e[9]!==g?(x=r.jsxs(le,{onClick:m,children:[p,g]}),e[9]=g,e[10]=x):x=e[10];let v;e[11]!==u||e[12]!==f||e[13]!==x?(v=r.jsx(ki,{className:"h-full",image:h,title:u,description:f,actions:x}),e[11]=u,e[12]=f,e[13]=x,e[14]=v):v=e[14];let b;e[15]!==a?(b=r.jsx(v2,{open:a,onOpenChange:l,mode:"agent"}),e[15]=a,e[16]=b):b=e[16];let y;return e[17]!==v||e[18]!==b?(y=r.jsxs(r.Fragment,{children:[v,b]}),e[17]=v,e[18]=b,e[19]=y):y=e[19],y}let d;return e[20]!==s?(d=r.jsx(BE,{virtualMcpId:s}),e[20]=s,e[21]=d):d=e[21],d}const FE="https://decoims.com/decocms/01b321bd-4613-4b2c-9348-35058444d210/Visual_Studio_Code_1.35_icon.svg.png",zE="https://decoims.com/decocms/7583d3b5-81d0-4afb-becf-6a59bbb3a68e/cursor-logo-icon-freelogovectors.net_.png",KE=A.lazy(()=>Bs(()=>import("./file-explorer-Dd9gHOUu.js"),__vite__mapDeps([157,1,2,90,4,5,6,7,8,9,10,11,12,13,14,15,16,17,3,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,91,92,93,94,95,96,97,98,99,100,101,102,139,138,140,141,135,128,111,103,107,108,109,110,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,129,130,131,132,133,134,136,137,142,143,144,145,146,147,148,149,150,105,151,152,153,154,155])).then(t=>({default:t.FileExplorer})));function UE(t){const e=F.c(21),{openPath:s}=t,n=re(),i=ci(),{org:o}=Oe(),{currentBranch:a}=Zt(),l=i?.entity?.id??null,c=Er(),d=Fs(),h=c.vmEntry,u=d.lifecycle.phase==="running",f=h?.sandboxProviderKind==="user-desktop",m=l??"",p=a??"",g=f&&u&&!!l&&!!a;let x;e[0]!==o.slug||e[1]!==m||e[2]!==p||e[3]!==g?(x={orgSlug:o.slug,virtualMcpId:m,branch:p,enabled:g},e[0]=o.slug,e[1]=m,e[2]=p,e[3]=g,e[4]=x):x=e[4];const v=Bg(x),b=f?v:null;if(!l||!a){let j;e[5]!==n?(j=n("mainPanelTabs.codeTab.noSandboxToBrowse"),e[5]=n,e[6]=j):j=e[6];let S;return e[7]!==j?(S=r.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:j}),e[7]=j,e[8]=S):S=e[8],S}let y;e[9]!==b||e[10]!==n?(y=b&&r.jsx("div",{className:"relative flex h-12 shrink-0 items-center border-b border-border/60 px-3 md:px-4",children:r.jsxs("div",{className:"ml-auto flex shrink-0 items-center gap-0.5",children:[r.jsxs(Ue,{children:[r.jsx(ze,{asChild:!0,children:r.jsx(le,{variant:"ghost",size:"icon","aria-label":n("mainPanelTabs.codeTab.openInVscode"),onClick:()=>window.open(Pl("vscode",b)),children:r.jsx("img",{src:FE,alt:"VSCode",width:14,height:14})})}),r.jsx(Ke,{side:"bottom",children:n("mainPanelTabs.codeTab.openInVscode")})]}),r.jsxs(Ue,{children:[r.jsx(ze,{asChild:!0,children:r.jsx(le,{variant:"ghost",size:"icon","aria-label":n("mainPanelTabs.codeTab.openInCursor"),onClick:()=>window.open(Pl("cursor",b)),children:r.jsx("img",{src:zE,alt:"Cursor",width:14,height:14})})}),r.jsx(Ke,{side:"bottom",children:n("mainPanelTabs.codeTab.openInCursor")})]})]})}),e[9]=b,e[10]=n,e[11]=y):y=e[11];let _;e[12]===Symbol.for("react.memo_cache_sentinel")?(_=r.jsx("div",{className:"h-full flex items-center justify-center",children:r.jsx(et,{size:20,className:"animate-spin text-muted-foreground"})}),e[12]=_):_=e[12];let L;e[13]!==a||e[14]!==s||e[15]!==o.slug||e[16]!==l?(L=r.jsx("div",{className:"flex-1 relative overflow-hidden bg-background",children:r.jsx(A.Suspense,{fallback:_,children:r.jsx(KE,{orgSlug:o.slug,virtualMcpId:l,branch:a,openPath:s})})}),e[13]=a,e[14]=s,e[15]=o.slug,e[16]=l,e[17]=L):L=e[17];let w;return e[18]!==y||e[19]!==L?(w=r.jsxs("div",{className:"flex flex-col w-full h-full",children:[y,L]}),e[18]=y,e[19]=L,e[20]=w):w=e[20],w}function HE(t){return gs(t)?.metadata?.runtime?.path??null}function WE(t,e){if(!t||!e?.length)return t;const s=Object.fromEntries(Object.entries(t.properties??{}).filter(([n])=>!e.includes(n)));return Object.keys(s).length>0?{...t,properties:s}:t}function qE(t,e,s){return typeof t!="string"?null:WE(yn(t,e),s)}function Fg(t,e,s){if(!e||typeof t!="string")return!1;const n=qE(t,e,s);return!!n&&Object.keys(n.properties??{}).length>0}function GE({orgSlug:t,virtualMcpId:e,branch:s}){const n=Ls(),i=gs(e)?.metadata?.runtime?.path??null;return Ys({mutationFn:async({blockKey:o})=>{const a=Pr(i,Zm(o)),l=await fetch(`/api/${t}/sandbox/${encodeURIComponent(e)}/${encodeURIComponent(s)}/unlink`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({path:a})});if(!l.ok){const c=await l.json().catch(()=>({}));throw new Error(c.error??`Delete failed (${l.status})`)}return l.json()},onMutate:async({blockKey:o})=>{const a=`${t}/${e}/${s}`,l=at.decofile(a);await n.cancelQueries({queryKey:l});const c=n.getQueryData(l);return n.setQueryData(l,d=>{if(!d)return d;const{[o]:h,...u}=d;return u}),{previous:c,queryKey:l}},onError:(o,a,l)=>{l?.queryKey&&n.setQueryData(l.queryKey,l.previous)},onSuccess:()=>{n.invalidateQueries({queryKey:at.liveMeta(t,e,s)})}})}function Ji(t){const e=F.c(6),{hasItems:s,emptyLabel:n,emptyHint:i}=t;let o;e[0]!==i||e[1]!==n||e[2]!==s?(o=s?"No results match your search.":r.jsxs(r.Fragment,{children:[r.jsx("div",{children:n}),r.jsx("div",{className:"mt-1 text-muted-foreground/80",children:i})]}),e[0]=i,e[1]=n,e[2]=s,e[3]=o):o=e[3];let a;return e[4]!==o?(a=r.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 wc(t,e){return`${t}-${e}`}function zg(t,e){return`site/apps/${t}/${e}.ts`}function Kg(t){const e=t.match(/^site\/apps\/([^/]+)\/([^/.]+)\.tsx?$/);if(e)return{vendor:e[1],app:e[2]};const s=t.match(/^([^/]+)\/apps\/([^/.]+)\.tsx?$/);return s?{vendor:s[1],app:s[2]}:null}function YE(t){const e=t.match(/^([^-]+)-(.+)$/);return e?{vendor:e[1],app:e[2]}:null}function JE(t){return t==="local"?"Custom":"Installed"}function Ug(t,e,s){const n=new Set([wc(t,e),e].map(o=>o.toLowerCase())),i=zg(t,e);for(const[o,a]of Object.entries(s)){if(o.includes("/")||!a||typeof a!="object"||Array.isArray(a))continue;const l=a;if(n.has(o.toLowerCase())||l.__resolveType===i)return o}return null}function XE(t,e){const s=t.vendor.alias,n=t.name,i=Ug(s,n,e);return{id:wc(s,n),app:n,vendor:s,title:t.title||t.name,description:t.description,category:t.category??"Other",logo:t.logo||void 0,resolveType:zg(s,n),blockKey:i,installed:i!==null}}function QE(t,e,s){if(t===D9)return null;const n=Kg(t);if(!n)return null;const{vendor:i,app:o}=n,a=Ug(i,o,s),l=li(t,e);return{id:wc(i,o),app:o,vendor:i,title:l.title??o,description:l.description??"",category:"Others",logo:l.logo??l.icon,resolveType:t,blockKey:a,installed:a!==null}}function ZE(t,e,s){const n=e.__resolveType;if(typeof n!="string"||Ll(t,e)||!Tp(n))return null;const i=Kg(n)??YE(t);if(!i)return null;const o=li(n,s),{vendor:a,app:l}=i;return{id:wc(a,l),app:l,vendor:a,title:o.title??Sl(t,e,s),description:o.description??"",category:JE(a),logo:o.logo??o.icon,resolveType:n,blockKey:t,installed:!0}}function eP(t,e,s){const n=new Map;for(const o of t){const a=XE(o,s);n.set(a.id,a)}const i=e.manifest?.blocks?.apps??{};for(const o of Object.keys(i)){const a=QE(o,e,s);!a||n.has(a.id)||n.set(a.id,a)}for(const[o,a]of Object.entries(s)){if(o.includes("/")||!a||typeof a!="object"||Array.isArray(a))continue;const l=ZE(o,a,e);!l||n.has(l.id)||n.set(l.id,l)}return[...n.values()].sort(tP)}function tP(t,e){return t.installed!==e.installed?t.installed?-1:1:t.title.localeCompare(e.title)}async function sP(){const t=await fetch("/api/deco-apps");if(!t.ok)throw new Error(`Failed to fetch deco apps: ${t.status}`);return(await t.json()).apps??[]}function nP(t,e,s){const n=F.c(12),i=s?.enabled??!0;let o;n[0]===Symbol.for("react.memo_cache_sentinel")?(o=at.decoApps(),n[0]=o):o=n[0];let a;n[1]!==i?(a={queryKey:o,queryFn:sP,staleTime:3e5,retry:1,enabled:i},n[1]=i,n[2]=a):a=n[2];const l=Mt(a);let c;n[3]!==e||n[4]!==t||n[5]!==l.data?(c=t&&e?eP(l.data??[],t,e):[],n[3]=e,n[4]=t,n[5]=l.data,n[6]=c):c=n[6];const d=c,h=l.isLoading&&!l.isError;let u;return n[7]!==d||n[8]!==l.isError||n[9]!==l.refetch||n[10]!==h?(u={catalog:d,isLoading:h,isError:l.isError,refetch:l.refetch},n[7]=d,n[8]=l.isError,n[9]=l.refetch,n[10]=h,n[11]=u):u=n[11],u}function Hg(t){return(e,s)=>{M6(e),t(e,s)}}function iP(t){const e=F.c(86),{active:s,counts:n,showBlog:i,onSelect:o}=t,a=re();let l;e[0]!==a?(l=a("sandbox.collectionsSidebar.content"),e[0]=a,e[1]=l):l=e[1];let c;e[2]!==l?(c=r.jsx("div",{className:"px-3 h-12 flex items-center border-b shrink-0",children:r.jsx("span",{className:"text-sm font-medium",children:l})}),e[2]=l,e[3]=c):c=e[3];let d;e[4]!==a?(d=a("sandbox.collectionsSidebar.pages"),e[4]=a,e[5]=d):d=e[5];const h=s==="pages";let u;e[6]!==n.pages||e[7]!==o||e[8]!==d||e[9]!==h?(u=r.jsx(zs,{id:"pages",icon:Nn,label:d,count:n.pages,active:h,onSelect:o}),e[6]=n.pages,e[7]=o,e[8]=d,e[9]=h,e[10]=u):u=e[10];let f;e[11]!==a?(f=a("sandbox.collectionsSidebar.sections"),e[11]=a,e[12]=f):f=e[12];const m=s==="sections";let p;e[13]!==n.sections||e[14]!==o||e[15]!==f||e[16]!==m?(p=r.jsx(zs,{id:"sections",icon:gn,label:f,count:n.sections,active:m,onSelect:o}),e[13]=n.sections,e[14]=o,e[15]=f,e[16]=m,e[17]=p):p=e[17];let g;e[18]!==a?(g=a("sandbox.collectionsSidebar.apps"),e[18]=a,e[19]=g):g=e[19];const x=s==="apps";let v;e[20]!==n.apps||e[21]!==o||e[22]!==x||e[23]!==g?(v=r.jsx(zs,{id:"apps",icon:L2,label:g,count:n.apps,active:x,onSelect:o}),e[20]=n.apps,e[21]=o,e[22]=x,e[23]=g,e[24]=v):v=e[24];let b;e[25]!==a?(b=a("sandbox.collectionsSidebar.redirects"),e[25]=a,e[26]=b):b=e[26];const y=s==="redirects";let _;e[27]!==n.redirects||e[28]!==o||e[29]!==b||e[30]!==y?(_=r.jsx(zs,{id:"redirects",icon:zm,label:b,count:n.redirects,active:y,onSelect:o}),e[27]=n.redirects,e[28]=o,e[29]=b,e[30]=y,e[31]=_):_=e[31];let L;e[32]!==a?(L=a("sandbox.collectionsSidebar.loaders"),e[32]=a,e[33]=L):L=e[33];const w=s==="loaders";let j;e[34]!==n.loaders||e[35]!==o||e[36]!==L||e[37]!==w?(j=r.jsx(zs,{id:"loaders",icon:nl,label:L,count:n.loaders,active:w,onSelect:o}),e[34]=n.loaders,e[35]=o,e[36]=L,e[37]=w,e[38]=j):j=e[38];let S;e[39]!==a?(S=a("sandbox.collectionsSidebar.actions"),e[39]=a,e[40]=S):S=e[40];const C=s==="actions";let N;e[41]!==n.actions||e[42]!==o||e[43]!==S||e[44]!==C?(N=r.jsx(zs,{id:"actions",icon:Ni,label:S,count:n.actions,active:C,onSelect:o}),e[41]=n.actions,e[42]=o,e[43]=S,e[44]=C,e[45]=N):N=e[45];let V;e[46]!==a?(V=a("sandbox.collectionsSidebar.site"),e[46]=a,e[47]=V):V=e[47];const E=s==="site";let T;e[48]!==o||e[49]!==V||e[50]!==E?(T=r.jsx(zs,{id:"site",icon:Fm,label:V,active:E,onSelect:o}),e[48]=o,e[49]=V,e[50]=E,e[51]=T):T=e[51];let k;e[52]!==a?(k=a("sandbox.collectionsSidebar.seo"),e[52]=a,e[53]=k):k=e[53];const R=s==="seo";let P;e[54]!==o||e[55]!==k||e[56]!==R?(P=r.jsx(zs,{id:"seo",icon:sl,label:k,active:R,onSelect:o}),e[54]=o,e[55]=k,e[56]=R,e[57]=P):P=e[57];let D;e[58]!==a?(D=a("sandbox.collectionsSidebar.calendar"),e[58]=a,e[59]=D):D=e[59];const I=s==="calendar";let M;e[60]!==o||e[61]!==D||e[62]!==I?(M=r.jsx(zs,{id:"calendar",icon:Z0,label:D,active:I,onSelect:o}),e[60]=o,e[61]=D,e[62]=I,e[63]=M):M=e[63];let O;e[64]!==s||e[65]!==n.authors||e[66]!==n.categories||e[67]!==n.posts||e[68]!==o||e[69]!==i||e[70]!==a?(O=i&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"mt-3 flex items-center gap-1.5 px-2.5 pb-1 pt-1 text-xs font-medium text-muted-foreground/70",children:[r.jsx(fr,{size:13,className:"shrink-0"}),a("sandbox.collectionsSidebar.blog")]}),r.jsx(zs,{id:"posts",icon:mr,label:a("sandbox.collectionsSidebar.posts"),count:n.posts,active:s==="posts",onSelect:o}),r.jsx(zs,{id:"authors",icon:ec,label:a("sandbox.collectionsSidebar.authors"),count:n.authors,active:s==="authors",onSelect:o}),r.jsx(zs,{id:"categories",icon:Km,label:a("sandbox.collectionsSidebar.categories"),count:n.categories,active:s==="categories",onSelect:o})]}),e[64]=s,e[65]=n.authors,e[66]=n.categories,e[67]=n.posts,e[68]=o,e[69]=i,e[70]=a,e[71]=O):O=e[71];let $;e[72]!==v||e[73]!==_||e[74]!==j||e[75]!==N||e[76]!==T||e[77]!==P||e[78]!==M||e[79]!==O||e[80]!==u||e[81]!==p?($=r.jsxs("nav",{className:"flex flex-col p-1.5 gap-0.5",children:[u,p,v,_,j,N,T,P,M,O]}),e[72]=v,e[73]=_,e[74]=j,e[75]=N,e[76]=T,e[77]=P,e[78]=M,e[79]=O,e[80]=u,e[81]=p,e[82]=$):$=e[82];let B;return e[83]!==c||e[84]!==$?(B=r.jsxs("div",{className:"w-[208px] shrink-0 border-r flex flex-col",children:[c,$]}),e[83]=c,e[84]=$,e[85]=B):B=e[85],B}function zs(t){const e=F.c(18),{id:s,icon:n,label:i,count:o,active:a,onSelect:l}=t;let c;e[0]!==s||e[1]!==l?(c=()=>l(s),e[0]=s,e[1]=l,e[2]=c):c=e[2];const d=a?"bg-accent text-accent-foreground":"text-muted-foreground hover:bg-muted hover:text-foreground";let h;e[3]!==d?(h=ie("flex w-full items-center gap-2 rounded-md px-2.5 py-1.5 text-left text-sm transition-colors cursor-pointer",d),e[3]=d,e[4]=h):h=e[4];let u;e[5]!==n?(u=r.jsx(n,{size:16,className:"shrink-0"}),e[5]=n,e[6]=u):u=e[6];let f;e[7]!==i?(f=r.jsx("span",{className:"flex-1 truncate",children:i}),e[7]=i,e[8]=f):f=e[8];let m;e[9]!==a||e[10]!==o?(m=o!==void 0&&r.jsx("span",{className:ie("shrink-0 text-xs tabular-nums",a?"text-accent-foreground/70":"text-muted-foreground/70"),children:o}),e[9]=a,e[10]=o,e[11]=m):m=e[11];let p;return e[12]!==c||e[13]!==h||e[14]!==u||e[15]!==f||e[16]!==m?(p=r.jsxs("button",{type:"button",onClick:c,className:h,children:[u,f,m]}),e[12]=c,e[13]=h,e[14]=u,e[15]=f,e[16]=m,e[17]=p):p=e[17],p}function rP(t){const e=F.c(12),{state:s,claimPhase:n,lifecycle:i,onStart:o,connectionsHref:a}=t;switch(s.kind){case"starting":{let l;e[0]!==n||e[1]!==i?(l=wg({claimPhase:n,lifecycle:i}),e[0]=n,e[1]=i,e[2]=l):l=e[2];let c;return e[3]!==n||e[4]!==l?(c=r.jsx(gi,{kind:"starting",progress:l,claimPhase:n}),e[3]=n,e[4]=l,e[5]=c):c=e[5],c}case"suspended":{let l;return e[6]!==o?(l=r.jsx(gi,{kind:"suspended",onResume:o}),e[6]=o,e[7]=l):l=e[7],l}case"errored":{let l;return e[8]!==a||e[9]!==o||e[10]!==s.error?(l=r.jsx(gi,{kind:"errored",error:s.error,onRetry:o,connectionsHref:a}),e[8]=a,e[9]=o,e[10]=s.error,e[11]=l):l=e[11],l}}}function Lf(t,e){const s=e.replace(/\s*\(copy(?:\s+\d+)?\)\s*$/,"").trim(),n=`${s} (copy)`;if(!t.has(n))return n;for(let i=2;i<1e3;i++){const o=`${s} (copy ${i})`;if(!t.has(o))return o}return`${s} (copy ${Date.now()})`}function oP(t,e){const s=Gn,n=e.replace(/-copy(?:-\d+)?$/,""),i=`${n}-copy`;if(!t.has(s(i)))return i;for(let o=2;o<1e3;o++){const a=`${n}-copy-${o}`;if(!t.has(s(a)))return a}return`${n}-copy-${Date.now()}`}function aP(t,e){const s=e.replace(/_copy(?:_\d+)?$/,""),n=`${s}_copy`;if(!Object.hasOwn(t,n))return n;for(let i=2;i<1e3;i++){const o=`${s}_copy_${i}`;if(!Object.hasOwn(t,o))return o}return`${s}_copy_${Date.now()}`}function lP(t){const e=lu(t.newName),s={...t.source,name:t.newName,path:t.newPath};return{key:e,data:s}}function cP(t,e){return mg(t,e)}const dP=1e3;function uP(t,e){for(let s=0;s<dP;s++){const n=lu(e);if(!Object.hasOwn(t,n))return n}throw new Error("Could not generate a unique page block key")}const hP={create:"sandbox.pageFormDialog.titleCreate",duplicate:"sandbox.pageFormDialog.titleDuplicate",rename:"sandbox.pageFormDialog.titleRename"},fP={create:"sandbox.pageFormDialog.submitCreate",duplicate:"sandbox.pageFormDialog.submitDuplicate",rename:"sandbox.pageFormDialog.submitSave"},mP={create:"sandbox.pageFormDialog.pendingCreate",duplicate:"sandbox.pageFormDialog.pendingDuplicate",rename:"sandbox.pageFormDialog.pendingSave"};function pP(t){const e=F.c(88),{open:s,mode:n,initialName:i,initialPath:o,isPending:a,error:l,templates:c,validate:d,onSubmit:h,onOpenChange:u}=t,f=a===void 0?!1:a,m=re(),[p,g]=A.useState(i),[x,v]=A.useState(o),[b,y]=A.useState(Yn),[_,L]=A.useState(null),[w,j]=A.useState(s);s!==w&&(j(s),s&&(g(i),v(o),y(Yn),L(null)));const S=n==="create"&&!!c?.length;let C;e[0]!==f||e[1]!==u?(C=ue=>{!ue&&!f&&(L(null),u(!1))},e[0]=f,e[1]=u,e[2]=C):C=e[2];const N=C;let V;e[3]!==f||e[4]!==p||e[5]!==h||e[6]!==x||e[7]!==S||e[8]!==b||e[9]!==d?(V=async ue=>{ue.preventDefault();const ce=p.trim(),oe=x.trim();if(!ce||!oe||f)return;const fe=P9(oe);if(fe){L(fe);return}const pe=d?.({name:ce,path:oe});if(pe){L(pe);return}L(null),await h({name:ce,path:oe,templateKey:S&&b!==Yn?b:null})},e[3]=f,e[4]=p,e[5]=h,e[6]=x,e[7]=S,e[8]=b,e[9]=d,e[10]=V):V=e[10];const E=V,T=_??l,k=hP[n];let R;e[11]!==m||e[12]!==k?(R=m(k),e[11]=m,e[12]=k,e[13]=R):R=e[13];let P;e[14]!==R?(P=r.jsx(ms,{children:r.jsx(ps,{children:R})}),e[14]=R,e[15]=P):P=e[15];let D;e[16]!==f||e[17]!==S||e[18]!==m||e[19]!==b||e[20]!==c?(D=S&&r.jsxs("div",{className:"space-y-1.5",children:[r.jsx("label",{htmlFor:"page-form-template",className:"text-xs font-medium text-muted-foreground",children:m("sandbox.pageFormDialog.labelTemplate")}),r.jsx(gg,{id:"page-form-template",value:b,onChange:y,templates:c??[],disabled:f})]}),e[16]=f,e[17]=S,e[18]=m,e[19]=b,e[20]=c,e[21]=D):D=e[21];let I;e[22]!==m?(I=m("sandbox.pageFormDialog.labelName"),e[22]=m,e[23]=I):I=e[23];let M;e[24]!==I?(M=r.jsx("label",{htmlFor:"page-form-name",className:"text-xs font-medium text-muted-foreground",children:I}),e[24]=I,e[25]=M):M=e[25];let O;e[26]===Symbol.for("react.memo_cache_sentinel")?(O=ue=>g(ue.target.value),e[26]=O):O=e[26];let $;e[27]!==m?($=m("sandbox.pageFormDialog.placeholderName"),e[27]=m,e[28]=$):$=e[28];let B;e[29]!==f||e[30]!==p||e[31]!==$?(B=r.jsx(rt,{id:"page-form-name",value:p,onChange:O,placeholder:$,autoFocus:!0,disabled:f}),e[29]=f,e[30]=p,e[31]=$,e[32]=B):B=e[32];let z;e[33]!==B||e[34]!==M?(z=r.jsxs("div",{className:"space-y-1.5",children:[M,B]}),e[33]=B,e[34]=M,e[35]=z):z=e[35];let K;e[36]!==m?(K=m("sandbox.pageFormDialog.labelPath"),e[36]=m,e[37]=K):K=e[37];let G;e[38]!==K?(G=r.jsx("label",{htmlFor:"page-form-path",className:"text-xs font-medium text-muted-foreground",children:K}),e[38]=K,e[39]=G):G=e[39];let Y;e[40]===Symbol.for("react.memo_cache_sentinel")?(Y=ue=>v(ue.target.value),e[40]=Y):Y=e[40];let U;e[41]!==m?(U=m("sandbox.pageFormDialog.placeholderPath"),e[41]=m,e[42]=U):U=e[42];let W;e[43]!==f||e[44]!==x||e[45]!==U?(W=r.jsx(rt,{id:"page-form-path",value:x,onChange:Y,placeholder:U,disabled:f}),e[43]=f,e[44]=x,e[45]=U,e[46]=W):W=e[46];let H;e[47]!==G||e[48]!==W?(H=r.jsxs("div",{className:"space-y-1.5",children:[G,W]}),e[47]=G,e[48]=W,e[49]=H):H=e[49];let X;e[50]!==T?(X=T&&r.jsx("p",{className:"text-xs text-destructive",children:T}),e[50]=T,e[51]=X):X=e[51];let q;e[52]!==z||e[53]!==H||e[54]!==X||e[55]!==D?(q=r.jsxs("div",{className:"space-y-4 py-4",children:[D,z,H,X]}),e[52]=z,e[53]=H,e[54]=X,e[55]=D,e[56]=q):q=e[56];let Z;e[57]!==u?(Z=()=>u(!1),e[57]=u,e[58]=Z):Z=e[58];let Q;e[59]!==m?(Q=m("sandbox.pageFormDialog.buttonCancel"),e[59]=m,e[60]=Q):Q=e[60];let ee;e[61]!==f||e[62]!==Z||e[63]!==Q?(ee=r.jsx(le,{type:"button",variant:"outline",onClick:Z,disabled:f,children:Q}),e[61]=f,e[62]=Z,e[63]=Q,e[64]=ee):ee=e[64];let J;e[65]!==f||e[66]!==p||e[67]!==x?(J=!p.trim()||!x.trim()||f,e[65]=f,e[66]=p,e[67]=x,e[68]=J):J=e[68];let te;e[69]!==f||e[70]!==n||e[71]!==m?(te=f?r.jsxs(r.Fragment,{children:[r.jsx(et,{size:14,className:"animate-spin"}),m(mP[n])]}):m(fP[n]),e[69]=f,e[70]=n,e[71]=m,e[72]=te):te=e[72];let se;e[73]!==J||e[74]!==te?(se=r.jsx(le,{type:"submit",disabled:J,children:te}),e[73]=J,e[74]=te,e[75]=se):se=e[75];let ne;e[76]!==ee||e[77]!==se?(ne=r.jsxs(Mi,{children:[ee,se]}),e[76]=ee,e[77]=se,e[78]=ne):ne=e[78];let de;e[79]!==E||e[80]!==q||e[81]!==ne||e[82]!==P?(de=r.jsx(es,{className:"sm:max-w-md",children:r.jsxs("form",{onSubmit:E,children:[P,q,ne]})}),e[79]=E,e[80]=q,e[81]=ne,e[82]=P,e[83]=de):de=e[83];let xe;return e[84]!==N||e[85]!==s||e[86]!==de?(xe=r.jsx(ts,{open:s,onOpenChange:N,children:de}),e[84]=N,e[85]=s,e[86]=de,e[87]=xe):xe=e[87],xe}function gP(t){const e=F.c(70),{open:s,blockKey:n,initialName:i,isPending:o,onSubmit:a,onOpenChange:l}=t,c=o===void 0?!1:o,d=re(),[h,u]=A.useState(i),[f,m]=A.useState(s);s!==f&&(m(s),s&&u(i));let p;e[0]!==c||e[1]!==l?(p=Y=>{!Y&&!c&&l(!1)},e[0]=c,e[1]=l,e[2]=p):p=e[2];const g=p;let x;e[3]!==c||e[4]!==h||e[5]!==a?(x=async Y=>{Y.preventDefault();const U=h.trim();!U||c||await a(U)},e[3]=c,e[4]=h,e[5]=a,e[6]=x):x=e[6];const v=x;let b;e[7]!==d?(b=d("sandbox.sectionRenameDialog.title"),e[7]=d,e[8]=b):b=e[8];let y;e[9]!==b?(y=r.jsx(ps,{children:b}),e[9]=b,e[10]=y):y=e[10];let _;e[11]!==d?(_=d("sandbox.sectionRenameDialog.description"),e[11]=d,e[12]=_):_=e[12];let L;e[13]!==_?(L=r.jsx(ri,{children:_}),e[13]=_,e[14]=L):L=e[14];let w;e[15]!==y||e[16]!==L?(w=r.jsxs(ms,{children:[y,L]}),e[15]=y,e[16]=L,e[17]=w):w=e[17];let j;e[18]!==d?(j=d("sandbox.sectionRenameDialog.nameLabel"),e[18]=d,e[19]=j):j=e[19];let S;e[20]!==j?(S=r.jsx("label",{htmlFor:"section-rename-name",className:"text-xs font-medium text-muted-foreground",children:j}),e[20]=j,e[21]=S):S=e[21];let C;e[22]===Symbol.for("react.memo_cache_sentinel")?(C=Y=>u(Y.target.value),e[22]=C):C=e[22];let N;e[23]!==c||e[24]!==h?(N=r.jsx(rt,{id:"section-rename-name",value:h,onChange:C,autoFocus:!0,disabled:c}),e[23]=c,e[24]=h,e[25]=N):N=e[25];let V;e[26]!==S||e[27]!==N?(V=r.jsxs("div",{className:"space-y-1.5",children:[S,N]}),e[26]=S,e[27]=N,e[28]=V):V=e[28];let E;e[29]!==d?(E=d("sandbox.sectionRenameDialog.keyLabel"),e[29]=d,e[30]=E):E=e[30];let T;e[31]!==E?(T=r.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:E}),e[31]=E,e[32]=T):T=e[32];let k;e[33]!==n?(k=r.jsx(rt,{value:n,readOnly:!0,disabled:!0,className:"font-mono"}),e[33]=n,e[34]=k):k=e[34];let R;e[35]!==T||e[36]!==k?(R=r.jsxs("div",{className:"space-y-1.5",children:[T,k]}),e[35]=T,e[36]=k,e[37]=R):R=e[37];let P;e[38]!==V||e[39]!==R?(P=r.jsxs("div",{className:"space-y-4 py-4",children:[V,R]}),e[38]=V,e[39]=R,e[40]=P):P=e[40];let D;e[41]!==l?(D=()=>l(!1),e[41]=l,e[42]=D):D=e[42];let I;e[43]!==d?(I=d("sandbox.sectionRenameDialog.cancel"),e[43]=d,e[44]=I):I=e[44];let M;e[45]!==c||e[46]!==D||e[47]!==I?(M=r.jsx(le,{type:"button",variant:"outline",onClick:D,disabled:c,children:I}),e[45]=c,e[46]=D,e[47]=I,e[48]=M):M=e[48];let O;e[49]!==c||e[50]!==h?(O=!h.trim()||c,e[49]=c,e[50]=h,e[51]=O):O=e[51];let $;e[52]!==c||e[53]!==d?($=c?r.jsxs(r.Fragment,{children:[r.jsx(et,{size:14,className:"animate-spin"}),d("sandbox.sectionRenameDialog.saving")]}):d("sandbox.sectionRenameDialog.save"),e[52]=c,e[53]=d,e[54]=$):$=e[54];let B;e[55]!==O||e[56]!==$?(B=r.jsx(le,{type:"submit",disabled:O,children:$}),e[55]=O,e[56]=$,e[57]=B):B=e[57];let z;e[58]!==M||e[59]!==B?(z=r.jsxs(Mi,{children:[M,B]}),e[58]=M,e[59]=B,e[60]=z):z=e[60];let K;e[61]!==v||e[62]!==P||e[63]!==z||e[64]!==w?(K=r.jsx(es,{className:"sm:max-w-md",children:r.jsxs("form",{onSubmit:v,children:[w,P,z]})}),e[61]=v,e[62]=P,e[63]=z,e[64]=w,e[65]=K):K=e[65];let G;return e[66]!==g||e[67]!==s||e[68]!==K?(G=r.jsx(ts,{open:s,onOpenChange:g,children:K}),e[66]=g,e[67]=s,e[68]=K,e[69]=G):G=e[69],G}function xP(t){const e=F.c(7),{type:s}=t,n=iw[s];let i;e[0]!==n?(i=r.jsx(ze,{asChild:!0,children:r.jsx("span",{className:"shrink-0 rounded-full bg-muted px-1.5 py-0.5 text-[10px] font-medium tabular-nums text-muted-foreground",children:n})}),e[0]=n,e[1]=i):i=e[1];const o=s==="permanent"?"Permanent":"Temporary";let a;e[2]!==o?(a=r.jsx(Ke,{side:"left",children:o}),e[2]=o,e[3]=a):a=e[3];let l;return e[4]!==i||e[5]!==a?(l=r.jsxs(Ue,{children:[i,a]}),e[4]=i,e[5]=a,e[6]=l):l=e[6],l}const nd={post:"blog/loaders/Blogpost.ts",author:"blog/loaders/Author.ts",category:"blog/loaders/Category.ts"},fu=["posts","authors","categories"],Lo={posts:"post",authors:"author",categories:"category"};function So(t){return fu.includes(t)}const mu={posts:"post",authors:"author",categories:"category"},Wg={posts:nd.post,authors:nd.author,categories:nd.category},vP=Object.fromEntries(Object.entries(Wg).map(([t,e])=>[e,t]));function bP(t){return typeof t=="string"?vP[t]??null:null}function si(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:null}function Pt(t){return typeof t=="string"?t:""}function _P(t,e){switch(t){case"posts":return{label:Pt(e.title)||"Untitled post",subtitle:Pt(e.slug)};case"authors":return{label:Pt(e.name)||"Unnamed author",subtitle:Pt(e.email)};case"categories":return{label:Pt(e.name)||"Unnamed category",subtitle:Pt(e.slug)};default:{const s=t;throw new Error(`Unhandled blog kind: ${String(s)}`)}}}function qg(t){const e={posts:[],authors:[],categories:[]};for(const[s,n]of Object.entries(t)){const i=si(n);if(!i)continue;const o=bP(i.__resolveType);if(!o)continue;const a=si(i[mu[o]])??{},{label:l,subtitle:c}=_P(o,a);e[o].push({key:s,kind:o,label:l,subtitle:c})}for(const s of fu)e[s].sort((n,i)=>n.label.localeCompare(i.label));return e}function yP(t,e){return qg(t)[e]}function Ko(t,e){return yP(t,e).map(s=>({key:s.key,payload:Wa(si(t[s.key])??void 0,e)}))}const Sf=Object.freeze({});function Wa(t,e){return t?si(t[mu[e]])??Sf:Sf}function Va(t,e,s){return{name:t,__resolveType:Wg[e],[mu[e]]:s}}function Gg(t){return`.deco/blocks/${encodeURIComponent(t)}.json`}function GH({records:t,selected:e,valueField:s,toRef:n}){const i=Array.isArray(e)?e:[],o=f=>typeof f=="string"?f:Pt(si(f)?.[s]),a=f=>typeof f=="string"?f:Pt(si(f)?.name),l=f=>{const m=o(f),p=m?t.find(({payload:x})=>Pt(x[s])===m):void 0;if(p)return p;const g=a(f);return g?t.find(({payload:x})=>Pt(x.name)===g):void 0},c=t.map(({key:f,payload:m})=>({value:f,label:Pt(m.name)||Pt(m[s])||f})),d=new Map,h=[];return i.forEach((f,m)=>{const p=l(f);if(p){h.includes(p.key)||h.push(p.key);return}const g=`unresolved:${m}`;d.set(g,f),h.push(g),c.push({value:g,label:a(f)||o(f)||"Unknown"})}),{options:c,selectedValues:h,refsForValues:f=>f.map(m=>{const p=t.find(g=>g.key===m);return p?n(p.payload):d.get(m)}).filter(m=>m!==void 0)}}function Ai(t){return Array.isArray(t)?t:[]}function An(t){if(typeof t=="string")return t;const e=si(t);return e?Pt(e.slug):""}function LP(t){if(typeof t=="string")return t;const e=si(t);return e?Pt(e.email):""}function SP(t){const e=[];return Pt(t.title).trim()||e.push("Title"),Pt(t.slug).trim()||e.push("Slug"),Ai(t.categories).map(An).filter(Boolean).length===0&&e.push("Category"),Pt(t.excerpt).trim()||e.push("Excerpt"),Pt(t.image).trim()||e.push("Cover image"),e}function Yg(t){return Ko(t,"posts").map(({key:e,payload:s})=>({key:e,title:Pt(s.title)||"Untitled post",slug:Pt(s.slug),date:Pt(s.date),categorySlugs:Ai(s.categories).map(An).filter(Boolean),authorEmails:Ai(s.authors).map(LP).filter(Boolean),missing:SP(s)}))}function wP(t,e){const s=Ai(t.categories);return s.some(n=>An(n)===e.slug)?t:{...t,categories:[...s,{name:e.name,slug:e.slug}]}}function jP(t,e){const s=Ai(t.categories);return s.length===1&&An(s[0])===e.slug?t:{...t,categories:[{name:e.name,slug:e.slug}]}}function YH(t,e,s){const n=Ai(t.categories);if(!n.some(l=>An(l)===e))return t;const i=n.map(l=>{const c=An(l);return c===e||c===s.slug?{name:s.name,slug:s.slug}:l}),o=new Set,a=i.filter(l=>{const c=An(l);return c?o.has(c)?!1:(o.add(c),!0):!0});return{...t,categories:a}}function CP(t,e){const s=Ai(t.categories);return s.some(n=>An(n)===e)?{...t,categories:s.filter(n=>An(n)!==e)}:t}function wf(t){return{...t,dateModified:new Date().toISOString()}}function Xd(t){const e=new Uint8Array(Math.ceil(t/2));return crypto.getRandomValues(e),Array.from(e,s=>s.toString(16).padStart(2,"0")).join("").slice(0,t)}function jf(t,e){const s=`collections/blog/${e}/${Xd(12)}`;if(!Object.hasOwn(t,s))return s;throw new Error("Could not generate a unique blog block key")}function kP(t){switch(t){case"posts":return{title:"Untitled post",excerpt:"",slug:`untitled-${Xd(8)}`,date:new Date().toISOString().slice(0,10),image:"",authors:[],categories:[],sections:[]};case"authors":return{name:"New author",type:"Person",email:"",jobTitle:"",company:"",avatar:""};case"categories":return{name:"New category",slug:`category-${Xd(8)}`,description:"",sections:[]};default:{const e=t;throw new Error(`Unhandled blog kind: ${String(e)}`)}}}const VP={Paragraph:{title:"Paragraph",description:"Rich text content",iconName:"Pilcrow01"},Heading:{title:"Heading",description:"Section title (H1–H6)",iconName:"HeadingSquare"},Quote:{title:"Quote",description:"Pull quote",iconName:"MessageTextSquare02"},Code:{title:"Code",description:"Code block with syntax highlighting",iconName:"Code02"},List:{title:"List",description:"Bulleted or numbered list",iconName:"List"},BlockImage:{title:"Image",description:"Image with optional caption",iconName:"Image01"},Video:{title:"Video",description:"Embedded video",iconName:"PlayCircle"},Divider:{title:"Divider",description:"Horizontal divider",iconName:"Divider"},Cta:{title:"Call to action",description:"Button linking to a URL",iconName:"CursorClick01"},Callout:{title:"Callout",description:"Highlighted note, tip or warning",iconName:"Lightbulb02"},Stat:{title:"Stat",description:"Single key metric",iconName:"BarChartSquareUp"},StatGroup:{title:"Stat group",description:"Row of metrics",iconName:"BarChartSquare02"},CardGroup:{title:"Card group",description:"Grid of cards",iconName:"LayoutGrid01"},Checklist:{title:"Checklist",description:"List of check items",iconName:"CheckSquare"},Steps:{title:"Steps",description:"Step-by-step guide",iconName:"LayersThree01"},Comparison:{title:"Comparison",description:"Side-by-side comparison",iconName:"Columns03"},Table:{title:"Table",description:"Rows and columns of structured data",iconName:"Table"},ProductCard:{title:"Product card",description:"Single product",iconName:"Tag01"},ProductShelf:{title:"Product shelf",description:"Row of products",iconName:"ShoppingBag01"}},Cf="Box";function NP(t){return t.startsWith("site/")?"site":"app"}function TP(t){return t.startsWith("http://")||t.startsWith("https://")||t.startsWith("data:")||t.startsWith("/")}function Gr(...t){for(const e of t)if(e!==void 0)return e}function JH(t){const e=new Set,s=[],n=t.manifest?.blocks??{};for(const i of Object.values(n))for(const o of Object.keys(i)){if(!PP(o)||e.has(o))continue;e.add(o);const a=li(o,t),l=AP(o),c=VP[l],d=NP(o),h=(d==="site"?Gr(a.title,c?.title):Gr(c?.title,a.title))??l,u=d==="site"?Gr(a.description,c?.description):Gr(c?.description,a.description),f=d==="site"?a.icon:void 0,m=f&&TP(f)?f:void 0,p=m!==void 0?c?.iconName??Cf:Gr(f,c?.iconName)??Cf;s.push({resolveType:o,title:h,description:u,iconName:p,iconUrl:m,source:d})}return s.sort((i,o)=>i.title.localeCompare(o.title))}function AP(t){return(t.split("/").pop()??t).replace(/\.(tsx?|jsx?)$/,"")}const EP=["blog/sections/blocks/","site/sections/Blog/Post/"];function PP(t){return EP.some(e=>t.startsWith(e))}function Jg({orgSlug:t,virtualMcpId:e,branch:s}){return at.decofile(`${t}/${e}/${s}`)}function RP({orgSlug:t,virtualMcpId:e,branch:s}){return at.liveMeta(t,e,s)}function DP({orgSlug:t,virtualMcpId:e,branch:s},n){return`/api/${t}/sandbox/${encodeURIComponent(e)}/${encodeURIComponent(s)}/${n}`}async function Xg(t,e,s,n){const i=await fetch(DP(t,e),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(s)});if(!i.ok){const o=await i.json().catch(()=>({}));throw new Error(o.error??`${n} (${i.status})`)}return i.json()}function IP(t){const e=F.c(11),s=Ls();let n;e[0]!==t?(n=l=>{const{blockKey:c,data:d}=l;return Xg(t,"write",{path:Pr(t.packagePath,Gg(c)),content:JSON.stringify(d,null,2)},"Write failed")},e[0]=t,e[1]=n):n=e[1];let i;e[2]!==t||e[3]!==s?(i=async l=>{const{blockKey:c,data:d}=l,h=Jg(t);await s.cancelQueries({queryKey:h});const u=s.getQueryData(h);return s.setQueryData(h,f=>({...f??{},[c]:d})),{previous:u,queryKey:h}},e[2]=t,e[3]=s,e[4]=i):i=e[4];let o;e[5]!==s?(o=(l,c,d)=>{d?.queryKey&&s.setQueryData(d.queryKey,d.previous)},e[5]=s,e[6]=o):o=e[6];let a;return e[7]!==n||e[8]!==i||e[9]!==o?(a={mutationFn:n,onMutate:i,onError:o},e[7]=n,e[8]=i,e[9]=o,e[10]=a):a=e[10],Ys(a)}function MP(t){const e=Ls();return Ys({mutationFn:({blockKey:s})=>Xg(t,"unlink",{path:Pr(t.packagePath,Gg(s))},"Delete failed"),onMutate:async({blockKey:s})=>{const n=Jg(t);await e.cancelQueries({queryKey:n});const i=e.getQueryData(n);return e.setQueryData(n,o=>{if(!o)return o;const{[s]:a,...l}=o;return l}),{previous:i,queryKey:n}},onError:(s,n,i)=>{i?.queryKey&&e.setQueryData(i.queryKey,i.previous)},onSuccess:()=>{e.invalidateQueries({queryKey:RP(t)})}})}function OP({open:t,onOpenChange:e,pageKey:s,decofile:n,onSave:i}){const o=re(),a=n[s],l=a===void 0,c=l?"":JSON.stringify(a,null,2),[d,h]=A.useState(!1),[u,f]=A.useState(c),[m,p]=A.useState(!1),g=!i||l,x=u!==c,v=()=>{navigator.clipboard.writeText(u).then(()=>{h(!0),setTimeout(()=>h(!1),2e3)})},b=async y=>{if(!i||m)return;let _;try{_=JSON.parse(y)}catch{ge.error(o("sectionsEditor.pageJsonDialog.invalidJsonError"));return}p(!0);try{await i(_),ge.success(o("sectionsEditor.pageJsonDialog.saveSuccess")),e(!1)}catch(L){ge.error(o("sectionsEditor.pageJsonDialog.saveError",{error:L instanceof Error?L.message:String(L)}))}finally{p(!1)}};return r.jsx(ts,{open:t,onOpenChange:e,children:r.jsxs(es,{className:"max-w-3xl p-0 gap-0",children:[r.jsxs(ms,{className:"px-4 py-3 border-b flex-row items-center justify-between space-y-0",children:[r.jsx(ps,{className:"text-sm font-semibold",children:o("sectionsEditor.pageJsonDialog.title")}),r.jsxs("div",{className:"flex items-center gap-2 mr-8",children:[r.jsxs(le,{variant:"ghost",size:"sm",onClick:v,className:"h-7 gap-1.5 text-xs",children:[d?r.jsx(Xl,{size:12}):r.jsx(Os,{size:12}),o(d?"sectionsEditor.pageJsonDialog.copied":"sectionsEditor.pageJsonDialog.copy")]}),!g&&r.jsx(le,{size:"sm",onClick:()=>b(u),disabled:!x||m,className:"h-7 text-xs",children:o(m?"sectionsEditor.pageJsonDialog.saving":"sectionsEditor.pageJsonDialog.save")})]})]}),l?r.jsxs("div",{className:"p-4 text-xs font-mono text-foreground/60",children:["// ",o("sectionsEditor.pageJsonDialog.pageNotFound")]}):r.jsx("div",{className:"h-[70vh]",children:r.jsx(ra,{code:c,language:"json",readOnly:g,height:"100%",onChange:y=>f(y??""),onSave:y=>{b(y)}})})]})})}function Qs(t){const e=F.c(45),{icon:s,logoUrl:n,title:i,subtitle:o,active:a,accent:l,variantCount:c,trailing:d,selectable:h,selectionActive:u,selected:f,invalid:m,invalidReason:p,onToggleSelect:g,onClick:x,menu:v}=t,b=l==="global";let y;e[0]!==s||e[1]!==a||e[2]!==b||e[3]!==n||e[4]!==c?(y=c&&c>1?r.jsx("span",{className:"flex size-8 shrink-0 items-center justify-center",children:r.jsxs(Ue,{children:[r.jsx(ze,{asChild:!0,children:r.jsx(s,{size:16,className:"shrink-0 text-success"})}),r.jsxs(Ke,{side:"right",children:[c," variants"]})]})}):n?r.jsx("img",{src:n,alt:"",className:"size-8 shrink-0 rounded-lg object-cover bg-muted"}):r.jsx("span",{className:ie("flex size-8 shrink-0 items-center justify-center rounded-lg",b?"bg-global-section/15":"bg-muted"),children:r.jsx(s,{size:16,className:ie("shrink-0",!b&&(a?"text-accent-foreground":"text-muted-foreground")),style:b?{color:N9}:void 0})}),e[0]=s,e[1]=a,e[2]=b,e[3]=n,e[4]=c,e[5]=y):y=e[5];const _=y,L=a?b?"bg-global-section/15 text-global-section-fg dark:text-global-section-fg-dark":"bg-accent text-accent-foreground":b?"hover:bg-global-section/10":"hover:bg-muted";let w;e[6]!==L?(w=ie("group relative flex min-w-0 items-center rounded-md transition-colors",L),e[6]=L,e[7]=w):w=e[7];let j;e[8]!==g||e[9]!==h||e[10]!==f||e[11]!==u||e[12]!==i?(j=h&&r.jsx("span",{className:ie("flex shrink-0 items-center pl-2.5 transition-opacity",f||u?"opacity-100":"opacity-0 group-hover:opacity-100 focus-within:opacity-100"),onClick:BP,children:r.jsx(Ar,{checked:f,onCheckedChange:()=>g?.(),"aria-label":`Select ${i}`})}),e[8]=g,e[9]=h,e[10]=f,e[11]=u,e[12]=i,e[13]=j):j=e[13];const S=m&&!a&&"text-destructive";let C;e[14]!==S?(C=ie("block truncate text-sm font-medium",S),e[14]=S,e[15]=C):C=e[15];let N;e[16]!==C||e[17]!==i?(N=r.jsx("span",{className:C,children:i}),e[16]=C,e[17]=i,e[18]=N):N=e[18];const V=a?"text-accent-foreground/70":"text-muted-foreground";let E;e[19]!==V?(E=ie("block truncate text-xs",V),e[19]=V,e[20]=E):E=e[20];let T;e[21]!==o||e[22]!==E?(T=r.jsx("span",{className:E,children:o}),e[21]=o,e[22]=E,e[23]=T):T=e[23];let k;e[24]!==T||e[25]!==N?(k=r.jsxs("span",{className:"min-w-0 flex-1",children:[N,T]}),e[24]=T,e[25]=N,e[26]=k):k=e[26];let R;e[27]!==a||e[28]!==m||e[29]!==p?(R=m&&r.jsxs(Ue,{children:[r.jsx(ze,{asChild:!0,children:r.jsx("span",{className:ie("flex shrink-0 items-center",a?"text-accent-foreground":"text-destructive"),children:r.jsx(wn,{size:14})})}),p&&r.jsx(Ke,{side:"bottom",children:p})]}),e[27]=a,e[28]=m,e[29]=p,e[30]=R):R=e[30];let P;e[31]!==x||e[32]!==_||e[33]!==k||e[34]!==R||e[35]!==d?(P=r.jsxs("button",{type:"button",onClick:x,className:"flex min-w-0 flex-1 items-center gap-2.5 rounded-md px-2.5 py-2 text-left cursor-pointer",children:[_,k,R,d]}),e[31]=x,e[32]=_,e[33]=k,e[34]=R,e[35]=d,e[36]=P):P=e[36];let D;e[37]!==a||e[38]!==v?(D=v&&r.jsx("div",{className:ie("pr-1 opacity-0 transition-opacity group-hover:opacity-100",a&&"opacity-100"),children:v}),e[37]=a,e[38]=v,e[39]=D):D=e[39];let I;return e[40]!==P||e[41]!==D||e[42]!==w||e[43]!==j?(I=r.jsxs("div",{className:w,children:[j,P,D]}),e[40]=P,e[41]=D,e[42]=w,e[43]=j,e[44]=I):I=e[44],I}function BP(t){return t.stopPropagation()}function Hn(t){const e=F.c(10),{icon:s,title:n,description:i}=t;let o;e[0]!==s?(o=s&&r.jsx(s,{size:24,className:"text-muted-foreground/60"}),e[0]=s,e[1]=o):o=e[1];let a;e[2]!==n?(a=r.jsx("div",{children:n}),e[2]=n,e[3]=a):a=e[3];let l;e[4]!==i?(l=i&&r.jsx("div",{className:"text-xs text-muted-foreground/80 max-w-sm",children:i}),e[4]=i,e[5]=l):l=e[5];let c;return e[6]!==o||e[7]!==a||e[8]!==l?(c=r.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-2 p-6 text-center text-sm text-muted-foreground",children:[o,a,l]}),e[6]=o,e[7]=a,e[8]=l,e[9]=c):c=e[9],c}var $P=nv.create({name:"textAlign",addOptions(){return{types:[],alignments:["left","center","right","justify"],defaultAlignment:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:t=>{const e=t.style.textAlign;return this.options.alignments.includes(e)?e:this.options.defaultAlignment},renderHTML:t=>t.textAlign?{style:`text-align: ${t.textAlign}`}:{}}}}]},addCommands(){return{setTextAlign:t=>({commands:e})=>this.options.alignments.includes(t)?this.options.types.map(s=>e.updateAttributes(s,{textAlign:t})).some(s=>s):!1,unsetTextAlign:()=>({commands:t})=>this.options.types.map(e=>t.resetAttributes(e,"textAlign")).some(e=>e),toggleTextAlign:t=>({editor:e,commands:s})=>this.options.alignments.includes(t)?e.isActive({textAlign:t})?s.unsetTextAlign():s.setTextAlign(t):!1}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}}),FP=$P;const zP=new Set(["http:","https:","mailto:","tel:","ftp:"]);function KP(t){if(t.startsWith("/")||t.startsWith(".")||t.startsWith("#"))return!0;try{const e=new URL(t,"https://placeholder.invalid");return zP.has(e.protocol)}catch{return!1}}function UP(t){const e=t.trim();return e?e.startsWith("/")||e.startsWith(".")||e.startsWith("#")||/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(e)?e:`https://${e}`:""}const HP="noopener noreferrer nofollow";function bs(t){const e=F.c(8),{active:s,label:n,onClick:i,children:o}=t,a=s?"bg-accent text-accent-foreground":"text-muted-foreground hover:bg-muted hover:text-foreground";let l;e[0]!==a?(l=ie("flex h-7 w-7 items-center justify-center rounded transition-colors cursor-pointer",a),e[0]=a,e[1]=l):l=e[1];let c;return e[2]!==s||e[3]!==o||e[4]!==n||e[5]!==i||e[6]!==l?(c=r.jsx("button",{type:"button","aria-label":n,"aria-pressed":s,onMouseDown:WP,onClick:i,className:l,children:o}),e[2]=s,e[3]=o,e[4]=n,e[5]=i,e[6]=l,e[7]=c):c=e[7],c}function WP(t){return t.preventDefault()}function kf(t){const e=F.c(7),{active:s,label:n,onSelect:i}=t,o=s?"bg-accent text-accent-foreground":"text-muted-foreground hover:bg-muted hover:text-foreground";let a;e[0]!==o?(a=ie("flex-1 rounded px-2 py-1 text-xs transition-colors cursor-pointer",o),e[0]=o,e[1]=a):a=e[1];let l;return e[2]!==s||e[3]!==n||e[4]!==i||e[5]!==a?(l=r.jsx("button",{type:"button","aria-pressed":s,onMouseDown:qP,onClick:i,className:a,children:n}),e[2]=s,e[3]=n,e[4]=i,e[5]=a,e[6]=l):l=e[6],l}function qP(t){return t.preventDefault()}function GP(t){const e=F.c(36),{editor:s,active:n,open:i,onOpenChange:o}=t,a=re(),[l,c]=A.useState(""),[d,h]=A.useState(!0),[u,f]=A.useState(!1);let m;e[0]!==n||e[1]!==s||e[2]!==o?(m=()=>{const V=s.getAttributes("link");c(typeof V.href=="string"?V.href:""),h(n?V.target==="_blank":!0),f(!1),o(!0)},e[0]=n,e[1]=s,e[2]=o,e[3]=m):m=e[3];const p=m;let g;e[4]!==s||e[5]!==o?(g=()=>{o(!1),s.chain().focus().run()},e[4]=s,e[5]=o,e[6]=g):g=e[6];const x=g;let v;e[7]!==l||e[8]!==s||e[9]!==d||e[10]!==o?(v=()=>{const V=UP(l);if(V===""){s.chain().focus().extendMarkRange("link").unsetLink().run(),o(!1);return}if(!KP(V)){f(!0);return}s.chain().focus().extendMarkRange("link").setLink({href:V,target:d?"_blank":null,rel:d?HP:null}).run(),o(!1)},e[7]=l,e[8]=s,e[9]=d,e[10]=o,e[11]=v):v=e[11];const b=v;let y;e[12]!==s||e[13]!==o?(y=()=>{s.chain().focus().extendMarkRange("link").unsetLink().run(),o(!1)},e[12]=s,e[13]=o,e[14]=y):y=e[14];const _=y;let L;e[15]!==a?(L=a("sectionsEditor.richTextLinkControl.linkButtonLabel"),e[15]=a,e[16]=L):L=e[16];const w=i?x:p;let j;e[17]===Symbol.for("react.memo_cache_sentinel")?(j=r.jsx(s2,{size:14}),e[17]=j):j=e[17];let S;e[18]!==n||e[19]!==L||e[20]!==w?(S=r.jsx(bs,{active:n,label:L,onClick:w,children:j}),e[18]=n,e[19]=L,e[20]=w,e[21]=S):S=e[21];let C;e[22]!==n||e[23]!==b||e[24]!==x||e[25]!==l||e[26]!==u||e[27]!==d||e[28]!==o||e[29]!==i||e[30]!==_||e[31]!==a?(C=i&&r.jsxs("div",{className:"absolute left-0 top-full z-20 mt-1.5 flex w-64 flex-col gap-1 rounded-md border bg-popover p-1 shadow-md",onBlur:V=>{V.currentTarget.contains(V.relatedTarget)||o(!1)},children:[r.jsxs("div",{className:"flex items-center gap-0.5",children:[r.jsx("input",{autoFocus:!0,type:"text","aria-label":a("sectionsEditor.richTextLinkControl.urlInputAriaLabel"),"aria-invalid":u,placeholder:a("sectionsEditor.richTextLinkControl.urlInputPlaceholder"),value:l,onChange:V=>{c(V.target.value),f(!1)},onKeyDown:V=>{V.key==="Enter"?(V.preventDefault(),b()):V.key==="Escape"&&(V.preventDefault(),x())},className:ie("h-7 flex-1 rounded bg-transparent px-2 text-sm text-foreground placeholder:text-muted-foreground focus:outline-none",u&&"text-destructive")}),r.jsx(bs,{active:!1,label:a("sectionsEditor.richTextLinkControl.applyLinkLabel"),onClick:b,children:r.jsx(zt,{size:14})}),n&&r.jsx(bs,{active:!1,label:a("sectionsEditor.richTextLinkControl.removeLinkLabel"),onClick:_,children:r.jsx(Ns,{size:14})})]}),r.jsxs("div",{className:"flex items-center gap-0.5 rounded bg-muted/40 p-0.5",children:[r.jsx(kf,{active:!d,label:a("sectionsEditor.richTextLinkControl.sameTabLabel"),onSelect:()=>h(!1)}),r.jsx(kf,{active:d,label:a("sectionsEditor.richTextLinkControl.newTabLabel"),onSelect:()=>h(!0)})]})]}),e[22]=n,e[23]=b,e[24]=x,e[25]=l,e[26]=u,e[27]=d,e[28]=o,e[29]=i,e[30]=_,e[31]=a,e[32]=C):C=e[32];let N;return e[33]!==S||e[34]!==C?(N=r.jsxs("div",{className:"relative",children:[S,C]}),e[33]=S,e[34]=C,e[35]=N):N=e[35],N}function YP({schema:t,value:e,onChange:s,path:n,label:i}){const o=typeof e=="string"?e:"",a=A.useRef(s);a.current=s;const[l,c]=A.useState(!1),d=Lm({extensions:[fm.configure({heading:{levels:[1,2,3]},link:{HTMLAttributes:{}}}),FP.configure({types:["heading","paragraph"]})],content:o||"",editorProps:{attributes:{class:ie("prose prose-sm dark:prose-invert max-w-none focus:outline-none","min-h-[80px] px-3 py-2")}},onUpdate:({editor:u})=>{const f=u.getHTML();a.current(f==="<p></p>"?"":f)}}),h=iv({editor:d,selector:({editor:u})=>({bold:u?.isActive("bold")??!1,italic:u?.isActive("italic")??!1,underline:u?.isActive("underline")??!1,strike:u?.isActive("strike")??!1,h1:u?.isActive("heading",{level:1})??!1,h2:u?.isActive("heading",{level:2})??!1,bulletList:u?.isActive("bulletList")??!1,orderedList:u?.isActive("orderedList")??!1,link:u?.isActive("link")??!1,alignLeft:u?.isActive({textAlign:"left"})??!1,alignCenter:u?.isActive({textAlign:"center"})??!1,alignRight:u?.isActive({textAlign:"right"})??!1,alignJustify:u?.isActive({textAlign:"justify"})??!1})});return d?r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"space-y-0.5",children:[r.jsx(lt,{htmlFor:n,children:i}),t.description&&r.jsx("p",{className:"text-xs leading-normal text-muted-foreground",children:t.description})]}),r.jsxs("div",{className:"overflow-hidden rounded-md border border-input",children:[r.jsxs("div",{className:"flex flex-wrap items-center gap-0.5 border-b border-border/60 bg-muted/30 px-1.5 py-1",children:[r.jsx(bs,{active:h.bold,label:"Bold",onClick:()=>d.chain().focus().toggleBold().run(),children:r.jsx(Jv,{size:14})}),r.jsx(bs,{active:h.italic,label:"Italic",onClick:()=>d.chain().focus().toggleItalic().run(),children:r.jsx(Xv,{size:14})}),r.jsx(bs,{active:h.underline,label:"Underline",onClick:()=>d.chain().focus().toggleUnderline().run(),children:r.jsx(Qv,{size:14})}),r.jsx(bs,{active:h.strike,label:"Strikethrough",onClick:()=>d.chain().focus().toggleStrike().run(),children:r.jsx(Zv,{size:14})}),r.jsx("div",{className:"mx-0.5 h-4 w-px bg-border"}),r.jsx(bs,{active:h.h1,label:"Heading 1",onClick:()=>d.chain().focus().toggleHeading({level:1}).run(),children:r.jsx(e6,{size:14})}),r.jsx(bs,{active:h.h2,label:"Heading 2",onClick:()=>d.chain().focus().toggleHeading({level:2}).run(),children:r.jsx(t6,{size:14})}),r.jsx("div",{className:"mx-0.5 h-4 w-px bg-border"}),r.jsx(bs,{active:h.bulletList,label:"Bullet list",onClick:()=>d.chain().focus().toggleBulletList().run(),children:r.jsx(zb,{size:14})}),r.jsx(bs,{active:h.orderedList,label:"Ordered list",onClick:()=>d.chain().focus().toggleOrderedList().run(),children:r.jsx("span",{className:"text-[11px] font-semibold leading-none",children:"1."})}),r.jsx("div",{className:"mx-0.5 h-4 w-px bg-border"}),r.jsx(GP,{editor:d,active:h.link,open:l,onOpenChange:c}),r.jsx("div",{className:"mx-0.5 h-4 w-px bg-border"}),r.jsx(bs,{active:h.alignLeft,label:"Align left",onClick:()=>d.chain().focus().setTextAlign("left").run(),children:r.jsx($b,{size:14})}),r.jsx(bs,{active:h.alignCenter,label:"Align center",onClick:()=>d.chain().focus().setTextAlign("center").run(),children:r.jsx(s6,{size:14})}),r.jsx(bs,{active:h.alignRight,label:"Align right",onClick:()=>d.chain().focus().setTextAlign("right").run(),children:r.jsx(n6,{size:14})}),r.jsx(bs,{active:h.alignJustify,label:"Justify",onClick:()=>d.chain().focus().setTextAlign("justify").run(),children:r.jsx(i6,{size:14})})]}),r.jsx(Sm,{editor:d})]})]}):null}const sr=t=>String(t).padStart(2,"0"),JP="1900-01-01",XP="2099-12-31",QP="1900-01-01T00:00",ZP="2099-12-31T23:59";function eR(t){if(!t)return"";const e=t.slice(0,10);if(/^\d{4}-\d{2}-\d{2}$/.test(e))return e;const s=new Date(t);return Number.isNaN(s.getTime())?"":`${s.getUTCFullYear()}-${sr(s.getUTCMonth()+1)}-${sr(s.getUTCDate())}`}function tR(t){return!t||!/^\d{4}-\d{2}-\d{2}$/.test(t)?"":`${t}T00:00:00.000Z`}function sR(t){if(!t)return"";const e=new Date(t);return Number.isNaN(e.getTime())?"":`${e.getFullYear()}-${sr(e.getMonth()+1)}-${sr(e.getDate())}T${sr(e.getHours())}:${sr(e.getMinutes())}`}function nR(t){if(!t)return"";const e=new Date(t);return Number.isNaN(e.getTime())?"":e.toISOString()}function iR(t){const e=F.c(41),{id:s,withTime:n,value:i,onChange:o,calendarLabel:a}=t,[l,c]=A.useState(!1);let d;e[0]!==n?(d=M=>n?sR(M):eR(M),e[0]=n,e[1]=d):d=e[1];const h=d;let u;e[2]!==n?(u=M=>n?nR(M):tR(M),e[2]=n,e[3]=u):u=e[3];const f=u;let m;e[4]!==h||e[5]!==i?(m=()=>h(i),e[4]=h,e[5]=i,e[6]=m):m=e[6];const[p,g]=A.useState(m),[x,v]=A.useState(i);if(i!==x){v(i);const M=h(i);M!==p&&g(M)}let b;e[7]!==o||e[8]!==f?(b=M=>{g(M.target.value),o(f(M.target.value))},e[7]=o,e[8]=f,e[9]=b):b=e[9];const y=b;let _;if(e[10]!==i){const M=i?new Date(i):null;_=M&&!Number.isNaN(M.getTime())?M:null,e[10]=i,e[11]=_}else _=e[11];const L=_;let w;e[12]!==o||e[13]!==L||e[14]!==h||e[15]!==n?(w=M=>{if(!M)return;n&&L?M.setHours(L.getHours(),L.getMinutes(),0,0):M.setHours(0,0,0,0);const O=M.toISOString();g(h(O)),v(O),o(O),c(!1)},e[12]=o,e[13]=L,e[14]=h,e[15]=n,e[16]=w):w=e[16];const j=w,S=n?"datetime-local":"date",C=n?QP:JP,N=n?ZP:XP;let V;e[17]!==h||e[18]!==i?(V=()=>g(h(i)),e[17]=h,e[18]=i,e[19]=V):V=e[19];let E;e[20]!==y||e[21]!==s||e[22]!==p||e[23]!==V||e[24]!==S||e[25]!==C||e[26]!==N?(E=r.jsx(rt,{id:s,type:S,min:C,max:N,value:p,onChange:y,onBlur:V,className:"h-10 flex-1 [&::-webkit-calendar-picker-indicator]:hidden [&::-webkit-calendar-picker-indicator]:opacity-0"}),e[20]=y,e[21]=s,e[22]=p,e[23]=V,e[24]=S,e[25]=C,e[26]=N,e[27]=E):E=e[27];let T;e[28]===Symbol.for("react.memo_cache_sentinel")?(T=r.jsx(Z0,{className:"h-4 w-4"}),e[28]=T):T=e[28];let k;e[29]!==a?(k=r.jsx(Es,{asChild:!0,children:r.jsx(le,{type:"button",variant:"outline",size:"icon",className:"h-10 w-10 shrink-0","aria-label":a,children:T})}),e[29]=a,e[30]=k):k=e[30];const R=L??void 0;let P;e[31]!==j||e[32]!==R?(P=r.jsx(Ps,{className:"w-auto p-0",align:"end",onCloseAutoFocus:rR,children:r.jsx(rv,{mode:"single",selected:R,onSelect:j,initialFocus:!0})}),e[31]=j,e[32]=R,e[33]=P):P=e[33];let D;e[34]!==l||e[35]!==k||e[36]!==P?(D=r.jsxs(As,{open:l,onOpenChange:c,children:[k,P]}),e[34]=l,e[35]=k,e[36]=P,e[37]=D):D=e[37];let I;return e[38]!==E||e[39]!==D?(I=r.jsxs("div",{className:"flex gap-1",children:[E,D]}),e[38]=E,e[39]=D,e[40]=I):I=e[40],I}function rR(t){return t.preventDefault()}function Na(t){const e=F.c(8),{htmlFor:s,label:n,description:i}=t;let o;e[0]!==s||e[1]!==n?(o=r.jsx(lt,{htmlFor:s,children:n}),e[0]=s,e[1]=n,e[2]=o):o=e[2];let a;e[3]!==i?(a=i&&r.jsx("p",{className:"text-xs leading-normal text-muted-foreground",children:i}),e[3]=i,e[4]=a):a=e[4];let l;return e[5]!==o||e[6]!==a?(l=r.jsxs("div",{className:"space-y-0.5",children:[o,a]}),e[5]=o,e[6]=a,e[7]=l):l=e[7],l}function Ta(t){const e=F.c(70),{schema:s,value:n,onChange:i,path:o,label:a}=t,l=re(),c=typeof n=="string"?n:"",d=s.format;if(d==="rich-text"||d==="rich-text-inline"||d==="html"){let x;return e[0]!==a||e[1]!==i||e[2]!==o||e[3]!==s||e[4]!==n?(x=r.jsx(YP,{schema:s,value:n,onChange:i,path:o,label:a}),e[0]=a,e[1]=i,e[2]=o,e[3]=s,e[4]=n,e[5]=x):x=e[5],x}if(d==="textarea"||d==="markdown"){let x;e[6]!==a||e[7]!==o||e[8]!==s.description?(x=r.jsx(Na,{htmlFor:o,label:a,description:s.description}),e[6]=a,e[7]=o,e[8]=s.description,e[9]=x):x=e[9];let v;e[10]!==i?(v=_=>i(_.target.value),e[10]=i,e[11]=v):v=e[11];let b;e[12]!==o||e[13]!==c||e[14]!==v?(b=r.jsx(gr,{id:o,value:c,onChange:v,rows:4}),e[12]=o,e[13]=c,e[14]=v,e[15]=b):b=e[15];let y;return e[16]!==x||e[17]!==b?(y=r.jsxs("div",{className:"space-y-2",children:[x,b]}),e[16]=x,e[17]=b,e[18]=y):y=e[18],y}if(d==="date"||d==="date-time"){let x;e[19]!==a||e[20]!==o||e[21]!==s.description?(x=r.jsx(Na,{htmlFor:o,label:a,description:s.description}),e[19]=a,e[20]=o,e[21]=s.description,e[22]=x):x=e[22];const v=d==="date-time";let b;e[23]!==l?(b=l("sectionsEditor.stringField.openCalendar"),e[23]=l,e[24]=b):b=e[24];let y;e[25]!==i||e[26]!==o||e[27]!==c||e[28]!==v||e[29]!==b?(y=r.jsx(iR,{id:o,withTime:v,value:c,onChange:i,calendarLabel:b}),e[25]=i,e[26]=o,e[27]=c,e[28]=v,e[29]=b,e[30]=y):y=e[30];let _;return e[31]!==x||e[32]!==y?(_=r.jsxs("div",{className:"space-y-2",children:[x,y]}),e[31]=x,e[32]=y,e[33]=_):_=e[33],_}if(d==="color-input"||d==="color"){let x;e[34]!==a||e[35]!==o||e[36]!==s.description?(x=r.jsx(Na,{htmlFor:o,label:a,description:s.description}),e[34]=a,e[35]=o,e[36]=s.description,e[37]=x):x=e[37];const v=c||"#000000";let b;e[38]!==i?(b=S=>i(S.target.value),e[38]=i,e[39]=b):b=e[39];let y;e[40]!==v||e[41]!==b?(y=r.jsx("input",{type:"color",value:v,onChange:b,className:"h-10 w-10 cursor-pointer rounded-lg border border-border bg-background p-1"}),e[40]=v,e[41]=b,e[42]=y):y=e[42];let _;e[43]!==i?(_=S=>i(S.target.value),e[43]=i,e[44]=_):_=e[44];let L;e[45]!==o||e[46]!==c||e[47]!==_?(L=r.jsx(rt,{id:o,value:c,onChange:_,placeholder:"#000000",className:"h-10 flex-1"}),e[45]=o,e[46]=c,e[47]=_,e[48]=L):L=e[48];let w;e[49]!==y||e[50]!==L?(w=r.jsxs("div",{className:"flex items-center gap-2",children:[y,L]}),e[49]=y,e[50]=L,e[51]=w):w=e[51];let j;return e[52]!==x||e[53]!==w?(j=r.jsxs("div",{className:"space-y-2",children:[x,w]}),e[52]=x,e[53]=w,e[54]=j):j=e[54],j}let h;e[55]!==a||e[56]!==o||e[57]!==s.description?(h=r.jsx(Na,{htmlFor:o,label:a,description:s.description}),e[55]=a,e[56]=o,e[57]=s.description,e[58]=h):h=e[58];const u=d==="url"?"url":"text";let f;e[59]!==i?(f=x=>i(x.target.value),e[59]=i,e[60]=f):f=e[60];const m=s.default!=null?String(s.default):void 0;let p;e[61]!==o||e[62]!==c||e[63]!==u||e[64]!==f||e[65]!==m?(p=r.jsx(rt,{id:o,type:u,value:c,onChange:f,placeholder:m,className:"h-10"}),e[61]=o,e[62]=c,e[63]=u,e[64]=f,e[65]=m,e[66]=p):p=e[66];let g;return e[67]!==h||e[68]!==p?(g=r.jsxs("div",{className:"space-y-2",children:[h,p]}),e[67]=h,e[68]=p,e[69]=g):g=e[69],g}const oR=/^[+-]?\d*\.?\d*(?:[eE][+-]?\d*)?$/;function aR(t){const e=F.c(18),{schema:s,value:n,onChange:i,path:o,label:a}=t,l=typeof n=="number"?String(n):"",[c,d]=A.useState(l),[h,u]=A.useState(l);l!==h&&(u(l),c!==""&&l!==""&&Number(c)===Number(l)||d(l));let f;e[0]!==a||e[1]!==o?(f=r.jsx(lt,{htmlFor:o,children:a}),e[0]=a,e[1]=o,e[2]=f):f=e[2];let m;e[3]!==s.description?(m=s.description&&r.jsx("p",{className:"text-xs leading-normal text-muted-foreground",children:s.description}),e[3]=s.description,e[4]=m):m=e[4];let p;e[5]!==f||e[6]!==m?(p=r.jsxs("div",{className:"space-y-0.5",children:[f,m]}),e[5]=f,e[6]=m,e[7]=p):p=e[7];const g=s.type==="integer"?"numeric":"decimal";let x;e[8]!==i?(x=y=>{const _=y.target.value;if(_!==""&&!oR.test(_))return;d(_);const L=Number(_);i(_===""||Number.isNaN(L)?void 0:L)},e[8]=i,e[9]=x):x=e[9];let v;e[10]!==o||e[11]!==c||e[12]!==g||e[13]!==x?(v=r.jsx(rt,{id:o,type:"text",inputMode:g,value:c,onChange:x,className:"h-10"}),e[10]=o,e[11]=c,e[12]=g,e[13]=x,e[14]=v):v=e[14];let b;return e[15]!==p||e[16]!==v?(b=r.jsxs("div",{className:"space-y-2",children:[p,v]}),e[15]=p,e[16]=v,e[17]=b):b=e[17],b}function lR(t){const e=F.c(17),{value:s,onChange:n,path:i,label:o,schema:a}=t,l=typeof s=="boolean"?s:!1;let c;e[0]!==o||e[1]!==i?(c=r.jsx(lt,{htmlFor:i,children:o}),e[0]=o,e[1]=i,e[2]=c):c=e[2];let d;e[3]!==a.description?(d=a.description&&r.jsx("p",{className:"text-xs leading-normal text-muted-foreground",children:a.description}),e[3]=a.description,e[4]=d):d=e[4];let h;e[5]!==c||e[6]!==d?(h=r.jsxs("div",{className:"space-y-0.5",children:[c,d]}),e[5]=c,e[6]=d,e[7]=h):h=e[7];let u;e[8]!==n?(u=p=>n(p),e[8]=n,e[9]=u):u=e[9];let f;e[10]!==l||e[11]!==i||e[12]!==u?(f=r.jsx(xr,{id:i,checked:l,onCheckedChange:u}),e[10]=l,e[11]=i,e[12]=u,e[13]=f):f=e[13];let m;return e[14]!==h||e[15]!==f?(m=r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[h,f]}),e[14]=h,e[15]=f,e[16]=m):m=e[16],m}const pu="__enum_empty__";function gu(t){return t===""?pu:String(t)}function cR(t,e){if(t===pu)return"";const s=e.find(n=>gu(n)===t);return s!==void 0?s:t}function dR(t,e){return t==null?e.some(s=>s==="")?pu:void 0:gu(t)}function uR(t){return t===""?"":String(t)}function hR(t){const e=F.c(32),{schema:s,value:n,onChange:i,path:o,label:a}=t,l=re();let c;e[0]!==s.enum?(c=s.enum??[],e[0]=s.enum,e[1]=c):c=e[1];const d=c;let h;e[2]!==d||e[3]!==n?(h=dR(n,d),e[2]=d,e[3]=n,e[4]=h):h=e[4];const u=h;let f;e[5]!==a||e[6]!==o?(f=r.jsx(lt,{htmlFor:o,children:a}),e[5]=a,e[6]=o,e[7]=f):f=e[7];let m;e[8]!==s.description?(m=s.description&&r.jsx("p",{className:"text-xs leading-normal text-muted-foreground",children:s.description}),e[8]=s.description,e[9]=m):m=e[9];let p;e[10]!==f||e[11]!==m?(p=r.jsxs("div",{className:"space-y-0.5",children:[f,m]}),e[10]=f,e[11]=m,e[12]=p):p=e[12];let g;e[13]!==i||e[14]!==d?(g=w=>i(cR(w,d)),e[13]=i,e[14]=d,e[15]=g):g=e[15];let x;e[16]!==l?(x=l("sectionsEditor.enumField.selectPlaceholder"),e[16]=l,e[17]=x):x=e[17];let v;e[18]!==x?(v=r.jsx(Jt,{className:"h-10",children:r.jsx(as,{placeholder:x})}),e[18]=x,e[19]=v):v=e[19];let b;e[20]!==d?(b=d.map(fR),e[20]=d,e[21]=b):b=e[21];let y;e[22]!==b?(y=r.jsx(Xt,{children:b}),e[22]=b,e[23]=y):y=e[23];let _;e[24]!==u||e[25]!==y||e[26]!==g||e[27]!==v?(_=r.jsxs(Qt,{value:u,onValueChange:g,children:[v,y]}),e[24]=u,e[25]=y,e[26]=g,e[27]=v,e[28]=_):_=e[28];let L;return e[29]!==_||e[30]!==p?(L=r.jsxs("div",{className:"space-y-2",children:[p,_]}),e[29]=_,e[30]=p,e[31]=L):L=e[31],L}function fR(t){const e=gu(t);return r.jsx(vt,{value:e,children:uR(t)},e)}function Qg(t){if(!t||typeof t!="object"||Array.isArray(t))return null;const e=t;return Array.isArray(e.variants)?e:null}function wo(t){return Qg(t)?.variants?.[0]?.rule?.__resolveType===Rr}function Vf(t){return{__resolveType:Ki,variants:[{value:t,rule:{__resolveType:Rr}}]}}function Zg(t){return wo(t)?Qg(t)?.variants?.[0]?.value:t}function co(t){return wo(t)?Zg(t):t}function xu(t){const e=t.__resolveType;if(typeof e!="string")return null;if(fs(e)){const n=t.section?.__resolveType;return typeof n=="string"?n:e}return e}function mR(t){return t.includes("flags/multivariate")}function pR(t){return Tt(t)}function gR(t,e){const s=[...t],n=new Set(s.map(o=>o.resolveType)),i=(o,a)=>{!o||n.has(o)||(n.add(o),s.push({resolveType:o,title:a??pR(o)}))};if(e.savedBlockKey&&i(e.savedBlockKey,e.savedBlockKey),e.editorValue&&typeof e.editorValue=="object"&&!Array.isArray(e.editorValue)){const o=xu(e.editorValue);o?.includes("/")&&i(o)}return s}function xR(t,e,s){const n=e[0]?.resolveType??"";if(s)return s;if(!t||typeof t!="object"||Array.isArray(t))return n;const i=t,o=i.__resolveType;if(typeof o=="string"){if(_n(o)){const u=e.find(f=>f.resolveType===o);return u?u.resolveType:o}const d=e.find(u=>Vh(u.resolveType,o));if(d)return d.resolveType;const h=e.find(u=>u.resolveType===o);if(h)return h.resolveType;if(o.includes("/"))return o}const a=typeof i.type=="string"?i.type:void 0;if(a){const d=e.find(h=>h.discriminatorValue===a||h.resolveType===a||Vh(h.resolveType,a));if(d)return d.resolveType}let l=n,c=-1;for(const d of e){if(!d.schema?.properties)continue;const u=Object.keys(d.schema.properties).filter(f=>!f.startsWith("__")&&f!=="@type"&&f!=="action"&&f!=="alt").filter(f=>i[f]!==void 0).length;u>0&&u>c&&(c=u,l=d.resolveType)}return c>0,l}function Nf(t,e,s){if(!t||typeof t!="object"||Array.isArray(t))return s??null;const n=xu(t);if(!n)return s??null;if(!e)return n.includes("/")?null:s??null;const i=yn(n,e);return i||(n.includes("/")?null:s??null)}function vR(t,e){if(!t?.properties||!e)return t??null;if(!(e in t.properties))return t;const s={...t.properties};return delete s[e],{...t,properties:s}}function e4(t){if(!t||typeof t!="object"||Array.isArray(t))return null;const e=t;if(typeof e.__resolveType!="string"||!fs(e.__resolveType))return null;const s=e.section;return!s||typeof s!="object"||Array.isArray(s)?null:s}function bR(t,e){if(e)return!0;if(!t||typeof t!="object"||Array.isArray(t))return!1;const s=t,n=xu(s);return n&&mR(n)?Array.isArray(s.variants)&&s.variants.length>0:Object.keys(s).some(i=>!i.startsWith("__")&&i!=="@type")}function vu(t){if(typeof t=="string")return t;if(!t||typeof t!="object")return"";const e=t;if(Array.isArray(e.variants)){const s=e.variants,n=s.find(o=>o.rule?.__resolveType?.includes("always"));if(typeof n?.value=="string")return n.value;const i=s.find(o=>typeof o.value=="string");if(i)return i.value}return typeof e.src=="string"?e.src:typeof e.url=="string"?e.url:typeof e.value=="string"?e.value:""}function _R(t){if(t?.trim())try{const e=new URL(t);return e.protocol!=="https:"?void 0:e.href}catch{return}}function yR(t){if(Array.isArray(t.variants)){const e=t.variants,s=e.find(i=>i.rule?.__resolveType?.includes("always"));if(typeof s?.value=="string")return s.value;const n=e.find(i=>typeof i.value=="string");if(n)return n.value}if(typeof t.src=="string")return t.src;if(typeof t.url=="string")return t.url;if(typeof t.value=="string")return t.value}function t4(t){if(typeof t=="string"||t==null||typeof t!="object")return t;if(Array.isArray(t))return t.map(t4);const e=t;return e.__resolveType?yR(e)??t:s4(e)}function s4(t){const e={};for(const[s,n]of Object.entries(t))e[s]=t4(n);return e}function LR(t,e){return e.split(".").reduce((s,n)=>{if(!(s==null||typeof s!="object"))return s[n]},t)}function n4(t){return t==null?"":Array.isArray(t)?t.map(n4).filter(Boolean).join(","):typeof t=="object"?"":String(t)}function bu(t,e){if(!t.includes("{"))return;const s=s4(e);return t.replace(/\{\{\{([^}]+)\}\}\}|\{\{([^}]+)\}\}/g,(i,o,a)=>{const l=(o??a??"").trim();return n4(LR(s,l))}).trim()||void 0}function SR(t){return t.replace(/<[^>]*>/g,"").trim()}function wR(t,e){if(e.includes("{"))return bu(e,t);const s=t[e];if(typeof s=="string"&&s)return s;if(Array.isArray(s)){const n=s.map(i=>i==null?"":String(i)).filter(Boolean).join(",");if(n)return n}}function vi(t,e,s){if(typeof t=="string")return t.trim()?t:`Item ${e+1}`;if(typeof t=="number"||typeof t=="boolean")return String(t);if(t&&typeof t=="object"&&!Array.isArray(t)){let n=co(t);const i=e4(n);if(i&&(n=i),s?.titleBy){const a=wR(n,s.titleBy);if(a)return a}for(const a of["name","label","title","alt","text","href","id","key"]){const l=n[a];if(typeof l=="string"&&l.trim()){const c=s?.properties?.[a]?.format;if(c==="rich-text"||c==="html"){const d=SR(l);if(d)return d;continue}return l}if(Array.isArray(l)){const c=l.map(d=>d==null?"":String(d)).filter(Boolean).join(",");if(c)return c}}const o=n.__resolveType;if(typeof o=="string"&&o)return Tt(o);if(s?.title){const a=bu(s.title,n);if(a)return a;if(!s.title.includes("{"))return s.title}}return`Item ${e+1}`}function jR(t){if(!t)return;if(typeof t.image=="string"&&t.image.includes("{"))return t.image;const e=t.properties?.image;if(!e)return;if(e.format==="image-uri")return"{{{image}}}";const s=e.properties;return s?.mobile?"{{{image.mobile}}}":s?.desktop?"{{{image.desktop}}}":"{{{image}}}"}function Tf(t,e){if(!t||typeof t!="object"||Array.isArray(t))return;const s=jR(e);if(!s)return;const n=bu(s,t);if(!n)return;const i=vu(n)||n;return _R(i)}function i4(t){return t.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[_-]/g," ").replace(/^\w/,e=>e.toUpperCase())}function Ei(t){return t.normalize("NFC").trim()}function Ft(t,e){return Ei(t)===Ei(e)}function Af(t,e){return Ei(t).replace(/\s+/g,"").toLowerCase()===Ei(e).replace(/\s+/g,"").toLowerCase()}function CR(t,e,s){return(s?.hasSiblingDrillDownFields??!1)||Ft(e,t)||s?.arrayKey!=null&&Ft(e,s.arrayKey)}function Aa(t,e,s,n){const i=Ei(s);if(t.some(a=>Ft(a,i)||Ft(a,s)))return t;const o=[...t];return CR(e,s,n)&&!o.some(a=>Ft(a,e))&&o.push(e),o.push(s),o}function kR(t,e){return t.slice(0,t.length-e.length)}function VR(t,e,s){if(s.length===0)return s;const n=jo(t,e),i=s[0];return Ft(i,n)||Ft(i,t)?s.slice(1):s}function jo(t,e){return e.title??i4(t)}function XH(t,e){return e<=0?[]:t.slice(0,e)}function Ef(t,e){const s=Ei(e);return t.findIndex(n=>Ei(n)===s)}function Qd(t,e){return t.type==="array"&&t.items||Lc(t)?!0:Array.isArray(e)}function NR(t){return t!=null&&typeof t=="object"&&!Array.isArray(t)?t:{}}function Uo(t,e,s,n){if(n.length===0)return null;const i=n[0];for(const a of t){const l=e[a];if(!l||!Qd(l,s[a]))continue;const c=jo(a,l);if(Ft(i,c)||Ft(i,a)||n.some(d=>Ft(d,c)||Ft(d,a)))return a}for(const a of t){const l=e[a];if(!l||!Qd(l,s[a]))continue;const c=s[a];if(!Array.isArray(c))continue;const d=l.items;for(let h=0;h<c.length;h++){const u=vi(c[h],h,d);if(Ft(u,i))return a}}for(const a of t){const l=e[a];if(l?.type!=="object"||!l.properties)continue;const c=Object.keys(l.properties),d=NR(s[a]),h=jo(a,l);if(Uo(c,l.properties,d,n)||(Ft(i,h)||Ft(i,a))&&Uo(c,l.properties,d,n.slice(1)))return a}let o=null;for(const a of t){const l=e[a];if(l?.type!=="block-ref")continue;const c=jo(a,l);if(!(i!==c&&i!==a)){if(n.length>1){const d=s[a];if(d&&typeof d=="object"&&!Array.isArray(d)){const h=n[1];if(Object.keys(d).some(f=>!f.startsWith("__")&&(Af(i4(f),h)||Af(f,h))))return a}}o||(o=a)}}return o||null}function TR(t,e,s,n){return Uo(t,e,s,n)}function AR(t,e,s,n,i){if(i.length===0||!s.properties)return!1;const o=Object.keys(s.properties);if(Uo(o,s.properties,n,i))return!0;const a=i[0];return!Ft(a,e)&&!Ft(a,t)?!1:i.length>1||Uo(o,s.properties,n,i.slice(1))!==null}function Pf(t,e,s,n){return n!=null&&n>=0&&n<t.length&&Ft(vi(t[n],n,e),s)?n:t.findIndex((i,o)=>Ft(vi(i,o,e),s))}function ER(t,e,s,n,i){if(e.length===0)return null;for(let a=0;a<e.length;a++){const l=e[a],c=Pf(s,n,l,i);if(c>=0)return{index:c,innerPath:e.slice(a+1)}}const o=e.findIndex(a=>Ft(a,t));if(o>=0&&e.length>o+1){const a=e[o+1],l=Pf(s,n,a,i);if(l>=0)return{index:l,innerPath:e.slice(o+2)}}return null}function id(t){return t.includes("/sections/")||t.includes("multivariate/section")||t===Dr}function PR(t){if(t.type==="block-ref"&&t.anyOfRefs?.length)return t.anyOfRefs.some(s=>id(s.resolveType));if(t.anyOfRefs?.length)return t.anyOfRefs.some(s=>id(s.resolveType));const e=t.properties?.__resolveType;return e?.type==="block-ref"&&e.anyOfRefs?.length?e.anyOfRefs.some(s=>id(s.resolveType)):!1}function RR(t,e){if(e==="global"||e==="sections"||Lc(t))return!0;const s=t.type==="array"?t.items:void 0;return s?PR(s):!1}function Rf(t){return Array.from({length:t},(e,s)=>({id:crypto.randomUUID(),index:s}))}function r4(t){return t.map((e,s)=>({...e,index:s}))}function DR(t,e){if(e===t.length)return t;if(e<t.length)return r4(t.slice(0,e));const s=Array.from({length:e-t.length},(n,i)=>({id:crypto.randomUUID(),index:t.length+i}));return[...t,...s]}function IR(t,e){const s=t.findIndex(o=>o.index===e),n=t.map(o=>o.index>e?{...o,index:o.index+1}:o),i={id:crypto.randomUUID(),index:e+1};return s===-1?[...n,i]:[...n.slice(0,s+1),i,...n.slice(s+1)]}function MR(t,e){return t.filter(s=>s.index!==e).map(s=>s.index>e?{...s,index:s.index-1}:s)}function OR(t){const e=F.c(8),{labelText:s,imageSrc:n}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(ia,{className:"size-3.5 shrink-0 text-muted-foreground/40"}),e[0]=i):i=e[0];let o;e[1]!==n?(o=n&&r.jsx("img",{src:n,alt:"",referrerPolicy:"no-referrer",className:"h-12 max-w-[100px] shrink-0 rounded object-cover"}),e[1]=n,e[2]=o):o=e[2];let a;e[3]!==s?(a=r.jsx("span",{className:"min-w-0 truncate",children:s}),e[3]=s,e[4]=a):a=e[4];let l;return e[5]!==o||e[6]!==a?(l=r.jsxs(r.Fragment,{children:[i,r.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2.5 text-sm",children:[o,a]})]}),e[5]=o,e[6]=a,e[7]=l):l=e[7],l}function BR(t){const e=F.c(50),{sortableId:s,labelText:n,imageSrc:i,hidden:o,onToggleHidden:a,onOpen:l,onDuplicate:c,onRemove:d}=t;let h;e[0]!==s?(h={id:s,animateLayoutChanges:KR},e[0]=s,e[1]=h):h=e[1];const{attributes:u,listeners:f,setNodeRef:m,transform:p,isDragging:g}=eu(h);let x;e[2]!==p?(x=Ln.Transform.toString(p?{...p,x:0}:null),e[2]=p,e[3]=x):x=e[3];const v=g?0:void 0;let b;e[4]!==x||e[5]!==v?(b={transform:x,opacity:v},e[4]=x,e[5]=v,e[6]=b):b=e[6];const y=b;let _;e[7]!==l?(_=z=>{(z.key==="Enter"||z.key===" ")&&(z.preventDefault(),l())},e[7]=l,e[8]=_):_=e[8];const L=g?"cursor-grabbing":"cursor-pointer";let w;e[9]!==L?(w=ie("group flex min-w-0 items-center gap-2.5 rounded-lg px-2 py-2.5 hover:bg-accent hover:text-accent-foreground touch-none",L),e[9]=L,e[10]=w):w=e[10];let j;e[11]===Symbol.for("react.memo_cache_sentinel")?(j=r.jsx(ia,{className:"size-3.5 shrink-0 text-muted-foreground/40"}),e[11]=j):j=e[11];let S;e[12]!==i?(S=i&&r.jsx("img",{src:i,alt:"",referrerPolicy:"no-referrer",className:"h-12 max-w-[100px] shrink-0 rounded object-cover"}),e[12]=i,e[13]=S):S=e[13];const C=o&&"line-through opacity-50";let N;e[14]!==C?(N=ie("min-w-0 flex-1 truncate text-sm",C),e[14]=C,e[15]=N):N=e[15];let V;e[16]!==n||e[17]!==N?(V=r.jsx("span",{className:N,children:n}),e[16]=n,e[17]=N,e[18]=V):V=e[18];let E;e[19]!==o||e[20]!==a?(E=a&&r.jsxs(Ue,{children:[r.jsx(ze,{asChild:!0,children:r.jsx(le,{type:"button",variant:"ghost",size:"icon","aria-label":o?"Show item":"Hide item",className:ie("size-6 shrink-0",o?"opacity-100":"opacity-0 transition-opacity group-hover:opacity-100"),onClick:z=>{z.stopPropagation(),a()},onPointerDown:zR,children:o?r.jsx(f6,{size:14}):r.jsx(u9,{size:14})})}),r.jsx(Ke,{side:"bottom",children:o?"Show item":"Hide item"})]}),e[19]=o,e[20]=a,e[21]=E):E=e[21];const T=`Open actions for ${n}`;let k;e[22]===Symbol.for("react.memo_cache_sentinel")?(k=r.jsx(oi,{size:14}),e[22]=k):k=e[22];let R;e[23]!==T?(R=r.jsx(ds,{asChild:!0,children:r.jsx(le,{type:"button",variant:"ghost",size:"icon","aria-label":T,className:"size-6 shrink-0 opacity-0 transition-opacity group-hover:opacity-100",onClick:FR,onPointerDown:$R,children:k})}),e[23]=T,e[24]=R):R=e[24];let P;e[25]===Symbol.for("react.memo_cache_sentinel")?(P=r.jsx(Os,{size:14}),e[25]=P):P=e[25];let D;e[26]!==c?(D=r.jsxs(Xe,{onClick:c,children:[P,"Duplicate"]}),e[26]=c,e[27]=D):D=e[27];let I;e[28]===Symbol.for("react.memo_cache_sentinel")?(I=r.jsx(Ns,{size:14}),e[28]=I):I=e[28];let M;e[29]!==d?(M=r.jsxs(Xe,{className:"text-destructive focus:text-destructive",onClick:d,children:[I,"Delete"]}),e[29]=d,e[30]=M):M=e[30];let O;e[31]!==D||e[32]!==M?(O=r.jsxs(hs,{align:"end",children:[D,M]}),e[31]=D,e[32]=M,e[33]=O):O=e[33];let $;e[34]!==R||e[35]!==O?($=r.jsxs(us,{children:[R,O]}),e[34]=R,e[35]=O,e[36]=$):$=e[36];let B;return e[37]!==u||e[38]!==n||e[39]!==f||e[40]!==l||e[41]!==m||e[42]!==y||e[43]!==V||e[44]!==E||e[45]!==$||e[46]!==_||e[47]!==w||e[48]!==S?(B=r.jsxs("div",{ref:m,style:y,...u,...f,role:"button",tabIndex:0,onClick:l,onKeyDown:_,className:w,title:n,children:[j,S,V,E,$]}),e[37]=u,e[38]=n,e[39]=f,e[40]=l,e[41]=m,e[42]=y,e[43]=V,e[44]=E,e[45]=$,e[46]=_,e[47]=w,e[48]=S,e[49]=B):B=e[49],B}function $R(t){return t.stopPropagation()}function FR(t){return t.stopPropagation()}function zR(t){return t.stopPropagation()}function KR(){return!1}function UR(t,e,s,n,i){if(e?.type==="object"&&e.properties&&Object.keys(e.properties).length>0||e?.type==="block-ref"&&e.anyOfRefs?.length)return e;if(t!=null&&typeof t=="object"&&!Array.isArray(t)){const o=t.__resolveType;if(typeof o=="string"&&s){const a=yn(o,s);if(a?.properties&&Object.keys(a.properties).length>0)return a}}if(s&&n&&i){const a=yn(n,s)?.properties?.[i]?.items;if(a?.properties&&Object.keys(a.properties).length>0)return{...a,titleBy:a.titleBy??e?.titleBy}}return e}function HR(t){const e=t.split(".").filter(s=>!/^\d+$/.test(s));return e[e.length-1]??t}function Ea(t){const e=F.c(27),{schema:s,value:n,onChange:i,path:o,label:a,breadcrumbPath:l,onBreadcrumbChange:c,hasSiblingDrillDownFields:d,meta:h,decofile:u,onSaveReferencedBlock:f,containerResolveType:m,previewBaseUrl:p,onAddSectionItem:g,onRequestAddSection:x,sandbox:v}=t,b=l===void 0?[]:l,y=re(),_=Array.isArray(n)?n:[],L=s.items,w=HR(o),j={arrayKey:w,hasSiblingDrillDownFields:d},S=RR(s,w),C=!S&&L?.type==="object",[N,V]=A.useState(null),E=ER(a,b,_,L,N),T=E?.index??null;E===null?N!==null&&V(null):E.index!==N&&V(E.index);const[k,R]=A.useState(()=>Rf(_.length)),[P,D]=A.useState(null),[I,M]=A.useState(o),[O,$]=A.useState(_.length),B=A.useRef(!1);I!==o?(M(o),$(_.length),R(Rf(_.length)),V(null)):O!==_.length&&($(_.length),R(ve=>DR(ve,_.length)));let z;e[0]!==L?(z=(ve,Le)=>vi(co(ve),Le,L),e[0]=L,e[1]=z):z=e[1];const K=z,G=ve=>{if(B.current)return;const Le=K(_[ve],ve);V(ve),c?.(Aa(b,a,Le,j))},Y=ve=>{const Le=[..._,ve];i(Le);const $e=Le.length-1;V($e);const ke=vi(ve,$e,L);c?.(Aa(b,a,ke,j))},U=()=>{const ve=L?.type,Le=L?.default!==void 0?L.default:ve==="object"?{}:ve==="block-ref"?(()=>{const Be=L?.anyOfRefs?.[0]?.resolveType;return typeof Be!="string"||vo(Be)?{}:{__resolveType:Be}})():ve==="number"||ve==="integer"?0:ve==="boolean"?!1:ve==="array"?[]:"",$e=[..._,Le];i($e);const ke=$e.length-1;V(ke);const Se=vi(Le,ke,L);c?.(Aa(b,a,Se,j))},W=()=>{if(S){if(!p){ge.error(y("sectionsEditor.arrayField.startPreviewServer"));return}if(x){x({append:Y});return}ge.error(y("sectionsEditor.arrayField.sectionPickerNotAvailable"));return}U()},H=ve=>{const Le=_[ve],$e=typeof structuredClone=="function"?structuredClone(Le):JSON.parse(JSON.stringify(Le??null)),ke=[..._.slice(0,ve+1),$e,..._.slice(ve+1)];i(ke),R(Se=>IR(Se,ve))},X=ve=>{const Le=_[ve],$e=[..._];$e[ve]=wo(Le)?Zg(Le):Vf(Le),i($e)},q=ve=>{i(_.filter((Le,$e)=>$e!==ve)),R(Le=>MR(Le,ve))},Z=(ve,Le)=>{const $e=[..._];if($e[ve]=wo(_[ve])?Vf(Le):Le,i($e),ve===T&&T!==null){const ke=K(_[ve],ve),Se=vi(Le,ve,L);if(ke!==Se){const Be=Ef(b,ke);if(Be>=0){const nt=[...b];nt[Be]=Se,c?.(nt)}}}};let Q;e[2]===Symbol.for("react.memo_cache_sentinel")?(Q={activationConstraint:{distance:8}},e[2]=Q):Q=e[2];let ee;e[3]===Symbol.for("react.memo_cache_sentinel")?(ee={coordinateGetter:tu},e[3]=ee):ee=e[3];const J=fc(ti($r,Q),ti(Br,ee)),te=k.map(WR);let se;e[4]===Symbol.for("react.memo_cache_sentinel")?(se=ve=>{D(String(ve.active.id))},e[4]=se):se=e[4];const ne=se,de=ve=>{D(null);const{active:Le,over:$e}=ve;if(!$e||Le.id===$e.id)return;const ke=te.indexOf(String(Le.id)),Se=te.indexOf(String($e.id));ke===-1||Se===-1||(R(Be=>r4(yr([...Be],ke,Se))),i(yr([..._],ke,Se)),B.current=!0,requestAnimationFrame(()=>{B.current=!1}))};let xe;e[5]===Symbol.for("react.memo_cache_sentinel")?(xe=()=>{D(null)},e[5]=xe):xe=e[5];const ue=xe,ce=P?k.find(ve=>ve.id===P):null,oe=ce!=null?_[ce.index]:void 0,fe=ce!=null&&oe!==void 0?K(oe,ce.index):null,pe=ce!=null&&oe!==void 0?Tf(co(oe),L):void 0;if(T!==null&&T<_.length){const ve=co(_[T]),Le=UR(ve,L,h,m,w),$e=()=>{const ke=K(ve,T),Se=Aa(b,a,ke,j),Be=Ef(Se,ke);return Be>=0?Se.slice(0,Be+1):Se};return r.jsx("div",{className:"min-w-0",children:Le?.type==="object"&&Le.properties?r.jsx(In,{schema:Le,value:ve,onChange:ke=>Z(T,ke),basePath:`${o}.${T}`,breadcrumbPath:E?.innerPath??[],onBreadcrumbChange:ke=>{c?.([...$e(),...ke])},meta:h,decofile:u,onSaveReferencedBlock:f,previewBaseUrl:p,onAddSectionItem:g,onRequestAddSection:x,sandbox:v}):Le?Ho({schema:Le,value:ve,onChange:ke=>Z(T,ke),path:`${o}.${T}`,label:Le.title&&!Le.title.includes("{{")?Le.title:K(ve,T),breadcrumbPath:E?.innerPath??[],onBreadcrumbChange:ke=>{c?.([...$e(),...ke])},meta:h,decofile:u,onSaveReferencedBlock:f,previewBaseUrl:p,onAddSectionItem:g,onRequestAddSection:x,sandbox:v}):null})}const we="space-y-2";let Ne;e[6]!==a?(Ne=r.jsx("span",{className:"min-w-0 truncate text-sm font-medium",children:a}),e[6]=a,e[7]=Ne):Ne=e[7];const Fe=_.length>0&&r.jsx("span",{className:"rounded-md bg-muted px-1.5 py-0.5 text-xs font-medium text-muted-foreground",children:_.length});let je;e[8]!==Ne||e[9]!==Fe?(je=r.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[Ne,Fe]}),e[8]=Ne,e[9]=Fe,e[10]=je):je=e[10];let Ie;e[11]!==s.description?(Ie=s.description&&r.jsx("p",{className:"break-words text-xs leading-normal text-muted-foreground",children:s.description}),e[11]=s.description,e[12]=Ie):Ie=e[12];let Pe;e[13]!==je||e[14]!==Ie?(Pe=r.jsxs("div",{className:"min-w-0 space-y-0.5",children:[je,Ie]}),e[13]=je,e[14]=Ie,e[15]=Pe):Pe=e[15];const Ye=_.length>0&&r.jsx("div",{className:ie(P&&"cursor-grabbing"),children:r.jsxs(xc,{sensors:J,collisionDetection:U9,onDragStart:ne,onDragEnd:de,onDragCancel:ue,children:[r.jsx(Z9,{items:te,strategy:Q9,children:r.jsx("div",{className:"min-w-0 overflow-hidden rounded-xl border border-border/50 p-1.5",children:k.map(ve=>{const Le=_[ve.index];if(Le===void 0)return null;const $e=K(Le,ve.index),ke=Tf(co(Le),L);return r.jsx(BR,{sortableId:ve.id,labelText:$e,imageSrc:ke,hidden:wo(Le),onToggleHidden:C?()=>X(ve.index):void 0,onOpen:()=>G(ve.index),onDuplicate:()=>H(ve.index),onRemove:()=>q(ve.index)},ve.id)})})}),r.jsx(G9,{dropAnimation:null,children:fe?r.jsx("div",{className:"flex min-w-0 items-center gap-2.5 rounded-lg border border-border/60 bg-background px-2 py-2.5 shadow-lg ring-1 ring-border/60",children:r.jsx(OR,{labelText:fe,imageSrc:pe})}):null})]})});let _e;e[16]===Symbol.for("react.memo_cache_sentinel")?(_e=r.jsx(kt,{size:14}),e[16]=_e):_e=e[16];let Ae;e[17]!==y||e[18]!==S?(Ae=y(S?"sectionsEditor.arrayField.addSection":"sectionsEditor.arrayField.addItem"),e[17]=y,e[18]=S,e[19]=Ae):Ae=e[19];let Re;e[20]!==W||e[21]!==Ae?(Re=r.jsxs("button",{type:"button",onClick:W,className:"flex w-full items-center justify-center gap-1.5 rounded-xl border border-dashed border-border/60 py-2.5 text-sm text-muted-foreground transition-colors hover:border-border hover:bg-muted/30",children:[_e,Ae]}),e[20]=W,e[21]=Ae,e[22]=Re):Re=e[22];let ye;return e[23]!==Pe||e[24]!==Ye||e[25]!==Re?(ye=r.jsxs("div",{className:we,children:[Pe,Ye,Re]}),e[23]=Pe,e[24]=Ye,e[25]=Re,e[26]=ye):ye=e[26],ye}function WR(t){return t.id}function qR(t){const e=F.c(44),{schema:s,value:n,onChange:i,path:o,label:a,breadcrumbPath:l,onBreadcrumbChange:c,meta:d,decofile:h,onSaveReferencedBlock:u,previewBaseUrl:f,onAddSectionItem:m,onRequestAddSection:p,sandbox:g}=t;let x;e[0]!==l?(x=l===void 0?[]:l,e[0]=l,e[1]=x):x=e[1];const v=x,[b,y]=A.useState(!1);let _;e[2]!==n?(_=n!=null&&typeof n=="object"&&!Array.isArray(n)?n:{},e[2]=n,e[3]=_):_=e[3];const L=_;if(!s.properties)return null;let w;e[4]!==o?(w=o.split(".").pop()??o,e[4]=o,e[5]=w):w=e[5];const j=w;let S;e[6]!==v||e[7]!==j||e[8]!==a||e[9]!==L||e[10]!==s?(S=AR(j,a,s,L,v),e[6]=v,e[7]=j,e[8]=a,e[9]=L,e[10]=s,e[11]=S):S=e[11];const N=b||S,V=`${o}-fields`;let E;e[12]===Symbol.for("react.memo_cache_sentinel")?(E=()=>y(GR),e[12]=E):E=e[12];let T;e[13]!==N?(T=r.jsx("span",{className:"flex size-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors group-hover:text-accent-foreground",children:N?r.jsx(ss,{size:16}):r.jsx(bn,{size:16})}),e[13]=N,e[14]=T):T=e[14];let k;e[15]!==a?(k=r.jsx("span",{className:"min-w-0 truncate text-sm font-medium",children:a}),e[15]=a,e[16]=k):k=e[16];let R;e[17]!==V||e[18]!==N||e[19]!==T||e[20]!==k?(R=r.jsxs("button",{type:"button","aria-expanded":N,"aria-controls":V,onClick:E,className:"group flex w-full min-w-0 items-center gap-2 rounded-md py-1.5 pr-2 text-left transition-colors hover:bg-accent hover:text-accent-foreground",children:[T,k]}),e[17]=V,e[18]=N,e[19]=T,e[20]=k,e[21]=R):R=e[21];let P;e[22]!==s.description?(P=s.description&&r.jsx("p",{className:"break-words pl-9 text-xs leading-normal text-muted-foreground",children:s.description}),e[22]=s.description,e[23]=P):P=e[23];let D;e[24]!==v||e[25]!==V||e[26]!==h||e[27]!==N||e[28]!==d||e[29]!==L||e[30]!==m||e[31]!==c||e[32]!==i||e[33]!==p||e[34]!==u||e[35]!==o||e[36]!==f||e[37]!==g||e[38]!==s?(D=N&&r.jsx("div",{id:V,className:"ml-3 min-w-0 max-w-full overflow-hidden border-l border-border/80 pl-5",children:r.jsx(In,{schema:s,value:L,onChange:i,basePath:o,breadcrumbPath:v,onBreadcrumbChange:c,meta:d,decofile:h,onSaveReferencedBlock:u,previewBaseUrl:f,onAddSectionItem:m,onRequestAddSection:p,sandbox:g})}),e[24]=v,e[25]=V,e[26]=h,e[27]=N,e[28]=d,e[29]=L,e[30]=m,e[31]=c,e[32]=i,e[33]=p,e[34]=u,e[35]=o,e[36]=f,e[37]=g,e[38]=s,e[39]=D):D=e[39];let I;return e[40]!==P||e[41]!==D||e[42]!==R?(I=r.jsxs("div",{className:"min-w-0 space-y-2",children:[R,P,D]}),e[40]=P,e[41]=D,e[42]=R,e[43]=I):I=e[43],I}function GR(t){return!t}function QH(t,e,s,n,i){const o={...t[e]};if(i.length>1){const a=o.sections,l=[...a?.variants??[]];l[n]&&(l[n]={...l[n],value:s}),o.sections={...a,variants:l}}else o.sections=s;return o}function ZH(t){return structuredClone(t)}function eW(t){return!t.isSavedBlock&&!t.isMultivariate&&!t.isHidden}function o4(t){const e=t.replace(/[^A-Za-z0-9_ -]/g,"").replace(/\s+/g," ").trim();return/^[A-Za-z]/.test(e)?e:e?`Block ${e}`:""}function _u(t,e){const s=t.trim();return s?s.includes("/")?"Block name cannot contain slashes.":Object.hasOwn(e,s)?"A block with this name already exists.":/^[A-Za-z][A-Za-z0-9_ -]*$/.test(s)?null:"Use letters, numbers, spaces, hyphens, or underscores. Must start with a letter.":"Block name is required."}function yu(t){const e=F.c(61),{open:s,onOpenChange:n,defaultBlockId:i,isPending:o,onSubmit:a}=t,l=i===void 0?"":i,c=o===void 0?!1:o,[d,h]=A.useState(l),[u,f]=A.useState(s);s!==u&&(f(s),s&&h(l));let m;e[0]!==c||e[1]!==n?(m=B=>{!B&&!c&&n(!1)},e[0]=c,e[1]=n,e[2]=m):m=e[2];const p=m;let g;e[3]!==d||e[4]!==c||e[5]!==a?(g=async B=>{B.preventDefault();const z=d.trim();!z||c||await a(z)},e[3]=d,e[4]=c,e[5]=a,e[6]=g):g=e[6];const x=g,v=re();let b;e[7]!==v?(b=v("sectionsEditor.makeReusableModal.title"),e[7]=v,e[8]=b):b=e[8];let y;e[9]!==b?(y=r.jsx(ps,{children:b}),e[9]=b,e[10]=y):y=e[10];let _;e[11]!==v?(_=v("sectionsEditor.makeReusableModal.description"),e[11]=v,e[12]=_):_=e[12];let L;e[13]!==_?(L=r.jsx(ri,{children:_}),e[13]=_,e[14]=L):L=e[14];let w;e[15]!==y||e[16]!==L?(w=r.jsxs(ms,{children:[y,L]}),e[15]=y,e[16]=L,e[17]=w):w=e[17];let j;e[18]!==v?(j=v("sectionsEditor.makeReusableModal.blockNameLabel"),e[18]=v,e[19]=j):j=e[19];let S;e[20]!==j?(S=r.jsx("label",{htmlFor:"block-id",className:"text-sm font-medium",children:j}),e[20]=j,e[21]=S):S=e[21];let C;e[22]===Symbol.for("react.memo_cache_sentinel")?(C=B=>h(B.target.value),e[22]=C):C=e[22];let N;e[23]!==v?(N=v("sectionsEditor.makeReusableModal.blockNamePlaceholder"),e[23]=v,e[24]=N):N=e[24];let V;e[25]!==d||e[26]!==c||e[27]!==N?(V=r.jsx(rt,{id:"block-id",value:d,onChange:C,placeholder:N,autoFocus:!0,disabled:c}),e[25]=d,e[26]=c,e[27]=N,e[28]=V):V=e[28];let E;e[29]!==S||e[30]!==V?(E=r.jsxs("div",{className:"py-4 space-y-2",children:[S,V]}),e[29]=S,e[30]=V,e[31]=E):E=e[31];let T;e[32]!==n?(T=()=>n(!1),e[32]=n,e[33]=T):T=e[33];let k;e[34]!==v?(k=v("sectionsEditor.makeReusableModal.cancel"),e[34]=v,e[35]=k):k=e[35];let R;e[36]!==c||e[37]!==T||e[38]!==k?(R=r.jsx(le,{type:"button",variant:"outline",onClick:T,disabled:c,children:k}),e[36]=c,e[37]=T,e[38]=k,e[39]=R):R=e[39];let P;e[40]!==d||e[41]!==c?(P=!d.trim()||c,e[40]=d,e[41]=c,e[42]=P):P=e[42];let D;e[43]!==c||e[44]!==v?(D=c?r.jsxs(r.Fragment,{children:[r.jsx(et,{size:14,className:"animate-spin"}),v("sectionsEditor.makeReusableModal.saving")]}):v("sectionsEditor.makeReusableModal.save"),e[43]=c,e[44]=v,e[45]=D):D=e[45];let I;e[46]!==P||e[47]!==D?(I=r.jsx(le,{type:"submit",disabled:P,children:D}),e[46]=P,e[47]=D,e[48]=I):I=e[48];let M;e[49]!==R||e[50]!==I?(M=r.jsxs(Mi,{children:[R,I]}),e[49]=R,e[50]=I,e[51]=M):M=e[51];let O;e[52]!==x||e[53]!==E||e[54]!==M||e[55]!==w?(O=r.jsx(es,{className:"sm:max-w-md",children:r.jsxs("form",{onSubmit:x,children:[w,E,M]})}),e[52]=x,e[53]=E,e[54]=M,e[55]=w,e[56]=O):O=e[56];let $;return e[57]!==p||e[58]!==s||e[59]!==O?($=r.jsx(ts,{open:s,onOpenChange:p,children:O}),e[57]=p,e[58]=s,e[59]=O,e[60]=$):$=e[60],$}function a4(t){return t===Dr||t===Ki}function jc(t,e){if(!Object.hasOwn(e,t))return null;const s=e[t]??{},n=s.__resolveType??t;return{data:{...s},resolveType:n}}function Rl(t,e){const s=t.__resolveType??"";if(!s)return null;if(fs(s)){const n=t.section??{};return l4(n,e)}if(a4(s)){const n=t.variants?.[0]?.value;return n?Rl(n,e):null}return!_n(s)||!Object.hasOwn(e,s)?{data:{...t},resolveType:s}:jc(s,e)}function l4(t,e){const s=t.__resolveType??"";if(!s)return null;if(a4(s)){const n=t.variants?.[0]?.value;return n?Rl(n,e):null}return!_n(s)||!Object.hasOwn(e,s)?{data:{...t},resolveType:s}:jc(s,e)}function YR(t,e){if(!t||typeof t!="object"||Array.isArray(t))return null;const n=t.__resolveType;if(typeof n!="string"||!_n(n)||!Object.hasOwn(e,n))return null;const i=jc(n,e);return i?{blockKey:n,...i}:null}function JR(t,e,s){if(e.isMultivariate)return null;if(e.isSavedBlock){const n=e.isLazy?t.section?.__resolveType??t.__resolveType:t.__resolveType;return jc(n,s)}if(e.isHidden){const o=(fs(t.__resolveType)?t.section:t)?.variants?.[0]?.value??t;return Rl(o,s)}if(e.isLazy||fs(t.__resolveType)){const n=t.section??{};return l4(n,s)}return Rl(t,s)}function XR(t){if(!t?.properties)return{};const e={};for(const[s,n]of Object.entries(t.properties))s.startsWith("__")||s==="@type"||(n.default!==void 0?e[s]=n.default:n.type==="boolean"?e[s]=!1:n.type==="string"?e[s]="":n.type==="number"||n.type==="integer"?e[s]=0:n.type==="object"&&(e[s]={}));return e}function QR(t){const e=F.c(13),{blockKey:s}=t,n=re();let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(ai,{size:11}),e[0]=i):i=e[0];let o;e[1]!==n?(o=n("sectionsEditor.anyOfField.global"),e[1]=n,e[2]=o):o=e[2];let a;e[3]!==o?(a=r.jsx(ze,{asChild:!0,children:r.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 rounded bg-global-section/14 px-1.5 py-0.5 text-[11px] font-medium text-global-section-fg dark:text-global-section-fg-dark",children:[i,o]})}),e[3]=o,e[4]=a):a=e[4];let l;e[5]!==s||e[6]!==n?(l=n("sectionsEditor.anyOfField.globalLoaderTooltip",{blockKey:s}),e[5]=s,e[6]=n,e[7]=l):l=e[7];let c;e[8]!==l?(c=r.jsx(Ke,{side:"top",className:"max-w-[260px]",children:l}),e[8]=l,e[9]=c):c=e[9];let d;return e[10]!==a||e[11]!==c?(d=r.jsxs(Ue,{children:[a,c]}),e[10]=a,e[11]=c,e[12]=d):d=e[12],d}function ZR(t){const e=F.c(36),{path:s,open:n,onOpenChange:i,title:o,nested:a,nestedBlockRef:l,globalBlockKey:c,onDetach:d,onMakeGlobal:h}=t,u=re(),f=`${s}-loader-config`,m=l&&"ml-1";let p;e[0]!==m?(p=ie("rounded-lg border border-border/80 bg-muted/30",m),e[0]=m,e[1]=p):p=e[1];let g;e[2]!==i||e[3]!==n?(g=()=>i(!n),e[2]=i,e[3]=n,e[4]=g):g=e[4];let x;e[5]!==n?(x=r.jsx("span",{className:"flex size-6 shrink-0 items-center justify-center text-muted-foreground transition-colors group-hover:text-foreground",children:n?r.jsx(ss,{size:16}):r.jsx(bn,{size:16})}),e[5]=n,e[6]=x):x=e[6];let v;e[7]!==o?(v=r.jsx("span",{className:"truncate text-xs font-medium tracking-wide text-muted-foreground uppercase",children:o}),e[7]=o,e[8]=v):v=e[8];let b;e[9]!==c?(b=c&&r.jsx(QR,{blockKey:c}),e[9]=c,e[10]=b):b=e[10];let y;e[11]!==v||e[12]!==b?(y=r.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[v,b]}),e[11]=v,e[12]=b,e[13]=y):y=e[13];let _;e[14]!==f||e[15]!==n||e[16]!==g||e[17]!==x||e[18]!==y?(_=r.jsxs("button",{type:"button","aria-expanded":n,"aria-controls":f,onClick:g,className:"flex min-w-0 flex-1 items-center gap-2 rounded-lg px-3 py-2.5 text-left",children:[x,y]}),e[14]=f,e[15]=n,e[16]=g,e[17]=x,e[18]=y,e[19]=_):_=e[19];let L;e[20]!==c||e[21]!==d||e[22]!==h||e[23]!==u?(L=(d||h)&&r.jsxs(us,{children:[r.jsx(ds,{asChild:!0,children:r.jsx(le,{type:"button",variant:"ghost",size:"icon","aria-label":u("sectionsEditor.anyOfField.loaderActions"),className:"h-7 w-7 shrink-0 text-muted-foreground",children:r.jsx(oi,{size:16})})}),r.jsxs(hs,{align:"end",className:"w-48",children:[c&&d&&r.jsxs(Xe,{onClick:d,children:[r.jsx(Nn,{className:"h-4 w-4"}),u("sectionsEditor.anyOfField.detach")]}),!c&&h&&r.jsxs(Xe,{onClick:h,children:[r.jsx(ai,{className:"h-4 w-4"}),u("sectionsEditor.anyOfField.makeGlobal")]})]})]}),e[20]=c,e[21]=d,e[22]=h,e[23]=u,e[24]=L):L=e[24];let w;e[25]!==_||e[26]!==L?(w=r.jsxs("div",{className:"group flex w-full min-w-0 items-center gap-1 rounded-lg pr-2 transition-colors hover:bg-accent/50",children:[_,L]}),e[25]=_,e[26]=L,e[27]=w):w=e[27];let j;e[28]!==f||e[29]!==a||e[30]!==n?(j=n&&r.jsx("div",{id:f,className:"border-t border-border/60 px-4 pb-4 pt-3",children:r.jsx("div",{className:"border-l border-border/80 pl-4",children:a})}),e[28]=f,e[29]=a,e[30]=n,e[31]=j):j=e[31];let S;return e[32]!==w||e[33]!==j||e[34]!==p?(S=r.jsxs("div",{className:p,children:[w,j]}),e[32]=w,e[33]=j,e[34]=p,e[35]=S):S=e[35],S}function Df(t){const e=F.c(38),{schema:s,value:n,onChange:i,path:o,label:a,breadcrumbPath:l,onBreadcrumbChange:c,meta:d,decofile:h,onSaveReferencedBlock:u,sandbox:f}=t,m=re(),p=(s.anyOfRefs??[]).filter(sD),g=h&&n?YR(n,h):null,x=g?.data??n,v=g?null:e4(x),b=v??x,y=gR(p,{savedBlockKey:g?.blockKey,editorValue:x}),_=y.length>0?xR(x,y,g?.blockKey):y[0]?.resolveType??"",w=s.type==="block-ref"&&y.some(tD);let j;e[0]!==a||e[1]!==o?(j=a??(o.includes(".")?o.split(".")[0]:o),e[0]=a,e[1]=o,e[2]=j):j=e[2];const S=j;let C;e[3]!==l?(C=l??[],e[3]=l,e[4]=C):C=e[4];const N=C,V=w&&N[0]===S,E=V?N.slice(1):N,T=V?H=>{c?.([S,...H])}:c,[k,R]=A.useState(_),[P,D]=A.useState(_);P!==_&&(D(_),R(_));const[I,M]=A.useState(()=>bR(x,g?.blockKey)),[O,$]=A.useState(!1);if(y.length>0){const H=k||_;let X;e[5]!==H?(X=je=>je.resolveType===H,e[5]=H,e[6]=X):X=e[6];const q=y.find(X),Z=Nf(x,d,q?.schema),Q=vR(Z??q?.schema??null,s.discriminatorKey),ee=s.discriminatorKey,J=je=>{R(je);const Ie=y.find(ye=>ye.resolveType===je),Pe=Nf(x,d,Ie?.schema),Ye=new Set(Object.keys((Pe??Ie?.schema)?.properties??{})),_e=n!==null&&typeof n=="object"&&!Array.isArray(n)?n:{},Ae=Object.fromEntries(Object.entries(_e).filter(ye=>{const[ve]=ye;return Ye.has(ve)})),Re={...XR(Ie?.schema),...Ae};if(ee){const ye=Ie?.discriminatorValue??je;i({...Re,[ee]:ye});return}if(vo(je)){i(Re);return}i({...Re,__resolveType:je})};let te;e[7]!==H||e[8]!==ee||e[9]!==i?(te=je=>{if(ee||!vo(H)||je===null||typeof je!="object"||Array.isArray(je)){i(je);return}const{__resolveType:Ie,...Pe}=je;i(Pe)},e[7]=H,e[8]=ee,e[9]=i,e[10]=te):te=e[10];const se=te,ne=Q?.properties?r.jsx(In,{schema:Q,value:b,onChange:je=>{if(g&&u){u(g.blockKey,je);return}if(v){i({...x,section:je});return}se(je)},basePath:o,breadcrumbPath:E,onBreadcrumbChange:T,meta:d,decofile:h,onSaveReferencedBlock:u,sandbox:f}):null;let de;e[11]!==o?(de=o.includes("."),e[11]=o,e[12]=de):de=e[12];const xe=de,ue=g?()=>{const{name:je,...Ie}=g.data;i(Ie)}:void 0,ce=!g&&!v&&!!u&&w&&!vo(H)&&H.includes("/"),oe=b&&typeof b=="object"&&!Array.isArray(b)?b:{},fe=je=>{if(!u)return;const Ie=je.trim(),Pe=h?_u(Ie,h):null;if(Pe){ge.error(Pe);return}u(Ie,{...oe,__resolveType:H,name:Ie}),i({__resolveType:Ie}),$(!1),ge.success(m("sectionsEditor.anyOfField.globalBlockSaved",{name:Ie}))};let pe;e[13]!==a||e[14]!==o?(pe=r.jsx(lt,{htmlFor:o,children:a}),e[13]=a,e[14]=o,e[15]=pe):pe=e[15];let we;e[16]!==m?(we=m("sectionsEditor.anyOfField.selectPlaceholder"),e[16]=m,e[17]=we):we=e[17];let Ne;e[18]!==we?(Ne=r.jsx(Jt,{children:r.jsx(as,{placeholder:we})}),e[18]=we,e[19]=Ne):Ne=e[19];let Fe;return e[20]!==s.description?(Fe=s.description&&r.jsx("p",{className:"text-xs text-muted-foreground",children:s.description}),e[20]=s.description,e[21]=Fe):Fe=e[21],r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"space-y-1.5",children:[pe,r.jsxs(Qt,{value:H||void 0,onValueChange:J,children:[Ne,r.jsx(Xt,{children:y.map(eD)})]}),Fe]}),ne&&(w?r.jsx(ZR,{path:o,open:I,onOpenChange:M,title:m(xe?"sectionsEditor.anyOfField.configuration":"sectionsEditor.anyOfField.loaderConfiguration"),nested:ne,nestedBlockRef:xe,globalBlockKey:g?.blockKey,onDetach:ue,onMakeGlobal:ce?()=>$(!0):void 0}):ne),ce&&r.jsx(yu,{open:O,onOpenChange:$,defaultBlockId:o4(Tt(H)),onSubmit:fe})]})}if(s.anyOfRefs&&s.anyOfRefs.length>0)return null;let B;e[22]!==a||e[23]!==o?(B=r.jsx(lt,{htmlFor:o,children:a}),e[22]=a,e[23]=o,e[24]=B):B=e[24];const z=n!=null?String(n):"";let K;e[25]!==i?(K=H=>i(H.target.value),e[25]=i,e[26]=K):K=e[26];const G=s.description??"";let Y;e[27]!==o||e[28]!==z||e[29]!==K||e[30]!==G?(Y=r.jsx("input",{id:o,type:"text",value:z,onChange:K,className:"w-full rounded-md border bg-background px-3 py-1.5 text-sm",placeholder:G}),e[27]=o,e[28]=z,e[29]=K,e[30]=G,e[31]=Y):Y=e[31];let U;e[32]!==s.description?(U=s.description&&r.jsx("p",{className:"text-xs text-muted-foreground",children:s.description}),e[32]=s.description,e[33]=U):U=e[33];let W;return e[34]!==B||e[35]!==Y||e[36]!==U?(W=r.jsxs("div",{className:"space-y-1.5",children:[B,Y,U]}),e[34]=B,e[35]=Y,e[36]=U,e[37]=W):W=e[37],W}function eD(t){const e=t.title&&!t.title.includes("/")?t.title:Id(t.resolveType)??Tt(t.resolveType);return r.jsx(vt,{value:t.resolveType,children:e},t.resolveType)}function tD(t){return t.resolveType.includes("/")&&!vo(t.resolveType)}function sD(t){return t.resolveType!==""}function nD(t){if(!Array.isArray(t))return[];const e=[];for(const s of t)if(typeof s=="string")e.push({value:s,label:s});else if(s&&typeof s=="object"&&"value"in s){const n=s;e.push({value:String(n.value),label:typeof n.label=="string"?n.label:String(n.value),image:typeof n.image=="string"?n.image:void 0,icon:typeof n.icon=="string"?n.icon:void 0})}return e}function iD(t){if(!Array.isArray(t))return[];const e=[];for(const s of t)typeof s=="string"&&e.push({value:s,label:s});return e}function rD(t,e){return t.length>0?t:e}function oD(t,e){const s=e.trim().toLowerCase();return s?t.filter(n=>n.value.toLowerCase().includes(s)||(n.label??"").toLowerCase().includes(s)):t}function aD(t,e){const n=`<style>${e?`svg{color:${e}}`:""}.fill-current{fill:currentColor}.stroke-current{stroke:currentColor}.text-current{color:currentColor}</style>`,i=t.replace(/(<svg[^>]*>)/i,`$1${n}`);return`data:image/svg+xml;utf8,${encodeURIComponent(i)}`}function lD(){return getComputedStyle(document.documentElement).color||void 0}function cD(t){if(t.image)return t.image;if(t.icon)return aD(t.icon,lD())}async function dD(t,e,s){const n={};s&&(n.term=s);const o=`${t.replace(/\/+$/,"")}/deco/invoke/${e}`,a=await fetch(o,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(n)});if(!a.ok)throw new Error(`Failed to fetch dynamic options: ${a.status}`);const l=await a.json();return nD(l)}function If(t){const e=F.c(8),{option:s,className:n}=t;let i;e[0]!==s?(i=cD(s),e[0]=s,e[1]=i):i=e[1];const o=i;if(!o)return null;const a=s.image?"rounded object-cover":"object-contain";let l;e[2]!==n||e[3]!==a?(l=ie("shrink-0",a,n),e[2]=n,e[3]=a,e[4]=l):l=e[4];let c;return e[5]!==o||e[6]!==l?(c=r.jsx("img",{src:o,alt:"",referrerPolicy:"no-referrer",className:l}),e[5]=o,e[6]=l,e[7]=c):c=e[7],c}function Mf(t){const e=F.c(8),{path:s,label:n,description:i}=t;let o;e[0]!==n||e[1]!==s?(o=r.jsx(lt,{htmlFor:s,children:n}),e[0]=n,e[1]=s,e[2]=o):o=e[2];let a;e[3]!==i?(a=i&&r.jsx("p",{className:"text-xs leading-normal text-muted-foreground",children:i}),e[3]=i,e[4]=a):a=e[4];let l;return e[5]!==o||e[6]!==a?(l=r.jsxs("div",{className:"space-y-0.5",children:[o,a]}),e[5]=o,e[6]=a,e[7]=l):l=e[7],l}function uD(t){const e=F.c(107),{schema:s,value:n,onChange:i,path:o,label:a,sandbox:l}=t,c=re(),d=s.options,h=l?.previewUrl,[u,f]=A.useState(!1),[m,p]=A.useState(""),[g,x]=A.useState(""),v=A.useRef(null);let b;e[0]===Symbol.for("react.memo_cache_sentinel")?(b=ee=>{p(ee),v.current&&clearTimeout(v.current),v.current=setTimeout(()=>{x(ee)},300)},e[0]=b):b=e[0];const y=b,_=l?`${l.orgSlug}/${l.virtualMcpId}/${l.branch}`:"",L=typeof n=="string"?n:"";let w;e[1]!==g||e[2]!==d||e[3]!==_?(w=at.sandboxInvoke(_,`dynamic-options:${d??""}:${g}`),e[1]=g,e[2]=d,e[3]=_,e[4]=w):w=e[4];let j;e[5]!==g||e[6]!==d||e[7]!==h?(j=()=>dD(h,d,g||void 0),e[5]=g,e[6]=d,e[7]=h,e[8]=j):j=e[8];const S=!!h&&!!d&&(u||!!L);let C;e[9]!==w||e[10]!==j||e[11]!==S?(C={queryKey:w,queryFn:j,enabled:S,staleTime:6e4,retry:1},e[9]=w,e[10]=j,e[11]=S,e[12]=C):C=e[12];const N=Mt(C);let V,E,T,k,R,P,D,I,M,O,$,B,z,K,G,Y,U;if(e[13]!==L||e[14]!==a||e[15]!==d||e[16]!==i||e[17]!==u||e[18]!==o||e[19]!==h||e[20]!==N.data||e[21]!==N.isLoading||e[22]!==s.description||e[23]!==s.enum||e[24]!==m||e[25]!==c){z=Symbol.for("react.early_return_sentinel");e:{const ee=iD(s.enum),J=rD(N.data??[],ee),te=oD(J,m);let se;e[43]!==L?(se=fe=>fe.value===L,e[43]=L,e[44]=se):se=e[44];const ne=J.find(se);if((!h||!d)&&ee.length===0){let fe;e[45]!==a||e[46]!==o||e[47]!==s.description?(fe=r.jsx(Mf,{path:o,label:a,description:s.description}),e[45]=a,e[46]=o,e[47]=s.description,e[48]=fe):fe=e[48];let pe;e[49]!==i?(pe=Fe=>i(Fe.target.value),e[49]=i,e[50]=pe):pe=e[50];let we;e[51]!==L||e[52]!==o||e[53]!==pe?(we=r.jsx(rt,{id:o,type:"text",value:L,onChange:pe}),e[51]=L,e[52]=o,e[53]=pe,e[54]=we):we=e[54];let Ne;e[55]!==fe||e[56]!==we?(Ne=r.jsxs("div",{className:"space-y-2",children:[fe,we]}),e[55]=fe,e[56]=we,e[57]=Ne):Ne=e[57],z=Ne;break e}$="space-y-2",e[58]!==a||e[59]!==o||e[60]!==s.description?(B=r.jsx(Mf,{path:o,label:a,description:s.description}),e[58]=a,e[59]=o,e[60]=s.description,e[61]=B):B=e[61],R=As,I=u,M=f;const de=ne?r.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[r.jsx(If,{option:ne,className:"h-6 w-6"}),r.jsx("span",{className:"truncate",children:ne.label??ne.value})]}):L?r.jsx("span",{className:"truncate",children:L}):r.jsx("span",{className:"text-muted-foreground",children:c("sectionsEditor.dynamicOptionsField.selectPlaceholder")});let xe;e[62]===Symbol.for("react.memo_cache_sentinel")?(xe=r.jsx(x9,{className:"size-4 shrink-0 opacity-50"}),e[62]=xe):xe=e[62],e[63]!==u||e[64]!==de?(O=r.jsx(Es,{asChild:!0,children:r.jsxs(le,{variant:"outline",role:"combobox","aria-expanded":u,className:"h-10 w-full justify-between font-normal",children:[de,xe]})}),e[63]=u,e[64]=de,e[65]=O):O=e[65],k=Ps,P="p-0",e[66]===Symbol.for("react.memo_cache_sentinel")?(D={width:"var(--radix-popover-trigger-width)"},e[66]=D):D=e[66],T=Tr,Y=!1;let ue;e[67]!==c?(ue=c("sectionsEditor.dynamicOptionsField.searchPlaceholder"),e[67]=c,e[68]=ue):ue=e[68],e[69]!==m||e[70]!==ue?(U=r.jsx($i,{placeholder:ue,className:"h-9",value:m,onValueChange:y}),e[69]=m,e[70]=ue,e[71]=U):U=e[71],E=Fi;let ce;e[72]!==N.isLoading||e[73]!==c?(ce=N.isLoading?c("sectionsEditor.dynamicOptionsField.loading"):c("sectionsEditor.dynamicOptionsField.noResults"),e[72]=N.isLoading,e[73]=c,e[74]=ce):ce=e[74],e[75]!==ce?(G=r.jsx(Qn,{children:ce}),e[75]=ce,e[76]=G):G=e[76],V=Ms;let oe;e[77]!==L||e[78]!==i?(oe=fe=>r.jsxs(Vs,{value:fe.value,onSelect:()=>{i(fe.value===L?"":fe.value),f(!1)},children:[r.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[r.jsx(If,{option:fe,className:ie(fe.image?"h-9 w-9":"h-6 w-6")}),r.jsx("span",{className:"truncate",children:fe.label??fe.value})]}),r.jsx(zt,{className:ie("ml-auto size-4 shrink-0",L===fe.value?"opacity-100":"opacity-0")})]},fe.value),e[77]=L,e[78]=i,e[79]=oe):oe=e[79],K=te.map(oe)}e[13]=L,e[14]=a,e[15]=d,e[16]=i,e[17]=u,e[18]=o,e[19]=h,e[20]=N.data,e[21]=N.isLoading,e[22]=s.description,e[23]=s.enum,e[24]=m,e[25]=c,e[26]=V,e[27]=E,e[28]=T,e[29]=k,e[30]=R,e[31]=P,e[32]=D,e[33]=I,e[34]=M,e[35]=O,e[36]=$,e[37]=B,e[38]=z,e[39]=K,e[40]=G,e[41]=Y,e[42]=U}else V=e[26],E=e[27],T=e[28],k=e[29],R=e[30],P=e[31],D=e[32],I=e[33],M=e[34],O=e[35],$=e[36],B=e[37],z=e[38],K=e[39],G=e[40],Y=e[41],U=e[42];if(z!==Symbol.for("react.early_return_sentinel"))return z;let W;e[80]!==V||e[81]!==K?(W=r.jsx(V,{children:K}),e[80]=V,e[81]=K,e[82]=W):W=e[82];let H;e[83]!==E||e[84]!==W||e[85]!==G?(H=r.jsxs(E,{children:[G,W]}),e[83]=E,e[84]=W,e[85]=G,e[86]=H):H=e[86];let X;e[87]!==T||e[88]!==H||e[89]!==Y||e[90]!==U?(X=r.jsxs(T,{shouldFilter:Y,children:[U,H]}),e[87]=T,e[88]=H,e[89]=Y,e[90]=U,e[91]=X):X=e[91];let q;e[92]!==k||e[93]!==P||e[94]!==D||e[95]!==X?(q=r.jsx(k,{className:P,style:D,children:X}),e[92]=k,e[93]=P,e[94]=D,e[95]=X,e[96]=q):q=e[96];let Z;e[97]!==R||e[98]!==I||e[99]!==M||e[100]!==O||e[101]!==q?(Z=r.jsxs(R,{open:I,onOpenChange:M,children:[O,q]}),e[97]=R,e[98]=I,e[99]=M,e[100]=O,e[101]=q,e[102]=Z):Z=e[102];let Q;return e[103]!==$||e[104]!==B||e[105]!==Z?(Q=r.jsxs("div",{className:$,children:[B,Z]}),e[103]=$,e[104]=B,e[105]=Z,e[106]=Q):Q=e[106],Q}function hD(t){const e=F.c(17),{org:s}=Oe(),n=$s();let i,o,a,l;e[0]!==s.id||e[1]!==t.configId||e[2]!==t.imageOnly||e[3]!==t.search?(o=t.search?.trim()||void 0,i=t.imageOnly??!1,l=Xm,a=at.filePickerObjects(s.id,t.configId,o,i),e[0]=s.id,e[1]=t.configId,e[2]=t.imageOnly,e[3]=t.search,e[4]=i,e[5]=o,e[6]=a,e[7]=l):(i=e[4],o=e[5],a=e[6],l=e[7]);const c=t.enabled!==!1&&!!t.configId;let d;e[8]!==i||e[9]!==t.configId||e[10]!==o||e[11]!==n?(d=async u=>{const{pageParam:f}=u;return await n.call("FILE_OBJECTS_LIST",{configId:t.configId,cursor:f??void 0,search:o,imageOnly:i||void 0})},e[8]=i,e[9]=t.configId,e[10]=o,e[11]=n,e[12]=d):d=e[12];let h;return e[13]!==a||e[14]!==c||e[15]!==d?(h={queryKey:a,enabled:c,staleTime:3e4,initialPageParam:null,queryFn:d,getNextPageParam:fD},e[13]=a,e[14]=c,e[15]=d,e[16]=h):h=e[16],l(h)}function fD(t){return t.nextCursor??void 0}function Lu(){const t=F.c(2),{org:e}=Oe();let s;return t[0]!==e?(s={mutationFn:async n=>{const i=n.file.type||"application/octet-stream",o=await fetch(`/api/${encodeURIComponent(e.slug)}/file-configs/${encodeURIComponent(n.configId)}/upload?filename=${encodeURIComponent(n.file.name)}`,{method:"POST",headers:{"Content-Type":i},body:n.file});if(!o.ok){const a=await o.text().catch(mD);let l=`${o.status} ${o.statusText}`;try{const c=JSON.parse(a);c.message&&(l=c.message)}catch{a&&(l=a.slice(0,200))}throw new Error(`Upload failed: ${l}`)}return await o.json()}},t[0]=e,t[1]=s):s=t[1],Ys(s)}function mD(){return""}const Cc="file-picker:last-config-id";function c4(t){const e=F.c(31),s=re(),n=t.open,i=t.onOpenChange;let o;e[0]!==t.mode||e[1]!==s?(o=t.mode==="image"?s("filePicker.filePickerDialog.pickAnImage"):s("filePicker.filePickerDialog.pickAFile"),e[0]=t.mode,e[1]=s,e[2]=o):o=e[2];let a;e[3]!==o?(a=r.jsx(ps,{children:o}),e[3]=o,e[4]=a):a=e[4];let l;e[5]!==s?(l=s("filePicker.filePickerDialog.description"),e[5]=s,e[6]=l):l=e[6];let c;e[7]!==l?(c=r.jsx(ri,{children:l}),e[7]=l,e[8]=c):c=e[8];let d;e[9]!==a||e[10]!==c?(d=r.jsxs(ms,{children:[a,c]}),e[9]=a,e[10]=c,e[11]=d):d=e[11];let h;e[12]!==s?(h=v=>{const{error:b}=v;return r.jsx(pD,{error:b??new Error(s("filePicker.filePickerDialog.failedToLoadBuckets"))})},e[12]=s,e[13]=h):h=e[13];let u;e[14]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx(Rt,{className:"h-64 w-full"}),e[14]=u):u=e[14];let f;e[15]!==t?(f=v=>{t.onSelect(v),t.onOpenChange(!1)},e[15]=t,e[16]=f):f=e[16];let m;e[17]!==t.lockedConfigId||e[18]!==t.mode||e[19]!==f?(m=r.jsx(A.Suspense,{fallback:u,children:r.jsx(gD,{mode:t.mode,lockedConfigId:t.lockedConfigId,onSelect:f})}),e[17]=t.lockedConfigId,e[18]=t.mode,e[19]=f,e[20]=m):m=e[20];let p;e[21]!==m||e[22]!==h?(p=r.jsx(ys,{fallback:h,children:m}),e[21]=m,e[22]=h,e[23]=p):p=e[23];let g;e[24]!==p||e[25]!==d?(g=r.jsxs(es,{className:"sm:max-w-3xl max-h-[85vh] overflow-hidden flex flex-col",children:[d,p]}),e[24]=p,e[25]=d,e[26]=g):g=e[26];let x;return e[27]!==t.onOpenChange||e[28]!==t.open||e[29]!==g?(x=r.jsx(ts,{open:n,onOpenChange:i,children:g}),e[27]=t.onOpenChange,e[28]=t.open,e[29]=g,e[30]=x):x=e[30],x}function pD(t){const e=F.c(3),{error:s}=t;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=r.jsx(wn,{size:16}),e[0]=n):n=e[0];let i;return e[1]!==s.message?(i=r.jsxs("div",{className:"p-4 rounded-md bg-destructive/10 text-destructive flex items-center gap-2",children:[n,r.jsx("span",{className:"text-sm font-medium",children:s.message})]}),e[1]=s.message,e[2]=i):i=e[2],i}function gD(t){const e=F.c(32),{mode:s,lockedConfigId:n,onSelect:i}=t,o=Ub();if(o.length===0){let p;return e[0]===Symbol.for("react.memo_cache_sentinel")?(p=r.jsx(bD,{}),e[0]=p):p=e[0],p}if(n){let p;if(e[1]!==o||e[2]!==n){let x;e[4]!==n?(x=v=>v.id===n,e[4]=n,e[5]=x):x=e[5],p=o.find(x),e[1]=o,e[2]=n,e[3]=p}else p=e[3];const g=p;if(g){let x;return e[6]!==g||e[7]!==s||e[8]!==i?(x=r.jsx(rd,{config:g,mode:s,onSelect:i}),e[6]=g,e[7]=s,e[8]=i,e[9]=x):x=e[9],x}}if(o.length===1){const p=o[0];let g;return e[10]!==p||e[11]!==s||e[12]!==i?(g=r.jsx(rd,{config:p,mode:s,onSelect:i}),e[10]=p,e[11]=s,e[12]=i,e[13]=g):g=e[13],g}let a;e[14]===Symbol.for("react.memo_cache_sentinel")?(a=typeof window<"u"?window.localStorage.getItem(Cc):null,e[14]=a):a=e[14];const l=a;let c;e[15]!==o?(c=o.find(p=>p.id===l)?.id??o[0].id,e[15]=o,e[16]=c):c=e[16];const d=c;let h;e[17]!==o?(h=o.map(xD),e[17]=o,e[18]=h):h=e[18];let u;e[19]!==h?(u=r.jsx(ta,{className:"self-start",children:h}),e[19]=h,e[20]=u):u=e[20];let f;if(e[21]!==o||e[22]!==s||e[23]!==i){let p;e[25]!==s||e[26]!==i?(p=g=>r.jsx(_i,{value:g.id,className:"min-h-0 flex-1 overflow-hidden",children:r.jsx(rd,{config:g,mode:s,onSelect:i})},g.id),e[25]=s,e[26]=i,e[27]=p):p=e[27],f=o.map(p),e[21]=o,e[22]=s,e[23]=i,e[24]=f}else f=e[24];let m;return e[28]!==d||e[29]!==u||e[30]!==f?(m=r.jsxs(Vr,{defaultValue:d,onValueChange:vD,className:"min-h-0 flex-1 flex flex-col",children:[u,f]}),e[28]=d,e[29]=u,e[30]=f,e[31]=m):m=e[31],m}function xD(t){return r.jsx(xn,{value:t.id,children:t.name},t.id)}function vD(t){typeof window<"u"&&window.localStorage.setItem(Cc,t)}function bD(){const t=F.c(22),{org:e}=Oe(),s=re();let n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n=r.jsx("div",{className:"size-12 rounded-full bg-muted flex items-center justify-center",children:r.jsx(Bi,{size:20,className:"text-muted-foreground"})}),t[0]=n):n=t[0];let i;t[1]!==s?(i=s("filePicker.filePickerDialog.noBucketConfigured"),t[1]=s,t[2]=i):i=t[2];let o;t[3]!==i?(o=r.jsx("p",{className:"font-medium text-sm",children:i}),t[3]=i,t[4]=o):o=t[4];let a;t[5]!==s?(a=s("filePicker.filePickerDialog.noBucketDescription"),t[5]=s,t[6]=a):a=t[6];let l;t[7]!==a?(l=r.jsx("p",{className:"text-xs text-muted-foreground mt-1 max-w-sm",children:a}),t[7]=a,t[8]=l):l=t[8];let c;t[9]!==o||t[10]!==l?(c=r.jsxs("div",{children:[o,l]}),t[9]=o,t[10]=l,t[11]=c):c=t[11];let d;t[12]!==e.slug?(d={org:e.slug},t[12]=e.slug,t[13]=d):d=t[13];let h;t[14]!==s?(h=s("filePicker.filePickerDialog.configureABucket"),t[14]=s,t[15]=h):h=t[15];let u;t[16]!==d||t[17]!==h?(u=r.jsx(le,{asChild:!0,size:"sm",className:"mt-2",children:r.jsx(om,{to:"/$org/settings/files",params:d,children:h})}),t[16]=d,t[17]=h,t[18]=u):u=t[18];let f;return t[19]!==c||t[20]!==u?(f=r.jsxs("div",{className:"rounded-xl border border-dashed border-border/60 p-10 flex flex-col items-center justify-center text-center gap-3",children:[n,c,u]}),t[19]=c,t[20]=u,t[21]=f):f=t[21],f}function rd({config:t,mode:e,onSelect:s}){const n=re(),[i,o]=A.useState(""),a=Kb(i,300),l=hD({configId:t.id,search:a,imageOnly:e==="image"}),c=Lu(),[d,h]=A.useState(!1),u=A.useRef(null),f=e==="image"?"image/*":void 0;async function m(j){if(!j)return;const S=Array.from(j);if(S.length===0)return;let C=null;const N=[];for(const V of S)try{const E=await c.mutateAsync({configId:t.id,file:V});C??=E.publicUrl}catch(E){N.push(`${V.name} (${E instanceof Error?E.message:"upload failed"})`)}await l.refetch(),N.length>0&&ge.error(N.length===S.length?n("filePicker.filePickerDialog.uploadFailedAll",{errors:N.join("; ")}):n("filePicker.filePickerDialog.uploadFailedSome",{errors:N.join("; ")})),C&&s(C)}function p(j){j.preventDefault(),h(!0)}function g(){h(!1)}function x(j){j.preventDefault(),h(!1),m(j.dataTransfer.files)}const b=(l.data?.pages??[]).flatMap(j=>j.items),y=b.filter(j=>e==="image"?d4(j.key):!0),_=a.trim(),L=b.length>0||i.trim().length>0,w=i!==a||l.isFetching&&!l.isFetchingNextPage;return r.jsxs("div",{className:"flex flex-col gap-3 min-h-0 h-full",children:[r.jsxs("button",{type:"button",onClick:()=>u.current?.click(),onDragOver:p,onDragLeave:g,onDrop:x,className:ie("rounded-xl border border-dashed border-border/60 p-6 flex flex-col items-center justify-center gap-2 text-center transition-colors",d&&"border-primary bg-primary/5",c.isPending&&"opacity-60 pointer-events-none"),children:[r.jsx(Bi,{size:18,className:"text-muted-foreground"}),r.jsx("p",{className:"text-sm font-medium",children:c.isPending?n("filePicker.filePickerDialog.uploading"):n("filePicker.filePickerDialog.dropFilesOrClick")}),r.jsxs("p",{className:"text-xs text-muted-foreground",children:[n("filePicker.filePickerDialog.uploadSizeLimit")," ",n(e==="image"?"filePicker.filePickerDialog.imagesOnlyTypes":"filePicker.filePickerDialog.commonMediaTypes")]}),r.jsx("input",{ref:u,type:"file",accept:f,multiple:!0,className:"hidden",onChange:j=>{const S=Array.from(j.target.files??[]);j.target.value="",m(S)}})]}),L?r.jsx(h9,{value:i,onChange:o,isSearching:w,placeholder:n(e==="image"?"filePicker.filePickerDialog.searchImagesPlaceholder":"filePicker.filePickerDialog.searchFilesPlaceholder"),className:"shrink-0"}):null,r.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto pr-1",children:[y.length===0?_?r.jsx(LD,{query:_}):e==="image"&&b.length>0?r.jsx(yD,{}):r.jsx(_D,{}):e==="image"?r.jsx(wD,{items:y,onSelect:s}):r.jsx(jD,{items:y,onSelect:s}),l.hasNextPage&&r.jsx("div",{className:"flex justify-center py-4",children:r.jsx(le,{type:"button",variant:"outline",size:"sm",disabled:l.isFetchingNextPage,onClick:()=>l.fetchNextPage(),children:l.isFetchingNextPage?r.jsxs(r.Fragment,{children:[r.jsx(et,{size:14,className:"animate-spin"}),n("filePicker.filePickerDialog.loading")]}):n("filePicker.filePickerDialog.loadMore")})})]})]})}function _D(){const t=F.c(12),e=re();let s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx("div",{className:"flex size-10 items-center justify-center rounded-full bg-muted",children:r.jsx(En,{size:18,className:"text-muted-foreground"})}),t[0]=s):s=t[0];let n;t[1]!==e?(n=e("filePicker.filePickerDialog.noFilesYet"),t[1]=e,t[2]=n):n=t[2];let i;t[3]!==n?(i=r.jsx("p",{className:"text-sm font-medium",children:n}),t[3]=n,t[4]=i):i=t[4];let o;t[5]!==e?(o=e("filePicker.filePickerDialog.dropFileToGetStarted"),t[5]=e,t[6]=o):o=t[6];let a;t[7]!==o?(a=r.jsx("p",{className:"text-xs text-muted-foreground",children:o}),t[7]=o,t[8]=a):a=t[8];let l;return t[9]!==i||t[10]!==a?(l=r.jsxs("div",{className:"flex h-full min-h-40 flex-col items-center justify-center gap-2 py-8 text-center",children:[s,i,a]}),t[9]=i,t[10]=a,t[11]=l):l=t[11],l}function yD(){const t=F.c(12),e=re();let s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx("div",{className:"flex size-10 items-center justify-center rounded-full bg-muted",children:r.jsx(En,{size:18,className:"text-muted-foreground"})}),t[0]=s):s=t[0];let n;t[1]!==e?(n=e("filePicker.filePickerDialog.noImagesYet"),t[1]=e,t[2]=n):n=t[2];let i;t[3]!==n?(i=r.jsx("p",{className:"text-sm font-medium",children:n}),t[3]=n,t[4]=i):i=t[4];let o;t[5]!==e?(o=e("filePicker.filePickerDialog.noImagesFormatDesc"),t[5]=e,t[6]=o):o=t[6];let a;t[7]!==o?(a=r.jsx("p",{className:"text-xs text-muted-foreground",children:o}),t[7]=o,t[8]=a):a=t[8];let l;return t[9]!==i||t[10]!==a?(l=r.jsxs("div",{className:"flex h-full min-h-40 flex-col items-center justify-center gap-2 py-8 text-center",children:[s,i,a]}),t[9]=i,t[10]=a,t[11]=l):l=t[11],l}function LD(t){const e=F.c(13),{query:s}=t,n=re();let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx("div",{className:"flex size-10 items-center justify-center rounded-full bg-muted",children:r.jsx(En,{size:18,className:"text-muted-foreground"})}),e[0]=i):i=e[0];let o;e[1]!==s||e[2]!==n?(o=n("filePicker.filePickerDialog.noMatches",{query:s}),e[1]=s,e[2]=n,e[3]=o):o=e[3];let a;e[4]!==o?(a=r.jsx("p",{className:"text-sm font-medium",children:o}),e[4]=o,e[5]=a):a=e[5];let l;e[6]!==n?(l=n("filePicker.filePickerDialog.tryDifferentSearchOrLoadMore"),e[6]=n,e[7]=l):l=e[7];let c;e[8]!==l?(c=r.jsx("p",{className:"text-xs text-muted-foreground",children:l}),e[8]=l,e[9]=c):c=e[9];let d;return e[10]!==a||e[11]!==c?(d=r.jsxs("div",{className:"flex h-full min-h-40 flex-col items-center justify-center gap-2 py-8 text-center",children:[i,a,c]}),e[10]=a,e[11]=c,e[12]=d):d=e[12],d}function d4(t){return/\.(png|jpe?g|gif|webp|svg|avif|bmp)$/i.test(t)}function SD(t){const e=t.lastIndexOf(".");return e<0||e===t.length-1?"file":t.slice(e+1).toLowerCase()}function wD(t){const e=F.c(7),{items:s,onSelect:n}=t;let i;if(e[0]!==s||e[1]!==n){let a;e[3]!==n?(a=l=>r.jsx(u4,{item:l,variant:"image",onSelect:n},l.key),e[3]=n,e[4]=a):a=e[4],i=s.map(a),e[0]=s,e[1]=n,e[2]=i}else i=e[2];let o;return e[5]!==i?(o=r.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 gap-3",children:i}),e[5]=i,e[6]=o):o=e[6],o}function jD(t){const e=F.c(7),{items:s,onSelect:n}=t;let i;if(e[0]!==s||e[1]!==n){let a;e[3]!==n?(a=l=>r.jsx("li",{children:r.jsx(u4,{item:l,variant:"row",onSelect:n})},l.key),e[3]=n,e[4]=a):a=e[4],i=s.map(a),e[0]=s,e[1]=n,e[2]=i}else i=e[2];let o;return e[5]!==i?(o=r.jsx("ul",{className:"divide-y divide-border/60 rounded-lg border border-border/60",children:i}),e[5]=i,e[6]=o):o=e[6],o}function u4(t){const e=F.c(58),{item:s,variant:n,onSelect:i}=t;let o;e[0]!==s.key?(o=SD(s.key),e[0]=s.key,e[1]=o):o=e[1];const a=o;if(n==="image"){let y;e[2]!==s.publicUrl||e[3]!==i?(y=()=>i(s.publicUrl),e[2]=s.publicUrl,e[3]=i,e[4]=y):y=e[4];let _;e[5]!==s.key||e[6]!==s.publicUrl?(_=r.jsx("img",{src:s.publicUrl,alt:s.key,loading:"lazy",className:"h-full w-full object-cover",onError:CD}),e[5]=s.key,e[6]=s.publicUrl,e[7]=_):_=e[7];let L;e[8]!==s.key||e[9]!==y||e[10]!==_?(L=r.jsx("button",{type:"button",onClick:y,className:"block h-full w-full transition hover:ring-2 hover:ring-primary",title:s.key,children:_}),e[8]=s.key,e[9]=y,e[10]=_,e[11]=L):L=e[11];let w;e[12]!==a?(w=r.jsx("span",{className:"pointer-events-none absolute left-1.5 top-1.5 rounded bg-background/80 px-1.5 py-0.5 text-[10px] font-medium uppercase text-foreground opacity-0 backdrop-blur-sm transition-opacity group-hover:opacity-100",children:a}),e[12]=a,e[13]=w):w=e[13];let j;e[14]!==s||e[15]!==i?(j=r.jsx("div",{className:"absolute right-1.5 top-1.5 opacity-0 transition-opacity group-hover:opacity-100",children:r.jsx(Of,{item:s,onSelect:i})}),e[14]=s,e[15]=i,e[16]=j):j=e[16];let S;e[17]!==s.key?(S=Bf(s.key),e[17]=s.key,e[18]=S):S=e[18];let C;e[19]!==S?(C=r.jsx("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 bg-gradient-to-t from-black/70 to-transparent p-2 opacity-0 transition-opacity group-hover:opacity-100",children:r.jsx("p",{className:"truncate text-xs text-white",children:S})}),e[19]=S,e[20]=C):C=e[20];let N;return e[21]!==L||e[22]!==w||e[23]!==j||e[24]!==C?(N=r.jsxs("div",{className:"group relative aspect-square overflow-hidden rounded-lg border border-border/60 bg-muted",children:[L,w,j,C]}),e[21]=L,e[22]=w,e[23]=j,e[24]=C,e[25]=N):N=e[25],N}let l;e[26]!==s.publicUrl||e[27]!==i?(l=()=>i(s.publicUrl),e[26]=s.publicUrl,e[27]=i,e[28]=l):l=e[28];let c;e[29]!==s.key?(c=r.jsx("div",{className:"flex size-9 shrink-0 items-center justify-center rounded-md bg-muted",children:d4(s.key)?r.jsx(En,{size:16,className:"text-muted-foreground"}):r.jsx(mr,{size:16,className:"text-muted-foreground"})}),e[29]=s.key,e[30]=c):c=e[30];let d;e[31]!==s.key?(d=Bf(s.key),e[31]=s.key,e[32]=d):d=e[32];let h;e[33]!==d?(h=r.jsx("p",{className:"truncate text-sm font-medium",children:d}),e[33]=d,e[34]=h):h=e[34];let u;e[35]!==s.key?(u=r.jsx("p",{className:"truncate font-mono text-xs text-muted-foreground",children:s.key}),e[35]=s.key,e[36]=u):u=e[36];let f;e[37]!==h||e[38]!==u?(f=r.jsxs("div",{className:"min-w-0 flex-1",children:[h,u]}),e[37]=h,e[38]=u,e[39]=f):f=e[39];let m;e[40]!==a?(m=r.jsx("span",{className:"shrink-0 rounded bg-muted px-1.5 py-0.5 text-[10px] font-medium uppercase text-muted-foreground",children:a}),e[40]=a,e[41]=m):m=e[41];let p;e[42]!==s.size?(p=TD(s.size),e[42]=s.size,e[43]=p):p=e[43];let g;e[44]!==p?(g=r.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:p}),e[44]=p,e[45]=g):g=e[45];let x;e[46]!==g||e[47]!==l||e[48]!==c||e[49]!==f||e[50]!==m?(x=r.jsxs("button",{type:"button",onClick:l,className:"flex min-w-0 flex-1 items-center gap-3 text-left",children:[c,f,m,g]}),e[46]=g,e[47]=l,e[48]=c,e[49]=f,e[50]=m,e[51]=x):x=e[51];let v;e[52]!==s||e[53]!==i?(v=r.jsx(Of,{item:s,onSelect:i}),e[52]=s,e[53]=i,e[54]=v):v=e[54];let b;return e[55]!==x||e[56]!==v?(b=r.jsxs("div",{className:"group flex items-center gap-3 px-3 py-2 transition hover:bg-muted/50",children:[x,v]}),e[55]=x,e[56]=v,e[57]=b):b=e[57],b}function CD(t){t.target.style.display="none"}function Of(t){const e=F.c(39),{item:s,onSelect:n}=t,i=re(),[o,a]=A.useState(!1);let l;e[0]!==s.publicUrl||e[1]!==i?(l=async function(N){N.preventDefault(),N.stopPropagation();try{await navigator.clipboard.writeText(s.publicUrl),a(!0),window.setTimeout(()=>a(!1),1500)}catch{ge.error(i("filePicker.filePickerDialog.failedToCopyUrl"))}},e[0]=s.publicUrl,e[1]=i,e[2]=l):l=e[2];const c=l;let d;e[3]!==i?(d=i("filePicker.filePickerDialog.assetActions"),e[3]=i,e[4]=d):d=e[4];let h;e[5]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx(p2,{size:14}),e[5]=h):h=e[5];let u;e[6]!==d?(u=r.jsx(ds,{asChild:!0,children:r.jsx(le,{type:"button",variant:"ghost",size:"icon",className:"size-7 rounded-md bg-background/80 backdrop-blur-sm",onClick:ND,"aria-label":d,children:h})}),e[6]=d,e[7]=u):u=e[7];let f;e[8]!==s.publicUrl||e[9]!==n?(f=()=>n(s.publicUrl),e[8]=s.publicUrl,e[9]=n,e[10]=f):f=e[10];let m;e[11]===Symbol.for("react.memo_cache_sentinel")?(m=r.jsx(zt,{size:14}),e[11]=m):m=e[11];let p;e[12]!==i?(p=i("filePicker.filePickerDialog.useThis"),e[12]=i,e[13]=p):p=e[13];let g;e[14]!==f||e[15]!==p?(g=r.jsxs(Xe,{onClick:f,children:[m,p]}),e[14]=f,e[15]=p,e[16]=g):g=e[16];let x;e[17]!==o?(x=o?r.jsx(zt,{size:14}):r.jsx(Os,{size:14}),e[17]=o,e[18]=x):x=e[18];let v;e[19]!==o||e[20]!==i?(v=i(o?"filePicker.filePickerDialog.copied":"filePicker.filePickerDialog.copyUrl"),e[19]=o,e[20]=i,e[21]=v):v=e[21];let b;e[22]!==c||e[23]!==v||e[24]!==x?(b=r.jsxs(Xe,{onClick:c,children:[x,v]}),e[22]=c,e[23]=v,e[24]=x,e[25]=b):b=e[25];const y=s.publicUrl;let _;e[26]===Symbol.for("react.memo_cache_sentinel")?(_=r.jsx(Dn,{size:14}),e[26]=_):_=e[26];let L;e[27]!==i?(L=i("filePicker.filePickerDialog.openInNewTab"),e[27]=i,e[28]=L):L=e[28];let w;e[29]!==s.publicUrl||e[30]!==L?(w=r.jsx(Xe,{asChild:!0,children:r.jsxs("a",{href:y,target:"_blank",rel:"noreferrer",onClick:kD,children:[_,L]})}),e[29]=s.publicUrl,e[30]=L,e[31]=w):w=e[31];let j;e[32]!==b||e[33]!==w||e[34]!==g?(j=r.jsxs(hs,{align:"end",onClick:VD,children:[g,b,w]}),e[32]=b,e[33]=w,e[34]=g,e[35]=j):j=e[35];let S;return e[36]!==j||e[37]!==u?(S=r.jsxs(us,{children:[u,j]}),e[36]=j,e[37]=u,e[38]=S):S=e[38],S}function kD(t){return t.stopPropagation()}function VD(t){return t.stopPropagation()}function ND(t){return t.stopPropagation()}function Bf(t){const e=t.split("/");return e[e.length-1]??t}function TD(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function h4(t,e){if(!e)return null;const s=e.toLowerCase();return t.find(n=>{const i=n.bucket.toLowerCase();return n.siteSlug?.toLowerCase()===s||i===s||i===`deco-assets-${s}`})??null}function f4(){const t=F.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center bg-black/40 opacity-0 transition-opacity group-hover:opacity-100 group-focus-within:opacity-100",children:r.jsxs("span",{className:"flex items-center gap-1.5 rounded-md bg-background px-3 py-1.5 text-xs font-medium shadow",children:[r.jsx(Bi,{size:14}),"Click to replace"]})}),t[0]=e):e=t[0],e}function m4(t){try{const e=new URL(t).pathname;return decodeURIComponent(e.split("/").pop()??t)}catch{return t.split("/").pop()??t}}function p4(t){const e=t.lastIndexOf(".");return e<0||e===t.length-1?"":t.slice(e+1).toLowerCase()}const AD=["low","medium","high","original"];function g4(t){return t==="low"||t==="medium"||t==="high"||t==="original"}function x4(t,e){try{return new URL(t).searchParams.get(e)}catch{const s=ED(t);for(const n of s){const i=n.indexOf("=");if((i>=0?n.slice(0,i):n)===e)return i>=0?n.slice(i+1):""}return null}}function v4(t,e,s){const n=t.indexOf("#"),i=n>=0?t.slice(n):"",o=n>=0?t.slice(0,n):t,a=o.indexOf("?"),l=a>=0?o.slice(0,a):o,c=(a>=0?o.slice(a+1).split("&"):[]).filter(Boolean).filter(d=>{const h=d.indexOf("=");return(h>=0?d.slice(0,h):d)!==e});return s!==void 0&&c.push(`${e}=${s}`),`${l}${c.length?`?${c.join("&")}`:""}${i}`}function ED(t){const e=t.indexOf("#"),s=e>=0?t.slice(0,e):t,n=s.indexOf("?");return n<0?[]:s.slice(n+1).split("&").filter(Boolean)}function PD(t){if(!t)return;const e=x4(t,"quality");return g4(e)?e:void 0}function RD(t,e){return v4(t,"quality",e)}function DD(t){return t?x4(t,"muted")!=="false":!0}function ID(t,e){return v4(t,"muted",e?void 0:"false")}function b4(t){const e=F.c(36),{value:s,onChange:n,showMuted:i}=t,o=i===void 0?!1:i,a=re(),l=A.useId();let c;e[0]!==s?(c=PD(s),e[0]=s,e[1]=c):c=e[1];const d=c;let h;e[2]!==s?(h=DD(s),e[2]=s,e[3]=h):h=e[3];const u=h;let f;e[4]!==a?(f=a("sectionsEditor.mediaTransformControls.mediaOptionsLabel"),e[4]=a,e[5]=f):f=e[5];let m;e[6]===Symbol.for("react.memo_cache_sentinel")?(m=r.jsx(p2,{size:14}),e[6]=m):m=e[6];let p;e[7]!==f?(p=r.jsx(Es,{asChild:!0,children:r.jsx(le,{type:"button",variant:"outline",size:"sm",className:"h-9 shrink-0","aria-label":f,children:m})}),e[7]=f,e[8]=p):p=e[8];let g;e[9]!==a?(g=a("sectionsEditor.mediaTransformControls.qualityLabel"),e[9]=a,e[10]=g):g=e[10];let x;e[11]!==g?(x=r.jsx(lt,{className:"text-xs text-muted-foreground",children:g}),e[11]=g,e[12]=x):x=e[12];const v=d??"";let b;e[13]!==n||e[14]!==s?(b=C=>n(RD(s,g4(C)?C:void 0)),e[13]=n,e[14]=s,e[15]=b):b=e[15];let y;e[16]===Symbol.for("react.memo_cache_sentinel")?(y=AD.map(MD),e[16]=y):y=e[16];let _;e[17]!==b||e[18]!==v?(_=r.jsx(n9,{type:"single",variant:"outline",size:"sm",value:v,onValueChange:b,children:y}),e[17]=b,e[18]=v,e[19]=_):_=e[19];let L;e[20]!==_||e[21]!==x?(L=r.jsxs("div",{className:"flex flex-col gap-1.5",children:[x,_]}),e[20]=_,e[21]=x,e[22]=L):L=e[22];let w;e[23]!==u||e[24]!==l||e[25]!==n||e[26]!==o||e[27]!==a||e[28]!==s?(w=o&&r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[r.jsx(lt,{htmlFor:l,className:"text-xs text-muted-foreground",children:a("sectionsEditor.mediaTransformControls.mutedLabel")}),r.jsx(xr,{id:l,checked:u,onCheckedChange:C=>n(ID(s,C))})]}),e[23]=u,e[24]=l,e[25]=n,e[26]=o,e[27]=a,e[28]=s,e[29]=w):w=e[29];let j;e[30]!==L||e[31]!==w?(j=r.jsx(Ps,{align:"end",className:"w-auto min-w-52 p-3",children:r.jsxs("div",{className:"flex flex-col gap-3",children:[L,w]})}),e[30]=L,e[31]=w,e[32]=j):j=e[32];let S;return e[33]!==j||e[34]!==p?(S=r.jsxs(As,{children:[p,j]}),e[33]=j,e[34]=p,e[35]=S):S=e[35],S}function MD(t){return r.jsx(To,{value:t,className:"h-8 px-3 text-xs capitalize",children:t},t)}function $f(t){const e=F.c(2),{ext:s}=t;if(!s)return null;let n;return e[0]!==s?(n=r.jsx("span",{className:"shrink-0 rounded bg-muted px-1.5 py-0.5 text-[10px] font-medium uppercase text-muted-foreground",children:s}),e[0]=s,e[1]=n):n=e[1],n}function OD(t){const e=F.c(86),{schema:s,value:n,onChange:i,path:o,label:a,sandbox:l}=t,c=re(),d=s.format==="video-uri",h=vu(n),[u,f]=A.useState(!1),[m,p]=A.useState(!1),g=h?m4(h):"",x=g?p4(g):"",v=S2(),b=Lu();let y;e[0]!==v.data?.configs?(y=v.data?.configs??[],e[0]=v.data?.configs,e[1]=y):y=e[1];const _=l?.siteSlug;let L;e[2]!==y||e[3]!==_?(L=h4(y,_),e[2]=y,e[3]=_,e[4]=L):L=e[4];const w=L;let j;e[5]!==v.data?.configs||e[6]!==w?(j=function(){if(w)return w.id;const se=v.data?.configs??[];if(se.length===1)return se[0].id;if(se.length===0)return null;const ne=typeof window<"u"?window.localStorage.getItem(Cc):null;return se.some(de=>de.id===ne)?ne:null},e[5]=v.data?.configs,e[6]=w,e[7]=j):j=e[7];const S=j;let C;e[8]!==d||e[9]!==i||e[10]!==S||e[11]!==f||e[12]!==c||e[13]!==b?(C=async function(se){if(!se)return;let ne=Array.from(se);if(ne.length===0)return;if(d&&(ne=ne.filter(BD),ne.length===0)){ge.error(c("sectionsEditor.fileField.videoFileError"));return}const de=S();if(!de){f(!0);return}try{const xe=await b.mutateAsync({configId:de,file:ne[0]});i(xe.publicUrl),ne.length>1&&ge.info(c("sectionsEditor.fileField.multiFileWarning",{fileName:ne[0].name}))}catch(xe){const ue=xe;ge.error(ue instanceof Error?ue.message:c("sectionsEditor.fileField.uploadFailed"))}},e[8]=d,e[9]=i,e[10]=S,e[11]=f,e[12]=c,e[13]=b,e[14]=C):C=e[14];const N=C;let V;e[15]!==p?(V=function(se){se.preventDefault(),se.dataTransfer.types.includes("Files")&&p(!0)},e[15]=p,e[16]=V):V=e[16];const E=V;let T;e[17]!==p?(T=function(se){se.currentTarget===se.target&&p(!1)},e[17]=p,e[18]=T):T=e[18];const k=T;let R;e[19]!==N||e[20]!==p?(R=function(se){se.preventDefault(),p(!1),N(se.dataTransfer.files)},e[19]=N,e[20]=p,e[21]=R):R=e[21];const P=R;let D;e[22]!==a||e[23]!==o?(D=r.jsx(lt,{htmlFor:o,className:"text-muted-foreground",children:a}),e[22]=a,e[23]=o,e[24]=D):D=e[24];let I;e[25]!==s.description?(I=s.description&&r.jsx("p",{className:"text-xs leading-normal text-muted-foreground",children:s.description}),e[25]=s.description,e[26]=I):I=e[26];let M;e[27]!==I||e[28]!==D?(M=r.jsxs("div",{className:"min-w-0 space-y-0.5",children:[D,I]}),e[27]=I,e[28]=D,e[29]=M):M=e[29];const O=m&&"border-primary ring-2 ring-primary/30",$=b.isPending&&"pointer-events-none opacity-60";let B;e[30]!==O||e[31]!==$?(B=ie("group relative w-full overflow-hidden rounded-xl border border-border/60 bg-muted/30 transition",O,$),e[30]=O,e[31]=$,e[32]=B):B=e[32];let z;e[33]!==x||e[34]!==g||e[35]!==d||e[36]!==f||e[37]!==h||e[38]!==c||e[39]!==b.isPending?(z=h?d?r.jsxs(r.Fragment,{children:[r.jsxs("button",{type:"button",onClick:()=>f(!0),"aria-label":c("sectionsEditor.fileField.replaceVideoLabel"),className:"relative block h-40 w-full cursor-pointer overflow-hidden bg-black",children:[r.jsx("video",{src:h,preload:"metadata",className:"h-full w-full object-contain"},h),r.jsx(f4,{})]}),r.jsxs("div",{className:"flex items-center gap-2 border-t border-border/60 bg-background/50 px-3 py-2",children:[r.jsx(Hu,{size:14,className:"shrink-0 text-muted-foreground"}),r.jsx("p",{className:"min-w-0 flex-1 truncate text-xs text-muted-foreground",children:g}),r.jsx($f,{ext:x})]})]}):r.jsxs("button",{type:"button",onClick:()=>f(!0),"aria-label":c("sectionsEditor.fileField.replaceFileLabel"),className:"flex w-full cursor-pointer items-center gap-3 px-3 py-2.5 text-left hover:bg-muted/60",children:[r.jsx("div",{className:"flex size-10 shrink-0 items-center justify-center rounded-md bg-background",children:r.jsx(mr,{size:18,className:"text-muted-foreground"})}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("p",{className:"truncate text-sm font-medium",children:g}),r.jsx("p",{className:"truncate text-xs text-muted-foreground",children:h})]}),r.jsx($f,{ext:x})]}):r.jsxs("button",{type:"button",onClick:()=>f(!0),className:"flex w-full flex-col items-center justify-center gap-2 py-8 text-sm text-muted-foreground hover:bg-muted/60 hover:text-foreground",children:[d?r.jsx(Hu,{size:20}):r.jsx(mr,{size:20}),r.jsx("span",{className:"text-sm font-medium",children:b.isPending?c("sectionsEditor.fileField.uploading"):c(d?"sectionsEditor.fileField.dropVideoHint":"sectionsEditor.fileField.dropFileHint")}),r.jsx("span",{className:"text-xs text-muted-foreground",children:c("sectionsEditor.fileField.sizeLimit")})]}),e[33]=x,e[34]=g,e[35]=d,e[36]=f,e[37]=h,e[38]=c,e[39]=b.isPending,e[40]=z):z=e[40];let K;e[41]!==m||e[42]!==c?(K=m&&r.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center bg-primary/10 backdrop-blur-[1px]",children:r.jsx("span",{className:"rounded-md bg-background px-3 py-1.5 text-xs font-medium shadow",children:c("sectionsEditor.fileField.dropToUpload")})}),e[41]=m,e[42]=c,e[43]=K):K=e[43];let G;e[44]!==k||e[45]!==E||e[46]!==P||e[47]!==B||e[48]!==z||e[49]!==K?(G=r.jsxs("div",{onDragOver:E,onDragLeave:k,onDrop:P,className:B,children:[z,K]}),e[44]=k,e[45]=E,e[46]=P,e[47]=B,e[48]=z,e[49]=K,e[50]=G):G=e[50];let Y;e[51]!==i?(Y=te=>i(te.target.value),e[51]=i,e[52]=Y):Y=e[52];let U;e[53]!==o||e[54]!==h||e[55]!==Y?(U=r.jsx(rt,{id:o,type:"url",value:h,onChange:Y,placeholder:"https://...",className:"h-9 min-w-0 flex-1"}),e[53]=o,e[54]=h,e[55]=Y,e[56]=U):U=e[56];let W;e[57]!==f||e[58]!==h||e[59]!==c?(W=!h&&r.jsxs(le,{type:"button",variant:"outline",size:"sm",onClick:()=>f(!0),className:"h-9 shrink-0",children:[r.jsx(Bi,{size:14}),c("sectionsEditor.fileField.browseButton")]}),e[57]=f,e[58]=h,e[59]=c,e[60]=W):W=e[60];let H;e[61]!==d||e[62]!==i||e[63]!==h?(H=d&&h&&r.jsx(b4,{value:h,onChange:i,showMuted:!0}),e[61]=d,e[62]=i,e[63]=h,e[64]=H):H=e[64];let X;e[65]!==i||e[66]!==h||e[67]!==c?(X=h&&r.jsx(le,{type:"button",variant:"ghost",size:"sm",onClick:()=>i(""),className:"h-9 shrink-0","aria-label":c("sectionsEditor.fileField.removeFileLabel"),children:r.jsx(Ns,{size:14})}),e[65]=i,e[66]=h,e[67]=c,e[68]=X):X=e[68];let q;e[69]!==U||e[70]!==W||e[71]!==H||e[72]!==X?(q=r.jsxs("div",{className:"flex w-full min-w-0 items-center gap-2",children:[U,W,H,X]}),e[69]=U,e[70]=W,e[71]=H,e[72]=X,e[73]=q):q=e[73];let Z;e[74]!==i?(Z=te=>i(te),e[74]=i,e[75]=Z):Z=e[75];const Q=w?.id??null;let ee;e[76]!==u||e[77]!==f||e[78]!==Z||e[79]!==Q?(ee=r.jsx(c4,{open:u,onOpenChange:f,mode:"any",onSelect:Z,lockedConfigId:Q}),e[76]=u,e[77]=f,e[78]=Z,e[79]=Q,e[80]=ee):ee=e[80];let J;return e[81]!==M||e[82]!==G||e[83]!==q||e[84]!==ee?(J=r.jsxs("div",{className:"grid w-full min-w-0 grid-cols-[minmax(0,1fr)] gap-2",children:[M,G,q,ee]}),e[81]=M,e[82]=G,e[83]=q,e[84]=ee,e[85]=J):J=e[85],J}function BD(t){return t.type.startsWith("video/")}const $D=new Set(["image/png","image/jpeg","image/gif","image/webp","image/svg+xml","image/avif"]);function FD(t){const e=F.c(91),{schema:s,value:n,onChange:i,path:o,label:a,sandbox:l}=t,c=re(),d=vu(n),[h,u]=A.useState(!1),[f,m]=A.useState(!1),[p,g]=A.useState(!1),[x,v]=A.useState(!1),b=d?m4(d):"",y=b?p4(b):"",_=S2(),L=Lu();let w;e[0]!==_.data?.configs?(w=_.data?.configs??[],e[0]=_.data?.configs,e[1]=w):w=e[1];const j=l?.siteSlug;let S;e[2]!==w||e[3]!==j?(S=h4(w,j),e[2]=w,e[3]=j,e[4]=S):S=e[4];const C=S;let N;e[5]!==i||e[6]!==v||e[7]!==g?(N=function(ce){g(!1),v(!1),i(ce)},e[5]=i,e[6]=v,e[7]=g,e[8]=N):N=e[8];const V=N;let E;e[9]!==_.data?.configs||e[10]!==C?(E=function(){if(C)return C.id;const ce=_.data?.configs??[];if(ce.length===1)return ce[0].id;if(ce.length===0)return null;const oe=typeof window<"u"?window.localStorage.getItem(Cc):null;return ce.some(fe=>fe.id===oe)?oe:null},e[9]=_.data?.configs,e[10]=C,e[11]=E):E=e[11];const T=E;let k;e[12]!==T||e[13]!==u||e[14]!==V||e[15]!==c||e[16]!==L?(k=async function(ce){if(!ce)return;const oe=Array.from(ce).filter(zD);if(oe.length===0){ge.error(c("sectionsEditor.imageField.onlyImageFilesAccepted"));return}const fe=T();if(!fe){u(!0);return}try{const pe=await L.mutateAsync({configId:fe,file:oe[0]});V(pe.publicUrl),oe.length>1&&ge.info(c("sectionsEditor.imageField.uploadedWithExtraFilesIgnored",{fileName:oe[0].name}))}catch(pe){const we=pe;ge.error(we instanceof Error?we.message:c("sectionsEditor.imageField.uploadFailed"))}},e[12]=T,e[13]=u,e[14]=V,e[15]=c,e[16]=L,e[17]=k):k=e[17];const R=k;let P;e[18]!==m?(P=function(ce){ce.preventDefault(),ce.dataTransfer.types.includes("Files")&&m(!0)},e[18]=m,e[19]=P):P=e[19];const D=P;let I;e[20]!==m?(I=function(ce){ce.currentTarget===ce.target&&m(!1)},e[20]=m,e[21]=I):I=e[21];const M=I;let O;e[22]!==R||e[23]!==m?(O=function(ce){ce.preventDefault(),m(!1),R(ce.dataTransfer.files)},e[22]=R,e[23]=m,e[24]=O):O=e[24];const $=O;let B;e[25]!==a||e[26]!==o?(B=r.jsx(lt,{htmlFor:o,className:"text-muted-foreground",children:a}),e[25]=a,e[26]=o,e[27]=B):B=e[27];let z;e[28]!==s.description?(z=s.description&&r.jsx("p",{className:"text-xs leading-normal text-muted-foreground",children:s.description}),e[28]=s.description,e[29]=z):z=e[29];let K;e[30]!==B||e[31]!==z?(K=r.jsxs("div",{className:"min-w-0 space-y-0.5",children:[B,z]}),e[30]=B,e[31]=z,e[32]=K):K=e[32];const G=f&&"border-primary ring-2 ring-primary/30",Y=L.isPending&&"pointer-events-none opacity-60";let U;e[33]!==G||e[34]!==Y?(U=ie("group relative w-full overflow-hidden rounded-xl border border-border/60 bg-muted/30 transition",G,Y),e[33]=G,e[34]=Y,e[35]=U):U=e[35];let W;e[36]!==y||e[37]!==b||e[38]!==x||e[39]!==p||e[40]!==a||e[41]!==v||e[42]!==g||e[43]!==u||e[44]!==d||e[45]!==c||e[46]!==L.isPending?(W=d?r.jsxs(r.Fragment,{children:[r.jsxs("button",{type:"button",onClick:()=>u(!0),"aria-label":c("sectionsEditor.imageField.replaceImage"),className:"relative block h-40 w-full cursor-pointer bg-[image:linear-gradient(45deg,rgba(0,0,0,0.04)_25%,transparent_25%,transparent_75%,rgba(0,0,0,0.04)_75%),linear-gradient(45deg,rgba(0,0,0,0.04)_25%,transparent_25%,transparent_75%,rgba(0,0,0,0.04)_75%)] bg-[position:0_0,8px_8px] [background-size:16px_16px]",children:[!x&&r.jsx("img",{src:d,alt:a,className:ie("h-full w-full object-contain transition-opacity",!p&&"opacity-0"),onLoad:()=>g(!0),onError:()=>v(!0)},d),x&&r.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-1 text-muted-foreground",children:[r.jsx(En,{size:20}),r.jsx("p",{className:"text-xs",children:c("sectionsEditor.imageField.previewUnavailable")})]}),!p&&!x&&r.jsx("div",{className:"absolute inset-0 animate-pulse bg-muted/60"}),r.jsx(f4,{})]}),r.jsxs("div",{className:"flex items-center gap-2 border-t border-border/60 bg-background/50 px-3 py-2",children:[r.jsx("span",{className:"min-w-0 flex-1 truncate text-xs font-medium",children:b}),y&&r.jsx("span",{className:"shrink-0 rounded bg-muted px-1.5 py-0.5 text-[10px] font-medium uppercase text-muted-foreground",children:y})]})]}):r.jsxs("button",{type:"button",onClick:()=>u(!0),className:"flex h-40 w-full flex-col items-center justify-center gap-2 text-sm text-muted-foreground hover:bg-muted/60 hover:text-foreground",children:[r.jsx(En,{size:20}),r.jsx("span",{className:"text-sm font-medium",children:L.isPending?c("sectionsEditor.imageField.uploading"):c("sectionsEditor.imageField.dropImageOrClickToBrowse")}),r.jsx("span",{className:"text-xs text-muted-foreground",children:c("sectionsEditor.imageField.supportedFormatsAndSize")})]}),e[36]=y,e[37]=b,e[38]=x,e[39]=p,e[40]=a,e[41]=v,e[42]=g,e[43]=u,e[44]=d,e[45]=c,e[46]=L.isPending,e[47]=W):W=e[47];let H;e[48]!==f||e[49]!==c?(H=f&&r.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center bg-primary/10 backdrop-blur-[1px]",children:r.jsx("span",{className:"rounded-md bg-background px-3 py-1.5 text-xs font-medium shadow",children:c("sectionsEditor.imageField.dropToUpload")})}),e[48]=f,e[49]=c,e[50]=H):H=e[50];let X;e[51]!==M||e[52]!==D||e[53]!==$||e[54]!==U||e[55]!==W||e[56]!==H?(X=r.jsxs("div",{onDragOver:D,onDragLeave:M,onDrop:$,className:U,children:[W,H]}),e[51]=M,e[52]=D,e[53]=$,e[54]=U,e[55]=W,e[56]=H,e[57]=X):X=e[57];let q;e[58]!==V?(q=ue=>V(ue.target.value),e[58]=V,e[59]=q):q=e[59];let Z;e[60]!==c?(Z=c("sectionsEditor.imageField.urlPlaceholder"),e[60]=c,e[61]=Z):Z=e[61];let Q;e[62]!==o||e[63]!==d||e[64]!==q||e[65]!==Z?(Q=r.jsx(rt,{id:o,type:"url",value:d,onChange:q,placeholder:Z,className:"h-9 min-w-0 flex-1"}),e[62]=o,e[63]=d,e[64]=q,e[65]=Z,e[66]=Q):Q=e[66];let ee;e[67]!==u||e[68]!==d||e[69]!==c?(ee=!d&&r.jsxs(le,{type:"button",variant:"outline",size:"sm",onClick:()=>u(!0),className:"h-9 shrink-0",children:[r.jsx(Bi,{size:14}),c("sectionsEditor.imageField.browse")]}),e[67]=u,e[68]=d,e[69]=c,e[70]=ee):ee=e[70];let J;e[71]!==V||e[72]!==d||e[73]!==c?(J=d&&r.jsxs(r.Fragment,{children:[r.jsx(b4,{value:d,onChange:V}),r.jsx(le,{type:"button",variant:"ghost",size:"sm",onClick:()=>V(""),className:"h-9 shrink-0","aria-label":c("sectionsEditor.imageField.removeImage"),children:r.jsx(Ns,{size:14})})]}),e[71]=V,e[72]=d,e[73]=c,e[74]=J):J=e[74];let te;e[75]!==Q||e[76]!==ee||e[77]!==J?(te=r.jsxs("div",{className:"flex w-full min-w-0 items-center gap-2",children:[Q,ee,J]}),e[75]=Q,e[76]=ee,e[77]=J,e[78]=te):te=e[78];let se;e[79]!==V?(se=ue=>V(ue),e[79]=V,e[80]=se):se=e[80];const ne=C?.id??null;let de;e[81]!==h||e[82]!==u||e[83]!==se||e[84]!==ne?(de=r.jsx(c4,{open:h,onOpenChange:u,mode:"image",onSelect:se,lockedConfigId:ne}),e[81]=h,e[82]=u,e[83]=se,e[84]=ne,e[85]=de):de=e[85];let xe;return e[86]!==K||e[87]!==X||e[88]!==te||e[89]!==de?(xe=r.jsxs("div",{className:"grid w-full min-w-0 grid-cols-[minmax(0,1fr)] gap-2",children:[K,X,te,de]}),e[86]=K,e[87]=X,e[88]=te,e[89]=de,e[90]=xe):xe=e[90],xe}function zD(t){return $D.has(t.type||"")}function _4(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:{}}function KD(t,e){if(e.length===0)return 0;const s=_4(t);for(let o=0;o<e.length;o++){const a=e[o].discriminators;if(a&&Object.keys(a).length>0&&Object.entries(a).every(([c,d])=>s[c]===d))return o}let n=0,i=-1;for(let o=0;o<e.length;o++){const a=e[o],l=new Set(Object.keys(a.discriminators??{})),d=a.propertyKeys.filter(h=>!l.has(h)).filter(h=>s[h]!==void 0&&s[h]!==null&&s[h]!=="").length;d>i&&(i=d,n=o)}return n}function UD(t,e){const s=_4(t),n=new Set(e);return Object.fromEntries(Object.entries(s).filter(([i])=>!n.has(i)))}const HD="0 0 1080 1080",WD="matrix(1 0 0 1 540 540)",Su=[{code:"AC",name:"Acre",gTransform:"matrix(1 0 0 1 -248.53 -95.16)",pathTransform:"translate(-57.47, -224.1)",d:"M 30.47 237.77 L 28.39 237.73 L 28.93 235.92 L 28.72 235.09 L 28.47 234.6 L 27.22 233.9 L 27.08 233.45 L 27.35 232.3 L 26.58 230.35 L 25.49 229.71 L 19.89 228.46 L 12.55 228.27 L 12.82 227.71 L 15.31 225.45 L 16.2 224.22 L 16.49 223.02 L 16.27 221.79 L 15.59 220.88 L 14.76 220.44 L 13.08 217.49 L 12.31 217.05 L 11.41 216.86 L 10.28 215.73 L 9.36 213.35 L 7.36 211.82 L 6.38 208.2 L 5.51 206.56 L 3.63 205.48 L 3.55 204.31 L 4.36 204.41 L 4.78 203.89 L 4.85 203.22 L 4.65 202.8 L 2.53 201.87 L 2.17 201.21 L 0 199.32 L 0.04 198.95 L 0.66 198.9 L 1.16 197.58 L 1.15 196.27 L 4.16 195.88 L 4.66 195.49 L 4.44 194.14 L 3.27 192.57 L 3.27 192.57 L 21.22 200.05 L 44.88 205.71 L 57.02 208.85 L 83.46 223.02 L 111.97 235.15 L 111.97 235.15 L 114.94 236.41 L 114.94 236.41 L 114.64 236.89 L 113.07 237.55 L 110.98 239.14 L 108.12 241.93 L 106.47 242.79 L 105.81 242.61 L 104.28 242.79 L 104.23 243.35 L 102.31 244.65 L 100.23 245.64 L 98.79 247.47 L 98.35 248.65 L 97.74 248.93 L 96.57 248.18 L 95.81 248.05 L 93.44 248.1 L 92.76 248.36 L 92.13 248.81 L 91.77 249.67 L 89.33 253.15 L 85.56 254.4 L 84.72 255.09 L 82.78 255.6 L 81.75 255.63 L 81.83 253.52 L 80.47 253.72 L 76.92 252.95 L 71.68 252.48 L 66.59 252.86 L 65.93 252.28 L 63.66 252.11 L 60.1 253.94 L 57.37 254.56 L 55.69 253.89 L 54.29 252.45 L 52.65 253.61 L 52.69 236.06 L 52.74 234.96 L 53.21 234.25 L 53.28 231.9 L 53.02 231.02 L 53.99 229.84 L 54.47 228.7 L 53.31 228.9 L 50.34 231.49 L 48.74 232.5 L 46.68 234.88 L 44.73 235.55 L 44.08 236.63 L 42.27 237.62 z"},{code:"AL",name:"Alagoas",gTransform:"matrix(1 0 0 1 276.36 -86.82)",pathTransform:"translate(-582.36, -232.44)",d:"M 561.91 230.3 L 561.71 229.57 L 560.29 228.79 L 559.84 228.88 L 558.82 228.59 L 558.28 227.19 L 558.28 227.19 L 559.6 226.12 L 560.24 225.03 L 562.41 224.27 L 564.79 220.98 L 564.88 220.29 L 565.7 219.69 L 566.7 220.91 L 568.37 221.21 L 569.45 221.09 L 572 223.11 L 573.9 225.23 L 575.68 226.28 L 577.59 226.76 L 580.09 226.11 L 583.23 226.4 L 584.4 226.29 L 586.26 225.23 L 587.42 225.28 L 589.23 224.17 L 591.41 221.88 L 591.53 221.43 L 593.08 220.19 L 595.08 219.95 L 597.32 220.8 L 599.88 219.51 L 601.35 219.32 L 603.27 220.13 L 606.17 220.4 L 606.44 220.61 L 606.44 220.61 L 603.66 225.57 L 599.11 230.7 L 595.53 234.28 L 592.49 238.86 L 589.16 241.74 L 588.16 243.77 L 586.84 245.56 L 586.84 245.56 L 586.24 244.25 L 582.65 242.02 L 582.19 241.99 L 580.53 241.2 L 578.77 239.75 L 577.47 237.3 L 572.05 234.23 L 568.37 233.28 z"},{code:"AM",name:"Amazonas",gTransform:"matrix(1 0 0 1 -166.8 -178.05)",pathTransform:"translate(-139.2, -141.22)",d:"M 165.82 47.29 L 166.54 48.07 L 167.29 48.41 L 167.9 48.42 L 169.03 48 L 169.66 48.11 L 169.72 49.07 L 170.93 50.24 L 171.9 50.61 L 172.78 50.4 L 174.14 50.51 L 176.09 51.46 L 176.58 52.12 L 175.67 55.44 L 174.96 56.94 L 177.69 60.68 L 179.35 65.44 L 179.54 67.7 L 180.41 68.82 L 180.46 69.27 L 178.84 70.73 L 179.2 72.32 L 179.86 73.9 L 179.09 76.94 L 178.52 77.9 L 178.81 82.88 L 179.69 85.05 L 180.91 85.89 L 181.49 86.79 L 182.62 91.12 L 182.56 91.7 L 181.42 93.02 L 179.58 92.69 L 179.44 93.83 L 184.45 98.25 L 184.97 98.29 L 186.93 99.6 L 188.41 101.25 L 189.45 103.29 L 189.98 103.36 L 191.32 102.94 L 193.68 103.98 L 193.24 101.87 L 193.99 99.58 L 194.24 97.85 L 193.87 96.05 L 194.69 93.08 L 195.71 91.82 L 196.99 91.13 L 199.08 90.42 L 199.63 89.53 L 201.23 89.47 L 204.06 90.4 L 205.93 92.44 L 206.85 94.95 L 208.67 95.18 L 209.92 94.72 L 211.33 93.31 L 213.36 92.76 L 213.78 92.37 L 213.8 91.84 L 212.66 90.43 L 212.43 89.7 L 212.54 89.04 L 213.69 86.4 L 213.76 85.27 L 215.42 82.24 L 217.75 78.98 L 217.72 78.3 L 236.21 78.37 L 236.21 78.37 L 236.61 83.23 L 236.18 84.68 L 236.36 86.95 L 236.6 87.63 L 238.3 88.48 L 238.48 88.89 L 238.13 89.58 L 238.08 91.69 L 239.91 93.68 L 240.27 93.87 L 240.97 93.69 L 242.81 94.92 L 243.36 96.75 L 243.4 97.68 L 243.7 98.13 L 248.34 101.9 L 252.92 104.44 L 253.55 105.34 L 254.9 106.43 L 256.78 107.1 L 259.15 108.41 L 261.41 109.06 L 262.77 109.21 L 264.09 110.03 L 264.17 110.64 L 265.44 111.98 L 268.14 113.42 L 269.24 115.59 L 271.11 116.38 L 271.96 115.77 L 273.34 115.42 L 273.53 115.9 L 273.4 116.68 L 275.21 118.35 L 245.31 182.59 L 244.53 183.9 L 243.08 185.03 L 242.5 186 L 242.47 187.13 L 243.29 189.46 L 243.67 190.03 L 244.74 190.61 L 246.32 192.17 L 246.96 193.43 L 247.11 195.39 L 247.68 195.96 L 247.68 195.96 L 246.5 197.16 L 246.3 197.77 L 246.24 198.53 L 246.58 199.37 L 246.31 200.38 L 245.11 202.2 L 244.25 202.84 L 243.83 203.69 L 243.93 204.54 L 244.59 205.91 L 245.05 207.85 L 243.67 212.07 L 242.49 217.29 L 241.28 218.02 L 193.43 218.34 L 193.43 218.34 L 193.47 217.64 L 193.11 217.26 L 191.72 216.98 L 189.8 218.06 L 189.26 219.8 L 188.58 219.99 L 185.34 218.51 L 184.66 215.63 L 184.04 215.43 L 183.06 215.56 L 182.6 215.35 L 181.35 212.08 L 178.81 211.1 L 177.48 209.83 L 176.68 207.92 L 176.23 207.43 L 174.08 206.3 L 163.29 206.36 L 161.91 208.92 L 160.19 209.42 L 160.28 210.59 L 160.02 210.81 L 157.54 211.34 L 156.35 212.93 L 156.3 213.6 L 157.2 214.3 L 157.37 214.75 L 157.01 215.77 L 156.2 216.92 L 154.14 218.13 L 154.03 219.94 L 154.27 221.4 L 150.4 220.94 L 148.27 221.32 L 147.07 222.39 L 145.28 222.29 L 144.44 221.74 L 143.98 221.72 L 142.23 222.98 L 141.7 223.82 L 141.96 225.57 L 139.42 228.73 L 138.74 228.81 L 138.06 228.28 L 137.42 226.02 L 137.04 225.93 L 135.2 226.95 L 133.9 228.16 L 132.53 228.55 L 131.76 228.42 L 130.68 228.92 L 130.27 229.45 L 130.14 230.17 L 128.92 230.96 L 128.55 230.98 L 126.24 228.65 L 125.52 228.28 L 122.65 228.61 L 118.69 228.35 L 118.85 229.64 L 118.7 230.2 L 117.15 232.01 L 115.23 232.59 L 111.97 235.15 L 111.97 235.15 L 83.46 223.02 L 57.02 208.85 L 44.88 205.71 L 21.22 200.05 L 3.27 192.57 L 3.27 192.57 L 3.2 191.92 L 3.9 189 L 5.12 187.6 L 10.04 184.13 L 12.3 183.89 L 12.77 183.59 L 13.75 182.03 L 13.83 181 L 12.09 176.51 L 12.47 175.32 L 13.65 173.13 L 14.93 171.81 L 15.85 170.56 L 16.27 169.58 L 16.57 167.84 L 16.28 166.52 L 16.95 164.48 L 17.26 162.17 L 17.99 161.42 L 21.65 159.79 L 23.84 158.56 L 24.99 157.52 L 25.43 156.12 L 26.21 155.75 L 27.62 155.64 L 29.27 154.71 L 32.81 151.98 L 35.23 151.55 L 36.74 151.84 L 40.93 150.62 L 42.43 149.85 L 44.25 149.49 L 47.58 149.87 L 48.88 148.28 L 49.51 146.83 L 50.6 146.22 L 52.74 146.42 L 53.38 146.96 L 54.7 146.72 L 55.8 145.98 L 57.51 146.1 L 57.82 146.63 L 57.8 147.81 L 59.41 149.1 L 62.24 149.18 L 62.82 148.78 L 63.28 148 L 63.17 147.61 L 64.34 142.69 L 71.04 105.52 L 72.2 102.6 L 71.21 97.64 L 71.33 97.38 L 70.03 96.33 L 68.55 93.58 L 68.51 93.09 L 69.16 91.7 L 68.64 89.92 L 68.27 89.52 L 66.57 88.93 L 63.54 86.58 L 61.6 84.3 L 61.8 72.79 L 65.69 72.53 L 67.44 71.36 L 70.94 70.44 L 73.62 72.2 L 74.84 72.31 L 76.11 71.88 L 75.62 70.19 L 75.92 68.47 L 74.55 66.37 L 73.98 65.83 L 72.83 65.23 L 71.32 65.76 L 68.53 65.15 L 64.96 65.24 L 64.9 55.34 L 65.86 55.38 L 67.18 54.8 L 69.46 54.2 L 72.3 55.07 L 91.33 55.13 L 90.87 54.47 L 90.08 54.33 L 89.7 53.13 L 90.65 51.2 L 92.08 51.6 L 92.69 53.12 L 93.56 54.44 L 94.22 54.79 L 95.05 54.8 L 96.66 54.19 L 98.6 52.1 L 98.92 51.26 L 100.18 50.02 L 102.73 48.63 L 104.02 49.09 L 105.19 51.67 L 106.81 53.66 L 107.55 54.96 L 108.21 56.74 L 108.44 58.29 L 107.95 61.92 L 108.15 63.68 L 111.35 62.93 L 119.66 69.99 L 120.45 70.27 L 122.95 70.48 L 125.25 69.48 L 126.95 67.78 L 129.06 66.62 L 131.25 66.51 L 131.81 66.8 L 132.58 67.88 L 132.56 68.85 L 131.45 70.55 L 131.82 71.53 L 132.4 71.8 L 133.73 71.08 L 134.29 70.17 L 134.52 68.88 L 135.52 67.72 L 135.99 67.49 L 136.99 67.67 L 137.54 67.49 L 137.95 66.83 L 138.41 64.52 L 138.92 64.15 L 140.43 63.79 L 143.36 62.02 L 144.33 62.57 L 145.26 62.28 L 146.86 61.24 L 147.88 59.63 L 149.99 58.42 L 152.02 58.97 L 154.38 57.32 L 154.93 56.5 L 155.37 53.84 L 155.34 52.55 L 156.11 51.63 L 157.14 51.21 L 158.88 51.19 L 160.22 50.8 L 162.28 49.2 L 163.24 48.83 L 165.52 48.53 z"},{code:"AP",name:"Amapá",gTransform:"matrix(1 0 0 1 32.29 -262.31)",pathTransform:"translate(-338.29, -56.97)",d:"M 344.98 99.7 L 344.04 99.64 L 343.27000000000004 99.98 L 341.97 100.10000000000001 L 339.18 99.42 L 337.73 98.39 L 337.3 96.89 L 335.43 95.5 L 335.32 94.2 L 335.53 93.51 L 335.21999999999997 91.93 L 334.89 91.46000000000001 L 333.94 91.27000000000001 L 333.53 90.33000000000001 L 333.60999999999996 87.9 L 330.67999999999995 84.62 L 329.9 84.98 L 329.08 84.79 L 327.58 81.31 L 327.71 79.73 L 327.12 77.92 L 326.5 77.36 L 325.83 75.85 L 325.64 73.74 L 326.07 70.6 L 325.9 70.27 L 323.33 69.53999999999999 L 321.31 67.27999999999999 L 320.55 64.44999999999999 L 320.74 63.72999999999999 L 321.42 63.49999999999999 L 320.93 62.31999999999999 L 320.25 62.349999999999994 L 317.41 59.69 L 316.47 59.83 L 316.09000000000003 60.25 L 314.76000000000005 60.39 L 313.9200000000001 60.12 L 313.12000000000006 59.14 L 311.9800000000001 58.3 L 310.7900000000001 58.18 L 310.30000000000007 56.9 L 309.63000000000005 56.1 L 307.70000000000005 55.050000000000004 L 306.41 54.56 L 303.02000000000004 54.190000000000005 L 301.94000000000005 54.480000000000004 L 300.77000000000004 54.46 L 300.46000000000004 53.92 L 300.22 52.480000000000004 L 300.47 47.940000000000005 L 301.09000000000003 46.64000000000001 L 300.72 44.34000000000001 L 300.1 43.77000000000001 L 300.1 43.77000000000001 L 300.45000000000005 43.56000000000001 L 301.44000000000005 43.86000000000001 L 301.43000000000006 44.67000000000001 L 301.14000000000004 44.85000000000001 L 301.48 45.82000000000001 L 302.95000000000005 45.760000000000005 L 303.77000000000004 45.99 L 304.12000000000006 46.89 L 304.96000000000004 47.6 L 307.21000000000004 48.38 L 310.50000000000006 49.13 L 313.26000000000005 47.35 L 313.61000000000007 46.59 L 315.3400000000001 45.42 L 316.1700000000001 45.13 L 316.86000000000007 46.07 L 319.57000000000005 47.01 L 320.65000000000003 46.89 L 322.37000000000006 45.88 L 322.49000000000007 45.46 L 322.81000000000006 45.49 L 324.27000000000004 46.79 L 324.07000000000005 47.66 L 326.44000000000005 47.489999999999995 L 326.95000000000005 47.989999999999995 L 327.90000000000003 48.16 L 328.52000000000004 48.15 L 329.43000000000006 47.67 L 331.1000000000001 46.17 L 332.88000000000005 45.07 L 334.63000000000005 42.77 L 335.00000000000006 41.77 L 334.80000000000007 41.230000000000004 L 337.93000000000006 34.730000000000004 L 338.0400000000001 32.910000000000004 L 339.1500000000001 31.610000000000003 L 339.8800000000001 31.42 L 343.48000000000013 25.630000000000003 L 343.71000000000015 24.480000000000004 L 344.5500000000001 23.280000000000005 L 346.34000000000015 21.730000000000004 L 346.97000000000014 20.070000000000004 L 349.08000000000015 18.930000000000003 L 349.5500000000002 18.01 L 350.5900000000002 17.430000000000003 L 351.1500000000002 18.890000000000004 L 352.0300000000002 20.250000000000004 L 350.3600000000002 15.450000000000003 L 350.2900000000002 14.160000000000004 L 350.4700000000002 13.830000000000004 L 353.8400000000002 16.250000000000004 L 354.9800000000002 17.460000000000004 L 355.8900000000002 18.680000000000003 L 356.4100000000002 19.870000000000005 L 356.44000000000017 21.450000000000003 L 356.88000000000017 21.76 L 357.20000000000016 21.28 L 357.58000000000015 21.18 L 357.79000000000013 21.58 L 358.0000000000001 29.47 L 358.66000000000014 33.339999999999996 L 361.3700000000001 39.38999999999999 L 364.03000000000014 48.32999999999999 L 367.35000000000014 53.32999999999999 L 368.3600000000001 53.67999999999999 L 371.6300000000001 53.599999999999994 L 374.4100000000001 54.53999999999999 L 375.7000000000001 55.38999999999999 L 376.4700000000001 58.03999999999999 L 376.31000000000006 61.36999999999999 L 375.02000000000004 62.32999999999999 L 373.29 62.75999999999999 L 372.91 63.08999999999999 L 374.70000000000005 62.93999999999999 L 375.74000000000007 62.51999999999999 L 376.02000000000004 62.749999999999986 L 376.14000000000004 63.33999999999999 L 375.97 64.07 L 370.94000000000005 68.13 L 369.77000000000004 70.22999999999999 L 367.62000000000006 71.63999999999999 L 365.68000000000006 75.35999999999999 L 362.77000000000004 78.85999999999999 L 362.07000000000005 79.31999999999998 L 361.13000000000005 79.22999999999998 L 359.68000000000006 79.74999999999997 L 357.6000000000001 82.72999999999998 L 357.6000000000001 82.72999999999998 L 356.2600000000001 82.79999999999997 L 355.5100000000001 83.69999999999997 L 355.5100000000001 83.69999999999997 L 354.0400000000001 85.37999999999998 L 353.07000000000005 87.59999999999998 L 351.95000000000005 89.46999999999998 L 351.11000000000007 90.11999999999999 L 348.1000000000001 93.57 L 347.74000000000007 95.97 L 347.9100000000001 97.77 L 345.9600000000001 99.58 L 344.98 99.7 z M 368.34 52.71 L 367.89 52.38 L 366.78999999999996 50.52 L 366.85999999999996 49.64 L 367.09 49.230000000000004 L 368.75 48.78 L 369.18 49.17 L 370.01 51.440000000000005 L 369.02 52.540000000000006 L 368.34 52.71 z M 370.83 70.32 L 370.43 70.07 L 370.35 69.36 L 371.46000000000004 68.26 L 372.34000000000003 68.11 L 373.59000000000003 68.35 L 374.05 68.24 L 374.49 67.6 L 374.54 68.19 L 373.57 69.63 L 372.58 70.13 L 370.83 70.32 z M 374.27 67.45 L 373.49 67.22 L 373.49 66.66 L 374.21000000000004 65.61999999999999 L 375.46000000000004 65.52 L 375.64000000000004 65.86999999999999 L 375.54 66.38 L 374.27 67.45 z M 367.08 49.03 L 366.32 48.53 L 366.58 47.7 L 367.46 47.53 L 368.32 47.85 L 368.33 48.58 L 367.08 49.03 z"},{code:"BA",name:"Bahia",gTransform:"matrix(1 0 0 1 193.52 -26.39)",pathTransform:"translate(-499.52, -292.87)",d:"M 527.5 365.33 L 527.14 364.5 L 527.8199999999999 363.15 L 527.81 362.62 L 527.28 361.58 L 523.15 358.53 L 523 358.02 L 523.22 356.51 L 522.65 355.28 L 522 355.52 L 521.8 355.96999999999997 L 521.4599999999999 356.15 L 521.2399999999999 355.9 L 521.7699999999999 351.5 L 522.5899999999999 348.2 L 523.41 347.32 L 525.88 347.56 L 526.9 346.85 L 526.9 346.43 L 526.34 345.41 L 526.5 342.76000000000005 L 531.46 338.54 L 532.9300000000001 335.46000000000004 L 532.5100000000001 334.29 L 531.7300000000001 333.27000000000004 L 530.8400000000001 333.21000000000004 L 530.1100000000001 332.83000000000004 L 527.2800000000001 330.36 L 525.1600000000001 330.38 L 522.97 329.78 L 520.7 328.7 L 517.97 328.14 L 515.99 328 L 514.67 328.99 L 513.1999999999999 329.49 L 510.5899999999999 329.04 L 510.0199999999999 329.25 L 509.5799999999999 325.29 L 503.05999999999995 319.09000000000003 L 502.67999999999995 318.91 L 498.28999999999996 320.14000000000004 L 496.76 318.90000000000003 L 496.25 319.11 L 495.32 318.89 L 492.78 317.66999999999996 L 490.60999999999996 316.04999999999995 L 489.62999999999994 316.22999999999996 L 485.2799999999999 312.59999999999997 L 484.1799999999999 312.05999999999995 L 481.4499999999999 311.30999999999995 L 479.6799999999999 311.55999999999995 L 477.7999999999999 312.4599999999999 L 476.9899999999999 313.5799999999999 L 476.3499999999999 313.75999999999993 L 471.0199999999999 312.2899999999999 L 470.4099999999999 311.7999999999999 L 470.1499999999999 310.2999999999999 L 470.2899999999999 309.4099999999999 L 471.5799999999999 306.6699999999999 L 470.7199999999999 306.2099999999999 L 468.43999999999994 305.68999999999994 L 466.25999999999993 305.6499999999999 L 465.05999999999995 305.1499999999999 L 463.2699999999999 305.06999999999994 L 459.43999999999994 306.6499999999999 L 455.17999999999995 309.6799999999999 L 454.53999999999996 310.7899999999999 L 451.16999999999996 312.6599999999999 L 449.15 313.0599999999999 L 448.2 314.2399999999999 L 446.39 315.7899999999999 L 444.96 316.3099999999999 L 443.96 316.1599999999999 L 442.10999999999996 318.7399999999999 L 441.06999999999994 319.5099999999999 L 438.93999999999994 319.1299999999999 L 438.2199999999999 319.2599999999999 L 437.5299999999999 320.2599999999999 L 436.18999999999994 321.1799999999999 L 435.78999999999996 320.9399999999999 L 437.21999999999997 317.5099999999999 L 436.71 315.09999999999985 L 436.71 315.09999999999985 L 438.19 313.1299999999998 L 438.44 312.35999999999984 L 438.21 311.08999999999986 L 437.53999999999996 309.36999999999983 L 437.64 308.6999999999998 L 438.34999999999997 307.2799999999998 L 438.29999999999995 306.8199999999998 L 435.09 304.1999999999998 L 433.4 300.73999999999984 L 432.78 297.21999999999986 L 432.83 295.66999999999985 L 434.03 291.83999999999986 L 435.61999999999995 290.8099999999999 L 435.84999999999997 290.4299999999999 L 435.90999999999997 289.4899999999999 L 434.28 288.6499999999999 L 434.16999999999996 288.31999999999994 L 434.65 285.79999999999995 L 436.08 284.73999999999995 L 436.06 284.36999999999995 L 433.34 281.90999999999997 L 433.34 281.90999999999997 L 433.29999999999995 280.97999999999996 L 434.65999999999997 278.59999999999997 L 434.61999999999995 277.53 L 434.44999999999993 277.10999999999996 L 432.98999999999995 276.61999999999995 L 432.04999999999995 275.96999999999997 L 431.69999999999993 274.71 L 431.75999999999993 271.78999999999996 L 431.94999999999993 270.93999999999994 L 433.8999999999999 269.2699999999999 L 435.0399999999999 268.8499999999999 L 435.9999999999999 268.1299999999999 L 435.70999999999987 267.4999999999999 L 435.1299999999999 266.9799999999999 L 434.20999999999987 266.6899999999999 L 433.1799999999999 266.8699999999999 L 432.82999999999987 266.5399999999999 L 432.7399999999999 266.0399999999999 L 433.1599999999999 265.0799999999999 L 435.19999999999993 264.25999999999993 L 435.75999999999993 263.80999999999995 L 435.7199999999999 263.04999999999995 L 433.8399999999999 262.06999999999994 L 430.25999999999993 261.3999999999999 L 428.3999999999999 259.43999999999994 L 428.1699999999999 258.5199999999999 L 428.6699999999999 257.3599999999999 L 429.6799999999999 256.6299999999999 L 431.1999999999999 253.1499999999999 L 432.09999999999985 252.53999999999988 L 433.10999999999984 252.26999999999987 L 433.45999999999987 251.88999999999987 L 432.16999999999985 250.08999999999986 L 432.35999999999984 249.71999999999986 L 435.5699999999998 247.09999999999985 L 439.3899999999998 245.07999999999984 L 439.9499999999998 244.60999999999984 L 440.16999999999985 243.62999999999985 L 440.85999999999984 242.97999999999985 L 440.85999999999984 242.97999999999985 L 443.1899999999998 242.95999999999984 L 444.6299999999998 244.29999999999984 L 445.28999999999985 245.33999999999983 L 445.8199999999998 247.54999999999984 L 447.5799999999998 250.03999999999985 L 451.7599999999998 251.89999999999986 L 453.55999999999983 251.37999999999985 L 455.66999999999985 251.55999999999986 L 455.99999999999983 251.34999999999985 L 456.74999999999983 249.89999999999986 L 457.8899999999998 249.52999999999986 L 458.55999999999983 248.65999999999985 L 459.72999999999985 247.76999999999987 L 461.9399999999998 247.01999999999987 L 463.2699999999998 247.18999999999986 L 464.74999999999983 247.71999999999986 L 466.09999999999985 247.29999999999987 L 469.0699999999999 244.87999999999988 L 472.01999999999987 239.82999999999987 L 472.7399999999999 238.96999999999986 L 472.9799999999999 238.04999999999987 L 473.2799999999999 235.48999999999987 L 473.1599999999999 234.32999999999987 L 470.9199999999999 229.89999999999986 L 470.9699999999999 228.96999999999986 L 474.2099999999999 227.31999999999985 L 476.1599999999999 227.29999999999984 L 477.6599999999999 227.75999999999985 L 478.06999999999994 228.68999999999986 L 478.38999999999993 228.86999999999986 L 480.50999999999993 228.43999999999986 L 481.8999999999999 227.89999999999986 L 483.2299999999999 228.27999999999986 L 484.9399999999999 229.26999999999987 L 484.8099999999999 229.91999999999987 L 484.9999999999999 230.20999999999987 L 485.8199999999999 230.48999999999987 L 488.8199999999999 230.37999999999985 L 490.2899999999999 229.73999999999987 L 491.9899999999999 229.63999999999987 L 492.8099999999999 228.41999999999987 L 494.3199999999999 227.07999999999987 L 497.0499999999999 226.73999999999987 L 497.8199999999999 226.37999999999985 L 498.6299999999999 225.39999999999986 L 500.7999999999999 225.40999999999985 L 501.4199999999999 226.03999999999985 L 501.7299999999999 226.08999999999986 L 503.5899999999999 224.27999999999986 L 503.4899999999999 221.87999999999985 L 505.4799999999999 221.49999999999986 L 506.2699999999999 221.67999999999986 L 507.31999999999994 221.01999999999987 L 508.81999999999994 218.70999999999987 L 509.2799999999999 217.55999999999986 L 509.2799999999999 217.55999999999986 L 510.1699999999999 217.95999999999987 L 511.3299999999999 217.68999999999986 L 513.53 217.97999999999985 L 516.35 219.36999999999983 L 516.7900000000001 219.87999999999982 L 516.7300000000001 222.60999999999981 L 517.4500000000002 224.5499999999998 L 519.6600000000002 225.4599999999998 L 519.9300000000002 227.4599999999998 L 519.0100000000002 229.13999999999982 L 520.8400000000003 229.75999999999982 L 521.8000000000003 229.53999999999982 L 522.6200000000003 228.61999999999983 L 525.4900000000004 227.73999999999984 L 526.2600000000003 224.15999999999983 L 526.7600000000003 223.28999999999982 L 527.5100000000003 223.12999999999982 L 528.2900000000003 223.65999999999983 L 528.9200000000003 223.70999999999984 L 531.3100000000003 222.68999999999983 L 532.4100000000003 221.44999999999982 L 532.5800000000003 220.85999999999981 L 532.3300000000003 219.4999999999998 L 532.6200000000002 219.2499999999998 L 534.8600000000002 218.7999999999998 L 535.6300000000002 216.7499999999998 L 537.2800000000002 216.3099999999998 L 539.8100000000002 214.8499999999998 L 540.4000000000002 214.7499999999998 L 541.8900000000002 215.3099999999998 L 542.7200000000003 216.7499999999998 L 544.0800000000003 217.5599999999998 L 546.4400000000003 218.3399999999998 L 549.4300000000003 218.7399999999998 L 551.0100000000003 219.88999999999982 L 551.5500000000003 221.53999999999982 L 551.9400000000003 221.80999999999983 L 552.3700000000002 221.65999999999983 L 552.6600000000002 219.90999999999983 L 553.0900000000001 219.46999999999983 L 554.0900000000001 219.45999999999984 L 554.5400000000002 219.77999999999983 L 554.5600000000002 220.40999999999983 L 553.9400000000002 221.28999999999982 L 554.3900000000002 222.11999999999983 L 554.8900000000002 222.48999999999984 L 556.9900000000002 223.34999999999985 L 557.0100000000002 224.28999999999985 L 558.2300000000002 227.33999999999986 L 558.2300000000002 227.33999999999986 L 558.7700000000002 228.73999999999987 L 559.7900000000002 229.02999999999986 L 560.2400000000002 228.93999999999986 L 561.6700000000002 229.72999999999985 L 561.8700000000002 230.44999999999985 L 561.8700000000002 230.44999999999985 L 561.2000000000003 231.60999999999984 L 561.4100000000003 233.74999999999983 L 562.6900000000003 236.24999999999983 L 564.6800000000003 238.19999999999982 L 565.4300000000003 239.34999999999982 L 565.3500000000003 242.46999999999983 L 564.6900000000003 244.08999999999983 L 564.6000000000003 244.96999999999983 L 565.3600000000002 247.71999999999983 L 565.0600000000003 248.29999999999984 L 564.3700000000002 248.84999999999985 L 561.8200000000003 249.84999999999985 L 560.6900000000003 249.09999999999985 L 558.9800000000002 249.08999999999986 L 558.6600000000002 249.38999999999987 L 558.0700000000002 250.96999999999989 L 558.0900000000001 251.7399999999999 L 559.0400000000002 253.3399999999999 L 560.1400000000002 253.9999999999999 L 560.6600000000002 255.4899999999999 L 562.0900000000001 256.9999999999999 L 562.2400000000001 257.3899999999999 L 562.1100000000001 258.8099999999999 L 561.7700000000001 259.1999999999999 L 561.8900000000001 259.6199999999999 L 562.4800000000001 260.1399999999999 L 564.4100000000001 261.0599999999999 L 564.8900000000001 261.76999999999987 L 565.4300000000001 262.10999999999984 L 566.98 262.74999999999983 L 569.87 261.86999999999983 L 569.87 261.86999999999983 L 570.51 261.84999999999985 L 570.87 262.2599999999999 L 566.79 271.08999999999986 L 562.9599999999999 276.27999999999986 L 561.93 278.60999999999984 L 556.9 284.34999999999985 L 554.4499999999999 285.60999999999984 L 553.5799999999999 285.59999999999985 L 553.8799999999999 284.16999999999985 L 554.2499999999999 284.01999999999987 L 554.3899999999999 282.91999999999985 L 553.9399999999998 280.98999999999984 L 552.0699999999998 280.73999999999984 L 551.6399999999999 279.4399999999998 L 550.9599999999999 278.6899999999998 L 550.5899999999999 279.28999999999985 L 550.1299999999999 281.61999999999983 L 549.6299999999999 282.48999999999984 L 549.0799999999999 282.86999999999983 L 548.52 282.5799999999998 L 548.03 280.8399999999998 L 548.14 280.5199999999998 L 548.4499999999999 280.3899999999998 L 548.42 279.99999999999983 L 547.55 281.28999999999985 L 548.4799999999999 282.97999999999985 L 548.9399999999999 283.20999999999987 L 549.31 283.0599999999999 L 550.4599999999999 283.3199999999999 L 549.9999999999999 285.1299999999999 L 548.7899999999998 286.27999999999986 L 548.5399999999998 288.09999999999985 L 547.2899999999998 289.0699999999999 L 546.9399999999998 289.7399999999999 L 546.7399999999998 290.57999999999987 L 546.9199999999997 291.4299999999999 L 545.5699999999997 291.0399999999999 L 545.3599999999997 291.4299999999999 L 544.9999999999997 293.9499999999999 L 545.3599999999997 293.22999999999985 L 546.1099999999997 293.4399999999998 L 546.3499999999997 293.97999999999985 L 546.1199999999997 294.3899999999999 L 546.1799999999996 295.0099999999999 L 546.4799999999996 295.3099999999999 L 546.8099999999996 296.3099999999999 L 545.7699999999996 298.8199999999999 L 546.3399999999997 302.2599999999999 L 545.7899999999997 302.7499999999999 L 545.2199999999997 302.52999999999986 L 545.0799999999997 303.65999999999985 L 545.6699999999997 304.11999999999983 L 546.8799999999998 302.3999999999998 L 546.4099999999997 300.1899999999998 L 547.2299999999998 299.5799999999998 L 547.4799999999998 300.11999999999983 L 547.4199999999998 301.8799999999998 L 546.4599999999998 304.48999999999984 L 545.7199999999998 309.91999999999985 L 545.2099999999998 311.72999999999985 L 545.4099999999999 314.1999999999999 L 546.1899999999998 317.0499999999999 L 546.3799999999999 321.5899999999999 L 547.2499999999999 327.99999999999994 L 548.2399999999999 331.41999999999996 L 546.0299999999999 338.08 L 544.6799999999998 344.72999999999996 L 544.2099999999998 345.73999999999995 L 544.0499999999998 348.59999999999997 L 542.9899999999999 352.32 L 542.8999999999999 354.65 L 543.2899999999998 359.07 L 544.1799999999998 360.78 L 541.9399999999998 363.76 L 540.1299999999999 364.43 L 539.1899999999998 365.07 L 536.4699999999998 368.96 L 535.9 371 L 535.9 371 L 527.81 365.86 L 527.5 365.33 z M 549.78 287.33 L 549.55 286.13 L 550.29 285.71999999999997 L 551.3499999999999 284.67999999999995 L 551.5099999999999 284.03999999999996 L 551.1399999999999 283.30999999999995 L 551.8999999999999 283.44999999999993 L 552.7199999999999 284.49999999999994 L 552.67 285.0299999999999 L 549.78 287.33 z M 547.25 294.18 L 546.62 294.15000000000003 L 546.63 293.48 L 546.89 293.12 L 546.09 292.9 L 545.6700000000001 292.5 L 545.8000000000001 291.43 L 547.6700000000001 291.28000000000003 L 547.83 291.48 L 547.94 292.61 L 547.25 294.18 z"},{code:"CE",name:"Ceará",gTransform:"matrix(1 0 0 1 235.04 -154.64)",pathTransform:"translate(-541.04, -164.62)",d:"M 573.79 156.85 L 568.9 158.44 L 566.29 160.45 L 562.99 167.14 L 562.15 168.26 L 561.28 168.83 L 560.63 170.5 L 560.78 171.24 L 559.38 173.68 L 557.92 175.19 L 557.35 176.29 L 556.32 176.55 L 555.54 176.04 L 555.03 176.11 L 554.19 176.99 L 552.78 179.24 L 552.44 181.21 L 553.08 181.38 L 553.74 181 L 553.74 181 L 553.66 181.54 L 552.82 182.69 L 551.79 185.69 L 552.31 187 L 551.65 188.31 L 550.56 188.94 L 550.39 189.32 L 550.27 190.25 L 550.51 190.66 L 551.09 190.95 L 551.44 191.67 L 551.42 193.33 L 552.66 194.22 L 553.35 194.3 L 553.69 195.49 L 552.08 198.98 L 550.89 200.1 L 551.06 200.35 L 551.06 200.35 L 549.47 200.84 L 548.4 201.67 L 546.86 203.96 L 545.21 204.01 L 544.58 202.37 L 543.8 201.8 L 542.44 201.32 L 541.43 200.25 L 540.97 199.26 L 539.14 198.43 L 536.29 196.53 L 533.21 196.11 L 531.92 196.21 L 529.78 197.01 L 528.15 197.2 L 527.26 196.96 L 522.33 196.76 L 522.33 196.76 L 522.39 195.44 L 521.71 194.76 L 521.63 193.79 L 522.77 190.68 L 524.27 188.43 L 524.28 187.74 L 523.51 186.58 L 520.95 186.11 L 519.64 185.46 L 518.63 182.79 L 517.58 177.59 L 516.82 175.02 L 517.06 174.57 L 516.12 166.41 L 516.01 166.03 L 515.09 165.34 L 515.89 164.76 L 516.48 163.18 L 515.88 160.19 L 514.88 158.18 L 515.36 156.58 L 514.57 152.71 L 515.31 151.35 L 515.33 150.59 L 513.97 149 L 513.53 147.27 L 510.38 140.85 L 508.58 136.13 L 508.29 134.84 L 508.47 133.38 L 510.05 131.41 L 511.14 129.56 L 511.25 128.76 L 511.25 128.76 L 511.44 128.62 L 511.4 128 L 511 127.34 L 511.65 126.53 L 518.39 126.31 L 521.28 125.88 L 523.35 125.22 L 530.75 126.01 L 532.87 127.13 L 534.81 128.63 L 538.93 130.81 L 540.39 131.33 L 545.21 134.33 L 546.42 134.53 L 548.64 136.82 L 551.63 138.93 L 554.2 139.65 L 556.64 142.56 L 557.86 143.17 L 560.82 146.98 L 564.98 150.06 L 566.44 152.06 L 567.48 153.05 L 568.98 153.87 L 570.13 153.9 L 572.5 154.82 L 573.29 155.49 z"},{code:"DF",name:"Distrito Federal",gTransform:"matrix(1 0 0 1 103.1 10.18)",pathTransform:"translate(-409.11, -329.45)",d:"M 416.71 333.87 L 402.02 333.85 L 401.5 330.59 L 402.42 328.76 L 402.8 325.03 L 414.75 325.04 L 416.58 327.02 L 416.64 329.23 L 416.05 330.42 L 415.84 332.86 z"},{code:"ES",name:"Espírito Santo",gTransform:"matrix(1 0 0 1 212.62 72.56)",pathTransform:"translate(-518.62, -391.82)",d:"M 501.63 411.37 L 501.34 411.23 L 501.78 408.89 L 502.35 407.59 L 501.76 404.47 L 501.92 404.05 L 503.64 401.99 L 508.79 402.02 L 509.34 401.7 L 510.31 398.46 L 511.42 397.19 L 512.3 394.9 L 512.54 393.18 L 512.8 392.74 L 514.04 391.88 L 515.75 389.79 L 516.29 386.82 L 516 384.39 L 514.73 381.58 L 513.63 380.31 L 513.11 380.22 L 512.66 380.51 L 511.9 380.23 L 511.41 379.52 L 511.84 378.97 L 513.32 378.88 L 514.12 379.23 L 515.09 379.26 L 516.04 379.02 L 516.36 378.6 L 516.19 376.88 L 514.88 376.53 L 514.67 376.12 L 514.97 374.58 L 515 372.66 L 514.48 372 L 513.15 371.33 L 512.85 370.63 L 514.02 368.7 L 516.19 367.39 L 516.5 367.37 L 517.55 368.11 L 518.68 368.22 L 518.7 367.41 L 517.03 365.14 L 518.37 365.27 L 520.55 364.98 L 521.39 364.37 L 522.47 364.05 L 524.05 363.97 L 526.59 364.78 L 527.5 365.33 L 527.5 365.33 L 527.5 365.33 L 527.5 365.33 L 527.8 365.86 L 535.9 371 L 535.9 371 L 534.97 374.35 L 534.66 377.21 L 534.78 380.8 L 535.5 386.95 L 535.19 389.42 L 533.7 392.6 L 530.95 393.99 L 530.4 394.59 L 528.73 397.92 L 527.75 401.72 L 526.98 403.19 L 526.15 402.51 L 525.27 402.38 L 524.98 403.66 L 526.33 404.18 L 524.39 408.42 L 520.94 412.26 L 520.7 411.99 L 518.84 412.65 L 518.04 413.88 L 517.98 415.27 L 517.56 416.52 L 515.97 418.54 L 515.68 419.67 L 515.68 419.67 L 514.06 418.61 L 511.07 418.98 L 506.73 417.97 L 504.23 416.84 L 503.56 412.13 z"},{code:"GO",name:"Goiás",gTransform:"matrix(1 0 0 1 75.37 14.13)",pathTransform:"translate(-381.37, -333.38)",d:"M 416.71 333.87 L 415.84 332.86 L 416.05 330.42 L 416.64 329.23 L 416.58 327.02 L 414.75 325.04 L 402.8 325.03 L 402.42 328.76 L 401.5 330.59 L 402.02 333.85 L 416.71 333.87 L 416.71 333.87 L 416.71 333.87 L 416.71 333.87 L 416.18 335.39 L 416.49 336.96 L 415.81 338.55 L 414.77 339.8 L 414.36 341.27 L 415.21 342.48 L 416.06 342.82 L 417.48 343.85 L 419.13 348.41 L 419.13 349.01 L 416.81 351.72 L 413.57 354.73 L 413.14 356.87 L 414.23 357.98 L 415.13 357.51 L 416.71 358.08 L 417.18 358.69 L 417.36 359.69 L 417.19 360.4 L 416.46 361.3 L 415.95 363.19 L 417.14 366.65 L 414.05 368.71 L 412.89 368.91 L 412.03 369.81 L 411.55 370.93 L 406.66 373.67 L 405.96 372.9 L 401.61 371.04 L 401.06 371.52 L 400.48 371.61 L 398.73 371.62 L 397.25 371.34 L 393.39 371.5 L 391.38 370.61 L 387.25 373.25 L 384.34 376.17 L 384.01 376.17 L 382.7 374.75 L 381.18 374.45 L 377.99 376.09 L 374.28 375.47 L 371.8 376.43 L 369.57 376.97 L 368.16 379.07 L 366.95 381.53 L 367.01 382.53 L 366.17 383.83 L 365.35 384.11 L 364.51 383.95 L 364.06 384.09 L 363.12 384.83 L 361.48 386.93 L 360.91 388.83 L 361.47 389.44 L 361.46 389.78 L 361.1 390.01 L 360.24 389.55 L 360.24 389.55 L 360 389.1 L 357.34 386.86 L 354.19 386.25 L 352.57 384.7 L 350.67 384.27 L 349.18 384.23 L 345.83 382.89 L 345.15 382.04 L 342.08 380.48 L 341.41 379.87 L 339.97 379.16 L 338.83 378.99 L 336.13 377.31 L 333.35 377.47 L 329.55 376.77 L 329.42 376.44 L 329.68 375.6 L 330.25 374.43 L 331.56 372.67 L 331.48 372.25 L 329.23 371.35 L 328.09 372.02 L 327.43 371.83 L 327.15 371.42 L 326.92 370.31 L 327.18 367.73 L 326.99 365.96 L 326.99 365.96 L 326.04 363.76 L 325.86 360.33 L 324.45 358.14 L 324.29 357.43 L 324.69 354.02 L 327.24 350.17 L 327.62 347.26 L 328.32 346.49 L 330.34 345.65 L 332.26 343.88 L 333.51 341.86 L 333.84 339.91 L 334.34 338.9 L 335.62 337.86 L 336.44 336.43 L 336.52 334.89 L 338.27 333.92 L 339.67 331.3 L 342.32 331.17 L 345.04 330.31 L 345.36 330.03 L 347.34 325.84 L 348.05 324.88 L 348.69 320.78 L 349.07 320.04 L 350.99 318.1 L 352.64 317.09 L 353.71 316.83 L 354.94 317.51 L 356.15 316.78 L 357.54 315.35 L 358.38 312.42 L 359.55 309.55 L 359.54 308.75 L 359.06 307.61 L 359.64 304.87 L 361.24 301.78 L 361.12 296.6 L 362.33 295.82 L 363.36 293.19 L 365.36 290.02 L 365.75 288.95 L 365.59 286.23 L 365.94 285.33 L 366.91 284.47 L 367.18 283.34 L 367.1 282.71 L 367.1 282.71 L 367.44 282.26 L 367.64 280.38 L 368.3 279.15 L 370.11 277.06 L 370.67 276.76 L 370.64 278.47 L 369.42 280.35 L 368.9 282.69 L 371.3 283.09 L 373.5 284.12 L 377.43 284.52 L 380.52 286.23 L 384.59 287.66 L 385.22 287.43 L 386.85 281.49 L 388.32 279.1 L 389.5 278.13 L 390.65 279.44 L 391.69 281.32 L 392.8 285.03 L 393.41 288.13 L 394.55 288.18 L 395.3 287.43 L 395.6 286.43 L 396.16 285.89 L 398.92 286.23 L 403.45 285.7 L 403.67 286.44 L 403.11 288 L 406.24 289.47 L 409.59 290.15 L 410.28 290.07 L 410.79 286.77 L 411.34 286.8 L 412.85 289.42 L 413.31 289.66 L 415.09 288.76 L 417.61 286.68 L 422.14 285.68 L 423.69 285.68 L 426.25 284.58 L 427.99 283.24 L 433.35 281.82 L 433.35 281.82 L 436.07 284.28 L 436.09 284.66 L 434.66 285.72 L 434.18 288.24 L 434.28 288.57 L 435.91 289.41 L 435.85 290.35 L 435.62 290.73 L 434.03 291.76 L 432.84 295.59 L 432.79 297.14 L 433.41 300.66 L 435.11 304.12 L 438.32 306.74 L 438.37 307.21 L 437.65 308.63 L 437.55 309.3 L 438.22 311.02 L 438.45 312.3 L 438.2 313.07 L 436.72 315.04 L 436.72 315.04 L 435.72 316.05 L 432.49 315.71 L 431.59 313.95 L 429.17 312.47 L 428 313.96 L 428.58 317.73 L 428.01 318.27 L 427.61 318.4 L 424.83 317.26 L 423.66 317.49 L 423.29 317.77 L 422.57 320.95 L 423.29 321.05 L 423.78 322.21 L 423.21 323.15 L 422.48 323.85 L 422.52 325.75 L 422.94 326.36 L 423.47 326.55 L 424.16 330.81 L 423.63 331.34 L 420.27 332.24 L 417.98 333.75 z"},{code:"MA",name:"Maranhão",gTransform:"matrix(1 0 0 1 142.22 -148.63)",pathTransform:"translate(-448.22, -170.64)",d:"M 458.57 128.92 L 458.53 129.25 L 456.48999999999995 131.4 L 456.05999999999995 131.57 L 456.0199999999999 133.01 L 457.98999999999995 131.31 L 458.66999999999996 130.1 L 460.78999999999996 128.51999999999998 L 461.67999999999995 127.37999999999998 L 462.7099999999999 121.04999999999998 L 463.8599999999999 120.34999999999998 L 464.9699999999999 120.22999999999998 L 466.63999999999993 119.30999999999997 L 467.2899999999999 119.17999999999998 L 467.7499999999999 119.29999999999998 L 467.82999999999987 120.92999999999998 L 467.6299999999999 121.37999999999998 L 466.20999999999987 123.24999999999999 L 462.9999999999999 124.99999999999999 L 462.9699999999999 125.71999999999998 L 463.69999999999993 125.83999999999999 L 464.1499999999999 125.02999999999999 L 465.2999999999999 124.71999999999998 L 465.5199999999999 125.54999999999998 L 464.92999999999995 126.05999999999999 L 465.17999999999995 126.35999999999999 L 469.38999999999993 121.38999999999999 L 470.24999999999994 121.71999999999998 L 472.8299999999999 120.78999999999998 L 476.86999999999995 121.21999999999998 L 476.40999999999997 118.80999999999999 L 477.02 118.57999999999998 L 479.44 118.65999999999998 L 481.21999999999997 119.03999999999998 L 483.84999999999997 120.08999999999997 L 484.89 120.19999999999997 L 487.03999999999996 121.57999999999997 L 488.43999999999994 121.60999999999997 L 489.69999999999993 122.90999999999997 L 491.5899999999999 124.22999999999996 L 494.0899999999999 124.80999999999996 L 495.24999999999994 124.61999999999996 L 495.80999999999995 125.37999999999997 L 496.1499999999999 125.42999999999996 L 497.7399999999999 125.33999999999996 L 500.1999999999999 125.99999999999996 L 500.45999999999987 125.09999999999995 L 499.78999999999985 124.62999999999995 L 501.45999999999987 124.24999999999996 L 502.02999999999986 124.35999999999996 L 501.9399999999999 124.77999999999996 L 501.9399999999999 124.77999999999996 L 501.4799999999999 126.20999999999997 L 501.7099999999999 126.92999999999996 L 502.3399999999999 127.46999999999997 L 501.9599999999999 128.99999999999997 L 500.1699999999999 131.26999999999998 L 496.0399999999999 135.23999999999998 L 492.7199999999999 135.7 L 491.9199999999999 135.54 L 488.9999999999999 138.94 L 489.0399999999999 140.74 L 488.1599999999999 142.57000000000002 L 486.2699999999999 144.42000000000002 L 485.44999999999993 146.4 L 484.80999999999995 146.57 L 484.03999999999996 147.62 L 484.4 149.54 L 485.63 150.37 L 486.01 151.65 L 485.73 153.11 L 484.59000000000003 155.98000000000002 L 486.17 158.79000000000002 L 486.72 161.77 L 486.61 164.20000000000002 L 486.40000000000003 164.75000000000003 L 482.3 169.17000000000002 L 482.13 171.65 L 482.25 173.76000000000002 L 482.76 176.06000000000003 L 484.53999999999996 178.10000000000002 L 486.15 179.01000000000002 L 486.32 179.51000000000002 L 486.45 180.35000000000002 L 486.06 182.55 L 485.77 182.99 L 485.65 184.20000000000002 L 485.15 185.66000000000003 L 483.94 186.97000000000003 L 481.65 187.26000000000002 L 481 186.98000000000002 L 480.17 187.02 L 477.74 187.88000000000002 L 476.22 187.99000000000004 L 473.72 186.17000000000004 L 472.71000000000004 185.96000000000004 L 471.25000000000006 186.15000000000003 L 470.24000000000007 186.75000000000003 L 469.12000000000006 187.01000000000002 L 468.89000000000004 186.71 L 468.05000000000007 186.95000000000002 L 467.55000000000007 187.17000000000002 L 465.6500000000001 189.08 L 465.6600000000001 189.54000000000002 L 465.0300000000001 190.41000000000003 L 463.0200000000001 192.41000000000003 L 460.6800000000001 193.32000000000002 L 457.8100000000001 195.88000000000002 L 456.48000000000013 196.41000000000003 L 455.4300000000001 196.45000000000002 L 453.73000000000013 197.98000000000002 L 452.65000000000015 198.34000000000003 L 450.04000000000013 198.66000000000003 L 447.3200000000001 199.42000000000002 L 445.1900000000001 201.37 L 444.2100000000001 204.34 L 443.8200000000001 207.31 L 443.1900000000001 209.63 L 441.7400000000001 212.37 L 441.4400000000001 212.59 L 441.10000000000014 213.41 L 440.97000000000014 214.93 L 439.77000000000015 217.41 L 438.07000000000016 218.81 L 437.34000000000015 220.81 L 438.0500000000001 222.75 L 438.52000000000015 225.93 L 440.25000000000017 228.99 L 440.21000000000015 229.51000000000002 L 439.45000000000016 230.91000000000003 L 439.32000000000016 237.27000000000004 L 438.1700000000002 239.72000000000003 L 437.9100000000002 240.78000000000003 L 437.8600000000002 242.70000000000002 L 437.8600000000002 242.70000000000002 L 436.5800000000002 242.04000000000002 L 435.9700000000002 241.22000000000003 L 435.1500000000002 240.77000000000004 L 434.1600000000002 240.48000000000005 L 432.3800000000002 240.68000000000004 L 431.67000000000024 240.50000000000003 L 430.3200000000002 238.50000000000003 L 429.3300000000002 235.64000000000001 L 427.2000000000002 234.02 L 427.06000000000023 232.37 L 428.7000000000002 230.56 L 428.62000000000023 230.03 L 424.74000000000024 228.08 L 424.12000000000023 227.03 L 424.06000000000023 225.37 L 423.31000000000023 223.78 L 422.37000000000023 223.09 L 420.29000000000025 222.81 L 420.09000000000026 222.39000000000001 L 420.35000000000025 221.68 L 422.98000000000025 219.14000000000001 L 422.61000000000024 217.83 L 423.34000000000026 215.15 L 424.03000000000026 213.72 L 424.60000000000025 213.17 L 425.9400000000002 212.63 L 429.3300000000002 212.28 L 428.9400000000002 210.93 L 429.5800000000002 207.68 L 429.5000000000002 205.92000000000002 L 427.7000000000002 204.71 L 423.43000000000023 205.65 L 421.28000000000026 206.99 L 419.0100000000003 203.97 L 418.10000000000025 203.12 L 415.10000000000025 198.97 L 414.22000000000025 199.04 L 413.3800000000003 197.6 L 413.9900000000003 196.41 L 413.8800000000003 195.53 L 413.6300000000003 195.19 L 412.2600000000003 194.95 L 411.84000000000026 195.22 L 409.91000000000025 193.89 L 410.09000000000026 193.17999999999998 L 411.85000000000025 192.51999999999998 L 413.60000000000025 190.48 L 413.85000000000025 188.89 L 413.5700000000003 187.89 L 413.8800000000003 185.52999999999997 L 415.65000000000026 179.36999999999998 L 415.66000000000025 178.93999999999997 L 414.98000000000025 177.79999999999998 L 414.7500000000002 176.71999999999997 L 414.9600000000002 172.99999999999997 L 414.3200000000002 171.49999999999997 L 413.8500000000002 168.00999999999996 L 413.0100000000002 166.97999999999996 L 409.61000000000024 165.53999999999996 L 408.3900000000002 165.51999999999995 L 408.11000000000024 165.19999999999996 L 408.03000000000026 164.16999999999996 L 407.4400000000003 163.47999999999996 L 405.7000000000003 163.18999999999997 L 404.7400000000003 163.70999999999998 L 403.3400000000003 163.61999999999998 L 400.56000000000034 162.10999999999999 L 399.70000000000033 162.04999999999998 L 397.74000000000035 162.57999999999998 L 395.12000000000035 164.42999999999998 L 394.5900000000004 165.06999999999996 L 394.5900000000004 165.06999999999996 L 394.10000000000036 164.98999999999995 L 408.81000000000034 153.15999999999994 L 411.16000000000037 153.38999999999993 L 412.3300000000004 152.46999999999994 L 413.8800000000004 150.29999999999995 L 414.3100000000004 149.14999999999995 L 415.8600000000004 147.97999999999996 L 416.4800000000004 145.09999999999997 L 417.6000000000004 144.63999999999996 L 420.0400000000004 142.31999999999996 L 420.51000000000045 141.10999999999996 L 420.80000000000047 139.20999999999995 L 422.4000000000005 134.51999999999995 L 424.36000000000047 132.97999999999996 L 425.8400000000005 131.21999999999997 L 426.67000000000047 129.76999999999998 L 427.13000000000045 128.48999999999998 L 426.95000000000044 126.66999999999999 L 427.74000000000046 125.85999999999999 L 426.70000000000044 124.27999999999999 L 430.38000000000045 121.18999999999998 L 430.25000000000045 119.54999999999998 L 430.75000000000045 117.16999999999999 L 432.49000000000046 115.6 L 432.8500000000005 114.89 L 433.75000000000045 111.87 L 433.83000000000044 110.26 L 433.40000000000043 109.73 L 432.4100000000004 109.89 L 432.14000000000044 109.4 L 432.19000000000045 108.78 L 433.33000000000044 108.63 L 433.90000000000043 107.89 L 434.6100000000004 103.5 L 434.4500000000004 102.12 L 434.9200000000004 101.09 L 435.6900000000004 100.64 L 435.6900000000004 100.64 L 436.3200000000004 100.64 L 436.5600000000004 100.4 L 436.5000000000004 99.86 L 436.8400000000004 99.11 L 437.42000000000036 98.58 L 438.76000000000033 99.56 L 439.2100000000003 101.4 L 440.4000000000003 101.52000000000001 L 441.1700000000003 100.16000000000001 L 441.7800000000003 103.09000000000002 L 442.7700000000003 103.13000000000002 L 443.06000000000034 102.64000000000003 L 443.13000000000034 101.70000000000003 L 443.98000000000036 101.66000000000003 L 445.67000000000036 102.19000000000003 L 446.17000000000036 102.88000000000002 L 444.74000000000035 104.58000000000003 L 445.41000000000037 105.28000000000003 L 445.43000000000035 105.83000000000003 L 446.6400000000003 103.79000000000002 L 447.13000000000034 102.25000000000001 L 447.5800000000003 102.25000000000001 L 447.9800000000003 103.27000000000001 L 447.9800000000003 103.85000000000001 L 447.1100000000003 104.77000000000001 L 446.8400000000003 105.76 L 446.9200000000003 108.47 L 447.1800000000003 108.8 L 447.6500000000003 108.92 L 448.2300000000003 108.78 L 449.1900000000003 107.85 L 448.72000000000025 106.85 L 448.86000000000024 106.25 L 450.18000000000023 104.82 L 451.23000000000025 104.57 L 453.36000000000024 105.16 L 454.86000000000024 104.05 L 454.91000000000025 104.97 L 454.55000000000024 105.17999999999999 L 453.42000000000024 106.71 L 454.0100000000002 107.28999999999999 L 454.11000000000024 106.91999999999999 L 455.36000000000024 106.32 L 455.9400000000002 107.11 L 455.80000000000024 108.32 L 457.43000000000023 110.07 L 458.29000000000025 109.63 L 459.87000000000023 110.3 L 460.6400000000002 112.7 L 460.5300000000002 113.65 L 458.3400000000002 116.38000000000001 L 457.9600000000002 117.27000000000001 L 458.06000000000023 117.93 L 458.66000000000025 116.9 L 460.41000000000025 115.22 L 461.24000000000024 115.19 L 462.11000000000024 116 L 462.6300000000002 117.89 L 462.36000000000024 119.12 L 461.3900000000002 119.31 L 460.36000000000024 120.22 L 459.2000000000002 121.71 L 459.2700000000002 122.47999999999999 L 458.1100000000002 124.82999999999998 L 457.4900000000002 128.35 L 457.70000000000016 128.69 L 458.57 128.92 z M 459.09 129.37 L 459.03 128.58 L 459.55999999999995 127.05000000000001 L 459.1499999999999 125.98000000000002 L 459.2799999999999 125.32000000000002 L 460.18999999999994 124.08000000000003 L 460.73999999999995 123.89000000000003 L 460.78999999999996 126.24000000000002 L 460.56999999999994 127.58000000000003 L 459.7699999999999 128.18000000000004 L 459.09 129.37 z M 452.79 103.61 L 452.35 103.15 L 452.27000000000004 102.55000000000001 L 453.07000000000005 101.43 L 453.91 101.4 L 454.59000000000003 101.82000000000001 L 454.69000000000005 102.16000000000001 L 454.50000000000006 102.52000000000001 L 452.79 103.61 z M 456.29 107.79 L 456 107.49000000000001 L 456.06 106.96000000000001 L 457.12 106.07000000000001 L 457.6 106.14 L 458.1 106.99 L 457.96000000000004 107.6 L 457.56000000000006 107.42999999999999 L 456.29 107.79 z M 442.13 102.98 L 441.92 102.93 L 442.87 99.35000000000001 L 443.17 99.44000000000001 L 443.2 99.67000000000002 L 442.78999999999996 102.73000000000002 L 442.13 102.98 z"},{code:"MG",name:"Minas Gerais",gTransform:"matrix(1 0 0 1 139.79 56.66)",pathTransform:"translate(-445.79, -375.93)",d:"M 527.5 365.33 L 526.59 364.78 L 524.05 363.97 L 522.47 364.05 L 521.39 364.37 L 520.55 364.98 L 518.37 365.27 L 517.03 365.14 L 518.7 367.41 L 518.68 368.22 L 517.55 368.11 L 516.5 367.37 L 516.19 367.39 L 514.02 368.7 L 512.85 370.63 L 513.15 371.33 L 514.48 372 L 515 372.66 L 514.97 374.58 L 514.67 376.12 L 514.88 376.53 L 516.19 376.88 L 516.36 378.6 L 516.04 379.02 L 515.09 379.26 L 514.12 379.23 L 513.32 378.88 L 511.84 378.97 L 511.41 379.52 L 511.9 380.23 L 512.66 380.51 L 513.11 380.22 L 513.63 380.31 L 514.73 381.58 L 516 384.39 L 516.29 386.82 L 515.75 389.79 L 514.04 391.88 L 512.8 392.74 L 512.54 393.18 L 512.3 394.9 L 511.42 397.19 L 510.31 398.46 L 509.34 401.7 L 508.79 402.02 L 503.64 401.99 L 501.92 404.05 L 501.76 404.47 L 502.35 407.59 L 501.78 408.89 L 501.34 411.23 L 501.63 411.37 L 501.63 411.37 L 499.1 413.72 L 497.86 413.99 L 497.3 414.49 L 498.04 415.19 L 495.68 421.24 L 493.78 424.95 L 493.69 425.7 L 495.13 425.83 L 495.42 426.44 L 495.21 426.96 L 492.68 427.94 L 483.17 432.47 L 481.8 432.67 L 481.82 432.21 L 481.33 432.04 L 478.8 431.77 L 478.23 431.83 L 476.61 432.77 L 475.36 432.93 L 472.16 433.01 L 471.8 432.69 L 471.29 432.77 L 467.19 434.55 L 466.14 435.32 L 464.43 436.09 L 463.93 435.81 L 461.34 435.98 L 458.43 437.32 L 456.01 438.06 L 455.33 438.55 L 455.33 438.55 L 454.08 439.28 L 451.88 439.5 L 449.95 440.52 L 448.72 441.76 L 446.93 442.43 L 444.55 442.68 L 442.21 442.6 L 442.2 442.11 L 442.55 441.62 L 442.46 441.27 L 441.27 441.6 L 441.09 443.9 L 441.33 444.13 L 441.28 444.97 L 440.53 445.95 L 439.23 446.27 L 438.66 445.84 L 435.05 446.84 L 434.86 446.31 L 432.85 446.55 L 431.73 446.3 L 429.7 442.99 L 430.92 442.28 L 430.4 440.57 L 428.6 439.74 L 426.81 438.51 L 426.1 436.9 L 426.63 435.34 L 426.82 431.89 L 426.56 428.95 L 428.42 426.23 L 429.12 424.05 L 429.17 422.78 L 428.94 422.41 L 425.24 421.09 L 424.24 421.14 L 423.96 421.5 L 423.18 421.81 L 421.57 421.86 L 421.6 421.01 L 420.77 419.02 L 419.47 417.23 L 419.1 415.02 L 418.79 414.4 L 418 413.66 L 418.19 411.72 L 419.71 409.69 L 419.77 409.13 L 419.37 407.58 L 417.49 406.37 L 416.91 405.76 L 417.2 403.39 L 417.77 402.38 L 417.57 401.34 L 414.3 397.99 L 413 398.28 L 412.15 398.92 L 410.5 398.14 L 408.12 398.25 L 407.81 398.86 L 408.01 399.32 L 407.57 400.31 L 404.79 400.99 L 403.68 400.56 L 402.17 399.11 L 401.16 400.36 L 392.98 401.04 L 392.52 401.52 L 392.04 402.71 L 392.31 405.25 L 391.9 405.69 L 390.71 405.17 L 390.7 402.39 L 390.45 401.43 L 390.09 401.04 L 389.53 400.99 L 389.27 401.18 L 388.86 402.31 L 388.19 403.25 L 387.65 403.57 L 387.03 403.55 L 385.82 401.45 L 385.49 400.03 L 385.63 399.12 L 383.95 398.33 L 381.77 396.91 L 379.78 397.5 L 378.16 397.28 L 376.49 397.63 L 372.2 396.67 L 369.65 396.59 L 367.92 395.04 L 367.17 394.9 L 365.67 395.51 L 364.24 397.2 L 362.32 397.57 L 360.17 398.68 L 358.95 399.81 L 358.95 399.81 L 359.26 397.19 L 358.67 393.98 L 359.66 389.8 L 360.24 389.55 L 360.24 389.55 L 361.1 390.01 L 361.46 389.78 L 361.47 389.44 L 360.91 388.83 L 361.48 386.93 L 363.12 384.83 L 364.06 384.09 L 364.51 383.95 L 365.35 384.11 L 366.17 383.83 L 367.01 382.53 L 366.95 381.53 L 368.16 379.07 L 369.57 376.97 L 371.8 376.43 L 374.28 375.47 L 377.99 376.09 L 381.18 374.45 L 382.7 374.75 L 384.01 376.17 L 384.34 376.17 L 387.25 373.25 L 391.38 370.61 L 393.39 371.5 L 397.25 371.34 L 398.73 371.62 L 400.48 371.61 L 401.06 371.52 L 401.61 371.04 L 405.96 372.9 L 406.66 373.67 L 411.55 370.93 L 412.03 369.81 L 412.89 368.91 L 414.05 368.71 L 417.14 366.65 L 415.95 363.19 L 416.46 361.3 L 417.19 360.4 L 417.36 359.69 L 417.18 358.69 L 416.71 358.08 L 415.13 357.51 L 414.23 357.98 L 413.14 356.87 L 413.57 354.73 L 416.81 351.72 L 419.13 349.01 L 419.13 348.41 L 417.48 343.85 L 416.06 342.82 L 415.21 342.48 L 414.36 341.27 L 414.77 339.8 L 415.81 338.55 L 416.49 336.96 L 416.18 335.39 L 416.71 333.87 L 417.98 333.75 L 420.27 332.24 L 423.63 331.34 L 424.16 330.81 L 423.47 326.55 L 422.94 326.36 L 422.52 325.75 L 422.48 323.85 L 423.21 323.15 L 423.78 322.21 L 423.29 321.05 L 422.57 320.95 L 423.29 317.77 L 423.66 317.49 L 424.83 317.26 L 427.61 318.4 L 428.01 318.27 L 428.58 317.73 L 428 313.96 L 429.17 312.47 L 431.59 313.95 L 432.49 315.71 L 435.72 316.05 L 436.72 315.04 L 436.72 315.04 L 437.23 317.45 L 435.8 320.89 L 436.2 321.12 L 437.54 320.21 L 438.24 319.21 L 438.96 319.08 L 441.09 319.46 L 442.13 318.69 L 443.98 316.12 L 444.97 316.27 L 446.4 315.74 L 448.21 314.19 L 449.16 313.02 L 451.18 312.61 L 454.55 310.75 L 455.19 309.64 L 459.46 306.61 L 463.28 305.03 L 465.08 305.12 L 466.28 305.62 L 468.46 305.65 L 470.74 306.18 L 471.59 306.64 L 470.3 309.38 L 470.15 310.27 L 470.41 311.76 L 471.02 312.26 L 476.35 313.72 L 476.99 313.55 L 477.8 312.43 L 479.68 311.54 L 481.45 311.28 L 484.18 312.03 L 485.28 312.57 L 489.63 316.21 L 490.61 316.03 L 492.78 317.65 L 495.31 318.87 L 496.24 319.09 L 496.75 318.88 L 498.28 320.12 L 502.67 318.89 L 503.05 319.07 L 509.57 325.27 L 510.01 329.23 L 510.58 329.02 L 513.19 329.47 L 514.66 328.97 L 515.98 327.98 L 517.97 328.13 L 520.7 328.69 L 522.96 329.77 L 525.15 330.38 L 527.27 330.35 L 530.1 332.82 L 530.83 333.2 L 531.72 333.27 L 532.5 334.29 L 532.92 335.46 L 531.45 338.54 L 526.49 342.76 L 526.34 345.41 L 526.9 346.43 L 526.9 346.85 L 525.88 347.56 L 523.4 347.32 L 522.58 348.2 L 521.76 351.5 L 521.23 355.9 L 521.45 356.15 L 521.8 355.96 L 522 355.51 L 522.64 355.27 L 523.22 356.5 L 523 358.01 L 523.15 358.52 L 527.29 361.58 L 527.82 362.62 L 527.83 363.15 L 527.15 364.5 z"},{code:"MS",name:"Mato Grosso do Sul",gTransform:"matrix(1 0 0 1 -2.22 90.13)",pathTransform:"translate(-303.77, -409.4)",d:"M 358.95 399.81 L 358.55 402.27 L 358.27 402.67 L 356.77 403.45 L 355.45 403.49 L 354.98 403.71 L 353.76 404.74 L 351.77 407.42 L 351.04 408.07 L 350.03 408.37 L 349.41 410.05 L 349.25 412.98 L 346.66 416.62 L 345.7 417.14 L 345.47 417.52 L 345.78 419.45 L 345.7 420.4 L 344.49 422.74 L 342.49 425 L 342.84 425.85 L 342.56 427.06 L 341.12 428.09 L 340.72 429.3 L 338.99 430.99 L 337.73 433.43 L 335.78 435.3 L 328.22 439.83 L 326.96 440.97 L 326.22 442.51 L 325.38 443.59 L 325.38 443.59 L 319.97 445.86 L 318.86 446.68 L 317.93 449.01 L 317.95 450.16 L 316.5 453.72 L 315.83 454.4 L 314.17 455.41 L 313.06 455.73 L 312.73 456.08 L 311.16 464 L 310.8 464.82 L 308.42 466.38 L 308.42 466.38 L 305.87 464.05 L 302.46 462.16 L 298.47 464.13 L 297.79 464.88 L 296.13 465.37 L 293.55 465.8 L 291.19 465.34 L 290.18 464.69 L 289.71 460.42 L 289.39 459.72 L 288.49 458.77 L 288.26 456.3 L 288.77 454.96 L 288.13 454.17 L 288.04 453.73 L 288.04 450.86 L 287.15 448.89 L 286.55 446.15 L 286.5 445.43 L 287.09 444.07 L 287.11 442.46 L 285.54 441.37 L 285.16 440.57 L 285 438.41 L 283.35 436.59 L 281.18 436.33 L 279.67 436.64 L 277.84 436.35 L 275.38 434.39 L 274.82 432.9 L 273.28 433.23 L 271.11 435.97 L 270.11 435.37 L 268.39 436.18 L 267.31 436.34 L 265.57 435.65 L 263.01 435.16 L 259.55 435.39 L 255.89 434.68 L 255.41 433.77 L 253.42 433.64 L 252.53 434.16 L 250.03 433.28 L 250.94 426.01 L 250.51 423.63 L 251.11 422.21 L 252.09 420.75 L 252.69 414.72 L 252.03 412.39 L 251.98 410.66 L 251.22 409.7 L 250.79 409.61 L 250.3 410.26 L 249.66 407 L 248.87 405.13 L 247.66 403.11 L 247.31 401.28 L 251.34 398.98 L 252.1 398.1 L 247.9 394.24 L 253.28 382.82 L 254.4 382.76 L 254.12 380.63 L 253.38 380.5 L 256.61 370.17 L 257.27 369.01 L 254.18 363.16 L 254.21 361.25 L 254.21 361.25 L 254.91 361.45 L 255.93 362.55 L 258.08 364.07 L 263.7 362.1 L 265.75 360.1 L 267.77 357.15 L 267.86 355.98 L 269.26 354.53 L 271.85 354.56 L 273.41 354.34 L 274.18 354.68 L 275.84 354.17 L 277.19 352.92 L 279.21 352.43 L 280.48 352.63 L 281.24 353.78 L 284.03 355.03 L 286.65 355.5 L 287.3 355.85 L 287.57 356.71 L 288.35 357.73 L 291.38 358.89 L 292.64 360 L 293.88 360.57 L 298.4 359.94 L 299.66 359.14 L 300.15 358.29 L 301.58 357.68 L 304.02 357.75 L 305.61 358.79 L 305.91 360.16 L 306.15 360.41 L 307.14 360.45 L 309.27 359.57 L 310.28 359.63 L 315.9 353.62 L 317.24 353.49 L 316.01 360.1 L 314.21 360.8 L 312.55 363.63 L 312.36 364.09 L 312.51 364.62 L 313.81 364.73 L 315.55 366 L 320.17 366.27 L 320.74 365.7 L 323.4 365.62 L 324.27 365.7 L 325.44 366.27 L 326.99 365.96 L 326.99 365.96 L 327.18 367.73 L 326.92 370.31 L 327.15 371.42 L 327.43 371.83 L 328.09 372.02 L 329.23 371.35 L 331.48 372.25 L 331.56 372.67 L 330.25 374.43 L 329.68 375.6 L 329.42 376.44 L 329.55 376.77 L 333.35 377.47 L 336.13 377.31 L 338.83 378.99 L 339.97 379.16 L 341.41 379.87 L 342.08 380.48 L 345.15 382.04 L 345.83 382.89 L 349.18 384.23 L 350.67 384.27 L 352.57 384.7 L 354.19 386.25 L 357.34 386.86 L 360 389.1 L 360.24 389.55 L 360.24 389.55 L 359.66 389.8 L 358.67 393.98 L 359.26 397.19 z"},{code:"MT",name:"Mato Grosso",gTransform:"matrix(1 0 0 1 -23.8 -38.15)",pathTransform:"translate(-282.2, -281.12)",d:"M 206.96 296.05 L 208.43 294.62 L 212.54 292.05 L 213.06 289.6 L 214.49 285.82 L 215.42 284.74 L 217.06 284.21 L 217.49 283.8 L 218.07 282.96 L 218.59 280.71 L 220.25 278.7 L 220.81 276.46 L 220.88 274.75 L 220.3 273.26 L 220.34 271.21 L 218.81 267.87 L 217.91 267.9 L 217.33 267.39 L 216.9 264.14 L 217.04 262.82 L 218.4 261.74 L 219.8 259.99 L 219.97 259.24 L 218.56 255.65 L 217.49 255.22 L 216.38 255.11 L 212.88 255.2 L 211.66 254.09 L 211.9 253.53 L 194.74 253.48 L 195.64 244.48 L 194.14 241.73 L 193.87 239.97 L 193.9 239.17 L 194.9 235.65 L 194.52 233.72 L 195.46 232.05 L 194.63 229.78 L 194.48 228.39 L 194.22 227.78 L 193.44 227.31 L 193.38 226.96 L 194.67 221.97 L 195.43 220.55 L 194.83 219.31 L 193.43 218.34 L 193.43 218.34 L 241.28 218.02 L 242.49 217.29 L 243.67 212.07 L 245.05 207.85 L 244.59 205.91 L 243.93 204.54 L 243.83 203.69 L 244.25 202.84 L 245.11 202.2 L 246.31 200.38 L 246.58 199.37 L 246.24 198.53 L 246.3 197.77 L 246.5 197.16 L 247.68 195.96 L 247.68 195.96 L 248.85 197.04 L 251.3 201.1 L 251.7 202.86 L 253.07 206.82 L 254.39 208.75 L 255.16 210.37 L 254.93 212.81 L 255.41 215.21 L 256.14 217.41 L 257.67 218.52 L 260.67 221.27 L 264.05 222.97 L 264.28 223.91 L 264.24 225.01 L 264.47 225.5 L 265.42 225.9 L 266.24 225.73 L 267.87 226.18 L 268.41 226.9 L 268.61 227.98 L 268.96 228.3 L 270.33 227.85 L 274.02 229.34 L 308.06 231.76 L 371.03 235.24 L 371.03 235.24 L 370.38 236.26 L 369.82 238.15 L 368.72 239.4 L 368.28 242.54 L 367.85 243.39 L 367.48 243.66 L 365.54 248.95 L 365 251.92 L 364.96 254.87 L 363.08 260.86 L 363.14 261.72 L 364.53 263.06 L 364.37 263.93 L 363.55 264.82 L 363.5 265.32 L 364.6 267.57 L 364.13 270.88 L 364.14 272.45 L 364.66 273.03 L 365.1 276.08 L 364.36 278.84 L 365.34 282.18 L 366.3 282.69 L 367.1 282.71 L 367.1 282.71 L 367.18 283.34 L 366.91 284.47 L 365.94 285.33 L 365.59 286.23 L 365.75 288.95 L 365.36 290.02 L 363.36 293.19 L 362.33 295.82 L 361.12 296.6 L 361.24 301.78 L 359.64 304.87 L 359.06 307.61 L 359.54 308.75 L 359.55 309.55 L 358.38 312.42 L 357.54 315.35 L 356.15 316.78 L 354.94 317.51 L 353.71 316.83 L 352.64 317.09 L 350.99 318.1 L 349.07 320.04 L 348.69 320.78 L 348.05 324.88 L 347.34 325.84 L 345.36 330.03 L 345.04 330.31 L 342.32 331.17 L 339.67 331.3 L 338.27 333.92 L 336.52 334.89 L 336.44 336.43 L 335.62 337.86 L 334.34 338.9 L 333.84 339.91 L 333.51 341.86 L 332.26 343.88 L 330.34 345.65 L 328.32 346.49 L 327.62 347.26 L 327.24 350.17 L 324.69 354.02 L 324.29 357.43 L 324.45 358.14 L 325.86 360.33 L 326.04 363.76 L 326.99 365.96 L 326.99 365.96 L 325.44 366.27 L 324.27 365.7 L 323.4 365.62 L 320.74 365.7 L 320.17 366.27 L 315.55 366 L 313.81 364.73 L 312.51 364.62 L 312.36 364.09 L 312.55 363.63 L 314.21 360.8 L 316.01 360.1 L 317.24 353.49 L 315.9 353.62 L 310.28 359.63 L 309.27 359.57 L 307.14 360.45 L 306.15 360.41 L 305.91 360.16 L 305.61 358.79 L 304.02 357.75 L 301.58 357.68 L 300.15 358.29 L 299.66 359.14 L 298.4 359.94 L 293.88 360.57 L 292.64 360 L 291.38 358.89 L 288.35 357.73 L 287.57 356.71 L 287.3 355.85 L 286.65 355.5 L 284.03 355.03 L 281.24 353.78 L 280.48 352.63 L 279.21 352.43 L 277.19 352.92 L 275.84 354.17 L 274.18 354.68 L 273.41 354.34 L 271.85 354.56 L 269.26 354.53 L 267.86 355.98 L 267.77 357.15 L 265.75 360.1 L 263.7 362.1 L 258.08 364.07 L 255.93 362.55 L 254.91 361.45 L 254.21 361.25 L 254.21 361.25 L 253.55 360.58 L 253.23 359.78 L 253.77 359.07 L 251.33 356.92 L 250.05 357.55 L 249.53 357.5 L 248.36 356.82 L 247.91 356.12 L 245.89 354.71 L 244 353.95 L 243.7 353.63 L 243.4 352.51 L 243.17 349.58 L 242.56 347.81 L 242.37 344.15 L 243.25 342.51 L 244.39 341.42 L 244.73 339.64 L 244.68 337.75 L 243.72 337.81 L 243.32 338.41 L 242.94 338.57 L 216.08 337.49 L 215.03 324.84 L 209.66 318.71 L 214.54 318.65 L 214.19 311.1 L 211.55 305.78 L 211.06 303.81 L 211.32 302.75 L 211.93 302.2 L 212.58 300.92 L 211.14 297.99 L 208.03 296.95 z"},{code:"PA",name:"Pará",gTransform:"matrix(1 0 0 1 29.16 -180.48)",pathTransform:"translate(-335.15, -138.78)",d:"M 371.03 235.24 L 308.05999999999995 231.76000000000002 L 274.0199999999999 229.34000000000003 L 270.3299999999999 227.85000000000002 L 268.9599999999999 228.3 L 268.6099999999999 227.99 L 268.4099999999999 226.9 L 267.8599999999999 226.18 L 266.2299999999999 225.73000000000002 L 265.4099999999999 225.9 L 264.4599999999999 225.51000000000002 L 264.2299999999999 225.01000000000002 L 264.2699999999999 223.91000000000003 L 264.0399999999999 222.97000000000003 L 260.6599999999999 221.27000000000004 L 257.6599999999999 218.51000000000005 L 256.1199999999999 217.40000000000003 L 255.3999999999999 215.20000000000005 L 254.9199999999999 212.81000000000006 L 255.1499999999999 210.37000000000006 L 254.37999999999988 208.74000000000007 L 253.04999999999987 206.81000000000006 L 251.67999999999986 202.86000000000007 L 251.28999999999988 201.10000000000008 L 248.8399999999999 197.04000000000008 L 247.65999999999988 195.96000000000006 L 247.65999999999988 195.96000000000006 L 247.0899999999999 195.40000000000006 L 246.93999999999988 193.44000000000005 L 246.2999999999999 192.18000000000006 L 244.7099999999999 190.62000000000006 L 243.6399999999999 190.04000000000005 L 243.2699999999999 189.47000000000006 L 242.43999999999988 187.13000000000005 L 242.46999999999989 186.00000000000006 L 243.0499999999999 185.03000000000006 L 244.4999999999999 183.90000000000006 L 245.2799999999999 182.59000000000006 L 275.1799999999999 118.35000000000007 L 273.3699999999999 116.68000000000006 L 273.4999999999999 115.90000000000006 L 273.3099999999999 115.42000000000006 L 271.9199999999999 115.77000000000005 L 271.0699999999999 116.38000000000005 L 269.1999999999999 115.60000000000005 L 268.09999999999985 113.43000000000005 L 265.40999999999985 111.98000000000005 L 264.1399999999999 110.64000000000004 L 264.0599999999999 110.04000000000005 L 262.7399999999999 109.22000000000006 L 261.3699999999999 109.07000000000005 L 259.1199999999999 108.42000000000004 L 256.7399999999999 107.11000000000004 L 254.8599999999999 106.44000000000004 L 253.5099999999999 105.35000000000004 L 252.8799999999999 104.45000000000003 L 248.2999999999999 101.91000000000003 L 243.6599999999999 98.14000000000003 L 243.3599999999999 97.70000000000003 L 243.3199999999999 96.77000000000002 L 242.7699999999999 94.94000000000003 L 240.9299999999999 93.71000000000002 L 240.2299999999999 93.90000000000002 L 239.8699999999999 93.70000000000002 L 238.03999999999988 91.72000000000001 L 238.0899999999999 89.61000000000001 L 238.43999999999988 88.92000000000002 L 238.25999999999988 88.51000000000002 L 236.56999999999988 87.66000000000003 L 236.32999999999987 86.98000000000002 L 236.14999999999986 84.71000000000002 L 236.57999999999987 83.26000000000002 L 236.17999999999986 78.40000000000002 L 236.17999999999986 78.40000000000002 L 234.58999999999986 61.43000000000002 L 234.58999999999986 61.43000000000002 L 235.33999999999986 61.75000000000002 L 235.76999999999987 62.33000000000002 L 235.74999999999986 62.81000000000002 L 236.19999999999985 63.210000000000015 L 237.11999999999983 63.490000000000016 L 238.48999999999984 62.780000000000015 L 238.95999999999984 61.97000000000001 L 241.66999999999985 62.20000000000001 L 242.47999999999985 61.15000000000001 L 241.93999999999986 59.34000000000001 L 243.72999999999985 58.98000000000001 L 245.13999999999984 57.35000000000001 L 247.77999999999983 58.36000000000001 L 249.65999999999983 58.39000000000001 L 250.19999999999982 56.870000000000005 L 253.52999999999983 55.25000000000001 L 255.49999999999983 55.64000000000001 L 256.65999999999985 55.53000000000001 L 257.14999999999986 55.28000000000001 L 258.34999999999985 53.80000000000001 L 258.74999999999983 52.40000000000001 L 260.2099999999998 51.30000000000001 L 261.0699999999998 51.19000000000001 L 261.7199999999998 51.65000000000001 L 263.8299999999998 50.52000000000001 L 264.23999999999984 50.63000000000001 L 264.60999999999984 51.62000000000001 L 265.33999999999986 52.070000000000014 L 267.36999999999983 52.55000000000001 L 268.97999999999985 52.80000000000001 L 269.53999999999985 52.20000000000001 L 271.20999999999987 51.81000000000001 L 271.98999999999984 52.09000000000001 L 272.80999999999983 52.08000000000001 L 273.66999999999985 51.74000000000001 L 275.90999999999985 52.040000000000006 L 280.57999999999987 53.42000000000001 L 281.53999999999985 53.28000000000001 L 282.53999999999985 52.41000000000001 L 282.5099999999999 50.13000000000001 L 280.4399999999999 47.63000000000001 L 279.1999999999999 47.00000000000001 L 279.6899999999999 45.32000000000001 L 280.9999999999999 43.870000000000005 L 281.27999999999986 42.760000000000005 L 281.58999999999986 42.59 L 282.29999999999984 42.78 L 283.1299999999998 43.54 L 285.47999999999985 44.65 L 297.09999999999985 42.32 L 298.66999999999985 44.01 L 299.6899999999998 44.07 L 300.1299999999998 43.78 L 300.1299999999998 43.78 L 300.74999999999983 44.35 L 301.11999999999983 46.65 L 300.49999999999983 47.949999999999996 L 300.24999999999983 52.489999999999995 L 300.48999999999984 53.92999999999999 L 300.79999999999984 54.46999999999999 L 301.96999999999986 54.489999999999995 L 303.04999999999984 54.199999999999996 L 306.4399999999998 54.56999999999999 L 307.72999999999985 55.059999999999995 L 309.65999999999985 56.10999999999999 L 310.32999999999987 56.90999999999999 L 310.8199999999999 58.18999999999999 L 312.0099999999999 58.30999999999999 L 313.14999999999986 59.14999999999999 L 313.9499999999999 60.12999999999999 L 314.78999999999985 60.39999999999999 L 316.11999999999983 60.25999999999999 L 316.49999999999983 59.83999999999999 L 317.4399999999998 59.69999999999999 L 320.2799999999998 62.359999999999985 L 320.9599999999998 62.329999999999984 L 321.4499999999998 63.509999999999984 L 320.7699999999998 63.73999999999998 L 320.5799999999998 64.45999999999998 L 321.3399999999998 67.28999999999998 L 323.3599999999998 69.54999999999998 L 325.9299999999998 70.27999999999999 L 326.0999999999998 70.60999999999999 L 325.6699999999998 73.74999999999999 L 325.8599999999998 75.85999999999999 L 326.5299999999998 77.36999999999999 L 327.1499999999998 77.92999999999999 L 327.7399999999998 79.74 L 327.6099999999998 81.32 L 329.1099999999998 84.8 L 329.9299999999998 84.99 L 330.70999999999975 84.63 L 333.63999999999976 87.91 L 333.5599999999998 90.34 L 333.9699999999998 91.28 L 334.9199999999998 91.47 L 335.2499999999998 91.94 L 335.5599999999998 93.52 L 335.3499999999998 94.21 L 335.4599999999998 95.50999999999999 L 337.3299999999998 96.89999999999999 L 337.7599999999998 98.39999999999999 L 339.2099999999998 99.42999999999999 L 341.99999999999983 100.11 L 343.29999999999984 99.99 L 344.0699999999998 99.64999999999999 L 345.0099999999998 99.71 L 345.0099999999998 99.71 L 344.47999999999985 100.44999999999999 L 344.76999999999987 102.03999999999999 L 344.59999999999985 102.57 L 343.30999999999983 103.67999999999999 L 341.91999999999985 103.85 L 341.41999999999985 103.66999999999999 L 340.57999999999987 102.87999999999998 L 339.91999999999985 102.72999999999998 L 336.53999999999985 104.30999999999997 L 336.16999999999985 104.84999999999998 L 334.5699999999998 105.56999999999998 L 333.9399999999998 105.54999999999998 L 332.3899999999998 106.13999999999999 L 332.42999999999984 106.71999999999998 L 338.8899999999998 105.65999999999998 L 339.7699999999998 106.31999999999998 L 339.8999999999998 106.77999999999997 L 339.8999999999998 107.43999999999997 L 339.2799999999998 107.93999999999997 L 339.5799999999998 108.29999999999997 L 340.2099999999998 108.09999999999997 L 341.0699999999998 107.09999999999997 L 342.0899999999998 107.08999999999996 L 342.6199999999998 106.81999999999996 L 343.2199999999998 106.93999999999997 L 344.2899999999998 106.51999999999997 L 345.4299999999998 105.94999999999997 L 348.70999999999975 103.60999999999997 L 350.20999999999975 103.25999999999998 L 352.0499999999997 102.44999999999997 L 355.20999999999975 100.60999999999997 L 355.7499999999998 99.60999999999997 L 356.4199999999998 99.08999999999997 L 358.50999999999976 98.07999999999997 L 359.1699999999998 97.35999999999997 L 358.9199999999998 96.68999999999997 L 359.12999999999977 96.27999999999997 L 360.25999999999976 95.99999999999997 L 361.34999999999974 96.05999999999997 L 361.75999999999976 96.26999999999997 L 362.13999999999976 100.06999999999996 L 361.6199999999998 102.64999999999996 L 361.94999999999976 104.26999999999997 L 362.75999999999976 105.86999999999996 L 364.06999999999977 107.21999999999996 L 364.3699999999998 108.85999999999996 L 364.2499999999998 109.32999999999996 L 362.4099999999998 111.16999999999996 L 361.93999999999977 111.29999999999995 L 361.06999999999977 110.77999999999996 L 359.2499999999998 110.25999999999996 L 357.9899999999998 109.94999999999996 L 357.0599999999998 110.08999999999996 L 354.9299999999998 109.04999999999995 L 354.6699999999998 107.92999999999995 L 353.7899999999998 107.39999999999995 L 351.5099999999998 111.21999999999994 L 350.8999999999998 113.58999999999995 L 351.5799999999998 116.55999999999995 L 352.05999999999983 117.19999999999995 L 352.97999999999985 117.81999999999995 L 351.96999999999986 116.67999999999995 L 351.53999999999985 113.98999999999995 L 351.65999999999985 113.46999999999996 L 354.22999999999985 109.24999999999996 L 356.53999999999985 110.42999999999996 L 356.64999999999986 110.87999999999997 L 359.17999999999984 113.32999999999997 L 358.92999999999984 115.34999999999997 L 358.1899999999998 115.89999999999996 L 358.5899999999998 118.22999999999996 L 359.1099999999998 119.35999999999996 L 360.2299999999998 120.10999999999996 L 360.9699999999998 120.25999999999996 L 361.4899999999998 120.74999999999996 L 361.1499999999998 120.10999999999996 L 360.3799999999998 119.86999999999996 L 359.17999999999984 118.82999999999996 L 358.9599999999998 118.14999999999995 L 359.2999999999998 113.94999999999995 L 360.1199999999998 112.75999999999995 L 361.5499999999998 113.48999999999995 L 362.37999999999977 114.68999999999996 L 362.2899999999998 115.47999999999996 L 363.4899999999998 116.33999999999996 L 363.7399999999998 116.04999999999995 L 362.7399999999998 114.78999999999995 L 361.81999999999977 112.68999999999996 L 361.81999999999977 112.24999999999996 L 364.07999999999976 109.92999999999996 L 365.69999999999976 110.01999999999997 L 367.62999999999977 110.65999999999997 L 367.96999999999974 111.21999999999997 L 367.35999999999973 111.80999999999997 L 367.6799999999997 112.08999999999997 L 368.15999999999974 112.11999999999998 L 369.1899999999997 111.94999999999997 L 370.5199999999997 111.04999999999997 L 374.6099999999997 110.08999999999997 L 375.37999999999965 110.28999999999998 L 377.11999999999966 111.34999999999998 L 380.2899999999997 110.92999999999998 L 381.3599999999997 110.51999999999998 L 382.37999999999965 109.50999999999998 L 383.3599999999997 108.91999999999997 L 385.0999999999997 108.40999999999997 L 385.86999999999966 108.47999999999996 L 385.92999999999967 109.22999999999996 L 383.88999999999965 113.24999999999996 L 383.64999999999964 114.74999999999996 L 383.18999999999966 115.81999999999995 L 382.3599999999997 116.84999999999995 L 382.3499999999997 117.72999999999995 L 382.92999999999967 119.14999999999995 L 382.6099999999997 121.61999999999995 L 383.48999999999967 120.42999999999995 L 383.49999999999966 119.02999999999994 L 385.0399999999997 116.02999999999994 L 386.1699999999997 112.83999999999995 L 387.2899999999997 111.27999999999994 L 387.55999999999966 111.00999999999995 L 388.31999999999965 110.95999999999995 L 388.89999999999964 110.60999999999996 L 390.71999999999963 110.37999999999995 L 391.5999999999996 109.02999999999996 L 393.1099999999996 107.33999999999996 L 394.46999999999963 105.07999999999996 L 394.9899999999996 104.61999999999996 L 395.77999999999963 105.10999999999996 L 396.39999999999964 104.64999999999996 L 398.01999999999964 106.98999999999997 L 399.20999999999964 107.57999999999997 L 399.1599999999996 106.83999999999997 L 398.8099999999996 106.08999999999997 L 399.4299999999996 105.07999999999997 L 402.9399999999996 104.56999999999996 L 401.9099999999996 104.24999999999997 L 398.39999999999964 104.70999999999997 L 398.08999999999963 104.49999999999997 L 398.37999999999965 102.06999999999996 L 398.88999999999965 101.77999999999996 L 399.55999999999966 102.15999999999995 L 400.57999999999964 102.26999999999995 L 401.64999999999964 99.16999999999996 L 400.96999999999963 97.77999999999996 L 400.9999999999996 97.09999999999995 L 402.1699999999996 95.28999999999995 L 405.0099999999996 92.80999999999995 L 405.3699999999996 92.72999999999995 L 406.4799999999996 93.86999999999995 L 409.4099999999996 91.77999999999994 L 409.8699999999996 91.70999999999995 L 410.2699999999996 92.15999999999995 L 410.3699999999996 92.72999999999995 L 410.0499999999996 93.39999999999995 L 411.1199999999996 93.23999999999995 L 411.9299999999996 92.65999999999995 L 412.2899999999996 91.87999999999995 L 412.9199999999996 91.68999999999996 L 413.1999999999996 91.83999999999996 L 413.9399999999996 93.22999999999996 L 415.2699999999996 94.42999999999996 L 415.4699999999996 93.86999999999996 L 415.35999999999956 93.48999999999997 L 414.4 93 L 414.26 92.71 L 414.13 91.50999999999999 L 414.3 91.08999999999999 L 414.74 90.89999999999999 L 417.02 91.16 L 418.2 91.81 L 418.82 92.83 L 420.45 93.53999999999999 L 422.09999999999997 92.75999999999999 L 422.62999999999994 94.89999999999999 L 422.12999999999994 95.21 L 422.09999999999997 95.8 L 423.02 95.28 L 424.18 92.93 L 424.56 93.16000000000001 L 424.33 94.49000000000001 L 424.74 94.93 L 427.25 94.67 L 427.7 95.32000000000001 L 428.15999999999997 97.00000000000001 L 427.55999999999995 97.95000000000002 L 428.40999999999997 97.45000000000002 L 428.66999999999996 97.82000000000002 L 430.55999999999995 97.96000000000002 L 434.0899999999999 96.72000000000003 L 433.7799999999999 98.30000000000003 L 433.0299999999999 100.13000000000002 L 434.49999999999994 99.64000000000003 L 435.0899999999999 99.02000000000002 L 435.7199999999999 100.64000000000003 L 435.7199999999999 100.64000000000003 L 434.94999999999993 101.09000000000003 L 434.4799999999999 102.12000000000003 L 434.63999999999993 103.50000000000003 L 433.92999999999995 107.89000000000003 L 433.35999999999996 108.63000000000002 L 432.21999999999997 108.78000000000003 L 432.16999999999996 109.40000000000003 L 432.43999999999994 109.89000000000003 L 433.42999999999995 109.73000000000003 L 433.85999999999996 110.26000000000003 L 433.78 111.87000000000003 L 432.88 114.89000000000003 L 432.52 115.60000000000002 L 430.78 117.17000000000002 L 430.28 119.55000000000001 L 430.40999999999997 121.19000000000001 L 426.72999999999996 124.28000000000002 L 427.77 125.86000000000001 L 426.97999999999996 126.67000000000002 L 427.15999999999997 128.49 L 426.7 129.77 L 425.87 131.22 L 424.39 132.98 L 422.43 134.51999999999998 L 420.83 139.20999999999998 L 420.53999999999996 141.10999999999999 L 420.06999999999994 142.32 L 417.62999999999994 144.64 L 416.50999999999993 145.1 L 415.88999999999993 147.98 L 414.3399999999999 149.14999999999998 L 413.9099999999999 150.29999999999998 L 412.3599999999999 152.46999999999997 L 411.1899999999999 153.38999999999996 L 408.83999999999986 153.15999999999997 L 394.1299999999999 164.98999999999998 L 394.6199999999999 165.07 L 394.6199999999999 165.07 L 396.9099999999999 165.88 L 398.7799999999999 165.64 L 400.06999999999994 165.76 L 401.0899999999999 167.42 L 401.4799999999999 167.73 L 402.3499999999999 167.86999999999998 L 403.6099999999999 169.03999999999996 L 403.5699999999999 169.66999999999996 L 403.1999999999999 170.33999999999995 L 402.47999999999985 170.70999999999995 L 401.5099999999998 170.77999999999994 L 401.2199999999998 171.05999999999995 L 401.3099999999998 172.46999999999994 L 402.31999999999977 173.80999999999995 L 401.39999999999975 176.55999999999995 L 400.75999999999976 177.03999999999994 L 399.2999999999998 177.49999999999994 L 399.0499999999998 177.95999999999995 L 399.3399999999998 179.15999999999994 L 399.1499999999998 180.49999999999994 L 397.8499999999998 180.64999999999995 L 396.3399999999998 181.98999999999995 L 395.4899999999998 183.25999999999996 L 395.63999999999976 184.76999999999995 L 395.39999999999975 185.26999999999995 L 392.89999999999975 186.46999999999994 L 389.4899999999997 187.60999999999993 L 387.0199999999997 189.38999999999993 L 386.8299999999997 189.73999999999992 L 387.2599999999997 191.92999999999992 L 387.3199999999997 194.5999999999999 L 386.03999999999974 196.6999999999999 L 384.6299999999997 198.3799999999999 L 384.47999999999973 198.9499999999999 L 384.64999999999975 199.8299999999999 L 385.2399999999997 200.7899999999999 L 386.90999999999974 202.52999999999992 L 387.65999999999974 202.8499999999999 L 387.8099999999997 203.14999999999992 L 387.1499999999997 207.1899999999999 L 385.3899999999997 212.33999999999992 L 384.3099999999997 213.14999999999992 L 382.60999999999973 216.38999999999993 L 382.4299999999997 217.37999999999994 L 381.4899999999997 218.91999999999993 L 380.7499999999997 219.76999999999992 L 379.6999999999997 219.92999999999992 L 378.3299999999997 220.8499999999999 L 377.2999999999997 222.7699999999999 L 376.08999999999975 224.4499999999999 L 374.90999999999974 225.5399999999999 L 373.75999999999976 227.11999999999992 L 372.62999999999977 231.57999999999993 L 371.03 235.24 z M 392.19 104.93 L 387.67 106.89 L 384.28000000000003 107.41 L 382.26000000000005 107.1 L 381.61000000000007 108.22999999999999 L 379.7700000000001 109.41999999999999 L 379.05000000000007 108.80999999999999 L 378.44000000000005 107.27999999999999 L 378.21000000000004 107.55999999999999 L 378.63000000000005 108.78999999999999 L 378.2900000000001 109.6 L 377.5800000000001 110.00999999999999 L 373.8100000000001 108.36999999999999 L 373.0100000000001 109.08999999999999 L 368.8200000000001 110.35 L 365.6200000000001 109.78 L 364.8100000000001 109.17 L 364.5700000000001 107.32000000000001 L 364.3400000000001 106.91000000000001 L 363.2300000000001 105.89000000000001 L 362.1700000000001 104.29000000000002 L 361.9600000000001 102.51000000000002 L 362.4800000000001 99.76000000000002 L 363.1000000000001 99.38000000000002 L 364.86000000000007 99.74000000000002 L 365.7900000000001 98.99000000000002 L 365.87000000000006 98.43000000000002 L 364.57000000000005 98.86000000000003 L 363.35 98.73000000000003 L 362.41 98.02000000000004 L 362.23 96.97000000000004 L 362.57 91.89000000000004 L 363.3 91.13000000000004 L 363.65000000000003 91.88000000000004 L 365.41 92.48000000000003 L 365.96000000000004 92.42000000000003 L 365.50000000000006 92.00000000000003 L 364.2300000000001 91.78000000000003 L 363.3300000000001 89.62000000000003 L 363.6900000000001 87.94000000000003 L 364.5800000000001 85.97000000000003 L 365.9100000000001 84.64000000000003 L 366.87000000000006 84.07000000000004 L 368.21000000000004 83.58000000000004 L 369.53000000000003 83.45000000000005 L 372.99 83.97000000000004 L 380.2 85.74000000000004 L 383.9 85.28000000000004 L 384.01 84.98000000000005 L 385.15 84.36000000000004 L 387.31 83.99000000000004 L 390.2 84.28000000000004 L 393 85.10000000000004 L 399.48 85.95000000000003 L 400.11 86.42000000000003 L 400.06 87.65000000000003 L 399.36 88.39000000000003 L 398.68 89.89000000000003 L 398.32 92.54000000000003 L 397.46 95.84000000000003 L 396.16999999999996 96.52000000000004 L 395.81999999999994 97.21000000000004 L 396.04999999999995 98.40000000000003 L 394.06999999999994 100.98000000000003 L 392.67999999999995 104.48000000000003 L 392.19 104.93 z M 344.98 104.76 L 344.23 104.25 L 345.33000000000004 102 L 345.24000000000007 100.21 L 345.49000000000007 100 L 347.82000000000005 99.52 L 348.72 98.66 L 348.87 98.16 L 348.67 95.82 L 349.53000000000003 93.24 L 350.79 91.75 L 353.08000000000004 90.28 L 355.95000000000005 90.08 L 356.6700000000001 92.44 L 355.57000000000005 94.63 L 354.72 97.67 L 353.62 98.34 L 352.28000000000003 100.37 L 351.50000000000006 101.09 L 346.56000000000006 104.4 L 344.98 104.76 z M 373.46 81.86 L 372.43 81.61 L 369.98 81.69 L 369.19 81.53 L 368.9 81.27 L 368.52 80.17999999999999 L 368.53 78.94 L 370.03999999999996 78.52 L 371.92999999999995 78.56 L 374.11999999999995 77.27 L 378.92999999999995 76.67 L 379.69999999999993 76.93 L 380.37999999999994 77.61000000000001 L 380.19999999999993 78.63000000000001 L 377.63999999999993 80.02000000000001 L 375.85999999999996 82.50000000000001 L 374.76 83 L 373.46 81.86 z M 378.25 81.86 L 380.11 80.66 L 382.09000000000003 80.69 L 383.74 81.31 L 384.27 82.3 L 384.32 82.92 L 383.44 83.69 L 380.59 83.97 L 379.41999999999996 84.28999999999999 L 377.15999999999997 83.39999999999999 L 376.96 82.86999999999999 L 378.25 81.86 z M 361.27 86.25 L 360.77 85.99 L 360.15999999999997 86.03 L 358.61999999999995 85.34 L 358.8299999999999 84.18 L 359.4699999999999 83.26 L 361.38999999999993 82.86 L 363.74999999999994 81.96 L 365.06999999999994 82.03999999999999 L 365.86999999999995 82.72 L 365.9599999999999 82.85 L 364.0299999999999 84.46 L 362.9599999999999 84.8 L 361.27 86.25 z M 370.69 76.56 L 369.87 76.26 L 369.7 74.60000000000001 L 369.84999999999997 74.00000000000001 L 371.02 72.69000000000001 L 373.46999999999997 71.77000000000001 L 373.71999999999997 71.89000000000001 L 374.24999999999994 72.57000000000002 L 374.28999999999996 73.46000000000002 L 372.34 75.45000000000002 L 370.69 76.56 z M 356.86 96.78 L 356.72 96.37 L 356.91 95.44 L 357.95000000000005 92.63 L 360.54 90.94 L 361.26000000000005 90.66 L 361.95000000000005 90.8 L 361.79 92.59 L 360.23 93.03 L 358.61 95.22 L 356.86 96.78 z M 367.77 79.21 L 366.58 78.89999999999999 L 366.28 78.41999999999999 L 367.15999999999997 77.46 L 367.86999999999995 73.50999999999999 L 368.75999999999993 72.27999999999999 L 369.04999999999995 72.40999999999998 L 369.11999999999995 72.72999999999998 L 369.09999999999997 75.20999999999998 L 369.7 77.07999999999998 L 369.38 77.95999999999998 L 368.35 78.35999999999999 L 367.77 79.21 z M 352.96 89.4 L 352.69 89.21000000000001 L 352.81 88.60000000000001 L 353.36 88.24000000000001 L 354.55 86.53000000000002 L 355.31 84.99000000000001 L 356.04 84.33000000000001 L 357.49 83.79 L 357.29 85.28 L 356.89000000000004 86.28 L 355.17 87.94 L 352.96 89.4 z M 366.83 82.37 L 366.22999999999996 82.22 L 365.39 81.51 L 364.43 79.87 L 364.38 79.49000000000001 L 364.61 79.2 L 365.42 78.62 L 367.27000000000004 79.46000000000001 L 367.56000000000006 79.89000000000001 L 367.80000000000007 81.98000000000002 L 366.83 82.37 z M 361.45 112.93 L 360.8 112.82000000000001 L 359.92 112.30000000000001 L 359.23 112.76 L 358.48 112.48 L 356.8 110.74000000000001 L 356.8 110.13000000000001 L 358.08 110.12 L 361.14 111.44 L 361.45 112.93 z M 340.3 107.39 L 340.34000000000003 106.36 L 340.14000000000004 106.06 L 340.74000000000007 105.07000000000001 L 343.1000000000001 104.19000000000001 L 343.88000000000005 104.57000000000001 L 344.75000000000006 105.43 L 344.46000000000004 105.78 L 343.43000000000006 106.25 L 340.89000000000004 106.66 L 340.3 107.39 z M 353 100.7 L 352.82 100.67 L 352.83 100.32000000000001 L 353.37 99.38000000000001 L 355.16 97.76 L 355.58000000000004 96.52000000000001 L 355.63000000000005 95.22000000000001 L 355.87000000000006 94.92000000000002 L 356.19000000000005 95.36000000000001 L 356.19000000000005 96.87000000000002 L 355.30000000000007 99.60000000000002 L 354.68000000000006 100.25000000000003 L 353 100.7 z M 359.3 90.8 L 360.95 87.84 L 361.83 87.63000000000001 L 362.53999999999996 87.82000000000001 L 362.80999999999995 88.69000000000001 L 362.22999999999996 89.4 L 359.3 90.8 z M 390.72 109.77 L 389.88000000000005 109.42 L 389.5400000000001 108.36 L 390.5800000000001 106.64 L 391.6500000000001 106.31 L 391.8400000000001 106.41 L 391.8200000000001 107.14999999999999 L 391.0800000000001 109.38999999999999 L 390.72 109.77 z M 357.24 90.3 L 356.7 90.1 L 357.02 88.05999999999999 L 358.34999999999997 86.24999999999999 L 358.58 86.28999999999999 L 359.87 87.16999999999999 L 359.86 87.41999999999999 L 358.31 88.05999999999999 L 357.24 90.3 z M 359.47 95.33 L 360.19000000000005 95.36 L 359.7900000000001 95.81 L 358.8500000000001 96.12 L 358.74000000000007 97.24000000000001 L 357.95000000000005 97.95 L 356.26000000000005 98.79 L 356.1 98.61 L 356.37 97.78 L 356.84000000000003 97.15 L 358.57000000000005 95.48 L 359.47 95.33 z M 336.91 105.54 L 336.36 105.35000000000001 L 336.29 105.00000000000001 L 336.72 104.60000000000001 L 340.28000000000003 103.00000000000001 L 340.82000000000005 103.70000000000002 L 340.81000000000006 103.90000000000002 L 339.4100000000001 104.63000000000002 L 336.91 105.54 z M 400.44 100.76 L 399.41 100.57000000000001 L 398.59000000000003 99.78 L 399.46000000000004 98.53 L 400.8 98.52 L 400.99 99.71 L 400.89 100.3 L 400.44 100.76 z M 363.19 81.86 L 360.83 82.56 L 360.24 82.57000000000001 L 360.06 82.36000000000001 L 361.09 81.32000000000001 L 362.13 80.81 L 363.17 80.98 L 363.61 81.32000000000001 L 363.76 81.55000000000001 L 363.61 81.76 L 363.19 81.86 z M 357.92 90.45 L 357.84000000000003 89.69 L 358.09000000000003 89.19 L 360.57000000000005 87.73 L 359.6700000000001 89.73 L 358.86000000000007 90.36 L 357.92 90.45 z M 360.06 94.98 L 359.61 94.86 L 359.54 94.63 L 360.32 93.13 L 361.51 93.14999999999999 L 361.39 94.49999999999999 L 360.06 94.98 z M 388.1 110.81 L 387.82000000000005 110.58 L 388.72 108.98 L 389.40000000000003 108.58 L 389.63000000000005 109.33 L 390.14000000000004 109.7 L 389.88000000000005 110.22 L 389.45000000000005 110.56 L 388.82000000000005 110.38 L 388.1 110.81 z M 361.44 87.49 L 360.55 87.42 L 360.57 87.23 L 362.93 85.39 L 362.97 86.35 L 362.74 86.97999999999999 L 362.49 87.32 L 361.44 87.49 z M 428.9 97.71 L 428.52 97.17999999999999 L 428.71 96.41999999999999 L 429.72999999999996 95.50999999999999 L 429.97999999999996 95.66 L 430.21 97.41 L 428.9 97.71 z"},{code:"PB",name:"Paraíba",gTransform:"matrix(1 0 0 1 275.13 -126.21)",pathTransform:"translate(-581.13, -193.05)",d:"M 610.43 199.15 L 607.93 197.09 L 607.11 196.83 L 604.46 196.62 L 602.15 197.69 L 600.67 198.97 L 600.22 200.77 L 598.32 201.8 L 596.31 202.25 L 595.17 202.23 L 595.17 202.83 L 594.37 203.36 L 592.19 203.65 L 588.31 203.39 L 586.7 204.27 L 586.15 204.91 L 584.33 205.01 L 583.44 205.7 L 582.9 206.46 L 583.29 207.19 L 583.3 207.73 L 582.9 208.21 L 581.12 209.74 L 579.78 209.9 L 578.13 210.74 L 576.53 209.95 L 575.58 209.01 L 575.23 206.77 L 575.47 206.28 L 575.29 205.98 L 574.15 205.66 L 573.71 205.95 L 572.2 206.2 L 572.24 205.75 L 574.77 203.11 L 574.94 202.68 L 574.22 200.81 L 574.18 200.34 L 574.55 199.56 L 577.55 198.49 L 577.66 198.19 L 577.16 196.8 L 573.66 194.88 L 572.18 195.29 L 569.96 196.55 L 569.03 198.06 L 567.55 198.93 L 566.5 199.24 L 563.8 201.12 L 562.28 202.76 L 560.65 202.99 L 558.02 203.96 L 557.25 203.63 L 557.3 202.95 L 556.67 201.71 L 556.29 201.63 L 555.36 202.36 L 553.85 202.68 L 552.86 202.35 L 551.46 200.44 L 551.06 200.35 L 551.06 200.35 L 550.89 200.1 L 552.08 198.98 L 553.69 195.49 L 553.35 194.3 L 552.66 194.22 L 551.42 193.33 L 551.44 191.67 L 551.09 190.95 L 550.51 190.66 L 550.27 190.25 L 550.39 189.32 L 550.56 188.94 L 551.65 188.31 L 552.31 187 L 551.79 185.69 L 552.82 182.69 L 553.66 181.54 L 553.74 181 L 553.74 181 L 554.31 180.54 L 556.24 182.18 L 557.14 182.6 L 560.02 183.21 L 561.18 182.08 L 564.41 180.42 L 565.23 179.71 L 565.33 178.67 L 565.74 177.72 L 568.92 176.51 L 570.35 176.39 L 573.61 175.35 L 574.25 175.43 L 574.78 175.87 L 574.79 177.06 L 571.8 180.27 L 571.36 181.23 L 570.98 182.97 L 570.57 183.35 L 569.72 183.6 L 569.51 183.91 L 569.43 185.63 L 572.96 186.15 L 573.28 186.38 L 573.59 187.76 L 573.88 187.99 L 577.03 186.73 L 578.8 186.65 L 580.75 186.95 L 581.64 188.12 L 581.12 189.66 L 581.95 190.4 L 584.3 189.47 L 584.8 188.73 L 585.35 187.52 L 584.88 186.58 L 584.72 185.16 L 585.2 184.57 L 586.21 184.89 L 585.68 183.36 L 584.96 182.58 L 585.27 181.1 L 587.09 179.75 L 588.47 179.7 L 588.89 180.09 L 588.79 181.09 L 589.41 181.58 L 592.83 181.98 L 593.36 182.33 L 599.19 181.94 L 601.36 182.24 L 603.82 183.34 L 604.86 182.94 L 608.36 183.15 L 609.29 182.91 L 609.29 182.91 L 609.38 185.31 L 610.83 189.7 L 610.89 190.34 L 610.71 191.28 L 610.34 191.73 L 610.31 192.61 L 610.89 191.87 L 611.4 190.37 L 611.41 192.35 L 612 193.36 L 611.73 198.54 L 611.37 199.14 z"},{code:"PE",name:"Pernambuco",gTransform:"matrix(1 0 0 1 254.6 -106.99)",pathTransform:"translate(-560.6, -212.26)",d:"M 558.28 227.19 L 557.06 224.15 L 557.05 223.21 L 554.94 222.35 L 554.44 221.98 L 553.99 221.15 L 554.6 220.26 L 554.58 219.64 L 554.13 219.32 L 553.13 219.33 L 552.7 219.77 L 552.41 221.51 L 551.98 221.66 L 551.59 221.4 L 551.05 219.75 L 549.47 218.6 L 546.48 218.2 L 544.12 217.43 L 542.77 216.62 L 541.94 215.18 L 540.45 214.62 L 539.86 214.73 L 537.33 216.19 L 535.68 216.63 L 534.91 218.68 L 532.68 219.13 L 532.39 219.38 L 532.64 220.74 L 532.47 221.33 L 531.37 222.57 L 528.98 223.6 L 528.34 223.54 L 527.57 223.01 L 526.81 223.18 L 526.31 224.05 L 525.54 227.62 L 522.67 228.5 L 521.85 229.42 L 520.89 229.65 L 519.05 229.03 L 519.97 227.35 L 519.71 225.35 L 517.5 224.44 L 516.78 222.5 L 516.84 219.77 L 516.4 219.26 L 513.59 217.88 L 511.39 217.59 L 510.23 217.85 L 509.33 217.45 L 509.33 217.45 L 511.95 216.18 L 513.92 214.47 L 514.46 213.6 L 516.75 212.27 L 517.72 211.99 L 521.61 208.12 L 522.35 206.36 L 522.41 204.09 L 522.12 203.55 L 520.5 201.97 L 520.57 199.78 L 519.97 198.65 L 519.91 197.7 L 520.02 197.25 L 520.54 196.92 L 522.33 196.76 L 522.33 196.76 L 527.26 196.96 L 528.15 197.2 L 529.78 197.01 L 531.92 196.21 L 533.21 196.11 L 536.29 196.53 L 539.14 198.43 L 540.97 199.26 L 541.43 200.25 L 542.44 201.32 L 543.8 201.8 L 544.58 202.37 L 545.21 204.01 L 546.86 203.96 L 548.4 201.67 L 549.47 200.84 L 551.06 200.35 L 551.06 200.35 L 551.46 200.44 L 552.86 202.35 L 553.85 202.68 L 555.36 202.36 L 556.29 201.63 L 556.67 201.71 L 557.3 202.95 L 557.25 203.63 L 558.02 203.96 L 560.65 202.99 L 562.28 202.76 L 563.8 201.12 L 566.5 199.24 L 567.55 198.93 L 569.03 198.06 L 569.96 196.55 L 572.18 195.29 L 573.66 194.88 L 577.16 196.8 L 577.66 198.19 L 577.55 198.49 L 574.55 199.56 L 574.18 200.34 L 574.22 200.81 L 574.94 202.68 L 574.77 203.11 L 572.24 205.75 L 572.2 206.2 L 573.71 205.95 L 574.15 205.66 L 575.29 205.98 L 575.47 206.28 L 575.23 206.77 L 575.58 209.01 L 576.53 209.95 L 578.13 210.74 L 579.78 209.9 L 581.12 209.74 L 582.9 208.21 L 583.3 207.73 L 583.29 207.19 L 582.9 206.46 L 583.44 205.7 L 584.33 205.01 L 586.15 204.91 L 586.7 204.27 L 588.31 203.39 L 592.19 203.65 L 594.37 203.36 L 595.17 202.83 L 595.17 202.23 L 596.31 202.25 L 598.32 201.8 L 600.22 200.77 L 600.67 198.97 L 602.15 197.69 L 604.46 196.62 L 607.11 196.83 L 607.93 197.09 L 610.43 199.15 L 610.43 199.15 L 611.31 199.38 L 611.86 200.6 L 610.59 202.32 L 610.48 202.87 L 610.49 203.35 L 611.19 203.72 L 611.46 204.22 L 611.65 205.28 L 609.69 211.66 L 606.44 220.61 L 606.44 220.61 L 606.17 220.4 L 603.27 220.13 L 601.35 219.32 L 599.88 219.51 L 597.32 220.8 L 595.08 219.95 L 593.08 220.19 L 591.53 221.43 L 591.41 221.88 L 589.23 224.17 L 587.42 225.28 L 586.26 225.23 L 584.4 226.29 L 583.23 226.4 L 580.09 226.11 L 577.59 226.76 L 575.68 226.28 L 573.9 225.23 L 572 223.11 L 569.45 221.09 L 568.37 221.21 L 566.7 220.91 L 565.7 219.69 L 564.88 220.29 L 564.79 220.98 L 562.41 224.27 L 560.24 225.03 L 559.6 226.12 z"},{code:"PI",name:"Piauí",gTransform:"matrix(1 0 0 1 174.84 -130.97)",pathTransform:"translate(-480.85, -188.29)",d:"M 505.7 126.91 L 507.01 127.03 L 507.7 126.8 L 509.94 127.31 L 510.93 128.16 L 511.25 128.76 L 511.25 128.76 L 511.14 129.56 L 510.05 131.41 L 508.47 133.38 L 508.29 134.84 L 508.58 136.13 L 510.38 140.85 L 513.53 147.27 L 513.97 149 L 515.33 150.59 L 515.31 151.35 L 514.57 152.71 L 515.36 156.58 L 514.88 158.18 L 515.88 160.19 L 516.48 163.18 L 515.89 164.76 L 515.09 165.34 L 516.01 166.03 L 516.12 166.41 L 517.06 174.57 L 516.82 175.02 L 517.58 177.59 L 518.63 182.79 L 519.64 185.46 L 520.95 186.11 L 523.51 186.58 L 524.28 187.74 L 524.27 188.43 L 522.77 190.68 L 521.63 193.79 L 521.71 194.76 L 522.39 195.44 L 522.33 196.76 L 522.33 196.76 L 520.54 196.92 L 520.02 197.25 L 519.91 197.7 L 519.97 198.65 L 520.57 199.78 L 520.5 201.97 L 522.12 203.55 L 522.41 204.09 L 522.35 206.36 L 521.61 208.12 L 517.72 211.99 L 516.75 212.27 L 514.46 213.6 L 513.92 214.47 L 511.95 216.18 L 509.33 217.45 L 509.33 217.45 L 508.88 218.61 L 507.38 220.91 L 506.33 221.58 L 505.54 221.4 L 503.54 221.78 L 503.65 224.18 L 501.79 225.98 L 501.47 225.93 L 500.85 225.31 L 498.69 225.3 L 497.87 226.28 L 497.1 226.64 L 494.37 226.98 L 492.86 228.32 L 492.04 229.54 L 490.34 229.64 L 488.86 230.28 L 485.86 230.39 L 485.04 230.11 L 484.85 229.83 L 484.98 229.17 L 483.27 228.19 L 481.94 227.8 L 480.55 228.35 L 478.42 228.78 L 478.1 228.6 L 477.69 227.67 L 476.19 227.21 L 474.24 227.23 L 471 228.88 L 470.94 229.81 L 473.18 234.25 L 473.3 235.4 L 473.01 237.97 L 472.76 238.88 L 472.04 239.74 L 469.09 244.79 L 466.12 247.21 L 464.77 247.63 L 463.29 247.1 L 461.95 246.93 L 459.75 247.68 L 458.58 248.57 L 457.91 249.44 L 456.77 249.82 L 456.02 251.27 L 455.69 251.48 L 453.58 251.3 L 451.78 251.82 L 447.6 249.97 L 445.83 247.48 L 445.3 245.27 L 444.64 244.23 L 443.2 242.89 L 440.87 242.91 L 440.87 242.91 L 437.93 242.7 L 437.93 242.7 L 437.98 240.78 L 438.24 239.72 L 439.39 237.27 L 439.52 230.91 L 440.28 229.51 L 440.31 229 L 438.58 225.94 L 438.11 222.75 L 437.41 220.81 L 438.14 218.81 L 439.84 217.41 L 441.04 214.93 L 441.17 213.42 L 441.51 212.59 L 441.81 212.38 L 443.25 209.64 L 443.88 207.32 L 444.27 204.35 L 445.25 201.37 L 447.38 199.42 L 450.1 198.66 L 452.71 198.35 L 453.78 197.98 L 455.48 196.45 L 456.53 196.41 L 457.87 195.89 L 460.73 193.32 L 463.07 192.41 L 465.08 190.41 L 465.71 189.54 L 465.71 189.08 L 467.61 187.16 L 468.11 186.94 L 468.95 186.7 L 469.18 187 L 470.3 186.74 L 471.3 186.14 L 472.76 185.95 L 473.77 186.16 L 476.28 187.98 L 477.79 187.88 L 480.23 187.02 L 481.06 186.98 L 481.71 187.26 L 483.99 186.97 L 485.2 185.66 L 485.7 184.2 L 485.82 182.99 L 486.11 182.55 L 486.5 180.35 L 486.37 179.5 L 486.2 179 L 484.59 178.09 L 482.81 176.06 L 482.3 173.76 L 482.19 171.65 L 482.36 169.17 L 486.46 164.74 L 486.67 164.19 L 486.77 161.76 L 486.22 158.78 L 484.64 155.98 L 485.78 153.11 L 486.06 151.64 L 485.68 150.37 L 484.45 149.53 L 484.1 147.61 L 484.87 146.56 L 485.51 146.39 L 486.33 144.41 L 488.22 142.56 L 489.1 140.73 L 489.06 138.94 L 491.98 135.53 L 492.79 135.69 L 496.1 135.23 L 500.23 131.26 L 502.02 128.99 L 502.41 127.46 L 501.77 126.93 L 501.55 126.21 L 502.01 124.77 L 502.01 124.77 L 502.74 124.89 L 504.21 125.76 L 504.72 126.27 L 504.59 126.58 z"},{code:"PR",name:"Paraná",gTransform:"matrix(1 0 0 1 47.59 157)",pathTransform:"translate(-353.59, -476.27)",d:"M 396.75 499.4 L 391.51 499.37 L 391.18 499.81 L 389.44 500.05 L 388.68 499.98 L 388.57 499.59 L 387 500.16 L 385.65 501.59 L 382.3 503.72 L 380.86 503.56 L 379.63 502.94 L 376.5 500.34 L 375.47 499.95 L 374.71 499.94 L 371.87 500.67 L 369.54 500.84 L 368.73 500.81 L 367.31 500.05 L 366.2 500.19 L 364.67 500.84 L 364.08 502.31 L 363.35 503.18 L 361.48 504.16 L 357.91 503.75 L 355.91 504.9 L 355.19 505.67 L 354.5 507.26 L 355.35 510.25 L 354.48 511.11 L 353.56 511.13 L 352.81 511.51 L 352.64 512 L 351.31 510.11 L 347.06 510.24 L 343.3 509.81 L 341.72 508.63 L 341.56 508.22 L 340.53 507.59 L 336.27 507.23 L 330.98 505.55 L 328.64 506.12 L 325.95 506.09 L 323.93 504.68 L 323.61 504.17 L 322.55 503.93 L 322.02 503.92 L 321.31 504.29 L 317.68 504.27 L 317.68 504.27 L 317.46 503.06 L 314.93 498.88 L 314.95 496.29 L 313.96 493.41 L 310.54 491.04 L 309.45 492.17 L 307.33 492.06 L 306.23 492.49 L 305.16 493.39 L 303.7 492.31 L 302.88 492.37 L 302.6 490.17 L 303.26 488.6 L 304.33 487.33 L 305.55 485.15 L 305.61 484.81 L 305.12 484.06 L 305.14 482.82 L 306.04 479.18 L 307.3 476.16 L 307.05 473.86 L 308.33 471.48 L 308.12 470.46 L 307.28 469.58 L 306.97 467.98 L 307.63 466.92 L 308.42 466.38 L 308.42 466.38 L 310.8 464.82 L 311.16 464 L 312.73 456.08 L 313.06 455.73 L 314.17 455.41 L 315.83 454.4 L 316.5 453.72 L 317.95 450.16 L 317.93 449.01 L 318.86 446.68 L 319.97 445.86 L 325.38 443.59 L 325.38 443.59 L 328.64 441.3 L 332.47 441.95 L 336.48 441.84 L 339.75 442.13 L 340.96 441.51 L 341.31 440.91 L 342.04 440.54 L 343.21 440.83 L 344.69 441.61 L 347.21 442.07 L 349.85 443.16 L 351.16 443.29 L 352.23 442.75 L 354.81 442.74 L 355.59 443.74 L 357.34 444.58 L 360.85 445.38 L 361.48 445.89 L 362.19 447.21 L 363.92 447.28 L 364.34 446.94 L 365.99 447.09 L 366.65 447.63 L 371.96 447.76 L 374.93 446.91 L 376.06 448.46 L 379.65 451.29 L 380.54 453.05 L 380.55 455.79 L 380.16 456.37 L 380 457.18 L 380.38 459.02 L 381.68 460.53 L 381.6 462.29 L 381.24 462.85 L 382.73 465.85 L 383.94 467 L 384.61 467.28 L 385.11 467.96 L 385.06 468.85 L 385.98 470.82 L 386.58 471.11 L 386.83 471.55 L 386.58 472.6 L 385.31 474.73 L 385.63 476.77 L 386.23 477.15 L 387.24 477.36 L 389.62 477.24 L 393.04 476.71 L 393.54 477.1 L 395.12 476.91 L 396.71 477.04 L 398.32 478.3 L 398.18 478.71 L 397.29 479.36 L 396.6 482.66 L 396.95 483.44 L 398.02 483.97 L 398.67 483.12 L 399.77 480.36 L 400.53 480.19 L 402.67 480.77 L 402.27 482.72 L 403 486.02 L 404.42 486.6 L 404.58 487.92 L 404.58 487.92 L 403.23 488.94 L 402.62 490.42 L 402.07 490.3 L 402.34 488.36 L 403.78 487.41 L 402.37 487.69 L 401.48 488.18 L 400.61 488.16 L 400.27 487.77 L 399.7 487.6 L 399.16 487.97 L 398.88 488.9 L 399.4 489.7 L 398.67 490.66 L 398.37 490.76 L 395.89 490.23 L 395.1 489.69 L 394.65 489.81 L 394.47 490.71 L 394.81 491.08 L 396.42 491.64 L 397.82 491.39 L 399.95 491.99 L 400.22 492.47 L 399.25 493.15 L 397.71 495.93 L 396.47 496.7 L 394.05 497.27 L 393.85 497.72 L 396.8 497.52 L 396.95 498.71 z"},{code:"RJ",name:"Rio de Janeiro",gTransform:"matrix(1 0 0 1 179.27 113.69)",pathTransform:"translate(-485.28, -432.95)",d:"M 468.35 450.28 L 468.28000000000003 449.5 L 468.66 449.23 L 471.85 449.45000000000005 L 474.44 448.86000000000007 L 471.91 447.31000000000006 L 470.51000000000005 446.81000000000006 L 467.70000000000005 447.49000000000007 L 466.34000000000003 449.0900000000001 L 465.31000000000006 449.4100000000001 L 464.61000000000007 449.36000000000007 L 463.26000000000005 447.2100000000001 L 462.78000000000003 447.2100000000001 L 461.88000000000005 447.6300000000001 L 460.9200000000001 448.6900000000001 L 457.7700000000001 449.4900000000001 L 457.4300000000001 450.40000000000015 L 457.2400000000001 452.3000000000001 L 459.4300000000001 452.4300000000001 L 460.5000000000001 453.4400000000001 L 459.35000000000014 454.5200000000001 L 458.41000000000014 454.3500000000001 L 456.9900000000001 454.5200000000001 L 456.9900000000001 454.5200000000001 L 456.5100000000001 454.2600000000001 L 454.8800000000001 452.5300000000001 L 454.8300000000001 452.12000000000006 L 455.9200000000001 448.62000000000006 L 457.01000000000005 447.4700000000001 L 459.36000000000007 446.4600000000001 L 459.86000000000007 446.61000000000007 L 462.63000000000005 446.25000000000006 L 464.13000000000005 445.5400000000001 L 465.78000000000003 443.3900000000001 L 465.03000000000003 441.7500000000001 L 463.33000000000004 441.7400000000001 L 460.18000000000006 442.2700000000001 L 458.4100000000001 441.8800000000001 L 457.18000000000006 440.29000000000013 L 456.62000000000006 439.1200000000001 L 455.3500000000001 438.5800000000001 L 455.3500000000001 438.5800000000001 L 456.0300000000001 438.0900000000001 L 458.4500000000001 437.3500000000001 L 461.3600000000001 436.0100000000001 L 463.9400000000001 435.8400000000001 L 464.4400000000001 436.11000000000007 L 466.16000000000014 435.3400000000001 L 467.21000000000015 434.5700000000001 L 471.3000000000001 432.7800000000001 L 471.8200000000001 432.7100000000001 L 472.1800000000001 433.0200000000001 L 475.3800000000001 432.9500000000001 L 476.6300000000001 432.7800000000001 L 478.2600000000001 431.8400000000001 L 478.8300000000001 431.7800000000001 L 481.36000000000007 432.05000000000007 L 481.8500000000001 432.2200000000001 L 481.8300000000001 432.6900000000001 L 483.2100000000001 432.4900000000001 L 492.7200000000001 427.96000000000015 L 495.25000000000006 426.97000000000014 L 495.46000000000004 426.45000000000016 L 495.18000000000006 425.84000000000015 L 493.74000000000007 425.71000000000015 L 493.83000000000004 424.96000000000015 L 495.72 421.25000000000017 L 498.08000000000004 415.21000000000015 L 497.35 414.50000000000017 L 497.91 414.01000000000016 L 499.15000000000003 413.7400000000002 L 501.68 411.38000000000017 L 501.68 411.38000000000017 L 503.61 412.14000000000016 L 504.28000000000003 416.85000000000014 L 506.78000000000003 417.98000000000013 L 511.11 418.9900000000001 L 514.1 418.6200000000001 L 515.72 419.6800000000001 L 515.72 419.6800000000001 L 515.64 420.9500000000001 L 514.6999999999999 422.5600000000001 L 514.4799999999999 424.6900000000001 L 515.6199999999999 431.4700000000001 L 515.1199999999999 432.1500000000001 L 512.0399999999998 433.9000000000001 L 506.0699999999998 435.8400000000001 L 503.23999999999984 437.5600000000001 L 499.73999999999984 441.2500000000001 L 499.6299999999998 442.91000000000014 L 499.9399999999998 444.10000000000014 L 499.74999999999983 445.72000000000014 L 499.0199999999998 447.20000000000016 L 497.1999999999998 447.71000000000015 L 490.6499999999998 447.54000000000013 L 484.8599999999998 448.2400000000001 L 482.4699999999998 447.78000000000014 L 481.9799999999998 447.40000000000015 L 481.9199999999998 446.72000000000014 L 482.94999999999976 445.2400000000001 L 483.6199999999998 443.79000000000013 L 483.5299999999998 443.17000000000013 L 482.74999999999983 442.9900000000001 L 479.9599999999998 444.1400000000001 L 479.6999999999998 444.8300000000001 L 480.0099999999998 445.6200000000001 L 481.3899999999998 446.79000000000013 L 481.6399999999998 447.76000000000016 L 481.04999999999984 448.28000000000014 L 479.41999999999985 448.79000000000013 L 477.84999999999985 448.76000000000016 L 469.80999999999983 449.83000000000015 L 468.35 450.28 z M 463.24 452.27 L 462.57 451.29999999999995 L 464.68 449.74999999999994 L 466.54 450.68999999999994 L 466.97 451.38999999999993 L 464.51000000000005 451.88999999999993 L 464.1 451.5399999999999 L 463.63 451.5399999999999 L 463.24 452.27 z"},{code:"RN",name:"Rio Grande do Norte",gTransform:"matrix(1 0 0 1 274.86 -145.63)",pathTransform:"translate(-580.87, -173.63)",d:"M 609.29 182.91 L 608.36 183.15 L 604.86 182.94 L 603.82 183.34 L 601.36 182.24 L 599.19 181.94 L 593.36 182.33 L 592.83 181.98 L 589.41 181.58 L 588.79 181.09 L 588.89 180.09 L 588.47 179.7 L 587.09 179.75 L 585.27 181.1 L 584.96 182.58 L 585.68 183.36 L 586.21 184.89 L 585.2 184.57 L 584.72 185.16 L 584.88 186.58 L 585.35 187.52 L 584.8 188.73 L 584.3 189.47 L 581.95 190.4 L 581.12 189.66 L 581.64 188.12 L 580.75 186.95 L 578.8 186.65 L 577.03 186.73 L 573.88 187.99 L 573.59 187.76 L 573.28 186.38 L 572.96 186.15 L 569.43 185.63 L 569.51 183.91 L 569.72 183.6 L 570.57 183.35 L 570.98 182.97 L 571.36 181.23 L 571.8 180.27 L 574.79 177.06 L 574.78 175.87 L 574.25 175.43 L 573.61 175.35 L 570.35 176.39 L 568.92 176.51 L 565.74 177.72 L 565.33 178.67 L 565.23 179.71 L 564.41 180.42 L 561.18 182.08 L 560.02 183.21 L 557.14 182.6 L 556.24 182.18 L 554.31 180.54 L 553.74 181 L 553.74 181 L 553.08 181.38 L 552.44 181.21 L 552.78 179.24 L 554.19 176.99 L 555.03 176.11 L 555.54 176.04 L 556.32 176.55 L 557.35 176.29 L 557.92 175.19 L 559.38 173.68 L 560.78 171.24 L 560.63 170.5 L 561.28 168.83 L 562.15 168.26 L 562.99 167.14 L 566.29 160.45 L 568.9 158.44 L 573.79 156.85 L 573.79 156.85 L 574.26 157.61 L 575.12 158.36 L 578.25 158.35 L 579.47 158.76 L 581.16 160.51 L 582.48 161.01 L 585.81 160.69 L 588.69 161.21 L 591.23 160.97 L 593.56 160.24 L 598.06 161.16 L 599.33 161.2 L 601.28 162.06 L 602.3 162.88 L 602.94 163.82 L 605.25 168.56 L 605.75 170.35 L 605.71 171.1 L 607.19 176.48 L 607.4 178.16 L 608.12 178.7 L 609.08 181.39 z"},{code:"RO",name:"Rondônia",gTransform:"matrix(1 0 0 1 -139.57 -68.08)",pathTransform:"translate(-166.43, -251.18)",d:"M 187.32 290.95 L 186.03 289.5 L 185.59 287.62 L 184.03 287.1 L 183.17 287.42 L 181.36 287.5 L 177.29 285.69 L 177.28 285.29 L 176.62 284.68 L 175.35 285.27 L 173.37 283.59 L 171.85 282.62 L 170.99 281.16 L 170.71 279.77 L 169.67 279.38 L 167.9 280.5 L 166.68 280.47 L 165.27 279.67 L 164.4 278.34 L 161.27 276.76 L 159.31 276.59 L 158.17 277.13 L 157.27 277.98 L 155.84 277.81 L 155.53 277.51 L 153.39 277 L 150.33 276.72 L 149.57 276.29 L 148.39 275.1 L 148.09 273.13 L 146.51 272.64 L 144.62 271.67 L 143.8 269.95 L 143.51 269.75 L 140.79 269.47 L 140.41 269.12 L 139.57 265.41 L 138.69 264.52 L 138.21 265.68 L 137.55 265.36 L 137.28 264.72 L 137.9 263.19 L 137.06 261.67 L 135.7 261.28 L 134.44 257.81 L 134.27 256.15 L 135.82 253.24 L 135.61 251.58 L 134.45 249.61 L 133.7 247.45 L 133.64 245.16 L 134.26 244.66 L 134.64 243.29 L 135.68 242.24 L 136.04 240.77 L 135.8 239.28 L 135.38 238.39 L 135.29 236.86 L 135.83 235.21 L 134.66 233.03 L 133.64 232.65 L 132.55 233.63 L 132.49 234.14 L 131.65 235.1 L 131.08 235.1 L 128.9 234.08 L 123.72 234.16 L 118.11 235.94 L 116.42 235.93 L 114.94 236.41 L 114.94 236.41 L 111.97 235.15 L 111.97 235.15 L 115.23 232.59 L 117.15 232.01 L 118.7 230.2 L 118.85 229.64 L 118.69 228.35 L 122.65 228.61 L 125.52 228.28 L 126.24 228.65 L 128.55 230.98 L 128.92 230.96 L 130.14 230.17 L 130.27 229.45 L 130.68 228.92 L 131.76 228.42 L 132.53 228.55 L 133.9 228.16 L 135.2 226.95 L 137.04 225.93 L 137.42 226.02 L 138.06 228.28 L 138.74 228.81 L 139.42 228.73 L 141.96 225.57 L 141.7 223.82 L 142.23 222.98 L 143.98 221.72 L 144.44 221.74 L 145.28 222.29 L 147.07 222.39 L 148.27 221.32 L 150.4 220.94 L 154.27 221.4 L 154.03 219.94 L 154.14 218.13 L 156.2 216.92 L 157.01 215.77 L 157.37 214.75 L 157.2 214.3 L 156.3 213.6 L 156.35 212.93 L 157.54 211.34 L 160.02 210.81 L 160.28 210.59 L 160.19 209.42 L 161.91 208.92 L 163.29 206.36 L 174.08 206.3 L 176.23 207.43 L 176.68 207.92 L 177.48 209.83 L 178.81 211.1 L 181.35 212.08 L 182.6 215.35 L 183.06 215.56 L 184.04 215.43 L 184.66 215.63 L 185.34 218.51 L 188.58 219.99 L 189.26 219.8 L 189.8 218.06 L 191.72 216.98 L 193.11 217.26 L 193.47 217.64 L 193.43 218.34 L 193.43 218.34 L 194.83 219.31 L 195.43 220.55 L 194.67 221.97 L 193.38 226.96 L 193.44 227.31 L 194.22 227.78 L 194.48 228.39 L 194.63 229.78 L 195.46 232.05 L 194.52 233.72 L 194.9 235.65 L 193.9 239.17 L 193.87 239.97 L 194.14 241.73 L 195.64 244.48 L 194.74 253.48 L 211.9 253.53 L 211.66 254.09 L 212.88 255.2 L 216.38 255.11 L 217.49 255.22 L 218.56 255.65 L 219.97 259.24 L 219.8 259.99 L 218.4 261.74 L 217.04 262.82 L 216.9 264.14 L 217.33 267.39 L 217.91 267.9 L 218.81 267.87 L 220.34 271.21 L 220.3 273.26 L 220.88 274.75 L 220.81 276.46 L 220.25 278.7 L 218.59 280.71 L 218.07 282.96 L 217.49 283.8 L 217.06 284.21 L 215.42 284.74 L 214.49 285.82 L 213.06 289.6 L 212.54 292.05 L 208.43 294.62 L 206.96 296.05 L 206.96 296.05 L 206.22 296.01 L 203.63 294.46 L 202.36 293.03 L 195.28 293.99 L 193.96 293.56 L 193.71 293.26 L 190.33 293.92 L 189.85 293.76 L 189.33 292.41 z"},{code:"RR",name:"Roraima",gTransform:"matrix(1 0 0 1 -116.08 -267.27)",pathTransform:"translate(-189.92, -51.99)",d:"M 234.61 61.4 L 236.21 78.37 L 236.21 78.37 L 217.72 78.3 L 217.75 78.98 L 215.42 82.24 L 213.76 85.27 L 213.69 86.4 L 212.54 89.04 L 212.43 89.7 L 212.66 90.43 L 213.8 91.84 L 213.78 92.37 L 213.36 92.76 L 211.33 93.31 L 209.92 94.72 L 208.67 95.18 L 206.85 94.95 L 205.93 92.44 L 204.06 90.4 L 201.23 89.47 L 199.63 89.53 L 199.08 90.42 L 196.99 91.13 L 195.71 91.82 L 194.69 93.08 L 193.87 96.05 L 194.24 97.85 L 193.99 99.58 L 193.24 101.87 L 193.68 103.98 L 191.32 102.94 L 189.98 103.36 L 189.45 103.29 L 188.41 101.25 L 186.93 99.6 L 184.97 98.29 L 184.45 98.25 L 179.44 93.83 L 179.58 92.69 L 181.42 93.02 L 182.56 91.7 L 182.62 91.12 L 181.49 86.79 L 180.91 85.89 L 179.69 85.05 L 178.81 82.88 L 178.52 77.9 L 179.09 76.94 L 179.86 73.9 L 179.2 72.32 L 178.84 70.73 L 180.46 69.27 L 180.41 68.82 L 179.54 67.7 L 179.35 65.44 L 177.69 60.68 L 174.96 56.94 L 175.67 55.44 L 176.58 52.12 L 176.09 51.46 L 174.14 50.51 L 172.78 50.4 L 171.9 50.61 L 170.93 50.24 L 169.72 49.07 L 169.66 48.11 L 169.03 48 L 167.9 48.42 L 167.29 48.41 L 166.54 48.07 L 165.82 47.29 L 165.82 47.29 L 166.12 46.83 L 166.35 44.55 L 166.05 44.33 L 162.68 44.1 L 158.93 44.24 L 155.62 43.54 L 155.42 42.94 L 156.22 41.18 L 156.34 39.7 L 155.61 37.93 L 153.67 34.39 L 152.94 32.33 L 152.47 28.61 L 153.26 27.13 L 153.18 26.17 L 151.34 24.17 L 149.18 23.11 L 146.37 20.33 L 145.31 18.52 L 145.02 17.56 L 143.88 16.91 L 143.63 16.52 L 143.66 15.68 L 143.95 15.35 L 144.85 15.42 L 145.97 16.08 L 146.91 17.81 L 147.52 17.9 L 150.91 17.4 L 152.26 17.5 L 154.17 18.09 L 154.78 19.29 L 155.33 21.22 L 155.87 21.57 L 156.83 21.49 L 157.57 20.84 L 158.52 20.44 L 161.7 20.6 L 162.17 20.65 L 163.48 21.86 L 164.08 22.01 L 164.6 21.87 L 165.21 20.31 L 166.52 20.45 L 167.97 21.38 L 171.9 25.95 L 172.95 26.52 L 173.66 26.63 L 175.17 25.95 L 175.91 24.82 L 176.01 23.98 L 175.18 21.22 L 175.54 19.48 L 176 19.2 L 177.93 19.15 L 178.94 18.05 L 180.49 16.96 L 181.24 17.01 L 185.14 18.35 L 185.73 18.18 L 186.53 17.46 L 187.56 17.16 L 188.69 17.51 L 189.72 17.3 L 191.06 16.02 L 192.06 15.77 L 193.21 16 L 194.32 15.93 L 195 15.08 L 195.05 13.73 L 198.08 11.92 L 200.41 12.11 L 203.17 11.72 L 204.06 10.59 L 204.15 9.88 L 204.74 8.76 L 205.49 8.63 L 207.34 7.73 L 208.44 6.69 L 209.55 4.98 L 208.35 1.42 L 207.18 1.06 L 207.82 0.88 L 209.25 0.95 L 210.05 1.27 L 213.62 1.17 L 214.68 0.22 L 215.42 0 L 216.79 0.42 L 217.32 1.73 L 218.36 2.53 L 218.84 3.9 L 218.17 8.8 L 217.45 10.18 L 216.2 10.88 L 216.26 11.71 L 217.87 12.12 L 219.49 11.9 L 221.84 12.71 L 223.66 13.81 L 222.78 15.24 L 222.77 16.39 L 225.11 19.81 L 225.31 21.36 L 223.8 24.28 L 221.92 25.69 L 221.2 27.19 L 221.47 27.58 L 221.53 29.75 L 220.06 32.16 L 219.16 34.93 L 218.85 37.5 L 218.76 40.17 L 219.74 42.04 L 220.25 43.8 L 220.24 45.2 L 221.81 46.23 L 222.71 46.43 L 222.84 47.11 L 222.38 52.26 L 222.5 53 L 224.31 53.29 L 223.65 54.46 L 224.11 54.96 L 226.26 55.7 L 227.72 57.62 L 230.38 60.36 z"},{code:"RS",name:"Rio Grande do Sul",gTransform:"matrix(1 0 0 1 11.62 259.25)",pathTransform:"translate(-317.63, -578.5)",d:"M 321.99 638.52 L 321.63 638.53 L 319.69 637.42 L 319.49 636.96 L 320.01 632.69 L 319.55 628.44 L 319.7 627.37 L 320.33 626.13 L 323.17 623.75 L 324 622.19 L 326.3 619.63 L 324.84 617.98 L 323.77 617.36 L 321.52 616.76 L 319.2 614.51 L 317.99 612.89 L 317.89 611.3 L 317.46 610.12 L 316.23 608.09 L 314.17 605.85 L 313.5 605.26 L 311.11 604.05 L 309.66 604.26 L 307.76 602.75 L 306.24 601.12 L 304.99 600.34 L 304.85 598.64 L 302.95 596.48 L 299.63 596.02 L 298.71 595.55 L 296.98 593.89 L 295.22 594.02 L 293.05 592.64 L 291.14 588.93 L 290.03 587.44 L 287.5 585.32 L 286.8 585.4 L 286.13 587.19 L 283.54 589.43 L 280.87 589.55 L 280.97 586.69 L 281.37 585.41 L 280.98 584.41 L 277.33 580.12 L 274.96 578.35 L 272.78 576.29 L 271.03 574.18 L 268.34 571.97 L 266.44 571.83 L 264.29 572.04 L 263.15 573.4 L 263.09 574.36 L 262.06 575.33 L 260.95 575.35 L 260.37 574.87 L 257.21 575.01 L 256.56 574.53 L 256.4 573.62 L 255.91 573.4 L 256.76 573.18 L 257.8 572.46 L 260.32 569.69 L 260.43 567.85 L 261.03 566.6 L 261.85 566.15 L 263.14 566.08 L 263.78 565.82 L 264.7 564.82 L 270.15 558.34 L 270.78 556.92 L 270.95 555.81 L 271.77 554.74 L 272.97 553.89 L 274.34 553.48 L 276.3 549.26 L 276.4 548.65 L 276.71 548.28 L 278.35 547.42 L 279.98 545.62 L 280.83 544.47 L 281.34 543.18 L 282.68 541.08 L 283.61 540.79 L 285.18 540.97 L 285.73 541.76 L 286.2 540.48 L 285.99 539.9 L 284.64 539.08 L 284.59 538.72 L 284.94 538.39 L 286.02 538.01 L 286.84 537.05 L 289.63 536.1 L 290.68 535.03 L 290.78 534.11 L 291.6 533.2 L 293.81 532.05 L 296.28 531.65 L 298.05 529.84 L 298.2 528.78 L 299.52 526.42 L 299.85 526.38 L 299.9 526.74 L 300.19 526.94 L 301.52 526.77 L 303.96 525.64 L 306.64 525.05 L 307.85 524.48 L 309.95 522.13 L 310.45 522.14 L 311.12 521.75 L 312.13 520.4 L 314.44 519.67 L 314.74 520.05 L 314.74 520.05 L 318.26 520.44 L 321.52 519.29 L 322.08 518.48 L 323.43 519.06 L 323.28 519.98 L 326.36 519.95 L 327.99 520.94 L 330.55 520.57 L 332.47 521.72 L 335.05 521.31 L 336.59 521.49 L 339.39 521.33 L 341.65 522.25 L 344.13 523.65 L 345.13 526.09 L 346.72 526.28 L 346.81 525.8 L 348.62 525.45 L 354.18 528.99 L 355.55 530.54 L 356.26 530.51 L 357.82 531.49 L 360.85 534.98 L 362.49 537.19 L 362.97 538.67 L 365.14 541.33 L 366.31 541.88 L 373 542.94 L 375.11 542.54 L 378.46 542.88 L 379.34 545.22 L 377.26 546.8 L 375.99 547.21 L 375.26 549.07 L 375.48 551.26 L 375.1 552.82 L 374.58 554.12 L 373.4 554.32 L 372.11 556.01 L 372.08 557.42 L 373.88 558.59 L 374.15 558.39 L 373.87 557.42 L 373.88 556.46 L 375.37 555.64 L 376.95 556.28 L 377.68 557.19 L 378.85 558.04 L 379.3 558.01 L 379.3 558.01 L 377.9 559.74 L 374 566.78 L 369.79 578.38 L 363.49 588.86 L 358.05 595.52 L 351.54 601.48 L 345.45 605.16 L 342.35 609.47 L 342.17 609.04 L 342.82 607.46 L 343.16 605.28 L 341.98 603.57 L 342.08 603.15 L 343.01 602.98 L 344.02 603.38 L 344.58 603.96 L 345.6 604 L 348.18 602.59 L 349 601.91 L 351.85 598.2 L 352.6 597.51 L 353.05 597.7 L 354.07 597.51 L 355.12 596.67 L 356.05 595.4 L 356.42 593.92 L 356.6 592.99 L 356.37 590.89 L 356.57 589.52 L 358.14 589.45 L 358.88 589.75 L 359.15 590.58 L 359.5 590.32 L 359.21 588.92 L 359.72 586.85 L 360.2 586.28 L 362.94 584.69 L 363.67 583.61 L 364.14 580.86 L 363.93 578.58 L 364.49 577.9 L 364.99 578.7 L 365.36 578.73 L 365.79 578.31 L 366.26 575.23 L 366.16 574.79 L 365.21 573.57 L 364.54 573.54 L 364.28 574.23 L 364.45 574.62 L 364.31 575.19 L 363.96 575.39 L 362.45 575.37 L 360.44 575.77 L 360.1 577.38 L 359.57 577.43 L 358.76 576.99 L 358.86 575.28 L 358.04 574.39 L 357 574.72 L 356.4 574.24 L 355.67 572.98 L 355.27 571.53 L 355.39 570.96 L 354.75 570.27 L 354.14 572.98 L 354.58 575.23 L 355.83 577.34 L 355.26 578.15 L 354.52 580.69 L 354.9 583.72 L 354.72 584.49 L 354.24 584.12 L 354.5 583.88 L 354.47 583.17 L 354 581.89 L 353.55 581.5 L 353.02 582.16 L 352.99 583.53 L 351.58 586.8 L 351.53 588.69 L 351.75 589.21 L 351.03 589.91 L 349.42 590.55 L 348.81 592.13 L 344.72 593.7 L 344 594.23 L 343.47 595.82 L 343.37 598.09 L 342.4 600.36 L 340.04 601.66 L 339.93 603.42 L 340.41 604.25 L 340.66 605.27 L 339.71 605.83 L 339.46 607.34 L 339.89 607.94 L 340.57 607.8 L 341.87 608.43 L 342.02 609.34 L 339.89 610.99 L 337.57 615.51 L 335.64 622.39 L 333.63 626.88 L 331.95 629.4 L 324.16 636.93 z"},{code:"SC",name:"Santa Catarina",gTransform:"matrix(1 0 0 1 51.41 209.71)",pathTransform:"translate(-357.4, -528.97)",d:"M 379.3 558.01 L 378.85 558.04 L 377.68 557.1899999999999 L 376.95 556.27 L 375.36 555.64 L 373.88 556.46 L 373.87 557.4200000000001 L 374.15 558.3900000000001 L 373.88 558.5900000000001 L 372.08 557.4200000000002 L 372.12 556.0100000000002 L 373.4 554.3200000000002 L 374.58 554.1200000000001 L 375.10999999999996 552.8100000000002 L 375.47999999999996 551.2600000000002 L 375.25999999999993 549.0700000000002 L 375.98999999999995 547.2100000000002 L 377.25999999999993 546.7900000000002 L 379.3399999999999 545.2100000000002 L 378.4599999999999 542.8700000000001 L 375.1099999999999 542.5300000000001 L 372.9999999999999 542.9300000000001 L 366.3099999999999 541.8700000000001 L 365.14999999999986 541.3300000000002 L 362.97999999999985 538.6700000000002 L 362.48999999999984 537.1900000000002 L 360.85999999999984 534.9800000000001 L 357.82999999999987 531.4900000000001 L 356.2599999999999 530.5000000000001 L 355.5499999999999 530.5300000000001 L 354.1799999999999 528.9800000000001 L 348.6199999999999 525.4400000000002 L 346.8099999999999 525.7800000000002 L 346.7199999999999 526.2600000000002 L 345.1199999999999 526.0700000000002 L 344.1199999999999 523.6300000000001 L 341.64999999999986 522.2400000000001 L 339.3799999999999 521.3100000000002 L 336.58999999999986 521.4700000000001 L 335.04999999999984 521.2900000000002 L 332.45999999999987 521.7000000000002 L 330.54999999999984 520.5500000000002 L 327.97999999999985 520.9100000000002 L 326.34999999999985 519.9300000000002 L 323.26999999999987 519.9600000000002 L 323.41999999999985 519.0300000000002 L 322.0699999999998 518.4500000000002 L 321.5099999999998 519.2600000000001 L 318.24999999999983 520.4200000000001 L 314.72999999999985 520.0300000000001 L 314.72999999999985 520.0300000000001 L 316.17999999999984 517.1000000000001 L 316.90999999999985 515.0100000000001 L 316.32999999999987 511.7600000000001 L 316.7399999999999 508.5500000000001 L 316.6999999999999 506.0000000000001 L 317.65999999999985 504.2500000000001 L 317.65999999999985 504.2500000000001 L 321.28999999999985 504.2700000000001 L 321.99999999999983 503.8900000000001 L 322.5299999999998 503.9000000000001 L 323.5899999999998 504.1400000000001 L 323.8999999999998 504.6500000000001 L 325.9299999999998 506.0600000000001 L 328.6099999999998 506.0900000000001 L 330.94999999999976 505.5100000000001 L 336.2399999999998 507.1900000000001 L 340.4999999999998 507.5500000000001 L 341.51999999999975 508.1800000000001 L 341.68999999999977 508.59000000000015 L 343.25999999999976 509.77000000000015 L 347.02999999999975 510.19000000000017 L 351.27999999999975 510.0600000000002 L 352.60999999999973 511.96000000000015 L 352.78999999999974 511.46000000000015 L 353.52999999999975 511.08000000000015 L 354.44999999999976 511.0600000000002 L 355.31999999999977 510.20000000000016 L 354.46999999999974 507.21000000000015 L 355.15999999999974 505.63000000000017 L 355.87999999999977 504.8500000000002 L 357.87999999999977 503.7100000000002 L 361.44999999999976 504.1100000000002 L 363.31999999999977 503.14000000000016 L 364.0499999999998 502.27000000000015 L 364.63999999999976 500.79000000000013 L 366.16999999999973 500.14000000000016 L 367.27999999999975 500.00000000000017 L 368.69999999999976 500.76000000000016 L 369.50999999999976 500.79000000000013 L 371.83999999999975 500.6200000000001 L 374.6799999999997 499.8900000000001 L 375.4299999999997 499.9000000000001 L 376.46999999999974 500.30000000000007 L 379.58999999999975 502.9000000000001 L 380.81999999999977 503.5200000000001 L 382.25999999999976 503.6800000000001 L 385.6099999999998 501.5500000000001 L 386.9599999999998 500.1200000000001 L 388.5199999999998 499.5500000000001 L 388.6399999999998 499.9400000000001 L 389.3999999999998 500.0100000000001 L 391.1399999999998 499.7800000000001 L 391.4699999999998 499.3400000000001 L 396.7099999999998 499.37000000000006 L 396.7099999999998 499.37000000000006 L 396.3199999999998 500.69000000000005 L 396.8299999999998 502.34000000000003 L 396.7599999999998 502.73 L 395.2599999999998 503.87 L 394.2799999999998 503.39 L 393.4599999999998 500.86 L 393.4399999999998 501.98 L 394.0299999999998 504.70000000000005 L 395.7399999999998 506.36000000000007 L 396.2999999999998 507.31000000000006 L 395.2899999999998 509.6000000000001 L 395.12999999999977 511.9200000000001 L 395.2299999999998 512.35 L 395.9899999999998 513.08 L 396.2499999999998 518.94 L 396.5599999999998 519.49 L 396.9899999999998 519.69 L 397.75999999999976 519.1800000000001 L 398.1099999999998 519.9000000000001 L 398.2099999999998 520.7700000000001 L 397.7399999999998 520.83 L 397.3099999999998 520.5500000000001 L 396.1199999999998 521.1800000000001 L 395.7799999999998 525.0200000000001 L 396.3499999999998 527.6100000000001 L 395.7799999999998 528.3600000000001 L 396.0899999999998 530.2900000000001 L 396.99999999999983 532.1700000000001 L 396.1399999999998 534.5100000000001 L 395.61999999999983 538.5200000000001 L 393.90999999999985 543.2 L 393.5699999999999 543.1 L 393.20999999999987 542.34 L 393.41999999999985 541.37 L 392.49999999999983 540.19 L 392.23999999999984 540.5200000000001 L 392.41999999999985 542.95 L 393.57999999999987 543.7800000000001 L 392.65999999999985 545.44 L 391.01999999999987 546.09 L 386.8899999999999 549.13 L 384.08999999999986 551.6899999999999 L 380.33999999999986 556.13 L 379.3 558.01 z M 397.18 531.46 L 397.03000000000003 530.99 L 397.28000000000003 529.24 L 398.04 526.84 L 397.64000000000004 525.6600000000001 L 397.80000000000007 524.6400000000001 L 399.20000000000005 523.8800000000001 L 399.4200000000001 523.94 L 400.0800000000001 524.8800000000001 L 399.5400000000001 527.44 L 398.7200000000001 528.3000000000001 L 398.1300000000001 529.5200000000001 L 398.3300000000001 530.69 L 397.18 531.46 z M 396.73 507.09 L 394.86 505.07 L 397.41 502.63 L 397.66 502.67 L 398.31 503.72 L 397.45 505.04 L 396.73 507.09 z"},{code:"SE",name:"Sergipe",gTransform:"matrix(1 0 0 1 266.49 -72.82)",pathTransform:"translate(-572.49, -246.44)",d:"M 569.94 261.69 L 567.04 262.58 L 565.49 261.94 L 564.95 261.6 L 564.47 260.88 L 562.55 259.96 L 561.95 259.44 L 561.83 259.03 L 562.17 258.64 L 562.3 257.22 L 562.15 256.83 L 560.72 255.32 L 560.2 253.83 L 559.11 253.16 L 558.15 251.56 L 558.13 250.79 L 558.72 249.21 L 559.04 248.91 L 560.74 248.92 L 561.87 249.67 L 564.42 248.68 L 565.11 248.13 L 565.41 247.55 L 564.65 244.8 L 564.73 243.92 L 565.39 242.3 L 565.47 239.19 L 564.72 238.04 L 562.73 236.09 L 561.46 233.59 L 561.24 231.45 L 561.91 230.3 L 561.91 230.3 L 568.37 233.28 L 572.05 234.23 L 577.47 237.3 L 578.77 239.75 L 580.53 241.2 L 582.19 241.99 L 582.65 242.02 L 586.24 244.25 L 586.84 245.56 L 586.84 245.56 L 584.46 246.32 L 579.89 249.26 L 578.92 250.15 L 577.37 252.36 L 577.05 252.34 L 577.16 251.24 L 576.11 249.42 L 575.12 249.58 L 575.46 250.74 L 576.7 250.74 L 576.93 250.98 L 576.41 252.95 L 575.14 255.04 L 574.61 254.69 L 574.24 254.02 L 573.25 253.86 L 573.45 254.54 L 574.58 255.16 L 574.32 256.93 L 573.46 258.08 L 572.53 260.11 L 571.75 260.26 L 571.45 259.8 L 571.93 258.4 L 572.34 258.27 L 572.65 257.84 L 573.02 256.8 L 572.21 256.43 L 572.31 257.11 L 571.86 258.24 L 571.38 258.74 L 571.12 259.83 L 571.4 260.55 L 571.14 261.07 z"},{code:"SP",name:"São Paulo",gTransform:"matrix(1 0 0 1 89.6 122.15)",pathTransform:"translate(-395.6, -441.42)",d:"M 404.58 487.92 L 404.41999999999996 486.59000000000003 L 402.99999999999994 486.02000000000004 L 402.2699999999999 482.72 L 402.6699999999999 480.77000000000004 L 400.5299999999999 480.19000000000005 L 399.7699999999999 480.36000000000007 L 398.6699999999999 483.13000000000005 L 398.0099999999999 483.9800000000001 L 396.9499999999999 483.4500000000001 L 396.59999999999985 482.67000000000013 L 397.28999999999985 479.3700000000001 L 398.17999999999984 478.7100000000001 L 398.3199999999998 478.3100000000001 L 396.7099999999998 477.04000000000013 L 395.11999999999983 476.91000000000014 L 393.53999999999985 477.10000000000014 L 393.03999999999985 476.72000000000014 L 389.6299999999998 477.2500000000001 L 387.24999999999983 477.3700000000001 L 386.23999999999984 477.16000000000014 L 385.6399999999998 476.77000000000015 L 385.30999999999983 474.73000000000013 L 386.5899999999998 472.6100000000001 L 386.8399999999998 471.5600000000001 L 386.5899999999998 471.1200000000001 L 385.9899999999998 470.8200000000001 L 385.06999999999977 468.8500000000001 L 385.12999999999977 467.9600000000001 L 384.62999999999977 467.2800000000001 L 383.95999999999975 466.99000000000007 L 382.7499999999998 465.8500000000001 L 381.25999999999976 462.8400000000001 L 381.6199999999998 462.2900000000001 L 381.69999999999976 460.5300000000001 L 380.39999999999975 459.0100000000001 L 380.01999999999975 457.17000000000013 L 380.18999999999977 456.3600000000001 L 380.57999999999976 455.78000000000014 L 380.5599999999998 453.04000000000013 L 379.6699999999998 451.28000000000014 L 376.0799999999998 448.45000000000016 L 374.9499999999998 446.90000000000015 L 371.9799999999998 447.76000000000016 L 366.6699999999998 447.63000000000017 L 366.00999999999976 447.09000000000015 L 364.3599999999998 446.95000000000016 L 363.93999999999977 447.29000000000013 L 362.21999999999974 447.22000000000014 L 361.4999999999997 445.90000000000015 L 360.8699999999997 445.39000000000016 L 357.35999999999973 444.59000000000015 L 355.60999999999973 443.75000000000017 L 354.82999999999976 442.75000000000017 L 352.2499999999998 442.76000000000016 L 351.1799999999998 443.3000000000002 L 349.8599999999998 443.1700000000002 L 347.2199999999998 442.0800000000002 L 344.6899999999998 441.62000000000023 L 343.2099999999998 440.8300000000002 L 342.0399999999998 440.5400000000002 L 341.3099999999998 440.9100000000002 L 340.9699999999998 441.5100000000002 L 339.7599999999998 442.1300000000002 L 336.47999999999985 441.8400000000002 L 332.46999999999986 441.9500000000002 L 328.6399999999999 441.30000000000024 L 325.3899999999999 443.59000000000026 L 325.3899999999999 443.59000000000026 L 326.22999999999985 442.5100000000003 L 326.95999999999987 440.97000000000025 L 328.21999999999986 439.83000000000027 L 335.77999999999986 435.29000000000025 L 337.72999999999985 433.42000000000024 L 338.98999999999984 430.99000000000024 L 340.71999999999986 429.30000000000024 L 341.11999999999983 428.09000000000026 L 342.55999999999983 427.0600000000003 L 342.8399999999998 425.84000000000026 L 342.4899999999998 425.0000000000003 L 344.4899999999998 422.7400000000003 L 345.69999999999976 420.4000000000003 L 345.76999999999975 419.4600000000003 L 345.45999999999975 417.5300000000003 L 345.68999999999977 417.1400000000003 L 346.64999999999975 416.62000000000035 L 349.2499999999998 412.98000000000036 L 349.4099999999998 410.05000000000035 L 350.0299999999998 408.37000000000035 L 351.0399999999998 408.07000000000033 L 351.7699999999998 407.43000000000035 L 353.7599999999998 404.75000000000034 L 354.97999999999985 403.73000000000036 L 355.4499999999999 403.50000000000034 L 356.7599999999999 403.4600000000003 L 358.2599999999999 402.68000000000035 L 358.53999999999985 402.28000000000037 L 358.9399999999998 399.8200000000004 L 358.9399999999998 399.8200000000004 L 360.15999999999985 398.6900000000004 L 362.30999999999983 397.5800000000004 L 364.22999999999985 397.2100000000004 L 365.65999999999985 395.5200000000004 L 367.15999999999985 394.91000000000037 L 367.90999999999985 395.05000000000035 L 369.6399999999999 396.60000000000036 L 372.1899999999999 396.68000000000035 L 376.4799999999999 397.6400000000003 L 378.1499999999999 397.2800000000003 L 379.7699999999999 397.50000000000034 L 381.7699999999999 396.91000000000037 L 383.94999999999993 398.3300000000004 L 385.61999999999995 399.1200000000004 L 385.48999999999995 400.0400000000004 L 385.81999999999994 401.46000000000043 L 387.0299999999999 403.5500000000004 L 387.6599999999999 403.5800000000004 L 388.19999999999993 403.2600000000004 L 388.86999999999995 402.3200000000004 L 389.28 401.1900000000004 L 389.53999999999996 401.0000000000004 L 390.09 401.0500000000004 L 390.45 401.4400000000004 L 390.7 402.4000000000004 L 390.71 405.18000000000035 L 391.90999999999997 405.7100000000003 L 392.32 405.26000000000033 L 392.05 402.7200000000003 L 392.54 401.5300000000003 L 392.99 401.0500000000003 L 401.17 400.3800000000003 L 402.18 399.1300000000003 L 403.68 400.59000000000026 L 404.8 401.02000000000027 L 407.58 400.33000000000027 L 408.02 399.34000000000026 L 407.82 398.8800000000003 L 408.13 398.27000000000027 L 410.51 398.16000000000025 L 412.17 398.9400000000002 L 413.02000000000004 398.30000000000024 L 414.33000000000004 398.0100000000002 L 417.59000000000003 401.36000000000024 L 417.79 402.40000000000026 L 417.22 403.41000000000025 L 416.93 405.78000000000026 L 417.51 406.39000000000027 L 419.4 407.60000000000025 L 419.79999999999995 409.15000000000026 L 419.73999999999995 409.71000000000026 L 418.21999999999997 411.74000000000024 L 418.03999999999996 413.68000000000023 L 418.83 414.42000000000024 L 419.14 415.03000000000026 L 419.51 417.24000000000024 L 420.81 419.04000000000025 L 421.64 421.03000000000026 L 421.61 421.8800000000003 L 423.22 421.83000000000027 L 424 421.52000000000027 L 424.28 421.16000000000025 L 425.28 421.11000000000024 L 428.97999999999996 422.43000000000023 L 429.21 422.80000000000024 L 429.15999999999997 424.0700000000002 L 428.46 426.2500000000002 L 426.59999999999997 428.97000000000025 L 426.85999999999996 431.91000000000025 L 426.66999999999996 435.36000000000024 L 426.14 436.92000000000024 L 426.86 438.52000000000027 L 428.64 439.7600000000003 L 430.45 440.59000000000026 L 430.96 442.3100000000003 L 429.75 443.0100000000003 L 431.77 446.3200000000003 L 432.9 446.5700000000003 L 434.90999999999997 446.33000000000027 L 435.09 446.86000000000024 L 438.71 445.86000000000024 L 439.27 446.28000000000026 L 440.58 445.96000000000026 L 441.33 444.98000000000025 L 441.38 444.14000000000027 L 441.14 443.90000000000026 L 441.31 441.60000000000025 L 442.5 441.27000000000027 L 442.59 441.6200000000003 L 442.23999999999995 442.1100000000003 L 442.24999999999994 442.5900000000003 L 444.5899999999999 442.6700000000003 L 446.9799999999999 442.4200000000003 L 448.7699999999999 441.7500000000003 L 449.99999999999994 440.5100000000003 L 451.92999999999995 439.4900000000003 L 454.13999999999993 439.27000000000027 L 455.37999999999994 438.54000000000025 L 455.37999999999994 438.54000000000025 L 456.6499999999999 439.08000000000027 L 457.2099999999999 440.2500000000003 L 458.43999999999994 441.84000000000026 L 460.2099999999999 442.23000000000025 L 463.3599999999999 441.7000000000003 L 465.0599999999999 441.71000000000026 L 465.8099999999999 443.35000000000025 L 464.1599999999999 445.5000000000002 L 462.6599999999999 446.2100000000002 L 459.88999999999993 446.5700000000002 L 459.38999999999993 446.42000000000024 L 457.0399999999999 447.43000000000023 L 455.94999999999993 448.5800000000002 L 454.85999999999996 452.0800000000002 L 454.90999999999997 452.49000000000024 L 456.53999999999996 454.22000000000025 L 457.02 454.48000000000025 L 457.02 454.48000000000025 L 456.96 454.68000000000023 L 455.27 455.10000000000025 L 454.21 454.28000000000026 L 452.72999999999996 455.39000000000027 L 452.29999999999995 456.04000000000025 L 452.56999999999994 456.2600000000003 L 451.80999999999995 456.90000000000026 L 448.5899999999999 458.4500000000003 L 446.3399999999999 459.15000000000026 L 446.05999999999995 459.59000000000026 L 446.09999999999997 460.55000000000024 L 446.59999999999997 462.10000000000025 L 446.28 462.52000000000027 L 444.88 462.78000000000026 L 444.18 462.14000000000027 L 442.84000000000003 461.85000000000025 L 439.72 461.35000000000025 L 438.86 461.5000000000002 L 437.54 461.8400000000002 L 435.81 462.6600000000002 L 435.31 463.1700000000002 L 434.1 465.32000000000016 L 432.79 465.89000000000016 L 432.29 465.77000000000015 L 432.87 465.3000000000001 L 432.39 464.0800000000001 L 431.21999999999997 463.2300000000001 L 430.39 464.4600000000001 L 430.65 465.2100000000001 L 430.34999999999997 465.8200000000001 L 422.72999999999996 470.0600000000001 L 421.78 470.8800000000001 L 421.46999999999997 472.04000000000013 L 418.2 475.04000000000013 L 414.95 476.9900000000001 L 413.03 477.5200000000001 L 408.53 480.7300000000001 L 406.2 482.69000000000005 L 405.53 482.77000000000004 L 405.09 483.39000000000004 L 405.98999999999995 483.82000000000005 L 406.65 483.88000000000005 L 407.58 483.52000000000004 L 407.58 484.28000000000003 L 406.96 485.59000000000003 L 405.64 486.44000000000005 L 404.58 487.92 z M 448.89 464.91 L 447.34999999999997 464.26000000000005 L 446.18999999999994 464.44000000000005 L 445.69999999999993 464.06000000000006 L 445.79999999999995 463.2800000000001 L 446.74999999999994 462.6300000000001 L 447.8399999999999 460.7800000000001 L 448.55999999999995 461.0300000000001 L 449.21999999999997 461.68000000000006 L 449.34999999999997 464.5900000000001 L 448.89 464.91 z"},{code:"TO",name:"Tocantins",gTransform:"matrix(1 0 0 1 95.98 -93.17)",pathTransform:"translate(-401.98, -226.09)",d:"M 433.35 281.82 L 427.99 283.24 L 426.25 284.58 L 423.69 285.68 L 422.14 285.68 L 417.61 286.68 L 415.09 288.76 L 413.31 289.66 L 412.85 289.42 L 411.34 286.8 L 410.79 286.77 L 410.28 290.07 L 409.59 290.15 L 406.24 289.47 L 403.11 288 L 403.67 286.44 L 403.45 285.7 L 398.92 286.23 L 396.16 285.89 L 395.6 286.43 L 395.3 287.43 L 394.55 288.18 L 393.41 288.13 L 392.8 285.03 L 391.69 281.32 L 390.65 279.44 L 389.5 278.13 L 388.32 279.1 L 386.85 281.49 L 385.22 287.43 L 384.59 287.66 L 380.52 286.23 L 377.43 284.52 L 373.5 284.12 L 371.3 283.09 L 368.9 282.69 L 369.42 280.35 L 370.64 278.47 L 370.67 276.76 L 370.11 277.06 L 368.3 279.15 L 367.64 280.38 L 367.44 282.26 L 367.1 282.71 L 367.1 282.71 L 366.3 282.69 L 365.34 282.18 L 364.36 278.84 L 365.1 276.08 L 364.66 273.03 L 364.14 272.45 L 364.13 270.88 L 364.6 267.57 L 363.5 265.32 L 363.55 264.82 L 364.37 263.93 L 364.53 263.06 L 363.14 261.72 L 363.08 260.86 L 364.96 254.87 L 365 251.92 L 365.54 248.95 L 367.48 243.66 L 367.85 243.39 L 368.28 242.54 L 368.72 239.4 L 369.82 238.15 L 370.38 236.26 L 371.03 235.24 L 371.03 235.24 L 372.65 231.55 L 373.78 227.1 L 374.93 225.52 L 376.12 224.42 L 377.33 222.74 L 378.36 220.82 L 379.73 219.9 L 380.78 219.74 L 381.51 218.89 L 382.45 217.35 L 382.63 216.36 L 384.33 213.12 L 385.42 212.32 L 387.18 207.17 L 387.84 203.13 L 387.69 202.83 L 386.95 202.51 L 385.28 200.77 L 384.68 199.82 L 384.52 198.94 L 384.66 198.37 L 386.07 196.68 L 387.36 194.58 L 387.3 191.91 L 386.87 189.73 L 387.06 189.38 L 389.53 187.6 L 392.94 186.46 L 395.44 185.25 L 395.68 184.75 L 395.53 183.24 L 396.39 181.97 L 397.9 180.63 L 399.19 180.48 L 399.38 179.14 L 399.09 177.94 L 399.34 177.48 L 400.8 177.02 L 401.44 176.54 L 402.37 173.79 L 401.35 172.45 L 401.26 171.05 L 401.55 170.77 L 402.52 170.69 L 403.24 170.32 L 403.61 169.66 L 403.64 169.02 L 402.38 167.85 L 401.51 167.71 L 401.12 167.4 L 400.1 165.74 L 398.81 165.62 L 396.94 165.87 L 394.65 165.06 L 394.65 165.06 L 395.18 164.42 L 397.8 162.57 L 399.76 162.04 L 400.63 162.09 L 403.41 163.61 L 404.81 163.69 L 405.76 163.17 L 407.5 163.46 L 408.09 164.15 L 408.17 165.18 L 408.45 165.5 L 409.67 165.53 L 413.07 166.96 L 413.91 167.99 L 414.38 171.49 L 415.02 172.99 L 414.81 176.71 L 415.04 177.79 L 415.71 178.92 L 415.7 179.36 L 413.93 185.51 L 413.62 187.88 L 413.9 188.88 L 413.65 190.47 L 411.9 192.51 L 410.14 193.18 L 409.96 193.89 L 411.9 195.21 L 412.32 194.94 L 413.69 195.18 L 413.94 195.53 L 414.05 196.41 L 413.43 197.6 L 414.28 199.04 L 415.16 198.97 L 418.16 203.13 L 419.07 203.98 L 421.35 207 L 423.49 205.66 L 427.76 204.72 L 429.56 205.94 L 429.64 207.69 L 429 210.94 L 429.39 212.29 L 426 212.64 L 424.66 213.18 L 424.09 213.73 L 423.41 215.16 L 422.68 217.84 L 423.05 219.14 L 420.42 221.69 L 420.16 222.39 L 420.36 222.81 L 422.44 223.1 L 423.38 223.79 L 424.12 225.38 L 424.18 227.04 L 424.8 228.08 L 428.68 230.03 L 428.77 230.56 L 427.13 232.37 L 427.26 234.02 L 429.4 235.64 L 430.39 238.51 L 431.73 240.51 L 432.44 240.69 L 434.22 240.48 L 435.22 240.78 L 436.04 241.22 L 436.65 242.04 L 437.93 242.7 L 437.93 242.7 L 440.87 242.91 L 440.87 242.91 L 440.18 243.56 L 439.96 244.54 L 439.4 245.01 L 435.58 247.03 L 432.37 249.65 L 432.18 250.02 L 433.47 251.82 L 433.11 252.21 L 432.1 252.48 L 431.2 253.09 L 429.68 256.58 L 428.67 257.3 L 428.17 258.46 L 428.4 259.38 L 430.26 261.33 L 433.85 262 L 435.72 262.99 L 435.77 263.75 L 435.21 264.2 L 433.17 265.01 L 432.74 265.97 L 432.83 266.47 L 433.18 266.8 L 434.21 266.62 L 435.13 266.91 L 435.71 267.42 L 436 268.06 L 435.04 268.77 L 433.89 269.19 L 431.94 270.86 L 431.75 271.71 L 431.7 274.63 L 432.05 275.88 L 432.99 276.54 L 434.04 276.78 L 434.45 277.03 L 434.62 277.45 L 434.67 278.51 L 433.31 280.89 z"}];function qD({selected:t,onSelect:e}){const s=re(),[n,i]=A.useState(HD),o=a=>{if(a)try{const l=a.getBBox();if(!l.width||!l.height)return;const c=Math.max(l.width,l.height)*.04,d=`${l.x-c} ${l.y-c} ${l.width+c*2} ${l.height+c*2}`;i(h=>h===d?h:d)}catch{}};return r.jsx("svg",{ref:o,viewBox:n,role:"group","aria-label":s("sectionsEditor.brazilMap.ariaLabel"),className:"h-72 w-full rounded-md border border-border/60 bg-muted/20",children:r.jsx("g",{transform:WD,children:Su.map(a=>{const l=a.code===t;return r.jsx("g",{transform:a.gTransform,children:r.jsx("path",{d:a.d,transform:a.pathTransform,role:"button",tabIndex:0,"aria-label":a.name,"aria-pressed":l,onClick:()=>e(a.code),onKeyDown:c=>{(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),e(a.code))},className:ie("cursor-pointer stroke-background outline-none transition-colors [stroke-width:1] [vector-effect:non-scaling-stroke]","hover:fill-primary/50 focus-visible:fill-primary/50",l?"fill-primary":"fill-muted-foreground/40")})},a.code)})})})}const GD=[{code:"AF",name:"Afghanistan"},{code:"AX",name:"Åland Islands"},{code:"AL",name:"Albania"},{code:"DZ",name:"Algeria"},{code:"AS",name:"American Samoa"},{code:"AD",name:"Andorra"},{code:"AO",name:"Angola"},{code:"AI",name:"Anguilla"},{code:"AQ",name:"Antarctica"},{code:"AG",name:"Antigua & Barbuda"},{code:"AR",name:"Argentina"},{code:"AM",name:"Armenia"},{code:"AW",name:"Aruba"},{code:"AU",name:"Australia"},{code:"AT",name:"Austria"},{code:"AZ",name:"Azerbaijan"},{code:"BS",name:"Bahamas"},{code:"BH",name:"Bahrain"},{code:"BD",name:"Bangladesh"},{code:"BB",name:"Barbados"},{code:"BY",name:"Belarus"},{code:"BE",name:"Belgium"},{code:"BZ",name:"Belize"},{code:"BJ",name:"Benin"},{code:"BM",name:"Bermuda"},{code:"BT",name:"Bhutan"},{code:"BO",name:"Bolivia"},{code:"BA",name:"Bosnia & Herzegovina"},{code:"BW",name:"Botswana"},{code:"BV",name:"Bouvet Island"},{code:"BR",name:"Brazil"},{code:"VG",name:"British Virgin Islands"},{code:"BN",name:"Brunei"},{code:"BG",name:"Bulgaria"},{code:"BF",name:"Burkina Faso"},{code:"BI",name:"Burundi"},{code:"KH",name:"Cambodia"},{code:"CM",name:"Cameroon"},{code:"CA",name:"Canada"},{code:"CV",name:"Cape Verde"},{code:"BQ",name:"Caribbean Netherlands"},{code:"KY",name:"Cayman Islands"},{code:"CF",name:"Central African Republic"},{code:"TD",name:"Chad"},{code:"IO",name:"Chagos Archipelago"},{code:"CL",name:"Chile"},{code:"CN",name:"China mainland"},{code:"CX",name:"Christmas Island"},{code:"CC",name:"Cocos (Keeling) Islands"},{code:"CO",name:"Colombia"},{code:"KM",name:"Comoros"},{code:"CG",name:"Congo - Brazzaville"},{code:"CD",name:"Congo - Kinshasa"},{code:"CK",name:"Cook Islands"},{code:"CR",name:"Costa Rica"},{code:"CI",name:"Côte d’Ivoire"},{code:"HR",name:"Croatia"},{code:"CU",name:"Cuba"},{code:"CW",name:"Curaçao"},{code:"CY",name:"Cyprus"},{code:"CZ",name:"Czechia"},{code:"DK",name:"Denmark"},{code:"DJ",name:"Djibouti"},{code:"DM",name:"Dominica"},{code:"DO",name:"Dominican Republic"},{code:"EC",name:"Ecuador"},{code:"EG",name:"Egypt"},{code:"SV",name:"El Salvador"},{code:"GQ",name:"Equatorial Guinea"},{code:"ER",name:"Eritrea"},{code:"EE",name:"Estonia"},{code:"SZ",name:"Eswatini"},{code:"ET",name:"Ethiopia"},{code:"FK",name:"Falkland Islands"},{code:"FO",name:"Faroe Islands"},{code:"FJ",name:"Fiji"},{code:"FI",name:"Finland"},{code:"FR",name:"France"},{code:"GF",name:"French Guiana"},{code:"PF",name:"French Polynesia"},{code:"TF",name:"French Southern Territories"},{code:"GA",name:"Gabon"},{code:"GM",name:"Gambia"},{code:"GE",name:"Georgia"},{code:"DE",name:"Germany"},{code:"GH",name:"Ghana"},{code:"GI",name:"Gibraltar"},{code:"GR",name:"Greece"},{code:"GL",name:"Greenland"},{code:"GD",name:"Grenada"},{code:"GP",name:"Guadeloupe"},{code:"GU",name:"Guam"},{code:"GT",name:"Guatemala"},{code:"GG",name:"Guernsey"},{code:"GN",name:"Guinea"},{code:"GW",name:"Guinea-Bissau"},{code:"GY",name:"Guyana"},{code:"HT",name:"Haiti"},{code:"HM",name:"Heard & McDonald Islands"},{code:"HN",name:"Honduras"},{code:"HK",name:"Hong Kong"},{code:"HU",name:"Hungary"},{code:"IS",name:"Iceland"},{code:"IN",name:"India"},{code:"ID",name:"Indonesia"},{code:"IR",name:"Iran"},{code:"IQ",name:"Iraq"},{code:"IE",name:"Ireland"},{code:"IM",name:"Isle of Man"},{code:"IL",name:"Israel"},{code:"IT",name:"Italy"},{code:"JM",name:"Jamaica"},{code:"JP",name:"Japan"},{code:"JE",name:"Jersey"},{code:"JO",name:"Jordan"},{code:"KZ",name:"Kazakhstan"},{code:"KE",name:"Kenya"},{code:"KI",name:"Kiribati"},{code:"KW",name:"Kuwait"},{code:"KG",name:"Kyrgyzstan"},{code:"LA",name:"Laos"},{code:"LV",name:"Latvia"},{code:"LB",name:"Lebanon"},{code:"LS",name:"Lesotho"},{code:"LR",name:"Liberia"},{code:"LY",name:"Libya"},{code:"LI",name:"Liechtenstein"},{code:"LT",name:"Lithuania"},{code:"LU",name:"Luxembourg"},{code:"MO",name:"Macao"},{code:"MG",name:"Madagascar"},{code:"MW",name:"Malawi"},{code:"MY",name:"Malaysia"},{code:"MV",name:"Maldives"},{code:"ML",name:"Mali"},{code:"MT",name:"Malta"},{code:"MH",name:"Marshall Islands"},{code:"MQ",name:"Martinique"},{code:"MR",name:"Mauritania"},{code:"MU",name:"Mauritius"},{code:"YT",name:"Mayotte"},{code:"MX",name:"Mexico"},{code:"FM",name:"Micronesia"},{code:"MD",name:"Moldova"},{code:"MC",name:"Monaco"},{code:"MN",name:"Mongolia"},{code:"ME",name:"Montenegro"},{code:"MS",name:"Montserrat"},{code:"MA",name:"Morocco"},{code:"MZ",name:"Mozambique"},{code:"MM",name:"Myanmar (Burma)"},{code:"NA",name:"Namibia"},{code:"NR",name:"Nauru"},{code:"NP",name:"Nepal"},{code:"NL",name:"Netherlands"},{code:"NC",name:"New Caledonia"},{code:"NZ",name:"New Zealand"},{code:"NI",name:"Nicaragua"},{code:"NE",name:"Niger"},{code:"NG",name:"Nigeria"},{code:"NU",name:"Niue"},{code:"NF",name:"Norfolk Island"},{code:"KP",name:"North Korea"},{code:"MK",name:"North Macedonia"},{code:"MP",name:"Northern Mariana Islands"},{code:"NO",name:"Norway"},{code:"OM",name:"Oman"},{code:"PK",name:"Pakistan"},{code:"PW",name:"Palau"},{code:"PS",name:"Palestinian Territories"},{code:"PA",name:"Panama"},{code:"PG",name:"Papua New Guinea"},{code:"PY",name:"Paraguay"},{code:"PE",name:"Peru"},{code:"PH",name:"Philippines"},{code:"PN",name:"Pitcairn Islands"},{code:"PL",name:"Poland"},{code:"PT",name:"Portugal"},{code:"PR",name:"Puerto Rico"},{code:"QA",name:"Qatar"},{code:"RE",name:"Réunion"},{code:"RO",name:"Romania"},{code:"RU",name:"Russia"},{code:"RW",name:"Rwanda"},{code:"WS",name:"Samoa"},{code:"SM",name:"San Marino"},{code:"ST",name:"São Tomé & Príncipe"},{code:"SA",name:"Saudi Arabia"},{code:"SN",name:"Senegal"},{code:"RS",name:"Serbia"},{code:"SC",name:"Seychelles"},{code:"SL",name:"Sierra Leone"},{code:"SG",name:"Singapore"},{code:"SX",name:"Sint Maarten"},{code:"SK",name:"Slovakia"},{code:"SI",name:"Slovenia"},{code:"GS",name:"So. Georgia & So. Sandwich Isl."},{code:"SB",name:"Solomon Islands"},{code:"SO",name:"Somalia"},{code:"ZA",name:"South Africa"},{code:"KR",name:"South Korea"},{code:"SS",name:"South Sudan"},{code:"ES",name:"Spain"},{code:"LK",name:"Sri Lanka"},{code:"BL",name:"St. Barthélemy"},{code:"SH",name:"St. Helena"},{code:"KN",name:"St. Kitts & Nevis"},{code:"LC",name:"St. Lucia"},{code:"MF",name:"St. Martin"},{code:"PM",name:"St. Pierre & Miquelon"},{code:"VC",name:"St. Vincent & Grenadines"},{code:"SD",name:"Sudan"},{code:"SR",name:"Suriname"},{code:"SJ",name:"Svalbard & Jan Mayen"},{code:"SE",name:"Sweden"},{code:"CH",name:"Switzerland"},{code:"SY",name:"Syria"},{code:"TW",name:"Taiwan"},{code:"TJ",name:"Tajikistan"},{code:"TZ",name:"Tanzania"},{code:"TH",name:"Thailand"},{code:"TL",name:"Timor-Leste"},{code:"TG",name:"Togo"},{code:"TK",name:"Tokelau"},{code:"TO",name:"Tonga"},{code:"T1",name:"Tor network (Cloudflare)"},{code:"TT",name:"Trinidad & Tobago"},{code:"TN",name:"Tunisia"},{code:"TR",name:"Türkiye"},{code:"TM",name:"Turkmenistan"},{code:"TC",name:"Turks & Caicos Islands"},{code:"TV",name:"Tuvalu"},{code:"UM",name:"U.S. Outlying Islands"},{code:"VI",name:"U.S. Virgin Islands"},{code:"UG",name:"Uganda"},{code:"UA",name:"Ukraine"},{code:"AE",name:"United Arab Emirates"},{code:"GB",name:"United Kingdom"},{code:"US",name:"United States"},{code:"XX",name:"Unknown (Cloudflare could not determine)"},{code:"UY",name:"Uruguay"},{code:"UZ",name:"Uzbekistan"},{code:"VU",name:"Vanuatu"},{code:"VA",name:"Vatican City"},{code:"VE",name:"Venezuela"},{code:"VN",name:"Vietnam"},{code:"WF",name:"Wallis & Futuna"},{code:"EH",name:"Western Sahara"},{code:"YE",name:"Yemen"},{code:"ZM",name:"Zambia"},{code:"ZW",name:"Zimbabwe"}],YD="BR";function JD(t){if(!t)return!1;const e=Object.keys(t).sort();return e.length===3&&e[0]==="city"&&e[1]==="country"&&e[2]==="regionCode"}function XD(t){const e=t&&typeof t=="object"&&!Array.isArray(t)?t:{};return{city:typeof e.city=="string"?e.city:"",regionCode:typeof e.regionCode=="string"?e.regionCode:"",country:typeof e.country=="string"?e.country:""}}function QD(t,e){const s={...t,...e},n={};for(const i of["city","regionCode","country"])s[i]&&(n[i]=s[i]);return n}function Ff(t){const e=F.c(37),{id:s,options:n,value:i,placeholder:o,emptyMessage:a,onChange:l}=t,[c,d]=A.useState(!1);let h;if(e[0]!==n||e[1]!==i){let j;e[3]!==i?(j=S=>S.value===i,e[3]=i,e[4]=j):j=e[4],h=n.find(j),e[0]=n,e[1]=i,e[2]=h}else h=e[2];const u=h;let f;e[5]!==o||e[6]!==u?(f=u?r.jsx("span",{className:"truncate",children:u.label}):r.jsx("span",{className:"text-muted-foreground",children:o}),e[5]=o,e[6]=u,e[7]=f):f=e[7];let m;e[8]===Symbol.for("react.memo_cache_sentinel")?(m=r.jsx(x9,{className:"size-4 shrink-0 opacity-50"}),e[8]=m):m=e[8];let p;e[9]!==s||e[10]!==c||e[11]!==f?(p=r.jsx(Es,{asChild:!0,children:r.jsxs(le,{id:s,variant:"outline",role:"combobox","aria-expanded":c,className:"h-10 w-full justify-between font-normal",children:[f,m]})}),e[9]=s,e[10]=c,e[11]=f,e[12]=p):p=e[12];let g;e[13]===Symbol.for("react.memo_cache_sentinel")?(g={width:"var(--radix-popover-trigger-width)"},e[13]=g):g=e[13];let x;e[14]!==o?(x=r.jsx($i,{placeholder:o,className:"h-9"}),e[14]=o,e[15]=x):x=e[15];let v;e[16]!==a?(v=r.jsx(Qn,{children:a}),e[16]=a,e[17]=v):v=e[17];let b;if(e[18]!==l||e[19]!==n||e[20]!==i){let j;e[22]!==l||e[23]!==i?(j=S=>r.jsxs(Vs,{value:`${S.label} ${S.value}`,onSelect:()=>{l(S.value===i?"":S.value),d(!1)},children:[r.jsx("span",{className:"truncate",children:S.label}),r.jsx(zt,{className:ie("ml-auto size-4 shrink-0",i===S.value?"opacity-100":"opacity-0")})]},S.value),e[22]=l,e[23]=i,e[24]=j):j=e[24],b=n.map(j),e[18]=l,e[19]=n,e[20]=i,e[21]=b}else b=e[21];let y;e[25]!==b?(y=r.jsx(Ms,{children:b}),e[25]=b,e[26]=y):y=e[26];let _;e[27]!==v||e[28]!==y?(_=r.jsxs(Fi,{children:[v,y]}),e[27]=v,e[28]=y,e[29]=_):_=e[29];let L;e[30]!==_||e[31]!==x?(L=r.jsx(Ps,{className:"p-0",style:g,children:r.jsxs(Tr,{children:[x,_]})}),e[30]=_,e[31]=x,e[32]=L):L=e[32];let w;return e[33]!==c||e[34]!==L||e[35]!==p?(w=r.jsxs(As,{open:c,onOpenChange:d,children:[p,L]}),e[33]=c,e[34]=L,e[35]=p,e[36]=w):w=e[36],w}const ZD=GD.map(t=>({value:t.code,label:`${t.name} (${t.code})`})),eI=Su.map(t=>({value:t.code,label:`${t.name} (${t.code})`}));function y4(t){const e=F.c(68),{schema:s,value:n,onChange:i,path:o}=t,a=re();let l;e[0]!==n?(l=XD(n),e[0]=n,e[1]=l):l=e[1];const c=l,{city:d,regionCode:h,country:u}=c;let f;e[2]!==s.properties?(f=s.properties??{},e[2]=s.properties,e[3]=f):f=e[3];const m=f;let p;e[4]!==m.country?.title||e[5]!==a?(p=m.country?.title??a("sectionsEditor.locationField.countryDefault"),e[4]=m.country?.title,e[5]=a,e[6]=p):p=e[6];const g=p;let x;e[7]!==m.regionCode?.title||e[8]!==a?(x=m.regionCode?.title??a("sectionsEditor.locationField.regionDefault"),e[7]=m.regionCode?.title,e[8]=a,e[9]=x):x=e[9];const v=x;let b;e[10]!==m.city?.title||e[11]!==a?(b=m.city?.title??a("sectionsEditor.locationField.cityDefault"),e[10]=m.city?.title,e[11]=a,e[12]=b):b=e[12];const y=b;let _;e[13]!==c||e[14]!==i?(_=S=>{i(QD(c,S))},e[13]=c,e[14]=i,e[15]=_):_=e[15];const L=_,w=u===YD;let j;if(e[16]!==d||e[17]!==y||e[18]!==u||e[19]!==g||e[20]!==L||e[21]!==w||e[22]!==o||e[23]!==h||e[24]!==v||e[25]!==s.description||e[26]!==s.title||e[27]!==a){let S;e[29]!==h?(S=K=>K.code===h,e[29]=h,e[30]=S):S=e[30];const C=Su.find(S),N=`${o}.country`;let V;e[31]!==s.title||e[32]!==a?(V=s.title??a("sectionsEditor.locationField.locationDefault"),e[31]=s.title,e[32]=a,e[33]=V):V=e[33];let E;e[34]!==V||e[35]!==N?(E=r.jsx(lt,{htmlFor:N,children:V}),e[34]=V,e[35]=N,e[36]=E):E=e[36];let T;e[37]!==s.description?(T=s.description&&r.jsx("p",{className:"text-xs leading-normal text-muted-foreground",children:s.description}),e[37]=s.description,e[38]=T):T=e[38];let k;e[39]!==E||e[40]!==T?(k=r.jsxs("div",{className:"space-y-0.5",children:[E,T]}),e[39]=E,e[40]=T,e[41]=k):k=e[41];const R=`${o}.country`;let P;e[42]!==g||e[43]!==R?(P=r.jsx(lt,{htmlFor:R,className:"text-xs",children:g}),e[42]=g,e[43]=R,e[44]=P):P=e[44];const D=`${o}.country`;let I;e[45]!==a?(I=a("sectionsEditor.locationField.selectCountryPlaceholder"),e[45]=a,e[46]=I):I=e[46];let M;e[47]!==a?(M=a("sectionsEditor.locationField.noCountryFound"),e[47]=a,e[48]=M):M=e[48];let O;e[49]!==L?(O=K=>L({country:K,regionCode:"",city:""}),e[49]=L,e[50]=O):O=e[50];let $;e[51]!==u||e[52]!==D||e[53]!==I||e[54]!==M||e[55]!==O?($=r.jsx(Ff,{id:D,options:ZD,value:u,placeholder:I,emptyMessage:M,onChange:O}),e[51]=u,e[52]=D,e[53]=I,e[54]=M,e[55]=O,e[56]=$):$=e[56];let B;e[57]!==P||e[58]!==$?(B=r.jsxs("div",{className:"space-y-1.5",children:[P,$]}),e[57]=P,e[58]=$,e[59]=B):B=e[59];let z;e[60]!==u||e[61]!==L||e[62]!==w||e[63]!==o||e[64]!==h||e[65]!==v||e[66]!==a?(z=u&&r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(lt,{htmlFor:`${o}.regionCode`,className:"text-xs",children:v}),w?r.jsxs("div",{className:"space-y-2",children:[r.jsx(qD,{selected:h,onSelect:K=>L({regionCode:K===h?"":K,city:""})}),r.jsx(Ff,{id:`${o}.regionCode`,options:eI,value:h,placeholder:a("sectionsEditor.locationField.selectStatePlaceholder"),emptyMessage:a("sectionsEditor.locationField.noStateFound"),onChange:K=>L({regionCode:K,city:""})})]}):r.jsxs(r.Fragment,{children:[r.jsx(rt,{id:`${o}.regionCode`,type:"text",value:h,placeholder:a("sectionsEditor.locationField.regionCodePlaceholder"),onChange:K=>L({regionCode:K.target.value})}),r.jsx("p",{className:"text-xs leading-normal text-muted-foreground",children:a("sectionsEditor.locationField.regionCodeHelperText")})]})]}),e[60]=u,e[61]=L,e[62]=w,e[63]=o,e[64]=h,e[65]=v,e[66]=a,e[67]=z):z=e[67],j=r.jsxs("div",{className:"space-y-4",children:[k,B,z,u&&r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(lt,{htmlFor:`${o}.city`,className:"text-xs",children:y}),r.jsx(rt,{id:`${o}.city`,type:"text",value:d,placeholder:w&&C?a("sectionsEditor.locationField.cityPlaceholderWithState",{state:C.name}):a("sectionsEditor.locationField.cityPlaceholder"),onChange:K=>L({city:K.target.value})}),r.jsx("p",{className:"text-xs leading-normal text-muted-foreground",children:a("sectionsEditor.locationField.cityHelperText")})]})]}),e[16]=d,e[17]=y,e[18]=u,e[19]=g,e[20]=L,e[21]=w,e[22]=o,e[23]=h,e[24]=v,e[25]=s.description,e[26]=s.title,e[27]=a,e[28]=j}else j=e[28];return j}function tI(t){const e=t.schema;if(!e?.properties)return null;const s=new Set(Object.keys(t.discriminators??{}));if(s.size===0)return e;const n={};for(const[i,o]of Object.entries(e.properties))s.has(i)||(n[i]=o);return{...e,properties:n}}function sI(t){const e=F.c(50),s=re(),{schema:n,value:i,onChange:o,path:a,label:l}=t;let c,d;e[0]!==n.inlineUnionBranches||e[1]!==i?(c=n.inlineUnionBranches??[],d=KD(i,c.map(iI)),e[0]=n.inlineUnionBranches,e[1]=i,e[2]=c,e[3]=d):(c=e[2],d=e[3]);const h=d,[u,f]=A.useState(h),[m,p]=A.useState(h);m!==h&&(p(h),f(h));const g=Math.min(u,c.length-1),x=c[g];let v;e[4]!==c||e[5]!==o?(v=M=>{const O=Number(M);f(O),o({...c[O]?.discriminators??{}})},e[4]=c,e[5]=o,e[6]=v):v=e[6];const b=v;if(c.length===0)return null;let y;e[7]!==x?(y=x?tI(x):null,e[7]=x,e[8]=y):y=e[8];const _=y;let L;if(e[9]!==x?.schema?.properties||e[10]!==i){let M;e[12]!==x?.schema?.properties?(M=x?.schema?.properties??{},e[12]=x?.schema?.properties,e[13]=M):M=e[13],L=UD(i,Object.keys(M)),e[9]=x?.schema?.properties,e[10]=i,e[11]=L}else L=e[11];const w=L;let j;e[14]!==l||e[15]!==a?(j=r.jsx(lt,{htmlFor:a,children:l}),e[14]=l,e[15]=a,e[16]=j):j=e[16];const S=String(g);let C;e[17]!==s?(C=s("sectionsEditor.inlineUnionField.selectPlaceholder"),e[17]=s,e[18]=C):C=e[18];let N;e[19]!==C?(N=r.jsx(as,{placeholder:C}),e[19]=C,e[20]=N):N=e[20];let V;e[21]!==a||e[22]!==N?(V=r.jsx(Jt,{id:a,children:N}),e[21]=a,e[22]=N,e[23]=V):V=e[23];let E;e[24]!==c?(E=c.map(nI),e[24]=c,e[25]=E):E=e[25];let T;e[26]!==E?(T=r.jsx(Xt,{children:E}),e[26]=E,e[27]=T):T=e[27];let k;e[28]!==b||e[29]!==T||e[30]!==S||e[31]!==V?(k=r.jsxs(Qt,{value:S,onValueChange:b,children:[V,T]}),e[28]=b,e[29]=T,e[30]=S,e[31]=V,e[32]=k):k=e[32];let R;e[33]!==n.description?(R=n.description&&r.jsx("p",{className:"text-xs text-muted-foreground",children:n.description}),e[33]=n.description,e[34]=R):R=e[34];let P;e[35]!==k||e[36]!==R||e[37]!==j?(P=r.jsxs("div",{className:"space-y-1.5",children:[j,k,R]}),e[35]=k,e[36]=R,e[37]=j,e[38]=P):P=e[38];let D;e[39]!==x||e[40]!==_||e[41]!==o||e[42]!==a||e[43]!==w||e[44]!==t||e[45]!==i?(D=x&&(JD(x.schema?.properties)?r.jsx(y4,{...t,schema:x.schema,onChange:M=>o({...w,...M,...x.discriminators??{}})}):_?r.jsx(In,{schema:_,value:i,onChange:M=>o({...M,...x.discriminators??{}}),basePath:a,breadcrumbPath:t.breadcrumbPath,onBreadcrumbChange:t.onBreadcrumbChange,meta:t.meta,decofile:t.decofile,onSaveReferencedBlock:t.onSaveReferencedBlock,sandbox:t.sandbox,previewBaseUrl:t.previewBaseUrl,onAddSectionItem:t.onAddSectionItem,onRequestAddSection:t.onRequestAddSection}):null),e[39]=x,e[40]=_,e[41]=o,e[42]=a,e[43]=w,e[44]=t,e[45]=i,e[46]=D):D=e[46];let I;return e[47]!==P||e[48]!==D?(I=r.jsxs("div",{className:"space-y-3",children:[P,D]}),e[47]=P,e[48]=D,e[49]=I):I=e[49],I}function nI(t,e){return r.jsx(vt,{value:String(e),children:t.title},t.title)}function iI(t){return{discriminators:t.discriminators,propertyKeys:Object.keys(t.schema?.properties??{})}}const rI={lat:-21.9,lng:-41.42},Zd=1e5;let Pa=null;function oI(t){return Pa||(Pa=new Promise((e,s)=>{if(typeof window>"u"){s(new Error("Google Maps requires a browser environment"));return}const n=window;if(n.google?.maps){e(n.google.maps);return}const i=()=>{const l=window.google?.maps;l?e(l):s(new Error("Google Maps script loaded without google.maps"))},o=document.querySelector("script[data-google-maps-loader]");if(o){o.addEventListener("load",i),o.addEventListener("error",()=>s(new Error("Failed to load Google Maps")));return}const a=document.createElement("script");a.src=`https://maps.googleapis.com/maps/api/js?key=${t}&v=weekly&libraries=maps`,a.async=!0,a.defer=!0,a.dataset.googleMapsLoader="true",a.addEventListener("load",i),a.addEventListener("error",()=>s(new Error("Failed to load Google Maps"))),document.head.appendChild(a)}),Pa)}function aI(t){if(typeof t!="string"||!t)return null;const e=t.split(",").map(Number),[s,n,i]=e;return!Number.isFinite(s)||!Number.isFinite(n)?null:{lat:s,lng:n,radius:Number.isFinite(i)?i:Zd}}function lI({schema:t,value:e,onChange:s,path:n,label:i}){const o=tm().googleMapsApiKey,a=A.useRef(s);a.current=s;const l=A.useRef(aI(e)),[c,d]=A.useState(null),h=A.useRef(null),u=f=>{if(!f||!o)return;const m={disposed:!1,circle:null,listeners:[]};return oI(o).then(p=>{if(m.disposed)return;const g=l.current,x=g?{lat:g.lat,lng:g.lng}:rI,v=g?.radius??Zd,b=new p.Map(f,{center:x,zoom:v?Math.round(Math.log2(768e4/v))+1:4,draggable:!0,streetViewControl:!1,mapTypeControl:!1}),y=new p.Circle({strokeColor:"#2E6ED9",strokeOpacity:.8,strokeWeight:2,fillColor:"#2E6ED9",fillOpacity:.35,editable:!0,draggable:!0,map:b,center:x,radius:v});m.circle=y;const _=()=>{const w=y.getCenter(),j=y.getRadius();w&&a.current(`${w.lat()},${w.lng()},${j}`)},L=w=>{w&&m.listeners.push(w)};L(b.addListener("click",w=>{w.latLng&&(y.setCenter({lat:w.latLng.lat(),lng:w.latLng.lng()}),y.getRadius()||y.setRadius(Zd),_())})),L(y.addListener("radius_changed",_)),L(y.addListener("dragend",_))},p=>{m.disposed||d(p instanceof Error?p.message:"Failed to load map")}),()=>{m.disposed=!0;for(const p of m.listeners)try{p?.remove()}catch{}if(m.listeners=[],m.circle){try{m.circle.setMap(null)}catch{}m.circle=null}}};return h.current||(h.current=u),r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"space-y-0.5",children:[r.jsx(lt,{htmlFor:n,children:i}),t.description&&r.jsx("p",{className:"text-xs leading-normal text-muted-foreground",children:t.description})]}),o?c?r.jsx("div",{className:"rounded-md border border-destructive/40 bg-destructive/5 px-3 py-2 text-xs text-destructive",children:c}):r.jsx("div",{ref:h.current,id:n,className:"h-72 w-full rounded-md border border-border/60"}):r.jsxs("div",{className:"rounded-md border border-border/60 bg-muted/30 px-3 py-2 text-xs text-muted-foreground",children:["The map picker is unavailable — set"," ",r.jsx("code",{className:"font-mono",children:"GOOGLE_MAPS_API_KEY"})," on the server to enable it."]})]})}const cI="oklch(0.65 0.15 160)",dI="text-[oklch(0.45_0.15_160)] hover:bg-[oklch(0.65_0.15_160/0.12)] dark:text-[oklch(0.78_0.15_160)] dark:hover:bg-[oklch(0.65_0.15_160/0.15)]",L4="text-[oklch(0.45_0.15_160)] bg-[oklch(0.65_0.15_160/0.18)] dark:text-[oklch(0.78_0.15_160)] dark:bg-[oklch(0.65_0.15_160/0.2)]",tW="text-[oklch(0.45_0.15_160)] focus:bg-[oklch(0.65_0.15_160/0.12)] focus:text-[oklch(0.45_0.15_160)] dark:text-[oklch(0.78_0.15_160)] dark:focus:bg-[oklch(0.65_0.15_160/0.15)] dark:focus:text-[oklch(0.78_0.15_160)]";function zf(t){return t.map(e=>e.label).join(`
|
|
481
|
-
`)}function od(t){return t.map(e=>({id:crypto.randomUUID(),index:e.index,label:e.label}))}function uI(t){return t.map((e,s)=>({...e,index:s}))}function S4(t){const e=F.c(19),{label:s,canDelete:n,dragging:i,onRename:o,onDuplicate:a,onDelete:l}=t,c=re(),d=i?"opacity-100":"opacity-0 group-hover:opacity-100";let h;e[0]!==d?(h=ie("h-4 w-4 shrink-0 text-muted-foreground/40 transition-opacity",d),e[0]=d,e[1]=h):h=e[1];let u;e[2]!==h?(u=r.jsx(ia,{className:h}),e[2]=h,e[3]=u):u=e[3];let f;e[4]===Symbol.for("react.memo_cache_sentinel")?(f=r.jsx(Nn,{className:"h-4 w-4 shrink-0",style:{color:cI}}),e[4]=f):f=e[4];let m;e[5]!==s?(m=r.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-medium",children:s}),e[5]=s,e[6]=m):m=e[6];let p;e[7]!==n||e[8]!==i||e[9]!==s||e[10]!==l||e[11]!==a||e[12]!==o||e[13]!==c?(p=!i&&r.jsxs(us,{children:[r.jsx(ds,{asChild:!0,children:r.jsx(le,{type:"button",variant:"ghost",size:"icon","aria-label":c("sectionsEditor.sectionVariantList.openActionsFor",{label:s}),className:"size-6 shrink-0 opacity-0 transition-opacity group-hover:opacity-100 data-[state=open]:opacity-100",onClick:fI,onPointerDown:hI,children:r.jsx(oi,{size:14})})}),r.jsxs(hs,{align:"end",children:[o&&r.jsxs(Xe,{onClick:x=>{x.stopPropagation(),o()},children:[r.jsx(hb,{size:14}),c("sectionsEditor.sectionVariantList.rename")]}),r.jsxs(Xe,{onClick:x=>{x.stopPropagation(),a?.()},children:[r.jsx(Os,{size:14}),c("sectionsEditor.sectionVariantList.duplicate")]}),r.jsxs(Xe,{variant:"destructive",disabled:!n,onClick:x=>{x.stopPropagation(),l?.()},children:[r.jsx(Ns,{size:14}),c("sectionsEditor.sectionVariantList.delete")]})]})]}),e[7]=n,e[8]=i,e[9]=s,e[10]=l,e[11]=a,e[12]=o,e[13]=c,e[14]=p):p=e[14];let g;return e[15]!==u||e[16]!==m||e[17]!==p?(g=r.jsxs(r.Fragment,{children:[u,f,m,p]}),e[15]=u,e[16]=m,e[17]=p,e[18]=g):g=e[18],g}function hI(t){return t.stopPropagation()}function fI(t){return t.stopPropagation()}function mI(t){const e=F.c(27),{entry:s,selected:n,canDelete:i,onSelect:o,onRename:a,onDuplicate:l,onDelete:c}=t;let d;e[0]!==s.id?(d={id:s.id,animateLayoutChanges:pI},e[0]=s.id,e[1]=d):d=e[1];const{attributes:h,listeners:u,setNodeRef:f,transform:m,isDragging:p}=eu(d);let g;e[2]!==m?(g=Ln.Transform.toString(m?{...m,x:0}:null),e[2]=m,e[3]=g):g=e[3];const x=p?0:void 0;let v;e[4]!==g||e[5]!==x?(v={transform:g,opacity:x},e[4]=g,e[5]=x,e[6]=v):v=e[6];const b=v;let y;e[7]!==o?(y=C=>{C.target===C.currentTarget&&(C.key==="Enter"||C.key===" ")&&(C.preventDefault(),o())},e[7]=o,e[8]=y):y=e[8];const _=p?"cursor-grabbing":"cursor-grab",L=n?L4:dI;let w;e[9]!==_||e[10]!==L?(w=ie("group flex select-none items-center gap-2 rounded-md px-2 py-2.5 transition-colors touch-none",_,L),e[9]=_,e[10]=L,e[11]=w):w=e[11];let j;e[12]!==i||e[13]!==s.label||e[14]!==c||e[15]!==l||e[16]!==a?(j=r.jsx(S4,{label:s.label,canDelete:i,onRename:a,onDuplicate:l,onDelete:c}),e[12]=i,e[13]=s.label,e[14]=c,e[15]=l,e[16]=a,e[17]=j):j=e[17];let S;return e[18]!==h||e[19]!==u||e[20]!==o||e[21]!==f||e[22]!==b||e[23]!==y||e[24]!==w||e[25]!==j?(S=r.jsx("div",{ref:f,style:b,...h,...u,onClick:o,onKeyDown:y,className:w,children:j}),e[18]=h,e[19]=u,e[20]=o,e[21]=f,e[22]=b,e[23]=y,e[24]=w,e[25]=j,e[26]=S):S=e[26],S}function pI(){return!1}function gI(t){const e=F.c(103),{listKey:s,variants:n,selectedIndex:i,onSelect:o,onRename:a,onDuplicate:l,onDelete:c,onRemoveAll:d,onReorder:h,onAdd:u}=t,f=re(),m=n.length>1;let p;e[0]!==n?(p=()=>od(n),e[0]=n,e[1]=p):p=e[1];const[g,x]=A.useState(p),[v,b]=A.useState(null),[y,_]=A.useState(s),[L,w]=A.useState(n.length);let j;e[2]!==n?(j=()=>zf(n),e[2]=n,e[3]=j):j=e[3];const[S,C]=A.useState(j),N=A.useRef(!1),V=zf(n);y!==s?(_(s),w(n.length),C(V),x(od(n))):L!==n.length?(w(n.length),C(V),x(od(n))):S!==V&&(C(V),x(ce=>n.map((oe,fe)=>({id:ce[fe]?.id??crypto.randomUUID(),index:oe.index,label:oe.label}))));let E;e[4]===Symbol.for("react.memo_cache_sentinel")?(E={activationConstraint:{distance:8}},e[4]=E):E=e[4];let T;e[5]===Symbol.for("react.memo_cache_sentinel")?(T={coordinateGetter:tu},e[5]=T):T=e[5];const k=fc(ti($r,E),ti(Br,T));let R;e[6]!==g?(R=g.map(xI),e[6]=g,e[7]=R):R=e[7];const P=R;let D;e[8]!==g?(D=ce=>{const oe=String(ce.active.id);b(g.find(fe=>fe.id===oe)??null)},e[8]=g,e[9]=D):D=e[9];const I=D;let M;e[10]!==P||e[11]!==h?(M=ce=>{b(null);const{active:oe,over:fe}=ce;if(!fe||oe.id===fe.id)return;const pe=P.indexOf(String(oe.id)),we=P.indexOf(String(fe.id));pe===-1||we===-1||(x(Ne=>uI(yr([...Ne],pe,we))),N.current=!0,requestAnimationFrame(()=>{N.current=!1}),h(pe,we))},e[10]=P,e[11]=h,e[12]=M):M=e[12];const O=M;let $;e[13]===Symbol.for("react.memo_cache_sentinel")?($=()=>{b(null)},e[13]=$):$=e[13];const B=$;let z,K,G,Y,U,W,H,X,q,Z,Q,ee,J;if(e[14]!==m||e[15]!==g||e[16]!==P||e[17]!==O||e[18]!==I||e[19]!==u||e[20]!==c||e[21]!==l||e[22]!==d||e[23]!==a||e[24]!==o||e[25]!==i||e[26]!==k||e[27]!==f){const ce=Le=>{N.current||o(Le)};Q="space-y-1 border-b p-2";let oe;e[41]!==f?(oe=f("sectionsEditor.sectionVariantList.title"),e[41]=f,e[42]=oe):oe=e[42];let fe;e[43]!==oe?(fe=r.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:oe}),e[43]=oe,e[44]=fe):fe=e[44];let pe;e[45]!==f?(pe=f("sectionsEditor.sectionVariantList.addVariantAriaLabel"),e[45]=f,e[46]=pe):pe=e[46];let we;e[47]===Symbol.for("react.memo_cache_sentinel")?(we=r.jsx(kt,{size:14}),e[47]=we):we=e[47];let Ne;e[48]!==u||e[49]!==pe?(Ne=r.jsx(ze,{asChild:!0,children:r.jsx(le,{type:"button",variant:"ghost",size:"icon","aria-label":pe,className:"size-6",onClick:u,children:we})}),e[48]=u,e[49]=pe,e[50]=Ne):Ne=e[50];let Fe;e[51]!==f?(Fe=f("sectionsEditor.sectionVariantList.addVariant"),e[51]=f,e[52]=Fe):Fe=e[52];let je;e[53]!==Fe?(je=r.jsx(Ke,{children:Fe}),e[53]=Fe,e[54]=je):je=e[54];let Ie;e[55]!==Ne||e[56]!==je?(Ie=r.jsxs(Ue,{children:[Ne,je]}),e[55]=Ne,e[56]=je,e[57]=Ie):Ie=e[57];let Pe;e[58]!==f?(Pe=f("sectionsEditor.sectionVariantList.removeAllVariantsAriaLabel"),e[58]=f,e[59]=Pe):Pe=e[59];let Ye;e[60]===Symbol.for("react.memo_cache_sentinel")?(Ye=r.jsx(Ns,{size:14}),e[60]=Ye):Ye=e[60];let _e;e[61]!==d||e[62]!==Pe?(_e=r.jsx(ze,{asChild:!0,children:r.jsx(le,{type:"button",variant:"ghost",size:"icon","aria-label":Pe,className:"size-6 text-muted-foreground hover:text-destructive",onClick:d,children:Ye})}),e[61]=d,e[62]=Pe,e[63]=_e):_e=e[63];let Ae;e[64]!==f?(Ae=f("sectionsEditor.sectionVariantList.removeAllVariants"),e[64]=f,e[65]=Ae):Ae=e[65];let Re;e[66]!==Ae?(Re=r.jsx(Ke,{children:Ae}),e[66]=Ae,e[67]=Re):Re=e[67];let ye;e[68]!==_e||e[69]!==Re?(ye=r.jsxs(Ue,{children:[_e,Re]}),e[68]=_e,e[69]=Re,e[70]=ye):ye=e[70];let ve;e[71]!==Ie||e[72]!==ye?(ve=r.jsxs("div",{className:"flex items-center gap-0.5",children:[Ie,ye]}),e[71]=Ie,e[72]=ye,e[73]=ve):ve=e[73],e[74]!==fe||e[75]!==ve?(ee=r.jsxs("div",{className:"flex items-center justify-between",children:[fe,ve]}),e[74]=fe,e[75]=ve,e[76]=ee):ee=e[76],K=xc,W=k,H=U9,X=I,q=O,Z=B,z=Z9,Y=P,U=Q9,J="space-y-0.5",G=g.map(Le=>r.jsx(mI,{entry:Le,selected:Le.index===i,canDelete:m,onSelect:()=>ce(Le.index),onRename:a?()=>a(Le.index):void 0,onDuplicate:()=>l(Le.index),onDelete:()=>c(Le.index)},Le.id)),e[14]=m,e[15]=g,e[16]=P,e[17]=O,e[18]=I,e[19]=u,e[20]=c,e[21]=l,e[22]=d,e[23]=a,e[24]=o,e[25]=i,e[26]=k,e[27]=f,e[28]=z,e[29]=K,e[30]=G,e[31]=Y,e[32]=U,e[33]=W,e[34]=H,e[35]=X,e[36]=q,e[37]=Z,e[38]=Q,e[39]=ee,e[40]=J}else z=e[28],K=e[29],G=e[30],Y=e[31],U=e[32],W=e[33],H=e[34],X=e[35],q=e[36],Z=e[37],Q=e[38],ee=e[39],J=e[40];let te;e[77]!==G||e[78]!==J?(te=r.jsx("div",{className:J,children:G}),e[77]=G,e[78]=J,e[79]=te):te=e[79];let se;e[80]!==z||e[81]!==Y||e[82]!==U||e[83]!==te?(se=r.jsx(z,{items:Y,strategy:U,children:te}),e[80]=z,e[81]=Y,e[82]=U,e[83]=te,e[84]=se):se=e[84];let ne;e[85]!==v||e[86]!==m?(ne=v?r.jsx("div",{className:ie("flex items-center gap-2 rounded-md px-2 py-2.5 shadow-lg ring-1 ring-border/60 cursor-grabbing",L4),children:r.jsx(S4,{label:v.label,canDelete:m,dragging:!0})}):null,e[85]=v,e[86]=m,e[87]=ne):ne=e[87];let de;e[88]!==ne?(de=r.jsx(G9,{dropAnimation:null,children:ne}),e[88]=ne,e[89]=de):de=e[89];let xe;e[90]!==K||e[91]!==W||e[92]!==H||e[93]!==X||e[94]!==q||e[95]!==Z||e[96]!==se||e[97]!==de?(xe=r.jsxs(K,{sensors:W,collisionDetection:H,onDragStart:X,onDragEnd:q,onDragCancel:Z,children:[se,de]}),e[90]=K,e[91]=W,e[92]=H,e[93]=X,e[94]=q,e[95]=Z,e[96]=se,e[97]=de,e[98]=xe):xe=e[98];let ue;return e[99]!==Q||e[100]!==ee||e[101]!==xe?(ue=r.jsxs("div",{className:Q,children:[ee,xe]}),e[99]=Q,e[100]=ee,e[101]=xe,e[102]=ue):ue=e[102],ue}function xI(t){return t.id}const vI=[[/always|matchalways/i,"Users03"],[/device|matchdevice/i,"Phone02"],[/date|matchdate/i,"Calendar"],[/random|matchrandom/i,"Shuffle01"],[/host|matchhost/i,"Globe02"],[/location|matchlocation/i,"MarkerPin01"],[/pathname/i,"Link03"],[/cron|matchcron/i,"Clock"],[/multi|matchmulti/i,"FilterLines"],[/never|matchnever/i,"EyeOff"],[/environment|matchenvironment/i,"Cloud01"],[/eq\.ts|\/eq$/i,"Brackets"],[/user|requser|isdecouser/i,"User01"],[/site|template/i,"LayoutAlt01"]],bI={"device-mobile":"Phone02","device-desktop":"Monitor01","device-tablet":"Tablet01","calendar-event":"Calendar","calendar-month":"Calendar",clock:"Clock","current-location":"MarkerPin01","map-2":"MarkerPin01","world-search":"Globe02",shuffle:"Shuffle01",filter:"FilterLines","eye-off":"EyeOff",flask:"Beaker02",link:"Link03","git-merge":"GitBranch01",users:"Users03",flag:"Flag01","cloud-storm":"Cloud01",campaign:"Announcement01",experiment:"Beaker02",language:"Globe02","hand-click":"CursorClick01"};function ad(t){return Oi(t)!==void 0}function wu(t,e){if(e){if(ad(e))return e;const s=bI[e];if(s&&ad(s))return s}for(const[s,n]of vI)if(s.test(t)&&ad(n))return n;return"FilterLines"}function _I(t){return Oi(t)??Hb}function ld(t){const e=F.c(11),{iconName:s,size:n,className:i}=t,o=n===void 0?"md":n;let a;e[0]!==s?(a=_I(s),e[0]=s,e[1]=a):a=e[1];const l=a,c=o==="sm"?"size-7":"size-9",d=o==="sm"?16:18;let h;e[2]!==c||e[3]!==i?(h=ie("flex shrink-0 items-center justify-center rounded-full bg-muted",c,i),e[2]=c,e[3]=i,e[4]=h):h=e[4];let u;e[5]!==l||e[6]!==d?(u=r.jsx(l,{size:d,className:"text-muted-foreground"}),e[5]=l,e[6]=d,e[7]=u):u=e[7];let f;return e[8]!==h||e[9]!==u?(f=r.jsx("div",{className:h,children:u}),e[8]=h,e[9]=u,e[10]=f):f=e[10],f}const yI=t=>t.charAt(0).toUpperCase()+t.slice(1).toLowerCase(),LI=5,SI=new Intl.DateTimeFormat("en",{dateStyle:"medium",timeStyle:"short"});function Kf(t){const{start:e,end:s}=t,n=typeof e=="string"?e:"",i=typeof s=="string"?s:"";if(!n&&!i)return null;const o=c=>{if(!c)return null;const d=new Date(c);return Number.isNaN(d.getTime())?null:SI.format(d)},a=o(n),l=o(i);return a&&l?`${a} → ${l}`:a?`From ${a}`:l?`Until ${l}`:null}function Dl(t,e=0){if(!t)return"Default";if(e>LI)return"...";const s=t.__resolveType??"";if(["website/matchers/always.ts","$live/matchers/MatchAlways.ts"].includes(s)||s==="")return"Default";switch(s){case"website/matchers/never.ts":return"Hidden";case"website/matchers/device.ts":case"$live/matchers/MatchDevice.ts":{const{mobile:i,tablet:o,desktop:a,devices:l=[]}=t,c=[...l];return i&&c.push("Mobile"),o&&c.push("Tablet"),a&&c.push("Desktop"),c.length>0?c.map(yI).join(" & "):Tt(s)}case"website/matchers/date.ts":case"$live/matchers/MatchDate.ts":return Kf(t)??Tt(s);case"website/matchers/random.ts":case"$live/matchers/MatchRandom.ts":{const{traffic:i}=t;return typeof i=="number"?`${Math.ceil(i*100)}% of sessions`:Tt(s)}case"website/matchers/host.ts":case"$live/matchers/MatchHost.ts":{const{includes:i,match:o}=t,a=[];return i&&a.push(i),o&&a.push(o),a.length>0?a.join(" - "):Tt(s)}case"website/matchers/pathname.ts":{const i=t.case,{type:o,pathname:a}=i??{};return o&&a?`Pathname ${o} ${a}`:Tt(s)}case"website/matchers/location.ts":case"$live/matchers/MatchLocation.ts":{const{includeLocations:i,excludeLocations:o}=t,a=d=>[d.city,d.regionCode,d.country].filter(Boolean).join(" - "),l=i?.[0];if(l){const d=(i?.length??0)-1;return`${a(l)}${d>0?` +${d}`:""}`}const c=o?.[0];if(c){const d=(o?.length??0)-1;return`Except ${a(c)}${d>0?` +${d}`:""}`}return"Any location"}case"website/matchers/multi.ts":case"$live/matchers/MatchMulti.ts":{const{matchers:i,op:o="AND"}=t;if(i&&i.length>0){const a=o==="OR"?"OR":"AND";return i.map(l=>Dl(l,e+1)).join(` ${a} `)}return Tt(s)}default:{const i=Kf(t);return i||Tt(s)||"Default"}}}function sW(t,e){return JT(t,e).map(s=>{const n=e[s.blockKey]??{},i=ug(ZT(s.blockKey),e,t);return{blockKey:s.blockKey,title:cc(s.blockKey,n),description:Dl(i),iconName:wu(s.matcherResolveType)}})}const w4="Users03";function wI(t){const e=t.manifest?.blocks??{},s=[];for(const[n,i]of Object.entries(e))if(n.includes("matchers"))for(const o of Object.keys(i)){if(o.includes("always"))continue;const a=li(o,t);s.push({resolveType:o,title:a.title??Tt(o),description:a.description,iconName:wu(o,a.icon)})}return s}function jI(t,e){if(!t)return w4;const s=e.find(n=>n.resolveType===t);return s?s.iconName:wu(t)}function CI(t){const e=F.c(80),{currentRt:s,currentLabel:n,currentGlobalKey:i,matchers:o,globals:a,onSelect:l,onSelectGlobal:c}=t,d=a===void 0?[]:a,[h,u]=A.useState(!1),f=re(),p=(i?d.find(q=>q.blockKey===i):void 0)?.iconName??jI(s,o),g=Oi(p);let x;e[0]!==l||e[1]!==u?(x=q=>{l(q),u(!1)},e[0]=l,e[1]=u,e[2]=x):x=e[2];const v=x;let b;e[3]!==c||e[4]!==u?(b=q=>{c?.(q),u(!1)},e[3]=c,e[4]=u,e[5]=b):b=e[5];const y=b;let _;e[6]!==u?(_=()=>u(!0),e[6]=u,e[7]=_):_=e[7];let L;e[8]!==g?(L=g&&r.jsx(g,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),e[8]=g,e[9]=L):L=e[9];let w;e[10]!==n?(w=r.jsx("span",{className:"flex-1 truncate",children:n}),e[10]=n,e[11]=w):w=e[11];let j;e[12]===Symbol.for("react.memo_cache_sentinel")?(j=r.jsx(ss,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e[12]=j):j=e[12];let S;e[13]!==_||e[14]!==L||e[15]!==w?(S=r.jsxs("button",{type:"button",onClick:_,className:"flex h-10 w-full items-center gap-2 rounded-md border border-input bg-transparent px-3 text-left text-sm shadow-xs transition-colors hover:bg-accent/40 cursor-pointer",children:[L,w,j]}),e[13]=_,e[14]=L,e[15]=w,e[16]=S):S=e[16];let C;e[17]!==f?(C=f("sectionsEditor.matcherPicker.chooseRuleTitle"),e[17]=f,e[18]=C):C=e[18];let N;e[19]!==f?(N=f("sectionsEditor.matcherPicker.chooseRuleDescription"),e[19]=f,e[20]=N):N=e[20];let V;e[21]!==f?(V=f("sectionsEditor.matcherPicker.searchRulesPlaceholder"),e[21]=f,e[22]=V):V=e[22];let E;e[23]!==V?(E=r.jsx($i,{placeholder:V}),e[23]=V,e[24]=E):E=e[24];let T;e[25]!==f?(T=f("sectionsEditor.matcherPicker.noRulesFound"),e[25]=f,e[26]=T):T=e[26];let k;e[27]!==T?(k=r.jsx(Qn,{children:T}),e[27]=T,e[28]=k):k=e[28];let R;e[29]!==v?(R=()=>v(""),e[29]=v,e[30]=R):R=e[30];const P=!s&&!i&&"bg-accent/60";let D;e[31]!==P?(D=ie("gap-2.5",P),e[31]=P,e[32]=D):D=e[32];let I;e[33]===Symbol.for("react.memo_cache_sentinel")?(I=r.jsx(ld,{iconName:w4,size:"sm"}),e[33]=I):I=e[33];let M;e[34]!==f?(M=f("sectionsEditor.matcherPicker.alwaysLabel"),e[34]=f,e[35]=M):M=e[35];let O;e[36]!==M?(O=r.jsx("span",{className:"text-sm",children:M}),e[36]=M,e[37]=O):O=e[37];let $;e[38]!==f?($=f("sectionsEditor.matcherPicker.targetAllUsers"),e[38]=f,e[39]=$):$=e[39];let B;e[40]!==$?(B=r.jsx("span",{className:"text-xs text-muted-foreground",children:$}),e[40]=$,e[41]=B):B=e[41];let z;e[42]!==O||e[43]!==B?(z=r.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[O,B]}),e[42]=O,e[43]=B,e[44]=z):z=e[44];let K;e[45]!==R||e[46]!==D||e[47]!==z?(K=r.jsxs(Vs,{value:"always Target all users",onSelect:R,className:D,children:[I,z]}),e[45]=R,e[46]=D,e[47]=z,e[48]=K):K=e[48];let G;if(e[49]!==i||e[50]!==s||e[51]!==v||e[52]!==o){let q;e[54]!==i||e[55]!==s||e[56]!==v?(q=Z=>r.jsxs(Vs,{value:`${Z.title} ${Z.resolveType} ${Z.description??""}`,onSelect:()=>v(Z.resolveType),className:ie("gap-2.5",!i&&s===Z.resolveType&&"bg-accent/60"),children:[r.jsx(ld,{iconName:Z.iconName,size:"sm"}),r.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[r.jsx("span",{className:"text-sm",children:Z.title}),Z.description&&r.jsx("span",{className:"truncate text-xs text-muted-foreground",children:Z.description})]})]},Z.resolveType),e[54]=i,e[55]=s,e[56]=v,e[57]=q):q=e[57],G=o.map(q),e[49]=i,e[50]=s,e[51]=v,e[52]=o,e[53]=G}else G=e[53];let Y;e[58]!==K||e[59]!==G?(Y=r.jsxs(Ms,{children:[K,G]}),e[58]=K,e[59]=G,e[60]=Y):Y=e[60];let U;e[61]!==i||e[62]!==d||e[63]!==y||e[64]!==f?(U=d.length>0&&r.jsx(Ms,{heading:f("sectionsEditor.matcherPicker.savedRulesHeading"),children:d.map(q=>r.jsxs(Vs,{value:`${q.title} ${q.blockKey} ${q.description??""}`,onSelect:()=>y(q.blockKey),className:ie("gap-2.5",i===q.blockKey&&"bg-accent/60"),children:[r.jsx(ld,{iconName:q.iconName,size:"sm"}),r.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[r.jsx("span",{className:"truncate text-sm",children:q.title}),q.description&&r.jsx("span",{className:"truncate text-xs text-muted-foreground",children:q.description})]})]},q.blockKey))}),e[61]=i,e[62]=d,e[63]=y,e[64]=f,e[65]=U):U=e[65];let W;e[66]!==k||e[67]!==Y||e[68]!==U?(W=r.jsxs(Fi,{children:[k,Y,U]}),e[66]=k,e[67]=Y,e[68]=U,e[69]=W):W=e[69];let H;e[70]!==h||e[71]!==u||e[72]!==N||e[73]!==E||e[74]!==W||e[75]!==C?(H=r.jsxs(k6,{open:h,onOpenChange:u,title:C,description:N,className:"sm:max-w-lg",children:[E,W]}),e[70]=h,e[71]=u,e[72]=N,e[73]=E,e[74]=W,e[75]=C,e[76]=H):H=e[76];let X;return e[77]!==H||e[78]!==S?(X=r.jsxs(r.Fragment,{children:[S,H]}),e[77]=H,e[78]=S,e[79]=X):X=e[79],X}function kI(t){if(!t||typeof t!="object")return!1;const e=t;return typeof e.__resolveType=="string"&&Array.isArray(e.variants)}function VI(t,e){return{__resolveType:e,variants:[{rule:br(),value:structuredClone(t)},{rule:br(),value:structuredClone(t)}]}}function NI(t){const e=t.variants;if(e.length===0)return;const s=e.find(n=>cu(n.rule));return s?s.value:e[e.length-1]?.value}function TI(t){const e=[...t.variants],s=e[e.length-1],n={rule:br(),value:s?structuredClone(s.value):void 0};return{...t,variants:[...e,n]}}function AI(t,e){if(t.variants.length<=1)return null;const s=[...t.variants];return s.splice(e,1),{...t,variants:s}}function EI(t,e){const s=[...t.variants],n=s[e];return n?(s.splice(e+1,0,structuredClone(n)),{...t,variants:s}):t}function PI(t,e,s){const n=[...t.variants];if(e===s||e<0||s<0||e>=n.length||s>=n.length)return t;const[i]=n.splice(e,1);return i?(n.splice(s,0,i),{...t,variants:n}):t}function RI(t,e,s){const n=[...t.variants],i=n[e];return i?(n[e]={...i,value:s},{...t,variants:n}):t}function Uf(t,e,s){const n=[...t.variants],i=n[e];return i?(n[e]={...i,rule:s},{...t,variants:n}):t}const Hf=new WeakMap,Wf=new Map;function DI(t){let e=Hf.get(t);return e||(e=wI(t),Hf.set(t,e)),e}function II(t,e){let s=Wf.get(t);return s===void 0&&(s=yn(t,e),Wf.set(t,s)),s}function j4(t){const e=F.c(10),{multivariateResolveType:s,renderInnerField:n,...i}=t,o=re(),{value:a,onChange:l,meta:c,path:d}=i,[h,u]=A.useState(0);if(!kI(a)){let M;e[0]!==o?(M=o("sectionsEditor.multivariateFieldWrapper.addVariant"),e[0]=o,e[1]=M):M=e[1];let O;e[2]===Symbol.for("react.memo_cache_sentinel")?(O=r.jsx(p9,{size:14}),e[2]=O):O=e[2];let $;e[3]!==o?($=o("sectionsEditor.multivariateFieldWrapper.addVariant"),e[3]=o,e[4]=$):$=e[4];let B;return e[5]!==$?(B=r.jsx(Ke,{children:$}),e[5]=$,e[6]=B):B=e[6],r.jsxs("div",{className:"relative grid w-full min-w-0 grid-cols-[minmax(0,1fr)] gap-2",children:[r.jsxs(Ue,{children:[r.jsx(ze,{asChild:!0,children:r.jsx(le,{type:"button",variant:"ghost",size:"icon",className:"absolute right-0 top-0 size-6 text-muted-foreground hover:text-foreground","aria-label":M,onClick:()=>{l(VI(a,s)),u(0)},children:O})}),B]}),n(i)]})}const f=a,m=f.variants,p=Math.min(h,m.length-1);let g;e[7]!==o?(g=(M,O)=>({index:O,label:Dl(M.rule)||o("sectionsEditor.multivariateFieldWrapper.variantN",{n:String(O+1)})}),e[7]=o,e[8]=g):g=e[8];const x=m.map(g),v=m[p],b=v?.rule??{},y=b.__resolveType??"",_=v?.value,L=c?DI(c):[],w=y&&c?II(y,c):null,{__resolveType:j,...S}=b,C=()=>{l(NI(f)),u(0)},N=()=>{const M=TI(f);l(M),u(M.variants.length-1)},V=M=>{const O=AI(f,M);O&&(l(O),p>=O.variants.length&&u(O.variants.length-1))},E=M=>{const O=EI(f,M);l(O),u(M+1)},T=(M,O)=>{const $=PI(f,M,O);l($),p===M&&u(O)},k=M=>{l(Uf(f,p,M?{__resolveType:M}:{__resolveType:Cp}))},R=M=>{const O=M,$=y?{...O,__resolveType:y}:{...O};l(Uf(f,p,$))},P=M=>{l(RI(f,p,M))},D=`${d}-${f.__resolveType}`;let I;return e[9]===Symbol.for("react.memo_cache_sentinel")?(I=r.jsx(lt,{className:"text-xs text-muted-foreground",children:"Rule"}),e[9]=I):I=e[9],r.jsxs("div",{className:"grid w-full min-w-0 grid-cols-[minmax(0,1fr)] gap-0",children:[r.jsx(gI,{listKey:D,variants:x,selectedIndex:p,onSelect:u,onDuplicate:E,onDelete:V,onRemoveAll:C,onReorder:T,onAdd:N}),r.jsxs("div",{className:"space-y-4 px-2 pt-3",children:[r.jsxs("div",{className:"space-y-1.5",children:[I,r.jsx(CI,{currentRt:y,currentLabel:Dl(b),matchers:L,onSelect:k}),w&&r.jsx("div",{className:"pt-1",children:r.jsx(In,{schema:w,value:S,onChange:R,basePath:""})})]}),n({...i,value:_,onChange:P})]})]})}const MI="website/loaders/secret.ts";function Co(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;const e=t.__resolveType;return typeof e=="string"&&(e.endsWith("/secret.ts")||e.includes("loaders/secret"))}function OI(){return{__resolveType:MI,name:"",encrypted:""}}function BI(t){const{value:e,...s}=t;return s}function cd(t){const e=F.c(55),{schema:s,value:n,onChange:i,label:o,path:a}=t,l=re();if(typeof n=="string"||n==null&&!Co(n)){const C=typeof n=="string"?n:"";let N;e[0]!==o||e[1]!==a?(N=r.jsx(lt,{htmlFor:a,className:"text-sm font-medium",children:o}),e[0]=o,e[1]=a,e[2]=N):N=e[2];let V;e[3]!==s.description?(V=s.description&&r.jsx("p",{className:"text-xs text-muted-foreground",children:s.description}),e[3]=s.description,e[4]=V):V=e[4];let E;e[5]!==l?(E=l("sectionsEditor.secretField.secretValuePlaceholder"),e[5]=l,e[6]=E):E=e[6];let T;e[7]!==i?(T=P=>i(P.target.value),e[7]=i,e[8]=T):T=e[8];let k;e[9]!==a||e[10]!==C||e[11]!==E||e[12]!==T?(k=r.jsx(rt,{id:a,type:"password",value:C,autoComplete:"new-password",autoCorrect:"off",spellCheck:!1,placeholder:E,onChange:T,className:"h-10"}),e[9]=a,e[10]=C,e[11]=E,e[12]=T,e[13]=k):k=e[13];let R;return e[14]!==N||e[15]!==V||e[16]!==k?(R=r.jsxs("div",{className:"space-y-2",children:[N,V,k]}),e[14]=N,e[15]=V,e[16]=k,e[17]=R):R=e[17],R}let c;e[18]!==n?(c=Co(n)?n:OI(),e[18]=n,e[19]=c):c=e[19];const d=c,h=typeof d.name=="string"?d.name:"",u=typeof d.encrypted=="string"&&d.encrypted,f=`${a}-name`;let m;e[20]!==o||e[21]!==f?(m=r.jsx(lt,{htmlFor:f,className:"text-sm font-medium",children:o}),e[20]=o,e[21]=f,e[22]=m):m=e[22];let p;e[23]!==s.description?(p=s.description&&r.jsx("p",{className:"text-xs text-muted-foreground",children:s.description}),e[23]=s.description,e[24]=p):p=e[24];const g=`${a}-name`;let x;e[25]!==l?(x=l("sectionsEditor.secretField.secretNamePlaceholder"),e[25]=l,e[26]=x):x=e[26];let v;e[27]!==d||e[28]!==i?(v=C=>i({...d,name:C.target.value}),e[27]=d,e[28]=i,e[29]=v):v=e[29];let b;e[30]!==h||e[31]!==g||e[32]!==x||e[33]!==v?(b=r.jsx(rt,{id:g,value:h,placeholder:x,onChange:v,className:"h-10"}),e[30]=h,e[31]=g,e[32]=x,e[33]=v,e[34]=b):b=e[34];const y=`${a}-value`;let _;e[35]!==u||e[36]!==l?(_=l(u?"sectionsEditor.secretField.leaveBlankPlaceholder":"sectionsEditor.secretField.secretValuePlaceholder"),e[35]=u,e[36]=l,e[37]=_):_=e[37];let L;e[38]!==d||e[39]!==u||e[40]!==i?(L=C=>{const N=C.target.value;if(!N){i(u?BI(d):d);return}i({...d,value:N})},e[38]=d,e[39]=u,e[40]=i,e[41]=L):L=e[41];let w;e[42]!==_||e[43]!==L||e[44]!==y?(w=r.jsx(rt,{id:y,type:"password",autoComplete:"new-password",autoCorrect:"off",spellCheck:!1,placeholder:_,onChange:L,className:"h-10"}),e[42]=_,e[43]=L,e[44]=y,e[45]=w):w=e[45];let j;e[46]!==u||e[47]!==l?(j=u&&r.jsx("p",{className:"text-xs text-muted-foreground",children:l("sectionsEditor.secretField.storedSecretMessage")}),e[46]=u,e[47]=l,e[48]=j):j=e[48];let S;return e[49]!==w||e[50]!==j||e[51]!==m||e[52]!==p||e[53]!==b?(S=r.jsxs("div",{className:"space-y-2",children:[m,p,b,w,j]}),e[49]=w,e[50]=j,e[51]=m,e[52]=p,e[53]=b,e[54]=S):S=e[54],S}function $I(t,e){const s=t.anyOfRefs;if(!s?.length)return;const n=e.find(d=>d!=null&&typeof d=="object"&&!Array.isArray(d)),i=n?Object.keys(n).filter(d=>!d.startsWith("__")):[],o=[],a=d=>{d?.type==="object"&&d.properties&&o.push(d)};for(const d of s){const h=d.schema;if(h&&(h.type==="array"&&a(h.items),h.properties))for(const u of Object.values(h.properties))u?.type==="array"&&a(u.items)}if(o.length===0)return;if(i.length===0)return o.length===1?o[0]:void 0;let l,c=-1;for(const d of o){const h=d.properties??{},u=i.filter(f=>f in h).length*2+(d.titleBy?1:0);u>c&&(c=u,l=d)}return c>=2?l:void 0}function FI(t){const e=t.length>0?t[0]:void 0;if(e==null||typeof e!="object"||Array.isArray(e))return;const s={};for(const[n,i]of Object.entries(e))n.startsWith("__")||(typeof i=="string"?s[n]={type:"string"}:typeof i=="number"?s[n]={type:"number"}:typeof i=="boolean"&&(s[n]={type:"boolean"}));return Object.keys(s).length>0?{type:"object",properties:s}:void 0}const zI=new Set(["__resolveType","@type"]);function KI(t){if(t.type!=="block-ref"||!t.anyOfRefs?.length||t.anyOfRefs.length!==1)return!1;const e=t.anyOfRefs[0].schema;return!!(e?.properties?.variants||!e&&t.plainSchema)}function UI(t){if(Lc(t))for(const e of t.anyOfRefs??[]){const i=e.schema?.properties?.variants?.items?.properties?.value;if(i?.type==="array"&&i.items)return i.items}}function qf(t){if(t.type==="array"&&t.items)return t;const e=t.items??UI(t);return e?{...t,type:"array",items:e}:null}function HI(t,e){if(e!==void 0)return e;switch(t){case"string":return"";case"number":case"integer":return 0;case"boolean":return!1;case"array":return[];case"object":return{};default:return null}}function Ho(t){const{schema:e,value:s}=t;if(El(s)){const a=_A(s),l=qf(e);if(a!==null&&l)return r.jsx(Ea,{...t,schema:l,value:a,onChange:c=>t.onChange(yA(s,c))},t.path)}if(Array.isArray(s)&&e.type==="block-ref"&&Lc(e)){const a=qf(e);if(a)return r.jsx(Ea,{...t,schema:a,value:s,onChange:t.onChange},t.path)}if(Array.isArray(s)&&!El(s)&&e.type==="block-ref"){const a=$I(e,s)??FI(s);if(a){const l={...e,type:"array",items:a};return r.jsx(Ea,{...t,schema:l,value:s,onChange:t.onChange},t.path)}}if(e.type==="block-ref"||s!==null&&typeof s=="object"&&!Array.isArray(s)&&typeof s.__resolveType=="string"&&e.anyOfRefs){if(KI(e)){const a=e.anyOfRefs[0],l=a.schema?.properties?.variants?.items?.properties?.value,c=l&&l.type!=="block-ref"?l:e.plainSchema??l?.plainSchema??{type:"string"},d=h=>Ho({...h,schema:c});return r.jsx(j4,{...t,multivariateResolveType:a.resolveType,renderInnerField:d},t.path)}return e.anyOfRefs?r.jsx(Df,{...t},t.path):null}if(e.type==="inline-union")return r.jsx(sI,{...t},t.path);if(e.format==="image-uri")return r.jsx(FD,{...t},t.path);if(e.format==="file-uri"||e.format==="video-uri")return r.jsx(OD,{...t},t.path);if(e.format==="map")return r.jsx(lI,{...t},t.path);if((e.format==="dynamic-options"||e.format==="icon-select")&&e.options)return r.jsx(uD,{...t},t.path);if(e.format==="location")return r.jsx(y4,{...t},t.path);if(e.enum&&e.enum.length>0)return r.jsx(hR,{...t},t.path);if(e.type==="anyOf")return r.jsx(Df,{...t},t.path);if(Co(s)||e.format==="password"||s==null&&e.format==="password")return r.jsx(cd,{...t},t.path);const n=s??HI(e.type,e.default);if(n==null)return Co(s)?r.jsx(cd,{...t},t.path):null;if(Co(n))return r.jsx(cd,{...t,value:n},t.path);const i={...t,value:n},o=s==null?e.type??typeof n:Array.isArray(n)?"array":typeof n;if(o==="array"||Array.isArray(n))return r.jsx(Ea,{...i},t.path);switch(o){case"boolean":return r.jsx(lR,{...i},t.path);case"number":case"integer":return r.jsx(aR,{...i},t.path);case"string":{const a=e.format;return a==="color-input"||a==="color"?r.jsx(Ta,{...i},t.path):a==="textarea"||a==="rich-text"||a==="html"?r.jsx(Ta,{...i},t.path):r.jsx(Ta,{...i},t.path)}case"object":return n!==null&&typeof n=="object"&&!Array.isArray(n)?r.jsx(qR,{...i},t.path):null;default:return r.jsx(Ta,{...i},t.path)}}function WI(t,e){if(e&&(e.type==="block-ref"||e.anyOfRefs||e.properties))return Ho({...t,schema:e});const s=t.value;if(s&&typeof s=="object"&&!Array.isArray(s)&&typeof s.__resolveType=="string"&&t.meta){const n=yn(s.__resolveType,t.meta);if(n)return r.jsx(In,{schema:n,value:s,onChange:t.onChange,basePath:t.path,breadcrumbPath:t.breadcrumbPath,onBreadcrumbChange:t.onBreadcrumbChange,meta:t.meta,decofile:t.decofile,onSaveReferencedBlock:t.onSaveReferencedBlock,sandbox:t.sandbox})}return Ho(e?{...t,schema:e}:t)}function In(t){const e=F.c(18),{schema:s,value:n,onChange:i,basePath:o,breadcrumbPath:a,onBreadcrumbChange:l,meta:c,decofile:d,onSaveReferencedBlock:h,previewBaseUrl:u,onAddSectionItem:f,onRequestAddSection:m,sandbox:p}=t;let g,x;if(e[0]!==o||e[1]!==d||e[2]!==c||e[3]!==f||e[4]!==l||e[5]!==i||e[6]!==m||e[7]!==h||e[8]!==u||e[9]!==p||e[10]!==s||e[11]!==a||e[12]!==n){x=Symbol.for("react.early_return_sentinel");e:{const v=a===void 0?[]:a,b=s.properties;if(!b){x=null;break e}if(bA(n)&&b.variants){const k=b.variants.items?.properties?.value;let R;e[15]!==k?(R=P=>WI(P,k),e[15]=k,e[16]=R):R=e[16],x=r.jsx(j4,{schema:s,value:n,onChange:i,path:o,label:s.title??"",breadcrumbPath:v,onBreadcrumbChange:l,meta:c,decofile:d,onSaveReferencedBlock:h,previewBaseUrl:u,onAddSectionItem:f,onRequestAddSection:m,sandbox:p,multivariateResolveType:n.__resolveType,renderInnerField:R},o);break e}const y=n!=null&&typeof n=="object"&&!Array.isArray(n)?n:{},_=Object.keys(b).filter(k=>!zI.has(k)&&b[k]?.hidden!==!0);if(_.length===0){let k;e[17]===Symbol.for("react.memo_cache_sentinel")?(k=r.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:"No editable fields on this section."}),e[17]=k):k=e[17],x=k;break e}const L=(k,R)=>{i({...y,[k]:R})},w=typeof y.__resolveType=="string"?y.__resolveType:void 0,j=_.filter(k=>{const R=b[k];return R!=null&&Qd(R,y[k])}).length>1,S=v.length>0?TR(_,b,y,v):null,C=S?b[S]:null,N=S&&C?[S]:_,V=S&&C?VR(S,C,v):v,E=kR(v,V),T=E.length>0&&l?k=>l([...E,...k]):l;g=r.jsx("div",{className:"min-w-0 space-y-6",children:N.map(k=>{const R=b[k];if(!R)return null;const P=o?`${o}.${k}`:k,D=jo(k,R);return Ho({schema:R,value:y[k],onChange:I=>L(k,I),path:P,label:D,breadcrumbPath:V,onBreadcrumbChange:T,hasSiblingDrillDownFields:j,meta:c,decofile:d,onSaveReferencedBlock:h,containerResolveType:w,previewBaseUrl:u,onAddSectionItem:f,onRequestAddSection:m,sandbox:p})})})}e[0]=o,e[1]=d,e[2]=c,e[3]=f,e[4]=l,e[5]=i,e[6]=m,e[7]=h,e[8]=u,e[9]=p,e[10]=s,e[11]=a,e[12]=n,e[13]=g,e[14]=x}else g=e[13],x=e[14];return x!==Symbol.for("react.early_return_sentinel")?x:g}function qI(t){const e=F.c(3),{isPending:s,isError:n}=t;if(n){let o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-destructive",children:[r.jsx(wn,{size:13}),"Couldn't save"]}),e[0]=o):o=e[0],o}if(s){let o;return e[1]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[r.jsx(et,{size:13,className:"animate-spin"}),"Saving…"]}),e[1]=o):o=e[1],o}let i;return e[2]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground/70",children:[r.jsx(zt,{size:13}),"Saved"]}),e[2]=i):i=e[2],i}function GI({orgSlug:t,virtualMcpId:e,branch:s,previewUrl:n,meta:i,decofile:o,kind:a,target:l,initialValue:c,isCreating:d,onCreate:h,onSaveReferencedBlock:u,onBack:f}){const m=re(),p=ci(),g=p?.entity?.id===e?p.entity.metadata?.siteSlug??null:null,x=yn(l.resolveType,i),v=!x&&JS(l.resolveType,i),b=v?XS(c):null,y=x??b,[_,L]=A.useState(c),[w,j]=A.useState([]),[S,C]=A.useState(0),[N,V]=A.useState(!1),[E,T]=A.useState(null),[k,R]=A.useState(!1),[P,D]=A.useState(!1),[I,M]=A.useState(!1),O=E!==null,{save:$,flush:B,isPending:z}=pg({orgSlug:t,virtualMcpId:e,branch:s}),K=lE({orgSlug:t,virtualMcpId:e,branch:s});A.useEffect(()=>()=>{B()},[]);const G=Ig(a),Y=l.resolveType.split("/").pop()?.replace(/\.tsx?$/,"")??l.resolveType,U={orgSlug:t,virtualMcpId:e,branch:s,previewUrl:n??void 0,siteSlug:g},W=te=>{L(te),l.mode==="saved"&&$(l.blockKey,{__resolveType:l.resolveType,...te})},H=()=>{O?(T(null),V(!1),C(te=>te+1)):T(JSON.stringify(_,null,2))},X=te=>{const se=te??"";try{const ne=JSON.parse(se);if(ne&&typeof ne=="object"&&!Array.isArray(ne)){V(!1),W(ne);return}V(!0)}catch{V(!0)}},q=async te=>{const se=_u(te,o);if(se){ge.error(se);return}await h(te,{__resolveType:l.resolveType,..._}),R(!1)},Z=()=>{D(!0),K.mutate({resolveType:l.resolveType,props:_})},Q=()=>{n&&window.open(oE(n,l.resolveType,_,Date.now()),"_blank","noopener")},ee=[l.title,...w],J=te=>{j(w.slice(0,te)),C(se=>se+1)};return r.jsxs("div",{className:"flex h-full w-full min-w-0 flex-col",children:[r.jsxs("div",{className:"shrink-0 border-b px-3 py-2.5",children:[r.jsxs("div",{className:"flex min-w-0 items-center gap-2 overflow-hidden",children:[f&&r.jsx(le,{variant:"ghost",size:"icon",className:"size-8 shrink-0",onClick:f,"aria-label":m("sandbox.runnableBlockEditor.backToList"),children:r.jsx(Gl,{size:14})}),r.jsx("nav",{"aria-label":m("sandbox.runnableBlockEditor.editingBreadcrumb"),className:"flex min-w-0 flex-1 items-center gap-1 overflow-hidden text-sm",children:ee.map((te,se)=>{const ne=se===ee.length-1;return r.jsxs("span",{className:"flex min-w-0 items-center gap-1 overflow-hidden",children:[se>0&&r.jsx(bn,{className:"size-3 shrink-0 text-muted-foreground/60"}),r.jsx("button",{type:"button",onClick:()=>J(se),title:te,className:ie("min-w-0 truncate rounded-md px-1 py-0.5 text-left transition-colors hover:bg-accent hover:text-accent-foreground",ne?"font-medium text-foreground":"text-muted-foreground"),children:te})]},`${te}-${se}`)})}),l.mode==="saved"&&r.jsx(qI,{isPending:z,isError:!1}),r.jsxs(le,{size:"sm",variant:"outline",className:"h-8 shrink-0 gap-1.5",onClick:Z,disabled:K.isPending,"aria-label":m("sandbox.runnableBlockEditor.runAriaLabel",{singular:G}),children:[K.isPending?r.jsx(et,{size:14,className:"animate-spin"}):r.jsx(Vi,{size:14}),m("sandbox.runnableBlockEditor.run")]}),l.mode==="available"&&r.jsxs(Ue,{children:[r.jsx(ze,{asChild:!0,children:r.jsx(le,{size:"icon",className:"size-8 shrink-0",disabled:d,onClick:()=>R(!0),"aria-label":m("sandbox.runnableBlockEditor.saveAsGlobalAriaLabel",{singular:G}),children:r.jsx(J0,{size:14})})}),r.jsx(Ke,{side:"bottom",children:m("sandbox.runnableBlockEditor.saveAsGlobal",{singular:G})})]}),r.jsxs(Ue,{children:[r.jsx(ze,{asChild:!0,children:r.jsx(le,{variant:O?"default":"ghost",size:"icon",className:"size-8 shrink-0",onClick:H,"aria-label":m(O?"sandbox.runnableBlockEditor.closeJsonEditor":"sandbox.runnableBlockEditor.editAsJson"),"aria-pressed":O,children:O?r.jsx(ks,{size:14}):r.jsx(ea,{size:14})})}),r.jsx(Ke,{side:"bottom",children:m(O?"sandbox.runnableBlockEditor.closeJsonEditor":"sandbox.runnableBlockEditor.editAsJson")})]})]}),r.jsx("p",{className:"mt-1.5 py-1 pl-1 text-sm leading-snug text-muted-foreground",children:l.mode==="saved"?m("sandbox.runnableBlockEditor.savedModeDescription",{singular:G}):m("sandbox.runnableBlockEditor.availableModeDescription",{typeLabel:Y,singular:G})})]}),r.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[r.jsxs("div",{className:ie("relative min-h-0 flex-1",P&&I&&"hidden"),children:[r.jsx(ii,{className:"h-full [&_[data-slot=scroll-area-viewport]>div]:!block",children:r.jsx("div",{className:"min-w-0 max-w-full overflow-x-hidden px-6 py-4",children:r.jsxs("div",{className:"mx-auto max-w-2xl",children:[b&&y===b&&r.jsx("p",{className:"mb-3 rounded-md bg-muted px-3 py-2 text-xs leading-snug text-muted-foreground",children:m("sandbox.runnableBlockEditor.inferredSchemaNotice",{singular:G})}),y?r.jsx(In,{schema:y,value:_,onChange:te=>W(te),basePath:"",breadcrumbPath:w,onBreadcrumbChange:j,meta:i,decofile:o,onSaveReferencedBlock:u,sandbox:U},S):r.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:v?m("sandbox.runnableBlockEditor.freeformPropsEmptyState",{singular:G}):m("sandbox.runnableBlockEditor.noInputEmptyState",{singular:G})})]})})}),E!==null&&r.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[N&&r.jsx("div",{className:"shrink-0 border-b bg-destructive/10 px-3 py-1.5 text-xs text-destructive",children:m("sandbox.runnableBlockEditor.invalidJsonError")}),r.jsx("div",{className:"min-h-0 flex-1",children:r.jsx(ra,{language:"json",height:"100%",code:E,onChange:X,onSave:te=>{X(te),B()}})})]})]}),P&&r.jsx(YI,{singular:G,result:{isPending:K.isPending,error:K.error,data:K.data,hasRun:K.status!=="idle"},expanded:I,onToggleExpand:()=>M(te=>!te),onOpenInNewTab:n?Q:void 0,onClose:()=>{D(!1),M(!1)}})]}),r.jsx(yu,{open:k,onOpenChange:R,defaultBlockId:"",isPending:d,onSubmit:q})]})}function YI(t){const e=F.c(54),{singular:s,result:n,expanded:i,onToggleExpand:o,onOpenInNewTab:a,onClose:l}=t,c=re();let d;e[0]!==n.data?(d=typeof n.data=="string"?n.data:JSON.stringify(n.data??null,null,2),e[0]=n.data,e[1]=d):d=e[1];const h=d,u=i?"flex-1":"h-[45%] shrink-0";let f;e[2]!==u?(f=ie("flex min-h-0 flex-col border-t",u),e[2]=u,e[3]=f):f=e[3];let m;e[4]!==c?(m=c("sandbox.runnableBlockEditor.resultPanelTitle"),e[4]=c,e[5]=m):m=e[5];let p;e[6]!==m?(p=r.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:m}),e[6]=m,e[7]=p):p=e[7];let g;e[8]!==a||e[9]!==s||e[10]!==c?(g=a&&r.jsxs(Ue,{children:[r.jsx(ze,{asChild:!0,children:r.jsx(le,{variant:"ghost",size:"icon",className:"size-7",onClick:a,"aria-label":c("sandbox.runnableBlockEditor.openResultInNewTabAriaLabel"),children:r.jsx(Dn,{size:14})})}),r.jsx(Ke,{side:"bottom",children:c("sandbox.runnableBlockEditor.openInNewTabTooltip",{singular:s})})]}),e[8]=a,e[9]=s,e[10]=c,e[11]=g):g=e[11];let x;e[12]!==i||e[13]!==c?(x=c(i?"sandbox.runnableBlockEditor.collapseResult":"sandbox.runnableBlockEditor.expandResult"),e[12]=i,e[13]=c,e[14]=x):x=e[14];let v;e[15]!==i?(v=i?r.jsx(r6,{size:14}):r.jsx(Bm,{size:14}),e[15]=i,e[16]=v):v=e[16];let b;e[17]!==i||e[18]!==o||e[19]!==x||e[20]!==v?(b=r.jsx(ze,{asChild:!0,children:r.jsx(le,{variant:"ghost",size:"icon",className:"size-7",onClick:o,"aria-label":x,"aria-pressed":i,children:v})}),e[17]=i,e[18]=o,e[19]=x,e[20]=v,e[21]=b):b=e[21];let y;e[22]!==i||e[23]!==c?(y=c(i?"sandbox.runnableBlockEditor.collapse":"sandbox.runnableBlockEditor.expand"),e[22]=i,e[23]=c,e[24]=y):y=e[24];let _;e[25]!==y?(_=r.jsx(Ke,{side:"bottom",children:y}),e[25]=y,e[26]=_):_=e[26];let L;e[27]!==_||e[28]!==b?(L=r.jsxs(Ue,{children:[b,_]}),e[27]=_,e[28]=b,e[29]=L):L=e[29];let w;e[30]!==c?(w=c("sandbox.runnableBlockEditor.closeResult"),e[30]=c,e[31]=w):w=e[31];let j;e[32]===Symbol.for("react.memo_cache_sentinel")?(j=r.jsx(ks,{size:14}),e[32]=j):j=e[32];let S;e[33]!==l||e[34]!==w?(S=r.jsx(le,{variant:"ghost",size:"icon",className:"size-7",onClick:l,"aria-label":w,children:j}),e[33]=l,e[34]=w,e[35]=S):S=e[35];let C;e[36]!==L||e[37]!==S||e[38]!==g?(C=r.jsxs("div",{className:"flex items-center gap-0.5",children:[g,L,S]}),e[36]=L,e[37]=S,e[38]=g,e[39]=C):C=e[39];let N;e[40]!==C||e[41]!==p?(N=r.jsxs("div",{className:"flex h-9 shrink-0 items-center justify-between border-b px-3",children:[p,C]}),e[40]=C,e[41]=p,e[42]=N):N=e[42];let V;e[43]!==n.error||e[44]!==n.hasRun||e[45]!==n.isPending||e[46]!==h||e[47]!==s||e[48]!==c?(V=r.jsx("div",{className:"min-h-0 flex-1",children:n.isPending?r.jsxs("div",{className:"flex h-full items-center justify-center gap-2 text-xs text-muted-foreground",children:[r.jsx(et,{size:16,className:"animate-spin"}),c("sandbox.runnableBlockEditor.running",{singular:s})]}):n.error?r.jsxs("div",{className:"h-full overflow-auto px-4 py-3",children:[r.jsx("p",{className:"text-xs font-medium text-destructive",children:c("sandbox.runnableBlockEditor.failedToRun",{singular:s})}),r.jsx("pre",{className:"mt-1 whitespace-pre-wrap break-words text-xs text-destructive/90",children:n.error.message})]}):n.hasRun?r.jsx(ra,{language:"json",height:"100%",code:h,readOnly:!0}):r.jsx("div",{className:"flex h-full items-center justify-center text-xs text-muted-foreground",children:c("sandbox.runnableBlockEditor.pressRunToInvoke",{singular:s})})}),e[43]=n.error,e[44]=n.hasRun,e[45]=n.isPending,e[46]=h,e[47]=s,e[48]=c,e[49]=V):V=e[49];let E;return e[50]!==N||e[51]!==V||e[52]!==f?(E=r.jsxs("div",{className:f,children:[N,V]}),e[50]=N,e[51]=V,e[52]=f,e[53]=E):E=e[53],E}const JI={loaders:nl,actions:Ni},XI={loaders:"Loaders",actions:"Actions"},QI={analytics:Pb,blog:fr,commerce:m9,site:fb,website:ai};function ZI(t,e){return e===0?QI[t.toLowerCase()]??Zn:Zn}function Ra(t,e){return e===0?LE(t):t}function eM(t){const e=F.c(98),{orgSlug:s,virtualMcpId:n,branch:i,previewUrl:o,meta:a,decofile:l,kind:c}=t,d=re();let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=[],e[0]=h):h=e[0];const[u,f]=A.useState(h),[m,p]=A.useState(null),[g,x]=A.useState(""),[v,b]=A.useState(lM),[y,_]=A.useState(c);y!==c&&(_(c),f([]),p(null),x(""),b(new Set));let L;e[1]===Symbol.for("react.memo_cache_sentinel")?(L=K=>{b(G=>{const Y=new Set(G);return Y.has(K)?Y.delete(K):Y.add(K),Y})},e[1]=L):L=e[1];const w=L;let j;e[2]!==i||e[3]!==s||e[4]!==n?(j={orgSlug:s,virtualMcpId:n,branch:i},e[2]=i,e[3]=s,e[4]=n,e[5]=j):j=e[5];const S=yc(j);let C;e[6]!==S?(C=Hg((K,G)=>S.mutate({blockKey:K,data:G})),e[6]=S,e[7]=C):C=e[7];const N=C;let V;e[8]!==c?(V=Ig(c),e[8]=c,e[9]=V):V=e[9];const E=V,T=JI[c];let k,R,P,D,I,M,O;if(e[10]!==T||e[11]!==i||e[12]!==l||e[13]!==c||e[14]!==a||e[15]!==v||e[16]!==s||e[17]!==u||e[18]!==o||e[19]!==S||e[20]!==N||e[21]!==g||e[22]!==m||e[23]!==E||e[24]!==d||e[25]!==n){P=Symbol.for("react.early_return_sentinel");e:{const K=[...SE(a,l,c).map(aM),...Mg(a,c).map(oM)],G=g.trim().toLowerCase(),Y=G.length>0,U=Y?K.filter(_e=>_e.title.toLowerCase().includes(G)||_e.resolveType.toLowerCase().includes(G)):[],W=new Map,H=[],X=new Map;if(!Y){for(const _e of K){const Ae=_e.folderPath;if(!(Ae.length<u.length)&&u.every((Re,ye)=>Ae[ye]===Re))if(Ae.length===u.length)if(_e.savedKey!==void 0){const Re=X.get(_e.resolveType);Re?Re.push(_e):X.set(_e.resolveType,[_e])}else H.push(_e);else{const Re=Ae[u.length],ye=W.get(Re)??{count:0,savedCount:0};_e.savedKey!==void 0?ye.savedCount=ye.savedCount+1:ye.count=ye.count+1,W.set(Re,ye)}}H.sort(rM);for(const _e of X.values())_e.sort(iM)}const q=[...X.entries()].filter(_e=>{const[Ae]=_e;return!H.some(Re=>Re.resolveType===Ae)}).flatMap(nM).sort(sM);let Z;e[33]!==u?(Z=(_e,Ae)=>Ra(_e.name,u.length).localeCompare(Ra(Ae.name,u.length)),e[33]=u,e[34]=Z):Z=e[34];const Q=[...W.entries()].map(tM).sort(Z);let ee;e[35]===Symbol.for("react.memo_cache_sentinel")?(ee=_e=>{p(_e.savedKey!==void 0?{mode:"saved",key:_e.savedKey}:{mode:"available",resolveType:_e.resolveType,title:_e.title})},e[35]=ee):ee=e[35];const J=ee;let te;e[36]!==S||e[37]!==E||e[38]!==d?(te=async(_e,Ae)=>{await S.mutateAsync({blockKey:_e,data:Ae}),ge.success(d("sandbox.runnableBlocksBrowser.savedBlockToast",{singular:E,blockId:_e})),p({mode:"saved",key:_e})},e[36]=S,e[37]=E,e[38]=d,e[39]=te):te=e[39];const se=te;let ne;e[40]!==l||e[41]!==m?(ne=cM(m,l),e[40]=l,e[41]=m,e[42]=ne):ne=e[42];const de=ne;if(de){const _e=`${de.mode}:${de.mode==="saved"?de.blockKey:de.resolveType}`;let Ae;e[43]===Symbol.for("react.memo_cache_sentinel")?(Ae=()=>p(null),e[43]=Ae):Ae=e[43];let Re;e[44]!==i||e[45]!==l||e[46]!==se||e[47]!==c||e[48]!==a||e[49]!==s||e[50]!==o||e[51]!==S.isPending||e[52]!==N||e[53]!==_e||e[54]!==de.editorTarget||e[55]!==de.initialValue||e[56]!==n?(Re=r.jsx(GI,{orgSlug:s,virtualMcpId:n,branch:i,previewUrl:o,meta:a,decofile:l,kind:c,target:de.editorTarget,initialValue:de.initialValue,isCreating:S.isPending,onCreate:se,onSaveReferencedBlock:N,onBack:Ae},_e),e[44]=i,e[45]=l,e[46]=se,e[47]=c,e[48]=a,e[49]=s,e[50]=o,e[51]=S.isPending,e[52]=N,e[53]=_e,e[54]=de.editorTarget,e[55]=de.initialValue,e[56]=n,e[57]=Re):Re=e[57],P=Re;break e}O="flex h-full w-full min-w-0 flex-col";let xe;e[58]!==d?(xe=d("sandbox.runnableBlocksBrowser.folderBreadcrumb"),e[58]=d,e[59]=xe):xe=e[59];let ue;e[60]===Symbol.for("react.memo_cache_sentinel")?(ue=()=>f([]),e[60]=ue):ue=e[60];const ce=u.length===0?"font-medium text-foreground":"text-muted-foreground";let oe;e[61]!==ce?(oe=ie("min-w-0 truncate rounded-md px-1 py-0.5 transition-colors hover:bg-accent hover:text-accent-foreground",ce),e[61]=ce,e[62]=oe):oe=e[62];const fe=XI[c];let pe;e[63]!==oe||e[64]!==fe?(pe=r.jsx("button",{type:"button",onClick:ue,className:oe,children:fe}),e[63]=oe,e[64]=fe,e[65]=pe):pe=e[65];let we;e[66]!==u?(we=u.map((_e,Ae)=>{const Re=Ae===u.length-1;return r.jsxs("span",{className:"flex min-w-0 items-center gap-1 overflow-hidden",children:[r.jsx(bn,{className:"size-3 shrink-0 text-muted-foreground/60"}),r.jsx("button",{type:"button",onClick:()=>f(u.slice(0,Ae+1)),className:ie("min-w-0 truncate rounded-md px-1 py-0.5 transition-colors hover:bg-accent hover:text-accent-foreground",Re?"font-medium text-foreground":"text-muted-foreground"),children:Ra(_e,Ae)})]},`${_e}-${Ae}`)}),e[66]=u,e[67]=we):we=e[67];let Ne;e[68]!==xe||e[69]!==pe||e[70]!==we?(Ne=r.jsxs("nav",{"aria-label":xe,className:"flex min-w-0 flex-1 items-center gap-1 overflow-hidden text-sm",children:[pe,we]}),e[68]=xe,e[69]=pe,e[70]=we,e[71]=Ne):Ne=e[71];let Fe;e[72]===Symbol.for("react.memo_cache_sentinel")?(Fe=r.jsx(g9,{size:14,className:"shrink-0 text-muted-foreground","aria-hidden":!0}),e[72]=Fe):Fe=e[72];let je;e[73]===Symbol.for("react.memo_cache_sentinel")?(je=_e=>x(_e.target.value),e[73]=je):je=e[73];let Ie;e[74]!==c||e[75]!==d?(Ie=d("sandbox.runnableBlocksBrowser.searchPlaceholder",{kind:c}),e[74]=c,e[75]=d,e[76]=Ie):Ie=e[76];let Pe;e[77]!==c||e[78]!==d?(Pe=d("sandbox.runnableBlocksBrowser.searchAriaLabel",{kind:c}),e[77]=c,e[78]=d,e[79]=Pe):Pe=e[79];let Ye;e[80]!==g||e[81]!==Ie||e[82]!==Pe?(Ye=r.jsxs("div",{className:"flex w-56 shrink-0 items-center gap-2",children:[Fe,r.jsx("input",{type:"text",value:g,onChange:je,placeholder:Ie,"aria-label":Pe,className:"w-full bg-transparent text-sm outline-none placeholder:text-muted-foreground"})]}),e[80]=g,e[81]=Ie,e[82]=Pe,e[83]=Ye):Ye=e[83],e[84]!==Ne||e[85]!==Ye?(R=r.jsxs("div",{className:"flex h-12 shrink-0 items-center gap-2 border-b px-4",children:[Ne,Ye]}),e[84]=Ne,e[85]=Ye,e[86]=R):R=e[86],k=ii,M="min-h-0 flex-1 [&_[data-slot=scroll-area-viewport]>div]:!block",D="mx-auto w-full max-w-4xl px-6 py-5",I=Y?U.length===0?r.jsx(Hn,{title:d("sandbox.runnableBlocksBrowser.noSearchResults",{kind:c,query:g.trim()}),description:d("sandbox.runnableBlocksBrowser.noSearchResultsDescription")}):r.jsx("div",{className:"flex flex-col gap-1",children:U.map(_e=>r.jsx(Qs,{icon:T,accent:_e.savedKey!==void 0?"global":void 0,title:_e.title,subtitle:_e.resolveType,active:!1,onClick:()=>J(_e)},_e.savedKey??_e.resolveType))}):Q.length===0&&H.length===0&&q.length===0?r.jsx(Hn,{title:d("sandbox.runnableBlocksBrowser.emptyFolderTitle",{kind:c}),description:u.length===0?d("sandbox.runnableBlocksBrowser.emptyFolderNoManifest"):d("sandbox.runnableBlocksBrowser.emptyFolder")}):r.jsxs(r.Fragment,{children:[Q.length>0&&r.jsx("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(180px,1fr))] gap-2",children:Q.map(_e=>{const Ae=ZI(_e.name,u.length);return r.jsxs("button",{type:"button",onClick:()=>f([...u,_e.name]),className:"flex items-center gap-2.5 rounded-lg border px-3 py-2.5 text-left transition-colors hover:bg-muted cursor-pointer",children:[r.jsx(Ae,{size:18,className:"shrink-0 text-muted-foreground"}),r.jsxs("span",{className:"min-w-0 flex-1",children:[r.jsx("span",{className:"block truncate text-sm font-medium",children:Ra(_e.name,u.length)}),r.jsxs("span",{className:"block truncate text-xs text-muted-foreground",children:[_e.count," ",_e.count===1?E:c,_e.savedCount>0&&r.jsxs(r.Fragment,{children:[" ","·"," ",d("sandbox.runnableBlocksBrowser.savedCountLabel",{count:_e.savedCount})]})]})]})]},_e.name)})}),(H.length>0||q.length>0)&&r.jsxs("div",{className:ie("flex flex-col gap-1",Q.length>0&&"mt-4"),children:[H.map(_e=>{const Ae=X.get(_e.resolveType)??[],Re=v.has(_e.resolveType);return r.jsxs("div",{className:"flex flex-col",children:[r.jsx(Qs,{icon:T,title:_e.title,subtitle:_e.resolveType,active:!1,onClick:()=>J(_e)}),Ae.length>0&&r.jsxs(r.Fragment,{children:[r.jsxs("button",{type:"button",onClick:()=>w(_e.resolveType),"aria-expanded":Re,className:"flex items-center gap-1 self-start rounded-md px-2.5 py-1 text-xs font-medium transition-colors hover:bg-global-section/10 cursor-pointer ml-11",style:{color:N9},children:[Re?r.jsx(ss,{size:12,className:"shrink-0"}):r.jsx(bn,{size:12,className:"shrink-0"}),d(Re?"sandbox.runnableBlocksBrowser.hideSaved":"sandbox.runnableBlocksBrowser.seeSaved")," ","(",Ae.length,")"]}),Re&&r.jsx("div",{className:"ml-11 flex flex-col gap-1 pb-1",children:Ae.map(ye=>r.jsx(Qs,{icon:T,accent:"global",title:ye.title,subtitle:ye.resolveType,active:!1,onClick:()=>J(ye)},ye.savedKey))})]})]},_e.resolveType)}),q.map(_e=>r.jsx(Qs,{icon:T,accent:"global",title:_e.title,subtitle:_e.resolveType,active:!1,onClick:()=>J(_e)},_e.savedKey))]})]})}e[10]=T,e[11]=i,e[12]=l,e[13]=c,e[14]=a,e[15]=v,e[16]=s,e[17]=u,e[18]=o,e[19]=S,e[20]=N,e[21]=g,e[22]=m,e[23]=E,e[24]=d,e[25]=n,e[26]=k,e[27]=R,e[28]=P,e[29]=D,e[30]=I,e[31]=M,e[32]=O}else k=e[26],R=e[27],P=e[28],D=e[29],I=e[30],M=e[31],O=e[32];if(P!==Symbol.for("react.early_return_sentinel"))return P;let $;e[87]!==D||e[88]!==I?($=r.jsx("div",{className:D,children:I}),e[87]=D,e[88]=I,e[89]=$):$=e[89];let B;e[90]!==k||e[91]!==$||e[92]!==M?(B=r.jsx(k,{className:M,children:$}),e[90]=k,e[91]=$,e[92]=M,e[93]=B):B=e[93];let z;return e[94]!==R||e[95]!==B||e[96]!==O?(z=r.jsxs("div",{className:O,children:[R,B]}),e[94]=R,e[95]=B,e[96]=O,e[97]=z):z=e[97],z}function tM(t){const[e,s]=t;return{name:e,...s}}function sM(t,e){return t.title.localeCompare(e.title)}function nM(t){const[,e]=t;return e}function iM(t,e){return t.title.localeCompare(e.title)}function rM(t,e){return t.title.localeCompare(e.title)}function oM(t){return{resolveType:t.resolveType,title:t.title,folderPath:Og(t.resolveType)}}function aM(t){return{resolveType:t.resolveType,title:t.title,folderPath:Og(t.resolveType),savedKey:t.key}}function lM(){return new Set}function cM(t,e){if(!t)return null;if(t.mode==="available")return{mode:"available",resolveType:t.resolveType,editorTarget:{mode:"available",resolveType:t.resolveType,title:t.title},initialValue:{}};const s=e[t.key],n=s&&typeof s.__resolveType=="string"?s.__resolveType:"",{__resolveType:i,...o}=s??{},a=s&&typeof s.name=="string"&&s.name?s.name:t.key;return{mode:"saved",blockKey:t.key,resolveType:n,editorTarget:{mode:"saved",blockKey:t.key,resolveType:n,title:a},initialValue:o}}function dM(t){const e=F.c(96),{orgSlug:s,virtualMcpId:n,branch:i,previewUrl:o,meta:a,decofile:l,resolveType:c,title:d,defaultBlockId:h,isCreating:u,onCreate:f,onSaveReferencedBlock:m}=t,p=re(),g=ci(),x=g?.entity?.id===n?g.entity.metadata?.siteSlug??null:null;let v;e[0]===Symbol.for("react.memo_cache_sentinel")?(v={},e[0]=v):v=e[0];const[b,y]=A.useState(v);let _;e[1]===Symbol.for("react.memo_cache_sentinel")?(_=[],e[1]=_):_=e[1];const[L,w]=A.useState(_),[j,S]=A.useState(0),[C,N]=A.useState(!1);let V;e[2]!==a||e[3]!==c?(V=yn(c,a),e[2]=a,e[3]=c,e[4]=V):V=e[4];const E=V;let T,k,R,P,D,I,M,O;if(e[5]!==x||e[6]!==i||e[7]!==l||e[8]!==L||e[9]!==b||e[10]!==u||e[11]!==f||e[12]!==s||e[13]!==o||e[14]!==c||e[15]!==p||e[16]!==d||e[17]!==n){const U=c.split("/").pop()?.replace(/\.tsx?$/,"")??c,W=o??void 0;let H;e[26]!==x||e[27]!==i||e[28]!==s||e[29]!==W||e[30]!==n?(H={orgSlug:s,virtualMcpId:n,branch:i,previewUrl:W,siteSlug:x},e[26]=x,e[27]=i,e[28]=s,e[29]=W,e[30]=n,e[31]=H):H=e[31],k=H;let X;e[32]!==L||e[33]!==d?(X=[d,...L],e[32]=L,e[33]=d,e[34]=X):X=e[34];const q=X;let Z;e[35]!==L?(Z=pe=>{w(L.slice(0,pe)),S(uM)},e[35]=L,e[36]=Z):Z=e[36];const Q=Z;let ee;e[37]!==l||e[38]!==b||e[39]!==f?(ee=async pe=>{const we=_u(pe,l);if(we){ge.error(we);return}await f(pe,b),N(!1)},e[37]=l,e[38]=b,e[39]=f,e[40]=ee):ee=e[40],T=ee,O="flex h-full w-full min-w-0",M="flex min-w-0 flex-1 flex-col",D="shrink-0 border-b px-3 py-2.5";let J;e[41]!==p?(J=p("sandbox.availableSectionEditor.editingBreadcrumb"),e[41]=p,e[42]=J):J=e[42];let te;e[43]!==Q||e[44]!==q?(te=q.map((pe,we)=>{const Ne=we===q.length-1;return r.jsxs("span",{className:"flex min-w-0 items-center gap-1 overflow-hidden",children:[we>0&&r.jsx(bn,{className:"size-3 shrink-0 text-muted-foreground/60"}),r.jsx("button",{type:"button",onClick:()=>Q(we),title:pe,className:ie("min-w-0 truncate rounded-md px-1 py-0.5 text-left transition-colors hover:bg-accent hover:text-accent-foreground",Ne?"font-medium text-foreground":"text-muted-foreground"),children:pe})]},`${pe}-${we}`)}),e[43]=Q,e[44]=q,e[45]=te):te=e[45];let se;e[46]!==J||e[47]!==te?(se=r.jsx("nav",{"aria-label":J,className:"flex min-w-0 flex-1 items-center gap-1 overflow-hidden text-sm",children:te}),e[46]=J,e[47]=te,e[48]=se):se=e[48];let ne;e[49]===Symbol.for("react.memo_cache_sentinel")?(ne=()=>N(!0),e[49]=ne):ne=e[49];let de;e[50]!==p?(de=p("sandbox.availableSectionEditor.saveAsGlobalSection"),e[50]=p,e[51]=de):de=e[51];let xe;e[52]===Symbol.for("react.memo_cache_sentinel")?(xe=r.jsx(J0,{size:14}),e[52]=xe):xe=e[52];let ue;e[53]!==u||e[54]!==de?(ue=r.jsx(ze,{asChild:!0,children:r.jsx(le,{size:"icon",className:"size-8 shrink-0",disabled:u,onClick:ne,"aria-label":de,children:xe})}),e[53]=u,e[54]=de,e[55]=ue):ue=e[55];let ce;e[56]!==p?(ce=p("sandbox.availableSectionEditor.saveAsGlobalSection"),e[56]=p,e[57]=ce):ce=e[57];let oe;e[58]!==ce?(oe=r.jsx(Ke,{side:"bottom",children:ce}),e[58]=ce,e[59]=oe):oe=e[59];let fe;e[60]!==ue||e[61]!==oe?(fe=r.jsxs(Ue,{children:[ue,oe]}),e[60]=ue,e[61]=oe,e[62]=fe):fe=e[62],e[63]!==se||e[64]!==fe?(I=r.jsxs("div",{className:"flex min-w-0 items-center gap-2 overflow-hidden",children:[se,fe]}),e[63]=se,e[64]=fe,e[65]=I):I=e[65],R="mt-1.5 py-1 pl-1 text-sm leading-snug text-muted-foreground",P=p("sandbox.availableSectionEditor.localEditsHint",{typeLabel:U}),e[5]=x,e[6]=i,e[7]=l,e[8]=L,e[9]=b,e[10]=u,e[11]=f,e[12]=s,e[13]=o,e[14]=c,e[15]=p,e[16]=d,e[17]=n,e[18]=T,e[19]=k,e[20]=R,e[21]=P,e[22]=D,e[23]=I,e[24]=M,e[25]=O}else T=e[18],k=e[19],R=e[20],P=e[21],D=e[22],I=e[23],M=e[24],O=e[25];let $;e[66]!==R||e[67]!==P?($=r.jsx("p",{className:R,children:P}),e[66]=R,e[67]=P,e[68]=$):$=e[68];let B;e[69]!==$||e[70]!==D||e[71]!==I?(B=r.jsxs("div",{className:D,children:[I,$]}),e[69]=$,e[70]=D,e[71]=I,e[72]=B):B=e[72];let z;e[73]!==l||e[74]!==L||e[75]!==j||e[76]!==b||e[77]!==a||e[78]!==m||e[79]!==k||e[80]!==E||e[81]!==p?(z=r.jsx(ii,{className:"min-h-0 flex-1 [&_[data-slot=scroll-area-viewport]>div]:!block",children:r.jsx("div",{className:"min-w-0 max-w-full overflow-x-hidden px-6 py-4",children:r.jsx("div",{className:"mx-auto max-w-2xl",children:E?r.jsx(In,{schema:E,value:b,onChange:U=>y(U),basePath:"",breadcrumbPath:L,onBreadcrumbChange:w,meta:a,decofile:l,onSaveReferencedBlock:m,sandbox:k},j):r.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:p("sandbox.availableSectionEditor.noEditableFields")})})})}),e[73]=l,e[74]=L,e[75]=j,e[76]=b,e[77]=a,e[78]=m,e[79]=k,e[80]=E,e[81]=p,e[82]=z):z=e[82];let K;e[83]!==B||e[84]!==z||e[85]!==M?(K=r.jsxs("div",{className:M,children:[B,z]}),e[83]=B,e[84]=z,e[85]=M,e[86]=K):K=e[86];let G;e[87]!==h||e[88]!==T||e[89]!==u||e[90]!==C?(G=r.jsx(yu,{open:C,onOpenChange:N,defaultBlockId:h,isPending:u,onSubmit:T}),e[87]=h,e[88]=T,e[89]=u,e[90]=C,e[91]=G):G=e[91];let Y;return e[92]!==K||e[93]!==G||e[94]!==O?(Y=r.jsxs("div",{className:O,children:[K,G]}),e[92]=K,e[93]=G,e[94]=O,e[95]=Y):Y=e[95],Y}function uM(t){return t+1}function hM(t,e){const s={__resolveType:t},n=xg([s],e)[0];return n?JR(s,n,e):null}function fM({orgSlug:t,virtualMcpId:e,branch:s,previewUrl:n,meta:i,decofile:o,blockKey:a,onSaveReferencedBlock:l}){const c=re(),d=ci(),h=d?.entity?.id===e?d.entity.metadata?.siteSlug??null:null,[u]=A.useState(()=>hM(a,o)),[f,m]=A.useState(u?.data??{}),[p,g]=A.useState([]),[x,v]=A.useState(0),[b,y]=A.useState(!1),[_,L]=A.useState(null),w=_!==null,{save:j,flush:S}=pg({orgSlug:t,virtualMcpId:e,branch:s}),C=u?.resolveType?yn(u.resolveType,i):null,N=o[a],V=N?cc(a,N):a,E={orgSlug:t,virtualMcpId:e,branch:s,previewUrl:n??void 0,siteSlug:h},T=I=>{m(I),j(a,I)},k=()=>{w?(L(null),y(!1),v(I=>I+1)):L(JSON.stringify(f,null,2))},R=I=>{const M=I??"";try{const O=JSON.parse(M);if(O&&typeof O=="object"&&!Array.isArray(O)){y(!1),T(O);return}y(!0)}catch{y(!0)}},P=[V,...p],D=I=>{g(p.slice(0,I)),v(M=>M+1)};return r.jsx("div",{className:"flex h-full w-full min-w-0",children:r.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[r.jsxs("div",{className:"shrink-0 border-b px-3 py-2.5",children:[r.jsxs("div",{className:"flex min-w-0 items-center gap-2 overflow-hidden",children:[r.jsx("span",{className:"size-2 shrink-0 rounded-full",style:{backgroundColor:N9},"aria-hidden":!0}),r.jsx("nav",{"aria-label":"Editing breadcrumb",className:"flex min-w-0 flex-1 items-center gap-1 overflow-hidden text-sm",children:P.map((I,M)=>{const O=M===P.length-1;return r.jsxs("span",{className:"flex min-w-0 items-center gap-1 overflow-hidden",children:[M>0&&r.jsx(bn,{className:"size-3 shrink-0 text-muted-foreground/60"}),r.jsx("button",{type:"button",onClick:()=>D(M),title:I,className:ie("min-w-0 truncate rounded-md px-1 py-0.5 text-left transition-colors hover:bg-accent hover:text-accent-foreground",O?"font-medium text-foreground":"text-muted-foreground"),children:I})]},`${I}-${M}`)})}),r.jsxs(Ue,{children:[r.jsx(ze,{asChild:!0,children:r.jsx(le,{variant:w?"default":"ghost",size:"icon",className:"size-8 shrink-0",onClick:k,"aria-label":c(w?"sandbox.savedSectionEditor.closeJsonEditor":"sandbox.savedSectionEditor.editAsJson"),"aria-pressed":w,children:w?r.jsx(ks,{size:14}):r.jsx(ea,{size:14})})}),r.jsx(Ke,{side:"bottom",children:c(w?"sandbox.savedSectionEditor.closeJsonEditor":"sandbox.savedSectionEditor.editAsJson")})]})]}),r.jsx("p",{className:"mt-1.5 py-1 pl-1 text-sm leading-snug text-muted-foreground",children:c("sandbox.savedSectionEditor.globalSectionDescription")})]}),r.jsxs("div",{className:"relative min-h-0 flex-1",children:[r.jsx(ii,{className:"h-full [&_[data-slot=scroll-area-viewport]>div]:!block",children:r.jsx("div",{className:"min-w-0 max-w-full overflow-x-hidden px-6 py-4",children:r.jsx("div",{className:"mx-auto max-w-2xl",children:C?r.jsx(In,{schema:C,value:f,onChange:I=>T(I),basePath:"",breadcrumbPath:p,onBreadcrumbChange:g,meta:i,decofile:o,onSaveReferencedBlock:l,sandbox:E},x):r.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:c("sandbox.savedSectionEditor.noEditableFields")})})})}),_!==null&&r.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[b&&r.jsx("div",{className:"shrink-0 border-b bg-destructive/10 px-3 py-1.5 text-xs text-destructive",children:c("sandbox.savedSectionEditor.invalidJsonError")}),r.jsx("div",{className:"min-h-0 flex-1",children:r.jsx(ra,{language:"json",height:"100%",code:_,onChange:R,onSave:I=>{R(I),S()}})})]})]})]})})}function mM(t){const e=F.c(36),{selection:s,orgSlug:n,virtualMcpId:i,branch:o,previewUrl:a,meta:l,decofile:c,isCreating:d,onCreateAvailable:h,onSaveReferencedBlock:u}=t,f=re();if(!s){let g;e[0]!==f?(g=f("sandbox.sectionsRightPane.selectSectionTitle"),e[0]=f,e[1]=g):g=e[1];let x;e[2]!==f?(x=f("sandbox.sectionsRightPane.selectSectionDescription"),e[2]=f,e[3]=x):x=e[3];let v;return e[4]!==g||e[5]!==x?(v=r.jsx(Hn,{title:g,description:x}),e[4]=g,e[5]=x,e[6]=v):v=e[6],v}if(s.collection==="available-section"){const g=`available:${s.resolveType}`,x=s.resolveType,v=s.title;let b;e[7]!==s.title?(b=o4(s.title),e[7]=s.title,e[8]=b):b=e[8];let y;e[9]!==h||e[10]!==s.resolveType?(y=(L,w)=>h(s.resolveType,L,w),e[9]=h,e[10]=s.resolveType,e[11]=y):y=e[11];let _;return e[12]!==o||e[13]!==c||e[14]!==d||e[15]!==l||e[16]!==u||e[17]!==n||e[18]!==a||e[19]!==s.resolveType||e[20]!==s.title||e[21]!==g||e[22]!==b||e[23]!==y||e[24]!==i?(_=r.jsx(dM,{orgSlug:n,virtualMcpId:i,branch:o,previewUrl:a,meta:l,decofile:c,resolveType:x,title:v,defaultBlockId:b,isCreating:d,onCreate:y,onSaveReferencedBlock:u},g),e[12]=o,e[13]=c,e[14]=d,e[15]=l,e[16]=u,e[17]=n,e[18]=a,e[19]=s.resolveType,e[20]=s.title,e[21]=g,e[22]=b,e[23]=y,e[24]=i,e[25]=_):_=e[25],_}const m=`saved:${s.key}`;let p;return e[26]!==o||e[27]!==c||e[28]!==l||e[29]!==u||e[30]!==n||e[31]!==a||e[32]!==s.key||e[33]!==m||e[34]!==i?(p=r.jsx(fM,{orgSlug:n,virtualMcpId:i,branch:o,previewUrl:a,meta:l,decofile:c,blockKey:s.key,onSaveReferencedBlock:u},m),e[26]=o,e[27]=c,e[28]=l,e[29]=u,e[30]=n,e[31]=a,e[32]=s.key,e[33]=m,e[34]=i,e[35]=p):p=e[35],p}const Gf="__all__",Yf={"date-desc":"sandbox.postToolbar.sortNewestFirst","date-asc":"sandbox.postToolbar.sortOldestFirst",az:"sandbox.postToolbar.sortTitleAZ",za:"sandbox.postToolbar.sortTitleZA"},pM={"date-desc":"sandbox.postToolbar.sortNewest","date-asc":"sandbox.postToolbar.sortOldest",az:"sandbox.postToolbar.sortAZ",za:"sandbox.postToolbar.sortZA"},Jf=A.forwardRef(function(e,s){const n=F.c(20);let i,o,a,l,c;n[0]!==e?({icon:i,active:o,value:c,className:a,...l}=e,n[0]=e,n[1]=i,n[2]=o,n[3]=a,n[4]=l,n[5]=c):(i=n[1],o=n[2],a=n[3],l=n[4],c=n[5]);const d=o?"text-foreground":"text-muted-foreground";let h;n[6]!==a||n[7]!==d?(h=ie("h-7 gap-1 px-1.5 text-xs",d,a),n[6]=a,n[7]=d,n[8]=h):h=n[8];let u;n[9]!==i?(u=r.jsx(i,{size:14,className:"shrink-0"}),n[9]=i,n[10]=u):u=n[10];let f;n[11]!==c?(f=c&&r.jsx("span",{className:"min-w-0 flex-1 truncate",children:c}),n[11]=c,n[12]=f):f=n[12];let m;n[13]===Symbol.for("react.memo_cache_sentinel")?(m=r.jsx(ss,{size:12,className:"shrink-0 opacity-60"}),n[13]=m):m=n[13];let p;return n[14]!==l||n[15]!==s||n[16]!==h||n[17]!==u||n[18]!==f?(p=r.jsxs(le,{ref:s,type:"button",variant:"ghost",size:"sm",className:h,...l,children:[u,f,m]}),n[14]=l,n[15]=s,n[16]=h,n[17]=u,n[18]=f,n[19]=p):p=n[19],p});function C4(t){const e=F.c(2),{count:s}=t;let n;return e[0]!==s?(n=r.jsx("span",{className:"ml-auto pl-3 text-xs text-muted-foreground tabular-nums",children:s}),e[0]=s,e[1]=n):n=e[1],n}function gM(t){const e=F.c(88),{categories:s,authors:n,categoryFilter:i,authorFilter:o,sort:a,onCategoryFilterChange:l,onAuthorFilterChange:c,onSortChange:d}=t,h=re();let u;if(e[0]!==s||e[1]!==i){let Z;e[3]!==i?(Z=Q=>Q.slug===i,e[3]=i,e[4]=Z):Z=e[4],u=s.find(Z),e[0]=s,e[1]=i,e[2]=u}else u=e[2];const f=u;let m;if(e[5]!==o||e[6]!==n){let Z;e[8]!==o?(Z=Q=>Q.email===o,e[8]=o,e[9]=Z):Z=e[9],m=n.find(Z),e[5]=o,e[6]=n,e[7]=m}else m=e[7];const p=m,g=!!(i||o);let x;e[10]!==p?.name||e[11]!==f?.name||e[12]!==h?(x=f?.name??p?.name??h("sandbox.postToolbar.filterLabel"),e[10]=p?.name,e[11]=f?.name,e[12]=h,e[13]=x):x=e[13];const v=x,b=i?`cat:${i}`:o?`author:${o}`:Gf;let y;e[14]!==c||e[15]!==l?(y=()=>{l(null),c(null)},e[14]=c,e[15]=l,e[16]=y):y=e[16];const _=y;let L;e[17]!==_||e[18]!==c||e[19]!==l?(L=Z=>{Z.startsWith("cat:")?(c(null),l(Z.slice(4))):Z.startsWith("author:")?(l(null),c(Z.slice(7))):_()},e[17]=_,e[18]=c,e[19]=l,e[20]=L):L=e[20];const w=L;let j;e[21]!==v||e[22]!==g?(j=r.jsx(ds,{asChild:!0,children:r.jsx(Jf,{icon:o6,active:g,value:v,className:"min-w-0 shrink"})}),e[21]=v,e[22]=g,e[23]=j):j=e[23];let S;e[24]!==h?(S=h("sandbox.postToolbar.filterBy"),e[24]=h,e[25]=S):S=e[25];let C;e[26]!==S?(C=r.jsx(ro,{children:S}),e[26]=S,e[27]=C):C=e[27];let N;e[28]!==h?(N=h("sandbox.postToolbar.allPosts"),e[28]=h,e[29]=N):N=e[29];let V;e[30]!==N?(V=r.jsx(Ro,{value:Gf,children:N}),e[30]=N,e[31]=V):V=e[31];let E;e[32]!==s.length||e[33]!==h?(E=s.length>0&&r.jsx(ro,{className:"text-muted-foreground/70",children:h("sandbox.postToolbar.categoryLabel")}),e[32]=s.length,e[33]=h,e[34]=E):E=e[34];let T;e[35]!==s?(T=s.map(vM),e[35]=s,e[36]=T):T=e[36];let k;e[37]!==n.length||e[38]!==h?(k=n.length>0&&r.jsx(ro,{className:"text-muted-foreground/70",children:h("sandbox.postToolbar.authorLabel")}),e[37]=n.length,e[38]=h,e[39]=k):k=e[39];let R;e[40]!==n?(R=n.map(xM),e[40]=n,e[41]=R):R=e[41];let P;e[42]!==b||e[43]!==w||e[44]!==V||e[45]!==E||e[46]!==T||e[47]!==k||e[48]!==R?(P=r.jsxs(Ad,{value:b,onValueChange:w,children:[V,E,T,k,R]}),e[42]=b,e[43]=w,e[44]=V,e[45]=E,e[46]=T,e[47]=k,e[48]=R,e[49]=P):P=e[49];let D;e[50]!==P||e[51]!==C?(D=r.jsxs(hs,{align:"start",className:"max-h-96 w-60 overflow-y-auto",children:[C,P]}),e[50]=P,e[51]=C,e[52]=D):D=e[52];let I;e[53]!==D||e[54]!==j?(I=r.jsxs(us,{children:[j,D]}),e[53]=D,e[54]=j,e[55]=I):I=e[55];let M;e[56]!==_||e[57]!==g||e[58]!==h?(M=g&&r.jsx(bM,{label:h("sandbox.postToolbar.clearFilter"),onClick:_}),e[56]=_,e[57]=g,e[58]=h,e[59]=M):M=e[59];const O=pM[a];let $;e[60]!==h||e[61]!==O?($=h(O),e[60]=h,e[61]=O,e[62]=$):$=e[62];let B;e[63]!==$?(B=r.jsx(ds,{asChild:!0,children:r.jsx(Jf,{icon:a6,active:!0,value:$})}),e[63]=$,e[64]=B):B=e[64];let z;e[65]!==h?(z=h("sandbox.postToolbar.sortBy"),e[65]=h,e[66]=z):z=e[66];let K;e[67]!==z?(K=r.jsx(ro,{children:z}),e[67]=z,e[68]=K):K=e[68];let G;e[69]!==d?(G=Z=>d(Z),e[69]=d,e[70]=G):G=e[70];let Y;e[71]===Symbol.for("react.memo_cache_sentinel")?(Y=Object.keys(Yf),e[71]=Y):Y=e[71];let U;e[72]!==h?(U=Y.map(Z=>r.jsx(Ro,{value:Z,children:h(Yf[Z])},Z)),e[72]=h,e[73]=U):U=e[73];let W;e[74]!==a||e[75]!==G||e[76]!==U?(W=r.jsx(Ad,{value:a,onValueChange:G,children:U}),e[74]=a,e[75]=G,e[76]=U,e[77]=W):W=e[77];let H;e[78]!==K||e[79]!==W?(H=r.jsxs(hs,{align:"end",className:"w-44",children:[K,W]}),e[78]=K,e[79]=W,e[80]=H):H=e[80];let X;e[81]!==B||e[82]!==H?(X=r.jsx("div",{className:"ml-auto shrink-0",children:r.jsxs(us,{children:[B,H]})}),e[81]=B,e[82]=H,e[83]=X):X=e[83];let q;return e[84]!==I||e[85]!==M||e[86]!==X?(q=r.jsxs("div",{className:"flex min-w-0 items-center gap-1 overflow-hidden border-b px-2 py-1.5",children:[I,M,X]}),e[84]=I,e[85]=M,e[86]=X,e[87]=q):q=e[87],q}function xM(t){return r.jsxs(Ro,{value:`author:${t.email}`,children:[r.jsx("span",{className:"min-w-0 flex-1 truncate",children:t.name}),r.jsx(C4,{count:t.count})]},`author:${t.email}`)}function vM(t){return r.jsxs(Ro,{value:`cat:${t.slug}`,children:[r.jsx("span",{className:"min-w-0 flex-1 truncate",children:t.name}),r.jsx(C4,{count:t.count})]},`cat:${t.slug}`)}function bM(t){const e=F.c(4),{label:s,onClick:n}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(ks,{size:12}),e[0]=i):i=e[0];let o;return e[1]!==s||e[2]!==n?(o=r.jsx("button",{type:"button","aria-label":s,onClick:n,className:"flex h-6 w-6 shrink-0 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-muted hover:text-foreground cursor-pointer",children:i}),e[1]=s,e[2]=n,e[3]=o):o=e[3],o}function _M(t){const e=F.c(18),{checked:s,disabled:n,onToggle:i}=t,o=re();let a;e[0]!==i?(a=()=>i(),e[0]=i,e[1]=a):a=e[1];let l;e[2]!==s||e[3]!==o?(l=o(s?"sandbox.postToolbar.deselectAllPosts":"sandbox.postToolbar.selectAllPosts"),e[2]=s,e[3]=o,e[4]=l):l=e[4];let c;e[5]!==s||e[6]!==n||e[7]!==a||e[8]!==l?(c=r.jsx(ze,{asChild:!0,children:r.jsx("span",{className:"flex shrink-0 items-center px-1.5",onClick:yM,children:r.jsx(Ar,{checked:s,disabled:n,onCheckedChange:a,"aria-label":l})})}),e[5]=s,e[6]=n,e[7]=a,e[8]=l,e[9]=c):c=e[9];let d;e[10]!==s||e[11]!==o?(d=o(s?"sandbox.postToolbar.deselectAll":"sandbox.postToolbar.selectAll"),e[10]=s,e[11]=o,e[12]=d):d=e[12];let h;e[13]!==d?(h=r.jsx(Ke,{side:"bottom",children:d}),e[13]=d,e[14]=h):h=e[14];let u;return e[15]!==c||e[16]!==h?(u=r.jsxs(Ue,{children:[c,h]}),e[15]=c,e[16]=h,e[17]=u):u=e[17],u}function yM(t){return t.stopPropagation()}function LM(t){const e=F.c(42),{count:s,allSelected:n,onToggleSelectAll:i,onDelete:o,onExit:a}=t,l=re();let c;e[0]!==n||e[1]!==i?(c=r.jsx(_M,{checked:n,onToggle:i}),e[0]=n,e[1]=i,e[2]=c):c=e[2];let d;e[3]!==s||e[4]!==l?(d=l("sandbox.postToolbar.itemsSelected",{count:s}),e[3]=s,e[4]=l,e[5]=d):d=e[5];let h;e[6]!==d?(h=r.jsx("span",{className:"text-xs font-medium tabular-nums",children:d}),e[6]=d,e[7]=h):h=e[7];const u=s===0;let f;e[8]!==l?(f=l("sandbox.postToolbar.deleteSelectedPosts"),e[8]=l,e[9]=f):f=e[9];let m;e[10]===Symbol.for("react.memo_cache_sentinel")?(m=r.jsx(Ns,{size:14}),e[10]=m):m=e[10];let p;e[11]!==o||e[12]!==u||e[13]!==f?(p=r.jsx(ze,{asChild:!0,children:r.jsx(le,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive hover:text-destructive",disabled:u,onClick:o,"aria-label":f,children:m})}),e[11]=o,e[12]=u,e[13]=f,e[14]=p):p=e[14];let g;e[15]!==l?(g=l("sandbox.postToolbar.deleteSelected"),e[15]=l,e[16]=g):g=e[16];let x;e[17]!==g?(x=r.jsx(Ke,{side:"bottom",children:g}),e[17]=g,e[18]=x):x=e[18];let v;e[19]!==p||e[20]!==x?(v=r.jsxs(Ue,{children:[p,x]}),e[19]=p,e[20]=x,e[21]=v):v=e[21];let b;e[22]!==l?(b=l("sandbox.postToolbar.exitSelection"),e[22]=l,e[23]=b):b=e[23];let y;e[24]===Symbol.for("react.memo_cache_sentinel")?(y=r.jsx(ks,{size:14}),e[24]=y):y=e[24];let _;e[25]!==a||e[26]!==b?(_=r.jsx(ze,{asChild:!0,children:r.jsx(le,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7",onClick:a,"aria-label":b,children:y})}),e[25]=a,e[26]=b,e[27]=_):_=e[27];let L;e[28]!==l?(L=l("sandbox.postToolbar.exitSelection"),e[28]=l,e[29]=L):L=e[29];let w;e[30]!==L?(w=r.jsx(Ke,{side:"bottom",children:L}),e[30]=L,e[31]=w):w=e[31];let j;e[32]!==_||e[33]!==w?(j=r.jsxs(Ue,{children:[_,w]}),e[32]=_,e[33]=w,e[34]=j):j=e[34];let S;e[35]!==v||e[36]!==j?(S=r.jsxs("div",{className:"ml-auto flex items-center gap-0.5",children:[v,j]}),e[35]=v,e[36]=j,e[37]=S):S=e[37];let C;return e[38]!==c||e[39]!==S||e[40]!==h?(C=r.jsxs("div",{className:"flex items-center gap-0.5 border-b bg-accent/40 px-2 py-1.5",children:[c,h,S]}),e[38]=c,e[39]=S,e[40]=h,e[41]=C):C=e[41],C}function Yr(t){const e=F.c(34),{onDuplicate:s,onRename:n,onAddVariant:i,onEditSeo:o,onViewJson:a,onDelete:l}=t,c=re();let d;e[0]!==c?(d=c("sandbox.itemActions.moreActions"),e[0]=c,e[1]=d):d=e[1];let h;e[2]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx(oi,{size:14}),e[2]=h):h=e[2];let u;e[3]!==d?(u=r.jsx(ds,{asChild:!0,children:r.jsx("button",{type:"button","aria-label":d,className:"flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:bg-background hover:text-foreground cursor-pointer",onClick:SM,children:h})}),e[3]=d,e[4]=u):u=e[4];let f;e[5]!==n||e[6]!==c?(f=n&&r.jsxs(Xe,{onClick:n,children:[r.jsx(v9,{size:14}),c("sandbox.itemActions.rename")]}),e[5]=n,e[6]=c,e[7]=f):f=e[7];let m;e[8]!==s||e[9]!==c?(m=s&&r.jsxs(Xe,{onClick:s,children:[r.jsx(Os,{size:14}),c("sandbox.itemActions.duplicate")]}),e[8]=s,e[9]=c,e[10]=m):m=e[10];let p;e[11]!==i||e[12]!==c?(p=i&&r.jsxs(r.Fragment,{children:[r.jsx(rr,{}),r.jsxs(Xe,{onClick:i,className:"cursor-pointer text-success focus:text-success",children:[r.jsx(p9,{size:14}),c("sandbox.itemActions.addVariant")]})]}),e[11]=i,e[12]=c,e[13]=p):p=e[13];let g;e[14]!==o||e[15]!==a||e[16]!==c?(g=(o||a)&&r.jsxs(r.Fragment,{children:[r.jsx(rr,{}),o&&r.jsxs(Xe,{onClick:o,children:[r.jsx(sl,{size:14}),c("sandbox.itemActions.editSeo")]}),a&&r.jsxs(Xe,{onClick:a,children:[r.jsx(ea,{size:14}),c("sandbox.itemActions.viewJson")]})]}),e[14]=o,e[15]=a,e[16]=c,e[17]=g):g=e[17];let x;e[18]===Symbol.for("react.memo_cache_sentinel")?(x=r.jsx(rr,{}),e[18]=x):x=e[18];let v;e[19]===Symbol.for("react.memo_cache_sentinel")?(v=r.jsx(Ns,{size:14}),e[19]=v):v=e[19];let b;e[20]!==c?(b=c("sandbox.itemActions.delete"),e[20]=c,e[21]=b):b=e[21];let y;e[22]!==l||e[23]!==b?(y=r.jsxs(Xe,{onClick:l,className:"text-destructive focus:text-destructive",children:[v,b]}),e[22]=l,e[23]=b,e[24]=y):y=e[24];let _;e[25]!==y||e[26]!==f||e[27]!==m||e[28]!==p||e[29]!==g?(_=r.jsxs(hs,{align:"end",className:"w-44",children:[f,m,p,g,x,y]}),e[25]=y,e[26]=f,e[27]=m,e[28]=p,e[29]=g,e[30]=_):_=e[30];let L;return e[31]!==_||e[32]!==u?(L=r.jsxs(us,{children:[u,_]}),e[31]=_,e[32]=u,e[33]=L):L=e[33],L}function SM(t){return t.stopPropagation()}function wM(t){return t.split("/").pop()?.replace(/\.tsx?$/,"")||t||"Section"}function jM(t){const e=new Map;for(const s of t){const n=wM(s.resolveType),i=e.get(n);i?i.push(s):e.set(n,[s])}return[...e.entries()].map(([s,n])=>({label:s,sections:n})).sort((s,n)=>s.label.localeCompare(n.label))}function Xf(t){const e=F.c(8),{icon:s,label:n,className:i}=t;let o;e[0]!==i?(o=ie("flex items-center gap-1.5 px-2.5 pb-1 pt-1 text-xs font-medium text-muted-foreground/70",i),e[0]=i,e[1]=o):o=e[1];let a;e[2]!==s?(a=r.jsx(s,{size:13,className:"shrink-0"}),e[2]=s,e[3]=a):a=e[3];let l;return e[4]!==n||e[5]!==o||e[6]!==a?(l=r.jsxs("div",{className:o,children:[a,n]}),e[4]=n,e[5]=o,e[6]=a,e[7]=l):l=e[7],l}const Qf=A.lazy(()=>Bs(()=>import("./app-editor-CdS1tGJ2.js"),__vite__mapDeps([158,1,2,18,52,53,54,17,3,19,55,56,57,58,59,60,61,62,32,63,50,64,65,66,67,68,5,16,20,4,6,7,8,9,10,11,12,13,14,15,21,22,23,24,25,26,27,28,29,30,31,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,51,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,106,107,108,109,110,111,112,113,114,115,116,117,103,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,105,151,152,153,154,155])).then(t=>({default:t.AppEditor}))),CM=A.lazy(()=>Bs(()=>import("./post-editor-BYA6kioK.js"),__vite__mapDeps([159,1,2,5,34,4,6,7,8,9,10,11,12,13,14,15,16,17,3,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,102,101,160,131,134,118,119,77,111,121,128,54,161,92,52,53,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,78,79,80,81,82,83,84,85,86,87,88,89,90,91,93,94,95,96,97,98,99,100,162,163,107,108,109,110,112,113,114,115,116,117,103,120,122,123,124,125,126,127,129,130,132,133,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,105,151,152,153,154,155])).then(t=>({default:t.PostEditor}))),kM=A.lazy(()=>Bs(()=>import("./record-editor-3_i-4UK5.js"),__vite__mapDeps([164,1,2,102,101,53,54,17,3,19,128,162,4,5,6,7,8,9,10,11,12,13,14,15,16,18,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,163,83,84,79,58,59,80,81,82,70,60,85,86,78,87,88,52,55,56,57,61,62,63,64,65,66,67,68,69,71,72,73,74,75,76,77,89,90,91,92,93,94,95,96,97,98,99,100,107,108,109,110,111,112,113,114,115,116,117,103,118,119,120,121,122,123,124,125,126,127,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,105,151,152,153,154,155])).then(t=>({default:t.RecordEditor}))),VM=A.lazy(()=>Bs(()=>import("./category-editor-DHD2RkWu.js"),__vite__mapDeps([165,1,2,10,14,34,4,5,6,7,8,9,11,12,13,15,16,17,3,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,139,102,101,161,118,119,77,111,92,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,78,79,80,81,82,83,84,85,86,87,88,89,90,91,93,94,95,96,97,98,99,100,162,163,107,108,109,110,112,113,114,115,116,117,103,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,140,141,142,143,144,145,146,147,148,149,150,105,151,152,153,154,155])).then(t=>({default:t.CategoryEditor}))),NM=A.lazy(()=>Bs(()=>import("./bulk-category-panel-7Z7LJBC2.js"),__vite__mapDeps([166,1,2,14,50,101,53,54,17,3,19,7,83,84,79,58,59,80,81,82,70,60,85,86,78,87,88,52,55,56,57,61,62,32,63,64,65,66,67,68,5,16,20,4,6,8,9,10,11,12,13,15,18,21,22,23,24,25,26,27,28,29,30,31,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,51,69,71,72,73,74,75,76,77,89,90,91,92,93,94,95,96,97,98,99,100,102,107,108,109,110,111,112,113,114,115,116,117,103,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,105,151,152,153,154,155])).then(t=>({default:t.BulkCategoryPanel}))),TM=A.lazy(()=>Bs(()=>import("./sections-editor-qd7Dwqwc.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155])).then(t=>({default:t.SectionsEditor}))),AM=A.lazy(()=>Bs(()=>import("./seo-editor-wLb7dDyd.js"),__vite__mapDeps([167,1,2,18,4,5,6,7,8,9,10,11,12,13,14,15,16,17,3,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,104,105,107,108,109,110,111,112,113,114,115,116,117,103,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155])).then(t=>({default:t.SeoEditor}))),EM=A.lazy(()=>Bs(()=>import("./variant-calendar-D_jp21Fc.js"),__vite__mapDeps([168,1,2,4,5,6,7,8,9,10,11,12,13,14,15,16,17,3,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,101,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,102,105,169])).then(t=>({default:t.VariantCalendar}))),PM=A.lazy(()=>Bs(()=>import("./redirect-editor-C87YqCVU.js"),__vite__mapDeps([170,1,2,134,17,102,101,53,54,3,19,163,7,83,84,79,58,59,80,81,82,70,60,85,86,78,87,88,52,55,56,57,61,62,32,63,50,64,65,66,67,68,5,16,20,4,6,8,9,10,11,12,13,14,15,18,21,22,23,24,25,26,27,28,29,30,31,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,51,69,71,72,73,74,75,76,77,89,90,91,92,93,94,95,96,97,98,99,100,107,108,109,110,111,112,113,114,115,116,117,103,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,105,151,152,153,154,155])).then(t=>({default:t.RedirectEditor})));function dd(t){return t?t.kind==="page"?{collection:"pages",key:t.key,path:t.path}:{collection:"sections",key:t.key}:null}function RM(t){return t?t.kind==="page"?`page:${t.key}:${t.path}`:`section:${t.key}`:null}function DM(t){const e=F.c(21),{mode:s}=t,n=s===void 0?"content":s,i=ci(),{data:o}=Di.useSession(),{currentBranch:a}=Zt(),{org:l}=Oe(),c=i?.entity?.id??null,d=o?.user?.id,h=i?.entity?.metadata,u=d&&a?zl(h?.sandboxMap?.[d]?.[a]):{},f=Object.values(u),p=(f.find(IM)??f[0])?.previewUrl??null,g=Fs(),x=i?.entity?.organization_id??"";let v;e[0]!==l.slug||e[1]!==x?(v={connectionId:Jo,orgId:x,orgSlug:l.slug},e[0]=l.slug,e[1]=x,e[2]=v):v=e[2];const b=ht(v),y=w9(b);let _;e[3]!==a||e[4]!==y||e[5]!==c?(_=()=>{if(!c)return;const N={virtualMcpId:c};a&&(N.branch=a),y.mutate(N)},e[3]=a,e[4]=y,e[5]=c,e[6]=_):_=e[6];const L=_,w=!!c&&!!a&&vl.isStopped(c,a),j=Z2({previewUrl:p,appPaused:g.status.state==="paused",userStopped:w,startError:y.isError&&y.error?tp(y.error.message):null});if(j.kind==="othersThread")return null;if(j.kind!=="iframe"){const N=`/${l.slug}/settings/connections`;let V;return e[7]!==j||e[8]!==N||e[9]!==L||e[10]!==g.lifecycle||e[11]!==g.phase?(V=r.jsx(rP,{state:j,claimPhase:g.phase,lifecycle:g.lifecycle,onStart:L,connectionsHref:N}),e[7]=j,e[8]=N,e[9]=L,e[10]=g.lifecycle,e[11]=g.phase,e[12]=V):V=e[12],V}if(!c||!a){let N;return e[13]===Symbol.for("react.memo_cache_sentinel")?(N=r.jsx(Hn,{title:"Waiting for sandbox context…"}),e[13]=N):N=e[13],N}const S=g.lifecycle.phase==="running";let C;return e[14]!==a||e[15]!==n||e[16]!==l.slug||e[17]!==p||e[18]!==S||e[19]!==c?(C=r.jsx(OM,{orgSlug:l.slug,virtualMcpId:c,branch:a,previewUrl:p,mode:n,devServerReady:S}),e[14]=a,e[15]=n,e[16]=l.slug,e[17]=p,e[18]=S,e[19]=c,e[20]=C):C=e[20],C}function IM(t){return t.sandboxProviderKind!=="user-desktop"}const Zf=2e3,MM=15;function e1(t,e,s,n){return typeof e!="string"||s&&(Fg(e,s,n)||t.state.dataUpdateCount>=MM)?!1:Zf}function OM({orgSlug:t,virtualMcpId:e,branch:s,previewUrl:n,mode:i,devServerReady:o}){const a=hu(),l={orgSlug:t,virtualMcpId:e,branch:s,previewUrl:n},c=HE(e),{data:d,isLoading:h}=rc(l,{fetchEnabled:o}),[u,f]=A.useState("pages"),[m,p]=A.useState(()=>i==="blocks"?dd(a.state.target):null),[g,x]=A.useState(()=>i==="blocks"?a.state.editSeoPageKey:null),v=RM(a.state.target),[b,y]=A.useState(v);if(i==="blocks"&&b!==v){y(v);const ae=dd(a.state.target);p(ae),(ae?.collection==="pages"||ae?.collection==="sections")&&f(ae.collection)}const[_,L]=A.useState(a.state.editSeoPageKey);if(i==="blocks"&&_!==a.state.editSeoPageKey&&(L(a.state.editSeoPageKey),a.state.editSeoPageKey)){const ae=a.state.target;ae?.kind==="page"&&(f("pages"),p(dd(ae)),x(ae.key))}const[w,j]=A.useState(""),[S,C]=A.useState(null),[N,V]=A.useState(null),[E,T]=A.useState("date-desc"),[k,R]=A.useState(()=>new Set),[P,D]=A.useState(null),I=()=>{R(new Set),D(null)},M=ae=>{p(ae),x(null),!(i!=="blocks"||!ae)&&(ae.collection==="pages"?a.selectTarget({kind:"page",key:ae.key,path:ae.path}):ae.collection==="sections"&&a.selectTarget({kind:"section",key:ae.key}))},[O,$]=A.useState(u);O!==u&&($(u),j(""),C(null),V(null),T("date-desc"),R(new Set),D(null));const{data:B,isLoading:z,isFetching:K}=oc(l,{fetchEnabled:o,refetchInterval:ae=>{const Te=ae.state.data;if(u==="apps"&&m&&m.collection==="apps"){const We=d?.[m.key];return e1(ae,typeof We?.__resolveType=="string"?We.__resolveType:void 0,Te)}if(u==="site"&&d){const We=Te?Bd(d,Te):null,Ge=d.site,mt=We?.resolveType??(typeof Ge?.__resolveType=="string"?Ge.__resolveType:void 0);return e1(ae,mt,Te,["seo"])}return!1}}),G=(ae,Te)=>!Fg(ae,B,Te)&&(z||K),{catalog:Y,isLoading:U}=nP(B??void 0,d??void 0,{enabled:u==="apps"}),W=yc(l),H=GE(l),X=IP({...l,packagePath:c}),q=MP({...l,packagePath:c}),[Z,Q]=A.useState(null),[ee,J]=A.useState(),[te,se]=A.useState(null),[ne,de]=A.useState(null),[xe,ue]=A.useState(null);if(h||z)return r.jsx("div",{className:"h-full w-full flex items-center justify-center",children:r.jsx(et,{size:20,className:"animate-spin text-muted-foreground"})});if(!d||!B)return r.jsx(Hn,{title:"Could not load site data."});const ce=M9(d).sort((ae,Te)=>ae.name.localeCompare(Te.name)),oe=Op(d).sort((ae,Te)=>ae.from.localeCompare(Te.from)),fe=O9(d,B),pe=u==="sections"?sw(B):[],we=Bd(d,B),Ne=qg(d),Fe=fu.some(ae=>Ne[ae].length>0),je=So(u)?Ne[u]:[],Ie=(Fe?Ko(d,"categories"):[]).map(({key:ae,payload:Te})=>{const We=typeof Te.slug=="string"?Te.slug:"",Ge=typeof Te.name=="string"?Te.name:"";return{slug:We||ae,name:Ge||We||ae}}).filter(ae=>ae.slug).sort((ae,Te)=>ae.name.localeCompare(Te.name)),Pe=u==="posts"&&(k.size>0||P!==null),Ye=Pe?Yg(d).filter(ae=>k.has(ae.key)):[],_e=gf(B,"loaders"),Ae=gf(B,"actions");if(!I9(d,B)&&!Fe&&_e===0&&Ae===0)return r.jsx(Hn,{icon:wn,title:"No editable content",description:"This project doesn't expose any Deco pages, sections, apps, loaders, or actions."});const Re={pages:ce.length,sections:fe.length,apps:Y.length,loaders:_e,actions:Ae,redirects:oe.length,posts:Ne.posts.length,authors:Ne.authors.length,categories:Ne.categories.length},ye=new Set(ce.map(ae=>Gn(ae.path))),ve=new Set(ce.map(ae=>ae.name)),Le=new Set(fe.map(ae=>ae.name)),$e=async ae=>{const Te=d[ae.key];if(!Te)return;const We=yg(d,ae.key),Ge=Lg(d,ae.key,Math.max(0,We-1)),mt=SA(Te.sections,Ge);if(mt)try{await W.mutateAsync({blockKey:ae.key,data:{...Te,sections:mt}}),ge.success(`Variant added to "${ae.name}"`),p({collection:"pages",key:ae.key,path:ae.path})}catch(wt){ge.error(wt instanceof Error?wt.message:"Could not add variant")}},ke=()=>{J(void 0),Q({mode:"create",sourceKey:null,initialName:"My new page",initialPath:"/example"})},Se=ae=>{J(void 0),Q({mode:"duplicate",sourceKey:ae.key,initialName:Lf(ve,ae.name),initialPath:oP(ye,ae.path)})},Be=ae=>{J(void 0),Q({mode:"rename",sourceKey:ae.key,initialName:ae.name,initialPath:ae.path})},nt=async ae=>{if(!Z)return;const{mode:Te,sourceKey:We}=Z;try{if(Te==="create"){let Ge;if(ae.templateKey){const wt=d[ae.templateKey];if(!wt)throw new Error("Selected template no longer exists.");Ge={...wt,name:ae.name,path:ae.path}}else Ge=cP(ae.name,ae.path);const mt=uP(d,ae.name);await W.mutateAsync({blockKey:mt,data:Ge}),ge.success(`Created "${ae.name}"`),p({collection:"pages",key:mt,path:ae.path})}else if(Te==="duplicate"&&We){const Ge=d[We];if(!Ge)throw new Error("Source page not found");const{key:mt,data:wt}=lP({source:Ge,pages:ce,newName:ae.name,newPath:ae.path});await W.mutateAsync({blockKey:mt,data:wt}),ge.success(`Duplicated as "${ae.name}"`),p({collection:"pages",key:mt,path:ae.path})}else if(Te==="rename"&&We){const Ge=d[We];if(!Ge)throw new Error("Page not found");const mt={...Ge,name:ae.name,path:ae.path};await W.mutateAsync({blockKey:We,data:mt}),ge.success("Page updated"),m?.collection==="pages"&&m.key===We&&p({collection:"pages",key:We,path:ae.path})}Q(null)}catch(Ge){J(Ge instanceof Error?Ge.message:"Save failed")}},pt=({path:ae})=>{if(!Z)return null;const Te=Gn(ae);return(Z.mode==="rename"?Gn(Z.initialPath):null)!==Te&&ye.has(Te)?`A page with path "${ae}" already exists.`:null},Je=async(ae,Te,We)=>{await W.mutateAsync({blockKey:Te,data:{...We,name:Te,__resolveType:ae}}),ge.success(`Created section "${Te}"`),p({collection:"sections",key:Te})},gt=Hg((ae,Te)=>W.mutate({blockKey:ae,data:Te})),dt=async ae=>{const Te=d[ae.key];if(!Te){ge.error("Section not found.");return}const We=aP(d,ae.key),Ge=Lf(Le,ae.name),mt={...Te,name:Ge};try{await W.mutateAsync({blockKey:We,data:mt}),ge.success(`Duplicated "${ae.name}"`),p({collection:"sections",key:We})}catch(wt){ge.error(wt instanceof Error?wt.message:"Duplicate failed")}},st=async ae=>{if(!te)return;const Te=d[te];if(!Te){ge.error("Section not found.");return}try{await W.mutateAsync({blockKey:te,data:{...Te,name:ae}}),ge.success("Section renamed"),se(null)}catch(We){ge.error(We instanceof Error?We.message:"Rename failed")}},ft=async()=>{const ae="/redirect-from",Te=cw(d,ae),We=ow({from:ae,to:"/redirect-to",type:"temporary",discardQueryParameters:!1});try{await W.mutateAsync({blockKey:Te,data:We}),ge.success("Created redirect"),p({collection:"redirects",key:Te})}catch(Ge){ge.error(Ge instanceof Error?Ge.message:"Could not create redirect")}},me=async ae=>{const Te=jf(d,ae),We=Va(Te,ae,kP(ae));try{await X.mutateAsync({blockKey:Te,data:We}),ge.success(`Created ${Lo[ae]}`),p({collection:ae,key:Te})}catch(Ge){ge.error(Ge instanceof Error?Ge.message:"Could not create")}},De=async ae=>{const Te=d[ae.key];if(!Te){ge.error("Record not found.");return}const We=jf(d,ae.kind),Ge=ae.kind==="posts"?"title":"name",mt={...structuredClone(Wa(Te,ae.kind)),[Ge]:`${ae.label} (copy)`};try{await X.mutateAsync({blockKey:We,data:Va(We,ae.kind,mt)}),ge.success(`Duplicated "${ae.label}"`),p({collection:ae.kind,key:We})}catch(wt){ge.error(wt instanceof Error?wt.message:"Duplicate failed")}},Qe=ae=>{R(Te=>{const We=new Set(Te);return We.has(ae)?We.delete(ae):We.add(ae),We})},xt=ae=>{f("posts"),$("posts"),p(null),x(null),j(""),C(null),V(null),T("date-desc"),R(new Set),D(ae||null)},ls=async(ae,Te)=>{const We=[...k];let Ge=0;for(const mt of We){const wt=d[mt],Bn=Wa(wt,"posts"),di=ae==="add"?wP(Bn,Te):jP(Bn,Te);di!==Bn&&(await X.mutateAsync({blockKey:mt,data:Va(mt,"posts",wf(di))}),Ge+=1)}return Ge},Vt=async(ae,Te)=>{const We=k.size;try{const Ge=await ls(ae,Te),mt=ae==="add"?"Added to":"Moved",wt=We-Ge;ge.success(`${mt} ${Ge} ${Ge===1?"post":"posts"}`+(wt>0?` (${wt} already set)`:"")),I()}catch(Ge){ge.error(Ge instanceof Error?Ge.message:"Bulk update failed")}},Ut=async()=>{if(ne)try{if(ne.kind==="blog-bulk"){for(const Ge of ne.keys)await q.mutateAsync({blockKey:Ge});ge.success(`Deleted ${ne.count} ${ne.count===1?"post":"posts"}`),m&&m.collection!=="available-section"&&ne.keys.includes(m.key)&&p(null),I(),de(null);return}const{kind:ae,key:Te,label:We}=ne;if(ae==="blog"){if(ne.blogKind==="categories"){const Ge=Wa(d[Te],"categories").slug,mt=typeof Ge=="string"?Ge:"";if(mt)for(const{key:wt,payload:Bn}of Ko(d,"posts")){const di=CP(Bn,mt);di!==Bn&&await X.mutateAsync({blockKey:wt,data:Va(wt,"posts",wf(di))})}}await q.mutateAsync({blockKey:Te})}else await H.mutateAsync({blockKey:Te});ge.success(`Deleted "${We}"`),m&&m.collection!=="available-section"&&m.key===Te&&p(null),de(null)}catch(ae){ge.error(ae instanceof Error?ae.message:"Delete failed")}},is=H.isPending||q.isPending||X.isPending,He=ne?.kind==="blog"?Lo[ne.blogKind]:ne?.kind==="blog-bulk"?`${ne.count} ${ne.count===1?"post":"posts"}`:ne?.kind??"item";return r.jsxs("div",{className:"flex h-full w-full",children:[i==="content"&&r.jsx(iP,{active:u,counts:Re,showBlog:Fe,onSelect:ae=>{f(ae),p(null),x(null)}}),u!=="seo"&&u!=="site"&&u!=="calendar"&&u!=="loaders"&&u!=="actions"&&r.jsx(BM,{blocksMode:i==="blocks",activeCollection:u,pages:ce,redirects:oe,sections:fe,availableSections:pe,appCatalog:Y,appCatalogLoading:U,blogEntries:je,decofile:d,searchQuery:w,onSearchChange:j,postCategoryFilter:S,postAuthorFilter:N,postSort:E,onPostCategoryFilterChange:ae=>{C(ae),R(new Set)},onPostAuthorFilterChange:ae=>{V(ae),R(new Set)},onPostSortChange:T,selectedPostKeys:k,postBulkPanelOpen:Pe,onTogglePostSelect:Qe,onSelectAllPosts:ae=>R(new Set(ae)),onClearPostSelection:()=>R(new Set),onExitPostSelection:I,onBulkDeletePosts:()=>de({kind:"blog-bulk",keys:[...k],count:k.size}),selection:m,onSelect:M,onCollectionSelect:ae=>{f(ae),p(null),x(null)},onCreate:()=>{u==="pages"?ke():u==="redirects"?ft():So(u)&&me(u)},onDuplicatePage:Se,onRenamePage:Be,onAddPageVariant:$e,onDeletePage:ae=>de({kind:"page",key:ae.key,label:ae.name}),onEditPageSeo:ae=>{const Te={collection:"pages",key:ae.key,path:ae.path};p(Te),x(ae.key),i==="blocks"&&a.editSeo({kind:"page",key:ae.key,path:ae.path})},onViewPageJson:ae=>ue(ae.key),onDuplicateSection:dt,onRenameSection:ae=>se(ae.key),onDeleteSection:ae=>de({kind:"section",key:ae.key,label:ae.name}),onDeleteRedirect:ae=>de({kind:"redirect",key:ae.key,label:ae.from||ae.key}),onDuplicateBlog:De,onDeleteBlog:ae=>de({kind:"blog",blogKind:ae.kind,key:ae.key,label:ae.label})}),r.jsx("div",{className:"flex-1 min-w-0",children:u==="loaders"||u==="actions"?r.jsx(eM,{orgSlug:t,virtualMcpId:e,branch:s,previewUrl:n,meta:B,decofile:d,kind:u}):r.jsx(A.Suspense,{fallback:r.jsx("div",{className:"h-full flex items-center justify-center",children:r.jsx(et,{size:20,className:"animate-spin text-muted-foreground"})}),children:u==="calendar"?r.jsx(EM,{decofile:d}):u==="site"?we?r.jsx(Qf,{orgSlug:t,virtualMcpId:e,branch:s,blockKey:we.key,block:d[we.key],decofile:d,meta:B,title:"Site",excludeFields:["seo"],schemaPending:G(we.resolveType,["seo"]),previewBaseUrl:n},`site:${we.key}`):r.jsx(Hn,{title:"Site settings not found",description:"This project doesn't have a site app block (site/apps/site.ts)."}):u==="seo"?r.jsx(AM,{orgSlug:t,virtualMcpId:e,branch:s,decofile:d,meta:B,target:{kind:"site"},previewBaseUrl:n}):u==="sections"?r.jsx(mM,{selection:m?.collection==="sections"||m?.collection==="available-section"?m:null,orgSlug:t,virtualMcpId:e,branch:s,previewUrl:n,meta:B,decofile:d,isCreating:W.isPending,onCreateAvailable:Je,onSaveReferencedBlock:gt}):Pe?r.jsx(NM,{posts:Ye,categories:Ie,initialSlug:P,isPending:X.isPending,onApply:(ae,Te)=>{Vt(ae,Te)},onClose:I},P??"selection"):m&&m.collection!=="available-section"?m.collection==="apps"?r.jsx(Qf,{orgSlug:t,virtualMcpId:e,branch:s,blockKey:m.key,block:d[m.key],decofile:d,meta:B,previewBaseUrl:n,schemaPending:G(typeof d[m.key]?.__resolveType=="string"?String(d[m.key].__resolveType):void 0)},`app:${m.key}`):m.collection==="posts"?r.jsx(CM,{orgSlug:t,virtualMcpId:e,branch:s,blockKey:m.key,block:d[m.key],decofile:d,meta:B,previewBaseUrl:n},`post:${m.key}`):m.collection==="categories"?r.jsx(VM,{orgSlug:t,virtualMcpId:e,branch:s,blockKey:m.key,block:d[m.key],decofile:d,meta:B,onManagePosts:xt,onOpenPost:ae=>{f("posts"),$("posts"),p({collection:"posts",key:ae}),x(null)},previewBaseUrl:n},`category:${m.key}`):m.collection==="authors"?r.jsx(kM,{orgSlug:t,virtualMcpId:e,branch:s,kind:"authors",blockKey:m.key,block:d[m.key]},`authors:${m.key}`):m.collection==="redirects"?r.jsx(PM,{orgSlug:t,virtualMcpId:e,branch:s,blockKey:m.key,block:d[m.key]},`redirect:${m.key}`):r.jsx(TM,{orgSlug:t,virtualMcpId:e,branch:s,previewReady:!0,previewUrl:n??void 0,currentPath:m.collection==="pages"?m.path:"/",activePageBlockKey:m.collection==="pages"?m.key:null,activeGlobalBlockKey:m.collection==="sections"?m.key:null,initialEditSeo:m.collection==="pages"&&g===m.key,onExitSeo:()=>{x(null),i==="blocks"&&a.consumeEditSeo()}},m.collection==="pages"?`page:${m.key}`:`section:${m.key}`):r.jsx(Hn,{title:`Select ${So(u)?`a ${Lo[u]}`:u==="pages"?"a page":u==="apps"?"an app":u==="redirects"?"a redirect":"a section"} to edit`,description:u==="apps"?"Browse all apps and select an installed one to edit its settings.":'Pick an item from the list, or click "+" to create one.'})})}),Z&&r.jsx(pP,{open:!!Z,mode:Z.mode,initialName:Z.initialName,initialPath:Z.initialPath,isPending:W.isPending,error:ee,templates:ce,validate:pt,onSubmit:nt,onOpenChange:ae=>{ae||(Q(null),J(void 0))}}),te&&r.jsx(gP,{open:!!te,blockKey:te,initialName:fe.find(ae=>ae.key===te)?.name??te,isPending:W.isPending,onSubmit:st,onOpenChange:ae=>{ae||se(null)}}),xe&&r.jsx(OP,{open:!!xe,onOpenChange:ae=>{ae||ue(null)},pageKey:xe,decofile:d,onSave:ae=>W.mutateAsync({blockKey:xe,data:ae})}),r.jsx(al,{open:!!ne,onOpenChange:ae=>{!ae&&!is&&de(null)},children:r.jsxs(ll,{children:[r.jsxs(cl,{children:[r.jsx(dl,{children:`Delete ${He}?`}),r.jsx(ul,{children:ne?.kind==="section"?`"${ne.label}" will be removed. Pages that still reference it will lose this section.`:ne?.kind==="blog-bulk"?`${ne.count} ${ne.count===1?"post":"posts"} will be removed permanently. This can't be undone.`:ne?`"${ne.label}" will be removed permanently. This can't be undone.`:null})]}),r.jsxs(hl,{children:[r.jsx(fl,{disabled:is,children:"Cancel"}),r.jsx(ml,{onClick:ae=>{ae.preventDefault(),Ut()},disabled:is,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:is?r.jsxs(r.Fragment,{children:[r.jsx(et,{size:14,className:"animate-spin"}),"Deleting…"]}):"Delete"})]})]})})]})}function BM(t){const e=F.c(88),{blocksMode:s,activeCollection:n,pages:i,redirects:o,sections:a,availableSections:l,appCatalog:c,appCatalogLoading:d,blogEntries:h,decofile:u,searchQuery:f,onSearchChange:m,postCategoryFilter:p,postAuthorFilter:g,postSort:x,onPostCategoryFilterChange:v,onPostAuthorFilterChange:b,onPostSortChange:y,selectedPostKeys:_,postBulkPanelOpen:L,onTogglePostSelect:w,onSelectAllPosts:j,onClearPostSelection:S,onExitPostSelection:C,onBulkDeletePosts:N,selection:V,onSelect:E,onCollectionSelect:T,onCreate:k,onDuplicatePage:R,onRenamePage:P,onAddPageVariant:D,onDeletePage:I,onEditPageSeo:M,onViewPageJson:O,onDuplicateSection:$,onRenameSection:B,onDeleteSection:z,onDeleteRedirect:K,onDuplicateBlog:G,onDeleteBlog:Y}=t;let U,W,H,X,q,Z,Q,ee;if(e[0]!==n||e[1]!==c||e[2]!==d||e[3]!==l||e[4]!==s||e[5]!==h||e[6]!==u||e[7]!==D||e[8]!==N||e[9]!==S||e[10]!==T||e[11]!==k||e[12]!==Y||e[13]!==I||e[14]!==K||e[15]!==z||e[16]!==G||e[17]!==R||e[18]!==$||e[19]!==M||e[20]!==C||e[21]!==b||e[22]!==v||e[23]!==y||e[24]!==P||e[25]!==B||e[26]!==m||e[27]!==E||e[28]!==j||e[29]!==w||e[30]!==O||e[31]!==i||e[32]!==g||e[33]!==L||e[34]!==p||e[35]!==x||e[36]!==o||e[37]!==f||e[38]!==a||e[39]!==_||e[40]!==V){const ne=f.toLowerCase(),de=i.filter(me=>!ne||me.name.toLowerCase().includes(ne)||me.path.toLowerCase().includes(ne)),xe=o.filter(me=>!ne||me.from.toLowerCase().includes(ne)||me.to.toLowerCase().includes(ne)),ue=a.filter(me=>!ne||me.name.toLowerCase().includes(ne)||me.key.toLowerCase().includes(ne)||me.resolveType.toLowerCase().includes(ne)),ce=l.filter(me=>!ne||me.title.toLowerCase().includes(ne)||me.resolveType.toLowerCase().includes(ne)||(me.description?.toLowerCase().includes(ne)??!1)),oe=jM(ue),fe=c.filter(me=>!ne||me.title.toLowerCase().includes(ne)||me.app.toLowerCase().includes(ne)||me.vendor.toLowerCase().includes(ne)||me.category.toLowerCase().includes(ne)),pe=h.filter(me=>!ne||me.label.toLowerCase().includes(ne)||me.subtitle.toLowerCase().includes(ne)),we=n==="posts",Ne=KM,Fe=we?Yg(u):[],je=new Map,Ie=new Map;for(const me of Fe){for(const De of me.categorySlugs)je.set(De,(je.get(De)??0)+1);for(const De of me.authorEmails)Ie.set(De,(Ie.get(De)??0)+1)}const Pe=(we?Ko(u,"categories"):[]).map(me=>{const{key:De,payload:Qe}=me,xt=Ne(Qe.slug)||De;return{slug:xt,name:Ne(Qe.name)||Ne(Qe.slug)||De,count:je.get(xt)??0}}).filter(zM),Ye=(we?Ko(u,"authors"):[]).map(me=>{const{key:De,payload:Qe}=me,xt=Ne(Qe.email);return{email:xt,name:Ne(Qe.name)||Ne(Qe.email)||De,count:Ie.get(xt)??0}}).filter(FM);let _e;e[49]!==p?(_e=me=>!p||me.categorySlugs.includes(p),e[49]=p,e[50]=_e):_e=e[50];let Ae;e[51]!==g?(Ae=me=>!g||me.authorEmails.includes(g),e[51]=g,e[52]=Ae):Ae=e[52];let Re;e[53]!==x?(Re=(me,De)=>{if(x==="az")return me.title.localeCompare(De.title);if(x==="za")return De.title.localeCompare(me.title);const Qe=me.date.localeCompare(De.date);return x==="date-asc"?Qe:-Qe},e[53]=x,e[54]=Re):Re=e[54];const ye=Fe.filter(me=>!ne||me.title.toLowerCase().includes(ne)||me.slug.toLowerCase().includes(ne)).filter(_e).filter(Ae).sort(Re),ve=_.size,Le=ye.map($M),$e=Le.length>0&&Le.every(me=>_.has(me)),ke=ve>0||L,Se=()=>{$e?S():j(Le)},Be=`Search ${n}…`,nt=So(n)?`Create new ${Lo[n]}`:n==="redirects"?"Create new redirect":"Create new page",pt=n!=="apps"&&n!=="sections",Je=s?"w-[240px]":"w-[300px]";e[55]!==Je?(q=ie("shrink-0 border-r flex flex-col min-h-0",Je),e[55]=Je,e[56]=q):q=e[56],e[57]!==n||e[58]!==s||e[59]!==T?(Z=s&&r.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-1 border-b px-2",children:[r.jsxs(le,{variant:n==="pages"?"secondary":"ghost",size:"sm",className:"h-7 flex-1",onClick:()=>T("pages"),children:[r.jsx(Nn,{size:14}),"Pages"]}),r.jsxs(le,{variant:n==="sections"?"secondary":"ghost",size:"sm",className:"h-7 flex-1",onClick:()=>T("sections"),children:[r.jsx(gn,{size:14}),"Sections"]})]}),e[57]=n,e[58]=s,e[59]=T,e[60]=Z):Z=e[60];let gt;e[61]===Symbol.for("react.memo_cache_sentinel")?(gt=r.jsx(g9,{size:14,className:"shrink-0 text-muted-foreground","aria-hidden":!0}),e[61]=gt):gt=e[61];let dt;e[62]!==m?(dt=me=>m(me.target.value),e[62]=m,e[63]=dt):dt=e[63];let st;e[64]!==Be||e[65]!==f||e[66]!==dt?(st=r.jsxs("div",{className:"flex flex-1 items-center gap-2 pl-1",children:[gt,r.jsx("input",{type:"text",value:f,onChange:dt,placeholder:Be,"aria-label":Be,className:"w-full bg-transparent text-sm outline-none placeholder:text-muted-foreground"})]}),e[64]=Be,e[65]=f,e[66]=dt,e[67]=st):st=e[67];let ft;e[68]!==nt||e[69]!==k||e[70]!==pt?(ft=pt&&r.jsxs(Ue,{children:[r.jsx(ze,{asChild:!0,children:r.jsx(le,{variant:"ghost",size:"icon",onClick:k,"aria-label":nt,children:r.jsx(kt,{size:14})})}),r.jsx(Ke,{side:"bottom",children:nt})]}),e[68]=nt,e[69]=k,e[70]=pt,e[71]=ft):ft=e[71],e[72]!==st||e[73]!==ft?(Q=r.jsxs("div",{className:"px-2 h-12 flex items-center gap-1 border-b shrink-0",children:[st,ft]}),e[72]=st,e[73]=ft,e[74]=Q):Q=e[74],ee=we&&(ke?r.jsx(LM,{count:ve,allSelected:$e,onToggleSelectAll:Se,onDelete:N,onExit:C}):r.jsx(gM,{categories:Pe,authors:Ye,categoryFilter:p,authorFilter:g,sort:x,onCategoryFilterChange:v,onAuthorFilterChange:b,onSortChange:y})),U=ii,X="flex-1 min-h-0 [&_[data-slot=scroll-area-viewport]>div]:!block",W="flex flex-col gap-1 p-1.5",H=n==="pages"?de.length===0?r.jsx(Ji,{hasItems:i.length>0,emptyLabel:"No pages yet.",emptyHint:'Click "+" to create your first page.'}):de.map(me=>{const De=V?.collection==="pages"&&V.key===me.key,Qe=yg(u,me.key);return r.jsx(Qs,{icon:Nn,title:me.name,subtitle:me.path,active:De,variantCount:Qe,onClick:()=>E({collection:"pages",key:me.key,path:me.path}),menu:r.jsx(Yr,{onDuplicate:()=>R(me),onRename:()=>P(me),onAddVariant:()=>D(me),onEditSeo:()=>M(me),onViewJson:()=>O(me),onDelete:()=>I(me)})},me.key)}):n==="sections"?ue.length===0&&ce.length===0?r.jsx(Ji,{hasItems:a.length>0||l.length>0,emptyLabel:"No sections yet.",emptyHint:"Save a section from a page, or start the preview dev server."}):r.jsxs(r.Fragment,{children:[oe.length>0&&r.jsxs(r.Fragment,{children:[r.jsx(Xf,{icon:gn,label:"Saved sections"}),oe.map(me=>r.jsxs("div",{className:"flex flex-col gap-1",children:[r.jsx("div",{className:"px-2.5 pt-1 pb-0.5 text-[11px] font-medium uppercase tracking-wide text-muted-foreground/60",children:me.label}),me.sections.map(De=>{const Qe=V?.collection==="sections"&&V.key===De.key;return r.jsx(Qs,{icon:gn,accent:"global",title:De.name,subtitle:me.label,active:Qe,onClick:()=>E({collection:"sections",key:De.key}),menu:r.jsx(Yr,{onDuplicate:()=>$(De),onRename:()=>B(De),onDelete:()=>z(De)})},De.key)})]},me.label))]}),ce.length>0&&r.jsxs(r.Fragment,{children:[r.jsx(Xf,{icon:Nn,label:"Available sections",className:ie(oe.length>0&&"mt-3")}),ce.map(me=>{const De=V?.collection==="available-section"&&V.resolveType===me.resolveType,Qe=me.resolveType.split("/").pop()?.replace(/\.tsx?$/,"");return r.jsx(Qs,{icon:Nn,title:me.title,subtitle:Qe??me.resolveType,active:De,onClick:()=>E({collection:"available-section",resolveType:me.resolveType,title:me.title})},me.resolveType)})]})]}):n==="apps"?d?r.jsx("div",{className:"flex items-center justify-center py-8",children:r.jsx(et,{size:18,className:"animate-spin text-muted-foreground"})}):fe.length===0?r.jsx(Ji,{hasItems:c.length>0,emptyLabel:"No apps found.",emptyHint:"Try a different search term."}):fe.map(me=>{const De=V?.collection==="apps"&&me.blockKey!==null&&V.key===me.blockKey;return r.jsx(Qs,{icon:L2,logoUrl:me.logo,title:me.title,subtitle:me.category,active:De,trailing:me.installed?r.jsx("span",{className:"shrink-0 rounded-full bg-success/15 px-1.5 py-0.5 text-[10px] font-medium text-success",children:"Installed"}):void 0,onClick:()=>{if(!me.installed||!me.blockKey){ge.message(`${me.title} is not installed on this site.`);return}E({collection:"apps",key:me.blockKey})}},me.id)}):n==="redirects"?xe.length===0?r.jsx(Ji,{hasItems:o.length>0,emptyLabel:"No redirects yet.",emptyHint:'Click "+" to create your first redirect.'}):xe.map(me=>r.jsx(Qs,{icon:zm,title:me.from||"(no source)",subtitle:`→ ${me.to||"(no target)"}`,active:V?.collection==="redirects"&&V.key===me.key,trailing:r.jsx(xP,{type:me.type}),onClick:()=>E({collection:"redirects",key:me.key}),menu:r.jsx(Yr,{onDelete:()=>K(me)})},me.key)):we?ye.length===0?r.jsx(Ji,{hasItems:Fe.length>0,emptyLabel:"No posts yet.",emptyHint:'Click "+" to create your first post.'}):ye.map(me=>{const De={key:me.key,kind:"posts",label:me.title,subtitle:me.slug};return r.jsx(Qs,{icon:mr,title:me.title,subtitle:me.slug||"no slug",invalid:me.missing.length>0,invalidReason:`Missing: ${me.missing.join(", ")}`,active:V?.collection==="posts"&&V.key===me.key,selectable:!0,selectionActive:ke,selected:_.has(me.key),onToggleSelect:()=>w(me.key),onClick:()=>ke?w(me.key):E({collection:"posts",key:me.key}),menu:r.jsx(Yr,{onDuplicate:()=>G(De),onDelete:()=>Y(De)})},me.key)}):pe.length===0?r.jsx(Ji,{hasItems:h.length>0,emptyLabel:`No ${n} yet.`,emptyHint:`Click "+" to create your first ${So(n)?Lo[n]:"item"}.`}):pe.map(me=>{const De=V?.collection===me.kind&&V.key===me.key;return r.jsx(Qs,{icon:me.kind==="posts"?mr:me.kind==="authors"?ec:Km,title:me.label,subtitle:me.subtitle,active:De,onClick:()=>E({collection:me.kind,key:me.key}),menu:r.jsx(Yr,{onDuplicate:()=>G(me),onDelete:()=>Y(me)})},me.key)}),e[0]=n,e[1]=c,e[2]=d,e[3]=l,e[4]=s,e[5]=h,e[6]=u,e[7]=D,e[8]=N,e[9]=S,e[10]=T,e[11]=k,e[12]=Y,e[13]=I,e[14]=K,e[15]=z,e[16]=G,e[17]=R,e[18]=$,e[19]=M,e[20]=C,e[21]=b,e[22]=v,e[23]=y,e[24]=P,e[25]=B,e[26]=m,e[27]=E,e[28]=j,e[29]=w,e[30]=O,e[31]=i,e[32]=g,e[33]=L,e[34]=p,e[35]=x,e[36]=o,e[37]=f,e[38]=a,e[39]=_,e[40]=V,e[41]=U,e[42]=W,e[43]=H,e[44]=X,e[45]=q,e[46]=Z,e[47]=Q,e[48]=ee}else U=e[41],W=e[42],H=e[43],X=e[44],q=e[45],Z=e[46],Q=e[47],ee=e[48];let J;e[75]!==W||e[76]!==H?(J=r.jsx("div",{className:W,children:H}),e[75]=W,e[76]=H,e[77]=J):J=e[77];let te;e[78]!==U||e[79]!==X||e[80]!==J?(te=r.jsx(U,{className:X,children:J}),e[78]=U,e[79]=X,e[80]=J,e[81]=te):te=e[81];let se;return e[82]!==q||e[83]!==Z||e[84]!==Q||e[85]!==ee||e[86]!==te?(se=r.jsxs("div",{className:q,children:[Z,Q,ee,te]}),e[82]=q,e[83]=Z,e[84]=Q,e[85]=ee,e[86]=te,e[87]=se):se=e[87],se}function $M(t){return t.key}function FM(t){return t.email}function zM(t){return t.slug}function KM(t){return typeof t=="string"?t:""}function UM(t){const e=F.c(13),{virtualMcpId:s}=t,n=re(),i=gs(s);if(!sn(i?.metadata)){let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(wn,{size:24,className:"text-muted-foreground/60"}),e[0]=l):l=e[0];let c;e[1]!==n?(c=n("mainPanelTabs.contentTab.noContentToEdit"),e[1]=n,e[2]=c):c=e[2];let d;e[3]!==c?(d=r.jsx("div",{children:c}),e[3]=c,e[4]=d):d=e[4];let h;e[5]!==n?(h=n("mainPanelTabs.contentTab.connectGithubDescription"),e[5]=n,e[6]=h):h=e[6];let u;e[7]!==h?(u=r.jsx("div",{className:"text-xs text-muted-foreground/80",children:h}),e[7]=h,e[8]=u):u=e[8];let f;return e[9]!==d||e[10]!==u?(f=r.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-2 text-center text-sm text-muted-foreground p-6",children:[l,d,u]}),e[9]=d,e[10]=u,e[11]=f):f=e[11],f}let a;return e[12]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx(DM,{}),e[12]=a):a=e[12],a}const ud={fast:{labelKey:"automations.automationConfig.tierFast",subtitleKey:"automations.automationConfig.tierFastSubtitle",icon:G0},smart:{labelKey:"automations.automationConfig.tierSmart",subtitleKey:"automations.automationConfig.tierSmartSubtitle",icon:qn},thinking:{labelKey:"automations.automationConfig.tierThinking",subtitleKey:"automations.automationConfig.tierThinkingSubtitle",icon:Am}},HM=["fast","smart","thinking"];function WM(t){const e=F.c(19),{tier:s,onSelect:n}=t,i=re(),[o,a]=A.useState(!1),l=ud[s].icon;let c;e[0]!==l?(c=r.jsx(l,{size:14,className:"text-muted-foreground"}),e[0]=l,e[1]=c):c=e[1];const d=ud[s];let h;e[2]!==i||e[3]!==d.labelKey?(h=i(d.labelKey),e[2]=i,e[3]=d.labelKey,e[4]=h):h=e[4];let u;e[5]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx(ss,{size:14,className:"text-muted-foreground"}),e[5]=u):u=e[5];let f;e[6]!==c||e[7]!==h?(f=r.jsx(Es,{asChild:!0,children:r.jsxs(le,{variant:"outline",size:"sm",className:"w-fit gap-1.5",children:[c,h,u]})}),e[6]=c,e[7]=h,e[8]=f):f=e[8];let m;e[9]!==n||e[10]!==i||e[11]!==s?(m=HM.map(x=>{const v=ud[x],b=v.icon;return r.jsxs("button",{type:"button",onClick:()=>{n(x),a(!1)},className:ie("flex items-start gap-2 px-2 py-1.5 rounded-md text-left hover:bg-muted"),children:[r.jsx(b,{size:16,className:"shrink-0 text-muted-foreground mt-0.5"}),r.jsxs("div",{className:"flex-1",children:[r.jsx("div",{className:"text-sm",children:i(v.labelKey)}),r.jsx("div",{className:"text-xs text-muted-foreground",children:i(v.subtitleKey)})]}),x===s&&r.jsx(zt,{size:14,className:"text-foreground mt-0.5"})]},x)}),e[9]=n,e[10]=i,e[11]=s,e[12]=m):m=e[12];let p;e[13]!==m?(p=r.jsx(Ps,{align:"start",className:"p-1 w-64",children:r.jsx("div",{className:"flex flex-col",children:m})}),e[13]=m,e[14]=p):p=e[14];let g;return e[15]!==o||e[16]!==f||e[17]!==p?(g=r.jsxs(As,{open:o,onOpenChange:a,children:[f,p]}),e[15]=o,e[16]=f,e[17]=p,e[18]=g):g=e[18],g}function qM(t){const e=F.c(27),{tier:s,onTierChange:n,override:i,onOverrideChange:o}=t,a=re(),[l,c]=A.useState(i!==null);let d;e[0]!==a?(d=a("automations.automationConfig.modelLabel"),e[0]=a,e[1]=d):d=e[1];let h;e[2]!==d?(h=r.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:d}),e[2]=d,e[3]=h):h=e[3];let u;e[4]!==o||e[5]!==n||e[6]!==i||e[7]!==a||e[8]!==s||e[9]!==l?(u=l?r.jsx(A.Suspense,{fallback:r.jsx(le,{variant:"outline",size:"sm",disabled:!0,className:"w-fit",children:a("automations.automationConfig.loadingModels")}),children:r.jsx(GM,{override:i,onOverrideChange:o})}):r.jsx(WM,{tier:s,onSelect:n}),e[4]=o,e[5]=n,e[6]=i,e[7]=a,e[8]=s,e[9]=l,e[10]=u):u=e[10];let f;e[11]!==o?(f=b=>{c(b),b||o(null)},e[11]=o,e[12]=f):f=e[12];let m;e[13]!==f||e[14]!==l?(m=r.jsx(xr,{checked:l,onCheckedChange:f,className:"cursor-pointer"}),e[13]=f,e[14]=l,e[15]=m):m=e[15];let p;e[16]!==a?(p=a("automations.automationConfig.specificModel"),e[16]=a,e[17]=p):p=e[17];let g;e[18]!==m||e[19]!==p?(g=r.jsxs("label",{className:"flex items-center gap-2 text-xs text-muted-foreground cursor-pointer select-none",children:[m,p]}),e[18]=m,e[19]=p,e[20]=g):g=e[20];let x;e[21]!==u||e[22]!==g?(x=r.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[u,g]}),e[21]=u,e[22]=g,e[23]=x):x=e[23];let v;return e[24]!==h||e[25]!==x?(v=r.jsxs("div",{className:"flex flex-col gap-2",children:[h,x]}),e[24]=h,e[25]=x,e[26]=v):v=e[26],v}function GM(t){const e=F.c(16),{override:s,onOverrideChange:n}=t,i=re(),o=n2(),a=o[0]?.id??null,[l,c]=A.useState(s?.credentialId??a);let d;e[0]!==s?(d=s?{modelId:s.modelId,title:s.title||s.modelId,keyId:s.credentialId,providerId:"deco",description:null,logo:null,capabilities:[],limits:null,costs:null}:null,e[0]=s,e[1]=d):d=e[1];const h=d;if(o.length===0){let p;e[2]!==i?(p=i("automations.automationConfig.connectAiProviderHint"),e[2]=i,e[3]=p):p=e[3];let g;return e[4]!==p?(g=r.jsx("span",{className:"text-xs text-muted-foreground italic",children:p}),e[4]=p,e[5]=g):g=e[5],g}let u;e[6]!==i?(u=i("automations.automationConfig.pickModelPlaceholder"),e[6]=i,e[7]=u):u=e[7];let f;e[8]!==l||e[9]!==n?(f=p=>{const g=p.keyId??l??"";c(g),n({modelId:p.modelId,credentialId:g,title:p.title??p.modelId})},e[8]=l,e[9]=n,e[10]=f):f=e[10];let m;return e[11]!==l||e[12]!==h||e[13]!==u||e[14]!==f?(m=r.jsx("div",{className:"w-fit max-w-full [&_button]:rounded-md",children:r.jsx(w6,{variant:"bordered",placeholder:u,model:h,credentialId:l,onCredentialChange:c,onModelChange:f})}),e[11]=l,e[12]=h,e[13]=u,e[14]=f,e[15]=m):m=e[15],m}const k4=[{key:"capabilities",headingKey:"automations.automationConfig.builtinCapabilities",icon:b9,tools:[{name:"web_search",titleKey:"automations.automationConfig.toolWebSearch",descriptionKey:"automations.automationConfig.toolWebSearchDesc",icon:ai},{name:"generate_image",titleKey:"automations.automationConfig.toolGenerateImage",descriptionKey:"automations.automationConfig.toolGenerateImageDesc",icon:En},{name:"subtask",titleKey:"automations.automationConfig.toolSubtask",descriptionKey:"automations.automationConfig.toolSubtaskDesc",icon:Zs},{name:"user_ask",titleKey:"automations.automationConfig.toolAskUser",descriptionKey:"automations.automationConfig.toolAskUserDesc",icon:l6}]},{key:"files",headingKey:"automations.automationConfig.filesCode",icon:Zn,tools:[{name:"read",titleKey:"automations.automationConfig.toolReadFile",descriptionKey:"automations.automationConfig.toolReadFileDesc",icon:l2},{name:"write",titleKey:"automations.automationConfig.toolWriteFile",descriptionKey:"automations.automationConfig.toolWriteFileDesc",icon:v9},{name:"edit",titleKey:"automations.automationConfig.toolEditFile",descriptionKey:"automations.automationConfig.toolEditFileDesc",icon:W0},{name:"grep",titleKey:"automations.automationConfig.toolSearchContent",descriptionKey:"automations.automationConfig.toolSearchContentDesc",icon:Io},{name:"glob",titleKey:"automations.automationConfig.toolFindFiles",descriptionKey:"automations.automationConfig.toolFindFilesDesc",icon:Zn},{name:"bash",titleKey:"automations.automationConfig.toolRunCommand",descriptionKey:"automations.automationConfig.toolRunCommandDesc",icon:c6}]},{key:"context",headingKey:"automations.automationConfig.context",icon:nl,tools:[{name:"read_resource",titleKey:"automations.automationConfig.toolReadResource",descriptionKey:"automations.automationConfig.toolReadResourceDesc",icon:nl},{name:"read_prompt",titleKey:"automations.automationConfig.toolReadPrompt",descriptionKey:"automations.automationConfig.toolReadPromptDesc",icon:fr},{name:"skill",titleKey:"automations.automationConfig.toolLoadSkill",descriptionKey:"automations.automationConfig.toolLoadSkillDesc",icon:fr}]},{key:"browser",headingKey:"automations.automationConfig.browser",icon:gn,tools:[{name:"take_screenshot",titleKey:"automations.automationConfig.toolTakeScreenshot",descriptionKey:"automations.automationConfig.toolTakeScreenshotDesc",icon:Nr},{name:"scrape_url",titleKey:"automations.automationConfig.toolScrapeUrl",descriptionKey:"automations.automationConfig.toolScrapeUrlDesc",icon:gn},{name:"inspect_page",titleKey:"automations.automationConfig.toolInspectPage",descriptionKey:"automations.automationConfig.toolInspectPageDesc",icon:ea}]}],YM=k4.flatMap(t=>t.tools.map(e=>e.name));function JM(t){const e=t.replace(/[_-]+/g," ").trim();return e?e.toLowerCase().replace(/\b\w/g,s=>s.toUpperCase()):t}function XM(t){const e=F.c(12),{agentId:s,value:n,onChange:i}=t,o=re();let a;e[0]!==o?(a=o("automations.automationConfig.toolsLabel"),e[0]=o,e[1]=a):a=e[1];let l;e[2]!==a?(l=r.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:a}),e[2]=a,e[3]=l):l=e[3];let c;e[4]!==s||e[5]!==i||e[6]!==o||e[7]!==n?(c=s?r.jsx(A.Suspense,{fallback:r.jsxs(le,{variant:"outline",size:"sm",disabled:!0,className:"w-fit",children:[r.jsx(b9,{size:14}),o("automations.automationConfig.loadingTools")]}),children:r.jsx(QM,{agentId:s,value:n,onChange:i})}):r.jsx("span",{className:"text-xs text-muted-foreground italic",children:o("automations.automationConfig.pickAgentFirst")}),e[4]=s,e[5]=i,e[6]=o,e[7]=n,e[8]=c):c=e[8];let d;return e[9]!==l||e[10]!==c?(d=r.jsxs("div",{className:"flex flex-col gap-2",children:[l,c]}),e[9]=l,e[10]=c,e[11]=d):d=e[11],d}function t1(t){const e=F.c(17),{value:s,checked:n,onToggle:i,title:o,description:a,leading:l}=t;let c;e[0]!==n?(c=r.jsx(Ar,{checked:n,className:"pointer-events-none mt-0.5"}),e[0]=n,e[1]=c):c=e[1];let d;e[2]!==l?(d=l&&r.jsx("span",{className:"mt-px shrink-0",children:l}),e[2]=l,e[3]=d):d=e[3];let h;e[4]!==o?(h=r.jsx("span",{className:"truncate text-sm leading-tight",children:o}),e[4]=o,e[5]=h):h=e[5];let u;e[6]!==a?(u=a&&r.jsx("span",{className:"line-clamp-2 text-xs leading-snug text-muted-foreground",children:a}),e[6]=a,e[7]=u):u=e[7];let f;e[8]!==h||e[9]!==u?(f=r.jsxs("div",{className:"flex min-w-0 flex-col gap-0.5",children:[h,u]}),e[8]=h,e[9]=u,e[10]=f):f=e[10];let m;return e[11]!==i||e[12]!==c||e[13]!==d||e[14]!==f||e[15]!==s?(m=r.jsxs(Vs,{value:s,onSelect:i,className:"items-start gap-2.5 py-2",children:[c,d,f]}),e[11]=i,e[12]=c,e[13]=d,e[14]=f,e[15]=s,e[16]=m):m=e[16],m}function s1(t){const e=F.c(27),{conn:s,label:n,icon:i,on:o,total:a,onToggle:l}=t,c=re(),d=o===a;let h;e[0]!==i||e[1]!==s?(h=s?r.jsx(an,{icon:s.icon,name:s.title,size:"2xs"}):i?r.jsx(i,{size:14,className:"text-muted-foreground"}):r.jsx(d6,{size:14,className:"text-muted-foreground"}),e[0]=i,e[1]=s,e[2]=h):h=e[2];let u;e[3]!==s?.title||e[4]!==n||e[5]!==c?(u=s?.title??n??c("automations.automationConfig.otherTools"),e[3]=s?.title,e[4]=n,e[5]=c,e[6]=u):u=e[6];let f;e[7]!==u?(f=r.jsx("span",{className:"truncate",children:u}),e[7]=u,e[8]=f):f=e[8];let m;e[9]!==o||e[10]!==a?(m=r.jsxs("span",{className:"text-[11px] font-normal tabular-nums text-muted-foreground/70",children:[o,"/",a]}),e[9]=o,e[10]=a,e[11]=m):m=e[11];let p;e[12]!==l?(p=y=>{y.stopPropagation(),l()},e[12]=l,e[13]=p):p=e[13];let g;e[14]!==d||e[15]!==c?(g=c(d?"automations.automationConfig.none":"automations.automationConfig.all"),e[14]=d,e[15]=c,e[16]=g):g=e[16];let x;e[17]!==p||e[18]!==g?(x=r.jsx("button",{type:"button",onClick:p,className:"text-[11px] font-medium text-primary hover:underline",children:g}),e[17]=p,e[18]=g,e[19]=x):x=e[19];let v;e[20]!==m||e[21]!==x?(v=r.jsxs("span",{className:"ml-auto flex items-center gap-2",children:[m,x]}),e[20]=m,e[21]=x,e[22]=v):v=e[22];let b;return e[23]!==h||e[24]!==f||e[25]!==v?(b=r.jsxs("div",{className:"flex items-center gap-2",children:[h,f,v]}),e[23]=h,e[24]=f,e[25]=v,e[26]=b):b=e[26],b}function QM(t){const e=F.c(83),{agentId:s,value:n,onChange:i}=t,o=re(),{org:a}=Oe(),[l,c]=A.useState(!1);let d;e[0]!==s||e[1]!==a.id||e[2]!==a.slug?(d={connectionId:s,orgId:a.id,orgSlug:a.slug},e[0]=s,e[1]=a.id,e[2]=a.slug,e[3]=d):d=e[3];const h=ht(d);let u;e[4]!==h?(u={client:h},e[4]=h,e[5]=u):u=e[5];const{data:f,isLoading:m}=a9(u),p=Rn();let g,x,v,b,y,_,L,w,j,S,C,N,V;if(e[6]!==p||e[7]!==f?.tools||e[8]!==m||e[9]!==i||e[10]!==l||e[11]!==o||e[12]!==n){const P=new Map(p.map(nO)),D=new Map;for(const ce of f?.tools??[]){const oe=pn(ce._meta)??"__other__",fe=jr(ce.name,oe==="__other__"?void 0:oe),pe=ce.title,we=pe&&pe!==ce.name?pe:JM(fe);D.has(oe)||D.set(oe,{clientId:oe,conn:P.get(oe),tools:[]}),D.get(oe).tools.push({name:ce.name,display:we,description:ce.description})}const I=[...D.values()].sort(sO),M=(f?.tools??[]).map(tO),O=[...YM,...M],$=n===null?new Set(O):new Set(n),B=O.every(ce=>$.has(ce)),z=ce=>i(O.every(oe=>ce.has(oe))?null:[...ce]),K=ce=>{const oe=new Set($);oe.has(ce)?oe.delete(ce):oe.add(ce),z(oe)},G=(ce,oe)=>{const fe=new Set($);for(const pe of ce)oe?fe.add(pe):fe.delete(pe);z(fe)};b=As,V=l,y=c;let Y;e[26]===Symbol.for("react.memo_cache_sentinel")?(Y=r.jsx(b9,{size:14,className:"text-muted-foreground"}),e[26]=Y):Y=e[26];let U;e[27]!==B||e[28]!==o?(U=o(B?"automations.automationConfig.allTools":"automations.automationConfig.tools"),e[27]=B,e[28]=o,e[29]=U):U=e[29];const W=!B&&r.jsxs(Wb,{variant:"secondary",className:"ml-0.5 h-5 px-1.5 text-[11px] tabular-nums",children:[$.size,"/",O.length]});let H;e[30]===Symbol.for("react.memo_cache_sentinel")?(H=r.jsx(ss,{size:14,className:"text-muted-foreground"}),e[30]=H):H=e[30],e[31]!==U||e[32]!==W?(_=r.jsx(Es,{asChild:!0,children:r.jsxs(le,{variant:"outline",size:"sm",className:"w-fit gap-1.5",children:[Y,U,W,H]})}),e[31]=U,e[32]=W,e[33]=_):_=e[33],v=Ps,C="p-0 w-80",N="start",x=Tr;let X;e[34]!==o?(X=o("automations.automationConfig.searchToolsPlaceholder"),e[34]=o,e[35]=X):X=e[35],e[36]!==X?(j=r.jsx($i,{placeholder:X}),e[36]=X,e[37]=j):j=e[37];const q=B?o("automations.automationConfig.allToolsEnabled",{count:O.length}):o("automations.automationConfig.toolsEnabledCount",{enabled:$.size,total:O.length});let Z;e[38]!==q?(Z=r.jsx("span",{className:"text-xs text-muted-foreground",children:q}),e[38]=q,e[39]=Z):Z=e[39];let Q;e[40]!==i?(Q=()=>i(null),e[40]=i,e[41]=Q):Q=e[41];let ee;e[42]!==o?(ee=o("automations.automationConfig.selectAll"),e[42]=o,e[43]=ee):ee=e[43];let J;e[44]!==B||e[45]!==Q||e[46]!==ee?(J=r.jsx("button",{type:"button",onClick:Q,disabled:B,className:"text-xs font-medium text-primary hover:underline disabled:cursor-default disabled:opacity-40 disabled:no-underline",children:ee}),e[44]=B,e[45]=Q,e[46]=ee,e[47]=J):J=e[47];let te;e[48]===Symbol.for("react.memo_cache_sentinel")?(te=r.jsx("span",{className:"text-muted-foreground/30",children:"·"}),e[48]=te):te=e[48];let se;e[49]!==i?(se=()=>i([]),e[49]=i,e[50]=se):se=e[50];const ne=$.size===0;let de;e[51]!==o?(de=o("automations.automationConfig.clear"),e[51]=o,e[52]=de):de=e[52];let xe;e[53]!==se||e[54]!==ne||e[55]!==de?(xe=r.jsx("button",{type:"button",onClick:se,disabled:ne,className:"text-xs font-medium text-muted-foreground hover:underline disabled:cursor-default disabled:opacity-40 disabled:no-underline",children:de}),e[53]=se,e[54]=ne,e[55]=de,e[56]=xe):xe=e[56];let ue;e[57]!==J||e[58]!==xe?(ue=r.jsxs("div",{className:"flex items-center gap-2",children:[J,te,xe]}),e[57]=J,e[58]=xe,e[59]=ue):ue=e[59],e[60]!==Z||e[61]!==ue?(S=r.jsxs("div",{className:"flex items-center justify-between border-b px-3 py-2",children:[Z,ue]}),e[60]=Z,e[61]=ue,e[62]=S):S=e[62],g=Fi,L="max-h-80",w=m?r.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:o("automations.automationConfig.loadingTools")}):r.jsxs(r.Fragment,{children:[r.jsx(Qn,{children:o("automations.automationConfig.noToolsFound")}),k4.map(ce=>{const oe=ce.tools.map(eO),fe=oe.filter(pe=>$.has(pe)).length;return r.jsx(Ms,{heading:r.jsx(s1,{label:o(ce.headingKey),icon:ce.icon,on:fe,total:oe.length,onToggle:()=>G(oe,fe!==oe.length)}),children:ce.tools.map(pe=>r.jsx(t1,{value:`${o(pe.titleKey)} ${pe.name}`,checked:$.has(pe.name),onToggle:()=>K(pe.name),title:o(pe.titleKey),description:o(pe.descriptionKey),leading:r.jsx(pe.icon,{size:16,className:"text-muted-foreground"})},pe.name))},ce.key)}),I.map(ce=>{const oe=ce.tools.map(ZM),fe=oe.filter(pe=>$.has(pe)).length;return r.jsx(Ms,{heading:r.jsx(s1,{conn:ce.conn,on:fe,total:oe.length,onToggle:()=>G(oe,fe!==oe.length)}),children:ce.tools.map(pe=>r.jsx(t1,{value:`${pe.display} ${pe.name} ${ce.conn?.title??""}`,checked:$.has(pe.name),onToggle:()=>K(pe.name),title:pe.display,description:pe.description},pe.name))},ce.clientId)})]}),e[6]=p,e[7]=f?.tools,e[8]=m,e[9]=i,e[10]=l,e[11]=o,e[12]=n,e[13]=g,e[14]=x,e[15]=v,e[16]=b,e[17]=y,e[18]=_,e[19]=L,e[20]=w,e[21]=j,e[22]=S,e[23]=C,e[24]=N,e[25]=V}else g=e[13],x=e[14],v=e[15],b=e[16],y=e[17],_=e[18],L=e[19],w=e[20],j=e[21],S=e[22],C=e[23],N=e[24],V=e[25];let E;e[63]!==g||e[64]!==L||e[65]!==w?(E=r.jsx(g,{className:L,children:w}),e[63]=g,e[64]=L,e[65]=w,e[66]=E):E=e[66];let T;e[67]!==x||e[68]!==E||e[69]!==j||e[70]!==S?(T=r.jsxs(x,{children:[j,S,E]}),e[67]=x,e[68]=E,e[69]=j,e[70]=S,e[71]=T):T=e[71];let k;e[72]!==v||e[73]!==T||e[74]!==C||e[75]!==N?(k=r.jsx(v,{className:C,align:N,children:T}),e[72]=v,e[73]=T,e[74]=C,e[75]=N,e[76]=k):k=e[76];let R;return e[77]!==b||e[78]!==y||e[79]!==_||e[80]!==k||e[81]!==V?(R=r.jsxs(b,{open:V,onOpenChange:y,children:[_,k]}),e[77]=b,e[78]=y,e[79]=_,e[80]=k,e[81]=V,e[82]=R):R=e[82],R}function ZM(t){return t.name}function eO(t){return t.name}function tO(t){return t.name}function sO(t,e){return(t.conn?.title??t.clientId).localeCompare(e.conn?.title??e.clientId)}function nO(t){return[t.id,t]}function ko(t){const e=t.trim().split(/\s+/);return e.length!==5?!1:e.every(s=>/^[\d*/,-]+$/.test(s))}function iO(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 n=e.match(/^0\s+\*\/(\d+)\s+\*\s+\*\s+\*$/);if(n)return`Every ${n[1]} hours`;const i=e.match(/^0\s+0\s+\*\/(\d+)\s+\*\s+\*$/);if(i){const l=parseInt(i[1]??"1");return l%7===0?`Every ${l/7} weeks`:`Every ${l} days`}const o=e.match(/^(\d+)\s+(\d+)\s+\*\s+\*\s+\*$/);if(o){const l=(o[2]??"0").padStart(2,"0"),c=(o[1]??"0").padStart(2,"0");return`Every day at ${l}:${c} UTC`}const a=e.match(/^(\d+)\s+(\d+)\s+\*\s+\*\s+(\d)$/);if(a){const c=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][parseInt(a[3]??"0")]??"day",d=(a[2]??"0").padStart(2,"0"),h=(a[1]??"0").padStart(2,"0");return`Every ${c} at ${d}:${h} UTC`}return t}function rO(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 oO(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 n=e.match(/^0\s+\*\/(\d+)\s+\*\s+\*\s+\*$/);if(n)return{count:parseInt(n[1]),unit:"hours"};const i=e.match(/^0\s+0\s+\*\/(\d+)\s+\*\s+\*$/);return i?{count:parseInt(i[1]),unit:"days"}:null}function aO(t,e){return e===1?{minutes:"minute",hours:"hour",days:"day",weeks:"week"}[t]??t:t}const lO=[{label:"5 minutes",cron:"*/5 * * * *"},{label:"Hour",cron:"0 * * * *"},{label:"Day",cron:"0 0 * * *"},{label:"Week",cron:"0 0 * * 1"}];function cO({automationId:t,open:e,onOpenChange:s,onCustomSelect:n,onEventSelect:i,onWebhookCreated:o}){const a=re(),{triggerAdd:l}=oa(),[c,d]=A.useState(!1),h=e??c,u=p=>{s?s(p):d(p)},f=async p=>{try{await l.mutateAsync({automation_id:t,type:"cron",cron_expression:p}),ge.success(a("automations.addStarterPopover.starterAdded")),u(!1)}catch(g){const x=g instanceof Error?g.message:a("automations.addStarterPopover.failedAddStarter");ge.error(x)}},m=async()=>{try{const p=await l.mutateAsync({automation_id:t,type:"webhook"});u(!1),p.webhook?o?.(p.webhook):ge.success(a("automations.addStarterPopover.webhookStarterAdded"))}catch(p){const g=p instanceof Error?p.message:a("automations.addStarterPopover.failedAddWebhookStarter");ge.error(g)}};return r.jsxs(us,{open:h,onOpenChange:u,children:[r.jsx(ds,{asChild:!0,children:r.jsxs(le,{variant:"outline",size:"sm",children:[r.jsx(kt,{size:14}),a("automations.addStarterPopover.addStarter")]})}),r.jsxs(hs,{align:"end",className:"w-[200px]",children:[r.jsxs(Ao,{children:[r.jsxs(Eo,{className:"gap-2.5",children:[r.jsx(xo,{size:14,className:"text-muted-foreground shrink-0"}),a("automations.addStarterPopover.every")]}),r.jsx(Po,{className:"w-[160px]",children:lO.map(p=>r.jsxs(Xe,{className:"gap-2.5",onSelect:()=>f(p.cron),disabled:l.isPending,children:[r.jsx(xo,{size:14,className:"text-muted-foreground shrink-0"}),a("automations.addStarterPopover.everyUnit",{unit:p.label})]},p.cron))})]}),r.jsxs(Xe,{className:"gap-2.5",onSelect:()=>{u(!1),n?.()},children:[r.jsx(xo,{size:14,className:"text-muted-foreground shrink-0"}),a("automations.addStarterPopover.customCron")]}),r.jsxs(Xe,{className:"gap-2.5",onSelect:()=>{u(!1),i?.()},children:[r.jsx(Ni,{size:14,className:"text-muted-foreground shrink-0"}),a("automations.addStarterPopover.event")]}),r.jsxs(Xe,{className:"gap-2.5",onSelect:()=>{m()},disabled:l.isPending,children:[r.jsx(ai,{size:14,className:"text-muted-foreground shrink-0"}),a("automations.addStarterPopover.webhook")]})]})]})}function V4(t){const e=F.c(39),{open:s,onOpenChange:n,url:i,token:o,title:a,description:l}=t,c=a===void 0?"Webhook ready":a,d=l===void 0?"Send a POST to this URL with the bearer token to fire the automation. The token is shown once — copy it now.":l,h=re(),[u,f]=A.useState(null),[m,p]=A.useState("curl"),[g,x]=A.useState("header"),v=A.useId();let b;e[0]!==h?(b=async(I,M)=>{try{await navigator.clipboard.writeText(I),f(M),ge.success(h("automations.webhookSecretDialog.copied")),setTimeout(()=>f(null),1500)}catch{ge.error(h("automations.webhookSecretDialog.failedCopy"))}},e[0]=h,e[1]=b):b=e[1];const y=b;let _;e[2]!==g||e[3]!==o||e[4]!==i?(_=i&&o&&g==="url"?`${i.replace(/\/$/,"")}/${o}`:i??"",e[2]=g,e[3]=o,e[4]=i,e[5]=_):_=e[5];const L=_,w=i&&o?g==="header"?`curl -X POST "${L}" \\
|
|
482
|
-
-H "Authorization: Bearer ${o}" \\
|
|
483
|
-
-H "Content-Type: application/json" \\
|
|
484
|
-
-d '{"hello":"world"}'`:`curl -X POST "${L}" \\
|
|
485
|
-
-H "Content-Type: application/json" \\
|
|
486
|
-
-d '{"hello":"world"}'`:"",j=i&&o?g==="header"?`await fetch("${L}", {
|
|
487
|
-
method: "POST",
|
|
488
|
-
headers: {
|
|
489
|
-
Authorization: "Bearer ${o}",
|
|
490
|
-
"Content-Type": "application/json",
|
|
491
|
-
},
|
|
492
|
-
body: JSON.stringify({ hello: "world" }),
|
|
493
|
-
});`:`await fetch("${L}", {
|
|
494
|
-
method: "POST",
|
|
495
|
-
headers: {
|
|
496
|
-
"Content-Type": "application/json",
|
|
497
|
-
},
|
|
498
|
-
body: JSON.stringify({ hello: "world" }),
|
|
499
|
-
});`:"",S=m==="curl"?w:j;let C;e[6]!==c?(C=r.jsx(ps,{children:c}),e[6]=c,e[7]=C):C=e[7];let N;e[8]!==d?(N=r.jsx(ri,{children:d}),e[8]=d,e[9]=N):N=e[9];let V;e[10]!==C||e[11]!==N?(V=r.jsxs(ms,{children:[C,N]}),e[10]=C,e[11]=N,e[12]=V):V=e[12];let E;e[13]!==g||e[14]!==u||e[15]!==y||e[16]!==L||e[17]!==m||e[18]!==S||e[19]!==h||e[20]!==o||e[21]!==v||e[22]!==i?(E=i&&o?r.jsxs("div",{className:"flex flex-col gap-3 min-w-0",children:[r.jsxs("div",{className:"flex flex-col gap-1",children:[r.jsx("span",{className:"text-xs font-semibold text-muted-foreground",children:h("automations.webhookSecretDialog.url")}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("code",{className:"flex-1 min-w-0 text-xs font-mono bg-muted rounded-md px-2 py-1.5 truncate",children:L}),r.jsxs(le,{size:"sm",variant:"outline",onClick:()=>y(L,"url"),children:[r.jsx(Os,{size:13}),h(u==="url"?"automations.webhookSecretDialog.copied":"automations.webhookSecretDialog.copy")]})]})]}),r.jsxs("div",{className:"flex flex-col gap-1",children:[r.jsx("span",{className:"text-xs font-semibold text-muted-foreground",children:h("automations.webhookSecretDialog.tokenLabel")}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("code",{className:"flex-1 min-w-0 text-xs font-mono bg-muted rounded-md px-2 py-1.5 truncate",children:o}),r.jsxs(le,{size:"sm",variant:"outline",onClick:()=>y(o,"token"),children:[r.jsx(Os,{size:13}),h(u==="token"?"automations.webhookSecretDialog.copied":"automations.webhookSecretDialog.copy")]})]})]}),r.jsxs("div",{className:"flex flex-col gap-2",children:[r.jsx("span",{className:"text-xs font-semibold text-muted-foreground",children:h("automations.webhookSecretDialog.snippet")}),r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx(Vr,{value:m,onValueChange:I=>p(I),children:r.jsxs(ta,{className:"h-8 p-[2px]",children:[r.jsx(xn,{value:"curl",className:"h-7 px-2.5 text-xs",children:"curl"}),r.jsx(xn,{value:"fetch",className:"h-7 px-2.5 text-xs",children:"fetch"})]})}),r.jsxs("label",{htmlFor:v,className:"flex items-center gap-1.5 text-xs text-muted-foreground cursor-pointer select-none",children:[r.jsx(Ar,{id:v,checked:g==="url",onCheckedChange:I=>x(I?"url":"header")}),h("automations.webhookSecretDialog.tokenInUrl")]})]}),r.jsxs(le,{size:"sm",variant:"outline",onClick:()=>y(S,"example"),children:[r.jsx(Os,{size:13}),h(u==="example"?"automations.webhookSecretDialog.copied":"automations.webhookSecretDialog.copy")]})]}),r.jsx("div",{className:"rounded-md border overflow-hidden min-w-0",children:r.jsx(ra,{code:S,language:m==="curl"?"shell":"typescript",readOnly:!0,disableDiagnostics:!0,height:180})})]})]}):null,e[13]=g,e[14]=u,e[15]=y,e[16]=L,e[17]=m,e[18]=S,e[19]=h,e[20]=o,e[21]=v,e[22]=i,e[23]=E):E=e[23];let T;e[24]!==n?(T=()=>n(!1),e[24]=n,e[25]=T):T=e[25];let k;e[26]!==h?(k=h("automations.webhookSecretDialog.done"),e[26]=h,e[27]=k):k=e[27];let R;e[28]!==k||e[29]!==T?(R=r.jsx(Mi,{children:r.jsx(le,{onClick:T,children:k})}),e[28]=k,e[29]=T,e[30]=R):R=e[30];let P;e[31]!==R||e[32]!==V||e[33]!==E?(P=r.jsxs(es,{className:"max-w-lg",children:[V,E,R]}),e[31]=R,e[32]=V,e[33]=E,e[34]=P):P=e[34];let D;return e[35]!==n||e[36]!==s||e[37]!==P?(D=r.jsx(ts,{open:s,onOpenChange:n,children:P}),e[35]=n,e[36]=s,e[37]=P,e[38]=D):D=e[38],D}function dO(t){const e=F.c(137),{trigger:s,automationId:n,connectionName:i}=t,o=re(),{triggerAdd:a,triggerRemove:l,triggerRotateToken:c}=oa(),[d,h]=A.useState(!1),[u,f]=A.useState(!1),[m,p]=A.useState(null);let g;e[0]!==s.cron_expression?(g=s.cron_expression?oO(s.cron_expression):null,e[0]=s.cron_expression,e[1]=g):g=e[1];const x=g,[v,b]=A.useState(x?.count??1),[y,_]=A.useState(!1),[L,w]=A.useState(s.cron_expression??""),j=l.isPending||a.isPending||c.isPending,S=s.type==="cron",C=s.type==="webhook";let N;e[2]!==n||e[3]!==l||e[4]!==o||e[5]!==s.id?(N=async()=>{try{await l.mutateAsync({trigger_id:s.id,automation_id:n}),ge.success(o("automations.triggerCard.starterRemoved"))}catch{ge.error(o("automations.triggerCard.failedToRemoveStarter"))}h(!1)},e[2]=n,e[3]=l,e[4]=o,e[5]=s.id,e[6]=N):N=e[6];const V=N;let E;e[7]!==a||e[8]!==n||e[9]!==l||e[10]!==s.id?(E=async ke=>{await a.mutateAsync({automation_id:n,type:"cron",cron_expression:ke}),await l.mutateAsync({trigger_id:s.id,automation_id:n})},e[7]=a,e[8]=n,e[9]=l,e[10]=s.id,e[11]=E):E=e[11];const T=E;let k;e[12]!==L||e[13]!==T||e[14]!==o||e[15]!==s.cron_expression?(k=async()=>{const ke=L.trim();if(!ke||!ko(ke)||ke===s.cron_expression){_(!1),w(s.cron_expression??"");return}try{await T(ke),_(!1)}catch{ge.error(o("automations.triggerCard.failedToUpdateStarter")),w(s.cron_expression??""),_(!1)}},e[12]=L,e[13]=T,e[14]=o,e[15]=s.cron_expression,e[16]=k):k=e[16];const R=k;let P;e[17]!==n||e[18]!==c||e[19]!==s.id?(P=async()=>{f(!1);try{const ke=await c.mutateAsync({trigger_id:s.id,automation_id:n});p({url:ke.url,token:ke.token})}catch(ke){const Se=ke,Be=Se instanceof Error?Se.message:"Failed to rotate token";ge.error(Be)}},e[17]=n,e[18]=c,e[19]=s.id,e[20]=P):P=e[20];const D=P;let I;e[21]!==x||e[22]!==T||e[23]!==o||e[24]!==s.cron_expression?(I=async ke=>{if(!x)return;const Se=x.unit==="minutes"?5:1,Be=Math.max(Se,ke);Be!==ke&&b(Be);const nt=rO(Be,x.unit);if(nt!==s.cron_expression)try{await T(nt)}catch{ge.error(o("automations.triggerCard.failedToUpdateStarter")),b(x.count)}},e[21]=x,e[22]=T,e[23]=o,e[24]=s.cron_expression,e[25]=I):I=e[25];const M=I;let O;e[26]!==S||e[27]!==C?(O=S?r.jsx(xo,{size:14,className:"text-muted-foreground shrink-0"}):C?r.jsx(ai,{size:14,className:"text-muted-foreground shrink-0"}):r.jsx(Ni,{size:14,className:"text-muted-foreground shrink-0"}),e[26]=S,e[27]=C,e[28]=O):O=e[28];let $;e[29]!==i||e[30]!==v||e[31]!==L||e[32]!==M||e[33]!==R||e[34]!==x||e[35]!==S||e[36]!==y||e[37]!==j||e[38]!==C||e[39]!==o||e[40]!==s.cron_expression||e[41]!==s.event_type||e[42]!==s.params?($=x&&S?r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"text-sm text-muted-foreground",children:o("automations.triggerCard.every")}),r.jsx("input",{type:"number",min:x.unit==="minutes"?5:1,value:v,onChange:ke=>b(parseInt(ke.target.value)||1),onBlur:()=>M(v),onKeyDown:ke=>{ke.key==="Enter"&&ke.target.blur(),ke.key==="Escape"&&b(x.count)},disabled:j,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"}),r.jsx("span",{className:"text-sm",children:aO(x.unit,v)})]}):S&&y?r.jsxs(r.Fragment,{children:[r.jsx("input",{type:"text",value:L,onChange:ke=>w(ke.target.value),onBlur:R,onKeyDown:ke=>{ke.key==="Enter"&&ke.target.blur(),ke.key==="Escape"&&(_(!1),w(s.cron_expression??""))},className:"flex-1 text-sm font-mono bg-transparent outline-none",autoFocus:!0}),L&&!ko(L)&&r.jsx("span",{className:"text-xs text-muted-foreground/60 shrink-0",children:o("automations.triggerCard.invalid")})]}):r.jsxs("div",{className:"flex flex-col gap-0.5 flex-1 min-w-0",children:[r.jsx("span",{className:"text-sm font-mono text-xs text-muted-foreground truncate",children:S?iO(s.cron_expression??""):C?o("automations.triggerCard.webhookPostToFire"):`${s.event_type}${i?` · ${i}`:""}`}),!S&&!C&&s.params&&Object.keys(s.params).length>0&&r.jsx("span",{className:"text-xs text-muted-foreground/60 truncate",children:Object.entries(s.params).map(uO).join(", ")})]}),e[29]=i,e[30]=v,e[31]=L,e[32]=M,e[33]=R,e[34]=x,e[35]=S,e[36]=y,e[37]=j,e[38]=C,e[39]=o,e[40]=s.cron_expression,e[41]=s.event_type,e[42]=s.params,e[43]=$):$=e[43];let B;e[44]!==j?(B=j&&r.jsx(et,{size:13,className:"animate-spin text-muted-foreground"}),e[44]=j,e[45]=B):B=e[45];let z;e[46]!==x||e[47]!==S||e[48]!==y||e[49]!==s.cron_expression?(z=S&&!x&&!y&&r.jsx(le,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>{w(s.cron_expression??""),_(!0)},children:r.jsx(v9,{size:13,className:"text-muted-foreground"})}),e[46]=x,e[47]=S,e[48]=y,e[49]=s.cron_expression,e[50]=z):z=e[50];let K;e[51]!==C||e[52]!==o?(K=C&&r.jsx(le,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 transition-opacity",title:o("automations.triggerCard.rotateToken"),onClick:()=>f(!0),children:r.jsx(dr,{size:13,className:"text-muted-foreground"})}),e[51]=C,e[52]=o,e[53]=K):K=e[53];let G;e[54]===Symbol.for("react.memo_cache_sentinel")?(G=r.jsx(le,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>h(!0),children:r.jsx(Pn,{size:13,className:"text-muted-foreground"})}),e[54]=G):G=e[54];let Y;e[55]!==z||e[56]!==K||e[57]!==B?(Y=r.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[B,z,K,G]}),e[55]=z,e[56]=K,e[57]=B,e[58]=Y):Y=e[58];let U;e[59]!==Y||e[60]!==O||e[61]!==$?(U=r.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2.5 rounded-lg border border-border bg-background group",children:[O,$,Y]}),e[59]=Y,e[60]=O,e[61]=$,e[62]=U):U=e[62];let W;e[63]!==o?(W=o("automations.triggerCard.removeStarter"),e[63]=o,e[64]=W):W=e[64];let H;e[65]!==W?(H=r.jsx(dl,{children:W}),e[65]=W,e[66]=H):H=e[66];let X;e[67]!==o?(X=o("automations.triggerCard.confirmRemoveStarter"),e[67]=o,e[68]=X):X=e[68];let q;e[69]!==X?(q=r.jsx(ul,{children:X}),e[69]=X,e[70]=q):q=e[70];let Z;e[71]!==H||e[72]!==q?(Z=r.jsxs(cl,{children:[H,q]}),e[71]=H,e[72]=q,e[73]=Z):Z=e[73];let Q;e[74]!==o?(Q=o("automations.triggerCard.cancel"),e[74]=o,e[75]=Q):Q=e[75];let ee;e[76]!==Q?(ee=r.jsx(fl,{children:Q}),e[76]=Q,e[77]=ee):ee=e[77];let J;e[78]!==o?(J=o("automations.triggerCard.remove"),e[78]=o,e[79]=J):J=e[79];let te;e[80]!==V||e[81]!==J?(te=r.jsx(ml,{onClick:V,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:J}),e[80]=V,e[81]=J,e[82]=te):te=e[82];let se;e[83]!==ee||e[84]!==te?(se=r.jsxs(hl,{children:[ee,te]}),e[83]=ee,e[84]=te,e[85]=se):se=e[85];let ne;e[86]!==Z||e[87]!==se?(ne=r.jsxs(ll,{children:[Z,se]}),e[86]=Z,e[87]=se,e[88]=ne):ne=e[88];let de;e[89]!==d||e[90]!==ne?(de=r.jsx(al,{open:d,onOpenChange:h,children:ne}),e[89]=d,e[90]=ne,e[91]=de):de=e[91];let xe;e[92]!==o?(xe=o("automations.triggerCard.rotateWebhookToken"),e[92]=o,e[93]=xe):xe=e[93];let ue;e[94]!==xe?(ue=r.jsx(dl,{children:xe}),e[94]=xe,e[95]=ue):ue=e[95];let ce;e[96]!==o?(ce=o("automations.triggerCard.rotateWebhookTokenDescription"),e[96]=o,e[97]=ce):ce=e[97];let oe;e[98]!==ce?(oe=r.jsx(ul,{children:ce}),e[98]=ce,e[99]=oe):oe=e[99];let fe;e[100]!==ue||e[101]!==oe?(fe=r.jsxs(cl,{children:[ue,oe]}),e[100]=ue,e[101]=oe,e[102]=fe):fe=e[102];let pe;e[103]!==o?(pe=o("automations.triggerCard.cancel"),e[103]=o,e[104]=pe):pe=e[104];let we;e[105]!==pe?(we=r.jsx(fl,{children:pe}),e[105]=pe,e[106]=we):we=e[106];let Ne;e[107]!==o?(Ne=o("automations.triggerCard.rotate"),e[107]=o,e[108]=Ne):Ne=e[108];let Fe;e[109]!==D||e[110]!==Ne?(Fe=r.jsx(ml,{onClick:D,children:Ne}),e[109]=D,e[110]=Ne,e[111]=Fe):Fe=e[111];let je;e[112]!==we||e[113]!==Fe?(je=r.jsxs(hl,{children:[we,Fe]}),e[112]=we,e[113]=Fe,e[114]=je):je=e[114];let Ie;e[115]!==fe||e[116]!==je?(Ie=r.jsxs(ll,{children:[fe,je]}),e[115]=fe,e[116]=je,e[117]=Ie):Ie=e[117];let Pe;e[118]!==u||e[119]!==Ie?(Pe=r.jsx(al,{open:u,onOpenChange:f,children:Ie}),e[118]=u,e[119]=Ie,e[120]=Pe):Pe=e[120];const Ye=m!==null;let _e;e[121]===Symbol.for("react.memo_cache_sentinel")?(_e=ke=>{ke||p(null)},e[121]=_e):_e=e[121];const Ae=m?.url??null,Re=m?.token??null;let ye;e[122]!==o?(ye=o("automations.triggerCard.newWebhookToken"),e[122]=o,e[123]=ye):ye=e[123];let ve;e[124]!==o?(ve=o("automations.triggerCard.newWebhookTokenDescription"),e[124]=o,e[125]=ve):ve=e[125];let Le;e[126]!==Ye||e[127]!==Ae||e[128]!==Re||e[129]!==ye||e[130]!==ve?(Le=r.jsx(V4,{open:Ye,onOpenChange:_e,url:Ae,token:Re,title:ye,description:ve}),e[126]=Ye,e[127]=Ae,e[128]=Re,e[129]=ye,e[130]=ve,e[131]=Le):Le=e[131];let $e;return e[132]!==U||e[133]!==de||e[134]!==Pe||e[135]!==Le?($e=r.jsxs(r.Fragment,{children:[U,de,Pe,Le]}),e[132]=U,e[133]=de,e[134]=Pe,e[135]=Le,e[136]=$e):$e=e[136],$e}function uO(t){const[e,s]=t;return`${e}: ${s}`}function hO(t){const e=F.c(70),{automationId:s,onDone:n}=t,i=re();let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o={binding:"TRIGGER"},e[0]=o):o=e[0];const a=Rn(o),[l,c]=A.useState(),[d,h]=A.useState();let u;e[1]===Symbol.for("react.memo_cache_sentinel")?(u={},e[1]=u):u=e[1];const[f,m]=A.useState(u),{triggerAdd:p}=oa(),{data:g,isLoading:x}=qb(l);let v,b,y,_,L,w;if(e[2]!==p||e[3]!==s||e[4]!==l||e[5]!==d||e[6]!==x||e[7]!==n||e[8]!==f||e[9]!==i||e[10]!==a||e[11]!==g){const C=g?.find(B=>B.type===d);let N;e[18]!==p||e[19]!==s||e[20]!==l||e[21]!==d||e[22]!==n||e[23]!==f||e[24]!==i?(N=async()=>{if(!(!l||!d))try{await p.mutateAsync({automation_id:s,type:"event",event_type:d,connection_id:l,params:f}),Me("automation_trigger_added",{automation_id:s,trigger_type:"event",connection_id:l,event_type:d}),ge.success(i("automations.eventTriggerForm.successAdded")),n()}catch{ge.error(i("automations.eventTriggerForm.errorFailed"))}},e[18]=p,e[19]=s,e[20]=l,e[21]=d,e[22]=n,e[23]=f,e[24]=i,e[25]=N):N=e[25],v=N,b="flex flex-col gap-3 px-3 py-3 rounded-lg border border-border bg-background";let V;e[26]===Symbol.for("react.memo_cache_sentinel")?(V=r.jsx(Ni,{size:14,className:"text-muted-foreground shrink-0"}),e[26]=V):V=e[26];let E;e[27]!==i?(E=i("automations.eventTriggerForm.title"),e[27]=i,e[28]=E):E=e[28];let T;e[29]!==E?(T=r.jsx("span",{className:"text-sm font-medium",children:E}),e[29]=E,e[30]=T):T=e[30];let k;e[31]===Symbol.for("react.memo_cache_sentinel")?(k=r.jsx(Pn,{size:13}),e[31]=k):k=e[31];let R;e[32]!==n?(R=r.jsx("button",{type:"button",className:"ml-auto shrink-0 p-0.5 rounded text-muted-foreground hover:text-foreground",onClick:n,children:k}),e[32]=n,e[33]=R):R=e[33],e[34]!==T||e[35]!==R?(y=r.jsxs("div",{className:"flex items-center gap-2",children:[V,T,R]}),e[34]=T,e[35]=R,e[36]=y):y=e[36];const P=l??"";let D;e[37]===Symbol.for("react.memo_cache_sentinel")?(D=B=>{c(B),h(void 0),m({})},e[37]=D):D=e[37];let I;e[38]!==i?(I=i("automations.eventTriggerForm.selectConnectionPlaceholder"),e[38]=i,e[39]=I):I=e[39];let M;e[40]!==I?(M=r.jsx(Jt,{className:"w-full",children:r.jsx(as,{placeholder:I})}),e[40]=I,e[41]=M):M=e[41];let O;e[42]!==i||e[43]!==a?(O=a.length===0?r.jsx("div",{className:"px-2 py-3 text-center text-xs text-muted-foreground",children:i("automations.eventTriggerForm.noConnectionsWithTrigger")}):a.map(pO),e[42]=i,e[43]=a,e[44]=O):O=e[44];let $;e[45]!==O?($=r.jsx(Xt,{children:O}),e[45]=O,e[46]=$):$=e[46],e[47]!==P||e[48]!==M||e[49]!==$?(_=r.jsxs(Qt,{value:P,onValueChange:D,children:[M,$]}),e[47]=P,e[48]=M,e[49]=$,e[50]=_):_=e[50],e[51]!==l||e[52]!==d||e[53]!==x||e[54]!==i||e[55]!==g?(L=l&&r.jsxs(Qt,{value:d??"",onValueChange:B=>{h(B),m({})},children:[r.jsx(Jt,{className:"w-full",children:x?r.jsxs("span",{className:"flex items-center gap-2 text-muted-foreground",children:[r.jsx(et,{size:13,className:"animate-spin"}),i("automations.eventTriggerForm.loadingEvents")]}):r.jsx(as,{placeholder:i("automations.eventTriggerForm.selectEventTypePlaceholder"),children:d??i("automations.eventTriggerForm.selectEventTypePlaceholder")})}),r.jsx(Xt,{children:g?.map(mO)})]}),e[51]=l,e[52]=d,e[53]=x,e[54]=i,e[55]=g,e[56]=L):L=e[56],w=C?.paramsSchema&&Object.keys(C.paramsSchema).length>0&&r.jsx("div",{className:"flex flex-col gap-2",children:Object.entries(C.paramsSchema).map(B=>{const[z,K]=B;return r.jsxs("div",{className:"flex flex-col gap-1",children:[r.jsxs("label",{className:"text-xs text-muted-foreground",children:[z,K.description&&r.jsxs("span",{className:"text-muted-foreground/60",children:[" ","— ",K.description]})]}),K.enum?r.jsxs(Qt,{value:f[z]??"",onValueChange:G=>m(Y=>({...Y,[z]:G})),children:[r.jsx(Jt,{className:"w-full",children:r.jsx(as,{placeholder:i("automations.eventTriggerForm.selectParamPlaceholder",{key:z})})}),r.jsx(Xt,{children:K.enum.map(fO)})]}):r.jsx("input",{type:"text",value:f[z]??"",onChange:G=>m(Y=>({...Y,[z]:G.target.value})),placeholder:K.description??z,className:"text-sm border border-border rounded-md bg-background px-2 py-1.5 focus:outline-none focus:ring-1 focus:ring-ring"})]},z)})}),e[2]=p,e[3]=s,e[4]=l,e[5]=d,e[6]=x,e[7]=n,e[8]=f,e[9]=i,e[10]=a,e[11]=g,e[12]=v,e[13]=b,e[14]=y,e[15]=_,e[16]=L,e[17]=w}else v=e[12],b=e[13],y=e[14],_=e[15],L=e[16],w=e[17];let j;e[57]!==p||e[58]!==l||e[59]!==d||e[60]!==v||e[61]!==i?(j=l&&d&&r.jsx(le,{size:"sm",onClick:v,disabled:p.isPending,children:p.isPending?r.jsx(et,{size:13,className:"animate-spin"}):i("automations.eventTriggerForm.addTriggerButton")}),e[57]=p,e[58]=l,e[59]=d,e[60]=v,e[61]=i,e[62]=j):j=e[62];let S;return e[63]!==b||e[64]!==y||e[65]!==_||e[66]!==L||e[67]!==w||e[68]!==j?(S=r.jsxs("div",{className:b,children:[y,_,L,w,j]}),e[63]=b,e[64]=y,e[65]=_,e[66]=L,e[67]=w,e[68]=j,e[69]=S):S=e[69],S}function fO(t){return r.jsx(vt,{value:t,children:t},t)}function mO(t){return r.jsx(vt,{value:t.type,children:r.jsxs("div",{className:"flex flex-col",children:[r.jsx("span",{children:t.type}),r.jsx("span",{className:"text-xs text-muted-foreground",children:t.description})]})},t.type)}function pO(t){return r.jsx(vt,{value:t.id,children:t.title},t.id)}const gO=30;function xO(t,e){switch(e.type){case"accumulate":{const s=t??{start:e.now,fields:new Set,saveCount:0},n=new Set(s.fields);for(const i of e.fields)n.add(i);return{...s,fields:n,saveCount:s.saveCount+1}}case"reset":return null}}function vO({automationId:t,automation:e,onBack:s,onDelete:n}){const i=re(),o=e.virtual_mcp_id,{org:a}=Oe(),{update:l,triggerAdd:c,run:d}=oa(),h=Rn(),u=new Map(h.map(J=>[J.id,J.title])),{openTask:f}=Zt(),{openSidePanel:m}=Qo(),{sendMessage:p}=Js(),g=e.messages?.[0]?.metadata?.tiptapDoc??void 0,[x,v]=A.useState(g),[b,y]=A.useState(!1),[_,L]=A.useState(!1),[w,j]=A.useState(!1),[S,C]=A.useState(""),[N,V]=A.useState(!1),[E,T]=A.useState(null),[k,R]=A.useState(!1),[P,D]=A.useState(!1),[I,M]=A.useState(!1),O=async()=>{if(k)return;const te=xx(x).filter(se=>se.type==="text").map(se=>se.text).join(`
|
|
500
|
-
`);if(te.trim()){R(!0);try{Z(),Me("automation_improve_clicked",{automation_id:t,agent_id:o,instructions_length:te.length}),m("chat"),await p({tiptapDoc:Fp({managerAgentId:_m.AUTOMATION_MANAGER(a.id),managerName:"Automation Manager",kind:"automation",id:t,instructions:te})})}finally{R(!1)}}},$=e.models?.tier??"smart",B=e.models?.modelId&&e.models?.credentialId?{modelId:e.models.modelId,credentialId:e.models.credentialId,title:e.models.modelTitle??e.models.modelId}:null,z=O0({defaultValues:{name:e.name,active:e.active,tier:$,modelOverride:B,tools:e.tools??null,maxAgentSteps:e.maxAgentSteps??null}}),K=z.watch("active"),[G,Y]=A.useReducer(xO,null),U=()=>{G!==null&&(Me("automation_updated",{automation_id:t,agent_id:o,fields:Array.from(G.fields),save_count:G.saveCount,edit_duration_ms:Date.now()-G.start}),Y({type:"reset"}))},W=async()=>{const J=z.control._formState.dirtyFields,te=Object.keys(J);if(te.length===0&&!I)return!0;const se=z.getValues(),ne=z.control._defaultValues;z.reset(se,{keepValues:!0});const de=I;M(!1);const xe={tier:se.tier,...se.modelOverride?{modelId:se.modelOverride.modelId,credentialId:se.modelOverride.credentialId,modelTitle:se.modelOverride.title}:{}},ue={id:t,name:se.name,active:se.active,models:xe,tools:se.tools,maxAgentSteps:se.maxAgentSteps,messages:gx(x),temperature:0};try{await l.mutateAsync(ue)}catch{return z.reset(ne,{keepValues:!0}),de&&M(!0),!1}const ce=[...te];return de&&ce.push("messages"),Y({type:"accumulate",now:Date.now(),fields:ce}),q(),!0},{schedule:H,flush:X}=gl({save:W}),{schedule:q,flush:Z}=gl({delayMs:3e4,save:async()=>U()});A.useEffect(()=>{const J=z.watch(()=>H());return()=>J.unsubscribe()},[]);const Q=J=>{if(v(J),!P){D(!0);return}M(!0),H()},ee=async()=>{Me("automation_test_clicked",{automation_id:t,agent_id:o});const J=await X();if(Z(),!!J){if(!x){ge.error(i("automations.automationDetail.noInstructionsConfigured"));return}try{const te=await d.mutateAsync(t);te.threadId&&(m("chat"),f(te.threadId))}catch{}}};return r.jsxs(r.Fragment,{children:[s&&r.jsx("div",{className:"flex items-center pb-4 shrink-0",children:r.jsxs(le,{variant:"ghost",size:"sm",onClick:s,children:[r.jsx(Gl,{size:14}),i("automations.automationDetail.backToList")]})}),r.jsxs("div",{className:"flex flex-col gap-8",children:[r.jsxs("div",{className:"flex flex-col gap-1.5",children:[r.jsxs("div",{className:"flex items-center justify-between gap-4",children:[r.jsx(_s,{control:z.control,name:"name",render:({field:J})=>r.jsx(rt,{...J,placeholder:i("automations.automationDetail.automationNamePlaceholder"),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"}})}),n&&r.jsx(le,{variant:"ghost",size:"icon",className:"text-muted-foreground hover:text-destructive shrink-0",onClick:n,children:r.jsx(Ns,{size:14})})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(_s,{control:z.control,name:"active",render:({field:J})=>r.jsx(xr,{checked:J.value,onCheckedChange:te=>{J.onChange(te),X()},className:"cursor-pointer"})}),r.jsx("span",{className:"text-sm text-muted-foreground",children:i(K?"automations.automationDetail.active":"automations.automationDetail.inactive")}),r.jsx("span",{className:"text-muted-foreground/50 text-sm",children:"·"}),r.jsx(zp,{id:e.created_by,size:"2xs",className:"text-sm text-muted-foreground"})]})]}),r.jsxs("div",{className:"flex flex-col gap-2.5",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:i("automations.automationDetail.starter")}),r.jsx(cO,{automationId:t,open:b,onOpenChange:y,onCustomSelect:()=>{j(!0),V(!1),C("")},onEventSelect:()=>{V(!0),j(!1)},onWebhookCreated:J=>{Me("automation_trigger_added",{automation_id:t,trigger_type:"webhook"}),T(J)}})]}),e.triggers.length===0&&!w?r.jsx("div",{className:"rounded-lg border border-dashed border-border px-4 py-6 text-center",children:r.jsxs("p",{className:"text-sm text-muted-foreground",children:[i("automations.automationDetail.whenShouldRun")," ",r.jsx("button",{type:"button",className:"text-foreground underline underline-offset-2 cursor-pointer hover:text-foreground/80 transition-colors",onClick:()=>y(!0),children:i("automations.automationDetail.addStarter")})," ",i("automations.automationDetail.toGetGoing")]})}):r.jsx("div",{className:"flex flex-col gap-2",children:e.triggers.map(J=>r.jsx(dO,{trigger:J,automationId:t,connectionName:J.connection_id?u.get(J.connection_id):void 0},J.id))}),w&&r.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2.5 rounded-lg border border-border bg-background group",children:[r.jsx(xo,{size:14,className:"text-muted-foreground shrink-0"}),r.jsx("input",{type:"text",value:S,onChange:J=>C(J.target.value),onBlur:async()=>{const J=S.trim();if(!(!J||!ko(J)))try{await c.mutateAsync({automation_id:t,type:"cron",cron_expression:J}),Me("automation_trigger_added",{automation_id:t,trigger_type:"cron"}),ge.success(i("automations.automationDetail.starterAdded")),j(!1),C("")}catch{ge.error(i("automations.automationDetail.failedToAddStarter"))}},onKeyDown:async J=>{const te=S.trim();J.key==="Enter"&&te&&ko(te)&&J.target.blur(),J.key==="Escape"&&(j(!1),C(""))},placeholder:"0 9 * * 1-5",className:"flex-1 text-sm font-mono bg-transparent outline-none placeholder:text-muted-foreground/40",autoFocus:!0}),S&&!ko(S)&&r.jsx("span",{className:"text-xs text-muted-foreground/60 shrink-0",children:i("automations.automationDetail.invalid")}),c.isPending&&r.jsx(et,{size:13,className:"animate-spin text-muted-foreground shrink-0"}),r.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:()=>{j(!1),C("")},children:r.jsx(Pn,{size:13})})]}),N&&r.jsx(A.Suspense,{fallback:r.jsxs("div",{className:"flex items-center gap-2 px-3 py-3 rounded-lg border border-border bg-background",children:[r.jsx(et,{size:13,className:"animate-spin text-muted-foreground"}),r.jsx("span",{className:"text-sm text-muted-foreground",children:i("automations.automationDetail.loadingConnections")})]}),children:r.jsx(hO,{automationId:t,onDone:()=>V(!1)})}),r.jsx(V4,{open:E!==null,onOpenChange:J=>{J||T(null)},url:E?.url??null,token:E?.token??null})]}),r.jsxs("div",{className:"flex flex-col gap-2.5",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:i("automations.automationDetail.instructions")}),r.jsxs(le,{variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",disabled:k||!x,onClick:O,children:[r.jsx(qn,{size:13}),i("automations.automationDetail.improve")]})]}),r.jsx(vp,{tiptapDoc:x,setTiptapDoc:Q,placeholder:i("automations.automationDetail.instructionsPlaceholder"),children:r.jsxs("div",{className:"rounded-xl border border-border min-h-[120px] flex flex-col",children:[r.jsx(bp,{virtualMcpId:o||null,className:"max-h-[45vh]"}),r.jsx("div",{className:"@container/chat-bottom flex items-center justify-end gap-1.5 p-2.5",children:r.jsxs(Ue,{children:[r.jsx(ze,{asChild:!0,children:r.jsxs(le,{type:"button",variant:"default",className:"h-8 gap-1.5 rounded-md px-3 text-sm font-medium",onClick:ee,disabled:!o,children:[r.jsx($0,{size:16}),i("automations.automationDetail.test")]})}),r.jsx(Ke,{children:i("automations.automationDetail.testAutomation")})]})})]})})]}),r.jsxs(Rx,{open:_,onOpenChange:L,className:"flex flex-col gap-2.5",children:[r.jsxs(Dx,{className:"group flex w-fit cursor-pointer items-center gap-1.5",children:[r.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:i("automations.automationDetail.advanced")}),r.jsx(ss,{size:14,className:"text-muted-foreground/60 transition-transform group-data-[state=open]:rotate-180"})]}),r.jsxs(Ix,{className:"flex flex-col gap-5 pt-0.5",children:[r.jsx(qM,{tier:z.watch("tier"),onTierChange:J=>z.setValue("tier",J,{shouldDirty:!0}),override:z.watch("modelOverride"),onOverrideChange:J=>z.setValue("modelOverride",J,{shouldDirty:!0})}),r.jsx(XM,{agentId:o||null,value:z.watch("tools"),onChange:J=>z.setValue("tools",J,{shouldDirty:!0})}),r.jsxs("div",{className:"flex flex-col gap-2",children:[r.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:i("automations.automationDetail.maxSteps")}),r.jsx(rt,{type:"number",min:1,max:100,className:"w-40",placeholder:i("automations.automationDetail.maxStepsPlaceholder",{default:gO}),value:z.watch("maxAgentSteps")??"",onChange:J=>{const te=J.target.value.trim(),se=te===""?null:Number(te);z.setValue("maxAgentSteps",se===null||Number.isNaN(se)?null:se,{shouldDirty:!0})}})]})]})]})]})]})}const N4=[{key:"24h",labelKey:"mainPanelTabs.automationTab.last24hours",ms:1440*60*1e3},{key:"7d",labelKey:"mainPanelTabs.automationTab.last7days",ms:10080*60*1e3},{key:"30d",labelKey:"mainPanelTabs.automationTab.last30days",ms:720*60*60*1e3}];function T4(t){const e=N4.find(n=>n.key===t).ms,s=Date.now();return{startDate:new Date(s-e).toISOString(),endDate:new Date(s).toISOString()}}function bO(t){const e=F.c(16),{automationId:s,triggerIds:n}=t,i=re(),[o,a]=A.useState("30d"),[l,c]=A.useState(_O);let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=x=>{const v=x;a(v),c(T4(v))},e[0]=d):d=e[0];let h;e[1]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx(Jt,{className:"w-44",children:r.jsx(as,{})}),e[1]=h):h=e[1];let u;e[2]!==i?(u=N4.map(x=>r.jsx(vt,{value:x.key,children:i(x.labelKey)},x.key)),e[2]=i,e[3]=u):u=e[3];let f;e[4]!==u?(f=r.jsx(Xt,{children:u}),e[4]=u,e[5]=f):f=e[5];let m;e[6]!==f||e[7]!==o?(m=r.jsx("div",{className:"flex items-center justify-end",children:r.jsxs(Qt,{value:o,onValueChange:d,children:[h,f]})}),e[6]=f,e[7]=o,e[8]=m):m=e[8];let p;e[9]!==s||e[10]!==l||e[11]!==n?(p=r.jsx(Mx,{automationId:s,triggerIds:n,range:l}),e[9]=s,e[10]=l,e[11]=n,e[12]=p):p=e[12];let g;return e[13]!==m||e[14]!==p?(g=r.jsxs("div",{className:"flex flex-col gap-5",children:[m,p]}),e[13]=m,e[14]=p,e[15]=g):g=e[15],g}function _O(){return T4("30d")}function yO(t){const e=F.c(5),{tabId:s}=t;let n;e[0]!==s?(n=i2(s),e[0]=s,e[1]=n):n=e[1];const i=n;if(!i)return null;let o;e[2]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx(Ti,{}),e[2]=o):o=e[2];let a;return e[3]!==i.id?(a=r.jsx(A.Suspense,{fallback:o,children:r.jsx(LO,{id:i.id})}),e[3]=i.id,e[4]=a):a=e[4],a}function LO(t){const e=F.c(41),{id:s}=t,n=re(),i=St(),{data:o,isLoading:a}=Gb(s),[l,c]=A.useState("settings");let d;e[0]!==i?(d=()=>{i({to:".",search:wO,replace:!0})},e[0]=i,e[1]=d):d=e[1];const h=d;if(a){let N;return e[2]===Symbol.for("react.memo_cache_sentinel")?(N=r.jsx(Ti,{}),e[2]=N):N=e[2],N}if(!o){let N;e[3]!==n?(N=n("mainPanelTabs.automationTab.automationNotFound"),e[3]=n,e[4]=N):N=e[4];let V;return e[5]!==N?(V=r.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-muted-foreground",children:N}),e[5]=N,e[6]=V):V=e[6],V}let u;e[7]!==o.triggers?(u=o.triggers.map(SO),e[7]=o.triggers,e[8]=u):u=e[8];const f=u;let m;e[9]===Symbol.for("react.memo_cache_sentinel")?(m=r.jsx(Gl,{size:14}),e[9]=m):m=e[9];let p;e[10]!==n?(p=n("mainPanelTabs.automationTab.backToList"),e[10]=n,e[11]=p):p=e[11];let g;e[12]!==h||e[13]!==p?(g=r.jsxs(le,{variant:"ghost",size:"sm",onClick:h,children:[m,p]}),e[12]=h,e[13]=p,e[14]=g):g=e[14];let x;e[15]!==n?(x=n("mainPanelTabs.automationTab.settings"),e[15]=n,e[16]=x):x=e[16];let v;e[17]!==x?(v={id:"settings",label:x},e[17]=x,e[18]=v):v=e[18];let b;e[19]!==n?(b=n("mainPanelTabs.automationTab.runs"),e[19]=n,e[20]=b):b=e[20];let y;e[21]!==b?(y={id:"runs",label:b},e[21]=b,e[22]=y):y=e[22];let _;e[23]!==v||e[24]!==y?(_=[v,y],e[23]=v,e[24]=y,e[25]=_):_=e[25];let L;e[26]===Symbol.for("react.memo_cache_sentinel")?(L=N=>c(N),e[26]=L):L=e[26];let w;e[27]!==_||e[28]!==l?(w=r.jsx(g2,{tabs:_,activeTab:l,onTabChange:L}),e[27]=_,e[28]=l,e[29]=w):w=e[29];let j;e[30]!==w||e[31]!==g?(j=r.jsxs("div",{className:"flex items-center justify-between pb-4 shrink-0",children:[g,w]}),e[30]=w,e[31]=g,e[32]=j):j=e[32];let S;e[33]!==o||e[34]!==s||e[35]!==l||e[36]!==f?(S=l==="settings"?r.jsx(vO,{automationId:s,automation:o}):r.jsx(bO,{automationId:s,triggerIds:f}),e[33]=o,e[34]=s,e[35]=l,e[36]=f,e[37]=S):S=e[37];let C;return e[38]!==j||e[39]!==S?(C=r.jsx(en,{children:r.jsx(en.Content,{children:r.jsxs(en.Body,{children:[j,S]})})}),e[38]=j,e[39]=S,e[40]=C):C=e[40],C}function SO(t){return t.id}function wO(t){return{...t,main:"automations"}}function jO(t){const e=F.c(29),{virtualMcpId:s}=t,n=re(),i=St(),{data:o}=Yb(s),a=o===void 0?[]:o,{create:l}=oa(),[c,d]=A.useState(""),h=c.toLowerCase(),u=a.filter(P=>P.name.toLowerCase().includes(h));let f;e[0]!==i?(f=P=>i({to:".",search:D=>({...D,main:"automation:"+P}),replace:!0}),e[0]=i,e[1]=f):f=e[1];const m=f,p=async()=>{if(l.isPending)return;Me("automation_new_clicked",{virtual_mcp_id:s,existing_count:a.length});const P=await l.mutateAsync(Jb(s));m(P.id)},g=l.isPending;let x;e[2]===Symbol.for("react.memo_cache_sentinel")?(x=r.jsx(kt,{size:14}),e[2]=x):x=e[2];let v;e[3]!==n?(v=n("automations.automationsList.newAutomation"),e[3]=n,e[4]=v):v=e[4];let b;e[5]!==l.isPending||e[6]!==p||e[7]!==v?(b=r.jsxs(le,{size:"sm",onClick:p,disabled:g,children:[x,v]}),e[5]=l.isPending,e[6]=p,e[7]=v,e[8]=b):b=e[8];const y=b,_=en,L=en,w=en;let j;e[9]!==n?(j=n("automations.automationsList.title"),e[9]=n,e[10]=j):j=e[10];let S;e[11]!==j?(S=r.jsx(en.Title,{children:j}),e[11]=j,e[12]=S):S=e[12];const C=a.length>0&&r.jsx(h9,{value:c,onChange:d,placeholder:n("automations.automationsList.searchPlaceholder"),className:"w-full md:w-[375px]"});let N;e[13]!==y||e[14]!==C?(N=r.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[C,y]}),e[13]=y,e[14]=C,e[15]=N):N=e[15];let V;e[16]!==S||e[17]!==N?(V=r.jsxs("div",{className:"flex flex-col gap-6",children:[S,N]}),e[16]=S,e[17]=N,e[18]=V):V=e[18];const E=a.length===0?r.jsx("div",{className:"flex items-center justify-center py-20",children:r.jsx(ki,{image:r.jsx(Ni,{size:48,className:"text-muted-foreground"}),title:n("automations.automationsList.emptyTitle"),description:n("automations.automationsList.emptyDescription"),actions:y})}):u.length===0?r.jsx("div",{className:"flex items-center justify-center py-20",children:r.jsx(ki,{image:r.jsx(Ni,{size:48,className:"text-muted-foreground"}),title:n("automations.automationsList.noResultsTitle"),description:n("automations.automationsList.noResultsDescription",{search:c})})}):r.jsx("div",{className:"mt-6 rounded-xl border border-border overflow-hidden",children:u.map(P=>r.jsx(Xb,{automation:P,onClick:()=>m(P.id)},P.id))});let T;e[19]!==V||e[20]!==E||e[21]!==w.Body?(T=r.jsxs(w.Body,{children:[V,E]}),e[19]=V,e[20]=E,e[21]=w.Body,e[22]=T):T=e[22];let k;e[23]!==T||e[24]!==L.Content?(k=r.jsx(L.Content,{children:T}),e[23]=T,e[24]=L.Content,e[25]=k):k=e[25];let R;return e[26]!==_||e[27]!==k?(R=r.jsx(_,{children:k}),e[26]=_,e[27]=k,e[28]=R):R=e[28],R}function CO(t){const e=F.c(3),{virtualMcpId:s}=t;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=r.jsx(Ti,{}),e[0]=n):n=e[0];let i;return e[1]!==s?(i=r.jsx(A.Suspense,{fallback:n,children:r.jsx(jO,{virtualMcpId:s})}),e[1]=s,e[2]=i):i=e[2],i}function kO(t){const e=F.c(49),{file:s,onClose:n}=t,i=re();let o,a;e[0]!==s.filename?(o=r.jsx(pr,{filename:s.filename,className:"h-4.5 w-3.5 shrink-0"}),a=r.jsx("span",{className:"truncate text-xs font-medium text-foreground",children:s.filename}),e[0]=s.filename,e[1]=o,e[2]=a):(o=e[1],a=e[2]);let l;e[3]!==s.size?(l=$6(s.size),e[3]=s.size,e[4]=l):l=e[4];let c;e[5]!==l?(c=r.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:l}),e[5]=l,e[6]=c):c=e[6];let d;e[7]!==o||e[8]!==a||e[9]!==c?(d=r.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2 px-2",children:[o,a,c]}),e[7]=o,e[8]=a,e[9]=c,e[10]=d):d=e[10];let h;e[11]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx(mb,{size:14}),e[11]=h):h=e[11];let u;e[12]!==s.downloadUrl||e[13]!==s.filename?(u=r.jsx(ze,{asChild:!0,children:r.jsx(le,{variant:"ghost",size:"icon",asChild:!0,children:r.jsx("a",{href:s.downloadUrl,download:s.filename,children:h})})}),e[12]=s.downloadUrl,e[13]=s.filename,e[14]=u):u=e[14];let f;e[15]!==i?(f=i("mainPanelTabs.fileTab.download"),e[15]=i,e[16]=f):f=e[16];let m;e[17]!==f?(m=r.jsx(Ke,{side:"bottom",children:f}),e[17]=f,e[18]=m):m=e[18];let p;e[19]!==u||e[20]!==m?(p=r.jsxs(Ue,{children:[u,m]}),e[19]=u,e[20]=m,e[21]=p):p=e[21];let g;e[22]!==s.downloadUrl?(g=()=>window.open(s.downloadUrl,"_blank","noopener"),e[22]=s.downloadUrl,e[23]=g):g=e[23];let x;e[24]===Symbol.for("react.memo_cache_sentinel")?(x=r.jsx(Dn,{size:14}),e[24]=x):x=e[24];let v;e[25]!==g?(v=r.jsx(ze,{asChild:!0,children:r.jsx(le,{variant:"ghost",size:"icon",onClick:g,children:x})}),e[25]=g,e[26]=v):v=e[26];let b;e[27]!==i?(b=i("mainPanelTabs.fileTab.openInNewTab"),e[27]=i,e[28]=b):b=e[28];let y;e[29]!==b?(y=r.jsx(Ke,{side:"bottom",children:b}),e[29]=b,e[30]=y):y=e[30];let _;e[31]!==v||e[32]!==y?(_=r.jsxs(Ue,{children:[v,y]}),e[31]=v,e[32]=y,e[33]=_):_=e[33];let L;e[34]===Symbol.for("react.memo_cache_sentinel")?(L=r.jsx(Pn,{size:14}),e[34]=L):L=e[34];let w;e[35]!==n?(w=r.jsx(ze,{asChild:!0,children:r.jsx(le,{variant:"ghost",size:"icon",onClick:n,children:L})}),e[35]=n,e[36]=w):w=e[36];let j;e[37]!==i?(j=i("mainPanelTabs.fileTab.close"),e[37]=i,e[38]=j):j=e[38];let S;e[39]!==j?(S=r.jsx(Ke,{side:"bottom",children:j}),e[39]=j,e[40]=S):S=e[40];let C;e[41]!==w||e[42]!==S?(C=r.jsxs(Ue,{children:[w,S]}),e[41]=w,e[42]=S,e[43]=C):C=e[43];let N;return e[44]!==p||e[45]!==_||e[46]!==C||e[47]!==d?(N=r.jsxs("div",{className:"flex h-9 shrink-0 items-center gap-1 border-b border-border/60 px-2",children:[d,p,_,C]}),e[44]=p,e[45]=_,e[46]=C,e[47]=d,e[48]=N):N=e[48],N}function VO(t){const e=F.c(31),{fileKey:s,taskId:n}=t,i=re(),o=St(),{data:a,isPending:l}=pm(n);let c;e[0]!==s||e[1]!==a?(c=a?.find(g=>g.key===s)??null,e[0]=s,e[1]=a,e[2]=c):c=e[2];const d=c;let h;e[3]!==o?(h=()=>o({to:".",search:NO,replace:!0}),e[3]=o,e[4]=h):h=e[4];const u=h;if(!d){if(l){let w;return e[5]===Symbol.for("react.memo_cache_sentinel")?(w=r.jsx("div",{className:"h-full w-full bg-background",children:r.jsx(O6,{})}),e[5]=w):w=e[5],w}let g;e[6]!==s?(g=s.split("/").pop()??s,e[6]=s,e[7]=g):g=e[7];let x;e[8]!==g?(x=r.jsx(pr,{filename:g,className:"h-7.5 w-6"}),e[8]=g,e[9]=x):x=e[9];let v;e[10]!==i?(v=i("mainPanelTabs.fileTab.fileNotAvailable"),e[10]=i,e[11]=v):v=e[11];let b;e[12]!==v?(b=r.jsx("span",{className:"text-sm text-muted-foreground",children:v}),e[12]=v,e[13]=b):b=e[13];let y;e[14]!==i?(y=i("mainPanelTabs.fileTab.close"),e[14]=i,e[15]=y):y=e[15];let _;e[16]!==u||e[17]!==y?(_=r.jsx(le,{variant:"ghost",size:"sm",onClick:u,children:y}),e[16]=u,e[17]=y,e[18]=_):_=e[18];let L;return e[19]!==x||e[20]!==b||e[21]!==_?(L=r.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-2 bg-background",children:[x,b,_]}),e[19]=x,e[20]=b,e[21]=_,e[22]=L):L=e[22],L}let f;e[23]!==d||e[24]!==u?(f=r.jsx(kO,{file:d,onClose:u}),e[23]=d,e[24]=u,e[25]=f):f=e[25];let m;e[26]!==d?(m=r.jsx("div",{className:"relative min-h-0 flex-1",children:r.jsx(B6,{file:d})}),e[26]=d,e[27]=m):m=e[27];let p;return e[28]!==f||e[29]!==m?(p=r.jsxs("div",{className:"flex h-full w-full flex-col bg-background",children:[f,m]}),e[28]=f,e[29]=m,e[30]=p):p=e[30],p}function NO(t){return{...t,main:0}}const hd="home";function TO(t){const e=F.c(5),{label:s}=t;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=r.jsx(Rt,{className:"aspect-video w-2/3 max-w-xl"}),e[0]=n):n=e[0];let i;e[1]!==s?(i=s&&r.jsx("p",{className:"text-xs text-muted-foreground",children:s}),e[1]=s,e[2]=i):i=e[2];let o;return e[3]!==i?(o=r.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-3 bg-background",children:[n,i]}),e[3]=i,e[4]=o):o=e[4],o}function AO(t){const e=F.c(15),{path:s}=t;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n={refetchIntervalWhenAbsent:2e3},e[0]=n):n=e[0];const i=F6(hd,s,n),o=z6(hd)(s);if(i.isPending||!i.data){const f=!i.isPending&&!i.data?"Waiting for the deck to sync…":void 0;let m;return e[1]!==f?(m=r.jsx(TO,{label:f}),e[1]=f,e[2]=m):m=e[2],m}let a;e[3]!==i.data?(a=K6(i.data),e[3]=i.data,e[4]=a):a=e[4];const l=i.data.shareMode??"private",c=i.data.effectivePublic??!1,d=window.location.origin+o;let h;e[5]!==s||e[6]!==l||e[7]!==c||e[8]!==d?(h=r.jsx(U6,{volume:hd,path:s,shareMode:l,effectivePublic:c,url:d}),e[5]=s,e[6]=l,e[7]=c,e[8]=d,e[9]=h):h=e[9];let u;return e[10]!==s||e[11]!==o||e[12]!==a||e[13]!==h?(u=r.jsx(H6,{readUrl:o,marker:a,title:s,savePath:s,trailing:h}),e[10]=s,e[11]=o,e[12]=a,e[13]=h,e[14]=u):u=e[14],u}function EO(t){const e=F.c(5),{path:s}=t,n=St();let i;e[0]!==n?(i=()=>n({to:".",search:PO,replace:!0}),e[0]=n,e[1]=i):i=e[1];const o=i;let a;return e[2]!==o||e[3]!==s?(a=r.jsx(W6,{previewPath:s,onClose:o,showSeeInLibrary:!0}),e[2]=o,e[3]=s,e[4]=a):a=e[4],a}function PO(t){return{...t,main:0}}function RO(){const t=F.c(12),e=St(),[s,n]=A.useState(null),[i,o]=A.useState(null);let a;t[0]!==e?(a=f=>e({to:".",search:m=>({...m,main:f}),replace:!0}),t[0]=e,t[1]=a):a=t[1];const l=a;let c;t[2]!==l?(c=r.jsx(q6,{onOpenFile:f=>l(rb(f)),onOpenSkill:n,onOpenBrand:o}),t[2]=l,t[3]=c):c=t[3];let d;t[4]!==s?(d=s&&r.jsx(G6,{skillPath:s,onClose:()=>n(null)},s),t[4]=s,t[5]=d):d=t[5];let h;t[6]!==i?(h=i&&r.jsx(Y6,{brandPath:i,onClose:()=>o(null)},i),t[6]=i,t[7]=h):h=t[7];let u;return t[8]!==c||t[9]!==d||t[10]!==h?(u=r.jsxs("div",{className:"flex flex-col h-full min-h-0 overflow-hidden",children:[c,d,h]}),t[8]=c,t[9]=d,t[10]=h,t[11]=u):u=t[11],u}const n1=A.lazy(()=>Bs(()=>import("./project-app-view-CaeNKaZB.js"),__vite__mapDeps([171,1,2,52,53,54,17,3,19,55,56,57,58,59,60,61,62,32,63,50,64,65,66,67,68,5,16,20,4,6,7,8,9,10,11,12,13,14,15,18,21,22,23,24,25,26,27,28,29,30,31,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,51,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,113,107,108,109,110,111,112,114,115,116,117,103,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,105,151,152,153,154,155])).then(t=>({default:t.AppViewContent})));function DO(t){const e=F.c(60),{activeTab:s,virtualMcpId:n,taskId:i,layoutTabs:o,expandedTools:a,automationTabParsed:l}=t;if(s==="overview"){let L;return e[0]===Symbol.for("react.memo_cache_sentinel")?(L=r.jsx(FN,{}),e[0]=L):L=e[0],L}if(s==="board"){let L;return e[1]===Symbol.for("react.memo_cache_sentinel")?(L=r.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:r.jsx(Nv,{})}),e[1]=L):L=e[1],L}if(ob(s)){let L;return e[2]!==n?(L=r.jsx(Oh,{virtualMcpId:n}),e[2]=n,e[3]=L):L=e[3],L}if(s==="git"){let L;return e[4]!==n?(L=r.jsx(HT,{virtualMcpId:n}),e[4]=n,e[5]=L):L=e[5],L}if(s==="automations"){let L;return e[6]!==n?(L=r.jsx(CO,{virtualMcpId:n}),e[6]=n,e[7]=L):L=e[7],L}if(s==="preview"){let L;return e[8]!==n?(L=r.jsx($E,{virtualMcpId:n}),e[8]=n,e[9]=L):L=e[9],L}let c;e[10]!==s?(c=ab(s),e[10]=s,e[11]=c):c=e[11];const d=c;if(d){let L;return e[12]!==d.path?(L=r.jsx(UE,{openPath:d.path}),e[12]=d.path,e[13]=L):L=e[13],L}if(s==="content"){let L;return e[14]!==n?(L=r.jsx(UM,{virtualMcpId:n}),e[14]=n,e[15]=L):L=e[15],L}if(s==="files"){let L;return e[16]===Symbol.for("react.memo_cache_sentinel")?(L=r.jsx(RO,{}),e[16]=L):L=e[16],L}if(l){let L;return e[17]!==s?(L=r.jsx(yO,{tabId:s}),e[17]=s,e[18]=L):L=e[18],L}let h;e[19]!==s?(h=o2(s),e[19]=s,e[20]=h):h=e[20];const u=h;if(u){let L;return e[21]!==u.path?(L=r.jsx(AO,{path:u.path},u.path),e[21]=u.path,e[22]=L):L=e[22],L}let f;e[23]!==s?(f=r2(s),e[23]=s,e[24]=f):f=e[24];const m=f;if(m){let L;return e[25]!==m.key||e[26]!==i?(L=r.jsx(VO,{fileKey:m.key,taskId:i}),e[25]=m.key,e[26]=i,e[27]=L):L=e[27],L}let p;e[28]!==s?(p=a2(s),e[28]=s,e[29]=p):p=e[29];const g=p;if(g){let L;return e[30]!==g.path?(L=r.jsx(EO,{path:g.path},g.path),e[30]=g.path,e[31]=L):L=e[31],L}let x;e[32]!==s?(x=lb(s),e[32]=s,e[33]=x):x=e[33];const v=x;if(v){let L;if(e[34]!==a||e[35]!==v.connectionId||e[36]!==v.toolName){let N;e[38]!==v.connectionId||e[39]!==v.toolName?(N=V=>V.appId===v.connectionId&&V.toolName===v.toolName,e[38]=v.connectionId,e[39]=v.toolName,e[40]=N):N=e[40],L=a.find(N),e[34]=a,e[35]=v.connectionId,e[36]=v.toolName,e[37]=L}else L=e[37];const w=L;let j;e[41]===Symbol.for("react.memo_cache_sentinel")?(j=r.jsx(Ti,{}),e[41]=j):j=e[41];const S=w?.args;let C;return e[42]!==s||e[43]!==v.connectionId||e[44]!==v.toolName||e[45]!==S?(C=r.jsx(A.Suspense,{fallback:j,children:r.jsx(n1,{connectionId:v.connectionId,toolName:v.toolName,args:S},s)}),e[42]=s,e[43]=v.connectionId,e[44]=v.toolName,e[45]=S,e[46]=C):C=e[46],C}let b;if(e[47]!==s||e[48]!==o){let L;e[50]!==s?(L=w=>w.id===s,e[50]=s,e[51]=L):L=e[51],b=o.find(L),e[47]=s,e[48]=o,e[49]=b}else b=e[49];const y=b;if(y){let L;e[52]===Symbol.for("react.memo_cache_sentinel")?(L=r.jsx(Ti,{}),e[52]=L):L=e[52];let w;return e[53]!==s||e[54]!==y.id||e[55]!==y.view.appId||e[56]!==y.view.args?(w=r.jsx(A.Suspense,{fallback:L,children:r.jsx(n1,{connectionId:y.view.appId,toolName:y.id,args:y.view.args},s)}),e[53]=s,e[54]=y.id,e[55]=y.view.appId,e[56]=y.view.args,e[57]=w):w=e[57],w}let _;return e[58]!==n?(_=r.jsx(Oh,{virtualMcpId:n}),e[58]=n,e[59]=_):_=e[59],_}function IO(t){const e=F.c(14),{taskId:s,virtualMcpId:n}=t;let i;e[0]!==s||e[1]!==n?(i={virtualMcpId:n,taskId:s},e[0]=s,e[1]=n,e[2]=i):i=e[2];const{activeTab:o,layoutTabs:a,expandedTools:l,automationTabParsed:c}=B9(i);let d;e[3]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(Ti,{}),e[3]=d):d=e[3];let h;e[4]!==o||e[5]!==c||e[6]!==l||e[7]!==a||e[8]!==s||e[9]!==n?(h=r.jsx(A.Suspense,{fallback:d,children:r.jsx(DO,{activeTab:o,virtualMcpId:n,taskId:s,layoutTabs:a,expandedTools:l,automationTabParsed:c})}),e[4]=o,e[5]=c,e[6]=l,e[7]=a,e[8]=s,e[9]=n,e[10]=h):h=e[10];let u;return e[11]!==o||e[12]!==h?(u=r.jsx(ys,{children:h},o),e[11]=o,e[12]=h,e[13]=u):u=e[13],u}const Li="setup";function MO(t){const e=F.c(38),s=re();let n;if(e[0]!==t.scriptTabs||e[1]!==t.scripts){let p;e[3]!==t.scriptTabs?(p=g=>!t.scriptTabs.includes(g),e[3]=t.scriptTabs,e[4]=p):p=e[4],n=t.scripts.filter(p),e[0]=t.scriptTabs,e[1]=t.scripts,e[2]=n}else n=e[2];const i=n;let o;e[5]!==t?(o=()=>{t.active===Li?t.onToggle():t.onSelectTab(Li)},e[5]=t,e[6]=o):o=e[6];const a=o,l=t.active===Li;let c;e[7]!==a||e[8]!==t.open||e[9]!==s||e[10]!==l?(c=r.jsx(OO,{active:l,open:t.open,onClick:a,t:s}),e[7]=a,e[8]=t.open,e[9]=s,e[10]=l,e[11]=c):c=e[11];let d;e[12]!==t||e[13]!==s?(d=t.scriptTabs.map(p=>r.jsx($O,{active:t.active===p,onClick:()=>{t.active===p?t.onToggle():t.onSelectTab(p)},onClose:()=>t.onCloseScript(p),t:s,children:p},p)),e[12]=t,e[13]=s,e[14]=d):d=e[14];let h;e[15]!==i||e[16]!==t.onAddScript?(h=r.jsx(FO,{scripts:i,onRun:t.onAddScript}),e[15]=i,e[16]=t.onAddScript,e[17]=h):h=e[17];let u;e[18]!==c||e[19]!==d||e[20]!==h?(u=r.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1 overflow-x-auto",children:[c,d,h]}),e[18]=c,e[19]=d,e[20]=h,e[21]=u):u=e[21];let f;e[22]!==t.onRestart||e[23]!==t.onResume||e[24]!==t.onRetry||e[25]!==t.onRunActiveScript||e[26]!==t.onStart||e[27]!==t.onStop||e[28]!==t.onStopActiveScript||e[29]!==t.scriptIsKilling||e[30]!==t.scriptIsRunning||e[31]!==t.showScriptControls||e[32]!==t.status||e[33]!==s?(f=t.showScriptControls?r.jsx(zO,{isRunning:t.scriptIsRunning,isKilling:t.scriptIsKilling,onRun:t.onRunActiveScript,onStop:t.onStopActiveScript,t:s}):r.jsx(BO,{status:t.status,onStart:t.onStart,onStop:t.onStop,onRestart:t.onRestart,onResume:t.onResume,onRetry:t.onRetry,t:s}),e[22]=t.onRestart,e[23]=t.onResume,e[24]=t.onRetry,e[25]=t.onRunActiveScript,e[26]=t.onStart,e[27]=t.onStop,e[28]=t.onStopActiveScript,e[29]=t.scriptIsKilling,e[30]=t.scriptIsRunning,e[31]=t.showScriptControls,e[32]=t.status,e[33]=s,e[34]=f):f=e[34];let m;return e[35]!==u||e[36]!==f?(m=r.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-1 border-t border-b border-border bg-muted/60 px-3",children:[u,f]}),e[35]=u,e[36]=f,e[37]=m):m=e[37],m}function OO(t){const e=F.c(11),{active:s,open:n,onClick:i,t:o}=t,a=s&&n,l=s&&n,c=s?"border-border bg-background font-medium text-foreground shadow-sm":"border-transparent text-muted-foreground hover:bg-background/50 hover:text-foreground";let d;e[0]!==c?(d=ie("flex h-7 items-center gap-1.5 rounded-md border px-2.5 text-xs",c),e[0]=c,e[1]=d):d=e[1];let h;e[2]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx(u6,{className:"size-3.5"}),e[2]=h):h=e[2];let u;e[3]!==o?(u=o("sandbox.toolbar.setupTab"),e[3]=o,e[4]=u):u=e[4];let f;return e[5]!==i||e[6]!==a||e[7]!==l||e[8]!==d||e[9]!==u?(f=r.jsxs("button",{type:"button","aria-pressed":a,"aria-expanded":l,onClick:i,className:d,children:[h,u]}),e[5]=i,e[6]=a,e[7]=l,e[8]=d,e[9]=u,e[10]=f):f=e[10],f}function BO(t){const e=F.c(41),{status:s,onStart:n,onStop:i,onRestart:o,onResume:a,onRetry:l,t:c}=t;if(s==="idle"&&n){let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(Vi,{className:"size-3.5"}),e[0]=d):d=e[0];let h;e[1]!==c?(h=c("sandbox.toolbar.start"),e[1]=c,e[2]=h):h=e[2];let u;return e[3]!==n||e[4]!==h?(u=r.jsxs(le,{variant:"outline",size:"sm",onClick:n,children:[d," ",h]}),e[3]=n,e[4]=h,e[5]=u):u=e[5],u}if(s==="suspended"&&a){let d;e[6]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(Vi,{className:"size-3.5"}),e[6]=d):d=e[6];let h;e[7]!==c?(h=c("sandbox.toolbar.resume"),e[7]=c,e[8]=h):h=e[8];let u;return e[9]!==a||e[10]!==h?(u=r.jsxs(le,{variant:"outline",size:"sm",onClick:a,children:[d," ",h]}),e[9]=a,e[10]=h,e[11]=u):u=e[11],u}if(s==="errored"&&l){let d;e[12]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(dr,{className:"size-3.5"}),e[12]=d):d=e[12];let h;e[13]!==c?(h=c("sandbox.toolbar.retry"),e[13]=c,e[14]=h):h=e[14];let u;return e[15]!==l||e[16]!==h?(u=r.jsxs(le,{variant:"outline",size:"sm",onClick:l,children:[d," ",h]}),e[15]=l,e[16]=h,e[17]=u):u=e[17],u}if(s==="starting"||s==="running"){const d=s==="running"&&!!o,h=d?"rounded-r-none border-r-0":void 0;let u;e[18]!==h?(u=ie(h),e[18]=h,e[19]=u):u=e[19];let f;e[20]===Symbol.for("react.memo_cache_sentinel")?(f=r.jsx(Um,{className:"size-3.5"}),e[20]=f):f=e[20];let m;e[21]!==c?(m=c("sandbox.toolbar.stop"),e[21]=c,e[22]=m):m=e[22];let p;e[23]!==i||e[24]!==u||e[25]!==m?(p=r.jsx(ze,{asChild:!0,children:r.jsxs(le,{variant:"outline",size:"sm",onClick:i,className:u,children:[f," ",m]})}),e[23]=i,e[24]=u,e[25]=m,e[26]=p):p=e[26];let g;e[27]!==c?(g=c("sandbox.toolbar.stopSandboxTooltip"),e[27]=c,e[28]=g):g=e[28];let x;e[29]!==g?(x=r.jsx(Ke,{children:g}),e[29]=g,e[30]=x):x=e[30];let v;e[31]!==p||e[32]!==x?(v=r.jsxs(Ue,{children:[p,x]}),e[31]=p,e[32]=x,e[33]=v):v=e[33];let b;e[34]!==o||e[35]!==d||e[36]!==c?(b=d&&r.jsxs(us,{children:[r.jsx(ds,{asChild:!0,children:r.jsx(le,{variant:"outline",size:"sm",className:"rounded-l-none px-1",children:r.jsx(ss,{className:"size-3"})})}),r.jsx(hs,{align:"end",children:r.jsxs(Xe,{onClick:o,children:[r.jsx(dr,{className:"size-3.5"})," ",c("sandbox.toolbar.restart")]})})]}),e[34]=o,e[35]=d,e[36]=c,e[37]=b):b=e[37];let y;return e[38]!==v||e[39]!==b?(y=r.jsxs("div",{className:"flex items-center",children:[v,b]}),e[38]=v,e[39]=b,e[40]=y):y=e[40],y}return null}function $O(t){const e=F.c(17),{active:s,onClick:n,onClose:i,children:o,t:a}=t,l=s?"border-border bg-background shadow-sm":"border-transparent hover:bg-background/50";let c;e[0]!==l?(c=ie("flex h-7 items-center rounded-md border text-xs",l),e[0]=l,e[1]=c):c=e[1];const d=i?"pl-2.5 pr-1":"px-2.5",h=s?"font-medium text-foreground":"text-muted-foreground hover:text-foreground";let u;e[2]!==d||e[3]!==h?(u=ie("flex h-full items-center",d,h),e[2]=d,e[3]=h,e[4]=u):u=e[4];let f;e[5]!==o||e[6]!==n||e[7]!==u?(f=r.jsx("button",{type:"button",onClick:n,className:u,children:o}),e[5]=o,e[6]=n,e[7]=u,e[8]=f):f=e[8];let m;e[9]!==o||e[10]!==i||e[11]!==a?(m=i&&r.jsx("button",{type:"button","aria-label":a("sandbox.toolbar.closeTab",{tab:String(o)}),onClick:i,className:"pr-1.5 text-muted-foreground hover:text-foreground",children:r.jsx(ks,{className:"size-3"})}),e[9]=o,e[10]=i,e[11]=a,e[12]=m):m=e[12];let p;return e[13]!==c||e[14]!==f||e[15]!==m?(p=r.jsxs("div",{className:c,children:[f,m]}),e[13]=c,e[14]=f,e[15]=m,e[16]=p):p=e[16],p}function FO(t){const e=F.c(27),{scripts:s,onRun:n}=t,i=re(),[o,a]=A.useState(!1);let l;e[0]!==i?(l=i("sandbox.toolbar.runScript"),e[0]=i,e[1]=l):l=e[1];let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=r.jsx(kt,{className:"size-3.5"}),e[2]=c):c=e[2];let d;e[3]!==l?(d=r.jsx(ze,{asChild:!0,children:r.jsx(Es,{asChild:!0,children:r.jsx(le,{variant:"ghost",size:"sm","aria-label":l,children:c})})}),e[3]=l,e[4]=d):d=e[4];let h;e[5]!==i?(h=i("sandbox.toolbar.runScript"),e[5]=i,e[6]=h):h=e[6];let u;e[7]!==h?(u=r.jsx(Ke,{children:h}),e[7]=h,e[8]=u):u=e[8];let f;e[9]!==d||e[10]!==u?(f=r.jsxs(Ue,{children:[d,u]}),e[9]=d,e[10]=u,e[11]=f):f=e[11];let m;e[12]!==i?(m=i("sandbox.toolbar.runAScript"),e[12]=i,e[13]=m):m=e[13];let p;e[14]!==m?(p=r.jsx("div",{className:"px-2 py-1 text-[10px] uppercase tracking-wide text-muted-foreground",children:m}),e[14]=m,e[15]=p):p=e[15];let g;e[16]!==n||e[17]!==s||e[18]!==i?(g=s.length===0?r.jsx("div",{className:"px-2 py-2 text-xs text-muted-foreground",children:i("sandbox.toolbar.noScriptsFound")}):s.map(b=>r.jsxs("button",{type:"button",onClick:()=>{a(!1),n(b)},className:"w-full rounded-md px-2 py-1.5 text-left text-xs hover:bg-accent",children:["▸ ",b]},b)),e[16]=n,e[17]=s,e[18]=i,e[19]=g):g=e[19];let x;e[20]!==p||e[21]!==g?(x=r.jsxs(Ps,{align:"start",className:"p-1 w-56",children:[p,g]}),e[20]=p,e[21]=g,e[22]=x):x=e[22];let v;return e[23]!==o||e[24]!==x||e[25]!==f?(v=r.jsxs(As,{open:o,onOpenChange:a,children:[f,x]}),e[23]=o,e[24]=x,e[25]=f,e[26]=v):v=e[26],v}function zO(t){const e=F.c(31),{isRunning:s,isKilling:n,onRun:i,onStop:o,t:a}=t;if(n){let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m=r.jsx(et,{className:"size-3.5 animate-spin"}),e[0]=m):m=e[0];let p;e[1]!==a?(p=a("sandbox.toolbar.stopping"),e[1]=a,e[2]=p):p=e[2];let g;return e[3]!==p?(g=r.jsxs(le,{variant:"outline",size:"sm",disabled:!0,children:[m," ",p]}),e[3]=p,e[4]=g):g=e[4],g}if(!s){let m;e[5]===Symbol.for("react.memo_cache_sentinel")?(m=r.jsx(Vi,{className:"size-3.5"}),e[5]=m):m=e[5];let p;e[6]!==a?(p=a("sandbox.toolbar.run"),e[6]=a,e[7]=p):p=e[7];let g;e[8]!==i||e[9]!==p?(g=r.jsx(ze,{asChild:!0,children:r.jsxs(le,{variant:"outline",size:"sm",onClick:i,children:[m," ",p]})}),e[8]=i,e[9]=p,e[10]=g):g=e[10];let x;e[11]!==a?(x=a("sandbox.toolbar.startProcess"),e[11]=a,e[12]=x):x=e[12];let v;e[13]!==x?(v=r.jsx(Ke,{children:x}),e[13]=x,e[14]=v):v=e[14];let b;return e[15]!==g||e[16]!==v?(b=r.jsxs(Ue,{children:[g,v]}),e[15]=g,e[16]=v,e[17]=b):b=e[17],b}let l;e[18]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(Um,{className:"size-3.5"}),e[18]=l):l=e[18];let c;e[19]!==a?(c=a("sandbox.toolbar.stop"),e[19]=a,e[20]=c):c=e[20];let d;e[21]!==o||e[22]!==c?(d=r.jsx(ze,{asChild:!0,children:r.jsxs(le,{variant:"outline",size:"sm",onClick:o,children:[l," ",c]})}),e[21]=o,e[22]=c,e[23]=d):d=e[23];let h;e[24]!==a?(h=a("sandbox.toolbar.stopProcess"),e[24]=a,e[25]=h):h=e[25];let u;e[26]!==h?(u=r.jsx(Ke,{children:h}),e[26]=h,e[27]=u):u=e[27];let f;return e[28]!==d||e[29]!==u?(f=r.jsxs(Ue,{children:[d,u]}),e[28]=d,e[29]=u,e[30]=f):f=e[30],f}var A4=Object.defineProperty,KO=Object.getOwnPropertyDescriptor,UO=(t,e)=>{for(var s in e)A4(t,s,{get:e[s],enumerable:!0})},At=(t,e,s,n)=>{for(var i=n>1?void 0:n?KO(e,s):e,o=t.length-1,a;o>=0;o--)(a=t[o])&&(i=(n?a(e,s,i):a(i))||i);return n&&i&&A4(e,s,i),i},Ee=(t,e)=>(s,n)=>e(s,n,t),i1="Terminal input",e0={get:()=>i1,set:t=>i1=t},r1="Too much output to announce, navigate to rows manually to read",t0={get:()=>r1,set:t=>r1=t};function HO(t){return t.replace(/\r?\n/g,"\r")}function WO(t,e){return e?"\x1B[200~"+t+"\x1B[201~":t}function qO(t,e){t.clipboardData&&t.clipboardData.setData("text/plain",e.selectionText),t.preventDefault()}function GO(t,e,s,n){if(t.stopPropagation(),t.clipboardData){let i=t.clipboardData.getData("text/plain");E4(i,e,s,n)}}function E4(t,e,s,n){t=HO(t),t=WO(t,s.decPrivateModes.bracketedPasteMode&&n.rawOptions.ignoreBracketedPasteMode!==!0),s.triggerDataEvent(t,!0),e.value=""}function P4(t,e,s){let n=s.getBoundingClientRect(),i=t.clientX-n.left-10,o=t.clientY-n.top-10;e.style.width="20px",e.style.height="20px",e.style.left=`${i}px`,e.style.top=`${o}px`,e.style.zIndex="1000",e.focus()}function o1(t,e,s,n,i){P4(t,e,s),i&&n.rightClickSelect(t),e.value=n.selectionText,e.select()}function Un(t){return t>65535?(t-=65536,String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):String.fromCharCode(t)}function kc(t,e=0,s=t.length){let n="";for(let i=e;i<s;++i){let o=t[i];o>65535?(o-=65536,n+=String.fromCharCode((o>>10)+55296)+String.fromCharCode(o%1024+56320)):n+=String.fromCharCode(o)}return n}var YO=class{constructor(){this._interim=0}clear(){this._interim=0}decode(t,e){let s=t.length;if(!s)return 0;let n=0,i=0;if(this._interim){let o=t.charCodeAt(i++);56320<=o&&o<=57343?e[n++]=(this._interim-55296)*1024+o-56320+65536:(e[n++]=this._interim,e[n++]=o),this._interim=0}for(let o=i;o<s;++o){let a=t.charCodeAt(o);if(55296<=a&&a<=56319){if(++o>=s)return this._interim=a,n;let l=t.charCodeAt(o);56320<=l&&l<=57343?e[n++]=(a-55296)*1024+l-56320+65536:(e[n++]=a,e[n++]=l);continue}a!==65279&&(e[n++]=a)}return n}},JO=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(t,e){let s=t.length;if(!s)return 0;let n=0,i,o,a,l,c=0,d=0;if(this.interim[0]){let f=!1,m=this.interim[0];m&=(m&224)===192?31:(m&240)===224?15:7;let p=0,g;for(;(g=this.interim[++p]&63)&&p<4;)m<<=6,m|=g;let x=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,v=x-p;for(;d<v;){if(d>=s)return 0;if(g=t[d++],(g&192)!==128){d--,f=!0;break}else this.interim[p++]=g,m<<=6,m|=g&63}f||(x===2?m<128?d--:e[n++]=m:x===3?m<2048||m>=55296&&m<=57343||m===65279||(e[n++]=m):m<65536||m>1114111||(e[n++]=m)),this.interim.fill(0)}let h=s-4,u=d;for(;u<s;){for(;u<h&&!((i=t[u])&128)&&!((o=t[u+1])&128)&&!((a=t[u+2])&128)&&!((l=t[u+3])&128);)e[n++]=i,e[n++]=o,e[n++]=a,e[n++]=l,u+=4;if(i=t[u++],i<128)e[n++]=i;else if((i&224)===192){if(u>=s)return this.interim[0]=i,n;if(o=t[u++],(o&192)!==128){u--;continue}if(c=(i&31)<<6|o&63,c<128){u--;continue}e[n++]=c}else if((i&240)===224){if(u>=s)return this.interim[0]=i,n;if(o=t[u++],(o&192)!==128){u--;continue}if(u>=s)return this.interim[0]=i,this.interim[1]=o,n;if(a=t[u++],(a&192)!==128){u--;continue}if(c=(i&15)<<12|(o&63)<<6|a&63,c<2048||c>=55296&&c<=57343||c===65279)continue;e[n++]=c}else if((i&248)===240){if(u>=s)return this.interim[0]=i,n;if(o=t[u++],(o&192)!==128){u--;continue}if(u>=s)return this.interim[0]=i,this.interim[1]=o,n;if(a=t[u++],(a&192)!==128){u--;continue}if(u>=s)return this.interim[0]=i,this.interim[1]=o,this.interim[2]=a,n;if(l=t[u++],(l&192)!==128){u--;continue}if(c=(i&7)<<18|(o&63)<<12|(a&63)<<6|l&63,c<65536||c>1114111)continue;e[n++]=c}}return n}},R4="",Wn=" ",fa=class D4{constructor(){this.fg=0,this.bg=0,this.extended=new Il}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let e=new D4;return e.fg=this.fg,e.bg=this.bg,e.extended=this.extended.clone(),e}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)===50331648}isBgRGB(){return(this.bg&50331648)===50331648}isFgPalette(){return(this.fg&50331648)===16777216||(this.fg&50331648)===33554432}isBgPalette(){return(this.bg&50331648)===16777216||(this.bg&50331648)===33554432}isFgDefault(){return(this.fg&50331648)===0}isBgDefault(){return(this.bg&50331648)===0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===16777216||(this.extended.underlineColor&50331648)===33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},Il=class I4{constructor(e=0,s=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=s}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new I4(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Gs=class M4 extends fa{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new Il,this.combinedData=""}static fromCharData(e){let s=new M4;return s.setFromCharData(e),s}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?Un(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let s=!1;if(e[1].length>2)s=!0;else if(e[1].length===2){let n=e[1].charCodeAt(0);if(55296<=n&&n<=56319){let i=e[1].charCodeAt(1);56320<=i&&i<=57343?this.content=(n-55296)*1024+i-56320+65536|e[2]<<22:s=!0}else s=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;s&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},a1="di$target",s0="di$dependencies",fd=new Map;function XO(t){return t[s0]||[]}function ns(t){if(fd.has(t))return fd.get(t);let e=function(s,n,i){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");QO(e,s,i)};return e._id=t,fd.set(t,e),e}function QO(t,e,s){e[a1]===e?e[s0].push({id:t,index:s}):(e[s0]=[{id:t,index:s}],e[a1]=e)}var ws=ns("BufferService"),O4=ns("CoreMouseService"),Gi=ns("CoreService"),ZO=ns("CharsetService"),ju=ns("InstantiationService"),B4=ns("LogService"),js=ns("OptionsService"),$4=ns("OscLinkService"),eB=ns("UnicodeService"),ma=ns("DecorationService"),n0=class{constructor(t,e,s){this._bufferService=t,this._optionsService=e,this._oscLinkService=s}provideLinks(t,e){let s=this._bufferService.buffer.lines.get(t-1);if(!s){e(void 0);return}let n=[],i=this._optionsService.rawOptions.linkHandler,o=new Gs,a=s.getTrimmedLength(),l=-1,c=-1,d=!1;for(let h=0;h<a;h++)if(!(c===-1&&!s.hasContent(h))){if(s.loadCell(h,o),o.hasExtendedAttrs()&&o.extended.urlId)if(c===-1){c=h,l=o.extended.urlId;continue}else d=o.extended.urlId!==l;else c!==-1&&(d=!0);if(d||c!==-1&&h===a-1){let u=this._oscLinkService.getLinkData(l)?.uri;if(u){let f={start:{x:c+1,y:t},end:{x:h+(!d&&h===a-1?1:0),y:t}},m=!1;if(!i?.allowNonHttpProtocols)try{let p=new URL(u);["http:","https:"].includes(p.protocol)||(m=!0)}catch{m=!0}m||n.push({text:u,range:f,activate:(p,g)=>i?i.activate(p,g,f):tB(p,g),hover:(p,g)=>i?.hover?.(p,g,f),leave:(p,g)=>i?.leave?.(p,g,f)})}d=!1,o.hasExtendedAttrs()&&o.extended.urlId?(c=h,l=o.extended.urlId):(c=-1,l=-1)}}e(n)}};n0=At([Ee(0,ws),Ee(1,js),Ee(2,$4)],n0);function tB(t,e){if(confirm(`Do you want to navigate to ${e}?
|
|
501
|
-
|
|
502
|
-
WARNING: This link could potentially be dangerous`)){let s=window.open();if(s){try{s.opener=null}catch{}s.location.href=e}else console.warn("Opening link blocked as opener could not be cleared")}}var Vc=ns("CharSizeService"),Mn=ns("CoreBrowserService"),Cu=ns("MouseService"),On=ns("RenderService"),sB=ns("SelectionService"),F4=ns("CharacterJoinerService"),zr=ns("ThemeService"),z4=ns("LinkProviderService"),nB=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(t){setTimeout(()=>{throw t.stack?l1.isErrorNoTelemetry(t)?new l1(t.message+`
|
|
503
|
-
|
|
504
|
-
`+t.stack):new Error(t.message+`
|
|
505
|
-
|
|
506
|
-
`+t.stack):t},0)}}addListener(t){return this.listeners.push(t),()=>{this._removeListener(t)}}emit(t){this.listeners.forEach(e=>{e(t)})}_removeListener(t){this.listeners.splice(this.listeners.indexOf(t),1)}setUnexpectedErrorHandler(t){this.unexpectedErrorHandler=t}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(t){this.unexpectedErrorHandler(t),this.emit(t)}onUnexpectedExternalError(t){this.unexpectedErrorHandler(t)}},iB=new nB;function qa(t){rB(t)||iB.onUnexpectedError(t)}var i0="Canceled";function rB(t){return t instanceof oB?!0:t instanceof Error&&t.name===i0&&t.message===i0}var oB=class extends Error{constructor(){super(i0),this.name=this.message}};function aB(t){return new Error(`Illegal argument: ${t}`)}var l1=class r0 extends Error{constructor(e){super(e),this.name="CodeExpectedError"}static fromError(e){if(e instanceof r0)return e;let s=new r0;return s.message=e.message,s.stack=e.stack,s}static isErrorNoTelemetry(e){return e.name==="CodeExpectedError"}},o0=class K4 extends Error{constructor(e){super(e||"An unexpected bug occurred."),Object.setPrototypeOf(this,K4.prototype)}};function Rs(t,e=0){return t[t.length-(1+e)]}var lB;(t=>{function e(o){return o<0}t.isLessThan=e;function s(o){return o<=0}t.isLessThanOrEqual=s;function n(o){return o>0}t.isGreaterThan=n;function i(o){return o===0}t.isNeitherLessOrGreaterThan=i,t.greaterThan=1,t.lessThan=-1,t.neitherLessOrGreaterThan=0})(lB||={});function cB(t,e){let s=this,n=!1,i;return function(){return n||(n=!0,e||(i=t.apply(s,arguments))),i}}var U4;(t=>{function e(_){return _&&typeof _=="object"&&typeof _[Symbol.iterator]=="function"}t.is=e;let s=Object.freeze([]);function n(){return s}t.empty=n;function*i(_){yield _}t.single=i;function o(_){return e(_)?_:i(_)}t.wrap=o;function a(_){return _||s}t.from=a;function*l(_){for(let L=_.length-1;L>=0;L--)yield _[L]}t.reverse=l;function c(_){return!_||_[Symbol.iterator]().next().done===!0}t.isEmpty=c;function d(_){return _[Symbol.iterator]().next().value}t.first=d;function h(_,L){let w=0;for(let j of _)if(L(j,w++))return!0;return!1}t.some=h;function u(_,L){for(let w of _)if(L(w))return w}t.find=u;function*f(_,L){for(let w of _)L(w)&&(yield w)}t.filter=f;function*m(_,L){let w=0;for(let j of _)yield L(j,w++)}t.map=m;function*p(_,L){let w=0;for(let j of _)yield*L(j,w++)}t.flatMap=p;function*g(..._){for(let L of _)yield*L}t.concat=g;function x(_,L,w){let j=w;for(let S of _)j=L(j,S);return j}t.reduce=x;function*v(_,L,w=_.length){for(L<0&&(L+=_.length),w<0?w+=_.length:w>_.length&&(w=_.length);L<w;L++)yield _[L]}t.slice=v;function b(_,L=Number.POSITIVE_INFINITY){let w=[];if(L===0)return[w,_];let j=_[Symbol.iterator]();for(let S=0;S<L;S++){let C=j.next();if(C.done)return[w,t.empty()];w.push(C.value)}return[w,{[Symbol.iterator](){return j}}]}t.consume=b;async function y(_){let L=[];for await(let w of _)L.push(w);return Promise.resolve(L)}t.asyncToArray=y})(U4||={});function Pi(t){if(U4.is(t)){let e=[];for(let s of t)if(s)try{s.dispose()}catch(n){e.push(n)}if(e.length===1)throw e[0];if(e.length>1)throw new AggregateError(e,"Encountered errors while disposing of store");return Array.isArray(t)?[]:t}else if(t)return t.dispose(),t}function dB(...t){return Lt(()=>Pi(t))}function Lt(t){return{dispose:cB(()=>{t()})}}var H4=class W4{constructor(){this._toDispose=new Set,this._isDisposed=!1}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{Pi(this._toDispose)}finally{this._toDispose.clear()}}add(e){if(!e)return e;if(e===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?W4.DISABLE_DISPOSED_WARNING||console.warn(new Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(e),e}delete(e){if(e){if(e===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(e),e.dispose()}}deleteAndLeak(e){e&&this._toDispose.has(e)&&(this._toDispose.delete(e),void 0)}};H4.DISABLE_DISPOSED_WARNING=!1;var Jn=H4,tt=class{constructor(){this._store=new Jn,this._store}dispose(){this._store.dispose()}_register(t){if(t===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(t)}};tt.None=Object.freeze({dispose(){}});var Lr=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(t){this._isDisposed||t===this._value||(this._value?.dispose(),this._value=t)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,this._value?.dispose(),this._value=void 0}clearAndLeak(){let t=this._value;return this._value=void 0,t}},Tn=typeof window=="object"?window:globalThis,a0=class l0{constructor(e){this.element=e,this.next=l0.Undefined,this.prev=l0.Undefined}};a0.Undefined=new a0(void 0);var jt=a0,c1=class{constructor(){this._first=jt.Undefined,this._last=jt.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===jt.Undefined}clear(){let t=this._first;for(;t!==jt.Undefined;){let e=t.next;t.prev=jt.Undefined,t.next=jt.Undefined,t=e}this._first=jt.Undefined,this._last=jt.Undefined,this._size=0}unshift(t){return this._insert(t,!1)}push(t){return this._insert(t,!0)}_insert(t,e){let s=new jt(t);if(this._first===jt.Undefined)this._first=s,this._last=s;else if(e){let i=this._last;this._last=s,s.prev=i,i.next=s}else{let i=this._first;this._first=s,s.next=i,i.prev=s}this._size+=1;let n=!1;return()=>{n||(n=!0,this._remove(s))}}shift(){if(this._first!==jt.Undefined){let t=this._first.element;return this._remove(this._first),t}}pop(){if(this._last!==jt.Undefined){let t=this._last.element;return this._remove(this._last),t}}_remove(t){if(t.prev!==jt.Undefined&&t.next!==jt.Undefined){let e=t.prev;e.next=t.next,t.next.prev=e}else t.prev===jt.Undefined&&t.next===jt.Undefined?(this._first=jt.Undefined,this._last=jt.Undefined):t.next===jt.Undefined?(this._last=this._last.prev,this._last.next=jt.Undefined):t.prev===jt.Undefined&&(this._first=this._first.next,this._first.prev=jt.Undefined);this._size-=1}*[Symbol.iterator](){let t=this._first;for(;t!==jt.Undefined;)yield t.element,t=t.next}},uB=globalThis.performance&&typeof globalThis.performance.now=="function",hB=class q4{static create(e){return new q4(e)}constructor(e){this._now=uB&&e===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime!==-1?this._stopTime-this._startTime:this._now()-this._startTime}},os;(t=>{t.None=()=>tt.None;function e(E,T){return u(E,()=>{},0,void 0,!0,void 0,T)}t.defer=e;function s(E){return(T,k=null,R)=>{let P=!1,D;return D=E(I=>{if(!P)return D?D.dispose():P=!0,T.call(k,I)},null,R),P&&D.dispose(),D}}t.once=s;function n(E,T,k){return d((R,P=null,D)=>E(I=>R.call(P,T(I)),null,D),k)}t.map=n;function i(E,T,k){return d((R,P=null,D)=>E(I=>{T(I),R.call(P,I)},null,D),k)}t.forEach=i;function o(E,T,k){return d((R,P=null,D)=>E(I=>T(I)&&R.call(P,I),null,D),k)}t.filter=o;function a(E){return E}t.signal=a;function l(...E){return(T,k=null,R)=>{let P=dB(...E.map(D=>D(I=>T.call(k,I))));return h(P,R)}}t.any=l;function c(E,T,k,R){let P=k;return n(E,D=>(P=T(P,D),P),R)}t.reduce=c;function d(E,T){let k,R={onWillAddFirstListener(){k=E(P.fire,P)},onDidRemoveLastListener(){k?.dispose()}},P=new Ce(R);return T?.add(P),P.event}function h(E,T){return T instanceof Array?T.push(E):T&&T.add(E),E}function u(E,T,k=100,R=!1,P=!1,D,I){let M,O,$,B=0,z,K={leakWarningThreshold:D,onWillAddFirstListener(){M=E(Y=>{B++,O=T(O,Y),R&&!$&&(G.fire(O),O=void 0),z=()=>{let U=O;O=void 0,$=void 0,(!R||B>1)&&G.fire(U),B=0},typeof k=="number"?(clearTimeout($),$=setTimeout(z,k)):$===void 0&&($=0,queueMicrotask(z))})},onWillRemoveListener(){P&&B>0&&z?.()},onDidRemoveLastListener(){z=void 0,M.dispose()}},G=new Ce(K);return I?.add(G),G.event}t.debounce=u;function f(E,T=0,k){return t.debounce(E,(R,P)=>R?(R.push(P),R):[P],T,void 0,!0,void 0,k)}t.accumulate=f;function m(E,T=(R,P)=>R===P,k){let R=!0,P;return o(E,D=>{let I=R||!T(D,P);return R=!1,P=D,I},k)}t.latch=m;function p(E,T,k){return[t.filter(E,T,k),t.filter(E,R=>!T(R),k)]}t.split=p;function g(E,T=!1,k=[],R){let P=k.slice(),D=E(O=>{P?P.push(O):M.fire(O)});R&&R.add(D);let I=()=>{P?.forEach(O=>M.fire(O)),P=null},M=new Ce({onWillAddFirstListener(){D||(D=E(O=>M.fire(O)),R&&R.add(D))},onDidAddFirstListener(){P&&(T?setTimeout(I):I())},onDidRemoveLastListener(){D&&D.dispose(),D=null}});return R&&R.add(M),M.event}t.buffer=g;function x(E,T){return(k,R,P)=>{let D=T(new b);return E(function(I){let M=D.evaluate(I);M!==v&&k.call(R,M)},void 0,P)}}t.chain=x;let v=Symbol("HaltChainable");class b{constructor(){this.steps=[]}map(T){return this.steps.push(T),this}forEach(T){return this.steps.push(k=>(T(k),k)),this}filter(T){return this.steps.push(k=>T(k)?k:v),this}reduce(T,k){let R=k;return this.steps.push(P=>(R=T(R,P),R)),this}latch(T=(k,R)=>k===R){let k=!0,R;return this.steps.push(P=>{let D=k||!T(P,R);return k=!1,R=P,D?P:v}),this}evaluate(T){for(let k of this.steps)if(T=k(T),T===v)break;return T}}function y(E,T,k=R=>R){let R=(...M)=>I.fire(k(...M)),P=()=>E.on(T,R),D=()=>E.removeListener(T,R),I=new Ce({onWillAddFirstListener:P,onDidRemoveLastListener:D});return I.event}t.fromNodeEventEmitter=y;function _(E,T,k=R=>R){let R=(...M)=>I.fire(k(...M)),P=()=>E.addEventListener(T,R),D=()=>E.removeEventListener(T,R),I=new Ce({onWillAddFirstListener:P,onDidRemoveLastListener:D});return I.event}t.fromDOMEventEmitter=_;function L(E){return new Promise(T=>s(E)(T))}t.toPromise=L;function w(E){let T=new Ce;return E.then(k=>{T.fire(k)},()=>{T.fire(void 0)}).finally(()=>{T.dispose()}),T.event}t.fromPromise=w;function j(E,T){return E(k=>T.fire(k))}t.forward=j;function S(E,T,k){return T(k),E(R=>T(R))}t.runAndSubscribe=S;class C{constructor(T,k){this._observable=T,this._counter=0,this._hasChanged=!1;let R={onWillAddFirstListener:()=>{T.addObserver(this)},onDidRemoveLastListener:()=>{T.removeObserver(this)}};this.emitter=new Ce(R),k&&k.add(this.emitter)}beginUpdate(T){this._counter++}handlePossibleChange(T){}handleChange(T,k){this._hasChanged=!0}endUpdate(T){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function N(E,T){return new C(E,T).emitter.event}t.fromObservable=N;function V(E){return(T,k,R)=>{let P=0,D=!1,I={beginUpdate(){P++},endUpdate(){P--,P===0&&(E.reportChanges(),D&&(D=!1,T.call(k)))},handlePossibleChange(){},handleChange(){D=!0}};E.addObserver(I),E.reportChanges();let M={dispose(){E.removeObserver(I)}};return R instanceof Jn?R.add(M):Array.isArray(R)&&R.push(M),M}}t.fromObservableLight=V})(os||={});var c0=class d0{constructor(e){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${e}_${d0._idPool++}`,d0.all.add(this)}start(e){this._stopWatch=new hB,this.listenerCount=e}stop(){if(this._stopWatch){let e=this._stopWatch.elapsed();this.durations.push(e),this.elapsedOverall+=e,this.invocationCount+=1,this._stopWatch=void 0}}};c0.all=new Set,c0._idPool=0;var fB=c0,mB=-1,G4=class Y4{constructor(e,s,n=(Y4._idPool++).toString(16).padStart(3,"0")){this._errorHandler=e,this.threshold=s,this.name=n,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(e,s){let n=this.threshold;if(n<=0||s<n)return;this._stacks||(this._stacks=new Map);let i=this._stacks.get(e.value)||0;if(this._stacks.set(e.value,i+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=n*.5;let[o,a]=this.getMostFrequentStack(),l=`[${this.name}] potential listener LEAK detected, having ${s} listeners already. MOST frequent listener (${a}):`;console.warn(l),console.warn(o);let c=new xB(l,o);this._errorHandler(c)}return()=>{let o=this._stacks.get(e.value)||0;this._stacks.set(e.value,o-1)}}getMostFrequentStack(){if(!this._stacks)return;let e,s=0;for(let[n,i]of this._stacks)(!e||s<i)&&(e=[n,i],s=i);return e}};G4._idPool=1;var pB=G4,gB=class J4{constructor(e){this.value=e}static create(){let e=new Error;return new J4(e.stack??"")}print(){console.warn(this.value.split(`
|
|
507
|
-
`).slice(2).join(`
|
|
508
|
-
`))}},xB=class extends Error{constructor(t,e){super(t),this.name="ListenerLeakError",this.stack=e}},vB=class extends Error{constructor(t,e){super(t),this.name="ListenerRefusalError",this.stack=e}},bB=0,md=class{constructor(t){this.value=t,this.id=bB++}},_B=2,yB,Ce=class{constructor(t){this._size=0,this._options=t,this._leakageMon=this._options?.leakWarningThreshold?new pB(t?.onListenerError??qa,this._options?.leakWarningThreshold??mB):void 0,this._perfMon=this._options?._profName?new fB(this._options._profName):void 0,this._deliveryQueue=this._options?.deliveryQueue}dispose(){this._disposed||(this._disposed=!0,this._deliveryQueue?.current===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),this._options?.onDidRemoveLastListener?.(),this._leakageMon?.dispose())}get event(){return this._event??=(t,e,s)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let a=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(a);let l=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],c=new vB(`${a}. HINT: Stack shows most frequent listener (${l[1]}-times)`,l[0]);return(this._options?.onListenerError||qa)(c),tt.None}if(this._disposed)return tt.None;e&&(t=t.bind(e));let n=new md(t),i;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(n.stack=gB.create(),i=this._leakageMon.check(n.stack,this._size+1)),this._listeners?this._listeners instanceof md?(this._deliveryQueue??=new LB,this._listeners=[this._listeners,n]):this._listeners.push(n):(this._options?.onWillAddFirstListener?.(this),this._listeners=n,this._options?.onDidAddFirstListener?.(this)),this._size++;let o=Lt(()=>{i?.(),this._removeListener(n)});return s instanceof Jn?s.add(o):Array.isArray(s)&&s.push(o),o},this._event}_removeListener(t){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(this._size===1){this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),this._size=0;return}let e=this._listeners,s=e.indexOf(t);if(s===-1)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),new Error("Attempted to dispose unknown listener");this._size--,e[s]=void 0;let n=this._deliveryQueue.current===this;if(this._size*_B<=e.length){let i=0;for(let o=0;o<e.length;o++)e[o]?e[i++]=e[o]:n&&(this._deliveryQueue.end--,i<this._deliveryQueue.i&&this._deliveryQueue.i--);e.length=i}}_deliver(t,e){if(!t)return;let s=this._options?.onListenerError||qa;if(!s){t.value(e);return}try{t.value(e)}catch(n){s(n)}}_deliverQueue(t){let e=t.current._listeners;for(;t.i<t.end;)this._deliver(e[t.i++],t.value);t.reset()}fire(t){if(this._deliveryQueue?.current&&(this._deliverQueue(this._deliveryQueue),this._perfMon?.stop()),this._perfMon?.start(this._size),this._listeners)if(this._listeners instanceof md)this._deliver(this._listeners,t);else{let e=this._deliveryQueue;e.enqueue(this,t,this._listeners.length),this._deliverQueue(e)}this._perfMon?.stop()}hasListeners(){return this._size>0}},LB=class{constructor(){this.i=-1,this.end=0}enqueue(t,e,s){this.i=0,this.end=s,this.current=t,this.value=e}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},u0=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new Ce,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new Ce,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(e){return this.mapWindowIdToZoomLevel.get(this.getWindowId(e))??0}setZoomLevel(e,s){if(this.getZoomLevel(s)===e)return;let n=this.getWindowId(s);this.mapWindowIdToZoomLevel.set(n,e),this._onDidChangeZoomLevel.fire(n)}getZoomFactor(e){return this.mapWindowIdToZoomFactor.get(this.getWindowId(e))??1}setZoomFactor(e,s){this.mapWindowIdToZoomFactor.set(this.getWindowId(s),e)}setFullscreen(e,s){if(this.isFullscreen(s)===e)return;let n=this.getWindowId(s);this.mapWindowIdToFullScreen.set(n,e),this._onDidChangeFullscreen.fire(n)}isFullscreen(e){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(e))}getWindowId(e){return e.vscodeWindowId}};u0.INSTANCE=new u0;var ku=u0;function SB(t,e,s){typeof e=="string"&&(e=t.matchMedia(e)),e.addEventListener("change",s)}ku.INSTANCE.onDidChangeZoomLevel;function wB(t){return ku.INSTANCE.getZoomFactor(t)}ku.INSTANCE.onDidChangeFullscreen;var Kr=typeof navigator=="object"?navigator.userAgent:"",h0=Kr.indexOf("Firefox")>=0,jB=Kr.indexOf("AppleWebKit")>=0,Vu=Kr.indexOf("Chrome")>=0,CB=!Vu&&Kr.indexOf("Safari")>=0;Kr.indexOf("Electron/")>=0;Kr.indexOf("Android")>=0;var pd=!1;if(typeof Tn.matchMedia=="function"){let t=Tn.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),e=Tn.matchMedia("(display-mode: fullscreen)");pd=t.matches,SB(Tn,t,({matches:s})=>{pd&&e.matches||(pd=s)})}var nr="en",f0=!1,m0=!1,Ga=!1,X4=!1,Da,Ya=nr,d1=nr,kB,kn,Si=globalThis,Is;typeof Si.vscode<"u"&&typeof Si.vscode.process<"u"?Is=Si.vscode.process:typeof process<"u"&&typeof process?.versions?.node=="string"&&(Is=process);var VB=typeof Is?.versions?.electron=="string",NB=VB&&Is?.type==="renderer";if(typeof Is=="object"){f0=Is.platform==="win32",m0=Is.platform==="darwin",Ga=Is.platform==="linux",Ga&&Is.env.SNAP&&Is.env.SNAP_REVISION,Is.env.CI||Is.env.BUILD_ARTIFACTSTAGINGDIRECTORY,Da=nr,Ya=nr;let t=Is.env.VSCODE_NLS_CONFIG;if(t)try{let e=JSON.parse(t);Da=e.userLocale,d1=e.osLocale,Ya=e.resolvedLanguage||nr,kB=e.languagePack?.translationsConfigFile}catch{}X4=!0}else typeof navigator=="object"&&!NB?(kn=navigator.userAgent,f0=kn.indexOf("Windows")>=0,m0=kn.indexOf("Macintosh")>=0,(kn.indexOf("Macintosh")>=0||kn.indexOf("iPad")>=0||kn.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,Ga=kn.indexOf("Linux")>=0,kn?.indexOf("Mobi")>=0,Ya=globalThis._VSCODE_NLS_LANGUAGE||nr,Da=navigator.language.toLowerCase(),d1=Da):console.error("Unable to resolve platform.");var Q4=f0,vn=m0,TB=Ga,u1=X4,Sn=kn,$n=Ya,AB;(t=>{function e(){return $n}t.value=e;function s(){return $n.length===2?$n==="en":$n.length>=3?$n[0]==="e"&&$n[1]==="n"&&$n[2]==="-":!1}t.isDefaultVariant=s;function n(){return $n==="en"}t.isDefault=n})(AB||={});var EB=typeof Si.postMessage=="function"&&!Si.importScripts;(()=>{if(EB){let t=[];Si.addEventListener("message",s=>{if(s.data&&s.data.vscodeScheduleAsyncWork)for(let n=0,i=t.length;n<i;n++){let o=t[n];if(o.id===s.data.vscodeScheduleAsyncWork){t.splice(n,1),o.callback();return}}});let e=0;return s=>{let n=++e;t.push({id:n,callback:s}),Si.postMessage({vscodeScheduleAsyncWork:n},"*")}}return t=>setTimeout(t)})();var PB=!!(Sn&&Sn.indexOf("Chrome")>=0);Sn&&Sn.indexOf("Firefox")>=0;!PB&&Sn&&Sn.indexOf("Safari")>=0;Sn&&Sn.indexOf("Edg/")>=0;Sn&&Sn.indexOf("Android")>=0;var Xi=typeof navigator=="object"?navigator:{};u1||document.queryCommandSupported&&document.queryCommandSupported("copy")||Xi&&Xi.clipboard&&Xi.clipboard.writeText,u1||Xi&&Xi.clipboard&&Xi.clipboard.readText;var Nu=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(t,e){this._keyCodeToStr[t]=e,this._strToKeyCode[e.toLowerCase()]=t}keyCodeToStr(t){return this._keyCodeToStr[t]}strToKeyCode(t){return this._strToKeyCode[t.toLowerCase()]||0}},gd=new Nu,h1=new Nu,f1=new Nu,RB=new Array(230),Z4;(t=>{function e(l){return gd.keyCodeToStr(l)}t.toString=e;function s(l){return gd.strToKeyCode(l)}t.fromString=s;function n(l){return h1.keyCodeToStr(l)}t.toUserSettingsUS=n;function i(l){return f1.keyCodeToStr(l)}t.toUserSettingsGeneral=i;function o(l){return h1.strToKeyCode(l)||f1.strToKeyCode(l)}t.fromUserSettings=o;function a(l){if(l>=98&&l<=113)return null;switch(l){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return gd.keyCodeToStr(l)}t.toElectronAccelerator=a})(Z4||={});var DB=class e5{constructor(e,s,n,i,o){this.ctrlKey=e,this.shiftKey=s,this.altKey=n,this.metaKey=i,this.keyCode=o}equals(e){return e instanceof e5&&this.ctrlKey===e.ctrlKey&&this.shiftKey===e.shiftKey&&this.altKey===e.altKey&&this.metaKey===e.metaKey&&this.keyCode===e.keyCode}getHashCode(){let e=this.ctrlKey?"1":"0",s=this.shiftKey?"1":"0",n=this.altKey?"1":"0",i=this.metaKey?"1":"0";return`K${e}${s}${n}${i}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new IB([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},IB=class{constructor(t){if(t.length===0)throw aB("chords");this.chords=t}getHashCode(){let t="";for(let e=0,s=this.chords.length;e<s;e++)e!==0&&(t+=";"),t+=this.chords[e].getHashCode();return t}equals(t){if(t===null||this.chords.length!==t.chords.length)return!1;for(let e=0;e<this.chords.length;e++)if(!this.chords[e].equals(t.chords[e]))return!1;return!0}};function MB(t){if(t.charCode){let s=String.fromCharCode(t.charCode).toUpperCase();return Z4.fromString(s)}let e=t.keyCode;if(e===3)return 7;if(h0)switch(e){case 59:return 85;case 60:if(TB)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(vn)return 57;break}else if(jB&&(vn&&e===93||!vn&&e===92))return 57;return RB[e]||0}var OB=vn?256:2048,BB=512,$B=1024,FB=vn?2048:256,m1=class{constructor(t){this._standardKeyboardEventBrand=!0;let e=t;this.browserEvent=e,this.target=e.target,this.ctrlKey=e.ctrlKey,this.shiftKey=e.shiftKey,this.altKey=e.altKey,this.metaKey=e.metaKey,this.altGraphKey=e.getModifierState?.("AltGraph"),this.keyCode=MB(e),this.code=e.code,this.ctrlKey=this.ctrlKey||this.keyCode===5,this.altKey=this.altKey||this.keyCode===6,this.shiftKey=this.shiftKey||this.keyCode===4,this.metaKey=this.metaKey||this.keyCode===57,this._asKeybinding=this._computeKeybinding(),this._asKeyCodeChord=this._computeKeyCodeChord()}preventDefault(){this.browserEvent&&this.browserEvent.preventDefault&&this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent&&this.browserEvent.stopPropagation&&this.browserEvent.stopPropagation()}toKeyCodeChord(){return this._asKeyCodeChord}equals(t){return this._asKeybinding===t}_computeKeybinding(){let t=0;this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(t=this.keyCode);let e=0;return this.ctrlKey&&(e|=OB),this.altKey&&(e|=BB),this.shiftKey&&(e|=$B),this.metaKey&&(e|=FB),e|=t,e}_computeKeyCodeChord(){let t=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(t=this.keyCode),new DB(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,t)}},p1=new WeakMap;function zB(t){if(!t.parent||t.parent===t)return null;try{let e=t.location,s=t.parent.location;if(e.origin!=="null"&&s.origin!=="null"&&e.origin!==s.origin)return null}catch{return null}return t.parent}var KB=class{static getSameOriginWindowChain(t){let e=p1.get(t);if(!e){e=[],p1.set(t,e);let s=t,n;do n=zB(s),n?e.push({window:new WeakRef(s),iframeElement:s.frameElement||null}):e.push({window:new WeakRef(s),iframeElement:null}),s=n;while(s)}return e.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(t,e){if(!e||t===e)return{top:0,left:0};let s=0,n=0,i=this.getSameOriginWindowChain(t);for(let o of i){let a=o.window.deref();if(s+=a?.scrollY??0,n+=a?.scrollX??0,a===e||!o.iframeElement)break;let l=o.iframeElement.getBoundingClientRect();s+=l.top,n+=l.left}return{top:s,left:n}}},Ia=class{constructor(t,e){this.timestamp=Date.now(),this.browserEvent=e,this.leftButton=e.button===0,this.middleButton=e.button===1,this.rightButton=e.button===2,this.buttons=e.buttons,this.target=e.target,this.detail=e.detail||1,e.type==="dblclick"&&(this.detail=2),this.ctrlKey=e.ctrlKey,this.shiftKey=e.shiftKey,this.altKey=e.altKey,this.metaKey=e.metaKey,typeof e.pageX=="number"?(this.posx=e.pageX,this.posy=e.pageY):(this.posx=e.clientX+this.target.ownerDocument.body.scrollLeft+this.target.ownerDocument.documentElement.scrollLeft,this.posy=e.clientY+this.target.ownerDocument.body.scrollTop+this.target.ownerDocument.documentElement.scrollTop);let s=KB.getPositionOfChildWindowRelativeToAncestorWindow(t,e.view);this.posx-=s.left,this.posy-=s.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},g1=class{constructor(t,e=0,s=0){this.browserEvent=t||null,this.target=t?t.target||t.targetNode||t.srcElement:null,this.deltaY=s,this.deltaX=e;let n=!1;if(Vu){let i=navigator.userAgent.match(/Chrome\/(\d+)/);n=(i?parseInt(i[1]):123)<=122}if(t){let i=t,o=t,a=t.view?.devicePixelRatio||1;if(typeof i.wheelDeltaY<"u")n?this.deltaY=i.wheelDeltaY/(120*a):this.deltaY=i.wheelDeltaY/120;else if(typeof o.VERTICAL_AXIS<"u"&&o.axis===o.VERTICAL_AXIS)this.deltaY=-o.detail/3;else if(t.type==="wheel"){let l=t;l.deltaMode===l.DOM_DELTA_LINE?h0&&!vn?this.deltaY=-t.deltaY/3:this.deltaY=-t.deltaY:this.deltaY=-t.deltaY/40}if(typeof i.wheelDeltaX<"u")CB&&Q4?this.deltaX=-(i.wheelDeltaX/120):n?this.deltaX=i.wheelDeltaX/(120*a):this.deltaX=i.wheelDeltaX/120;else if(typeof o.HORIZONTAL_AXIS<"u"&&o.axis===o.HORIZONTAL_AXIS)this.deltaX=-t.detail/3;else if(t.type==="wheel"){let l=t;l.deltaMode===l.DOM_DELTA_LINE?h0&&!vn?this.deltaX=-t.deltaX/3:this.deltaX=-t.deltaX:this.deltaX=-t.deltaX/40}this.deltaY===0&&this.deltaX===0&&t.wheelDelta&&(n?this.deltaY=t.wheelDelta/(120*a):this.deltaY=t.wheelDelta/120)}}preventDefault(){this.browserEvent?.preventDefault()}stopPropagation(){this.browserEvent?.stopPropagation()}},t5=Object.freeze(function(t,e){let s=setTimeout(t.bind(e),0);return{dispose(){clearTimeout(s)}}}),UB;(t=>{function e(s){return s===t.None||s===t.Cancelled||s instanceof HB?!0:!s||typeof s!="object"?!1:typeof s.isCancellationRequested=="boolean"&&typeof s.onCancellationRequested=="function"}t.isCancellationToken=e,t.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:os.None}),t.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:t5})})(UB||={});var HB=class{constructor(){this._isCancelled=!1,this._emitter=null}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?t5:(this._emitter||(this._emitter=new Ce),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},Tu=class{constructor(t,e){this._isDisposed=!1,this._token=-1,typeof t=="function"&&typeof e=="number"&&this.setIfNotSet(t,e)}dispose(){this.cancel(),this._isDisposed=!0}cancel(){this._token!==-1&&(clearTimeout(this._token),this._token=-1)}cancelAndSet(t,e){if(this._isDisposed)throw new o0("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,t()},e)}setIfNotSet(t,e){if(this._isDisposed)throw new o0("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,t()},e))}},WB=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){this.disposable?.dispose(),this.disposable=void 0}cancelAndSet(t,e,s=globalThis){if(this.isDisposed)throw new o0("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let n=s.setInterval(()=>{t()},e);this.disposable=Lt(()=>{s.clearInterval(n),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},qB;(t=>{async function e(n){let i,o=await Promise.all(n.map(a=>a.then(l=>l,l=>{i||(i=l)})));if(typeof i<"u")throw i;return o}t.settled=e;function s(n){return new Promise(async(i,o)=>{try{await n(i,o)}catch(a){o(a)}})}t.withAsyncBody=s})(qB||={});var x1=class Us{static fromArray(e){return new Us(s=>{s.emitMany(e)})}static fromPromise(e){return new Us(async s=>{s.emitMany(await e)})}static fromPromises(e){return new Us(async s=>{await Promise.all(e.map(async n=>s.emitOne(await n)))})}static merge(e){return new Us(async s=>{await Promise.all(e.map(async n=>{for await(let i of n)s.emitOne(i)}))})}constructor(e,s){this._state=0,this._results=[],this._error=null,this._onReturn=s,this._onStateChanged=new Ce,queueMicrotask(async()=>{let n={emitOne:i=>this.emitOne(i),emitMany:i=>this.emitMany(i),reject:i=>this.reject(i)};try{await Promise.resolve(e(n)),this.resolve()}catch(i){this.reject(i)}finally{n.emitOne=void 0,n.emitMany=void 0,n.reject=void 0}})}[Symbol.asyncIterator](){let e=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(e<this._results.length)return{done:!1,value:this._results[e++]};if(this._state===1)return{done:!0,value:void 0};await os.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(e,s){return new Us(async n=>{for await(let i of e)n.emitOne(s(i))})}map(e){return Us.map(this,e)}static filter(e,s){return new Us(async n=>{for await(let i of e)s(i)&&n.emitOne(i)})}filter(e){return Us.filter(this,e)}static coalesce(e){return Us.filter(e,s=>!!s)}coalesce(){return Us.coalesce(this)}static async toPromise(e){let s=[];for await(let n of e)s.push(n);return s}toPromise(){return Us.toPromise(this)}emitOne(e){this._state===0&&(this._results.push(e),this._onStateChanged.fire())}emitMany(e){this._state===0&&(this._results=this._results.concat(e),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(e){this._state===0&&(this._state=2,this._error=e,this._onStateChanged.fire())}};x1.EMPTY=x1.fromArray([]);var{getWindow:mn,getWindowId:GB,onDidRegisterWindow:YB}=(function(){let t=new Map,e={window:Tn,disposables:new Jn};t.set(Tn.vscodeWindowId,e);let s=new Ce,n=new Ce,i=new Ce;function o(a,l){return(typeof a=="number"?t.get(a):void 0)??(l?e:void 0)}return{onDidRegisterWindow:s.event,onWillUnregisterWindow:i.event,onDidUnregisterWindow:n.event,registerWindow(a){if(t.has(a.vscodeWindowId))return tt.None;let l=new Jn,c={window:a,disposables:l.add(new Jn)};return t.set(a.vscodeWindowId,c),l.add(Lt(()=>{t.delete(a.vscodeWindowId),n.fire(a)})),l.add(qe(a,Ht.BEFORE_UNLOAD,()=>{i.fire(a)})),s.fire(c),l},getWindows(){return t.values()},getWindowsCount(){return t.size},getWindowId(a){return a.vscodeWindowId},hasWindow(a){return t.has(a)},getWindowById:o,getWindow(a){let l=a;if(l?.ownerDocument?.defaultView)return l.ownerDocument.defaultView.window;let c=a;return c?.view?c.view.window:Tn},getDocument(a){return mn(a).document}}})(),JB=class{constructor(t,e,s,n){this._node=t,this._type=e,this._handler=s,this._options=n||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,this._handler=null)}};function qe(t,e,s,n){return new JB(t,e,s,n)}var v1=function(t,e,s,n){return qe(t,e,s,n)},Au,XB=class extends WB{constructor(t){super(),this.defaultTarget=t&&mn(t)}cancelAndSet(t,e,s){return super.cancelAndSet(t,e,s??this.defaultTarget)}},b1=class{constructor(t,e=0){this._runner=t,this.priority=e,this._canceled=!1}dispose(){this._canceled=!0}execute(){if(!this._canceled)try{this._runner()}catch(t){qa(t)}}static sort(t,e){return e.priority-t.priority}};(function(){let t=new Map,e=new Map,s=new Map,n=new Map,i=o=>{s.set(o,!1);let a=t.get(o)??[];for(e.set(o,a),t.set(o,[]),n.set(o,!0);a.length>0;)a.sort(b1.sort),a.shift().execute();n.set(o,!1)};Au=(o,a,l=0)=>{let c=GB(o),d=new b1(a,l),h=t.get(c);return h||(h=[],t.set(c,h)),h.push(d),s.get(c)||(s.set(c,!0),o.requestAnimationFrame(()=>i(c))),d}})();function QB(t){let e=t.getBoundingClientRect(),s=mn(t);return{left:e.left+s.scrollX,top:e.top+s.scrollY,width:e.width,height:e.height}}var Ht={CLICK:"click",MOUSE_DOWN:"mousedown",MOUSE_OVER:"mouseover",MOUSE_LEAVE:"mouseleave",MOUSE_WHEEL:"wheel",POINTER_UP:"pointerup",POINTER_DOWN:"pointerdown",POINTER_MOVE:"pointermove",KEY_DOWN:"keydown",KEY_UP:"keyup",BEFORE_UNLOAD:"beforeunload",CHANGE:"change",FOCUS:"focus",BLUR:"blur",INPUT:"input"},ZB=class{constructor(t){this.domNode=t,this._maxWidth="",this._width="",this._height="",this._top="",this._left="",this._bottom="",this._right="",this._paddingTop="",this._paddingLeft="",this._paddingBottom="",this._paddingRight="",this._fontFamily="",this._fontWeight="",this._fontSize="",this._fontStyle="",this._fontFeatureSettings="",this._fontVariationSettings="",this._textDecoration="",this._lineHeight="",this._letterSpacing="",this._className="",this._display="",this._position="",this._visibility="",this._color="",this._backgroundColor="",this._layerHint=!1,this._contain="none",this._boxShadow=""}setMaxWidth(t){let e=Cs(t);this._maxWidth!==e&&(this._maxWidth=e,this.domNode.style.maxWidth=this._maxWidth)}setWidth(t){let e=Cs(t);this._width!==e&&(this._width=e,this.domNode.style.width=this._width)}setHeight(t){let e=Cs(t);this._height!==e&&(this._height=e,this.domNode.style.height=this._height)}setTop(t){let e=Cs(t);this._top!==e&&(this._top=e,this.domNode.style.top=this._top)}setLeft(t){let e=Cs(t);this._left!==e&&(this._left=e,this.domNode.style.left=this._left)}setBottom(t){let e=Cs(t);this._bottom!==e&&(this._bottom=e,this.domNode.style.bottom=this._bottom)}setRight(t){let e=Cs(t);this._right!==e&&(this._right=e,this.domNode.style.right=this._right)}setPaddingTop(t){let e=Cs(t);this._paddingTop!==e&&(this._paddingTop=e,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(t){let e=Cs(t);this._paddingLeft!==e&&(this._paddingLeft=e,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(t){let e=Cs(t);this._paddingBottom!==e&&(this._paddingBottom=e,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(t){let e=Cs(t);this._paddingRight!==e&&(this._paddingRight=e,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(t){this._fontFamily!==t&&(this._fontFamily=t,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(t){this._fontWeight!==t&&(this._fontWeight=t,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(t){let e=Cs(t);this._fontSize!==e&&(this._fontSize=e,this.domNode.style.fontSize=this._fontSize)}setFontStyle(t){this._fontStyle!==t&&(this._fontStyle=t,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(t){this._fontFeatureSettings!==t&&(this._fontFeatureSettings=t,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(t){this._fontVariationSettings!==t&&(this._fontVariationSettings=t,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(t){this._textDecoration!==t&&(this._textDecoration=t,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(t){let e=Cs(t);this._lineHeight!==e&&(this._lineHeight=e,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(t){let e=Cs(t);this._letterSpacing!==e&&(this._letterSpacing=e,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(t){this._className!==t&&(this._className=t,this.domNode.className=this._className)}toggleClassName(t,e){this.domNode.classList.toggle(t,e),this._className=this.domNode.className}setDisplay(t){this._display!==t&&(this._display=t,this.domNode.style.display=this._display)}setPosition(t){this._position!==t&&(this._position=t,this.domNode.style.position=this._position)}setVisibility(t){this._visibility!==t&&(this._visibility=t,this.domNode.style.visibility=this._visibility)}setColor(t){this._color!==t&&(this._color=t,this.domNode.style.color=this._color)}setBackgroundColor(t){this._backgroundColor!==t&&(this._backgroundColor=t,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(t){this._layerHint!==t&&(this._layerHint=t,this.domNode.style.transform=this._layerHint?"translate3d(0px, 0px, 0px)":"")}setBoxShadow(t){this._boxShadow!==t&&(this._boxShadow=t,this.domNode.style.boxShadow=t)}setContain(t){this._contain!==t&&(this._contain=t,this.domNode.style.contain=this._contain)}setAttribute(t,e){this.domNode.setAttribute(t,e)}removeAttribute(t){this.domNode.removeAttribute(t)}appendChild(t){this.domNode.appendChild(t.domNode)}removeChild(t){this.domNode.removeChild(t.domNode)}};function Cs(t){return typeof t=="number"?`${t}px`:t}function Vo(t){return new ZB(t)}var s5=class{constructor(){this._hooks=new Jn,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(t,e){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let s=this._onStopCallback;this._onStopCallback=null,t&&s&&s(e)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(t,e,s,n,i){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=n,this._onStopCallback=i;let o=t;try{t.setPointerCapture(e),this._hooks.add(Lt(()=>{try{t.releasePointerCapture(e)}catch{}}))}catch{o=mn(t)}this._hooks.add(qe(o,Ht.POINTER_MOVE,a=>{if(a.buttons!==s){this.stopMonitoring(!0);return}a.preventDefault(),this._pointerMoveCallback(a)})),this._hooks.add(qe(o,Ht.POINTER_UP,a=>this.stopMonitoring(!0)))}};function e$(t,e,s){let n=null,i=null;if(typeof s.value=="function"?(n="value",i=s.value,i.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof s.get=="function"&&(n="get",i=s.get),!i)throw new Error("not supported");let o=`$memoize$${e}`;s[n]=function(...a){return this.hasOwnProperty(o)||Object.defineProperty(this,o,{configurable:!1,enumerable:!1,writable:!1,value:i.apply(this,a)}),this[o]}}var un;(t=>(t.Tap="-xterm-gesturetap",t.Change="-xterm-gesturechange",t.Start="-xterm-gesturestart",t.End="-xterm-gesturesend",t.Contextmenu="-xterm-gesturecontextmenu"))(un||={});var uo=class cs extends tt{constructor(){super(),this.dispatched=!1,this.targets=new c1,this.ignoreTargets=new c1,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(os.runAndSubscribe(YB,({window:e,disposables:s})=>{s.add(qe(e.document,"touchstart",n=>this.onTouchStart(n),{passive:!1})),s.add(qe(e.document,"touchend",n=>this.onTouchEnd(e,n))),s.add(qe(e.document,"touchmove",n=>this.onTouchMove(n),{passive:!1}))},{window:Tn,disposables:this._store}))}static addTarget(e){if(!cs.isTouchDevice())return tt.None;cs.INSTANCE||(cs.INSTANCE=new cs);let s=cs.INSTANCE.targets.push(e);return Lt(s)}static ignoreTarget(e){if(!cs.isTouchDevice())return tt.None;cs.INSTANCE||(cs.INSTANCE=new cs);let s=cs.INSTANCE.ignoreTargets.push(e);return Lt(s)}static isTouchDevice(){return"ontouchstart"in Tn||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(e){let s=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let n=0,i=e.targetTouches.length;n<i;n++){let o=e.targetTouches.item(n);this.activeTouches[o.identifier]={id:o.identifier,initialTarget:o.target,initialTimeStamp:s,initialPageX:o.pageX,initialPageY:o.pageY,rollingTimestamps:[s],rollingPageX:[o.pageX],rollingPageY:[o.pageY]};let a=this.newGestureEvent(un.Start,o.target);a.pageX=o.pageX,a.pageY=o.pageY,this.dispatchEvent(a)}this.dispatched&&(e.preventDefault(),e.stopPropagation(),this.dispatched=!1)}onTouchEnd(e,s){let n=Date.now(),i=Object.keys(this.activeTouches).length;for(let o=0,a=s.changedTouches.length;o<a;o++){let l=s.changedTouches.item(o);if(!this.activeTouches.hasOwnProperty(String(l.identifier))){console.warn("move of an UNKNOWN touch",l);continue}let c=this.activeTouches[l.identifier],d=Date.now()-c.initialTimeStamp;if(d<cs.HOLD_DELAY&&Math.abs(c.initialPageX-Rs(c.rollingPageX))<30&&Math.abs(c.initialPageY-Rs(c.rollingPageY))<30){let h=this.newGestureEvent(un.Tap,c.initialTarget);h.pageX=Rs(c.rollingPageX),h.pageY=Rs(c.rollingPageY),this.dispatchEvent(h)}else if(d>=cs.HOLD_DELAY&&Math.abs(c.initialPageX-Rs(c.rollingPageX))<30&&Math.abs(c.initialPageY-Rs(c.rollingPageY))<30){let h=this.newGestureEvent(un.Contextmenu,c.initialTarget);h.pageX=Rs(c.rollingPageX),h.pageY=Rs(c.rollingPageY),this.dispatchEvent(h)}else if(i===1){let h=Rs(c.rollingPageX),u=Rs(c.rollingPageY),f=Rs(c.rollingTimestamps)-c.rollingTimestamps[0],m=h-c.rollingPageX[0],p=u-c.rollingPageY[0],g=[...this.targets].filter(x=>c.initialTarget instanceof Node&&x.contains(c.initialTarget));this.inertia(e,g,n,Math.abs(m)/f,m>0?1:-1,h,Math.abs(p)/f,p>0?1:-1,u)}this.dispatchEvent(this.newGestureEvent(un.End,c.initialTarget)),delete this.activeTouches[l.identifier]}this.dispatched&&(s.preventDefault(),s.stopPropagation(),this.dispatched=!1)}newGestureEvent(e,s){let n=document.createEvent("CustomEvent");return n.initEvent(e,!1,!0),n.initialTarget=s,n.tapCount=0,n}dispatchEvent(e){if(e.type===un.Tap){let s=new Date().getTime(),n=0;s-this._lastSetTapCountTime>cs.CLEAR_TAP_COUNT_TIME?n=1:n=2,this._lastSetTapCountTime=s,e.tapCount=n}else(e.type===un.Change||e.type===un.Contextmenu)&&(this._lastSetTapCountTime=0);if(e.initialTarget instanceof Node){for(let n of this.ignoreTargets)if(n.contains(e.initialTarget))return;let s=[];for(let n of this.targets)if(n.contains(e.initialTarget)){let i=0,o=e.initialTarget;for(;o&&o!==n;)i++,o=o.parentElement;s.push([i,n])}s.sort((n,i)=>n[0]-i[0]);for(let[n,i]of s)i.dispatchEvent(e),this.dispatched=!0}}inertia(e,s,n,i,o,a,l,c,d){this.handle=Au(e,()=>{let h=Date.now(),u=h-n,f=0,m=0,p=!0;i+=cs.SCROLL_FRICTION*u,l+=cs.SCROLL_FRICTION*u,i>0&&(p=!1,f=o*i*u),l>0&&(p=!1,m=c*l*u);let g=this.newGestureEvent(un.Change);g.translationX=f,g.translationY=m,s.forEach(x=>x.dispatchEvent(g)),p||this.inertia(e,s,h,i,o,a+f,l,c,d+m)})}onTouchMove(e){let s=Date.now();for(let n=0,i=e.changedTouches.length;n<i;n++){let o=e.changedTouches.item(n);if(!this.activeTouches.hasOwnProperty(String(o.identifier))){console.warn("end of an UNKNOWN touch",o);continue}let a=this.activeTouches[o.identifier],l=this.newGestureEvent(un.Change,a.initialTarget);l.translationX=o.pageX-Rs(a.rollingPageX),l.translationY=o.pageY-Rs(a.rollingPageY),l.pageX=o.pageX,l.pageY=o.pageY,this.dispatchEvent(l),a.rollingPageX.length>3&&(a.rollingPageX.shift(),a.rollingPageY.shift(),a.rollingTimestamps.shift()),a.rollingPageX.push(o.pageX),a.rollingPageY.push(o.pageY),a.rollingTimestamps.push(s)}this.dispatched&&(e.preventDefault(),e.stopPropagation(),this.dispatched=!1)}};uo.SCROLL_FRICTION=-.005,uo.HOLD_DELAY=700,uo.CLEAR_TAP_COUNT_TIME=400,At([e$],uo,"isTouchDevice",1);var t$=uo,Eu=class extends tt{onclick(t,e){this._register(qe(t,Ht.CLICK,s=>e(new Ia(mn(t),s))))}onmousedown(t,e){this._register(qe(t,Ht.MOUSE_DOWN,s=>e(new Ia(mn(t),s))))}onmouseover(t,e){this._register(qe(t,Ht.MOUSE_OVER,s=>e(new Ia(mn(t),s))))}onmouseleave(t,e){this._register(qe(t,Ht.MOUSE_LEAVE,s=>e(new Ia(mn(t),s))))}onkeydown(t,e){this._register(qe(t,Ht.KEY_DOWN,s=>e(new m1(s))))}onkeyup(t,e){this._register(qe(t,Ht.KEY_UP,s=>e(new m1(s))))}oninput(t,e){this._register(qe(t,Ht.INPUT,e))}onblur(t,e){this._register(qe(t,Ht.BLUR,e))}onfocus(t,e){this._register(qe(t,Ht.FOCUS,e))}onchange(t,e){this._register(qe(t,Ht.CHANGE,e))}ignoreGesture(t){return t$.ignoreTarget(t)}},_1=11,s$=class extends Eu{constructor(t){super(),this._onActivate=t.onActivate,this.bgDomNode=document.createElement("div"),this.bgDomNode.className="arrow-background",this.bgDomNode.style.position="absolute",this.bgDomNode.style.width=t.bgWidth+"px",this.bgDomNode.style.height=t.bgHeight+"px",typeof t.top<"u"&&(this.bgDomNode.style.top="0px"),typeof t.left<"u"&&(this.bgDomNode.style.left="0px"),typeof t.bottom<"u"&&(this.bgDomNode.style.bottom="0px"),typeof t.right<"u"&&(this.bgDomNode.style.right="0px"),this.domNode=document.createElement("div"),this.domNode.className=t.className,this.domNode.style.position="absolute",this.domNode.style.width=_1+"px",this.domNode.style.height=_1+"px",typeof t.top<"u"&&(this.domNode.style.top=t.top+"px"),typeof t.left<"u"&&(this.domNode.style.left=t.left+"px"),typeof t.bottom<"u"&&(this.domNode.style.bottom=t.bottom+"px"),typeof t.right<"u"&&(this.domNode.style.right=t.right+"px"),this._pointerMoveMonitor=this._register(new s5),this._register(v1(this.bgDomNode,Ht.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._register(v1(this.domNode,Ht.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._pointerdownRepeatTimer=this._register(new XB),this._pointerdownScheduleRepeatTimer=this._register(new Tu)}_arrowPointerDown(t){if(!t.target||!(t.target instanceof Element))return;let e=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,mn(t))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(e,200),this._pointerMoveMonitor.startMonitoring(t.target,t.pointerId,t.buttons,s=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),t.preventDefault()}},n$=class p0{constructor(e,s,n,i,o,a,l){this._forceIntegerValues=e,this._scrollStateBrand=void 0,this._forceIntegerValues&&(s=s|0,n=n|0,i=i|0,o=o|0,a=a|0,l=l|0),this.rawScrollLeft=i,this.rawScrollTop=l,s<0&&(s=0),i+s>n&&(i=n-s),i<0&&(i=0),o<0&&(o=0),l+o>a&&(l=a-o),l<0&&(l=0),this.width=s,this.scrollWidth=n,this.scrollLeft=i,this.height=o,this.scrollHeight=a,this.scrollTop=l}equals(e){return this.rawScrollLeft===e.rawScrollLeft&&this.rawScrollTop===e.rawScrollTop&&this.width===e.width&&this.scrollWidth===e.scrollWidth&&this.scrollLeft===e.scrollLeft&&this.height===e.height&&this.scrollHeight===e.scrollHeight&&this.scrollTop===e.scrollTop}withScrollDimensions(e,s){return new p0(this._forceIntegerValues,typeof e.width<"u"?e.width:this.width,typeof e.scrollWidth<"u"?e.scrollWidth:this.scrollWidth,s?this.rawScrollLeft:this.scrollLeft,typeof e.height<"u"?e.height:this.height,typeof e.scrollHeight<"u"?e.scrollHeight:this.scrollHeight,s?this.rawScrollTop:this.scrollTop)}withScrollPosition(e){return new p0(this._forceIntegerValues,this.width,this.scrollWidth,typeof e.scrollLeft<"u"?e.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof e.scrollTop<"u"?e.scrollTop:this.rawScrollTop)}createScrollEvent(e,s){let n=this.width!==e.width,i=this.scrollWidth!==e.scrollWidth,o=this.scrollLeft!==e.scrollLeft,a=this.height!==e.height,l=this.scrollHeight!==e.scrollHeight,c=this.scrollTop!==e.scrollTop;return{inSmoothScrolling:s,oldWidth:e.width,oldScrollWidth:e.scrollWidth,oldScrollLeft:e.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:e.height,oldScrollHeight:e.scrollHeight,oldScrollTop:e.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:n,scrollWidthChanged:i,scrollLeftChanged:o,heightChanged:a,scrollHeightChanged:l,scrollTopChanged:c}}},i$=class extends tt{constructor(t){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new Ce),this.onScroll=this._onScroll.event,this._smoothScrollDuration=t.smoothScrollDuration,this._scheduleAtNextAnimationFrame=t.scheduleAtNextAnimationFrame,this._state=new n$(t.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),super.dispose()}setSmoothScrollDuration(t){this._smoothScrollDuration=t}validateScrollPosition(t){return this._state.withScrollPosition(t)}getScrollDimensions(){return this._state}setScrollDimensions(t,e){let s=this._state.withScrollDimensions(t,e);this._setState(s,!!this._smoothScrolling),this._smoothScrolling?.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(t){let e=this._state.withScrollPosition(t);this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),this._setState(e,!1)}setScrollPositionSmooth(t,e){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(t);if(this._smoothScrolling){t={scrollLeft:typeof t.scrollLeft>"u"?this._smoothScrolling.to.scrollLeft:t.scrollLeft,scrollTop:typeof t.scrollTop>"u"?this._smoothScrolling.to.scrollTop:t.scrollTop};let s=this._state.withScrollPosition(t);if(this._smoothScrolling.to.scrollLeft===s.scrollLeft&&this._smoothScrolling.to.scrollTop===s.scrollTop)return;let n;e?n=new L1(this._smoothScrolling.from,s,this._smoothScrolling.startTime,this._smoothScrolling.duration):n=this._smoothScrolling.combine(this._state,s,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=n}else{let s=this._state.withScrollPosition(t);this._smoothScrolling=L1.start(this._state,s,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let t=this._smoothScrolling.tick(),e=this._state.withScrollPosition(t);if(this._setState(e,!0),!!this._smoothScrolling){if(t.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(t,e){let s=this._state;s.equals(t)||(this._state=t,this._onScroll.fire(this._state.createScrollEvent(s,e)))}},y1=class{constructor(t,e,s){this.scrollLeft=t,this.scrollTop=e,this.isDone=s}};function xd(t,e){let s=e-t;return function(n){return t+s*a$(n)}}function r$(t,e,s){return function(n){return n<s?t(n/s):e((n-s)/(1-s))}}var L1=class g0{constructor(e,s,n,i){this.from=e,this.to=s,this.duration=i,this.startTime=n,this.animationFrameDisposable=null,this._initAnimations()}_initAnimations(){this.scrollLeft=this._initAnimation(this.from.scrollLeft,this.to.scrollLeft,this.to.width),this.scrollTop=this._initAnimation(this.from.scrollTop,this.to.scrollTop,this.to.height)}_initAnimation(e,s,n){if(Math.abs(e-s)>2.5*n){let i,o;return e<s?(i=e+.75*n,o=s-.75*n):(i=e-.75*n,o=s+.75*n),r$(xd(e,i),xd(o,s),.33)}return xd(e,s)}dispose(){this.animationFrameDisposable!==null&&(this.animationFrameDisposable.dispose(),this.animationFrameDisposable=null)}acceptScrollDimensions(e){this.to=e.withScrollPosition(this.to),this._initAnimations()}tick(){return this._tick(Date.now())}_tick(e){let s=(e-this.startTime)/this.duration;if(s<1){let n=this.scrollLeft(s),i=this.scrollTop(s);return new y1(n,i,!1)}return new y1(this.to.scrollLeft,this.to.scrollTop,!0)}combine(e,s,n){return g0.start(e,s,n)}static start(e,s,n){n=n+10;let i=Date.now()-10;return new g0(e,s,i,n)}};function o$(t){return Math.pow(t,3)}function a$(t){return 1-o$(1-t)}var l$=class extends tt{constructor(t,e,s){super(),this._visibility=t,this._visibleClassName=e,this._invisibleClassName=s,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new Tu)}setVisibility(t){this._visibility!==t&&(this._visibility=t,this._updateShouldBeVisible())}setShouldBeVisible(t){this._rawShouldBeVisible=t,this._updateShouldBeVisible()}_applyVisibilitySetting(){return this._visibility===2?!1:this._visibility===3?!0:this._rawShouldBeVisible}_updateShouldBeVisible(){let t=this._applyVisibilitySetting();this._shouldBeVisible!==t&&(this._shouldBeVisible=t,this.ensureVisibility())}setIsNeeded(t){this._isNeeded!==t&&(this._isNeeded=t,this.ensureVisibility())}setDomNode(t){this._domNode=t,this._domNode.setClassName(this._invisibleClassName),this.setShouldBeVisible(!1)}ensureVisibility(){if(!this._isNeeded){this._hide(!1);return}this._shouldBeVisible?this._reveal():this._hide(!0)}_reveal(){this._isVisible||(this._isVisible=!0,this._revealTimer.setIfNotSet(()=>{this._domNode?.setClassName(this._visibleClassName)},0))}_hide(t){this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,this._domNode?.setClassName(this._invisibleClassName+(t?" fade":"")))}},c$=140,n5=class extends Eu{constructor(t){super(),this._lazyRender=t.lazyRender,this._host=t.host,this._scrollable=t.scrollable,this._scrollByPage=t.scrollByPage,this._scrollbarState=t.scrollbarState,this._visibilityController=this._register(new l$(t.visibility,"visible scrollbar "+t.extraScrollbarClassName,"invisible scrollbar "+t.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new s5),this._shouldRender=!0,this.domNode=Vo(document.createElement("div")),this.domNode.setAttribute("role","presentation"),this.domNode.setAttribute("aria-hidden","true"),this._visibilityController.setDomNode(this.domNode),this.domNode.setPosition("absolute"),this._register(qe(this.domNode.domNode,Ht.POINTER_DOWN,e=>this._domNodePointerDown(e)))}_createArrow(t){let e=this._register(new s$(t));this.domNode.domNode.appendChild(e.bgDomNode),this.domNode.domNode.appendChild(e.domNode)}_createSlider(t,e,s,n){this.slider=Vo(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(t),this.slider.setLeft(e),typeof s=="number"&&this.slider.setWidth(s),typeof n=="number"&&this.slider.setHeight(n),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(qe(this.slider.domNode,Ht.POINTER_DOWN,i=>{i.button===0&&(i.preventDefault(),this._sliderPointerDown(i))})),this.onclick(this.slider.domNode,i=>{i.leftButton&&i.stopPropagation()})}_onElementSize(t){return this._scrollbarState.setVisibleSize(t)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(t){return this._scrollbarState.setScrollSize(t)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(t){return this._scrollbarState.setScrollPosition(t)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(t){t.target===this.domNode.domNode&&this._onPointerDown(t)}delegatePointerDown(t){let e=this.domNode.domNode.getClientRects()[0].top,s=e+this._scrollbarState.getSliderPosition(),n=e+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),i=this._sliderPointerPosition(t);s<=i&&i<=n?t.button===0&&(t.preventDefault(),this._sliderPointerDown(t)):this._onPointerDown(t)}_onPointerDown(t){let e,s;if(t.target===this.domNode.domNode&&typeof t.offsetX=="number"&&typeof t.offsetY=="number")e=t.offsetX,s=t.offsetY;else{let i=QB(this.domNode.domNode);e=t.pageX-i.left,s=t.pageY-i.top}let n=this._pointerDownRelativePosition(e,s);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(n):this._scrollbarState.getDesiredScrollPositionFromOffset(n)),t.button===0&&(t.preventDefault(),this._sliderPointerDown(t))}_sliderPointerDown(t){if(!t.target||!(t.target instanceof Element))return;let e=this._sliderPointerPosition(t),s=this._sliderOrthogonalPointerPosition(t),n=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(t.target,t.pointerId,t.buttons,i=>{let o=this._sliderOrthogonalPointerPosition(i),a=Math.abs(o-s);if(Q4&&a>c$){this._setDesiredScrollPositionNow(n.getScrollPosition());return}let l=this._sliderPointerPosition(i)-e;this._setDesiredScrollPositionNow(n.getDesiredScrollPositionFromDelta(l))},()=>{this.slider.toggleClassName("active",!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(t){let e={};this.writeScrollPosition(e,t),this._scrollable.setScrollPositionNow(e)}updateScrollbarSize(t){this._updateScrollbarSize(t),this._scrollbarState.setScrollbarSize(t),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},i5=class x0{constructor(e,s,n,i,o,a){this._scrollbarSize=Math.round(s),this._oppositeScrollbarSize=Math.round(n),this._arrowSize=Math.round(e),this._visibleSize=i,this._scrollSize=o,this._scrollPosition=a,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new x0(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(e){let s=Math.round(e);return this._visibleSize!==s?(this._visibleSize=s,this._refreshComputedValues(),!0):!1}setScrollSize(e){let s=Math.round(e);return this._scrollSize!==s?(this._scrollSize=s,this._refreshComputedValues(),!0):!1}setScrollPosition(e){let s=Math.round(e);return this._scrollPosition!==s?(this._scrollPosition=s,this._refreshComputedValues(),!0):!1}setScrollbarSize(e){this._scrollbarSize=Math.round(e)}setOppositeScrollbarSize(e){this._oppositeScrollbarSize=Math.round(e)}static _computeValues(e,s,n,i,o){let a=Math.max(0,n-e),l=Math.max(0,a-2*s),c=i>0&&i>n;if(!c)return{computedAvailableSize:Math.round(a),computedIsNeeded:c,computedSliderSize:Math.round(l),computedSliderRatio:0,computedSliderPosition:0};let d=Math.round(Math.max(20,Math.floor(n*l/i))),h=(l-d)/(i-n),u=o*h;return{computedAvailableSize:Math.round(a),computedIsNeeded:c,computedSliderSize:Math.round(d),computedSliderRatio:h,computedSliderPosition:Math.round(u)}}_refreshComputedValues(){let e=x0._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=e.computedAvailableSize,this._computedIsNeeded=e.computedIsNeeded,this._computedSliderSize=e.computedSliderSize,this._computedSliderRatio=e.computedSliderRatio,this._computedSliderPosition=e.computedSliderPosition}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(e){if(!this._computedIsNeeded)return 0;let s=e-this._arrowSize-this._computedSliderSize/2;return Math.round(s/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(e){if(!this._computedIsNeeded)return 0;let s=e-this._arrowSize,n=this._scrollPosition;return s<this._computedSliderPosition?n-=this._visibleSize:n+=this._visibleSize,n}getDesiredScrollPositionFromDelta(e){if(!this._computedIsNeeded)return 0;let s=this._computedSliderPosition+e;return Math.round(s/this._computedSliderRatio)}},d$=class extends n5{constructor(t,e,s){let n=t.getScrollDimensions(),i=t.getCurrentScrollPosition();if(super({lazyRender:e.lazyRender,host:s,scrollbarState:new i5(e.horizontalHasArrows?e.arrowSize:0,e.horizontal===2?0:e.horizontalScrollbarSize,e.vertical===2?0:e.verticalScrollbarSize,n.width,n.scrollWidth,i.scrollLeft),visibility:e.horizontal,extraScrollbarClassName:"horizontal",scrollable:t,scrollByPage:e.scrollByPage}),e.horizontalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(Math.floor((e.horizontalScrollbarSize-e.horizontalSliderSize)/2),0,void 0,e.horizontalSliderSize)}_updateSlider(t,e){this.slider.setWidth(t),this.slider.setLeft(e)}_renderDomNode(t,e){this.domNode.setWidth(t),this.domNode.setHeight(e),this.domNode.setLeft(0),this.domNode.setBottom(0)}onDidScroll(t){return this._shouldRender=this._onElementScrollSize(t.scrollWidth)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(t.scrollLeft)||this._shouldRender,this._shouldRender=this._onElementSize(t.width)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(t,e){return t}_sliderPointerPosition(t){return t.pageX}_sliderOrthogonalPointerPosition(t){return t.pageY}_updateScrollbarSize(t){this.slider.setHeight(t)}writeScrollPosition(t,e){t.scrollLeft=e}updateOptions(t){this.updateScrollbarSize(t.horizontal===2?0:t.horizontalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(t.vertical===2?0:t.verticalScrollbarSize),this._visibilityController.setVisibility(t.horizontal),this._scrollByPage=t.scrollByPage}},u$=class extends n5{constructor(t,e,s){let n=t.getScrollDimensions(),i=t.getCurrentScrollPosition();if(super({lazyRender:e.lazyRender,host:s,scrollbarState:new i5(e.verticalHasArrows?e.arrowSize:0,e.vertical===2?0:e.verticalScrollbarSize,0,n.height,n.scrollHeight,i.scrollTop),visibility:e.vertical,extraScrollbarClassName:"vertical",scrollable:t,scrollByPage:e.scrollByPage}),e.verticalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(0,Math.floor((e.verticalScrollbarSize-e.verticalSliderSize)/2),e.verticalSliderSize,void 0)}_updateSlider(t,e){this.slider.setHeight(t),this.slider.setTop(e)}_renderDomNode(t,e){this.domNode.setWidth(e),this.domNode.setHeight(t),this.domNode.setRight(0),this.domNode.setTop(0)}onDidScroll(t){return this._shouldRender=this._onElementScrollSize(t.scrollHeight)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(t.scrollTop)||this._shouldRender,this._shouldRender=this._onElementSize(t.height)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(t,e){return e}_sliderPointerPosition(t){return t.pageY}_sliderOrthogonalPointerPosition(t){return t.pageX}_updateScrollbarSize(t){this.slider.setWidth(t)}writeScrollPosition(t,e){t.scrollTop=e}updateOptions(t){this.updateScrollbarSize(t.vertical===2?0:t.verticalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(0),this._visibilityController.setVisibility(t.vertical),this._scrollByPage=t.scrollByPage}},h$=500,S1=50,f$=class{constructor(t,e,s){this.timestamp=t,this.deltaX=e,this.deltaY=s,this.score=0}},v0=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(this._front===-1&&this._rear===-1)return!1;let e=1,s=0,n=1,i=this._rear;do{let o=i===this._front?e:Math.pow(2,-n);if(e-=o,s+=this._memory[i].score*o,i===this._front)break;i=(this._capacity+i-1)%this._capacity,n++}while(!0);return s<=.5}acceptStandardWheelEvent(e){if(Vu){let s=mn(e.browserEvent),n=wB(s);this.accept(Date.now(),e.deltaX*n,e.deltaY*n)}else this.accept(Date.now(),e.deltaX,e.deltaY)}accept(e,s,n){let i=null,o=new f$(e,s,n);this._front===-1&&this._rear===-1?(this._memory[0]=o,this._front=0,this._rear=0):(i=this._memory[this._rear],this._rear=(this._rear+1)%this._capacity,this._rear===this._front&&(this._front=(this._front+1)%this._capacity),this._memory[this._rear]=o),o.score=this._computeScore(o,i)}_computeScore(e,s){if(Math.abs(e.deltaX)>0&&Math.abs(e.deltaY)>0)return 1;let n=.5;if((!this._isAlmostInt(e.deltaX)||!this._isAlmostInt(e.deltaY))&&(n+=.25),s){let i=Math.abs(e.deltaX),o=Math.abs(e.deltaY),a=Math.abs(s.deltaX),l=Math.abs(s.deltaY),c=Math.max(Math.min(i,a),1),d=Math.max(Math.min(o,l),1),h=Math.max(i,a),u=Math.max(o,l);h%c===0&&u%d===0&&(n-=.5)}return Math.min(Math.max(n,0),1)}_isAlmostInt(e){return Math.abs(Math.round(e)-e)<.01}};v0.INSTANCE=new v0;var m$=v0,p$=class extends Eu{constructor(t,e,s){super(),this._onScroll=this._register(new Ce),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new Ce),this.onWillScroll=this._onWillScroll.event,this._options=x$(e),this._scrollable=s,this._register(this._scrollable.onScroll(i=>{this._onWillScroll.fire(i),this._onDidScroll(i),this._onScroll.fire(i)}));let n={onMouseWheel:i=>this._onMouseWheel(i),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new u$(this._scrollable,this._options,n)),this._horizontalScrollbar=this._register(new d$(this._scrollable,this._options,n)),this._domNode=document.createElement("div"),this._domNode.className="xterm-scrollable-element "+this._options.className,this._domNode.setAttribute("role","presentation"),this._domNode.style.position="relative",this._domNode.appendChild(t),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=Vo(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=Vo(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=Vo(document.createElement("div")),this._topLeftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topLeftShadowDomNode.domNode)):(this._leftShadowDomNode=null,this._topShadowDomNode=null,this._topLeftShadowDomNode=null),this._listenOnDomNode=this._options.listenOnDomNode||this._domNode,this._mouseWheelToDispose=[],this._setListeningToMouseWheel(this._options.handleMouseWheel),this.onmouseover(this._listenOnDomNode,i=>this._onMouseOver(i)),this.onmouseleave(this._listenOnDomNode,i=>this._onMouseLeave(i)),this._hideTimeout=this._register(new Tu),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=Pi(this._mouseWheelToDispose),super.dispose()}getDomNode(){return this._domNode}getOverviewRulerLayoutInfo(){return{parent:this._domNode,insertBefore:this._verticalScrollbar.domNode.domNode}}delegateVerticalScrollbarPointerDown(t){this._verticalScrollbar.delegatePointerDown(t)}getScrollDimensions(){return this._scrollable.getScrollDimensions()}setScrollDimensions(t){this._scrollable.setScrollDimensions(t,!1)}updateClassName(t){this._options.className=t,vn&&(this._options.className+=" mac"),this._domNode.className="xterm-scrollable-element "+this._options.className}updateOptions(t){typeof t.handleMouseWheel<"u"&&(this._options.handleMouseWheel=t.handleMouseWheel,this._setListeningToMouseWheel(this._options.handleMouseWheel)),typeof t.mouseWheelScrollSensitivity<"u"&&(this._options.mouseWheelScrollSensitivity=t.mouseWheelScrollSensitivity),typeof t.fastScrollSensitivity<"u"&&(this._options.fastScrollSensitivity=t.fastScrollSensitivity),typeof t.scrollPredominantAxis<"u"&&(this._options.scrollPredominantAxis=t.scrollPredominantAxis),typeof t.horizontal<"u"&&(this._options.horizontal=t.horizontal),typeof t.vertical<"u"&&(this._options.vertical=t.vertical),typeof t.horizontalScrollbarSize<"u"&&(this._options.horizontalScrollbarSize=t.horizontalScrollbarSize),typeof t.verticalScrollbarSize<"u"&&(this._options.verticalScrollbarSize=t.verticalScrollbarSize),typeof t.scrollByPage<"u"&&(this._options.scrollByPage=t.scrollByPage),this._horizontalScrollbar.updateOptions(this._options),this._verticalScrollbar.updateOptions(this._options),this._options.lazyRender||this._render()}setRevealOnScroll(t){this._revealOnScroll=t}delegateScrollFromMouseWheelEvent(t){this._onMouseWheel(new g1(t))}_setListeningToMouseWheel(t){if(this._mouseWheelToDispose.length>0!==t&&(this._mouseWheelToDispose=Pi(this._mouseWheelToDispose),t)){let e=s=>{this._onMouseWheel(new g1(s))};this._mouseWheelToDispose.push(qe(this._listenOnDomNode,Ht.MOUSE_WHEEL,e,{passive:!1}))}}_onMouseWheel(t){if(t.browserEvent?.defaultPrevented)return;let e=m$.INSTANCE;e.acceptStandardWheelEvent(t);let s=!1;if(t.deltaY||t.deltaX){let i=t.deltaY*this._options.mouseWheelScrollSensitivity,o=t.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&o+i===0?o=i=0:Math.abs(i)>=Math.abs(o)?o=0:i=0),this._options.flipAxes&&([i,o]=[o,i]);let a=!vn&&t.browserEvent&&t.browserEvent.shiftKey;(this._options.scrollYToX||a)&&!o&&(o=i,i=0),t.browserEvent&&t.browserEvent.altKey&&(o=o*this._options.fastScrollSensitivity,i=i*this._options.fastScrollSensitivity);let l=this._scrollable.getFutureScrollPosition(),c={};if(i){let d=S1*i,h=l.scrollTop-(d<0?Math.floor(d):Math.ceil(d));this._verticalScrollbar.writeScrollPosition(c,h)}if(o){let d=S1*o,h=l.scrollLeft-(d<0?Math.floor(d):Math.ceil(d));this._horizontalScrollbar.writeScrollPosition(c,h)}c=this._scrollable.validateScrollPosition(c),(l.scrollLeft!==c.scrollLeft||l.scrollTop!==c.scrollTop)&&(this._options.mouseWheelSmoothScroll&&e.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(c):this._scrollable.setScrollPositionNow(c),s=!0)}let n=s;!n&&this._options.alwaysConsumeMouseWheel&&(n=!0),!n&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(n=!0),n&&(t.preventDefault(),t.stopPropagation())}_onDidScroll(t){this._shouldRender=this._horizontalScrollbar.onDidScroll(t)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(t)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw new Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let t=this._scrollable.getCurrentScrollPosition(),e=t.scrollTop>0,s=t.scrollLeft>0,n=s?" left":"",i=e?" top":"",o=s||e?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${n}`),this._topShadowDomNode.setClassName(`shadow${i}`),this._topLeftShadowDomNode.setClassName(`shadow${o}${i}${n}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(t){this._mouseIsOver=!1,this._hide()}_onMouseOver(t){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){!this._mouseIsOver&&!this._isDragging&&(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){!this._mouseIsOver&&!this._isDragging&&this._hideTimeout.cancelAndSet(()=>this._hide(),h$)}},g$=class extends p${constructor(t,e,s){super(t,e,s)}setScrollPosition(t){t.reuseAnimation?this._scrollable.setScrollPositionSmooth(t,t.reuseAnimation):this._scrollable.setScrollPositionNow(t)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function x$(t){let e={lazyRender:typeof t.lazyRender<"u"?t.lazyRender:!1,className:typeof t.className<"u"?t.className:"",useShadows:typeof t.useShadows<"u"?t.useShadows:!0,handleMouseWheel:typeof t.handleMouseWheel<"u"?t.handleMouseWheel:!0,flipAxes:typeof t.flipAxes<"u"?t.flipAxes:!1,consumeMouseWheelIfScrollbarIsNeeded:typeof t.consumeMouseWheelIfScrollbarIsNeeded<"u"?t.consumeMouseWheelIfScrollbarIsNeeded:!1,alwaysConsumeMouseWheel:typeof t.alwaysConsumeMouseWheel<"u"?t.alwaysConsumeMouseWheel:!1,scrollYToX:typeof t.scrollYToX<"u"?t.scrollYToX:!1,mouseWheelScrollSensitivity:typeof t.mouseWheelScrollSensitivity<"u"?t.mouseWheelScrollSensitivity:1,fastScrollSensitivity:typeof t.fastScrollSensitivity<"u"?t.fastScrollSensitivity:5,scrollPredominantAxis:typeof t.scrollPredominantAxis<"u"?t.scrollPredominantAxis:!0,mouseWheelSmoothScroll:typeof t.mouseWheelSmoothScroll<"u"?t.mouseWheelSmoothScroll:!0,arrowSize:typeof t.arrowSize<"u"?t.arrowSize:11,listenOnDomNode:typeof t.listenOnDomNode<"u"?t.listenOnDomNode:null,horizontal:typeof t.horizontal<"u"?t.horizontal:1,horizontalScrollbarSize:typeof t.horizontalScrollbarSize<"u"?t.horizontalScrollbarSize:10,horizontalSliderSize:typeof t.horizontalSliderSize<"u"?t.horizontalSliderSize:0,horizontalHasArrows:typeof t.horizontalHasArrows<"u"?t.horizontalHasArrows:!1,vertical:typeof t.vertical<"u"?t.vertical:1,verticalScrollbarSize:typeof t.verticalScrollbarSize<"u"?t.verticalScrollbarSize:10,verticalHasArrows:typeof t.verticalHasArrows<"u"?t.verticalHasArrows:!1,verticalSliderSize:typeof t.verticalSliderSize<"u"?t.verticalSliderSize:0,scrollByPage:typeof t.scrollByPage<"u"?t.scrollByPage:!1};return e.horizontalSliderSize=typeof t.horizontalSliderSize<"u"?t.horizontalSliderSize:e.horizontalScrollbarSize,e.verticalSliderSize=typeof t.verticalSliderSize<"u"?t.verticalSliderSize:e.verticalScrollbarSize,vn&&(e.className+=" mac"),e}var b0=class extends tt{constructor(t,e,s,n,i,o,a,l){super(),this._bufferService=s,this._optionsService=a,this._renderService=l,this._onRequestScrollLines=this._register(new Ce),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let c=this._register(new i$({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:d=>Au(n.window,d)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{c.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new g$(e,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},c)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(i.onProtocolChange(d=>{this._scrollableElement.updateOptions({handleMouseWheel:!(d&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(os.runAndSubscribe(o.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=o.colors.background.css})),t.appendChild(this._scrollableElement.getDomNode()),this._register(Lt(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=n.mainDocument.createElement("style"),e.appendChild(this._styleElement),this._register(Lt(()=>this._styleElement.remove())),this._register(os.runAndSubscribe(o.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${o.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${o.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${o.colors.scrollbarSliderActiveBackground.css};`,"}"].join(`
|
|
509
|
-
`)})),this._register(this._bufferService.onResize(()=>this.queueSync())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._latestYDisp=void 0,this.queueSync()})),this._register(this._bufferService.onScroll(()=>this._sync())),this._register(this._scrollableElement.onScroll(d=>this._handleScroll(d)))}scrollLines(t){let e=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:e.scrollTop+t*this._renderService.dimensions.css.cell.height})}scrollToLine(t,e){e&&(this._latestYDisp=t),this._scrollableElement.setScrollPosition({reuseAnimation:!e,scrollTop:t*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:this._optionsService.rawOptions.overviewRuler?.width||14}}queueSync(t){t!==void 0&&(this._latestYDisp=t),this._queuedAnimationFrame===void 0&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(t=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,t!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:t*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(t){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let e=Math.round(t.scrollTop/this._renderService.dimensions.css.cell.height),s=e-this._bufferService.buffer.ydisp;s!==0&&(this._latestYDisp=e,this._onRequestScrollLines.fire(s)),this._isHandlingScroll=!1}};b0=At([Ee(2,ws),Ee(3,Mn),Ee(4,O4),Ee(5,zr),Ee(6,js),Ee(7,On)],b0);var _0=class extends tt{constructor(t,e,s,n,i){super(),this._screenElement=t,this._bufferService=e,this._coreBrowserService=s,this._decorationService=n,this._renderService=i,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this._register(this._renderService.onRenderedViewportChange(()=>this._doRefreshDecorations())),this._register(this._renderService.onDimensionsChange(()=>{this._dimensionsChanged=!0,this._queueRefresh()})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt})),this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh())),this._register(this._decorationService.onDecorationRemoved(o=>this._removeDecoration(o))),this._register(Lt(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(let t of this._decorationService.decorations)this._renderDecoration(t);this._dimensionsChanged=!1}_renderDecoration(t){this._refreshStyle(t),this._dimensionsChanged&&this._refreshXPosition(t)}_createElement(t){let e=this._coreBrowserService.mainDocument.createElement("div");e.classList.add("xterm-decoration"),e.classList.toggle("xterm-decoration-top-layer",t?.options?.layer==="top"),e.style.width=`${Math.round((t.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,e.style.height=`${(t.options.height||1)*this._renderService.dimensions.css.cell.height}px`,e.style.top=`${(t.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,e.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let s=t.options.x??0;return s&&s>this._bufferService.cols&&(e.style.display="none"),this._refreshXPosition(t,e),e}_refreshStyle(t){let e=t.marker.line-this._bufferService.buffers.active.ydisp;if(e<0||e>=this._bufferService.rows)t.element&&(t.element.style.display="none",t.onRenderEmitter.fire(t.element));else{let s=this._decorationElements.get(t);s||(s=this._createElement(t),t.element=s,this._decorationElements.set(t,s),this._container.appendChild(s),t.onDispose(()=>{this._decorationElements.delete(t),s.remove()})),s.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(s.style.width=`${Math.round((t.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,s.style.height=`${(t.options.height||1)*this._renderService.dimensions.css.cell.height}px`,s.style.top=`${e*this._renderService.dimensions.css.cell.height}px`,s.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),t.onRenderEmitter.fire(s)}}_refreshXPosition(t,e=t.element){if(!e)return;let s=t.options.x??0;(t.options.anchor||"left")==="right"?e.style.right=s?`${s*this._renderService.dimensions.css.cell.width}px`:"":e.style.left=s?`${s*this._renderService.dimensions.css.cell.width}px`:""}_removeDecoration(t){this._decorationElements.get(t)?.remove(),this._decorationElements.delete(t),t.dispose()}};_0=At([Ee(1,ws),Ee(2,Mn),Ee(3,ma),Ee(4,On)],_0);var v$=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(t){if(t.options.overviewRulerOptions){for(let e of this._zones)if(e.color===t.options.overviewRulerOptions.color&&e.position===t.options.overviewRulerOptions.position){if(this._lineIntersectsZone(e,t.marker.line))return;if(this._lineAdjacentToZone(e,t.marker.line,t.options.overviewRulerOptions.position)){this._addLineToZone(e,t.marker.line);return}}if(this._zonePoolIndex<this._zonePool.length){this._zonePool[this._zonePoolIndex].color=t.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=t.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=t.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=t.marker.line,this._zones.push(this._zonePool[this._zonePoolIndex++]);return}this._zones.push({color:t.options.overviewRulerOptions.color,position:t.options.overviewRulerOptions.position,startBufferLine:t.marker.line,endBufferLine:t.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(t){this._linePadding=t}_lineIntersectsZone(t,e){return e>=t.startBufferLine&&e<=t.endBufferLine}_lineAdjacentToZone(t,e,s){return e>=t.startBufferLine-this._linePadding[s||"full"]&&e<=t.endBufferLine+this._linePadding[s||"full"]}_addLineToZone(t,e){t.startBufferLine=Math.min(t.startBufferLine,e),t.endBufferLine=Math.max(t.endBufferLine,e)}},cn={full:0,left:0,center:0,right:0},Fn={full:0,left:0,center:0,right:0},Jr={full:0,left:0,center:0,right:0},Ml=class extends tt{constructor(t,e,s,n,i,o,a,l){super(),this._viewportElement=t,this._screenElement=e,this._bufferService=s,this._decorationService=n,this._renderService=i,this._optionsService=o,this._themeService=a,this._coreBrowserService=l,this._colorZoneStore=new v$,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas"),this._canvas.classList.add("xterm-decoration-overview-ruler"),this._refreshCanvasDimensions(),this._viewportElement.parentElement?.insertBefore(this._canvas,this._viewportElement),this._register(Lt(()=>this._canvas?.remove()));let c=this._canvas.getContext("2d");if(c)this._ctx=c;else throw new Error("Ctx cannot be null");this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh(void 0,!0))),this._register(this._decorationService.onDecorationRemoved(()=>this._queueRefresh(void 0,!0))),this._register(this._renderService.onRenderedViewportChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?"none":"block"})),this._register(this._bufferService.onScroll(()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})),this._register(this._renderService.onRender(()=>{(!this._containerHeight||this._containerHeight!==this._screenElement.clientHeight)&&(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh(!0))),this._register(this._optionsService.onSpecificOptionChange("overviewRuler",()=>this._queueRefresh(!0))),this._register(this._themeService.onChangeColors(()=>this._queueRefresh())),this._queueRefresh(!0)}get _width(){return this._optionsService.options.overviewRuler?.width||0}_refreshDrawConstants(){let t=Math.floor((this._canvas.width-1)/3),e=Math.ceil((this._canvas.width-1)/3);Fn.full=this._canvas.width,Fn.left=t,Fn.center=e,Fn.right=t,this._refreshDrawHeightConstants(),Jr.full=1,Jr.left=1,Jr.center=1+Fn.left,Jr.right=1+Fn.left+Fn.center}_refreshDrawHeightConstants(){cn.full=Math.round(2*this._coreBrowserService.dpr);let t=this._canvas.height/this._bufferService.buffer.lines.length,e=Math.round(Math.max(Math.min(t,12),6)*this._coreBrowserService.dpr);cn.left=e,cn.center=e,cn.right=e}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*cn.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*cn.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*cn.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*cn.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowserService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowserService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(let e of this._decorationService.decorations)this._colorZoneStore.addDecoration(e);this._ctx.lineWidth=1,this._renderRulerOutline();let t=this._colorZoneStore.zones;for(let e of t)e.position!=="full"&&this._renderColorZone(e);for(let e of t)e.position==="full"&&this._renderColorZone(e);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderRulerOutline(){this._ctx.fillStyle=this._themeService.colors.overviewRulerBorder.css,this._ctx.fillRect(0,0,1,this._canvas.height),this._optionsService.rawOptions.overviewRuler.showTopBorder&&this._ctx.fillRect(1,0,this._canvas.width-1,1),this._optionsService.rawOptions.overviewRuler.showBottomBorder&&this._ctx.fillRect(1,this._canvas.height-1,this._canvas.width-1,this._canvas.height)}_renderColorZone(t){this._ctx.fillStyle=t.color,this._ctx.fillRect(Jr[t.position||"full"],Math.round((this._canvas.height-1)*(t.startBufferLine/this._bufferService.buffers.active.lines.length)-cn[t.position||"full"]/2),Fn[t.position||"full"],Math.round((this._canvas.height-1)*((t.endBufferLine-t.startBufferLine)/this._bufferService.buffers.active.lines.length)+cn[t.position||"full"]))}_queueRefresh(t,e){this._shouldUpdateDimensions=t||this._shouldUpdateDimensions,this._shouldUpdateAnchor=e||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._refreshDecorations(),this._animationFrame=void 0}))}};Ml=At([Ee(2,ws),Ee(3,ma),Ee(4,On),Ee(5,js),Ee(6,zr),Ee(7,Mn)],Ml);var be;(t=>(t.NUL="\0",t.SOH="",t.STX="",t.ETX="",t.EOT="",t.ENQ="",t.ACK="",t.BEL="\x07",t.BS="\b",t.HT=" ",t.LF=`
|
|
510
|
-
`,t.VT="\v",t.FF="\f",t.CR="\r",t.SO="",t.SI="",t.DLE="",t.DC1="",t.DC2="",t.DC3="",t.DC4="",t.NAK="",t.SYN="",t.ETB="",t.CAN="",t.EM="",t.SUB="",t.ESC="\x1B",t.FS="",t.GS="",t.RS="",t.US="",t.SP=" ",t.DEL=""))(be||={});var Ja;(t=>(t.PAD="",t.HOP="",t.BPH="",t.NBH="",t.IND="",t.NEL="
",t.SSA="",t.ESA="",t.HTS="",t.HTJ="",t.VTS="",t.PLD="",t.PLU="",t.RI="",t.SS2="",t.SS3="",t.DCS="",t.PU1="",t.PU2="",t.STS="",t.CCH="",t.MW="",t.SPA="",t.EPA="",t.SOS="",t.SGCI="",t.SCI="",t.CSI="",t.ST="",t.OSC="",t.PM="",t.APC=""))(Ja||={});var r5;(t=>t.ST=`${be.ESC}\\`)(r5||={});var y0=class{constructor(t,e,s,n,i,o){this._textarea=t,this._compositionView=e,this._bufferService=s,this._optionsService=n,this._coreService=i,this._renderService=o,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(t){this._compositionView.textContent=t.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(t){if(this._isComposing||this._isSendingComposition){if(t.keyCode===20||t.keyCode===229||t.keyCode===16||t.keyCode===17||t.keyCode===18)return!1;this._finalizeComposition(!1)}return t.keyCode===229?(this._handleAnyTextareaChanges(),!1):!0}_finalizeComposition(t){if(this._compositionView.classList.remove("active"),this._isComposing=!1,t){let e={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let s;e.start+=this._dataAlreadySent.length,this._isComposing?s=this._textarea.value.substring(e.start,this._compositionPosition.start):s=this._textarea.value.substring(e.start),s.length>0&&this._coreService.triggerDataEvent(s,!0)}},0)}else{this._isSendingComposition=!1;let e=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(e,!0)}}_handleAnyTextareaChanges(){let t=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let e=this._textarea.value,s=e.replace(t,"");this._dataAlreadySent=s,e.length>t.length?this._coreService.triggerDataEvent(s,!0):e.length<t.length?this._coreService.triggerDataEvent(`${be.DEL}`,!0):e.length===t.length&&e!==t&&this._coreService.triggerDataEvent(e,!0)}},0)}updateCompositionElements(t){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let e=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),s=this._renderService.dimensions.css.cell.height,n=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,i=e*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=i+"px",this._compositionView.style.top=n+"px",this._compositionView.style.height=s+"px",this._compositionView.style.lineHeight=s+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let o=this._compositionView.getBoundingClientRect();this._textarea.style.left=i+"px",this._textarea.style.top=n+"px",this._textarea.style.width=Math.max(o.width,1)+"px",this._textarea.style.height=Math.max(o.height,1)+"px",this._textarea.style.lineHeight=o.height+"px"}t||setTimeout(()=>this.updateCompositionElements(!0),0)}}};y0=At([Ee(2,ws),Ee(3,js),Ee(4,Gi),Ee(5,On)],y0);var qt=0,Gt=0,Yt=0,Nt=0,w1={css:"#00000000",rgba:0},It;(t=>{function e(i,o,a,l){return l!==void 0?`#${hi(i)}${hi(o)}${hi(a)}${hi(l)}`:`#${hi(i)}${hi(o)}${hi(a)}`}t.toCss=e;function s(i,o,a,l=255){return(i<<24|o<<16|a<<8|l)>>>0}t.toRgba=s;function n(i,o,a,l){return{css:t.toCss(i,o,a,l),rgba:t.toRgba(i,o,a,l)}}t.toColor=n})(It||={});var _t;(t=>{function e(c,d){if(Nt=(d.rgba&255)/255,Nt===1)return{css:d.css,rgba:d.rgba};let h=d.rgba>>24&255,u=d.rgba>>16&255,f=d.rgba>>8&255,m=c.rgba>>24&255,p=c.rgba>>16&255,g=c.rgba>>8&255;qt=m+Math.round((h-m)*Nt),Gt=p+Math.round((u-p)*Nt),Yt=g+Math.round((f-g)*Nt);let x=It.toCss(qt,Gt,Yt),v=It.toRgba(qt,Gt,Yt);return{css:x,rgba:v}}t.blend=e;function s(c){return(c.rgba&255)===255}t.isOpaque=s;function n(c,d,h){let u=Xa.ensureContrastRatio(c.rgba,d.rgba,h);if(u)return It.toColor(u>>24&255,u>>16&255,u>>8&255)}t.ensureContrastRatio=n;function i(c){let d=(c.rgba|255)>>>0;return[qt,Gt,Yt]=Xa.toChannels(d),{css:It.toCss(qt,Gt,Yt),rgba:d}}t.opaque=i;function o(c,d){return Nt=Math.round(d*255),[qt,Gt,Yt]=Xa.toChannels(c.rgba),{css:It.toCss(qt,Gt,Yt,Nt),rgba:It.toRgba(qt,Gt,Yt,Nt)}}t.opacity=o;function a(c,d){return Nt=c.rgba&255,o(c,Nt*d/255)}t.multiplyOpacity=a;function l(c){return[c.rgba>>24&255,c.rgba>>16&255,c.rgba>>8&255]}t.toColorRGB=l})(_t||={});var Ct;(t=>{let e,s;try{let i=document.createElement("canvas");i.width=1,i.height=1;let o=i.getContext("2d",{willReadFrequently:!0});o&&(e=o,e.globalCompositeOperation="copy",s=e.createLinearGradient(0,0,1,1))}catch{}function n(i){if(i.match(/#[\da-f]{3,8}/i))switch(i.length){case 4:return qt=parseInt(i.slice(1,2).repeat(2),16),Gt=parseInt(i.slice(2,3).repeat(2),16),Yt=parseInt(i.slice(3,4).repeat(2),16),It.toColor(qt,Gt,Yt);case 5:return qt=parseInt(i.slice(1,2).repeat(2),16),Gt=parseInt(i.slice(2,3).repeat(2),16),Yt=parseInt(i.slice(3,4).repeat(2),16),Nt=parseInt(i.slice(4,5).repeat(2),16),It.toColor(qt,Gt,Yt,Nt);case 7:return{css:i,rgba:(parseInt(i.slice(1),16)<<8|255)>>>0};case 9:return{css:i,rgba:parseInt(i.slice(1),16)>>>0}}let o=i.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(o)return qt=parseInt(o[1]),Gt=parseInt(o[2]),Yt=parseInt(o[3]),Nt=Math.round((o[5]===void 0?1:parseFloat(o[5]))*255),It.toColor(qt,Gt,Yt,Nt);if(!e||!s)throw new Error("css.toColor: Unsupported css format");if(e.fillStyle=s,e.fillStyle=i,typeof e.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(e.fillRect(0,0,1,1),[qt,Gt,Yt,Nt]=e.getImageData(0,0,1,1).data,Nt!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:It.toRgba(qt,Gt,Yt,Nt),css:i}}t.toColor=n})(Ct||={});var vs;(t=>{function e(n){return s(n>>16&255,n>>8&255,n&255)}t.relativeLuminance=e;function s(n,i,o){let a=n/255,l=i/255,c=o/255,d=a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4),h=l<=.03928?l/12.92:Math.pow((l+.055)/1.055,2.4),u=c<=.03928?c/12.92:Math.pow((c+.055)/1.055,2.4);return d*.2126+h*.7152+u*.0722}t.relativeLuminance2=s})(vs||={});var Xa;(t=>{function e(a,l){if(Nt=(l&255)/255,Nt===1)return l;let c=l>>24&255,d=l>>16&255,h=l>>8&255,u=a>>24&255,f=a>>16&255,m=a>>8&255;return qt=u+Math.round((c-u)*Nt),Gt=f+Math.round((d-f)*Nt),Yt=m+Math.round((h-m)*Nt),It.toRgba(qt,Gt,Yt)}t.blend=e;function s(a,l,c){let d=vs.relativeLuminance(a>>8),h=vs.relativeLuminance(l>>8);if(Cn(d,h)<c){if(h<d){let m=n(a,l,c),p=Cn(d,vs.relativeLuminance(m>>8));if(p<c){let g=i(a,l,c),x=Cn(d,vs.relativeLuminance(g>>8));return p>x?m:g}return m}let u=i(a,l,c),f=Cn(d,vs.relativeLuminance(u>>8));if(f<c){let m=n(a,l,c),p=Cn(d,vs.relativeLuminance(m>>8));return f>p?u:m}return u}}t.ensureContrastRatio=s;function n(a,l,c){let d=a>>24&255,h=a>>16&255,u=a>>8&255,f=l>>24&255,m=l>>16&255,p=l>>8&255,g=Cn(vs.relativeLuminance2(f,m,p),vs.relativeLuminance2(d,h,u));for(;g<c&&(f>0||m>0||p>0);)f-=Math.max(0,Math.ceil(f*.1)),m-=Math.max(0,Math.ceil(m*.1)),p-=Math.max(0,Math.ceil(p*.1)),g=Cn(vs.relativeLuminance2(f,m,p),vs.relativeLuminance2(d,h,u));return(f<<24|m<<16|p<<8|255)>>>0}t.reduceLuminance=n;function i(a,l,c){let d=a>>24&255,h=a>>16&255,u=a>>8&255,f=l>>24&255,m=l>>16&255,p=l>>8&255,g=Cn(vs.relativeLuminance2(f,m,p),vs.relativeLuminance2(d,h,u));for(;g<c&&(f<255||m<255||p<255);)f=Math.min(255,f+Math.ceil((255-f)*.1)),m=Math.min(255,m+Math.ceil((255-m)*.1)),p=Math.min(255,p+Math.ceil((255-p)*.1)),g=Cn(vs.relativeLuminance2(f,m,p),vs.relativeLuminance2(d,h,u));return(f<<24|m<<16|p<<8|255)>>>0}t.increaseLuminance=i;function o(a){return[a>>24&255,a>>16&255,a>>8&255,a&255]}t.toChannels=o})(Xa||={});function hi(t){let e=t.toString(16);return e.length<2?"0"+e:e}function Cn(t,e){return t<e?(e+.05)/(t+.05):(t+.05)/(e+.05)}var b$=class extends fa{constructor(t,e,s){super(),this.content=0,this.combinedData="",this.fg=t.fg,this.bg=t.bg,this.combinedData=e,this._width=s}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(t){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Ol=class{constructor(t){this._bufferService=t,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new Gs}register(t){let e={id:this._nextCharacterJoinerId++,handler:t};return this._characterJoiners.push(e),e.id}deregister(t){for(let e=0;e<this._characterJoiners.length;e++)if(this._characterJoiners[e].id===t)return this._characterJoiners.splice(e,1),!0;return!1}getJoinedCharacters(t){if(this._characterJoiners.length===0)return[];let e=this._bufferService.buffer.lines.get(t);if(!e||e.length===0)return[];let s=[],n=e.translateToString(!0),i=0,o=0,a=0,l=e.getFg(0),c=e.getBg(0);for(let d=0;d<e.getTrimmedLength();d++)if(e.loadCell(d,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==l||this._workCell.bg!==c){if(d-i>1){let h=this._getJoinedRanges(n,a,o,e,i);for(let u=0;u<h.length;u++)s.push(h[u])}i=d,a=o,l=this._workCell.fg,c=this._workCell.bg}o+=this._workCell.getChars().length||Wn.length}if(this._bufferService.cols-i>1){let d=this._getJoinedRanges(n,a,o,e,i);for(let h=0;h<d.length;h++)s.push(d[h])}return s}_getJoinedRanges(t,e,s,n,i){let o=t.substring(e,s),a=[];try{a=this._characterJoiners[0].handler(o)}catch(l){console.error(l)}for(let l=1;l<this._characterJoiners.length;l++)try{let c=this._characterJoiners[l].handler(o);for(let d=0;d<c.length;d++)Ol._mergeRanges(a,c[d])}catch(c){console.error(c)}return this._stringRangesToCellRanges(a,n,i),a}_stringRangesToCellRanges(t,e,s){let n=0,i=!1,o=0,a=t[n];if(a){for(let l=s;l<this._bufferService.cols;l++){let c=e.getWidth(l),d=e.getString(l).length||Wn.length;if(c!==0){if(!i&&a[0]<=o&&(a[0]=l,i=!0),a[1]<=o){if(a[1]=l,a=t[++n],!a)break;a[0]<=o?(a[0]=l,i=!0):i=!1}o+=d}}a&&(a[1]=this._bufferService.cols)}}static _mergeRanges(t,e){let s=!1;for(let n=0;n<t.length;n++){let i=t[n];if(s){if(e[1]<=i[0])return t[n-1][1]=e[1],t;if(e[1]<=i[1])return t[n-1][1]=Math.max(e[1],i[1]),t.splice(n,1),t;t.splice(n,1),n--}else{if(e[1]<=i[0])return t.splice(n,0,e),t;if(e[1]<=i[1])return i[0]=Math.min(e[0],i[0]),t;e[0]<i[1]&&(i[0]=Math.min(e[0],i[0]),s=!0);continue}}return s?t[t.length-1][1]=e[1]:t.push(e),t}};Ol=At([Ee(0,ws)],Ol);function _$(t){return 57508<=t&&t<=57558}function y$(t){return 9472<=t&&t<=9631}function L$(t){return _$(t)||y$(t)}function S$(){return{css:{canvas:Ma(),cell:Ma()},device:{canvas:Ma(),cell:Ma(),char:{width:0,height:0,left:0,top:0}}}}function Ma(){return{width:0,height:0}}var L0=class{constructor(t,e,s,n,i,o,a){this._document=t,this._characterJoinerService=e,this._optionsService=s,this._coreBrowserService=n,this._coreService=i,this._decorationService=o,this._themeService=a,this._workCell=new Gs,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(t,e,s){this._selectionStart=t,this._selectionEnd=e,this._columnSelectMode=s}createRow(t,e,s,n,i,o,a,l,c,d,h){let u=[],f=this._characterJoinerService.getJoinedCharacters(e),m=this._themeService.colors,p=t.getNoBgTrimmedLength();s&&p<o+1&&(p=o+1);let g,x=0,v="",b=0,y=0,_=0,L=0,w=!1,j=0,S=!1,C=0,N=0,V=[],E=d!==-1&&h!==-1;for(let T=0;T<p;T++){t.loadCell(T,this._workCell);let k=this._workCell.getWidth();if(k===0)continue;let R=!1,P=T>=N,D=T,I=this._workCell;if(f.length>0&&T===f[0][0]&&P){let Q=f.shift(),ee=this._isCellInSelection(Q[0],e);for(b=Q[0]+1;b<Q[1];b++)P&&=ee===this._isCellInSelection(b,e);P&&=!s||o<Q[0]||o>=Q[1],P?(R=!0,I=new b$(this._workCell,t.translateToString(!0,Q[0],Q[1]),Q[1]-Q[0]),D=Q[1]-1,k=I.getWidth()):N=Q[1]}let M=this._isCellInSelection(T,e),O=s&&T===o,$=E&&T>=d&&T<=h,B=!1;this._decorationService.forEachDecorationAtCell(T,e,void 0,Q=>{B=!0});let z=I.getChars()||Wn;if(z===" "&&(I.isUnderline()||I.isOverline())&&(z=" "),C=k*l-c.get(z,I.isBold(),I.isItalic()),!g)g=this._document.createElement("span");else if(x&&(M&&S||!M&&!S&&I.bg===y)&&(M&&S&&m.selectionForeground||I.fg===_)&&I.extended.ext===L&&$===w&&C===j&&!O&&!R&&!B&&P){I.isInvisible()?v+=Wn:v+=z,x++;continue}else x&&(g.textContent=v),g=this._document.createElement("span"),x=0,v="";if(y=I.bg,_=I.fg,L=I.extended.ext,w=$,j=C,S=M,R&&o>=T&&o<=D&&(o=T),!this._coreService.isCursorHidden&&O&&this._coreService.isCursorInitialized){if(V.push("xterm-cursor"),this._coreBrowserService.isFocused)a&&V.push("xterm-cursor-blink"),V.push(n==="bar"?"xterm-cursor-bar":n==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(i)switch(i){case"outline":V.push("xterm-cursor-outline");break;case"block":V.push("xterm-cursor-block");break;case"bar":V.push("xterm-cursor-bar");break;case"underline":V.push("xterm-cursor-underline");break}}if(I.isBold()&&V.push("xterm-bold"),I.isItalic()&&V.push("xterm-italic"),I.isDim()&&V.push("xterm-dim"),I.isInvisible()?v=Wn:v=I.getChars()||Wn,I.isUnderline()&&(V.push(`xterm-underline-${I.extended.underlineStyle}`),v===" "&&(v=" "),!I.isUnderlineColorDefault()))if(I.isUnderlineColorRGB())g.style.textDecorationColor=`rgb(${fa.toColorRGB(I.getUnderlineColor()).join(",")})`;else{let Q=I.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&I.isBold()&&Q<8&&(Q+=8),g.style.textDecorationColor=m.ansi[Q].css}I.isOverline()&&(V.push("xterm-overline"),v===" "&&(v=" ")),I.isStrikethrough()&&V.push("xterm-strikethrough"),$&&(g.style.textDecoration="underline");let K=I.getFgColor(),G=I.getFgColorMode(),Y=I.getBgColor(),U=I.getBgColorMode(),W=!!I.isInverse();if(W){let Q=K;K=Y,Y=Q;let ee=G;G=U,U=ee}let H,X,q=!1;this._decorationService.forEachDecorationAtCell(T,e,void 0,Q=>{Q.options.layer!=="top"&&q||(Q.backgroundColorRGB&&(U=50331648,Y=Q.backgroundColorRGB.rgba>>8&16777215,H=Q.backgroundColorRGB),Q.foregroundColorRGB&&(G=50331648,K=Q.foregroundColorRGB.rgba>>8&16777215,X=Q.foregroundColorRGB),q=Q.options.layer==="top")}),!q&&M&&(H=this._coreBrowserService.isFocused?m.selectionBackgroundOpaque:m.selectionInactiveBackgroundOpaque,Y=H.rgba>>8&16777215,U=50331648,q=!0,m.selectionForeground&&(G=50331648,K=m.selectionForeground.rgba>>8&16777215,X=m.selectionForeground)),q&&V.push("xterm-decoration-top");let Z;switch(U){case 16777216:case 33554432:Z=m.ansi[Y],V.push(`xterm-bg-${Y}`);break;case 50331648:Z=It.toColor(Y>>16,Y>>8&255,Y&255),this._addStyle(g,`background-color:#${j1((Y>>>0).toString(16),"0",6)}`);break;default:W?(Z=m.foreground,V.push("xterm-bg-257")):Z=m.background}switch(H||I.isDim()&&(H=_t.multiplyOpacity(Z,.5)),G){case 16777216:case 33554432:I.isBold()&&K<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(K+=8),this._applyMinimumContrast(g,Z,m.ansi[K],I,H,void 0)||V.push(`xterm-fg-${K}`);break;case 50331648:let Q=It.toColor(K>>16&255,K>>8&255,K&255);this._applyMinimumContrast(g,Z,Q,I,H,X)||this._addStyle(g,`color:#${j1(K.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(g,Z,m.foreground,I,H,X)||W&&V.push("xterm-fg-257")}V.length&&(g.className=V.join(" "),V.length=0),!O&&!R&&!B&&P?x++:g.textContent=v,C!==this.defaultSpacing&&(g.style.letterSpacing=`${C}px`),u.push(g),T=D}return g&&x&&(g.textContent=v),u}_applyMinimumContrast(t,e,s,n,i,o){if(this._optionsService.rawOptions.minimumContrastRatio===1||L$(n.getCode()))return!1;let a=this._getContrastCache(n),l;if(!i&&!o&&(l=a.getColor(e.rgba,s.rgba)),l===void 0){let c=this._optionsService.rawOptions.minimumContrastRatio/(n.isDim()?2:1);l=_t.ensureContrastRatio(i||e,o||s,c),a.setColor((i||e).rgba,(o||s).rgba,l??null)}return l?(this._addStyle(t,`color:${l.css}`),!0):!1}_getContrastCache(t){return t.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(t,e){t.setAttribute("style",`${t.getAttribute("style")||""}${e};`)}_isCellInSelection(t,e){let s=this._selectionStart,n=this._selectionEnd;return!s||!n?!1:this._columnSelectMode?s[0]<=n[0]?t>=s[0]&&e>=s[1]&&t<n[0]&&e<=n[1]:t<s[0]&&e>=s[1]&&t>=n[0]&&e<=n[1]:e>s[1]&&e<n[1]||s[1]===n[1]&&e===s[1]&&t>=s[0]&&t<n[0]||s[1]<n[1]&&e===n[1]&&t<n[0]||s[1]<n[1]&&e===s[1]&&t>=s[0]}};L0=At([Ee(1,F4),Ee(2,js),Ee(3,Mn),Ee(4,Gi),Ee(5,ma),Ee(6,zr)],L0);function j1(t,e,s){for(;t.length<s;)t=e+t;return t}var w$=class{constructor(t,e){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=t.createElement("div"),this._container.classList.add("xterm-width-cache-measure-container"),this._container.setAttribute("aria-hidden","true"),this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";let s=t.createElement("span");s.classList.add("xterm-char-measure-element");let n=t.createElement("span");n.classList.add("xterm-char-measure-element"),n.style.fontWeight="bold";let i=t.createElement("span");i.classList.add("xterm-char-measure-element"),i.style.fontStyle="italic";let o=t.createElement("span");o.classList.add("xterm-char-measure-element"),o.style.fontWeight="bold",o.style.fontStyle="italic",this._measureElements=[s,n,i,o],this._container.appendChild(s),this._container.appendChild(n),this._container.appendChild(i),this._container.appendChild(o),e.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(t,e,s,n){t===this._font&&e===this._fontSize&&s===this._weight&&n===this._weightBold||(this._font=t,this._fontSize=e,this._weight=s,this._weightBold=n,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${s}`,this._measureElements[1].style.fontWeight=`${n}`,this._measureElements[2].style.fontWeight=`${s}`,this._measureElements[3].style.fontWeight=`${n}`,this.clear())}get(t,e,s){let n=0;if(!e&&!s&&t.length===1&&(n=t.charCodeAt(0))<256){if(this._flat[n]!==-9999)return this._flat[n];let a=this._measure(t,0);return a>0&&(this._flat[n]=a),a}let i=t;e&&(i+="B"),s&&(i+="I");let o=this._holey.get(i);if(o===void 0){let a=0;e&&(a|=1),s&&(a|=2),o=this._measure(t,a),o>0&&this._holey.set(i,o)}return o}_measure(t,e){let s=this._measureElements[e];return s.textContent=t.repeat(32),s.offsetWidth/32}},j$=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(t,e,s,n=!1){if(this.selectionStart=e,this.selectionEnd=s,!e||!s||e[0]===s[0]&&e[1]===s[1]){this.clear();return}let i=t.buffers.active.ydisp,o=e[1]-i,a=s[1]-i,l=Math.max(o,0),c=Math.min(a,t.rows-1);if(l>=t.rows||c<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=n,this.viewportStartRow=o,this.viewportEndRow=a,this.viewportCappedStartRow=l,this.viewportCappedEndRow=c,this.startCol=e[0],this.endCol=s[0]}isCellSelected(t,e,s){return this.hasSelection?(s-=t.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?e>=this.startCol&&s>=this.viewportCappedStartRow&&e<this.endCol&&s<=this.viewportCappedEndRow:e<this.startCol&&s>=this.viewportCappedStartRow&&e>=this.endCol&&s<=this.viewportCappedEndRow:s>this.viewportStartRow&&s<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&s===this.viewportStartRow&&e>=this.startCol&&e<this.endCol||this.viewportStartRow<this.viewportEndRow&&s===this.viewportEndRow&&e<this.endCol||this.viewportStartRow<this.viewportEndRow&&s===this.viewportStartRow&&e>=this.startCol):!1}};function C$(){return new j$}var vd="xterm-dom-renderer-owner-",Ks="xterm-rows",Oa="xterm-fg-",C1="xterm-bg-",Xr="xterm-focus",Ba="xterm-selection",k$=1,S0=class extends tt{constructor(t,e,s,n,i,o,a,l,c,d,h,u,f,m){super(),this._terminal=t,this._document=e,this._element=s,this._screenElement=n,this._viewportElement=i,this._helperContainer=o,this._linkifier2=a,this._charSizeService=c,this._optionsService=d,this._bufferService=h,this._coreService=u,this._coreBrowserService=f,this._themeService=m,this._terminalClass=k$++,this._rowElements=[],this._selectionRenderModel=C$(),this.onRequestRedraw=this._register(new Ce).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(Ks),this._rowContainer.style.lineHeight="normal",this._rowContainer.setAttribute("aria-hidden","true"),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=this._document.createElement("div"),this._selectionContainer.classList.add(Ba),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=S$(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(p=>this._injectCss(p))),this._injectCss(this._themeService.colors),this._rowFactory=l.createInstance(L0,document),this._element.classList.add(vd+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(p=>this._handleLinkHover(p))),this._register(this._linkifier2.onHideLinkUnderline(p=>this._handleLinkLeave(p))),this._register(Lt(()=>{this._element.classList.remove(vd+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new w$(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let t=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*t,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*t),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/t),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/t),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(let s of this._rowElements)s.style.width=`${this.dimensions.css.canvas.width}px`,s.style.height=`${this.dimensions.css.cell.height}px`,s.style.lineHeight=`${this.dimensions.css.cell.height}px`,s.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let e=`${this._terminalSelector} .${Ks} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=e,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(t){this._themeStyleElement||(this._themeStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let e=`${this._terminalSelector} .${Ks} { pointer-events: none; color: ${t.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;e+=`${this._terminalSelector} .${Ks} .xterm-dim { color: ${_t.multiplyOpacity(t.foreground,.5).css};}`,e+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let s=`blink_underline_${this._terminalClass}`,n=`blink_bar_${this._terminalClass}`,i=`blink_block_${this._terminalClass}`;e+=`@keyframes ${s} { 50% { border-bottom-style: hidden; }}`,e+=`@keyframes ${n} { 50% { box-shadow: none; }}`,e+=`@keyframes ${i} { 0% { background-color: ${t.cursor.css}; color: ${t.cursorAccent.css}; } 50% { background-color: inherit; color: ${t.cursor.css}; }}`,e+=`${this._terminalSelector} .${Ks}.${Xr} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${Ks}.${Xr} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${Ks}.${Xr} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${Ks} .xterm-cursor.xterm-cursor-block { background-color: ${t.cursor.css}; color: ${t.cursorAccent.css};}${this._terminalSelector} .${Ks} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${t.cursor.css} !important; color: ${t.cursorAccent.css} !important;}${this._terminalSelector} .${Ks} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${t.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${Ks} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${t.cursor.css} inset;}${this._terminalSelector} .${Ks} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${t.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,e+=`${this._terminalSelector} .${Ba} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${Ba} div { position: absolute; background-color: ${t.selectionBackgroundOpaque.css};}${this._terminalSelector} .${Ba} div { position: absolute; background-color: ${t.selectionInactiveBackgroundOpaque.css};}`;for(let[o,a]of t.ansi.entries())e+=`${this._terminalSelector} .${Oa}${o} { color: ${a.css}; }${this._terminalSelector} .${Oa}${o}.xterm-dim { color: ${_t.multiplyOpacity(a,.5).css}; }${this._terminalSelector} .${C1}${o} { background-color: ${a.css}; }`;e+=`${this._terminalSelector} .${Oa}257 { color: ${_t.opaque(t.background).css}; }${this._terminalSelector} .${Oa}257.xterm-dim { color: ${_t.multiplyOpacity(_t.opaque(t.background),.5).css}; }${this._terminalSelector} .${C1}257 { background-color: ${t.foreground.css}; }`,this._themeStyleElement.textContent=e}_setDefaultSpacing(){let t=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${t}px`,this._rowFactory.defaultSpacing=t}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(t,e){for(let s=this._rowElements.length;s<=e;s++){let n=this._document.createElement("div");this._rowContainer.appendChild(n),this._rowElements.push(n)}for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(t,e){this._refreshRowElements(t,e),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(Xr),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(Xr),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(t,e,s){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(t,e,s),this.renderRows(0,this._bufferService.rows-1),!t||!e||(this._selectionRenderModel.update(this._terminal,t,e,s),!this._selectionRenderModel.hasSelection))return;let n=this._selectionRenderModel.viewportStartRow,i=this._selectionRenderModel.viewportEndRow,o=this._selectionRenderModel.viewportCappedStartRow,a=this._selectionRenderModel.viewportCappedEndRow,l=this._document.createDocumentFragment();if(s){let c=t[0]>e[0];l.appendChild(this._createSelectionElement(o,c?e[0]:t[0],c?t[0]:e[0],a-o+1))}else{let c=n===o?t[0]:0,d=o===i?e[0]:this._bufferService.cols;l.appendChild(this._createSelectionElement(o,c,d));let h=a-o-1;if(l.appendChild(this._createSelectionElement(o+1,0,this._bufferService.cols,h)),o!==a){let u=i===a?e[0]:this._bufferService.cols;l.appendChild(this._createSelectionElement(a,0,u))}}this._selectionContainer.appendChild(l)}_createSelectionElement(t,e,s,n=1){let i=this._document.createElement("div"),o=e*this.dimensions.css.cell.width,a=this.dimensions.css.cell.width*(s-e);return o+a>this.dimensions.css.canvas.width&&(a=this.dimensions.css.canvas.width-o),i.style.height=`${n*this.dimensions.css.cell.height}px`,i.style.top=`${t*this.dimensions.css.cell.height}px`,i.style.left=`${o}px`,i.style.width=`${a}px`,i}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let t of this._rowElements)t.replaceChildren()}renderRows(t,e){let s=this._bufferService.buffer,n=s.ybase+s.y,i=Math.min(s.x,this._bufferService.cols-1),o=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,a=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,l=this._optionsService.rawOptions.cursorInactiveStyle;for(let c=t;c<=e;c++){let d=c+s.ydisp,h=this._rowElements[c],u=s.lines.get(d);if(!h||!u)break;h.replaceChildren(...this._rowFactory.createRow(u,d,d===n,a,l,i,o,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${vd}${this._terminalClass}`}_handleLinkHover(t){this._setCellUnderline(t.x1,t.x2,t.y1,t.y2,t.cols,!0)}_handleLinkLeave(t){this._setCellUnderline(t.x1,t.x2,t.y1,t.y2,t.cols,!1)}_setCellUnderline(t,e,s,n,i,o){s<0&&(t=0),n<0&&(e=0);let a=this._bufferService.rows-1;s=Math.max(Math.min(s,a),0),n=Math.max(Math.min(n,a),0),i=Math.min(i,this._bufferService.cols);let l=this._bufferService.buffer,c=l.ybase+l.y,d=Math.min(l.x,i-1),h=this._optionsService.rawOptions.cursorBlink,u=this._optionsService.rawOptions.cursorStyle,f=this._optionsService.rawOptions.cursorInactiveStyle;for(let m=s;m<=n;++m){let p=m+l.ydisp,g=this._rowElements[m],x=l.lines.get(p);if(!g||!x)break;g.replaceChildren(...this._rowFactory.createRow(x,p,p===c,u,f,d,h,this.dimensions.css.cell.width,this._widthCache,o?m===s?t:0:-1,o?(m===n?e:i)-1:-1))}}};S0=At([Ee(7,ju),Ee(8,Vc),Ee(9,js),Ee(10,ws),Ee(11,Gi),Ee(12,Mn),Ee(13,zr)],S0);var w0=class extends tt{constructor(t,e,s){super(),this._optionsService=s,this.width=0,this.height=0,this._onCharSizeChange=this._register(new Ce),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new N$(this._optionsService))}catch{this._measureStrategy=this._register(new V$(t,e,this._optionsService))}this._register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],()=>this.measure()))}get hasValidSize(){return this.width>0&&this.height>0}measure(){let t=this._measureStrategy.measure();(t.width!==this.width||t.height!==this.height)&&(this.width=t.width,this.height=t.height,this._onCharSizeChange.fire())}};w0=At([Ee(2,js)],w0);var o5=class extends tt{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(t,e){t!==void 0&&t>0&&e!==void 0&&e>0&&(this._result.width=t,this._result.height=e)}},V$=class extends o5{constructor(t,e,s){super(),this._document=t,this._parentElement=e,this._optionsService=s,this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}},N$=class extends o5{constructor(t){super(),this._optionsService=t,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext("2d");let e=this._ctx.measureText("W");if(!("width"in e&&"fontBoundingBoxAscent"in e&&"fontBoundingBoxDescent"in e))throw new Error("Required font metrics not supported")}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;let t=this._ctx.measureText("W");return this._validateAndSet(t.width,t.fontBoundingBoxAscent+t.fontBoundingBoxDescent),this._result}},T$=class extends tt{constructor(t,e,s){super(),this._textarea=t,this._window=e,this.mainDocument=s,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new A$(this._window)),this._onDprChange=this._register(new Ce),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new Ce),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(n=>this._screenDprMonitor.setWindow(n))),this._register(os.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(qe(this._textarea,"focus",()=>this._isFocused=!0)),this._register(qe(this._textarea,"blur",()=>this._isFocused=!1))}get window(){return this._window}set window(t){this._window!==t&&(this._window=t,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask(()=>this._cachedIsFocused=void 0)),this._cachedIsFocused}},A$=class extends tt{constructor(t){super(),this._parentWindow=t,this._windowResizeListener=this._register(new Lr),this._onDprChange=this._register(new Ce),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(Lt(()=>this.clearListener()))}setWindow(t){this._parentWindow=t,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=qe(this._parentWindow,"resize",()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){this._outerListener&&(this._resolutionMediaMatchList?.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){!this._resolutionMediaMatchList||!this._outerListener||(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}},E$=class extends tt{constructor(){super(),this.linkProviders=[],this._register(Lt(()=>this.linkProviders.length=0))}registerLinkProvider(t){return this.linkProviders.push(t),{dispose:()=>{let e=this.linkProviders.indexOf(t);e!==-1&&this.linkProviders.splice(e,1)}}}};function Pu(t,e,s){let n=s.getBoundingClientRect(),i=t.getComputedStyle(s),o=parseInt(i.getPropertyValue("padding-left")),a=parseInt(i.getPropertyValue("padding-top"));return[e.clientX-n.left-o,e.clientY-n.top-a]}function P$(t,e,s,n,i,o,a,l,c){if(!o)return;let d=Pu(t,e,s);if(d)return d[0]=Math.ceil((d[0]+(c?a/2:0))/a),d[1]=Math.ceil(d[1]/l),d[0]=Math.min(Math.max(d[0],1),n+(c?1:0)),d[1]=Math.min(Math.max(d[1],1),i),d}var j0=class{constructor(t,e){this._renderService=t,this._charSizeService=e}getCoords(t,e,s,n,i){return P$(window,t,e,s,n,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,i)}getMouseReportCoords(t,e){let s=Pu(window,t,e);if(this._charSizeService.hasValidSize)return s[0]=Math.min(Math.max(s[0],0),this._renderService.dimensions.css.canvas.width-1),s[1]=Math.min(Math.max(s[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(s[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(s[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(s[0]),y:Math.floor(s[1])}}};j0=At([Ee(0,On),Ee(1,Vc)],j0);var R$=class{constructor(t,e){this._renderCallback=t,this._coreBrowserService=e,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(t){return this._refreshCallbacks.push(t),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh())),this._animationFrame}refresh(t,e,s){this._rowCount=s,t=t!==void 0?t:0,e=e!==void 0?e:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,t):t,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,e):e,!this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0){this._runRefreshCallbacks();return}let t=Math.max(this._rowStart,0),e=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(t,e),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let t of this._refreshCallbacks)t(0);this._refreshCallbacks=[]}},a5={};UO(a5,{getSafariVersion:()=>I$,isChromeOS:()=>u5,isFirefox:()=>l5,isIpad:()=>M$,isIphone:()=>O$,isLegacyEdge:()=>D$,isLinux:()=>Ru,isMac:()=>Bl,isNode:()=>Nc,isSafari:()=>c5,isWindows:()=>d5});var Nc=typeof process<"u"&&"title"in process,pa=Nc?"node":navigator.userAgent,ga=Nc?"node":navigator.platform,l5=pa.includes("Firefox"),D$=pa.includes("Edge"),c5=/^((?!chrome|android).)*safari/i.test(pa);function I$(){if(!c5)return 0;let t=pa.match(/Version\/(\d+)/);return t===null||t.length<2?0:parseInt(t[1])}var Bl=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(ga),M$=ga==="iPad",O$=ga==="iPhone",d5=["Windows","Win16","Win32","WinCE"].includes(ga),Ru=ga.indexOf("Linux")>=0,u5=/\bCrOS\b/.test(pa),h5=class{constructor(){this._tasks=[],this._i=0}enqueue(t){this._tasks.push(t),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(t){this._idleCallback=void 0;let e=0,s=0,n=t.timeRemaining(),i=0;for(;this._i<this._tasks.length;){if(e=performance.now(),this._tasks[this._i]()||this._i++,e=Math.max(1,performance.now()-e),s=Math.max(e,s),i=t.timeRemaining(),s*1.5>i){n-e<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(n-e))}ms`),this._start();return}n=i}this.clear()}},B$=class extends h5{_requestCallback(t){return setTimeout(()=>t(this._createDeadline(16)))}_cancelCallback(t){clearTimeout(t)}_createDeadline(t){let e=performance.now()+t;return{timeRemaining:()=>Math.max(0,e-performance.now())}}},$$=class extends h5{_requestCallback(t){return requestIdleCallback(t)}_cancelCallback(t){cancelIdleCallback(t)}},$l=!Nc&&"requestIdleCallback"in window?$$:B$,F$=class{constructor(){this._queue=new $l}set(t){this._queue.clear(),this._queue.enqueue(t)}flush(){this._queue.flush()}},C0=class extends tt{constructor(t,e,s,n,i,o,a,l,c){super(),this._rowCount=t,this._optionsService=s,this._charSizeService=n,this._coreService=i,this._coreBrowserService=l,this._renderer=this._register(new Lr),this._pausedResizeTask=new F$,this._observerDisposable=this._register(new Lr),this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this._register(new Ce),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new Ce),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new Ce),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new Ce),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new R$((d,h)=>this._renderRows(d,h),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new z$(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(Lt(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(a.onResize(()=>this._fullRefresh())),this._register(a.buffers.onBufferActivate(()=>this._renderer.value?.clear())),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(o.onDecorationRegistered(()=>this._fullRefresh())),this._register(o.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(a.cols,a.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(a.buffer.y,a.buffer.y,!0))),this._register(c.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,e),this._register(this._coreBrowserService.onWindowChange(d=>this._registerIntersectionObserver(d,e)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(t,e){if("IntersectionObserver"in t){let s=new t.IntersectionObserver(n=>this._handleIntersectionChange(n[n.length-1]),{threshold:0});s.observe(e),this._observerDisposable.value=Lt(()=>s.disconnect())}}_handleIntersectionChange(t){this._isPaused=t.isIntersecting===void 0?t.intersectionRatio===0:!t.isIntersecting,!this._isPaused&&!this._charSizeService.hasValidSize&&this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(t,e,s=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(t,e);return}let n=this._syncOutputHandler.flush();n&&(t=Math.min(t,n.start),e=Math.max(e,n.end)),s||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(t,e,this._rowCount)}_renderRows(t,e){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(t,e);return}t=Math.min(t,this._rowCount-1),e=Math.min(e,this._rowCount-1),this._renderer.value.renderRows(t,e),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:t,end:e}),this._onRender.fire({start:t,end:e}),this._isNextRenderRedrawOnly=!0}}resize(t,e){this._rowCount=e,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(t){this._renderer.value=t,this._renderer.value&&(this._renderer.value.onRequestRedraw(e=>this.refreshRows(e.start,e.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(t){return this._renderDebouncer.addRefreshCallback(t)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){this._renderer.value&&(this._renderer.value.clearTextureAtlas?.(),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(t,e){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>this._renderer.value?.handleResize(t,e)):this._renderer.value.handleResize(t,e),this._fullRefresh())}handleCharSizeChanged(){this._renderer.value?.handleCharSizeChanged()}handleBlur(){this._renderer.value?.handleBlur()}handleFocus(){this._renderer.value?.handleFocus()}handleSelectionChanged(t,e,s){this._selectionState.start=t,this._selectionState.end=e,this._selectionState.columnSelectMode=s,this._renderer.value?.handleSelectionChanged(t,e,s)}handleCursorMove(){this._renderer.value?.handleCursorMove()}clear(){this._renderer.value?.clear()}};C0=At([Ee(2,js),Ee(3,Vc),Ee(4,Gi),Ee(5,ma),Ee(6,ws),Ee(7,Mn),Ee(8,zr)],C0);var z$=class{constructor(t,e,s){this._coreBrowserService=t,this._coreService=e,this._onTimeout=s,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(t,e){this._isBuffering?(this._start=Math.min(this._start,t),this._end=Math.max(this._end,e)):(this._start=t,this._end=e,this._isBuffering=!0),this._timeout===void 0&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let t={start:this._start,end:this._end};return this._isBuffering=!1,t}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function K$(t,e,s,n){let i=s.buffer.x,o=s.buffer.y;if(!s.buffer.hasScrollback)return W$(i,o,t,e,s,n)+Tc(o,e,s,n)+q$(i,o,t,e,s,n);let a;if(o===e)return a=i>t?"D":"C",qo(Math.abs(i-t),Wo(a,n));a=o>e?"D":"C";let l=Math.abs(o-e),c=H$(o>e?t:i,s)+(l-1)*s.cols+1+U$(o>e?i:t);return qo(c,Wo(a,n))}function U$(t,e){return t-1}function H$(t,e){return e.cols-t}function W$(t,e,s,n,i,o){return Tc(e,n,i,o).length===0?"":qo(m5(t,e,t,e-Ri(e,i),!1,i).length,Wo("D",o))}function Tc(t,e,s,n){let i=t-Ri(t,s),o=e-Ri(e,s),a=Math.abs(i-o)-G$(t,e,s);return qo(a,Wo(f5(t,e),n))}function q$(t,e,s,n,i,o){let a;Tc(e,n,i,o).length>0?a=n-Ri(n,i):a=e;let l=n,c=Y$(t,e,s,n,i,o);return qo(m5(t,a,s,l,c==="C",i).length,Wo(c,o))}function G$(t,e,s){let n=0,i=t-Ri(t,s),o=e-Ri(e,s);for(let a=0;a<Math.abs(i-o);a++){let l=f5(t,e)==="A"?-1:1;s.buffer.lines.get(i+l*a)?.isWrapped&&n++}return n}function Ri(t,e){let s=0,n=e.buffer.lines.get(t),i=n?.isWrapped;for(;i&&t>=0&&t<e.rows;)s++,n=e.buffer.lines.get(--t),i=n?.isWrapped;return s}function Y$(t,e,s,n,i,o){let a;return Tc(s,n,i,o).length>0?a=n-Ri(n,i):a=e,t<s&&a<=n||t>=s&&a<n?"C":"D"}function f5(t,e){return t>e?"A":"B"}function m5(t,e,s,n,i,o){let a=t,l=e,c="";for(;(a!==s||l!==n)&&l>=0&&l<o.buffer.lines.length;)a+=i?1:-1,i&&a>o.cols-1?(c+=o.buffer.translateBufferLineToString(l,!1,t,a),a=0,t=0,l++):!i&&a<0&&(c+=o.buffer.translateBufferLineToString(l,!1,0,t+1),a=o.cols-1,t=a,l--);return c+o.buffer.translateBufferLineToString(l,!1,t,a)}function Wo(t,e){let s=e?"O":"[";return be.ESC+s+t}function qo(t,e){t=Math.floor(t);let s="";for(let n=0;n<t;n++)s+=e;return s}var J$=class{constructor(t){this._bufferService=t,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:!this.selectionEnd||!this.selectionStart?this.selectionStart:this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){let t=this.selectionStart[0]+this.selectionStartLength;return t>this._bufferService.cols?t%this._bufferService.cols===0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(t/this._bufferService.cols)-1]:[t%this._bufferService.cols,this.selectionStart[1]+Math.floor(t/this._bufferService.cols)]:[t,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let t=this.selectionStart[0]+this.selectionStartLength;return t>this._bufferService.cols?[t%this._bufferService.cols,this.selectionStart[1]+Math.floor(t/this._bufferService.cols)]:[Math.max(t,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let t=this.selectionStart,e=this.selectionEnd;return!t||!e?!1:t[1]>e[1]||t[1]===e[1]&&t[0]>e[0]}handleTrim(t){return this.selectionStart&&(this.selectionStart[1]-=t),this.selectionEnd&&(this.selectionEnd[1]-=t),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}};function k1(t,e){if(t.start.y>t.end.y)throw new Error(`Buffer range end (${t.end.x}, ${t.end.y}) cannot be before start (${t.start.x}, ${t.start.y})`);return e*(t.end.y-t.start.y)+(t.end.x-t.start.x+1)}var bd=50,X$=15,Q$=50,Z$=500,eF=" ",tF=new RegExp(eF,"g"),k0=class extends tt{constructor(t,e,s,n,i,o,a,l,c){super(),this._element=t,this._screenElement=e,this._linkifier=s,this._bufferService=n,this._coreService=i,this._mouseService=o,this._optionsService=a,this._renderService=l,this._coreBrowserService=c,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new Gs,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new Ce),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new Ce),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new Ce),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new Ce),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=d=>this._handleMouseMove(d),this._mouseUpListener=d=>this._handleMouseUp(d),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(d=>this._handleTrim(d)),this._register(this._bufferService.buffers.onBufferActivate(d=>this._handleBufferActivate(d))),this.enable(),this._model=new J$(this._bufferService),this._activeSelectionMode=0,this._register(Lt(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(d=>{d.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let t=this._model.finalSelectionStart,e=this._model.finalSelectionEnd;return!t||!e?!1:t[0]!==e[0]||t[1]!==e[1]}get selectionText(){let t=this._model.finalSelectionStart,e=this._model.finalSelectionEnd;if(!t||!e)return"";let s=this._bufferService.buffer,n=[];if(this._activeSelectionMode===3){if(t[0]===e[0])return"";let i=t[0]<e[0]?t[0]:e[0],o=t[0]<e[0]?e[0]:t[0];for(let a=t[1];a<=e[1];a++){let l=s.translateBufferLineToString(a,!0,i,o);n.push(l)}}else{let i=t[1]===e[1]?e[0]:void 0;n.push(s.translateBufferLineToString(t[1],!0,t[0],i));for(let o=t[1]+1;o<=e[1]-1;o++){let a=s.lines.get(o),l=s.translateBufferLineToString(o,!0);a?.isWrapped?n[n.length-1]+=l:n.push(l)}if(t[1]!==e[1]){let o=s.lines.get(e[1]),a=s.translateBufferLineToString(e[1],!0,0,e[0]);o&&o.isWrapped?n[n.length-1]+=a:n.push(a)}}return n.map(i=>i.replace(tF," ")).join(d5?`\r
|
|
511
|
-
`:`
|
|
512
|
-
`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(t){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),Ru&&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,n=this._model.finalSelectionEnd;return!s||!n||!e?!1:this._areCoordsInSelection(e,s,n)}isCellInSelection(t,e){let s=this._model.finalSelectionStart,n=this._model.finalSelectionEnd;return!s||!n?!1:this._areCoordsInSelection([t,e],s,n)}_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=k1(s,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let n=this._getMouseBufferCoords(t);return n?(this._selectWordAt(n,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=Pu(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,-bd),bd),e/=bd,e/Math.abs(e)+Math.round(e*(X$-1)))}shouldForceSelection(t){return Bl?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(),Q$)}_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&&!(Bl&&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 n=s.lines.get(this._model.selectionEnd[1]);n&&n.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<Z$&&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 n=K$(s[0]-1,s[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(n,!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 n=0;e>=n;n++){let i=t.loadCell(n,this._workCell).getChars().length;this._workCell.getWidth()===0?s--:i>1&&e!==n&&(s+=i-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,n=!0){if(t[0]>=this._bufferService.cols)return;let i=this._bufferService.buffer,o=i.lines.get(t[1]);if(!o)return;let a=i.translateBufferLineToString(t[1],!1),l=this._convertViewportColToCharacterIndex(o,t[0]),c=l,d=t[0]-l,h=0,u=0,f=0,m=0;if(a.charAt(l)===" "){for(;l>0&&a.charAt(l-1)===" ";)l--;for(;c<a.length&&a.charAt(c+1)===" ";)c++}else{let x=t[0],v=t[0];o.getWidth(x)===0&&(h++,x--),o.getWidth(v)===2&&(u++,v++);let b=o.getString(v).length;for(b>1&&(m+=b-1,c+=b-1);x>0&&l>0&&!this._isCharWordSeparator(o.loadCell(x-1,this._workCell));){o.loadCell(x-1,this._workCell);let y=this._workCell.getChars().length;this._workCell.getWidth()===0?(h++,x--):y>1&&(f+=y-1,l-=y-1),l--,x--}for(;v<o.length&&c+1<a.length&&!this._isCharWordSeparator(o.loadCell(v+1,this._workCell));){o.loadCell(v+1,this._workCell);let y=this._workCell.getChars().length;this._workCell.getWidth()===2?(u++,v++):y>1&&(m+=y-1,c+=y-1),c++,v++}}c++;let p=l+d-h+f,g=Math.min(this._bufferService.cols,c-l+h+u-f-m);if(!(!e&&a.slice(l,c).trim()==="")){if(s&&p===0&&o.getCodePoint(0)!==32){let x=i.lines.get(t[1]-1);if(x&&o.isWrapped&&x.getCodePoint(this._bufferService.cols-1)!==32){let v=this._getWordAt([this._bufferService.cols-1,t[1]-1],!1,!0,!1);if(v){let b=this._bufferService.cols-v.start;p-=b,g+=b}}}if(n&&p+g===this._bufferService.cols&&o.getCodePoint(this._bufferService.cols-1)!==32){let x=i.lines.get(t[1]+1);if(x?.isWrapped&&x.getCodePoint(0)!==32){let v=this._getWordAt([0,t[1]+1],!1,!1,!0);v&&(g+=v.length)}}return{start:p,length:g}}}_selectWordAt(t,e){let s=this._getWordAt(t,e);if(s){for(;s.start<0;)s.start+=this._bufferService.cols,t[1]--;this._model.selectionStart=[s.start,t[1]],this._model.selectionStartLength=s.length}}_selectToWordAt(t){let e=this._getWordAt(t,!0);if(e){let s=t[1];for(;e.start<0;)e.start+=this._bufferService.cols,s--;if(!this._model.areSelectionValuesReversed())for(;e.start+e.length>this._bufferService.cols;)e.length-=this._bufferService.cols,s++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?e.start:e.start+e.length,s]}}_isCharWordSeparator(t){return t.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(t.getChars())>=0}_selectLineAt(t){let e=this._bufferService.buffer.getWrappedRangeForLine(t),s={start:{x:0,y:e.first},end:{x:this._bufferService.cols-1,y:e.last}};this._model.selectionStart=[0,e.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=k1(s,this._bufferService.cols)}};k0=At([Ee(3,ws),Ee(4,Gi),Ee(5,Cu),Ee(6,js),Ee(7,On),Ee(8,Mn)],k0);var V1=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={}}},N1=class{constructor(){this._color=new V1,this._css=new V1}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()}},Ot=Object.freeze((()=>{let t=[Ct.toColor("#2e3436"),Ct.toColor("#cc0000"),Ct.toColor("#4e9a06"),Ct.toColor("#c4a000"),Ct.toColor("#3465a4"),Ct.toColor("#75507b"),Ct.toColor("#06989a"),Ct.toColor("#d3d7cf"),Ct.toColor("#555753"),Ct.toColor("#ef2929"),Ct.toColor("#8ae234"),Ct.toColor("#fce94f"),Ct.toColor("#729fcf"),Ct.toColor("#ad7fa8"),Ct.toColor("#34e2e2"),Ct.toColor("#eeeeec")],e=[0,95,135,175,215,255];for(let s=0;s<216;s++){let n=e[s/36%6|0],i=e[s/6%6|0],o=e[s%6];t.push({css:It.toCss(n,i,o),rgba:It.toRgba(n,i,o)})}for(let s=0;s<24;s++){let n=8+s*10;t.push({css:It.toCss(n,n,n),rgba:It.toRgba(n,n,n)})}return t})()),fi=Ct.toColor("#ffffff"),ho=Ct.toColor("#000000"),T1=Ct.toColor("#ffffff"),A1=ho,Qr={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},sF=fi,V0=class extends tt{constructor(t){super(),this._optionsService=t,this._contrastCache=new N1,this._halfContrastCache=new N1,this._onChangeColors=this._register(new Ce),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:fi,background:ho,cursor:T1,cursorAccent:A1,selectionForeground:void 0,selectionBackgroundTransparent:Qr,selectionBackgroundOpaque:_t.blend(ho,Qr),selectionInactiveBackgroundTransparent:Qr,selectionInactiveBackgroundOpaque:_t.blend(ho,Qr),scrollbarSliderBackground:_t.opacity(fi,.2),scrollbarSliderHoverBackground:_t.opacity(fi,.4),scrollbarSliderActiveBackground:_t.opacity(fi,.5),overviewRulerBorder:fi,ansi:Ot.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=ut(t.foreground,fi),e.background=ut(t.background,ho),e.cursor=_t.blend(e.background,ut(t.cursor,T1)),e.cursorAccent=_t.blend(e.background,ut(t.cursorAccent,A1)),e.selectionBackgroundTransparent=ut(t.selectionBackground,Qr),e.selectionBackgroundOpaque=_t.blend(e.background,e.selectionBackgroundTransparent),e.selectionInactiveBackgroundTransparent=ut(t.selectionInactiveBackground,e.selectionBackgroundTransparent),e.selectionInactiveBackgroundOpaque=_t.blend(e.background,e.selectionInactiveBackgroundTransparent),e.selectionForeground=t.selectionForeground?ut(t.selectionForeground,w1):void 0,e.selectionForeground===w1&&(e.selectionForeground=void 0),_t.isOpaque(e.selectionBackgroundTransparent)&&(e.selectionBackgroundTransparent=_t.opacity(e.selectionBackgroundTransparent,.3)),_t.isOpaque(e.selectionInactiveBackgroundTransparent)&&(e.selectionInactiveBackgroundTransparent=_t.opacity(e.selectionInactiveBackgroundTransparent,.3)),e.scrollbarSliderBackground=ut(t.scrollbarSliderBackground,_t.opacity(e.foreground,.2)),e.scrollbarSliderHoverBackground=ut(t.scrollbarSliderHoverBackground,_t.opacity(e.foreground,.4)),e.scrollbarSliderActiveBackground=ut(t.scrollbarSliderActiveBackground,_t.opacity(e.foreground,.5)),e.overviewRulerBorder=ut(t.overviewRulerBorder,sF),e.ansi=Ot.slice(),e.ansi[0]=ut(t.black,Ot[0]),e.ansi[1]=ut(t.red,Ot[1]),e.ansi[2]=ut(t.green,Ot[2]),e.ansi[3]=ut(t.yellow,Ot[3]),e.ansi[4]=ut(t.blue,Ot[4]),e.ansi[5]=ut(t.magenta,Ot[5]),e.ansi[6]=ut(t.cyan,Ot[6]),e.ansi[7]=ut(t.white,Ot[7]),e.ansi[8]=ut(t.brightBlack,Ot[8]),e.ansi[9]=ut(t.brightRed,Ot[9]),e.ansi[10]=ut(t.brightGreen,Ot[10]),e.ansi[11]=ut(t.brightYellow,Ot[11]),e.ansi[12]=ut(t.brightBlue,Ot[12]),e.ansi[13]=ut(t.brightMagenta,Ot[13]),e.ansi[14]=ut(t.brightCyan,Ot[14]),e.ansi[15]=ut(t.brightWhite,Ot[15]),t.extendedAnsi){let s=Math.min(e.ansi.length-16,t.extendedAnsi.length);for(let n=0;n<s;n++)e.ansi[n+16]=ut(t.extendedAnsi[n],Ot[n+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()}}};V0=At([Ee(0,js)],V0);function ut(t,e){if(t!==void 0)try{return Ct.toColor(t)}catch{}return e}var nF=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)}},iF=class{constructor(){this._services=new nF,this._services.set(ju,this)}setService(t,e){this._services.set(t,e)}getService(t){return this._services.get(t)}createInstance(t,...e){let s=XO(t).sort((o,a)=>o.index-a.index),n=[];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}.`);n.push(a)}let i=s.length>0?s[0].index:e.length;if(e.length!==i)throw new Error(`[createInstance] First service dependency of ${t.name} at position ${i+1} conflicts with ${e.length} static arguments`);return new t(...e,...n)}},rF={trace:0,debug:1,info:2,warn:3,error:4,off:5},oF="xterm.js: ",N0=class extends tt{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=rF[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?"":oF)+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)}};N0=At([Ee(0,js)],N0);var E1=class extends tt{constructor(t){super(),this._maxLength=t,this.onDeleteEmitter=this._register(new Ce),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new Ce),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new Ce),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 n=t;n<this._length-e;n++)this._array[this._getCyclicIndex(n)]=this._array[this._getCyclicIndex(n+e)];this._length-=e,this.onDeleteEmitter.fire({index:t,amount:e})}for(let n=this._length-1;n>=t;n--)this._array[this._getCyclicIndex(n+s.length)]=this._array[this._getCyclicIndex(n)];for(let n=0;n<s.length;n++)this._array[this._getCyclicIndex(t+n)]=s[n];if(s.length&&this.onInsertEmitter.fire({index:t,amount:s.length}),this._length+s.length>this._maxLength){let n=this._length+s.length-this._maxLength;this._startIndex+=n,this._length=this._maxLength,this.onTrimEmitter.fire(n)}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 i=e-1;i>=0;i--)this.set(t+i+s,this.get(t+i));let n=t+e+s-this._length;if(n>0)for(this._length+=n;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let n=0;n<e;n++)this.set(t+n+s,this.get(t+n))}}_getCyclicIndex(t){return(this._startIndex+t)%this._maxLength}},Ze=3,Dt=Object.freeze(new fa),$a=0,_d=2,fo=class p5{constructor(e,s,n=!1){this.isWrapped=n,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(e*Ze);let i=s||Gs.fromCharData([0,R4,1,0]);for(let o=0;o<e;++o)this.setCell(o,i);this.length=e}get(e){let s=this._data[e*Ze+0],n=s&2097151;return[this._data[e*Ze+1],s&2097152?this._combined[e]:n?Un(n):"",s>>22,s&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):n]}set(e,s){this._data[e*Ze+1]=s[0],s[1].length>1?(this._combined[e]=s[1],this._data[e*Ze+0]=e|2097152|s[2]<<22):this._data[e*Ze+0]=s[1].charCodeAt(0)|s[2]<<22}getWidth(e){return this._data[e*Ze+0]>>22}hasWidth(e){return this._data[e*Ze+0]&12582912}getFg(e){return this._data[e*Ze+1]}getBg(e){return this._data[e*Ze+2]}hasContent(e){return this._data[e*Ze+0]&4194303}getCodePoint(e){let s=this._data[e*Ze+0];return s&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):s&2097151}isCombined(e){return this._data[e*Ze+0]&2097152}getString(e){let s=this._data[e*Ze+0];return s&2097152?this._combined[e]:s&2097151?Un(s&2097151):""}isProtected(e){return this._data[e*Ze+2]&536870912}loadCell(e,s){return $a=e*Ze,s.content=this._data[$a+0],s.fg=this._data[$a+1],s.bg=this._data[$a+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*Ze+0]=s.content,this._data[e*Ze+1]=s.fg,this._data[e*Ze+2]=s.bg}setCellFromCodepoint(e,s,n,i){i.bg&268435456&&(this._extendedAttrs[e]=i.extended),this._data[e*Ze+0]=s|n<<22,this._data[e*Ze+1]=i.fg,this._data[e*Ze+2]=i.bg}addCodepointToCell(e,s,n){let i=this._data[e*Ze+0];i&2097152?this._combined[e]+=Un(s):i&2097151?(this._combined[e]=Un(i&2097151)+Un(s),i&=-2097152,i|=2097152):i=s|1<<22,n&&(i&=-12582913,i|=n<<22),this._data[e*Ze+0]=i}insertCells(e,s,n){if(e%=this.length,e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,n),s<this.length-e){let i=new Gs;for(let o=this.length-e-s-1;o>=0;--o)this.setCell(e+s+o,this.loadCell(e+o,i));for(let o=0;o<s;++o)this.setCell(e+o,n)}else for(let i=e;i<this.length;++i)this.setCell(i,n);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,n)}deleteCells(e,s,n){if(e%=this.length,s<this.length-e){let i=new Gs;for(let o=0;o<this.length-e-s;++o)this.setCell(e+o,this.loadCell(e+s+o,i));for(let o=this.length-s;o<this.length;++o)this.setCell(o,n)}else for(let i=e;i<this.length;++i)this.setCell(i,n);e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,n),this.getWidth(e)===0&&!this.hasContent(e)&&this.setCellFromCodepoint(e,0,1,n)}replaceCells(e,s,n,i=!1){if(i){for(e&&this.getWidth(e-1)===2&&!this.isProtected(e-1)&&this.setCellFromCodepoint(e-1,0,1,n),s<this.length&&this.getWidth(s-1)===2&&!this.isProtected(s)&&this.setCellFromCodepoint(s,0,1,n);e<s&&e<this.length;)this.isProtected(e)||this.setCell(e,n),e++;return}for(e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,n),s<this.length&&this.getWidth(s-1)===2&&this.setCellFromCodepoint(s,0,1,n);e<s&&e<this.length;)this.setCell(e++,n)}resize(e,s){if(e===this.length)return this._data.length*4*_d<this._data.buffer.byteLength;let n=e*Ze;if(e>this.length){if(this._data.buffer.byteLength>=n*4)this._data=new Uint32Array(this._data.buffer,0,n);else{let i=new Uint32Array(n);i.set(this._data),this._data=i}for(let i=this.length;i<e;++i)this.setCell(i,s)}else{this._data=this._data.subarray(0,n);let i=Object.keys(this._combined);for(let a=0;a<i.length;a++){let l=parseInt(i[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,n*4*_d<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*_d<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 n=0;n<this.length;++n)this.isProtected(n)||this.setCell(n,e);return}this._combined={},this._extendedAttrs={};for(let n=0;n<this.length;++n)this.setCell(n,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 p5(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*Ze+0]&4194303)return e+(this._data[e*Ze+0]>>22);return 0}getNoBgTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*Ze+0]&4194303||this._data[e*Ze+2]&50331648)return e+(this._data[e*Ze+0]>>22);return 0}copyCellsFrom(e,s,n,i,o){let a=e._data;if(o)for(let c=i-1;c>=0;c--){for(let d=0;d<Ze;d++)this._data[(n+c)*Ze+d]=a[(s+c)*Ze+d];a[(s+c)*Ze+2]&268435456&&(this._extendedAttrs[n+c]=e._extendedAttrs[s+c])}else for(let c=0;c<i;c++){for(let d=0;d<Ze;d++)this._data[(n+c)*Ze+d]=a[(s+c)*Ze+d];a[(s+c)*Ze+2]&268435456&&(this._extendedAttrs[n+c]=e._extendedAttrs[s+c])}let l=Object.keys(e._combined);for(let c=0;c<l.length;c++){let d=parseInt(l[c],10);d>=s&&(this._combined[d-s+n]=e._combined[d])}}translateToString(e,s,n,i){s=s??0,n=n??this.length,e&&(n=Math.min(n,this.getTrimmedLength())),i&&(i.length=0);let o="";for(;s<n;){let a=this._data[s*Ze+0],l=a&2097151,c=a&2097152?this._combined[s]:l?Un(l):Wn;if(o+=c,i)for(let d=0;d<c.length;++d)i.push(s);s+=a>>22||1}return i&&i.push(s),o}};function aF(t,e,s,n,i,o){let a=[];for(let l=0;l<t.length-1;l++){let c=l,d=t.get(++c);if(!d.isWrapped)continue;let h=[t.get(l)];for(;c<t.length&&d.isWrapped;)h.push(d),d=t.get(++c);if(!o&&n>=l&&n<c){l+=h.length-1;continue}let u=0,f=Go(h,u,e),m=1,p=0;for(;m<h.length;){let x=Go(h,m,e),v=x-p,b=s-f,y=Math.min(v,b);h[u].copyCellsFrom(h[m],p,f,y,!1),f+=y,f===s&&(u++,f=0),p+=y,p===x&&(m++,p=0),f===0&&u!==0&&h[u-1].getWidth(s-1)===2&&(h[u].copyCellsFrom(h[u-1],s-1,f++,1,!1),h[u-1].setCell(s-1,i))}h[u].replaceCells(f,s,i);let g=0;for(let x=h.length-1;x>0&&(x>u||h[x].getTrimmedLength()===0);x--)g++;g>0&&(a.push(l+h.length-g),a.push(g)),l+=h.length-1}return a}function lF(t,e){let s=[],n=0,i=e[n],o=0;for(let a=0;a<t.length;a++)if(i===a){let l=e[++n];t.onDeleteEmitter.fire({index:a-o,amount:l}),a+=l-1,o+=l,i=e[++n]}else s.push(a);return{layout:s,countRemoved:o}}function cF(t,e){let s=[];for(let n=0;n<e.length;n++)s.push(t.get(e[n]));for(let n=0;n<s.length;n++)t.set(n,s[n]);t.length=e.length}function dF(t,e,s){let n=[],i=t.map((c,d)=>Go(t,d,e)).reduce((c,d)=>c+d),o=0,a=0,l=0;for(;l<i;){if(i-l<s){n.push(i-l);break}o+=s;let c=Go(t,a,e);o>c&&(o-=c,a++);let d=t[a].getWidth(o-1)===2;d&&o--;let h=d?s-1:s;n.push(h),l+=h}return n}function Go(t,e,s){if(e===t.length-1)return t[e].getTrimmedLength();let n=!t[e].hasContent(s-1)&&t[e].getWidth(s-1)===1,i=t[e+1].getWidth(0)===2;return n&&i?s-1:s}var g5=class x5{constructor(e){this.line=e,this.isDisposed=!1,this._disposables=[],this._id=x5._nextId++,this._onDispose=this.register(new Ce),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),Pi(this._disposables),this._disposables.length=0)}register(e){return this._disposables.push(e),e}};g5._nextId=1;var uF=g5,Kt={},mi=Kt.B;Kt[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:"≥","{":"π","|":"≠","}":"£","~":"·"};Kt.A={"#":"£"};Kt.B=void 0;Kt[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};Kt.C=Kt[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Kt.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};Kt.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};Kt.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};Kt.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};Kt.E=Kt[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};Kt.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};Kt.H=Kt[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Kt["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var P1=4294967295,R1=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=Dt.clone(),this.savedCharset=mi,this.markers=[],this._nullCell=Gs.fromCharData([0,R4,1,0]),this._whitespaceCell=Gs.fromCharData([0,Wn,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new $l,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new E1(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 Il),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 Il),this._whitespaceCell}getBlankLine(t,e){return new fo(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>P1?P1:e}fillViewportRows(t){if(this.lines.length===0){t===void 0&&(t=Dt);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 E1(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(t,e){let s=this.getNullCell(Dt),n=0,i=this._getCorrectBufferLength(e);if(i>this.lines.maxLength&&(this.lines.maxLength=i),this.lines.length>0){if(this._cols<t)for(let a=0;a<this.lines.length;a++)n+=+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 fo(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 fo(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(i<this.lines.maxLength){let a=this.lines.length-i;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=i}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++)n+=+this.lines.get(o).resize(t,s);this._cols=t,this._rows=e,this._memoryCleanupQueue.clear(),n>.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,n=aF(this.lines,this._cols,t,this.ybase+this.y,this.getNullCell(Dt),s);if(n.length>0){let i=lF(this.lines,n);cF(this.lines,i.layout),this._reflowLargerAdjustViewport(t,e,i.countRemoved)}}_reflowLargerAdjustViewport(t,e,s){let n=this.getNullCell(Dt),i=s;for(;i-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<e&&this.lines.push(new fo(t,n))):(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,n=this.getNullCell(Dt),i=[],o=0;for(let a=this.lines.length-1;a>=0;a--){let l=this.lines.get(a);if(!l||!l.isWrapped&&l.getTrimmedLength()<=t)continue;let c=[l];for(;l.isWrapped&&a>0;)l=this.lines.get(--a),c.unshift(l);if(!s){let y=this.ybase+this.y;if(y>=a&&y<a+c.length)continue}let d=c[c.length-1].getTrimmedLength(),h=dF(c,this._cols,t),u=h.length-c.length,f;this.ybase===0&&this.y!==this.lines.length-1?f=Math.max(0,this.y-this.lines.maxLength+u):f=Math.max(0,this.lines.length-this.lines.maxLength+u);let m=[];for(let y=0;y<u;y++){let _=this.getBlankLine(Dt,!0);m.push(_)}m.length>0&&(i.push({start:a+c.length+o,newLines:m}),o+=m.length),c.push(...m);let p=h.length-1,g=h[p];g===0&&(p--,g=h[p]);let x=c.length-u-1,v=d;for(;x>=0;){let y=Math.min(v,g);if(c[p]===void 0)break;if(c[p].copyCellsFrom(c[x],v-y,g-y,y,!0),g-=y,g===0&&(p--,g=h[p]),v-=y,v===0){x--;let _=Math.max(x,0);v=Go(c,_,this._cols)}}for(let y=0;y<c.length;y++)h[y]<t&&c[y].setCell(h[y],n);let b=u-f;for(;b-- >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(i.length>0){let a=[],l=[];for(let g=0;g<this.lines.length;g++)l.push(this.lines.get(g));let c=this.lines.length,d=c-1,h=0,u=i[h];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+o);let f=0;for(let g=Math.min(this.lines.maxLength-1,c+o-1);g>=0;g--)if(u&&u.start>d+f){for(let x=u.newLines.length-1;x>=0;x--)this.lines.set(g--,u.newLines[x]);g++,a.push({index:d+1,amount:u.newLines.length}),f+=u.newLines.length,u=i[++h]}else this.lines.set(g,l[d--]);let m=0;for(let g=a.length-1;g>=0;g--)a[g].index+=m,this.lines.onInsertEmitter.fire(a[g]),m+=a[g].amount;let p=Math.max(0,c+o-this.lines.maxLength);p>0&&this.lines.onTrimEmitter.fire(p)}}translateBufferLineToString(t,e,s=0,n){let i=this.lines.get(t);return i?i.translateToString(e,s,n):""}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 uF(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)}},hF=class extends tt{constructor(t,e){super(),this._optionsService=t,this._bufferService=e,this._onBufferActivate=this._register(new Ce),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 R1(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new R1(!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)}},v5=2,b5=1,T0=class extends tt{constructor(t){super(),this.isUserScrolling=!1,this._onResize=this._register(new Ce),this.onResize=this._onResize.event,this._onScroll=this._register(new Ce),this.onScroll=this._onScroll.event,this.cols=Math.max(t.rawOptions.cols||0,v5),this.rows=Math.max(t.rawOptions.rows||0,b5),this.buffers=this._register(new hF(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,n=this.rows!==e;this.cols=t,this.rows=e,this.buffers.resize(t,e),this._onResize.fire({cols:t,rows:e,colsChanged:s,rowsChanged:n})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(t,e=!1){let s=this.buffer,n;n=this._cachedBlankLine,(!n||n.length!==this.cols||n.getFg(0)!==t.fg||n.getBg(0)!==t.bg)&&(n=s.getBlankLine(t,e),this._cachedBlankLine=n),n.isWrapped=e;let i=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(n):s.lines.push(n.clone()):s.lines.splice(o+1,0,n.clone()),a?this.isUserScrolling&&(s.ydisp=Math.max(s.ydisp-1,0)):(s.ybase++,this.isUserScrolling||s.ydisp++)}else{let a=o-i+1;s.lines.shiftElements(i+1,a-1,-1),s.lines.set(o,n.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 n=s.ydisp;s.ydisp=Math.max(Math.min(s.ydisp+t,s.ybase),0),n!==s.ydisp&&(e||this._onScroll.fire(s.ydisp))}};T0=At([Ee(0,js)],T0);var Qi={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:Bl,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},fF=["normal","bold","100","200","300","400","500","600","700","800","900"],mF=class extends tt{constructor(t){super(),this._onOptionChange=this._register(new Ce),this.onOptionChange=this._onOptionChange.event;let e={...Qi};for(let s in t)if(s in e)try{let n=t[s];e[s]=this._sanitizeAndValidateOption(s,n)}catch(n){console.error(n)}this.rawOptions=e,this.options={...e},this._setupOptions(),this._register(Lt(()=>{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 Qi))throw new Error(`No option with key "${s}"`);return this.rawOptions[s]},e=(s,n)=>{if(!(s in Qi))throw new Error(`No option with key "${s}"`);n=this._sanitizeAndValidateOption(s,n),this.rawOptions[s]!==n&&(this.rawOptions[s]=n,this._onOptionChange.fire(s))};for(let s in this.rawOptions){let n={get:t.bind(this,s),set:e.bind(this,s)};Object.defineProperty(this.options,s,n)}}_sanitizeAndValidateOption(t,e){switch(t){case"cursorStyle":if(e||(e=Qi[t]),!pF(e))throw new Error(`"${e}" is not a valid value for ${t}`);break;case"wordSeparator":e||(e=Qi[t]);break;case"fontWeight":case"fontWeightBold":if(typeof e=="number"&&1<=e&&e<=1e3)break;e=fF.includes(e)?e:Qi[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 pF(t){return t==="block"||t==="underline"||t==="bar"}function mo(t,e=5){if(typeof t!="object")return t;let s=Array.isArray(t)?[]:{};for(let n in t)s[n]=e<=1?t[n]:t[n]&&mo(t[n],e-1);return s}var D1=Object.freeze({insertMode:!1}),I1=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),A0=class extends tt{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 Ce),this.onData=this._onData.event,this._onUserInput=this._register(new Ce),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new Ce),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new Ce),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=mo(D1),this.decPrivateModes=mo(I1)}reset(){this.modes=mo(D1),this.decPrivateModes=mo(I1)}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(n=>n.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))}};A0=At([Ee(0,ws),Ee(1,B4),Ee(2,js)],A0);var M1={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 yd(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 Ld=String.fromCharCode,O1={DEFAULT:t=>{let e=[yd(t,!1)+32,t.col+32,t.row+32];return e[0]>255||e[1]>255||e[2]>255?"":`\x1B[M${Ld(e[0])}${Ld(e[1])}${Ld(e[2])}`},SGR:t=>{let e=t.action===0&&t.button!==4?"m":"M";return`\x1B[<${yd(t,!0)};${t.col};${t.row}${e}`},SGR_PIXELS:t=>{let e=t.action===0&&t.button!==4?"m":"M";return`\x1B[<${yd(t,!0)};${t.x};${t.y}${e}`}},E0=class extends tt{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 Ce),this.onProtocolChange=this._onProtocolChange.event;for(let n of Object.keys(M1))this.addProtocol(n,M1[n]);for(let n of Object.keys(O1))this.addEncoding(n,O1[n]);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 n=e/s,i=this._applyScrollModifier(t.deltaY,t);return t.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(i/=n+0,Math.abs(t.deltaY)<50&&(i*=.3),this._wheelPartialScroll+=i,i=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):t.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(i*=this._bufferService.rows),i}_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)}};E0=At([Ee(0,ws),Ee(1,Gi),Ee(2,js)],E0);var Sd=[[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]],gF=[[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]],Bt;function xF(t,e){let s=0,n=e.length-1,i;if(t<e[0][0]||t>e[n][1])return!1;for(;n>=s;)if(i=s+n>>1,t>e[i][1])s=i+1;else if(t<e[i][0])n=i-1;else return!0;return!1}var vF=class{constructor(){if(this.version="6",!Bt){Bt=new Uint8Array(65536),Bt.fill(1),Bt[0]=0,Bt.fill(0,1,32),Bt.fill(0,127,160),Bt.fill(2,4352,4448),Bt[9001]=2,Bt[9002]=2,Bt.fill(2,11904,42192),Bt[12351]=1,Bt.fill(2,44032,55204),Bt.fill(2,63744,64256),Bt.fill(2,65040,65050),Bt.fill(2,65072,65136),Bt.fill(2,65280,65377),Bt.fill(2,65504,65511);for(let t=0;t<Sd.length;++t)Bt.fill(0,Sd[t][0],Sd[t][1]+1)}}wcwidth(t){return t<32?0:t<127?1:t<65536?Bt[t]:xF(t,gF)?0:t>=131072&&t<=196605||t>=196608&&t<=262141?2:1}charProperties(t,e){let s=this.wcwidth(t),n=s===0&&e!==0;if(n){let i=bi.extractWidth(e);i===0?n=!1:i>s&&(s=i)}return bi.createPropertyValue(0,s,n)}},bi=class Qa{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new Ce,this.onChange=this._onChange.event;let e=new vF;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,n=!1){return(e&16777215)<<3|(s&3)<<1|(n?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,n=0,i=e.length;for(let o=0;o<i;++o){let a=e.charCodeAt(o);if(55296<=a&&a<=56319){if(++o>=i)return s+this.wcwidth(a);let d=e.charCodeAt(o);56320<=d&&d<=57343?a=(a-55296)*1024+d-56320+65536:s+=this.wcwidth(d)}let l=this.charProperties(a,n),c=Qa.extractWidth(l);Qa.extractShouldJoin(l)&&(c-=Qa.extractWidth(n)),s+=c,n=l}return s}charProperties(e,s){return this._activeProvider.charProperties(e,s)}},bF=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 B1(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 Zr=2147483647,_F=256,_5=class P0{constructor(e=32,s=32){if(this.maxLength=e,this.maxSubParamsLength=s,s>_F)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 P0;if(!e.length)return s;for(let n=Array.isArray(e[0])?1:0;n<e.length;++n){let i=e[n];if(Array.isArray(i))for(let o=0;o<i.length;++o)s.addSubParam(i[o]);else s.addParam(i)}return s}clone(){let e=new P0(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 n=this._subParamsIdx[s]>>8,i=this._subParamsIdx[s]&255;i-n>0&&e.push(Array.prototype.slice.call(this._subParams,n,i))}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>Zr?Zr: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>Zr?Zr: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,n=this._subParamsIdx[e]&255;return n-s>0?this._subParams.subarray(s,n):null}getSubParamsAll(){let e={};for(let s=0;s<this.length;++s){let n=this._subParamsIdx[s]>>8,i=this._subParamsIdx[s]&255;i-n>0&&(e[s]=this._subParams.slice(n,i))}return e}addDigit(e){let s;if(this._rejectDigits||!(s=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let n=this._digitIsSub?this._subParams:this.params,i=n[s-1];n[s-1]=~i?Math.min(i*10+e,Zr):e}},eo=[],yF=class{constructor(){this._state=0,this._active=eo,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 n=s.indexOf(e);n!==-1&&s.splice(n,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=eo}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=eo,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||eo,!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",kc(t,e,s));else for(let n=this._active.length-1;n>=0;n--)this._active[n].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 n=t[e++];if(n===59){this._state=2,this._start();break}if(n<48||57<n){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+n-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,n=this._active.length-1,i=!1;if(this._stack.paused&&(n=this._stack.loopPosition-1,s=e,i=this._stack.fallThrough,this._stack.paused=!1),!i&&s===!1){for(;n>=0&&(s=this._active[n].end(t),s!==!0);n--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=n,this._stack.fallThrough=!1,s;n--}for(;n>=0;n--)if(s=this._active[n].end(!1),s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=n,this._stack.fallThrough=!0,s}this._active=eo,this._id=-1,this._state=0}}},Ds=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+=kc(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}},to=[],LF=class{constructor(){this._handlers=Object.create(null),this._active=to,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=to}registerHandler(t,e){this._handlers[t]===void 0&&(this._handlers[t]=[]);let s=this._handlers[t];return s.push(e),{dispose:()=>{let n=s.indexOf(e);n!==-1&&s.splice(n,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=to,this._ident=0}hook(t,e){if(this.reset(),this._ident=t,this._active=this._handlers[t]||to,!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",kc(t,e,s));else for(let n=this._active.length-1;n>=0;n--)this._active[n].put(t,e,s)}unhook(t,e=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",t);else{let s=!1,n=this._active.length-1,i=!1;if(this._stack.paused&&(n=this._stack.loopPosition-1,s=e,i=this._stack.fallThrough,this._stack.paused=!1),!i&&s===!1){for(;n>=0&&(s=this._active[n].unhook(t),s!==!0);n--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=n,this._stack.fallThrough=!1,s;n--}for(;n>=0;n--)if(s=this._active[n].unhook(!1),s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=n,this._stack.fallThrough=!0,s}this._active=to,this._ident=0}},po=new _5;po.addParam(0);var $1=class{constructor(t){this._handler=t,this._data="",this._params=po,this._hitLimit=!1}hook(t){this._params=t.length>1||t.params[0]?t.clone():po,this._data="",this._hitLimit=!1}put(t,e,s){this._hitLimit||(this._data+=kc(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=po,this._data="",this._hitLimit=!1,s));return this._params=po,this._data="",this._hitLimit=!1,e}},SF=class{constructor(t){this.table=new Uint8Array(t)}setDefault(t,e){this.table.fill(t<<4|e)}add(t,e,s,n){this.table[e<<8|t]=s<<4|n}addMany(t,e,s,n){for(let i=0;i<t.length;i++)this.table[e<<8|t[i]]=s<<4|n}},qs=160,wF=(function(){let t=new SF(4095),e=Array.apply(null,Array(256)).map((l,c)=>c),s=(l,c)=>e.slice(l,c),n=s(32,127),i=s(0,24);i.push(25),i.push.apply(i,s(28,32));let o=s(0,14),a;t.setDefault(1,0),t.addMany(n,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(i,0,3,0),t.addMany(i,1,3,1),t.add(127,1,0,1),t.addMany(i,8,0,8),t.addMany(i,3,3,3),t.add(127,3,0,3),t.addMany(i,4,3,4),t.add(127,4,0,4),t.addMany(i,6,3,6),t.addMany(i,5,3,5),t.add(127,5,0,5),t.addMany(i,2,3,2),t.add(127,2,0,2),t.add(93,1,4,8),t.addMany(n,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(n,7,0,7),t.addMany(i,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(i,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(i,11,0,11),t.addMany(s(32,128),11,0,11),t.addMany(s(28,32),11,0,11),t.addMany(i,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(i,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(i,13,13,13),t.addMany(n,13,13,13),t.add(127,13,0,13),t.addMany([27,156,24,26],13,14,0),t.add(qs,0,2,0),t.add(qs,8,5,8),t.add(qs,6,0,6),t.add(qs,11,0,11),t.add(qs,13,13,13),t})(),jF=class extends tt{constructor(t=wF){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 _5,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(e,s,n)=>{},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(Lt(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new yF),this._dcsParser=this._register(new LF),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 i=0;i<t.intermediates.length;++i){let o=t.intermediates.charCodeAt(i);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 n=t.final.charCodeAt(0);if(e[0]>n||n>e[1])throw new Error(`final must be in range ${e[0]} .. ${e[1]}`);return s<<=8,s|=n,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 n=this._escHandlers[s];return n.push(e),{dispose:()=>{let i=n.indexOf(e);i!==-1&&n.splice(i,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 n=this._csiHandlers[s];return n.push(e),{dispose:()=>{let i=n.indexOf(e);i!==-1&&n.splice(i,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,n,i){this._parseStack.state=t,this._parseStack.handlers=e,this._parseStack.handlerPos=s,this._parseStack.transition=n,this._parseStack.chunkPos=i}parse(t,e,s){let n=0,i=0,o=0,a;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,o=this._parseStack.chunkPos+1;else{if(s===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let l=this._parseStack.handlers,c=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(s===!1&&c>-1){for(;c>=0&&(a=l[c](this._params),a!==!0);c--)if(a instanceof Promise)return this._parseStack.handlerPos=c,a}this._parseStack.handlers=[];break;case 4:if(s===!1&&c>-1){for(;c>=0&&(a=l[c](),a!==!0);c--)if(a instanceof Promise)return this._parseStack.handlerPos=c,a}this._parseStack.handlers=[];break;case 6:if(n=t[this._parseStack.chunkPos],a=this._dcsParser.unhook(n!==24&&n!==26,s),a)return a;n===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(n=t[this._parseStack.chunkPos],a=this._oscParser.end(n!==24&&n!==26,s),a)return a;n===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(n=t[l],i=this._transitions.table[this.currentState<<8|(n<160?n:qs)],i>>4){case 2:for(let f=l+1;;++f){if(f>=e||(n=t[f])<32||n>126&&n<qs){this._printHandler(t,l,f),l=f-1;break}if(++f>=e||(n=t[f])<32||n>126&&n<qs){this._printHandler(t,l,f),l=f-1;break}if(++f>=e||(n=t[f])<32||n>126&&n<qs){this._printHandler(t,l,f),l=f-1;break}if(++f>=e||(n=t[f])<32||n>126&&n<qs){this._printHandler(t,l,f),l=f-1;break}}break;case 3:this._executeHandlers[n]?this._executeHandlers[n]():this._executeHandlerFb(n),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:l,code:n,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let c=this._csiHandlers[this._collect<<8|n],d=c?c.length-1:-1;for(;d>=0&&(a=c[d](this._params),a!==!0);d--)if(a instanceof Promise)return this._preserveStack(3,c,d,i,l),a;d<0&&this._csiHandlerFb(this._collect<<8|n,this._params),this.precedingJoinState=0;break;case 8:do switch(n){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(n-48)}while(++l<e&&(n=t[l])>47&&n<60);l--;break;case 9:this._collect<<=8,this._collect|=n;break;case 10:let h=this._escHandlers[this._collect<<8|n],u=h?h.length-1:-1;for(;u>=0&&(a=h[u](),a!==!0);u--)if(a instanceof Promise)return this._preserveStack(4,h,u,i,l),a;u<0&&this._escHandlerFb(this._collect<<8|n),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|n,this._params);break;case 13:for(let f=l+1;;++f)if(f>=e||(n=t[f])===24||n===26||n===27||n>127&&n<qs){this._dcsParser.put(t,l,f),l=f-1;break}break;case 14:if(a=this._dcsParser.unhook(n!==24&&n!==26),a)return this._preserveStack(6,[],0,i,l),a;n===27&&(i|=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||(n=t[f])<32||n>127&&n<qs){this._oscParser.put(t,l,f),l=f-1;break}break;case 6:if(a=this._oscParser.end(n!==24&&n!==26),a)return this._preserveStack(5,[],0,i,l),a;n===27&&(i|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=i&15}}},CF=/^([\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})$/,kF=/^[\da-f]+$/;function F1(t){if(!t)return;let e=t.toLowerCase();if(e.indexOf("rgb:")===0){e=e.slice(4);let s=CF.exec(e);if(s){let n=s[1]?15:s[4]?255:s[7]?4095:65535;return[Math.round(parseInt(s[1]||s[4]||s[7]||s[10],16)/n*255),Math.round(parseInt(s[2]||s[5]||s[8]||s[11],16)/n*255),Math.round(parseInt(s[3]||s[6]||s[9]||s[12],16)/n*255)]}}else if(e.indexOf("#")===0&&(e=e.slice(1),kF.exec(e)&&[3,6,9,12].includes(e.length))){let s=e.length/3,n=[0,0,0];for(let i=0;i<3;++i){let o=parseInt(e.slice(s*i,s*i+s),16);n[i]=s===1?o<<4:s===2?o:s===3?o>>4:o>>8}return n}}function wd(t,e){let s=t.toString(16),n=s.length<2?"0"+s:s;switch(e){case 4:return s[0];case 8:return n;case 12:return(n+n).slice(0,3);default:return n+n}}function VF(t,e=16){let[s,n,i]=t;return`rgb:${wd(s,e)}/${wd(n,e)}/${wd(i,e)}`}var NF={"(":0,")":1,"*":2,"+":3,"-":1,".":2},zn=131072,z1=10;function K1(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 U1=5e3,H1=0,TF=class extends tt{constructor(t,e,s,n,i,o,a,l,c=new jF){super(),this._bufferService=t,this._charsetService=e,this._coreService=s,this._logService=n,this._optionsService=i,this._oscLinkService=o,this._coreMouseService=a,this._unicodeService=l,this._parser=c,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new YO,this._utf8Decoder=new JO,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=Dt.clone(),this._eraseAttrDataInternal=Dt.clone(),this._onRequestBell=this._register(new Ce),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new Ce),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new Ce),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new Ce),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new Ce),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new Ce),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new Ce),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new Ce),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new Ce),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new Ce),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new Ce),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new Ce),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new Ce),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 R0(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(d=>this._activeBuffer=d.activeBuffer)),this._parser.setCsiHandlerFallback((d,h)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(d),params:h.toArray()})}),this._parser.setEscHandlerFallback(d=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(d)})}),this._parser.setExecuteHandlerFallback(d=>{this._logService.debug("Unknown EXECUTE code: ",{code:d})}),this._parser.setOscHandlerFallback((d,h,u)=>{this._logService.debug("Unknown OSC code: ",{identifier:d,action:h,data:u})}),this._parser.setDcsHandlerFallback((d,h,u)=>{h==="HOOK"&&(u=u.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(d),action:h,payload:u})}),this._parser.setPrintHandler((d,h,u)=>this.print(d,h,u)),this._parser.registerCsiHandler({final:"@"},d=>this.insertChars(d)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},d=>this.scrollLeft(d)),this._parser.registerCsiHandler({final:"A"},d=>this.cursorUp(d)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},d=>this.scrollRight(d)),this._parser.registerCsiHandler({final:"B"},d=>this.cursorDown(d)),this._parser.registerCsiHandler({final:"C"},d=>this.cursorForward(d)),this._parser.registerCsiHandler({final:"D"},d=>this.cursorBackward(d)),this._parser.registerCsiHandler({final:"E"},d=>this.cursorNextLine(d)),this._parser.registerCsiHandler({final:"F"},d=>this.cursorPrecedingLine(d)),this._parser.registerCsiHandler({final:"G"},d=>this.cursorCharAbsolute(d)),this._parser.registerCsiHandler({final:"H"},d=>this.cursorPosition(d)),this._parser.registerCsiHandler({final:"I"},d=>this.cursorForwardTab(d)),this._parser.registerCsiHandler({final:"J"},d=>this.eraseInDisplay(d,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},d=>this.eraseInDisplay(d,!0)),this._parser.registerCsiHandler({final:"K"},d=>this.eraseInLine(d,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},d=>this.eraseInLine(d,!0)),this._parser.registerCsiHandler({final:"L"},d=>this.insertLines(d)),this._parser.registerCsiHandler({final:"M"},d=>this.deleteLines(d)),this._parser.registerCsiHandler({final:"P"},d=>this.deleteChars(d)),this._parser.registerCsiHandler({final:"S"},d=>this.scrollUp(d)),this._parser.registerCsiHandler({final:"T"},d=>this.scrollDown(d)),this._parser.registerCsiHandler({final:"X"},d=>this.eraseChars(d)),this._parser.registerCsiHandler({final:"Z"},d=>this.cursorBackwardTab(d)),this._parser.registerCsiHandler({final:"`"},d=>this.charPosAbsolute(d)),this._parser.registerCsiHandler({final:"a"},d=>this.hPositionRelative(d)),this._parser.registerCsiHandler({final:"b"},d=>this.repeatPrecedingCharacter(d)),this._parser.registerCsiHandler({final:"c"},d=>this.sendDeviceAttributesPrimary(d)),this._parser.registerCsiHandler({prefix:">",final:"c"},d=>this.sendDeviceAttributesSecondary(d)),this._parser.registerCsiHandler({final:"d"},d=>this.linePosAbsolute(d)),this._parser.registerCsiHandler({final:"e"},d=>this.vPositionRelative(d)),this._parser.registerCsiHandler({final:"f"},d=>this.hVPosition(d)),this._parser.registerCsiHandler({final:"g"},d=>this.tabClear(d)),this._parser.registerCsiHandler({final:"h"},d=>this.setMode(d)),this._parser.registerCsiHandler({prefix:"?",final:"h"},d=>this.setModePrivate(d)),this._parser.registerCsiHandler({final:"l"},d=>this.resetMode(d)),this._parser.registerCsiHandler({prefix:"?",final:"l"},d=>this.resetModePrivate(d)),this._parser.registerCsiHandler({final:"m"},d=>this.charAttributes(d)),this._parser.registerCsiHandler({final:"n"},d=>this.deviceStatus(d)),this._parser.registerCsiHandler({prefix:"?",final:"n"},d=>this.deviceStatusPrivate(d)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},d=>this.softReset(d)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},d=>this.setCursorStyle(d)),this._parser.registerCsiHandler({final:"r"},d=>this.setScrollRegion(d)),this._parser.registerCsiHandler({final:"s"},d=>this.saveCursor(d)),this._parser.registerCsiHandler({final:"t"},d=>this.windowOptions(d)),this._parser.registerCsiHandler({final:"u"},d=>this.restoreCursor(d)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},d=>this.insertColumns(d)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},d=>this.deleteColumns(d)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},d=>this.selectProtected(d)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},d=>this.requestMode(d,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},d=>this.requestMode(d,!1)),this._parser.setExecuteHandler(be.BEL,()=>this.bell()),this._parser.setExecuteHandler(be.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(be.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(be.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(be.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(be.BS,()=>this.backspace()),this._parser.setExecuteHandler(be.HT,()=>this.tab()),this._parser.setExecuteHandler(be.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(be.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(Ja.IND,()=>this.index()),this._parser.setExecuteHandler(Ja.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(Ja.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new Ds(d=>(this.setTitle(d),this.setIconName(d),!0))),this._parser.registerOscHandler(1,new Ds(d=>this.setIconName(d))),this._parser.registerOscHandler(2,new Ds(d=>this.setTitle(d))),this._parser.registerOscHandler(4,new Ds(d=>this.setOrReportIndexedColor(d))),this._parser.registerOscHandler(8,new Ds(d=>this.setHyperlink(d))),this._parser.registerOscHandler(10,new Ds(d=>this.setOrReportFgColor(d))),this._parser.registerOscHandler(11,new Ds(d=>this.setOrReportBgColor(d))),this._parser.registerOscHandler(12,new Ds(d=>this.setOrReportCursorColor(d))),this._parser.registerOscHandler(104,new Ds(d=>this.restoreIndexedColor(d))),this._parser.registerOscHandler(110,new Ds(d=>this.restoreFgColor(d))),this._parser.registerOscHandler(111,new Ds(d=>this.restoreBgColor(d))),this._parser.registerOscHandler(112,new Ds(d=>this.restoreCursorColor(d))),this._parser.registerEscHandler({final:"7"},()=>this.saveCursor()),this._parser.registerEscHandler({final:"8"},()=>this.restoreCursor()),this._parser.registerEscHandler({final:"D"},()=>this.index()),this._parser.registerEscHandler({final:"E"},()=>this.nextLine()),this._parser.registerEscHandler({final:"H"},()=>this.tabSet()),this._parser.registerEscHandler({final:"M"},()=>this.reverseIndex()),this._parser.registerEscHandler({final:"="},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:">"},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:"c"},()=>this.fullReset()),this._parser.registerEscHandler({final:"n"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"o"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"|"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"}"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"~"},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:"%",final:"@"},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:"%",final:"G"},()=>this.selectDefaultCharset());for(let d in Kt)this._parser.registerEscHandler({intermediates:"(",final:d},()=>this.selectCharset("("+d)),this._parser.registerEscHandler({intermediates:")",final:d},()=>this.selectCharset(")"+d)),this._parser.registerEscHandler({intermediates:"*",final:d},()=>this.selectCharset("*"+d)),this._parser.registerEscHandler({intermediates:"+",final:d},()=>this.selectCharset("+"+d)),this._parser.registerEscHandler({intermediates:"-",final:d},()=>this.selectCharset("-"+d)),this._parser.registerEscHandler({intermediates:".",final:d},()=>this.selectCharset("."+d)),this._parser.registerEscHandler({intermediates:"/",final:d},()=>this.selectCharset("/"+d));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(d=>(this._logService.error("Parsing error: ",d),d)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new $1((d,h)=>this.requestStatusString(d,h)))}getAttrData(){return this._curAttrData}_preserveStack(t,e,s,n){this._parseStack.paused=!0,this._parseStack.cursorStartX=t,this._parseStack.cursorStartY=e,this._parseStack.decodedLength=s,this._parseStack.position=n}_logSlowResolvingAsync(t){this._logService.logLevel<=3&&Promise.race([t,new Promise((e,s)=>setTimeout(()=>s("#SLOW_TIMEOUT"),U1))]).catch(e=>{if(e!=="#SLOW_TIMEOUT")throw e;console.warn(`async parser handler taking longer than ${U1} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(t,e){let s,n=this._activeBuffer.x,i=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;n=this._parseStack.cursorStartX,i=this._parseStack.cursorStartY,this._parseStack.paused=!1,t.length>zn&&(o=this._parseStack.position+zn)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof t=="string"?` "${t}"`:` "${Array.prototype.map.call(t,d=>String.fromCharCode(d)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof t=="string"?t.split("").map(d=>d.charCodeAt(0)):t),this._parseBuffer.length<t.length&&this._parseBuffer.length<zn&&(this._parseBuffer=new Uint32Array(Math.min(t.length,zn))),a||this._dirtyRowTracker.clearRange(),t.length>zn)for(let d=o;d<t.length;d+=zn){let h=d+zn<t.length?d+zn:t.length,u=typeof t=="string"?this._stringDecoder.decode(t.substring(d,h),this._parseBuffer):this._utf8Decoder.decode(t.subarray(d,h),this._parseBuffer);if(s=this._parser.parse(this._parseBuffer,u))return this._preserveStack(n,i,u,d),this._logSlowResolvingAsync(s),s}else if(!a){let d=typeof t=="string"?this._stringDecoder.decode(t,this._parseBuffer):this._utf8Decoder.decode(t,this._parseBuffer);if(s=this._parser.parse(this._parseBuffer,d))return this._preserveStack(n,i,d,0),this._logSlowResolvingAsync(s),s}(this._activeBuffer.x!==n||this._activeBuffer.y!==i)&&this._onCursorMove.fire();let l=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),c=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);c<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(c,this._bufferService.rows-1),end:Math.min(l,this._bufferService.rows-1)})}print(t,e,s){let n,i,o=this._charsetService.charset,a=this._optionsService.rawOptions.screenReaderMode,l=this._bufferService.cols,c=this._coreService.decPrivateModes.wraparound,d=this._coreService.modes.insertMode,h=this._curAttrData,u=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&s-e>0&&u.getWidth(this._activeBuffer.x-1)===2&&u.setCellFromCodepoint(this._activeBuffer.x-1,0,1,h);let f=this._parser.precedingJoinState;for(let m=e;m<s;++m){if(n=t[m],n<127&&o){let v=o[String.fromCharCode(n)];v&&(n=v.charCodeAt(0))}let p=this._unicodeService.charProperties(n,f);i=bi.extractWidth(p);let g=bi.extractShouldJoin(p),x=g?bi.extractWidth(f):0;if(f=p,a&&this._onA11yChar.fire(Un(n)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+i-x>l){if(c){let v=u,b=this._activeBuffer.x-x;for(this._activeBuffer.x=x,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),x>0&&u instanceof fo&&u.copyCellsFrom(v,b,0,x,!1);b<l;)v.setCellFromCodepoint(b++,0,1,h)}else if(this._activeBuffer.x=l-1,i===2)continue}if(g&&this._activeBuffer.x){let v=u.getWidth(this._activeBuffer.x-1)?1:2;u.addCodepointToCell(this._activeBuffer.x-v,n,i);for(let b=i-x;--b>=0;)u.setCellFromCodepoint(this._activeBuffer.x++,0,0,h);continue}if(d&&(u.insertCells(this._activeBuffer.x,i-x,this._activeBuffer.getNullCell(h)),u.getWidth(l-1)===2&&u.setCellFromCodepoint(l-1,0,1,h)),u.setCellFromCodepoint(this._activeBuffer.x++,n,i,h),i>0)for(;--i;)u.setCellFromCodepoint(this._activeBuffer.x++,0,0,h)}this._parser.precedingJoinState=f,this._activeBuffer.x<l&&s-e>0&&u.getWidth(this._activeBuffer.x)===0&&!u.hasContent(this._activeBuffer.x)&&u.setCellFromCodepoint(this._activeBuffer.x,0,1,h),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(t,e){return t.final==="t"&&!t.prefix&&!t.intermediates?this._parser.registerCsiHandler(t,s=>K1(s.params[0],this._optionsService.rawOptions.windowOptions)?e(s):!0):this._parser.registerCsiHandler(t,e)}registerDcsHandler(t,e){return this._parser.registerDcsHandler(t,new $1(e))}registerEscHandler(t,e){return this._parser.registerEscHandler(t,e)}registerOscHandler(t,e){return this._parser.registerOscHandler(t,new Ds(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,n=!1,i=!1){let o=this._activeBuffer.lines.get(this._activeBuffer.ybase+t);o.replaceCells(e,s,this._activeBuffer.getNullCell(this._eraseAttrData()),i),n&&(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 n=this._activeBuffer.lines.length-this._bufferService.rows;n>0&&(this._activeBuffer.lines.trimStart(n),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-n,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-n,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,n=this._bufferService.rows-1-this._activeBuffer.scrollBottom,i=this._bufferService.rows-1+this._activeBuffer.ybase-n+1;for(;e--;)this._activeBuffer.lines.splice(i-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,n;for(n=this._bufferService.rows-1-this._activeBuffer.scrollBottom,n=this._bufferService.rows-1+this._activeBuffer.ybase-n;e--;)this._activeBuffer.lines.splice(s,1),this._activeBuffer.lines.splice(n,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(Dt));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 n=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);n.deleteCells(0,e,this._activeBuffer.getNullCell(this._eraseAttrData())),n.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 n=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);n.insertCells(0,e,this._activeBuffer.getNullCell(this._eraseAttrData())),n.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 n=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);n.insertCells(this._activeBuffer.x,e,this._activeBuffer.getNullCell(this._eraseAttrData())),n.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 n=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);n.deleteCells(this._activeBuffer.x,e,this._activeBuffer.getNullCell(this._eraseAttrData())),n.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,n=bi.extractWidth(e),i=this._activeBuffer.x-n,o=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(i),a=new Uint32Array(o.length*s),l=0;for(let d=0;d<o.length;){let h=o.codePointAt(d)||0;a[l++]=h,d+=h>65535?2:1}let c=l;for(let d=1;d<s;++d)a.copyWithin(c,0,l),c+=l;return this.print(a,0,c),!0}sendDeviceAttributesPrimary(t){return t.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(be.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(be.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(t){return t.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(be.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(be.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(t.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(be.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,mi),this._charsetService.setgCharset(1,mi),this._charsetService.setgCharset(2,mi),this._charsetService.setgCharset(3,mi);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1e3:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!0;break}return!0}resetMode(t){for(let e=0;e<t.length;e++)switch(t.params[e]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1;break}return!0}resetModePrivate(t){for(let e=0;e<t.length;e++)switch(t.params[e]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),t.params[e]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!1,this._onRequestRefreshRows.fire(void 0);break}return!0}requestMode(t,e){let s;(g=>(g[g.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",g[g.SET=1]="SET",g[g.RESET=2]="RESET",g[g.PERMANENTLY_SET=3]="PERMANENTLY_SET",g[g.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(s||={});let n=this._coreService.decPrivateModes,{activeProtocol:i,activeEncoding:o}=this._coreMouseService,a=this._coreService,{buffers:l,cols:c}=this._bufferService,{active:d,alt:h}=l,u=this._optionsService.rawOptions,f=(g,x)=>(a.triggerDataEvent(`${be.ESC}[${e?"":"?"}${g};${x}$y`),!0),m=g=>g?1:2,p=t.params[0];return e?p===2?f(p,4):p===4?f(p,m(a.modes.insertMode)):p===12?f(p,3):p===20?f(p,m(u.convertEol)):f(p,0):p===1?f(p,m(n.applicationCursorKeys)):p===3?f(p,u.windowOptions.setWinLines?c===80?2:c===132?1:0:0):p===6?f(p,m(n.origin)):p===7?f(p,m(n.wraparound)):p===8?f(p,3):p===9?f(p,m(i==="X10")):p===12?f(p,m(u.cursorBlink)):p===25?f(p,m(!a.isCursorHidden)):p===45?f(p,m(n.reverseWraparound)):p===66?f(p,m(n.applicationKeypad)):p===67?f(p,4):p===1e3?f(p,m(i==="VT200")):p===1002?f(p,m(i==="DRAG")):p===1003?f(p,m(i==="ANY")):p===1004?f(p,m(n.sendFocus)):p===1005?f(p,4):p===1006?f(p,m(o==="SGR")):p===1015?f(p,4):p===1016?f(p,m(o==="SGR_PIXELS")):p===1048?f(p,1):p===47||p===1047||p===1049?f(p,m(d===h)):p===2004?f(p,m(n.bracketedPasteMode)):p===2026?f(p,m(n.synchronizedOutput)):f(p,0)}_updateAttrColor(t,e,s,n,i){return e===2?(t|=50331648,t&=-16777216,t|=fa.fromColorRGB([s,n,i])):e===5&&(t&=-50331904,t|=33554432|s&255),t}_extractColor(t,e,s){let n=[0,0,-1,0,0,0],i=0,o=0;do{if(n[o+i]=t.params[e+o],t.hasSubParams(e+o)){let a=t.getSubParams(e+o),l=0;do n[1]===5&&(i=1),n[o+l+1+i]=a[l];while(++l<a.length&&l+o+1+i<n.length);break}if(n[1]===5&&o+i>=2||n[1]===2&&o+i>=5)break;n[1]&&(i=1)}while(++o+e<t.length&&o+i<n.length);for(let a=2;a<n.length;++a)n[a]===-1&&(n[a]=0);switch(n[0]){case 38:s.fg=this._updateAttrColor(s.fg,n[1],n[3],n[4],n[5]);break;case 48:s.bg=this._updateAttrColor(s.bg,n[1],n[3],n[4],n[5]);break;case 58:s.extended=s.extended.clone(),s.extended.underlineColor=this._updateAttrColor(s.extended.underlineColor,n[1],n[3],n[4],n[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=Dt.fg,t.bg=Dt.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,n=this._curAttrData;for(let i=0;i<e;i++)s=t.params[i],s>=30&&s<=37?(n.fg&=-50331904,n.fg|=16777216|s-30):s>=40&&s<=47?(n.bg&=-50331904,n.bg|=16777216|s-40):s>=90&&s<=97?(n.fg&=-50331904,n.fg|=16777216|s-90|8):s>=100&&s<=107?(n.bg&=-50331904,n.bg|=16777216|s-100|8):s===0?this._processSGR0(n):s===1?n.fg|=134217728:s===3?n.bg|=67108864:s===4?(n.fg|=268435456,this._processUnderline(t.hasSubParams(i)?t.getSubParams(i)[0]:1,n)):s===5?n.fg|=536870912:s===7?n.fg|=67108864:s===8?n.fg|=1073741824:s===9?n.fg|=2147483648:s===2?n.bg|=134217728:s===21?this._processUnderline(2,n):s===22?(n.fg&=-134217729,n.bg&=-134217729):s===23?n.bg&=-67108865:s===24?(n.fg&=-268435457,this._processUnderline(0,n)):s===25?n.fg&=-536870913:s===27?n.fg&=-67108865:s===28?n.fg&=-1073741825:s===29?n.fg&=2147483647:s===39?(n.fg&=-67108864,n.fg|=Dt.fg&16777215):s===49?(n.bg&=-67108864,n.bg|=Dt.bg&16777215):s===38||s===48||s===58?i+=this._extractColor(t,i,n):s===53?n.bg|=1073741824:s===55?n.bg&=-1073741825:s===59?(n.extended=n.extended.clone(),n.extended.underlineColor=-1,n.updateExtended()):s===100?(n.fg&=-67108864,n.fg|=Dt.fg&16777215,n.bg&=-67108864,n.bg|=Dt.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",s);return!0}deviceStatus(t){switch(t.params[0]){case 5:this._coreService.triggerDataEvent(`${be.ESC}[0n`);break;case 6:let e=this._activeBuffer.y+1,s=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${be.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(`${be.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=Dt.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(!K1(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(`${be.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(e===0||e===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>z1&&this._windowTitleStack.shift()),(e===0||e===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>z1&&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 n=s.shift(),i=s.shift();if(/^\d+$/.exec(n)){let o=parseInt(n);if(W1(o))if(i==="?")e.push({type:0,index:o});else{let a=F1(i);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(),n=t.slice(e+1);return n?this._createHyperlink(s,n):s.trim()?!1:this._finishHyperlink()}_createHyperlink(t,e){this._getCurrentLinkId()&&this._finishHyperlink();let s=t.split(":"),n,i=s.findIndex(o=>o.startsWith("id="));return i!==-1&&(n=s[i].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:n,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 n=0;n<s.length&&!(e>=this._specialColors.length);++n,++e)if(s[n]==="?")this._onColor.fire([{type:0,index:this._specialColors[e]}]);else{let i=F1(s[n]);i&&this._onColor.fire([{type:1,index:this._specialColors[e],color:i}])}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 n=0;n<s.length;++n)if(/^\d+$/.exec(s[n])){let i=parseInt(s[n]);W1(i)&&e.push({type:2,index:i})}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,mi),!0}selectCharset(t){return t.length!==2?(this.selectDefaultCharset(),!0):(t[0]==="/"||this._charsetService.setgCharset(NF[t[0]],Kt[t[1]]||mi),!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=Dt.clone(),this._eraseAttrDataInternal=Dt.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 Gs;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,n=this._activeBuffer.lines.get(s);n&&(n.fill(t),n.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(t,e){let s=a=>(this._coreService.triggerDataEvent(`${be.ESC}${a}${be.ESC}\\`),!0),n=this._bufferService.buffer,i=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${n.scrollTop+1};${n.scrollBottom+1}r`:t==="m"?"P1$r0m":t===" q"?`P1$r${{block:2,underline:4,bar:6}[i.cursorStyle]-(i.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(t,e){this._dirtyRowTracker.markRangeDirty(t,e)}},R0=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&&(H1=t,t=e,e=H1),t<this.start&&(this.start=t),e>this.end&&(this.end=e)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};R0=At([Ee(0,ws)],R0);function W1(t){return 0<=t&&t<256}var AF=5e7,q1=12,EF=50,PF=class extends tt{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 Ce),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 n=this._callbacks.shift();n&&n()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(t,e){if(this._pendingData>AF)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 n=this._writeBuffer[this._bufferOffset],i=this._action(n,e);if(i){let a=l=>performance.now()-s>=q1?setTimeout(()=>this._innerWrite(0,l)):this._innerWrite(s,l);i.catch(l=>(queueMicrotask(()=>{throw l}),Promise.resolve(!1))).then(a);return}let o=this._callbacks[this._bufferOffset];if(o&&o(),this._bufferOffset++,this._pendingData-=n.length,performance.now()-s>=q1)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>EF&&(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()}},D0=class{constructor(t){this._bufferService=t,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(t){let e=this._bufferService.buffer;if(t.id===void 0){let l=e.addMarker(e.ybase+e.y),c={data:t,id:this._nextId++,lines:[l]};return l.onDispose(()=>this._removeMarkerFromLink(c,l)),this._dataByLinkId.set(c.id,c),c.id}let s=t,n=this._getEntryIdKey(s),i=this._entriesWithId.get(n);if(i)return this.addLineToLink(i.id,e.ybase+e.y),i.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(n=>n.line!==e)){let n=this._bufferService.buffer.addMarker(e);s.lines.push(n),n.onDispose(()=>this._removeMarkerFromLink(s,n))}}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)))}};D0=At([Ee(0,ws)],D0);var G1=!1,RF=class extends tt{constructor(t){super(),this._windowsWrappingHeuristics=this._register(new Lr),this._onBinary=this._register(new Ce),this.onBinary=this._onBinary.event,this._onData=this._register(new Ce),this.onData=this._onData.event,this._onLineFeed=this._register(new Ce),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new Ce),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new Ce),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new Ce),this._instantiationService=new iF,this.optionsService=this._register(new mF(t)),this._instantiationService.setService(js,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(T0)),this._instantiationService.setService(ws,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(N0)),this._instantiationService.setService(B4,this._logService),this.coreService=this._register(this._instantiationService.createInstance(A0)),this._instantiationService.setService(Gi,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(E0)),this._instantiationService.setService(O4,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(bi)),this._instantiationService.setService(eB,this.unicodeService),this._charsetService=this._instantiationService.createInstance(bF),this._instantiationService.setService(ZO,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(D0),this._instantiationService.setService($4,this._oscLinkService),this._inputHandler=this._register(new TF(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(os.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(os.forward(this._bufferService.onResize,this._onResize)),this._register(os.forward(this.coreService.onData,this._onData)),this._register(os.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 PF((e,s)=>this._inputHandler.parse(e,s))),this._register(os.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new Ce),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&&!G1&&(this._logService.warn("writeSync is unreliable and will be removed soon."),G1=!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,v5),e=Math.max(e,b5),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(B1.bind(null,this._bufferService))),t.push(this.registerCsiHandler({final:"H"},()=>(B1(this._bufferService),!1))),this._windowsWrappingHeuristics.value=Lt(()=>{for(let e of t)e.dispose()})}}},DF={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 IF(t,e,s,n){let i={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?i.key=be.ESC+"OA":i.key=be.ESC+"[A":t.key==="UIKeyInputLeftArrow"?e?i.key=be.ESC+"OD":i.key=be.ESC+"[D":t.key==="UIKeyInputRightArrow"?e?i.key=be.ESC+"OC":i.key=be.ESC+"[C":t.key==="UIKeyInputDownArrow"&&(e?i.key=be.ESC+"OB":i.key=be.ESC+"[B");break;case 8:i.key=t.ctrlKey?"\b":be.DEL,t.altKey&&(i.key=be.ESC+i.key);break;case 9:if(t.shiftKey){i.key=be.ESC+"[Z";break}i.key=be.HT,i.cancel=!0;break;case 13:i.key=t.altKey?be.ESC+be.CR:be.CR,i.cancel=!0;break;case 27:i.key=be.ESC,t.altKey&&(i.key=be.ESC+be.ESC),i.cancel=!0;break;case 37:if(t.metaKey)break;o?i.key=be.ESC+"[1;"+(o+1)+"D":e?i.key=be.ESC+"OD":i.key=be.ESC+"[D";break;case 39:if(t.metaKey)break;o?i.key=be.ESC+"[1;"+(o+1)+"C":e?i.key=be.ESC+"OC":i.key=be.ESC+"[C";break;case 38:if(t.metaKey)break;o?i.key=be.ESC+"[1;"+(o+1)+"A":e?i.key=be.ESC+"OA":i.key=be.ESC+"[A";break;case 40:if(t.metaKey)break;o?i.key=be.ESC+"[1;"+(o+1)+"B":e?i.key=be.ESC+"OB":i.key=be.ESC+"[B";break;case 45:!t.shiftKey&&!t.ctrlKey&&(i.key=be.ESC+"[2~");break;case 46:o?i.key=be.ESC+"[3;"+(o+1)+"~":i.key=be.ESC+"[3~";break;case 36:o?i.key=be.ESC+"[1;"+(o+1)+"H":e?i.key=be.ESC+"OH":i.key=be.ESC+"[H";break;case 35:o?i.key=be.ESC+"[1;"+(o+1)+"F":e?i.key=be.ESC+"OF":i.key=be.ESC+"[F";break;case 33:t.shiftKey?i.type=2:t.ctrlKey?i.key=be.ESC+"[5;"+(o+1)+"~":i.key=be.ESC+"[5~";break;case 34:t.shiftKey?i.type=3:t.ctrlKey?i.key=be.ESC+"[6;"+(o+1)+"~":i.key=be.ESC+"[6~";break;case 112:o?i.key=be.ESC+"[1;"+(o+1)+"P":i.key=be.ESC+"OP";break;case 113:o?i.key=be.ESC+"[1;"+(o+1)+"Q":i.key=be.ESC+"OQ";break;case 114:o?i.key=be.ESC+"[1;"+(o+1)+"R":i.key=be.ESC+"OR";break;case 115:o?i.key=be.ESC+"[1;"+(o+1)+"S":i.key=be.ESC+"OS";break;case 116:o?i.key=be.ESC+"[15;"+(o+1)+"~":i.key=be.ESC+"[15~";break;case 117:o?i.key=be.ESC+"[17;"+(o+1)+"~":i.key=be.ESC+"[17~";break;case 118:o?i.key=be.ESC+"[18;"+(o+1)+"~":i.key=be.ESC+"[18~";break;case 119:o?i.key=be.ESC+"[19;"+(o+1)+"~":i.key=be.ESC+"[19~";break;case 120:o?i.key=be.ESC+"[20;"+(o+1)+"~":i.key=be.ESC+"[20~";break;case 121:o?i.key=be.ESC+"[21;"+(o+1)+"~":i.key=be.ESC+"[21~";break;case 122:o?i.key=be.ESC+"[23;"+(o+1)+"~":i.key=be.ESC+"[23~";break;case 123:o?i.key=be.ESC+"[24;"+(o+1)+"~":i.key=be.ESC+"[24~";break;default:if(t.ctrlKey&&!t.shiftKey&&!t.altKey&&!t.metaKey)t.keyCode>=65&&t.keyCode<=90?i.key=String.fromCharCode(t.keyCode-64):t.keyCode===32?i.key=be.NUL:t.keyCode>=51&&t.keyCode<=55?i.key=String.fromCharCode(t.keyCode-51+27):t.keyCode===56?i.key=be.DEL:t.keyCode===219?i.key=be.ESC:t.keyCode===220?i.key=be.FS:t.keyCode===221&&(i.key=be.GS);else if((!s||n)&&t.altKey&&!t.metaKey){let a=DF[t.keyCode]?.[t.shiftKey?1:0];if(a)i.key=be.ESC+a;else if(t.keyCode>=65&&t.keyCode<=90){let l=t.ctrlKey?t.keyCode-64:t.keyCode+32,c=String.fromCharCode(l);t.shiftKey&&(c=c.toUpperCase()),i.key=be.ESC+c}else if(t.keyCode===32)i.key=be.ESC+(t.ctrlKey?be.NUL:" ");else if(t.key==="Dead"&&t.code.startsWith("Key")){let l=t.code.slice(3,4);t.shiftKey||(l=l.toLowerCase()),i.key=be.ESC+l,i.cancel=!0}}else s&&!t.altKey&&!t.ctrlKey&&!t.shiftKey&&t.metaKey?t.keyCode===65&&(i.type=1):t.key&&!t.ctrlKey&&!t.altKey&&!t.metaKey&&t.keyCode>=48&&t.key.length===1?i.key=t.key:t.key&&t.ctrlKey&&(t.key==="_"&&(i.key=be.US),t.key==="@"&&(i.key=be.NUL));break}return i}var Et=0,MF=class{constructor(t){this._getKey=t,this._array=[],this._insertedValues=[],this._flushInsertedTask=new $l,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new $l,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((i,o)=>this._getKey(i)-this._getKey(o)),e=0,s=0,n=new Array(this._array.length+this._insertedValues.length);for(let i=0;i<n.length;i++)s>=this._array.length||this._getKey(t[e])<=this._getKey(this._array[s])?(n[i]=t[e],e++):n[i]=this._array[s++];this._array=n,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||(Et=this._search(e),Et===-1)||this._getKey(this._array[Et])!==e)return!1;do if(this._array[Et]===t)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(Et),!0;while(++Et<this._array.length&&this._getKey(this._array[Et])===e);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let t=this._deletedIndices.sort((i,o)=>i-o),e=0,s=new Array(this._array.length-t.length),n=0;for(let i=0;i<this._array.length;i++)t[e]===i?e++:s[n++]=this._array[i];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&&(Et=this._search(t),!(Et<0||Et>=this._array.length)&&this._getKey(this._array[Et])===t))do yield this._array[Et];while(++Et<this._array.length&&this._getKey(this._array[Et])===t)}forEachByKey(t,e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(Et=this._search(t),!(Et<0||Et>=this._array.length)&&this._getKey(this._array[Et])===t))do e(this._array[Et]);while(++Et<this._array.length&&this._getKey(this._array[Et])===t)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(t){let e=0,s=this._array.length-1;for(;s>=e;){let n=e+s>>1,i=this._getKey(this._array[n]);if(i>t)s=n-1;else if(i<t)e=n+1;else{for(;n>0&&this._getKey(this._array[n-1])===t;)n--;return n}}return e}},jd=0,Y1=0,OF=class extends tt{constructor(){super(),this._decorations=new MF(t=>t?.marker.line),this._onDecorationRegistered=this._register(new Ce),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new Ce),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(Lt(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(t){if(t.marker.isDisposed)return;let e=new BF(t);if(e){let s=e.marker.onDispose(()=>e.dispose()),n=e.onDispose(()=>{n.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 n=0,i=0;for(let o of this._decorations.getKeyIterator(e))n=o.options.x??0,i=n+(o.options.width??1),t>=n&&t<i&&(!s||(o.options.layer??"bottom")===s)&&(yield o)}forEachDecorationAtCell(t,e,s,n){this._decorations.forEachByKey(e,i=>{jd=i.options.x??0,Y1=jd+(i.options.width??1),t>=jd&&t<Y1&&(!s||(i.options.layer??"bottom")===s)&&n(i)})}},BF=class extends Jn{constructor(t){super(),this.options=t,this.onRenderEmitter=this.add(new Ce),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new Ce),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=Ct.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=Ct.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},$F=1e3,FF=class{constructor(t,e=$F){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 n=performance.now();if(n-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=n,this._innerRefresh();else if(!this._additionalRefreshRequested){let i=n-this._lastRefreshMs,o=this._debounceThresholdMS-i;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)}},J1=20,Fl=class extends tt{constructor(t,e,s,n){super(),this._terminal=t,this._coreBrowserService=s,this._renderService=n,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let i=this._coreBrowserService.mainDocument;this._accessibilityContainer=i.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=i.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=i.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new FF(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(`
|
|
513
|
-
`))),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(qe(i,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(Lt(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(t){for(let e=0;e<t;e++)this._handleChar(" ")}_handleChar(t){this._liveRegionLineCount<J1+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==t&&(this._charsToAnnounce+=t):this._charsToAnnounce+=t,t===`
|
|
514
|
-
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===J1+1&&(this._liveRegion.textContent+=t0.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,n=s.lines.length.toString();for(let i=t;i<=e;i++){let o=s.lines.get(s.ydisp+i),a=[],l=o?.translateToString(!0,void 0,void 0,a)||"",c=(s.ydisp+i+1).toString(),d=this._rowElements[i];d&&(l.length===0?(d.textContent=" ",this._rowColumns.set(d,[0,1])):(d.textContent=l,this._rowColumns.set(d,a)),d.setAttribute("aria-posinset",c),d.setAttribute("aria-setsize",n),this._alignRowWidth(d))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(t,e){let s=t.target,n=this._rowElements[e===0?1:this._rowElements.length-2],i=s.getAttribute("aria-posinset"),o=e===0?"1":`${this._terminal.buffer.lines.length}`;if(i===o||t.relatedTarget!==n)return;let a,l;if(e===0?(a=s,l=this._rowElements.pop(),this._rowContainer.removeChild(l)):(a=this._rowElements.shift(),l=s,this._rowContainer.removeChild(a)),a.removeEventListener("focus",this._topBoundaryFocusListener),l.removeEventListener("focus",this._bottomBoundaryFocusListener),e===0){let c=this._createAccessibilityTreeNode();this._rowElements.unshift(c),this._rowContainer.insertAdjacentElement("afterbegin",c)}else{let c=this._createAccessibilityTreeNode();this._rowElements.push(c),this._rowContainer.appendChild(c)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(e===0?-1:1),this._rowElements[e===0?1:this._rowElements.length-2].focus(),t.preventDefault(),t.stopImmediatePropagation()}_handleSelectionChange(){if(this._rowElements.length===0)return;let t=this._coreBrowserService.mainDocument.getSelection();if(!t)return;if(t.isCollapsed){this._rowContainer.contains(t.anchorNode)&&this._terminal.clearSelection();return}if(!t.anchorNode||!t.focusNode){console.error("anchorNode and/or focusNode are null");return}let e={node:t.anchorNode,offset:t.anchorOffset},s={node:t.focusNode,offset:t.focusOffset};if((e.node.compareDocumentPosition(s.node)&Node.DOCUMENT_POSITION_PRECEDING||e.node===s.node&&e.offset>s.offset)&&([e,s]=[s,e]),e.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(e={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(e.node))return;let n=this._rowElements.slice(-1)[0];if(s.node.compareDocumentPosition(n)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(s={node:n,offset:n.textContent?.length??0}),!this._rowContainer.contains(s.node))return;let i=({node:l,offset:c})=>{let d=l instanceof Text?l.parentNode:l,h=parseInt(d?.getAttribute("aria-posinset"),10)-1;if(isNaN(h))return console.warn("row is invalid. Race condition?"),null;let u=this._rowColumns.get(d);if(!u)return console.warn("columns is null. Race condition?"),null;let f=c<u.length?u[c]:u.slice(-1)[0]+1;return f>=this._terminal.cols&&(++h,f=0),{row:h,column:f}},o=i(e),a=i(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 n=s*this._renderService.dimensions.css.cell.width;t.style.transform=`scaleX(${n/e})`}};Fl=At([Ee(1,ju),Ee(2,Mn),Ee(3,On)],Fl);var I0=class extends tt{constructor(t,e,s,n,i){super(),this._element=t,this._mouseService=e,this._renderService=s,this._bufferService=n,this._linkProviderService=i,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new Ce),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new Ce),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(Lt(()=>{Pi(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(qe(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(qe(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(qe(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(qe(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 n=0;n<s.length;n++){let i=s[n];if(i.classList.contains("xterm"))break;if(i.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(n=>{n?.forEach(i=>{i.link.dispose&&i.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=t.y);let s=!1;for(let[n,i]of this._linkProviderService.linkProviders.entries())e?this._activeProviderReplies?.get(n)&&(s=this._checkLinkProviderResult(n,t,s)):i.provideLinks(t.y,o=>{if(this._isMouseOut)return;let a=o?.map(l=>({link:l}));this._activeProviderReplies?.set(n,a),s=this._checkLinkProviderResult(n,t,s),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(t.y,this._activeProviderReplies)})}_removeIntersectingLinks(t,e){let s=new Set;for(let n=0;n<e.size;n++){let i=e.get(n);if(i)for(let o=0;o<i.length;o++){let a=i[o],l=a.link.range.start.y<t?0:a.link.range.start.x,c=a.link.range.end.y>t?this._bufferService.cols:a.link.range.end.x;for(let d=l;d<=c;d++){if(s.has(d)){i.splice(o--,1);break}s.add(d)}}}}_checkLinkProviderResult(t,e,s){if(!this._activeProviderReplies)return s;let n=this._activeProviderReplies.get(t),i=!1;for(let o=0;o<t;o++)(!this._activeProviderReplies.has(o)||this._activeProviderReplies.get(o))&&(i=!0);if(!i&&n){let o=n.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&&zF(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,Pi(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 n=s.start===0?0:s.start+1+this._bufferService.buffer.ydisp,i=this._bufferService.buffer.ydisp+1+s.end;if(this._currentLink.link.range.start.y>=n&&this._currentLink.link.range.end.y<=i&&(this._clearCurrentLink(n,i),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,n=this._bufferService.buffer.ydisp,i=this._createLinkUnderlineEvent(s.start.x-1,s.start.y-n-1,s.end.x,s.end.y-n-1,void 0);(e?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(i)}_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,n=t.range.end.y*this._bufferService.cols+t.range.end.x,i=e.y*this._bufferService.cols+e.x;return s<=i&&i<=n}_positionFromMouseEvent(t,e,s){let n=s.getCoords(t,e,this._bufferService.cols,this._bufferService.rows);if(n)return{x:n[0],y:n[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(t,e,s,n,i){return{x1:t,y1:e,x2:s,y2:n,cols:this._bufferService.cols,fg:i}}};I0=At([Ee(1,Cu),Ee(2,On),Ee(3,ws),Ee(4,z4)],I0);function zF(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 KF=class extends RF{constructor(t={}){super(t),this._linkifier=this._register(new Lr),this.browser=a5,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new Lr),this._onCursorMove=this._register(new Ce),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new Ce),this.onKey=this._onKey.event,this._onRender=this._register(new Ce),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new Ce),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new Ce),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new Ce),this.onBell=this._onBell.event,this._onFocus=this._register(new Ce),this._onBlur=this._register(new Ce),this._onA11yCharEmitter=this._register(new Ce),this._onA11yTabEmitter=this._register(new Ce),this._onWillOpen=this._register(new Ce),this._setup(),this._decorationService=this._instantiationService.createInstance(OF),this._instantiationService.setService(ma,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(E$),this._instantiationService.setService(z4,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(n0)),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(os.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(os.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(os.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(os.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(e=>this._afterResize(e.cols,e.rows))),this._register(Lt(()=>{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,n="";switch(e.index){case 256:s="foreground",n="10";break;case 257:s="background",n="11";break;case 258:s="cursor",n="12";break;default:s="ansi",n="4;"+e.index}switch(e.type){case 0:let i=_t.toColorRGB(s==="ansi"?this._themeService.colors.ansi[e.index]:this._themeService.colors[s]);this.coreService.triggerDataEvent(`${be.ESC}]${n};${VF(i)}${r5.ST}`);break;case 1:if(s==="ansi")this._themeService.modifyColors(o=>o.ansi[e.index]=It.toColor(...e.color));else{let o=s;this._themeService.modifyColors(a=>a[o]=It.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(Fl,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(t){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(be.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(be.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),n=this._renderService.dimensions.css.cell.height,i=e.getWidth(s),o=this._renderService.dimensions.css.cell.width*i,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=n+"px",this.textarea.style.lineHeight=n+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(qe(this.element,"copy",e=>{this.hasSelection()&&qO(e,this._selectionService)}));let t=e=>GO(e,this.textarea,this.coreService,this.optionsService);this._register(qe(this.textarea,"paste",t)),this._register(qe(this.element,"paste",t)),l5?this._register(qe(this.element,"mousedown",e=>{e.button===2&&o1(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(qe(this.element,"contextmenu",e=>{o1(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),Ru&&this._register(qe(this.element,"auxclick",e=>{e.button===1&&P4(e,this.textarea,this.screenElement)}))}_bindKeys(){this._register(qe(this.textarea,"keyup",t=>this._keyUp(t),!0)),this._register(qe(this.textarea,"keydown",t=>this._keyDown(t),!0)),this._register(qe(this.textarea,"keypress",t=>this._keyPress(t),!0)),this._register(qe(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(qe(this.textarea,"compositionupdate",t=>this._compositionHelper.compositionupdate(t))),this._register(qe(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(qe(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(qe(this.screenElement,"mousemove",i=>this.updateCursorStyle(i))),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",e0.get()),u5||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(T$,this.textarea,t.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(Mn,this._coreBrowserService),this._register(qe(this.textarea,"focus",i=>this._handleTextAreaFocus(i))),this._register(qe(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(w0,this._document,this._helperContainer),this._instantiationService.setService(Vc,this._charSizeService),this._themeService=this._instantiationService.createInstance(V0),this._instantiationService.setService(zr,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(Ol),this._instantiationService.setService(F4,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(C0,this.rows,this.screenElement)),this._instantiationService.setService(On,this._renderService),this._register(this._renderService.onRenderedViewportChange(i=>this._onRender.fire(i))),this.onResize(i=>this._renderService.resize(i.cols,i.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(y0,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(j0),this._instantiationService.setService(Cu,this._mouseService);let n=this._linkifier.value=this._register(this._instantiationService.createInstance(I0,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(b0,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(i=>{super.scrollLines(i,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(k0,this.element,this.screenElement,n)),this._instantiationService.setService(sB,this._selectionService),this._register(this._selectionService.onRequestScrollLines(i=>this.scrollLines(i.amount,i.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(i=>this._renderService.handleSelectionChanged(i.start,i.end,i.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(i=>{this.textarea.value=i,this.textarea.focus(),this.textarea.select()})),this._register(os.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(_0,this.screenElement)),this._register(qe(this.element,"mousedown",i=>this._selectionService.handleMouseDown(i))),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(Fl,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",i=>this._handleScreenReaderModeOptionChange(i))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Ml,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",i=>{!this._overviewRulerRenderer&&i&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Ml,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(S0,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let t=this,e=this.element;function s(o){let a=t._mouseService.getMouseReportCoords(o,t.screenElement);if(!a)return!1;let l,c;switch(o.overrideType||o.type){case"mousemove":c=32,o.buttons===void 0?(l=3,o.button!==void 0&&(l=o.button<3?o.button:3)):l=o.buttons&1?0:o.buttons&4?1:o.buttons&2?2:3;break;case"mouseup":c=0,l=o.button<3?o.button:3;break;case"mousedown":c=1,l=o.button<3?o.button:3;break;case"wheel":if(t._customWheelEventHandler&&t._customWheelEventHandler(o)===!1)return!1;let d=o.deltaY;if(d===0||t.coreMouseService.consumeWheelEvent(o,t._renderService?.dimensions?.device?.cell?.height,t._coreBrowserService?.dpr)===0)return!1;c=d<0?0:1,l=4;break;default:return!1}return c===void 0||l===void 0||l>4?!1:t.coreMouseService.triggerMouseEvent({col:a.col,row:a.row,x:a.x,y:a.y,button:l,action:c,ctrl:o.ctrlKey,alt:o.altKey,shift:o.shiftKey})}let n={mouseup:null,wheel:null,mousedrag:null,mousemove:null},i={mouseup:o=>(s(o),o.buttons||(this._document.removeEventListener("mouseup",n.mouseup),n.mousedrag&&this._document.removeEventListener("mousemove",n.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?n.mousemove||(e.addEventListener("mousemove",i.mousemove),n.mousemove=i.mousemove):(e.removeEventListener("mousemove",n.mousemove),n.mousemove=null),o&16?n.wheel||(e.addEventListener("wheel",i.wheel,{passive:!1}),n.wheel=i.wheel):(e.removeEventListener("wheel",n.wheel),n.wheel=null),o&2?n.mouseup||(n.mouseup=i.mouseup):(this._document.removeEventListener("mouseup",n.mouseup),n.mouseup=null),o&4?n.mousedrag||(n.mousedrag=i.mousedrag):(this._document.removeEventListener("mousemove",n.mousedrag),n.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(qe(e,"mousedown",o=>{if(o.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(o)))return s(o),n.mouseup&&this._document.addEventListener("mouseup",n.mouseup),n.mousedrag&&this._document.addEventListener("mousemove",n.mousedrag),this.cancel(o)})),this._register(qe(e,"wheel",o=>{if(!n.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=be.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){E4(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=IF(t,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(t),s.type===3||s.type===2){let n=this.rows-1;return this.scrollLines(s.type===2?-n:n),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===be.ETX||s.key===be.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)&&(UF(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(Dt));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(be.ESC+"[I"):this.coreService.triggerDataEvent(be.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(`${be.ESC}[4;${s};${e}t`);break;case 1:let n=this._renderService.dimensions.css.cell.width.toFixed(0),i=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${be.ESC}[6;${i};${n}t`);break}}cancel(t,e){if(!(!this.options.cancelEvents&&!e))return t.preventDefault(),t.stopPropagation(),!1}};function UF(t){return t.keyCode===16||t.keyCode===17||t.keyCode===18}var HF=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)}},WF=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 Gs)}translateToString(t,e,s){return this._line.translateToString(t,e,s)}},X1=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 WF(e)}getNullCell(){return new Gs}},qF=class extends tt{constructor(t){super(),this._core=t,this._onBufferChange=this._register(new Ce),this.onBufferChange=this._onBufferChange.event,this._normal=new X1(this._core.buffers.normal,"normal"),this._alternate=new X1(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)}},GF=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,n)=>e(s,n.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)}},YF=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}},JF=["cols","rows"],dn=0,XF=class extends tt{constructor(t){super(),this._core=this._register(new KF(t)),this._addonManager=this._register(new HF),this._publicOptions={...this._core.options};let e=n=>this._core.options[n],s=(n,i)=>{this._checkReadonlyOptions(n),this._core.options[n]=i};for(let n in this._core.options){let i={get:e.bind(this,n),set:s.bind(this,n)};Object.defineProperty(this._publicOptions,n,i)}}_checkReadonlyOptions(t){if(JF.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 GF(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new YF(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 qF(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
|
|
515
|
-
`,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 e0.get()},set promptLabel(t){e0.set(t)},get tooMuchOutput(){return t0.get()},set tooMuchOutput(t){t0.set(t)}}}_verifyIntegers(...t){for(dn of t)if(dn===1/0||isNaN(dn)||dn%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...t){for(dn of t)if(dn&&(dn===1/0||isNaN(dn)||dn%1!==0||dn<0))throw new Error("This API only accepts positive integers")}};var QF=2,ZF=1,ez=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),n=parseInt(s.getPropertyValue("height")),i=Math.max(0,parseInt(s.getPropertyValue("width"))),o=window.getComputedStyle(this._terminal.element),a={top:parseInt(o.getPropertyValue("padding-top")),bottom:parseInt(o.getPropertyValue("padding-bottom")),right:parseInt(o.getPropertyValue("padding-right")),left:parseInt(o.getPropertyValue("padding-left"))},l=a.top+a.bottom,c=a.right+a.left,d=n-l,h=i-c-e;return{cols:Math.max(QF,Math.floor(h/t.css.cell.width)),rows:Math.max(ZF,Math.floor(d/t.css.cell.height))}}};function tz({source:t,onReady:e,onSelectionChange:s,className:n}){const i=A.useRef(null),o=A.useRef(null),a=A.useRef(s);a.current=s;const l=Fs(),c=A.useRef(t);return c.current=t,Q2((d,h)=>{d===c.current&&o.current?.write(h)}),A.useEffect(()=>{const d=i.current;if(!d)return;const h=getComputedStyle(document.documentElement),u=v=>h.getPropertyValue(v).trim()||void 0,f=new XF({allowTransparency:!1,fontFamily:u("--font-mono")||"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",fontSize:12.5,lineHeight:1.5,scrollback:5e3,cursorBlink:!1,disableStdin:!0,theme:{background:u("--sidebar")||u("--card")||u("--background")||"#1e1e1e",cursor:"transparent",foreground:u("--foreground")||"#d4d4d4",selectionBackground:u("--accent"),selectionForeground:u("--accent-foreground"),black:u("--muted"),red:u("--destructive"),green:u("--success"),yellow:u("--warning"),blue:u("--chart-1"),magenta:u("--chart-3"),cyan:u("--chart-5"),white:u("--foreground"),brightBlack:u("--muted-foreground"),brightRed:u("--destructive"),brightGreen:u("--success"),brightYellow:u("--warning"),brightBlue:u("--chart-1"),brightMagenta:u("--chart-3"),brightCyan:u("--chart-5"),brightWhite:u("--foreground")}}),m=new ez;f.loadAddon(m),f.open(d),m.fit();const p=l.getBuffer(t);p&&f.write(p),o.current=f,e?.(f);const g=f.onSelectionChange(()=>{const v=!!f.getSelection();a.current?.(v,()=>f.getSelection())}),x=new ResizeObserver(()=>{m.fit()});return x.observe(d),()=>{g.dispose(),x.disconnect(),o.current=null,f.dispose()}},[]),r.jsx("div",{className:ie("h-full bg-sidebar p-3",n),children:r.jsx("div",{ref:i,className:"h-full"})})}function sz(t){const e=re(),s=Fs(),[n,i]=A.useState(Li),[o,a]=A.useState([]),[l,c]=A.useState(new Set),d=A.useRef(!1);if(!d.current&&s.scripts.length>0){const w=R_.find(j=>s.scripts.includes(j));w&&(d.current=!0,a(j=>j.includes(w)?j:[...j,w]),i(w))}if(l.size>0){let w=!1;const j=new Set(l);for(const S of l)s.activeProcesses.includes(S)||(j.delete(S),w=!0);w&&c(j)}const h=()=>t.onOpenChange(!t.open),u=w=>{i(w),t.open||t.onOpenChange(!0)},f=w=>!t.virtualMcpId||!t.branch?Promise.resolve(null):fetch(`/api/${encodeURIComponent(t.orgSlug)}/sandbox/${encodeURIComponent(t.virtualMcpId)}/${encodeURIComponent(t.branch)}/exec/${encodeURIComponent(w)}`,{method:"POST"}),m=w=>!t.virtualMcpId||!t.branch?Promise.resolve(null):fetch(`/api/${encodeURIComponent(t.orgSlug)}/sandbox/${encodeURIComponent(t.virtualMcpId)}/${encodeURIComponent(t.branch)}/exec/${encodeURIComponent(w)}/kill`,{method:"POST"}),p=async(w,j)=>{try{const S=await f(w);if(S===null)return;if(!S.ok)throw new Error(`Exec failed: ${S.statusText}`)}catch{ge.error(j)}},g=async w=>{a(j=>j.includes(w)?j:[...j,w]),i(w),t.onOpenChange(!0),await p(w,e("sandbox.drawer.failedToRun",{name:w}))},x=async w=>{await m(w),a(j=>j.filter(S=>S!==w)),n===w&&i(Li)},v=async()=>{const j=s.activeProcesses.includes(n)?e("sandbox.drawer.failedToRestart",{name:n}):e("sandbox.drawer.failedToRun",{name:n});await p(n,j)},b=async()=>{if(!l.has(n)){c(w=>new Set(w).add(n));try{const w=await m(n);if(w===null){c(j=>{const S=new Set(j);return S.delete(n),S});return}if(!w.ok)throw new Error(`Kill failed: ${w.statusText}`)}catch{c(w=>{const j=new Set(w);return j.delete(n),j}),ge.error(e("sandbox.drawer.failedToStop",{name:n}))}}},y=n!==Li&&o.includes(n),_=y&&s.activeProcesses.includes(n),L=y&&l.has(n);return r.jsxs("div",{className:"flex shrink-0 flex-col",style:{height:t.open?"50%":"auto"},children:[r.jsx(MO,{status:t.status,open:t.open,onToggle:h,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:n,scriptTabs:o,onSelectTab:u,onAddScript:g,onCloseScript:x,showScriptControls:y,scriptIsRunning:_,scriptIsKilling:L,onRunActiveScript:v,onStopActiveScript:b}),t.open&&r.jsx("div",{className:"flex-1 overflow-hidden",children:r.jsx(nz,{vmId:t.vmId,active:n,hasData:s.hasData(n),onRunActive:v})})]})}function nz(t){const e=F.c(16),{vmId:s,active:n,hasData:i,onRunActive:o}=t,a=re();if(!s)return null;if(n===Li||i){let m;return e[0]!==n?(m=r.jsx(tz,{source:n,className:"h-full"},n),e[0]=n,e[1]=m):m=e[1],m}let l;e[2]!==n||e[3]!==a?(l=a("sandbox.drawer.scriptNotRunning",{name:n}),e[2]=n,e[3]=a,e[4]=l):l=e[4];let c;e[5]!==l?(c=r.jsx("p",{children:l}),e[5]=l,e[6]=c):c=e[6];let d;e[7]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(Vi,{className:"size-3.5"}),e[7]=d):d=e[7];let h;e[8]!==a?(h=a("sandbox.drawer.run"),e[8]=a,e[9]=h):h=e[9];let u;e[10]!==o||e[11]!==h?(u=r.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:[d," ",h]}),e[10]=o,e[11]=h,e[12]=u):u=e[12];let f;return e[13]!==c||e[14]!==u?(f=r.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 text-sm text-muted-foreground",children:[c,u]}),e[13]=c,e[14]=u,e[15]=f):f=e[15],f}const y5=t=>`preview-drawer:${t}`,iz=/Authentication failed for|Invalid username or token|Password authentication is not supported/i;function rz(t){try{const e=localStorage.getItem(y5(t));return e?!!JSON.parse(e).open:!1}catch{return!1}}function oz(t,e){try{localStorage.setItem(y5(t),JSON.stringify({open:e}))}catch{}}function az(){const t=F.c(21),e=ci(),{org:s}=Oe(),n=e?.virtualMcpId??null,i=Er(),o=Fs(),a=A.useRef(null);let l;t[0]!==o||t[1]!==i||t[2]!==n?(l=b=>{b!=="setup"||!n||a.current!==n&&iz.test(o.getBuffer("setup"))&&(a.current=n,i.restart())},t[0]=o,t[1]=i,t[2]=n,t[3]=l):l=t[3],Q2(l);const c=n??"__no-vmcp__",[d,h]=A.useState(null),u=A.useRef(null);u.current!==c&&(u.current=c,h(rz(c)));const f=d??!1;let m;t[4]!==c?(m=b=>{h(b),oz(c,b)},t[4]=c,t[5]=m):m=t[5];const p=m,g=i.vmEntry?.sandboxHandle??"no-vm",x=i.vmEntry?.sandboxHandle??null;let v;return t[6]!==o.scripts||t[7]!==p||t[8]!==i.branch||t[9]!==i.restart||t[10]!==i.resume||t[11]!==i.retry||t[12]!==i.start||t[13]!==i.status||t[14]!==i.stop||t[15]!==f||t[16]!==s.slug||t[17]!==g||t[18]!==x||t[19]!==n?(v=r.jsx(sz,{vmId:x,orgSlug:s.slug,virtualMcpId:n,branch:i.branch,status:i.status,scripts:o.scripts,open:f,onOpenChange:p,onStart:i.start,onStop:i.stop,onRestart:i.restart,onResume:i.resume,onRetry:i.retry},g),t[6]=o.scripts,t[7]=p,t[8]=i.branch,t[9]=i.restart,t[10]=i.resume,t[11]=i.retry,t[12]=i.start,t[13]=i.status,t[14]=i.stop,t[15]=f,t[16]=s.slug,t[17]=g,t[18]=x,t[19]=n,t[20]=v):v=t[20],v}function L5(t){const e=F.c(15),{virtualMcpId:s,taskId:n}=t,i=ci(),{activeTask:o}=Zt();let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a={strict:!1},e[0]=a):a=e[0];const{main:l}=wr(a);let c;e[1]!==o?.metadata||e[2]!==i?.entity?.metadata?(c=sn(i?.entity?.metadata)||sn(o?.metadata),e[1]=o?.metadata,e[2]=i?.entity?.metadata,e[3]=c):c=e[3];const d=c;let h;e[4]!==d||e[5]!==l?(h=d&&!(typeof l=="string"&&cb.has(l)),e[4]=d,e[5]=l,e[6]=h):h=e[6];const u=h;let f;e[7]!==n||e[8]!==s?(f=r.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:r.jsx(IO,{taskId:n,virtualMcpId:s})}),e[7]=n,e[8]=s,e[9]=f):f=e[9];let m;e[10]!==u?(m=u&&r.jsx(az,{}),e[10]=u,e[11]=m):m=e[11];let p;return e[12]!==f||e[13]!==m?(p=r.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[f,m]}),e[12]=f,e[13]=m,e[14]=p):p=e[14],p}function S5(t){const e=F.c(4),{chatContent:s}=t;let n;e[0]!==s?(n=s??r.jsx(Lp,{}),e[0]=s,e[1]=n):n=e[1];let i;return e[2]!==n?(i=r.jsx("div",{"data-testid":"chat-panel",className:"h-full min-h-0",children:n}),e[2]=n,e[3]=i):i=e[3],i}function Q1(t){const e=F.c(3),{children:s,testId:n}=t;let i;return e[0]!==s||e[1]!==n?(i=r.jsx("div",{className:"h-full p-0.5 pt-0.25",children:r.jsx("div",{"data-testid":n,className:"h-full min-h-0 overflow-hidden rounded-[0.75rem] bg-background card-shadow",children:s})}),e[0]=s,e[1]=n,e[2]=i):i=e[2],i}function lz(t){const e=F.c(38),{virtualMcpId:s,taskId:n,sidePanel:i,mainOpen:o,chatContent:a}=t,[,l]=A.useTransition(),[c,d]=RS(),h=A.useRef(null);let u;e[0]!==o||e[1]!==i?(u=NS({sidePanel:i,mainOpen:o}),e[0]=o,e[1]=i,e[2]=u):u=e[2];const f=u,m=i!==null&&o?c:f.side,p=100-m;let g,x;e[3]!==p||e[4]!==m?(g=()=>{h.current?.setLayout([m,p])},x=[m,p],e[3]=p,e[4]=m,e[5]=g,e[6]=x):(g=e[5],x=e[6]),A.useEffect(g,x);const v=`${s}-${n}`;let b;e[7]===Symbol.for("react.memo_cache_sentinel")?(b={overflow:"visible"},e[7]=b):b=e[7];const y=f.side,_=i!==null?"min-w-[320px]":"min-w-0";let L;e[8]!==_?(L=ie("overflow-hidden bg-sidebar",_),e[8]=_,e[9]=L):L=e[9];let w;e[10]!==o||e[11]!==d||e[12]!==i?(w=D=>l(()=>{i!==null&&o&&D>0&&D<100&&d(D)}),e[10]=o,e[11]=d,e[12]=i,e[13]=w):w=e[13];let j;e[14]!==a||e[15]!==i?(j=i!==null&&r.jsx(S5,{chatContent:a}),e[14]=a,e[15]=i,e[16]=j):j=e[16];let S;e[17]!==j?(S=r.jsx(Q1,{testId:"side-panel",children:j}),e[17]=j,e[18]=S):S=e[18];let C;e[19]!==f.side||e[20]!==S||e[21]!==L||e[22]!==w?(C=r.jsx(il,{order:1,defaultSize:y,minSize:20,collapsible:!0,collapsedSize:0,className:L,onResize:w,children:S}),e[19]=f.side,e[20]=S,e[21]=L,e[22]=w,e[23]=C):C=e[23];let N;e[24]===Symbol.for("react.memo_cache_sentinel")?(N=r.jsx(t2,{className:"bg-sidebar"}),e[24]=N):N=e[24];const V=f.main,E=o?"min-w-[320px]":"min-w-0";let T;e[25]!==E?(T=ie("min-w-0 overflow-hidden bg-sidebar",E),e[25]=E,e[26]=T):T=e[26];let k;e[27]!==n||e[28]!==s?(k=r.jsx(Q1,{testId:"main-panel",children:r.jsx(L5,{taskId:n,virtualMcpId:s})}),e[27]=n,e[28]=s,e[29]=k):k=e[29];let R;e[30]!==f.main||e[31]!==T||e[32]!==k?(R=r.jsx(il,{order:2,defaultSize:V,minSize:20,collapsible:!0,collapsedSize:0,className:T,children:k}),e[30]=f.main,e[31]=T,e[32]=k,e[33]=R):R=e[33];let P;return e[34]!==C||e[35]!==R||e[36]!==v?(P=r.jsxs(e2,{ref:h,direction:"horizontal",className:"flex-1 min-h-0 pb-1 pr-1 pl-0 pt-0",style:b,children:[C,N,R]},v),e[34]=C,e[35]=R,e[36]=v,e[37]=P):P=e[37],P}function w5(t){const e=F.c(13),s=St();let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n={strict:!1},e[0]=n):n=e[0];const i=Kl(n);let o;e[1]===Symbol.for("react.memo_cache_sentinel")?(o={strict:!1},e[1]=o):o=e[1];const a=wr(o),l=a.main===t,c=A.useRef(void 0),d=!!(i.org&&i.taskId);let h;e[2]!==l||e[3]!==s||e[4]!==t||e[5]!==i.org||e[6]!==i.taskId||e[7]!==a.main?(h=()=>{if(!i.org||!i.taskId)return;const m=i.org,p=i.taskId;s({to:"/$org/$taskId",params:{org:m,taskId:p},search:g=>{const x={...g};if(l){const v=c.current;v&&v!==t?x.main=v:delete x.main}else c.current=a.main===0?void 0:a.main,x.main=t;return x},replace:!0})},e[2]=l,e[3]=s,e[4]=t,e[5]=i.org,e[6]=i.taskId,e[7]=a.main,e[8]=h):h=e[8];const u=h;let f;return e[9]!==l||e[10]!==d||e[11]!==u?(f={active:l,enabled:d,toggle:u},e[9]=l,e[10]=d,e[11]=u,e[12]=f):f=e[12],f}function cz(){const t=F.c(10),e=re(),s=Ql(),{active:n,enabled:i,toggle:o}=w5("files");if(!i||s)return null;let a;t[0]!==e?(a=e("agentShellLayout.libraryToggle.library"),t[0]=e,t[1]=a):a=t[1];let l;t[2]===Symbol.for("react.memo_cache_sentinel")?(l={kind:"component",Component:Zn},t[2]=l):l=t[2];let c;t[3]!==n||t[4]!==o?(c=()=>{Me("agent_toolbar_toggled",{button:"library",next_state:n?"closed":"open"}),o()},t[3]=n,t[4]=o,t[5]=c):c=t[5];let d;return t[6]!==n||t[7]!==a||t[8]!==c?(d=r.jsx(Jl,{title:a,icon:l,active:n,className:"wco-no-drag h-10 md:h-8 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50",onClick:c}),t[6]=n,t[7]=a,t[8]=c,t[9]=d):d=t[9],d}function dz(){const t=F.c(10),e=re(),{active:s,enabled:n,toggle:i}=w5("board");if(!n)return null;let o;t[0]!==e?(o=e("agentShellLayout.tasksToggle.tasks"),t[0]=e,t[1]=o):o=t[1];let a;t[2]===Symbol.for("react.memo_cache_sentinel")?(a={kind:"component",Component:Hm},t[2]=a):a=t[2];let l;t[3]!==s||t[4]!==i?(l=()=>{Me("agent_toolbar_toggled",{button:"tasks",next_state:s?"closed":"open"}),i()},t[3]=s,t[4]=i,t[5]=l):l=t[5];let c;return t[6]!==s||t[7]!==o||t[8]!==l?(c=r.jsx(Jl,{title:o,icon:a,active:s,className:"wco-no-drag h-10 md:h-8 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50",onClick:l}),t[6]=s,t[7]=o,t[8]=l,t[9]=c):c=t[9],c}function uz(t){const e=F.c(15),{sidePanel:s,toggleSidePanel:n,disableActiveSidePanelToggle:i}=t,o=i===void 0?!1:i,a=re();let l;e[0]!==a?(l=a("agentShellLayout.toggleButtons.chat"),e[0]=a,e[1]=l):l=e[1];let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c={kind:"component",Component:Wm},e[2]=c):c=e[2];const d=s==="chat",h=o&&s==="chat";let u;e[3]!==s||e[4]!==n?(u=()=>{Me("agent_toolbar_toggled",{button:"chat",next_state:s==="chat"?"closed":"open"}),n("chat")},e[3]=s,e[4]=n,e[5]=u):u=e[5];let f;e[6]!==l||e[7]!==d||e[8]!==h||e[9]!==u?(f=r.jsx(Jl,{title:l,icon:c,active:d,disabled:h,className:"wco-no-drag h-10 md:h-8 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50 disabled:opacity-50",onClick:u}),e[6]=l,e[7]=d,e[8]=h,e[9]=u,e[10]=f):f=e[10];let m,p;e[11]===Symbol.for("react.memo_cache_sentinel")?(m=r.jsx(dz,{}),p=r.jsx(cz,{}),e[11]=m,e[12]=p):(m=e[11],p=e[12]);let g;return e[13]!==f?(g=r.jsxs(r.Fragment,{children:[f,m,p]}),e[13]=f,e[14]=g):g=e[14],g}function hz(t,e,s){if(t.length<=s)return{visible:t,overflow:[]};const n=t.slice(0,s),i=t.slice(s);if(e==null)return{visible:n,overflow:i};if(n.some(u=>u.id===e))return{visible:n,overflow:i};const a=i.findIndex(u=>u.id===e);if(a===-1)return{visible:n,overflow:i};const l=n[n.length-1],c=i[a],d=[...n.slice(0,-1),c],h=[l,...i.slice(0,a),...i.slice(a+1)];return{visible:d,overflow:h}}function fz(t){const e=F.c(21),{overflow:s,onSelect:n}=t,i=re(),[o,a]=A.useState(!1);let l;e[0]!==n?(l=x=>{a(!1),n(x)},e[0]=n,e[1]=l):l=e[1];const c=l;let d;e[2]!==i?(d=i("mainPanelTabs.tabOverflowMenu.moreTabs"),e[2]=i,e[3]=d):d=e[3];let h;e[4]!==i?(h=i("mainPanelTabs.tabOverflowMenu.moreTabs"),e[4]=i,e[5]=h):h=e[5];let u;e[6]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx(oi,{className:"size-4"}),e[6]=u):u=e[6];let f;e[7]!==d||e[8]!==h?(f=r.jsx(Es,{asChild:!0,children:r.jsx("button",{type:"button",title:d,"aria-label":h,className:"shrink-0 flex size-8 items-center justify-center rounded-md text-muted-foreground hover:bg-accent hover:text-foreground transition-colors",children:u})}),e[7]=d,e[8]=h,e[9]=f):f=e[9];let m;if(e[10]!==c||e[11]!==s){let x;e[13]!==c?(x=v=>r.jsx("li",{children:r.jsxs("button",{type:"button",onClick:()=>c(v.id),className:"w-full flex items-center gap-2 px-3 py-2 rounded-md hover:bg-accent text-sm text-foreground",children:[r.jsx("span",{className:"flex size-5 items-center justify-center shrink-0",children:r.jsx(l9,{icon:v.icon})}),r.jsx("span",{className:"truncate",children:v.title})]})},v.id),e[13]=c,e[14]=x):x=e[14],m=s.map(x),e[10]=c,e[11]=s,e[12]=m}else m=e[12];let p;e[15]!==m?(p=r.jsx(Ps,{align:"end",className:"w-56 p-1",children:r.jsx("ul",{className:"flex flex-col",children:m})}),e[15]=m,e[16]=p):p=e[16];let g;return e[17]!==o||e[18]!==f||e[19]!==p?(g=r.jsxs(As,{open:o,onOpenChange:a,children:[f,p]}),e[17]=o,e[18]=f,e[19]=p,e[20]=g):g=e[20],g}const mz=6;function pz(t){const e=F.c(21),{virtualMcpId:s,taskId:n,disableActiveMainToggle:i}=t,o=i===void 0?!1:i,a=St();let l;e[0]!==n||e[1]!==s?(l={virtualMcpId:s,taskId:n},e[0]=n,e[1]=s,e[2]=l):l=e[2];const{tabs:c,activeTab:d,mainOpen:h,setActiveTab:u}=B9(l);let f,m,p,g;if(e[3]!==d||e[4]!==o||e[5]!==h||e[6]!==a||e[7]!==u||e[8]!==c||e[9]!==s){const b=db({activeTab:d,mainOpen:h}),y=S=>S.id==="automations"?b:h&&S.id===d,L=c.find(S=>y(S))?.id??null,{visible:w,overflow:j}=hz(c,L,mz);m=j,f=S=>{const C=c.find(V=>V.id===S);if(o&&C&&y(C))return;const N=L===S&&h;if(Me("main_panel_tab_clicked",{virtual_mcp_id:s,tab_id:S,tab_kind:C?.kind??null,was_active:N}),S==="automations"){const V=ub({activeTab:d,mainOpen:h});a({to:".",search:E=>({...E,main:V}),replace:!0});return}u(S)},p="flex items-center min-w-0 gap-0.5",g=w.map(S=>r.jsx(Jl,{title:S.title,icon:S.icon,active:y(S),locked:o&&y(S),onClick:()=>f(S.id)},S.id)),e[3]=d,e[4]=o,e[5]=h,e[6]=a,e[7]=u,e[8]=c,e[9]=s,e[10]=f,e[11]=m,e[12]=p,e[13]=g}else f=e[10],m=e[11],p=e[12],g=e[13];let x;e[14]!==f||e[15]!==m?(x=m.length>0&&r.jsx(fz,{overflow:m,onSelect:f}),e[14]=f,e[15]=m,e[16]=x):x=e[16];let v;return e[17]!==p||e[18]!==g||e[19]!==x?(v=r.jsxs("div",{className:p,children:[g,x]}),e[17]=p,e[18]=g,e[19]=x,e[20]=v):v=e[20],v}const Cd="__mobile-main-panel-tab-select__";function gz({tabs:t,activeTab:e,mainOpen:s,t:n}){const i=t.find(a=>a.id===e),o=n("mainPanelTabs.mobileMainPanelTabSelect.mainView");return s?i?.title??o:i?.title??t[0]?.title??o}const xz={kind:"component",Component:Wm},vz={kind:"component",Component:Hm},bz={kind:"component",Component:Zn};function _z(t){const e=F.c(62),{virtualMcpId:s,taskId:n}=t,i=re(),o=St();let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a={strict:!1},e[0]=a):a=e[0];const l=Kl(a);let c;e[1]!==n||e[2]!==s?(c={virtualMcpId:s,taskId:n},e[1]=n,e[2]=s,e[3]=c):c=e[3];const{tabs:d,activeTab:h,mainOpen:u}=B9(c),{org:f}=Oe(),m=Ql();let p;e[4]!==f.id?(p=tl(f.id),e[4]=f.id,e[5]=p):p=e[5];const g=s===p,x=!!(l.org&&l.taskId);let v;e[6]!==i?(v=i("mainPanelTabs.mobileMainPanelTabSelect.chat"),e[6]=i,e[7]=v):v=e[7];let b;e[8]!==v?(b={value:"chat",title:v,icon:xz},e[8]=v,e[9]=b):b=e[9];let y;if(e[10]!==x||e[11]!==i||e[12]!==b||e[13]!==d){let B,z;e[15]!==x||e[16]!==i?(B=x?[{value:"board",title:i("mainPanelTabs.mobileMainPanelTabSelect.tasks"),icon:vz}]:[],z=x?[{value:"files",title:i("mainPanelTabs.mobileMainPanelTabSelect.library"),icon:bz}]:[],e[15]=x,e[16]=i,e[17]=B,e[18]=z):(B=e[17],z=e[18]),y=[b,...d.map(Lz),...B,...z],e[10]=x,e[11]=i,e[12]=b,e[13]=d,e[14]=y}else y=e[14];const _=y;let L;e[19]!==h||e[20]!==u||e[21]!==_?(L=u?_.find(B=>B.value===h)?.value??h:"chat",e[19]=h,e[20]=u,e[21]=_,e[22]=L):L=e[22];const w=L;let j;e[23]!==w||e[24]!==_?(j=_.find(B=>B.value===w),e[23]=w,e[24]=_,e[25]=j):j=e[25];const S=j;let C;e[26]!==h||e[27]!==u||e[28]!==S?.title||e[29]!==i||e[30]!==d?(C=S?.title??gz({tabs:d,activeTab:h,mainOpen:u,t:i}),e[26]=h,e[27]=u,e[28]=S?.title,e[29]=i,e[30]=d,e[31]=C):C=e[31];const N=C;let V;e[32]!==o||e[33]!==g||e[34]!==f.id||e[35]!==f.slug||e[36]!==m||e[37]!==s?(V=B=>{if(B!==Cd){if(Me("main_panel_tab_clicked",{virtual_mcp_id:s,tab_id:B,source:"mobile_select"}),$p({reportsOnly:m,onReportAgent:g,tabId:B})){o({to:"/$org/$taskId",params:{org:f.slug,taskId:crypto.randomUUID()},search:{virtualmcpid:tl(f.id),main:B}});return}o({to:".",search:z=>B==="chat"?{...z,sidepanel:"chat",main:0}:{...z,sidepanel:0,main:B},replace:!0})}},e[32]=o,e[33]=g,e[34]=f.id,e[35]=f.slug,e[36]=m,e[37]=s,e[38]=V):V=e[38];const E=V;let T;e[39]!==i?(T=i("mainPanelTabs.mobileMainPanelTabSelect.view"),e[39]=i,e[40]=T):T=e[40];let k;e[41]!==S?(k=S&&r.jsx("span",{className:"flex size-5 shrink-0 items-center justify-center",children:r.jsx(l9,{icon:S.icon,className:"size-5"})}),e[41]=S,e[42]=k):k=e[42];let R;e[43]!==N?(R=r.jsx("span",{className:"min-w-0 truncate",children:N}),e[43]=N,e[44]=R):R=e[44];let P;e[45]!==k||e[46]!==R?(P=r.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[k,R]}),e[45]=k,e[46]=R,e[47]=P):P=e[47];let D;e[48]!==T||e[49]!==P?(D=r.jsx(Jt,{"aria-label":T,className:"h-10! w-full min-w-0 max-w-[7.5rem] rounded-md border-0 bg-transparent px-1.5 text-xs shadow-none [--card-shadow:none]",children:P}),e[48]=T,e[49]=P,e[50]=D):D=e[50];let I;e[51]!==N?(I=r.jsx(vt,{value:Cd,disabled:!0,hideCheck:!0,className:"hidden",children:N}),e[51]=N,e[52]=I):I=e[52];let M;e[53]!==_?(M=_.map(yz),e[53]=_,e[54]=M):M=e[54];let O;e[55]!==I||e[56]!==M?(O=r.jsxs(Xt,{align:"end",className:"w-56",children:[I,M]}),e[55]=I,e[56]=M,e[57]=O):O=e[57];let $;return e[58]!==E||e[59]!==D||e[60]!==O?($=r.jsxs(Qt,{value:Cd,onValueChange:E,children:[D,O]}),e[58]=E,e[59]=D,e[60]=O,e[61]=$):$=e[61],$}function yz(t){return r.jsx(vt,{value:t.value,children:r.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[r.jsx("span",{className:"flex size-5 shrink-0 items-center justify-center",children:r.jsx(l9,{icon:t.icon})}),r.jsx("span",{className:"min-w-0 truncate",children:t.title})]})},t.value)}function Lz(t){return{value:t.id,title:t.title,icon:t.icon}}function j5(t){return aa({userName:t?.name,userEmail:t?.email})??void 0}const Sz=new Set(["main","master"]);function Du(t,e){return Sz.has(t.trim().toLowerCase())?e("thread.headerActions.publishToProduction"):e("thread.headerActions.publish")}function wz(t){const e=F.c(29),{baseBranch:s,disabled:n,loading:i,onPublish:o,onReview:a}=t,l=i===void 0?!1:i,c=re();let d;e[0]!==s||e[1]!==c?(d=Du(s,c),e[0]=s,e[1]=c,e[2]=d):d=e[2];const h=d;let u;e[3]!==o?(u=()=>{o()},e[3]=o,e[4]=u):u=e[4];let f;e[5]!==l?(f=l?r.jsx(wi,{size:"xs",variant:"default"}):null,e[5]=l,e[6]=f):f=e[6];let m;e[7]!==n||e[8]!==h||e[9]!==u||e[10]!==f?(m=r.jsxs(le,{size:"sm",variant:"success",className:"rounded-r-none border-r border-success-foreground/20",disabled:n,onClick:u,children:[f,h]}),e[7]=n,e[8]=h,e[9]=u,e[10]=f,e[11]=m):m=e[11];let p;e[12]!==c?(p=c("thread.mergeSplitButton.moreActionsAriaLabel"),e[12]=c,e[13]=p):p=e[13];let g;e[14]===Symbol.for("react.memo_cache_sentinel")?(g=r.jsx(ss,{className:"h-3.5 w-3.5"}),e[14]=g):g=e[14];let x;e[15]!==n||e[16]!==p?(x=r.jsx(ds,{asChild:!0,children:r.jsx(le,{size:"sm",variant:"success",className:"rounded-l-none px-2",disabled:n,"aria-label":p,children:g})}),e[15]=n,e[16]=p,e[17]=x):x=e[17];let v;e[18]!==a||e[19]!==c?(v=a?r.jsx(Xe,{onClick:a,children:c("thread.mergeSplitButton.review")}):null,e[18]=a,e[19]=c,e[20]=v):v=e[20];let b;e[21]!==v?(b=r.jsx(hs,{align:"end",children:v}),e[21]=v,e[22]=b):b=e[22];let y;e[23]!==b||e[24]!==x?(y=r.jsxs(us,{children:[x,b]}),e[23]=b,e[24]=x,e[25]=y):y=e[25];let _;return e[26]!==y||e[27]!==m?(_=r.jsxs("div",{className:"inline-flex items-stretch rounded-md",children:[m,y]}),e[26]=y,e[27]=m,e[28]=_):_=e[28],_}function jz(t,e,s,n,i){return["smart-review-verdict",t,e,s,n,i]}function Cz(t){const e=F.c(24),{orgSlug:s,virtualMcpId:n,branch:i,status:o,diff:a,enabled:l}=t,[c]=ni(),{language:d}=c;let h,u,f;if(e[0]!==i||e[1]!==a||e[2]!==l||e[3]!==d||e[4]!==s||e[5]!==o||e[6]!==n){const y=a?QN(a):"";h=l&&!!i&&!!o&&!!a&&y!=="",f=Mt,u=jz(s,n,i,y,d),e[0]=i,e[1]=a,e[2]=l,e[3]=d,e[4]=s,e[5]=o,e[6]=n,e[7]=h,e[8]=u,e[9]=f}else h=e[7],u=e[8],f=e[9];let m;e[10]!==i||e[11]!==a||e[12]!==d||e[13]!==s||e[14]!==o||e[15]!==n?(m=()=>ZN(s,n,i,{status:o,diff:a,language:d}),e[10]=i,e[11]=a,e[12]=d,e[13]=s,e[14]=o,e[15]=n,e[16]=m):m=e[16];let p;e[17]!==h||e[18]!==u||e[19]!==m?(p={queryKey:u,queryFn:m,enabled:h,staleTime:1/0,gcTime:6e5,retry:kz},e[17]=h,e[18]=u,e[19]=m,e[20]=p):p=e[20];const g=f(p),x=g.data??null,v=h&&g.isFetching&&!g.data;let b;return e[21]!==x||e[22]!==v?(b={verdict:x,loading:v},e[21]=x,e[22]=v,e[23]=b):b=e[23],b}function kz(t,e){return!iu(e)&&t<1}function Vz(t,e,s,n,i){return["publish-gate",t,e,s,n,i]}function Nz(t){const e=F.c(23),{orgSlug:s,virtualMcpId:n,branch:i,base:o,headSha:a,signature:l,policy:c,enabled:d}=t,h=d===void 0?!0:d;let u;e[0]!==o||e[1]!==i||e[2]!==s||e[3]!==l||e[4]!==n?(u=Vz(s,n,i,o,l),e[0]=o,e[1]=i,e[2]=s,e[3]=l,e[4]=n,e[5]=u):u=e[5];let f;e[6]!==o||e[7]!==i||e[8]!==a||e[9]!==s||e[10]!==n?(f=async()=>{const y=await Ha(s,n,i),_=(y.aheadOfBase??0)>0?await lr(s,n,i,{base:o,...a?{headSha:a}:{}}):null,L=vc(y)?await lr(s,n,i):null;return{status:y,diff:J3(_,L)}},e[6]=o,e[7]=i,e[8]=a,e[9]=s,e[10]=n,e[11]=f):f=e[11];const m=h&&!!i;let p;e[12]!==u||e[13]!==f||e[14]!==m?(p={queryKey:u,queryFn:f,enabled:m,refetchInterval:1e4,staleTime:5e3,retry:Tz},e[12]=u,e[13]=f,e[14]=m,e[15]=p):p=e[15];const g=Mt(p),x=g.data?.status??null,v=g.data?.diff??null;let b;return e[16]!==i||e[17]!==s||e[18]!==c||e[19]!==x||e[20]!==v||e[21]!==n?(b={orgSlug:s,virtualMcpId:n,branch:i,status:x,diff:v,policy:c},e[16]=i,e[17]=s,e[18]=c,e[19]=x,e[20]=v,e[21]=n,e[22]=b):b=e[22],C5(b)}function Tz(t,e){return!iu(e)&&t<2}function C5(t){const e=F.c(23),{orgSlug:s,virtualMcpId:n,branch:i,status:o,diff:a,policy:l,judgeEnabled:c}=t,d=c===void 0?!0:c;let h;e[0]!==a||e[1]!==d||e[2]!==l?(h=d&&rT(a,l),e[0]=a,e[1]=d,e[2]=l,e[3]=h):h=e[3];const u=h;let f;e[4]!==i||e[5]!==a||e[6]!==u||e[7]!==s||e[8]!==o||e[9]!==n?(f={orgSlug:s,virtualMcpId:n,branch:i,status:o,diff:a,enabled:u},e[4]=i,e[5]=a,e[6]=u,e[7]=s,e[8]=o,e[9]=n,e[10]=f):f=e[10];const{verdict:m,loading:p}=Cz(f);if(!a){let b;return e[11]===Symbol.for("react.memo_cache_sentinel")?(b={gate:{allowed:!0,reason:null},ready:!1},e[11]=b):b=e[11],b}if(!u){let b;e[12]!==a||e[13]!==l?(b=iT(a,l),e[12]=a,e[13]=l,e[14]=b):b=e[14];let y;return e[15]!==b?(y={gate:b,ready:!0},e[15]=b,e[16]=y):y=e[16],y}let g;e[17]!==p||e[18]!==m?(g=oT(m,p),e[17]=p,e[18]=m,e[19]=g):g=e[19];const x=!p;let v;return e[20]!==g||e[21]!==x?(v={gate:g,ready:x},e[20]=g,e[21]=x,e[22]=v):v=e[22],v}class so extends Error{constructor(e,s,n){super(e),this.step=s,this.pr=n,this.name="PublishFlowError"}step;pr}function Az(t){const e=F.c(10),[s,n]=A.useState(0);let i;e[0]!==t?(i=c=>{c&&n(Ez),t.onOpenChange(c)},e[0]=t,e[1]=i):i=e[1];const o=i;let a;e[2]!==o||e[3]!==t||e[4]!==s?(a=t.open?r.jsx(Pz,{...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=r.jsx(ts,{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 Ez(t){return t+1}function Pz({onOpenChange:t,orgSlug:e,orgId:s,virtualMcpId:n,branch:i,baseBranch:o,githubConnectionId:a,owner:l,repo:c,previewUrl:d,publishPolicy:h,dialogIntent:u="open-pr",headSha:f=null,openPullRequest:m=null,onPullRequestChanged:p,onPublished:g}){const x=re(),v=ht({connectionId:a,orgId:s,orgSlug:e}),b=ht({connectionId:Jo,orgId:s,orgSlug:e}),{data:y}=Di.useSession(),_=w9(b),L=j5(y?.user),w=m?.state==="open",j=u==="open-pr"&&!w,S=u==="publish-only",[C,N]=A.useState(null),[V,E]=A.useState(null),[T,k]=A.useState(!0),[R,P]=A.useState(!1),[D,I]=A.useState(""),[M,O]=A.useState(""),[$,B]=A.useState(),[z,K]=A.useState(!1),[G,Y]=A.useState(),[U,W]=A.useState(!1),[H,X]=A.useState(!1),[q,Z]=A.useState(!1),Q=A.useRef(!1),ee=A.useRef(!1),J={base:o,...f?{headSha:f}:{}},te=async ye=>{const ve=(ye.aheadOfBase??0)>0?await lr(e,n,i,J):null,Le=vc(ye)?await lr(e,n,i):null;return J3(ve,Le)},se=async()=>{const ye=await Ha(e,n,i),ve=S?await te(ye):await lr(e,n,i,nT(ye,{openPrFromCommits:j,commitToOpenPr:w})?J:void 0);N(ye),E(ve),I(x("thread.publishDialog.changesFrom",{branch:ye.current??i})),Z(!0),af(e,n,i,{status:ye,diff:ve}).then(Le=>{I(Le.title),O(Le.body)}).catch(()=>{}).finally(()=>Z(!1))};Q.current||(Q.current=!0,(async()=>{k(!0),B(void 0),E(null),I(""),O(""),Y(void 0);try{await se()}catch(ye){if(iu(ye)&&!ee.current){ee.current=!0;try{await _.mutateAsync({virtualMcpId:n,branch:i}),await se();return}catch(ve){B(ve instanceof Error?ve.message:x("thread.publishDialog.failedLoadAfterReprovision"));return}}B(ye instanceof Error?ye.message:x("thread.publishDialog.failedLoad"))}finally{k(!1)}})());const ne=tT(C)??i,de=Du(o,x),xe=()=>{!C||!V||(Z(!0),af(e,n,i,{status:C,diff:V}).then(ye=>{I(ye.title),O(ye.body)}).catch(()=>{}).finally(()=>Z(!1)))},ue=G3(C),ce=V?Object.keys(V.diffs).length:ue,{gate:oe}=C5({orgSlug:e,virtualMcpId:n,branch:i,status:C,diff:V,policy:h,judgeEnabled:S}),fe=j?Y3(C):sT(C,V),pe=!T&&(fe||j),we=pe&&oe.allowed,Ne=!pe||oe.allowed?null:oe.pending?x("thread.publishDialog.reviewingChanges"):oe.reason??x("thread.publishDialog.publishNeedsReview"),Fe=j||!w&&(C?.aheadOfBase??0)>0,je=!T&&(Fe||fe)&&(ce>0||fe),Ie=()=>[D.trim(),M.trim()].filter(Boolean).join(`
|
|
516
|
-
|
|
517
|
-
`),Pe=ye=>{R||z||t(ye)},Ye=async()=>{P(!0),B(void 0);let ye;try{const ve=D.trim()||x("thread.publishDialog.changesFrom",{branch:ne}),Le=M.trim()||void 0,$e=Ie()||ve;try{await lf(e,n,i,$e)}catch(ke){throw new so(ke instanceof Error?ke.message:x("thread.publishDialog.failedPushChanges"),"push")}try{await GN(e,n,i,o)}catch(ke){throw new so(ke instanceof Error?ke.message:x("thread.publishDialog.failedRebase"),"rebase")}try{ye=await sh(v,{owner:l,repo:c,branch:ne,title:ve,body:Le,base:o,coAuthor:L})}catch(ke){throw new so(ke instanceof Error?ke.message:x("thread.publishDialog.failedOpenPullRequest"),"open-pr")}try{await W2(v,{owner:l,repo:c,pullNumber:ye.number,commitTitle:ve,commitMessage:Le,coAuthor:L})}catch(ke){throw new so(ke instanceof Error?ke.message:x("thread.publishDialog.failedMergePullRequest"),"merge",ye)}ge.success(x("thread.publishDialog.publishedTo",{baseBranch:o})),Pe(!1),E(null),I(""),O(""),await p?.(),await g?.()}catch(ve){if(ve instanceof so&&ve.step==="merge"&&ve.pr){const Le=x("thread.publishDialog.mergeFailed",{prNumber:ve.pr.number,message:ve.message});B(Le),ge.error(Le,{action:{label:x("thread.publishDialog.viewPr"),onClick:()=>window.open(ve.pr.htmlUrl,"_blank","noopener,noreferrer")}}),await p?.();return}B(ve instanceof Error?ve.message:x("thread.publishDialog.failedPublish"))}finally{P(!1)}},_e=async ye=>{try{await cf(e,n,i,[ye]),ge.success(x("thread.publishDialog.discardedChanges",{filepath:ye})),E(Le=>{if(!Le)return Le;const $e={...Le,diffs:{...Le.diffs}};return delete $e.diffs[ye],$e});const ve=await Ha(e,n,i);N(ve)}catch(ve){ge.error(ve instanceof Error?ve.message:x("thread.publishDialog.failedDiscardChanges"))}},Ae=async()=>{if(V){W(!1),X(!0);try{const ye=Object.keys(V.diffs);if(ye.length===0)return;await cf(e,n,i,ye),ge.success(x("thread.publishDialog.allChangesDiscarded")),E(null);const ve=await Ha(e,n,i);N(ve),Pe(!1)}catch(ye){ge.error(ye instanceof Error?ye.message:x("thread.publishDialog.failedDiscardChanges"))}finally{X(!1)}}},Re=async()=>{K(!0),Y(void 0);try{const ye=D.trim()||x("thread.publishDialog.changesFrom",{branch:ne}),ve=M.trim()||void 0,Le=Ie()||ye;await lf(e,n,i,Le);const $e=await sh(v,{owner:l,repo:c,branch:ne,title:ye,body:ve,base:o,coAuthor:L});ge.success(x("thread.publishDialog.submittedForReview",{prNumber:$e.number}),{action:{label:x("thread.publishDialog.viewOnGithub"),onClick:()=>window.open($e.htmlUrl,"_blank","noopener,noreferrer")}}),Pe(!1),await p?.()}catch(ye){Y(ye instanceof Error?ye.message:x("thread.publishDialog.failedSubmitForReview"))}finally{K(!1)}};return r.jsx(es,{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:r.jsxs(Vr,{defaultValue:"description",className:"flex h-full flex-col gap-0",children:[r.jsxs("div",{className:"shrink-0 space-y-3 px-6 pt-5 pb-4",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:j?x("thread.publishDialog.submitForReview"):de}),r.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[r.jsx("span",{className:"inline-block h-2.5 w-2.5 shrink-0 rounded-full bg-success"}),ce," ",x(ce===1?"thread.publishDialog.change":"thread.publishDialog.changes")," ",x(j?"thread.publishDialog.inThisPr":"thread.publishDialog.toPublish")]})]}),U?r.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-md bg-destructive/5 px-3 py-2",children:[r.jsx("span",{className:"text-xs text-destructive",children:x("thread.publishDialog.discardConfirmMessage")}),r.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[r.jsx(le,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2 text-xs",onClick:()=>W(!1),children:x("thread.publishDialog.cancel")}),r.jsxs(le,{type:"button",size:"sm",className:"h-7 bg-destructive px-2 text-xs text-destructive-foreground hover:bg-destructive/90",onClick:Ae,disabled:H,children:[H?r.jsx(et,{className:"h-3 w-3 animate-spin"}):null,x("thread.publishDialog.discardAll")]})]})]}):r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs(ta,{className:"h-8 w-auto",variant:"pill",children:[r.jsx(xn,{value:"description",className:"px-3 text-xs",children:x("thread.publishDialog.description")}),r.jsx(xn,{value:"changes",className:"px-3 text-xs",children:x("thread.publishDialog.changesTab")})]}),ce>0&&!j&&r.jsx("button",{type:"button",className:"text-xs text-muted-foreground transition-colors hover:text-destructive disabled:opacity-50",onClick:()=>W(!0),disabled:R||H,children:x("thread.publishDialog.discardAll")})]})]}),r.jsx("div",{className:"border-t"}),r.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:T?r.jsxs("div",{className:"flex items-center justify-center gap-2 py-16 text-muted-foreground",children:[r.jsx(et,{className:"h-4 w-4 animate-spin"}),r.jsx("span",{className:"text-sm",children:x("thread.publishDialog.loadingChanges")})]}):r.jsxs(r.Fragment,{children:[r.jsx(_i,{value:"description",className:"mt-0 px-6 py-5",children:r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("p",{className:"text-sm font-medium",children:x(j?"thread.publishDialog.pullRequest":"thread.publishDialog.commitMessage")}),r.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:q||R||z,onClick:xe,children:[q?r.jsx(et,{className:"h-3 w-3 animate-spin"}):r.jsx(qn,{className:"h-3 w-3"}),x(q?"thread.publishDialog.generating":"thread.publishDialog.regenerate")]})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx("label",{htmlFor:"publish-title",className:"text-xs font-medium text-muted-foreground",children:x("thread.publishDialog.title")}),r.jsx(rt,{id:"publish-title",value:D,onChange:ye=>I(ye.target.value),placeholder:x(q?"thread.publishDialog.generating":"thread.publishDialog.commitTitlePlaceholder"),disabled:R||z||q,className:"text-sm"})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx("label",{htmlFor:"publish-body",className:"text-xs font-medium text-muted-foreground",children:x("thread.publishDialog.descriptionLabel")}),r.jsx(gr,{id:"publish-body",value:M,onChange:ye=>O(ye.target.value),placeholder:x(q?"thread.publishDialog.generating":"thread.publishDialog.descriptionPlaceholder"),disabled:R||z||q,rows:5,className:"resize-none text-sm"})]}),r.jsxs("p",{className:"text-xs text-muted-foreground",children:[x("thread.publishDialog.branchLabel")," ",r.jsx("span",{className:"font-mono",children:i})," → ",r.jsx("span",{className:"font-mono",children:o})," · ",r.jsx("span",{className:"text-foreground/80",children:S?x("thread.publishDialog.squashMergesInto",{publishLabel:de,baseBranch:o}):x("thread.publishDialog.opensPullRequestInto",{baseBranch:o})})]})]})}),r.jsx(_i,{value:"changes",className:"mt-0",children:r.jsx(X3,{diff:V,onDiscardFile:_e})})]})}),r.jsx("div",{className:"shrink-0 border-t",children:r.jsxs("button",{type:"button",className:"flex w-full items-center justify-between px-6 py-3.5 text-sm transition-colors hover:bg-muted/50 disabled:opacity-50",onClick:()=>{d&&window.open(d,"_blank","noopener,noreferrer")},disabled:!d,children:[r.jsxs("span",{className:"flex items-center gap-3",children:[r.jsx(u9,{className:"h-4 w-4 text-muted-foreground"}),x("thread.publishDialog.visitPreview")]}),r.jsx(kr,{className:"h-4 w-4 text-muted-foreground"})]})}),r.jsx("div",{className:"shrink-0 border-t px-6 py-3",children:S?r.jsxs(r.Fragment,{children:[r.jsx(Rz,{label:de,canPublish:we,disabledReason:Ne,isPublishing:R,onPublish:Ye}),$&&r.jsx("p",{className:"mt-2 text-xs text-destructive",children:$})]}):r.jsxs(r.Fragment,{children:[r.jsxs(le,{type:"button",className:"w-full",onClick:Re,disabled:!je||z,children:[z?r.jsx(et,{className:"h-4 w-4 animate-spin"}):r.jsx(Zs,{className:"h-4 w-4"}),x("thread.publishDialog.submitForReviewButton")]}),G&&r.jsx("p",{className:"mt-2 text-xs text-destructive",children:G})]})})]})})}function Rz(t){const e=F.c(14),{label:s,canPublish:n,disabledReason:i,isPublishing:o,onPublish:a}=t,l=!n||o;let c;e[0]!==o?(c=o?r.jsx(et,{className:"h-4 w-4 animate-spin"}):null,e[0]=o,e[1]=c):c=e[1];let d;e[2]!==s||e[3]!==a||e[4]!==l||e[5]!==c?(d=r.jsxs(le,{type:"button",variant:"success",className:"w-full",onClick:a,disabled:l,children:[c,s]}),e[2]=s,e[3]=a,e[4]=l,e[5]=c,e[6]=d):d=e[6];const h=d;if(!i)return h;let u;e[7]!==h?(u=r.jsx(ze,{asChild:!0,children:r.jsx("span",{className:"flex w-full",children:h})}),e[7]=h,e[8]=u):u=e[8];let f;e[9]!==i?(f=r.jsx(Ke,{children:i}),e[9]=i,e[10]=f):f=e[10];let m;return e[11]!==u||e[12]!==f?(m=r.jsx(ji,{children:r.jsxs(Ue,{children:[u,f]})}),e[11]=u,e[12]=f,e[13]=m):m=e[13],m}function Dz(){return!1}function k5(t,e){Dz()&&console.log(`[github-header] ${t}`,e??"")}function Iz(t){if(!(t==="claiming"||t==="ready"||t==="failed"))return Sg[t].short}const Mz=new Set(["failure","timed_out","cancelled","action_required"]);function Oz(t){return t.status==="completed"&&Mz.has(t.conclusion)}function Bz(t){return t.status==="queued"||t.status==="in_progress"}function $z(t){return t.isPending&&t.fetchStatus!=="idle"}function Fz(t){const{lifecycle:e,branch:s,pr:n,checks:i,reviews:o,loading:a,t:l}=t;if(a)return{label:l("thread.headerActions.loading"),disabled:!0,loading:!0,variant:"outline",tooltip:l("thread.headerActions.loadingBranchTooltip")};switch(e.phase){case"idle":return{label:t.claimPhase&&Iz(t.claimPhase.kind)||l("thread.headerActions.startingSandbox"),disabled:!0,loading:!0,variant:"outline",tooltip:l("thread.headerActions.waitingForDaemonTooltip")};case"cloning":return{label:l("thread.headerActions.cloningRepo"),disabled:!0,loading:!0,variant:"outline",tooltip:l("thread.headerActions.cloningRepoTooltip")};case"clone-failed":return{label:l("thread.headerActions.cloneFailed"),disabled:!0,variant:"outline",tooltip:e.error||l("thread.headerActions.cloneFailedDefaultTooltip")};case"checking-out":return{label:l("thread.headerActions.switchingTo",{branch:e.to}),disabled:!0,loading:!0,variant:"outline",tooltip:l("thread.headerActions.checkingOutTooltip",{branch:e.to})}}if(s.kind!=="ready")return{label:l("thread.headerActions.loadingBranch"),disabled:!0,loading:!0,variant:"outline",tooltip:l("thread.headerActions.waitingForBranchTooltip")};const c=s;if(c.workingTreeDirty)return{label:l("thread.headerActions.submitForReview"),action:"create-pr",variant:"default",tooltip:l("thread.headerActions.pushAndOpenPrTooltip",{branch:c.branch,base:c.base}),showPublishSide:!0};if(c.unpushed>0&&!(n&&c.headSha&&n.headSha&&c.headSha===n.headSha))return n?{label:l("thread.headerActions.submitForReview"),action:"create-pr",variant:"default",tooltip:l("thread.headerActions.pushLocalCommitsTooltip",{prNumber:String(n.number)}),showPublishSide:!0}:{label:l("thread.headerActions.submitForReview"),action:"create-pr",variant:"default",tooltip:l("thread.headerActions.pushAndOpenPrTooltip",{branch:c.branch,base:c.base}),showPublishSide:!0};if(k5("no local work — checking PR/sync state",{workingTreeDirty:c.workingTreeDirty,unpushed:c.unpushed,aheadOfBase:c.aheadOfBase,behindBase:c.behindBase,branch:c.branch,base:c.base,prMerged:n?.merged??null,prState:n?.state??null}),n?.merged)return!!c.headSha&&!!n.headSha&&c.headSha!==n.headSha?{label:l("thread.headerActions.continue"),action:"create-pr",variant:"special",tooltip:l("thread.headerActions.openNewPrTooltip"),showPublishSide:!0}:{label:l("thread.headerActions.published"),disabled:!0,variant:"outline",tooltip:l("thread.headerActions.prMergedTooltip",{prNumber:String(n.number),base:n.base})};if(c.aheadOfBase>0){if(n&&n.state==="closed"&&!n.merged)return{label:l("thread.headerActions.reopen"),action:"reopen",variant:"default",tooltip:l("thread.headerActions.reopenPrTooltip",{prNumber:String(n.number)})};if(!n)return{label:l("thread.headerActions.submitForReview"),action:"create-pr",variant:"default",tooltip:l("thread.headerActions.openPrForBranchTooltip",{branch:c.branch,base:c.base}),showPublishSide:!0};if((o?.mergeableState??"unknown")==="dirty")return{label:l("thread.headerActions.syncWith",{base:n.base}),action:"rebase",variant:"default",tooltip:l("thread.headerActions.resolveConflictsTooltip",{base:n.base})};const u=i.filter(Oz).map(p=>p.name);if(u.length>0)return{label:l("thread.headerActions.fixTests"),action:"fix-checks",variant:"default",tooltip:l("thread.headerActions.failingChecksTooltip",{checks:u.join(", ")}),meta:{failingChecks:u}};const f=i.filter(Bz);if(f.length>0)return{label:l("thread.headerActions.runningTests"),disabled:!0,loading:!0,variant:"outline",tooltip:l("thread.headerActions.waitingOnChecksTooltip",{count:String(f.length)})};if(o?.draft)return{label:l("thread.headerActions.markReady"),action:"mark-ready",variant:"default",tooltip:l("thread.headerActions.markDraftReadyTooltip")};const m=o?.unresolvedConversations??0;return m>0?{label:l("thread.headerActions.addressFeedback"),action:"resolve-comments",variant:"default",tooltip:l("thread.headerActions.unresolvedConversationsTooltip",{count:String(m)})}:o?.missingRequiredApprovals?{label:l("thread.headerActions.awaitingReview"),disabled:!0,variant:"outline",tooltip:l("thread.headerActions.waitingForApprovalsTooltip")}:{label:Du(n.base,l),action:"merge-split",variant:"success",tooltip:l("thread.headerActions.squashMergeTooltip",{prNumber:String(n.number),base:n.base})}}return{label:l("thread.headerActions.upToDate"),disabled:!0,variant:"outline",tooltip:l("thread.headerActions.branchInSyncTooltip",{base:c.base})}}function zz(t,e,s){if(!e)return s??null;const n=t?.[e];if(!n)return s??null;if(s&&n[s])return s;for(const[i,o]of Object.entries(n))if(o&&Object.keys(o).length>0)return i;return s??null}const Kz=6e4,Uz=3e4;function Hz(t){const e=F.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 n=ht(s),i=t.prNumber??0;let o;e[4]!==t.owner||e[5]!==t.repo||e[6]!==i?(o={method:"get",owner:t.owner,repo:t.repo,pullNumber:i},e[4]=t.owner,e[5]=t.repo,e[6]=i,e[7]=o):o=e[7];const a=!!t.prNumber;let l;return e[8]!==n||e[9]!==o||e[10]!==a?(l={client:n,toolName:"pull_request_read",toolArguments:o,enabled:a,refetchInterval:Kz,refetchIntervalInBackground:!1,staleTime:Uz,select:Wz},e[8]=n,e[9]=o,e[10]=a,e[11]=l):l=e[11],na(l)}function Wz(t){const e=zi(t);if(!e)return null;const s=e.mergeable_state??"unknown",n=!!(e.draft??!1),i=Number(e.review_comments??0),o=s==="blocked"&&i>0?i:0;return{draft:n,mergeableState:s,unresolvedConversations:o,missingRequiredApprovals:s==="blocked"&&o===0}}function qz(t){return{label:t("thread.headerActions.loadingBranch"),disabled:!0,loading:!0,variant:"outline",tooltip:t("thread.headerActions.waitingForSandboxBranchTooltip")}}function Gz({virtualMcpId:t}){const e=re(),{org:s}=Oe(),{data:n}=Di.useSession(),i=gs(t),{currentBranch:o,setCurrentTaskBranch:a}=Zt(),l=Js(),[c,d]=A.useState(!1),[h,u]=A.useState("open-pr"),[f,m]=A.useState(!1),p=A.useRef(""),g=m6(i),x=g.status==="attached"||g.status==="public-clone"?g.repo:null,v=n?.user?.id,b=ht({connectionId:x?.connectionId??"",orgId:s.id,orgSlug:s.slug}),{lifecycle:y,branch:_,phase:L}=Fs(),w=_.kind==="ready"?_.branch:null,j=zz(i?.metadata?.sandboxMap,v,o??w),S=o??w??j??void 0,C=(_.kind==="ready"?_.branch:null)??S??null,N=S9({orgId:s.id,orgSlug:s.slug,connectionId:x?.connectionId??"",owner:x?.owner??"",repo:x?.name??"",branch:C}),V=N.data??null,E=G2({orgId:s.id,orgSlug:s.slug,connectionId:x?.connectionId??"",owner:x?.owner??"",repo:x?.name??"",prNumber:V&&V.state==="open"?V.number:null}),T=Hz({orgId:s.id,orgSlug:s.slug,connectionId:x?.connectionId??"",owner:x?.owner??"",repo:x?.name??"",prNumber:V&&V.state==="open"?V.number:null}),k=_,R=k.kind==="ready"?k.base:"main",P=k.kind==="ready"&&!!S&&(k.workingTreeDirty||k.unpushed>0||k.aheadOfBase>0),D=k.kind==="ready"?`${k.headSha}:${k.workingTreeDirty}:${k.unpushed}:${k.aheadOfBase}`:"unknown",I=XN(i?.metadata?.publishPolicy),{gate:M}=Nz({orgSlug:s.slug,virtualMcpId:t,branch:S??"",base:R,headSha:k.kind==="ready"?k.headSha:null,signature:D,policy:I,enabled:P});if(g.status==="detached")return r.jsx(Za,{label:e("thread.headerActions.githubConnectionRemoved"),children:r.jsx(le,{size:"sm",variant:"outline",disabled:!0,children:e("thread.headerActions.reconnectGithub")})});if(!x)return null;const O=v&&C?zl(i?.metadata?.sandboxMap?.[v]?.[C]):{},$=Object.values(O),z=($.find(te=>te.sandboxProviderKind!=="user-desktop")??$[0])?.previewUrl??null,K=C?Fz({lifecycle:y,branch:k,claimPhase:L,pr:V,checks:E.data??[],reviews:T.data??null,loading:$z(N),t:e}):qz(e),G=JSON.stringify({label:K.label,branchKind:k.kind,workingTreeDirty:k.kind==="ready"?k.workingTreeDirty:null,unpushed:k.kind==="ready"?k.unpushed:null,aheadOfBase:k.kind==="ready"?k.aheadOfBase:null,lifecycle:y.phase,githubHeadBranch:C});p.current!==G&&(p.current=G,k5("header button",{label:K.label,tooltip:K.tooltip,action:K.action,chatBranch:o,sandboxBranch:w,sandboxMapBranch:j,sandboxRouteBranch:S,githubHeadBranch:C,branchMeta:_,effectiveBranchMeta:k,lifecyclePhase:y.phase,prNumber:V?.number??null,prState:V?.state??null}));const Y=te=>l.sendMessage({parts:[{type:"text",text:te}]}),U=l.isStreaming,W=k.kind==="ready"?k.base:"main",H=async()=>{await Promise.all([N.refetch(),E.refetch(),T.refetch()])},X=async()=>{const te=F2(n?.user?.name??n?.user?.email?.split("@")[0]);await a(te)},q=async te=>{if(!(!x?.connectionId||f)){m(!0);try{const se=j5(n?.user);await W2(b,{owner:x.owner,repo:x.name,pullNumber:te,coAuthor:se}),ge.success(e("thread.headerActions.publishedPr",{prNumber:String(te)})),await H(),await X()}catch(se){ge.error(se instanceof Error?se.message:e("thread.headerActions.failedToMergePullRequest"))}finally{m(!1)}}},Z=te=>{if(!(!te||!C))switch(te){case"create-pr":u("open-pr"),d(!0);return;case"reopen":if(U)return;V&&Y(uT({prNumber:V.number}));return;case"rebase":if(U)return;Y(hT({branch:C}));return;case"fix-checks":if(U)return;V&&Y(mT({prNumber:V.number,failingChecks:K.meta?.failingChecks??[]}));return;case"mark-ready":if(U)return;V&&Y(pT({prNumber:V.number}));return;case"resolve-comments":if(U)return;V&&Y(gT({prNumber:V.number}));return;case"merge-split":return}},Q=()=>{u("publish-only"),d(!0)},ee=K.showPublishSide??!1,J=f||U;return r.jsxs(r.Fragment,{children:[r.jsx(Yz,{t:e,button:K,actionBusy:J,githubActionPending:f,onActivate:Z,showPublishSide:ee,onPublishSide:Q,publishGate:M,prNumber:V?.number,prBase:V?.base,onSquashMerge:q,onReview:V?()=>{U||Y(xT({prNumber:V.number}))}:void 0}),S&&r.jsx(Az,{open:c,onOpenChange:d,orgSlug:s.slug,orgId:s.id,virtualMcpId:t,branch:S,baseBranch:W,githubConnectionId:x.connectionId??"",owner:x.owner,repo:x.name,previewUrl:z,publishPolicy:I,dialogIntent:h,headSha:k.kind==="ready"?k.headSha:null,openPullRequest:h==="publish-only"?null:V?.state==="open"?V:null,onPullRequestChanged:H,onPublished:X})]})}function Yz(t){const e=F.c(38),{t:s,button:n,actionBusy:i,githubActionPending:o}=t,a=i&&n.action!=="create-pr"&&n.action!=="merge-split",l=!!n.disabled||a||o&&n.action==="merge-split",c=!!n.loading||o&&n.action==="merge-split";let d;e[0]!==n.tooltip||e[1]!==a||e[2]!==s?(d=a?s("thread.headerActions.chatIsRunning"):n.tooltip??null,e[0]=n.tooltip,e[1]=a,e[2]=s,e[3]=d):d=e[3];const h=d;if(n.action==="merge-split"&&t.prNumber!=null&&t.prBase!=null){let v;e[4]!==t?(v=()=>t.onSquashMerge(t.prNumber),e[4]=t,e[5]=v):v=e[5];let b;e[6]!==l||e[7]!==c||e[8]!==t.onReview||e[9]!==t.prBase||e[10]!==v?(b=r.jsx(wz,{baseBranch:t.prBase,disabled:l,loading:c,onPublish:v,onReview:t.onReview}),e[6]=l,e[7]=c,e[8]=t.onReview,e[9]=t.prBase,e[10]=v,e[11]=b):b=e[11];let y;return e[12]!==b||e[13]!==h?(y=r.jsx(Za,{label:h,children:b}),e[12]=b,e[13]=h,e[14]=y):y=e[14],y}let u;e[15]!==n.action||e[16]!==t?(u=()=>{n.action&&t.onActivate(n.action)},e[15]=n.action,e[16]=t,e[17]=u):u=e[17];let f;e[18]!==c?(f=c?r.jsx(wi,{size:"xs",variant:"default"}):null,e[18]=c,e[19]=f):f=e[19];let m;e[20]!==n.label||e[21]!==n.variant||e[22]!==l||e[23]!==u||e[24]!==f?(m=r.jsxs(le,{size:"sm",variant:n.variant,disabled:l,onClick:u,children:[f,n.label]}),e[20]=n.label,e[21]=n.variant,e[22]=l,e[23]=u,e[24]=f,e[25]=m):m=e[25];let p;e[26]!==m||e[27]!==h?(p=r.jsx(Za,{label:h,children:m}),e[26]=m,e[27]=h,e[28]=p):p=e[28];let g;e[29]!==t.githubActionPending||e[30]!==t.onPublishSide||e[31]!==t.publishGate||e[32]!==t.showPublishSide||e[33]!==s?(g=t.showPublishSide?r.jsx(Za,{label:t.publishGate.pending?s("thread.headerActions.reviewingChanges"):t.publishGate.allowed?s("thread.headerActions.publishDirectlySkipReview"):t.publishGate.reason??s("thread.headerActions.publishNeedsReview"),children:r.jsxs(le,{size:"sm",variant:"success",disabled:t.githubActionPending||!t.publishGate.allowed,onClick:t.onPublishSide,children:[t.publishGate.pending?r.jsx(wi,{size:"xs",variant:"default"}):null,s("thread.headerActions.publish")]})}):null,e[29]=t.githubActionPending,e[30]=t.onPublishSide,e[31]=t.publishGate,e[32]=t.showPublishSide,e[33]=s,e[34]=g):g=e[34];let x;return e[35]!==p||e[36]!==g?(x=r.jsxs("div",{className:"flex items-center gap-2",children:[p,g]}),e[35]=p,e[36]=g,e[37]=x):x=e[37],x}function Za(t){const e=F.c(9),{label:s,children:n}=t;if(!s){let l;return e[0]!==n?(l=r.jsx(r.Fragment,{children:n}),e[0]=n,e[1]=l):l=e[1],l}let i;e[2]!==n?(i=r.jsx(ze,{asChild:!0,children:r.jsx("span",{children:n})}),e[2]=n,e[3]=i):i=e[3];let o;e[4]!==s?(o=r.jsx(Ke,{children:s}),e[4]=s,e[5]=o):o=e[5];let a;return e[6]!==i||e[7]!==o?(a=r.jsx(ji,{children:r.jsxs(Ue,{children:[i,o]})}),e[6]=i,e[7]=o,e[8]=a):a=e[8],a}function Jz(t){const e=F.c(9),{virtualMcp:s}=t,n=Zo(),{navigateToTask:i}=vx(),{create:o}=Hl();let a,l;if(e[0]!==n||e[1]!==o||e[2]!==i||e[3]!==s){l=Symbol.for("react.early_return_sentinel");e:{const c=p6(s,n);if(!c){l=null;break e}const d=c.mode==="dev";let h;e[6]!==o||e[7]!==i?(h=async m=>{const p=crypto.randomUUID();try{await o({id:p,virtual_mcp_id:m})}catch{}i(p,{virtualMcpId:m})},e[6]=o,e[7]=i,e[8]=h):h=e[8];const u=h,f=(m,p)=>r.jsx("button",{type:"button","aria-pressed":p,onClick:()=>{p||u(c.targetId)},className:ie("px-2.5 py-1 rounded-md transition-colors",p?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:m});a=r.jsxs("div",{className:"inline-flex items-center rounded-lg border border-border bg-muted p-0.5 text-xs font-medium",children:[f("Develop",d),f("Live",!d)]})}e[0]=n,e[1]=o,e[2]=i,e[3]=s,e[4]=a,e[5]=l}else a=e[4],l=e[5];return l!==Symbol.for("react.early_return_sentinel")?l:a}function Xz(t){const e=F.c(10),{locator:s}=Oe(),n=$s();let i;e[0]!==s?(i=at.taskBoardItems(s),e[0]=s,e[1]=i):i=e[1];let o;e[2]!==n?(o=async()=>(await n.call("TASK_BOARD_ITEM_LIST",{})).items,e[2]=n,e[3]=o):o=e[3];let a;e[4]!==i||e[5]!==o?(a={queryKey:i,queryFn:o},e[4]=i,e[5]=o,e[6]=a):a=e[6];const{data:l}=Mt(a);if(!t||!l)return null;let c;return e[7]!==l||e[8]!==t?(c=l.find(d=>d.threads.some(h=>h.threadId===t))?.id??null,e[7]=l,e[8]=t,e[9]=c):c=e[9],c}function Qz(){const t=F.c(17),e=re(),{org:s}=Oe(),{taskId:n}=Zt(),i=St(),o=Xz(n);if(!o)return null;let a;t[0]!==e?(a=e("thread.openInBoardButton.openTaskAriaLabel"),t[0]=e,t[1]=a):a=t[1];let l;t[2]!==o||t[3]!==i||t[4]!==s.slug?(l=()=>i({to:"/$org/board",params:{org:s.slug},search:{task:o}}),t[2]=o,t[3]=i,t[4]=s.slug,t[5]=l):l=t[5];let c;t[6]===Symbol.for("react.memo_cache_sentinel")?(c=r.jsx(Nn,{size:16}),t[6]=c):c=t[6];let d;t[7]!==a||t[8]!==l?(d=r.jsx(ze,{asChild:!0,children:r.jsx(Ed,{"aria-label":a,onClick:l,children:c})}),t[7]=a,t[8]=l,t[9]=d):d=t[9];let h;t[10]!==e?(h=e("thread.openInBoardButton.openTaskInBoard"),t[10]=e,t[11]=h):h=t[11];let u;t[12]!==h?(u=r.jsx(Ke,{children:h}),t[12]=h,t[13]=u):u=t[13];let f;return t[14]!==d||t[15]!==u?(f=r.jsx(ji,{children:r.jsxs(Ue,{children:[d,u]})}),t[14]=d,t[15]=u,t[16]=f):f=t[16],f}function Zz(t){const e=F.c(9),{virtualMcp:s,inline:n}=t,i=n===void 0?!1:n;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx(Qz,{}),e[0]=o):o=e[0];let a,l;e[1]!==s?(a=r.jsx(Jz,{virtualMcp:s}),l=g6(s)?r.jsx(Gz,{virtualMcpId:s.id}):null,e[1]=s,e[2]=a,e[3]=l):(a=e[2],l=e[3]);let c;e[4]!==a||e[5]!==l?(c=r.jsxs("div",{className:"flex items-center gap-2",children:[o,a,l]}),e[4]=a,e[5]=l,e[6]=c):c=e[6];const d=c;if(i)return d;let h;return e[7]!==d?(h=r.jsx(ol.Right,{children:d}),e[7]=d,e[8]=h):h=e[8],h}function eK(t,e){const s=F.c(34),n=wm(),i=A.useSyncExternalStore(n.threads.subscribe,n.threads.get),o=A.useSyncExternalStore(n.threadsStatus.subscribe,n.threadsStatus.get);let a;s[0]!==t||s[1]!==i?(a=t?i.find(y=>y.id===t)??null:null,s[0]=t,s[1]=i,s[2]=a):a=s[2];const l=a,[c,d]=A.useState(void 0);let h;s[3]===Symbol.for("react.memo_cache_sentinel")?(h=()=>{d(void 0)},s[3]=h):h=s[3];let u;s[4]!==t?(u=[t],s[4]=t,s[5]=u):u=s[5],A.useEffect(h,u);let f,m;s[6]!==c||s[7]!==t||s[8]!==l||s[9]!==n||s[10]!==o.kind?(f=()=>{t&&(l||o.kind!=="loading"&&c===void 0&&(d("pending"),n.fetchThread(t).then(y=>{d(y)})))},m=[t,l,o.kind,c,n],s[6]=c,s[7]=t,s[8]=l,s[9]=n,s[10]=o.kind,s[11]=f,s[12]=m):(f=s[11],m=s[12]),A.useEffect(f,m);let p;s[13]!==n||s[14]!==e?(p={mutationFn:async y=>n.create({id:y,virtual_mcp_id:e})},s[13]=n,s[14]=e,s[15]=p):p=s[15];const g=Ys(p);let x,v;if(s[16]!==g||s[17]!==c||s[18]!==t||s[19]!==l||s[20]!==o.kind?(x=()=>{t&&(l||c===null&&o.kind!=="loading"&&(g.isPending||g.variables!==t&&g.mutate(t)))},v=[t,l,c,o.kind,g],s[16]=g,s[17]=c,s[18]=t,s[19]=l,s[20]=o.kind,s[21]=x,s[22]=v):(x=s[21],v=s[22]),A.useEffect(x,v),!t){let y;return s[23]===Symbol.for("react.memo_cache_sentinel")?(y={status:"ready",task:null},s[23]=y):y=s[23],y}if(l){let y;return s[24]!==l?(y={status:"ready",task:l},s[24]=l,s[25]=y):y=s[25],y}if(c&&typeof c=="object"){let y;return s[26]!==c?(y={status:"ready",task:c},s[26]=c,s[27]=y):y=s[27],y}if(g.data){let y;return s[28]!==g.data?(y={status:"ready",task:g.data},s[28]=g.data,s[29]=y):y=s[29],y}if(g.isError){let y;return s[30]!==g.error?(y={status:"error",error:g.error},s[30]=g.error,s[31]=y):y=s[31],y}if(g.isPending||o.kind!=="loading"){let y;return s[32]===Symbol.for("react.memo_cache_sentinel")?(y={status:"creating"},s[32]=y):y=s[32],y}let b;return s[33]===Symbol.for("react.memo_cache_sentinel")?(b={status:"loading"},s[33]=b):b=s[33],b}function tK(){const t=F.c(6),e=Cr(),s=St();let n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n={strict:!1},t[0]=n):n=t[0];const{preview:i}=wr(n);if(!e||!i)return null;let o;t[1]!==s?(o=()=>s({to:".",search:sK}),t[1]=s,t[2]=o):o=t[2];let a;return t[3]!==i||t[4]!==o?(a=r.jsx(J6,{previewPath:i,showSeeInLibrary:!0,onClose:o}),t[3]=i,t[4]=o,t[5]=a):a=t[5],a}function sK(t){const{preview:e,...s}=t;return s}const er=A.createContext(null);function ci(){return A.use(er)}function V5(t){const e=F.c(12),{children:s}=t,n=re();let i;e[0]!==n?(i=n("agentShellLayout.agentShellLayout.chatLoadingError"),e[0]=n,e[1]=i):i=e[1];let o;e[2]!==i?(o=r.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:i}),e[2]=i,e[3]=o):o=e[3];let a;e[4]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx(yt.Skeleton,{}),e[4]=a):a=e[4];let l;e[5]!==s?(l=s??r.jsx(Lp,{}),e[5]=s,e[6]=l):l=e[6];let c;e[7]!==l?(c=r.jsx(A.Suspense,{fallback:a,children:l}),e[7]=l,e[8]=c):c=e[8];let d;return e[9]!==o||e[10]!==c?(d=r.jsx(ys,{fallback:o,children:c}),e[9]=o,e[10]=c,e[11]=d):d=e[11],d}function N5(t){const e=F.c(3),{onNewTaskRef:s,createNewTask:n}=t;let i;return e[0]!==n||e[1]!==s?(i=()=>(s.current=n,()=>{s.current=null}),e[0]=n,e[1]=s,e[2]=i):i=e[2],A.useLayoutEffect(i),null}function Z1(t){const e=F.c(30),{virtualMcpId:s,hasActiveGithubRepo:n,sandboxMap:i,children:o}=t,{currentBranch:a,activeTask:l}=Zt(),{pendingSandboxProviderKind:c}=Ts(),{data:d}=Di.useSession(),h=d?.user?.id,u=l?.metadata?.sandboxMap,f=h&&a&&u?.[h]?.[a]?{...i??{},[h]:{...i?.[h]??{},[a]:u[h][a]}}:i;let m;e[0]!==l?.metadata||e[1]!==n?(m=n||sn(l?.metadata),e[0]=l?.metadata,e[1]=n,e[2]=m):m=e[2];const p=m,g=h??null,x=l?.created_by,v=l?.branch,b=l?.title;let y;e[3]!==g||e[4]!==x||e[5]!==v||e[6]!==b?(y=_y({userId:g,createdBy:x,branch:v,title:b}),e[3]=g,e[4]=x,e[5]=v,e[6]=b,e[7]=y):y=e[7];const _=y,L=ry(s,a??void 0),w=h&&a?zl(f?.[h]?.[a]):{},S=(c?w[c]??null:Y2(w))?.previewUrl??null;let C;e[8]!==w||e[9]!==L?(C=Object.keys(w).length>0||L,e[8]=w,e[9]=L,e[10]=C):C=e[10];const N=C,V=a??null,E=a??null,T=h??null,k=l?.id??null,R=`${s}:${a??"no-branch"}`;let P;e[11]!==o||e[12]!==R?(P=r.jsx(CE,{children:o},R),e[11]=o,e[12]=R,e[13]=P):P=e[13];let D;e[14]!==p||e[15]!==f||e[16]!==_||e[17]!==c||e[18]!==T||e[19]!==k||e[20]!==P||e[21]!==E||e[22]!==s?(D=r.jsx(wy,{virtualMcpId:s,branch:E,userId:T,hasActiveGithubRepo:p,sandboxMap:f,sandboxProviderKind:c,othersThreadLabel:_,othersThreadId:k,children:P}),e[14]=p,e[15]=f,e[16]=_,e[17]=c,e[18]=T,e[19]=k,e[20]=P,e[21]=E,e[22]=s,e[23]=D):D=e[23];let I;return e[24]!==S||e[25]!==N||e[26]!==D||e[27]!==V||e[28]!==s?(I=r.jsx(py,{virtualMcpId:s,branch:V,previewUrl:S,enabled:N,children:D}),e[24]=S,e[25]=N,e[26]=D,e[27]=V,e[28]=s,e[29]=I):I=e[29],I}function nK(t){const e=F.c(26),{entity:s,virtualMcpId:n,layout:i,onNewTaskRef:o}=t,a=!i.mainOpen;let l;e[0]!==i.sidePanel||e[1]!==i.toggleSidePanel||e[2]!==a?(l=r.jsx(ol.Toggles,{children:r.jsx(uz,{sidePanel:i.sidePanel,toggleSidePanel:i.toggleSidePanel,disableActiveSidePanelToggle:a})}),e[0]=i.sidePanel,e[1]=i.toggleSidePanel,e[2]=a,e[3]=l):l=e[3];const c=i.sidePanel===null;let d;e[4]!==i.taskId||e[5]!==c||e[6]!==n?(d=r.jsx(ol.Tabs,{children:r.jsx(pz,{virtualMcpId:n,taskId:i.taskId,disableActiveMainToggle:c})}),e[4]=i.taskId,e[5]=c,e[6]=n,e[7]=d):d=e[7];let h;e[8]!==i.createNewTask||e[9]!==o?(h=r.jsx(N5,{onNewTaskRef:o,createNewTask:i.createNewTask}),e[8]=i.createNewTask,e[9]=o,e[10]=h):h=e[10];let u;e[11]!==s?(u=r.jsx(Zz,{virtualMcp:s}),e[11]=s,e[12]=u):u=e[12];let f;e[13]===Symbol.for("react.memo_cache_sentinel")?(f=r.jsx(yt.Skeleton,{}),e[13]=f):f=e[13];let m;e[14]===Symbol.for("react.memo_cache_sentinel")?(m=r.jsx(V5,{}),e[14]=m):m=e[14];let p;e[15]!==i.mainOpen||e[16]!==i.sidePanel||e[17]!==i.taskId||e[18]!==n?(p=r.jsx(A.Suspense,{fallback:f,children:r.jsx(lz,{virtualMcpId:n,taskId:i.taskId,sidePanel:i.sidePanel,mainOpen:i.mainOpen,chatContent:m})}),e[15]=i.mainOpen,e[16]=i.sidePanel,e[17]=i.taskId,e[18]=n,e[19]=p):p=e[19];let g;return e[20]!==l||e[21]!==d||e[22]!==h||e[23]!==u||e[24]!==p?(g=r.jsxs(r.Fragment,{children:[l,d,h,u,p]}),e[20]=l,e[21]=d,e[22]=h,e[23]=u,e[24]=p,e[25]=g):g=e[25],g}function iK(t){const e=F.c(16),{virtualMcpId:s,layout:n,onNewTaskRef:i}=t,o=re(),a=n.mainOpen?"main":n.sidePanel??"chat";let l;e[0]!==n.taskId||e[1]!==s?(l=r.jsx(ol.Tabs,{children:r.jsx(_z,{virtualMcpId:s,taskId:n.taskId})}),e[0]=n.taskId,e[1]=s,e[2]=l):l=e[2];let c;e[3]!==n.createNewTask||e[4]!==i?(c=r.jsx(N5,{onNewTaskRef:i,createNewTask:n.createNewTask}),e[3]=n.createNewTask,e[4]=i,e[5]=c):c=e[5];let d;e[6]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(yt.Skeleton,{}),e[6]=d):d=e[6];let h;e[7]!==n.taskId||e[8]!==a||e[9]!==o||e[10]!==s?(h=r.jsx(A.Suspense,{fallback:d,children:r.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:a==="main"?r.jsx(ys,{fallback:r.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:o("agentShellLayout.agentShellLayout.somethingWentWrong")}),children:r.jsx(A.Suspense,{fallback:r.jsx("div",{className:"h-full flex items-center justify-center",children:r.jsx(et,{size:20,className:"animate-spin text-muted-foreground"})}),children:r.jsx("div",{"data-testid":"main-panel",className:"h-full",children:r.jsx(L5,{taskId:n.taskId,virtualMcpId:s})})})}):r.jsx(S5,{chatContent:r.jsx(V5,{})})})}),e[7]=n.taskId,e[8]=a,e[9]=o,e[10]=s,e[11]=h):h=e[11];let u;return e[12]!==l||e[13]!==c||e[14]!==h?(u=r.jsxs(r.Fragment,{children:[l,c,h]}),e[12]=l,e[13]=c,e[14]=h,e[15]=u):u=e[15],u}function rK(){const t=F.c(97),e=re(),s=Cr(),n=St(),{org:i}=Oe();eb(i.slug);let o;t[0]===Symbol.for("react.memo_cache_sentinel")?(o={strict:!1},t[0]=o):o=t[0];const a=Kl(o),l=a.org??"";let c;t[1]===Symbol.for("react.memo_cache_sentinel")?(c={strict:!1},t[1]=c):c=t[1];const d=wr(c);let h;t[2]!==i.id||t[3]!==d.virtualmcpid?(h=d.virtualmcpid??Yo(i.id).id,t[2]=i.id,t[3]=d.virtualmcpid,t[4]=h):h=t[4];const u=h,f=eK(a.taskId??"",u),m=gs(u),p=m?.metadata?.ui?.layout??null;let g;t[5]!==p?(g=p?{defaultMainView:p.defaultMainView??null,chatDefaultOpen:p.chatDefaultOpen??null}:null,t[5]=p,t[6]=g):g=t[6];const x=g;let v;t[7]!==m?(v=m&&sa(m),t[7]=m,t[8]=v):v=t[8];const b=!!v;let y;t[9]!==l||t[10]!==u?(y={virtualMcpId:u,orgSlug:l,isAgentRoute:!0},t[9]=l,t[10]=u,t[11]=y):y=t[11];const _=AS(x,y),L=A.useRef(null);let w,j;t[12]===Symbol.for("react.memo_cache_sentinel")?(w=()=>{const M=O=>{jm(O)&&O.shiftKey&&O.code==="KeyS"&&!O.repeat&&(O.preventDefault(),L.current?.())};return document.addEventListener("keydown",M),()=>document.removeEventListener("keydown",M)},j=[],t[12]=w,t[13]=j):(w=t[12],j=t[13]),A.useEffect(w,j);const S=u;let C;t[14]!==m||t[15]!==u?(C={virtualMcpId:u,entity:m},t[14]=m,t[15]=u,t[16]=C):C=t[16];const N=C;if(f.status==="creating"||f.status==="loading"){let M;t[17]===Symbol.for("react.memo_cache_sentinel")?(M=r.jsx(et,{className:"size-4 animate-spin mr-2"}),t[17]=M):M=t[17];let O;t[18]!==e?(O=e("agentShellLayout.agentShellLayout.creatingTask"),t[18]=e,t[19]=O):O=t[19];let $;t[20]!==O?($=r.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:r.jsxs("div",{className:"flex h-full items-center justify-center bg-background card-shadow rounded-[0.75rem] text-sm text-muted-foreground",children:[M,O]})}),t[20]=O,t[21]=$):$=t[21];let B;return t[22]!==N||t[23]!==$?(B=r.jsx(er,{value:N,children:$}),t[22]=N,t[23]=$,t[24]=B):B=t[24],B}if(f.status==="error"){let M;t[25]!==e?(M=e("agentShellLayout.agentShellLayout.taskUnavailable"),t[25]=e,t[26]=M):M=t[26];let O;t[27]!==M?(O=r.jsx("div",{className:"font-medium",children:M}),t[27]=M,t[28]=O):O=t[28];let $;t[29]!==f.error.message?($=r.jsx("div",{className:"text-muted-foreground",children:f.error.message}),t[29]=f.error.message,t[30]=$):$=t[30];let B;t[31]!==O||t[32]!==$?(B=r.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:r.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:[O,$]})}),t[31]=O,t[32]=$,t[33]=B):B=t[33];let z;return t[34]!==N||t[35]!==B?(z=r.jsx(er,{value:N,children:B}),t[34]=N,t[35]=B,t[36]=z):z=t[36],z}if(!m){let M;t[37]===Symbol.for("react.memo_cache_sentinel")?(M=r.jsx(wn,{size:48,className:"text-muted-foreground"}),t[37]=M):M=t[37];let O;t[38]!==e?(O=e("agentShellLayout.agentShellLayout.agentNotFound"),t[38]=e,t[39]=O):O=t[39];let $;t[40]!==e||t[41]!==u?($=e("agentShellLayout.agentShellLayout.agentNotFoundDescription",{virtualMcpId:u}),t[40]=e,t[41]=u,t[42]=$):$=t[42];let B;t[43]!==n||t[44]!==l?(B=()=>n({to:"/$org",params:{org:l}}),t[43]=n,t[44]=l,t[45]=B):B=t[45];let z;t[46]!==e?(z=e("agentShellLayout.agentShellLayout.goToOrgHome"),t[46]=e,t[47]=z):z=t[47];let K;t[48]!==B||t[49]!==z?(K=r.jsx(le,{variant:"outline",onClick:B,children:z}),t[48]=B,t[49]=z,t[50]=K):K=t[50];let G;t[51]!==O||t[52]!==$||t[53]!==K?(G=r.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:r.jsx("div",{className:"flex flex-col h-full bg-background overflow-hidden card-shadow rounded-[0.75rem]",children:r.jsx(ki,{image:M,title:O,description:$,actions:K})})}),t[51]=O,t[52]=$,t[53]=K,t[54]=G):G=t[54];let Y;return t[55]!==N||t[56]!==G?(Y=r.jsx(er,{value:N,children:G}),t[55]=N,t[56]=G,t[57]=Y):Y=t[57],Y}if(s){const M=f.status==="ready"?f.task:null,O=m?.metadata?.sandboxMap;let $;t[58]===Symbol.for("react.memo_cache_sentinel")?($=r.jsx(yt.Skeleton,{}),t[58]=$):$=t[58];let B;t[59]!==S||t[60]!==_?(B=r.jsx(A.Suspense,{fallback:$,children:r.jsx(iK,{virtualMcpId:S,layout:_,onNewTaskRef:L})}),t[59]=S,t[60]=_,t[61]=B):B=t[61];let z;t[62]!==_.taskId||t[63]!==B?(z=r.jsx(yt.ActiveTaskProvider,{taskId:_.taskId,children:B},_.taskId),t[62]=_.taskId,t[63]=B,t[64]=z):z=t[64];let K;t[65]!==b||t[66]!==O||t[67]!==z||t[68]!==u?(K=r.jsx(Z1,{virtualMcpId:u,hasActiveGithubRepo:b,sandboxMap:O,children:z}),t[65]=b,t[66]=O,t[67]=z,t[68]=u,t[69]=K):K=t[69];let G;t[70]!==S||t[71]!==K||t[72]!==M?(G=r.jsx("div",{className:"flex flex-col flex-1 min-w-0 bg-background min-h-0",children:r.jsx(yt.Provider,{virtualMcpId:S,task:M,children:K},S)}),t[70]=S,t[71]=K,t[72]=M,t[73]=G):G=t[73];let Y;return t[74]!==N||t[75]!==G?(Y=r.jsx(er,{value:N,children:G}),t[74]=N,t[75]=G,t[76]=Y):Y=t[76],Y}const V=f.status==="ready"?f.task:null,E=m?.metadata?.sandboxMap;let T;t[77]===Symbol.for("react.memo_cache_sentinel")?(T=r.jsx(yt.Skeleton,{}),t[77]=T):T=t[77];let k;t[78]!==m||t[79]!==_||t[80]!==u?(k=r.jsx(A.Suspense,{fallback:T,children:r.jsx(nK,{entity:m,virtualMcpId:u,layout:_,onNewTaskRef:L})}),t[78]=m,t[79]=_,t[80]=u,t[81]=k):k=t[81];let R;t[82]!==_.taskId||t[83]!==k?(R=r.jsx(yt.ActiveTaskProvider,{taskId:_.taskId,children:k},_.taskId),t[82]=_.taskId,t[83]=k,t[84]=R):R=t[84];let P;t[85]!==b||t[86]!==E||t[87]!==R||t[88]!==u?(P=r.jsx(Z1,{virtualMcpId:u,hasActiveGithubRepo:b,sandboxMap:E,children:R}),t[85]=b,t[86]=E,t[87]=R,t[88]=u,t[89]=P):P=t[89];let D;t[90]!==S||t[91]!==P||t[92]!==V?(D=r.jsx(yt.Provider,{virtualMcpId:S,task:V,children:P},S),t[90]=S,t[91]=P,t[92]=V,t[93]=D):D=t[93];let I;return t[94]!==N||t[95]!==D?(I=r.jsx("div",{className:"flex-1 min-w-0 flex flex-col",children:r.jsx(er,{value:N,children:D})}),t[94]=N,t[95]=D,t[96]=I):I=t[96],I}function oK(){const t=F.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx(lx,{}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(A.Suspense,{fallback:e,children:r.jsxs(gb,{children:[r.jsx(rK,{}),r.jsx(tK,{})]})}),t[1]=s):s=t[1],s}const rW=Object.freeze(Object.defineProperty({__proto__:null,default:oK,useInsetContext:ci},Symbol.toStringTag,{value:"Module"}));export{Yg as $,wf as A,GH as B,Ko as C,Ta as D,Xy as E,Ag as F,N9 as G,fc as H,FD as I,ti as J,Br as K,tu as L,yr as M,Z9 as N,P3 as O,$r as P,xc as Q,GP as R,In as S,bs as T,U9 as U,eu as V,Ln as W,AP as X,PP as Y,JH as Z,Q9 as _,LH as a,Cp as a$,YH as a0,Lw as a1,yw as a2,AH as a3,bu as a4,_R as a5,FH as a6,eW as a7,tW as a8,G9 as a9,Fr as aA,DH as aB,zH as aC,SA as aD,UH as aE,BH as aF,pA as aG,PH as aH,$H as aI,OH as aJ,MH as aK,QH as aL,TH as aM,EH as aN,NH as aO,ZH as aP,_u as aQ,ug as aR,dg as aS,wH as aT,ZT as aU,CH as aV,kH as aW,tA as aX,qH as aY,IH as aZ,WH as a_,wu as aa,SH as ab,KH as ac,Dl as ad,CI as ae,rc as af,oc as ag,ci as ah,GE as ai,M9 as aj,uw as ak,cc as al,xg as am,El as an,JR as ao,jH as ap,wI as aq,sW as ar,bg as as,RH as at,gI as au,XT as av,QT as aw,yu as ax,o4 as ay,OP as az,Md as b,HH as b0,yH as b1,iw as b2,ow as b3,rW as b4,Od as c,_n as d,pg as e,Ha as f,Ho as g,qE as h,fs as i,Sl as j,yc as k,XH as l,Hg as m,aP as n,qI as o,bH as p,_H as q,yn as r,k5 as s,VH as t,Er as u,HE as v,IP as w,Wa as x,SP as y,Va as z};
|