decocms 3.80.0 → 3.82.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-CzPpSV3W.js → AlertCircle-DifM-3Ys.js} +1 -1
- package/dist/client/assets/{ArrowUpRight-BefNTATY.js → ArrowUpRight-DTNfyjlQ.js} +1 -1
- package/dist/client/assets/{CheckCircle-BRNW9lmT.js → CheckCircle-DmLgOHHp.js} +1 -1
- package/dist/client/assets/{ChevronDown-Di-ZHzN-.js → ChevronDown-BY59w4Qk.js} +1 -1
- package/dist/client/assets/{ChevronLeft-ByolOLbh.js → ChevronLeft-DVIgNVyn.js} +1 -1
- package/dist/client/assets/{ChevronRight-CmB8MBzZ.js → ChevronRight-CM2UCxLV.js} +1 -1
- package/dist/client/assets/{ChevronUp-BurUkCqE.js → ChevronUp-ELVqY6cz.js} +1 -1
- package/dist/client/assets/{DotsVertical-Dsznav3Y.js → DotsVertical-FbZSolmB.js} +1 -1
- package/dist/client/assets/{Eye-B8NUm9Br.js → Eye-8PGvC0iK.js} +1 -1
- package/dist/client/assets/{FilterLines-DMbodALc.js → FilterLines-Cf2PdvFM.js} +1 -1
- package/dist/client/assets/{Globe01-BG9Wm5DJ.js → Globe01-B90chNia.js} +1 -1
- package/dist/client/assets/{Globe04-Fg_TSPLj.js → Globe04-Dw4nWd3A.js} +1 -1
- package/dist/client/assets/{HardDrive-BLr46_IN.js → HardDrive-CKn4i_9T.js} +1 -1
- package/dist/client/assets/{Key01-Dc0MTS9j.js → Key01-oftOkafI.js} +1 -1
- package/dist/client/assets/{LayoutLeft-nNhAa0Dy.js → LayoutLeft-Bij2Lb4X.js} +1 -1
- package/dist/client/assets/{LinkExternal01-D0OVTAOa.js → LinkExternal01-9FNotiMN.js} +1 -1
- package/dist/client/assets/{Monitor01-D_VMj6ZB.js → Monitor01-CR1JDEQ7.js} +1 -1
- package/dist/client/assets/{Palette-BmXFbt3l.js → Palette-ArrfZuOV.js} +1 -1
- package/dist/client/assets/{Play-CAiQqhjZ.js → Play-BB5dP1L8.js} +1 -1
- package/dist/client/assets/{Plus-DHDiWYHk.js → Plus-CglBKrb5.js} +1 -1
- package/dist/client/assets/{SearchMd-DaWHy1GV.js → SearchMd-Bmh_sD0S.js} +1 -1
- package/dist/client/assets/{Settings02-B7jENSJZ.js → Settings02-RazZjdiv.js} +1 -1
- package/dist/client/assets/{Shield01-YoAzrA51.js → Shield01-D44r3AdO.js} +1 -1
- package/dist/client/assets/{Star01-CaB7lNB9.js → Star01-C9VN0Du_.js} +1 -1
- package/dist/client/assets/{Stars01-a6WqibZn.js → Stars01-CoxwYWLP.js} +1 -1
- package/dist/client/assets/{Stars02-D2Vky1vN.js → Stars02-l9mDD3eo.js} +1 -1
- package/dist/client/assets/{Sun-vyxrPcie.js → Sun-D-fwbx_z.js} +1 -1
- package/dist/client/assets/{SwitchHorizontal01-C3K-vKiU.js → SwitchHorizontal01-DO04KALD.js} +1 -1
- package/dist/client/assets/{Tool01-CTw8qR4v.js → Tool01-CqbO1hX2.js} +1 -1
- package/dist/client/assets/{Trash01-BzTEx-hS.js → Trash01-DUxygeaL.js} +1 -1
- package/dist/client/assets/{Upload01-DwgHgRix.js → Upload01-CEAuuYpa.js} +1 -1
- package/dist/client/assets/{User01-BtO-AoKy.js → User01-fdrqbZOX.js} +1 -1
- package/dist/client/assets/{Users01-BRTza8nY.js → Users01-BQH1rUR7.js} +1 -1
- package/dist/client/assets/{Users03-9LUo_raC.js → Users03-V7VYPOVz.js} +1 -1
- package/dist/client/assets/{X-1BuEzBGR.js → X-DH6rpzm4.js} +1 -1
- package/dist/client/assets/{XCircle-DtHr5hnB.js → XCircle-CNgW1bnA.js} +1 -1
- package/dist/client/assets/{XClose-qpXD94Yo.js → XClose-DY_H1WmQ.js} +1 -1
- package/dist/client/assets/{Zap-DluXKGP1.js → Zap-jC0lbn1q.js} +1 -1
- package/dist/client/assets/{ZapSquare-C2q_71C5.js → ZapSquare-wbaFJ6J6.js} +1 -1
- package/dist/client/assets/{ZoomOut-DHX-bR9F.js → ZoomOut-XI-iJG4j.js} +1 -1
- package/dist/client/assets/{access-gate-CGKEhEok.js → access-gate-DDQd7LZ9.js} +1 -1
- package/dist/client/assets/{add-section-modal-SzJO4niJ.js → add-section-modal-DbYQ6fO0.js} +1 -1
- package/dist/client/assets/{agent-icon-B8qJNw4_.js → agent-icon-BUISstKv.js} +1 -1
- package/dist/client/assets/{agents-list-BCVql_rD.js → agents-list-CLbNQC9z.js} +1 -1
- package/dist/client/assets/{ai-providers-DfbrzvnV.js → ai-providers-61qxW7f5.js} +1 -1
- package/dist/client/assets/{alert-BdFRtqYC.js → alert-VlhASuYO.js} +1 -1
- package/dist/client/assets/{alert-dialog-CSRFWtbt.js → alert-dialog-Dh6V_14o.js} +1 -1
- package/dist/client/assets/{app-editor-CSxGjHmN.js → app-editor-BI1KpS86.js} +1 -1
- package/dist/client/assets/{auth-DOooeHhC.js → auth-COC6Da1O.js} +1 -1
- package/dist/client/assets/{auth-catchall-esDJNOF7.js → auth-catchall-DjeD5XiQ.js} +1 -1
- package/dist/client/assets/{auth-entry-CJkDGWB9.js → auth-entry-DDP2v7bj.js} +1 -1
- package/dist/client/assets/{auth-split-layout-BHOeLJSB.js → auth-split-layout-CYQ7PKOY.js} +1 -1
- package/dist/client/assets/{authenticate-and-persist-oauth-CAo_oHNJ.js → authenticate-and-persist-oauth-7kSYvcg8.js} +1 -1
- package/dist/client/assets/{automation-list-row-CBS-1Qac.js → automation-list-row-DCvQVGai.js} +1 -1
- package/dist/client/assets/{automation-runs-BhCrA9zN.js → automation-runs-DMkXGxyD.js} +1 -1
- package/dist/client/assets/{automations-DgOam79q.js → automations-CRTazwGA.js} +1 -1
- package/dist/client/assets/{avatar-BnBqk-2k.js → avatar-yxz7fyGH.js} +1 -1
- package/dist/client/assets/{badge-CpxlbcB7.js → badge-CQquKN9p.js} +1 -1
- package/dist/client/assets/{block-document-DJ0g8qfo.js → block-document-BBSIfcJ0.js} +1 -1
- package/dist/client/assets/{brand-context-COIa0n8O.js → brand-context-gRadlp6o.js} +1 -1
- package/dist/client/assets/{buckets-BINQS-Su.js → buckets-CHaLsSDx.js} +1 -1
- package/dist/client/assets/{capability-load-error-HdFgr5IE.js → capability-load-error-geYLJLvZ.js} +1 -1
- package/dist/client/assets/{card-DQnbTJFb.js → card-Bj8otFuN.js} +1 -1
- package/dist/client/assets/category-editor-UeZPwCgj.js +1 -0
- package/dist/client/assets/{chat-context-CmZjYRTw.js → chat-context-D2XCyHNy.js} +1 -1
- package/dist/client/assets/{checkbox-DokO2DXd.js → checkbox-Da1mUHNU.js} +1 -1
- package/dist/client/assets/{cli-auth-success-NPtl5xjH.js → cli-auth-success-DGCDjW3a.js} +1 -1
- package/dist/client/assets/{collection-detail-DgzIzvmX.js → collection-detail-B8ehy7SJ.js} +1 -1
- package/dist/client/assets/{collection-display-button-hKaFuGbc.js → collection-display-button-BbDeI4M_.js} +1 -1
- package/dist/client/assets/{collection-search-9oxtR-cY.js → collection-search-Bde6_LbH.js} +1 -1
- package/dist/client/assets/{collection-tabs-CvHGsfW_.js → collection-tabs-CmheS0lt.js} +1 -1
- package/dist/client/assets/{command-Bw5g6PzP.js → command-D_g4Qh6z.js} +1 -1
- package/dist/client/assets/commerce-onboarding-hTRnas9I.js +1 -0
- package/dist/client/assets/{connect-desktop-dialog-BktLGd3J.js → connect-desktop-dialog-CSA1yCDL.js} +1 -1
- package/dist/client/assets/{connection-card-BZz5WDR5.js → connection-card-BavDtRRe.js} +1 -1
- package/dist/client/assets/{connection-detail-DNAdeiIH.js → connection-detail-BluTRGVx.js} +1 -1
- package/dist/client/assets/{connection-form-helpers-CltinQul.js → connection-form-helpers-vW7WD93k.js} +1 -1
- package/dist/client/assets/{connections-BSiahnsQ.js → connections-C6JDIrTa.js} +1 -1
- package/dist/client/assets/{context-menu-ByPsUX7u.js → context-menu-CFoKwdsl.js} +1 -1
- package/dist/client/assets/{decopilot-DjAEZRNX.js → decopilot-DgdLPSeb.js} +1 -1
- package/dist/client/assets/{decopilot-sse-pool-R-AtQW2s.js → decopilot-sse-pool-BRv-o5yu.js} +1 -1
- package/dist/client/assets/{dialog-L9SFsS1U.js → dialog-D9WjjXCi.js} +1 -1
- package/dist/client/assets/{domain-settings-BDbjH98X.js → domain-settings-BzX_jmew.js} +1 -1
- package/dist/client/assets/{drawer-D-LP9Hh8.js → drawer-B07QIoON.js} +1 -1
- package/dist/client/assets/{dropdown-menu-ByaGrYAQ.js → dropdown-menu-Cym0YADL.js} +1 -1
- package/dist/client/assets/{empty-state-BoeIt5Fh.js → empty-state-Dc-tsC-2.js} +1 -1
- package/dist/client/assets/{extract-connection-data-Rczvmr_Y.js → extract-connection-data-BSTqgqHH.js} +1 -1
- package/dist/client/assets/{file-explorer-QNJW4EAt.js → file-explorer-BfDoSrZk.js} +1 -1
- package/dist/client/assets/{file-type-icon-C96ES1WD.js → file-type-icon-DtYuEk9O.js} +1 -1
- package/dist/client/assets/{files-CK2ZpMSb.js → files-Brjfptic.js} +1 -1
- package/dist/client/assets/{form-Ci3Mfx5E.js → form-2979wdxX.js} +1 -1
- package/dist/client/assets/{general-Dt135lsN.js → general-CTI0wRux.js} +1 -1
- package/dist/client/assets/{github-repo-picker-CLrsrBV_.js → github-repo-picker-BkDPWKjv.js} +1 -1
- package/dist/client/assets/{hooks-BBwQx9Hj.js → hooks-CMSXeMFL.js} +1 -1
- package/dist/client/assets/{import-from-deco-dialog-D3nDDNau.js → import-from-deco-dialog-D-c4LLRp.js} +1 -1
- package/dist/client/assets/{index-_BBnqQdQ.js → index-BYx78v24.js} +1 -1
- package/dist/client/assets/{index-Dtsr5F6p.js → index-CHiBkNe7.js} +1 -1
- package/dist/client/assets/{index-CuZWA4Jo.js → index-CcHBEZaL.js} +1 -1
- package/dist/client/assets/{index-DM3CipuA.js → index-CfQz19re.js} +1 -1
- package/dist/client/assets/{index-DUXTdmoE.js → index-CkgRi4X3.js} +1 -1
- package/dist/client/assets/{index-DF_aAsrE.js → index-D6hU96vm.js} +1 -1
- package/dist/client/assets/{index-JnEot5Hj.js → index-DFxFL0tW.js} +1 -1
- package/dist/client/assets/{index-BYWWr4r7.js → index-DXI2OWA9.js} +1 -1
- package/dist/client/assets/{index-28ylgXoe.js → index-Y-0r87FI.js} +1 -1
- package/dist/client/assets/{index-B-wtw2cV.js → index-eQTuHKl6.js} +1 -1
- package/dist/client/assets/{index-Y9nbouYw.js → index-gNo-Kuqg.js} +1 -1
- package/dist/client/assets/{index-BRqNUInJ.js → index-ndGiTd2H.js} +1 -1
- package/dist/client/assets/{index-D4eNxtKO.js → index-pvUD-kUc.js} +5 -5
- package/dist/client/assets/{index-redirect-DmPoZnz_.js → index-redirect-C7otwZuS.js} +1 -1
- package/dist/client/assets/{index-DrM3Gy-E.js → index-vUJ0Rroa.js} +3 -3
- package/dist/client/assets/index-xCrqP1qS.css +1 -0
- package/dist/client/assets/{input-BiM4A7Ep.js → input-D475ckPl.js} +1 -1
- package/dist/client/assets/{integration-icon-g_GK3RAr.js → integration-icon-DWC1E-NM.js} +1 -1
- package/dist/client/assets/{label-CjJncELr.js → label-Ds5L98Th.js} +1 -1
- package/dist/client/assets/{login-BOHERlR0.js → login-Bna6EQXB.js} +1 -1
- package/dist/client/assets/{mcp-oauth-CEKI9gHX.js → mcp-oauth-BuJKTbpq.js} +1 -1
- package/dist/client/assets/{members-BRt8WHan.js → members-CfxGG4ms.js} +1 -1
- package/dist/client/assets/{monaco-editor-BiUexVQ3.js → monaco-editor-BIbmj68Y.js} +1 -1
- package/dist/client/assets/{monitoring-stats-row-CwoDwl1p.js → monitoring-stats-row-FEqgyaSm.js} +1 -1
- package/dist/client/assets/{oauth-callback-BuVPnEYV.js → oauth-callback-BTT9yfsW.js} +1 -1
- package/dist/client/assets/{oauth-callback-ai-provider-YJv6IQM9.js → oauth-callback-ai-provider-NTmJLpKs.js} +1 -1
- package/dist/client/assets/{onboarding-CYpSkBDm.js → onboarding-Bg6NNcXN.js} +1 -1
- package/dist/client/assets/{org-install-DCy7wocy.js → org-install-DU4xYSjy.js} +1 -1
- package/dist/client/assets/{org-layout-RT_U7zH8.js → org-layout-BI-1sw6-.js} +1 -1
- package/dist/client/assets/{organization-choice-bTsrQb1b.js → organization-choice-BKBCasUi.js} +1 -1
- package/dist/client/assets/{page-seo-form-oftq8ir_.js → page-seo-form-UXOt1Xq8.js} +1 -1
- package/dist/client/assets/page-seo-sheet-Cb5cCBSA.js +1 -0
- package/dist/client/assets/{popover-CdhOYhn4.js → popover-BEzlzjXA.js} +1 -1
- package/dist/client/assets/{post-editor-B3gQokNp.js → post-editor-Dlb8m7Iz.js} +1 -1
- package/dist/client/assets/{preview-dialog-vDgojfWg.js → preview-dialog-DtFiLW4L.js} +1 -1
- package/dist/client/assets/{primitives-CPVg2JCk.js → primitives-BSQDvGLE.js} +1 -1
- package/dist/client/assets/{profile-C8hjNf5c.js → profile-BnTQMGfC.js} +1 -1
- package/dist/client/assets/project-app-view-C9CksfQE.js +1 -0
- package/dist/client/assets/record-editor-BjHlAGT_.js +1 -0
- package/dist/client/assets/registry-Bq0zziYB.js +2 -0
- package/dist/client/assets/{registry-layout-BuJ69l8z.js → registry-layout-Che-hfuD.js} +1 -1
- package/dist/client/assets/{require-capability-7xlqOMAl.js → require-capability-BPVqafNl.js} +1 -1
- package/dist/client/assets/{required-auth-layout-DMkbzFqw.js → required-auth-layout-0H2r_sG0.js} +1 -1
- package/dist/client/assets/{reset-password-CANGclZQ.js → reset-password-BnD36W_y.js} +1 -1
- package/dist/client/assets/{roles-BsbFpQdA.js → roles-E1DxEKKj.js} +1 -1
- package/dist/client/assets/{save-status-BZrjQZNL.js → save-status-lTcRFIDk.js} +1 -1
- package/dist/client/assets/{scroll-area-DaDHqFsI.js → scroll-area-BcHB6NVX.js} +1 -1
- package/dist/client/assets/{search-input-CA0juGKQ.js → search-input-DLLGaO2O.js} +1 -1
- package/dist/client/assets/{secrets-2KI9BQIB.js → secrets-CPwF9JEQ.js} +1 -1
- package/dist/client/assets/{sections-editor-DAz_riff.js → sections-editor-C33mQAPq.js} +1 -1
- package/dist/client/assets/{select-model-DhPTkTLZ.js → select-model-DRzRHvEm.js} +1 -1
- package/dist/client/assets/{select-lfhjFS6i.js → select-wPD7z-7a.js} +1 -1
- package/dist/client/assets/{seo-editor-qYixYUVP.js → seo-editor-DVLMhS9K.js} +1 -1
- package/dist/client/assets/{settings-layout-D8_yU3Dv.js → settings-layout-D_rTN8X_.js} +1 -1
- package/dist/client/assets/{settings-section-uGwPOE8T.js → settings-section-DTFkKe0k.js} +1 -1
- package/dist/client/assets/{sheet-nKeubIDJ.js → sheet-D7Sq65N5.js} +1 -1
- package/dist/client/assets/{shell-controls-Nhg6txWq.js → shell-controls-MZoa2pcn.js} +1 -1
- package/dist/client/assets/{shell-layout-DJP1UAvL.js → shell-layout-CicMe8M5.js} +1 -1
- package/dist/client/assets/{shell-route-loading-BQkX9uZV.js → shell-route-loading-ALc0mrI8.js} +1 -1
- package/dist/client/assets/{sidebar-BDxhgXc-.js → sidebar-BBRwD7tX.js} +1 -1
- package/dist/client/assets/{skeleton-CQjs3VsL.js → skeleton-Et7A2pSm.js} +1 -1
- package/dist/client/assets/{sortable.esm-DaR8hxU_.js → sortable.esm-DHRoGvrT.js} +1 -1
- package/dist/client/assets/{sso-hQT21VNe.js → sso-C92vsbFf.js} +1 -1
- package/dist/client/assets/{store-BEmqzV80.js → store-BkJbUZAQ.js} +1 -1
- package/dist/client/assets/store-registry-Pmy6lYa3.js +2 -0
- package/dist/client/assets/{studio-tools-CAUx-JUt.js → studio-tools-BZzXzwRs.js} +1 -1
- package/dist/client/assets/{switch-Vf_P6Fjw.js → switch-CS7rft2F.js} +1 -1
- package/dist/client/assets/{table-Df43OI16.js → table-6zTgSv0k.js} +1 -1
- package/dist/client/assets/{tabs-B7LOh75O.js → tabs-NT5hIgye.js} +1 -1
- package/dist/client/assets/{task-status-CNl7XTqg.js → task-status-BGl9HRbw.js} +1 -1
- package/dist/client/assets/{textarea-CoSni5ST.js → textarea-Dv2h0FHy.js} +1 -1
- package/dist/client/assets/{toggle-group-Dpya1ElG.js → toggle-group-BlIuQKMU.js} +1 -1
- package/dist/client/assets/{toolbar-C-FtiPvy.js → toolbar-Dqn0u_dp.js} +1 -1
- package/dist/client/assets/{tooltip-Cs_BNuMF.js → tooltip-CMUaL9C1.js} +1 -1
- package/dist/client/assets/{types-GBPItn3L.js → types-BSxSWkiR.js} +1 -1
- package/dist/client/assets/{use-ai-providers-Cyy4e6Er.js → use-ai-providers-DzNi6Q_V.js} +1 -1
- package/dist/client/assets/{use-automations-jx__re2k.js → use-automations-DBCBw7t_.js} +1 -1
- package/dist/client/assets/{use-capability-_e3uVe_7.js → use-capability-hUlYEzZt.js} +1 -1
- package/dist/client/assets/{use-clock-tick-g2v6P087.js → use-clock-tick-BQWtBapt.js} +1 -1
- package/dist/client/assets/{use-collections-B_GMLsdD.js → use-collections-CmcFURA8.js} +1 -1
- package/dist/client/assets/{use-connection-DKt0DY8s.js → use-connection-BlyaSvk_.js} +1 -1
- package/dist/client/assets/{use-copy-CgtuLhVL.js → use-copy-Ck1s3Ly_.js} +1 -1
- package/dist/client/assets/{use-create-virtual-mcp-3Gcq1gem.js → use-create-virtual-mcp-C6iKxwna.js} +1 -1
- package/dist/client/assets/{use-debounced-autosave-EPMbx34N.js → use-debounced-autosave-B3PmQihS.js} +1 -1
- package/dist/client/assets/{use-delete-connection-CWY-Tuh_.js → use-delete-connection-QgWRMpRZ.js} +1 -1
- package/dist/client/assets/{use-file-configs-Ci1h3IZS.js → use-file-configs-D4iNPF8_.js} +1 -1
- package/dist/client/assets/{use-infinite-scroll-Dt6SxdrG.js → use-infinite-scroll-D0Uygp_Y.js} +1 -1
- package/dist/client/assets/{use-join-requests-Dtt8rzJS.js → use-join-requests-BVSkwLEZ.js} +1 -1
- package/dist/client/assets/{use-mcp-client-lyJJArps.js → use-mcp-client-CbMJzr4L.js} +1 -1
- package/dist/client/assets/{use-mcp-prompts-82Xtua4M.js → use-mcp-prompts-BCcxOooU.js} +1 -1
- package/dist/client/assets/{use-mcp-tools-CdHM3tvY.js → use-mcp-tools-CoU1W6We.js} +1 -1
- package/dist/client/assets/{use-members-CR5Y6qBg.js → use-members-BkVP92fJ.js} +1 -1
- package/dist/client/assets/{use-navigate-to-agent-DKc1WVEH.js → use-navigate-to-agent-DAdQNXr7.js} +1 -1
- package/dist/client/assets/{use-org-auth-client-DyCA15LL.js → use-org-auth-client-BVVEzYWX.js} +1 -1
- package/dist/client/assets/{use-org-sso-DzO_wPSE.js → use-org-sso-BwpmbYKY.js} +1 -1
- package/dist/client/assets/{use-organization-roles-CfNQzskd.js → use-organization-roles-CubNpt4Q.js} +1 -1
- package/dist/client/assets/{use-organization-settings-DmFrFel5.js → use-organization-settings-BlTbQ8o8.js} +1 -1
- package/dist/client/assets/{use-registry-connections-grv_p5nm.js → use-registry-connections-6RdLigQp.js} +1 -1
- package/dist/client/assets/{use-secrets-DzWb-lJi.js → use-secrets-fz_TrA3p.js} +1 -1
- package/dist/client/assets/{use-status-sounds-CeAiKW9f.js → use-status-sounds-BRVcePS8.js} +1 -1
- package/dist/client/assets/{use-view-mode-PWJQxDpL.js → use-view-mode-BHx0KhQn.js} +1 -1
- package/dist/client/assets/{use-virtual-mcp-Bglvu7_H.js → use-virtual-mcp-BgEUqJv7.js} +1 -1
- package/dist/client/assets/useInfiniteQuery-ChBCbSD3.js +1 -0
- package/dist/client/assets/useSuspenseInfiniteQuery-COloy4Cl.js +1 -0
- package/dist/client/assets/{variant-calendar-BwPeBwqf.js → variant-calendar-cujTqFIv.js} +1 -1
- package/dist/client/assets/{view-mode-toggle-B_Gx2-J_.js → view-mode-toggle-Bpaa83uS.js} +1 -1
- package/dist/client/index.html +2 -2
- package/dist/server/cli.js +530 -525
- package/package.json +1 -1
- package/dist/client/assets/category-editor-vCwJctBK.js +0 -1
- package/dist/client/assets/commerce-onboarding-QQ9bqrwx.js +0 -1
- package/dist/client/assets/index-Bh2oT8fz.css +0 -1
- package/dist/client/assets/page-seo-sheet-CAgRh54V.js +0 -1
- package/dist/client/assets/project-app-view-CVZVC5T9.js +0 -1
- package/dist/client/assets/record-editor-BZDypwa5.js +0 -1
- package/dist/client/assets/registry-BSMljcPA.js +0 -2
- package/dist/client/assets/store-registry-BoeF7jFP.js +0 -2
- package/dist/client/assets/useInfiniteQuery-v9qNAGwf.js +0 -1
- package/dist/client/assets/useSuspenseInfiniteQuery-Bu3QWDEr.js +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/sections-editor-
|
|
2
|
-
import{c as U,r as D,l as ae,j as n,i as Oe,v as Me,a as $i,a2 as Zt,b as qt,u as eo,e as Fh,s as qp,L as Gp,k as Es,K as Et,m as oi,a3 as to,a4 as Yp,a5 as Xp,t as he,B as ie,a6 as Hh,a7 as Jp,a8 as Zp,q as Ke,a9 as Uh,aa as Qp,ab as so,ac as Pn,ad as Ht,ae as eg,E as Wh,C as tg,x as Vh,af as Ut,P as Kh,ag as sg,U as ig,$ as qh,W as ng,ah as rg,Q as og,ai as ag,d as ai,y as pr,aj as pn,z as ns,ak as ls}from"./index-DrM3Gy-E.js";import{C as it,a as lg,w as cg,u as ll,s as oa,T as dg,b as hg,g as ug,c as fg}from"./index-28ylgXoe.js";import{u as li,a as Ts,b as cl,c as Gh,S as dl,t as mg,d as pg}from"./chat-context-CmZjYRTw.js";import{i as zi}from"./AlertCircle-CzPpSV3W.js";import{i as Yh}from"./CheckCircle-BRNW9lmT.js";import{n as Tc}from"./ChevronLeft-ByolOLbh.js";import{a as gg,b as _g,i as vg}from"./XCircle-DtHr5hnB.js";import{s as Hs}from"./XClose-qpXD94Yo.js";import{a as vs,u as hl,b as Xh,c as xg}from"./use-virtual-mcp-Bglvu7_H.js";import{c as bg,u as yg,a as Jh,O as Sg,t as aa,S as Fi,T as wg,b as Zh,R as Cg,C as kg,G as jg,d as Ng,i as Eg,E as Tg,g as Ag,s as Rg,e as Pg,f as Dg,h as Ig}from"./scroll-area-DaDHqFsI.js";import{I as xs}from"./integration-icon-g_GK3RAr.js";import{a as Qh,u as Pt,S as ul,b as Lg,c as Og,i as Bg,d as eu}from"./use-mcp-client-lyJJArps.js";import{a as Mg}from"./Users03-9LUo_raC.js";import{t as cs}from"./ChevronDown-Di-ZHzN-.js";import{u as $g,h as zg,a as Wn,i as tu,j as ti,g as Fg,A as Hg,b as su,c as wr,K as iu,P as nu,D as ru,d as ou,S as au,v as lu,k as cu,l as la,e as du,C as hu,s as uu,m as Ug,n as Wg}from"./sortable.esm-DaR8hxU_.js";import{u as fu}from"./use-ai-providers-Cyy4e6Er.js";import{u as Vg}from"./connect-desktop-dialog-BktLGd3J.js";import{r as Kg,b as fl,i as qg}from"./shell-layout-DJP1UAvL.js";import{u as ml,T as Ne,a as Ee,b as Te,c as mu}from"./tooltip-Cs_BNuMF.js";import{u as Gg}from"./use-status-sounds-CeAiKW9f.js";import{E as Cr}from"./empty-state-BoeIt5Fh.js";import{r as ca,a as Yg,p as pu,f as Ac,b as gu,c as _u,d as vu,e as Xg,F as Jg,i as Zg,g as Qg,h as xu,j as bu}from"./tab-id-BptcWVWa.js";import{u as yu,a as Su}from"./hooks-BBwQx9Hj.js";import{T as Rc,a as gn}from"./toolbar-C-FtiPvy.js";import{u as e_,a as t_,b as s_,c as i_,g as n_,d as wu,e as Pc,f as r_,F as o_,h as a_,i as l_,j as c_,k as d_,l as h_,m as u_,H as f_,L as m_,R as Cu,n as p_,o as g_,T as pl,p as __,q as v_}from"./preview-dialog-vDgojfWg.js";import{g as Dn,h as gl,j as ku,k as x_,p as io,l as ci,m as _l,n as ju,o as da,q as wo,r as Dc,A as Ic,s as b_,t as y_,u as S_,v as w_,w as C_,x as Nu,y as k_,z as j_,B as N_,C as E_,D as Hi,E as T_,F as Lc,G as Oc,H as A_,d as R_,I as P_,J as D_,K as Ni,L as kr,M as no,N as I_,O as L_,P as O_,Q as B_,R as M_,S as $_,T as Eu,U as Ri,V as Bc,W as Tu,X as ro,Y as z_,Z as F_,_ as H_,$ as U_,a0 as W_,a1 as Mc,a2 as V_,a3 as K_,a4 as q_,a5 as Au,a6 as G_}from"./agent-icon-B8qJNw4_.js";import{i as Ui,n as Y_}from"./Globe01-BG9Wm5DJ.js";import{i as Ru}from"./Monitor01-D_VMj6ZB.js";import{u as Vn,a as vl,b as Pu}from"./use-connection-DKt0DY8s.js";import{u as oo,a as Du,b as Iu}from"./use-mcp-tools-CdHM3tvY.js";import{g as Lu}from"./types-GBPItn3L.js";import{u as di}from"./studio-tools-CAUx-JUt.js";import{u as X_}from"./use-capability-_e3uVe_7.js";import{F as Pi,M as xl,O as J_}from"./file-type-icon-C96ES1WD.js";import{P as As,a as Rs,b as Ps}from"./popover-CdhOYhn4.js";import{b as kt,c as Rt,S as jt,a as tt,d as Nt}from"./select-lfhjFS6i.js";import{D as Wt,a as Vt,b as Kt,c as Ue,d as ha,e as ua,f as fa,g as Cn,h as In,i as Co,j as ko}from"./dropdown-menu-ByaGrYAQ.js";import{d as Bt,c as Mt,D as ts,a as ss,e as Ws,b as Wi}from"./dialog-L9SFsS1U.js";import{I as ze}from"./input-BiM4A7Ep.js";import{T as zs,a as ao,b as Ei,c as lo}from"./tabs-B7LOh75O.js";import{T as Ln}from"./textarea-CoSni5ST.js";import{a as as,s as Z_}from"./Eye-B8NUm9Br.js";import{t as Zs}from"./Stars01-a6WqibZn.js";import{l as Q_,w as e1}from"./index-DF_aAsrE.js";import{i as Vi}from"./ChevronRight-CmB8MBzZ.js";import{a as ma,b as Ou,c as bl}from"./ZoomOut-DHX-bR9F.js";import{S as t1}from"./shell-route-loading-BQkX9uZV.js";import{a as s1}from"./extract-connection-data-Rczvmr_Y.js";import{A as jo}from"./avatar-BnBqk-2k.js";import{T as Bu,u as Mu,I as i1,R as n1,a as r1}from"./index-DUXTdmoE.js";import{a as o1,i as $c}from"./mcp-oauth-CEKI9gHX.js";import{s as $u,g as a1}from"./connection-slug-eyAPH6o3.js";import{f as jr,a as Nr,b as Er,c as Tr,d as Ar,e as Rr,A as Pr,g as Dr}from"./alert-dialog-CSRFWtbt.js";import{C as yl,a as Ir}from"./card-DQnbTJFb.js";import{L as Ve}from"./label-CjJncELr.js";import{S as On}from"./switch-Vf_P6Fjw.js";import{i as Di}from"./Play-CAiQqhjZ.js";import{s as Dt}from"./Plus-DHDiWYHk.js";import{a as l1,i as zu}from"./Settings02-B7jENSJZ.js";import{s as es}from"./Trash01-BzTEx-hS.js";import{u as Lr}from"./use-debounced-autosave-EPMbx34N.js";import{i as Bn}from"./SearchMd-DaWHy1GV.js";import{i as Kn}from"./Upload01-DwgHgRix.js";import{i as c1}from"./LayoutLeft-nNhAa0Dy.js";import{P as os}from"./index-BYWWr4r7.js";import{C as Ki}from"./checkbox-DokO2DXd.js";import{S as Fu}from"./search-input-CA0juGKQ.js";import{C as Hu}from"./collection-tabs-CvHGsfW_.js";import{u as d1}from"./use-mcp-prompts-82Xtua4M.js";import{b as h1,a as u1,D as f1}from"./drawer-D-LP9Hh8.js";import{i as js}from"./ChevronUp-BurUkCqE.js";import{i as Sl}from"./Key01-Dc0MTS9j.js";import{a as Uu,G as m1}from"./github-repo-picker-CLrsrBV_.js";import{S as wl}from"./skeleton-CQjs3VsL.js";import{s as p1}from"./User01-BtO-AoKy.js";import{t as co}from"./Users01-BRTza8nY.js";import{u as g1,a as _1}from"./use-secrets-DzWb-lJi.js";import{f as v1}from"./formatDistanceToNow-Cb2QZZJn.js";import{n as hi}from"./LinkExternal01-D0OVTAOa.js";import{s as si}from"./Star01-CaB7lNB9.js";import{i as Wu,s as kn}from"./Stars02-D2Vky1vN.js";import{V as x1}from"./view-mode-toggle-B_Gx2-J_.js";import{n as pa}from"./ZapSquare-C2q_71C5.js";import{i as b1,a as Ii,b as Cl,c as kl}from"./Tool01-CTw8qR4v.js";import{i as y1,c as Vu,a as S1}from"./SwitchHorizontal01-C3K-vKiU.js";import{i as jl}from"./X-1BuEzBGR.js";import{i as w1,a as C1}from"./DotsVertical-Dsznav3Y.js";import{C as k1,A as j1}from"./automation-runs-BhCrA9zN.js";import{b as Nl,C as El,a as Or,e as Br,c as Tl,d as Ku,f as N1}from"./command-Bw5g6PzP.js";import{u as E1,a as qu}from"./use-file-configs-Ci1h3IZS.js";import{u as T1}from"./useInfiniteQuery-v9qNAGwf.js";import{i as A1}from"./FilterLines-DMbodALc.js";import{M as Gu}from"./monaco-editor-BiUexVQ3.js";import{B as R1}from"./badge-CpxlbcB7.js";import{M as P1}from"./select-model-DhPTkTLZ.js";import{u as qn,a as D1,b as I1,c as L1,d as O1}from"./use-automations-jx__re2k.js";import{i as Mn}from"./Zap-DluXKGP1.js";import{A as B1}from"./automation-list-row-CBS-1Qac.js";function nn(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}k`:String(t)}function zc(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 M1(t){return t?t.replace(/-\d{8}(?:-[a-z0-9]+)*$/i,"").replace(/-/g," "):"—"}function $1(t){const e=U.c(4),{items:s}=t;let i;e[0]!==s?(i=s.map(z1),e[0]=s,e[1]=i):i=e[1];let r;return e[2]!==i?(r=n.jsx("div",{className:"grid grid-cols-2 gap-x-8 gap-y-6",children:i}),e[2]=i,e[3]=r):r=e[3],r}function z1(t){return n.jsxs("div",{className:"flex flex-col gap-1 min-w-0",children:[n.jsx("span",{className:"text-xs text-muted-foreground truncate",children:t.label}),n.jsx("span",{className:"text-sm text-foreground tabular-nums truncate",children:t.value})]},t.label)}function F1(t){const e=U.c(30),{userTokens:s,assistantTokens:i,otherTokens:r}=t,o=s+i+r,a=o>0?s/o*100:0,l=o>0?i/o*100:0,d=o>0?r/o*100:0;let c;e[0]!==a?(c=a>0&&n.jsx("div",{className:"h-full bg-chart-1",style:{width:`${a}%`}}),e[0]=a,e[1]=c):c=e[1];let h;e[2]!==l?(h=l>0&&n.jsx("div",{className:"h-full bg-chart-2",style:{width:`${l}%`}}),e[2]=l,e[3]=h):h=e[3];let u;e[4]!==d?(u=d>0&&n.jsx("div",{className:"h-full bg-muted-foreground/30",style:{width:`${d}%`}}),e[4]=d,e[5]=u):u=e[5];let f;e[6]!==c||e[7]!==h||e[8]!==u?(f=n.jsxs("div",{className:"flex h-2 w-full overflow-hidden rounded-full bg-muted",children:[c,h,u]}),e[6]=c,e[7]=h,e[8]=u,e[9]=f):f=e[9];let m;e[10]===Symbol.for("react.memo_cache_sentinel")?(m=n.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-chart-1 shrink-0"}),e[10]=m):m=e[10];let p;e[11]!==a?(p=a.toFixed(1),e[11]=a,e[12]=p):p=e[12];let g;e[13]!==p?(g=n.jsxs("div",{className:"flex items-center gap-1.5",children:[m,n.jsxs("span",{className:"text-xs text-muted-foreground",children:["User ",p,"%"]})]}),e[13]=p,e[14]=g):g=e[14];let _;e[15]===Symbol.for("react.memo_cache_sentinel")?(_=n.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-chart-2 shrink-0"}),e[15]=_):_=e[15];let b;e[16]!==l?(b=l.toFixed(1),e[16]=l,e[17]=b):b=e[17];let x;e[18]!==b?(x=n.jsxs("div",{className:"flex items-center gap-1.5",children:[_,n.jsxs("span",{className:"text-xs text-muted-foreground",children:["Assistant ",b,"%"]})]}),e[18]=b,e[19]=x):x=e[19];let v;e[20]!==d||e[21]!==r?(v=r>0&&n.jsxs("div",{className:"flex items-center gap-1.5",children:[n.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-muted-foreground/30 shrink-0"}),n.jsxs("span",{className:"text-xs text-muted-foreground",children:["Other ",d.toFixed(1),"%"]})]}),e[20]=d,e[21]=r,e[22]=v):v=e[22];let y;e[23]!==x||e[24]!==v||e[25]!==g?(y=n.jsxs("div",{className:"flex flex-wrap gap-x-3 gap-y-1",children:[g,x,v]}),e[23]=x,e[24]=v,e[25]=g,e[26]=y):y=e[26];let S;return e[27]!==y||e[28]!==f?(S=n.jsxs("div",{className:"flex flex-col gap-2",children:[f,y]}),e[27]=y,e[28]=f,e[29]=S):S=e[29],S}function H1(t){const e=U.c(11),{agentId:s,isError:i}=t,r=vs(s),o=r?.title??"Subtask",a=r?.icon??null;let l;e[0]!==a||e[1]!==o?(l=n.jsx(xs,{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 d=i?"text-destructive":"text-foreground";let c;e[3]!==d?(c=ae("shrink-0 font-medium",d),e[3]=d,e[4]=c):c=e[4];let h;e[5]!==o||e[6]!==c?(h=n.jsx("span",{className:c,children:o}),e[5]=o,e[6]=c,e[7]=h):h=e[7];let u;return e[8]!==l||e[9]!==h?(u=n.jsxs(n.Fragment,{children:[l,h]}),e[8]=l,e[9]=h,e[10]=u):u=e[10],u}function U1(t){const e=U.c(5),{isError:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx(xs,{icon:null,name:"Subtask",size:"xs",className:"size-6 rounded-md shrink-0"}),e[0]=i):i=e[0];const r=s?"text-destructive":"text-foreground";let o;e[1]!==r?(o=ae("shrink-0 font-medium",r),e[1]=r,e[2]=o):o=e[2];let a;return e[3]!==o?(a=n.jsxs(n.Fragment,{children:[i,n.jsx("span",{className:o,children:"Subtask"})]}),e[3]=o,e[4]=a):a=e[4],a}function W1(t){const e=U.c(18),{part:s}=t,i=s.input?.agent_id,r=s.state==="input-streaming"||s.state==="input-available"||s.state==="output-available"&&s.preliminary===!0,o=s.state==="output-error",a=s.state==="approval-requested";let l;e[0]!==o?(l=n.jsx(U1,{isError:o}),e[0]=o,e[1]=l):l=e[1];let d;e[2]!==i||e[3]!==o?(d=n.jsx(H1,{agentId:i,isError:o}),e[2]=i,e[3]=o,e[4]=d):d=e[4];let c;e[5]!==l||e[6]!==d?(c=n.jsx(D.Suspense,{fallback:l,children:d}),e[5]=l,e[6]=d,e[7]=c):c=e[7];let h;e[8]!==s.input?(h=s.input?.prompt&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"text-muted-foreground/50",children:"·"}),n.jsx("span",{className:"truncate text-muted-foreground",children:s.input.prompt})]}),e[8]=s.input,e[9]=h):h=e[9];let u;e[10]!==a||e[11]!==o||e[12]!==r?(u=n.jsx("span",{className:"ml-auto shrink-0",children:r?n.jsx(Oe,{size:12,className:"animate-spin text-muted-foreground"}):o?n.jsx(gg,{size:12,className:"text-destructive"}):a?n.jsx(zi,{size:12,className:"text-warning"}):n.jsx(Yh,{size:12,className:"text-emerald-500"})}),e[10]=a,e[11]=o,e[12]=r,e[13]=u):u=e[13];let f;return e[14]!==c||e[15]!==h||e[16]!==u?(f=n.jsxs("div",{className:"flex items-center gap-2 text-xs min-w-0",children:[c,h,u]}),e[14]=c,e[15]=h,e[16]=u,e[17]=f):f=e[17],f}function V1(t){const e=U.c(55),{onClose:s,back:i,className:r}=t,[o,a]=D.useState(null),{messages:l}=li(),{activeTask:d}=Ts(),{selectedModel:c,selectedVirtualMcp:h}=cl();let u,f,m,p,g,_,b,x;if(e[0]!==d||e[1]!==i||e[2]!==r||e[3]!==l||e[4]!==s||e[5]!==o?.id||e[6]!==c||e[7]!==h?.title){x=Symbol.for("react.early_return_sentinel");e:{const S=bg(l),w=[...l].reverse().find(sv),C=w?.metadata?.usage,N=w?.metadata?.modelLimits?.contextWindow??c?.limits?.contextWindow??null,E=C?.contextTokens??0,R=N&&N>0?(E/N*100).toFixed(1):null,T=l;let k;e[16]!==T?(k=T.filter(tv).reduce(ev,0),e[16]=T,e[17]=k):k=e[17];const j=k,I=l;let A;e[18]!==I?(A=I.filter(Q1).reduce(Z1,0),e[18]=I,e[19]=A):A=e[19];const O=A,L=Math.max(0,S.totalTokens-j-O),P=l[0],B=l.at(-1),F=P?.metadata?.created_at??d?.created_at,H=B?.metadata?.created_at??d?.updated_at,z=l.filter(J1),W=l.flatMap(Y1),q=c?.modelId?M1(c.modelId):"—",K=h?.title??"Decopilot",Z=[{label:"Session",value:d?.title??"New chat"},{label:"Messages",value:z.length},{label:"Agent",value:K},{label:"Model",value:q},{label:"Context Limit",value:N?nn(N):"—"},{label:"Session Tokens (billed)",value:S.totalTokens>0?nn(S.totalTokens):"0"},{label:"Usage",value:R!==null?`${R}%`:"—"},{label:"Input Tokens",value:S.inputTokens>0?nn(S.inputTokens):"0"},{label:"Output Tokens",value:S.outputTokens>0?nn(S.outputTokens):"0"},{label:"Reasoning Tokens",value:S.reasoningTokens>0?nn(S.reasoningTokens):"0"},{label:"Cost",value:S.cost>0?`$${S.cost<.001?S.cost.toFixed(6):S.cost.toFixed(4)}`:"$0.00"},{label:"Session Created",value:zc(F)},{label:"Last Activity",value:zc(H)}];if(!d&&z.length===0){let $;e[20]!==r?($=ae("flex flex-col h-full w-full border-l border-border bg-background",r),e[20]=r,e[21]=$):$=e[21];let X;e[22]===Symbol.for("react.memo_cache_sentinel")?(X=n.jsx("span",{className:"text-sm font-medium text-foreground",children:"Context"}),e[22]=X):X=e[22];let V;e[23]!==i?(V=i?n.jsx(Tc,{size:14,className:"text-muted-foreground"}):n.jsx(Hs,{size:14,className:"text-muted-foreground"}),e[23]=i,e[24]=V):V=e[24];let se;e[25]!==s||e[26]!==V?(se=n.jsxs("div",{className:"h-11 px-4 flex items-center justify-between shrink-0 border-b border-border/50",children:[X,n.jsx("button",{type:"button",onClick:s,className:"flex size-6 items-center justify-center rounded hover:bg-accent transition-colors",children:V})]}),e[25]=s,e[26]=V,e[27]=se):se=e[27];let ee;e[28]===Symbol.for("react.memo_cache_sentinel")?(ee=n.jsx("div",{className:"flex-1 flex items-center justify-center px-4 text-center",children:n.jsx("p",{className:"text-xs text-muted-foreground",children:"Start a conversation to see context"})}),e[28]=ee):ee=e[28];let le;e[29]!==$||e[30]!==se?(le=n.jsxs("div",{className:$,children:[se,ee]}),e[29]=$,e[30]=se,e[31]=le):le=e[31],x=le;break e}e[32]!==r?(_=ae("flex flex-col h-full w-full border-l border-border bg-background overflow-y-auto",r),e[32]=r,e[33]=_):_=e[33];let Y;e[34]===Symbol.for("react.memo_cache_sentinel")?(Y=n.jsx("span",{className:"text-sm font-medium text-foreground",children:"Context"}),e[34]=Y):Y=e[34];let G;e[35]!==i?(G=i?n.jsx(Tc,{size:14}):n.jsx(Hs,{size:14}),e[35]=i,e[36]=G):G=e[36],e[37]!==s||e[38]!==G?(b=n.jsxs("div",{className:"flex h-11 shrink-0 items-center justify-between border-b border-border/50 px-4",children:[Y,n.jsx("button",{type:"button",onClick:s,className:"flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",children:G})]}),e[37]=s,e[38]=G,e[39]=b):b=e[39],u="flex flex-col gap-8 p-6",f=W.length>0&&n.jsxs("div",{className:"flex flex-col gap-3",children:[n.jsx("span",{className:"text-xs text-muted-foreground",children:"Subtasks"}),n.jsx("div",{className:"flex flex-col gap-1",children:W.map(G1)})]}),m=n.jsx($1,{items:Z});let Q;e[40]===Symbol.for("react.memo_cache_sentinel")?(Q=n.jsx("span",{className:"text-xs text-muted-foreground",children:"Context Breakdown"}),e[40]=Q):Q=e[40],e[41]!==O||e[42]!==L||e[43]!==j?(p=n.jsxs("div",{className:"flex flex-col gap-3",children:[Q,n.jsx(F1,{userTokens:j,assistantTokens:O,otherTokens:L})]}),e[41]=O,e[42]=L,e[43]=j,e[44]=p):p=e[44],g=z.length>0&&n.jsxs("div",{className:"flex flex-col gap-3",children:[n.jsx("span",{className:"text-xs text-muted-foreground",children:"Raw messages"}),n.jsx("div",{className:"flex flex-col gap-1",children:z.map($=>{const X=$.metadata?.created_at,V=o?.id===$.id;return n.jsxs("div",{className:"rounded-md border border-border/50 overflow-hidden",children:[n.jsxs("button",{type:"button",onClick:()=>a(V?null:$),className:"flex items-center justify-between gap-2 px-3 py-2 text-xs hover:bg-accent/50 w-full text-left cursor-pointer",children:[n.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[n.jsx("span",{className:ae("shrink-0 font-medium",$.role==="user"?"text-chart-1":"text-chart-2"),children:$.role}),n.jsx("span",{className:"text-muted-foreground",children:"•"}),n.jsx("span",{className:"truncate text-muted-foreground font-mono",children:$.id})]}),X&&n.jsx("span",{className:"shrink-0 text-muted-foreground tabular-nums",children:new Date(X).toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"})})]}),V&&n.jsxs(n.Fragment,{children:[$.role==="assistant"&&(()=>{const se=$.metadata?._request;if(!se)return null;const ee=se.systemSections??[],le=Math.max(1,...ee.map(q1)),ce=ee.reduce(K1,0);return n.jsxs("div",{className:"border-t border-border/50 px-3 py-2.5 text-xs space-y-2.5",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("span",{className:"font-medium text-foreground",children:"Request"}),n.jsxs("span",{className:"text-muted-foreground tabular-nums",children:[se.activeTools??0," / ",se.tools??0," ","tools active"]})]}),ee.length>0&&n.jsxs("div",{className:"space-y-1.5",children:[n.jsxs("div",{className:"text-muted-foreground",children:["System prompt"," ",n.jsxs("span",{className:"tabular-nums",children:["~",Math.round(ce/4).toLocaleString()," ","tok"]})]}),ee.map((fe,J)=>{const te=fe.preview.match(/^<([a-z-]+)/i)?.[1]??`section ${J}`,oe=fe.chars/le*100,de=Math.round(fe.chars/4);return n.jsxs("div",{className:"space-y-0.5",children:[n.jsxs("div",{className:"flex items-center justify-between gap-2",children:[n.jsx("span",{className:"font-mono text-foreground truncate",children:te}),n.jsxs("span",{className:"text-muted-foreground tabular-nums shrink-0",children:["~",de.toLocaleString()," tok"]})]}),n.jsx("div",{className:"h-1 w-full rounded-full bg-muted overflow-hidden",children:n.jsx("div",{className:"h-full rounded-full bg-chart-3",style:{width:`${oe}%`}})})]},J)})]})]})})(),n.jsx("pre",{className:"text-xs font-mono bg-muted px-3 py-2 overflow-auto whitespace-pre-wrap break-all border-t border-border/50 max-h-64",children:JSON.stringify($,null,2)})]})]},$.id)})})]})}e[0]=d,e[1]=i,e[2]=r,e[3]=l,e[4]=s,e[5]=o?.id,e[6]=c,e[7]=h?.title,e[8]=u,e[9]=f,e[10]=m,e[11]=p,e[12]=g,e[13]=_,e[14]=b,e[15]=x}else u=e[8],f=e[9],m=e[10],p=e[11],g=e[12],_=e[13],b=e[14],x=e[15];if(x!==Symbol.for("react.early_return_sentinel"))return x;let v;e[45]!==u||e[46]!==f||e[47]!==m||e[48]!==p||e[49]!==g?(v=n.jsxs("div",{className:u,children:[f,m,p,g]}),e[45]=u,e[46]=f,e[47]=m,e[48]=p,e[49]=g,e[50]=v):v=e[50];let y;return e[51]!==_||e[52]!==b||e[53]!==v?(y=n.jsxs("div",{className:_,children:[b,v]}),e[51]=_,e[52]=b,e[53]=v,e[54]=y):y=e[54],y}function K1(t,e){return t+e.chars}function q1(t){return t.chars}function G1(t,e){return n.jsx(W1,{part:t},e)}function Y1(t){return(t.parts??[]).filter(X1)}function X1(t){return t.type==="tool-subtask"}function J1(t){return t.role!=="system"}function Z1(t,e){const s=e.metadata?.usage;return t+(s?.outputTokens??0)}function Q1(t){return t.role==="assistant"}function ev(t,e){const s=e.metadata?.usage;return t+(s?.inputTokens??0)}function tv(t){return t.role==="user"}function sv(t){return t.role==="assistant"&&t.metadata?.usage}function iv(t){const e=U.c(13),{readOnly:s,identity:i,aboveRow:r,input:o,iceBreakers:a}=t,l=!s&&i?i:null;let d;e[0]!==r||e[1]!==s?(d=!s&&r?n.jsx("div",{"data-chat-above-row":"true",className:"@container/chat-bottom flex justify-start gap-1",children:r}):null,e[0]=r,e[1]=s,e[2]=d):d=e[2];let c;e[3]!==o||e[4]!==d?(c=n.jsxs("div",{className:"flex flex-col gap-2",children:[d,o]}),e[3]=o,e[4]=d,e[5]=c):c=e[5];let h;e[6]!==a||e[7]!==s?(h=!s&&a?n.jsx("div",{className:"w-full",children:a}):null,e[6]=a,e[7]=s,e[8]=h):h=e[8];let u;return e[9]!==l||e[10]!==c||e[11]!==h?(u=n.jsx("div",{"data-chat-centered":"true",className:"h-full w-full flex flex-col items-center justify-center px-4 gap-6",children:n.jsxs("div",{className:"w-full max-w-3xl flex flex-col gap-6",children:[l,c,h]})}),e[9]=l,e[10]=c,e[11]=h,e[12]=u):u=e[12],u}function nv(t){const e=U.c(25),{onOpenContextPanel:s}=t,{org:i}=Me(),{selectedVirtualMcp:r}=cl();let o;e[0]!==i.id?(o=Qh(i.id),e[0]=i.id,e[1]=o):o=e[1];const l=r??o,d=vs(l.id),c=Gh(),{data:h}=$i.useSession(),u=h?.user?.id,f=c?.activeTask??null,m=!!(u&&f?.created_by&&f.created_by!==u);let p;e[2]===Symbol.for("react.memo_cache_sentinel")?(p=n.jsx(Mg,{size:32}),e[2]=p):p=e[2];let g;e[3]!==l.icon||e[4]!==l.title?(g=n.jsx(xs,{icon:l.icon,name:l.title,size:"lg",fallbackIcon:p,className:"size-10 min-w-10 md:size-[60px]! md:min-w-[60px] rounded-xl md:rounded-[18px]!"}),e[3]=l.icon,e[4]=l.title,e[5]=g):g=e[5];let _;e[6]!==l.title?(_=n.jsx("h3",{className:"text-base md:text-xl font-medium text-foreground",children:l.title}),e[6]=l.title,e[7]=_):_=e[7];const b=l.description??"Ask anything about configuring model providers or using MCP Mesh.";let x;e[8]!==b?(x=n.jsx("div",{className:"text-muted-foreground text-center text-base max-w-md line-clamp-2",children:b}),e[8]=b,e[9]=x):x=e[9];let v;e[10]!==g||e[11]!==_||e[12]!==x?(v=n.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 md:gap-4 text-center",children:[g,_,x]}),e[10]=g,e[11]=_,e[12]=x,e[13]=v):v=e[13];const y=c?.currentBranch??null;let S;e[14]!==d||e[15]!==y?(S=n.jsx(lg,{virtualMcp:d,currentBranch:y}),e[14]=d,e[15]=y,e[16]=S):S=e[16];let w;e[17]!==s?(w=n.jsx(it.Input,{onOpenContextPanel:s}),e[17]=s,e[18]=w):w=e[18];let C;e[19]===Symbol.for("react.memo_cache_sentinel")?(C=n.jsx(it.IceBreakers,{}),e[19]=C):C=e[19];let N;return e[20]!==m||e[21]!==w||e[22]!==v||e[23]!==S?(N=n.jsx(iv,{readOnly:m,identity:v,aboveRow:S,input:w,iceBreakers:C}),e[20]=m,e[21]=w,e[22]=v,e[23]=S,e[24]=N):N=e[24],N}function Fc(t){const e=U.c(17),{outputs:s,collapsed:i,onToggle:r,variant:o}=t,a=o==="card"?"rounded-xl border border-border bg-muted/95 shadow-sm backdrop-blur-sm":"border-b border-border bg-background";let l;e[0]!==a?(l=ae(a),e[0]=a,e[1]=l):l=e[1];let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx("span",{className:"text-sm font-medium text-foreground",children:"Files in this task"}),e[2]=d):d=e[2];const c=i&&"-rotate-90";let h;e[3]!==c?(h=ae("size-4 text-muted-foreground transition-transform",c),e[3]=c,e[4]=h):h=e[4];let u;e[5]!==h?(u=n.jsx(cs,{className:h}),e[5]=h,e[6]=u):u=e[6];let f;e[7]!==r||e[8]!==u?(f=n.jsxs("button",{type:"button",onClick:r,className:"flex w-full items-center justify-between px-3 py-2.5 text-left",children:[d,u]}),e[7]=r,e[8]=u,e[9]=f):f=e[9];let m;e[10]!==i||e[11]!==s?(m=!i&&n.jsx("div",{className:"flex max-h-72 flex-col gap-1.5 overflow-y-auto px-2 pb-2",children:s.map(rv)}),e[10]=i,e[11]=s,e[12]=m):m=e[12];let p;return e[13]!==l||e[14]!==f||e[15]!==m?(p=n.jsxs("div",{className:l,children:[f,m]}),e[13]=l,e[14]=f,e[15]=m,e[16]=p):p=e[16],p}function rv(t){return n.jsx(Sg,{file:t},t.key)}function ov(){const t=U.c(13),e=Gh()?.taskId??null,s=yg();let i;t[0]!==s?(i={enabled:s},t[0]=s,t[1]=i):i=t[1];const{data:r}=Jh(e,i),[o,a]=D.useState(!1),[l,d]=D.useState(!0);if(!e||!r||r.length===0)return null;let c;t[2]===Symbol.for("react.memo_cache_sentinel")?(c=()=>a(lv),t[2]=c):c=t[2];let h;t[3]!==o||t[4]!==r?(h=n.jsx("div",{className:"absolute top-2 right-2 z-10 hidden w-72 @[1280px]:block",children:n.jsx(Fc,{variant:"card",outputs:r,collapsed:o,onToggle:c})}),t[3]=o,t[4]=r,t[5]=h):h=t[5];let u;t[6]===Symbol.for("react.memo_cache_sentinel")?(u=()=>d(av),t[6]=u):u=t[6];let f;t[7]!==l||t[8]!==r?(f=n.jsx("div",{className:"shrink-0 @[1280px]:hidden",children:n.jsx(Fc,{variant:"bar",outputs:r,collapsed:l,onToggle:u})}),t[7]=l,t[8]=r,t[9]=f):f=t[9];let m;return t[10]!==h||t[11]!==f?(m=n.jsxs(n.Fragment,{children:[h,f]}),t[10]=h,t[11]=f,t[12]=m):m=t[12],m}function av(t){return!t}function lv(t){return!t}function cv(){const t=U.c(26),{org:e}=Me(),s=fu(),{isChatEmpty:i}=li(),[r,o]=D.useState("chat"),a=$g(),l=Vg();if(s.length===0&&!zg(l)){let S;return t[0]===Symbol.for("react.memo_cache_sentinel")?(S=n.jsx(it,{className:"animate-in fade-in-0 duration-200",children:n.jsx(it.Main,{className:"flex flex-col items-center",children:n.jsx(it.EmptyState,{children:n.jsx(it.NoAiProviderEmptyState,{})})})}),t[0]=S):S=t[0],S}let c;t[1]!==a.hasDecoKey||t[2]!==a.hasOnlyDecoProvider||t[3]!==a.isLoading||t[4]!==a.isZeroBalance||t[5]!==i||t[6]!==e?(c=a.hasDecoKey&&a.isZeroBalance&&a.hasOnlyDecoProvider&&!a.isLoading&&i&&!cg(e.id),t[1]=a.hasDecoKey,t[2]=a.hasOnlyDecoProvider,t[3]=a.isLoading,t[4]=a.isZeroBalance,t[5]=i,t[6]=e,t[7]=c):c=t[7];const h=c;let u;t[8]!==h?(u=h&&n.jsx(it.CreditsEmptyState,{}),t[8]=h,t[9]=u):u=t[9];const f=r!=="chat"?"opacity-0 pointer-events-none":"opacity-100";let m;t[10]!==f?(m=ae("absolute inset-0 flex flex-col transition-opacity duration-100 ease-out",f),t[10]=f,t[11]=m):m=t[11];let p;t[12]!==i?(p=i?n.jsx(it.Main,{children:n.jsx(nv,{onOpenContextPanel:()=>o("context")})}):n.jsxs(n.Fragment,{children:[n.jsxs(it.Main,{className:"relative flex flex-col overflow-hidden @container",children:[n.jsx(ov,{}),n.jsx("div",{className:"min-h-0 flex-1",children:n.jsx(it.Messages,{})})]}),n.jsx(it.Footer,{children:n.jsx(it.Input,{onOpenContextPanel:()=>o("context")})})]}),t[12]=i,t[13]=p):p=t[13];let g;t[14]!==m||t[15]!==p?(g=n.jsx("div",{className:m,children:p}),t[14]=m,t[15]=p,t[16]=g):g=t[16];const _=r==="context"?"opacity-100":"opacity-0 pointer-events-none";let b;t[17]!==_?(b=ae("absolute inset-0 flex flex-col transition-opacity duration-100 ease-out",_),t[17]=_,t[18]=b):b=t[18];let x;t[19]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsx(V1,{back:!0,onClose:()=>o("chat")}),t[19]=x):x=t[19];let v;t[20]!==b?(v=n.jsx("div",{className:b,children:x}),t[20]=b,t[21]=v):v=t[21];let y;return t[22]!==u||t[23]!==g||t[24]!==v?(y=n.jsxs(it,{className:"relative overflow-hidden animate-in fade-in-0 duration-200",children:[u,g,v]}),t[22]=u,t[23]=g,t[24]=v,t[25]=y):y=t[25],y}function Yu(){const t=U.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(it.Skeleton,{}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx(Zt,{fallback:e,children:n.jsx(D.Suspense,{fallback:n.jsx(it.Skeleton,{}),children:n.jsx(cv,{})})}),t[1]=s):s=t[1],s}function dv(t){const e=t.entityMetadata?.defaultMainView??null,s=e==null||e.type==="chat",i=t.mainParamPresent?t.mainParamValue!=="0":!s,r=s?!0:t.entityMetadata?.chatDefaultOpen??!1;return{mainOpen:i,chatOpen:r}}function Hc(t,e){return t&&e?{chat:45,main:55}:t&&!e?{chat:100,main:0}:!t&&e?{chat:0,main:100}:{chat:0,main:0}}function hv(t,e){return t===1?!0:t===0?!1:e}function uv(t,e){const s=qt(),i=eo({strict:!1}),r=Fh({strict:!1}),{create:o}=yu(),{locator:a}=Me(),{virtualMcpId:l,orgSlug:d,isAgentRoute:c}=e,h=dv({entityMetadata:t,mainParamPresent:i.main!==void 0,mainParamValue:i.main}),u=hv(i.chat,h.chatOpen),f=h.mainOpen,m=D.useRef(crypto.randomUUID()),p=r.taskId??m.current,g="/$org/$taskId",_=E=>({org:d,taskId:E}),b=c?{virtualmcpid:l}:{},x=(E,R)=>{s({to:g,params:_(p),search:T=>({...T,...E}),replace:R?.replace??!1})},v=(E,R)=>{s({to:g,params:_(E),search:T=>{const k={};return R?k.virtualmcpid=R:c&&(k.virtualmcpid=l),k}})},y=()=>{f?x({main:"0"},{replace:!0}):x({main:ca(t)},{replace:!0})},S=()=>{x({chat:u?0:1},{replace:!0})},w=()=>{u||x({chat:1},{replace:!0})},C=async()=>{const E=crypto.randomUUID(),R=Kg(d,a,p);try{await o({id:E,virtual_mcp_id:l,...R?{branch:R}:{}})}catch{}s({to:g,params:_(E),search:T=>({...b,chat:1})})},N=E=>{x({main:E},{replace:!0})};return{taskId:p,mainOpen:f,chatOpen:u,mainParam:i.main,setTaskId:v,toggleMain:y,toggleChat:S,openChat:w,createNewTask:C,openTab:N}}const Al=45;function Xu(t,e=Al){const s=typeof t=="number"?t:Number(t);return!Number.isFinite(s)||s<=0||s>=100?e:s}function fv(t){return Xu(t,Al)}function mv(){const t=U.c(6);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=Gp.decoChatPanelWidth(),t[0]=e):e=t[0];const[s,i]=qp(e,fv);let r;t[1]!==s?(r=Xu(s,Al),t[1]=s,t[2]=r):r=t[2];const o=r;let a;return t[3]!==i||t[4]!==o?(a=[o,i],t[3]=i,t[4]=o,t[5]=a):a=t[5],a}function pv(t){try{return JSON.parse(t)}catch{return null}}function gv(t){if(!t||typeof t!="object")return null;const e=t,s=e.content?.find(o=>o.type==="text")?.text,i=s?pv(s):null,r=e.structuredContent;return r==null?i:typeof r=="object"&&!Array.isArray(r)&&Object.keys(r).length===0?i??r:r}function ui(t){const e=gv(t);return e===null?null:e}function Rl(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 _v(t){if(!t||typeof t!="object")return null;const e=t.content?.find(r=>r.type==="text")?.text;if(!e)return null;const s=e.match(/https:\/\/github\.com\/[^\s"]+\/pull\/\d+/)?.[0],i=Rl(s);return!i||!s?null:{number:i,htmlUrl:s}}const Uc=/[\r\n<>]/,vv=/^[^\s@<>]+@[^\s@<>]+\.[^\s@<>]+$/;function Gn(t){const e=t?.userName?.trim();if(!e||Uc.test(e))return null;const s=t?.userEmail?.trim();return!s||Uc.test(s)?{userName:e}:vv.test(s)?{userName:e,userEmail:s}:{userName:e}}function xv(t){return t.split(`
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/sections-editor-C33mQAPq.js","assets/index-vUJ0Rroa.js","assets/index-xCrqP1qS.css","assets/ChevronDown-BY59w4Qk.js","assets/ChevronLeft-DVIgNVyn.js","assets/ChevronRight-CM2UCxLV.js","assets/ChevronUp-ELVqY6cz.js","assets/agent-icon-BUISstKv.js","assets/AlertCircle-DifM-3Ys.js","assets/Tool01-CqbO1hX2.js","assets/SwitchHorizontal01-DO04KALD.js","assets/Settings02-RazZjdiv.js","assets/XCircle-CNgW1bnA.js","assets/ArrowUpRight-DTNfyjlQ.js","assets/ZapSquare-wbaFJ6J6.js","assets/Users03-V7VYPOVz.js","assets/CheckCircle-DmLgOHHp.js","assets/DotsVertical-FbZSolmB.js","assets/Stars02-l9mDD3eo.js","assets/Eye-8PGvC0iK.js","assets/ZoomOut-XI-iJG4j.js","assets/Globe01-B90chNia.js","assets/FilterLines-Cf2PdvFM.js","assets/Star01-C9VN0Du_.js","assets/Globe04-Dw4nWd3A.js","assets/HardDrive-CKn4i_9T.js","assets/Key01-oftOkafI.js","assets/LayoutLeft-Bij2Lb4X.js","assets/LinkExternal01-9FNotiMN.js","assets/Monitor01-CR1JDEQ7.js","assets/Sun-D-fwbx_z.js","assets/Palette-ArrfZuOV.js","assets/Play-BB5dP1L8.js","assets/Plus-CglBKrb5.js","assets/SearchMd-Bmh_sD0S.js","assets/Shield01-D44r3AdO.js","assets/Stars01-CoxwYWLP.js","assets/Trash01-DUxygeaL.js","assets/Upload01-CEAuuYpa.js","assets/User01-fdrqbZOX.js","assets/Users01-BQH1rUR7.js","assets/XClose-DY_H1WmQ.js","assets/X-DH6rpzm4.js","assets/Zap-jC0lbn1q.js","assets/scroll-area-BcHB6NVX.js","assets/use-clock-tick-BQWtBapt.js","assets/differenceInSeconds-NQ4PDo0z.js","assets/use-copy-Ck1s3Ly_.js","assets/tooltip-CMUaL9C1.js","assets/file-type-icon-DtYuEk9O.js","assets/dialog-D9WjjXCi.js","assets/tab-id-BptcWVWa.js","assets/content-blocks-o63cs2vh.js","assets/types-BSxSWkiR.js","assets/use-mcp-client-CbMJzr4L.js","assets/auth-COC6Da1O.js","assets/chat-context-D2XCyHNy.js","assets/hooks-CMSXeMFL.js","assets/decopilot-sse-pool-BRv-o5yu.js","assets/backoff-CrEUbyZT.js","assets/delay-CnY5UFtP.js","assets/use-virtual-mcp-BgEUqJv7.js","assets/use-collections-CmcFURA8.js","assets/use-ai-providers-DzNi6Q_V.js","assets/studio-tools-BZzXzwRs.js","assets/use-organization-settings-BlTbQ8o8.js","assets/shell-layout-CicMe8M5.js","assets/avatar-yxz7fyGH.js","assets/required-auth-layout-0H2r_sG0.js","assets/use-org-sso-BwpmbYKY.js","assets/sheet-D7Sq65N5.js","assets/integration-icon-DWC1E-NM.js","assets/use-navigate-to-agent-DAdQNXr7.js","assets/use-connection-BlyaSvk_.js","assets/use-mcp-prompts-BCcxOooU.js","assets/form-2979wdxX.js","assets/label-Ds5L98Th.js","assets/input-D475ckPl.js","assets/select-wPD7z-7a.js","assets/dropdown-menu-Cym0YADL.js","assets/sortable.esm-DHRoGvrT.js","assets/connection-slug-eyAPH6o3.js","assets/connection-card-BavDtRRe.js","assets/use-registry-connections-6RdLigQp.js","assets/useInfiniteQuery-ChBCbSD3.js","assets/use-infinite-scroll-D0Uygp_Y.js","assets/extract-connection-data-BSTqgqHH.js","assets/card-Bj8otFuN.js","assets/collection-search-Bde6_LbH.js","assets/collection-tabs-CmheS0lt.js","assets/badge-CQquKN9p.js","assets/drawer-B07QIoON.js","assets/textarea-Dv2h0FHy.js","assets/connection-form-helpers-vW7WD93k.js","assets/authenticate-and-persist-oauth-7kSYvcg8.js","assets/mcp-oauth-BuJKTbpq.js","assets/useSuspenseInfiniteQuery-COloy4Cl.js","assets/page-seo-form-UXOt1Xq8.js","assets/switch-CS7rft2F.js","assets/add-section-modal-DbYQ6fO0.js","assets/index-Y-0r87FI.js","assets/tabs-NT5hIgye.js","assets/toggle-group-BlIuQKMU.js","assets/connect-desktop-dialog-CSA1yCDL.js","assets/decopilot-DgdLPSeb.js","assets/checkbox-Da1mUHNU.js","assets/skeleton-Et7A2pSm.js","assets/ai-providers-logos-DD3qZ33J.js","assets/settings-section-DTFkKe0k.js","assets/popover-BEzlzjXA.js","assets/command-D_g4Qh6z.js","assets/index-BYx78v24.js","assets/question-004-sINsf4GQ.js","assets/use-status-sounds-BRVcePS8.js","assets/empty-state-Dc-tsC-2.js","assets/toolbar-Dqn0u_dp.js","assets/preview-dialog-DtFiLW4L.js","assets/index-D6hU96vm.js","assets/use-mcp-tools-CoU1W6We.js","assets/use-capability-hUlYEzZt.js","assets/shell-route-loading-ALc0mrI8.js","assets/index-CkgRi4X3.js","assets/alert-dialog-Dh6V_14o.js","assets/use-debounced-autosave-B3PmQihS.js","assets/index-DXI2OWA9.js","assets/sidebar-BBRwD7tX.js","assets/search-input-DLLGaO2O.js","assets/github-repo-picker-BkDPWKjv.js","assets/use-secrets-fz_TrA3p.js","assets/formatDistanceToNow-Cb2QZZJn.js","assets/view-mode-toggle-Bpaa83uS.js","assets/automation-runs-DMkXGxyD.js","assets/table-6zTgSv0k.js","assets/use-members-BkVP92fJ.js","assets/use-org-auth-client-BVVEzYWX.js","assets/task-status-BGl9HRbw.js","assets/use-automations-DBCBw7t_.js","assets/use-file-configs-D4iNPF8_.js","assets/monaco-editor-BIbmj68Y.js","assets/select-model-DRzRHvEm.js","assets/automation-list-row-DCvQVGai.js","assets/page-seo-sheet-Cb5cCBSA.js","assets/file-explorer-BfDoSrZk.js","assets/context-menu-CFoKwdsl.js","assets/app-editor-BI1KpS86.js","assets/save-status-lTcRFIDk.js","assets/post-editor-Dlb8m7Iz.js","assets/primitives-BSQDvGLE.js","assets/block-document-BBSIfcJ0.js","assets/record-editor-BjHlAGT_.js","assets/category-editor-UeZPwCgj.js","assets/seo-editor-DVLMhS9K.js","assets/variant-calendar-cujTqFIv.js","assets/project-app-view-C9CksfQE.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{c as U,r as D,l as ae,j as n,i as Oe,v as Me,a as $i,a2 as Zt,b as qt,u as eo,e as Fh,s as qp,L as Gp,k as Es,K as Et,m as oi,a3 as to,a4 as Yp,a5 as Xp,t as he,B as ie,a6 as Hh,a7 as Jp,a8 as Zp,q as Ke,a9 as Uh,aa as Qp,ab as so,ac as Pn,ad as Ht,ae as eg,E as Wh,C as tg,x as Vh,af as Ut,P as Kh,ag as sg,U as ig,$ as qh,W as ng,ah as rg,Q as og,ai as ag,d as ai,y as pr,aj as pn,z as ns,ak as ls}from"./index-vUJ0Rroa.js";import{C as it,a as lg,w as cg,u as ll,s as oa,T as dg,b as hg,g as ug,c as fg}from"./index-Y-0r87FI.js";import{u as li,a as Ts,b as cl,c as Gh,S as dl,t as mg,d as pg}from"./chat-context-D2XCyHNy.js";import{i as zi}from"./AlertCircle-DifM-3Ys.js";import{i as Yh}from"./CheckCircle-DmLgOHHp.js";import{n as Tc}from"./ChevronLeft-DVIgNVyn.js";import{a as gg,b as _g,i as vg}from"./XCircle-CNgW1bnA.js";import{s as Hs}from"./XClose-DY_H1WmQ.js";import{a as vs,u as hl,b as Xh,c as xg}from"./use-virtual-mcp-BgEUqJv7.js";import{c as bg,u as yg,a as Jh,O as Sg,t as aa,S as Fi,T as wg,b as Zh,R as Cg,C as kg,G as jg,d as Ng,i as Eg,E as Tg,g as Ag,s as Rg,e as Pg,f as Dg,h as Ig}from"./scroll-area-BcHB6NVX.js";import{I as xs}from"./integration-icon-DWC1E-NM.js";import{a as Qh,u as Pt,S as ul,b as Lg,c as Og,i as Bg,d as eu}from"./use-mcp-client-CbMJzr4L.js";import{a as Mg}from"./Users03-V7VYPOVz.js";import{t as cs}from"./ChevronDown-BY59w4Qk.js";import{u as $g,h as zg,a as Wn,i as tu,j as ti,g as Fg,A as Hg,b as su,c as wr,K as iu,P as nu,D as ru,d as ou,S as au,v as lu,k as cu,l as la,e as du,C as hu,s as uu,m as Ug,n as Wg}from"./sortable.esm-DHRoGvrT.js";import{u as fu}from"./use-ai-providers-DzNi6Q_V.js";import{u as Vg}from"./connect-desktop-dialog-CSA1yCDL.js";import{r as Kg,b as fl,i as qg}from"./shell-layout-CicMe8M5.js";import{u as ml,T as Ne,a as Ee,b as Te,c as mu}from"./tooltip-CMUaL9C1.js";import{u as Gg}from"./use-status-sounds-BRVcePS8.js";import{E as Cr}from"./empty-state-Dc-tsC-2.js";import{r as ca,a as Yg,p as pu,f as Ac,b as gu,c as _u,d as vu,e as Xg,F as Jg,i as Zg,g as Qg,h as xu,j as bu}from"./tab-id-BptcWVWa.js";import{u as yu,a as Su}from"./hooks-CMSXeMFL.js";import{T as Rc,a as gn}from"./toolbar-Dqn0u_dp.js";import{u as e_,a as t_,b as s_,c as i_,g as n_,d as wu,e as Pc,f as r_,F as o_,h as a_,i as l_,j as c_,k as d_,l as h_,m as u_,H as f_,L as m_,R as Cu,n as p_,o as g_,T as pl,p as __,q as v_}from"./preview-dialog-DtFiLW4L.js";import{g as Dn,h as gl,j as ku,k as x_,p as io,l as ci,m as _l,n as ju,o as da,q as wo,r as Dc,A as Ic,s as b_,t as y_,u as S_,v as w_,w as C_,x as Nu,y as k_,z as j_,B as N_,C as E_,D as Hi,E as T_,F as Lc,G as Oc,H as A_,d as R_,I as P_,J as D_,K as Ni,L as kr,M as no,N as I_,O as L_,P as O_,Q as B_,R as M_,S as $_,T as Eu,U as Ri,V as Bc,W as Tu,X as ro,Y as z_,Z as F_,_ as H_,$ as U_,a0 as W_,a1 as Mc,a2 as V_,a3 as K_,a4 as q_,a5 as Au,a6 as G_}from"./agent-icon-BUISstKv.js";import{i as Ui,n as Y_}from"./Globe01-B90chNia.js";import{i as Ru}from"./Monitor01-CR1JDEQ7.js";import{u as Vn,a as vl,b as Pu}from"./use-connection-BlyaSvk_.js";import{u as oo,a as Du,b as Iu}from"./use-mcp-tools-CoU1W6We.js";import{g as Lu}from"./types-BSxSWkiR.js";import{u as di}from"./studio-tools-BZzXzwRs.js";import{u as X_}from"./use-capability-hUlYEzZt.js";import{F as Pi,M as xl,O as J_}from"./file-type-icon-DtYuEk9O.js";import{P as As,a as Rs,b as Ps}from"./popover-BEzlzjXA.js";import{b as kt,c as Rt,S as jt,a as tt,d as Nt}from"./select-wPD7z-7a.js";import{D as Wt,a as Vt,b as Kt,c as Ue,d as ha,e as ua,f as fa,g as Cn,h as In,i as Co,j as ko}from"./dropdown-menu-Cym0YADL.js";import{d as Bt,c as Mt,D as ts,a as ss,e as Ws,b as Wi}from"./dialog-D9WjjXCi.js";import{I as ze}from"./input-D475ckPl.js";import{T as zs,a as ao,b as Ei,c as lo}from"./tabs-NT5hIgye.js";import{T as Ln}from"./textarea-Dv2h0FHy.js";import{a as as,s as Z_}from"./Eye-8PGvC0iK.js";import{t as Zs}from"./Stars01-CoxwYWLP.js";import{l as Q_,w as e1}from"./index-D6hU96vm.js";import{i as Vi}from"./ChevronRight-CM2UCxLV.js";import{a as ma,b as Ou,c as bl}from"./ZoomOut-XI-iJG4j.js";import{S as t1}from"./shell-route-loading-ALc0mrI8.js";import{a as s1}from"./extract-connection-data-BSTqgqHH.js";import{A as jo}from"./avatar-yxz7fyGH.js";import{T as Bu,u as Mu,I as i1,R as n1,a as r1}from"./index-CkgRi4X3.js";import{a as o1,i as $c}from"./mcp-oauth-BuJKTbpq.js";import{s as $u,g as a1}from"./connection-slug-eyAPH6o3.js";import{f as jr,a as Nr,b as Er,c as Tr,d as Ar,e as Rr,A as Pr,g as Dr}from"./alert-dialog-Dh6V_14o.js";import{C as yl,a as Ir}from"./card-Bj8otFuN.js";import{L as Ve}from"./label-Ds5L98Th.js";import{S as On}from"./switch-CS7rft2F.js";import{i as Di}from"./Play-BB5dP1L8.js";import{s as Dt}from"./Plus-CglBKrb5.js";import{a as l1,i as zu}from"./Settings02-RazZjdiv.js";import{s as es}from"./Trash01-DUxygeaL.js";import{u as Lr}from"./use-debounced-autosave-B3PmQihS.js";import{i as Bn}from"./SearchMd-Bmh_sD0S.js";import{i as Kn}from"./Upload01-CEAuuYpa.js";import{i as c1}from"./LayoutLeft-Bij2Lb4X.js";import{P as os}from"./index-DXI2OWA9.js";import{C as Ki}from"./checkbox-Da1mUHNU.js";import{S as Fu}from"./search-input-DLLGaO2O.js";import{C as Hu}from"./collection-tabs-CmheS0lt.js";import{u as d1}from"./use-mcp-prompts-BCcxOooU.js";import{b as h1,a as u1,D as f1}from"./drawer-B07QIoON.js";import{i as js}from"./ChevronUp-ELVqY6cz.js";import{i as Sl}from"./Key01-oftOkafI.js";import{a as Uu,G as m1}from"./github-repo-picker-BkDPWKjv.js";import{S as wl}from"./skeleton-Et7A2pSm.js";import{s as p1}from"./User01-fdrqbZOX.js";import{t as co}from"./Users01-BQH1rUR7.js";import{u as g1,a as _1}from"./use-secrets-fz_TrA3p.js";import{f as v1}from"./formatDistanceToNow-Cb2QZZJn.js";import{n as hi}from"./LinkExternal01-9FNotiMN.js";import{s as si}from"./Star01-C9VN0Du_.js";import{i as Wu,s as kn}from"./Stars02-l9mDD3eo.js";import{V as x1}from"./view-mode-toggle-Bpaa83uS.js";import{n as pa}from"./ZapSquare-wbaFJ6J6.js";import{i as b1,a as Ii,b as Cl,c as kl}from"./Tool01-CqbO1hX2.js";import{i as y1,c as Vu,a as S1}from"./SwitchHorizontal01-DO04KALD.js";import{i as jl}from"./X-DH6rpzm4.js";import{i as w1,a as C1}from"./DotsVertical-FbZSolmB.js";import{C as k1,A as j1}from"./automation-runs-DMkXGxyD.js";import{b as Nl,C as El,a as Or,e as Br,c as Tl,d as Ku,f as N1}from"./command-D_g4Qh6z.js";import{u as E1,a as qu}from"./use-file-configs-D4iNPF8_.js";import{u as T1}from"./useInfiniteQuery-ChBCbSD3.js";import{i as A1}from"./FilterLines-Cf2PdvFM.js";import{M as Gu}from"./monaco-editor-BIbmj68Y.js";import{B as R1}from"./badge-CQquKN9p.js";import{M as P1}from"./select-model-DRzRHvEm.js";import{u as qn,a as D1,b as I1,c as L1,d as O1}from"./use-automations-DBCBw7t_.js";import{i as Mn}from"./Zap-jC0lbn1q.js";import{A as B1}from"./automation-list-row-DCvQVGai.js";function nn(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}k`:String(t)}function zc(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 M1(t){return t?t.replace(/-\d{8}(?:-[a-z0-9]+)*$/i,"").replace(/-/g," "):"—"}function $1(t){const e=U.c(4),{items:s}=t;let i;e[0]!==s?(i=s.map(z1),e[0]=s,e[1]=i):i=e[1];let r;return e[2]!==i?(r=n.jsx("div",{className:"grid grid-cols-2 gap-x-8 gap-y-6",children:i}),e[2]=i,e[3]=r):r=e[3],r}function z1(t){return n.jsxs("div",{className:"flex flex-col gap-1 min-w-0",children:[n.jsx("span",{className:"text-xs text-muted-foreground truncate",children:t.label}),n.jsx("span",{className:"text-sm text-foreground tabular-nums truncate",children:t.value})]},t.label)}function F1(t){const e=U.c(30),{userTokens:s,assistantTokens:i,otherTokens:r}=t,o=s+i+r,a=o>0?s/o*100:0,l=o>0?i/o*100:0,d=o>0?r/o*100:0;let c;e[0]!==a?(c=a>0&&n.jsx("div",{className:"h-full bg-chart-1",style:{width:`${a}%`}}),e[0]=a,e[1]=c):c=e[1];let h;e[2]!==l?(h=l>0&&n.jsx("div",{className:"h-full bg-chart-2",style:{width:`${l}%`}}),e[2]=l,e[3]=h):h=e[3];let u;e[4]!==d?(u=d>0&&n.jsx("div",{className:"h-full bg-muted-foreground/30",style:{width:`${d}%`}}),e[4]=d,e[5]=u):u=e[5];let f;e[6]!==c||e[7]!==h||e[8]!==u?(f=n.jsxs("div",{className:"flex h-2 w-full overflow-hidden rounded-full bg-muted",children:[c,h,u]}),e[6]=c,e[7]=h,e[8]=u,e[9]=f):f=e[9];let m;e[10]===Symbol.for("react.memo_cache_sentinel")?(m=n.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-chart-1 shrink-0"}),e[10]=m):m=e[10];let p;e[11]!==a?(p=a.toFixed(1),e[11]=a,e[12]=p):p=e[12];let g;e[13]!==p?(g=n.jsxs("div",{className:"flex items-center gap-1.5",children:[m,n.jsxs("span",{className:"text-xs text-muted-foreground",children:["User ",p,"%"]})]}),e[13]=p,e[14]=g):g=e[14];let _;e[15]===Symbol.for("react.memo_cache_sentinel")?(_=n.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-chart-2 shrink-0"}),e[15]=_):_=e[15];let b;e[16]!==l?(b=l.toFixed(1),e[16]=l,e[17]=b):b=e[17];let x;e[18]!==b?(x=n.jsxs("div",{className:"flex items-center gap-1.5",children:[_,n.jsxs("span",{className:"text-xs text-muted-foreground",children:["Assistant ",b,"%"]})]}),e[18]=b,e[19]=x):x=e[19];let v;e[20]!==d||e[21]!==r?(v=r>0&&n.jsxs("div",{className:"flex items-center gap-1.5",children:[n.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-muted-foreground/30 shrink-0"}),n.jsxs("span",{className:"text-xs text-muted-foreground",children:["Other ",d.toFixed(1),"%"]})]}),e[20]=d,e[21]=r,e[22]=v):v=e[22];let y;e[23]!==x||e[24]!==v||e[25]!==g?(y=n.jsxs("div",{className:"flex flex-wrap gap-x-3 gap-y-1",children:[g,x,v]}),e[23]=x,e[24]=v,e[25]=g,e[26]=y):y=e[26];let S;return e[27]!==y||e[28]!==f?(S=n.jsxs("div",{className:"flex flex-col gap-2",children:[f,y]}),e[27]=y,e[28]=f,e[29]=S):S=e[29],S}function H1(t){const e=U.c(11),{agentId:s,isError:i}=t,r=vs(s),o=r?.title??"Subtask",a=r?.icon??null;let l;e[0]!==a||e[1]!==o?(l=n.jsx(xs,{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 d=i?"text-destructive":"text-foreground";let c;e[3]!==d?(c=ae("shrink-0 font-medium",d),e[3]=d,e[4]=c):c=e[4];let h;e[5]!==o||e[6]!==c?(h=n.jsx("span",{className:c,children:o}),e[5]=o,e[6]=c,e[7]=h):h=e[7];let u;return e[8]!==l||e[9]!==h?(u=n.jsxs(n.Fragment,{children:[l,h]}),e[8]=l,e[9]=h,e[10]=u):u=e[10],u}function U1(t){const e=U.c(5),{isError:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx(xs,{icon:null,name:"Subtask",size:"xs",className:"size-6 rounded-md shrink-0"}),e[0]=i):i=e[0];const r=s?"text-destructive":"text-foreground";let o;e[1]!==r?(o=ae("shrink-0 font-medium",r),e[1]=r,e[2]=o):o=e[2];let a;return e[3]!==o?(a=n.jsxs(n.Fragment,{children:[i,n.jsx("span",{className:o,children:"Subtask"})]}),e[3]=o,e[4]=a):a=e[4],a}function W1(t){const e=U.c(18),{part:s}=t,i=s.input?.agent_id,r=s.state==="input-streaming"||s.state==="input-available"||s.state==="output-available"&&s.preliminary===!0,o=s.state==="output-error",a=s.state==="approval-requested";let l;e[0]!==o?(l=n.jsx(U1,{isError:o}),e[0]=o,e[1]=l):l=e[1];let d;e[2]!==i||e[3]!==o?(d=n.jsx(H1,{agentId:i,isError:o}),e[2]=i,e[3]=o,e[4]=d):d=e[4];let c;e[5]!==l||e[6]!==d?(c=n.jsx(D.Suspense,{fallback:l,children:d}),e[5]=l,e[6]=d,e[7]=c):c=e[7];let h;e[8]!==s.input?(h=s.input?.prompt&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"text-muted-foreground/50",children:"·"}),n.jsx("span",{className:"truncate text-muted-foreground",children:s.input.prompt})]}),e[8]=s.input,e[9]=h):h=e[9];let u;e[10]!==a||e[11]!==o||e[12]!==r?(u=n.jsx("span",{className:"ml-auto shrink-0",children:r?n.jsx(Oe,{size:12,className:"animate-spin text-muted-foreground"}):o?n.jsx(gg,{size:12,className:"text-destructive"}):a?n.jsx(zi,{size:12,className:"text-warning"}):n.jsx(Yh,{size:12,className:"text-emerald-500"})}),e[10]=a,e[11]=o,e[12]=r,e[13]=u):u=e[13];let f;return e[14]!==c||e[15]!==h||e[16]!==u?(f=n.jsxs("div",{className:"flex items-center gap-2 text-xs min-w-0",children:[c,h,u]}),e[14]=c,e[15]=h,e[16]=u,e[17]=f):f=e[17],f}function V1(t){const e=U.c(55),{onClose:s,back:i,className:r}=t,[o,a]=D.useState(null),{messages:l}=li(),{activeTask:d}=Ts(),{selectedModel:c,selectedVirtualMcp:h}=cl();let u,f,m,p,g,_,b,x;if(e[0]!==d||e[1]!==i||e[2]!==r||e[3]!==l||e[4]!==s||e[5]!==o?.id||e[6]!==c||e[7]!==h?.title){x=Symbol.for("react.early_return_sentinel");e:{const S=bg(l),w=[...l].reverse().find(sv),C=w?.metadata?.usage,N=w?.metadata?.modelLimits?.contextWindow??c?.limits?.contextWindow??null,E=C?.contextTokens??0,R=N&&N>0?(E/N*100).toFixed(1):null,T=l;let k;e[16]!==T?(k=T.filter(tv).reduce(ev,0),e[16]=T,e[17]=k):k=e[17];const j=k,I=l;let A;e[18]!==I?(A=I.filter(Q1).reduce(Z1,0),e[18]=I,e[19]=A):A=e[19];const O=A,L=Math.max(0,S.totalTokens-j-O),P=l[0],B=l.at(-1),F=P?.metadata?.created_at??d?.created_at,H=B?.metadata?.created_at??d?.updated_at,z=l.filter(J1),W=l.flatMap(Y1),q=c?.modelId?M1(c.modelId):"—",K=h?.title??"Decopilot",Z=[{label:"Session",value:d?.title??"New chat"},{label:"Messages",value:z.length},{label:"Agent",value:K},{label:"Model",value:q},{label:"Context Limit",value:N?nn(N):"—"},{label:"Session Tokens (billed)",value:S.totalTokens>0?nn(S.totalTokens):"0"},{label:"Usage",value:R!==null?`${R}%`:"—"},{label:"Input Tokens",value:S.inputTokens>0?nn(S.inputTokens):"0"},{label:"Output Tokens",value:S.outputTokens>0?nn(S.outputTokens):"0"},{label:"Reasoning Tokens",value:S.reasoningTokens>0?nn(S.reasoningTokens):"0"},{label:"Cost",value:S.cost>0?`$${S.cost<.001?S.cost.toFixed(6):S.cost.toFixed(4)}`:"$0.00"},{label:"Session Created",value:zc(F)},{label:"Last Activity",value:zc(H)}];if(!d&&z.length===0){let $;e[20]!==r?($=ae("flex flex-col h-full w-full border-l border-border bg-background",r),e[20]=r,e[21]=$):$=e[21];let X;e[22]===Symbol.for("react.memo_cache_sentinel")?(X=n.jsx("span",{className:"text-sm font-medium text-foreground",children:"Context"}),e[22]=X):X=e[22];let V;e[23]!==i?(V=i?n.jsx(Tc,{size:14,className:"text-muted-foreground"}):n.jsx(Hs,{size:14,className:"text-muted-foreground"}),e[23]=i,e[24]=V):V=e[24];let se;e[25]!==s||e[26]!==V?(se=n.jsxs("div",{className:"h-11 px-4 flex items-center justify-between shrink-0 border-b border-border/50",children:[X,n.jsx("button",{type:"button",onClick:s,className:"flex size-6 items-center justify-center rounded hover:bg-accent transition-colors",children:V})]}),e[25]=s,e[26]=V,e[27]=se):se=e[27];let ee;e[28]===Symbol.for("react.memo_cache_sentinel")?(ee=n.jsx("div",{className:"flex-1 flex items-center justify-center px-4 text-center",children:n.jsx("p",{className:"text-xs text-muted-foreground",children:"Start a conversation to see context"})}),e[28]=ee):ee=e[28];let le;e[29]!==$||e[30]!==se?(le=n.jsxs("div",{className:$,children:[se,ee]}),e[29]=$,e[30]=se,e[31]=le):le=e[31],x=le;break e}e[32]!==r?(_=ae("flex flex-col h-full w-full border-l border-border bg-background overflow-y-auto",r),e[32]=r,e[33]=_):_=e[33];let Y;e[34]===Symbol.for("react.memo_cache_sentinel")?(Y=n.jsx("span",{className:"text-sm font-medium text-foreground",children:"Context"}),e[34]=Y):Y=e[34];let G;e[35]!==i?(G=i?n.jsx(Tc,{size:14}):n.jsx(Hs,{size:14}),e[35]=i,e[36]=G):G=e[36],e[37]!==s||e[38]!==G?(b=n.jsxs("div",{className:"flex h-11 shrink-0 items-center justify-between border-b border-border/50 px-4",children:[Y,n.jsx("button",{type:"button",onClick:s,className:"flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",children:G})]}),e[37]=s,e[38]=G,e[39]=b):b=e[39],u="flex flex-col gap-8 p-6",f=W.length>0&&n.jsxs("div",{className:"flex flex-col gap-3",children:[n.jsx("span",{className:"text-xs text-muted-foreground",children:"Subtasks"}),n.jsx("div",{className:"flex flex-col gap-1",children:W.map(G1)})]}),m=n.jsx($1,{items:Z});let Q;e[40]===Symbol.for("react.memo_cache_sentinel")?(Q=n.jsx("span",{className:"text-xs text-muted-foreground",children:"Context Breakdown"}),e[40]=Q):Q=e[40],e[41]!==O||e[42]!==L||e[43]!==j?(p=n.jsxs("div",{className:"flex flex-col gap-3",children:[Q,n.jsx(F1,{userTokens:j,assistantTokens:O,otherTokens:L})]}),e[41]=O,e[42]=L,e[43]=j,e[44]=p):p=e[44],g=z.length>0&&n.jsxs("div",{className:"flex flex-col gap-3",children:[n.jsx("span",{className:"text-xs text-muted-foreground",children:"Raw messages"}),n.jsx("div",{className:"flex flex-col gap-1",children:z.map($=>{const X=$.metadata?.created_at,V=o?.id===$.id;return n.jsxs("div",{className:"rounded-md border border-border/50 overflow-hidden",children:[n.jsxs("button",{type:"button",onClick:()=>a(V?null:$),className:"flex items-center justify-between gap-2 px-3 py-2 text-xs hover:bg-accent/50 w-full text-left cursor-pointer",children:[n.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[n.jsx("span",{className:ae("shrink-0 font-medium",$.role==="user"?"text-chart-1":"text-chart-2"),children:$.role}),n.jsx("span",{className:"text-muted-foreground",children:"•"}),n.jsx("span",{className:"truncate text-muted-foreground font-mono",children:$.id})]}),X&&n.jsx("span",{className:"shrink-0 text-muted-foreground tabular-nums",children:new Date(X).toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"})})]}),V&&n.jsxs(n.Fragment,{children:[$.role==="assistant"&&(()=>{const se=$.metadata?._request;if(!se)return null;const ee=se.systemSections??[],le=Math.max(1,...ee.map(q1)),ce=ee.reduce(K1,0);return n.jsxs("div",{className:"border-t border-border/50 px-3 py-2.5 text-xs space-y-2.5",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("span",{className:"font-medium text-foreground",children:"Request"}),n.jsxs("span",{className:"text-muted-foreground tabular-nums",children:[se.activeTools??0," / ",se.tools??0," ","tools active"]})]}),ee.length>0&&n.jsxs("div",{className:"space-y-1.5",children:[n.jsxs("div",{className:"text-muted-foreground",children:["System prompt"," ",n.jsxs("span",{className:"tabular-nums",children:["~",Math.round(ce/4).toLocaleString()," ","tok"]})]}),ee.map((fe,J)=>{const te=fe.preview.match(/^<([a-z-]+)/i)?.[1]??`section ${J}`,oe=fe.chars/le*100,de=Math.round(fe.chars/4);return n.jsxs("div",{className:"space-y-0.5",children:[n.jsxs("div",{className:"flex items-center justify-between gap-2",children:[n.jsx("span",{className:"font-mono text-foreground truncate",children:te}),n.jsxs("span",{className:"text-muted-foreground tabular-nums shrink-0",children:["~",de.toLocaleString()," tok"]})]}),n.jsx("div",{className:"h-1 w-full rounded-full bg-muted overflow-hidden",children:n.jsx("div",{className:"h-full rounded-full bg-chart-3",style:{width:`${oe}%`}})})]},J)})]})]})})(),n.jsx("pre",{className:"text-xs font-mono bg-muted px-3 py-2 overflow-auto whitespace-pre-wrap break-all border-t border-border/50 max-h-64",children:JSON.stringify($,null,2)})]})]},$.id)})})]})}e[0]=d,e[1]=i,e[2]=r,e[3]=l,e[4]=s,e[5]=o?.id,e[6]=c,e[7]=h?.title,e[8]=u,e[9]=f,e[10]=m,e[11]=p,e[12]=g,e[13]=_,e[14]=b,e[15]=x}else u=e[8],f=e[9],m=e[10],p=e[11],g=e[12],_=e[13],b=e[14],x=e[15];if(x!==Symbol.for("react.early_return_sentinel"))return x;let v;e[45]!==u||e[46]!==f||e[47]!==m||e[48]!==p||e[49]!==g?(v=n.jsxs("div",{className:u,children:[f,m,p,g]}),e[45]=u,e[46]=f,e[47]=m,e[48]=p,e[49]=g,e[50]=v):v=e[50];let y;return e[51]!==_||e[52]!==b||e[53]!==v?(y=n.jsxs("div",{className:_,children:[b,v]}),e[51]=_,e[52]=b,e[53]=v,e[54]=y):y=e[54],y}function K1(t,e){return t+e.chars}function q1(t){return t.chars}function G1(t,e){return n.jsx(W1,{part:t},e)}function Y1(t){return(t.parts??[]).filter(X1)}function X1(t){return t.type==="tool-subtask"}function J1(t){return t.role!=="system"}function Z1(t,e){const s=e.metadata?.usage;return t+(s?.outputTokens??0)}function Q1(t){return t.role==="assistant"}function ev(t,e){const s=e.metadata?.usage;return t+(s?.inputTokens??0)}function tv(t){return t.role==="user"}function sv(t){return t.role==="assistant"&&t.metadata?.usage}function iv(t){const e=U.c(13),{readOnly:s,identity:i,aboveRow:r,input:o,iceBreakers:a}=t,l=!s&&i?i:null;let d;e[0]!==r||e[1]!==s?(d=!s&&r?n.jsx("div",{"data-chat-above-row":"true",className:"@container/chat-bottom flex justify-start gap-1",children:r}):null,e[0]=r,e[1]=s,e[2]=d):d=e[2];let c;e[3]!==o||e[4]!==d?(c=n.jsxs("div",{className:"flex flex-col gap-2",children:[d,o]}),e[3]=o,e[4]=d,e[5]=c):c=e[5];let h;e[6]!==a||e[7]!==s?(h=!s&&a?n.jsx("div",{className:"w-full",children:a}):null,e[6]=a,e[7]=s,e[8]=h):h=e[8];let u;return e[9]!==l||e[10]!==c||e[11]!==h?(u=n.jsx("div",{"data-chat-centered":"true",className:"h-full w-full flex flex-col items-center justify-center px-4 gap-6",children:n.jsxs("div",{className:"w-full max-w-3xl flex flex-col gap-6",children:[l,c,h]})}),e[9]=l,e[10]=c,e[11]=h,e[12]=u):u=e[12],u}function nv(t){const e=U.c(25),{onOpenContextPanel:s}=t,{org:i}=Me(),{selectedVirtualMcp:r}=cl();let o;e[0]!==i.id?(o=Qh(i.id),e[0]=i.id,e[1]=o):o=e[1];const l=r??o,d=vs(l.id),c=Gh(),{data:h}=$i.useSession(),u=h?.user?.id,f=c?.activeTask??null,m=!!(u&&f?.created_by&&f.created_by!==u);let p;e[2]===Symbol.for("react.memo_cache_sentinel")?(p=n.jsx(Mg,{size:32}),e[2]=p):p=e[2];let g;e[3]!==l.icon||e[4]!==l.title?(g=n.jsx(xs,{icon:l.icon,name:l.title,size:"lg",fallbackIcon:p,className:"size-10 min-w-10 md:size-[60px]! md:min-w-[60px] rounded-xl md:rounded-[18px]!"}),e[3]=l.icon,e[4]=l.title,e[5]=g):g=e[5];let _;e[6]!==l.title?(_=n.jsx("h3",{className:"text-base md:text-xl font-medium text-foreground",children:l.title}),e[6]=l.title,e[7]=_):_=e[7];const b=l.description??"Ask anything about configuring model providers or using MCP Mesh.";let x;e[8]!==b?(x=n.jsx("div",{className:"text-muted-foreground text-center text-base max-w-md line-clamp-2",children:b}),e[8]=b,e[9]=x):x=e[9];let v;e[10]!==g||e[11]!==_||e[12]!==x?(v=n.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 md:gap-4 text-center",children:[g,_,x]}),e[10]=g,e[11]=_,e[12]=x,e[13]=v):v=e[13];const y=c?.currentBranch??null;let S;e[14]!==d||e[15]!==y?(S=n.jsx(lg,{virtualMcp:d,currentBranch:y}),e[14]=d,e[15]=y,e[16]=S):S=e[16];let w;e[17]!==s?(w=n.jsx(it.Input,{onOpenContextPanel:s}),e[17]=s,e[18]=w):w=e[18];let C;e[19]===Symbol.for("react.memo_cache_sentinel")?(C=n.jsx(it.IceBreakers,{}),e[19]=C):C=e[19];let N;return e[20]!==m||e[21]!==w||e[22]!==v||e[23]!==S?(N=n.jsx(iv,{readOnly:m,identity:v,aboveRow:S,input:w,iceBreakers:C}),e[20]=m,e[21]=w,e[22]=v,e[23]=S,e[24]=N):N=e[24],N}function Fc(t){const e=U.c(17),{outputs:s,collapsed:i,onToggle:r,variant:o}=t,a=o==="card"?"rounded-xl border border-border bg-muted/95 shadow-sm backdrop-blur-sm":"border-b border-border bg-background";let l;e[0]!==a?(l=ae(a),e[0]=a,e[1]=l):l=e[1];let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx("span",{className:"text-sm font-medium text-foreground",children:"Files in this task"}),e[2]=d):d=e[2];const c=i&&"-rotate-90";let h;e[3]!==c?(h=ae("size-4 text-muted-foreground transition-transform",c),e[3]=c,e[4]=h):h=e[4];let u;e[5]!==h?(u=n.jsx(cs,{className:h}),e[5]=h,e[6]=u):u=e[6];let f;e[7]!==r||e[8]!==u?(f=n.jsxs("button",{type:"button",onClick:r,className:"flex w-full items-center justify-between px-3 py-2.5 text-left",children:[d,u]}),e[7]=r,e[8]=u,e[9]=f):f=e[9];let m;e[10]!==i||e[11]!==s?(m=!i&&n.jsx("div",{className:"flex max-h-72 flex-col gap-1.5 overflow-y-auto px-2 pb-2",children:s.map(rv)}),e[10]=i,e[11]=s,e[12]=m):m=e[12];let p;return e[13]!==l||e[14]!==f||e[15]!==m?(p=n.jsxs("div",{className:l,children:[f,m]}),e[13]=l,e[14]=f,e[15]=m,e[16]=p):p=e[16],p}function rv(t){return n.jsx(Sg,{file:t},t.key)}function ov(){const t=U.c(13),e=Gh()?.taskId??null,s=yg();let i;t[0]!==s?(i={enabled:s},t[0]=s,t[1]=i):i=t[1];const{data:r}=Jh(e,i),[o,a]=D.useState(!1),[l,d]=D.useState(!0);if(!e||!r||r.length===0)return null;let c;t[2]===Symbol.for("react.memo_cache_sentinel")?(c=()=>a(lv),t[2]=c):c=t[2];let h;t[3]!==o||t[4]!==r?(h=n.jsx("div",{className:"absolute top-2 right-2 z-10 hidden w-72 @[1280px]:block",children:n.jsx(Fc,{variant:"card",outputs:r,collapsed:o,onToggle:c})}),t[3]=o,t[4]=r,t[5]=h):h=t[5];let u;t[6]===Symbol.for("react.memo_cache_sentinel")?(u=()=>d(av),t[6]=u):u=t[6];let f;t[7]!==l||t[8]!==r?(f=n.jsx("div",{className:"shrink-0 @[1280px]:hidden",children:n.jsx(Fc,{variant:"bar",outputs:r,collapsed:l,onToggle:u})}),t[7]=l,t[8]=r,t[9]=f):f=t[9];let m;return t[10]!==h||t[11]!==f?(m=n.jsxs(n.Fragment,{children:[h,f]}),t[10]=h,t[11]=f,t[12]=m):m=t[12],m}function av(t){return!t}function lv(t){return!t}function cv(){const t=U.c(26),{org:e}=Me(),s=fu(),{isChatEmpty:i}=li(),[r,o]=D.useState("chat"),a=$g(),l=Vg();if(s.length===0&&!zg(l)){let S;return t[0]===Symbol.for("react.memo_cache_sentinel")?(S=n.jsx(it,{className:"animate-in fade-in-0 duration-200",children:n.jsx(it.Main,{className:"flex flex-col items-center",children:n.jsx(it.EmptyState,{children:n.jsx(it.NoAiProviderEmptyState,{})})})}),t[0]=S):S=t[0],S}let c;t[1]!==a.hasDecoKey||t[2]!==a.hasOnlyDecoProvider||t[3]!==a.isLoading||t[4]!==a.isZeroBalance||t[5]!==i||t[6]!==e?(c=a.hasDecoKey&&a.isZeroBalance&&a.hasOnlyDecoProvider&&!a.isLoading&&i&&!cg(e.id),t[1]=a.hasDecoKey,t[2]=a.hasOnlyDecoProvider,t[3]=a.isLoading,t[4]=a.isZeroBalance,t[5]=i,t[6]=e,t[7]=c):c=t[7];const h=c;let u;t[8]!==h?(u=h&&n.jsx(it.CreditsEmptyState,{}),t[8]=h,t[9]=u):u=t[9];const f=r!=="chat"?"opacity-0 pointer-events-none":"opacity-100";let m;t[10]!==f?(m=ae("absolute inset-0 flex flex-col transition-opacity duration-100 ease-out",f),t[10]=f,t[11]=m):m=t[11];let p;t[12]!==i?(p=i?n.jsx(it.Main,{children:n.jsx(nv,{onOpenContextPanel:()=>o("context")})}):n.jsxs(n.Fragment,{children:[n.jsxs(it.Main,{className:"relative flex flex-col overflow-hidden @container",children:[n.jsx(ov,{}),n.jsx("div",{className:"min-h-0 flex-1",children:n.jsx(it.Messages,{})})]}),n.jsx(it.Footer,{children:n.jsx(it.Input,{onOpenContextPanel:()=>o("context")})})]}),t[12]=i,t[13]=p):p=t[13];let g;t[14]!==m||t[15]!==p?(g=n.jsx("div",{className:m,children:p}),t[14]=m,t[15]=p,t[16]=g):g=t[16];const _=r==="context"?"opacity-100":"opacity-0 pointer-events-none";let b;t[17]!==_?(b=ae("absolute inset-0 flex flex-col transition-opacity duration-100 ease-out",_),t[17]=_,t[18]=b):b=t[18];let x;t[19]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsx(V1,{back:!0,onClose:()=>o("chat")}),t[19]=x):x=t[19];let v;t[20]!==b?(v=n.jsx("div",{className:b,children:x}),t[20]=b,t[21]=v):v=t[21];let y;return t[22]!==u||t[23]!==g||t[24]!==v?(y=n.jsxs(it,{className:"relative overflow-hidden animate-in fade-in-0 duration-200",children:[u,g,v]}),t[22]=u,t[23]=g,t[24]=v,t[25]=y):y=t[25],y}function Yu(){const t=U.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(it.Skeleton,{}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx(Zt,{fallback:e,children:n.jsx(D.Suspense,{fallback:n.jsx(it.Skeleton,{}),children:n.jsx(cv,{})})}),t[1]=s):s=t[1],s}function dv(t){const e=t.entityMetadata?.defaultMainView??null,s=e==null||e.type==="chat",i=t.mainParamPresent?t.mainParamValue!=="0":!s,r=s?!0:t.entityMetadata?.chatDefaultOpen??!1;return{mainOpen:i,chatOpen:r}}function Hc(t,e){return t&&e?{chat:45,main:55}:t&&!e?{chat:100,main:0}:!t&&e?{chat:0,main:100}:{chat:0,main:0}}function hv(t,e){return t===1?!0:t===0?!1:e}function uv(t,e){const s=qt(),i=eo({strict:!1}),r=Fh({strict:!1}),{create:o}=yu(),{locator:a}=Me(),{virtualMcpId:l,orgSlug:d,isAgentRoute:c}=e,h=dv({entityMetadata:t,mainParamPresent:i.main!==void 0,mainParamValue:i.main}),u=hv(i.chat,h.chatOpen),f=h.mainOpen,m=D.useRef(crypto.randomUUID()),p=r.taskId??m.current,g="/$org/$taskId",_=E=>({org:d,taskId:E}),b=c?{virtualmcpid:l}:{},x=(E,R)=>{s({to:g,params:_(p),search:T=>({...T,...E}),replace:R?.replace??!1})},v=(E,R)=>{s({to:g,params:_(E),search:T=>{const k={};return R?k.virtualmcpid=R:c&&(k.virtualmcpid=l),k}})},y=()=>{f?x({main:"0"},{replace:!0}):x({main:ca(t)},{replace:!0})},S=()=>{x({chat:u?0:1},{replace:!0})},w=()=>{u||x({chat:1},{replace:!0})},C=async()=>{const E=crypto.randomUUID(),R=Kg(d,a,p);try{await o({id:E,virtual_mcp_id:l,...R?{branch:R}:{}})}catch{}s({to:g,params:_(E),search:T=>({...b,chat:1})})},N=E=>{x({main:E},{replace:!0})};return{taskId:p,mainOpen:f,chatOpen:u,mainParam:i.main,setTaskId:v,toggleMain:y,toggleChat:S,openChat:w,createNewTask:C,openTab:N}}const Al=45;function Xu(t,e=Al){const s=typeof t=="number"?t:Number(t);return!Number.isFinite(s)||s<=0||s>=100?e:s}function fv(t){return Xu(t,Al)}function mv(){const t=U.c(6);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=Gp.decoChatPanelWidth(),t[0]=e):e=t[0];const[s,i]=qp(e,fv);let r;t[1]!==s?(r=Xu(s,Al),t[1]=s,t[2]=r):r=t[2];const o=r;let a;return t[3]!==i||t[4]!==o?(a=[o,i],t[3]=i,t[4]=o,t[5]=a):a=t[5],a}function pv(t){try{return JSON.parse(t)}catch{return null}}function gv(t){if(!t||typeof t!="object")return null;const e=t,s=e.content?.find(o=>o.type==="text")?.text,i=s?pv(s):null,r=e.structuredContent;return r==null?i:typeof r=="object"&&!Array.isArray(r)&&Object.keys(r).length===0?i??r:r}function ui(t){const e=gv(t);return e===null?null:e}function Rl(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 _v(t){if(!t||typeof t!="object")return null;const e=t.content?.find(r=>r.type==="text")?.text;if(!e)return null;const s=e.match(/https:\/\/github\.com\/[^\s"]+\/pull\/\d+/)?.[0],i=Rl(s);return!i||!s?null:{number:i,htmlUrl:s}}const Uc=/[\r\n<>]/,vv=/^[^\s@<>]+@[^\s@<>]+\.[^\s@<>]+$/;function Gn(t){const e=t?.userName?.trim();if(!e||Uc.test(e))return null;const s=t?.userEmail?.trim();return!s||Uc.test(s)?{userName:e}:vv.test(s)?{userName:e,userEmail:s}:{userName:e}}function xv(t){return t.split(`
|
|
3
3
|
`).filter(e=>!/^Co-authored-by:\s/i.test(e)).join(`
|
|
4
4
|
`).trimEnd()}function bv(t){const e=t.userName.trim(),s=t.userEmail?.trim();return s?`Co-authored-by: ${e} <${s}>`:`Co-authored-by: ${e}`}function Ju(t,e){const s=Gn(e);if(!s)return t;const i=xv(t),r=bv(s);if(i.includes(r))return i;const o=i.trimEnd();return o.length>0?`${o}
|
|
5
5
|
|
|
@@ -463,8 +463,8 @@ ${X}`:X;c.setValue("metadata.instructions",V,{shouldDirty:!0})},K=new Set(h.map(
|
|
|
463
463
|
8% { opacity: 1; }
|
|
464
464
|
22% { opacity: 0; }
|
|
465
465
|
}
|
|
466
|
-
`}),e[26]=y):y=e[26];let S;return e[27]!==v||e[28]!==h?(S=n.jsxs("div",{className:"relative flex w-full flex-col items-center justify-center gap-12 select-none [clip-path:inset(-24px_0_-200px_0)]",children:[h,v,y]}),e[27]=v,e[28]=h,e[29]=S):S=e[29],S}function ir(t){const e=U.c(10),{phase:s,current:i,children:r}=t,o=s-i,a=o<0,l=o===0,d=a?90:o*-22,c=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=ae("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(${d}px) scale(${c})`,g=l?"auto":"none";let _;e[1]!==h||e[2]!==p||e[3]!==g||e[4]!==u?(_={transform:p,opacity:h,zIndex:u,transitionDuration:"1000ms",pointerEvents:g},e[1]=h,e[2]=p,e[3]=g,e[4]=u,e[5]=_):_=e[5];let b;return e[6]!==r||e[7]!==f||e[8]!==_?(b=n.jsx("div",{"aria-hidden":f,className:m,style:_,children:r}),e[6]=r,e[7]=f,e[8]=_,e[9]=b):b=e[9],b}function po(t){const e=U.c(7),{showUrl:s}=t,i=s===void 0?!1:s;let r,o,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=n.jsx("div",{className:ae("size-2.5 rounded-full",Xt)}),o=n.jsx("div",{className:ae("size-2.5 rounded-full",Xt)}),a=n.jsx("div",{className:ae("size-2.5 rounded-full",Xt)}),e[0]=r,e[1]=o,e[2]=a):(r=e[0],o=e[1],a=e[2]);let l;e[3]!==i?(l=i&&n.jsx("div",{className:ae("ml-3 h-3.5 max-w-[220px] flex-1 rounded-sm",ms)}),e[3]=i,e[4]=l):l=e[4];let d;return e[5]!==l?(d=n.jsxs("div",{className:"flex h-7 shrink-0 items-center gap-1.5 px-3",children:[r,o,a,l]}),e[5]=l,e[6]=d):d=e[6],d}function V0(){const t=U.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(po,{}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsxs("div",{className:"flex h-full flex-col",children:[e,n.jsx("div",{className:"flex flex-1 px-8 py-5",children:n.jsx("div",{className:"grid h-full w-full grid-cols-8 grid-rows-6 gap-2",children:$0.map(K0)})})]}),t[1]=s):s=t[1],s}function K0(t,e){if(e===om)return n.jsx("div",{className:"rounded-md bg-chart-1/[0.55]",style:{animation:"vm-breathe 2.4s ease-in-out infinite"}},e);const s=t;return n.jsx("div",{className:ae("relative rounded-md",Xt),children:n.jsx("div",{className:"absolute inset-0 rounded-md bg-chart-1/40 opacity-0",style:{animation:`vm-rack-scan ${am}s ease-in-out infinite`,animationDelay:`${s}s`}})},e)}function q0(){const t=U.c(5);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(po,{}),t[0]=e):e=t[0];let s;t[1]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx("div",{className:ae("w-[18%] rounded-md",ms),style:{animation:"vm-breathe 3s ease-in-out infinite"}}),t[1]=s):s=t[1];let i;t[2]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx("div",{className:"h-[42%] shrink-0 rounded-md bg-chart-3/[0.12]",style:{animation:"vm-breathe 3s ease-in-out 0.4s infinite"}}),t[2]=i):i=t[2];let r;t[3]===Symbol.for("react.memo_cache_sentinel")?(r=n.jsx("div",{className:"col-span-3 rounded-md bg-chart-3/[0.12]",style:{animation:"vm-breathe 3s ease-in-out 0.8s infinite"}}),t[3]=r):r=t[3];let o;return t[4]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsxs("div",{className:"flex h-full flex-col",children:[e,n.jsxs("div",{className:"flex min-h-0 flex-1 gap-1.5 p-3",children:[s,n.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-1.5",children:[i,n.jsxs("div",{className:"grid min-h-0 flex-1 grid-cols-5 gap-1.5",children:[r,n.jsxs("div",{className:"col-span-2 grid grid-rows-2 gap-1.5",children:[n.jsx("div",{className:ae("rounded-md",ms),style:{animation:"vm-breathe 3s ease-in-out 1.2s infinite"}}),n.jsx("div",{className:ae("rounded-md",ms),style:{animation:"vm-breathe 3s ease-in-out 1.6s infinite"}})]})]})]})]})]}),t[4]=o):o=t[4],o}function G0(){const t=U.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(po,{}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsxs("div",{className:"flex h-full flex-col",children:[e,n.jsx("div",{className:"relative flex flex-1 items-center justify-center px-8 py-5",children:n.jsx("div",{className:"grid w-full gap-2",style:{gridTemplateColumns:"repeat(7, minmax(0, 1fr))"},children:H0.map(Y0)})})]}),t[1]=s):s=t[1],s}function Y0(t,e){return n.jsx("div",{className:ae("aspect-square rounded-md",U0[e]?"bg-chart-2/70":Xt),style:{animation:`vm-pulse-soft 2.2s ease-in-out ${t}s infinite`}},e)}function X0(){const t=U.c(11);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(po,{showUrl:!0}),t[0]=e):e=t[0];let s,i,r,o,a;t[1]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx("div",{className:"mb-2 h-5 rounded-md bg-chart-1/[0.10]"}),i=n.jsx("div",{className:ae("h-1.5 w-[70%] rounded-sm",Xt)}),r=n.jsx("div",{className:ae("h-1.5 w-[55%] rounded-sm",Xt)}),o=n.jsx("div",{className:ae("h-1.5 w-[80%] rounded-sm",Xt)}),a=n.jsx("div",{className:ae("h-1.5 w-[50%] rounded-sm",Xt)}),t[1]=s,t[2]=i,t[3]=r,t[4]=o,t[5]=a):(s=t[1],i=t[2],r=t[3],o=t[4],a=t[5]);let l;t[6]===Symbol.for("react.memo_cache_sentinel")?(l=n.jsxs("div",{className:"flex w-[18%] shrink-0 flex-col gap-1.5 bg-chart-1/[0.05] p-2.5",children:[s,i,r,o,a,n.jsx("div",{className:"mt-auto",children:n.jsx("div",{className:ae("h-4 rounded-md",Xt)})})]}),t[6]=l):l=t[6];let d;t[7]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx("div",{className:"relative h-[42%] shrink-0 overflow-hidden bg-chart-1/[0.10]",children:n.jsxs("div",{className:"absolute right-3 bottom-3 left-3 space-y-1.5",children:[n.jsx("div",{className:"h-3 w-[35%] rounded-sm bg-chart-1/[0.15]"}),n.jsx("div",{className:ae("h-1.5 w-[55%] rounded-sm",ms)})]})}),t[7]=d):d=t[7];let c;t[8]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsxs("div",{className:"flex shrink-0 gap-1.5",children:[n.jsx("div",{className:"h-4 w-12 rounded-full bg-chart-1/[0.12]"}),n.jsx("div",{className:ae("h-4 w-10 rounded-full",ms)}),n.jsx("div",{className:ae("h-4 w-14 rounded-full",ms)})]}),t[8]=c):c=t[8];let h;t[9]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsxs("div",{className:ae("col-span-3 flex flex-col justify-end gap-1 rounded-md p-2",ms),children:[n.jsx("div",{className:ae("h-1.5 w-[50%] rounded-sm",Xt)}),n.jsx("div",{className:ae("h-1 w-[75%] rounded-sm",Xt)})]}),t[9]=h):h=t[9];let u;return t[10]===Symbol.for("react.memo_cache_sentinel")?(u=n.jsxs("div",{className:"flex h-full flex-col",children:[e,n.jsxs("div",{className:"flex min-h-0 flex-1",children:[l,n.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[d,n.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-2.5 p-3",children:[c,n.jsxs("div",{className:"grid min-h-0 flex-1 grid-cols-5 gap-2",children:[h,n.jsxs("div",{className:"col-span-2 grid grid-rows-2 gap-2",children:[n.jsx("div",{className:ae("rounded-md",ms)}),n.jsx("div",{className:ae("rounded-md",ms)})]})]})]})]})]})]}),t[10]=u):u=t[10],u}function Wr(t){const e=U.c(9);if(t.kind==="starting"){let l;return e[0]!==t.claimPhase||e[1]!==t.progress?(l=n.jsx("div",{className:"flex h-full w-full items-center justify-center bg-background p-6",children:n.jsx(W0,{progress:t.progress,claimPhase:t.claimPhase})}),e[0]=t.claimPhase,e[1]=t.progress,e[2]=l):l=e[2],l}let s;e[3]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx(T_,{className:"size-12 text-blue-500"}),e[3]=s):s=e[3];let i,r;e[4]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx("h3",{className:"text-lg font-medium",children:B0("suspended")}),r=n.jsx("p",{className:"max-w-sm text-sm text-muted-foreground",children:"Resume to continue."}),e[4]=i,e[5]=r):(i=e[4],r=e[5]);let o;e[6]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx(Di,{className:"size-4"}),e[6]=o):o=e[6];let a;return e[7]!==t.onResume?(a=n.jsx("div",{className:"flex h-full w-full items-center justify-center bg-background p-6",children:n.jsxs("div",{className:"flex w-full max-w-md flex-col items-center gap-4 text-center",children:[s,i,r,n.jsxs(ie,{onClick:t.onResume,className:"mt-2",children:[o," Resume"]})]})}),e[7]=t.onResume,e[8]=a):a=e[8],a}function J0(t){const e=U.c(12),{orgSlug:s,virtualMcpId:i,branch:r,enabled:o}=t,a=o===void 0?!0:o;let l;e[0]!==r||e[1]!==s||e[2]!==i?(l=Et.sandboxRepoDir(s,i,r),e[0]=r,e[1]=s,e[2]=i,e[3]=l):l=e[3];let d;e[4]!==r||e[5]!==s||e[6]!==i?(d=async()=>{const u=`/api/${s}/sandbox/${encodeURIComponent(i)}/${encodeURIComponent(r)}/config`,f=await fetch(u);return f.ok?(await f.json()).repoDir??null:null},e[4]=r,e[5]=s,e[6]=i,e[7]=d):d=e[7];let c;return e[8]!==a||e[9]!==l||e[10]!==d?(c={queryKey:l,queryFn:d,enabled:a,staleTime:1/0},e[8]=a,e[9]=l,e[10]=d,e[11]=c):c=e[11],Es(c).data??null}const hd="https://decoims.com/decocms/01b321bd-4613-4b2c-9348-35058444d210/Visual_Studio_Code_1.35_icon.svg.png",ud="https://decoims.com/decocms/7583d3b5-81d0-4afb-becf-6a59bbb3a68e/cursor-logo-icon-freelogovectors.net_.png",Z0=D.lazy(()=>ls(()=>import("./sections-editor-DAz_riff.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])).then(t=>({default:t.SectionsEditor}))),Q0=D.lazy(()=>ls(()=>import("./page-seo-sheet-CAgRh54V.js"),__vite__mapDeps([141,1,2,70,42,44,7,8,9,10,11,12,13,14,15,16,6,3,4,5,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,43,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,71,72,73,74,75,76,77,78,97,98,100,91,88,101,102,80,81,82,83,84,85,86,87,89,90,92,93,94,95,96,103,104,105,106,107,108,109,110,111,79,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])).then(t=>({default:t.SeoSheet}))),e2=D.lazy(()=>ls(()=>import("./file-explorer-QNJW4EAt.js"),__vite__mapDeps([142,1,2,117,7,8,9,10,11,12,13,14,15,16,6,3,4,5,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,122,143,116,106,79,109,100,91,88,101,102,80,81,82,83,84,85,86,87,89,90,92,93,94,95,96,103,104,105,107,108,110,111,112,113,114,115,118,119,120,121,98,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140])).then(t=>({default:t.FileExplorer}))),Do=500,t2={mobile:375,tablet:768,desktop:null},Io=["desktop","mobile","tablet"],s2={mobile:"Mobile (375px)",tablet:"Tablet (768px)",desktop:"Desktop"},i2="website/sections/Rendering/Lazy.tsx";function ya(t,e){let s=t,i=typeof s?.__resolveType=="string"?s.__resolveType:"";for(let r=0;i&&r<5;r++){const o=e[i];if(o&&typeof o=="object"&&"__resolveType"in o){const a=o.__resolveType;if(typeof a=="string"&&a&&a!==i){s=o,i=a;continue}}break}if(!i)return[];if(i.includes("flags/multivariate")){const r=Array.isArray(s.variants)?s.variants:[],o=[];for(const a of r){const l=a?.value;if(l&&typeof l=="object")for(const d of ya(l,e))o.includes(d)||o.push(d)}return o}if(i===i2){const r=s.section&&typeof s.section=="object"?ya(s.section,e):[];return r.length?[i,...r]:[i]}return[i]}function n2(t,e){const s=new URL(t,window.location.href);return s.searchParams.set("deviceHint",e),s.href}function r2(){const t=gi(),{currentBranch:e}=Ts(),[s,i]=D.useState("preview"),[r,o]=D.useState("desktop"),[a,l]=D.useState(null),d=D.useRef(null),c=s==="cms",[h,u]=D.useState(null),[f,m]=D.useState(null),[p,g]=D.useState(384),_=D.useRef(!1),b=D.useRef(0),x=D.useRef(0),v=D.useRef(null),[y,S]=D.useState(!1),[w,C]=D.useState(""),N=D.useRef(null),[E,R]=D.useState(!1),[T,k]=D.useState(),[j,I]=D.useState(null),[A,O]=D.useState(null),[L,P]=D.useState("/"),[B,F]=D.useState(null),[H,z]=D.useState(!1),[W,q]=D.useState(!1),[K,Z]=D.useState(null),Y=t?.entity?.id??null,{org:G}=Me(),Q=bs(),$=Gl(),X=$.vmEntry,V=$.previewUrl,se=Q.lifecycle.phase,ee=se==="running",le=X?.sandboxProviderKind==="user-desktop",ce=J0({orgSlug:G.slug,virtualMcpId:Y??"",branch:e??"",enabled:le&&ee&&!!Y&&!!e}),fe=le?ce:null,J=Y&&e&&ee?{orgSlug:G.slug,virtualMcpId:Y,branch:e,previewUrl:V}:null,{data:te}=Ol(J,{fetchEnabled:ee}),{data:oe}=Bl(J,{fetchEnabled:ee}),de=Y&&e?{orgSlug:G.slug,virtualMcpId:Y,branch:e}:null,be=N0(de),ve=te?Vl(te).sort((ne,je)=>ne.name.localeCompare(je.name)):[],we=te&&oe?ql(te,oe):[],De=Ti,Be=ve.filter(ne=>{if(!w)return!0;const je=w.toLowerCase();return ne.name.toLowerCase().includes(je)||ne.path.toLowerCase().includes(je)}),Pe=we.filter(ne=>{if(!w)return!0;const je=w.toLowerCase();return ne.name.toLowerCase().includes(je)||ne.key.toLowerCase().includes(je)||ne.resolveType.toLowerCase().includes(je)}),Fe=j?null:ix(ve,L,B),xe=j?j.name:Fe?.name,ye=Fe?.key??null,Ie=te&&ye?tm(te,ye,0):[],Le=te?Xf(Ie,te):[],qe=Le.map(ne=>ne.isSavedBlock?ne.label:""),st=Le.map(ne=>ne.isSavedBlock?"global":ne.isMultivariate?"variant":"normal"),ct=Ie.map(ne=>ya(ne,te??{})),Se=D.useRef(null),pe=D.useRef(null);mx(()=>{const ne=d.current,je=Se.current;!ne||!je||(ne.src=je)});const $e=Q.status.state==="paused",Ge=Q.phase,He=rm({claimPhase:Ge,lifecycle:Q.lifecycle}),Ye=$.previewState,M=$.userStopped,ue=Ye.kind==="starting"||Ye.kind==="iframe"&&He.status==="doing",ge=Ye.kind==="iframe"?c0(n2(A??new URL(L,Ye.previewUrl).href,r),c&&f?f:[]):null,[ke,Je]=D.useState(null);if(Ye.kind==="iframe"&&ke!==Ye.previewUrl){const ne=ke!==null;Je(Ye.previewUrl),ne&&(pe.current=null,P("/"),O(null),F(null),I(null))}Se.current=ge;const mt=!!Y&&!!e&&!Q.notFound&&!M&&!$e&&(Ge?.kind==="ready"||se!=="idle"),Vs=Ye.kind!=="iframe"&&(s==="visual"||s==="cms")?"preview":s;D.useEffect(()=>{if(!V)return;let ne;try{ne=new URL(V,window.location.href).origin}catch{return}const je=bt=>{if(bt.origin===ne){if(bt.data?.type==="visual-editor::element-clicked"){const yt=T0.safeParse(bt.data.payload);yt.success&&l(yt.data)}else if(bt.data?.type==="cms-editor::section-clicked"){const yt=R0.safeParse(bt.data.payload);yt.success&&u(yt.data.sectionIndex)}}};return window.addEventListener("message",je),()=>window.removeEventListener("message",je)},[V]),D.useEffect(()=>{if(!y)return;const ne=je=>{N.current?.contains(je.target)||(S(!1),C(""))};return document.addEventListener("pointerdown",ne),()=>document.removeEventListener("pointerdown",ne)},[y]),D.useEffect(()=>{if(!c)return;const ne=bt=>{const yt=bt.target;yt&&yt!==d.current&&(v.current=yt)},je=()=>{requestAnimationFrame(()=>{const bt=document.activeElement;(bt===document.body||bt===d.current)&&v.current&&v.current.focus()})};return document.addEventListener("focusin",ne),document.addEventListener("blur",je,!0),()=>{document.removeEventListener("focusin",ne),document.removeEventListener("blur",je,!0)}},[c]);const tn=()=>{const ne=d.current?.contentWindow;ne&&ne.postMessage({type:"visual-editor::activate",script:A0},"*")},Ip=()=>{const ne=d.current?.contentWindow;ne&&ne.postMessage({type:"visual-editor::deactivate"},"*")},Nc=()=>{const ne=d.current?.contentWindow;ne&&(ne.postMessage({type:"visual-editor::activate",script:P0},"*"),ne.postMessage({type:"cms-editor::set-labels",labels:qe,kinds:st,keys:ct},"*"))},Lp=()=>{const ne=d.current?.contentWindow;ne&&ne.postMessage({type:"cms-editor::deactivate"},"*")},sn=ne=>{const je=s;i(ne),l(null),ne!=="code"&&Z(null),ne!=="cms"&&(u(null),m(null)),je==="visual"&&Ip(),je==="cms"&&Lp(),ne==="visual"&&tn(),ne==="cms"&&Nc()},Op=()=>{if(!d.current||!ge)return;const ne=d.current;ne.src=ge},Bp=ne=>{m(ne)},Mp=()=>{const ne=d.current;if(!ne)return;const je=document.activeElement,bt=ne.tabIndex;ne.tabIndex=-1,ne.style.pointerEvents="none",ne.blur();try{ne.contentWindow?.location.reload()}catch{const is=Se.current;is&&(ne.src=is)}const yt=()=>{ne.tabIndex=bt,ne.style.pointerEvents="",je?.focus(),ne.removeEventListener("load",yt)};ne.addEventListener("load",yt),setTimeout(yt,3e3)},$p=()=>{if(!d.current||!ge)return;const ne=ge.includes("?")?"&":"?";d.current.src=`${ge}${ne}_r=${Date.now()}`},zp=()=>{const ne=Io.indexOf(r);o(Io[(ne+1)%Io.length])},Fp=()=>{const ne=d.current?.contentWindow?.location?.href??ge??V;ne&&navigator.clipboard.writeText(ne)},Hp=(()=>{if(!V)return"No server running";if(j)return j.name;try{const ne=new URL(V),je=L==="/"?"":L;return`${ne.host}${je}`}catch{return V}})(),Ec=ne=>{pe.current=ne.path,I(null),O(null),F(ne.key),P(ne.path),u(null),z(!1)},Up=ne=>{if(!V||!oe){he.error("Preview metadata not ready yet");return}pe.current=null;const je=_f(oe),bt=S0(V,je,ne.key);I(ne),O(bt),u(null)},Wp=async({name:ne,path:je})=>{if(!Y||!e)return;const bt=Hl(je);if(bt){k(bt);return}const yt=je.trim().startsWith("/")?je.trim():`/${je.trim()}`;if(ve.some(is=>De(is.path)===De(yt))){k(`A page with path "${yt}" already exists.`);return}k(void 0);try{const is=await be.mutateAsync({name:ne,path:yt});R(!1),he.success(`Page "${ne}" created`),await new Promise(Kp=>setTimeout(Kp,Do)),Ec({key:is.key,name:is.name,path:is.path}),sn("cms")}catch(is){k(is instanceof Error?is.message:"Failed to create page")}},Vp=[{value:"preview",icon:n.jsx(Lc,{size:14}),tooltip:"Interactive"},...Ye.kind==="iframe"?[{value:"visual",icon:n.jsx(Oc,{size:14}),tooltip:"Visual editor"}]:[],...Ye.kind==="iframe"&&Wl(te,oe)?[{value:"cms",icon:n.jsx(A_,{size:14}),tooltip:"Sections editor"}]:[],{value:"code",icon:n.jsx(R_,{size:14}),tooltip:"Code editor"}];return n.jsxs("div",{className:"flex flex-col w-full h-full",children:[mt&&n.jsxs("div",{className:"flex h-12 shrink-0 items-center gap-4 border-b border-border/60 px-3 md:px-4",children:[n.jsx("div",{className:"flex shrink-0 items-center gap-1",children:n.jsx(x1,{value:Vs,onValueChange:sn,options:Vp,size:"sm",className:"shrink-0 bg-foreground/4.5"})}),Ye.kind==="iframe"&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:ae("flex min-w-0 flex-1 items-center gap-0.5 ml-2",s==="code"&&"hidden"),children:[n.jsxs(Te,{children:[n.jsx(Ne,{asChild:!0,children:n.jsx(ie,{variant:"ghost",size:"icon",onClick:Op,children:n.jsx(Pn,{size:14})})}),n.jsx(Ee,{side:"bottom",children:"Refresh"})]}),n.jsxs(Te,{children:[n.jsx(Ne,{asChild:!0,children:n.jsx(ie,{variant:"ghost",size:"icon",onClick:zp,children:n.jsxs("span",{className:"flex items-center justify-center animate-device-icon-pop",children:[r==="mobile"&&n.jsx(P_,{size:14}),r==="tablet"&&n.jsx(D_,{size:14}),r==="desktop"&&n.jsx(Lc,{size:14})]},r)})}),n.jsx(Ee,{side:"bottom",children:s2[r]})]}),n.jsxs("div",{ref:N,className:"relative min-w-0 flex-1",children:[n.jsxs("button",{type:"button",className:"flex h-8 w-full min-w-0 items-center gap-1 rounded-md bg-background px-2 transition-colors duration-200 hover:bg-accent",onClick:()=>S(ne=>!ne),children:[j&&n.jsxs("span",{className:"shrink-0 inline-flex items-center gap-1 rounded bg-global-section/14 px-1.5 py-0.5 text-[11px] font-medium text-global-section-fg dark:text-global-section-fg-dark",children:[n.jsx(si,{size:11}),"Global"]}),n.jsx("span",{className:"min-w-0 flex-1 truncate text-left text-[12px] text-foreground/88",children:Hp}),xe&&!j&&n.jsx("span",{className:"shrink-0 text-[12px] text-muted-foreground",children:xe}),n.jsx(cs,{size:12,className:ae("shrink-0 text-muted-foreground transition-transform",y&&"rotate-180")})]}),y&&n.jsxs("div",{className:"absolute left-0 right-0 top-full z-50 mt-1.5 overflow-hidden rounded-lg border bg-popover shadow-lg",children:[n.jsxs("div",{className:"px-2 h-10 flex items-center gap-2 border-b",children:[n.jsx(Wu,{size:14,className:"shrink-0 text-muted-foreground","aria-hidden":!0}),n.jsx("input",{type:"text",value:w,onChange:ne=>C(ne.target.value),placeholder:"Search pages and components...",className:"w-full bg-transparent text-sm outline-none placeholder:text-muted-foreground",autoFocus:!0})]}),n.jsx("div",{className:"p-1.5 border-b",children:n.jsxs("button",{type:"button",className:"flex w-full items-center gap-2.5 rounded-md px-3 py-2.5 text-left text-sm hover:bg-accent hover:text-accent-foreground",onMouseDown:ne=>{ne.preventDefault(),S(!1),C(""),k(void 0),R(!0)},children:[n.jsx(Dt,{size:16,className:"shrink-0 text-muted-foreground"}),n.jsx("span",{className:"flex-1 font-medium",children:"Create new page"})]})}),Be.length===0&&Pe.length===0?n.jsx("div",{className:"px-4 py-5 text-center text-xs text-muted-foreground",children:ve.length===0&&we.length===0?"No pages found in this site.":"No results match your search."}):n.jsxs("div",{className:"max-h-80 overflow-y-auto overscroll-contain",children:[Be.length>0&&n.jsx("div",{className:"p-1.5",children:Be.map(ne=>n.jsxs("button",{type:"button",className:"flex w-full items-center gap-3 rounded-md px-3 py-2.5 text-left text-sm hover:bg-accent hover:text-accent-foreground",onMouseDown:je=>{je.preventDefault(),S(!1),C(""),Ec(ne)},children:[n.jsx(Ni,{size:16,className:"shrink-0 text-muted-foreground"}),n.jsx("span",{className:"min-w-0 flex-1 truncate font-medium",children:ne.name}),n.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:ne.path})]},ne.key))}),Pe.length>0&&n.jsxs("div",{className:ae("p-1.5",Be.length>0&&"border-t"),children:[n.jsx("div",{className:"px-3 py-2 text-xs font-medium text-muted-foreground",children:"Global components"}),Pe.map(ne=>n.jsxs("button",{type:"button",className:"flex w-full items-center gap-3 rounded-md px-3 py-2.5 text-left text-sm hover:bg-accent hover:text-accent-foreground",onMouseDown:je=>{je.preventDefault(),S(!1),C(""),Up(ne)},children:[n.jsx(si,{size:16,className:"shrink-0 text-muted-foreground"}),n.jsx("span",{className:"min-w-0 flex-1 truncate font-medium",children:ne.name}),n.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:ne.resolveType.split("/").pop()?.replace(/\.tsx?$/,"")})]},ne.key))]})]})]})]})]}),n.jsxs("div",{className:ae("flex shrink-0 items-center gap-0.5",s==="code"&&"hidden"),children:[n.jsxs(Te,{children:[n.jsx(Ne,{asChild:!0,children:n.jsx(ie,{variant:"ghost",size:"icon",onClick:()=>{const ne=ge??Ye.previewUrl;ne&&window.open(ne,"_blank","noopener")},children:n.jsx(hi,{size:14})})}),n.jsx(Ee,{side:"bottom",children:"Open in new tab"})]}),n.jsxs(Wt,{children:[n.jsx(Vt,{asChild:!0,children:n.jsx(ie,{variant:"ghost",size:"icon",children:n.jsx(Hi,{size:14})})}),n.jsxs(Kt,{align:"end",className:"w-44",children:[n.jsx(Ue,{onClick:$p,children:"Hard Reload"}),n.jsx(Ue,{onClick:Fp,children:"Copy Current URL"}),te&&oe&&n.jsxs(n.Fragment,{children:[n.jsx(Cn,{}),ye&&n.jsxs(Ue,{onClick:()=>{z(!0),sn("cms")},children:[n.jsx(kr,{size:14}),"Edit SEO"]}),ye&&n.jsxs(Ue,{onClick:()=>{try{Z(Pc(ye)),sn("code")}catch{he.error("Invalid page block key")}},children:[n.jsx(no,{size:14}),"View JSON"]}),n.jsxs(Ue,{onClick:()=>q(!0),children:[n.jsx(kr,{size:14}),"Site SEO"]})]}),fe&&n.jsxs(n.Fragment,{children:[n.jsx(Cn,{}),n.jsxs(Ue,{onClick:()=>window.open(`vscode://file${fe}?windowId=_blank`),children:[n.jsx("img",{src:hd,alt:"VSCode",width:14,height:14}),"Open in VSCode"]}),n.jsxs(Ue,{onClick:()=>window.open(`cursor://file${fe}?windowId=_blank`),children:[n.jsx("img",{src:ud,alt:"Cursor",width:14,height:14}),"Open in Cursor"]})]})]})]})]})]}),s==="code"&&fe&&n.jsxs("div",{className:"ml-auto flex shrink-0 items-center gap-0.5",children:[n.jsxs(Te,{children:[n.jsx(Ne,{asChild:!0,children:n.jsx(ie,{variant:"ghost",size:"icon","aria-label":"Open in VSCode",onClick:()=>window.open(`vscode://file${fe}?windowId=_blank`),children:n.jsx("img",{src:hd,alt:"VSCode",width:14,height:14})})}),n.jsx(Ee,{side:"bottom",children:"Open in VSCode"})]}),n.jsxs(Te,{children:[n.jsx(Ne,{asChild:!0,children:n.jsx(ie,{variant:"ghost",size:"icon","aria-label":"Open in Cursor",onClick:()=>window.open(`cursor://file${fe}?windowId=_blank`),children:n.jsx("img",{src:ud,alt:"Cursor",width:14,height:14})})}),n.jsx(Ee,{side:"bottom",children:"Open in Cursor"})]})]})]}),n.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[c&&V&&e&&Y&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"shrink-0 border-r overflow-hidden",style:{width:p},children:n.jsx(D.Suspense,{fallback:n.jsx("div",{className:"h-full flex items-center justify-center",children:n.jsx(Oe,{size:20,className:"animate-spin text-muted-foreground"})}),children:n.jsx(Z0,{orgSlug:G.slug,virtualMcpId:Y,branch:e,previewReady:ee,previewUrl:V,currentPath:L,activePageBlockKey:ye,activeGlobalBlockKey:j?.key??null,externalSelectedIndex:j?null:h,onSaved:()=>{setTimeout(Mp,Do)},initialEditSeo:H,onExitSeo:()=>z(!1),onViewJsonFile:ne=>{try{Z(Pc(ne)),sn("code")}catch{he.error("Invalid page block key")}},onVariantPreviewOverride:Bp})})}),n.jsx("div",{className:"w-1 shrink-0 cursor-col-resize bg-transparent hover:bg-border transition-colors",onPointerDown:ne=>{_.current=!0,b.current=ne.clientX,x.current=p,ne.currentTarget.setPointerCapture(ne.pointerId)},onPointerMove:ne=>{if(!_.current)return;const je=ne.clientX-b.current;g(Math.max(240,Math.min(640,x.current+je)))},onPointerUp:()=>{_.current=!1}})]}),n.jsxs("div",{className:ae("flex-1 relative overflow-hidden",r!=="desktop"&&Ye.kind==="iframe"&&s!=="code"&&"flex justify-center bg-muted/30"),children:[ue&&n.jsx("div",{className:"absolute inset-0 z-30",children:n.jsx(Wr,{kind:"starting",progress:He,claimPhase:Ge})}),Ye.kind==="suspended"&&n.jsx("div",{className:"absolute inset-0 z-30",children:n.jsx(Wr,{kind:"suspended",onResume:$.resume})}),Vs==="visual"&&!a&&n.jsxs("div",{className:"absolute top-2 left-1/2 -translate-x-1/2 z-20 flex items-center gap-1.5 rounded-full border border-violet-400/40 bg-violet-500/90 px-3 py-1 text-xs font-medium text-white shadow-md backdrop-blur-sm pointer-events-none select-none",children:[n.jsx(Oc,{size:12}),"Click any element to ask the AI"]}),Vs==="visual"&&a&&n.jsx(L0,{element:a,onDismiss:()=>l(null)}),s==="code"&&mt&&Y&&e&&n.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:n.jsx(D.Suspense,{fallback:n.jsx("div",{className:"h-full flex items-center justify-center",children:n.jsx(Oe,{size:20,className:"animate-spin text-muted-foreground"})}),children:n.jsx(e2,{orgSlug:G.slug,virtualMcpId:Y,branch:e,openPath:K})})}),Ye.kind==="iframe"&&ge&&n.jsx("div",{className:ae("h-full transition-[width] duration-250 [transition-timing-function:var(--ease-in-out-cubic)]",r!=="desktop"&&s!=="code"&&"w-full max-w-full border-x border-border bg-background shadow-sm"),style:{width:r==="desktop"||s==="code"?"100%":`${t2[r]}px`},children:n.jsx("iframe",{ref:d,src:ge,className:ae("w-full h-full border-0",s==="code"&&"invisible"),title:"Dev Server Preview",tabIndex:c?-1:void 0,onLoad:()=>{if(Ke("vm_preview_loaded",{view_mode:s,vm_id:X?.sandboxHandle??null}),!j)try{const ne=d.current?.contentWindow?.location?.pathname;if(!ne)return;const je=pe.current;if(je!==null){pe.current=null,De(ne)===De(je)&&P(ne);return}P(ne)}catch{}s==="visual"&&tn(),s==="cms"&&Nc()}},Ye.previewUrl)})]})]}),n.jsx(E0,{open:E,onOpenChange:R,isPending:be.isPending,error:T,onSubmit:Wp}),W&&te&&oe&&n.jsx(D.Suspense,{fallback:null,children:n.jsx(Q0,{open:W,onOpenChange:q,orgSlug:G.slug,virtualMcpId:Y??"",branch:e??"",decofile:te,meta:oe,onSaved:()=>{setTimeout(()=>{const ne=d.current;if(ne)try{ne.contentWindow?.location.reload()}catch{const je=Se.current;je&&(ne.src=je)}},Do)},target:{kind:"site"}})})]})}function o2(t){const e=U.c(2),{virtualMcpId:s}=t,i=vs(s);if(!ti(i?.metadata)){let a;return e[0]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-2 text-center text-sm text-muted-foreground p-6",children:[n.jsx(zi,{size:24,className:"text-muted-foreground/60"}),n.jsx("div",{children:"No source to preview."}),n.jsx("div",{className:"text-xs text-muted-foreground/80",children:"Connect a GitHub repository from the Connections tab to enable Preview."})]}),e[0]=a):a=e[0],a}let o;return e[1]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx(r2,{}),e[1]=o):o=e[1],o}function a2(t){const e=U.c(8);let s,i;e[0]!==t?({className:s,...i}=t,e[0]=t,e[1]=s,e[2]=i):(s=e[1],i=e[2]);let r;e[3]!==s?(r=ae("grid gap-3",s),e[3]=s,e[4]=r):r=e[4];let o;return e[5]!==i||e[6]!==r?(o=n.jsx(n1,{"data-slot":"radio-group",className:r,...i}),e[5]=i,e[6]=r,e[7]=o):o=e[7],o}function fd(t){const e=U.c(9);let s,i;e[0]!==t?({className:s,...i}=t,e[0]=t,e[1]=s,e[2]=i):(s=e[1],i=e[2]);let r;e[3]!==s?(r=ae("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]=r):r=e[4];let o;e[5]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx(r1,{"data-slot":"radio-group-indicator",className:"relative flex items-center justify-center",children:n.jsx(w1,{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]!==i||e[7]!==r?(a=n.jsx(i1,{"data-slot":"radio-group-item",className:r,...i,children:o}),e[6]=i,e[7]=r,e[8]=a):a=e[8],a}function l2(t,e){if(!t||!e?.length)return t;const s=Object.fromEntries(Object.entries(t.properties??{}).filter(([i])=>!e.includes(i)));return Object.keys(s).length>0?{...t,properties:s}:t}function c2(t,e,s){return typeof t!="string"?null:l2(Us(t,e),s)}function lm(t,e,s){if(!e||typeof t!="string")return!1;const i=c2(t,e,s);return!!i&&Object.keys(i.properties??{}).length>0}function d2({orgSlug:t,virtualMcpId:e,branch:s}){const i=oi();return ai({mutationFn:async({blockKey:r})=>{const o=wu(r),a=await fetch(`/api/${t}/sandbox/${encodeURIComponent(e)}/${encodeURIComponent(s)}/unlink`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({path:o})});if(!a.ok){const l=await a.json().catch(()=>({}));throw new Error(l.error??`Delete failed (${a.status})`)}return a.json()},onMutate:async({blockKey:r})=>{const o=`${t}/${e}/${s}`,a=Et.decofile(o);await i.cancelQueries({queryKey:a});const l=i.getQueryData(a);return i.setQueryData(a,d=>{if(!d)return d;const{[r]:c,...h}=d;return h}),{previous:l,queryKey:a}},onError:(r,o,a)=>{a?.queryKey&&i.setQueryData(a.queryKey,a.previous)},onSuccess:()=>{const r=`${t}/${e}/${s}`;i.invalidateQueries({queryKey:Et.liveMeta(r)})}})}function go(t,e){return`${t}-${e}`}function cm(t,e){return`site/apps/${t}/${e}.ts`}function dm(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 h2(t){const e=t.match(/^([^-]+)-(.+)$/);return e?{vendor:e[1],app:e[2]}:null}function u2(t){return t==="local"?"Custom":"Installed"}function hm(t,e,s){const i=new Set([go(t,e),e].map(o=>o.toLowerCase())),r=cm(t,e);for(const[o,a]of Object.entries(s)){if(o.includes("/")||!a||typeof a!="object"||Array.isArray(a))continue;const l=a;if(i.has(o.toLowerCase())||l.__resolveType===r)return o}return null}function f2(t,e){const s=t.vendor.alias,i=t.name,r=hm(s,i,e);return{id:go(s,i),app:i,vendor:s,title:t.title||t.name,description:t.description,category:t.category??"Other",logo:t.logo||void 0,resolveType:cm(s,i),blockKey:r,installed:r!==null}}function m2(t,e,s){if(t===Ul)return null;const i=dm(t);if(!i)return null;const{vendor:r,app:o}=i,a=hm(r,o,s),l=fi(t,e);return{id:go(r,o),app:o,vendor:r,title:l.title??o,description:l.description??"",category:"Others",logo:l.logo??l.icon,resolveType:t,blockKey:a,installed:a!==null}}function p2(t,e,s){const i=e.__resolveType;if(typeof i!="string"||$r(t,e)||!mf(i))return null;const r=dm(i)??h2(t);if(!r)return null;const o=fi(i,s),{vendor:a,app:l}=r;return{id:go(a,l),app:l,vendor:a,title:o.title??zr(t,e,s),description:o.description??"",category:u2(a),logo:o.logo??o.icon,resolveType:i,blockKey:t,installed:!0}}function g2(t,e,s){const i=new Map;for(const o of t){const a=f2(o,s);i.set(a.id,a)}const r=e.manifest?.blocks?.apps??{};for(const o of Object.keys(r)){const a=m2(o,e,s);!a||i.has(a.id)||i.set(a.id,a)}for(const[o,a]of Object.entries(s)){if(o.includes("/")||!a||typeof a!="object"||Array.isArray(a))continue;const l=p2(o,a,e);!l||i.has(l.id)||i.set(l.id,l)}return[...i.values()].sort(_2)}function _2(t,e){return t.installed!==e.installed?t.installed?-1:1:t.title.localeCompare(e.title)}async function v2(){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 x2(t,e,s){const i=U.c(12),r=s?.enabled??!0;let o;i[0]===Symbol.for("react.memo_cache_sentinel")?(o=Et.decoApps(),i[0]=o):o=i[0];let a;i[1]!==r?(a={queryKey:o,queryFn:v2,staleTime:3e5,retry:1,enabled:r},i[1]=r,i[2]=a):a=i[2];const l=Es(a);let d;i[3]!==e||i[4]!==t||i[5]!==l.data?(d=t&&e?g2(l.data??[],t,e):[],i[3]=e,i[4]=t,i[5]=l.data,i[6]=d):d=i[6];const c=d,h=l.isLoading&&!l.isError;let u;return i[7]!==c||i[8]!==l.isError||i[9]!==l.refetch||i[10]!==h?(u={catalog:c,isLoading:h,isError:l.isError,refetch:l.refetch},i[7]=c,i[8]=l.isError,i[9]=l.refetch,i[10]=h,i[11]=u):u=i[11],u}function SE(t,e,s,i,r){const o={...t[e]};if(r.length>1){const a=o.sections,l=[...a?.variants??[]];l[i]&&(l[i]={...l[i],value:s}),o.sections={...a,variants:l}}else o.sections=s;return o}function wE(t){return structuredClone(t)}function CE(t){return!t.isSavedBlock&&!t.isMultivariate&&!t.isHidden}function b2(t){const e=t.replace(/[^A-Za-z0-9_-]/g,"");return/^[A-Za-z]/.test(e)?e:e?`Block${e}`:""}function y2(t,e){const s=t.trim();return s?s.includes("/")?"Block name cannot contain slashes.":Object.hasOwn(e,s)?"A block with this name already exists.":/^[A-Za-z][A-Za-z0-9_-]*$/.test(s)?null:"Use letters, numbers, hyphens, or underscores. Must start with a letter.":"Block name is required."}function S2(t){return(e,s)=>{r_(e),t(e,s)}}const w2=new Set(["http:","https:","mailto:","tel:","ftp:"]);function C2(t){if(t.startsWith("/")||t.startsWith(".")||t.startsWith("#"))return!0;try{const e=new URL(t,"https://placeholder.invalid");return w2.has(e.protocol)}catch{return!1}}function ys(t){const e=U.c(8),{active:s,label:i,onClick:r,children:o}=t,a=s?"bg-accent text-accent-foreground":"text-muted-foreground hover:bg-muted hover:text-foreground";let l;e[0]!==a?(l=ae("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 d;return e[2]!==s||e[3]!==o||e[4]!==i||e[5]!==r||e[6]!==l?(d=n.jsx("button",{type:"button","aria-label":i,"aria-pressed":s,onMouseDown:k2,onClick:r,className:l,children:o}),e[2]=s,e[3]=o,e[4]=i,e[5]=r,e[6]=l,e[7]=d):d=e[7],d}function k2(t){return t.preventDefault()}function j2({schema:t,value:e,onChange:s,path:i,label:r}){const o=typeof e=="string"?e:"",a=D.useRef(s);a.current=s;const l=Ng({extensions:[Eg.configure({heading:{levels:[1,2,3]}})],content:o||"",editorProps:{attributes:{class:ae("prose prose-sm dark:prose-invert max-w-none focus:outline-none","min-h-[80px] px-3 py-2")}},onUpdate:({editor:d})=>{const c=d.getHTML();a.current(c==="<p></p>"?"":c)}});return l?n.jsxs("div",{className:"space-y-2",children:[n.jsxs("div",{className:"space-y-0.5",children:[n.jsx(Ve,{htmlFor:i,children:r}),t.description&&n.jsx("p",{className:"text-xs leading-normal text-muted-foreground",children:t.description})]}),n.jsxs("div",{className:"overflow-hidden rounded-md border border-input",children:[n.jsxs("div",{className:"flex flex-wrap items-center gap-0.5 border-b border-border/60 bg-muted/30 px-1.5 py-1",children:[n.jsx(ys,{active:l.isActive("bold"),label:"Bold",onClick:()=>l.chain().focus().toggleBold().run(),children:n.jsx(I_,{size:14})}),n.jsx(ys,{active:l.isActive("italic"),label:"Italic",onClick:()=>l.chain().focus().toggleItalic().run(),children:n.jsx(L_,{size:14})}),n.jsx(ys,{active:l.isActive("underline"),label:"Underline",onClick:()=>l.chain().focus().toggleUnderline().run(),children:n.jsx(O_,{size:14})}),n.jsx(ys,{active:l.isActive("strike"),label:"Strikethrough",onClick:()=>l.chain().focus().toggleStrike().run(),children:n.jsx(B_,{size:14})}),n.jsx("div",{className:"mx-0.5 h-4 w-px bg-border"}),n.jsx(ys,{active:l.isActive("heading",{level:1}),label:"Heading 1",onClick:()=>l.chain().focus().toggleHeading({level:1}).run(),children:n.jsx(M_,{size:14})}),n.jsx(ys,{active:l.isActive("heading",{level:2}),label:"Heading 2",onClick:()=>l.chain().focus().toggleHeading({level:2}).run(),children:n.jsx($_,{size:14})}),n.jsx("div",{className:"mx-0.5 h-4 w-px bg-border"}),n.jsx(ys,{active:l.isActive("bulletList"),label:"Bullet list",onClick:()=>l.chain().focus().toggleBulletList().run(),children:n.jsx(y1,{size:14})}),n.jsx(ys,{active:l.isActive("orderedList"),label:"Ordered list",onClick:()=>l.chain().focus().toggleOrderedList().run(),children:n.jsx("span",{className:"text-[11px] font-semibold leading-none",children:"1."})}),n.jsx("div",{className:"mx-0.5 h-4 w-px bg-border"}),n.jsx(ys,{active:l.isActive("link"),label:"Link",onClick:()=>{const d=l.getAttributes("link").href,c=window.prompt("Link URL",d??"https://");c!==null&&(c===""?l.chain().focus().unsetLink().run():C2(c)&&l.chain().focus().setLink({href:c}).run())},children:n.jsx(_g,{size:14})})]}),n.jsx(Tg,{editor:l})]})]}):null}const Ci=t=>String(t).padStart(2,"0"),N2="1900-01-01",E2="2099-12-31",T2="1900-01-01T00:00",A2="2099-12-31T23:59";function R2(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()}-${Ci(s.getUTCMonth()+1)}-${Ci(s.getUTCDate())}`}function P2(t){return!t||!/^\d{4}-\d{2}-\d{2}$/.test(t)?"":`${t}T00:00:00.000Z`}function D2(t){if(!t)return"";const e=new Date(t);return Number.isNaN(e.getTime())?"":`${e.getFullYear()}-${Ci(e.getMonth()+1)}-${Ci(e.getDate())}T${Ci(e.getHours())}:${Ci(e.getMinutes())}`}function I2(t){if(!t)return"";const e=new Date(t);return Number.isNaN(e.getTime())?"":e.toISOString()}function L2(t){const e=U.c(29),{id:s,withTime:i,value:r,onChange:o}=t,[a,l]=D.useState(!1);let d;e[0]!==r||e[1]!==i?(d=i?D2(r):R2(r),e[0]=r,e[1]=i,e[2]=d):d=e[2];const c=d;let h;e[3]!==o||e[4]!==i?(h=E=>{o(i?I2(E.target.value):P2(E.target.value))},e[3]=o,e[4]=i,e[5]=h):h=e[5];const u=h;let f;if(e[6]!==r){const E=r?new Date(r):null;f=E&&!Number.isNaN(E.getTime())?E:null,e[6]=r,e[7]=f}else f=e[7];const m=f;let p;e[8]!==o||e[9]!==m||e[10]!==i?(p=E=>{E&&(i&&m?E.setHours(m.getHours(),m.getMinutes(),0,0):E.setHours(0,0,0,0),o(E.toISOString()),l(!1))},e[8]=o,e[9]=m,e[10]=i,e[11]=p):p=e[11];const g=p,_=i?"datetime-local":"date",b=i?T2:N2,x=i?A2:E2;let v;e[12]!==u||e[13]!==s||e[14]!==c||e[15]!==_||e[16]!==b||e[17]!==x?(v=n.jsx(ze,{id:s,type:_,min:b,max:x,value:c,onChange:u,className:"h-10 flex-1 [&::-webkit-calendar-picker-indicator]:hidden [&::-webkit-calendar-picker-indicator]:opacity-0"}),e[12]=u,e[13]=s,e[14]=c,e[15]=_,e[16]=b,e[17]=x,e[18]=v):v=e[18];let y;e[19]===Symbol.for("react.memo_cache_sentinel")?(y=n.jsx(Rs,{asChild:!0,children:n.jsx(ie,{type:"button",variant:"outline",size:"icon",className:"h-10 w-10 shrink-0","aria-label":"Open calendar",children:n.jsx(Eu,{className:"h-4 w-4"})})}),e[19]=y):y=e[19];const S=m??void 0;let w;e[20]!==g||e[21]!==S?(w=n.jsx(Ps,{className:"w-auto p-0",align:"end",children:n.jsx(k1,{mode:"single",selected:S,onSelect:g,initialFocus:!0})}),e[20]=g,e[21]=S,e[22]=w):w=e[22];let C;e[23]!==a||e[24]!==w?(C=n.jsxs(As,{open:a,onOpenChange:l,children:[y,w]}),e[23]=a,e[24]=w,e[25]=C):C=e[25];let N;return e[26]!==C||e[27]!==v?(N=n.jsxs("div",{className:"flex gap-1",children:[v,C]}),e[26]=C,e[27]=v,e[28]=N):N=e[28],N}function nr(t){const e=U.c(8),{htmlFor:s,label:i,description:r}=t;let o;e[0]!==s||e[1]!==i?(o=n.jsx(Ve,{htmlFor:s,children:i}),e[0]=s,e[1]=i,e[2]=o):o=e[2];let a;e[3]!==r?(a=r&&n.jsx("p",{className:"text-xs leading-normal text-muted-foreground",children:r}),e[3]=r,e[4]=a):a=e[4];let l;return e[5]!==o||e[6]!==a?(l=n.jsxs("div",{className:"space-y-0.5",children:[o,a]}),e[5]=o,e[6]=a,e[7]=l):l=e[7],l}function rr(t){const e=U.c(67),{schema:s,value:i,onChange:r,path:o,label:a}=t,l=typeof i=="string"?i:"",d=s.format;if(d==="rich-text"||d==="rich-text-inline"||d==="html"){let g;return e[0]!==a||e[1]!==r||e[2]!==o||e[3]!==s||e[4]!==i?(g=n.jsx(j2,{schema:s,value:i,onChange:r,path:o,label:a}),e[0]=a,e[1]=r,e[2]=o,e[3]=s,e[4]=i,e[5]=g):g=e[5],g}if(d==="textarea"||d==="markdown"){let g;e[6]!==a||e[7]!==o||e[8]!==s.description?(g=n.jsx(nr,{htmlFor:o,label:a,description:s.description}),e[6]=a,e[7]=o,e[8]=s.description,e[9]=g):g=e[9];let _;e[10]!==r?(_=v=>r(v.target.value),e[10]=r,e[11]=_):_=e[11];let b;e[12]!==o||e[13]!==l||e[14]!==_?(b=n.jsx(Ln,{id:o,value:l,onChange:_,rows:4}),e[12]=o,e[13]=l,e[14]=_,e[15]=b):b=e[15];let x;return e[16]!==g||e[17]!==b?(x=n.jsxs("div",{className:"space-y-2",children:[g,b]}),e[16]=g,e[17]=b,e[18]=x):x=e[18],x}if(d==="date"||d==="date-time"){let g;e[19]!==a||e[20]!==o||e[21]!==s.description?(g=n.jsx(nr,{htmlFor:o,label:a,description:s.description}),e[19]=a,e[20]=o,e[21]=s.description,e[22]=g):g=e[22];const _=d==="date-time";let b;e[23]!==r||e[24]!==o||e[25]!==l||e[26]!==_?(b=n.jsx(L2,{id:o,withTime:_,value:l,onChange:r}),e[23]=r,e[24]=o,e[25]=l,e[26]=_,e[27]=b):b=e[27];let x;return e[28]!==g||e[29]!==b?(x=n.jsxs("div",{className:"space-y-2",children:[g,b]}),e[28]=g,e[29]=b,e[30]=x):x=e[30],x}if(d==="color-input"){let g;e[31]!==a||e[32]!==o||e[33]!==s.description?(g=n.jsx(nr,{htmlFor:o,label:a,description:s.description}),e[31]=a,e[32]=o,e[33]=s.description,e[34]=g):g=e[34];const _=l||"#000000";let b;e[35]!==r?(b=C=>r(C.target.value),e[35]=r,e[36]=b):b=e[36];let x;e[37]!==_||e[38]!==b?(x=n.jsx("input",{type:"color",value:_,onChange:b,className:"h-10 w-10 cursor-pointer rounded-lg border border-border bg-background p-1"}),e[37]=_,e[38]=b,e[39]=x):x=e[39];let v;e[40]!==r?(v=C=>r(C.target.value),e[40]=r,e[41]=v):v=e[41];let y;e[42]!==o||e[43]!==l||e[44]!==v?(y=n.jsx(ze,{id:o,value:l,onChange:v,placeholder:"#000000",className:"h-10 flex-1"}),e[42]=o,e[43]=l,e[44]=v,e[45]=y):y=e[45];let S;e[46]!==x||e[47]!==y?(S=n.jsxs("div",{className:"flex items-center gap-2",children:[x,y]}),e[46]=x,e[47]=y,e[48]=S):S=e[48];let w;return e[49]!==g||e[50]!==S?(w=n.jsxs("div",{className:"space-y-2",children:[g,S]}),e[49]=g,e[50]=S,e[51]=w):w=e[51],w}let c;e[52]!==a||e[53]!==o||e[54]!==s.description?(c=n.jsx(nr,{htmlFor:o,label:a,description:s.description}),e[52]=a,e[53]=o,e[54]=s.description,e[55]=c):c=e[55];const h=d==="url"?"url":"text";let u;e[56]!==r?(u=g=>r(g.target.value),e[56]=r,e[57]=u):u=e[57];const f=s.default!=null?String(s.default):void 0;let m;e[58]!==o||e[59]!==l||e[60]!==h||e[61]!==u||e[62]!==f?(m=n.jsx(ze,{id:o,type:h,value:l,onChange:u,placeholder:f,className:"h-10"}),e[58]=o,e[59]=l,e[60]=h,e[61]=u,e[62]=f,e[63]=m):m=e[63];let p;return e[64]!==c||e[65]!==m?(p=n.jsxs("div",{className:"space-y-2",children:[c,m]}),e[64]=c,e[65]=m,e[66]=p):p=e[66],p}function O2(t){const e=U.c(17),{schema:s,value:i,onChange:r,path:o,label:a}=t,l=typeof i=="number"?i:"";let d;e[0]!==a||e[1]!==o?(d=n.jsx(Ve,{htmlFor:o,children:a}),e[0]=a,e[1]=o,e[2]=d):d=e[2];let c;e[3]!==s.description?(c=s.description&&n.jsx("p",{className:"text-xs leading-normal text-muted-foreground",children:s.description}),e[3]=s.description,e[4]=c):c=e[4];let h;e[5]!==d||e[6]!==c?(h=n.jsxs("div",{className:"space-y-0.5",children:[d,c]}),e[5]=d,e[6]=c,e[7]=h):h=e[7];let u;e[8]!==r?(u=p=>{const g=p.target.value;r(g===""?void 0:Number(g))},e[8]=r,e[9]=u):u=e[9];let f;e[10]!==l||e[11]!==o||e[12]!==u?(f=n.jsx(ze,{id:o,type:"number",value:l,onChange:u,className:"h-10"}),e[10]=l,e[11]=o,e[12]=u,e[13]=f):f=e[13];let m;return e[14]!==h||e[15]!==f?(m=n.jsxs("div",{className:"space-y-2",children:[h,f]}),e[14]=h,e[15]=f,e[16]=m):m=e[16],m}function B2(t){const e=U.c(17),{value:s,onChange:i,path:r,label:o,schema:a}=t,l=typeof s=="boolean"?s:!1;let d;e[0]!==o||e[1]!==r?(d=n.jsx(Ve,{htmlFor:r,children:o}),e[0]=o,e[1]=r,e[2]=d):d=e[2];let c;e[3]!==a.description?(c=a.description&&n.jsx("p",{className:"text-xs leading-normal text-muted-foreground",children:a.description}),e[3]=a.description,e[4]=c):c=e[4];let h;e[5]!==d||e[6]!==c?(h=n.jsxs("div",{className:"space-y-0.5",children:[d,c]}),e[5]=d,e[6]=c,e[7]=h):h=e[7];let u;e[8]!==i?(u=p=>i(p),e[8]=i,e[9]=u):u=e[9];let f;e[10]!==l||e[11]!==r||e[12]!==u?(f=n.jsx(On,{id:r,checked:l,onCheckedChange:u}),e[10]=l,e[11]=r,e[12]=u,e[13]=f):f=e[13];let m;return e[14]!==h||e[15]!==f?(m=n.jsxs("div",{className:"flex items-center justify-between gap-3",children:[h,f]}),e[14]=h,e[15]=f,e[16]=m):m=e[16],m}const rc="__enum_empty__";function oc(t){return t===""?rc:String(t)}function M2(t,e){if(t===rc)return"";const s=e.find(i=>oc(i)===t);return s!==void 0?s:t}function $2(t,e){return t==null?e.some(s=>s==="")?rc:void 0:oc(t)}function z2(t){return t===""?"":String(t)}function F2(t){const e=U.c(28),{schema:s,value:i,onChange:r,path:o,label:a}=t;let l;e[0]!==s.enum?(l=s.enum??[],e[0]=s.enum,e[1]=l):l=e[1];const d=l;let c;e[2]!==d||e[3]!==i?(c=$2(i,d),e[2]=d,e[3]=i,e[4]=c):c=e[4];const h=c;let u;e[5]!==a||e[6]!==o?(u=n.jsx(Ve,{htmlFor:o,children:a}),e[5]=a,e[6]=o,e[7]=u):u=e[7];let f;e[8]!==s.description?(f=s.description&&n.jsx("p",{className:"text-xs leading-normal text-muted-foreground",children:s.description}),e[8]=s.description,e[9]=f):f=e[9];let m;e[10]!==u||e[11]!==f?(m=n.jsxs("div",{className:"space-y-0.5",children:[u,f]}),e[10]=u,e[11]=f,e[12]=m):m=e[12];let p;e[13]!==r||e[14]!==d?(p=y=>r(M2(y,d)),e[13]=r,e[14]=d,e[15]=p):p=e[15];let g;e[16]===Symbol.for("react.memo_cache_sentinel")?(g=n.jsx(kt,{className:"h-10",children:n.jsx(Rt,{placeholder:"Select..."})}),e[16]=g):g=e[16];let _;e[17]!==d?(_=d.map(H2),e[17]=d,e[18]=_):_=e[18];let b;e[19]!==_?(b=n.jsx(jt,{children:_}),e[19]=_,e[20]=b):b=e[20];let x;e[21]!==h||e[22]!==p||e[23]!==b?(x=n.jsxs(Nt,{value:h,onValueChange:p,children:[g,b]}),e[21]=h,e[22]=p,e[23]=b,e[24]=x):x=e[24];let v;return e[25]!==x||e[26]!==m?(v=n.jsxs("div",{className:"space-y-2",children:[m,x]}),e[25]=x,e[26]=m,e[27]=v):v=e[27],v}function H2(t){const e=oc(t);return n.jsx(tt,{value:e,children:z2(t)},e)}function ac(t){const e=t.__resolveType;if(typeof e!="string")return null;if(Tt(e)){const i=t.section?.__resolveType;return typeof i=="string"?i:e}return e}function U2(t){return t.includes("flags/multivariate")}function W2(t){return ut(t)}function V2(t,e){const s=[...t],i=new Set(s.map(o=>o.resolveType)),r=(o,a)=>{!o||i.has(o)||(i.add(o),s.push({resolveType:o,title:a??W2(o)}))};if(e.savedBlockKey&&r(e.savedBlockKey,e.savedBlockKey),e.editorValue&&typeof e.editorValue=="object"&&!Array.isArray(e.editorValue)){const o=ac(e.editorValue);o?.includes("/")&&r(o)}return s}function K2(t,e,s){const i=e[0]?.resolveType??"";if(s)return s;if(!t||typeof t!="object"||Array.isArray(t))return i;const r=t,o=r.__resolveType;if(typeof o=="string"){if(Ns(o)){const u=e.find(f=>f.resolveType===o);return u?u.resolveType:o}const c=e.find(u=>Kc(u.resolveType,o));if(c)return c.resolveType;const h=e.find(u=>u.resolveType===o);if(h)return h.resolveType;if(o.includes("/"))return o}const a=typeof r.type=="string"?r.type:void 0;if(a){const c=e.find(h=>h.discriminatorValue===a||h.resolveType===a||Kc(h.resolveType,a));if(c)return c.resolveType}let l=i,d=-1;for(const c of e){if(!c.schema?.properties)continue;const u=Object.keys(c.schema.properties).filter(f=>!f.startsWith("__")&&f!=="@type"&&f!=="action"&&f!=="alt").filter(f=>r[f]!==void 0).length;u>0&&u>d&&(d=u,l=c.resolveType)}return d>0,l}function md(t,e,s){if(!t||typeof t!="object"||Array.isArray(t))return s??null;const i=ac(t);if(!i)return s??null;if(!e)return i.includes("/")?null:s??null;const r=Us(i,e);return r||(i.includes("/")?null:s??null)}function q2(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 um(t){if(!t||typeof t!="object"||Array.isArray(t))return null;const e=t;if(typeof e.__resolveType!="string"||!Tt(e.__resolveType))return null;const s=e.section;return!s||typeof s!="object"||Array.isArray(s)?null:s}function G2(t,e){if(e)return!0;if(!t||typeof t!="object"||Array.isArray(t))return!1;const s=t,i=ac(s);return i&&U2(i)?Array.isArray(s.variants)&&s.variants.length>0:Object.keys(s).some(r=>!r.startsWith("__")&&r!=="@type")}function lc(t){if(typeof t=="string")return t;if(!t||typeof t!="object")return"";const e=t;if(Array.isArray(e.variants)){const s=e.variants,i=s.find(o=>o.rule?.__resolveType?.includes("always"));if(typeof i?.value=="string")return i.value;const r=s.find(o=>typeof o.value=="string");if(r)return r.value}return typeof e.src=="string"?e.src:typeof e.url=="string"?e.url:typeof e.value=="string"?e.value:""}function Y2(t){if(t?.trim())try{const e=new URL(t);return e.protocol!=="https:"?void 0:e.href}catch{return}}function X2(t){if(Array.isArray(t.variants)){const e=t.variants,s=e.find(r=>r.rule?.__resolveType?.includes("always"));if(typeof s?.value=="string")return s.value;const i=e.find(r=>typeof r.value=="string");if(i)return i.value}if(typeof t.src=="string")return t.src;if(typeof t.url=="string")return t.url;if(typeof t.value=="string")return t.value}function fm(t){if(typeof t=="string"||t==null||typeof t!="object")return t;if(Array.isArray(t))return t.map(fm);const e=t;return e.__resolveType?X2(e)??t:mm(e)}function mm(t){const e={};for(const[s,i]of Object.entries(t))e[s]=fm(i);return e}function J2(t,e){return e.split(".").reduce((s,i)=>{if(!(s==null||typeof s!="object"))return s[i]},t)}function pm(t){return t==null?"":Array.isArray(t)?t.map(pm).filter(Boolean).join(","):typeof t=="object"?"":String(t)}function cc(t,e){if(!t.includes("{"))return;const s=mm(e);return t.replace(/\{\{\{([^}]+)\}\}\}|\{\{([^}]+)\}\}/g,(r,o,a)=>{const l=(o??a??"").trim();return pm(J2(s,l))}).trim()||void 0}function Z2(t){return t.replace(/<[^>]*>/g,"").trim()}function Q2(t,e){if(e.includes("{"))return cc(e,t);const s=t[e];if(typeof s=="string"&&s)return s;if(Array.isArray(s)){const i=s.map(r=>r==null?"":String(r)).filter(Boolean).join(",");if(i)return i}}function Xs(t,e,s){if(typeof t=="string")return t.trim()?t:`Item ${e+1}`;if(typeof t=="number"||typeof t=="boolean")return String(t);if(t&&typeof t=="object"&&!Array.isArray(t)){let i=t;const r=um(i);if(r&&(i=r),s?.titleBy){const a=Q2(i,s.titleBy);if(a)return a}for(const a of["name","label","title","alt","text","href","id","key"]){const l=i[a];if(typeof l=="string"&&l.trim()){const d=s?.properties?.[a]?.format;if(d==="rich-text"||d==="html"){const c=Z2(l);if(c)return c;continue}return l}if(Array.isArray(l)){const d=l.map(c=>c==null?"":String(c)).filter(Boolean).join(",");if(d)return d}}const o=i.__resolveType;if(typeof o=="string"&&o)return ut(o);if(s?.title){const a=cc(s.title,i);if(a)return a;if(!s.title.includes("{"))return s.title}}return`Item ${e+1}`}function eS(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 pd(t,e){if(!t||typeof t!="object"||Array.isArray(t))return;const s=eS(e);if(!s)return;const i=cc(s,t);if(!i)return;const r=lc(i)||i;return Y2(r)}function gm(t){return t.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[_-]/g," ").replace(/^\w/,e=>e.toUpperCase())}function ii(t){return t.normalize("NFC").trim()}function St(t,e){return ii(t)===ii(e)}function gd(t,e){return ii(t).replace(/\s+/g,"").toLowerCase()===ii(e).replace(/\s+/g,"").toLowerCase()}function or(t,e,s){const i=ii(s);if(t.some(a=>St(a,i)||St(a,s)))return t;const r=[...t];return r.some(a=>St(a,e))||r.push(e),r.push(s),r}function tS(t,e,s){if(s.length===0)return s;const i=jn(t,e),r=s[0];return St(r,i)||St(r,t)?s.slice(1):s}function jn(t,e){return e.title??gm(t)}function kE(t,e){return e<=0?[]:t.slice(0,e)}function Lo(t,e){const s=ii(e);return t.findIndex(i=>ii(i)===s)}function _d(t,e){return t.type==="array"&&t.items||mo(t)?!0:Array.isArray(e)}function sS(t){return t!=null&&typeof t=="object"&&!Array.isArray(t)?t:{}}function zn(t,e,s,i){if(i.length===0)return null;const r=i[0];for(const a of t){const l=e[a];if(!l||!_d(l,s[a]))continue;const d=jn(a,l);if(St(r,d)||St(r,a)||i.some(c=>St(c,d)||St(c,a)))return a}for(const a of t){const l=e[a];if(!l||!_d(l,s[a]))continue;const d=s[a];if(!Array.isArray(d))continue;const c=l.items;for(let h=0;h<d.length;h++){const u=Xs(d[h],h,c);if(St(u,r))return a}}for(const a of t){const l=e[a];if(l?.type!=="object"||!l.properties)continue;const d=Object.keys(l.properties),c=sS(s[a]),h=jn(a,l);if(zn(d,l.properties,c,i)||(St(r,h)||St(r,a))&&zn(d,l.properties,c,i.slice(1)))return a}let o=null;for(const a of t){const l=e[a];if(l?.type!=="block-ref")continue;const d=jn(a,l);if(!(r!==d&&r!==a)){if(i.length>1){const c=s[a];if(c&&typeof c=="object"&&!Array.isArray(c)){const h=i[1];if(Object.keys(c).some(f=>!f.startsWith("__")&&(gd(gm(f),h)||gd(f,h))))return a}}o||(o=a)}}return o||null}function iS(t,e,s,i){return zn(t,e,s,i)}function nS(t,e,s,i,r){if(r.length===0||!s.properties)return!1;const o=Object.keys(s.properties);if(zn(o,s.properties,i,r))return!0;const a=r[0];return!St(a,e)&&!St(a,t)?!1:r.length>1||zn(o,s.properties,i,r.slice(1))!==null}function rS(t,e,s,i){if(e.length===0)return null;for(let o=0;o<e.length;o++){const a=e[o],l=s.findIndex((d,c)=>St(Xs(d,c,i),a));if(l>=0)return{index:l,innerPath:e.slice(o+1)}}const r=e.findIndex(o=>St(o,t));if(r>=0&&e.length>r+1){const o=e[r+1],a=s.findIndex((l,d)=>St(Xs(l,d,i),o));if(a>=0)return{index:a,innerPath:e.slice(r+2)}}return null}function Oo(t){return t.includes("/sections/")||t.includes("multivariate/section")||t===Yn}function oS(t){if(t.type==="block-ref"&&t.anyOfRefs?.length)return t.anyOfRefs.some(s=>Oo(s.resolveType));if(t.anyOfRefs?.length)return t.anyOfRefs.some(s=>Oo(s.resolveType));const e=t.properties?.__resolveType;return e?.type==="block-ref"&&e.anyOfRefs?.length?e.anyOfRefs.some(s=>Oo(s.resolveType)):!1}function aS(t,e){if(e==="global"||e==="sections"||mo(t))return!0;const s=t.type==="array"?t.items:void 0;return s?oS(s):!1}function vd(t){return Array.from({length:t},(e,s)=>({id:crypto.randomUUID(),index:s}))}function lS(t,e,s,i,r){if(e?.type==="object"&&e.properties&&Object.keys(e.properties).length>0||e?.type==="block-ref"&&e.anyOfRefs?.length)return e;if(t!=null&&typeof t=="object"&&!Array.isArray(t)){const o=t.__resolveType;if(typeof o=="string"&&s){const a=Us(o,s);if(a?.properties&&Object.keys(a.properties).length>0)return a}}if(s&&i&&r){const a=Us(i,s)?.properties?.[r]?.items;if(a?.properties&&Object.keys(a.properties).length>0)return{...a,titleBy:a.titleBy??e?.titleBy}}return e}function cS(t){const e=t.split(".").filter(s=>!/^\d+$/.test(s));return e[e.length-1]??t}function _m(t){return t.map((e,s)=>({...e,index:s}))}function dS(t,e){if(e===t.length)return t;if(e<t.length)return _m(t.slice(0,e));const s=Array.from({length:e-t.length},(i,r)=>({id:crypto.randomUUID(),index:t.length+r}));return[...t,...s]}function hS(t){const e=U.c(8),{labelText:s,imageSrc:i}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=n.jsx(bl,{className:"size-3.5 shrink-0 text-muted-foreground/40"}),e[0]=r):r=e[0];let o;e[1]!==i?(o=i&&n.jsx("img",{src:i,alt:"",referrerPolicy:"no-referrer",className:"h-12 max-w-[100px] shrink-0 rounded object-cover"}),e[1]=i,e[2]=o):o=e[2];let a;e[3]!==s?(a=n.jsx("span",{className:"min-w-0 truncate",children:s}),e[3]=s,e[4]=a):a=e[4];let l;return e[5]!==o||e[6]!==a?(l=n.jsxs(n.Fragment,{children:[r,n.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2.5 text-sm",children:[o,a]})]}),e[5]=o,e[6]=a,e[7]=l):l=e[7],l}function uS(t){const e=U.c(37),{sortableId:s,labelText:i,imageSrc:r,onOpen:o,onRemove:a}=t;let l;e[0]!==s?(l={id:s,animateLayoutChanges:pS},e[0]=s,e[1]=l):l=e[1];const{attributes:d,listeners:c,setNodeRef:h,transform:u,isDragging:f}=du(l);let m;e[2]!==u?(m=hu.Transform.toString(u?{...u,x:0}:null),e[2]=u,e[3]=m):m=e[3];const p=f?0:void 0;let g;e[4]!==m||e[5]!==p?(g={transform:m,opacity:p},e[4]=m,e[5]=p,e[6]=g):g=e[6];const _=g;let b;e[7]!==o?(b=I=>{(I.key==="Enter"||I.key===" ")&&(I.preventDefault(),o())},e[7]=o,e[8]=b):b=e[8];const x=f?"cursor-grabbing":"cursor-pointer";let v;e[9]!==x?(v=ae("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",x),e[9]=x,e[10]=v):v=e[10];let y;e[11]===Symbol.for("react.memo_cache_sentinel")?(y=n.jsx(bl,{className:"size-3.5 shrink-0 text-muted-foreground/40"}),e[11]=y):y=e[11];let S;e[12]!==r?(S=r&&n.jsx("img",{src:r,alt:"",referrerPolicy:"no-referrer",className:"h-12 max-w-[100px] shrink-0 rounded object-cover"}),e[12]=r,e[13]=S):S=e[13];let w;e[14]!==i?(w=n.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:i}),e[14]=i,e[15]=w):w=e[15];const C=`Open actions for ${i}`;let N;e[16]===Symbol.for("react.memo_cache_sentinel")?(N=n.jsx(Hi,{size:14}),e[16]=N):N=e[16];let E;e[17]!==C?(E=n.jsx(Vt,{asChild:!0,children:n.jsx(ie,{type:"button",variant:"ghost",size:"icon","aria-label":C,className:"size-6 shrink-0 opacity-0 transition-opacity group-hover:opacity-100",onClick:mS,onPointerDown:fS,children:N})}),e[17]=C,e[18]=E):E=e[18];let R;e[19]===Symbol.for("react.memo_cache_sentinel")?(R=n.jsx(es,{size:14}),e[19]=R):R=e[19];let T;e[20]!==a?(T=n.jsx(Kt,{align:"end",children:n.jsxs(Ue,{className:"text-destructive focus:text-destructive",onClick:a,children:[R,"Delete"]})}),e[20]=a,e[21]=T):T=e[21];let k;e[22]!==E||e[23]!==T?(k=n.jsxs(Wt,{children:[E,T]}),e[22]=E,e[23]=T,e[24]=k):k=e[24];let j;return e[25]!==d||e[26]!==i||e[27]!==c||e[28]!==o||e[29]!==h||e[30]!==_||e[31]!==w||e[32]!==k||e[33]!==b||e[34]!==v||e[35]!==S?(j=n.jsxs("div",{ref:h,style:_,...d,...c,role:"button",tabIndex:0,onClick:o,onKeyDown:b,className:v,title:i,children:[y,S,w,k]}),e[25]=d,e[26]=i,e[27]=c,e[28]=o,e[29]=h,e[30]=_,e[31]=w,e[32]=k,e[33]=b,e[34]=v,e[35]=S,e[36]=j):j=e[36],j}function fS(t){return t.stopPropagation()}function mS(t){return t.stopPropagation()}function pS(){return!1}function ar(t){const e=U.c(24),{schema:s,value:i,onChange:r,path:o,label:a,breadcrumbPath:l,onBreadcrumbChange:d,meta:c,decofile:h,onSaveReferencedBlock:u,containerResolveType:f,previewBaseUrl:m,onAddSectionItem:p,onRequestAddSection:g,sandbox:_}=t,b=l===void 0?[]:l,x=Array.isArray(i)?i:[],v=s.items,y=cS(o),S=aS(s,y),w=rS(a,b,x,v),C=w?.index??null,[N,E]=D.useState(()=>vd(x.length)),[R,T]=D.useState(null),[k,j]=D.useState(o),[I,A]=D.useState(x.length),O=D.useRef(!1);k!==o?(j(o),A(x.length),E(vd(x.length))):I!==x.length&&(A(x.length),E(xe=>dS(xe,x.length)));let L;e[0]!==v?(L=(xe,ye)=>Xs(xe,ye,v),e[0]=v,e[1]=L):L=e[1];const P=L,B=xe=>{if(O.current)return;const ye=P(x[xe],xe);d?.(or(b,a,ye))},F=xe=>{const ye=[...x,xe];r(ye);const Ie=ye.length-1,Le=Xs(xe,Ie,v);d?.(or(b,a,Le))},H=()=>{const xe=v?.type,ye=v?.default!==void 0?v.default:xe==="object"?{}:xe==="block-ref"?(()=>{const st=v?.anyOfRefs?.[0]?.resolveType;return typeof st!="string"||Mr(st)?{}:{__resolveType:st}})():xe==="number"||xe==="integer"?0:xe==="boolean"?!1:xe==="array"?[]:"",Ie=[...x,ye];r(Ie);const Le=Ie.length-1,qe=Xs(ye,Le,v);d?.(or(b,a,qe))},z=()=>{if(S){if(!m){he.error("Start the preview dev server to add sections.");return}if(g){g({append:F});return}he.error("Section picker is not available in this editor.");return}H()},W=xe=>{if(r(x.filter((ye,Ie)=>Ie!==xe)),C===xe){const ye=P(x[xe],xe),Ie=Lo(b,ye);d?.(Ie>=0?b.slice(0,Ie):[])}},q=(xe,ye)=>{const Ie=[...x];if(Ie[xe]=ye,r(Ie),xe===C&&C!==null){const Le=P(x[xe],xe),qe=Xs(ye,xe,v);if(Le!==qe){const st=Lo(b,Le);if(st>=0){const ct=[...b];ct[st]=qe,d?.(ct)}}}};let K;e[2]===Symbol.for("react.memo_cache_sentinel")?(K={activationConstraint:{distance:8}},e[2]=K):K=e[2];let Z;e[3]===Symbol.for("react.memo_cache_sentinel")?(Z={coordinateGetter:uu},e[3]=Z):Z=e[3];const Y=su(wr(nu,K),wr(iu,Z)),G=N.map(gS);let Q;e[4]===Symbol.for("react.memo_cache_sentinel")?(Q=xe=>{T(String(xe.active.id))},e[4]=Q):Q=e[4];const $=Q,X=xe=>{T(null);const{active:ye,over:Ie}=xe;if(!Ie||ye.id===Ie.id)return;const Le=G.indexOf(String(ye.id)),qe=G.indexOf(String(Ie.id));Le===-1||qe===-1||(E(st=>_m(la([...st],Le,qe))),r(la([...x],Le,qe)),O.current=!0,requestAnimationFrame(()=>{O.current=!1}))};let V;e[5]===Symbol.for("react.memo_cache_sentinel")?(V=()=>{T(null)},e[5]=V):V=e[5];const se=V,ee=R?N.find(xe=>xe.id===R):null,le=ee!=null?x[ee.index]:void 0,ce=ee!=null&&le!==void 0?P(le,ee.index):null,fe=ee!=null&&le!==void 0?pd(le,v):void 0;if(C!==null&&C<x.length){const xe=x[C],ye=lS(xe,v,c,f,y),Ie=()=>{const Le=P(xe,C),qe=or(b,a,Le),st=Lo(qe,Le);return st>=0?qe.slice(0,st+1):qe};return n.jsx("div",{className:"min-w-0",children:ye?.type==="object"&&ye.properties?n.jsx(Zi,{schema:ye,value:xe,onChange:Le=>q(C,Le),basePath:`${o}.${C}`,breadcrumbPath:w?.innerPath??[],onBreadcrumbChange:Le=>{d?.([...Ie(),...Le])},meta:c,decofile:h,onSaveReferencedBlock:u,previewBaseUrl:m,onAddSectionItem:p,onRequestAddSection:g,sandbox:_}):ye?uc({schema:ye,value:xe,onChange:Le=>q(C,Le),path:`${o}.${C}`,label:ye.title??`Item ${C+1}`,breadcrumbPath:w?.innerPath??[],onBreadcrumbChange:Le=>{d?.([...Ie(),...Le])},meta:c,decofile:h,onSaveReferencedBlock:u,previewBaseUrl:m,onAddSectionItem:p,onRequestAddSection:g,sandbox:_}):null})}const J="space-y-2";let te;e[6]!==a?(te=n.jsx("span",{className:"min-w-0 truncate text-sm font-medium",children:a}),e[6]=a,e[7]=te):te=e[7];const oe=x.length>0&&n.jsx("span",{className:"rounded-md bg-muted px-1.5 py-0.5 text-xs font-medium text-muted-foreground",children:x.length});let de;e[8]!==te||e[9]!==oe?(de=n.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[te,oe]}),e[8]=te,e[9]=oe,e[10]=de):de=e[10];let be;e[11]!==s.description?(be=s.description&&n.jsx("p",{className:"break-words text-xs leading-normal text-muted-foreground",children:s.description}),e[11]=s.description,e[12]=be):be=e[12];let ve;e[13]!==de||e[14]!==be?(ve=n.jsxs("div",{className:"min-w-0 space-y-0.5",children:[de,be]}),e[13]=de,e[14]=be,e[15]=ve):ve=e[15];const we=x.length>0&&n.jsx("div",{className:ae(R&&"cursor-grabbing"),children:n.jsxs(ru,{sensors:Y,collisionDetection:ou,onDragStart:$,onDragEnd:X,onDragCancel:se,children:[n.jsx(au,{items:G,strategy:lu,children:n.jsx("div",{className:"min-w-0 overflow-hidden rounded-xl border border-border/50 p-1.5",children:N.map(xe=>{const ye=x[xe.index];if(ye===void 0)return null;const Ie=P(ye,xe.index),Le=pd(ye,v);return n.jsx(uS,{sortableId:xe.id,labelText:Ie,imageSrc:Le,onOpen:()=>B(xe.index),onRemove:()=>W(xe.index)},xe.id)})})}),n.jsx(cu,{dropAnimation:null,children:ce?n.jsx("div",{className:"flex min-w-0 items-center gap-2.5 rounded-lg border border-border/60 bg-background px-2 py-2.5 shadow-lg ring-1 ring-border/60",children:n.jsx(hS,{labelText:ce,imageSrc:fe})}):null})]})});let De;e[16]===Symbol.for("react.memo_cache_sentinel")?(De=n.jsx(Dt,{size:14}),e[16]=De):De=e[16];const Be=S?"Add section":"Add item";let Pe;e[17]!==z||e[18]!==Be?(Pe=n.jsxs("button",{type:"button",onClick:z,className:"flex w-full items-center justify-center gap-1.5 rounded-xl border border-dashed border-border/60 py-2.5 text-sm text-muted-foreground transition-colors hover:border-border hover:bg-muted/30",children:[De,Be]}),e[17]=z,e[18]=Be,e[19]=Pe):Pe=e[19];let Fe;return e[20]!==ve||e[21]!==we||e[22]!==Pe?(Fe=n.jsxs("div",{className:J,children:[ve,we,Pe]}),e[20]=ve,e[21]=we,e[22]=Pe,e[23]=Fe):Fe=e[23],Fe}function gS(t){return t.id}function _S(t){const e=U.c(44),{schema:s,value:i,onChange:r,path:o,label:a,breadcrumbPath:l,onBreadcrumbChange:d,meta:c,decofile:h,onSaveReferencedBlock:u,previewBaseUrl:f,onAddSectionItem:m,onRequestAddSection:p,sandbox:g}=t;let _;e[0]!==l?(_=l===void 0?[]:l,e[0]=l,e[1]=_):_=e[1];const b=_,[x,v]=D.useState(!1);let y;e[2]!==i?(y=i!=null&&typeof i=="object"&&!Array.isArray(i)?i:{},e[2]=i,e[3]=y):y=e[3];const S=y;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 C=w;let N;e[6]!==b||e[7]!==C||e[8]!==a||e[9]!==S||e[10]!==s?(N=nS(C,a,s,S,b),e[6]=b,e[7]=C,e[8]=a,e[9]=S,e[10]=s,e[11]=N):N=e[11];const R=x||N,T=`${o}-fields`;let k;e[12]===Symbol.for("react.memo_cache_sentinel")?(k=()=>v(vS),e[12]=k):k=e[12];let j;e[13]!==R?(j=n.jsx("span",{className:"flex size-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors group-hover:text-accent-foreground",children:R?n.jsx(cs,{size:16}):n.jsx(Vi,{size:16})}),e[13]=R,e[14]=j):j=e[14];let I;e[15]!==a?(I=n.jsx("span",{className:"min-w-0 truncate text-sm font-medium",children:a}),e[15]=a,e[16]=I):I=e[16];let A;e[17]!==T||e[18]!==R||e[19]!==j||e[20]!==I?(A=n.jsxs("button",{type:"button","aria-expanded":R,"aria-controls":T,onClick:k,className:"group flex w-full min-w-0 items-center gap-2 rounded-md py-1.5 pr-2 text-left transition-colors hover:bg-accent hover:text-accent-foreground",children:[j,I]}),e[17]=T,e[18]=R,e[19]=j,e[20]=I,e[21]=A):A=e[21];let O;e[22]!==s.description?(O=s.description&&n.jsx("p",{className:"break-words pl-9 text-xs leading-normal text-muted-foreground",children:s.description}),e[22]=s.description,e[23]=O):O=e[23];let L;e[24]!==b||e[25]!==T||e[26]!==h||e[27]!==R||e[28]!==c||e[29]!==S||e[30]!==m||e[31]!==d||e[32]!==r||e[33]!==p||e[34]!==u||e[35]!==o||e[36]!==f||e[37]!==g||e[38]!==s?(L=R&&n.jsx("div",{id:T,className:"ml-3 min-w-0 max-w-full overflow-hidden border-l border-border/80 pl-5",children:n.jsx(Zi,{schema:s,value:S,onChange:r,basePath:o,breadcrumbPath:b,onBreadcrumbChange:d,meta:c,decofile:h,onSaveReferencedBlock:u,previewBaseUrl:f,onAddSectionItem:m,onRequestAddSection:p,sandbox:g})}),e[24]=b,e[25]=T,e[26]=h,e[27]=R,e[28]=c,e[29]=S,e[30]=m,e[31]=d,e[32]=r,e[33]=p,e[34]=u,e[35]=o,e[36]=f,e[37]=g,e[38]=s,e[39]=L):L=e[39];let P;return e[40]!==O||e[41]!==L||e[42]!==A?(P=n.jsxs("div",{className:"min-w-0 space-y-2",children:[A,O,L]}),e[40]=O,e[41]=L,e[42]=A,e[43]=P):P=e[43],P}function vS(t){return!t}function vm(t){return t===Yn||t===qi}function _o(t,e){if(!Object.hasOwn(e,t))return null;const s=e[t]??{},i=s.__resolveType??t;return{data:{...s},resolveType:i}}function Vr(t,e){const s=t.__resolveType??"";if(!s)return null;if(Tt(s)){const i=t.section??{};return xm(i,e)}if(vm(s)){const i=t.variants?.[0]?.value;return i?Vr(i,e):null}return!Ns(s)||!Object.hasOwn(e,s)?{data:{...t},resolveType:s}:_o(s,e)}function xm(t,e){const s=t.__resolveType??"";if(!s)return null;if(vm(s)){const i=t.variants?.[0]?.value;return i?Vr(i,e):null}return!Ns(s)||!Object.hasOwn(e,s)?{data:{...t},resolveType:s}:_o(s,e)}function xS(t,e){if(!t||typeof t!="object"||Array.isArray(t))return null;const i=t.__resolveType;if(typeof i!="string"||!Ns(i)||!Object.hasOwn(e,i))return null;const r=_o(i,e);return r?{blockKey:i,...r}:null}function bS(t,e,s){if(e.isMultivariate)return null;if(e.isSavedBlock){const i=e.isLazy?t.section?.__resolveType??t.__resolveType:t.__resolveType;return _o(i,s)}if(e.isHidden){const o=(Tt(t.__resolveType)?t.section:t)?.variants?.[0]?.value??t;return Vr(o,s)}if(e.isLazy||Tt(t.__resolveType)){const i=t.section??{};return xm(i,s)}return Vr(t,s)}function yS(t){if(!t?.properties)return{};const e={};for(const[s,i]of Object.entries(t.properties))s.startsWith("__")||s==="@type"||(i.default!==void 0?e[s]=i.default:i.type==="boolean"?e[s]=!1:i.type==="string"?e[s]="":i.type==="number"||i.type==="integer"?e[s]=0:i.type==="object"&&(e[s]={}));return e}function SS(t){const e=U.c(3),{blockKey:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx(Ne,{asChild:!0,children:n.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 rounded bg-global-section/14 px-1.5 py-0.5 text-[11px] font-medium text-global-section-fg dark:text-global-section-fg-dark",children:[n.jsx(Ui,{size:11}),"Global"]})}),e[0]=i):i=e[0];let r;return e[1]!==s?(r=n.jsxs(Te,{children:[i,n.jsxs(Ee,{side:"top",className:"max-w-[260px]",children:["Edits the saved block “",s,"”. Changes apply everywhere this loader is referenced on your site."]})]}),e[1]=s,e[2]=r):r=e[2],r}function wS(t){const e=U.c(28),{path:s,open:i,onOpenChange:r,title:o,nested:a,nestedBlockRef:l,globalBlockKey:d}=t,c=`${s}-loader-config`,h=l&&"ml-1";let u;e[0]!==h?(u=ae("rounded-lg border border-border/80 bg-muted/30",h),e[0]=h,e[1]=u):u=e[1];let f;e[2]!==r||e[3]!==i?(f=()=>r(!i),e[2]=r,e[3]=i,e[4]=f):f=e[4];let m;e[5]!==i?(m=n.jsx("span",{className:"flex size-6 shrink-0 items-center justify-center text-muted-foreground transition-colors group-hover:text-foreground",children:i?n.jsx(cs,{size:16}):n.jsx(Vi,{size:16})}),e[5]=i,e[6]=m):m=e[6];let p;e[7]!==o?(p=n.jsx("span",{className:"truncate text-xs font-medium tracking-wide text-muted-foreground uppercase",children:o}),e[7]=o,e[8]=p):p=e[8];let g;e[9]!==d?(g=d&&n.jsx(SS,{blockKey:d}),e[9]=d,e[10]=g):g=e[10];let _;e[11]!==p||e[12]!==g?(_=n.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[p,g]}),e[11]=p,e[12]=g,e[13]=_):_=e[13];let b;e[14]!==c||e[15]!==i||e[16]!==f||e[17]!==m||e[18]!==_?(b=n.jsxs("button",{type:"button","aria-expanded":i,"aria-controls":c,onClick:f,className:"group flex w-full min-w-0 items-center gap-2 rounded-lg px-3 py-2.5 text-left transition-colors hover:bg-accent/50",children:[m,_]}),e[14]=c,e[15]=i,e[16]=f,e[17]=m,e[18]=_,e[19]=b):b=e[19];let x;e[20]!==c||e[21]!==a||e[22]!==i?(x=i&&n.jsx("div",{id:c,className:"border-t border-border/60 px-4 pb-4 pt-3",children:n.jsx("div",{className:"border-l border-border/80 pl-4",children:a})}),e[20]=c,e[21]=a,e[22]=i,e[23]=x):x=e[23];let v;return e[24]!==u||e[25]!==b||e[26]!==x?(v=n.jsxs("div",{className:u,children:[b,x]}),e[24]=u,e[25]=b,e[26]=x,e[27]=v):v=e[27],v}function xd(t){const e=U.c(35),{schema:s,value:i,onChange:r,path:o,label:a,breadcrumbPath:l,onBreadcrumbChange:d,meta:c,decofile:h,onSaveReferencedBlock:u,sandbox:f}=t,m=(s.anyOfRefs??[]).filter(jS),p=h&&i?xS(i,h):null,g=p?.data??i,_=p?null:um(g),b=_??g,x=V2(m,{savedBlockKey:p?.blockKey,editorValue:g}),v=x.length>0?K2(g,x,p?.blockKey):x[0]?.resolveType??"",S=s.type==="block-ref"&&x.some(kS);let w;e[0]!==a||e[1]!==o?(w=a??(o.includes(".")?o.split(".")[0]:o),e[0]=a,e[1]=o,e[2]=w):w=e[2];const C=w;let N;e[3]!==l?(N=l??[],e[3]=l,e[4]=N):N=e[4];const E=N,R=S&&E[0]===C?E.slice(1):E,T=S?K=>{d?.([C,...K])}:d,[k,j]=D.useState(v),[I,A]=D.useState(v);I!==v&&(A(v),j(v));const[O,L]=D.useState(()=>G2(g,p?.blockKey));if(x.length>0){const K=k||v;let Z;e[5]!==K?(Z=oe=>oe.resolveType===K,e[5]=K,e[6]=Z):Z=e[6];const Y=x.find(Z),G=md(g,c,Y?.schema),Q=q2(G??Y?.schema??null,s.discriminatorKey),$=s.discriminatorKey,X=oe=>{j(oe);const de=x.find(Pe=>Pe.resolveType===oe),be=md(g,c,de?.schema),ve=new Set(Object.keys((be??de?.schema)?.properties??{})),we=i!==null&&typeof i=="object"&&!Array.isArray(i)?i:{},De=Object.fromEntries(Object.entries(we).filter(Pe=>{const[Fe]=Pe;return ve.has(Fe)})),Be={...yS(de?.schema),...De};if($){const Pe=de?.discriminatorValue??oe;r({...Be,[$]:Pe});return}if(Mr(oe)){r(Be);return}r({...Be,__resolveType:oe})};let V;e[7]!==K||e[8]!==$||e[9]!==r?(V=oe=>{if($||!Mr(K)||oe===null||typeof oe!="object"||Array.isArray(oe)){r(oe);return}const{__resolveType:de,...be}=oe;r(be)},e[7]=K,e[8]=$,e[9]=r,e[10]=V):V=e[10];const se=V,ee=Q?.properties?n.jsx(Zi,{schema:Q,value:b,onChange:oe=>{if(p&&u){u(p.blockKey,oe);return}if(_){r({...g,section:oe});return}se(oe)},basePath:o,breadcrumbPath:R,onBreadcrumbChange:T,meta:c,decofile:h,onSaveReferencedBlock:u,sandbox:f}):null;let le;e[11]!==o?(le=o.includes("."),e[11]=o,e[12]=le):le=e[12];const ce=le;let fe;e[13]!==a||e[14]!==o?(fe=n.jsx(Ve,{htmlFor:o,children:a}),e[13]=a,e[14]=o,e[15]=fe):fe=e[15];let J;e[16]===Symbol.for("react.memo_cache_sentinel")?(J=n.jsx(kt,{children:n.jsx(Rt,{placeholder:"Select..."})}),e[16]=J):J=e[16];let te;return e[17]!==s.description?(te=s.description&&n.jsx("p",{className:"text-xs text-muted-foreground",children:s.description}),e[17]=s.description,e[18]=te):te=e[18],n.jsxs("div",{className:"space-y-3",children:[n.jsxs("div",{className:"space-y-1.5",children:[fe,n.jsxs(Nt,{value:K||void 0,onValueChange:X,children:[J,n.jsx(jt,{children:x.map(CS)})]}),te]}),ee&&(S?n.jsx(wS,{path:o,open:O,onOpenChange:L,title:ce?"Configuration":"Loader configuration",nested:ee,nestedBlockRef:ce,globalBlockKey:p?.blockKey}):ee)]})}if(s.anyOfRefs&&s.anyOfRefs.length>0)return null;let P;e[19]!==a||e[20]!==o?(P=n.jsx(Ve,{htmlFor:o,children:a}),e[19]=a,e[20]=o,e[21]=P):P=e[21];const B=i!=null?String(i):"";let F;e[22]!==r?(F=K=>r(K.target.value),e[22]=r,e[23]=F):F=e[23];const H=s.description??"";let z;e[24]!==o||e[25]!==B||e[26]!==F||e[27]!==H?(z=n.jsx("input",{id:o,type:"text",value:B,onChange:F,className:"w-full rounded-md border bg-background px-3 py-1.5 text-sm",placeholder:H}),e[24]=o,e[25]=B,e[26]=F,e[27]=H,e[28]=z):z=e[28];let W;e[29]!==s.description?(W=s.description&&n.jsx("p",{className:"text-xs text-muted-foreground",children:s.description}),e[29]=s.description,e[30]=W):W=e[30];let q;return e[31]!==P||e[32]!==z||e[33]!==W?(q=n.jsxs("div",{className:"space-y-1.5",children:[P,z,W]}),e[31]=P,e[32]=z,e[33]=W,e[34]=q):q=e[34],q}function CS(t){const e=t.title&&!t.title.includes("/")?t.title:ga(t.resolveType)??ut(t.resolveType);return n.jsx(tt,{value:t.resolveType,children:e},t.resolveType)}function kS(t){return t.resolveType.includes("/")&&!Mr(t.resolveType)}function jS(t){return t.resolveType!==""}function NS(t){if(!Array.isArray(t))return[];const e=[];for(const s of t)if(typeof s=="string")e.push({value:s,label:s});else if(s&&typeof s=="object"&&"value"in s){const i=s;e.push({value:String(i.value),label:typeof i.label=="string"?i.label:String(i.value),image:typeof i.image=="string"?i.image:void 0})}return e}async function ES(t,e,s){const i={};s&&(i.term=s);const o=`${t.replace(/\/+$/,"")}/deco/invoke/${e}`,a=await fetch(o,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(i)});if(!a.ok)throw new Error(`Failed to fetch dynamic options: ${a.status}`);const l=await a.json();return NS(l)}function bd(t){const e=U.c(8),{path:s,label:i,description:r}=t;let o;e[0]!==i||e[1]!==s?(o=n.jsx(Ve,{htmlFor:s,children:i}),e[0]=i,e[1]=s,e[2]=o):o=e[2];let a;e[3]!==r?(a=r&&n.jsx("p",{className:"text-xs leading-normal text-muted-foreground",children:r}),e[3]=r,e[4]=a):a=e[4];let l;return e[5]!==o||e[6]!==a?(l=n.jsxs("div",{className:"space-y-0.5",children:[o,a]}),e[5]=o,e[6]=a,e[7]=l):l=e[7],l}function TS(t){const e=U.c(71),{schema:s,value:i,onChange:r,path:o,label:a,sandbox:l}=t,d=s.options,c=l?.previewUrl,[h,u]=D.useState(!1),[f,m]=D.useState(""),[p,g]=D.useState(""),_=D.useRef(null);let b;e[0]===Symbol.for("react.memo_cache_sentinel")?(b=G=>{m(G),_.current&&clearTimeout(_.current),_.current=setTimeout(()=>{g(G)},300)},e[0]=b):b=e[0];const x=b,v=l?`${l.orgSlug}/${l.virtualMcpId}/${l.branch}`:"";let y;e[1]!==p||e[2]!==d||e[3]!==v?(y=Et.sandboxInvoke(v,`dynamic-options:${d??""}:${p}`),e[1]=p,e[2]=d,e[3]=v,e[4]=y):y=e[4];let S;e[5]!==p||e[6]!==d||e[7]!==c?(S=()=>ES(c,d,p||void 0),e[5]=p,e[6]=d,e[7]=c,e[8]=S):S=e[8];const w=!!c&&!!d&&h;let C;e[9]!==y||e[10]!==S||e[11]!==w?(C={queryKey:y,queryFn:S,enabled:w,staleTime:6e4,retry:1},e[9]=y,e[10]=S,e[11]=w,e[12]=C):C=e[12];const N=Es(C);let E;e[13]!==N.data?(E=N.data??[],e[13]=N.data,e[14]=E):E=e[14];const R=E,T=typeof i=="string"?i:"";let k;if(e[15]!==T||e[16]!==R){let G;e[18]!==T?(G=Q=>Q.value===T,e[18]=T,e[19]=G):G=e[19],k=R.find(G),e[15]=T,e[16]=R,e[17]=k}else k=e[17];const j=k;if(!c||!d){let G;e[20]!==a||e[21]!==o||e[22]!==s.description?(G=n.jsx(bd,{path:o,label:a,description:s.description}),e[20]=a,e[21]=o,e[22]=s.description,e[23]=G):G=e[23];let Q;e[24]!==r?(Q=V=>r(V.target.value),e[24]=r,e[25]=Q):Q=e[25];let $;e[26]!==T||e[27]!==o||e[28]!==Q?($=n.jsx(ze,{id:o,type:"text",value:T,onChange:Q}),e[26]=T,e[27]=o,e[28]=Q,e[29]=$):$=e[29];let X;return e[30]!==$||e[31]!==G?(X=n.jsxs("div",{className:"space-y-2",children:[G,$]}),e[30]=$,e[31]=G,e[32]=X):X=e[32],X}let I;e[33]!==a||e[34]!==o||e[35]!==s.description?(I=n.jsx(bd,{path:o,label:a,description:s.description}),e[33]=a,e[34]=o,e[35]=s.description,e[36]=I):I=e[36];let A;e[37]!==T||e[38]!==j?(A=j?n.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[j.image&&n.jsx("img",{src:j.image,alt:"",referrerPolicy:"no-referrer",className:"h-6 w-6 shrink-0 rounded object-cover"}),n.jsx("span",{className:"truncate",children:j.label??j.value})]}):T?n.jsx("span",{className:"truncate",children:T}):n.jsx("span",{className:"text-muted-foreground",children:"Select..."}),e[37]=T,e[38]=j,e[39]=A):A=e[39];let O;e[40]===Symbol.for("react.memo_cache_sentinel")?(O=n.jsx(b1,{className:"size-4 shrink-0 opacity-50"}),e[40]=O):O=e[40];let L;e[41]!==h||e[42]!==A?(L=n.jsx(Rs,{asChild:!0,children:n.jsxs(ie,{variant:"outline",role:"combobox","aria-expanded":h,className:"h-10 w-full justify-between font-normal",children:[A,O]})}),e[41]=h,e[42]=A,e[43]=L):L=e[43];let P;e[44]===Symbol.for("react.memo_cache_sentinel")?(P={width:"var(--radix-popover-trigger-width)"},e[44]=P):P=e[44];let B;e[45]!==f?(B=n.jsx(Nl,{placeholder:"Search...",className:"h-9",value:f,onValueChange:x}),e[45]=f,e[46]=B):B=e[46];const F=N.isLoading?"Loading...":"No results found.";let H;e[47]!==F?(H=n.jsx(El,{children:F}),e[47]=F,e[48]=H):H=e[48];let z;if(e[49]!==T||e[50]!==r||e[51]!==R){let G;e[53]!==T||e[54]!==r?(G=Q=>n.jsxs(Or,{value:Q.value,onSelect:()=>{r(Q.value===T?"":Q.value),u(!1)},children:[n.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[Q.image&&n.jsx("img",{src:Q.image,alt:"",referrerPolicy:"no-referrer",className:"h-9 w-9 shrink-0 rounded object-cover"}),n.jsx("span",{className:"truncate",children:Q.label??Q.value})]}),n.jsx(js,{className:ae("ml-auto size-4 shrink-0",T===Q.value?"opacity-100":"opacity-0")})]},Q.value),e[53]=T,e[54]=r,e[55]=G):G=e[55],z=R.map(G),e[49]=T,e[50]=r,e[51]=R,e[52]=z}else z=e[52];let W;e[56]!==z?(W=n.jsx(Br,{children:z}),e[56]=z,e[57]=W):W=e[57];let q;e[58]!==H||e[59]!==W?(q=n.jsxs(Tl,{children:[H,W]}),e[58]=H,e[59]=W,e[60]=q):q=e[60];let K;e[61]!==B||e[62]!==q?(K=n.jsx(Ps,{className:"p-0",style:P,children:n.jsxs(Ku,{shouldFilter:!1,children:[B,q]})}),e[61]=B,e[62]=q,e[63]=K):K=e[63];let Z;e[64]!==h||e[65]!==L||e[66]!==K?(Z=n.jsxs(As,{open:h,onOpenChange:u,children:[L,K]}),e[64]=h,e[65]=L,e[66]=K,e[67]=Z):Z=e[67];let Y;return e[68]!==Z||e[69]!==I?(Y=n.jsxs("div",{className:"space-y-2",children:[I,Z]}),e[68]=Z,e[69]=I,e[70]=Y):Y=e[70],Y}function AS(t){const e=U.c(10),{org:s}=Me(),i=di();let r;e[0]!==s.id||e[1]!==t.configId?(r=Et.filePickerObjects(s.id,t.configId),e[0]=s.id,e[1]=t.configId,e[2]=r):r=e[2];const o=t.enabled!==!1&&!!t.configId;let a;e[3]!==t.configId||e[4]!==i?(a=async d=>{const{pageParam:c}=d;return await i.call("FILE_OBJECTS_LIST",{configId:t.configId,cursor:c??void 0})},e[3]=t.configId,e[4]=i,e[5]=a):a=e[5];let l;return e[6]!==r||e[7]!==o||e[8]!==a?(l={queryKey:r,enabled:o,staleTime:3e4,initialPageParam:null,queryFn:a,getNextPageParam:RS},e[6]=r,e[7]=o,e[8]=a,e[9]=l):l=e[9],T1(l)}function RS(t){return t.nextCursor??void 0}function dc(){const t=U.c(2),{org:e}=Me();let s;return t[0]!==e?(s={mutationFn:async i=>{const r=i.file.type||"application/octet-stream",o=await fetch(`/api/${encodeURIComponent(e.slug)}/file-configs/${encodeURIComponent(i.configId)}/upload?filename=${encodeURIComponent(i.file.name)}`,{method:"POST",headers:{"Content-Type":r},body:i.file});if(!o.ok){const a=await o.text().catch(PS);let l=`${o.status} ${o.statusText}`;try{const d=JSON.parse(a);d.message&&(l=d.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],ai(s)}function PS(){return""}const vo="file-picker:last-config-id";function bm(t){const e=U.c(19),s=t.mode==="image"?"Pick an image":"Pick a file";let i;e[0]!==s?(i=n.jsx(ss,{children:s}),e[0]=s,e[1]=i):i=e[1];let r;e[2]===Symbol.for("react.memo_cache_sentinel")?(r=n.jsx(Wi,{children:"Upload a new file or pick one previously uploaded to a configured bucket."}),e[2]=r):r=e[2];let o;e[3]!==i?(o=n.jsxs(ts,{children:[i,r]}),e[3]=i,e[4]=o):o=e[4];let a;e[5]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx(wl,{className:"h-64 w-full"}),e[5]=a):a=e[5];let l;e[6]!==t?(l=u=>{t.onSelect(u),t.onOpenChange(!1)},e[6]=t,e[7]=l):l=e[7];let d;e[8]!==t.lockedConfigId||e[9]!==t.mode||e[10]!==l?(d=n.jsx(Zt,{fallback:DS,children:n.jsx(D.Suspense,{fallback:a,children:n.jsx(LS,{mode:t.mode,lockedConfigId:t.lockedConfigId,onSelect:l})})}),e[8]=t.lockedConfigId,e[9]=t.mode,e[10]=l,e[11]=d):d=e[11];let c;e[12]!==o||e[13]!==d?(c=n.jsxs(Mt,{className:"sm:max-w-3xl max-h-[85vh] overflow-hidden flex flex-col",children:[o,d]}),e[12]=o,e[13]=d,e[14]=c):c=e[14];let h;return e[15]!==t.onOpenChange||e[16]!==t.open||e[17]!==c?(h=n.jsx(Bt,{open:t.open,onOpenChange:t.onOpenChange,children:c}),e[15]=t.onOpenChange,e[16]=t.open,e[17]=c,e[18]=h):h=e[18],h}function DS(t){const{error:e}=t;return n.jsx(IS,{error:e??new Error("Failed to load buckets")})}function IS(t){const e=U.c(3),{error:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx(zi,{size:16}),e[0]=i):i=e[0];let r;return e[1]!==s.message?(r=n.jsxs("div",{className:"p-4 rounded-md bg-destructive/10 text-destructive flex items-center gap-2",children:[i,n.jsx("span",{className:"text-sm font-medium",children:s.message})]}),e[1]=s.message,e[2]=r):r=e[2],r}function LS(t){const e=U.c(32),{mode:s,lockedConfigId:i,onSelect:r}=t,o=E1();if(o.length===0){let p;return e[0]===Symbol.for("react.memo_cache_sentinel")?(p=n.jsx(MS,{}),e[0]=p):p=e[0],p}if(i){let p;if(e[1]!==o||e[2]!==i){let _;e[4]!==i?(_=b=>b.id===i,e[4]=i,e[5]=_):_=e[5],p=o.find(_),e[1]=o,e[2]=i,e[3]=p}else p=e[3];const g=p;if(g){let _;return e[6]!==g||e[7]!==s||e[8]!==r?(_=n.jsx(Bo,{config:g,mode:s,onSelect:r}),e[6]=g,e[7]=s,e[8]=r,e[9]=_):_=e[9],_}}if(o.length===1){const p=o[0];let g;return e[10]!==p||e[11]!==s||e[12]!==r?(g=n.jsx(Bo,{config:p,mode:s,onSelect:r}),e[10]=p,e[11]=s,e[12]=r,e[13]=g):g=e[13],g}let a;e[14]===Symbol.for("react.memo_cache_sentinel")?(a=typeof window<"u"?window.localStorage.getItem(vo):null,e[14]=a):a=e[14];const l=a;let d;e[15]!==o?(d=o.find(p=>p.id===l)?.id??o[0].id,e[15]=o,e[16]=d):d=e[16];const c=d;let h;e[17]!==o?(h=o.map(OS),e[17]=o,e[18]=h):h=e[18];let u;e[19]!==h?(u=n.jsx(ao,{className:"self-start",children:h}),e[19]=h,e[20]=u):u=e[20];let f;if(e[21]!==o||e[22]!==s||e[23]!==r){let p;e[25]!==s||e[26]!==r?(p=g=>n.jsx(Ei,{value:g.id,className:"min-h-0 flex-1 overflow-hidden",children:n.jsx(Bo,{config:g,mode:s,onSelect:r})},g.id),e[25]=s,e[26]=r,e[27]=p):p=e[27],f=o.map(p),e[21]=o,e[22]=s,e[23]=r,e[24]=f}else f=e[24];let m;return e[28]!==c||e[29]!==u||e[30]!==f?(m=n.jsxs(lo,{defaultValue:c,onValueChange:BS,className:"min-h-0 flex-1 flex flex-col",children:[u,f]}),e[28]=c,e[29]=u,e[30]=f,e[31]=m):m=e[31],m}function OS(t){return n.jsx(zs,{value:t.id,children:t.name},t.id)}function BS(t){typeof window<"u"&&window.localStorage.setItem(vo,t)}function MS(){const t=U.c(4),{org:e}=Me();let s,i;t[0]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx("div",{className:"size-12 rounded-full bg-muted flex items-center justify-center",children:n.jsx(Kn,{size:20,className:"text-muted-foreground"})}),i=n.jsxs("div",{children:[n.jsx("p",{className:"font-medium text-sm",children:"No bucket configured"}),n.jsx("p",{className:"text-xs text-muted-foreground mt-1 max-w-sm",children:"Add an S3-compatible bucket in Settings before you can upload files."})]}),t[0]=s,t[1]=i):(s=t[0],i=t[1]);let r;return t[2]!==e.slug?(r=n.jsxs("div",{className:"rounded-xl border border-dashed border-border/60 p-10 flex flex-col items-center justify-center text-center gap-3",children:[s,i,n.jsx(ie,{asChild:!0,size:"sm",className:"mt-2",children:n.jsx(Vh,{to:"/$org/settings/files",params:{org:e.slug},children:"Configure a bucket"})})]}),t[2]=e.slug,t[3]=r):r=t[3],r}function Bo({config:t,mode:e,onSelect:s}){const i=AS({configId:t.id}),r=dc(),[o,a]=D.useState(!1),l=D.useRef(null),d=e==="image"?"image/*":void 0;async function c(_){if(!_)return;const b=Array.from(_);if(b.length===0)return;let x=null;const v=[];for(const y of b)try{const S=await r.mutateAsync({configId:t.id,file:y});x??=S.publicUrl}catch(S){v.push(`${y.name} (${S instanceof Error?S.message:"upload failed"})`)}await i.refetch(),v.length>0&&he.error(v.length===b.length?`Upload failed: ${v.join("; ")}`:`Some files failed: ${v.join("; ")}`),x&&s(x)}function h(_){_.preventDefault(),a(!0)}function u(){a(!1)}function f(_){_.preventDefault(),a(!1),c(_.dataTransfer.files)}const p=(i.data?.pages??[]).flatMap(_=>_.items),g=p.filter(_=>e==="image"?ym(_.key):!0);return n.jsxs("div",{className:"flex flex-col gap-3 min-h-0 h-full",children:[n.jsxs("button",{type:"button",onClick:()=>l.current?.click(),onDragOver:h,onDragLeave:u,onDrop:f,className:ae("rounded-xl border border-dashed border-border/60 p-6 flex flex-col items-center justify-center gap-2 text-center transition-colors",o&&"border-primary bg-primary/5",r.isPending&&"opacity-60 pointer-events-none"),children:[n.jsx(Kn,{size:18,className:"text-muted-foreground"}),n.jsx("p",{className:"text-sm font-medium",children:r.isPending?"Uploading…":"Drop files here or click to upload"}),n.jsxs("p",{className:"text-xs text-muted-foreground",children:["Up to 100 MB."," ",e==="image"?"Images only (PNG, JPEG, WebP, GIF, SVG, AVIF).":"Common image, video, audio, and document types."]}),n.jsx("input",{ref:l,type:"file",accept:d,multiple:!0,className:"hidden",onChange:_=>{const b=Array.from(_.target.files??[]);_.target.value="",c(b)}})]}),i.isFetching&&!i.isFetchingNextPage?n.jsx("div",{className:"flex justify-end",children:n.jsx("span",{className:"text-xs text-muted-foreground",children:"Loading…"})}):null,n.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto pr-1",children:[g.length===0?e==="image"&&p.length>0?n.jsx(zS,{}):n.jsx($S,{}):e==="image"?n.jsx(HS,{items:g,onSelect:s}):n.jsx(US,{items:g,onSelect:s}),i.hasNextPage&&n.jsx("div",{className:"flex justify-center py-4",children:n.jsx(ie,{type:"button",variant:"outline",size:"sm",disabled:i.isFetchingNextPage,onClick:()=>i.fetchNextPage(),children:i.isFetchingNextPage?n.jsxs(n.Fragment,{children:[n.jsx(Oe,{size:14,className:"animate-spin"}),"Loading…"]}):"Load more"})})]})]})}function $S(){const t=U.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsxs("div",{className:"flex h-full min-h-40 flex-col items-center justify-center gap-2 py-8 text-center",children:[n.jsx("div",{className:"flex size-10 items-center justify-center rounded-full bg-muted",children:n.jsx(Ii,{size:18,className:"text-muted-foreground"})}),n.jsx("p",{className:"text-sm font-medium",children:"No files in this bucket yet"}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Drop a file above to get started."})]}),t[0]=e):e=t[0],e}function zS(){const t=U.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsxs("div",{className:"flex h-full min-h-40 flex-col items-center justify-center gap-2 py-8 text-center",children:[n.jsx("div",{className:"flex size-10 items-center justify-center rounded-full bg-muted",children:n.jsx(Ii,{size:18,className:"text-muted-foreground"})}),n.jsx("p",{className:"text-sm font-medium",children:"No images in this bucket yet"}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"The bucket has other files, but none match common image formats."})]}),t[0]=e):e=t[0],e}function ym(t){return/\.(png|jpe?g|gif|webp|svg|avif|bmp)$/i.test(t)}function FS(t){const e=t.lastIndexOf(".");return e<0||e===t.length-1?"file":t.slice(e+1).toLowerCase()}function HS(t){const e=U.c(7),{items:s,onSelect:i}=t;let r;if(e[0]!==s||e[1]!==i){let a;e[3]!==i?(a=l=>n.jsx(Sm,{item:l,variant:"image",onSelect:i},l.key),e[3]=i,e[4]=a):a=e[4],r=s.map(a),e[0]=s,e[1]=i,e[2]=r}else r=e[2];let o;return e[5]!==r?(o=n.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 gap-3",children:r}),e[5]=r,e[6]=o):o=e[6],o}function US(t){const e=U.c(7),{items:s,onSelect:i}=t;let r;if(e[0]!==s||e[1]!==i){let a;e[3]!==i?(a=l=>n.jsx("li",{children:n.jsx(Sm,{item:l,variant:"row",onSelect:i})},l.key),e[3]=i,e[4]=a):a=e[4],r=s.map(a),e[0]=s,e[1]=i,e[2]=r}else r=e[2];let o;return e[5]!==r?(o=n.jsx("ul",{className:"divide-y divide-border/60 rounded-lg border border-border/60",children:r}),e[5]=r,e[6]=o):o=e[6],o}function Sm(t){const e=U.c(58),{item:s,variant:i,onSelect:r}=t;let o;e[0]!==s.key?(o=FS(s.key),e[0]=s.key,e[1]=o):o=e[1];const a=o;if(i==="image"){let v;e[2]!==s.publicUrl||e[3]!==r?(v=()=>r(s.publicUrl),e[2]=s.publicUrl,e[3]=r,e[4]=v):v=e[4];let y;e[5]!==s.key||e[6]!==s.publicUrl?(y=n.jsx("img",{src:s.publicUrl,alt:s.key,loading:"lazy",className:"h-full w-full object-cover",onError:WS}),e[5]=s.key,e[6]=s.publicUrl,e[7]=y):y=e[7];let S;e[8]!==s.key||e[9]!==v||e[10]!==y?(S=n.jsx("button",{type:"button",onClick:v,className:"block h-full w-full transition hover:ring-2 hover:ring-primary",title:s.key,children:y}),e[8]=s.key,e[9]=v,e[10]=y,e[11]=S):S=e[11];let w;e[12]!==a?(w=n.jsx("span",{className:"pointer-events-none absolute left-1.5 top-1.5 rounded bg-background/80 px-1.5 py-0.5 text-[10px] font-medium uppercase text-foreground opacity-0 backdrop-blur-sm transition-opacity group-hover:opacity-100",children:a}),e[12]=a,e[13]=w):w=e[13];let C;e[14]!==s||e[15]!==r?(C=n.jsx("div",{className:"absolute right-1.5 top-1.5 opacity-0 transition-opacity group-hover:opacity-100",children:n.jsx(yd,{item:s,onSelect:r})}),e[14]=s,e[15]=r,e[16]=C):C=e[16];let N;e[17]!==s.key?(N=Sd(s.key),e[17]=s.key,e[18]=N):N=e[18];let E;e[19]!==N?(E=n.jsx("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 bg-gradient-to-t from-black/70 to-transparent p-2 opacity-0 transition-opacity group-hover:opacity-100",children:n.jsx("p",{className:"truncate text-xs text-white",children:N})}),e[19]=N,e[20]=E):E=e[20];let R;return e[21]!==S||e[22]!==w||e[23]!==C||e[24]!==E?(R=n.jsxs("div",{className:"group relative aspect-square overflow-hidden rounded-lg border border-border/60 bg-muted",children:[S,w,C,E]}),e[21]=S,e[22]=w,e[23]=C,e[24]=E,e[25]=R):R=e[25],R}let l;e[26]!==s.publicUrl||e[27]!==r?(l=()=>r(s.publicUrl),e[26]=s.publicUrl,e[27]=r,e[28]=l):l=e[28];let d;e[29]!==s.key?(d=n.jsx("div",{className:"flex size-9 shrink-0 items-center justify-center rounded-md bg-muted",children:ym(s.key)?n.jsx(Ii,{size:16,className:"text-muted-foreground"}):n.jsx(Ri,{size:16,className:"text-muted-foreground"})}),e[29]=s.key,e[30]=d):d=e[30];let c;e[31]!==s.key?(c=Sd(s.key),e[31]=s.key,e[32]=c):c=e[32];let h;e[33]!==c?(h=n.jsx("p",{className:"truncate text-sm font-medium",children:c}),e[33]=c,e[34]=h):h=e[34];let u;e[35]!==s.key?(u=n.jsx("p",{className:"truncate font-mono text-xs text-muted-foreground",children:s.key}),e[35]=s.key,e[36]=u):u=e[36];let f;e[37]!==h||e[38]!==u?(f=n.jsxs("div",{className:"min-w-0 flex-1",children:[h,u]}),e[37]=h,e[38]=u,e[39]=f):f=e[39];let m;e[40]!==a?(m=n.jsx("span",{className:"shrink-0 rounded bg-muted px-1.5 py-0.5 text-[10px] font-medium uppercase text-muted-foreground",children:a}),e[40]=a,e[41]=m):m=e[41];let p;e[42]!==s.size?(p=GS(s.size),e[42]=s.size,e[43]=p):p=e[43];let g;e[44]!==p?(g=n.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:p}),e[44]=p,e[45]=g):g=e[45];let _;e[46]!==g||e[47]!==l||e[48]!==d||e[49]!==f||e[50]!==m?(_=n.jsxs("button",{type:"button",onClick:l,className:"flex min-w-0 flex-1 items-center gap-3 text-left",children:[d,f,m,g]}),e[46]=g,e[47]=l,e[48]=d,e[49]=f,e[50]=m,e[51]=_):_=e[51];let b;e[52]!==s||e[53]!==r?(b=n.jsx(yd,{item:s,onSelect:r}),e[52]=s,e[53]=r,e[54]=b):b=e[54];let x;return e[55]!==_||e[56]!==b?(x=n.jsxs("div",{className:"group flex items-center gap-3 px-3 py-2 transition hover:bg-muted/50",children:[_,b]}),e[55]=_,e[56]=b,e[57]=x):x=e[57],x}function WS(t){t.target.style.display="none"}function yd(t){const e=U.c(22),{item:s,onSelect:i}=t,[r,o]=D.useState(!1);let a;e[0]!==s.publicUrl?(a=async function(v){v.preventDefault(),v.stopPropagation();try{await navigator.clipboard.writeText(s.publicUrl),o(!0),window.setTimeout(()=>o(!1),1500)}catch{he.error("Failed to copy URL")}},e[0]=s.publicUrl,e[1]=a):a=e[1];const l=a;let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx(Vt,{asChild:!0,children:n.jsx(ie,{type:"button",variant:"ghost",size:"icon",className:"size-7 rounded-md bg-background/80 backdrop-blur-sm",onClick:qS,"aria-label":"Asset actions",children:n.jsx(C1,{size:14})})}),e[2]=d):d=e[2];let c;e[3]!==s.publicUrl||e[4]!==i?(c=()=>i(s.publicUrl),e[3]=s.publicUrl,e[4]=i,e[5]=c):c=e[5];let h;e[6]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx(js,{size:14}),e[6]=h):h=e[6];let u;e[7]!==c?(u=n.jsxs(Ue,{onClick:c,children:[h,"Use this"]}),e[7]=c,e[8]=u):u=e[8];let f;e[9]!==r?(f=r?n.jsx(js,{size:14}):n.jsx(as,{size:14}),e[9]=r,e[10]=f):f=e[10];const m=r?"Copied":"Copy URL";let p;e[11]!==l||e[12]!==f||e[13]!==m?(p=n.jsxs(Ue,{onClick:l,children:[f,m]}),e[11]=l,e[12]=f,e[13]=m,e[14]=p):p=e[14];let g;e[15]===Symbol.for("react.memo_cache_sentinel")?(g=n.jsx(hi,{size:14}),e[15]=g):g=e[15];let _;e[16]!==s.publicUrl?(_=n.jsx(Ue,{asChild:!0,children:n.jsxs("a",{href:s.publicUrl,target:"_blank",rel:"noreferrer",onClick:VS,children:[g,"Open in new tab"]})}),e[16]=s.publicUrl,e[17]=_):_=e[17];let b;return e[18]!==_||e[19]!==u||e[20]!==p?(b=n.jsxs(Wt,{children:[d,n.jsxs(Kt,{align:"end",onClick:KS,children:[u,p,_]})]}),e[18]=_,e[19]=u,e[20]=p,e[21]=b):b=e[21],b}function VS(t){return t.stopPropagation()}function KS(t){return t.stopPropagation()}function qS(t){return t.stopPropagation()}function Sd(t){const e=t.split("/");return e[e.length-1]??t}function GS(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function wm(t,e){if(!e)return null;const s=e.toLowerCase();return t.find(i=>{const r=i.bucket.toLowerCase();return i.siteSlug?.toLowerCase()===s||r===s||r===`deco-assets-${s}`})??null}function wd(t){const e=U.c(2),{ext:s}=t;if(!s)return null;let i;return e[0]!==s?(i=n.jsx("span",{className:"shrink-0 rounded bg-muted px-1.5 py-0.5 text-[10px] font-medium uppercase text-muted-foreground",children:s}),e[0]=s,e[1]=i):i=e[1],i}function YS(t){try{const e=new URL(t).pathname;return decodeURIComponent(e.split("/").pop()??t)}catch{return t.split("/").pop()??t}}function XS(t){const e=t.lastIndexOf(".");return e<0||e===t.length-1?"":t.slice(e+1).toLowerCase()}function JS(t){const e=U.c(79),{schema:s,value:i,onChange:r,path:o,label:a,sandbox:l}=t,d=s.format==="video-uri",c=lc(i),[h,u]=D.useState(!1),[f,m]=D.useState(!1),p=c?YS(c):"",g=p?XS(p):"",_=qu(),b=dc();let x;e[0]!==_.data?.configs?(x=_.data?.configs??[],e[0]=_.data?.configs,e[1]=x):x=e[1];const v=l?.siteSlug;let y;e[2]!==x||e[3]!==v?(y=wm(x,v),e[2]=x,e[3]=v,e[4]=y):y=e[4];const S=y;let w;e[5]!==_.data?.configs||e[6]!==S?(w=function(){if(S)return S.id;const J=_.data?.configs??[];if(J.length===1)return J[0].id;if(J.length===0)return null;const te=typeof window<"u"?window.localStorage.getItem(vo):null;return J.some(oe=>oe.id===te)?te:null},e[5]=_.data?.configs,e[6]=S,e[7]=w):w=e[7];const C=w;let N;e[8]!==d||e[9]!==r||e[10]!==C||e[11]!==u||e[12]!==b?(N=async function(J){if(!J)return;let te=Array.from(J);if(te.length===0)return;if(d&&(te=te.filter(ZS),te.length===0)){he.error("Please drop a video file (mp4, webm, …).");return}const oe=C();if(!oe){u(!0);return}try{const de=await b.mutateAsync({configId:oe,file:te[0]});r(de.publicUrl),te.length>1&&he.info(`Uploaded ${te[0].name}; extra files were ignored (single-select field).`)}catch(de){const be=de;he.error(be instanceof Error?be.message:"Upload failed")}},e[8]=d,e[9]=r,e[10]=C,e[11]=u,e[12]=b,e[13]=N):N=e[13];const E=N;let R;e[14]!==m?(R=function(J){J.preventDefault(),J.dataTransfer.types.includes("Files")&&m(!0)},e[14]=m,e[15]=R):R=e[15];const T=R;let k;e[16]!==m?(k=function(J){J.currentTarget===J.target&&m(!1)},e[16]=m,e[17]=k):k=e[17];const j=k;let I;e[18]!==E||e[19]!==m?(I=function(J){J.preventDefault(),m(!1),E(J.dataTransfer.files)},e[18]=E,e[19]=m,e[20]=I):I=e[20];const A=I;let O;e[21]!==a||e[22]!==o?(O=n.jsx(Ve,{htmlFor:o,className:"text-muted-foreground",children:a}),e[21]=a,e[22]=o,e[23]=O):O=e[23];let L;e[24]!==s.description?(L=s.description&&n.jsx("p",{className:"text-xs leading-normal text-muted-foreground",children:s.description}),e[24]=s.description,e[25]=L):L=e[25];let P;e[26]!==L||e[27]!==O?(P=n.jsxs("div",{className:"min-w-0 space-y-0.5",children:[O,L]}),e[26]=L,e[27]=O,e[28]=P):P=e[28];const B=f&&"border-primary ring-2 ring-primary/30",F=b.isPending&&"pointer-events-none opacity-60";let H;e[29]!==B||e[30]!==F?(H=ae("group relative w-full overflow-hidden rounded-xl border border-border/60 bg-muted/30 transition",B,F),e[29]=B,e[30]=F,e[31]=H):H=e[31];let z;e[32]!==g||e[33]!==p||e[34]!==d||e[35]!==u||e[36]!==c||e[37]!==b.isPending?(z=c?d?n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"relative h-40 w-full overflow-hidden bg-black",children:n.jsx("video",{src:c,preload:"metadata",className:"h-full w-full object-contain"},c)}),n.jsxs("div",{className:"flex items-center gap-2 border-t border-border/60 bg-background/50 px-3 py-2",children:[n.jsx(Bc,{size:14,className:"shrink-0 text-muted-foreground"}),n.jsx("p",{className:"min-w-0 flex-1 truncate text-xs text-muted-foreground",children:p}),n.jsx(wd,{ext:g})]})]}):n.jsxs("div",{className:"flex items-center gap-3 px-3 py-2.5",children:[n.jsx("div",{className:"flex size-10 shrink-0 items-center justify-center rounded-md bg-background",children:n.jsx(Ri,{size:18,className:"text-muted-foreground"})}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("p",{className:"truncate text-sm font-medium",children:p}),n.jsx("p",{className:"truncate text-xs text-muted-foreground",children:c})]}),n.jsx(wd,{ext:g})]}):n.jsxs("button",{type:"button",onClick:()=>u(!0),className:"flex w-full flex-col items-center justify-center gap-2 py-8 text-sm text-muted-foreground hover:bg-muted/60 hover:text-foreground",children:[d?n.jsx(Bc,{size:20}):n.jsx(Ri,{size:20}),n.jsx("span",{className:"text-sm font-medium",children:b.isPending?"Uploading…":d?"Drop a video here or click to browse":"Drop a file or click to browse"}),n.jsx("span",{className:"text-xs text-muted-foreground",children:"Up to 100 MB"})]}),e[32]=g,e[33]=p,e[34]=d,e[35]=u,e[36]=c,e[37]=b.isPending,e[38]=z):z=e[38];let W;e[39]!==f?(W=f&&n.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center bg-primary/10 backdrop-blur-[1px]",children:n.jsx("span",{className:"rounded-md bg-background px-3 py-1.5 text-xs font-medium shadow",children:"Drop to upload"})}),e[39]=f,e[40]=W):W=e[40];let q;e[41]!==j||e[42]!==T||e[43]!==A||e[44]!==H||e[45]!==z||e[46]!==W?(q=n.jsxs("div",{onDragOver:T,onDragLeave:j,onDrop:A,className:H,children:[z,W]}),e[41]=j,e[42]=T,e[43]=A,e[44]=H,e[45]=z,e[46]=W,e[47]=q):q=e[47];let K;e[48]!==r?(K=fe=>r(fe.target.value),e[48]=r,e[49]=K):K=e[49];let Z;e[50]!==o||e[51]!==c||e[52]!==K?(Z=n.jsx(ze,{id:o,type:"url",value:c,onChange:K,placeholder:"https://...",className:"h-9 min-w-0 flex-1"}),e[50]=o,e[51]=c,e[52]=K,e[53]=Z):Z=e[53];let Y;e[54]!==u?(Y=()=>u(!0),e[54]=u,e[55]=Y):Y=e[55];let G;e[56]===Symbol.for("react.memo_cache_sentinel")?(G=n.jsx(Kn,{size:14}),e[56]=G):G=e[56];const Q=c?"Replace":"Browse";let $;e[57]!==Y||e[58]!==Q?($=n.jsxs(ie,{type:"button",variant:"outline",size:"sm",onClick:Y,className:"h-9 shrink-0",children:[G,Q]}),e[57]=Y,e[58]=Q,e[59]=$):$=e[59];let X;e[60]!==r||e[61]!==c?(X=c&&n.jsx(ie,{type:"button",variant:"ghost",size:"sm",onClick:()=>r(""),className:"h-9 shrink-0","aria-label":"Remove file",children:n.jsx(es,{size:14})}),e[60]=r,e[61]=c,e[62]=X):X=e[62];let V;e[63]!==Z||e[64]!==$||e[65]!==X?(V=n.jsxs("div",{className:"flex w-full min-w-0 items-center gap-2",children:[Z,$,X]}),e[63]=Z,e[64]=$,e[65]=X,e[66]=V):V=e[66];let se;e[67]!==r?(se=fe=>r(fe),e[67]=r,e[68]=se):se=e[68];const ee=S?.id??null;let le;e[69]!==h||e[70]!==u||e[71]!==se||e[72]!==ee?(le=n.jsx(bm,{open:h,onOpenChange:u,mode:"any",onSelect:se,lockedConfigId:ee}),e[69]=h,e[70]=u,e[71]=se,e[72]=ee,e[73]=le):le=e[73];let ce;return e[74]!==P||e[75]!==q||e[76]!==V||e[77]!==le?(ce=n.jsxs("div",{className:"grid w-full min-w-0 grid-cols-[minmax(0,1fr)] gap-2",children:[P,q,V,le]}),e[74]=P,e[75]=q,e[76]=V,e[77]=le,e[78]=ce):ce=e[78],ce}function ZS(t){return t.type.startsWith("video/")}function QS(t){try{const e=new URL(t).pathname;return decodeURIComponent(e.split("/").pop()??t)}catch{return t.split("/").pop()??t}}function ew(t){const e=t.lastIndexOf(".");return e<0||e===t.length-1?"":t.slice(e+1).toLowerCase()}const tw=new Set(["image/png","image/jpeg","image/gif","image/webp","image/svg+xml","image/avif"]);function sw(t){const e=U.c(86),{schema:s,value:i,onChange:r,path:o,label:a,sandbox:l}=t,d=lc(i),[c,h]=D.useState(!1),[u,f]=D.useState(!1),[m,p]=D.useState(!1),[g,_]=D.useState(!1),b=d?QS(d):"",x=b?ew(b):"",v=qu(),y=dc();let S;e[0]!==v.data?.configs?(S=v.data?.configs??[],e[0]=v.data?.configs,e[1]=S):S=e[1];const w=l?.siteSlug;let C;e[2]!==S||e[3]!==w?(C=wm(S,w),e[2]=S,e[3]=w,e[4]=C):C=e[4];const N=C;let E;e[5]!==r||e[6]!==_||e[7]!==p?(E=function(ve){p(!1),_(!1),r(ve)},e[5]=r,e[6]=_,e[7]=p,e[8]=E):E=e[8];const R=E;let T;e[9]!==v.data?.configs||e[10]!==N?(T=function(){if(N)return N.id;const ve=v.data?.configs??[];if(ve.length===1)return ve[0].id;if(ve.length===0)return null;const we=typeof window<"u"?window.localStorage.getItem(vo):null;return ve.some(De=>De.id===we)?we:null},e[9]=v.data?.configs,e[10]=N,e[11]=T):T=e[11];const k=T;let j;e[12]!==k||e[13]!==h||e[14]!==R||e[15]!==y?(j=async function(ve){if(!ve)return;const we=Array.from(ve).filter(iw);if(we.length===0){he.error("Only image files are accepted here.");return}const De=k();if(!De){h(!0);return}try{const Be=await y.mutateAsync({configId:De,file:we[0]});R(Be.publicUrl),we.length>1&&he.info(`Uploaded ${we[0].name}; extra files were ignored (single-select field).`)}catch(Be){const Pe=Be;he.error(Pe instanceof Error?Pe.message:"Upload failed")}},e[12]=k,e[13]=h,e[14]=R,e[15]=y,e[16]=j):j=e[16];const I=j;let A;e[17]!==f?(A=function(ve){ve.preventDefault(),ve.dataTransfer.types.includes("Files")&&f(!0)},e[17]=f,e[18]=A):A=e[18];const O=A;let L;e[19]!==f?(L=function(ve){ve.currentTarget===ve.target&&f(!1)},e[19]=f,e[20]=L):L=e[20];const P=L;let B;e[21]!==I||e[22]!==f?(B=function(ve){ve.preventDefault(),f(!1),I(ve.dataTransfer.files)},e[21]=I,e[22]=f,e[23]=B):B=e[23];const F=B;let H;e[24]!==a||e[25]!==o?(H=n.jsx(Ve,{htmlFor:o,className:"text-muted-foreground",children:a}),e[24]=a,e[25]=o,e[26]=H):H=e[26];let z;e[27]!==s.description?(z=s.description&&n.jsx("p",{className:"text-xs leading-normal text-muted-foreground",children:s.description}),e[27]=s.description,e[28]=z):z=e[28];let W;e[29]!==H||e[30]!==z?(W=n.jsxs("div",{className:"min-w-0 space-y-0.5",children:[H,z]}),e[29]=H,e[30]=z,e[31]=W):W=e[31];const q=u&&"border-primary ring-2 ring-primary/30",K=y.isPending&&"pointer-events-none opacity-60";let Z;e[32]!==q||e[33]!==K?(Z=ae("group relative w-full overflow-hidden rounded-xl border border-border/60 bg-muted/30 transition",q,K),e[32]=q,e[33]=K,e[34]=Z):Z=e[34];let Y;e[35]!==x||e[36]!==b||e[37]!==g||e[38]!==m||e[39]!==a||e[40]!==_||e[41]!==p||e[42]!==h||e[43]!==d||e[44]!==y.isPending?(Y=d?n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"relative h-40 w-full bg-[image:linear-gradient(45deg,rgba(0,0,0,0.04)_25%,transparent_25%,transparent_75%,rgba(0,0,0,0.04)_75%),linear-gradient(45deg,rgba(0,0,0,0.04)_25%,transparent_25%,transparent_75%,rgba(0,0,0,0.04)_75%)] bg-[position:0_0,8px_8px] [background-size:16px_16px]",children:[!g&&n.jsx("img",{src:d,alt:a,className:ae("h-full w-full object-contain transition-opacity",!m&&"opacity-0"),onLoad:()=>p(!0),onError:()=>_(!0)},d),g&&n.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-1 text-muted-foreground",children:[n.jsx(Ii,{size:20}),n.jsx("p",{className:"text-xs",children:"Preview unavailable"})]}),!m&&!g&&n.jsx("div",{className:"absolute inset-0 animate-pulse bg-muted/60"})]}),n.jsxs("div",{className:"flex items-center gap-2 border-t border-border/60 bg-background/50 px-3 py-2",children:[n.jsx("span",{className:"min-w-0 flex-1 truncate text-xs font-medium",children:b}),x&&n.jsx("span",{className:"shrink-0 rounded bg-muted px-1.5 py-0.5 text-[10px] font-medium uppercase text-muted-foreground",children:x})]})]}):n.jsxs("button",{type:"button",onClick:()=>h(!0),className:"flex h-40 w-full flex-col items-center justify-center gap-2 text-sm text-muted-foreground hover:bg-muted/60 hover:text-foreground",children:[n.jsx(Ii,{size:20}),n.jsx("span",{className:"text-sm font-medium",children:y.isPending?"Uploading…":"Drop an image or click to browse"}),n.jsx("span",{className:"text-xs text-muted-foreground",children:"PNG, JPEG, WebP, GIF, SVG, AVIF — up to 100 MB"})]}),e[35]=x,e[36]=b,e[37]=g,e[38]=m,e[39]=a,e[40]=_,e[41]=p,e[42]=h,e[43]=d,e[44]=y.isPending,e[45]=Y):Y=e[45];let G;e[46]!==u?(G=u&&n.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center bg-primary/10 backdrop-blur-[1px]",children:n.jsx("span",{className:"rounded-md bg-background px-3 py-1.5 text-xs font-medium shadow",children:"Drop to upload"})}),e[46]=u,e[47]=G):G=e[47];let Q;e[48]!==P||e[49]!==O||e[50]!==F||e[51]!==Z||e[52]!==Y||e[53]!==G?(Q=n.jsxs("div",{onDragOver:O,onDragLeave:P,onDrop:F,className:Z,children:[Y,G]}),e[48]=P,e[49]=O,e[50]=F,e[51]=Z,e[52]=Y,e[53]=G,e[54]=Q):Q=e[54];let $;e[55]!==R?($=be=>R(be.target.value),e[55]=R,e[56]=$):$=e[56];let X;e[57]!==o||e[58]!==d||e[59]!==$?(X=n.jsx(ze,{id:o,type:"url",value:d,onChange:$,placeholder:"https://...",className:"h-9 min-w-0 flex-1"}),e[57]=o,e[58]=d,e[59]=$,e[60]=X):X=e[60];let V;e[61]!==h?(V=()=>h(!0),e[61]=h,e[62]=V):V=e[62];let se;e[63]===Symbol.for("react.memo_cache_sentinel")?(se=n.jsx(Kn,{size:14}),e[63]=se):se=e[63];const ee=d?"Replace":"Browse";let le;e[64]!==V||e[65]!==ee?(le=n.jsxs(ie,{type:"button",variant:"outline",size:"sm",onClick:V,className:"h-9 shrink-0",children:[se,ee]}),e[64]=V,e[65]=ee,e[66]=le):le=e[66];let ce;e[67]!==R||e[68]!==d?(ce=d&&n.jsx(ie,{type:"button",variant:"ghost",size:"sm",onClick:()=>R(""),className:"h-9 shrink-0","aria-label":"Remove image",children:n.jsx(es,{size:14})}),e[67]=R,e[68]=d,e[69]=ce):ce=e[69];let fe;e[70]!==X||e[71]!==le||e[72]!==ce?(fe=n.jsxs("div",{className:"flex w-full min-w-0 items-center gap-2",children:[X,le,ce]}),e[70]=X,e[71]=le,e[72]=ce,e[73]=fe):fe=e[73];let J;e[74]!==R?(J=be=>R(be),e[74]=R,e[75]=J):J=e[75];const te=N?.id??null;let oe;e[76]!==c||e[77]!==h||e[78]!==J||e[79]!==te?(oe=n.jsx(bm,{open:c,onOpenChange:h,mode:"image",onSelect:J,lockedConfigId:te}),e[76]=c,e[77]=h,e[78]=J,e[79]=te,e[80]=oe):oe=e[80];let de;return e[81]!==W||e[82]!==Q||e[83]!==fe||e[84]!==oe?(de=n.jsxs("div",{className:"grid w-full min-w-0 grid-cols-[minmax(0,1fr)] gap-2",children:[W,Q,fe,oe]}),e[81]=W,e[82]=Q,e[83]=fe,e[84]=oe,e[85]=de):de=e[85],de}function iw(t){return tw.has(t.type||"")}const nw="oklch(0.65 0.15 160)",rw="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)]",Cm="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)]",jE="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 Cd(t){return t.map(e=>e.label).join(`
|
|
467
|
-
`)}function Mo(t){return t.map(e=>({id:crypto.randomUUID(),index:e.index,label:e.label}))}function ow(t){return t.map((e,s)=>({...e,index:s}))}function km(t){const e=U.c(17),{label:s,canDelete:i,dragging:r,onDuplicate:o,onDelete:a}=t,l=r?"opacity-100":"opacity-0 group-hover:opacity-100";let d;e[0]!==l?(d=ae("h-4 w-4 shrink-0 text-muted-foreground/40 transition-opacity",l),e[0]=l,e[1]=d):d=e[1];let c;e[2]!==d?(c=n.jsx(bl,{className:d}),e[2]=d,e[3]=c):c=e[3];let h;e[4]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx(Ni,{className:"h-4 w-4 shrink-0",style:{color:nw}}),e[4]=h):h=e[4];let u;e[5]!==s?(u=n.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-medium",children:s}),e[5]=s,e[6]=u):u=e[6];let f;e[7]!==i||e[8]!==r||e[9]!==s||e[10]!==a||e[11]!==o?(f=!r&&n.jsxs(Wt,{children:[n.jsx(Vt,{asChild:!0,children:n.jsx(ie,{type:"button",variant:"ghost",size:"icon","aria-label":`Open actions for ${s}`,className:"size-6 shrink-0 opacity-0 transition-opacity group-hover:opacity-100 data-[state=open]:opacity-100",onClick:lw,onPointerDown:aw,children:n.jsx(Hi,{size:14})})}),n.jsxs(Kt,{align:"end",children:[n.jsxs(Ue,{onClick:p=>{p.stopPropagation(),o?.()},children:[n.jsx(as,{size:14}),"Duplicate"]}),n.jsxs(Ue,{variant:"destructive",disabled:!i,onClick:p=>{p.stopPropagation(),a?.()},children:[n.jsx(es,{size:14}),"Delete"]})]})]}),e[7]=i,e[8]=r,e[9]=s,e[10]=a,e[11]=o,e[12]=f):f=e[12];let m;return e[13]!==c||e[14]!==u||e[15]!==f?(m=n.jsxs(n.Fragment,{children:[c,h,u,f]}),e[13]=c,e[14]=u,e[15]=f,e[16]=m):m=e[16],m}function aw(t){return t.stopPropagation()}function lw(t){return t.stopPropagation()}function cw(t){const e=U.c(26),{entry:s,selected:i,canDelete:r,onSelect:o,onDuplicate:a,onDelete:l}=t;let d;e[0]!==s.id?(d={id:s.id,animateLayoutChanges:dw},e[0]=s.id,e[1]=d):d=e[1];const{attributes:c,listeners:h,setNodeRef:u,transform:f,isDragging:m}=du(d);let p;e[2]!==f?(p=hu.Transform.toString(f?{...f,x:0}:null),e[2]=f,e[3]=p):p=e[3];const g=m?0:void 0;let _;e[4]!==p||e[5]!==g?(_={transform:p,opacity:g},e[4]=p,e[5]=g,e[6]=_):_=e[6];const b=_;let x;e[7]!==o?(x=N=>{N.target===N.currentTarget&&(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),o())},e[7]=o,e[8]=x):x=e[8];const v=m?"cursor-grabbing":"cursor-grab",y=i?Cm:rw;let S;e[9]!==v||e[10]!==y?(S=ae("group flex select-none items-center gap-2 rounded-md px-2 py-2.5 transition-colors touch-none",v,y),e[9]=v,e[10]=y,e[11]=S):S=e[11];let w;e[12]!==r||e[13]!==s.label||e[14]!==l||e[15]!==a?(w=n.jsx(km,{label:s.label,canDelete:r,onDuplicate:a,onDelete:l}),e[12]=r,e[13]=s.label,e[14]=l,e[15]=a,e[16]=w):w=e[16];let C;return e[17]!==c||e[18]!==h||e[19]!==o||e[20]!==u||e[21]!==b||e[22]!==x||e[23]!==S||e[24]!==w?(C=n.jsx("div",{ref:u,style:b,...c,...h,onClick:o,onKeyDown:x,className:S,children:w}),e[17]=c,e[18]=h,e[19]=o,e[20]=u,e[21]=b,e[22]=x,e[23]=S,e[24]=w,e[25]=C):C=e[25],C}function dw(){return!1}function hw(t){const e=U.c(81),{listKey:s,variants:i,selectedIndex:r,onSelect:o,onDuplicate:a,onDelete:l,onRemoveAll:d,onReorder:c,onAdd:h}=t,u=i.length>1;let f;e[0]!==i?(f=()=>Mo(i),e[0]=i,e[1]=f):f=e[1];const[m,p]=D.useState(f),[g,_]=D.useState(null),[b,x]=D.useState(s),[v,y]=D.useState(i.length);let S;e[2]!==i?(S=()=>Cd(i),e[2]=i,e[3]=S):S=e[3];const[w,C]=D.useState(S),N=D.useRef(!1),E=Cd(i);b!==s?(x(s),y(i.length),C(E),p(Mo(i))):v!==i.length?(y(i.length),C(E),p(Mo(i))):w!==E&&(C(E),p(oe=>i.map((de,be)=>({id:oe[be]?.id??crypto.randomUUID(),index:de.index,label:de.label}))));let R;e[4]===Symbol.for("react.memo_cache_sentinel")?(R={activationConstraint:{distance:8}},e[4]=R):R=e[4];let T;e[5]===Symbol.for("react.memo_cache_sentinel")?(T={coordinateGetter:uu},e[5]=T):T=e[5];const k=su(wr(nu,R),wr(iu,T));let j;e[6]!==m?(j=m.map(uw),e[6]=m,e[7]=j):j=e[7];const I=j;let A;e[8]!==m?(A=oe=>{const de=String(oe.active.id);_(m.find(be=>be.id===de)??null)},e[8]=m,e[9]=A):A=e[9];const O=A;let L;e[10]!==I||e[11]!==c?(L=oe=>{_(null);const{active:de,over:be}=oe;if(!be||de.id===be.id)return;const ve=I.indexOf(String(de.id)),we=I.indexOf(String(be.id));ve===-1||we===-1||(p(De=>ow(la([...De],ve,we))),N.current=!0,requestAnimationFrame(()=>{N.current=!1}),c(ve,we))},e[10]=I,e[11]=c,e[12]=L):L=e[12];const P=L;let B;e[13]===Symbol.for("react.memo_cache_sentinel")?(B=()=>{_(null)},e[13]=B):B=e[13];const F=B;let H,z,W,q,K,Z,Y,G,Q,$,X,V,se;if(e[14]!==u||e[15]!==m||e[16]!==I||e[17]!==P||e[18]!==O||e[19]!==h||e[20]!==l||e[21]!==a||e[22]!==d||e[23]!==o||e[24]!==r||e[25]!==k){const oe=ye=>{N.current||o(ye)};X="space-y-1 border-b p-2";let de;e[39]===Symbol.for("react.memo_cache_sentinel")?(de=n.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Variants"}),e[39]=de):de=e[39];let be;e[40]===Symbol.for("react.memo_cache_sentinel")?(be=n.jsx(Dt,{size:14}),e[40]=be):be=e[40];let ve;e[41]!==h?(ve=n.jsx(Ne,{asChild:!0,children:n.jsx(ie,{type:"button",variant:"ghost",size:"icon","aria-label":"Add variant",className:"size-6",onClick:h,children:be})}),e[41]=h,e[42]=ve):ve=e[42];let we;e[43]===Symbol.for("react.memo_cache_sentinel")?(we=n.jsx(Ee,{children:"Add variant"}),e[43]=we):we=e[43];let De;e[44]!==ve?(De=n.jsxs(Te,{children:[ve,we]}),e[44]=ve,e[45]=De):De=e[45];let Be;e[46]===Symbol.for("react.memo_cache_sentinel")?(Be=n.jsx(es,{size:14}),e[46]=Be):Be=e[46];let Pe;e[47]!==d?(Pe=n.jsx(Ne,{asChild:!0,children:n.jsx(ie,{type:"button",variant:"ghost",size:"icon","aria-label":"Remove all variants",className:"size-6 text-muted-foreground hover:text-destructive",onClick:d,children:Be})}),e[47]=d,e[48]=Pe):Pe=e[48];let Fe;e[49]===Symbol.for("react.memo_cache_sentinel")?(Fe=n.jsx(Ee,{children:"Remove all variants"}),e[49]=Fe):Fe=e[49];let xe;e[50]!==Pe?(xe=n.jsxs(Te,{children:[Pe,Fe]}),e[50]=Pe,e[51]=xe):xe=e[51],e[52]!==De||e[53]!==xe?(V=n.jsxs("div",{className:"flex items-center justify-between",children:[de,n.jsxs("div",{className:"flex items-center gap-0.5",children:[De,xe]})]}),e[52]=De,e[53]=xe,e[54]=V):V=e[54],z=ru,Z=k,Y=ou,G=O,Q=P,$=F,H=au,q=I,K=lu,se="space-y-0.5",W=m.map(ye=>n.jsx(cw,{entry:ye,selected:ye.index===r,canDelete:u,onSelect:()=>oe(ye.index),onDuplicate:()=>a(ye.index),onDelete:()=>l(ye.index)},ye.id)),e[14]=u,e[15]=m,e[16]=I,e[17]=P,e[18]=O,e[19]=h,e[20]=l,e[21]=a,e[22]=d,e[23]=o,e[24]=r,e[25]=k,e[26]=H,e[27]=z,e[28]=W,e[29]=q,e[30]=K,e[31]=Z,e[32]=Y,e[33]=G,e[34]=Q,e[35]=$,e[36]=X,e[37]=V,e[38]=se}else H=e[26],z=e[27],W=e[28],q=e[29],K=e[30],Z=e[31],Y=e[32],G=e[33],Q=e[34],$=e[35],X=e[36],V=e[37],se=e[38];let ee;e[55]!==W||e[56]!==se?(ee=n.jsx("div",{className:se,children:W}),e[55]=W,e[56]=se,e[57]=ee):ee=e[57];let le;e[58]!==H||e[59]!==q||e[60]!==K||e[61]!==ee?(le=n.jsx(H,{items:q,strategy:K,children:ee}),e[58]=H,e[59]=q,e[60]=K,e[61]=ee,e[62]=le):le=e[62];let ce;e[63]!==g||e[64]!==u?(ce=g?n.jsx("div",{className:ae("flex items-center gap-2 rounded-md px-2 py-2.5 shadow-lg ring-1 ring-border/60 cursor-grabbing",Cm),children:n.jsx(km,{label:g.label,canDelete:u,dragging:!0})}):null,e[63]=g,e[64]=u,e[65]=ce):ce=e[65];let fe;e[66]!==ce?(fe=n.jsx(cu,{dropAnimation:null,children:ce}),e[66]=ce,e[67]=fe):fe=e[67];let J;e[68]!==z||e[69]!==Z||e[70]!==Y||e[71]!==G||e[72]!==Q||e[73]!==$||e[74]!==le||e[75]!==fe?(J=n.jsxs(z,{sensors:Z,collisionDetection:Y,onDragStart:G,onDragEnd:Q,onDragCancel:$,children:[le,fe]}),e[68]=z,e[69]=Z,e[70]=Y,e[71]=G,e[72]=Q,e[73]=$,e[74]=le,e[75]=fe,e[76]=J):J=e[76];let te;return e[77]!==X||e[78]!==V||e[79]!==J?(te=n.jsxs("div",{className:X,children:[V,J]}),e[77]=X,e[78]=V,e[79]=J,e[80]=te):te=e[80],te}function uw(t){return t.id}const fw=[[/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"]],mw={"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 $o(t){return ci(t)!==void 0}function jm(t,e){if(e){if($o(e))return e;const s=mw[e];if(s&&$o(s))return s}for(const[s,i]of fw)if(s.test(t)&&$o(i))return i;return"FilterLines"}function pw(t){return ci(t)??A1}function kd(t){const e=U.c(11),{iconName:s,size:i,className:r}=t,o=i===void 0?"md":i;let a;e[0]!==s?(a=pw(s),e[0]=s,e[1]=a):a=e[1];const l=a,d=o==="sm"?"size-7":"size-9",c=o==="sm"?16:18;let h;e[2]!==d||e[3]!==r?(h=ae("flex shrink-0 items-center justify-center rounded-full bg-muted",d,r),e[2]=d,e[3]=r,e[4]=h):h=e[4];let u;e[5]!==l||e[6]!==c?(u=n.jsx(l,{size:c,className:"text-muted-foreground"}),e[5]=l,e[6]=c,e[7]=u):u=e[7];let f;return e[8]!==h||e[9]!==u?(f=n.jsx("div",{className:h,children:u}),e[8]=h,e[9]=u,e[10]=f):f=e[10],f}const Nm="Users03";function gw(t){const e=t.manifest?.blocks??{},s=[];for(const[i,r]of Object.entries(e))if(i.includes("matchers"))for(const o of Object.keys(r)){if(o.includes("always"))continue;const a=fi(o,t);s.push({resolveType:o,title:a.title??ut(o),description:a.description,iconName:jm(o,a.icon)})}return s}function _w(t,e){if(!t)return Nm;const s=e.find(i=>i.resolveType===t);return s?s.iconName:jm(t)}function vw(t){const e=U.c(41),{currentRt:s,currentLabel:i,matchers:r,onSelect:o}=t,[a,l]=D.useState(!1);let d;if(e[0]!==s||e[1]!==r){const j=_w(s,r);d=ci(j),e[0]=s,e[1]=r,e[2]=d}else d=e[2];const c=d;let h;e[3]!==o?(h=j=>{o(j),l(!1)},e[3]=o,e[4]=h):h=e[4];const u=h;let f;e[5]===Symbol.for("react.memo_cache_sentinel")?(f=()=>l(!0),e[5]=f):f=e[5];let m;e[6]!==c?(m=c&&n.jsx(c,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),e[6]=c,e[7]=m):m=e[7];let p;e[8]!==i?(p=n.jsx("span",{className:"flex-1 truncate",children:i}),e[8]=i,e[9]=p):p=e[9];let g;e[10]===Symbol.for("react.memo_cache_sentinel")?(g=n.jsx(cs,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e[10]=g):g=e[10];let _;e[11]!==m||e[12]!==p?(_=n.jsxs("button",{type:"button",onClick:f,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:[m,p,g]}),e[11]=m,e[12]=p,e[13]=_):_=e[13];let b;e[14]===Symbol.for("react.memo_cache_sentinel")?(b=n.jsx(Nl,{placeholder:"Search rules..."}),e[14]=b):b=e[14];let x;e[15]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsx(El,{children:"No rules found."}),e[15]=x):x=e[15];let v;e[16]!==u?(v=()=>u(""),e[16]=u,e[17]=v):v=e[17];const y=!s&&"bg-accent/60";let S;e[18]!==y?(S=ae("gap-2.5",y),e[18]=y,e[19]=S):S=e[19];let w;e[20]===Symbol.for("react.memo_cache_sentinel")?(w=n.jsx(kd,{iconName:Nm,size:"sm"}),e[20]=w):w=e[20];let C;e[21]===Symbol.for("react.memo_cache_sentinel")?(C=n.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[n.jsx("span",{className:"text-sm",children:"Always"}),n.jsx("span",{className:"text-xs text-muted-foreground",children:"Target all users"})]}),e[21]=C):C=e[21];let N;e[22]!==v||e[23]!==S?(N=n.jsxs(Or,{value:"always Target all users",onSelect:v,className:S,children:[w,C]}),e[22]=v,e[23]=S,e[24]=N):N=e[24];let E;if(e[25]!==s||e[26]!==u||e[27]!==r){let j;e[29]!==s||e[30]!==u?(j=I=>n.jsxs(Or,{value:`${I.title} ${I.resolveType} ${I.description??""}`,onSelect:()=>u(I.resolveType),className:ae("gap-2.5",s===I.resolveType&&"bg-accent/60"),children:[n.jsx(kd,{iconName:I.iconName,size:"sm"}),n.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[n.jsx("span",{className:"text-sm",children:I.title}),I.description&&n.jsx("span",{className:"truncate text-xs text-muted-foreground",children:I.description})]})]},I.resolveType),e[29]=s,e[30]=u,e[31]=j):j=e[31],E=r.map(j),e[25]=s,e[26]=u,e[27]=r,e[28]=E}else E=e[28];let R;e[32]!==N||e[33]!==E?(R=n.jsxs(Tl,{children:[x,n.jsxs(Br,{children:[N,E]})]}),e[32]=N,e[33]=E,e[34]=R):R=e[34];let T;e[35]!==a||e[36]!==R?(T=n.jsxs(N1,{open:a,onOpenChange:l,title:"Choose a rule",description:"Pick how to target users for this variant",className:"sm:max-w-lg",children:[b,R]}),e[35]=a,e[36]=R,e[37]=T):T=e[37];let k;return e[38]!==T||e[39]!==_?(k=n.jsxs(n.Fragment,{children:[_,T]}),e[38]=T,e[39]=_,e[40]=k):k=e[40],k}const xw=t=>t.charAt(0).toUpperCase()+t.slice(1).toLowerCase(),bw=5,yw=new Intl.DateTimeFormat("en",{dateStyle:"medium",timeStyle:"short"});function jd(t){const{start:e,end:s}=t,i=typeof e=="string"?e:"",r=typeof s=="string"?s:"";if(!i&&!r)return null;const o=d=>{if(!d)return null;const c=new Date(d);return Number.isNaN(c.getTime())?null:yw.format(c)},a=o(i),l=o(r);return a&&l?`${a} → ${l}`:a?`From ${a}`:l?`Until ${l}`:null}function hc(t,e=0){if(!t)return"Default";if(e>bw)return"...";const s=t.__resolveType??"";if(["website/matchers/always.ts","$live/matchers/MatchAlways.ts"].includes(s)||s==="")return"Default";switch(s){case"website/matchers/never.ts":return"Hidden";case"website/matchers/device.ts":case"$live/matchers/MatchDevice.ts":{const{mobile:r,tablet:o,desktop:a,devices:l=[]}=t,d=[...l];return r&&d.push("Mobile"),o&&d.push("Tablet"),a&&d.push("Desktop"),d.length>0?d.map(xw).join(" & "):ut(s)}case"website/matchers/date.ts":case"$live/matchers/MatchDate.ts":return jd(t)??ut(s);case"website/matchers/random.ts":case"$live/matchers/MatchRandom.ts":{const{traffic:r}=t;return typeof r=="number"?`${Math.ceil(r*100)}% of sessions`:ut(s)}case"website/matchers/host.ts":case"$live/matchers/MatchHost.ts":{const{includes:r,match:o}=t,a=[];return r&&a.push(r),o&&a.push(o),a.length>0?a.join(" - "):ut(s)}case"website/matchers/pathname.ts":{const r=t.case,{type:o,pathname:a}=r??{};return o&&a?`Pathname ${o} ${a}`:ut(s)}case"website/matchers/location.ts":case"$live/matchers/MatchLocation.ts":{const{includeLocations:r,excludeLocations:o}=t,a=c=>[c.city,c.regionCode,c.country].filter(Boolean).join(" - "),l=r?.[0];if(l){const c=(r?.length??0)-1;return`${a(l)}${c>0?` +${c}`:""}`}const d=o?.[0];if(d){const c=(o?.length??0)-1;return`Except ${a(d)}${c>0?` +${c}`:""}`}return"Any location"}case"website/matchers/multi.ts":case"$live/matchers/MatchMulti.ts":{const{matchers:r,op:o="AND"}=t;if(r&&r.length>0){const a=o==="OR"?"OR":"AND";return r.map(l=>hc(l,e+1)).join(` ${a} `)}return ut(s)}default:{const r=jd(t);return r||ut(s)||"Default"}}}function Sw(t){if(!t||typeof t!="object")return!1;const e=t;return typeof e.__resolveType=="string"&&Array.isArray(e.variants)}function ww(t,e){return{__resolveType:e,variants:[{rule:Li(),value:structuredClone(t)},{rule:Li(),value:structuredClone(t)}]}}function Cw(t){const e=t.variants;if(e.length===0)return;const s=e.find(i=>sc(i.rule));return s?s.value:e[e.length-1]?.value}function kw(t){const e=[...t.variants],s=e[e.length-1],i={rule:Li(),value:s?structuredClone(s.value):void 0};return{...t,variants:[...e,i]}}function jw(t,e){if(t.variants.length<=1)return null;const s=[...t.variants];return s.splice(e,1),{...t,variants:s}}function Nw(t,e){const s=[...t.variants],i=s[e];return i?(s.splice(e+1,0,structuredClone(i)),{...t,variants:s}):t}function Ew(t,e,s){const i=[...t.variants];if(e===s||e<0||s<0||e>=i.length||s>=i.length)return t;const[r]=i.splice(e,1);return r?(i.splice(s,0,r),{...t,variants:i}):t}function Tw(t,e,s){const i=[...t.variants],r=i[e];return r?(i[e]={...r,value:s},{...t,variants:i}):t}function Nd(t,e,s){const i=[...t.variants],r=i[e];return r?(i[e]={...r,rule:s},{...t,variants:i}):t}const Ed=new WeakMap,Td=new Map;function Aw(t){let e=Ed.get(t);return e||(e=gw(t),Ed.set(t,e)),e}function Rw(t,e){let s=Td.get(t);return s===void 0&&(s=Us(t,e),Td.set(t,s)),s}function Pw(t){const e=U.c(3),{multivariateResolveType:s,renderInnerField:i,...r}=t,{value:o,onChange:a,meta:l,path:d}=r,[c,h]=D.useState(0);if(!Sw(o)){let L;e[0]===Symbol.for("react.memo_cache_sentinel")?(L=n.jsx(Tu,{size:14}),e[0]=L):L=e[0];let P;return e[1]===Symbol.for("react.memo_cache_sentinel")?(P=n.jsx(Ee,{children:"Add variant"}),e[1]=P):P=e[1],n.jsxs("div",{className:"relative grid w-full min-w-0 grid-cols-[minmax(0,1fr)] gap-2",children:[n.jsxs(Te,{children:[n.jsx(Ne,{asChild:!0,children:n.jsx(ie,{type:"button",variant:"ghost",size:"icon",className:"absolute right-0 top-0 size-6 text-muted-foreground hover:text-foreground","aria-label":"Add variant",onClick:()=>{a(ww(o,s)),h(0)},children:L})}),P]}),i(r)]})}const u=o,f=u.variants,m=Math.min(c,f.length-1),p=f.map(Dw),g=f[m],_=g?.rule??{},b=_.__resolveType??"",x=g?.value,v=l?Aw(l):[],y=b&&l?Rw(b,l):null,{__resolveType:S,...w}=_,C=()=>{a(Cw(u)),h(0)},N=()=>{const L=kw(u);a(L),h(L.variants.length-1)},E=L=>{const P=jw(u,L);P&&(a(P),m>=P.variants.length&&h(P.variants.length-1))},R=L=>{const P=Nw(u,L);a(P),h(L+1)},T=(L,P)=>{const B=Ew(u,L,P);a(B),m===L&&h(P)},k=L=>{a(Nd(u,m,L?{__resolveType:L}:{__resolveType:cf}))},j=L=>{const P=L,B=b?{...P,__resolveType:b}:{...P};a(Nd(u,m,B))},I=L=>{a(Tw(u,m,L))},A=`${d}-${u.__resolveType}`;let O;return e[2]===Symbol.for("react.memo_cache_sentinel")?(O=n.jsx(Ve,{className:"text-xs text-muted-foreground",children:"Rule"}),e[2]=O):O=e[2],n.jsxs("div",{className:"grid w-full min-w-0 grid-cols-[minmax(0,1fr)] gap-0",children:[n.jsx(hw,{listKey:A,variants:p,selectedIndex:m,onSelect:h,onDuplicate:R,onDelete:E,onRemoveAll:C,onReorder:T,onAdd:N}),n.jsxs("div",{className:"space-y-4 px-2 pt-3",children:[n.jsxs("div",{className:"space-y-1.5",children:[O,n.jsx(vw,{currentRt:b,currentLabel:hc(_),matchers:v,onSelect:k}),y&&n.jsx("div",{className:"pt-1",children:n.jsx(Zi,{schema:y,value:w,onChange:j,basePath:""})})]}),i({...r,value:x,onChange:I})]})]})}function Dw(t,e){return{index:e,label:hc(t.rule)||`Variant ${e+1}`}}const Iw="website/loaders/secret.ts";function Nn(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 Lw(){return{__resolveType:Iw,name:"",encrypted:""}}function Ow(t){const{value:e,...s}=t;return s}function zo(t){const e=U.c(45),{schema:s,value:i,onChange:r,label:o,path:a}=t;if(typeof i=="string"||i==null&&!Nn(i)){const C=typeof i=="string"?i:"";let N;e[0]!==o||e[1]!==a?(N=n.jsx(Ve,{htmlFor:a,className:"text-sm font-medium",children:o}),e[0]=o,e[1]=a,e[2]=N):N=e[2];let E;e[3]!==s.description?(E=s.description&&n.jsx("p",{className:"text-xs text-muted-foreground",children:s.description}),e[3]=s.description,e[4]=E):E=e[4];let R;e[5]!==r?(R=j=>r(j.target.value),e[5]=r,e[6]=R):R=e[6];let T;e[7]!==a||e[8]!==C||e[9]!==R?(T=n.jsx(ze,{id:a,type:"password",value:C,autoComplete:"new-password",autoCorrect:"off",spellCheck:!1,placeholder:"Secret value",onChange:R,className:"h-10"}),e[7]=a,e[8]=C,e[9]=R,e[10]=T):T=e[10];let k;return e[11]!==N||e[12]!==E||e[13]!==T?(k=n.jsxs("div",{className:"space-y-2",children:[N,E,T]}),e[11]=N,e[12]=E,e[13]=T,e[14]=k):k=e[14],k}let l;e[15]!==i?(l=Nn(i)?i:Lw(),e[15]=i,e[16]=l):l=e[16];const d=l,c=typeof d.name=="string"?d.name:"",h=typeof d.encrypted=="string"&&d.encrypted,u=`${a}-name`;let f;e[17]!==o||e[18]!==u?(f=n.jsx(Ve,{htmlFor:u,className:"text-sm font-medium",children:o}),e[17]=o,e[18]=u,e[19]=f):f=e[19];let m;e[20]!==s.description?(m=s.description&&n.jsx("p",{className:"text-xs text-muted-foreground",children:s.description}),e[20]=s.description,e[21]=m):m=e[21];const p=`${a}-name`;let g;e[22]!==d||e[23]!==r?(g=C=>r({...d,name:C.target.value}),e[22]=d,e[23]=r,e[24]=g):g=e[24];let _;e[25]!==c||e[26]!==p||e[27]!==g?(_=n.jsx(ze,{id:p,value:c,placeholder:"Secret name",onChange:g,className:"h-10"}),e[25]=c,e[26]=p,e[27]=g,e[28]=_):_=e[28];const b=`${a}-value`,x=h?"Leave blank to keep current value":"Secret value";let v;e[29]!==d||e[30]!==h||e[31]!==r?(v=C=>{const N=C.target.value;if(!N){r(h?Ow(d):d);return}r({...d,value:N})},e[29]=d,e[30]=h,e[31]=r,e[32]=v):v=e[32];let y;e[33]!==v||e[34]!==b||e[35]!==x?(y=n.jsx(ze,{id:b,type:"password",autoComplete:"new-password",autoCorrect:"off",spellCheck:!1,placeholder:x,onChange:v,className:"h-10"}),e[33]=v,e[34]=b,e[35]=x,e[36]=y):y=e[36];let S;e[37]!==h?(S=h&&n.jsx("p",{className:"text-xs text-muted-foreground",children:"A secret value is stored."}),e[37]=h,e[38]=S):S=e[38];let w;return e[39]!==y||e[40]!==S||e[41]!==f||e[42]!==m||e[43]!==_?(w=n.jsxs("div",{className:"space-y-2",children:[f,m,_,y,S]}),e[39]=y,e[40]=S,e[41]=f,e[42]=m,e[43]=_,e[44]=w):w=e[44],w}function Bw(t){const e=t.length>0?t[0]:void 0;if(e==null||typeof e!="object"||Array.isArray(e))return;const s={};for(const[i,r]of Object.entries(e))i.startsWith("__")||(typeof r=="string"?s[i]={type:"string"}:typeof r=="number"?s[i]={type:"number"}:typeof r=="boolean"&&(s[i]={type:"boolean"}));return Object.keys(s).length>0?{type:"object",properties:s}:void 0}const Mw=new Set(["__resolveType","@type"]);function $w(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 zw(t){if(mo(t))for(const e of t.anyOfRefs??[]){const r=e.schema?.properties?.variants?.items?.properties?.value;if(r?.type==="array"&&r.items)return r.items}}function Ad(t){if(t.type==="array"&&t.items)return t;const e=t.items??zw(t);return e?{...t,type:"array",items:e}:null}function Fw(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 uc(t){const{schema:e,value:s}=t;if(Ur(s)){const a=_0(s),l=Ad(e);if(a!==null&&l)return n.jsx(ar,{...t,schema:l,value:a,onChange:d=>t.onChange(v0(s,d))},t.path)}if(Array.isArray(s)&&e.type==="block-ref"&&mo(e)){const a=Ad(e);if(a)return n.jsx(ar,{...t,schema:a,value:s,onChange:t.onChange},t.path)}if(Array.isArray(s)&&!Ur(s)&&e.type==="block-ref"){const a=Bw(s);if(a){const l={...e,type:"array",items:a};return n.jsx(ar,{...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($w(e)){const a=e.anyOfRefs[0],l=a.schema?.properties?.variants?.items?.properties?.value,d=l&&l.type!=="block-ref"?l:e.plainSchema??l?.plainSchema??{type:"string"},c=h=>uc({...h,schema:d});return n.jsx(Pw,{...t,multivariateResolveType:a.resolveType,renderInnerField:c},t.path)}return e.anyOfRefs?n.jsx(xd,{...t},t.path):null}if(e.format==="image-uri")return n.jsx(sw,{...t},t.path);if(e.format==="file-uri"||e.format==="video-uri")return n.jsx(JS,{...t},t.path);if(e.format==="dynamic-options"&&e.options)return n.jsx(TS,{...t},t.path);if(e.enum&&e.enum.length>0)return n.jsx(F2,{...t},t.path);if(e.type==="anyOf")return n.jsx(xd,{...t},t.path);if(Nn(s)||e.format==="password"||s==null&&e.format==="password")return n.jsx(zo,{...t},t.path);const i=s??Fw(e.type,e.default);if(i==null)return Nn(s)?n.jsx(zo,{...t},t.path):null;if(Nn(i))return n.jsx(zo,{...t,value:i},t.path);const r={...t,value:i},o=s==null?e.type??typeof i:Array.isArray(i)?"array":typeof i;if(o==="array"||Array.isArray(i))return n.jsx(ar,{...r},t.path);switch(o){case"boolean":return n.jsx(B2,{...r},t.path);case"number":case"integer":return n.jsx(O2,{...r},t.path);case"string":{const a=e.format;return a==="color-input"?n.jsx(rr,{...r},t.path):a==="textarea"||a==="rich-text"||a==="html"?n.jsx(rr,{...r},t.path):n.jsx(rr,{...r},t.path)}case"object":return i!==null&&typeof i=="object"&&!Array.isArray(i)?n.jsx(_S,{...r},t.path):null;default:return n.jsx(rr,{...r},t.path)}}function Zi(t){const e=U.c(16),{schema:s,value:i,onChange:r,basePath:o,breadcrumbPath:a,onBreadcrumbChange:l,meta:d,decofile:c,onSaveReferencedBlock:h,previewBaseUrl:u,onAddSectionItem:f,onRequestAddSection:m,sandbox:p}=t;let g,_;if(e[0]!==o||e[1]!==c||e[2]!==d||e[3]!==f||e[4]!==l||e[5]!==r||e[6]!==m||e[7]!==h||e[8]!==u||e[9]!==p||e[10]!==s.properties||e[11]!==a||e[12]!==i){_=Symbol.for("react.early_return_sentinel");e:{const b=a===void 0?[]:a,x=s.properties;if(!x){_=null;break e}const v=i!=null&&typeof i=="object"&&!Array.isArray(i)?i:{},y=Object.keys(x).filter(T=>!Mw.has(T)&&x[T]?.hidden!==!0);if(y.length===0){let T;e[15]===Symbol.for("react.memo_cache_sentinel")?(T=n.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:"No editable fields on this section."}),e[15]=T):T=e[15],_=T;break e}const S=(T,k)=>{r({...v,[T]:k})},w=typeof v.__resolveType=="string"?v.__resolveType:void 0,C=b.length>0?iS(y,x,v,b):null,N=C?x[C]:null,E=C&&N?[C]:y,R=C&&N?tS(C,N,b):b;g=n.jsx("div",{className:"min-w-0 space-y-6",children:E.map(T=>{const k=x[T];if(!k)return null;const j=o?`${o}.${T}`:T,I=jn(T,k);return uc({schema:k,value:v[T],onChange:A=>S(T,A),path:j,label:I,breadcrumbPath:R,onBreadcrumbChange:l,meta:d,decofile:c,onSaveReferencedBlock:h,containerResolveType:w,previewBaseUrl:u,onAddSectionItem:f,onRequestAddSection:m,sandbox:p})})})}e[0]=o,e[1]=c,e[2]=d,e[3]=f,e[4]=l,e[5]=r,e[6]=m,e[7]=h,e[8]=u,e[9]=p,e[10]=s.properties,e[11]=a,e[12]=i,e[13]=g,e[14]=_}else g=e[13],_=e[14];return _!==Symbol.for("react.early_return_sentinel")?_:g}function Hw(t){const e=U.c(37),{open:s,onOpenChange:i,defaultBlockId:r,isPending:o,onSubmit:a}=t,l=r===void 0?"":r,d=o===void 0?!1:o,[c,h]=D.useState(l),[u,f]=D.useState(s);s!==u&&(f(s),s&&h(l));let m;e[0]!==d||e[1]!==i?(m=j=>{!j&&!d&&i(!1)},e[0]=d,e[1]=i,e[2]=m):m=e[2];const p=m;let g;e[3]!==c||e[4]!==d||e[5]!==a?(g=async j=>{j.preventDefault();const I=c.trim();!I||d||await a(I)},e[3]=c,e[4]=d,e[5]=a,e[6]=g):g=e[6];const _=g;let b;e[7]===Symbol.for("react.memo_cache_sentinel")?(b=n.jsxs(ts,{children:[n.jsx(ss,{children:"Save as global"}),n.jsx(Wi,{children:"Save this section as a global block so it can be reused on other pages."})]}),e[7]=b):b=e[7];let x;e[8]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsx("label",{htmlFor:"block-id",className:"text-sm font-medium",children:"Block name"}),e[8]=x):x=e[8];let v;e[9]===Symbol.for("react.memo_cache_sentinel")?(v=j=>h(j.target.value),e[9]=v):v=e[9];let y;e[10]!==c||e[11]!==d?(y=n.jsxs("div",{className:"py-4 space-y-2",children:[x,n.jsx(ze,{id:"block-id",value:c,onChange:v,placeholder:"MyNewBlock",autoFocus:!0,disabled:d})]}),e[10]=c,e[11]=d,e[12]=y):y=e[12];let S;e[13]!==i?(S=()=>i(!1),e[13]=i,e[14]=S):S=e[14];let w;e[15]!==d||e[16]!==S?(w=n.jsx(ie,{type:"button",variant:"outline",onClick:S,disabled:d,children:"Cancel"}),e[15]=d,e[16]=S,e[17]=w):w=e[17];let C;e[18]!==c||e[19]!==d?(C=!c.trim()||d,e[18]=c,e[19]=d,e[20]=C):C=e[20];let N;e[21]!==d?(N=d?n.jsxs(n.Fragment,{children:[n.jsx(Oe,{size:14,className:"animate-spin"}),"Saving…"]}):"Save",e[21]=d,e[22]=N):N=e[22];let E;e[23]!==C||e[24]!==N?(E=n.jsx(ie,{type:"submit",disabled:C,children:N}),e[23]=C,e[24]=N,e[25]=E):E=e[25];let R;e[26]!==w||e[27]!==E?(R=n.jsxs(Ws,{children:[w,E]}),e[26]=w,e[27]=E,e[28]=R):R=e[28];let T;e[29]!==_||e[30]!==R||e[31]!==y?(T=n.jsx(Mt,{className:"sm:max-w-md",children:n.jsxs("form",{onSubmit:_,children:[b,y,R]})}),e[29]=_,e[30]=R,e[31]=y,e[32]=T):T=e[32];let k;return e[33]!==p||e[34]!==s||e[35]!==T?(k=n.jsx(Bt,{open:s,onOpenChange:p,children:T}),e[33]=p,e[34]=s,e[35]=T,e[36]=k):k=e[36],k}function Uw(t){const e=U.c(60),{orgSlug:s,virtualMcpId:i,branch:r,previewUrl:o,meta:a,decofile:l,resolveType:d,title:c,defaultBlockId:h,isCreating:u,onCreate:f,onSaveReferencedBlock:m}=t,p=gi(),g=p?.entity?.id===i?p.entity.metadata?.siteSlug??null:null;let _;e[0]===Symbol.for("react.memo_cache_sentinel")?(_={},e[0]=_):_=e[0];const[b,x]=D.useState(_);let v;e[1]===Symbol.for("react.memo_cache_sentinel")?(v=[],e[1]=v):v=e[1];const[y,S]=D.useState(v),[w,C]=D.useState(0),[N,E]=D.useState(!1);let R;e[2]!==a||e[3]!==d?(R=Us(d,a),e[2]=a,e[3]=d,e[4]=R):R=e[4];const T=R;let k;e[5]!==d?(k=d.split("/").pop()?.replace(/\.tsx?$/,"")??d,e[5]=d,e[6]=k):k=e[6];const j=k,I=o??void 0;let A;e[7]!==g||e[8]!==r||e[9]!==s||e[10]!==I||e[11]!==i?(A={orgSlug:s,virtualMcpId:i,branch:r,previewUrl:I,siteSlug:g},e[7]=g,e[8]=r,e[9]=s,e[10]=I,e[11]=i,e[12]=A):A=e[12];const O=A;let L;e[13]!==y||e[14]!==c?(L=[c,...y],e[13]=y,e[14]=c,e[15]=L):L=e[15];const P=L;let B;e[16]!==y?(B=ce=>{S(y.slice(0,ce)),C(Ww)},e[16]=y,e[17]=B):B=e[17];const F=B;let H;e[18]!==l||e[19]!==b||e[20]!==f?(H=async ce=>{const fe=y2(ce,l);if(fe){he.error(fe);return}await f(ce,b),E(!1)},e[18]=l,e[19]=b,e[20]=f,e[21]=H):H=e[21];const z=H;let W;e[22]!==F||e[23]!==P?(W=n.jsx("nav",{"aria-label":"Editing breadcrumb",className:"flex min-w-0 flex-1 items-center gap-1 overflow-hidden text-sm",children:P.map((ce,fe)=>{const J=fe===P.length-1;return n.jsxs("span",{className:"flex min-w-0 items-center gap-1 overflow-hidden",children:[fe>0&&n.jsx(Vi,{className:"size-3 shrink-0 text-muted-foreground/60"}),n.jsx("button",{type:"button",onClick:()=>F(fe),title:ce,className:ae("min-w-0 truncate rounded-md px-1 py-0.5 text-left transition-colors hover:bg-accent hover:text-accent-foreground",J?"font-medium text-foreground":"text-muted-foreground"),children:ce})]},`${ce}-${fe}`)})}),e[22]=F,e[23]=P,e[24]=W):W=e[24];let q;e[25]===Symbol.for("react.memo_cache_sentinel")?(q=()=>E(!0),e[25]=q):q=e[25];let K;e[26]===Symbol.for("react.memo_cache_sentinel")?(K=n.jsx(Nu,{size:14}),e[26]=K):K=e[26];let Z;e[27]!==u?(Z=n.jsx(Ne,{asChild:!0,children:n.jsx(ie,{size:"icon",className:"size-8 shrink-0",disabled:u,onClick:q,"aria-label":"Save as global section",children:K})}),e[27]=u,e[28]=Z):Z=e[28];let Y;e[29]===Symbol.for("react.memo_cache_sentinel")?(Y=n.jsx(Ee,{side:"bottom",children:"Save as global section"}),e[29]=Y):Y=e[29];let G;e[30]!==Z?(G=n.jsxs(Te,{children:[Z,Y]}),e[30]=Z,e[31]=G):G=e[31];let Q;e[32]!==W||e[33]!==G?(Q=n.jsxs("div",{className:"flex min-w-0 items-center gap-2 overflow-hidden",children:[W,G]}),e[32]=W,e[33]=G,e[34]=Q):Q=e[34];let $;e[35]!==j?($=n.jsxs("p",{className:"mt-1.5 py-1 pl-1 text-sm leading-snug text-muted-foreground",children:[j," — edits stay local until you save this as a global section."]}),e[35]=j,e[36]=$):$=e[36];let X;e[37]!==Q||e[38]!==$?(X=n.jsxs("div",{className:"shrink-0 border-b px-3 py-2.5",children:[Q,$]}),e[37]=Q,e[38]=$,e[39]=X):X=e[39];let V;e[40]!==l||e[41]!==y||e[42]!==w||e[43]!==b||e[44]!==a||e[45]!==m||e[46]!==O||e[47]!==T?(V=n.jsx(Fi,{className:"min-h-0 flex-1 [&_[data-slot=scroll-area-viewport]>div]:!block",children:n.jsx("div",{className:"min-w-0 max-w-full overflow-x-hidden px-6 py-4",children:n.jsx("div",{className:"mx-auto max-w-2xl",children:T?n.jsx(Zi,{schema:T,value:b,onChange:ce=>x(ce),basePath:"",breadcrumbPath:y,onBreadcrumbChange:S,meta:a,decofile:l,onSaveReferencedBlock:m,sandbox:O},w):n.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:"No editable fields for this section."})})})}),e[40]=l,e[41]=y,e[42]=w,e[43]=b,e[44]=a,e[45]=m,e[46]=O,e[47]=T,e[48]=V):V=e[48];let se;e[49]!==X||e[50]!==V?(se=n.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[X,V]}),e[49]=X,e[50]=V,e[51]=se):se=e[51];let ee;e[52]!==h||e[53]!==z||e[54]!==u||e[55]!==N?(ee=n.jsx(Hw,{open:N,onOpenChange:E,defaultBlockId:h,isPending:u,onSubmit:z}),e[52]=h,e[53]=z,e[54]=u,e[55]=N,e[56]=ee):ee=e[56];let le;return e[57]!==se||e[58]!==ee?(le=n.jsxs("div",{className:"flex h-full w-full min-w-0",children:[se,ee]}),e[57]=se,e[58]=ee,e[59]=le):le=e[59],le}function Ww(t){return t+1}function Vw(t,e){const s={__resolveType:t},i=Xf([s],e)[0];return i?bS(s,i,e):null}function Kw({orgSlug:t,virtualMcpId:e,branch:s,previewUrl:i,meta:r,decofile:o,blockKey:a,onSaveReferencedBlock:l}){const d=gi(),c=d?.entity?.id===e?d.entity.metadata?.siteSlug??null:null,[h]=D.useState(()=>Vw(a,o)),[u,f]=D.useState(h?.data??{}),[m,p]=D.useState([]),[g,_]=D.useState(0),[b,x]=D.useState(!1),[v,y]=D.useState(null),S=v!==null,{save:w,flush:C}=k0({orgSlug:t,virtualMcpId:e,branch:s}),N=h?.resolveType?Us(h.resolveType,r):null,E=o[a],R=E?Kl(a,E):a,T={orgSlug:t,virtualMcpId:e,branch:s,previewUrl:i??void 0,siteSlug:c},k=L=>{f(L),w(a,L)},j=()=>{S?(y(null),x(!1),_(L=>L+1)):y(JSON.stringify(u,null,2))},I=L=>{const P=L??"";try{const B=JSON.parse(P);if(B&&typeof B=="object"&&!Array.isArray(B)){x(!1),k(B);return}x(!0)}catch{x(!0)}},A=[R,...m],O=L=>{p(m.slice(0,L)),_(P=>P+1)};return n.jsx("div",{className:"flex h-full w-full min-w-0",children:n.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[n.jsxs("div",{className:"shrink-0 border-b px-3 py-2.5",children:[n.jsxs("div",{className:"flex min-w-0 items-center gap-2 overflow-hidden",children:[n.jsx("span",{className:"size-2 shrink-0 rounded-full",style:{backgroundColor:lf},"aria-hidden":!0}),n.jsx("nav",{"aria-label":"Editing breadcrumb",className:"flex min-w-0 flex-1 items-center gap-1 overflow-hidden text-sm",children:A.map((L,P)=>{const B=P===A.length-1;return n.jsxs("span",{className:"flex min-w-0 items-center gap-1 overflow-hidden",children:[P>0&&n.jsx(Vi,{className:"size-3 shrink-0 text-muted-foreground/60"}),n.jsx("button",{type:"button",onClick:()=>O(P),title:L,className:ae("min-w-0 truncate rounded-md px-1 py-0.5 text-left transition-colors hover:bg-accent hover:text-accent-foreground",B?"font-medium text-foreground":"text-muted-foreground"),children:L})]},`${L}-${P}`)})}),n.jsxs(Te,{children:[n.jsx(Ne,{asChild:!0,children:n.jsx(ie,{variant:S?"default":"ghost",size:"icon",className:"size-8 shrink-0",onClick:j,"aria-label":S?"Close JSON editor":"Edit as JSON","aria-pressed":S,children:S?n.jsx(jl,{size:14}):n.jsx(no,{size:14})})}),n.jsx(Ee,{side:"bottom",children:S?"Close JSON editor":"Edit as JSON"})]})]}),n.jsx("p",{className:"mt-1.5 py-1 pl-1 text-sm leading-snug text-muted-foreground",children:"Global section — changes save automatically and apply everywhere it's used."})]}),n.jsxs("div",{className:"relative min-h-0 flex-1",children:[n.jsx(Fi,{className:"h-full [&_[data-slot=scroll-area-viewport]>div]:!block",children:n.jsx("div",{className:"min-w-0 max-w-full overflow-x-hidden px-6 py-4",children:n.jsx("div",{className:"mx-auto max-w-2xl",children:N?n.jsx(Zi,{schema:N,value:u,onChange:L=>k(L),basePath:"",breadcrumbPath:m,onBreadcrumbChange:p,meta:r,decofile:o,onSaveReferencedBlock:l,sandbox:T},g):n.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:"No editable fields for this section."})})})}),v!==null&&n.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[b&&n.jsx("div",{className:"shrink-0 border-b bg-destructive/10 px-3 py-1.5 text-xs text-destructive",children:"Invalid JSON — changes aren't saved until it parses."}),n.jsx("div",{className:"min-h-0 flex-1",children:n.jsx(Gu,{language:"json",height:"100%",code:v,onChange:I,onSave:L=>{I(L),C()}})})]})]})]})})}function Rd(t,e){const s=e.replace(/\s*\(copy(?:\s+\d+)?\)\s*$/,"").trim(),i=`${s} (copy)`;if(!t.has(i))return i;for(let r=2;r<1e3;r++){const o=`${s} (copy ${r})`;if(!t.has(o))return o}return`${s} (copy ${Date.now()})`}function qw(t,e){const s=Ti,i=e.replace(/-copy(?:-\d+)?$/,""),r=`${i}-copy`;if(!t.has(s(r)))return r;for(let o=2;o<1e3;o++){const a=`${i}-copy-${o}`;if(!t.has(s(a)))return a}return`${i}-copy-${Date.now()}`}function Gw(t,e){const s=e.replace(/_copy(?:_\d+)?$/,""),i=`${s}_copy`;if(!Object.hasOwn(t,i))return i;for(let r=2;r<1e3;r++){const o=`${s}_copy_${r}`;if(!Object.hasOwn(t,o))return o}return`${s}_copy_${Date.now()}`}function Yw(t){const e=ic(t.newName),s={...t.source,name:t.newName,path:t.newPath};return{key:e,data:s}}function Xw(t,e){return im(t,e)}const Jw=1e3;function Zw(t,e){for(let s=0;s<Jw;s++){const i=ic(e);if(!Object.hasOwn(t,i))return i}throw new Error("Could not generate a unique page block key")}const Qw={create:"Create new page",duplicate:"Duplicate page",rename:"Rename page"},eC={create:"Create",duplicate:"Duplicate",rename:"Save"},tC={create:"Creating…",duplicate:"Duplicating…",rename:"Saving…"};function sC(t){const e=U.c(54),{open:s,mode:i,initialName:r,initialPath:o,isPending:a,error:l,validate:d,onSubmit:c,onOpenChange:h}=t,u=a===void 0?!1:a,[f,m]=D.useState(r),[p,g]=D.useState(o),[_,b]=D.useState(null),[x,v]=D.useState(s);s!==x&&(v(s),s&&(m(r),g(o),b(null)));let y;e[0]!==u||e[1]!==h?(y=Y=>{!Y&&!u&&(b(null),h(!1))},e[0]=u,e[1]=h,e[2]=y):y=e[2];const S=y;let w;e[3]!==u||e[4]!==f||e[5]!==c||e[6]!==p||e[7]!==d?(w=async Y=>{Y.preventDefault();const G=f.trim(),Q=p.trim();if(!G||!Q||u)return;const $=Hl(Q);if($){b($);return}const X=d?.({name:G,path:Q});if(X){b(X);return}b(null),await c({name:G,path:Q})},e[3]=u,e[4]=f,e[5]=c,e[6]=p,e[7]=d,e[8]=w):w=e[8];const C=w,N=_??l,E=Qw[i];let R;e[9]!==E?(R=n.jsx(ts,{children:n.jsx(ss,{children:E})}),e[9]=E,e[10]=R):R=e[10];let T;e[11]===Symbol.for("react.memo_cache_sentinel")?(T=n.jsx("label",{htmlFor:"page-form-name",className:"text-xs font-medium text-muted-foreground",children:"Name"}),e[11]=T):T=e[11];let k;e[12]===Symbol.for("react.memo_cache_sentinel")?(k=Y=>m(Y.target.value),e[12]=k):k=e[12];let j;e[13]!==u||e[14]!==f?(j=n.jsxs("div",{className:"space-y-1.5",children:[T,n.jsx(ze,{id:"page-form-name",value:f,onChange:k,placeholder:"My page",autoFocus:!0,disabled:u})]}),e[13]=u,e[14]=f,e[15]=j):j=e[15];let I;e[16]===Symbol.for("react.memo_cache_sentinel")?(I=n.jsx("label",{htmlFor:"page-form-path",className:"text-xs font-medium text-muted-foreground",children:"Path"}),e[16]=I):I=e[16];let A;e[17]===Symbol.for("react.memo_cache_sentinel")?(A=Y=>g(Y.target.value),e[17]=A):A=e[17];let O;e[18]!==u||e[19]!==p?(O=n.jsxs("div",{className:"space-y-1.5",children:[I,n.jsx(ze,{id:"page-form-path",value:p,onChange:A,placeholder:"/example",disabled:u})]}),e[18]=u,e[19]=p,e[20]=O):O=e[20];let L;e[21]!==N?(L=N&&n.jsx("p",{className:"text-xs text-destructive",children:N}),e[21]=N,e[22]=L):L=e[22];let P;e[23]!==O||e[24]!==L||e[25]!==j?(P=n.jsxs("div",{className:"space-y-4 py-4",children:[j,O,L]}),e[23]=O,e[24]=L,e[25]=j,e[26]=P):P=e[26];let B;e[27]!==h?(B=()=>h(!1),e[27]=h,e[28]=B):B=e[28];let F;e[29]!==u||e[30]!==B?(F=n.jsx(ie,{type:"button",variant:"outline",onClick:B,disabled:u,children:"Cancel"}),e[29]=u,e[30]=B,e[31]=F):F=e[31];let H;e[32]!==u||e[33]!==f||e[34]!==p?(H=!f.trim()||!p.trim()||u,e[32]=u,e[33]=f,e[34]=p,e[35]=H):H=e[35];let z;e[36]!==u||e[37]!==i?(z=u?n.jsxs(n.Fragment,{children:[n.jsx(Oe,{size:14,className:"animate-spin"}),tC[i]]}):eC[i],e[36]=u,e[37]=i,e[38]=z):z=e[38];let W;e[39]!==H||e[40]!==z?(W=n.jsx(ie,{type:"submit",disabled:H,children:z}),e[39]=H,e[40]=z,e[41]=W):W=e[41];let q;e[42]!==F||e[43]!==W?(q=n.jsxs(Ws,{children:[F,W]}),e[42]=F,e[43]=W,e[44]=q):q=e[44];let K;e[45]!==C||e[46]!==P||e[47]!==q||e[48]!==R?(K=n.jsx(Mt,{className:"sm:max-w-md",children:n.jsxs("form",{onSubmit:C,children:[R,P,q]})}),e[45]=C,e[46]=P,e[47]=q,e[48]=R,e[49]=K):K=e[49];let Z;return e[50]!==S||e[51]!==s||e[52]!==K?(Z=n.jsx(Bt,{open:s,onOpenChange:S,children:K}),e[50]=S,e[51]=s,e[52]=K,e[53]=Z):Z=e[53],Z}function iC(t){const e=U.c(43),{open:s,blockKey:i,initialName:r,isPending:o,onSubmit:a,onOpenChange:l}=t,d=o===void 0?!1:o,[c,h]=D.useState(r),[u,f]=D.useState(s);s!==u&&(f(s),s&&h(r));let m;e[0]!==d||e[1]!==l?(m=O=>{!O&&!d&&l(!1)},e[0]=d,e[1]=l,e[2]=m):m=e[2];const p=m;let g;e[3]!==d||e[4]!==c||e[5]!==a?(g=async O=>{O.preventDefault();const L=c.trim();!L||d||await a(L)},e[3]=d,e[4]=c,e[5]=a,e[6]=g):g=e[6];const _=g;let b;e[7]===Symbol.for("react.memo_cache_sentinel")?(b=n.jsxs(ts,{children:[n.jsx(ss,{children:"Rename section"}),n.jsx(Wi,{children:"Updates the display name. The internal key stays the same so pages referencing this section keep working."})]}),e[7]=b):b=e[7];let x;e[8]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsx("label",{htmlFor:"section-rename-name",className:"text-xs font-medium text-muted-foreground",children:"Name"}),e[8]=x):x=e[8];let v;e[9]===Symbol.for("react.memo_cache_sentinel")?(v=O=>h(O.target.value),e[9]=v):v=e[9];let y;e[10]!==d||e[11]!==c?(y=n.jsxs("div",{className:"space-y-1.5",children:[x,n.jsx(ze,{id:"section-rename-name",value:c,onChange:v,autoFocus:!0,disabled:d})]}),e[10]=d,e[11]=c,e[12]=y):y=e[12];let S;e[13]===Symbol.for("react.memo_cache_sentinel")?(S=n.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Key"}),e[13]=S):S=e[13];let w;e[14]!==i?(w=n.jsxs("div",{className:"space-y-1.5",children:[S,n.jsx(ze,{value:i,readOnly:!0,disabled:!0,className:"font-mono"})]}),e[14]=i,e[15]=w):w=e[15];let C;e[16]!==y||e[17]!==w?(C=n.jsxs("div",{className:"space-y-4 py-4",children:[y,w]}),e[16]=y,e[17]=w,e[18]=C):C=e[18];let N;e[19]!==l?(N=()=>l(!1),e[19]=l,e[20]=N):N=e[20];let E;e[21]!==d||e[22]!==N?(E=n.jsx(ie,{type:"button",variant:"outline",onClick:N,disabled:d,children:"Cancel"}),e[21]=d,e[22]=N,e[23]=E):E=e[23];let R;e[24]!==d||e[25]!==c?(R=!c.trim()||d,e[24]=d,e[25]=c,e[26]=R):R=e[26];let T;e[27]!==d?(T=d?n.jsxs(n.Fragment,{children:[n.jsx(Oe,{size:14,className:"animate-spin"}),"Saving…"]}):"Save",e[27]=d,e[28]=T):T=e[28];let k;e[29]!==R||e[30]!==T?(k=n.jsx(ie,{type:"submit",disabled:R,children:T}),e[29]=R,e[30]=T,e[31]=k):k=e[31];let j;e[32]!==E||e[33]!==k?(j=n.jsxs(Ws,{children:[E,k]}),e[32]=E,e[33]=k,e[34]=j):j=e[34];let I;e[35]!==_||e[36]!==C||e[37]!==j?(I=n.jsx(Mt,{className:"sm:max-w-md",children:n.jsxs("form",{onSubmit:_,children:[b,C,j]})}),e[35]=_,e[36]=C,e[37]=j,e[38]=I):I=e[38];let A;return e[39]!==p||e[40]!==s||e[41]!==I?(A=n.jsx(Bt,{open:s,onOpenChange:p,children:I}),e[39]=p,e[40]=s,e[41]=I,e[42]=A):A=e[42],A}const Fo={post:"blog/loaders/Blogpost.ts",author:"blog/loaders/Author.ts",category:"blog/loaders/Category.ts"},fc=["posts","authors","categories"],En={posts:"post",authors:"author",categories:"category"};function Tn(t){return fc.includes(t)}const mc={posts:"post",authors:"author",categories:"category"},Em={posts:Fo.post,authors:Fo.author,categories:Fo.category},nC=Object.fromEntries(Object.entries(Em).map(([t,e])=>[e,t]));function rC(t){return typeof t=="string"?nC[t]??null:null}function Oi(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:null}function rs(t){return typeof t=="string"?t:""}function oC(t,e){switch(t){case"posts":return{label:rs(e.title)||"Untitled post",subtitle:rs(e.slug)};case"authors":return{label:rs(e.name)||"Unnamed author",subtitle:rs(e.email)};case"categories":return{label:rs(e.name)||"Unnamed category",subtitle:rs(e.slug)};default:{const s=t;throw new Error(`Unhandled blog kind: ${String(s)}`)}}}function Tm(t){const e={posts:[],authors:[],categories:[]};for(const[s,i]of Object.entries(t)){const r=Oi(i);if(!r)continue;const o=rC(r.__resolveType);if(!o)continue;const a=Oi(r[mc[o]])??{},{label:l,subtitle:d}=oC(o,a);e[o].push({key:s,kind:o,label:l,subtitle:d})}for(const s of fc)e[s].sort((i,r)=>i.label.localeCompare(r.label));return e}function aC(t,e){return Tm(t)[e]}function Kr(t,e){return aC(t,e).map(s=>({key:s.key,payload:Sa(Oi(t[s.key])??void 0,e)}))}function Sa(t,e){return t?Oi(t[mc[e]])??{}:{}}function Ho(t,e,s){return{name:t,__resolveType:Em[e],[mc[e]]:s}}function Am(t){return`.deco/blocks/${encodeURIComponent(t)}.json`}function qr(t){return Array.isArray(t)?t:[]}function pc(t){if(typeof t=="string")return t;const e=Oi(t);return e?rs(e.slug):""}function lC(t){if(typeof t=="string")return t;const e=Oi(t);return e?rs(e.email):""}function cC(t){return Kr(t,"posts").map(({key:e,payload:s})=>({key:e,title:rs(s.title)||"Untitled post",slug:rs(s.slug),date:rs(s.date),categorySlugs:qr(s.categories).map(pc).filter(Boolean),authorEmails:qr(s.authors).map(lC).filter(Boolean)}))}function dC(t,e){const s=qr(t.categories);return s.some(i=>pc(i)===e.slug)?t:{...t,categories:[...s,{name:e.name,slug:e.slug}]}}function hC(t,e){const s=qr(t.categories);return s.length===1&&pc(s[0])===e.slug?t:{...t,categories:[{name:e.name,slug:e.slug}]}}function wa(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 Pd(t,e){const s=`collections/blog/${e}/${wa(12)}`;if(!Object.hasOwn(t,s))return s;throw new Error("Could not generate a unique blog block key")}function uC(t){switch(t){case"posts":return{title:"Untitled post",excerpt:"",slug:`untitled-${wa(8)}`,date:new Date().toISOString().slice(0,10),image:"",authors:[],categories:[],sections:[]};case"authors":return{name:"New author",email:"",jobTitle:"",company:"",avatar:""};case"categories":return{name:"New category",slug:`category-${wa(8)}`,description:"",sections:[]};default:{const e=t;throw new Error(`Unhandled blog kind: ${String(e)}`)}}}const fC={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"},ProductCard:{title:"Product card",description:"Single product",iconName:"Tag01"},ProductShelf:{title:"Product shelf",description:"Row of products",iconName:"ShoppingBag01"}},Dd="Box";function mC(t){return t.startsWith("site/")?"site":"app"}function pC(t){return t.startsWith("http://")||t.startsWith("https://")||t.startsWith("data:")||t.startsWith("/")}function on(...t){for(const e of t)if(e!==void 0)return e}function NE(t){const e=new Set,s=[],i=t.manifest?.blocks??{};for(const r of Object.values(i))for(const o of Object.keys(r)){if(!vC(o)||e.has(o))continue;e.add(o);const a=fi(o,t),l=gC(o),d=fC[l],c=mC(o),h=(c==="site"?on(a.title,d?.title):on(d?.title,a.title))??l,u=c==="site"?on(a.description,d?.description):on(d?.description,a.description),f=c==="site"?a.icon:void 0,m=f&&pC(f)?f:void 0,p=m!==void 0?d?.iconName??Dd:on(f,d?.iconName)??Dd;s.push({resolveType:o,title:h,description:u,iconName:p,iconUrl:m,source:c})}return s.sort((r,o)=>r.title.localeCompare(o.title))}function gC(t){return(t.split("/").pop()??t).replace(/\.(tsx?|jsx?)$/,"")}const _C=["blog/sections/blocks/","site/sections/Blog/Post/"];function vC(t){return _C.some(e=>t.startsWith(e))}function Rm({orgSlug:t,virtualMcpId:e,branch:s}){return Et.decofile(`${t}/${e}/${s}`)}function Pm({orgSlug:t,virtualMcpId:e,branch:s},i){return`/api/${t}/sandbox/${encodeURIComponent(e)}/${encodeURIComponent(s)}/${i}`}function xC(t){const e=U.c(11),s=oi();let i;e[0]!==t?(i=async l=>{const{blockKey:d,data:c}=l,h=await fetch(Pm(t,"write"),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({path:Am(d),content:JSON.stringify(c,null,2)})});if(!h.ok){const u=await h.json().catch(bC);throw new Error(u.error??`Write failed (${h.status})`)}return h.json()},e[0]=t,e[1]=i):i=e[1];let r;e[2]!==t||e[3]!==s?(r=async l=>{const{blockKey:d,data:c}=l,h=Rm(t);await s.cancelQueries({queryKey:h});const u=s.getQueryData(h);return s.setQueryData(h,f=>({...f??{},[d]:c})),{previous:u,queryKey:h}},e[2]=t,e[3]=s,e[4]=r):r=e[4];let o;e[5]!==s?(o=(l,d,c)=>{c?.queryKey&&s.setQueryData(c.queryKey,c.previous)},e[5]=s,e[6]=o):o=e[6];let a;return e[7]!==i||e[8]!==r||e[9]!==o?(a={mutationFn:i,onMutate:r,onError:o},e[7]=i,e[8]=r,e[9]=o,e[10]=a):a=e[10],ai(a)}function bC(){return{}}function yC(t){const e=oi();return ai({mutationFn:async({blockKey:s})=>{const i=await fetch(Pm(t,"unlink"),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({path:Am(s)})});if(!i.ok){const r=await i.json().catch(()=>({}));throw new Error(r.error??`Delete failed (${i.status})`)}return i.json()},onMutate:async({blockKey:s})=>{const i=Rm(t);await e.cancelQueries({queryKey:i});const r=e.getQueryData(i);return e.setQueryData(i,o=>{if(!o)return o;const{[s]:a,...l}=o;return l}),{previous:r,queryKey:i}},onError:(s,i,r)=>{r?.queryKey&&e.setQueryData(r.queryKey,r.previous)}})}function SC(t){const e=U.c(20),{open:s,onOpenChange:i,pageKey:r,decofile:o}=t,[a,l]=D.useState(!1),d=o[r];let c;e[0]!==d?(c=d===void 0?"// Page not found.":JSON.stringify(d,null,2),e[0]=d,e[1]=c):c=e[1];const h=c;let u;e[2]!==h?(u=()=>{navigator.clipboard.writeText(h).then(()=>{l(!0),setTimeout(()=>l(!1),2e3)})},e[2]=h,e[3]=u):u=e[3];const f=u;let m;e[4]===Symbol.for("react.memo_cache_sentinel")?(m=n.jsx(ss,{className:"text-sm font-semibold",children:"Page JSON"}),e[4]=m):m=e[4];let p;e[5]!==a?(p=a?n.jsx(Yh,{size:12}):n.jsx(as,{size:12}),e[5]=a,e[6]=p):p=e[6];const g=a?"Copied":"Copy";let _;e[7]!==f||e[8]!==p||e[9]!==g?(_=n.jsxs(ts,{className:"px-4 py-3 border-b flex-row items-center justify-between space-y-0",children:[m,n.jsxs(ie,{variant:"ghost",size:"sm",onClick:f,className:"h-7 gap-1.5 text-xs",children:[p,g]})]}),e[7]=f,e[8]=p,e[9]=g,e[10]=_):_=e[10];let b;e[11]!==h?(b=n.jsx(Fi,{className:"max-h-[70vh]",children:n.jsx("pre",{className:"p-4 text-xs font-mono text-foreground/90 whitespace-pre overflow-auto",children:h})}),e[11]=h,e[12]=b):b=e[12];let x;e[13]!==_||e[14]!==b?(x=n.jsxs(Mt,{className:"max-w-2xl p-0 gap-0",children:[_,b]}),e[13]=_,e[14]=b,e[15]=x):x=e[15];let v;return e[16]!==i||e[17]!==s||e[18]!==x?(v=n.jsx(Bt,{open:s,onOpenChange:i,children:x}),e[16]=i,e[17]=s,e[18]=x,e[19]=v):v=e[19],v}const Id=D.lazy(()=>ls(()=>import("./app-editor-CSxGjHmN.js"),__vite__mapDeps([144,1,2,5,44,7,8,9,10,11,12,13,14,15,16,6,3,4,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,99,145,100,91,88,101,102,80,81,82,83,84,85,86,87,89,90,92,93,94,95,96,103,104,105,106,107,108,109,110,111,79,112,113,114,115,116,117,118,119,120,121,122,98,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140])).then(t=>({default:t.AppEditor}))),wC=D.lazy(()=>ls(()=>import("./post-editor-B3gQokNp.js"),__vite__mapDeps([146,1,2,3,28,7,8,9,10,11,12,13,14,15,16,6,4,5,17,18,19,20,21,22,23,24,25,26,27,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,131,84,85,87,132,114,133,134,135,136,96,90,105,110,111,109,92,147,145,148,80,81,82,83,86,88,89,91,93,94,95,100,101,102,103,104,106,107,108,79,112,113,115,116,117,118,119,120,121,122,98,123,124,125,126,127,128,129,130,137,138,139,140])).then(t=>({default:t.PostEditor}))),CC=D.lazy(()=>ls(()=>import("./record-editor-BZDypwa5.js"),__vite__mapDeps([149,1,2,77,76,92,147,33,37,145,8,6,100,56,57,54,55,58,59,60,61,62,63,64,51,65,44,7,9,10,11,12,13,14,15,16,3,4,5,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,34,35,36,38,39,40,41,42,43,45,46,47,48,49,50,52,53,66,67,68,69,70,71,72,73,74,75,78,91,88,101,102,80,81,82,83,84,85,86,87,89,90,93,94,95,96,103,104,105,106,107,108,109,110,111,79,112,113,114,115,116,117,118,119,120,121,122,98,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140])).then(t=>({default:t.RecordEditor}))),kC=D.lazy(()=>ls(()=>import("./category-editor-vCwJctBK.js"),__vite__mapDeps([150,1,2,12,7,8,9,10,11,13,14,15,16,6,3,4,5,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,77,76,147,145,148,80,81,82,83,73,62,54,55,65,64,84,85,86,87,71,88,89,90,50,91,48,75,78,92,93,94,95,96,63,110,111,109,44,45,46,47,49,51,52,53,56,57,58,59,60,61,66,67,68,69,70,72,74,100,101,102,103,104,105,106,107,108,79,112,113,114,115,116,117,118,119,120,121,122,98,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140])).then(t=>({default:t.CategoryEditor}))),jC=D.lazy(()=>ls(()=>import("./sections-editor-DAz_riff.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])).then(t=>({default:t.SectionsEditor}))),NC=D.lazy(()=>ls(()=>import("./seo-editor-qYixYUVP.js"),__vite__mapDeps([151,1,2,5,7,8,9,10,11,12,13,14,15,16,6,3,4,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,97,98,100,91,88,101,102,80,81,82,83,84,85,86,87,89,90,92,93,94,95,96,103,104,105,106,107,108,109,110,111,79,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])).then(t=>({default:t.SeoEditor}))),EC=D.lazy(()=>ls(()=>import("./variant-calendar-BwPeBwqf.js"),__vite__mapDeps([152,1,2,7,8,9,10,11,12,13,14,15,16,6,3,4,5,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,130])).then(t=>({default:t.VariantCalendar}))),Ca="oklch(0.65 0.15 160)";function TC(t){return t.split("/").pop()?.replace(/\.tsx?$/,"")||t||"Section"}function AC(t){const e=new Map;for(const s of t){const i=TC(s.resolveType),r=e.get(i);r?r.push(s):e.set(i,[s])}return[...e.entries()].map(([s,i])=>({label:s,sections:i})).sort((s,i)=>s.label.localeCompare(i.label))}function RC(){const t=U.c(18),e=gi(),{data:s}=$i.useSession(),{currentBranch:i}=Ts(),{org:r}=Me(),o=e?.entity?.id??null,a=s?.user?.id,l=e?.entity?.metadata,d=a&&i?to(l?.sandboxMap?.[a]?.[i]):{},c=Object.values(d),u=(c.find(PC)??c[0])?.previewUrl??null,f=bs(),m=e?.entity?.organization_id??"";let p;t[0]!==r.slug||t[1]!==m?(p={connectionId:ul,orgId:m,orgSlug:r.slug},t[0]=r.slug,t[1]=m,t[2]=p):p=t[2];const g=Pt(p),_=ll(g);let b;t[3]!==i||t[4]!==_||t[5]!==o?(b=()=>{if(!o)return;const w={virtualMcpId:o};i&&(w.branch=i),_.mutate(w)},t[3]=i,t[4]=_,t[5]=o,t[6]=b):b=t[6];const x=b,v=!!o&&!!i&&oa.isStopped(o,i),y=wf({previewUrl:u,appPaused:f.status.state==="paused",userStopped:v});if(y.kind!=="iframe"){let w;return t[7]!==y||t[8]!==x||t[9]!==f.lifecycle||t[10]!==f.phase?(w=n.jsx(QC,{state:y,claimPhase:f.phase,lifecycle:f.lifecycle,onStart:x}),t[7]=y,t[8]=x,t[9]=f.lifecycle,t[10]=f.phase,t[11]=w):w=t[11],w}if(!o||!i){let w;return t[12]===Symbol.for("react.memo_cache_sentinel")?(w=n.jsx(ki,{title:"Waiting for sandbox context…"}),t[12]=w):w=t[12],w}let S;return t[13]!==i||t[14]!==r.slug||t[15]!==u||t[16]!==o?(S=n.jsx(IC,{orgSlug:r.slug,virtualMcpId:o,branch:i,previewUrl:u}),t[13]=i,t[14]=r.slug,t[15]=u,t[16]=o,t[17]=S):S=t[17],S}function PC(t){return t.sandboxProviderKind!=="user-desktop"}const Ld=2e3,DC=15;function Od(t,e,s,i){return typeof e!="string"||s&&(lm(e,s,i)||t.state.dataUpdateCount>=DC)?!1:Ld}function IC({orgSlug:t,virtualMcpId:e,branch:s,previewUrl:i}){const r={orgSlug:t,virtualMcpId:e,branch:s,previewUrl:i},{data:o,isLoading:a}=Ol(r),[l,d]=D.useState("pages"),[c,h]=D.useState(null),[u,f]=D.useState(null),[m,p]=D.useState(""),[g,_]=D.useState(null),[b,x]=D.useState(null),[v,y]=D.useState("date-desc"),[S,w]=D.useState(()=>new Set),[C,N]=D.useState(l);C!==l&&(N(l),p(""),_(null),x(null),y("date-desc"),w(new Set));const{data:E,isLoading:R,isFetching:T}=Bl(r,{refetchInterval:M=>{const ue=M.state.data;if(l==="apps"&&c&&c.collection==="apps"){const ge=o?.[c.key];return Od(M,typeof ge?.__resolveType=="string"?ge.__resolveType:void 0,ue)}if(l==="site"&&o){const ge=ue?va(o,ue):null,ke=o.site,Je=ge?.resolveType??(typeof ke?.__resolveType=="string"?ke.__resolveType:void 0);return Od(M,Je,ue,["seo"])}return!1}}),k=(M,ue)=>!lm(M,E,ue)&&(R||T),{catalog:j,isLoading:I}=x2(E??void 0,o??void 0,{enabled:l==="apps"}),A=nc(r),O=d2(r),L=xC(r),P=yC(r),[B,F]=D.useState(null),[H,z]=D.useState(),[W,q]=D.useState(null),[K,Z]=D.useState(null),[Y,G]=D.useState(null),[Q,$]=D.useState(null);if(a||R)return n.jsx("div",{className:"h-full w-full flex items-center justify-center",children:n.jsx(Oe,{size:20,className:"animate-spin text-muted-foreground"})});if(!o||!E)return n.jsx(ki,{title:"Could not load site data."});const X=Vl(o).sort((M,ue)=>M.name.localeCompare(ue.name)),V=ql(o,E),se=l==="sections"?ex(E):[],ee=va(o,E),le=Tm(o),ce=fc.some(M=>le[M].length>0),fe=Tn(l)?le[l]:[],J=(ce?Kr(o,"categories"):[]).map(({key:M,payload:ue})=>{const ge=typeof ue.slug=="string"?ue.slug:"",ke=typeof ue.name=="string"?ue.name:"";return{slug:ge||M,name:ke||ge||M}}).filter(M=>M.slug).sort((M,ue)=>M.name.localeCompare(ue.name));if(!Wl(o,E)&&!ce)return n.jsx(ki,{icon:zi,title:"No editable content",description:"This project doesn't expose any Deco pages, sections, or apps."});const te={pages:X.length,sections:V.length,apps:j.length,posts:le.posts.length,authors:le.authors.length,categories:le.categories.length},oe=new Set(X.map(M=>Ti(M.path))),de=new Set(X.map(M=>M.name)),be=new Set(V.map(M=>M.name)),ve=async M=>{const ue=o[M.key];if(!ue)return;const ge=em(o,M.key),ke=tm(o,M.key,Math.max(0,ge-1)),Je=b0(ue.sections,ke);if(Je)try{await A.mutateAsync({blockKey:M.key,data:{...ue,sections:Je}}),he.success(`Variant added to "${M.name}"`),h({collection:"pages",key:M.key,path:M.path})}catch(mt){he.error(mt instanceof Error?mt.message:"Could not add variant")}},we=()=>{z(void 0),F({mode:"create",sourceKey:null,initialName:"My new page",initialPath:"/example"})},De=M=>{z(void 0),F({mode:"duplicate",sourceKey:M.key,initialName:Rd(de,M.name),initialPath:qw(oe,M.path)})},Be=M=>{z(void 0),F({mode:"rename",sourceKey:M.key,initialName:M.name,initialPath:M.path})},Pe=async M=>{if(!B)return;const{mode:ue,sourceKey:ge}=B;try{if(ue==="create"){const ke=Xw(M.name,M.path),Je=Zw(o,M.name);await A.mutateAsync({blockKey:Je,data:ke}),he.success(`Created "${M.name}"`),h({collection:"pages",key:Je,path:M.path})}else if(ue==="duplicate"&&ge){const ke=o[ge];if(!ke)throw new Error("Source page not found");const{key:Je,data:mt}=Yw({source:ke,pages:X,newName:M.name,newPath:M.path});await A.mutateAsync({blockKey:Je,data:mt}),he.success(`Duplicated as "${M.name}"`),h({collection:"pages",key:Je,path:M.path})}else if(ue==="rename"&&ge){const ke=o[ge];if(!ke)throw new Error("Page not found");const Je={...ke,name:M.name,path:M.path};await A.mutateAsync({blockKey:ge,data:Je}),he.success("Page updated"),c?.collection==="pages"&&c.key===ge&&h({collection:"pages",key:ge,path:M.path})}F(null)}catch(ke){z(ke instanceof Error?ke.message:"Save failed")}},Fe=({path:M})=>{if(!B)return null;const ue=Ti(M);return(B.mode==="rename"?Ti(B.initialPath):null)!==ue&&oe.has(ue)?`A page with path "${M}" already exists.`:null},xe=async(M,ue,ge)=>{await A.mutateAsync({blockKey:ue,data:{...ge,name:ue,__resolveType:M}}),he.success(`Created section "${ue}"`),h({collection:"sections",key:ue})},ye=S2((M,ue)=>A.mutate({blockKey:M,data:ue})),Ie=async M=>{const ue=o[M.key];if(!ue){he.error("Section not found.");return}const ge=Gw(o,M.key),ke=Rd(be,M.name),Je={...ue,name:ke};try{await A.mutateAsync({blockKey:ge,data:Je}),he.success(`Duplicated "${M.name}"`),h({collection:"sections",key:ge})}catch(mt){he.error(mt instanceof Error?mt.message:"Duplicate failed")}},Le=async M=>{if(!W)return;const ue=o[W];if(!ue){he.error("Section not found.");return}try{await A.mutateAsync({blockKey:W,data:{...ue,name:M}}),he.success("Section renamed"),q(null)}catch(ge){he.error(ge instanceof Error?ge.message:"Rename failed")}},qe=async M=>{const ue=Pd(o,M),ge=Ho(ue,M,uC(M));try{await L.mutateAsync({blockKey:ue,data:ge}),he.success(`Created ${En[M]}`),h({collection:M,key:ue})}catch(ke){he.error(ke instanceof Error?ke.message:"Could not create")}},st=async M=>{const ue=o[M.key];if(!ue){he.error("Record not found.");return}const ge=Pd(o,M.kind),ke=M.kind==="posts"?"title":"name",Je={...structuredClone(Sa(ue,M.kind)),[ke]:`${M.label} (copy)`};try{await L.mutateAsync({blockKey:ge,data:Ho(ge,M.kind,Je)}),he.success(`Duplicated "${M.label}"`),h({collection:M.kind,key:ge})}catch(mt){he.error(mt instanceof Error?mt.message:"Duplicate failed")}},ct=M=>{w(ue=>{const ge=new Set(ue);return ge.has(M)?ge.delete(M):ge.add(M),ge})},Se=M=>{d("posts"),N("posts"),h(null),f(null),p(""),_(M),x(null),y("date-desc"),w(new Set)},pe=async(M,ue)=>{const ge=[...S];let ke=0;for(const Je of ge){const mt=o[Je],Vs=Sa(mt,"posts"),tn=M==="add"?dC(Vs,ue):hC(Vs,ue);tn!==Vs&&(await L.mutateAsync({blockKey:Je,data:Ho(Je,"posts",tn)}),ke+=1)}return ke},$e=async(M,ue)=>{const ge=S.size;try{const ke=await pe(M,ue),Je=M==="add"?"Added to":"Moved",mt=ge-ke;he.success(`${Je} ${ke} ${ke===1?"post":"posts"}`+(mt>0?` (${mt} already set)`:"")),w(new Set),$(null)}catch(ke){he.error(ke instanceof Error?ke.message:"Bulk update failed")}},Ge=async()=>{if(K)try{if(K.kind==="blog-bulk"){for(const ke of K.keys)await P.mutateAsync({blockKey:ke});he.success(`Deleted ${K.count} ${K.count===1?"post":"posts"}`),c&&c.collection!=="available-section"&&K.keys.includes(c.key)&&h(null),w(new Set),Z(null);return}const{kind:M,key:ue,label:ge}=K;M==="blog"?await P.mutateAsync({blockKey:ue}):await O.mutateAsync({blockKey:ue}),he.success(`Deleted "${ge}"`),c&&c.collection!=="available-section"&&c.key===ue&&h(null),Z(null)}catch(M){he.error(M instanceof Error?M.message:"Delete failed")}},He=O.isPending||P.isPending,Ye=K?.kind==="blog"?En[K.blogKind]:K?.kind==="blog-bulk"?`${K.count} ${K.count===1?"post":"posts"}`:K?.kind??"item";return n.jsxs("div",{className:"flex h-full w-full",children:[n.jsx(OC,{active:l,counts:te,showBlog:ce,onSelect:M=>{d(M),h(null),f(null)}}),l!=="seo"&&l!=="site"&&l!=="calendar"&&n.jsx(BC,{activeCollection:l,pages:X,sections:V,availableSections:se,appCatalog:j,appCatalogLoading:I,blogEntries:fe,decofile:o,searchQuery:m,onSearchChange:p,postCategoryFilter:g,postAuthorFilter:b,postSort:v,onPostCategoryFilterChange:M=>{_(M),w(new Set)},onPostAuthorFilterChange:M=>{x(M),w(new Set)},onPostSortChange:y,selectedPostKeys:S,onTogglePostSelect:ct,onSelectAllPosts:M=>w(new Set(M)),onClearPostSelection:()=>w(new Set),onBulkUpdateCategory:()=>$({count:S.size}),onBulkDeletePosts:()=>Z({kind:"blog-bulk",keys:[...S],count:S.size}),selection:c,onSelect:M=>{h(M),f(null)},onCreate:()=>{l==="pages"?we():Tn(l)&&qe(l)},onDuplicatePage:De,onRenamePage:Be,onAddPageVariant:ve,onDeletePage:M=>Z({kind:"page",key:M.key,label:M.name}),onEditPageSeo:M=>{h({collection:"pages",key:M.key,path:M.path}),f(M.key)},onViewPageJson:M=>G(M.key),onDuplicateSection:Ie,onRenameSection:M=>q(M.key),onDeleteSection:M=>Z({kind:"section",key:M.key,label:M.name}),onDuplicateBlog:st,onDeleteBlog:M=>Z({kind:"blog",blogKind:M.kind,key:M.key,label:M.label})}),n.jsx("div",{className:"flex-1 min-w-0",children:n.jsx(D.Suspense,{fallback:n.jsx("div",{className:"h-full flex items-center justify-center",children:n.jsx(Oe,{size:20,className:"animate-spin text-muted-foreground"})}),children:l==="calendar"?n.jsx(EC,{decofile:o}):l==="site"?ee?n.jsx(Id,{orgSlug:t,virtualMcpId:e,branch:s,blockKey:ee.key,block:o[ee.key],decofile:o,meta:E,title:"Site",excludeFields:["seo"],schemaPending:k(ee.resolveType,["seo"]),previewBaseUrl:i},`site:${ee.key}`):n.jsx(ki,{title:"Site settings not found",description:"This project doesn't have a site app block (site/apps/site.ts)."}):l==="seo"?n.jsx(NC,{orgSlug:t,virtualMcpId:e,branch:s,decofile:o,meta:E,target:{kind:"site"},previewBaseUrl:i}):l==="sections"?n.jsx(LC,{selection:c?.collection==="sections"||c?.collection==="available-section"?c:null,orgSlug:t,virtualMcpId:e,branch:s,previewUrl:i,meta:E,decofile:o,isCreating:A.isPending,onCreateAvailable:xe,onSaveReferencedBlock:ye}):c&&c.collection!=="available-section"?c.collection==="apps"?n.jsx(Id,{orgSlug:t,virtualMcpId:e,branch:s,blockKey:c.key,block:o[c.key],decofile:o,meta:E,previewBaseUrl:i,schemaPending:k(typeof o[c.key]?.__resolveType=="string"?String(o[c.key].__resolveType):void 0)},`app:${c.key}`):c.collection==="posts"?n.jsx(wC,{orgSlug:t,virtualMcpId:e,branch:s,blockKey:c.key,block:o[c.key],decofile:o,meta:E,previewBaseUrl:i},`post:${c.key}`):c.collection==="categories"?n.jsx(kC,{orgSlug:t,virtualMcpId:e,branch:s,blockKey:c.key,block:o[c.key],decofile:o,meta:E,onManagePosts:Se},`category:${c.key}`):c.collection==="authors"?n.jsx(CC,{orgSlug:t,virtualMcpId:e,branch:s,kind:"authors",blockKey:c.key,block:o[c.key]},`authors:${c.key}`):n.jsx(jC,{orgSlug:t,virtualMcpId:e,branch:s,previewReady:!0,previewUrl:i??void 0,currentPath:c.collection==="pages"?c.path:"/",activePageBlockKey:c.collection==="pages"?c.key:null,activeGlobalBlockKey:c.collection==="sections"?c.key:null,initialEditSeo:c.collection==="pages"&&u===c.key,onExitSeo:()=>f(null)},c.collection==="pages"?`page:${c.key}`:`section:${c.key}`):n.jsx(ki,{title:`Select ${Tn(l)?`a ${En[l]}`:l==="pages"?"a page":l==="apps"?"an app":"a section"} to edit`,description:l==="apps"?"Browse all apps and select an installed one to edit its settings.":'Pick an item from the list, or click "+" to create one.'})})}),B&&n.jsx(sC,{open:!!B,mode:B.mode,initialName:B.initialName,initialPath:B.initialPath,isPending:A.isPending,error:H,validate:Fe,onSubmit:Pe,onOpenChange:M=>{M||(F(null),z(void 0))}}),W&&n.jsx(iC,{open:!!W,blockKey:W,initialName:V.find(M=>M.key===W)?.name??W,isPending:A.isPending,onSubmit:Le,onOpenChange:M=>{M||q(null)}}),Y&&n.jsx(SC,{open:!!Y,onOpenChange:M=>{M||G(null)},pageKey:Y,decofile:o}),Q&&n.jsx(YC,{count:Q.count,categories:J,isPending:L.isPending,onApply:(M,ue)=>{$e(M,ue)},onOpenChange:M=>{!M&&!L.isPending&&$(null)}}),n.jsx(jr,{open:!!K,onOpenChange:M=>{!M&&!He&&Z(null)},children:n.jsxs(Nr,{children:[n.jsxs(Er,{children:[n.jsx(Tr,{children:`Delete ${Ye}?`}),n.jsx(Ar,{children:K?.kind==="section"?`"${K.label}" will be removed. Pages that still reference it will lose this section.`:K?.kind==="blog-bulk"?`${K.count} ${K.count===1?"post":"posts"} will be removed permanently. This can't be undone.`:K?`"${K.label}" will be removed permanently. This can't be undone.`:null})]}),n.jsxs(Rr,{children:[n.jsx(Pr,{disabled:He,children:"Cancel"}),n.jsx(Dr,{onClick:M=>{M.preventDefault(),Ge()},disabled:He,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:He?n.jsxs(n.Fragment,{children:[n.jsx(Oe,{size:14,className:"animate-spin"}),"Deleting…"]}):"Delete"})]})]})})]})}function LC(t){const e=U.c(30),{selection:s,orgSlug:i,virtualMcpId:r,branch:o,previewUrl:a,meta:l,decofile:d,isCreating:c,onCreateAvailable:h,onSaveReferencedBlock:u}=t;if(!s){let p;return e[0]===Symbol.for("react.memo_cache_sentinel")?(p=n.jsx(ki,{title:"Select a section to edit",description:"Pick a saved section to edit it, or an available one to customize and save as global."}),e[0]=p):p=e[0],p}if(s.collection==="available-section"){const p=`available:${s.resolveType}`,g=s.resolveType,_=s.title;let b;e[1]!==s.title?(b=b2(s.title),e[1]=s.title,e[2]=b):b=e[2];let x;e[3]!==h||e[4]!==s.resolveType?(x=(y,S)=>h(s.resolveType,y,S),e[3]=h,e[4]=s.resolveType,e[5]=x):x=e[5];let v;return e[6]!==o||e[7]!==d||e[8]!==c||e[9]!==l||e[10]!==u||e[11]!==i||e[12]!==a||e[13]!==s.resolveType||e[14]!==s.title||e[15]!==p||e[16]!==b||e[17]!==x||e[18]!==r?(v=n.jsx(Uw,{orgSlug:i,virtualMcpId:r,branch:o,previewUrl:a,meta:l,decofile:d,resolveType:g,title:_,defaultBlockId:b,isCreating:c,onCreate:x,onSaveReferencedBlock:u},p),e[6]=o,e[7]=d,e[8]=c,e[9]=l,e[10]=u,e[11]=i,e[12]=a,e[13]=s.resolveType,e[14]=s.title,e[15]=p,e[16]=b,e[17]=x,e[18]=r,e[19]=v):v=e[19],v}const f=`saved:${s.key}`;let m;return e[20]!==o||e[21]!==d||e[22]!==l||e[23]!==u||e[24]!==i||e[25]!==a||e[26]!==s.key||e[27]!==f||e[28]!==r?(m=n.jsx(Kw,{orgSlug:i,virtualMcpId:r,branch:o,previewUrl:a,meta:l,decofile:d,blockKey:s.key,onSaveReferencedBlock:u},f),e[20]=o,e[21]=d,e[22]=l,e[23]=u,e[24]=i,e[25]=a,e[26]=s.key,e[27]=f,e[28]=r,e[29]=m):m=e[29],m}function Bd(t){const e=U.c(8),{icon:s,label:i,className:r}=t;let o;e[0]!==r?(o=ae("flex items-center gap-1.5 px-2.5 pb-1 pt-1 text-xs font-medium text-muted-foreground/70",r),e[0]=r,e[1]=o):o=e[1];let a;e[2]!==s?(a=n.jsx(s,{size:13,className:"shrink-0"}),e[2]=s,e[3]=a):a=e[3];let l;return e[4]!==i||e[5]!==o||e[6]!==a?(l=n.jsxs("div",{className:o,children:[a,i]}),e[4]=i,e[5]=o,e[6]=a,e[7]=l):l=e[7],l}function OC(t){const e=U.c(37),{active:s,counts:i,showBlog:r,onSelect:o}=t;let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx("div",{className:"px-3 h-12 flex items-center border-b shrink-0",children:n.jsx("span",{className:"text-sm font-medium",children:"Content"})}),e[0]=a):a=e[0];const l=s==="pages";let d;e[1]!==i.pages||e[2]!==o||e[3]!==l?(d=n.jsx(Ss,{id:"pages",icon:Ni,label:"Pages",count:i.pages,active:l,onSelect:o}),e[1]=i.pages,e[2]=o,e[3]=l,e[4]=d):d=e[4];const c=s==="sections";let h;e[5]!==i.sections||e[6]!==o||e[7]!==c?(h=n.jsx(Ss,{id:"sections",icon:si,label:"Sections",count:i.sections,active:c,onSelect:o}),e[5]=i.sections,e[6]=o,e[7]=c,e[8]=h):h=e[8];const u=s==="apps";let f;e[9]!==i.apps||e[10]!==o||e[11]!==u?(f=n.jsx(Ss,{id:"apps",icon:Vu,label:"Apps",count:i.apps,active:u,onSelect:o}),e[9]=i.apps,e[10]=o,e[11]=u,e[12]=f):f=e[12];const m=s==="calendar";let p;e[13]!==o||e[14]!==m?(p=n.jsx(Ss,{id:"calendar",icon:Eu,label:"Calendar",active:m,onSelect:o}),e[13]=o,e[14]=m,e[15]=p):p=e[15];let g;e[16]!==s||e[17]!==i.authors||e[18]!==i.categories||e[19]!==i.posts||e[20]!==o||e[21]!==r?(g=r&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"mt-3 flex items-center gap-1.5 px-2.5 pb-1 pt-1 text-xs font-medium text-muted-foreground/70",children:[n.jsx(pa,{size:13,className:"shrink-0"}),"Blog"]}),n.jsx(Ss,{id:"posts",icon:Ri,label:"Posts",count:i.posts,active:s==="posts",onSelect:o}),n.jsx(Ss,{id:"authors",icon:co,label:"Authors",count:i.authors,active:s==="authors",onSelect:o}),n.jsx(Ss,{id:"categories",icon:ro,label:"Categories",count:i.categories,active:s==="categories",onSelect:o})]}),e[16]=s,e[17]=i.authors,e[18]=i.categories,e[19]=i.posts,e[20]=o,e[21]=r,e[22]=g):g=e[22];const _=s==="site";let b;e[23]!==o||e[24]!==_?(b=n.jsx(Ss,{id:"site",icon:z_,label:"Site",active:_,onSelect:o}),e[23]=o,e[24]=_,e[25]=b):b=e[25];const x=s==="seo";let v;e[26]!==o||e[27]!==x?(v=n.jsx(Ss,{id:"seo",icon:kr,label:"SEO",active:x,onSelect:o}),e[26]=o,e[27]=x,e[28]=v):v=e[28];let y;return e[29]!==g||e[30]!==b||e[31]!==v||e[32]!==d||e[33]!==h||e[34]!==f||e[35]!==p?(y=n.jsxs("div",{className:"w-[208px] shrink-0 border-r flex flex-col",children:[a,n.jsxs("nav",{className:"flex flex-col p-1.5 gap-0.5",children:[d,h,f,p,g,b,v]})]}),e[29]=g,e[30]=b,e[31]=v,e[32]=d,e[33]=h,e[34]=f,e[35]=p,e[36]=y):y=e[36],y}function Ss(t){const e=U.c(18),{id:s,icon:i,label:r,count:o,active:a,onSelect:l}=t;let d;e[0]!==s||e[1]!==l?(d=()=>l(s),e[0]=s,e[1]=l,e[2]=d):d=e[2];const c=a?"bg-accent text-accent-foreground":"text-muted-foreground hover:bg-muted hover:text-foreground";let h;e[3]!==c?(h=ae("flex w-full items-center gap-2 rounded-md px-2.5 py-1.5 text-left text-sm transition-colors cursor-pointer",c),e[3]=c,e[4]=h):h=e[4];let u;e[5]!==i?(u=n.jsx(i,{size:16,className:"shrink-0"}),e[5]=i,e[6]=u):u=e[6];let f;e[7]!==r?(f=n.jsx("span",{className:"flex-1 truncate",children:r}),e[7]=r,e[8]=f):f=e[8];let m;e[9]!==a||e[10]!==o?(m=o!==void 0&&n.jsx("span",{className:ae("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]!==d||e[13]!==h||e[14]!==u||e[15]!==f||e[16]!==m?(p=n.jsxs("button",{type:"button",onClick:d,className:h,children:[u,f,m]}),e[12]=d,e[13]=h,e[14]=u,e[15]=f,e[16]=m,e[17]=p):p=e[17],p}function BC(t){const e=U.c(75),{activeCollection:s,pages:i,sections:r,availableSections:o,appCatalog:a,appCatalogLoading:l,blogEntries:d,decofile:c,searchQuery:h,onSearchChange:u,postCategoryFilter:f,postAuthorFilter:m,postSort:p,onPostCategoryFilterChange:g,onPostAuthorFilterChange:_,onPostSortChange:b,selectedPostKeys:x,onTogglePostSelect:v,onSelectAllPosts:y,onClearPostSelection:S,onBulkUpdateCategory:w,onBulkDeletePosts:C,selection:N,onSelect:E,onCreate:R,onDuplicatePage:T,onRenamePage:k,onAddPageVariant:j,onDeletePage:I,onEditPageSeo:A,onViewPageJson:O,onDuplicateSection:L,onRenameSection:P,onDeleteSection:B,onDuplicateBlog:F,onDeleteBlog:H}=t;let z,W,q,K,Z,Y,G;if(e[0]!==s||e[1]!==a||e[2]!==l||e[3]!==o||e[4]!==d||e[5]!==c||e[6]!==j||e[7]!==C||e[8]!==w||e[9]!==S||e[10]!==R||e[11]!==H||e[12]!==I||e[13]!==B||e[14]!==F||e[15]!==T||e[16]!==L||e[17]!==A||e[18]!==_||e[19]!==g||e[20]!==b||e[21]!==k||e[22]!==P||e[23]!==u||e[24]!==E||e[25]!==y||e[26]!==v||e[27]!==O||e[28]!==i||e[29]!==m||e[30]!==f||e[31]!==p||e[32]!==h||e[33]!==r||e[34]!==x||e[35]!==N){const V=h.toLowerCase(),se=i.filter(M=>!V||M.name.toLowerCase().includes(V)||M.path.toLowerCase().includes(V)),ee=r.filter(M=>!V||M.name.toLowerCase().includes(V)||M.key.toLowerCase().includes(V)||M.resolveType.toLowerCase().includes(V)),le=o.filter(M=>!V||M.title.toLowerCase().includes(V)||M.resolveType.toLowerCase().includes(V)||(M.description?.toLowerCase().includes(V)??!1)),ce=AC(ee),fe=a.filter(M=>!V||M.title.toLowerCase().includes(V)||M.app.toLowerCase().includes(V)||M.vendor.toLowerCase().includes(V)||M.category.toLowerCase().includes(V)),J=d.filter(M=>!V||M.label.toLowerCase().includes(V)||M.subtitle.toLowerCase().includes(V)),te=s==="posts",oe=FC,de=te?cC(c):[],be=new Map,ve=new Map;for(const M of de){for(const ue of M.categorySlugs)be.set(ue,(be.get(ue)??0)+1);for(const ue of M.authorEmails)ve.set(ue,(ve.get(ue)??0)+1)}const we=(te?Kr(c,"categories"):[]).map(M=>{const{key:ue,payload:ge}=M,ke=oe(ge.slug)||ue;return{slug:ke,name:oe(ge.name)||oe(ge.slug)||ue,count:be.get(ke)??0}}).filter(zC),De=(te?Kr(c,"authors"):[]).map(M=>{const{key:ue,payload:ge}=M,ke=oe(ge.email);return{email:ke,name:oe(ge.name)||oe(ge.email)||ue,count:ve.get(ke)??0}}).filter($C);let Be;e[43]!==f?(Be=M=>!f||M.categorySlugs.includes(f),e[43]=f,e[44]=Be):Be=e[44];let Pe;e[45]!==m?(Pe=M=>!m||M.authorEmails.includes(m),e[45]=m,e[46]=Pe):Pe=e[46];let Fe;e[47]!==p?(Fe=(M,ue)=>{if(p==="az")return M.title.localeCompare(ue.title);if(p==="za")return ue.title.localeCompare(M.title);const ge=M.date.localeCompare(ue.date);return p==="date-asc"?ge:-ge},e[47]=p,e[48]=Fe):Fe=e[48];const xe=de.filter(M=>!V||M.title.toLowerCase().includes(V)||M.slug.toLowerCase().includes(V)).filter(Be).filter(Pe).sort(Fe),ye=x.size,Ie=xe.map(MC),Le=Ie.length>0&&Ie.every(M=>x.has(M)),qe=ye>0,st=()=>{Le?S():y(Ie)},ct=`Search ${s}…`,Se=Tn(s)?`Create new ${En[s]}`:"Create new page",pe=s!=="apps"&&s!=="sections";Z="w-[300px] shrink-0 border-r flex flex-col min-h-0";let $e;e[49]===Symbol.for("react.memo_cache_sentinel")?($e=n.jsx(Wu,{size:14,className:"shrink-0 text-muted-foreground","aria-hidden":!0}),e[49]=$e):$e=e[49];let Ge;e[50]!==u?(Ge=M=>u(M.target.value),e[50]=u,e[51]=Ge):Ge=e[51];let He;e[52]!==ct||e[53]!==h||e[54]!==Ge?(He=n.jsxs("div",{className:"flex flex-1 items-center gap-2 pl-1",children:[$e,n.jsx("input",{type:"text",value:h,onChange:Ge,placeholder:ct,"aria-label":ct,className:"w-full bg-transparent text-sm outline-none placeholder:text-muted-foreground"})]}),e[52]=ct,e[53]=h,e[54]=Ge,e[55]=He):He=e[55];let Ye;e[56]!==Se||e[57]!==R||e[58]!==pe?(Ye=pe&&n.jsxs(Te,{children:[n.jsx(Ne,{asChild:!0,children:n.jsx(ie,{variant:"ghost",size:"icon",onClick:R,"aria-label":Se,children:n.jsx(Dt,{size:14})})}),n.jsx(Ee,{side:"bottom",children:Se})]}),e[56]=Se,e[57]=R,e[58]=pe,e[59]=Ye):Ye=e[59],e[60]!==He||e[61]!==Ye?(Y=n.jsxs("div",{className:"px-2 h-12 flex items-center gap-1 border-b shrink-0",children:[He,Ye]}),e[60]=He,e[61]=Ye,e[62]=Y):Y=e[62],G=te&&(qe?n.jsx(GC,{count:ye,allSelected:Le,onToggleSelectAll:st,onUpdateCategory:w,onDelete:C,onClear:S}):n.jsx(UC,{categories:we,authors:De,categoryFilter:f,authorFilter:m,sort:p,hasPosts:de.length>0,allSelected:Le,onToggleSelectAll:st,onCategoryFilterChange:g,onAuthorFilterChange:_,onSortChange:b})),z=Fi,K="flex-1 min-h-0 [&_[data-slot=scroll-area-viewport]>div]:!block",W="flex flex-col gap-1 p-1.5",q=s==="pages"?se.length===0?n.jsx(an,{hasItems:i.length>0,emptyLabel:"No pages yet.",emptyHint:'Click "+" to create your first page.'}):se.map(M=>{const ue=N?.collection==="pages"&&N.key===M.key,ge=em(c,M.key);return n.jsx(bi,{icon:Ni,title:M.name,subtitle:M.path,active:ue,variantCount:ge,onClick:()=>E({collection:"pages",key:M.key,path:M.path}),menu:n.jsx(lr,{onDuplicate:()=>T(M),onRename:()=>k(M),onAddVariant:()=>j(M),onEditSeo:()=>A(M),onViewJson:()=>O(M),onDelete:()=>I(M)})},M.key)}):s==="sections"?ee.length===0&&le.length===0?n.jsx(an,{hasItems:r.length>0||o.length>0,emptyLabel:"No sections yet.",emptyHint:"Save a section from a page, or start the preview dev server."}):n.jsxs(n.Fragment,{children:[ce.length>0&&n.jsxs(n.Fragment,{children:[n.jsx(Bd,{icon:si,label:"Saved sections"}),ce.map(M=>n.jsxs("div",{className:"flex flex-col gap-1",children:[n.jsx("div",{className:"px-2.5 pt-1 pb-0.5 text-[11px] font-medium uppercase tracking-wide text-muted-foreground/60",children:M.label}),M.sections.map(ue=>{const ge=N?.collection==="sections"&&N.key===ue.key;return n.jsx(bi,{icon:si,accent:"global",title:ue.name,subtitle:M.label,active:ge,onClick:()=>E({collection:"sections",key:ue.key}),menu:n.jsx(lr,{onDuplicate:()=>L(ue),onRename:()=>P(ue),onDelete:()=>B(ue)})},ue.key)})]},M.label))]}),le.length>0&&n.jsxs(n.Fragment,{children:[n.jsx(Bd,{icon:Ni,label:"Available sections",className:ae(ce.length>0&&"mt-3")}),le.map(M=>{const ue=N?.collection==="available-section"&&N.resolveType===M.resolveType,ge=M.resolveType.split("/").pop()?.replace(/\.tsx?$/,"");return n.jsx(bi,{icon:Ni,title:M.title,subtitle:ge??M.resolveType,active:ue,onClick:()=>E({collection:"available-section",resolveType:M.resolveType,title:M.title})},M.resolveType)})]})]}):s==="apps"?l?n.jsx("div",{className:"flex items-center justify-center py-8",children:n.jsx(Oe,{size:18,className:"animate-spin text-muted-foreground"})}):fe.length===0?n.jsx(an,{hasItems:a.length>0,emptyLabel:"No apps found.",emptyHint:"Try a different search term."}):fe.map(M=>{const ue=N?.collection==="apps"&&M.blockKey!==null&&N.key===M.blockKey;return n.jsx(bi,{icon:Vu,logoUrl:M.logo,title:M.title,subtitle:M.category,active:ue,trailing:M.installed?n.jsx("span",{className:"shrink-0 rounded-full bg-emerald-500/15 px-1.5 py-0.5 text-[10px] font-medium text-emerald-700 dark:text-emerald-400",children:"Installed"}):void 0,onClick:()=>{if(!M.installed||!M.blockKey){he.message(`${M.title} is not installed on this site.`);return}E({collection:"apps",key:M.blockKey})}},M.id)}):te?xe.length===0?n.jsx(an,{hasItems:de.length>0,emptyLabel:"No posts yet.",emptyHint:'Click "+" to create your first post.'}):xe.map(M=>{const ue={key:M.key,kind:"posts",label:M.title,subtitle:M.slug};return n.jsx(bi,{icon:Ri,title:M.title,subtitle:M.slug,active:N?.collection==="posts"&&N.key===M.key,selectable:!0,selectionActive:qe,selected:x.has(M.key),onToggleSelect:()=>v(M.key),onClick:()=>E({collection:"posts",key:M.key}),menu:n.jsx(lr,{onDuplicate:()=>F(ue),onDelete:()=>H(ue)})},M.key)}):J.length===0?n.jsx(an,{hasItems:d.length>0,emptyLabel:`No ${s} yet.`,emptyHint:`Click "+" to create your first ${Tn(s)?En[s]:"item"}.`}):J.map(M=>{const ue=N?.collection===M.kind&&N.key===M.key;return n.jsx(bi,{icon:M.kind==="posts"?Ri:M.kind==="authors"?co:ro,title:M.label,subtitle:M.subtitle,active:ue,onClick:()=>E({collection:M.kind,key:M.key}),menu:n.jsx(lr,{onDuplicate:()=>F(M),onDelete:()=>H(M)})},M.key)}),e[0]=s,e[1]=a,e[2]=l,e[3]=o,e[4]=d,e[5]=c,e[6]=j,e[7]=C,e[8]=w,e[9]=S,e[10]=R,e[11]=H,e[12]=I,e[13]=B,e[14]=F,e[15]=T,e[16]=L,e[17]=A,e[18]=_,e[19]=g,e[20]=b,e[21]=k,e[22]=P,e[23]=u,e[24]=E,e[25]=y,e[26]=v,e[27]=O,e[28]=i,e[29]=m,e[30]=f,e[31]=p,e[32]=h,e[33]=r,e[34]=x,e[35]=N,e[36]=z,e[37]=W,e[38]=q,e[39]=K,e[40]=Z,e[41]=Y,e[42]=G}else z=e[36],W=e[37],q=e[38],K=e[39],Z=e[40],Y=e[41],G=e[42];let Q;e[63]!==W||e[64]!==q?(Q=n.jsx("div",{className:W,children:q}),e[63]=W,e[64]=q,e[65]=Q):Q=e[65];let $;e[66]!==z||e[67]!==K||e[68]!==Q?($=n.jsx(z,{className:K,children:Q}),e[66]=z,e[67]=K,e[68]=Q,e[69]=$):$=e[69];let X;return e[70]!==Z||e[71]!==Y||e[72]!==G||e[73]!==$?(X=n.jsxs("div",{className:Z,children:[Y,G,$]}),e[70]=Z,e[71]=Y,e[72]=G,e[73]=$,e[74]=X):X=e[74],X}function MC(t){return t.key}function $C(t){return t.email}function zC(t){return t.slug}function FC(t){return typeof t=="string"?t:""}const xi="__all__",Dm={"date-desc":"Newest first","date-asc":"Oldest first",az:"Title A–Z",za:"Title Z–A"},HC={"date-desc":"Newest","date-asc":"Oldest",az:"A–Z",za:"Z–A"},Uo=D.forwardRef(function(e,s){const i=U.c(20);let r,o,a,l,d;i[0]!==e?({icon:r,active:o,value:d,className:a,...l}=e,i[0]=e,i[1]=r,i[2]=o,i[3]=a,i[4]=l,i[5]=d):(r=i[1],o=i[2],a=i[3],l=i[4],d=i[5]);const c=o?"text-foreground":"text-muted-foreground";let h;i[6]!==a||i[7]!==c?(h=ae("h-7 gap-1 px-1.5 text-xs",c,a),i[6]=a,i[7]=c,i[8]=h):h=i[8];let u;i[9]!==r?(u=n.jsx(r,{size:14,className:"shrink-0"}),i[9]=r,i[10]=u):u=i[10];let f;i[11]!==d?(f=d&&n.jsx("span",{className:"min-w-0 flex-1 truncate",children:d}),i[11]=d,i[12]=f):f=i[12];let m;i[13]===Symbol.for("react.memo_cache_sentinel")?(m=n.jsx(cs,{size:12,className:"shrink-0 opacity-60"}),i[13]=m):m=i[13];let p;return i[14]!==l||i[15]!==s||i[16]!==h||i[17]!==u||i[18]!==f?(p=n.jsxs(ie,{ref:s,type:"button",variant:"ghost",size:"sm",className:h,...l,children:[u,f,m]}),i[14]=l,i[15]=s,i[16]=h,i[17]=u,i[18]=f,i[19]=p):p=i[19],p});function Im(t){const e=U.c(2),{count:s}=t;let i;return e[0]!==s?(i=n.jsx("span",{className:"ml-auto pl-3 text-xs text-muted-foreground tabular-nums",children:s}),e[0]=s,e[1]=i):i=e[1],i}function UC(t){const e=U.c(64),{categories:s,authors:i,categoryFilter:r,authorFilter:o,sort:a,hasPosts:l,allSelected:d,onToggleSelectAll:c,onCategoryFilterChange:h,onAuthorFilterChange:u,onSortChange:f}=t;let m;if(e[0]!==s||e[1]!==r){let V;e[3]!==r?(V=se=>se.slug===r,e[3]=r,e[4]=V):V=e[4],m=s.find(V),e[0]=s,e[1]=r,e[2]=m}else m=e[2];const p=m;let g;if(e[5]!==o||e[6]!==i){let V;e[8]!==o?(V=se=>se.email===o,e[8]=o,e[9]=V):V=e[9],g=i.find(V),e[5]=o,e[6]=i,e[7]=g}else g=e[7];const _=g,b=!l;let x;e[10]!==d||e[11]!==c||e[12]!==b?(x=n.jsx(Lm,{checked:d,disabled:b,onToggle:c}),e[10]=d,e[11]=c,e[12]=b,e[13]=x):x=e[13];const v=!!r,y=p?.name;let S;e[14]!==v||e[15]!==y?(S=n.jsx(Vt,{asChild:!0,children:n.jsx(Uo,{icon:ro,active:v,value:y,className:"min-w-0 shrink"})}),e[14]=v,e[15]=y,e[16]=S):S=e[16];let w;e[17]===Symbol.for("react.memo_cache_sentinel")?(w=n.jsx(Co,{children:"Filter by category"}),e[17]=w):w=e[17];const C=r??xi;let N;e[18]!==h?(N=V=>h(V===xi?null:V),e[18]=h,e[19]=N):N=e[19];let E;e[20]===Symbol.for("react.memo_cache_sentinel")?(E=n.jsx(In,{value:xi,children:"All categories"}),e[20]=E):E=e[20];let R;e[21]!==s?(R=s.map(KC),e[21]=s,e[22]=R):R=e[22];let T;e[23]!==N||e[24]!==R||e[25]!==C?(T=n.jsxs(Kt,{align:"start",className:"max-h-80 w-56 overflow-y-auto",children:[w,n.jsxs(ko,{value:C,onValueChange:N,children:[E,R]})]}),e[23]=N,e[24]=R,e[25]=C,e[26]=T):T=e[26];let k;e[27]!==T||e[28]!==S?(k=n.jsxs(Wt,{children:[S,T]}),e[27]=T,e[28]=S,e[29]=k):k=e[29];const j=!!o,I=_?.name;let A;e[30]!==j||e[31]!==I?(A=n.jsx(Vt,{asChild:!0,children:n.jsx(Uo,{icon:co,active:j,value:I,className:"min-w-0 shrink"})}),e[30]=j,e[31]=I,e[32]=A):A=e[32];let O;e[33]===Symbol.for("react.memo_cache_sentinel")?(O=n.jsx(Co,{children:"Filter by author"}),e[33]=O):O=e[33];const L=o??xi;let P;e[34]!==u?(P=V=>u(V===xi?null:V),e[34]=u,e[35]=P):P=e[35];let B;e[36]===Symbol.for("react.memo_cache_sentinel")?(B=n.jsx(In,{value:xi,children:"All authors"}),e[36]=B):B=e[36];let F;e[37]!==i?(F=i.map(VC),e[37]=i,e[38]=F):F=e[38];let H;e[39]!==L||e[40]!==P||e[41]!==F?(H=n.jsxs(Kt,{align:"start",className:"max-h-80 w-56 overflow-y-auto",children:[O,n.jsxs(ko,{value:L,onValueChange:P,children:[B,F]})]}),e[39]=L,e[40]=P,e[41]=F,e[42]=H):H=e[42];let z;e[43]!==A||e[44]!==H?(z=n.jsxs(Wt,{children:[A,H]}),e[43]=A,e[44]=H,e[45]=z):z=e[45];const W=HC[a];let q;e[46]!==W?(q=n.jsx(Vt,{asChild:!0,children:n.jsx(Uo,{icon:F_,active:!0,value:W})}),e[46]=W,e[47]=q):q=e[47];let K;e[48]===Symbol.for("react.memo_cache_sentinel")?(K=n.jsx(Co,{children:"Sort by"}),e[48]=K):K=e[48];let Z;e[49]!==f?(Z=V=>f(V),e[49]=f,e[50]=Z):Z=e[50];let Y;e[51]===Symbol.for("react.memo_cache_sentinel")?(Y=Object.keys(Dm),e[51]=Y):Y=e[51];let G;e[52]===Symbol.for("react.memo_cache_sentinel")?(G=Y.map(WC),e[52]=G):G=e[52];let Q;e[53]!==a||e[54]!==Z?(Q=n.jsxs(Kt,{align:"end",className:"w-44",children:[K,n.jsx(ko,{value:a,onValueChange:Z,children:G})]}),e[53]=a,e[54]=Z,e[55]=Q):Q=e[55];let $;e[56]!==q||e[57]!==Q?($=n.jsxs(Wt,{children:[q,Q]}),e[56]=q,e[57]=Q,e[58]=$):$=e[58];let X;return e[59]!==k||e[60]!==z||e[61]!==$||e[62]!==x?(X=n.jsxs("div",{className:"flex min-w-0 items-center gap-0.5 overflow-hidden border-b px-2 py-1.5",children:[x,k,z,$]}),e[59]=k,e[60]=z,e[61]=$,e[62]=x,e[63]=X):X=e[63],X}function WC(t){return n.jsx(In,{value:t,children:Dm[t]},t)}function VC(t){return n.jsxs(In,{value:t.email,children:[n.jsx("span",{className:"min-w-0 flex-1 truncate",children:t.name}),n.jsx(Im,{count:t.count})]},t.email)}function KC(t){return n.jsxs(In,{value:t.slug,children:[n.jsx("span",{className:"min-w-0 flex-1 truncate",children:t.name}),n.jsx(Im,{count:t.count})]},t.slug)}function Lm(t){const e=U.c(12),{checked:s,disabled:i,onToggle:r}=t;let o;e[0]!==r?(o=()=>r(),e[0]=r,e[1]=o):o=e[1];const a=s?"Deselect all posts":"Select all posts";let l;e[2]!==s||e[3]!==i||e[4]!==o||e[5]!==a?(l=n.jsx(Ne,{asChild:!0,children:n.jsx("span",{className:"flex shrink-0 items-center px-1.5",onClick:qC,children:n.jsx(Ki,{checked:s,disabled:i,onCheckedChange:o,"aria-label":a})})}),e[2]=s,e[3]=i,e[4]=o,e[5]=a,e[6]=l):l=e[6];const d=s?"Deselect all":"Select all";let c;e[7]!==d?(c=n.jsx(Ee,{side:"bottom",children:d}),e[7]=d,e[8]=c):c=e[8];let h;return e[9]!==l||e[10]!==c?(h=n.jsxs(Te,{children:[l,c]}),e[9]=l,e[10]=c,e[11]=h):h=e[11],h}function qC(t){return t.stopPropagation()}function GC(t){const e=U.c(31),{count:s,allSelected:i,onToggleSelectAll:r,onUpdateCategory:o,onDelete:a,onClear:l}=t;let d;e[0]!==i||e[1]!==r?(d=n.jsx(Lm,{checked:i,onToggle:r}),e[0]=i,e[1]=r,e[2]=d):d=e[2];let c;e[3]!==s?(c=n.jsxs("span",{className:"text-xs font-medium tabular-nums",children:[s," selected"]}),e[3]=s,e[4]=c):c=e[4];let h;e[5]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx(ro,{size:14}),e[5]=h):h=e[5];let u;e[6]!==o?(u=n.jsx(Ne,{asChild:!0,children:n.jsxs(ie,{type:"button",variant:"ghost",size:"sm",className:"h-7 gap-1 px-2 text-xs",onClick:o,"aria-label":"Update category for selected posts",children:[h,"Category"]})}),e[6]=o,e[7]=u):u=e[7];let f;e[8]===Symbol.for("react.memo_cache_sentinel")?(f=n.jsx(Ee,{side:"bottom",children:"Update category"}),e[8]=f):f=e[8];let m;e[9]!==u?(m=n.jsxs(Te,{children:[u,f]}),e[9]=u,e[10]=m):m=e[10];let p;e[11]===Symbol.for("react.memo_cache_sentinel")?(p=n.jsx(es,{size:14}),e[11]=p):p=e[11];let g;e[12]!==a?(g=n.jsx(Ne,{asChild:!0,children:n.jsx(ie,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive hover:text-destructive",onClick:a,"aria-label":"Delete selected posts",children:p})}),e[12]=a,e[13]=g):g=e[13];let _;e[14]===Symbol.for("react.memo_cache_sentinel")?(_=n.jsx(Ee,{side:"bottom",children:"Delete selected"}),e[14]=_):_=e[14];let b;e[15]!==g?(b=n.jsxs(Te,{children:[g,_]}),e[15]=g,e[16]=b):b=e[16];let x;e[17]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsx(jl,{size:14}),e[17]=x):x=e[17];let v;e[18]!==l?(v=n.jsx(Ne,{asChild:!0,children:n.jsx(ie,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7",onClick:l,"aria-label":"Clear selection",children:x})}),e[18]=l,e[19]=v):v=e[19];let y;e[20]===Symbol.for("react.memo_cache_sentinel")?(y=n.jsx(Ee,{side:"bottom",children:"Clear selection"}),e[20]=y):y=e[20];let S;e[21]!==v?(S=n.jsxs(Te,{children:[v,y]}),e[21]=v,e[22]=S):S=e[22];let w;e[23]!==b||e[24]!==S||e[25]!==m?(w=n.jsxs("div",{className:"ml-auto flex items-center gap-0.5",children:[m,b,S]}),e[23]=b,e[24]=S,e[25]=m,e[26]=w):w=e[26];let C;return e[27]!==d||e[28]!==w||e[29]!==c?(C=n.jsxs("div",{className:"flex items-center gap-0.5 border-b bg-accent/40 px-2 py-1.5",children:[d,c,w]}),e[27]=d,e[28]=w,e[29]=c,e[30]=C):C=e[30],C}function YC(t){const e=U.c(48),{count:s,categories:i,isPending:r,onApply:o,onOpenChange:a}=t,[l,d]=D.useState(i[0]?.slug??""),[c,h]=D.useState("add");let u;if(e[0]!==i||e[1]!==l){let P;e[3]!==l?(P=B=>B.slug===l,e[3]=l,e[4]=P):P=e[4],u=i.find(P),e[0]=i,e[1]=l,e[2]=u}else u=e[2];const f=u;let m;e[5]===Symbol.for("react.memo_cache_sentinel")?(m=n.jsx(ss,{children:"Update category"}),e[5]=m):m=e[5];const p=s===1?"post":"posts";let g;e[6]!==s||e[7]!==p?(g=n.jsxs(ts,{children:[m,n.jsxs(Wi,{children:["Choose a category to apply to ",s," ",p,"."]})]}),e[6]=s,e[7]=p,e[8]=g):g=e[8];let _;e[9]===Symbol.for("react.memo_cache_sentinel")?(_=n.jsx(Ve,{children:"Category"}),e[9]=_):_=e[9];let b;e[10]!==i||e[11]!==l?(b=n.jsxs("div",{className:"space-y-2",children:[_,i.length===0?n.jsx("p",{className:"text-sm text-muted-foreground",children:"No categories yet — create one in the Categories collection."}):n.jsxs(Nt,{value:l,onValueChange:d,children:[n.jsx(kt,{className:"w-full",children:n.jsx(Rt,{placeholder:"Select a category"})}),n.jsx(jt,{children:i.map(XC)})]})]}),e[10]=i,e[11]=l,e[12]=b):b=e[12];let x;e[13]===Symbol.for("react.memo_cache_sentinel")?(x=P=>h(P),e[13]=x):x=e[13];let v;e[14]===Symbol.for("react.memo_cache_sentinel")?(v=n.jsx(fd,{value:"add",id:"cat-mode-add",className:"mt-0.5"}),e[14]=v):v=e[14];let y;e[15]===Symbol.for("react.memo_cache_sentinel")?(y=n.jsxs(Ve,{htmlFor:"cat-mode-add",className:"flex cursor-pointer items-start gap-2.5 rounded-lg border p-3",children:[v,n.jsxs("span",{className:"space-y-0.5",children:[n.jsx("span",{className:"block text-sm font-medium",children:"Add category"}),n.jsx("span",{className:"block text-xs text-muted-foreground",children:"Keep existing categories and add this one."})]})]}),e[15]=y):y=e[15];let S;e[16]===Symbol.for("react.memo_cache_sentinel")?(S=n.jsx(fd,{value:"replace",id:"cat-mode-replace",className:"mt-0.5"}),e[16]=S):S=e[16];let w;e[17]===Symbol.for("react.memo_cache_sentinel")?(w=n.jsxs(Ve,{htmlFor:"cat-mode-replace",className:"flex cursor-pointer items-start gap-2.5 rounded-lg border p-3",children:[S,n.jsxs("span",{className:"space-y-0.5",children:[n.jsx("span",{className:"block text-sm font-medium",children:"Replace category"}),n.jsx("span",{className:"block text-xs text-muted-foreground",children:"Remove all current categories and set only this one."})]})]}),e[17]=w):w=e[17];let C;e[18]!==c?(C=n.jsxs(a2,{value:c,onValueChange:x,className:"gap-2",children:[y,w]}),e[18]=c,e[19]=C):C=e[19];let N;e[20]!==C||e[21]!==b?(N=n.jsxs("div",{className:"space-y-4 py-2",children:[b,C]}),e[20]=C,e[21]=b,e[22]=N):N=e[22];let E;e[23]!==a?(E=()=>a(!1),e[23]=a,e[24]=E):E=e[24];let R;e[25]!==r||e[26]!==E?(R=n.jsx(ie,{type:"button",variant:"outline",onClick:E,disabled:r,children:"Cancel"}),e[25]=r,e[26]=E,e[27]=R):R=e[27];const T=!f||r;let k;e[28]!==c||e[29]!==o||e[30]!==f?(k=()=>f&&o(c,{name:f.name,slug:f.slug}),e[28]=c,e[29]=o,e[30]=f,e[31]=k):k=e[31];let j;e[32]!==r?(j=r?n.jsxs(n.Fragment,{children:[n.jsx(Oe,{size:14,className:"animate-spin"}),"Updating…"]}):"Apply",e[32]=r,e[33]=j):j=e[33];let I;e[34]!==T||e[35]!==k||e[36]!==j?(I=n.jsx(ie,{type:"button",disabled:T,onClick:k,children:j}),e[34]=T,e[35]=k,e[36]=j,e[37]=I):I=e[37];let A;e[38]!==R||e[39]!==I?(A=n.jsxs(Ws,{children:[R,I]}),e[38]=R,e[39]=I,e[40]=A):A=e[40];let O;e[41]!==N||e[42]!==A||e[43]!==g?(O=n.jsxs(Mt,{className:"sm:max-w-md",children:[g,N,A]}),e[41]=N,e[42]=A,e[43]=g,e[44]=O):O=e[44];let L;return e[45]!==a||e[46]!==O?(L=n.jsx(Bt,{open:!0,onOpenChange:a,children:O}),e[45]=a,e[46]=O,e[47]=L):L=e[47],L}function XC(t){return n.jsx(tt,{value:t.slug,children:n.jsx("span",{className:"truncate",children:t.name})},t.slug)}function bi(t){const e=U.c(37),{icon:s,logoUrl:i,title:r,subtitle:o,active:a,accent:l,variantCount:d,trailing:c,selectable:h,selectionActive:u,selected:f,onToggleSelect:m,onClick:p,menu:g}=t,_=l==="global";let b;e[0]!==s||e[1]!==a||e[2]!==_||e[3]!==i||e[4]!==d?(b=d&&d>1?n.jsx("span",{className:"flex size-8 shrink-0 items-center justify-center",children:n.jsxs(Te,{children:[n.jsx(Ne,{asChild:!0,children:n.jsx(s,{size:16,className:"shrink-0",style:{color:Ca}})}),n.jsxs(Ee,{side:"right",children:[d," variants"]})]})}):i?n.jsx("img",{src:i,alt:"",className:"size-8 shrink-0 rounded-lg object-cover bg-muted"}):n.jsx("span",{className:ae("flex size-8 shrink-0 items-center justify-center rounded-lg",_?"bg-global-section/15":"bg-muted"),children:n.jsx(s,{size:16,className:ae("shrink-0",!_&&(a?"text-accent-foreground":"text-muted-foreground")),style:_?{color:lf}:void 0})}),e[0]=s,e[1]=a,e[2]=_,e[3]=i,e[4]=d,e[5]=b):b=e[5];const x=b,v=a?_?"bg-global-section/15 text-global-section-fg dark:text-global-section-fg-dark":"bg-accent text-accent-foreground":_?"hover:bg-global-section/10":"hover:bg-muted";let y;e[6]!==v?(y=ae("group relative flex min-w-0 items-center rounded-md transition-colors",v),e[6]=v,e[7]=y):y=e[7];let S;e[8]!==m||e[9]!==h||e[10]!==f||e[11]!==u||e[12]!==r?(S=h&&n.jsx("span",{className:ae("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:JC,children:n.jsx(Ki,{checked:f,onCheckedChange:()=>m?.(),"aria-label":`Select ${r}`})}),e[8]=m,e[9]=h,e[10]=f,e[11]=u,e[12]=r,e[13]=S):S=e[13];let w;e[14]!==r?(w=n.jsx("span",{className:"block truncate text-sm font-medium",children:r}),e[14]=r,e[15]=w):w=e[15];const C=a?"text-accent-foreground/70":"text-muted-foreground";let N;e[16]!==C?(N=ae("block truncate text-xs",C),e[16]=C,e[17]=N):N=e[17];let E;e[18]!==o||e[19]!==N?(E=n.jsx("span",{className:N,children:o}),e[18]=o,e[19]=N,e[20]=E):E=e[20];let R;e[21]!==w||e[22]!==E?(R=n.jsxs("span",{className:"min-w-0 flex-1",children:[w,E]}),e[21]=w,e[22]=E,e[23]=R):R=e[23];let T;e[24]!==p||e[25]!==x||e[26]!==R||e[27]!==c?(T=n.jsxs("button",{type:"button",onClick:p,className:"flex min-w-0 flex-1 items-center gap-2.5 rounded-md px-2.5 py-2 text-left cursor-pointer",children:[x,R,c]}),e[24]=p,e[25]=x,e[26]=R,e[27]=c,e[28]=T):T=e[28];let k;e[29]!==a||e[30]!==g?(k=g&&n.jsx("div",{className:ae("pr-1 opacity-0 transition-opacity group-hover:opacity-100",a&&"opacity-100"),children:g}),e[29]=a,e[30]=g,e[31]=k):k=e[31];let j;return e[32]!==T||e[33]!==k||e[34]!==y||e[35]!==S?(j=n.jsxs("div",{className:y,children:[S,T,k]}),e[32]=T,e[33]=k,e[34]=y,e[35]=S,e[36]=j):j=e[36],j}function JC(t){return t.stopPropagation()}function lr(t){const e=U.c(21),{onDuplicate:s,onRename:i,onAddVariant:r,onEditSeo:o,onViewJson:a,onDelete:l}=t;let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx(Vt,{asChild:!0,children:n.jsx("button",{type:"button","aria-label":"More actions",className:"flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:bg-background hover:text-foreground cursor-pointer",onClick:ZC,children:n.jsx(Hi,{size:14})})}),e[0]=d):d=e[0];let c;e[1]!==i?(c=i&&n.jsxs(Ue,{onClick:i,children:[n.jsx(Cl,{size:14}),"Rename"]}),e[1]=i,e[2]=c):c=e[2];let h;e[3]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx(as,{size:14}),e[3]=h):h=e[3];let u;e[4]!==s?(u=n.jsxs(Ue,{onClick:s,children:[h,"Duplicate"]}),e[4]=s,e[5]=u):u=e[5];let f;e[6]!==r?(f=r&&n.jsxs(n.Fragment,{children:[n.jsx(Cn,{}),n.jsxs(Ue,{onClick:r,className:"cursor-pointer",style:{color:Ca},children:[n.jsx(Tu,{size:14,style:{color:Ca}}),"Add variant"]})]}),e[6]=r,e[7]=f):f=e[7];let m;e[8]!==o||e[9]!==a?(m=(o||a)&&n.jsxs(n.Fragment,{children:[n.jsx(Cn,{}),o&&n.jsxs(Ue,{onClick:o,children:[n.jsx(kr,{size:14}),"Edit SEO"]}),a&&n.jsxs(Ue,{onClick:a,children:[n.jsx(no,{size:14}),"View JSON"]})]}),e[8]=o,e[9]=a,e[10]=m):m=e[10];let p;e[11]===Symbol.for("react.memo_cache_sentinel")?(p=n.jsx(Cn,{}),e[11]=p):p=e[11];let g;e[12]===Symbol.for("react.memo_cache_sentinel")?(g=n.jsx(es,{size:14}),e[12]=g):g=e[12];let _;e[13]!==l?(_=n.jsxs(Ue,{onClick:l,className:"text-destructive focus:text-destructive",children:[g,"Delete"]}),e[13]=l,e[14]=_):_=e[14];let b;return e[15]!==c||e[16]!==u||e[17]!==f||e[18]!==m||e[19]!==_?(b=n.jsxs(Wt,{children:[d,n.jsxs(Kt,{align:"end",className:"w-44",children:[c,u,f,m,p,_]})]}),e[15]=c,e[16]=u,e[17]=f,e[18]=m,e[19]=_,e[20]=b):b=e[20],b}function ZC(t){return t.stopPropagation()}function an(t){const e=U.c(6),{hasItems:s,emptyLabel:i,emptyHint:r}=t;let o;e[0]!==r||e[1]!==i||e[2]!==s?(o=s?"No results match your search.":n.jsxs(n.Fragment,{children:[n.jsx("div",{children:i}),n.jsx("div",{className:"mt-1 text-muted-foreground/80",children:r})]}),e[0]=r,e[1]=i,e[2]=s,e[3]=o):o=e[3];let a;return e[4]!==o?(a=n.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:o}),e[4]=o,e[5]=a):a=e[5],a}function QC(t){const e=U.c(8),{state:s,claimPhase:i,lifecycle:r,onStart:o}=t;switch(s.kind){case"starting":{let a;e[0]!==i||e[1]!==r?(a=rm({claimPhase:i,lifecycle:r}),e[0]=i,e[1]=r,e[2]=a):a=e[2];let l;return e[3]!==i||e[4]!==a?(l=n.jsx(Wr,{kind:"starting",progress:a,claimPhase:i}),e[3]=i,e[4]=a,e[5]=l):l=e[5],l}case"suspended":{let a;return e[6]!==o?(a=n.jsx(Wr,{kind:"suspended",onResume:o}),e[6]=o,e[7]=a):a=e[7],a}}}function ki(t){const e=U.c(10),{icon:s,title:i,description:r}=t;let o;e[0]!==s?(o=s&&n.jsx(s,{size:24,className:"text-muted-foreground/60"}),e[0]=s,e[1]=o):o=e[1];let a;e[2]!==i?(a=n.jsx("div",{children:i}),e[2]=i,e[3]=a):a=e[3];let l;e[4]!==r?(l=r&&n.jsx("div",{className:"text-xs text-muted-foreground/80 max-w-sm",children:r}),e[4]=r,e[5]=l):l=e[5];let d;return e[6]!==o||e[7]!==a||e[8]!==l?(d=n.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-2 p-6 text-center text-sm text-muted-foreground",children:[o,a,l]}),e[6]=o,e[7]=a,e[8]=l,e[9]=d):d=e[9],d}function e3(t){const e=U.c(2),{virtualMcpId:s}=t,i=vs(s);if(!ti(i?.metadata)){let a;return e[0]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-2 text-center text-sm text-muted-foreground p-6",children:[n.jsx(zi,{size:24,className:"text-muted-foreground/60"}),n.jsx("div",{children:"No content to edit."}),n.jsx("div",{className:"text-xs text-muted-foreground/80",children:"Connect a GitHub repository from the Settings tab to enable Content."})]}),e[0]=a):a=e[0],a}let o;return e[1]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx(RC,{}),e[1]=o):o=e[1],o}const Wo={fast:{label:"Fast",subtitle:"Quick responses for simple tasks",icon:ku},smart:{label:"Smart",subtitle:"Balanced quality and speed",icon:Zs},thinking:{label:"Thinking",subtitle:"Deeper reasoning for hard tasks",icon:V_}},t3=["fast","smart","thinking"];function s3(t){const e=U.c(15),{tier:s,onSelect:i}=t,[r,o]=D.useState(!1),a=Wo[s].icon;let l;e[0]!==a?(l=n.jsx(a,{size:14,className:"text-muted-foreground"}),e[0]=a,e[1]=l):l=e[1];const d=Wo[s];let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx(cs,{size:14,className:"text-muted-foreground"}),e[2]=c):c=e[2];let h;e[3]!==l||e[4]!==d.label?(h=n.jsx(Rs,{asChild:!0,children:n.jsxs(ie,{variant:"outline",size:"sm",className:"w-fit gap-1.5",children:[l,d.label,c]})}),e[3]=l,e[4]=d.label,e[5]=h):h=e[5];let u;e[6]!==i||e[7]!==s?(u=t3.map(p=>{const g=Wo[p],_=g.icon;return n.jsxs("button",{type:"button",onClick:()=>{i(p),o(!1)},className:ae("flex items-start gap-2 px-2 py-1.5 rounded-md text-left hover:bg-muted"),children:[n.jsx(_,{size:16,className:"shrink-0 text-muted-foreground mt-0.5"}),n.jsxs("div",{className:"flex-1",children:[n.jsx("div",{className:"text-sm",children:g.label}),n.jsx("div",{className:"text-xs text-muted-foreground",children:g.subtitle})]}),p===s&&n.jsx(js,{size:14,className:"text-foreground mt-0.5"})]},p)}),e[6]=i,e[7]=s,e[8]=u):u=e[8];let f;e[9]!==u?(f=n.jsx(Ps,{align:"start",className:"p-1 w-64",children:n.jsx("div",{className:"flex flex-col",children:u})}),e[9]=u,e[10]=f):f=e[10];let m;return e[11]!==r||e[12]!==h||e[13]!==f?(m=n.jsxs(As,{open:r,onOpenChange:o,children:[h,f]}),e[11]=r,e[12]=h,e[13]=f,e[14]=m):m=e[14],m}function i3(t){const e=U.c(15),{tier:s,onTierChange:i,override:r,onOverrideChange:o}=t,[a,l]=D.useState(r!==null);let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Model"}),e[0]=d):d=e[0];let c;e[1]!==o||e[2]!==i||e[3]!==r||e[4]!==s||e[5]!==a?(c=a?n.jsx(D.Suspense,{fallback:n.jsx(ie,{variant:"outline",size:"sm",disabled:!0,className:"w-fit",children:"Loading models…"}),children:n.jsx(n3,{override:r,onOverrideChange:o})}):n.jsx(s3,{tier:s,onSelect:i}),e[1]=o,e[2]=i,e[3]=r,e[4]=s,e[5]=a,e[6]=c):c=e[6];let h;e[7]!==o?(h=m=>{l(m),m||o(null)},e[7]=o,e[8]=h):h=e[8];let u;e[9]!==h||e[10]!==a?(u=n.jsxs("label",{className:"flex items-center gap-2 text-xs text-muted-foreground cursor-pointer select-none",children:[n.jsx(On,{checked:a,onCheckedChange:h,className:"cursor-pointer"}),"Specific model"]}),e[9]=h,e[10]=a,e[11]=u):u=e[11];let f;return e[12]!==c||e[13]!==u?(f=n.jsxs("div",{className:"flex flex-col gap-2",children:[d,n.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[c,u]})]}),e[12]=c,e[13]=u,e[14]=f):f=e[14],f}function n3(t){const e=U.c(10),{override:s,onOverrideChange:i}=t,r=fu(),o=r[0]?.id??null,[a,l]=D.useState(s?.credentialId??o);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 c=d;if(r.length===0){let f;return e[2]===Symbol.for("react.memo_cache_sentinel")?(f=n.jsx("span",{className:"text-xs text-muted-foreground italic",children:"Connect an AI provider in settings to pick a specific model."}),e[2]=f):f=e[2],f}let h;e[3]!==a||e[4]!==i?(h=f=>{const m=f.keyId??a??"";l(m),i({modelId:f.modelId,credentialId:m,title:f.title??f.modelId})},e[3]=a,e[4]=i,e[5]=h):h=e[5];let u;return e[6]!==a||e[7]!==c||e[8]!==h?(u=n.jsx("div",{className:"w-fit max-w-full [&_button]:rounded-md",children:n.jsx(P1,{variant:"bordered",placeholder:"Pick a model",model:c,credentialId:a,onCredentialChange:l,onModelChange:h})}),e[6]=a,e[7]=c,e[8]=h,e[9]=u):u=e[9],u}const Om=[{key:"capabilities",heading:"Built-in capabilities",icon:kl,tools:[{name:"web_search",title:"Web search",description:"Look up current information on the web",icon:Ui},{name:"generate_image",title:"Generate image",description:"Create images from a text prompt",icon:Ii},{name:"subtask",title:"Subtask",description:"Spawn a focused sub-agent to handle part of the work",icon:Dn},{name:"user_ask",title:"Ask the user",description:"Pause to ask the user a clarifying question",icon:H_}]},{key:"files",heading:"Files & code",icon:ma,tools:[{name:"read",title:"Read File",description:"Read a file from the workspace",icon:Ou},{name:"write",title:"Write File",description:"Create or overwrite a file",icon:Cl},{name:"edit",title:"Edit File",description:"Make targeted edits to an existing file",icon:U_},{name:"grep",title:"Search Content",description:"Search file contents by pattern",icon:Bn},{name:"glob",title:"Find Files",description:"Find files by name pattern",icon:ma},{name:"bash",title:"Run Command",description:"Run shell commands in the sandbox",icon:W_}]},{key:"context",heading:"Context",icon:Mc,tools:[{name:"read_resource",title:"Read Resource",description:"Read an MCP resource by URI",icon:Mc},{name:"read_prompt",title:"Read Prompt",description:"Read an MCP prompt definition",icon:pa},{name:"skill",title:"Load Skill",description:"Load a skill's full instructions (SKILL.md) by id",icon:pa}]},{key:"browser",heading:"Browser",icon:si,tools:[{name:"take_screenshot",title:"Take Screenshot",description:"Capture a screenshot of a web page",icon:Ru},{name:"scrape_url",title:"Scrape URL",description:"Fetch and extract content from a URL",icon:si},{name:"inspect_page",title:"Inspect Page",description:"Inspect a web page's structure",icon:no}]}],r3=Om.flatMap(t=>t.tools.map(e=>e.name));function o3(t){const e=t.replace(/[_-]+/g," ").trim();return e?e.toLowerCase().replace(/\b\w/g,s=>s.toUpperCase()):t}function a3(t){const e=U.c(5),{agentId:s,value:i,onChange:r}=t;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Tools"}),e[0]=o):o=e[0];let a;return e[1]!==s||e[2]!==r||e[3]!==i?(a=n.jsxs("div",{className:"flex flex-col gap-2",children:[o,s?n.jsx(D.Suspense,{fallback:n.jsxs(ie,{variant:"outline",size:"sm",disabled:!0,className:"w-fit",children:[n.jsx(kl,{size:14}),"Loading tools…"]}),children:n.jsx(l3,{agentId:s,value:i,onChange:r})}):n.jsx("span",{className:"text-xs text-muted-foreground italic",children:"Pick an agent first"})]}),e[1]=s,e[2]=r,e[3]=i,e[4]=a):a=e[4],a}function Md(t){const e=U.c(17),{value:s,checked:i,onToggle:r,title:o,description:a,leading:l}=t;let d;e[0]!==i?(d=n.jsx(Ki,{checked:i,className:"pointer-events-none mt-0.5"}),e[0]=i,e[1]=d):d=e[1];let c;e[2]!==l?(c=l&&n.jsx("span",{className:"mt-px shrink-0",children:l}),e[2]=l,e[3]=c):c=e[3];let h;e[4]!==o?(h=n.jsx("span",{className:"truncate text-sm leading-tight",children:o}),e[4]=o,e[5]=h):h=e[5];let u;e[6]!==a?(u=a&&n.jsx("span",{className:"line-clamp-2 text-xs leading-snug text-muted-foreground",children:a}),e[6]=a,e[7]=u):u=e[7];let f;e[8]!==h||e[9]!==u?(f=n.jsxs("div",{className:"flex min-w-0 flex-col gap-0.5",children:[h,u]}),e[8]=h,e[9]=u,e[10]=f):f=e[10];let m;return e[11]!==r||e[12]!==d||e[13]!==c||e[14]!==f||e[15]!==s?(m=n.jsxs(Or,{value:s,onSelect:r,className:"items-start gap-2.5 py-2",children:[d,c,f]}),e[11]=r,e[12]=d,e[13]=c,e[14]=f,e[15]=s,e[16]=m):m=e[16],m}function $d(t){const e=U.c(20),{conn:s,label:i,icon:r,on:o,total:a,onToggle:l}=t,d=o===a;let c;e[0]!==r||e[1]!==s?(c=s?n.jsx(xs,{icon:s.icon,name:s.title,size:"2xs"}):r?n.jsx(r,{size:14,className:"text-muted-foreground"}):n.jsx(K_,{size:14,className:"text-muted-foreground"}),e[0]=r,e[1]=s,e[2]=c):c=e[2];const h=s?.title??i??"Other tools";let u;e[3]!==h?(u=n.jsx("span",{className:"truncate",children:h}),e[3]=h,e[4]=u):u=e[4];let f;e[5]!==o||e[6]!==a?(f=n.jsxs("span",{className:"text-[11px] font-normal tabular-nums text-muted-foreground/70",children:[o,"/",a]}),e[5]=o,e[6]=a,e[7]=f):f=e[7];let m;e[8]!==l?(m=x=>{x.stopPropagation(),l()},e[8]=l,e[9]=m):m=e[9];const p=d?"None":"All";let g;e[10]!==m||e[11]!==p?(g=n.jsx("button",{type:"button",onClick:m,className:"text-[11px] font-medium text-primary hover:underline",children:p}),e[10]=m,e[11]=p,e[12]=g):g=e[12];let _;e[13]!==f||e[14]!==g?(_=n.jsxs("span",{className:"ml-auto flex items-center gap-2",children:[f,g]}),e[13]=f,e[14]=g,e[15]=_):_=e[15];let b;return e[16]!==c||e[17]!==u||e[18]!==_?(b=n.jsxs("div",{className:"flex items-center gap-2",children:[c,u,_]}),e[16]=c,e[17]=u,e[18]=_,e[19]=b):b=e[19],b}function l3(t){const e=U.c(70),{agentId:s,value:i,onChange:r}=t,{org:o}=Me(),[a,l]=D.useState(!1);let d;e[0]!==s||e[1]!==o.id||e[2]!==o.slug?(d={connectionId:s,orgId:o.id,orgSlug:o.slug},e[0]=s,e[1]=o.id,e[2]=o.slug,e[3]=d):d=e[3];const c=Pt(d);let h;e[4]!==c?(h={client:c},e[4]=c,e[5]=h):h=e[5];const{data:u,isLoading:f}=Du(h),m=Vn();let p,g,_,b,x,v,y,S,w,C,N,E,R;if(e[6]!==m||e[7]!==u?.tools||e[8]!==f||e[9]!==r||e[10]!==a||e[11]!==i){const A=new Map(m.map(f3)),O=new Map;for(const J of u?.tools??[]){const te=Ag(J._meta)??"__other__",oe=Rg(J.name,te==="__other__"?void 0:te),de=J.title,be=de&&de!==J.name?de:o3(oe);O.has(te)||O.set(te,{clientId:te,conn:A.get(te),tools:[]}),O.get(te).tools.push({name:J.name,display:be,description:J.description})}const L=[...O.values()].sort(u3),P=(u?.tools??[]).map(h3),B=[...r3,...P],F=i===null?new Set(B):new Set(i),H=B.every(J=>F.has(J)),z=J=>r(B.every(te=>J.has(te))?null:[...J]),W=J=>{const te=new Set(F);te.has(J)?te.delete(J):te.add(J),z(te)},q=(J,te)=>{const oe=new Set(F);for(const de of J)te?oe.add(de):oe.delete(de);z(oe)};b=As,R=a,x=l;let K;e[25]===Symbol.for("react.memo_cache_sentinel")?(K=n.jsx(kl,{size:14,className:"text-muted-foreground"}),e[25]=K):K=e[25];const Z=H?"All tools":"Tools",Y=!H&&n.jsxs(R1,{variant:"secondary",className:"ml-0.5 h-5 px-1.5 text-[11px] tabular-nums",children:[F.size,"/",B.length]});let G;e[26]===Symbol.for("react.memo_cache_sentinel")?(G=n.jsx(cs,{size:14,className:"text-muted-foreground"}),e[26]=G):G=e[26],e[27]!==Z||e[28]!==Y?(v=n.jsx(Rs,{asChild:!0,children:n.jsxs(ie,{variant:"outline",size:"sm",className:"w-fit gap-1.5",children:[K,Z,Y,G]})}),e[27]=Z,e[28]=Y,e[29]=v):v=e[29],_=Ps,N="p-0 w-80",E="start",g=Ku,e[30]===Symbol.for("react.memo_cache_sentinel")?(w=n.jsx(Nl,{placeholder:"Search tools..."}),e[30]=w):w=e[30];const Q=H?`All ${B.length} tools enabled`:`${F.size} of ${B.length} enabled`;let $;e[31]!==Q?($=n.jsx("span",{className:"text-xs text-muted-foreground",children:Q}),e[31]=Q,e[32]=$):$=e[32];let X;e[33]!==r?(X=()=>r(null),e[33]=r,e[34]=X):X=e[34];let V;e[35]!==H||e[36]!==X?(V=n.jsx("button",{type:"button",onClick:X,disabled:H,className:"text-xs font-medium text-primary hover:underline disabled:cursor-default disabled:opacity-40 disabled:no-underline",children:"Select all"}),e[35]=H,e[36]=X,e[37]=V):V=e[37];let se;e[38]===Symbol.for("react.memo_cache_sentinel")?(se=n.jsx("span",{className:"text-muted-foreground/30",children:"·"}),e[38]=se):se=e[38];let ee;e[39]!==r?(ee=()=>r([]),e[39]=r,e[40]=ee):ee=e[40];const le=F.size===0;let ce;e[41]!==ee||e[42]!==le?(ce=n.jsx("button",{type:"button",onClick:ee,disabled:le,className:"text-xs font-medium text-muted-foreground hover:underline disabled:cursor-default disabled:opacity-40 disabled:no-underline",children:"Clear"}),e[41]=ee,e[42]=le,e[43]=ce):ce=e[43];let fe;e[44]!==V||e[45]!==ce?(fe=n.jsxs("div",{className:"flex items-center gap-2",children:[V,se,ce]}),e[44]=V,e[45]=ce,e[46]=fe):fe=e[46],e[47]!==$||e[48]!==fe?(C=n.jsxs("div",{className:"flex items-center justify-between border-b px-3 py-2",children:[$,fe]}),e[47]=$,e[48]=fe,e[49]=C):C=e[49],p=Tl,y="max-h-80",S=f?n.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:"Loading tools…"}):n.jsxs(n.Fragment,{children:[n.jsx(El,{children:"No tools found"}),Om.map(J=>{const te=J.tools.map(d3),oe=te.filter(de=>F.has(de)).length;return n.jsx(Br,{heading:n.jsx($d,{label:J.heading,icon:J.icon,on:oe,total:te.length,onToggle:()=>q(te,oe!==te.length)}),children:J.tools.map(de=>n.jsx(Md,{value:`${de.title} ${de.name}`,checked:F.has(de.name),onToggle:()=>W(de.name),title:de.title,description:de.description,leading:n.jsx(de.icon,{size:16,className:"text-muted-foreground"})},de.name))},J.key)}),L.map(J=>{const te=J.tools.map(c3),oe=te.filter(de=>F.has(de)).length;return n.jsx(Br,{heading:n.jsx($d,{conn:J.conn,on:oe,total:te.length,onToggle:()=>q(te,oe!==te.length)}),children:J.tools.map(de=>n.jsx(Md,{value:`${de.display} ${de.name} ${J.conn?.title??""}`,checked:F.has(de.name),onToggle:()=>W(de.name),title:de.display,description:de.description},de.name))},J.clientId)})]}),e[6]=m,e[7]=u?.tools,e[8]=f,e[9]=r,e[10]=a,e[11]=i,e[12]=p,e[13]=g,e[14]=_,e[15]=b,e[16]=x,e[17]=v,e[18]=y,e[19]=S,e[20]=w,e[21]=C,e[22]=N,e[23]=E,e[24]=R}else p=e[12],g=e[13],_=e[14],b=e[15],x=e[16],v=e[17],y=e[18],S=e[19],w=e[20],C=e[21],N=e[22],E=e[23],R=e[24];let T;e[50]!==p||e[51]!==y||e[52]!==S?(T=n.jsx(p,{className:y,children:S}),e[50]=p,e[51]=y,e[52]=S,e[53]=T):T=e[53];let k;e[54]!==g||e[55]!==T||e[56]!==w||e[57]!==C?(k=n.jsxs(g,{children:[w,C,T]}),e[54]=g,e[55]=T,e[56]=w,e[57]=C,e[58]=k):k=e[58];let j;e[59]!==_||e[60]!==k||e[61]!==N||e[62]!==E?(j=n.jsx(_,{className:N,align:E,children:k}),e[59]=_,e[60]=k,e[61]=N,e[62]=E,e[63]=j):j=e[63];let I;return e[64]!==b||e[65]!==x||e[66]!==v||e[67]!==j||e[68]!==R?(I=n.jsxs(b,{open:R,onOpenChange:x,children:[v,j]}),e[64]=b,e[65]=x,e[66]=v,e[67]=j,e[68]=R,e[69]=I):I=e[69],I}function c3(t){return t.name}function d3(t){return t.name}function h3(t){return t.name}function u3(t,e){return(t.conn?.title??t.clientId).localeCompare(e.conn?.title??e.clientId)}function f3(t){return[t.id,t]}function An(t){const e=t.trim().split(/\s+/);return e.length!==5?!1:e.every(s=>/^[\d*/,-]+$/.test(s))}function m3(t){if(!t)return"Unknown schedule";const e=t.trim();if(e==="* * * * *")return"Every minute";if(e==="0 * * * *")return"Every hour";if(e==="0 0 * * *")return"Every day";if(e==="0 0 * * 1")return"Every week";const s=e.match(/^\*\/(\d+)\s+\*\s+\*\s+\*\s+\*$/);if(s)return`Every ${s[1]} minutes`;const i=e.match(/^0\s+\*\/(\d+)\s+\*\s+\*\s+\*$/);if(i)return`Every ${i[1]} hours`;const r=e.match(/^0\s+0\s+\*\/(\d+)\s+\*\s+\*$/);if(r){const l=parseInt(r[1]??"1");return l%7===0?`Every ${l/7} weeks`:`Every ${l} days`}const o=e.match(/^(\d+)\s+(\d+)\s+\*\s+\*\s+\*$/);if(o){const l=(o[2]??"0").padStart(2,"0"),d=(o[1]??"0").padStart(2,"0");return`Every day at ${l}:${d} UTC`}const a=e.match(/^(\d+)\s+(\d+)\s+\*\s+\*\s+(\d)$/);if(a){const d=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][parseInt(a[3]??"0")]??"day",c=(a[2]??"0").padStart(2,"0"),h=(a[1]??"0").padStart(2,"0");return`Every ${d} at ${c}:${h} UTC`}return t}function p3(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 g3(t){const e=t.trim();if(e==="* * * * *")return{count:1,unit:"minutes"};if(e==="0 * * * *")return{count:1,unit:"hours"};if(e==="0 0 * * *")return{count:1,unit:"days"};if(e==="0 0 * * 1")return{count:1,unit:"weeks"};const s=e.match(/^\*\/(\d+)\s+\*\s+\*\s+\*\s+\*$/);if(s)return{count:parseInt(s[1]),unit:"minutes"};const i=e.match(/^0\s+\*\/(\d+)\s+\*\s+\*\s+\*$/);if(i)return{count:parseInt(i[1]),unit:"hours"};const r=e.match(/^0\s+0\s+\*\/(\d+)\s+\*\s+\*$/);if(r){const o=parseInt(r[1]);return o%7===0?{count:o/7,unit:"weeks"}:{count:o,unit:"days"}}return null}function _3(t,e){return e===1?{minutes:"minute",hours:"hour",days:"day",weeks:"week"}[t]??t:t}const v3=[{label:"5 minutes",cron:"*/5 * * * *"},{label:"Hour",cron:"0 * * * *"},{label:"Day",cron:"0 0 * * *"},{label:"Week",cron:"0 0 * * 1"}];function x3({automationId:t,open:e,onOpenChange:s,onCustomSelect:i,onEventSelect:r,onWebhookCreated:o}){const{triggerAdd:a}=qn(),[l,d]=D.useState(!1),c=e??l,h=m=>{s?s(m):d(m)},u=async m=>{try{await a.mutateAsync({automation_id:t,type:"cron",cron_expression:m}),he.success("Starter added"),h(!1)}catch(p){const g=p instanceof Error?p.message:"Failed to add starter";he.error(g)}},f=async()=>{try{const m=await a.mutateAsync({automation_id:t,type:"webhook"});h(!1),m.webhook?o?.(m.webhook):he.success("Webhook starter added")}catch(m){const p=m instanceof Error?m.message:"Failed to add webhook starter";he.error(p)}};return n.jsxs(Wt,{open:c,onOpenChange:h,children:[n.jsx(Vt,{asChild:!0,children:n.jsxs(ie,{variant:"outline",size:"sm",children:[n.jsx(Dt,{size:14}),"Add Starter"]})}),n.jsxs(Kt,{align:"end",className:"w-[200px]",children:[n.jsxs(ha,{children:[n.jsxs(ua,{className:"gap-2.5",children:[n.jsx(kn,{size:14,className:"text-muted-foreground shrink-0"}),"Every..."]}),n.jsx(fa,{className:"w-[160px]",children:v3.map(m=>n.jsxs(Ue,{className:"gap-2.5",onSelect:()=>u(m.cron),disabled:a.isPending,children:[n.jsx(kn,{size:14,className:"text-muted-foreground shrink-0"}),"Every ",m.label]},m.cron))})]}),n.jsxs(Ue,{className:"gap-2.5",onSelect:()=>{h(!1),i?.()},children:[n.jsx(kn,{size:14,className:"text-muted-foreground shrink-0"}),"Custom (cron)"]}),n.jsxs(Ue,{className:"gap-2.5",onSelect:()=>{h(!1),r?.()},children:[n.jsx(Mn,{size:14,className:"text-muted-foreground shrink-0"}),"Event"]}),n.jsxs(Ue,{className:"gap-2.5",onSelect:()=>{f()},disabled:a.isPending,children:[n.jsx(Ui,{size:14,className:"text-muted-foreground shrink-0"}),"Webhook"]})]})]})}function Bm(t){const e=U.c(31),{open:s,onOpenChange:i,url:r,token:o,title:a,description:l}=t,d=a===void 0?"Webhook ready":a,c=l===void 0?"Send a POST to this URL with the bearer token to fire the automation. The token is shown once — copy it now.":l,[h,u]=D.useState(null),[f,m]=D.useState("curl"),[p,g]=D.useState("header"),_=D.useId();let b;e[0]===Symbol.for("react.memo_cache_sentinel")?(b=async(A,O)=>{try{await navigator.clipboard.writeText(A),u(O),he.success("Copied"),setTimeout(()=>u(null),1500)}catch{he.error("Failed to copy")}},e[0]=b):b=e[0];const x=b;let v;e[1]!==p||e[2]!==o||e[3]!==r?(v=r&&o&&p==="url"?`${r.replace(/\/$/,"")}/${o}`:r??"",e[1]=p,e[2]=o,e[3]=r,e[4]=v):v=e[4];const y=v,S=r&&o?p==="header"?`curl -X POST "${y}" \\
|
|
466
|
+
`}),e[26]=y):y=e[26];let S;return e[27]!==v||e[28]!==h?(S=n.jsxs("div",{className:"relative flex w-full flex-col items-center justify-center gap-12 select-none [clip-path:inset(-24px_0_-200px_0)]",children:[h,v,y]}),e[27]=v,e[28]=h,e[29]=S):S=e[29],S}function ir(t){const e=U.c(10),{phase:s,current:i,children:r}=t,o=s-i,a=o<0,l=o===0,d=a?90:o*-22,c=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=ae("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(${d}px) scale(${c})`,g=l?"auto":"none";let _;e[1]!==h||e[2]!==p||e[3]!==g||e[4]!==u?(_={transform:p,opacity:h,zIndex:u,transitionDuration:"1000ms",pointerEvents:g},e[1]=h,e[2]=p,e[3]=g,e[4]=u,e[5]=_):_=e[5];let b;return e[6]!==r||e[7]!==f||e[8]!==_?(b=n.jsx("div",{"aria-hidden":f,className:m,style:_,children:r}),e[6]=r,e[7]=f,e[8]=_,e[9]=b):b=e[9],b}function po(t){const e=U.c(7),{showUrl:s}=t,i=s===void 0?!1:s;let r,o,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=n.jsx("div",{className:ae("size-2.5 rounded-full",Xt)}),o=n.jsx("div",{className:ae("size-2.5 rounded-full",Xt)}),a=n.jsx("div",{className:ae("size-2.5 rounded-full",Xt)}),e[0]=r,e[1]=o,e[2]=a):(r=e[0],o=e[1],a=e[2]);let l;e[3]!==i?(l=i&&n.jsx("div",{className:ae("ml-3 h-3.5 max-w-[220px] flex-1 rounded-sm",ms)}),e[3]=i,e[4]=l):l=e[4];let d;return e[5]!==l?(d=n.jsxs("div",{className:"flex h-7 shrink-0 items-center gap-1.5 px-3",children:[r,o,a,l]}),e[5]=l,e[6]=d):d=e[6],d}function V0(){const t=U.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(po,{}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsxs("div",{className:"flex h-full flex-col",children:[e,n.jsx("div",{className:"flex flex-1 px-8 py-5",children:n.jsx("div",{className:"grid h-full w-full grid-cols-8 grid-rows-6 gap-2",children:$0.map(K0)})})]}),t[1]=s):s=t[1],s}function K0(t,e){if(e===om)return n.jsx("div",{className:"rounded-md bg-chart-1/[0.55]",style:{animation:"vm-breathe 2.4s ease-in-out infinite"}},e);const s=t;return n.jsx("div",{className:ae("relative rounded-md",Xt),children:n.jsx("div",{className:"absolute inset-0 rounded-md bg-chart-1/40 opacity-0",style:{animation:`vm-rack-scan ${am}s ease-in-out infinite`,animationDelay:`${s}s`}})},e)}function q0(){const t=U.c(5);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(po,{}),t[0]=e):e=t[0];let s;t[1]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx("div",{className:ae("w-[18%] rounded-md",ms),style:{animation:"vm-breathe 3s ease-in-out infinite"}}),t[1]=s):s=t[1];let i;t[2]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx("div",{className:"h-[42%] shrink-0 rounded-md bg-chart-3/[0.12]",style:{animation:"vm-breathe 3s ease-in-out 0.4s infinite"}}),t[2]=i):i=t[2];let r;t[3]===Symbol.for("react.memo_cache_sentinel")?(r=n.jsx("div",{className:"col-span-3 rounded-md bg-chart-3/[0.12]",style:{animation:"vm-breathe 3s ease-in-out 0.8s infinite"}}),t[3]=r):r=t[3];let o;return t[4]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsxs("div",{className:"flex h-full flex-col",children:[e,n.jsxs("div",{className:"flex min-h-0 flex-1 gap-1.5 p-3",children:[s,n.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-1.5",children:[i,n.jsxs("div",{className:"grid min-h-0 flex-1 grid-cols-5 gap-1.5",children:[r,n.jsxs("div",{className:"col-span-2 grid grid-rows-2 gap-1.5",children:[n.jsx("div",{className:ae("rounded-md",ms),style:{animation:"vm-breathe 3s ease-in-out 1.2s infinite"}}),n.jsx("div",{className:ae("rounded-md",ms),style:{animation:"vm-breathe 3s ease-in-out 1.6s infinite"}})]})]})]})]})]}),t[4]=o):o=t[4],o}function G0(){const t=U.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(po,{}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsxs("div",{className:"flex h-full flex-col",children:[e,n.jsx("div",{className:"relative flex flex-1 items-center justify-center px-8 py-5",children:n.jsx("div",{className:"grid w-full gap-2",style:{gridTemplateColumns:"repeat(7, minmax(0, 1fr))"},children:H0.map(Y0)})})]}),t[1]=s):s=t[1],s}function Y0(t,e){return n.jsx("div",{className:ae("aspect-square rounded-md",U0[e]?"bg-chart-2/70":Xt),style:{animation:`vm-pulse-soft 2.2s ease-in-out ${t}s infinite`}},e)}function X0(){const t=U.c(11);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(po,{showUrl:!0}),t[0]=e):e=t[0];let s,i,r,o,a;t[1]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx("div",{className:"mb-2 h-5 rounded-md bg-chart-1/[0.10]"}),i=n.jsx("div",{className:ae("h-1.5 w-[70%] rounded-sm",Xt)}),r=n.jsx("div",{className:ae("h-1.5 w-[55%] rounded-sm",Xt)}),o=n.jsx("div",{className:ae("h-1.5 w-[80%] rounded-sm",Xt)}),a=n.jsx("div",{className:ae("h-1.5 w-[50%] rounded-sm",Xt)}),t[1]=s,t[2]=i,t[3]=r,t[4]=o,t[5]=a):(s=t[1],i=t[2],r=t[3],o=t[4],a=t[5]);let l;t[6]===Symbol.for("react.memo_cache_sentinel")?(l=n.jsxs("div",{className:"flex w-[18%] shrink-0 flex-col gap-1.5 bg-chart-1/[0.05] p-2.5",children:[s,i,r,o,a,n.jsx("div",{className:"mt-auto",children:n.jsx("div",{className:ae("h-4 rounded-md",Xt)})})]}),t[6]=l):l=t[6];let d;t[7]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx("div",{className:"relative h-[42%] shrink-0 overflow-hidden bg-chart-1/[0.10]",children:n.jsxs("div",{className:"absolute right-3 bottom-3 left-3 space-y-1.5",children:[n.jsx("div",{className:"h-3 w-[35%] rounded-sm bg-chart-1/[0.15]"}),n.jsx("div",{className:ae("h-1.5 w-[55%] rounded-sm",ms)})]})}),t[7]=d):d=t[7];let c;t[8]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsxs("div",{className:"flex shrink-0 gap-1.5",children:[n.jsx("div",{className:"h-4 w-12 rounded-full bg-chart-1/[0.12]"}),n.jsx("div",{className:ae("h-4 w-10 rounded-full",ms)}),n.jsx("div",{className:ae("h-4 w-14 rounded-full",ms)})]}),t[8]=c):c=t[8];let h;t[9]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsxs("div",{className:ae("col-span-3 flex flex-col justify-end gap-1 rounded-md p-2",ms),children:[n.jsx("div",{className:ae("h-1.5 w-[50%] rounded-sm",Xt)}),n.jsx("div",{className:ae("h-1 w-[75%] rounded-sm",Xt)})]}),t[9]=h):h=t[9];let u;return t[10]===Symbol.for("react.memo_cache_sentinel")?(u=n.jsxs("div",{className:"flex h-full flex-col",children:[e,n.jsxs("div",{className:"flex min-h-0 flex-1",children:[l,n.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[d,n.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-2.5 p-3",children:[c,n.jsxs("div",{className:"grid min-h-0 flex-1 grid-cols-5 gap-2",children:[h,n.jsxs("div",{className:"col-span-2 grid grid-rows-2 gap-2",children:[n.jsx("div",{className:ae("rounded-md",ms)}),n.jsx("div",{className:ae("rounded-md",ms)})]})]})]})]})]})]}),t[10]=u):u=t[10],u}function Wr(t){const e=U.c(9);if(t.kind==="starting"){let l;return e[0]!==t.claimPhase||e[1]!==t.progress?(l=n.jsx("div",{className:"flex h-full w-full items-center justify-center bg-background p-6",children:n.jsx(W0,{progress:t.progress,claimPhase:t.claimPhase})}),e[0]=t.claimPhase,e[1]=t.progress,e[2]=l):l=e[2],l}let s;e[3]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx(T_,{className:"size-12 text-blue-500"}),e[3]=s):s=e[3];let i,r;e[4]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx("h3",{className:"text-lg font-medium",children:B0("suspended")}),r=n.jsx("p",{className:"max-w-sm text-sm text-muted-foreground",children:"Resume to continue."}),e[4]=i,e[5]=r):(i=e[4],r=e[5]);let o;e[6]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx(Di,{className:"size-4"}),e[6]=o):o=e[6];let a;return e[7]!==t.onResume?(a=n.jsx("div",{className:"flex h-full w-full items-center justify-center bg-background p-6",children:n.jsxs("div",{className:"flex w-full max-w-md flex-col items-center gap-4 text-center",children:[s,i,r,n.jsxs(ie,{onClick:t.onResume,className:"mt-2",children:[o," Resume"]})]})}),e[7]=t.onResume,e[8]=a):a=e[8],a}function J0(t){const e=U.c(12),{orgSlug:s,virtualMcpId:i,branch:r,enabled:o}=t,a=o===void 0?!0:o;let l;e[0]!==r||e[1]!==s||e[2]!==i?(l=Et.sandboxRepoDir(s,i,r),e[0]=r,e[1]=s,e[2]=i,e[3]=l):l=e[3];let d;e[4]!==r||e[5]!==s||e[6]!==i?(d=async()=>{const u=`/api/${s}/sandbox/${encodeURIComponent(i)}/${encodeURIComponent(r)}/config`,f=await fetch(u);return f.ok?(await f.json()).repoDir??null:null},e[4]=r,e[5]=s,e[6]=i,e[7]=d):d=e[7];let c;return e[8]!==a||e[9]!==l||e[10]!==d?(c={queryKey:l,queryFn:d,enabled:a,staleTime:1/0},e[8]=a,e[9]=l,e[10]=d,e[11]=c):c=e[11],Es(c).data??null}const hd="https://decoims.com/decocms/01b321bd-4613-4b2c-9348-35058444d210/Visual_Studio_Code_1.35_icon.svg.png",ud="https://decoims.com/decocms/7583d3b5-81d0-4afb-becf-6a59bbb3a68e/cursor-logo-icon-freelogovectors.net_.png",Z0=D.lazy(()=>ls(()=>import("./sections-editor-C33mQAPq.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])).then(t=>({default:t.SectionsEditor}))),Q0=D.lazy(()=>ls(()=>import("./page-seo-sheet-Cb5cCBSA.js"),__vite__mapDeps([141,1,2,70,42,44,7,8,9,10,11,12,13,14,15,16,6,3,4,5,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,43,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,71,72,73,74,75,76,77,78,97,98,100,91,88,101,102,80,81,82,83,84,85,86,87,89,90,92,93,94,95,96,103,104,105,106,107,108,109,110,111,79,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])).then(t=>({default:t.SeoSheet}))),e2=D.lazy(()=>ls(()=>import("./file-explorer-BfDoSrZk.js"),__vite__mapDeps([142,1,2,117,7,8,9,10,11,12,13,14,15,16,6,3,4,5,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,122,143,116,106,79,109,100,91,88,101,102,80,81,82,83,84,85,86,87,89,90,92,93,94,95,96,103,104,105,107,108,110,111,112,113,114,115,118,119,120,121,98,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140])).then(t=>({default:t.FileExplorer}))),Do=500,t2={mobile:375,tablet:768,desktop:null},Io=["desktop","mobile","tablet"],s2={mobile:"Mobile (375px)",tablet:"Tablet (768px)",desktop:"Desktop"},i2="website/sections/Rendering/Lazy.tsx";function ya(t,e){let s=t,i=typeof s?.__resolveType=="string"?s.__resolveType:"";for(let r=0;i&&r<5;r++){const o=e[i];if(o&&typeof o=="object"&&"__resolveType"in o){const a=o.__resolveType;if(typeof a=="string"&&a&&a!==i){s=o,i=a;continue}}break}if(!i)return[];if(i.includes("flags/multivariate")){const r=Array.isArray(s.variants)?s.variants:[],o=[];for(const a of r){const l=a?.value;if(l&&typeof l=="object")for(const d of ya(l,e))o.includes(d)||o.push(d)}return o}if(i===i2){const r=s.section&&typeof s.section=="object"?ya(s.section,e):[];return r.length?[i,...r]:[i]}return[i]}function n2(t,e){const s=new URL(t,window.location.href);return s.searchParams.set("deviceHint",e),s.href}function r2(){const t=gi(),{currentBranch:e}=Ts(),[s,i]=D.useState("preview"),[r,o]=D.useState("desktop"),[a,l]=D.useState(null),d=D.useRef(null),c=s==="cms",[h,u]=D.useState(null),[f,m]=D.useState(null),[p,g]=D.useState(384),_=D.useRef(!1),b=D.useRef(0),x=D.useRef(0),v=D.useRef(null),[y,S]=D.useState(!1),[w,C]=D.useState(""),N=D.useRef(null),[E,R]=D.useState(!1),[T,k]=D.useState(),[j,I]=D.useState(null),[A,O]=D.useState(null),[L,P]=D.useState("/"),[B,F]=D.useState(null),[H,z]=D.useState(!1),[W,q]=D.useState(!1),[K,Z]=D.useState(null),Y=t?.entity?.id??null,{org:G}=Me(),Q=bs(),$=Gl(),X=$.vmEntry,V=$.previewUrl,se=Q.lifecycle.phase,ee=se==="running",le=X?.sandboxProviderKind==="user-desktop",ce=J0({orgSlug:G.slug,virtualMcpId:Y??"",branch:e??"",enabled:le&&ee&&!!Y&&!!e}),fe=le?ce:null,J=Y&&e&&ee?{orgSlug:G.slug,virtualMcpId:Y,branch:e,previewUrl:V}:null,{data:te}=Ol(J,{fetchEnabled:ee}),{data:oe}=Bl(J,{fetchEnabled:ee}),de=Y&&e?{orgSlug:G.slug,virtualMcpId:Y,branch:e}:null,be=N0(de),ve=te?Vl(te).sort((ne,je)=>ne.name.localeCompare(je.name)):[],we=te&&oe?ql(te,oe):[],De=Ti,Be=ve.filter(ne=>{if(!w)return!0;const je=w.toLowerCase();return ne.name.toLowerCase().includes(je)||ne.path.toLowerCase().includes(je)}),Pe=we.filter(ne=>{if(!w)return!0;const je=w.toLowerCase();return ne.name.toLowerCase().includes(je)||ne.key.toLowerCase().includes(je)||ne.resolveType.toLowerCase().includes(je)}),Fe=j?null:ix(ve,L,B),xe=j?j.name:Fe?.name,ye=Fe?.key??null,Ie=te&&ye?tm(te,ye,0):[],Le=te?Xf(Ie,te):[],qe=Le.map(ne=>ne.isSavedBlock?ne.label:""),st=Le.map(ne=>ne.isSavedBlock?"global":ne.isMultivariate?"variant":"normal"),ct=Ie.map(ne=>ya(ne,te??{})),Se=D.useRef(null),pe=D.useRef(null);mx(()=>{const ne=d.current,je=Se.current;!ne||!je||(ne.src=je)});const $e=Q.status.state==="paused",Ge=Q.phase,He=rm({claimPhase:Ge,lifecycle:Q.lifecycle}),Ye=$.previewState,M=$.userStopped,ue=Ye.kind==="starting"||Ye.kind==="iframe"&&He.status==="doing",ge=Ye.kind==="iframe"?c0(n2(A??new URL(L,Ye.previewUrl).href,r),c&&f?f:[]):null,[ke,Je]=D.useState(null);if(Ye.kind==="iframe"&&ke!==Ye.previewUrl){const ne=ke!==null;Je(Ye.previewUrl),ne&&(pe.current=null,P("/"),O(null),F(null),I(null))}Se.current=ge;const mt=!!Y&&!!e&&!Q.notFound&&!M&&!$e&&(Ge?.kind==="ready"||se!=="idle"),Vs=Ye.kind!=="iframe"&&(s==="visual"||s==="cms")?"preview":s;D.useEffect(()=>{if(!V)return;let ne;try{ne=new URL(V,window.location.href).origin}catch{return}const je=bt=>{if(bt.origin===ne){if(bt.data?.type==="visual-editor::element-clicked"){const yt=T0.safeParse(bt.data.payload);yt.success&&l(yt.data)}else if(bt.data?.type==="cms-editor::section-clicked"){const yt=R0.safeParse(bt.data.payload);yt.success&&u(yt.data.sectionIndex)}}};return window.addEventListener("message",je),()=>window.removeEventListener("message",je)},[V]),D.useEffect(()=>{if(!y)return;const ne=je=>{N.current?.contains(je.target)||(S(!1),C(""))};return document.addEventListener("pointerdown",ne),()=>document.removeEventListener("pointerdown",ne)},[y]),D.useEffect(()=>{if(!c)return;const ne=bt=>{const yt=bt.target;yt&&yt!==d.current&&(v.current=yt)},je=()=>{requestAnimationFrame(()=>{const bt=document.activeElement;(bt===document.body||bt===d.current)&&v.current&&v.current.focus()})};return document.addEventListener("focusin",ne),document.addEventListener("blur",je,!0),()=>{document.removeEventListener("focusin",ne),document.removeEventListener("blur",je,!0)}},[c]);const tn=()=>{const ne=d.current?.contentWindow;ne&&ne.postMessage({type:"visual-editor::activate",script:A0},"*")},Ip=()=>{const ne=d.current?.contentWindow;ne&&ne.postMessage({type:"visual-editor::deactivate"},"*")},Nc=()=>{const ne=d.current?.contentWindow;ne&&(ne.postMessage({type:"visual-editor::activate",script:P0},"*"),ne.postMessage({type:"cms-editor::set-labels",labels:qe,kinds:st,keys:ct},"*"))},Lp=()=>{const ne=d.current?.contentWindow;ne&&ne.postMessage({type:"cms-editor::deactivate"},"*")},sn=ne=>{const je=s;i(ne),l(null),ne!=="code"&&Z(null),ne!=="cms"&&(u(null),m(null)),je==="visual"&&Ip(),je==="cms"&&Lp(),ne==="visual"&&tn(),ne==="cms"&&Nc()},Op=()=>{if(!d.current||!ge)return;const ne=d.current;ne.src=ge},Bp=ne=>{m(ne)},Mp=()=>{const ne=d.current;if(!ne)return;const je=document.activeElement,bt=ne.tabIndex;ne.tabIndex=-1,ne.style.pointerEvents="none",ne.blur();try{ne.contentWindow?.location.reload()}catch{const is=Se.current;is&&(ne.src=is)}const yt=()=>{ne.tabIndex=bt,ne.style.pointerEvents="",je?.focus(),ne.removeEventListener("load",yt)};ne.addEventListener("load",yt),setTimeout(yt,3e3)},$p=()=>{if(!d.current||!ge)return;const ne=ge.includes("?")?"&":"?";d.current.src=`${ge}${ne}_r=${Date.now()}`},zp=()=>{const ne=Io.indexOf(r);o(Io[(ne+1)%Io.length])},Fp=()=>{const ne=d.current?.contentWindow?.location?.href??ge??V;ne&&navigator.clipboard.writeText(ne)},Hp=(()=>{if(!V)return"No server running";if(j)return j.name;try{const ne=new URL(V),je=L==="/"?"":L;return`${ne.host}${je}`}catch{return V}})(),Ec=ne=>{pe.current=ne.path,I(null),O(null),F(ne.key),P(ne.path),u(null),z(!1)},Up=ne=>{if(!V||!oe){he.error("Preview metadata not ready yet");return}pe.current=null;const je=_f(oe),bt=S0(V,je,ne.key);I(ne),O(bt),u(null)},Wp=async({name:ne,path:je})=>{if(!Y||!e)return;const bt=Hl(je);if(bt){k(bt);return}const yt=je.trim().startsWith("/")?je.trim():`/${je.trim()}`;if(ve.some(is=>De(is.path)===De(yt))){k(`A page with path "${yt}" already exists.`);return}k(void 0);try{const is=await be.mutateAsync({name:ne,path:yt});R(!1),he.success(`Page "${ne}" created`),await new Promise(Kp=>setTimeout(Kp,Do)),Ec({key:is.key,name:is.name,path:is.path}),sn("cms")}catch(is){k(is instanceof Error?is.message:"Failed to create page")}},Vp=[{value:"preview",icon:n.jsx(Lc,{size:14}),tooltip:"Interactive"},...Ye.kind==="iframe"?[{value:"visual",icon:n.jsx(Oc,{size:14}),tooltip:"Visual editor"}]:[],...Ye.kind==="iframe"&&Wl(te,oe)?[{value:"cms",icon:n.jsx(A_,{size:14}),tooltip:"Sections editor"}]:[],{value:"code",icon:n.jsx(R_,{size:14}),tooltip:"Code editor"}];return n.jsxs("div",{className:"flex flex-col w-full h-full",children:[mt&&n.jsxs("div",{className:"flex h-12 shrink-0 items-center gap-4 border-b border-border/60 px-3 md:px-4",children:[n.jsx("div",{className:"flex shrink-0 items-center gap-1",children:n.jsx(x1,{value:Vs,onValueChange:sn,options:Vp,size:"sm",className:"shrink-0 bg-foreground/4.5"})}),Ye.kind==="iframe"&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:ae("flex min-w-0 flex-1 items-center gap-0.5 ml-2",s==="code"&&"hidden"),children:[n.jsxs(Te,{children:[n.jsx(Ne,{asChild:!0,children:n.jsx(ie,{variant:"ghost",size:"icon",onClick:Op,children:n.jsx(Pn,{size:14})})}),n.jsx(Ee,{side:"bottom",children:"Refresh"})]}),n.jsxs(Te,{children:[n.jsx(Ne,{asChild:!0,children:n.jsx(ie,{variant:"ghost",size:"icon",onClick:zp,children:n.jsxs("span",{className:"flex items-center justify-center animate-device-icon-pop",children:[r==="mobile"&&n.jsx(P_,{size:14}),r==="tablet"&&n.jsx(D_,{size:14}),r==="desktop"&&n.jsx(Lc,{size:14})]},r)})}),n.jsx(Ee,{side:"bottom",children:s2[r]})]}),n.jsxs("div",{ref:N,className:"relative min-w-0 flex-1",children:[n.jsxs("button",{type:"button",className:"flex h-8 w-full min-w-0 items-center gap-1 rounded-md bg-background px-2 transition-colors duration-200 hover:bg-accent",onClick:()=>S(ne=>!ne),children:[j&&n.jsxs("span",{className:"shrink-0 inline-flex items-center gap-1 rounded bg-global-section/14 px-1.5 py-0.5 text-[11px] font-medium text-global-section-fg dark:text-global-section-fg-dark",children:[n.jsx(si,{size:11}),"Global"]}),n.jsx("span",{className:"min-w-0 flex-1 truncate text-left text-[12px] text-foreground/88",children:Hp}),xe&&!j&&n.jsx("span",{className:"shrink-0 text-[12px] text-muted-foreground",children:xe}),n.jsx(cs,{size:12,className:ae("shrink-0 text-muted-foreground transition-transform",y&&"rotate-180")})]}),y&&n.jsxs("div",{className:"absolute left-0 right-0 top-full z-50 mt-1.5 overflow-hidden rounded-lg border bg-popover shadow-lg",children:[n.jsxs("div",{className:"px-2 h-10 flex items-center gap-2 border-b",children:[n.jsx(Wu,{size:14,className:"shrink-0 text-muted-foreground","aria-hidden":!0}),n.jsx("input",{type:"text",value:w,onChange:ne=>C(ne.target.value),placeholder:"Search pages and components...",className:"w-full bg-transparent text-sm outline-none placeholder:text-muted-foreground",autoFocus:!0})]}),n.jsx("div",{className:"p-1.5 border-b",children:n.jsxs("button",{type:"button",className:"flex w-full items-center gap-2.5 rounded-md px-3 py-2.5 text-left text-sm hover:bg-accent hover:text-accent-foreground",onMouseDown:ne=>{ne.preventDefault(),S(!1),C(""),k(void 0),R(!0)},children:[n.jsx(Dt,{size:16,className:"shrink-0 text-muted-foreground"}),n.jsx("span",{className:"flex-1 font-medium",children:"Create new page"})]})}),Be.length===0&&Pe.length===0?n.jsx("div",{className:"px-4 py-5 text-center text-xs text-muted-foreground",children:ve.length===0&&we.length===0?"No pages found in this site.":"No results match your search."}):n.jsxs("div",{className:"max-h-80 overflow-y-auto overscroll-contain",children:[Be.length>0&&n.jsx("div",{className:"p-1.5",children:Be.map(ne=>n.jsxs("button",{type:"button",className:"flex w-full items-center gap-3 rounded-md px-3 py-2.5 text-left text-sm hover:bg-accent hover:text-accent-foreground",onMouseDown:je=>{je.preventDefault(),S(!1),C(""),Ec(ne)},children:[n.jsx(Ni,{size:16,className:"shrink-0 text-muted-foreground"}),n.jsx("span",{className:"min-w-0 flex-1 truncate font-medium",children:ne.name}),n.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:ne.path})]},ne.key))}),Pe.length>0&&n.jsxs("div",{className:ae("p-1.5",Be.length>0&&"border-t"),children:[n.jsx("div",{className:"px-3 py-2 text-xs font-medium text-muted-foreground",children:"Global components"}),Pe.map(ne=>n.jsxs("button",{type:"button",className:"flex w-full items-center gap-3 rounded-md px-3 py-2.5 text-left text-sm hover:bg-accent hover:text-accent-foreground",onMouseDown:je=>{je.preventDefault(),S(!1),C(""),Up(ne)},children:[n.jsx(si,{size:16,className:"shrink-0 text-muted-foreground"}),n.jsx("span",{className:"min-w-0 flex-1 truncate font-medium",children:ne.name}),n.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:ne.resolveType.split("/").pop()?.replace(/\.tsx?$/,"")})]},ne.key))]})]})]})]})]}),n.jsxs("div",{className:ae("flex shrink-0 items-center gap-0.5",s==="code"&&"hidden"),children:[n.jsxs(Te,{children:[n.jsx(Ne,{asChild:!0,children:n.jsx(ie,{variant:"ghost",size:"icon",onClick:()=>{const ne=ge??Ye.previewUrl;ne&&window.open(ne,"_blank","noopener")},children:n.jsx(hi,{size:14})})}),n.jsx(Ee,{side:"bottom",children:"Open in new tab"})]}),n.jsxs(Wt,{children:[n.jsx(Vt,{asChild:!0,children:n.jsx(ie,{variant:"ghost",size:"icon",children:n.jsx(Hi,{size:14})})}),n.jsxs(Kt,{align:"end",className:"w-44",children:[n.jsx(Ue,{onClick:$p,children:"Hard Reload"}),n.jsx(Ue,{onClick:Fp,children:"Copy Current URL"}),te&&oe&&n.jsxs(n.Fragment,{children:[n.jsx(Cn,{}),ye&&n.jsxs(Ue,{onClick:()=>{z(!0),sn("cms")},children:[n.jsx(kr,{size:14}),"Edit SEO"]}),ye&&n.jsxs(Ue,{onClick:()=>{try{Z(Pc(ye)),sn("code")}catch{he.error("Invalid page block key")}},children:[n.jsx(no,{size:14}),"View JSON"]}),n.jsxs(Ue,{onClick:()=>q(!0),children:[n.jsx(kr,{size:14}),"Site SEO"]})]}),fe&&n.jsxs(n.Fragment,{children:[n.jsx(Cn,{}),n.jsxs(Ue,{onClick:()=>window.open(`vscode://file${fe}?windowId=_blank`),children:[n.jsx("img",{src:hd,alt:"VSCode",width:14,height:14}),"Open in VSCode"]}),n.jsxs(Ue,{onClick:()=>window.open(`cursor://file${fe}?windowId=_blank`),children:[n.jsx("img",{src:ud,alt:"Cursor",width:14,height:14}),"Open in Cursor"]})]})]})]})]})]}),s==="code"&&fe&&n.jsxs("div",{className:"ml-auto flex shrink-0 items-center gap-0.5",children:[n.jsxs(Te,{children:[n.jsx(Ne,{asChild:!0,children:n.jsx(ie,{variant:"ghost",size:"icon","aria-label":"Open in VSCode",onClick:()=>window.open(`vscode://file${fe}?windowId=_blank`),children:n.jsx("img",{src:hd,alt:"VSCode",width:14,height:14})})}),n.jsx(Ee,{side:"bottom",children:"Open in VSCode"})]}),n.jsxs(Te,{children:[n.jsx(Ne,{asChild:!0,children:n.jsx(ie,{variant:"ghost",size:"icon","aria-label":"Open in Cursor",onClick:()=>window.open(`cursor://file${fe}?windowId=_blank`),children:n.jsx("img",{src:ud,alt:"Cursor",width:14,height:14})})}),n.jsx(Ee,{side:"bottom",children:"Open in Cursor"})]})]})]}),n.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[c&&V&&e&&Y&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"shrink-0 border-r overflow-hidden",style:{width:p},children:n.jsx(D.Suspense,{fallback:n.jsx("div",{className:"h-full flex items-center justify-center",children:n.jsx(Oe,{size:20,className:"animate-spin text-muted-foreground"})}),children:n.jsx(Z0,{orgSlug:G.slug,virtualMcpId:Y,branch:e,previewReady:ee,previewUrl:V,currentPath:L,activePageBlockKey:ye,activeGlobalBlockKey:j?.key??null,externalSelectedIndex:j?null:h,onSaved:()=>{setTimeout(Mp,Do)},initialEditSeo:H,onExitSeo:()=>z(!1),onViewJsonFile:ne=>{try{Z(Pc(ne)),sn("code")}catch{he.error("Invalid page block key")}},onVariantPreviewOverride:Bp})})}),n.jsx("div",{className:"w-1 shrink-0 cursor-col-resize bg-transparent hover:bg-border transition-colors",onPointerDown:ne=>{_.current=!0,b.current=ne.clientX,x.current=p,ne.currentTarget.setPointerCapture(ne.pointerId)},onPointerMove:ne=>{if(!_.current)return;const je=ne.clientX-b.current;g(Math.max(240,Math.min(640,x.current+je)))},onPointerUp:()=>{_.current=!1}})]}),n.jsxs("div",{className:ae("flex-1 relative overflow-hidden",r!=="desktop"&&Ye.kind==="iframe"&&s!=="code"&&"flex justify-center bg-muted/30"),children:[ue&&n.jsx("div",{className:"absolute inset-0 z-30",children:n.jsx(Wr,{kind:"starting",progress:He,claimPhase:Ge})}),Ye.kind==="suspended"&&n.jsx("div",{className:"absolute inset-0 z-30",children:n.jsx(Wr,{kind:"suspended",onResume:$.resume})}),Vs==="visual"&&!a&&n.jsxs("div",{className:"absolute top-2 left-1/2 -translate-x-1/2 z-20 flex items-center gap-1.5 rounded-full border border-violet-400/40 bg-violet-500/90 px-3 py-1 text-xs font-medium text-white shadow-md backdrop-blur-sm pointer-events-none select-none",children:[n.jsx(Oc,{size:12}),"Click any element to ask the AI"]}),Vs==="visual"&&a&&n.jsx(L0,{element:a,onDismiss:()=>l(null)}),s==="code"&&mt&&Y&&e&&n.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:n.jsx(D.Suspense,{fallback:n.jsx("div",{className:"h-full flex items-center justify-center",children:n.jsx(Oe,{size:20,className:"animate-spin text-muted-foreground"})}),children:n.jsx(e2,{orgSlug:G.slug,virtualMcpId:Y,branch:e,openPath:K})})}),Ye.kind==="iframe"&&ge&&n.jsx("div",{className:ae("h-full transition-[width] duration-250 [transition-timing-function:var(--ease-in-out-cubic)]",r!=="desktop"&&s!=="code"&&"w-full max-w-full border-x border-border bg-background shadow-sm"),style:{width:r==="desktop"||s==="code"?"100%":`${t2[r]}px`},children:n.jsx("iframe",{ref:d,src:ge,className:ae("w-full h-full border-0",s==="code"&&"invisible"),title:"Dev Server Preview",tabIndex:c?-1:void 0,onLoad:()=>{if(Ke("vm_preview_loaded",{view_mode:s,vm_id:X?.sandboxHandle??null}),!j)try{const ne=d.current?.contentWindow?.location?.pathname;if(!ne)return;const je=pe.current;if(je!==null){pe.current=null,De(ne)===De(je)&&P(ne);return}P(ne)}catch{}s==="visual"&&tn(),s==="cms"&&Nc()}},Ye.previewUrl)})]})]}),n.jsx(E0,{open:E,onOpenChange:R,isPending:be.isPending,error:T,onSubmit:Wp}),W&&te&&oe&&n.jsx(D.Suspense,{fallback:null,children:n.jsx(Q0,{open:W,onOpenChange:q,orgSlug:G.slug,virtualMcpId:Y??"",branch:e??"",decofile:te,meta:oe,onSaved:()=>{setTimeout(()=>{const ne=d.current;if(ne)try{ne.contentWindow?.location.reload()}catch{const je=Se.current;je&&(ne.src=je)}},Do)},target:{kind:"site"}})})]})}function o2(t){const e=U.c(2),{virtualMcpId:s}=t,i=vs(s);if(!ti(i?.metadata)){let a;return e[0]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-2 text-center text-sm text-muted-foreground p-6",children:[n.jsx(zi,{size:24,className:"text-muted-foreground/60"}),n.jsx("div",{children:"No source to preview."}),n.jsx("div",{className:"text-xs text-muted-foreground/80",children:"Connect a GitHub repository from the Connections tab to enable Preview."})]}),e[0]=a):a=e[0],a}let o;return e[1]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx(r2,{}),e[1]=o):o=e[1],o}function a2(t){const e=U.c(8);let s,i;e[0]!==t?({className:s,...i}=t,e[0]=t,e[1]=s,e[2]=i):(s=e[1],i=e[2]);let r;e[3]!==s?(r=ae("grid gap-3",s),e[3]=s,e[4]=r):r=e[4];let o;return e[5]!==i||e[6]!==r?(o=n.jsx(n1,{"data-slot":"radio-group",className:r,...i}),e[5]=i,e[6]=r,e[7]=o):o=e[7],o}function fd(t){const e=U.c(9);let s,i;e[0]!==t?({className:s,...i}=t,e[0]=t,e[1]=s,e[2]=i):(s=e[1],i=e[2]);let r;e[3]!==s?(r=ae("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]=r):r=e[4];let o;e[5]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx(r1,{"data-slot":"radio-group-indicator",className:"relative flex items-center justify-center",children:n.jsx(w1,{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]!==i||e[7]!==r?(a=n.jsx(i1,{"data-slot":"radio-group-item",className:r,...i,children:o}),e[6]=i,e[7]=r,e[8]=a):a=e[8],a}function l2(t,e){if(!t||!e?.length)return t;const s=Object.fromEntries(Object.entries(t.properties??{}).filter(([i])=>!e.includes(i)));return Object.keys(s).length>0?{...t,properties:s}:t}function c2(t,e,s){return typeof t!="string"?null:l2(Us(t,e),s)}function lm(t,e,s){if(!e||typeof t!="string")return!1;const i=c2(t,e,s);return!!i&&Object.keys(i.properties??{}).length>0}function d2({orgSlug:t,virtualMcpId:e,branch:s}){const i=oi();return ai({mutationFn:async({blockKey:r})=>{const o=wu(r),a=await fetch(`/api/${t}/sandbox/${encodeURIComponent(e)}/${encodeURIComponent(s)}/unlink`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({path:o})});if(!a.ok){const l=await a.json().catch(()=>({}));throw new Error(l.error??`Delete failed (${a.status})`)}return a.json()},onMutate:async({blockKey:r})=>{const o=`${t}/${e}/${s}`,a=Et.decofile(o);await i.cancelQueries({queryKey:a});const l=i.getQueryData(a);return i.setQueryData(a,d=>{if(!d)return d;const{[r]:c,...h}=d;return h}),{previous:l,queryKey:a}},onError:(r,o,a)=>{a?.queryKey&&i.setQueryData(a.queryKey,a.previous)},onSuccess:()=>{const r=`${t}/${e}/${s}`;i.invalidateQueries({queryKey:Et.liveMeta(r)})}})}function go(t,e){return`${t}-${e}`}function cm(t,e){return`site/apps/${t}/${e}.ts`}function dm(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 h2(t){const e=t.match(/^([^-]+)-(.+)$/);return e?{vendor:e[1],app:e[2]}:null}function u2(t){return t==="local"?"Custom":"Installed"}function hm(t,e,s){const i=new Set([go(t,e),e].map(o=>o.toLowerCase())),r=cm(t,e);for(const[o,a]of Object.entries(s)){if(o.includes("/")||!a||typeof a!="object"||Array.isArray(a))continue;const l=a;if(i.has(o.toLowerCase())||l.__resolveType===r)return o}return null}function f2(t,e){const s=t.vendor.alias,i=t.name,r=hm(s,i,e);return{id:go(s,i),app:i,vendor:s,title:t.title||t.name,description:t.description,category:t.category??"Other",logo:t.logo||void 0,resolveType:cm(s,i),blockKey:r,installed:r!==null}}function m2(t,e,s){if(t===Ul)return null;const i=dm(t);if(!i)return null;const{vendor:r,app:o}=i,a=hm(r,o,s),l=fi(t,e);return{id:go(r,o),app:o,vendor:r,title:l.title??o,description:l.description??"",category:"Others",logo:l.logo??l.icon,resolveType:t,blockKey:a,installed:a!==null}}function p2(t,e,s){const i=e.__resolveType;if(typeof i!="string"||$r(t,e)||!mf(i))return null;const r=dm(i)??h2(t);if(!r)return null;const o=fi(i,s),{vendor:a,app:l}=r;return{id:go(a,l),app:l,vendor:a,title:o.title??zr(t,e,s),description:o.description??"",category:u2(a),logo:o.logo??o.icon,resolveType:i,blockKey:t,installed:!0}}function g2(t,e,s){const i=new Map;for(const o of t){const a=f2(o,s);i.set(a.id,a)}const r=e.manifest?.blocks?.apps??{};for(const o of Object.keys(r)){const a=m2(o,e,s);!a||i.has(a.id)||i.set(a.id,a)}for(const[o,a]of Object.entries(s)){if(o.includes("/")||!a||typeof a!="object"||Array.isArray(a))continue;const l=p2(o,a,e);!l||i.has(l.id)||i.set(l.id,l)}return[...i.values()].sort(_2)}function _2(t,e){return t.installed!==e.installed?t.installed?-1:1:t.title.localeCompare(e.title)}async function v2(){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 x2(t,e,s){const i=U.c(12),r=s?.enabled??!0;let o;i[0]===Symbol.for("react.memo_cache_sentinel")?(o=Et.decoApps(),i[0]=o):o=i[0];let a;i[1]!==r?(a={queryKey:o,queryFn:v2,staleTime:3e5,retry:1,enabled:r},i[1]=r,i[2]=a):a=i[2];const l=Es(a);let d;i[3]!==e||i[4]!==t||i[5]!==l.data?(d=t&&e?g2(l.data??[],t,e):[],i[3]=e,i[4]=t,i[5]=l.data,i[6]=d):d=i[6];const c=d,h=l.isLoading&&!l.isError;let u;return i[7]!==c||i[8]!==l.isError||i[9]!==l.refetch||i[10]!==h?(u={catalog:c,isLoading:h,isError:l.isError,refetch:l.refetch},i[7]=c,i[8]=l.isError,i[9]=l.refetch,i[10]=h,i[11]=u):u=i[11],u}function SE(t,e,s,i,r){const o={...t[e]};if(r.length>1){const a=o.sections,l=[...a?.variants??[]];l[i]&&(l[i]={...l[i],value:s}),o.sections={...a,variants:l}}else o.sections=s;return o}function wE(t){return structuredClone(t)}function CE(t){return!t.isSavedBlock&&!t.isMultivariate&&!t.isHidden}function b2(t){const e=t.replace(/[^A-Za-z0-9_-]/g,"");return/^[A-Za-z]/.test(e)?e:e?`Block${e}`:""}function y2(t,e){const s=t.trim();return s?s.includes("/")?"Block name cannot contain slashes.":Object.hasOwn(e,s)?"A block with this name already exists.":/^[A-Za-z][A-Za-z0-9_-]*$/.test(s)?null:"Use letters, numbers, hyphens, or underscores. Must start with a letter.":"Block name is required."}function S2(t){return(e,s)=>{r_(e),t(e,s)}}const w2=new Set(["http:","https:","mailto:","tel:","ftp:"]);function C2(t){if(t.startsWith("/")||t.startsWith(".")||t.startsWith("#"))return!0;try{const e=new URL(t,"https://placeholder.invalid");return w2.has(e.protocol)}catch{return!1}}function ys(t){const e=U.c(8),{active:s,label:i,onClick:r,children:o}=t,a=s?"bg-accent text-accent-foreground":"text-muted-foreground hover:bg-muted hover:text-foreground";let l;e[0]!==a?(l=ae("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 d;return e[2]!==s||e[3]!==o||e[4]!==i||e[5]!==r||e[6]!==l?(d=n.jsx("button",{type:"button","aria-label":i,"aria-pressed":s,onMouseDown:k2,onClick:r,className:l,children:o}),e[2]=s,e[3]=o,e[4]=i,e[5]=r,e[6]=l,e[7]=d):d=e[7],d}function k2(t){return t.preventDefault()}function j2({schema:t,value:e,onChange:s,path:i,label:r}){const o=typeof e=="string"?e:"",a=D.useRef(s);a.current=s;const l=Ng({extensions:[Eg.configure({heading:{levels:[1,2,3]}})],content:o||"",editorProps:{attributes:{class:ae("prose prose-sm dark:prose-invert max-w-none focus:outline-none","min-h-[80px] px-3 py-2")}},onUpdate:({editor:d})=>{const c=d.getHTML();a.current(c==="<p></p>"?"":c)}});return l?n.jsxs("div",{className:"space-y-2",children:[n.jsxs("div",{className:"space-y-0.5",children:[n.jsx(Ve,{htmlFor:i,children:r}),t.description&&n.jsx("p",{className:"text-xs leading-normal text-muted-foreground",children:t.description})]}),n.jsxs("div",{className:"overflow-hidden rounded-md border border-input",children:[n.jsxs("div",{className:"flex flex-wrap items-center gap-0.5 border-b border-border/60 bg-muted/30 px-1.5 py-1",children:[n.jsx(ys,{active:l.isActive("bold"),label:"Bold",onClick:()=>l.chain().focus().toggleBold().run(),children:n.jsx(I_,{size:14})}),n.jsx(ys,{active:l.isActive("italic"),label:"Italic",onClick:()=>l.chain().focus().toggleItalic().run(),children:n.jsx(L_,{size:14})}),n.jsx(ys,{active:l.isActive("underline"),label:"Underline",onClick:()=>l.chain().focus().toggleUnderline().run(),children:n.jsx(O_,{size:14})}),n.jsx(ys,{active:l.isActive("strike"),label:"Strikethrough",onClick:()=>l.chain().focus().toggleStrike().run(),children:n.jsx(B_,{size:14})}),n.jsx("div",{className:"mx-0.5 h-4 w-px bg-border"}),n.jsx(ys,{active:l.isActive("heading",{level:1}),label:"Heading 1",onClick:()=>l.chain().focus().toggleHeading({level:1}).run(),children:n.jsx(M_,{size:14})}),n.jsx(ys,{active:l.isActive("heading",{level:2}),label:"Heading 2",onClick:()=>l.chain().focus().toggleHeading({level:2}).run(),children:n.jsx($_,{size:14})}),n.jsx("div",{className:"mx-0.5 h-4 w-px bg-border"}),n.jsx(ys,{active:l.isActive("bulletList"),label:"Bullet list",onClick:()=>l.chain().focus().toggleBulletList().run(),children:n.jsx(y1,{size:14})}),n.jsx(ys,{active:l.isActive("orderedList"),label:"Ordered list",onClick:()=>l.chain().focus().toggleOrderedList().run(),children:n.jsx("span",{className:"text-[11px] font-semibold leading-none",children:"1."})}),n.jsx("div",{className:"mx-0.5 h-4 w-px bg-border"}),n.jsx(ys,{active:l.isActive("link"),label:"Link",onClick:()=>{const d=l.getAttributes("link").href,c=window.prompt("Link URL",d??"https://");c!==null&&(c===""?l.chain().focus().unsetLink().run():C2(c)&&l.chain().focus().setLink({href:c}).run())},children:n.jsx(_g,{size:14})})]}),n.jsx(Tg,{editor:l})]})]}):null}const Ci=t=>String(t).padStart(2,"0"),N2="1900-01-01",E2="2099-12-31",T2="1900-01-01T00:00",A2="2099-12-31T23:59";function R2(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()}-${Ci(s.getUTCMonth()+1)}-${Ci(s.getUTCDate())}`}function P2(t){return!t||!/^\d{4}-\d{2}-\d{2}$/.test(t)?"":`${t}T00:00:00.000Z`}function D2(t){if(!t)return"";const e=new Date(t);return Number.isNaN(e.getTime())?"":`${e.getFullYear()}-${Ci(e.getMonth()+1)}-${Ci(e.getDate())}T${Ci(e.getHours())}:${Ci(e.getMinutes())}`}function I2(t){if(!t)return"";const e=new Date(t);return Number.isNaN(e.getTime())?"":e.toISOString()}function L2(t){const e=U.c(29),{id:s,withTime:i,value:r,onChange:o}=t,[a,l]=D.useState(!1);let d;e[0]!==r||e[1]!==i?(d=i?D2(r):R2(r),e[0]=r,e[1]=i,e[2]=d):d=e[2];const c=d;let h;e[3]!==o||e[4]!==i?(h=E=>{o(i?I2(E.target.value):P2(E.target.value))},e[3]=o,e[4]=i,e[5]=h):h=e[5];const u=h;let f;if(e[6]!==r){const E=r?new Date(r):null;f=E&&!Number.isNaN(E.getTime())?E:null,e[6]=r,e[7]=f}else f=e[7];const m=f;let p;e[8]!==o||e[9]!==m||e[10]!==i?(p=E=>{E&&(i&&m?E.setHours(m.getHours(),m.getMinutes(),0,0):E.setHours(0,0,0,0),o(E.toISOString()),l(!1))},e[8]=o,e[9]=m,e[10]=i,e[11]=p):p=e[11];const g=p,_=i?"datetime-local":"date",b=i?T2:N2,x=i?A2:E2;let v;e[12]!==u||e[13]!==s||e[14]!==c||e[15]!==_||e[16]!==b||e[17]!==x?(v=n.jsx(ze,{id:s,type:_,min:b,max:x,value:c,onChange:u,className:"h-10 flex-1 [&::-webkit-calendar-picker-indicator]:hidden [&::-webkit-calendar-picker-indicator]:opacity-0"}),e[12]=u,e[13]=s,e[14]=c,e[15]=_,e[16]=b,e[17]=x,e[18]=v):v=e[18];let y;e[19]===Symbol.for("react.memo_cache_sentinel")?(y=n.jsx(Rs,{asChild:!0,children:n.jsx(ie,{type:"button",variant:"outline",size:"icon",className:"h-10 w-10 shrink-0","aria-label":"Open calendar",children:n.jsx(Eu,{className:"h-4 w-4"})})}),e[19]=y):y=e[19];const S=m??void 0;let w;e[20]!==g||e[21]!==S?(w=n.jsx(Ps,{className:"w-auto p-0",align:"end",children:n.jsx(k1,{mode:"single",selected:S,onSelect:g,initialFocus:!0})}),e[20]=g,e[21]=S,e[22]=w):w=e[22];let C;e[23]!==a||e[24]!==w?(C=n.jsxs(As,{open:a,onOpenChange:l,children:[y,w]}),e[23]=a,e[24]=w,e[25]=C):C=e[25];let N;return e[26]!==C||e[27]!==v?(N=n.jsxs("div",{className:"flex gap-1",children:[v,C]}),e[26]=C,e[27]=v,e[28]=N):N=e[28],N}function nr(t){const e=U.c(8),{htmlFor:s,label:i,description:r}=t;let o;e[0]!==s||e[1]!==i?(o=n.jsx(Ve,{htmlFor:s,children:i}),e[0]=s,e[1]=i,e[2]=o):o=e[2];let a;e[3]!==r?(a=r&&n.jsx("p",{className:"text-xs leading-normal text-muted-foreground",children:r}),e[3]=r,e[4]=a):a=e[4];let l;return e[5]!==o||e[6]!==a?(l=n.jsxs("div",{className:"space-y-0.5",children:[o,a]}),e[5]=o,e[6]=a,e[7]=l):l=e[7],l}function rr(t){const e=U.c(67),{schema:s,value:i,onChange:r,path:o,label:a}=t,l=typeof i=="string"?i:"",d=s.format;if(d==="rich-text"||d==="rich-text-inline"||d==="html"){let g;return e[0]!==a||e[1]!==r||e[2]!==o||e[3]!==s||e[4]!==i?(g=n.jsx(j2,{schema:s,value:i,onChange:r,path:o,label:a}),e[0]=a,e[1]=r,e[2]=o,e[3]=s,e[4]=i,e[5]=g):g=e[5],g}if(d==="textarea"||d==="markdown"){let g;e[6]!==a||e[7]!==o||e[8]!==s.description?(g=n.jsx(nr,{htmlFor:o,label:a,description:s.description}),e[6]=a,e[7]=o,e[8]=s.description,e[9]=g):g=e[9];let _;e[10]!==r?(_=v=>r(v.target.value),e[10]=r,e[11]=_):_=e[11];let b;e[12]!==o||e[13]!==l||e[14]!==_?(b=n.jsx(Ln,{id:o,value:l,onChange:_,rows:4}),e[12]=o,e[13]=l,e[14]=_,e[15]=b):b=e[15];let x;return e[16]!==g||e[17]!==b?(x=n.jsxs("div",{className:"space-y-2",children:[g,b]}),e[16]=g,e[17]=b,e[18]=x):x=e[18],x}if(d==="date"||d==="date-time"){let g;e[19]!==a||e[20]!==o||e[21]!==s.description?(g=n.jsx(nr,{htmlFor:o,label:a,description:s.description}),e[19]=a,e[20]=o,e[21]=s.description,e[22]=g):g=e[22];const _=d==="date-time";let b;e[23]!==r||e[24]!==o||e[25]!==l||e[26]!==_?(b=n.jsx(L2,{id:o,withTime:_,value:l,onChange:r}),e[23]=r,e[24]=o,e[25]=l,e[26]=_,e[27]=b):b=e[27];let x;return e[28]!==g||e[29]!==b?(x=n.jsxs("div",{className:"space-y-2",children:[g,b]}),e[28]=g,e[29]=b,e[30]=x):x=e[30],x}if(d==="color-input"){let g;e[31]!==a||e[32]!==o||e[33]!==s.description?(g=n.jsx(nr,{htmlFor:o,label:a,description:s.description}),e[31]=a,e[32]=o,e[33]=s.description,e[34]=g):g=e[34];const _=l||"#000000";let b;e[35]!==r?(b=C=>r(C.target.value),e[35]=r,e[36]=b):b=e[36];let x;e[37]!==_||e[38]!==b?(x=n.jsx("input",{type:"color",value:_,onChange:b,className:"h-10 w-10 cursor-pointer rounded-lg border border-border bg-background p-1"}),e[37]=_,e[38]=b,e[39]=x):x=e[39];let v;e[40]!==r?(v=C=>r(C.target.value),e[40]=r,e[41]=v):v=e[41];let y;e[42]!==o||e[43]!==l||e[44]!==v?(y=n.jsx(ze,{id:o,value:l,onChange:v,placeholder:"#000000",className:"h-10 flex-1"}),e[42]=o,e[43]=l,e[44]=v,e[45]=y):y=e[45];let S;e[46]!==x||e[47]!==y?(S=n.jsxs("div",{className:"flex items-center gap-2",children:[x,y]}),e[46]=x,e[47]=y,e[48]=S):S=e[48];let w;return e[49]!==g||e[50]!==S?(w=n.jsxs("div",{className:"space-y-2",children:[g,S]}),e[49]=g,e[50]=S,e[51]=w):w=e[51],w}let c;e[52]!==a||e[53]!==o||e[54]!==s.description?(c=n.jsx(nr,{htmlFor:o,label:a,description:s.description}),e[52]=a,e[53]=o,e[54]=s.description,e[55]=c):c=e[55];const h=d==="url"?"url":"text";let u;e[56]!==r?(u=g=>r(g.target.value),e[56]=r,e[57]=u):u=e[57];const f=s.default!=null?String(s.default):void 0;let m;e[58]!==o||e[59]!==l||e[60]!==h||e[61]!==u||e[62]!==f?(m=n.jsx(ze,{id:o,type:h,value:l,onChange:u,placeholder:f,className:"h-10"}),e[58]=o,e[59]=l,e[60]=h,e[61]=u,e[62]=f,e[63]=m):m=e[63];let p;return e[64]!==c||e[65]!==m?(p=n.jsxs("div",{className:"space-y-2",children:[c,m]}),e[64]=c,e[65]=m,e[66]=p):p=e[66],p}function O2(t){const e=U.c(17),{schema:s,value:i,onChange:r,path:o,label:a}=t,l=typeof i=="number"?i:"";let d;e[0]!==a||e[1]!==o?(d=n.jsx(Ve,{htmlFor:o,children:a}),e[0]=a,e[1]=o,e[2]=d):d=e[2];let c;e[3]!==s.description?(c=s.description&&n.jsx("p",{className:"text-xs leading-normal text-muted-foreground",children:s.description}),e[3]=s.description,e[4]=c):c=e[4];let h;e[5]!==d||e[6]!==c?(h=n.jsxs("div",{className:"space-y-0.5",children:[d,c]}),e[5]=d,e[6]=c,e[7]=h):h=e[7];let u;e[8]!==r?(u=p=>{const g=p.target.value;r(g===""?void 0:Number(g))},e[8]=r,e[9]=u):u=e[9];let f;e[10]!==l||e[11]!==o||e[12]!==u?(f=n.jsx(ze,{id:o,type:"number",value:l,onChange:u,className:"h-10"}),e[10]=l,e[11]=o,e[12]=u,e[13]=f):f=e[13];let m;return e[14]!==h||e[15]!==f?(m=n.jsxs("div",{className:"space-y-2",children:[h,f]}),e[14]=h,e[15]=f,e[16]=m):m=e[16],m}function B2(t){const e=U.c(17),{value:s,onChange:i,path:r,label:o,schema:a}=t,l=typeof s=="boolean"?s:!1;let d;e[0]!==o||e[1]!==r?(d=n.jsx(Ve,{htmlFor:r,children:o}),e[0]=o,e[1]=r,e[2]=d):d=e[2];let c;e[3]!==a.description?(c=a.description&&n.jsx("p",{className:"text-xs leading-normal text-muted-foreground",children:a.description}),e[3]=a.description,e[4]=c):c=e[4];let h;e[5]!==d||e[6]!==c?(h=n.jsxs("div",{className:"space-y-0.5",children:[d,c]}),e[5]=d,e[6]=c,e[7]=h):h=e[7];let u;e[8]!==i?(u=p=>i(p),e[8]=i,e[9]=u):u=e[9];let f;e[10]!==l||e[11]!==r||e[12]!==u?(f=n.jsx(On,{id:r,checked:l,onCheckedChange:u}),e[10]=l,e[11]=r,e[12]=u,e[13]=f):f=e[13];let m;return e[14]!==h||e[15]!==f?(m=n.jsxs("div",{className:"flex items-center justify-between gap-3",children:[h,f]}),e[14]=h,e[15]=f,e[16]=m):m=e[16],m}const rc="__enum_empty__";function oc(t){return t===""?rc:String(t)}function M2(t,e){if(t===rc)return"";const s=e.find(i=>oc(i)===t);return s!==void 0?s:t}function $2(t,e){return t==null?e.some(s=>s==="")?rc:void 0:oc(t)}function z2(t){return t===""?"":String(t)}function F2(t){const e=U.c(28),{schema:s,value:i,onChange:r,path:o,label:a}=t;let l;e[0]!==s.enum?(l=s.enum??[],e[0]=s.enum,e[1]=l):l=e[1];const d=l;let c;e[2]!==d||e[3]!==i?(c=$2(i,d),e[2]=d,e[3]=i,e[4]=c):c=e[4];const h=c;let u;e[5]!==a||e[6]!==o?(u=n.jsx(Ve,{htmlFor:o,children:a}),e[5]=a,e[6]=o,e[7]=u):u=e[7];let f;e[8]!==s.description?(f=s.description&&n.jsx("p",{className:"text-xs leading-normal text-muted-foreground",children:s.description}),e[8]=s.description,e[9]=f):f=e[9];let m;e[10]!==u||e[11]!==f?(m=n.jsxs("div",{className:"space-y-0.5",children:[u,f]}),e[10]=u,e[11]=f,e[12]=m):m=e[12];let p;e[13]!==r||e[14]!==d?(p=y=>r(M2(y,d)),e[13]=r,e[14]=d,e[15]=p):p=e[15];let g;e[16]===Symbol.for("react.memo_cache_sentinel")?(g=n.jsx(kt,{className:"h-10",children:n.jsx(Rt,{placeholder:"Select..."})}),e[16]=g):g=e[16];let _;e[17]!==d?(_=d.map(H2),e[17]=d,e[18]=_):_=e[18];let b;e[19]!==_?(b=n.jsx(jt,{children:_}),e[19]=_,e[20]=b):b=e[20];let x;e[21]!==h||e[22]!==p||e[23]!==b?(x=n.jsxs(Nt,{value:h,onValueChange:p,children:[g,b]}),e[21]=h,e[22]=p,e[23]=b,e[24]=x):x=e[24];let v;return e[25]!==x||e[26]!==m?(v=n.jsxs("div",{className:"space-y-2",children:[m,x]}),e[25]=x,e[26]=m,e[27]=v):v=e[27],v}function H2(t){const e=oc(t);return n.jsx(tt,{value:e,children:z2(t)},e)}function ac(t){const e=t.__resolveType;if(typeof e!="string")return null;if(Tt(e)){const i=t.section?.__resolveType;return typeof i=="string"?i:e}return e}function U2(t){return t.includes("flags/multivariate")}function W2(t){return ut(t)}function V2(t,e){const s=[...t],i=new Set(s.map(o=>o.resolveType)),r=(o,a)=>{!o||i.has(o)||(i.add(o),s.push({resolveType:o,title:a??W2(o)}))};if(e.savedBlockKey&&r(e.savedBlockKey,e.savedBlockKey),e.editorValue&&typeof e.editorValue=="object"&&!Array.isArray(e.editorValue)){const o=ac(e.editorValue);o?.includes("/")&&r(o)}return s}function K2(t,e,s){const i=e[0]?.resolveType??"";if(s)return s;if(!t||typeof t!="object"||Array.isArray(t))return i;const r=t,o=r.__resolveType;if(typeof o=="string"){if(Ns(o)){const u=e.find(f=>f.resolveType===o);return u?u.resolveType:o}const c=e.find(u=>Kc(u.resolveType,o));if(c)return c.resolveType;const h=e.find(u=>u.resolveType===o);if(h)return h.resolveType;if(o.includes("/"))return o}const a=typeof r.type=="string"?r.type:void 0;if(a){const c=e.find(h=>h.discriminatorValue===a||h.resolveType===a||Kc(h.resolveType,a));if(c)return c.resolveType}let l=i,d=-1;for(const c of e){if(!c.schema?.properties)continue;const u=Object.keys(c.schema.properties).filter(f=>!f.startsWith("__")&&f!=="@type"&&f!=="action"&&f!=="alt").filter(f=>r[f]!==void 0).length;u>0&&u>d&&(d=u,l=c.resolveType)}return d>0,l}function md(t,e,s){if(!t||typeof t!="object"||Array.isArray(t))return s??null;const i=ac(t);if(!i)return s??null;if(!e)return i.includes("/")?null:s??null;const r=Us(i,e);return r||(i.includes("/")?null:s??null)}function q2(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 um(t){if(!t||typeof t!="object"||Array.isArray(t))return null;const e=t;if(typeof e.__resolveType!="string"||!Tt(e.__resolveType))return null;const s=e.section;return!s||typeof s!="object"||Array.isArray(s)?null:s}function G2(t,e){if(e)return!0;if(!t||typeof t!="object"||Array.isArray(t))return!1;const s=t,i=ac(s);return i&&U2(i)?Array.isArray(s.variants)&&s.variants.length>0:Object.keys(s).some(r=>!r.startsWith("__")&&r!=="@type")}function lc(t){if(typeof t=="string")return t;if(!t||typeof t!="object")return"";const e=t;if(Array.isArray(e.variants)){const s=e.variants,i=s.find(o=>o.rule?.__resolveType?.includes("always"));if(typeof i?.value=="string")return i.value;const r=s.find(o=>typeof o.value=="string");if(r)return r.value}return typeof e.src=="string"?e.src:typeof e.url=="string"?e.url:typeof e.value=="string"?e.value:""}function Y2(t){if(t?.trim())try{const e=new URL(t);return e.protocol!=="https:"?void 0:e.href}catch{return}}function X2(t){if(Array.isArray(t.variants)){const e=t.variants,s=e.find(r=>r.rule?.__resolveType?.includes("always"));if(typeof s?.value=="string")return s.value;const i=e.find(r=>typeof r.value=="string");if(i)return i.value}if(typeof t.src=="string")return t.src;if(typeof t.url=="string")return t.url;if(typeof t.value=="string")return t.value}function fm(t){if(typeof t=="string"||t==null||typeof t!="object")return t;if(Array.isArray(t))return t.map(fm);const e=t;return e.__resolveType?X2(e)??t:mm(e)}function mm(t){const e={};for(const[s,i]of Object.entries(t))e[s]=fm(i);return e}function J2(t,e){return e.split(".").reduce((s,i)=>{if(!(s==null||typeof s!="object"))return s[i]},t)}function pm(t){return t==null?"":Array.isArray(t)?t.map(pm).filter(Boolean).join(","):typeof t=="object"?"":String(t)}function cc(t,e){if(!t.includes("{"))return;const s=mm(e);return t.replace(/\{\{\{([^}]+)\}\}\}|\{\{([^}]+)\}\}/g,(r,o,a)=>{const l=(o??a??"").trim();return pm(J2(s,l))}).trim()||void 0}function Z2(t){return t.replace(/<[^>]*>/g,"").trim()}function Q2(t,e){if(e.includes("{"))return cc(e,t);const s=t[e];if(typeof s=="string"&&s)return s;if(Array.isArray(s)){const i=s.map(r=>r==null?"":String(r)).filter(Boolean).join(",");if(i)return i}}function Xs(t,e,s){if(typeof t=="string")return t.trim()?t:`Item ${e+1}`;if(typeof t=="number"||typeof t=="boolean")return String(t);if(t&&typeof t=="object"&&!Array.isArray(t)){let i=t;const r=um(i);if(r&&(i=r),s?.titleBy){const a=Q2(i,s.titleBy);if(a)return a}for(const a of["name","label","title","alt","text","href","id","key"]){const l=i[a];if(typeof l=="string"&&l.trim()){const d=s?.properties?.[a]?.format;if(d==="rich-text"||d==="html"){const c=Z2(l);if(c)return c;continue}return l}if(Array.isArray(l)){const d=l.map(c=>c==null?"":String(c)).filter(Boolean).join(",");if(d)return d}}const o=i.__resolveType;if(typeof o=="string"&&o)return ut(o);if(s?.title){const a=cc(s.title,i);if(a)return a;if(!s.title.includes("{"))return s.title}}return`Item ${e+1}`}function eS(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 pd(t,e){if(!t||typeof t!="object"||Array.isArray(t))return;const s=eS(e);if(!s)return;const i=cc(s,t);if(!i)return;const r=lc(i)||i;return Y2(r)}function gm(t){return t.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[_-]/g," ").replace(/^\w/,e=>e.toUpperCase())}function ii(t){return t.normalize("NFC").trim()}function St(t,e){return ii(t)===ii(e)}function gd(t,e){return ii(t).replace(/\s+/g,"").toLowerCase()===ii(e).replace(/\s+/g,"").toLowerCase()}function or(t,e,s){const i=ii(s);if(t.some(a=>St(a,i)||St(a,s)))return t;const r=[...t];return r.some(a=>St(a,e))||r.push(e),r.push(s),r}function tS(t,e,s){if(s.length===0)return s;const i=jn(t,e),r=s[0];return St(r,i)||St(r,t)?s.slice(1):s}function jn(t,e){return e.title??gm(t)}function kE(t,e){return e<=0?[]:t.slice(0,e)}function Lo(t,e){const s=ii(e);return t.findIndex(i=>ii(i)===s)}function _d(t,e){return t.type==="array"&&t.items||mo(t)?!0:Array.isArray(e)}function sS(t){return t!=null&&typeof t=="object"&&!Array.isArray(t)?t:{}}function zn(t,e,s,i){if(i.length===0)return null;const r=i[0];for(const a of t){const l=e[a];if(!l||!_d(l,s[a]))continue;const d=jn(a,l);if(St(r,d)||St(r,a)||i.some(c=>St(c,d)||St(c,a)))return a}for(const a of t){const l=e[a];if(!l||!_d(l,s[a]))continue;const d=s[a];if(!Array.isArray(d))continue;const c=l.items;for(let h=0;h<d.length;h++){const u=Xs(d[h],h,c);if(St(u,r))return a}}for(const a of t){const l=e[a];if(l?.type!=="object"||!l.properties)continue;const d=Object.keys(l.properties),c=sS(s[a]),h=jn(a,l);if(zn(d,l.properties,c,i)||(St(r,h)||St(r,a))&&zn(d,l.properties,c,i.slice(1)))return a}let o=null;for(const a of t){const l=e[a];if(l?.type!=="block-ref")continue;const d=jn(a,l);if(!(r!==d&&r!==a)){if(i.length>1){const c=s[a];if(c&&typeof c=="object"&&!Array.isArray(c)){const h=i[1];if(Object.keys(c).some(f=>!f.startsWith("__")&&(gd(gm(f),h)||gd(f,h))))return a}}o||(o=a)}}return o||null}function iS(t,e,s,i){return zn(t,e,s,i)}function nS(t,e,s,i,r){if(r.length===0||!s.properties)return!1;const o=Object.keys(s.properties);if(zn(o,s.properties,i,r))return!0;const a=r[0];return!St(a,e)&&!St(a,t)?!1:r.length>1||zn(o,s.properties,i,r.slice(1))!==null}function rS(t,e,s,i){if(e.length===0)return null;for(let o=0;o<e.length;o++){const a=e[o],l=s.findIndex((d,c)=>St(Xs(d,c,i),a));if(l>=0)return{index:l,innerPath:e.slice(o+1)}}const r=e.findIndex(o=>St(o,t));if(r>=0&&e.length>r+1){const o=e[r+1],a=s.findIndex((l,d)=>St(Xs(l,d,i),o));if(a>=0)return{index:a,innerPath:e.slice(r+2)}}return null}function Oo(t){return t.includes("/sections/")||t.includes("multivariate/section")||t===Yn}function oS(t){if(t.type==="block-ref"&&t.anyOfRefs?.length)return t.anyOfRefs.some(s=>Oo(s.resolveType));if(t.anyOfRefs?.length)return t.anyOfRefs.some(s=>Oo(s.resolveType));const e=t.properties?.__resolveType;return e?.type==="block-ref"&&e.anyOfRefs?.length?e.anyOfRefs.some(s=>Oo(s.resolveType)):!1}function aS(t,e){if(e==="global"||e==="sections"||mo(t))return!0;const s=t.type==="array"?t.items:void 0;return s?oS(s):!1}function vd(t){return Array.from({length:t},(e,s)=>({id:crypto.randomUUID(),index:s}))}function lS(t,e,s,i,r){if(e?.type==="object"&&e.properties&&Object.keys(e.properties).length>0||e?.type==="block-ref"&&e.anyOfRefs?.length)return e;if(t!=null&&typeof t=="object"&&!Array.isArray(t)){const o=t.__resolveType;if(typeof o=="string"&&s){const a=Us(o,s);if(a?.properties&&Object.keys(a.properties).length>0)return a}}if(s&&i&&r){const a=Us(i,s)?.properties?.[r]?.items;if(a?.properties&&Object.keys(a.properties).length>0)return{...a,titleBy:a.titleBy??e?.titleBy}}return e}function cS(t){const e=t.split(".").filter(s=>!/^\d+$/.test(s));return e[e.length-1]??t}function _m(t){return t.map((e,s)=>({...e,index:s}))}function dS(t,e){if(e===t.length)return t;if(e<t.length)return _m(t.slice(0,e));const s=Array.from({length:e-t.length},(i,r)=>({id:crypto.randomUUID(),index:t.length+r}));return[...t,...s]}function hS(t){const e=U.c(8),{labelText:s,imageSrc:i}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=n.jsx(bl,{className:"size-3.5 shrink-0 text-muted-foreground/40"}),e[0]=r):r=e[0];let o;e[1]!==i?(o=i&&n.jsx("img",{src:i,alt:"",referrerPolicy:"no-referrer",className:"h-12 max-w-[100px] shrink-0 rounded object-cover"}),e[1]=i,e[2]=o):o=e[2];let a;e[3]!==s?(a=n.jsx("span",{className:"min-w-0 truncate",children:s}),e[3]=s,e[4]=a):a=e[4];let l;return e[5]!==o||e[6]!==a?(l=n.jsxs(n.Fragment,{children:[r,n.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2.5 text-sm",children:[o,a]})]}),e[5]=o,e[6]=a,e[7]=l):l=e[7],l}function uS(t){const e=U.c(37),{sortableId:s,labelText:i,imageSrc:r,onOpen:o,onRemove:a}=t;let l;e[0]!==s?(l={id:s,animateLayoutChanges:pS},e[0]=s,e[1]=l):l=e[1];const{attributes:d,listeners:c,setNodeRef:h,transform:u,isDragging:f}=du(l);let m;e[2]!==u?(m=hu.Transform.toString(u?{...u,x:0}:null),e[2]=u,e[3]=m):m=e[3];const p=f?0:void 0;let g;e[4]!==m||e[5]!==p?(g={transform:m,opacity:p},e[4]=m,e[5]=p,e[6]=g):g=e[6];const _=g;let b;e[7]!==o?(b=I=>{(I.key==="Enter"||I.key===" ")&&(I.preventDefault(),o())},e[7]=o,e[8]=b):b=e[8];const x=f?"cursor-grabbing":"cursor-pointer";let v;e[9]!==x?(v=ae("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",x),e[9]=x,e[10]=v):v=e[10];let y;e[11]===Symbol.for("react.memo_cache_sentinel")?(y=n.jsx(bl,{className:"size-3.5 shrink-0 text-muted-foreground/40"}),e[11]=y):y=e[11];let S;e[12]!==r?(S=r&&n.jsx("img",{src:r,alt:"",referrerPolicy:"no-referrer",className:"h-12 max-w-[100px] shrink-0 rounded object-cover"}),e[12]=r,e[13]=S):S=e[13];let w;e[14]!==i?(w=n.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:i}),e[14]=i,e[15]=w):w=e[15];const C=`Open actions for ${i}`;let N;e[16]===Symbol.for("react.memo_cache_sentinel")?(N=n.jsx(Hi,{size:14}),e[16]=N):N=e[16];let E;e[17]!==C?(E=n.jsx(Vt,{asChild:!0,children:n.jsx(ie,{type:"button",variant:"ghost",size:"icon","aria-label":C,className:"size-6 shrink-0 opacity-0 transition-opacity group-hover:opacity-100",onClick:mS,onPointerDown:fS,children:N})}),e[17]=C,e[18]=E):E=e[18];let R;e[19]===Symbol.for("react.memo_cache_sentinel")?(R=n.jsx(es,{size:14}),e[19]=R):R=e[19];let T;e[20]!==a?(T=n.jsx(Kt,{align:"end",children:n.jsxs(Ue,{className:"text-destructive focus:text-destructive",onClick:a,children:[R,"Delete"]})}),e[20]=a,e[21]=T):T=e[21];let k;e[22]!==E||e[23]!==T?(k=n.jsxs(Wt,{children:[E,T]}),e[22]=E,e[23]=T,e[24]=k):k=e[24];let j;return e[25]!==d||e[26]!==i||e[27]!==c||e[28]!==o||e[29]!==h||e[30]!==_||e[31]!==w||e[32]!==k||e[33]!==b||e[34]!==v||e[35]!==S?(j=n.jsxs("div",{ref:h,style:_,...d,...c,role:"button",tabIndex:0,onClick:o,onKeyDown:b,className:v,title:i,children:[y,S,w,k]}),e[25]=d,e[26]=i,e[27]=c,e[28]=o,e[29]=h,e[30]=_,e[31]=w,e[32]=k,e[33]=b,e[34]=v,e[35]=S,e[36]=j):j=e[36],j}function fS(t){return t.stopPropagation()}function mS(t){return t.stopPropagation()}function pS(){return!1}function ar(t){const e=U.c(24),{schema:s,value:i,onChange:r,path:o,label:a,breadcrumbPath:l,onBreadcrumbChange:d,meta:c,decofile:h,onSaveReferencedBlock:u,containerResolveType:f,previewBaseUrl:m,onAddSectionItem:p,onRequestAddSection:g,sandbox:_}=t,b=l===void 0?[]:l,x=Array.isArray(i)?i:[],v=s.items,y=cS(o),S=aS(s,y),w=rS(a,b,x,v),C=w?.index??null,[N,E]=D.useState(()=>vd(x.length)),[R,T]=D.useState(null),[k,j]=D.useState(o),[I,A]=D.useState(x.length),O=D.useRef(!1);k!==o?(j(o),A(x.length),E(vd(x.length))):I!==x.length&&(A(x.length),E(xe=>dS(xe,x.length)));let L;e[0]!==v?(L=(xe,ye)=>Xs(xe,ye,v),e[0]=v,e[1]=L):L=e[1];const P=L,B=xe=>{if(O.current)return;const ye=P(x[xe],xe);d?.(or(b,a,ye))},F=xe=>{const ye=[...x,xe];r(ye);const Ie=ye.length-1,Le=Xs(xe,Ie,v);d?.(or(b,a,Le))},H=()=>{const xe=v?.type,ye=v?.default!==void 0?v.default:xe==="object"?{}:xe==="block-ref"?(()=>{const st=v?.anyOfRefs?.[0]?.resolveType;return typeof st!="string"||Mr(st)?{}:{__resolveType:st}})():xe==="number"||xe==="integer"?0:xe==="boolean"?!1:xe==="array"?[]:"",Ie=[...x,ye];r(Ie);const Le=Ie.length-1,qe=Xs(ye,Le,v);d?.(or(b,a,qe))},z=()=>{if(S){if(!m){he.error("Start the preview dev server to add sections.");return}if(g){g({append:F});return}he.error("Section picker is not available in this editor.");return}H()},W=xe=>{if(r(x.filter((ye,Ie)=>Ie!==xe)),C===xe){const ye=P(x[xe],xe),Ie=Lo(b,ye);d?.(Ie>=0?b.slice(0,Ie):[])}},q=(xe,ye)=>{const Ie=[...x];if(Ie[xe]=ye,r(Ie),xe===C&&C!==null){const Le=P(x[xe],xe),qe=Xs(ye,xe,v);if(Le!==qe){const st=Lo(b,Le);if(st>=0){const ct=[...b];ct[st]=qe,d?.(ct)}}}};let K;e[2]===Symbol.for("react.memo_cache_sentinel")?(K={activationConstraint:{distance:8}},e[2]=K):K=e[2];let Z;e[3]===Symbol.for("react.memo_cache_sentinel")?(Z={coordinateGetter:uu},e[3]=Z):Z=e[3];const Y=su(wr(nu,K),wr(iu,Z)),G=N.map(gS);let Q;e[4]===Symbol.for("react.memo_cache_sentinel")?(Q=xe=>{T(String(xe.active.id))},e[4]=Q):Q=e[4];const $=Q,X=xe=>{T(null);const{active:ye,over:Ie}=xe;if(!Ie||ye.id===Ie.id)return;const Le=G.indexOf(String(ye.id)),qe=G.indexOf(String(Ie.id));Le===-1||qe===-1||(E(st=>_m(la([...st],Le,qe))),r(la([...x],Le,qe)),O.current=!0,requestAnimationFrame(()=>{O.current=!1}))};let V;e[5]===Symbol.for("react.memo_cache_sentinel")?(V=()=>{T(null)},e[5]=V):V=e[5];const se=V,ee=R?N.find(xe=>xe.id===R):null,le=ee!=null?x[ee.index]:void 0,ce=ee!=null&&le!==void 0?P(le,ee.index):null,fe=ee!=null&&le!==void 0?pd(le,v):void 0;if(C!==null&&C<x.length){const xe=x[C],ye=lS(xe,v,c,f,y),Ie=()=>{const Le=P(xe,C),qe=or(b,a,Le),st=Lo(qe,Le);return st>=0?qe.slice(0,st+1):qe};return n.jsx("div",{className:"min-w-0",children:ye?.type==="object"&&ye.properties?n.jsx(Zi,{schema:ye,value:xe,onChange:Le=>q(C,Le),basePath:`${o}.${C}`,breadcrumbPath:w?.innerPath??[],onBreadcrumbChange:Le=>{d?.([...Ie(),...Le])},meta:c,decofile:h,onSaveReferencedBlock:u,previewBaseUrl:m,onAddSectionItem:p,onRequestAddSection:g,sandbox:_}):ye?uc({schema:ye,value:xe,onChange:Le=>q(C,Le),path:`${o}.${C}`,label:ye.title??`Item ${C+1}`,breadcrumbPath:w?.innerPath??[],onBreadcrumbChange:Le=>{d?.([...Ie(),...Le])},meta:c,decofile:h,onSaveReferencedBlock:u,previewBaseUrl:m,onAddSectionItem:p,onRequestAddSection:g,sandbox:_}):null})}const J="space-y-2";let te;e[6]!==a?(te=n.jsx("span",{className:"min-w-0 truncate text-sm font-medium",children:a}),e[6]=a,e[7]=te):te=e[7];const oe=x.length>0&&n.jsx("span",{className:"rounded-md bg-muted px-1.5 py-0.5 text-xs font-medium text-muted-foreground",children:x.length});let de;e[8]!==te||e[9]!==oe?(de=n.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[te,oe]}),e[8]=te,e[9]=oe,e[10]=de):de=e[10];let be;e[11]!==s.description?(be=s.description&&n.jsx("p",{className:"break-words text-xs leading-normal text-muted-foreground",children:s.description}),e[11]=s.description,e[12]=be):be=e[12];let ve;e[13]!==de||e[14]!==be?(ve=n.jsxs("div",{className:"min-w-0 space-y-0.5",children:[de,be]}),e[13]=de,e[14]=be,e[15]=ve):ve=e[15];const we=x.length>0&&n.jsx("div",{className:ae(R&&"cursor-grabbing"),children:n.jsxs(ru,{sensors:Y,collisionDetection:ou,onDragStart:$,onDragEnd:X,onDragCancel:se,children:[n.jsx(au,{items:G,strategy:lu,children:n.jsx("div",{className:"min-w-0 overflow-hidden rounded-xl border border-border/50 p-1.5",children:N.map(xe=>{const ye=x[xe.index];if(ye===void 0)return null;const Ie=P(ye,xe.index),Le=pd(ye,v);return n.jsx(uS,{sortableId:xe.id,labelText:Ie,imageSrc:Le,onOpen:()=>B(xe.index),onRemove:()=>W(xe.index)},xe.id)})})}),n.jsx(cu,{dropAnimation:null,children:ce?n.jsx("div",{className:"flex min-w-0 items-center gap-2.5 rounded-lg border border-border/60 bg-background px-2 py-2.5 shadow-lg ring-1 ring-border/60",children:n.jsx(hS,{labelText:ce,imageSrc:fe})}):null})]})});let De;e[16]===Symbol.for("react.memo_cache_sentinel")?(De=n.jsx(Dt,{size:14}),e[16]=De):De=e[16];const Be=S?"Add section":"Add item";let Pe;e[17]!==z||e[18]!==Be?(Pe=n.jsxs("button",{type:"button",onClick:z,className:"flex w-full items-center justify-center gap-1.5 rounded-xl border border-dashed border-border/60 py-2.5 text-sm text-muted-foreground transition-colors hover:border-border hover:bg-muted/30",children:[De,Be]}),e[17]=z,e[18]=Be,e[19]=Pe):Pe=e[19];let Fe;return e[20]!==ve||e[21]!==we||e[22]!==Pe?(Fe=n.jsxs("div",{className:J,children:[ve,we,Pe]}),e[20]=ve,e[21]=we,e[22]=Pe,e[23]=Fe):Fe=e[23],Fe}function gS(t){return t.id}function _S(t){const e=U.c(44),{schema:s,value:i,onChange:r,path:o,label:a,breadcrumbPath:l,onBreadcrumbChange:d,meta:c,decofile:h,onSaveReferencedBlock:u,previewBaseUrl:f,onAddSectionItem:m,onRequestAddSection:p,sandbox:g}=t;let _;e[0]!==l?(_=l===void 0?[]:l,e[0]=l,e[1]=_):_=e[1];const b=_,[x,v]=D.useState(!1);let y;e[2]!==i?(y=i!=null&&typeof i=="object"&&!Array.isArray(i)?i:{},e[2]=i,e[3]=y):y=e[3];const S=y;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 C=w;let N;e[6]!==b||e[7]!==C||e[8]!==a||e[9]!==S||e[10]!==s?(N=nS(C,a,s,S,b),e[6]=b,e[7]=C,e[8]=a,e[9]=S,e[10]=s,e[11]=N):N=e[11];const R=x||N,T=`${o}-fields`;let k;e[12]===Symbol.for("react.memo_cache_sentinel")?(k=()=>v(vS),e[12]=k):k=e[12];let j;e[13]!==R?(j=n.jsx("span",{className:"flex size-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors group-hover:text-accent-foreground",children:R?n.jsx(cs,{size:16}):n.jsx(Vi,{size:16})}),e[13]=R,e[14]=j):j=e[14];let I;e[15]!==a?(I=n.jsx("span",{className:"min-w-0 truncate text-sm font-medium",children:a}),e[15]=a,e[16]=I):I=e[16];let A;e[17]!==T||e[18]!==R||e[19]!==j||e[20]!==I?(A=n.jsxs("button",{type:"button","aria-expanded":R,"aria-controls":T,onClick:k,className:"group flex w-full min-w-0 items-center gap-2 rounded-md py-1.5 pr-2 text-left transition-colors hover:bg-accent hover:text-accent-foreground",children:[j,I]}),e[17]=T,e[18]=R,e[19]=j,e[20]=I,e[21]=A):A=e[21];let O;e[22]!==s.description?(O=s.description&&n.jsx("p",{className:"break-words pl-9 text-xs leading-normal text-muted-foreground",children:s.description}),e[22]=s.description,e[23]=O):O=e[23];let L;e[24]!==b||e[25]!==T||e[26]!==h||e[27]!==R||e[28]!==c||e[29]!==S||e[30]!==m||e[31]!==d||e[32]!==r||e[33]!==p||e[34]!==u||e[35]!==o||e[36]!==f||e[37]!==g||e[38]!==s?(L=R&&n.jsx("div",{id:T,className:"ml-3 min-w-0 max-w-full overflow-hidden border-l border-border/80 pl-5",children:n.jsx(Zi,{schema:s,value:S,onChange:r,basePath:o,breadcrumbPath:b,onBreadcrumbChange:d,meta:c,decofile:h,onSaveReferencedBlock:u,previewBaseUrl:f,onAddSectionItem:m,onRequestAddSection:p,sandbox:g})}),e[24]=b,e[25]=T,e[26]=h,e[27]=R,e[28]=c,e[29]=S,e[30]=m,e[31]=d,e[32]=r,e[33]=p,e[34]=u,e[35]=o,e[36]=f,e[37]=g,e[38]=s,e[39]=L):L=e[39];let P;return e[40]!==O||e[41]!==L||e[42]!==A?(P=n.jsxs("div",{className:"min-w-0 space-y-2",children:[A,O,L]}),e[40]=O,e[41]=L,e[42]=A,e[43]=P):P=e[43],P}function vS(t){return!t}function vm(t){return t===Yn||t===qi}function _o(t,e){if(!Object.hasOwn(e,t))return null;const s=e[t]??{},i=s.__resolveType??t;return{data:{...s},resolveType:i}}function Vr(t,e){const s=t.__resolveType??"";if(!s)return null;if(Tt(s)){const i=t.section??{};return xm(i,e)}if(vm(s)){const i=t.variants?.[0]?.value;return i?Vr(i,e):null}return!Ns(s)||!Object.hasOwn(e,s)?{data:{...t},resolveType:s}:_o(s,e)}function xm(t,e){const s=t.__resolveType??"";if(!s)return null;if(vm(s)){const i=t.variants?.[0]?.value;return i?Vr(i,e):null}return!Ns(s)||!Object.hasOwn(e,s)?{data:{...t},resolveType:s}:_o(s,e)}function xS(t,e){if(!t||typeof t!="object"||Array.isArray(t))return null;const i=t.__resolveType;if(typeof i!="string"||!Ns(i)||!Object.hasOwn(e,i))return null;const r=_o(i,e);return r?{blockKey:i,...r}:null}function bS(t,e,s){if(e.isMultivariate)return null;if(e.isSavedBlock){const i=e.isLazy?t.section?.__resolveType??t.__resolveType:t.__resolveType;return _o(i,s)}if(e.isHidden){const o=(Tt(t.__resolveType)?t.section:t)?.variants?.[0]?.value??t;return Vr(o,s)}if(e.isLazy||Tt(t.__resolveType)){const i=t.section??{};return xm(i,s)}return Vr(t,s)}function yS(t){if(!t?.properties)return{};const e={};for(const[s,i]of Object.entries(t.properties))s.startsWith("__")||s==="@type"||(i.default!==void 0?e[s]=i.default:i.type==="boolean"?e[s]=!1:i.type==="string"?e[s]="":i.type==="number"||i.type==="integer"?e[s]=0:i.type==="object"&&(e[s]={}));return e}function SS(t){const e=U.c(3),{blockKey:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx(Ne,{asChild:!0,children:n.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 rounded bg-global-section/14 px-1.5 py-0.5 text-[11px] font-medium text-global-section-fg dark:text-global-section-fg-dark",children:[n.jsx(Ui,{size:11}),"Global"]})}),e[0]=i):i=e[0];let r;return e[1]!==s?(r=n.jsxs(Te,{children:[i,n.jsxs(Ee,{side:"top",className:"max-w-[260px]",children:["Edits the saved block “",s,"”. Changes apply everywhere this loader is referenced on your site."]})]}),e[1]=s,e[2]=r):r=e[2],r}function wS(t){const e=U.c(28),{path:s,open:i,onOpenChange:r,title:o,nested:a,nestedBlockRef:l,globalBlockKey:d}=t,c=`${s}-loader-config`,h=l&&"ml-1";let u;e[0]!==h?(u=ae("rounded-lg border border-border/80 bg-muted/30",h),e[0]=h,e[1]=u):u=e[1];let f;e[2]!==r||e[3]!==i?(f=()=>r(!i),e[2]=r,e[3]=i,e[4]=f):f=e[4];let m;e[5]!==i?(m=n.jsx("span",{className:"flex size-6 shrink-0 items-center justify-center text-muted-foreground transition-colors group-hover:text-foreground",children:i?n.jsx(cs,{size:16}):n.jsx(Vi,{size:16})}),e[5]=i,e[6]=m):m=e[6];let p;e[7]!==o?(p=n.jsx("span",{className:"truncate text-xs font-medium tracking-wide text-muted-foreground uppercase",children:o}),e[7]=o,e[8]=p):p=e[8];let g;e[9]!==d?(g=d&&n.jsx(SS,{blockKey:d}),e[9]=d,e[10]=g):g=e[10];let _;e[11]!==p||e[12]!==g?(_=n.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[p,g]}),e[11]=p,e[12]=g,e[13]=_):_=e[13];let b;e[14]!==c||e[15]!==i||e[16]!==f||e[17]!==m||e[18]!==_?(b=n.jsxs("button",{type:"button","aria-expanded":i,"aria-controls":c,onClick:f,className:"group flex w-full min-w-0 items-center gap-2 rounded-lg px-3 py-2.5 text-left transition-colors hover:bg-accent/50",children:[m,_]}),e[14]=c,e[15]=i,e[16]=f,e[17]=m,e[18]=_,e[19]=b):b=e[19];let x;e[20]!==c||e[21]!==a||e[22]!==i?(x=i&&n.jsx("div",{id:c,className:"border-t border-border/60 px-4 pb-4 pt-3",children:n.jsx("div",{className:"border-l border-border/80 pl-4",children:a})}),e[20]=c,e[21]=a,e[22]=i,e[23]=x):x=e[23];let v;return e[24]!==u||e[25]!==b||e[26]!==x?(v=n.jsxs("div",{className:u,children:[b,x]}),e[24]=u,e[25]=b,e[26]=x,e[27]=v):v=e[27],v}function xd(t){const e=U.c(35),{schema:s,value:i,onChange:r,path:o,label:a,breadcrumbPath:l,onBreadcrumbChange:d,meta:c,decofile:h,onSaveReferencedBlock:u,sandbox:f}=t,m=(s.anyOfRefs??[]).filter(jS),p=h&&i?xS(i,h):null,g=p?.data??i,_=p?null:um(g),b=_??g,x=V2(m,{savedBlockKey:p?.blockKey,editorValue:g}),v=x.length>0?K2(g,x,p?.blockKey):x[0]?.resolveType??"",S=s.type==="block-ref"&&x.some(kS);let w;e[0]!==a||e[1]!==o?(w=a??(o.includes(".")?o.split(".")[0]:o),e[0]=a,e[1]=o,e[2]=w):w=e[2];const C=w;let N;e[3]!==l?(N=l??[],e[3]=l,e[4]=N):N=e[4];const E=N,R=S&&E[0]===C?E.slice(1):E,T=S?K=>{d?.([C,...K])}:d,[k,j]=D.useState(v),[I,A]=D.useState(v);I!==v&&(A(v),j(v));const[O,L]=D.useState(()=>G2(g,p?.blockKey));if(x.length>0){const K=k||v;let Z;e[5]!==K?(Z=oe=>oe.resolveType===K,e[5]=K,e[6]=Z):Z=e[6];const Y=x.find(Z),G=md(g,c,Y?.schema),Q=q2(G??Y?.schema??null,s.discriminatorKey),$=s.discriminatorKey,X=oe=>{j(oe);const de=x.find(Pe=>Pe.resolveType===oe),be=md(g,c,de?.schema),ve=new Set(Object.keys((be??de?.schema)?.properties??{})),we=i!==null&&typeof i=="object"&&!Array.isArray(i)?i:{},De=Object.fromEntries(Object.entries(we).filter(Pe=>{const[Fe]=Pe;return ve.has(Fe)})),Be={...yS(de?.schema),...De};if($){const Pe=de?.discriminatorValue??oe;r({...Be,[$]:Pe});return}if(Mr(oe)){r(Be);return}r({...Be,__resolveType:oe})};let V;e[7]!==K||e[8]!==$||e[9]!==r?(V=oe=>{if($||!Mr(K)||oe===null||typeof oe!="object"||Array.isArray(oe)){r(oe);return}const{__resolveType:de,...be}=oe;r(be)},e[7]=K,e[8]=$,e[9]=r,e[10]=V):V=e[10];const se=V,ee=Q?.properties?n.jsx(Zi,{schema:Q,value:b,onChange:oe=>{if(p&&u){u(p.blockKey,oe);return}if(_){r({...g,section:oe});return}se(oe)},basePath:o,breadcrumbPath:R,onBreadcrumbChange:T,meta:c,decofile:h,onSaveReferencedBlock:u,sandbox:f}):null;let le;e[11]!==o?(le=o.includes("."),e[11]=o,e[12]=le):le=e[12];const ce=le;let fe;e[13]!==a||e[14]!==o?(fe=n.jsx(Ve,{htmlFor:o,children:a}),e[13]=a,e[14]=o,e[15]=fe):fe=e[15];let J;e[16]===Symbol.for("react.memo_cache_sentinel")?(J=n.jsx(kt,{children:n.jsx(Rt,{placeholder:"Select..."})}),e[16]=J):J=e[16];let te;return e[17]!==s.description?(te=s.description&&n.jsx("p",{className:"text-xs text-muted-foreground",children:s.description}),e[17]=s.description,e[18]=te):te=e[18],n.jsxs("div",{className:"space-y-3",children:[n.jsxs("div",{className:"space-y-1.5",children:[fe,n.jsxs(Nt,{value:K||void 0,onValueChange:X,children:[J,n.jsx(jt,{children:x.map(CS)})]}),te]}),ee&&(S?n.jsx(wS,{path:o,open:O,onOpenChange:L,title:ce?"Configuration":"Loader configuration",nested:ee,nestedBlockRef:ce,globalBlockKey:p?.blockKey}):ee)]})}if(s.anyOfRefs&&s.anyOfRefs.length>0)return null;let P;e[19]!==a||e[20]!==o?(P=n.jsx(Ve,{htmlFor:o,children:a}),e[19]=a,e[20]=o,e[21]=P):P=e[21];const B=i!=null?String(i):"";let F;e[22]!==r?(F=K=>r(K.target.value),e[22]=r,e[23]=F):F=e[23];const H=s.description??"";let z;e[24]!==o||e[25]!==B||e[26]!==F||e[27]!==H?(z=n.jsx("input",{id:o,type:"text",value:B,onChange:F,className:"w-full rounded-md border bg-background px-3 py-1.5 text-sm",placeholder:H}),e[24]=o,e[25]=B,e[26]=F,e[27]=H,e[28]=z):z=e[28];let W;e[29]!==s.description?(W=s.description&&n.jsx("p",{className:"text-xs text-muted-foreground",children:s.description}),e[29]=s.description,e[30]=W):W=e[30];let q;return e[31]!==P||e[32]!==z||e[33]!==W?(q=n.jsxs("div",{className:"space-y-1.5",children:[P,z,W]}),e[31]=P,e[32]=z,e[33]=W,e[34]=q):q=e[34],q}function CS(t){const e=t.title&&!t.title.includes("/")?t.title:ga(t.resolveType)??ut(t.resolveType);return n.jsx(tt,{value:t.resolveType,children:e},t.resolveType)}function kS(t){return t.resolveType.includes("/")&&!Mr(t.resolveType)}function jS(t){return t.resolveType!==""}function NS(t){if(!Array.isArray(t))return[];const e=[];for(const s of t)if(typeof s=="string")e.push({value:s,label:s});else if(s&&typeof s=="object"&&"value"in s){const i=s;e.push({value:String(i.value),label:typeof i.label=="string"?i.label:String(i.value),image:typeof i.image=="string"?i.image:void 0})}return e}async function ES(t,e,s){const i={};s&&(i.term=s);const o=`${t.replace(/\/+$/,"")}/deco/invoke/${e}`,a=await fetch(o,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(i)});if(!a.ok)throw new Error(`Failed to fetch dynamic options: ${a.status}`);const l=await a.json();return NS(l)}function bd(t){const e=U.c(8),{path:s,label:i,description:r}=t;let o;e[0]!==i||e[1]!==s?(o=n.jsx(Ve,{htmlFor:s,children:i}),e[0]=i,e[1]=s,e[2]=o):o=e[2];let a;e[3]!==r?(a=r&&n.jsx("p",{className:"text-xs leading-normal text-muted-foreground",children:r}),e[3]=r,e[4]=a):a=e[4];let l;return e[5]!==o||e[6]!==a?(l=n.jsxs("div",{className:"space-y-0.5",children:[o,a]}),e[5]=o,e[6]=a,e[7]=l):l=e[7],l}function TS(t){const e=U.c(71),{schema:s,value:i,onChange:r,path:o,label:a,sandbox:l}=t,d=s.options,c=l?.previewUrl,[h,u]=D.useState(!1),[f,m]=D.useState(""),[p,g]=D.useState(""),_=D.useRef(null);let b;e[0]===Symbol.for("react.memo_cache_sentinel")?(b=G=>{m(G),_.current&&clearTimeout(_.current),_.current=setTimeout(()=>{g(G)},300)},e[0]=b):b=e[0];const x=b,v=l?`${l.orgSlug}/${l.virtualMcpId}/${l.branch}`:"";let y;e[1]!==p||e[2]!==d||e[3]!==v?(y=Et.sandboxInvoke(v,`dynamic-options:${d??""}:${p}`),e[1]=p,e[2]=d,e[3]=v,e[4]=y):y=e[4];let S;e[5]!==p||e[6]!==d||e[7]!==c?(S=()=>ES(c,d,p||void 0),e[5]=p,e[6]=d,e[7]=c,e[8]=S):S=e[8];const w=!!c&&!!d&&h;let C;e[9]!==y||e[10]!==S||e[11]!==w?(C={queryKey:y,queryFn:S,enabled:w,staleTime:6e4,retry:1},e[9]=y,e[10]=S,e[11]=w,e[12]=C):C=e[12];const N=Es(C);let E;e[13]!==N.data?(E=N.data??[],e[13]=N.data,e[14]=E):E=e[14];const R=E,T=typeof i=="string"?i:"";let k;if(e[15]!==T||e[16]!==R){let G;e[18]!==T?(G=Q=>Q.value===T,e[18]=T,e[19]=G):G=e[19],k=R.find(G),e[15]=T,e[16]=R,e[17]=k}else k=e[17];const j=k;if(!c||!d){let G;e[20]!==a||e[21]!==o||e[22]!==s.description?(G=n.jsx(bd,{path:o,label:a,description:s.description}),e[20]=a,e[21]=o,e[22]=s.description,e[23]=G):G=e[23];let Q;e[24]!==r?(Q=V=>r(V.target.value),e[24]=r,e[25]=Q):Q=e[25];let $;e[26]!==T||e[27]!==o||e[28]!==Q?($=n.jsx(ze,{id:o,type:"text",value:T,onChange:Q}),e[26]=T,e[27]=o,e[28]=Q,e[29]=$):$=e[29];let X;return e[30]!==$||e[31]!==G?(X=n.jsxs("div",{className:"space-y-2",children:[G,$]}),e[30]=$,e[31]=G,e[32]=X):X=e[32],X}let I;e[33]!==a||e[34]!==o||e[35]!==s.description?(I=n.jsx(bd,{path:o,label:a,description:s.description}),e[33]=a,e[34]=o,e[35]=s.description,e[36]=I):I=e[36];let A;e[37]!==T||e[38]!==j?(A=j?n.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[j.image&&n.jsx("img",{src:j.image,alt:"",referrerPolicy:"no-referrer",className:"h-6 w-6 shrink-0 rounded object-cover"}),n.jsx("span",{className:"truncate",children:j.label??j.value})]}):T?n.jsx("span",{className:"truncate",children:T}):n.jsx("span",{className:"text-muted-foreground",children:"Select..."}),e[37]=T,e[38]=j,e[39]=A):A=e[39];let O;e[40]===Symbol.for("react.memo_cache_sentinel")?(O=n.jsx(b1,{className:"size-4 shrink-0 opacity-50"}),e[40]=O):O=e[40];let L;e[41]!==h||e[42]!==A?(L=n.jsx(Rs,{asChild:!0,children:n.jsxs(ie,{variant:"outline",role:"combobox","aria-expanded":h,className:"h-10 w-full justify-between font-normal",children:[A,O]})}),e[41]=h,e[42]=A,e[43]=L):L=e[43];let P;e[44]===Symbol.for("react.memo_cache_sentinel")?(P={width:"var(--radix-popover-trigger-width)"},e[44]=P):P=e[44];let B;e[45]!==f?(B=n.jsx(Nl,{placeholder:"Search...",className:"h-9",value:f,onValueChange:x}),e[45]=f,e[46]=B):B=e[46];const F=N.isLoading?"Loading...":"No results found.";let H;e[47]!==F?(H=n.jsx(El,{children:F}),e[47]=F,e[48]=H):H=e[48];let z;if(e[49]!==T||e[50]!==r||e[51]!==R){let G;e[53]!==T||e[54]!==r?(G=Q=>n.jsxs(Or,{value:Q.value,onSelect:()=>{r(Q.value===T?"":Q.value),u(!1)},children:[n.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[Q.image&&n.jsx("img",{src:Q.image,alt:"",referrerPolicy:"no-referrer",className:"h-9 w-9 shrink-0 rounded object-cover"}),n.jsx("span",{className:"truncate",children:Q.label??Q.value})]}),n.jsx(js,{className:ae("ml-auto size-4 shrink-0",T===Q.value?"opacity-100":"opacity-0")})]},Q.value),e[53]=T,e[54]=r,e[55]=G):G=e[55],z=R.map(G),e[49]=T,e[50]=r,e[51]=R,e[52]=z}else z=e[52];let W;e[56]!==z?(W=n.jsx(Br,{children:z}),e[56]=z,e[57]=W):W=e[57];let q;e[58]!==H||e[59]!==W?(q=n.jsxs(Tl,{children:[H,W]}),e[58]=H,e[59]=W,e[60]=q):q=e[60];let K;e[61]!==B||e[62]!==q?(K=n.jsx(Ps,{className:"p-0",style:P,children:n.jsxs(Ku,{shouldFilter:!1,children:[B,q]})}),e[61]=B,e[62]=q,e[63]=K):K=e[63];let Z;e[64]!==h||e[65]!==L||e[66]!==K?(Z=n.jsxs(As,{open:h,onOpenChange:u,children:[L,K]}),e[64]=h,e[65]=L,e[66]=K,e[67]=Z):Z=e[67];let Y;return e[68]!==Z||e[69]!==I?(Y=n.jsxs("div",{className:"space-y-2",children:[I,Z]}),e[68]=Z,e[69]=I,e[70]=Y):Y=e[70],Y}function AS(t){const e=U.c(10),{org:s}=Me(),i=di();let r;e[0]!==s.id||e[1]!==t.configId?(r=Et.filePickerObjects(s.id,t.configId),e[0]=s.id,e[1]=t.configId,e[2]=r):r=e[2];const o=t.enabled!==!1&&!!t.configId;let a;e[3]!==t.configId||e[4]!==i?(a=async d=>{const{pageParam:c}=d;return await i.call("FILE_OBJECTS_LIST",{configId:t.configId,cursor:c??void 0})},e[3]=t.configId,e[4]=i,e[5]=a):a=e[5];let l;return e[6]!==r||e[7]!==o||e[8]!==a?(l={queryKey:r,enabled:o,staleTime:3e4,initialPageParam:null,queryFn:a,getNextPageParam:RS},e[6]=r,e[7]=o,e[8]=a,e[9]=l):l=e[9],T1(l)}function RS(t){return t.nextCursor??void 0}function dc(){const t=U.c(2),{org:e}=Me();let s;return t[0]!==e?(s={mutationFn:async i=>{const r=i.file.type||"application/octet-stream",o=await fetch(`/api/${encodeURIComponent(e.slug)}/file-configs/${encodeURIComponent(i.configId)}/upload?filename=${encodeURIComponent(i.file.name)}`,{method:"POST",headers:{"Content-Type":r},body:i.file});if(!o.ok){const a=await o.text().catch(PS);let l=`${o.status} ${o.statusText}`;try{const d=JSON.parse(a);d.message&&(l=d.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],ai(s)}function PS(){return""}const vo="file-picker:last-config-id";function bm(t){const e=U.c(19),s=t.mode==="image"?"Pick an image":"Pick a file";let i;e[0]!==s?(i=n.jsx(ss,{children:s}),e[0]=s,e[1]=i):i=e[1];let r;e[2]===Symbol.for("react.memo_cache_sentinel")?(r=n.jsx(Wi,{children:"Upload a new file or pick one previously uploaded to a configured bucket."}),e[2]=r):r=e[2];let o;e[3]!==i?(o=n.jsxs(ts,{children:[i,r]}),e[3]=i,e[4]=o):o=e[4];let a;e[5]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx(wl,{className:"h-64 w-full"}),e[5]=a):a=e[5];let l;e[6]!==t?(l=u=>{t.onSelect(u),t.onOpenChange(!1)},e[6]=t,e[7]=l):l=e[7];let d;e[8]!==t.lockedConfigId||e[9]!==t.mode||e[10]!==l?(d=n.jsx(Zt,{fallback:DS,children:n.jsx(D.Suspense,{fallback:a,children:n.jsx(LS,{mode:t.mode,lockedConfigId:t.lockedConfigId,onSelect:l})})}),e[8]=t.lockedConfigId,e[9]=t.mode,e[10]=l,e[11]=d):d=e[11];let c;e[12]!==o||e[13]!==d?(c=n.jsxs(Mt,{className:"sm:max-w-3xl max-h-[85vh] overflow-hidden flex flex-col",children:[o,d]}),e[12]=o,e[13]=d,e[14]=c):c=e[14];let h;return e[15]!==t.onOpenChange||e[16]!==t.open||e[17]!==c?(h=n.jsx(Bt,{open:t.open,onOpenChange:t.onOpenChange,children:c}),e[15]=t.onOpenChange,e[16]=t.open,e[17]=c,e[18]=h):h=e[18],h}function DS(t){const{error:e}=t;return n.jsx(IS,{error:e??new Error("Failed to load buckets")})}function IS(t){const e=U.c(3),{error:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx(zi,{size:16}),e[0]=i):i=e[0];let r;return e[1]!==s.message?(r=n.jsxs("div",{className:"p-4 rounded-md bg-destructive/10 text-destructive flex items-center gap-2",children:[i,n.jsx("span",{className:"text-sm font-medium",children:s.message})]}),e[1]=s.message,e[2]=r):r=e[2],r}function LS(t){const e=U.c(32),{mode:s,lockedConfigId:i,onSelect:r}=t,o=E1();if(o.length===0){let p;return e[0]===Symbol.for("react.memo_cache_sentinel")?(p=n.jsx(MS,{}),e[0]=p):p=e[0],p}if(i){let p;if(e[1]!==o||e[2]!==i){let _;e[4]!==i?(_=b=>b.id===i,e[4]=i,e[5]=_):_=e[5],p=o.find(_),e[1]=o,e[2]=i,e[3]=p}else p=e[3];const g=p;if(g){let _;return e[6]!==g||e[7]!==s||e[8]!==r?(_=n.jsx(Bo,{config:g,mode:s,onSelect:r}),e[6]=g,e[7]=s,e[8]=r,e[9]=_):_=e[9],_}}if(o.length===1){const p=o[0];let g;return e[10]!==p||e[11]!==s||e[12]!==r?(g=n.jsx(Bo,{config:p,mode:s,onSelect:r}),e[10]=p,e[11]=s,e[12]=r,e[13]=g):g=e[13],g}let a;e[14]===Symbol.for("react.memo_cache_sentinel")?(a=typeof window<"u"?window.localStorage.getItem(vo):null,e[14]=a):a=e[14];const l=a;let d;e[15]!==o?(d=o.find(p=>p.id===l)?.id??o[0].id,e[15]=o,e[16]=d):d=e[16];const c=d;let h;e[17]!==o?(h=o.map(OS),e[17]=o,e[18]=h):h=e[18];let u;e[19]!==h?(u=n.jsx(ao,{className:"self-start",children:h}),e[19]=h,e[20]=u):u=e[20];let f;if(e[21]!==o||e[22]!==s||e[23]!==r){let p;e[25]!==s||e[26]!==r?(p=g=>n.jsx(Ei,{value:g.id,className:"min-h-0 flex-1 overflow-hidden",children:n.jsx(Bo,{config:g,mode:s,onSelect:r})},g.id),e[25]=s,e[26]=r,e[27]=p):p=e[27],f=o.map(p),e[21]=o,e[22]=s,e[23]=r,e[24]=f}else f=e[24];let m;return e[28]!==c||e[29]!==u||e[30]!==f?(m=n.jsxs(lo,{defaultValue:c,onValueChange:BS,className:"min-h-0 flex-1 flex flex-col",children:[u,f]}),e[28]=c,e[29]=u,e[30]=f,e[31]=m):m=e[31],m}function OS(t){return n.jsx(zs,{value:t.id,children:t.name},t.id)}function BS(t){typeof window<"u"&&window.localStorage.setItem(vo,t)}function MS(){const t=U.c(4),{org:e}=Me();let s,i;t[0]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx("div",{className:"size-12 rounded-full bg-muted flex items-center justify-center",children:n.jsx(Kn,{size:20,className:"text-muted-foreground"})}),i=n.jsxs("div",{children:[n.jsx("p",{className:"font-medium text-sm",children:"No bucket configured"}),n.jsx("p",{className:"text-xs text-muted-foreground mt-1 max-w-sm",children:"Add an S3-compatible bucket in Settings before you can upload files."})]}),t[0]=s,t[1]=i):(s=t[0],i=t[1]);let r;return t[2]!==e.slug?(r=n.jsxs("div",{className:"rounded-xl border border-dashed border-border/60 p-10 flex flex-col items-center justify-center text-center gap-3",children:[s,i,n.jsx(ie,{asChild:!0,size:"sm",className:"mt-2",children:n.jsx(Vh,{to:"/$org/settings/files",params:{org:e.slug},children:"Configure a bucket"})})]}),t[2]=e.slug,t[3]=r):r=t[3],r}function Bo({config:t,mode:e,onSelect:s}){const i=AS({configId:t.id}),r=dc(),[o,a]=D.useState(!1),l=D.useRef(null),d=e==="image"?"image/*":void 0;async function c(_){if(!_)return;const b=Array.from(_);if(b.length===0)return;let x=null;const v=[];for(const y of b)try{const S=await r.mutateAsync({configId:t.id,file:y});x??=S.publicUrl}catch(S){v.push(`${y.name} (${S instanceof Error?S.message:"upload failed"})`)}await i.refetch(),v.length>0&&he.error(v.length===b.length?`Upload failed: ${v.join("; ")}`:`Some files failed: ${v.join("; ")}`),x&&s(x)}function h(_){_.preventDefault(),a(!0)}function u(){a(!1)}function f(_){_.preventDefault(),a(!1),c(_.dataTransfer.files)}const p=(i.data?.pages??[]).flatMap(_=>_.items),g=p.filter(_=>e==="image"?ym(_.key):!0);return n.jsxs("div",{className:"flex flex-col gap-3 min-h-0 h-full",children:[n.jsxs("button",{type:"button",onClick:()=>l.current?.click(),onDragOver:h,onDragLeave:u,onDrop:f,className:ae("rounded-xl border border-dashed border-border/60 p-6 flex flex-col items-center justify-center gap-2 text-center transition-colors",o&&"border-primary bg-primary/5",r.isPending&&"opacity-60 pointer-events-none"),children:[n.jsx(Kn,{size:18,className:"text-muted-foreground"}),n.jsx("p",{className:"text-sm font-medium",children:r.isPending?"Uploading…":"Drop files here or click to upload"}),n.jsxs("p",{className:"text-xs text-muted-foreground",children:["Up to 100 MB."," ",e==="image"?"Images only (PNG, JPEG, WebP, GIF, SVG, AVIF).":"Common image, video, audio, and document types."]}),n.jsx("input",{ref:l,type:"file",accept:d,multiple:!0,className:"hidden",onChange:_=>{const b=Array.from(_.target.files??[]);_.target.value="",c(b)}})]}),i.isFetching&&!i.isFetchingNextPage?n.jsx("div",{className:"flex justify-end",children:n.jsx("span",{className:"text-xs text-muted-foreground",children:"Loading…"})}):null,n.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto pr-1",children:[g.length===0?e==="image"&&p.length>0?n.jsx(zS,{}):n.jsx($S,{}):e==="image"?n.jsx(HS,{items:g,onSelect:s}):n.jsx(US,{items:g,onSelect:s}),i.hasNextPage&&n.jsx("div",{className:"flex justify-center py-4",children:n.jsx(ie,{type:"button",variant:"outline",size:"sm",disabled:i.isFetchingNextPage,onClick:()=>i.fetchNextPage(),children:i.isFetchingNextPage?n.jsxs(n.Fragment,{children:[n.jsx(Oe,{size:14,className:"animate-spin"}),"Loading…"]}):"Load more"})})]})]})}function $S(){const t=U.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsxs("div",{className:"flex h-full min-h-40 flex-col items-center justify-center gap-2 py-8 text-center",children:[n.jsx("div",{className:"flex size-10 items-center justify-center rounded-full bg-muted",children:n.jsx(Ii,{size:18,className:"text-muted-foreground"})}),n.jsx("p",{className:"text-sm font-medium",children:"No files in this bucket yet"}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Drop a file above to get started."})]}),t[0]=e):e=t[0],e}function zS(){const t=U.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsxs("div",{className:"flex h-full min-h-40 flex-col items-center justify-center gap-2 py-8 text-center",children:[n.jsx("div",{className:"flex size-10 items-center justify-center rounded-full bg-muted",children:n.jsx(Ii,{size:18,className:"text-muted-foreground"})}),n.jsx("p",{className:"text-sm font-medium",children:"No images in this bucket yet"}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"The bucket has other files, but none match common image formats."})]}),t[0]=e):e=t[0],e}function ym(t){return/\.(png|jpe?g|gif|webp|svg|avif|bmp)$/i.test(t)}function FS(t){const e=t.lastIndexOf(".");return e<0||e===t.length-1?"file":t.slice(e+1).toLowerCase()}function HS(t){const e=U.c(7),{items:s,onSelect:i}=t;let r;if(e[0]!==s||e[1]!==i){let a;e[3]!==i?(a=l=>n.jsx(Sm,{item:l,variant:"image",onSelect:i},l.key),e[3]=i,e[4]=a):a=e[4],r=s.map(a),e[0]=s,e[1]=i,e[2]=r}else r=e[2];let o;return e[5]!==r?(o=n.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 gap-3",children:r}),e[5]=r,e[6]=o):o=e[6],o}function US(t){const e=U.c(7),{items:s,onSelect:i}=t;let r;if(e[0]!==s||e[1]!==i){let a;e[3]!==i?(a=l=>n.jsx("li",{children:n.jsx(Sm,{item:l,variant:"row",onSelect:i})},l.key),e[3]=i,e[4]=a):a=e[4],r=s.map(a),e[0]=s,e[1]=i,e[2]=r}else r=e[2];let o;return e[5]!==r?(o=n.jsx("ul",{className:"divide-y divide-border/60 rounded-lg border border-border/60",children:r}),e[5]=r,e[6]=o):o=e[6],o}function Sm(t){const e=U.c(58),{item:s,variant:i,onSelect:r}=t;let o;e[0]!==s.key?(o=FS(s.key),e[0]=s.key,e[1]=o):o=e[1];const a=o;if(i==="image"){let v;e[2]!==s.publicUrl||e[3]!==r?(v=()=>r(s.publicUrl),e[2]=s.publicUrl,e[3]=r,e[4]=v):v=e[4];let y;e[5]!==s.key||e[6]!==s.publicUrl?(y=n.jsx("img",{src:s.publicUrl,alt:s.key,loading:"lazy",className:"h-full w-full object-cover",onError:WS}),e[5]=s.key,e[6]=s.publicUrl,e[7]=y):y=e[7];let S;e[8]!==s.key||e[9]!==v||e[10]!==y?(S=n.jsx("button",{type:"button",onClick:v,className:"block h-full w-full transition hover:ring-2 hover:ring-primary",title:s.key,children:y}),e[8]=s.key,e[9]=v,e[10]=y,e[11]=S):S=e[11];let w;e[12]!==a?(w=n.jsx("span",{className:"pointer-events-none absolute left-1.5 top-1.5 rounded bg-background/80 px-1.5 py-0.5 text-[10px] font-medium uppercase text-foreground opacity-0 backdrop-blur-sm transition-opacity group-hover:opacity-100",children:a}),e[12]=a,e[13]=w):w=e[13];let C;e[14]!==s||e[15]!==r?(C=n.jsx("div",{className:"absolute right-1.5 top-1.5 opacity-0 transition-opacity group-hover:opacity-100",children:n.jsx(yd,{item:s,onSelect:r})}),e[14]=s,e[15]=r,e[16]=C):C=e[16];let N;e[17]!==s.key?(N=Sd(s.key),e[17]=s.key,e[18]=N):N=e[18];let E;e[19]!==N?(E=n.jsx("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 bg-gradient-to-t from-black/70 to-transparent p-2 opacity-0 transition-opacity group-hover:opacity-100",children:n.jsx("p",{className:"truncate text-xs text-white",children:N})}),e[19]=N,e[20]=E):E=e[20];let R;return e[21]!==S||e[22]!==w||e[23]!==C||e[24]!==E?(R=n.jsxs("div",{className:"group relative aspect-square overflow-hidden rounded-lg border border-border/60 bg-muted",children:[S,w,C,E]}),e[21]=S,e[22]=w,e[23]=C,e[24]=E,e[25]=R):R=e[25],R}let l;e[26]!==s.publicUrl||e[27]!==r?(l=()=>r(s.publicUrl),e[26]=s.publicUrl,e[27]=r,e[28]=l):l=e[28];let d;e[29]!==s.key?(d=n.jsx("div",{className:"flex size-9 shrink-0 items-center justify-center rounded-md bg-muted",children:ym(s.key)?n.jsx(Ii,{size:16,className:"text-muted-foreground"}):n.jsx(Ri,{size:16,className:"text-muted-foreground"})}),e[29]=s.key,e[30]=d):d=e[30];let c;e[31]!==s.key?(c=Sd(s.key),e[31]=s.key,e[32]=c):c=e[32];let h;e[33]!==c?(h=n.jsx("p",{className:"truncate text-sm font-medium",children:c}),e[33]=c,e[34]=h):h=e[34];let u;e[35]!==s.key?(u=n.jsx("p",{className:"truncate font-mono text-xs text-muted-foreground",children:s.key}),e[35]=s.key,e[36]=u):u=e[36];let f;e[37]!==h||e[38]!==u?(f=n.jsxs("div",{className:"min-w-0 flex-1",children:[h,u]}),e[37]=h,e[38]=u,e[39]=f):f=e[39];let m;e[40]!==a?(m=n.jsx("span",{className:"shrink-0 rounded bg-muted px-1.5 py-0.5 text-[10px] font-medium uppercase text-muted-foreground",children:a}),e[40]=a,e[41]=m):m=e[41];let p;e[42]!==s.size?(p=GS(s.size),e[42]=s.size,e[43]=p):p=e[43];let g;e[44]!==p?(g=n.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:p}),e[44]=p,e[45]=g):g=e[45];let _;e[46]!==g||e[47]!==l||e[48]!==d||e[49]!==f||e[50]!==m?(_=n.jsxs("button",{type:"button",onClick:l,className:"flex min-w-0 flex-1 items-center gap-3 text-left",children:[d,f,m,g]}),e[46]=g,e[47]=l,e[48]=d,e[49]=f,e[50]=m,e[51]=_):_=e[51];let b;e[52]!==s||e[53]!==r?(b=n.jsx(yd,{item:s,onSelect:r}),e[52]=s,e[53]=r,e[54]=b):b=e[54];let x;return e[55]!==_||e[56]!==b?(x=n.jsxs("div",{className:"group flex items-center gap-3 px-3 py-2 transition hover:bg-muted/50",children:[_,b]}),e[55]=_,e[56]=b,e[57]=x):x=e[57],x}function WS(t){t.target.style.display="none"}function yd(t){const e=U.c(22),{item:s,onSelect:i}=t,[r,o]=D.useState(!1);let a;e[0]!==s.publicUrl?(a=async function(v){v.preventDefault(),v.stopPropagation();try{await navigator.clipboard.writeText(s.publicUrl),o(!0),window.setTimeout(()=>o(!1),1500)}catch{he.error("Failed to copy URL")}},e[0]=s.publicUrl,e[1]=a):a=e[1];const l=a;let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx(Vt,{asChild:!0,children:n.jsx(ie,{type:"button",variant:"ghost",size:"icon",className:"size-7 rounded-md bg-background/80 backdrop-blur-sm",onClick:qS,"aria-label":"Asset actions",children:n.jsx(C1,{size:14})})}),e[2]=d):d=e[2];let c;e[3]!==s.publicUrl||e[4]!==i?(c=()=>i(s.publicUrl),e[3]=s.publicUrl,e[4]=i,e[5]=c):c=e[5];let h;e[6]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx(js,{size:14}),e[6]=h):h=e[6];let u;e[7]!==c?(u=n.jsxs(Ue,{onClick:c,children:[h,"Use this"]}),e[7]=c,e[8]=u):u=e[8];let f;e[9]!==r?(f=r?n.jsx(js,{size:14}):n.jsx(as,{size:14}),e[9]=r,e[10]=f):f=e[10];const m=r?"Copied":"Copy URL";let p;e[11]!==l||e[12]!==f||e[13]!==m?(p=n.jsxs(Ue,{onClick:l,children:[f,m]}),e[11]=l,e[12]=f,e[13]=m,e[14]=p):p=e[14];let g;e[15]===Symbol.for("react.memo_cache_sentinel")?(g=n.jsx(hi,{size:14}),e[15]=g):g=e[15];let _;e[16]!==s.publicUrl?(_=n.jsx(Ue,{asChild:!0,children:n.jsxs("a",{href:s.publicUrl,target:"_blank",rel:"noreferrer",onClick:VS,children:[g,"Open in new tab"]})}),e[16]=s.publicUrl,e[17]=_):_=e[17];let b;return e[18]!==_||e[19]!==u||e[20]!==p?(b=n.jsxs(Wt,{children:[d,n.jsxs(Kt,{align:"end",onClick:KS,children:[u,p,_]})]}),e[18]=_,e[19]=u,e[20]=p,e[21]=b):b=e[21],b}function VS(t){return t.stopPropagation()}function KS(t){return t.stopPropagation()}function qS(t){return t.stopPropagation()}function Sd(t){const e=t.split("/");return e[e.length-1]??t}function GS(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function wm(t,e){if(!e)return null;const s=e.toLowerCase();return t.find(i=>{const r=i.bucket.toLowerCase();return i.siteSlug?.toLowerCase()===s||r===s||r===`deco-assets-${s}`})??null}function wd(t){const e=U.c(2),{ext:s}=t;if(!s)return null;let i;return e[0]!==s?(i=n.jsx("span",{className:"shrink-0 rounded bg-muted px-1.5 py-0.5 text-[10px] font-medium uppercase text-muted-foreground",children:s}),e[0]=s,e[1]=i):i=e[1],i}function YS(t){try{const e=new URL(t).pathname;return decodeURIComponent(e.split("/").pop()??t)}catch{return t.split("/").pop()??t}}function XS(t){const e=t.lastIndexOf(".");return e<0||e===t.length-1?"":t.slice(e+1).toLowerCase()}function JS(t){const e=U.c(79),{schema:s,value:i,onChange:r,path:o,label:a,sandbox:l}=t,d=s.format==="video-uri",c=lc(i),[h,u]=D.useState(!1),[f,m]=D.useState(!1),p=c?YS(c):"",g=p?XS(p):"",_=qu(),b=dc();let x;e[0]!==_.data?.configs?(x=_.data?.configs??[],e[0]=_.data?.configs,e[1]=x):x=e[1];const v=l?.siteSlug;let y;e[2]!==x||e[3]!==v?(y=wm(x,v),e[2]=x,e[3]=v,e[4]=y):y=e[4];const S=y;let w;e[5]!==_.data?.configs||e[6]!==S?(w=function(){if(S)return S.id;const J=_.data?.configs??[];if(J.length===1)return J[0].id;if(J.length===0)return null;const te=typeof window<"u"?window.localStorage.getItem(vo):null;return J.some(oe=>oe.id===te)?te:null},e[5]=_.data?.configs,e[6]=S,e[7]=w):w=e[7];const C=w;let N;e[8]!==d||e[9]!==r||e[10]!==C||e[11]!==u||e[12]!==b?(N=async function(J){if(!J)return;let te=Array.from(J);if(te.length===0)return;if(d&&(te=te.filter(ZS),te.length===0)){he.error("Please drop a video file (mp4, webm, …).");return}const oe=C();if(!oe){u(!0);return}try{const de=await b.mutateAsync({configId:oe,file:te[0]});r(de.publicUrl),te.length>1&&he.info(`Uploaded ${te[0].name}; extra files were ignored (single-select field).`)}catch(de){const be=de;he.error(be instanceof Error?be.message:"Upload failed")}},e[8]=d,e[9]=r,e[10]=C,e[11]=u,e[12]=b,e[13]=N):N=e[13];const E=N;let R;e[14]!==m?(R=function(J){J.preventDefault(),J.dataTransfer.types.includes("Files")&&m(!0)},e[14]=m,e[15]=R):R=e[15];const T=R;let k;e[16]!==m?(k=function(J){J.currentTarget===J.target&&m(!1)},e[16]=m,e[17]=k):k=e[17];const j=k;let I;e[18]!==E||e[19]!==m?(I=function(J){J.preventDefault(),m(!1),E(J.dataTransfer.files)},e[18]=E,e[19]=m,e[20]=I):I=e[20];const A=I;let O;e[21]!==a||e[22]!==o?(O=n.jsx(Ve,{htmlFor:o,className:"text-muted-foreground",children:a}),e[21]=a,e[22]=o,e[23]=O):O=e[23];let L;e[24]!==s.description?(L=s.description&&n.jsx("p",{className:"text-xs leading-normal text-muted-foreground",children:s.description}),e[24]=s.description,e[25]=L):L=e[25];let P;e[26]!==L||e[27]!==O?(P=n.jsxs("div",{className:"min-w-0 space-y-0.5",children:[O,L]}),e[26]=L,e[27]=O,e[28]=P):P=e[28];const B=f&&"border-primary ring-2 ring-primary/30",F=b.isPending&&"pointer-events-none opacity-60";let H;e[29]!==B||e[30]!==F?(H=ae("group relative w-full overflow-hidden rounded-xl border border-border/60 bg-muted/30 transition",B,F),e[29]=B,e[30]=F,e[31]=H):H=e[31];let z;e[32]!==g||e[33]!==p||e[34]!==d||e[35]!==u||e[36]!==c||e[37]!==b.isPending?(z=c?d?n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"relative h-40 w-full overflow-hidden bg-black",children:n.jsx("video",{src:c,preload:"metadata",className:"h-full w-full object-contain"},c)}),n.jsxs("div",{className:"flex items-center gap-2 border-t border-border/60 bg-background/50 px-3 py-2",children:[n.jsx(Bc,{size:14,className:"shrink-0 text-muted-foreground"}),n.jsx("p",{className:"min-w-0 flex-1 truncate text-xs text-muted-foreground",children:p}),n.jsx(wd,{ext:g})]})]}):n.jsxs("div",{className:"flex items-center gap-3 px-3 py-2.5",children:[n.jsx("div",{className:"flex size-10 shrink-0 items-center justify-center rounded-md bg-background",children:n.jsx(Ri,{size:18,className:"text-muted-foreground"})}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("p",{className:"truncate text-sm font-medium",children:p}),n.jsx("p",{className:"truncate text-xs text-muted-foreground",children:c})]}),n.jsx(wd,{ext:g})]}):n.jsxs("button",{type:"button",onClick:()=>u(!0),className:"flex w-full flex-col items-center justify-center gap-2 py-8 text-sm text-muted-foreground hover:bg-muted/60 hover:text-foreground",children:[d?n.jsx(Bc,{size:20}):n.jsx(Ri,{size:20}),n.jsx("span",{className:"text-sm font-medium",children:b.isPending?"Uploading…":d?"Drop a video here or click to browse":"Drop a file or click to browse"}),n.jsx("span",{className:"text-xs text-muted-foreground",children:"Up to 100 MB"})]}),e[32]=g,e[33]=p,e[34]=d,e[35]=u,e[36]=c,e[37]=b.isPending,e[38]=z):z=e[38];let W;e[39]!==f?(W=f&&n.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center bg-primary/10 backdrop-blur-[1px]",children:n.jsx("span",{className:"rounded-md bg-background px-3 py-1.5 text-xs font-medium shadow",children:"Drop to upload"})}),e[39]=f,e[40]=W):W=e[40];let q;e[41]!==j||e[42]!==T||e[43]!==A||e[44]!==H||e[45]!==z||e[46]!==W?(q=n.jsxs("div",{onDragOver:T,onDragLeave:j,onDrop:A,className:H,children:[z,W]}),e[41]=j,e[42]=T,e[43]=A,e[44]=H,e[45]=z,e[46]=W,e[47]=q):q=e[47];let K;e[48]!==r?(K=fe=>r(fe.target.value),e[48]=r,e[49]=K):K=e[49];let Z;e[50]!==o||e[51]!==c||e[52]!==K?(Z=n.jsx(ze,{id:o,type:"url",value:c,onChange:K,placeholder:"https://...",className:"h-9 min-w-0 flex-1"}),e[50]=o,e[51]=c,e[52]=K,e[53]=Z):Z=e[53];let Y;e[54]!==u?(Y=()=>u(!0),e[54]=u,e[55]=Y):Y=e[55];let G;e[56]===Symbol.for("react.memo_cache_sentinel")?(G=n.jsx(Kn,{size:14}),e[56]=G):G=e[56];const Q=c?"Replace":"Browse";let $;e[57]!==Y||e[58]!==Q?($=n.jsxs(ie,{type:"button",variant:"outline",size:"sm",onClick:Y,className:"h-9 shrink-0",children:[G,Q]}),e[57]=Y,e[58]=Q,e[59]=$):$=e[59];let X;e[60]!==r||e[61]!==c?(X=c&&n.jsx(ie,{type:"button",variant:"ghost",size:"sm",onClick:()=>r(""),className:"h-9 shrink-0","aria-label":"Remove file",children:n.jsx(es,{size:14})}),e[60]=r,e[61]=c,e[62]=X):X=e[62];let V;e[63]!==Z||e[64]!==$||e[65]!==X?(V=n.jsxs("div",{className:"flex w-full min-w-0 items-center gap-2",children:[Z,$,X]}),e[63]=Z,e[64]=$,e[65]=X,e[66]=V):V=e[66];let se;e[67]!==r?(se=fe=>r(fe),e[67]=r,e[68]=se):se=e[68];const ee=S?.id??null;let le;e[69]!==h||e[70]!==u||e[71]!==se||e[72]!==ee?(le=n.jsx(bm,{open:h,onOpenChange:u,mode:"any",onSelect:se,lockedConfigId:ee}),e[69]=h,e[70]=u,e[71]=se,e[72]=ee,e[73]=le):le=e[73];let ce;return e[74]!==P||e[75]!==q||e[76]!==V||e[77]!==le?(ce=n.jsxs("div",{className:"grid w-full min-w-0 grid-cols-[minmax(0,1fr)] gap-2",children:[P,q,V,le]}),e[74]=P,e[75]=q,e[76]=V,e[77]=le,e[78]=ce):ce=e[78],ce}function ZS(t){return t.type.startsWith("video/")}function QS(t){try{const e=new URL(t).pathname;return decodeURIComponent(e.split("/").pop()??t)}catch{return t.split("/").pop()??t}}function ew(t){const e=t.lastIndexOf(".");return e<0||e===t.length-1?"":t.slice(e+1).toLowerCase()}const tw=new Set(["image/png","image/jpeg","image/gif","image/webp","image/svg+xml","image/avif"]);function sw(t){const e=U.c(86),{schema:s,value:i,onChange:r,path:o,label:a,sandbox:l}=t,d=lc(i),[c,h]=D.useState(!1),[u,f]=D.useState(!1),[m,p]=D.useState(!1),[g,_]=D.useState(!1),b=d?QS(d):"",x=b?ew(b):"",v=qu(),y=dc();let S;e[0]!==v.data?.configs?(S=v.data?.configs??[],e[0]=v.data?.configs,e[1]=S):S=e[1];const w=l?.siteSlug;let C;e[2]!==S||e[3]!==w?(C=wm(S,w),e[2]=S,e[3]=w,e[4]=C):C=e[4];const N=C;let E;e[5]!==r||e[6]!==_||e[7]!==p?(E=function(ve){p(!1),_(!1),r(ve)},e[5]=r,e[6]=_,e[7]=p,e[8]=E):E=e[8];const R=E;let T;e[9]!==v.data?.configs||e[10]!==N?(T=function(){if(N)return N.id;const ve=v.data?.configs??[];if(ve.length===1)return ve[0].id;if(ve.length===0)return null;const we=typeof window<"u"?window.localStorage.getItem(vo):null;return ve.some(De=>De.id===we)?we:null},e[9]=v.data?.configs,e[10]=N,e[11]=T):T=e[11];const k=T;let j;e[12]!==k||e[13]!==h||e[14]!==R||e[15]!==y?(j=async function(ve){if(!ve)return;const we=Array.from(ve).filter(iw);if(we.length===0){he.error("Only image files are accepted here.");return}const De=k();if(!De){h(!0);return}try{const Be=await y.mutateAsync({configId:De,file:we[0]});R(Be.publicUrl),we.length>1&&he.info(`Uploaded ${we[0].name}; extra files were ignored (single-select field).`)}catch(Be){const Pe=Be;he.error(Pe instanceof Error?Pe.message:"Upload failed")}},e[12]=k,e[13]=h,e[14]=R,e[15]=y,e[16]=j):j=e[16];const I=j;let A;e[17]!==f?(A=function(ve){ve.preventDefault(),ve.dataTransfer.types.includes("Files")&&f(!0)},e[17]=f,e[18]=A):A=e[18];const O=A;let L;e[19]!==f?(L=function(ve){ve.currentTarget===ve.target&&f(!1)},e[19]=f,e[20]=L):L=e[20];const P=L;let B;e[21]!==I||e[22]!==f?(B=function(ve){ve.preventDefault(),f(!1),I(ve.dataTransfer.files)},e[21]=I,e[22]=f,e[23]=B):B=e[23];const F=B;let H;e[24]!==a||e[25]!==o?(H=n.jsx(Ve,{htmlFor:o,className:"text-muted-foreground",children:a}),e[24]=a,e[25]=o,e[26]=H):H=e[26];let z;e[27]!==s.description?(z=s.description&&n.jsx("p",{className:"text-xs leading-normal text-muted-foreground",children:s.description}),e[27]=s.description,e[28]=z):z=e[28];let W;e[29]!==H||e[30]!==z?(W=n.jsxs("div",{className:"min-w-0 space-y-0.5",children:[H,z]}),e[29]=H,e[30]=z,e[31]=W):W=e[31];const q=u&&"border-primary ring-2 ring-primary/30",K=y.isPending&&"pointer-events-none opacity-60";let Z;e[32]!==q||e[33]!==K?(Z=ae("group relative w-full overflow-hidden rounded-xl border border-border/60 bg-muted/30 transition",q,K),e[32]=q,e[33]=K,e[34]=Z):Z=e[34];let Y;e[35]!==x||e[36]!==b||e[37]!==g||e[38]!==m||e[39]!==a||e[40]!==_||e[41]!==p||e[42]!==h||e[43]!==d||e[44]!==y.isPending?(Y=d?n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"relative h-40 w-full bg-[image:linear-gradient(45deg,rgba(0,0,0,0.04)_25%,transparent_25%,transparent_75%,rgba(0,0,0,0.04)_75%),linear-gradient(45deg,rgba(0,0,0,0.04)_25%,transparent_25%,transparent_75%,rgba(0,0,0,0.04)_75%)] bg-[position:0_0,8px_8px] [background-size:16px_16px]",children:[!g&&n.jsx("img",{src:d,alt:a,className:ae("h-full w-full object-contain transition-opacity",!m&&"opacity-0"),onLoad:()=>p(!0),onError:()=>_(!0)},d),g&&n.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-1 text-muted-foreground",children:[n.jsx(Ii,{size:20}),n.jsx("p",{className:"text-xs",children:"Preview unavailable"})]}),!m&&!g&&n.jsx("div",{className:"absolute inset-0 animate-pulse bg-muted/60"})]}),n.jsxs("div",{className:"flex items-center gap-2 border-t border-border/60 bg-background/50 px-3 py-2",children:[n.jsx("span",{className:"min-w-0 flex-1 truncate text-xs font-medium",children:b}),x&&n.jsx("span",{className:"shrink-0 rounded bg-muted px-1.5 py-0.5 text-[10px] font-medium uppercase text-muted-foreground",children:x})]})]}):n.jsxs("button",{type:"button",onClick:()=>h(!0),className:"flex h-40 w-full flex-col items-center justify-center gap-2 text-sm text-muted-foreground hover:bg-muted/60 hover:text-foreground",children:[n.jsx(Ii,{size:20}),n.jsx("span",{className:"text-sm font-medium",children:y.isPending?"Uploading…":"Drop an image or click to browse"}),n.jsx("span",{className:"text-xs text-muted-foreground",children:"PNG, JPEG, WebP, GIF, SVG, AVIF — up to 100 MB"})]}),e[35]=x,e[36]=b,e[37]=g,e[38]=m,e[39]=a,e[40]=_,e[41]=p,e[42]=h,e[43]=d,e[44]=y.isPending,e[45]=Y):Y=e[45];let G;e[46]!==u?(G=u&&n.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center bg-primary/10 backdrop-blur-[1px]",children:n.jsx("span",{className:"rounded-md bg-background px-3 py-1.5 text-xs font-medium shadow",children:"Drop to upload"})}),e[46]=u,e[47]=G):G=e[47];let Q;e[48]!==P||e[49]!==O||e[50]!==F||e[51]!==Z||e[52]!==Y||e[53]!==G?(Q=n.jsxs("div",{onDragOver:O,onDragLeave:P,onDrop:F,className:Z,children:[Y,G]}),e[48]=P,e[49]=O,e[50]=F,e[51]=Z,e[52]=Y,e[53]=G,e[54]=Q):Q=e[54];let $;e[55]!==R?($=be=>R(be.target.value),e[55]=R,e[56]=$):$=e[56];let X;e[57]!==o||e[58]!==d||e[59]!==$?(X=n.jsx(ze,{id:o,type:"url",value:d,onChange:$,placeholder:"https://...",className:"h-9 min-w-0 flex-1"}),e[57]=o,e[58]=d,e[59]=$,e[60]=X):X=e[60];let V;e[61]!==h?(V=()=>h(!0),e[61]=h,e[62]=V):V=e[62];let se;e[63]===Symbol.for("react.memo_cache_sentinel")?(se=n.jsx(Kn,{size:14}),e[63]=se):se=e[63];const ee=d?"Replace":"Browse";let le;e[64]!==V||e[65]!==ee?(le=n.jsxs(ie,{type:"button",variant:"outline",size:"sm",onClick:V,className:"h-9 shrink-0",children:[se,ee]}),e[64]=V,e[65]=ee,e[66]=le):le=e[66];let ce;e[67]!==R||e[68]!==d?(ce=d&&n.jsx(ie,{type:"button",variant:"ghost",size:"sm",onClick:()=>R(""),className:"h-9 shrink-0","aria-label":"Remove image",children:n.jsx(es,{size:14})}),e[67]=R,e[68]=d,e[69]=ce):ce=e[69];let fe;e[70]!==X||e[71]!==le||e[72]!==ce?(fe=n.jsxs("div",{className:"flex w-full min-w-0 items-center gap-2",children:[X,le,ce]}),e[70]=X,e[71]=le,e[72]=ce,e[73]=fe):fe=e[73];let J;e[74]!==R?(J=be=>R(be),e[74]=R,e[75]=J):J=e[75];const te=N?.id??null;let oe;e[76]!==c||e[77]!==h||e[78]!==J||e[79]!==te?(oe=n.jsx(bm,{open:c,onOpenChange:h,mode:"image",onSelect:J,lockedConfigId:te}),e[76]=c,e[77]=h,e[78]=J,e[79]=te,e[80]=oe):oe=e[80];let de;return e[81]!==W||e[82]!==Q||e[83]!==fe||e[84]!==oe?(de=n.jsxs("div",{className:"grid w-full min-w-0 grid-cols-[minmax(0,1fr)] gap-2",children:[W,Q,fe,oe]}),e[81]=W,e[82]=Q,e[83]=fe,e[84]=oe,e[85]=de):de=e[85],de}function iw(t){return tw.has(t.type||"")}const nw="oklch(0.65 0.15 160)",rw="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)]",Cm="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)]",jE="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 Cd(t){return t.map(e=>e.label).join(`
|
|
467
|
+
`)}function Mo(t){return t.map(e=>({id:crypto.randomUUID(),index:e.index,label:e.label}))}function ow(t){return t.map((e,s)=>({...e,index:s}))}function km(t){const e=U.c(17),{label:s,canDelete:i,dragging:r,onDuplicate:o,onDelete:a}=t,l=r?"opacity-100":"opacity-0 group-hover:opacity-100";let d;e[0]!==l?(d=ae("h-4 w-4 shrink-0 text-muted-foreground/40 transition-opacity",l),e[0]=l,e[1]=d):d=e[1];let c;e[2]!==d?(c=n.jsx(bl,{className:d}),e[2]=d,e[3]=c):c=e[3];let h;e[4]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx(Ni,{className:"h-4 w-4 shrink-0",style:{color:nw}}),e[4]=h):h=e[4];let u;e[5]!==s?(u=n.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-medium",children:s}),e[5]=s,e[6]=u):u=e[6];let f;e[7]!==i||e[8]!==r||e[9]!==s||e[10]!==a||e[11]!==o?(f=!r&&n.jsxs(Wt,{children:[n.jsx(Vt,{asChild:!0,children:n.jsx(ie,{type:"button",variant:"ghost",size:"icon","aria-label":`Open actions for ${s}`,className:"size-6 shrink-0 opacity-0 transition-opacity group-hover:opacity-100 data-[state=open]:opacity-100",onClick:lw,onPointerDown:aw,children:n.jsx(Hi,{size:14})})}),n.jsxs(Kt,{align:"end",children:[n.jsxs(Ue,{onClick:p=>{p.stopPropagation(),o?.()},children:[n.jsx(as,{size:14}),"Duplicate"]}),n.jsxs(Ue,{variant:"destructive",disabled:!i,onClick:p=>{p.stopPropagation(),a?.()},children:[n.jsx(es,{size:14}),"Delete"]})]})]}),e[7]=i,e[8]=r,e[9]=s,e[10]=a,e[11]=o,e[12]=f):f=e[12];let m;return e[13]!==c||e[14]!==u||e[15]!==f?(m=n.jsxs(n.Fragment,{children:[c,h,u,f]}),e[13]=c,e[14]=u,e[15]=f,e[16]=m):m=e[16],m}function aw(t){return t.stopPropagation()}function lw(t){return t.stopPropagation()}function cw(t){const e=U.c(26),{entry:s,selected:i,canDelete:r,onSelect:o,onDuplicate:a,onDelete:l}=t;let d;e[0]!==s.id?(d={id:s.id,animateLayoutChanges:dw},e[0]=s.id,e[1]=d):d=e[1];const{attributes:c,listeners:h,setNodeRef:u,transform:f,isDragging:m}=du(d);let p;e[2]!==f?(p=hu.Transform.toString(f?{...f,x:0}:null),e[2]=f,e[3]=p):p=e[3];const g=m?0:void 0;let _;e[4]!==p||e[5]!==g?(_={transform:p,opacity:g},e[4]=p,e[5]=g,e[6]=_):_=e[6];const b=_;let x;e[7]!==o?(x=N=>{N.target===N.currentTarget&&(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),o())},e[7]=o,e[8]=x):x=e[8];const v=m?"cursor-grabbing":"cursor-grab",y=i?Cm:rw;let S;e[9]!==v||e[10]!==y?(S=ae("group flex select-none items-center gap-2 rounded-md px-2 py-2.5 transition-colors touch-none",v,y),e[9]=v,e[10]=y,e[11]=S):S=e[11];let w;e[12]!==r||e[13]!==s.label||e[14]!==l||e[15]!==a?(w=n.jsx(km,{label:s.label,canDelete:r,onDuplicate:a,onDelete:l}),e[12]=r,e[13]=s.label,e[14]=l,e[15]=a,e[16]=w):w=e[16];let C;return e[17]!==c||e[18]!==h||e[19]!==o||e[20]!==u||e[21]!==b||e[22]!==x||e[23]!==S||e[24]!==w?(C=n.jsx("div",{ref:u,style:b,...c,...h,onClick:o,onKeyDown:x,className:S,children:w}),e[17]=c,e[18]=h,e[19]=o,e[20]=u,e[21]=b,e[22]=x,e[23]=S,e[24]=w,e[25]=C):C=e[25],C}function dw(){return!1}function hw(t){const e=U.c(81),{listKey:s,variants:i,selectedIndex:r,onSelect:o,onDuplicate:a,onDelete:l,onRemoveAll:d,onReorder:c,onAdd:h}=t,u=i.length>1;let f;e[0]!==i?(f=()=>Mo(i),e[0]=i,e[1]=f):f=e[1];const[m,p]=D.useState(f),[g,_]=D.useState(null),[b,x]=D.useState(s),[v,y]=D.useState(i.length);let S;e[2]!==i?(S=()=>Cd(i),e[2]=i,e[3]=S):S=e[3];const[w,C]=D.useState(S),N=D.useRef(!1),E=Cd(i);b!==s?(x(s),y(i.length),C(E),p(Mo(i))):v!==i.length?(y(i.length),C(E),p(Mo(i))):w!==E&&(C(E),p(oe=>i.map((de,be)=>({id:oe[be]?.id??crypto.randomUUID(),index:de.index,label:de.label}))));let R;e[4]===Symbol.for("react.memo_cache_sentinel")?(R={activationConstraint:{distance:8}},e[4]=R):R=e[4];let T;e[5]===Symbol.for("react.memo_cache_sentinel")?(T={coordinateGetter:uu},e[5]=T):T=e[5];const k=su(wr(nu,R),wr(iu,T));let j;e[6]!==m?(j=m.map(uw),e[6]=m,e[7]=j):j=e[7];const I=j;let A;e[8]!==m?(A=oe=>{const de=String(oe.active.id);_(m.find(be=>be.id===de)??null)},e[8]=m,e[9]=A):A=e[9];const O=A;let L;e[10]!==I||e[11]!==c?(L=oe=>{_(null);const{active:de,over:be}=oe;if(!be||de.id===be.id)return;const ve=I.indexOf(String(de.id)),we=I.indexOf(String(be.id));ve===-1||we===-1||(p(De=>ow(la([...De],ve,we))),N.current=!0,requestAnimationFrame(()=>{N.current=!1}),c(ve,we))},e[10]=I,e[11]=c,e[12]=L):L=e[12];const P=L;let B;e[13]===Symbol.for("react.memo_cache_sentinel")?(B=()=>{_(null)},e[13]=B):B=e[13];const F=B;let H,z,W,q,K,Z,Y,G,Q,$,X,V,se;if(e[14]!==u||e[15]!==m||e[16]!==I||e[17]!==P||e[18]!==O||e[19]!==h||e[20]!==l||e[21]!==a||e[22]!==d||e[23]!==o||e[24]!==r||e[25]!==k){const oe=ye=>{N.current||o(ye)};X="space-y-1 border-b p-2";let de;e[39]===Symbol.for("react.memo_cache_sentinel")?(de=n.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Variants"}),e[39]=de):de=e[39];let be;e[40]===Symbol.for("react.memo_cache_sentinel")?(be=n.jsx(Dt,{size:14}),e[40]=be):be=e[40];let ve;e[41]!==h?(ve=n.jsx(Ne,{asChild:!0,children:n.jsx(ie,{type:"button",variant:"ghost",size:"icon","aria-label":"Add variant",className:"size-6",onClick:h,children:be})}),e[41]=h,e[42]=ve):ve=e[42];let we;e[43]===Symbol.for("react.memo_cache_sentinel")?(we=n.jsx(Ee,{children:"Add variant"}),e[43]=we):we=e[43];let De;e[44]!==ve?(De=n.jsxs(Te,{children:[ve,we]}),e[44]=ve,e[45]=De):De=e[45];let Be;e[46]===Symbol.for("react.memo_cache_sentinel")?(Be=n.jsx(es,{size:14}),e[46]=Be):Be=e[46];let Pe;e[47]!==d?(Pe=n.jsx(Ne,{asChild:!0,children:n.jsx(ie,{type:"button",variant:"ghost",size:"icon","aria-label":"Remove all variants",className:"size-6 text-muted-foreground hover:text-destructive",onClick:d,children:Be})}),e[47]=d,e[48]=Pe):Pe=e[48];let Fe;e[49]===Symbol.for("react.memo_cache_sentinel")?(Fe=n.jsx(Ee,{children:"Remove all variants"}),e[49]=Fe):Fe=e[49];let xe;e[50]!==Pe?(xe=n.jsxs(Te,{children:[Pe,Fe]}),e[50]=Pe,e[51]=xe):xe=e[51],e[52]!==De||e[53]!==xe?(V=n.jsxs("div",{className:"flex items-center justify-between",children:[de,n.jsxs("div",{className:"flex items-center gap-0.5",children:[De,xe]})]}),e[52]=De,e[53]=xe,e[54]=V):V=e[54],z=ru,Z=k,Y=ou,G=O,Q=P,$=F,H=au,q=I,K=lu,se="space-y-0.5",W=m.map(ye=>n.jsx(cw,{entry:ye,selected:ye.index===r,canDelete:u,onSelect:()=>oe(ye.index),onDuplicate:()=>a(ye.index),onDelete:()=>l(ye.index)},ye.id)),e[14]=u,e[15]=m,e[16]=I,e[17]=P,e[18]=O,e[19]=h,e[20]=l,e[21]=a,e[22]=d,e[23]=o,e[24]=r,e[25]=k,e[26]=H,e[27]=z,e[28]=W,e[29]=q,e[30]=K,e[31]=Z,e[32]=Y,e[33]=G,e[34]=Q,e[35]=$,e[36]=X,e[37]=V,e[38]=se}else H=e[26],z=e[27],W=e[28],q=e[29],K=e[30],Z=e[31],Y=e[32],G=e[33],Q=e[34],$=e[35],X=e[36],V=e[37],se=e[38];let ee;e[55]!==W||e[56]!==se?(ee=n.jsx("div",{className:se,children:W}),e[55]=W,e[56]=se,e[57]=ee):ee=e[57];let le;e[58]!==H||e[59]!==q||e[60]!==K||e[61]!==ee?(le=n.jsx(H,{items:q,strategy:K,children:ee}),e[58]=H,e[59]=q,e[60]=K,e[61]=ee,e[62]=le):le=e[62];let ce;e[63]!==g||e[64]!==u?(ce=g?n.jsx("div",{className:ae("flex items-center gap-2 rounded-md px-2 py-2.5 shadow-lg ring-1 ring-border/60 cursor-grabbing",Cm),children:n.jsx(km,{label:g.label,canDelete:u,dragging:!0})}):null,e[63]=g,e[64]=u,e[65]=ce):ce=e[65];let fe;e[66]!==ce?(fe=n.jsx(cu,{dropAnimation:null,children:ce}),e[66]=ce,e[67]=fe):fe=e[67];let J;e[68]!==z||e[69]!==Z||e[70]!==Y||e[71]!==G||e[72]!==Q||e[73]!==$||e[74]!==le||e[75]!==fe?(J=n.jsxs(z,{sensors:Z,collisionDetection:Y,onDragStart:G,onDragEnd:Q,onDragCancel:$,children:[le,fe]}),e[68]=z,e[69]=Z,e[70]=Y,e[71]=G,e[72]=Q,e[73]=$,e[74]=le,e[75]=fe,e[76]=J):J=e[76];let te;return e[77]!==X||e[78]!==V||e[79]!==J?(te=n.jsxs("div",{className:X,children:[V,J]}),e[77]=X,e[78]=V,e[79]=J,e[80]=te):te=e[80],te}function uw(t){return t.id}const fw=[[/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"]],mw={"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 $o(t){return ci(t)!==void 0}function jm(t,e){if(e){if($o(e))return e;const s=mw[e];if(s&&$o(s))return s}for(const[s,i]of fw)if(s.test(t)&&$o(i))return i;return"FilterLines"}function pw(t){return ci(t)??A1}function kd(t){const e=U.c(11),{iconName:s,size:i,className:r}=t,o=i===void 0?"md":i;let a;e[0]!==s?(a=pw(s),e[0]=s,e[1]=a):a=e[1];const l=a,d=o==="sm"?"size-7":"size-9",c=o==="sm"?16:18;let h;e[2]!==d||e[3]!==r?(h=ae("flex shrink-0 items-center justify-center rounded-full bg-muted",d,r),e[2]=d,e[3]=r,e[4]=h):h=e[4];let u;e[5]!==l||e[6]!==c?(u=n.jsx(l,{size:c,className:"text-muted-foreground"}),e[5]=l,e[6]=c,e[7]=u):u=e[7];let f;return e[8]!==h||e[9]!==u?(f=n.jsx("div",{className:h,children:u}),e[8]=h,e[9]=u,e[10]=f):f=e[10],f}const Nm="Users03";function gw(t){const e=t.manifest?.blocks??{},s=[];for(const[i,r]of Object.entries(e))if(i.includes("matchers"))for(const o of Object.keys(r)){if(o.includes("always"))continue;const a=fi(o,t);s.push({resolveType:o,title:a.title??ut(o),description:a.description,iconName:jm(o,a.icon)})}return s}function _w(t,e){if(!t)return Nm;const s=e.find(i=>i.resolveType===t);return s?s.iconName:jm(t)}function vw(t){const e=U.c(41),{currentRt:s,currentLabel:i,matchers:r,onSelect:o}=t,[a,l]=D.useState(!1);let d;if(e[0]!==s||e[1]!==r){const j=_w(s,r);d=ci(j),e[0]=s,e[1]=r,e[2]=d}else d=e[2];const c=d;let h;e[3]!==o?(h=j=>{o(j),l(!1)},e[3]=o,e[4]=h):h=e[4];const u=h;let f;e[5]===Symbol.for("react.memo_cache_sentinel")?(f=()=>l(!0),e[5]=f):f=e[5];let m;e[6]!==c?(m=c&&n.jsx(c,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),e[6]=c,e[7]=m):m=e[7];let p;e[8]!==i?(p=n.jsx("span",{className:"flex-1 truncate",children:i}),e[8]=i,e[9]=p):p=e[9];let g;e[10]===Symbol.for("react.memo_cache_sentinel")?(g=n.jsx(cs,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e[10]=g):g=e[10];let _;e[11]!==m||e[12]!==p?(_=n.jsxs("button",{type:"button",onClick:f,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:[m,p,g]}),e[11]=m,e[12]=p,e[13]=_):_=e[13];let b;e[14]===Symbol.for("react.memo_cache_sentinel")?(b=n.jsx(Nl,{placeholder:"Search rules..."}),e[14]=b):b=e[14];let x;e[15]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsx(El,{children:"No rules found."}),e[15]=x):x=e[15];let v;e[16]!==u?(v=()=>u(""),e[16]=u,e[17]=v):v=e[17];const y=!s&&"bg-accent/60";let S;e[18]!==y?(S=ae("gap-2.5",y),e[18]=y,e[19]=S):S=e[19];let w;e[20]===Symbol.for("react.memo_cache_sentinel")?(w=n.jsx(kd,{iconName:Nm,size:"sm"}),e[20]=w):w=e[20];let C;e[21]===Symbol.for("react.memo_cache_sentinel")?(C=n.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[n.jsx("span",{className:"text-sm",children:"Always"}),n.jsx("span",{className:"text-xs text-muted-foreground",children:"Target all users"})]}),e[21]=C):C=e[21];let N;e[22]!==v||e[23]!==S?(N=n.jsxs(Or,{value:"always Target all users",onSelect:v,className:S,children:[w,C]}),e[22]=v,e[23]=S,e[24]=N):N=e[24];let E;if(e[25]!==s||e[26]!==u||e[27]!==r){let j;e[29]!==s||e[30]!==u?(j=I=>n.jsxs(Or,{value:`${I.title} ${I.resolveType} ${I.description??""}`,onSelect:()=>u(I.resolveType),className:ae("gap-2.5",s===I.resolveType&&"bg-accent/60"),children:[n.jsx(kd,{iconName:I.iconName,size:"sm"}),n.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[n.jsx("span",{className:"text-sm",children:I.title}),I.description&&n.jsx("span",{className:"truncate text-xs text-muted-foreground",children:I.description})]})]},I.resolveType),e[29]=s,e[30]=u,e[31]=j):j=e[31],E=r.map(j),e[25]=s,e[26]=u,e[27]=r,e[28]=E}else E=e[28];let R;e[32]!==N||e[33]!==E?(R=n.jsxs(Tl,{children:[x,n.jsxs(Br,{children:[N,E]})]}),e[32]=N,e[33]=E,e[34]=R):R=e[34];let T;e[35]!==a||e[36]!==R?(T=n.jsxs(N1,{open:a,onOpenChange:l,title:"Choose a rule",description:"Pick how to target users for this variant",className:"sm:max-w-lg",children:[b,R]}),e[35]=a,e[36]=R,e[37]=T):T=e[37];let k;return e[38]!==T||e[39]!==_?(k=n.jsxs(n.Fragment,{children:[_,T]}),e[38]=T,e[39]=_,e[40]=k):k=e[40],k}const xw=t=>t.charAt(0).toUpperCase()+t.slice(1).toLowerCase(),bw=5,yw=new Intl.DateTimeFormat("en",{dateStyle:"medium",timeStyle:"short"});function jd(t){const{start:e,end:s}=t,i=typeof e=="string"?e:"",r=typeof s=="string"?s:"";if(!i&&!r)return null;const o=d=>{if(!d)return null;const c=new Date(d);return Number.isNaN(c.getTime())?null:yw.format(c)},a=o(i),l=o(r);return a&&l?`${a} → ${l}`:a?`From ${a}`:l?`Until ${l}`:null}function hc(t,e=0){if(!t)return"Default";if(e>bw)return"...";const s=t.__resolveType??"";if(["website/matchers/always.ts","$live/matchers/MatchAlways.ts"].includes(s)||s==="")return"Default";switch(s){case"website/matchers/never.ts":return"Hidden";case"website/matchers/device.ts":case"$live/matchers/MatchDevice.ts":{const{mobile:r,tablet:o,desktop:a,devices:l=[]}=t,d=[...l];return r&&d.push("Mobile"),o&&d.push("Tablet"),a&&d.push("Desktop"),d.length>0?d.map(xw).join(" & "):ut(s)}case"website/matchers/date.ts":case"$live/matchers/MatchDate.ts":return jd(t)??ut(s);case"website/matchers/random.ts":case"$live/matchers/MatchRandom.ts":{const{traffic:r}=t;return typeof r=="number"?`${Math.ceil(r*100)}% of sessions`:ut(s)}case"website/matchers/host.ts":case"$live/matchers/MatchHost.ts":{const{includes:r,match:o}=t,a=[];return r&&a.push(r),o&&a.push(o),a.length>0?a.join(" - "):ut(s)}case"website/matchers/pathname.ts":{const r=t.case,{type:o,pathname:a}=r??{};return o&&a?`Pathname ${o} ${a}`:ut(s)}case"website/matchers/location.ts":case"$live/matchers/MatchLocation.ts":{const{includeLocations:r,excludeLocations:o}=t,a=c=>[c.city,c.regionCode,c.country].filter(Boolean).join(" - "),l=r?.[0];if(l){const c=(r?.length??0)-1;return`${a(l)}${c>0?` +${c}`:""}`}const d=o?.[0];if(d){const c=(o?.length??0)-1;return`Except ${a(d)}${c>0?` +${c}`:""}`}return"Any location"}case"website/matchers/multi.ts":case"$live/matchers/MatchMulti.ts":{const{matchers:r,op:o="AND"}=t;if(r&&r.length>0){const a=o==="OR"?"OR":"AND";return r.map(l=>hc(l,e+1)).join(` ${a} `)}return ut(s)}default:{const r=jd(t);return r||ut(s)||"Default"}}}function Sw(t){if(!t||typeof t!="object")return!1;const e=t;return typeof e.__resolveType=="string"&&Array.isArray(e.variants)}function ww(t,e){return{__resolveType:e,variants:[{rule:Li(),value:structuredClone(t)},{rule:Li(),value:structuredClone(t)}]}}function Cw(t){const e=t.variants;if(e.length===0)return;const s=e.find(i=>sc(i.rule));return s?s.value:e[e.length-1]?.value}function kw(t){const e=[...t.variants],s=e[e.length-1],i={rule:Li(),value:s?structuredClone(s.value):void 0};return{...t,variants:[...e,i]}}function jw(t,e){if(t.variants.length<=1)return null;const s=[...t.variants];return s.splice(e,1),{...t,variants:s}}function Nw(t,e){const s=[...t.variants],i=s[e];return i?(s.splice(e+1,0,structuredClone(i)),{...t,variants:s}):t}function Ew(t,e,s){const i=[...t.variants];if(e===s||e<0||s<0||e>=i.length||s>=i.length)return t;const[r]=i.splice(e,1);return r?(i.splice(s,0,r),{...t,variants:i}):t}function Tw(t,e,s){const i=[...t.variants],r=i[e];return r?(i[e]={...r,value:s},{...t,variants:i}):t}function Nd(t,e,s){const i=[...t.variants],r=i[e];return r?(i[e]={...r,rule:s},{...t,variants:i}):t}const Ed=new WeakMap,Td=new Map;function Aw(t){let e=Ed.get(t);return e||(e=gw(t),Ed.set(t,e)),e}function Rw(t,e){let s=Td.get(t);return s===void 0&&(s=Us(t,e),Td.set(t,s)),s}function Pw(t){const e=U.c(3),{multivariateResolveType:s,renderInnerField:i,...r}=t,{value:o,onChange:a,meta:l,path:d}=r,[c,h]=D.useState(0);if(!Sw(o)){let L;e[0]===Symbol.for("react.memo_cache_sentinel")?(L=n.jsx(Tu,{size:14}),e[0]=L):L=e[0];let P;return e[1]===Symbol.for("react.memo_cache_sentinel")?(P=n.jsx(Ee,{children:"Add variant"}),e[1]=P):P=e[1],n.jsxs("div",{className:"relative grid w-full min-w-0 grid-cols-[minmax(0,1fr)] gap-2",children:[n.jsxs(Te,{children:[n.jsx(Ne,{asChild:!0,children:n.jsx(ie,{type:"button",variant:"ghost",size:"icon",className:"absolute right-0 top-0 size-6 text-muted-foreground hover:text-foreground","aria-label":"Add variant",onClick:()=>{a(ww(o,s)),h(0)},children:L})}),P]}),i(r)]})}const u=o,f=u.variants,m=Math.min(c,f.length-1),p=f.map(Dw),g=f[m],_=g?.rule??{},b=_.__resolveType??"",x=g?.value,v=l?Aw(l):[],y=b&&l?Rw(b,l):null,{__resolveType:S,...w}=_,C=()=>{a(Cw(u)),h(0)},N=()=>{const L=kw(u);a(L),h(L.variants.length-1)},E=L=>{const P=jw(u,L);P&&(a(P),m>=P.variants.length&&h(P.variants.length-1))},R=L=>{const P=Nw(u,L);a(P),h(L+1)},T=(L,P)=>{const B=Ew(u,L,P);a(B),m===L&&h(P)},k=L=>{a(Nd(u,m,L?{__resolveType:L}:{__resolveType:cf}))},j=L=>{const P=L,B=b?{...P,__resolveType:b}:{...P};a(Nd(u,m,B))},I=L=>{a(Tw(u,m,L))},A=`${d}-${u.__resolveType}`;let O;return e[2]===Symbol.for("react.memo_cache_sentinel")?(O=n.jsx(Ve,{className:"text-xs text-muted-foreground",children:"Rule"}),e[2]=O):O=e[2],n.jsxs("div",{className:"grid w-full min-w-0 grid-cols-[minmax(0,1fr)] gap-0",children:[n.jsx(hw,{listKey:A,variants:p,selectedIndex:m,onSelect:h,onDuplicate:R,onDelete:E,onRemoveAll:C,onReorder:T,onAdd:N}),n.jsxs("div",{className:"space-y-4 px-2 pt-3",children:[n.jsxs("div",{className:"space-y-1.5",children:[O,n.jsx(vw,{currentRt:b,currentLabel:hc(_),matchers:v,onSelect:k}),y&&n.jsx("div",{className:"pt-1",children:n.jsx(Zi,{schema:y,value:w,onChange:j,basePath:""})})]}),i({...r,value:x,onChange:I})]})]})}function Dw(t,e){return{index:e,label:hc(t.rule)||`Variant ${e+1}`}}const Iw="website/loaders/secret.ts";function Nn(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 Lw(){return{__resolveType:Iw,name:"",encrypted:""}}function Ow(t){const{value:e,...s}=t;return s}function zo(t){const e=U.c(45),{schema:s,value:i,onChange:r,label:o,path:a}=t;if(typeof i=="string"||i==null&&!Nn(i)){const C=typeof i=="string"?i:"";let N;e[0]!==o||e[1]!==a?(N=n.jsx(Ve,{htmlFor:a,className:"text-sm font-medium",children:o}),e[0]=o,e[1]=a,e[2]=N):N=e[2];let E;e[3]!==s.description?(E=s.description&&n.jsx("p",{className:"text-xs text-muted-foreground",children:s.description}),e[3]=s.description,e[4]=E):E=e[4];let R;e[5]!==r?(R=j=>r(j.target.value),e[5]=r,e[6]=R):R=e[6];let T;e[7]!==a||e[8]!==C||e[9]!==R?(T=n.jsx(ze,{id:a,type:"password",value:C,autoComplete:"new-password",autoCorrect:"off",spellCheck:!1,placeholder:"Secret value",onChange:R,className:"h-10"}),e[7]=a,e[8]=C,e[9]=R,e[10]=T):T=e[10];let k;return e[11]!==N||e[12]!==E||e[13]!==T?(k=n.jsxs("div",{className:"space-y-2",children:[N,E,T]}),e[11]=N,e[12]=E,e[13]=T,e[14]=k):k=e[14],k}let l;e[15]!==i?(l=Nn(i)?i:Lw(),e[15]=i,e[16]=l):l=e[16];const d=l,c=typeof d.name=="string"?d.name:"",h=typeof d.encrypted=="string"&&d.encrypted,u=`${a}-name`;let f;e[17]!==o||e[18]!==u?(f=n.jsx(Ve,{htmlFor:u,className:"text-sm font-medium",children:o}),e[17]=o,e[18]=u,e[19]=f):f=e[19];let m;e[20]!==s.description?(m=s.description&&n.jsx("p",{className:"text-xs text-muted-foreground",children:s.description}),e[20]=s.description,e[21]=m):m=e[21];const p=`${a}-name`;let g;e[22]!==d||e[23]!==r?(g=C=>r({...d,name:C.target.value}),e[22]=d,e[23]=r,e[24]=g):g=e[24];let _;e[25]!==c||e[26]!==p||e[27]!==g?(_=n.jsx(ze,{id:p,value:c,placeholder:"Secret name",onChange:g,className:"h-10"}),e[25]=c,e[26]=p,e[27]=g,e[28]=_):_=e[28];const b=`${a}-value`,x=h?"Leave blank to keep current value":"Secret value";let v;e[29]!==d||e[30]!==h||e[31]!==r?(v=C=>{const N=C.target.value;if(!N){r(h?Ow(d):d);return}r({...d,value:N})},e[29]=d,e[30]=h,e[31]=r,e[32]=v):v=e[32];let y;e[33]!==v||e[34]!==b||e[35]!==x?(y=n.jsx(ze,{id:b,type:"password",autoComplete:"new-password",autoCorrect:"off",spellCheck:!1,placeholder:x,onChange:v,className:"h-10"}),e[33]=v,e[34]=b,e[35]=x,e[36]=y):y=e[36];let S;e[37]!==h?(S=h&&n.jsx("p",{className:"text-xs text-muted-foreground",children:"A secret value is stored."}),e[37]=h,e[38]=S):S=e[38];let w;return e[39]!==y||e[40]!==S||e[41]!==f||e[42]!==m||e[43]!==_?(w=n.jsxs("div",{className:"space-y-2",children:[f,m,_,y,S]}),e[39]=y,e[40]=S,e[41]=f,e[42]=m,e[43]=_,e[44]=w):w=e[44],w}function Bw(t){const e=t.length>0?t[0]:void 0;if(e==null||typeof e!="object"||Array.isArray(e))return;const s={};for(const[i,r]of Object.entries(e))i.startsWith("__")||(typeof r=="string"?s[i]={type:"string"}:typeof r=="number"?s[i]={type:"number"}:typeof r=="boolean"&&(s[i]={type:"boolean"}));return Object.keys(s).length>0?{type:"object",properties:s}:void 0}const Mw=new Set(["__resolveType","@type"]);function $w(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 zw(t){if(mo(t))for(const e of t.anyOfRefs??[]){const r=e.schema?.properties?.variants?.items?.properties?.value;if(r?.type==="array"&&r.items)return r.items}}function Ad(t){if(t.type==="array"&&t.items)return t;const e=t.items??zw(t);return e?{...t,type:"array",items:e}:null}function Fw(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 uc(t){const{schema:e,value:s}=t;if(Ur(s)){const a=_0(s),l=Ad(e);if(a!==null&&l)return n.jsx(ar,{...t,schema:l,value:a,onChange:d=>t.onChange(v0(s,d))},t.path)}if(Array.isArray(s)&&e.type==="block-ref"&&mo(e)){const a=Ad(e);if(a)return n.jsx(ar,{...t,schema:a,value:s,onChange:t.onChange},t.path)}if(Array.isArray(s)&&!Ur(s)&&e.type==="block-ref"){const a=Bw(s);if(a){const l={...e,type:"array",items:a};return n.jsx(ar,{...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($w(e)){const a=e.anyOfRefs[0],l=a.schema?.properties?.variants?.items?.properties?.value,d=l&&l.type!=="block-ref"?l:e.plainSchema??l?.plainSchema??{type:"string"},c=h=>uc({...h,schema:d});return n.jsx(Pw,{...t,multivariateResolveType:a.resolveType,renderInnerField:c},t.path)}return e.anyOfRefs?n.jsx(xd,{...t},t.path):null}if(e.format==="image-uri")return n.jsx(sw,{...t},t.path);if(e.format==="file-uri"||e.format==="video-uri")return n.jsx(JS,{...t},t.path);if(e.format==="dynamic-options"&&e.options)return n.jsx(TS,{...t},t.path);if(e.enum&&e.enum.length>0)return n.jsx(F2,{...t},t.path);if(e.type==="anyOf")return n.jsx(xd,{...t},t.path);if(Nn(s)||e.format==="password"||s==null&&e.format==="password")return n.jsx(zo,{...t},t.path);const i=s??Fw(e.type,e.default);if(i==null)return Nn(s)?n.jsx(zo,{...t},t.path):null;if(Nn(i))return n.jsx(zo,{...t,value:i},t.path);const r={...t,value:i},o=s==null?e.type??typeof i:Array.isArray(i)?"array":typeof i;if(o==="array"||Array.isArray(i))return n.jsx(ar,{...r},t.path);switch(o){case"boolean":return n.jsx(B2,{...r},t.path);case"number":case"integer":return n.jsx(O2,{...r},t.path);case"string":{const a=e.format;return a==="color-input"?n.jsx(rr,{...r},t.path):a==="textarea"||a==="rich-text"||a==="html"?n.jsx(rr,{...r},t.path):n.jsx(rr,{...r},t.path)}case"object":return i!==null&&typeof i=="object"&&!Array.isArray(i)?n.jsx(_S,{...r},t.path):null;default:return n.jsx(rr,{...r},t.path)}}function Zi(t){const e=U.c(16),{schema:s,value:i,onChange:r,basePath:o,breadcrumbPath:a,onBreadcrumbChange:l,meta:d,decofile:c,onSaveReferencedBlock:h,previewBaseUrl:u,onAddSectionItem:f,onRequestAddSection:m,sandbox:p}=t;let g,_;if(e[0]!==o||e[1]!==c||e[2]!==d||e[3]!==f||e[4]!==l||e[5]!==r||e[6]!==m||e[7]!==h||e[8]!==u||e[9]!==p||e[10]!==s.properties||e[11]!==a||e[12]!==i){_=Symbol.for("react.early_return_sentinel");e:{const b=a===void 0?[]:a,x=s.properties;if(!x){_=null;break e}const v=i!=null&&typeof i=="object"&&!Array.isArray(i)?i:{},y=Object.keys(x).filter(T=>!Mw.has(T)&&x[T]?.hidden!==!0);if(y.length===0){let T;e[15]===Symbol.for("react.memo_cache_sentinel")?(T=n.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:"No editable fields on this section."}),e[15]=T):T=e[15],_=T;break e}const S=(T,k)=>{r({...v,[T]:k})},w=typeof v.__resolveType=="string"?v.__resolveType:void 0,C=b.length>0?iS(y,x,v,b):null,N=C?x[C]:null,E=C&&N?[C]:y,R=C&&N?tS(C,N,b):b;g=n.jsx("div",{className:"min-w-0 space-y-6",children:E.map(T=>{const k=x[T];if(!k)return null;const j=o?`${o}.${T}`:T,I=jn(T,k);return uc({schema:k,value:v[T],onChange:A=>S(T,A),path:j,label:I,breadcrumbPath:R,onBreadcrumbChange:l,meta:d,decofile:c,onSaveReferencedBlock:h,containerResolveType:w,previewBaseUrl:u,onAddSectionItem:f,onRequestAddSection:m,sandbox:p})})})}e[0]=o,e[1]=c,e[2]=d,e[3]=f,e[4]=l,e[5]=r,e[6]=m,e[7]=h,e[8]=u,e[9]=p,e[10]=s.properties,e[11]=a,e[12]=i,e[13]=g,e[14]=_}else g=e[13],_=e[14];return _!==Symbol.for("react.early_return_sentinel")?_:g}function Hw(t){const e=U.c(37),{open:s,onOpenChange:i,defaultBlockId:r,isPending:o,onSubmit:a}=t,l=r===void 0?"":r,d=o===void 0?!1:o,[c,h]=D.useState(l),[u,f]=D.useState(s);s!==u&&(f(s),s&&h(l));let m;e[0]!==d||e[1]!==i?(m=j=>{!j&&!d&&i(!1)},e[0]=d,e[1]=i,e[2]=m):m=e[2];const p=m;let g;e[3]!==c||e[4]!==d||e[5]!==a?(g=async j=>{j.preventDefault();const I=c.trim();!I||d||await a(I)},e[3]=c,e[4]=d,e[5]=a,e[6]=g):g=e[6];const _=g;let b;e[7]===Symbol.for("react.memo_cache_sentinel")?(b=n.jsxs(ts,{children:[n.jsx(ss,{children:"Save as global"}),n.jsx(Wi,{children:"Save this section as a global block so it can be reused on other pages."})]}),e[7]=b):b=e[7];let x;e[8]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsx("label",{htmlFor:"block-id",className:"text-sm font-medium",children:"Block name"}),e[8]=x):x=e[8];let v;e[9]===Symbol.for("react.memo_cache_sentinel")?(v=j=>h(j.target.value),e[9]=v):v=e[9];let y;e[10]!==c||e[11]!==d?(y=n.jsxs("div",{className:"py-4 space-y-2",children:[x,n.jsx(ze,{id:"block-id",value:c,onChange:v,placeholder:"MyNewBlock",autoFocus:!0,disabled:d})]}),e[10]=c,e[11]=d,e[12]=y):y=e[12];let S;e[13]!==i?(S=()=>i(!1),e[13]=i,e[14]=S):S=e[14];let w;e[15]!==d||e[16]!==S?(w=n.jsx(ie,{type:"button",variant:"outline",onClick:S,disabled:d,children:"Cancel"}),e[15]=d,e[16]=S,e[17]=w):w=e[17];let C;e[18]!==c||e[19]!==d?(C=!c.trim()||d,e[18]=c,e[19]=d,e[20]=C):C=e[20];let N;e[21]!==d?(N=d?n.jsxs(n.Fragment,{children:[n.jsx(Oe,{size:14,className:"animate-spin"}),"Saving…"]}):"Save",e[21]=d,e[22]=N):N=e[22];let E;e[23]!==C||e[24]!==N?(E=n.jsx(ie,{type:"submit",disabled:C,children:N}),e[23]=C,e[24]=N,e[25]=E):E=e[25];let R;e[26]!==w||e[27]!==E?(R=n.jsxs(Ws,{children:[w,E]}),e[26]=w,e[27]=E,e[28]=R):R=e[28];let T;e[29]!==_||e[30]!==R||e[31]!==y?(T=n.jsx(Mt,{className:"sm:max-w-md",children:n.jsxs("form",{onSubmit:_,children:[b,y,R]})}),e[29]=_,e[30]=R,e[31]=y,e[32]=T):T=e[32];let k;return e[33]!==p||e[34]!==s||e[35]!==T?(k=n.jsx(Bt,{open:s,onOpenChange:p,children:T}),e[33]=p,e[34]=s,e[35]=T,e[36]=k):k=e[36],k}function Uw(t){const e=U.c(60),{orgSlug:s,virtualMcpId:i,branch:r,previewUrl:o,meta:a,decofile:l,resolveType:d,title:c,defaultBlockId:h,isCreating:u,onCreate:f,onSaveReferencedBlock:m}=t,p=gi(),g=p?.entity?.id===i?p.entity.metadata?.siteSlug??null:null;let _;e[0]===Symbol.for("react.memo_cache_sentinel")?(_={},e[0]=_):_=e[0];const[b,x]=D.useState(_);let v;e[1]===Symbol.for("react.memo_cache_sentinel")?(v=[],e[1]=v):v=e[1];const[y,S]=D.useState(v),[w,C]=D.useState(0),[N,E]=D.useState(!1);let R;e[2]!==a||e[3]!==d?(R=Us(d,a),e[2]=a,e[3]=d,e[4]=R):R=e[4];const T=R;let k;e[5]!==d?(k=d.split("/").pop()?.replace(/\.tsx?$/,"")??d,e[5]=d,e[6]=k):k=e[6];const j=k,I=o??void 0;let A;e[7]!==g||e[8]!==r||e[9]!==s||e[10]!==I||e[11]!==i?(A={orgSlug:s,virtualMcpId:i,branch:r,previewUrl:I,siteSlug:g},e[7]=g,e[8]=r,e[9]=s,e[10]=I,e[11]=i,e[12]=A):A=e[12];const O=A;let L;e[13]!==y||e[14]!==c?(L=[c,...y],e[13]=y,e[14]=c,e[15]=L):L=e[15];const P=L;let B;e[16]!==y?(B=ce=>{S(y.slice(0,ce)),C(Ww)},e[16]=y,e[17]=B):B=e[17];const F=B;let H;e[18]!==l||e[19]!==b||e[20]!==f?(H=async ce=>{const fe=y2(ce,l);if(fe){he.error(fe);return}await f(ce,b),E(!1)},e[18]=l,e[19]=b,e[20]=f,e[21]=H):H=e[21];const z=H;let W;e[22]!==F||e[23]!==P?(W=n.jsx("nav",{"aria-label":"Editing breadcrumb",className:"flex min-w-0 flex-1 items-center gap-1 overflow-hidden text-sm",children:P.map((ce,fe)=>{const J=fe===P.length-1;return n.jsxs("span",{className:"flex min-w-0 items-center gap-1 overflow-hidden",children:[fe>0&&n.jsx(Vi,{className:"size-3 shrink-0 text-muted-foreground/60"}),n.jsx("button",{type:"button",onClick:()=>F(fe),title:ce,className:ae("min-w-0 truncate rounded-md px-1 py-0.5 text-left transition-colors hover:bg-accent hover:text-accent-foreground",J?"font-medium text-foreground":"text-muted-foreground"),children:ce})]},`${ce}-${fe}`)})}),e[22]=F,e[23]=P,e[24]=W):W=e[24];let q;e[25]===Symbol.for("react.memo_cache_sentinel")?(q=()=>E(!0),e[25]=q):q=e[25];let K;e[26]===Symbol.for("react.memo_cache_sentinel")?(K=n.jsx(Nu,{size:14}),e[26]=K):K=e[26];let Z;e[27]!==u?(Z=n.jsx(Ne,{asChild:!0,children:n.jsx(ie,{size:"icon",className:"size-8 shrink-0",disabled:u,onClick:q,"aria-label":"Save as global section",children:K})}),e[27]=u,e[28]=Z):Z=e[28];let Y;e[29]===Symbol.for("react.memo_cache_sentinel")?(Y=n.jsx(Ee,{side:"bottom",children:"Save as global section"}),e[29]=Y):Y=e[29];let G;e[30]!==Z?(G=n.jsxs(Te,{children:[Z,Y]}),e[30]=Z,e[31]=G):G=e[31];let Q;e[32]!==W||e[33]!==G?(Q=n.jsxs("div",{className:"flex min-w-0 items-center gap-2 overflow-hidden",children:[W,G]}),e[32]=W,e[33]=G,e[34]=Q):Q=e[34];let $;e[35]!==j?($=n.jsxs("p",{className:"mt-1.5 py-1 pl-1 text-sm leading-snug text-muted-foreground",children:[j," — edits stay local until you save this as a global section."]}),e[35]=j,e[36]=$):$=e[36];let X;e[37]!==Q||e[38]!==$?(X=n.jsxs("div",{className:"shrink-0 border-b px-3 py-2.5",children:[Q,$]}),e[37]=Q,e[38]=$,e[39]=X):X=e[39];let V;e[40]!==l||e[41]!==y||e[42]!==w||e[43]!==b||e[44]!==a||e[45]!==m||e[46]!==O||e[47]!==T?(V=n.jsx(Fi,{className:"min-h-0 flex-1 [&_[data-slot=scroll-area-viewport]>div]:!block",children:n.jsx("div",{className:"min-w-0 max-w-full overflow-x-hidden px-6 py-4",children:n.jsx("div",{className:"mx-auto max-w-2xl",children:T?n.jsx(Zi,{schema:T,value:b,onChange:ce=>x(ce),basePath:"",breadcrumbPath:y,onBreadcrumbChange:S,meta:a,decofile:l,onSaveReferencedBlock:m,sandbox:O},w):n.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:"No editable fields for this section."})})})}),e[40]=l,e[41]=y,e[42]=w,e[43]=b,e[44]=a,e[45]=m,e[46]=O,e[47]=T,e[48]=V):V=e[48];let se;e[49]!==X||e[50]!==V?(se=n.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[X,V]}),e[49]=X,e[50]=V,e[51]=se):se=e[51];let ee;e[52]!==h||e[53]!==z||e[54]!==u||e[55]!==N?(ee=n.jsx(Hw,{open:N,onOpenChange:E,defaultBlockId:h,isPending:u,onSubmit:z}),e[52]=h,e[53]=z,e[54]=u,e[55]=N,e[56]=ee):ee=e[56];let le;return e[57]!==se||e[58]!==ee?(le=n.jsxs("div",{className:"flex h-full w-full min-w-0",children:[se,ee]}),e[57]=se,e[58]=ee,e[59]=le):le=e[59],le}function Ww(t){return t+1}function Vw(t,e){const s={__resolveType:t},i=Xf([s],e)[0];return i?bS(s,i,e):null}function Kw({orgSlug:t,virtualMcpId:e,branch:s,previewUrl:i,meta:r,decofile:o,blockKey:a,onSaveReferencedBlock:l}){const d=gi(),c=d?.entity?.id===e?d.entity.metadata?.siteSlug??null:null,[h]=D.useState(()=>Vw(a,o)),[u,f]=D.useState(h?.data??{}),[m,p]=D.useState([]),[g,_]=D.useState(0),[b,x]=D.useState(!1),[v,y]=D.useState(null),S=v!==null,{save:w,flush:C}=k0({orgSlug:t,virtualMcpId:e,branch:s}),N=h?.resolveType?Us(h.resolveType,r):null,E=o[a],R=E?Kl(a,E):a,T={orgSlug:t,virtualMcpId:e,branch:s,previewUrl:i??void 0,siteSlug:c},k=L=>{f(L),w(a,L)},j=()=>{S?(y(null),x(!1),_(L=>L+1)):y(JSON.stringify(u,null,2))},I=L=>{const P=L??"";try{const B=JSON.parse(P);if(B&&typeof B=="object"&&!Array.isArray(B)){x(!1),k(B);return}x(!0)}catch{x(!0)}},A=[R,...m],O=L=>{p(m.slice(0,L)),_(P=>P+1)};return n.jsx("div",{className:"flex h-full w-full min-w-0",children:n.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[n.jsxs("div",{className:"shrink-0 border-b px-3 py-2.5",children:[n.jsxs("div",{className:"flex min-w-0 items-center gap-2 overflow-hidden",children:[n.jsx("span",{className:"size-2 shrink-0 rounded-full",style:{backgroundColor:lf},"aria-hidden":!0}),n.jsx("nav",{"aria-label":"Editing breadcrumb",className:"flex min-w-0 flex-1 items-center gap-1 overflow-hidden text-sm",children:A.map((L,P)=>{const B=P===A.length-1;return n.jsxs("span",{className:"flex min-w-0 items-center gap-1 overflow-hidden",children:[P>0&&n.jsx(Vi,{className:"size-3 shrink-0 text-muted-foreground/60"}),n.jsx("button",{type:"button",onClick:()=>O(P),title:L,className:ae("min-w-0 truncate rounded-md px-1 py-0.5 text-left transition-colors hover:bg-accent hover:text-accent-foreground",B?"font-medium text-foreground":"text-muted-foreground"),children:L})]},`${L}-${P}`)})}),n.jsxs(Te,{children:[n.jsx(Ne,{asChild:!0,children:n.jsx(ie,{variant:S?"default":"ghost",size:"icon",className:"size-8 shrink-0",onClick:j,"aria-label":S?"Close JSON editor":"Edit as JSON","aria-pressed":S,children:S?n.jsx(jl,{size:14}):n.jsx(no,{size:14})})}),n.jsx(Ee,{side:"bottom",children:S?"Close JSON editor":"Edit as JSON"})]})]}),n.jsx("p",{className:"mt-1.5 py-1 pl-1 text-sm leading-snug text-muted-foreground",children:"Global section — changes save automatically and apply everywhere it's used."})]}),n.jsxs("div",{className:"relative min-h-0 flex-1",children:[n.jsx(Fi,{className:"h-full [&_[data-slot=scroll-area-viewport]>div]:!block",children:n.jsx("div",{className:"min-w-0 max-w-full overflow-x-hidden px-6 py-4",children:n.jsx("div",{className:"mx-auto max-w-2xl",children:N?n.jsx(Zi,{schema:N,value:u,onChange:L=>k(L),basePath:"",breadcrumbPath:m,onBreadcrumbChange:p,meta:r,decofile:o,onSaveReferencedBlock:l,sandbox:T},g):n.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:"No editable fields for this section."})})})}),v!==null&&n.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[b&&n.jsx("div",{className:"shrink-0 border-b bg-destructive/10 px-3 py-1.5 text-xs text-destructive",children:"Invalid JSON — changes aren't saved until it parses."}),n.jsx("div",{className:"min-h-0 flex-1",children:n.jsx(Gu,{language:"json",height:"100%",code:v,onChange:I,onSave:L=>{I(L),C()}})})]})]})]})})}function Rd(t,e){const s=e.replace(/\s*\(copy(?:\s+\d+)?\)\s*$/,"").trim(),i=`${s} (copy)`;if(!t.has(i))return i;for(let r=2;r<1e3;r++){const o=`${s} (copy ${r})`;if(!t.has(o))return o}return`${s} (copy ${Date.now()})`}function qw(t,e){const s=Ti,i=e.replace(/-copy(?:-\d+)?$/,""),r=`${i}-copy`;if(!t.has(s(r)))return r;for(let o=2;o<1e3;o++){const a=`${i}-copy-${o}`;if(!t.has(s(a)))return a}return`${i}-copy-${Date.now()}`}function Gw(t,e){const s=e.replace(/_copy(?:_\d+)?$/,""),i=`${s}_copy`;if(!Object.hasOwn(t,i))return i;for(let r=2;r<1e3;r++){const o=`${s}_copy_${r}`;if(!Object.hasOwn(t,o))return o}return`${s}_copy_${Date.now()}`}function Yw(t){const e=ic(t.newName),s={...t.source,name:t.newName,path:t.newPath};return{key:e,data:s}}function Xw(t,e){return im(t,e)}const Jw=1e3;function Zw(t,e){for(let s=0;s<Jw;s++){const i=ic(e);if(!Object.hasOwn(t,i))return i}throw new Error("Could not generate a unique page block key")}const Qw={create:"Create new page",duplicate:"Duplicate page",rename:"Rename page"},eC={create:"Create",duplicate:"Duplicate",rename:"Save"},tC={create:"Creating…",duplicate:"Duplicating…",rename:"Saving…"};function sC(t){const e=U.c(54),{open:s,mode:i,initialName:r,initialPath:o,isPending:a,error:l,validate:d,onSubmit:c,onOpenChange:h}=t,u=a===void 0?!1:a,[f,m]=D.useState(r),[p,g]=D.useState(o),[_,b]=D.useState(null),[x,v]=D.useState(s);s!==x&&(v(s),s&&(m(r),g(o),b(null)));let y;e[0]!==u||e[1]!==h?(y=Y=>{!Y&&!u&&(b(null),h(!1))},e[0]=u,e[1]=h,e[2]=y):y=e[2];const S=y;let w;e[3]!==u||e[4]!==f||e[5]!==c||e[6]!==p||e[7]!==d?(w=async Y=>{Y.preventDefault();const G=f.trim(),Q=p.trim();if(!G||!Q||u)return;const $=Hl(Q);if($){b($);return}const X=d?.({name:G,path:Q});if(X){b(X);return}b(null),await c({name:G,path:Q})},e[3]=u,e[4]=f,e[5]=c,e[6]=p,e[7]=d,e[8]=w):w=e[8];const C=w,N=_??l,E=Qw[i];let R;e[9]!==E?(R=n.jsx(ts,{children:n.jsx(ss,{children:E})}),e[9]=E,e[10]=R):R=e[10];let T;e[11]===Symbol.for("react.memo_cache_sentinel")?(T=n.jsx("label",{htmlFor:"page-form-name",className:"text-xs font-medium text-muted-foreground",children:"Name"}),e[11]=T):T=e[11];let k;e[12]===Symbol.for("react.memo_cache_sentinel")?(k=Y=>m(Y.target.value),e[12]=k):k=e[12];let j;e[13]!==u||e[14]!==f?(j=n.jsxs("div",{className:"space-y-1.5",children:[T,n.jsx(ze,{id:"page-form-name",value:f,onChange:k,placeholder:"My page",autoFocus:!0,disabled:u})]}),e[13]=u,e[14]=f,e[15]=j):j=e[15];let I;e[16]===Symbol.for("react.memo_cache_sentinel")?(I=n.jsx("label",{htmlFor:"page-form-path",className:"text-xs font-medium text-muted-foreground",children:"Path"}),e[16]=I):I=e[16];let A;e[17]===Symbol.for("react.memo_cache_sentinel")?(A=Y=>g(Y.target.value),e[17]=A):A=e[17];let O;e[18]!==u||e[19]!==p?(O=n.jsxs("div",{className:"space-y-1.5",children:[I,n.jsx(ze,{id:"page-form-path",value:p,onChange:A,placeholder:"/example",disabled:u})]}),e[18]=u,e[19]=p,e[20]=O):O=e[20];let L;e[21]!==N?(L=N&&n.jsx("p",{className:"text-xs text-destructive",children:N}),e[21]=N,e[22]=L):L=e[22];let P;e[23]!==O||e[24]!==L||e[25]!==j?(P=n.jsxs("div",{className:"space-y-4 py-4",children:[j,O,L]}),e[23]=O,e[24]=L,e[25]=j,e[26]=P):P=e[26];let B;e[27]!==h?(B=()=>h(!1),e[27]=h,e[28]=B):B=e[28];let F;e[29]!==u||e[30]!==B?(F=n.jsx(ie,{type:"button",variant:"outline",onClick:B,disabled:u,children:"Cancel"}),e[29]=u,e[30]=B,e[31]=F):F=e[31];let H;e[32]!==u||e[33]!==f||e[34]!==p?(H=!f.trim()||!p.trim()||u,e[32]=u,e[33]=f,e[34]=p,e[35]=H):H=e[35];let z;e[36]!==u||e[37]!==i?(z=u?n.jsxs(n.Fragment,{children:[n.jsx(Oe,{size:14,className:"animate-spin"}),tC[i]]}):eC[i],e[36]=u,e[37]=i,e[38]=z):z=e[38];let W;e[39]!==H||e[40]!==z?(W=n.jsx(ie,{type:"submit",disabled:H,children:z}),e[39]=H,e[40]=z,e[41]=W):W=e[41];let q;e[42]!==F||e[43]!==W?(q=n.jsxs(Ws,{children:[F,W]}),e[42]=F,e[43]=W,e[44]=q):q=e[44];let K;e[45]!==C||e[46]!==P||e[47]!==q||e[48]!==R?(K=n.jsx(Mt,{className:"sm:max-w-md",children:n.jsxs("form",{onSubmit:C,children:[R,P,q]})}),e[45]=C,e[46]=P,e[47]=q,e[48]=R,e[49]=K):K=e[49];let Z;return e[50]!==S||e[51]!==s||e[52]!==K?(Z=n.jsx(Bt,{open:s,onOpenChange:S,children:K}),e[50]=S,e[51]=s,e[52]=K,e[53]=Z):Z=e[53],Z}function iC(t){const e=U.c(43),{open:s,blockKey:i,initialName:r,isPending:o,onSubmit:a,onOpenChange:l}=t,d=o===void 0?!1:o,[c,h]=D.useState(r),[u,f]=D.useState(s);s!==u&&(f(s),s&&h(r));let m;e[0]!==d||e[1]!==l?(m=O=>{!O&&!d&&l(!1)},e[0]=d,e[1]=l,e[2]=m):m=e[2];const p=m;let g;e[3]!==d||e[4]!==c||e[5]!==a?(g=async O=>{O.preventDefault();const L=c.trim();!L||d||await a(L)},e[3]=d,e[4]=c,e[5]=a,e[6]=g):g=e[6];const _=g;let b;e[7]===Symbol.for("react.memo_cache_sentinel")?(b=n.jsxs(ts,{children:[n.jsx(ss,{children:"Rename section"}),n.jsx(Wi,{children:"Updates the display name. The internal key stays the same so pages referencing this section keep working."})]}),e[7]=b):b=e[7];let x;e[8]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsx("label",{htmlFor:"section-rename-name",className:"text-xs font-medium text-muted-foreground",children:"Name"}),e[8]=x):x=e[8];let v;e[9]===Symbol.for("react.memo_cache_sentinel")?(v=O=>h(O.target.value),e[9]=v):v=e[9];let y;e[10]!==d||e[11]!==c?(y=n.jsxs("div",{className:"space-y-1.5",children:[x,n.jsx(ze,{id:"section-rename-name",value:c,onChange:v,autoFocus:!0,disabled:d})]}),e[10]=d,e[11]=c,e[12]=y):y=e[12];let S;e[13]===Symbol.for("react.memo_cache_sentinel")?(S=n.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Key"}),e[13]=S):S=e[13];let w;e[14]!==i?(w=n.jsxs("div",{className:"space-y-1.5",children:[S,n.jsx(ze,{value:i,readOnly:!0,disabled:!0,className:"font-mono"})]}),e[14]=i,e[15]=w):w=e[15];let C;e[16]!==y||e[17]!==w?(C=n.jsxs("div",{className:"space-y-4 py-4",children:[y,w]}),e[16]=y,e[17]=w,e[18]=C):C=e[18];let N;e[19]!==l?(N=()=>l(!1),e[19]=l,e[20]=N):N=e[20];let E;e[21]!==d||e[22]!==N?(E=n.jsx(ie,{type:"button",variant:"outline",onClick:N,disabled:d,children:"Cancel"}),e[21]=d,e[22]=N,e[23]=E):E=e[23];let R;e[24]!==d||e[25]!==c?(R=!c.trim()||d,e[24]=d,e[25]=c,e[26]=R):R=e[26];let T;e[27]!==d?(T=d?n.jsxs(n.Fragment,{children:[n.jsx(Oe,{size:14,className:"animate-spin"}),"Saving…"]}):"Save",e[27]=d,e[28]=T):T=e[28];let k;e[29]!==R||e[30]!==T?(k=n.jsx(ie,{type:"submit",disabled:R,children:T}),e[29]=R,e[30]=T,e[31]=k):k=e[31];let j;e[32]!==E||e[33]!==k?(j=n.jsxs(Ws,{children:[E,k]}),e[32]=E,e[33]=k,e[34]=j):j=e[34];let I;e[35]!==_||e[36]!==C||e[37]!==j?(I=n.jsx(Mt,{className:"sm:max-w-md",children:n.jsxs("form",{onSubmit:_,children:[b,C,j]})}),e[35]=_,e[36]=C,e[37]=j,e[38]=I):I=e[38];let A;return e[39]!==p||e[40]!==s||e[41]!==I?(A=n.jsx(Bt,{open:s,onOpenChange:p,children:I}),e[39]=p,e[40]=s,e[41]=I,e[42]=A):A=e[42],A}const Fo={post:"blog/loaders/Blogpost.ts",author:"blog/loaders/Author.ts",category:"blog/loaders/Category.ts"},fc=["posts","authors","categories"],En={posts:"post",authors:"author",categories:"category"};function Tn(t){return fc.includes(t)}const mc={posts:"post",authors:"author",categories:"category"},Em={posts:Fo.post,authors:Fo.author,categories:Fo.category},nC=Object.fromEntries(Object.entries(Em).map(([t,e])=>[e,t]));function rC(t){return typeof t=="string"?nC[t]??null:null}function Oi(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:null}function rs(t){return typeof t=="string"?t:""}function oC(t,e){switch(t){case"posts":return{label:rs(e.title)||"Untitled post",subtitle:rs(e.slug)};case"authors":return{label:rs(e.name)||"Unnamed author",subtitle:rs(e.email)};case"categories":return{label:rs(e.name)||"Unnamed category",subtitle:rs(e.slug)};default:{const s=t;throw new Error(`Unhandled blog kind: ${String(s)}`)}}}function Tm(t){const e={posts:[],authors:[],categories:[]};for(const[s,i]of Object.entries(t)){const r=Oi(i);if(!r)continue;const o=rC(r.__resolveType);if(!o)continue;const a=Oi(r[mc[o]])??{},{label:l,subtitle:d}=oC(o,a);e[o].push({key:s,kind:o,label:l,subtitle:d})}for(const s of fc)e[s].sort((i,r)=>i.label.localeCompare(r.label));return e}function aC(t,e){return Tm(t)[e]}function Kr(t,e){return aC(t,e).map(s=>({key:s.key,payload:Sa(Oi(t[s.key])??void 0,e)}))}function Sa(t,e){return t?Oi(t[mc[e]])??{}:{}}function Ho(t,e,s){return{name:t,__resolveType:Em[e],[mc[e]]:s}}function Am(t){return`.deco/blocks/${encodeURIComponent(t)}.json`}function qr(t){return Array.isArray(t)?t:[]}function pc(t){if(typeof t=="string")return t;const e=Oi(t);return e?rs(e.slug):""}function lC(t){if(typeof t=="string")return t;const e=Oi(t);return e?rs(e.email):""}function cC(t){return Kr(t,"posts").map(({key:e,payload:s})=>({key:e,title:rs(s.title)||"Untitled post",slug:rs(s.slug),date:rs(s.date),categorySlugs:qr(s.categories).map(pc).filter(Boolean),authorEmails:qr(s.authors).map(lC).filter(Boolean)}))}function dC(t,e){const s=qr(t.categories);return s.some(i=>pc(i)===e.slug)?t:{...t,categories:[...s,{name:e.name,slug:e.slug}]}}function hC(t,e){const s=qr(t.categories);return s.length===1&&pc(s[0])===e.slug?t:{...t,categories:[{name:e.name,slug:e.slug}]}}function wa(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 Pd(t,e){const s=`collections/blog/${e}/${wa(12)}`;if(!Object.hasOwn(t,s))return s;throw new Error("Could not generate a unique blog block key")}function uC(t){switch(t){case"posts":return{title:"Untitled post",excerpt:"",slug:`untitled-${wa(8)}`,date:new Date().toISOString().slice(0,10),image:"",authors:[],categories:[],sections:[]};case"authors":return{name:"New author",email:"",jobTitle:"",company:"",avatar:""};case"categories":return{name:"New category",slug:`category-${wa(8)}`,description:"",sections:[]};default:{const e=t;throw new Error(`Unhandled blog kind: ${String(e)}`)}}}const fC={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"},ProductCard:{title:"Product card",description:"Single product",iconName:"Tag01"},ProductShelf:{title:"Product shelf",description:"Row of products",iconName:"ShoppingBag01"}},Dd="Box";function mC(t){return t.startsWith("site/")?"site":"app"}function pC(t){return t.startsWith("http://")||t.startsWith("https://")||t.startsWith("data:")||t.startsWith("/")}function on(...t){for(const e of t)if(e!==void 0)return e}function NE(t){const e=new Set,s=[],i=t.manifest?.blocks??{};for(const r of Object.values(i))for(const o of Object.keys(r)){if(!vC(o)||e.has(o))continue;e.add(o);const a=fi(o,t),l=gC(o),d=fC[l],c=mC(o),h=(c==="site"?on(a.title,d?.title):on(d?.title,a.title))??l,u=c==="site"?on(a.description,d?.description):on(d?.description,a.description),f=c==="site"?a.icon:void 0,m=f&&pC(f)?f:void 0,p=m!==void 0?d?.iconName??Dd:on(f,d?.iconName)??Dd;s.push({resolveType:o,title:h,description:u,iconName:p,iconUrl:m,source:c})}return s.sort((r,o)=>r.title.localeCompare(o.title))}function gC(t){return(t.split("/").pop()??t).replace(/\.(tsx?|jsx?)$/,"")}const _C=["blog/sections/blocks/","site/sections/Blog/Post/"];function vC(t){return _C.some(e=>t.startsWith(e))}function Rm({orgSlug:t,virtualMcpId:e,branch:s}){return Et.decofile(`${t}/${e}/${s}`)}function Pm({orgSlug:t,virtualMcpId:e,branch:s},i){return`/api/${t}/sandbox/${encodeURIComponent(e)}/${encodeURIComponent(s)}/${i}`}function xC(t){const e=U.c(11),s=oi();let i;e[0]!==t?(i=async l=>{const{blockKey:d,data:c}=l,h=await fetch(Pm(t,"write"),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({path:Am(d),content:JSON.stringify(c,null,2)})});if(!h.ok){const u=await h.json().catch(bC);throw new Error(u.error??`Write failed (${h.status})`)}return h.json()},e[0]=t,e[1]=i):i=e[1];let r;e[2]!==t||e[3]!==s?(r=async l=>{const{blockKey:d,data:c}=l,h=Rm(t);await s.cancelQueries({queryKey:h});const u=s.getQueryData(h);return s.setQueryData(h,f=>({...f??{},[d]:c})),{previous:u,queryKey:h}},e[2]=t,e[3]=s,e[4]=r):r=e[4];let o;e[5]!==s?(o=(l,d,c)=>{c?.queryKey&&s.setQueryData(c.queryKey,c.previous)},e[5]=s,e[6]=o):o=e[6];let a;return e[7]!==i||e[8]!==r||e[9]!==o?(a={mutationFn:i,onMutate:r,onError:o},e[7]=i,e[8]=r,e[9]=o,e[10]=a):a=e[10],ai(a)}function bC(){return{}}function yC(t){const e=oi();return ai({mutationFn:async({blockKey:s})=>{const i=await fetch(Pm(t,"unlink"),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({path:Am(s)})});if(!i.ok){const r=await i.json().catch(()=>({}));throw new Error(r.error??`Delete failed (${i.status})`)}return i.json()},onMutate:async({blockKey:s})=>{const i=Rm(t);await e.cancelQueries({queryKey:i});const r=e.getQueryData(i);return e.setQueryData(i,o=>{if(!o)return o;const{[s]:a,...l}=o;return l}),{previous:r,queryKey:i}},onError:(s,i,r)=>{r?.queryKey&&e.setQueryData(r.queryKey,r.previous)}})}function SC(t){const e=U.c(20),{open:s,onOpenChange:i,pageKey:r,decofile:o}=t,[a,l]=D.useState(!1),d=o[r];let c;e[0]!==d?(c=d===void 0?"// Page not found.":JSON.stringify(d,null,2),e[0]=d,e[1]=c):c=e[1];const h=c;let u;e[2]!==h?(u=()=>{navigator.clipboard.writeText(h).then(()=>{l(!0),setTimeout(()=>l(!1),2e3)})},e[2]=h,e[3]=u):u=e[3];const f=u;let m;e[4]===Symbol.for("react.memo_cache_sentinel")?(m=n.jsx(ss,{className:"text-sm font-semibold",children:"Page JSON"}),e[4]=m):m=e[4];let p;e[5]!==a?(p=a?n.jsx(Yh,{size:12}):n.jsx(as,{size:12}),e[5]=a,e[6]=p):p=e[6];const g=a?"Copied":"Copy";let _;e[7]!==f||e[8]!==p||e[9]!==g?(_=n.jsxs(ts,{className:"px-4 py-3 border-b flex-row items-center justify-between space-y-0",children:[m,n.jsxs(ie,{variant:"ghost",size:"sm",onClick:f,className:"h-7 gap-1.5 text-xs",children:[p,g]})]}),e[7]=f,e[8]=p,e[9]=g,e[10]=_):_=e[10];let b;e[11]!==h?(b=n.jsx(Fi,{className:"max-h-[70vh]",children:n.jsx("pre",{className:"p-4 text-xs font-mono text-foreground/90 whitespace-pre overflow-auto",children:h})}),e[11]=h,e[12]=b):b=e[12];let x;e[13]!==_||e[14]!==b?(x=n.jsxs(Mt,{className:"max-w-2xl p-0 gap-0",children:[_,b]}),e[13]=_,e[14]=b,e[15]=x):x=e[15];let v;return e[16]!==i||e[17]!==s||e[18]!==x?(v=n.jsx(Bt,{open:s,onOpenChange:i,children:x}),e[16]=i,e[17]=s,e[18]=x,e[19]=v):v=e[19],v}const Id=D.lazy(()=>ls(()=>import("./app-editor-BI1KpS86.js"),__vite__mapDeps([144,1,2,5,44,7,8,9,10,11,12,13,14,15,16,6,3,4,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,99,145,100,91,88,101,102,80,81,82,83,84,85,86,87,89,90,92,93,94,95,96,103,104,105,106,107,108,109,110,111,79,112,113,114,115,116,117,118,119,120,121,122,98,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140])).then(t=>({default:t.AppEditor}))),wC=D.lazy(()=>ls(()=>import("./post-editor-Dlb8m7Iz.js"),__vite__mapDeps([146,1,2,3,28,7,8,9,10,11,12,13,14,15,16,6,4,5,17,18,19,20,21,22,23,24,25,26,27,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,131,84,85,87,132,114,133,134,135,136,96,90,105,110,111,109,92,147,145,148,80,81,82,83,86,88,89,91,93,94,95,100,101,102,103,104,106,107,108,79,112,113,115,116,117,118,119,120,121,122,98,123,124,125,126,127,128,129,130,137,138,139,140])).then(t=>({default:t.PostEditor}))),CC=D.lazy(()=>ls(()=>import("./record-editor-BjHlAGT_.js"),__vite__mapDeps([149,1,2,77,76,92,147,33,37,145,8,6,100,56,57,54,55,58,59,60,61,62,63,64,51,65,44,7,9,10,11,12,13,14,15,16,3,4,5,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,34,35,36,38,39,40,41,42,43,45,46,47,48,49,50,52,53,66,67,68,69,70,71,72,73,74,75,78,91,88,101,102,80,81,82,83,84,85,86,87,89,90,93,94,95,96,103,104,105,106,107,108,109,110,111,79,112,113,114,115,116,117,118,119,120,121,122,98,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140])).then(t=>({default:t.RecordEditor}))),kC=D.lazy(()=>ls(()=>import("./category-editor-UeZPwCgj.js"),__vite__mapDeps([150,1,2,12,7,8,9,10,11,13,14,15,16,6,3,4,5,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,77,76,147,145,148,80,81,82,83,73,62,54,55,65,64,84,85,86,87,71,88,89,90,50,91,48,75,78,92,93,94,95,96,63,110,111,109,44,45,46,47,49,51,52,53,56,57,58,59,60,61,66,67,68,69,70,72,74,100,101,102,103,104,105,106,107,108,79,112,113,114,115,116,117,118,119,120,121,122,98,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140])).then(t=>({default:t.CategoryEditor}))),jC=D.lazy(()=>ls(()=>import("./sections-editor-C33mQAPq.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])).then(t=>({default:t.SectionsEditor}))),NC=D.lazy(()=>ls(()=>import("./seo-editor-DVLMhS9K.js"),__vite__mapDeps([151,1,2,5,7,8,9,10,11,12,13,14,15,16,6,3,4,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,97,98,100,91,88,101,102,80,81,82,83,84,85,86,87,89,90,92,93,94,95,96,103,104,105,106,107,108,109,110,111,79,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])).then(t=>({default:t.SeoEditor}))),EC=D.lazy(()=>ls(()=>import("./variant-calendar-cujTqFIv.js"),__vite__mapDeps([152,1,2,7,8,9,10,11,12,13,14,15,16,6,3,4,5,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,130])).then(t=>({default:t.VariantCalendar}))),Ca="oklch(0.65 0.15 160)";function TC(t){return t.split("/").pop()?.replace(/\.tsx?$/,"")||t||"Section"}function AC(t){const e=new Map;for(const s of t){const i=TC(s.resolveType),r=e.get(i);r?r.push(s):e.set(i,[s])}return[...e.entries()].map(([s,i])=>({label:s,sections:i})).sort((s,i)=>s.label.localeCompare(i.label))}function RC(){const t=U.c(18),e=gi(),{data:s}=$i.useSession(),{currentBranch:i}=Ts(),{org:r}=Me(),o=e?.entity?.id??null,a=s?.user?.id,l=e?.entity?.metadata,d=a&&i?to(l?.sandboxMap?.[a]?.[i]):{},c=Object.values(d),u=(c.find(PC)??c[0])?.previewUrl??null,f=bs(),m=e?.entity?.organization_id??"";let p;t[0]!==r.slug||t[1]!==m?(p={connectionId:ul,orgId:m,orgSlug:r.slug},t[0]=r.slug,t[1]=m,t[2]=p):p=t[2];const g=Pt(p),_=ll(g);let b;t[3]!==i||t[4]!==_||t[5]!==o?(b=()=>{if(!o)return;const w={virtualMcpId:o};i&&(w.branch=i),_.mutate(w)},t[3]=i,t[4]=_,t[5]=o,t[6]=b):b=t[6];const x=b,v=!!o&&!!i&&oa.isStopped(o,i),y=wf({previewUrl:u,appPaused:f.status.state==="paused",userStopped:v});if(y.kind!=="iframe"){let w;return t[7]!==y||t[8]!==x||t[9]!==f.lifecycle||t[10]!==f.phase?(w=n.jsx(QC,{state:y,claimPhase:f.phase,lifecycle:f.lifecycle,onStart:x}),t[7]=y,t[8]=x,t[9]=f.lifecycle,t[10]=f.phase,t[11]=w):w=t[11],w}if(!o||!i){let w;return t[12]===Symbol.for("react.memo_cache_sentinel")?(w=n.jsx(ki,{title:"Waiting for sandbox context…"}),t[12]=w):w=t[12],w}let S;return t[13]!==i||t[14]!==r.slug||t[15]!==u||t[16]!==o?(S=n.jsx(IC,{orgSlug:r.slug,virtualMcpId:o,branch:i,previewUrl:u}),t[13]=i,t[14]=r.slug,t[15]=u,t[16]=o,t[17]=S):S=t[17],S}function PC(t){return t.sandboxProviderKind!=="user-desktop"}const Ld=2e3,DC=15;function Od(t,e,s,i){return typeof e!="string"||s&&(lm(e,s,i)||t.state.dataUpdateCount>=DC)?!1:Ld}function IC({orgSlug:t,virtualMcpId:e,branch:s,previewUrl:i}){const r={orgSlug:t,virtualMcpId:e,branch:s,previewUrl:i},{data:o,isLoading:a}=Ol(r),[l,d]=D.useState("pages"),[c,h]=D.useState(null),[u,f]=D.useState(null),[m,p]=D.useState(""),[g,_]=D.useState(null),[b,x]=D.useState(null),[v,y]=D.useState("date-desc"),[S,w]=D.useState(()=>new Set),[C,N]=D.useState(l);C!==l&&(N(l),p(""),_(null),x(null),y("date-desc"),w(new Set));const{data:E,isLoading:R,isFetching:T}=Bl(r,{refetchInterval:M=>{const ue=M.state.data;if(l==="apps"&&c&&c.collection==="apps"){const ge=o?.[c.key];return Od(M,typeof ge?.__resolveType=="string"?ge.__resolveType:void 0,ue)}if(l==="site"&&o){const ge=ue?va(o,ue):null,ke=o.site,Je=ge?.resolveType??(typeof ke?.__resolveType=="string"?ke.__resolveType:void 0);return Od(M,Je,ue,["seo"])}return!1}}),k=(M,ue)=>!lm(M,E,ue)&&(R||T),{catalog:j,isLoading:I}=x2(E??void 0,o??void 0,{enabled:l==="apps"}),A=nc(r),O=d2(r),L=xC(r),P=yC(r),[B,F]=D.useState(null),[H,z]=D.useState(),[W,q]=D.useState(null),[K,Z]=D.useState(null),[Y,G]=D.useState(null),[Q,$]=D.useState(null);if(a||R)return n.jsx("div",{className:"h-full w-full flex items-center justify-center",children:n.jsx(Oe,{size:20,className:"animate-spin text-muted-foreground"})});if(!o||!E)return n.jsx(ki,{title:"Could not load site data."});const X=Vl(o).sort((M,ue)=>M.name.localeCompare(ue.name)),V=ql(o,E),se=l==="sections"?ex(E):[],ee=va(o,E),le=Tm(o),ce=fc.some(M=>le[M].length>0),fe=Tn(l)?le[l]:[],J=(ce?Kr(o,"categories"):[]).map(({key:M,payload:ue})=>{const ge=typeof ue.slug=="string"?ue.slug:"",ke=typeof ue.name=="string"?ue.name:"";return{slug:ge||M,name:ke||ge||M}}).filter(M=>M.slug).sort((M,ue)=>M.name.localeCompare(ue.name));if(!Wl(o,E)&&!ce)return n.jsx(ki,{icon:zi,title:"No editable content",description:"This project doesn't expose any Deco pages, sections, or apps."});const te={pages:X.length,sections:V.length,apps:j.length,posts:le.posts.length,authors:le.authors.length,categories:le.categories.length},oe=new Set(X.map(M=>Ti(M.path))),de=new Set(X.map(M=>M.name)),be=new Set(V.map(M=>M.name)),ve=async M=>{const ue=o[M.key];if(!ue)return;const ge=em(o,M.key),ke=tm(o,M.key,Math.max(0,ge-1)),Je=b0(ue.sections,ke);if(Je)try{await A.mutateAsync({blockKey:M.key,data:{...ue,sections:Je}}),he.success(`Variant added to "${M.name}"`),h({collection:"pages",key:M.key,path:M.path})}catch(mt){he.error(mt instanceof Error?mt.message:"Could not add variant")}},we=()=>{z(void 0),F({mode:"create",sourceKey:null,initialName:"My new page",initialPath:"/example"})},De=M=>{z(void 0),F({mode:"duplicate",sourceKey:M.key,initialName:Rd(de,M.name),initialPath:qw(oe,M.path)})},Be=M=>{z(void 0),F({mode:"rename",sourceKey:M.key,initialName:M.name,initialPath:M.path})},Pe=async M=>{if(!B)return;const{mode:ue,sourceKey:ge}=B;try{if(ue==="create"){const ke=Xw(M.name,M.path),Je=Zw(o,M.name);await A.mutateAsync({blockKey:Je,data:ke}),he.success(`Created "${M.name}"`),h({collection:"pages",key:Je,path:M.path})}else if(ue==="duplicate"&&ge){const ke=o[ge];if(!ke)throw new Error("Source page not found");const{key:Je,data:mt}=Yw({source:ke,pages:X,newName:M.name,newPath:M.path});await A.mutateAsync({blockKey:Je,data:mt}),he.success(`Duplicated as "${M.name}"`),h({collection:"pages",key:Je,path:M.path})}else if(ue==="rename"&&ge){const ke=o[ge];if(!ke)throw new Error("Page not found");const Je={...ke,name:M.name,path:M.path};await A.mutateAsync({blockKey:ge,data:Je}),he.success("Page updated"),c?.collection==="pages"&&c.key===ge&&h({collection:"pages",key:ge,path:M.path})}F(null)}catch(ke){z(ke instanceof Error?ke.message:"Save failed")}},Fe=({path:M})=>{if(!B)return null;const ue=Ti(M);return(B.mode==="rename"?Ti(B.initialPath):null)!==ue&&oe.has(ue)?`A page with path "${M}" already exists.`:null},xe=async(M,ue,ge)=>{await A.mutateAsync({blockKey:ue,data:{...ge,name:ue,__resolveType:M}}),he.success(`Created section "${ue}"`),h({collection:"sections",key:ue})},ye=S2((M,ue)=>A.mutate({blockKey:M,data:ue})),Ie=async M=>{const ue=o[M.key];if(!ue){he.error("Section not found.");return}const ge=Gw(o,M.key),ke=Rd(be,M.name),Je={...ue,name:ke};try{await A.mutateAsync({blockKey:ge,data:Je}),he.success(`Duplicated "${M.name}"`),h({collection:"sections",key:ge})}catch(mt){he.error(mt instanceof Error?mt.message:"Duplicate failed")}},Le=async M=>{if(!W)return;const ue=o[W];if(!ue){he.error("Section not found.");return}try{await A.mutateAsync({blockKey:W,data:{...ue,name:M}}),he.success("Section renamed"),q(null)}catch(ge){he.error(ge instanceof Error?ge.message:"Rename failed")}},qe=async M=>{const ue=Pd(o,M),ge=Ho(ue,M,uC(M));try{await L.mutateAsync({blockKey:ue,data:ge}),he.success(`Created ${En[M]}`),h({collection:M,key:ue})}catch(ke){he.error(ke instanceof Error?ke.message:"Could not create")}},st=async M=>{const ue=o[M.key];if(!ue){he.error("Record not found.");return}const ge=Pd(o,M.kind),ke=M.kind==="posts"?"title":"name",Je={...structuredClone(Sa(ue,M.kind)),[ke]:`${M.label} (copy)`};try{await L.mutateAsync({blockKey:ge,data:Ho(ge,M.kind,Je)}),he.success(`Duplicated "${M.label}"`),h({collection:M.kind,key:ge})}catch(mt){he.error(mt instanceof Error?mt.message:"Duplicate failed")}},ct=M=>{w(ue=>{const ge=new Set(ue);return ge.has(M)?ge.delete(M):ge.add(M),ge})},Se=M=>{d("posts"),N("posts"),h(null),f(null),p(""),_(M),x(null),y("date-desc"),w(new Set)},pe=async(M,ue)=>{const ge=[...S];let ke=0;for(const Je of ge){const mt=o[Je],Vs=Sa(mt,"posts"),tn=M==="add"?dC(Vs,ue):hC(Vs,ue);tn!==Vs&&(await L.mutateAsync({blockKey:Je,data:Ho(Je,"posts",tn)}),ke+=1)}return ke},$e=async(M,ue)=>{const ge=S.size;try{const ke=await pe(M,ue),Je=M==="add"?"Added to":"Moved",mt=ge-ke;he.success(`${Je} ${ke} ${ke===1?"post":"posts"}`+(mt>0?` (${mt} already set)`:"")),w(new Set),$(null)}catch(ke){he.error(ke instanceof Error?ke.message:"Bulk update failed")}},Ge=async()=>{if(K)try{if(K.kind==="blog-bulk"){for(const ke of K.keys)await P.mutateAsync({blockKey:ke});he.success(`Deleted ${K.count} ${K.count===1?"post":"posts"}`),c&&c.collection!=="available-section"&&K.keys.includes(c.key)&&h(null),w(new Set),Z(null);return}const{kind:M,key:ue,label:ge}=K;M==="blog"?await P.mutateAsync({blockKey:ue}):await O.mutateAsync({blockKey:ue}),he.success(`Deleted "${ge}"`),c&&c.collection!=="available-section"&&c.key===ue&&h(null),Z(null)}catch(M){he.error(M instanceof Error?M.message:"Delete failed")}},He=O.isPending||P.isPending,Ye=K?.kind==="blog"?En[K.blogKind]:K?.kind==="blog-bulk"?`${K.count} ${K.count===1?"post":"posts"}`:K?.kind??"item";return n.jsxs("div",{className:"flex h-full w-full",children:[n.jsx(OC,{active:l,counts:te,showBlog:ce,onSelect:M=>{d(M),h(null),f(null)}}),l!=="seo"&&l!=="site"&&l!=="calendar"&&n.jsx(BC,{activeCollection:l,pages:X,sections:V,availableSections:se,appCatalog:j,appCatalogLoading:I,blogEntries:fe,decofile:o,searchQuery:m,onSearchChange:p,postCategoryFilter:g,postAuthorFilter:b,postSort:v,onPostCategoryFilterChange:M=>{_(M),w(new Set)},onPostAuthorFilterChange:M=>{x(M),w(new Set)},onPostSortChange:y,selectedPostKeys:S,onTogglePostSelect:ct,onSelectAllPosts:M=>w(new Set(M)),onClearPostSelection:()=>w(new Set),onBulkUpdateCategory:()=>$({count:S.size}),onBulkDeletePosts:()=>Z({kind:"blog-bulk",keys:[...S],count:S.size}),selection:c,onSelect:M=>{h(M),f(null)},onCreate:()=>{l==="pages"?we():Tn(l)&&qe(l)},onDuplicatePage:De,onRenamePage:Be,onAddPageVariant:ve,onDeletePage:M=>Z({kind:"page",key:M.key,label:M.name}),onEditPageSeo:M=>{h({collection:"pages",key:M.key,path:M.path}),f(M.key)},onViewPageJson:M=>G(M.key),onDuplicateSection:Ie,onRenameSection:M=>q(M.key),onDeleteSection:M=>Z({kind:"section",key:M.key,label:M.name}),onDuplicateBlog:st,onDeleteBlog:M=>Z({kind:"blog",blogKind:M.kind,key:M.key,label:M.label})}),n.jsx("div",{className:"flex-1 min-w-0",children:n.jsx(D.Suspense,{fallback:n.jsx("div",{className:"h-full flex items-center justify-center",children:n.jsx(Oe,{size:20,className:"animate-spin text-muted-foreground"})}),children:l==="calendar"?n.jsx(EC,{decofile:o}):l==="site"?ee?n.jsx(Id,{orgSlug:t,virtualMcpId:e,branch:s,blockKey:ee.key,block:o[ee.key],decofile:o,meta:E,title:"Site",excludeFields:["seo"],schemaPending:k(ee.resolveType,["seo"]),previewBaseUrl:i},`site:${ee.key}`):n.jsx(ki,{title:"Site settings not found",description:"This project doesn't have a site app block (site/apps/site.ts)."}):l==="seo"?n.jsx(NC,{orgSlug:t,virtualMcpId:e,branch:s,decofile:o,meta:E,target:{kind:"site"},previewBaseUrl:i}):l==="sections"?n.jsx(LC,{selection:c?.collection==="sections"||c?.collection==="available-section"?c:null,orgSlug:t,virtualMcpId:e,branch:s,previewUrl:i,meta:E,decofile:o,isCreating:A.isPending,onCreateAvailable:xe,onSaveReferencedBlock:ye}):c&&c.collection!=="available-section"?c.collection==="apps"?n.jsx(Id,{orgSlug:t,virtualMcpId:e,branch:s,blockKey:c.key,block:o[c.key],decofile:o,meta:E,previewBaseUrl:i,schemaPending:k(typeof o[c.key]?.__resolveType=="string"?String(o[c.key].__resolveType):void 0)},`app:${c.key}`):c.collection==="posts"?n.jsx(wC,{orgSlug:t,virtualMcpId:e,branch:s,blockKey:c.key,block:o[c.key],decofile:o,meta:E,previewBaseUrl:i},`post:${c.key}`):c.collection==="categories"?n.jsx(kC,{orgSlug:t,virtualMcpId:e,branch:s,blockKey:c.key,block:o[c.key],decofile:o,meta:E,onManagePosts:Se},`category:${c.key}`):c.collection==="authors"?n.jsx(CC,{orgSlug:t,virtualMcpId:e,branch:s,kind:"authors",blockKey:c.key,block:o[c.key]},`authors:${c.key}`):n.jsx(jC,{orgSlug:t,virtualMcpId:e,branch:s,previewReady:!0,previewUrl:i??void 0,currentPath:c.collection==="pages"?c.path:"/",activePageBlockKey:c.collection==="pages"?c.key:null,activeGlobalBlockKey:c.collection==="sections"?c.key:null,initialEditSeo:c.collection==="pages"&&u===c.key,onExitSeo:()=>f(null)},c.collection==="pages"?`page:${c.key}`:`section:${c.key}`):n.jsx(ki,{title:`Select ${Tn(l)?`a ${En[l]}`:l==="pages"?"a page":l==="apps"?"an app":"a section"} to edit`,description:l==="apps"?"Browse all apps and select an installed one to edit its settings.":'Pick an item from the list, or click "+" to create one.'})})}),B&&n.jsx(sC,{open:!!B,mode:B.mode,initialName:B.initialName,initialPath:B.initialPath,isPending:A.isPending,error:H,validate:Fe,onSubmit:Pe,onOpenChange:M=>{M||(F(null),z(void 0))}}),W&&n.jsx(iC,{open:!!W,blockKey:W,initialName:V.find(M=>M.key===W)?.name??W,isPending:A.isPending,onSubmit:Le,onOpenChange:M=>{M||q(null)}}),Y&&n.jsx(SC,{open:!!Y,onOpenChange:M=>{M||G(null)},pageKey:Y,decofile:o}),Q&&n.jsx(YC,{count:Q.count,categories:J,isPending:L.isPending,onApply:(M,ue)=>{$e(M,ue)},onOpenChange:M=>{!M&&!L.isPending&&$(null)}}),n.jsx(jr,{open:!!K,onOpenChange:M=>{!M&&!He&&Z(null)},children:n.jsxs(Nr,{children:[n.jsxs(Er,{children:[n.jsx(Tr,{children:`Delete ${Ye}?`}),n.jsx(Ar,{children:K?.kind==="section"?`"${K.label}" will be removed. Pages that still reference it will lose this section.`:K?.kind==="blog-bulk"?`${K.count} ${K.count===1?"post":"posts"} will be removed permanently. This can't be undone.`:K?`"${K.label}" will be removed permanently. This can't be undone.`:null})]}),n.jsxs(Rr,{children:[n.jsx(Pr,{disabled:He,children:"Cancel"}),n.jsx(Dr,{onClick:M=>{M.preventDefault(),Ge()},disabled:He,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:He?n.jsxs(n.Fragment,{children:[n.jsx(Oe,{size:14,className:"animate-spin"}),"Deleting…"]}):"Delete"})]})]})})]})}function LC(t){const e=U.c(30),{selection:s,orgSlug:i,virtualMcpId:r,branch:o,previewUrl:a,meta:l,decofile:d,isCreating:c,onCreateAvailable:h,onSaveReferencedBlock:u}=t;if(!s){let p;return e[0]===Symbol.for("react.memo_cache_sentinel")?(p=n.jsx(ki,{title:"Select a section to edit",description:"Pick a saved section to edit it, or an available one to customize and save as global."}),e[0]=p):p=e[0],p}if(s.collection==="available-section"){const p=`available:${s.resolveType}`,g=s.resolveType,_=s.title;let b;e[1]!==s.title?(b=b2(s.title),e[1]=s.title,e[2]=b):b=e[2];let x;e[3]!==h||e[4]!==s.resolveType?(x=(y,S)=>h(s.resolveType,y,S),e[3]=h,e[4]=s.resolveType,e[5]=x):x=e[5];let v;return e[6]!==o||e[7]!==d||e[8]!==c||e[9]!==l||e[10]!==u||e[11]!==i||e[12]!==a||e[13]!==s.resolveType||e[14]!==s.title||e[15]!==p||e[16]!==b||e[17]!==x||e[18]!==r?(v=n.jsx(Uw,{orgSlug:i,virtualMcpId:r,branch:o,previewUrl:a,meta:l,decofile:d,resolveType:g,title:_,defaultBlockId:b,isCreating:c,onCreate:x,onSaveReferencedBlock:u},p),e[6]=o,e[7]=d,e[8]=c,e[9]=l,e[10]=u,e[11]=i,e[12]=a,e[13]=s.resolveType,e[14]=s.title,e[15]=p,e[16]=b,e[17]=x,e[18]=r,e[19]=v):v=e[19],v}const f=`saved:${s.key}`;let m;return e[20]!==o||e[21]!==d||e[22]!==l||e[23]!==u||e[24]!==i||e[25]!==a||e[26]!==s.key||e[27]!==f||e[28]!==r?(m=n.jsx(Kw,{orgSlug:i,virtualMcpId:r,branch:o,previewUrl:a,meta:l,decofile:d,blockKey:s.key,onSaveReferencedBlock:u},f),e[20]=o,e[21]=d,e[22]=l,e[23]=u,e[24]=i,e[25]=a,e[26]=s.key,e[27]=f,e[28]=r,e[29]=m):m=e[29],m}function Bd(t){const e=U.c(8),{icon:s,label:i,className:r}=t;let o;e[0]!==r?(o=ae("flex items-center gap-1.5 px-2.5 pb-1 pt-1 text-xs font-medium text-muted-foreground/70",r),e[0]=r,e[1]=o):o=e[1];let a;e[2]!==s?(a=n.jsx(s,{size:13,className:"shrink-0"}),e[2]=s,e[3]=a):a=e[3];let l;return e[4]!==i||e[5]!==o||e[6]!==a?(l=n.jsxs("div",{className:o,children:[a,i]}),e[4]=i,e[5]=o,e[6]=a,e[7]=l):l=e[7],l}function OC(t){const e=U.c(37),{active:s,counts:i,showBlog:r,onSelect:o}=t;let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx("div",{className:"px-3 h-12 flex items-center border-b shrink-0",children:n.jsx("span",{className:"text-sm font-medium",children:"Content"})}),e[0]=a):a=e[0];const l=s==="pages";let d;e[1]!==i.pages||e[2]!==o||e[3]!==l?(d=n.jsx(Ss,{id:"pages",icon:Ni,label:"Pages",count:i.pages,active:l,onSelect:o}),e[1]=i.pages,e[2]=o,e[3]=l,e[4]=d):d=e[4];const c=s==="sections";let h;e[5]!==i.sections||e[6]!==o||e[7]!==c?(h=n.jsx(Ss,{id:"sections",icon:si,label:"Sections",count:i.sections,active:c,onSelect:o}),e[5]=i.sections,e[6]=o,e[7]=c,e[8]=h):h=e[8];const u=s==="apps";let f;e[9]!==i.apps||e[10]!==o||e[11]!==u?(f=n.jsx(Ss,{id:"apps",icon:Vu,label:"Apps",count:i.apps,active:u,onSelect:o}),e[9]=i.apps,e[10]=o,e[11]=u,e[12]=f):f=e[12];const m=s==="calendar";let p;e[13]!==o||e[14]!==m?(p=n.jsx(Ss,{id:"calendar",icon:Eu,label:"Calendar",active:m,onSelect:o}),e[13]=o,e[14]=m,e[15]=p):p=e[15];let g;e[16]!==s||e[17]!==i.authors||e[18]!==i.categories||e[19]!==i.posts||e[20]!==o||e[21]!==r?(g=r&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"mt-3 flex items-center gap-1.5 px-2.5 pb-1 pt-1 text-xs font-medium text-muted-foreground/70",children:[n.jsx(pa,{size:13,className:"shrink-0"}),"Blog"]}),n.jsx(Ss,{id:"posts",icon:Ri,label:"Posts",count:i.posts,active:s==="posts",onSelect:o}),n.jsx(Ss,{id:"authors",icon:co,label:"Authors",count:i.authors,active:s==="authors",onSelect:o}),n.jsx(Ss,{id:"categories",icon:ro,label:"Categories",count:i.categories,active:s==="categories",onSelect:o})]}),e[16]=s,e[17]=i.authors,e[18]=i.categories,e[19]=i.posts,e[20]=o,e[21]=r,e[22]=g):g=e[22];const _=s==="site";let b;e[23]!==o||e[24]!==_?(b=n.jsx(Ss,{id:"site",icon:z_,label:"Site",active:_,onSelect:o}),e[23]=o,e[24]=_,e[25]=b):b=e[25];const x=s==="seo";let v;e[26]!==o||e[27]!==x?(v=n.jsx(Ss,{id:"seo",icon:kr,label:"SEO",active:x,onSelect:o}),e[26]=o,e[27]=x,e[28]=v):v=e[28];let y;return e[29]!==g||e[30]!==b||e[31]!==v||e[32]!==d||e[33]!==h||e[34]!==f||e[35]!==p?(y=n.jsxs("div",{className:"w-[208px] shrink-0 border-r flex flex-col",children:[a,n.jsxs("nav",{className:"flex flex-col p-1.5 gap-0.5",children:[d,h,f,p,g,b,v]})]}),e[29]=g,e[30]=b,e[31]=v,e[32]=d,e[33]=h,e[34]=f,e[35]=p,e[36]=y):y=e[36],y}function Ss(t){const e=U.c(18),{id:s,icon:i,label:r,count:o,active:a,onSelect:l}=t;let d;e[0]!==s||e[1]!==l?(d=()=>l(s),e[0]=s,e[1]=l,e[2]=d):d=e[2];const c=a?"bg-accent text-accent-foreground":"text-muted-foreground hover:bg-muted hover:text-foreground";let h;e[3]!==c?(h=ae("flex w-full items-center gap-2 rounded-md px-2.5 py-1.5 text-left text-sm transition-colors cursor-pointer",c),e[3]=c,e[4]=h):h=e[4];let u;e[5]!==i?(u=n.jsx(i,{size:16,className:"shrink-0"}),e[5]=i,e[6]=u):u=e[6];let f;e[7]!==r?(f=n.jsx("span",{className:"flex-1 truncate",children:r}),e[7]=r,e[8]=f):f=e[8];let m;e[9]!==a||e[10]!==o?(m=o!==void 0&&n.jsx("span",{className:ae("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]!==d||e[13]!==h||e[14]!==u||e[15]!==f||e[16]!==m?(p=n.jsxs("button",{type:"button",onClick:d,className:h,children:[u,f,m]}),e[12]=d,e[13]=h,e[14]=u,e[15]=f,e[16]=m,e[17]=p):p=e[17],p}function BC(t){const e=U.c(75),{activeCollection:s,pages:i,sections:r,availableSections:o,appCatalog:a,appCatalogLoading:l,blogEntries:d,decofile:c,searchQuery:h,onSearchChange:u,postCategoryFilter:f,postAuthorFilter:m,postSort:p,onPostCategoryFilterChange:g,onPostAuthorFilterChange:_,onPostSortChange:b,selectedPostKeys:x,onTogglePostSelect:v,onSelectAllPosts:y,onClearPostSelection:S,onBulkUpdateCategory:w,onBulkDeletePosts:C,selection:N,onSelect:E,onCreate:R,onDuplicatePage:T,onRenamePage:k,onAddPageVariant:j,onDeletePage:I,onEditPageSeo:A,onViewPageJson:O,onDuplicateSection:L,onRenameSection:P,onDeleteSection:B,onDuplicateBlog:F,onDeleteBlog:H}=t;let z,W,q,K,Z,Y,G;if(e[0]!==s||e[1]!==a||e[2]!==l||e[3]!==o||e[4]!==d||e[5]!==c||e[6]!==j||e[7]!==C||e[8]!==w||e[9]!==S||e[10]!==R||e[11]!==H||e[12]!==I||e[13]!==B||e[14]!==F||e[15]!==T||e[16]!==L||e[17]!==A||e[18]!==_||e[19]!==g||e[20]!==b||e[21]!==k||e[22]!==P||e[23]!==u||e[24]!==E||e[25]!==y||e[26]!==v||e[27]!==O||e[28]!==i||e[29]!==m||e[30]!==f||e[31]!==p||e[32]!==h||e[33]!==r||e[34]!==x||e[35]!==N){const V=h.toLowerCase(),se=i.filter(M=>!V||M.name.toLowerCase().includes(V)||M.path.toLowerCase().includes(V)),ee=r.filter(M=>!V||M.name.toLowerCase().includes(V)||M.key.toLowerCase().includes(V)||M.resolveType.toLowerCase().includes(V)),le=o.filter(M=>!V||M.title.toLowerCase().includes(V)||M.resolveType.toLowerCase().includes(V)||(M.description?.toLowerCase().includes(V)??!1)),ce=AC(ee),fe=a.filter(M=>!V||M.title.toLowerCase().includes(V)||M.app.toLowerCase().includes(V)||M.vendor.toLowerCase().includes(V)||M.category.toLowerCase().includes(V)),J=d.filter(M=>!V||M.label.toLowerCase().includes(V)||M.subtitle.toLowerCase().includes(V)),te=s==="posts",oe=FC,de=te?cC(c):[],be=new Map,ve=new Map;for(const M of de){for(const ue of M.categorySlugs)be.set(ue,(be.get(ue)??0)+1);for(const ue of M.authorEmails)ve.set(ue,(ve.get(ue)??0)+1)}const we=(te?Kr(c,"categories"):[]).map(M=>{const{key:ue,payload:ge}=M,ke=oe(ge.slug)||ue;return{slug:ke,name:oe(ge.name)||oe(ge.slug)||ue,count:be.get(ke)??0}}).filter(zC),De=(te?Kr(c,"authors"):[]).map(M=>{const{key:ue,payload:ge}=M,ke=oe(ge.email);return{email:ke,name:oe(ge.name)||oe(ge.email)||ue,count:ve.get(ke)??0}}).filter($C);let Be;e[43]!==f?(Be=M=>!f||M.categorySlugs.includes(f),e[43]=f,e[44]=Be):Be=e[44];let Pe;e[45]!==m?(Pe=M=>!m||M.authorEmails.includes(m),e[45]=m,e[46]=Pe):Pe=e[46];let Fe;e[47]!==p?(Fe=(M,ue)=>{if(p==="az")return M.title.localeCompare(ue.title);if(p==="za")return ue.title.localeCompare(M.title);const ge=M.date.localeCompare(ue.date);return p==="date-asc"?ge:-ge},e[47]=p,e[48]=Fe):Fe=e[48];const xe=de.filter(M=>!V||M.title.toLowerCase().includes(V)||M.slug.toLowerCase().includes(V)).filter(Be).filter(Pe).sort(Fe),ye=x.size,Ie=xe.map(MC),Le=Ie.length>0&&Ie.every(M=>x.has(M)),qe=ye>0,st=()=>{Le?S():y(Ie)},ct=`Search ${s}…`,Se=Tn(s)?`Create new ${En[s]}`:"Create new page",pe=s!=="apps"&&s!=="sections";Z="w-[300px] shrink-0 border-r flex flex-col min-h-0";let $e;e[49]===Symbol.for("react.memo_cache_sentinel")?($e=n.jsx(Wu,{size:14,className:"shrink-0 text-muted-foreground","aria-hidden":!0}),e[49]=$e):$e=e[49];let Ge;e[50]!==u?(Ge=M=>u(M.target.value),e[50]=u,e[51]=Ge):Ge=e[51];let He;e[52]!==ct||e[53]!==h||e[54]!==Ge?(He=n.jsxs("div",{className:"flex flex-1 items-center gap-2 pl-1",children:[$e,n.jsx("input",{type:"text",value:h,onChange:Ge,placeholder:ct,"aria-label":ct,className:"w-full bg-transparent text-sm outline-none placeholder:text-muted-foreground"})]}),e[52]=ct,e[53]=h,e[54]=Ge,e[55]=He):He=e[55];let Ye;e[56]!==Se||e[57]!==R||e[58]!==pe?(Ye=pe&&n.jsxs(Te,{children:[n.jsx(Ne,{asChild:!0,children:n.jsx(ie,{variant:"ghost",size:"icon",onClick:R,"aria-label":Se,children:n.jsx(Dt,{size:14})})}),n.jsx(Ee,{side:"bottom",children:Se})]}),e[56]=Se,e[57]=R,e[58]=pe,e[59]=Ye):Ye=e[59],e[60]!==He||e[61]!==Ye?(Y=n.jsxs("div",{className:"px-2 h-12 flex items-center gap-1 border-b shrink-0",children:[He,Ye]}),e[60]=He,e[61]=Ye,e[62]=Y):Y=e[62],G=te&&(qe?n.jsx(GC,{count:ye,allSelected:Le,onToggleSelectAll:st,onUpdateCategory:w,onDelete:C,onClear:S}):n.jsx(UC,{categories:we,authors:De,categoryFilter:f,authorFilter:m,sort:p,hasPosts:de.length>0,allSelected:Le,onToggleSelectAll:st,onCategoryFilterChange:g,onAuthorFilterChange:_,onSortChange:b})),z=Fi,K="flex-1 min-h-0 [&_[data-slot=scroll-area-viewport]>div]:!block",W="flex flex-col gap-1 p-1.5",q=s==="pages"?se.length===0?n.jsx(an,{hasItems:i.length>0,emptyLabel:"No pages yet.",emptyHint:'Click "+" to create your first page.'}):se.map(M=>{const ue=N?.collection==="pages"&&N.key===M.key,ge=em(c,M.key);return n.jsx(bi,{icon:Ni,title:M.name,subtitle:M.path,active:ue,variantCount:ge,onClick:()=>E({collection:"pages",key:M.key,path:M.path}),menu:n.jsx(lr,{onDuplicate:()=>T(M),onRename:()=>k(M),onAddVariant:()=>j(M),onEditSeo:()=>A(M),onViewJson:()=>O(M),onDelete:()=>I(M)})},M.key)}):s==="sections"?ee.length===0&&le.length===0?n.jsx(an,{hasItems:r.length>0||o.length>0,emptyLabel:"No sections yet.",emptyHint:"Save a section from a page, or start the preview dev server."}):n.jsxs(n.Fragment,{children:[ce.length>0&&n.jsxs(n.Fragment,{children:[n.jsx(Bd,{icon:si,label:"Saved sections"}),ce.map(M=>n.jsxs("div",{className:"flex flex-col gap-1",children:[n.jsx("div",{className:"px-2.5 pt-1 pb-0.5 text-[11px] font-medium uppercase tracking-wide text-muted-foreground/60",children:M.label}),M.sections.map(ue=>{const ge=N?.collection==="sections"&&N.key===ue.key;return n.jsx(bi,{icon:si,accent:"global",title:ue.name,subtitle:M.label,active:ge,onClick:()=>E({collection:"sections",key:ue.key}),menu:n.jsx(lr,{onDuplicate:()=>L(ue),onRename:()=>P(ue),onDelete:()=>B(ue)})},ue.key)})]},M.label))]}),le.length>0&&n.jsxs(n.Fragment,{children:[n.jsx(Bd,{icon:Ni,label:"Available sections",className:ae(ce.length>0&&"mt-3")}),le.map(M=>{const ue=N?.collection==="available-section"&&N.resolveType===M.resolveType,ge=M.resolveType.split("/").pop()?.replace(/\.tsx?$/,"");return n.jsx(bi,{icon:Ni,title:M.title,subtitle:ge??M.resolveType,active:ue,onClick:()=>E({collection:"available-section",resolveType:M.resolveType,title:M.title})},M.resolveType)})]})]}):s==="apps"?l?n.jsx("div",{className:"flex items-center justify-center py-8",children:n.jsx(Oe,{size:18,className:"animate-spin text-muted-foreground"})}):fe.length===0?n.jsx(an,{hasItems:a.length>0,emptyLabel:"No apps found.",emptyHint:"Try a different search term."}):fe.map(M=>{const ue=N?.collection==="apps"&&M.blockKey!==null&&N.key===M.blockKey;return n.jsx(bi,{icon:Vu,logoUrl:M.logo,title:M.title,subtitle:M.category,active:ue,trailing:M.installed?n.jsx("span",{className:"shrink-0 rounded-full bg-emerald-500/15 px-1.5 py-0.5 text-[10px] font-medium text-emerald-700 dark:text-emerald-400",children:"Installed"}):void 0,onClick:()=>{if(!M.installed||!M.blockKey){he.message(`${M.title} is not installed on this site.`);return}E({collection:"apps",key:M.blockKey})}},M.id)}):te?xe.length===0?n.jsx(an,{hasItems:de.length>0,emptyLabel:"No posts yet.",emptyHint:'Click "+" to create your first post.'}):xe.map(M=>{const ue={key:M.key,kind:"posts",label:M.title,subtitle:M.slug};return n.jsx(bi,{icon:Ri,title:M.title,subtitle:M.slug,active:N?.collection==="posts"&&N.key===M.key,selectable:!0,selectionActive:qe,selected:x.has(M.key),onToggleSelect:()=>v(M.key),onClick:()=>E({collection:"posts",key:M.key}),menu:n.jsx(lr,{onDuplicate:()=>F(ue),onDelete:()=>H(ue)})},M.key)}):J.length===0?n.jsx(an,{hasItems:d.length>0,emptyLabel:`No ${s} yet.`,emptyHint:`Click "+" to create your first ${Tn(s)?En[s]:"item"}.`}):J.map(M=>{const ue=N?.collection===M.kind&&N.key===M.key;return n.jsx(bi,{icon:M.kind==="posts"?Ri:M.kind==="authors"?co:ro,title:M.label,subtitle:M.subtitle,active:ue,onClick:()=>E({collection:M.kind,key:M.key}),menu:n.jsx(lr,{onDuplicate:()=>F(M),onDelete:()=>H(M)})},M.key)}),e[0]=s,e[1]=a,e[2]=l,e[3]=o,e[4]=d,e[5]=c,e[6]=j,e[7]=C,e[8]=w,e[9]=S,e[10]=R,e[11]=H,e[12]=I,e[13]=B,e[14]=F,e[15]=T,e[16]=L,e[17]=A,e[18]=_,e[19]=g,e[20]=b,e[21]=k,e[22]=P,e[23]=u,e[24]=E,e[25]=y,e[26]=v,e[27]=O,e[28]=i,e[29]=m,e[30]=f,e[31]=p,e[32]=h,e[33]=r,e[34]=x,e[35]=N,e[36]=z,e[37]=W,e[38]=q,e[39]=K,e[40]=Z,e[41]=Y,e[42]=G}else z=e[36],W=e[37],q=e[38],K=e[39],Z=e[40],Y=e[41],G=e[42];let Q;e[63]!==W||e[64]!==q?(Q=n.jsx("div",{className:W,children:q}),e[63]=W,e[64]=q,e[65]=Q):Q=e[65];let $;e[66]!==z||e[67]!==K||e[68]!==Q?($=n.jsx(z,{className:K,children:Q}),e[66]=z,e[67]=K,e[68]=Q,e[69]=$):$=e[69];let X;return e[70]!==Z||e[71]!==Y||e[72]!==G||e[73]!==$?(X=n.jsxs("div",{className:Z,children:[Y,G,$]}),e[70]=Z,e[71]=Y,e[72]=G,e[73]=$,e[74]=X):X=e[74],X}function MC(t){return t.key}function $C(t){return t.email}function zC(t){return t.slug}function FC(t){return typeof t=="string"?t:""}const xi="__all__",Dm={"date-desc":"Newest first","date-asc":"Oldest first",az:"Title A–Z",za:"Title Z–A"},HC={"date-desc":"Newest","date-asc":"Oldest",az:"A–Z",za:"Z–A"},Uo=D.forwardRef(function(e,s){const i=U.c(20);let r,o,a,l,d;i[0]!==e?({icon:r,active:o,value:d,className:a,...l}=e,i[0]=e,i[1]=r,i[2]=o,i[3]=a,i[4]=l,i[5]=d):(r=i[1],o=i[2],a=i[3],l=i[4],d=i[5]);const c=o?"text-foreground":"text-muted-foreground";let h;i[6]!==a||i[7]!==c?(h=ae("h-7 gap-1 px-1.5 text-xs",c,a),i[6]=a,i[7]=c,i[8]=h):h=i[8];let u;i[9]!==r?(u=n.jsx(r,{size:14,className:"shrink-0"}),i[9]=r,i[10]=u):u=i[10];let f;i[11]!==d?(f=d&&n.jsx("span",{className:"min-w-0 flex-1 truncate",children:d}),i[11]=d,i[12]=f):f=i[12];let m;i[13]===Symbol.for("react.memo_cache_sentinel")?(m=n.jsx(cs,{size:12,className:"shrink-0 opacity-60"}),i[13]=m):m=i[13];let p;return i[14]!==l||i[15]!==s||i[16]!==h||i[17]!==u||i[18]!==f?(p=n.jsxs(ie,{ref:s,type:"button",variant:"ghost",size:"sm",className:h,...l,children:[u,f,m]}),i[14]=l,i[15]=s,i[16]=h,i[17]=u,i[18]=f,i[19]=p):p=i[19],p});function Im(t){const e=U.c(2),{count:s}=t;let i;return e[0]!==s?(i=n.jsx("span",{className:"ml-auto pl-3 text-xs text-muted-foreground tabular-nums",children:s}),e[0]=s,e[1]=i):i=e[1],i}function UC(t){const e=U.c(64),{categories:s,authors:i,categoryFilter:r,authorFilter:o,sort:a,hasPosts:l,allSelected:d,onToggleSelectAll:c,onCategoryFilterChange:h,onAuthorFilterChange:u,onSortChange:f}=t;let m;if(e[0]!==s||e[1]!==r){let V;e[3]!==r?(V=se=>se.slug===r,e[3]=r,e[4]=V):V=e[4],m=s.find(V),e[0]=s,e[1]=r,e[2]=m}else m=e[2];const p=m;let g;if(e[5]!==o||e[6]!==i){let V;e[8]!==o?(V=se=>se.email===o,e[8]=o,e[9]=V):V=e[9],g=i.find(V),e[5]=o,e[6]=i,e[7]=g}else g=e[7];const _=g,b=!l;let x;e[10]!==d||e[11]!==c||e[12]!==b?(x=n.jsx(Lm,{checked:d,disabled:b,onToggle:c}),e[10]=d,e[11]=c,e[12]=b,e[13]=x):x=e[13];const v=!!r,y=p?.name;let S;e[14]!==v||e[15]!==y?(S=n.jsx(Vt,{asChild:!0,children:n.jsx(Uo,{icon:ro,active:v,value:y,className:"min-w-0 shrink"})}),e[14]=v,e[15]=y,e[16]=S):S=e[16];let w;e[17]===Symbol.for("react.memo_cache_sentinel")?(w=n.jsx(Co,{children:"Filter by category"}),e[17]=w):w=e[17];const C=r??xi;let N;e[18]!==h?(N=V=>h(V===xi?null:V),e[18]=h,e[19]=N):N=e[19];let E;e[20]===Symbol.for("react.memo_cache_sentinel")?(E=n.jsx(In,{value:xi,children:"All categories"}),e[20]=E):E=e[20];let R;e[21]!==s?(R=s.map(KC),e[21]=s,e[22]=R):R=e[22];let T;e[23]!==N||e[24]!==R||e[25]!==C?(T=n.jsxs(Kt,{align:"start",className:"max-h-80 w-56 overflow-y-auto",children:[w,n.jsxs(ko,{value:C,onValueChange:N,children:[E,R]})]}),e[23]=N,e[24]=R,e[25]=C,e[26]=T):T=e[26];let k;e[27]!==T||e[28]!==S?(k=n.jsxs(Wt,{children:[S,T]}),e[27]=T,e[28]=S,e[29]=k):k=e[29];const j=!!o,I=_?.name;let A;e[30]!==j||e[31]!==I?(A=n.jsx(Vt,{asChild:!0,children:n.jsx(Uo,{icon:co,active:j,value:I,className:"min-w-0 shrink"})}),e[30]=j,e[31]=I,e[32]=A):A=e[32];let O;e[33]===Symbol.for("react.memo_cache_sentinel")?(O=n.jsx(Co,{children:"Filter by author"}),e[33]=O):O=e[33];const L=o??xi;let P;e[34]!==u?(P=V=>u(V===xi?null:V),e[34]=u,e[35]=P):P=e[35];let B;e[36]===Symbol.for("react.memo_cache_sentinel")?(B=n.jsx(In,{value:xi,children:"All authors"}),e[36]=B):B=e[36];let F;e[37]!==i?(F=i.map(VC),e[37]=i,e[38]=F):F=e[38];let H;e[39]!==L||e[40]!==P||e[41]!==F?(H=n.jsxs(Kt,{align:"start",className:"max-h-80 w-56 overflow-y-auto",children:[O,n.jsxs(ko,{value:L,onValueChange:P,children:[B,F]})]}),e[39]=L,e[40]=P,e[41]=F,e[42]=H):H=e[42];let z;e[43]!==A||e[44]!==H?(z=n.jsxs(Wt,{children:[A,H]}),e[43]=A,e[44]=H,e[45]=z):z=e[45];const W=HC[a];let q;e[46]!==W?(q=n.jsx(Vt,{asChild:!0,children:n.jsx(Uo,{icon:F_,active:!0,value:W})}),e[46]=W,e[47]=q):q=e[47];let K;e[48]===Symbol.for("react.memo_cache_sentinel")?(K=n.jsx(Co,{children:"Sort by"}),e[48]=K):K=e[48];let Z;e[49]!==f?(Z=V=>f(V),e[49]=f,e[50]=Z):Z=e[50];let Y;e[51]===Symbol.for("react.memo_cache_sentinel")?(Y=Object.keys(Dm),e[51]=Y):Y=e[51];let G;e[52]===Symbol.for("react.memo_cache_sentinel")?(G=Y.map(WC),e[52]=G):G=e[52];let Q;e[53]!==a||e[54]!==Z?(Q=n.jsxs(Kt,{align:"end",className:"w-44",children:[K,n.jsx(ko,{value:a,onValueChange:Z,children:G})]}),e[53]=a,e[54]=Z,e[55]=Q):Q=e[55];let $;e[56]!==q||e[57]!==Q?($=n.jsxs(Wt,{children:[q,Q]}),e[56]=q,e[57]=Q,e[58]=$):$=e[58];let X;return e[59]!==k||e[60]!==z||e[61]!==$||e[62]!==x?(X=n.jsxs("div",{className:"flex min-w-0 items-center gap-0.5 overflow-hidden border-b px-2 py-1.5",children:[x,k,z,$]}),e[59]=k,e[60]=z,e[61]=$,e[62]=x,e[63]=X):X=e[63],X}function WC(t){return n.jsx(In,{value:t,children:Dm[t]},t)}function VC(t){return n.jsxs(In,{value:t.email,children:[n.jsx("span",{className:"min-w-0 flex-1 truncate",children:t.name}),n.jsx(Im,{count:t.count})]},t.email)}function KC(t){return n.jsxs(In,{value:t.slug,children:[n.jsx("span",{className:"min-w-0 flex-1 truncate",children:t.name}),n.jsx(Im,{count:t.count})]},t.slug)}function Lm(t){const e=U.c(12),{checked:s,disabled:i,onToggle:r}=t;let o;e[0]!==r?(o=()=>r(),e[0]=r,e[1]=o):o=e[1];const a=s?"Deselect all posts":"Select all posts";let l;e[2]!==s||e[3]!==i||e[4]!==o||e[5]!==a?(l=n.jsx(Ne,{asChild:!0,children:n.jsx("span",{className:"flex shrink-0 items-center px-1.5",onClick:qC,children:n.jsx(Ki,{checked:s,disabled:i,onCheckedChange:o,"aria-label":a})})}),e[2]=s,e[3]=i,e[4]=o,e[5]=a,e[6]=l):l=e[6];const d=s?"Deselect all":"Select all";let c;e[7]!==d?(c=n.jsx(Ee,{side:"bottom",children:d}),e[7]=d,e[8]=c):c=e[8];let h;return e[9]!==l||e[10]!==c?(h=n.jsxs(Te,{children:[l,c]}),e[9]=l,e[10]=c,e[11]=h):h=e[11],h}function qC(t){return t.stopPropagation()}function GC(t){const e=U.c(31),{count:s,allSelected:i,onToggleSelectAll:r,onUpdateCategory:o,onDelete:a,onClear:l}=t;let d;e[0]!==i||e[1]!==r?(d=n.jsx(Lm,{checked:i,onToggle:r}),e[0]=i,e[1]=r,e[2]=d):d=e[2];let c;e[3]!==s?(c=n.jsxs("span",{className:"text-xs font-medium tabular-nums",children:[s," selected"]}),e[3]=s,e[4]=c):c=e[4];let h;e[5]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx(ro,{size:14}),e[5]=h):h=e[5];let u;e[6]!==o?(u=n.jsx(Ne,{asChild:!0,children:n.jsxs(ie,{type:"button",variant:"ghost",size:"sm",className:"h-7 gap-1 px-2 text-xs",onClick:o,"aria-label":"Update category for selected posts",children:[h,"Category"]})}),e[6]=o,e[7]=u):u=e[7];let f;e[8]===Symbol.for("react.memo_cache_sentinel")?(f=n.jsx(Ee,{side:"bottom",children:"Update category"}),e[8]=f):f=e[8];let m;e[9]!==u?(m=n.jsxs(Te,{children:[u,f]}),e[9]=u,e[10]=m):m=e[10];let p;e[11]===Symbol.for("react.memo_cache_sentinel")?(p=n.jsx(es,{size:14}),e[11]=p):p=e[11];let g;e[12]!==a?(g=n.jsx(Ne,{asChild:!0,children:n.jsx(ie,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive hover:text-destructive",onClick:a,"aria-label":"Delete selected posts",children:p})}),e[12]=a,e[13]=g):g=e[13];let _;e[14]===Symbol.for("react.memo_cache_sentinel")?(_=n.jsx(Ee,{side:"bottom",children:"Delete selected"}),e[14]=_):_=e[14];let b;e[15]!==g?(b=n.jsxs(Te,{children:[g,_]}),e[15]=g,e[16]=b):b=e[16];let x;e[17]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsx(jl,{size:14}),e[17]=x):x=e[17];let v;e[18]!==l?(v=n.jsx(Ne,{asChild:!0,children:n.jsx(ie,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7",onClick:l,"aria-label":"Clear selection",children:x})}),e[18]=l,e[19]=v):v=e[19];let y;e[20]===Symbol.for("react.memo_cache_sentinel")?(y=n.jsx(Ee,{side:"bottom",children:"Clear selection"}),e[20]=y):y=e[20];let S;e[21]!==v?(S=n.jsxs(Te,{children:[v,y]}),e[21]=v,e[22]=S):S=e[22];let w;e[23]!==b||e[24]!==S||e[25]!==m?(w=n.jsxs("div",{className:"ml-auto flex items-center gap-0.5",children:[m,b,S]}),e[23]=b,e[24]=S,e[25]=m,e[26]=w):w=e[26];let C;return e[27]!==d||e[28]!==w||e[29]!==c?(C=n.jsxs("div",{className:"flex items-center gap-0.5 border-b bg-accent/40 px-2 py-1.5",children:[d,c,w]}),e[27]=d,e[28]=w,e[29]=c,e[30]=C):C=e[30],C}function YC(t){const e=U.c(48),{count:s,categories:i,isPending:r,onApply:o,onOpenChange:a}=t,[l,d]=D.useState(i[0]?.slug??""),[c,h]=D.useState("add");let u;if(e[0]!==i||e[1]!==l){let P;e[3]!==l?(P=B=>B.slug===l,e[3]=l,e[4]=P):P=e[4],u=i.find(P),e[0]=i,e[1]=l,e[2]=u}else u=e[2];const f=u;let m;e[5]===Symbol.for("react.memo_cache_sentinel")?(m=n.jsx(ss,{children:"Update category"}),e[5]=m):m=e[5];const p=s===1?"post":"posts";let g;e[6]!==s||e[7]!==p?(g=n.jsxs(ts,{children:[m,n.jsxs(Wi,{children:["Choose a category to apply to ",s," ",p,"."]})]}),e[6]=s,e[7]=p,e[8]=g):g=e[8];let _;e[9]===Symbol.for("react.memo_cache_sentinel")?(_=n.jsx(Ve,{children:"Category"}),e[9]=_):_=e[9];let b;e[10]!==i||e[11]!==l?(b=n.jsxs("div",{className:"space-y-2",children:[_,i.length===0?n.jsx("p",{className:"text-sm text-muted-foreground",children:"No categories yet — create one in the Categories collection."}):n.jsxs(Nt,{value:l,onValueChange:d,children:[n.jsx(kt,{className:"w-full",children:n.jsx(Rt,{placeholder:"Select a category"})}),n.jsx(jt,{children:i.map(XC)})]})]}),e[10]=i,e[11]=l,e[12]=b):b=e[12];let x;e[13]===Symbol.for("react.memo_cache_sentinel")?(x=P=>h(P),e[13]=x):x=e[13];let v;e[14]===Symbol.for("react.memo_cache_sentinel")?(v=n.jsx(fd,{value:"add",id:"cat-mode-add",className:"mt-0.5"}),e[14]=v):v=e[14];let y;e[15]===Symbol.for("react.memo_cache_sentinel")?(y=n.jsxs(Ve,{htmlFor:"cat-mode-add",className:"flex cursor-pointer items-start gap-2.5 rounded-lg border p-3",children:[v,n.jsxs("span",{className:"space-y-0.5",children:[n.jsx("span",{className:"block text-sm font-medium",children:"Add category"}),n.jsx("span",{className:"block text-xs text-muted-foreground",children:"Keep existing categories and add this one."})]})]}),e[15]=y):y=e[15];let S;e[16]===Symbol.for("react.memo_cache_sentinel")?(S=n.jsx(fd,{value:"replace",id:"cat-mode-replace",className:"mt-0.5"}),e[16]=S):S=e[16];let w;e[17]===Symbol.for("react.memo_cache_sentinel")?(w=n.jsxs(Ve,{htmlFor:"cat-mode-replace",className:"flex cursor-pointer items-start gap-2.5 rounded-lg border p-3",children:[S,n.jsxs("span",{className:"space-y-0.5",children:[n.jsx("span",{className:"block text-sm font-medium",children:"Replace category"}),n.jsx("span",{className:"block text-xs text-muted-foreground",children:"Remove all current categories and set only this one."})]})]}),e[17]=w):w=e[17];let C;e[18]!==c?(C=n.jsxs(a2,{value:c,onValueChange:x,className:"gap-2",children:[y,w]}),e[18]=c,e[19]=C):C=e[19];let N;e[20]!==C||e[21]!==b?(N=n.jsxs("div",{className:"space-y-4 py-2",children:[b,C]}),e[20]=C,e[21]=b,e[22]=N):N=e[22];let E;e[23]!==a?(E=()=>a(!1),e[23]=a,e[24]=E):E=e[24];let R;e[25]!==r||e[26]!==E?(R=n.jsx(ie,{type:"button",variant:"outline",onClick:E,disabled:r,children:"Cancel"}),e[25]=r,e[26]=E,e[27]=R):R=e[27];const T=!f||r;let k;e[28]!==c||e[29]!==o||e[30]!==f?(k=()=>f&&o(c,{name:f.name,slug:f.slug}),e[28]=c,e[29]=o,e[30]=f,e[31]=k):k=e[31];let j;e[32]!==r?(j=r?n.jsxs(n.Fragment,{children:[n.jsx(Oe,{size:14,className:"animate-spin"}),"Updating…"]}):"Apply",e[32]=r,e[33]=j):j=e[33];let I;e[34]!==T||e[35]!==k||e[36]!==j?(I=n.jsx(ie,{type:"button",disabled:T,onClick:k,children:j}),e[34]=T,e[35]=k,e[36]=j,e[37]=I):I=e[37];let A;e[38]!==R||e[39]!==I?(A=n.jsxs(Ws,{children:[R,I]}),e[38]=R,e[39]=I,e[40]=A):A=e[40];let O;e[41]!==N||e[42]!==A||e[43]!==g?(O=n.jsxs(Mt,{className:"sm:max-w-md",children:[g,N,A]}),e[41]=N,e[42]=A,e[43]=g,e[44]=O):O=e[44];let L;return e[45]!==a||e[46]!==O?(L=n.jsx(Bt,{open:!0,onOpenChange:a,children:O}),e[45]=a,e[46]=O,e[47]=L):L=e[47],L}function XC(t){return n.jsx(tt,{value:t.slug,children:n.jsx("span",{className:"truncate",children:t.name})},t.slug)}function bi(t){const e=U.c(37),{icon:s,logoUrl:i,title:r,subtitle:o,active:a,accent:l,variantCount:d,trailing:c,selectable:h,selectionActive:u,selected:f,onToggleSelect:m,onClick:p,menu:g}=t,_=l==="global";let b;e[0]!==s||e[1]!==a||e[2]!==_||e[3]!==i||e[4]!==d?(b=d&&d>1?n.jsx("span",{className:"flex size-8 shrink-0 items-center justify-center",children:n.jsxs(Te,{children:[n.jsx(Ne,{asChild:!0,children:n.jsx(s,{size:16,className:"shrink-0",style:{color:Ca}})}),n.jsxs(Ee,{side:"right",children:[d," variants"]})]})}):i?n.jsx("img",{src:i,alt:"",className:"size-8 shrink-0 rounded-lg object-cover bg-muted"}):n.jsx("span",{className:ae("flex size-8 shrink-0 items-center justify-center rounded-lg",_?"bg-global-section/15":"bg-muted"),children:n.jsx(s,{size:16,className:ae("shrink-0",!_&&(a?"text-accent-foreground":"text-muted-foreground")),style:_?{color:lf}:void 0})}),e[0]=s,e[1]=a,e[2]=_,e[3]=i,e[4]=d,e[5]=b):b=e[5];const x=b,v=a?_?"bg-global-section/15 text-global-section-fg dark:text-global-section-fg-dark":"bg-accent text-accent-foreground":_?"hover:bg-global-section/10":"hover:bg-muted";let y;e[6]!==v?(y=ae("group relative flex min-w-0 items-center rounded-md transition-colors",v),e[6]=v,e[7]=y):y=e[7];let S;e[8]!==m||e[9]!==h||e[10]!==f||e[11]!==u||e[12]!==r?(S=h&&n.jsx("span",{className:ae("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:JC,children:n.jsx(Ki,{checked:f,onCheckedChange:()=>m?.(),"aria-label":`Select ${r}`})}),e[8]=m,e[9]=h,e[10]=f,e[11]=u,e[12]=r,e[13]=S):S=e[13];let w;e[14]!==r?(w=n.jsx("span",{className:"block truncate text-sm font-medium",children:r}),e[14]=r,e[15]=w):w=e[15];const C=a?"text-accent-foreground/70":"text-muted-foreground";let N;e[16]!==C?(N=ae("block truncate text-xs",C),e[16]=C,e[17]=N):N=e[17];let E;e[18]!==o||e[19]!==N?(E=n.jsx("span",{className:N,children:o}),e[18]=o,e[19]=N,e[20]=E):E=e[20];let R;e[21]!==w||e[22]!==E?(R=n.jsxs("span",{className:"min-w-0 flex-1",children:[w,E]}),e[21]=w,e[22]=E,e[23]=R):R=e[23];let T;e[24]!==p||e[25]!==x||e[26]!==R||e[27]!==c?(T=n.jsxs("button",{type:"button",onClick:p,className:"flex min-w-0 flex-1 items-center gap-2.5 rounded-md px-2.5 py-2 text-left cursor-pointer",children:[x,R,c]}),e[24]=p,e[25]=x,e[26]=R,e[27]=c,e[28]=T):T=e[28];let k;e[29]!==a||e[30]!==g?(k=g&&n.jsx("div",{className:ae("pr-1 opacity-0 transition-opacity group-hover:opacity-100",a&&"opacity-100"),children:g}),e[29]=a,e[30]=g,e[31]=k):k=e[31];let j;return e[32]!==T||e[33]!==k||e[34]!==y||e[35]!==S?(j=n.jsxs("div",{className:y,children:[S,T,k]}),e[32]=T,e[33]=k,e[34]=y,e[35]=S,e[36]=j):j=e[36],j}function JC(t){return t.stopPropagation()}function lr(t){const e=U.c(21),{onDuplicate:s,onRename:i,onAddVariant:r,onEditSeo:o,onViewJson:a,onDelete:l}=t;let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx(Vt,{asChild:!0,children:n.jsx("button",{type:"button","aria-label":"More actions",className:"flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:bg-background hover:text-foreground cursor-pointer",onClick:ZC,children:n.jsx(Hi,{size:14})})}),e[0]=d):d=e[0];let c;e[1]!==i?(c=i&&n.jsxs(Ue,{onClick:i,children:[n.jsx(Cl,{size:14}),"Rename"]}),e[1]=i,e[2]=c):c=e[2];let h;e[3]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx(as,{size:14}),e[3]=h):h=e[3];let u;e[4]!==s?(u=n.jsxs(Ue,{onClick:s,children:[h,"Duplicate"]}),e[4]=s,e[5]=u):u=e[5];let f;e[6]!==r?(f=r&&n.jsxs(n.Fragment,{children:[n.jsx(Cn,{}),n.jsxs(Ue,{onClick:r,className:"cursor-pointer",style:{color:Ca},children:[n.jsx(Tu,{size:14,style:{color:Ca}}),"Add variant"]})]}),e[6]=r,e[7]=f):f=e[7];let m;e[8]!==o||e[9]!==a?(m=(o||a)&&n.jsxs(n.Fragment,{children:[n.jsx(Cn,{}),o&&n.jsxs(Ue,{onClick:o,children:[n.jsx(kr,{size:14}),"Edit SEO"]}),a&&n.jsxs(Ue,{onClick:a,children:[n.jsx(no,{size:14}),"View JSON"]})]}),e[8]=o,e[9]=a,e[10]=m):m=e[10];let p;e[11]===Symbol.for("react.memo_cache_sentinel")?(p=n.jsx(Cn,{}),e[11]=p):p=e[11];let g;e[12]===Symbol.for("react.memo_cache_sentinel")?(g=n.jsx(es,{size:14}),e[12]=g):g=e[12];let _;e[13]!==l?(_=n.jsxs(Ue,{onClick:l,className:"text-destructive focus:text-destructive",children:[g,"Delete"]}),e[13]=l,e[14]=_):_=e[14];let b;return e[15]!==c||e[16]!==u||e[17]!==f||e[18]!==m||e[19]!==_?(b=n.jsxs(Wt,{children:[d,n.jsxs(Kt,{align:"end",className:"w-44",children:[c,u,f,m,p,_]})]}),e[15]=c,e[16]=u,e[17]=f,e[18]=m,e[19]=_,e[20]=b):b=e[20],b}function ZC(t){return t.stopPropagation()}function an(t){const e=U.c(6),{hasItems:s,emptyLabel:i,emptyHint:r}=t;let o;e[0]!==r||e[1]!==i||e[2]!==s?(o=s?"No results match your search.":n.jsxs(n.Fragment,{children:[n.jsx("div",{children:i}),n.jsx("div",{className:"mt-1 text-muted-foreground/80",children:r})]}),e[0]=r,e[1]=i,e[2]=s,e[3]=o):o=e[3];let a;return e[4]!==o?(a=n.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:o}),e[4]=o,e[5]=a):a=e[5],a}function QC(t){const e=U.c(8),{state:s,claimPhase:i,lifecycle:r,onStart:o}=t;switch(s.kind){case"starting":{let a;e[0]!==i||e[1]!==r?(a=rm({claimPhase:i,lifecycle:r}),e[0]=i,e[1]=r,e[2]=a):a=e[2];let l;return e[3]!==i||e[4]!==a?(l=n.jsx(Wr,{kind:"starting",progress:a,claimPhase:i}),e[3]=i,e[4]=a,e[5]=l):l=e[5],l}case"suspended":{let a;return e[6]!==o?(a=n.jsx(Wr,{kind:"suspended",onResume:o}),e[6]=o,e[7]=a):a=e[7],a}}}function ki(t){const e=U.c(10),{icon:s,title:i,description:r}=t;let o;e[0]!==s?(o=s&&n.jsx(s,{size:24,className:"text-muted-foreground/60"}),e[0]=s,e[1]=o):o=e[1];let a;e[2]!==i?(a=n.jsx("div",{children:i}),e[2]=i,e[3]=a):a=e[3];let l;e[4]!==r?(l=r&&n.jsx("div",{className:"text-xs text-muted-foreground/80 max-w-sm",children:r}),e[4]=r,e[5]=l):l=e[5];let d;return e[6]!==o||e[7]!==a||e[8]!==l?(d=n.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-2 p-6 text-center text-sm text-muted-foreground",children:[o,a,l]}),e[6]=o,e[7]=a,e[8]=l,e[9]=d):d=e[9],d}function e3(t){const e=U.c(2),{virtualMcpId:s}=t,i=vs(s);if(!ti(i?.metadata)){let a;return e[0]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-2 text-center text-sm text-muted-foreground p-6",children:[n.jsx(zi,{size:24,className:"text-muted-foreground/60"}),n.jsx("div",{children:"No content to edit."}),n.jsx("div",{className:"text-xs text-muted-foreground/80",children:"Connect a GitHub repository from the Settings tab to enable Content."})]}),e[0]=a):a=e[0],a}let o;return e[1]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx(RC,{}),e[1]=o):o=e[1],o}const Wo={fast:{label:"Fast",subtitle:"Quick responses for simple tasks",icon:ku},smart:{label:"Smart",subtitle:"Balanced quality and speed",icon:Zs},thinking:{label:"Thinking",subtitle:"Deeper reasoning for hard tasks",icon:V_}},t3=["fast","smart","thinking"];function s3(t){const e=U.c(15),{tier:s,onSelect:i}=t,[r,o]=D.useState(!1),a=Wo[s].icon;let l;e[0]!==a?(l=n.jsx(a,{size:14,className:"text-muted-foreground"}),e[0]=a,e[1]=l):l=e[1];const d=Wo[s];let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx(cs,{size:14,className:"text-muted-foreground"}),e[2]=c):c=e[2];let h;e[3]!==l||e[4]!==d.label?(h=n.jsx(Rs,{asChild:!0,children:n.jsxs(ie,{variant:"outline",size:"sm",className:"w-fit gap-1.5",children:[l,d.label,c]})}),e[3]=l,e[4]=d.label,e[5]=h):h=e[5];let u;e[6]!==i||e[7]!==s?(u=t3.map(p=>{const g=Wo[p],_=g.icon;return n.jsxs("button",{type:"button",onClick:()=>{i(p),o(!1)},className:ae("flex items-start gap-2 px-2 py-1.5 rounded-md text-left hover:bg-muted"),children:[n.jsx(_,{size:16,className:"shrink-0 text-muted-foreground mt-0.5"}),n.jsxs("div",{className:"flex-1",children:[n.jsx("div",{className:"text-sm",children:g.label}),n.jsx("div",{className:"text-xs text-muted-foreground",children:g.subtitle})]}),p===s&&n.jsx(js,{size:14,className:"text-foreground mt-0.5"})]},p)}),e[6]=i,e[7]=s,e[8]=u):u=e[8];let f;e[9]!==u?(f=n.jsx(Ps,{align:"start",className:"p-1 w-64",children:n.jsx("div",{className:"flex flex-col",children:u})}),e[9]=u,e[10]=f):f=e[10];let m;return e[11]!==r||e[12]!==h||e[13]!==f?(m=n.jsxs(As,{open:r,onOpenChange:o,children:[h,f]}),e[11]=r,e[12]=h,e[13]=f,e[14]=m):m=e[14],m}function i3(t){const e=U.c(15),{tier:s,onTierChange:i,override:r,onOverrideChange:o}=t,[a,l]=D.useState(r!==null);let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Model"}),e[0]=d):d=e[0];let c;e[1]!==o||e[2]!==i||e[3]!==r||e[4]!==s||e[5]!==a?(c=a?n.jsx(D.Suspense,{fallback:n.jsx(ie,{variant:"outline",size:"sm",disabled:!0,className:"w-fit",children:"Loading models…"}),children:n.jsx(n3,{override:r,onOverrideChange:o})}):n.jsx(s3,{tier:s,onSelect:i}),e[1]=o,e[2]=i,e[3]=r,e[4]=s,e[5]=a,e[6]=c):c=e[6];let h;e[7]!==o?(h=m=>{l(m),m||o(null)},e[7]=o,e[8]=h):h=e[8];let u;e[9]!==h||e[10]!==a?(u=n.jsxs("label",{className:"flex items-center gap-2 text-xs text-muted-foreground cursor-pointer select-none",children:[n.jsx(On,{checked:a,onCheckedChange:h,className:"cursor-pointer"}),"Specific model"]}),e[9]=h,e[10]=a,e[11]=u):u=e[11];let f;return e[12]!==c||e[13]!==u?(f=n.jsxs("div",{className:"flex flex-col gap-2",children:[d,n.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[c,u]})]}),e[12]=c,e[13]=u,e[14]=f):f=e[14],f}function n3(t){const e=U.c(10),{override:s,onOverrideChange:i}=t,r=fu(),o=r[0]?.id??null,[a,l]=D.useState(s?.credentialId??o);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 c=d;if(r.length===0){let f;return e[2]===Symbol.for("react.memo_cache_sentinel")?(f=n.jsx("span",{className:"text-xs text-muted-foreground italic",children:"Connect an AI provider in settings to pick a specific model."}),e[2]=f):f=e[2],f}let h;e[3]!==a||e[4]!==i?(h=f=>{const m=f.keyId??a??"";l(m),i({modelId:f.modelId,credentialId:m,title:f.title??f.modelId})},e[3]=a,e[4]=i,e[5]=h):h=e[5];let u;return e[6]!==a||e[7]!==c||e[8]!==h?(u=n.jsx("div",{className:"w-fit max-w-full [&_button]:rounded-md",children:n.jsx(P1,{variant:"bordered",placeholder:"Pick a model",model:c,credentialId:a,onCredentialChange:l,onModelChange:h})}),e[6]=a,e[7]=c,e[8]=h,e[9]=u):u=e[9],u}const Om=[{key:"capabilities",heading:"Built-in capabilities",icon:kl,tools:[{name:"web_search",title:"Web search",description:"Look up current information on the web",icon:Ui},{name:"generate_image",title:"Generate image",description:"Create images from a text prompt",icon:Ii},{name:"subtask",title:"Subtask",description:"Spawn a focused sub-agent to handle part of the work",icon:Dn},{name:"user_ask",title:"Ask the user",description:"Pause to ask the user a clarifying question",icon:H_}]},{key:"files",heading:"Files & code",icon:ma,tools:[{name:"read",title:"Read File",description:"Read a file from the workspace",icon:Ou},{name:"write",title:"Write File",description:"Create or overwrite a file",icon:Cl},{name:"edit",title:"Edit File",description:"Make targeted edits to an existing file",icon:U_},{name:"grep",title:"Search Content",description:"Search file contents by pattern",icon:Bn},{name:"glob",title:"Find Files",description:"Find files by name pattern",icon:ma},{name:"bash",title:"Run Command",description:"Run shell commands in the sandbox",icon:W_}]},{key:"context",heading:"Context",icon:Mc,tools:[{name:"read_resource",title:"Read Resource",description:"Read an MCP resource by URI",icon:Mc},{name:"read_prompt",title:"Read Prompt",description:"Read an MCP prompt definition",icon:pa},{name:"skill",title:"Load Skill",description:"Load a skill's full instructions (SKILL.md) by id",icon:pa}]},{key:"browser",heading:"Browser",icon:si,tools:[{name:"take_screenshot",title:"Take Screenshot",description:"Capture a screenshot of a web page",icon:Ru},{name:"scrape_url",title:"Scrape URL",description:"Fetch and extract content from a URL",icon:si},{name:"inspect_page",title:"Inspect Page",description:"Inspect a web page's structure",icon:no}]}],r3=Om.flatMap(t=>t.tools.map(e=>e.name));function o3(t){const e=t.replace(/[_-]+/g," ").trim();return e?e.toLowerCase().replace(/\b\w/g,s=>s.toUpperCase()):t}function a3(t){const e=U.c(5),{agentId:s,value:i,onChange:r}=t;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Tools"}),e[0]=o):o=e[0];let a;return e[1]!==s||e[2]!==r||e[3]!==i?(a=n.jsxs("div",{className:"flex flex-col gap-2",children:[o,s?n.jsx(D.Suspense,{fallback:n.jsxs(ie,{variant:"outline",size:"sm",disabled:!0,className:"w-fit",children:[n.jsx(kl,{size:14}),"Loading tools…"]}),children:n.jsx(l3,{agentId:s,value:i,onChange:r})}):n.jsx("span",{className:"text-xs text-muted-foreground italic",children:"Pick an agent first"})]}),e[1]=s,e[2]=r,e[3]=i,e[4]=a):a=e[4],a}function Md(t){const e=U.c(17),{value:s,checked:i,onToggle:r,title:o,description:a,leading:l}=t;let d;e[0]!==i?(d=n.jsx(Ki,{checked:i,className:"pointer-events-none mt-0.5"}),e[0]=i,e[1]=d):d=e[1];let c;e[2]!==l?(c=l&&n.jsx("span",{className:"mt-px shrink-0",children:l}),e[2]=l,e[3]=c):c=e[3];let h;e[4]!==o?(h=n.jsx("span",{className:"truncate text-sm leading-tight",children:o}),e[4]=o,e[5]=h):h=e[5];let u;e[6]!==a?(u=a&&n.jsx("span",{className:"line-clamp-2 text-xs leading-snug text-muted-foreground",children:a}),e[6]=a,e[7]=u):u=e[7];let f;e[8]!==h||e[9]!==u?(f=n.jsxs("div",{className:"flex min-w-0 flex-col gap-0.5",children:[h,u]}),e[8]=h,e[9]=u,e[10]=f):f=e[10];let m;return e[11]!==r||e[12]!==d||e[13]!==c||e[14]!==f||e[15]!==s?(m=n.jsxs(Or,{value:s,onSelect:r,className:"items-start gap-2.5 py-2",children:[d,c,f]}),e[11]=r,e[12]=d,e[13]=c,e[14]=f,e[15]=s,e[16]=m):m=e[16],m}function $d(t){const e=U.c(20),{conn:s,label:i,icon:r,on:o,total:a,onToggle:l}=t,d=o===a;let c;e[0]!==r||e[1]!==s?(c=s?n.jsx(xs,{icon:s.icon,name:s.title,size:"2xs"}):r?n.jsx(r,{size:14,className:"text-muted-foreground"}):n.jsx(K_,{size:14,className:"text-muted-foreground"}),e[0]=r,e[1]=s,e[2]=c):c=e[2];const h=s?.title??i??"Other tools";let u;e[3]!==h?(u=n.jsx("span",{className:"truncate",children:h}),e[3]=h,e[4]=u):u=e[4];let f;e[5]!==o||e[6]!==a?(f=n.jsxs("span",{className:"text-[11px] font-normal tabular-nums text-muted-foreground/70",children:[o,"/",a]}),e[5]=o,e[6]=a,e[7]=f):f=e[7];let m;e[8]!==l?(m=x=>{x.stopPropagation(),l()},e[8]=l,e[9]=m):m=e[9];const p=d?"None":"All";let g;e[10]!==m||e[11]!==p?(g=n.jsx("button",{type:"button",onClick:m,className:"text-[11px] font-medium text-primary hover:underline",children:p}),e[10]=m,e[11]=p,e[12]=g):g=e[12];let _;e[13]!==f||e[14]!==g?(_=n.jsxs("span",{className:"ml-auto flex items-center gap-2",children:[f,g]}),e[13]=f,e[14]=g,e[15]=_):_=e[15];let b;return e[16]!==c||e[17]!==u||e[18]!==_?(b=n.jsxs("div",{className:"flex items-center gap-2",children:[c,u,_]}),e[16]=c,e[17]=u,e[18]=_,e[19]=b):b=e[19],b}function l3(t){const e=U.c(70),{agentId:s,value:i,onChange:r}=t,{org:o}=Me(),[a,l]=D.useState(!1);let d;e[0]!==s||e[1]!==o.id||e[2]!==o.slug?(d={connectionId:s,orgId:o.id,orgSlug:o.slug},e[0]=s,e[1]=o.id,e[2]=o.slug,e[3]=d):d=e[3];const c=Pt(d);let h;e[4]!==c?(h={client:c},e[4]=c,e[5]=h):h=e[5];const{data:u,isLoading:f}=Du(h),m=Vn();let p,g,_,b,x,v,y,S,w,C,N,E,R;if(e[6]!==m||e[7]!==u?.tools||e[8]!==f||e[9]!==r||e[10]!==a||e[11]!==i){const A=new Map(m.map(f3)),O=new Map;for(const J of u?.tools??[]){const te=Ag(J._meta)??"__other__",oe=Rg(J.name,te==="__other__"?void 0:te),de=J.title,be=de&&de!==J.name?de:o3(oe);O.has(te)||O.set(te,{clientId:te,conn:A.get(te),tools:[]}),O.get(te).tools.push({name:J.name,display:be,description:J.description})}const L=[...O.values()].sort(u3),P=(u?.tools??[]).map(h3),B=[...r3,...P],F=i===null?new Set(B):new Set(i),H=B.every(J=>F.has(J)),z=J=>r(B.every(te=>J.has(te))?null:[...J]),W=J=>{const te=new Set(F);te.has(J)?te.delete(J):te.add(J),z(te)},q=(J,te)=>{const oe=new Set(F);for(const de of J)te?oe.add(de):oe.delete(de);z(oe)};b=As,R=a,x=l;let K;e[25]===Symbol.for("react.memo_cache_sentinel")?(K=n.jsx(kl,{size:14,className:"text-muted-foreground"}),e[25]=K):K=e[25];const Z=H?"All tools":"Tools",Y=!H&&n.jsxs(R1,{variant:"secondary",className:"ml-0.5 h-5 px-1.5 text-[11px] tabular-nums",children:[F.size,"/",B.length]});let G;e[26]===Symbol.for("react.memo_cache_sentinel")?(G=n.jsx(cs,{size:14,className:"text-muted-foreground"}),e[26]=G):G=e[26],e[27]!==Z||e[28]!==Y?(v=n.jsx(Rs,{asChild:!0,children:n.jsxs(ie,{variant:"outline",size:"sm",className:"w-fit gap-1.5",children:[K,Z,Y,G]})}),e[27]=Z,e[28]=Y,e[29]=v):v=e[29],_=Ps,N="p-0 w-80",E="start",g=Ku,e[30]===Symbol.for("react.memo_cache_sentinel")?(w=n.jsx(Nl,{placeholder:"Search tools..."}),e[30]=w):w=e[30];const Q=H?`All ${B.length} tools enabled`:`${F.size} of ${B.length} enabled`;let $;e[31]!==Q?($=n.jsx("span",{className:"text-xs text-muted-foreground",children:Q}),e[31]=Q,e[32]=$):$=e[32];let X;e[33]!==r?(X=()=>r(null),e[33]=r,e[34]=X):X=e[34];let V;e[35]!==H||e[36]!==X?(V=n.jsx("button",{type:"button",onClick:X,disabled:H,className:"text-xs font-medium text-primary hover:underline disabled:cursor-default disabled:opacity-40 disabled:no-underline",children:"Select all"}),e[35]=H,e[36]=X,e[37]=V):V=e[37];let se;e[38]===Symbol.for("react.memo_cache_sentinel")?(se=n.jsx("span",{className:"text-muted-foreground/30",children:"·"}),e[38]=se):se=e[38];let ee;e[39]!==r?(ee=()=>r([]),e[39]=r,e[40]=ee):ee=e[40];const le=F.size===0;let ce;e[41]!==ee||e[42]!==le?(ce=n.jsx("button",{type:"button",onClick:ee,disabled:le,className:"text-xs font-medium text-muted-foreground hover:underline disabled:cursor-default disabled:opacity-40 disabled:no-underline",children:"Clear"}),e[41]=ee,e[42]=le,e[43]=ce):ce=e[43];let fe;e[44]!==V||e[45]!==ce?(fe=n.jsxs("div",{className:"flex items-center gap-2",children:[V,se,ce]}),e[44]=V,e[45]=ce,e[46]=fe):fe=e[46],e[47]!==$||e[48]!==fe?(C=n.jsxs("div",{className:"flex items-center justify-between border-b px-3 py-2",children:[$,fe]}),e[47]=$,e[48]=fe,e[49]=C):C=e[49],p=Tl,y="max-h-80",S=f?n.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:"Loading tools…"}):n.jsxs(n.Fragment,{children:[n.jsx(El,{children:"No tools found"}),Om.map(J=>{const te=J.tools.map(d3),oe=te.filter(de=>F.has(de)).length;return n.jsx(Br,{heading:n.jsx($d,{label:J.heading,icon:J.icon,on:oe,total:te.length,onToggle:()=>q(te,oe!==te.length)}),children:J.tools.map(de=>n.jsx(Md,{value:`${de.title} ${de.name}`,checked:F.has(de.name),onToggle:()=>W(de.name),title:de.title,description:de.description,leading:n.jsx(de.icon,{size:16,className:"text-muted-foreground"})},de.name))},J.key)}),L.map(J=>{const te=J.tools.map(c3),oe=te.filter(de=>F.has(de)).length;return n.jsx(Br,{heading:n.jsx($d,{conn:J.conn,on:oe,total:te.length,onToggle:()=>q(te,oe!==te.length)}),children:J.tools.map(de=>n.jsx(Md,{value:`${de.display} ${de.name} ${J.conn?.title??""}`,checked:F.has(de.name),onToggle:()=>W(de.name),title:de.display,description:de.description},de.name))},J.clientId)})]}),e[6]=m,e[7]=u?.tools,e[8]=f,e[9]=r,e[10]=a,e[11]=i,e[12]=p,e[13]=g,e[14]=_,e[15]=b,e[16]=x,e[17]=v,e[18]=y,e[19]=S,e[20]=w,e[21]=C,e[22]=N,e[23]=E,e[24]=R}else p=e[12],g=e[13],_=e[14],b=e[15],x=e[16],v=e[17],y=e[18],S=e[19],w=e[20],C=e[21],N=e[22],E=e[23],R=e[24];let T;e[50]!==p||e[51]!==y||e[52]!==S?(T=n.jsx(p,{className:y,children:S}),e[50]=p,e[51]=y,e[52]=S,e[53]=T):T=e[53];let k;e[54]!==g||e[55]!==T||e[56]!==w||e[57]!==C?(k=n.jsxs(g,{children:[w,C,T]}),e[54]=g,e[55]=T,e[56]=w,e[57]=C,e[58]=k):k=e[58];let j;e[59]!==_||e[60]!==k||e[61]!==N||e[62]!==E?(j=n.jsx(_,{className:N,align:E,children:k}),e[59]=_,e[60]=k,e[61]=N,e[62]=E,e[63]=j):j=e[63];let I;return e[64]!==b||e[65]!==x||e[66]!==v||e[67]!==j||e[68]!==R?(I=n.jsxs(b,{open:R,onOpenChange:x,children:[v,j]}),e[64]=b,e[65]=x,e[66]=v,e[67]=j,e[68]=R,e[69]=I):I=e[69],I}function c3(t){return t.name}function d3(t){return t.name}function h3(t){return t.name}function u3(t,e){return(t.conn?.title??t.clientId).localeCompare(e.conn?.title??e.clientId)}function f3(t){return[t.id,t]}function An(t){const e=t.trim().split(/\s+/);return e.length!==5?!1:e.every(s=>/^[\d*/,-]+$/.test(s))}function m3(t){if(!t)return"Unknown schedule";const e=t.trim();if(e==="* * * * *")return"Every minute";if(e==="0 * * * *")return"Every hour";if(e==="0 0 * * *")return"Every day";if(e==="0 0 * * 1")return"Every week";const s=e.match(/^\*\/(\d+)\s+\*\s+\*\s+\*\s+\*$/);if(s)return`Every ${s[1]} minutes`;const i=e.match(/^0\s+\*\/(\d+)\s+\*\s+\*\s+\*$/);if(i)return`Every ${i[1]} hours`;const r=e.match(/^0\s+0\s+\*\/(\d+)\s+\*\s+\*$/);if(r){const l=parseInt(r[1]??"1");return l%7===0?`Every ${l/7} weeks`:`Every ${l} days`}const o=e.match(/^(\d+)\s+(\d+)\s+\*\s+\*\s+\*$/);if(o){const l=(o[2]??"0").padStart(2,"0"),d=(o[1]??"0").padStart(2,"0");return`Every day at ${l}:${d} UTC`}const a=e.match(/^(\d+)\s+(\d+)\s+\*\s+\*\s+(\d)$/);if(a){const d=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][parseInt(a[3]??"0")]??"day",c=(a[2]??"0").padStart(2,"0"),h=(a[1]??"0").padStart(2,"0");return`Every ${d} at ${c}:${h} UTC`}return t}function p3(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 g3(t){const e=t.trim();if(e==="* * * * *")return{count:1,unit:"minutes"};if(e==="0 * * * *")return{count:1,unit:"hours"};if(e==="0 0 * * *")return{count:1,unit:"days"};if(e==="0 0 * * 1")return{count:1,unit:"weeks"};const s=e.match(/^\*\/(\d+)\s+\*\s+\*\s+\*\s+\*$/);if(s)return{count:parseInt(s[1]),unit:"minutes"};const i=e.match(/^0\s+\*\/(\d+)\s+\*\s+\*\s+\*$/);if(i)return{count:parseInt(i[1]),unit:"hours"};const r=e.match(/^0\s+0\s+\*\/(\d+)\s+\*\s+\*$/);if(r){const o=parseInt(r[1]);return o%7===0?{count:o/7,unit:"weeks"}:{count:o,unit:"days"}}return null}function _3(t,e){return e===1?{minutes:"minute",hours:"hour",days:"day",weeks:"week"}[t]??t:t}const v3=[{label:"5 minutes",cron:"*/5 * * * *"},{label:"Hour",cron:"0 * * * *"},{label:"Day",cron:"0 0 * * *"},{label:"Week",cron:"0 0 * * 1"}];function x3({automationId:t,open:e,onOpenChange:s,onCustomSelect:i,onEventSelect:r,onWebhookCreated:o}){const{triggerAdd:a}=qn(),[l,d]=D.useState(!1),c=e??l,h=m=>{s?s(m):d(m)},u=async m=>{try{await a.mutateAsync({automation_id:t,type:"cron",cron_expression:m}),he.success("Starter added"),h(!1)}catch(p){const g=p instanceof Error?p.message:"Failed to add starter";he.error(g)}},f=async()=>{try{const m=await a.mutateAsync({automation_id:t,type:"webhook"});h(!1),m.webhook?o?.(m.webhook):he.success("Webhook starter added")}catch(m){const p=m instanceof Error?m.message:"Failed to add webhook starter";he.error(p)}};return n.jsxs(Wt,{open:c,onOpenChange:h,children:[n.jsx(Vt,{asChild:!0,children:n.jsxs(ie,{variant:"outline",size:"sm",children:[n.jsx(Dt,{size:14}),"Add Starter"]})}),n.jsxs(Kt,{align:"end",className:"w-[200px]",children:[n.jsxs(ha,{children:[n.jsxs(ua,{className:"gap-2.5",children:[n.jsx(kn,{size:14,className:"text-muted-foreground shrink-0"}),"Every..."]}),n.jsx(fa,{className:"w-[160px]",children:v3.map(m=>n.jsxs(Ue,{className:"gap-2.5",onSelect:()=>u(m.cron),disabled:a.isPending,children:[n.jsx(kn,{size:14,className:"text-muted-foreground shrink-0"}),"Every ",m.label]},m.cron))})]}),n.jsxs(Ue,{className:"gap-2.5",onSelect:()=>{h(!1),i?.()},children:[n.jsx(kn,{size:14,className:"text-muted-foreground shrink-0"}),"Custom (cron)"]}),n.jsxs(Ue,{className:"gap-2.5",onSelect:()=>{h(!1),r?.()},children:[n.jsx(Mn,{size:14,className:"text-muted-foreground shrink-0"}),"Event"]}),n.jsxs(Ue,{className:"gap-2.5",onSelect:()=>{f()},disabled:a.isPending,children:[n.jsx(Ui,{size:14,className:"text-muted-foreground shrink-0"}),"Webhook"]})]})]})}function Bm(t){const e=U.c(31),{open:s,onOpenChange:i,url:r,token:o,title:a,description:l}=t,d=a===void 0?"Webhook ready":a,c=l===void 0?"Send a POST to this URL with the bearer token to fire the automation. The token is shown once — copy it now.":l,[h,u]=D.useState(null),[f,m]=D.useState("curl"),[p,g]=D.useState("header"),_=D.useId();let b;e[0]===Symbol.for("react.memo_cache_sentinel")?(b=async(A,O)=>{try{await navigator.clipboard.writeText(A),u(O),he.success("Copied"),setTimeout(()=>u(null),1500)}catch{he.error("Failed to copy")}},e[0]=b):b=e[0];const x=b;let v;e[1]!==p||e[2]!==o||e[3]!==r?(v=r&&o&&p==="url"?`${r.replace(/\/$/,"")}/${o}`:r??"",e[1]=p,e[2]=o,e[3]=r,e[4]=v):v=e[4];const y=v,S=r&&o?p==="header"?`curl -X POST "${y}" \\
|
|
468
468
|
-H "Authorization: Bearer ${o}" \\
|
|
469
469
|
-H "Content-Type: application/json" \\
|
|
470
470
|
-d '{"hello":"world"}'`:`curl -X POST "${y}" \\
|
|
@@ -483,7 +483,7 @@ ${X}`:X;c.setValue("metadata.instructions",V,{shouldDirty:!0})},K=new Set(h.map(
|
|
|
483
483
|
},
|
|
484
484
|
body: JSON.stringify({ hello: "world" }),
|
|
485
485
|
});`:"",C=f==="curl"?S:w;let N;e[5]!==d?(N=n.jsx(ss,{children:d}),e[5]=d,e[6]=N):N=e[6];let E;e[7]!==c?(E=n.jsx(Wi,{children:c}),e[7]=c,e[8]=E):E=e[8];let R;e[9]!==N||e[10]!==E?(R=n.jsxs(ts,{children:[N,E]}),e[9]=N,e[10]=E,e[11]=R):R=e[11];let T;e[12]!==p||e[13]!==h||e[14]!==y||e[15]!==f||e[16]!==C||e[17]!==o||e[18]!==_||e[19]!==r?(T=r&&o?n.jsxs("div",{className:"flex flex-col gap-3 min-w-0",children:[n.jsxs("div",{className:"flex flex-col gap-1",children:[n.jsx("span",{className:"text-xs font-semibold text-muted-foreground",children:"URL"}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("code",{className:"flex-1 min-w-0 text-xs font-mono bg-muted rounded-md px-2 py-1.5 truncate",children:y}),n.jsxs(ie,{size:"sm",variant:"outline",onClick:()=>x(y,"url"),children:[n.jsx(as,{size:13}),h==="url"?"Copied":"Copy"]})]})]}),n.jsxs("div",{className:"flex flex-col gap-1",children:[n.jsx("span",{className:"text-xs font-semibold text-muted-foreground",children:"Token (shown once)"}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("code",{className:"flex-1 min-w-0 text-xs font-mono bg-muted rounded-md px-2 py-1.5 truncate",children:o}),n.jsxs(ie,{size:"sm",variant:"outline",onClick:()=>x(o,"token"),children:[n.jsx(as,{size:13}),h==="token"?"Copied":"Copy"]})]})]}),n.jsxs("div",{className:"flex flex-col gap-2",children:[n.jsx("span",{className:"text-xs font-semibold text-muted-foreground",children:"Snippet"}),n.jsxs("div",{className:"flex items-center justify-between gap-3",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx(lo,{value:f,onValueChange:A=>m(A),children:n.jsxs(ao,{className:"h-8 p-[2px]",children:[n.jsx(zs,{value:"curl",className:"h-7 px-2.5 text-xs",children:"curl"}),n.jsx(zs,{value:"fetch",className:"h-7 px-2.5 text-xs",children:"fetch"})]})}),n.jsxs("label",{htmlFor:_,className:"flex items-center gap-1.5 text-xs text-muted-foreground cursor-pointer select-none",children:[n.jsx(Ki,{id:_,checked:p==="url",onCheckedChange:A=>g(A?"url":"header")}),"Token in URL"]})]}),n.jsxs(ie,{size:"sm",variant:"outline",onClick:()=>x(C,"example"),children:[n.jsx(as,{size:13}),h==="example"?"Copied":"Copy"]})]}),n.jsx("div",{className:"rounded-md border overflow-hidden min-w-0",children:n.jsx(Gu,{code:C,language:f==="curl"?"shell":"typescript",readOnly:!0,disableDiagnostics:!0,height:180})})]})]}):null,e[12]=p,e[13]=h,e[14]=y,e[15]=f,e[16]=C,e[17]=o,e[18]=_,e[19]=r,e[20]=T):T=e[20];let k;e[21]!==i?(k=n.jsx(Ws,{children:n.jsx(ie,{onClick:()=>i(!1),children:"Done"})}),e[21]=i,e[22]=k):k=e[22];let j;e[23]!==R||e[24]!==T||e[25]!==k?(j=n.jsxs(Mt,{className:"max-w-lg",children:[R,T,k]}),e[23]=R,e[24]=T,e[25]=k,e[26]=j):j=e[26];let I;return e[27]!==i||e[28]!==s||e[29]!==j?(I=n.jsx(Bt,{open:s,onOpenChange:i,children:j}),e[27]=i,e[28]=s,e[29]=j,e[30]=I):I=e[30],I}function b3(t){const e=U.c(83),{trigger:s,automationId:i,connectionName:r}=t,{triggerAdd:o,triggerRemove:a,triggerRotateToken:l}=qn(),[d,c]=D.useState(!1),[h,u]=D.useState(!1),[f,m]=D.useState(null);let p;e[0]!==s.cron_expression?(p=s.cron_expression?g3(s.cron_expression):null,e[0]=s.cron_expression,e[1]=p):p=e[1];const g=p,[_,b]=D.useState(g?.count??1),[x,v]=D.useState(!1),[y,S]=D.useState(s.cron_expression??""),w=a.isPending||o.isPending||l.isPending,C=s.type==="cron",N=s.type==="webhook";let E;e[2]!==i||e[3]!==a||e[4]!==s.id?(E=async()=>{try{await a.mutateAsync({trigger_id:s.id,automation_id:i}),he.success("Starter removed")}catch{he.error("Failed to remove starter")}c(!1)},e[2]=i,e[3]=a,e[4]=s.id,e[5]=E):E=e[5];const R=E;let T;e[6]!==o||e[7]!==i||e[8]!==y||e[9]!==a||e[10]!==s.cron_expression||e[11]!==s.id?(T=async()=>{const te=y.trim();if(!te||!An(te)||te===s.cron_expression){v(!1),S(s.cron_expression??"");return}try{await o.mutateAsync({automation_id:i,type:"cron",cron_expression:te}),await a.mutateAsync({trigger_id:s.id,automation_id:i}),v(!1)}catch{he.error("Failed to update starter"),S(s.cron_expression??""),v(!1)}},e[6]=o,e[7]=i,e[8]=y,e[9]=a,e[10]=s.cron_expression,e[11]=s.id,e[12]=T):T=e[12];const k=T;let j;e[13]!==i||e[14]!==l||e[15]!==s.id?(j=async()=>{u(!1);try{const te=await l.mutateAsync({trigger_id:s.id,automation_id:i});m({url:te.url,token:te.token})}catch(te){const oe=te,de=oe instanceof Error?oe.message:"Failed to rotate token";he.error(de)}},e[13]=i,e[14]=l,e[15]=s.id,e[16]=j):j=e[16];const I=j;let A;e[17]!==o||e[18]!==i||e[19]!==g||e[20]!==a||e[21]!==s.cron_expression||e[22]!==s.id?(A=async te=>{if(!g)return;const oe=g.unit==="minutes"?5:1,de=Math.max(oe,te);de!==te&&b(de);const be=p3(de,g.unit);if(be!==s.cron_expression)try{await o.mutateAsync({automation_id:i,type:"cron",cron_expression:be}),await a.mutateAsync({trigger_id:s.id,automation_id:i})}catch{he.error("Failed to update starter"),b(g.count)}},e[17]=o,e[18]=i,e[19]=g,e[20]=a,e[21]=s.cron_expression,e[22]=s.id,e[23]=A):A=e[23];const O=A;let L;e[24]!==C||e[25]!==N?(L=C?n.jsx(kn,{size:14,className:"text-muted-foreground shrink-0"}):N?n.jsx(Ui,{size:14,className:"text-muted-foreground shrink-0"}):n.jsx(Mn,{size:14,className:"text-muted-foreground shrink-0"}),e[24]=C,e[25]=N,e[26]=L):L=e[26];let P;e[27]!==r||e[28]!==_||e[29]!==y||e[30]!==O||e[31]!==k||e[32]!==g||e[33]!==C||e[34]!==x||e[35]!==w||e[36]!==N||e[37]!==s.cron_expression||e[38]!==s.event_type||e[39]!==s.params?(P=g&&C?n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"text-sm text-muted-foreground",children:"Every"}),n.jsx("input",{type:"number",min:g.unit==="minutes"?5:1,value:_,onChange:te=>b(parseInt(te.target.value)||1),onBlur:()=>O(_),onKeyDown:te=>{te.key==="Enter"&&te.target.blur(),te.key==="Escape"&&b(g.count)},disabled:w,className:"w-12 text-center text-sm h-7 border border-border rounded-md bg-background px-1 focus:outline-none focus:ring-1 focus:ring-ring"}),n.jsx("span",{className:"text-sm",children:_3(g.unit,_)})]}):C&&x?n.jsxs(n.Fragment,{children:[n.jsx("input",{type:"text",value:y,onChange:te=>S(te.target.value),onBlur:k,onKeyDown:te=>{te.key==="Enter"&&te.target.blur(),te.key==="Escape"&&(v(!1),S(s.cron_expression??""))},className:"flex-1 text-sm font-mono bg-transparent outline-none",autoFocus:!0}),y&&!An(y)&&n.jsx("span",{className:"text-xs text-muted-foreground/60 shrink-0",children:"invalid"})]}):n.jsxs("div",{className:"flex flex-col gap-0.5 flex-1 min-w-0",children:[n.jsx("span",{className:"text-sm font-mono text-xs text-muted-foreground truncate",children:C?m3(s.cron_expression??""):N?"Webhook · POST to fire":`${s.event_type}${r?` · ${r}`:""}`}),!C&&!N&&s.params&&Object.keys(s.params).length>0&&n.jsx("span",{className:"text-xs text-muted-foreground/60 truncate",children:Object.entries(s.params).map(y3).join(", ")})]}),e[27]=r,e[28]=_,e[29]=y,e[30]=O,e[31]=k,e[32]=g,e[33]=C,e[34]=x,e[35]=w,e[36]=N,e[37]=s.cron_expression,e[38]=s.event_type,e[39]=s.params,e[40]=P):P=e[40];let B;e[41]!==w?(B=w&&n.jsx(Oe,{size:13,className:"animate-spin text-muted-foreground"}),e[41]=w,e[42]=B):B=e[42];let F;e[43]!==g||e[44]!==C||e[45]!==x||e[46]!==s.cron_expression?(F=C&&!g&&!x&&n.jsx(ie,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>{S(s.cron_expression??""),v(!0)},children:n.jsx(Cl,{size:13,className:"text-muted-foreground"})}),e[43]=g,e[44]=C,e[45]=x,e[46]=s.cron_expression,e[47]=F):F=e[47];let H;e[48]!==N?(H=N&&n.jsx(ie,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 transition-opacity",title:"Rotate token",onClick:()=>u(!0),children:n.jsx(Pn,{size:13,className:"text-muted-foreground"})}),e[48]=N,e[49]=H):H=e[49];let z;e[50]===Symbol.for("react.memo_cache_sentinel")?(z=n.jsx(ie,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>c(!0),children:n.jsx(Hs,{size:13,className:"text-muted-foreground"})}),e[50]=z):z=e[50];let W;e[51]!==H||e[52]!==B||e[53]!==F?(W=n.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[B,F,H,z]}),e[51]=H,e[52]=B,e[53]=F,e[54]=W):W=e[54];let q;e[55]!==W||e[56]!==L||e[57]!==P?(q=n.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2.5 rounded-lg border border-border bg-background group",children:[L,P,W]}),e[55]=W,e[56]=L,e[57]=P,e[58]=q):q=e[58];let K;e[59]===Symbol.for("react.memo_cache_sentinel")?(K=n.jsxs(Er,{children:[n.jsx(Tr,{children:"Remove Starter"}),n.jsx(Ar,{children:"Are you sure you want to remove this starter?"})]}),e[59]=K):K=e[59];let Z;e[60]===Symbol.for("react.memo_cache_sentinel")?(Z=n.jsx(Pr,{children:"Cancel"}),e[60]=Z):Z=e[60];let Y;e[61]!==R?(Y=n.jsxs(Nr,{children:[K,n.jsxs(Rr,{children:[Z,n.jsx(Dr,{onClick:R,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Remove"})]})]}),e[61]=R,e[62]=Y):Y=e[62];let G;e[63]!==d||e[64]!==Y?(G=n.jsx(jr,{open:d,onOpenChange:c,children:Y}),e[63]=d,e[64]=Y,e[65]=G):G=e[65];let Q;e[66]===Symbol.for("react.memo_cache_sentinel")?(Q=n.jsxs(Er,{children:[n.jsx(Tr,{children:"Rotate webhook token"}),n.jsx(Ar,{children:"A new token will be generated and the current token will stop working. Any senders using the old token must be updated."})]}),e[66]=Q):Q=e[66];let $;e[67]===Symbol.for("react.memo_cache_sentinel")?($=n.jsx(Pr,{children:"Cancel"}),e[67]=$):$=e[67];let X;e[68]!==I?(X=n.jsxs(Nr,{children:[Q,n.jsxs(Rr,{children:[$,n.jsx(Dr,{onClick:I,children:"Rotate"})]})]}),e[68]=I,e[69]=X):X=e[69];let V;e[70]!==h||e[71]!==X?(V=n.jsx(jr,{open:h,onOpenChange:u,children:X}),e[70]=h,e[71]=X,e[72]=V):V=e[72];const se=f!==null;let ee;e[73]===Symbol.for("react.memo_cache_sentinel")?(ee=te=>{te||m(null)},e[73]=ee):ee=e[73];const le=f?.url??null,ce=f?.token??null;let fe;e[74]!==se||e[75]!==le||e[76]!==ce?(fe=n.jsx(Bm,{open:se,onOpenChange:ee,url:le,token:ce,title:"New webhook token",description:"The previous token has been revoked. Copy the new token now — it will not be shown again."}),e[74]=se,e[75]=le,e[76]=ce,e[77]=fe):fe=e[77];let J;return e[78]!==q||e[79]!==G||e[80]!==V||e[81]!==fe?(J=n.jsxs(n.Fragment,{children:[q,G,V,fe]}),e[78]=q,e[79]=G,e[80]=V,e[81]=fe,e[82]=J):J=e[82],J}function y3(t){const[e,s]=t;return`${e}: ${s}`}const S3=30;function w3(t,e){switch(e.type){case"accumulate":{const s=t??{start:e.now,fields:new Set,saveCount:0},i=new Set(s.fields);for(const r of e.fields)i.add(r);return{...s,fields:i,saveCount:s.saveCount+1}}case"reset":return null}}function C3(t){const e=U.c(55),{automationId:s,onDone:i}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={binding:"TRIGGER"},e[0]=r):r=e[0];const o=Vn(r),[a,l]=D.useState(),[d,c]=D.useState();let h;e[1]===Symbol.for("react.memo_cache_sentinel")?(h={},e[1]=h):h=e[1];const[u,f]=D.useState(h),{triggerAdd:m}=qn(),{data:p,isLoading:g}=D1(a);let _,b,x,v,y,S;if(e[2]!==m||e[3]!==s||e[4]!==a||e[5]!==d||e[6]!==g||e[7]!==i||e[8]!==u||e[9]!==o||e[10]!==p){const N=p?.find(P=>P.type===d);let E;e[17]!==m||e[18]!==s||e[19]!==a||e[20]!==d||e[21]!==i||e[22]!==u?(E=async()=>{if(!(!a||!d))try{await m.mutateAsync({automation_id:s,type:"event",event_type:d,connection_id:a,params:u}),Ke("automation_trigger_added",{automation_id:s,trigger_type:"event",connection_id:a,event_type:d}),he.success("Event trigger added"),i()}catch{he.error("Failed to add event trigger")}},e[17]=m,e[18]=s,e[19]=a,e[20]=d,e[21]=i,e[22]=u,e[23]=E):E=e[23],_=E,b="flex flex-col gap-3 px-3 py-3 rounded-lg border border-border bg-background";let R,T;e[24]===Symbol.for("react.memo_cache_sentinel")?(T=n.jsx(Mn,{size:14,className:"text-muted-foreground shrink-0"}),R=n.jsx("span",{className:"text-sm font-medium",children:"Event trigger"}),e[24]=R,e[25]=T):(R=e[24],T=e[25]);let k;e[26]===Symbol.for("react.memo_cache_sentinel")?(k=n.jsx(Hs,{size:13}),e[26]=k):k=e[26],e[27]!==i?(x=n.jsxs("div",{className:"flex items-center gap-2",children:[T,R,n.jsx("button",{type:"button",className:"ml-auto shrink-0 p-0.5 rounded text-muted-foreground hover:text-foreground",onClick:i,children:k})]}),e[27]=i,e[28]=x):x=e[28];const j=a??"";let I;e[29]===Symbol.for("react.memo_cache_sentinel")?(I=P=>{l(P),c(void 0),f({})},e[29]=I):I=e[29];let A;e[30]===Symbol.for("react.memo_cache_sentinel")?(A=n.jsx(kt,{className:"w-full",children:n.jsx(Rt,{placeholder:"Select connection..."})}),e[30]=A):A=e[30];let O;e[31]!==o?(O=o.length===0?n.jsx("div",{className:"px-2 py-3 text-center text-xs text-muted-foreground",children:"No connections with trigger support"}):o.map(N3),e[31]=o,e[32]=O):O=e[32];let L;e[33]!==O?(L=n.jsx(jt,{children:O}),e[33]=O,e[34]=L):L=e[34],e[35]!==j||e[36]!==L?(v=n.jsxs(Nt,{value:j,onValueChange:I,children:[A,L]}),e[35]=j,e[36]=L,e[37]=v):v=e[37],e[38]!==a||e[39]!==d||e[40]!==g||e[41]!==p?(y=a&&n.jsxs(Nt,{value:d??"",onValueChange:P=>{c(P),f({})},children:[n.jsx(kt,{className:"w-full",children:g?n.jsxs("span",{className:"flex items-center gap-2 text-muted-foreground",children:[n.jsx(Oe,{size:13,className:"animate-spin"}),"Loading events..."]}):n.jsx(Rt,{placeholder:"Select event type...",children:d??"Select event type..."})}),n.jsx(jt,{children:p?.map(j3)})]}),e[38]=a,e[39]=d,e[40]=g,e[41]=p,e[42]=y):y=e[42],S=N?.paramsSchema&&Object.keys(N.paramsSchema).length>0&&n.jsx("div",{className:"flex flex-col gap-2",children:Object.entries(N.paramsSchema).map(P=>{const[B,F]=P;return n.jsxs("div",{className:"flex flex-col gap-1",children:[n.jsxs("label",{className:"text-xs text-muted-foreground",children:[B,F.description&&n.jsxs("span",{className:"text-muted-foreground/60",children:[" ","— ",F.description]})]}),F.enum?n.jsxs(Nt,{value:u[B]??"",onValueChange:H=>f(z=>({...z,[B]:H})),children:[n.jsx(kt,{className:"w-full",children:n.jsx(Rt,{placeholder:`Select ${B}...`})}),n.jsx(jt,{children:F.enum.map(k3)})]}):n.jsx("input",{type:"text",value:u[B]??"",onChange:H=>f(z=>({...z,[B]:H.target.value})),placeholder:F.description??B,className:"text-sm border border-border rounded-md bg-background px-2 py-1.5 focus:outline-none focus:ring-1 focus:ring-ring"})]},B)})}),e[2]=m,e[3]=s,e[4]=a,e[5]=d,e[6]=g,e[7]=i,e[8]=u,e[9]=o,e[10]=p,e[11]=_,e[12]=b,e[13]=x,e[14]=v,e[15]=y,e[16]=S}else _=e[11],b=e[12],x=e[13],v=e[14],y=e[15],S=e[16];let w;e[43]!==m||e[44]!==a||e[45]!==d||e[46]!==_?(w=a&&d&&n.jsx(ie,{size:"sm",onClick:_,disabled:m.isPending,children:m.isPending?n.jsx(Oe,{size:13,className:"animate-spin"}):"Add trigger"}),e[43]=m,e[44]=a,e[45]=d,e[46]=_,e[47]=w):w=e[47];let C;return e[48]!==b||e[49]!==x||e[50]!==v||e[51]!==y||e[52]!==S||e[53]!==w?(C=n.jsxs("div",{className:b,children:[x,v,y,S,w]}),e[48]=b,e[49]=x,e[50]=v,e[51]=y,e[52]=S,e[53]=w,e[54]=C):C=e[54],C}function k3(t){return n.jsx(tt,{value:t,children:t},t)}function j3(t){return n.jsx(tt,{value:t.type,children:n.jsxs("div",{className:"flex flex-col",children:[n.jsx("span",{children:t.type}),n.jsx("span",{className:"text-xs text-muted-foreground",children:t.description})]})},t.type)}function N3(t){return n.jsx(tt,{value:t.id,children:t.title},t.id)}function E3({automationId:t,automation:e,onBack:s,onDelete:i}){const r=e.virtual_mcp_id,{org:o}=Me(),{update:a,triggerAdd:l,run:d}=qn(),c=Vn(),h=new Map(c.map(ee=>[ee.id,ee.title])),{openTask:u}=Ts(),{setChatOpen:f}=fl(),{sendMessage:m}=li(),p=e.messages?.[0]?.metadata?.tiptapDoc??void 0,[g,_]=D.useState(p),[b,x]=D.useState(!1),[v,y]=D.useState(!1),[S,w]=D.useState(!1),[C,N]=D.useState(""),[E,R]=D.useState(!1),[T,k]=D.useState(null),[j,I]=D.useState(!1),[A,O]=D.useState(!1),[L,P]=D.useState(!1),B=async()=>{if(j)return;const le=pg(g).filter(ce=>ce.type==="text").map(ce=>ce.text).join(`
|
|
486
|
-
`);if(le.trim()){I(!0);try{X(),Ke("automation_improve_clicked",{automation_id:t,agent_id:r,instructions_length:le.length}),f(!0),await m({tiptapDoc:kf({managerAgentId:eu.AUTOMATION_MANAGER(o.id),managerName:"Automation Manager",kind:"automation",id:t,instructions:le})})}finally{I(!1)}}},F=e.models?.tier??"smart",H=e.models?.modelId&&e.models?.credentialId?{modelId:e.models.modelId,credentialId:e.models.credentialId,title:e.models.modelTitle??e.models.modelId}:null,z=Wh({defaultValues:{name:e.name,active:e.active,tier:F,modelOverride:H,tools:e.tools??null,maxAgentSteps:e.maxAgentSteps??null}}),W=z.watch("active"),[q,K]=D.useReducer(w3,null),Z=()=>{q!==null&&(Ke("automation_updated",{automation_id:t,agent_id:r,fields:Array.from(q.fields),save_count:q.saveCount,edit_duration_ms:Date.now()-q.start}),K({type:"reset"}))},Y=async()=>{const ee=z.control._formState.dirtyFields,le=Object.keys(ee);if(le.length===0&&!L)return!0;const ce=z.getValues(),fe=z.control._defaultValues;z.reset(ce,{keepValues:!0});const J=L;P(!1);const te={tier:ce.tier,...ce.modelOverride?{modelId:ce.modelOverride.modelId,credentialId:ce.modelOverride.credentialId,modelTitle:ce.modelOverride.title}:{}},oe={id:t,name:ce.name,active:ce.active,models:te,tools:ce.tools,maxAgentSteps:ce.maxAgentSteps,messages:mg(g),temperature:0};try{await a.mutateAsync(oe)}catch{return z.reset(fe,{keepValues:!0}),J&&P(!0),!1}const de=[...le];return J&&de.push("messages"),K({type:"accumulate",now:Date.now(),fields:de}),$(),!0},{schedule:G,flush:Q}=Lr({save:Y}),{schedule:$,flush:X}=Lr({delayMs:3e4,save:async()=>Z()});D.useEffect(()=>{const ee=z.watch(()=>G());return()=>ee.unsubscribe()},[]);const V=ee=>{if(_(ee),!A){O(!0);return}P(!0),G()},se=async()=>{Ke("automation_test_clicked",{automation_id:t,agent_id:r});const ee=await Q();if(X(),!!ee){if(!g){he.error("No instructions configured for this automation");return}try{const le=await d.mutateAsync(t);le.threadId&&(f(!0),u(le.threadId))}catch{}}};return n.jsxs(n.Fragment,{children:[s&&n.jsx("div",{className:"flex items-center pb-4 shrink-0",children:n.jsxs(ie,{variant:"ghost",size:"sm",onClick:s,children:[n.jsx(zu,{size:14}),"Back to list"]})}),n.jsxs("div",{className:"flex flex-col gap-8",children:[n.jsxs("div",{className:"flex flex-col gap-1.5",children:[n.jsxs("div",{className:"flex items-center justify-between gap-4",children:[n.jsx(Ht,{control:z.control,name:"name",render:({field:ee})=>n.jsx(ze,{...ee,placeholder:"Automation name",className:"border border-transparent shadow-none px-0 text-lg font-medium h-auto focus-visible:ring-0 focus-visible:border-border bg-transparent flex-1",style:{boxShadow:"none"}})}),i&&n.jsx(ie,{variant:"ghost",size:"icon",className:"text-muted-foreground hover:text-destructive shrink-0",onClick:i,children:n.jsx(es,{size:14})})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Ht,{control:z.control,name:"active",render:({field:ee})=>n.jsx(On,{checked:ee.value,onCheckedChange:le=>{ee.onChange(le),Q()},className:"cursor-pointer"})}),n.jsx("span",{className:"text-sm text-muted-foreground",children:W?"Active":"Inactive"}),n.jsx("span",{className:"text-muted-foreground/50 text-sm",children:"·"}),n.jsx(jf,{id:e.created_by,size:"2xs",className:"text-sm text-muted-foreground"})]})]}),n.jsxs("div",{className:"flex flex-col gap-2.5",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Starter"}),n.jsx(x3,{automationId:t,open:b,onOpenChange:x,onCustomSelect:()=>{w(!0),R(!1),N("")},onEventSelect:()=>{R(!0),w(!1)},onWebhookCreated:ee=>{Ke("automation_trigger_added",{automation_id:t,trigger_type:"webhook"}),k(ee)}})]}),e.triggers.length===0&&!S?n.jsx("div",{className:"rounded-lg border border-dashed border-border px-4 py-6 text-center",children:n.jsxs("p",{className:"text-sm text-muted-foreground",children:["When should this automation run?"," ",n.jsx("button",{type:"button",className:"text-foreground underline underline-offset-2 cursor-pointer hover:text-foreground/80 transition-colors",onClick:()=>x(!0),children:"Add a starter"})," ","to get going."]})}):n.jsx("div",{className:"flex flex-col gap-2",children:e.triggers.map(ee=>n.jsx(b3,{trigger:ee,automationId:t,connectionName:ee.connection_id?h.get(ee.connection_id):void 0},ee.id))}),S&&n.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2.5 rounded-lg border border-border bg-background group",children:[n.jsx(kn,{size:14,className:"text-muted-foreground shrink-0"}),n.jsx("input",{type:"text",value:C,onChange:ee=>N(ee.target.value),onBlur:async()=>{const ee=C.trim();if(!(!ee||!An(ee)))try{await l.mutateAsync({automation_id:t,type:"cron",cron_expression:ee}),Ke("automation_trigger_added",{automation_id:t,trigger_type:"cron"}),he.success("Starter added"),w(!1),N("")}catch{he.error("Failed to add starter")}},onKeyDown:async ee=>{const le=C.trim();ee.key==="Enter"&&le&&An(le)&&ee.target.blur(),ee.key==="Escape"&&(w(!1),N(""))},placeholder:"0 9 * * 1-5",className:"flex-1 text-sm font-mono bg-transparent outline-none placeholder:text-muted-foreground/40",autoFocus:!0}),C&&!An(C)&&n.jsx("span",{className:"text-xs text-muted-foreground/60 shrink-0",children:"invalid"}),l.isPending&&n.jsx(Oe,{size:13,className:"animate-spin text-muted-foreground shrink-0"}),n.jsx("button",{type:"button",className:"shrink-0 p-0.5 rounded text-muted-foreground opacity-0 group-hover:opacity-100 hover:text-foreground transition-opacity",onClick:()=>{w(!1),N("")},children:n.jsx(Hs,{size:13})})]}),E&&n.jsx(D.Suspense,{fallback:n.jsxs("div",{className:"flex items-center gap-2 px-3 py-3 rounded-lg border border-border bg-background",children:[n.jsx(Oe,{size:13,className:"animate-spin text-muted-foreground"}),n.jsx("span",{className:"text-sm text-muted-foreground",children:"Loading connections..."})]}),children:n.jsx(C3,{automationId:t,onDone:()=>R(!1)})}),n.jsx(Bm,{open:T!==null,onOpenChange:ee=>{ee||k(null)},url:T?.url??null,token:T?.token??null})]}),n.jsxs("div",{className:"flex flex-col gap-2.5",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Instructions"}),n.jsxs(ie,{variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",disabled:j||!g,onClick:B,children:[n.jsx(Zs,{size:13}),"Improve"]})]}),n.jsx(dg,{tiptapDoc:g,setTiptapDoc:V,placeholder:"What should this automation do?",children:n.jsxs("div",{className:"rounded-xl border border-border min-h-[120px] flex flex-col",children:[n.jsx(hg,{virtualMcpId:r||null,className:"max-h-[45vh]"}),n.jsx("div",{className:"@container/chat-bottom flex items-center justify-end gap-1.5 p-2.5",children:n.jsxs(Te,{children:[n.jsx(Ne,{asChild:!0,children:n.jsxs(ie,{type:"button",variant:"default",className:"h-8 gap-1.5 rounded-md px-3 text-sm font-medium",onClick:se,disabled:!r,children:[n.jsx(S1,{size:16}),"Test"]})}),n.jsx(Ee,{children:"Test Automation"})]})})]})})]}),n.jsxs(Pg,{open:v,onOpenChange:y,className:"flex flex-col gap-2.5",children:[n.jsxs(Dg,{className:"group flex w-fit cursor-pointer items-center gap-1.5",children:[n.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Advanced"}),n.jsx(cs,{size:14,className:"text-muted-foreground/60 transition-transform group-data-[state=open]:rotate-180"})]}),n.jsxs(Ig,{className:"flex flex-col gap-5 pt-0.5",children:[n.jsx(i3,{tier:z.watch("tier"),onTierChange:ee=>z.setValue("tier",ee,{shouldDirty:!0}),override:z.watch("modelOverride"),onOverrideChange:ee=>z.setValue("modelOverride",ee,{shouldDirty:!0})}),n.jsx(a3,{agentId:r||null,value:z.watch("tools"),onChange:ee=>z.setValue("tools",ee,{shouldDirty:!0})}),n.jsxs("div",{className:"flex flex-col gap-2",children:[n.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Max steps"}),n.jsx(ze,{type:"number",min:1,max:100,className:"w-40",placeholder:`${S3} (default)`,value:z.watch("maxAgentSteps")??"",onChange:ee=>{const le=ee.target.value.trim(),ce=le===""?null:Number(le);z.setValue("maxAgentSteps",ce===null||Number.isNaN(ce)?null:ce,{shouldDirty:!0})}})]})]})]})]})]})}function Bi(){const t=U.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx("div",{"data-testid":"main-panel-loading",className:"flex h-full w-full items-center justify-center",children:n.jsx(Oe,{size:20,className:"animate-spin text-muted-foreground"})}),t[0]=e):e=t[0],e}const Mm=[{key:"24h",label:"Last 24 hours",ms:1440*60*1e3},{key:"7d",label:"Last 7 days",ms:10080*60*1e3},{key:"30d",label:"Last 30 days",ms:720*60*60*1e3}];function $m(t){const e=Mm.find(i=>i.key===t).ms,s=Date.now();return{startDate:new Date(s-e).toISOString(),endDate:new Date(s).toISOString()}}function T3(t){const e=U.c(12),{automationId:s,triggerIds:i}=t,[r,o]=D.useState("30d"),[a,l]=D.useState(R3);let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=p=>{const g=p;o(g),l($m(g))},e[0]=d):d=e[0];let c;e[1]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx(kt,{className:"w-44",children:n.jsx(Rt,{})}),e[1]=c):c=e[1];let h;e[2]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx(jt,{children:Mm.map(A3)}),e[2]=h):h=e[2];let u;e[3]!==r?(u=n.jsx("div",{className:"flex items-center justify-end",children:n.jsxs(Nt,{value:r,onValueChange:d,children:[c,h]})}),e[3]=r,e[4]=u):u=e[4];let f;e[5]!==s||e[6]!==a||e[7]!==i?(f=n.jsx(j1,{automationId:s,triggerIds:i,range:a}),e[5]=s,e[6]=a,e[7]=i,e[8]=f):f=e[8];let m;return e[9]!==u||e[10]!==f?(m=n.jsxs("div",{className:"flex flex-col gap-5",children:[u,f]}),e[9]=u,e[10]=f,e[11]=m):m=e[11],m}function A3(t){return n.jsx(tt,{value:t.key,children:t.label},t.key)}function R3(){return $m("30d")}function P3(t){const e=U.c(5),{tabId:s}=t;let i;e[0]!==s?(i=pu(s),e[0]=s,e[1]=i):i=e[1];const r=i;if(!r)return null;let o;e[2]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx(Bi,{}),e[2]=o):o=e[2];let a;return e[3]!==r.id?(a=n.jsx(D.Suspense,{fallback:o,children:n.jsx(D3,{id:r.id})}),e[3]=r.id,e[4]=a):a=e[4],a}function D3(t){const e=U.c(24),{id:s}=t,i=qt(),{data:r,isLoading:o}=I1(s),[a,l]=D.useState("settings");let d;e[0]!==i?(d=()=>{i({to:".",search:L3,replace:!0})},e[0]=i,e[1]=d):d=e[1];const c=d;if(o){let y;return e[2]===Symbol.for("react.memo_cache_sentinel")?(y=n.jsx(Bi,{}),e[2]=y):y=e[2],y}if(!r){let y;return e[3]===Symbol.for("react.memo_cache_sentinel")?(y=n.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-muted-foreground",children:"Automation not found"}),e[3]=y):y=e[3],y}let h;e[4]!==r.triggers?(h=r.triggers.map(I3),e[4]=r.triggers,e[5]=h):h=e[5];const u=h;let f;e[6]===Symbol.for("react.memo_cache_sentinel")?(f=n.jsx(zu,{size:14}),e[6]=f):f=e[6];let m;e[7]!==c?(m=n.jsxs(ie,{variant:"ghost",size:"sm",onClick:c,children:[f,"Back to list"]}),e[7]=c,e[8]=m):m=e[8];let p;e[9]===Symbol.for("react.memo_cache_sentinel")?(p=[{id:"settings",label:"Settings"},{id:"runs",label:"Runs"}],e[9]=p):p=e[9];let g;e[10]===Symbol.for("react.memo_cache_sentinel")?(g=y=>l(y),e[10]=g):g=e[10];let _;e[11]!==a?(_=n.jsx(Hu,{tabs:p,activeTab:a,onTabChange:g}),e[11]=a,e[12]=_):_=e[12];let b;e[13]!==m||e[14]!==_?(b=n.jsxs("div",{className:"flex items-center justify-between pb-4 shrink-0",children:[m,_]}),e[13]=m,e[14]=_,e[15]=b):b=e[15];let x;e[16]!==r||e[17]!==s||e[18]!==a||e[19]!==u?(x=a==="settings"?n.jsx(E3,{automationId:s,automation:r}):n.jsx(T3,{automationId:s,triggerIds:u}),e[16]=r,e[17]=s,e[18]=a,e[19]=u,e[20]=x):x=e[20];let v;return e[21]!==b||e[22]!==x?(v=n.jsx(os,{children:n.jsx(os.Content,{children:n.jsxs(os.Body,{children:[b,x]})})}),e[21]=b,e[22]=x,e[23]=v):v=e[23],v}function I3(t){return t.id}function L3(t){return{...t,main:"automations"}}function O3(t){const e=U.c(20),{virtualMcpId:s}=t,i=qt(),{data:r}=L1(s),o=r===void 0?[]:r,{create:a}=qn(),[l,d]=D.useState(""),c=l.toLowerCase(),h=o.filter(T=>T.name.toLowerCase().includes(c));let u;e[0]!==i?(u=T=>i({to:".",search:k=>({...k,main:"automation:"+T}),replace:!0}),e[0]=i,e[1]=u):u=e[1];const f=u,m=async()=>{if(a.isPending)return;Ke("automation_new_clicked",{virtual_mcp_id:s,existing_count:o.length});const T=await a.mutateAsync(O1(s));f(T.id)};let p;e[2]===Symbol.for("react.memo_cache_sentinel")?(p=n.jsx(Dt,{size:14}),e[2]=p):p=e[2];let g;e[3]!==a.isPending||e[4]!==m?(g=n.jsxs(ie,{size:"sm",onClick:m,disabled:a.isPending,children:[p,"New automation"]}),e[3]=a.isPending,e[4]=m,e[5]=g):g=e[5];const _=g,b=os,x=os,v=os;let y;e[6]===Symbol.for("react.memo_cache_sentinel")?(y=n.jsx(os.Title,{children:"Automations"}),e[6]=y):y=e[6];const S=o.length>0&&n.jsx(Fu,{value:l,onChange:d,placeholder:"Search automations...",className:"w-full md:w-[375px]"});let w;e[7]!==_||e[8]!==S?(w=n.jsxs("div",{className:"flex flex-col gap-6",children:[y,n.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[S,_]})]}),e[7]=_,e[8]=S,e[9]=w):w=e[9];const C=o.length===0?n.jsx("div",{className:"flex items-center justify-center py-20",children:n.jsx(Cr,{image:n.jsx(Mn,{size:48,className:"text-muted-foreground"}),title:"No automations yet",description:"Create your first automation to run this agent on a schedule or in response to events.",actions:_})}):h.length===0?n.jsx("div",{className:"flex items-center justify-center py-20",children:n.jsx(Cr,{image:n.jsx(Mn,{size:48,className:"text-muted-foreground"}),title:"No automations found",description:`No automations match "${l}"`})}):n.jsx("div",{className:"mt-6 rounded-xl border border-border overflow-hidden",children:h.map(T=>n.jsx(B1,{automation:T,onClick:()=>f(T.id)},T.id))});let N;e[10]!==C||e[11]!==v.Body||e[12]!==w?(N=n.jsxs(v.Body,{children:[w,C]}),e[10]=C,e[11]=v.Body,e[12]=w,e[13]=N):N=e[13];let E;e[14]!==N||e[15]!==x.Content?(E=n.jsx(x.Content,{children:N}),e[14]=N,e[15]=x.Content,e[16]=E):E=e[16];let R;return e[17]!==b||e[18]!==E?(R=n.jsx(b,{children:E}),e[17]=b,e[18]=E,e[19]=R):R=e[19],R}function B3(t){const e=U.c(3),{virtualMcpId:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx(Bi,{}),e[0]=i):i=e[0];let r;return e[1]!==s?(r=n.jsx(D.Suspense,{fallback:i,children:n.jsx(O3,{virtualMcpId:s})}),e[1]=s,e[2]=r):r=e[2],r}function M3(t){const e=U.c(37),{file:s,onClose:i}=t;let r,o;e[0]!==s.filename?(r=n.jsx(Pi,{filename:s.filename,className:"h-4.5 w-3.5 shrink-0"}),o=n.jsx("span",{className:"truncate text-xs font-medium text-foreground",children:s.filename}),e[0]=s.filename,e[1]=r,e[2]=o):(r=e[1],o=e[2]);let a;e[3]!==s.size?(a=l_(s.size),e[3]=s.size,e[4]=a):a=e[4];let l;e[5]!==a?(l=n.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:a}),e[5]=a,e[6]=l):l=e[6];let d;e[7]!==r||e[8]!==o||e[9]!==l?(d=n.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2 px-2",children:[r,o,l]}),e[7]=r,e[8]=o,e[9]=l,e[10]=d):d=e[10];let c;e[11]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx(Y_,{size:14}),e[11]=c):c=e[11];let h;e[12]!==s.downloadUrl||e[13]!==s.filename?(h=n.jsx(Ne,{asChild:!0,children:n.jsx(ie,{variant:"ghost",size:"icon",asChild:!0,children:n.jsx("a",{href:s.downloadUrl,download:s.filename,children:c})})}),e[12]=s.downloadUrl,e[13]=s.filename,e[14]=h):h=e[14];let u;e[15]===Symbol.for("react.memo_cache_sentinel")?(u=n.jsx(Ee,{side:"bottom",children:"Download"}),e[15]=u):u=e[15];let f;e[16]!==h?(f=n.jsxs(Te,{children:[h,u]}),e[16]=h,e[17]=f):f=e[17];let m;e[18]!==s.downloadUrl?(m=()=>window.open(s.downloadUrl,"_blank","noopener"),e[18]=s.downloadUrl,e[19]=m):m=e[19];let p;e[20]===Symbol.for("react.memo_cache_sentinel")?(p=n.jsx(hi,{size:14}),e[20]=p):p=e[20];let g;e[21]!==m?(g=n.jsx(Ne,{asChild:!0,children:n.jsx(ie,{variant:"ghost",size:"icon",onClick:m,children:p})}),e[21]=m,e[22]=g):g=e[22];let _;e[23]===Symbol.for("react.memo_cache_sentinel")?(_=n.jsx(Ee,{side:"bottom",children:"Open in new tab"}),e[23]=_):_=e[23];let b;e[24]!==g?(b=n.jsxs(Te,{children:[g,_]}),e[24]=g,e[25]=b):b=e[25];let x;e[26]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsx(Hs,{size:14}),e[26]=x):x=e[26];let v;e[27]!==i?(v=n.jsx(Ne,{asChild:!0,children:n.jsx(ie,{variant:"ghost",size:"icon",onClick:i,children:x})}),e[27]=i,e[28]=v):v=e[28];let y;e[29]===Symbol.for("react.memo_cache_sentinel")?(y=n.jsx(Ee,{side:"bottom",children:"Close"}),e[29]=y):y=e[29];let S;e[30]!==v?(S=n.jsxs(Te,{children:[v,y]}),e[30]=v,e[31]=S):S=e[31];let w;return e[32]!==b||e[33]!==S||e[34]!==d||e[35]!==f?(w=n.jsxs("div",{className:"flex h-9 shrink-0 items-center gap-1 border-b border-border/60 px-2",children:[d,f,b,S]}),e[32]=b,e[33]=S,e[34]=d,e[35]=f,e[36]=w):w=e[36],w}function $3(t){const e=U.c(24),{fileKey:s,taskId:i}=t,r=qt(),{data:o,isPending:a}=Jh(i);let l;e[0]!==s||e[1]!==o?(l=o?.find(p=>p.key===s)??null,e[0]=s,e[1]=o,e[2]=l):l=e[2];const d=l;let c;e[3]!==r?(c=()=>r({to:".",search:z3,replace:!0}),e[3]=r,e[4]=c):c=e[4];const h=c;if(!d){if(a){let v;return e[5]===Symbol.for("react.memo_cache_sentinel")?(v=n.jsx("div",{className:"h-full w-full bg-background",children:n.jsx(o_,{})}),e[5]=v):v=e[5],v}let p;e[6]!==s?(p=s.split("/").pop()??s,e[6]=s,e[7]=p):p=e[7];let g;e[8]!==p?(g=n.jsx(Pi,{filename:p,className:"h-7.5 w-6"}),e[8]=p,e[9]=g):g=e[9];let _;e[10]===Symbol.for("react.memo_cache_sentinel")?(_=n.jsx("span",{className:"text-sm text-muted-foreground",children:"This file is no longer available."}),e[10]=_):_=e[10];let b;e[11]!==h?(b=n.jsx(ie,{variant:"ghost",size:"sm",onClick:h,children:"Close"}),e[11]=h,e[12]=b):b=e[12];let x;return e[13]!==g||e[14]!==b?(x=n.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-2 bg-background",children:[g,_,b]}),e[13]=g,e[14]=b,e[15]=x):x=e[15],x}let u;e[16]!==d||e[17]!==h?(u=n.jsx(M3,{file:d,onClose:h}),e[16]=d,e[17]=h,e[18]=u):u=e[18];let f;e[19]!==d?(f=n.jsx("div",{className:"relative min-h-0 flex-1",children:n.jsx(a_,{file:d})}),e[19]=d,e[20]=f):f=e[20];let m;return e[21]!==u||e[22]!==f?(m=n.jsxs("div",{className:"flex h-full w-full flex-col bg-background",children:[u,f]}),e[21]=u,e[22]=f,e[23]=m):m=e[23],m}function z3(t){return{...t,main:"0"}}const Vo="home";function F3(t){const e=U.c(5),{label:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx(wl,{className:"aspect-video w-2/3 max-w-xl"}),e[0]=i):i=e[0];let r;e[1]!==s?(r=s&&n.jsx("p",{className:"text-xs text-muted-foreground",children:s}),e[1]=s,e[2]=r):r=e[2];let o;return e[3]!==r?(o=n.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-3 bg-background",children:[i,r]}),e[3]=r,e[4]=o):o=e[4],o}function H3(t){const e=U.c(15),{path:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={refetchIntervalWhenAbsent:2e3},e[0]=i):i=e[0];const r=c_(Vo,s,i),o=d_(Vo)(s);if(r.isPending||!r.data){const f=!r.isPending&&!r.data?"Waiting for the deck to sync…":void 0;let m;return e[1]!==f?(m=n.jsx(F3,{label:f}),e[1]=f,e[2]=m):m=e[2],m}let a;e[3]!==r.data?(a=h_(r.data),e[3]=r.data,e[4]=a):a=e[4];const l=r.data.shareMode??"private",d=r.data.effectivePublic??!1,c=window.location.origin+o;let h;e[5]!==s||e[6]!==l||e[7]!==d||e[8]!==c?(h=n.jsx(u_,{volume:Vo,path:s,shareMode:l,effectivePublic:d,url:c}),e[5]=s,e[6]=l,e[7]=d,e[8]=c,e[9]=h):h=e[9];let u;return e[10]!==s||e[11]!==o||e[12]!==a||e[13]!==h?(u=n.jsx(f_,{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 U3(t){const e=U.c(5),{path:s}=t,i=qt();let r;e[0]!==i?(r=()=>i({to:".",search:W3,replace:!0}),e[0]=i,e[1]=r):r=e[1];const o=r;let a;return e[2]!==o||e[3]!==s?(a=n.jsx(m_,{previewPath:s,onClose:o,showSeeInLibrary:!0}),e[2]=o,e[3]=s,e[4]=a):a=e[4],a}function W3(t){return{...t,main:"0"}}const zd=D.lazy(()=>ls(()=>import("./project-app-view-CVZVC5T9.js"),__vite__mapDeps([153,1,2,44,7,8,9,10,11,12,13,14,15,16,6,3,4,5,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,118,100,91,88,101,102,80,81,82,83,84,85,86,87,89,90,92,93,94,95,96,103,104,105,106,107,108,109,110,111,79,112,113,114,115,116,117,119,120,121,122,98,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140])).then(t=>({default:t.AppViewContent})));function V3(t){const e=U.c(53),{activeTab:s,virtualMcpId:i,taskId:r,layoutTabs:o,expandedTools:a,automationTabParsed:l}=t;if(Zg(s)){let v;return e[0]!==i?(v=n.jsx(id,{virtualMcpId:i}),e[0]=i,e[1]=v):v=e[1],v}if(s==="git"){let v;return e[2]!==i?(v=n.jsx(e0,{virtualMcpId:i}),e[2]=i,e[3]=v):v=e[3],v}if(s==="automations"){let v;return e[4]!==i?(v=n.jsx(B3,{virtualMcpId:i}),e[4]=i,e[5]=v):v=e[5],v}if(s==="preview"){let v;return e[6]!==i?(v=n.jsx(o2,{virtualMcpId:i}),e[6]=i,e[7]=v):v=e[7],v}if(s==="content"){let v;return e[8]!==i?(v=n.jsx(e3,{virtualMcpId:i}),e[8]=i,e[9]=v):v=e[9],v}if(l){let v;return e[10]!==s?(v=n.jsx(P3,{tabId:s}),e[10]=s,e[11]=v):v=e[11],v}let d;e[12]!==s?(d=_u(s),e[12]=s,e[13]=d):d=e[13];const c=d;if(c){let v;return e[14]!==c.path?(v=n.jsx(H3,{path:c.path},c.path),e[14]=c.path,e[15]=v):v=e[15],v}let h;e[16]!==s?(h=gu(s),e[16]=s,e[17]=h):h=e[17];const u=h;if(u){let v;return e[18]!==u.key||e[19]!==r?(v=n.jsx($3,{fileKey:u.key,taskId:r}),e[18]=u.key,e[19]=r,e[20]=v):v=e[20],v}let f;e[21]!==s?(f=vu(s),e[21]=s,e[22]=f):f=e[22];const m=f;if(m){let v;return e[23]!==m.path?(v=n.jsx(U3,{path:m.path},m.path),e[23]=m.path,e[24]=v):v=e[24],v}let p;e[25]!==s?(p=Qg(s),e[25]=s,e[26]=p):p=e[26];const g=p;if(g){let v;if(e[27]!==a||e[28]!==g.connectionId||e[29]!==g.toolName){let N;e[31]!==g.connectionId||e[32]!==g.toolName?(N=E=>E.appId===g.connectionId&&E.toolName===g.toolName,e[31]=g.connectionId,e[32]=g.toolName,e[33]=N):N=e[33],v=a.find(N),e[27]=a,e[28]=g.connectionId,e[29]=g.toolName,e[30]=v}else v=e[30];const y=v;let S;e[34]===Symbol.for("react.memo_cache_sentinel")?(S=n.jsx(Bi,{}),e[34]=S):S=e[34];const w=y?.args;let C;return e[35]!==s||e[36]!==g.connectionId||e[37]!==g.toolName||e[38]!==w?(C=n.jsx(D.Suspense,{fallback:S,children:n.jsx(zd,{connectionId:g.connectionId,toolName:g.toolName,args:w},s)}),e[35]=s,e[36]=g.connectionId,e[37]=g.toolName,e[38]=w,e[39]=C):C=e[39],C}let _;if(e[40]!==s||e[41]!==o){let v;e[43]!==s?(v=y=>y.id===s,e[43]=s,e[44]=v):v=e[44],_=o.find(v),e[40]=s,e[41]=o,e[42]=_}else _=e[42];const b=_;if(b){let v;e[45]===Symbol.for("react.memo_cache_sentinel")?(v=n.jsx(Bi,{}),e[45]=v):v=e[45];let y;return e[46]!==s||e[47]!==b.id||e[48]!==b.view.appId||e[49]!==b.view.args?(y=n.jsx(D.Suspense,{fallback:v,children:n.jsx(zd,{connectionId:b.view.appId,toolName:b.id,args:b.view.args},s)}),e[46]=s,e[47]=b.id,e[48]=b.view.appId,e[49]=b.view.args,e[50]=y):y=e[50],y}let x;return e[51]!==i?(x=n.jsx(id,{virtualMcpId:i}),e[51]=i,e[52]=x):x=e[52],x}function K3(t){const e=U.c(14),{taskId:s,virtualMcpId:i}=t;let r;e[0]!==s||e[1]!==i?(r={virtualMcpId:i,taskId:s},e[0]=s,e[1]=i,e[2]=r):r=e[2];const{activeTab:o,layoutTabs:a,expandedTools:l,automationTabParsed:d}=Yl(r);let c;e[3]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx(Bi,{}),e[3]=c):c=e[3];let h;e[4]!==o||e[5]!==d||e[6]!==l||e[7]!==a||e[8]!==s||e[9]!==i?(h=n.jsx(D.Suspense,{fallback:c,children:n.jsx(V3,{activeTab:o,virtualMcpId:i,taskId:s,layoutTabs:a,expandedTools:l,automationTabParsed:d})}),e[4]=o,e[5]=d,e[6]=l,e[7]=a,e[8]=s,e[9]=i,e[10]=h):h=e[10];let u;return e[11]!==o||e[12]!==h?(u=n.jsx(Zt,{children:h},o),e[11]=o,e[12]=h,e[13]=u):u=e[13],u}const Qs="setup";function q3(t){const e=U.c(35);let s;if(e[0]!==t.scriptTabs||e[1]!==t.scripts){let m;e[3]!==t.scriptTabs?(m=p=>!t.scriptTabs.includes(p),e[3]=t.scriptTabs,e[4]=m):m=e[4],s=t.scripts.filter(m),e[0]=t.scriptTabs,e[1]=t.scripts,e[2]=s}else s=e[2];const i=s;let r;e[5]!==t?(r=()=>{t.active===Qs?t.onToggle():t.onSelectTab(Qs)},e[5]=t,e[6]=r):r=e[6];const o=r,a=t.active===Qs;let l;e[7]!==o||e[8]!==t.open||e[9]!==a?(l=n.jsx(G3,{active:a,open:t.open,onClick:o}),e[7]=o,e[8]=t.open,e[9]=a,e[10]=l):l=e[10];let d;e[11]!==t?(d=t.scriptTabs.map(m=>n.jsx(X3,{active:t.active===m,onClick:()=>{t.active===m?t.onToggle():t.onSelectTab(m)},onClose:()=>t.onCloseScript(m),children:m},m)),e[11]=t,e[12]=d):d=e[12];let c;e[13]!==i||e[14]!==t.onAddScript?(c=n.jsx(J3,{scripts:i,onRun:t.onAddScript}),e[13]=i,e[14]=t.onAddScript,e[15]=c):c=e[15];let h;e[16]!==l||e[17]!==d||e[18]!==c?(h=n.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1 overflow-x-auto",children:[l,d,c]}),e[16]=l,e[17]=d,e[18]=c,e[19]=h):h=e[19];let u;e[20]!==t.onRestart||e[21]!==t.onResume||e[22]!==t.onRetry||e[23]!==t.onRunActiveScript||e[24]!==t.onStart||e[25]!==t.onStop||e[26]!==t.onStopActiveScript||e[27]!==t.scriptIsKilling||e[28]!==t.scriptIsRunning||e[29]!==t.showScriptControls||e[30]!==t.status?(u=t.showScriptControls?n.jsx(Z3,{isRunning:t.scriptIsRunning,isKilling:t.scriptIsKilling,onRun:t.onRunActiveScript,onStop:t.onStopActiveScript}):n.jsx(Y3,{status:t.status,onStart:t.onStart,onStop:t.onStop,onRestart:t.onRestart,onResume:t.onResume,onRetry:t.onRetry}),e[20]=t.onRestart,e[21]=t.onResume,e[22]=t.onRetry,e[23]=t.onRunActiveScript,e[24]=t.onStart,e[25]=t.onStop,e[26]=t.onStopActiveScript,e[27]=t.scriptIsKilling,e[28]=t.scriptIsRunning,e[29]=t.showScriptControls,e[30]=t.status,e[31]=u):u=e[31];let f;return e[32]!==h||e[33]!==u?(f=n.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-1 border-t border-b border-border bg-muted/60 px-3",children:[h,u]}),e[32]=h,e[33]=u,e[34]=f):f=e[34],f}function G3(t){const e=U.c(8),{active:s,open:i,onClick:r}=t,o=s&&i,a=s&&i,l=s?"border-border bg-background font-medium text-foreground shadow-sm":"border-transparent text-muted-foreground hover:bg-background/50 hover:text-foreground";let d;e[0]!==l?(d=ae("flex h-7 items-center gap-1.5 rounded-md border px-2.5 text-xs",l),e[0]=l,e[1]=d):d=e[1];let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx(q_,{className:"size-3.5"}),e[2]=c):c=e[2];let h;return e[3]!==r||e[4]!==o||e[5]!==a||e[6]!==d?(h=n.jsxs("button",{type:"button","aria-pressed":o,"aria-expanded":a,onClick:r,className:d,children:[c,"sandbox"]}),e[3]=r,e[4]=o,e[5]=a,e[6]=d,e[7]=h):h=e[7],h}function Y3(t){const e=U.c(24),{status:s,onStart:i,onStop:r,onRestart:o,onResume:a,onRetry:l}=t;if(s==="idle"&&i){let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx(Di,{className:"size-3.5"}),e[0]=d):d=e[0];let c;return e[1]!==i?(c=n.jsxs(ie,{variant:"outline",size:"sm",onClick:i,children:[d," Start"]}),e[1]=i,e[2]=c):c=e[2],c}if(s==="suspended"&&a){let d;e[3]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx(Di,{className:"size-3.5"}),e[3]=d):d=e[3];let c;return e[4]!==a?(c=n.jsxs(ie,{variant:"outline",size:"sm",onClick:a,children:[d," Resume"]}),e[4]=a,e[5]=c):c=e[5],c}if(s==="errored"&&l){let d;e[6]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx(Pn,{className:"size-3.5"}),e[6]=d):d=e[6];let c;return e[7]!==l?(c=n.jsxs(ie,{variant:"outline",size:"sm",onClick:l,children:[d," Retry"]}),e[7]=l,e[8]=c):c=e[8],c}if(s==="starting"||s==="running"){const d=s==="running"&&!!o,c=d?"rounded-r-none border-r-0":void 0;let h;e[9]!==c?(h=ae(c),e[9]=c,e[10]=h):h=e[10];let u;e[11]===Symbol.for("react.memo_cache_sentinel")?(u=n.jsx(Au,{className:"size-3.5"}),e[11]=u):u=e[11];let f;e[12]!==r||e[13]!==h?(f=n.jsx(Ne,{asChild:!0,children:n.jsxs(ie,{variant:"outline",size:"sm",onClick:r,className:h,children:[u," Stop"]})}),e[12]=r,e[13]=h,e[14]=f):f=e[14];let m;e[15]===Symbol.for("react.memo_cache_sentinel")?(m=n.jsx(Ee,{children:"Stop sandbox"}),e[15]=m):m=e[15];let p;e[16]!==f?(p=n.jsxs(Te,{children:[f,m]}),e[16]=f,e[17]=p):p=e[17];let g;e[18]!==o||e[19]!==d?(g=d&&n.jsxs(Wt,{children:[n.jsx(Vt,{asChild:!0,children:n.jsx(ie,{variant:"outline",size:"sm",className:"rounded-l-none px-1",children:n.jsx(cs,{className:"size-3"})})}),n.jsx(Kt,{align:"end",children:n.jsxs(Ue,{onClick:o,children:[n.jsx(Pn,{className:"size-3.5"})," Restart"]})})]}),e[18]=o,e[19]=d,e[20]=g):g=e[20];let _;return e[21]!==p||e[22]!==g?(_=n.jsxs("div",{className:"flex items-center",children:[p,g]}),e[21]=p,e[22]=g,e[23]=_):_=e[23],_}return null}function X3(t){const e=U.c(16),{active:s,onClick:i,onClose:r,children:o}=t,a=s?"border-border bg-background shadow-sm":"border-transparent hover:bg-background/50";let l;e[0]!==a?(l=ae("flex h-7 items-center rounded-md border text-xs",a),e[0]=a,e[1]=l):l=e[1];const d=r?"pl-2.5 pr-1":"px-2.5",c=s?"font-medium text-foreground":"text-muted-foreground hover:text-foreground";let h;e[2]!==d||e[3]!==c?(h=ae("flex h-full items-center",d,c),e[2]=d,e[3]=c,e[4]=h):h=e[4];let u;e[5]!==o||e[6]!==i||e[7]!==h?(u=n.jsx("button",{type:"button",onClick:i,className:h,children:o}),e[5]=o,e[6]=i,e[7]=h,e[8]=u):u=e[8];let f;e[9]!==o||e[10]!==r?(f=r&&n.jsx("button",{type:"button","aria-label":`Close ${o}`,onClick:r,className:"pr-1.5 text-muted-foreground hover:text-foreground",children:n.jsx(jl,{className:"size-3"})}),e[9]=o,e[10]=r,e[11]=f):f=e[11];let m;return e[12]!==l||e[13]!==u||e[14]!==f?(m=n.jsxs("div",{className:l,children:[u,f]}),e[12]=l,e[13]=u,e[14]=f,e[15]=m):m=e[15],m}function J3(t){const e=U.c(10),{scripts:s,onRun:i}=t,[r,o]=D.useState(!1);let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsxs(Te,{children:[n.jsx(Ne,{asChild:!0,children:n.jsx(Rs,{asChild:!0,children:n.jsx(ie,{variant:"ghost",size:"sm","aria-label":"Run script",children:n.jsx(Dt,{className:"size-3.5"})})})}),n.jsx(Ee,{children:"Run script"})]}),e[0]=a):a=e[0];let l;e[1]===Symbol.for("react.memo_cache_sentinel")?(l=n.jsx("div",{className:"px-2 py-1 text-[10px] uppercase tracking-wide text-muted-foreground",children:"run a script"}),e[1]=l):l=e[1];let d;e[2]!==i||e[3]!==s?(d=s.length===0?n.jsx("div",{className:"px-2 py-2 text-xs text-muted-foreground",children:"No scripts found"}):s.map(u=>n.jsxs("button",{type:"button",onClick:()=>{o(!1),i(u)},className:"w-full rounded-md px-2 py-1.5 text-left text-xs hover:bg-accent",children:["▸ ",u]},u)),e[2]=i,e[3]=s,e[4]=d):d=e[4];let c;e[5]!==d?(c=n.jsxs(Ps,{align:"start",className:"p-1 w-56",children:[l,d]}),e[5]=d,e[6]=c):c=e[6];let h;return e[7]!==r||e[8]!==c?(h=n.jsxs(As,{open:r,onOpenChange:o,children:[a,c]}),e[7]=r,e[8]=c,e[9]=h):h=e[9],h}function Z3(t){const e=U.c(13),{isRunning:s,isKilling:i,onRun:r,onStop:o}=t;if(i){let h;return e[0]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsxs(ie,{variant:"outline",size:"sm",disabled:!0,children:[n.jsx(Oe,{className:"size-3.5 animate-spin"})," Stopping…"]}),e[0]=h):h=e[0],h}if(!s){let h;e[1]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx(Di,{className:"size-3.5"}),e[1]=h):h=e[1];let u;e[2]!==r?(u=n.jsx(Ne,{asChild:!0,children:n.jsxs(ie,{variant:"outline",size:"sm",onClick:r,children:[h," Run"]})}),e[2]=r,e[3]=u):u=e[3];let f;e[4]===Symbol.for("react.memo_cache_sentinel")?(f=n.jsx(Ee,{children:"Start process"}),e[4]=f):f=e[4];let m;return e[5]!==u?(m=n.jsxs(Te,{children:[u,f]}),e[5]=u,e[6]=m):m=e[6],m}let a;e[7]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx(Au,{className:"size-3.5"}),e[7]=a):a=e[7];let l;e[8]!==o?(l=n.jsx(Ne,{asChild:!0,children:n.jsxs(ie,{variant:"outline",size:"sm",onClick:o,children:[a," Stop"]})}),e[8]=o,e[9]=l):l=e[9];let d;e[10]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx(Ee,{children:"Stop process"}),e[10]=d):d=e[10];let c;return e[11]!==l?(c=n.jsxs(Te,{children:[l,d]}),e[11]=l,e[12]=c):c=e[12],c}var zm=Object.defineProperty,Q3=Object.getOwnPropertyDescriptor,ek=(t,e)=>{for(var s in e)zm(t,s,{get:e[s],enumerable:!0})},rt=(t,e,s,i)=>{for(var r=i>1?void 0:i?Q3(e,s):e,o=t.length-1,a;o>=0;o--)(a=t[o])&&(r=(i?a(e,s,r):a(r))||r);return i&&r&&zm(e,s,r),r},_e=(t,e)=>(s,i)=>e(s,i,t),Fd="Terminal input",ka={get:()=>Fd,set:t=>Fd=t},Hd="Too much output to announce, navigate to rows manually to read",ja={get:()=>Hd,set:t=>Hd=t};function tk(t){return t.replace(/\r?\n/g,"\r")}function sk(t,e){return e?"\x1B[200~"+t+"\x1B[201~":t}function ik(t,e){t.clipboardData&&t.clipboardData.setData("text/plain",e.selectionText),t.preventDefault()}function nk(t,e,s,i){if(t.stopPropagation(),t.clipboardData){let r=t.clipboardData.getData("text/plain");Fm(r,e,s,i)}}function Fm(t,e,s,i){t=tk(t),t=sk(t,s.decPrivateModes.bracketedPasteMode&&i.rawOptions.ignoreBracketedPasteMode!==!0),s.triggerDataEvent(t,!0),e.value=""}function Hm(t,e,s){let i=s.getBoundingClientRect(),r=t.clientX-i.left-10,o=t.clientY-i.top-10;e.style.width="20px",e.style.height="20px",e.style.left=`${r}px`,e.style.top=`${o}px`,e.style.zIndex="1000",e.focus()}function Ud(t,e,s,i,r){Hm(t,e,s),r&&i.rightClickSelect(t),e.value=i.selectionText,e.select()}function Ms(t){return t>65535?(t-=65536,String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):String.fromCharCode(t)}function xo(t,e=0,s=t.length){let i="";for(let r=e;r<s;++r){let o=t[r];o>65535?(o-=65536,i+=String.fromCharCode((o>>10)+55296)+String.fromCharCode(o%1024+56320)):i+=String.fromCharCode(o)}return i}var rk=class{constructor(){this._interim=0}clear(){this._interim=0}decode(t,e){let s=t.length;if(!s)return 0;let i=0,r=0;if(this._interim){let o=t.charCodeAt(r++);56320<=o&&o<=57343?e[i++]=(this._interim-55296)*1024+o-56320+65536:(e[i++]=this._interim,e[i++]=o),this._interim=0}for(let o=r;o<s;++o){let a=t.charCodeAt(o);if(55296<=a&&a<=56319){if(++o>=s)return this._interim=a,i;let l=t.charCodeAt(o);56320<=l&&l<=57343?e[i++]=(a-55296)*1024+l-56320+65536:(e[i++]=a,e[i++]=l);continue}a!==65279&&(e[i++]=a)}return i}},ok=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(t,e){let s=t.length;if(!s)return 0;let i=0,r,o,a,l,d=0,c=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 _=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,b=_-p;for(;c<b;){if(c>=s)return 0;if(g=t[c++],(g&192)!==128){c--,f=!0;break}else this.interim[p++]=g,m<<=6,m|=g&63}f||(_===2?m<128?c--:e[i++]=m:_===3?m<2048||m>=55296&&m<=57343||m===65279||(e[i++]=m):m<65536||m>1114111||(e[i++]=m)),this.interim.fill(0)}let h=s-4,u=c;for(;u<s;){for(;u<h&&!((r=t[u])&128)&&!((o=t[u+1])&128)&&!((a=t[u+2])&128)&&!((l=t[u+3])&128);)e[i++]=r,e[i++]=o,e[i++]=a,e[i++]=l,u+=4;if(r=t[u++],r<128)e[i++]=r;else if((r&224)===192){if(u>=s)return this.interim[0]=r,i;if(o=t[u++],(o&192)!==128){u--;continue}if(d=(r&31)<<6|o&63,d<128){u--;continue}e[i++]=d}else if((r&240)===224){if(u>=s)return this.interim[0]=r,i;if(o=t[u++],(o&192)!==128){u--;continue}if(u>=s)return this.interim[0]=r,this.interim[1]=o,i;if(a=t[u++],(a&192)!==128){u--;continue}if(d=(r&15)<<12|(o&63)<<6|a&63,d<2048||d>=55296&&d<=57343||d===65279)continue;e[i++]=d}else if((r&248)===240){if(u>=s)return this.interim[0]=r,i;if(o=t[u++],(o&192)!==128){u--;continue}if(u>=s)return this.interim[0]=r,this.interim[1]=o,i;if(a=t[u++],(a&192)!==128){u--;continue}if(u>=s)return this.interim[0]=r,this.interim[1]=o,this.interim[2]=a,i;if(l=t[u++],(l&192)!==128){u--;continue}if(d=(r&7)<<18|(o&63)<<12|(a&63)<<6|l&63,d<65536||d>1114111)continue;e[i++]=d}}return i}},Um="",$s=" ",Xn=class Wm{constructor(){this.fg=0,this.bg=0,this.extended=new Gr}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 Wm;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}},Gr=class Vm{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 Vm(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Qt=class Km extends Xn{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new Gr,this.combinedData=""}static fromCharData(e){let s=new Km;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?Ms(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let s=!1;if(e[1].length>2)s=!0;else if(e[1].length===2){let i=e[1].charCodeAt(0);if(55296<=i&&i<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(i-55296)*1024+r-56320+65536|e[2]<<22:s=!0}else s=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;s&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Wd="di$target",Na="di$dependencies",Ko=new Map;function ak(t){return t[Na]||[]}function xt(t){if(Ko.has(t))return Ko.get(t);let e=function(s,i,r){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");lk(e,s,r)};return e._id=t,Ko.set(t,e),e}function lk(t,e,s){e[Wd]===e?e[Na].push({id:t,index:s}):(e[Na]=[{id:t,index:s}],e[Wd]=e)}var It=xt("BufferService"),qm=xt("CoreMouseService"),pi=xt("CoreService"),ck=xt("CharsetService"),gc=xt("InstantiationService"),Gm=xt("LogService"),Lt=xt("OptionsService"),Ym=xt("OscLinkService"),dk=xt("UnicodeService"),Jn=xt("DecorationService"),Ea=class{constructor(t,e,s){this._bufferService=t,this._optionsService=e,this._oscLinkService=s}provideLinks(t,e){let s=this._bufferService.buffer.lines.get(t-1);if(!s){e(void 0);return}let i=[],r=this._optionsService.rawOptions.linkHandler,o=new Qt,a=s.getTrimmedLength(),l=-1,d=-1,c=!1;for(let h=0;h<a;h++)if(!(d===-1&&!s.hasContent(h))){if(s.loadCell(h,o),o.hasExtendedAttrs()&&o.extended.urlId)if(d===-1){d=h,l=o.extended.urlId;continue}else c=o.extended.urlId!==l;else d!==-1&&(c=!0);if(c||d!==-1&&h===a-1){let u=this._oscLinkService.getLinkData(l)?.uri;if(u){let f={start:{x:d+1,y:t},end:{x:h+(!c&&h===a-1?1:0),y:t}},m=!1;if(!r?.allowNonHttpProtocols)try{let p=new URL(u);["http:","https:"].includes(p.protocol)||(m=!0)}catch{m=!0}m||i.push({text:u,range:f,activate:(p,g)=>r?r.activate(p,g,f):hk(p,g),hover:(p,g)=>r?.hover?.(p,g,f),leave:(p,g)=>r?.leave?.(p,g,f)})}c=!1,o.hasExtendedAttrs()&&o.extended.urlId?(d=h,l=o.extended.urlId):(d=-1,l=-1)}}e(i)}};Ea=rt([_e(0,It),_e(1,Lt),_e(2,Ym)],Ea);function hk(t,e){if(confirm(`Do you want to navigate to ${e}?
|
|
486
|
+
`);if(le.trim()){I(!0);try{X(),Ke("automation_improve_clicked",{automation_id:t,agent_id:r,instructions_length:le.length}),f(!0),await m({tiptapDoc:kf({managerAgentId:eu.AUTOMATION_MANAGER(o.id),managerName:"Automation Manager",kind:"automation",id:t,instructions:le})})}finally{I(!1)}}},F=e.models?.tier??"smart",H=e.models?.modelId&&e.models?.credentialId?{modelId:e.models.modelId,credentialId:e.models.credentialId,title:e.models.modelTitle??e.models.modelId}:null,z=Wh({defaultValues:{name:e.name,active:e.active,tier:F,modelOverride:H,tools:e.tools??null,maxAgentSteps:e.maxAgentSteps??null}}),W=z.watch("active"),[q,K]=D.useReducer(w3,null),Z=()=>{q!==null&&(Ke("automation_updated",{automation_id:t,agent_id:r,fields:Array.from(q.fields),save_count:q.saveCount,edit_duration_ms:Date.now()-q.start}),K({type:"reset"}))},Y=async()=>{const ee=z.control._formState.dirtyFields,le=Object.keys(ee);if(le.length===0&&!L)return!0;const ce=z.getValues(),fe=z.control._defaultValues;z.reset(ce,{keepValues:!0});const J=L;P(!1);const te={tier:ce.tier,...ce.modelOverride?{modelId:ce.modelOverride.modelId,credentialId:ce.modelOverride.credentialId,modelTitle:ce.modelOverride.title}:{}},oe={id:t,name:ce.name,active:ce.active,models:te,tools:ce.tools,maxAgentSteps:ce.maxAgentSteps,messages:mg(g),temperature:0};try{await a.mutateAsync(oe)}catch{return z.reset(fe,{keepValues:!0}),J&&P(!0),!1}const de=[...le];return J&&de.push("messages"),K({type:"accumulate",now:Date.now(),fields:de}),$(),!0},{schedule:G,flush:Q}=Lr({save:Y}),{schedule:$,flush:X}=Lr({delayMs:3e4,save:async()=>Z()});D.useEffect(()=>{const ee=z.watch(()=>G());return()=>ee.unsubscribe()},[]);const V=ee=>{if(_(ee),!A){O(!0);return}P(!0),G()},se=async()=>{Ke("automation_test_clicked",{automation_id:t,agent_id:r});const ee=await Q();if(X(),!!ee){if(!g){he.error("No instructions configured for this automation");return}try{const le=await d.mutateAsync(t);le.threadId&&(f(!0),u(le.threadId))}catch{}}};return n.jsxs(n.Fragment,{children:[s&&n.jsx("div",{className:"flex items-center pb-4 shrink-0",children:n.jsxs(ie,{variant:"ghost",size:"sm",onClick:s,children:[n.jsx(zu,{size:14}),"Back to list"]})}),n.jsxs("div",{className:"flex flex-col gap-8",children:[n.jsxs("div",{className:"flex flex-col gap-1.5",children:[n.jsxs("div",{className:"flex items-center justify-between gap-4",children:[n.jsx(Ht,{control:z.control,name:"name",render:({field:ee})=>n.jsx(ze,{...ee,placeholder:"Automation name",className:"border border-transparent shadow-none px-0 text-lg font-medium h-auto focus-visible:ring-0 focus-visible:border-border bg-transparent flex-1",style:{boxShadow:"none"}})}),i&&n.jsx(ie,{variant:"ghost",size:"icon",className:"text-muted-foreground hover:text-destructive shrink-0",onClick:i,children:n.jsx(es,{size:14})})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Ht,{control:z.control,name:"active",render:({field:ee})=>n.jsx(On,{checked:ee.value,onCheckedChange:le=>{ee.onChange(le),Q()},className:"cursor-pointer"})}),n.jsx("span",{className:"text-sm text-muted-foreground",children:W?"Active":"Inactive"}),n.jsx("span",{className:"text-muted-foreground/50 text-sm",children:"·"}),n.jsx(jf,{id:e.created_by,size:"2xs",className:"text-sm text-muted-foreground"})]})]}),n.jsxs("div",{className:"flex flex-col gap-2.5",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Starter"}),n.jsx(x3,{automationId:t,open:b,onOpenChange:x,onCustomSelect:()=>{w(!0),R(!1),N("")},onEventSelect:()=>{R(!0),w(!1)},onWebhookCreated:ee=>{Ke("automation_trigger_added",{automation_id:t,trigger_type:"webhook"}),k(ee)}})]}),e.triggers.length===0&&!S?n.jsx("div",{className:"rounded-lg border border-dashed border-border px-4 py-6 text-center",children:n.jsxs("p",{className:"text-sm text-muted-foreground",children:["When should this automation run?"," ",n.jsx("button",{type:"button",className:"text-foreground underline underline-offset-2 cursor-pointer hover:text-foreground/80 transition-colors",onClick:()=>x(!0),children:"Add a starter"})," ","to get going."]})}):n.jsx("div",{className:"flex flex-col gap-2",children:e.triggers.map(ee=>n.jsx(b3,{trigger:ee,automationId:t,connectionName:ee.connection_id?h.get(ee.connection_id):void 0},ee.id))}),S&&n.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2.5 rounded-lg border border-border bg-background group",children:[n.jsx(kn,{size:14,className:"text-muted-foreground shrink-0"}),n.jsx("input",{type:"text",value:C,onChange:ee=>N(ee.target.value),onBlur:async()=>{const ee=C.trim();if(!(!ee||!An(ee)))try{await l.mutateAsync({automation_id:t,type:"cron",cron_expression:ee}),Ke("automation_trigger_added",{automation_id:t,trigger_type:"cron"}),he.success("Starter added"),w(!1),N("")}catch{he.error("Failed to add starter")}},onKeyDown:async ee=>{const le=C.trim();ee.key==="Enter"&&le&&An(le)&&ee.target.blur(),ee.key==="Escape"&&(w(!1),N(""))},placeholder:"0 9 * * 1-5",className:"flex-1 text-sm font-mono bg-transparent outline-none placeholder:text-muted-foreground/40",autoFocus:!0}),C&&!An(C)&&n.jsx("span",{className:"text-xs text-muted-foreground/60 shrink-0",children:"invalid"}),l.isPending&&n.jsx(Oe,{size:13,className:"animate-spin text-muted-foreground shrink-0"}),n.jsx("button",{type:"button",className:"shrink-0 p-0.5 rounded text-muted-foreground opacity-0 group-hover:opacity-100 hover:text-foreground transition-opacity",onClick:()=>{w(!1),N("")},children:n.jsx(Hs,{size:13})})]}),E&&n.jsx(D.Suspense,{fallback:n.jsxs("div",{className:"flex items-center gap-2 px-3 py-3 rounded-lg border border-border bg-background",children:[n.jsx(Oe,{size:13,className:"animate-spin text-muted-foreground"}),n.jsx("span",{className:"text-sm text-muted-foreground",children:"Loading connections..."})]}),children:n.jsx(C3,{automationId:t,onDone:()=>R(!1)})}),n.jsx(Bm,{open:T!==null,onOpenChange:ee=>{ee||k(null)},url:T?.url??null,token:T?.token??null})]}),n.jsxs("div",{className:"flex flex-col gap-2.5",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Instructions"}),n.jsxs(ie,{variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",disabled:j||!g,onClick:B,children:[n.jsx(Zs,{size:13}),"Improve"]})]}),n.jsx(dg,{tiptapDoc:g,setTiptapDoc:V,placeholder:"What should this automation do?",children:n.jsxs("div",{className:"rounded-xl border border-border min-h-[120px] flex flex-col",children:[n.jsx(hg,{virtualMcpId:r||null,className:"max-h-[45vh]"}),n.jsx("div",{className:"@container/chat-bottom flex items-center justify-end gap-1.5 p-2.5",children:n.jsxs(Te,{children:[n.jsx(Ne,{asChild:!0,children:n.jsxs(ie,{type:"button",variant:"default",className:"h-8 gap-1.5 rounded-md px-3 text-sm font-medium",onClick:se,disabled:!r,children:[n.jsx(S1,{size:16}),"Test"]})}),n.jsx(Ee,{children:"Test Automation"})]})})]})})]}),n.jsxs(Pg,{open:v,onOpenChange:y,className:"flex flex-col gap-2.5",children:[n.jsxs(Dg,{className:"group flex w-fit cursor-pointer items-center gap-1.5",children:[n.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Advanced"}),n.jsx(cs,{size:14,className:"text-muted-foreground/60 transition-transform group-data-[state=open]:rotate-180"})]}),n.jsxs(Ig,{className:"flex flex-col gap-5 pt-0.5",children:[n.jsx(i3,{tier:z.watch("tier"),onTierChange:ee=>z.setValue("tier",ee,{shouldDirty:!0}),override:z.watch("modelOverride"),onOverrideChange:ee=>z.setValue("modelOverride",ee,{shouldDirty:!0})}),n.jsx(a3,{agentId:r||null,value:z.watch("tools"),onChange:ee=>z.setValue("tools",ee,{shouldDirty:!0})}),n.jsxs("div",{className:"flex flex-col gap-2",children:[n.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Max steps"}),n.jsx(ze,{type:"number",min:1,max:100,className:"w-40",placeholder:`${S3} (default)`,value:z.watch("maxAgentSteps")??"",onChange:ee=>{const le=ee.target.value.trim(),ce=le===""?null:Number(le);z.setValue("maxAgentSteps",ce===null||Number.isNaN(ce)?null:ce,{shouldDirty:!0})}})]})]})]})]})]})}function Bi(){const t=U.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx("div",{"data-testid":"main-panel-loading",className:"flex h-full w-full items-center justify-center",children:n.jsx(Oe,{size:20,className:"animate-spin text-muted-foreground"})}),t[0]=e):e=t[0],e}const Mm=[{key:"24h",label:"Last 24 hours",ms:1440*60*1e3},{key:"7d",label:"Last 7 days",ms:10080*60*1e3},{key:"30d",label:"Last 30 days",ms:720*60*60*1e3}];function $m(t){const e=Mm.find(i=>i.key===t).ms,s=Date.now();return{startDate:new Date(s-e).toISOString(),endDate:new Date(s).toISOString()}}function T3(t){const e=U.c(12),{automationId:s,triggerIds:i}=t,[r,o]=D.useState("30d"),[a,l]=D.useState(R3);let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=p=>{const g=p;o(g),l($m(g))},e[0]=d):d=e[0];let c;e[1]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx(kt,{className:"w-44",children:n.jsx(Rt,{})}),e[1]=c):c=e[1];let h;e[2]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx(jt,{children:Mm.map(A3)}),e[2]=h):h=e[2];let u;e[3]!==r?(u=n.jsx("div",{className:"flex items-center justify-end",children:n.jsxs(Nt,{value:r,onValueChange:d,children:[c,h]})}),e[3]=r,e[4]=u):u=e[4];let f;e[5]!==s||e[6]!==a||e[7]!==i?(f=n.jsx(j1,{automationId:s,triggerIds:i,range:a}),e[5]=s,e[6]=a,e[7]=i,e[8]=f):f=e[8];let m;return e[9]!==u||e[10]!==f?(m=n.jsxs("div",{className:"flex flex-col gap-5",children:[u,f]}),e[9]=u,e[10]=f,e[11]=m):m=e[11],m}function A3(t){return n.jsx(tt,{value:t.key,children:t.label},t.key)}function R3(){return $m("30d")}function P3(t){const e=U.c(5),{tabId:s}=t;let i;e[0]!==s?(i=pu(s),e[0]=s,e[1]=i):i=e[1];const r=i;if(!r)return null;let o;e[2]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx(Bi,{}),e[2]=o):o=e[2];let a;return e[3]!==r.id?(a=n.jsx(D.Suspense,{fallback:o,children:n.jsx(D3,{id:r.id})}),e[3]=r.id,e[4]=a):a=e[4],a}function D3(t){const e=U.c(24),{id:s}=t,i=qt(),{data:r,isLoading:o}=I1(s),[a,l]=D.useState("settings");let d;e[0]!==i?(d=()=>{i({to:".",search:L3,replace:!0})},e[0]=i,e[1]=d):d=e[1];const c=d;if(o){let y;return e[2]===Symbol.for("react.memo_cache_sentinel")?(y=n.jsx(Bi,{}),e[2]=y):y=e[2],y}if(!r){let y;return e[3]===Symbol.for("react.memo_cache_sentinel")?(y=n.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-muted-foreground",children:"Automation not found"}),e[3]=y):y=e[3],y}let h;e[4]!==r.triggers?(h=r.triggers.map(I3),e[4]=r.triggers,e[5]=h):h=e[5];const u=h;let f;e[6]===Symbol.for("react.memo_cache_sentinel")?(f=n.jsx(zu,{size:14}),e[6]=f):f=e[6];let m;e[7]!==c?(m=n.jsxs(ie,{variant:"ghost",size:"sm",onClick:c,children:[f,"Back to list"]}),e[7]=c,e[8]=m):m=e[8];let p;e[9]===Symbol.for("react.memo_cache_sentinel")?(p=[{id:"settings",label:"Settings"},{id:"runs",label:"Runs"}],e[9]=p):p=e[9];let g;e[10]===Symbol.for("react.memo_cache_sentinel")?(g=y=>l(y),e[10]=g):g=e[10];let _;e[11]!==a?(_=n.jsx(Hu,{tabs:p,activeTab:a,onTabChange:g}),e[11]=a,e[12]=_):_=e[12];let b;e[13]!==m||e[14]!==_?(b=n.jsxs("div",{className:"flex items-center justify-between pb-4 shrink-0",children:[m,_]}),e[13]=m,e[14]=_,e[15]=b):b=e[15];let x;e[16]!==r||e[17]!==s||e[18]!==a||e[19]!==u?(x=a==="settings"?n.jsx(E3,{automationId:s,automation:r}):n.jsx(T3,{automationId:s,triggerIds:u}),e[16]=r,e[17]=s,e[18]=a,e[19]=u,e[20]=x):x=e[20];let v;return e[21]!==b||e[22]!==x?(v=n.jsx(os,{children:n.jsx(os.Content,{children:n.jsxs(os.Body,{children:[b,x]})})}),e[21]=b,e[22]=x,e[23]=v):v=e[23],v}function I3(t){return t.id}function L3(t){return{...t,main:"automations"}}function O3(t){const e=U.c(20),{virtualMcpId:s}=t,i=qt(),{data:r}=L1(s),o=r===void 0?[]:r,{create:a}=qn(),[l,d]=D.useState(""),c=l.toLowerCase(),h=o.filter(T=>T.name.toLowerCase().includes(c));let u;e[0]!==i?(u=T=>i({to:".",search:k=>({...k,main:"automation:"+T}),replace:!0}),e[0]=i,e[1]=u):u=e[1];const f=u,m=async()=>{if(a.isPending)return;Ke("automation_new_clicked",{virtual_mcp_id:s,existing_count:o.length});const T=await a.mutateAsync(O1(s));f(T.id)};let p;e[2]===Symbol.for("react.memo_cache_sentinel")?(p=n.jsx(Dt,{size:14}),e[2]=p):p=e[2];let g;e[3]!==a.isPending||e[4]!==m?(g=n.jsxs(ie,{size:"sm",onClick:m,disabled:a.isPending,children:[p,"New automation"]}),e[3]=a.isPending,e[4]=m,e[5]=g):g=e[5];const _=g,b=os,x=os,v=os;let y;e[6]===Symbol.for("react.memo_cache_sentinel")?(y=n.jsx(os.Title,{children:"Automations"}),e[6]=y):y=e[6];const S=o.length>0&&n.jsx(Fu,{value:l,onChange:d,placeholder:"Search automations...",className:"w-full md:w-[375px]"});let w;e[7]!==_||e[8]!==S?(w=n.jsxs("div",{className:"flex flex-col gap-6",children:[y,n.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[S,_]})]}),e[7]=_,e[8]=S,e[9]=w):w=e[9];const C=o.length===0?n.jsx("div",{className:"flex items-center justify-center py-20",children:n.jsx(Cr,{image:n.jsx(Mn,{size:48,className:"text-muted-foreground"}),title:"No automations yet",description:"Create your first automation to run this agent on a schedule or in response to events.",actions:_})}):h.length===0?n.jsx("div",{className:"flex items-center justify-center py-20",children:n.jsx(Cr,{image:n.jsx(Mn,{size:48,className:"text-muted-foreground"}),title:"No automations found",description:`No automations match "${l}"`})}):n.jsx("div",{className:"mt-6 rounded-xl border border-border overflow-hidden",children:h.map(T=>n.jsx(B1,{automation:T,onClick:()=>f(T.id)},T.id))});let N;e[10]!==C||e[11]!==v.Body||e[12]!==w?(N=n.jsxs(v.Body,{children:[w,C]}),e[10]=C,e[11]=v.Body,e[12]=w,e[13]=N):N=e[13];let E;e[14]!==N||e[15]!==x.Content?(E=n.jsx(x.Content,{children:N}),e[14]=N,e[15]=x.Content,e[16]=E):E=e[16];let R;return e[17]!==b||e[18]!==E?(R=n.jsx(b,{children:E}),e[17]=b,e[18]=E,e[19]=R):R=e[19],R}function B3(t){const e=U.c(3),{virtualMcpId:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx(Bi,{}),e[0]=i):i=e[0];let r;return e[1]!==s?(r=n.jsx(D.Suspense,{fallback:i,children:n.jsx(O3,{virtualMcpId:s})}),e[1]=s,e[2]=r):r=e[2],r}function M3(t){const e=U.c(37),{file:s,onClose:i}=t;let r,o;e[0]!==s.filename?(r=n.jsx(Pi,{filename:s.filename,className:"h-4.5 w-3.5 shrink-0"}),o=n.jsx("span",{className:"truncate text-xs font-medium text-foreground",children:s.filename}),e[0]=s.filename,e[1]=r,e[2]=o):(r=e[1],o=e[2]);let a;e[3]!==s.size?(a=l_(s.size),e[3]=s.size,e[4]=a):a=e[4];let l;e[5]!==a?(l=n.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:a}),e[5]=a,e[6]=l):l=e[6];let d;e[7]!==r||e[8]!==o||e[9]!==l?(d=n.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2 px-2",children:[r,o,l]}),e[7]=r,e[8]=o,e[9]=l,e[10]=d):d=e[10];let c;e[11]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx(Y_,{size:14}),e[11]=c):c=e[11];let h;e[12]!==s.downloadUrl||e[13]!==s.filename?(h=n.jsx(Ne,{asChild:!0,children:n.jsx(ie,{variant:"ghost",size:"icon",asChild:!0,children:n.jsx("a",{href:s.downloadUrl,download:s.filename,children:c})})}),e[12]=s.downloadUrl,e[13]=s.filename,e[14]=h):h=e[14];let u;e[15]===Symbol.for("react.memo_cache_sentinel")?(u=n.jsx(Ee,{side:"bottom",children:"Download"}),e[15]=u):u=e[15];let f;e[16]!==h?(f=n.jsxs(Te,{children:[h,u]}),e[16]=h,e[17]=f):f=e[17];let m;e[18]!==s.downloadUrl?(m=()=>window.open(s.downloadUrl,"_blank","noopener"),e[18]=s.downloadUrl,e[19]=m):m=e[19];let p;e[20]===Symbol.for("react.memo_cache_sentinel")?(p=n.jsx(hi,{size:14}),e[20]=p):p=e[20];let g;e[21]!==m?(g=n.jsx(Ne,{asChild:!0,children:n.jsx(ie,{variant:"ghost",size:"icon",onClick:m,children:p})}),e[21]=m,e[22]=g):g=e[22];let _;e[23]===Symbol.for("react.memo_cache_sentinel")?(_=n.jsx(Ee,{side:"bottom",children:"Open in new tab"}),e[23]=_):_=e[23];let b;e[24]!==g?(b=n.jsxs(Te,{children:[g,_]}),e[24]=g,e[25]=b):b=e[25];let x;e[26]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsx(Hs,{size:14}),e[26]=x):x=e[26];let v;e[27]!==i?(v=n.jsx(Ne,{asChild:!0,children:n.jsx(ie,{variant:"ghost",size:"icon",onClick:i,children:x})}),e[27]=i,e[28]=v):v=e[28];let y;e[29]===Symbol.for("react.memo_cache_sentinel")?(y=n.jsx(Ee,{side:"bottom",children:"Close"}),e[29]=y):y=e[29];let S;e[30]!==v?(S=n.jsxs(Te,{children:[v,y]}),e[30]=v,e[31]=S):S=e[31];let w;return e[32]!==b||e[33]!==S||e[34]!==d||e[35]!==f?(w=n.jsxs("div",{className:"flex h-9 shrink-0 items-center gap-1 border-b border-border/60 px-2",children:[d,f,b,S]}),e[32]=b,e[33]=S,e[34]=d,e[35]=f,e[36]=w):w=e[36],w}function $3(t){const e=U.c(24),{fileKey:s,taskId:i}=t,r=qt(),{data:o,isPending:a}=Jh(i);let l;e[0]!==s||e[1]!==o?(l=o?.find(p=>p.key===s)??null,e[0]=s,e[1]=o,e[2]=l):l=e[2];const d=l;let c;e[3]!==r?(c=()=>r({to:".",search:z3,replace:!0}),e[3]=r,e[4]=c):c=e[4];const h=c;if(!d){if(a){let v;return e[5]===Symbol.for("react.memo_cache_sentinel")?(v=n.jsx("div",{className:"h-full w-full bg-background",children:n.jsx(o_,{})}),e[5]=v):v=e[5],v}let p;e[6]!==s?(p=s.split("/").pop()??s,e[6]=s,e[7]=p):p=e[7];let g;e[8]!==p?(g=n.jsx(Pi,{filename:p,className:"h-7.5 w-6"}),e[8]=p,e[9]=g):g=e[9];let _;e[10]===Symbol.for("react.memo_cache_sentinel")?(_=n.jsx("span",{className:"text-sm text-muted-foreground",children:"This file is no longer available."}),e[10]=_):_=e[10];let b;e[11]!==h?(b=n.jsx(ie,{variant:"ghost",size:"sm",onClick:h,children:"Close"}),e[11]=h,e[12]=b):b=e[12];let x;return e[13]!==g||e[14]!==b?(x=n.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-2 bg-background",children:[g,_,b]}),e[13]=g,e[14]=b,e[15]=x):x=e[15],x}let u;e[16]!==d||e[17]!==h?(u=n.jsx(M3,{file:d,onClose:h}),e[16]=d,e[17]=h,e[18]=u):u=e[18];let f;e[19]!==d?(f=n.jsx("div",{className:"relative min-h-0 flex-1",children:n.jsx(a_,{file:d})}),e[19]=d,e[20]=f):f=e[20];let m;return e[21]!==u||e[22]!==f?(m=n.jsxs("div",{className:"flex h-full w-full flex-col bg-background",children:[u,f]}),e[21]=u,e[22]=f,e[23]=m):m=e[23],m}function z3(t){return{...t,main:"0"}}const Vo="home";function F3(t){const e=U.c(5),{label:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx(wl,{className:"aspect-video w-2/3 max-w-xl"}),e[0]=i):i=e[0];let r;e[1]!==s?(r=s&&n.jsx("p",{className:"text-xs text-muted-foreground",children:s}),e[1]=s,e[2]=r):r=e[2];let o;return e[3]!==r?(o=n.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-3 bg-background",children:[i,r]}),e[3]=r,e[4]=o):o=e[4],o}function H3(t){const e=U.c(15),{path:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={refetchIntervalWhenAbsent:2e3},e[0]=i):i=e[0];const r=c_(Vo,s,i),o=d_(Vo)(s);if(r.isPending||!r.data){const f=!r.isPending&&!r.data?"Waiting for the deck to sync…":void 0;let m;return e[1]!==f?(m=n.jsx(F3,{label:f}),e[1]=f,e[2]=m):m=e[2],m}let a;e[3]!==r.data?(a=h_(r.data),e[3]=r.data,e[4]=a):a=e[4];const l=r.data.shareMode??"private",d=r.data.effectivePublic??!1,c=window.location.origin+o;let h;e[5]!==s||e[6]!==l||e[7]!==d||e[8]!==c?(h=n.jsx(u_,{volume:Vo,path:s,shareMode:l,effectivePublic:d,url:c}),e[5]=s,e[6]=l,e[7]=d,e[8]=c,e[9]=h):h=e[9];let u;return e[10]!==s||e[11]!==o||e[12]!==a||e[13]!==h?(u=n.jsx(f_,{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 U3(t){const e=U.c(5),{path:s}=t,i=qt();let r;e[0]!==i?(r=()=>i({to:".",search:W3,replace:!0}),e[0]=i,e[1]=r):r=e[1];const o=r;let a;return e[2]!==o||e[3]!==s?(a=n.jsx(m_,{previewPath:s,onClose:o,showSeeInLibrary:!0}),e[2]=o,e[3]=s,e[4]=a):a=e[4],a}function W3(t){return{...t,main:"0"}}const zd=D.lazy(()=>ls(()=>import("./project-app-view-C9CksfQE.js"),__vite__mapDeps([153,1,2,44,7,8,9,10,11,12,13,14,15,16,6,3,4,5,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,118,100,91,88,101,102,80,81,82,83,84,85,86,87,89,90,92,93,94,95,96,103,104,105,106,107,108,109,110,111,79,112,113,114,115,116,117,119,120,121,122,98,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140])).then(t=>({default:t.AppViewContent})));function V3(t){const e=U.c(53),{activeTab:s,virtualMcpId:i,taskId:r,layoutTabs:o,expandedTools:a,automationTabParsed:l}=t;if(Zg(s)){let v;return e[0]!==i?(v=n.jsx(id,{virtualMcpId:i}),e[0]=i,e[1]=v):v=e[1],v}if(s==="git"){let v;return e[2]!==i?(v=n.jsx(e0,{virtualMcpId:i}),e[2]=i,e[3]=v):v=e[3],v}if(s==="automations"){let v;return e[4]!==i?(v=n.jsx(B3,{virtualMcpId:i}),e[4]=i,e[5]=v):v=e[5],v}if(s==="preview"){let v;return e[6]!==i?(v=n.jsx(o2,{virtualMcpId:i}),e[6]=i,e[7]=v):v=e[7],v}if(s==="content"){let v;return e[8]!==i?(v=n.jsx(e3,{virtualMcpId:i}),e[8]=i,e[9]=v):v=e[9],v}if(l){let v;return e[10]!==s?(v=n.jsx(P3,{tabId:s}),e[10]=s,e[11]=v):v=e[11],v}let d;e[12]!==s?(d=_u(s),e[12]=s,e[13]=d):d=e[13];const c=d;if(c){let v;return e[14]!==c.path?(v=n.jsx(H3,{path:c.path},c.path),e[14]=c.path,e[15]=v):v=e[15],v}let h;e[16]!==s?(h=gu(s),e[16]=s,e[17]=h):h=e[17];const u=h;if(u){let v;return e[18]!==u.key||e[19]!==r?(v=n.jsx($3,{fileKey:u.key,taskId:r}),e[18]=u.key,e[19]=r,e[20]=v):v=e[20],v}let f;e[21]!==s?(f=vu(s),e[21]=s,e[22]=f):f=e[22];const m=f;if(m){let v;return e[23]!==m.path?(v=n.jsx(U3,{path:m.path},m.path),e[23]=m.path,e[24]=v):v=e[24],v}let p;e[25]!==s?(p=Qg(s),e[25]=s,e[26]=p):p=e[26];const g=p;if(g){let v;if(e[27]!==a||e[28]!==g.connectionId||e[29]!==g.toolName){let N;e[31]!==g.connectionId||e[32]!==g.toolName?(N=E=>E.appId===g.connectionId&&E.toolName===g.toolName,e[31]=g.connectionId,e[32]=g.toolName,e[33]=N):N=e[33],v=a.find(N),e[27]=a,e[28]=g.connectionId,e[29]=g.toolName,e[30]=v}else v=e[30];const y=v;let S;e[34]===Symbol.for("react.memo_cache_sentinel")?(S=n.jsx(Bi,{}),e[34]=S):S=e[34];const w=y?.args;let C;return e[35]!==s||e[36]!==g.connectionId||e[37]!==g.toolName||e[38]!==w?(C=n.jsx(D.Suspense,{fallback:S,children:n.jsx(zd,{connectionId:g.connectionId,toolName:g.toolName,args:w},s)}),e[35]=s,e[36]=g.connectionId,e[37]=g.toolName,e[38]=w,e[39]=C):C=e[39],C}let _;if(e[40]!==s||e[41]!==o){let v;e[43]!==s?(v=y=>y.id===s,e[43]=s,e[44]=v):v=e[44],_=o.find(v),e[40]=s,e[41]=o,e[42]=_}else _=e[42];const b=_;if(b){let v;e[45]===Symbol.for("react.memo_cache_sentinel")?(v=n.jsx(Bi,{}),e[45]=v):v=e[45];let y;return e[46]!==s||e[47]!==b.id||e[48]!==b.view.appId||e[49]!==b.view.args?(y=n.jsx(D.Suspense,{fallback:v,children:n.jsx(zd,{connectionId:b.view.appId,toolName:b.id,args:b.view.args},s)}),e[46]=s,e[47]=b.id,e[48]=b.view.appId,e[49]=b.view.args,e[50]=y):y=e[50],y}let x;return e[51]!==i?(x=n.jsx(id,{virtualMcpId:i}),e[51]=i,e[52]=x):x=e[52],x}function K3(t){const e=U.c(14),{taskId:s,virtualMcpId:i}=t;let r;e[0]!==s||e[1]!==i?(r={virtualMcpId:i,taskId:s},e[0]=s,e[1]=i,e[2]=r):r=e[2];const{activeTab:o,layoutTabs:a,expandedTools:l,automationTabParsed:d}=Yl(r);let c;e[3]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx(Bi,{}),e[3]=c):c=e[3];let h;e[4]!==o||e[5]!==d||e[6]!==l||e[7]!==a||e[8]!==s||e[9]!==i?(h=n.jsx(D.Suspense,{fallback:c,children:n.jsx(V3,{activeTab:o,virtualMcpId:i,taskId:s,layoutTabs:a,expandedTools:l,automationTabParsed:d})}),e[4]=o,e[5]=d,e[6]=l,e[7]=a,e[8]=s,e[9]=i,e[10]=h):h=e[10];let u;return e[11]!==o||e[12]!==h?(u=n.jsx(Zt,{children:h},o),e[11]=o,e[12]=h,e[13]=u):u=e[13],u}const Qs="setup";function q3(t){const e=U.c(35);let s;if(e[0]!==t.scriptTabs||e[1]!==t.scripts){let m;e[3]!==t.scriptTabs?(m=p=>!t.scriptTabs.includes(p),e[3]=t.scriptTabs,e[4]=m):m=e[4],s=t.scripts.filter(m),e[0]=t.scriptTabs,e[1]=t.scripts,e[2]=s}else s=e[2];const i=s;let r;e[5]!==t?(r=()=>{t.active===Qs?t.onToggle():t.onSelectTab(Qs)},e[5]=t,e[6]=r):r=e[6];const o=r,a=t.active===Qs;let l;e[7]!==o||e[8]!==t.open||e[9]!==a?(l=n.jsx(G3,{active:a,open:t.open,onClick:o}),e[7]=o,e[8]=t.open,e[9]=a,e[10]=l):l=e[10];let d;e[11]!==t?(d=t.scriptTabs.map(m=>n.jsx(X3,{active:t.active===m,onClick:()=>{t.active===m?t.onToggle():t.onSelectTab(m)},onClose:()=>t.onCloseScript(m),children:m},m)),e[11]=t,e[12]=d):d=e[12];let c;e[13]!==i||e[14]!==t.onAddScript?(c=n.jsx(J3,{scripts:i,onRun:t.onAddScript}),e[13]=i,e[14]=t.onAddScript,e[15]=c):c=e[15];let h;e[16]!==l||e[17]!==d||e[18]!==c?(h=n.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1 overflow-x-auto",children:[l,d,c]}),e[16]=l,e[17]=d,e[18]=c,e[19]=h):h=e[19];let u;e[20]!==t.onRestart||e[21]!==t.onResume||e[22]!==t.onRetry||e[23]!==t.onRunActiveScript||e[24]!==t.onStart||e[25]!==t.onStop||e[26]!==t.onStopActiveScript||e[27]!==t.scriptIsKilling||e[28]!==t.scriptIsRunning||e[29]!==t.showScriptControls||e[30]!==t.status?(u=t.showScriptControls?n.jsx(Z3,{isRunning:t.scriptIsRunning,isKilling:t.scriptIsKilling,onRun:t.onRunActiveScript,onStop:t.onStopActiveScript}):n.jsx(Y3,{status:t.status,onStart:t.onStart,onStop:t.onStop,onRestart:t.onRestart,onResume:t.onResume,onRetry:t.onRetry}),e[20]=t.onRestart,e[21]=t.onResume,e[22]=t.onRetry,e[23]=t.onRunActiveScript,e[24]=t.onStart,e[25]=t.onStop,e[26]=t.onStopActiveScript,e[27]=t.scriptIsKilling,e[28]=t.scriptIsRunning,e[29]=t.showScriptControls,e[30]=t.status,e[31]=u):u=e[31];let f;return e[32]!==h||e[33]!==u?(f=n.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-1 border-t border-b border-border bg-muted/60 px-3",children:[h,u]}),e[32]=h,e[33]=u,e[34]=f):f=e[34],f}function G3(t){const e=U.c(8),{active:s,open:i,onClick:r}=t,o=s&&i,a=s&&i,l=s?"border-border bg-background font-medium text-foreground shadow-sm":"border-transparent text-muted-foreground hover:bg-background/50 hover:text-foreground";let d;e[0]!==l?(d=ae("flex h-7 items-center gap-1.5 rounded-md border px-2.5 text-xs",l),e[0]=l,e[1]=d):d=e[1];let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx(q_,{className:"size-3.5"}),e[2]=c):c=e[2];let h;return e[3]!==r||e[4]!==o||e[5]!==a||e[6]!==d?(h=n.jsxs("button",{type:"button","aria-pressed":o,"aria-expanded":a,onClick:r,className:d,children:[c,"sandbox"]}),e[3]=r,e[4]=o,e[5]=a,e[6]=d,e[7]=h):h=e[7],h}function Y3(t){const e=U.c(24),{status:s,onStart:i,onStop:r,onRestart:o,onResume:a,onRetry:l}=t;if(s==="idle"&&i){let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx(Di,{className:"size-3.5"}),e[0]=d):d=e[0];let c;return e[1]!==i?(c=n.jsxs(ie,{variant:"outline",size:"sm",onClick:i,children:[d," Start"]}),e[1]=i,e[2]=c):c=e[2],c}if(s==="suspended"&&a){let d;e[3]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx(Di,{className:"size-3.5"}),e[3]=d):d=e[3];let c;return e[4]!==a?(c=n.jsxs(ie,{variant:"outline",size:"sm",onClick:a,children:[d," Resume"]}),e[4]=a,e[5]=c):c=e[5],c}if(s==="errored"&&l){let d;e[6]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx(Pn,{className:"size-3.5"}),e[6]=d):d=e[6];let c;return e[7]!==l?(c=n.jsxs(ie,{variant:"outline",size:"sm",onClick:l,children:[d," Retry"]}),e[7]=l,e[8]=c):c=e[8],c}if(s==="starting"||s==="running"){const d=s==="running"&&!!o,c=d?"rounded-r-none border-r-0":void 0;let h;e[9]!==c?(h=ae(c),e[9]=c,e[10]=h):h=e[10];let u;e[11]===Symbol.for("react.memo_cache_sentinel")?(u=n.jsx(Au,{className:"size-3.5"}),e[11]=u):u=e[11];let f;e[12]!==r||e[13]!==h?(f=n.jsx(Ne,{asChild:!0,children:n.jsxs(ie,{variant:"outline",size:"sm",onClick:r,className:h,children:[u," Stop"]})}),e[12]=r,e[13]=h,e[14]=f):f=e[14];let m;e[15]===Symbol.for("react.memo_cache_sentinel")?(m=n.jsx(Ee,{children:"Stop sandbox"}),e[15]=m):m=e[15];let p;e[16]!==f?(p=n.jsxs(Te,{children:[f,m]}),e[16]=f,e[17]=p):p=e[17];let g;e[18]!==o||e[19]!==d?(g=d&&n.jsxs(Wt,{children:[n.jsx(Vt,{asChild:!0,children:n.jsx(ie,{variant:"outline",size:"sm",className:"rounded-l-none px-1",children:n.jsx(cs,{className:"size-3"})})}),n.jsx(Kt,{align:"end",children:n.jsxs(Ue,{onClick:o,children:[n.jsx(Pn,{className:"size-3.5"})," Restart"]})})]}),e[18]=o,e[19]=d,e[20]=g):g=e[20];let _;return e[21]!==p||e[22]!==g?(_=n.jsxs("div",{className:"flex items-center",children:[p,g]}),e[21]=p,e[22]=g,e[23]=_):_=e[23],_}return null}function X3(t){const e=U.c(16),{active:s,onClick:i,onClose:r,children:o}=t,a=s?"border-border bg-background shadow-sm":"border-transparent hover:bg-background/50";let l;e[0]!==a?(l=ae("flex h-7 items-center rounded-md border text-xs",a),e[0]=a,e[1]=l):l=e[1];const d=r?"pl-2.5 pr-1":"px-2.5",c=s?"font-medium text-foreground":"text-muted-foreground hover:text-foreground";let h;e[2]!==d||e[3]!==c?(h=ae("flex h-full items-center",d,c),e[2]=d,e[3]=c,e[4]=h):h=e[4];let u;e[5]!==o||e[6]!==i||e[7]!==h?(u=n.jsx("button",{type:"button",onClick:i,className:h,children:o}),e[5]=o,e[6]=i,e[7]=h,e[8]=u):u=e[8];let f;e[9]!==o||e[10]!==r?(f=r&&n.jsx("button",{type:"button","aria-label":`Close ${o}`,onClick:r,className:"pr-1.5 text-muted-foreground hover:text-foreground",children:n.jsx(jl,{className:"size-3"})}),e[9]=o,e[10]=r,e[11]=f):f=e[11];let m;return e[12]!==l||e[13]!==u||e[14]!==f?(m=n.jsxs("div",{className:l,children:[u,f]}),e[12]=l,e[13]=u,e[14]=f,e[15]=m):m=e[15],m}function J3(t){const e=U.c(10),{scripts:s,onRun:i}=t,[r,o]=D.useState(!1);let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsxs(Te,{children:[n.jsx(Ne,{asChild:!0,children:n.jsx(Rs,{asChild:!0,children:n.jsx(ie,{variant:"ghost",size:"sm","aria-label":"Run script",children:n.jsx(Dt,{className:"size-3.5"})})})}),n.jsx(Ee,{children:"Run script"})]}),e[0]=a):a=e[0];let l;e[1]===Symbol.for("react.memo_cache_sentinel")?(l=n.jsx("div",{className:"px-2 py-1 text-[10px] uppercase tracking-wide text-muted-foreground",children:"run a script"}),e[1]=l):l=e[1];let d;e[2]!==i||e[3]!==s?(d=s.length===0?n.jsx("div",{className:"px-2 py-2 text-xs text-muted-foreground",children:"No scripts found"}):s.map(u=>n.jsxs("button",{type:"button",onClick:()=>{o(!1),i(u)},className:"w-full rounded-md px-2 py-1.5 text-left text-xs hover:bg-accent",children:["▸ ",u]},u)),e[2]=i,e[3]=s,e[4]=d):d=e[4];let c;e[5]!==d?(c=n.jsxs(Ps,{align:"start",className:"p-1 w-56",children:[l,d]}),e[5]=d,e[6]=c):c=e[6];let h;return e[7]!==r||e[8]!==c?(h=n.jsxs(As,{open:r,onOpenChange:o,children:[a,c]}),e[7]=r,e[8]=c,e[9]=h):h=e[9],h}function Z3(t){const e=U.c(13),{isRunning:s,isKilling:i,onRun:r,onStop:o}=t;if(i){let h;return e[0]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsxs(ie,{variant:"outline",size:"sm",disabled:!0,children:[n.jsx(Oe,{className:"size-3.5 animate-spin"})," Stopping…"]}),e[0]=h):h=e[0],h}if(!s){let h;e[1]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx(Di,{className:"size-3.5"}),e[1]=h):h=e[1];let u;e[2]!==r?(u=n.jsx(Ne,{asChild:!0,children:n.jsxs(ie,{variant:"outline",size:"sm",onClick:r,children:[h," Run"]})}),e[2]=r,e[3]=u):u=e[3];let f;e[4]===Symbol.for("react.memo_cache_sentinel")?(f=n.jsx(Ee,{children:"Start process"}),e[4]=f):f=e[4];let m;return e[5]!==u?(m=n.jsxs(Te,{children:[u,f]}),e[5]=u,e[6]=m):m=e[6],m}let a;e[7]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx(Au,{className:"size-3.5"}),e[7]=a):a=e[7];let l;e[8]!==o?(l=n.jsx(Ne,{asChild:!0,children:n.jsxs(ie,{variant:"outline",size:"sm",onClick:o,children:[a," Stop"]})}),e[8]=o,e[9]=l):l=e[9];let d;e[10]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx(Ee,{children:"Stop process"}),e[10]=d):d=e[10];let c;return e[11]!==l?(c=n.jsxs(Te,{children:[l,d]}),e[11]=l,e[12]=c):c=e[12],c}var zm=Object.defineProperty,Q3=Object.getOwnPropertyDescriptor,ek=(t,e)=>{for(var s in e)zm(t,s,{get:e[s],enumerable:!0})},rt=(t,e,s,i)=>{for(var r=i>1?void 0:i?Q3(e,s):e,o=t.length-1,a;o>=0;o--)(a=t[o])&&(r=(i?a(e,s,r):a(r))||r);return i&&r&&zm(e,s,r),r},_e=(t,e)=>(s,i)=>e(s,i,t),Fd="Terminal input",ka={get:()=>Fd,set:t=>Fd=t},Hd="Too much output to announce, navigate to rows manually to read",ja={get:()=>Hd,set:t=>Hd=t};function tk(t){return t.replace(/\r?\n/g,"\r")}function sk(t,e){return e?"\x1B[200~"+t+"\x1B[201~":t}function ik(t,e){t.clipboardData&&t.clipboardData.setData("text/plain",e.selectionText),t.preventDefault()}function nk(t,e,s,i){if(t.stopPropagation(),t.clipboardData){let r=t.clipboardData.getData("text/plain");Fm(r,e,s,i)}}function Fm(t,e,s,i){t=tk(t),t=sk(t,s.decPrivateModes.bracketedPasteMode&&i.rawOptions.ignoreBracketedPasteMode!==!0),s.triggerDataEvent(t,!0),e.value=""}function Hm(t,e,s){let i=s.getBoundingClientRect(),r=t.clientX-i.left-10,o=t.clientY-i.top-10;e.style.width="20px",e.style.height="20px",e.style.left=`${r}px`,e.style.top=`${o}px`,e.style.zIndex="1000",e.focus()}function Ud(t,e,s,i,r){Hm(t,e,s),r&&i.rightClickSelect(t),e.value=i.selectionText,e.select()}function Ms(t){return t>65535?(t-=65536,String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):String.fromCharCode(t)}function xo(t,e=0,s=t.length){let i="";for(let r=e;r<s;++r){let o=t[r];o>65535?(o-=65536,i+=String.fromCharCode((o>>10)+55296)+String.fromCharCode(o%1024+56320)):i+=String.fromCharCode(o)}return i}var rk=class{constructor(){this._interim=0}clear(){this._interim=0}decode(t,e){let s=t.length;if(!s)return 0;let i=0,r=0;if(this._interim){let o=t.charCodeAt(r++);56320<=o&&o<=57343?e[i++]=(this._interim-55296)*1024+o-56320+65536:(e[i++]=this._interim,e[i++]=o),this._interim=0}for(let o=r;o<s;++o){let a=t.charCodeAt(o);if(55296<=a&&a<=56319){if(++o>=s)return this._interim=a,i;let l=t.charCodeAt(o);56320<=l&&l<=57343?e[i++]=(a-55296)*1024+l-56320+65536:(e[i++]=a,e[i++]=l);continue}a!==65279&&(e[i++]=a)}return i}},ok=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(t,e){let s=t.length;if(!s)return 0;let i=0,r,o,a,l,d=0,c=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 _=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,b=_-p;for(;c<b;){if(c>=s)return 0;if(g=t[c++],(g&192)!==128){c--,f=!0;break}else this.interim[p++]=g,m<<=6,m|=g&63}f||(_===2?m<128?c--:e[i++]=m:_===3?m<2048||m>=55296&&m<=57343||m===65279||(e[i++]=m):m<65536||m>1114111||(e[i++]=m)),this.interim.fill(0)}let h=s-4,u=c;for(;u<s;){for(;u<h&&!((r=t[u])&128)&&!((o=t[u+1])&128)&&!((a=t[u+2])&128)&&!((l=t[u+3])&128);)e[i++]=r,e[i++]=o,e[i++]=a,e[i++]=l,u+=4;if(r=t[u++],r<128)e[i++]=r;else if((r&224)===192){if(u>=s)return this.interim[0]=r,i;if(o=t[u++],(o&192)!==128){u--;continue}if(d=(r&31)<<6|o&63,d<128){u--;continue}e[i++]=d}else if((r&240)===224){if(u>=s)return this.interim[0]=r,i;if(o=t[u++],(o&192)!==128){u--;continue}if(u>=s)return this.interim[0]=r,this.interim[1]=o,i;if(a=t[u++],(a&192)!==128){u--;continue}if(d=(r&15)<<12|(o&63)<<6|a&63,d<2048||d>=55296&&d<=57343||d===65279)continue;e[i++]=d}else if((r&248)===240){if(u>=s)return this.interim[0]=r,i;if(o=t[u++],(o&192)!==128){u--;continue}if(u>=s)return this.interim[0]=r,this.interim[1]=o,i;if(a=t[u++],(a&192)!==128){u--;continue}if(u>=s)return this.interim[0]=r,this.interim[1]=o,this.interim[2]=a,i;if(l=t[u++],(l&192)!==128){u--;continue}if(d=(r&7)<<18|(o&63)<<12|(a&63)<<6|l&63,d<65536||d>1114111)continue;e[i++]=d}}return i}},Um="",$s=" ",Xn=class Wm{constructor(){this.fg=0,this.bg=0,this.extended=new Gr}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 Wm;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}},Gr=class Vm{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 Vm(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Qt=class Km extends Xn{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new Gr,this.combinedData=""}static fromCharData(e){let s=new Km;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?Ms(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let s=!1;if(e[1].length>2)s=!0;else if(e[1].length===2){let i=e[1].charCodeAt(0);if(55296<=i&&i<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(i-55296)*1024+r-56320+65536|e[2]<<22:s=!0}else s=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;s&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Wd="di$target",Na="di$dependencies",Ko=new Map;function ak(t){return t[Na]||[]}function xt(t){if(Ko.has(t))return Ko.get(t);let e=function(s,i,r){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");lk(e,s,r)};return e._id=t,Ko.set(t,e),e}function lk(t,e,s){e[Wd]===e?e[Na].push({id:t,index:s}):(e[Na]=[{id:t,index:s}],e[Wd]=e)}var It=xt("BufferService"),qm=xt("CoreMouseService"),pi=xt("CoreService"),ck=xt("CharsetService"),gc=xt("InstantiationService"),Gm=xt("LogService"),Lt=xt("OptionsService"),Ym=xt("OscLinkService"),dk=xt("UnicodeService"),Jn=xt("DecorationService"),Ea=class{constructor(t,e,s){this._bufferService=t,this._optionsService=e,this._oscLinkService=s}provideLinks(t,e){let s=this._bufferService.buffer.lines.get(t-1);if(!s){e(void 0);return}let i=[],r=this._optionsService.rawOptions.linkHandler,o=new Qt,a=s.getTrimmedLength(),l=-1,d=-1,c=!1;for(let h=0;h<a;h++)if(!(d===-1&&!s.hasContent(h))){if(s.loadCell(h,o),o.hasExtendedAttrs()&&o.extended.urlId)if(d===-1){d=h,l=o.extended.urlId;continue}else c=o.extended.urlId!==l;else d!==-1&&(c=!0);if(c||d!==-1&&h===a-1){let u=this._oscLinkService.getLinkData(l)?.uri;if(u){let f={start:{x:d+1,y:t},end:{x:h+(!c&&h===a-1?1:0),y:t}},m=!1;if(!r?.allowNonHttpProtocols)try{let p=new URL(u);["http:","https:"].includes(p.protocol)||(m=!0)}catch{m=!0}m||i.push({text:u,range:f,activate:(p,g)=>r?r.activate(p,g,f):hk(p,g),hover:(p,g)=>r?.hover?.(p,g,f),leave:(p,g)=>r?.leave?.(p,g,f)})}c=!1,o.hasExtendedAttrs()&&o.extended.urlId?(d=h,l=o.extended.urlId):(d=-1,l=-1)}}e(i)}};Ea=rt([_e(0,It),_e(1,Lt),_e(2,Ym)],Ea);function hk(t,e){if(confirm(`Do you want to navigate to ${e}?
|
|
487
487
|
|
|
488
488
|
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 bo=xt("CharSizeService"),Ds=xt("CoreBrowserService"),_c=xt("MouseService"),Is=xt("RenderService"),uk=xt("SelectionService"),Xm=xt("CharacterJoinerService"),Qi=xt("ThemeService"),Jm=xt("LinkProviderService"),fk=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(t){setTimeout(()=>{throw t.stack?Vd.isErrorNoTelemetry(t)?new Vd(t.message+`
|
|
489
489
|
|