decocms 4.123.2 → 4.123.3
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-XCC42vnv.js → AlertCircle-eRcWDqyz.js} +1 -1
- package/dist/client/assets/{AreaChart-BbeQRNr_.js → AreaChart-CWCyj3e3.js} +1 -1
- package/dist/client/assets/{ArrowRight-BKBmhaLR.js → ArrowRight-p9iPk5i0.js} +1 -1
- package/dist/client/assets/{ArrowUp-CIc1qLBi.js → ArrowUp-DpycHbYJ.js} +1 -1
- package/dist/client/assets/{ArrowUpRight-BfP64txw.js → ArrowUpRight-CfTkoU4B.js} +1 -1
- package/dist/client/assets/{Check-BqbTs6Sp.js → Check-BdLBTBRG.js} +1 -1
- package/dist/client/assets/{CheckCircle-BPEhKJ6_.js → CheckCircle-CCKZTxeZ.js} +1 -1
- package/dist/client/assets/{ChevronDown-BeuEDkJI.js → ChevronDown-Bx3JuxA4.js} +1 -1
- package/dist/client/assets/{ChevronRight-CpxTzNTm.js → ChevronRight-CFrIQqny.js} +1 -1
- package/dist/client/assets/{ChevronUp-tFv_O9M0.js → ChevronUp-Dq6n-X7O.js} +1 -1
- package/dist/client/assets/{Copy01-DqXF8bW_.js → Copy01-XmlYTCnq.js} +1 -1
- package/dist/client/assets/{DotsVertical-Ue6eGmYj.js → DotsVertical-ws7g1gHH.js} +1 -1
- package/dist/client/assets/{Eye-Bk2Xgrvg.js → Eye-BBuEG2Wd.js} +1 -1
- package/dist/client/assets/{FilterLines-8U9bkKls.js → FilterLines-C8U7CVV9.js} +1 -1
- package/dist/client/assets/{Globe01-D61pxNbc.js → Globe01-C4KqixhG.js} +1 -1
- package/dist/client/assets/{Globe04-BVIaxGYK.js → Globe04-BqWPfPhC.js} +1 -1
- package/dist/client/assets/{HardDrive-Dp3ZELAy.js → HardDrive-C_ycSVMi.js} +1 -1
- package/dist/client/assets/{Image01-C0tZD_4N.js → Image01-DVjQLwZ-.js} +1 -1
- package/dist/client/assets/{Key01-C1OrSDs9.js → Key01-FIEtfPiH.js} +1 -1
- package/dist/client/assets/{LayoutLeft-BR0426bP.js → LayoutLeft-Dnm3NgQz.js} +1 -1
- package/dist/client/assets/{LinkExternal01-Dbdi7ThP.js → LinkExternal01-DunixMNV.js} +1 -1
- package/dist/client/assets/{LogOut01-BGKt8uk-.js → LogOut01-DlvBCesx.js} +1 -1
- package/dist/client/assets/{Monitor01-BpV1xCDw.js → Monitor01-JoeiLfz-.js} +1 -1
- package/dist/client/assets/{Package-CPikbMFw.js → Package-fVT5gTF_.js} +1 -1
- package/dist/client/assets/{Palette-CI2gPMub.js → Palette-BWnu1KwQ.js} +1 -1
- package/dist/client/assets/{Play-Ce8b-45f.js → Play-HYSZBOc2.js} +1 -1
- package/dist/client/assets/{Plus-BHn273te.js → Plus-CyjW8iPH.js} +1 -1
- package/dist/client/assets/{SearchLg-BhaN5Dkw.js → SearchLg-B2jol46R.js} +1 -1
- package/dist/client/assets/{SearchMd-ZOU8eHm5.js → SearchMd-DkKUttLm.js} +1 -1
- package/dist/client/assets/{Settings02-BMEbk95n.js → Settings02-BrdhYfJi.js} +1 -1
- package/dist/client/assets/{Shield01-ByBmvv87.js → Shield01-B1XsHete.js} +1 -1
- package/dist/client/assets/{Star01-CXoaBlcx.js → Star01-Hbm6yGaD.js} +1 -1
- package/dist/client/assets/{Stars01-DzME0iEm.js → Stars01-DipJVSzo.js} +1 -1
- package/dist/client/assets/{Stars02-aAWJ3II4.js → Stars02-D2qzcZbs.js} +1 -1
- package/dist/client/assets/{Sun-BvXvztsJ.js → Sun-D9gwkrf5.js} +1 -1
- package/dist/client/assets/{SwitchHorizontal01-D0-CcWGL.js → SwitchHorizontal01-Bt3ZhF2O.js} +1 -1
- package/dist/client/assets/{Tool01-CsQku2ha.js → Tool01-DvE5TzJB.js} +1 -1
- package/dist/client/assets/{Tool02-9ZNic0qo.js → Tool02-_NBLVeeV.js} +1 -1
- package/dist/client/assets/{Trash01-DxhoFTU2.js → Trash01-BepZYT7H.js} +1 -1
- package/dist/client/assets/{TrendUp01-DolEYhiE.js → TrendUp01-BKJLyuI9.js} +1 -1
- package/dist/client/assets/{Upload01-Cw1RTJdA.js → Upload01-BubHQTIU.js} +1 -1
- package/dist/client/assets/{User01-B9tHPp45.js → User01-DkpYEYe6.js} +1 -1
- package/dist/client/assets/{Users01-CtZ6-BIN.js → Users01-DjvWkBZ9.js} +1 -1
- package/dist/client/assets/{Users03-DKzOXdwZ.js → Users03-Ci9mYAgC.js} +1 -1
- package/dist/client/assets/{X-BlyIKSVp.js → X-HQl8Aj_L.js} +1 -1
- package/dist/client/assets/{XCircle-BS-TfzRr.js → XCircle-BizT01hc.js} +1 -1
- package/dist/client/assets/{XClose-CRX1ODGE.js → XClose-CcoerXx4.js} +1 -1
- package/dist/client/assets/{Zap-BbOt7jmA.js → Zap-BF-fUeLE.js} +1 -1
- package/dist/client/assets/{ZapSquare-CmpVcXwq.js → ZapSquare-vjVCshpw.js} +1 -1
- package/dist/client/assets/{ZoomOut-0gQoEQDY.js → ZoomOut-B_jcciLR.js} +1 -1
- package/dist/client/assets/{access-gate-BVvy6Xvh.js → access-gate-BqHB36ZF.js} +1 -1
- package/dist/client/assets/{add-section-modal-Q5ILcd5n.js → add-section-modal-CQaBEUCu.js} +1 -1
- package/dist/client/assets/{agent-icon-D8X6NgHQ.js → agent-icon-ibE4Mzzu.js} +1 -1
- package/dist/client/assets/{agents-list-Djdw5X52.js → agents-list-0DDVnJrl.js} +1 -1
- package/dist/client/assets/{ai-providers-CZhLConq.js → ai-providers-DqD3zgSv.js} +1 -1
- package/dist/client/assets/{alert-DZt6s1-5.js → alert-DDQjZ7Sa.js} +1 -1
- package/dist/client/assets/{alert-dialog-BbSxHfpk.js → alert-dialog-BWhpN8gU.js} +1 -1
- package/dist/client/assets/{app-editor-meMLTo05.js → app-editor-DVkvKRDN.js} +1 -1
- package/dist/client/assets/{auth-C0wxe8j1.js → auth-D8HvRHHP.js} +1 -1
- package/dist/client/assets/{auth-catchall-y2fJEFYv.js → auth-catchall-C_KTlh8d.js} +1 -1
- package/dist/client/assets/{auth-entry-DcpdTLhj.js → auth-entry-DyZakAOt.js} +1 -1
- package/dist/client/assets/{auth-split-layout-BKK4N-N6.js → auth-split-layout-C79zlQMZ.js} +1 -1
- package/dist/client/assets/{authenticate-and-persist-oauth-Bkljayza.js → authenticate-and-persist-oauth-D2zBt4t0.js} +1 -1
- package/dist/client/assets/{automation-list-row-BjXQjt1z.js → automation-list-row-7FNfxpyb.js} +1 -1
- package/dist/client/assets/{automation-runs-B-1RH_oI.js → automation-runs-cQOAIuK1.js} +1 -1
- package/dist/client/assets/{automations-B_fbLWl9.js → automations-DFHU57uN.js} +1 -1
- package/dist/client/assets/{autosend-Be-3DD9j.js → autosend-Btkz6-0l.js} +1 -1
- package/dist/client/assets/{avatar-CfUWjhDf.js → avatar-DtoeWk0Z.js} +1 -1
- package/dist/client/assets/{badge-DF-If9rp.js → badge-Coz8TMU0.js} +1 -1
- package/dist/client/assets/{block-document-QDu2JdkJ.js → block-document-TkTeRgax.js} +1 -1
- package/dist/client/assets/{brand-context-dVMghOOW.js → brand-context-DyrNgbHb.js} +1 -1
- package/dist/client/assets/{buckets-Buo3pKQm.js → buckets-jEkDUMWc.js} +1 -1
- package/dist/client/assets/{bulk-category-panel-CvwIPpKb.js → bulk-category-panel-DcFs9iGz.js} +1 -1
- package/dist/client/assets/{calendar-DDdEu02Z.js → calendar-CUO5b1ow.js} +1 -1
- package/dist/client/assets/{capability-load-error-B47bErtJ.js → capability-load-error-B7XmMBaL.js} +1 -1
- package/dist/client/assets/{card-Di-QpnW-.js → card-OSM07-YE.js} +1 -1
- package/dist/client/assets/{category-editor-BYmynf3_.js → category-editor-Kdrp5Ecc.js} +1 -1
- package/dist/client/assets/{chat-context-Bnmr5Esu.js → chat-context-DoZ1baNe.js} +1 -1
- package/dist/client/assets/{checkbox-Ca7NY1wR.js → checkbox-5Dqb50rX.js} +1 -1
- package/dist/client/assets/{cli-auth-success-BM4UbwaW.js → cli-auth-success-5-sqgCR1.js} +1 -1
- package/dist/client/assets/{collection-detail-C_jvvVx2.js → collection-detail-BtHBlghi.js} +1 -1
- package/dist/client/assets/{collection-display-button-Dvi-6XHb.js → collection-display-button-CnPuuZw0.js} +1 -1
- package/dist/client/assets/{collection-search-2V1qih3c.js → collection-search-5eKJWC8a.js} +1 -1
- package/dist/client/assets/{collection-table-wrapper-CVTrxPz3.js → collection-table-wrapper-Bt4X8CDw.js} +1 -1
- package/dist/client/assets/{collection-tabs-u1HJ_eBo.js → collection-tabs-CNvc5FXj.js} +1 -1
- package/dist/client/assets/{command-DfYO983M.js → command-F60Vvdw9.js} +1 -1
- package/dist/client/assets/{commerce-onboarding--4NONN4b.js → commerce-onboarding-9CZnisfq.js} +1 -1
- package/dist/client/assets/{companions-core-BBPRO-hx.js → companions-core-DlPclFME.js} +1 -1
- package/dist/client/assets/{connect-CxMb3kaP.js → connect-Ce_xd66Z.js} +1 -1
- package/dist/client/assets/{connect-desktop-dialog-CVoQrJ8F.js → connect-desktop-dialog-DUZxmsUO.js} +1 -1
- package/dist/client/assets/{connection-BbilOib-.js → connection-DvYP4ame.js} +1 -1
- package/dist/client/assets/{connection-card-DrMoCtl4.js → connection-card-Cdfh1gnU.js} +1 -1
- package/dist/client/assets/{connection-detail-DhhlgQDD.js → connection-detail-q5RUuSrv.js} +1 -1
- package/dist/client/assets/{connection-form-helpers-jobllNge.js → connection-form-helpers-ofcrOZAr.js} +1 -1
- package/dist/client/assets/{connections-Cbwi0auT.js → connections-eosewDDm.js} +1 -1
- package/dist/client/assets/{decopilot-sse-pool-BuymyfF0.js → decopilot-sse-pool-BjZ-wPbg.js} +1 -1
- package/dist/client/assets/{dialog-poX5N6OF.js → dialog-CKP-t2d8.js} +1 -1
- package/dist/client/assets/{domain-settings-Bf7aOGCi.js → domain-settings-Bg5U7NKI.js} +1 -1
- package/dist/client/assets/{drawer-CemU5qiA.js → drawer-DQHW9t04.js} +1 -1
- package/dist/client/assets/{dropdown-menu-C_IfrJtZ.js → dropdown-menu-ylG9Kkc3.js} +1 -1
- package/dist/client/assets/{empty-state-BPgoMkQH.js → empty-state-C08XplZ3.js} +1 -1
- package/dist/client/assets/{extract-connection-data-BP-6YHKf.js → extract-connection-data-C_r5IGMb.js} +1 -1
- package/dist/client/assets/{file-explorer-Ba3Y3MJx.js → file-explorer-CICAaSO_.js} +1 -1
- package/dist/client/assets/{file-type-icon-CCvkC4UX.js → file-type-icon-BlvOD0PX.js} +1 -1
- package/dist/client/assets/{files-z7S0toY0.js → files-Dp05Y0HV.js} +1 -1
- package/dist/client/assets/{form-CBy1yFE7.js → form-BOHVNPhz.js} +1 -1
- package/dist/client/assets/{general-CT5NFN2-.js → general-BRGJds_Q.js} +1 -1
- package/dist/client/assets/{github-repo-picker-WGLIOn68.js → github-repo-picker-DcHCLyjR.js} +1 -1
- package/dist/client/assets/{hooks-DO_GgbQ9.js → hooks-C9juaECv.js} +1 -1
- package/dist/client/assets/{index-BYB7faC2.js → index-4jOyya6Y.js} +1 -1
- package/dist/client/assets/{index-BTDLuR6K.js → index-70mmTZc_.js} +1 -1
- package/dist/client/assets/index-BgF6OVaJ.css +1 -0
- package/dist/client/assets/{index-CrVcfr0w.js → index-Bp_8bhFo.js} +3 -3
- package/dist/client/assets/{index-DAtTWfgt.js → index-C7paW5qO.js} +3 -3
- package/dist/client/assets/{index-NwnGjivz.js → index-CCsdUvVs.js} +1 -1
- package/dist/client/assets/{index-BUOc0Rlo.js → index-CHQBwCua.js} +1 -1
- package/dist/client/assets/{index-BZketn2G.js → index-COt3Wzd4.js} +1 -1
- package/dist/client/assets/{index-AqXdWiS8.js → index-CeSX2hgY.js} +1 -1
- package/dist/client/assets/{index-yo4ZLMjW.js → index-CpkyNb-g.js} +1 -1
- package/dist/client/assets/{index-COExXZVa.js → index-CvSG3gCR.js} +5 -5
- package/dist/client/assets/{index-BipIQ3Z0.js → index-DIGsSdbK.js} +1 -1
- package/dist/client/assets/{index-Dd3322Xk.js → index-DvmOfoBg.js} +1 -1
- package/dist/client/assets/{index-C8Q5qfXW.js → index-mMZ1-UT7.js} +1 -1
- package/dist/client/assets/{index-redirect-XUFJEhWY.js → index-redirect-DowabVtC.js} +1 -1
- package/dist/client/assets/{input-BTaZQTwt.js → input-B7NjdaWP.js} +1 -1
- package/dist/client/assets/{integration-icon-BFQyCHkv.js → integration-icon-DEmdrigW.js} +1 -1
- package/dist/client/assets/{invite-member-dialog-UtoUhAQN.js → invite-member-dialog-Do_rh2sG.js} +1 -1
- package/dist/client/assets/{label-CFiSNSYm.js → label-BsC9V_2x.js} +1 -1
- package/dist/client/assets/{layout-DNQqS4dI.js → layout-DttsLFsc.js} +1 -1
- package/dist/client/assets/{login-x836Suod.js → login-Bc-4_kHz.js} +1 -1
- package/dist/client/assets/{mcp-oauth-DjzzahSx.js → mcp-oauth-iPqAJoGm.js} +1 -1
- package/dist/client/assets/{members-C0PCyfD6.js → members-Df_EE43H.js} +1 -1
- package/dist/client/assets/{monaco-editor-BQlr5iHl.js → monaco-editor-B9OF3jRu.js} +1 -1
- package/dist/client/assets/{monitoring-stats-row-CYTksZ0o.js → monitoring-stats-row-BPtjhObG.js} +1 -1
- package/dist/client/assets/{multi-select-g0Zcdpuc.js → multi-select-B8L-uR0Z.js} +1 -1
- package/dist/client/assets/{oauth-callback-CUqReAyz.js → oauth-callback-Dr5zVhyV.js} +1 -1
- package/dist/client/assets/{oauth-callback-ai-provider-BO8s14-F.js → oauth-callback-ai-provider-DMC1bSAT.js} +1 -1
- package/dist/client/assets/{onboarding-ifaPlnD7.js → onboarding-fiTo09oR.js} +1 -1
- package/dist/client/assets/{org-install-HCRLLUwR.js → org-install-B2bM7ppY.js} +1 -1
- package/dist/client/assets/{org-layout-37oPrsYr.js → org-layout-DZyE1NBJ.js} +1 -1
- package/dist/client/assets/{organization-choice-D4wTlG5B.js → organization-choice-CSaGCmhQ.js} +1 -1
- package/dist/client/assets/{orgs-CO8Ia10y.js → orgs-DQh8lqIU.js} +1 -1
- package/dist/client/assets/{page-seo-form-BElu4PcX.js → page-seo-form-BGL3rL7i.js} +1 -1
- package/dist/client/assets/page-seo-sheet-CsLUJ1Yf.js +1 -0
- package/dist/client/assets/{popover-6uiYyt5u.js → popover-BARdtmQ6.js} +1 -1
- package/dist/client/assets/{post-editor-CsfSnGeq.js → post-editor-C7J0K8nu.js} +1 -1
- package/dist/client/assets/{primitives-BQwrCqaw.js → primitives-DLF6JtPS.js} +1 -1
- package/dist/client/assets/{profile-BLmFaHgn.js → profile-BqTzXs9x.js} +1 -1
- package/dist/client/assets/project-app-view-4XZrS0Mr.js +1 -0
- package/dist/client/assets/record-editor-YzJoN9bv.js +1 -0
- package/dist/client/assets/{redirect-editor-CAt-r8L6.js → redirect-editor-YHB4gvcQ.js} +1 -1
- package/dist/client/assets/registry-DKMLAjwr.js +2 -0
- package/dist/client/assets/{registry-layout-DzeMIQ1B.js → registry-layout-C0zwUwDi.js} +1 -1
- package/dist/client/assets/{reports-CjTucZb2.js → reports-BG46h4YF.js} +1 -1
- package/dist/client/assets/{require-capability-AlDMTe2M.js → require-capability-l1pPM6L3.js} +1 -1
- package/dist/client/assets/{required-auth-layout-CxsIwght.js → required-auth-layout-Dgwezb2q.js} +1 -1
- package/dist/client/assets/{reset-password-fK3yI8C1.js → reset-password-C7WC8kCI.js} +1 -1
- package/dist/client/assets/{roles-8n-_hcZU.js → roles-55zZDlTP.js} +1 -1
- package/dist/client/assets/{search-input-BIlo3d_x.js → search-input-Rf45slkr.js} +1 -1
- package/dist/client/assets/{secrets-C5IXt4y-.js → secrets-CumVvXzE.js} +1 -1
- package/dist/client/assets/{sections-editor-C5e3xbtX.js → sections-editor-AIZ_vXyM.js} +1 -1
- package/dist/client/assets/{select-C-lRFMd0.js → select-Cofdiz7g.js} +1 -1
- package/dist/client/assets/{select-model-CnP2KvlX.js → select-model-CQjdy8JP.js} +1 -1
- package/dist/client/assets/{self-tool-result-WKXfGLIo.js → self-tool-result-CZ8BrxAv.js} +1 -1
- package/dist/client/assets/{seo-editor-DDHhP88k.js → seo-editor-Bg3KN1r0.js} +1 -1
- package/dist/client/assets/{settings-layout-Bv0OyYHJ.js → settings-layout-BO3edXkv.js} +1 -1
- package/dist/client/assets/{settings-section-DcvaTSLo.js → settings-section-CW4yLPtI.js} +1 -1
- package/dist/client/assets/{shell-controls-7jsmZLrB.js → shell-controls-cEHP32Pv.js} +1 -1
- package/dist/client/assets/{shell-layout-CxYEqHLt.js → shell-layout-BbDwMSR1.js} +1 -1
- package/dist/client/assets/{sidebar-BAm9qD2e.js → sidebar-CsCKy7i2.js} +1 -1
- package/dist/client/assets/{skeleton-rk4WuHqh.js → skeleton-C6T-49IJ.js} +1 -1
- package/dist/client/assets/{sso-CzAtA7Zs.js → sso-D-Fm27Br.js} +1 -1
- package/dist/client/assets/{store-DTElmzZA.js → store-BizgsZ6V.js} +1 -1
- package/dist/client/assets/store-registry-BSBzU8Cs.js +2 -0
- package/dist/client/assets/{studio-tools-B1eVxu6k.js → studio-tools-BgcbqxiX.js} +1 -1
- package/dist/client/assets/{switch-DItIkDat.js → switch-CcOR9vLu.js} +1 -1
- package/dist/client/assets/{table-Cp9c4BcU.js → table-BAGpdfFB.js} +1 -1
- package/dist/client/assets/{tabs-D7y8E5Ya.js → tabs-BBIq1chp.js} +1 -1
- package/dist/client/assets/{textarea-uMNP0LCC.js → textarea-Cu9wZQ0x.js} +1 -1
- package/dist/client/assets/{toggle-group-BqEa1TEc.js → toggle-group-3NzAw3cD.js} +1 -1
- package/dist/client/assets/{toolbar-Dk_EQcxK.js → toolbar-BCd7IYjs.js} +1 -1
- package/dist/client/assets/{toolbar-icon-button-B3a3a06z.js → toolbar-icon-button-CdCR26vG.js} +1 -1
- package/dist/client/assets/{tooltip-D1kWwXpZ.js → tooltip-Du-iZy7N.js} +1 -1
- package/dist/client/assets/{use-ai-providers-laCpnXdd.js → use-ai-providers-DVcvRuW8.js} +1 -1
- package/dist/client/assets/{use-api-keys-CsDXZwqL.js → use-api-keys-V0LOyd3c.js} +1 -1
- package/dist/client/assets/{use-automations-BfXgjd_V.js → use-automations-CEI45ay4.js} +1 -1
- package/dist/client/assets/{use-autosave-BAraq6AW.js → use-autosave-CJsA34KG.js} +1 -1
- package/dist/client/assets/{use-capability-DzC2Klfd.js → use-capability-Cx0l8hzs.js} +1 -1
- package/dist/client/assets/{use-clock-tick-DRjNjgqA.js → use-clock-tick-C_-xNV1u.js} +1 -1
- package/dist/client/assets/{use-connection-Bmwh1M0H.js → use-connection-IvaPXMMI.js} +1 -1
- package/dist/client/assets/{use-copy-CnoszhL7.js → use-copy-B_1XRnig.js} +1 -1
- package/dist/client/assets/{use-create-virtual-mcp-BsqQsVxp.js → use-create-virtual-mcp-CIJjVQB3.js} +1 -1
- package/dist/client/assets/{use-debounced-autosave-BCK-z4zD.js → use-debounced-autosave-Br4PVksK.js} +1 -1
- package/dist/client/assets/{use-debounced-value-CV3OhKhZ.js → use-debounced-value-DbPd-3pt.js} +1 -1
- package/dist/client/assets/{use-deco-credits-DJYZaYfn.js → use-deco-credits-FKsuCiez.js} +1 -1
- package/dist/client/assets/{use-decopilot-events-CJAX9qbZ.js → use-decopilot-events-DbYP1aYj.js} +1 -1
- package/dist/client/assets/{use-delete-connection-BbE8VrIR.js → use-delete-connection-5AZ2BCY9.js} +1 -1
- package/dist/client/assets/{use-deployment-admin-BB1Jrj8e.js → use-deployment-admin-3b1R1FZS.js} +1 -1
- package/dist/client/assets/{use-file-configs-dIk120-N.js → use-file-configs-VWs6VY08.js} +1 -1
- package/dist/client/assets/{use-infinite-scroll-B7e1w8Ad.js → use-infinite-scroll-BZi9tXU0.js} +1 -1
- package/dist/client/assets/{use-join-requests-BuakQTEO.js → use-join-requests-CsMCalmA.js} +1 -1
- package/dist/client/assets/{use-mcp-auth-status-DUPES28-.js → use-mcp-auth-status-DnXazVhb.js} +1 -1
- package/dist/client/assets/{use-mcp-client-B36Osh-D.js → use-mcp-client-D_VzqTLh.js} +1 -1
- package/dist/client/assets/{use-mcp-tools-C_xSJpE0.js → use-mcp-tools-DjkP_M1a.js} +1 -1
- package/dist/client/assets/{use-members-B218nv1M.js → use-members-DV4j3UXl.js} +1 -1
- package/dist/client/assets/{use-mobile--PifyK00.js → use-mobile-CWC5nRCB.js} +1 -1
- package/dist/client/assets/{use-navigate-to-agent-BBbQ-aHe.js → use-navigate-to-agent-DroDm4RE.js} +1 -1
- package/dist/client/assets/{use-org-auth-client-DK6Nh6IP.js → use-org-auth-client-BCUT78RS.js} +1 -1
- package/dist/client/assets/{use-org-sso-DZihocwz.js → use-org-sso-Dv2OfSjz.js} +1 -1
- package/dist/client/assets/{use-organization-roles-CdFvxl4s.js → use-organization-roles-CoETHAsw.js} +1 -1
- package/dist/client/assets/{use-organization-settings-CAH1_Gfq.js → use-organization-settings-U7F2Hhh2.js} +1 -1
- package/dist/client/assets/{use-registry-app-Bs5fLaKB.js → use-registry-app-CXrI3NDe.js} +1 -1
- package/dist/client/assets/{use-registry-connections-C0Ibblmm.js → use-registry-connections-BUuKAzIu.js} +1 -1
- package/dist/client/assets/{use-secrets-BTSjhTGA.js → use-secrets-r-sdg8_V.js} +1 -1
- package/dist/client/assets/{use-status-sounds-CMNbO4bj.js → use-status-sounds-D7DlFxOJ.js} +1 -1
- package/dist/client/assets/{use-view-mode-CPAZulMe.js → use-view-mode-ZZSYMSJV.js} +1 -1
- package/dist/client/assets/{use-virtual-mcp-CQaiGnUU.js → use-virtual-mcp-CBDJvgVd.js} +1 -1
- package/dist/client/assets/useInfiniteQuery-xktR2NpE.js +1 -0
- package/dist/client/assets/{useQueries-CF9YH8lZ.js → useQueries-CJGiUc5a.js} +1 -1
- package/dist/client/assets/{useRouterState-C8-zqAk7.js → useRouterState-v18d10us.js} +1 -1
- package/dist/client/assets/useSuspenseInfiniteQuery-CvxvsZx8.js +1 -0
- package/dist/client/assets/{users-BC5ArrE1.js → users-DB009SMi.js} +1 -1
- package/dist/client/assets/{variant-calendar-B8wZWFL-.js → variant-calendar-ZP0jU61K.js} +1 -1
- package/dist/client/assets/{view-mode-toggle-Bmph2BY4.js → view-mode-toggle-Dnn6UOzU.js} +1 -1
- package/dist/client/index.html +2 -2
- package/dist/server/cli.js +1 -1
- package/dist/server/server.js +1 -1
- package/package.json +1 -1
- package/dist/client/assets/index-BUug5fNW.css +0 -1
- package/dist/client/assets/page-seo-sheet-BqtOe7CO.js +0 -1
- package/dist/client/assets/project-app-view-QX-ZdCUU.js +0 -1
- package/dist/client/assets/record-editor-Bl1Ur8U7.js +0 -1
- package/dist/client/assets/registry-7xJw8GM7.js +0 -2
- package/dist/client/assets/store-registry-BuSUDYda.js +0 -2
- package/dist/client/assets/useInfiniteQuery-ByuEOZ10.js +0 -1
- package/dist/client/assets/useSuspenseInfiniteQuery-BVdkw7ML.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as U,af as xt,c as H,b as se,j as s,W as He,X as ve,F as xe,o as Ie,Y as qe,Z as Ge,e as ke,K as re,t as le,B as ne,p as ie,D as gt,m as pe,n as vt,d as bt,E as yt,z as jt}from"./index-
|
|
1
|
+
import{r as U,af as xt,c as H,b as se,j as s,W as He,X as ve,F as xe,o as Ie,Y as qe,Z as Ge,e as ke,K as re,t as le,B as ne,p as ie,D as gt,m as pe,n as vt,d as bt,E as yt,z as jt}from"./index-C7paW5qO.js";import{c as Xe,e as Ye,d as Qe,a as St,b as Je,h as Nt,D as kt}from"./dialog-CKP-t2d8.js";import{g as Ct,b as wt,a as It,D as _t}from"./drawer-DQHW9t04.js";import{u as Mt}from"./use-mobile-CWC5nRCB.js";import{S as Le,u as Et,q as Ot,a as _e}from"./chat-context-DoZ1baNe.js";import{C as Pt}from"./checkbox-5Dqb50rX.js";import{I as fe}from"./input-B7NjdaWP.js";import{S as Lt,a as At,b as Tt,c as zt,d as Rt}from"./select-Cofdiz7g.js";import{S as ee}from"./skeleton-C6T-49IJ.js";import{i as Ze,b as et,c as Ft,a as Dt,s as Kt}from"./Settings02-BrdhYfJi.js";import{c as $t,a as Ut,i as Bt}from"./Tool01-DvE5TzJB.js";import{i as Wt}from"./Key01-FIEtfPiH.js";import{i as tt}from"./SearchMd-DkKUttLm.js";import{b as Me,u as Vt,a as Ht}from"./use-ai-providers-DVcvRuW8.js";import{g as Ee}from"./ai-providers-logos-DD3qZ33J.js";import{i as qt}from"./Monitor01-JoeiLfz-.js";import{i as Gt}from"./AlertCircle-eRcWDqyz.js";import{u as we}from"./studio-tools-BgcbqxiX.js";import{i as Xt}from"./ChevronRight-CFrIQqny.js";import{A as Yt}from"./avatar-DtoeWk0Z.js";import{S as Ae,a as Te,b as st}from"./settings-section-CW4yLPtI.js";import{s as it}from"./Eye-BBuEG2Wd.js";import{a as Se,b as Ne,C as Qt}from"./connect-desktop-dialog-DUZxmsUO.js";import{t as ze}from"./ChevronDown-Bx3JuxA4.js";import{a as Jt}from"./Image01-DVjQLwZ-.js";import{t as Zt}from"./Stars01-DipJVSzo.js";function he(l,e,t){let i=t.initialDeps??[],n,o=!0;function r(){var a,d,u;let c;t.key&&((a=t.debug)!=null&&a.call(t))&&(c=Date.now());const h=l();if(!(h.length!==i.length||h.some((p,j)=>i[j]!==p)))return n;i=h;let m;if(t.key&&((d=t.debug)!=null&&d.call(t))&&(m=Date.now()),n=e(...h),t.key&&((u=t.debug)!=null&&u.call(t))){const p=Math.round((Date.now()-c)*100)/100,j=Math.round((Date.now()-m)*100)/100,k=j/16,b=(S,I)=>{for(S=String(S);S.length<I;)S=" "+S;return S};console.info(`%c⏱ ${b(j,5)} /${b(p,5)} ms`,`
|
|
2
2
|
font-size: .6rem;
|
|
3
3
|
font-weight: bold;
|
|
4
4
|
color: hsl(${Math.max(0,Math.min(120-120*k,120))}deg 100% 31%);`,t?.key)}return t?.onChange&&!(o&&t.skipInitialOnChange)&&t.onChange(n),o=!1,n}return r.updateDeps=a=>{i=a},r}function Re(l,e){if(l===void 0)throw new Error("Unexpected undefined");return l}const es=(l,e)=>Math.abs(l-e)<1.01,ts=(l,e,t)=>{let i;return function(...n){l.clearTimeout(i),i=l.setTimeout(()=>e.apply(this,n),t)}},Fe=l=>{const{offsetWidth:e,offsetHeight:t}=l;return{width:e,height:t}},ss=l=>l,is=l=>{const e=Math.max(l.startIndex-l.overscan,0),t=Math.min(l.endIndex+l.overscan,l.count-1),i=[];for(let n=e;n<=t;n++)i.push(n);return i},ls=(l,e)=>{const t=l.scrollElement;if(!t)return;const i=l.targetWindow;if(!i)return;const n=r=>{const{width:a,height:d}=r;e({width:Math.round(a),height:Math.round(d)})};if(n(Fe(t)),!i.ResizeObserver)return()=>{};const o=new i.ResizeObserver(r=>{const a=()=>{const d=r[0];if(d?.borderBoxSize){const u=d.borderBoxSize[0];if(u){n({width:u.inlineSize,height:u.blockSize});return}}n(Fe(t))};l.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(a):a()});return o.observe(t,{box:"border-box"}),()=>{o.unobserve(t)}},De={passive:!0},Ke=typeof window>"u"?!0:"onscrollend"in window,ns=(l,e)=>{const t=l.scrollElement;if(!t)return;const i=l.targetWindow;if(!i)return;let n=0;const o=l.options.useScrollendEvent&&Ke?()=>{}:ts(i,()=>{e(n,!1)},l.options.isScrollingResetDelay),r=c=>()=>{const{horizontal:h,isRtl:f}=l.options;n=h?t.scrollLeft*(f&&-1||1):t.scrollTop,o(),e(n,c)},a=r(!0),d=r(!1);t.addEventListener("scroll",a,De);const u=l.options.useScrollendEvent&&Ke;return u&&t.addEventListener("scrollend",d,De),()=>{t.removeEventListener("scroll",a),u&&t.removeEventListener("scrollend",d)}},os=(l,e,t)=>{if(e?.borderBoxSize){const i=e.borderBoxSize[0];if(i)return Math.round(i[t.options.horizontal?"inlineSize":"blockSize"])}return l[t.options.horizontal?"offsetWidth":"offsetHeight"]},rs=(l,{adjustments:e=0,behavior:t},i)=>{var 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 as{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.laneAssignments=new Map,this.pendingMeasuredCacheIndexes=[],this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.now=()=>{var t,i,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 a=o.target,d=this.indexFromElement(a);if(!a.isConnected){this.observer.unobserve(a);return}this.shouldMeasureDuringScroll(d)&&this.resizeItem(d,this.options.measureElement(a,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:ss,rangeExtractor:is,onChange:()=>{},measureElement:os,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:"estimate",...t}},this.notify=t=>{var i,n;(n=(i=this.options).onChange)==null||n.call(i,this,t)},this.maybeNotify=he(()=>(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 a=t[r];if(n.has(a.lane))continue;const d=o.get(a.lane);if(d==null||a.end>d.end?o.set(a.lane,a):a.end<d.end&&n.set(a.lane,!0),n.size===this.options.lanes)break}return o.size===this.options.lanes?Array.from(o.values()).sort((r,a)=>r.end===a.end?r.index-a.index:r.end-a.end)[0]:void 0},this.getMeasurementOptions=he(()=>[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,a,d)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMeasuredCacheIndexes=[],{count:t,paddingStart:i,scrollMargin:n,getItemKey:o,enabled:r,lanes:a,laneAssignmentMode:d}),{key:!1}),this.getMeasurements=he(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:t,paddingStart:i,scrollMargin:n,getItemKey:o,enabled:r,lanes:a,laneAssignmentMode:d},u)=>{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 c=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,c),f=new Array(a).fill(void 0);for(let m=0;m<c;m++){const p=h[m];p&&(f[p.lane]=m)}for(let m=c;m<t;m++){const p=o(m),j=this.laneAssignments.get(m);let k,b;const S=d==="estimate"||u.has(p);if(j!==void 0&&this.options.lanes>1){k=j;const _=f[k],x=_!==void 0?h[_]:void 0;b=x?x.end+this.options.gap:i+n}else{const _=this.options.lanes===1?h[m-1]:this.getFurthestMeasurement(h,m);b=_?_.end+this.options.gap:i+n,k=_?_.lane:m%this.options.lanes,this.options.lanes>1&&S&&this.laneAssignments.set(m,k)}const I=u.get(p),P=typeof I=="number"?I:this.options.estimateSize(m),E=b+P;h[m]={index:m,start:b,size:P,end:E,key:p,lane:k},f[k]=m}return this.measurementsCache=h,h},{key:!1,debug:()=>this.options.debug}),this.calculateRange=he(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(t,i,n,o)=>this.range=t.length>0&&i>0?cs({measurements:t,outerSize:i,scrollOffset:n,lanes:o}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=he(()=>{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),a=Math.min(this.options.count-1,n+o);return t>=r&&t<=a}return!0},this.measureElement=t=>{if(!t){this.elementsCache.forEach((r,a)=>{r.isConnected||(this.observer.unobserve(r),this.elementsCache.delete(a))});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,a=i-r;a!==0&&(((n=this.scrollState)==null?void 0:n.behavior)!=="smooth"&&(this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(o,a,this):o.start<this.getScrollOffset()+this.scrollAdjustments)&&this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=a,behavior:void 0}),this.pendingMeasuredCacheIndexes.push(o.index),this.itemSizeCache=new Map(this.itemSizeCache.set(o.key,i)),this.notify(!1))},this.getVirtualItems=he(()=>[this.getVirtualIndexes(),this.getMeasurements()],(t,i)=>{const n=[];for(let o=0,r=t.length;o<r;o++){const a=t[o],d=i[a];n.push(d)}return n},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=t=>{const i=this.getMeasurements();if(i.length!==0)return Re(i[lt(0,i.length-1,n=>Re(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 a=this.getMaxScrollOffset();return Math.max(Math.min(a,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 a=i==="end"?r.end+this.options.scrollPaddingEnd:r.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,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,a]=o,d=this.now();this.scrollState={index:t,align:a,behavior:n,startedAt:d,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(a=>a===null);){const a=i[r];o[a.lane]===null&&(o[a.lane]=a.end),r--}n=Math.max(...o.filter(a=>a!==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&&es(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 lt=(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 cs({measurements:l,outerSize:e,scrollOffset:t,lanes:i}){const n=l.length-1,o=d=>l[d].start;if(l.length<=i)return{startIndex:0,endIndex:n};let r=lt(0,n,o,t),a=r;if(i===1)for(;a<n&&l[a].end<t+e;)a++;else if(i>1){const d=Array(i).fill(0);for(;a<n&&d.some(c=>c<t+e);){const c=l[a];d[c.lane]=c.end,a++}const u=Array(i).fill(t+e);for(;r>=0&&u.some(c=>c>=t);){const c=l[r];u[c.lane]=c.start,r--}r=Math.max(0,r-r%i),a=Math.min(n,a+(i-1-a%i))}return{startIndex:r,endIndex:a}}const $e=typeof document<"u"?U.useLayoutEffect:U.useEffect;function ds({useFlushSync:l=!0,...e}){const t=U.useReducer(()=>({}),{})[1],i={...e,onChange:(o,r)=>{var a;l&&r?xt.flushSync(t):t(),(a=e.onChange)==null||a.call(e,o,r)}},[n]=U.useState(()=>new as(i));return n.setOptions(i),$e(()=>n._didMount(),[]),$e(()=>n._willUpdate()),n}function us(l){return ds({observeElementRect:ls,observeElementOffset:ns,scrollToFn:rs,...l})}const nt=[{id:"openai",name:"OpenAI",description:"GPT-4, GPT-5, and other OpenAI models",logo:"https://decoims.com/decocms/b51001ef-ae58-4db4-8a75-9e6d2df2dd8e/openai.png",baseUrlPlaceholder:"https://api.openai.com/v1",defaultBaseUrl:"https://api.openai.com/v1",apiKeyRecommended:!0,helpText:"Use your OpenAI API key (starts with sk-)."},{id:"litellm",name:"LiteLLM",description:"Connect to a LiteLLM gateway your team manages",logo:"https://decoims.com/decocms/e974ae05-ad64-4b4a-8444-d9705f019b85/litellm.png",baseUrlPlaceholder:"http://localhost:4000",apiKeyRecommended:!0,helpText:"Point at your LiteLLM proxy. The base URL should be the root of the proxy (we'll append /v1)."},{id:"ollama",name:"Ollama",description:"Run open-source models on your own computer",logo:"https://decoims.com/decocms/2bb2f822-5288-4b7c-a541-dcbef76525a0/ollama.png",baseUrlPlaceholder:"http://localhost:11434",apiKeyRecommended:!1,helpText:"Ollama exposes /v1 by default — no API key required for local use."},{id:"lm-studio",name:"LM Studio",description:"Open models running through LM Studio",logo:"https://decoims.com/decocms/9f0ab1a9-d2d5-4f3e-9de0-aadd4926428d/lmstudio.webp",baseUrlPlaceholder:"http://localhost:1234",apiKeyRecommended:!1,helpText:"Start the local server in LM Studio, then paste its base URL here."},{id:"vllm",name:"vLLM",description:"Connect to your team's self-hosted vLLM server",logo:"https://decoims.com/decocms/b6c60e4f-a4aa-443c-981f-ad0f31640e22/vllm.png",baseUrlPlaceholder:"http://localhost:8000",apiKeyRecommended:!1}];function be(l){if(l)return nt.find(e=>e.id===l)}const Ue=4;function ge(l){const e=H.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(Yt,{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 a;return e[3]!==n||e[4]!==i||e[5]!==o||e[6]!==r?(a=s.jsx(st,{onClick:o,icon:r,title:i,description:n}),e[3]=n,e[4]=i,e[5]=o,e[6]=r,e[7]=a):a=e[7],a}function ot(l){const e=H.c(38),{providers:t,onSelect:i,onShowAll:n}=l,o=se();let r;e[0]!==t?(r=t.find(ps),e[0]=t,e[1]=r):r=e[1];const a=r;let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d={openrouter:0,llmapi:1,anthropic:2,google:3},e[2]=d):d=e[2];const u=d;let c;if(e[3]!==i||e[4]!==t||e[5]!==o){let P;e[7]===Symbol.for("react.memo_cache_sentinel")?(P=(y,C)=>{const L=u[y.id]??Number.MAX_SAFE_INTEGER,A=u[C.id]??Number.MAX_SAFE_INTEGER;return L-A},e[7]=P):P=e[7];const E=t.filter(fs).sort(P);let _;e[8]!==t?(_=t.find(hs),e[8]=t,e[9]=_):_=e[9];const x=_;let N;e[10]===Symbol.for("react.memo_cache_sentinel")?(N=be("openai"),e[10]=N):N=e[10];const w=N;let M;e[11]!==i?(M=y=>s.jsx(ge,{logo:y.logo,name:y.name,description:y.description,onClick:()=>i({kind:"provider",provider:y})},y.id),e[11]=i,e[12]=M):M=e[12];let g;e[13]!==i||e[14]!==x?(g=x&&w?[s.jsx(ge,{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]=g):g=e[15];let v;e[16]!==i||e[17]!==x||e[18]!==o?(v=x?[...nt.filter(ms).map(y=>s.jsx(ge,{logo:y.logo,name:y.name,description:y.description,onClick:()=>i({kind:"openai-compatible",provider:x,preset:y})},y.id)),s.jsx(ge,{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]=v):v=e[19],c=[...E.map(M),...g,...v],e[3]=i,e[4]=t,e[5]=o,e[6]=c}else c=e[6];const h=c,f=h.length-Ue,m=!!n&&f>0;let p;e[20]!==h||e[21]!==m?(p=m?h.slice(0,Ue):h,e[20]=h,e[21]=m,e[22]=p):p=e[22];const j=p;let k;e[23]!==a||e[24]!==i||e[25]!==o?(k=a&&s.jsx(Ae,{children:s.jsxs("div",{className:"relative rounded-xl border border-violet-400/30 bg-gradient-to-br from-violet-50/50 via-transparent to-lime-50/30 dark:from-violet-950/20 dark:to-lime-950/10 p-1.5",children:[s.jsx("div",{className:"absolute inset-0 rounded-xl bg-gradient-to-br from-violet-400/5 to-lime-400/5 pointer-events-none"}),s.jsx("p",{className:"text-xs font-medium text-violet-700 dark:text-violet-400 mb-1.5 px-2 pt-2 relative",children:o("settings.aiProviders.recommended")}),s.jsx(Te,{className:"relative",children:s.jsx(ge,{logo:a.logo,name:a.name,description:a.description,onClick:()=>i({kind:"provider",provider:a})})})]})}),e[23]=a,e[24]=i,e[25]=o,e[26]=k):k=e[26];let b;e[27]!==f||e[28]!==n||e[29]!==m||e[30]!==o?(b=m&&s.jsx(st,{onClick:n,title:o("settings.aiProviders.moreProviders",{count:f,plural:f===1?"":"s"}),action:s.jsx(Xt,{size:16,className:"text-muted-foreground"})}),e[27]=f,e[28]=n,e[29]=m,e[30]=o,e[31]=b):b=e[31];let S;e[32]!==b||e[33]!==j?(S=s.jsx(Ae,{children:s.jsxs(Te,{children:[j,b]})}),e[32]=b,e[33]=j,e[34]=S):S=e[34];let I;return e[35]!==k||e[36]!==S?(I=s.jsxs("div",{className:"flex flex-col gap-6",children:[k,S]}),e[35]=k,e[36]=S,e[37]=I):I=e[37],I}function ms(l){return l.id!=="openai"}function hs(l){return l.id==="openai-compatible"}function fs(l){return l.id!=="deco"&&l.id!=="openai-compatible"}function ps(l){return l.id==="deco"}const xs=He({label:ve().optional(),apiKey:ve().min(1,"API key is required")});function gs(l){const e=H.c(87),{providerId:t,onCancel:i,onSuccess:n}=l,{org:o}=xe(),r=we(),a=Ie(),[d,u]=U.useState(!1),c=se();let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h={resolver:qe(xs),defaultValues:{label:"",apiKey:""}},e[0]=h):h=e[0];const{register:f,handleSubmit:m,formState:p}=Ge(h),{errors:j}=p;let k;e[1]!==t||e[2]!==r||e[3]!==c?(k=async Z=>{await r.call("AI_PROVIDER_KEY_CREATE",{providerId:t,label:Z.label||c("settings.connectForms.defaultKeyLabel"),apiKey:Z.apiKey})},e[1]=t,e[2]=r,e[3]=c,e[4]=k):k=e[4];let b;e[5]!==n||e[6]!==o||e[7]!==a||e[8]!==c?(b=()=>{a.invalidateQueries({queryKey:re.aiProviderKeys(o.id)}),a.invalidateQueries({queryKey:re.aiProviders(o.id)}),le.success(c("settings.connectForms.keySavedSuccess")),n()},e[5]=n,e[6]=o,e[7]=a,e[8]=c,e[9]=b):b=e[9];let S;e[10]!==c?(S=Z=>{le.error(c("settings.connectForms.failedSaveKey",{error:Z.message}))},e[10]=c,e[11]=S):S=e[11];let I;e[12]!==k||e[13]!==b||e[14]!==S?(I={mutationFn:k,onSuccess:b,onError:S},e[12]=k,e[13]=b,e[14]=S,e[15]=I):I=e[15];const{mutate:P,isPending:E,error:_}=ke(I);let x;e[16]!==P?(x=Z=>P(Z),e[16]=P,e[17]=x):x=e[17];let N;e[18]!==m||e[19]!==x?(N=m(x),e[18]=m,e[19]=x,e[20]=N):N=e[20];let w;e[21]!==c?(w=c("settings.connectForms.labelField"),e[21]=c,e[22]=w):w=e[22];let M;e[23]!==w?(M=s.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:w}),e[23]=w,e[24]=M):M=e[24];let g;e[25]!==c?(g=c("settings.connectForms.labelPlaceholder"),e[25]=c,e[26]=g):g=e[26];let v;e[27]!==f?(v=f("label"),e[27]=f,e[28]=v):v=e[28];let y;e[29]!==g||e[30]!==v?(y=s.jsx(fe,{placeholder:g,...v,className:"h-8 text-sm"}),e[29]=g,e[30]=v,e[31]=y):y=e[31];let C;e[32]!==M||e[33]!==y?(C=s.jsxs("div",{className:"space-y-1",children:[M,y]}),e[32]=M,e[33]=y,e[34]=C):C=e[34];let L;e[35]!==c?(L=c("settings.connectForms.apiKeyField"),e[35]=c,e[36]=L):L=e[36];let A;e[37]!==L?(A=s.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:L}),e[37]=L,e[38]=A):A=e[38];const O=d?"text":"password";let R;e[39]!==f?(R=f("apiKey"),e[39]=f,e[40]=R):R=e[40];let F;e[41]!==O||e[42]!==R?(F=s.jsx(fe,{type:O,placeholder:"sk-...",...R,className:"ph-no-capture h-8 text-sm pr-8"}),e[41]=O,e[42]=R,e[43]=F):F=e[43];let D;e[44]!==d?(D=()=>u(!d),e[44]=d,e[45]=D):D=e[45];let z;e[46]!==d||e[47]!==c?(z=c(d?"settings.connectForms.hideApiKey":"settings.connectForms.showApiKey"),e[46]=d,e[47]=c,e[48]=z):z=e[48];let K;e[49]!==d?(K=d?s.jsx(Ze,{size:14}):s.jsx(it,{size:14}),e[49]=d,e[50]=K):K=e[50];let V;e[51]!==D||e[52]!==z||e[53]!==K?(V=s.jsx("button",{type:"button",onClick:D,"aria-label":z,className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:K}),e[51]=D,e[52]=z,e[53]=K,e[54]=V):V=e[54];let J;e[55]!==F||e[56]!==V?(J=s.jsxs("div",{className:"relative",children:[F,V]}),e[55]=F,e[56]=V,e[57]=J):J=e[57];let G;e[58]!==j.apiKey?(G=j.apiKey&&s.jsx("p",{className:"text-xs text-destructive",children:j.apiKey.message}),e[58]=j.apiKey,e[59]=G):G=e[59];let X;e[60]!==A||e[61]!==J||e[62]!==G?(X=s.jsxs("div",{className:"space-y-1",children:[A,J,G]}),e[60]=A,e[61]=J,e[62]=G,e[63]=X):X=e[63];let T;e[64]!==_?(T=_&&s.jsx("p",{className:"text-xs text-destructive",children:_.message}),e[64]=_,e[65]=T):T=e[65];let B;e[66]!==c?(B=c("settings.connectForms.cancel"),e[66]=c,e[67]=B):B=e[67];let W;e[68]!==E||e[69]!==i||e[70]!==B?(W=s.jsx(ne,{type:"button",variant:"ghost",size:"sm",onClick:i,disabled:E,children:B}),e[68]=E,e[69]=i,e[70]=B,e[71]=W):W=e[71];let q;e[72]!==E||e[73]!==c?(q=c(E?"settings.connectForms.saving":"settings.connectForms.saveKey"),e[72]=E,e[73]=c,e[74]=q):q=e[74];let $;e[75]!==E||e[76]!==q?($=s.jsx(ne,{type:"submit",size:"sm",disabled:E,children:q}),e[75]=E,e[76]=q,e[77]=$):$=e[77];let Y;e[78]!==W||e[79]!==$?(Y=s.jsxs(Xe,{children:[W,$]}),e[78]=W,e[79]=$,e[80]=Y):Y=e[80];let te;return e[81]!==C||e[82]!==X||e[83]!==T||e[84]!==Y||e[85]!==N?(te=s.jsxs("form",{onSubmit:N,className:"space-y-3",children:[C,X,T,Y]}),e[81]=C,e[82]=X,e[83]=T,e[84]=Y,e[85]=N,e[86]=te):te=e[86],te}const vs=He({label:ve().optional(),baseUrl:ve().min(1,"Base URL is required"),apiKey:ve().optional()});function bs(l){const e=H.c(105),{preset:t,onCancel:i,onSuccess:n}=l,{org:o}=xe(),r=we(),a=Ie(),[d,u]=U.useState(!1),c=se();let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=qe(vs),e[0]=h):h=e[0];const f=t?.defaultBaseUrl??"";let m;e[1]!==f?(m={resolver:h,defaultValues:{label:"",baseUrl:f,apiKey:""}},e[1]=f,e[2]=m):m=e[2];const{register:p,handleSubmit:j,formState:k}=Ge(m),{errors:b}=k;let S;e[3]!==t||e[4]!==r?(S=async oe=>{const pt=JSON.stringify({baseUrl:oe.baseUrl,apiKey:oe.apiKey||""});await r.call("AI_PROVIDER_KEY_CREATE",{providerId:"openai-compatible",label:oe.label||t?.name||oe.baseUrl,apiKey:pt,...t?{presetId:t.id}:{}})},e[3]=t,e[4]=r,e[5]=S):S=e[5];let I;e[6]!==n||e[7]!==o||e[8]!==a||e[9]!==c?(I=()=>{a.invalidateQueries({queryKey:re.aiProviderKeys(o.id)}),a.invalidateQueries({queryKey:re.aiProviders(o.id)}),le.success(c("settings.connectForms.connectionSavedSuccess")),n()},e[6]=n,e[7]=o,e[8]=a,e[9]=c,e[10]=I):I=e[10];let P;e[11]!==c?(P=oe=>{le.error(c("settings.connectForms.failedSaveConnection",{error:oe.message}))},e[11]=c,e[12]=P):P=e[12];let E;e[13]!==S||e[14]!==I||e[15]!==P?(E={mutationFn:S,onSuccess:I,onError:P},e[13]=S,e[14]=I,e[15]=P,e[16]=E):E=e[16];const{mutate:_,isPending:x,error:N}=ke(E);let w;e[17]!==t||e[18]!==c?(w=t?c("settings.connectForms.labelPlaceholderPreset",{name:t.name}):c("settings.connectForms.labelPlaceholderOpenAiCompatible"),e[17]=t,e[18]=c,e[19]=w):w=e[19];const M=w;let g;e[20]!==t?.baseUrlPlaceholder||e[21]!==c?(g=t?.baseUrlPlaceholder??c("settings.connectForms.baseUrlPlaceholder"),e[20]=t?.baseUrlPlaceholder,e[21]=c,e[22]=g):g=e[22];const v=g;let y;e[23]!==_?(y=oe=>_(oe),e[23]=_,e[24]=y):y=e[24];let C;e[25]!==j||e[26]!==y?(C=j(y),e[25]=j,e[26]=y,e[27]=C):C=e[27];let L;e[28]!==c?(L=c("settings.connectForms.labelField"),e[28]=c,e[29]=L):L=e[29];let A;e[30]!==L?(A=s.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:L}),e[30]=L,e[31]=A):A=e[31];let O;e[32]!==p?(O=p("label"),e[32]=p,e[33]=O):O=e[33];let R;e[34]!==M||e[35]!==O?(R=s.jsx(fe,{placeholder:M,...O,className:"h-8 text-sm"}),e[34]=M,e[35]=O,e[36]=R):R=e[36];let F;e[37]!==A||e[38]!==R?(F=s.jsxs("div",{className:"space-y-1",children:[A,R]}),e[37]=A,e[38]=R,e[39]=F):F=e[39];let D;e[40]!==v||e[41]!==b||e[42]!==t?.defaultBaseUrl||e[43]!==p||e[44]!==c?(D=t?.defaultBaseUrl?s.jsx("input",{type:"hidden",...p("baseUrl")}):s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:c("settings.connectForms.baseUrlField")}),s.jsx(fe,{type:"url",placeholder:v,...p("baseUrl"),className:"h-8 text-sm"}),b.baseUrl&&s.jsx("p",{className:"text-xs text-destructive",children:b.baseUrl.message})]}),e[40]=v,e[41]=b,e[42]=t?.defaultBaseUrl,e[43]=p,e[44]=c,e[45]=D):D=e[45];let z;e[46]!==c?(z=c("settings.connectForms.apiKeyField"),e[46]=c,e[47]=z):z=e[47];let K;e[48]!==t?.apiKeyRecommended||e[49]!==c?(K=t?.apiKeyRecommended?c("settings.connectForms.recommended"):c("settings.connectForms.optional"),e[48]=t?.apiKeyRecommended,e[49]=c,e[50]=K):K=e[50];let V;e[51]!==K?(V=s.jsxs("span",{className:"text-muted-foreground/60",children:["(",K,")"]}),e[51]=K,e[52]=V):V=e[52];let J;e[53]!==z||e[54]!==V?(J=s.jsxs("label",{className:"text-xs font-medium text-muted-foreground",children:[z," ",V]}),e[53]=z,e[54]=V,e[55]=J):J=e[55];const G=d?"text":"password";let X;e[56]!==p?(X=p("apiKey"),e[56]=p,e[57]=X):X=e[57];let T;e[58]!==G||e[59]!==X?(T=s.jsx(fe,{type:G,placeholder:"sk-...",...X,className:"ph-no-capture h-8 text-sm pr-8"}),e[58]=G,e[59]=X,e[60]=T):T=e[60];let B;e[61]!==d?(B=()=>u(!d),e[61]=d,e[62]=B):B=e[62];let W;e[63]!==d||e[64]!==c?(W=c(d?"settings.connectForms.hideApiKey":"settings.connectForms.showApiKey"),e[63]=d,e[64]=c,e[65]=W):W=e[65];let q;e[66]!==d?(q=d?s.jsx(Ze,{size:14}):s.jsx(it,{size:14}),e[66]=d,e[67]=q):q=e[67];let $;e[68]!==B||e[69]!==W||e[70]!==q?($=s.jsx("button",{type:"button",onClick:B,"aria-label":W,className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:q}),e[68]=B,e[69]=W,e[70]=q,e[71]=$):$=e[71];let Y;e[72]!==T||e[73]!==$?(Y=s.jsxs("div",{className:"relative",children:[T,$]}),e[72]=T,e[73]=$,e[74]=Y):Y=e[74];let te;e[75]!==J||e[76]!==Y?(te=s.jsxs("div",{className:"space-y-1",children:[J,Y]}),e[75]=J,e[76]=Y,e[77]=te):te=e[77];let Z;e[78]!==t?(Z=t?.helpText&&s.jsx("p",{className:"text-xs text-muted-foreground",children:t.helpText}),e[78]=t,e[79]=Z):Z=e[79];let Q;e[80]!==N?(Q=N&&s.jsx("p",{className:"text-xs text-destructive",children:N.message}),e[80]=N,e[81]=Q):Q=e[81];let ae;e[82]!==c?(ae=c("settings.connectForms.cancel"),e[82]=c,e[83]=ae):ae=e[83];let ce;e[84]!==x||e[85]!==i||e[86]!==ae?(ce=s.jsx(ne,{type:"button",variant:"ghost",size:"sm",onClick:i,disabled:x,children:ae}),e[84]=x,e[85]=i,e[86]=ae,e[87]=ce):ce=e[87];let de;e[88]!==x||e[89]!==c?(de=c(x?"settings.connectForms.saving":"settings.connectForms.saveConnection"),e[88]=x,e[89]=c,e[90]=de):de=e[90];let ue;e[91]!==x||e[92]!==de?(ue=s.jsx(ne,{type:"submit",size:"sm",disabled:x,children:de}),e[91]=x,e[92]=de,e[93]=ue):ue=e[93];let me;e[94]!==ce||e[95]!==ue?(me=s.jsxs(Xe,{children:[ce,ue]}),e[94]=ce,e[95]=ue,e[96]=me):me=e[96];let ye;return e[97]!==C||e[98]!==F||e[99]!==D||e[100]!==te||e[101]!==Z||e[102]!==Q||e[103]!==me?(ye=s.jsxs("form",{onSubmit:C,className:"space-y-3",children:[F,D,te,Z,Q,me]}),e[97]=C,e[98]=F,e[99]=D,e[100]=te,e[101]=Z,e[102]=Q,e[103]=me,e[104]=ye):ye=e[104],ye}const ys={kind:"closed"};function js(l,e){switch(e.type){case"open":return l.kind==="closed"?{kind:"grid"}:l;case"close":return{kind:"closed"};case"back":switch(l.kind){case"form":case"oauth-pending":case"provision-pending":case"provision-error":return{kind:"grid"};default:return l}case"select-form":return l.kind!=="grid"?l:{kind:"form",providerId:e.providerId,presetId:e.presetId};case"select-oauth":return l.kind!=="grid"?l:{kind:"oauth-pending",providerId:e.providerId,stateToken:e.stateToken};case"oauth-failed":return l.kind==="oauth-pending"?{kind:"grid"}:l;case"select-provision":return l.kind!=="grid"?l:{kind:"provision-pending",providerId:e.providerId};case"provision-error":return l.kind!=="provision-pending"?l:{kind:"provision-error",providerId:l.providerId,error:e.error};case"retry-provision":return l.kind!=="provision-error"?l:{kind:"provision-pending",providerId:l.providerId}}}function Ss(l){switch(l.kind){case"form":case"oauth-pending":case"provision-pending":case"provision-error":return l.providerId;default:return null}}function Ns({open:l,onOpenChange:e,initialProvider:t}){const i=se(),o=Me()?.providers??[],{org:r}=xe(),a=we(),d=Ie(),[u,c]=U.useReducer(js,ys),h=U.useRef(!1);U.useEffect(()=>{l&&u.kind==="closed"?c({type:"open"}):!l&&u.kind!=="closed"&&c({type:"close"})},[l,u.kind]);const f=()=>{h.current=!1,c({type:"close"}),e(!1)},m=()=>{d.invalidateQueries({queryKey:re.aiProviderKeys(r.id)}),d.invalidateQueries({queryKey:re.aiProviders(r.id)})},{mutate:p}=ke({mutationFn:async({providerId:g,code:v,stateToken:y,label:C})=>(await a.call("AI_PROVIDER_OAUTH_EXCHANGE",{providerId:g,code:v,stateToken:y,label:C}),g),onSuccess:g=>{ie("ai_provider_oauth_succeeded",{provider_id:g}),m();const v=o.find(y=>y.id===g);le.success(i("settings.connectProviderDialog.oauthSuccessMessage",{provider:v?.name??i("settings.connectProviderDialog.defaultProviderName")})),f()},onError:(g,v)=>{ie("ai_provider_oauth_failed",{provider_id:v.providerId,error:g.message}),le.error(i("settings.connectProviderDialog.oauthFailedMessage",{error:g.message})),c({type:"oauth-failed"})}}),{mutate:j}=ke({mutationFn:async g=>(await a.call("AI_PROVIDER_PROVISION_KEY",{providerId:g}),g),onSuccess:g=>{ie("ai_provider_provision_succeeded",{provider_id:g}),m();const v=o.find(y=>y.id===g);le.success(i("settings.connectProviderDialog.provisionSuccessMessage",{provider:v?.name??i("settings.connectProviderDialog.defaultProviderName")})),f()},onError:(g,v)=>{ie("ai_provider_provision_failed",{provider_id:v,error:g.message}),c({type:"provision-error",error:g.message})}}),k=async g=>{const{provider:v}=g,y=g.kind==="openai-compatible"?g.preset?.id??null:null,C=v.supportedMethods.includes("oauth-pkce"),L=v.supportedMethods.includes("api-key");if(v.supportsProvision===!0){ie("ai_provider_connect_clicked",{provider_id:v.id,method:"provision"}),c({type:"select-provision",providerId:v.id}),j(v.id);return}if(C){ie("ai_provider_connect_clicked",{provider_id:v.id,method:"oauth-pkce"});try{const O=await a.call("AI_PROVIDER_OAUTH_URL",{providerId:v.id,callbackUrl:`${window.location.origin}/oauth/callback/ai-provider`});if(!O?.url)throw new Error("Invalid response from AI_PROVIDER_OAUTH_URL");c({type:"select-oauth",providerId:v.id,stateToken:O.stateToken}),window.open(O.url,"AiProviderOAuth","width=600,height=700")}catch(O){le.error(i("settings.connectProviderDialog.startOAuthFailedMessage",{error:O instanceof Error?O.message:String(O)}))}return}L&&(ie("ai_provider_connect_clicked",{provider_id:v.id,...y!==null?{preset_id:y}:{},method:"api-key"}),c({type:"select-form",providerId:v.id,presetId:y}))},b=U.useRef(k);b.current=k;const S=U.useRef(t);S.current=t,U.useEffect(()=>{!S.current||u.kind!=="grid"||h.current||(h.current=!0,b.current(S.current))},[u.kind]);const I=u.kind==="oauth-pending"?u.stateToken:null,P=u.kind==="oauth-pending"?u.providerId:null;U.useEffect(()=>{if(u.kind!=="oauth-pending")return;let g=!1;const v=u.stateToken,y=u.providerId,C=A=>{if(A.origin!==window.location.origin||A.data?.type!=="AI_PROVIDER_OAUTH_CALLBACK")return;const{code:O,stateToken:R}=A.data;if(R!==v){le.error(i("settings.connectProviderDialog.securityCheckFailedMessage")),c({type:"oauth-failed"});return}g=!0;const F=o.find(D=>D.id===y);p({providerId:y,code:O,stateToken:v,label:F?.name??y})};window.addEventListener("message",C);const L=setTimeout(()=>{g||(ie("ai_provider_oauth_timeout",{provider_id:y}),c({type:"oauth-failed"}),le.error(i("settings.connectProviderDialog.connectionTimedOutMessage")))},12e4);return()=>{window.removeEventListener("message",C),clearTimeout(L)}},[u.kind,I,P,p]);const E=Ss(u),_=E?o.find(g=>g.id===E):null,N=(u.kind==="form"&&u.presetId?be(u.presetId):null)?.name??_?.name??i("settings.connectProviderDialog.defaultTitle"),w=u.kind!=="grid"&&u.kind!=="closed",M=()=>{t?f():c({type:"back"})};return s.jsx(Ye,{open:u.kind!=="closed",onOpenChange:g=>!g&&f(),children:s.jsxs(Qe,{className:"sm:max-w-md max-h-[90vh] overflow-y-auto",children:[s.jsxs(St,{children:[s.jsxs("div",{className:"flex items-center gap-2",children:[w&&s.jsx(ne,{variant:"ghost",size:"icon","aria-label":i("settings.connectProviderDialog.backButtonLabel"),className:"h-7 w-7",onClick:M,children:s.jsx(et,{size:16})}),s.jsx(Je,{children:N})]}),u.kind==="grid"&&!t&&s.jsx(Nt,{children:i("settings.connectProviderDialog.gridDescription")})]}),u.kind==="grid"&&!t&&s.jsx(ot,{providers:o,onSelect:k}),u.kind==="form"&&(u.providerId==="openai-compatible"?s.jsx(bs,{preset:u.presetId?be(u.presetId):void 0,onCancel:()=>c({type:"back"}),onSuccess:()=>{m(),f()}}):s.jsx(gs,{providerId:u.providerId,onCancel:()=>c({type:"back"}),onSuccess:()=>{m(),f()}})),u.kind==="oauth-pending"&&s.jsxs("div",{className:"flex flex-col items-center gap-4 py-8",children:[s.jsx(Le,{size:"lg"}),s.jsx("p",{className:"text-sm text-muted-foreground text-center",children:i("settings.connectProviderDialog.oauthPendingMessage")})]}),u.kind==="provision-pending"&&s.jsxs("div",{className:"flex flex-col items-center gap-4 py-8",children:[s.jsx(Le,{size:"lg"}),s.jsx("p",{className:"text-sm text-muted-foreground",children:i("settings.connectProviderDialog.provisionPendingMessage")})]}),u.kind==="provision-error"&&s.jsxs("div",{className:"flex flex-col items-center gap-4 py-6",children:[s.jsx(Gt,{size:28,className:"text-destructive"}),s.jsx("p",{className:"text-sm text-foreground text-center",children:u.error}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(ne,{variant:"outline",size:"sm",onClick:()=>c({type:"back"}),children:i("settings.connectProviderDialog.backButton")}),s.jsx(ne,{size:"sm",onClick:()=>{c({type:"retry-provision"}),j(u.providerId)},children:i("settings.connectProviderDialog.retryButton")})]})]})]})})}function ks(){const l=H.c(7),{org:e}=xe(),t=we();let i;l[0]!==e.id?(i=re.defaultBrand(e.id),l[0]=e.id,l[1]=i):i=l[1];let n;l[2]!==t?(n=async()=>{const{items:a}=await t.call("BRAND_CONTEXT_LIST",{});return(Array.isArray(a)?a:[]).find(Cs)??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}=vt(o);return r??null}function Cs(l){return l.isDefault&&!l.archivedAt}function ws(l){const e=l.colors;if(!e)return null;if(Array.isArray(e)){const t=e.find(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 Is(l){const e=H.c(66);let t;e[0]!==l?(t=l===void 0?{}:l,e[0]=l,e[1]=t):t=e[1];const{title:i,description:n,onLocalRuntimePicked:o}=t,r=se(),{org:a}=xe(),{localMode:d}=gt(),u=ks(),c=Et(),h=Ot(),[f,m]=U.useState(null),[p,j]=U.useState(!1),[k,b]=U.useState(!1),S=Me();let I;e[2]!==S?.providers?(I=S?.providers??[],e[2]=S?.providers,e[3]=I):I=e[3];const P=I;let E,_,x;if(e[4]!==u||e[5]!==h||e[6]!==n||e[7]!==c.capabilities||e[8]!==c.online||e[9]!==d||e[10]!==o||e[11]!==a.name||e[12]!==r||e[13]!==i){const O=[];if(c.online){if(c.capabilities.includes("claude-code")){let Q;e[17]===Symbol.for("react.memo_cache_sentinel")?(Q=s.jsx(Se,{size:16}),e[17]=Q):Q=e[17],O.push({option:"claude-code-desktop",label:"Claude Code",icon:Q})}if(c.capabilities.includes("codex")){let Q;e[18]===Symbol.for("react.memo_cache_sentinel")?(Q=s.jsx(Ne,{size:16}),e[18]=Q):Q=e[18],O.push({option:"codex-desktop",label:"Codex",icon:Q})}}const R=O.length>0&&h!==null,F=a.name;let D;e[19]!==u?(D=u?ws(u):null,e[19]=u,e[20]=D):D=e[20];const z=D,K=u?.favicon??u?.logo??null;let V;e[21]!==F||e[22]!==r||e[23]!==i?(V=i??(F?r("chat.noAiProviderEmptyState.headingWithOrg",{org:F}):r("chat.noAiProviderEmptyState.headingDefault")),e[21]=F,e[22]=r,e[23]=i,e[24]=V):V=e[24];const J=V;let G;e[25]!==n||e[26]!==R||e[27]!==d||e[28]!==r?(G=n??r(R?"chat.noAiProviderEmptyState.subtitleWithDesktop":d?"chat.noAiProviderEmptyState.subtitleLocalMode":"chat.noAiProviderEmptyState.subtitleDefault"),e[25]=n,e[26]=R,e[27]=d,e[28]=r,e[29]=G):G=e[29];const X=G,T=!!(K||z);let B;e[30]!==z?(B=z?{backgroundColor:`${z}18`,borderColor:`${z}30`}:void 0,e[30]=z,e[31]=B):B=e[31];const W=B,q=T?"flex items-center justify-center size-14 rounded-2xl border":"flex items-center justify-center size-14 rounded-2xl bg-muted border border-border";E="flex flex-col items-center gap-8 w-full max-w-3xl px-4";let $;e[32]!==q||e[33]!==W||e[34]!==K||e[35]!==c.online||e[36]!==z||e[37]!==r?($=K?s.jsx("div",{className:q,style:W,children:s.jsx("img",{src:K,alt:"",className:"size-7 rounded object-contain"})}):s.jsx("button",{type:"button",onClick:()=>b(!0),"aria-label":c.online?r("chat.noAiProviderEmptyState.desktopLinkedLabel"):r("chat.noAiProviderEmptyState.connectDesktopLabel"),className:pe(q,"cursor-pointer transition-colors hover:bg-accent"),style:W,children:s.jsxs("span",{className:"relative inline-flex items-center justify-center",children:[s.jsx(qt,{size:24,style:z?{color:z}:void 0,className:pe(!z&&"text-muted-foreground")}),c.online&&s.jsx("span",{className:"absolute -top-0.5 -right-0.5 size-2.5 rounded-full bg-success ring-2 ring-background animate-pulse"})]})}),e[32]=q,e[33]=W,e[34]=K,e[35]=c.online,e[36]=z,e[37]=r,e[38]=$):$=e[38];let Y;e[39]!==J?(Y=s.jsx("p",{className:"text-xl font-semibold text-foreground tracking-tight",children:J}),e[39]=J,e[40]=Y):Y=e[40];let te;e[41]!==X?(te=s.jsx("p",{className:"text-sm text-muted-foreground max-w-md",children:X}),e[41]=X,e[42]=te):te=e[42];let Z;e[43]!==Y||e[44]!==te?(Z=s.jsxs("div",{className:"space-y-2",children:[Y,te]}),e[43]=Y,e[44]=te,e[45]=Z):Z=e[45],e[46]!==$||e[47]!==Z?(_=s.jsxs("div",{className:"flex flex-col items-center gap-4 text-center",children:[$,Z]}),e[46]=$,e[47]=Z,e[48]=_):_=e[48],x=R&&s.jsxs("div",{className:"flex flex-col items-center gap-3 w-full",children:[s.jsx("div",{className:"flex flex-wrap items-center justify-center gap-2",children:O.map(Q=>s.jsxs(ne,{variant:"default",className:"gap-2",onClick:()=>{h?.setPendingAgentOption(Q.option),o?.(Q.option)},children:[Q.icon,r("chat.noAiProviderEmptyState.useLabel",{label:Q.label})]},Q.option))}),s.jsxs("div",{className:"flex items-center gap-3 w-full max-w-xs text-xs text-muted-foreground",children:[s.jsx("span",{className:"h-px flex-1 bg-border"}),r("chat.noAiProviderEmptyState.orConnectProvider"),s.jsx("span",{className:"h-px flex-1 bg-border"})]})]}),e[4]=u,e[5]=h,e[6]=n,e[7]=c.capabilities,e[8]=c.online,e[9]=d,e[10]=o,e[11]=a.name,e[12]=r,e[13]=i,e[14]=E,e[15]=_,e[16]=x}else E=e[14],_=e[15],x=e[16];let N,w;e[49]===Symbol.for("react.memo_cache_sentinel")?(N=O=>m(O),w=()=>j(!0),e[49]=N,e[50]=w):(N=e[49],w=e[50]);let M;e[51]!==P?(M=s.jsx("div",{className:"w-full",children:s.jsx(ot,{providers:P,onSelect:N,onShowAll:w})}),e[51]=P,e[52]=M):M=e[52];const g=f!==null||p;let v;e[53]===Symbol.for("react.memo_cache_sentinel")?(v=O=>{O||(m(null),j(!1))},e[53]=v):v=e[53];const y=f??void 0;let C;e[54]!==y||e[55]!==g?(C=s.jsx(Ns,{open:g,onOpenChange:v,initialProvider:y}),e[54]=y,e[55]=g,e[56]=C):C=e[56];let L;e[57]!==k?(L=s.jsx(Qt,{open:k,onOpenChange:b}),e[57]=k,e[58]=L):L=e[58];let A;return e[59]!==C||e[60]!==L||e[61]!==E||e[62]!==_||e[63]!==x||e[64]!==M?(A=s.jsxs("div",{className:E,children:[_,x,M,C,L]}),e[59]=C,e[60]=L,e[61]=E,e[62]=_,e[63]=x,e[64]=M,e[65]=A):A=e[65],A}function Oe(l){const e=l.title.includes(": ");return{provider:e?l.title.split(": ")[0]??"":l.modelId.split("/")[0]??"",displayName:e?l.title.split(": ").slice(1).join(": "):l.title}}function _s(l){return l<32e3?{level:1,labelKey:"chat.shared.contextLevelSmall",descriptionKey:"chat.shared.contextLevelSmallDesc"}:l<2e5?{level:2,labelKey:"chat.shared.contextLevelMedium",descriptionKey:"chat.shared.contextLevelMediumDesc"}:l<5e5?{level:3,labelKey:"chat.shared.contextLevelLarge",descriptionKey:"chat.shared.contextLevelLargeDesc"}:{level:4,labelKey:"chat.shared.contextLevelVeryLarge",descriptionKey:"chat.shared.contextLevelVeryLargeDesc"}}const Ms=["bg-destructive","bg-warning","bg-success","bg-success"],Es=["text-success","text-warning","text-warning","text-destructive"];function Os(l,e){const t=Math.round(l*.75/1e3),i=t>=1?`${t}K`:`${Math.round(l*.75)}`;return e("chat.shared.approxWords",{wordCount:i})}function Ps(l){return l<1?{level:1,labelKey:"chat.shared.costLevelCheap"}:l<5?{level:2,labelKey:"chat.shared.costLevelModerate"}:l<15?{level:3,labelKey:"chat.shared.costLevelHigh"}:{level:4,labelKey:"chat.shared.costLevelExpensive"}}const Ls={text:{icon:s.jsx(Ut,{className:"size-3.5"}),labelKey:"chat.shared.capabilityText"},vision:{icon:s.jsx(Jt,{className:"size-3.5"}),labelKey:"chat.shared.capabilityVision"},image:{icon:s.jsx(Ft,{className:"size-3.5"}),labelKey:"chat.shared.capabilityImage"},tools:{icon:s.jsx($t,{className:"size-3.5"}),labelKey:"chat.shared.capabilityTools"},reasoning:{icon:s.jsx(Zt,{className:"size-3.5"}),labelKey:"chat.shared.capabilityReasoning"},"web-search":{icon:s.jsx(tt,{className:"size-3.5"}),labelKey:"chat.shared.capabilityWebSearch"}};function As(l){const e=H.c(10),{capability:t}=l,i=se(),n=Ls[t];if(n){const d=n.icon;let u;e[0]!==n.labelKey||e[1]!==i?(u=i(n.labelKey),e[0]=n.labelKey,e[1]=i,e[2]=u):u=e[2];let c;return e[3]!==n.icon||e[4]!==u?(c=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:[d,u]}),e[3]=n.icon,e[4]=u,e[5]=c):c=e[5],c}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 a;return e[8]!==r?(a=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]=a):a=e[9],a}function Ts(l){const e=H.c(59),{model:t,compact:i}=l,n=i===void 0?!1:i,o=se();if(!t){let x;e[0]!==o?(x=o("chat.shared.hoverToPreview"),e[0]=o,e[1]=x):x=e[1];let N;return e[2]!==x?(N=s.jsx("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:x}),e[2]=x,e[3]=N):N=e[3],N}const r=t.costs?.input!=null?t.costs.input*1e6:null,a=t.costs?.output!=null?t.costs.output*1e6:null;let d;e[4]!==t?(d=Oe(t),e[4]=t,e[5]=d):d=e[5];const{provider:u,displayName:c}=d;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 N;e[9]!==r||e[10]!==o?(N=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]=N):N=e[11];let w;e[12]!==a||e[13]!==o?(w=a!=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:["$",a.toFixed(2)," / 1M"]})]}),e[12]=a,e[13]=o,e[14]=w):w=e[14];let M;e[15]!==t.limits||e[16]!==o?(M=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]=M):M=e[17];let g;return e[18]!==x||e[19]!==N||e[20]!==w||e[21]!==M?(g=s.jsxs("div",{className:"flex flex-col gap-2 pt-3 pb-3 px-3 text-xs",children:[x,N,w,M]}),e[18]=x,e[19]=N,e[20]=w,e[21]=M,e[22]=g):g=e[22],g}let h;e[23]!==u?(h=s.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:u}),e[23]=u,e[24]=h):h=e[24];let f;e[25]!==t.logo||e[26]!==t.title?(f=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]=f):f=e[27];let m;e[28]!==c?(m=s.jsx("p",{className:"text-lg font-semibold leading-snug tracking-tight",children:c}),e[28]=c,e[29]=m):m=e[29];let p;e[30]!==f||e[31]!==m?(p=s.jsxs("div",{className:"flex items-center gap-2.5",children:[f,m]}),e[30]=f,e[31]=m,e[32]=p):p=e[32];let j;e[33]!==t.modelId?(j=s.jsx("p",{className:"text-xs text-muted-foreground/50 font-mono",children:t.modelId}),e[33]=t.modelId,e[34]=j):j=e[34];let k;e[35]!==h||e[36]!==p||e[37]!==j?(k=s.jsxs("div",{className:"flex flex-col gap-1 pt-1 pr-6",children:[h,p,j]}),e[35]=h,e[36]=p,e[37]=j,e[38]=k):k=e[38];let b;e[39]!==t.capabilities?(b=t.capabilities&&t.capabilities.length>0&&s.jsx("div",{className:"flex flex-wrap items-center gap-1.5 pb-4 border-b border-border",children:[...new Set(t.capabilities)].map(zs)}),e[39]=t.capabilities,e[40]=b):b=e[40];let S;e[41]!==t.limits||e[42]!==o?(S=t.limits?.contextWindow&&(()=>{const{level:x,labelKey:N,descriptionKey:w}=_s(t.limits.contextWindow);return s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsx("span",{className:"text-xs font-medium text-muted-foreground",children: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(M=>s.jsx("div",{className:pe("w-2 h-2 rounded-full",M<=x?Ms[x-1]:"bg-muted")},M))}),s.jsx("span",{className:"text-xs text-muted-foreground font-medium",children:o(N)}),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]=S):S=e[43];let I;e[44]!==t.limits||e[45]!==o?(I=t.limits?.maxOutputTokens&&s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx("span",{className:"text-xs font-medium text-muted-foreground",children: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:Os(t.limits.maxOutputTokens,o)})]})]}),e[44]=t.limits,e[45]=o,e[46]=I):I=e[46];let P;e[47]!==r||e[48]!==a||e[49]!==o?(P=(r!=null||a!=null)&&(()=>{const{level:x,labelKey:N}=r!=null?Ps(r):{level:0,labelKey:null};return s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx("span",{className:"text-xs font-medium text-muted-foreground",children: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:pe("text-sm font-bold leading-none",w<=x?Es[x-1]:"text-muted-foreground/20"),children:"$"},w))}),s.jsx("span",{className:"text-xs text-muted-foreground font-medium",children:N?o(N):""})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[r!=null&&s.jsxs("div",{className:"flex justify-between items-center",children:[s.jsx("span",{className:"text-xs text-muted-foreground",children:o("chat.shared.input")}),s.jsxs("span",{className:"text-xs text-foreground",children:["$",r.toFixed(2)," / 1M"," ",o("chat.shared.tokens")]})]}),a!=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:["$",a.toFixed(2)," / 1M"," ",o("chat.shared.tokens")]})]})]})]})})(),e[47]=r,e[48]=a,e[49]=o,e[50]=P):P=e[50];let E;e[51]!==S||e[52]!==I||e[53]!==P?(E=s.jsxs("div",{className:"flex flex-col gap-6",children:[S,I,P]}),e[51]=S,e[52]=I,e[53]=P,e[54]=E):E=e[54];let _;return e[55]!==E||e[56]!==k||e[57]!==b?(_=s.jsxs("div",{className:"flex flex-col gap-5 py-1 px-1.5",children:[k,b,E]}),e[55]=E,e[56]=k,e[57]=b,e[58]=_):_=e[58],_}function zs(l){return s.jsx(As,{capability:l},l)}function rt(l){const e=H.c(22),{model:t,placeholder:i,isLoading:n}=l,o=n===void 0?!1:n,r=se();let a;e[0]!==i||e[1]!==r?(a=i??r("chat.shared.selectModel"),e[0]=i,e[1]=r,e[2]=a):a=e[2];const d=a;if(o){let b;return e[3]===Symbol.for("react.memo_cache_sentinel")?(b=s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(ee,{className:"w-5 h-5 rounded-sm shrink-0"}),s.jsx(ee,{className:"w-16 h-3 hidden md:block"})]}),e[3]=b):b=e[3],b}if(!t){let b;e[4]!==d?(b=s.jsx("span",{className:"text-sm text-muted-foreground",children:d}),e[4]=d,e[5]=b):b=e[5];let S;e[6]===Symbol.for("react.memo_cache_sentinel")?(S=s.jsx(ze,{size:14,className:"text-muted-foreground opacity-50 shrink-0"}),e[6]=S):S=e[6];let I;return e[7]!==b?(I=s.jsxs("div",{className:"flex items-center gap-1.5",children:[b,S]}),e[7]=b,e[8]=I):I=e[8],I}let u;e[9]!==t?(u=Oe(t),e[9]=t,e[10]=u):u=e[10];const{displayName:c}=u;let h;e[11]!==t?(h=Ee(t),e[11]=t,e[12]=h):h=e[12];const f=h;let m;e[13]!==t.title||e[14]!==f?(m=s.jsx("img",{src:f,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]=f,e[15]=m):m=e[15];let p;e[16]!==c?(p=s.jsx("span",{className:"text-sm truncate whitespace-nowrap text-muted-foreground max-w-[100px] sm:max-w-none",children:c}),e[16]=c,e[17]=p):p=e[17];let j;e[18]===Symbol.for("react.memo_cache_sentinel")?(j=s.jsx(ze,{size:14,className:"text-muted-foreground opacity-50 shrink-0"}),e[18]=j):j=e[18];let k;return e[19]!==m||e[20]!==p?(k=s.jsxs("div",{className:"flex items-center gap-1.5 min-w-0 overflow-hidden",children:[m,p,j]}),e[19]=m,e[20]=p,e[21]=k):k=e[21],k}const Rs=["vision","image","file","audio","video"],at=["image/png","image/jpeg","image/gif","image/webp"],ct=["application/vnd.openxmlformats-officedocument.presentationml.presentation","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"];function Pe(l){const e=l?.capabilities;return e?Rs.some(t=>e.includes(t)):!1}function Gi(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&&at.includes(l)||n&&l==="application/pdf"||o&&l.startsWith("audio/")||r&&l.startsWith("video/")||Pe(e)&&ct.includes(l))}function Xi(l){const e=l?.capabilities??[],t=["text/*"];return(e.includes("vision")||e.includes("image"))&&t.push(...at),e.includes("file")&&t.push("application/pdf"),e.includes("audio")&&t.push("audio/*"),e.includes("video")&&t.push("video/*"),Pe(l)&&t.push(...ct),t.join(",")}function Yi(l){const e=l?.capabilities??[],t=[];return(e.includes("vision")||e.includes("image"))&&t.push("chat.shared.fileTypeImages"),e.includes("file")&&t.push("chat.shared.fileTypePdfs"),e.includes("audio")&&t.push("chat.shared.fileTypeAudio"),e.includes("video")&&t.push("chat.shared.fileTypeVideo"),Pe(l)&&t.push("chat.shared.fileTypeOffice"),{parts:t,count:t.length}}const dt=["smarter","faster","cheaper"],Fs={smarter:"chat.decopilot.tierSmarter",faster:"chat.decopilot.tierFaster",cheaper:"chat.decopilot.tierCheaper"},Ds=[{tier:"smarter",prefixes:["anthropic/claude-opus-4.8","anthropic/claude-sonnet-4.6","anthropic/claude-4.6-sonnet","openai/gpt-5.3-codex","google/gemini-3-pro","google/gemini-2.5-pro","cohere/command-r-plus","cohere/command-a"]},{tier:"faster",prefixes:["anthropic/claude-haiku-4.5","anthropic/claude-4.5-haiku","google/gemini-3-flash","openai/gpt-5.1-codex-mini","x-ai/grok-code-fast","x-ai/grok-3","mistralai/mistral-large","mistralai/codestral","mistralai/mistral-medium","minimax/minimax-m1"]},{tier:"cheaper",prefixes:["google/gemini-2.5-flash-lite","google/gemini-2.5-flash","google/gemini-2.0-flash","deepseek/deepseek-v3","openai/gpt-oss-120b","mistralai/mistral-small","mistralai/pixtral","cohere/command-r"]}],Ks=Ds.flatMap(({tier:l,prefixes:e})=>e.map(t=>({tier:l,prefix:t}))).sort((l,e)=>e.prefix.length-l.prefix.length),$s="google/gemini-2.5-pro",Be=new Map;function Us(l){const e=Be.get(l);if(e!==void 0)return e;let t=null;if(l.endsWith(":free"))t="cheaper";else for(const{tier:i,prefix:n}of Ks)if(l.startsWith(n)){if(n===$s&&l.length>n.length&&l[n.length]==="-"){const r=l[n.length+1];if(!r||!/\d/.test(r))continue}t=i;break}return Be.set(l,t),t}function We(l){const e={smarter:[],faster:[],cheaper:[],other:[]};for(const t of l){const i=Us(t.modelId);e[i??"other"].push(t)}for(const t of Object.keys(e))e[t].sort((i,n)=>i.title.localeCompare(n.title));return e}const ut="studio:model-shortlist:",Bs=new Set(["anthropic/claude-opus-4.8","anthropic/claude-sonnet-4.6","anthropic/claude-4.6-sonnet","anthropic/claude-sonnet-4.6:extended","openai/gpt-5.3-codex","google/gemini-3-pro-preview","google/gemini-2.5-pro","anthropic/claude-haiku-4.5","anthropic/claude-haiku-4.5-20251001","anthropic/claude-4.5-haiku","google/gemini-3-flash-preview","openai/gpt-5.1-codex-mini","x-ai/grok-code-fast-1","google/gemini-2.5-flash","deepseek/deepseek-v3.2","google/gemini-2.5-flash-lite","openai/gpt-oss-120b:free"]);function Ws(l){try{const e=localStorage.getItem(ut+l);return e?new Set(JSON.parse(e)):null}catch{return null}}function Vs(l,e){localStorage.setItem(ut+l,JSON.stringify([...e]))}function Hs(l){const e=H.c(21),{model:t,onHover:i}=l;let n;e[0]!==t?(n=Oe(t),e[0]=t,e[1]=n):n=e[1];const{displayName:o,provider:r}=n;let a;e[2]!==t?(a=Ee(t),e[2]=t,e[3]=a):a=e[3];const d=a;let u;e[4]!==t||e[5]!==i?(u=()=>i(t),e[4]=t,e[5]=i,e[6]=u):u=e[6];let c;e[7]!==t.title||e[8]!==d?(c=s.jsx("img",{src:d,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]=d,e[9]=c):c=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 f;e[12]!==r?(f=s.jsx("span",{className:"text-xs text-muted-foreground/60 leading-tight",children:r}),e[12]=r,e[13]=f):f=e[13];let m;e[14]!==h||e[15]!==f?(m=s.jsxs("div",{className:"flex flex-col flex-1 min-w-0",children:[h,f]}),e[14]=h,e[15]=f,e[16]=m):m=e[16];let p;return e[17]!==u||e[18]!==c||e[19]!==m?(p=s.jsxs("div",{className:"flex items-center gap-2.5 py-2 px-3 hover:bg-accent cursor-pointer rounded-lg",onMouseEnter:u,children:[c,m]}),e[17]=u,e[18]=c,e[19]=m,e[20]=p):p=e[20],p}function qs(l){const e=H.c(16),{error:t,onRetry:i}=l,n=se();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(jt,{className:"size-5 text-destructive"})}),e[0]=o):o=e[0];const r=n("chat.decopilot.failedToLoadModels");let a;e[1]!==r?(a=s.jsx("p",{className:"text-sm font-medium text-foreground",children:r}),e[1]=r,e[2]=a):a=e[2];const d=t?.message||n("chat.decopilot.couldNotFetchModels"),u=" "+n("chat.decopilot.tryAnotherProviderOrRetry");let c;e[3]!==d||e[4]!==u?(c=s.jsxs("p",{className:"text-xs text-muted-foreground max-w-[260px]",children:[d,u]}),e[3]=d,e[4]=u,e[5]=c):c=e[5];let h;e[6]!==a||e[7]!==c?(h=s.jsxs("div",{className:"flex flex-col gap-1",children:[a,c]}),e[6]=a,e[7]=c,e[8]=h):h=e[8];let f;e[9]===Symbol.for("react.memo_cache_sentinel")?(f=s.jsx(Kt,{className:"size-3.5"}),e[9]=f):f=e[9];const m=n("chat.decopilot.retry");let p;e[10]!==i||e[11]!==m?(p=s.jsx("div",{className:"flex items-center gap-2",children:s.jsxs(ne,{variant:"outline",size:"sm",onClick:i,className:"gap-1.5",children:[f,m]})}),e[10]=i,e[11]=m,e[12]=p):p=e[12];let j;return e[13]!==p||e[14]!==h?(j=s.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-3 px-4 py-8 text-center",children:[o,h,p]}),e[13]=p,e[14]=h,e[15]=j):j=e[15],j}function Gs(){const l=H.c(1);let e;return l[0]===Symbol.for("react.memo_cache_sentinel")?(e=s.jsx("div",{className:"flex-1 overflow-y-auto p-2 space-y-1",children:Array.from({length:6}).map(Xs)}),l[0]=e):e=l[0],e}function Xs(l,e){return s.jsxs("div",{className:"flex items-center gap-2 min-h-8 py-3 px-3 rounded-lg",children:[s.jsx(ee,{className:"size-5 shrink-0 rounded-sm"}),s.jsx(ee,{className:"flex-1 h-4"}),s.jsx(ee,{className:"w-16 h-5 shrink-0 rounded-md"})]},e)}function Ve(l){const e=H.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 a;if(e[2]!==i||e[3]!==o||e[4]!==n){let u;e[6]!==o||e[7]!==n?(u=c=>s.jsx("div",{onClick:()=>n(c),className:"cursor-pointer",children:s.jsx(Hs,{model:c,onHover:o})},c.modelId),e[6]=o,e[7]=n,e[8]=u):u=e[8],a=i.map(u),e[2]=i,e[3]=o,e[4]=n,e[5]=a}else a=e[5];let d;return e[9]!==r||e[10]!==a?(d=s.jsxs("div",{children:[r,a]}),e[9]=r,e[10]=a,e[11]=d):d=e[11],d}function Ce(l,e){return e(l==="other"?"chat.decopilot.tierOther":Fs[l])}function Ys(l){const e=H.c(21),{model:t,isChecked:i,onToggle:n,onHover:o}=l,[r,a]=U.useState(i);r!==i&&a(i);let d;e[0]!==t?(d=Ee(t),e[0]=t,e[1]=d):d=e[1];const u=d;let c;e[2]!==t||e[3]!==o?(c=()=>o(t),e[2]=t,e[3]=o,e[4]=c):c=e[4];let h;e[5]!==t.modelId||e[6]!==n?(h=()=>{a(Qs),n(t.modelId)},e[5]=t.modelId,e[6]=n,e[7]=h):h=e[7];let f;e[8]!==r||e[9]!==h?(f=s.jsx(Pt,{checked:r,onCheckedChange:h}),e[8]=r,e[9]=h,e[10]=f):f=e[10];let m;e[11]!==u||e[12]!==t.title?(m=s.jsx("img",{src:u,className:"w-5 h-5 shrink-0 rounded-sm dark:bg-white dark:rounded-sm dark:p-px",alt:t.title}),e[11]=u,e[12]=t.title,e[13]=m):m=e[13];let p;e[14]!==t.title?(p=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]=p):p=e[15];let j;return e[16]!==c||e[17]!==f||e[18]!==m||e[19]!==p?(j=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:c,children:[f,m,p]}),e[16]=c,e[17]=f,e[18]=m,e[19]=p,e[20]=j):j=e[20],j}function Qs(l){return!l}function Js(l,e){const t=[];for(const i of dt)if(l[i].length>0){t.push({type:"header",label:Ce(i,e)});for(const n of l[i])t.push({type:"model",model:n})}if(l.other.length>0){t.push({type:"header",label:Ce("other",e)});for(const i of l.other)t.push({type:"model",model:i})}return t}function Zs({items:l,shortlistSet:e,onToggle:t,onHover:i}){const n=U.useRef(null),o=us({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 a=l[r.index];return a?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:a.type==="header"?s.jsx("div",{className:"text-xs font-medium text-muted-foreground px-3 pt-3 pb-1",children:a.label}):s.jsx(Ys,{model:a.model,isChecked:e.has(a.model.modelId),onToggle:t,onHover:i})},r.key):null})})})}function ei(l){const e=H.c(30),{keyId:t,searchTerm:i,onHover:n,onModelSelect:o,managing:r,onToggleManage:a,filterModels:d}=l,u=se(),{models:c}=Ht(t),h=d?c.filter(d):c.filter(ti);let f;e[0]!==t?(f=()=>(t?Ws(t):null)??Bs,e[0]=t,e[1]=f):f=e[1];const[m,p]=U.useState(f),[,j]=U.useTransition();let k;e[2]!==t||e[3]!==j?(k=v=>{t&&j(()=>{p(y=>{const C=new Set(y);return C.has(v)?C.delete(v):C.add(v),Vs(t,C),C})})},e[2]=t,e[3]=j,e[4]=k):k=e[4];const b=k,S=i.toLowerCase().trim(),I=v=>S?v.filter(y=>y.title.toLowerCase().includes(S)||y.modelId.toLowerCase().includes(S)):v;if(r){const v=We(I(h)),y=Js(v,u);let C;e[5]!==m?(C=F=>m.has(F.modelId),e[5]=m,e[6]=C):C=e[6];const L=h.filter(C).length;let A;e[7]===Symbol.for("react.memo_cache_sentinel")?(A=s.jsx(et,{size:14}),e[7]=A):A=e[7];let O;e[8]!==u?(O=u("chat.decopilot.back"),e[8]=u,e[9]=O):O=e[9];let R;return e[10]!==a||e[11]!==O?(R=s.jsxs("button",{type:"button",onClick:a,className:"flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground cursor-pointer",children:[A,O]}),e[10]=a,e[11]=O,e[12]=R):R=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:[R,s.jsx("span",{className:"text-xs text-muted-foreground",children:u("chat.decopilot.selectedCount",{count:L})})]}),s.jsx(Zs,{items:y,shortlistSet:m,onToggle:b,onHover:n})]})}let P;e[13]!==m?(P=v=>m.has(v.modelId),e[13]=m,e[14]=P):P=e[14];const E=h.filter(P),_=E.length>0?E:h,x=We(I(_));let N;e[15]!==x||e[16]!==n||e[17]!==o||e[18]!==u?(N=dt.map(v=>s.jsx(Ve,{label:Ce(v,u),models:x[v],onSelect:o,onHover:n},v)),e[15]=x,e[16]=n,e[17]=o,e[18]=u,e[19]=N):N=e[19];let w;e[20]!==u?(w=Ce("other",u),e[20]=u,e[21]=w):w=e[21];let M;e[22]!==x.other||e[23]!==n||e[24]!==o||e[25]!==w?(M=s.jsx(Ve,{label:w,models:x.other,onSelect:o,onHover:n}),e[22]=x.other,e[23]=n,e[24]=o,e[25]=w,e[26]=M):M=e[26];let g;return e[27]!==N||e[28]!==M?(g=s.jsxs("div",{className:"flex-1 overflow-y-auto px-0.5 pt-1 [touch-action:pan-y]",children:[N,M]}),e[27]=N,e[28]=M,e[29]=g):g=e[29],g}function ti(l){return l.asyncResearch!==!0}function si(){const l=H.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(ee,{className:"size-4 shrink-0"}),s.jsx(ee,{className:"flex-1 h-6"}),s.jsx(ee,{className:"w-[140px] h-8 shrink-0"})]})}),l[0]=e):e=l[0];let t;l[1]===Symbol.for("react.memo_cache_sentinel")?(t=s.jsxs("div",{className:"flex-1 flex flex-col md:border-r md:w-[420px] md:min-w-[420px] min-h-0 overflow-hidden",children:[e,s.jsx("div",{className:"flex-1 overflow-y-auto p-2 space-y-1",children:Array.from({length:8}).map(ii)})]}),l[1]=t):t=l[1];let i;l[2]===Symbol.for("react.memo_cache_sentinel")?(i=s.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[s.jsx(ee,{className:"size-6 shrink-0"}),s.jsx(ee,{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(ee,{className:"h-6 w-20 rounded-md"}),s.jsx(ee,{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(ee,{className:"h-4 w-24"}),s.jsx(ee,{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(ee,{className:"h-4 w-16"}),s.jsx(ee,{className:"h-4 w-40"})]})]})]})})]}),l[5]=r):r=l[5],r}function ii(l,e){return s.jsxs("div",{className:"flex items-center gap-2 min-h-8 py-3 px-3 rounded-lg",children:[s.jsx(ee,{className:"size-5 shrink-0 rounded-sm"}),s.jsx(ee,{className:"flex-1 h-4"}),s.jsx(ee,{className:"w-16 h-5 shrink-0 rounded-md"})]},e)}function mt(l){const e=H.c(54),{onClose:t,credentialId:i,onCredentialChange:n,selectedModel:o,onModelChange:r,filterModels:a}=l,d=se(),[u,c]=U.useState(null),[h,f]=U.useState(""),[m,p]=U.useState(!1),j=U.useRef(null),k=Me(),b=Vt();let S;e[0]!==k?.providers?(S=Object.fromEntries((k?.providers??[]).map(oi)),e[0]=k?.providers,e[1]=S):S=e[1];const I=S,P=bt(),{org:E}=xe();let _;e[2]!==n?(_=T=>{n(T),c(null)},e[2]=n,e[3]=_):_=e[3];const x=_;let N;e[4]!==i||e[5]!==t||e[6]!==r?(N=T=>{i&&(r(T),f(""),t())},e[4]=i,e[5]=t,e[6]=r,e[7]=N):N=e[7];const w=N;if(b.length===0){let T;return e[8]===Symbol.for("react.memo_cache_sentinel")?(T=s.jsx("div",{className:"flex items-center justify-center p-8 w-full sm:w-[740px]",children:s.jsx(Is,{})}),e[8]=T):T=e[8],T}let M;e[9]===Symbol.for("react.memo_cache_sentinel")?(M=s.jsx(tt,{size:16,className:"text-muted-foreground shrink-0"}),e[9]=M):M=e[9];let g;e[10]!==m||e[11]!==d?(g=d(m?"chat.decopilot.searchAllModels":"chat.decopilot.searchForModel"),e[10]=m,e[11]=d,e[12]=g):g=e[12];let v;e[13]===Symbol.for("react.memo_cache_sentinel")?(v=T=>f(T.target.value),e[13]=v):v=e[13];let y;e[14]!==h||e[15]!==g?(y=s.jsx(fe,{ref:j,type:"text",placeholder:g,value:h,onChange:v,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[14]=h,e[15]=g,e[16]=y):y=e[16];let C;e[17]!==i||e[18]!==x||e[19]!==b||e[20]!==I||e[21]!==d?(C=b.length>0&&s.jsxs(Lt,{value:i??"",onValueChange:x,children:[s.jsxs(At,{size:"sm",className:"w-auto max-w-[140px] h-8 shrink-0 gap-1.5 px-2 [&>svg:last-child]:hidden",onClick:ni,children:[s.jsx(Tt,{placeholder:d("chat.decopilot.key"),children:(()=>{const T=b.find(Y=>Y.id===i),B=T?I[T.providerId]:void 0,W=be(T?.presetId),q=W?.logo??B?.logo,$=W?.name??B?.name??T?.providerId??"Key";return s.jsxs("span",{className:"flex items-center gap-1.5 min-w-0",children:[q?s.jsx("img",{src:q,alt:$,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:$.slice(0,1).toUpperCase()}),s.jsx("span",{className:"text-xs truncate",children:$})]})})()}),s.jsx(Bt,{className:"size-4 opacity-50 shrink-0 pointer-events-none"})]}),s.jsx(zt,{children:b.map(T=>{const B=I[T.providerId],W=be(T.presetId),q=W?.logo??B?.logo,$=W?.name??B?.name??T.providerId;return s.jsx(Rt,{value:T.id,children:s.jsxs("div",{className:"flex items-center gap-2",children:[q?s.jsx("img",{src:q,alt:$,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:$.slice(0,1).toUpperCase()}),s.jsxs("span",{children:[$," — ",T.label]})]})},T.id)})})]}),e[17]=i,e[18]=x,e[19]=b,e[20]=I,e[21]=d,e[22]=C):C=e[22];let L;e[23]!==y||e[24]!==C?(L=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:[M,y,C]})}),e[23]=y,e[24]=C,e[25]=L):L=e[25];let A;e[26]!==i?(A=T=>{const{error:B,resetError:W}=T;return s.jsx(qs,{error:B,onRetry:W,credentialId:i??void 0})},e[26]=i,e[27]=A):A=e[27];let O;e[28]===Symbol.for("react.memo_cache_sentinel")?(O=s.jsx(Gs,{}),e[28]=O):O=e[28];const R=i??void 0;let F;e[29]===Symbol.for("react.memo_cache_sentinel")?(F=()=>p(li),e[29]=F):F=e[29];let D;e[30]!==a||e[31]!==w||e[32]!==m||e[33]!==h||e[34]!==R?(D=s.jsx(U.Suspense,{fallback:O,children:s.jsx(ei,{keyId:R,searchTerm:h,onHover:c,onModelSelect:w,managing:m,onToggleManage:F,filterModels:a})}),e[30]=a,e[31]=w,e[32]=m,e[33]=h,e[34]=R,e[35]=D):D=e[35];let z;e[36]!==i||e[37]!==A||e[38]!==D?(z=s.jsx(yt,{fallback:A,children:D},i),e[36]=i,e[37]=A,e[38]=D,e[39]=z):z=e[39];let K;e[40]!==m||e[41]!==P||e[42]!==E||e[43]!==d?(K=!m&&s.jsxs("div",{className:"border-t border-border flex",children:[s.jsxs("button",{type:"button",onClick:()=>U.startTransition(()=>p(!0)),className:"flex items-center gap-2 flex-1 px-4 py-2.5 text-xs text-muted-foreground hover:text-foreground hover:bg-accent cursor-pointer",children:[s.jsx(Dt,{className:"size-3.5 shrink-0"}),d("chat.decopilot.manageModels")]}),s.jsx("div",{className:"w-px bg-border shrink-0"}),s.jsxs("button",{type:"button",onClick:()=>P({to:"/$org/settings/ai-providers",params:{org:E.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(Wt,{className:"size-3.5 shrink-0"}),d("chat.decopilot.manageApiKeys")]})]}),e[40]=m,e[41]=P,e[42]=E,e[43]=d,e[44]=K):K=e[44];let V;e[45]!==z||e[46]!==K||e[47]!==L?(V=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:[L,z,K]}),e[45]=z,e[46]=K,e[47]=L,e[48]=V):V=e[48];const J=u??o??null;let G;e[49]!==J?(G=s.jsx("div",{className:"hidden md:flex md:flex-col md:w-[320px] md:shrink-0 p-3",children:s.jsx(Ts,{model:J})}),e[49]=J,e[50]=G):G=e[50];let X;return e[51]!==V||e[52]!==G?(X=s.jsxs("div",{className:"flex flex-col md:flex-row h-full sm:h-[460px] min-h-0",children:[V,G]}),e[51]=V,e[52]=G,e[53]=X):X=e[53],X}function li(l){return!l}function ni(l){return l.stopPropagation()}function oi(l){return[l.id,l]}function ri(l){const e=H.c(12),{onClose:t}=l,{credentialId:i,setCredentialId:n,selectedModel:o,setModel:r}=_e();let a;e[0]!==n?(a=c=>{ie("chat_credential_changed",{credential_id:c}),n(c)},e[0]=n,e[1]=a):a=e[1];let d;e[2]!==i||e[3]!==o?.modelId||e[4]!==r?(d=c=>{i&&(ie("chat_model_changed",{from_model_id:o?.modelId??null,to_model_id:c.modelId,to_model_provider:c.providerId??null,credential_id:i}),r({...c,keyId:i}))},e[2]=i,e[3]=o?.modelId,e[4]=r,e[5]=d):d=e[5];let u;return e[6]!==i||e[7]!==t||e[8]!==o||e[9]!==a||e[10]!==d?(u=s.jsx(mt,{onClose:t,credentialId:i,onCredentialChange:a,selectedModel:o,onModelChange:d}),e[6]=i,e[7]=t,e[8]=o,e[9]=a,e[10]=d,e[11]=u):u=e[11],u}function ai(l){const e=H.c(2),{onClose:t}=l;let i;return e[0]!==t?(i=s.jsx(ri,{onClose:t}),e[0]=t,e[1]=i):i=e[1],i}function ci(l){const e=H.c(2);let t;return e[0]!==l?(t=s.jsx(mt,{...l}),e[0]=l,e[1]=t):t=e[1],t}const di=[{tier:"fast",labelKey:"chat.desktopCli.tierFastDescription"},{tier:"smart",labelKey:"chat.desktopCli.tierSmartDescription"},{tier:"thinking",labelKey:"chat.desktopCli.tierThinkingDescription"}];function ht(l){const e=H.c(11),{modelSet:t,selectedModelId:i,onSelect:n}=l,o=se();let r,a;if(e[0]!==t.logo||e[1]!==t.models||e[2]!==t.tiers||e[3]!==n||e[4]!==i||e[5]!==o){const u=Object.fromEntries(t.models.map(ui));r="flex flex-col p-2 w-[320px]",a=di.map(c=>{const{tier:h,labelKey:f}=c,m=t.tiers[h];if(!m.modelId)return null;const p=u[m.modelId];if(!p)return null;const j=i===m.modelId;return s.jsxs("button",{type:"button",onClick:()=>n(p),className:pe("flex items-center gap-3 px-3 py-2.5 rounded-lg text-left hover:bg-accent",j&&"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(f)})]})]},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]=a}else r=e[6],a=e[7];let d;return e[8]!==r||e[9]!==a?(d=s.jsx("div",{className:r,children:a}),e[8]=r,e[9]=a,e[10]=d):d=e[10],d}function ui(l){return[l.modelId,l]}const mi=[{providerId:"claude-code",modelId:"claude-code:haiku",title:"Claude Code Haiku",description:"Fast and lightweight",capabilities:["text"],limits:null,costs:null},{providerId:"claude-code",modelId:"claude-code:sonnet",title:"Claude Code Sonnet 5",description:"Balanced performance",capabilities:["text","reasoning"],limits:null,costs:null},{providerId:"claude-code",modelId:"claude-code:opus",title:"Claude Code Opus",description:"Most capable",capabilities:["text","reasoning"],limits:null,costs:null},{providerId:"claude-code",modelId:"claude-code:opus-1m",title:"Claude Code Opus 4.8 1M",description:"Most capable, 1M context window",capabilities:["text","reasoning"],limits:{contextWindow:1e6,maxOutputTokens:null},costs:null}],je="https://assets.decocache.com/decocms/6ac44f1c-c0cf-4480-84b5-2ae6fe742d0b/codex-app.png.png",hi=[{providerId:"codex",modelId:"codex:gpt-5.6-sol",title:"GPT-5.6 Sol",description:"Frontier Codex model for deep reasoning, complex coding, and real-world work",capabilities:["text","reasoning"],logo:je,limits:null,costs:null},{providerId:"codex",modelId:"codex:gpt-5.6-terra",title:"GPT-5.6 Terra",description:"Balanced Codex model for everyday coding and agent work",capabilities:["text","reasoning"],logo:je,limits:null,costs:null},{providerId:"codex",modelId:"codex:gpt-5.6-luna",title:"GPT-5.6 Luna",description:"Fast Codex model for lightweight coding tasks and titles",capabilities:["text","reasoning"],logo:je,limits:null,costs:null},{providerId:"codex",modelId:"codex:gpt-5.3-codex-spark",title:"GPT-5.3 Codex Spark",description:"Ultra-fast coding model",capabilities:["text","reasoning"],logo:je,limits:null,costs:null}],fi="https://decoims.com/decocms/93e4059c-e598-412b-87eb-54d72a946ec8/claude-stroke-rounded.svg",pi="https://decoims.com/decocms/9170ffd4-b9cc-4661-ad8f-ae2eea019e00/codex.svg";function xi(l){return{fast:{modelId:"claude-code:haiku",label:l("chat.agentModels.haikuLabel"),description:l("chat.agentModels.quickerResponses"),iconNode:s.jsx(Se,{size:16})},smart:{modelId:"claude-code:sonnet",label:l("chat.agentModels.sonnetLabel"),description:l("chat.agentModels.balancedQuality"),iconNode:s.jsx(Se,{size:16})},thinking:{modelId:"claude-code:opus-1m",label:l("chat.agentModels.opusLabel"),description:l("chat.agentModels.deeperReasoning"),iconNode:s.jsx(Se,{size:16})}}}function gi(l){return{fast:{modelId:"codex:gpt-5.6-luna",label:l("chat.agentModels.gptLunaLabel"),description:l("chat.agentModels.quickerResponses"),iconNode:s.jsx(Ne,{size:16})},smart:{modelId:"codex:gpt-5.6-terra",label:l("chat.agentModels.gptTerraLabel"),description:l("chat.agentModels.balancedQuality"),iconNode:s.jsx(Ne,{size:16})},thinking:{modelId:"codex:gpt-5.6-sol",label:l("chat.agentModels.gptSolLabel"),description:l("chat.agentModels.deeperReasoning"),iconNode:s.jsx(Ne,{size:16})}}}function ft(l,e){return l==="claude-code"?{logo:fi,tiers:xi(e),models:mi}:l==="codex"?{logo:pi,tiers:gi(e),models:hi}:null}function vi(l){const e=H.c(12),{onClose:t,agent:i}=l,n=se(),o=_e(),r=i??o.pendingHarnessId??"decopilot";let a;e[0]!==r||e[1]!==n?(a=ft(r,n),e[0]=r,e[1]=n,e[2]=a):a=e[2];const d=a;if(!d){let f;return e[3]!==t?(f=s.jsx(ai,{onClose:t}),e[3]=t,e[4]=f):f=e[4],f}const u=o.selectedModel?.modelId??d.tiers[o.simpleModeTier].modelId;let c;e[5]!==t||e[6]!==o?(c=f=>{o.setModel({...f,keyId:void 0}),t()},e[5]=t,e[6]=o,e[7]=c):c=e[7];let h;return e[8]!==d||e[9]!==u||e[10]!==c?(h=s.jsx(ht,{modelSet:d,selectedModelId:u,onSelect:c}),e[8]=d,e[9]=u,e[10]=c,e[11]=h):h=e[11],h}function bi(l){const e=H.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=se();let o;e[3]!==t||e[4]!==n?(o=t?ft(t,n):null,e[3]=t,e[4]=n,e[5]=o):o=e[5];const r=o;if(!r){let c;return e[6]!==i?(c=s.jsx(ci,{...i}),e[6]=i,e[7]=c):c=e[7],c}const a=i.selectedModel?.modelId??r.tiers.smart.modelId;let d;e[8]!==i?(d=c=>{i.onModelChange(c),i.onClose()},e[8]=i,e[9]=d):d=e[9];let u;return e[10]!==r||e[11]!==a||e[12]!==d?(u=s.jsx(ht,{modelSet:r,selectedModelId:a,onSelect:d}),e[10]=r,e[11]=a,e[12]=d,e[13]=u):u=e[13],u}function Qi(l){const e=H.c(49),{variant:t,className:i,placeholder:n,model:o,isLoading:r,credentialId:a,onCredentialChange:d,onModelChange:u,filterModels:c,agent:h}=l,f=t===void 0?"borderless":t,m=n===void 0?"Select model":n,p=se(),[j,k]=U.useState(!1),b=u!==void 0,S=Mt(),I=f==="borderless"?"ghost":"outline",P=f==="borderless"&&"md:border-none";let E;e[0]!==i||e[1]!==P?(E=pe("text-sm hover:bg-accent rounded-lg py-0.5 px-1 gap-1 shadow-none cursor-pointer border-0 group focus-visible:ring-0 focus-visible:ring-offset-0 min-w-0 shrink justify-start overflow-hidden",P,i),e[0]=i,e[1]=P,e[2]=E):E=e[2];let _;e[3]!==r||e[4]!==o||e[5]!==m||e[6]!==b?(_=b?s.jsx(rt,{model:o??null,placeholder:m,isLoading:r}):s.jsx(ji,{placeholder:m}),e[3]=r,e[4]=o,e[5]=m,e[6]=b,e[7]=_):_=e[7];let x;e[8]!==I||e[9]!==E||e[10]!==_?(x=s.jsx(ne,{variant:I,size:"sm",className:E,children:_}),e[8]=I,e[9]=E,e[10]=_,e[11]=x):x=e[11];const N=x;let w;e[12]===Symbol.for("react.memo_cache_sentinel")?(w=s.jsx(si,{}),e[12]=w):w=e[12];let M;e[13]!==h||e[14]!==a||e[15]!==c||e[16]!==o||e[17]!==d||e[18]!==u||e[19]!==b?(M=s.jsx(U.Suspense,{fallback:w,children:b?s.jsx(bi,{onClose:()=>k(!1),agent:h,credentialId:a??null,onCredentialChange:d??yi,selectedModel:o??null,onModelChange:u,filterModels:c}):s.jsx(vi,{onClose:()=>k(!1),agent:h})}),e[13]=h,e[14]=a,e[15]=c,e[16]=o,e[17]=d,e[18]=u,e[19]=b,e[20]=M):M=e[20];const g=M;if(S){let O;e[21]!==N?(O=s.jsx(Ct,{asChild:!0,children:N}),e[21]=N,e[22]=O):O=e[22];let R;e[23]!==p?(R=p("chat.selectModel.selectModel"),e[23]=p,e[24]=R):R=e[24];let F;e[25]!==R?(F=s.jsx(wt,{className:"sr-only",children:R}),e[25]=R,e[26]=F):F=e[26];let D;e[27]!==g?(D=s.jsx("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:g}),e[27]=g,e[28]=D):D=e[28];let z;e[29]!==F||e[30]!==D?(z=s.jsxs(It,{className:"p-0 flex flex-col max-h-[95vh]",children:[F,D]}),e[29]=F,e[30]=D,e[31]=z):z=e[31];let K;return e[32]!==j||e[33]!==O||e[34]!==z?(K=s.jsxs(_t,{open:j,onOpenChange:k,children:[O,z]}),e[32]=j,e[33]=O,e[34]=z,e[35]=K):K=e[35],K}let v;e[36]!==N?(v=s.jsx(kt,{asChild:!0,children:N}),e[36]=N,e[37]=v):v=e[37];let y;e[38]!==p?(y=p("chat.selectModel.selectModel"),e[38]=p,e[39]=y):y=e[39];let C;e[40]!==y?(C=s.jsx(Je,{className:"sr-only",children:y}),e[40]=y,e[41]=C):C=e[41];let L;e[42]!==g||e[43]!==C?(L=s.jsxs(Qe,{className:"p-0 gap-0 sm:max-w-fit overflow-hidden h-[100dvh] sm:h-auto max-h-[100dvh] sm:max-h-[85vh] w-full max-w-full sm:max-w-fit rounded-none sm:rounded-xl border-0 sm:border",closeButtonClassName:"top-3.5 right-3.5 z-20",children:[C,g]}),e[42]=g,e[43]=C,e[44]=L):L=e[44];let A;return e[45]!==j||e[46]!==v||e[47]!==L?(A=s.jsxs(Ye,{open:j,onOpenChange:k,children:[v,L]}),e[45]=j,e[46]=v,e[47]=L,e[48]=A):A=e[48],A}function yi(){}function ji(l){const e=H.c(4),{placeholder:t}=l,{selectedModel:i,isModelsLoading:n}=_e();let o;return e[0]!==n||e[1]!==i||e[2]!==t?(o=s.jsx(rt,{model:i,placeholder:t,isLoading:n}),e[0]=n,e[1]=i,e[2]=t,e[3]=o):o=e[3],o}export{Ns as C,Qi as M,Is as N,ot as P,Xi as a,be as b,Yi as g,Gi as i,Pe as m};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{V as Nt,c as M,r as V,m as ce,j as n,b as re,k as Ue,B as Y,o as Se,e as Fe,K as X,W as _e,X as de,Y as Ne,Z as Oe,n as be,_ as Ot,t as ke,x as Ke,p as le,Q as It,E as Et,a as Tt}from"./index-DAtTWfgt.js";import{W as ct,g as wt,u as ze,S as At}from"./use-mcp-client-B36Osh-D.js";import{I as Ge}from"./integration-icon-BFQyCHkv.js";import{c as Ce,b as dt,h as ut,a as mt,d as ft,e as pt}from"./dialog-poX5N6OF.js";import{c as Be,T as Me,a as Ve}from"./tooltip-D1kWwXpZ.js";import{j as Qe,g as gt,k as Lt}from"./agent-icon-D8X6NgHQ.js";import{u as ne,t as kt,m as Rt,s as Ft,g as Pt,p as Dt,F as $t,b as qt,a as Kt,c as Ut}from"./companions-core-BBPRO-hx.js";import{i as ht}from"./CheckCircle-BPEhKJ6_.js";import{F as ue,a as Ie,b as me,c as Le,d as fe,e as pe,f as zt}from"./form-CBy1yFE7.js";import{I as Ee}from"./input-BTaZQTwt.js";import{i as Gt}from"./Check-BqbTs6Sp.js";import{a as xt}from"./Copy01-DqXF8bW_.js";import{i as Bt}from"./Settings02-BMEbk95n.js";import{s as Mt}from"./Eye-Bk2Xgrvg.js";import{u as Vt}from"./use-debounced-value-CV3OhKhZ.js";import{f as bt,a as Qt,p as Ht}from"./provision-repo-scoped-github-connection-2iDn-wQ1.js";import{c as Wt,e as Yt}from"./extract-connection-data-BP-6YHKf.js";import{u as Zt}from"./useQueries-CF9YH8lZ.js";import{a as Xt}from"./authenticate-and-persist-oauth-Bkljayza.js";function Jt(s,e){return Zt({...s,queries:s.queries.map(t=>({...t,suspense:!0,throwOnError:Nt,enabled:!0,placeholderData:void 0}))},e)}const en=/^[a-zA-Z][a-zA-Z\d+.-]*:/,tn=/^[a-zA-Z][a-zA-Z\d+.-]*:\/\//,nn=/^[^\s/:?#]+\.[^\s/:?#]+:\d+(?:[/?#]|$)/,on=/^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/i;function Re(s){const e=s.trim();if(!e)return{ok:!1,error:"Enter a website URL."};const t=en.test(e),o=tn.test(e),c=nn.test(e);if(t&&!o&&!c)return{ok:!1,error:"Use an HTTP or HTTPS website URL."};const a=o?e:`https://${e}`;let u;try{u=new URL(a)}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(l=>!l||!on.test(l))?{ok:!1,error:"Enter a valid website URL."}:(u.protocol="https:",{ok:!0,value:u.origin})}function To(s,e){if(!s.trim())return!0;const t=Re(s);if(!t.ok||!e)return!1;const o=Re(e);return o.ok&&o.value===t.value}function wo(s){if(!s)return null;const e=Re(s);return e.ok?new URL(e.value).hostname:null}function sn(s){const e=M.c(14),{children:t,className:o,wrapperClassName:c}=s,[a,u]=V.useState(!0);let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=j=>{if(!j)return;const x=()=>{const f=j.scrollHeight-j.scrollTop-j.clientHeight<8;u(f)};x(),j.addEventListener("scroll",x,{passive:!0});const b=new ResizeObserver(x);b.observe(j);for(const f of Array.from(j.children))b.observe(f);return()=>{j.removeEventListener("scroll",x),b.disconnect()}},e[0]=d):d=e[0];const l=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:l,className:o,children:t}),e[3]=t,e[4]=o,e[5]=i):i=e[5];const r=a?"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 rn(s){const e=M.c(25),{icon:t,title:o,headline:c,required:a,attention:u,action:d}=s,l=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]!==a||e[3]!==l?(r=a&&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:l("commerceOnboarding.companionCard.required")}),e[2]=a,e[3]=l,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 x;e[15]!==g||e[16]!==j?(x=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]=x):x=e[17];let b;e[18]!==d?(b=n.jsx("div",{className:"shrink-0",children:d}),e[18]=d,e[19]=b):b=e[19];let f;return e[20]!==i||e[21]!==r||e[22]!==x||e[23]!==b?(f=n.jsxs("div",{className:i,children:[r,x,b]}),e[20]=i,e[21]=r,e[22]=x,e[23]=b,e[24]=f):f=e[24],f}function Ct(s){const e=M.c(12),{connecting:t,disabled:o,title:c,primary:a,onConnect:u}=s,d=re(),l=a?"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]!==l||e[8]!==p||e[9]!==i||e[10]!==r?(g=n.jsx(Y,{type:"button",variant:l,size:"sm",disabled:p,onClick:u,"aria-label":i,children:r}),e[6]=u,e[7]=l,e[8]=p,e[9]=i,e[10]=r,e[11]=g):g=e[11],g}function an(s){const e=M.c(11),{disabled:t,title:o,onConfigure:c}=s,a=re();let u;e[0]!==a||e[1]!==o?(u=a("commerceOnboarding.companionCard.configureAriaLabel",{title:o}),e[0]=a,e[1]=o,e[2]=u):u=e[2];let d;e[3]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx(Qe,{size:16}),e[3]=d):d=e[3];let l;e[4]!==a?(l=a("commerceOnboarding.companionCard.finishSetup"),e[4]=a,e[5]=l):l=e[5];let p;return e[6]!==t||e[7]!==c||e[8]!==u||e[9]!==l?(p=n.jsxs(Y,{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,l]}),e[6]=t,e[7]=c,e[8]=u,e[9]=l,e[10]=p):p=e[10],p}function ln(s){const e=M.c(8),{controls:t}=s,o=re();let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx(ht,{size:16,className:"text-success"}),e[0]=c):c=e[0];let a;e[1]!==o?(a=o("commerceOnboarding.companionCard.connected"),e[1]=o,e[2]=a):a=e[2];let u;e[3]!==a?(u=n.jsxs("span",{className:"flex items-center gap-1.5 text-sm text-muted-foreground",children:[c," ",a]}),e[3]=a,e[4]=u):u=e[4];let d;return e[5]!==t||e[6]!==u?(d=n.jsxs("div",{className:"flex items-center gap-1",children:[u,t]}),e[5]=t,e[6]=u,e[7]=d):d=e[7],d}function lt(s){const e=M.c(38);let t,o,c,a,u;e[0]!==s?({value:u,onChange:o,placeholder:c,className:t,...a}=s,e[0]=s,e[1]=t,e[2]=o,e[3]=c,e[4]=a,e[5]=u):(t=e[1],o=e[2],c=e[3],a=e[4],u=e[5]);const[d,l]=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=()=>{l(!d)},e[8]=d,e[9]=m):m=e[9];const y=m,j=d?"text":"password";let x;e[10]!==t?(x=ce("pr-20",t),e[10]=t,e[11]=x):x=e[11];let b;e[12]!==o||e[13]!==c||e[14]!==a||e[15]!==j||e[16]!==x||e[17]!==u?(b=n.jsx(Ee,{type:j,value:u,onChange:o,placeholder:c,className:x,...a}),e[12]=o,e[13]=c,e[14]=a,e[15]=j,e[16]=x,e[17]=u,e[18]=b):b=e[18];const f=d?"Hide password":"Show password";let S;e[19]!==d?(S=d?n.jsx(Bt,{size:16}):n.jsx(Mt,{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(Y,{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(Gt,{size:16}):n.jsx(xt,{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(Y,{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]!==b?(I=n.jsxs("div",{className:"relative",children:[b,w]}),e[35]=w,e[36]=b,e[37]=I):I=e[37],I}function He(s){const e=M.c(19),{card:t,selfClient:o,org:c,onDone:a,onError:u}=s,d=Se();let l;e[0]!==t||e[1]!==o?(l=async x=>{const b={...t.configurationState??{},...x};await o.callTool({name:"COLLECTION_CONNECTIONS_UPDATE",arguments:{id:t.linkedConnectionId||t.candidateConnectionId,data:{configuration_state:b}}})},e[0]=t,e[1]=o,e[2]=l):l=e[2];let p;e[3]!==a||e[4]!==c||e[5]!==d?(p=async()=>{await d.invalidateQueries({queryKey:X.commerceDiscoveryCompanionConnectionsPrefix(c.id)}),a()},e[3]=a,e[4]=c,e[5]=d,e[6]=p):p=e[6];let i;e[7]!==u?(i=x=>{u?.(x)},e[7]=u,e[8]=i):i=e[8];let r;e[9]!==l||e[10]!==p||e[11]!==i?(r={mutationFn:l,onSuccess:p,onError:i},e[9]=l,e[10]=p,e[11]=i,e[12]=r):r=e[12];const g=Fe(r);let m;e[13]!==g?(m=x=>g.mutate(x),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 cn=_e({accountName:de().min(1,"Informe o nome da conta"),appKey:de().optional(),appToken:de().optional()});function dn(s){const e=M.c(73),{card:t,selfClient:o,org:c,onDone:a,onIsPendingChange:u}=s,d=re();let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=Ne(cn),e[0]=l):l=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:l,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 x;e[13]!==t||e[14]!==a||e[15]!==c||e[16]!==o?(x={card:t,selfClient:o,org:c,onDone:a},e[13]=t,e[14]=a,e[15]=c,e[16]=o,e[17]=x):x=e[17];const{save:b,isPending:f,error:S}=He(x);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]!==b){let P;e[25]!==b?(P=async E=>{b(E)},e[25]=b,e[26]=P):P=e[26],T=m.handleSubmit(P),e[22]=m,e[23]=b,e[24]=T}else T=e[24];const C=T;let v;e[27]!==f||e[28]!==d?(v=P=>{const{field:E}=P;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=P=>{const{field:E}=P;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 R;e[39]!==f||e[40]!==d?(R=P=>{const{field:E}=P;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]=R):R=e[41];let _;e[42]!==m.control||e[43]!==R?(_=n.jsx(ue,{control:m.control,name:"appToken",render:R}),e[42]=m.control,e[43]=R,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 D;e[50]!==S||e[51]!==d?(D=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]=D):D=e[52];let F;e[53]!==d?(F=d("commerceOnboarding.vtexConfigForm.cancelButton"),e[53]=d,e[54]=F):F=e[54];let $;e[55]!==f||e[56]!==a||e[57]!==F?($=n.jsx(Y,{type:"button",variant:"outline",onClick:a,disabled:f,children:F}),e[55]=f,e[56]=a,e[57]=F,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(Y,{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]!==D||e[71]!==z?(G=n.jsxs("form",{onSubmit:C,className:"space-y-4",children:[O,D,z]}),e[68]=C,e[69]=O,e[70]=D,e[71]=z,e[72]=G):G=e[72],G}function We(s){const e=M.c(29),{options:t,value:o,onChange:c,disabled:a,ariaLabel:u,searchPlaceholder:d,hideSearch:l}=s,p=d===void 0?"Buscar...":d,i=l===void 0?!1:l,[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(un),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 x=j;let b;e[6]!==a||e[7]!==y||e[8]!==c?(b=function(v){if(a||!["ArrowDown","ArrowRight","ArrowUp","ArrowLeft","Home","End"].includes(v.key))return;v.preventDefault();const I=v.currentTarget.dataset.value,A=y.indexOf(I),R=y.length;if(R===0)return;let _;v.key==="ArrowDown"||v.key==="ArrowRight"?_=(A+1)%R:v.key==="ArrowUp"||v.key==="ArrowLeft"?_=(A-1+R)%R:v.key==="Home"?_=0:_=R-1;const O=y[_];c(O),v.currentTarget.closest('[role="radiogroup"]')?.querySelector(`[data-value="${CSS.escape(O)}"]`)?.focus()},e[6]=a,e[7]=y,e[8]=c,e[9]=b):b=e[9];const f=b;let S;e[10]!==u||e[11]!==a||e[12]!==i||e[13]!==r||e[14]!==p?(S=i?null:n.jsxs("div",{className:"relative",children:[n.jsx(gt,{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:a,placeholder:p,"aria-label":`Buscar ${u}`,className:"h-8 pl-8"})]}),e[10]=u,e[11]=a,e[12]=i,e[13]=r,e[14]=p,e[15]=S):S=e[15];let h;e[16]!==a||e[17]!==m||e[18]!==f||e[19]!==c||e[20]!==x||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:a,"data-value":C.value,tabIndex:C.value===x?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(ht,{size:16,className:"shrink-0 text-primary"}):null]},C.value)}),e[16]=a,e[17]=m,e[18]=f,e[19]=c,e[20]=x,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 un(s){return s.value}function Ye(s){const e=M.c(16),{label:t,iconSize:o,className:c,iconClassName:a,labelClassName:u}=s,d=o===void 0?14:o;let l;e[0]!==c?(l=ce("inline-flex items-center gap-2",c),e[0]=c,e[1]=l):l=e[1];let p;e[2]!==a?(p=ce("shrink-0 animate-spin",a),e[2]=a,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]!==l||e[13]!==i||e[14]!==g?(m=n.jsxs("span",{className:l,children:[i,g]}),e[12]=l,e[13]=i,e[14]=g,e[15]=m):m=e[15],m}const mn=_e({propertyId:de().min(1,"Selecione uma propriedade")});function fn(s){const e=M.c(68),{card:t,connectionId:o,companionClient:c,selfClient:a,org:u,onDone:d,onDisconnect:l,onIsPendingChange:p}=s;let i;e[0]!==o||e[1]!==u.id?(i=X.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 kt(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(mn),e[8]=y):y=e[8];const j=t.configurationState?.propertyId||"";let x;e[9]!==j?(x={resolver:y,defaultValues:{propertyId:j}},e[9]=j,e[10]=x):x=e[10];const b=Oe(x);let f;e[11]!==t||e[12]!==d||e[13]!==u||e[14]!==a?(f={card:t,selfClient:a,org:u,onDone:d},e[11]=t,e[12]=d,e[13]=u,e[14]=a,e[15]=f):f=e[15];const{save:S,isPending:h,error:L}=He(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]!==b||e[21]!==S){let k;e[23]!==S?(k=async N=>{S(N)},e[23]=S,e[24]=k):k=e[24],v=b.handleSubmit(k),e[20]=b,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(Ye,{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(gn).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]!==l?(N=l?n.jsx("button",{type:"button",onClick:l,className:"text-xs text-muted-foreground underline underline-offset-2 hover:text-destructive",children:"Desconectar conta"}):n.jsx("span",{}),e[30]=l,e[31]=N):N=e[31];let B;e[32]!==d?(B=n.jsx(Y,{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(We,{options:A.flatMap(pn),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]!==b.control||e[41]!==_?(O=n.jsx(ue,{control:b.control,name:"propertyId",render:_}),e[40]=b.control,e[41]=_,e[42]=O):O=e[42];let D;e[43]!==b||e[44]!==O?(D=n.jsx(Ie,{...b,children:O}),e[43]=b,e[44]=O,e[45]=D):D=e[45];let F;e[46]!==L?(F=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]=F):F=e[47];let $;e[48]!==h||e[49]!==l?($=l?n.jsx("button",{type:"button",onClick:l,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]=l,e[50]=$):$=e[50];let K;e[51]!==h||e[52]!==d?(K=n.jsx(Y,{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(Y,{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 P;e[60]!==$||e[61]!==G?(P=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]=P):P=e[62];let E;return e[63]!==w||e[64]!==D||e[65]!==F||e[66]!==P?(E=n.jsxs("form",{onSubmit:w,className:"space-y-4",children:[D,F,P]}),e[63]=w,e[64]=D,e[65]=F,e[66]=P,e[67]=E):E=e[67],E}function pn(s){return s.options}function gn(s){return s.options}const hn=_e({siteUrl:de().min(1,"Selecione um site")});function xn(s){const e=M.c(62),{card:t,connectionId:o,companionClient:c,selfClient:a,org:u,contextSiteUrl:d,onDone:l,onIsPendingChange:p}=s;let i;e[0]!==o||e[1]!==u.id?(i=X.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(hn),e[8]=y):y=e[8];const j=t.configurationState?.siteUrl||"";let x;e[9]!==j?(x={resolver:y,defaultValues:{siteUrl:j}},e[9]=j,e[10]=x):x=e[10];const b=Oe(x);let f;e[11]!==t||e[12]!==l||e[13]!==u||e[14]!==a?(f={card:t,selfClient:a,org:u,onDone:l},e[11]=t,e[12]=l,e[13]=u,e[14]=a,e[15]=f):f=e[15];const{save:S,isPending:h,error:L}=He(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]!==b||e[22]!==C||e[23]!==m.data||e[24]!==m.isSuccess?(I=()=>{if(!(T.current||!m.isSuccess)){if(T.current=!0,C){b.getValues("siteUrl")!==C&&b.setValue("siteUrl",C);return}if(!b.getValues("siteUrl")){const N=Rt(d,m.data??[]);N&&b.setValue("siteUrl",N)}}},A=[m.isSuccess,m.data,C,d,b],e[20]=d,e[21]=b,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 R;if(e[27]!==b||e[28]!==S){let N;e[30]!==S?(N=async B=>{S(B)},e[30]=S,e[31]=N):N=e[31],R=b.handleSubmit(N),e[27]=b,e[28]=S,e[29]=R}else R=e[29];const _=R;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(Ye,{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 D=O;if(D.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 F;e[37]!==h||e[38]!==D?(F=N=>{const{field:B}=N;return n.jsxs(me,{children:[n.jsx(fe,{children:n.jsx(We,{options:D.map(bn),value:B.value,onChange:B.onChange,disabled:h,ariaLabel:"Site verificado"})}),n.jsx(pe,{})]})},e[37]=h,e[38]=D,e[39]=F):F=e[39];let $;e[40]!==b.control||e[41]!==F?($=n.jsx(ue,{control:b.control,name:"siteUrl",render:F}),e[40]=b.control,e[41]=F,e[42]=$):$=e[42];let K;e[43]!==b||e[44]!==$?(K=n.jsx(Ie,{...b,children:$}),e[43]=b,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]!==l?(z=n.jsx(Y,{type:"button",variant:"outline",onClick:l,disabled:h,children:"Cancelar"}),e[48]=h,e[49]=l,e[50]=z):z=e[50];const G=h?"Salvando...":"Salvar";let P;e[51]!==h||e[52]!==G?(P=n.jsx(Y,{type:"submit",disabled:h,children:G}),e[51]=h,e[52]=G,e[53]=P):P=e[53];let E;e[54]!==z||e[55]!==P?(E=n.jsxs(Ce,{className:"pt-4",children:[z,P]}),e[54]=z,e[55]=P,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 bn(s){return{value:s.siteUrl,label:s.siteUrl}}function Cn(s){const[e,t]=s.split("/");return!e||!t?null:{owner:e,name:t}}function yn(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 vn(s){const{existingRepo:e,existingConnections:t,repoConnectionId:o}=s,c=e?.connectionId&&e.connectionId!==o?e.connectionId:void 0,a=[...t.filter(u=>u.connection_id!==o&&u.connection_id!==c),{connection_id:o,selected_tools:[]}];return{staleConnectionId:c,mergedConnections:a}}const jn=_e({githubRepo:de().min(1,"commerceOnboarding.githubConfigForm.selectRepository")}),Sn=15e3,_n=/^[\w.-]+\/[\w.-]+$/;async function Nn(s,e,t,o){const{installations:c}=await bt(s,t),a=o.trim(),u=await Promise.allSettled(c.map(async i=>{const r=i.type==="User"?"user":"org",g=a?`${r}:${i.login} ${a} in:name`:`${r}:${i.login}`,y=await e.callTool({name:"search_repositories",arguments:{query:g,page:1,perPage:50}},void 0,{signal:AbortSignal.timeout(Sn)}),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 l=0;for(const i of u){if(i.status==="rejected"){l+=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:l,total:c.length}}function On(s){const e=M.c(109),{connectionId:t,companionClient:o,selfClient:c,org:a,onDone:u,onIsPendingChange:d}=s,l=re(),p=Se();let i;e[0]!==a.id?(i=ct.COMMERCE_DISCOVERY(a.id),e[0]=a.id,e[1]=i):i=e[1];const r=i,[g,m]=V.useState(""),y=Vt(g,300),j=V.useRef(!1);let x;e[2]!==t||e[3]!==a.id?(x=X.commerceDiscoveryCompanionGithubSelected(a.id,t),e[2]=t,e[3]=a.id,e[4]=x):x=e[4];let b;e[5]!==r||e[6]!==c?(b=async()=>{const Z=await c.callTool({name:"COLLECTION_CONNECTIONS_GET",arguments:{id:r}}),se=ne(Z).item?.configuration_state??null;return typeof se?.github_repo=="string"?se.github_repo:""},e[5]=r,e[6]=c,e[7]=b):b=e[7];let f;e[8]!==x||e[9]!==b?(f={queryKey:x,queryFn:b},e[8]=x,e[9]=b,e[10]=f):f=e[10];const S=be(f);let h;e[11]!==t||e[12]!==y||e[13]!==a.id?(h=X.commerceDiscoveryCompanionGithubRepos(a.id,t,y.trim()),e[11]=t,e[12]=y,e[13]=a.id,e[14]=h):h=e[14];let L;e[15]!==o||e[16]!==t||e[17]!==y||e[18]!==c?(L=()=>Nn(Z=>c.callTool(Z),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(jn),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]!==a.id||e[28]!==a.slug||e[29]!==c||e[30]!==l?(I=async Z=>{const se=await c.callTool({name:"COLLECTION_CONNECTIONS_GET",arguments:{id:r}}),jt={...ne(se).item?.configuration_state??null??{},github_repo:Z};await c.callTool({name:"COLLECTION_CONNECTIONS_UPDATE",arguments:{id:r,data:{configuration_state:jt}}});const et=Cn(Z);if(!et)throw new Error(l("commerceOnboarding.githubConfigForm.invalidRepository",{repo:Z}));const{owner:ve,name:Pe}=et,tt=wt(a.id),nt=ne(await c.callTool({name:"COLLECTION_VIRTUAL_MCP_GET",arguments:{id:tt}})).item,ot=nt?.metadata?.githubRepo,St=nt?.connections??[],st=yn({existingRepo:ot,owner:ve,name:Pe});let we=st?.connectionId,De=st?.installationId,$e;if(!we){const{installations:qe}=await bt(je=>c.callTool(je),t),Ae=Qt(qe,ve);if(!Ae)throw new Error(l("commerceOnboarding.githubConfigForm.noGithubInstallation",{owner:ve}));De=Ae.installationId;const rt=ne(await c.callTool({name:"COLLECTION_CONNECTIONS_GET",arguments:{id:t}})).item;if(!rt)throw new Error(l("commerceOnboarding.githubConfigForm.githubConnectionNotFound"));const{childConnectionId:at}=await Ht({orgSlug:a.slug,sourceConnection:rt,installationId:De,owner:ve,repo:Pe,githubCallTool:je=>o.callTool(je),selfCallTool:je=>c.callTool(je)});we=at,$e=at}const{staleConnectionId:it,mergedConnections:_t}=vn({existingRepo:ot,existingConnections:St,repoConnectionId:we});try{await c.callTool({name:"COLLECTION_VIRTUAL_MCP_UPDATE",arguments:{id:tt,data:{connections:_t,metadata:{githubRepo:{owner:ve,name:Pe,url:`https://github.com/${Z}`,installationId:De,connectionId:we}}}}}),it&&await c.callTool({name:"COLLECTION_CONNECTIONS_DELETE",arguments:{id:it,force:!0}}).catch(Tn)}catch(qe){const Ae=qe;throw $e&&await c.callTool({name:"COLLECTION_CONNECTIONS_DELETE",arguments:{id:$e,force:!0}}).catch(En),Ae}},e[24]=r,e[25]=o,e[26]=t,e[27]=a.id,e[28]=a.slug,e[29]=c,e[30]=l,e[31]=I):I=e[31];let A;e[32]!==r||e[33]!==u||e[34]!==a.id||e[35]!==p?(A=async()=>{await p.invalidateQueries({queryKey:X.commerceDiscoveryConnection(a.id,r)}),await p.invalidateQueries({queryKey:X.commerceDiscoveryCompanionConnectionsPrefix(a.id)}),Ot(p,a.id),u()},e[32]=r,e[33]=u,e[34]=a.id,e[35]=p,e[36]=A):A=e[36];let R;e[37]!==A||e[38]!==I?(R={mutationFn:I,onSuccess:A},e[37]=A,e[38]=I,e[39]=R):R=e[39];const _=Fe(R),O=_.isPending;let D,F;e[40]!==O||e[41]!==d?(D=()=>{d?.(O)},F=[O,d],e[40]=O,e[41]=d,e[42]=D,e[43]=F):(D=e[42],F=e[43]),V.useEffect(D,F);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 Z;e[52]!==_?(Z=async se=>{_.mutate(se.githubRepo)},e[52]=_,e[53]=Z):Z=e[53],z=w.handleSubmit(Z),e[49]=w,e[50]=_,e[51]=z}else z=e[51];const G=z;let P,E,k;if(e[54]!==y||e[55]!==C.data?.failed||e[56]!==C.data?.repos||e[57]!==C.data?.total||e[58]!==$){const Z=C.data?.repos??[];P=C.data?.failed??0,k=C.data?.total??0;const se=y.trim();E=[...Z],se&&_n.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]=P,e[60]=E,e[61]=k}else P=e[59],E=e[60],k=e[61];const N=k>0&&P===k;let B;e[62]!==N||e[63]!==P||e[64]!==C.isError||e[65]!==l?(B=C.isError||N?l("commerceOnboarding.githubConfigForm.searchFailedTotal"):P>0?l("commerceOnboarding.githubConfigForm.searchFailedPartial"):null,e[62]=N,e[63]=P,e[64]=C.isError,e[65]=l,e[66]=B):B=e[66];const Q=B;let te;e[67]===Symbol.for("react.memo_cache_sentinel")?(te=n.jsx(gt,{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=Z=>m(Z.target.value),e[68]=oe):oe=e[68];let J;e[69]!==l?(J=l("commerceOnboarding.githubConfigForm.searchRepositoryPlaceholder"),e[69]=l,e[70]=J):J=e[70];let q;e[71]!==l?(q=l("commerceOnboarding.githubConfigForm.searchRepositoryLabel"),e[71]=l,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]!==l?(ee=C.isLoading?n.jsx("div",{className:"flex min-h-[160px] items-center justify-center",children:n.jsx(Ye,{label:l("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:l("commerceOnboarding.githubConfigForm.noRepositoriesFound")}):n.jsx(Ie,{...w,children:n.jsx(ue,{control:w.control,name:"githubRepo",render:Z=>{const{field:se}=Z;return n.jsxs(me,{children:[n.jsx(fe,{children:n.jsx(We,{options:E.map(In),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]=l,e[84]=ee):ee=e[84];let ae;e[85]!==_.error||e[86]!==l?(ae=_.error&&n.jsx("p",{role:"alert",className:"text-sm text-destructive",children:_.error instanceof Error?_.error.message:l("commerceOnboarding.githubConfigForm.failedToSave")}),e[85]=_.error,e[86]=l,e[87]=ae):ae=e[87];let W;e[88]!==l?(W=l("commerceOnboarding.githubConfigForm.cancel"),e[88]=l,e[89]=W):W=e[89];let ie;e[90]!==O||e[91]!==u||e[92]!==W?(ie=n.jsx(Y,{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]!==l?(ge=l(O?"commerceOnboarding.githubConfigForm.saving":"commerceOnboarding.githubConfigForm.save"),e[94]=O,e[95]=l,e[96]=ge):ge=e[96];let he;e[97]!==O||e[98]!==ge?(he=n.jsx(Y,{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 In(s){return{value:s,label:s}}function En(){}function Tn(){}const wn={vtex:dn,"google-analytics":fn,"google-search-console":xn,github:On},ye="deco-reader@decocms.iam.gserviceaccount.com",yt={"google-analytics":"ga4","google-search-console":"gsc"},vt={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 An(s,e){const t=vt[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 Ln(s){const e=M.c(95),{provider:t,siteUrl:o,selfClient:c,org:a,initialResourceId:u,onDone:d,onIsPendingChange:l,onOAuthInstead:p}=s,i=re(),r=vt[t],g=Se(),[m,y]=V.useState(null);let j,x;if(e[0]!==r.resourceLabel||e[1]!==i){const W=_e({resourceId:de().trim().min(1,i("commerceOnboarding.saBindingForm.resourceIdRequired",{resourceLabel:r.resourceLabel.toLowerCase()}))});x=Oe,j=Ne(W),e[0]=r.resourceLabel,e[1]=i,e[2]=j,e[3]=x}else j=e[2],x=e[3];const b=u??"";let f;e[4]!==b?(f={resourceId:b},e[4]=b,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=x(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]!==l?(T=()=>l?.(!0),C=()=>l?.(!1),e[14]=l,e[15]=T,e[16]=C):(T=e[15],C=e[16]);let v;e[17]!==r.label||e[18]!==d||e[19]!==a||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:X.commerceDiscoveryConnectionStatus(a.id,o)}),d();return}y({...An(t,W.reason??"unknown"),detail:W.detail})},e[17]=r.label,e[18]=d,e[19]=a,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=Fe(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 R=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 D=O;let F;e[37]!==r.connectSteps?(F=r.connectSteps.map(Rn),e[37]=r.connectSteps,e[38]=F):F=e[38];let $;e[39]!==F?($=n.jsx("ol",{className:"space-y-2 text-sm text-muted-foreground",children:F}),e[39]=F,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(xt,{size:16}),e[44]=z):z=e[44];let G;e[45]!==D||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(Y,{type:"button",variant:"ghost",size:"icon-sm",onClick:D,"aria-label":U,children:z})]}),e[45]=D,e[46]=U,e[47]=G):G=e[47];let P;e[48]!==r.resourceHint||e[49]!==r.resourceLabel||e[50]!==r.resourcePlaceholder||e[51]!==_?(P=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(zt,{children:r.resourceHint}),n.jsx(pe,{})]})},e[48]=r.resourceHint,e[49]=r.resourceLabel,e[50]=r.resourcePlaceholder,e[51]=_,e[52]=P):P=e[52];let E;e[53]!==h.control||e[54]!==P?(E=n.jsx(ue,{control:h.control,name:"resourceId",render:P}),e[53]=h.control,e[54]=P,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(kn)})]}),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(Y,{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(Y,{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]!==R||e[88]!==$||e[89]!==G||e[90]!==k||e[91]!==N||e[92]!==B||e[93]!==ee?(ae=n.jsxs("form",{onSubmit:R,className:"space-y-4",children:[$,G,k,N,B,ee]}),e[87]=R,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 kn(s){return n.jsxs("li",{className:"flex gap-2",children:[n.jsx("span",{"aria-hidden":!0,children:"•"}),n.jsx("span",{children:s})]},s)}function Rn(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 Fn(){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 Pn(s){const e=M.c(17),{title:t,disconnecting:o,disabled:c,onDisconnect:a}=s,u=re(),d=c||o;let l;e[0]!==u||e[1]!==t?(l=u("commerceOnboarding.companionCard.disconnectAriaLabel",{title:t}),e[0]=u,e[1]=t,e[2]=l):l=e[2];let p;e[3]!==o?(p=o?n.jsx(Ue,{size:16,className:"animate-spin"}):n.jsx(Lt,{size:16}),e[3]=o,e[4]=p):p=e[4];let i;e[5]!==a||e[6]!==d||e[7]!==l||e[8]!==p?(i=n.jsx(Me,{asChild:!0,children:n.jsx(Y,{type:"button",variant:"ghost",size:"icon-sm",className:"shrink-0 text-muted-foreground hover:text-destructive",disabled:d,onClick:a,"aria-label":l,children:p})}),e[5]=a,e[6]=d,e[7]=l,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 Dn(s){const e=M.c(23),{card:t,connecting:o,disconnecting:c,disabled:a,onConnect:u,onDisconnect:d,org:l,selfClient:p,siteUrl:i,autoOpenConfigFieldKey:r,onAutoOpenConfigHandled:g}=s,m=t.linkedConnectionId,y=yt[t.bindingType],j=!!y&&t.boundVia!=="oauth",x=t.satisfied&&!t.configured;let b;e[0]!==r||e[1]!==t||e[2]!==o||e[3]!==a||e[4]!==c||e[5]!==m||e[6]!==x||e[7]!==g||e[8]!==u||e[9]!==d||e[10]!==l||e[11]!==y||e[12]!==p||e[13]!==i||e[14]!==j?(b=j&&y?n.jsx($n,{card:t,provider:y,org:l,selfClient:p,siteUrl:i,onOAuthInstead:u,disabled:a,connecting:o,primary:t.required}):t.satisfied&&m?n.jsxs("div",{className:"flex items-center justify-end gap-1 sm:justify-start",children:[n.jsx(V.Suspense,{fallback:n.jsx(qn,{}),children:n.jsx(Kn,{card:t,org:l,selfClient:p,connectionId:m,contextSiteUrl:i,variant:x?"configure":"gear",disabled:a,autoOpen:x||Ft({autoOpenFieldKey:r,card:t}),onAutoOpenHandled:g})}),n.jsx(Pn,{title:t.title,disconnecting:c,disabled:a,onDisconnect:d})]}):n.jsx(Ct,{connecting:o,disabled:a,title:t.title,primary:t.required,onConnect:u}),e[0]=r,e[1]=t,e[2]=o,e[3]=a,e[4]=c,e[5]=m,e[6]=x,e[7]=g,e[8]=u,e[9]=d,e[10]=l,e[11]=y,e[12]=p,e[13]=i,e[14]=j,e[15]=b):b=e[15];const f=b,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]!==x||e[21]!==S?(h=n.jsx(rn,{icon:t.icon,title:t.title,headline:t.headline,required:S,attention:x,action:f}),e[16]=f,e[17]=t.headline,e[18]=t.icon,e[19]=t.title,e[20]=x,e[21]=S,e[22]=h):h=e[22],h}function $n(s){const e=M.c(45),{card:t,provider:o,org:c,selfClient:a,siteUrl:u,onOAuthInstead:d,disabled:l,connecting:p,primary:i}=s,r=re(),[g,m]=V.useState(!1),[y,j]=V.useState(!1);let x;e[0]!==y?(x=F=>{!F&&y||m(F)},e[0]=y,e[1]=x):x=e[1];const b=x;let f;e[2]!==t.satisfied||e[3]!==t.title||e[4]!==p||e[5]!==l||e[6]!==i||e[7]!==r?(f=t.satisfied?n.jsx(ln,{controls:n.jsxs(Be,{children:[n.jsx(Me,{asChild:!0,children:n.jsx(Y,{type:"button",variant:"ghost",size:"icon-sm",className:"shrink-0",onClick:()=>m(!0),"aria-label":r("commerceOnboarding.companionCard.configureAriaLabel",{title:t.title}),children:n.jsx(Qe,{size:16})})}),n.jsx(Ve,{children:r("commerceOnboarding.companionCard.editConfiguration")})]})}):n.jsx(Ct,{connecting:p,disabled:l,title:t.title,primary:i,onConnect:()=>m(!0)}),e[2]=t.satisfied,e[3]=t.title,e[4]=p,e[5]=l,e[6]=i,e[7]=r,e[8]=f):f=e[8];let S;e[9]!==t.icon||e[10]!==t.title?(S=n.jsx(Ge,{icon:t.icon,name:t.title,size:"md",fit:"contain",className:"p-1.5"}),e[9]=t.icon,e[10]=t.title,e[11]=S):S=e[11];let h;e[12]!==t.title?(h=n.jsx(dt,{children:t.title}),e[12]=t.title,e[13]=h):h=e[13];let L;e[14]!==r?(L=r("commerceOnboarding.companionCard.grantAccessDescription"),e[14]=r,e[15]=L):L=e[15];let T;e[16]!==L?(T=n.jsx(ut,{children:L}),e[16]=L,e[17]=T):T=e[17];let C;e[18]!==h||e[19]!==T?(C=n.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:[h,T]}),e[18]=h,e[19]=T,e[20]=C):C=e[20];let v;e[21]!==S||e[22]!==C?(v=n.jsxs(mt,{className:"flex-row items-center gap-3 space-y-0 text-left",children:[S,C]}),e[21]=S,e[22]=C,e[23]=v):v=e[23];const w=t.boundResource??void 0;let I;e[24]===Symbol.for("react.memo_cache_sentinel")?(I=()=>m(!1),e[24]=I):I=e[24];let A;e[25]!==t.satisfied||e[26]!==d?(A=t.satisfied?void 0:()=>{m(!1),d()},e[25]=t.satisfied,e[26]=d,e[27]=A):A=e[27];let R;e[28]!==c||e[29]!==o||e[30]!==a||e[31]!==u||e[32]!==A||e[33]!==w?(R=n.jsx(Ln,{provider:o,siteUrl:u,selfClient:a,org:c,initialResourceId:w,onDone:I,onIsPendingChange:j,onOAuthInstead:A}),e[28]=c,e[29]=o,e[30]=a,e[31]=u,e[32]=A,e[33]=w,e[34]=R):R=e[34];let _;e[35]!==R||e[36]!==v?(_=n.jsxs(ft,{className:"sm:max-w-lg",children:[v,R]}),e[35]=R,e[36]=v,e[37]=_):_=e[37];let O;e[38]!==b||e[39]!==g||e[40]!==_?(O=n.jsx(pt,{open:g,onOpenChange:b,children:_}),e[38]=b,e[39]=g,e[40]=_,e[41]=O):O=e[41];let D;return e[42]!==O||e[43]!==f?(D=n.jsxs(n.Fragment,{children:[f,O]}),e[42]=O,e[43]=f,e[44]=D):D=e[44],D}function qn(){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 Kn(s){const e=M.c(71),{card:t,org:o,selfClient:c,connectionId:a,contextSiteUrl:u,variant:d,disabled:l,autoOpen:p,onAutoOpenHandled:i}=s,r=re();let g;e[0]!==a||e[1]!==o.id||e[2]!==o.slug?(g={connectionId:a,orgId:o.id,orgSlug:o.slug},e[0]=a,e[1]=o.id,e[2]=o.slug,e[3]=g):g=e[3];const m=ze(g),[y,j]=V.useState(p),[x,b]=V.useState(!1),f=Se(),S=wn[t.bindingType];let h;e[4]!==t.configurationState?(h=Pt(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]!==x?(v=te=>{if(!(!te&&x)){if(!te){C();return}j(!0)}},e[9]=C,e[10]=x,e[11]=v):v=e[11];const w=v;let I;e[12]!==a||e[13]!==c?(I=async()=>{await c.callTool({name:"COLLECTION_CONNECTIONS_DELETE",arguments:{id:a,force:!0}})},e[12]=a,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:X.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 R;e[21]!==r?(R=()=>{ke.error(r("commerceOnboarding.companionCard.disconnectError"))},e[21]=r,e[22]=R):R=e[22];let _;e[23]!==I||e[24]!==A||e[25]!==R?(_={mutationFn:I,onSuccess:A,onError:R},e[23]=I,e[24]=A,e[25]=R,e[26]=_):_=e[26];const O=Fe(_);if(!S)return null;let D;e[27]!==t.title||e[28]!==l||e[29]!==L||e[30]!==r||e[31]!==d?(D=d==="configure"?n.jsx(an,{disabled:l,title:t.title,onConfigure:()=>j(!0)}):n.jsxs(Be,{children:[n.jsx(Me,{asChild:!0,children:n.jsx(Y,{type:"button",variant:"ghost",size:"icon-sm",className:"shrink-0",onClick:()=>j(!0),"aria-label":r("commerceOnboarding.companionCard.configureAriaLabel",{title:t.title}),children:n.jsx(Qe,{size:16})})}),n.jsx(Ve,{children:L.length>0?r("commerceOnboarding.companionCard.editConfiguration"):r("commerceOnboarding.companionCard.configure")})]}),e[27]=t.title,e[28]=l,e[29]=L,e[30]=r,e[31]=d,e[32]=D):D=e[32];const F=D;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(dt,{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(ut,{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 P;e[46]!==$||e[47]!==G?(P=n.jsxs(mt,{className:"flex-row items-center gap-3 space-y-0 text-left",children:[$,G]}),e[46]=$,e[47]=G,e[48]=P):P=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]!==a||e[56]!==u||e[57]!==o||e[58]!==c||e[59]!==E?(k=n.jsx(S,{card:t,connectionId:a,companionClient:m,selfClient:c,org:o,contextSiteUrl:u,onDone:C,onDisconnect:E,onIsPendingChange:b}),e[51]=S,e[52]=t,e[53]=C,e[54]=m,e[55]=a,e[56]=u,e[57]=o,e[58]=c,e[59]=E,e[60]=k):k=e[60];let N;e[61]!==P||e[62]!==k?(N=n.jsxs(ft,{className:"sm:max-w-lg",children:[P,k]}),e[61]=P,e[62]=k,e[63]=N):N=e[63];let B;e[64]!==y||e[65]!==w||e[66]!==N?(B=n.jsx(pt,{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]!==F?(Q=n.jsxs(n.Fragment,{children:[F,B]}),e[68]=B,e[69]=F,e[70]=Q):Q=e[70],Q}const Ze={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 Un(s){const e=M.c(40),{selfClient:t,org:o,cdConnectionId:c,siteUrl:a}=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 l;e[4]!==c||e[5]!==o.id?(l=X.commerceDiscoveryCompanionSchema(o.id,c),e[4]=c,e[5]=o.id,e[6]=l):l=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]!==l||e[10]!==p?(i={queryKey:l,queryFn:p,retry:!1},e[9]=l,e[10]=p,e[11]=i):i=e[11];const r=be(i),g=r.data?.stateSchema?Dt(r.data.stateSchema):null,m=g&&g.length>0?g:$t,y=m.map(Zn),j=m.map(Yn).filter(Wn),x=m.filter(Hn).map(Qn),b=[...j,...x].sort().join(",");let f;e[12]!==c||e[13]!==o.id?(f=X.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(Vn),w=[...y.map(Mn),...j.map(Bn),...v.map(Gn)].sort().join(","),A=Ke({queryKey:X.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??[],R=new Set(v),_=A.filter(q=>R.has(q.id)),O=_.filter(zn);let D;e[23]!==o.id||e[24]!==o.slug?(D=q=>({queryKey:X.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]=D):D=e[25];const F=Jt({queries:O.map(D)});let $;e[26]!==F?($=(q,H)=>[q.id,F[H]?.data?.hasToken===!0],e[26]=F,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:X.commerceDiscoveryCompanionRegistry(o.id,b),queryFn:async()=>{if(m.length===0)return{items:[]};const q=qt(j,x),H=await Wt(ct.REGISTRY(o.id),o.id,o.slug,"COLLECTION_REGISTRY_APP_LIST",{...q?{where:q}:{},limit:1e3});return ne(H)}}),G={},P={};for(const q of z.data?.items??[])G[q.id]=q,q.server?.name&&(P[q.server.name]=q);let E;e[28]!==o.id||e[29]!==a?(E=X.commerceDiscoveryConnectionStatus(o.id,a??""),e[28]=o.id,e[29]=a,e[30]=E):E=e[30];const k=!!a;let N;e[31]!==t||e[32]!==a?(N=async()=>{const q=await t.callTool({name:"COMMERCE_DISCOVERY_CONNECTION_STATUS",arguments:{siteUrl:a}});return ne(q)},e[31]=t,e[32]=a,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(yt)){const ee=Q.data?.providers?.[H];ee?.connected&&ee.via==="sa"&&(te[q]={resource:ee.resource??null})}const oe=Kt({requirements:m,itemsById:G,itemsByName:P,connections:A,connectionReadiness:U,configurationState:T,curated:Ze,saBindings:te});let J;return e[38]!==oe?(J={cards:oe},e[38]=oe,e[39]=J):J=e[39],J}function zn(s){return s.oauth_config&&!s.connection_token}function Gn(s){return`linked:${s}`}function Bn(s){return`app:${s}`}function Mn(s){return`binding:${s}`}function Vn(s){return typeof s=="string"&&s.length>0}function Qn(s){return s.bindingType}function Hn(s){return!Ze[s.bindingType]}function Wn(s){return!!s}function Yn(s){return Ze[s.bindingType]?.registryAppId}function Zn(s){return s.bindingType}function Xn({selfClient:s,org:e,userId:t,cdConnectionId:o,domain:c,siteUrl:a}){const u=Se(),[d,l]=V.useState(null),[p,i]=V.useState(null),[r,g]=V.useState(null),m=async(x,b)=>{const f=await s.callTool({name:"COLLECTION_CONNECTIONS_UPDATE",arguments:{id:x,data:b}});return ne(f)};async function y(x){l(x.fieldKey),g(null);const b={app_name:x.title,field_key:x.fieldKey,organization_id:e.id,domain:c,site_url:a};le("commerce_onboarding_companion_connect_clicked",b);try{let f=x.candidateConnectionId;if(!f){const v=Yt(x.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",{...b,error:"no_connection_method"}),g(`${x.title} cannot be connected: no connection method available`),!1;const R=await s.callTool({name:"COLLECTION_CONNECTIONS_CREATE",arguments:{data:v}});f=ne(R).item.id}const S=f,h=await Xt({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",{...b,error:h.error}),g(`Couldn't sign in to ${x.title}: ${h.error}`),!1;const L=await s.callTool({name:"COLLECTION_CONNECTIONS_GET",arguments:{id:o}}),T=ne(L).item?.configuration_state??null,C=Ut(T,x.fieldKey,x.bindingType,S);return x.bindingType==="github"&&delete C.github_repo,await m(o,{configuration_state:C}),await u.invalidateQueries({queryKey:X.commerceDiscoveryConnection(e.id,o)}),await u.invalidateQueries({queryKey:X.commerceDiscoveryCompanionConnectionsPrefix(e.id)}),le("commerce_onboarding_companion_connected",b),!0}catch(f){return le("commerce_onboarding_companion_connect_failed",{...b,error:f instanceof Error?f.message:String(f)}),g(f instanceof Error?f.message:String(f)),!1}finally{l(null)}}async function j(x){i(x.fieldKey),g(null);const b={app_name:x.title,field_key:x.fieldKey,organization_id:e.id,domain:c,site_url:a};le("commerce_onboarding_companion_disconnect_clicked",b);try{const f=await s.callTool({name:"COLLECTION_CONNECTIONS_GET",arguments:{id:o}}),h={...ne(f).item?.configuration_state??null??{}};return delete h[x.fieldKey],x.bindingType==="github"&&delete h.github_repo,await m(o,{configuration_state:h}),await u.invalidateQueries({queryKey:X.commerceDiscoveryConnection(e.id,o)}),await u.invalidateQueries({queryKey:X.commerceDiscoveryCompanionConnectionsPrefix(e.id)}),le("commerce_onboarding_companion_disconnected",b),!0}catch(f){return le("commerce_onboarding_companion_disconnect_failed",{...b,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 Xe="flex min-h-0 flex-1 flex-col gap-6 md:grid md:flex-none md:gap-6";function Je(){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 Jn(){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(eo)}),s[0]=e):e=s[0],e}function eo(s){return n.jsx(Fn,{},s)}function to(){const s=M.c(1);let e;return s[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsxs("div",{className:Xe,children:[n.jsx(Je,{}),n.jsx(Jn,{})]}),s[0]=e):e=s[0],e}function no(s){const e=M.c(18),{onRetry:t}=s,o=re();let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx(Je,{}),e[0]=c):c=e[0];let a;e[1]!==o?(a=o("routes.commerceOnboarding.companionSection.loadError"),e[1]=o,e[2]=a):a=e[2];let u;e[3]!==a?(u=n.jsx("p",{className:"text-sm text-foreground",children:a}),e[3]=a,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 l;e[7]!==d?(l=n.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:d}),e[7]=d,e[8]=l):l=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(Y,{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]!==l||e[16]!==i?(r=n.jsxs("div",{className:Xe,children:[c,n.jsxs("div",{role:"alert",className:"rounded-2xl border border-border bg-card p-4",children:[u,l,i]})]}),e[14]=u,e[15]=l,e[16]=i,e[17]=r):r=e[17],r}function Ao(s){const e=M.c(2);let t;return e[0]!==s?(t=n.jsx(It,{children:o=>{const{reset:c}=o;return n.jsx(Et,{fallback:a=>{const{resetError:u}=a;return n.jsx(no,{onRetry:()=>{c(),u()}})},children:n.jsx(V.Suspense,{fallback:n.jsx(to,{}),children:n.jsx(oo,{...s})})})}}),e[0]=s,e[1]=t):t=e[1],t}function oo(s){const e=M.c(53),{org:t,cdConnectionId:o,siteUrl:c,onReadinessChange:a}=s,{data:u}=Tt.useSession(),d=u?.user?.id??"";let l;if(e[0]!==c){const K=c?Re(c):null;if(K?.ok)try{l=new URL(K.value).hostname}catch{l=void 0}e[0]=c,e[1]=l}else l=e[1];let p;e[2]!==t.id||e[3]!==t.slug?(p={connectionId:At,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}=Un(r);let m;e[10]!==o||e[11]!==t||e[12]!==i||e[13]!==l||e[14]!==c||e[15]!==d?(m={selfClient:i,org:t,userId:d,cdConnectionId:o,domain:l,siteUrl:c},e[10]=o,e[11]=t,e[12]=i,e[13]=l,e[14]=c,e[15]=d,e[16]=m):m=e[16];const{connect:y,connectingFieldKey:j,disconnect:x,disconnectingFieldKey:b,error:f}=Xn(m),[S,h]=V.useState(null),L=ro;let T,C,v,w,I,A,R,_,O;if(e[17]!==S||e[18]!==g||e[19]!==y||e[20]!==f||e[21]!==j||e[22]!==x||e[23]!==b||e[24]!==a||e[25]!==t||e[26]!==i||e[27]!==c){v=Symbol.for("react.early_return_sentinel");e:{const K=g.filter(io),U=g.filter(so),z=K.length>0?K.every(L):g.length===0||g.some(L);if(a?.(z),g.length===0){v=null;break e}const G=j!==null||b!==null,P=E=>{const k=async()=>{await y(E)&&h(E.fieldKey)};return n.jsx(Dn,{card:E,connecting:j===E.fieldKey,disconnecting:b===E.fieldKey,disabled:G&&j!==E.fieldKey&&b!==E.fieldKey,org:t,selfClient:i,siteUrl:c,autoOpenConfigFieldKey:S,onAutoOpenConfigHandled:()=>h(N=>N===E.fieldKey?null:N),onConnect:()=>{k()},onDisconnect:()=>{x(E)}},E.fieldKey)};O=Xe,e[37]===Symbol.for("react.memo_cache_sentinel")?(C=n.jsx(Je,{}),e[37]=C):C=e[37],T=sn,A="flex min-h-0 flex-1 flex-col md:block",R="-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(P)}e[17]=S,e[18]=g,e[19]=y,e[20]=f,e[21]=j,e[22]=x,e[23]=b,e[24]=a,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]=R,e[35]=_,e[36]=O}else T=e[28],C=e[29],v=e[30],w=e[31],I=e[32],A=e[33],R=e[34],_=e[35],O=e[36];if(v!==Symbol.for("react.early_return_sentinel"))return v;let D;e[40]!==w||e[41]!==I?(D=n.jsx("div",{className:w,children:I}),e[40]=w,e[41]=I,e[42]=D):D=e[42];let F;e[43]!==T||e[44]!==D||e[45]!==A||e[46]!==R||e[47]!==_?(F=n.jsxs(T,{wrapperClassName:A,className:R,children:[_,D]}),e[43]=T,e[44]=D,e[45]=A,e[46]=R,e[47]=_,e[48]=F):F=e[48];let $;return e[49]!==C||e[50]!==F||e[51]!==O?($=n.jsxs("div",{className:O,children:[C,F]}),e[49]=C,e[50]=F,e[51]=O,e[52]=$):$=e[52],$}function so(s){return!s.required}function io(s){return s.required}function ro(s){return s.satisfied&&s.configured}function ao(s){return s.content?.find(e=>e.text)?.text??"A configuração do Commerce Discovery falhou."}function Lo(s){const e=s;if(e.isError)throw new Error(ao(e));return e.structuredContent??s}export{to as C,Ye as L,sn as S,Ao as a,To as i,Re as n,Lo as p,wo as s};
|
|
1
|
+
import{V as Nt,c as M,r as V,m as ce,j as n,b as re,k as Ue,B as Y,o as Se,e as Fe,K as X,W as _e,X as de,Y as Ne,Z as Oe,n as be,_ as Ot,t as ke,x as Ke,p as le,Q as It,E as Et,a as Tt}from"./index-C7paW5qO.js";import{W as ct,g as wt,u as ze,S as At}from"./use-mcp-client-D_VzqTLh.js";import{I as Ge}from"./integration-icon-DEmdrigW.js";import{c as Ce,b as dt,h as ut,a as mt,d as ft,e as pt}from"./dialog-CKP-t2d8.js";import{c as Be,T as Me,a as Ve}from"./tooltip-Du-iZy7N.js";import{j as Qe,g as gt,k as Lt}from"./agent-icon-ibE4Mzzu.js";import{u as ne,t as kt,m as Rt,s as Ft,g as Pt,p as Dt,F as $t,b as qt,a as Kt,c as Ut}from"./companions-core-DlPclFME.js";import{i as ht}from"./CheckCircle-CCKZTxeZ.js";import{F as ue,a as Ie,b as me,c as Le,d as fe,e as pe,f as zt}from"./form-BOHVNPhz.js";import{I as Ee}from"./input-B7NjdaWP.js";import{i as Gt}from"./Check-BdLBTBRG.js";import{a as xt}from"./Copy01-XmlYTCnq.js";import{i as Bt}from"./Settings02-BrdhYfJi.js";import{s as Mt}from"./Eye-BBuEG2Wd.js";import{u as Vt}from"./use-debounced-value-DbPd-3pt.js";import{f as bt,a as Qt,p as Ht}from"./provision-repo-scoped-github-connection-2iDn-wQ1.js";import{c as Wt,e as Yt}from"./extract-connection-data-C_r5IGMb.js";import{u as Zt}from"./useQueries-CJGiUc5a.js";import{a as Xt}from"./authenticate-and-persist-oauth-D2zBt4t0.js";function Jt(s,e){return Zt({...s,queries:s.queries.map(t=>({...t,suspense:!0,throwOnError:Nt,enabled:!0,placeholderData:void 0}))},e)}const en=/^[a-zA-Z][a-zA-Z\d+.-]*:/,tn=/^[a-zA-Z][a-zA-Z\d+.-]*:\/\//,nn=/^[^\s/:?#]+\.[^\s/:?#]+:\d+(?:[/?#]|$)/,on=/^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/i;function Re(s){const e=s.trim();if(!e)return{ok:!1,error:"Enter a website URL."};const t=en.test(e),o=tn.test(e),c=nn.test(e);if(t&&!o&&!c)return{ok:!1,error:"Use an HTTP or HTTPS website URL."};const a=o?e:`https://${e}`;let u;try{u=new URL(a)}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(l=>!l||!on.test(l))?{ok:!1,error:"Enter a valid website URL."}:(u.protocol="https:",{ok:!0,value:u.origin})}function To(s,e){if(!s.trim())return!0;const t=Re(s);if(!t.ok||!e)return!1;const o=Re(e);return o.ok&&o.value===t.value}function wo(s){if(!s)return null;const e=Re(s);return e.ok?new URL(e.value).hostname:null}function sn(s){const e=M.c(14),{children:t,className:o,wrapperClassName:c}=s,[a,u]=V.useState(!0);let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=j=>{if(!j)return;const x=()=>{const f=j.scrollHeight-j.scrollTop-j.clientHeight<8;u(f)};x(),j.addEventListener("scroll",x,{passive:!0});const b=new ResizeObserver(x);b.observe(j);for(const f of Array.from(j.children))b.observe(f);return()=>{j.removeEventListener("scroll",x),b.disconnect()}},e[0]=d):d=e[0];const l=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:l,className:o,children:t}),e[3]=t,e[4]=o,e[5]=i):i=e[5];const r=a?"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 rn(s){const e=M.c(25),{icon:t,title:o,headline:c,required:a,attention:u,action:d}=s,l=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]!==a||e[3]!==l?(r=a&&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:l("commerceOnboarding.companionCard.required")}),e[2]=a,e[3]=l,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 x;e[15]!==g||e[16]!==j?(x=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]=x):x=e[17];let b;e[18]!==d?(b=n.jsx("div",{className:"shrink-0",children:d}),e[18]=d,e[19]=b):b=e[19];let f;return e[20]!==i||e[21]!==r||e[22]!==x||e[23]!==b?(f=n.jsxs("div",{className:i,children:[r,x,b]}),e[20]=i,e[21]=r,e[22]=x,e[23]=b,e[24]=f):f=e[24],f}function Ct(s){const e=M.c(12),{connecting:t,disabled:o,title:c,primary:a,onConnect:u}=s,d=re(),l=a?"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]!==l||e[8]!==p||e[9]!==i||e[10]!==r?(g=n.jsx(Y,{type:"button",variant:l,size:"sm",disabled:p,onClick:u,"aria-label":i,children:r}),e[6]=u,e[7]=l,e[8]=p,e[9]=i,e[10]=r,e[11]=g):g=e[11],g}function an(s){const e=M.c(11),{disabled:t,title:o,onConfigure:c}=s,a=re();let u;e[0]!==a||e[1]!==o?(u=a("commerceOnboarding.companionCard.configureAriaLabel",{title:o}),e[0]=a,e[1]=o,e[2]=u):u=e[2];let d;e[3]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx(Qe,{size:16}),e[3]=d):d=e[3];let l;e[4]!==a?(l=a("commerceOnboarding.companionCard.finishSetup"),e[4]=a,e[5]=l):l=e[5];let p;return e[6]!==t||e[7]!==c||e[8]!==u||e[9]!==l?(p=n.jsxs(Y,{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,l]}),e[6]=t,e[7]=c,e[8]=u,e[9]=l,e[10]=p):p=e[10],p}function ln(s){const e=M.c(8),{controls:t}=s,o=re();let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx(ht,{size:16,className:"text-success"}),e[0]=c):c=e[0];let a;e[1]!==o?(a=o("commerceOnboarding.companionCard.connected"),e[1]=o,e[2]=a):a=e[2];let u;e[3]!==a?(u=n.jsxs("span",{className:"flex items-center gap-1.5 text-sm text-muted-foreground",children:[c," ",a]}),e[3]=a,e[4]=u):u=e[4];let d;return e[5]!==t||e[6]!==u?(d=n.jsxs("div",{className:"flex items-center gap-1",children:[u,t]}),e[5]=t,e[6]=u,e[7]=d):d=e[7],d}function lt(s){const e=M.c(38);let t,o,c,a,u;e[0]!==s?({value:u,onChange:o,placeholder:c,className:t,...a}=s,e[0]=s,e[1]=t,e[2]=o,e[3]=c,e[4]=a,e[5]=u):(t=e[1],o=e[2],c=e[3],a=e[4],u=e[5]);const[d,l]=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=()=>{l(!d)},e[8]=d,e[9]=m):m=e[9];const y=m,j=d?"text":"password";let x;e[10]!==t?(x=ce("pr-20",t),e[10]=t,e[11]=x):x=e[11];let b;e[12]!==o||e[13]!==c||e[14]!==a||e[15]!==j||e[16]!==x||e[17]!==u?(b=n.jsx(Ee,{type:j,value:u,onChange:o,placeholder:c,className:x,...a}),e[12]=o,e[13]=c,e[14]=a,e[15]=j,e[16]=x,e[17]=u,e[18]=b):b=e[18];const f=d?"Hide password":"Show password";let S;e[19]!==d?(S=d?n.jsx(Bt,{size:16}):n.jsx(Mt,{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(Y,{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(Gt,{size:16}):n.jsx(xt,{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(Y,{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]!==b?(I=n.jsxs("div",{className:"relative",children:[b,w]}),e[35]=w,e[36]=b,e[37]=I):I=e[37],I}function He(s){const e=M.c(19),{card:t,selfClient:o,org:c,onDone:a,onError:u}=s,d=Se();let l;e[0]!==t||e[1]!==o?(l=async x=>{const b={...t.configurationState??{},...x};await o.callTool({name:"COLLECTION_CONNECTIONS_UPDATE",arguments:{id:t.linkedConnectionId||t.candidateConnectionId,data:{configuration_state:b}}})},e[0]=t,e[1]=o,e[2]=l):l=e[2];let p;e[3]!==a||e[4]!==c||e[5]!==d?(p=async()=>{await d.invalidateQueries({queryKey:X.commerceDiscoveryCompanionConnectionsPrefix(c.id)}),a()},e[3]=a,e[4]=c,e[5]=d,e[6]=p):p=e[6];let i;e[7]!==u?(i=x=>{u?.(x)},e[7]=u,e[8]=i):i=e[8];let r;e[9]!==l||e[10]!==p||e[11]!==i?(r={mutationFn:l,onSuccess:p,onError:i},e[9]=l,e[10]=p,e[11]=i,e[12]=r):r=e[12];const g=Fe(r);let m;e[13]!==g?(m=x=>g.mutate(x),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 cn=_e({accountName:de().min(1,"Informe o nome da conta"),appKey:de().optional(),appToken:de().optional()});function dn(s){const e=M.c(73),{card:t,selfClient:o,org:c,onDone:a,onIsPendingChange:u}=s,d=re();let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=Ne(cn),e[0]=l):l=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:l,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 x;e[13]!==t||e[14]!==a||e[15]!==c||e[16]!==o?(x={card:t,selfClient:o,org:c,onDone:a},e[13]=t,e[14]=a,e[15]=c,e[16]=o,e[17]=x):x=e[17];const{save:b,isPending:f,error:S}=He(x);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]!==b){let P;e[25]!==b?(P=async E=>{b(E)},e[25]=b,e[26]=P):P=e[26],T=m.handleSubmit(P),e[22]=m,e[23]=b,e[24]=T}else T=e[24];const C=T;let v;e[27]!==f||e[28]!==d?(v=P=>{const{field:E}=P;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=P=>{const{field:E}=P;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 R;e[39]!==f||e[40]!==d?(R=P=>{const{field:E}=P;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]=R):R=e[41];let _;e[42]!==m.control||e[43]!==R?(_=n.jsx(ue,{control:m.control,name:"appToken",render:R}),e[42]=m.control,e[43]=R,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 D;e[50]!==S||e[51]!==d?(D=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]=D):D=e[52];let F;e[53]!==d?(F=d("commerceOnboarding.vtexConfigForm.cancelButton"),e[53]=d,e[54]=F):F=e[54];let $;e[55]!==f||e[56]!==a||e[57]!==F?($=n.jsx(Y,{type:"button",variant:"outline",onClick:a,disabled:f,children:F}),e[55]=f,e[56]=a,e[57]=F,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(Y,{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]!==D||e[71]!==z?(G=n.jsxs("form",{onSubmit:C,className:"space-y-4",children:[O,D,z]}),e[68]=C,e[69]=O,e[70]=D,e[71]=z,e[72]=G):G=e[72],G}function We(s){const e=M.c(29),{options:t,value:o,onChange:c,disabled:a,ariaLabel:u,searchPlaceholder:d,hideSearch:l}=s,p=d===void 0?"Buscar...":d,i=l===void 0?!1:l,[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(un),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 x=j;let b;e[6]!==a||e[7]!==y||e[8]!==c?(b=function(v){if(a||!["ArrowDown","ArrowRight","ArrowUp","ArrowLeft","Home","End"].includes(v.key))return;v.preventDefault();const I=v.currentTarget.dataset.value,A=y.indexOf(I),R=y.length;if(R===0)return;let _;v.key==="ArrowDown"||v.key==="ArrowRight"?_=(A+1)%R:v.key==="ArrowUp"||v.key==="ArrowLeft"?_=(A-1+R)%R:v.key==="Home"?_=0:_=R-1;const O=y[_];c(O),v.currentTarget.closest('[role="radiogroup"]')?.querySelector(`[data-value="${CSS.escape(O)}"]`)?.focus()},e[6]=a,e[7]=y,e[8]=c,e[9]=b):b=e[9];const f=b;let S;e[10]!==u||e[11]!==a||e[12]!==i||e[13]!==r||e[14]!==p?(S=i?null:n.jsxs("div",{className:"relative",children:[n.jsx(gt,{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:a,placeholder:p,"aria-label":`Buscar ${u}`,className:"h-8 pl-8"})]}),e[10]=u,e[11]=a,e[12]=i,e[13]=r,e[14]=p,e[15]=S):S=e[15];let h;e[16]!==a||e[17]!==m||e[18]!==f||e[19]!==c||e[20]!==x||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:a,"data-value":C.value,tabIndex:C.value===x?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(ht,{size:16,className:"shrink-0 text-primary"}):null]},C.value)}),e[16]=a,e[17]=m,e[18]=f,e[19]=c,e[20]=x,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 un(s){return s.value}function Ye(s){const e=M.c(16),{label:t,iconSize:o,className:c,iconClassName:a,labelClassName:u}=s,d=o===void 0?14:o;let l;e[0]!==c?(l=ce("inline-flex items-center gap-2",c),e[0]=c,e[1]=l):l=e[1];let p;e[2]!==a?(p=ce("shrink-0 animate-spin",a),e[2]=a,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]!==l||e[13]!==i||e[14]!==g?(m=n.jsxs("span",{className:l,children:[i,g]}),e[12]=l,e[13]=i,e[14]=g,e[15]=m):m=e[15],m}const mn=_e({propertyId:de().min(1,"Selecione uma propriedade")});function fn(s){const e=M.c(68),{card:t,connectionId:o,companionClient:c,selfClient:a,org:u,onDone:d,onDisconnect:l,onIsPendingChange:p}=s;let i;e[0]!==o||e[1]!==u.id?(i=X.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 kt(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(mn),e[8]=y):y=e[8];const j=t.configurationState?.propertyId||"";let x;e[9]!==j?(x={resolver:y,defaultValues:{propertyId:j}},e[9]=j,e[10]=x):x=e[10];const b=Oe(x);let f;e[11]!==t||e[12]!==d||e[13]!==u||e[14]!==a?(f={card:t,selfClient:a,org:u,onDone:d},e[11]=t,e[12]=d,e[13]=u,e[14]=a,e[15]=f):f=e[15];const{save:S,isPending:h,error:L}=He(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]!==b||e[21]!==S){let k;e[23]!==S?(k=async N=>{S(N)},e[23]=S,e[24]=k):k=e[24],v=b.handleSubmit(k),e[20]=b,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(Ye,{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(gn).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]!==l?(N=l?n.jsx("button",{type:"button",onClick:l,className:"text-xs text-muted-foreground underline underline-offset-2 hover:text-destructive",children:"Desconectar conta"}):n.jsx("span",{}),e[30]=l,e[31]=N):N=e[31];let B;e[32]!==d?(B=n.jsx(Y,{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(We,{options:A.flatMap(pn),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]!==b.control||e[41]!==_?(O=n.jsx(ue,{control:b.control,name:"propertyId",render:_}),e[40]=b.control,e[41]=_,e[42]=O):O=e[42];let D;e[43]!==b||e[44]!==O?(D=n.jsx(Ie,{...b,children:O}),e[43]=b,e[44]=O,e[45]=D):D=e[45];let F;e[46]!==L?(F=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]=F):F=e[47];let $;e[48]!==h||e[49]!==l?($=l?n.jsx("button",{type:"button",onClick:l,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]=l,e[50]=$):$=e[50];let K;e[51]!==h||e[52]!==d?(K=n.jsx(Y,{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(Y,{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 P;e[60]!==$||e[61]!==G?(P=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]=P):P=e[62];let E;return e[63]!==w||e[64]!==D||e[65]!==F||e[66]!==P?(E=n.jsxs("form",{onSubmit:w,className:"space-y-4",children:[D,F,P]}),e[63]=w,e[64]=D,e[65]=F,e[66]=P,e[67]=E):E=e[67],E}function pn(s){return s.options}function gn(s){return s.options}const hn=_e({siteUrl:de().min(1,"Selecione um site")});function xn(s){const e=M.c(62),{card:t,connectionId:o,companionClient:c,selfClient:a,org:u,contextSiteUrl:d,onDone:l,onIsPendingChange:p}=s;let i;e[0]!==o||e[1]!==u.id?(i=X.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(hn),e[8]=y):y=e[8];const j=t.configurationState?.siteUrl||"";let x;e[9]!==j?(x={resolver:y,defaultValues:{siteUrl:j}},e[9]=j,e[10]=x):x=e[10];const b=Oe(x);let f;e[11]!==t||e[12]!==l||e[13]!==u||e[14]!==a?(f={card:t,selfClient:a,org:u,onDone:l},e[11]=t,e[12]=l,e[13]=u,e[14]=a,e[15]=f):f=e[15];const{save:S,isPending:h,error:L}=He(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]!==b||e[22]!==C||e[23]!==m.data||e[24]!==m.isSuccess?(I=()=>{if(!(T.current||!m.isSuccess)){if(T.current=!0,C){b.getValues("siteUrl")!==C&&b.setValue("siteUrl",C);return}if(!b.getValues("siteUrl")){const N=Rt(d,m.data??[]);N&&b.setValue("siteUrl",N)}}},A=[m.isSuccess,m.data,C,d,b],e[20]=d,e[21]=b,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 R;if(e[27]!==b||e[28]!==S){let N;e[30]!==S?(N=async B=>{S(B)},e[30]=S,e[31]=N):N=e[31],R=b.handleSubmit(N),e[27]=b,e[28]=S,e[29]=R}else R=e[29];const _=R;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(Ye,{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 D=O;if(D.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 F;e[37]!==h||e[38]!==D?(F=N=>{const{field:B}=N;return n.jsxs(me,{children:[n.jsx(fe,{children:n.jsx(We,{options:D.map(bn),value:B.value,onChange:B.onChange,disabled:h,ariaLabel:"Site verificado"})}),n.jsx(pe,{})]})},e[37]=h,e[38]=D,e[39]=F):F=e[39];let $;e[40]!==b.control||e[41]!==F?($=n.jsx(ue,{control:b.control,name:"siteUrl",render:F}),e[40]=b.control,e[41]=F,e[42]=$):$=e[42];let K;e[43]!==b||e[44]!==$?(K=n.jsx(Ie,{...b,children:$}),e[43]=b,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]!==l?(z=n.jsx(Y,{type:"button",variant:"outline",onClick:l,disabled:h,children:"Cancelar"}),e[48]=h,e[49]=l,e[50]=z):z=e[50];const G=h?"Salvando...":"Salvar";let P;e[51]!==h||e[52]!==G?(P=n.jsx(Y,{type:"submit",disabled:h,children:G}),e[51]=h,e[52]=G,e[53]=P):P=e[53];let E;e[54]!==z||e[55]!==P?(E=n.jsxs(Ce,{className:"pt-4",children:[z,P]}),e[54]=z,e[55]=P,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 bn(s){return{value:s.siteUrl,label:s.siteUrl}}function Cn(s){const[e,t]=s.split("/");return!e||!t?null:{owner:e,name:t}}function yn(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 vn(s){const{existingRepo:e,existingConnections:t,repoConnectionId:o}=s,c=e?.connectionId&&e.connectionId!==o?e.connectionId:void 0,a=[...t.filter(u=>u.connection_id!==o&&u.connection_id!==c),{connection_id:o,selected_tools:[]}];return{staleConnectionId:c,mergedConnections:a}}const jn=_e({githubRepo:de().min(1,"commerceOnboarding.githubConfigForm.selectRepository")}),Sn=15e3,_n=/^[\w.-]+\/[\w.-]+$/;async function Nn(s,e,t,o){const{installations:c}=await bt(s,t),a=o.trim(),u=await Promise.allSettled(c.map(async i=>{const r=i.type==="User"?"user":"org",g=a?`${r}:${i.login} ${a} in:name`:`${r}:${i.login}`,y=await e.callTool({name:"search_repositories",arguments:{query:g,page:1,perPage:50}},void 0,{signal:AbortSignal.timeout(Sn)}),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 l=0;for(const i of u){if(i.status==="rejected"){l+=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:l,total:c.length}}function On(s){const e=M.c(109),{connectionId:t,companionClient:o,selfClient:c,org:a,onDone:u,onIsPendingChange:d}=s,l=re(),p=Se();let i;e[0]!==a.id?(i=ct.COMMERCE_DISCOVERY(a.id),e[0]=a.id,e[1]=i):i=e[1];const r=i,[g,m]=V.useState(""),y=Vt(g,300),j=V.useRef(!1);let x;e[2]!==t||e[3]!==a.id?(x=X.commerceDiscoveryCompanionGithubSelected(a.id,t),e[2]=t,e[3]=a.id,e[4]=x):x=e[4];let b;e[5]!==r||e[6]!==c?(b=async()=>{const Z=await c.callTool({name:"COLLECTION_CONNECTIONS_GET",arguments:{id:r}}),se=ne(Z).item?.configuration_state??null;return typeof se?.github_repo=="string"?se.github_repo:""},e[5]=r,e[6]=c,e[7]=b):b=e[7];let f;e[8]!==x||e[9]!==b?(f={queryKey:x,queryFn:b},e[8]=x,e[9]=b,e[10]=f):f=e[10];const S=be(f);let h;e[11]!==t||e[12]!==y||e[13]!==a.id?(h=X.commerceDiscoveryCompanionGithubRepos(a.id,t,y.trim()),e[11]=t,e[12]=y,e[13]=a.id,e[14]=h):h=e[14];let L;e[15]!==o||e[16]!==t||e[17]!==y||e[18]!==c?(L=()=>Nn(Z=>c.callTool(Z),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(jn),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]!==a.id||e[28]!==a.slug||e[29]!==c||e[30]!==l?(I=async Z=>{const se=await c.callTool({name:"COLLECTION_CONNECTIONS_GET",arguments:{id:r}}),jt={...ne(se).item?.configuration_state??null??{},github_repo:Z};await c.callTool({name:"COLLECTION_CONNECTIONS_UPDATE",arguments:{id:r,data:{configuration_state:jt}}});const et=Cn(Z);if(!et)throw new Error(l("commerceOnboarding.githubConfigForm.invalidRepository",{repo:Z}));const{owner:ve,name:Pe}=et,tt=wt(a.id),nt=ne(await c.callTool({name:"COLLECTION_VIRTUAL_MCP_GET",arguments:{id:tt}})).item,ot=nt?.metadata?.githubRepo,St=nt?.connections??[],st=yn({existingRepo:ot,owner:ve,name:Pe});let we=st?.connectionId,De=st?.installationId,$e;if(!we){const{installations:qe}=await bt(je=>c.callTool(je),t),Ae=Qt(qe,ve);if(!Ae)throw new Error(l("commerceOnboarding.githubConfigForm.noGithubInstallation",{owner:ve}));De=Ae.installationId;const rt=ne(await c.callTool({name:"COLLECTION_CONNECTIONS_GET",arguments:{id:t}})).item;if(!rt)throw new Error(l("commerceOnboarding.githubConfigForm.githubConnectionNotFound"));const{childConnectionId:at}=await Ht({orgSlug:a.slug,sourceConnection:rt,installationId:De,owner:ve,repo:Pe,githubCallTool:je=>o.callTool(je),selfCallTool:je=>c.callTool(je)});we=at,$e=at}const{staleConnectionId:it,mergedConnections:_t}=vn({existingRepo:ot,existingConnections:St,repoConnectionId:we});try{await c.callTool({name:"COLLECTION_VIRTUAL_MCP_UPDATE",arguments:{id:tt,data:{connections:_t,metadata:{githubRepo:{owner:ve,name:Pe,url:`https://github.com/${Z}`,installationId:De,connectionId:we}}}}}),it&&await c.callTool({name:"COLLECTION_CONNECTIONS_DELETE",arguments:{id:it,force:!0}}).catch(Tn)}catch(qe){const Ae=qe;throw $e&&await c.callTool({name:"COLLECTION_CONNECTIONS_DELETE",arguments:{id:$e,force:!0}}).catch(En),Ae}},e[24]=r,e[25]=o,e[26]=t,e[27]=a.id,e[28]=a.slug,e[29]=c,e[30]=l,e[31]=I):I=e[31];let A;e[32]!==r||e[33]!==u||e[34]!==a.id||e[35]!==p?(A=async()=>{await p.invalidateQueries({queryKey:X.commerceDiscoveryConnection(a.id,r)}),await p.invalidateQueries({queryKey:X.commerceDiscoveryCompanionConnectionsPrefix(a.id)}),Ot(p,a.id),u()},e[32]=r,e[33]=u,e[34]=a.id,e[35]=p,e[36]=A):A=e[36];let R;e[37]!==A||e[38]!==I?(R={mutationFn:I,onSuccess:A},e[37]=A,e[38]=I,e[39]=R):R=e[39];const _=Fe(R),O=_.isPending;let D,F;e[40]!==O||e[41]!==d?(D=()=>{d?.(O)},F=[O,d],e[40]=O,e[41]=d,e[42]=D,e[43]=F):(D=e[42],F=e[43]),V.useEffect(D,F);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 Z;e[52]!==_?(Z=async se=>{_.mutate(se.githubRepo)},e[52]=_,e[53]=Z):Z=e[53],z=w.handleSubmit(Z),e[49]=w,e[50]=_,e[51]=z}else z=e[51];const G=z;let P,E,k;if(e[54]!==y||e[55]!==C.data?.failed||e[56]!==C.data?.repos||e[57]!==C.data?.total||e[58]!==$){const Z=C.data?.repos??[];P=C.data?.failed??0,k=C.data?.total??0;const se=y.trim();E=[...Z],se&&_n.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]=P,e[60]=E,e[61]=k}else P=e[59],E=e[60],k=e[61];const N=k>0&&P===k;let B;e[62]!==N||e[63]!==P||e[64]!==C.isError||e[65]!==l?(B=C.isError||N?l("commerceOnboarding.githubConfigForm.searchFailedTotal"):P>0?l("commerceOnboarding.githubConfigForm.searchFailedPartial"):null,e[62]=N,e[63]=P,e[64]=C.isError,e[65]=l,e[66]=B):B=e[66];const Q=B;let te;e[67]===Symbol.for("react.memo_cache_sentinel")?(te=n.jsx(gt,{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=Z=>m(Z.target.value),e[68]=oe):oe=e[68];let J;e[69]!==l?(J=l("commerceOnboarding.githubConfigForm.searchRepositoryPlaceholder"),e[69]=l,e[70]=J):J=e[70];let q;e[71]!==l?(q=l("commerceOnboarding.githubConfigForm.searchRepositoryLabel"),e[71]=l,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]!==l?(ee=C.isLoading?n.jsx("div",{className:"flex min-h-[160px] items-center justify-center",children:n.jsx(Ye,{label:l("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:l("commerceOnboarding.githubConfigForm.noRepositoriesFound")}):n.jsx(Ie,{...w,children:n.jsx(ue,{control:w.control,name:"githubRepo",render:Z=>{const{field:se}=Z;return n.jsxs(me,{children:[n.jsx(fe,{children:n.jsx(We,{options:E.map(In),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]=l,e[84]=ee):ee=e[84];let ae;e[85]!==_.error||e[86]!==l?(ae=_.error&&n.jsx("p",{role:"alert",className:"text-sm text-destructive",children:_.error instanceof Error?_.error.message:l("commerceOnboarding.githubConfigForm.failedToSave")}),e[85]=_.error,e[86]=l,e[87]=ae):ae=e[87];let W;e[88]!==l?(W=l("commerceOnboarding.githubConfigForm.cancel"),e[88]=l,e[89]=W):W=e[89];let ie;e[90]!==O||e[91]!==u||e[92]!==W?(ie=n.jsx(Y,{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]!==l?(ge=l(O?"commerceOnboarding.githubConfigForm.saving":"commerceOnboarding.githubConfigForm.save"),e[94]=O,e[95]=l,e[96]=ge):ge=e[96];let he;e[97]!==O||e[98]!==ge?(he=n.jsx(Y,{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 In(s){return{value:s,label:s}}function En(){}function Tn(){}const wn={vtex:dn,"google-analytics":fn,"google-search-console":xn,github:On},ye="deco-reader@decocms.iam.gserviceaccount.com",yt={"google-analytics":"ga4","google-search-console":"gsc"},vt={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 An(s,e){const t=vt[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 Ln(s){const e=M.c(95),{provider:t,siteUrl:o,selfClient:c,org:a,initialResourceId:u,onDone:d,onIsPendingChange:l,onOAuthInstead:p}=s,i=re(),r=vt[t],g=Se(),[m,y]=V.useState(null);let j,x;if(e[0]!==r.resourceLabel||e[1]!==i){const W=_e({resourceId:de().trim().min(1,i("commerceOnboarding.saBindingForm.resourceIdRequired",{resourceLabel:r.resourceLabel.toLowerCase()}))});x=Oe,j=Ne(W),e[0]=r.resourceLabel,e[1]=i,e[2]=j,e[3]=x}else j=e[2],x=e[3];const b=u??"";let f;e[4]!==b?(f={resourceId:b},e[4]=b,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=x(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]!==l?(T=()=>l?.(!0),C=()=>l?.(!1),e[14]=l,e[15]=T,e[16]=C):(T=e[15],C=e[16]);let v;e[17]!==r.label||e[18]!==d||e[19]!==a||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:X.commerceDiscoveryConnectionStatus(a.id,o)}),d();return}y({...An(t,W.reason??"unknown"),detail:W.detail})},e[17]=r.label,e[18]=d,e[19]=a,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=Fe(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 R=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 D=O;let F;e[37]!==r.connectSteps?(F=r.connectSteps.map(Rn),e[37]=r.connectSteps,e[38]=F):F=e[38];let $;e[39]!==F?($=n.jsx("ol",{className:"space-y-2 text-sm text-muted-foreground",children:F}),e[39]=F,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(xt,{size:16}),e[44]=z):z=e[44];let G;e[45]!==D||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(Y,{type:"button",variant:"ghost",size:"icon-sm",onClick:D,"aria-label":U,children:z})]}),e[45]=D,e[46]=U,e[47]=G):G=e[47];let P;e[48]!==r.resourceHint||e[49]!==r.resourceLabel||e[50]!==r.resourcePlaceholder||e[51]!==_?(P=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(zt,{children:r.resourceHint}),n.jsx(pe,{})]})},e[48]=r.resourceHint,e[49]=r.resourceLabel,e[50]=r.resourcePlaceholder,e[51]=_,e[52]=P):P=e[52];let E;e[53]!==h.control||e[54]!==P?(E=n.jsx(ue,{control:h.control,name:"resourceId",render:P}),e[53]=h.control,e[54]=P,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(kn)})]}),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(Y,{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(Y,{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]!==R||e[88]!==$||e[89]!==G||e[90]!==k||e[91]!==N||e[92]!==B||e[93]!==ee?(ae=n.jsxs("form",{onSubmit:R,className:"space-y-4",children:[$,G,k,N,B,ee]}),e[87]=R,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 kn(s){return n.jsxs("li",{className:"flex gap-2",children:[n.jsx("span",{"aria-hidden":!0,children:"•"}),n.jsx("span",{children:s})]},s)}function Rn(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 Fn(){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 Pn(s){const e=M.c(17),{title:t,disconnecting:o,disabled:c,onDisconnect:a}=s,u=re(),d=c||o;let l;e[0]!==u||e[1]!==t?(l=u("commerceOnboarding.companionCard.disconnectAriaLabel",{title:t}),e[0]=u,e[1]=t,e[2]=l):l=e[2];let p;e[3]!==o?(p=o?n.jsx(Ue,{size:16,className:"animate-spin"}):n.jsx(Lt,{size:16}),e[3]=o,e[4]=p):p=e[4];let i;e[5]!==a||e[6]!==d||e[7]!==l||e[8]!==p?(i=n.jsx(Me,{asChild:!0,children:n.jsx(Y,{type:"button",variant:"ghost",size:"icon-sm",className:"shrink-0 text-muted-foreground hover:text-destructive",disabled:d,onClick:a,"aria-label":l,children:p})}),e[5]=a,e[6]=d,e[7]=l,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 Dn(s){const e=M.c(23),{card:t,connecting:o,disconnecting:c,disabled:a,onConnect:u,onDisconnect:d,org:l,selfClient:p,siteUrl:i,autoOpenConfigFieldKey:r,onAutoOpenConfigHandled:g}=s,m=t.linkedConnectionId,y=yt[t.bindingType],j=!!y&&t.boundVia!=="oauth",x=t.satisfied&&!t.configured;let b;e[0]!==r||e[1]!==t||e[2]!==o||e[3]!==a||e[4]!==c||e[5]!==m||e[6]!==x||e[7]!==g||e[8]!==u||e[9]!==d||e[10]!==l||e[11]!==y||e[12]!==p||e[13]!==i||e[14]!==j?(b=j&&y?n.jsx($n,{card:t,provider:y,org:l,selfClient:p,siteUrl:i,onOAuthInstead:u,disabled:a,connecting:o,primary:t.required}):t.satisfied&&m?n.jsxs("div",{className:"flex items-center justify-end gap-1 sm:justify-start",children:[n.jsx(V.Suspense,{fallback:n.jsx(qn,{}),children:n.jsx(Kn,{card:t,org:l,selfClient:p,connectionId:m,contextSiteUrl:i,variant:x?"configure":"gear",disabled:a,autoOpen:x||Ft({autoOpenFieldKey:r,card:t}),onAutoOpenHandled:g})}),n.jsx(Pn,{title:t.title,disconnecting:c,disabled:a,onDisconnect:d})]}):n.jsx(Ct,{connecting:o,disabled:a,title:t.title,primary:t.required,onConnect:u}),e[0]=r,e[1]=t,e[2]=o,e[3]=a,e[4]=c,e[5]=m,e[6]=x,e[7]=g,e[8]=u,e[9]=d,e[10]=l,e[11]=y,e[12]=p,e[13]=i,e[14]=j,e[15]=b):b=e[15];const f=b,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]!==x||e[21]!==S?(h=n.jsx(rn,{icon:t.icon,title:t.title,headline:t.headline,required:S,attention:x,action:f}),e[16]=f,e[17]=t.headline,e[18]=t.icon,e[19]=t.title,e[20]=x,e[21]=S,e[22]=h):h=e[22],h}function $n(s){const e=M.c(45),{card:t,provider:o,org:c,selfClient:a,siteUrl:u,onOAuthInstead:d,disabled:l,connecting:p,primary:i}=s,r=re(),[g,m]=V.useState(!1),[y,j]=V.useState(!1);let x;e[0]!==y?(x=F=>{!F&&y||m(F)},e[0]=y,e[1]=x):x=e[1];const b=x;let f;e[2]!==t.satisfied||e[3]!==t.title||e[4]!==p||e[5]!==l||e[6]!==i||e[7]!==r?(f=t.satisfied?n.jsx(ln,{controls:n.jsxs(Be,{children:[n.jsx(Me,{asChild:!0,children:n.jsx(Y,{type:"button",variant:"ghost",size:"icon-sm",className:"shrink-0",onClick:()=>m(!0),"aria-label":r("commerceOnboarding.companionCard.configureAriaLabel",{title:t.title}),children:n.jsx(Qe,{size:16})})}),n.jsx(Ve,{children:r("commerceOnboarding.companionCard.editConfiguration")})]})}):n.jsx(Ct,{connecting:p,disabled:l,title:t.title,primary:i,onConnect:()=>m(!0)}),e[2]=t.satisfied,e[3]=t.title,e[4]=p,e[5]=l,e[6]=i,e[7]=r,e[8]=f):f=e[8];let S;e[9]!==t.icon||e[10]!==t.title?(S=n.jsx(Ge,{icon:t.icon,name:t.title,size:"md",fit:"contain",className:"p-1.5"}),e[9]=t.icon,e[10]=t.title,e[11]=S):S=e[11];let h;e[12]!==t.title?(h=n.jsx(dt,{children:t.title}),e[12]=t.title,e[13]=h):h=e[13];let L;e[14]!==r?(L=r("commerceOnboarding.companionCard.grantAccessDescription"),e[14]=r,e[15]=L):L=e[15];let T;e[16]!==L?(T=n.jsx(ut,{children:L}),e[16]=L,e[17]=T):T=e[17];let C;e[18]!==h||e[19]!==T?(C=n.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:[h,T]}),e[18]=h,e[19]=T,e[20]=C):C=e[20];let v;e[21]!==S||e[22]!==C?(v=n.jsxs(mt,{className:"flex-row items-center gap-3 space-y-0 text-left",children:[S,C]}),e[21]=S,e[22]=C,e[23]=v):v=e[23];const w=t.boundResource??void 0;let I;e[24]===Symbol.for("react.memo_cache_sentinel")?(I=()=>m(!1),e[24]=I):I=e[24];let A;e[25]!==t.satisfied||e[26]!==d?(A=t.satisfied?void 0:()=>{m(!1),d()},e[25]=t.satisfied,e[26]=d,e[27]=A):A=e[27];let R;e[28]!==c||e[29]!==o||e[30]!==a||e[31]!==u||e[32]!==A||e[33]!==w?(R=n.jsx(Ln,{provider:o,siteUrl:u,selfClient:a,org:c,initialResourceId:w,onDone:I,onIsPendingChange:j,onOAuthInstead:A}),e[28]=c,e[29]=o,e[30]=a,e[31]=u,e[32]=A,e[33]=w,e[34]=R):R=e[34];let _;e[35]!==R||e[36]!==v?(_=n.jsxs(ft,{className:"sm:max-w-lg",children:[v,R]}),e[35]=R,e[36]=v,e[37]=_):_=e[37];let O;e[38]!==b||e[39]!==g||e[40]!==_?(O=n.jsx(pt,{open:g,onOpenChange:b,children:_}),e[38]=b,e[39]=g,e[40]=_,e[41]=O):O=e[41];let D;return e[42]!==O||e[43]!==f?(D=n.jsxs(n.Fragment,{children:[f,O]}),e[42]=O,e[43]=f,e[44]=D):D=e[44],D}function qn(){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 Kn(s){const e=M.c(71),{card:t,org:o,selfClient:c,connectionId:a,contextSiteUrl:u,variant:d,disabled:l,autoOpen:p,onAutoOpenHandled:i}=s,r=re();let g;e[0]!==a||e[1]!==o.id||e[2]!==o.slug?(g={connectionId:a,orgId:o.id,orgSlug:o.slug},e[0]=a,e[1]=o.id,e[2]=o.slug,e[3]=g):g=e[3];const m=ze(g),[y,j]=V.useState(p),[x,b]=V.useState(!1),f=Se(),S=wn[t.bindingType];let h;e[4]!==t.configurationState?(h=Pt(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]!==x?(v=te=>{if(!(!te&&x)){if(!te){C();return}j(!0)}},e[9]=C,e[10]=x,e[11]=v):v=e[11];const w=v;let I;e[12]!==a||e[13]!==c?(I=async()=>{await c.callTool({name:"COLLECTION_CONNECTIONS_DELETE",arguments:{id:a,force:!0}})},e[12]=a,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:X.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 R;e[21]!==r?(R=()=>{ke.error(r("commerceOnboarding.companionCard.disconnectError"))},e[21]=r,e[22]=R):R=e[22];let _;e[23]!==I||e[24]!==A||e[25]!==R?(_={mutationFn:I,onSuccess:A,onError:R},e[23]=I,e[24]=A,e[25]=R,e[26]=_):_=e[26];const O=Fe(_);if(!S)return null;let D;e[27]!==t.title||e[28]!==l||e[29]!==L||e[30]!==r||e[31]!==d?(D=d==="configure"?n.jsx(an,{disabled:l,title:t.title,onConfigure:()=>j(!0)}):n.jsxs(Be,{children:[n.jsx(Me,{asChild:!0,children:n.jsx(Y,{type:"button",variant:"ghost",size:"icon-sm",className:"shrink-0",onClick:()=>j(!0),"aria-label":r("commerceOnboarding.companionCard.configureAriaLabel",{title:t.title}),children:n.jsx(Qe,{size:16})})}),n.jsx(Ve,{children:L.length>0?r("commerceOnboarding.companionCard.editConfiguration"):r("commerceOnboarding.companionCard.configure")})]}),e[27]=t.title,e[28]=l,e[29]=L,e[30]=r,e[31]=d,e[32]=D):D=e[32];const F=D;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(dt,{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(ut,{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 P;e[46]!==$||e[47]!==G?(P=n.jsxs(mt,{className:"flex-row items-center gap-3 space-y-0 text-left",children:[$,G]}),e[46]=$,e[47]=G,e[48]=P):P=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]!==a||e[56]!==u||e[57]!==o||e[58]!==c||e[59]!==E?(k=n.jsx(S,{card:t,connectionId:a,companionClient:m,selfClient:c,org:o,contextSiteUrl:u,onDone:C,onDisconnect:E,onIsPendingChange:b}),e[51]=S,e[52]=t,e[53]=C,e[54]=m,e[55]=a,e[56]=u,e[57]=o,e[58]=c,e[59]=E,e[60]=k):k=e[60];let N;e[61]!==P||e[62]!==k?(N=n.jsxs(ft,{className:"sm:max-w-lg",children:[P,k]}),e[61]=P,e[62]=k,e[63]=N):N=e[63];let B;e[64]!==y||e[65]!==w||e[66]!==N?(B=n.jsx(pt,{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]!==F?(Q=n.jsxs(n.Fragment,{children:[F,B]}),e[68]=B,e[69]=F,e[70]=Q):Q=e[70],Q}const Ze={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 Un(s){const e=M.c(40),{selfClient:t,org:o,cdConnectionId:c,siteUrl:a}=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 l;e[4]!==c||e[5]!==o.id?(l=X.commerceDiscoveryCompanionSchema(o.id,c),e[4]=c,e[5]=o.id,e[6]=l):l=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]!==l||e[10]!==p?(i={queryKey:l,queryFn:p,retry:!1},e[9]=l,e[10]=p,e[11]=i):i=e[11];const r=be(i),g=r.data?.stateSchema?Dt(r.data.stateSchema):null,m=g&&g.length>0?g:$t,y=m.map(Zn),j=m.map(Yn).filter(Wn),x=m.filter(Hn).map(Qn),b=[...j,...x].sort().join(",");let f;e[12]!==c||e[13]!==o.id?(f=X.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(Vn),w=[...y.map(Mn),...j.map(Bn),...v.map(Gn)].sort().join(","),A=Ke({queryKey:X.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??[],R=new Set(v),_=A.filter(q=>R.has(q.id)),O=_.filter(zn);let D;e[23]!==o.id||e[24]!==o.slug?(D=q=>({queryKey:X.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]=D):D=e[25];const F=Jt({queries:O.map(D)});let $;e[26]!==F?($=(q,H)=>[q.id,F[H]?.data?.hasToken===!0],e[26]=F,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:X.commerceDiscoveryCompanionRegistry(o.id,b),queryFn:async()=>{if(m.length===0)return{items:[]};const q=qt(j,x),H=await Wt(ct.REGISTRY(o.id),o.id,o.slug,"COLLECTION_REGISTRY_APP_LIST",{...q?{where:q}:{},limit:1e3});return ne(H)}}),G={},P={};for(const q of z.data?.items??[])G[q.id]=q,q.server?.name&&(P[q.server.name]=q);let E;e[28]!==o.id||e[29]!==a?(E=X.commerceDiscoveryConnectionStatus(o.id,a??""),e[28]=o.id,e[29]=a,e[30]=E):E=e[30];const k=!!a;let N;e[31]!==t||e[32]!==a?(N=async()=>{const q=await t.callTool({name:"COMMERCE_DISCOVERY_CONNECTION_STATUS",arguments:{siteUrl:a}});return ne(q)},e[31]=t,e[32]=a,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(yt)){const ee=Q.data?.providers?.[H];ee?.connected&&ee.via==="sa"&&(te[q]={resource:ee.resource??null})}const oe=Kt({requirements:m,itemsById:G,itemsByName:P,connections:A,connectionReadiness:U,configurationState:T,curated:Ze,saBindings:te});let J;return e[38]!==oe?(J={cards:oe},e[38]=oe,e[39]=J):J=e[39],J}function zn(s){return s.oauth_config&&!s.connection_token}function Gn(s){return`linked:${s}`}function Bn(s){return`app:${s}`}function Mn(s){return`binding:${s}`}function Vn(s){return typeof s=="string"&&s.length>0}function Qn(s){return s.bindingType}function Hn(s){return!Ze[s.bindingType]}function Wn(s){return!!s}function Yn(s){return Ze[s.bindingType]?.registryAppId}function Zn(s){return s.bindingType}function Xn({selfClient:s,org:e,userId:t,cdConnectionId:o,domain:c,siteUrl:a}){const u=Se(),[d,l]=V.useState(null),[p,i]=V.useState(null),[r,g]=V.useState(null),m=async(x,b)=>{const f=await s.callTool({name:"COLLECTION_CONNECTIONS_UPDATE",arguments:{id:x,data:b}});return ne(f)};async function y(x){l(x.fieldKey),g(null);const b={app_name:x.title,field_key:x.fieldKey,organization_id:e.id,domain:c,site_url:a};le("commerce_onboarding_companion_connect_clicked",b);try{let f=x.candidateConnectionId;if(!f){const v=Yt(x.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",{...b,error:"no_connection_method"}),g(`${x.title} cannot be connected: no connection method available`),!1;const R=await s.callTool({name:"COLLECTION_CONNECTIONS_CREATE",arguments:{data:v}});f=ne(R).item.id}const S=f,h=await Xt({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",{...b,error:h.error}),g(`Couldn't sign in to ${x.title}: ${h.error}`),!1;const L=await s.callTool({name:"COLLECTION_CONNECTIONS_GET",arguments:{id:o}}),T=ne(L).item?.configuration_state??null,C=Ut(T,x.fieldKey,x.bindingType,S);return x.bindingType==="github"&&delete C.github_repo,await m(o,{configuration_state:C}),await u.invalidateQueries({queryKey:X.commerceDiscoveryConnection(e.id,o)}),await u.invalidateQueries({queryKey:X.commerceDiscoveryCompanionConnectionsPrefix(e.id)}),le("commerce_onboarding_companion_connected",b),!0}catch(f){return le("commerce_onboarding_companion_connect_failed",{...b,error:f instanceof Error?f.message:String(f)}),g(f instanceof Error?f.message:String(f)),!1}finally{l(null)}}async function j(x){i(x.fieldKey),g(null);const b={app_name:x.title,field_key:x.fieldKey,organization_id:e.id,domain:c,site_url:a};le("commerce_onboarding_companion_disconnect_clicked",b);try{const f=await s.callTool({name:"COLLECTION_CONNECTIONS_GET",arguments:{id:o}}),h={...ne(f).item?.configuration_state??null??{}};return delete h[x.fieldKey],x.bindingType==="github"&&delete h.github_repo,await m(o,{configuration_state:h}),await u.invalidateQueries({queryKey:X.commerceDiscoveryConnection(e.id,o)}),await u.invalidateQueries({queryKey:X.commerceDiscoveryCompanionConnectionsPrefix(e.id)}),le("commerce_onboarding_companion_disconnected",b),!0}catch(f){return le("commerce_onboarding_companion_disconnect_failed",{...b,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 Xe="flex min-h-0 flex-1 flex-col gap-6 md:grid md:flex-none md:gap-6";function Je(){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 Jn(){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(eo)}),s[0]=e):e=s[0],e}function eo(s){return n.jsx(Fn,{},s)}function to(){const s=M.c(1);let e;return s[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsxs("div",{className:Xe,children:[n.jsx(Je,{}),n.jsx(Jn,{})]}),s[0]=e):e=s[0],e}function no(s){const e=M.c(18),{onRetry:t}=s,o=re();let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx(Je,{}),e[0]=c):c=e[0];let a;e[1]!==o?(a=o("routes.commerceOnboarding.companionSection.loadError"),e[1]=o,e[2]=a):a=e[2];let u;e[3]!==a?(u=n.jsx("p",{className:"text-sm text-foreground",children:a}),e[3]=a,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 l;e[7]!==d?(l=n.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:d}),e[7]=d,e[8]=l):l=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(Y,{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]!==l||e[16]!==i?(r=n.jsxs("div",{className:Xe,children:[c,n.jsxs("div",{role:"alert",className:"rounded-2xl border border-border bg-card p-4",children:[u,l,i]})]}),e[14]=u,e[15]=l,e[16]=i,e[17]=r):r=e[17],r}function Ao(s){const e=M.c(2);let t;return e[0]!==s?(t=n.jsx(It,{children:o=>{const{reset:c}=o;return n.jsx(Et,{fallback:a=>{const{resetError:u}=a;return n.jsx(no,{onRetry:()=>{c(),u()}})},children:n.jsx(V.Suspense,{fallback:n.jsx(to,{}),children:n.jsx(oo,{...s})})})}}),e[0]=s,e[1]=t):t=e[1],t}function oo(s){const e=M.c(53),{org:t,cdConnectionId:o,siteUrl:c,onReadinessChange:a}=s,{data:u}=Tt.useSession(),d=u?.user?.id??"";let l;if(e[0]!==c){const K=c?Re(c):null;if(K?.ok)try{l=new URL(K.value).hostname}catch{l=void 0}e[0]=c,e[1]=l}else l=e[1];let p;e[2]!==t.id||e[3]!==t.slug?(p={connectionId:At,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}=Un(r);let m;e[10]!==o||e[11]!==t||e[12]!==i||e[13]!==l||e[14]!==c||e[15]!==d?(m={selfClient:i,org:t,userId:d,cdConnectionId:o,domain:l,siteUrl:c},e[10]=o,e[11]=t,e[12]=i,e[13]=l,e[14]=c,e[15]=d,e[16]=m):m=e[16];const{connect:y,connectingFieldKey:j,disconnect:x,disconnectingFieldKey:b,error:f}=Xn(m),[S,h]=V.useState(null),L=ro;let T,C,v,w,I,A,R,_,O;if(e[17]!==S||e[18]!==g||e[19]!==y||e[20]!==f||e[21]!==j||e[22]!==x||e[23]!==b||e[24]!==a||e[25]!==t||e[26]!==i||e[27]!==c){v=Symbol.for("react.early_return_sentinel");e:{const K=g.filter(io),U=g.filter(so),z=K.length>0?K.every(L):g.length===0||g.some(L);if(a?.(z),g.length===0){v=null;break e}const G=j!==null||b!==null,P=E=>{const k=async()=>{await y(E)&&h(E.fieldKey)};return n.jsx(Dn,{card:E,connecting:j===E.fieldKey,disconnecting:b===E.fieldKey,disabled:G&&j!==E.fieldKey&&b!==E.fieldKey,org:t,selfClient:i,siteUrl:c,autoOpenConfigFieldKey:S,onAutoOpenConfigHandled:()=>h(N=>N===E.fieldKey?null:N),onConnect:()=>{k()},onDisconnect:()=>{x(E)}},E.fieldKey)};O=Xe,e[37]===Symbol.for("react.memo_cache_sentinel")?(C=n.jsx(Je,{}),e[37]=C):C=e[37],T=sn,A="flex min-h-0 flex-1 flex-col md:block",R="-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(P)}e[17]=S,e[18]=g,e[19]=y,e[20]=f,e[21]=j,e[22]=x,e[23]=b,e[24]=a,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]=R,e[35]=_,e[36]=O}else T=e[28],C=e[29],v=e[30],w=e[31],I=e[32],A=e[33],R=e[34],_=e[35],O=e[36];if(v!==Symbol.for("react.early_return_sentinel"))return v;let D;e[40]!==w||e[41]!==I?(D=n.jsx("div",{className:w,children:I}),e[40]=w,e[41]=I,e[42]=D):D=e[42];let F;e[43]!==T||e[44]!==D||e[45]!==A||e[46]!==R||e[47]!==_?(F=n.jsxs(T,{wrapperClassName:A,className:R,children:[_,D]}),e[43]=T,e[44]=D,e[45]=A,e[46]=R,e[47]=_,e[48]=F):F=e[48];let $;return e[49]!==C||e[50]!==F||e[51]!==O?($=n.jsxs("div",{className:O,children:[C,F]}),e[49]=C,e[50]=F,e[51]=O,e[52]=$):$=e[52],$}function so(s){return!s.required}function io(s){return s.required}function ro(s){return s.satisfied&&s.configured}function ao(s){return s.content?.find(e=>e.text)?.text??"A configuração do Commerce Discovery falhou."}function Lo(s){const e=s;if(e.isError)throw new Error(ao(e));return e.structuredContent??s}export{to as C,Ye as L,sn as S,Ao as a,To as i,Re as n,Lo as p,wo as s};
|