decocms 2.306.0 → 2.306.2
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-ri2xuBKe.js → AlertCircle-CcUtX5uM.js} +1 -1
- package/dist/client/assets/{ArrowNarrowLeft-yxFeL5-Q.js → ArrowNarrowLeft-IKO0Pdme.js} +1 -1
- package/dist/client/assets/{ArrowUpRight-Bxgj2IVp.js → ArrowUpRight-B9ER_pU4.js} +1 -1
- package/dist/client/assets/{Check-C6Fa8-x7.js → Check-DVRpvrTF.js} +1 -1
- package/dist/client/assets/{CheckCircle-D7N7MOmw.js → CheckCircle-C1PuOF6d.js} +1 -1
- package/dist/client/assets/{ChevronDown-DmrzaACF.js → ChevronDown-BgtmJwU7.js} +1 -1
- package/dist/client/assets/{ChevronRight-CZ_XAq5W.js → ChevronRight-BxsGpbIW.js} +1 -1
- package/dist/client/assets/{ChevronUp-Ds9ufeJd.js → ChevronUp-DvM1tvKw.js} +1 -1
- package/dist/client/assets/{Container-BXYDPrF5.js → Container-D_d73BfD.js} +1 -1
- package/dist/client/assets/{DotsVertical-CYFsY1AY.js → DotsVertical-CFsox5cs.js} +1 -1
- package/dist/client/assets/{LinkExternal01-Dvpxn-Ig.js → LinkExternal01-BFJlAOho.js} +1 -1
- package/dist/client/assets/{Lock01-63SpB195.js → Lock01-BDVFL4zm.js} +1 -1
- package/dist/client/assets/{Palette-D0iAFXNq.js → Palette-C4Za_YQg.js} +1 -1
- package/dist/client/assets/{Play-D4xI5B_i.js → Play-CG03drxN.js} +1 -1
- package/dist/client/assets/{Plus-CDEOyPu8.js → Plus-BMxmddO-.js} +1 -1
- package/dist/client/assets/{RefreshCcw01-B2ZHRQzo.js → RefreshCcw01-B_PJ5f1k.js} +1 -1
- package/dist/client/assets/{SearchMd-6IRfjRcX.js → SearchMd-BH72zEYs.js} +1 -1
- package/dist/client/assets/{Settings02-3HEuuiVe.js → Settings02-Bvv_nn0Y.js} +1 -1
- package/dist/client/assets/{Shield01-BGj8uiOU.js → Shield01-B-3tcngo.js} +1 -1
- package/dist/client/assets/{Star01-BSZxz5Wn.js → Star01-Cdw_hElv.js} +1 -1
- package/dist/client/assets/{Sun-DdqVKeEA.js → Sun-ja3JE2c9.js} +1 -1
- package/dist/client/assets/{Tool01-DMFP0Svb.js → Tool01-DK9-mVZw.js} +1 -1
- package/dist/client/assets/{Trash01-Dj5mVOWm.js → Trash01-D676SGAl.js} +1 -1
- package/dist/client/assets/{User01-CDDY3fE9.js → User01-DGJlNaMw.js} +1 -1
- package/dist/client/assets/{Users03-BbIOB2XC.js → Users03-CRQrY9LZ.js} +1 -1
- package/dist/client/assets/{X-yKx8T0mV.js → X-DZI_qdyG.js} +1 -1
- package/dist/client/assets/{XCircle-BLtaN_6O.js → XCircle-BI7HQKdL.js} +1 -1
- package/dist/client/assets/{XClose-Bk1D4OG4.js → XClose-DQPB9QhN.js} +1 -1
- package/dist/client/assets/{Zap-Ctp20y2W.js → Zap-Dd-DoFdM.js} +1 -1
- package/dist/client/assets/{ZapSquare-BOPwjpzz.js → ZapSquare-DZh8af5t.js} +1 -1
- package/dist/client/assets/{accordion-Cp5pOFIt.js → accordion-BqJi9w98.js} +1 -1
- package/dist/client/assets/{agent-icon-6IsHLhhx.js → agent-icon-BpIPT-PU.js} +1 -1
- package/dist/client/assets/{agents-list-2IMNAAmL.js → agents-list-C92sGcpj.js} +1 -1
- package/dist/client/assets/ai-providers-Bi9o279v.js +1 -0
- package/dist/client/assets/{alert-dialog-D-vKhXAM.js → alert-dialog-DZnXWtkc.js} +1 -1
- package/dist/client/assets/{auth-catchall-DSDUVS7V.js → auth-catchall-BlSxNcbF.js} +1 -1
- package/dist/client/assets/{automation-list-row-DXQ1xbHt.js → automation-list-row-BjkF6IP8.js} +1 -1
- package/dist/client/assets/{automations-BKGLmUCl.js → automations-Dk44qwnk.js} +1 -1
- package/dist/client/assets/{avatar-DiYo_VFp.js → avatar-EJ4rWeJV.js} +1 -1
- package/dist/client/assets/{badge-v1Fnh_-2.js → badge-CMhkMPpc.js} +1 -1
- package/dist/client/assets/{brand-context-DWyvnvIk.js → brand-context-DHKafDne.js} +1 -1
- package/dist/client/assets/{card-CMatfPs6.js → card-DfBr11OH.js} +1 -1
- package/dist/client/assets/{chat-context-BOGVHhEC.js → chat-context-DfNQ7f-M.js} +1 -1
- package/dist/client/assets/{checkbox-DgRshC0u.js → checkbox-CsVxpSNu.js} +1 -1
- package/dist/client/assets/{collection-detail-D8ViAcbL.js → collection-detail-D3z0bht4.js} +1 -1
- package/dist/client/assets/{collection-display-button-BEIthj-o.js → collection-display-button-CijPjsBx.js} +1 -1
- package/dist/client/assets/{collection-search-CLwC-feE.js → collection-search-CUzZkask.js} +1 -1
- package/dist/client/assets/{collection-search-Dsu0rnLF.js → collection-search-DDXROr4Y.js} +1 -1
- package/dist/client/assets/{collection-table-wrapper-Df3XEjUz.js → collection-table-wrapper-BJIOgEuU.js} +1 -1
- package/dist/client/assets/{collection-tabs-3zydPpJg.js → collection-tabs-Sh1c6Hp3.js} +1 -1
- package/dist/client/assets/{collections-DIZVbUQW.js → collections-B6H9755O.js} +1 -1
- package/dist/client/assets/{command-Cb8AzRR0.js → command-CN0wol1M.js} +1 -1
- package/dist/client/assets/{connection-card-CN5pQMAi.js → connection-card-t8q3avUo.js} +1 -1
- package/dist/client/assets/{connection-detail-DMf-fgcD.js → connection-detail-_U-y0yZK.js} +1 -1
- package/dist/client/assets/{connection-form-helpers-0uGtdPq8.js → connection-form-helpers-CDqLkd8a.js} +1 -1
- package/dist/client/assets/{connections-oG85p-mQ.js → connections-B7soayai.js} +1 -1
- package/dist/client/assets/{constants-hjtpWhr_.js → constants-Hpdlytpy.js} +1 -1
- package/dist/client/assets/{constants-BBSLGS7p.js → constants-RvCh42kd.js} +1 -1
- package/dist/client/assets/{dialog-CICi1bFC.js → dialog-sB-RNyMu.js} +1 -1
- package/dist/client/assets/{domain-settings-CjSKJW17.js → domain-settings-CfN0XeQj.js} +1 -1
- package/dist/client/assets/{drawer-CAsvHZha.js → drawer-DdDu6FoS.js} +1 -1
- package/dist/client/assets/{dropdown-menu-DVFKsYz3.js → dropdown-menu-Ba10Ub1x.js} +1 -1
- package/dist/client/assets/{dynamic-plugin-layout-BTYFB5Vl.js → dynamic-plugin-layout-DXfaFfD-.js} +1 -1
- package/dist/client/assets/{empty-state-Dk0gx8oo.js → empty-state-4KQTPzu7.js} +1 -1
- package/dist/client/assets/{empty-state-CwHUFi5m.js → empty-state-oHMUpnK0.js} +1 -1
- package/dist/client/assets/{extract-connection-data-CvD7TUFj.js → extract-connection-data-CLmSiyTB.js} +1 -1
- package/dist/client/assets/{features-vcFr7_NO.js → features-gEXnGXJn.js} +1 -1
- package/dist/client/assets/{form-bUi5oN1u.js → form-C8F4itc9.js} +1 -1
- package/dist/client/assets/{general-iD0oGniS.js → general-YVhMnlrc.js} +1 -1
- package/dist/client/assets/{index-CMnREwkX.js → index-9WMiiDWH.js} +1 -1
- package/dist/client/assets/{index-B7e3gTna.js → index-A1kUSxVF.js} +1 -1
- package/dist/client/assets/{index-Dg6zk4z0.js → index-B__IE7Zg.js} +1 -1
- package/dist/client/assets/{index-k1BGw4YF.js → index-BfH23PIC.js} +1 -1
- package/dist/client/assets/{index-C_78kpYQ.js → index-C8Jg2iKl.js} +1 -1
- package/dist/client/assets/{index-D9n-W_rO.js → index-CPXgqgtn.js} +2 -2
- package/dist/client/assets/{index-BczjQy3M.js → index-CaFhVluQ.js} +1 -1
- package/dist/client/assets/{index-CKbPmli4.js → index-Ccbgu0mE.js} +1 -1
- package/dist/client/assets/{index-PFIdYUp0.js → index-CsYx-I3w.js} +1 -1
- package/dist/client/assets/{index-CBeau-VE.js → index-CzNtdOVE.js} +3 -3
- package/dist/client/assets/{index-DM4aujMZ.js → index-DGIpb-N4.js} +1 -1
- package/dist/client/assets/{index-BCI_OHNR.js → index-RcpmOMcB.js} +1 -1
- package/dist/client/assets/{index-BxSEc3iB.js → index-SKdTLMdd.js} +1 -1
- package/dist/client/assets/{index-BOCF3HeX.js → index-Vpu4sPxo.js} +1 -1
- package/dist/client/assets/index-s5U-1Asm.js +1 -0
- package/dist/client/assets/{index-DWSuPJ_b.js → index-vqBvbw9C.js} +1 -1
- package/dist/client/assets/{infiniteQueryObserver-DnwZzogs.js → infiniteQueryObserver-BeoG5sU6.js} +1 -1
- package/dist/client/assets/{input-Aj2AxbJX.js → input-BYLqJazY.js} +1 -1
- package/dist/client/assets/{integration-icon-CNrz8Wxa.js → integration-icon-Btpdnlb-.js} +1 -1
- package/dist/client/assets/{label-CuWuUZ3O.js → label-wqfg1Psv.js} +1 -1
- package/dist/client/assets/{layout-zn0Mql8j.js → layout-CSZNypzG.js} +1 -1
- package/dist/client/assets/{lean-canvas-recruit-modal-mlOx896G.js → lean-canvas-recruit-modal-aeSS5EN2.js} +1 -1
- package/dist/client/assets/{login-BAIGAZLg.js → login-eSx-pmqu.js} +1 -1
- package/dist/client/assets/{members--FDE6tuk.js → members-Dp2QRB1E.js} +1 -1
- package/dist/client/assets/{monaco-editor-PZYP8jhf.js → monaco-editor-Bp7vt54e.js} +1 -1
- package/dist/client/assets/{monitoring-stats-row-BbRUPAD5.js → monitoring-stats-row-CSfdCe-P.js} +1 -1
- package/dist/client/assets/{oauth-callback-BaQ7B2Rx.js → oauth-callback-ChiIJvQB.js} +1 -1
- package/dist/client/assets/{oauth-callback-ai-provider-DcbaUyEX.js → oauth-callback-ai-provider-Uj96uOps.js} +1 -1
- package/dist/client/assets/{onboarding-h88h3klM.js → onboarding-B_0dDnLd.js} +1 -1
- package/dist/client/assets/{org-layout-BBR4isCp.js → org-layout-DokAgJ5h.js} +1 -1
- package/dist/client/assets/{org-plugin-layout-Dl6QtWDy.js → org-plugin-layout-C98RwuLU.js} +1 -1
- package/dist/client/assets/{pair-DST-dVfc.js → pair-DYA5r7ea.js} +1 -1
- package/dist/client/assets/{plugin-empty-state-CAfBOmv9.js → plugin-empty-state-j8s8XCj4.js} +1 -1
- package/dist/client/assets/{plugin-header-RtXpJdkF.js → plugin-header-BufwzLmI.js} +1 -1
- package/dist/client/assets/{plugin-layout-DLTDP8qX.js → plugin-layout-BwLMjrn6.js} +1 -1
- package/dist/client/assets/{popover-DFJMwPZz.js → popover-BP8qYbWI.js} +1 -1
- package/dist/client/assets/{profile-Bc72ys1m.js → profile-BUq_8Y8L.js} +1 -1
- package/dist/client/assets/{project-app-view-k_Cpcixt.js → project-app-view-Xj3yVfXy.js} +1 -1
- package/dist/client/assets/registry-BLsA5AO_.js +2 -0
- package/dist/client/assets/{registry-layout-Cg78aXMt.js → registry-layout-CZ27EJiP.js} +1 -1
- package/dist/client/assets/{required-auth-layout-BRdLiCQS.js → required-auth-layout-DxobDViQ.js} +1 -1
- package/dist/client/assets/{reset-password-B6r9t9Oh.js → reset-password-BX31j3AV.js} +1 -1
- package/dist/client/assets/{roles-Ee_Uhan9.js → roles-dyH1CsHQ.js} +1 -1
- package/dist/client/assets/{scroll-area-D7xTqtD-.js → scroll-area-Bazrt5Q_.js} +1 -1
- package/dist/client/assets/{search-input-BYHjVlDa.js → search-input-CagM2rOd.js} +1 -1
- package/dist/client/assets/{select-DWMsyC47.js → select-DV6XTbu1.js} +1 -1
- package/dist/client/assets/{select-model-p3PkjF3m.js → select-model-q-6_EO7e.js} +1 -1
- package/dist/client/assets/{settings-layout-B5lxdePw.js → settings-layout-ydozaX1z.js} +1 -1
- package/dist/client/assets/{settings-section-DLmXqm7P.js → settings-section-BSSTyi59.js} +1 -1
- package/dist/client/assets/{shell-layout-DDd0qO09.js → shell-layout-CCBbSGMK.js} +1 -1
- package/dist/client/assets/{skeleton-fTv1xeu9.js → skeleton-eJ5dvmO1.js} +1 -1
- package/dist/client/assets/{sso-DPaJITTm.js → sso-D3B4i8mi.js} +1 -1
- package/dist/client/assets/store-registry-BizfzILs.js +2 -0
- package/dist/client/assets/{store-CAA-krPV.js → store-tol-TExI.js} +1 -1
- package/dist/client/assets/{switch-D664sdCn.js → switch-B9P99cpo.js} +1 -1
- package/dist/client/assets/{table-mlNAjytE.js → table-BIJ38639.js} +1 -1
- package/dist/client/assets/{tabs-Bakk2hgc.js → tabs-C0vV7-ts.js} +1 -1
- package/dist/client/assets/{task-status-B1waCh_f.js → task-status-nAuAdX3m.js} +1 -1
- package/dist/client/assets/{textarea-B5ocquNh.js → textarea-Dk5HQM76.js} +1 -1
- package/dist/client/assets/{toggle-group-CdL7Wi0S.js → toggle-group-DiN3ciV3.js} +1 -1
- package/dist/client/assets/{tools-list-C9TFhRWw.js → tools-list-NaHpnv5w.js} +1 -1
- package/dist/client/assets/{tooltip-D3G-75TX.js → tooltip-CCRvyunm.js} +1 -1
- package/dist/client/assets/{types-iEh-ujpY.js → types-CsuD99pM.js} +1 -1
- package/dist/client/assets/{use-ai-providers-B5bMFCmc.js → use-ai-providers-Dgd0mo29.js} +1 -1
- package/dist/client/assets/{use-collections-D6rFCbFs.js → use-collections-Ra-WueHq.js} +1 -1
- package/dist/client/assets/{use-connection-ChcOtrff.js → use-connection-D6QJlUO9.js} +1 -1
- package/dist/client/assets/{use-copy-m0n_RO3C.js → use-copy-BHjujE3w.js} +1 -1
- package/dist/client/assets/{use-create-virtual-mcp-YEubcOB4.js → use-create-virtual-mcp-BxdAiHU1.js} +1 -1
- package/dist/client/assets/{use-debounced-autosave-B2P6o2k5.js → use-debounced-autosave-C7GmOCQZ.js} +1 -1
- package/dist/client/assets/{use-decopilot-events-2TQ7wYAd.js → use-decopilot-events-DQouP0Xf.js} +1 -1
- package/dist/client/assets/{use-delete-connection-D5bnzRUU.js → use-delete-connection-1o_zv9iJ.js} +1 -1
- package/dist/client/assets/{use-infinite-scroll-3bbSny2Z.js → use-infinite-scroll-CBiQU4Ab.js} +1 -1
- package/dist/client/assets/{use-list-state-wMdeexdh.js → use-list-state-COPr6pvf.js} +1 -1
- package/dist/client/assets/{use-mcp-tools-BcOc7oDE.js → use-mcp-tools-DD1IUYEC.js} +1 -1
- package/dist/client/assets/{use-members-BNZ3ZVzn.js → use-members-uqCUADFs.js} +1 -1
- package/dist/client/assets/{use-navigate-to-agent-BpE3mIlu.js → use-navigate-to-agent-DtcXsTmt.js} +1 -1
- package/dist/client/assets/{use-org-auth-client-C94Cx1kj.js → use-org-auth-client-lzEa1Nt5.js} +1 -1
- package/dist/client/assets/{use-org-sso-V0U-retN.js → use-org-sso-XYdJdNGD.js} +1 -1
- package/dist/client/assets/{use-organization-roles-Byz74Exs.js → use-organization-roles-DaSsDuIz.js} +1 -1
- package/dist/client/assets/{use-organization-settings-Crj_HvGT.js → use-organization-settings-DZQEi_vL.js} +1 -1
- package/dist/client/assets/{use-registry-connections-BLE97Xkr.js → use-registry-connections-BgfsM9PL.js} +1 -1
- package/dist/client/assets/{use-status-sounds-BFxmOR4f.js → use-status-sounds-BnOGH79m.js} +1 -1
- package/dist/client/assets/{use-tasks-B1IA46S1.js → use-tasks-CP9EEDgQ.js} +1 -1
- package/dist/client/assets/{use-view-mode-DmgZ_4mP.js → use-view-mode-DBMTYwcB.js} +1 -1
- package/dist/client/assets/{use-virtual-mcp-DbNBWdfU.js → use-virtual-mcp-BNrt8cOn.js} +1 -1
- package/dist/client/assets/useInfiniteQuery-m6hlUQnd.js +1 -0
- package/dist/client/assets/useSuspenseInfiniteQuery-BbuXOIpQ.js +1 -0
- package/dist/client/assets/{user-BnqvTrf4.js → user-O4Eqd0DY.js} +1 -1
- package/dist/client/assets/{view-mode-toggle-CwkAkApt.js → view-mode-toggle-BDOZY65E.js} +1 -1
- package/dist/client/assets/{workflow-R3hZyuyQ.js → workflow-BiwnYTIB.js} +1 -1
- package/dist/client/assets/workflow-detail-CHrqPsdS.js +1 -0
- package/dist/client/index.html +1 -1
- package/dist/server/cli.js +2 -2
- package/dist/server/node_modules/ansi-styles/index.d.ts +236 -0
- package/dist/server/node_modules/ansi-styles/index.js +223 -0
- package/dist/server/node_modules/ansi-styles/license +9 -0
- package/dist/server/node_modules/ansi-styles/package.json +54 -0
- package/dist/server/node_modules/ansi-styles/readme.md +173 -0
- package/dist/server/node_modules/postgres-array/index.d.ts +4 -0
- package/dist/server/node_modules/postgres-array/index.js +97 -0
- package/dist/server/node_modules/postgres-array/license +21 -0
- package/dist/server/node_modules/postgres-array/package.json +35 -0
- package/dist/server/node_modules/postgres-array/readme.md +43 -0
- package/dist/server/node_modules/postgres-bytea/index.js +33 -0
- package/dist/server/node_modules/postgres-bytea/license +21 -0
- package/dist/server/node_modules/postgres-bytea/package.json +34 -0
- package/dist/server/node_modules/postgres-bytea/readme.md +34 -0
- package/dist/server/node_modules/postgres-interval/index.d.ts +20 -0
- package/dist/server/node_modules/postgres-interval/index.js +125 -0
- package/dist/server/node_modules/postgres-interval/license +21 -0
- package/dist/server/node_modules/postgres-interval/package.json +36 -0
- package/dist/server/node_modules/postgres-interval/readme.md +48 -0
- package/dist/server/node_modules/split2/LICENSE +13 -0
- package/dist/server/node_modules/split2/README.md +85 -0
- package/dist/server/node_modules/split2/bench.js +27 -0
- package/dist/server/node_modules/split2/index.js +141 -0
- package/dist/server/node_modules/split2/package.json +39 -0
- package/dist/server/node_modules/split2/test.js +409 -0
- package/dist/server/server.js +1 -1
- package/package.json +1 -1
- package/dist/client/assets/ai-providers-DJCkxeza.js +0 -1
- package/dist/client/assets/index-C3jp8V-r.js +0 -1
- package/dist/client/assets/registry-BsIc5aMc.js +0 -2
- package/dist/client/assets/store-registry-ofreyRMo.js +0 -2
- package/dist/client/assets/useInfiniteQuery-CkLPMOdO.js +0 -1
- package/dist/client/assets/useSuspenseInfiniteQuery-3g8exEkj.js +0 -1
- package/dist/client/assets/workflow-detail-BJ1tXzcM.js +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/project-app-view-
|
|
2
|
-
import{o as ds,r as P,p as Ml,q as Il,e as H,s as ve,K as Bs,n as Uo,a as Vo,c as re,j as o,l as Ie,B as oe,E as Ht,b as Ci,v as oi,f as Bt,d as Jr,w as Al,x as pe,y as Bl,V as Pl,t as ye,z as Ko,C as Ll,D as $t,F as Ol,G as xn,L as zl,H as Li,I as Zs,J as ht,M as qo,P as $l,_ as Fl,Q as Go,R as Yo,T as Hl,g as Wl}from"./index-D9n-W_rO.js";import{C as je,u as Ul,w as Vl,A as Kl,T as ql,a as Gl}from"./index-BxSEc3iB.js";import{I as us}from"./integration-icon-CNrz8Wxa.js";import{S as Pt,u as He,g as Xo,a as Jo}from"./constants-BBSLGS7p.js";import{u as Ct,a as Yl}from"./use-virtual-mcp-DbNBWdfU.js";import{a as Xl}from"./Users03-BbIOB2XC.js";import{u as Zo,a as vt,b as Zr,c as fs,t as Jl,d as bn}from"./chat-context-BOGVHhEC.js";import{i as Ps}from"./AlertCircle-ri2xuBKe.js";import{i as Zl}from"./CheckCircle-D7N7MOmw.js";import{n as Sn,a as Ql}from"./ZapSquare-BOPwjpzz.js";import{i as ec,a as tc,b as sc,c as ki,d as ic}from"./XCircle-BLtaN_6O.js";import{s as ls,i as rc}from"./XClose-Bk1D4OG4.js";import{c as nc,r as oc,p as Qo,f as yn,a as ac,F as lc,t as wn,M as Qr,G as ea,L as cc,i as hc,b as dc,d as uc,e as fc}from"./pair-DST-dVfc.js";import{C as mc,a as Cn,b as kn,c as _c,d as pc,e as gc,f as vc}from"./command-Cb8AzRR0.js";import{P as Ws,a as Us,b as Vs}from"./popover-DFJMwPZz.js";import{i as Rs,a as pi,b as xc,c as bc,p as Ni,g as ji,d as en,e as ta,h as cr,f as Oi,j as Nn,A as jn,k as sa,l as Sc,m as yc,n as wc,t as Cc,o as kc,q as ai,r as ia,s as ra,u as na,v as En,w as Nc,x as Ds,y as jc,z as Ec,B as oa}from"./agent-icon-6IsHLhhx.js";import{u as ms,a as Tc}from"./use-mcp-tools-BcOc7oDE.js";import{u as Rc,a as Dc}from"./use-ai-providers-B5bMFCmc.js";import{g as Kt,c as Tn,u as Mc,b as hr,d as Ic,e as Ac,f as Bc,T as Pc}from"./index-k1BGw4YF.js";import{u as Ei,i as Lc}from"./shell-layout-DDd0qO09.js";import{i as Oc,P as ct,u as zc,c as $c,d as Fc,e as Hc}from"./index-CMnREwkX.js";import{u as aa,T as Ke,a as qe,b as Ge,c as Wc}from"./tooltip-D3G-75TX.js";import{u as Uc}from"./use-status-sounds-BFxmOR4f.js";import{E as Ls}from"./empty-state-Dk0gx8oo.js";import{A as Vc,a as Kc,b as qc,c as Gc,R as la,d as Yc,e as Xc}from"./accordion-Cp5pOFIt.js";import{u as Ti,a as tn,b as Jc}from"./use-connection-ChcOtrff.js";import{g as Zc}from"./constants-hjtpWhr_.js";import{u as Qc,g as eh}from"./types-iEh-ujpY.js";import{u as ca,G as th}from"./lean-canvas-recruit-modal-mlOx896G.js";import{U as ha}from"./user-BnqvTrf4.js";import{T as sh,u as da}from"./tools-list-C9TFhRWw.js";import{u as ih}from"./unwrap-tool-result-BYXdCQMg.js";import{s as ua,g as rh}from"./connection-slug-eyAPH6o3.js";import{A as fa,a as ma,b as _a,c as pa,d as ga,e as va,f as xa,g as ba}from"./alert-dialog-D-vKhXAM.js";import{D as nh,a as sn,b as rn,c as Sa,d as ya}from"./dialog-CICi1bFC.js";import{C as oh,a as Rn}from"./card-CMatfPs6.js";import{I as _s}from"./input-Aj2AxbJX.js";import{L as Ms}from"./label-CuWuUZ3O.js";import{S as ts,a as ss,b as is,c as rs,d as At}from"./select-DWMsyC47.js";import{S as dr}from"./switch-D664sdCn.js";import{T as Dn}from"./textarea-B5ocquNh.js";import{i as li}from"./Play-D4xI5B_i.js";import{s as cs}from"./Plus-CDEOyPu8.js";import{a as ah}from"./Settings02-3HEuuiVe.js";import{t as wa,i as lh}from"./Tool01-DMFP0Svb.js";import{s as ur}from"./Trash01-Dj5mVOWm.js";import{u as Ca}from"./use-debounced-autosave-B2P6o2k5.js";import{S as ka}from"./scroll-area-D7xTqtD-.js";import{i as Na,a as ch}from"./SearchMd-6IRfjRcX.js";import{C as hh}from"./collection-tabs-3zydPpJg.js";import{C as dh}from"./checkbox-DgRshC0u.js";import{u as uh,T as zi,a as fh,b as mh,c as $i}from"./tabs-Bakk2hgc.js";import{D as _h,a as ph,b as gh}from"./drawer-CAsvHZha.js";import{i as Ri}from"./Check-C6Fa8-x7.js";import{n as qt}from"./LinkExternal01-Dvpxn-Ig.js";import{S as vh}from"./index-C_78kpYQ.js";import{D as ns,a as os,b as as,c as wt,d as xh,e as bh,f as Sh}from"./dropdown-menu-DVFKsYz3.js";import{t as fr}from"./ChevronDown-DmrzaACF.js";import{i as ja}from"./RefreshCcw01-B2ZHRQzo.js";import{V as yh}from"./view-mode-toggle-CwkAkApt.js";import{M as wh}from"./select-model-p3PkjF3m.js";import{u as Ks,a as Ch,b as kh,c as Nh,A as jh,d as Eh}from"./automation-list-row-DXQ1xbHt.js";import{i as Os}from"./Zap-Ctp20y2W.js";import{S as Th}from"./search-input-BYHjVlDa.js";import"./use-navigate-to-agent-BpE3mIlu.js";import"./use-tasks-B1IA46S1.js";import"./use-collections-D6rFCbFs.js";import"./collection-search-CLwC-feE.js";import"./form-bUi5oN1u.js";import"./Star01-BSZxz5Wn.js";import"./Lock01-63SpB195.js";import"./X-yKx8T0mV.js";import"./toggle-group-CdL7Wi0S.js";import"./index-PFIdYUp0.js";import"./question-004-sINsf4GQ.js";import"./ai-providers-logos-DD3qZ33J.js";import"./connection-card-CN5pQMAi.js";import"./use-registry-connections-BLE97Xkr.js";import"./use-organization-settings-Crj_HvGT.js";import"./useInfiniteQuery-CkLPMOdO.js";import"./infiniteQueryObserver-DnwZzogs.js";import"./extract-connection-data-CvD7TUFj.js";import"./Container-BXYDPrF5.js";import"./connection-form-helpers-0uGtdPq8.js";import"./use-infinite-scroll-3bbSny2Z.js";import"./useSuspenseInfiniteQuery-3g8exEkj.js";import"./badge-v1Fnh_-2.js";import"./ChevronRight-CZ_XAq5W.js";import"./use-decopilot-events-2TQ7wYAd.js";import"./create-sse-subscription-CxkOgzKf.js";import"./use-copy-m0n_RO3C.js";import"./differenceInSeconds-NQ4PDo0z.js";import"./content-blocks-o63cs2vh.js";import"./Sun-DdqVKeEA.js";import"./index-CKbPmli4.js";import"./ArrowNarrowLeft-yxFeL5-Q.js";import"./ArrowUpRight-Bxgj2IVp.js";import"./ChevronUp-Ds9ufeJd.js";import"./DotsVertical-CYFsY1AY.js";import"./Palette-D0iAFXNq.js";import"./Shield01-BGj8uiOU.js";import"./User01-CDDY3fE9.js";import"./skeleton-fTv1xeu9.js";import"./avatar-DiYo_VFp.js";import"./index-B7e3gTna.js";import"./collection-search-Dsu0rnLF.js";import"./use-create-virtual-mcp-YEubcOB4.js";import"./task-status-B1waCh_f.js";import"./required-auth-layout-BRdLiCQS.js";import"./use-org-sso-V0U-retN.js";import"./collections-DIZVbUQW.js";import"./settings-section-DLmXqm7P.js";import"./formatDistanceToNow-Cb2QZZJn.js";function Rh(t,e){const s=ds(e);return Dh({filters:{...t,status:"pending"}},s).length}function Mn(t,e){return t.findAll(e.filters).map(s=>e.select?e.select(s):s.state)}function Dh(t={},e){const s=ds(e).getMutationCache(),i=P.useRef(t),r=P.useRef(null);return r.current===null&&(r.current=Mn(s,t)),P.useEffect(()=>{i.current=t}),P.useSyncExternalStore(P.useCallback(n=>s.subscribe(()=>{const a=Ml(r.current,Mn(s,i.current));r.current!==a&&(r.current=a,Il.schedule(n))}),[s]),()=>r.current,()=>r.current)}function Mh(t,e){const s=H.c(40),{org:i,locator:r}=ve();let n;s[0]!==i.id||s[1]!==i.slug?(n={connectionId:Pt,orgId:i.id,orgSlug:i.slug},s[0]=i.id,s[1]=i.slug,s[2]=n):n=s[2];const a=He(n),l=ds();let h;s[3]!==t||s[4]!==i.id?(h=Bs.ensureTask(i.id,t),s[3]=t,s[4]=i.id,s[5]=h):h=s[5];let c;s[6]!==a||s[7]!==t?(c=async()=>(await a.callTool({name:"COLLECTION_THREADS_GET",arguments:{id:t}})).structuredContent?.item??null,s[6]=a,s[7]=t,s[8]=c):c=s[8];const u=t.length>0;let d;s[9]!==h||s[10]!==c||s[11]!==u?(d={queryKey:h,queryFn:c,enabled:u,retry:!1,refetchOnWindowFocus:!1},s[9]=h,s[10]=c,s[11]=u,s[12]=d):d=s[12];const f=Uo(d);let _;s[13]!==a||s[14]!==e?(_=async x=>{const y=await a.callTool({name:"COLLECTION_THREADS_CREATE",arguments:{data:{id:x,virtual_mcp_id:e}}});if(y.isError){const C=y.content,T=Array.isArray(C)&&C[0]&&typeof C[0]=="object"?C[0].text??"Create failed":"Create failed";throw new Error(T)}return y.structuredContent.item},s[13]=a,s[14]=e,s[15]=_):_=s[15];let m;s[16]!==r||s[17]!==i.id||s[18]!==f||s[19]!==l?(m=()=>{l.invalidateQueries({predicate:x=>x.queryKey[1]===i.id&&x.queryKey[3]==="collection"&&x.queryKey[4]==="THREADS"}),l.invalidateQueries({queryKey:Bs.tasksPrefix(r)}),f.refetch()},s[16]=r,s[17]=i.id,s[18]=f,s[19]=l,s[20]=m):m=s[20];let p;s[21]!==_||s[22]!==m?(p={mutationFn:_,onSuccess:m},s[21]=_,s[22]=m,s[23]=p):p=s[23];const g=Vo(p);let v,b;if(s[24]!==g||s[25]!==t||s[26]!==f.data||s[27]!==f.isSuccess?(v=()=>{t&&(!f.isSuccess||f.data||g.isPending||g.variables!==t&&g.mutate(t))},b=[t,f.isSuccess,f.data,g],s[24]=g,s[25]=t,s[26]=f.data,s[27]=f.isSuccess,s[28]=v,s[29]=b):(v=s[28],b=s[29]),P.useEffect(v,b),!t){let x;return s[30]===Symbol.for("react.memo_cache_sentinel")?(x={status:"ready",task:null},s[30]=x):x=s[30],x}if(f.isLoading){let x;return s[31]===Symbol.for("react.memo_cache_sentinel")?(x={status:"loading"},s[31]=x):x=s[31],x}if(f.isError){const x=f.error;let y;return s[32]!==x?(y={status:"error",error:x},s[32]=x,s[33]=y):y=s[33],y}if(f.isSuccess&&f.data){let x;return s[34]!==f.data?(x={status:"ready",task:f.data},s[34]=f.data,s[35]=x):x=s[35],x}if(g.isPending||f.isSuccess&&!f.data){let x;return s[36]===Symbol.for("react.memo_cache_sentinel")?(x={status:"creating"},s[36]=x):x=s[36],x}if(g.isError){let x;return s[37]!==g.error?(x={status:"error",error:g.error},s[37]=g.error,s[38]=x):x=s[38],x}let S;return s[39]===Symbol.for("react.memo_cache_sentinel")?(S={status:"loading"},s[39]=S):S=s[39],S}function vs(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}k`:String(t)}function In(t){if(!t)return"—";const e=typeof t=="string"?new Date(t):t;return isNaN(e.getTime())?"—":e.toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"})}function Ih(t){return t?t.replace(/-\d{8}(?:-[a-z0-9]+)*$/i,"").replace(/-/g," "):"—"}function Ah(t){const e=H.c(4),{items:s}=t;let i;e[0]!==s?(i=s.map(Bh),e[0]=s,e[1]=i):i=e[1];let r;return e[2]!==i?(r=o.jsx("div",{className:"grid grid-cols-2 gap-x-8 gap-y-6",children:i}),e[2]=i,e[3]=r):r=e[3],r}function Bh(t){return o.jsxs("div",{className:"flex flex-col gap-1 min-w-0",children:[o.jsx("span",{className:"text-xs text-muted-foreground truncate",children:t.label}),o.jsx("span",{className:"text-sm text-foreground tabular-nums truncate",children:t.value})]},t.label)}function Ph(t){const e=H.c(30),{userTokens:s,assistantTokens:i,otherTokens:r}=t,n=s+i+r,a=n>0?s/n*100:0,l=n>0?i/n*100:0,h=n>0?r/n*100:0;let c;e[0]!==a?(c=a>0&&o.jsx("div",{className:"h-full bg-chart-1",style:{width:`${a}%`}}),e[0]=a,e[1]=c):c=e[1];let u;e[2]!==l?(u=l>0&&o.jsx("div",{className:"h-full bg-chart-2",style:{width:`${l}%`}}),e[2]=l,e[3]=u):u=e[3];let d;e[4]!==h?(d=h>0&&o.jsx("div",{className:"h-full bg-muted-foreground/30",style:{width:`${h}%`}}),e[4]=h,e[5]=d):d=e[5];let f;e[6]!==c||e[7]!==u||e[8]!==d?(f=o.jsxs("div",{className:"flex h-2 w-full overflow-hidden rounded-full bg-muted",children:[c,u,d]}),e[6]=c,e[7]=u,e[8]=d,e[9]=f):f=e[9];let _;e[10]===Symbol.for("react.memo_cache_sentinel")?(_=o.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-chart-1 shrink-0"}),e[10]=_):_=e[10];let m;e[11]!==a?(m=a.toFixed(1),e[11]=a,e[12]=m):m=e[12];let p;e[13]!==m?(p=o.jsxs("div",{className:"flex items-center gap-1.5",children:[_,o.jsxs("span",{className:"text-xs text-muted-foreground",children:["User ",m,"%"]})]}),e[13]=m,e[14]=p):p=e[14];let g;e[15]===Symbol.for("react.memo_cache_sentinel")?(g=o.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-chart-2 shrink-0"}),e[15]=g):g=e[15];let v;e[16]!==l?(v=l.toFixed(1),e[16]=l,e[17]=v):v=e[17];let b;e[18]!==v?(b=o.jsxs("div",{className:"flex items-center gap-1.5",children:[g,o.jsxs("span",{className:"text-xs text-muted-foreground",children:["Assistant ",v,"%"]})]}),e[18]=v,e[19]=b):b=e[19];let S;e[20]!==h||e[21]!==r?(S=r>0&&o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-muted-foreground/30 shrink-0"}),o.jsxs("span",{className:"text-xs text-muted-foreground",children:["Other ",h.toFixed(1),"%"]})]}),e[20]=h,e[21]=r,e[22]=S):S=e[22];let x;e[23]!==b||e[24]!==S||e[25]!==p?(x=o.jsxs("div",{className:"flex flex-wrap gap-x-3 gap-y-1",children:[p,b,S]}),e[23]=b,e[24]=S,e[25]=p,e[26]=x):x=e[26];let y;return e[27]!==x||e[28]!==f?(y=o.jsxs("div",{className:"flex flex-col gap-2",children:[f,x]}),e[27]=x,e[28]=f,e[29]=y):y=e[29],y}function Lh(t){const e=H.c(19),{part:s}=t,i=s.input?.agent_id,r=Ct(i),n=r?.title??"Subtask",a=r?.icon??null,l=s.state==="input-streaming"||s.state==="input-available"||s.state==="output-available"&&s.preliminary===!0,h=s.state==="output-error",c=s.state==="approval-requested";let u;e[0]!==a||e[1]!==n?(u=o.jsx(us,{icon:a,name:n,size:"xs",className:"size-6 rounded-md shrink-0"}),e[0]=a,e[1]=n,e[2]=u):u=e[2];const d=h?"text-destructive":"text-foreground";let f;e[3]!==d?(f=re("shrink-0 font-medium",d),e[3]=d,e[4]=f):f=e[4];let _;e[5]!==n||e[6]!==f?(_=o.jsx("span",{className:f,children:n}),e[5]=n,e[6]=f,e[7]=_):_=e[7];let m;e[8]!==s.input?(m=s.input?.prompt&&o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"text-muted-foreground/50",children:"·"}),o.jsx("span",{className:"truncate text-muted-foreground",children:s.input.prompt})]}),e[8]=s.input,e[9]=m):m=e[9];let p;e[10]!==c||e[11]!==h||e[12]!==l?(p=o.jsx("span",{className:"ml-auto shrink-0",children:l?o.jsx(Ie,{size:12,className:"animate-spin text-muted-foreground"}):h?o.jsx(ec,{size:12,className:"text-destructive"}):c?o.jsx(Ps,{size:12,className:"text-warning"}):o.jsx(Zl,{size:12,className:"text-emerald-500"})}),e[10]=c,e[11]=h,e[12]=l,e[13]=p):p=e[13];let g;return e[14]!==u||e[15]!==_||e[16]!==m||e[17]!==p?(g=o.jsxs("div",{className:"flex items-center gap-2 text-xs min-w-0",children:[u,_,m,p]}),e[14]=u,e[15]=_,e[16]=m,e[17]=p,e[18]=g):g=e[18],g}function Oh(t){const e=H.c(58),{onClose:s,back:i,className:r}=t,[n,a]=P.useState(null),{messages:l}=Zo(),{tasks:h,taskId:c}=vt(),{selectedModel:u,selectedVirtualMcp:d}=Zr();let f,_,m,p,g,v,b,S;if(e[0]!==i||e[1]!==r||e[2]!==l||e[3]!==s||e[4]!==n?.id||e[5]!==u||e[6]!==d?.title||e[7]!==c||e[8]!==h){S=Symbol.for("react.early_return_sentinel");e:{let j;e[17]!==c?(j=Y=>Y.id===c,e[17]=c,e[18]=j):j=e[18];const C=h.find(j),T=nc(l),E=[...l].reverse().find(Yh),M=E?.metadata?.usage,A=E?.metadata?.modelLimits?.contextWindow??u?.limits?.contextWindow??null,I=M?.contextTokens??M?.totalTokens??0,k=A&&A>0?(I/A*100).toFixed(1):null,w=l;let N;e[19]!==w?(N=w.filter(Gh).reduce(qh,0),e[19]=w,e[20]=N):N=e[20];const R=N,D=l;let B;e[21]!==D?(B=D.filter(Kh).reduce(Vh,0),e[21]=D,e[22]=B):B=e[22];const z=B,G=Math.max(0,T.totalTokens-R-z),W=l[0],F=l.at(-1),Z=W?.metadata?.created_at??C?.created_at,q=F?.metadata?.created_at??C?.updated_at,$=l.filter(Uh),U=l.flatMap(Hh),V=u?.modelId?Ih(u.modelId):"—",se=d?.title??"Decopilot",L=[{label:"Session",value:C?.title??"New chat"},{label:"Messages",value:$.length},{label:"Agent",value:se},{label:"Model",value:V},{label:"Context Limit",value:A?vs(A):"—"},{label:"Session Tokens (billed)",value:T.totalTokens>0?vs(T.totalTokens):"0"},{label:"Usage",value:k!==null?`${k}%`:"—"},{label:"Input Tokens",value:T.inputTokens>0?vs(T.inputTokens):"0"},{label:"Output Tokens",value:T.outputTokens>0?vs(T.outputTokens):"0"},{label:"Reasoning Tokens",value:T.reasoningTokens>0?vs(T.reasoningTokens):"0"},{label:"Cost",value:T.cost>0?`$${T.cost<.001?T.cost.toFixed(6):T.cost.toFixed(4)}`:"$0.00"},{label:"Session Created",value:In(Z)},{label:"Last Activity",value:In(q)}];if(!C&&$.length===0){let Y;e[23]!==r?(Y=re("flex flex-col h-full w-full border-l border-border bg-background",r),e[23]=r,e[24]=Y):Y=e[24];let le;e[25]===Symbol.for("react.memo_cache_sentinel")?(le=o.jsx("span",{className:"text-sm font-medium text-foreground",children:"Context"}),e[25]=le):le=e[25];let ue;e[26]!==i?(ue=i?o.jsx(Sn,{size:14,className:"text-muted-foreground"}):o.jsx(ls,{size:14,className:"text-muted-foreground"}),e[26]=i,e[27]=ue):ue=e[27];let de;e[28]!==s||e[29]!==ue?(de=o.jsxs("div",{className:"h-11 px-4 flex items-center justify-between shrink-0 border-b border-border/50",children:[le,o.jsx("button",{type:"button",onClick:s,className:"flex size-6 items-center justify-center rounded hover:bg-accent transition-colors",children:ue})]}),e[28]=s,e[29]=ue,e[30]=de):de=e[30];let fe;e[31]===Symbol.for("react.memo_cache_sentinel")?(fe=o.jsx("div",{className:"flex-1 flex items-center justify-center px-4 text-center",children:o.jsx("p",{className:"text-xs text-muted-foreground",children:"Start a conversation to see context"})}),e[31]=fe):fe=e[31];let _e;e[32]!==Y||e[33]!==de?(_e=o.jsxs("div",{className:Y,children:[de,fe]}),e[32]=Y,e[33]=de,e[34]=_e):_e=e[34],S=_e;break e}e[35]!==r?(v=re("flex flex-col h-full w-full border-l border-border bg-background overflow-y-auto",r),e[35]=r,e[36]=v):v=e[36];let te;e[37]===Symbol.for("react.memo_cache_sentinel")?(te=o.jsx("span",{className:"text-sm font-medium text-foreground",children:"Context"}),e[37]=te):te=e[37];let ie;e[38]!==i?(ie=i?o.jsx(Sn,{size:14}):o.jsx(ls,{size:14}),e[38]=i,e[39]=ie):ie=e[39],e[40]!==s||e[41]!==ie?(b=o.jsxs("div",{className:"flex h-11 shrink-0 items-center justify-between border-b border-border/50 px-4",children:[te,o.jsx("button",{type:"button",onClick:s,className:"flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",children:ie})]}),e[40]=s,e[41]=ie,e[42]=b):b=e[42],f="flex flex-col gap-8 p-6",_=U.length>0&&o.jsxs("div",{className:"flex flex-col gap-3",children:[o.jsx("span",{className:"text-xs text-muted-foreground",children:"Subtasks"}),o.jsx("div",{className:"flex flex-col gap-1",children:U.map(Fh)})]}),m=o.jsx(Ah,{items:L});let ee;e[43]===Symbol.for("react.memo_cache_sentinel")?(ee=o.jsx("span",{className:"text-xs text-muted-foreground",children:"Context Breakdown"}),e[43]=ee):ee=e[43],e[44]!==z||e[45]!==G||e[46]!==R?(p=o.jsxs("div",{className:"flex flex-col gap-3",children:[ee,o.jsx(Ph,{userTokens:R,assistantTokens:z,otherTokens:G})]}),e[44]=z,e[45]=G,e[46]=R,e[47]=p):p=e[47],g=$.length>0&&o.jsxs("div",{className:"flex flex-col gap-3",children:[o.jsx("span",{className:"text-xs text-muted-foreground",children:"Raw messages"}),o.jsx("div",{className:"flex flex-col gap-1",children:$.map(Y=>{const le=Y.metadata?.created_at,ue=n?.id===Y.id;return o.jsxs("div",{className:"rounded-md border border-border/50 overflow-hidden",children:[o.jsxs("button",{type:"button",onClick:()=>a(ue?null:Y),className:"flex items-center justify-between gap-2 px-3 py-2 text-xs hover:bg-accent/50 w-full text-left cursor-pointer",children:[o.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[o.jsx("span",{className:re("shrink-0 font-medium",Y.role==="user"?"text-chart-1":"text-chart-2"),children:Y.role}),o.jsx("span",{className:"text-muted-foreground",children:"•"}),o.jsx("span",{className:"truncate text-muted-foreground font-mono",children:Y.id})]}),le&&o.jsx("span",{className:"shrink-0 text-muted-foreground tabular-nums",children:new Date(le).toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"})})]}),ue&&o.jsxs(o.Fragment,{children:[Y.role==="assistant"&&(()=>{const de=Y.metadata?._request;if(!de)return null;const fe=de.systemSections??[],_e=Math.max(1,...fe.map($h)),Ue=fe.reduce(zh,0);return o.jsxs("div",{className:"border-t border-border/50 px-3 py-2.5 text-xs space-y-2.5",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"font-medium text-foreground",children:"Request"}),o.jsxs("span",{className:"text-muted-foreground tabular-nums",children:[de.activeTools??0," / ",de.tools??0," ","tools active"]})]}),fe.length>0&&o.jsxs("div",{className:"space-y-1.5",children:[o.jsxs("div",{className:"text-muted-foreground",children:["System prompt"," ",o.jsxs("span",{className:"tabular-nums",children:["~",Math.round(Ue/4).toLocaleString()," ","tok"]})]}),fe.map(($e,Qe)=>{const at=$e.preview.match(/^<([a-z-]+)/i)?.[1]??`section ${Qe}`,Q=$e.chars/_e*100,Ne=Math.round($e.chars/4);return o.jsxs("div",{className:"space-y-0.5",children:[o.jsxs("div",{className:"flex items-center justify-between gap-2",children:[o.jsx("span",{className:"font-mono text-foreground truncate",children:at}),o.jsxs("span",{className:"text-muted-foreground tabular-nums shrink-0",children:["~",Ne.toLocaleString()," tok"]})]}),o.jsx("div",{className:"h-1 w-full rounded-full bg-muted overflow-hidden",children:o.jsx("div",{className:"h-full rounded-full bg-chart-3",style:{width:`${Q}%`}})})]},Qe)})]})]})})(),o.jsx("pre",{className:"text-xs font-mono bg-muted px-3 py-2 overflow-auto whitespace-pre-wrap break-all border-t border-border/50 max-h-64",children:JSON.stringify(Y,null,2)})]})]},Y.id)})})]})}e[0]=i,e[1]=r,e[2]=l,e[3]=s,e[4]=n?.id,e[5]=u,e[6]=d?.title,e[7]=c,e[8]=h,e[9]=f,e[10]=_,e[11]=m,e[12]=p,e[13]=g,e[14]=v,e[15]=b,e[16]=S}else f=e[9],_=e[10],m=e[11],p=e[12],g=e[13],v=e[14],b=e[15],S=e[16];if(S!==Symbol.for("react.early_return_sentinel"))return S;let x;e[48]!==f||e[49]!==_||e[50]!==m||e[51]!==p||e[52]!==g?(x=o.jsxs("div",{className:f,children:[_,m,p,g]}),e[48]=f,e[49]=_,e[50]=m,e[51]=p,e[52]=g,e[53]=x):x=e[53];let y;return e[54]!==v||e[55]!==b||e[56]!==x?(y=o.jsxs("div",{className:v,children:[b,x]}),e[54]=v,e[55]=b,e[56]=x,e[57]=y):y=e[57],y}function zh(t,e){return t+e.chars}function $h(t){return t.chars}function Fh(t,e){return o.jsx(Lh,{part:t},e)}function Hh(t){return(t.parts??[]).filter(Wh)}function Wh(t){return t.type==="tool-subtask"}function Uh(t){return t.role!=="system"}function Vh(t,e){const s=e.metadata?.usage;return t+(s?.outputTokens??0)}function Kh(t){return t.role==="assistant"}function qh(t,e){const s=e.metadata?.usage;return t+(s?.inputTokens??0)}function Gh(t){return t.role==="user"}function Yh(t){return t.role==="assistant"&&t.metadata?.usage}const An=["amber","bold","bright","calm","crimson","coral","daring","deep","dusty","eager","faint","fierce","frozen","gentle","golden","grand","green","hollow","iron","ivory","keen","lasting","lunar","mellow","misty","noble","olive","pale","prime","quiet","rapid","rustic","serene","sharp","silver","sleek","solar","stark","still","swift","tawny","tender","thin","true","vast","velvet","warm","wild","young","zen"],Bn=["anchor","birch","brook","cedar","cliff","cove","crane","dune","echo","ember","falcon","fern","flint","forge","frost","glade","grove","harbor","hawk","iris","jade","lark","maple","marsh","mesa","opal","orbit","peak","pine","plume","quartz","rapids","reef","ridge","river","sage","shore","slate","spruce","stone","summit","thorn","tide","trail","vale","wren","aspen","delta","crest","spark"];function Xh(){const t=An[Math.floor(Math.random()*An.length)],e=Bn[Math.floor(Math.random()*Bn.length)];return`deco/${t}-${e}`}function Jh(t){const e=t;if(e.structuredContent)return e.structuredContent;const s=e.content?.find(i=>i.type==="text")?.text;if(s)try{return JSON.parse(s)}catch{return[]}return[]}function Zh(t){const e=H.c(26),{orgId:s,orgSlug:i,userId:r,connectionId:n,vmMap:a,owner:l,repo:h,enabled:c}=t,u=c===void 0?!0:c,d=n??null;let f;e[0]!==s||e[1]!==i||e[2]!==d?(f={connectionId:d,orgId:s,orgSlug:i},e[0]=s,e[1]=i,e[2]=d,e[3]=f):f=e[3];const _=He(f);let m;e[4]!==l||e[5]!==h?(m={owner:l,repo:h},e[4]=l,e[5]=h,e[6]=m):m=e[6];const p=u&&!!n&&!!l&&!!h;let g;e[7]!==_||e[8]!==m||e[9]!==p?(g={client:_,toolName:"list_branches",toolArguments:m,enabled:p,staleTime:3e4,select:sd},e[7]=_,e[8]=m,e[9]=p,e[10]=g):g=e[10];const{data:v,isLoading:b,isError:S}=ms(g);let x,y;e[11]!==r||e[12]!==a?(y=new Set(Object.keys(a?.[r]??{})),x=[...y].sort().map(td),e[11]=r,e[12]=a,e[13]=x,e[14]=y):(x=e[13],y=e[14]);const j=x;let C;if(e[15]!==v||e[16]!==y){const A=Array.isArray(v)?v:v?.branches??[];let I;e[18]!==y?(I=k=>!y.has(k.name),e[18]=y,e[19]=I):I=e[19],C=A.filter(ed).filter(I).map(Qh),e[15]=v,e[16]=y,e[17]=C}else C=e[17];const T=C,E=Array.isArray(v)?null:v?.default_branch??null;let M;return e[20]!==E||e[21]!==S||e[22]!==b||e[23]!==T||e[24]!==j?(M={yours:j,others:T,defaultBase:E,isLoading:b,isError:S},e[20]=E,e[21]=S,e[22]=b,e[23]=T,e[24]=j,e[25]=M):M=e[25],M}function Qh(t){return{name:t.name,source:"other",author:typeof t.commit?.author=="string"?t.commit.author:t.commit?.author?.login??null}}function ed(t){return typeof t.name=="string"}function td(t){return{name:t,source:"yours"}}function sd(t){return Jh(t)}function id(t){const e=H.c(42),{orgId:s,orgSlug:i,userId:r,connectionId:n,owner:a,repo:l,vmMap:h,value:c,onChange:u}=t,[d,f]=P.useState(!1);let _;e[0]!==n||e[1]!==d||e[2]!==s||e[3]!==i||e[4]!==a||e[5]!==l||e[6]!==r||e[7]!==h?(_={orgId:s,orgSlug:i,userId:r,connectionId:n,vmMap:h,owner:a,repo:l,enabled:d},e[0]=n,e[1]=d,e[2]=s,e[3]=i,e[4]=a,e[5]=l,e[6]=r,e[7]=h,e[8]=_):_=e[8];const{yours:m,others:p,isLoading:g,isError:v}=Zh(_);let b;e[9]!==u?(b=R=>{u(R),f(!1)},e[9]=u,e[10]=b):b=e[10];const S=b,x=c??"Select branch…";let y;e[11]===Symbol.for("react.memo_cache_sentinel")?(y=o.jsx(Rs,{className:"h-3.5 w-3.5"}),e[11]=y):y=e[11];let j;e[12]!==x?(j=o.jsx(Ws,{asChild:!0,children:o.jsxs(oe,{variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 font-mono text-xs",children:[y,o.jsx("span",{className:"max-w-[200px] truncate",children:x})]})}),e[12]=x,e[13]=j):j=e[13];let C;e[14]===Symbol.for("react.memo_cache_sentinel")?(C=o.jsx(pc,{placeholder:"Search branches…"}),e[14]=C):C=e[14];let T;e[15]!==S?(T=o.jsxs("div",{className:"flex items-center border-b pr-2 [&>[data-slot=command-input-wrapper]]:flex-1 [&>[data-slot=command-input-wrapper]]:border-b-0",children:[C,o.jsx(oe,{variant:"outline",size:"sm",className:"h-7 shrink-0",onClick:()=>S(Xh()),children:"New"})]}),e[15]=S,e[16]=T):T=e[16];let E;e[17]!==v?(E=v&&o.jsx("div",{className:"p-3 text-xs text-muted-foreground",children:"Couldn't load branches from GitHub. You can still pick from your branches."}),e[17]=v,e[18]=E):E=e[18];let M;e[19]!==v||e[20]!==g||e[21]!==p.length||e[22]!==m.length?(M=!v&&!g&&m.length===0&&p.length===0&&o.jsx(mc,{children:"No branches found."}),e[19]=v,e[20]=g,e[21]=p.length,e[22]=m.length,e[23]=M):M=e[23];let A;e[24]!==S||e[25]!==m?(A=m.length>0&&o.jsx(Cn,{heading:"Your branches",children:m.map(R=>o.jsxs(kn,{value:R.name,onSelect:()=>S(R.name),children:[o.jsx(Rs,{className:"mr-2 h-4 w-4"}),o.jsx("span",{className:"flex-1 truncate",children:R.name})]},R.name))}),e[24]=S,e[25]=m,e[26]=A):A=e[26];let I;e[27]!==p||e[28]!==S?(I=p.length>0&&o.jsxs(o.Fragment,{children:[o.jsx(_c,{}),o.jsx(Cn,{heading:"Other branches in repo",children:p.map(R=>o.jsxs(kn,{value:R.name,onSelect:()=>S(R.name),children:[o.jsx(Rs,{className:"mr-2 h-4 w-4"}),o.jsx("span",{className:"flex-1 truncate",children:R.name}),R.author&&o.jsxs("span",{className:"text-xs text-muted-foreground",children:["@",R.author]})]},R.name))})]}),e[27]=p,e[28]=S,e[29]=I):I=e[29];let k;e[30]!==I||e[31]!==E||e[32]!==M||e[33]!==A?(k=o.jsxs(gc,{children:[E,M,A,I]}),e[30]=I,e[31]=E,e[32]=M,e[33]=A,e[34]=k):k=e[34];let w;e[35]!==k||e[36]!==T?(w=o.jsx(Us,{className:"w-[min(420px,calc(100vw-2rem))] p-0",align:"start",children:o.jsxs(vc,{children:[T,k]})}),e[35]=k,e[36]=T,e[37]=w):w=e[37];let N;return e[38]!==d||e[39]!==w||e[40]!==j?(N=o.jsxs(Vs,{open:d,onOpenChange:f,children:[j,w]}),e[38]=d,e[39]=w,e[40]=j,e[41]=N):N=e[41],N}function rd(){const t=H.c(27),{org:e}=ve(),{selectedVirtualMcp:s}=Zr(),{data:i}=Ci.useSession(),{currentBranch:r,setCurrentTaskBranch:n}=vt();let a;t[0]!==e.id?(a=Xo(e.id),t[0]=e.id,t[1]=a):a=t[1];const h=s??a,c=Ct(h.id),u=i?.user?.id??"",d=c?.metadata?.githubRepo??null,f=!!d?.connectionId&&!!u;let _;t[2]===Symbol.for("react.memo_cache_sentinel")?(_=o.jsx(Xl,{size:32}),t[2]=_):_=t[2];let m;t[3]!==h.icon||t[4]!==h.title?(m=o.jsx(us,{icon:h.icon,name:h.title,size:"lg",fallbackIcon:_,className:"size-10 min-w-10 md:size-[60px]! md:min-w-[60px] rounded-xl md:rounded-[18px]!"}),t[3]=h.icon,t[4]=h.title,t[5]=m):m=t[5];let p;t[6]!==h.title?(p=o.jsx("h3",{className:"text-base md:text-xl font-medium text-foreground",children:h.title}),t[6]=h.title,t[7]=p):p=t[7];const g=h.description??"Ask anything about configuring model providers or using MCP Mesh.";let v;t[8]!==g?(v=o.jsx("div",{className:"text-muted-foreground text-center text-base max-w-md line-clamp-2",children:g}),t[8]=g,t[9]=v):v=t[9];let b;t[10]!==r||t[11]!==c?.metadata?.vmMap||t[12]!==d||t[13]!==e.id||t[14]!==e.slug||t[15]!==n||t[16]!==f||t[17]!==u?(b=f&&o.jsx("div",{className:"mt-2",children:o.jsx(id,{orgId:e.id,orgSlug:e.slug,userId:u,connectionId:d.connectionId,owner:d.owner,repo:d.name,vmMap:c?.metadata?.vmMap,value:r??void 0,onChange:n})}),t[10]=r,t[11]=c?.metadata?.vmMap,t[12]=d,t[13]=e.id,t[14]=e.slug,t[15]=n,t[16]=f,t[17]=u,t[18]=b):b=t[18];let S;t[19]!==m||t[20]!==p||t[21]!==v||t[22]!==b?(S=o.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 md:gap-4 text-center",children:[m,p,v,b]}),t[19]=m,t[20]=p,t[21]=v,t[22]=b,t[23]=S):S=t[23];let x;t[24]===Symbol.for("react.memo_cache_sentinel")?(x=o.jsx("div",{className:"w-full max-w-3xl mx-auto",children:o.jsx(je.IceBreakers,{})}),t[24]=x):x=t[24];let y;return t[25]!==S?(y=o.jsxs("div",{className:"h-full w-full flex flex-col items-center justify-center gap-6 px-4",children:[S,x]}),t[25]=S,t[26]=y):y=t[26],y}function nd(){const t=H.c(26),{org:e}=ve(),s=Rc(),{isChatEmpty:i}=Zo(),[r,n]=P.useState("chat"),a=Ul();if(s.length===0){let S;return t[0]===Symbol.for("react.memo_cache_sentinel")?(S=o.jsx(je,{className:"animate-in fade-in-0 duration-200",children:o.jsx(je.Main,{className:"flex flex-col items-center",children:o.jsx(je.EmptyState,{children:o.jsx(je.NoAiProviderEmptyState,{})})})}),t[0]=S):S=t[0],S}let l;t[1]!==a.hasDecoKey||t[2]!==a.hasOnlyDecoProvider||t[3]!==a.isLoading||t[4]!==a.isZeroBalance||t[5]!==i||t[6]!==e?(l=a.hasDecoKey&&a.isZeroBalance&&a.hasOnlyDecoProvider&&!a.isLoading&&i&&!Vl(e.id),t[1]=a.hasDecoKey,t[2]=a.hasOnlyDecoProvider,t[3]=a.isLoading,t[4]=a.isZeroBalance,t[5]=i,t[6]=e,t[7]=l):l=t[7];const h=l;let c;t[8]!==h?(c=h&&o.jsx(je.CreditsEmptyState,{}),t[8]=h,t[9]=c):c=t[9];const u=r!=="chat"?"opacity-0 pointer-events-none":"opacity-100";let d;t[10]!==u?(d=re("absolute inset-0 flex flex-col transition-opacity duration-100 ease-out",u),t[10]=u,t[11]=d):d=t[11];let f;t[12]!==i?(f=i?o.jsxs(o.Fragment,{children:[o.jsx(je.Main,{children:o.jsx(rd,{})}),o.jsx(je.Footer,{children:o.jsx(je.Input,{onOpenContextPanel:()=>n("context")})})]}):o.jsxs(o.Fragment,{children:[o.jsx(je.Main,{children:o.jsx(je.Messages,{})}),o.jsx(je.Footer,{children:o.jsx(je.Input,{onOpenContextPanel:()=>n("context")})})]}),t[12]=i,t[13]=f):f=t[13];let _;t[14]!==d||t[15]!==f?(_=o.jsx("div",{className:d,children:f}),t[14]=d,t[15]=f,t[16]=_):_=t[16];const m=r==="context"?"opacity-100":"opacity-0 pointer-events-none";let p;t[17]!==m?(p=re("absolute inset-0 flex flex-col transition-opacity duration-100 ease-out",m),t[17]=m,t[18]=p):p=t[18];let g;t[19]===Symbol.for("react.memo_cache_sentinel")?(g=o.jsx(Oh,{back:!0,onClose:()=>n("chat")}),t[19]=g):g=t[19];let v;t[20]!==p?(v=o.jsx("div",{className:p,children:g}),t[20]=p,t[21]=v):v=t[21];let b;return t[22]!==c||t[23]!==_||t[24]!==v?(b=o.jsxs(je,{className:"relative overflow-hidden animate-in fade-in-0 duration-200",children:[c,_,v]}),t[22]=c,t[23]=_,t[24]=v,t[25]=b):b=t[25],b}function Ea(){const t=H.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=o.jsx(je.Skeleton,{}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=o.jsx(Ht,{fallback:e,children:o.jsx(P.Suspense,{fallback:o.jsx(je.Skeleton,{}),children:o.jsx(nd,{})})}),t[1]=s):s=t[1],s}async function od(t,e,s){const i=await t.callTool({name:e,arguments:s});if(i.isError){const r=i.content?.[0]?.text??`Tool ${e} failed without a message`;throw new Error(r)}return i}const Ta=["VM_START"],Qs=new Map,ad=t=>`${t.virtualMcpId}::${t.branch??""}`,Fi=new Set,gi={mark:(t,e)=>Fi.add(`${t}::${e}`),clear:(t,e)=>Fi.delete(`${t}::${e}`),isStopped:(t,e)=>Fi.has(`${t}::${e}`)};function nn(t){const e=ds();return Vo({mutationKey:Ta,mutationFn:async s=>{s.branch&&gi.clear(s.virtualMcpId,s.branch);const i=ad(s),r=Qs.get(i);if(r)return r;const n=(async()=>(await od(t,"VM_START",s)).structuredContent)();Qs.set(i,n);try{return await n}finally{Qs.get(i)===n&&Qs.delete(i)}},onSuccess:()=>{oi(e)}})}function Ra(t,e){const s=H.c(3);let i;return s[0]!==e||s[1]!==t?(i={mutationKey:Ta,predicate:n=>{if(!t)return!1;const a=n.state.variables;return!a||a.virtualMcpId!==t?!1:(a.branch??"")===(e??"")}},s[0]=e,s[1]=t,s[2]=i):i=s[2],Rh(i)>0}const ld={settings:bc,automations:xc,env:pi,preview:tc,git:Rs};function Pn(t){const e=Ni(t);if(e.type==="icon"){const s=ji(e.name);return s?{kind:"component",Component:s}:null}return e.type==="url"?{kind:"url",src:e.url}:null}function Hi(t){if(t.kind==="system")return{kind:"component",Component:ld[t.tabId]};const e=Pn(t.iconUrl);if(e)return e;if(!t.appId)return{kind:"fallback"};const s=t.connections.find(r=>r.id===t.appId);if(!s)return{kind:"fallback"};const i=Pn(s.icon);return i||{kind:"fallback"}}function cd(t){const{org:e}=ve(),s=He({connectionId:Pt,orgId:e.id,orgSlug:e.slug}),{data:i}=Al({queryKey:Bs.threadMetadata(t),queryFn:async()=>{if(!s||!t)return null;try{const r=await s.callTool({name:"COLLECTION_THREADS_GET",arguments:{id:t}});return(r.structuredContent??r).item?.metadata??null}catch{return null}},staleTime:3e4});return i}function Da(t){const e=H.c(8),s=Bt();let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={strict:!1},e[0]=i):i=e[0];const r=Jr(i),n=Ct(t.virtualMcpId),a=cd(t.taskId),{currentBranch:l}=vt(),h=n?.metadata?.ui??null,c=h?.layout??null,u=c?.tabs??[],d=h?.pinnedViews??[],f=a?.expanded_tools??[],_=!!(n&&Kt(n));let m;e[1]===Symbol.for("react.memo_cache_sentinel")?(m={includeVirtual:!0},e[1]=m):m=e[1];const p=Ti(m),{activeTab:g,mainOpen:v}=oc({mainParam:r.main,metadata:c?{defaultMainView:c.defaultMainView??null,tabs:u.map(hd)}:null}),b=Qo(g),S=[];_&&(S.push({id:"preview",title:"Preview"}),S.push({id:"env",title:"Terminal"}),S.push({id:"git",title:l??"git"})),S.push({id:"settings",title:"Settings"}),S.push({id:"automations",title:"Automations"});const x=new Map;for(const E of f){const M=yn(E.appId,E.toolName);x.set(M,{id:M,title:E.toolName,appId:E.appId,iconKey:E.toolName})}for(const E of d){const M=yn(E.connectionId,E.toolName);x.set(M,{id:M,title:E.label||E.toolName,appId:E.connectionId,iconKey:E.toolName,iconUrl:E.icon??null})}let y;e[2]!==p?(y=E=>({id:E.id,title:E.title,kind:"agent",icon:Hi({tabId:E.id,kind:"agent",appId:E.view.appId,connections:p})}),e[2]=p,e[3]=y):y=e[3];const j=[...u.map(y),...Array.from(x.values()).map(E=>({id:E.id,title:E.title,kind:"expanded",icon:Hi({tabId:E.iconKey,kind:"expanded",appId:E.appId,iconUrl:E.iconUrl,connections:p})})),...S.map(E=>({id:E.id,title:E.title,kind:"system",icon:Hi({tabId:E.id,kind:"system",connections:p})}))];let C;return e[4]!==g||e[5]!==v||e[6]!==s?(C=E=>{const M=ac({clickedId:E,activeTab:g,mainOpen:v});s({to:".",search:A=>({...A,main:M}),replace:!0})},e[4]=g,e[5]=v,e[6]=s,e[7]=C):C=e[7],{activeTab:g,mainOpen:v,setActiveTab:C,systemTabs:S,layoutTabs:u,expandedTools:f,automationTabParsed:b,tabs:j}}function hd(t){return{id:t.id}}function Ma(t){const{managerAgentId:e,managerName:s,kind:i,id:r,instructions:n}=t,a=` to improve the instructions of ${i} "${r}". Here are its current instructions.
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/project-app-view-Xj3yVfXy.js","assets/index-CPXgqgtn.js","assets/index-B_4-KoG_.css","assets/pair-DYA5r7ea.js","assets/agent-icon-BpIPT-PU.js","assets/AlertCircle-CcUtX5uM.js","assets/Tool01-DK9-mVZw.js","assets/XClose-DQPB9QhN.js","assets/RefreshCcw01-B_PJ5f1k.js","assets/ArrowNarrowLeft-IKO0Pdme.js","assets/XCircle-BI7HQKdL.js","assets/ArrowUpRight-B9ER_pU4.js","assets/ZapSquare-DZh8af5t.js","assets/Users03-CRQrY9LZ.js","assets/CheckCircle-C1PuOF6d.js","assets/Check-DVRpvrTF.js","assets/ChevronDown-BgtmJwU7.js","assets/ChevronRight-BxsGpbIW.js","assets/ChevronUp-DvM1tvKw.js","assets/DotsVertical-CFsox5cs.js","assets/Container-D_d73BfD.js","assets/Star01-Cdw_hElv.js","assets/Palette-C4Za_YQg.js","assets/SearchMd-BH72zEYs.js","assets/index-9WMiiDWH.js","assets/tooltip-CCRvyunm.js","assets/X-DZI_qdyG.js","assets/LinkExternal01-BFJlAOho.js","assets/Lock01-BDVFL4zm.js","assets/Sun-ja3JE2c9.js","assets/Play-CG03drxN.js","assets/Plus-BMxmddO-.js","assets/Settings02-Bvv_nn0Y.js","assets/Shield01-B-3tcngo.js","assets/Trash01-D676SGAl.js","assets/User01-DGJlNaMw.js","assets/Zap-Dd-DoFdM.js","assets/index-C8Jg2iKl.js","assets/use-copy-BHjujE3w.js","assets/differenceInSeconds-NQ4PDo0z.js","assets/dialog-sB-RNyMu.js","assets/content-blocks-o63cs2vh.js","assets/types-CsuD99pM.js","assets/constants-RvCh42kd.js","assets/chat-context-DfNQ7f-M.js","assets/use-virtual-mcp-BNrt8cOn.js","assets/use-collections-Ra-WueHq.js","assets/use-ai-providers-Dgd0mo29.js","assets/use-decopilot-events-DQouP0Xf.js","assets/create-sse-subscription-CxkOgzKf.js","assets/use-tasks-CP9EEDgQ.js","assets/use-organization-settings-DZQEi_vL.js","assets/shell-layout-CCBbSGMK.js","assets/required-auth-layout-DxobDViQ.js","assets/use-org-sso-XYdJdNGD.js","assets/integration-icon-Btpdnlb-.js","assets/use-mcp-tools-DD1IUYEC.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{o as ds,r as P,p as Ml,q as Il,e as H,s as ve,K as Bs,n as Uo,a as Vo,c as re,j as o,l as Ie,B as oe,E as Ht,b as Ci,v as oi,f as Bt,d as Jr,w as Al,x as pe,y as Bl,V as Pl,t as ye,z as Ko,C as Ll,D as $t,F as Ol,G as xn,L as zl,H as Li,I as Zs,J as ht,M as qo,P as $l,_ as Fl,Q as Go,R as Yo,T as Hl,g as Wl}from"./index-CPXgqgtn.js";import{C as je,u as Ul,w as Vl,A as Kl,T as ql,a as Gl}from"./index-SKdTLMdd.js";import{I as us}from"./integration-icon-Btpdnlb-.js";import{S as Pt,u as He,g as Xo,a as Jo}from"./constants-RvCh42kd.js";import{u as Ct,a as Yl}from"./use-virtual-mcp-BNrt8cOn.js";import{a as Xl}from"./Users03-CRQrY9LZ.js";import{u as Zo,a as vt,b as Zr,c as fs,t as Jl,d as bn}from"./chat-context-DfNQ7f-M.js";import{i as Ps}from"./AlertCircle-CcUtX5uM.js";import{i as Zl}from"./CheckCircle-C1PuOF6d.js";import{n as Sn,a as Ql}from"./ZapSquare-DZh8af5t.js";import{i as ec,a as tc,b as sc,c as ki,d as ic}from"./XCircle-BI7HQKdL.js";import{s as ls,i as rc}from"./XClose-DQPB9QhN.js";import{c as nc,r as oc,p as Qo,f as yn,a as ac,F as lc,t as wn,M as Qr,G as ea,L as cc,i as hc,b as dc,d as uc,e as fc}from"./pair-DYA5r7ea.js";import{C as mc,a as Cn,b as kn,c as _c,d as pc,e as gc,f as vc}from"./command-CN0wol1M.js";import{P as Ws,a as Us,b as Vs}from"./popover-BP8qYbWI.js";import{i as Rs,a as pi,b as xc,c as bc,p as Ni,g as ji,d as en,e as ta,h as cr,f as Oi,j as Nn,A as jn,k as sa,l as Sc,m as yc,n as wc,t as Cc,o as kc,q as ai,r as ia,s as ra,u as na,v as En,w as Nc,x as Ds,y as jc,z as Ec,B as oa}from"./agent-icon-BpIPT-PU.js";import{u as ms,a as Tc}from"./use-mcp-tools-DD1IUYEC.js";import{u as Rc,a as Dc}from"./use-ai-providers-Dgd0mo29.js";import{g as Kt,c as Tn,u as Mc,b as hr,d as Ic,e as Ac,f as Bc,T as Pc}from"./index-BfH23PIC.js";import{u as Ei,i as Lc}from"./shell-layout-CCBbSGMK.js";import{i as Oc,P as ct,u as zc,c as $c,d as Fc,e as Hc}from"./index-9WMiiDWH.js";import{u as aa,T as Ke,a as qe,b as Ge,c as Wc}from"./tooltip-CCRvyunm.js";import{u as Uc}from"./use-status-sounds-BnOGH79m.js";import{E as Ls}from"./empty-state-4KQTPzu7.js";import{A as Vc,a as Kc,b as qc,c as Gc,R as la,d as Yc,e as Xc}from"./accordion-BqJi9w98.js";import{u as Ti,a as tn,b as Jc}from"./use-connection-D6QJlUO9.js";import{g as Zc}from"./constants-Hpdlytpy.js";import{u as Qc,g as eh}from"./types-CsuD99pM.js";import{u as ca,G as th}from"./lean-canvas-recruit-modal-aeSS5EN2.js";import{U as ha}from"./user-O4Eqd0DY.js";import{T as sh,u as da}from"./tools-list-NaHpnv5w.js";import{u as ih}from"./unwrap-tool-result-BYXdCQMg.js";import{s as ua,g as rh}from"./connection-slug-eyAPH6o3.js";import{A as fa,a as ma,b as _a,c as pa,d as ga,e as va,f as xa,g as ba}from"./alert-dialog-DZnXWtkc.js";import{D as nh,a as sn,b as rn,c as Sa,d as ya}from"./dialog-sB-RNyMu.js";import{C as oh,a as Rn}from"./card-DfBr11OH.js";import{I as _s}from"./input-BYLqJazY.js";import{L as Ms}from"./label-wqfg1Psv.js";import{S as ts,a as ss,b as is,c as rs,d as At}from"./select-DV6XTbu1.js";import{S as dr}from"./switch-B9P99cpo.js";import{T as Dn}from"./textarea-Dk5HQM76.js";import{i as li}from"./Play-CG03drxN.js";import{s as cs}from"./Plus-BMxmddO-.js";import{a as ah}from"./Settings02-Bvv_nn0Y.js";import{t as wa,i as lh}from"./Tool01-DK9-mVZw.js";import{s as ur}from"./Trash01-D676SGAl.js";import{u as Ca}from"./use-debounced-autosave-C7GmOCQZ.js";import{S as ka}from"./scroll-area-Bazrt5Q_.js";import{i as Na,a as ch}from"./SearchMd-BH72zEYs.js";import{C as hh}from"./collection-tabs-Sh1c6Hp3.js";import{C as dh}from"./checkbox-CsVxpSNu.js";import{u as uh,T as zi,a as fh,b as mh,c as $i}from"./tabs-C0vV7-ts.js";import{D as _h,a as ph,b as gh}from"./drawer-DdDu6FoS.js";import{i as Ri}from"./Check-DVRpvrTF.js";import{n as qt}from"./LinkExternal01-BFJlAOho.js";import{S as vh}from"./index-C8Jg2iKl.js";import{D as ns,a as os,b as as,c as wt,d as xh,e as bh,f as Sh}from"./dropdown-menu-Ba10Ub1x.js";import{t as fr}from"./ChevronDown-BgtmJwU7.js";import{i as ja}from"./RefreshCcw01-B_PJ5f1k.js";import{V as yh}from"./view-mode-toggle-BDOZY65E.js";import{M as wh}from"./select-model-q-6_EO7e.js";import{u as Ks,a as Ch,b as kh,c as Nh,A as jh,d as Eh}from"./automation-list-row-BjkF6IP8.js";import{i as Os}from"./Zap-Dd-DoFdM.js";import{S as Th}from"./search-input-CagM2rOd.js";import"./use-navigate-to-agent-DtcXsTmt.js";import"./use-tasks-CP9EEDgQ.js";import"./use-collections-Ra-WueHq.js";import"./collection-search-CUzZkask.js";import"./form-C8F4itc9.js";import"./Star01-Cdw_hElv.js";import"./Lock01-BDVFL4zm.js";import"./X-DZI_qdyG.js";import"./toggle-group-DiN3ciV3.js";import"./index-CsYx-I3w.js";import"./question-004-sINsf4GQ.js";import"./ai-providers-logos-DD3qZ33J.js";import"./connection-card-t8q3avUo.js";import"./use-registry-connections-BgfsM9PL.js";import"./use-organization-settings-DZQEi_vL.js";import"./useInfiniteQuery-m6hlUQnd.js";import"./infiniteQueryObserver-BeoG5sU6.js";import"./extract-connection-data-CLmSiyTB.js";import"./Container-D_d73BfD.js";import"./connection-form-helpers-CDqLkd8a.js";import"./use-infinite-scroll-CBiQU4Ab.js";import"./useSuspenseInfiniteQuery-BbuXOIpQ.js";import"./badge-CMhkMPpc.js";import"./ChevronRight-BxsGpbIW.js";import"./use-decopilot-events-DQouP0Xf.js";import"./create-sse-subscription-CxkOgzKf.js";import"./use-copy-BHjujE3w.js";import"./differenceInSeconds-NQ4PDo0z.js";import"./content-blocks-o63cs2vh.js";import"./Sun-ja3JE2c9.js";import"./index-Ccbgu0mE.js";import"./ArrowNarrowLeft-IKO0Pdme.js";import"./ArrowUpRight-B9ER_pU4.js";import"./ChevronUp-DvM1tvKw.js";import"./DotsVertical-CFsox5cs.js";import"./Palette-C4Za_YQg.js";import"./Shield01-B-3tcngo.js";import"./User01-DGJlNaMw.js";import"./skeleton-eJ5dvmO1.js";import"./avatar-EJ4rWeJV.js";import"./index-A1kUSxVF.js";import"./collection-search-DDXROr4Y.js";import"./use-create-virtual-mcp-BxdAiHU1.js";import"./task-status-nAuAdX3m.js";import"./required-auth-layout-DxobDViQ.js";import"./use-org-sso-XYdJdNGD.js";import"./collections-B6H9755O.js";import"./settings-section-BSSTyi59.js";import"./formatDistanceToNow-Cb2QZZJn.js";function Rh(t,e){const s=ds(e);return Dh({filters:{...t,status:"pending"}},s).length}function Mn(t,e){return t.findAll(e.filters).map(s=>e.select?e.select(s):s.state)}function Dh(t={},e){const s=ds(e).getMutationCache(),i=P.useRef(t),r=P.useRef(null);return r.current===null&&(r.current=Mn(s,t)),P.useEffect(()=>{i.current=t}),P.useSyncExternalStore(P.useCallback(n=>s.subscribe(()=>{const a=Ml(r.current,Mn(s,i.current));r.current!==a&&(r.current=a,Il.schedule(n))}),[s]),()=>r.current,()=>r.current)}function Mh(t,e){const s=H.c(40),{org:i,locator:r}=ve();let n;s[0]!==i.id||s[1]!==i.slug?(n={connectionId:Pt,orgId:i.id,orgSlug:i.slug},s[0]=i.id,s[1]=i.slug,s[2]=n):n=s[2];const a=He(n),l=ds();let h;s[3]!==t||s[4]!==i.id?(h=Bs.ensureTask(i.id,t),s[3]=t,s[4]=i.id,s[5]=h):h=s[5];let c;s[6]!==a||s[7]!==t?(c=async()=>(await a.callTool({name:"COLLECTION_THREADS_GET",arguments:{id:t}})).structuredContent?.item??null,s[6]=a,s[7]=t,s[8]=c):c=s[8];const u=t.length>0;let d;s[9]!==h||s[10]!==c||s[11]!==u?(d={queryKey:h,queryFn:c,enabled:u,retry:!1,refetchOnWindowFocus:!1},s[9]=h,s[10]=c,s[11]=u,s[12]=d):d=s[12];const f=Uo(d);let _;s[13]!==a||s[14]!==e?(_=async x=>{const y=await a.callTool({name:"COLLECTION_THREADS_CREATE",arguments:{data:{id:x,virtual_mcp_id:e}}});if(y.isError){const C=y.content,T=Array.isArray(C)&&C[0]&&typeof C[0]=="object"?C[0].text??"Create failed":"Create failed";throw new Error(T)}return y.structuredContent.item},s[13]=a,s[14]=e,s[15]=_):_=s[15];let m;s[16]!==r||s[17]!==i.id||s[18]!==f||s[19]!==l?(m=()=>{l.invalidateQueries({predicate:x=>x.queryKey[1]===i.id&&x.queryKey[3]==="collection"&&x.queryKey[4]==="THREADS"}),l.invalidateQueries({queryKey:Bs.tasksPrefix(r)}),f.refetch()},s[16]=r,s[17]=i.id,s[18]=f,s[19]=l,s[20]=m):m=s[20];let p;s[21]!==_||s[22]!==m?(p={mutationFn:_,onSuccess:m},s[21]=_,s[22]=m,s[23]=p):p=s[23];const g=Vo(p);let v,b;if(s[24]!==g||s[25]!==t||s[26]!==f.data||s[27]!==f.isSuccess?(v=()=>{t&&(!f.isSuccess||f.data||g.isPending||g.variables!==t&&g.mutate(t))},b=[t,f.isSuccess,f.data,g],s[24]=g,s[25]=t,s[26]=f.data,s[27]=f.isSuccess,s[28]=v,s[29]=b):(v=s[28],b=s[29]),P.useEffect(v,b),!t){let x;return s[30]===Symbol.for("react.memo_cache_sentinel")?(x={status:"ready",task:null},s[30]=x):x=s[30],x}if(f.isLoading){let x;return s[31]===Symbol.for("react.memo_cache_sentinel")?(x={status:"loading"},s[31]=x):x=s[31],x}if(f.isError){const x=f.error;let y;return s[32]!==x?(y={status:"error",error:x},s[32]=x,s[33]=y):y=s[33],y}if(f.isSuccess&&f.data){let x;return s[34]!==f.data?(x={status:"ready",task:f.data},s[34]=f.data,s[35]=x):x=s[35],x}if(g.isPending||f.isSuccess&&!f.data){let x;return s[36]===Symbol.for("react.memo_cache_sentinel")?(x={status:"creating"},s[36]=x):x=s[36],x}if(g.isError){let x;return s[37]!==g.error?(x={status:"error",error:g.error},s[37]=g.error,s[38]=x):x=s[38],x}let S;return s[39]===Symbol.for("react.memo_cache_sentinel")?(S={status:"loading"},s[39]=S):S=s[39],S}function vs(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}k`:String(t)}function In(t){if(!t)return"—";const e=typeof t=="string"?new Date(t):t;return isNaN(e.getTime())?"—":e.toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"})}function Ih(t){return t?t.replace(/-\d{8}(?:-[a-z0-9]+)*$/i,"").replace(/-/g," "):"—"}function Ah(t){const e=H.c(4),{items:s}=t;let i;e[0]!==s?(i=s.map(Bh),e[0]=s,e[1]=i):i=e[1];let r;return e[2]!==i?(r=o.jsx("div",{className:"grid grid-cols-2 gap-x-8 gap-y-6",children:i}),e[2]=i,e[3]=r):r=e[3],r}function Bh(t){return o.jsxs("div",{className:"flex flex-col gap-1 min-w-0",children:[o.jsx("span",{className:"text-xs text-muted-foreground truncate",children:t.label}),o.jsx("span",{className:"text-sm text-foreground tabular-nums truncate",children:t.value})]},t.label)}function Ph(t){const e=H.c(30),{userTokens:s,assistantTokens:i,otherTokens:r}=t,n=s+i+r,a=n>0?s/n*100:0,l=n>0?i/n*100:0,h=n>0?r/n*100:0;let c;e[0]!==a?(c=a>0&&o.jsx("div",{className:"h-full bg-chart-1",style:{width:`${a}%`}}),e[0]=a,e[1]=c):c=e[1];let u;e[2]!==l?(u=l>0&&o.jsx("div",{className:"h-full bg-chart-2",style:{width:`${l}%`}}),e[2]=l,e[3]=u):u=e[3];let d;e[4]!==h?(d=h>0&&o.jsx("div",{className:"h-full bg-muted-foreground/30",style:{width:`${h}%`}}),e[4]=h,e[5]=d):d=e[5];let f;e[6]!==c||e[7]!==u||e[8]!==d?(f=o.jsxs("div",{className:"flex h-2 w-full overflow-hidden rounded-full bg-muted",children:[c,u,d]}),e[6]=c,e[7]=u,e[8]=d,e[9]=f):f=e[9];let _;e[10]===Symbol.for("react.memo_cache_sentinel")?(_=o.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-chart-1 shrink-0"}),e[10]=_):_=e[10];let m;e[11]!==a?(m=a.toFixed(1),e[11]=a,e[12]=m):m=e[12];let p;e[13]!==m?(p=o.jsxs("div",{className:"flex items-center gap-1.5",children:[_,o.jsxs("span",{className:"text-xs text-muted-foreground",children:["User ",m,"%"]})]}),e[13]=m,e[14]=p):p=e[14];let g;e[15]===Symbol.for("react.memo_cache_sentinel")?(g=o.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-chart-2 shrink-0"}),e[15]=g):g=e[15];let v;e[16]!==l?(v=l.toFixed(1),e[16]=l,e[17]=v):v=e[17];let b;e[18]!==v?(b=o.jsxs("div",{className:"flex items-center gap-1.5",children:[g,o.jsxs("span",{className:"text-xs text-muted-foreground",children:["Assistant ",v,"%"]})]}),e[18]=v,e[19]=b):b=e[19];let S;e[20]!==h||e[21]!==r?(S=r>0&&o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-muted-foreground/30 shrink-0"}),o.jsxs("span",{className:"text-xs text-muted-foreground",children:["Other ",h.toFixed(1),"%"]})]}),e[20]=h,e[21]=r,e[22]=S):S=e[22];let x;e[23]!==b||e[24]!==S||e[25]!==p?(x=o.jsxs("div",{className:"flex flex-wrap gap-x-3 gap-y-1",children:[p,b,S]}),e[23]=b,e[24]=S,e[25]=p,e[26]=x):x=e[26];let y;return e[27]!==x||e[28]!==f?(y=o.jsxs("div",{className:"flex flex-col gap-2",children:[f,x]}),e[27]=x,e[28]=f,e[29]=y):y=e[29],y}function Lh(t){const e=H.c(19),{part:s}=t,i=s.input?.agent_id,r=Ct(i),n=r?.title??"Subtask",a=r?.icon??null,l=s.state==="input-streaming"||s.state==="input-available"||s.state==="output-available"&&s.preliminary===!0,h=s.state==="output-error",c=s.state==="approval-requested";let u;e[0]!==a||e[1]!==n?(u=o.jsx(us,{icon:a,name:n,size:"xs",className:"size-6 rounded-md shrink-0"}),e[0]=a,e[1]=n,e[2]=u):u=e[2];const d=h?"text-destructive":"text-foreground";let f;e[3]!==d?(f=re("shrink-0 font-medium",d),e[3]=d,e[4]=f):f=e[4];let _;e[5]!==n||e[6]!==f?(_=o.jsx("span",{className:f,children:n}),e[5]=n,e[6]=f,e[7]=_):_=e[7];let m;e[8]!==s.input?(m=s.input?.prompt&&o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"text-muted-foreground/50",children:"·"}),o.jsx("span",{className:"truncate text-muted-foreground",children:s.input.prompt})]}),e[8]=s.input,e[9]=m):m=e[9];let p;e[10]!==c||e[11]!==h||e[12]!==l?(p=o.jsx("span",{className:"ml-auto shrink-0",children:l?o.jsx(Ie,{size:12,className:"animate-spin text-muted-foreground"}):h?o.jsx(ec,{size:12,className:"text-destructive"}):c?o.jsx(Ps,{size:12,className:"text-warning"}):o.jsx(Zl,{size:12,className:"text-emerald-500"})}),e[10]=c,e[11]=h,e[12]=l,e[13]=p):p=e[13];let g;return e[14]!==u||e[15]!==_||e[16]!==m||e[17]!==p?(g=o.jsxs("div",{className:"flex items-center gap-2 text-xs min-w-0",children:[u,_,m,p]}),e[14]=u,e[15]=_,e[16]=m,e[17]=p,e[18]=g):g=e[18],g}function Oh(t){const e=H.c(58),{onClose:s,back:i,className:r}=t,[n,a]=P.useState(null),{messages:l}=Zo(),{tasks:h,taskId:c}=vt(),{selectedModel:u,selectedVirtualMcp:d}=Zr();let f,_,m,p,g,v,b,S;if(e[0]!==i||e[1]!==r||e[2]!==l||e[3]!==s||e[4]!==n?.id||e[5]!==u||e[6]!==d?.title||e[7]!==c||e[8]!==h){S=Symbol.for("react.early_return_sentinel");e:{let j;e[17]!==c?(j=Y=>Y.id===c,e[17]=c,e[18]=j):j=e[18];const C=h.find(j),T=nc(l),E=[...l].reverse().find(Yh),M=E?.metadata?.usage,A=E?.metadata?.modelLimits?.contextWindow??u?.limits?.contextWindow??null,I=M?.contextTokens??M?.totalTokens??0,k=A&&A>0?(I/A*100).toFixed(1):null,w=l;let N;e[19]!==w?(N=w.filter(Gh).reduce(qh,0),e[19]=w,e[20]=N):N=e[20];const R=N,D=l;let B;e[21]!==D?(B=D.filter(Kh).reduce(Vh,0),e[21]=D,e[22]=B):B=e[22];const z=B,G=Math.max(0,T.totalTokens-R-z),W=l[0],F=l.at(-1),Z=W?.metadata?.created_at??C?.created_at,q=F?.metadata?.created_at??C?.updated_at,$=l.filter(Uh),U=l.flatMap(Hh),V=u?.modelId?Ih(u.modelId):"—",se=d?.title??"Decopilot",L=[{label:"Session",value:C?.title??"New chat"},{label:"Messages",value:$.length},{label:"Agent",value:se},{label:"Model",value:V},{label:"Context Limit",value:A?vs(A):"—"},{label:"Session Tokens (billed)",value:T.totalTokens>0?vs(T.totalTokens):"0"},{label:"Usage",value:k!==null?`${k}%`:"—"},{label:"Input Tokens",value:T.inputTokens>0?vs(T.inputTokens):"0"},{label:"Output Tokens",value:T.outputTokens>0?vs(T.outputTokens):"0"},{label:"Reasoning Tokens",value:T.reasoningTokens>0?vs(T.reasoningTokens):"0"},{label:"Cost",value:T.cost>0?`$${T.cost<.001?T.cost.toFixed(6):T.cost.toFixed(4)}`:"$0.00"},{label:"Session Created",value:In(Z)},{label:"Last Activity",value:In(q)}];if(!C&&$.length===0){let Y;e[23]!==r?(Y=re("flex flex-col h-full w-full border-l border-border bg-background",r),e[23]=r,e[24]=Y):Y=e[24];let le;e[25]===Symbol.for("react.memo_cache_sentinel")?(le=o.jsx("span",{className:"text-sm font-medium text-foreground",children:"Context"}),e[25]=le):le=e[25];let ue;e[26]!==i?(ue=i?o.jsx(Sn,{size:14,className:"text-muted-foreground"}):o.jsx(ls,{size:14,className:"text-muted-foreground"}),e[26]=i,e[27]=ue):ue=e[27];let de;e[28]!==s||e[29]!==ue?(de=o.jsxs("div",{className:"h-11 px-4 flex items-center justify-between shrink-0 border-b border-border/50",children:[le,o.jsx("button",{type:"button",onClick:s,className:"flex size-6 items-center justify-center rounded hover:bg-accent transition-colors",children:ue})]}),e[28]=s,e[29]=ue,e[30]=de):de=e[30];let fe;e[31]===Symbol.for("react.memo_cache_sentinel")?(fe=o.jsx("div",{className:"flex-1 flex items-center justify-center px-4 text-center",children:o.jsx("p",{className:"text-xs text-muted-foreground",children:"Start a conversation to see context"})}),e[31]=fe):fe=e[31];let _e;e[32]!==Y||e[33]!==de?(_e=o.jsxs("div",{className:Y,children:[de,fe]}),e[32]=Y,e[33]=de,e[34]=_e):_e=e[34],S=_e;break e}e[35]!==r?(v=re("flex flex-col h-full w-full border-l border-border bg-background overflow-y-auto",r),e[35]=r,e[36]=v):v=e[36];let te;e[37]===Symbol.for("react.memo_cache_sentinel")?(te=o.jsx("span",{className:"text-sm font-medium text-foreground",children:"Context"}),e[37]=te):te=e[37];let ie;e[38]!==i?(ie=i?o.jsx(Sn,{size:14}):o.jsx(ls,{size:14}),e[38]=i,e[39]=ie):ie=e[39],e[40]!==s||e[41]!==ie?(b=o.jsxs("div",{className:"flex h-11 shrink-0 items-center justify-between border-b border-border/50 px-4",children:[te,o.jsx("button",{type:"button",onClick:s,className:"flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",children:ie})]}),e[40]=s,e[41]=ie,e[42]=b):b=e[42],f="flex flex-col gap-8 p-6",_=U.length>0&&o.jsxs("div",{className:"flex flex-col gap-3",children:[o.jsx("span",{className:"text-xs text-muted-foreground",children:"Subtasks"}),o.jsx("div",{className:"flex flex-col gap-1",children:U.map(Fh)})]}),m=o.jsx(Ah,{items:L});let ee;e[43]===Symbol.for("react.memo_cache_sentinel")?(ee=o.jsx("span",{className:"text-xs text-muted-foreground",children:"Context Breakdown"}),e[43]=ee):ee=e[43],e[44]!==z||e[45]!==G||e[46]!==R?(p=o.jsxs("div",{className:"flex flex-col gap-3",children:[ee,o.jsx(Ph,{userTokens:R,assistantTokens:z,otherTokens:G})]}),e[44]=z,e[45]=G,e[46]=R,e[47]=p):p=e[47],g=$.length>0&&o.jsxs("div",{className:"flex flex-col gap-3",children:[o.jsx("span",{className:"text-xs text-muted-foreground",children:"Raw messages"}),o.jsx("div",{className:"flex flex-col gap-1",children:$.map(Y=>{const le=Y.metadata?.created_at,ue=n?.id===Y.id;return o.jsxs("div",{className:"rounded-md border border-border/50 overflow-hidden",children:[o.jsxs("button",{type:"button",onClick:()=>a(ue?null:Y),className:"flex items-center justify-between gap-2 px-3 py-2 text-xs hover:bg-accent/50 w-full text-left cursor-pointer",children:[o.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[o.jsx("span",{className:re("shrink-0 font-medium",Y.role==="user"?"text-chart-1":"text-chart-2"),children:Y.role}),o.jsx("span",{className:"text-muted-foreground",children:"•"}),o.jsx("span",{className:"truncate text-muted-foreground font-mono",children:Y.id})]}),le&&o.jsx("span",{className:"shrink-0 text-muted-foreground tabular-nums",children:new Date(le).toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"})})]}),ue&&o.jsxs(o.Fragment,{children:[Y.role==="assistant"&&(()=>{const de=Y.metadata?._request;if(!de)return null;const fe=de.systemSections??[],_e=Math.max(1,...fe.map($h)),Ue=fe.reduce(zh,0);return o.jsxs("div",{className:"border-t border-border/50 px-3 py-2.5 text-xs space-y-2.5",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"font-medium text-foreground",children:"Request"}),o.jsxs("span",{className:"text-muted-foreground tabular-nums",children:[de.activeTools??0," / ",de.tools??0," ","tools active"]})]}),fe.length>0&&o.jsxs("div",{className:"space-y-1.5",children:[o.jsxs("div",{className:"text-muted-foreground",children:["System prompt"," ",o.jsxs("span",{className:"tabular-nums",children:["~",Math.round(Ue/4).toLocaleString()," ","tok"]})]}),fe.map(($e,Qe)=>{const at=$e.preview.match(/^<([a-z-]+)/i)?.[1]??`section ${Qe}`,Q=$e.chars/_e*100,Ne=Math.round($e.chars/4);return o.jsxs("div",{className:"space-y-0.5",children:[o.jsxs("div",{className:"flex items-center justify-between gap-2",children:[o.jsx("span",{className:"font-mono text-foreground truncate",children:at}),o.jsxs("span",{className:"text-muted-foreground tabular-nums shrink-0",children:["~",Ne.toLocaleString()," tok"]})]}),o.jsx("div",{className:"h-1 w-full rounded-full bg-muted overflow-hidden",children:o.jsx("div",{className:"h-full rounded-full bg-chart-3",style:{width:`${Q}%`}})})]},Qe)})]})]})})(),o.jsx("pre",{className:"text-xs font-mono bg-muted px-3 py-2 overflow-auto whitespace-pre-wrap break-all border-t border-border/50 max-h-64",children:JSON.stringify(Y,null,2)})]})]},Y.id)})})]})}e[0]=i,e[1]=r,e[2]=l,e[3]=s,e[4]=n?.id,e[5]=u,e[6]=d?.title,e[7]=c,e[8]=h,e[9]=f,e[10]=_,e[11]=m,e[12]=p,e[13]=g,e[14]=v,e[15]=b,e[16]=S}else f=e[9],_=e[10],m=e[11],p=e[12],g=e[13],v=e[14],b=e[15],S=e[16];if(S!==Symbol.for("react.early_return_sentinel"))return S;let x;e[48]!==f||e[49]!==_||e[50]!==m||e[51]!==p||e[52]!==g?(x=o.jsxs("div",{className:f,children:[_,m,p,g]}),e[48]=f,e[49]=_,e[50]=m,e[51]=p,e[52]=g,e[53]=x):x=e[53];let y;return e[54]!==v||e[55]!==b||e[56]!==x?(y=o.jsxs("div",{className:v,children:[b,x]}),e[54]=v,e[55]=b,e[56]=x,e[57]=y):y=e[57],y}function zh(t,e){return t+e.chars}function $h(t){return t.chars}function Fh(t,e){return o.jsx(Lh,{part:t},e)}function Hh(t){return(t.parts??[]).filter(Wh)}function Wh(t){return t.type==="tool-subtask"}function Uh(t){return t.role!=="system"}function Vh(t,e){const s=e.metadata?.usage;return t+(s?.outputTokens??0)}function Kh(t){return t.role==="assistant"}function qh(t,e){const s=e.metadata?.usage;return t+(s?.inputTokens??0)}function Gh(t){return t.role==="user"}function Yh(t){return t.role==="assistant"&&t.metadata?.usage}const An=["amber","bold","bright","calm","crimson","coral","daring","deep","dusty","eager","faint","fierce","frozen","gentle","golden","grand","green","hollow","iron","ivory","keen","lasting","lunar","mellow","misty","noble","olive","pale","prime","quiet","rapid","rustic","serene","sharp","silver","sleek","solar","stark","still","swift","tawny","tender","thin","true","vast","velvet","warm","wild","young","zen"],Bn=["anchor","birch","brook","cedar","cliff","cove","crane","dune","echo","ember","falcon","fern","flint","forge","frost","glade","grove","harbor","hawk","iris","jade","lark","maple","marsh","mesa","opal","orbit","peak","pine","plume","quartz","rapids","reef","ridge","river","sage","shore","slate","spruce","stone","summit","thorn","tide","trail","vale","wren","aspen","delta","crest","spark"];function Xh(){const t=An[Math.floor(Math.random()*An.length)],e=Bn[Math.floor(Math.random()*Bn.length)];return`deco/${t}-${e}`}function Jh(t){const e=t;if(e.structuredContent)return e.structuredContent;const s=e.content?.find(i=>i.type==="text")?.text;if(s)try{return JSON.parse(s)}catch{return[]}return[]}function Zh(t){const e=H.c(26),{orgId:s,orgSlug:i,userId:r,connectionId:n,vmMap:a,owner:l,repo:h,enabled:c}=t,u=c===void 0?!0:c,d=n??null;let f;e[0]!==s||e[1]!==i||e[2]!==d?(f={connectionId:d,orgId:s,orgSlug:i},e[0]=s,e[1]=i,e[2]=d,e[3]=f):f=e[3];const _=He(f);let m;e[4]!==l||e[5]!==h?(m={owner:l,repo:h},e[4]=l,e[5]=h,e[6]=m):m=e[6];const p=u&&!!n&&!!l&&!!h;let g;e[7]!==_||e[8]!==m||e[9]!==p?(g={client:_,toolName:"list_branches",toolArguments:m,enabled:p,staleTime:3e4,select:sd},e[7]=_,e[8]=m,e[9]=p,e[10]=g):g=e[10];const{data:v,isLoading:b,isError:S}=ms(g);let x,y;e[11]!==r||e[12]!==a?(y=new Set(Object.keys(a?.[r]??{})),x=[...y].sort().map(td),e[11]=r,e[12]=a,e[13]=x,e[14]=y):(x=e[13],y=e[14]);const j=x;let C;if(e[15]!==v||e[16]!==y){const A=Array.isArray(v)?v:v?.branches??[];let I;e[18]!==y?(I=k=>!y.has(k.name),e[18]=y,e[19]=I):I=e[19],C=A.filter(ed).filter(I).map(Qh),e[15]=v,e[16]=y,e[17]=C}else C=e[17];const T=C,E=Array.isArray(v)?null:v?.default_branch??null;let M;return e[20]!==E||e[21]!==S||e[22]!==b||e[23]!==T||e[24]!==j?(M={yours:j,others:T,defaultBase:E,isLoading:b,isError:S},e[20]=E,e[21]=S,e[22]=b,e[23]=T,e[24]=j,e[25]=M):M=e[25],M}function Qh(t){return{name:t.name,source:"other",author:typeof t.commit?.author=="string"?t.commit.author:t.commit?.author?.login??null}}function ed(t){return typeof t.name=="string"}function td(t){return{name:t,source:"yours"}}function sd(t){return Jh(t)}function id(t){const e=H.c(42),{orgId:s,orgSlug:i,userId:r,connectionId:n,owner:a,repo:l,vmMap:h,value:c,onChange:u}=t,[d,f]=P.useState(!1);let _;e[0]!==n||e[1]!==d||e[2]!==s||e[3]!==i||e[4]!==a||e[5]!==l||e[6]!==r||e[7]!==h?(_={orgId:s,orgSlug:i,userId:r,connectionId:n,vmMap:h,owner:a,repo:l,enabled:d},e[0]=n,e[1]=d,e[2]=s,e[3]=i,e[4]=a,e[5]=l,e[6]=r,e[7]=h,e[8]=_):_=e[8];const{yours:m,others:p,isLoading:g,isError:v}=Zh(_);let b;e[9]!==u?(b=R=>{u(R),f(!1)},e[9]=u,e[10]=b):b=e[10];const S=b,x=c??"Select branch…";let y;e[11]===Symbol.for("react.memo_cache_sentinel")?(y=o.jsx(Rs,{className:"h-3.5 w-3.5"}),e[11]=y):y=e[11];let j;e[12]!==x?(j=o.jsx(Ws,{asChild:!0,children:o.jsxs(oe,{variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 font-mono text-xs",children:[y,o.jsx("span",{className:"max-w-[200px] truncate",children:x})]})}),e[12]=x,e[13]=j):j=e[13];let C;e[14]===Symbol.for("react.memo_cache_sentinel")?(C=o.jsx(pc,{placeholder:"Search branches…"}),e[14]=C):C=e[14];let T;e[15]!==S?(T=o.jsxs("div",{className:"flex items-center border-b pr-2 [&>[data-slot=command-input-wrapper]]:flex-1 [&>[data-slot=command-input-wrapper]]:border-b-0",children:[C,o.jsx(oe,{variant:"outline",size:"sm",className:"h-7 shrink-0",onClick:()=>S(Xh()),children:"New"})]}),e[15]=S,e[16]=T):T=e[16];let E;e[17]!==v?(E=v&&o.jsx("div",{className:"p-3 text-xs text-muted-foreground",children:"Couldn't load branches from GitHub. You can still pick from your branches."}),e[17]=v,e[18]=E):E=e[18];let M;e[19]!==v||e[20]!==g||e[21]!==p.length||e[22]!==m.length?(M=!v&&!g&&m.length===0&&p.length===0&&o.jsx(mc,{children:"No branches found."}),e[19]=v,e[20]=g,e[21]=p.length,e[22]=m.length,e[23]=M):M=e[23];let A;e[24]!==S||e[25]!==m?(A=m.length>0&&o.jsx(Cn,{heading:"Your branches",children:m.map(R=>o.jsxs(kn,{value:R.name,onSelect:()=>S(R.name),children:[o.jsx(Rs,{className:"mr-2 h-4 w-4"}),o.jsx("span",{className:"flex-1 truncate",children:R.name})]},R.name))}),e[24]=S,e[25]=m,e[26]=A):A=e[26];let I;e[27]!==p||e[28]!==S?(I=p.length>0&&o.jsxs(o.Fragment,{children:[o.jsx(_c,{}),o.jsx(Cn,{heading:"Other branches in repo",children:p.map(R=>o.jsxs(kn,{value:R.name,onSelect:()=>S(R.name),children:[o.jsx(Rs,{className:"mr-2 h-4 w-4"}),o.jsx("span",{className:"flex-1 truncate",children:R.name}),R.author&&o.jsxs("span",{className:"text-xs text-muted-foreground",children:["@",R.author]})]},R.name))})]}),e[27]=p,e[28]=S,e[29]=I):I=e[29];let k;e[30]!==I||e[31]!==E||e[32]!==M||e[33]!==A?(k=o.jsxs(gc,{children:[E,M,A,I]}),e[30]=I,e[31]=E,e[32]=M,e[33]=A,e[34]=k):k=e[34];let w;e[35]!==k||e[36]!==T?(w=o.jsx(Us,{className:"w-[min(420px,calc(100vw-2rem))] p-0",align:"start",children:o.jsxs(vc,{children:[T,k]})}),e[35]=k,e[36]=T,e[37]=w):w=e[37];let N;return e[38]!==d||e[39]!==w||e[40]!==j?(N=o.jsxs(Vs,{open:d,onOpenChange:f,children:[j,w]}),e[38]=d,e[39]=w,e[40]=j,e[41]=N):N=e[41],N}function rd(){const t=H.c(27),{org:e}=ve(),{selectedVirtualMcp:s}=Zr(),{data:i}=Ci.useSession(),{currentBranch:r,setCurrentTaskBranch:n}=vt();let a;t[0]!==e.id?(a=Xo(e.id),t[0]=e.id,t[1]=a):a=t[1];const h=s??a,c=Ct(h.id),u=i?.user?.id??"",d=c?.metadata?.githubRepo??null,f=!!d?.connectionId&&!!u;let _;t[2]===Symbol.for("react.memo_cache_sentinel")?(_=o.jsx(Xl,{size:32}),t[2]=_):_=t[2];let m;t[3]!==h.icon||t[4]!==h.title?(m=o.jsx(us,{icon:h.icon,name:h.title,size:"lg",fallbackIcon:_,className:"size-10 min-w-10 md:size-[60px]! md:min-w-[60px] rounded-xl md:rounded-[18px]!"}),t[3]=h.icon,t[4]=h.title,t[5]=m):m=t[5];let p;t[6]!==h.title?(p=o.jsx("h3",{className:"text-base md:text-xl font-medium text-foreground",children:h.title}),t[6]=h.title,t[7]=p):p=t[7];const g=h.description??"Ask anything about configuring model providers or using MCP Mesh.";let v;t[8]!==g?(v=o.jsx("div",{className:"text-muted-foreground text-center text-base max-w-md line-clamp-2",children:g}),t[8]=g,t[9]=v):v=t[9];let b;t[10]!==r||t[11]!==c?.metadata?.vmMap||t[12]!==d||t[13]!==e.id||t[14]!==e.slug||t[15]!==n||t[16]!==f||t[17]!==u?(b=f&&o.jsx("div",{className:"mt-2",children:o.jsx(id,{orgId:e.id,orgSlug:e.slug,userId:u,connectionId:d.connectionId,owner:d.owner,repo:d.name,vmMap:c?.metadata?.vmMap,value:r??void 0,onChange:n})}),t[10]=r,t[11]=c?.metadata?.vmMap,t[12]=d,t[13]=e.id,t[14]=e.slug,t[15]=n,t[16]=f,t[17]=u,t[18]=b):b=t[18];let S;t[19]!==m||t[20]!==p||t[21]!==v||t[22]!==b?(S=o.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 md:gap-4 text-center",children:[m,p,v,b]}),t[19]=m,t[20]=p,t[21]=v,t[22]=b,t[23]=S):S=t[23];let x;t[24]===Symbol.for("react.memo_cache_sentinel")?(x=o.jsx("div",{className:"w-full max-w-3xl mx-auto",children:o.jsx(je.IceBreakers,{})}),t[24]=x):x=t[24];let y;return t[25]!==S?(y=o.jsxs("div",{className:"h-full w-full flex flex-col items-center justify-center gap-6 px-4",children:[S,x]}),t[25]=S,t[26]=y):y=t[26],y}function nd(){const t=H.c(26),{org:e}=ve(),s=Rc(),{isChatEmpty:i}=Zo(),[r,n]=P.useState("chat"),a=Ul();if(s.length===0){let S;return t[0]===Symbol.for("react.memo_cache_sentinel")?(S=o.jsx(je,{className:"animate-in fade-in-0 duration-200",children:o.jsx(je.Main,{className:"flex flex-col items-center",children:o.jsx(je.EmptyState,{children:o.jsx(je.NoAiProviderEmptyState,{})})})}),t[0]=S):S=t[0],S}let l;t[1]!==a.hasDecoKey||t[2]!==a.hasOnlyDecoProvider||t[3]!==a.isLoading||t[4]!==a.isZeroBalance||t[5]!==i||t[6]!==e?(l=a.hasDecoKey&&a.isZeroBalance&&a.hasOnlyDecoProvider&&!a.isLoading&&i&&!Vl(e.id),t[1]=a.hasDecoKey,t[2]=a.hasOnlyDecoProvider,t[3]=a.isLoading,t[4]=a.isZeroBalance,t[5]=i,t[6]=e,t[7]=l):l=t[7];const h=l;let c;t[8]!==h?(c=h&&o.jsx(je.CreditsEmptyState,{}),t[8]=h,t[9]=c):c=t[9];const u=r!=="chat"?"opacity-0 pointer-events-none":"opacity-100";let d;t[10]!==u?(d=re("absolute inset-0 flex flex-col transition-opacity duration-100 ease-out",u),t[10]=u,t[11]=d):d=t[11];let f;t[12]!==i?(f=i?o.jsxs(o.Fragment,{children:[o.jsx(je.Main,{children:o.jsx(rd,{})}),o.jsx(je.Footer,{children:o.jsx(je.Input,{onOpenContextPanel:()=>n("context")})})]}):o.jsxs(o.Fragment,{children:[o.jsx(je.Main,{children:o.jsx(je.Messages,{})}),o.jsx(je.Footer,{children:o.jsx(je.Input,{onOpenContextPanel:()=>n("context")})})]}),t[12]=i,t[13]=f):f=t[13];let _;t[14]!==d||t[15]!==f?(_=o.jsx("div",{className:d,children:f}),t[14]=d,t[15]=f,t[16]=_):_=t[16];const m=r==="context"?"opacity-100":"opacity-0 pointer-events-none";let p;t[17]!==m?(p=re("absolute inset-0 flex flex-col transition-opacity duration-100 ease-out",m),t[17]=m,t[18]=p):p=t[18];let g;t[19]===Symbol.for("react.memo_cache_sentinel")?(g=o.jsx(Oh,{back:!0,onClose:()=>n("chat")}),t[19]=g):g=t[19];let v;t[20]!==p?(v=o.jsx("div",{className:p,children:g}),t[20]=p,t[21]=v):v=t[21];let b;return t[22]!==c||t[23]!==_||t[24]!==v?(b=o.jsxs(je,{className:"relative overflow-hidden animate-in fade-in-0 duration-200",children:[c,_,v]}),t[22]=c,t[23]=_,t[24]=v,t[25]=b):b=t[25],b}function Ea(){const t=H.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=o.jsx(je.Skeleton,{}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=o.jsx(Ht,{fallback:e,children:o.jsx(P.Suspense,{fallback:o.jsx(je.Skeleton,{}),children:o.jsx(nd,{})})}),t[1]=s):s=t[1],s}async function od(t,e,s){const i=await t.callTool({name:e,arguments:s});if(i.isError){const r=i.content?.[0]?.text??`Tool ${e} failed without a message`;throw new Error(r)}return i}const Ta=["VM_START"],Qs=new Map,ad=t=>`${t.virtualMcpId}::${t.branch??""}`,Fi=new Set,gi={mark:(t,e)=>Fi.add(`${t}::${e}`),clear:(t,e)=>Fi.delete(`${t}::${e}`),isStopped:(t,e)=>Fi.has(`${t}::${e}`)};function nn(t){const e=ds();return Vo({mutationKey:Ta,mutationFn:async s=>{s.branch&&gi.clear(s.virtualMcpId,s.branch);const i=ad(s),r=Qs.get(i);if(r)return r;const n=(async()=>(await od(t,"VM_START",s)).structuredContent)();Qs.set(i,n);try{return await n}finally{Qs.get(i)===n&&Qs.delete(i)}},onSuccess:()=>{oi(e)}})}function Ra(t,e){const s=H.c(3);let i;return s[0]!==e||s[1]!==t?(i={mutationKey:Ta,predicate:n=>{if(!t)return!1;const a=n.state.variables;return!a||a.virtualMcpId!==t?!1:(a.branch??"")===(e??"")}},s[0]=e,s[1]=t,s[2]=i):i=s[2],Rh(i)>0}const ld={settings:bc,automations:xc,env:pi,preview:tc,git:Rs};function Pn(t){const e=Ni(t);if(e.type==="icon"){const s=ji(e.name);return s?{kind:"component",Component:s}:null}return e.type==="url"?{kind:"url",src:e.url}:null}function Hi(t){if(t.kind==="system")return{kind:"component",Component:ld[t.tabId]};const e=Pn(t.iconUrl);if(e)return e;if(!t.appId)return{kind:"fallback"};const s=t.connections.find(r=>r.id===t.appId);if(!s)return{kind:"fallback"};const i=Pn(s.icon);return i||{kind:"fallback"}}function cd(t){const{org:e}=ve(),s=He({connectionId:Pt,orgId:e.id,orgSlug:e.slug}),{data:i}=Al({queryKey:Bs.threadMetadata(t),queryFn:async()=>{if(!s||!t)return null;try{const r=await s.callTool({name:"COLLECTION_THREADS_GET",arguments:{id:t}});return(r.structuredContent??r).item?.metadata??null}catch{return null}},staleTime:3e4});return i}function Da(t){const e=H.c(8),s=Bt();let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={strict:!1},e[0]=i):i=e[0];const r=Jr(i),n=Ct(t.virtualMcpId),a=cd(t.taskId),{currentBranch:l}=vt(),h=n?.metadata?.ui??null,c=h?.layout??null,u=c?.tabs??[],d=h?.pinnedViews??[],f=a?.expanded_tools??[],_=!!(n&&Kt(n));let m;e[1]===Symbol.for("react.memo_cache_sentinel")?(m={includeVirtual:!0},e[1]=m):m=e[1];const p=Ti(m),{activeTab:g,mainOpen:v}=oc({mainParam:r.main,metadata:c?{defaultMainView:c.defaultMainView??null,tabs:u.map(hd)}:null}),b=Qo(g),S=[];_&&(S.push({id:"preview",title:"Preview"}),S.push({id:"env",title:"Terminal"}),S.push({id:"git",title:l??"git"})),S.push({id:"settings",title:"Settings"}),S.push({id:"automations",title:"Automations"});const x=new Map;for(const E of f){const M=yn(E.appId,E.toolName);x.set(M,{id:M,title:E.toolName,appId:E.appId,iconKey:E.toolName})}for(const E of d){const M=yn(E.connectionId,E.toolName);x.set(M,{id:M,title:E.label||E.toolName,appId:E.connectionId,iconKey:E.toolName,iconUrl:E.icon??null})}let y;e[2]!==p?(y=E=>({id:E.id,title:E.title,kind:"agent",icon:Hi({tabId:E.id,kind:"agent",appId:E.view.appId,connections:p})}),e[2]=p,e[3]=y):y=e[3];const j=[...u.map(y),...Array.from(x.values()).map(E=>({id:E.id,title:E.title,kind:"expanded",icon:Hi({tabId:E.iconKey,kind:"expanded",appId:E.appId,iconUrl:E.iconUrl,connections:p})})),...S.map(E=>({id:E.id,title:E.title,kind:"system",icon:Hi({tabId:E.id,kind:"system",connections:p})}))];let C;return e[4]!==g||e[5]!==v||e[6]!==s?(C=E=>{const M=ac({clickedId:E,activeTab:g,mainOpen:v});s({to:".",search:A=>({...A,main:M}),replace:!0})},e[4]=g,e[5]=v,e[6]=s,e[7]=C):C=e[7],{activeTab:g,mainOpen:v,setActiveTab:C,systemTabs:S,layoutTabs:u,expandedTools:f,automationTabParsed:b,tabs:j}}function hd(t){return{id:t.id}}function Ma(t){const{managerAgentId:e,managerName:s,kind:i,id:r,instructions:n}=t,a=` to improve the instructions of ${i} "${r}". Here are its current instructions.
|
|
3
3
|
<current_instructions>${n}</current_instructions>`;return{type:"doc",content:[{type:"paragraph",content:[{type:"text",text:"Use "},{type:"mention",attrs:{id:e,name:s,char:"@",metadata:{agentId:e,title:s}}},{type:"text",text:a}]}]}}function dd(t){const e=H.c(84),{value:s,onChange:i,onColorChange:r,name:n,size:a,className:l,avatarClassName:h,showHoverOverlay:c,disabled:u}=t,d=a===void 0?"lg":a,f=c===void 0?!0:c,_=u===void 0?!1:u,[m,p]=P.useState(!1),[g,v]=P.useState("icons"),[b,S]=P.useState(""),[x,y]=P.useState("blue");let j;e[0]!==s?(j=Ni(s),e[0]=s,e[1]=j):j=e[1];const C=j,T=C.type==="icon"||C.type==="url"&&C.color?C.color:x;let E;e[2]!==i||e[3]!==T?(E=Q=>{i(Oi(Q,T))},e[2]=i,e[3]=T,e[4]=E):E=e[4];const M=E;let A;e[5]!==i||e[6]!==r||e[7]!==C.name||e[8]!==C.type||e[9]!==C.url?(A=Q=>{y(Q),r?.(Q),C.type==="icon"?i(Oi(C.name,Q)):C.type==="url"&&i(Nn(C.url,Q))},e[5]=i,e[6]=r,e[7]=C.name,e[8]=C.type,e[9]=C.url,e[10]=A):A=e[10];const I=A;let k;e[11]!==i||e[12]!==T?(k=Q=>{i(Nn(Q,T)),p(!1)},e[11]=i,e[12]=T,e[13]=k):k=e[13];const w=k;let N;e[14]!==i||e[15]!==T?(N=()=>{const Q=en(),Ne=Q[Math.floor(Math.random()*Q.length)];i(Oi(Ne,T))},e[14]=i,e[15]=T,e[16]=N):N=e[16];const R=N;let D,B,z,G,W,F,Z,q;if(e[17]!==l||e[18]!==_||e[19]!==m||e[20]!==d){const Q={xs:"rounded-md",sm:"rounded-lg","sm+":"rounded-xl",md:"rounded-xl",lg:"rounded-2xl",xl:"rounded-2xl"};B=Vs,F=_?!1:m,Z=p,D=Ws,W=!0,q="button",z=_,G=re("relative group overflow-hidden",_?"cursor-default opacity-50":"cursor-pointer",Q[d],l),e[17]=l,e[18]=_,e[19]=m,e[20]=d,e[21]=D,e[22]=B,e[23]=z,e[24]=G,e[25]=W,e[26]=F,e[27]=Z,e[28]=q}else D=e[21],B=e[22],z=e[23],G=e[24],W=e[25],F=e[26],Z=e[27],q=e[28];let $;e[29]!==h||e[30]!==n||e[31]!==d||e[32]!==s?($=o.jsx(jn,{icon:s,name:n,size:d,className:h}),e[29]=h,e[30]=n,e[31]=d,e[32]=s,e[33]=$):$=e[33];let U;e[34]!==_||e[35]!==f?(U=f&&!_&&o.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/50 opacity-0 group-hover:opacity-100 transition-opacity",children:o.jsx(sa,{size:16,className:"text-white"})}),e[34]=_,e[35]=f,e[36]=U):U=e[36];let V;e[37]!==z||e[38]!==G||e[39]!==$||e[40]!==U||e[41]!==q?(V=o.jsxs("button",{type:q,disabled:z,className:G,children:[$,U]}),e[37]=z,e[38]=G,e[39]=$,e[40]=U,e[41]=q,e[42]=V):V=e[42];let se;e[43]!==D||e[44]!==W||e[45]!==V?(se=o.jsx(D,{asChild:W,children:V}),e[43]=D,e[44]=W,e[45]=V,e[46]=se):se=e[46];let L;e[47]!==n||e[48]!==s?(L=o.jsx("div",{className:"flex items-center justify-center py-4",children:o.jsx(jn,{icon:s,name:n,size:"xl"})}),e[47]=n,e[48]=s,e[49]=L):L=e[49];let te;e[50]===Symbol.for("react.memo_cache_sentinel")?(te=()=>v("icons"),e[50]=te):te=e[50];const ie=g==="icons"?"border-foreground text-foreground":"border-transparent text-muted-foreground hover:text-foreground";let ee;e[51]!==ie?(ee=re("px-3 py-2 text-sm font-medium border-b-2 -mb-px transition-colors",ie),e[51]=ie,e[52]=ee):ee=e[52];let Y;e[53]!==ee?(Y=o.jsx("button",{type:"button",onClick:te,className:ee,children:"Icons"}),e[53]=ee,e[54]=Y):Y=e[54];let le;e[55]===Symbol.for("react.memo_cache_sentinel")?(le=()=>v("upload"),e[55]=le):le=e[55];const ue=g==="upload"?"border-foreground text-foreground":"border-transparent text-muted-foreground hover:text-foreground";let de;e[56]!==ue?(de=re("px-3 py-2 text-sm font-medium border-b-2 -mb-px transition-colors",ue),e[56]=ue,e[57]=de):de=e[57];let fe;e[58]!==de?(fe=o.jsx("button",{type:"button",onClick:le,className:de,children:"Upload"}),e[58]=de,e[59]=fe):fe=e[59];let _e;e[60]===Symbol.for("react.memo_cache_sentinel")?(_e=o.jsx("div",{className:"flex-1"}),e[60]=_e):_e=e[60];let Ue;e[61]!==Y||e[62]!==fe?(Ue=o.jsxs("div",{className:"flex items-center border-b border-border px-3",children:[Y,fe,_e]}),e[61]=Y,e[62]=fe,e[63]=Ue):Ue=e[63];let $e;e[64]!==I||e[65]!==R||e[66]!==M||e[67]!==w||e[68]!==C.name||e[69]!==C.type||e[70]!==b||e[71]!==T||e[72]!==g?($e=g==="icons"?o.jsx(_d,{search:b,onSearchChange:S,selectedColor:T,onColorChange:I,onSelectIcon:M,onRandom:R,currentIconName:C.type==="icon"?C.name:null}):o.jsx(pd,{onUpload:w}),e[64]=I,e[65]=R,e[66]=M,e[67]=w,e[68]=C.name,e[69]=C.type,e[70]=b,e[71]=T,e[72]=g,e[73]=$e):$e=e[73];let Qe;e[74]!==L||e[75]!==Ue||e[76]!==$e?(Qe=o.jsx(Us,{align:"start",className:"w-80 p-0",onOpenAutoFocus:ud,children:o.jsxs("div",{className:"flex flex-col",children:[L,Ue,$e]})}),e[74]=L,e[75]=Ue,e[76]=$e,e[77]=Qe):Qe=e[77];let at;return e[78]!==B||e[79]!==F||e[80]!==Z||e[81]!==se||e[82]!==Qe?(at=o.jsxs(B,{open:F,onOpenChange:Z,children:[se,Qe]}),e[78]=B,e[79]=F,e[80]=Z,e[81]=se,e[82]=Qe,e[83]=at):at=e[83],at}function ud(t){return t.preventDefault()}function fd(t){const e=H.c(27),{selectedColor:s,onColorChange:i}=t,[r,n]=P.useState(!1);let a,l,h,c,u,d,f;if(e[0]!==r||e[1]!==s){const b=ta(s);l=Vs,d=r,f=n,a=Ws,u=!0,h="button",c=re("h-6 w-6 rounded-full shrink-0 ring-2 ring-offset-2 ring-offset-background transition-all cursor-pointer hover:scale-110",b.dot,"ring-foreground/20"),e[0]=r,e[1]=s,e[2]=a,e[3]=l,e[4]=h,e[5]=c,e[6]=u,e[7]=d,e[8]=f}else a=e[2],l=e[3],h=e[4],c=e[5],u=e[6],d=e[7],f=e[8];let _;e[9]!==h||e[10]!==c?(_=o.jsx("button",{type:h,className:c,title:"Change color"}),e[9]=h,e[10]=c,e[11]=_):_=e[11];let m;e[12]!==a||e[13]!==u||e[14]!==_?(m=o.jsx(a,{asChild:u,children:_}),e[12]=a,e[13]=u,e[14]=_,e[15]=m):m=e[15];let p;e[16]!==i||e[17]!==s?(p=yc.map(b=>o.jsx("button",{type:"button",onClick:()=>{i(b.name),n(!1)},className:re("h-5 w-5 rounded-full transition-all shrink-0 cursor-pointer",b.dot,s===b.name?"ring-2 ring-offset-1 ring-offset-background ring-foreground/30 scale-110":"hover:scale-110"),title:b.name},b.name)),e[16]=i,e[17]=s,e[18]=p):p=e[18];let g;e[19]!==p?(g=o.jsx(Us,{align:"start",side:"right",sideOffset:8,className:"w-auto p-2",onOpenAutoFocus:md,children:o.jsx("div",{className:"grid grid-cols-4 gap-1",children:p})}),e[19]=p,e[20]=g):g=e[20];let v;return e[21]!==l||e[22]!==d||e[23]!==f||e[24]!==m||e[25]!==g?(v=o.jsxs(l,{open:d,onOpenChange:f,children:[m,g]}),e[21]=l,e[22]=d,e[23]=f,e[24]=m,e[25]=g,e[26]=v):v=e[26],v}function md(t){return t.preventDefault()}function _d(t){const e=H.c(44),{search:s,onSearchChange:i,selectedColor:r,onColorChange:n,onSelectIcon:a,onRandom:l,currentIconName:h}=t;let c,u,d,f,_,m,p;if(e[0]!==h||e[1]!==n||e[2]!==l||e[3]!==i||e[4]!==a||e[5]!==s||e[6]!==r){const x=en(),y=ta(r);u=s.trim()?x.filter(I=>{const k=cr(I),w=s.toLowerCase();return k.includes(w)||I.toLowerCase().includes(w)}):x,m="flex flex-col";let j;e[14]===Symbol.for("react.memo_cache_sentinel")?(j=o.jsx(Na,{size:14,className:"absolute left-2 top-1/2 -translate-y-1/2 text-muted-foreground pointer-events-none"}),e[14]=j):j=e[14];let C;e[15]!==i?(C=I=>i(I.target.value),e[15]=i,e[16]=C):C=e[16];let T;e[17]!==s||e[18]!==C?(T=o.jsxs("div",{className:"relative flex-1",children:[j,o.jsx(_s,{value:s,onChange:C,placeholder:"Filter...",className:"h-8 text-xs pl-7"})]}),e[17]=s,e[18]=C,e[19]=T):T=e[19];let E;e[20]===Symbol.for("react.memo_cache_sentinel")?(E=o.jsx(Sc,{size:14,className:"text-muted-foreground"}),e[20]=E):E=e[20];let M;e[21]!==l?(M=o.jsx("button",{type:"button",onClick:l,className:"h-8 w-8 flex items-center justify-center rounded-md border border-border hover:bg-accent transition-colors shrink-0",title:"Random icon",children:E}),e[21]=l,e[22]=M):M=e[22];let A;e[23]!==n||e[24]!==r?(A=o.jsx(fd,{selectedColor:r,onColorChange:n}),e[23]=n,e[24]=r,e[25]=A):A=e[25],e[26]!==M||e[27]!==A||e[28]!==T?(p=o.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",children:[T,M,A]}),e[26]=M,e[27]=A,e[28]=T,e[29]=p):p=e[29],c=ka,_="h-56",d="grid grid-cols-9 gap-0.5 px-2 pb-2",f=u.map(I=>{const k=ji(I);return k?o.jsx("button",{type:"button",onClick:()=>a(I),className:re("h-8 w-8 flex items-center justify-center rounded-md transition-colors cursor-pointer",h===I?re(y.bg,y.text):re(y.text,"hover:bg-accent")),title:I,children:o.jsx(k,{size:18})},I):null}),e[0]=h,e[1]=n,e[2]=l,e[3]=i,e[4]=a,e[5]=s,e[6]=r,e[7]=c,e[8]=u,e[9]=d,e[10]=f,e[11]=_,e[12]=m,e[13]=p}else c=e[7],u=e[8],d=e[9],f=e[10],_=e[11],m=e[12],p=e[13];let g;e[30]!==d||e[31]!==f?(g=o.jsx("div",{className:d,children:f}),e[30]=d,e[31]=f,e[32]=g):g=e[32];let v;e[33]!==u.length?(v=u.length===0&&o.jsx("div",{className:"flex items-center justify-center py-8 text-sm text-muted-foreground",children:"No icons found"}),e[33]=u.length,e[34]=v):v=e[34];let b;e[35]!==c||e[36]!==_||e[37]!==g||e[38]!==v?(b=o.jsxs(c,{className:_,children:[g,v]}),e[35]=c,e[36]=_,e[37]=g,e[38]=v,e[39]=b):b=e[39];let S;return e[40]!==m||e[41]!==p||e[42]!==b?(S=o.jsxs("div",{className:m,children:[p,b]}),e[40]=m,e[41]=p,e[42]=b,e[43]=S):S=e[43],S}function pd(t){const e=H.c(27),{onUpload:s}=t,i=P.useRef(null);let r;e[0]!==s?(r=j=>{const C=j.target.files?.[0];if(!C)return;if(C.size>2097152){pe.error("Image must be smaller than 2MB"),j.target.value="";return}const T=new FileReader;T.onerror=()=>{pe.error("Failed to read image file"),i.current&&(i.current.value="")},T.onloadend=()=>{T.readyState===FileReader.DONE&&T.result&&s(T.result),i.current&&(i.current.value="")},T.readAsDataURL(C)},e[0]=s,e[1]=r):r=e[1];const n=r,[a,l]=P.useState("");let h;e[2]!==s||e[3]!==a?(h=()=>{const j=a.trim();j&&(s(j),l(""))},e[2]=s,e[3]=a,e[4]=h):h=e[4];const c=h;let u;e[5]!==n?(u=o.jsx("input",{type:"file",ref:i,className:"hidden",accept:"image/*",onChange:n}),e[5]=n,e[6]=u):u=e[6];let d;e[7]===Symbol.for("react.memo_cache_sentinel")?(d=()=>i.current?.click(),e[7]=d):d=e[7];let f;e[8]===Symbol.for("react.memo_cache_sentinel")?(f=o.jsxs("button",{type:"button",onClick:d,className:"h-24 rounded-lg border-2 border-dashed border-border hover:border-foreground/50 hover:bg-accent/50 transition-colors flex flex-col items-center justify-center gap-2 text-muted-foreground hover:text-foreground",children:[o.jsx(sc,{size:20}),o.jsx("span",{className:"text-xs",children:"Click to upload an image (max 2MB)"})]}),e[8]=f):f=e[8];let _;e[9]===Symbol.for("react.memo_cache_sentinel")?(_=o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-xs text-muted-foreground",children:"or"}),o.jsx("div",{className:"flex-1 h-px bg-border"})]}),e[9]=_):_=e[9];let m;e[10]===Symbol.for("react.memo_cache_sentinel")?(m=j=>l(j.target.value),e[10]=m):m=e[10];let p;e[11]!==c?(p=j=>{j.key==="Enter"&&(j.preventDefault(),c())},e[11]=c,e[12]=p):p=e[12];let g;e[13]!==a||e[14]!==p?(g=o.jsx(_s,{value:a,onChange:m,placeholder:"Paste image URL...",className:"h-8 text-xs flex-1",onKeyDown:p}),e[13]=a,e[14]=p,e[15]=g):g=e[15];let v;e[16]!==a?(v=a.trim(),e[16]=a,e[17]=v):v=e[17];const b=!v;let S;e[18]!==c||e[19]!==b?(S=o.jsx(oe,{variant:"outline",size:"sm",className:"h-8 px-3 text-xs shrink-0",onClick:c,disabled:b,children:"Apply"}),e[18]=c,e[19]=b,e[20]=S):S=e[20];let x;e[21]!==S||e[22]!==g?(x=o.jsxs("div",{className:"flex items-center gap-1.5",children:[g,S]}),e[21]=S,e[22]=g,e[23]=x):x=e[23];let y;return e[24]!==x||e[25]!==u?(y=o.jsxs("div",{className:"flex flex-col gap-3 p-4",children:[u,f,_,x]}),e[24]=x,e[25]=u,e[26]=y):y=e[26],y}function gd(t){const e=H.c(5),{value:s}=t;let i;if(e[0]!==s){i=Symbol.for("react.early_return_sentinel");e:{const n=Ni(s);if(n.type==="icon"){const a=ji(n.name);if(a){let l;e[2]!==a?(l=o.jsx(a,{size:16,className:"text-muted-foreground"}),e[2]=a,e[3]=l):l=e[3],i=l;break e}}}e[0]=s,e[1]=i}else i=e[1];if(i!==Symbol.for("react.early_return_sentinel"))return i;let r;return e[4]===Symbol.for("react.memo_cache_sentinel")?(r=o.jsx(Oc,{size:16,className:"text-muted-foreground"}),e[4]=r):r=e[4],r}function vd(t){const e=H.c(66),{value:s,onChange:i,className:r,disabled:n}=t,[a,l]=P.useState(!1),[h,c]=P.useState("");let u;e[0]!==s?(u=Ni(s),e[0]=s,e[1]=u):u=e[1];const d=u,f=d.type==="icon"?d.name:null;let _,m,p,g,v,b,S,x,y,j,C,T,E,M,A;if(e[2]!==r||e[3]!==f||e[4]!==n||e[5]!==i||e[6]!==a||e[7]!==h||e[8]!==s){const B=en();g=h.trim()?B.filter($=>{const U=h.toLowerCase();return cr($).includes(U)||$.toLowerCase().includes(U)}):B,p=Vs,v=n?!1:a,b=l;const z=n?"cursor-default opacity-50":"cursor-pointer hover:bg-accent";let G;e[24]!==r||e[25]!==z?(G=re("size-7 shrink-0 rounded-md transition-colors flex items-center justify-center",z,r),e[24]=r,e[25]=z,e[26]=G):G=e[26];let W;e[27]!==s?(W=o.jsx(gd,{value:s}),e[27]=s,e[28]=W):W=e[28],e[29]!==n||e[30]!==G||e[31]!==W?(S=o.jsx(Ws,{asChild:!0,children:o.jsx("button",{type:"button",disabled:n,className:G,children:W})}),e[29]=n,e[30]=G,e[31]=W,e[32]=S):S=e[32],m=Us,E="start",M="w-64 p-0",A=xd,C="flex flex-col";let F;e[33]===Symbol.for("react.memo_cache_sentinel")?(F=o.jsx(Na,{size:14,className:"absolute left-2 top-1/2 -translate-y-1/2 text-muted-foreground pointer-events-none"}),e[33]=F):F=e[33];let Z;e[34]===Symbol.for("react.memo_cache_sentinel")?(Z=$=>c($.target.value),e[34]=Z):Z=e[34],e[35]!==h?(T=o.jsx("div",{className:"px-2 py-2",children:o.jsxs("div",{className:"relative",children:[F,o.jsx(_s,{value:h,onChange:Z,placeholder:"Filter...",className:"h-7 text-xs pl-7"})]})}),e[35]=h,e[36]=T):T=e[36],_=ka,j="h-48",x="grid grid-cols-8 gap-0.5 px-2 pb-2";let q;e[37]!==f||e[38]!==i?(q=$=>{const U=ji($);return U?o.jsx("button",{type:"button",onClick:()=>{i(`icon://${$}`),l(!1)},className:re("h-7 w-7 flex items-center justify-center rounded-md transition-colors cursor-pointer",f===$?"bg-accent text-foreground":"text-muted-foreground hover:bg-accent hover:text-foreground"),title:cr($),children:o.jsx(U,{size:16})},$):null},e[37]=f,e[38]=i,e[39]=q):q=e[39],y=g.map(q),e[2]=r,e[3]=f,e[4]=n,e[5]=i,e[6]=a,e[7]=h,e[8]=s,e[9]=_,e[10]=m,e[11]=p,e[12]=g,e[13]=v,e[14]=b,e[15]=S,e[16]=x,e[17]=y,e[18]=j,e[19]=C,e[20]=T,e[21]=E,e[22]=M,e[23]=A}else _=e[9],m=e[10],p=e[11],g=e[12],v=e[13],b=e[14],S=e[15],x=e[16],y=e[17],j=e[18],C=e[19],T=e[20],E=e[21],M=e[22],A=e[23];let I;e[40]!==x||e[41]!==y?(I=o.jsx("div",{className:x,children:y}),e[40]=x,e[41]=y,e[42]=I):I=e[42];let k;e[43]!==g.length?(k=g.length===0&&o.jsx("div",{className:"flex items-center justify-center py-6 text-xs text-muted-foreground",children:"No icons found"}),e[43]=g.length,e[44]=k):k=e[44];let w;e[45]!==_||e[46]!==I||e[47]!==k||e[48]!==j?(w=o.jsxs(_,{className:j,children:[I,k]}),e[45]=_,e[46]=I,e[47]=k,e[48]=j,e[49]=w):w=e[49];let N;e[50]!==w||e[51]!==C||e[52]!==T?(N=o.jsxs("div",{className:C,children:[T,w]}),e[50]=w,e[51]=C,e[52]=T,e[53]=N):N=e[53];let R;e[54]!==m||e[55]!==N||e[56]!==E||e[57]!==M||e[58]!==A?(R=o.jsx(m,{align:E,className:M,onOpenAutoFocus:A,children:N}),e[54]=m,e[55]=N,e[56]=E,e[57]=M,e[58]=A,e[59]=R):R=e[59];let D;return e[60]!==p||e[61]!==v||e[62]!==b||e[63]!==S||e[64]!==R?(D=o.jsxs(p,{open:v,onOpenChange:b,children:[S,R]}),e[60]=p,e[61]=v,e[62]=b,e[63]=S,e[64]=R,e[65]=D):D=e[65],D}function xd(t){return t.preventDefault()}function ci(){const t=H.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=o.jsx("div",{className:"flex items-center justify-center h-32",children:o.jsx(Ie,{className:"animate-spin text-muted-foreground",size:24})}),t[0]=e):e=t[0],e}function Wi(t){return({error:e})=>e?.message?.includes("Method not found")||e?.code===-32601?o.jsx("div",{className:"flex-1 overflow-auto px-4 py-3 space-y-1",children:o.jsx("div",{className:"flex items-center justify-center h-32 text-sm text-muted-foreground",children:t})}):o.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center h-full p-6 text-center space-y-4",children:[o.jsx("div",{className:"bg-destructive/10 p-3 rounded-full",children:o.jsx(Bl,{className:"h-6 w-6 text-destructive"})}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("h3",{className:"text-lg font-medium",children:"Something went wrong"}),o.jsx("p",{className:"text-sm text-muted-foreground max-w-xs mx-auto",children:e?.message?e.message.length>200?`${e.message.slice(0,200)}...`:e.message:"An unexpected error occurred"})]})]})}function bd(t){const e=H.c(23),{item:s,isSelected:i,onToggle:r,disabled:n}=t,a=n?"cursor-not-allowed opacity-50":"cursor-pointer",l=i?"bg-accent/25":"hover:bg-muted/50";let h;e[0]!==a||e[1]!==l?(h=re("flex items-start gap-3 p-4 rounded-lg transition-colors",a,l),e[0]=a,e[1]=l,e[2]=h):h=e[2];let c;e[3]!==s.name?(c=o.jsx("p",{className:"text-sm font-medium leading-none truncate",children:s.name}),e[3]=s.name,e[4]=c):c=e[4];let u;e[5]!==s.tags?(u=s.tags&&o.jsx("span",{className:"shrink-0",children:s.tags}),e[5]=s.tags,e[6]=u):u=e[6];let d;e[7]!==c||e[8]!==u?(d=o.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[c,u]}),e[7]=c,e[8]=u,e[9]=d):d=e[9];let f;e[10]!==s.description?(f=s.description&&o.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2",children:s.description}),e[10]=s.description,e[11]=f):f=e[11];let _;e[12]!==d||e[13]!==f?(_=o.jsxs("div",{className:"flex-1 min-w-0 space-y-2",children:[d,f]}),e[12]=d,e[13]=f,e[14]=_):_=e[14];let m;e[15]!==n||e[16]!==i||e[17]!==r?(m=o.jsx(dh,{checked:i,onCheckedChange:r,disabled:n,className:"mt-0.5"}),e[15]=n,e[16]=i,e[17]=r,e[18]=m):m=e[18];let p;return e[19]!==h||e[20]!==_||e[21]!==m?(p=o.jsxs("label",{className:h,children:[_,m]}),e[19]=h,e[20]=_,e[21]=m,e[22]=p):p=e[22],p}function on(t){const e=H.c(13),{items:s,selections:i,onToggle:r,emptyMessage:n,disabled:a}=t;let l,h,c;if(e[0]!==a||e[1]!==n||e[2]!==s||e[3]!==r||e[4]!==i){c=Symbol.for("react.early_return_sentinel");e:{const d=s.map(Sd);if(s.length===0){let f;e[8]!==n?(f=o.jsx("div",{className:"flex-1 overflow-auto px-4 py-3 space-y-1",children:o.jsx("div",{className:"flex items-center justify-center h-32 text-sm text-muted-foreground",children:n})}),e[8]=n,e[9]=f):f=e[9],c=f;break e}l="flex-1 overflow-auto px-4 py-3 space-y-1",h=s.map(f=>o.jsx(bd,{item:f,isSelected:i===null||i?.includes(f.id),onToggle:()=>r(f.id,d),disabled:a},f.id))}e[0]=a,e[1]=n,e[2]=s,e[3]=r,e[4]=i,e[5]=l,e[6]=h,e[7]=c}else l=e[5],h=e[6],c=e[7];if(c!==Symbol.for("react.early_return_sentinel"))return c;let u;return e[10]!==l||e[11]!==h?(u=o.jsx("div",{className:l,children:h}),e[10]=l,e[11]=h,e[12]=u):u=e[12],u}function Sd(t){return t.id}function yd(t){const e=H.c(13),{connectionId:s,selections:i,onToggle:r,disabled:n}=t,{org:a}=ve();let l;e[0]!==s||e[1]!==a.id||e[2]!==a.slug?(l={connectionId:s,orgId:a.id,orgSlug:a.slug},e[0]=s,e[1]=a.id,e[2]=a.slug,e[3]=l):l=e[3];const h=He(l);let c;e[4]!==h?(c={client:h},e[4]=h,e[5]=c):c=e[5];const{data:u}=Tc(c);let d;e[6]!==u.tools?(d=u.tools.map(wd),e[6]=u.tools,e[7]=d):d=e[7];const f=d;let _;return e[8]!==n||e[9]!==f||e[10]!==r||e[11]!==i?(_=o.jsx(on,{items:f,selections:i,onToggle:r,emptyMessage:"No tools available",disabled:n}),e[8]=n,e[9]=f,e[10]=r,e[11]=i,e[12]=_):_=e[12],_}function wd(t){return{id:t.name,name:t.name,description:t.description,tags:o.jsx(sh,{annotations:t.annotations,_meta:t._meta})}}function Cd(t){const e=H.c(13),{connectionId:s,selections:i,onToggle:r,disabled:n}=t,{org:a}=ve();let l;e[0]!==s||e[1]!==a.id||e[2]!==a.slug?(l={connectionId:s,orgId:a.id,orgSlug:a.slug},e[0]=s,e[1]=a.id,e[2]=a.slug,e[3]=l):l=e[3];const h=He(l);let c;e[4]!==h?(c={client:h},e[4]=h,e[5]=c):c=e[5];const{data:u}=Qc(c);let d;e[6]!==u.resources?(d=u.resources.map(kd),e[6]=u.resources,e[7]=d):d=e[7];const f=d;let _;return e[8]!==n||e[9]!==f||e[10]!==r||e[11]!==i?(_=o.jsx(on,{items:f,selections:i,onToggle:r,emptyMessage:"No resources available",disabled:n}),e[8]=n,e[9]=f,e[10]=r,e[11]=i,e[12]=_):_=e[12],_}function kd(t){return{id:t.name||t.uri,name:t.name||t.uri,description:t.description}}function Nd(t){const e=H.c(13),{connectionId:s,selections:i,onToggle:r,disabled:n}=t,{org:a}=ve();let l;e[0]!==s||e[1]!==a.id||e[2]!==a.slug?(l={connectionId:s,orgId:a.id,orgSlug:a.slug},e[0]=s,e[1]=a.id,e[2]=a.slug,e[3]=l):l=e[3];const h=He(l);let c;e[4]!==h?(c={client:h},e[4]=h,e[5]=c):c=e[5];const{data:u}=uh(c);let d;e[6]!==u.prompts?(d=u.prompts.map(jd),e[6]=u.prompts,e[7]=d):d=e[7];const f=d;let _;return e[8]!==n||e[9]!==f||e[10]!==r||e[11]!==i?(_=o.jsx(on,{items:f,selections:i,onToggle:r,emptyMessage:"No prompts available",disabled:n}),e[8]=n,e[9]=f,e[10]=r,e[11]=i,e[12]=_):_=e[12],_}function jd(t){return{id:t.name,name:t.name,description:t.description}}function Ed(t){const e=H.c(54),{currentConnection:s,activeTab:i,selectedId:r,formData:n,toggleTool:a,toggleResource:l,togglePrompt:h,toggleAllTools:c,toggleAllResources:u,toggleAllPrompts:d,onTabChange:f}=t,_=n[r],m=i==="tools"?_?.tools===null:i==="resources"?_?.resources===null:_?.prompts===null;let p;e[0]!==i||e[1]!==r||e[2]!==d||e[3]!==u||e[4]!==c?(p=()=>{i==="tools"?c(r):i==="resources"?u(r):d(r)},e[0]=i,e[1]=r,e[2]=d,e[3]=u,e[4]=c,e[5]=p):p=e[5];const g=p;let v;e[6]!==s.icon||e[7]!==s.title?(v=o.jsx(us,{icon:s.icon,name:s.title,size:"sm",className:"shrink-0"}),e[6]=s.icon,e[7]=s.title,e[8]=v):v=e[8];let b;e[9]!==s.title?(b=o.jsx("h2",{className:"text-base font-semibold truncate",children:s.title}),e[9]=s.title,e[10]=b):b=e[10];let S;e[11]!==s.description?(S=s.description&&o.jsx("p",{className:"text-xs text-muted-foreground truncate",children:s.description}),e[11]=s.description,e[12]=S):S=e[12];let x;e[13]!==b||e[14]!==S?(x=o.jsxs("div",{className:"flex-1 min-w-0",children:[b,S]}),e[13]=b,e[14]=S,e[15]=x):x=e[15];let y;e[16]!==v||e[17]!==x?(y=o.jsx("div",{className:"px-6 pt-5 pb-4 shrink-0",children:o.jsxs("div",{className:"flex items-center gap-3",children:[v,x]})}),e[16]=v,e[17]=x,e[18]=y):y=e[18];let j;e[19]===Symbol.for("react.memo_cache_sentinel")?(j=[{id:"tools",label:"Tools"},{id:"resources",label:"Resources"},{id:"prompts",label:"Prompts"}],e[19]=j):j=e[19];let C;e[20]!==f?(C=D=>f(D),e[20]=f,e[21]=C):C=e[21];let T;e[22]!==i||e[23]!==C?(T=o.jsx(hh,{tabs:j,activeTab:i,onTabChange:C}),e[22]=i,e[23]=C,e[24]=T):T=e[24];const E=m?"Deselect all":"Select all";let M;e[25]!==g||e[26]!==E?(M=o.jsx("button",{type:"button",onClick:g,className:"text-xs text-muted-foreground hover:text-foreground transition-colors",children:E}),e[25]=g,e[26]=E,e[27]=M):M=e[27];let A;e[28]!==M||e[29]!==T?(A=o.jsxs("div",{className:"flex items-center justify-between px-6 py-3 border-t border-border shrink-0",children:[T,M]}),e[28]=M,e[29]=T,e[30]=A):A=e[30];let I;e[31]!==i||e[32]!==n||e[33]!==r||e[34]!==a?(I=i==="tools"&&o.jsx(Ht,{fallback:Wi("Tools not supported by this server"),children:o.jsx(P.Suspense,{fallback:o.jsx(ci,{}),children:o.jsx(yd,{connectionId:r,selections:n[r]?n[r].tools:[],onToggle:(D,B)=>a(r,D,B)})})}),e[31]=i,e[32]=n,e[33]=r,e[34]=a,e[35]=I):I=e[35];let k;e[36]!==i||e[37]!==n||e[38]!==r||e[39]!==l?(k=i==="resources"&&o.jsx(Ht,{fallback:Wi("Resources not supported by this server"),children:o.jsx(P.Suspense,{fallback:o.jsx(ci,{}),children:o.jsx(Cd,{connectionId:r,selections:n[r]?n[r].resources:[],onToggle:(D,B)=>l(r,D,B)})})}),e[36]=i,e[37]=n,e[38]=r,e[39]=l,e[40]=k):k=e[40];let w;e[41]!==i||e[42]!==n||e[43]!==r||e[44]!==h?(w=i==="prompts"&&o.jsx(Ht,{fallback:Wi("Prompts not supported by this server"),children:o.jsx(P.Suspense,{fallback:o.jsx(ci,{}),children:o.jsx(Nd,{connectionId:r,selections:n[r]?n[r].prompts:[],onToggle:(D,B)=>h(r,D,B)})})}),e[41]=i,e[42]=n,e[43]=r,e[44]=h,e[45]=w):w=e[45];let N;e[46]!==I||e[47]!==k||e[48]!==w?(N=o.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[I,k,w]}),e[46]=I,e[47]=k,e[48]=w,e[49]=N):N=e[49];let R;return e[50]!==A||e[51]!==N||e[52]!==y?(R=o.jsxs(o.Fragment,{children:[y,A,N]}),e[50]=A,e[51]=N,e[52]=y,e[53]=R):R=e[53],R}function Td(t){const e=H.c(11),{connectionId:s,onAuthenticate:i,children:r}=t;let n;e[0]!==s?(n={connectionId:s},e[0]=s,e[1]=n):n=e[1];const a=da(n);if(a.supportsOAuth&&!a.isAuthenticated){let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=o.jsx("div",{className:"flex items-center justify-center size-12 rounded-full bg-muted",children:o.jsx(wc,{size:22,className:"text-muted-foreground"})}),e[2]=c):c=e[2];let u;e[3]===Symbol.for("react.memo_cache_sentinel")?(u=o.jsxs("div",{className:"space-y-1",children:[o.jsx("p",{className:"text-sm font-medium",children:"Authorization required"}),o.jsx("p",{className:"text-xs text-muted-foreground max-w-xs",children:"This connection needs to be authorized before you can configure its tools and resources."})]}),e[3]=u):u=e[3];let d;e[4]!==s||e[5]!==i?(d=i&&o.jsx(oe,{variant:"outline",size:"sm",onClick:()=>i(s),children:"Authorize"}),e[4]=s,e[5]=i,e[6]=d):d=e[6];let f;return e[7]!==d?(f=o.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-4 p-8 text-center",children:[c,u,d]}),e[7]=d,e[8]=f):f=e[8],f}let h;return e[9]!==r?(h=o.jsx(o.Fragment,{children:r}),e[9]=r,e[10]=h):h=e[10],h}function Rd(t){const e={};for(const s of t)e[s.connection_id]={tools:s.selected_tools,resources:s.selected_resources??null,prompts:s.selected_prompts??null};return e}function Ln(t){return Object.entries(t).map(([e,s])=>({connection_id:e,selected_tools:s.tools,selected_resources:s.resources,selected_prompts:s.prompts}))}function Dd(t,e){return e.type==="SET_ACTIVE_TAB"?{...t,activeTab:e.payload}:t}function Md(t){const e=H.c(49),{open:s,onOpenChange:i,selectedId:r,form:n,connections:a,onAuthenticate:l}=t;let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h={activeTab:"tools"},e[0]=h):h=e[0];const[c,u]=P.useReducer(Dd,h),d=tn(r??"");let f;e[1]!==a?(f=a??[],e[1]=a,e[2]=f):f=e[2];let _;e[3]!==f?(_=Rd(f),e[3]=f,e[4]=_):_=e[4];const m=_;let p;e[5]!==n||e[6]!==m?(p=(F,Z,q,$)=>{const U=m[F]?.[Z];let V;U===null?V=$.filter(L=>L!==q):U?.includes(q)?V=U.filter(L=>L!==q):(V=[...U??[],q],V.length===$.length&&(V=null));const se={...m};se[F]?se[F]={...se[F]}:se[F]={tools:null,resources:null,prompts:null},se[F][Z]=V,n.setValue("connections",Ln(se),{shouldDirty:!0,shouldTouch:!0})},e[5]=n,e[6]=m,e[7]=p):p=e[7];const g=p;let v;e[8]!==n||e[9]!==m?(v=(F,Z)=>{const $=m[F]?.[Z]===null?[]:null,U={...m};U[F]?U[F]={...U[F]}:U[F]={tools:null,resources:null,prompts:null},U[F][Z]=$,n.setValue("connections",Ln(U),{shouldDirty:!0,shouldTouch:!0})},e[8]=n,e[9]=m,e[10]=v):v=e[10];const b=v;let S;e[11]!==g?(S=(F,Z,q)=>g(F,"tools",Z,q),e[11]=g,e[12]=S):S=e[12];const x=S;let y;e[13]!==g?(y=(F,Z,q)=>g(F,"resources",Z,q),e[13]=g,e[14]=y):y=e[14];const j=y;let C;e[15]!==g?(C=(F,Z,q)=>g(F,"prompts",Z,q),e[15]=g,e[16]=C):C=e[16];const T=C;let E;e[17]!==b?(E=F=>b(F,"tools"),e[17]=b,e[18]=E):E=e[18];const M=E;let A;e[19]!==b?(A=F=>b(F,"resources"),e[19]=b,e[20]=A):A=e[20];const I=A;let k;e[21]!==b?(k=F=>b(F,"prompts"),e[21]=b,e[22]=k):k=e[22];const w=k;if(!r||!d)return null;let N;e[23]===Symbol.for("react.memo_cache_sentinel")?(N=o.jsx(ci,{}),e[23]=N):N=e[23];let R;e[24]===Symbol.for("react.memo_cache_sentinel")?(R=F=>u({type:"SET_ACTIVE_TAB",payload:F}),e[24]=R):R=e[24];let D;e[25]!==d||e[26]!==c.activeTab||e[27]!==m||e[28]!==r||e[29]!==w||e[30]!==I||e[31]!==M||e[32]!==T||e[33]!==j||e[34]!==x?(D=o.jsx(Ed,{currentConnection:d,activeTab:c.activeTab,selectedId:r,formData:m,toggleTool:x,toggleResource:j,togglePrompt:T,toggleAllTools:M,toggleAllResources:I,toggleAllPrompts:w,onTabChange:R},r),e[25]=d,e[26]=c.activeTab,e[27]=m,e[28]=r,e[29]=w,e[30]=I,e[31]=M,e[32]=T,e[33]=j,e[34]=x,e[35]=D):D=e[35];let B;e[36]!==l||e[37]!==r||e[38]!==D?(B=o.jsx(P.Suspense,{fallback:N,children:o.jsx(Td,{connectionId:r,onAuthenticate:l,children:D})}),e[36]=l,e[37]=r,e[38]=D,e[39]=B):B=e[39];let z;e[40]!==i?(z=o.jsx(nh,{className:"px-6 py-4 border-t border-border shrink-0",children:o.jsx(oe,{variant:"outline",onClick:()=>i(!1),children:"Done"})}),e[40]=i,e[41]=z):z=e[41];let G;e[42]!==B||e[43]!==z?(G=o.jsxs(sn,{className:"sm:max-w-2xl h-[75vh] max-h-[75vh] flex flex-col p-0 gap-0 overflow-hidden w-[95vw]",children:[B,z]}),e[42]=B,e[43]=z,e[44]=G):G=e[44];let W;return e[45]!==i||e[46]!==s||e[47]!==G?(W=o.jsx(rn,{open:s,onOpenChange:i,children:G}),e[45]=i,e[46]=s,e[47]=G,e[48]=W):W=e[48],W}const Ui={tools:null,resources:null,prompts:null},Id=Pl.pick({status:!0,title:!0,description:!0,icon:!0,metadata:!0,connections:!0});function Ad(t){const s=new TextEncoder().encode(t),i=Array.from(s,r=>String.fromCharCode(r)).join("");return btoa(i)}function Bd(t){const e=H.c(11),{url:s,agentId:i}=t,[r,n]=P.useState(!1);let a;e[0]!==i||e[1]!==s?(a=async()=>{ye("agent_connect_action",{agent_id:i,action:"copy_url"}),await navigator.clipboard.writeText(s),n(!0),pe.success("Agent URL copied to clipboard"),setTimeout(()=>n(!1),2e3)},e[0]=i,e[1]=s,e[2]=a):a=e[2];const l=a;let h;e[3]!==r?(h=r?o.jsx(Ri,{size:20,className:"text-green-600"}):o.jsx(ki,{size:20}),e[3]=r,e[4]=h):h=e[4];const c=r?"Copied!":"Copy URL";let u;e[5]!==c?(u=o.jsx("span",{className:"text-xs font-medium",children:c}),e[5]=c,e[6]=u):u=e[6];let d;return e[7]!==l||e[8]!==h||e[9]!==u?(d=o.jsxs(oe,{type:"button",variant:"outline",onClick:l,className:"h-auto py-3 px-4 flex flex-col items-center gap-2",children:[h,u]}),e[7]=l,e[8]=h,e[9]=u,e[10]=d):d=e[10],d}function Pd(t){const e=H.c(8),{url:s,serverName:i,agentId:r}=t;let n;e[0]!==r||e[1]!==i||e[2]!==s?(n=()=>{ye("agent_connect_action",{agent_id:r,action:"install_cursor"});const u=ua(i),f=Ad(JSON.stringify({type:"http",url:s,headers:{"x-mesh-client":"Cursor"}},null,2)),_=`cursor://anysphere.cursor-deeplink/mcp/install?name=${encodeURIComponent(u)}&config=${encodeURIComponent(f)}`;window.open(_,"_blank"),pe.success("Opening Cursor...")},e[0]=r,e[1]=i,e[2]=s,e[3]=n):n=e[3];const a=n;let l,h;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=o.jsx("img",{src:"/logos/cursor.svg",alt:"Cursor",className:"h-5 w-5",style:{filter:"brightness(0) saturate(100%) invert(11%) sepia(8%) saturate(785%) hue-rotate(1deg) brightness(95%) contrast(89%)"}}),h=o.jsx("span",{className:"text-xs font-medium",children:"Install on Cursor"}),e[4]=l,e[5]=h):(l=e[4],h=e[5]);let c;return e[6]!==a?(c=o.jsxs(oe,{type:"button",variant:"outline",onClick:a,className:"h-auto py-3 px-4 flex flex-col items-center gap-2",children:[l,h]}),e[6]=a,e[7]=c):c=e[7],c}function Ld(t){const e=H.c(12),{url:s,serverName:i,agentId:r}=t,[n,a]=P.useState(!1);let l;e[0]!==r||e[1]!==i||e[2]!==s?(l=async()=>{ye("agent_connect_action",{agent_id:r,action:"install_claude_code"});const _=ua(i),p=JSON.stringify({type:"http",url:s,headers:{"x-mesh-client":"Claude Code"}},null,2),g=`claude mcp add-json "${_}" '${p.replace(/'/g,"'\\''")}' --scope user`;await navigator.clipboard.writeText(g),a(!0),pe.success("Claude Code command copied to clipboard"),setTimeout(()=>a(!1),2e3)},e[0]=r,e[1]=i,e[2]=s,e[3]=l):l=e[3];const h=l;let c;e[4]!==n?(c=n?o.jsx(Ri,{size:20,className:"text-green-600"}):o.jsx("img",{src:"/logos/Claude Code.svg",alt:"Claude Code",className:"h-5 w-5",style:{filter:"brightness(0) saturate(100%) invert(55%) sepia(31%) saturate(1264%) hue-rotate(331deg) brightness(92%) contrast(86%)"}}),e[4]=n,e[5]=c):c=e[5];const u=n?"Copied!":"Install on Claude Code";let d;e[6]!==u?(d=o.jsx("span",{className:"text-xs font-medium",children:u}),e[6]=u,e[7]=d):d=e[7];let f;return e[8]!==h||e[9]!==c||e[10]!==d?(f=o.jsxs(oe,{type:"button",variant:"outline",onClick:h,className:"h-auto py-3 px-4 flex flex-col items-center gap-2",children:[c,d]}),e[8]=h,e[9]=c,e[10]=d,e[11]=f):f=e[11],f}function Od({virtualMcp:t}){const{org:e}=ve(),s=He({connectionId:Pt,orgId:e.id,orgSlug:e.slug}),[i,r]=P.useState(null),[n,a]=P.useState(!1),[l,h]=P.useState(!1),c=t.id,u=t.title||`agent-${c.slice(0,8)}`,d=i?`bunx @decocms/typegen@latest --mcp ${c} --key ${i} --output client.ts`:`bunx @decocms/typegen@latest --mcp ${c} --key <api-key> --output client.ts`,f=async()=>{a(!0);try{const p=(await s.callTool({name:"API_KEY_CREATE",arguments:{name:`typegen-${u}`,permissions:{[c]:["*"]}}})).structuredContent?.key;if(!p)throw new Error("No key in response");r(p),ye("agent_typegen_key_generated",{agent_id:c})}catch{ye("agent_typegen_key_failed",{agent_id:c}),pe.error("Failed to generate API key")}finally{a(!1)}},_=async()=>{ye("agent_connect_action",{agent_id:c,action:"typegen_copy_command",has_api_key:!!i}),await navigator.clipboard.writeText(d),h(!0),pe.success("Command copied to clipboard"),setTimeout(()=>h(!1),2e3)};return o.jsxs("div",{className:"flex min-w-0 flex-col gap-3",children:[o.jsxs("div",{className:"flex items-start justify-between gap-3",children:[o.jsxs("div",{className:"flex flex-col gap-0.5",children:[o.jsx("h4",{className:"text-sm font-medium text-foreground",children:"Generate typed client"}),o.jsxs("p",{className:"text-xs text-muted-foreground",children:["Introspects this agent and writes a typed"," ",o.jsx("code",{className:"font-mono",children:"client.ts"})," you can import directly."]})]}),!i&&o.jsxs(oe,{type:"button",variant:"outline",size:"sm",className:"shrink-0 gap-1.5",onClick:f,disabled:n,children:[n?o.jsx(Ie,{size:14,className:"animate-spin"}):o.jsx(ch,{size:14}),o.jsx("span",{children:n?"Generating…":"Generate API key"})]})]}),i&&o.jsx("p",{className:"rounded-md border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-700",children:"Store this key securely — it won't be shown again."}),o.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Generate client"}),o.jsx("div",{className:"rounded-md border border-input bg-muted/50 px-3 py-2.5",children:o.jsxs("div",{className:"flex items-start gap-2",children:[o.jsx("code",{className:"min-w-0 flex-1 break-all font-mono text-xs text-muted-foreground",children:d}),o.jsx(oe,{type:"button",variant:"ghost",size:"icon",className:"size-6 shrink-0",onClick:_,children:l?o.jsx(Ri,{size:12,className:"text-green-600"}):o.jsx(ki,{size:12})})]})}),o.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Runtime variables"}),o.jsx(zd,{apiKey:i,agentId:c})]})}function zd(t){const e=H.c(21),{apiKey:s,agentId:i}=t,[r,n]=P.useState(!1),a=window.location.origin,l=s?`MESH_API_KEY=${s}`:"MESH_API_KEY=<api-key>",h=`MESH_BASE_URL=${a}`,c=`${l}
|
|
4
4
|
${h}`;let u;e[0]!==i||e[1]!==s||e[2]!==c?(u=async()=>{ye("agent_connect_action",{agent_id:i,action:"typegen_copy_env",has_api_key:!!s}),await navigator.clipboard.writeText(c),n(!0),setTimeout(()=>n(!1),2e3)},e[0]=i,e[1]=s,e[2]=c,e[3]=u):u=e[3];const d=u,f=!s;let _;e[4]!==f?(_=re({"opacity-50":f}),e[4]=f,e[5]=_):_=e[5];let m;e[6]!==l||e[7]!==_?(m=o.jsx("span",{className:_,children:l}),e[6]=l,e[7]=_,e[8]=m):m=e[8];let p,g;e[9]===Symbol.for("react.memo_cache_sentinel")?(p=o.jsx("br",{}),g=o.jsx("span",{children:h}),e[9]=p,e[10]=g):(p=e[9],g=e[10]);let v;e[11]!==m?(v=o.jsxs("code",{className:"min-w-0 flex-1 font-mono text-xs text-muted-foreground",children:[m,p,g]}),e[11]=m,e[12]=v):v=e[12];let b;e[13]!==r?(b=r?o.jsx(Ri,{size:12,className:"text-green-600"}):o.jsx(ki,{size:12}),e[13]=r,e[14]=b):b=e[14];let S;e[15]!==d||e[16]!==b?(S=o.jsx(oe,{type:"button",variant:"ghost",size:"icon",className:"size-6 shrink-0",onClick:d,children:b}),e[15]=d,e[16]=b,e[17]=S):S=e[17];let x;return e[18]!==v||e[19]!==S?(x=o.jsx("div",{className:"rounded-md border border-input bg-muted/50 px-3 py-2.5",children:o.jsxs("div",{className:"flex items-start gap-2",children:[v,S]})}),e[18]=v,e[19]=S,e[20]=x):x=e[20],x}function $d(t){const e=H.c(3),{virtualMcp:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=o.jsx("div",{className:"h-20 animate-pulse rounded-md bg-muted"}),e[0]=i):i=e[0];let r;return e[1]!==s?(r=o.jsx(P.Suspense,{fallback:i,children:o.jsx(Od,{virtualMcp:s})}),e[1]=s,e[2]=r):r=e[2],r}function Fd(t){const e=H.c(37),{open:s,onOpenChange:i,virtualMcp:r}=t,{org:n}=ve(),a=`/api/${n.slug}/mcp/virtual-mcp/${r.id}`;let l;e[0]!==a?(l=new URL(a,window.location.origin),e[0]=a,e[1]=l):l=e[1];const h=l;let c;e[2]!==r.id||e[3]!==r.title?(c=r.title||`agent-${r.id?.slice(0,8)??"default"}`,e[2]=r.id,e[3]=r.title,e[4]=c):c=e[4];const u=c,d=aa();let f;e[5]!==r.id||e[6]!==h.href?(f=o.jsx(Bd,{url:h.href,agentId:r.id}),e[5]=r.id,e[6]=h.href,e[7]=f):f=e[7];let _,m;e[8]!==u||e[9]!==r.id||e[10]!==h.href?(_=o.jsx(Pd,{url:h.href,serverName:u,agentId:r.id}),m=o.jsx(Ld,{url:h.href,serverName:u,agentId:r.id}),e[8]=u,e[9]=r.id,e[10]=h.href,e[11]=_,e[12]=m):(_=e[11],m=e[12]);let p;e[13]!==f||e[14]!==_||e[15]!==m?(p=o.jsx("div",{className:"flex flex-col gap-3 pt-2",children:o.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[f,_,m]})}),e[13]=f,e[14]=_,e[15]=m,e[16]=p):p=e[16];let g;e[17]===Symbol.for("react.memo_cache_sentinel")?(g=o.jsx("div",{className:"border-t border-border"}),e[17]=g):g=e[17];let v;e[18]!==r?(v=o.jsx($d,{virtualMcp:r}),e[18]=r,e[19]=v):v=e[19];let b;e[20]!==p||e[21]!==v?(b=o.jsxs("div",{className:"flex flex-col gap-6",children:[p,g,v]}),e[20]=p,e[21]=v,e[22]=b):b=e[22];const S=b;if(d){let C;e[23]===Symbol.for("react.memo_cache_sentinel")?(C=o.jsx(_h,{className:"mt-4 mb-4 text-base font-semibold",children:"Connect"}),e[23]=C):C=e[23];let T;e[24]!==S?(T=o.jsx(ph,{children:o.jsxs("div",{className:"flex-1 overflow-y-auto px-4 pb-6 [touch-action:pan-y]",children:[C,S]})}),e[24]=S,e[25]=T):T=e[25];let E;return e[26]!==i||e[27]!==s||e[28]!==T?(E=o.jsx(gh,{open:s,onOpenChange:i,children:T}),e[26]=i,e[27]=s,e[28]=T,e[29]=E):E=e[29],E}let x;e[30]===Symbol.for("react.memo_cache_sentinel")?(x=o.jsx(Sa,{children:o.jsx(ya,{children:"Connect"})}),e[30]=x):x=e[30];let y;e[31]!==S?(y=o.jsxs(sn,{className:"max-h-[80vh] overflow-y-auto sm:max-w-2xl",children:[x,S]}),e[31]=S,e[32]=y):y=e[32];let j;return e[33]!==i||e[34]!==s||e[35]!==y?(j=o.jsx(rn,{open:s,onOpenChange:i,children:y}),e[33]=i,e[34]=s,e[35]=y,e[36]=j):j=e[36],j}function Hd(t,e){switch(e.type){case"SET_SHARE_DIALOG_OPEN":return{...t,shareDialogOpen:e.payload};case"SET_ADD_DIALOG_OPEN":return{...t,addDialogOpen:e.payload};case"OPEN_SETTINGS":return{...t,settingsDialogOpen:!0,settingsConnectionId:e.payload};case"CLOSE_SETTINGS":return{...t,settingsDialogOpen:!1,settingsConnectionId:null};default:return t}}function Wd(t){const e=H.c(22),{connection_id:s,usedConnectionIds:i,onOpenSettings:r,onRemove:n,onAuthenticate:a,onSwitchInstance:l,onNewInstance:h}=t,c=tn(s),{org:u}=ve();if(!c)return null;let d;e[0]!==c?(d=rh(c),e[0]=c,e[1]=d):d=e[1];const f=d;let _;e[2]!==s?(_=o.jsx(qd,{connection_id:s}),e[2]=s,e[3]=_):_=e[3];let m;e[4]!==c.app_name||e[5]!==c.connection_type||e[6]!==c.description||e[7]!==c.icon||e[8]!==c.title||e[9]!==s||e[10]!==a||e[11]!==h||e[12]!==r||e[13]!==n||e[14]!==l||e[15]!==u.slug||e[16]!==f||e[17]!==i?(m=o.jsx(Kd,{connection_id:s,connectionTitle:c.title,connectionDescription:c.description,connectionIcon:c.icon,connectionType:c.connection_type,slug:f,orgSlug:u.slug,appName:c.app_name,usedConnectionIds:i,onOpenSettings:r,onRemove:n,onAuthenticate:a,onSwitchInstance:l,onNewInstance:h}),e[4]=c.app_name,e[5]=c.connection_type,e[6]=c.description,e[7]=c.icon,e[8]=c.title,e[9]=s,e[10]=a,e[11]=h,e[12]=r,e[13]=n,e[14]=l,e[15]=u.slug,e[16]=f,e[17]=i,e[18]=m):m=e[18];let p;return e[19]!==_||e[20]!==m?(p=o.jsx(P.Suspense,{fallback:_,children:m}),e[19]=_,e[20]=m,e[21]=p):p=e[21],p}const On="__new_instance__";async function Ud(t,e){const s=t?.idToken??null;if(s){const r=zn(s);if(r)return r}const i=t?.userinfoEndpoint??null;if(i)try{const r=await fetch(i,{headers:{Authorization:`Bearer ${e}`}});if(r.ok){const n=await r.json(),a=typeof n.email=="string"?n.email:typeof n.upn=="string"?n.upn:typeof n.preferred_username=="string"?n.preferred_username:null;if(a)return a}}catch{}return zn(e)}function zn(t){try{const e=t.split(".");if(e.length===3&&e[1]){const s=JSON.parse(atob(e[1].replace(/-/g,"+").replace(/_/g,"/")));if(typeof s.email=="string")return s.email;if(typeof s.upn=="string")return s.upn;if(typeof s.preferred_username=="string")return s.preferred_username}}catch{}return null}function Vd(t){const e=H.c(23),{appName:s,connectionId:i,usedConnectionIds:r,onSwitchInstance:n,onNewInstance:a}=t;let l;e[0]!==s?(l={filters:[{column:"app_name",value:s}]},e[0]=s,e[1]=l):l=e[1];const h=Ti(l);if(h.length<=1)return null;let c;e[2]!==i||e[3]!==a||e[4]!==n?(c=p=>{p===On?a?.():n(i,p)},e[2]=i,e[3]=a,e[4]=n,e[5]=c):c=e[5];let u;e[6]===Symbol.for("react.memo_cache_sentinel")?(u=o.jsx(ss,{size:"sm",className:"w-auto text-xs gap-1 px-2 shadow-none",children:o.jsx(is,{})}),e[6]=u):u=e[6];let d;if(e[7]!==i||e[8]!==h||e[9]!==r){let p;e[11]!==i||e[12]!==r?(p=g=>o.jsx(At,{value:g.id,className:"text-xs",disabled:g.id!==i&&r.has(g.id),children:g.title},g.id),e[11]=i,e[12]=r,e[13]=p):p=e[13],d=h.map(p),e[7]=i,e[8]=h,e[9]=r,e[10]=d}else d=e[10];let f;e[14]!==a?(f=a&&o.jsx(At,{value:On,className:"text-xs text-muted-foreground",children:"+ New instance"}),e[14]=a,e[15]=f):f=e[15];let _;e[16]!==d||e[17]!==f?(_=o.jsxs(rs,{children:[d,f]}),e[16]=d,e[17]=f,e[18]=_):_=e[18];let m;return e[19]!==i||e[20]!==c||e[21]!==_?(m=o.jsxs(ts,{value:i,onValueChange:c,children:[u,_]}),e[19]=i,e[20]=c,e[21]=_,e[22]=m):m=e[22],m}function Kd(t){const e=H.c(55),{connection_id:s,connectionTitle:i,connectionDescription:r,connectionIcon:n,connectionType:a,slug:l,orgSlug:h,appName:c,usedConnectionIds:u,onOpenSettings:d,onRemove:f,onAuthenticate:_,onSwitchInstance:m,onNewInstance:p}=t;let g;e[0]!==s?(g={connectionId:s},e[0]=s,e[1]=g):g=e[1];const v=da(g),S=!(a==="VIRTUAL")&&v.supportsOAuth&&!v.isAuthenticated,x=S?"border-destructive/50 bg-destructive/5":"border-border";let y;e[2]!==x?(y=re("rounded-xl border overflow-hidden transition-colors",x),e[2]=x,e[3]=y):y=e[3];let j;e[4]!==h||e[5]!==l?(j={org:h,appSlug:l},e[4]=h,e[5]=l,e[6]=j):j=e[6];let C;e[7]!==n||e[8]!==i?(C=o.jsx(us,{icon:n,name:i,size:"sm",className:"shrink-0"}),e[7]=n,e[8]=i,e[9]=C):C=e[9];let T;e[10]!==i?(T=o.jsx("p",{className:"text-sm font-medium truncate",children:i}),e[10]=i,e[11]=T):T=e[11];let E;e[12]!==r||e[13]!==S?(E=S?o.jsx("span",{className:"text-xs text-destructive font-medium",children:"Needs authorization"}):r&&o.jsx("p",{className:"text-xs text-muted-foreground truncate",children:r}),e[12]=r,e[13]=S,e[14]=E):E=e[14];let M;e[15]!==T||e[16]!==E?(M=o.jsxs("div",{className:"flex-1 min-w-0",children:[T,E]}),e[15]=T,e[16]=E,e[17]=M):M=e[17];let A;e[18]!==s||e[19]!==S||e[20]!==_?(A=S?o.jsx(oe,{variant:"outline",size:"sm",className:"h-7 text-xs shrink-0",onClick:$=>{$.preventDefault(),$.stopPropagation(),_(s)},children:"Authorize"}):o.jsxs(Ke,{delayDuration:0,children:[o.jsx(qe,{asChild:!0,children:o.jsx("span",{className:"inline-flex items-center justify-center rounded-md h-7 w-7 hover:bg-accent text-muted-foreground shrink-0 transition-colors",children:o.jsx(ah,{size:16})})}),o.jsx(Ge,{side:"bottom",children:"Connection settings"})]}),e[18]=s,e[19]=S,e[20]=_,e[21]=A):A=e[21];let I;e[22]!==j||e[23]!==C||e[24]!==M||e[25]!==A?(I=o.jsxs(zl,{to:"/$org/settings/connections/$appSlug",params:j,className:"flex items-center gap-3 px-4 py-3 cursor-pointer hover:bg-muted/50 transition-colors",children:[C,M,A]}),e[22]=j,e[23]=C,e[24]=M,e[25]=A,e[26]=I):I=e[26];let k;e[27]!==c||e[28]!==s||e[29]!==p||e[30]!==m||e[31]!==u?(k=c&&o.jsx(Vd,{appName:c,connectionId:s,usedConnectionIds:u,onSwitchInstance:m,onNewInstance:p}),e[27]=c,e[28]=s,e[29]=p,e[30]=m,e[31]=u,e[32]=k):k=e[32];let w;e[33]===Symbol.for("react.memo_cache_sentinel")?(w=o.jsx(kc,{size:13}),e[33]=w):w=e[33];let N;e[34]!==d?(N=o.jsx(qe,{asChild:!0,children:o.jsx(oe,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:d,"aria-label":"Configure resources",children:w})}),e[34]=d,e[35]=N):N=e[35];let R;e[36]===Symbol.for("react.memo_cache_sentinel")?(R=o.jsx(Ge,{side:"bottom",children:"Configure resources"}),e[36]=R):R=e[36];let D;e[37]!==N?(D=o.jsxs(Ke,{delayDuration:0,children:[N,R]}),e[37]=N,e[38]=D):D=e[38];let B;e[39]===Symbol.for("react.memo_cache_sentinel")?(B=o.jsx(ls,{size:13}),e[39]=B):B=e[39];let z;e[40]!==f?(z=o.jsx(qe,{asChild:!0,children:o.jsx(oe,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-destructive",onClick:f,"aria-label":"Remove connection",children:B})}),e[40]=f,e[41]=z):z=e[41];let G;e[42]===Symbol.for("react.memo_cache_sentinel")?(G=o.jsx(Ge,{side:"bottom",children:"Remove"}),e[42]=G):G=e[42];let W;e[43]!==z?(W=o.jsxs(Ke,{delayDuration:0,children:[z,G]}),e[43]=z,e[44]=W):W=e[44];let F;e[45]!==D||e[46]!==W?(F=o.jsxs("div",{className:"flex items-center gap-0.5 ml-auto",children:[D,W]}),e[45]=D,e[46]=W,e[47]=F):F=e[47];let Z;e[48]!==k||e[49]!==F?(Z=o.jsxs("div",{className:"flex items-center gap-3 px-4 py-2 border-t border-border bg-muted/25",children:[k,F]}),e[48]=k,e[49]=F,e[50]=Z):Z=e[50];let q;return e[51]!==I||e[52]!==Z||e[53]!==y?(q=o.jsxs("div",{className:y,children:[I,Z]}),e[51]=I,e[52]=Z,e[53]=y,e[54]=q):q=e[54],q}function qd(t){const e=H.c(17),{connection_id:s}=t,i=tn(s);if(!i){let d;return e[0]===Symbol.for("react.memo_cache_sentinel")?(d=o.jsx(Ia,{}),e[0]=d):d=e[0],d}let r;e[1]!==i.icon||e[2]!==i.title?(r=o.jsx(us,{icon:i.icon,name:i.title,size:"sm",className:"shrink-0"}),e[1]=i.icon,e[2]=i.title,e[3]=r):r=e[3];let n;e[4]!==i.title?(n=o.jsx("p",{className:"text-sm font-medium truncate",children:i.title}),e[4]=i.title,e[5]=n):n=e[5];let a;e[6]!==i.description?(a=i.description&&o.jsx("p",{className:"text-xs text-muted-foreground truncate",children:i.description}),e[6]=i.description,e[7]=a):a=e[7];let l;e[8]!==n||e[9]!==a?(l=o.jsxs("div",{className:"flex-1 min-w-0",children:[n,a]}),e[8]=n,e[9]=a,e[10]=l):l=e[10];let h;e[11]!==r||e[12]!==l?(h=o.jsxs("div",{className:"flex items-center gap-3 px-4 py-3",children:[r,l]}),e[11]=r,e[12]=l,e[13]=h):h=e[13];let c;e[14]===Symbol.for("react.memo_cache_sentinel")?(c=o.jsx("div",{className:"flex items-center px-4 py-2 border-t border-border bg-muted/25",children:o.jsx("div",{className:"h-5 w-20 rounded bg-muted animate-pulse"})}),e[14]=c):c=e[14];let u;return e[15]!==h?(u=o.jsxs("div",{className:"rounded-xl border border-border overflow-hidden",children:[h,c]}),e[15]=h,e[16]=u):u=e[16],u}function Ia(){const t=H.c(3);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=o.jsx("div",{className:"size-8 rounded-md bg-muted animate-pulse shrink-0"}),t[0]=e):e=t[0];let s;t[1]===Symbol.for("react.memo_cache_sentinel")?(s=o.jsxs("div",{className:"flex items-center gap-3 px-4 py-3",children:[e,o.jsxs("div",{className:"flex-1 space-y-1.5",children:[o.jsx("div",{className:"h-4 w-32 rounded bg-muted animate-pulse"}),o.jsx("div",{className:"h-3 w-48 rounded bg-muted animate-pulse"})]})]}),t[1]=s):s=t[1];let i;return t[2]===Symbol.for("react.memo_cache_sentinel")?(i=o.jsxs("div",{className:"rounded-xl border border-border overflow-hidden",children:[s,o.jsx("div",{className:"flex items-center px-4 py-2 border-t border-border bg-muted/25",children:o.jsx("div",{className:"h-5 w-20 rounded bg-muted animate-pulse"})})]}),t[2]=i):i=t[2],i}function Gd({virtualMcpId:t,form:e,debouncedSave:s,flushAndSave:i}){const{org:r}=ve(),n=He({connectionId:Pt,orgId:r.id,orgSlug:r.slug}),a=Ct(t),l=(a?.connections??[]).map(w=>w.connection_id).sort(),{data:h}=Uo({queryKey:Bs.projectConnectionDetails(t,l),enabled:l.length>0,queryFn:async()=>await Promise.all(l.map(async N=>{try{const R=await n.callTool({name:"COLLECTION_CONNECTIONS_GET",arguments:{id:N}}),{item:D}=ih(R),B=(D?.tools??[]).filter(z=>!!eh(z._meta)).map(z=>({name:z.name,description:z.description}));return{fetchOk:!0,id:N,title:D?.title??N,icon:D?.icon??null,uiTools:B}}catch{return{fetchOk:!1,id:N,title:N,icon:null,uiTools:[]}}}))}),c=(h??[]).filter(w=>w.uiTools.length>0),u=new Set(lc),d=e.watch("metadata.ui.pinnedViews")??[],f=e.watch("metadata.ui.layout")??null,_=f?.defaultMainView??null,m=f?.chatDefaultOpen??!1,p=!_||_.type==="chat"?"chat":_.type==="instructions"||_.type==="connections"||_.type==="layout"?"settings":u.has(_.type)?_.type:`${_.type}:${_.id??""}:${_.toolName??""}`,g=w=>{const[N,R,D]=w.split(":");return N?N==="chat"?{type:N}:u.has(N)?{type:N}:N==="ext-apps"&&R?{type:"ext-apps",id:R,toolName:D||void 0}:null:null},v=w=>{e.setValue("metadata.ui.pinnedViews",w,{shouldDirty:!0})},b=w=>{e.setValue("metadata.ui.layout",{...f,...w},{shouldDirty:!0})},S=P.useRef(!1);if(h&&h.length>0&&!S.current){S.current=!0;const w=new Set((h??[]).filter(D=>D.fetchOk).map(D=>D.id)),N=new Set(c.flatMap(D=>D.uiTools.map(B=>`${D.id}:${B.name}`))),R=d.filter(D=>!w.has(D.connectionId)||N.has(`${D.connectionId}:${D.toolName}`));R.length!==d.length&&(v(R),_?.type==="ext-apps"&&!R.some(D=>D.connectionId===_.id&&D.toolName===_.toolName)&&b({defaultMainView:{type:"chat"}}),s())}const x=(w,N)=>{if(d.some(D=>D.connectionId===w&&D.toolName===N)){const D=d.filter(z=>!(z.connectionId===w&&z.toolName===N));v(D);const B=`ext-apps:${w}:${N}`;p===B&&b({defaultMainView:{type:"chat"}})}else v([...d,{connectionId:w,toolName:N,label:wn(N),icon:null}]);i()},y=(w,N,R)=>{v(d.map(D=>D.connectionId===w&&D.toolName===N?{...D,label:R}:D)),s()},j=()=>{i()},C=(w,N,R)=>{v(d.map(D=>D.connectionId===w&&D.toolName===N?{...D,icon:R}:D)),i()},T=w=>{b({defaultMainView:g(w)}),i()},E=l.length===0,M=h&&c.length===0,A=!!Kt(a),I=[{value:"chat",label:"Chat"},{value:"settings",label:"Settings"},{value:"automations",label:"Automations"}];A&&(I.push({value:"env",label:"Terminal"}),I.push({value:"preview",label:"Preview"}));for(const w of d)I.push({value:`ext-apps:${w.connectionId}:${w.toolName}`,label:w.label||w.toolName});const k=c.length>0||E||M;return o.jsxs("div",{className:"flex flex-col gap-3",children:[o.jsx("div",{className:"flex items-center justify-between gap-3",children:o.jsx("h2",{className:"text-sm font-medium text-foreground",children:"Layout"})}),o.jsxs(oh,{className:"p-6 gap-5",children:[o.jsxs(Rn,{className:"p-0 space-y-5",children:[o.jsxs("div",{className:"flex items-center justify-between gap-4",children:[o.jsxs("div",{className:"space-y-0.5 min-w-0",children:[o.jsx(Ms,{className:"font-normal text-foreground",children:"Main view"}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"What users see when they first open this agent."})]}),o.jsxs(ts,{value:p,onValueChange:T,children:[o.jsx(ss,{className:"w-44 h-8 text-sm capitalize shrink-0",children:o.jsx(is,{})}),o.jsx(rs,{children:I.map(w=>o.jsx(At,{value:w.value,className:"capitalize",children:w.label},w.value))})]})]}),o.jsxs("div",{className:"flex items-center justify-between gap-4",children:[o.jsxs("div",{className:"space-y-0.5 min-w-0",children:[o.jsx(Ms,{className:"font-normal text-foreground",children:"Show chat"}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"Display the chat panel alongside the main view."})]}),o.jsxs(Ke,{delayDuration:0,children:[o.jsx(qe,{asChild:!0,children:o.jsx("span",{className:"shrink-0",children:o.jsx(dr,{checked:p==="chat"?!0:m,disabled:p==="chat",onCheckedChange:w=>{b({chatDefaultOpen:w}),i()}})})}),p==="chat"&&o.jsx(Ge,{side:"top",children:"Chat is always shown when it is the default view"})]})]})]}),k&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"border-t border-border -mx-6"}),o.jsxs(Rn,{className:"p-0 space-y-3",children:[o.jsx("div",{className:"flex items-center justify-between gap-4",children:o.jsxs("div",{className:"space-y-0.5 min-w-0",children:[o.jsx(Ms,{className:"font-normal text-foreground",children:"Pinned views"}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"Surface interactive tools as top-level tabs in the agent."})]})}),E&&o.jsx("p",{className:"text-xs text-muted-foreground",children:"Add a connection above to configure pinned views."}),M&&!E&&o.jsx("p",{className:"text-xs text-muted-foreground",children:"None of the connected servers expose interactive tools."}),c.length>0&&o.jsx("div",{className:"space-y-4 pt-1",children:c.map((w,N)=>o.jsxs("div",{children:[N>0&&o.jsx("div",{className:"border-t border-border -mx-6 mb-4"}),o.jsxs("div",{className:"flex items-center gap-2 mb-2.5",children:[o.jsx(us,{icon:w.icon,name:w.title,size:"xs",className:"shrink-0"}),o.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:w.title})]}),o.jsx("div",{className:"space-y-1.5",children:w.uiTools.map(R=>{const D=d.some(z=>z.connectionId===w.id&&z.toolName===R.name),B=d.find(z=>z.connectionId===w.id&&z.toolName===R.name);return o.jsxs("div",{className:re("flex items-center justify-between gap-3 px-3 py-2 rounded-lg border transition-colors",D?"bg-accent/40 border-border":"bg-transparent border-border"),children:[o.jsxs("div",{className:"min-w-0 flex-1 flex items-center gap-2",children:[o.jsx(vd,{value:B?.icon??null,onChange:z=>C(w.id,R.name,z),disabled:!D}),o.jsx(_s,{value:D&&B?B.label:wn(R.name),onChange:z=>y(w.id,R.name,z.target.value),onBlur:j,className:"h-7 text-sm w-40",disabled:!D,readOnly:!D})]}),o.jsx(dr,{checked:D,onCheckedChange:()=>x(w.id,R.name)})]},R.name)})})]},w.id))})]})]})]})]})}function Yd({virtualMcp:t,hideOwnTitle:e}){const{org:s}=ve(),i=Yl(),r=Jc(),n=ds(),a=He({connectionId:Pt,orgId:s.id,orgSlug:s.slug}),l=Ko({resolver:Ll(Id),defaultValues:t}),h=l.watch("connections"),c=!!Kt(t),[u,d]=P.useReducer(Hd,{shareDialogOpen:!1,addDialogOpen:!1,settingsDialogOpen:!1,settingsConnectionId:null}),[f,_]=P.useState(!1),[m,p]=P.useState(!1),{createNewTask:g,setChatOpen:v}=Ei(),{sendMessage:b}=fs(),S=ca(),x=async()=>{if(m)return;const L=l.getValues("metadata.instructions");if(L?.trim()){p(!0);try{I(),ye("agent_instructions_improve_clicked",{agent_id:t.id,instructions_length:L.length}),await S(["studio-agent-manager"]),v(!0),await b({tiptapDoc:Ma({managerAgentId:Jo.AGENT_MANAGER(s.id),managerName:"Agent Manager",kind:"agent",id:t.id,instructions:L})})}finally{p(!1)}}},y=()=>{I(),ye("agent_test_clicked",{agent_id:t.id}),g()},j=P.useRef(null),C=P.useRef(new Set),T=P.useRef(0),E=P.useRef(null),M=P.useRef(null),A=3e4,I=()=>{M.current&&(clearTimeout(M.current),M.current=null),j.current!==null&&(ye("agent_updated",{agent_id:t.id,fields:Array.from(C.current),instructions_length:E.current,save_count:T.current,edit_duration_ms:Date.now()-j.current}),j.current=null,C.current=new Set,T.current=0,E.current=null)},k=async()=>{const L=Object.keys(l.formState.dirtyFields);if(L.length===0)return;const te=L.includes("metadata"),ie=l.getValues(),ee=await i.update.mutateAsync({id:t.id,data:ie});j.current===null&&(j.current=Date.now());for(const Y of L)C.current.add(Y);T.current+=1,te&&(E.current=ie.metadata?.instructions?.length??0),M.current&&clearTimeout(M.current),M.current=setTimeout(I,A),l.reset(ee)},{schedule:w,flush:N}=Ca({save:k}),R=()=>{ye("connections_dialog_opened",{source:"agent_settings",mode:"add"}),d({type:"SET_ADD_DIALOG_OPEN",payload:!0})},D=async L=>{const te=l.getValues("connections");if(te.some(Y=>Y.connection_id===L))return;l.setValue("connections",[...te,{connection_id:L,selected_tools:Ui.tools,selected_resources:Ui.resources,selected_prompts:Ui.prompts}],{shouldDirty:!0}),w(),d({type:"SET_ADD_DIALOG_OPEN",payload:!1});const ie=new URL(`/api/${s.slug}/mcp/${L}`,window.location.origin),ee=await xn({url:ie.href,token:null,orgId:s.id});ee.supportsOAuth&&!ee.isAuthenticated&&await F(L)},B=L=>{const ie=l.getValues("connections").filter(ee=>ee.connection_id!==L);l.setValue("connections",ie,{shouldDirty:!0}),w()},z=(L,te)=>{const ie=l.getValues("connections");if(ie.some(ee=>ee.connection_id===te)){pe.error("This instance is already added to the agent");return}l.setValue("connections",ie.map(ee=>ee.connection_id===L?{...ee,connection_id:te}:ee),{shouldDirty:!0}),w()},G=async L=>{if(l.getValues("connections").find(ie=>ie.connection_id===L))try{const ie=await a.callTool({name:"COLLECTION_CONNECTIONS_GET",arguments:{id:L}}),{item:ee}=ie.structuredContent??{};if(!ee)return;const Y=ee.title.replace(/\s*\(.*?\)\s*$/,""),le=Zc("conn"),ue=`${Y} (${Date.now().toString(36).slice(-4)})`;await r.create.mutateAsync({id:le,title:ue,description:ee.description??null,connection_type:ee.connection_type,connection_url:ee.connection_url??null,connection_token:null,icon:ee.icon??null,app_name:ee.app_name??null,app_id:ee.app_id??null,connection_headers:ee.connection_headers??null});const de=new URL(`/api/${s.slug}/mcp/${le}`,window.location.origin),fe=await xn({url:de.href,token:null,orgId:s.id});if(fe.supportsOAuth&&!fe.isAuthenticated){const _e=await F(le);if(!_e){await r.delete.mutateAsync(le);return}await r.update.mutateAsync({id:le,data:{title:`${Y} (${_e})`}})}z(L,le),pe.success("New instance created")}catch(ie){console.error("Failed to create instance:",ie),pe.error("Failed to create instance")}},W=L=>{d({type:"OPEN_SETTINGS",payload:L})},F=async L=>{const{token:te,tokenInfo:ie,error:ee}=await Ol({connectionId:L,orgSlug:s.slug,scope:"offline_access"});if(ee||!te)return pe.error(`Authentication failed: ${ee}`),null;if(ie)try{const le=await fetch(`/api/${s.slug}/connections/${L}/oauth-token`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({accessToken:ie.accessToken,refreshToken:ie.refreshToken,expiresIn:ie.expiresIn,scope:ie.scope,clientId:ie.clientId,clientSecret:ie.clientSecret,tokenEndpoint:ie.tokenEndpoint})});if(!le.ok)console.error("Failed to save OAuth token:",await le.text()),await r.update.mutateAsync({id:L,data:{connection_token:te}});else try{await r.update.mutateAsync({id:L,data:{}})}catch(ue){console.warn("Failed to refresh connection tools after OAuth:",ue)}}catch(le){console.error("Error saving OAuth token:",le),await r.update.mutateAsync({id:L,data:{connection_token:te}})}else await r.update.mutateAsync({id:L,data:{connection_token:te}});const Y=new URL(`/api/${s.slug}/mcp/${L}`,window.location.origin);return await n.invalidateQueries({queryKey:Bs.isMCPAuthenticated(Y.href,null)}),pe.success("Authentication successful"),Ud(ie,te)},Z=()=>{const L=l.getValues("metadata.instructions")??"",te=`<role>
|
|
5
5
|
Define who this agent is and what it specializes in.
|
|
@@ -179,4 +179,4 @@ WARNING: This link could potentially be dangerous`)){let s=window.open();if(s){t
|
|
|
179
179
|
`,e)}paste(t){this._core.paste(t)}refresh(t,e){this._verifyIntegers(t,e),this._core.refresh(t,e)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(t){this._addonManager.loadAddon(this,t)}static get strings(){return{get promptLabel(){return mr.get()},set promptLabel(t){mr.set(t)},get tooMuchOutput(){return _r.get()},set tooMuchOutput(t){_r.set(t)}}}_verifyIntegers(...t){for(ut of t)if(ut===1/0||isNaN(ut)||ut%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...t){for(ut of t)if(ut&&(ut===1/0||isNaN(ut)||ut%1!==0||ut<0))throw new Error("This API only accepts positive integers")}};var Sp=2,yp=1,wp=class{activate(t){this._terminal=t}dispose(){}fit(){let t=this.proposeDimensions();if(!t||!this._terminal||isNaN(t.cols)||isNaN(t.rows))return;let e=this._terminal._core;(this._terminal.rows!==t.rows||this._terminal.cols!==t.cols)&&(e._renderService.clear(),this._terminal.resize(t.cols,t.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let t=this._terminal._core._renderService.dimensions;if(t.css.cell.width===0||t.css.cell.height===0)return;let e=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,s=window.getComputedStyle(this._terminal.element.parentElement),i=parseInt(s.getPropertyValue("height")),r=Math.max(0,parseInt(s.getPropertyValue("width"))),n=window.getComputedStyle(this._terminal.element),a={top:parseInt(n.getPropertyValue("padding-top")),bottom:parseInt(n.getPropertyValue("padding-bottom")),right:parseInt(n.getPropertyValue("padding-right")),left:parseInt(n.getPropertyValue("padding-left"))},l=a.top+a.bottom,h=a.right+a.left,c=i-l,u=r-h-e;return{cols:Math.max(Sp,Math.floor(u/t.css.cell.width)),rows:Math.max(yp,Math.floor(c/t.css.cell.height))}}};function Cp({source:t,onReady:e,onSelectionChange:s,className:i}){const r=P.useRef(null),n=P.useRef(null),a=P.useRef(s);a.current=s;const l=Gt(),h=P.useRef(t);return h.current=t,Uu((c,u)=>{c===h.current&&n.current?.write(u)}),P.useEffect(()=>{const c=r.current;if(!c)return;const u=getComputedStyle(document.documentElement),d=v=>u.getPropertyValue(v).trim()||void 0,f=new bp({allowTransparency:!1,fontFamily:d("--font-mono")||"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",fontSize:12.5,lineHeight:1.5,scrollback:5e3,cursorBlink:!1,disableStdin:!0,theme:{background:d("--sidebar")||d("--card")||d("--background")||"#1e1e1e",cursor:"transparent",foreground:d("--foreground")||"#d4d4d4",selectionBackground:d("--accent"),selectionForeground:d("--accent-foreground"),black:d("--muted"),red:d("--destructive"),green:d("--success"),yellow:d("--warning"),blue:d("--chart-1"),magenta:d("--chart-3"),cyan:d("--chart-5"),white:d("--foreground"),brightBlack:d("--muted-foreground"),brightRed:d("--destructive"),brightGreen:d("--success"),brightYellow:d("--warning"),brightBlue:d("--chart-1"),brightMagenta:d("--chart-3"),brightCyan:d("--chart-5"),brightWhite:d("--foreground")}}),_=new wp;f.loadAddon(_),f.open(c),_.fit();const m=l.getBuffer(t);m&&f.write(m),n.current=f,e?.(f);const p=f.onSelectionChange(()=>{const v=!!f.getSelection();a.current?.(v,()=>f.getSelection())}),g=new ResizeObserver(()=>{_.fit()});return g.observe(c),()=>{p.dispose(),g.disconnect(),n.current=null,f.dispose()}},[]),o.jsx("div",{ref:r,className:re("overflow-hidden bg-sidebar px-4 py-3 [&_.xterm]:h-full [&_.xterm-screen]:min-h-full [&_.xterm-viewport]:overscroll-contain",i)})}function kp(){const t=H.c(2),s=vn()?.entity;let i;return t[0]!==s?(i=Kt(s),t[0]=s,t[1]=i):i=t[1],i}const Np={npm:{install:"npm install",run:t=>`npm run ${t}`,runtime:"node"},pnpm:{install:"pnpm install",run:t=>`pnpm run ${t}`,runtime:"node"},yarn:{install:"yarn install",run:t=>`yarn run ${t}`,runtime:"node"},bun:{install:"bun install",run:t=>`bun run ${t}`,runtime:"bun"},deno:{install:"deno install",run:t=>`deno task ${t}`,runtime:"deno"}},Lo=["dev","start"];function jp({daemonOpen:t=!1}){const{org:e}=ve(),s=vn(),i=ds(),{data:r}=Ci.useSession(),{currentBranch:n,setCurrentTaskBranch:a}=vt(),l=r?.user?.id,h=s?.entity?.metadata,c=l&&n?h?.vmMap?.[l]?.[n]:void 0,u=c&&n?{previewUrl:c.previewUrl,vmId:c.vmId,branch:n,runnerKind:c.runnerKind}:null,[d,f]=P.useState(null),[_,m]=P.useState(""),[p,g]=P.useState(""),[v,b]=P.useState(!1),[S,x]=P.useState(new Set),y=P.useRef(!1),j=P.useRef(Date.now()),[C,T]=P.useState("setup"),[E,M]=P.useState([]),A=P.useRef(new Map),{sendMessage:I}=fs(),{setChatOpen:k}=Ei(),[w,N]=P.useState(!1),R=P.useRef(null),D=X=>{T(X),N(!1),R.current=null},B=(X,ne,Re)=>{X===C&&(N(ne),R.current=ne?Re:null)},z=()=>{const X=R.current?.();if(!X)return;k(!0),I({parts:[{type:"text",text:`<server-logs>
|
|
180
180
|
${X}
|
|
181
181
|
</server-logs>`}]}),A.current.get(C)?.clearSelection()},G=He({connectionId:Pt,orgId:e.id,orgSlug:e.slug}),W=Gt(),F=Ra(s?.entity?.id,n??void 0),Z=W.suspended?"suspended":W.notFound?"creating":u?"running":F?"creating":"idle",q=d??Z;P.useEffect(()=>{d==="creating"&&Z==="running"&&f(null),d==="stopping"&&Z==="idle"&&f(null)},[Z,d]);const $=nn(G),{mutate:U,isPending:V}=$,se=s?.entity?.id,L=W.notFound?c?.vmId??null:null,te=P.useRef(null);P.useEffect(()=>{if(!L||!se||V||te.current===L)return;te.current=L;const X={virtualMcpId:se};n&&(X.branch=n),U(X,{onError:ne=>{console.error("[env] reprovision VM_START failed",ne)}})},[L,se,n,V,U]);const ie=P.useRef(!1);P.useEffect(()=>{if(W.scripts.length>0&&!ie.current){ie.current=!0;for(const X of Lo)if(W.scripts.includes(X)){M([X]),D(X);break}}},[W.scripts]);const ee=async(X,ne)=>{const Re=await G.callTool({name:X,arguments:ne}),Je=Re.content;if(Je?.[0]?.text?.startsWith("Error:"))throw new Error(Je[0].text);return Re.structuredContent??Re},Y=async X=>{if(!(v||!u||!se||!n)){b(!0);try{const ne=new URLSearchParams({virtualMcpId:se,branch:n}).toString(),Re=await fetch(`/api/vm-exec/exec/${encodeURIComponent(X)}?${ne}`,{method:"POST",headers:{"x-org-id":e.id}});if(!Re.ok)throw new Error(`Exec failed: ${Re.statusText}`);x(Je=>{const jt=new Set(Je);return jt.delete(X),jt})}finally{b(!1)}}},le=async X=>{if(!(v||!u||!se||!n)){b(!0);try{const ne=new URLSearchParams({virtualMcpId:se,branch:n}).toString(),Re=await fetch(`/api/vm-exec/kill/${encodeURIComponent(X)}?${ne}`,{method:"POST",headers:{"x-org-id":e.id}});if(!Re.ok)throw new Error(`Kill failed: ${Re.statusText}`);x(Je=>new Set(Je).add(X))}finally{b(!1)}}},ue=X=>{E.includes(X)||M(ne=>[...ne,X]),D(X),Y(X)},de=async()=>{if(!y.current){y.current=!0,s?.entity?.id&&n&&gi.clear(s.entity.id,n),j.current=Date.now(),f("creating"),m("Connecting..."),g(""),ie.current=!1,M([]),D("setup");try{if(!s?.entity)throw new Error("No virtual MCP context");const X={virtualMcpId:s.entity.id};n&&(X.branch=n);const ne=await ee("VM_START",X);if(!ne.vmId||!ne.branch)throw new Error("Invalid VM response — missing fields");n||a(ne.branch),m(""),oi(i)}catch(X){f("error"),g(X instanceof Error?X.message:"Failed to start VM")}finally{y.current=!1}}},fe=async()=>{const X=u?.branch??n;f("stopping");const ne=s?.entity?.id;if(ne&&X&&gi.mark(ne,X),ne&&X)try{await G.callTool({name:"VM_DELETE",arguments:{virtualMcpId:ne,branch:X}})}catch{}oi(i)},_e=kp(),Ue=s?.entity?.metadata?.runtime,$e="__none__",Qe=Object.keys(Np),at=async(X,ne)=>{if(s?.entity)try{await G.callTool({name:"COLLECTION_VIRTUAL_MCP_UPDATE",arguments:{id:s.entity.id,data:{metadata:{runtime:{...Ue,[X]:ne}}}}}),oi(i)}catch{pe.error("Failed to update setting")}};if(q==="idle"||q==="stopping"){const X=q==="stopping";return o.jsx("div",{className:"flex flex-col items-center justify-center w-full h-full p-6",children:o.jsxs("div",{className:"flex flex-col gap-4 w-full max-w-xs",children:[_e&&o.jsxs("a",{href:`https://github.com/${_e.owner}/${_e.name}`,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-3 p-4 rounded-lg border border-border hover:bg-accent/50 transition-colors",children:[o.jsx(th,{size:24}),o.jsxs("div",{className:"flex flex-col gap-0.5 min-w-0 flex-1",children:[o.jsxs("span",{className:"text-sm font-medium truncate",children:[_e.owner,"/",_e.name]}),o.jsxs("span",{className:"text-xs text-muted-foreground truncate",children:["github.com/",_e.owner,"/",_e.name]})]}),o.jsx(qt,{size:14,className:"text-muted-foreground shrink-0"})]}),o.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-2 w-full",children:[o.jsxs("div",{className:"flex flex-col gap-1",children:[o.jsx(Ms,{htmlFor:"env-runtime",className:"text-xs font-medium",children:"Runtime"}),o.jsxs(ts,{value:Ue?.selected??$e,onValueChange:ne=>at("selected",ne===$e?null:ne),children:[o.jsx(ss,{id:"env-runtime",className:"w-28",children:o.jsx(is,{placeholder:"None"})}),o.jsxs(rs,{children:[o.jsx(At,{value:$e,children:"None"}),Qe.map(ne=>o.jsx(At,{value:ne,children:ne},ne))]})]})]}),o.jsxs("div",{className:"flex flex-col gap-1",children:[o.jsx(Ms,{htmlFor:"env-port",className:"text-xs font-medium",children:"Port"}),o.jsx(_s,{id:"env-port",placeholder:"3001",className:"w-20 h-8",defaultValue:Ue?.port??"",onBlur:ne=>at("port",ne.target.value||null)})]}),o.jsxs(oe,{onClick:de,disabled:X,children:[X?o.jsx(Ie,{size:14,className:"animate-spin"}):o.jsx(li,{size:14}),X?"Stopping...":"Run"]})]})]})})}if(q==="creating"){const X=W.notFound?"Sandbox was stopped, we're restarting it…":_;return o.jsxs("div",{className:"flex flex-col items-center justify-center w-full h-full gap-4",children:[o.jsx(Ie,{size:24,className:"animate-spin text-muted-foreground"}),o.jsx("p",{className:"text-sm text-muted-foreground",children:X}),o.jsx(cc,{since:j.current})]})}if(q==="error")return o.jsx(za,{errorMsg:p,onRetry:de});if(q==="suspended")return o.jsx(Oa,{onResume:de});const Q=["setup",...E,...t?["daemon"]:[]],Ne=W.scripts.filter(X=>!E.includes(X));return o.jsx("div",{className:"flex flex-col w-full h-full",children:o.jsxs("div",{className:"flex flex-col h-full",children:[o.jsxs("div",{className:"flex h-12 items-center border-b border-border px-2 shrink-0",children:[Q.map(X=>o.jsx("button",{type:"button",onClick:()=>D(X),className:re("flex items-center h-full px-3 text-sm whitespace-nowrap border-b-2 mb-[-1px] capitalize transition-all hover:text-foreground",C===X?"text-foreground border-primary":"text-muted-foreground border-transparent"),children:X},X)),Ne.length>0&&o.jsxs(ns,{children:[o.jsx(os,{asChild:!0,children:o.jsx("button",{type:"button",className:"flex items-center h-full px-2 text-muted-foreground hover:text-foreground transition-colors",children:o.jsx(cs,{size:14})})}),o.jsx(as,{align:"start",children:Ne.map(X=>o.jsx(wt,{onClick:()=>ue(X),children:X},X))})]}),o.jsx("div",{className:"flex-1 flex justify-center",children:u?.vmId&&o.jsxs("div",{className:"flex items-center",children:[o.jsxs(Ke,{children:[o.jsx(qe,{asChild:!0,children:o.jsx("button",{type:"button",className:"shrink-0 rounded-l bg-muted px-1.5 py-0.5 text-[10px] font-mono text-muted-foreground cursor-pointer hover:bg-accent hover:text-foreground transition-colors border-r border-border/50",onClick:()=>navigator.clipboard.writeText(u?.vmId??""),children:u.vmId})}),o.jsx(Ge,{side:"bottom",children:"Copy VM ID"})]}),o.jsxs(ns,{children:[o.jsx(os,{asChild:!0,children:o.jsx("button",{type:"button",className:"shrink-0 self-stretch rounded-r bg-muted px-0.5 text-[10px] text-muted-foreground cursor-pointer hover:bg-accent hover:text-foreground transition-colors",children:o.jsx(fr,{size:10})})}),o.jsx(as,{align:"center",children:o.jsxs(wt,{onClick:fe,children:[o.jsx(En,{size:12}),"Stop Server"]})})]})]})}),o.jsxs("div",{className:"flex items-center gap-1",children:[w&&o.jsxs("button",{type:"button",onClick:z,className:"flex items-center gap-1 rounded-md border border-border px-2 py-1 text-xs font-medium text-muted-foreground hover:text-foreground hover:bg-muted transition-colors",children:[o.jsx(Nc,{size:12}),"Add to chat"]}),C!=="setup"&&C!=="daemon"&&E.includes(C)&&(()=>{const X=Lo.includes(C),ne=W.appStatus?.status==="up"||W.appStatus?.status==="starting",Re=X?ne:W.activeProcesses.includes(C)&&!S.has(C),Je=()=>Y(C),jt=()=>le(C);return o.jsxs("div",{className:"flex items-center",children:[o.jsxs("button",{type:"button",disabled:v,onClick:Je,className:re("flex items-center gap-1 border border-border px-2 py-1 text-xs font-medium text-muted-foreground hover:text-foreground hover:bg-muted transition-colors disabled:opacity-50",Re?"rounded-l-md border-r-0":"rounded-md"),children:[v?o.jsx(Ie,{size:12,className:"animate-spin"}):o.jsx(li,{size:12}),v?"Running...":Re?"Restart":"Run"]}),Re&&o.jsxs(ns,{children:[o.jsx(os,{asChild:!0,children:o.jsx("button",{type:"button",disabled:v,className:"flex items-center self-stretch rounded-r-md border border-border px-1 text-xs text-muted-foreground hover:text-foreground hover:bg-muted transition-colors disabled:opacity-50",children:o.jsx(fr,{size:12})})}),o.jsx(as,{align:"end",children:o.jsxs(wt,{onClick:jt,children:[o.jsx(En,{size:12}),X?"Stop":"Stop Process"]})})]})]})})()]})]}),o.jsx("div",{className:"flex-1 overflow-hidden",children:Q.map(X=>o.jsx("div",{className:re("h-full",C===X?"block":"hidden"),children:W.hasData(X)||X==="setup"||X==="daemon"?o.jsx(Cp,{source:X,onReady:ne=>{A.current.set(X,ne)},onSelectionChange:(ne,Re)=>B(X,ne,Re),className:"h-full"}):o.jsx(Ls,{className:"h-full",image:null,title:`Script "${X}" not running`,description:`Click Run to start "${X}".`,actions:o.jsxs(oe,{variant:"outline",size:"sm",disabled:v,onClick:()=>Y(X),children:[v?o.jsx(Ie,{size:14,className:"animate-spin"}):o.jsx(li,{size:14}),"Run"]})})},X))})]})})}function Ep(t){const e=H.c(1);let s;return e[0]===Symbol.for("react.memo_cache_sentinel")?(s=o.jsx(jp,{}),e[0]=s):s=e[0],s}function As(t){const e=t.trim().split(/\s+/);return e.length!==5?!1:e.every(s=>/^[\d*/,-]+$/.test(s))}function Tp(t){if(!t)return"Unknown schedule";const e=t.trim();if(e==="* * * * *")return"Every minute";if(e==="0 * * * *")return"Every hour";if(e==="0 0 * * *")return"Every day";if(e==="0 0 * * 1")return"Every week";const s=e.match(/^\*\/(\d+)\s+\*\s+\*\s+\*\s+\*$/);if(s)return`Every ${s[1]} minutes`;const i=e.match(/^0\s+\*\/(\d+)\s+\*\s+\*\s+\*$/);if(i)return`Every ${i[1]} hours`;const r=e.match(/^0\s+0\s+\*\/(\d+)\s+\*\s+\*$/);if(r){const l=parseInt(r[1]??"1");return l%7===0?`Every ${l/7} weeks`:`Every ${l} days`}const n=e.match(/^(\d+)\s+(\d+)\s+\*\s+\*\s+\*$/);if(n){const l=(n[2]??"0").padStart(2,"0"),h=(n[1]??"0").padStart(2,"0");return`Every day at ${l}:${h} UTC`}const a=e.match(/^(\d+)\s+(\d+)\s+\*\s+\*\s+(\d)$/);if(a){const h=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][parseInt(a[3]??"0")]??"day",c=(a[2]??"0").padStart(2,"0"),u=(a[1]??"0").padStart(2,"0");return`Every ${h} at ${c}:${u} UTC`}return t}function Rp(t,e){const s=Math.max(1,t);switch(e){case"minutes":return s===1?"* * * * *":`*/${s} * * * *`;case"hours":return s===1?"0 * * * *":`0 */${s} * * *`;case"days":return s===1?"0 0 * * *":`0 0 */${s} * *`;case"weeks":return s===1?"0 0 * * 1":`0 0 */${s*7} * *`}}function Dp(t){const e=t.trim();if(e==="* * * * *")return{count:1,unit:"minutes"};if(e==="0 * * * *")return{count:1,unit:"hours"};if(e==="0 0 * * *")return{count:1,unit:"days"};if(e==="0 0 * * 1")return{count:1,unit:"weeks"};const s=e.match(/^\*\/(\d+)\s+\*\s+\*\s+\*\s+\*$/);if(s)return{count:parseInt(s[1]),unit:"minutes"};const i=e.match(/^0\s+\*\/(\d+)\s+\*\s+\*\s+\*$/);if(i)return{count:parseInt(i[1]),unit:"hours"};const r=e.match(/^0\s+0\s+\*\/(\d+)\s+\*\s+\*$/);if(r){const n=parseInt(r[1]);return n%7===0?{count:n/7,unit:"weeks"}:{count:n,unit:"days"}}return null}function Mp(t,e){return e===1?{minutes:"minute",hours:"hour",days:"day",weeks:"week"}[t]??t:t}const Ip=[{label:"Minute",cron:"* * * * *"},{label:"Hour",cron:"0 * * * *"},{label:"Day",cron:"0 0 * * *"},{label:"Week",cron:"0 0 * * 1"}];function Ap(t){const e=H.c(33),{automationId:s,open:i,onOpenChange:r,onCustomSelect:n,onEventSelect:a}=t,{triggerAdd:l}=Ks(),[h,c]=P.useState(!1),u=i??h;let d;e[0]!==r?(d=A=>{r?r(A):c(A)},e[0]=r,e[1]=d):d=e[1];const f=d;let _;e[2]!==l||e[3]!==s||e[4]!==f?(_=async A=>{try{await l.mutateAsync({automation_id:s,type:"cron",cron_expression:A}),pe.success("Starter added"),f(!1)}catch(I){const k=I,w=k instanceof Error?k.message:"Failed to add starter";pe.error(w)}},e[2]=l,e[3]=s,e[4]=f,e[5]=_):_=e[5];const m=_;let p;e[6]===Symbol.for("react.memo_cache_sentinel")?(p=o.jsx(os,{asChild:!0,children:o.jsxs(oe,{variant:"outline",size:"sm",children:[o.jsx(cs,{size:14}),"Add Starter"]})}),e[6]=p):p=e[6];let g;e[7]===Symbol.for("react.memo_cache_sentinel")?(g=o.jsxs(xh,{className:"gap-2.5",children:[o.jsx(Ds,{size:14,className:"text-muted-foreground shrink-0"}),"Every..."]}),e[7]=g):g=e[7];let v;e[8]!==l||e[9]!==m?(v=Ip.map(A=>o.jsxs(wt,{className:"gap-2.5",onSelect:()=>m(A.cron),disabled:l.isPending,children:[o.jsx(Ds,{size:14,className:"text-muted-foreground shrink-0"}),"Every ",A.label]},A.cron)),e[8]=l,e[9]=m,e[10]=v):v=e[10];let b;e[11]!==v?(b=o.jsxs(bh,{children:[g,o.jsx(Sh,{className:"w-[160px]",children:v})]}),e[11]=v,e[12]=b):b=e[12];let S;e[13]!==f||e[14]!==n?(S=()=>{f(!1),n?.()},e[13]=f,e[14]=n,e[15]=S):S=e[15];let x;e[16]===Symbol.for("react.memo_cache_sentinel")?(x=o.jsx(Ds,{size:14,className:"text-muted-foreground shrink-0"}),e[16]=x):x=e[16];let y;e[17]!==S?(y=o.jsxs(wt,{className:"gap-2.5",onSelect:S,children:[x,"Custom (cron)"]}),e[17]=S,e[18]=y):y=e[18];let j;e[19]!==f||e[20]!==a?(j=()=>{f(!1),a?.()},e[19]=f,e[20]=a,e[21]=j):j=e[21];let C;e[22]===Symbol.for("react.memo_cache_sentinel")?(C=o.jsx(Os,{size:14,className:"text-muted-foreground shrink-0"}),e[22]=C):C=e[22];let T;e[23]!==j?(T=o.jsxs(wt,{className:"gap-2.5",onSelect:j,children:[C,"Event"]}),e[23]=j,e[24]=T):T=e[24];let E;e[25]!==T||e[26]!==b||e[27]!==y?(E=o.jsxs(as,{align:"end",className:"w-[200px]",children:[b,y,T]}),e[25]=T,e[26]=b,e[27]=y,e[28]=E):E=e[28];let M;return e[29]!==f||e[30]!==u||e[31]!==E?(M=o.jsxs(ns,{open:u,onOpenChange:f,children:[p,E]}),e[29]=f,e[30]=u,e[31]=E,e[32]=M):M=e[32],M}function Bp(t){const e=H.c(60),{trigger:s,automationId:i,connectionName:r}=t,{triggerAdd:n,triggerRemove:a}=Ks(),[l,h]=P.useState(!1);let c;e[0]!==s.cron_expression?(c=s.cron_expression?Dp(s.cron_expression):null,e[0]=s.cron_expression,e[1]=c):c=e[1];const u=c,[d,f]=P.useState(u?.count??1),[_,m]=P.useState(!1),[p,g]=P.useState(s.cron_expression??""),v=a.isPending||n.isPending,b=s.type==="cron";let S;e[2]!==i||e[3]!==a||e[4]!==s.id?(S=async()=>{try{await a.mutateAsync({trigger_id:s.id,automation_id:i}),pe.success("Starter removed")}catch{pe.error("Failed to remove starter")}h(!1)},e[2]=i,e[3]=a,e[4]=s.id,e[5]=S):S=e[5];const x=S;let y;e[6]!==n||e[7]!==i||e[8]!==p||e[9]!==a||e[10]!==s.cron_expression||e[11]!==s.id?(y=async()=>{const W=p.trim();if(!W||!As(W)||W===s.cron_expression){m(!1),g(s.cron_expression??"");return}try{await n.mutateAsync({automation_id:i,type:"cron",cron_expression:W}),await a.mutateAsync({trigger_id:s.id,automation_id:i}),m(!1)}catch{pe.error("Failed to update starter"),g(s.cron_expression??""),m(!1)}},e[6]=n,e[7]=i,e[8]=p,e[9]=a,e[10]=s.cron_expression,e[11]=s.id,e[12]=y):y=e[12];const j=y;let C;e[13]!==n||e[14]!==i||e[15]!==u||e[16]!==a||e[17]!==s.cron_expression||e[18]!==s.id?(C=async W=>{if(!u)return;const F=Math.max(1,W),Z=Rp(F,u.unit);if(Z!==s.cron_expression)try{await n.mutateAsync({automation_id:i,type:"cron",cron_expression:Z}),await a.mutateAsync({trigger_id:s.id,automation_id:i})}catch{pe.error("Failed to update starter"),f(u.count)}},e[13]=n,e[14]=i,e[15]=u,e[16]=a,e[17]=s.cron_expression,e[18]=s.id,e[19]=C):C=e[19];const T=C;let E;e[20]!==b?(E=b?o.jsx(Ds,{size:14,className:"text-muted-foreground shrink-0"}):o.jsx(Os,{size:14,className:"text-muted-foreground shrink-0"}),e[20]=b,e[21]=E):E=e[21];let M;e[22]!==r||e[23]!==d||e[24]!==p||e[25]!==T||e[26]!==j||e[27]!==u||e[28]!==b||e[29]!==_||e[30]!==v||e[31]!==s.cron_expression||e[32]!==s.event_type||e[33]!==s.params?(M=u&&b?o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"text-sm text-muted-foreground",children:"Every"}),o.jsx("input",{type:"number",min:1,value:d,onChange:W=>f(parseInt(W.target.value)||1),onBlur:()=>T(d),onKeyDown:W=>{W.key==="Enter"&&W.target.blur(),W.key==="Escape"&&f(u.count)},disabled:v,className:"w-12 text-center text-sm h-7 border border-border rounded-md bg-background px-1 focus:outline-none focus:ring-1 focus:ring-ring"}),o.jsx("span",{className:"text-sm",children:Mp(u.unit,d)})]}):b&&_?o.jsxs(o.Fragment,{children:[o.jsx("input",{type:"text",value:p,onChange:W=>g(W.target.value),onBlur:j,onKeyDown:W=>{W.key==="Enter"&&W.target.blur(),W.key==="Escape"&&(m(!1),g(s.cron_expression??""))},className:"flex-1 text-sm font-mono bg-transparent outline-none",autoFocus:!0}),p&&!As(p)&&o.jsx("span",{className:"text-xs text-muted-foreground/60 shrink-0",children:"invalid"})]}):o.jsxs("div",{className:"flex flex-col gap-0.5 flex-1 min-w-0",children:[o.jsx("span",{className:"text-sm font-mono text-xs text-muted-foreground truncate",children:b?Tp(s.cron_expression??""):`${s.event_type}${r?` · ${r}`:""}`}),!b&&s.params&&Object.keys(s.params).length>0&&o.jsx("span",{className:"text-xs text-muted-foreground/60 truncate",children:Object.entries(s.params).map(Pp).join(", ")})]}),e[22]=r,e[23]=d,e[24]=p,e[25]=T,e[26]=j,e[27]=u,e[28]=b,e[29]=_,e[30]=v,e[31]=s.cron_expression,e[32]=s.event_type,e[33]=s.params,e[34]=M):M=e[34];let A;e[35]!==v?(A=v&&o.jsx(Ie,{size:13,className:"animate-spin text-muted-foreground"}),e[35]=v,e[36]=A):A=e[36];let I;e[37]!==u||e[38]!==b||e[39]!==_||e[40]!==s.cron_expression?(I=b&&!u&&!_&&o.jsx(oe,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>{g(s.cron_expression??""),m(!0)},children:o.jsx(lh,{size:13,className:"text-muted-foreground"})}),e[37]=u,e[38]=b,e[39]=_,e[40]=s.cron_expression,e[41]=I):I=e[41];let k;e[42]===Symbol.for("react.memo_cache_sentinel")?(k=o.jsx(oe,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>h(!0),children:o.jsx(ls,{size:13,className:"text-muted-foreground"})}),e[42]=k):k=e[42];let w;e[43]!==A||e[44]!==I?(w=o.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[A,I,k]}),e[43]=A,e[44]=I,e[45]=w):w=e[45];let N;e[46]!==w||e[47]!==E||e[48]!==M?(N=o.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2.5 rounded-lg border border-border bg-background group",children:[E,M,w]}),e[46]=w,e[47]=E,e[48]=M,e[49]=N):N=e[49];let R;e[50]===Symbol.for("react.memo_cache_sentinel")?(R=o.jsxs(_a,{children:[o.jsx(pa,{children:"Remove Starter"}),o.jsx(ga,{children:"Are you sure you want to remove this starter?"})]}),e[50]=R):R=e[50];let D;e[51]===Symbol.for("react.memo_cache_sentinel")?(D=o.jsx(xa,{children:"Cancel"}),e[51]=D):D=e[51];let B;e[52]!==x?(B=o.jsxs(ma,{children:[R,o.jsxs(va,{children:[D,o.jsx(ba,{onClick:x,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Remove"})]})]}),e[52]=x,e[53]=B):B=e[53];let z;e[54]!==l||e[55]!==B?(z=o.jsx(fa,{open:l,onOpenChange:h,children:B}),e[54]=l,e[55]=B,e[56]=z):z=e[56];let G;return e[57]!==N||e[58]!==z?(G=o.jsxs(o.Fragment,{children:[N,z]}),e[57]=N,e[58]=z,e[59]=G):G=e[59],G}function Pp(t){const[e,s]=t;return`${e}: ${s}`}function Lp(t){const e=H.c(55),{automationId:s,onDone:i}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={binding:"TRIGGER"},e[0]=r):r=e[0];const n=Ti(r),[a,l]=P.useState(),[h,c]=P.useState();let u;e[1]===Symbol.for("react.memo_cache_sentinel")?(u={},e[1]=u):u=e[1];const[d,f]=P.useState(u),{triggerAdd:_}=Ks(),{data:m,isLoading:p}=Ch(a);let g,v,b,S,x,y;if(e[2]!==_||e[3]!==s||e[4]!==a||e[5]!==h||e[6]!==p||e[7]!==i||e[8]!==d||e[9]!==n||e[10]!==m){const T=m?.find(B=>B.type===h);let E;e[17]!==_||e[18]!==s||e[19]!==a||e[20]!==h||e[21]!==i||e[22]!==d?(E=async()=>{if(!(!a||!h))try{await _.mutateAsync({automation_id:s,type:"event",event_type:h,connection_id:a,params:d}),ye("automation_trigger_added",{automation_id:s,trigger_type:"event",connection_id:a,event_type:h}),pe.success("Event trigger added"),i()}catch{pe.error("Failed to add event trigger")}},e[17]=_,e[18]=s,e[19]=a,e[20]=h,e[21]=i,e[22]=d,e[23]=E):E=e[23],g=E,v="flex flex-col gap-3 px-3 py-3 rounded-lg border border-border bg-background";let M,A;e[24]===Symbol.for("react.memo_cache_sentinel")?(A=o.jsx(Os,{size:14,className:"text-muted-foreground shrink-0"}),M=o.jsx("span",{className:"text-sm font-medium",children:"Event trigger"}),e[24]=M,e[25]=A):(M=e[24],A=e[25]);let I;e[26]===Symbol.for("react.memo_cache_sentinel")?(I=o.jsx(ls,{size:13}),e[26]=I):I=e[26],e[27]!==i?(b=o.jsxs("div",{className:"flex items-center gap-2",children:[A,M,o.jsx("button",{type:"button",className:"ml-auto shrink-0 p-0.5 rounded text-muted-foreground hover:text-foreground",onClick:i,children:I})]}),e[27]=i,e[28]=b):b=e[28];const k=a??"";let w;e[29]===Symbol.for("react.memo_cache_sentinel")?(w=B=>{l(B),c(void 0),f({})},e[29]=w):w=e[29];let N;e[30]===Symbol.for("react.memo_cache_sentinel")?(N=o.jsx(ss,{className:"w-full",children:o.jsx(is,{placeholder:"Select connection..."})}),e[30]=N):N=e[30];let R;e[31]!==n?(R=n.length===0?o.jsx("div",{className:"px-2 py-3 text-center text-xs text-muted-foreground",children:"No connections with trigger support"}):n.map($p),e[31]=n,e[32]=R):R=e[32];let D;e[33]!==R?(D=o.jsx(rs,{children:R}),e[33]=R,e[34]=D):D=e[34],e[35]!==k||e[36]!==D?(S=o.jsxs(ts,{value:k,onValueChange:w,children:[N,D]}),e[35]=k,e[36]=D,e[37]=S):S=e[37],e[38]!==a||e[39]!==h||e[40]!==p||e[41]!==m?(x=a&&o.jsxs(ts,{value:h??"",onValueChange:B=>{c(B),f({})},children:[o.jsx(ss,{className:"w-full",children:p?o.jsxs("span",{className:"flex items-center gap-2 text-muted-foreground",children:[o.jsx(Ie,{size:13,className:"animate-spin"}),"Loading events..."]}):o.jsx(is,{placeholder:"Select event type...",children:h??"Select event type..."})}),o.jsx(rs,{children:m?.map(zp)})]}),e[38]=a,e[39]=h,e[40]=p,e[41]=m,e[42]=x):x=e[42],y=T?.paramsSchema&&Object.keys(T.paramsSchema).length>0&&o.jsx("div",{className:"flex flex-col gap-2",children:Object.entries(T.paramsSchema).map(B=>{const[z,G]=B;return o.jsxs("div",{className:"flex flex-col gap-1",children:[o.jsxs("label",{className:"text-xs text-muted-foreground",children:[z,G.description&&o.jsxs("span",{className:"text-muted-foreground/60",children:[" ","— ",G.description]})]}),G.enum?o.jsxs(ts,{value:d[z]??"",onValueChange:W=>f(F=>({...F,[z]:W})),children:[o.jsx(ss,{className:"w-full",children:o.jsx(is,{placeholder:`Select ${z}...`})}),o.jsx(rs,{children:G.enum.map(Op)})]}):o.jsx("input",{type:"text",value:d[z]??"",onChange:W=>f(F=>({...F,[z]:W.target.value})),placeholder:G.description??z,className:"text-sm border border-border rounded-md bg-background px-2 py-1.5 focus:outline-none focus:ring-1 focus:ring-ring"})]},z)})}),e[2]=_,e[3]=s,e[4]=a,e[5]=h,e[6]=p,e[7]=i,e[8]=d,e[9]=n,e[10]=m,e[11]=g,e[12]=v,e[13]=b,e[14]=S,e[15]=x,e[16]=y}else g=e[11],v=e[12],b=e[13],S=e[14],x=e[15],y=e[16];let j;e[43]!==_||e[44]!==a||e[45]!==h||e[46]!==g?(j=a&&h&&o.jsx(oe,{size:"sm",onClick:g,disabled:_.isPending,children:_.isPending?o.jsx(Ie,{size:13,className:"animate-spin"}):"Add trigger"}),e[43]=_,e[44]=a,e[45]=h,e[46]=g,e[47]=j):j=e[47];let C;return e[48]!==v||e[49]!==b||e[50]!==S||e[51]!==x||e[52]!==y||e[53]!==j?(C=o.jsxs("div",{className:v,children:[b,S,x,y,j]}),e[48]=v,e[49]=b,e[50]=S,e[51]=x,e[52]=y,e[53]=j,e[54]=C):C=e[54],C}function Op(t){return o.jsx(At,{value:t,children:t},t)}function zp(t){return o.jsx(At,{value:t.type,children:o.jsxs("div",{className:"flex flex-col",children:[o.jsx("span",{children:t.type}),o.jsx("span",{className:"text-xs text-muted-foreground",children:t.description})]})},t.type)}function $p(t){return o.jsx(At,{value:t.id,children:t.title},t.id)}function Fp({automationId:t,automation:e,onBack:s,onDelete:i}){const r=e.virtual_mcp_id,{org:n}=ve(),{update:a,triggerAdd:l}=Ks(),h=Ti(),c=new Map(h.map(Q=>[Q.id,Q.title])),{createTaskWithMessage:u}=vt(),{setModel:d,credentialId:f,selectedModel:_}=Zr(),{setChatOpen:m}=Ei(),{sendMessage:p}=fs(),g=ca(),[v,b]=$l(),S=e.messages?.[0]?.metadata?.tiptapDoc??void 0,[x,y]=P.useState(S),[j,C]=P.useState(!1),[T,E]=P.useState(!1),[M,A]=P.useState(""),[I,k]=P.useState(!1),[w,N]=P.useState(!1),R=P.useRef(!1),D=P.useRef(!1),B=P.useRef(S),z=async()=>{if(w)return;const Ne=bn(x).filter(X=>X.type==="text").map(X=>X.text).join(`
|
|
182
|
-
`);if(Ne.trim()){N(!0);try{le(),ye("automation_improve_clicked",{automation_id:t,agent_id:r,instructions_length:Ne.length}),await g(["studio-automation-manager"]),m(!0),await p({tiptapDoc:Ma({managerAgentId:Jo.AUTOMATION_MANAGER(n.id),managerName:"Automation Manager",kind:"automation",id:t,instructions:Ne})})}finally{N(!1)}}},G=e.models?.credentialId||f||"",W=e.models?.thinking?.id||_?.modelId||"",F=Ko({defaultValues:{name:e.name,active:e.active,credential_id:G,model_id:W}}),Z=F.watch("active"),q=F.watch("credential_id"),$=F.watch("model_id"),{models:U,isLoading:V}=Dc(q||void 0),se=U.find(Q=>Q.modelId===$)??null,L=P.useRef(null),te=P.useRef(new Set),ie=P.useRef(0),ee=P.useRef(null),Y=3e4,le=()=>{ee.current&&(clearTimeout(ee.current),ee.current=null),L.current!==null&&(ye("automation_updated",{automation_id:t,agent_id:r,fields:Array.from(te.current),save_count:ie.current,edit_duration_ms:Date.now()-L.current}),L.current=null,te.current=new Set,ie.current=0)},ue=P.useRef(new Set),de=Q=>{ue.current.add(Q)},fe=async()=>{const Q=Array.from(ue.current);if(!(Q.length>0)&&!D.current)return!0;const X=D.current;D.current=!1,ue.current=new Set;const ne=F.getValues(),Re=B.current;try{const Je=ne.credential_id&&ne.model_id?ne.credential_id:"",jt=ne.credential_id&&ne.model_id?ne.model_id:"",Rl={id:t,name:ne.name,active:ne.active,models:{credentialId:Je,thinking:{id:jt}},messages:Jl(Re),temperature:0};await a.mutateAsync(Rl),L.current===null&&(L.current=Date.now());for(const Dl of Q)te.current.add(Dl);return X&&te.current.add("messages"),ie.current+=1,ee.current&&clearTimeout(ee.current),ee.current=setTimeout(le,Y),Je!==ne.credential_id&&F.setValue("credential_id",Je),jt!==ne.model_id&&F.setValue("model_id",jt),!0}catch{D.current=!0;for(const Je of Q)ue.current.add(Je);return!1}},{schedule:_e,flush:Ue}=Ca({save:fe}),$e=Q=>{Q&&de(Q),_e()},Qe=Q=>{if(B.current=Q,y(Q),!R.current){R.current=!0;return}D.current=!0,_e()},at=async()=>{ye("automation_test_clicked",{automation_id:t,agent_id:r});const Q=await Ue();if(le(),!Q)return;if(!x){pe.error("No instructions configured for this automation");return}se&&q&&d({...se,keyId:q}),b({...v,toolApprovalLevel:"auto"});const Ne=bn(x);u({message:{tiptapDoc:x,parts:Ne},virtualMcpId:r||void 0})};return o.jsxs(o.Fragment,{children:[s&&o.jsx("div",{className:"flex items-center pb-4 shrink-0",children:o.jsxs(oe,{variant:"ghost",size:"sm",onClick:s,children:[o.jsx(ja,{size:14}),"Back to list"]})}),o.jsxs("div",{className:"flex flex-col gap-8",children:[o.jsxs("div",{className:"flex flex-col gap-1.5",children:[o.jsxs("div",{className:"flex items-center justify-between gap-4",children:[o.jsx($t,{control:F.control,name:"name",render:({field:Q})=>o.jsx(_s,{...Q,onChange:Ne=>{Q.onChange(Ne),$e("name")},placeholder:"Automation name",className:"border border-transparent shadow-none px-0 text-lg font-medium h-auto focus-visible:ring-0 focus-visible:border-border bg-transparent flex-1",style:{boxShadow:"none"}})}),i&&o.jsx(oe,{variant:"ghost",size:"icon",className:"text-muted-foreground hover:text-destructive shrink-0",onClick:i,children:o.jsx(ur,{size:14})})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx($t,{control:F.control,name:"active",render:({field:Q})=>o.jsx(dr,{checked:Q.value,onCheckedChange:Ne=>{Q.onChange(Ne),de("active"),setTimeout(()=>Ue(),0)},className:"cursor-pointer"})}),o.jsx("span",{className:"text-sm text-muted-foreground",children:Z?"Active":"Inactive"}),o.jsx("span",{className:"text-muted-foreground/50 text-sm",children:"·"}),o.jsx(ha,{id:e.created_by,size:"2xs",className:"text-sm text-muted-foreground"})]})]}),o.jsxs("div",{className:"flex flex-col gap-2.5",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Starter"}),o.jsx(Ap,{automationId:t,open:j,onOpenChange:C,onCustomSelect:()=>{E(!0),k(!1),A("")},onEventSelect:()=>{k(!0),E(!1)}})]}),e.triggers.length===0&&!T?o.jsx("div",{className:"rounded-lg border border-dashed border-border px-4 py-6 text-center",children:o.jsxs("p",{className:"text-sm text-muted-foreground",children:["When should this automation run?"," ",o.jsx("button",{type:"button",className:"text-foreground underline underline-offset-2 cursor-pointer hover:text-foreground/80 transition-colors",onClick:()=>C(!0),children:"Add a starter"})," ","to get going."]})}):o.jsx("div",{className:"flex flex-col gap-2",children:e.triggers.map(Q=>o.jsx(Bp,{trigger:Q,automationId:t,connectionName:Q.connection_id?c.get(Q.connection_id):void 0},Q.id))}),T&&o.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2.5 rounded-lg border border-border bg-background group",children:[o.jsx(Ds,{size:14,className:"text-muted-foreground shrink-0"}),o.jsx("input",{type:"text",value:M,onChange:Q=>A(Q.target.value),onBlur:async()=>{const Q=M.trim();if(!(!Q||!As(Q)))try{await l.mutateAsync({automation_id:t,type:"cron",cron_expression:Q}),ye("automation_trigger_added",{automation_id:t,trigger_type:"cron"}),pe.success("Starter added"),E(!1),A("")}catch{pe.error("Failed to add starter")}},onKeyDown:async Q=>{const Ne=M.trim();Q.key==="Enter"&&Ne&&As(Ne)&&Q.target.blur(),Q.key==="Escape"&&(E(!1),A(""))},placeholder:"0 9 * * 1-5",className:"flex-1 text-sm font-mono bg-transparent outline-none placeholder:text-muted-foreground/40",autoFocus:!0}),M&&!As(M)&&o.jsx("span",{className:"text-xs text-muted-foreground/60 shrink-0",children:"invalid"}),l.isPending&&o.jsx(Ie,{size:13,className:"animate-spin text-muted-foreground shrink-0"}),o.jsx("button",{type:"button",className:"shrink-0 p-0.5 rounded text-muted-foreground opacity-0 group-hover:opacity-100 hover:text-foreground transition-opacity",onClick:()=>{E(!1),A("")},children:o.jsx(ls,{size:13})})]}),I&&o.jsx(P.Suspense,{fallback:o.jsxs("div",{className:"flex items-center gap-2 px-3 py-3 rounded-lg border border-border bg-background",children:[o.jsx(Ie,{size:13,className:"animate-spin text-muted-foreground"}),o.jsx("span",{className:"text-sm text-muted-foreground",children:"Loading connections..."})]}),children:o.jsx(Lp,{automationId:t,onDone:()=>k(!1)})})]}),o.jsxs("div",{className:"flex flex-col gap-2.5",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Instructions"}),o.jsxs(oe,{variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",disabled:w||!x,onClick:z,children:[o.jsx(wa,{size:13}),"Improve"]})]}),o.jsx(ql,{tiptapDoc:x,setTiptapDoc:Qe,placeholder:"What should this automation do?",children:o.jsxs("div",{className:"rounded-xl border border-border min-h-[120px] flex flex-col",children:[o.jsx(Gl,{virtualMcpId:r||null,className:"max-h-[45vh]"}),o.jsxs("div",{className:"flex items-center justify-end gap-1.5 p-2.5",children:[o.jsx(wh,{model:se,isLoading:V,credentialId:q||null,onCredentialChange:Q=>{F.setValue("credential_id",Q??""),F.setValue("model_id",""),de("credential_id"),de("model_id"),_e()},onModelChange:Q=>{F.setValue("model_id",Q.modelId),$e("model_id")},placeholder:"Model"}),o.jsxs(Ke,{children:[o.jsx(qe,{asChild:!0,children:o.jsxs(oe,{type:"button",variant:"default",className:"h-8 gap-1.5 rounded-md px-3 text-sm font-medium",onClick:at,disabled:!r,children:[o.jsx(rc,{size:16}),"Test"]})}),o.jsx(Ge,{children:"Test Automation"})]})]})]})})]})]})]})}function Hp(t){const e=H.c(5),{tabId:s}=t;let i;e[0]!==s?(i=Qo(s),e[0]=s,e[1]=i):i=e[1];const r=i;if(!r)return null;let n;e[2]===Symbol.for("react.memo_cache_sentinel")?(n=o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsx(Ie,{size:20,className:"animate-spin text-muted-foreground"})}),e[2]=n):n=e[2];let a;return e[3]!==r.id?(a=o.jsx(ct,{children:o.jsx(ct.Content,{children:o.jsx(ct.Body,{children:o.jsx(P.Suspense,{fallback:n,children:o.jsx(Wp,{id:r.id})})})})}),e[3]=r.id,e[4]=a):a=e[4],a}function Wp(t){const e=H.c(8),{id:s}=t,i=Bt(),{data:r,isLoading:n}=kh(s);let a;e[0]!==i?(a=()=>i({to:".",search:Up,replace:!0}),e[0]=i,e[1]=a):a=e[1];const l=a;if(n){let c;return e[2]===Symbol.for("react.memo_cache_sentinel")?(c=o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsx(Ie,{size:20,className:"animate-spin text-muted-foreground"})}),e[2]=c):c=e[2],c}if(!r){let c;return e[3]===Symbol.for("react.memo_cache_sentinel")?(c=o.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:"Automation not found"}),e[3]=c):c=e[3],c}let h;return e[4]!==r||e[5]!==s||e[6]!==l?(h=o.jsx(Fp,{automationId:s,automation:r,onBack:l}),e[4]=r,e[5]=s,e[6]=l,e[7]=h):h=e[7],h}function Up(t){return{...t,main:"automations"}}function Vp(t){const e=H.c(20),{virtualMcpId:s}=t,i=Bt(),{data:r}=Nh(s),n=r===void 0?[]:r,{create:a}=Ks(),[l,h]=P.useState(""),c=l.toLowerCase(),u=n.filter(M=>M.name.toLowerCase().includes(c));let d;e[0]!==i?(d=M=>i({to:".",search:A=>({...A,main:"automation:"+M}),replace:!0}),e[0]=i,e[1]=d):d=e[1];const f=d,_=async()=>{if(a.isPending)return;ye("automation_new_clicked",{virtual_mcp_id:s,existing_count:n.length});const M=await a.mutateAsync(Eh(s));f(M.id)},m=ct,p=ct,g=ct;let v;e[2]===Symbol.for("react.memo_cache_sentinel")?(v=o.jsx(ct.Title,{children:"Automations"}),e[2]=v):v=e[2];const b=n.length>0&&o.jsx(Th,{value:l,onChange:h,placeholder:"Search automations...",className:"w-full md:w-[375px]"});let S;e[3]===Symbol.for("react.memo_cache_sentinel")?(S=o.jsx(cs,{size:14}),e[3]=S):S=e[3];let x;e[4]!==a.isPending||e[5]!==_?(x=o.jsxs(oe,{size:"sm",onClick:_,disabled:a.isPending,children:[S,"New automation"]}),e[4]=a.isPending,e[5]=_,e[6]=x):x=e[6];let y;e[7]!==b||e[8]!==x?(y=o.jsxs("div",{className:"flex flex-col gap-6",children:[v,o.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[b,x]})]}),e[7]=b,e[8]=x,e[9]=y):y=e[9];const j=n.length===0?o.jsx("div",{className:"flex items-center justify-center py-20",children:o.jsx(Ls,{image:o.jsx(Os,{size:48,className:"text-muted-foreground"}),title:"No automations yet",description:"Create your first automation to run this agent on a schedule or in response to events.",actions:o.jsxs(oe,{size:"sm",onClick:_,disabled:a.isPending,children:[o.jsx(cs,{size:14}),"New automation"]})})}):u.length===0?o.jsx("div",{className:"flex items-center justify-center py-20",children:o.jsx(Ls,{image:o.jsx(Os,{size:48,className:"text-muted-foreground"}),title:"No automations found",description:`No automations match "${l}"`})}):o.jsx("div",{className:"mt-6 rounded-xl border border-border overflow-hidden",children:u.map(M=>o.jsx(jh,{automation:M,onClick:()=>f(M.id)},M.id))});let C;e[10]!==j||e[11]!==g.Body||e[12]!==y?(C=o.jsxs(g.Body,{children:[y,j]}),e[10]=j,e[11]=g.Body,e[12]=y,e[13]=C):C=e[13];let T;e[14]!==C||e[15]!==p.Content?(T=o.jsx(p.Content,{children:C}),e[14]=C,e[15]=p.Content,e[16]=T):T=e[16];let E;return e[17]!==m||e[18]!==T?(E=o.jsx(m,{children:T}),e[17]=m,e[18]=T,e[19]=E):E=e[19],E}function Kp(t){const e=H.c(3),{virtualMcpId:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsx(Ie,{size:20,className:"animate-spin text-muted-foreground"})}),e[0]=i):i=e[0];let r;return e[1]!==s?(r=o.jsx(P.Suspense,{fallback:i,children:o.jsx(Vp,{virtualMcpId:s})}),e[1]=s,e[2]=r):r=e[2],r}const Oo=P.lazy(()=>Fl(()=>import("./project-app-view-k_Cpcixt.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56])).then(t=>({default:t.AppViewContent})));function qp(t){const e=H.c(43),{taskId:s,virtualMcpId:i}=t;let r;e[0]!==s||e[1]!==i?(r={virtualMcpId:i,taskId:s},e[0]=s,e[1]=i,e[2]=r):r=e[2];const{activeTab:n,layoutTabs:a,expandedTools:l,automationTabParsed:h}=Da(r);if(hc(n)){let m;return e[3]!==i?(m=o.jsx($n,{virtualMcpId:i}),e[3]=i,e[4]=m):m=e[4],m}if(n==="git"){let m;return e[5]!==i?(m=o.jsx(Eu,{virtualMcpId:i}),e[5]=i,e[6]=m):m=e[6],m}if(n==="automations"){let m;return e[7]!==i?(m=o.jsx(Kp,{virtualMcpId:i}),e[7]=i,e[8]=m):m=e[8],m}if(n==="env"){let m;return e[9]!==i?(m=o.jsx(Ep,{virtualMcpId:i}),e[9]=i,e[10]=m):m=e[10],m}if(n==="preview"){let m;return e[11]!==i?(m=o.jsx(df,{virtualMcpId:i}),e[11]=i,e[12]=m):m=e[12],m}if(h){let m;return e[13]!==n?(m=o.jsx(Hp,{tabId:n}),e[13]=n,e[14]=m):m=e[14],m}let c;e[15]!==n?(c=dc(n),e[15]=n,e[16]=c):c=e[16];const u=c;if(u){let m;if(e[17]!==l||e[18]!==u.connectionId||e[19]!==u.toolName){let S;e[21]!==u.connectionId||e[22]!==u.toolName?(S=x=>x.appId===u.connectionId&&x.toolName===u.toolName,e[21]=u.connectionId,e[22]=u.toolName,e[23]=S):S=e[23],m=l.find(S),e[17]=l,e[18]=u.connectionId,e[19]=u.toolName,e[20]=m}else m=e[20];const p=m;let g;e[24]===Symbol.for("react.memo_cache_sentinel")?(g=o.jsx("div",{className:"h-full w-full flex items-center justify-center",children:o.jsx(Ie,{size:20,className:"animate-spin text-muted-foreground"})}),e[24]=g):g=e[24];const v=p?.args;let b;return e[25]!==n||e[26]!==u.connectionId||e[27]!==u.toolName||e[28]!==v?(b=o.jsx(P.Suspense,{fallback:g,children:o.jsx(Oo,{connectionId:u.connectionId,toolName:u.toolName,args:v},n)}),e[25]=n,e[26]=u.connectionId,e[27]=u.toolName,e[28]=v,e[29]=b):b=e[29],b}let d;if(e[30]!==n||e[31]!==a){let m;e[33]!==n?(m=p=>p.id===n,e[33]=n,e[34]=m):m=e[34],d=a.find(m),e[30]=n,e[31]=a,e[32]=d}else d=e[32];const f=d;if(f){let m;e[35]===Symbol.for("react.memo_cache_sentinel")?(m=o.jsx("div",{className:"h-full w-full flex items-center justify-center",children:o.jsx(Ie,{size:20,className:"animate-spin text-muted-foreground"})}),e[35]=m):m=e[35];let p;return e[36]!==n||e[37]!==f.id||e[38]!==f.view.appId||e[39]!==f.view.args?(p=o.jsx(P.Suspense,{fallback:m,children:o.jsx(Oo,{connectionId:f.view.appId,toolName:f.id,args:f.view.args},n)}),e[36]=n,e[37]=f.id,e[38]=f.view.appId,e[39]=f.view.args,e[40]=p):p=e[40],p}let _;return e[41]!==i?(_=o.jsx($n,{virtualMcpId:i}),e[41]=i,e[42]=_):_=e[42],_}function Gp(t){const e=H.c(7),{children:s,defaultSize:i}=t,[,r]=P.useTransition();let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=Yo.decoChatPanelWidth(),e[0]=n):n=e[0];const[a,l]=Go(n,45),h=i>0&&i<100?a:i;let c;e[1]!==l?(c=f=>r(()=>{f>0&&f<100&&l(f)}),e[1]=l,e[2]=c):c=e[2];const u=c;let d;return e[3]!==s||e[4]!==h||e[5]!==u?(d=o.jsx(la,{defaultSize:h,minSize:20,collapsible:!0,collapsedSize:0,className:"min-w-0 overflow-hidden bg-sidebar",onResize:u,order:1,children:s}),e[3]=s,e[4]=h,e[5]=u,e[6]=d):d=e[6],d}function Yp(t){const e=H.c(30),{virtualMcpId:s,taskId:i,chatOpen:r,mainOpen:n,chatContent:a}=t;let l;e[0]!==r||e[1]!==n?(l=Tn(r,n),e[0]=r,e[1]=n,e[2]=l):l=e[2];const h=l;let c;e[3]===Symbol.for("react.memo_cache_sentinel")?(c=Yo.decoChatPanelWidth(),e[3]=c):c=e[3];const[u]=Go(c,45),d=P.useRef(null);let f,_;e[4]!==r||e[5]!==n||e[6]!==u?(f=()=>{const M=d.current;if(!M)return;const A=Tn(r,n),I=A.chat>0&&A.chat<100?u:A.chat,k=A.chat>0&&A.chat<100?100-u:A.main;M.setLayout([I,k])},_=[r,n,u],e[4]=r,e[5]=n,e[6]=u,e[7]=f,e[8]=_):(f=e[7],_=e[8]),P.useEffect(f,_);const m=`${s}-${i}`;let p;e[9]===Symbol.for("react.memo_cache_sentinel")?(p={overflow:"visible"},e[9]=p):p=e[9];let g;e[10]!==a?(g=a??o.jsx(Ea,{}),e[10]=a,e[11]=g):g=e[11];let v;e[12]!==g?(v=o.jsx("div",{className:"h-full p-0.5 pt-0.25",children:o.jsx("div",{className:"h-full bg-background rounded-[0.75rem] overflow-hidden card-shadow",children:g})}),e[12]=g,e[13]=v):v=e[13];let b;e[14]!==h.chat||e[15]!==v?(b=o.jsx(Gp,{defaultSize:h.chat,children:v}),e[14]=h.chat,e[15]=v,e[16]=b):b=e[16];let S;e[17]===Symbol.for("react.memo_cache_sentinel")?(S=o.jsx(Yc,{className:"bg-sidebar"}),e[17]=S):S=e[17];const x=h.main;let y;e[18]===Symbol.for("react.memo_cache_sentinel")?(y={overflow:"visible"},e[18]=y):y=e[18];let j;e[19]===Symbol.for("react.memo_cache_sentinel")?(j=re("flex flex-col h-full min-h-0 bg-background overflow-hidden","card-shadow","transition-[border-radius] duration-200 ease-[var(--ease-out-quart)]","rounded-[0.75rem]"),e[19]=j):j=e[19];let C;e[20]!==i||e[21]!==s?(C=o.jsx("div",{className:"h-full p-0.5 pt-0.25",children:o.jsx("div",{className:j,children:o.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:o.jsx(Ht,{children:o.jsx(qp,{taskId:i,virtualMcpId:s})})})})}),e[20]=i,e[21]=s,e[22]=C):C=e[22];let T;e[23]!==h.main||e[24]!==C?(T=o.jsx(la,{className:"min-w-0 flex flex-col",order:2,defaultSize:x,style:y,collapsible:!0,collapsedSize:0,minSize:20,children:C}),e[23]=h.main,e[24]=C,e[25]=T):T=e[25];let E;return e[26]!==T||e[27]!==m||e[28]!==b?(E=o.jsxs(Xc,{ref:d,direction:"horizontal",className:"flex-1 min-h-0 pb-1 pr-1 pl-0 pt-0",style:p,children:[b,S,T]},m),e[26]=T,e[27]=m,e[28]=b,e[29]=E):E=e[29],E}const ar="flex size-7 shrink-0 items-center justify-center rounded-md transition-colors",zo="bg-sidebar-accent text-sidebar-foreground",lr="text-sidebar-foreground/60 hover:bg-sidebar-accent hover:text-sidebar-foreground";function Xp(t){const e=H.c(47),{chatOpen:s,toggleChat:i,onNewTask:r}=t,{tasksOpen:n,toggleTasks:a}=Mc(),l=!!r;let h;e[0]!==n||e[1]!==a?(h=()=>{ye("agent_toolbar_toggled",{button:"tasks",next_state:n?"closed":"open"}),a()},e[0]=n,e[1]=a,e[2]=h):h=e[2];const c=n?zo:lr;let u;e[3]!==c?(u=re(ar,c),e[3]=c,e[4]=u):u=e[4];let d;e[5]===Symbol.for("react.memo_cache_sentinel")?(d=o.jsx(jc,{size:16}),e[5]=d):d=e[5];let f;e[6]!==h||e[7]!==u||e[8]!==n?(f=o.jsx(qe,{asChild:!0,children:o.jsx("button",{type:"button",onClick:h,"aria-pressed":n,className:u,children:d})}),e[6]=h,e[7]=u,e[8]=n,e[9]=f):f=e[9];let _;e[10]===Symbol.for("react.memo_cache_sentinel")?(_=o.jsx(Ge,{side:"bottom",children:"Tasks"}),e[10]=_):_=e[10];let m;e[11]!==f?(m=o.jsxs(Ke,{delayDuration:300,children:[f,_]}),e[11]=f,e[12]=m):m=e[12];let p;e[13]!==s||e[14]!==i?(p=()=>{ye("agent_toolbar_toggled",{button:"chat",next_state:s?"closed":"open"}),i()},e[13]=s,e[14]=i,e[15]=p):p=e[15];const g=s?zo:lr;let v;e[16]!==g?(v=re(ar,g),e[16]=g,e[17]=v):v=e[17];let b;e[18]===Symbol.for("react.memo_cache_sentinel")?(b=o.jsx(Ec,{size:16}),e[18]=b):b=e[18];let S;e[19]!==s||e[20]!==v||e[21]!==p?(S=o.jsx(qe,{asChild:!0,children:o.jsx("button",{type:"button",onClick:p,"aria-pressed":s,className:v,children:b})}),e[19]=s,e[20]=v,e[21]=p,e[22]=S):S=e[22];let x;e[23]===Symbol.for("react.memo_cache_sentinel")?(x=o.jsx(Ge,{side:"bottom",children:"Chat"}),e[23]=x):x=e[23];let y;e[24]!==S?(y=o.jsxs(Ke,{delayDuration:300,children:[S,x]}),e[24]=S,e[25]=y):y=e[25];const j=l?"grid-cols-[1fr]":"grid-cols-[0fr]";let C;e[26]!==j?(C=re("grid transition-[grid-template-columns] duration-200 ease-[var(--ease-out-quart)]",j),e[26]=j,e[27]=C):C=e[27];const T=!l,E=l?0:-1,M=!l,A=l?"translate-x-0 opacity-100":"-translate-x-2 opacity-0";let I;e[28]!==A?(I=re(ar,lr,"transition-[transform,opacity] duration-200 ease-[var(--ease-out-quart)] will-change-transform",A),e[28]=A,e[29]=I):I=e[29];let k;e[30]===Symbol.for("react.memo_cache_sentinel")?(k=o.jsx(sa,{size:16}),e[30]=k):k=e[30];let w;e[31]!==r||e[32]!==T||e[33]!==E||e[34]!==M||e[35]!==I?(w=o.jsx(qe,{asChild:!0,children:o.jsx("button",{type:"button",onClick:r,disabled:T,tabIndex:E,"aria-hidden":M,className:I,children:k})}),e[31]=r,e[32]=T,e[33]=E,e[34]=M,e[35]=I,e[36]=w):w=e[36];let N;e[37]===Symbol.for("react.memo_cache_sentinel")?(N=o.jsx(Ge,{side:"bottom",children:"New task"}),e[37]=N):N=e[37];let R;e[38]!==w?(R=o.jsx("div",{className:"overflow-hidden",children:o.jsxs(Ke,{delayDuration:300,children:[w,N]})}),e[38]=w,e[39]=R):R=e[39];let D;e[40]!==C||e[41]!==R?(D=o.jsx("div",{className:C,children:R}),e[40]=C,e[41]=R,e[42]=D):D=e[42];let B;return e[43]!==y||e[44]!==D||e[45]!==m?(B=o.jsxs(o.Fragment,{children:[m,y,D]}),e[43]=y,e[44]=D,e[45]=m,e[46]=B):B=e[46],B}function Jp(t,e,s){if(t.length<=s)return{visible:t,overflow:[]};const i=t.slice(0,s),r=t.slice(s);if(e==null)return{visible:i,overflow:r};if(i.some(d=>d.id===e))return{visible:i,overflow:r};const a=r.findIndex(d=>d.id===e);if(a===-1)return{visible:i,overflow:r};const l=i[i.length-1],h=r[a],c=[...i.slice(0,-1),h],u=[l,...r.slice(0,a),...r.slice(a+1)];return{visible:c,overflow:u}}function Zp(t){const e=H.c(13),{title:s,icon:i,active:r,onClick:n}=t,a=r?"bg-sidebar-accent text-sidebar-foreground":"text-sidebar-foreground/60 hover:bg-sidebar-accent hover:text-sidebar-foreground";let l;e[0]!==a?(l=re("shrink-0 flex items-center gap-1.5 h-8 rounded-md px-2","[transition:background-color_180ms_ease,color_180ms_ease]",a),e[0]=a,e[1]=l):l=e[1];let h;e[2]!==i?(h=o.jsx("span",{className:"flex size-5 items-center justify-center shrink-0",children:o.jsx(Qp,{icon:i})}),e[2]=i,e[3]=h):h=e[3];let c;e[4]!==s?(c=o.jsx("span",{className:"whitespace-nowrap text-sm font-medium leading-none",children:s}),e[4]=s,e[5]=c):c=e[5];let u;return e[6]!==r||e[7]!==n||e[8]!==l||e[9]!==h||e[10]!==c||e[11]!==s?(u=o.jsxs("button",{type:"button",onClick:n,"aria-pressed":r,"aria-label":s,className:l,children:[h,c]}),e[6]=r,e[7]=n,e[8]=l,e[9]=h,e[10]=c,e[11]=s,e[12]=u):u=e[12],u}function Qp(t){const e=H.c(5),{icon:s}=t;if(s.kind==="component"){const{Component:r}=s;let n;return e[0]!==r?(n=o.jsx(r,{className:"size-4"}),e[0]=r,e[1]=n):n=e[1],n}if(s.kind==="url"){let r;return e[2]!==s.src?(r=o.jsx("img",{src:s.src,alt:"",className:"size-4 rounded-sm object-cover"}),e[2]=s.src,e[3]=r):r=e[3],r}let i;return e[4]===Symbol.for("react.memo_cache_sentinel")?(i=o.jsx(oa,{className:"size-4"}),e[4]=i):i=e[4],i}function eg(t){const e=H.c(13),{overflow:s,onSelect:i}=t,[r,n]=P.useState(!1);let a;e[0]!==i?(a=f=>{n(!1),i(f)},e[0]=i,e[1]=a):a=e[1];const l=a;let h;e[2]===Symbol.for("react.memo_cache_sentinel")?(h=o.jsx(Ws,{asChild:!0,children:o.jsx("button",{type:"button",title:"More tabs","aria-label":"More tabs",className:"shrink-0 flex size-8 items-center justify-center rounded-md text-muted-foreground hover:bg-accent hover:text-foreground transition-colors",children:o.jsx(ia,{className:"size-4"})})}),e[2]=h):h=e[2];let c;if(e[3]!==l||e[4]!==s){let f;e[6]!==l?(f=_=>o.jsx("li",{children:o.jsxs("button",{type:"button",onClick:()=>l(_.id),className:"w-full flex items-center gap-2 px-3 py-2 rounded-md hover:bg-accent text-sm text-foreground",children:[o.jsx("span",{className:"flex size-5 items-center justify-center shrink-0",children:o.jsx(tg,{icon:_.icon})}),o.jsx("span",{className:"truncate",children:_.title})]})},_.id),e[6]=l,e[7]=f):f=e[7],c=s.map(f),e[3]=l,e[4]=s,e[5]=c}else c=e[5];let u;e[8]!==c?(u=o.jsx(Us,{align:"end",className:"w-56 p-1",children:o.jsx("ul",{className:"flex flex-col",children:c})}),e[8]=c,e[9]=u):u=e[9];let d;return e[10]!==r||e[11]!==u?(d=o.jsxs(Vs,{open:r,onOpenChange:n,children:[h,u]}),e[10]=r,e[11]=u,e[12]=d):d=e[12],d}function tg(t){const e=H.c(5),{icon:s}=t;if(s.kind==="component"){const{Component:r}=s;let n;return e[0]!==r?(n=o.jsx(r,{className:"size-4"}),e[0]=r,e[1]=n):n=e[1],n}if(s.kind==="url"){let r;return e[2]!==s.src?(r=o.jsx("img",{src:s.src,alt:"",className:"size-4 rounded-sm object-cover"}),e[2]=s.src,e[3]=r):r=e[3],r}let i;return e[4]===Symbol.for("react.memo_cache_sentinel")?(i=o.jsx(oa,{className:"size-4"}),e[4]=i):i=e[4],i}const sg=6;function ig(t){const e=H.c(20),{virtualMcpId:s,taskId:i}=t,r=Bt();let n;e[0]!==i||e[1]!==s?(n={virtualMcpId:s,taskId:i},e[0]=i,e[1]=s,e[2]=n):n=e[2];const{tabs:a,activeTab:l,mainOpen:h,setActiveTab:c}=Da(n);let u,d,f,_;if(e[3]!==l||e[4]!==h||e[5]!==r||e[6]!==c||e[7]!==a||e[8]!==s){const g=uc({activeTab:l,mainOpen:h}),v=j=>j.id==="automations"?g:h&&j.id===l,S=a.find(j=>v(j))?.id??null,{visible:x,overflow:y}=Jp(a,S,sg);d=y,u=j=>{const C=a.find(E=>E.id===j),T=S===j&&h;if(ye("main_panel_tab_clicked",{virtual_mcp_id:s,tab_id:j,tab_kind:C?.kind??null,was_active:T}),j==="automations"){const E=fc({activeTab:l,mainOpen:h});r({to:".",search:M=>({...M,main:E}),replace:!0});return}c(j)},f="flex items-center min-w-0 ml-auto gap-0.5",_=x.map(j=>o.jsx(Zp,{title:j.title,icon:j.icon,active:v(j),onClick:()=>u(j.id)},j.id)),e[3]=l,e[4]=h,e[5]=r,e[6]=c,e[7]=a,e[8]=s,e[9]=u,e[10]=d,e[11]=f,e[12]=_}else u=e[9],d=e[10],f=e[11],_=e[12];let m;e[13]!==u||e[14]!==d?(m=d.length>0&&o.jsx(eg,{overflow:d,onSelect:u}),e[13]=u,e[14]=d,e[15]=m):m=e[15];let p;return e[16]!==f||e[17]!==_||e[18]!==m?(p=o.jsxs("div",{className:f,children:[_,m]}),e[16]=f,e[17]=_,e[18]=m,e[19]=p):p=e[19],p}function rg(t){const e=H.c(12);let s,i,r,n;e[0]!==t?({className:s,orientation:r,decorative:n,...i}=t,e[0]=t,e[1]=s,e[2]=i,e[3]=r,e[4]=n):(s=e[1],i=e[2],r=e[3],n=e[4]);const a=r===void 0?"horizontal":r,l=n===void 0?!0:n;let h;e[5]!==s?(h=re("bg-border shrink-0 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px",s),e[5]=s,e[6]=h):h=e[6];let c;return e[7]!==l||e[8]!==a||e[9]!==i||e[10]!==h?(c=o.jsx(Hl,{"data-slot":"separator-root",decorative:l,orientation:a,className:h,...i}),e[7]=l,e[8]=a,e[9]=i,e[10]=h,e[11]=c):c=e[11],c}function ng(t){const e=H.c(20),{prNumber:s,disabled:i,send:r}=t;let n;e[0]!==s||e[1]!==r?(n=()=>r(gu({prNumber:s})),e[0]=s,e[1]=r,e[2]=n):n=e[2];const a=n;let l;e[3]!==s||e[4]!==r?(l=()=>r(pu({prNumber:s})),e[3]=s,e[4]=r,e[5]=l):l=e[5];const h=l;let c;e[6]!==i||e[7]!==a?(c=o.jsx(oe,{size:"sm",variant:"success",className:"rounded-r-none border-r border-success-foreground/20",disabled:i,onClick:a,children:"Publish"}),e[6]=i,e[7]=a,e[8]=c):c=e[8];let u;e[9]===Symbol.for("react.memo_cache_sentinel")?(u=o.jsx(fr,{className:"h-3.5 w-3.5"}),e[9]=u):u=e[9];let d;e[10]!==i?(d=o.jsx(os,{asChild:!0,children:o.jsx(oe,{size:"sm",variant:"success",className:"rounded-l-none px-2",disabled:i,"aria-label":"More actions",children:u})}),e[10]=i,e[11]=d):d=e[11];let f;e[12]!==h?(f=o.jsx(as,{align:"end",children:o.jsx(wt,{onClick:h,children:"Review"})}),e[12]=h,e[13]=f):f=e[13];let _;e[14]!==d||e[15]!==f?(_=o.jsxs(ns,{children:[d,f]}),e[14]=d,e[15]=f,e[16]=_):_=e[16];let m;return e[17]!==c||e[18]!==_?(m=o.jsxs("div",{className:"inline-flex items-stretch rounded-md",children:[c,_]}),e[17]=c,e[18]=_,e[19]=m):m=e[19],m}const og=new Set(["failure","timed_out","cancelled","action_required"]);function ag(t){return t.status==="completed"&&og.has(t.conclusion)}function lg(t){return t.status==="queued"||t.status==="in_progress"}function cg(t){const{branchStatus:e,pr:s,checks:i,reviews:r,loading:n}=t;if(!e||n)return{label:"Loading…",disabled:!0,loading:!0,variant:"outline",tooltip:"Loading branch and pull request status"};switch(e.kind){case"initializing":return{label:"Starting sandbox…",disabled:!0,loading:!0,variant:"outline",tooltip:"Waiting for the sandbox daemon to come online"};case"cloning":return{label:"Cloning repo…",disabled:!0,loading:!0,variant:"outline",tooltip:"Cloning the project repository"};case"clone-failed":return{label:"Clone failed",disabled:!0,variant:"outline",tooltip:e.error||"git clone failed — see setup logs"};case"checking-out":return{label:`Switching to ${e.to}…`,disabled:!0,loading:!0,variant:"outline",tooltip:`Checking out ${e.to}`};case"checkout-failed":return{label:"Checkout failed",disabled:!0,variant:"outline",tooltip:e.error||"git checkout failed — see setup logs"}}const a=e;if(a.workingTreeDirty||a.unpushed>0)return{label:"Save changes",action:"commit-and-push",variant:"default",tooltip:"Commit and push local changes"};if(s?.merged)return!!a.headSha&&!!s.headSha&&a.headSha!==s.headSha?{label:"Continue",action:"create-pr",variant:"special",tooltip:"Open a new PR with the latest commits"}:{label:"Published",disabled:!0,variant:"outline",tooltip:`PR #${s.number} merged into ${s.base}`};if(a.aheadOfBase>0){if(s&&s.state==="closed"&&!s.merged)return{label:"Reopen",action:"reopen",variant:"default",tooltip:`Reopen PR #${s.number}`};if(!s)return{label:"Submit for review",action:"create-pr",variant:"default",tooltip:`Open a PR for ${a.branch} → ${a.base}`};if((r?.mergeableState??"unknown")==="dirty")return{label:`Sync with ${s.base}`,action:"rebase",variant:"default",tooltip:`Resolve conflicts with ${s.base} before merging`};const c=i.filter(ag).map(f=>f.name);if(c.length>0)return{label:"Fix tests",action:"fix-checks",variant:"default",tooltip:`Failing: ${c.join(", ")}`,meta:{failingChecks:c}};const u=i.filter(lg);if(u.length>0)return{label:"Running tests…",disabled:!0,loading:!0,variant:"outline",tooltip:`Waiting on ${u.length} check${u.length===1?"":"s"} to finish`};if(r?.draft)return{label:"Mark ready",action:"mark-ready",variant:"default",tooltip:"Mark draft PR ready for review"};const d=r?.unresolvedConversations??0;return d>0?{label:"Address feedback",action:"resolve-comments",variant:"default",tooltip:`${d} unresolved conversation${d===1?"":"s"}`}:r?.missingRequiredApprovals?{label:"Awaiting review",disabled:!0,variant:"outline",tooltip:"Waiting for required approvals"}:{label:"Publish",action:"merge-split",variant:"success",tooltip:`Squash-merge PR #${s.number} into ${s.base}`}}return{label:"Up to date",disabled:!0,variant:"outline",tooltip:`Branch is in sync with ${a.base}`}}function hg(){return Gt().branchStatus}const dg=6e4,ug=3e4;function fg(t){const e=H.c(12);let s;e[0]!==t.connectionId||e[1]!==t.orgId||e[2]!==t.orgSlug?(s={connectionId:t.connectionId,orgId:t.orgId,orgSlug:t.orgSlug},e[0]=t.connectionId,e[1]=t.orgId,e[2]=t.orgSlug,e[3]=s):s=e[3];const i=He(s),r=t.prNumber??0;let n;e[4]!==t.owner||e[5]!==t.repo||e[6]!==r?(n={method:"get",owner:t.owner,repo:t.repo,pullNumber:r},e[4]=t.owner,e[5]=t.repo,e[6]=r,e[7]=n):n=e[7];const a=!!t.prNumber;let l;return e[8]!==i||e[9]!==n||e[10]!==a?(l={client:i,toolName:"pull_request_read",toolArguments:n,enabled:a,refetchInterval:dg,refetchIntervalInBackground:!1,staleTime:ug,select:mg},e[8]=i,e[9]=n,e[10]=a,e[11]=l):l=e[11],ms(l)}function mg(t){const e=qs(t);if(!e)return null;const s=e.mergeable_state??"unknown",i=!!(e.draft??!1),r=Number(e.review_comments??0),n=s==="blocked"&&r>0?r:0;return{draft:i,mergeableState:s,unresolvedConversations:n,missingRequiredApprovals:s==="blocked"&&n===0}}function _g(t){const e=H.c(42),{virtualMcpId:s}=t,{org:i}=ve(),r=Ct(s),{currentBranch:n}=vt(),a=fs(),l=r?.metadata?.githubRepo??null,h=hg(),c=l?.connectionId??"",u=l?.owner??"",d=l?.name??"",f=n??null;let _;e[0]!==i.id||e[1]!==i.slug||e[2]!==c||e[3]!==u||e[4]!==d||e[5]!==f?(_={orgId:i.id,orgSlug:i.slug,connectionId:c,owner:u,repo:d,branch:f},e[0]=i.id,e[1]=i.slug,e[2]=c,e[3]=u,e[4]=d,e[5]=f,e[6]=_):_=e[6];const m=Aa(_),p=m.data??null,g=l?.connectionId??"",v=l?.owner??"",b=l?.name??"",S=p&&p.state==="open"?p.number:null;let x;e[7]!==i.id||e[8]!==i.slug||e[9]!==g||e[10]!==v||e[11]!==b||e[12]!==S?(x={orgId:i.id,orgSlug:i.slug,connectionId:g,owner:v,repo:b,prNumber:S},e[7]=i.id,e[8]=i.slug,e[9]=g,e[10]=v,e[11]=b,e[12]=S,e[13]=x):x=e[13];const y=Pa(x),j=l?.connectionId??"",C=l?.owner??"",T=l?.name??"",E=p&&p.state==="open"?p.number:null;let M;e[14]!==i.id||e[15]!==i.slug||e[16]!==j||e[17]!==C||e[18]!==T||e[19]!==E?(M={orgId:i.id,orgSlug:i.slug,connectionId:j,owner:C,repo:T,prNumber:E},e[14]=i.id,e[15]=i.slug,e[16]=j,e[17]=C,e[18]=T,e[19]=E,e[20]=M):M=e[20];const A=fg(M);if(!l?.connectionId||!n)return null;let I;e[21]!==h||e[22]!==y.data||e[23]!==p||e[24]!==m.isPending||e[25]!==A.data?(I=cg({branchStatus:h,pr:p,checks:y.data??[],reviews:A.data??null,loading:m.isPending}),e[21]=h,e[22]=y.data,e[23]=p,e[24]=m.isPending,e[25]=A.data,e[26]=I):I=e[26];const k=I;let w;e[27]!==a?(w=F=>a.sendMessage({parts:[{type:"text",text:F}]}),e[27]=a,e[28]=w):w=e[28];const N=w,R=a.isStreaming;let D;e[29]!==n||e[30]!==k||e[31]!==R||e[32]!==p||e[33]!==N?(D=F=>{if(!R)switch(F){case"commit-and-push":{N(lu({branch:n}));return}case"create-pr":{N(cu({branch:n}));return}case"reopen":{p&&N(hu({prNumber:p.number}));return}case"rebase":{N(du({branch:n}));return}case"fix-checks":{p&&N(fu({prNumber:p.number,failingChecks:k.meta?.failingChecks??[]}));return}case"mark-ready":{p&&N(mu({prNumber:p.number}));return}case"resolve-comments":{p&&N(_u({prNumber:p.number}));return}case"merge-split":return}},e[29]=n,e[30]=k,e[31]=R,e[32]=p,e[33]=N,e[34]=D):D=e[34];const B=D;let z;e[35]===Symbol.for("react.memo_cache_sentinel")?(z=o.jsx(rg,{orientation:"vertical",className:"mx-2 data-[orientation=vertical]:h-5"}),e[35]=z):z=e[35];const G=p?.number;let W;return e[36]!==k||e[37]!==R||e[38]!==B||e[39]!==N||e[40]!==G?(W=o.jsxs(o.Fragment,{children:[z,o.jsx(pg,{button:k,isStreaming:R,onActivate:B,prNumber:G,send:N})]}),e[36]=k,e[37]=R,e[38]=B,e[39]=N,e[40]=G,e[41]=W):W=e[41],W}function pg(t){const e=H.c(21),{button:s,isStreaming:i}=t,r=!!s.disabled||i,n=i?"Chat is running":s.tooltip??null;if(s.action==="merge-split"&&t.prNumber!=null){let u;e[0]!==r||e[1]!==t.prNumber||e[2]!==t.send?(u=o.jsx(ng,{prNumber:t.prNumber,disabled:r,send:t.send}),e[0]=r,e[1]=t.prNumber,e[2]=t.send,e[3]=u):u=e[3];let d;return e[4]!==u||e[5]!==n?(d=o.jsx($o,{label:n,children:u}),e[4]=u,e[5]=n,e[6]=d):d=e[6],d}let a;e[7]!==s.action||e[8]!==t?(a=()=>t.onActivate(s.action),e[7]=s.action,e[8]=t,e[9]=a):a=e[9];let l;e[10]!==s.loading?(l=s.loading?o.jsx(vh,{size:"xs",variant:"default"}):null,e[10]=s.loading,e[11]=l):l=e[11];let h;e[12]!==s.label||e[13]!==s.variant||e[14]!==r||e[15]!==a||e[16]!==l?(h=o.jsxs(oe,{size:"sm",variant:s.variant,disabled:r,onClick:a,children:[l,s.label]}),e[12]=s.label,e[13]=s.variant,e[14]=r,e[15]=a,e[16]=l,e[17]=h):h=e[17];let c;return e[18]!==h||e[19]!==n?(c=o.jsx($o,{label:n,children:h}),e[18]=h,e[19]=n,e[20]=c):c=e[20],c}function $o(t){const e=H.c(9),{label:s,children:i}=t;if(!s){let l;return e[0]!==i?(l=o.jsx(o.Fragment,{children:i}),e[0]=i,e[1]=l):l=e[1],l}let r;e[2]!==i?(r=o.jsx(qe,{asChild:!0,children:o.jsx("span",{children:i})}),e[2]=i,e[3]=r):r=e[3];let n;e[4]!==s?(n=o.jsx(Ge,{children:s}),e[4]=s,e[5]=n):n=e[5];let a;return e[6]!==r||e[7]!==n?(a=o.jsx(Wc,{children:o.jsxs(Ke,{children:[r,n]})}),e[6]=r,e[7]=n,e[8]=a):a=e[8],a}function gg(t){const e=H.c(2),{virtualMcp:s}=t;if(!!!(s.metadata?.githubRepo??null)?.connectionId)return null;let n;return e[0]!==s.id?(n=o.jsx(hr.Right,{children:o.jsx(_g,{virtualMcpId:s.id})}),e[0]=s.id,e[1]=n):n=e[1],n}const Qt=P.createContext(null);function vn(){return P.use(Qt)}function Fo(t){const e=H.c(7),{children:s}=t,{taskId:i}=vt();let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=o.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:"Something went wrong loading the chat. Try refreshing."}),e[0]=r):r=e[0];let n;e[1]===Symbol.for("react.memo_cache_sentinel")?(n=o.jsx(je.Skeleton,{}),e[1]=n):n=e[1];let a;e[2]!==s?(a=s??o.jsx(Ea,{}),e[2]=s,e[3]=a):a=e[3];let l;return e[4]!==a||e[5]!==i?(l=o.jsx(Ht,{fallback:r,children:o.jsx(P.Suspense,{fallback:n,children:o.jsx(je.ActiveTaskProvider,{taskId:i,children:a})})}),e[4]=a,e[5]=i,e[6]=l):l=e[6],l}function Ho(t){const e=H.c(3),{onNewTaskRef:s,createNewTask:i}=t;let r;return e[0]!==i||e[1]!==s?(r=()=>(s.current=i,()=>{s.current=null}),e[0]=i,e[1]=s,e[2]=r):r=e[2],P.useLayoutEffect(r),null}function vg(t){const e=H.c(3),{onOpenSidebar:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=o.jsx(Ql,{size:20}),e[0]=i):i=e[0];let r;return e[1]!==s?(r=o.jsx("div",{className:"shrink-0 flex items-center justify-between px-3 h-12 bg-background border-b border-border",children:o.jsx("button",{type:"button",onClick:s,className:"flex size-8 items-center justify-center rounded-md text-foreground/60 hover:bg-accent hover:text-foreground transition-colors","aria-label":"Open menu",children:i})}),e[1]=s,e[2]=r):r=e[2],r}function Wo(t){const e=H.c(16),{virtualMcpId:s,hasActiveGithubRepo:i,vmMap:r,children:n}=t,{org:a}=ve(),{currentBranch:l}=vt(),{data:h}=Ci.useSession(),c=h?.user?.id;let u;e[0]!==a.id||e[1]!==a.slug?(u={connectionId:Pt,orgId:a.id,orgSlug:a.slug},e[0]=a.id,e[1]=a.slug,e[2]=u):u=e[2];const d=He(u),{mutate:f}=nn(d);let _;e[3]===Symbol.for("react.memo_cache_sentinel")?(_=new Set,e[3]=_):_=e[3];const m=P.useRef(_);let p,g;e[4]!==l||e[5]!==i||e[6]!==f||e[7]!==c||e[8]!==s||e[9]!==r?(p=()=>{if(i&&c&&l){if(r?.[c]?.[l]){m.current.add(l);return}m.current.has(l)||(m.current.add(l),f({virtualMcpId:s,branch:l},{onError:xg}))}},g=[i,c,l,r,s,f],e[4]=l,e[5]=i,e[6]=f,e[7]=c,e[8]=s,e[9]=r,e[10]=p,e[11]=g):(p=e[10],g=e[11]),P.useEffect(p,g);const v=l??null;let b;return e[12]!==n||e[13]!==v||e[14]!==s?(b=o.jsx(Wu,{virtualMcpId:s,branch:v,children:n}),e[12]=n,e[13]=v,e[14]=s,e[15]=b):b=e[15],b}function xg(t){console.error("[auto-start-vm] failed:",t)}function bg(){const t=H.c(96),e=aa(),s=Bt(),{org:i}=ve(),r=Ic()?.tasksOpen??!1;Uc(i.slug);let n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n={strict:!1},t[0]=n):n=t[0];const a=Wl(n),l=a.org??"";let h;t[1]===Symbol.for("react.memo_cache_sentinel")?(h={strict:!1},t[1]=h):h=t[1];const c=Jr(h);let u;t[2]!==i.id||t[3]!==c.virtualmcpid?(u=c.virtualmcpid??Xo(i.id).id,t[2]=i.id,t[3]=c.virtualmcpid,t[4]=u):u=t[4];const d=u,f=Mh(a.taskId??"",d),_=Ct(d),m=_?.metadata?.ui?.layout??null;let p;t[5]!==m?(p=m?{defaultMainView:m.defaultMainView??null,chatDefaultOpen:m.chatDefaultOpen??null}:null,t[5]=m,t[6]=p):p=t[6];const g=p;let v;t[7]!==_?(v=_&&Kt(_),t[7]=_,t[8]=v):v=t[8];const b=!!v;let S;t[9]!==l||t[10]!==d?(S={virtualMcpId:d,orgSlug:l,isAgentRoute:!0},t[9]=l,t[10]=d,t[11]=S):S=t[11];const x=Ac(g,S),{setOpenMobile:y,openMobile:j}=zc(),C=y,T=P.useRef(null);let E,M;t[12]===Symbol.for("react.memo_cache_sentinel")?(E=()=>{const $=U=>{Lc(U)&&U.shiftKey&&U.code==="KeyS"&&!U.repeat&&(U.preventDefault(),T.current?.())};return document.addEventListener("keydown",$),()=>document.removeEventListener("keydown",$)},M=[],t[12]=E,t[13]=M):(E=t[12],M=t[13]),P.useEffect(E,M);const A=d;let I;t[14]!==_||t[15]!==d?(I={virtualMcpId:d,entity:_},t[14]=_,t[15]=d,t[16]=I):I=t[16];const k=I;if(f.status==="creating"||f.status==="loading"){let $;t[17]===Symbol.for("react.memo_cache_sentinel")?($=o.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:o.jsxs("div",{className:"flex h-full items-center justify-center bg-background card-shadow rounded-[0.75rem] text-sm text-muted-foreground",children:[o.jsx(Ie,{className:"size-4 animate-spin mr-2"}),"Creating task…"]})}),t[17]=$):$=t[17];let U;return t[18]!==k?(U=o.jsx(Qt,{value:k,children:$}),t[18]=k,t[19]=U):U=t[19],U}if(f.status==="error"){let $;t[20]===Symbol.for("react.memo_cache_sentinel")?($=o.jsx("div",{className:"font-medium",children:"Task unavailable"}),t[20]=$):$=t[20];let U;t[21]!==f.error.message?(U=o.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:o.jsxs("div",{className:"flex flex-col h-full items-center justify-center gap-2 bg-background card-shadow rounded-[0.75rem] p-8 text-sm",children:[$,o.jsx("div",{className:"text-muted-foreground",children:f.error.message})]})}),t[21]=f.error.message,t[22]=U):U=t[22];let V;return t[23]!==k||t[24]!==U?(V=o.jsx(Qt,{value:k,children:U}),t[23]=k,t[24]=U,t[25]=V):V=t[25],V}if(!_){let $;t[26]===Symbol.for("react.memo_cache_sentinel")?($=o.jsx(Ps,{size:48,className:"text-muted-foreground"}),t[26]=$):$=t[26];const U=`The agent "${d}" does not exist in this organization.`;let V;t[27]!==s||t[28]!==l?(V=o.jsx(oe,{variant:"outline",onClick:()=>s({to:"/$org",params:{org:l}}),children:"Go to organization home"}),t[27]=s,t[28]=l,t[29]=V):V=t[29];let se;t[30]!==U||t[31]!==V?(se=o.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:o.jsx("div",{className:"flex flex-col h-full bg-background overflow-hidden card-shadow rounded-[0.75rem]",children:o.jsx(Ls,{image:$,title:"Agent not found",description:U,actions:V})})}),t[30]=U,t[31]=V,t[32]=se):se=t[32];let L;return t[33]!==k||t[34]!==se?(L=o.jsx(Qt,{value:k,children:se}),t[33]=k,t[34]=se,t[35]=L):L=t[35],L}if(e){let $;t[36]===Symbol.for("react.memo_cache_sentinel")?($=o.jsx($c,{className:"sr-only",children:"Navigation"}),t[36]=$):$=t[36];let U;t[37]!==C?(U=o.jsx("div",{className:"w-14 shrink-0 bg-sidebar flex flex-col items-center border-r border-border overflow-y-auto group/sidebar","data-state":"collapsed",children:o.jsx(Bc,{onClose:()=>C(!1)})}),t[37]=C,t[38]=U):U=t[38];let V;t[39]===Symbol.for("react.memo_cache_sentinel")?(V=o.jsx("div",{className:"flex-1 min-w-0 overflow-hidden",children:o.jsx(Pc,{})}),t[39]=V):V=t[39];let se;t[40]!==U?(se=o.jsxs(Fc,{side:"left",hideCloseButton:!0,className:"w-[calc(100vw-3rem)] sm:max-w-md! p-0",children:[$,o.jsxs("div",{className:"flex h-full",children:[U,V]})]}),t[40]=U,t[41]=se):se=t[41];let L;t[42]!==j||t[43]!==C||t[44]!==se?(L=o.jsx(Hc,{open:j,onOpenChange:C,children:se}),t[42]=j,t[43]=C,t[44]=se,t[45]=L):L=t[45];const te=L,ie=_?.metadata?.vmMap;let ee;t[46]!==x.createNewTask?(ee=o.jsx(Ho,{onNewTaskRef:T,createNewTask:x.createNewTask}),t[46]=x.createNewTask,t[47]=ee):ee=t[47];let Y;t[48]!==C?(Y=o.jsx(vg,{onOpenSidebar:()=>C(!0)}),t[48]=C,t[49]=Y):Y=t[49];let le;t[50]===Symbol.for("react.memo_cache_sentinel")?(le=o.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:o.jsx(Fo,{})}),t[50]=le):le=t[50];let ue;t[51]!==b||t[52]!==te||t[53]!==ie||t[54]!==ee||t[55]!==Y||t[56]!==d?(ue=o.jsxs(Wo,{virtualMcpId:d,hasActiveGithubRepo:b,vmMap:ie,children:[ee,Y,le,te]}),t[51]=b,t[52]=te,t[53]=ie,t[54]=ee,t[55]=Y,t[56]=d,t[57]=ue):ue=t[57];let de;t[58]!==A||t[59]!==ue?(de=o.jsx("div",{className:"flex flex-col flex-1 bg-background min-h-0",children:o.jsx(je.Provider,{virtualMcpId:A,children:ue},A)}),t[58]=A,t[59]=ue,t[60]=de):de=t[60];let fe;return t[61]!==k||t[62]!==de?(fe=o.jsx(Qt,{value:k,children:de}),t[61]=k,t[62]=de,t[63]=fe):fe=t[63],fe}const w=r?void 0:x.createNewTask;let N;t[64]!==x.chatOpen||t[65]!==x.toggleChat||t[66]!==w?(N=o.jsx(hr.Toggles,{children:o.jsx(Xp,{chatOpen:x.chatOpen,toggleChat:x.toggleChat,onNewTask:w})}),t[64]=x.chatOpen,t[65]=x.toggleChat,t[66]=w,t[67]=N):N=t[67];let R;t[68]!==x.taskId||t[69]!==d?(R=o.jsx(hr.Tabs,{children:o.jsx(ig,{virtualMcpId:d,taskId:x.taskId})}),t[68]=x.taskId,t[69]=d,t[70]=R):R=t[70];const D=_?.metadata?.vmMap;let B;t[71]!==_?(B=o.jsx(gg,{virtualMcp:_}),t[71]=_,t[72]=B):B=t[72];let z;t[73]!==x.createNewTask?(z=o.jsx(Ho,{onNewTaskRef:T,createNewTask:x.createNewTask}),t[73]=x.createNewTask,t[74]=z):z=t[74];let G;t[75]===Symbol.for("react.memo_cache_sentinel")?(G=o.jsx(Fo,{}),t[75]=G):G=t[75];let W;t[76]!==x.chatOpen||t[77]!==x.mainOpen||t[78]!==x.taskId||t[79]!==d?(W=o.jsx(Yp,{virtualMcpId:d,taskId:x.taskId,chatOpen:x.chatOpen,mainOpen:x.mainOpen,chatContent:G}),t[76]=x.chatOpen,t[77]=x.mainOpen,t[78]=x.taskId,t[79]=d,t[80]=W):W=t[80];let F;t[81]!==b||t[82]!==D||t[83]!==B||t[84]!==z||t[85]!==W||t[86]!==d?(F=o.jsxs(Wo,{virtualMcpId:d,hasActiveGithubRepo:b,vmMap:D,children:[B,z,W]}),t[81]=b,t[82]=D,t[83]=B,t[84]=z,t[85]=W,t[86]=d,t[87]=F):F=t[87];let Z;t[88]!==A||t[89]!==R||t[90]!==F?(Z=o.jsxs(je.Provider,{virtualMcpId:A,children:[R,F]},A),t[88]=A,t[89]=R,t[90]=F,t[91]=Z):Z=t[91];let q;return t[92]!==k||t[93]!==N||t[94]!==Z?(q=o.jsx("div",{className:"flex-1 min-w-0 flex flex-col",children:o.jsxs(Qt,{value:k,children:[N,Z]})}),t[92]=k,t[93]=N,t[94]=Z,t[95]=q):q=t[95],q}function E1(){const t=H.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=o.jsx(P.Suspense,{fallback:o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsx(Ie,{size:20,className:"animate-spin text-muted-foreground"})}),children:o.jsx(bg,{})}),t[0]=e):e=t[0],e}export{E1 as default,vn as useInsetContext};
|
|
182
|
+
`);if(Ne.trim()){N(!0);try{le(),ye("automation_improve_clicked",{automation_id:t,agent_id:r,instructions_length:Ne.length}),await g(["studio-automation-manager"]),m(!0),await p({tiptapDoc:Ma({managerAgentId:Jo.AUTOMATION_MANAGER(n.id),managerName:"Automation Manager",kind:"automation",id:t,instructions:Ne})})}finally{N(!1)}}},G=e.models?.credentialId||f||"",W=e.models?.thinking?.id||_?.modelId||"",F=Ko({defaultValues:{name:e.name,active:e.active,credential_id:G,model_id:W}}),Z=F.watch("active"),q=F.watch("credential_id"),$=F.watch("model_id"),{models:U,isLoading:V}=Dc(q||void 0),se=U.find(Q=>Q.modelId===$)??null,L=P.useRef(null),te=P.useRef(new Set),ie=P.useRef(0),ee=P.useRef(null),Y=3e4,le=()=>{ee.current&&(clearTimeout(ee.current),ee.current=null),L.current!==null&&(ye("automation_updated",{automation_id:t,agent_id:r,fields:Array.from(te.current),save_count:ie.current,edit_duration_ms:Date.now()-L.current}),L.current=null,te.current=new Set,ie.current=0)},ue=P.useRef(new Set),de=Q=>{ue.current.add(Q)},fe=async()=>{const Q=Array.from(ue.current);if(!(Q.length>0)&&!D.current)return!0;const X=D.current;D.current=!1,ue.current=new Set;const ne=F.getValues(),Re=B.current;try{const Je=ne.credential_id&&ne.model_id?ne.credential_id:"",jt=ne.credential_id&&ne.model_id?ne.model_id:"",Rl={id:t,name:ne.name,active:ne.active,models:{credentialId:Je,thinking:{id:jt}},messages:Jl(Re),temperature:0};await a.mutateAsync(Rl),L.current===null&&(L.current=Date.now());for(const Dl of Q)te.current.add(Dl);return X&&te.current.add("messages"),ie.current+=1,ee.current&&clearTimeout(ee.current),ee.current=setTimeout(le,Y),Je!==ne.credential_id&&F.setValue("credential_id",Je),jt!==ne.model_id&&F.setValue("model_id",jt),!0}catch{D.current=!0;for(const Je of Q)ue.current.add(Je);return!1}},{schedule:_e,flush:Ue}=Ca({save:fe}),$e=Q=>{Q&&de(Q),_e()},Qe=Q=>{if(B.current=Q,y(Q),!R.current){R.current=!0;return}D.current=!0,_e()},at=async()=>{ye("automation_test_clicked",{automation_id:t,agent_id:r});const Q=await Ue();if(le(),!Q)return;if(!x){pe.error("No instructions configured for this automation");return}se&&q&&d({...se,keyId:q}),b({...v,toolApprovalLevel:"auto"});const Ne=bn(x);u({message:{tiptapDoc:x,parts:Ne},virtualMcpId:r||void 0})};return o.jsxs(o.Fragment,{children:[s&&o.jsx("div",{className:"flex items-center pb-4 shrink-0",children:o.jsxs(oe,{variant:"ghost",size:"sm",onClick:s,children:[o.jsx(ja,{size:14}),"Back to list"]})}),o.jsxs("div",{className:"flex flex-col gap-8",children:[o.jsxs("div",{className:"flex flex-col gap-1.5",children:[o.jsxs("div",{className:"flex items-center justify-between gap-4",children:[o.jsx($t,{control:F.control,name:"name",render:({field:Q})=>o.jsx(_s,{...Q,onChange:Ne=>{Q.onChange(Ne),$e("name")},placeholder:"Automation name",className:"border border-transparent shadow-none px-0 text-lg font-medium h-auto focus-visible:ring-0 focus-visible:border-border bg-transparent flex-1",style:{boxShadow:"none"}})}),i&&o.jsx(oe,{variant:"ghost",size:"icon",className:"text-muted-foreground hover:text-destructive shrink-0",onClick:i,children:o.jsx(ur,{size:14})})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx($t,{control:F.control,name:"active",render:({field:Q})=>o.jsx(dr,{checked:Q.value,onCheckedChange:Ne=>{Q.onChange(Ne),de("active"),setTimeout(()=>Ue(),0)},className:"cursor-pointer"})}),o.jsx("span",{className:"text-sm text-muted-foreground",children:Z?"Active":"Inactive"}),o.jsx("span",{className:"text-muted-foreground/50 text-sm",children:"·"}),o.jsx(ha,{id:e.created_by,size:"2xs",className:"text-sm text-muted-foreground"})]})]}),o.jsxs("div",{className:"flex flex-col gap-2.5",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Starter"}),o.jsx(Ap,{automationId:t,open:j,onOpenChange:C,onCustomSelect:()=>{E(!0),k(!1),A("")},onEventSelect:()=>{k(!0),E(!1)}})]}),e.triggers.length===0&&!T?o.jsx("div",{className:"rounded-lg border border-dashed border-border px-4 py-6 text-center",children:o.jsxs("p",{className:"text-sm text-muted-foreground",children:["When should this automation run?"," ",o.jsx("button",{type:"button",className:"text-foreground underline underline-offset-2 cursor-pointer hover:text-foreground/80 transition-colors",onClick:()=>C(!0),children:"Add a starter"})," ","to get going."]})}):o.jsx("div",{className:"flex flex-col gap-2",children:e.triggers.map(Q=>o.jsx(Bp,{trigger:Q,automationId:t,connectionName:Q.connection_id?c.get(Q.connection_id):void 0},Q.id))}),T&&o.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2.5 rounded-lg border border-border bg-background group",children:[o.jsx(Ds,{size:14,className:"text-muted-foreground shrink-0"}),o.jsx("input",{type:"text",value:M,onChange:Q=>A(Q.target.value),onBlur:async()=>{const Q=M.trim();if(!(!Q||!As(Q)))try{await l.mutateAsync({automation_id:t,type:"cron",cron_expression:Q}),ye("automation_trigger_added",{automation_id:t,trigger_type:"cron"}),pe.success("Starter added"),E(!1),A("")}catch{pe.error("Failed to add starter")}},onKeyDown:async Q=>{const Ne=M.trim();Q.key==="Enter"&&Ne&&As(Ne)&&Q.target.blur(),Q.key==="Escape"&&(E(!1),A(""))},placeholder:"0 9 * * 1-5",className:"flex-1 text-sm font-mono bg-transparent outline-none placeholder:text-muted-foreground/40",autoFocus:!0}),M&&!As(M)&&o.jsx("span",{className:"text-xs text-muted-foreground/60 shrink-0",children:"invalid"}),l.isPending&&o.jsx(Ie,{size:13,className:"animate-spin text-muted-foreground shrink-0"}),o.jsx("button",{type:"button",className:"shrink-0 p-0.5 rounded text-muted-foreground opacity-0 group-hover:opacity-100 hover:text-foreground transition-opacity",onClick:()=>{E(!1),A("")},children:o.jsx(ls,{size:13})})]}),I&&o.jsx(P.Suspense,{fallback:o.jsxs("div",{className:"flex items-center gap-2 px-3 py-3 rounded-lg border border-border bg-background",children:[o.jsx(Ie,{size:13,className:"animate-spin text-muted-foreground"}),o.jsx("span",{className:"text-sm text-muted-foreground",children:"Loading connections..."})]}),children:o.jsx(Lp,{automationId:t,onDone:()=>k(!1)})})]}),o.jsxs("div",{className:"flex flex-col gap-2.5",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Instructions"}),o.jsxs(oe,{variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",disabled:w||!x,onClick:z,children:[o.jsx(wa,{size:13}),"Improve"]})]}),o.jsx(ql,{tiptapDoc:x,setTiptapDoc:Qe,placeholder:"What should this automation do?",children:o.jsxs("div",{className:"rounded-xl border border-border min-h-[120px] flex flex-col",children:[o.jsx(Gl,{virtualMcpId:r||null,className:"max-h-[45vh]"}),o.jsxs("div",{className:"flex items-center justify-end gap-1.5 p-2.5",children:[o.jsx(wh,{model:se,isLoading:V,credentialId:q||null,onCredentialChange:Q=>{F.setValue("credential_id",Q??""),F.setValue("model_id",""),de("credential_id"),de("model_id"),_e()},onModelChange:Q=>{F.setValue("model_id",Q.modelId),$e("model_id")},placeholder:"Model"}),o.jsxs(Ke,{children:[o.jsx(qe,{asChild:!0,children:o.jsxs(oe,{type:"button",variant:"default",className:"h-8 gap-1.5 rounded-md px-3 text-sm font-medium",onClick:at,disabled:!r,children:[o.jsx(rc,{size:16}),"Test"]})}),o.jsx(Ge,{children:"Test Automation"})]})]})]})})]})]})]})}function Hp(t){const e=H.c(5),{tabId:s}=t;let i;e[0]!==s?(i=Qo(s),e[0]=s,e[1]=i):i=e[1];const r=i;if(!r)return null;let n;e[2]===Symbol.for("react.memo_cache_sentinel")?(n=o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsx(Ie,{size:20,className:"animate-spin text-muted-foreground"})}),e[2]=n):n=e[2];let a;return e[3]!==r.id?(a=o.jsx(ct,{children:o.jsx(ct.Content,{children:o.jsx(ct.Body,{children:o.jsx(P.Suspense,{fallback:n,children:o.jsx(Wp,{id:r.id})})})})}),e[3]=r.id,e[4]=a):a=e[4],a}function Wp(t){const e=H.c(8),{id:s}=t,i=Bt(),{data:r,isLoading:n}=kh(s);let a;e[0]!==i?(a=()=>i({to:".",search:Up,replace:!0}),e[0]=i,e[1]=a):a=e[1];const l=a;if(n){let c;return e[2]===Symbol.for("react.memo_cache_sentinel")?(c=o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsx(Ie,{size:20,className:"animate-spin text-muted-foreground"})}),e[2]=c):c=e[2],c}if(!r){let c;return e[3]===Symbol.for("react.memo_cache_sentinel")?(c=o.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:"Automation not found"}),e[3]=c):c=e[3],c}let h;return e[4]!==r||e[5]!==s||e[6]!==l?(h=o.jsx(Fp,{automationId:s,automation:r,onBack:l}),e[4]=r,e[5]=s,e[6]=l,e[7]=h):h=e[7],h}function Up(t){return{...t,main:"automations"}}function Vp(t){const e=H.c(20),{virtualMcpId:s}=t,i=Bt(),{data:r}=Nh(s),n=r===void 0?[]:r,{create:a}=Ks(),[l,h]=P.useState(""),c=l.toLowerCase(),u=n.filter(M=>M.name.toLowerCase().includes(c));let d;e[0]!==i?(d=M=>i({to:".",search:A=>({...A,main:"automation:"+M}),replace:!0}),e[0]=i,e[1]=d):d=e[1];const f=d,_=async()=>{if(a.isPending)return;ye("automation_new_clicked",{virtual_mcp_id:s,existing_count:n.length});const M=await a.mutateAsync(Eh(s));f(M.id)},m=ct,p=ct,g=ct;let v;e[2]===Symbol.for("react.memo_cache_sentinel")?(v=o.jsx(ct.Title,{children:"Automations"}),e[2]=v):v=e[2];const b=n.length>0&&o.jsx(Th,{value:l,onChange:h,placeholder:"Search automations...",className:"w-full md:w-[375px]"});let S;e[3]===Symbol.for("react.memo_cache_sentinel")?(S=o.jsx(cs,{size:14}),e[3]=S):S=e[3];let x;e[4]!==a.isPending||e[5]!==_?(x=o.jsxs(oe,{size:"sm",onClick:_,disabled:a.isPending,children:[S,"New automation"]}),e[4]=a.isPending,e[5]=_,e[6]=x):x=e[6];let y;e[7]!==b||e[8]!==x?(y=o.jsxs("div",{className:"flex flex-col gap-6",children:[v,o.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[b,x]})]}),e[7]=b,e[8]=x,e[9]=y):y=e[9];const j=n.length===0?o.jsx("div",{className:"flex items-center justify-center py-20",children:o.jsx(Ls,{image:o.jsx(Os,{size:48,className:"text-muted-foreground"}),title:"No automations yet",description:"Create your first automation to run this agent on a schedule or in response to events.",actions:o.jsxs(oe,{size:"sm",onClick:_,disabled:a.isPending,children:[o.jsx(cs,{size:14}),"New automation"]})})}):u.length===0?o.jsx("div",{className:"flex items-center justify-center py-20",children:o.jsx(Ls,{image:o.jsx(Os,{size:48,className:"text-muted-foreground"}),title:"No automations found",description:`No automations match "${l}"`})}):o.jsx("div",{className:"mt-6 rounded-xl border border-border overflow-hidden",children:u.map(M=>o.jsx(jh,{automation:M,onClick:()=>f(M.id)},M.id))});let C;e[10]!==j||e[11]!==g.Body||e[12]!==y?(C=o.jsxs(g.Body,{children:[y,j]}),e[10]=j,e[11]=g.Body,e[12]=y,e[13]=C):C=e[13];let T;e[14]!==C||e[15]!==p.Content?(T=o.jsx(p.Content,{children:C}),e[14]=C,e[15]=p.Content,e[16]=T):T=e[16];let E;return e[17]!==m||e[18]!==T?(E=o.jsx(m,{children:T}),e[17]=m,e[18]=T,e[19]=E):E=e[19],E}function Kp(t){const e=H.c(3),{virtualMcpId:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsx(Ie,{size:20,className:"animate-spin text-muted-foreground"})}),e[0]=i):i=e[0];let r;return e[1]!==s?(r=o.jsx(P.Suspense,{fallback:i,children:o.jsx(Vp,{virtualMcpId:s})}),e[1]=s,e[2]=r):r=e[2],r}const Oo=P.lazy(()=>Fl(()=>import("./project-app-view-Xj3yVfXy.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56])).then(t=>({default:t.AppViewContent})));function qp(t){const e=H.c(43),{taskId:s,virtualMcpId:i}=t;let r;e[0]!==s||e[1]!==i?(r={virtualMcpId:i,taskId:s},e[0]=s,e[1]=i,e[2]=r):r=e[2];const{activeTab:n,layoutTabs:a,expandedTools:l,automationTabParsed:h}=Da(r);if(hc(n)){let m;return e[3]!==i?(m=o.jsx($n,{virtualMcpId:i}),e[3]=i,e[4]=m):m=e[4],m}if(n==="git"){let m;return e[5]!==i?(m=o.jsx(Eu,{virtualMcpId:i}),e[5]=i,e[6]=m):m=e[6],m}if(n==="automations"){let m;return e[7]!==i?(m=o.jsx(Kp,{virtualMcpId:i}),e[7]=i,e[8]=m):m=e[8],m}if(n==="env"){let m;return e[9]!==i?(m=o.jsx(Ep,{virtualMcpId:i}),e[9]=i,e[10]=m):m=e[10],m}if(n==="preview"){let m;return e[11]!==i?(m=o.jsx(df,{virtualMcpId:i}),e[11]=i,e[12]=m):m=e[12],m}if(h){let m;return e[13]!==n?(m=o.jsx(Hp,{tabId:n}),e[13]=n,e[14]=m):m=e[14],m}let c;e[15]!==n?(c=dc(n),e[15]=n,e[16]=c):c=e[16];const u=c;if(u){let m;if(e[17]!==l||e[18]!==u.connectionId||e[19]!==u.toolName){let S;e[21]!==u.connectionId||e[22]!==u.toolName?(S=x=>x.appId===u.connectionId&&x.toolName===u.toolName,e[21]=u.connectionId,e[22]=u.toolName,e[23]=S):S=e[23],m=l.find(S),e[17]=l,e[18]=u.connectionId,e[19]=u.toolName,e[20]=m}else m=e[20];const p=m;let g;e[24]===Symbol.for("react.memo_cache_sentinel")?(g=o.jsx("div",{className:"h-full w-full flex items-center justify-center",children:o.jsx(Ie,{size:20,className:"animate-spin text-muted-foreground"})}),e[24]=g):g=e[24];const v=p?.args;let b;return e[25]!==n||e[26]!==u.connectionId||e[27]!==u.toolName||e[28]!==v?(b=o.jsx(P.Suspense,{fallback:g,children:o.jsx(Oo,{connectionId:u.connectionId,toolName:u.toolName,args:v},n)}),e[25]=n,e[26]=u.connectionId,e[27]=u.toolName,e[28]=v,e[29]=b):b=e[29],b}let d;if(e[30]!==n||e[31]!==a){let m;e[33]!==n?(m=p=>p.id===n,e[33]=n,e[34]=m):m=e[34],d=a.find(m),e[30]=n,e[31]=a,e[32]=d}else d=e[32];const f=d;if(f){let m;e[35]===Symbol.for("react.memo_cache_sentinel")?(m=o.jsx("div",{className:"h-full w-full flex items-center justify-center",children:o.jsx(Ie,{size:20,className:"animate-spin text-muted-foreground"})}),e[35]=m):m=e[35];let p;return e[36]!==n||e[37]!==f.id||e[38]!==f.view.appId||e[39]!==f.view.args?(p=o.jsx(P.Suspense,{fallback:m,children:o.jsx(Oo,{connectionId:f.view.appId,toolName:f.id,args:f.view.args},n)}),e[36]=n,e[37]=f.id,e[38]=f.view.appId,e[39]=f.view.args,e[40]=p):p=e[40],p}let _;return e[41]!==i?(_=o.jsx($n,{virtualMcpId:i}),e[41]=i,e[42]=_):_=e[42],_}function Gp(t){const e=H.c(7),{children:s,defaultSize:i}=t,[,r]=P.useTransition();let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=Yo.decoChatPanelWidth(),e[0]=n):n=e[0];const[a,l]=Go(n,45),h=i>0&&i<100?a:i;let c;e[1]!==l?(c=f=>r(()=>{f>0&&f<100&&l(f)}),e[1]=l,e[2]=c):c=e[2];const u=c;let d;return e[3]!==s||e[4]!==h||e[5]!==u?(d=o.jsx(la,{defaultSize:h,minSize:20,collapsible:!0,collapsedSize:0,className:"min-w-0 overflow-hidden bg-sidebar",onResize:u,order:1,children:s}),e[3]=s,e[4]=h,e[5]=u,e[6]=d):d=e[6],d}function Yp(t){const e=H.c(30),{virtualMcpId:s,taskId:i,chatOpen:r,mainOpen:n,chatContent:a}=t;let l;e[0]!==r||e[1]!==n?(l=Tn(r,n),e[0]=r,e[1]=n,e[2]=l):l=e[2];const h=l;let c;e[3]===Symbol.for("react.memo_cache_sentinel")?(c=Yo.decoChatPanelWidth(),e[3]=c):c=e[3];const[u]=Go(c,45),d=P.useRef(null);let f,_;e[4]!==r||e[5]!==n||e[6]!==u?(f=()=>{const M=d.current;if(!M)return;const A=Tn(r,n),I=A.chat>0&&A.chat<100?u:A.chat,k=A.chat>0&&A.chat<100?100-u:A.main;M.setLayout([I,k])},_=[r,n,u],e[4]=r,e[5]=n,e[6]=u,e[7]=f,e[8]=_):(f=e[7],_=e[8]),P.useEffect(f,_);const m=`${s}-${i}`;let p;e[9]===Symbol.for("react.memo_cache_sentinel")?(p={overflow:"visible"},e[9]=p):p=e[9];let g;e[10]!==a?(g=a??o.jsx(Ea,{}),e[10]=a,e[11]=g):g=e[11];let v;e[12]!==g?(v=o.jsx("div",{className:"h-full p-0.5 pt-0.25",children:o.jsx("div",{className:"h-full bg-background rounded-[0.75rem] overflow-hidden card-shadow",children:g})}),e[12]=g,e[13]=v):v=e[13];let b;e[14]!==h.chat||e[15]!==v?(b=o.jsx(Gp,{defaultSize:h.chat,children:v}),e[14]=h.chat,e[15]=v,e[16]=b):b=e[16];let S;e[17]===Symbol.for("react.memo_cache_sentinel")?(S=o.jsx(Yc,{className:"bg-sidebar"}),e[17]=S):S=e[17];const x=h.main;let y;e[18]===Symbol.for("react.memo_cache_sentinel")?(y={overflow:"visible"},e[18]=y):y=e[18];let j;e[19]===Symbol.for("react.memo_cache_sentinel")?(j=re("flex flex-col h-full min-h-0 bg-background overflow-hidden","card-shadow","transition-[border-radius] duration-200 ease-[var(--ease-out-quart)]","rounded-[0.75rem]"),e[19]=j):j=e[19];let C;e[20]!==i||e[21]!==s?(C=o.jsx("div",{className:"h-full p-0.5 pt-0.25",children:o.jsx("div",{className:j,children:o.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:o.jsx(Ht,{children:o.jsx(qp,{taskId:i,virtualMcpId:s})})})})}),e[20]=i,e[21]=s,e[22]=C):C=e[22];let T;e[23]!==h.main||e[24]!==C?(T=o.jsx(la,{className:"min-w-0 flex flex-col",order:2,defaultSize:x,style:y,collapsible:!0,collapsedSize:0,minSize:20,children:C}),e[23]=h.main,e[24]=C,e[25]=T):T=e[25];let E;return e[26]!==T||e[27]!==m||e[28]!==b?(E=o.jsxs(Xc,{ref:d,direction:"horizontal",className:"flex-1 min-h-0 pb-1 pr-1 pl-0 pt-0",style:p,children:[b,S,T]},m),e[26]=T,e[27]=m,e[28]=b,e[29]=E):E=e[29],E}const ar="flex size-7 shrink-0 items-center justify-center rounded-md transition-colors",zo="bg-sidebar-accent text-sidebar-foreground",lr="text-sidebar-foreground/60 hover:bg-sidebar-accent hover:text-sidebar-foreground";function Xp(t){const e=H.c(47),{chatOpen:s,toggleChat:i,onNewTask:r}=t,{tasksOpen:n,toggleTasks:a}=Mc(),l=!!r;let h;e[0]!==n||e[1]!==a?(h=()=>{ye("agent_toolbar_toggled",{button:"tasks",next_state:n?"closed":"open"}),a()},e[0]=n,e[1]=a,e[2]=h):h=e[2];const c=n?zo:lr;let u;e[3]!==c?(u=re(ar,c),e[3]=c,e[4]=u):u=e[4];let d;e[5]===Symbol.for("react.memo_cache_sentinel")?(d=o.jsx(jc,{size:16}),e[5]=d):d=e[5];let f;e[6]!==h||e[7]!==u||e[8]!==n?(f=o.jsx(qe,{asChild:!0,children:o.jsx("button",{type:"button",onClick:h,"aria-pressed":n,className:u,children:d})}),e[6]=h,e[7]=u,e[8]=n,e[9]=f):f=e[9];let _;e[10]===Symbol.for("react.memo_cache_sentinel")?(_=o.jsx(Ge,{side:"bottom",children:"Tasks"}),e[10]=_):_=e[10];let m;e[11]!==f?(m=o.jsxs(Ke,{delayDuration:300,children:[f,_]}),e[11]=f,e[12]=m):m=e[12];let p;e[13]!==s||e[14]!==i?(p=()=>{ye("agent_toolbar_toggled",{button:"chat",next_state:s?"closed":"open"}),i()},e[13]=s,e[14]=i,e[15]=p):p=e[15];const g=s?zo:lr;let v;e[16]!==g?(v=re(ar,g),e[16]=g,e[17]=v):v=e[17];let b;e[18]===Symbol.for("react.memo_cache_sentinel")?(b=o.jsx(Ec,{size:16}),e[18]=b):b=e[18];let S;e[19]!==s||e[20]!==v||e[21]!==p?(S=o.jsx(qe,{asChild:!0,children:o.jsx("button",{type:"button",onClick:p,"aria-pressed":s,className:v,children:b})}),e[19]=s,e[20]=v,e[21]=p,e[22]=S):S=e[22];let x;e[23]===Symbol.for("react.memo_cache_sentinel")?(x=o.jsx(Ge,{side:"bottom",children:"Chat"}),e[23]=x):x=e[23];let y;e[24]!==S?(y=o.jsxs(Ke,{delayDuration:300,children:[S,x]}),e[24]=S,e[25]=y):y=e[25];const j=l?"grid-cols-[1fr]":"grid-cols-[0fr]";let C;e[26]!==j?(C=re("grid transition-[grid-template-columns] duration-200 ease-[var(--ease-out-quart)]",j),e[26]=j,e[27]=C):C=e[27];const T=!l,E=l?0:-1,M=!l,A=l?"translate-x-0 opacity-100":"-translate-x-2 opacity-0";let I;e[28]!==A?(I=re(ar,lr,"transition-[transform,opacity] duration-200 ease-[var(--ease-out-quart)] will-change-transform",A),e[28]=A,e[29]=I):I=e[29];let k;e[30]===Symbol.for("react.memo_cache_sentinel")?(k=o.jsx(sa,{size:16}),e[30]=k):k=e[30];let w;e[31]!==r||e[32]!==T||e[33]!==E||e[34]!==M||e[35]!==I?(w=o.jsx(qe,{asChild:!0,children:o.jsx("button",{type:"button",onClick:r,disabled:T,tabIndex:E,"aria-hidden":M,className:I,children:k})}),e[31]=r,e[32]=T,e[33]=E,e[34]=M,e[35]=I,e[36]=w):w=e[36];let N;e[37]===Symbol.for("react.memo_cache_sentinel")?(N=o.jsx(Ge,{side:"bottom",children:"New task"}),e[37]=N):N=e[37];let R;e[38]!==w?(R=o.jsx("div",{className:"overflow-hidden",children:o.jsxs(Ke,{delayDuration:300,children:[w,N]})}),e[38]=w,e[39]=R):R=e[39];let D;e[40]!==C||e[41]!==R?(D=o.jsx("div",{className:C,children:R}),e[40]=C,e[41]=R,e[42]=D):D=e[42];let B;return e[43]!==y||e[44]!==D||e[45]!==m?(B=o.jsxs(o.Fragment,{children:[m,y,D]}),e[43]=y,e[44]=D,e[45]=m,e[46]=B):B=e[46],B}function Jp(t,e,s){if(t.length<=s)return{visible:t,overflow:[]};const i=t.slice(0,s),r=t.slice(s);if(e==null)return{visible:i,overflow:r};if(i.some(d=>d.id===e))return{visible:i,overflow:r};const a=r.findIndex(d=>d.id===e);if(a===-1)return{visible:i,overflow:r};const l=i[i.length-1],h=r[a],c=[...i.slice(0,-1),h],u=[l,...r.slice(0,a),...r.slice(a+1)];return{visible:c,overflow:u}}function Zp(t){const e=H.c(13),{title:s,icon:i,active:r,onClick:n}=t,a=r?"bg-sidebar-accent text-sidebar-foreground":"text-sidebar-foreground/60 hover:bg-sidebar-accent hover:text-sidebar-foreground";let l;e[0]!==a?(l=re("shrink-0 flex items-center gap-1.5 h-8 rounded-md px-2","[transition:background-color_180ms_ease,color_180ms_ease]",a),e[0]=a,e[1]=l):l=e[1];let h;e[2]!==i?(h=o.jsx("span",{className:"flex size-5 items-center justify-center shrink-0",children:o.jsx(Qp,{icon:i})}),e[2]=i,e[3]=h):h=e[3];let c;e[4]!==s?(c=o.jsx("span",{className:"whitespace-nowrap text-sm font-medium leading-none",children:s}),e[4]=s,e[5]=c):c=e[5];let u;return e[6]!==r||e[7]!==n||e[8]!==l||e[9]!==h||e[10]!==c||e[11]!==s?(u=o.jsxs("button",{type:"button",onClick:n,"aria-pressed":r,"aria-label":s,className:l,children:[h,c]}),e[6]=r,e[7]=n,e[8]=l,e[9]=h,e[10]=c,e[11]=s,e[12]=u):u=e[12],u}function Qp(t){const e=H.c(5),{icon:s}=t;if(s.kind==="component"){const{Component:r}=s;let n;return e[0]!==r?(n=o.jsx(r,{className:"size-4"}),e[0]=r,e[1]=n):n=e[1],n}if(s.kind==="url"){let r;return e[2]!==s.src?(r=o.jsx("img",{src:s.src,alt:"",className:"size-4 rounded-sm object-cover"}),e[2]=s.src,e[3]=r):r=e[3],r}let i;return e[4]===Symbol.for("react.memo_cache_sentinel")?(i=o.jsx(oa,{className:"size-4"}),e[4]=i):i=e[4],i}function eg(t){const e=H.c(13),{overflow:s,onSelect:i}=t,[r,n]=P.useState(!1);let a;e[0]!==i?(a=f=>{n(!1),i(f)},e[0]=i,e[1]=a):a=e[1];const l=a;let h;e[2]===Symbol.for("react.memo_cache_sentinel")?(h=o.jsx(Ws,{asChild:!0,children:o.jsx("button",{type:"button",title:"More tabs","aria-label":"More tabs",className:"shrink-0 flex size-8 items-center justify-center rounded-md text-muted-foreground hover:bg-accent hover:text-foreground transition-colors",children:o.jsx(ia,{className:"size-4"})})}),e[2]=h):h=e[2];let c;if(e[3]!==l||e[4]!==s){let f;e[6]!==l?(f=_=>o.jsx("li",{children:o.jsxs("button",{type:"button",onClick:()=>l(_.id),className:"w-full flex items-center gap-2 px-3 py-2 rounded-md hover:bg-accent text-sm text-foreground",children:[o.jsx("span",{className:"flex size-5 items-center justify-center shrink-0",children:o.jsx(tg,{icon:_.icon})}),o.jsx("span",{className:"truncate",children:_.title})]})},_.id),e[6]=l,e[7]=f):f=e[7],c=s.map(f),e[3]=l,e[4]=s,e[5]=c}else c=e[5];let u;e[8]!==c?(u=o.jsx(Us,{align:"end",className:"w-56 p-1",children:o.jsx("ul",{className:"flex flex-col",children:c})}),e[8]=c,e[9]=u):u=e[9];let d;return e[10]!==r||e[11]!==u?(d=o.jsxs(Vs,{open:r,onOpenChange:n,children:[h,u]}),e[10]=r,e[11]=u,e[12]=d):d=e[12],d}function tg(t){const e=H.c(5),{icon:s}=t;if(s.kind==="component"){const{Component:r}=s;let n;return e[0]!==r?(n=o.jsx(r,{className:"size-4"}),e[0]=r,e[1]=n):n=e[1],n}if(s.kind==="url"){let r;return e[2]!==s.src?(r=o.jsx("img",{src:s.src,alt:"",className:"size-4 rounded-sm object-cover"}),e[2]=s.src,e[3]=r):r=e[3],r}let i;return e[4]===Symbol.for("react.memo_cache_sentinel")?(i=o.jsx(oa,{className:"size-4"}),e[4]=i):i=e[4],i}const sg=6;function ig(t){const e=H.c(20),{virtualMcpId:s,taskId:i}=t,r=Bt();let n;e[0]!==i||e[1]!==s?(n={virtualMcpId:s,taskId:i},e[0]=i,e[1]=s,e[2]=n):n=e[2];const{tabs:a,activeTab:l,mainOpen:h,setActiveTab:c}=Da(n);let u,d,f,_;if(e[3]!==l||e[4]!==h||e[5]!==r||e[6]!==c||e[7]!==a||e[8]!==s){const g=uc({activeTab:l,mainOpen:h}),v=j=>j.id==="automations"?g:h&&j.id===l,S=a.find(j=>v(j))?.id??null,{visible:x,overflow:y}=Jp(a,S,sg);d=y,u=j=>{const C=a.find(E=>E.id===j),T=S===j&&h;if(ye("main_panel_tab_clicked",{virtual_mcp_id:s,tab_id:j,tab_kind:C?.kind??null,was_active:T}),j==="automations"){const E=fc({activeTab:l,mainOpen:h});r({to:".",search:M=>({...M,main:E}),replace:!0});return}c(j)},f="flex items-center min-w-0 ml-auto gap-0.5",_=x.map(j=>o.jsx(Zp,{title:j.title,icon:j.icon,active:v(j),onClick:()=>u(j.id)},j.id)),e[3]=l,e[4]=h,e[5]=r,e[6]=c,e[7]=a,e[8]=s,e[9]=u,e[10]=d,e[11]=f,e[12]=_}else u=e[9],d=e[10],f=e[11],_=e[12];let m;e[13]!==u||e[14]!==d?(m=d.length>0&&o.jsx(eg,{overflow:d,onSelect:u}),e[13]=u,e[14]=d,e[15]=m):m=e[15];let p;return e[16]!==f||e[17]!==_||e[18]!==m?(p=o.jsxs("div",{className:f,children:[_,m]}),e[16]=f,e[17]=_,e[18]=m,e[19]=p):p=e[19],p}function rg(t){const e=H.c(12);let s,i,r,n;e[0]!==t?({className:s,orientation:r,decorative:n,...i}=t,e[0]=t,e[1]=s,e[2]=i,e[3]=r,e[4]=n):(s=e[1],i=e[2],r=e[3],n=e[4]);const a=r===void 0?"horizontal":r,l=n===void 0?!0:n;let h;e[5]!==s?(h=re("bg-border shrink-0 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px",s),e[5]=s,e[6]=h):h=e[6];let c;return e[7]!==l||e[8]!==a||e[9]!==i||e[10]!==h?(c=o.jsx(Hl,{"data-slot":"separator-root",decorative:l,orientation:a,className:h,...i}),e[7]=l,e[8]=a,e[9]=i,e[10]=h,e[11]=c):c=e[11],c}function ng(t){const e=H.c(20),{prNumber:s,disabled:i,send:r}=t;let n;e[0]!==s||e[1]!==r?(n=()=>r(gu({prNumber:s})),e[0]=s,e[1]=r,e[2]=n):n=e[2];const a=n;let l;e[3]!==s||e[4]!==r?(l=()=>r(pu({prNumber:s})),e[3]=s,e[4]=r,e[5]=l):l=e[5];const h=l;let c;e[6]!==i||e[7]!==a?(c=o.jsx(oe,{size:"sm",variant:"success",className:"rounded-r-none border-r border-success-foreground/20",disabled:i,onClick:a,children:"Publish"}),e[6]=i,e[7]=a,e[8]=c):c=e[8];let u;e[9]===Symbol.for("react.memo_cache_sentinel")?(u=o.jsx(fr,{className:"h-3.5 w-3.5"}),e[9]=u):u=e[9];let d;e[10]!==i?(d=o.jsx(os,{asChild:!0,children:o.jsx(oe,{size:"sm",variant:"success",className:"rounded-l-none px-2",disabled:i,"aria-label":"More actions",children:u})}),e[10]=i,e[11]=d):d=e[11];let f;e[12]!==h?(f=o.jsx(as,{align:"end",children:o.jsx(wt,{onClick:h,children:"Review"})}),e[12]=h,e[13]=f):f=e[13];let _;e[14]!==d||e[15]!==f?(_=o.jsxs(ns,{children:[d,f]}),e[14]=d,e[15]=f,e[16]=_):_=e[16];let m;return e[17]!==c||e[18]!==_?(m=o.jsxs("div",{className:"inline-flex items-stretch rounded-md",children:[c,_]}),e[17]=c,e[18]=_,e[19]=m):m=e[19],m}const og=new Set(["failure","timed_out","cancelled","action_required"]);function ag(t){return t.status==="completed"&&og.has(t.conclusion)}function lg(t){return t.status==="queued"||t.status==="in_progress"}function cg(t){const{branchStatus:e,pr:s,checks:i,reviews:r,loading:n}=t;if(!e||n)return{label:"Loading…",disabled:!0,loading:!0,variant:"outline",tooltip:"Loading branch and pull request status"};switch(e.kind){case"initializing":return{label:"Starting sandbox…",disabled:!0,loading:!0,variant:"outline",tooltip:"Waiting for the sandbox daemon to come online"};case"cloning":return{label:"Cloning repo…",disabled:!0,loading:!0,variant:"outline",tooltip:"Cloning the project repository"};case"clone-failed":return{label:"Clone failed",disabled:!0,variant:"outline",tooltip:e.error||"git clone failed — see setup logs"};case"checking-out":return{label:`Switching to ${e.to}…`,disabled:!0,loading:!0,variant:"outline",tooltip:`Checking out ${e.to}`};case"checkout-failed":return{label:"Checkout failed",disabled:!0,variant:"outline",tooltip:e.error||"git checkout failed — see setup logs"}}const a=e;if(a.workingTreeDirty||a.unpushed>0)return{label:"Save changes",action:"commit-and-push",variant:"default",tooltip:"Commit and push local changes"};if(s?.merged)return!!a.headSha&&!!s.headSha&&a.headSha!==s.headSha?{label:"Continue",action:"create-pr",variant:"special",tooltip:"Open a new PR with the latest commits"}:{label:"Published",disabled:!0,variant:"outline",tooltip:`PR #${s.number} merged into ${s.base}`};if(a.aheadOfBase>0){if(s&&s.state==="closed"&&!s.merged)return{label:"Reopen",action:"reopen",variant:"default",tooltip:`Reopen PR #${s.number}`};if(!s)return{label:"Submit for review",action:"create-pr",variant:"default",tooltip:`Open a PR for ${a.branch} → ${a.base}`};if((r?.mergeableState??"unknown")==="dirty")return{label:`Sync with ${s.base}`,action:"rebase",variant:"default",tooltip:`Resolve conflicts with ${s.base} before merging`};const c=i.filter(ag).map(f=>f.name);if(c.length>0)return{label:"Fix tests",action:"fix-checks",variant:"default",tooltip:`Failing: ${c.join(", ")}`,meta:{failingChecks:c}};const u=i.filter(lg);if(u.length>0)return{label:"Running tests…",disabled:!0,loading:!0,variant:"outline",tooltip:`Waiting on ${u.length} check${u.length===1?"":"s"} to finish`};if(r?.draft)return{label:"Mark ready",action:"mark-ready",variant:"default",tooltip:"Mark draft PR ready for review"};const d=r?.unresolvedConversations??0;return d>0?{label:"Address feedback",action:"resolve-comments",variant:"default",tooltip:`${d} unresolved conversation${d===1?"":"s"}`}:r?.missingRequiredApprovals?{label:"Awaiting review",disabled:!0,variant:"outline",tooltip:"Waiting for required approvals"}:{label:"Publish",action:"merge-split",variant:"success",tooltip:`Squash-merge PR #${s.number} into ${s.base}`}}return{label:"Up to date",disabled:!0,variant:"outline",tooltip:`Branch is in sync with ${a.base}`}}function hg(){return Gt().branchStatus}const dg=6e4,ug=3e4;function fg(t){const e=H.c(12);let s;e[0]!==t.connectionId||e[1]!==t.orgId||e[2]!==t.orgSlug?(s={connectionId:t.connectionId,orgId:t.orgId,orgSlug:t.orgSlug},e[0]=t.connectionId,e[1]=t.orgId,e[2]=t.orgSlug,e[3]=s):s=e[3];const i=He(s),r=t.prNumber??0;let n;e[4]!==t.owner||e[5]!==t.repo||e[6]!==r?(n={method:"get",owner:t.owner,repo:t.repo,pullNumber:r},e[4]=t.owner,e[5]=t.repo,e[6]=r,e[7]=n):n=e[7];const a=!!t.prNumber;let l;return e[8]!==i||e[9]!==n||e[10]!==a?(l={client:i,toolName:"pull_request_read",toolArguments:n,enabled:a,refetchInterval:dg,refetchIntervalInBackground:!1,staleTime:ug,select:mg},e[8]=i,e[9]=n,e[10]=a,e[11]=l):l=e[11],ms(l)}function mg(t){const e=qs(t);if(!e)return null;const s=e.mergeable_state??"unknown",i=!!(e.draft??!1),r=Number(e.review_comments??0),n=s==="blocked"&&r>0?r:0;return{draft:i,mergeableState:s,unresolvedConversations:n,missingRequiredApprovals:s==="blocked"&&n===0}}function _g(t){const e=H.c(42),{virtualMcpId:s}=t,{org:i}=ve(),r=Ct(s),{currentBranch:n}=vt(),a=fs(),l=r?.metadata?.githubRepo??null,h=hg(),c=l?.connectionId??"",u=l?.owner??"",d=l?.name??"",f=n??null;let _;e[0]!==i.id||e[1]!==i.slug||e[2]!==c||e[3]!==u||e[4]!==d||e[5]!==f?(_={orgId:i.id,orgSlug:i.slug,connectionId:c,owner:u,repo:d,branch:f},e[0]=i.id,e[1]=i.slug,e[2]=c,e[3]=u,e[4]=d,e[5]=f,e[6]=_):_=e[6];const m=Aa(_),p=m.data??null,g=l?.connectionId??"",v=l?.owner??"",b=l?.name??"",S=p&&p.state==="open"?p.number:null;let x;e[7]!==i.id||e[8]!==i.slug||e[9]!==g||e[10]!==v||e[11]!==b||e[12]!==S?(x={orgId:i.id,orgSlug:i.slug,connectionId:g,owner:v,repo:b,prNumber:S},e[7]=i.id,e[8]=i.slug,e[9]=g,e[10]=v,e[11]=b,e[12]=S,e[13]=x):x=e[13];const y=Pa(x),j=l?.connectionId??"",C=l?.owner??"",T=l?.name??"",E=p&&p.state==="open"?p.number:null;let M;e[14]!==i.id||e[15]!==i.slug||e[16]!==j||e[17]!==C||e[18]!==T||e[19]!==E?(M={orgId:i.id,orgSlug:i.slug,connectionId:j,owner:C,repo:T,prNumber:E},e[14]=i.id,e[15]=i.slug,e[16]=j,e[17]=C,e[18]=T,e[19]=E,e[20]=M):M=e[20];const A=fg(M);if(!l?.connectionId||!n)return null;let I;e[21]!==h||e[22]!==y.data||e[23]!==p||e[24]!==m.isPending||e[25]!==A.data?(I=cg({branchStatus:h,pr:p,checks:y.data??[],reviews:A.data??null,loading:m.isPending}),e[21]=h,e[22]=y.data,e[23]=p,e[24]=m.isPending,e[25]=A.data,e[26]=I):I=e[26];const k=I;let w;e[27]!==a?(w=F=>a.sendMessage({parts:[{type:"text",text:F}]}),e[27]=a,e[28]=w):w=e[28];const N=w,R=a.isStreaming;let D;e[29]!==n||e[30]!==k||e[31]!==R||e[32]!==p||e[33]!==N?(D=F=>{if(!R)switch(F){case"commit-and-push":{N(lu({branch:n}));return}case"create-pr":{N(cu({branch:n}));return}case"reopen":{p&&N(hu({prNumber:p.number}));return}case"rebase":{N(du({branch:n}));return}case"fix-checks":{p&&N(fu({prNumber:p.number,failingChecks:k.meta?.failingChecks??[]}));return}case"mark-ready":{p&&N(mu({prNumber:p.number}));return}case"resolve-comments":{p&&N(_u({prNumber:p.number}));return}case"merge-split":return}},e[29]=n,e[30]=k,e[31]=R,e[32]=p,e[33]=N,e[34]=D):D=e[34];const B=D;let z;e[35]===Symbol.for("react.memo_cache_sentinel")?(z=o.jsx(rg,{orientation:"vertical",className:"mx-2 data-[orientation=vertical]:h-5"}),e[35]=z):z=e[35];const G=p?.number;let W;return e[36]!==k||e[37]!==R||e[38]!==B||e[39]!==N||e[40]!==G?(W=o.jsxs(o.Fragment,{children:[z,o.jsx(pg,{button:k,isStreaming:R,onActivate:B,prNumber:G,send:N})]}),e[36]=k,e[37]=R,e[38]=B,e[39]=N,e[40]=G,e[41]=W):W=e[41],W}function pg(t){const e=H.c(21),{button:s,isStreaming:i}=t,r=!!s.disabled||i,n=i?"Chat is running":s.tooltip??null;if(s.action==="merge-split"&&t.prNumber!=null){let u;e[0]!==r||e[1]!==t.prNumber||e[2]!==t.send?(u=o.jsx(ng,{prNumber:t.prNumber,disabled:r,send:t.send}),e[0]=r,e[1]=t.prNumber,e[2]=t.send,e[3]=u):u=e[3];let d;return e[4]!==u||e[5]!==n?(d=o.jsx($o,{label:n,children:u}),e[4]=u,e[5]=n,e[6]=d):d=e[6],d}let a;e[7]!==s.action||e[8]!==t?(a=()=>t.onActivate(s.action),e[7]=s.action,e[8]=t,e[9]=a):a=e[9];let l;e[10]!==s.loading?(l=s.loading?o.jsx(vh,{size:"xs",variant:"default"}):null,e[10]=s.loading,e[11]=l):l=e[11];let h;e[12]!==s.label||e[13]!==s.variant||e[14]!==r||e[15]!==a||e[16]!==l?(h=o.jsxs(oe,{size:"sm",variant:s.variant,disabled:r,onClick:a,children:[l,s.label]}),e[12]=s.label,e[13]=s.variant,e[14]=r,e[15]=a,e[16]=l,e[17]=h):h=e[17];let c;return e[18]!==h||e[19]!==n?(c=o.jsx($o,{label:n,children:h}),e[18]=h,e[19]=n,e[20]=c):c=e[20],c}function $o(t){const e=H.c(9),{label:s,children:i}=t;if(!s){let l;return e[0]!==i?(l=o.jsx(o.Fragment,{children:i}),e[0]=i,e[1]=l):l=e[1],l}let r;e[2]!==i?(r=o.jsx(qe,{asChild:!0,children:o.jsx("span",{children:i})}),e[2]=i,e[3]=r):r=e[3];let n;e[4]!==s?(n=o.jsx(Ge,{children:s}),e[4]=s,e[5]=n):n=e[5];let a;return e[6]!==r||e[7]!==n?(a=o.jsx(Wc,{children:o.jsxs(Ke,{children:[r,n]})}),e[6]=r,e[7]=n,e[8]=a):a=e[8],a}function gg(t){const e=H.c(2),{virtualMcp:s}=t;if(!!!(s.metadata?.githubRepo??null)?.connectionId)return null;let n;return e[0]!==s.id?(n=o.jsx(hr.Right,{children:o.jsx(_g,{virtualMcpId:s.id})}),e[0]=s.id,e[1]=n):n=e[1],n}const Qt=P.createContext(null);function vn(){return P.use(Qt)}function Fo(t){const e=H.c(7),{children:s}=t,{taskId:i}=vt();let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=o.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:"Something went wrong loading the chat. Try refreshing."}),e[0]=r):r=e[0];let n;e[1]===Symbol.for("react.memo_cache_sentinel")?(n=o.jsx(je.Skeleton,{}),e[1]=n):n=e[1];let a;e[2]!==s?(a=s??o.jsx(Ea,{}),e[2]=s,e[3]=a):a=e[3];let l;return e[4]!==a||e[5]!==i?(l=o.jsx(Ht,{fallback:r,children:o.jsx(P.Suspense,{fallback:n,children:o.jsx(je.ActiveTaskProvider,{taskId:i,children:a})})}),e[4]=a,e[5]=i,e[6]=l):l=e[6],l}function Ho(t){const e=H.c(3),{onNewTaskRef:s,createNewTask:i}=t;let r;return e[0]!==i||e[1]!==s?(r=()=>(s.current=i,()=>{s.current=null}),e[0]=i,e[1]=s,e[2]=r):r=e[2],P.useLayoutEffect(r),null}function vg(t){const e=H.c(3),{onOpenSidebar:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=o.jsx(Ql,{size:20}),e[0]=i):i=e[0];let r;return e[1]!==s?(r=o.jsx("div",{className:"shrink-0 flex items-center justify-between px-3 h-12 bg-background border-b border-border",children:o.jsx("button",{type:"button",onClick:s,className:"flex size-8 items-center justify-center rounded-md text-foreground/60 hover:bg-accent hover:text-foreground transition-colors","aria-label":"Open menu",children:i})}),e[1]=s,e[2]=r):r=e[2],r}function Wo(t){const e=H.c(16),{virtualMcpId:s,hasActiveGithubRepo:i,vmMap:r,children:n}=t,{org:a}=ve(),{currentBranch:l}=vt(),{data:h}=Ci.useSession(),c=h?.user?.id;let u;e[0]!==a.id||e[1]!==a.slug?(u={connectionId:Pt,orgId:a.id,orgSlug:a.slug},e[0]=a.id,e[1]=a.slug,e[2]=u):u=e[2];const d=He(u),{mutate:f}=nn(d);let _;e[3]===Symbol.for("react.memo_cache_sentinel")?(_=new Set,e[3]=_):_=e[3];const m=P.useRef(_);let p,g;e[4]!==l||e[5]!==i||e[6]!==f||e[7]!==c||e[8]!==s||e[9]!==r?(p=()=>{if(i&&c&&l){if(r?.[c]?.[l]){m.current.add(l);return}m.current.has(l)||(m.current.add(l),f({virtualMcpId:s,branch:l},{onError:xg}))}},g=[i,c,l,r,s,f],e[4]=l,e[5]=i,e[6]=f,e[7]=c,e[8]=s,e[9]=r,e[10]=p,e[11]=g):(p=e[10],g=e[11]),P.useEffect(p,g);const v=l??null;let b;return e[12]!==n||e[13]!==v||e[14]!==s?(b=o.jsx(Wu,{virtualMcpId:s,branch:v,children:n}),e[12]=n,e[13]=v,e[14]=s,e[15]=b):b=e[15],b}function xg(t){console.error("[auto-start-vm] failed:",t)}function bg(){const t=H.c(96),e=aa(),s=Bt(),{org:i}=ve(),r=Ic()?.tasksOpen??!1;Uc(i.slug);let n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n={strict:!1},t[0]=n):n=t[0];const a=Wl(n),l=a.org??"";let h;t[1]===Symbol.for("react.memo_cache_sentinel")?(h={strict:!1},t[1]=h):h=t[1];const c=Jr(h);let u;t[2]!==i.id||t[3]!==c.virtualmcpid?(u=c.virtualmcpid??Xo(i.id).id,t[2]=i.id,t[3]=c.virtualmcpid,t[4]=u):u=t[4];const d=u,f=Mh(a.taskId??"",d),_=Ct(d),m=_?.metadata?.ui?.layout??null;let p;t[5]!==m?(p=m?{defaultMainView:m.defaultMainView??null,chatDefaultOpen:m.chatDefaultOpen??null}:null,t[5]=m,t[6]=p):p=t[6];const g=p;let v;t[7]!==_?(v=_&&Kt(_),t[7]=_,t[8]=v):v=t[8];const b=!!v;let S;t[9]!==l||t[10]!==d?(S={virtualMcpId:d,orgSlug:l,isAgentRoute:!0},t[9]=l,t[10]=d,t[11]=S):S=t[11];const x=Ac(g,S),{setOpenMobile:y,openMobile:j}=zc(),C=y,T=P.useRef(null);let E,M;t[12]===Symbol.for("react.memo_cache_sentinel")?(E=()=>{const $=U=>{Lc(U)&&U.shiftKey&&U.code==="KeyS"&&!U.repeat&&(U.preventDefault(),T.current?.())};return document.addEventListener("keydown",$),()=>document.removeEventListener("keydown",$)},M=[],t[12]=E,t[13]=M):(E=t[12],M=t[13]),P.useEffect(E,M);const A=d;let I;t[14]!==_||t[15]!==d?(I={virtualMcpId:d,entity:_},t[14]=_,t[15]=d,t[16]=I):I=t[16];const k=I;if(f.status==="creating"||f.status==="loading"){let $;t[17]===Symbol.for("react.memo_cache_sentinel")?($=o.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:o.jsxs("div",{className:"flex h-full items-center justify-center bg-background card-shadow rounded-[0.75rem] text-sm text-muted-foreground",children:[o.jsx(Ie,{className:"size-4 animate-spin mr-2"}),"Creating task…"]})}),t[17]=$):$=t[17];let U;return t[18]!==k?(U=o.jsx(Qt,{value:k,children:$}),t[18]=k,t[19]=U):U=t[19],U}if(f.status==="error"){let $;t[20]===Symbol.for("react.memo_cache_sentinel")?($=o.jsx("div",{className:"font-medium",children:"Task unavailable"}),t[20]=$):$=t[20];let U;t[21]!==f.error.message?(U=o.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:o.jsxs("div",{className:"flex flex-col h-full items-center justify-center gap-2 bg-background card-shadow rounded-[0.75rem] p-8 text-sm",children:[$,o.jsx("div",{className:"text-muted-foreground",children:f.error.message})]})}),t[21]=f.error.message,t[22]=U):U=t[22];let V;return t[23]!==k||t[24]!==U?(V=o.jsx(Qt,{value:k,children:U}),t[23]=k,t[24]=U,t[25]=V):V=t[25],V}if(!_){let $;t[26]===Symbol.for("react.memo_cache_sentinel")?($=o.jsx(Ps,{size:48,className:"text-muted-foreground"}),t[26]=$):$=t[26];const U=`The agent "${d}" does not exist in this organization.`;let V;t[27]!==s||t[28]!==l?(V=o.jsx(oe,{variant:"outline",onClick:()=>s({to:"/$org",params:{org:l}}),children:"Go to organization home"}),t[27]=s,t[28]=l,t[29]=V):V=t[29];let se;t[30]!==U||t[31]!==V?(se=o.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:o.jsx("div",{className:"flex flex-col h-full bg-background overflow-hidden card-shadow rounded-[0.75rem]",children:o.jsx(Ls,{image:$,title:"Agent not found",description:U,actions:V})})}),t[30]=U,t[31]=V,t[32]=se):se=t[32];let L;return t[33]!==k||t[34]!==se?(L=o.jsx(Qt,{value:k,children:se}),t[33]=k,t[34]=se,t[35]=L):L=t[35],L}if(e){let $;t[36]===Symbol.for("react.memo_cache_sentinel")?($=o.jsx($c,{className:"sr-only",children:"Navigation"}),t[36]=$):$=t[36];let U;t[37]!==C?(U=o.jsx("div",{className:"w-14 shrink-0 bg-sidebar flex flex-col items-center border-r border-border overflow-y-auto group/sidebar","data-state":"collapsed",children:o.jsx(Bc,{onClose:()=>C(!1)})}),t[37]=C,t[38]=U):U=t[38];let V;t[39]===Symbol.for("react.memo_cache_sentinel")?(V=o.jsx("div",{className:"flex-1 min-w-0 overflow-hidden",children:o.jsx(Pc,{})}),t[39]=V):V=t[39];let se;t[40]!==U?(se=o.jsxs(Fc,{side:"left",hideCloseButton:!0,className:"w-[calc(100vw-3rem)] sm:max-w-md! p-0",children:[$,o.jsxs("div",{className:"flex h-full",children:[U,V]})]}),t[40]=U,t[41]=se):se=t[41];let L;t[42]!==j||t[43]!==C||t[44]!==se?(L=o.jsx(Hc,{open:j,onOpenChange:C,children:se}),t[42]=j,t[43]=C,t[44]=se,t[45]=L):L=t[45];const te=L,ie=_?.metadata?.vmMap;let ee;t[46]!==x.createNewTask?(ee=o.jsx(Ho,{onNewTaskRef:T,createNewTask:x.createNewTask}),t[46]=x.createNewTask,t[47]=ee):ee=t[47];let Y;t[48]!==C?(Y=o.jsx(vg,{onOpenSidebar:()=>C(!0)}),t[48]=C,t[49]=Y):Y=t[49];let le;t[50]===Symbol.for("react.memo_cache_sentinel")?(le=o.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:o.jsx(Fo,{})}),t[50]=le):le=t[50];let ue;t[51]!==b||t[52]!==te||t[53]!==ie||t[54]!==ee||t[55]!==Y||t[56]!==d?(ue=o.jsxs(Wo,{virtualMcpId:d,hasActiveGithubRepo:b,vmMap:ie,children:[ee,Y,le,te]}),t[51]=b,t[52]=te,t[53]=ie,t[54]=ee,t[55]=Y,t[56]=d,t[57]=ue):ue=t[57];let de;t[58]!==A||t[59]!==ue?(de=o.jsx("div",{className:"flex flex-col flex-1 bg-background min-h-0",children:o.jsx(je.Provider,{virtualMcpId:A,children:ue},A)}),t[58]=A,t[59]=ue,t[60]=de):de=t[60];let fe;return t[61]!==k||t[62]!==de?(fe=o.jsx(Qt,{value:k,children:de}),t[61]=k,t[62]=de,t[63]=fe):fe=t[63],fe}const w=r?void 0:x.createNewTask;let N;t[64]!==x.chatOpen||t[65]!==x.toggleChat||t[66]!==w?(N=o.jsx(hr.Toggles,{children:o.jsx(Xp,{chatOpen:x.chatOpen,toggleChat:x.toggleChat,onNewTask:w})}),t[64]=x.chatOpen,t[65]=x.toggleChat,t[66]=w,t[67]=N):N=t[67];let R;t[68]!==x.taskId||t[69]!==d?(R=o.jsx(hr.Tabs,{children:o.jsx(ig,{virtualMcpId:d,taskId:x.taskId})}),t[68]=x.taskId,t[69]=d,t[70]=R):R=t[70];const D=_?.metadata?.vmMap;let B;t[71]!==_?(B=o.jsx(gg,{virtualMcp:_}),t[71]=_,t[72]=B):B=t[72];let z;t[73]!==x.createNewTask?(z=o.jsx(Ho,{onNewTaskRef:T,createNewTask:x.createNewTask}),t[73]=x.createNewTask,t[74]=z):z=t[74];let G;t[75]===Symbol.for("react.memo_cache_sentinel")?(G=o.jsx(Fo,{}),t[75]=G):G=t[75];let W;t[76]!==x.chatOpen||t[77]!==x.mainOpen||t[78]!==x.taskId||t[79]!==d?(W=o.jsx(Yp,{virtualMcpId:d,taskId:x.taskId,chatOpen:x.chatOpen,mainOpen:x.mainOpen,chatContent:G}),t[76]=x.chatOpen,t[77]=x.mainOpen,t[78]=x.taskId,t[79]=d,t[80]=W):W=t[80];let F;t[81]!==b||t[82]!==D||t[83]!==B||t[84]!==z||t[85]!==W||t[86]!==d?(F=o.jsxs(Wo,{virtualMcpId:d,hasActiveGithubRepo:b,vmMap:D,children:[B,z,W]}),t[81]=b,t[82]=D,t[83]=B,t[84]=z,t[85]=W,t[86]=d,t[87]=F):F=t[87];let Z;t[88]!==A||t[89]!==R||t[90]!==F?(Z=o.jsxs(je.Provider,{virtualMcpId:A,children:[R,F]},A),t[88]=A,t[89]=R,t[90]=F,t[91]=Z):Z=t[91];let q;return t[92]!==k||t[93]!==N||t[94]!==Z?(q=o.jsx("div",{className:"flex-1 min-w-0 flex flex-col",children:o.jsxs(Qt,{value:k,children:[N,Z]})}),t[92]=k,t[93]=N,t[94]=Z,t[95]=q):q=t[95],q}function E1(){const t=H.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=o.jsx(P.Suspense,{fallback:o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsx(Ie,{size:20,className:"animate-spin text-muted-foreground"})}),children:o.jsx(bg,{})}),t[0]=e):e=t[0],e}export{E1 as default,vn as useInsetContext};
|