decocms 4.143.0 → 4.144.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-B-jqRzEl.js → AlertCircle-bjC8VX70.js} +1 -1
- package/dist/client/assets/{AreaChart-BiVN9Rbg.js → AreaChart-Berf1Wcn.js} +1 -1
- package/dist/client/assets/{ArrowUp-8wVhqZbY.js → ArrowUp-SkFIu_Mh.js} +1 -1
- package/dist/client/assets/{ArrowUpRight-C79Mz0y9.js → ArrowUpRight-C-B3vUF1.js} +1 -1
- package/dist/client/assets/{Check-D2OTmp9f.js → Check-HrXMyT9G.js} +1 -1
- package/dist/client/assets/{CheckCircle-CagdexBy.js → CheckCircle-DiAhctKs.js} +1 -1
- package/dist/client/assets/{ChevronDown-6d9u53mr.js → ChevronDown-CJjb9vl_.js} +1 -1
- package/dist/client/assets/{ChevronRight-CNc7IJBh.js → ChevronRight-fsZHCheQ.js} +1 -1
- package/dist/client/assets/{ChevronUp-CFeWkGPA.js → ChevronUp-BczRZV-Y.js} +1 -1
- package/dist/client/assets/{Copy01-DAcswqJ-.js → Copy01-B9fZV42-.js} +1 -1
- package/dist/client/assets/{DotsVertical-C3lcToNm.js → DotsVertical-ATIM5zu0.js} +1 -1
- package/dist/client/assets/{Eye-5baqKWh-.js → Eye-BfiAoz0S.js} +1 -1
- package/dist/client/assets/{FilterLines-DdzesZPL.js → FilterLines-vkHMVWtQ.js} +1 -1
- package/dist/client/assets/{HardDrive-BKIKC-Q_.js → HardDrive-D6SAii7J.js} +1 -1
- package/dist/client/assets/{Key01-fqq_MFu4.js → Key01-C0p_oPg8.js} +1 -1
- package/dist/client/assets/{LayoutLeft-CuMVXGUK.js → LayoutLeft-CpDk0EOr.js} +1 -1
- package/dist/client/assets/{LinkExternal01-BqkooxOV.js → LinkExternal01-CNjcXqd6.js} +1 -1
- package/dist/client/assets/{LogOut01-B8UpmR8a.js → LogOut01-DqWMJEg8.js} +1 -1
- package/dist/client/assets/{Monitor01-BLwSOYdr.js → Monitor01-C07z4FWm.js} +1 -1
- package/dist/client/assets/{Palette-DIrZPBgO.js → Palette-D2Y58mS8.js} +1 -1
- package/dist/client/assets/{Play-b1Vma0LR.js → Play-DZHQldRw.js} +1 -1
- package/dist/client/assets/{Plus-Dn7E2MbI.js → Plus-Dli8Eqb0.js} +1 -1
- package/dist/client/assets/{SearchLg-CcdcmJuJ.js → SearchLg-Cl8SJOV5.js} +1 -1
- package/dist/client/assets/{SearchMd-BE8PZTOt.js → SearchMd-CuwSJsL7.js} +1 -1
- package/dist/client/assets/{Settings02-CyPLPNW_.js → Settings02-CmjWJ1c6.js} +1 -1
- package/dist/client/assets/{Shield01-CcpD-xYP.js → Shield01-ByboMUx5.js} +1 -1
- package/dist/client/assets/{Star01-CYWNL4zV.js → Star01-C42DJ-xk.js} +1 -1
- package/dist/client/assets/{Stars01-CNYsGUE-.js → Stars01-efT3oOwc.js} +1 -1
- package/dist/client/assets/{Stars02-BUKsUmOb.js → Stars02-BAQ5qRk1.js} +1 -1
- package/dist/client/assets/{Sun-Bls3wdhD.js → Sun-C_hjFhxT.js} +1 -1
- package/dist/client/assets/{SwitchHorizontal01-CzML4bwn.js → SwitchHorizontal01-GV0--qUc.js} +1 -1
- package/dist/client/assets/{Tool01-D6778Lob.js → Tool01-BdMCBLCF.js} +1 -1
- package/dist/client/assets/{Tool02-Z0l-5_iB.js → Tool02-CLHYu0yn.js} +1 -1
- package/dist/client/assets/{Trash01--va9a-rZ.js → Trash01-Do1QH01I.js} +1 -1
- package/dist/client/assets/{TrendUp01-B0vVWAUw.js → TrendUp01-46hVQ0WU.js} +1 -1
- package/dist/client/assets/{Upload01-DJH5T0zl.js → Upload01-C_4FIdsq.js} +1 -1
- package/dist/client/assets/{User01-BIYw5tFf.js → User01-BccqDgbp.js} +1 -1
- package/dist/client/assets/{Users01-CJQ3NAZn.js → Users01-BDoRfuXn.js} +1 -1
- package/dist/client/assets/{Users03-Da7W4Ncu.js → Users03-Cm6zJrF0.js} +1 -1
- package/dist/client/assets/{X-DM8kZX3_.js → X-v0Mh0h2J.js} +1 -1
- package/dist/client/assets/{XCircle-Mi8kCDLZ.js → XCircle-CItxK-fi.js} +1 -1
- package/dist/client/assets/{XClose-CnleH_rn.js → XClose-CmUu59X-.js} +1 -1
- package/dist/client/assets/{Zap-Caskj5Xs.js → Zap-C9AHpIXN.js} +1 -1
- package/dist/client/assets/{ZapSquare-D_Ea99yn.js → ZapSquare-CYXtyGQc.js} +1 -1
- package/dist/client/assets/{access-gate-BFCJT7AK.js → access-gate-gWiySoB6.js} +1 -1
- package/dist/client/assets/{add-section-modal-IrUHBk2G.js → add-section-modal-CHtxZWG_.js} +1 -1
- package/dist/client/assets/{agent-icon-C_Bcs5w3.js → agent-icon-BGbirapc.js} +1 -1
- package/dist/client/assets/{agents-list-DVtyxn3w.js → agents-list-CTlDK04C.js} +1 -1
- package/dist/client/assets/{ai-providers-Bj3HzBuS.js → ai-providers-DpKQQFBK.js} +1 -1
- package/dist/client/assets/{alert-B_zsxySU.js → alert-BDE3aQzs.js} +1 -1
- package/dist/client/assets/{alert-dialog-lKGaIGJ0.js → alert-dialog-BmYTAKM-.js} +1 -1
- package/dist/client/assets/app-editor-Co9YISCK.js +1 -0
- package/dist/client/assets/{auth-CyQvgFY_.js → auth-D6tgJd48.js} +1 -1
- package/dist/client/assets/{auth-catchall-DSya8pvs.js → auth-catchall-Xm12qM-O.js} +1 -1
- package/dist/client/assets/{auth-entry-CD-vn7aB.js → auth-entry-gVU-BKt3.js} +1 -1
- package/dist/client/assets/{auth-split-layout-4TADJHe3.js → auth-split-layout-BLxKbBEG.js} +1 -1
- package/dist/client/assets/{authenticate-and-persist-oauth-CYAmEm23.js → authenticate-and-persist-oauth-C7W8HXB-.js} +1 -1
- package/dist/client/assets/{automation-list-row-BNoWYkqJ.js → automation-list-row-UuK5SZ3b.js} +1 -1
- package/dist/client/assets/{automation-runs-BCXsq8ct.js → automation-runs-ZSHknXFL.js} +1 -1
- package/dist/client/assets/{automations-DaWbO5W0.js → automations-CkVQDRvh.js} +1 -1
- package/dist/client/assets/{avatar-D-26TcjI.js → avatar-CzQ7J9Py.js} +1 -1
- package/dist/client/assets/{badge-Bt07rmj0.js → badge-DxUkTZDX.js} +1 -1
- package/dist/client/assets/{block-document-DHwqz4ng.js → block-document-Dk1DKZt0.js} +1 -1
- package/dist/client/assets/{brand-context-DcWJH1eE.js → brand-context-Gz-FJLMN.js} +1 -1
- package/dist/client/assets/{buckets-BN8tEEe8.js → buckets-DpOfdOye.js} +1 -1
- package/dist/client/assets/bulk-category-panel-DzONs21U.js +1 -0
- package/dist/client/assets/{calendar-D-kF2A1V.js → calendar-ioOOy9x4.js} +1 -1
- package/dist/client/assets/{capability-load-error-DaoU0HSz.js → capability-load-error-BT6aAl1G.js} +1 -1
- package/dist/client/assets/{card-BJkx-TlV.js → card-Bzi6yUGv.js} +1 -1
- package/dist/client/assets/category-editor-DvvQDNn3.js +1 -0
- package/dist/client/assets/{chat-context-CRLCG-7m.js → chat-context-D_Gjawoo.js} +1 -1
- package/dist/client/assets/{checkbox-L_8J0VEc.js → checkbox-CsXwodnZ.js} +1 -1
- package/dist/client/assets/{cli-auth-success-CIORuBy8.js → cli-auth-success-B1L3aMzW.js} +1 -1
- package/dist/client/assets/{collection-detail-D-Ew8P97.js → collection-detail-DXl61wQP.js} +1 -1
- package/dist/client/assets/{collection-display-button-_4wEvm8K.js → collection-display-button-CkYsI7NF.js} +1 -1
- package/dist/client/assets/{collection-search-BP_osQGg.js → collection-search-Bw_AYyWe.js} +1 -1
- package/dist/client/assets/{collection-table-wrapper-CpxPnXz4.js → collection-table-wrapper-CDBGf-WF.js} +1 -1
- package/dist/client/assets/{collection-tabs-rQ-lQQ1f.js → collection-tabs-CPcyvgV6.js} +1 -1
- package/dist/client/assets/command-C0ZjGtQ6.js +1 -0
- package/dist/client/assets/{commerce-onboarding-D84or4Tp.js → commerce-onboarding-663-SWD1.js} +1 -1
- package/dist/client/assets/{companions-core-XkORCpwR.js → companions-core-BUUkoH1J.js} +1 -1
- package/dist/client/assets/{connect-CGvuELFE.js → connect-C39WuO_1.js} +1 -1
- package/dist/client/assets/{connect-desktop-dialog-ePivWtSb.js → connect-desktop-dialog-1q_x4ynM.js} +1 -1
- package/dist/client/assets/{connection-ByK9rd24.js → connection-CphxB6Hn.js} +1 -1
- package/dist/client/assets/{connection-card-CAxRM9Mg.js → connection-card-BJQrv-Sf.js} +1 -1
- package/dist/client/assets/{connection-detail-BRFBfHBS.js → connection-detail-CT2pr4RA.js} +1 -1
- package/dist/client/assets/{connection-form-helpers-BJFFbUQU.js → connection-form-helpers-pGgztUvg.js} +1 -1
- package/dist/client/assets/{connections-UQfEHlso.js → connections-DpT97VsB.js} +1 -1
- package/dist/client/assets/{decopilot-sse-pool-CG8MNCkB.js → decopilot-sse-pool-7Tzx6-E9.js} +1 -1
- package/dist/client/assets/{dialog-D33iO7_V.js → dialog-DbxgvIzU.js} +1 -1
- package/dist/client/assets/{domain-settings-DOD8a9FC.js → domain-settings-CmAKlGDM.js} +1 -1
- package/dist/client/assets/{drawer-DEBuno2i.js → drawer-DcSDhvlR.js} +1 -1
- package/dist/client/assets/{dropdown-menu-C6KbRlri.js → dropdown-menu-zLzf58UF.js} +1 -1
- package/dist/client/assets/{empty-state-Dd-cQnoB.js → empty-state-C8A6v1EQ.js} +1 -1
- package/dist/client/assets/{extract-connection-data-DV9ilPpM.js → extract-connection-data-BgqfCUzt.js} +1 -1
- package/dist/client/assets/file-explorer-Dq2OrUP8.js +2 -0
- package/dist/client/assets/{form-DU_fCIQ-.js → form-DXHtZ3Xd.js} +1 -1
- package/dist/client/assets/{general-D3ZVfxSw.js → general-6XhFsMt5.js} +1 -1
- package/dist/client/assets/{github-repo-picker-BjxldoVh.js → github-repo-picker-BOuY27Fo.js} +1 -1
- package/dist/client/assets/{hooks-UN_3FMZE.js → hooks-DRoQyAYD.js} +1 -1
- package/dist/client/assets/index-BbUR22_I.css +1 -0
- package/dist/client/assets/index-BrkQ12GR.js +8 -0
- package/dist/client/assets/{index-BMkx_fVM.js → index-C7eCvrix.js} +1 -1
- package/dist/client/assets/{index-CHxi5qA7.js → index-C_xlULy7.js} +1 -1
- package/dist/client/assets/{index-BEgR1yze.js → index-Cie8bNR2.js} +1 -1
- package/dist/client/assets/{index-DRZiVvJy.js → index-Cn6kNK5d.js} +1 -1
- package/dist/client/assets/{index-CCDNDdqy.js → index-Cz3eCJot.js} +1 -1
- package/dist/client/assets/{index-3s9Tew9h.js → index-DEjVUbQZ.js} +5 -5
- package/dist/client/assets/{index-ItRmrjqK.js → index-DFspaUcC.js} +5 -5
- package/dist/client/assets/{index-DwxbseCq.js → index-DV478YQv.js} +1 -1
- package/dist/client/assets/{index-O8J1Dp2X.js → index-Dw9Kh9ea.js} +1 -1
- package/dist/client/assets/{index-CKYr3lDt.js → index-Ge9lsRXc.js} +1 -1
- package/dist/client/assets/{index-redirect-Cd1hqm3U.js → index-redirect-BSBsnQKV.js} +1 -1
- package/dist/client/assets/{input-BfYMrULt.js → input-BsFsRYpb.js} +1 -1
- package/dist/client/assets/{integration-icon-efY4xiAf.js → integration-icon-Zd6y2lnO.js} +1 -1
- package/dist/client/assets/{invite-member-dialog-Da_OF_ll.js → invite-member-dialog-ea2rgdiV.js} +1 -1
- package/dist/client/assets/{label-IYRseMIB.js → label-Dy22a1G_.js} +1 -1
- package/dist/client/assets/{layout-DO22NBVL.js → layout-DTofO_A0.js} +1 -1
- package/dist/client/assets/{login-DNgu6l3u.js → login-Cz3Rtqo-.js} +1 -1
- package/dist/client/assets/{mcp-oauth-CSNCpmPq.js → mcp-oauth-CsDk7r71.js} +1 -1
- package/dist/client/assets/members-DuveJzOm.js +1 -0
- package/dist/client/assets/{monaco-editor-CG32495o.js → monaco-editor-p1KcCRI9.js} +1 -1
- package/dist/client/assets/{monitoring-stats-row-5WdWKDvN.js → monitoring-stats-row-C9gIDwLW.js} +1 -1
- package/dist/client/assets/{multi-select-daLSotTk.js → multi-select-Bzs4Ibjn.js} +1 -1
- package/dist/client/assets/{oauth-callback-DaIiIjJz.js → oauth-callback-Bwf5O6A5.js} +1 -1
- package/dist/client/assets/{oauth-callback-ai-provider-BgQLj9jp.js → oauth-callback-ai-provider-CoWQsYYc.js} +1 -1
- package/dist/client/assets/{onboarding-ChhvT3pz.js → onboarding-CPfNxv8z.js} +1 -1
- package/dist/client/assets/{org-install-BkjDyn8G.js → org-install-aMCVBdo1.js} +1 -1
- package/dist/client/assets/{org-layout-quA4JXB-.js → org-layout-DuTct6ab.js} +1 -1
- package/dist/client/assets/{organization-choice-DrOHVIOZ.js → organization-choice-6tMLFUIz.js} +1 -1
- package/dist/client/assets/{orgs-uafRHIoi.js → orgs-t7TB--eL.js} +1 -1
- package/dist/client/assets/{page-seo-form-DQF2bT-S.js → page-seo-form-OgfFKVEU.js} +1 -1
- package/dist/client/assets/{popover-B0IAIvG1.js → popover-QmmuC2j3.js} +1 -1
- package/dist/client/assets/post-editor-847fBebh.js +1 -0
- package/dist/client/assets/{primitives-TeELpOAu.js → primitives-DCjJZijO.js} +1 -1
- package/dist/client/assets/{profile-CwdfRf3t.js → profile-dxQOIoy6.js} +1 -1
- package/dist/client/assets/project-app-view-DDvhy0js.js +1 -0
- package/dist/client/assets/record-editor-DZP5PoIz.js +1 -0
- package/dist/client/assets/redirect-editor-Cj7N-Dee.js +1 -0
- package/dist/client/assets/registry-DdNbIMiF.js +2 -0
- package/dist/client/assets/{registry-layout-BiwVm6BS.js → registry-layout-hMOd-Vu6.js} +1 -1
- package/dist/client/assets/{reports-BAIAc8a3.js → reports-B36h6JQw.js} +1 -1
- package/dist/client/assets/{require-capability-5JvRqOC5.js → require-capability-BSRjSQ8m.js} +1 -1
- package/dist/client/assets/{required-auth-layout-pECQLZu3.js → required-auth-layout-DyZfLiuc.js} +1 -1
- package/dist/client/assets/{reset-password-6785Ja9D.js → reset-password-V6kMwcFG.js} +1 -1
- package/dist/client/assets/{roles-Ssu2ZMMo.js → roles-lc89Fi8t.js} +1 -1
- package/dist/client/assets/{search-input-Cs8XLlxq.js → search-input-eBi3jOVU.js} +1 -1
- package/dist/client/assets/{secrets-C3NcHdrk.js → secrets-BMRegWEv.js} +1 -1
- package/dist/client/assets/{sections-editor-BmggDKtT.js → sections-editor-BkTrlAhT.js} +2 -2
- package/dist/client/assets/{select-BVLvxRY_.js → select-ZZ2niYJE.js} +1 -1
- package/dist/client/assets/{select-model-B1FCO1sL.js → select-model-BUi0DPCz.js} +1 -1
- package/dist/client/assets/{self-tool-result-CiannG5U.js → self-tool-result-DabJKGlc.js} +1 -1
- package/dist/client/assets/seo-editor-ip7TK0og.js +1 -0
- package/dist/client/assets/{settings-layout-DAXoBBEe.js → settings-layout-BnjA-1vO.js} +1 -1
- package/dist/client/assets/{settings-section-DK8lFIzK.js → settings-section-DHLuH-PS.js} +1 -1
- package/dist/client/assets/{shell-controls-KuQmFzu6.js → shell-controls-vY4IuJVQ.js} +1 -1
- package/dist/client/assets/{shell-layout-BijKU0-I.js → shell-layout-DT_JVhSf.js} +1 -1
- package/dist/client/assets/{sidebar-CDXYvtn9.js → sidebar-DbuIqiea.js} +1 -1
- package/dist/client/assets/{skeleton-CGU246-L.js → skeleton-COECUkwI.js} +1 -1
- package/dist/client/assets/{sso-D91DYNig.js → sso-e-1MoLDx.js} +1 -1
- package/dist/client/assets/{store-DbD53Dwf.js → store-Xehwc_cL.js} +1 -1
- package/dist/client/assets/store-registry-B8Cc-Qyz.js +2 -0
- package/dist/client/assets/{studio-tools-VGyC9GwV.js → studio-tools-0zl4dMkN.js} +1 -1
- package/dist/client/assets/{switch-C4OvS2MT.js → switch-BFhEckeE.js} +1 -1
- package/dist/client/assets/{tab-id-BPYTTZ6r.js → tab-id-DBqQfYhM.js} +1 -1
- package/dist/client/assets/{table-ZV_kuvYr.js → table-jSwBp7om.js} +1 -1
- package/dist/client/assets/{tabs-C6hrxr6a.js → tabs-DStJuoyx.js} +1 -1
- package/dist/client/assets/{textarea-x-bE9Bxs.js → textarea-DoBp39jT.js} +1 -1
- package/dist/client/assets/{toggle-group-CRooMtRv.js → toggle-group-Cfybgxkd.js} +1 -1
- package/dist/client/assets/{toolbar-yFGKx-ED.js → toolbar-Chezv8Oj.js} +1 -1
- package/dist/client/assets/{tooltip-DDodsVeB.js → tooltip-BZNMQNvf.js} +1 -1
- package/dist/client/assets/{use-ai-providers-DVmSse-1.js → use-ai-providers-CbOFGwQ8.js} +1 -1
- package/dist/client/assets/{use-api-keys-uTQcq8rB.js → use-api-keys-6oSFOvUw.js} +1 -1
- package/dist/client/assets/{use-automations-CLUBhaHO.js → use-automations-D5QBILsR.js} +1 -1
- package/dist/client/assets/{use-autosave-Dzaioffs.js → use-autosave-d6m_eram.js} +1 -1
- package/dist/client/assets/{use-capability-kDNoyWdY.js → use-capability-CgcHlLav.js} +1 -1
- package/dist/client/assets/{use-clock-tick-BayrL0TS.js → use-clock-tick-N2b0izvt.js} +1 -1
- package/dist/client/assets/{use-connection-ChhJlAvS.js → use-connection-BD9Io0lK.js} +1 -1
- package/dist/client/assets/{use-copy-i2NkP3Jk.js → use-copy-yJAZMqb7.js} +1 -1
- package/dist/client/assets/{use-create-virtual-mcp-BImE2T8X.js → use-create-virtual-mcp-Dg_-07Uk.js} +1 -1
- package/dist/client/assets/{use-debounced-autosave-v1sdssj4.js → use-debounced-autosave-KyajsL3_.js} +1 -1
- package/dist/client/assets/{use-debounced-value-c9xf8WS9.js → use-debounced-value-BJf-6MsT.js} +1 -1
- package/dist/client/assets/{use-deco-credits-baDwitBx.js → use-deco-credits-bLxVczgz.js} +1 -1
- package/dist/client/assets/{use-decopilot-events-DZ9DZDbU.js → use-decopilot-events-B7L7auHL.js} +1 -1
- package/dist/client/assets/{use-delete-connection-CMAwaYVC.js → use-delete-connection-h726MShe.js} +1 -1
- package/dist/client/assets/{use-deployment-admin-1iMj6395.js → use-deployment-admin-BntjQTYI.js} +1 -1
- package/dist/client/assets/{use-file-configs-DN8YUUYy.js → use-file-configs-Dvqefsen.js} +1 -1
- package/dist/client/assets/{use-infinite-scroll-B7GLw7FT.js → use-infinite-scroll-BVn-n2Jl.js} +1 -1
- package/dist/client/assets/{use-join-requests-CKgL2XRY.js → use-join-requests-8HOi_Rh1.js} +1 -1
- package/dist/client/assets/{use-mcp-auth-status-Diqe229X.js → use-mcp-auth-status-hcqVaZjN.js} +1 -1
- package/dist/client/assets/{use-mcp-client-S8Ro9wXt.js → use-mcp-client-B--rl5yR.js} +1 -1
- package/dist/client/assets/{use-mcp-tools-Ds6vRkno.js → use-mcp-tools-BgLiM38H.js} +1 -1
- package/dist/client/assets/{use-members-1gWDO4iq.js → use-members-B-fG1LMe.js} +1 -1
- package/dist/client/assets/{use-mobile-BvKWcALO.js → use-mobile-BCA9NX4p.js} +1 -1
- package/dist/client/assets/{use-navigate-to-agent-BizqM7da.js → use-navigate-to-agent-KNBtuqax.js} +1 -1
- package/dist/client/assets/{use-org-auth-client-CjJB7VYj.js → use-org-auth-client-qpocT7z8.js} +1 -1
- package/dist/client/assets/{use-org-sso-BwEUjK1Y.js → use-org-sso-DaQhuxoB.js} +1 -1
- package/dist/client/assets/{use-organization-roles-C2rXgNfu.js → use-organization-roles-CLIu6Xv4.js} +1 -1
- package/dist/client/assets/{use-organization-settings-CzkVoVdP.js → use-organization-settings-TEhzXl51.js} +1 -1
- package/dist/client/assets/{use-registry-app-Cqp0RcKu.js → use-registry-app-COCi1sPa.js} +1 -1
- package/dist/client/assets/{use-registry-connections-BPeS8-S0.js → use-registry-connections-DRPB_2pH.js} +1 -1
- package/dist/client/assets/{use-secrets-DNpJcNyZ.js → use-secrets-DVcl6Hd_.js} +1 -1
- package/dist/client/assets/{use-status-sounds-Dl0inIB_.js → use-status-sounds-BNilDfXk.js} +1 -1
- package/dist/client/assets/use-tags-Ce5L6-F5.js +1 -0
- package/dist/client/assets/{use-view-mode-BkwnM4KV.js → use-view-mode-DLfr09AM.js} +1 -1
- package/dist/client/assets/{use-virtual-mcp-BerfEExf.js → use-virtual-mcp-BUKJpjSh.js} +1 -1
- package/dist/client/assets/useInfiniteQuery-gzOQBHzL.js +1 -0
- package/dist/client/assets/{useQueries-BaAVLqaJ.js → useQueries-B6CU5OfR.js} +1 -1
- package/dist/client/assets/{useRouterState-BvY77fPk.js → useRouterState-CN5lLbjm.js} +1 -1
- package/dist/client/assets/useSuspenseInfiniteQuery-DKovPPK2.js +1 -0
- package/dist/client/assets/{users-UlTXYJI6.js → users-CrtLImOC.js} +1 -1
- package/dist/client/assets/{variant-calendar-C3Io3KuI.js → variant-calendar-Ca6VyXSd.js} +1 -1
- package/dist/client/assets/{view-mode-toggle-3iPqRACB.js → view-mode-toggle-Bqak8ar1.js} +1 -1
- package/dist/client/index.html +2 -2
- package/dist/server/cli.js +579 -497
- package/dist/server/migrate.js +114 -114
- package/dist/server/server.js +315 -315
- package/package.json +1 -1
- package/dist/client/assets/app-editor-yVBKDLck.js +0 -1
- package/dist/client/assets/bulk-category-panel-BoXTOaok.js +0 -1
- package/dist/client/assets/category-editor-DLlLtm6q.js +0 -1
- package/dist/client/assets/command-C8JQ6fDH.js +0 -1
- package/dist/client/assets/file-explorer-DH5RcxcZ.js +0 -2
- package/dist/client/assets/index-DZpEhuMO.css +0 -1
- package/dist/client/assets/index-DdPmVGw1.js +0 -8
- package/dist/client/assets/members-CI7yJEQa.js +0 -1
- package/dist/client/assets/post-editor-kMykRTTR.js +0 -1
- package/dist/client/assets/project-app-view-D56KUgUw.js +0 -1
- package/dist/client/assets/record-editor-DwPka5iP.js +0 -1
- package/dist/client/assets/redirect-editor-BG5ZYn8w.js +0 -1
- package/dist/client/assets/registry-yjuga6ab.js +0 -2
- package/dist/client/assets/seo-editor-DQpqd24m.js +0 -1
- package/dist/client/assets/store-registry-CP1Njx2O.js +0 -2
- package/dist/client/assets/useInfiniteQuery-DVRcq0Og.js +0 -1
- package/dist/client/assets/useSuspenseInfiniteQuery-B2iCNXWP.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as V,ag as xt,c as G,b as se,j as s,X as He,Y as ve,F as xe,o as Ie,Z as qe,_ as Ge,e as ke,K as ce,t as le,B as ne,p as ie,D as gt,m as oe,n as vt,d as bt,E as yt,z as jt}from"./index-
|
|
1
|
+
import{r as V,ag as xt,c as G,b as se,j as s,X as He,Y as ve,F as xe,o as Ie,Z as qe,_ as Ge,e as ke,K as ce,t as le,B as ne,p as ie,D as gt,m as oe,n as vt,d as bt,E as yt,z as jt}from"./index-DEjVUbQZ.js";import{c as Xe,e as Ye,d as Qe,a as St,b as Je,h as Nt,D as kt}from"./dialog-DbxgvIzU.js";import{d as Ct,b as wt,a as It,D as _t}from"./drawer-DcSDhvlR.js";import{u as Mt}from"./use-mobile-BCA9NX4p.js";import{S as Le,u as Et,D as Ot,a as _e}from"./chat-context-D_Gjawoo.js";import{C as Pt}from"./checkbox-CsXwodnZ.js";import{I as pe}from"./input-BsFsRYpb.js";import{S as Lt,a as At,b as Tt,c as zt,d as Rt}from"./select-ZZ2niYJE.js";import{S as te}from"./skeleton-COECUkwI.js";import{i as Ze,b as et,c as Ft,a as Dt,s as Kt}from"./Settings02-CmjWJ1c6.js";import{d as $t,a as Ut,b as Bt,i as Wt}from"./Tool01-BdMCBLCF.js";import{i as Vt}from"./Key01-C0p_oPg8.js";import{i as tt}from"./SearchMd-CuwSJsL7.js";import{d as Me,u as Ht,b as qt}from"./use-ai-providers-CbOFGwQ8.js";import{g as Ee}from"./ai-providers-logos-DD3qZ33J.js";import{i as Gt}from"./Monitor01-C07z4FWm.js";import{i as Xt}from"./AlertCircle-bjC8VX70.js";import{u as we}from"./studio-tools-0zl4dMkN.js";import{i as Yt}from"./ChevronRight-fsZHCheQ.js";import{A as Qt}from"./avatar-CzQ7J9Py.js";import{S as Ae,a as Te,b as st}from"./settings-section-DHLuH-PS.js";import{s as it}from"./Eye-BfiAoz0S.js";import{a as Se,b as Ne,C as Jt}from"./connect-desktop-dialog-1q_x4ynM.js";import{t as ze}from"./ChevronDown-CJjb9vl_.js";import{t as Zt}from"./Stars01-efT3oOwc.js";function fe(l,e,t){let i=t.initialDeps??[],o,n=!0;function r(){var c,u,d;let a;t.key&&((c=t.debug)!=null&&c.call(t))&&(a=Date.now());const h=l();if(!(h.length!==i.length||h.some((f,b)=>i[b]!==f)))return o;i=h;let m;if(t.key&&((u=t.debug)!=null&&u.call(t))&&(m=Date.now()),o=e(...h),t.key&&((d=t.debug)!=null&&d.call(t))){const f=Math.round((Date.now()-a)*100)/100,b=Math.round((Date.now()-m)*100)/100,k=b/16,y=(S,I)=>{for(S=String(S);S.length<I;)S=" "+S;return S};console.info(`%c⏱ ${y(b,5)} /${y(f,5)} ms`,`
|
|
2
2
|
font-size: .6rem;
|
|
3
3
|
font-weight: bold;
|
|
4
4
|
color: hsl(${Math.max(0,Math.min(120-120*k,120))}deg 100% 31%);`,t?.key)}return t?.onChange&&!(n&&t.skipInitialOnChange)&&t.onChange(o),n=!1,o}return r.updateDeps=c=>{i=c},r}function Re(l,e){if(l===void 0)throw new Error("Unexpected undefined");return l}const es=(l,e)=>Math.abs(l-e)<1.01,ts=(l,e,t)=>{let i;return function(...o){l.clearTimeout(i),i=l.setTimeout(()=>e.apply(this,o),t)}},Fe=l=>{const{offsetWidth:e,offsetHeight:t}=l;return{width:e,height:t}},ss=l=>l,is=l=>{const e=Math.max(l.startIndex-l.overscan,0),t=Math.min(l.endIndex+l.overscan,l.count-1),i=[];for(let o=e;o<=t;o++)i.push(o);return i},ls=(l,e)=>{const t=l.scrollElement;if(!t)return;const i=l.targetWindow;if(!i)return;const o=r=>{const{width:c,height:u}=r;e({width:Math.round(c),height:Math.round(u)})};if(o(Fe(t)),!i.ResizeObserver)return()=>{};const n=new i.ResizeObserver(r=>{const c=()=>{const u=r[0];if(u?.borderBoxSize){const d=u.borderBoxSize[0];if(d){o({width:d.inlineSize,height:d.blockSize});return}}o(Fe(t))};l.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(c):c()});return n.observe(t,{box:"border-box"}),()=>{n.unobserve(t)}},De={passive:!0},Ke=typeof window>"u"?!0:"onscrollend"in window,ns=(l,e)=>{const t=l.scrollElement;if(!t)return;const i=l.targetWindow;if(!i)return;let o=0;const n=l.options.useScrollendEvent&&Ke?()=>{}:ts(i,()=>{e(o,!1)},l.options.isScrollingResetDelay),r=a=>()=>{const{horizontal:h,isRtl:p}=l.options;o=h?t.scrollLeft*(p&&-1||1):t.scrollTop,n(),e(o,a)},c=r(!0),u=r(!1);t.addEventListener("scroll",c,De);const d=l.options.useScrollendEvent&&Ke;return d&&t.addEventListener("scrollend",u,De),()=>{t.removeEventListener("scroll",c),d&&t.removeEventListener("scrollend",u)}},os=(l,e,t)=>{if(e?.borderBoxSize){const i=e.borderBoxSize[0];if(i)return Math.round(i[t.options.horizontal?"inlineSize":"blockSize"])}return l[t.options.horizontal?"offsetWidth":"offsetHeight"]},rs=(l,{adjustments:e=0,behavior:t},i)=>{var o,n;const r=l+e;(n=(o=i.scrollElement)==null?void 0:o.scrollTo)==null||n.call(o,{[i.options.horizontal?"left":"top"]:r,behavior:t})};class as{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.laneAssignments=new Map,this.pendingMeasuredCacheIndexes=[],this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.now=()=>{var t,i,o;return((o=(i=(t=this.targetWindow)==null?void 0:t.performance)==null?void 0:i.now)==null?void 0:o.call(i))??Date.now()},this.observer=(()=>{let t=null;const i=()=>t||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:t=new this.targetWindow.ResizeObserver(o=>{o.forEach(n=>{const r=()=>{const c=n.target,u=this.indexFromElement(c);if(!c.isConnected){this.observer.unobserve(c);return}this.shouldMeasureDuringScroll(u)&&this.resizeItem(u,this.options.measureElement(c,n,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()})}));return{disconnect:()=>{var o;(o=i())==null||o.disconnect(),t=null},observe:o=>{var n;return(n=i())==null?void 0:n.observe(o,{box:"border-box"})},unobserve:o=>{var n;return(n=i())==null?void 0:n.unobserve(o)}}})(),this.range=null,this.setOptions=t=>{Object.entries(t).forEach(([i,o])=>{typeof o>"u"&&delete t[i]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:ss,rangeExtractor:is,onChange:()=>{},measureElement:os,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:"estimate",...t}},this.notify=t=>{var i,o;(o=(i=this.options).onChange)==null||o.call(i,this,t)},this.maybeNotify=fe(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),t=>{this.notify(t)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(t=>t()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var t;const i=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==i){if(this.cleanup(),!i){this.maybeNotify();return}this.scrollElement=i,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((t=this.scrollElement)==null?void 0:t.window)??null,this.elementsCache.forEach(o=>{this.observer.observe(o)}),this.unsubs.push(this.options.observeElementRect(this,o=>{this.scrollRect=o,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(o,n)=>{this.scrollAdjustments=0,this.scrollDirection=n?this.getScrollOffset()<o?"forward":"backward":null,this.scrollOffset=o,this.isScrolling=n,this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(t,i)=>{const o=new Map,n=new Map;for(let r=i-1;r>=0;r--){const c=t[r];if(o.has(c.lane))continue;const u=n.get(c.lane);if(u==null||c.end>u.end?n.set(c.lane,c):c.end<u.end&&o.set(c.lane,!0),o.size===this.options.lanes)break}return n.size===this.options.lanes?Array.from(n.values()).sort((r,c)=>r.end===c.end?r.index-c.index:r.end-c.end)[0]:void 0},this.getMeasurementOptions=fe(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode],(t,i,o,n,r,c,u)=>(this.prevLanes!==void 0&&this.prevLanes!==c&&(this.lanesChangedFlag=!0),this.prevLanes=c,this.pendingMeasuredCacheIndexes=[],{count:t,paddingStart:i,scrollMargin:o,getItemKey:n,enabled:r,lanes:c,laneAssignmentMode:u}),{key:!1}),this.getMeasurements=fe(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:t,paddingStart:i,scrollMargin:o,getItemKey:n,enabled:r,lanes:c,laneAssignmentMode:u},d)=>{if(!r)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>t)for(const m of this.laneAssignments.keys())m>=t&&this.laneAssignments.delete(m);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMeasuredCacheIndexes=[]),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(m=>{this.itemSizeCache.set(m.key,m.size)}));const a=this.lanesSettling?0:this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[],this.lanesSettling&&this.measurementsCache.length===t&&(this.lanesSettling=!1);const h=this.measurementsCache.slice(0,a),p=new Array(c).fill(void 0);for(let m=0;m<a;m++){const f=h[m];f&&(p[f.lane]=m)}for(let m=a;m<t;m++){const f=n(m),b=this.laneAssignments.get(m);let k,y;const S=u==="estimate"||d.has(f);if(b!==void 0&&this.options.lanes>1){k=b;const _=p[k],x=_!==void 0?h[_]:void 0;y=x?x.end+this.options.gap:i+o}else{const _=this.options.lanes===1?h[m-1]:this.getFurthestMeasurement(h,m);y=_?_.end+this.options.gap:i+o,k=_?_.lane:m%this.options.lanes,this.options.lanes>1&&S&&this.laneAssignments.set(m,k)}const I=d.get(f),P=typeof I=="number"?I:this.options.estimateSize(m),E=y+P;h[m]={index:m,start:y,size:P,end:E,key:f,lane:k},p[k]=m}return this.measurementsCache=h,h},{key:!1,debug:()=>this.options.debug}),this.calculateRange=fe(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(t,i,o,n)=>this.range=t.length>0&&i>0?cs({measurements:t,outerSize:i,scrollOffset:o,lanes:n}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=fe(()=>{let t=null,i=null;const o=this.calculateRange();return o&&(t=o.startIndex,i=o.endIndex),this.maybeNotify.updateDeps([this.isScrolling,t,i]),[this.options.rangeExtractor,this.options.overscan,this.options.count,t,i]},(t,i,o,n,r)=>n===null||r===null?[]:t({startIndex:n,endIndex:r,overscan:i,count:o}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=t=>{const i=this.options.indexAttribute,o=t.getAttribute(i);return o?parseInt(o,10):(console.warn(`Missing attribute name '${i}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=t=>{var i;if(!this.scrollState||this.scrollState.behavior!=="smooth")return!0;const o=this.scrollState.index??((i=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))==null?void 0:i.index);if(o!==void 0&&this.range){const n=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),r=Math.max(0,o-n),c=Math.min(this.options.count-1,o+n);return t>=r&&t<=c}return!0},this.measureElement=t=>{if(!t){this.elementsCache.forEach((r,c)=>{r.isConnected||(this.observer.unobserve(r),this.elementsCache.delete(c))});return}const i=this.indexFromElement(t),o=this.options.getItemKey(i),n=this.elementsCache.get(o);n!==t&&(n&&this.observer.unobserve(n),this.observer.observe(t),this.elementsCache.set(o,t)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(i)&&this.resizeItem(i,this.options.measureElement(t,void 0,this))},this.resizeItem=(t,i)=>{var o;const n=this.measurementsCache[t];if(!n)return;const r=this.itemSizeCache.get(n.key)??n.size,c=i-r;c!==0&&(((o=this.scrollState)==null?void 0:o.behavior)!=="smooth"&&(this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(n,c,this):n.start<this.getScrollOffset()+this.scrollAdjustments)&&this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=c,behavior:void 0}),this.pendingMeasuredCacheIndexes.push(n.index),this.itemSizeCache=new Map(this.itemSizeCache.set(n.key,i)),this.notify(!1))},this.getVirtualItems=fe(()=>[this.getVirtualIndexes(),this.getMeasurements()],(t,i)=>{const o=[];for(let n=0,r=t.length;n<r;n++){const c=t[n],u=i[c];o.push(u)}return o},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=t=>{const i=this.getMeasurements();if(i.length!==0)return Re(i[lt(0,i.length-1,o=>Re(i[o]).start,t)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if("scrollHeight"in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{const t=this.scrollElement.document.documentElement;return this.options.horizontal?t.scrollWidth-this.scrollElement.innerWidth:t.scrollHeight-this.scrollElement.innerHeight}},this.getOffsetForAlignment=(t,i,o=0)=>{if(!this.scrollElement)return 0;const n=this.getSize(),r=this.getScrollOffset();i==="auto"&&(i=t>=r+n?"end":"start"),i==="center"?t+=(o-n)/2:i==="end"&&(t-=n);const c=this.getMaxScrollOffset();return Math.max(Math.min(c,t),0)},this.getOffsetForIndex=(t,i="auto")=>{t=Math.max(0,Math.min(t,this.options.count-1));const o=this.getSize(),n=this.getScrollOffset(),r=this.measurementsCache[t];if(!r)return;if(i==="auto")if(r.end>=n+o-this.options.scrollPaddingEnd)i="end";else if(r.start<=n+this.options.scrollPaddingStart)i="start";else return[n,i];if(i==="end"&&t===this.options.count-1)return[this.getMaxScrollOffset(),i];const c=i==="end"?r.end+this.options.scrollPaddingEnd:r.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(c,i,r.size),i]},this.scrollToOffset=(t,{align:i="start",behavior:o="auto"}={})=>{const n=this.getOffsetForAlignment(t,i),r=this.now();this.scrollState={index:null,align:i,behavior:o,startedAt:r,lastTargetOffset:n,stableFrames:0},this._scrollToOffset(n,{adjustments:void 0,behavior:o}),this.scheduleScrollReconcile()},this.scrollToIndex=(t,{align:i="auto",behavior:o="auto"}={})=>{t=Math.max(0,Math.min(t,this.options.count-1));const n=this.getOffsetForIndex(t,i);if(!n)return;const[r,c]=n,u=this.now();this.scrollState={index:t,align:c,behavior:o,startedAt:u,lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:o}),this.scheduleScrollReconcile()},this.scrollBy=(t,{behavior:i="auto"}={})=>{const o=this.getScrollOffset()+t,n=this.now();this.scrollState={index:null,align:"start",behavior:i,startedAt:n,lastTargetOffset:o,stableFrames:0},this._scrollToOffset(o,{adjustments:void 0,behavior:i}),this.scheduleScrollReconcile()},this.getTotalSize=()=>{var t;const i=this.getMeasurements();let o;if(i.length===0)o=this.options.paddingStart;else if(this.options.lanes===1)o=((t=i[i.length-1])==null?void 0:t.end)??0;else{const n=Array(this.options.lanes).fill(null);let r=i.length-1;for(;r>=0&&n.some(c=>c===null);){const c=i[r];n[c.lane]===null&&(n[c.lane]=c.end),r--}o=Math.max(...n.filter(c=>c!==null))}return Math.max(o-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(t,{adjustments:i,behavior:o})=>{this.options.scrollToFn(t,{behavior:o,adjustments:i},this)},this.measure=()=>{this.itemSizeCache=new Map,this.laneAssignments=new Map,this.notify(!1)},this.setOptions(e)}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId==null&&(this.rafId=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()}))}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}const i=this.scrollState.index!=null?this.getOffsetForIndex(this.scrollState.index,this.scrollState.align):void 0,o=i?i[0]:this.scrollState.lastTargetOffset,n=1,r=o!==this.scrollState.lastTargetOffset;if(!r&&es(o,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=n){this.scrollState=null;return}}else this.scrollState.stableFrames=0,r&&(this.scrollState.lastTargetOffset=o,this.scrollState.behavior="auto",this._scrollToOffset(o,{adjustments:void 0,behavior:"auto"}));this.scheduleScrollReconcile()}}const lt=(l,e,t,i)=>{for(;l<=e;){const o=(l+e)/2|0,n=t(o);if(n<i)l=o+1;else if(n>i)e=o-1;else return o}return l>0?l-1:0};function cs({measurements:l,outerSize:e,scrollOffset:t,lanes:i}){const o=l.length-1,n=u=>l[u].start;if(l.length<=i)return{startIndex:0,endIndex:o};let r=lt(0,o,n,t),c=r;if(i===1)for(;c<o&&l[c].end<t+e;)c++;else if(i>1){const u=Array(i).fill(0);for(;c<o&&u.some(a=>a<t+e);){const a=l[c];u[a.lane]=a.end,c++}const d=Array(i).fill(t+e);for(;r>=0&&d.some(a=>a>=t);){const a=l[r];d[a.lane]=a.start,r--}r=Math.max(0,r-r%i),c=Math.min(o,c+(i-1-c%i))}return{startIndex:r,endIndex:c}}const $e=typeof document<"u"?V.useLayoutEffect:V.useEffect;function ds({useFlushSync:l=!0,...e}){const t=V.useReducer(()=>({}),{})[1],i={...e,onChange:(n,r)=>{var c;l&&r?xt.flushSync(t):t(),(c=e.onChange)==null||c.call(e,n,r)}},[o]=V.useState(()=>new as(i));return o.setOptions(i),$e(()=>o._didMount(),[]),$e(()=>o._willUpdate()),o}function us(l){return ds({observeElementRect:ls,observeElementOffset:ns,scrollToFn:rs,...l})}const nt=[{id:"openai",name:"OpenAI",description:"GPT-4, GPT-5, and other OpenAI models",logo:"https://decoims.com/decocms/b51001ef-ae58-4db4-8a75-9e6d2df2dd8e/openai.png",baseUrlPlaceholder:"https://api.openai.com/v1",defaultBaseUrl:"https://api.openai.com/v1",apiKeyRecommended:!0,helpText:"Use your OpenAI API key (starts with sk-)."},{id:"litellm",name:"LiteLLM",description:"Connect to a LiteLLM gateway your team manages",logo:"https://decoims.com/decocms/e974ae05-ad64-4b4a-8444-d9705f019b85/litellm.png",baseUrlPlaceholder:"http://localhost:4000",apiKeyRecommended:!0,helpText:"Point at your LiteLLM proxy. The base URL should be the root of the proxy (we'll append /v1)."},{id:"ollama",name:"Ollama",description:"Run open-source models on your own computer",logo:"https://decoims.com/decocms/2bb2f822-5288-4b7c-a541-dcbef76525a0/ollama.png",baseUrlPlaceholder:"http://localhost:11434",apiKeyRecommended:!1,helpText:"Ollama exposes /v1 by default — no API key required for local use."},{id:"lm-studio",name:"LM Studio",description:"Open models running through LM Studio",logo:"https://decoims.com/decocms/9f0ab1a9-d2d5-4f3e-9de0-aadd4926428d/lmstudio.webp",baseUrlPlaceholder:"http://localhost:1234",apiKeyRecommended:!1,helpText:"Start the local server in LM Studio, then paste its base URL here."},{id:"vllm",name:"vLLM",description:"Connect to your team's self-hosted vLLM server",logo:"https://decoims.com/decocms/b6c60e4f-a4aa-443c-981f-ad0f31640e22/vllm.png",baseUrlPlaceholder:"http://localhost:8000",apiKeyRecommended:!1}];function be(l){if(l)return nt.find(e=>e.id===l)}const Ue=4;function ge(l){const e=G.c(8),{logo:t,name:i,description:o,onClick:n}=l;let r;e[0]!==t||e[1]!==i?(r=t?s.jsx("img",{src:t,alt:i,className:"size-8 rounded-md object-contain dark:bg-white dark:p-0.5"}):s.jsx(Qt,{fallback:i.charAt(0),className:"size-8 bg-primary/10 text-primary"}),e[0]=t,e[1]=i,e[2]=r):r=e[2];let c;return e[3]!==o||e[4]!==i||e[5]!==n||e[6]!==r?(c=s.jsx(st,{onClick:n,icon:r,title:i,description:o}),e[3]=o,e[4]=i,e[5]=n,e[6]=r,e[7]=c):c=e[7],c}function ot(l){const e=G.c(38),{providers:t,onSelect:i,onShowAll:o}=l,n=se();let r;e[0]!==t?(r=t.find(ps),e[0]=t,e[1]=r):r=e[1];const c=r;let u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u={openrouter:0,llmapi:1,anthropic:2,google:3},e[2]=u):u=e[2];const d=u;let a;if(e[3]!==i||e[4]!==t||e[5]!==n){let P;e[7]===Symbol.for("react.memo_cache_sentinel")?(P=(j,w)=>{const T=d[j.id]??Number.MAX_SAFE_INTEGER,A=d[w.id]??Number.MAX_SAFE_INTEGER;return T-A},e[7]=P):P=e[7];const E=t.filter(fs).sort(P);let _;e[8]!==t?(_=t.find(hs),e[8]=t,e[9]=_):_=e[9];const x=_;let N;e[10]===Symbol.for("react.memo_cache_sentinel")?(N=be("openai"),e[10]=N):N=e[10];const C=N;let M;e[11]!==i?(M=j=>s.jsx(ge,{logo:j.logo,name:j.name,description:j.description,onClick:()=>i({kind:"provider",provider:j})},j.id),e[11]=i,e[12]=M):M=e[12];let v;e[13]!==i||e[14]!==x?(v=x&&C?[s.jsx(ge,{logo:C.logo,name:C.name,description:C.description,onClick:()=>i({kind:"openai-compatible",provider:x,preset:C})},C.id)]:[],e[13]=i,e[14]=x,e[15]=v):v=e[15];let g;e[16]!==i||e[17]!==x||e[18]!==n?(g=x?[...nt.filter(ms).map(j=>s.jsx(ge,{logo:j.logo,name:j.name,description:j.description,onClick:()=>i({kind:"openai-compatible",provider:x,preset:j})},j.id)),s.jsx(ge,{logo:x.logo,name:n("settings.aiProviders.customOpenAiCompatible"),description:n("settings.aiProviders.customOpenAiDescription"),onClick:()=>i({kind:"openai-compatible",provider:x,preset:null})},"custom")]:[],e[16]=i,e[17]=x,e[18]=n,e[19]=g):g=e[19],a=[...E.map(M),...v,...g],e[3]=i,e[4]=t,e[5]=n,e[6]=a}else a=e[6];const h=a,p=h.length-Ue,m=!!o&&p>0;let f;e[20]!==h||e[21]!==m?(f=m?h.slice(0,Ue):h,e[20]=h,e[21]=m,e[22]=f):f=e[22];const b=f;let k;e[23]!==c||e[24]!==i||e[25]!==n?(k=c&&s.jsx(Ae,{children:s.jsxs("div",{className:"relative rounded-xl border border-violet-400/30 bg-gradient-to-br from-violet-50/50 via-transparent to-lime-50/30 dark:from-violet-950/20 dark:to-lime-950/10 p-1.5",children:[s.jsx("div",{className:"absolute inset-0 rounded-xl bg-gradient-to-br from-violet-400/5 to-lime-400/5 pointer-events-none"}),s.jsx("p",{className:"text-xs font-medium text-violet-700 dark:text-violet-400 mb-1.5 px-2 pt-2 relative",children:n("settings.aiProviders.recommended")}),s.jsx(Te,{className:"relative",children:s.jsx(ge,{logo:c.logo,name:c.name,description:c.description,onClick:()=>i({kind:"provider",provider:c})})})]})}),e[23]=c,e[24]=i,e[25]=n,e[26]=k):k=e[26];let y;e[27]!==p||e[28]!==o||e[29]!==m||e[30]!==n?(y=m&&s.jsx(st,{onClick:o,title:n("settings.aiProviders.moreProviders",{count:p,plural:p===1?"":"s"}),action:s.jsx(Yt,{size:16,className:"text-muted-foreground"})}),e[27]=p,e[28]=o,e[29]=m,e[30]=n,e[31]=y):y=e[31];let S;e[32]!==y||e[33]!==b?(S=s.jsx(Ae,{children:s.jsxs(Te,{children:[b,y]})}),e[32]=y,e[33]=b,e[34]=S):S=e[34];let I;return e[35]!==k||e[36]!==S?(I=s.jsxs("div",{className:"flex flex-col gap-6",children:[k,S]}),e[35]=k,e[36]=S,e[37]=I):I=e[37],I}function ms(l){return l.id!=="openai"}function hs(l){return l.id==="openai-compatible"}function fs(l){return l.id!=="deco"&&l.id!=="openai-compatible"}function ps(l){return l.id==="deco"}const xs=He({label:ve().optional(),apiKey:ve().min(1,"API key is required")});function gs(l){const e=G.c(87),{providerId:t,onCancel:i,onSuccess:o}=l,{org:n}=xe(),r=we(),c=Ie(),[u,d]=V.useState(!1),a=se();let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h={resolver:qe(xs),defaultValues:{label:"",apiKey:""}},e[0]=h):h=e[0];const{register:p,handleSubmit:m,formState:f}=Ge(h),{errors:b}=f;let k;e[1]!==t||e[2]!==r||e[3]!==a?(k=async U=>{await r.call("AI_PROVIDER_KEY_CREATE",{providerId:t,label:U.label||a("settings.connectForms.defaultKeyLabel"),apiKey:U.apiKey})},e[1]=t,e[2]=r,e[3]=a,e[4]=k):k=e[4];let y;e[5]!==o||e[6]!==n||e[7]!==c||e[8]!==a?(y=()=>{c.invalidateQueries({queryKey:ce.aiProviderKeys(n.id)}),c.invalidateQueries({queryKey:ce.aiProviders(n.id)}),le.success(a("settings.connectForms.keySavedSuccess")),o()},e[5]=o,e[6]=n,e[7]=c,e[8]=a,e[9]=y):y=e[9];let S;e[10]!==a?(S=U=>{le.error(a("settings.connectForms.failedSaveKey",{error:U.message}))},e[10]=a,e[11]=S):S=e[11];let I;e[12]!==k||e[13]!==y||e[14]!==S?(I={mutationFn:k,onSuccess:y,onError:S},e[12]=k,e[13]=y,e[14]=S,e[15]=I):I=e[15];const{mutate:P,isPending:E,error:_}=ke(I);let x;e[16]!==P?(x=U=>P(U),e[16]=P,e[17]=x):x=e[17];let N;e[18]!==m||e[19]!==x?(N=m(x),e[18]=m,e[19]=x,e[20]=N):N=e[20];let C;e[21]!==a?(C=a("settings.connectForms.labelField"),e[21]=a,e[22]=C):C=e[22];let M;e[23]!==C?(M=s.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:C}),e[23]=C,e[24]=M):M=e[24];let v;e[25]!==a?(v=a("settings.connectForms.labelPlaceholder"),e[25]=a,e[26]=v):v=e[26];let g;e[27]!==p?(g=p("label"),e[27]=p,e[28]=g):g=e[28];let j;e[29]!==v||e[30]!==g?(j=s.jsx(pe,{placeholder:v,...g,className:"h-8 text-sm"}),e[29]=v,e[30]=g,e[31]=j):j=e[31];let w;e[32]!==M||e[33]!==j?(w=s.jsxs("div",{className:"space-y-1",children:[M,j]}),e[32]=M,e[33]=j,e[34]=w):w=e[34];let T;e[35]!==a?(T=a("settings.connectForms.apiKeyField"),e[35]=a,e[36]=T):T=e[36];let A;e[37]!==T?(A=s.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:T}),e[37]=T,e[38]=A):A=e[38];const O=u?"text":"password";let z;e[39]!==p?(z=p("apiKey"),e[39]=p,e[40]=z):z=e[40];let F;e[41]!==O||e[42]!==z?(F=s.jsx(pe,{type:O,placeholder:"sk-...",...z,className:"ph-no-capture h-8 text-sm pr-8"}),e[41]=O,e[42]=z,e[43]=F):F=e[43];let K;e[44]!==u?(K=()=>d(!u),e[44]=u,e[45]=K):K=e[45];let R;e[46]!==u||e[47]!==a?(R=a(u?"settings.connectForms.hideApiKey":"settings.connectForms.showApiKey"),e[46]=u,e[47]=a,e[48]=R):R=e[48];let W;e[49]!==u?(W=u?s.jsx(Ze,{size:14}):s.jsx(it,{size:14}),e[49]=u,e[50]=W):W=e[50];let Q;e[51]!==K||e[52]!==R||e[53]!==W?(Q=s.jsx("button",{type:"button",onClick:K,"aria-label":R,className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:W}),e[51]=K,e[52]=R,e[53]=W,e[54]=Q):Q=e[54];let J;e[55]!==F||e[56]!==Q?(J=s.jsxs("div",{className:"relative",children:[F,Q]}),e[55]=F,e[56]=Q,e[57]=J):J=e[57];let Z;e[58]!==b.apiKey?(Z=b.apiKey&&s.jsx("p",{className:"text-xs text-destructive",children:b.apiKey.message}),e[58]=b.apiKey,e[59]=Z):Z=e[59];let X;e[60]!==A||e[61]!==J||e[62]!==Z?(X=s.jsxs("div",{className:"space-y-1",children:[A,J,Z]}),e[60]=A,e[61]=J,e[62]=Z,e[63]=X):X=e[63];let ee;e[64]!==_?(ee=_&&s.jsx("p",{className:"text-xs text-destructive",children:_.message}),e[64]=_,e[65]=ee):ee=e[65];let H;e[66]!==a?(H=a("settings.connectForms.cancel"),e[66]=a,e[67]=H):H=e[67];let q;e[68]!==E||e[69]!==i||e[70]!==H?(q=s.jsx(ne,{type:"button",variant:"ghost",size:"sm",onClick:i,disabled:E,children:H}),e[68]=E,e[69]=i,e[70]=H,e[71]=q):q=e[71];let Y;e[72]!==E||e[73]!==a?(Y=a(E?"settings.connectForms.saving":"settings.connectForms.saveKey"),e[72]=E,e[73]=a,e[74]=Y):Y=e[74];let L;e[75]!==E||e[76]!==Y?(L=s.jsx(ne,{type:"submit",size:"sm",disabled:E,children:Y}),e[75]=E,e[76]=Y,e[77]=L):L=e[77];let D;e[78]!==q||e[79]!==L?(D=s.jsxs(Xe,{children:[q,L]}),e[78]=q,e[79]=L,e[80]=D):D=e[80];let $;return e[81]!==w||e[82]!==X||e[83]!==ee||e[84]!==D||e[85]!==N?($=s.jsxs("form",{onSubmit:N,className:"space-y-3",children:[w,X,ee,D]}),e[81]=w,e[82]=X,e[83]=ee,e[84]=D,e[85]=N,e[86]=$):$=e[86],$}const vs=He({label:ve().optional(),baseUrl:ve().min(1,"Base URL is required"),apiKey:ve().optional()});function bs(l){const e=G.c(105),{preset:t,onCancel:i,onSuccess:o}=l,{org:n}=xe(),r=we(),c=Ie(),[u,d]=V.useState(!1),a=se();let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=qe(vs),e[0]=h):h=e[0];const p=t?.defaultBaseUrl??"";let m;e[1]!==p?(m={resolver:h,defaultValues:{label:"",baseUrl:p,apiKey:""}},e[1]=p,e[2]=m):m=e[2];const{register:f,handleSubmit:b,formState:k}=Ge(m),{errors:y}=k;let S;e[3]!==t||e[4]!==r?(S=async ae=>{const pt=JSON.stringify({baseUrl:ae.baseUrl,apiKey:ae.apiKey||""});await r.call("AI_PROVIDER_KEY_CREATE",{providerId:"openai-compatible",label:ae.label||t?.name||ae.baseUrl,apiKey:pt,...t?{presetId:t.id}:{}})},e[3]=t,e[4]=r,e[5]=S):S=e[5];let I;e[6]!==o||e[7]!==n||e[8]!==c||e[9]!==a?(I=()=>{c.invalidateQueries({queryKey:ce.aiProviderKeys(n.id)}),c.invalidateQueries({queryKey:ce.aiProviders(n.id)}),le.success(a("settings.connectForms.connectionSavedSuccess")),o()},e[6]=o,e[7]=n,e[8]=c,e[9]=a,e[10]=I):I=e[10];let P;e[11]!==a?(P=ae=>{le.error(a("settings.connectForms.failedSaveConnection",{error:ae.message}))},e[11]=a,e[12]=P):P=e[12];let E;e[13]!==S||e[14]!==I||e[15]!==P?(E={mutationFn:S,onSuccess:I,onError:P},e[13]=S,e[14]=I,e[15]=P,e[16]=E):E=e[16];const{mutate:_,isPending:x,error:N}=ke(E);let C;e[17]!==t||e[18]!==a?(C=t?a("settings.connectForms.labelPlaceholderPreset",{name:t.name}):a("settings.connectForms.labelPlaceholderOpenAiCompatible"),e[17]=t,e[18]=a,e[19]=C):C=e[19];const M=C;let v;e[20]!==t?.baseUrlPlaceholder||e[21]!==a?(v=t?.baseUrlPlaceholder??a("settings.connectForms.baseUrlPlaceholder"),e[20]=t?.baseUrlPlaceholder,e[21]=a,e[22]=v):v=e[22];const g=v;let j;e[23]!==_?(j=ae=>_(ae),e[23]=_,e[24]=j):j=e[24];let w;e[25]!==b||e[26]!==j?(w=b(j),e[25]=b,e[26]=j,e[27]=w):w=e[27];let T;e[28]!==a?(T=a("settings.connectForms.labelField"),e[28]=a,e[29]=T):T=e[29];let A;e[30]!==T?(A=s.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:T}),e[30]=T,e[31]=A):A=e[31];let O;e[32]!==f?(O=f("label"),e[32]=f,e[33]=O):O=e[33];let z;e[34]!==M||e[35]!==O?(z=s.jsx(pe,{placeholder:M,...O,className:"h-8 text-sm"}),e[34]=M,e[35]=O,e[36]=z):z=e[36];let F;e[37]!==A||e[38]!==z?(F=s.jsxs("div",{className:"space-y-1",children:[A,z]}),e[37]=A,e[38]=z,e[39]=F):F=e[39];let K;e[40]!==g||e[41]!==y||e[42]!==t?.defaultBaseUrl||e[43]!==f||e[44]!==a?(K=t?.defaultBaseUrl?s.jsx("input",{type:"hidden",...f("baseUrl")}):s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:a("settings.connectForms.baseUrlField")}),s.jsx(pe,{type:"url",placeholder:g,...f("baseUrl"),className:"h-8 text-sm"}),y.baseUrl&&s.jsx("p",{className:"text-xs text-destructive",children:y.baseUrl.message})]}),e[40]=g,e[41]=y,e[42]=t?.defaultBaseUrl,e[43]=f,e[44]=a,e[45]=K):K=e[45];let R;e[46]!==a?(R=a("settings.connectForms.apiKeyField"),e[46]=a,e[47]=R):R=e[47];let W;e[48]!==t?.apiKeyRecommended||e[49]!==a?(W=t?.apiKeyRecommended?a("settings.connectForms.recommended"):a("settings.connectForms.optional"),e[48]=t?.apiKeyRecommended,e[49]=a,e[50]=W):W=e[50];let Q;e[51]!==W?(Q=s.jsxs("span",{className:"text-muted-foreground/60",children:["(",W,")"]}),e[51]=W,e[52]=Q):Q=e[52];let J;e[53]!==R||e[54]!==Q?(J=s.jsxs("label",{className:"text-xs font-medium text-muted-foreground",children:[R," ",Q]}),e[53]=R,e[54]=Q,e[55]=J):J=e[55];const Z=u?"text":"password";let X;e[56]!==f?(X=f("apiKey"),e[56]=f,e[57]=X):X=e[57];let ee;e[58]!==Z||e[59]!==X?(ee=s.jsx(pe,{type:Z,placeholder:"sk-...",...X,className:"ph-no-capture h-8 text-sm pr-8"}),e[58]=Z,e[59]=X,e[60]=ee):ee=e[60];let H;e[61]!==u?(H=()=>d(!u),e[61]=u,e[62]=H):H=e[62];let q;e[63]!==u||e[64]!==a?(q=a(u?"settings.connectForms.hideApiKey":"settings.connectForms.showApiKey"),e[63]=u,e[64]=a,e[65]=q):q=e[65];let Y;e[66]!==u?(Y=u?s.jsx(Ze,{size:14}):s.jsx(it,{size:14}),e[66]=u,e[67]=Y):Y=e[67];let L;e[68]!==H||e[69]!==q||e[70]!==Y?(L=s.jsx("button",{type:"button",onClick:H,"aria-label":q,className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:Y}),e[68]=H,e[69]=q,e[70]=Y,e[71]=L):L=e[71];let D;e[72]!==ee||e[73]!==L?(D=s.jsxs("div",{className:"relative",children:[ee,L]}),e[72]=ee,e[73]=L,e[74]=D):D=e[74];let $;e[75]!==J||e[76]!==D?($=s.jsxs("div",{className:"space-y-1",children:[J,D]}),e[75]=J,e[76]=D,e[77]=$):$=e[77];let U;e[78]!==t?(U=t?.helpText&&s.jsx("p",{className:"text-xs text-muted-foreground",children:t.helpText}),e[78]=t,e[79]=U):U=e[79];let B;e[80]!==N?(B=N&&s.jsx("p",{className:"text-xs text-destructive",children:N.message}),e[80]=N,e[81]=B):B=e[81];let re;e[82]!==a?(re=a("settings.connectForms.cancel"),e[82]=a,e[83]=re):re=e[83];let de;e[84]!==x||e[85]!==i||e[86]!==re?(de=s.jsx(ne,{type:"button",variant:"ghost",size:"sm",onClick:i,disabled:x,children:re}),e[84]=x,e[85]=i,e[86]=re,e[87]=de):de=e[87];let ue;e[88]!==x||e[89]!==a?(ue=a(x?"settings.connectForms.saving":"settings.connectForms.saveConnection"),e[88]=x,e[89]=a,e[90]=ue):ue=e[90];let me;e[91]!==x||e[92]!==ue?(me=s.jsx(ne,{type:"submit",size:"sm",disabled:x,children:ue}),e[91]=x,e[92]=ue,e[93]=me):me=e[93];let he;e[94]!==de||e[95]!==me?(he=s.jsxs(Xe,{children:[de,me]}),e[94]=de,e[95]=me,e[96]=he):he=e[96];let ye;return e[97]!==w||e[98]!==F||e[99]!==K||e[100]!==$||e[101]!==U||e[102]!==B||e[103]!==he?(ye=s.jsxs("form",{onSubmit:w,className:"space-y-3",children:[F,K,$,U,B,he]}),e[97]=w,e[98]=F,e[99]=K,e[100]=$,e[101]=U,e[102]=B,e[103]=he,e[104]=ye):ye=e[104],ye}const ys={kind:"closed"};function js(l,e){switch(e.type){case"open":return l.kind==="closed"?{kind:"grid"}:l;case"close":return{kind:"closed"};case"back":switch(l.kind){case"form":case"oauth-pending":case"provision-pending":case"provision-error":return{kind:"grid"};default:return l}case"select-form":return l.kind!=="grid"?l:{kind:"form",providerId:e.providerId,presetId:e.presetId};case"select-oauth":return l.kind!=="grid"?l:{kind:"oauth-pending",providerId:e.providerId,stateToken:e.stateToken};case"oauth-failed":return l.kind==="oauth-pending"?{kind:"grid"}:l;case"select-provision":return l.kind!=="grid"?l:{kind:"provision-pending",providerId:e.providerId};case"provision-error":return l.kind!=="provision-pending"?l:{kind:"provision-error",providerId:l.providerId,error:e.error};case"retry-provision":return l.kind!=="provision-error"?l:{kind:"provision-pending",providerId:l.providerId}}}function Ss(l){switch(l.kind){case"form":case"oauth-pending":case"provision-pending":case"provision-error":return l.providerId;default:return null}}function Ns({open:l,onOpenChange:e,initialProvider:t}){const i=se(),n=Me()?.providers??[],{org:r}=xe(),c=we(),u=Ie(),[d,a]=V.useReducer(js,ys),h=V.useRef(!1);V.useEffect(()=>{l&&d.kind==="closed"?a({type:"open"}):!l&&d.kind!=="closed"&&a({type:"close"})},[l,d.kind]);const p=()=>{h.current=!1,a({type:"close"}),e(!1)},m=()=>{u.invalidateQueries({queryKey:ce.aiProviderKeys(r.id)}),u.invalidateQueries({queryKey:ce.aiProviders(r.id)})},{mutate:f}=ke({mutationFn:async({providerId:v,code:g,stateToken:j,label:w})=>(await c.call("AI_PROVIDER_OAUTH_EXCHANGE",{providerId:v,code:g,stateToken:j,label:w}),v),onSuccess:v=>{ie("ai_provider_oauth_succeeded",{provider_id:v}),m();const g=n.find(j=>j.id===v);le.success(i("settings.connectProviderDialog.oauthSuccessMessage",{provider:g?.name??i("settings.connectProviderDialog.defaultProviderName")})),p()},onError:(v,g)=>{ie("ai_provider_oauth_failed",{provider_id:g.providerId,error:v.message}),le.error(i("settings.connectProviderDialog.oauthFailedMessage",{error:v.message})),a({type:"oauth-failed"})}}),{mutate:b}=ke({mutationFn:async v=>(await c.call("AI_PROVIDER_PROVISION_KEY",{providerId:v}),v),onSuccess:v=>{ie("ai_provider_provision_succeeded",{provider_id:v}),m();const g=n.find(j=>j.id===v);le.success(i("settings.connectProviderDialog.provisionSuccessMessage",{provider:g?.name??i("settings.connectProviderDialog.defaultProviderName")})),p()},onError:(v,g)=>{ie("ai_provider_provision_failed",{provider_id:g,error:v.message}),a({type:"provision-error",error:v.message})}}),k=async v=>{const{provider:g}=v,j=v.kind==="openai-compatible"?v.preset?.id??null:null,w=g.supportedMethods.includes("oauth-pkce"),T=g.supportedMethods.includes("api-key");if(g.supportsProvision===!0){ie("ai_provider_connect_clicked",{provider_id:g.id,method:"provision"}),a({type:"select-provision",providerId:g.id}),b(g.id);return}if(w){ie("ai_provider_connect_clicked",{provider_id:g.id,method:"oauth-pkce"});try{const O=await c.call("AI_PROVIDER_OAUTH_URL",{providerId:g.id,callbackUrl:`${window.location.origin}/oauth/callback/ai-provider`});if(!O?.url)throw new Error("Invalid response from AI_PROVIDER_OAUTH_URL");a({type:"select-oauth",providerId:g.id,stateToken:O.stateToken}),window.open(O.url,"AiProviderOAuth","width=600,height=700")}catch(O){le.error(i("settings.connectProviderDialog.startOAuthFailedMessage",{error:O instanceof Error?O.message:String(O)}))}return}T&&(ie("ai_provider_connect_clicked",{provider_id:g.id,...j!==null?{preset_id:j}:{},method:"api-key"}),a({type:"select-form",providerId:g.id,presetId:j}))},y=V.useRef(k);y.current=k;const S=V.useRef(t);S.current=t,V.useEffect(()=>{!S.current||d.kind!=="grid"||h.current||(h.current=!0,y.current(S.current))},[d.kind]);const I=d.kind==="oauth-pending"?d.stateToken:null,P=d.kind==="oauth-pending"?d.providerId:null;V.useEffect(()=>{if(d.kind!=="oauth-pending")return;let v=!1;const g=d.stateToken,j=d.providerId,w=A=>{if(A.origin!==window.location.origin||A.data?.type!=="AI_PROVIDER_OAUTH_CALLBACK")return;const{code:O,stateToken:z}=A.data;if(z!==g){le.error(i("settings.connectProviderDialog.securityCheckFailedMessage")),a({type:"oauth-failed"});return}v=!0;const F=n.find(K=>K.id===j);f({providerId:j,code:O,stateToken:g,label:F?.name??j})};window.addEventListener("message",w);const T=setTimeout(()=>{v||(ie("ai_provider_oauth_timeout",{provider_id:j}),a({type:"oauth-failed"}),le.error(i("settings.connectProviderDialog.connectionTimedOutMessage")))},12e4);return()=>{window.removeEventListener("message",w),clearTimeout(T)}},[d.kind,I,P,f]);const E=Ss(d),_=E?n.find(v=>v.id===E):null,N=(d.kind==="form"&&d.presetId?be(d.presetId):null)?.name??_?.name??i("settings.connectProviderDialog.defaultTitle"),C=d.kind!=="grid"&&d.kind!=="closed",M=()=>{t?p():a({type:"back"})};return s.jsx(Ye,{open:d.kind!=="closed",onOpenChange:v=>!v&&p(),children:s.jsxs(Qe,{className:"sm:max-w-md max-h-[90vh] overflow-y-auto",children:[s.jsxs(St,{children:[s.jsxs("div",{className:"flex items-center gap-2",children:[C&&s.jsx(ne,{variant:"ghost",size:"icon","aria-label":i("settings.connectProviderDialog.backButtonLabel"),className:"h-7 w-7",onClick:M,children:s.jsx(et,{size:16})}),s.jsx(Je,{children:N})]}),d.kind==="grid"&&!t&&s.jsx(Nt,{children:i("settings.connectProviderDialog.gridDescription")})]}),d.kind==="grid"&&!t&&s.jsx(ot,{providers:n,onSelect:k}),d.kind==="form"&&(d.providerId==="openai-compatible"?s.jsx(bs,{preset:d.presetId?be(d.presetId):void 0,onCancel:()=>a({type:"back"}),onSuccess:()=>{m(),p()}}):s.jsx(gs,{providerId:d.providerId,onCancel:()=>a({type:"back"}),onSuccess:()=>{m(),p()}})),d.kind==="oauth-pending"&&s.jsxs("div",{className:"flex flex-col items-center gap-4 py-8",children:[s.jsx(Le,{size:"lg"}),s.jsx("p",{className:"text-sm text-muted-foreground text-center",children:i("settings.connectProviderDialog.oauthPendingMessage")})]}),d.kind==="provision-pending"&&s.jsxs("div",{className:"flex flex-col items-center gap-4 py-8",children:[s.jsx(Le,{size:"lg"}),s.jsx("p",{className:"text-sm text-muted-foreground",children:i("settings.connectProviderDialog.provisionPendingMessage")})]}),d.kind==="provision-error"&&s.jsxs("div",{className:"flex flex-col items-center gap-4 py-6",children:[s.jsx(Xt,{size:28,className:"text-destructive"}),s.jsx("p",{className:"text-sm text-foreground text-center",children:d.error}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(ne,{variant:"outline",size:"sm",onClick:()=>a({type:"back"}),children:i("settings.connectProviderDialog.backButton")}),s.jsx(ne,{size:"sm",onClick:()=>{a({type:"retry-provision"}),b(d.providerId)},children:i("settings.connectProviderDialog.retryButton")})]})]})]})})}function ks(){const l=G.c(7),{org:e}=xe(),t=we();let i;l[0]!==e.id?(i=ce.defaultBrand(e.id),l[0]=e.id,l[1]=i):i=l[1];let o;l[2]!==t?(o=async()=>{const{items:c}=await t.call("BRAND_CONTEXT_LIST",{});return(Array.isArray(c)?c:[]).find(Cs)??null},l[2]=t,l[3]=o):o=l[3];let n;l[4]!==i||l[5]!==o?(n={queryKey:i,queryFn:o},l[4]=i,l[5]=o,l[6]=n):n=l[6];const{data:r}=vt(n);return r??null}function Cs(l){return l.isDefault&&!l.archivedAt}function ws(l){const e=l.colors;if(!e)return null;if(Array.isArray(e)){const t=e.find(o=>typeof o=="object"&&o!==null&&"label"in o&&/primary|brand|main/i.test(o.label)),i=t?t.value:e[0]?.value;return typeof i=="string"?i:null}if(typeof e=="object"){const t=e;return t.primary??Object.values(t)[0]??null}return null}function Is(l){const e=G.c(66);let t;e[0]!==l?(t=l===void 0?{}:l,e[0]=l,e[1]=t):t=e[1];const{title:i,description:o,onLocalRuntimePicked:n}=t,r=se(),{org:c}=xe(),{localMode:u}=gt(),d=ks(),a=Et(),h=Ot(),[p,m]=V.useState(null),[f,b]=V.useState(!1),[k,y]=V.useState(!1),S=Me();let I;e[2]!==S?.providers?(I=S?.providers??[],e[2]=S?.providers,e[3]=I):I=e[3];const P=I;let E,_,x;if(e[4]!==d||e[5]!==h||e[6]!==o||e[7]!==a.capabilities||e[8]!==a.online||e[9]!==u||e[10]!==n||e[11]!==c.name||e[12]!==r||e[13]!==i){const O=[];if(a.online){if(a.capabilities.includes("claude-code")){let B;e[17]===Symbol.for("react.memo_cache_sentinel")?(B=s.jsx(Se,{size:16}),e[17]=B):B=e[17],O.push({option:"claude-code-desktop",label:"Claude Code",icon:B})}if(a.capabilities.includes("codex")){let B;e[18]===Symbol.for("react.memo_cache_sentinel")?(B=s.jsx(Ne,{size:16}),e[18]=B):B=e[18],O.push({option:"codex-desktop",label:"Codex",icon:B})}}const z=O.length>0&&h!==null,F=c.name;let K;e[19]!==d?(K=d?ws(d):null,e[19]=d,e[20]=K):K=e[20];const R=K,W=d?.favicon??d?.logo??null;let Q;e[21]!==F||e[22]!==r||e[23]!==i?(Q=i??(F?r("chat.noAiProviderEmptyState.headingWithOrg",{org:F}):r("chat.noAiProviderEmptyState.headingDefault")),e[21]=F,e[22]=r,e[23]=i,e[24]=Q):Q=e[24];const J=Q;let Z;e[25]!==o||e[26]!==z||e[27]!==u||e[28]!==r?(Z=o??r(z?"chat.noAiProviderEmptyState.subtitleWithDesktop":u?"chat.noAiProviderEmptyState.subtitleLocalMode":"chat.noAiProviderEmptyState.subtitleDefault"),e[25]=o,e[26]=z,e[27]=u,e[28]=r,e[29]=Z):Z=e[29];const X=Z,ee=!!(W||R);let H;e[30]!==R?(H=R?{backgroundColor:`${R}18`,borderColor:`${R}30`}:void 0,e[30]=R,e[31]=H):H=e[31];const q=H,Y=ee?"flex items-center justify-center size-14 rounded-2xl border":"flex items-center justify-center size-14 rounded-2xl bg-muted border border-border";E="flex flex-col items-center gap-8 w-full max-w-3xl px-4";let L;e[32]!==Y||e[33]!==q||e[34]!==W||e[35]!==a.online||e[36]!==R||e[37]!==r?(L=W?s.jsx("div",{className:Y,style:q,children:s.jsx("img",{src:W,alt:"",className:"size-7 rounded object-contain"})}):s.jsx("button",{type:"button",onClick:()=>y(!0),"aria-label":a.online?r("chat.noAiProviderEmptyState.desktopLinkedLabel"):r("chat.noAiProviderEmptyState.connectDesktopLabel"),className:oe(Y,"cursor-pointer transition-colors hover:bg-accent"),style:q,children:s.jsxs("span",{className:"relative inline-flex items-center justify-center",children:[s.jsx(Gt,{size:24,style:R?{color:R}:void 0,className:oe(!R&&"text-muted-foreground")}),a.online&&s.jsx("span",{className:"absolute -top-0.5 -right-0.5 size-2.5 rounded-full bg-success ring-2 ring-background animate-pulse"})]})}),e[32]=Y,e[33]=q,e[34]=W,e[35]=a.online,e[36]=R,e[37]=r,e[38]=L):L=e[38];let D;e[39]!==J?(D=s.jsx("p",{className:"text-xl font-semibold text-foreground tracking-tight",children:J}),e[39]=J,e[40]=D):D=e[40];let $;e[41]!==X?($=s.jsx("p",{className:"text-sm text-muted-foreground max-w-md",children:X}),e[41]=X,e[42]=$):$=e[42];let U;e[43]!==D||e[44]!==$?(U=s.jsxs("div",{className:"space-y-2",children:[D,$]}),e[43]=D,e[44]=$,e[45]=U):U=e[45],e[46]!==L||e[47]!==U?(_=s.jsxs("div",{className:"flex flex-col items-center gap-4 text-center",children:[L,U]}),e[46]=L,e[47]=U,e[48]=_):_=e[48],x=z&&s.jsxs("div",{className:"flex flex-col items-center gap-3 w-full",children:[s.jsx("div",{className:"flex flex-wrap items-center justify-center gap-2",children:O.map(B=>s.jsxs(ne,{variant:"default",className:"gap-2",onClick:()=>{h?.setPendingAgentOption(B.option),n?.(B.option)},children:[B.icon,r("chat.noAiProviderEmptyState.useLabel",{label:B.label})]},B.option))}),s.jsxs("div",{className:"flex items-center gap-3 w-full max-w-xs text-xs text-muted-foreground",children:[s.jsx("span",{className:"h-px flex-1 bg-border"}),r("chat.noAiProviderEmptyState.orConnectProvider"),s.jsx("span",{className:"h-px flex-1 bg-border"})]})]}),e[4]=d,e[5]=h,e[6]=o,e[7]=a.capabilities,e[8]=a.online,e[9]=u,e[10]=n,e[11]=c.name,e[12]=r,e[13]=i,e[14]=E,e[15]=_,e[16]=x}else E=e[14],_=e[15],x=e[16];let N,C;e[49]===Symbol.for("react.memo_cache_sentinel")?(N=O=>m(O),C=()=>b(!0),e[49]=N,e[50]=C):(N=e[49],C=e[50]);let M;e[51]!==P?(M=s.jsx("div",{className:"w-full",children:s.jsx(ot,{providers:P,onSelect:N,onShowAll:C})}),e[51]=P,e[52]=M):M=e[52];const v=p!==null||f;let g;e[53]===Symbol.for("react.memo_cache_sentinel")?(g=O=>{O||(m(null),b(!1))},e[53]=g):g=e[53];const j=p??void 0;let w;e[54]!==j||e[55]!==v?(w=s.jsx(Ns,{open:v,onOpenChange:g,initialProvider:j}),e[54]=j,e[55]=v,e[56]=w):w=e[56];let T;e[57]!==k?(T=s.jsx(Jt,{open:k,onOpenChange:y}),e[57]=k,e[58]=T):T=e[58];let A;return e[59]!==w||e[60]!==T||e[61]!==E||e[62]!==_||e[63]!==x||e[64]!==M?(A=s.jsxs("div",{className:E,children:[_,x,M,w,T]}),e[59]=w,e[60]=T,e[61]=E,e[62]=_,e[63]=x,e[64]=M,e[65]=A):A=e[65],A}function Oe(l){const e=l.title.includes(": ");return{provider:e?l.title.split(": ")[0]??"":l.modelId.split("/")[0]??"",displayName:e?l.title.split(": ").slice(1).join(": "):l.title}}function _s(l){return l<32e3?{level:1,labelKey:"chat.shared.contextLevelSmall",descriptionKey:"chat.shared.contextLevelSmallDesc"}:l<2e5?{level:2,labelKey:"chat.shared.contextLevelMedium",descriptionKey:"chat.shared.contextLevelMediumDesc"}:l<5e5?{level:3,labelKey:"chat.shared.contextLevelLarge",descriptionKey:"chat.shared.contextLevelLargeDesc"}:{level:4,labelKey:"chat.shared.contextLevelVeryLarge",descriptionKey:"chat.shared.contextLevelVeryLargeDesc"}}const Ms=["bg-destructive","bg-warning","bg-success","bg-success"],Es=["text-success","text-warning","text-warning","text-destructive"];function Os(l,e){const t=Math.round(l*.75/1e3),i=t>=1?`${t}K`:`${Math.round(l*.75)}`;return e("chat.shared.approxWords",{wordCount:i})}function Ps(l){return l<1?{level:1,labelKey:"chat.shared.costLevelCheap"}:l<5?{level:2,labelKey:"chat.shared.costLevelModerate"}:l<15?{level:3,labelKey:"chat.shared.costLevelHigh"}:{level:4,labelKey:"chat.shared.costLevelExpensive"}}const Ls={text:{icon:s.jsx(Bt,{className:"size-3.5"}),labelKey:"chat.shared.capabilityText"},vision:{icon:s.jsx(Ut,{className:"size-3.5"}),labelKey:"chat.shared.capabilityVision"},image:{icon:s.jsx(Ft,{className:"size-3.5"}),labelKey:"chat.shared.capabilityImage"},tools:{icon:s.jsx($t,{className:"size-3.5"}),labelKey:"chat.shared.capabilityTools"},reasoning:{icon:s.jsx(Zt,{className:"size-3.5"}),labelKey:"chat.shared.capabilityReasoning"},"web-search":{icon:s.jsx(tt,{className:"size-3.5"}),labelKey:"chat.shared.capabilityWebSearch"}};function As(l){const e=G.c(10),{capability:t}=l,i=se(),o=Ls[t];if(o){const u=o.icon;let d;e[0]!==o.labelKey||e[1]!==i?(d=i(o.labelKey),e[0]=o.labelKey,e[1]=i,e[2]=d):d=e[2];let a;return e[3]!==o.icon||e[4]!==d?(a=s.jsxs("span",{className:"inline-flex items-center gap-1 text-xs text-muted-foreground border border-border rounded px-2 py-0.5",children:[u,d]}),e[3]=o.icon,e[4]=d,e[5]=a):a=e[5],a}let n;e[6]!==t?(n=t.charAt(0).toUpperCase(),e[6]=t,e[7]=n):n=e[7];const r=n+t.slice(1);let c;return e[8]!==r?(c=s.jsx("span",{className:"inline-flex items-center gap-1 text-xs text-muted-foreground border border-border rounded px-2 py-0.5",children:r}),e[8]=r,e[9]=c):c=e[9],c}function Ts(l){const e=G.c(59),{model:t,compact:i}=l,o=i===void 0?!1:i,n=se();if(!t){let x;e[0]!==n?(x=n("chat.shared.hoverToPreview"),e[0]=n,e[1]=x):x=e[1];let N;return e[2]!==x?(N=s.jsx("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:x}),e[2]=x,e[3]=N):N=e[3],N}const r=t.costs?.input!=null?t.costs.input*1e6:null,c=t.costs?.output!=null?t.costs.output*1e6:null;let u;e[4]!==t?(u=Oe(t),e[4]=t,e[5]=u):u=e[5];const{provider:d,displayName:a}=u;if(o){let x;e[6]!==t.limits||e[7]!==n?(x=t.limits?.contextWindow&&s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-muted-foreground",children:n("chat.shared.context")}),s.jsxs("span",{className:"text-foreground font-medium",children:[t.limits.contextWindow.toLocaleString()," ",n("chat.shared.tokens")]})]}),e[6]=t.limits,e[7]=n,e[8]=x):x=e[8];let N;e[9]!==r||e[10]!==n?(N=r!=null&&s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-muted-foreground",children:n("chat.shared.input")}),s.jsxs("span",{className:"text-foreground font-medium",children:["$",r.toFixed(2)," / 1M"]})]}),e[9]=r,e[10]=n,e[11]=N):N=e[11];let C;e[12]!==c||e[13]!==n?(C=c!=null&&s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-muted-foreground",children:n("chat.shared.output")}),s.jsxs("span",{className:"text-foreground font-medium",children:["$",c.toFixed(2)," / 1M"]})]}),e[12]=c,e[13]=n,e[14]=C):C=e[14];let M;e[15]!==t.limits||e[16]!==n?(M=t.limits?.maxOutputTokens&&s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-muted-foreground",children:n("chat.shared.outputLimit")}),s.jsxs("span",{className:"text-foreground font-medium",children:[t.limits.maxOutputTokens.toLocaleString()," ",n("chat.shared.tokens")]})]}),e[15]=t.limits,e[16]=n,e[17]=M):M=e[17];let v;return e[18]!==x||e[19]!==N||e[20]!==C||e[21]!==M?(v=s.jsxs("div",{className:"flex flex-col gap-2 pt-3 pb-3 px-3 text-xs",children:[x,N,C,M]}),e[18]=x,e[19]=N,e[20]=C,e[21]=M,e[22]=v):v=e[22],v}let h;e[23]!==d?(h=s.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:d}),e[23]=d,e[24]=h):h=e[24];let p;e[25]!==t.logo||e[26]!==t.title?(p=t.logo&&s.jsx("img",{src:t.logo,className:"size-6 shrink-0 rounded-md dark:bg-white dark:rounded-sm dark:p-px",alt:t.title}),e[25]=t.logo,e[26]=t.title,e[27]=p):p=e[27];let m;e[28]!==a?(m=s.jsx("p",{className:"text-lg font-semibold leading-snug tracking-tight",children:a}),e[28]=a,e[29]=m):m=e[29];let f;e[30]!==p||e[31]!==m?(f=s.jsxs("div",{className:"flex items-center gap-2.5",children:[p,m]}),e[30]=p,e[31]=m,e[32]=f):f=e[32];let b;e[33]!==t.modelId?(b=s.jsx("p",{className:"text-xs text-muted-foreground/50 font-mono",children:t.modelId}),e[33]=t.modelId,e[34]=b):b=e[34];let k;e[35]!==h||e[36]!==f||e[37]!==b?(k=s.jsxs("div",{className:"flex flex-col gap-1 pt-1 pr-6",children:[h,f,b]}),e[35]=h,e[36]=f,e[37]=b,e[38]=k):k=e[38];let y;e[39]!==t.capabilities?(y=t.capabilities&&t.capabilities.length>0&&s.jsx("div",{className:"flex flex-wrap items-center gap-1.5 pb-4 border-b border-border",children:[...new Set(t.capabilities)].map(zs)}),e[39]=t.capabilities,e[40]=y):y=e[40];let S;e[41]!==t.limits||e[42]!==n?(S=t.limits?.contextWindow&&(()=>{const{level:x,labelKey:N,descriptionKey:C}=_s(t.limits.contextWindow);return s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:n("chat.shared.contextWindow")}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"flex items-center gap-0.5",children:[1,2,3,4].map(M=>s.jsx("div",{className:oe("w-2 h-2 rounded-full",M<=x?Ms[x-1]:"bg-muted")},M))}),s.jsx("span",{className:"text-xs text-muted-foreground font-medium",children:n(N)}),s.jsxs("span",{className:"text-xs text-muted-foreground",children:["— ",n(C)]})]}),s.jsxs("span",{className:"text-sm text-muted-foreground",children:[t.limits.contextWindow.toLocaleString()," ",n("chat.shared.tokens")]})]})})(),e[41]=t.limits,e[42]=n,e[43]=S):S=e[43];let I;e[44]!==t.limits||e[45]!==n?(I=t.limits?.maxOutputTokens&&s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:n("chat.shared.outputLimit")}),s.jsxs("div",{className:"flex items-baseline gap-2",children:[s.jsxs("span",{className:"text-sm text-foreground",children:[t.limits.maxOutputTokens.toLocaleString()," ",n("chat.shared.tokens")]}),s.jsx("span",{className:"text-sm text-muted-foreground",children:Os(t.limits.maxOutputTokens,n)})]})]}),e[44]=t.limits,e[45]=n,e[46]=I):I=e[46];let P;e[47]!==r||e[48]!==c||e[49]!==n?(P=(r!=null||c!=null)&&(()=>{const{level:x,labelKey:N}=r!=null?Ps(r):{level:0,labelKey:null};return s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:n("chat.shared.pricing")}),r!=null&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"flex items-center",children:[1,2,3,4].map(C=>s.jsx("span",{className:oe("text-sm font-bold leading-none",C<=x?Es[x-1]:"text-muted-foreground/20"),children:"$"},C))}),s.jsx("span",{className:"text-xs text-muted-foreground font-medium",children:N?n(N):""})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[r!=null&&s.jsxs("div",{className:"flex justify-between items-center",children:[s.jsx("span",{className:"text-xs text-muted-foreground",children:n("chat.shared.input")}),s.jsxs("span",{className:"text-xs text-foreground",children:["$",r.toFixed(2)," / 1M"," ",n("chat.shared.tokens")]})]}),c!=null&&s.jsxs("div",{className:"flex justify-between items-center",children:[s.jsx("span",{className:"text-xs text-muted-foreground",children:n("chat.shared.output")}),s.jsxs("span",{className:"text-xs text-foreground",children:["$",c.toFixed(2)," / 1M"," ",n("chat.shared.tokens")]})]})]})]})})(),e[47]=r,e[48]=c,e[49]=n,e[50]=P):P=e[50];let E;e[51]!==S||e[52]!==I||e[53]!==P?(E=s.jsxs("div",{className:"flex flex-col gap-6",children:[S,I,P]}),e[51]=S,e[52]=I,e[53]=P,e[54]=E):E=e[54];let _;return e[55]!==E||e[56]!==k||e[57]!==y?(_=s.jsxs("div",{className:"flex flex-col gap-5 py-1 px-1.5",children:[k,y,E]}),e[55]=E,e[56]=k,e[57]=y,e[58]=_):_=e[58],_}function zs(l){return s.jsx(As,{capability:l},l)}function rt(l){const e=G.c(22),{model:t,placeholder:i,isLoading:o}=l,n=o===void 0?!1:o,r=se();let c;e[0]!==i||e[1]!==r?(c=i??r("chat.shared.selectModel"),e[0]=i,e[1]=r,e[2]=c):c=e[2];const u=c;if(n){let y;return e[3]===Symbol.for("react.memo_cache_sentinel")?(y=s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(te,{className:"w-5 h-5 rounded-sm shrink-0"}),s.jsx(te,{className:"w-16 h-3 hidden md:block"})]}),e[3]=y):y=e[3],y}if(!t){let y;e[4]!==u?(y=s.jsx("span",{className:"text-sm text-muted-foreground",children:u}),e[4]=u,e[5]=y):y=e[5];let S;e[6]===Symbol.for("react.memo_cache_sentinel")?(S=s.jsx(ze,{size:14,className:"text-muted-foreground opacity-50 shrink-0"}),e[6]=S):S=e[6];let I;return e[7]!==y?(I=s.jsxs("div",{className:"flex items-center gap-1.5",children:[y,S]}),e[7]=y,e[8]=I):I=e[8],I}let d;e[9]!==t?(d=Oe(t),e[9]=t,e[10]=d):d=e[10];const{displayName:a}=d;let h;e[11]!==t?(h=Ee(t),e[11]=t,e[12]=h):h=e[12];const p=h;let m;e[13]!==t.title||e[14]!==p?(m=s.jsx("img",{src:p,className:"w-3.5 h-3.5 shrink-0 rounded-sm dark:bg-white dark:rounded-sm dark:p-px",alt:t.title}),e[13]=t.title,e[14]=p,e[15]=m):m=e[15];let f;e[16]!==a?(f=s.jsx("span",{className:"text-sm truncate whitespace-nowrap text-muted-foreground max-w-[100px] sm:max-w-none",children:a}),e[16]=a,e[17]=f):f=e[17];let b;e[18]===Symbol.for("react.memo_cache_sentinel")?(b=s.jsx(ze,{size:14,className:"text-muted-foreground opacity-50 shrink-0"}),e[18]=b):b=e[18];let k;return e[19]!==m||e[20]!==f?(k=s.jsxs("div",{className:"flex items-center gap-1.5 min-w-0 overflow-hidden",children:[m,f,b]}),e[19]=m,e[20]=f,e[21]=k):k=e[21],k}const Rs=["vision","image","file","audio","video"],at=["image/png","image/jpeg","image/gif","image/webp"],ct=["application/vnd.openxmlformats-officedocument.presentationml.presentation","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"];function Pe(l){const e=l?.capabilities;return e?Rs.some(t=>e.includes(t)):!1}function qi(l,e){if(!l)return!1;if(l.startsWith("text/"))return!0;const t=e?.capabilities??[],i=t.includes("vision")||t.includes("image"),o=t.includes("file"),n=t.includes("audio"),r=t.includes("video");return!!(i&&at.includes(l)||o&&l==="application/pdf"||n&&l.startsWith("audio/")||r&&l.startsWith("video/")||Pe(e)&&ct.includes(l))}function Gi(l){const e=l?.capabilities??[],t=["text/*"];return(e.includes("vision")||e.includes("image"))&&t.push(...at),e.includes("file")&&t.push("application/pdf"),e.includes("audio")&&t.push("audio/*"),e.includes("video")&&t.push("video/*"),Pe(l)&&t.push(...ct),t.join(",")}function Xi(l){const e=l?.capabilities??[],t=[];return(e.includes("vision")||e.includes("image"))&&t.push("chat.shared.fileTypeImages"),e.includes("file")&&t.push("chat.shared.fileTypePdfs"),e.includes("audio")&&t.push("chat.shared.fileTypeAudio"),e.includes("video")&&t.push("chat.shared.fileTypeVideo"),Pe(l)&&t.push("chat.shared.fileTypeOffice"),{parts:t,count:t.length}}const dt=["smarter","faster","cheaper"],Fs={smarter:"chat.decopilot.tierSmarter",faster:"chat.decopilot.tierFaster",cheaper:"chat.decopilot.tierCheaper"},Ds=[{tier:"smarter",prefixes:["anthropic/claude-opus-4.8","anthropic/claude-sonnet-4.6","anthropic/claude-4.6-sonnet","openai/gpt-5.3-codex","google/gemini-3-pro","google/gemini-2.5-pro","cohere/command-r-plus","cohere/command-a"]},{tier:"faster",prefixes:["anthropic/claude-haiku-4.5","anthropic/claude-4.5-haiku","google/gemini-3-flash","openai/gpt-5.1-codex-mini","x-ai/grok-code-fast","x-ai/grok-3","mistralai/mistral-large","mistralai/codestral","mistralai/mistral-medium","minimax/minimax-m1"]},{tier:"cheaper",prefixes:["google/gemini-2.5-flash-lite","google/gemini-2.5-flash","google/gemini-2.0-flash","deepseek/deepseek-v3","openai/gpt-oss-120b","mistralai/mistral-small","mistralai/pixtral","cohere/command-r"]}],Ks=Ds.flatMap(({tier:l,prefixes:e})=>e.map(t=>({tier:l,prefix:t}))).sort((l,e)=>e.prefix.length-l.prefix.length),$s="google/gemini-2.5-pro",Be=new Map;function Us(l){const e=Be.get(l);if(e!==void 0)return e;let t=null;if(l.endsWith(":free"))t="cheaper";else for(const{tier:i,prefix:o}of Ks)if(l.startsWith(o)){if(o===$s&&l.length>o.length&&l[o.length]==="-"){const r=l[o.length+1];if(!r||!/\d/.test(r))continue}t=i;break}return Be.set(l,t),t}function We(l){const e={smarter:[],faster:[],cheaper:[],other:[]};for(const t of l){const i=Us(t.modelId);e[i??"other"].push(t)}for(const t of Object.keys(e))e[t].sort((i,o)=>i.title.localeCompare(o.title));return e}const ut="studio:model-shortlist:",Bs=new Set(["anthropic/claude-opus-4.8","anthropic/claude-sonnet-4.6","anthropic/claude-4.6-sonnet","anthropic/claude-sonnet-4.6:extended","openai/gpt-5.3-codex","google/gemini-3-pro-preview","google/gemini-2.5-pro","anthropic/claude-haiku-4.5","anthropic/claude-haiku-4.5-20251001","anthropic/claude-4.5-haiku","google/gemini-3-flash-preview","openai/gpt-5.1-codex-mini","x-ai/grok-code-fast-1","google/gemini-2.5-flash","deepseek/deepseek-v3.2","google/gemini-2.5-flash-lite","openai/gpt-oss-120b:free"]);function Ws(l){try{const e=localStorage.getItem(ut+l);return e?new Set(JSON.parse(e)):null}catch{return null}}function Vs(l,e){localStorage.setItem(ut+l,JSON.stringify([...e]))}function Hs(l){const e=G.c(21),{model:t,onHover:i}=l;let o;e[0]!==t?(o=Oe(t),e[0]=t,e[1]=o):o=e[1];const{displayName:n,provider:r}=o;let c;e[2]!==t?(c=Ee(t),e[2]=t,e[3]=c):c=e[3];const u=c;let d;e[4]!==t||e[5]!==i?(d=()=>i(t),e[4]=t,e[5]=i,e[6]=d):d=e[6];let a;e[7]!==t.title||e[8]!==u?(a=s.jsx("img",{src:u,className:"w-4 h-4 shrink-0 rounded-sm dark:bg-white dark:rounded-sm dark:p-px",alt:t.title}),e[7]=t.title,e[8]=u,e[9]=a):a=e[9];let h;e[10]!==n?(h=s.jsx("span",{className:"text-sm text-foreground leading-tight truncate",children:n}),e[10]=n,e[11]=h):h=e[11];let p;e[12]!==r?(p=s.jsx("span",{className:"text-xs text-muted-foreground/60 leading-tight",children:r}),e[12]=r,e[13]=p):p=e[13];let m;e[14]!==h||e[15]!==p?(m=s.jsxs("div",{className:"flex flex-col flex-1 min-w-0",children:[h,p]}),e[14]=h,e[15]=p,e[16]=m):m=e[16];let f;return e[17]!==d||e[18]!==a||e[19]!==m?(f=s.jsxs("div",{className:"flex items-center gap-2.5 py-2 px-3 hover:bg-accent cursor-pointer rounded-lg",onMouseEnter:d,children:[a,m]}),e[17]=d,e[18]=a,e[19]=m,e[20]=f):f=e[20],f}function qs(l){const e=G.c(16),{error:t,onRetry:i}=l,o=se();let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsx("div",{className:"bg-destructive/10 p-2 rounded-full",children:s.jsx(jt,{className:"size-5 text-destructive"})}),e[0]=n):n=e[0];const r=o("chat.decopilot.failedToLoadModels");let c;e[1]!==r?(c=s.jsx("p",{className:"text-sm font-medium text-foreground",children:r}),e[1]=r,e[2]=c):c=e[2];const u=t?.message||o("chat.decopilot.couldNotFetchModels"),d=" "+o("chat.decopilot.tryAnotherProviderOrRetry");let a;e[3]!==u||e[4]!==d?(a=s.jsxs("p",{className:"text-xs text-muted-foreground max-w-[260px]",children:[u,d]}),e[3]=u,e[4]=d,e[5]=a):a=e[5];let h;e[6]!==c||e[7]!==a?(h=s.jsxs("div",{className:"flex flex-col gap-1",children:[c,a]}),e[6]=c,e[7]=a,e[8]=h):h=e[8];let p;e[9]===Symbol.for("react.memo_cache_sentinel")?(p=s.jsx(Kt,{className:"size-3.5"}),e[9]=p):p=e[9];const m=o("chat.decopilot.retry");let f;e[10]!==i||e[11]!==m?(f=s.jsx("div",{className:"flex items-center gap-2",children:s.jsxs(ne,{variant:"outline",size:"sm",onClick:i,className:"gap-1.5",children:[p,m]})}),e[10]=i,e[11]=m,e[12]=f):f=e[12];let b;return e[13]!==f||e[14]!==h?(b=s.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-3 px-4 py-8 text-center",children:[n,h,f]}),e[13]=f,e[14]=h,e[15]=b):b=e[15],b}function Gs(){const l=G.c(1);let e;return l[0]===Symbol.for("react.memo_cache_sentinel")?(e=s.jsx("div",{className:"flex-1 overflow-y-auto p-2 space-y-1",children:Array.from({length:6}).map(Xs)}),l[0]=e):e=l[0],e}function Xs(l,e){return s.jsxs("div",{className:"flex items-center gap-2 min-h-8 py-3 px-3 rounded-lg",children:[s.jsx(te,{className:"size-5 shrink-0 rounded-sm"}),s.jsx(te,{className:"flex-1 h-4"}),s.jsx(te,{className:"w-16 h-5 shrink-0 rounded-md"})]},e)}function Ve(l){const e=G.c(12),{label:t,models:i,onSelect:o,onHover:n}=l;if(i.length===0)return null;let r;e[0]!==t?(r=s.jsx("div",{className:"text-xs font-medium text-muted-foreground px-3 pt-3 pb-1",children:t}),e[0]=t,e[1]=r):r=e[1];let c;if(e[2]!==i||e[3]!==n||e[4]!==o){let d;e[6]!==n||e[7]!==o?(d=a=>s.jsx("div",{onClick:()=>o(a),className:"cursor-pointer",children:s.jsx(Hs,{model:a,onHover:n})},a.modelId),e[6]=n,e[7]=o,e[8]=d):d=e[8],c=i.map(d),e[2]=i,e[3]=n,e[4]=o,e[5]=c}else c=e[5];let u;return e[9]!==r||e[10]!==c?(u=s.jsxs("div",{children:[r,c]}),e[9]=r,e[10]=c,e[11]=u):u=e[11],u}function Ce(l,e){return e(l==="other"?"chat.decopilot.tierOther":Fs[l])}function Ys(l){const e=G.c(21),{model:t,isChecked:i,onToggle:o,onHover:n}=l,[r,c]=V.useState(i);r!==i&&c(i);let u;e[0]!==t?(u=Ee(t),e[0]=t,e[1]=u):u=e[1];const d=u;let a;e[2]!==t||e[3]!==n?(a=()=>n(t),e[2]=t,e[3]=n,e[4]=a):a=e[4];let h;e[5]!==t.modelId||e[6]!==o?(h=()=>{c(Qs),o(t.modelId)},e[5]=t.modelId,e[6]=o,e[7]=h):h=e[7];let p;e[8]!==r||e[9]!==h?(p=s.jsx(Pt,{checked:r,onCheckedChange:h}),e[8]=r,e[9]=h,e[10]=p):p=e[10];let m;e[11]!==d||e[12]!==t.title?(m=s.jsx("img",{src:d,className:"w-5 h-5 shrink-0 rounded-sm dark:bg-white dark:rounded-sm dark:p-px",alt:t.title}),e[11]=d,e[12]=t.title,e[13]=m):m=e[13];let f;e[14]!==t.title?(f=s.jsx("span",{className:"text-sm text-foreground flex-1 min-w-0 line-clamp-1",children:t.title}),e[14]=t.title,e[15]=f):f=e[15];let b;return e[16]!==a||e[17]!==p||e[18]!==m||e[19]!==f?(b=s.jsxs("label",{className:"flex items-center gap-3 min-h-8 py-2.5 px-3 hover:bg-accent cursor-pointer rounded-lg",onMouseEnter:a,children:[p,m,f]}),e[16]=a,e[17]=p,e[18]=m,e[19]=f,e[20]=b):b=e[20],b}function Qs(l){return!l}function Js(l,e){const t=[];for(const i of dt)if(l[i].length>0){t.push({type:"header",label:Ce(i,e)});for(const o of l[i])t.push({type:"model",model:o})}if(l.other.length>0){t.push({type:"header",label:Ce("other",e)});for(const i of l.other)t.push({type:"model",model:i})}return t}function Zs({items:l,shortlistSet:e,onToggle:t,onHover:i}){const o=V.useRef(null),n=us({count:l.length,getScrollElement:()=>o.current,estimateSize:r=>l[r]?.type==="header"?36:44,overscan:6});return s.jsx("div",{ref:o,className:"flex-1 overflow-y-auto",children:s.jsx("div",{className:"relative",style:{height:n.getTotalSize()},children:n.getVirtualItems().map(r=>{const c=l[r.index];return c?s.jsx("div",{"data-index":r.index,ref:n.measureElement,className:"absolute left-0 right-0 top-0 px-0.5",style:{transform:`translateY(${r.start}px)`},children:c.type==="header"?s.jsx("div",{className:"text-xs font-medium text-muted-foreground px-3 pt-3 pb-1",children:c.label}):s.jsx(Ys,{model:c.model,isChecked:e.has(c.model.modelId),onToggle:t,onHover:i})},r.key):null})})})}function ei(l){const e=G.c(30),{keyId:t,searchTerm:i,onHover:o,onModelSelect:n,managing:r,onToggleManage:c,filterModels:u}=l,d=se(),{models:a}=qt(t),h=u?a.filter(u):a.filter(ti);let p;e[0]!==t?(p=()=>(t?Ws(t):null)??Bs,e[0]=t,e[1]=p):p=e[1];const[m,f]=V.useState(p),[,b]=V.useTransition();let k;e[2]!==t||e[3]!==b?(k=g=>{t&&b(()=>{f(j=>{const w=new Set(j);return w.has(g)?w.delete(g):w.add(g),Vs(t,w),w})})},e[2]=t,e[3]=b,e[4]=k):k=e[4];const y=k,S=i.toLowerCase().trim(),I=g=>S?g.filter(j=>j.title.toLowerCase().includes(S)||j.modelId.toLowerCase().includes(S)):g;if(r){const g=We(I(h)),j=Js(g,d);let w;e[5]!==m?(w=F=>m.has(F.modelId),e[5]=m,e[6]=w):w=e[6];const T=h.filter(w).length;let A;e[7]===Symbol.for("react.memo_cache_sentinel")?(A=s.jsx(et,{size:14}),e[7]=A):A=e[7];let O;e[8]!==d?(O=d("chat.decopilot.back"),e[8]=d,e[9]=O):O=e[9];let z;return e[10]!==c||e[11]!==O?(z=s.jsxs("button",{type:"button",onClick:c,className:"flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground cursor-pointer",children:[A,O]}),e[10]=c,e[11]=O,e[12]=z):z=e[12],s.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[s.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-border",children:[z,s.jsx("span",{className:"text-xs text-muted-foreground",children:d("chat.decopilot.selectedCount",{count:T})})]}),s.jsx(Zs,{items:j,shortlistSet:m,onToggle:y,onHover:o})]})}let P;e[13]!==m?(P=g=>m.has(g.modelId),e[13]=m,e[14]=P):P=e[14];const E=h.filter(P),_=E.length>0?E:h,x=We(I(_));let N;e[15]!==x||e[16]!==o||e[17]!==n||e[18]!==d?(N=dt.map(g=>s.jsx(Ve,{label:Ce(g,d),models:x[g],onSelect:n,onHover:o},g)),e[15]=x,e[16]=o,e[17]=n,e[18]=d,e[19]=N):N=e[19];let C;e[20]!==d?(C=Ce("other",d),e[20]=d,e[21]=C):C=e[21];let M;e[22]!==x.other||e[23]!==o||e[24]!==n||e[25]!==C?(M=s.jsx(Ve,{label:C,models:x.other,onSelect:n,onHover:o}),e[22]=x.other,e[23]=o,e[24]=n,e[25]=C,e[26]=M):M=e[26];let v;return e[27]!==N||e[28]!==M?(v=s.jsxs("div",{className:"flex-1 overflow-y-auto px-0.5 pt-1 [touch-action:pan-y]",children:[N,M]}),e[27]=N,e[28]=M,e[29]=v):v=e[29],v}function ti(l){return l.asyncResearch!==!0}function si(){const l=G.c(6);let e;l[0]===Symbol.for("react.memo_cache_sentinel")?(e=s.jsx("div",{className:"border-b border-border h-12 bg-background/95 backdrop-blur sticky top-0 z-10",children:s.jsxs("div",{className:"flex items-center gap-2.5 h-12 px-4",children:[s.jsx(te,{className:"size-4 shrink-0"}),s.jsx(te,{className:"flex-1 h-6"}),s.jsx(te,{className:"w-[140px] h-8 shrink-0"})]})}),l[0]=e):e=l[0];let t;l[1]===Symbol.for("react.memo_cache_sentinel")?(t=s.jsxs("div",{className:"flex-1 flex flex-col md:border-r md:w-[420px] md:min-w-[420px] min-h-0 overflow-hidden",children:[e,s.jsx("div",{className:"flex-1 overflow-y-auto p-2 space-y-1",children:Array.from({length:8}).map(ii)})]}),l[1]=t):t=l[1];let i;l[2]===Symbol.for("react.memo_cache_sentinel")?(i=s.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[s.jsx(te,{className:"size-6 shrink-0"}),s.jsx(te,{className:"h-6 w-32"})]}),l[2]=i):i=l[2];let o;l[3]===Symbol.for("react.memo_cache_sentinel")?(o=s.jsxs("div",{className:"flex flex-col gap-3 py-2 px-0",children:[i,s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(te,{className:"h-6 w-20 rounded-md"}),s.jsx(te,{className:"h-6 w-24 rounded-md"})]})]}),l[3]=o):o=l[3];let n;l[4]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsx(te,{className:"h-4 w-24"}),s.jsx(te,{className:"h-4 w-32"})]}),l[4]=n):n=l[4];let r;return l[5]===Symbol.for("react.memo_cache_sentinel")?(r=s.jsxs("div",{className:"flex flex-col md:flex-row h-full sm:h-[460px] min-h-0",children:[t,s.jsx("div",{className:"hidden md:block md:w-[320px] md:shrink-0 p-3",children:s.jsxs("div",{className:"flex flex-col gap-3 py-1 px-1.5",children:[o,s.jsxs("div",{className:"flex flex-col gap-4",children:[n,s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsx(te,{className:"h-4 w-16"}),s.jsx(te,{className:"h-4 w-40"})]})]})]})})]}),l[5]=r):r=l[5],r}function ii(l,e){return s.jsxs("div",{className:"flex items-center gap-2 min-h-8 py-3 px-3 rounded-lg",children:[s.jsx(te,{className:"size-5 shrink-0 rounded-sm"}),s.jsx(te,{className:"flex-1 h-4"}),s.jsx(te,{className:"w-16 h-5 shrink-0 rounded-md"})]},e)}function mt(l){const e=G.c(66),{onClose:t,credentialId:i,onCredentialChange:o,selectedModel:n,onModelChange:r,filterModels:c,compact:u}=l,d=se(),[a,h]=V.useState(null),[p,m]=V.useState(""),[f,b]=V.useState(!1),k=V.useRef(null),y=Me(),S=Ht();let I;e[0]!==y?.providers?(I=Object.fromEntries((y?.providers??[]).map(oi)),e[0]=y?.providers,e[1]=I):I=e[1];const P=I,E=bt(),{org:_}=xe();let x;e[2]!==o?(x=L=>{o(L),h(null)},e[2]=o,e[3]=x):x=e[3];const N=x;let C;e[4]!==i||e[5]!==t||e[6]!==r?(C=L=>{i&&(r(L),m(""),t())},e[4]=i,e[5]=t,e[6]=r,e[7]=C):C=e[7];const M=C;if(S.length===0){const L=!u&&"sm:w-[740px]";let D;e[8]!==L?(D=oe("flex items-center justify-center p-8 w-full",L),e[8]=L,e[9]=D):D=e[9];let $;e[10]===Symbol.for("react.memo_cache_sentinel")?($=s.jsx(Is,{}),e[10]=$):$=e[10];let U;return e[11]!==D?(U=s.jsx("div",{className:D,children:$}),e[11]=D,e[12]=U):U=e[12],U}const v=u?"sm:h-[420px]":"sm:h-[460px]";let g;e[13]!==v?(g=oe("flex flex-col md:flex-row h-full min-h-0",v),e[13]=v,e[14]=g):g=e[14];const j=u?"w-full":"md:border-r md:w-[420px] md:min-w-[420px]";let w;e[15]!==j?(w=oe("flex-1 flex flex-col min-h-0 overflow-hidden",j),e[15]=j,e[16]=w):w=e[16];let T;e[17]===Symbol.for("react.memo_cache_sentinel")?(T=s.jsx(tt,{size:16,className:"text-muted-foreground shrink-0"}),e[17]=T):T=e[17];let A;e[18]!==f||e[19]!==d?(A=d(f?"chat.decopilot.searchAllModels":"chat.decopilot.searchForModel"),e[18]=f,e[19]=d,e[20]=A):A=e[20];let O;e[21]===Symbol.for("react.memo_cache_sentinel")?(O=L=>m(L.target.value),e[21]=O):O=e[21];let z;e[22]!==p||e[23]!==A?(z=s.jsx(pe,{ref:k,type:"text",placeholder:A,value:p,onChange:O,className:"flex-1 min-w-0 border-0 !shadow-none focus-visible:ring-0 px-0 h-full text-sm placeholder:text-muted-foreground/50 bg-transparent"}),e[22]=p,e[23]=A,e[24]=z):z=e[24];let F;e[25]!==i||e[26]!==N||e[27]!==S||e[28]!==P||e[29]!==d?(F=S.length>0&&s.jsxs(Lt,{value:i??"",onValueChange:N,children:[s.jsxs(At,{size:"sm",className:"w-auto max-w-[140px] h-8 shrink-0 gap-1.5 px-2 [&>svg:last-child]:hidden",onClick:ni,children:[s.jsx(Tt,{placeholder:d("chat.decopilot.key"),children:(()=>{const L=S.find(re=>re.id===i),D=L?P[L.providerId]:void 0,$=be(L?.presetId),U=$?.logo??D?.logo,B=$?.name??D?.name??L?.providerId??"Key";return s.jsxs("span",{className:"flex items-center gap-1.5 min-w-0",children:[U?s.jsx("img",{src:U,alt:B,className:"w-4 h-4 rounded shrink-0 dark:bg-white dark:rounded-sm dark:p-px"}):s.jsx("div",{className:"w-4 h-4 rounded bg-primary/10 flex items-center justify-center text-xs font-semibold text-primary shrink-0",children:B.slice(0,1).toUpperCase()}),s.jsx("span",{className:"text-xs truncate",children:B})]})})()}),s.jsx(Wt,{className:"size-4 opacity-50 shrink-0 pointer-events-none"})]}),s.jsx(zt,{children:S.map(L=>{const D=P[L.providerId],$=be(L.presetId),U=$?.logo??D?.logo,B=$?.name??D?.name??L.providerId;return s.jsx(Rt,{value:L.id,children:s.jsxs("div",{className:"flex items-center gap-2",children:[U?s.jsx("img",{src:U,alt:B,className:"w-4 h-4 rounded dark:bg-white dark:rounded-sm dark:p-px"}):s.jsx("div",{className:"w-4 h-4 rounded bg-primary/10 flex items-center justify-center text-xs font-semibold text-primary",children:B.slice(0,1).toUpperCase()}),s.jsxs("span",{children:[B," — ",L.label]})]})},L.id)})})]}),e[25]=i,e[26]=N,e[27]=S,e[28]=P,e[29]=d,e[30]=F):F=e[30];let K;e[31]!==z||e[32]!==F?(K=s.jsx("div",{className:"border-b border-border h-12 bg-background/95 backdrop-blur sticky top-0 z-10",children:s.jsxs("label",{className:"flex items-center gap-2.5 h-12 px-4 pr-12 md:pr-4 cursor-text",children:[T,z,F]})}),e[31]=z,e[32]=F,e[33]=K):K=e[33];let R;e[34]!==i?(R=L=>{const{error:D,resetError:$}=L;return s.jsx(qs,{error:D,onRetry:$,credentialId:i??void 0})},e[34]=i,e[35]=R):R=e[35];let W;e[36]===Symbol.for("react.memo_cache_sentinel")?(W=s.jsx(Gs,{}),e[36]=W):W=e[36];const Q=i??void 0;let J;e[37]===Symbol.for("react.memo_cache_sentinel")?(J=()=>b(li),e[37]=J):J=e[37];let Z;e[38]!==c||e[39]!==M||e[40]!==f||e[41]!==p||e[42]!==Q?(Z=s.jsx(V.Suspense,{fallback:W,children:s.jsx(ei,{keyId:Q,searchTerm:p,onHover:h,onModelSelect:M,managing:f,onToggleManage:J,filterModels:c})}),e[38]=c,e[39]=M,e[40]=f,e[41]=p,e[42]=Q,e[43]=Z):Z=e[43];let X;e[44]!==i||e[45]!==R||e[46]!==Z?(X=s.jsx(yt,{fallback:R,children:Z},i),e[44]=i,e[45]=R,e[46]=Z,e[47]=X):X=e[47];let ee;e[48]!==f||e[49]!==E||e[50]!==_||e[51]!==d?(ee=!f&&s.jsxs("div",{className:"border-t border-border flex",children:[s.jsxs("button",{type:"button",onClick:()=>V.startTransition(()=>b(!0)),className:"flex items-center gap-2 flex-1 px-4 py-2.5 text-xs text-muted-foreground hover:text-foreground hover:bg-accent cursor-pointer",children:[s.jsx(Dt,{className:"size-3.5 shrink-0"}),d("chat.decopilot.manageModels")]}),s.jsx("div",{className:"w-px bg-border shrink-0"}),s.jsxs("button",{type:"button",onClick:()=>E({to:"/$org/settings/ai-providers",params:{org:_.slug}}),className:"flex items-center gap-2 flex-1 px-4 py-2.5 text-xs text-muted-foreground hover:text-foreground hover:bg-accent cursor-pointer",children:[s.jsx(Vt,{className:"size-3.5 shrink-0"}),d("chat.decopilot.manageApiKeys")]})]}),e[48]=f,e[49]=E,e[50]=_,e[51]=d,e[52]=ee):ee=e[52];let H;e[53]!==K||e[54]!==X||e[55]!==ee||e[56]!==w?(H=s.jsxs("div",{className:w,children:[K,X,ee]}),e[53]=K,e[54]=X,e[55]=ee,e[56]=w,e[57]=H):H=e[57];let q;e[58]!==u||e[59]!==a||e[60]!==n?(q=!u&&s.jsx("div",{className:"hidden md:flex md:flex-col md:w-[320px] md:shrink-0 p-3",children:s.jsx(Ts,{model:a??n??null})}),e[58]=u,e[59]=a,e[60]=n,e[61]=q):q=e[61];let Y;return e[62]!==H||e[63]!==q||e[64]!==g?(Y=s.jsxs("div",{className:g,children:[H,q]}),e[62]=H,e[63]=q,e[64]=g,e[65]=Y):Y=e[65],Y}function li(l){return!l}function ni(l){return l.stopPropagation()}function oi(l){return[l.id,l]}function ri(l){const e=G.c(12),{onClose:t}=l,{credentialId:i,setCredentialId:o,selectedModel:n,setModel:r}=_e();let c;e[0]!==o?(c=a=>{ie("chat_credential_changed",{credential_id:a}),o(a)},e[0]=o,e[1]=c):c=e[1];let u;e[2]!==i||e[3]!==n?.modelId||e[4]!==r?(u=a=>{i&&(ie("chat_model_changed",{from_model_id:n?.modelId??null,to_model_id:a.modelId,to_model_provider:a.providerId??null,credential_id:i}),r({...a,keyId:i}))},e[2]=i,e[3]=n?.modelId,e[4]=r,e[5]=u):u=e[5];let d;return e[6]!==i||e[7]!==t||e[8]!==n||e[9]!==c||e[10]!==u?(d=s.jsx(mt,{onClose:t,credentialId:i,onCredentialChange:c,selectedModel:n,onModelChange:u}),e[6]=i,e[7]=t,e[8]=n,e[9]=c,e[10]=u,e[11]=d):d=e[11],d}function ai(l){const e=G.c(2),{onClose:t}=l;let i;return e[0]!==t?(i=s.jsx(ri,{onClose:t}),e[0]=t,e[1]=i):i=e[1],i}function ci(l){const e=G.c(2);let t;return e[0]!==l?(t=s.jsx(mt,{...l}),e[0]=l,e[1]=t):t=e[1],t}const di=[{tier:"fast",labelKey:"chat.desktopCli.tierFastDescription"},{tier:"smart",labelKey:"chat.desktopCli.tierSmartDescription"},{tier:"thinking",labelKey:"chat.desktopCli.tierThinkingDescription"}];function ht(l){const e=G.c(11),{modelSet:t,selectedModelId:i,onSelect:o}=l,n=se();let r,c;if(e[0]!==t.logo||e[1]!==t.models||e[2]!==t.tiers||e[3]!==o||e[4]!==i||e[5]!==n){const d=Object.fromEntries(t.models.map(ui));r="flex flex-col p-2 w-[320px]",c=di.map(a=>{const{tier:h,labelKey:p}=a,m=t.tiers[h];if(!m.modelId)return null;const f=d[m.modelId];if(!f)return null;const b=i===m.modelId;return s.jsxs("button",{type:"button",onClick:()=>o(f),className:oe("flex items-center gap-3 px-3 py-2.5 rounded-lg text-left hover:bg-accent",b&&"bg-accent/50"),children:[s.jsx("img",{src:t.logo,alt:m.label,className:"size-5 shrink-0 rounded-sm dark:bg-white dark:rounded-sm dark:p-px"}),s.jsxs("div",{className:"flex flex-col flex-1 min-w-0",children:[s.jsx("span",{className:"text-sm text-foreground leading-tight truncate",children:m.label}),s.jsx("span",{className:"text-xs text-muted-foreground leading-tight",children:n(p)})]})]},h)}),e[0]=t.logo,e[1]=t.models,e[2]=t.tiers,e[3]=o,e[4]=i,e[5]=n,e[6]=r,e[7]=c}else r=e[6],c=e[7];let u;return e[8]!==r||e[9]!==c?(u=s.jsx("div",{className:r,children:c}),e[8]=r,e[9]=c,e[10]=u):u=e[10],u}function ui(l){return[l.modelId,l]}const mi=[{providerId:"claude-code",modelId:"claude-code:haiku",title:"Claude Code Haiku",description:"Fast and lightweight",capabilities:["text"],limits:null,costs:null},{providerId:"claude-code",modelId:"claude-code:sonnet",title:"Claude Code Sonnet 5",description:"Balanced performance",capabilities:["text","reasoning"],limits:null,costs:null},{providerId:"claude-code",modelId:"claude-code:opus",title:"Claude Code Opus",description:"Most capable",capabilities:["text","reasoning"],limits:null,costs:null},{providerId:"claude-code",modelId:"claude-code:opus-1m",title:"Claude Code Opus 5 1M",description:"Most capable, 1M context window",capabilities:["text","reasoning"],limits:{contextWindow:1e6,maxOutputTokens:null},costs:null}],je="https://assets.decocache.com/decocms/6ac44f1c-c0cf-4480-84b5-2ae6fe742d0b/codex-app.png.png",hi=[{providerId:"codex",modelId:"codex:gpt-5.6-sol",title:"GPT-5.6 Sol",description:"Frontier Codex model for deep reasoning, complex coding, and real-world work",capabilities:["text","reasoning"],logo:je,limits:null,costs:null},{providerId:"codex",modelId:"codex:gpt-5.6-terra",title:"GPT-5.6 Terra",description:"Balanced Codex model for everyday coding and agent work",capabilities:["text","reasoning"],logo:je,limits:null,costs:null},{providerId:"codex",modelId:"codex:gpt-5.6-luna",title:"GPT-5.6 Luna",description:"Fast Codex model for lightweight coding tasks and titles",capabilities:["text","reasoning"],logo:je,limits:null,costs:null},{providerId:"codex",modelId:"codex:gpt-5.3-codex-spark",title:"GPT-5.3 Codex Spark",description:"Ultra-fast coding model",capabilities:["text","reasoning"],logo:je,limits:null,costs:null}],fi="https://decoims.com/decocms/93e4059c-e598-412b-87eb-54d72a946ec8/claude-stroke-rounded.svg",pi="https://decoims.com/decocms/9170ffd4-b9cc-4661-ad8f-ae2eea019e00/codex.svg";function xi(l){return{fast:{modelId:"claude-code:haiku",label:l("chat.agentModels.haikuLabel"),description:l("chat.agentModels.quickerResponses"),iconNode:s.jsx(Se,{size:16})},smart:{modelId:"claude-code:sonnet",label:l("chat.agentModels.sonnetLabel"),description:l("chat.agentModels.balancedQuality"),iconNode:s.jsx(Se,{size:16})},thinking:{modelId:"claude-code:opus-1m",label:l("chat.agentModels.opusLabel"),description:l("chat.agentModels.deeperReasoning"),iconNode:s.jsx(Se,{size:16})}}}function gi(l){return{fast:{modelId:"codex:gpt-5.6-luna",label:l("chat.agentModels.gptLunaLabel"),description:l("chat.agentModels.quickerResponses"),iconNode:s.jsx(Ne,{size:16})},smart:{modelId:"codex:gpt-5.6-terra",label:l("chat.agentModels.gptTerraLabel"),description:l("chat.agentModels.balancedQuality"),iconNode:s.jsx(Ne,{size:16})},thinking:{modelId:"codex:gpt-5.6-sol",label:l("chat.agentModels.gptSolLabel"),description:l("chat.agentModels.deeperReasoning"),iconNode:s.jsx(Ne,{size:16})}}}function ft(l,e){return l==="claude-code"?{logo:fi,tiers:xi(e),models:mi}:l==="codex"?{logo:pi,tiers:gi(e),models:hi}:null}function vi(l){const e=G.c(12),{onClose:t,agent:i}=l,o=se(),n=_e(),r=i??n.pendingHarnessId??"decopilot";let c;e[0]!==r||e[1]!==o?(c=ft(r,o),e[0]=r,e[1]=o,e[2]=c):c=e[2];const u=c;if(!u){let p;return e[3]!==t?(p=s.jsx(ai,{onClose:t}),e[3]=t,e[4]=p):p=e[4],p}const d=n.selectedModel?.modelId??u.tiers[n.simpleModeTier].modelId;let a;e[5]!==t||e[6]!==n?(a=p=>{n.setModel({...p,keyId:void 0}),t()},e[5]=t,e[6]=n,e[7]=a):a=e[7];let h;return e[8]!==u||e[9]!==d||e[10]!==a?(h=s.jsx(ht,{modelSet:u,selectedModelId:d,onSelect:a}),e[8]=u,e[9]=d,e[10]=a,e[11]=h):h=e[11],h}function bi(l){const e=G.c(14);let t,i;e[0]!==l?({agent:t,...i}=l,e[0]=l,e[1]=t,e[2]=i):(t=e[1],i=e[2]);const o=se();let n;e[3]!==t||e[4]!==o?(n=t?ft(t,o):null,e[3]=t,e[4]=o,e[5]=n):n=e[5];const r=n;if(!r){let a;return e[6]!==i?(a=s.jsx(ci,{...i}),e[6]=i,e[7]=a):a=e[7],a}const c=i.selectedModel?.modelId??r.tiers.smart.modelId;let u;e[8]!==i?(u=a=>{i.onModelChange(a),i.onClose()},e[8]=i,e[9]=u):u=e[9];let d;return e[10]!==r||e[11]!==c||e[12]!==u?(d=s.jsx(ht,{modelSet:r,selectedModelId:c,onSelect:u}),e[10]=r,e[11]=c,e[12]=u,e[13]=d):d=e[13],d}function Yi(l){const e=G.c(49),{variant:t,className:i,placeholder:o,model:n,isLoading:r,credentialId:c,onCredentialChange:u,onModelChange:d,filterModels:a,agent:h}=l,p=t===void 0?"borderless":t,m=o===void 0?"Select model":o,f=se(),[b,k]=V.useState(!1),y=d!==void 0,S=Mt(),I=p==="borderless"?"ghost":"outline",P=p==="borderless"&&"md:border-none";let E;e[0]!==i||e[1]!==P?(E=oe("text-sm hover:bg-accent rounded-lg py-0.5 px-1 gap-1 shadow-none cursor-pointer border-0 group focus-visible:ring-0 focus-visible:ring-offset-0 min-w-0 shrink justify-start overflow-hidden",P,i),e[0]=i,e[1]=P,e[2]=E):E=e[2];let _;e[3]!==r||e[4]!==n||e[5]!==m||e[6]!==y?(_=y?s.jsx(rt,{model:n??null,placeholder:m,isLoading:r}):s.jsx(ji,{placeholder:m}),e[3]=r,e[4]=n,e[5]=m,e[6]=y,e[7]=_):_=e[7];let x;e[8]!==I||e[9]!==E||e[10]!==_?(x=s.jsx(ne,{variant:I,size:"sm",className:E,children:_}),e[8]=I,e[9]=E,e[10]=_,e[11]=x):x=e[11];const N=x;let C;e[12]===Symbol.for("react.memo_cache_sentinel")?(C=s.jsx(si,{}),e[12]=C):C=e[12];let M;e[13]!==h||e[14]!==c||e[15]!==a||e[16]!==n||e[17]!==u||e[18]!==d||e[19]!==y?(M=s.jsx(V.Suspense,{fallback:C,children:y?s.jsx(bi,{onClose:()=>k(!1),agent:h,credentialId:c??null,onCredentialChange:u??yi,selectedModel:n??null,onModelChange:d,filterModels:a}):s.jsx(vi,{onClose:()=>k(!1),agent:h})}),e[13]=h,e[14]=c,e[15]=a,e[16]=n,e[17]=u,e[18]=d,e[19]=y,e[20]=M):M=e[20];const v=M;if(S){let O;e[21]!==N?(O=s.jsx(Ct,{asChild:!0,children:N}),e[21]=N,e[22]=O):O=e[22];let z;e[23]!==f?(z=f("chat.selectModel.selectModel"),e[23]=f,e[24]=z):z=e[24];let F;e[25]!==z?(F=s.jsx(wt,{className:"sr-only",children:z}),e[25]=z,e[26]=F):F=e[26];let K;e[27]!==v?(K=s.jsx("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:v}),e[27]=v,e[28]=K):K=e[28];let R;e[29]!==F||e[30]!==K?(R=s.jsxs(It,{className:"p-0 flex flex-col max-h-[95vh]",children:[F,K]}),e[29]=F,e[30]=K,e[31]=R):R=e[31];let W;return e[32]!==b||e[33]!==O||e[34]!==R?(W=s.jsxs(_t,{open:b,onOpenChange:k,children:[O,R]}),e[32]=b,e[33]=O,e[34]=R,e[35]=W):W=e[35],W}let g;e[36]!==N?(g=s.jsx(kt,{asChild:!0,children:N}),e[36]=N,e[37]=g):g=e[37];let j;e[38]!==f?(j=f("chat.selectModel.selectModel"),e[38]=f,e[39]=j):j=e[39];let w;e[40]!==j?(w=s.jsx(Je,{className:"sr-only",children:j}),e[40]=j,e[41]=w):w=e[41];let T;e[42]!==v||e[43]!==w?(T=s.jsxs(Qe,{className:"p-0 gap-0 sm:max-w-fit overflow-hidden h-[100dvh] sm:h-auto max-h-[100dvh] sm:max-h-[85vh] w-full max-w-full sm:max-w-fit rounded-none sm:rounded-xl border-0 sm:border",closeButtonClassName:"top-3.5 right-3.5 z-20",children:[w,v]}),e[42]=v,e[43]=w,e[44]=T):T=e[44];let A;return e[45]!==b||e[46]!==g||e[47]!==T?(A=s.jsxs(Ye,{open:b,onOpenChange:k,children:[g,T]}),e[45]=b,e[46]=g,e[47]=T,e[48]=A):A=e[48],A}function yi(){}function ji(l){const e=G.c(4),{placeholder:t}=l,{selectedModel:i,isModelsLoading:o}=_e();let n;return e[0]!==o||e[1]!==i||e[2]!==t?(n=s.jsx(rt,{model:i,placeholder:t,isLoading:o}),e[0]=o,e[1]=i,e[2]=t,e[3]=n):n=e[3],n}export{Ns as C,si as M,Is as N,ot as P,bi as a,Gi as b,Yi as c,be as d,Xi as g,qi as i,Pe as m};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{W as At,c as M,r as V,m as ce,j as n,b as re,k as Ue,B as X,o as Se,e as Re,K as Z,X as _e,Y as de,Z as Ne,_ as Oe,n as be,$ as Lt,t as ke,x as Ke,p as le,Q as kt,E as Ft,a as Rt}from"./index-3s9Tew9h.js";import{W as mt,g as Dt,u as ze,S as Pt}from"./use-mcp-client-S8Ro9wXt.js";import{I as Ge}from"./integration-icon-efY4xiAf.js";import{c as Ce,b as ft,h as pt,a as gt,d as ht,e as xt}from"./dialog-D33iO7_V.js";import{c as Be,T as Me,a as Ve}from"./tooltip-DDodsVeB.js";import{m as bt,h as Ct,a as $t}from"./agent-icon-C_Bcs5w3.js";import{u as ne,t as qt,m as Kt,s as at,g as Ut,p as zt,F as Gt,b as Bt,a as Mt,c as Vt}from"./companions-core-XkORCpwR.js";import{i as yt}from"./CheckCircle-CagdexBy.js";import{F as ue,a as Ie,b as me,c as Le,d as fe,e as pe,f as Qt}from"./form-DU_fCIQ-.js";import{I as Ee}from"./input-BfYMrULt.js";import{i as Ht}from"./Check-D2OTmp9f.js";import{a as vt}from"./Copy01-DAcswqJ-.js";import{i as Wt}from"./Settings02-CyPLPNW_.js";import{s as Yt}from"./Eye-5baqKWh-.js";import{u as Zt}from"./use-debounced-value-c9xf8WS9.js";import{f as jt,a as Xt,p as Jt}from"./provision-repo-scoped-github-connection-Dp638N7g.js";import{c as en,e as tn}from"./extract-connection-data-DV9ilPpM.js";import{u as nn}from"./useQueries-BaAVLqaJ.js";import{a as on}from"./authenticate-and-persist-oauth-CYAmEm23.js";function sn(s,e){return nn({...s,queries:s.queries.map(t=>({...t,suspense:!0,throwOnError:At,enabled:!0,placeholderData:void 0}))},e)}const rn=/^[a-zA-Z][a-zA-Z\d+.-]*:/,an=/^[a-zA-Z][a-zA-Z\d+.-]*:\/\//,ln=/^[^\s/:?#]+\.[^\s/:?#]+:\d+(?:[/?#]|$)/,cn=/^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/i;function Fe(s){const e=s.trim();if(!e)return{ok:!1,error:"Enter a website URL."};const t=rn.test(e),o=an.test(e),c=ln.test(e);if(t&&!o&&!c)return{ok:!1,error:"Use an HTTP or HTTPS website URL."};const l=o?e:`https://${e}`;let u;try{u=new URL(l)}catch{return{ok:!1,error:"Enter a valid website URL."}}if(u.protocol!=="http:"&&u.protocol!=="https:")return{ok:!1,error:"Use an HTTP or HTTPS website URL."};const d=u.hostname.split(".");return d.length<2||d.some(a=>!a||!cn.test(a))?{ok:!1,error:"Enter a valid website URL."}:(u.protocol="https:",{ok:!0,value:u.origin})}function wo(s,e){if(!s.trim())return!0;const t=Fe(s);if(!t.ok||!e)return!1;const o=Fe(e);return o.ok&&o.value===t.value}function Ao(s){if(!s)return null;const e=Fe(s);return e.ok?new URL(e.value).hostname:null}function dn(s){const e=M.c(14),{children:t,className:o,wrapperClassName:c}=s,[l,u]=V.useState(!0);let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=j=>{if(!j)return;const b=()=>{const f=j.scrollHeight-j.scrollTop-j.clientHeight<8;u(f)};b(),j.addEventListener("scroll",b,{passive:!0});const x=new ResizeObserver(b);x.observe(j);for(const f of Array.from(j.children))x.observe(f);return()=>{j.removeEventListener("scroll",b),x.disconnect()}},e[0]=d):d=e[0];const a=d;let p;e[1]!==c?(p=ce("relative",c),e[1]=c,e[2]=p):p=e[2];let i;e[3]!==t||e[4]!==o?(i=n.jsx("div",{ref:a,className:o,children:t}),e[3]=t,e[4]=o,e[5]=i):i=e[5];const r=l?"opacity-0":"opacity-100";let g;e[6]!==r?(g=ce("pointer-events-none absolute inset-x-0 -bottom-px h-[72px]","bg-gradient-to-t from-sidebar from-[6px] to-transparent","backdrop-blur-[1px] [mask-image:linear-gradient(to_top,black_6px,transparent)]","transition-opacity duration-200",r),e[6]=r,e[7]=g):g=e[7];let m;e[8]!==g?(m=n.jsx("div",{"aria-hidden":!0,className:g}),e[8]=g,e[9]=m):m=e[9];let y;return e[10]!==p||e[11]!==i||e[12]!==m?(y=n.jsxs("div",{className:p,children:[i,m]}),e[10]=p,e[11]=i,e[12]=m,e[13]=y):y=e[13],y}function un(s){const e=M.c(25),{icon:t,title:o,headline:c,required:l,attention:u,action:d}=s,a=re(),p=u?"border-warning/50 bg-warning/[0.04]":"border-border";let i;e[0]!==p?(i=ce("relative flex items-center justify-between gap-3 rounded-lg border bg-card p-3.5 sm:gap-4 sm:p-4",p),e[0]=p,e[1]=i):i=e[1];let r;e[2]!==l||e[3]!==a?(r=l&&n.jsx("span",{className:"absolute -top-3 right-4 rounded-full border border-input bg-background px-3 py-1 text-xs font-medium text-foreground",children:a("commerceOnboarding.companionCard.required")}),e[2]=l,e[3]=a,e[4]=r):r=e[4];let g;e[5]!==t||e[6]!==o?(g=n.jsx(Ge,{icon:t,name:o,size:"sm",fit:"contain",className:"size-[30px] shrink-0 p-1"}),e[5]=t,e[6]=o,e[7]=g):g=e[7];let m;e[8]!==o?(m=n.jsx("span",{className:"text-sm font-medium text-foreground",children:o}),e[8]=o,e[9]=m):m=e[9];let y;e[10]!==c?(y=c&&n.jsx("p",{className:"hidden text-sm leading-5 text-muted-foreground sm:block",children:c}),e[10]=c,e[11]=y):y=e[11];let j;e[12]!==m||e[13]!==y?(j=n.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[m,y]}),e[12]=m,e[13]=y,e[14]=j):j=e[14];let b;e[15]!==g||e[16]!==j?(b=n.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3 sm:items-start",children:[g,j]}),e[15]=g,e[16]=j,e[17]=b):b=e[17];let x;e[18]!==d?(x=n.jsx("div",{className:"shrink-0",children:d}),e[18]=d,e[19]=x):x=e[19];let f;return e[20]!==i||e[21]!==r||e[22]!==b||e[23]!==x?(f=n.jsxs("div",{className:i,children:[r,b,x]}),e[20]=i,e[21]=r,e[22]=b,e[23]=x,e[24]=f):f=e[24],f}function St(s){const e=M.c(12),{connecting:t,disabled:o,title:c,primary:l,onConnect:u}=s,d=re(),a=l?"default":"outline",p=o||t;let i;e[0]!==d||e[1]!==c?(i=d("commerceOnboarding.companionCard.connectAriaLabel",{title:c}),e[0]=d,e[1]=c,e[2]=i):i=e[2];let r;e[3]!==t||e[4]!==d?(r=t?n.jsx(Ue,{size:16,className:"animate-spin"}):d("commerceOnboarding.companionCard.connect"),e[3]=t,e[4]=d,e[5]=r):r=e[5];let g;return e[6]!==u||e[7]!==a||e[8]!==p||e[9]!==i||e[10]!==r?(g=n.jsx(X,{type:"button",variant:a,size:"sm",disabled:p,onClick:u,"aria-label":i,children:r}),e[6]=u,e[7]=a,e[8]=p,e[9]=i,e[10]=r,e[11]=g):g=e[11],g}function mn(s){const e=M.c(11),{disabled:t,title:o,onConfigure:c}=s,l=re();let u;e[0]!==l||e[1]!==o?(u=l("commerceOnboarding.companionCard.configureAriaLabel",{title:o}),e[0]=l,e[1]=o,e[2]=u):u=e[2];let d;e[3]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx(bt,{size:16}),e[3]=d):d=e[3];let a;e[4]!==l?(a=l("commerceOnboarding.companionCard.finishSetup"),e[4]=l,e[5]=a):a=e[5];let p;return e[6]!==t||e[7]!==c||e[8]!==u||e[9]!==a?(p=n.jsxs(X,{type:"button",variant:"outline",size:"sm",className:"border-warning/60 text-warning hover:bg-warning/10 hover:text-warning",disabled:t,onClick:c,"aria-label":u,children:[d,a]}),e[6]=t,e[7]=c,e[8]=u,e[9]=a,e[10]=p):p=e[10],p}function _t(s){const e=M.c(9),{detail:t,controls:o}=s,c=re();let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=n.jsx(yt,{size:16,className:"text-success"}),e[0]=l):l=e[0];let u;e[1]!==t||e[2]!==c?(u=t?n.jsx("span",{className:"max-w-40 truncate text-foreground",children:t}):c("commerceOnboarding.companionCard.connected"),e[1]=t,e[2]=c,e[3]=u):u=e[3];let d;e[4]!==u?(d=n.jsxs("span",{className:"flex items-center gap-1.5 text-sm text-muted-foreground",children:[l," ",u]}),e[4]=u,e[5]=d):d=e[5];let a;return e[6]!==o||e[7]!==d?(a=n.jsxs("div",{className:"flex items-center gap-1",children:[d,o]}),e[6]=o,e[7]=d,e[8]=a):a=e[8],a}function Nt(s){const e=M.c(4),{ariaLabel:t,onClick:o}=s;let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx(bt,{size:16}),e[0]=c):c=e[0];let l;return e[1]!==t||e[2]!==o?(l=n.jsx(X,{type:"button",variant:"ghost",size:"icon-sm",className:"shrink-0",onClick:o,"aria-label":t,children:c}),e[1]=t,e[2]=o,e[3]=l):l=e[3],l}function lt(s){const e=M.c(38);let t,o,c,l,u;e[0]!==s?({value:u,onChange:o,placeholder:c,className:t,...l}=s,e[0]=s,e[1]=t,e[2]=o,e[3]=c,e[4]=l,e[5]=u):(t=e[1],o=e[2],c=e[3],l=e[4],u=e[5]);const[d,a]=V.useState(!1),[p,i]=V.useState(!1);let r;e[6]!==u?(r=async()=>{if(u)try{await navigator.clipboard.writeText(u),i(!0),setTimeout(()=>i(!1),2e3)}catch(A){console.error("Failed to copy text: ",A)}},e[6]=u,e[7]=r):r=e[7];const g=r;let m;e[8]!==d?(m=()=>{a(!d)},e[8]=d,e[9]=m):m=e[9];const y=m,j=d?"text":"password";let b;e[10]!==t?(b=ce("pr-20",t),e[10]=t,e[11]=b):b=e[11];let x;e[12]!==o||e[13]!==c||e[14]!==l||e[15]!==j||e[16]!==b||e[17]!==u?(x=n.jsx(Ee,{type:j,value:u,onChange:o,placeholder:c,className:b,...l}),e[12]=o,e[13]=c,e[14]=l,e[15]=j,e[16]=b,e[17]=u,e[18]=x):x=e[18];const f=d?"Hide password":"Show password";let S;e[19]!==d?(S=d?n.jsx(Wt,{size:16}):n.jsx(Yt,{size:16}),e[19]=d,e[20]=S):S=e[20];let h;e[21]!==f||e[22]!==S||e[23]!==y?(h=n.jsx(X,{type:"button",variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:y,title:f,children:S}),e[21]=f,e[22]=S,e[23]=y,e[24]=h):h=e[24];const L=!u,T=p?"Copied!":"Copy token";let C;e[25]!==p?(C=p?n.jsx(Ht,{size:16}):n.jsx(vt,{size:16}),e[25]=p,e[26]=C):C=e[26];let v;e[27]!==g||e[28]!==T||e[29]!==C||e[30]!==L?(v=n.jsx(X,{type:"button",variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:g,disabled:L,title:T,children:C}),e[27]=g,e[28]=T,e[29]=C,e[30]=L,e[31]=v):v=e[31];let w;e[32]!==v||e[33]!==h?(w=n.jsxs("div",{className:"absolute right-1 top-1 flex items-center gap-1 h-8",children:[h,v]}),e[32]=v,e[33]=h,e[34]=w):w=e[34];let I;return e[35]!==w||e[36]!==x?(I=n.jsxs("div",{className:"relative",children:[x,w]}),e[35]=w,e[36]=x,e[37]=I):I=e[37],I}function Qe(s){const e=M.c(19),{card:t,selfClient:o,org:c,onDone:l,onError:u}=s,d=Se();let a;e[0]!==t||e[1]!==o?(a=async b=>{const x={...t.configurationState??{},...b};await o.callTool({name:"COLLECTION_CONNECTIONS_UPDATE",arguments:{id:t.linkedConnectionId||t.candidateConnectionId,data:{configuration_state:x}}})},e[0]=t,e[1]=o,e[2]=a):a=e[2];let p;e[3]!==l||e[4]!==c||e[5]!==d?(p=async()=>{await d.invalidateQueries({queryKey:Z.commerceDiscoveryCompanionConnectionsPrefix(c.id)}),l()},e[3]=l,e[4]=c,e[5]=d,e[6]=p):p=e[6];let i;e[7]!==u?(i=b=>{u?.(b)},e[7]=u,e[8]=i):i=e[8];let r;e[9]!==a||e[10]!==p||e[11]!==i?(r={mutationFn:a,onSuccess:p,onError:i},e[9]=a,e[10]=p,e[11]=i,e[12]=r):r=e[12];const g=Re(r);let m;e[13]!==g?(m=b=>g.mutate(b),e[13]=g,e[14]=m):m=e[14];const y=m;let j;return e[15]!==g.error||e[16]!==g.isPending||e[17]!==y?(j={save:y,isPending:g.isPending,error:g.error},e[15]=g.error,e[16]=g.isPending,e[17]=y,e[18]=j):j=e[18],j}const fn=_e({accountName:de().min(1,"Informe o nome da conta"),appKey:de().optional(),appToken:de().optional()});function pn(s){const e=M.c(73),{card:t,selfClient:o,org:c,onDone:l,onIsPendingChange:u}=s,d=re();let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=Ne(fn),e[0]=a):a=e[0];const p=t.configurationState?.accountName||"",i=t.configurationState?.appKey||"",r=t.configurationState?.appToken||"";let g;e[1]!==p||e[2]!==i||e[3]!==r?(g={resolver:a,defaultValues:{accountName:p,appKey:i,appToken:r}},e[1]=p,e[2]=i,e[3]=r,e[4]=g):g=e[4];const m=Oe(g);let y;e[5]!==t.configurationState?.accountName||e[6]!==t.configurationState?.appKey||e[7]!==t.configurationState?.appToken||e[8]!==m?(y=()=>{m.reset({accountName:t.configurationState?.accountName||"",appKey:t.configurationState?.appKey||"",appToken:t.configurationState?.appToken||""})},e[5]=t.configurationState?.accountName,e[6]=t.configurationState?.appKey,e[7]=t.configurationState?.appToken,e[8]=m,e[9]=y):y=e[9];let j;e[10]!==t.configurationState||e[11]!==m?(j=[t.configurationState,m],e[10]=t.configurationState,e[11]=m,e[12]=j):j=e[12],V.useEffect(y,j);let b;e[13]!==t||e[14]!==l||e[15]!==c||e[16]!==o?(b={card:t,selfClient:o,org:c,onDone:l},e[13]=t,e[14]=l,e[15]=c,e[16]=o,e[17]=b):b=e[17];const{save:x,isPending:f,error:S}=Qe(b);let h,L;e[18]!==f||e[19]!==u?(L=()=>{u?.(f)},h=[f,u],e[18]=f,e[19]=u,e[20]=h,e[21]=L):(h=e[20],L=e[21]),V.useEffect(L,h);let T;if(e[22]!==m||e[23]!==x){let D;e[25]!==x?(D=async E=>{x(E)},e[25]=x,e[26]=D):D=e[26],T=m.handleSubmit(D),e[22]=m,e[23]=x,e[24]=T}else T=e[24];const C=T;let v;e[27]!==f||e[28]!==d?(v=D=>{const{field:E}=D;return n.jsxs(me,{children:[n.jsx(Le,{children:d("commerceOnboarding.vtexConfigForm.accountNameLabel")}),n.jsx(fe,{children:n.jsx(Ee,{placeholder:d("commerceOnboarding.vtexConfigForm.accountNamePlaceholder"),...E,disabled:f})}),n.jsx(pe,{})]})},e[27]=f,e[28]=d,e[29]=v):v=e[29];let w;e[30]!==m.control||e[31]!==v?(w=n.jsx(ue,{control:m.control,name:"accountName",render:v}),e[30]=m.control,e[31]=v,e[32]=w):w=e[32];let I;e[33]!==f||e[34]!==d?(I=D=>{const{field:E}=D;return n.jsxs(me,{children:[n.jsx(Le,{children:d("commerceOnboarding.vtexConfigForm.appKeyLabel")}),n.jsx(fe,{children:n.jsx(lt,{placeholder:d("commerceOnboarding.vtexConfigForm.appKeyPlaceholder"),...E,disabled:f})}),n.jsx(pe,{})]})},e[33]=f,e[34]=d,e[35]=I):I=e[35];let A;e[36]!==m.control||e[37]!==I?(A=n.jsx(ue,{control:m.control,name:"appKey",render:I}),e[36]=m.control,e[37]=I,e[38]=A):A=e[38];let F;e[39]!==f||e[40]!==d?(F=D=>{const{field:E}=D;return n.jsxs(me,{children:[n.jsx(Le,{children:d("commerceOnboarding.vtexConfigForm.appTokenLabel")}),n.jsx(fe,{children:n.jsx(lt,{placeholder:d("commerceOnboarding.vtexConfigForm.appTokenPlaceholder"),...E,disabled:f})}),n.jsx(pe,{})]})},e[39]=f,e[40]=d,e[41]=F):F=e[41];let _;e[42]!==m.control||e[43]!==F?(_=n.jsx(ue,{control:m.control,name:"appToken",render:F}),e[42]=m.control,e[43]=F,e[44]=_):_=e[44];let O;e[45]!==m||e[46]!==w||e[47]!==A||e[48]!==_?(O=n.jsxs(Ie,{...m,children:[w,A,_]}),e[45]=m,e[46]=w,e[47]=A,e[48]=_,e[49]=O):O=e[49];let P;e[50]!==S||e[51]!==d?(P=S&&n.jsx("p",{role:"alert",className:"text-sm text-destructive",children:S instanceof Error?S.message:d("commerceOnboarding.vtexConfigForm.savingError")}),e[50]=S,e[51]=d,e[52]=P):P=e[52];let R;e[53]!==d?(R=d("commerceOnboarding.vtexConfigForm.cancelButton"),e[53]=d,e[54]=R):R=e[54];let $;e[55]!==f||e[56]!==l||e[57]!==R?($=n.jsx(X,{type:"button",variant:"outline",onClick:l,disabled:f,children:R}),e[55]=f,e[56]=l,e[57]=R,e[58]=$):$=e[58];let K;e[59]!==f||e[60]!==d?(K=d(f?"commerceOnboarding.vtexConfigForm.savingButton":"commerceOnboarding.vtexConfigForm.saveButton"),e[59]=f,e[60]=d,e[61]=K):K=e[61];let U;e[62]!==f||e[63]!==K?(U=n.jsx(X,{type:"submit",disabled:f,children:K}),e[62]=f,e[63]=K,e[64]=U):U=e[64];let z;e[65]!==$||e[66]!==U?(z=n.jsxs(Ce,{className:"pt-4",children:[$,U]}),e[65]=$,e[66]=U,e[67]=z):z=e[67];let G;return e[68]!==C||e[69]!==O||e[70]!==P||e[71]!==z?(G=n.jsxs("form",{onSubmit:C,className:"space-y-4",children:[O,P,z]}),e[68]=C,e[69]=O,e[70]=P,e[71]=z,e[72]=G):G=e[72],G}function He(s){const e=M.c(29),{options:t,value:o,onChange:c,disabled:l,ariaLabel:u,searchPlaceholder:d,hideSearch:a}=s,p=d===void 0?"Buscar...":d,i=a===void 0?!1:a,[r,g]=V.useState("");let m,y,j;if(e[0]!==t||e[1]!==r||e[2]!==o){const C=r.trim().toLowerCase();m=C?t.filter(v=>v.label.toLowerCase().includes(C)):t,y=m.map(gn),j=y.includes(o)?o:y[0]??"",e[0]=t,e[1]=r,e[2]=o,e[3]=m,e[4]=y,e[5]=j}else m=e[3],y=e[4],j=e[5];const b=j;let x;e[6]!==l||e[7]!==y||e[8]!==c?(x=function(v){if(l||!["ArrowDown","ArrowRight","ArrowUp","ArrowLeft","Home","End"].includes(v.key))return;v.preventDefault();const I=v.currentTarget.dataset.value,A=y.indexOf(I),F=y.length;if(F===0)return;let _;v.key==="ArrowDown"||v.key==="ArrowRight"?_=(A+1)%F:v.key==="ArrowUp"||v.key==="ArrowLeft"?_=(A-1+F)%F:v.key==="Home"?_=0:_=F-1;const O=y[_];c(O),v.currentTarget.closest('[role="radiogroup"]')?.querySelector(`[data-value="${CSS.escape(O)}"]`)?.focus()},e[6]=l,e[7]=y,e[8]=c,e[9]=x):x=e[9];const f=x;let S;e[10]!==u||e[11]!==l||e[12]!==i||e[13]!==r||e[14]!==p?(S=i?null:n.jsxs("div",{className:"relative",children:[n.jsx(Ct,{size:16,className:"pointer-events-none absolute left-2.5 top-1/2 -translate-y-1/2 text-muted-foreground"}),n.jsx(Ee,{type:"text",value:r,onChange:C=>g(C.target.value),disabled:l,placeholder:p,"aria-label":`Buscar ${u}`,className:"h-8 pl-8"})]}),e[10]=u,e[11]=l,e[12]=i,e[13]=r,e[14]=p,e[15]=S):S=e[15];let h;e[16]!==l||e[17]!==m||e[18]!==f||e[19]!==c||e[20]!==b||e[21]!==o?(h=m.length===0?n.jsx("div",{className:"px-2 py-2 text-sm text-muted-foreground",children:"Nenhum resultado"}):m.map(C=>{const v=C.value===o;return n.jsxs("button",{type:"button",role:"radio","aria-checked":v,disabled:l,"data-value":C.value,tabIndex:C.value===b?0:-1,onClick:()=>c(C.value),onKeyDown:f,className:ce("flex w-full items-center justify-between gap-2 rounded-sm px-2 py-2 text-left text-sm","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","disabled:pointer-events-none disabled:opacity-50",v?"bg-muted font-medium text-foreground":"text-foreground hover:bg-muted/50"),children:[n.jsx("span",{className:"truncate",children:C.label}),v?n.jsx(yt,{size:16,className:"shrink-0 text-primary"}):null]},C.value)}),e[16]=l,e[17]=m,e[18]=f,e[19]=c,e[20]=b,e[21]=o,e[22]=h):h=e[22];let L;e[23]!==u||e[24]!==h?(L=n.jsx("div",{role:"radiogroup","aria-label":u,className:"max-h-[280px] overflow-y-auto",children:h}),e[23]=u,e[24]=h,e[25]=L):L=e[25];let T;return e[26]!==S||e[27]!==L?(T=n.jsxs("div",{className:"space-y-2",children:[S,L]}),e[26]=S,e[27]=L,e[28]=T):T=e[28],T}function gn(s){return s.value}function We(s){const e=M.c(16),{label:t,iconSize:o,className:c,iconClassName:l,labelClassName:u}=s,d=o===void 0?14:o;let a;e[0]!==c?(a=ce("inline-flex items-center gap-2",c),e[0]=c,e[1]=a):a=e[1];let p;e[2]!==l?(p=ce("shrink-0 animate-spin",l),e[2]=l,e[3]=p):p=e[3];let i;e[4]!==d||e[5]!==p?(i=n.jsx(Ue,{size:d,className:p}),e[4]=d,e[5]=p,e[6]=i):i=e[6];let r;e[7]!==u?(r=ce("text-sm",u),e[7]=u,e[8]=r):r=e[8];let g;e[9]!==t||e[10]!==r?(g=n.jsx("span",{className:r,children:t}),e[9]=t,e[10]=r,e[11]=g):g=e[11];let m;return e[12]!==a||e[13]!==i||e[14]!==g?(m=n.jsxs("span",{className:a,children:[i,g]}),e[12]=a,e[13]=i,e[14]=g,e[15]=m):m=e[15],m}const hn=_e({propertyId:de().min(1,"Selecione uma propriedade")});function xn(s){const e=M.c(68),{card:t,connectionId:o,companionClient:c,selfClient:l,org:u,onDone:d,onDisconnect:a,onIsPendingChange:p}=s;let i;e[0]!==o||e[1]!==u.id?(i=Z.commerceDiscoveryCompanionGaProperties(u.id,o),e[0]=o,e[1]=u.id,e[2]=i):i=e[2];let r;e[3]!==c?(r=async()=>{const k=await c.callTool({name:"get-account-summaries",arguments:{}}),N=ne(k);return qt(N)},e[3]=c,e[4]=r):r=e[4];let g;e[5]!==i||e[6]!==r?(g={queryKey:i,queryFn:r},e[5]=i,e[6]=r,e[7]=g):g=e[7];const m=be(g);let y;e[8]===Symbol.for("react.memo_cache_sentinel")?(y=Ne(hn),e[8]=y):y=e[8];const j=t.configurationState?.propertyId||"";let b;e[9]!==j?(b={resolver:y,defaultValues:{propertyId:j}},e[9]=j,e[10]=b):b=e[10];const x=Oe(b);let f;e[11]!==t||e[12]!==d||e[13]!==u||e[14]!==l?(f={card:t,selfClient:l,org:u,onDone:d},e[11]=t,e[12]=d,e[13]=u,e[14]=l,e[15]=f):f=e[15];const{save:S,isPending:h,error:L}=Qe(f);let T,C;e[16]!==h||e[17]!==p?(T=()=>{p?.(h)},C=[h,p],e[16]=h,e[17]=p,e[18]=T,e[19]=C):(T=e[18],C=e[19]),V.useEffect(T,C);let v;if(e[20]!==x||e[21]!==S){let k;e[23]!==S?(k=async N=>{S(N)},e[23]=S,e[24]=k):k=e[24],v=x.handleSubmit(k),e[20]=x,e[21]=S,e[22]=v}else v=e[22];const w=v;if(m.isLoading){let k;return e[25]===Symbol.for("react.memo_cache_sentinel")?(k=n.jsx("div",{className:"flex min-h-[200px] items-center justify-center",children:n.jsx(We,{label:"Carregando propriedades..."})}),e[25]=k):k=e[25],k}if(m.isError){let k;return e[26]===Symbol.for("react.memo_cache_sentinel")?(k=n.jsx("div",{className:"space-y-4",children:n.jsx("p",{className:"text-sm text-destructive",children:"Não foi possível carregar as propriedades do Google Analytics."})}),e[26]=k):k=e[26],k}let I;e[27]!==m.data?(I=m.data||[],e[27]=m.data,e[28]=I):I=e[28];const A=I;if(A.flatMap(Cn).length===0){let k;e[29]===Symbol.for("react.memo_cache_sentinel")?(k=n.jsx("p",{className:"text-sm text-muted-foreground",children:"Nenhuma propriedade do Google Analytics foi encontrada. Conecte uma conta do Google Analytics com propriedades."}),e[29]=k):k=e[29];let N;e[30]!==a?(N=a?n.jsx("button",{type:"button",onClick:a,className:"text-xs text-muted-foreground underline underline-offset-2 hover:text-destructive",children:"Desconectar conta"}):n.jsx("span",{}),e[30]=a,e[31]=N):N=e[31];let B;e[32]!==d?(B=n.jsx(X,{type:"button",variant:"outline",onClick:d,children:"Fechar"}),e[32]=d,e[33]=B):B=e[33];let Q;return e[34]!==N||e[35]!==B?(Q=n.jsxs("div",{className:"space-y-4",children:[k,n.jsxs(Ce,{className:"flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[N,B]})]}),e[34]=N,e[35]=B,e[36]=Q):Q=e[36],Q}let _;e[37]!==h||e[38]!==A?(_=k=>{const{field:N}=k;return n.jsxs(me,{children:[n.jsx(fe,{children:n.jsx(He,{options:A.flatMap(bn),value:N.value,onChange:N.onChange,disabled:h,ariaLabel:"Propriedade do Google Analytics"})}),n.jsx(pe,{})]})},e[37]=h,e[38]=A,e[39]=_):_=e[39];let O;e[40]!==x.control||e[41]!==_?(O=n.jsx(ue,{control:x.control,name:"propertyId",render:_}),e[40]=x.control,e[41]=_,e[42]=O):O=e[42];let P;e[43]!==x||e[44]!==O?(P=n.jsx(Ie,{...x,children:O}),e[43]=x,e[44]=O,e[45]=P):P=e[45];let R;e[46]!==L?(R=L&&n.jsx("p",{role:"alert",className:"text-sm text-destructive",children:L instanceof Error?L.message:"Não foi possível salvar a configuração"}),e[46]=L,e[47]=R):R=e[47];let $;e[48]!==h||e[49]!==a?($=a?n.jsx("button",{type:"button",onClick:a,disabled:h,className:"text-xs text-muted-foreground underline underline-offset-2 hover:text-destructive disabled:opacity-50",children:"Desconectar conta"}):n.jsx("span",{}),e[48]=h,e[49]=a,e[50]=$):$=e[50];let K;e[51]!==h||e[52]!==d?(K=n.jsx(X,{type:"button",variant:"outline",onClick:d,disabled:h,children:"Cancelar"}),e[51]=h,e[52]=d,e[53]=K):K=e[53];const U=h?"Salvando...":"Salvar";let z;e[54]!==h||e[55]!==U?(z=n.jsx(X,{type:"submit",disabled:h,children:U}),e[54]=h,e[55]=U,e[56]=z):z=e[56];let G;e[57]!==K||e[58]!==z?(G=n.jsxs("div",{className:"flex gap-2",children:[K,z]}),e[57]=K,e[58]=z,e[59]=G):G=e[59];let D;e[60]!==$||e[61]!==G?(D=n.jsxs(Ce,{className:"flex-col gap-2 pt-4 sm:flex-row sm:items-center sm:justify-between",children:[$,G]}),e[60]=$,e[61]=G,e[62]=D):D=e[62];let E;return e[63]!==w||e[64]!==P||e[65]!==R||e[66]!==D?(E=n.jsxs("form",{onSubmit:w,className:"space-y-4",children:[P,R,D]}),e[63]=w,e[64]=P,e[65]=R,e[66]=D,e[67]=E):E=e[67],E}function bn(s){return s.options}function Cn(s){return s.options}const yn=_e({siteUrl:de().min(1,"Selecione um site")});function vn(s){const e=M.c(62),{card:t,connectionId:o,companionClient:c,selfClient:l,org:u,contextSiteUrl:d,onDone:a,onIsPendingChange:p}=s;let i;e[0]!==o||e[1]!==u.id?(i=Z.commerceDiscoveryCompanionGscSites(u.id,o),e[0]=o,e[1]=u.id,e[2]=i):i=e[2];let r;e[3]!==c?(r=async()=>{const N=await c.callTool({name:"list_sites",arguments:{}});return ne(N).sites||[]},e[3]=c,e[4]=r):r=e[4];let g;e[5]!==i||e[6]!==r?(g={queryKey:i,queryFn:r},e[5]=i,e[6]=r,e[7]=g):g=e[7];const m=be(g);let y;e[8]===Symbol.for("react.memo_cache_sentinel")?(y=Ne(yn),e[8]=y):y=e[8];const j=t.configurationState?.siteUrl||"";let b;e[9]!==j?(b={resolver:y,defaultValues:{siteUrl:j}},e[9]=j,e[10]=b):b=e[10];const x=Oe(b);let f;e[11]!==t||e[12]!==a||e[13]!==u||e[14]!==l?(f={card:t,selfClient:l,org:u,onDone:a},e[11]=t,e[12]=a,e[13]=u,e[14]=l,e[15]=f):f=e[15];const{save:S,isPending:h,error:L}=Qe(f),T=V.useRef(!1),C=t.configurationState?.siteUrl;let v,w;e[16]!==h||e[17]!==p?(v=()=>{p?.(h)},w=[h,p],e[16]=h,e[17]=p,e[18]=v,e[19]=w):(v=e[18],w=e[19]),V.useEffect(v,w);let I,A;e[20]!==d||e[21]!==x||e[22]!==C||e[23]!==m.data||e[24]!==m.isSuccess?(I=()=>{if(!(T.current||!m.isSuccess)){if(T.current=!0,C){x.getValues("siteUrl")!==C&&x.setValue("siteUrl",C);return}if(!x.getValues("siteUrl")){const N=Kt(d,m.data??[]);N&&x.setValue("siteUrl",N)}}},A=[m.isSuccess,m.data,C,d,x],e[20]=d,e[21]=x,e[22]=C,e[23]=m.data,e[24]=m.isSuccess,e[25]=I,e[26]=A):(I=e[25],A=e[26]),V.useEffect(I,A);let F;if(e[27]!==x||e[28]!==S){let N;e[30]!==S?(N=async B=>{S(B)},e[30]=S,e[31]=N):N=e[31],F=x.handleSubmit(N),e[27]=x,e[28]=S,e[29]=F}else F=e[29];const _=F;if(m.isLoading){let N;return e[32]===Symbol.for("react.memo_cache_sentinel")?(N=n.jsx("div",{className:"flex min-h-[200px] items-center justify-center",children:n.jsx(We,{label:"Carregando sites..."})}),e[32]=N):N=e[32],N}if(m.isError){let N;return e[33]===Symbol.for("react.memo_cache_sentinel")?(N=n.jsx("div",{className:"space-y-4",children:n.jsx("p",{className:"text-sm text-destructive",children:"Não foi possível carregar os sites do Google Search Console."})}),e[33]=N):N=e[33],N}let O;e[34]!==m.data?(O=m.data||[],e[34]=m.data,e[35]=O):O=e[35];const P=O;if(P.length===0){let N;return e[36]===Symbol.for("react.memo_cache_sentinel")?(N=n.jsx("div",{className:"space-y-4",children:n.jsx("p",{className:"text-sm text-muted-foreground",children:"Nenhum site verificado foi encontrado. Verifique um site no Google Search Console."})}),e[36]=N):N=e[36],N}let R;e[37]!==h||e[38]!==P?(R=N=>{const{field:B}=N;return n.jsxs(me,{children:[n.jsx(fe,{children:n.jsx(He,{options:P.map(jn),value:B.value,onChange:B.onChange,disabled:h,ariaLabel:"Site verificado"})}),n.jsx(pe,{})]})},e[37]=h,e[38]=P,e[39]=R):R=e[39];let $;e[40]!==x.control||e[41]!==R?($=n.jsx(ue,{control:x.control,name:"siteUrl",render:R}),e[40]=x.control,e[41]=R,e[42]=$):$=e[42];let K;e[43]!==x||e[44]!==$?(K=n.jsx(Ie,{...x,children:$}),e[43]=x,e[44]=$,e[45]=K):K=e[45];let U;e[46]!==L?(U=L&&n.jsx("p",{role:"alert",className:"text-sm text-destructive",children:L instanceof Error?L.message:"Não foi possível salvar a configuração"}),e[46]=L,e[47]=U):U=e[47];let z;e[48]!==h||e[49]!==a?(z=n.jsx(X,{type:"button",variant:"outline",onClick:a,disabled:h,children:"Cancelar"}),e[48]=h,e[49]=a,e[50]=z):z=e[50];const G=h?"Salvando...":"Salvar";let D;e[51]!==h||e[52]!==G?(D=n.jsx(X,{type:"submit",disabled:h,children:G}),e[51]=h,e[52]=G,e[53]=D):D=e[53];let E;e[54]!==z||e[55]!==D?(E=n.jsxs(Ce,{className:"pt-4",children:[z,D]}),e[54]=z,e[55]=D,e[56]=E):E=e[56];let k;return e[57]!==_||e[58]!==K||e[59]!==U||e[60]!==E?(k=n.jsxs("form",{onSubmit:_,className:"space-y-4",children:[K,U,E]}),e[57]=_,e[58]=K,e[59]=U,e[60]=E,e[61]=k):k=e[61],k}function jn(s){return{value:s.siteUrl,label:s.siteUrl}}function Sn(s){const[e,t]=s.split("/");return!e||!t?null:{owner:e,name:t}}function _n(s){const{existingRepo:e,owner:t,name:o}=s;return e?.connectionId&&e.owner.toLowerCase()===t.toLowerCase()&&e.name.toLowerCase()===o.toLowerCase()?{connectionId:e.connectionId,installationId:e.installationId}:null}function Nn(s){const{existingRepo:e,existingConnections:t,repoConnectionId:o}=s,c=e?.connectionId&&e.connectionId!==o?e.connectionId:void 0,l=[...t.filter(u=>u.connection_id!==o&&u.connection_id!==c),{connection_id:o,selected_tools:[]}];return{staleConnectionId:c,mergedConnections:l}}const On=_e({githubRepo:de().min(1,"commerceOnboarding.githubConfigForm.selectRepository")}),In=15e3,En=/^[\w.-]+\/[\w.-]+$/;async function Tn(s,e,t,o){const{installations:c}=await jt(s,t),l=o.trim(),u=await Promise.allSettled(c.map(async i=>{const r=i.type==="User"?"user":"org",g=l?`${r}:${i.login} ${l} in:name`:`${r}:${i.login}`,y=await e.callTool({name:"search_repositories",arguments:{query:g,page:1,perPage:50}},void 0,{signal:AbortSignal.timeout(In)}),j=y.content?.[0]?.text;if(y.isError)throw new Error(j??"search_repositories failed");if(!j)throw new Error("empty search_repositories response");return JSON.parse(j).items??[]})),d=new Map;let a=0;for(const i of u){if(i.status==="rejected"){a+=1;continue}for(const r of i.value)r.full_name&&!d.has(r.full_name)&&d.set(r.full_name,r)}return{repos:Array.from(d.values()).sort((i,r)=>(r.updated_at??"").localeCompare(i.updated_at??"")).map(i=>i.full_name),failed:a,total:c.length}}function wn(s){const e=M.c(109),{connectionId:t,companionClient:o,selfClient:c,org:l,onDone:u,onIsPendingChange:d}=s,a=re(),p=Se();let i;e[0]!==l.id?(i=mt.COMMERCE_DISCOVERY(l.id),e[0]=l.id,e[1]=i):i=e[1];const r=i,[g,m]=V.useState(""),y=Zt(g,300),j=V.useRef(!1);let b;e[2]!==t||e[3]!==l.id?(b=Z.commerceDiscoveryCompanionGithubSelected(l.id,t),e[2]=t,e[3]=l.id,e[4]=b):b=e[4];let x;e[5]!==r||e[6]!==c?(x=async()=>{const Y=await c.callTool({name:"COLLECTION_CONNECTIONS_GET",arguments:{id:r}}),se=ne(Y).item?.configuration_state??null;return typeof se?.github_repo=="string"?se.github_repo:""},e[5]=r,e[6]=c,e[7]=x):x=e[7];let f;e[8]!==b||e[9]!==x?(f={queryKey:b,queryFn:x},e[8]=b,e[9]=x,e[10]=f):f=e[10];const S=be(f);let h;e[11]!==t||e[12]!==y||e[13]!==l.id?(h=Z.commerceDiscoveryCompanionGithubRepos(l.id,t,y.trim()),e[11]=t,e[12]=y,e[13]=l.id,e[14]=h):h=e[14];let L;e[15]!==o||e[16]!==t||e[17]!==y||e[18]!==c?(L=()=>Tn(Y=>c.callTool(Y),o,t,y),e[15]=o,e[16]=t,e[17]=y,e[18]=c,e[19]=L):L=e[19];let T;e[20]!==h||e[21]!==L?(T={queryKey:h,queryFn:L},e[20]=h,e[21]=L,e[22]=T):T=e[22];const C=be(T);let v;e[23]===Symbol.for("react.memo_cache_sentinel")?(v={resolver:Ne(On),defaultValues:{githubRepo:""}},e[23]=v):v=e[23];const w=Oe(v);let I;e[24]!==r||e[25]!==o||e[26]!==t||e[27]!==l.id||e[28]!==l.slug||e[29]!==c||e[30]!==a?(I=async Y=>{const se=await c.callTool({name:"COLLECTION_CONNECTIONS_GET",arguments:{id:r}}),Et={...ne(se).item?.configuration_state??null??{},github_repo:Y};await c.callTool({name:"COLLECTION_CONNECTIONS_UPDATE",arguments:{id:r,data:{configuration_state:Et}}});const Je=Sn(Y);if(!Je)throw new Error(a("commerceOnboarding.githubConfigForm.invalidRepository",{repo:Y}));const{owner:ve,name:De}=Je,et=Dt(l.id),tt=ne(await c.callTool({name:"COLLECTION_VIRTUAL_MCP_GET",arguments:{id:et}})).item,nt=tt?.metadata?.githubRepo,Tt=tt?.connections??[],ot=_n({existingRepo:nt,owner:ve,name:De});let we=ot?.connectionId,Pe=ot?.installationId,$e;if(!we){const{installations:qe}=await jt(je=>c.callTool(je),t),Ae=Xt(qe,ve);if(!Ae)throw new Error(a("commerceOnboarding.githubConfigForm.noGithubInstallation",{owner:ve}));Pe=Ae.installationId;const it=ne(await c.callTool({name:"COLLECTION_CONNECTIONS_GET",arguments:{id:t}})).item;if(!it)throw new Error(a("commerceOnboarding.githubConfigForm.githubConnectionNotFound"));const{childConnectionId:rt}=await Jt({orgSlug:l.slug,sourceConnection:it,installationId:Pe,owner:ve,repo:De,githubCallTool:je=>o.callTool(je),selfCallTool:je=>c.callTool(je)});we=rt,$e=rt}const{staleConnectionId:st,mergedConnections:wt}=Nn({existingRepo:nt,existingConnections:Tt,repoConnectionId:we});try{await c.callTool({name:"COLLECTION_VIRTUAL_MCP_UPDATE",arguments:{id:et,data:{connections:wt,metadata:{githubRepo:{owner:ve,name:De,url:`https://github.com/${Y}`,installationId:Pe,connectionId:we}}}}}),st&&await c.callTool({name:"COLLECTION_CONNECTIONS_DELETE",arguments:{id:st,force:!0}}).catch(kn)}catch(qe){const Ae=qe;throw $e&&await c.callTool({name:"COLLECTION_CONNECTIONS_DELETE",arguments:{id:$e,force:!0}}).catch(Ln),Ae}},e[24]=r,e[25]=o,e[26]=t,e[27]=l.id,e[28]=l.slug,e[29]=c,e[30]=a,e[31]=I):I=e[31];let A;e[32]!==r||e[33]!==u||e[34]!==l.id||e[35]!==p?(A=async()=>{await p.invalidateQueries({queryKey:Z.commerceDiscoveryConnection(l.id,r)}),await p.invalidateQueries({queryKey:Z.commerceDiscoveryCompanionConnectionsPrefix(l.id)}),Lt(p,l.id),u()},e[32]=r,e[33]=u,e[34]=l.id,e[35]=p,e[36]=A):A=e[36];let F;e[37]!==A||e[38]!==I?(F={mutationFn:I,onSuccess:A},e[37]=A,e[38]=I,e[39]=F):F=e[39];const _=Re(F),O=_.isPending;let P,R;e[40]!==O||e[41]!==d?(P=()=>{d?.(O)},R=[O,d],e[40]=O,e[41]=d,e[42]=P,e[43]=R):(P=e[42],R=e[43]),V.useEffect(P,R);const $=S.data??"";let K,U;e[44]!==w||e[45]!==S.data||e[46]!==S.isSuccess?(K=()=>{!S.isSuccess||j.current||(j.current=!0,S.data&&w.setValue("githubRepo",S.data))},U=[S.isSuccess,S.data,w],e[44]=w,e[45]=S.data,e[46]=S.isSuccess,e[47]=K,e[48]=U):(K=e[47],U=e[48]),V.useEffect(K,U);let z;if(e[49]!==w||e[50]!==_){let Y;e[52]!==_?(Y=async se=>{_.mutate(se.githubRepo)},e[52]=_,e[53]=Y):Y=e[53],z=w.handleSubmit(Y),e[49]=w,e[50]=_,e[51]=z}else z=e[51];const G=z;let D,E,k;if(e[54]!==y||e[55]!==C.data?.failed||e[56]!==C.data?.repos||e[57]!==C.data?.total||e[58]!==$){const Y=C.data?.repos??[];D=C.data?.failed??0,k=C.data?.total??0;const se=y.trim();E=[...Y],se&&En.test(se)&&!E.includes(se)&&E.unshift(se),$&&!E.includes($)&&E.push($),e[54]=y,e[55]=C.data?.failed,e[56]=C.data?.repos,e[57]=C.data?.total,e[58]=$,e[59]=D,e[60]=E,e[61]=k}else D=e[59],E=e[60],k=e[61];const N=k>0&&D===k;let B;e[62]!==N||e[63]!==D||e[64]!==C.isError||e[65]!==a?(B=C.isError||N?a("commerceOnboarding.githubConfigForm.searchFailedTotal"):D>0?a("commerceOnboarding.githubConfigForm.searchFailedPartial"):null,e[62]=N,e[63]=D,e[64]=C.isError,e[65]=a,e[66]=B):B=e[66];const Q=B;let te;e[67]===Symbol.for("react.memo_cache_sentinel")?(te=n.jsx(Ct,{size:16,className:"pointer-events-none absolute left-2.5 top-1/2 -translate-y-1/2 text-muted-foreground"}),e[67]=te):te=e[67];let oe;e[68]===Symbol.for("react.memo_cache_sentinel")?(oe=Y=>m(Y.target.value),e[68]=oe):oe=e[68];let J;e[69]!==a?(J=a("commerceOnboarding.githubConfigForm.searchRepositoryPlaceholder"),e[69]=a,e[70]=J):J=e[70];let q;e[71]!==a?(q=a("commerceOnboarding.githubConfigForm.searchRepositoryLabel"),e[71]=a,e[72]=q):q=e[72];let H;e[73]!==O||e[74]!==g||e[75]!==J||e[76]!==q?(H=n.jsxs("div",{className:"relative",children:[te,n.jsx(Ee,{type:"text",value:g,onChange:oe,disabled:O,placeholder:J,"aria-label":q,className:"h-8 pl-8"})]}),e[73]=O,e[74]=g,e[75]=J,e[76]=q,e[77]=H):H=e[77];let ee;e[78]!==w||e[79]!==O||e[80]!==E||e[81]!==C.isLoading||e[82]!==Q||e[83]!==a?(ee=C.isLoading?n.jsx("div",{className:"flex min-h-[160px] items-center justify-center",children:n.jsx(We,{label:a("commerceOnboarding.githubConfigForm.loadingRepositories")})}):n.jsxs(n.Fragment,{children:[Q&&n.jsx("p",{role:"alert",className:"text-sm text-destructive",children:Q}),E.length===0?!Q&&n.jsx("p",{className:"text-sm text-muted-foreground",children:a("commerceOnboarding.githubConfigForm.noRepositoriesFound")}):n.jsx(Ie,{...w,children:n.jsx(ue,{control:w.control,name:"githubRepo",render:Y=>{const{field:se}=Y;return n.jsxs(me,{children:[n.jsx(fe,{children:n.jsx(He,{options:E.map(An),value:se.value,onChange:se.onChange,disabled:O,ariaLabel:"Repositório",hideSearch:!0})}),n.jsx(pe,{})]})}})})]}),e[78]=w,e[79]=O,e[80]=E,e[81]=C.isLoading,e[82]=Q,e[83]=a,e[84]=ee):ee=e[84];let ae;e[85]!==_.error||e[86]!==a?(ae=_.error&&n.jsx("p",{role:"alert",className:"text-sm text-destructive",children:_.error instanceof Error?_.error.message:a("commerceOnboarding.githubConfigForm.failedToSave")}),e[85]=_.error,e[86]=a,e[87]=ae):ae=e[87];let W;e[88]!==a?(W=a("commerceOnboarding.githubConfigForm.cancel"),e[88]=a,e[89]=W):W=e[89];let ie;e[90]!==O||e[91]!==u||e[92]!==W?(ie=n.jsx(X,{type:"button",variant:"outline",onClick:u,disabled:O,children:W}),e[90]=O,e[91]=u,e[92]=W,e[93]=ie):ie=e[93];let ge;e[94]!==O||e[95]!==a?(ge=a(O?"commerceOnboarding.githubConfigForm.saving":"commerceOnboarding.githubConfigForm.save"),e[94]=O,e[95]=a,e[96]=ge):ge=e[96];let he;e[97]!==O||e[98]!==ge?(he=n.jsx(X,{type:"submit",disabled:O,children:ge}),e[97]=O,e[98]=ge,e[99]=he):he=e[99];let xe;e[100]!==ie||e[101]!==he?(xe=n.jsxs(Ce,{className:"pt-4",children:[ie,he]}),e[100]=ie,e[101]=he,e[102]=xe):xe=e[102];let Te;return e[103]!==G||e[104]!==H||e[105]!==ee||e[106]!==ae||e[107]!==xe?(Te=n.jsxs("form",{onSubmit:G,className:"space-y-4",children:[H,ee,ae,xe]}),e[103]=G,e[104]=H,e[105]=ee,e[106]=ae,e[107]=xe,e[108]=Te):Te=e[108],Te}function An(s){return{value:s,label:s}}function Ln(){}function kn(){}const Fn={vtex:pn,"google-analytics":xn,"google-search-console":vn,github:wn},ye="deco-reader@decocms.iam.gserviceaccount.com",Ot={"google-analytics":"ga4","google-search-console":"gsc"},It={ga4:{label:"Google Analytics",resourceLabel:"ID da propriedade",resourcePlaceholder:"ex: 123456789",resourceHint:"No GA4: Admin → Detalhes da propriedade → ID da propriedade (só números).",connectSteps:["Abra o Google Analytics (GA4) da sua loja.","Vá em Admin → Acesso à propriedade (Gerenciamento de acesso).",`Clique em + → Adicionar usuários, cole ${ye} e conceda o papel Leitor.`,"Copie o ID da propriedade (Admin → Detalhes da propriedade) e cole abaixo."]},gsc:{label:"Google Search Console",resourceLabel:"Site / propriedade",resourcePlaceholder:"ex: sc-domain:sualoja.com.br",resourceHint:"Use o mesmo formato que aparece no Search Console: sc-domain:sualoja.com.br ou https://www.sualoja.com.br/.",connectSteps:["Abra o Google Search Console da sua loja.","Vá em Configurações → Usuários e permissões.",`Clique em Adicionar usuário, cole ${ye} e escolha permissão Completa.`,"Copie o endereço do site como aparece no seletor de propriedades e cole abaixo."]}};function Rn(s,e){const t=It[s].label;switch(e){case"no-access":return{title:`Ainda não conseguimos acessar este recurso no ${t}.`,steps:s==="ga4"?[`Confirme que ${ye} foi adicionado em Admin → Acesso à propriedade com o papel Leitor.`,"Confira se o ID da propriedade está correto (só números, sem o prefixo 'properties/').","A concessão de acesso pode levar alguns segundos — tente novamente."]:[`Confirme que ${ye} foi adicionado em Configurações → Usuários e permissões.`,"A permissão precisa ser Completa ou Restrita — 'Não verificado' não funciona.","Confira se o endereço do site está exatamente como aparece no Search Console."]};case"no-web-stream":return{title:"Esta propriedade do GA4 não tem um fluxo de dados da Web (site) configurado.",steps:["No GA4, vá em Admin → Fluxos de dados.","Clique em Adicionar fluxo → Web.","Informe a URL do site da sua loja e salve o fluxo.","Volte aqui e tente vincular de novo. (Propriedades só de app precisam de vínculo manual — fale com o suporte.)"]};case"no-match":return{title:"O recurso informado não corresponde ao domínio desta loja.",steps:s==="ga4"?["Verifique se digitou o ID da propriedade certa — provavelmente é de outro site.","No GA4, o site medido aparece em Admin → Fluxos de dados → (seu fluxo Web) → URL do stream."]:["Verifique se selecionou a propriedade do Search Console referente a esta loja.","O endereço precisa cobrir o mesmo domínio do diagnóstico."]};case"resource_already_bound":return{title:"Este recurso já está vinculado a outra loja.",steps:["Se este recurso é realmente desta loja, fale com o suporte para uma revisão manual.","Caso tenha digitado o id errado, confira e tente novamente."]};default:return{title:"Não foi possível verificar o acesso a este recurso.",steps:["Revise os passos de acesso acima e tente novamente.","Se persistir, fale com o suporte."]}}}function Dn(s){const e=M.c(95),{provider:t,siteUrl:o,selfClient:c,org:l,initialResourceId:u,onDone:d,onIsPendingChange:a,onOAuthInstead:p}=s,i=re(),r=It[t],g=Se(),[m,y]=V.useState(null);let j,b;if(e[0]!==r.resourceLabel||e[1]!==i){const W=_e({resourceId:de().trim().min(1,i("commerceOnboarding.saBindingForm.resourceIdRequired",{resourceLabel:r.resourceLabel.toLowerCase()}))});b=Oe,j=Ne(W),e[0]=r.resourceLabel,e[1]=i,e[2]=j,e[3]=b}else j=e[2],b=e[3];const x=u??"";let f;e[4]!==x?(f={resourceId:x},e[4]=x,e[5]=f):f=e[5];let S;e[6]!==j||e[7]!==f?(S={resolver:j,defaultValues:f},e[6]=j,e[7]=f,e[8]=S):S=e[8];const h=b(S);let L;e[9]!==t||e[10]!==c||e[11]!==o||e[12]!==i?(L=async W=>{if(!o)throw new Error(i("commerceOnboarding.saBindingForm.storeUrlUnavailable"));const ie=await c.callTool({name:"COMMERCE_DISCOVERY_BIND",arguments:{siteUrl:o,provider:t,resourceId:W.resourceId}});return ne(ie)},e[9]=t,e[10]=c,e[11]=o,e[12]=i,e[13]=L):L=e[13];let T,C;e[14]!==a?(T=()=>a?.(!0),C=()=>a?.(!1),e[14]=a,e[15]=T,e[16]=C):(T=e[15],C=e[16]);let v;e[17]!==r.label||e[18]!==d||e[19]!==l||e[20]!==t||e[21]!==g||e[22]!==o||e[23]!==i?(v=async W=>{if(W.ok){y(null),ke.success(i("commerceOnboarding.saBindingForm.connectedSuccess",{label:r.label})),o&&await g.invalidateQueries({queryKey:Z.commerceDiscoveryConnectionStatus(l.id,o)}),d();return}y({...Rn(t,W.reason??"unknown"),detail:W.detail})},e[17]=r.label,e[18]=d,e[19]=l,e[20]=t,e[21]=g,e[22]=o,e[23]=i,e[24]=v):v=e[24];let w;e[25]!==L||e[26]!==T||e[27]!==C||e[28]!==v?(w={mutationFn:L,onMutate:T,onSettled:C,onSuccess:v},e[25]=L,e[26]=T,e[27]=C,e[28]=v,e[29]=w):w=e[29];const I=Re(w);let A;if(e[30]!==h||e[31]!==I){let W;e[33]!==I?(W=ie=>I.mutate(ie),e[33]=I,e[34]=W):W=e[34],A=h.handleSubmit(W),e[30]=h,e[31]=I,e[32]=A}else A=e[32];const F=A,_=I.isPending;let O;e[35]!==i?(O=()=>{navigator.clipboard?.writeText(ye),ke.success(i("commerceOnboarding.saBindingForm.emailCopied"))},e[35]=i,e[36]=O):O=e[36];const P=O;let R;e[37]!==r.connectSteps?(R=r.connectSteps.map($n),e[37]=r.connectSteps,e[38]=R):R=e[38];let $;e[39]!==R?($=n.jsx("ol",{className:"space-y-2 text-sm text-muted-foreground",children:R}),e[39]=R,e[40]=$):$=e[40];let K;e[41]===Symbol.for("react.memo_cache_sentinel")?(K=n.jsx("code",{className:"min-w-0 flex-1 truncate text-xs text-foreground",children:ye}),e[41]=K):K=e[41];let U;e[42]!==i?(U=i("commerceOnboarding.saBindingForm.copyEmailLabel"),e[42]=i,e[43]=U):U=e[43];let z;e[44]===Symbol.for("react.memo_cache_sentinel")?(z=n.jsx(vt,{size:16}),e[44]=z):z=e[44];let G;e[45]!==P||e[46]!==U?(G=n.jsxs("div",{className:"flex items-center gap-2 rounded-lg border border-border bg-muted/40 p-2",children:[K,n.jsx(X,{type:"button",variant:"ghost",size:"icon-sm",onClick:P,"aria-label":U,children:z})]}),e[45]=P,e[46]=U,e[47]=G):G=e[47];let D;e[48]!==r.resourceHint||e[49]!==r.resourceLabel||e[50]!==r.resourcePlaceholder||e[51]!==_?(D=W=>{const{field:ie}=W;return n.jsxs(me,{children:[n.jsx(Le,{children:r.resourceLabel}),n.jsx(fe,{children:n.jsx(Ee,{...ie,placeholder:r.resourcePlaceholder,disabled:_,autoComplete:"off"})}),n.jsx(Qt,{children:r.resourceHint}),n.jsx(pe,{})]})},e[48]=r.resourceHint,e[49]=r.resourceLabel,e[50]=r.resourcePlaceholder,e[51]=_,e[52]=D):D=e[52];let E;e[53]!==h.control||e[54]!==D?(E=n.jsx(ue,{control:h.control,name:"resourceId",render:D}),e[53]=h.control,e[54]=D,e[55]=E):E=e[55];let k;e[56]!==h||e[57]!==E?(k=n.jsx(Ie,{...h,children:E}),e[56]=h,e[57]=E,e[58]=k):k=e[58];let N;e[59]!==m?(N=m&&n.jsxs("div",{role:"alert",className:"space-y-2 rounded-lg border border-destructive/40 bg-destructive/5 p-3",children:[n.jsx("p",{className:"text-sm font-medium text-foreground",children:m.title}),n.jsx("ol",{className:"space-y-1 text-sm text-muted-foreground",children:m.steps.map(Pn)})]}),e[59]=m,e[60]=N):N=e[60];let B;e[61]!==I.error||e[62]!==I.isError||e[63]!==i?(B=I.isError&&n.jsx("p",{role:"alert",className:"text-sm text-destructive",children:I.error instanceof Error?I.error.message:i("commerceOnboarding.saBindingForm.bindError")}),e[61]=I.error,e[62]=I.isError,e[63]=i,e[64]=B):B=e[64];let Q;e[65]!==_||e[66]!==p||e[67]!==i?(Q=p?n.jsx("button",{type:"button",onClick:p,disabled:_,className:"text-xs text-muted-foreground underline underline-offset-2 hover:text-foreground disabled:opacity-50",children:i("commerceOnboarding.saBindingForm.googleLoginAlternative")}):n.jsx("span",{}),e[65]=_,e[66]=p,e[67]=i,e[68]=Q):Q=e[68];let te;e[69]!==i?(te=i("commerceOnboarding.saBindingForm.cancel"),e[69]=i,e[70]=te):te=e[70];let oe;e[71]!==_||e[72]!==d||e[73]!==te?(oe=n.jsx(X,{type:"button",variant:"outline",onClick:d,disabled:_,children:te}),e[71]=_,e[72]=d,e[73]=te,e[74]=oe):oe=e[74];let J;e[75]!==_||e[76]!==i?(J=i(_?"commerceOnboarding.saBindingForm.verifying":"commerceOnboarding.saBindingForm.bind"),e[75]=_,e[76]=i,e[77]=J):J=e[77];let q;e[78]!==_||e[79]!==J?(q=n.jsx(X,{type:"submit",disabled:_,children:J}),e[78]=_,e[79]=J,e[80]=q):q=e[80];let H;e[81]!==oe||e[82]!==q?(H=n.jsxs("div",{className:"flex gap-2",children:[oe,q]}),e[81]=oe,e[82]=q,e[83]=H):H=e[83];let ee;e[84]!==Q||e[85]!==H?(ee=n.jsxs(Ce,{className:"flex-col gap-2 pt-2 sm:flex-row sm:items-center sm:justify-between",children:[Q,H]}),e[84]=Q,e[85]=H,e[86]=ee):ee=e[86];let ae;return e[87]!==F||e[88]!==$||e[89]!==G||e[90]!==k||e[91]!==N||e[92]!==B||e[93]!==ee?(ae=n.jsxs("form",{onSubmit:F,className:"space-y-4",children:[$,G,k,N,B,ee]}),e[87]=F,e[88]=$,e[89]=G,e[90]=k,e[91]=N,e[92]=B,e[93]=ee,e[94]=ae):ae=e[94],ae}function Pn(s){return n.jsxs("li",{className:"flex gap-2",children:[n.jsx("span",{"aria-hidden":!0,children:"•"}),n.jsx("span",{children:s})]},s)}function $n(s,e){return n.jsxs("li",{className:"flex gap-2",children:[n.jsx("span",{className:"flex size-5 shrink-0 items-center justify-center rounded-full bg-muted text-xs font-medium text-foreground",children:e+1}),n.jsx("span",{children:s})]},s)}function qn(){const s=M.c(2);let e;s[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx("div",{className:"size-9 shrink-0 animate-pulse rounded-lg bg-muted/60"}),s[0]=e):e=s[0];let t;return s[1]===Symbol.for("react.memo_cache_sentinel")?(t=n.jsxs("div",{className:"flex items-center gap-3 rounded-2xl border border-border bg-card p-3 sm:h-full sm:flex-col sm:items-stretch sm:p-4",children:[e,n.jsxs("div",{className:"min-w-0 flex-1 space-y-2",children:[n.jsx("div",{className:"h-4 w-24 animate-pulse rounded bg-muted/60"}),n.jsx("div",{className:"hidden h-3 w-full animate-pulse rounded bg-muted/60 sm:block"})]}),n.jsx("div",{className:"h-8 w-20 shrink-0 animate-pulse rounded-lg bg-muted/60 sm:mt-auto sm:w-full"})]}),s[1]=t):t=s[1],t}function ct(s){const e=M.c(17),{title:t,disconnecting:o,disabled:c,onDisconnect:l}=s,u=re(),d=c||o;let a;e[0]!==u||e[1]!==t?(a=u("commerceOnboarding.companionCard.disconnectAriaLabel",{title:t}),e[0]=u,e[1]=t,e[2]=a):a=e[2];let p;e[3]!==o?(p=o?n.jsx(Ue,{size:16,className:"animate-spin"}):n.jsx($t,{size:16}),e[3]=o,e[4]=p):p=e[4];let i;e[5]!==l||e[6]!==d||e[7]!==a||e[8]!==p?(i=n.jsx(Me,{asChild:!0,children:n.jsx(X,{type:"button",variant:"ghost",size:"icon-sm",className:"shrink-0 text-muted-foreground hover:text-destructive",disabled:d,onClick:l,"aria-label":a,children:p})}),e[5]=l,e[6]=d,e[7]=a,e[8]=p,e[9]=i):i=e[9];let r;e[10]!==u?(r=u("commerceOnboarding.companionCard.disconnect"),e[10]=u,e[11]=r):r=e[11];let g;e[12]!==r?(g=n.jsx(Ve,{children:r}),e[12]=r,e[13]=g):g=e[13];let m;return e[14]!==i||e[15]!==g?(m=n.jsxs(Be,{children:[i,g]}),e[14]=i,e[15]=g,e[16]=m):m=e[16],m}function Kn(s){const e=M.c(23),{card:t,connecting:o,disconnecting:c,disabled:l,onConnect:u,onDisconnect:d,org:a,selfClient:p,siteUrl:i,autoOpenConfigFieldKey:r,onAutoOpenConfigHandled:g}=s,m=t.linkedConnectionId,y=Ot[t.bindingType],j=!!y&&t.boundVia!=="oauth",b=t.satisfied&&!t.configured;let x;e[0]!==r||e[1]!==t||e[2]!==o||e[3]!==l||e[4]!==c||e[5]!==m||e[6]!==b||e[7]!==g||e[8]!==u||e[9]!==d||e[10]!==a||e[11]!==y||e[12]!==p||e[13]!==i||e[14]!==j?(x=j&&y?n.jsx(Un,{card:t,provider:y,org:a,selfClient:p,siteUrl:i,onOAuthInstead:u,disabled:l,connecting:o,primary:t.required}):t.satisfied&&m?b?n.jsxs("div",{className:"flex items-center justify-end gap-1 sm:justify-start",children:[n.jsx(V.Suspense,{fallback:n.jsx(dt,{}),children:n.jsx(ut,{card:t,org:a,selfClient:p,connectionId:m,contextSiteUrl:i,variant:"configure",disabled:l,autoOpen:at({autoOpenFieldKey:r,card:t}),onAutoOpenHandled:g})}),n.jsx(ct,{title:t.title,disconnecting:c,disabled:l,onDisconnect:d})]}):n.jsx(_t,{detail:t.connectedDetail,controls:n.jsxs(n.Fragment,{children:[n.jsx(V.Suspense,{fallback:n.jsx(dt,{}),children:n.jsx(ut,{card:t,org:a,selfClient:p,connectionId:m,contextSiteUrl:i,variant:"gear",disabled:l,autoOpen:at({autoOpenFieldKey:r,card:t}),onAutoOpenHandled:g})}),n.jsx(ct,{title:t.title,disconnecting:c,disabled:l,onDisconnect:d})]})}):n.jsx(St,{connecting:o,disabled:l,title:t.title,primary:t.required,onConnect:u}),e[0]=r,e[1]=t,e[2]=o,e[3]=l,e[4]=c,e[5]=m,e[6]=b,e[7]=g,e[8]=u,e[9]=d,e[10]=a,e[11]=y,e[12]=p,e[13]=i,e[14]=j,e[15]=x):x=e[15];const f=x,S=t.required&&!t.satisfied;let h;return e[16]!==f||e[17]!==t.headline||e[18]!==t.icon||e[19]!==t.title||e[20]!==b||e[21]!==S?(h=n.jsx(un,{icon:t.icon,title:t.title,headline:t.headline,required:S,attention:b,action:f}),e[16]=f,e[17]=t.headline,e[18]=t.icon,e[19]=t.title,e[20]=b,e[21]=S,e[22]=h):h=e[22],h}function Un(s){const e=M.c(46),{card:t,provider:o,org:c,selfClient:l,siteUrl:u,onOAuthInstead:d,disabled:a,connecting:p,primary:i}=s,r=re(),[g,m]=V.useState(!1),[y,j]=V.useState(!1);let b;e[0]!==y?(b=R=>{!R&&y||m(R)},e[0]=y,e[1]=b):b=e[1];const x=b;let f;e[2]!==t.connectedDetail||e[3]!==t.satisfied||e[4]!==t.title||e[5]!==p||e[6]!==a||e[7]!==i||e[8]!==r?(f=t.satisfied?n.jsx(_t,{detail:t.connectedDetail,controls:n.jsxs(Be,{children:[n.jsx(Me,{asChild:!0,children:n.jsx(Nt,{ariaLabel:r("commerceOnboarding.companionCard.configureAriaLabel",{title:t.title}),onClick:()=>m(!0)})}),n.jsx(Ve,{children:r("commerceOnboarding.companionCard.editConfiguration")})]})}):n.jsx(St,{connecting:p,disabled:a,title:t.title,primary:i,onConnect:()=>m(!0)}),e[2]=t.connectedDetail,e[3]=t.satisfied,e[4]=t.title,e[5]=p,e[6]=a,e[7]=i,e[8]=r,e[9]=f):f=e[9];let S;e[10]!==t.icon||e[11]!==t.title?(S=n.jsx(Ge,{icon:t.icon,name:t.title,size:"md",fit:"contain",className:"p-1.5"}),e[10]=t.icon,e[11]=t.title,e[12]=S):S=e[12];let h;e[13]!==t.title?(h=n.jsx(ft,{children:t.title}),e[13]=t.title,e[14]=h):h=e[14];let L;e[15]!==r?(L=r("commerceOnboarding.companionCard.grantAccessDescription"),e[15]=r,e[16]=L):L=e[16];let T;e[17]!==L?(T=n.jsx(pt,{children:L}),e[17]=L,e[18]=T):T=e[18];let C;e[19]!==h||e[20]!==T?(C=n.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:[h,T]}),e[19]=h,e[20]=T,e[21]=C):C=e[21];let v;e[22]!==S||e[23]!==C?(v=n.jsxs(gt,{className:"flex-row items-center gap-3 space-y-0 text-left",children:[S,C]}),e[22]=S,e[23]=C,e[24]=v):v=e[24];const w=t.boundResource??void 0;let I;e[25]===Symbol.for("react.memo_cache_sentinel")?(I=()=>m(!1),e[25]=I):I=e[25];let A;e[26]!==t.satisfied||e[27]!==d?(A=t.satisfied?void 0:()=>{m(!1),d()},e[26]=t.satisfied,e[27]=d,e[28]=A):A=e[28];let F;e[29]!==c||e[30]!==o||e[31]!==l||e[32]!==u||e[33]!==A||e[34]!==w?(F=n.jsx(Dn,{provider:o,siteUrl:u,selfClient:l,org:c,initialResourceId:w,onDone:I,onIsPendingChange:j,onOAuthInstead:A}),e[29]=c,e[30]=o,e[31]=l,e[32]=u,e[33]=A,e[34]=w,e[35]=F):F=e[35];let _;e[36]!==F||e[37]!==v?(_=n.jsxs(ht,{className:"sm:max-w-lg",children:[v,F]}),e[36]=F,e[37]=v,e[38]=_):_=e[38];let O;e[39]!==x||e[40]!==g||e[41]!==_?(O=n.jsx(xt,{open:g,onOpenChange:x,children:_}),e[39]=x,e[40]=g,e[41]=_,e[42]=O):O=e[42];let P;return e[43]!==O||e[44]!==f?(P=n.jsxs(n.Fragment,{children:[f,O]}),e[43]=O,e[44]=f,e[45]=P):P=e[45],P}function dt(){const s=M.c(1);let e;return s[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx("div",{className:"size-8 shrink-0 animate-pulse rounded-lg bg-muted/60"}),s[0]=e):e=s[0],e}function ut(s){const e=M.c(71),{card:t,org:o,selfClient:c,connectionId:l,contextSiteUrl:u,variant:d,disabled:a,autoOpen:p,onAutoOpenHandled:i}=s,r=re();let g;e[0]!==l||e[1]!==o.id||e[2]!==o.slug?(g={connectionId:l,orgId:o.id,orgSlug:o.slug},e[0]=l,e[1]=o.id,e[2]=o.slug,e[3]=g):g=e[3];const m=ze(g),[y,j]=V.useState(p),[b,x]=V.useState(!1),f=Se(),S=Fn[t.bindingType];let h;e[4]!==t.configurationState?(h=Ut(t.configurationState),e[4]=t.configurationState,e[5]=h):h=e[5];const L=h;let T;e[6]!==p||e[7]!==i?(T=()=>{j(!1),p&&i()},e[6]=p,e[7]=i,e[8]=T):T=e[8];const C=T;let v;e[9]!==C||e[10]!==b?(v=te=>{if(!(!te&&b)){if(!te){C();return}j(!0)}},e[9]=C,e[10]=b,e[11]=v):v=e[11];const w=v;let I;e[12]!==l||e[13]!==c?(I=async()=>{await c.callTool({name:"COLLECTION_CONNECTIONS_DELETE",arguments:{id:l,force:!0}})},e[12]=l,e[13]=c,e[14]=I):I=e[14];let A;e[15]!==t.title||e[16]!==C||e[17]!==o.id||e[18]!==f||e[19]!==r?(A=async()=>{await f.invalidateQueries({queryKey:Z.commerceDiscoveryCompanionConnectionsPrefix(o.id)}),ke.success(r("commerceOnboarding.companionCard.disconnectedSuccess",{title:t.title})),C()},e[15]=t.title,e[16]=C,e[17]=o.id,e[18]=f,e[19]=r,e[20]=A):A=e[20];let F;e[21]!==r?(F=()=>{ke.error(r("commerceOnboarding.companionCard.disconnectError"))},e[21]=r,e[22]=F):F=e[22];let _;e[23]!==I||e[24]!==A||e[25]!==F?(_={mutationFn:I,onSuccess:A,onError:F},e[23]=I,e[24]=A,e[25]=F,e[26]=_):_=e[26];const O=Re(_);if(!S)return null;let P;e[27]!==t.title||e[28]!==a||e[29]!==L||e[30]!==r||e[31]!==d?(P=d==="configure"?n.jsx(mn,{disabled:a,title:t.title,onConfigure:()=>j(!0)}):n.jsxs(Be,{children:[n.jsx(Me,{asChild:!0,children:n.jsx(Nt,{ariaLabel:r("commerceOnboarding.companionCard.configureAriaLabel",{title:t.title}),onClick:()=>j(!0)})}),n.jsx(Ve,{children:L.length>0?r("commerceOnboarding.companionCard.editConfiguration"):r("commerceOnboarding.companionCard.configure")})]}),e[27]=t.title,e[28]=a,e[29]=L,e[30]=r,e[31]=d,e[32]=P):P=e[32];const R=P;let $;e[33]!==t.icon||e[34]!==t.title?($=n.jsx(Ge,{icon:t.icon,name:t.title,size:"md",fit:"contain",className:"p-1.5"}),e[33]=t.icon,e[34]=t.title,e[35]=$):$=e[35];let K;e[36]!==t.title?(K=n.jsx(ft,{children:t.title}),e[36]=t.title,e[37]=K):K=e[37];let U;e[38]!==t.title||e[39]!==r?(U=r("commerceOnboarding.companionCard.configureDescription",{title:t.title}),e[38]=t.title,e[39]=r,e[40]=U):U=e[40];let z;e[41]!==U?(z=n.jsx(pt,{children:U}),e[41]=U,e[42]=z):z=e[42];let G;e[43]!==K||e[44]!==z?(G=n.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:[K,z]}),e[43]=K,e[44]=z,e[45]=G):G=e[45];let D;e[46]!==$||e[47]!==G?(D=n.jsxs(gt,{className:"flex-row items-center gap-3 space-y-0 text-left",children:[$,G]}),e[46]=$,e[47]=G,e[48]=D):D=e[48];let E;e[49]!==O?(E=()=>O.mutate(),e[49]=O,e[50]=E):E=e[50];let k;e[51]!==S||e[52]!==t||e[53]!==C||e[54]!==m||e[55]!==l||e[56]!==u||e[57]!==o||e[58]!==c||e[59]!==E?(k=n.jsx(S,{card:t,connectionId:l,companionClient:m,selfClient:c,org:o,contextSiteUrl:u,onDone:C,onDisconnect:E,onIsPendingChange:x}),e[51]=S,e[52]=t,e[53]=C,e[54]=m,e[55]=l,e[56]=u,e[57]=o,e[58]=c,e[59]=E,e[60]=k):k=e[60];let N;e[61]!==D||e[62]!==k?(N=n.jsxs(ht,{className:"sm:max-w-lg",children:[D,k]}),e[61]=D,e[62]=k,e[63]=N):N=e[63];let B;e[64]!==y||e[65]!==w||e[66]!==N?(B=n.jsx(xt,{open:y,onOpenChange:w,children:N}),e[64]=y,e[65]=w,e[66]=N,e[67]=B):B=e[67];let Q;return e[68]!==B||e[69]!==R?(Q=n.jsxs(n.Fragment,{children:[R,B]}),e[68]=B,e[69]=R,e[70]=Q):Q=e[70],Q}const Ye={vtex:{registryAppId:"deco/vtex",area:"Catálogo",headline:"Rupturas e PDPs que travam suas vendas."},"google-analytics":{registryAppId:"deco/google-analytics",area:"Funil",headline:"Onde a receita vaza no seu funil."},"google-search-console":{registryAppId:"deco/google-search-console",area:"Busca",headline:"O tráfego de busca que você deixa na mesa."},github:{registryAppId:"deco/mcp-github",area:"Engenharia",headline:"A saúde da entrega de código por trás da sua loja."}};function zn(s){const e=M.c(40),{selfClient:t,org:o,cdConnectionId:c,siteUrl:l}=s;let u;e[0]!==c||e[1]!==o.id||e[2]!==o.slug?(u={connectionId:c,orgId:o.id,orgSlug:o.slug},e[0]=c,e[1]=o.id,e[2]=o.slug,e[3]=u):u=e[3];const d=ze(u);let a;e[4]!==c||e[5]!==o.id?(a=Z.commerceDiscoveryCompanionSchema(o.id,c),e[4]=c,e[5]=o.id,e[6]=a):a=e[6];let p;e[7]!==d?(p=async()=>{const q=await d.callTool({name:"MCP_CONFIGURATION",arguments:{}});return ne(q)},e[7]=d,e[8]=p):p=e[8];let i;e[9]!==a||e[10]!==p?(i={queryKey:a,queryFn:p,retry:!1},e[9]=a,e[10]=p,e[11]=i):i=e[11];const r=be(i),g=r.data?.stateSchema?zt(r.data.stateSchema):null,m=g&&g.length>0?g:Gt,y=m.map(Xn),j=m.map(Zn).filter(Yn),b=m.filter(Wn).map(Hn),x=[...j,...b].sort().join(",");let f;e[12]!==c||e[13]!==o.id?(f=Z.commerceDiscoveryConnection(o.id,c),e[12]=c,e[13]=o.id,e[14]=f):f=e[14];let S;e[15]!==c||e[16]!==t?(S=async()=>{const q=await t.callTool({name:"COLLECTION_CONNECTIONS_GET",arguments:{id:c}});return ne(q)},e[15]=c,e[16]=t,e[17]=S):S=e[17];let h;e[18]!==f||e[19]!==S?(h={queryKey:f,queryFn:S},e[18]=f,e[19]=S,e[20]=h):h=e[20];const T=Ke(h).data?.item?.configuration_state??null;let C;e[21]!==T?(C=q=>T?.[q.fieldKey]?.value,e[21]=T,e[22]=C):C=e[22];const v=m.map(C).filter(Qn),w=[...y.map(Vn),...j.map(Mn),...v.map(Bn)].sort().join(","),A=Ke({queryKey:Z.commerceDiscoveryCompanionConnections(o.id,w),queryFn:async()=>{if(m.length===0)return{items:[]};const q=[{field:["app_name"],operator:"in",value:y},{field:["app_id"],operator:"in",value:j}];v.length>0&&q.push({field:["id"],operator:"in",value:v});const H=await t.callTool({name:"COLLECTION_CONNECTIONS_LIST",arguments:{where:{operator:"or",conditions:q},limit:1e3}});return ne(H)}}).data?.items??[],F=new Set(v),_=A.filter(q=>F.has(q.id)),O=_.filter(Gn);let P;e[23]!==o.id||e[24]!==o.slug?(P=q=>({queryKey:Z.commerceDiscoveryCompanionOAuthStatus(o.id,q.id),queryFn:async()=>{try{const H=await fetch(`/api/${encodeURIComponent(o.slug)}/connections/${encodeURIComponent(q.id)}/oauth-token/status`,{credentials:"include"});return H.ok?{hasToken:(await H.json()).hasToken===!0}:{hasToken:!1}}catch{return{hasToken:!1}}},retry:!1}),e[23]=o.id,e[24]=o.slug,e[25]=P):P=e[25];const R=sn({queries:O.map(P)});let $;e[26]!==R?($=(q,H)=>[q.id,R[H]?.data?.hasToken===!0],e[26]=R,e[27]=$):$=e[27];const K=new Map(O.map($)),U={};for(const q of _)U[q.id]=!q.oauth_config||!!q.connection_token||K.get(q.id)===!0;const z=Ke({queryKey:Z.commerceDiscoveryCompanionRegistry(o.id,x),queryFn:async()=>{if(m.length===0)return{items:[]};const q=Bt(j,b),H=await en(mt.REGISTRY(o.id),o.id,o.slug,"COLLECTION_REGISTRY_APP_LIST",{...q?{where:q}:{},limit:1e3});return ne(H)}}),G={},D={};for(const q of z.data?.items??[])G[q.id]=q,q.server?.name&&(D[q.server.name]=q);let E;e[28]!==o.id||e[29]!==l?(E=Z.commerceDiscoveryConnectionStatus(o.id,l??""),e[28]=o.id,e[29]=l,e[30]=E):E=e[30];const k=!!l;let N;e[31]!==t||e[32]!==l?(N=async()=>{const q=await t.callTool({name:"COMMERCE_DISCOVERY_CONNECTION_STATUS",arguments:{siteUrl:l}});return ne(q)},e[31]=t,e[32]=l,e[33]=N):N=e[33];let B;e[34]!==E||e[35]!==k||e[36]!==N?(B={queryKey:E,enabled:k,queryFn:N},e[34]=E,e[35]=k,e[36]=N,e[37]=B):B=e[37];const Q=be(B),te={};for(const[q,H]of Object.entries(Ot)){const ee=Q.data?.providers?.[H];ee?.connected&&ee.via==="sa"&&(te[q]={resource:ee.resource??null})}const oe=Mt({requirements:m,itemsById:G,itemsByName:D,connections:A,connectionReadiness:U,configurationState:T,curated:Ye,saBindings:te});let J;return e[38]!==oe?(J={cards:oe},e[38]=oe,e[39]=J):J=e[39],J}function Gn(s){return s.oauth_config&&!s.connection_token}function Bn(s){return`linked:${s}`}function Mn(s){return`app:${s}`}function Vn(s){return`binding:${s}`}function Qn(s){return typeof s=="string"&&s.length>0}function Hn(s){return s.bindingType}function Wn(s){return!Ye[s.bindingType]}function Yn(s){return!!s}function Zn(s){return Ye[s.bindingType]?.registryAppId}function Xn(s){return s.bindingType}function Jn({selfClient:s,org:e,userId:t,cdConnectionId:o,domain:c,siteUrl:l}){const u=Se(),[d,a]=V.useState(null),[p,i]=V.useState(null),[r,g]=V.useState(null),m=async(b,x)=>{const f=await s.callTool({name:"COLLECTION_CONNECTIONS_UPDATE",arguments:{id:b,data:x}});return ne(f)};async function y(b){a(b.fieldKey),g(null);const x={app_name:b.title,field_key:b.fieldKey,organization_id:e.id,domain:c,site_url:l};le("commerce_onboarding_companion_connect_clicked",x);try{let f=b.candidateConnectionId;if(!f){const v=tn(b.registryItem,e.id,t,{remoteIndex:0}),w=v.connection_type==="STDIO",I=!!v.connection_url,A=w&&v.connection_headers&&typeof v.connection_headers=="object"&&"command"in v.connection_headers;if(!I&&!A)return le("commerce_onboarding_companion_connect_failed",{...x,error:"no_connection_method"}),g(`${b.title} cannot be connected: no connection method available`),!1;const F=await s.callTool({name:"COLLECTION_CONNECTIONS_CREATE",arguments:{data:v}});f=ne(F).item.id}const S=f,h=await on({connectionId:S,orgId:e.id,orgSlug:e.slug,persistFallback:v=>m(S,{connection_token:v}).then(()=>{})});if(!h.ok)return le("commerce_onboarding_companion_connect_failed",{...x,error:h.error}),g(`Couldn't sign in to ${b.title}: ${h.error}`),!1;const L=await s.callTool({name:"COLLECTION_CONNECTIONS_GET",arguments:{id:o}}),T=ne(L).item?.configuration_state??null,C=Vt(T,b.fieldKey,b.bindingType,S);return b.bindingType==="github"&&delete C.github_repo,await m(o,{configuration_state:C}),await u.invalidateQueries({queryKey:Z.commerceDiscoveryConnection(e.id,o)}),await u.invalidateQueries({queryKey:Z.commerceDiscoveryCompanionConnectionsPrefix(e.id)}),le("commerce_onboarding_companion_connected",x),!0}catch(f){return le("commerce_onboarding_companion_connect_failed",{...x,error:f instanceof Error?f.message:String(f)}),g(f instanceof Error?f.message:String(f)),!1}finally{a(null)}}async function j(b){i(b.fieldKey),g(null);const x={app_name:b.title,field_key:b.fieldKey,organization_id:e.id,domain:c,site_url:l};le("commerce_onboarding_companion_disconnect_clicked",x);try{const f=await s.callTool({name:"COLLECTION_CONNECTIONS_GET",arguments:{id:o}}),h={...ne(f).item?.configuration_state??null??{}};return delete h[b.fieldKey],b.bindingType==="github"&&delete h.github_repo,await m(o,{configuration_state:h}),await u.invalidateQueries({queryKey:Z.commerceDiscoveryConnection(e.id,o)}),await u.invalidateQueries({queryKey:Z.commerceDiscoveryCompanionConnectionsPrefix(e.id)}),le("commerce_onboarding_companion_disconnected",x),!0}catch(f){return le("commerce_onboarding_companion_disconnect_failed",{...x,error:f instanceof Error?f.message:String(f)}),g(f instanceof Error?f.message:String(f)),!1}finally{i(null)}}return{connect:y,connectingFieldKey:d,disconnect:j,disconnectingFieldKey:p,error:r}}const Ze="flex min-h-0 flex-1 flex-col gap-6 md:grid md:flex-none md:gap-6";function Xe(){const s=M.c(4),e=re();let t;s[0]!==e?(t=e("routes.commerceOnboarding.companionSection.title"),s[0]=e,s[1]=t):t=s[1];let o;return s[2]!==t?(o=n.jsx("h1",{className:"text-lg font-medium leading-6 text-foreground lg:text-xl lg:leading-7",children:t}),s[2]=t,s[3]=o):o=s[3],o}function eo(){const s=M.c(1);let e;return s[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx("div",{className:"flex flex-col gap-4",children:[0,1,2,3].map(to)}),s[0]=e):e=s[0],e}function to(s){return n.jsx(qn,{},s)}function no(){const s=M.c(1);let e;return s[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsxs("div",{className:Ze,children:[n.jsx(Xe,{}),n.jsx(eo,{})]}),s[0]=e):e=s[0],e}function oo(s){const e=M.c(18),{onRetry:t}=s,o=re();let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx(Xe,{}),e[0]=c):c=e[0];let l;e[1]!==o?(l=o("routes.commerceOnboarding.companionSection.loadError"),e[1]=o,e[2]=l):l=e[2];let u;e[3]!==l?(u=n.jsx("p",{className:"text-sm text-foreground",children:l}),e[3]=l,e[4]=u):u=e[4];let d;e[5]!==o?(d=o("routes.commerceOnboarding.companionSection.loadErrorDescription"),e[5]=o,e[6]=d):d=e[6];let a;e[7]!==d?(a=n.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:d}),e[7]=d,e[8]=a):a=e[8];let p;e[9]!==o?(p=o("routes.commerceOnboarding.companionSection.retry"),e[9]=o,e[10]=p):p=e[10];let i;e[11]!==t||e[12]!==p?(i=n.jsx(X,{type:"button",variant:"outline",size:"sm",className:"mt-3",onClick:t,children:p}),e[11]=t,e[12]=p,e[13]=i):i=e[13];let r;return e[14]!==u||e[15]!==a||e[16]!==i?(r=n.jsxs("div",{className:Ze,children:[c,n.jsxs("div",{role:"alert",className:"rounded-2xl border border-border bg-card p-4",children:[u,a,i]})]}),e[14]=u,e[15]=a,e[16]=i,e[17]=r):r=e[17],r}function Lo(s){const e=M.c(2);let t;return e[0]!==s?(t=n.jsx(kt,{children:o=>{const{reset:c}=o;return n.jsx(Ft,{fallback:l=>{const{resetError:u}=l;return n.jsx(oo,{onRetry:()=>{c(),u()}})},children:n.jsx(V.Suspense,{fallback:n.jsx(no,{}),children:n.jsx(so,{...s})})})}}),e[0]=s,e[1]=t):t=e[1],t}function so(s){const e=M.c(53),{org:t,cdConnectionId:o,siteUrl:c,onReadinessChange:l}=s,{data:u}=Rt.useSession(),d=u?.user?.id??"";let a;if(e[0]!==c){const K=c?Fe(c):null;if(K?.ok)try{a=new URL(K.value).hostname}catch{a=void 0}e[0]=c,e[1]=a}else a=e[1];let p;e[2]!==t.id||e[3]!==t.slug?(p={connectionId:Pt,orgId:t.id,orgSlug:t.slug},e[2]=t.id,e[3]=t.slug,e[4]=p):p=e[4];const i=ze(p);let r;e[5]!==o||e[6]!==t||e[7]!==i||e[8]!==c?(r={selfClient:i,org:t,cdConnectionId:o,siteUrl:c},e[5]=o,e[6]=t,e[7]=i,e[8]=c,e[9]=r):r=e[9];const{cards:g}=zn(r);let m;e[10]!==o||e[11]!==t||e[12]!==i||e[13]!==a||e[14]!==c||e[15]!==d?(m={selfClient:i,org:t,userId:d,cdConnectionId:o,domain:a,siteUrl:c},e[10]=o,e[11]=t,e[12]=i,e[13]=a,e[14]=c,e[15]=d,e[16]=m):m=e[16];const{connect:y,connectingFieldKey:j,disconnect:b,disconnectingFieldKey:x,error:f}=Jn(m),[S,h]=V.useState(null),L=ao;let T,C,v,w,I,A,F,_,O;if(e[17]!==S||e[18]!==g||e[19]!==y||e[20]!==f||e[21]!==j||e[22]!==b||e[23]!==x||e[24]!==l||e[25]!==t||e[26]!==i||e[27]!==c){v=Symbol.for("react.early_return_sentinel");e:{const K=g.filter(ro),U=g.filter(io),z=K.length>0?K.every(L):g.length===0||g.some(L);if(l?.(z),g.length===0){v=null;break e}const G=j!==null||x!==null,D=E=>{const k=async()=>{await y(E)&&h(E.fieldKey)};return n.jsx(Kn,{card:E,connecting:j===E.fieldKey,disconnecting:x===E.fieldKey,disabled:G&&j!==E.fieldKey&&x!==E.fieldKey,org:t,selfClient:i,siteUrl:c,autoOpenConfigFieldKey:S,onAutoOpenConfigHandled:()=>h(N=>N===E.fieldKey?null:N),onConnect:()=>{k()},onDisconnect:()=>{b(E)}},E.fieldKey)};O=Ze,e[37]===Symbol.for("react.memo_cache_sentinel")?(C=n.jsx(Xe,{}),e[37]=C):C=e[37],T=dn,A="flex min-h-0 flex-1 flex-col md:block",F="-mx-1 min-h-0 flex-1 overflow-y-auto px-1 md:max-h-[min(60vh,calc(100dvh-330px))] md:flex-none",e[38]!==f?(_=f&&n.jsx("p",{role:"alert",className:"mb-3 text-sm text-destructive",children:f}),e[38]=f,e[39]=_):_=e[39],w="flex flex-col gap-4 pt-3",I=[...K,...U].map(D)}e[17]=S,e[18]=g,e[19]=y,e[20]=f,e[21]=j,e[22]=b,e[23]=x,e[24]=l,e[25]=t,e[26]=i,e[27]=c,e[28]=T,e[29]=C,e[30]=v,e[31]=w,e[32]=I,e[33]=A,e[34]=F,e[35]=_,e[36]=O}else T=e[28],C=e[29],v=e[30],w=e[31],I=e[32],A=e[33],F=e[34],_=e[35],O=e[36];if(v!==Symbol.for("react.early_return_sentinel"))return v;let P;e[40]!==w||e[41]!==I?(P=n.jsx("div",{className:w,children:I}),e[40]=w,e[41]=I,e[42]=P):P=e[42];let R;e[43]!==T||e[44]!==P||e[45]!==A||e[46]!==F||e[47]!==_?(R=n.jsxs(T,{wrapperClassName:A,className:F,children:[_,P]}),e[43]=T,e[44]=P,e[45]=A,e[46]=F,e[47]=_,e[48]=R):R=e[48];let $;return e[49]!==C||e[50]!==R||e[51]!==O?($=n.jsxs("div",{className:O,children:[C,R]}),e[49]=C,e[50]=R,e[51]=O,e[52]=$):$=e[52],$}function io(s){return!s.required}function ro(s){return s.required}function ao(s){return s.satisfied&&s.configured}function lo(s){return s.content?.find(e=>e.text)?.text??"A configuração do Commerce Discovery falhou."}function ko(s){const e=s;if(e.isError)throw new Error(lo(e));return e.structuredContent??s}export{no as C,We as L,dn as S,Lo as a,wo as i,Fe as n,ko as p,Ao as s};
|
|
1
|
+
import{W as At,c as M,r as V,m as ce,j as n,b as re,k as Ue,B as X,o as Se,e as Re,K as Z,X as _e,Y as de,Z as Ne,_ as Oe,n as be,$ as Lt,t as ke,x as Ke,p as le,Q as kt,E as Ft,a as Rt}from"./index-DEjVUbQZ.js";import{W as mt,g as Dt,u as ze,S as Pt}from"./use-mcp-client-B--rl5yR.js";import{I as Ge}from"./integration-icon-Zd6y2lnO.js";import{c as Ce,b as ft,h as pt,a as gt,d as ht,e as xt}from"./dialog-DbxgvIzU.js";import{c as Be,T as Me,a as Ve}from"./tooltip-BZNMQNvf.js";import{m as bt,h as Ct,a as $t}from"./agent-icon-BGbirapc.js";import{u as ne,t as qt,m as Kt,s as at,g as Ut,p as zt,F as Gt,b as Bt,a as Mt,c as Vt}from"./companions-core-BUUkoH1J.js";import{i as yt}from"./CheckCircle-DiAhctKs.js";import{F as ue,a as Ie,b as me,c as Le,d as fe,e as pe,f as Qt}from"./form-DXHtZ3Xd.js";import{I as Ee}from"./input-BsFsRYpb.js";import{i as Ht}from"./Check-HrXMyT9G.js";import{a as vt}from"./Copy01-B9fZV42-.js";import{i as Wt}from"./Settings02-CmjWJ1c6.js";import{s as Yt}from"./Eye-BfiAoz0S.js";import{u as Zt}from"./use-debounced-value-BJf-6MsT.js";import{f as jt,a as Xt,p as Jt}from"./provision-repo-scoped-github-connection-Dp638N7g.js";import{c as en,e as tn}from"./extract-connection-data-BgqfCUzt.js";import{u as nn}from"./useQueries-B6CU5OfR.js";import{a as on}from"./authenticate-and-persist-oauth-C7W8HXB-.js";function sn(s,e){return nn({...s,queries:s.queries.map(t=>({...t,suspense:!0,throwOnError:At,enabled:!0,placeholderData:void 0}))},e)}const rn=/^[a-zA-Z][a-zA-Z\d+.-]*:/,an=/^[a-zA-Z][a-zA-Z\d+.-]*:\/\//,ln=/^[^\s/:?#]+\.[^\s/:?#]+:\d+(?:[/?#]|$)/,cn=/^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/i;function Fe(s){const e=s.trim();if(!e)return{ok:!1,error:"Enter a website URL."};const t=rn.test(e),o=an.test(e),c=ln.test(e);if(t&&!o&&!c)return{ok:!1,error:"Use an HTTP or HTTPS website URL."};const l=o?e:`https://${e}`;let u;try{u=new URL(l)}catch{return{ok:!1,error:"Enter a valid website URL."}}if(u.protocol!=="http:"&&u.protocol!=="https:")return{ok:!1,error:"Use an HTTP or HTTPS website URL."};const d=u.hostname.split(".");return d.length<2||d.some(a=>!a||!cn.test(a))?{ok:!1,error:"Enter a valid website URL."}:(u.protocol="https:",{ok:!0,value:u.origin})}function wo(s,e){if(!s.trim())return!0;const t=Fe(s);if(!t.ok||!e)return!1;const o=Fe(e);return o.ok&&o.value===t.value}function Ao(s){if(!s)return null;const e=Fe(s);return e.ok?new URL(e.value).hostname:null}function dn(s){const e=M.c(14),{children:t,className:o,wrapperClassName:c}=s,[l,u]=V.useState(!0);let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=j=>{if(!j)return;const b=()=>{const f=j.scrollHeight-j.scrollTop-j.clientHeight<8;u(f)};b(),j.addEventListener("scroll",b,{passive:!0});const x=new ResizeObserver(b);x.observe(j);for(const f of Array.from(j.children))x.observe(f);return()=>{j.removeEventListener("scroll",b),x.disconnect()}},e[0]=d):d=e[0];const a=d;let p;e[1]!==c?(p=ce("relative",c),e[1]=c,e[2]=p):p=e[2];let i;e[3]!==t||e[4]!==o?(i=n.jsx("div",{ref:a,className:o,children:t}),e[3]=t,e[4]=o,e[5]=i):i=e[5];const r=l?"opacity-0":"opacity-100";let g;e[6]!==r?(g=ce("pointer-events-none absolute inset-x-0 -bottom-px h-[72px]","bg-gradient-to-t from-sidebar from-[6px] to-transparent","backdrop-blur-[1px] [mask-image:linear-gradient(to_top,black_6px,transparent)]","transition-opacity duration-200",r),e[6]=r,e[7]=g):g=e[7];let m;e[8]!==g?(m=n.jsx("div",{"aria-hidden":!0,className:g}),e[8]=g,e[9]=m):m=e[9];let y;return e[10]!==p||e[11]!==i||e[12]!==m?(y=n.jsxs("div",{className:p,children:[i,m]}),e[10]=p,e[11]=i,e[12]=m,e[13]=y):y=e[13],y}function un(s){const e=M.c(25),{icon:t,title:o,headline:c,required:l,attention:u,action:d}=s,a=re(),p=u?"border-warning/50 bg-warning/[0.04]":"border-border";let i;e[0]!==p?(i=ce("relative flex items-center justify-between gap-3 rounded-lg border bg-card p-3.5 sm:gap-4 sm:p-4",p),e[0]=p,e[1]=i):i=e[1];let r;e[2]!==l||e[3]!==a?(r=l&&n.jsx("span",{className:"absolute -top-3 right-4 rounded-full border border-input bg-background px-3 py-1 text-xs font-medium text-foreground",children:a("commerceOnboarding.companionCard.required")}),e[2]=l,e[3]=a,e[4]=r):r=e[4];let g;e[5]!==t||e[6]!==o?(g=n.jsx(Ge,{icon:t,name:o,size:"sm",fit:"contain",className:"size-[30px] shrink-0 p-1"}),e[5]=t,e[6]=o,e[7]=g):g=e[7];let m;e[8]!==o?(m=n.jsx("span",{className:"text-sm font-medium text-foreground",children:o}),e[8]=o,e[9]=m):m=e[9];let y;e[10]!==c?(y=c&&n.jsx("p",{className:"hidden text-sm leading-5 text-muted-foreground sm:block",children:c}),e[10]=c,e[11]=y):y=e[11];let j;e[12]!==m||e[13]!==y?(j=n.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[m,y]}),e[12]=m,e[13]=y,e[14]=j):j=e[14];let b;e[15]!==g||e[16]!==j?(b=n.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3 sm:items-start",children:[g,j]}),e[15]=g,e[16]=j,e[17]=b):b=e[17];let x;e[18]!==d?(x=n.jsx("div",{className:"shrink-0",children:d}),e[18]=d,e[19]=x):x=e[19];let f;return e[20]!==i||e[21]!==r||e[22]!==b||e[23]!==x?(f=n.jsxs("div",{className:i,children:[r,b,x]}),e[20]=i,e[21]=r,e[22]=b,e[23]=x,e[24]=f):f=e[24],f}function St(s){const e=M.c(12),{connecting:t,disabled:o,title:c,primary:l,onConnect:u}=s,d=re(),a=l?"default":"outline",p=o||t;let i;e[0]!==d||e[1]!==c?(i=d("commerceOnboarding.companionCard.connectAriaLabel",{title:c}),e[0]=d,e[1]=c,e[2]=i):i=e[2];let r;e[3]!==t||e[4]!==d?(r=t?n.jsx(Ue,{size:16,className:"animate-spin"}):d("commerceOnboarding.companionCard.connect"),e[3]=t,e[4]=d,e[5]=r):r=e[5];let g;return e[6]!==u||e[7]!==a||e[8]!==p||e[9]!==i||e[10]!==r?(g=n.jsx(X,{type:"button",variant:a,size:"sm",disabled:p,onClick:u,"aria-label":i,children:r}),e[6]=u,e[7]=a,e[8]=p,e[9]=i,e[10]=r,e[11]=g):g=e[11],g}function mn(s){const e=M.c(11),{disabled:t,title:o,onConfigure:c}=s,l=re();let u;e[0]!==l||e[1]!==o?(u=l("commerceOnboarding.companionCard.configureAriaLabel",{title:o}),e[0]=l,e[1]=o,e[2]=u):u=e[2];let d;e[3]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx(bt,{size:16}),e[3]=d):d=e[3];let a;e[4]!==l?(a=l("commerceOnboarding.companionCard.finishSetup"),e[4]=l,e[5]=a):a=e[5];let p;return e[6]!==t||e[7]!==c||e[8]!==u||e[9]!==a?(p=n.jsxs(X,{type:"button",variant:"outline",size:"sm",className:"border-warning/60 text-warning hover:bg-warning/10 hover:text-warning",disabled:t,onClick:c,"aria-label":u,children:[d,a]}),e[6]=t,e[7]=c,e[8]=u,e[9]=a,e[10]=p):p=e[10],p}function _t(s){const e=M.c(9),{detail:t,controls:o}=s,c=re();let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=n.jsx(yt,{size:16,className:"text-success"}),e[0]=l):l=e[0];let u;e[1]!==t||e[2]!==c?(u=t?n.jsx("span",{className:"max-w-40 truncate text-foreground",children:t}):c("commerceOnboarding.companionCard.connected"),e[1]=t,e[2]=c,e[3]=u):u=e[3];let d;e[4]!==u?(d=n.jsxs("span",{className:"flex items-center gap-1.5 text-sm text-muted-foreground",children:[l," ",u]}),e[4]=u,e[5]=d):d=e[5];let a;return e[6]!==o||e[7]!==d?(a=n.jsxs("div",{className:"flex items-center gap-1",children:[d,o]}),e[6]=o,e[7]=d,e[8]=a):a=e[8],a}function Nt(s){const e=M.c(4),{ariaLabel:t,onClick:o}=s;let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx(bt,{size:16}),e[0]=c):c=e[0];let l;return e[1]!==t||e[2]!==o?(l=n.jsx(X,{type:"button",variant:"ghost",size:"icon-sm",className:"shrink-0",onClick:o,"aria-label":t,children:c}),e[1]=t,e[2]=o,e[3]=l):l=e[3],l}function lt(s){const e=M.c(38);let t,o,c,l,u;e[0]!==s?({value:u,onChange:o,placeholder:c,className:t,...l}=s,e[0]=s,e[1]=t,e[2]=o,e[3]=c,e[4]=l,e[5]=u):(t=e[1],o=e[2],c=e[3],l=e[4],u=e[5]);const[d,a]=V.useState(!1),[p,i]=V.useState(!1);let r;e[6]!==u?(r=async()=>{if(u)try{await navigator.clipboard.writeText(u),i(!0),setTimeout(()=>i(!1),2e3)}catch(A){console.error("Failed to copy text: ",A)}},e[6]=u,e[7]=r):r=e[7];const g=r;let m;e[8]!==d?(m=()=>{a(!d)},e[8]=d,e[9]=m):m=e[9];const y=m,j=d?"text":"password";let b;e[10]!==t?(b=ce("pr-20",t),e[10]=t,e[11]=b):b=e[11];let x;e[12]!==o||e[13]!==c||e[14]!==l||e[15]!==j||e[16]!==b||e[17]!==u?(x=n.jsx(Ee,{type:j,value:u,onChange:o,placeholder:c,className:b,...l}),e[12]=o,e[13]=c,e[14]=l,e[15]=j,e[16]=b,e[17]=u,e[18]=x):x=e[18];const f=d?"Hide password":"Show password";let S;e[19]!==d?(S=d?n.jsx(Wt,{size:16}):n.jsx(Yt,{size:16}),e[19]=d,e[20]=S):S=e[20];let h;e[21]!==f||e[22]!==S||e[23]!==y?(h=n.jsx(X,{type:"button",variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:y,title:f,children:S}),e[21]=f,e[22]=S,e[23]=y,e[24]=h):h=e[24];const L=!u,T=p?"Copied!":"Copy token";let C;e[25]!==p?(C=p?n.jsx(Ht,{size:16}):n.jsx(vt,{size:16}),e[25]=p,e[26]=C):C=e[26];let v;e[27]!==g||e[28]!==T||e[29]!==C||e[30]!==L?(v=n.jsx(X,{type:"button",variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:g,disabled:L,title:T,children:C}),e[27]=g,e[28]=T,e[29]=C,e[30]=L,e[31]=v):v=e[31];let w;e[32]!==v||e[33]!==h?(w=n.jsxs("div",{className:"absolute right-1 top-1 flex items-center gap-1 h-8",children:[h,v]}),e[32]=v,e[33]=h,e[34]=w):w=e[34];let I;return e[35]!==w||e[36]!==x?(I=n.jsxs("div",{className:"relative",children:[x,w]}),e[35]=w,e[36]=x,e[37]=I):I=e[37],I}function Qe(s){const e=M.c(19),{card:t,selfClient:o,org:c,onDone:l,onError:u}=s,d=Se();let a;e[0]!==t||e[1]!==o?(a=async b=>{const x={...t.configurationState??{},...b};await o.callTool({name:"COLLECTION_CONNECTIONS_UPDATE",arguments:{id:t.linkedConnectionId||t.candidateConnectionId,data:{configuration_state:x}}})},e[0]=t,e[1]=o,e[2]=a):a=e[2];let p;e[3]!==l||e[4]!==c||e[5]!==d?(p=async()=>{await d.invalidateQueries({queryKey:Z.commerceDiscoveryCompanionConnectionsPrefix(c.id)}),l()},e[3]=l,e[4]=c,e[5]=d,e[6]=p):p=e[6];let i;e[7]!==u?(i=b=>{u?.(b)},e[7]=u,e[8]=i):i=e[8];let r;e[9]!==a||e[10]!==p||e[11]!==i?(r={mutationFn:a,onSuccess:p,onError:i},e[9]=a,e[10]=p,e[11]=i,e[12]=r):r=e[12];const g=Re(r);let m;e[13]!==g?(m=b=>g.mutate(b),e[13]=g,e[14]=m):m=e[14];const y=m;let j;return e[15]!==g.error||e[16]!==g.isPending||e[17]!==y?(j={save:y,isPending:g.isPending,error:g.error},e[15]=g.error,e[16]=g.isPending,e[17]=y,e[18]=j):j=e[18],j}const fn=_e({accountName:de().min(1,"Informe o nome da conta"),appKey:de().optional(),appToken:de().optional()});function pn(s){const e=M.c(73),{card:t,selfClient:o,org:c,onDone:l,onIsPendingChange:u}=s,d=re();let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=Ne(fn),e[0]=a):a=e[0];const p=t.configurationState?.accountName||"",i=t.configurationState?.appKey||"",r=t.configurationState?.appToken||"";let g;e[1]!==p||e[2]!==i||e[3]!==r?(g={resolver:a,defaultValues:{accountName:p,appKey:i,appToken:r}},e[1]=p,e[2]=i,e[3]=r,e[4]=g):g=e[4];const m=Oe(g);let y;e[5]!==t.configurationState?.accountName||e[6]!==t.configurationState?.appKey||e[7]!==t.configurationState?.appToken||e[8]!==m?(y=()=>{m.reset({accountName:t.configurationState?.accountName||"",appKey:t.configurationState?.appKey||"",appToken:t.configurationState?.appToken||""})},e[5]=t.configurationState?.accountName,e[6]=t.configurationState?.appKey,e[7]=t.configurationState?.appToken,e[8]=m,e[9]=y):y=e[9];let j;e[10]!==t.configurationState||e[11]!==m?(j=[t.configurationState,m],e[10]=t.configurationState,e[11]=m,e[12]=j):j=e[12],V.useEffect(y,j);let b;e[13]!==t||e[14]!==l||e[15]!==c||e[16]!==o?(b={card:t,selfClient:o,org:c,onDone:l},e[13]=t,e[14]=l,e[15]=c,e[16]=o,e[17]=b):b=e[17];const{save:x,isPending:f,error:S}=Qe(b);let h,L;e[18]!==f||e[19]!==u?(L=()=>{u?.(f)},h=[f,u],e[18]=f,e[19]=u,e[20]=h,e[21]=L):(h=e[20],L=e[21]),V.useEffect(L,h);let T;if(e[22]!==m||e[23]!==x){let D;e[25]!==x?(D=async E=>{x(E)},e[25]=x,e[26]=D):D=e[26],T=m.handleSubmit(D),e[22]=m,e[23]=x,e[24]=T}else T=e[24];const C=T;let v;e[27]!==f||e[28]!==d?(v=D=>{const{field:E}=D;return n.jsxs(me,{children:[n.jsx(Le,{children:d("commerceOnboarding.vtexConfigForm.accountNameLabel")}),n.jsx(fe,{children:n.jsx(Ee,{placeholder:d("commerceOnboarding.vtexConfigForm.accountNamePlaceholder"),...E,disabled:f})}),n.jsx(pe,{})]})},e[27]=f,e[28]=d,e[29]=v):v=e[29];let w;e[30]!==m.control||e[31]!==v?(w=n.jsx(ue,{control:m.control,name:"accountName",render:v}),e[30]=m.control,e[31]=v,e[32]=w):w=e[32];let I;e[33]!==f||e[34]!==d?(I=D=>{const{field:E}=D;return n.jsxs(me,{children:[n.jsx(Le,{children:d("commerceOnboarding.vtexConfigForm.appKeyLabel")}),n.jsx(fe,{children:n.jsx(lt,{placeholder:d("commerceOnboarding.vtexConfigForm.appKeyPlaceholder"),...E,disabled:f})}),n.jsx(pe,{})]})},e[33]=f,e[34]=d,e[35]=I):I=e[35];let A;e[36]!==m.control||e[37]!==I?(A=n.jsx(ue,{control:m.control,name:"appKey",render:I}),e[36]=m.control,e[37]=I,e[38]=A):A=e[38];let F;e[39]!==f||e[40]!==d?(F=D=>{const{field:E}=D;return n.jsxs(me,{children:[n.jsx(Le,{children:d("commerceOnboarding.vtexConfigForm.appTokenLabel")}),n.jsx(fe,{children:n.jsx(lt,{placeholder:d("commerceOnboarding.vtexConfigForm.appTokenPlaceholder"),...E,disabled:f})}),n.jsx(pe,{})]})},e[39]=f,e[40]=d,e[41]=F):F=e[41];let _;e[42]!==m.control||e[43]!==F?(_=n.jsx(ue,{control:m.control,name:"appToken",render:F}),e[42]=m.control,e[43]=F,e[44]=_):_=e[44];let O;e[45]!==m||e[46]!==w||e[47]!==A||e[48]!==_?(O=n.jsxs(Ie,{...m,children:[w,A,_]}),e[45]=m,e[46]=w,e[47]=A,e[48]=_,e[49]=O):O=e[49];let P;e[50]!==S||e[51]!==d?(P=S&&n.jsx("p",{role:"alert",className:"text-sm text-destructive",children:S instanceof Error?S.message:d("commerceOnboarding.vtexConfigForm.savingError")}),e[50]=S,e[51]=d,e[52]=P):P=e[52];let R;e[53]!==d?(R=d("commerceOnboarding.vtexConfigForm.cancelButton"),e[53]=d,e[54]=R):R=e[54];let $;e[55]!==f||e[56]!==l||e[57]!==R?($=n.jsx(X,{type:"button",variant:"outline",onClick:l,disabled:f,children:R}),e[55]=f,e[56]=l,e[57]=R,e[58]=$):$=e[58];let K;e[59]!==f||e[60]!==d?(K=d(f?"commerceOnboarding.vtexConfigForm.savingButton":"commerceOnboarding.vtexConfigForm.saveButton"),e[59]=f,e[60]=d,e[61]=K):K=e[61];let U;e[62]!==f||e[63]!==K?(U=n.jsx(X,{type:"submit",disabled:f,children:K}),e[62]=f,e[63]=K,e[64]=U):U=e[64];let z;e[65]!==$||e[66]!==U?(z=n.jsxs(Ce,{className:"pt-4",children:[$,U]}),e[65]=$,e[66]=U,e[67]=z):z=e[67];let G;return e[68]!==C||e[69]!==O||e[70]!==P||e[71]!==z?(G=n.jsxs("form",{onSubmit:C,className:"space-y-4",children:[O,P,z]}),e[68]=C,e[69]=O,e[70]=P,e[71]=z,e[72]=G):G=e[72],G}function He(s){const e=M.c(29),{options:t,value:o,onChange:c,disabled:l,ariaLabel:u,searchPlaceholder:d,hideSearch:a}=s,p=d===void 0?"Buscar...":d,i=a===void 0?!1:a,[r,g]=V.useState("");let m,y,j;if(e[0]!==t||e[1]!==r||e[2]!==o){const C=r.trim().toLowerCase();m=C?t.filter(v=>v.label.toLowerCase().includes(C)):t,y=m.map(gn),j=y.includes(o)?o:y[0]??"",e[0]=t,e[1]=r,e[2]=o,e[3]=m,e[4]=y,e[5]=j}else m=e[3],y=e[4],j=e[5];const b=j;let x;e[6]!==l||e[7]!==y||e[8]!==c?(x=function(v){if(l||!["ArrowDown","ArrowRight","ArrowUp","ArrowLeft","Home","End"].includes(v.key))return;v.preventDefault();const I=v.currentTarget.dataset.value,A=y.indexOf(I),F=y.length;if(F===0)return;let _;v.key==="ArrowDown"||v.key==="ArrowRight"?_=(A+1)%F:v.key==="ArrowUp"||v.key==="ArrowLeft"?_=(A-1+F)%F:v.key==="Home"?_=0:_=F-1;const O=y[_];c(O),v.currentTarget.closest('[role="radiogroup"]')?.querySelector(`[data-value="${CSS.escape(O)}"]`)?.focus()},e[6]=l,e[7]=y,e[8]=c,e[9]=x):x=e[9];const f=x;let S;e[10]!==u||e[11]!==l||e[12]!==i||e[13]!==r||e[14]!==p?(S=i?null:n.jsxs("div",{className:"relative",children:[n.jsx(Ct,{size:16,className:"pointer-events-none absolute left-2.5 top-1/2 -translate-y-1/2 text-muted-foreground"}),n.jsx(Ee,{type:"text",value:r,onChange:C=>g(C.target.value),disabled:l,placeholder:p,"aria-label":`Buscar ${u}`,className:"h-8 pl-8"})]}),e[10]=u,e[11]=l,e[12]=i,e[13]=r,e[14]=p,e[15]=S):S=e[15];let h;e[16]!==l||e[17]!==m||e[18]!==f||e[19]!==c||e[20]!==b||e[21]!==o?(h=m.length===0?n.jsx("div",{className:"px-2 py-2 text-sm text-muted-foreground",children:"Nenhum resultado"}):m.map(C=>{const v=C.value===o;return n.jsxs("button",{type:"button",role:"radio","aria-checked":v,disabled:l,"data-value":C.value,tabIndex:C.value===b?0:-1,onClick:()=>c(C.value),onKeyDown:f,className:ce("flex w-full items-center justify-between gap-2 rounded-sm px-2 py-2 text-left text-sm","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","disabled:pointer-events-none disabled:opacity-50",v?"bg-muted font-medium text-foreground":"text-foreground hover:bg-muted/50"),children:[n.jsx("span",{className:"truncate",children:C.label}),v?n.jsx(yt,{size:16,className:"shrink-0 text-primary"}):null]},C.value)}),e[16]=l,e[17]=m,e[18]=f,e[19]=c,e[20]=b,e[21]=o,e[22]=h):h=e[22];let L;e[23]!==u||e[24]!==h?(L=n.jsx("div",{role:"radiogroup","aria-label":u,className:"max-h-[280px] overflow-y-auto",children:h}),e[23]=u,e[24]=h,e[25]=L):L=e[25];let T;return e[26]!==S||e[27]!==L?(T=n.jsxs("div",{className:"space-y-2",children:[S,L]}),e[26]=S,e[27]=L,e[28]=T):T=e[28],T}function gn(s){return s.value}function We(s){const e=M.c(16),{label:t,iconSize:o,className:c,iconClassName:l,labelClassName:u}=s,d=o===void 0?14:o;let a;e[0]!==c?(a=ce("inline-flex items-center gap-2",c),e[0]=c,e[1]=a):a=e[1];let p;e[2]!==l?(p=ce("shrink-0 animate-spin",l),e[2]=l,e[3]=p):p=e[3];let i;e[4]!==d||e[5]!==p?(i=n.jsx(Ue,{size:d,className:p}),e[4]=d,e[5]=p,e[6]=i):i=e[6];let r;e[7]!==u?(r=ce("text-sm",u),e[7]=u,e[8]=r):r=e[8];let g;e[9]!==t||e[10]!==r?(g=n.jsx("span",{className:r,children:t}),e[9]=t,e[10]=r,e[11]=g):g=e[11];let m;return e[12]!==a||e[13]!==i||e[14]!==g?(m=n.jsxs("span",{className:a,children:[i,g]}),e[12]=a,e[13]=i,e[14]=g,e[15]=m):m=e[15],m}const hn=_e({propertyId:de().min(1,"Selecione uma propriedade")});function xn(s){const e=M.c(68),{card:t,connectionId:o,companionClient:c,selfClient:l,org:u,onDone:d,onDisconnect:a,onIsPendingChange:p}=s;let i;e[0]!==o||e[1]!==u.id?(i=Z.commerceDiscoveryCompanionGaProperties(u.id,o),e[0]=o,e[1]=u.id,e[2]=i):i=e[2];let r;e[3]!==c?(r=async()=>{const k=await c.callTool({name:"get-account-summaries",arguments:{}}),N=ne(k);return qt(N)},e[3]=c,e[4]=r):r=e[4];let g;e[5]!==i||e[6]!==r?(g={queryKey:i,queryFn:r},e[5]=i,e[6]=r,e[7]=g):g=e[7];const m=be(g);let y;e[8]===Symbol.for("react.memo_cache_sentinel")?(y=Ne(hn),e[8]=y):y=e[8];const j=t.configurationState?.propertyId||"";let b;e[9]!==j?(b={resolver:y,defaultValues:{propertyId:j}},e[9]=j,e[10]=b):b=e[10];const x=Oe(b);let f;e[11]!==t||e[12]!==d||e[13]!==u||e[14]!==l?(f={card:t,selfClient:l,org:u,onDone:d},e[11]=t,e[12]=d,e[13]=u,e[14]=l,e[15]=f):f=e[15];const{save:S,isPending:h,error:L}=Qe(f);let T,C;e[16]!==h||e[17]!==p?(T=()=>{p?.(h)},C=[h,p],e[16]=h,e[17]=p,e[18]=T,e[19]=C):(T=e[18],C=e[19]),V.useEffect(T,C);let v;if(e[20]!==x||e[21]!==S){let k;e[23]!==S?(k=async N=>{S(N)},e[23]=S,e[24]=k):k=e[24],v=x.handleSubmit(k),e[20]=x,e[21]=S,e[22]=v}else v=e[22];const w=v;if(m.isLoading){let k;return e[25]===Symbol.for("react.memo_cache_sentinel")?(k=n.jsx("div",{className:"flex min-h-[200px] items-center justify-center",children:n.jsx(We,{label:"Carregando propriedades..."})}),e[25]=k):k=e[25],k}if(m.isError){let k;return e[26]===Symbol.for("react.memo_cache_sentinel")?(k=n.jsx("div",{className:"space-y-4",children:n.jsx("p",{className:"text-sm text-destructive",children:"Não foi possível carregar as propriedades do Google Analytics."})}),e[26]=k):k=e[26],k}let I;e[27]!==m.data?(I=m.data||[],e[27]=m.data,e[28]=I):I=e[28];const A=I;if(A.flatMap(Cn).length===0){let k;e[29]===Symbol.for("react.memo_cache_sentinel")?(k=n.jsx("p",{className:"text-sm text-muted-foreground",children:"Nenhuma propriedade do Google Analytics foi encontrada. Conecte uma conta do Google Analytics com propriedades."}),e[29]=k):k=e[29];let N;e[30]!==a?(N=a?n.jsx("button",{type:"button",onClick:a,className:"text-xs text-muted-foreground underline underline-offset-2 hover:text-destructive",children:"Desconectar conta"}):n.jsx("span",{}),e[30]=a,e[31]=N):N=e[31];let B;e[32]!==d?(B=n.jsx(X,{type:"button",variant:"outline",onClick:d,children:"Fechar"}),e[32]=d,e[33]=B):B=e[33];let Q;return e[34]!==N||e[35]!==B?(Q=n.jsxs("div",{className:"space-y-4",children:[k,n.jsxs(Ce,{className:"flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[N,B]})]}),e[34]=N,e[35]=B,e[36]=Q):Q=e[36],Q}let _;e[37]!==h||e[38]!==A?(_=k=>{const{field:N}=k;return n.jsxs(me,{children:[n.jsx(fe,{children:n.jsx(He,{options:A.flatMap(bn),value:N.value,onChange:N.onChange,disabled:h,ariaLabel:"Propriedade do Google Analytics"})}),n.jsx(pe,{})]})},e[37]=h,e[38]=A,e[39]=_):_=e[39];let O;e[40]!==x.control||e[41]!==_?(O=n.jsx(ue,{control:x.control,name:"propertyId",render:_}),e[40]=x.control,e[41]=_,e[42]=O):O=e[42];let P;e[43]!==x||e[44]!==O?(P=n.jsx(Ie,{...x,children:O}),e[43]=x,e[44]=O,e[45]=P):P=e[45];let R;e[46]!==L?(R=L&&n.jsx("p",{role:"alert",className:"text-sm text-destructive",children:L instanceof Error?L.message:"Não foi possível salvar a configuração"}),e[46]=L,e[47]=R):R=e[47];let $;e[48]!==h||e[49]!==a?($=a?n.jsx("button",{type:"button",onClick:a,disabled:h,className:"text-xs text-muted-foreground underline underline-offset-2 hover:text-destructive disabled:opacity-50",children:"Desconectar conta"}):n.jsx("span",{}),e[48]=h,e[49]=a,e[50]=$):$=e[50];let K;e[51]!==h||e[52]!==d?(K=n.jsx(X,{type:"button",variant:"outline",onClick:d,disabled:h,children:"Cancelar"}),e[51]=h,e[52]=d,e[53]=K):K=e[53];const U=h?"Salvando...":"Salvar";let z;e[54]!==h||e[55]!==U?(z=n.jsx(X,{type:"submit",disabled:h,children:U}),e[54]=h,e[55]=U,e[56]=z):z=e[56];let G;e[57]!==K||e[58]!==z?(G=n.jsxs("div",{className:"flex gap-2",children:[K,z]}),e[57]=K,e[58]=z,e[59]=G):G=e[59];let D;e[60]!==$||e[61]!==G?(D=n.jsxs(Ce,{className:"flex-col gap-2 pt-4 sm:flex-row sm:items-center sm:justify-between",children:[$,G]}),e[60]=$,e[61]=G,e[62]=D):D=e[62];let E;return e[63]!==w||e[64]!==P||e[65]!==R||e[66]!==D?(E=n.jsxs("form",{onSubmit:w,className:"space-y-4",children:[P,R,D]}),e[63]=w,e[64]=P,e[65]=R,e[66]=D,e[67]=E):E=e[67],E}function bn(s){return s.options}function Cn(s){return s.options}const yn=_e({siteUrl:de().min(1,"Selecione um site")});function vn(s){const e=M.c(62),{card:t,connectionId:o,companionClient:c,selfClient:l,org:u,contextSiteUrl:d,onDone:a,onIsPendingChange:p}=s;let i;e[0]!==o||e[1]!==u.id?(i=Z.commerceDiscoveryCompanionGscSites(u.id,o),e[0]=o,e[1]=u.id,e[2]=i):i=e[2];let r;e[3]!==c?(r=async()=>{const N=await c.callTool({name:"list_sites",arguments:{}});return ne(N).sites||[]},e[3]=c,e[4]=r):r=e[4];let g;e[5]!==i||e[6]!==r?(g={queryKey:i,queryFn:r},e[5]=i,e[6]=r,e[7]=g):g=e[7];const m=be(g);let y;e[8]===Symbol.for("react.memo_cache_sentinel")?(y=Ne(yn),e[8]=y):y=e[8];const j=t.configurationState?.siteUrl||"";let b;e[9]!==j?(b={resolver:y,defaultValues:{siteUrl:j}},e[9]=j,e[10]=b):b=e[10];const x=Oe(b);let f;e[11]!==t||e[12]!==a||e[13]!==u||e[14]!==l?(f={card:t,selfClient:l,org:u,onDone:a},e[11]=t,e[12]=a,e[13]=u,e[14]=l,e[15]=f):f=e[15];const{save:S,isPending:h,error:L}=Qe(f),T=V.useRef(!1),C=t.configurationState?.siteUrl;let v,w;e[16]!==h||e[17]!==p?(v=()=>{p?.(h)},w=[h,p],e[16]=h,e[17]=p,e[18]=v,e[19]=w):(v=e[18],w=e[19]),V.useEffect(v,w);let I,A;e[20]!==d||e[21]!==x||e[22]!==C||e[23]!==m.data||e[24]!==m.isSuccess?(I=()=>{if(!(T.current||!m.isSuccess)){if(T.current=!0,C){x.getValues("siteUrl")!==C&&x.setValue("siteUrl",C);return}if(!x.getValues("siteUrl")){const N=Kt(d,m.data??[]);N&&x.setValue("siteUrl",N)}}},A=[m.isSuccess,m.data,C,d,x],e[20]=d,e[21]=x,e[22]=C,e[23]=m.data,e[24]=m.isSuccess,e[25]=I,e[26]=A):(I=e[25],A=e[26]),V.useEffect(I,A);let F;if(e[27]!==x||e[28]!==S){let N;e[30]!==S?(N=async B=>{S(B)},e[30]=S,e[31]=N):N=e[31],F=x.handleSubmit(N),e[27]=x,e[28]=S,e[29]=F}else F=e[29];const _=F;if(m.isLoading){let N;return e[32]===Symbol.for("react.memo_cache_sentinel")?(N=n.jsx("div",{className:"flex min-h-[200px] items-center justify-center",children:n.jsx(We,{label:"Carregando sites..."})}),e[32]=N):N=e[32],N}if(m.isError){let N;return e[33]===Symbol.for("react.memo_cache_sentinel")?(N=n.jsx("div",{className:"space-y-4",children:n.jsx("p",{className:"text-sm text-destructive",children:"Não foi possível carregar os sites do Google Search Console."})}),e[33]=N):N=e[33],N}let O;e[34]!==m.data?(O=m.data||[],e[34]=m.data,e[35]=O):O=e[35];const P=O;if(P.length===0){let N;return e[36]===Symbol.for("react.memo_cache_sentinel")?(N=n.jsx("div",{className:"space-y-4",children:n.jsx("p",{className:"text-sm text-muted-foreground",children:"Nenhum site verificado foi encontrado. Verifique um site no Google Search Console."})}),e[36]=N):N=e[36],N}let R;e[37]!==h||e[38]!==P?(R=N=>{const{field:B}=N;return n.jsxs(me,{children:[n.jsx(fe,{children:n.jsx(He,{options:P.map(jn),value:B.value,onChange:B.onChange,disabled:h,ariaLabel:"Site verificado"})}),n.jsx(pe,{})]})},e[37]=h,e[38]=P,e[39]=R):R=e[39];let $;e[40]!==x.control||e[41]!==R?($=n.jsx(ue,{control:x.control,name:"siteUrl",render:R}),e[40]=x.control,e[41]=R,e[42]=$):$=e[42];let K;e[43]!==x||e[44]!==$?(K=n.jsx(Ie,{...x,children:$}),e[43]=x,e[44]=$,e[45]=K):K=e[45];let U;e[46]!==L?(U=L&&n.jsx("p",{role:"alert",className:"text-sm text-destructive",children:L instanceof Error?L.message:"Não foi possível salvar a configuração"}),e[46]=L,e[47]=U):U=e[47];let z;e[48]!==h||e[49]!==a?(z=n.jsx(X,{type:"button",variant:"outline",onClick:a,disabled:h,children:"Cancelar"}),e[48]=h,e[49]=a,e[50]=z):z=e[50];const G=h?"Salvando...":"Salvar";let D;e[51]!==h||e[52]!==G?(D=n.jsx(X,{type:"submit",disabled:h,children:G}),e[51]=h,e[52]=G,e[53]=D):D=e[53];let E;e[54]!==z||e[55]!==D?(E=n.jsxs(Ce,{className:"pt-4",children:[z,D]}),e[54]=z,e[55]=D,e[56]=E):E=e[56];let k;return e[57]!==_||e[58]!==K||e[59]!==U||e[60]!==E?(k=n.jsxs("form",{onSubmit:_,className:"space-y-4",children:[K,U,E]}),e[57]=_,e[58]=K,e[59]=U,e[60]=E,e[61]=k):k=e[61],k}function jn(s){return{value:s.siteUrl,label:s.siteUrl}}function Sn(s){const[e,t]=s.split("/");return!e||!t?null:{owner:e,name:t}}function _n(s){const{existingRepo:e,owner:t,name:o}=s;return e?.connectionId&&e.owner.toLowerCase()===t.toLowerCase()&&e.name.toLowerCase()===o.toLowerCase()?{connectionId:e.connectionId,installationId:e.installationId}:null}function Nn(s){const{existingRepo:e,existingConnections:t,repoConnectionId:o}=s,c=e?.connectionId&&e.connectionId!==o?e.connectionId:void 0,l=[...t.filter(u=>u.connection_id!==o&&u.connection_id!==c),{connection_id:o,selected_tools:[]}];return{staleConnectionId:c,mergedConnections:l}}const On=_e({githubRepo:de().min(1,"commerceOnboarding.githubConfigForm.selectRepository")}),In=15e3,En=/^[\w.-]+\/[\w.-]+$/;async function Tn(s,e,t,o){const{installations:c}=await jt(s,t),l=o.trim(),u=await Promise.allSettled(c.map(async i=>{const r=i.type==="User"?"user":"org",g=l?`${r}:${i.login} ${l} in:name`:`${r}:${i.login}`,y=await e.callTool({name:"search_repositories",arguments:{query:g,page:1,perPage:50}},void 0,{signal:AbortSignal.timeout(In)}),j=y.content?.[0]?.text;if(y.isError)throw new Error(j??"search_repositories failed");if(!j)throw new Error("empty search_repositories response");return JSON.parse(j).items??[]})),d=new Map;let a=0;for(const i of u){if(i.status==="rejected"){a+=1;continue}for(const r of i.value)r.full_name&&!d.has(r.full_name)&&d.set(r.full_name,r)}return{repos:Array.from(d.values()).sort((i,r)=>(r.updated_at??"").localeCompare(i.updated_at??"")).map(i=>i.full_name),failed:a,total:c.length}}function wn(s){const e=M.c(109),{connectionId:t,companionClient:o,selfClient:c,org:l,onDone:u,onIsPendingChange:d}=s,a=re(),p=Se();let i;e[0]!==l.id?(i=mt.COMMERCE_DISCOVERY(l.id),e[0]=l.id,e[1]=i):i=e[1];const r=i,[g,m]=V.useState(""),y=Zt(g,300),j=V.useRef(!1);let b;e[2]!==t||e[3]!==l.id?(b=Z.commerceDiscoveryCompanionGithubSelected(l.id,t),e[2]=t,e[3]=l.id,e[4]=b):b=e[4];let x;e[5]!==r||e[6]!==c?(x=async()=>{const Y=await c.callTool({name:"COLLECTION_CONNECTIONS_GET",arguments:{id:r}}),se=ne(Y).item?.configuration_state??null;return typeof se?.github_repo=="string"?se.github_repo:""},e[5]=r,e[6]=c,e[7]=x):x=e[7];let f;e[8]!==b||e[9]!==x?(f={queryKey:b,queryFn:x},e[8]=b,e[9]=x,e[10]=f):f=e[10];const S=be(f);let h;e[11]!==t||e[12]!==y||e[13]!==l.id?(h=Z.commerceDiscoveryCompanionGithubRepos(l.id,t,y.trim()),e[11]=t,e[12]=y,e[13]=l.id,e[14]=h):h=e[14];let L;e[15]!==o||e[16]!==t||e[17]!==y||e[18]!==c?(L=()=>Tn(Y=>c.callTool(Y),o,t,y),e[15]=o,e[16]=t,e[17]=y,e[18]=c,e[19]=L):L=e[19];let T;e[20]!==h||e[21]!==L?(T={queryKey:h,queryFn:L},e[20]=h,e[21]=L,e[22]=T):T=e[22];const C=be(T);let v;e[23]===Symbol.for("react.memo_cache_sentinel")?(v={resolver:Ne(On),defaultValues:{githubRepo:""}},e[23]=v):v=e[23];const w=Oe(v);let I;e[24]!==r||e[25]!==o||e[26]!==t||e[27]!==l.id||e[28]!==l.slug||e[29]!==c||e[30]!==a?(I=async Y=>{const se=await c.callTool({name:"COLLECTION_CONNECTIONS_GET",arguments:{id:r}}),Et={...ne(se).item?.configuration_state??null??{},github_repo:Y};await c.callTool({name:"COLLECTION_CONNECTIONS_UPDATE",arguments:{id:r,data:{configuration_state:Et}}});const Je=Sn(Y);if(!Je)throw new Error(a("commerceOnboarding.githubConfigForm.invalidRepository",{repo:Y}));const{owner:ve,name:De}=Je,et=Dt(l.id),tt=ne(await c.callTool({name:"COLLECTION_VIRTUAL_MCP_GET",arguments:{id:et}})).item,nt=tt?.metadata?.githubRepo,Tt=tt?.connections??[],ot=_n({existingRepo:nt,owner:ve,name:De});let we=ot?.connectionId,Pe=ot?.installationId,$e;if(!we){const{installations:qe}=await jt(je=>c.callTool(je),t),Ae=Xt(qe,ve);if(!Ae)throw new Error(a("commerceOnboarding.githubConfigForm.noGithubInstallation",{owner:ve}));Pe=Ae.installationId;const it=ne(await c.callTool({name:"COLLECTION_CONNECTIONS_GET",arguments:{id:t}})).item;if(!it)throw new Error(a("commerceOnboarding.githubConfigForm.githubConnectionNotFound"));const{childConnectionId:rt}=await Jt({orgSlug:l.slug,sourceConnection:it,installationId:Pe,owner:ve,repo:De,githubCallTool:je=>o.callTool(je),selfCallTool:je=>c.callTool(je)});we=rt,$e=rt}const{staleConnectionId:st,mergedConnections:wt}=Nn({existingRepo:nt,existingConnections:Tt,repoConnectionId:we});try{await c.callTool({name:"COLLECTION_VIRTUAL_MCP_UPDATE",arguments:{id:et,data:{connections:wt,metadata:{githubRepo:{owner:ve,name:De,url:`https://github.com/${Y}`,installationId:Pe,connectionId:we}}}}}),st&&await c.callTool({name:"COLLECTION_CONNECTIONS_DELETE",arguments:{id:st,force:!0}}).catch(kn)}catch(qe){const Ae=qe;throw $e&&await c.callTool({name:"COLLECTION_CONNECTIONS_DELETE",arguments:{id:$e,force:!0}}).catch(Ln),Ae}},e[24]=r,e[25]=o,e[26]=t,e[27]=l.id,e[28]=l.slug,e[29]=c,e[30]=a,e[31]=I):I=e[31];let A;e[32]!==r||e[33]!==u||e[34]!==l.id||e[35]!==p?(A=async()=>{await p.invalidateQueries({queryKey:Z.commerceDiscoveryConnection(l.id,r)}),await p.invalidateQueries({queryKey:Z.commerceDiscoveryCompanionConnectionsPrefix(l.id)}),Lt(p,l.id),u()},e[32]=r,e[33]=u,e[34]=l.id,e[35]=p,e[36]=A):A=e[36];let F;e[37]!==A||e[38]!==I?(F={mutationFn:I,onSuccess:A},e[37]=A,e[38]=I,e[39]=F):F=e[39];const _=Re(F),O=_.isPending;let P,R;e[40]!==O||e[41]!==d?(P=()=>{d?.(O)},R=[O,d],e[40]=O,e[41]=d,e[42]=P,e[43]=R):(P=e[42],R=e[43]),V.useEffect(P,R);const $=S.data??"";let K,U;e[44]!==w||e[45]!==S.data||e[46]!==S.isSuccess?(K=()=>{!S.isSuccess||j.current||(j.current=!0,S.data&&w.setValue("githubRepo",S.data))},U=[S.isSuccess,S.data,w],e[44]=w,e[45]=S.data,e[46]=S.isSuccess,e[47]=K,e[48]=U):(K=e[47],U=e[48]),V.useEffect(K,U);let z;if(e[49]!==w||e[50]!==_){let Y;e[52]!==_?(Y=async se=>{_.mutate(se.githubRepo)},e[52]=_,e[53]=Y):Y=e[53],z=w.handleSubmit(Y),e[49]=w,e[50]=_,e[51]=z}else z=e[51];const G=z;let D,E,k;if(e[54]!==y||e[55]!==C.data?.failed||e[56]!==C.data?.repos||e[57]!==C.data?.total||e[58]!==$){const Y=C.data?.repos??[];D=C.data?.failed??0,k=C.data?.total??0;const se=y.trim();E=[...Y],se&&En.test(se)&&!E.includes(se)&&E.unshift(se),$&&!E.includes($)&&E.push($),e[54]=y,e[55]=C.data?.failed,e[56]=C.data?.repos,e[57]=C.data?.total,e[58]=$,e[59]=D,e[60]=E,e[61]=k}else D=e[59],E=e[60],k=e[61];const N=k>0&&D===k;let B;e[62]!==N||e[63]!==D||e[64]!==C.isError||e[65]!==a?(B=C.isError||N?a("commerceOnboarding.githubConfigForm.searchFailedTotal"):D>0?a("commerceOnboarding.githubConfigForm.searchFailedPartial"):null,e[62]=N,e[63]=D,e[64]=C.isError,e[65]=a,e[66]=B):B=e[66];const Q=B;let te;e[67]===Symbol.for("react.memo_cache_sentinel")?(te=n.jsx(Ct,{size:16,className:"pointer-events-none absolute left-2.5 top-1/2 -translate-y-1/2 text-muted-foreground"}),e[67]=te):te=e[67];let oe;e[68]===Symbol.for("react.memo_cache_sentinel")?(oe=Y=>m(Y.target.value),e[68]=oe):oe=e[68];let J;e[69]!==a?(J=a("commerceOnboarding.githubConfigForm.searchRepositoryPlaceholder"),e[69]=a,e[70]=J):J=e[70];let q;e[71]!==a?(q=a("commerceOnboarding.githubConfigForm.searchRepositoryLabel"),e[71]=a,e[72]=q):q=e[72];let H;e[73]!==O||e[74]!==g||e[75]!==J||e[76]!==q?(H=n.jsxs("div",{className:"relative",children:[te,n.jsx(Ee,{type:"text",value:g,onChange:oe,disabled:O,placeholder:J,"aria-label":q,className:"h-8 pl-8"})]}),e[73]=O,e[74]=g,e[75]=J,e[76]=q,e[77]=H):H=e[77];let ee;e[78]!==w||e[79]!==O||e[80]!==E||e[81]!==C.isLoading||e[82]!==Q||e[83]!==a?(ee=C.isLoading?n.jsx("div",{className:"flex min-h-[160px] items-center justify-center",children:n.jsx(We,{label:a("commerceOnboarding.githubConfigForm.loadingRepositories")})}):n.jsxs(n.Fragment,{children:[Q&&n.jsx("p",{role:"alert",className:"text-sm text-destructive",children:Q}),E.length===0?!Q&&n.jsx("p",{className:"text-sm text-muted-foreground",children:a("commerceOnboarding.githubConfigForm.noRepositoriesFound")}):n.jsx(Ie,{...w,children:n.jsx(ue,{control:w.control,name:"githubRepo",render:Y=>{const{field:se}=Y;return n.jsxs(me,{children:[n.jsx(fe,{children:n.jsx(He,{options:E.map(An),value:se.value,onChange:se.onChange,disabled:O,ariaLabel:"Repositório",hideSearch:!0})}),n.jsx(pe,{})]})}})})]}),e[78]=w,e[79]=O,e[80]=E,e[81]=C.isLoading,e[82]=Q,e[83]=a,e[84]=ee):ee=e[84];let ae;e[85]!==_.error||e[86]!==a?(ae=_.error&&n.jsx("p",{role:"alert",className:"text-sm text-destructive",children:_.error instanceof Error?_.error.message:a("commerceOnboarding.githubConfigForm.failedToSave")}),e[85]=_.error,e[86]=a,e[87]=ae):ae=e[87];let W;e[88]!==a?(W=a("commerceOnboarding.githubConfigForm.cancel"),e[88]=a,e[89]=W):W=e[89];let ie;e[90]!==O||e[91]!==u||e[92]!==W?(ie=n.jsx(X,{type:"button",variant:"outline",onClick:u,disabled:O,children:W}),e[90]=O,e[91]=u,e[92]=W,e[93]=ie):ie=e[93];let ge;e[94]!==O||e[95]!==a?(ge=a(O?"commerceOnboarding.githubConfigForm.saving":"commerceOnboarding.githubConfigForm.save"),e[94]=O,e[95]=a,e[96]=ge):ge=e[96];let he;e[97]!==O||e[98]!==ge?(he=n.jsx(X,{type:"submit",disabled:O,children:ge}),e[97]=O,e[98]=ge,e[99]=he):he=e[99];let xe;e[100]!==ie||e[101]!==he?(xe=n.jsxs(Ce,{className:"pt-4",children:[ie,he]}),e[100]=ie,e[101]=he,e[102]=xe):xe=e[102];let Te;return e[103]!==G||e[104]!==H||e[105]!==ee||e[106]!==ae||e[107]!==xe?(Te=n.jsxs("form",{onSubmit:G,className:"space-y-4",children:[H,ee,ae,xe]}),e[103]=G,e[104]=H,e[105]=ee,e[106]=ae,e[107]=xe,e[108]=Te):Te=e[108],Te}function An(s){return{value:s,label:s}}function Ln(){}function kn(){}const Fn={vtex:pn,"google-analytics":xn,"google-search-console":vn,github:wn},ye="deco-reader@decocms.iam.gserviceaccount.com",Ot={"google-analytics":"ga4","google-search-console":"gsc"},It={ga4:{label:"Google Analytics",resourceLabel:"ID da propriedade",resourcePlaceholder:"ex: 123456789",resourceHint:"No GA4: Admin → Detalhes da propriedade → ID da propriedade (só números).",connectSteps:["Abra o Google Analytics (GA4) da sua loja.","Vá em Admin → Acesso à propriedade (Gerenciamento de acesso).",`Clique em + → Adicionar usuários, cole ${ye} e conceda o papel Leitor.`,"Copie o ID da propriedade (Admin → Detalhes da propriedade) e cole abaixo."]},gsc:{label:"Google Search Console",resourceLabel:"Site / propriedade",resourcePlaceholder:"ex: sc-domain:sualoja.com.br",resourceHint:"Use o mesmo formato que aparece no Search Console: sc-domain:sualoja.com.br ou https://www.sualoja.com.br/.",connectSteps:["Abra o Google Search Console da sua loja.","Vá em Configurações → Usuários e permissões.",`Clique em Adicionar usuário, cole ${ye} e escolha permissão Completa.`,"Copie o endereço do site como aparece no seletor de propriedades e cole abaixo."]}};function Rn(s,e){const t=It[s].label;switch(e){case"no-access":return{title:`Ainda não conseguimos acessar este recurso no ${t}.`,steps:s==="ga4"?[`Confirme que ${ye} foi adicionado em Admin → Acesso à propriedade com o papel Leitor.`,"Confira se o ID da propriedade está correto (só números, sem o prefixo 'properties/').","A concessão de acesso pode levar alguns segundos — tente novamente."]:[`Confirme que ${ye} foi adicionado em Configurações → Usuários e permissões.`,"A permissão precisa ser Completa ou Restrita — 'Não verificado' não funciona.","Confira se o endereço do site está exatamente como aparece no Search Console."]};case"no-web-stream":return{title:"Esta propriedade do GA4 não tem um fluxo de dados da Web (site) configurado.",steps:["No GA4, vá em Admin → Fluxos de dados.","Clique em Adicionar fluxo → Web.","Informe a URL do site da sua loja e salve o fluxo.","Volte aqui e tente vincular de novo. (Propriedades só de app precisam de vínculo manual — fale com o suporte.)"]};case"no-match":return{title:"O recurso informado não corresponde ao domínio desta loja.",steps:s==="ga4"?["Verifique se digitou o ID da propriedade certa — provavelmente é de outro site.","No GA4, o site medido aparece em Admin → Fluxos de dados → (seu fluxo Web) → URL do stream."]:["Verifique se selecionou a propriedade do Search Console referente a esta loja.","O endereço precisa cobrir o mesmo domínio do diagnóstico."]};case"resource_already_bound":return{title:"Este recurso já está vinculado a outra loja.",steps:["Se este recurso é realmente desta loja, fale com o suporte para uma revisão manual.","Caso tenha digitado o id errado, confira e tente novamente."]};default:return{title:"Não foi possível verificar o acesso a este recurso.",steps:["Revise os passos de acesso acima e tente novamente.","Se persistir, fale com o suporte."]}}}function Dn(s){const e=M.c(95),{provider:t,siteUrl:o,selfClient:c,org:l,initialResourceId:u,onDone:d,onIsPendingChange:a,onOAuthInstead:p}=s,i=re(),r=It[t],g=Se(),[m,y]=V.useState(null);let j,b;if(e[0]!==r.resourceLabel||e[1]!==i){const W=_e({resourceId:de().trim().min(1,i("commerceOnboarding.saBindingForm.resourceIdRequired",{resourceLabel:r.resourceLabel.toLowerCase()}))});b=Oe,j=Ne(W),e[0]=r.resourceLabel,e[1]=i,e[2]=j,e[3]=b}else j=e[2],b=e[3];const x=u??"";let f;e[4]!==x?(f={resourceId:x},e[4]=x,e[5]=f):f=e[5];let S;e[6]!==j||e[7]!==f?(S={resolver:j,defaultValues:f},e[6]=j,e[7]=f,e[8]=S):S=e[8];const h=b(S);let L;e[9]!==t||e[10]!==c||e[11]!==o||e[12]!==i?(L=async W=>{if(!o)throw new Error(i("commerceOnboarding.saBindingForm.storeUrlUnavailable"));const ie=await c.callTool({name:"COMMERCE_DISCOVERY_BIND",arguments:{siteUrl:o,provider:t,resourceId:W.resourceId}});return ne(ie)},e[9]=t,e[10]=c,e[11]=o,e[12]=i,e[13]=L):L=e[13];let T,C;e[14]!==a?(T=()=>a?.(!0),C=()=>a?.(!1),e[14]=a,e[15]=T,e[16]=C):(T=e[15],C=e[16]);let v;e[17]!==r.label||e[18]!==d||e[19]!==l||e[20]!==t||e[21]!==g||e[22]!==o||e[23]!==i?(v=async W=>{if(W.ok){y(null),ke.success(i("commerceOnboarding.saBindingForm.connectedSuccess",{label:r.label})),o&&await g.invalidateQueries({queryKey:Z.commerceDiscoveryConnectionStatus(l.id,o)}),d();return}y({...Rn(t,W.reason??"unknown"),detail:W.detail})},e[17]=r.label,e[18]=d,e[19]=l,e[20]=t,e[21]=g,e[22]=o,e[23]=i,e[24]=v):v=e[24];let w;e[25]!==L||e[26]!==T||e[27]!==C||e[28]!==v?(w={mutationFn:L,onMutate:T,onSettled:C,onSuccess:v},e[25]=L,e[26]=T,e[27]=C,e[28]=v,e[29]=w):w=e[29];const I=Re(w);let A;if(e[30]!==h||e[31]!==I){let W;e[33]!==I?(W=ie=>I.mutate(ie),e[33]=I,e[34]=W):W=e[34],A=h.handleSubmit(W),e[30]=h,e[31]=I,e[32]=A}else A=e[32];const F=A,_=I.isPending;let O;e[35]!==i?(O=()=>{navigator.clipboard?.writeText(ye),ke.success(i("commerceOnboarding.saBindingForm.emailCopied"))},e[35]=i,e[36]=O):O=e[36];const P=O;let R;e[37]!==r.connectSteps?(R=r.connectSteps.map($n),e[37]=r.connectSteps,e[38]=R):R=e[38];let $;e[39]!==R?($=n.jsx("ol",{className:"space-y-2 text-sm text-muted-foreground",children:R}),e[39]=R,e[40]=$):$=e[40];let K;e[41]===Symbol.for("react.memo_cache_sentinel")?(K=n.jsx("code",{className:"min-w-0 flex-1 truncate text-xs text-foreground",children:ye}),e[41]=K):K=e[41];let U;e[42]!==i?(U=i("commerceOnboarding.saBindingForm.copyEmailLabel"),e[42]=i,e[43]=U):U=e[43];let z;e[44]===Symbol.for("react.memo_cache_sentinel")?(z=n.jsx(vt,{size:16}),e[44]=z):z=e[44];let G;e[45]!==P||e[46]!==U?(G=n.jsxs("div",{className:"flex items-center gap-2 rounded-lg border border-border bg-muted/40 p-2",children:[K,n.jsx(X,{type:"button",variant:"ghost",size:"icon-sm",onClick:P,"aria-label":U,children:z})]}),e[45]=P,e[46]=U,e[47]=G):G=e[47];let D;e[48]!==r.resourceHint||e[49]!==r.resourceLabel||e[50]!==r.resourcePlaceholder||e[51]!==_?(D=W=>{const{field:ie}=W;return n.jsxs(me,{children:[n.jsx(Le,{children:r.resourceLabel}),n.jsx(fe,{children:n.jsx(Ee,{...ie,placeholder:r.resourcePlaceholder,disabled:_,autoComplete:"off"})}),n.jsx(Qt,{children:r.resourceHint}),n.jsx(pe,{})]})},e[48]=r.resourceHint,e[49]=r.resourceLabel,e[50]=r.resourcePlaceholder,e[51]=_,e[52]=D):D=e[52];let E;e[53]!==h.control||e[54]!==D?(E=n.jsx(ue,{control:h.control,name:"resourceId",render:D}),e[53]=h.control,e[54]=D,e[55]=E):E=e[55];let k;e[56]!==h||e[57]!==E?(k=n.jsx(Ie,{...h,children:E}),e[56]=h,e[57]=E,e[58]=k):k=e[58];let N;e[59]!==m?(N=m&&n.jsxs("div",{role:"alert",className:"space-y-2 rounded-lg border border-destructive/40 bg-destructive/5 p-3",children:[n.jsx("p",{className:"text-sm font-medium text-foreground",children:m.title}),n.jsx("ol",{className:"space-y-1 text-sm text-muted-foreground",children:m.steps.map(Pn)})]}),e[59]=m,e[60]=N):N=e[60];let B;e[61]!==I.error||e[62]!==I.isError||e[63]!==i?(B=I.isError&&n.jsx("p",{role:"alert",className:"text-sm text-destructive",children:I.error instanceof Error?I.error.message:i("commerceOnboarding.saBindingForm.bindError")}),e[61]=I.error,e[62]=I.isError,e[63]=i,e[64]=B):B=e[64];let Q;e[65]!==_||e[66]!==p||e[67]!==i?(Q=p?n.jsx("button",{type:"button",onClick:p,disabled:_,className:"text-xs text-muted-foreground underline underline-offset-2 hover:text-foreground disabled:opacity-50",children:i("commerceOnboarding.saBindingForm.googleLoginAlternative")}):n.jsx("span",{}),e[65]=_,e[66]=p,e[67]=i,e[68]=Q):Q=e[68];let te;e[69]!==i?(te=i("commerceOnboarding.saBindingForm.cancel"),e[69]=i,e[70]=te):te=e[70];let oe;e[71]!==_||e[72]!==d||e[73]!==te?(oe=n.jsx(X,{type:"button",variant:"outline",onClick:d,disabled:_,children:te}),e[71]=_,e[72]=d,e[73]=te,e[74]=oe):oe=e[74];let J;e[75]!==_||e[76]!==i?(J=i(_?"commerceOnboarding.saBindingForm.verifying":"commerceOnboarding.saBindingForm.bind"),e[75]=_,e[76]=i,e[77]=J):J=e[77];let q;e[78]!==_||e[79]!==J?(q=n.jsx(X,{type:"submit",disabled:_,children:J}),e[78]=_,e[79]=J,e[80]=q):q=e[80];let H;e[81]!==oe||e[82]!==q?(H=n.jsxs("div",{className:"flex gap-2",children:[oe,q]}),e[81]=oe,e[82]=q,e[83]=H):H=e[83];let ee;e[84]!==Q||e[85]!==H?(ee=n.jsxs(Ce,{className:"flex-col gap-2 pt-2 sm:flex-row sm:items-center sm:justify-between",children:[Q,H]}),e[84]=Q,e[85]=H,e[86]=ee):ee=e[86];let ae;return e[87]!==F||e[88]!==$||e[89]!==G||e[90]!==k||e[91]!==N||e[92]!==B||e[93]!==ee?(ae=n.jsxs("form",{onSubmit:F,className:"space-y-4",children:[$,G,k,N,B,ee]}),e[87]=F,e[88]=$,e[89]=G,e[90]=k,e[91]=N,e[92]=B,e[93]=ee,e[94]=ae):ae=e[94],ae}function Pn(s){return n.jsxs("li",{className:"flex gap-2",children:[n.jsx("span",{"aria-hidden":!0,children:"•"}),n.jsx("span",{children:s})]},s)}function $n(s,e){return n.jsxs("li",{className:"flex gap-2",children:[n.jsx("span",{className:"flex size-5 shrink-0 items-center justify-center rounded-full bg-muted text-xs font-medium text-foreground",children:e+1}),n.jsx("span",{children:s})]},s)}function qn(){const s=M.c(2);let e;s[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx("div",{className:"size-9 shrink-0 animate-pulse rounded-lg bg-muted/60"}),s[0]=e):e=s[0];let t;return s[1]===Symbol.for("react.memo_cache_sentinel")?(t=n.jsxs("div",{className:"flex items-center gap-3 rounded-2xl border border-border bg-card p-3 sm:h-full sm:flex-col sm:items-stretch sm:p-4",children:[e,n.jsxs("div",{className:"min-w-0 flex-1 space-y-2",children:[n.jsx("div",{className:"h-4 w-24 animate-pulse rounded bg-muted/60"}),n.jsx("div",{className:"hidden h-3 w-full animate-pulse rounded bg-muted/60 sm:block"})]}),n.jsx("div",{className:"h-8 w-20 shrink-0 animate-pulse rounded-lg bg-muted/60 sm:mt-auto sm:w-full"})]}),s[1]=t):t=s[1],t}function ct(s){const e=M.c(17),{title:t,disconnecting:o,disabled:c,onDisconnect:l}=s,u=re(),d=c||o;let a;e[0]!==u||e[1]!==t?(a=u("commerceOnboarding.companionCard.disconnectAriaLabel",{title:t}),e[0]=u,e[1]=t,e[2]=a):a=e[2];let p;e[3]!==o?(p=o?n.jsx(Ue,{size:16,className:"animate-spin"}):n.jsx($t,{size:16}),e[3]=o,e[4]=p):p=e[4];let i;e[5]!==l||e[6]!==d||e[7]!==a||e[8]!==p?(i=n.jsx(Me,{asChild:!0,children:n.jsx(X,{type:"button",variant:"ghost",size:"icon-sm",className:"shrink-0 text-muted-foreground hover:text-destructive",disabled:d,onClick:l,"aria-label":a,children:p})}),e[5]=l,e[6]=d,e[7]=a,e[8]=p,e[9]=i):i=e[9];let r;e[10]!==u?(r=u("commerceOnboarding.companionCard.disconnect"),e[10]=u,e[11]=r):r=e[11];let g;e[12]!==r?(g=n.jsx(Ve,{children:r}),e[12]=r,e[13]=g):g=e[13];let m;return e[14]!==i||e[15]!==g?(m=n.jsxs(Be,{children:[i,g]}),e[14]=i,e[15]=g,e[16]=m):m=e[16],m}function Kn(s){const e=M.c(23),{card:t,connecting:o,disconnecting:c,disabled:l,onConnect:u,onDisconnect:d,org:a,selfClient:p,siteUrl:i,autoOpenConfigFieldKey:r,onAutoOpenConfigHandled:g}=s,m=t.linkedConnectionId,y=Ot[t.bindingType],j=!!y&&t.boundVia!=="oauth",b=t.satisfied&&!t.configured;let x;e[0]!==r||e[1]!==t||e[2]!==o||e[3]!==l||e[4]!==c||e[5]!==m||e[6]!==b||e[7]!==g||e[8]!==u||e[9]!==d||e[10]!==a||e[11]!==y||e[12]!==p||e[13]!==i||e[14]!==j?(x=j&&y?n.jsx(Un,{card:t,provider:y,org:a,selfClient:p,siteUrl:i,onOAuthInstead:u,disabled:l,connecting:o,primary:t.required}):t.satisfied&&m?b?n.jsxs("div",{className:"flex items-center justify-end gap-1 sm:justify-start",children:[n.jsx(V.Suspense,{fallback:n.jsx(dt,{}),children:n.jsx(ut,{card:t,org:a,selfClient:p,connectionId:m,contextSiteUrl:i,variant:"configure",disabled:l,autoOpen:at({autoOpenFieldKey:r,card:t}),onAutoOpenHandled:g})}),n.jsx(ct,{title:t.title,disconnecting:c,disabled:l,onDisconnect:d})]}):n.jsx(_t,{detail:t.connectedDetail,controls:n.jsxs(n.Fragment,{children:[n.jsx(V.Suspense,{fallback:n.jsx(dt,{}),children:n.jsx(ut,{card:t,org:a,selfClient:p,connectionId:m,contextSiteUrl:i,variant:"gear",disabled:l,autoOpen:at({autoOpenFieldKey:r,card:t}),onAutoOpenHandled:g})}),n.jsx(ct,{title:t.title,disconnecting:c,disabled:l,onDisconnect:d})]})}):n.jsx(St,{connecting:o,disabled:l,title:t.title,primary:t.required,onConnect:u}),e[0]=r,e[1]=t,e[2]=o,e[3]=l,e[4]=c,e[5]=m,e[6]=b,e[7]=g,e[8]=u,e[9]=d,e[10]=a,e[11]=y,e[12]=p,e[13]=i,e[14]=j,e[15]=x):x=e[15];const f=x,S=t.required&&!t.satisfied;let h;return e[16]!==f||e[17]!==t.headline||e[18]!==t.icon||e[19]!==t.title||e[20]!==b||e[21]!==S?(h=n.jsx(un,{icon:t.icon,title:t.title,headline:t.headline,required:S,attention:b,action:f}),e[16]=f,e[17]=t.headline,e[18]=t.icon,e[19]=t.title,e[20]=b,e[21]=S,e[22]=h):h=e[22],h}function Un(s){const e=M.c(46),{card:t,provider:o,org:c,selfClient:l,siteUrl:u,onOAuthInstead:d,disabled:a,connecting:p,primary:i}=s,r=re(),[g,m]=V.useState(!1),[y,j]=V.useState(!1);let b;e[0]!==y?(b=R=>{!R&&y||m(R)},e[0]=y,e[1]=b):b=e[1];const x=b;let f;e[2]!==t.connectedDetail||e[3]!==t.satisfied||e[4]!==t.title||e[5]!==p||e[6]!==a||e[7]!==i||e[8]!==r?(f=t.satisfied?n.jsx(_t,{detail:t.connectedDetail,controls:n.jsxs(Be,{children:[n.jsx(Me,{asChild:!0,children:n.jsx(Nt,{ariaLabel:r("commerceOnboarding.companionCard.configureAriaLabel",{title:t.title}),onClick:()=>m(!0)})}),n.jsx(Ve,{children:r("commerceOnboarding.companionCard.editConfiguration")})]})}):n.jsx(St,{connecting:p,disabled:a,title:t.title,primary:i,onConnect:()=>m(!0)}),e[2]=t.connectedDetail,e[3]=t.satisfied,e[4]=t.title,e[5]=p,e[6]=a,e[7]=i,e[8]=r,e[9]=f):f=e[9];let S;e[10]!==t.icon||e[11]!==t.title?(S=n.jsx(Ge,{icon:t.icon,name:t.title,size:"md",fit:"contain",className:"p-1.5"}),e[10]=t.icon,e[11]=t.title,e[12]=S):S=e[12];let h;e[13]!==t.title?(h=n.jsx(ft,{children:t.title}),e[13]=t.title,e[14]=h):h=e[14];let L;e[15]!==r?(L=r("commerceOnboarding.companionCard.grantAccessDescription"),e[15]=r,e[16]=L):L=e[16];let T;e[17]!==L?(T=n.jsx(pt,{children:L}),e[17]=L,e[18]=T):T=e[18];let C;e[19]!==h||e[20]!==T?(C=n.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:[h,T]}),e[19]=h,e[20]=T,e[21]=C):C=e[21];let v;e[22]!==S||e[23]!==C?(v=n.jsxs(gt,{className:"flex-row items-center gap-3 space-y-0 text-left",children:[S,C]}),e[22]=S,e[23]=C,e[24]=v):v=e[24];const w=t.boundResource??void 0;let I;e[25]===Symbol.for("react.memo_cache_sentinel")?(I=()=>m(!1),e[25]=I):I=e[25];let A;e[26]!==t.satisfied||e[27]!==d?(A=t.satisfied?void 0:()=>{m(!1),d()},e[26]=t.satisfied,e[27]=d,e[28]=A):A=e[28];let F;e[29]!==c||e[30]!==o||e[31]!==l||e[32]!==u||e[33]!==A||e[34]!==w?(F=n.jsx(Dn,{provider:o,siteUrl:u,selfClient:l,org:c,initialResourceId:w,onDone:I,onIsPendingChange:j,onOAuthInstead:A}),e[29]=c,e[30]=o,e[31]=l,e[32]=u,e[33]=A,e[34]=w,e[35]=F):F=e[35];let _;e[36]!==F||e[37]!==v?(_=n.jsxs(ht,{className:"sm:max-w-lg",children:[v,F]}),e[36]=F,e[37]=v,e[38]=_):_=e[38];let O;e[39]!==x||e[40]!==g||e[41]!==_?(O=n.jsx(xt,{open:g,onOpenChange:x,children:_}),e[39]=x,e[40]=g,e[41]=_,e[42]=O):O=e[42];let P;return e[43]!==O||e[44]!==f?(P=n.jsxs(n.Fragment,{children:[f,O]}),e[43]=O,e[44]=f,e[45]=P):P=e[45],P}function dt(){const s=M.c(1);let e;return s[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx("div",{className:"size-8 shrink-0 animate-pulse rounded-lg bg-muted/60"}),s[0]=e):e=s[0],e}function ut(s){const e=M.c(71),{card:t,org:o,selfClient:c,connectionId:l,contextSiteUrl:u,variant:d,disabled:a,autoOpen:p,onAutoOpenHandled:i}=s,r=re();let g;e[0]!==l||e[1]!==o.id||e[2]!==o.slug?(g={connectionId:l,orgId:o.id,orgSlug:o.slug},e[0]=l,e[1]=o.id,e[2]=o.slug,e[3]=g):g=e[3];const m=ze(g),[y,j]=V.useState(p),[b,x]=V.useState(!1),f=Se(),S=Fn[t.bindingType];let h;e[4]!==t.configurationState?(h=Ut(t.configurationState),e[4]=t.configurationState,e[5]=h):h=e[5];const L=h;let T;e[6]!==p||e[7]!==i?(T=()=>{j(!1),p&&i()},e[6]=p,e[7]=i,e[8]=T):T=e[8];const C=T;let v;e[9]!==C||e[10]!==b?(v=te=>{if(!(!te&&b)){if(!te){C();return}j(!0)}},e[9]=C,e[10]=b,e[11]=v):v=e[11];const w=v;let I;e[12]!==l||e[13]!==c?(I=async()=>{await c.callTool({name:"COLLECTION_CONNECTIONS_DELETE",arguments:{id:l,force:!0}})},e[12]=l,e[13]=c,e[14]=I):I=e[14];let A;e[15]!==t.title||e[16]!==C||e[17]!==o.id||e[18]!==f||e[19]!==r?(A=async()=>{await f.invalidateQueries({queryKey:Z.commerceDiscoveryCompanionConnectionsPrefix(o.id)}),ke.success(r("commerceOnboarding.companionCard.disconnectedSuccess",{title:t.title})),C()},e[15]=t.title,e[16]=C,e[17]=o.id,e[18]=f,e[19]=r,e[20]=A):A=e[20];let F;e[21]!==r?(F=()=>{ke.error(r("commerceOnboarding.companionCard.disconnectError"))},e[21]=r,e[22]=F):F=e[22];let _;e[23]!==I||e[24]!==A||e[25]!==F?(_={mutationFn:I,onSuccess:A,onError:F},e[23]=I,e[24]=A,e[25]=F,e[26]=_):_=e[26];const O=Re(_);if(!S)return null;let P;e[27]!==t.title||e[28]!==a||e[29]!==L||e[30]!==r||e[31]!==d?(P=d==="configure"?n.jsx(mn,{disabled:a,title:t.title,onConfigure:()=>j(!0)}):n.jsxs(Be,{children:[n.jsx(Me,{asChild:!0,children:n.jsx(Nt,{ariaLabel:r("commerceOnboarding.companionCard.configureAriaLabel",{title:t.title}),onClick:()=>j(!0)})}),n.jsx(Ve,{children:L.length>0?r("commerceOnboarding.companionCard.editConfiguration"):r("commerceOnboarding.companionCard.configure")})]}),e[27]=t.title,e[28]=a,e[29]=L,e[30]=r,e[31]=d,e[32]=P):P=e[32];const R=P;let $;e[33]!==t.icon||e[34]!==t.title?($=n.jsx(Ge,{icon:t.icon,name:t.title,size:"md",fit:"contain",className:"p-1.5"}),e[33]=t.icon,e[34]=t.title,e[35]=$):$=e[35];let K;e[36]!==t.title?(K=n.jsx(ft,{children:t.title}),e[36]=t.title,e[37]=K):K=e[37];let U;e[38]!==t.title||e[39]!==r?(U=r("commerceOnboarding.companionCard.configureDescription",{title:t.title}),e[38]=t.title,e[39]=r,e[40]=U):U=e[40];let z;e[41]!==U?(z=n.jsx(pt,{children:U}),e[41]=U,e[42]=z):z=e[42];let G;e[43]!==K||e[44]!==z?(G=n.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:[K,z]}),e[43]=K,e[44]=z,e[45]=G):G=e[45];let D;e[46]!==$||e[47]!==G?(D=n.jsxs(gt,{className:"flex-row items-center gap-3 space-y-0 text-left",children:[$,G]}),e[46]=$,e[47]=G,e[48]=D):D=e[48];let E;e[49]!==O?(E=()=>O.mutate(),e[49]=O,e[50]=E):E=e[50];let k;e[51]!==S||e[52]!==t||e[53]!==C||e[54]!==m||e[55]!==l||e[56]!==u||e[57]!==o||e[58]!==c||e[59]!==E?(k=n.jsx(S,{card:t,connectionId:l,companionClient:m,selfClient:c,org:o,contextSiteUrl:u,onDone:C,onDisconnect:E,onIsPendingChange:x}),e[51]=S,e[52]=t,e[53]=C,e[54]=m,e[55]=l,e[56]=u,e[57]=o,e[58]=c,e[59]=E,e[60]=k):k=e[60];let N;e[61]!==D||e[62]!==k?(N=n.jsxs(ht,{className:"sm:max-w-lg",children:[D,k]}),e[61]=D,e[62]=k,e[63]=N):N=e[63];let B;e[64]!==y||e[65]!==w||e[66]!==N?(B=n.jsx(xt,{open:y,onOpenChange:w,children:N}),e[64]=y,e[65]=w,e[66]=N,e[67]=B):B=e[67];let Q;return e[68]!==B||e[69]!==R?(Q=n.jsxs(n.Fragment,{children:[R,B]}),e[68]=B,e[69]=R,e[70]=Q):Q=e[70],Q}const Ye={vtex:{registryAppId:"deco/vtex",area:"Catálogo",headline:"Rupturas e PDPs que travam suas vendas."},"google-analytics":{registryAppId:"deco/google-analytics",area:"Funil",headline:"Onde a receita vaza no seu funil."},"google-search-console":{registryAppId:"deco/google-search-console",area:"Busca",headline:"O tráfego de busca que você deixa na mesa."},github:{registryAppId:"deco/mcp-github",area:"Engenharia",headline:"A saúde da entrega de código por trás da sua loja."}};function zn(s){const e=M.c(40),{selfClient:t,org:o,cdConnectionId:c,siteUrl:l}=s;let u;e[0]!==c||e[1]!==o.id||e[2]!==o.slug?(u={connectionId:c,orgId:o.id,orgSlug:o.slug},e[0]=c,e[1]=o.id,e[2]=o.slug,e[3]=u):u=e[3];const d=ze(u);let a;e[4]!==c||e[5]!==o.id?(a=Z.commerceDiscoveryCompanionSchema(o.id,c),e[4]=c,e[5]=o.id,e[6]=a):a=e[6];let p;e[7]!==d?(p=async()=>{const q=await d.callTool({name:"MCP_CONFIGURATION",arguments:{}});return ne(q)},e[7]=d,e[8]=p):p=e[8];let i;e[9]!==a||e[10]!==p?(i={queryKey:a,queryFn:p,retry:!1},e[9]=a,e[10]=p,e[11]=i):i=e[11];const r=be(i),g=r.data?.stateSchema?zt(r.data.stateSchema):null,m=g&&g.length>0?g:Gt,y=m.map(Xn),j=m.map(Zn).filter(Yn),b=m.filter(Wn).map(Hn),x=[...j,...b].sort().join(",");let f;e[12]!==c||e[13]!==o.id?(f=Z.commerceDiscoveryConnection(o.id,c),e[12]=c,e[13]=o.id,e[14]=f):f=e[14];let S;e[15]!==c||e[16]!==t?(S=async()=>{const q=await t.callTool({name:"COLLECTION_CONNECTIONS_GET",arguments:{id:c}});return ne(q)},e[15]=c,e[16]=t,e[17]=S):S=e[17];let h;e[18]!==f||e[19]!==S?(h={queryKey:f,queryFn:S},e[18]=f,e[19]=S,e[20]=h):h=e[20];const T=Ke(h).data?.item?.configuration_state??null;let C;e[21]!==T?(C=q=>T?.[q.fieldKey]?.value,e[21]=T,e[22]=C):C=e[22];const v=m.map(C).filter(Qn),w=[...y.map(Vn),...j.map(Mn),...v.map(Bn)].sort().join(","),A=Ke({queryKey:Z.commerceDiscoveryCompanionConnections(o.id,w),queryFn:async()=>{if(m.length===0)return{items:[]};const q=[{field:["app_name"],operator:"in",value:y},{field:["app_id"],operator:"in",value:j}];v.length>0&&q.push({field:["id"],operator:"in",value:v});const H=await t.callTool({name:"COLLECTION_CONNECTIONS_LIST",arguments:{where:{operator:"or",conditions:q},limit:1e3}});return ne(H)}}).data?.items??[],F=new Set(v),_=A.filter(q=>F.has(q.id)),O=_.filter(Gn);let P;e[23]!==o.id||e[24]!==o.slug?(P=q=>({queryKey:Z.commerceDiscoveryCompanionOAuthStatus(o.id,q.id),queryFn:async()=>{try{const H=await fetch(`/api/${encodeURIComponent(o.slug)}/connections/${encodeURIComponent(q.id)}/oauth-token/status`,{credentials:"include"});return H.ok?{hasToken:(await H.json()).hasToken===!0}:{hasToken:!1}}catch{return{hasToken:!1}}},retry:!1}),e[23]=o.id,e[24]=o.slug,e[25]=P):P=e[25];const R=sn({queries:O.map(P)});let $;e[26]!==R?($=(q,H)=>[q.id,R[H]?.data?.hasToken===!0],e[26]=R,e[27]=$):$=e[27];const K=new Map(O.map($)),U={};for(const q of _)U[q.id]=!q.oauth_config||!!q.connection_token||K.get(q.id)===!0;const z=Ke({queryKey:Z.commerceDiscoveryCompanionRegistry(o.id,x),queryFn:async()=>{if(m.length===0)return{items:[]};const q=Bt(j,b),H=await en(mt.REGISTRY(o.id),o.id,o.slug,"COLLECTION_REGISTRY_APP_LIST",{...q?{where:q}:{},limit:1e3});return ne(H)}}),G={},D={};for(const q of z.data?.items??[])G[q.id]=q,q.server?.name&&(D[q.server.name]=q);let E;e[28]!==o.id||e[29]!==l?(E=Z.commerceDiscoveryConnectionStatus(o.id,l??""),e[28]=o.id,e[29]=l,e[30]=E):E=e[30];const k=!!l;let N;e[31]!==t||e[32]!==l?(N=async()=>{const q=await t.callTool({name:"COMMERCE_DISCOVERY_CONNECTION_STATUS",arguments:{siteUrl:l}});return ne(q)},e[31]=t,e[32]=l,e[33]=N):N=e[33];let B;e[34]!==E||e[35]!==k||e[36]!==N?(B={queryKey:E,enabled:k,queryFn:N},e[34]=E,e[35]=k,e[36]=N,e[37]=B):B=e[37];const Q=be(B),te={};for(const[q,H]of Object.entries(Ot)){const ee=Q.data?.providers?.[H];ee?.connected&&ee.via==="sa"&&(te[q]={resource:ee.resource??null})}const oe=Mt({requirements:m,itemsById:G,itemsByName:D,connections:A,connectionReadiness:U,configurationState:T,curated:Ye,saBindings:te});let J;return e[38]!==oe?(J={cards:oe},e[38]=oe,e[39]=J):J=e[39],J}function Gn(s){return s.oauth_config&&!s.connection_token}function Bn(s){return`linked:${s}`}function Mn(s){return`app:${s}`}function Vn(s){return`binding:${s}`}function Qn(s){return typeof s=="string"&&s.length>0}function Hn(s){return s.bindingType}function Wn(s){return!Ye[s.bindingType]}function Yn(s){return!!s}function Zn(s){return Ye[s.bindingType]?.registryAppId}function Xn(s){return s.bindingType}function Jn({selfClient:s,org:e,userId:t,cdConnectionId:o,domain:c,siteUrl:l}){const u=Se(),[d,a]=V.useState(null),[p,i]=V.useState(null),[r,g]=V.useState(null),m=async(b,x)=>{const f=await s.callTool({name:"COLLECTION_CONNECTIONS_UPDATE",arguments:{id:b,data:x}});return ne(f)};async function y(b){a(b.fieldKey),g(null);const x={app_name:b.title,field_key:b.fieldKey,organization_id:e.id,domain:c,site_url:l};le("commerce_onboarding_companion_connect_clicked",x);try{let f=b.candidateConnectionId;if(!f){const v=tn(b.registryItem,e.id,t,{remoteIndex:0}),w=v.connection_type==="STDIO",I=!!v.connection_url,A=w&&v.connection_headers&&typeof v.connection_headers=="object"&&"command"in v.connection_headers;if(!I&&!A)return le("commerce_onboarding_companion_connect_failed",{...x,error:"no_connection_method"}),g(`${b.title} cannot be connected: no connection method available`),!1;const F=await s.callTool({name:"COLLECTION_CONNECTIONS_CREATE",arguments:{data:v}});f=ne(F).item.id}const S=f,h=await on({connectionId:S,orgId:e.id,orgSlug:e.slug,persistFallback:v=>m(S,{connection_token:v}).then(()=>{})});if(!h.ok)return le("commerce_onboarding_companion_connect_failed",{...x,error:h.error}),g(`Couldn't sign in to ${b.title}: ${h.error}`),!1;const L=await s.callTool({name:"COLLECTION_CONNECTIONS_GET",arguments:{id:o}}),T=ne(L).item?.configuration_state??null,C=Vt(T,b.fieldKey,b.bindingType,S);return b.bindingType==="github"&&delete C.github_repo,await m(o,{configuration_state:C}),await u.invalidateQueries({queryKey:Z.commerceDiscoveryConnection(e.id,o)}),await u.invalidateQueries({queryKey:Z.commerceDiscoveryCompanionConnectionsPrefix(e.id)}),le("commerce_onboarding_companion_connected",x),!0}catch(f){return le("commerce_onboarding_companion_connect_failed",{...x,error:f instanceof Error?f.message:String(f)}),g(f instanceof Error?f.message:String(f)),!1}finally{a(null)}}async function j(b){i(b.fieldKey),g(null);const x={app_name:b.title,field_key:b.fieldKey,organization_id:e.id,domain:c,site_url:l};le("commerce_onboarding_companion_disconnect_clicked",x);try{const f=await s.callTool({name:"COLLECTION_CONNECTIONS_GET",arguments:{id:o}}),h={...ne(f).item?.configuration_state??null??{}};return delete h[b.fieldKey],b.bindingType==="github"&&delete h.github_repo,await m(o,{configuration_state:h}),await u.invalidateQueries({queryKey:Z.commerceDiscoveryConnection(e.id,o)}),await u.invalidateQueries({queryKey:Z.commerceDiscoveryCompanionConnectionsPrefix(e.id)}),le("commerce_onboarding_companion_disconnected",x),!0}catch(f){return le("commerce_onboarding_companion_disconnect_failed",{...x,error:f instanceof Error?f.message:String(f)}),g(f instanceof Error?f.message:String(f)),!1}finally{i(null)}}return{connect:y,connectingFieldKey:d,disconnect:j,disconnectingFieldKey:p,error:r}}const Ze="flex min-h-0 flex-1 flex-col gap-6 md:grid md:flex-none md:gap-6";function Xe(){const s=M.c(4),e=re();let t;s[0]!==e?(t=e("routes.commerceOnboarding.companionSection.title"),s[0]=e,s[1]=t):t=s[1];let o;return s[2]!==t?(o=n.jsx("h1",{className:"text-lg font-medium leading-6 text-foreground lg:text-xl lg:leading-7",children:t}),s[2]=t,s[3]=o):o=s[3],o}function eo(){const s=M.c(1);let e;return s[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx("div",{className:"flex flex-col gap-4",children:[0,1,2,3].map(to)}),s[0]=e):e=s[0],e}function to(s){return n.jsx(qn,{},s)}function no(){const s=M.c(1);let e;return s[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsxs("div",{className:Ze,children:[n.jsx(Xe,{}),n.jsx(eo,{})]}),s[0]=e):e=s[0],e}function oo(s){const e=M.c(18),{onRetry:t}=s,o=re();let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx(Xe,{}),e[0]=c):c=e[0];let l;e[1]!==o?(l=o("routes.commerceOnboarding.companionSection.loadError"),e[1]=o,e[2]=l):l=e[2];let u;e[3]!==l?(u=n.jsx("p",{className:"text-sm text-foreground",children:l}),e[3]=l,e[4]=u):u=e[4];let d;e[5]!==o?(d=o("routes.commerceOnboarding.companionSection.loadErrorDescription"),e[5]=o,e[6]=d):d=e[6];let a;e[7]!==d?(a=n.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:d}),e[7]=d,e[8]=a):a=e[8];let p;e[9]!==o?(p=o("routes.commerceOnboarding.companionSection.retry"),e[9]=o,e[10]=p):p=e[10];let i;e[11]!==t||e[12]!==p?(i=n.jsx(X,{type:"button",variant:"outline",size:"sm",className:"mt-3",onClick:t,children:p}),e[11]=t,e[12]=p,e[13]=i):i=e[13];let r;return e[14]!==u||e[15]!==a||e[16]!==i?(r=n.jsxs("div",{className:Ze,children:[c,n.jsxs("div",{role:"alert",className:"rounded-2xl border border-border bg-card p-4",children:[u,a,i]})]}),e[14]=u,e[15]=a,e[16]=i,e[17]=r):r=e[17],r}function Lo(s){const e=M.c(2);let t;return e[0]!==s?(t=n.jsx(kt,{children:o=>{const{reset:c}=o;return n.jsx(Ft,{fallback:l=>{const{resetError:u}=l;return n.jsx(oo,{onRetry:()=>{c(),u()}})},children:n.jsx(V.Suspense,{fallback:n.jsx(no,{}),children:n.jsx(so,{...s})})})}}),e[0]=s,e[1]=t):t=e[1],t}function so(s){const e=M.c(53),{org:t,cdConnectionId:o,siteUrl:c,onReadinessChange:l}=s,{data:u}=Rt.useSession(),d=u?.user?.id??"";let a;if(e[0]!==c){const K=c?Fe(c):null;if(K?.ok)try{a=new URL(K.value).hostname}catch{a=void 0}e[0]=c,e[1]=a}else a=e[1];let p;e[2]!==t.id||e[3]!==t.slug?(p={connectionId:Pt,orgId:t.id,orgSlug:t.slug},e[2]=t.id,e[3]=t.slug,e[4]=p):p=e[4];const i=ze(p);let r;e[5]!==o||e[6]!==t||e[7]!==i||e[8]!==c?(r={selfClient:i,org:t,cdConnectionId:o,siteUrl:c},e[5]=o,e[6]=t,e[7]=i,e[8]=c,e[9]=r):r=e[9];const{cards:g}=zn(r);let m;e[10]!==o||e[11]!==t||e[12]!==i||e[13]!==a||e[14]!==c||e[15]!==d?(m={selfClient:i,org:t,userId:d,cdConnectionId:o,domain:a,siteUrl:c},e[10]=o,e[11]=t,e[12]=i,e[13]=a,e[14]=c,e[15]=d,e[16]=m):m=e[16];const{connect:y,connectingFieldKey:j,disconnect:b,disconnectingFieldKey:x,error:f}=Jn(m),[S,h]=V.useState(null),L=ao;let T,C,v,w,I,A,F,_,O;if(e[17]!==S||e[18]!==g||e[19]!==y||e[20]!==f||e[21]!==j||e[22]!==b||e[23]!==x||e[24]!==l||e[25]!==t||e[26]!==i||e[27]!==c){v=Symbol.for("react.early_return_sentinel");e:{const K=g.filter(ro),U=g.filter(io),z=K.length>0?K.every(L):g.length===0||g.some(L);if(l?.(z),g.length===0){v=null;break e}const G=j!==null||x!==null,D=E=>{const k=async()=>{await y(E)&&h(E.fieldKey)};return n.jsx(Kn,{card:E,connecting:j===E.fieldKey,disconnecting:x===E.fieldKey,disabled:G&&j!==E.fieldKey&&x!==E.fieldKey,org:t,selfClient:i,siteUrl:c,autoOpenConfigFieldKey:S,onAutoOpenConfigHandled:()=>h(N=>N===E.fieldKey?null:N),onConnect:()=>{k()},onDisconnect:()=>{b(E)}},E.fieldKey)};O=Ze,e[37]===Symbol.for("react.memo_cache_sentinel")?(C=n.jsx(Xe,{}),e[37]=C):C=e[37],T=dn,A="flex min-h-0 flex-1 flex-col md:block",F="-mx-1 min-h-0 flex-1 overflow-y-auto px-1 md:max-h-[min(60vh,calc(100dvh-330px))] md:flex-none",e[38]!==f?(_=f&&n.jsx("p",{role:"alert",className:"mb-3 text-sm text-destructive",children:f}),e[38]=f,e[39]=_):_=e[39],w="flex flex-col gap-4 pt-3",I=[...K,...U].map(D)}e[17]=S,e[18]=g,e[19]=y,e[20]=f,e[21]=j,e[22]=b,e[23]=x,e[24]=l,e[25]=t,e[26]=i,e[27]=c,e[28]=T,e[29]=C,e[30]=v,e[31]=w,e[32]=I,e[33]=A,e[34]=F,e[35]=_,e[36]=O}else T=e[28],C=e[29],v=e[30],w=e[31],I=e[32],A=e[33],F=e[34],_=e[35],O=e[36];if(v!==Symbol.for("react.early_return_sentinel"))return v;let P;e[40]!==w||e[41]!==I?(P=n.jsx("div",{className:w,children:I}),e[40]=w,e[41]=I,e[42]=P):P=e[42];let R;e[43]!==T||e[44]!==P||e[45]!==A||e[46]!==F||e[47]!==_?(R=n.jsxs(T,{wrapperClassName:A,className:F,children:[_,P]}),e[43]=T,e[44]=P,e[45]=A,e[46]=F,e[47]=_,e[48]=R):R=e[48];let $;return e[49]!==C||e[50]!==R||e[51]!==O?($=n.jsxs("div",{className:O,children:[C,R]}),e[49]=C,e[50]=R,e[51]=O,e[52]=$):$=e[52],$}function io(s){return!s.required}function ro(s){return s.required}function ao(s){return s.satisfied&&s.configured}function lo(s){return s.content?.find(e=>e.text)?.text??"A configuração do Commerce Discovery falhou."}function ko(s){const e=s;if(e.isError)throw new Error(lo(e));return e.structuredContent??s}export{no as C,We as L,dn as S,Lo as a,wo as i,Fe as n,ko as p,Ao as s};
|