decocms 4.150.21 → 4.150.23
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-BaA3X0Vc.js → AlertCircle-DcJb8iRa.js} +1 -1
- package/dist/client/assets/{AreaChart-B4pcuH23.js → AreaChart-CnXGIMEc.js} +1 -1
- package/dist/client/assets/{ArrowUp-Df4rbgne.js → ArrowUp-D0IVwHrj.js} +1 -1
- package/dist/client/assets/{ArrowUpRight-fq20wgvL.js → ArrowUpRight-BDfLBQkt.js} +1 -1
- package/dist/client/assets/{Check-DdyKCl8O.js → Check-gjVkLyjz.js} +1 -1
- package/dist/client/assets/{CheckCircle-IiUO6eKZ.js → CheckCircle-Brw1At1c.js} +1 -1
- package/dist/client/assets/{ChevronDown-BSVV4L9A.js → ChevronDown-C6lfFArn.js} +1 -1
- package/dist/client/assets/{ChevronRight-CSgj0z6i.js → ChevronRight-D5LzDyDE.js} +1 -1
- package/dist/client/assets/{ChevronUp-GR0-Yt4d.js → ChevronUp-eoLttylI.js} +1 -1
- package/dist/client/assets/{Copy01-Cv0Vuqbe.js → Copy01-xzQ4ogmG.js} +1 -1
- package/dist/client/assets/{CpuChip01-UMJdnf1a.js → CpuChip01-D3yBcvwh.js} +1 -1
- package/dist/client/assets/{DotsVertical-OBlENp_a.js → DotsVertical-B81JSfTm.js} +1 -1
- package/dist/client/assets/{Eye-CkjEvMwH.js → Eye-Bbyfcz3U.js} +1 -1
- package/dist/client/assets/{FilterLines-Ca7W3tHb.js → FilterLines-g4cIObbX.js} +1 -1
- package/dist/client/assets/{HardDrive-B91rzidb.js → HardDrive-BAom8AR4.js} +1 -1
- package/dist/client/assets/{Key01-DVGzNfoY.js → Key01-3KmfaqoQ.js} +1 -1
- package/dist/client/assets/{LayoutLeft-Ciug-ep8.js → LayoutLeft-Cvh2z-Gq.js} +1 -1
- package/dist/client/assets/{LinkExternal01-CbfqV87q.js → LinkExternal01-CZSiz4Ic.js} +1 -1
- package/dist/client/assets/{LogOut01-B0JVxGo4.js → LogOut01-BV9cjMBN.js} +1 -1
- package/dist/client/assets/{Monitor01-CEdUOtdj.js → Monitor01-fc3ZhEXF.js} +1 -1
- package/dist/client/assets/{Palette-DgmLnO_l.js → Palette-B_TkkqR9.js} +1 -1
- package/dist/client/assets/{Play-DcSuTxiG.js → Play-DjHrAgT6.js} +1 -1
- package/dist/client/assets/{Plus-DUvbS-Yy.js → Plus-CikdUs38.js} +1 -1
- package/dist/client/assets/{SearchLg-CSWY8viA.js → SearchLg-JzU424qf.js} +1 -1
- package/dist/client/assets/{SearchMd-D0poZQV_.js → SearchMd-BOfFIRRH.js} +1 -1
- package/dist/client/assets/{Settings02-Sy5kNpSu.js → Settings02-CBDIwie_.js} +1 -1
- package/dist/client/assets/{Shield01-Bcql6hT4.js → Shield01-DefKd0oD.js} +1 -1
- package/dist/client/assets/{Star01-2mO5G0Xw.js → Star01-KVwXdwxj.js} +1 -1
- package/dist/client/assets/{Stars01-DqIThrOc.js → Stars01-C-4SXXn7.js} +1 -1
- package/dist/client/assets/{Stars02-cKtwD-F2.js → Stars02-BoANd6Kf.js} +1 -1
- package/dist/client/assets/{Sun-DsnsEGXF.js → Sun-HcIWpb0y.js} +1 -1
- package/dist/client/assets/{SwitchHorizontal01-BwAs_KcG.js → SwitchHorizontal01-DE5mPN2-.js} +1 -1
- package/dist/client/assets/{Tool01-D2fd-Mg5.js → Tool01-hFe2UsG9.js} +1 -1
- package/dist/client/assets/{Tool02-C17Y4pBP.js → Tool02-Byyk9Vee.js} +1 -1
- package/dist/client/assets/{Trash01-BiVOd2DS.js → Trash01-TtVBqMTN.js} +1 -1
- package/dist/client/assets/{TrendUp01-D1GkdBOV.js → TrendUp01-B2goMTVh.js} +1 -1
- package/dist/client/assets/{Upload01-k2Sn0RXQ.js → Upload01-CbyAB4oE.js} +1 -1
- package/dist/client/assets/{User01-cC3unvvx.js → User01-lSU_Ire_.js} +1 -1
- package/dist/client/assets/{Users01-BdNSg6CC.js → Users01-DwgtBHFJ.js} +1 -1
- package/dist/client/assets/{Users03-CqyDxwt6.js → Users03-Rq4uYvEF.js} +1 -1
- package/dist/client/assets/{X-Baqkpp1k.js → X-3PgyJoHo.js} +1 -1
- package/dist/client/assets/{XCircle-8Wd2-AR5.js → XCircle-j11o8nYG.js} +1 -1
- package/dist/client/assets/{XClose-CBFLmbVP.js → XClose-B5-EL_eq.js} +1 -1
- package/dist/client/assets/{Zap-C4qF8Cn-.js → Zap-YaHmPbs0.js} +1 -1
- package/dist/client/assets/{ZapSquare-BH7ie7zg.js → ZapSquare-BY3CWoiI.js} +1 -1
- package/dist/client/assets/{access-gate-CxXZPkIw.js → access-gate-BrRUOUYq.js} +1 -1
- package/dist/client/assets/{add-section-modal-C7ktQCug.js → add-section-modal-IHIfksTy.js} +1 -1
- package/dist/client/assets/{agent-icon-q4cV7U67.js → agent-icon-D5JzlR5X.js} +1 -1
- package/dist/client/assets/{agents-list-UZwnNOjT.js → agents-list-CaVLSFy6.js} +1 -1
- package/dist/client/assets/{ai-providers-Cput0kVL.js → ai-providers-BeddGROn.js} +1 -1
- package/dist/client/assets/{alert-DjeIAXMV.js → alert-DliKxZ_m.js} +1 -1
- package/dist/client/assets/{alert-dialog-DIwINRgW.js → alert-dialog-BKskXtEG.js} +1 -1
- package/dist/client/assets/{app-editor-DdSH3pAD.js → app-editor-C2ptf1Dh.js} +1 -1
- package/dist/client/assets/{auth-catchall-6cph4qce.js → auth-catchall-CXtu3uVP.js} +1 -1
- package/dist/client/assets/{auth-entry-i0rNcujn.js → auth-entry-CqXrI1mX.js} +1 -1
- package/dist/client/assets/{auth-split-layout-3qPwGE8Z.js → auth-split-layout-C4pHBCKt.js} +1 -1
- package/dist/client/assets/{auth-FouChJbb.js → auth-t69bSn2K.js} +1 -1
- package/dist/client/assets/{authenticate-and-persist-oauth-Dx2DT3YD.js → authenticate-and-persist-oauth-DqnkEHz5.js} +1 -1
- package/dist/client/assets/{automation-list-row-Brn7k31U.js → automation-list-row-B3d7Fa8J.js} +1 -1
- package/dist/client/assets/{automation-runs-CP1cxXFo.js → automation-runs-Bwrqu-lm.js} +1 -1
- package/dist/client/assets/{automations-BlJndOBe.js → automations--79t6PzC.js} +1 -1
- package/dist/client/assets/{avatar-Du8HEobV.js → avatar-CPVdCa-q.js} +1 -1
- package/dist/client/assets/{badge-swCoKQnC.js → badge-PIDJwXZe.js} +1 -1
- package/dist/client/assets/{block-document-DiB0SOp5.js → block-document-D7e2Se-F.js} +1 -1
- package/dist/client/assets/{brand-context-C8l7XNKr.js → brand-context-BPLsCkvC.js} +1 -1
- package/dist/client/assets/{buckets-Bs0sTGAu.js → buckets-B1d9Lx14.js} +1 -1
- package/dist/client/assets/{bulk-category-panel-DE5pUVzi.js → bulk-category-panel-qFVuIjK-.js} +1 -1
- package/dist/client/assets/{calendar-BZcldUNV.js → calendar-BzP-iZOP.js} +1 -1
- package/dist/client/assets/{capability-load-error-CqwI-nav.js → capability-load-error-B7iCz6mL.js} +1 -1
- package/dist/client/assets/{card-9OUE6Bzl.js → card-rdaxkAgx.js} +1 -1
- package/dist/client/assets/{category-editor-JK7DojfI.js → category-editor-Dnug34di.js} +1 -1
- package/dist/client/assets/{chat-context-DYO1ODPB.js → chat-context-DUpUs54F.js} +1 -1
- package/dist/client/assets/{checkbox-Dd_rqLvT.js → checkbox-D-QJq7XZ.js} +1 -1
- package/dist/client/assets/{cli-auth-success-CFsjKhGa.js → cli-auth-success-BD5lLz9y.js} +1 -1
- package/dist/client/assets/{collection-detail-D0rtc2gf.js → collection-detail-wBVCEcj_.js} +1 -1
- package/dist/client/assets/{collection-display-button-iD10GGdW.js → collection-display-button-BCk9o0Bw.js} +1 -1
- package/dist/client/assets/{collection-search-5SFjfCC8.js → collection-search-lkrkOSW6.js} +1 -1
- package/dist/client/assets/{collection-table-wrapper-fW-dsmLE.js → collection-table-wrapper-C8UgE-LV.js} +1 -1
- package/dist/client/assets/{collection-tabs-DnykrgWW.js → collection-tabs-CTE8Yg6C.js} +1 -1
- package/dist/client/assets/{command-CDVbjOi5.js → command-D9ijNPQj.js} +1 -1
- package/dist/client/assets/{commerce-onboarding-CAOuADZ6.js → commerce-onboarding-Dqki5bhb.js} +1 -1
- package/dist/client/assets/{companions-core-6m5dy3es.js → companions-core-BQihQDwO.js} +1 -1
- package/dist/client/assets/{connect-B_K53Vaa.js → connect-CIafENMH.js} +1 -1
- package/dist/client/assets/{connection-DhlrJlFw.js → connection-D8Dv76YE.js} +1 -1
- package/dist/client/assets/{connection-card-CzF-xjYn.js → connection-card-B28rU1ux.js} +1 -1
- package/dist/client/assets/{connection-detail-DmWTCewb.js → connection-detail-BMNykvoh.js} +1 -1
- package/dist/client/assets/{connection-form-helpers-DRviH-Au.js → connection-form-helpers-LdFIzzLF.js} +1 -1
- package/dist/client/assets/{connections-DGvaZBx3.js → connections-CbFZ_fyr.js} +1 -1
- package/dist/client/assets/{decopilot-sse-pool-BXMXu1gQ.js → decopilot-sse-pool-6EUNiAy6.js} +1 -1
- package/dist/client/assets/{dialog-C82H2S70.js → dialog-Ezhjz9E0.js} +1 -1
- package/dist/client/assets/{domain-settings-DPn_9rd3.js → domain-settings-DrRRmNHM.js} +1 -1
- package/dist/client/assets/{drawer-lnIGl-vb.js → drawer-2Y1dMuWR.js} +1 -1
- package/dist/client/assets/{dropdown-menu-CRGAwBji.js → dropdown-menu-BmsikUlK.js} +1 -1
- package/dist/client/assets/{empty-state-BKzUesA7.js → empty-state-DEooU27n.js} +1 -1
- package/dist/client/assets/{extract-connection-data-B9TIJ0UC.js → extract-connection-data-DNA7o6q8.js} +1 -1
- package/dist/client/assets/{file-explorer-tNI79jXo.js → file-explorer-D0PiN9vT.js} +1 -1
- package/dist/client/assets/{form-DAiRK0vx.js → form-CdwOvuuM.js} +1 -1
- package/dist/client/assets/{general-CXtIEOrf.js → general-B8KMAgiV.js} +1 -1
- package/dist/client/assets/{github-repo-picker-DUNQ1oJW.js → github-repo-picker-DyeCKBgn.js} +1 -1
- package/dist/client/assets/{hooks-Bom1QoTc.js → hooks-DUfbKzwY.js} +1 -1
- package/dist/client/assets/{index-2KxPRjw5.js → index-30J4z2dD.js} +4 -4
- package/dist/client/assets/{index-D7cNsGmf.js → index-BE_dAky8.js} +3 -3
- package/dist/client/assets/{index-oBYlsJ_o.js → index-BH_MYqNK.js} +1 -1
- package/dist/client/assets/{index-BDQ6Ogmu.js → index-C0-pfybn.js} +5 -5
- package/dist/client/assets/{index-C_5SQGG6.js → index-CJmDrukF.js} +1 -1
- package/dist/client/assets/{index-Dv8k1EHh.js → index-CT4vVVkh.js} +1 -1
- package/dist/client/assets/{index-Df7LGqDK.js → index-CTHVCKuU.js} +1 -1
- package/dist/client/assets/{index-C-JAJ-o5.js → index-D5lX6giL.js} +1 -1
- package/dist/client/assets/{index-Z4CG7jJp.js → index-D97fya3E.js} +1 -1
- package/dist/client/assets/{index-DK8HHLRp.js → index-DsC6nOfN.js} +1 -1
- package/dist/client/assets/{index-redirect-Cj-NIgvU.js → index-redirect-C59786pk.js} +1 -1
- package/dist/client/assets/{index-B_kqSbsO.js → index-wU-cy7bZ.js} +1 -1
- package/dist/client/assets/{input-BAuCATqg.js → input-DO6f6Oyi.js} +1 -1
- package/dist/client/assets/{integration-icon-DKBuU8Fr.js → integration-icon-gnw4DLPa.js} +1 -1
- package/dist/client/assets/{invite-member-dialog-BiHY2r7m.js → invite-member-dialog-BptogSTb.js} +1 -1
- package/dist/client/assets/{label-onkw7wrh.js → label-BOL4d07L.js} +1 -1
- package/dist/client/assets/{layout-D8O9_Poo.js → layout-B3JKz_lV.js} +1 -1
- package/dist/client/assets/{login-B0j1yr6w.js → login-BtmJvFnQ.js} +1 -1
- package/dist/client/assets/{mcp-oauth-95IH3VKT.js → mcp-oauth-CxX_EpGC.js} +1 -1
- package/dist/client/assets/{members-Y7A-UiF5.js → members-CbR6NGyc.js} +1 -1
- package/dist/client/assets/{monaco-editor-CSUtCvVX.js → monaco-editor-DRxJlsld.js} +1 -1
- package/dist/client/assets/{monitoring-stats-row-Dcug_wR7.js → monitoring-stats-row-DxMqg_RE.js} +1 -1
- package/dist/client/assets/{multi-select-C68tqs9V.js → multi-select-Ds7z77R1.js} +1 -1
- package/dist/client/assets/{oauth-callback-ai-provider-C0UAY-58.js → oauth-callback-ai-provider-D3wpalZl.js} +1 -1
- package/dist/client/assets/{oauth-callback-CqH1tIve.js → oauth-callback-o14AOSPq.js} +1 -1
- package/dist/client/assets/{onboarding-2ZJYmqTH.js → onboarding-C1H2Rzr-.js} +1 -1
- package/dist/client/assets/{org-layout-qZcaYBLo.js → org-layout-CYKFkwe2.js} +1 -1
- package/dist/client/assets/{organization-choice-CduZOMP9.js → organization-choice-CwtI_hHl.js} +1 -1
- package/dist/client/assets/{orgs-DU0BEJAc.js → orgs-DU7XL6NJ.js} +1 -1
- package/dist/client/assets/{page-seo-form-nxKDUI-6.js → page-seo-form-CB-OJgf8.js} +1 -1
- package/dist/client/assets/{popover-x1qHvmwD.js → popover-ddNYtuzN.js} +1 -1
- package/dist/client/assets/{post-editor-BhfI7Odx.js → post-editor-pDG0QWkr.js} +1 -1
- package/dist/client/assets/{primitives-DITXbj-2.js → primitives-CgsmqPQU.js} +1 -1
- package/dist/client/assets/{profile-Dl3k4wub.js → profile-D6QujN3h.js} +1 -1
- package/dist/client/assets/project-app-view-EqdJwELN.js +1 -0
- package/dist/client/assets/record-editor-FwZf9H_x.js +1 -0
- package/dist/client/assets/{redirect-editor-BamLe0Vb.js → redirect-editor-DjloRUnO.js} +1 -1
- package/dist/client/assets/{registry-layout-Cfgh3Q9S.js → registry-layout-CoT2siHJ.js} +1 -1
- package/dist/client/assets/registry-o-K-mNuJ.js +2 -0
- package/dist/client/assets/{reports-2omVoMUm.js → reports-CbBUMCyA.js} +1 -1
- package/dist/client/assets/{require-capability-B1pg4EtO.js → require-capability-D9owsYJv.js} +1 -1
- package/dist/client/assets/{required-auth-layout-wB2bMMGI.js → required-auth-layout-C0fEZd67.js} +1 -1
- package/dist/client/assets/{reset-password-BmxFRY37.js → reset-password-CG1TeRN5.js} +1 -1
- package/dist/client/assets/{roles-ClU1umGx.js → roles-BttwbRxs.js} +1 -1
- package/dist/client/assets/{search-input-DtCL1YcZ.js → search-input-Ceaa5r9L.js} +1 -1
- package/dist/client/assets/{secrets-B-dmTgLw.js → secrets-QKqtq4bv.js} +1 -1
- package/dist/client/assets/{sections-editor-DqY5dzLX.js → sections-editor-Df2cLClj.js} +1 -1
- package/dist/client/assets/{select-DfQiZ-4J.js → select-DHyC2wGe.js} +1 -1
- package/dist/client/assets/select-model-C26oRqlD.js +4 -0
- package/dist/client/assets/{self-tool-result-BCgUr0ik.js → self-tool-result-C28rj1Ae.js} +1 -1
- package/dist/client/assets/{seo-editor-CEUCMyKF.js → seo-editor-S5ZqoAxb.js} +1 -1
- package/dist/client/assets/{settings-layout-DJLSOlbv.js → settings-layout-DI56dbNY.js} +1 -1
- package/dist/client/assets/{settings-section-BaFcIjo5.js → settings-section-BgDF_9yt.js} +1 -1
- package/dist/client/assets/{shell-controls-DIMDYHkk.js → shell-controls-BhFgVo2Q.js} +1 -1
- package/dist/client/assets/{shell-layout-B56j-p5N.js → shell-layout-D-c2X1KV.js} +1 -1
- package/dist/client/assets/{sidebar-DpVJgBAa.js → sidebar-Cwhg81Iz.js} +1 -1
- package/dist/client/assets/{skeleton-BtiEyhAl.js → skeleton-I0ZeK4UC.js} +1 -1
- package/dist/client/assets/{spinner-DPfrt4Tp.js → spinner-mEqeXw5u.js} +1 -1
- package/dist/client/assets/{sso-CICOFYfX.js → sso-Bq8zylip.js} +1 -1
- package/dist/client/assets/{store-BJgQ6scG.js → store-F-pcSCHR.js} +1 -1
- package/dist/client/assets/store-registry-CfpNP5E9.js +2 -0
- package/dist/client/assets/{studio-tools-CTJuN7Yy.js → studio-tools-kQ3NEEWO.js} +1 -1
- package/dist/client/assets/{switch-DIwoxI1y.js → switch-BRa8kkrS.js} +1 -1
- package/dist/client/assets/{tab-id-DJIms9m1.js → tab-id-C4bMCjr3.js} +1 -1
- package/dist/client/assets/{table-BbRTH9fF.js → table-x0GONNLh.js} +1 -1
- package/dist/client/assets/{tabs-DKyQ4Qe1.js → tabs-Bq81Vyjl.js} +1 -1
- package/dist/client/assets/{textarea-Y242n44c.js → textarea-CUAzWR5L.js} +1 -1
- package/dist/client/assets/{toggle-group-BBsmjOfV.js → toggle-group-Gmqz3gDK.js} +1 -1
- package/dist/client/assets/{toolbar-BaZp82JP.js → toolbar-BkBl6JIj.js} +1 -1
- package/dist/client/assets/{tooltip-CEu_we5y.js → tooltip-B-SCkbF9.js} +1 -1
- package/dist/client/assets/{use-ai-providers-B2nAOoUO.js → use-ai-providers-DiMxVRip.js} +1 -1
- package/dist/client/assets/{use-automations-irLGHKpI.js → use-automations-XL_0RJHM.js} +1 -1
- package/dist/client/assets/{use-autosave-BAjK3u8R.js → use-autosave-Hi4rlXng.js} +1 -1
- package/dist/client/assets/{use-capability-Y4a4cK2y.js → use-capability-BtPReSHt.js} +1 -1
- package/dist/client/assets/{use-clock-tick-kQx_nmDK.js → use-clock-tick-DXfDu1U2.js} +1 -1
- package/dist/client/assets/{use-connection-CvBcj0iA.js → use-connection-D0ep6AoQ.js} +1 -1
- package/dist/client/assets/{use-copy-POYUhIaM.js → use-copy-BvxfdX6N.js} +1 -1
- package/dist/client/assets/{use-create-virtual-mcp-Df8fpCi4.js → use-create-virtual-mcp-DgvhUI5T.js} +1 -1
- package/dist/client/assets/{use-debounced-autosave-EvVOUA6S.js → use-debounced-autosave-CHhWSqXz.js} +1 -1
- package/dist/client/assets/{use-debounced-value-IOz7dnNR.js → use-debounced-value-C8ryVVpy.js} +1 -1
- package/dist/client/assets/{use-deco-credits-CBOWsaT-.js → use-deco-credits-D_UVlDt_.js} +1 -1
- package/dist/client/assets/{use-decopilot-events-Dc8-pFMU.js → use-decopilot-events-BnwcV4U8.js} +1 -1
- package/dist/client/assets/{use-delete-connection-CxX7cCR_.js → use-delete-connection-CphOcDpT.js} +1 -1
- package/dist/client/assets/{use-deployment-admin-ucDRDdNR.js → use-deployment-admin-jnxGa9l6.js} +1 -1
- package/dist/client/assets/{use-file-configs-BsCj6gUu.js → use-file-configs-DwBVeXP6.js} +1 -1
- package/dist/client/assets/{use-infinite-scroll-ccrh4_KW.js → use-infinite-scroll-DGDKOGPe.js} +1 -1
- package/dist/client/assets/{use-join-requests-DjYbXyL8.js → use-join-requests-C22v4g-F.js} +1 -1
- package/dist/client/assets/{use-mcp-auth-status-vzmxIRHi.js → use-mcp-auth-status-CzVoDeIA.js} +1 -1
- package/dist/client/assets/{use-mcp-client-DRwUSZdO.js → use-mcp-client-BsWOvAzd.js} +1 -1
- package/dist/client/assets/{use-mcp-tools-PCSBjtNq.js → use-mcp-tools-C9hT_wdC.js} +1 -1
- package/dist/client/assets/{use-members-DjRi0Onl.js → use-members-DzQELg6H.js} +1 -1
- package/dist/client/assets/{use-mobile-CLE626Yq.js → use-mobile-DKlFMukO.js} +1 -1
- package/dist/client/assets/{use-navigate-to-agent-CXMG3HNZ.js → use-navigate-to-agent-39LPUcH9.js} +1 -1
- package/dist/client/assets/{use-org-auth-client-BxtVWNiI.js → use-org-auth-client-JYyEKX5R.js} +1 -1
- package/dist/client/assets/{use-org-sso-DBExuOVV.js → use-org-sso-CMGzDI_I.js} +1 -1
- package/dist/client/assets/{use-organization-roles-DFLLP3Qo.js → use-organization-roles-Ce_u9VNe.js} +1 -1
- package/dist/client/assets/{use-organization-settings-DKSNQ1_z.js → use-organization-settings-CJWrHwUl.js} +1 -1
- package/dist/client/assets/{use-registry-connections-BRZCHKHD.js → use-registry-connections-BnLvWUJS.js} +1 -1
- package/dist/client/assets/{use-secrets-DfGoccAw.js → use-secrets-D5BP08GP.js} +1 -1
- package/dist/client/assets/{use-status-sounds-DcgHuUFX.js → use-status-sounds-CP2AjcIU.js} +1 -1
- package/dist/client/assets/{use-tags-DRM6xsgU.js → use-tags-B4cYgssP.js} +1 -1
- package/dist/client/assets/{use-view-mode-DvgBYhz6.js → use-view-mode-DDu5UVga.js} +1 -1
- package/dist/client/assets/{use-virtual-mcp-D7SVi-2E.js → use-virtual-mcp-BWey1L5Y.js} +1 -1
- package/dist/client/assets/useInfiniteQuery-CvMEicTQ.js +1 -0
- package/dist/client/assets/{useQueries-DVb_HjzV.js → useQueries-CSD0nmBi.js} +1 -1
- package/dist/client/assets/{useRouterState-CJ97gzOK.js → useRouterState-Cxw9BBYF.js} +1 -1
- package/dist/client/assets/useSuspenseInfiniteQuery-CtTWf1s0.js +1 -0
- package/dist/client/assets/{users-CX6W_kiO.js → users-cdoSh0K6.js} +1 -1
- package/dist/client/assets/{variant-calendar-BSUlgs-W.js → variant-calendar-R7vv4L9Y.js} +1 -1
- package/dist/client/assets/{view-mode-toggle-DULJqLEB.js → view-mode-toggle-D8EW-zjw.js} +1 -1
- package/dist/client/index.html +1 -1
- package/dist/server/cli.js +178 -177
- package/dist/server/migrate.js +7 -7
- package/dist/server/server.js +145 -145
- package/package.json +1 -1
- package/dist/client/assets/project-app-view-CrBgtatz.js +0 -1
- package/dist/client/assets/record-editor-DUGdKTe8.js +0 -1
- package/dist/client/assets/registry-B4ci0gM-.js +0 -2
- package/dist/client/assets/select-model-Clf7Hlwn.js +0 -4
- package/dist/client/assets/store-registry-Di0pCo7I.js +0 -2
- package/dist/client/assets/useInfiniteQuery-BWd6o-wh.js +0 -1
- package/dist/client/assets/useSuspenseInfiniteQuery-DPyRMURT.js +0 -1
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{c as V,j as s,b as ie,r as U,B as de,m as ce,af as yt,X as Ye,Y as je,F as be,o as _e,Z as Qe,_ as Je,e as ke,K as fe,t as me,p as ue,D as jt,n as St,d as Nt,E as kt,z as wt}from"./index-30J4z2dD.js";import{e as Me,d as Ee,a as Ze,b as Oe,h as et,c as tt,D as Ct}from"./dialog-Ezhjz9E0.js";import{d as It,b as _t,a as Mt,D as Et}from"./drawer-2Y1dMuWR.js";import{u as Ot}from"./use-mobile-DKlFMukO.js";import{c as st,D as Lt,u as Le}from"./chat-context-DUpUs54F.js";import{C as At}from"./checkbox-D-QJq7XZ.js";import{I as xe}from"./input-DO6f6Oyi.js";import{S as Pt,a as Tt,b as Dt,c as zt,d as Rt}from"./select-DHyC2wGe.js";import{S as se}from"./skeleton-I0ZeK4UC.js";import{i as it,b as lt,c as Kt,a as Ft,s as $t}from"./Settings02-CBDIwie_.js";import{d as Ut,a as Bt,b as Wt,i as Vt}from"./Tool01-hFe2UsG9.js";import{i as Ht}from"./Key01-3KmfaqoQ.js";import{i as nt}from"./SearchMd-BOfFIRRH.js";import{d as Ae,u as qt,b as Gt}from"./use-ai-providers-DiMxVRip.js";import{g as Pe}from"./ai-providers-logos-DD3qZ33J.js";import{i as Xt}from"./Monitor01-fc3ZhEXF.js";import{i as Yt}from"./AlertCircle-DcJb8iRa.js";import{S as Ie}from"./spinner-mEqeXw5u.js";import{u as Ce}from"./studio-tools-kQ3NEEWO.js";import{i as Qt}from"./ChevronRight-D5LzDyDE.js";import{A as Jt}from"./avatar-CPVdCa-q.js";import{S as ze,a as Re,b as ot}from"./settings-section-BgDF_9yt.js";import{s as rt}from"./Eye-Bbyfcz3U.js";import{s as Zt,D as es}from"./tab-id-C4bMCjr3.js";import{u as ts}from"./use-is-desktop-app-BNujXJc_.js";import{i as ss}from"./Check-gjVkLyjz.js";import{a as is}from"./Copy01-xzQ4ogmG.js";import{t as Ke}from"./ChevronDown-C6lfFArn.js";import{t as ls}from"./Stars01-C-4SXXn7.js";function ge(l){const e=V.c(3),{size:t}=l,i=t===void 0?16:t;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsx("path",{d:"M13 12L18.5 5M7.63965 3L12.5 12L13.6865 3M4.48381 6.71679L11.9872 12M3 12L11.9872 12.473M12.2244 13.177L7 20M4.84194 16.8682L11.2824 12.9758M11.5 21L12.665 13.177M21 14L13.1846 12.668M21 10.5788L13 12.3223M16.779 19.646L12.8876 13.3772M19.3566 18.207L13.313 12.9893"}),e[0]=n):n=e[0];let o;return e[1]!==i?(o=s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",width:i,height:i,fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:n}),e[1]=i,e[2]=o):o=e[2],o}function ve(l){const e=V.c(3),{size:t}=l,i=t===void 0?16:t;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsx("path",{clipRule:"evenodd",d:"M8.086.457a6.105 6.105 0 013.046-.415c1.333.153 2.521.72 3.564 1.7a.117.117 0 00.107.029c1.408-.346 2.762-.224 4.061.366l.063.03.154.076c1.357.703 2.33 1.77 2.918 3.198.278.679.418 1.388.421 2.126a5.655 5.655 0 01-.18 1.631.167.167 0 00.04.155 5.982 5.982 0 011.578 2.891c.385 1.901-.01 3.615-1.183 5.14l-.182.22a6.063 6.063 0 01-2.934 1.851.162.162 0 00-.108.102c-.255.736-.511 1.364-.987 1.992-1.199 1.582-2.962 2.462-4.948 2.451-1.583-.008-2.986-.587-4.21-1.736a.145.145 0 00-.14-.032c-.518.167-1.04.191-1.604.185a5.924 5.924 0 01-2.595-.622 6.058 6.058 0 01-2.146-1.781c-.203-.269-.404-.522-.551-.821a7.74 7.74 0 01-.495-1.283 6.11 6.11 0 01-.017-3.064.166.166 0 00.008-.074.115.115 0 00-.037-.064 5.958 5.958 0 01-1.38-2.202 5.196 5.196 0 01-.333-1.589 6.915 6.915 0 01.188-2.132c.45-1.484 1.309-2.648 2.577-3.493.282-.188.55-.334.802-.438.286-.12.573-.22.861-.304a.129.129 0 00.087-.087A6.016 6.016 0 015.635 2.31C6.315 1.464 7.132.846 8.086.457zm-.804 7.85a.848.848 0 00-1.473.842l1.694 2.965-1.688 2.848a.849.849 0 001.46.864l1.94-3.272a.849.849 0 00.007-.854l-1.94-3.393zm5.446 6.24a.849.849 0 000 1.695h4.848a.849.849 0 000-1.696h-4.848z"}),e[0]=n):n=e[0];let o;return e[1]!==i?(o=s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",width:i,height:i,fill:"currentColor",fillRule:"evenodd","aria-hidden":"true",children:n}),e[1]=i,e[2]=o):o=e[2],o}const ns={"claude-code":{labelKey:"chat.agentIcons.claudeCode",Icon:ge},codex:{labelKey:"chat.agentIcons.codex",Icon:ve}};function nl(l){return(l&&ns[l])??null}const Fe="bunx decocms@latest link",os=[{capability:"claude-code",labelKey:"chat.connectDesktopDialog.agentClaudeCodeLabel",descriptionKey:"chat.connectDesktopDialog.agentClaudeCodeDescription",icon:s.jsx(ge,{size:18})},{capability:"codex",labelKey:"chat.connectDesktopDialog.agentCodexLabel",descriptionKey:"chat.connectDesktopDialog.agentCodexDescription",icon:s.jsx(ve,{size:18})}];function rs(l){const e=V.c(46),{open:t,onOpenChange:i}=l,n=ie();let o;e[0]!==t?(o={fast:t},e[0]=t,e[1]=o):o=e[1];const r=st(o),[c,u]=U.useState(!1);let d,a,h,p,m,f,b,N;if(e[2]!==r.hostname||e[3]!==r.machineId||e[4]!==r.online||e[5]!==i||e[6]!==t||e[7]!==n){const w=r.hostname??r.machineId??n("chat.connectDesktopDialog.yourDesktop");p=Me,b=t,N=i,h=Ee,f="sm:max-w-md",a=Ze,d=Oe,m=r.online?n("chat.connectDesktopDialog.connectedTo",{desktopName:w}):n("chat.connectDesktopDialog.connectYourDesktop"),e[2]=r.hostname,e[3]=r.machineId,e[4]=r.online,e[5]=i,e[6]=t,e[7]=n,e[8]=d,e[9]=a,e[10]=h,e[11]=p,e[12]=m,e[13]=f,e[14]=b,e[15]=N}else d=e[8],a=e[9],h=e[10],p=e[11],m=e[12],f=e[13],b=e[14],N=e[15];let y;e[16]!==d||e[17]!==m?(y=s.jsx(d,{children:m}),e[16]=d,e[17]=m,e[18]=y):y=e[18];let j;e[19]!==r.online||e[20]!==n?(j=r.online?n("chat.connectDesktopDialog.machineAgentsDescription"):n("chat.connectDesktopDialog.runCommandDescription"),e[19]=r.online,e[20]=n,e[21]=j):j=e[21];let C;e[22]!==j?(C=s.jsx(et,{children:j}),e[22]=j,e[23]=C):C=e[23];let E;e[24]!==a||e[25]!==y||e[26]!==C?(E=s.jsxs(a,{children:[y,C]}),e[24]=a,e[25]=y,e[26]=C,e[27]=E):E=e[27];let M;e[28]!==c||e[29]!==r.online?(M=!r.online&&s.jsxs("div",{className:"flex items-center gap-2 rounded-md bg-muted px-3 py-2 font-mono text-sm",children:[s.jsx("span",{className:"flex-1",children:Fe}),s.jsx(de,{type:"button",variant:"ghost",size:"icon-sm",onClick:()=>{navigator.clipboard.writeText(Fe).then(()=>{u(!0),setTimeout(()=>u(!1),1500)})},children:c?s.jsx(ss,{size:14}):s.jsx(is,{size:14})})]}),e[28]=c,e[29]=r.online,e[30]=M):M=e[30];let I;e[31]!==r.capabilities||e[32]!==r.online||e[33]!==n?(I=r.online?s.jsx("div",{className:"flex flex-col gap-3 text-sm",children:s.jsx("div",{className:"flex flex-col gap-2",children:os.map(w=>{const _=r.capabilities.includes(w.capability);return s.jsxs("div",{className:ce("flex items-center gap-3 rounded-md border px-3 py-2",_?"border-border bg-background text-foreground":"border-border/60 bg-muted/40 text-muted-foreground"),children:[s.jsx("div",{className:ce("flex size-6 items-center justify-center",_?"text-foreground":"text-muted-foreground"),children:w.icon}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"font-medium",children:n(w.labelKey)}),s.jsx("p",{className:"text-xs text-muted-foreground",children:n(_?w.descriptionKey:"chat.connectDesktopDialog.notDetected")})]}),s.jsx("span",{className:ce("size-2 rounded-full",_?"bg-success":"bg-muted-foreground/30")})]},w.capability)})})}):s.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[s.jsx(Ie,{size:"sm"}),n("chat.connectDesktopDialog.waitingForDesktop")]}),e[31]=r.capabilities,e[32]=r.online,e[33]=n,e[34]=I):I=e[34];let x;e[35]!==h||e[36]!==M||e[37]!==I||e[38]!==f||e[39]!==E?(x=s.jsxs(h,{className:f,children:[E,M,I]}),e[35]=h,e[36]=M,e[37]=I,e[38]=f,e[39]=E,e[40]=x):x=e[40];let k;return e[41]!==p||e[42]!==x||e[43]!==b||e[44]!==N?(k=s.jsx(p,{open:b,onOpenChange:N,children:x}),e[41]=p,e[42]=x,e[43]=b,e[44]=N,e[45]=k):k=e[45],k}function pe(l,e,t){let i=t.initialDeps??[],n,o=!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 n;i=h;let m;if(t.key&&((u=t.debug)!=null&&u.call(t))&&(m=Date.now()),n=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,N=b/16,y=(j,C)=>{for(j=String(j);j.length<C;)j=" "+j;return j};console.info(`%c⏱ ${y(b,5)} /${y(f,5)} ms`,`
|
|
2
|
+
font-size: .6rem;
|
|
3
|
+
font-weight: bold;
|
|
4
|
+
color: hsl(${Math.max(0,Math.min(120-120*N,120))}deg 100% 31%);`,t?.key)}return t?.onChange&&!(o&&t.skipInitialOnChange)&&t.onChange(n),o=!1,n}return r.updateDeps=c=>{i=c},r}function $e(l,e){if(l===void 0)throw new Error("Unexpected undefined");return l}const as=(l,e)=>Math.abs(l-e)<1.01,cs=(l,e,t)=>{let i;return function(...n){l.clearTimeout(i),i=l.setTimeout(()=>e.apply(this,n),t)}},Ue=l=>{const{offsetWidth:e,offsetHeight:t}=l;return{width:e,height:t}},ds=l=>l,us=l=>{const e=Math.max(l.startIndex-l.overscan,0),t=Math.min(l.endIndex+l.overscan,l.count-1),i=[];for(let n=e;n<=t;n++)i.push(n);return i},ms=(l,e)=>{const t=l.scrollElement;if(!t)return;const i=l.targetWindow;if(!i)return;const n=r=>{const{width:c,height:u}=r;e({width:Math.round(c),height:Math.round(u)})};if(n(Ue(t)),!i.ResizeObserver)return()=>{};const o=new i.ResizeObserver(r=>{const c=()=>{const u=r[0];if(u?.borderBoxSize){const d=u.borderBoxSize[0];if(d){n({width:d.inlineSize,height:d.blockSize});return}}n(Ue(t))};l.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(c):c()});return o.observe(t,{box:"border-box"}),()=>{o.unobserve(t)}},Be={passive:!0},We=typeof window>"u"?!0:"onscrollend"in window,hs=(l,e)=>{const t=l.scrollElement;if(!t)return;const i=l.targetWindow;if(!i)return;let n=0;const o=l.options.useScrollendEvent&&We?()=>{}:cs(i,()=>{e(n,!1)},l.options.isScrollingResetDelay),r=a=>()=>{const{horizontal:h,isRtl:p}=l.options;n=h?t.scrollLeft*(p&&-1||1):t.scrollTop,o(),e(n,a)},c=r(!0),u=r(!1);t.addEventListener("scroll",c,Be);const d=l.options.useScrollendEvent&&We;return d&&t.addEventListener("scrollend",u,Be),()=>{t.removeEventListener("scroll",c),d&&t.removeEventListener("scrollend",u)}},fs=(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"]},ps=(l,{adjustments:e=0,behavior:t},i)=>{var n,o;const r=l+e;(o=(n=i.scrollElement)==null?void 0:n.scrollTo)==null||o.call(n,{[i.options.horizontal?"left":"top"]:r,behavior:t})};class xs{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,n;return((n=(i=(t=this.targetWindow)==null?void 0:t.performance)==null?void 0:i.now)==null?void 0:n.call(i))??Date.now()},this.observer=(()=>{let t=null;const i=()=>t||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:t=new this.targetWindow.ResizeObserver(n=>{n.forEach(o=>{const r=()=>{const c=o.target,u=this.indexFromElement(c);if(!c.isConnected){this.observer.unobserve(c);return}this.shouldMeasureDuringScroll(u)&&this.resizeItem(u,this.options.measureElement(c,o,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()})}));return{disconnect:()=>{var n;(n=i())==null||n.disconnect(),t=null},observe:n=>{var o;return(o=i())==null?void 0:o.observe(n,{box:"border-box"})},unobserve:n=>{var o;return(o=i())==null?void 0:o.unobserve(n)}}})(),this.range=null,this.setOptions=t=>{Object.entries(t).forEach(([i,n])=>{typeof n>"u"&&delete t[i]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:ds,rangeExtractor:us,onChange:()=>{},measureElement:fs,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,n;(n=(i=this.options).onChange)==null||n.call(i,this,t)},this.maybeNotify=pe(()=>(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(n=>{this.observer.observe(n)}),this.unsubs.push(this.options.observeElementRect(this,n=>{this.scrollRect=n,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(n,o)=>{this.scrollAdjustments=0,this.scrollDirection=o?this.getScrollOffset()<n?"forward":"backward":null,this.scrollOffset=n,this.isScrolling=o,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 n=new Map,o=new Map;for(let r=i-1;r>=0;r--){const c=t[r];if(n.has(c.lane))continue;const u=o.get(c.lane);if(u==null||c.end>u.end?o.set(c.lane,c):c.end<u.end&&n.set(c.lane,!0),n.size===this.options.lanes)break}return o.size===this.options.lanes?Array.from(o.values()).sort((r,c)=>r.end===c.end?r.index-c.index:r.end-c.end)[0]:void 0},this.getMeasurementOptions=pe(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode],(t,i,n,o,r,c,u)=>(this.prevLanes!==void 0&&this.prevLanes!==c&&(this.lanesChangedFlag=!0),this.prevLanes=c,this.pendingMeasuredCacheIndexes=[],{count:t,paddingStart:i,scrollMargin:n,getItemKey:o,enabled:r,lanes:c,laneAssignmentMode:u}),{key:!1}),this.getMeasurements=pe(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:t,paddingStart:i,scrollMargin:n,getItemKey:o,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=o(m),b=this.laneAssignments.get(m);let N,y;const j=u==="estimate"||d.has(f);if(b!==void 0&&this.options.lanes>1){N=b;const I=p[N],x=I!==void 0?h[I]:void 0;y=x?x.end+this.options.gap:i+n}else{const I=this.options.lanes===1?h[m-1]:this.getFurthestMeasurement(h,m);y=I?I.end+this.options.gap:i+n,N=I?I.lane:m%this.options.lanes,this.options.lanes>1&&j&&this.laneAssignments.set(m,N)}const C=d.get(f),E=typeof C=="number"?C:this.options.estimateSize(m),M=y+E;h[m]={index:m,start:y,size:E,end:M,key:f,lane:N},p[N]=m}return this.measurementsCache=h,h},{key:!1,debug:()=>this.options.debug}),this.calculateRange=pe(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(t,i,n,o)=>this.range=t.length>0&&i>0?gs({measurements:t,outerSize:i,scrollOffset:n,lanes:o}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=pe(()=>{let t=null,i=null;const n=this.calculateRange();return n&&(t=n.startIndex,i=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,t,i]),[this.options.rangeExtractor,this.options.overscan,this.options.count,t,i]},(t,i,n,o,r)=>o===null||r===null?[]:t({startIndex:o,endIndex:r,overscan:i,count:n}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=t=>{const i=this.options.indexAttribute,n=t.getAttribute(i);return n?parseInt(n,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 n=this.scrollState.index??((i=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))==null?void 0:i.index);if(n!==void 0&&this.range){const o=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),r=Math.max(0,n-o),c=Math.min(this.options.count-1,n+o);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),n=this.options.getItemKey(i),o=this.elementsCache.get(n);o!==t&&(o&&this.observer.unobserve(o),this.observer.observe(t),this.elementsCache.set(n,t)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(i)&&this.resizeItem(i,this.options.measureElement(t,void 0,this))},this.resizeItem=(t,i)=>{var n;const o=this.measurementsCache[t];if(!o)return;const r=this.itemSizeCache.get(o.key)??o.size,c=i-r;c!==0&&(((n=this.scrollState)==null?void 0:n.behavior)!=="smooth"&&(this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(o,c,this):o.start<this.getScrollOffset()+this.scrollAdjustments)&&this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=c,behavior:void 0}),this.pendingMeasuredCacheIndexes.push(o.index),this.itemSizeCache=new Map(this.itemSizeCache.set(o.key,i)),this.notify(!1))},this.getVirtualItems=pe(()=>[this.getVirtualIndexes(),this.getMeasurements()],(t,i)=>{const n=[];for(let o=0,r=t.length;o<r;o++){const c=t[o],u=i[c];n.push(u)}return n},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=t=>{const i=this.getMeasurements();if(i.length!==0)return $e(i[at(0,i.length-1,n=>$e(i[n]).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,n=0)=>{if(!this.scrollElement)return 0;const o=this.getSize(),r=this.getScrollOffset();i==="auto"&&(i=t>=r+o?"end":"start"),i==="center"?t+=(n-o)/2:i==="end"&&(t-=o);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 n=this.getSize(),o=this.getScrollOffset(),r=this.measurementsCache[t];if(!r)return;if(i==="auto")if(r.end>=o+n-this.options.scrollPaddingEnd)i="end";else if(r.start<=o+this.options.scrollPaddingStart)i="start";else return[o,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:n="auto"}={})=>{const o=this.getOffsetForAlignment(t,i),r=this.now();this.scrollState={index:null,align:i,behavior:n,startedAt:r,lastTargetOffset:o,stableFrames:0},this._scrollToOffset(o,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollToIndex=(t,{align:i="auto",behavior:n="auto"}={})=>{t=Math.max(0,Math.min(t,this.options.count-1));const o=this.getOffsetForIndex(t,i);if(!o)return;const[r,c]=o,u=this.now();this.scrollState={index:t,align:c,behavior:n,startedAt:u,lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollBy=(t,{behavior:i="auto"}={})=>{const n=this.getScrollOffset()+t,o=this.now();this.scrollState={index:null,align:"start",behavior:i,startedAt:o,lastTargetOffset:n,stableFrames:0},this._scrollToOffset(n,{adjustments:void 0,behavior:i}),this.scheduleScrollReconcile()},this.getTotalSize=()=>{var t;const i=this.getMeasurements();let n;if(i.length===0)n=this.options.paddingStart;else if(this.options.lanes===1)n=((t=i[i.length-1])==null?void 0:t.end)??0;else{const o=Array(this.options.lanes).fill(null);let r=i.length-1;for(;r>=0&&o.some(c=>c===null);){const c=i[r];o[c.lane]===null&&(o[c.lane]=c.end),r--}n=Math.max(...o.filter(c=>c!==null))}return Math.max(n-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(t,{adjustments:i,behavior:n})=>{this.options.scrollToFn(t,{behavior:n,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,n=i?i[0]:this.scrollState.lastTargetOffset,o=1,r=n!==this.scrollState.lastTargetOffset;if(!r&&as(n,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=o){this.scrollState=null;return}}else this.scrollState.stableFrames=0,r&&(this.scrollState.lastTargetOffset=n,this.scrollState.behavior="auto",this._scrollToOffset(n,{adjustments:void 0,behavior:"auto"}));this.scheduleScrollReconcile()}}const at=(l,e,t,i)=>{for(;l<=e;){const n=(l+e)/2|0,o=t(n);if(o<i)l=n+1;else if(o>i)e=n-1;else return n}return l>0?l-1:0};function gs({measurements:l,outerSize:e,scrollOffset:t,lanes:i}){const n=l.length-1,o=u=>l[u].start;if(l.length<=i)return{startIndex:0,endIndex:n};let r=at(0,n,o,t),c=r;if(i===1)for(;c<n&&l[c].end<t+e;)c++;else if(i>1){const u=Array(i).fill(0);for(;c<n&&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(n,c+(i-1-c%i))}return{startIndex:r,endIndex:c}}const Ve=typeof document<"u"?U.useLayoutEffect:U.useEffect;function vs({useFlushSync:l=!0,...e}){const t=U.useReducer(()=>({}),{})[1],i={...e,onChange:(o,r)=>{var c;l&&r?yt.flushSync(t):t(),(c=e.onChange)==null||c.call(e,o,r)}},[n]=U.useState(()=>new xs(i));return n.setOptions(i),Ve(()=>n._didMount(),[]),Ve(()=>n._willUpdate()),n}function bs(l){return vs({observeElementRect:ms,observeElementOffset:hs,scrollToFn:ps,...l})}const ct=[{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 Se(l){if(l)return ct.find(e=>e.id===l)}const He=4;function ye(l){const e=V.c(8),{logo:t,name:i,description:n,onClick:o}=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(Jt,{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]!==n||e[4]!==i||e[5]!==o||e[6]!==r?(c=s.jsx(ot,{onClick:o,icon:r,title:i,description:n}),e[3]=n,e[4]=i,e[5]=o,e[6]=r,e[7]=c):c=e[7],c}function dt(l){const e=V.c(38),{providers:t,onSelect:i,onShowAll:n}=l,o=ie();let r;e[0]!==t?(r=t.find(Ns),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]!==o){let E;e[7]===Symbol.for("react.memo_cache_sentinel")?(E=(S,O)=>{const T=d[S.id]??Number.MAX_SAFE_INTEGER,P=d[O.id]??Number.MAX_SAFE_INTEGER;return T-P},e[7]=E):E=e[7];const M=t.filter(Ss).sort(E);let I;e[8]!==t?(I=t.find(js),e[8]=t,e[9]=I):I=e[9];const x=I;let k;e[10]===Symbol.for("react.memo_cache_sentinel")?(k=Se("openai"),e[10]=k):k=e[10];const w=k;let _;e[11]!==i?(_=S=>s.jsx(ye,{logo:S.logo,name:S.name,description:S.description,onClick:()=>i({kind:"provider",provider:S})},S.id),e[11]=i,e[12]=_):_=e[12];let v;e[13]!==i||e[14]!==x?(v=x&&w?[s.jsx(ye,{logo:w.logo,name:w.name,description:w.description,onClick:()=>i({kind:"openai-compatible",provider:x,preset:w})},w.id)]:[],e[13]=i,e[14]=x,e[15]=v):v=e[15];let g;e[16]!==i||e[17]!==x||e[18]!==o?(g=x?[...ct.filter(ys).map(S=>s.jsx(ye,{logo:S.logo,name:S.name,description:S.description,onClick:()=>i({kind:"openai-compatible",provider:x,preset:S})},S.id)),s.jsx(ye,{logo:x.logo,name:o("settings.aiProviders.customOpenAiCompatible"),description:o("settings.aiProviders.customOpenAiDescription"),onClick:()=>i({kind:"openai-compatible",provider:x,preset:null})},"custom")]:[],e[16]=i,e[17]=x,e[18]=o,e[19]=g):g=e[19],a=[...M.map(_),...v,...g],e[3]=i,e[4]=t,e[5]=o,e[6]=a}else a=e[6];const h=a,p=h.length-He,m=!!n&&p>0;let f;e[20]!==h||e[21]!==m?(f=m?h.slice(0,He):h,e[20]=h,e[21]=m,e[22]=f):f=e[22];const b=f;let N;e[23]!==c||e[24]!==i||e[25]!==o?(N=c&&s.jsx(ze,{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:o("settings.aiProviders.recommended")}),s.jsx(Re,{className:"relative",children:s.jsx(ye,{logo:c.logo,name:c.name,description:c.description,onClick:()=>i({kind:"provider",provider:c})})})]})}),e[23]=c,e[24]=i,e[25]=o,e[26]=N):N=e[26];let y;e[27]!==p||e[28]!==n||e[29]!==m||e[30]!==o?(y=m&&s.jsx(ot,{onClick:n,title:o(p===1?"settings.aiProviders.moreProvidersSingular":"settings.aiProviders.moreProvidersPlural",{count:p}),action:s.jsx(Qt,{size:16,className:"text-muted-foreground"})}),e[27]=p,e[28]=n,e[29]=m,e[30]=o,e[31]=y):y=e[31];let j;e[32]!==y||e[33]!==b?(j=s.jsx(ze,{children:s.jsxs(Re,{children:[b,y]})}),e[32]=y,e[33]=b,e[34]=j):j=e[34];let C;return e[35]!==N||e[36]!==j?(C=s.jsxs("div",{className:"flex flex-col gap-6",children:[N,j]}),e[35]=N,e[36]=j,e[37]=C):C=e[37],C}function ys(l){return l.id!=="openai"}function js(l){return l.id==="openai-compatible"}function Ss(l){return l.id!=="deco"&&l.id!=="openai-compatible"}function Ns(l){return l.id==="deco"}const ks=Ye({label:je().optional(),apiKey:je().min(1,"API key is required")});function ws(l){const e=V.c(87),{providerId:t,onCancel:i,onSuccess:n}=l,{org:o}=be(),r=Ce(),c=_e(),[u,d]=U.useState(!1),a=ie();let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h={resolver:Qe(ks),defaultValues:{label:"",apiKey:""}},e[0]=h):h=e[0];const{register:p,handleSubmit:m,formState:f}=Je(h),{errors:b}=f;let N;e[1]!==t||e[2]!==r||e[3]!==a?(N=async B=>{await r.call("AI_PROVIDER_KEY_CREATE",{providerId:t,label:B.label||a("settings.connectForms.defaultKeyLabel"),apiKey:B.apiKey})},e[1]=t,e[2]=r,e[3]=a,e[4]=N):N=e[4];let y;e[5]!==n||e[6]!==o||e[7]!==c||e[8]!==a?(y=()=>{c.invalidateQueries({queryKey:fe.aiProviderKeys(o.id)}),c.invalidateQueries({queryKey:fe.aiProviders(o.id)}),me.success(a("settings.connectForms.keySavedSuccess")),n()},e[5]=n,e[6]=o,e[7]=c,e[8]=a,e[9]=y):y=e[9];let j;e[10]!==a?(j=B=>{me.error(a("settings.connectForms.failedSaveKey",{error:B.message}))},e[10]=a,e[11]=j):j=e[11];let C;e[12]!==N||e[13]!==y||e[14]!==j?(C={mutationFn:N,onSuccess:y,onError:j},e[12]=N,e[13]=y,e[14]=j,e[15]=C):C=e[15];const{mutate:E,isPending:M,error:I}=ke(C);let x;e[16]!==E?(x=B=>E(B),e[16]=E,e[17]=x):x=e[17];let k;e[18]!==m||e[19]!==x?(k=m(x),e[18]=m,e[19]=x,e[20]=k):k=e[20];let w;e[21]!==a?(w=a("settings.connectForms.labelField"),e[21]=a,e[22]=w):w=e[22];let _;e[23]!==w?(_=s.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:w}),e[23]=w,e[24]=_):_=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 S;e[29]!==v||e[30]!==g?(S=s.jsx(xe,{placeholder:v,...g,className:"h-8 text-sm"}),e[29]=v,e[30]=g,e[31]=S):S=e[31];let O;e[32]!==_||e[33]!==S?(O=s.jsxs("div",{className:"space-y-1",children:[_,S]}),e[32]=_,e[33]=S,e[34]=O):O=e[34];let T;e[35]!==a?(T=a("settings.connectForms.apiKeyField"),e[35]=a,e[36]=T):T=e[36];let P;e[37]!==T?(P=s.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:T}),e[37]=T,e[38]=P):P=e[38];const L=u?"text":"password";let D;e[39]!==p?(D=p("apiKey"),e[39]=p,e[40]=D):D=e[40];let z;e[41]!==L||e[42]!==D?(z=s.jsx(xe,{type:L,placeholder:"sk-...",...D,className:"ph-no-capture h-8 text-sm pr-8"}),e[41]=L,e[42]=D,e[43]=z):z=e[43];let R;e[44]!==u?(R=()=>d(!u),e[44]=u,e[45]=R):R=e[45];let K;e[46]!==u||e[47]!==a?(K=a(u?"settings.connectForms.hideApiKey":"settings.connectForms.showApiKey"),e[46]=u,e[47]=a,e[48]=K):K=e[48];let W;e[49]!==u?(W=u?s.jsx(it,{size:14}):s.jsx(rt,{size:14}),e[49]=u,e[50]=W):W=e[50];let H;e[51]!==R||e[52]!==K||e[53]!==W?(H=s.jsx("button",{type:"button",onClick:R,"aria-label":K,className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:W}),e[51]=R,e[52]=K,e[53]=W,e[54]=H):H=e[54];let Q;e[55]!==z||e[56]!==H?(Q=s.jsxs("div",{className:"relative",children:[z,H]}),e[55]=z,e[56]=H,e[57]=Q):Q=e[57];let J;e[58]!==b.apiKey?(J=b.apiKey&&s.jsx("p",{className:"text-xs text-destructive",children:b.apiKey.message}),e[58]=b.apiKey,e[59]=J):J=e[59];let X;e[60]!==P||e[61]!==Q||e[62]!==J?(X=s.jsxs("div",{className:"space-y-1",children:[P,Q,J]}),e[60]=P,e[61]=Q,e[62]=J,e[63]=X):X=e[63];let F;e[64]!==I?(F=I&&s.jsx("p",{className:"text-xs text-destructive",children:I.message}),e[64]=I,e[65]=F):F=e[65];let q;e[66]!==a?(q=a("settings.connectForms.cancel"),e[66]=a,e[67]=q):q=e[67];let Y;e[68]!==M||e[69]!==i||e[70]!==q?(Y=s.jsx(de,{type:"button",variant:"ghost",size:"sm",onClick:i,disabled:M,children:q}),e[68]=M,e[69]=i,e[70]=q,e[71]=Y):Y=e[71];let Z;e[72]!==M||e[73]!==a?(Z=a(M?"settings.connectForms.saving":"settings.connectForms.saveKey"),e[72]=M,e[73]=a,e[74]=Z):Z=e[74];let A;e[75]!==M||e[76]!==Z?(A=s.jsx(de,{type:"submit",size:"sm",disabled:M,children:Z}),e[75]=M,e[76]=Z,e[77]=A):A=e[77];let $;e[78]!==Y||e[79]!==A?($=s.jsxs(tt,{children:[Y,A]}),e[78]=Y,e[79]=A,e[80]=$):$=e[80];let G;return e[81]!==O||e[82]!==X||e[83]!==F||e[84]!==$||e[85]!==k?(G=s.jsxs("form",{onSubmit:k,className:"space-y-3",children:[O,X,F,$]}),e[81]=O,e[82]=X,e[83]=F,e[84]=$,e[85]=k,e[86]=G):G=e[86],G}const Cs=Ye({label:je().optional(),baseUrl:je().min(1,"Base URL is required"),apiKey:je().optional()});function Is(l){const e=V.c(105),{preset:t,onCancel:i,onSuccess:n}=l,{org:o}=be(),r=Ce(),c=_e(),[u,d]=U.useState(!1),a=ie();let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=Qe(Cs),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:N}=Je(m),{errors:y}=N;let j;e[3]!==t||e[4]!==r?(j=async he=>{const bt=JSON.stringify({baseUrl:he.baseUrl,apiKey:he.apiKey||""});await r.call("AI_PROVIDER_KEY_CREATE",{providerId:"openai-compatible",label:he.label||t?.name||he.baseUrl,apiKey:bt,...t?{presetId:t.id}:{}})},e[3]=t,e[4]=r,e[5]=j):j=e[5];let C;e[6]!==n||e[7]!==o||e[8]!==c||e[9]!==a?(C=()=>{c.invalidateQueries({queryKey:fe.aiProviderKeys(o.id)}),c.invalidateQueries({queryKey:fe.aiProviders(o.id)}),me.success(a("settings.connectForms.connectionSavedSuccess")),n()},e[6]=n,e[7]=o,e[8]=c,e[9]=a,e[10]=C):C=e[10];let E;e[11]!==a?(E=he=>{me.error(a("settings.connectForms.failedSaveConnection",{error:he.message}))},e[11]=a,e[12]=E):E=e[12];let M;e[13]!==j||e[14]!==C||e[15]!==E?(M={mutationFn:j,onSuccess:C,onError:E},e[13]=j,e[14]=C,e[15]=E,e[16]=M):M=e[16];const{mutate:I,isPending:x,error:k}=ke(M);let w;e[17]!==t||e[18]!==a?(w=t?a("settings.connectForms.labelPlaceholderPreset",{name:t.name}):a("settings.connectForms.labelPlaceholderOpenAiCompatible"),e[17]=t,e[18]=a,e[19]=w):w=e[19];const _=w;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 S;e[23]!==I?(S=he=>I(he),e[23]=I,e[24]=S):S=e[24];let O;e[25]!==b||e[26]!==S?(O=b(S),e[25]=b,e[26]=S,e[27]=O):O=e[27];let T;e[28]!==a?(T=a("settings.connectForms.labelField"),e[28]=a,e[29]=T):T=e[29];let P;e[30]!==T?(P=s.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:T}),e[30]=T,e[31]=P):P=e[31];let L;e[32]!==f?(L=f("label"),e[32]=f,e[33]=L):L=e[33];let D;e[34]!==_||e[35]!==L?(D=s.jsx(xe,{placeholder:_,...L,className:"h-8 text-sm"}),e[34]=_,e[35]=L,e[36]=D):D=e[36];let z;e[37]!==P||e[38]!==D?(z=s.jsxs("div",{className:"space-y-1",children:[P,D]}),e[37]=P,e[38]=D,e[39]=z):z=e[39];let R;e[40]!==g||e[41]!==y||e[42]!==t?.defaultBaseUrl||e[43]!==f||e[44]!==a?(R=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(xe,{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]=R):R=e[45];let K;e[46]!==a?(K=a("settings.connectForms.apiKeyField"),e[46]=a,e[47]=K):K=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 H;e[51]!==W?(H=s.jsxs("span",{className:"text-muted-foreground/60",children:["(",W,")"]}),e[51]=W,e[52]=H):H=e[52];let Q;e[53]!==K||e[54]!==H?(Q=s.jsxs("label",{className:"text-xs font-medium text-muted-foreground",children:[K," ",H]}),e[53]=K,e[54]=H,e[55]=Q):Q=e[55];const J=u?"text":"password";let X;e[56]!==f?(X=f("apiKey"),e[56]=f,e[57]=X):X=e[57];let F;e[58]!==J||e[59]!==X?(F=s.jsx(xe,{type:J,placeholder:"sk-...",...X,className:"ph-no-capture h-8 text-sm pr-8"}),e[58]=J,e[59]=X,e[60]=F):F=e[60];let q;e[61]!==u?(q=()=>d(!u),e[61]=u,e[62]=q):q=e[62];let Y;e[63]!==u||e[64]!==a?(Y=a(u?"settings.connectForms.hideApiKey":"settings.connectForms.showApiKey"),e[63]=u,e[64]=a,e[65]=Y):Y=e[65];let Z;e[66]!==u?(Z=u?s.jsx(it,{size:14}):s.jsx(rt,{size:14}),e[66]=u,e[67]=Z):Z=e[67];let A;e[68]!==q||e[69]!==Y||e[70]!==Z?(A=s.jsx("button",{type:"button",onClick:q,"aria-label":Y,className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:Z}),e[68]=q,e[69]=Y,e[70]=Z,e[71]=A):A=e[71];let $;e[72]!==F||e[73]!==A?($=s.jsxs("div",{className:"relative",children:[F,A]}),e[72]=F,e[73]=A,e[74]=$):$=e[74];let G;e[75]!==Q||e[76]!==$?(G=s.jsxs("div",{className:"space-y-1",children:[Q,$]}),e[75]=Q,e[76]=$,e[77]=G):G=e[77];let B;e[78]!==t?(B=t?.helpText&&s.jsx("p",{className:"text-xs text-muted-foreground",children:t.helpText}),e[78]=t,e[79]=B):B=e[79];let te;e[80]!==k?(te=k&&s.jsx("p",{className:"text-xs text-destructive",children:k.message}),e[80]=k,e[81]=te):te=e[81];let le;e[82]!==a?(le=a("settings.connectForms.cancel"),e[82]=a,e[83]=le):le=e[83];let ne;e[84]!==x||e[85]!==i||e[86]!==le?(ne=s.jsx(de,{type:"button",variant:"ghost",size:"sm",onClick:i,disabled:x,children:le}),e[84]=x,e[85]=i,e[86]=le,e[87]=ne):ne=e[87];let oe;e[88]!==x||e[89]!==a?(oe=a(x?"settings.connectForms.saving":"settings.connectForms.saveConnection"),e[88]=x,e[89]=a,e[90]=oe):oe=e[90];let re;e[91]!==x||e[92]!==oe?(re=s.jsx(de,{type:"submit",size:"sm",disabled:x,children:oe}),e[91]=x,e[92]=oe,e[93]=re):re=e[93];let ae;e[94]!==ne||e[95]!==re?(ae=s.jsxs(tt,{children:[ne,re]}),e[94]=ne,e[95]=re,e[96]=ae):ae=e[96];let ee;return e[97]!==O||e[98]!==z||e[99]!==R||e[100]!==G||e[101]!==B||e[102]!==te||e[103]!==ae?(ee=s.jsxs("form",{onSubmit:O,className:"space-y-3",children:[z,R,G,B,te,ae]}),e[97]=O,e[98]=z,e[99]=R,e[100]=G,e[101]=B,e[102]=te,e[103]=ae,e[104]=ee):ee=e[104],ee}const _s={kind:"closed"};function Ms(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 Es(l){switch(l.kind){case"form":case"oauth-pending":case"provision-pending":case"provision-error":return l.providerId;default:return null}}function Os({open:l,onOpenChange:e,initialProvider:t}){const i=ie(),o=Ae()?.providers??[],{org:r}=be(),c=Ce(),u=_e(),[d,a]=U.useReducer(Ms,_s),h=U.useRef(!1);U.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:fe.aiProviderKeys(r.id)}),u.invalidateQueries({queryKey:fe.aiProviders(r.id)})},{mutate:f}=ke({mutationFn:async({providerId:v,code:g,stateToken:S,label:O})=>(await c.call("AI_PROVIDER_OAUTH_EXCHANGE",{providerId:v,code:g,stateToken:S,label:O}),v),onSuccess:v=>{ue("ai_provider_oauth_succeeded",{provider_id:v}),m();const g=o.find(S=>S.id===v);me.success(i("settings.connectProviderDialog.oauthSuccessMessage",{provider:g?.name??i("settings.connectProviderDialog.defaultProviderName")})),p()},onError:(v,g)=>{ue("ai_provider_oauth_failed",{provider_id:g.providerId,error:v.message}),me.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=>{ue("ai_provider_provision_succeeded",{provider_id:v}),m();const g=o.find(S=>S.id===v);me.success(i("settings.connectProviderDialog.provisionSuccessMessage",{provider:g?.name??i("settings.connectProviderDialog.defaultProviderName")})),p()},onError:(v,g)=>{ue("ai_provider_provision_failed",{provider_id:g,error:v.message}),a({type:"provision-error",error:v.message})}}),N=async v=>{const{provider:g}=v,S=v.kind==="openai-compatible"?v.preset?.id??null:null,O=g.supportedMethods.includes("oauth-pkce"),T=g.supportedMethods.includes("api-key");if(g.supportsProvision===!0){ue("ai_provider_connect_clicked",{provider_id:g.id,method:"provision"}),a({type:"select-provision",providerId:g.id}),b(g.id);return}if(O){ue("ai_provider_connect_clicked",{provider_id:g.id,method:"oauth-pkce"});try{const L=await c.call("AI_PROVIDER_OAUTH_URL",{providerId:g.id,callbackUrl:`${window.location.origin}/oauth/callback/ai-provider`});if(!L?.url)throw new Error("Invalid response from AI_PROVIDER_OAUTH_URL");a({type:"select-oauth",providerId:g.id,stateToken:L.stateToken}),window.open(L.url,"AiProviderOAuth","width=600,height=700")}catch(L){me.error(i("settings.connectProviderDialog.startOAuthFailedMessage",{error:L instanceof Error?L.message:String(L)}))}return}T&&(ue("ai_provider_connect_clicked",{provider_id:g.id,...S!==null?{preset_id:S}:{},method:"api-key"}),a({type:"select-form",providerId:g.id,presetId:S}))},y=U.useRef(N);y.current=N;const j=U.useRef(t);j.current=t,U.useEffect(()=>{!j.current||d.kind!=="grid"||h.current||(h.current=!0,y.current(j.current))},[d.kind]);const C=d.kind==="oauth-pending"?d.stateToken:null,E=d.kind==="oauth-pending"?d.providerId:null;U.useEffect(()=>{if(d.kind!=="oauth-pending")return;let v=!1;const g=d.stateToken,S=d.providerId,O=P=>{if(P.origin!==window.location.origin||P.data?.type!=="AI_PROVIDER_OAUTH_CALLBACK")return;const{code:L,stateToken:D}=P.data;if(D!==g){me.error(i("settings.connectProviderDialog.securityCheckFailedMessage")),a({type:"oauth-failed"});return}v=!0;const z=o.find(R=>R.id===S);f({providerId:S,code:L,stateToken:g,label:z?.name??S})};window.addEventListener("message",O);const T=setTimeout(()=>{v||(ue("ai_provider_oauth_timeout",{provider_id:S}),a({type:"oauth-failed"}),me.error(i("settings.connectProviderDialog.connectionTimedOutMessage")))},12e4);return()=>{window.removeEventListener("message",O),clearTimeout(T)}},[d.kind,C,E,f]);const M=Es(d),I=M?o.find(v=>v.id===M):null,k=(d.kind==="form"&&d.presetId?Se(d.presetId):null)?.name??I?.name??i("settings.connectProviderDialog.defaultTitle"),w=d.kind!=="grid"&&d.kind!=="closed",_=()=>{t?p():a({type:"back"})};return s.jsx(Me,{open:d.kind!=="closed",onOpenChange:v=>!v&&p(),children:s.jsxs(Ee,{className:"sm:max-w-md max-h-[90vh] overflow-y-auto",children:[s.jsxs(Ze,{children:[s.jsxs("div",{className:"flex items-center gap-2",children:[w&&s.jsx(de,{variant:"ghost",size:"icon","aria-label":i("settings.connectProviderDialog.backButtonLabel"),className:"h-7 w-7",onClick:_,children:s.jsx(lt,{size:16})}),s.jsx(Oe,{children:k})]}),d.kind==="grid"&&!t&&s.jsx(et,{children:i("settings.connectProviderDialog.gridDescription")})]}),d.kind==="grid"&&!t&&s.jsx(dt,{providers:o,onSelect:N}),d.kind==="form"&&(d.providerId==="openai-compatible"?s.jsx(Is,{preset:d.presetId?Se(d.presetId):void 0,onCancel:()=>a({type:"back"}),onSuccess:()=>{m(),p()}}):s.jsx(ws,{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(Ie,{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(Ie,{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(Yt,{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(de,{variant:"outline",size:"sm",onClick:()=>a({type:"back"}),children:i("settings.connectProviderDialog.backButton")}),s.jsx(de,{size:"sm",onClick:()=>{a({type:"retry-provision"}),b(d.providerId)},children:i("settings.connectProviderDialog.retryButton")})]})]})]})})}function Ls(){const l=V.c(7),{org:e}=be(),t=Ce();let i;l[0]!==e.id?(i=fe.defaultBrand(e.id),l[0]=e.id,l[1]=i):i=l[1];let n;l[2]!==t?(n=async()=>{const{items:c}=await t.call("BRAND_CONTEXT_LIST",{});return(Array.isArray(c)?c:[]).find(As)??null},l[2]=t,l[3]=n):n=l[3];let o;l[4]!==i||l[5]!==n?(o={queryKey:i,queryFn:n},l[4]=i,l[5]=n,l[6]=o):o=l[6];const{data:r}=St(o);return r??null}function As(l){return l.isDefault&&!l.archivedAt}function Ps(l){const e=l.colors;if(!e)return null;if(Array.isArray(e)){const t=e.find(n=>typeof n=="object"&&n!==null&&"label"in n&&/primary|brand|main/i.test(n.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 Ts(l){const e=V.c(74);let t;e[0]!==l?(t=l===void 0?{}:l,e[0]=l,e[1]=t):t=e[1];const{title:i,description:n,onLocalRuntimePicked:o}=t,r=ie(),{org:c}=be(),{localMode:u}=jt(),d=Ls(),a=st(),h=Lt(),[p,m]=U.useState(null),[f,b]=U.useState(!1),[N,y]=U.useState(!1),[j,C]=U.useState(!1),E=ts();let M;e[2]!==E||e[3]!==a.online?(M=Zt()&&!E&&!a.online,e[2]=E,e[3]=a.online,e[4]=M):M=e[4];const I=M,x=Ae();let k;e[5]!==x?.providers?(k=x?.providers??[],e[5]=x?.providers,e[6]=k):k=e[6];const w=k;let _,v,g;if(e[7]!==d||e[8]!==h||e[9]!==n||e[10]!==a.capabilities||e[11]!==a.online||e[12]!==u||e[13]!==I||e[14]!==o||e[15]!==c.name||e[16]!==r||e[17]!==i){const H=[];if(a.online){if(a.capabilities.includes("claude-code")){let ee;e[21]===Symbol.for("react.memo_cache_sentinel")?(ee=s.jsx(ge,{size:16}),e[21]=ee):ee=e[21],H.push({option:"claude-code-desktop",label:"Claude Code",icon:ee})}if(a.capabilities.includes("codex")){let ee;e[22]===Symbol.for("react.memo_cache_sentinel")?(ee=s.jsx(ve,{size:16}),e[22]=ee):ee=e[22],H.push({option:"codex-desktop",label:"Codex",icon:ee})}}const Q=H.length>0&&h!==null,J=c.name;let X;e[23]!==d?(X=d?Ps(d):null,e[23]=d,e[24]=X):X=e[24];const F=X,q=d?.favicon??d?.logo??null;let Y;e[25]!==J||e[26]!==r||e[27]!==i?(Y=i??(J?r("chat.noAiProviderEmptyState.headingWithOrg",{org:J}):r("chat.noAiProviderEmptyState.headingDefault")),e[25]=J,e[26]=r,e[27]=i,e[28]=Y):Y=e[28];const Z=Y;let A;e[29]!==n||e[30]!==Q||e[31]!==u||e[32]!==r?(A=n??r(Q?"chat.noAiProviderEmptyState.subtitleWithDesktop":u?"chat.noAiProviderEmptyState.subtitleLocalMode":"chat.noAiProviderEmptyState.subtitleDefault"),e[29]=n,e[30]=Q,e[31]=u,e[32]=r,e[33]=A):A=e[33];const $=A,G=!!(q||F);let B;e[34]!==F?(B=F?{backgroundColor:`${F}18`,borderColor:`${F}30`}:void 0,e[34]=F,e[35]=B):B=e[35];const te=B,le=G?"flex items-center justify-center size-14 rounded-2xl border":"flex items-center justify-center size-14 rounded-2xl bg-muted border border-border";_="flex flex-col items-center gap-8 w-full max-w-3xl px-4";let ne;e[36]!==le||e[37]!==te||e[38]!==q||e[39]!==a.online||e[40]!==I||e[41]!==F||e[42]!==r?(ne=q?s.jsx("div",{className:le,style:te,children:s.jsx("img",{src:q,alt:"",className:"size-7 rounded object-contain"})}):s.jsx("button",{type:"button",onClick:()=>I?C(!0):y(!0),"aria-label":I?r("downloadApp.openLabel"):a.online?r("chat.noAiProviderEmptyState.desktopLinkedLabel"):r("chat.noAiProviderEmptyState.connectDesktopLabel"),className:ce(le,"cursor-pointer transition-colors hover:bg-accent"),style:te,children:s.jsxs("span",{className:"relative inline-flex items-center justify-center",children:[s.jsx(Xt,{size:24,style:F?{color:F}:void 0,className:ce(!F&&"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[36]=le,e[37]=te,e[38]=q,e[39]=a.online,e[40]=I,e[41]=F,e[42]=r,e[43]=ne):ne=e[43];let oe;e[44]!==Z?(oe=s.jsx("p",{className:"text-xl font-semibold text-foreground tracking-tight",children:Z}),e[44]=Z,e[45]=oe):oe=e[45];let re;e[46]!==$?(re=s.jsx("p",{className:"text-sm text-muted-foreground max-w-md",children:$}),e[46]=$,e[47]=re):re=e[47];let ae;e[48]!==oe||e[49]!==re?(ae=s.jsxs("div",{className:"space-y-2",children:[oe,re]}),e[48]=oe,e[49]=re,e[50]=ae):ae=e[50],e[51]!==ne||e[52]!==ae?(v=s.jsxs("div",{className:"flex flex-col items-center gap-4 text-center",children:[ne,ae]}),e[51]=ne,e[52]=ae,e[53]=v):v=e[53],g=Q&&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:H.map(ee=>s.jsxs(de,{variant:"default",className:"gap-2",onClick:()=>{h?.setPendingAgentOption(ee.option),o?.(ee.option)},children:[ee.icon,r("chat.noAiProviderEmptyState.useLabel",{label:ee.label})]},ee.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[7]=d,e[8]=h,e[9]=n,e[10]=a.capabilities,e[11]=a.online,e[12]=u,e[13]=I,e[14]=o,e[15]=c.name,e[16]=r,e[17]=i,e[18]=_,e[19]=v,e[20]=g}else _=e[18],v=e[19],g=e[20];let S,O;e[54]===Symbol.for("react.memo_cache_sentinel")?(S=H=>m(H),O=()=>b(!0),e[54]=S,e[55]=O):(S=e[54],O=e[55]);let T;e[56]!==w?(T=s.jsx("div",{className:"w-full",children:s.jsx(dt,{providers:w,onSelect:S,onShowAll:O})}),e[56]=w,e[57]=T):T=e[57];const P=p!==null||f;let L;e[58]===Symbol.for("react.memo_cache_sentinel")?(L=H=>{H||(m(null),b(!1))},e[58]=L):L=e[58];const D=p??void 0;let z;e[59]!==P||e[60]!==D?(z=s.jsx(Os,{open:P,onOpenChange:L,initialProvider:D}),e[59]=P,e[60]=D,e[61]=z):z=e[61];let R;e[62]!==N?(R=s.jsx(rs,{open:N,onOpenChange:y}),e[62]=N,e[63]=R):R=e[63];let K;e[64]!==j?(K=s.jsx(es,{open:j,onOpenChange:C}),e[64]=j,e[65]=K):K=e[65];let W;return e[66]!==z||e[67]!==R||e[68]!==K||e[69]!==_||e[70]!==v||e[71]!==g||e[72]!==T?(W=s.jsxs("div",{className:_,children:[v,g,T,z,R,K]}),e[66]=z,e[67]=R,e[68]=K,e[69]=_,e[70]=v,e[71]=g,e[72]=T,e[73]=W):W=e[73],W}function Te(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 Ds(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 zs=["bg-destructive","bg-warning","bg-success","bg-success"],Rs=["text-success","text-warning","text-warning","text-destructive"];function Ks(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 Fs(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 $s={text:{icon:s.jsx(Wt,{className:"size-3.5"}),labelKey:"chat.shared.capabilityText"},vision:{icon:s.jsx(Bt,{className:"size-3.5"}),labelKey:"chat.shared.capabilityVision"},image:{icon:s.jsx(Kt,{className:"size-3.5"}),labelKey:"chat.shared.capabilityImage"},tools:{icon:s.jsx(Ut,{className:"size-3.5"}),labelKey:"chat.shared.capabilityTools"},reasoning:{icon:s.jsx(ls,{className:"size-3.5"}),labelKey:"chat.shared.capabilityReasoning"},"web-search":{icon:s.jsx(nt,{className:"size-3.5"}),labelKey:"chat.shared.capabilityWebSearch"}};function Us(l){const e=V.c(10),{capability:t}=l,i=ie(),n=$s[t];if(n){const u=n.icon;let d;e[0]!==n.labelKey||e[1]!==i?(d=i(n.labelKey),e[0]=n.labelKey,e[1]=i,e[2]=d):d=e[2];let a;return e[3]!==n.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]=n.icon,e[4]=d,e[5]=a):a=e[5],a}let o;e[6]!==t?(o=t.charAt(0).toUpperCase(),e[6]=t,e[7]=o):o=e[7];const r=o+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 Bs(l){const e=V.c(59),{model:t,compact:i}=l,n=i===void 0?!1:i,o=ie();if(!t){let x;e[0]!==o?(x=o("chat.shared.hoverToPreview"),e[0]=o,e[1]=x):x=e[1];let k;return e[2]!==x?(k=s.jsx("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:x}),e[2]=x,e[3]=k):k=e[3],k}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=Te(t),e[4]=t,e[5]=u):u=e[5];const{provider:d,displayName:a}=u;if(n){let x;e[6]!==t.limits||e[7]!==o?(x=t.limits?.contextWindow&&s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-muted-foreground",children:o("chat.shared.context")}),s.jsxs("span",{className:"text-foreground font-medium",children:[t.limits.contextWindow.toLocaleString()," ",o("chat.shared.tokens")]})]}),e[6]=t.limits,e[7]=o,e[8]=x):x=e[8];let k;e[9]!==r||e[10]!==o?(k=r!=null&&s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-muted-foreground",children:o("chat.shared.input")}),s.jsxs("span",{className:"text-foreground font-medium",children:["$",r.toFixed(2)," / 1M"]})]}),e[9]=r,e[10]=o,e[11]=k):k=e[11];let w;e[12]!==c||e[13]!==o?(w=c!=null&&s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-muted-foreground",children:o("chat.shared.output")}),s.jsxs("span",{className:"text-foreground font-medium",children:["$",c.toFixed(2)," / 1M"]})]}),e[12]=c,e[13]=o,e[14]=w):w=e[14];let _;e[15]!==t.limits||e[16]!==o?(_=t.limits?.maxOutputTokens&&s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-muted-foreground",children:o("chat.shared.outputLimit")}),s.jsxs("span",{className:"text-foreground font-medium",children:[t.limits.maxOutputTokens.toLocaleString()," ",o("chat.shared.tokens")]})]}),e[15]=t.limits,e[16]=o,e[17]=_):_=e[17];let v;return e[18]!==x||e[19]!==k||e[20]!==w||e[21]!==_?(v=s.jsxs("div",{className:"flex flex-col gap-2 pt-3 pb-3 px-3 text-xs",children:[x,k,w,_]}),e[18]=x,e[19]=k,e[20]=w,e[21]=_,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 N;e[35]!==h||e[36]!==f||e[37]!==b?(N=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]=N):N=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(Ws)}),e[39]=t.capabilities,e[40]=y):y=e[40];let j;e[41]!==t.limits||e[42]!==o?(j=t.limits?.contextWindow&&(()=>{const{level:x,labelKey:k,descriptionKey:w}=Ds(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:o("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(_=>s.jsx("div",{className:ce("w-2 h-2 rounded-full",_<=x?zs[x-1]:"bg-muted")},_))}),s.jsx("span",{className:"text-xs text-muted-foreground font-medium",children:o(k)}),s.jsxs("span",{className:"text-xs text-muted-foreground",children:["— ",o(w)]})]}),s.jsxs("span",{className:"text-sm text-muted-foreground",children:[t.limits.contextWindow.toLocaleString()," ",o("chat.shared.tokens")]})]})})(),e[41]=t.limits,e[42]=o,e[43]=j):j=e[43];let C;e[44]!==t.limits||e[45]!==o?(C=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:o("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()," ",o("chat.shared.tokens")]}),s.jsx("span",{className:"text-sm text-muted-foreground",children:Ks(t.limits.maxOutputTokens,o)})]})]}),e[44]=t.limits,e[45]=o,e[46]=C):C=e[46];let E;e[47]!==r||e[48]!==c||e[49]!==o?(E=(r!=null||c!=null)&&(()=>{const{level:x,labelKey:k}=r!=null?Fs(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:o("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(w=>s.jsx("span",{className:ce("text-sm font-bold leading-none",w<=x?Rs[x-1]:"text-muted-foreground/20"),children:"$"},w))}),s.jsx("span",{className:"text-xs text-muted-foreground font-medium",children:k?o(k):""})]}),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:o("chat.shared.input")}),s.jsxs("span",{className:"text-xs text-foreground",children:["$",r.toFixed(2)," / 1M"," ",o("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:o("chat.shared.output")}),s.jsxs("span",{className:"text-xs text-foreground",children:["$",c.toFixed(2)," / 1M"," ",o("chat.shared.tokens")]})]})]})]})})(),e[47]=r,e[48]=c,e[49]=o,e[50]=E):E=e[50];let M;e[51]!==j||e[52]!==C||e[53]!==E?(M=s.jsxs("div",{className:"flex flex-col gap-6",children:[j,C,E]}),e[51]=j,e[52]=C,e[53]=E,e[54]=M):M=e[54];let I;return e[55]!==M||e[56]!==N||e[57]!==y?(I=s.jsxs("div",{className:"flex flex-col gap-5 py-1 px-1.5",children:[N,y,M]}),e[55]=M,e[56]=N,e[57]=y,e[58]=I):I=e[58],I}function Ws(l){return s.jsx(Us,{capability:l},l)}function ut(l){const e=V.c(22),{model:t,placeholder:i,isLoading:n}=l,o=n===void 0?!1:n,r=ie();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(o){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(se,{className:"w-5 h-5 rounded-sm shrink-0"}),s.jsx(se,{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 j;e[6]===Symbol.for("react.memo_cache_sentinel")?(j=s.jsx(Ke,{size:14,className:"text-muted-foreground opacity-50 shrink-0"}),e[6]=j):j=e[6];let C;return e[7]!==y?(C=s.jsxs("div",{className:"flex items-center gap-1.5",children:[y,j]}),e[7]=y,e[8]=C):C=e[8],C}let d;e[9]!==t?(d=Te(t),e[9]=t,e[10]=d):d=e[10];const{displayName:a}=d;let h;e[11]!==t?(h=Pe(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(Ke,{size:14,className:"text-muted-foreground opacity-50 shrink-0"}),e[18]=b):b=e[18];let N;return e[19]!==m||e[20]!==f?(N=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]=N):N=e[21],N}const Vs=["vision","image","file","audio","video"],mt=["image/png","image/jpeg","image/gif","image/webp"],ht=["application/vnd.openxmlformats-officedocument.presentationml.presentation","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"];function De(l){const e=l?.capabilities;return e?Vs.some(t=>e.includes(t)):!1}function ol(l,e){if(!l)return!1;if(l.startsWith("text/"))return!0;const t=e?.capabilities??[],i=t.includes("vision")||t.includes("image"),n=t.includes("file"),o=t.includes("audio"),r=t.includes("video");return!!(i&&mt.includes(l)||n&&l==="application/pdf"||o&&l.startsWith("audio/")||r&&l.startsWith("video/")||De(e)&&ht.includes(l))}function rl(l){const e=l?.capabilities??[],t=["text/*"];return(e.includes("vision")||e.includes("image"))&&t.push(...mt),e.includes("file")&&t.push("application/pdf"),e.includes("audio")&&t.push("audio/*"),e.includes("video")&&t.push("video/*"),De(l)&&t.push(...ht),t.join(",")}function al(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"),De(l)&&t.push("chat.shared.fileTypeOffice"),{parts:t,count:t.length}}const ft=["smarter","faster","cheaper"],Hs={smarter:"chat.decopilot.tierSmarter",faster:"chat.decopilot.tierFaster",cheaper:"chat.decopilot.tierCheaper"},qs=[{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"]}],Gs=qs.flatMap(({tier:l,prefixes:e})=>e.map(t=>({tier:l,prefix:t}))).sort((l,e)=>e.prefix.length-l.prefix.length),Xs="google/gemini-2.5-pro",qe=new Map;function Ys(l){const e=qe.get(l);if(e!==void 0)return e;let t=null;if(l.endsWith(":free"))t="cheaper";else for(const{tier:i,prefix:n}of Gs)if(l.startsWith(n)){if(n===Xs&&l.length>n.length&&l[n.length]==="-"){const r=l[n.length+1];if(!r||!/\d/.test(r))continue}t=i;break}return qe.set(l,t),t}function Ge(l){const e={smarter:[],faster:[],cheaper:[],other:[]};for(const t of l){const i=Ys(t.modelId);e[i??"other"].push(t)}for(const t of Object.keys(e))e[t].sort((i,n)=>i.title.localeCompare(n.title));return e}const pt="studio:model-shortlist:",Qs=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 Js(l){try{const e=localStorage.getItem(pt+l);return e?new Set(JSON.parse(e)):null}catch{return null}}function Zs(l,e){localStorage.setItem(pt+l,JSON.stringify([...e]))}function ei(l){const e=V.c(21),{model:t,onHover:i}=l;let n;e[0]!==t?(n=Te(t),e[0]=t,e[1]=n):n=e[1];const{displayName:o,provider:r}=n;let c;e[2]!==t?(c=Pe(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]!==o?(h=s.jsx("span",{className:"text-sm text-foreground leading-tight truncate",children:o}),e[10]=o,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 ti(l){const e=V.c(16),{error:t,onRetry:i}=l,n=ie();let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=s.jsx("div",{className:"bg-destructive/10 p-2 rounded-full",children:s.jsx(wt,{className:"size-5 text-destructive"})}),e[0]=o):o=e[0];const r=n("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||n("chat.decopilot.couldNotFetchModels"),d=" "+n("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($t,{className:"size-3.5"}),e[9]=p):p=e[9];const m=n("chat.decopilot.retry");let f;e[10]!==i||e[11]!==m?(f=s.jsx("div",{className:"flex items-center gap-2",children:s.jsxs(de,{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:[o,h,f]}),e[13]=f,e[14]=h,e[15]=b):b=e[15],b}function si(){const l=V.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(ii)}),l[0]=e):e=l[0],e}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(se,{className:"size-5 shrink-0 rounded-sm"}),s.jsx(se,{className:"flex-1 h-4"}),s.jsx(se,{className:"w-16 h-5 shrink-0 rounded-md"})]},e)}function Xe(l){const e=V.c(12),{label:t,models:i,onSelect:n,onHover:o}=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]!==o||e[4]!==n){let d;e[6]!==o||e[7]!==n?(d=a=>s.jsx("div",{onClick:()=>n(a),className:"cursor-pointer",children:s.jsx(ei,{model:a,onHover:o})},a.modelId),e[6]=o,e[7]=n,e[8]=d):d=e[8],c=i.map(d),e[2]=i,e[3]=o,e[4]=n,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 we(l,e){return e(l==="other"?"chat.decopilot.tierOther":Hs[l])}function li(l){const e=V.c(21),{model:t,isChecked:i,onToggle:n,onHover:o}=l,[r,c]=U.useState(i);r!==i&&c(i);let u;e[0]!==t?(u=Pe(t),e[0]=t,e[1]=u):u=e[1];const d=u;let a;e[2]!==t||e[3]!==o?(a=()=>o(t),e[2]=t,e[3]=o,e[4]=a):a=e[4];let h;e[5]!==t.modelId||e[6]!==n?(h=()=>{c(ni),n(t.modelId)},e[5]=t.modelId,e[6]=n,e[7]=h):h=e[7];let p;e[8]!==r||e[9]!==h?(p=s.jsx(At,{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 ni(l){return!l}function oi(l,e){const t=[];for(const i of ft)if(l[i].length>0){t.push({type:"header",label:we(i,e)});for(const n of l[i])t.push({type:"model",model:n})}if(l.other.length>0){t.push({type:"header",label:we("other",e)});for(const i of l.other)t.push({type:"model",model:i})}return t}function ri({items:l,shortlistSet:e,onToggle:t,onHover:i}){const n=U.useRef(null),o=bs({count:l.length,getScrollElement:()=>n.current,estimateSize:r=>l[r]?.type==="header"?36:44,overscan:6});return s.jsx("div",{ref:n,className:"flex-1 overflow-y-auto",children:s.jsx("div",{className:"relative",style:{height:o.getTotalSize()},children:o.getVirtualItems().map(r=>{const c=l[r.index];return c?s.jsx("div",{"data-index":r.index,ref:o.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(li,{model:c.model,isChecked:e.has(c.model.modelId),onToggle:t,onHover:i})},r.key):null})})})}function ai(l){const e=V.c(30),{keyId:t,searchTerm:i,onHover:n,onModelSelect:o,managing:r,onToggleManage:c,filterModels:u}=l,d=ie(),{models:a}=Gt(t),h=u?a.filter(u):a.filter(ci);let p;e[0]!==t?(p=()=>(t?Js(t):null)??Qs,e[0]=t,e[1]=p):p=e[1];const[m,f]=U.useState(p),[,b]=U.useTransition();let N;e[2]!==t||e[3]!==b?(N=g=>{t&&b(()=>{f(S=>{const O=new Set(S);return O.has(g)?O.delete(g):O.add(g),Zs(t,O),O})})},e[2]=t,e[3]=b,e[4]=N):N=e[4];const y=N,j=i.toLowerCase().trim(),C=g=>j?g.filter(S=>S.title.toLowerCase().includes(j)||S.modelId.toLowerCase().includes(j)):g;if(r){const g=Ge(C(h)),S=oi(g,d);let O;e[5]!==m?(O=z=>m.has(z.modelId),e[5]=m,e[6]=O):O=e[6];const T=h.filter(O).length;let P;e[7]===Symbol.for("react.memo_cache_sentinel")?(P=s.jsx(lt,{size:14}),e[7]=P):P=e[7];let L;e[8]!==d?(L=d("chat.decopilot.back"),e[8]=d,e[9]=L):L=e[9];let D;return e[10]!==c||e[11]!==L?(D=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:[P,L]}),e[10]=c,e[11]=L,e[12]=D):D=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:[D,s.jsx("span",{className:"text-xs text-muted-foreground",children:d("chat.decopilot.selectedCount",{count:T})})]}),s.jsx(ri,{items:S,shortlistSet:m,onToggle:y,onHover:n})]})}let E;e[13]!==m?(E=g=>m.has(g.modelId),e[13]=m,e[14]=E):E=e[14];const M=h.filter(E),I=M.length>0?M:h,x=Ge(C(I));let k;e[15]!==x||e[16]!==n||e[17]!==o||e[18]!==d?(k=ft.map(g=>s.jsx(Xe,{label:we(g,d),models:x[g],onSelect:o,onHover:n},g)),e[15]=x,e[16]=n,e[17]=o,e[18]=d,e[19]=k):k=e[19];let w;e[20]!==d?(w=we("other",d),e[20]=d,e[21]=w):w=e[21];let _;e[22]!==x.other||e[23]!==n||e[24]!==o||e[25]!==w?(_=s.jsx(Xe,{label:w,models:x.other,onSelect:o,onHover:n}),e[22]=x.other,e[23]=n,e[24]=o,e[25]=w,e[26]=_):_=e[26];let v;return e[27]!==k||e[28]!==_?(v=s.jsxs("div",{className:"flex-1 overflow-y-auto px-0.5 pt-1 [touch-action:pan-y]",children:[k,_]}),e[27]=k,e[28]=_,e[29]=v):v=e[29],v}function ci(l){return l.asyncResearch!==!0}function di(){const l=V.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(se,{className:"size-4 shrink-0"}),s.jsx(se,{className:"flex-1 h-6"}),s.jsx(se,{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(ui)})]}),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(se,{className:"size-6 shrink-0"}),s.jsx(se,{className:"h-6 w-32"})]}),l[2]=i):i=l[2];let n;l[3]===Symbol.for("react.memo_cache_sentinel")?(n=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(se,{className:"h-6 w-20 rounded-md"}),s.jsx(se,{className:"h-6 w-24 rounded-md"})]})]}),l[3]=n):n=l[3];let o;l[4]===Symbol.for("react.memo_cache_sentinel")?(o=s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsx(se,{className:"h-4 w-24"}),s.jsx(se,{className:"h-4 w-32"})]}),l[4]=o):o=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:[n,s.jsxs("div",{className:"flex flex-col gap-4",children:[o,s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsx(se,{className:"h-4 w-16"}),s.jsx(se,{className:"h-4 w-40"})]})]})]})})]}),l[5]=r):r=l[5],r}function ui(l,e){return s.jsxs("div",{className:"flex items-center gap-2 min-h-8 py-3 px-3 rounded-lg",children:[s.jsx(se,{className:"size-5 shrink-0 rounded-sm"}),s.jsx(se,{className:"flex-1 h-4"}),s.jsx(se,{className:"w-16 h-5 shrink-0 rounded-md"})]},e)}function xt(l){const e=V.c(66),{onClose:t,credentialId:i,onCredentialChange:n,selectedModel:o,onModelChange:r,filterModels:c,compact:u}=l,d=ie(),[a,h]=U.useState(null),[p,m]=U.useState(""),[f,b]=U.useState(!1),N=U.useRef(null),y=Ae(),j=qt();let C;e[0]!==y?.providers?(C=Object.fromEntries((y?.providers??[]).map(fi)),e[0]=y?.providers,e[1]=C):C=e[1];const E=C,M=Nt(),{org:I}=be();let x;e[2]!==n?(x=A=>{n(A),h(null)},e[2]=n,e[3]=x):x=e[3];const k=x;let w;e[4]!==i||e[5]!==t||e[6]!==r?(w=A=>{i&&(r(A),m(""),t())},e[4]=i,e[5]=t,e[6]=r,e[7]=w):w=e[7];const _=w;if(j.length===0){const A=!u&&"sm:w-[740px]";let $;e[8]!==A?($=ce("flex items-center justify-center p-8 w-full",A),e[8]=A,e[9]=$):$=e[9];let G;e[10]===Symbol.for("react.memo_cache_sentinel")?(G=s.jsx(Ts,{}),e[10]=G):G=e[10];let B;return e[11]!==$?(B=s.jsx("div",{className:$,children:G}),e[11]=$,e[12]=B):B=e[12],B}const v=u?"sm:h-[420px]":"sm:h-[460px]";let g;e[13]!==v?(g=ce("flex flex-col md:flex-row h-full min-h-0",v),e[13]=v,e[14]=g):g=e[14];const S=u?"w-full":"md:border-r md:w-[420px] md:min-w-[420px]";let O;e[15]!==S?(O=ce("flex-1 flex flex-col min-h-0 overflow-hidden",S),e[15]=S,e[16]=O):O=e[16];let T;e[17]===Symbol.for("react.memo_cache_sentinel")?(T=s.jsx(nt,{size:16,className:"text-muted-foreground shrink-0"}),e[17]=T):T=e[17];let P;e[18]!==f||e[19]!==d?(P=d(f?"chat.decopilot.searchAllModels":"chat.decopilot.searchForModel"),e[18]=f,e[19]=d,e[20]=P):P=e[20];let L;e[21]===Symbol.for("react.memo_cache_sentinel")?(L=A=>m(A.target.value),e[21]=L):L=e[21];let D;e[22]!==p||e[23]!==P?(D=s.jsx(xe,{ref:N,type:"text",placeholder:P,value:p,onChange:L,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]=P,e[24]=D):D=e[24];let z;e[25]!==i||e[26]!==k||e[27]!==j||e[28]!==E||e[29]!==d?(z=j.length>0&&s.jsxs(Pt,{value:i??"",onValueChange:k,children:[s.jsxs(Tt,{size:"sm",className:"w-auto max-w-[140px] h-8 shrink-0 gap-1.5 px-2 [&>svg:last-child]:hidden",onClick:hi,children:[s.jsx(Dt,{placeholder:d("chat.decopilot.key"),children:(()=>{const A=j.find(le=>le.id===i),$=A?E[A.providerId]:void 0,G=Se(A?.presetId),B=G?.logo??$?.logo,te=G?.name??$?.name??A?.providerId??"Key";return s.jsxs("span",{className:"flex items-center gap-1.5 min-w-0",children:[B?s.jsx("img",{src:B,alt:te,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:te.slice(0,1).toUpperCase()}),s.jsx("span",{className:"text-xs truncate",children:te})]})})()}),s.jsx(Vt,{className:"size-4 opacity-50 shrink-0 pointer-events-none"})]}),s.jsx(zt,{children:j.map(A=>{const $=E[A.providerId],G=Se(A.presetId),B=G?.logo??$?.logo,te=G?.name??$?.name??A.providerId;return s.jsx(Rt,{value:A.id,children:s.jsxs("div",{className:"flex items-center gap-2",children:[B?s.jsx("img",{src:B,alt:te,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:te.slice(0,1).toUpperCase()}),s.jsxs("span",{children:[te," — ",A.label]})]})},A.id)})})]}),e[25]=i,e[26]=k,e[27]=j,e[28]=E,e[29]=d,e[30]=z):z=e[30];let R;e[31]!==D||e[32]!==z?(R=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,D,z]})}),e[31]=D,e[32]=z,e[33]=R):R=e[33];let K;e[34]!==i?(K=A=>{const{error:$,resetError:G}=A;return s.jsx(ti,{error:$,onRetry:G,credentialId:i??void 0})},e[34]=i,e[35]=K):K=e[35];let W;e[36]===Symbol.for("react.memo_cache_sentinel")?(W=s.jsx(si,{}),e[36]=W):W=e[36];const H=i??void 0;let Q;e[37]===Symbol.for("react.memo_cache_sentinel")?(Q=()=>b(mi),e[37]=Q):Q=e[37];let J;e[38]!==c||e[39]!==_||e[40]!==f||e[41]!==p||e[42]!==H?(J=s.jsx(U.Suspense,{fallback:W,children:s.jsx(ai,{keyId:H,searchTerm:p,onHover:h,onModelSelect:_,managing:f,onToggleManage:Q,filterModels:c})}),e[38]=c,e[39]=_,e[40]=f,e[41]=p,e[42]=H,e[43]=J):J=e[43];let X;e[44]!==i||e[45]!==K||e[46]!==J?(X=s.jsx(kt,{fallback:K,children:J},i),e[44]=i,e[45]=K,e[46]=J,e[47]=X):X=e[47];let F;e[48]!==f||e[49]!==M||e[50]!==I||e[51]!==d?(F=!f&&s.jsxs("div",{className:"border-t border-border flex",children:[s.jsxs("button",{type:"button",onClick:()=>U.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(Ft,{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:()=>M({to:"/$org/settings/ai-providers",params:{org:I.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(Ht,{className:"size-3.5 shrink-0"}),d("chat.decopilot.manageApiKeys")]})]}),e[48]=f,e[49]=M,e[50]=I,e[51]=d,e[52]=F):F=e[52];let q;e[53]!==R||e[54]!==X||e[55]!==F||e[56]!==O?(q=s.jsxs("div",{className:O,children:[R,X,F]}),e[53]=R,e[54]=X,e[55]=F,e[56]=O,e[57]=q):q=e[57];let Y;e[58]!==u||e[59]!==a||e[60]!==o?(Y=!u&&s.jsx("div",{className:"hidden md:flex md:flex-col md:w-[320px] md:shrink-0 p-3",children:s.jsx(Bs,{model:a??o??null})}),e[58]=u,e[59]=a,e[60]=o,e[61]=Y):Y=e[61];let Z;return e[62]!==q||e[63]!==Y||e[64]!==g?(Z=s.jsxs("div",{className:g,children:[q,Y]}),e[62]=q,e[63]=Y,e[64]=g,e[65]=Z):Z=e[65],Z}function mi(l){return!l}function hi(l){return l.stopPropagation()}function fi(l){return[l.id,l]}function pi(l){const e=V.c(12),{onClose:t}=l,{credentialId:i,setCredentialId:n,selectedModel:o,setModel:r}=Le();let c;e[0]!==n?(c=a=>{ue("chat_credential_changed",{credential_id:a}),n(a)},e[0]=n,e[1]=c):c=e[1];let u;e[2]!==i||e[3]!==o?.modelId||e[4]!==r?(u=a=>{i&&(ue("chat_model_changed",{from_model_id:o?.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]=o?.modelId,e[4]=r,e[5]=u):u=e[5];let d;return e[6]!==i||e[7]!==t||e[8]!==o||e[9]!==c||e[10]!==u?(d=s.jsx(xt,{onClose:t,credentialId:i,onCredentialChange:c,selectedModel:o,onModelChange:u}),e[6]=i,e[7]=t,e[8]=o,e[9]=c,e[10]=u,e[11]=d):d=e[11],d}function xi(l){const e=V.c(2),{onClose:t}=l;let i;return e[0]!==t?(i=s.jsx(pi,{onClose:t}),e[0]=t,e[1]=i):i=e[1],i}function gi(l){const e=V.c(2);let t;return e[0]!==l?(t=s.jsx(xt,{...l}),e[0]=l,e[1]=t):t=e[1],t}const vi=[{tier:"fast",labelKey:"chat.desktopCli.tierFastDescription"},{tier:"smart",labelKey:"chat.desktopCli.tierSmartDescription"},{tier:"thinking",labelKey:"chat.desktopCli.tierThinkingDescription"}];function gt(l){const e=V.c(11),{modelSet:t,selectedModelId:i,onSelect:n}=l,o=ie();let r,c;if(e[0]!==t.logo||e[1]!==t.models||e[2]!==t.tiers||e[3]!==n||e[4]!==i||e[5]!==o){const d=Object.fromEntries(t.models.map(bi));r="flex flex-col p-2 w-[320px]",c=vi.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:()=>n(f),className:ce("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:o(p)})]})]},h)}),e[0]=t.logo,e[1]=t.models,e[2]=t.tiers,e[3]=n,e[4]=i,e[5]=o,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 bi(l){return[l.modelId,l]}const yi=[{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}],Ne="https://assets.decocache.com/decocms/6ac44f1c-c0cf-4480-84b5-2ae6fe742d0b/codex-app.png.png",ji=[{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:Ne,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:Ne,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:Ne,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:Ne,limits:null,costs:null}],Si="https://decoims.com/decocms/93e4059c-e598-412b-87eb-54d72a946ec8/claude-stroke-rounded.svg",Ni="https://decoims.com/decocms/9170ffd4-b9cc-4661-ad8f-ae2eea019e00/codex.svg";function ki(l){return{fast:{modelId:"claude-code:haiku",label:l("chat.agentModels.haikuLabel"),description:l("chat.agentModels.quickerResponses"),iconNode:s.jsx(ge,{size:16})},smart:{modelId:"claude-code:sonnet",label:l("chat.agentModels.sonnetLabel"),description:l("chat.agentModels.balancedQuality"),iconNode:s.jsx(ge,{size:16})},thinking:{modelId:"claude-code:opus-1m",label:l("chat.agentModels.opusLabel"),description:l("chat.agentModels.deeperReasoning"),iconNode:s.jsx(ge,{size:16})}}}function wi(l){return{fast:{modelId:"codex:gpt-5.6-luna",label:l("chat.agentModels.gptLunaLabel"),description:l("chat.agentModels.quickerResponses"),iconNode:s.jsx(ve,{size:16})},smart:{modelId:"codex:gpt-5.6-terra",label:l("chat.agentModels.gptTerraLabel"),description:l("chat.agentModels.balancedQuality"),iconNode:s.jsx(ve,{size:16})},thinking:{modelId:"codex:gpt-5.6-sol",label:l("chat.agentModels.gptSolLabel"),description:l("chat.agentModels.deeperReasoning"),iconNode:s.jsx(ve,{size:16})}}}function vt(l,e){return l==="claude-code"?{logo:Si,tiers:ki(e),models:yi}:l==="codex"?{logo:Ni,tiers:wi(e),models:ji}:null}function Ci(l){const e=V.c(12),{onClose:t,agent:i}=l,n=ie(),o=Le(),r=i??o.pendingHarnessId??"decopilot";let c;e[0]!==r||e[1]!==n?(c=vt(r,n),e[0]=r,e[1]=n,e[2]=c):c=e[2];const u=c;if(!u){let p;return e[3]!==t?(p=s.jsx(xi,{onClose:t}),e[3]=t,e[4]=p):p=e[4],p}const d=o.selectedModel?.modelId??u.tiers[o.simpleModeTier].modelId;let a;e[5]!==t||e[6]!==o?(a=p=>{o.setModel({...p,keyId:void 0}),t()},e[5]=t,e[6]=o,e[7]=a):a=e[7];let h;return e[8]!==u||e[9]!==d||e[10]!==a?(h=s.jsx(gt,{modelSet:u,selectedModelId:d,onSelect:a}),e[8]=u,e[9]=d,e[10]=a,e[11]=h):h=e[11],h}function Ii(l){const e=V.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 n=ie();let o;e[3]!==t||e[4]!==n?(o=t?vt(t,n):null,e[3]=t,e[4]=n,e[5]=o):o=e[5];const r=o;if(!r){let a;return e[6]!==i?(a=s.jsx(gi,{...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(gt,{modelSet:r,selectedModelId:c,onSelect:u}),e[10]=r,e[11]=c,e[12]=u,e[13]=d):d=e[13],d}function cl(l){const e=V.c(49),{variant:t,className:i,placeholder:n,model:o,isLoading:r,credentialId:c,onCredentialChange:u,onModelChange:d,filterModels:a,agent:h}=l,p=t===void 0?"borderless":t,m=n===void 0?"Select model":n,f=ie(),[b,N]=U.useState(!1),y=d!==void 0,j=Ot(),C=p==="borderless"?"ghost":"outline",E=p==="borderless"&&"md:border-none";let M;e[0]!==i||e[1]!==E?(M=ce("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",E,i),e[0]=i,e[1]=E,e[2]=M):M=e[2];let I;e[3]!==r||e[4]!==o||e[5]!==m||e[6]!==y?(I=y?s.jsx(ut,{model:o??null,placeholder:m,isLoading:r}):s.jsx(Mi,{placeholder:m}),e[3]=r,e[4]=o,e[5]=m,e[6]=y,e[7]=I):I=e[7];let x;e[8]!==C||e[9]!==M||e[10]!==I?(x=s.jsx(de,{variant:C,size:"sm",className:M,children:I}),e[8]=C,e[9]=M,e[10]=I,e[11]=x):x=e[11];const k=x;let w;e[12]===Symbol.for("react.memo_cache_sentinel")?(w=s.jsx(di,{}),e[12]=w):w=e[12];let _;e[13]!==h||e[14]!==c||e[15]!==a||e[16]!==o||e[17]!==u||e[18]!==d||e[19]!==y?(_=s.jsx(U.Suspense,{fallback:w,children:y?s.jsx(Ii,{onClose:()=>N(!1),agent:h,credentialId:c??null,onCredentialChange:u??_i,selectedModel:o??null,onModelChange:d,filterModels:a}):s.jsx(Ci,{onClose:()=>N(!1),agent:h})}),e[13]=h,e[14]=c,e[15]=a,e[16]=o,e[17]=u,e[18]=d,e[19]=y,e[20]=_):_=e[20];const v=_;if(j){let L;e[21]!==k?(L=s.jsx(It,{asChild:!0,children:k}),e[21]=k,e[22]=L):L=e[22];let D;e[23]!==f?(D=f("chat.selectModel.selectModel"),e[23]=f,e[24]=D):D=e[24];let z;e[25]!==D?(z=s.jsx(_t,{className:"sr-only",children:D}),e[25]=D,e[26]=z):z=e[26];let R;e[27]!==v?(R=s.jsx("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:v}),e[27]=v,e[28]=R):R=e[28];let K;e[29]!==z||e[30]!==R?(K=s.jsxs(Mt,{className:"p-0 flex flex-col max-h-[95vh]",children:[z,R]}),e[29]=z,e[30]=R,e[31]=K):K=e[31];let W;return e[32]!==b||e[33]!==L||e[34]!==K?(W=s.jsxs(Et,{open:b,onOpenChange:N,children:[L,K]}),e[32]=b,e[33]=L,e[34]=K,e[35]=W):W=e[35],W}let g;e[36]!==k?(g=s.jsx(Ct,{asChild:!0,children:k}),e[36]=k,e[37]=g):g=e[37];let S;e[38]!==f?(S=f("chat.selectModel.selectModel"),e[38]=f,e[39]=S):S=e[39];let O;e[40]!==S?(O=s.jsx(Oe,{className:"sr-only",children:S}),e[40]=S,e[41]=O):O=e[41];let T;e[42]!==v||e[43]!==O?(T=s.jsxs(Ee,{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:[O,v]}),e[42]=v,e[43]=O,e[44]=T):T=e[44];let P;return e[45]!==b||e[46]!==g||e[47]!==T?(P=s.jsxs(Me,{open:b,onOpenChange:N,children:[g,T]}),e[45]=b,e[46]=g,e[47]=T,e[48]=P):P=e[48],P}function _i(){}function Mi(l){const e=V.c(4),{placeholder:t}=l,{selectedModel:i,isModelsLoading:n}=Le();let o;return e[0]!==n||e[1]!==i||e[2]!==t?(o=s.jsx(ut,{model:i,placeholder:t,isLoading:n}),e[0]=n,e[1]=i,e[2]=t,e[3]=o):o=e[3],o}export{rs as C,di as M,Ts as N,dt as P,Ii as a,ge as b,ve as c,rl as d,cl as e,Se as f,al as g,Os as h,ol as i,nl as l,De 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-2KxPRjw5.js";import{W as mt,g as Dt,u as ze,S as Pt}from"./use-mcp-client-DRwUSZdO.js";import{I as Ge}from"./integration-icon-DKBuU8Fr.js";import{c as Ce,b as ft,h as pt,a as gt,d as ht,e as xt}from"./dialog-C82H2S70.js";import{c as Be,T as Me,a as Ve}from"./tooltip-CEu_we5y.js";import{k as bt,f as Ct,a as $t}from"./agent-icon-q4cV7U67.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-6m5dy3es.js";import{i as yt}from"./CheckCircle-IiUO6eKZ.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-DAiRK0vx.js";import{I as Ee}from"./input-BAuCATqg.js";import{i as Ht}from"./Check-DdyKCl8O.js";import{a as vt}from"./Copy01-Cv0Vuqbe.js";import{i as Wt}from"./Settings02-Sy5kNpSu.js";import{s as Yt}from"./Eye-CkjEvMwH.js";import{u as Zt}from"./use-debounced-value-IOz7dnNR.js";import{f as jt,a as Xt,p as Jt}from"./provision-repo-scoped-github-connection-C2RHf8fG.js";import{c as en,e as tn}from"./extract-connection-data-B9TIJ0UC.js";import{u as nn}from"./useQueries-DVb_HjzV.js";import{a as on}from"./authenticate-and-persist-oauth-Dx2DT3YD.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-30J4z2dD.js";import{W as mt,g as Dt,u as ze,S as Pt}from"./use-mcp-client-BsWOvAzd.js";import{I as Ge}from"./integration-icon-gnw4DLPa.js";import{c as Ce,b as ft,h as pt,a as gt,d as ht,e as xt}from"./dialog-Ezhjz9E0.js";import{c as Be,T as Me,a as Ve}from"./tooltip-B-SCkbF9.js";import{k as bt,f as Ct,a as $t}from"./agent-icon-D5JzlR5X.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-BQihQDwO.js";import{i as yt}from"./CheckCircle-Brw1At1c.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-CdwOvuuM.js";import{I as Ee}from"./input-DO6f6Oyi.js";import{i as Ht}from"./Check-gjVkLyjz.js";import{a as vt}from"./Copy01-xzQ4ogmG.js";import{i as Wt}from"./Settings02-CBDIwie_.js";import{s as Yt}from"./Eye-Bbyfcz3U.js";import{u as Zt}from"./use-debounced-value-C8ryVVpy.js";import{f as jt,a as Xt,p as Jt}from"./provision-repo-scoped-github-connection-C2RHf8fG.js";import{c as en,e as tn}from"./extract-connection-data-DNA7o6q8.js";import{u as nn}from"./useQueries-CSD0nmBi.js";import{a as on}from"./authenticate-and-persist-oauth-DqnkEHz5.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};
|