decocms 2.282.1 → 2.282.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-CJ_7BsPP.js → AlertCircle-i753hIUr.js} +1 -1
- package/dist/client/assets/{ArrowNarrowLeft-DtS9FYAN.js → ArrowNarrowLeft-DyneV8jh.js} +1 -1
- package/dist/client/assets/{CheckCircle-smRbUGaN.js → CheckCircle-BDNIuV_g.js} +1 -1
- package/dist/client/assets/{ChevronDown-xWqM1qJV.js → ChevronDown-vRDN8zoj.js} +1 -1
- package/dist/client/assets/{ChevronRight-BCgvkwtC.js → ChevronRight-P2x5wJJp.js} +1 -1
- package/dist/client/assets/{ChevronUp-CrL9TH1K.js → ChevronUp-Dg737K7F.js} +1 -1
- package/dist/client/assets/{Container-B7M87Wz6.js → Container-DsC3rtEa.js} +1 -1
- package/dist/client/assets/{LinkExternal01-DLKyZWWz.js → LinkExternal01-Cw9xV77y.js} +1 -1
- package/dist/client/assets/{Lock01-bZF1KUvq.js → Lock01-B4C5ICSW.js} +1 -1
- package/dist/client/assets/{Palette-Dl7lzquw.js → Palette-CxbsG8jb.js} +1 -1
- package/dist/client/assets/{Play-DtJ0cxBf.js → Play-F_qMNNeX.js} +1 -1
- package/dist/client/assets/{Plus-IUiAby9e.js → Plus-BM77-3yZ.js} +1 -1
- package/dist/client/assets/{SearchMd-A2WzjBhy.js → SearchMd-BQ703EvX.js} +1 -1
- package/dist/client/assets/{Settings02-uCCFk89X.js → Settings02-CZ-RzoRL.js} +1 -1
- package/dist/client/assets/{Star01-07LmVEi1.js → Star01-D8uixfU7.js} +1 -1
- package/dist/client/assets/{Sun-NZLaiUcL.js → Sun-Dzvpwc78.js} +1 -1
- package/dist/client/assets/{Tool01-1Tm6sx2D.js → Tool01-DV6LLMyv.js} +1 -1
- package/dist/client/assets/{Trash01-2of3D7QX.js → Trash01-DeQUJecj.js} +1 -1
- package/dist/client/assets/{Upload01-BPC1olzj.js → Upload01-C7vhn2fS.js} +1 -1
- package/dist/client/assets/{User01-Dj2-no-V.js → User01-CFTuPOYw.js} +1 -1
- package/dist/client/assets/{Users03-B_ZFhEj7.js → Users03-AWMGi4Xo.js} +1 -1
- package/dist/client/assets/{X-BXQFKahF.js → X-B19qdsWt.js} +1 -1
- package/dist/client/assets/{XCircle-ByksmUze.js → XCircle-Cu_m9KsD.js} +1 -1
- package/dist/client/assets/{Zap-Ct-Bt-7a.js → Zap-kmaaq3eG.js} +1 -1
- package/dist/client/assets/{ZapSquare-CLlEU1BK.js → ZapSquare-Bzu6OwXc.js} +1 -1
- package/dist/client/assets/{accordion-CBx4kF0A.js → accordion-Bcqp7xWC.js} +1 -1
- package/dist/client/assets/{agent-icon-uOxmWZzX.js → agent-icon-FJlZxNBT.js} +1 -1
- package/dist/client/assets/{agents-list-c4HvLnHM.js → agents-list-BzpReqDX.js} +1 -1
- package/dist/client/assets/ai-providers-BxK1xIaH.js +1 -0
- package/dist/client/assets/{alert-dialog-P8pjafE2.js → alert-dialog-BJ0hwa2l.js} +1 -1
- package/dist/client/assets/{auth-catchall-8f9iLpUP.js → auth-catchall-CGjZNqai.js} +1 -1
- package/dist/client/assets/{automation-list-row-BDBawYyn.js → automation-list-row-GPd6_cjS.js} +1 -1
- package/dist/client/assets/{automations-C_zdEQX8.js → automations-CXyF6Wr3.js} +1 -1
- package/dist/client/assets/{avatar-F9o71OJ0.js → avatar-BeRTzZHX.js} +1 -1
- package/dist/client/assets/{badge-D2Q0fk8p.js → badge-OuHAk68F.js} +1 -1
- package/dist/client/assets/{brand-context-CW58R34a.js → brand-context-CAuLcp_u.js} +1 -1
- package/dist/client/assets/{card-fcmwdw-g.js → card-64W2yOQo.js} +1 -1
- package/dist/client/assets/{chat-context-CXS-qe2G.js → chat-context-BQqGEJhg.js} +1 -1
- package/dist/client/assets/{checkbox-CqcJoypg.js → checkbox-Cx3RPx8a.js} +1 -1
- package/dist/client/assets/{collection-detail-DhZtELgd.js → collection-detail-ztCad3qg.js} +1 -1
- package/dist/client/assets/{collection-display-button-CgNICB5x.js → collection-display-button-CLTxoM3d.js} +1 -1
- package/dist/client/assets/{collection-search-BhW0WppR.js → collection-search-CcNzJi6D.js} +1 -1
- package/dist/client/assets/{collection-table-wrapper-rCxyye9m.js → collection-table-wrapper-BzqYYOAP.js} +1 -1
- package/dist/client/assets/{collection-tabs-CCiykiFm.js → collection-tabs-DD0Qt8TU.js} +1 -1
- package/dist/client/assets/{collections-C5k4gitm.js → collections-BpO3SJDN.js} +1 -1
- package/dist/client/assets/{command-Bap7RtnO.js → command-rQqgIdbd.js} +1 -1
- package/dist/client/assets/{connection-card-CAIl5zuH.js → connection-card-DKlghzN6.js} +1 -1
- package/dist/client/assets/{connection-detail-C-murm81.js → connection-detail-nptsFfMw.js} +1 -1
- package/dist/client/assets/{connection-form-helpers-Kb2X2zWy.js → connection-form-helpers-ByqGzB7q.js} +1 -1
- package/dist/client/assets/{connections-BUYyasfH.js → connections-CAWxy7P8.js} +1 -1
- package/dist/client/assets/{constants-Cz3vSCG9.js → constants-CN6Il9QM.js} +1 -1
- package/dist/client/assets/{constants-BYqEB04Y.js → constants-DBlKftLg.js} +1 -1
- package/dist/client/assets/{dialog-BEtDzaNY.js → dialog-BG20y4ti.js} +1 -1
- package/dist/client/assets/{drawer-BXhHhfPv.js → drawer-Gt9dvwHd.js} +1 -1
- package/dist/client/assets/{dropdown-menu-CPrJeiSb.js → dropdown-menu-D_gbsFgj.js} +1 -1
- package/dist/client/assets/{dynamic-plugin-layout-B3frXkTC.js → dynamic-plugin-layout-DUhVE3zr.js} +1 -1
- package/dist/client/assets/{empty-state-D17b8ueP.js → empty-state-B4p5HAyS.js} +1 -1
- package/dist/client/assets/{empty-state-QyaCdfZt.js → empty-state-YlXuIlyl.js} +1 -1
- package/dist/client/assets/{extract-connection-data-Df_ti4Xy.js → extract-connection-data-BkUkPjk1.js} +1 -1
- package/dist/client/assets/{features-DpwKJvfV.js → features-ZB9YPD6T.js} +1 -1
- package/dist/client/assets/{form-CyOS6D3q.js → form-DVLM8o8l.js} +1 -1
- package/dist/client/assets/{general-BXFZtoDZ.js → general-BSRTvN4z.js} +1 -1
- package/dist/client/assets/{index-C6iu8syV.js → index-B3NgIo6R.js} +1 -1
- package/dist/client/assets/{index-CpMJ05u5.js → index-B9tg__2J.js} +1 -1
- package/dist/client/assets/{index-C27Pbex0.js → index-BR4Tv9I4.js} +2 -2
- package/dist/client/assets/{index-DYJpZ_hI.js → index-BZ-_pOxX.js} +1 -1
- package/dist/client/assets/{index-FD-g03rr.js → index-B_9MykSP.js} +1 -1
- package/dist/client/assets/{index-B6nAXVWE.js → index-BejE17RG.js} +1 -1
- package/dist/client/assets/{index-D2u00J0R.js → index-Bpfr1gkL.js} +5 -5
- package/dist/client/assets/{index-DsXJm4s8.js → index-BxuUqWWJ.js} +1 -1
- package/dist/client/assets/{index-tiUiHjMI.js → index-CvjwIR23.js} +1 -1
- package/dist/client/assets/{index-CjRdG1Vp.js → index-DWgdGM2y.js} +1 -1
- package/dist/client/assets/{infiniteQueryObserver-Bm_4nXxh.js → infiniteQueryObserver-DjdUCzEf.js} +1 -1
- package/dist/client/assets/{input-BMDCCsVs.js → input-C6wlfqbz.js} +1 -1
- package/dist/client/assets/{integration-icon-gIhUX9GC.js → integration-icon-EHHTVGeJ.js} +1 -1
- package/dist/client/assets/{label-2vBVhIzi.js → label-CMuBjs0l.js} +1 -1
- package/dist/client/assets/{layout-BU5OyVXS.js → layout-BvulCiLM.js} +1 -1
- package/dist/client/assets/{lean-canvas-recruit-modal-BpJpmMV7.js → lean-canvas-recruit-modal-D54L-ueX.js} +1 -1
- package/dist/client/assets/{login-mUATXvn9.js → login-VLvQus3r.js} +1 -1
- package/dist/client/assets/{members-CEd1LJk0.js → members-Tmd-6nti.js} +1 -1
- package/dist/client/assets/{monaco-editor-BnguFt9B.js → monaco-editor-BIIx6Osu.js} +1 -1
- package/dist/client/assets/{monitoring-stats-row-DRhzCagY.js → monitoring-stats-row-DfQoN4dU.js} +1 -1
- package/dist/client/assets/{oauth-callback-BeAxhA0O.js → oauth-callback-COaviXzZ.js} +1 -1
- package/dist/client/assets/{oauth-callback-ai-provider-BNMpbB2T.js → oauth-callback-ai-provider-CeDoTmGO.js} +1 -1
- package/dist/client/assets/{onboarding-DXyWyIV-.js → onboarding-DMIifXKD.js} +1 -1
- package/dist/client/assets/{org-layout-DJZ7Z_p1.js → org-layout-CkCSATkV.js} +1 -1
- package/dist/client/assets/{org-plugin-layout-nQpaPqCP.js → org-plugin-layout-lYj2r1Ln.js} +1 -1
- package/dist/client/assets/{plugin-empty-state-D4pz75Eg.js → plugin-empty-state-BCI2akiJ.js} +1 -1
- package/dist/client/assets/{plugin-header-D_Oa6gN8.js → plugin-header--LbVNTsl.js} +1 -1
- package/dist/client/assets/{plugin-layout-csD4Blom.js → plugin-layout-Dhbi8qfO.js} +1 -1
- package/dist/client/assets/{popover-C6ihUqMx.js → popover-DL7_3A88.js} +1 -1
- package/dist/client/assets/{profile-725q4zwE.js → profile-CYehHV8y.js} +1 -1
- package/dist/client/assets/{project-app-view-BgI1ObN0.js → project-app-view-B680Vk1Z.js} +1 -1
- package/dist/client/assets/registry-D5sX2gio.js +2 -0
- package/dist/client/assets/{registry-layout-CZiwWJ4l.js → registry-layout-CEoOd_Wq.js} +1 -1
- package/dist/client/assets/{required-auth-layout-DYZPY8fJ.js → required-auth-layout-9J8EILU3.js} +1 -1
- package/dist/client/assets/{reset-password-D92BxTuZ.js → reset-password-CzSWUiKA.js} +1 -1
- package/dist/client/assets/{scroll-area-BjkPDLjB.js → scroll-area-CrjX3IME.js} +1 -1
- package/dist/client/assets/{search-input-BsH-Fhn1.js → search-input-DmblMA4A.js} +1 -1
- package/dist/client/assets/{select-ByGBjkSM.js → select-BQ3zutkO.js} +1 -1
- package/dist/client/assets/{select-model-ipn8mtVw.js → select-model-Cbrp8hD-.js} +1 -1
- package/dist/client/assets/{settings-layout-DaVsMStD.js → settings-layout-BxZT4ePy.js} +1 -1
- package/dist/client/assets/{shell-layout-CBHcQlP6.js → shell-layout-DrONQ6vr.js} +1 -1
- package/dist/client/assets/{skeleton-CKW2-ArL.js → skeleton-CmnvTWJg.js} +1 -1
- package/dist/client/assets/{sso-GNLrvSnU.js → sso-Csn8t5YG.js} +1 -1
- package/dist/client/assets/{store-Bv7PRV1N.js → store-B5WMfqFO.js} +1 -1
- package/dist/client/assets/store-registry-MW9ZrAsP.js +2 -0
- package/dist/client/assets/{switch-D_oyEj-7.js → switch-CM_vPUzz.js} +1 -1
- package/dist/client/assets/{table-DmvqYMYA.js → table-S8IBqobR.js} +1 -1
- package/dist/client/assets/{tabs-CHeB-_P1.js → tabs-B14EKG0Q.js} +1 -1
- package/dist/client/assets/{task-status-CGy28UD5.js → task-status-CoVKDaYE.js} +1 -1
- package/dist/client/assets/{textarea-Bo2Nbyc2.js → textarea-Bxm5HSBV.js} +1 -1
- package/dist/client/assets/{toggle-group-hicYHCaj.js → toggle-group-xjN2RMip.js} +1 -1
- package/dist/client/assets/{tools-list-Bc5L72jI.js → tools-list-DqbhkVqY.js} +1 -1
- package/dist/client/assets/{types-Qy_lXSZi.js → types-DA2UHbyR.js} +1 -1
- package/dist/client/assets/{use-ai-providers-D5svCGwH.js → use-ai-providers-LqR26vuo.js} +1 -1
- package/dist/client/assets/{use-collections-C9mDhhDp.js → use-collections-Bo1B5pfj.js} +1 -1
- package/dist/client/assets/{use-connection-labJovV0.js → use-connection-NZXO3HH3.js} +1 -1
- package/dist/client/assets/{use-copy-C--xeydh.js → use-copy-BRihc-l2.js} +1 -1
- package/dist/client/assets/{use-create-virtual-mcp-Dmy-tzU3.js → use-create-virtual-mcp-DgwS04N8.js} +1 -1
- package/dist/client/assets/{use-decopilot-events-BQ6lKiUz.js → use-decopilot-events-cbOJk-u-.js} +1 -1
- package/dist/client/assets/{use-delete-connection-Bj5gBc4Q.js → use-delete-connection-_oGK4bpj.js} +1 -1
- package/dist/client/assets/{use-infinite-scroll-CSBdO1Tg.js → use-infinite-scroll-BE8Qm8G-.js} +1 -1
- package/dist/client/assets/{use-list-state-BjQoZx3U.js → use-list-state-CeUQEO5I.js} +1 -1
- package/dist/client/assets/{use-mcp-tools-C0TDyIdf.js → use-mcp-tools-DqNbK4tC.js} +1 -1
- package/dist/client/assets/{use-members-BJMZeTol.js → use-members-DH_gyd2k.js} +1 -1
- package/dist/client/assets/{use-mobile-49sQdb0b.js → use-mobile-UG3f-VUD.js} +1 -1
- package/dist/client/assets/{use-navigate-to-agent-DHv3qU4y.js → use-navigate-to-agent-CDgOtsNz.js} +1 -1
- package/dist/client/assets/{use-org-sso-DZn2rTnY.js → use-org-sso-eSfysoE_.js} +1 -1
- package/dist/client/assets/{use-organization-settings-BhA6YmfT.js → use-organization-settings-bbuIudaf.js} +1 -1
- package/dist/client/assets/{use-registry-connections-Bvn4-1Jy.js → use-registry-connections-DN_uk-6v.js} +1 -1
- package/dist/client/assets/{use-status-sounds-hwHn7ByT.js → use-status-sounds-e0qVVZe8.js} +1 -1
- package/dist/client/assets/{use-tasks-CEfchIrz.js → use-tasks-DkVJbPPF.js} +1 -1
- package/dist/client/assets/{use-view-mode-BZEJDQ3u.js → use-view-mode-BvSJEzBA.js} +1 -1
- package/dist/client/assets/{use-virtual-mcp-kjgk684A.js → use-virtual-mcp-Doro-WnT.js} +1 -1
- package/dist/client/assets/useInfiniteQuery-C5UYrvtb.js +1 -0
- package/dist/client/assets/{user-DxIuCi_O.js → user-DMxAeRCM.js} +1 -1
- package/dist/client/assets/{view-mode-toggle-KKeD1zNQ.js → view-mode-toggle-B0na2o09.js} +1 -1
- package/dist/client/assets/{workflow-3PvqRa7g.js → workflow-BOEOo5nq.js} +1 -1
- package/dist/client/assets/workflow-detail-IfcsUNZf.js +1 -0
- package/dist/client/index.html +1 -1
- package/dist/server/cli.js +1 -1
- package/package.json +1 -1
- package/dist/client/assets/ai-providers-DNv3Q1EX.js +0 -1
- package/dist/client/assets/registry-DiyPXzzy.js +0 -2
- package/dist/client/assets/store-registry-IxsRTF9k.js +0 -2
- package/dist/client/assets/useInfiniteQuery-Bices_FL.js +0 -1
- package/dist/client/assets/workflow-detail-BLyd9EdB.js +0 -1
- package/dist/server/node_modules/ansi-styles/index.d.ts +0 -236
- package/dist/server/node_modules/ansi-styles/index.js +0 -223
- package/dist/server/node_modules/ansi-styles/license +0 -9
- package/dist/server/node_modules/ansi-styles/package.json +0 -54
- package/dist/server/node_modules/ansi-styles/readme.md +0 -173
- package/dist/server/node_modules/postgres-array/index.d.ts +0 -4
- package/dist/server/node_modules/postgres-array/index.js +0 -97
- package/dist/server/node_modules/postgres-array/license +0 -21
- package/dist/server/node_modules/postgres-array/package.json +0 -35
- package/dist/server/node_modules/postgres-array/readme.md +0 -43
- package/dist/server/node_modules/postgres-bytea/index.js +0 -33
- package/dist/server/node_modules/postgres-bytea/license +0 -21
- package/dist/server/node_modules/postgres-bytea/package.json +0 -34
- package/dist/server/node_modules/postgres-bytea/readme.md +0 -34
|
@@ -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 Mt,r as S,p as Jm,q as Qm,e as B,s as xe,K as ct,n as Ki,a as qi,v as Ns,w as Un,x as Gi,j as n,B as ae,y as Et,c as J,E as As,z as ue,C as yi,_ as Zm,t as ne,f as Ge,D as ul,F as ep,R as Eh,G as tp,H as Vs,I as No,J as ms,L as sp,M as Ao,P as ip,Q as np,T as rp,U as op,V as Ih,W as ap,X as lp,Y as cp,Z as dp,$ as mc,l as Me,b as St,u as hp,a0 as bn,a1 as wr,a2 as fl,a3 as ml,g as Hn,a4 as Rh,d as Si,a5 as up,a6 as fp,a7 as mp,a8 as pp,a9 as Th,aa as Dh,ab as gp,ac as _p,ad as xp,ae as Ut,af as vp,ag as bp,ah as yp,ai as Sp,aj as nn,ak as wp,al as Vp,am as Cp,an as kp,ao as Mh,ap as jp,aq as Np,ar as Ap,as as Ep,at as Ip,au as Rp,av as Tp,aw as Dp,ax as Mp,ay as Pp,az as Ph,aA as Vr,aB as Lp,aC as Ti,aD as cr,aE as Lh,aF as Op,aG as Bp}from"./index-C27Pbex0.js";import{u as ai,a as Yi,b as es,A as $p,C as zp,t as Oh,c as da,d as Fp,e as no,f as pc}from"./chat-context-CXS-qe2G.js";import{d as ro,g as ni,c as Up,s as pl,t as Hp,a as Wp,M as Kp,i as qp,b as En,e as Gp,F as Yp,f as Bh,S as Xp,u as Jp,h as gc,j as Qp,k as Zp,l as ha,r as eg,m as tg,p as $h,n as sg,o as ig,q as gl,G as ng,L as rg,v as og,w as ag,x as lg,y as cg}from"./task-status-CGy28UD5.js";import{S as In,u as oo,P as ua,a as dg,b as hg,c as ug,E as fg,i as mg,d as pg,e as zh}from"./scroll-area-BjkPDLjB.js";import{T as Bi,u as Ps,a as st,b as it,c as nt}from"./use-mobile-49sQdb0b.js";import{D as ds,a as hs,b as _l,c as ts,d as ss,e as ao}from"./dialog-BEtDzaNY.js";import{D as lo,a as wi,b as Vi,c as Ci,d as gg,e as _g,f as xg}from"./drawer-BXhHhfPv.js";import{C as Fh}from"./collection-search-BhW0WppR.js";import{S as Pt,u as Be,g as co,i as Br,c as vg,W as ks,a as bg,b as xl}from"./constants-Cz3vSCG9.js";import{u as Uh,g as vl,T as Hh,a as Cr,l as $r,b as Eo,c as yg}from"./tabs-CHeB-_P1.js";import{F as $i,a as It,b as Rt,c as os,d as Tt,e as Dt,f as Sg}from"./form-CyOS6D3q.js";import{I as gt}from"./input-BMDCCsVs.js";import{i as Wh,u as Wn,r as Kh}from"./shell-layout-CBHcQlP6.js";import{D as at,a as kr,b as jr,c as Es,d as Is,e as Rs,f as qh,g as Gh,h as _c}from"./dropdown-menu-CPrJeiSb.js";import{t as wg,i as Yh,n as Xh,A as gs,a as Jh,b as bl,s as ri,c as Vg,d as Cg,e as Qh,f as Zh,g as kg,h as yl,j as yn,k as jg,l as Sl,m as Ng,o as Ag,p as Kn,q as qn,r as Eg,u as xc,v as vc,w as Ig,x as Rg,y as bc,z as Tg,B as wl,C as eu,D as fa,E as Io,F as yc,G as Dg,H as Mg,I as Pg,J as Lg,K as tu,L as su,M as iu,N as nu,O as Sc,P as Og,Q as Sn,R as Bg,S as $g,T as zg,U as ru}from"./agent-icon-uOxmWZzX.js";import{n as ou,a as ma,i as Fg,b as Ug,c as Hg}from"./ZapSquare-CLlEU1BK.js";import{i as Jt,t as Rn}from"./ChevronDown-xWqM1qJV.js";import{s as Li}from"./Star01-07LmVEi1.js";import{a as pa,t as Vl}from"./Tool01-1Tm6sx2D.js";import{i as au}from"./Lock01-bZF1KUvq.js";import{s as Qt}from"./Plus-IUiAby9e.js";import{i as lu}from"./Upload01-BPC1olzj.js";import{i as Js}from"./X-BXQFKahF.js";import{i as oi}from"./AlertCircle-CJ_7BsPP.js";import{S as Zs,a as ei,b as Ht,c as ti,d as si}from"./select-ByGBjkSM.js";import{i as Cl,a as kl,b as Wg}from"./SearchMd-A2WzjBhy.js";import{i as ho,t as Kg,a as qg,b as Gg,c as Yg,d as Xg,e as zi,f as cu}from"./XCircle-ByksmUze.js";import{T as du,a as zr}from"./toggle-group-hicYHCaj.js";import{u as jl,a as hu}from"./use-ai-providers-D5svCGwH.js";import{m as uo,g as Jg,i as Qg,a as uu,M as fu,N as Zg}from"./select-model-ipn8mtVw.js";import{S as e_,A as t_,a as s_,b as i_,c as n_,R as mu,d as r_,e as o_}from"./accordion-CBx4kF0A.js";import{r as pu,l as wn,u as a_,g as l_}from"./types-Qy_lXSZi.js";import{u as fo,a as is,b as Nl}from"./use-virtual-mcp-kjgk684A.js";import{u as Gn,a as mo,b as Al}from"./use-connection-labJovV0.js";import{p as c_,q as wc}from"./question-004-sINsf4GQ.js";import{g as Vc}from"./ai-providers-logos-CS4PCiqI.js";import{g as gu,s as _u}from"./connection-slug-eyAPH6o3.js";import{u as xu,a as vu,g as d_,C as Ro}from"./connection-card-CAIl5zuH.js";import{C as bu}from"./collection-tabs-CCiykiFm.js";import{g as yu}from"./constants-BYqEB04Y.js";import{T as ga}from"./textarea-Bo2Nbyc2.js";import{n as Nr}from"./Container-B7M87Wz6.js";import{c as h_,i as dr,a as Cc,E as u_,p as f_,b as m_,d as p_}from"./connection-form-helpers-Kb2X2zWy.js";import{u as kc}from"./use-infinite-scroll-CSBdO1Tg.js";import{u as g_,C as __,a as jc,b as Nc,c as x_,d as v_,e as b_,f as y_}from"./command-Bap7RtnO.js";import{g as S_,e as w_,a as V_}from"./extract-connection-data-Df_ti4Xy.js";import{B as Ac}from"./badge-D2Q0fk8p.js";import{i as El}from"./ChevronRight-BCgvkwtC.js";import{I as Ls}from"./integration-icon-gIhUX9GC.js";import{S as Fi}from"./skeleton-CKW2-ArL.js";import{a as po}from"./Users03-B_ZFhEj7.js";import{G as Su,u as C_,I as Fr,S as wu,L as k_,a as j_,b as Vu}from"./lean-canvas-recruit-modal-BpJpmMV7.js";import{u as Yn,a as Cu}from"./use-navigate-to-agent-DHv3qU4y.js";import{S as Ur}from"./switch-D_oyEj-7.js";import{u as ku}from"./use-create-virtual-mcp-Dmy-tzU3.js";import{i as N_}from"./CheckCircle-smRbUGaN.js";import{P as li,a as ci,b as di}from"./popover-C6ihUqMx.js";import{u as ki,a as A_}from"./use-mcp-tools-C0TDyIdf.js";import{E as Ui}from"./empty-state-D17b8ueP.js";import{u as E_}from"./use-decopilot-events-BQ6lKiUz.js";import{i as Hi}from"./Zap-Ct-Bt-7a.js";import{i as ju,S as Xn,a as Jn,b as vs,u as Qn,c as _s,d as Zt,e as Nu,f as Au,g as I_,h as Eu,j as Iu,P as ps,k as R_,l as T_,m as D_,n as M_,o as P_,p as L_}from"./index-DsXJm4s8.js";import{A as Ec}from"./avatar-F9o71OJ0.js";import{n as O_,a as B_,i as $_}from"./Sun-NZLaiUcL.js";import{a as Zn}from"./Settings02-uCCFk89X.js";import{A as Il,a as Rl,b as Tl,c as Dl,d as Ml,e as Pl,f as Ll,g as Ru}from"./alert-dialog-P8pjafE2.js";import"./index-C6iu8syV.js";import{u as Tu}from"./use-tasks-CEfchIrz.js";import{u as z_}from"./use-status-sounds-hwHn7ByT.js";import{T as F_,u as Du}from"./tools-list-Bc5L72jI.js";import{u as To}from"./unwrap-tool-result-BYXdCQMg.js";import{C as U_,a as Ic}from"./card-fcmwdw-g.js";import{L as Vn}from"./label-2vBVhIzi.js";import{i as Ar}from"./Play-DtJ0cxBf.js";import{s as _a}from"./Trash01-2of3D7QX.js";import{C as H_}from"./checkbox-CqcJoypg.js";import{n as ji}from"./LinkExternal01-DLKyZWWz.js";import{V as W_}from"./view-mode-toggle-KKeD1zNQ.js";import{U as K_}from"./user-DxIuCi_O.js";import{u as er,a as q_,b as G_,c as Y_,A as X_,d as J_}from"./automation-list-row-BDBawYyn.js";import{S as Q_}from"./search-input-BsH-Fhn1.js";import"./use-collections-C9mDhhDp.js";import"./use-organization-settings-BhA6YmfT.js";import"./use-copy-C--xeydh.js";import"./differenceInSeconds-NQ4PDo0z.js";import"./content-blocks-o63cs2vh.js";import"./required-auth-layout-DYZPY8fJ.js";import"./use-org-sso-DZn2rTnY.js";import"./ArrowNarrowLeft-DtS9FYAN.js";import"./ChevronUp-CrL9TH1K.js";import"./Palette-Dl7lzquw.js";import"./User01-Dj2-no-V.js";import"./formatDistanceToNow-Cb2QZZJn.js";import"./use-registry-connections-Bvn4-1Jy.js";import"./useInfiniteQuery-Bices_FL.js";import"./infiniteQueryObserver-Bm_4nXxh.js";import"./collections-C5k4gitm.js";import"./index-DYJpZ_hI.js";import"./create-sse-subscription-CxkOgzKf.js";function Z_(t,e){const s=Mt(e);return ex({filters:{...t,status:"pending"}},s).length}function Rc(t,e){return t.findAll(e.filters).map(s=>e.select?e.select(s):s.state)}function ex(t={},e){const s=Mt(e).getMutationCache(),i=S.useRef(t),r=S.useRef(null);return r.current===null&&(r.current=Rc(s,t)),S.useEffect(()=>{i.current=t}),S.useSyncExternalStore(S.useCallback(o=>s.subscribe(()=>{const a=Jm(r.current,Rc(s,i.current));r.current!==a&&(r.current=a,Qm.schedule(o))}),[s]),()=>r.current,()=>r.current)}function tx(t,e){const s=B.c(37),{org:i,locator:r}=xe();let o;s[0]!==i.id?(o={connectionId:Pt,orgId:i.id},s[0]=i.id,s[1]=o):o=s[1];const a=Be(o),l=Mt();let c;s[2]!==t||s[3]!==i.id?(c=ct.ensureTask(i.id,t),s[2]=t,s[3]=i.id,s[4]=c):c=s[4];let d;s[5]!==a||s[6]!==t?(d=async()=>(await a.callTool({name:"COLLECTION_THREADS_GET",arguments:{id:t}})).structuredContent?.item??null,s[5]=a,s[6]=t,s[7]=d):d=s[7];let u;s[8]!==c||s[9]!==d?(u={queryKey:c,queryFn:d,retry:!1,refetchOnWindowFocus:!1},s[8]=c,s[9]=d,s[10]=u):u=s[10];const h=Ki(u);let f;s[11]!==a||s[12]!==e?(f=async b=>{const y=await a.callTool({name:"COLLECTION_THREADS_CREATE",arguments:{data:{id:b,virtual_mcp_id:e}}});if(y.isError){const k=y.content,w=Array.isArray(k)&&k[0]&&typeof k[0]=="object"?k[0].text??"Create failed":"Create failed";throw new Error(w)}return y.structuredContent.item},s[11]=a,s[12]=e,s[13]=f):f=s[13];let m;s[14]!==r||s[15]!==i.id||s[16]!==h||s[17]!==l?(m=()=>{l.invalidateQueries({predicate:b=>b.queryKey[1]===i.id&&b.queryKey[3]==="collection"&&b.queryKey[4]==="THREADS"}),l.invalidateQueries({queryKey:ct.tasksPrefix(r)}),h.refetch()},s[14]=r,s[15]=i.id,s[16]=h,s[17]=l,s[18]=m):m=s[18];let p;s[19]!==f||s[20]!==m?(p={mutationFn:f,onSuccess:m},s[19]=f,s[20]=m,s[21]=p):p=s[21];const g=qi(p);let _,v;if(s[22]!==g||s[23]!==t||s[24]!==h.data||s[25]!==h.isSuccess?(_=()=>{!h.isSuccess||h.data||g.isPending||g.variables!==t&&g.mutate(t)},v=[t,h.isSuccess,h.data,g],s[22]=g,s[23]=t,s[24]=h.data,s[25]=h.isSuccess,s[26]=_,s[27]=v):(_=s[26],v=s[27]),S.useEffect(_,v),h.isLoading){let b;return s[28]===Symbol.for("react.memo_cache_sentinel")?(b={status:"loading"},s[28]=b):b=s[28],b}if(h.isError){const b=h.error;let y;return s[29]!==b?(y={status:"error",error:b},s[29]=b,s[30]=y):y=s[30],y}if(h.isSuccess&&h.data){let b;return s[31]!==h.data?(b={status:"ready",task:h.data},s[31]=h.data,s[32]=b):b=s[32],b}if(g.isPending||h.isSuccess&&!h.data){let b;return s[33]===Symbol.for("react.memo_cache_sentinel")?(b={status:"creating"},s[33]=b):b=s[33],b}if(g.isError){let b;return s[34]!==g.error?(b={status:"error",error:g.error},s[34]=g.error,s[35]=b):b=s[35],b}let x;return s[36]===Symbol.for("react.memo_cache_sentinel")?(x={status:"loading"},s[36]=x):x=s[36],x}function sx(t){const e={};for(const s of t.arguments??[])e[s.name]=s.required?Et().min(1,"Required"):Et();return Ns(e)}function ix(t){const e={};for(const s of t.arguments??[])e[s.name]="";return e}function Ol(t){const e=B.c(65),{prompt:s,setPrompt:i,onSubmit:r}=t,o=S.useId();let a;if(e[0]!==s){const D=s?sx(s):Ns({});a=Un(D),e[0]=s,e[1]=a}else a=e[1];const c=a;let d;e[2]!==s?(d=s?ix(s):{},e[2]=s,e[3]=d):d=e[3];let u;e[4]!==c||e[5]!==d?(u={resolver:c,defaultValues:d,mode:"onChange"},e[4]=c,e[5]=d,e[6]=u):u=e[6];const h=Gi(u);let f;e[7]!==s?.arguments?(f=s?.arguments??[],e[7]=s?.arguments,e[8]=f):f=e[8];const m=f;let p;e[9]!==h||e[10]!==r||e[11]!==i?(p=async D=>{await r(D),i(null),h.reset()},e[9]=h,e[10]=r,e[11]=i,e[12]=p):p=e[12];const g=p;let _;e[13]!==h||e[14]!==i?(_=D=>{D||(h.reset(),i(null))},e[13]=h,e[14]=i,e[15]=_):_=e[15];const v=_;if(!s)return null;let x;e[16]!==s._meta||e[17]!==s.name||e[18]!==s.title?(x=s.title||ro(s.name,ni(s._meta)),e[16]=s._meta,e[17]=s.name,e[18]=s.title,e[19]=x):x=e[19];let b;e[20]!==x?(b=n.jsx(ds,{children:n.jsx("span",{className:"capitalize",children:x})}),e[20]=x,e[21]=b):b=e[21];let y;e[22]!==s.description?(y=s.description&&n.jsx("p",{className:"text-sm text-muted-foreground",children:s.description}),e[22]=s.description,e[23]=y):y=e[23];let C;e[24]!==y||e[25]!==b?(C=n.jsxs(hs,{children:[b,y]}),e[24]=y,e[25]=b,e[26]=C):C=e[26];let k;e[27]!==h||e[28]!==g?(k=D=>{D.stopPropagation(),h.handleSubmit(g)(D)},e[27]=h,e[28]=g,e[29]=k):k=e[29];let w;if(e[30]!==m||e[31]!==h.control||e[32]!==h.formState.isSubmitting){let D;e[34]!==h.control||e[35]!==h.formState.isSubmitting?(D=P=>n.jsx(It,{control:h.control,name:P.name,render:O=>{const{field:z}=O;return n.jsxs(Rt,{children:[n.jsxs(os,{className:"text-xs",children:[P.name,P.required?null:n.jsxs("span",{className:"text-muted-foreground font-normal",children:[" ","(optional)"]})]}),n.jsx(Tt,{children:n.jsx(gt,{...z,value:z.value??"",required:P.required,placeholder:P.description??"",className:"h-9",disabled:h.formState.isSubmitting})}),n.jsx(Dt,{})]})}},P.name),e[34]=h.control,e[35]=h.formState.isSubmitting,e[36]=D):D=e[36],w=m.map(D),e[30]=m,e[31]=h.control,e[32]=h.formState.isSubmitting,e[33]=w}else w=e[33];let V;e[37]!==v?(V=()=>v(!1),e[37]=v,e[38]=V):V=e[38];let j;e[39]!==h.formState.isSubmitting||e[40]!==V?(j=n.jsx(ae,{type:"button",variant:"ghost",onClick:V,disabled:h.formState.isSubmitting,children:"Cancel"}),e[39]=h.formState.isSubmitting,e[40]=V,e[41]=j):j=e[41];const I=!h.formState.isValid||h.formState.isSubmitting;let T;e[42]!==h.formState.isSubmitting?(T=h.formState.isSubmitting?n.jsxs("span",{className:"flex items-center gap-2",children:[n.jsx(In,{size:"xs"}),"Loading..."]}):"Use prompt",e[42]=h.formState.isSubmitting,e[43]=T):T=e[43];let R;e[44]!==o||e[45]!==I||e[46]!==T?(R=n.jsx(ae,{type:"submit",form:o,disabled:I,children:T}),e[44]=o,e[45]=I,e[46]=T,e[47]=R):R=e[47];let N;e[48]!==j||e[49]!==R?(N=n.jsxs(_l,{children:[j,R]}),e[48]=j,e[49]=R,e[50]=N):N=e[50];let A;e[51]!==o||e[52]!==k||e[53]!==w||e[54]!==N?(A=n.jsxs("form",{id:o,className:"space-y-4 py-4",autoComplete:"off",onSubmit:k,children:[w,N]}),e[51]=o,e[52]=k,e[53]=w,e[54]=N,e[55]=A):A=e[55];let E;e[56]!==h||e[57]!==A?(E=n.jsx($i,{...h,children:A}),e[56]=h,e[57]=A,e[58]=E):E=e[58];let M;e[59]!==C||e[60]!==E?(M=n.jsxs(ts,{className:"sm:max-w-lg max-h-[80vh] overflow-y-auto",children:[C,E]}),e[59]=C,e[60]=E,e[61]=M):M=e[61];let L;return e[62]!==v||e[63]!==M?(L=n.jsx(ss,{open:!0,onOpenChange:v,children:M}),e[62]=v,e[63]=M,e[64]=L):L=e[64],L}function nx(t){return!t||!t.content||t.content.length===0?!0:t.content.every(e=>e.type==="paragraph"?!e.content||e.content.length===0?!0:e.content.every(s=>s.type==="hardBreak"||s.type==="text"&&(!s.text||s.text.trim()==="")):!1)}function rx(t,e){return{type:"doc",content:[...t?.content??[],e].filter(Boolean)}}const Tc=3,Mu="inline-flex items-center gap-2 px-5 py-2.5 rounded-full bg-muted text-muted-foreground text-sm font-medium transition-colors cursor-pointer",ox="flex flex-col gap-1.5 p-4 rounded-xl bg-accent/40 text-sm leading-snug transition-colors cursor-pointer text-left";function Pu(t){const e=B.c(46),{item:s,onSelect:i,isLoading:r,isDisabled:o,variant:a}=t,l=a===void 0?"pill":a,{prompt:c}=s;let d;if(e[0]!==c._meta||e[1]!==c.name||e[2]!==c.title){const w=ni(c._meta);d=c.title??ro(c.name,w),e[0]=c._meta,e[1]=c.name,e[2]=c.title,e[3]=d}else d=e[3];const u=d,h=c.description||null;if(l==="card"){let w;e[4]!==i||e[5]!==c?(w=()=>i(c),e[4]=i,e[5]=c,e[6]=w):w=e[6];const V=o||r,j=r&&"bg-accent/40",I=(o||r)&&"cursor-not-allowed opacity-50";let T;e[7]!==j||e[8]!==I?(T=J(ox,"hover:bg-accent/60 text-foreground",j,I),e[7]=j,e[8]=I,e[9]=T):T=e[9];let R;e[10]!==u?(R=n.jsx("span",{className:"font-medium truncate capitalize",children:u}),e[10]=u,e[11]=R):R=e[11];let N;e[12]!==r?(N=r&&n.jsx(In,{size:"xs"}),e[12]=r,e[13]=N):N=e[13];let A;e[14]!==R||e[15]!==N?(A=n.jsxs("div",{className:"flex items-center justify-between gap-2",children:[R,N]}),e[14]=R,e[15]=N,e[16]=A):A=e[16];let E;e[17]!==h?(E=h&&n.jsx("span",{className:"text-xs text-muted-foreground line-clamp-2",children:h}),e[17]=h,e[18]=E):E=e[18];let M;return e[19]!==A||e[20]!==E||e[21]!==w||e[22]!==V||e[23]!==T?(M=n.jsxs("button",{type:"button",onClick:w,disabled:V,className:T,children:[A,E]}),e[19]=A,e[20]=E,e[21]=w,e[22]=V,e[23]=T,e[24]=M):M=e[24],M}let f;e[25]!==i||e[26]!==c?(f=()=>i(c),e[25]=i,e[26]=c,e[27]=f):f=e[27];const m=o||r,p=r&&"bg-muted/50",g=(o||r)&&"cursor-not-allowed opacity-50";let _;e[28]!==p||e[29]!==g?(_=J(Mu,"hover:bg-muted/70 hover:text-foreground",p,g),e[28]=p,e[29]=g,e[30]=_):_=e[30];let v;e[31]!==u?(v=n.jsx("span",{className:"capitalize",children:u}),e[31]=u,e[32]=v):v=e[32];let x;e[33]!==r?(x=r&&n.jsx(In,{size:"xs"}),e[33]=r,e[34]=x):x=e[34];let b;e[35]!==f||e[36]!==m||e[37]!==_||e[38]!==v||e[39]!==x?(b=n.jsx(st,{asChild:!0,children:n.jsxs("button",{type:"button",onClick:f,disabled:m,className:_,children:[v,x]})}),e[35]=f,e[36]=m,e[37]=_,e[38]=v,e[39]=x,e[40]=b):b=e[40];const y=h??u;let C;e[41]!==y?(C=n.jsx(it,{side:"top",className:"max-w-xs",children:n.jsx("p",{className:"text-xs",children:y})}),e[41]=y,e[42]=C):C=e[42];let k;return e[43]!==b||e[44]!==C?(k=n.jsxs(nt,{delayDuration:400,children:[b,C]}),e[43]=b,e[44]=C,e[45]=k):k=e[45],k}function ax(t){const e=B.c(41),{items:s,open:i,onOpenChange:r,onSelect:o,loadingPrompt:a}=t,[l,c]=S.useState(""),d=!!a;let u;e[0]!==s||e[1]!==l?(u=l.trim()?s.filter(V=>{const j=l.toLowerCase();return V.prompt.name.toLowerCase().includes(j)||(V.prompt.title??"").toLowerCase().includes(j)||(V.prompt.description??"").toLowerCase().includes(j)}):s,e[0]=s,e[1]=l,e[2]=u):u=e[2];const h=u,f=Ps();let m;e[3]!==h.length||e[4]!==l?(m=h.length===0&&n.jsxs("p",{className:"col-span-4 text-sm text-muted-foreground text-center py-8",children:["No prompts match “",l,"”"]}),e[3]=h.length,e[4]=l,e[5]=m):m=e[5];let p;if(e[6]!==h||e[7]!==d||e[8]!==a?.name||e[9]!==r||e[10]!==o){let V;e[12]!==d||e[13]!==a?.name||e[14]!==r||e[15]!==o?(V=j=>n.jsx(Pu,{item:j,variant:"card",onSelect:I=>{r(!1),o(I)},isLoading:a?.name===j.prompt.name,isDisabled:d&&a?.name!==j.prompt.name},j.prompt.name),e[12]=d,e[13]=a?.name,e[14]=r,e[15]=o,e[16]=V):V=e[16],p=h.map(V),e[6]=h,e[7]=d,e[8]=a?.name,e[9]=r,e[10]=o,e[11]=p}else p=e[11];let g;e[17]!==m||e[18]!==p?(g=n.jsx("div",{className:"flex-1 overflow-y-auto [scrollbar-gutter:stable]",children:n.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 gap-3 p-5",children:[m,p]})}),e[17]=m,e[18]=p,e[19]=g):g=e[19];const _=g;let v;e[20]===Symbol.for("react.memo_cache_sentinel")?(v=V=>{V.key==="Escape"&&c("")},e[20]=v):v=e[20];let x;e[21]!==l?(x=n.jsx(Fh,{value:l,onChange:c,placeholder:"Search prompts...",onKeyDown:v}),e[21]=l,e[22]=x):x=e[22];const b=x;if(f){let V;e[23]===Symbol.for("react.memo_cache_sentinel")?(V=n.jsx(lo,{className:"sr-only",children:n.jsx(wi,{children:"All prompts"})}),e[23]=V):V=e[23];let j;e[24]===Symbol.for("react.memo_cache_sentinel")?(j=n.jsx("div",{className:"flex items-center h-12 border-b border-border px-4 shrink-0",children:n.jsx("span",{className:"text-sm font-medium text-foreground",children:"Prompts"})}),e[24]=j):j=e[24];let I;e[25]!==_||e[26]!==b?(I=n.jsxs(Vi,{className:"h-[85vh] flex flex-col p-0 gap-0",children:[V,j,b,_]}),e[25]=_,e[26]=b,e[27]=I):I=e[27];let T;return e[28]!==r||e[29]!==i||e[30]!==I?(T=n.jsx(Bi,{delayDuration:400,children:n.jsx(Ci,{open:i,onOpenChange:r,children:I})}),e[28]=r,e[29]=i,e[30]=I,e[31]=T):T=e[31],T}let y;e[32]===Symbol.for("react.memo_cache_sentinel")?(y=n.jsx(hs,{className:"sr-only",children:n.jsx(ds,{children:"All prompts"})}),e[32]=y):y=e[32];let C;e[33]===Symbol.for("react.memo_cache_sentinel")?(C=n.jsx("div",{className:"flex items-center h-12 border-b border-border px-4 shrink-0",children:n.jsx("span",{className:"text-sm font-medium text-foreground",children:"Prompts"})}),e[33]=C):C=e[33];let k;e[34]!==_||e[35]!==b?(k=n.jsxs(ts,{className:"sm:max-w-[1100px] h-[680px] p-0 gap-0 overflow-hidden flex flex-col",children:[y,C,b,_]}),e[34]=_,e[35]=b,e[36]=k):k=e[36];let w;return e[37]!==r||e[38]!==i||e[39]!==k?(w=n.jsx(Bi,{delayDuration:400,children:n.jsx(ss,{open:i,onOpenChange:r,children:k})}),e[37]=r,e[38]=i,e[39]=k,e[40]=w):w=e[40],w}function lx(t){const e=B.c(29),{items:s,onSelect:i,loadingPrompt:r,className:o}=t,[a,l]=S.useState(!1);if(s.length===0)return null;let c,d,u;if(e[0]!==s||e[1]!==r||e[2]!==i){const v=s.slice(0,Tc);let x;e[6]!==s?(x=s.slice(Tc),e[6]=s,e[7]=x):x=e[7],c=x,d=!!r;let b;e[8]!==d||e[9]!==r?.name||e[10]!==i?(b=y=>n.jsx(Pu,{item:y,onSelect:i,isLoading:r?.name===y.prompt.name,isDisabled:d&&r?.name!==y.prompt.name},y.prompt.name),e[8]=d,e[9]=r?.name,e[10]=i,e[11]=b):b=e[11],u=v.map(b),e[0]=s,e[1]=r,e[2]=i,e[3]=c,e[4]=d,e[5]=u}else c=e[3],d=e[4],u=e[5];const h=u;let f;e[12]!==o?(f=J("w-full flex flex-wrap gap-2 justify-center",o),e[12]=o,e[13]=f):f=e[13];let m;e[14]!==c.length||e[15]!==d?(m=c.length>0&&n.jsxs("button",{type:"button",disabled:d,onClick:()=>l(!0),className:J(Mu,"hover:bg-muted/70 hover:text-foreground",d&&"opacity-50 cursor-not-allowed"),children:["+",c.length," more"]}),e[14]=c.length,e[15]=d,e[16]=m):m=e[16];let p;e[17]!==h||e[18]!==f||e[19]!==m?(p=n.jsxs("div",{className:f,children:[h,m]}),e[17]=h,e[18]=f,e[19]=m,e[20]=p):p=e[20];let g;e[21]!==s||e[22]!==r||e[23]!==a||e[24]!==i?(g=n.jsx(ax,{items:s,open:a,onOpenChange:l,onSelect:i,loadingPrompt:r}),e[21]=s,e[22]=r,e[23]=a,e[24]=i,e[25]=g):g=e[25];let _;return e[26]!==p||e[27]!==g?(_=n.jsxs(Bi,{delayDuration:400,children:[p,g]}),e[26]=p,e[27]=g,e[28]=_):_=e[28],_}function cx(){return null}function dx(t,e){switch(e.type){case"SELECT_PROMPT":return!e.prompt.arguments||e.prompt.arguments.length===0?{stage:"loading",prompt:e.prompt}:{stage:"idle"};case"START_LOADING":return{stage:"loading",prompt:e.prompt,arguments:e.arguments};case"RESET":return{stage:"idle"};default:return t}}function hx(t){const e=B.c(30),{connectionId:s}=t,{sendMessage:i}=Yi(),{tiptapDocRef:r}=ai(),{org:o}=xe();let a;e[0]!==s||e[1]!==o.id?(a={connectionId:s,orgId:o.id},e[0]=s,e[1]=o.id,e[2]=a):a=e[2];const l=Be(a);let c;e[3]!==l?(c={client:l,staleTime:6e4},e[3]=l,e[4]=c):c=e[4];const{data:d}=Uh(c);let u;e[5]!==d?.prompts?(u=d?.prompts??[],e[5]=d?.prompts,e[6]=u):u=e[6];const h=u;let f;e[7]!==h?(f=h.map(ux),e[7]=h,e[8]=f):f=e[8];const m=f;let p;e[9]===Symbol.for("react.memo_cache_sentinel")?(p={stage:"idle"},e[9]=p):p=e[9];const[g,_]=S.useReducer(dx,p),[v,x]=S.useState(null);let b;e[10]!==l||e[11]!==i||e[12]!==r?(b=async(A,E)=>{if(!l){ue.error("MCP client not available"),_({type:"RESET"});return}try{const M=await vl(l,A.name,E);_({type:"RESET"});const L=rx(r.current,{type:"paragraph",content:[Up({id:A.name,name:pl(A.name,ni(A._meta)),metadata:M.messages,char:"/"})]});await i(L)}catch(M){console.error("[ice-breakers] Failed to fetch prompt:",M),ue.error("Failed to load prompt. Please try again."),_({type:"RESET"})}},e[10]=l,e[11]=i,e[12]=r,e[13]=b):b=e[13];const y=b;let C;e[14]!==y?(C=async A=>{if(A.arguments&&A.arguments.length>0){_({type:"SELECT_PROMPT",prompt:A}),x(A);return}_({type:"START_LOADING",prompt:A}),await y(A)},e[14]=y,e[15]=C):C=e[15];const k=C;let w;e[16]!==v||e[17]!==y?(w=async A=>{v&&(_({type:"START_LOADING",prompt:v,arguments:A}),x(null),await y(v,A))},e[16]=v,e[17]=y,e[18]=w):w=e[18];const V=w;if(m.length===0)return null;const j=g.stage==="loading"?g.prompt:null;let I;e[19]!==k||e[20]!==m||e[21]!==j?(I=n.jsx(lx,{items:m,onSelect:k,loadingPrompt:j}),e[19]=k,e[20]=m,e[21]=j,e[22]=I):I=e[22];let T;e[23]===Symbol.for("react.memo_cache_sentinel")?(T=()=>{x(null),_({type:"RESET"})},e[23]=T):T=e[23];let R;e[24]!==v||e[25]!==V?(R=n.jsx(Ol,{prompt:v,setPrompt:T,onSubmit:V}),e[24]=v,e[25]=V,e[26]=R):R=e[26];let N;return e[27]!==I||e[28]!==R?(N=n.jsxs(n.Fragment,{children:[I,R]}),e[27]=I,e[28]=R,e[29]=N):N=e[29],N}function ux(t){return{prompt:t}}function fx(t){const e=B.c(13),{className:s}=t,{selectedVirtualMcp:i}=ai(),{org:r}=xe();let o;e[0]!==r.id?(o=co(r.id),e[0]=r.id,e[1]=o):o=e[1];const a=o.id,l=i?.id??a;let c;e[2]!==s?(c=J("w-full @container",s),e[2]=s,e[3]=c):c=e[3];const d=l??"default";let u;e[4]===Symbol.for("react.memo_cache_sentinel")?(u=n.jsx(cx,{}),e[4]=u):u=e[4];let h;e[5]!==l?(h=n.jsx(hx,{connectionId:l}),e[5]=l,e[6]=h):h=e[6];let f;e[7]!==d||e[8]!==h?(f=n.jsx(As,{fallback:null,children:n.jsx(S.Suspense,{fallback:u,children:h},d)}),e[7]=d,e[8]=h,e[9]=f):f=e[9];let m;return e[10]!==c||e[11]!==f?(m=n.jsx("div",{className:c,children:f}),e[10]=c,e[11]=f,e[12]=m):m=e[12],m}function Lu(t){const e=B.c(21),{current:s,total:i,onPrev:r,onNext:o}=t;if(i<=1)return null;const a=s===0,l=s===0?"opacity-30 cursor-not-allowed":"hover:text-foreground cursor-pointer";let c;e[0]!==l?(c=J("p-0.5 rounded transition-colors",l),e[0]=l,e[1]=c):c=e[1];let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx(Cl,{size:14}),e[2]=d):d=e[2];let u;e[3]!==r||e[4]!==a||e[5]!==c?(u=n.jsx("button",{type:"button",onClick:r,disabled:a,className:c,"aria-label":"Previous question",children:d}),e[3]=r,e[4]=a,e[5]=c,e[6]=u):u=e[6];const h=s+1;let f;e[7]!==h||e[8]!==i?(f=n.jsxs("span",{className:"tabular-nums text-xs",children:[h," of ",i]}),e[7]=h,e[8]=i,e[9]=f):f=e[9];const m=s===i-1,p=s===i-1?"opacity-30 cursor-not-allowed":"hover:text-foreground cursor-pointer";let g;e[10]!==p?(g=J("p-0.5 rounded transition-colors",p),e[10]=p,e[11]=g):g=e[11];let _;e[12]===Symbol.for("react.memo_cache_sentinel")?(_=n.jsx(ho,{size:14}),e[12]=_):_=e[12];let v;e[13]!==o||e[14]!==g||e[15]!==m?(v=n.jsx("button",{type:"button",onClick:o,disabled:m,className:g,"aria-label":"Next question",children:_}),e[13]=o,e[14]=g,e[15]=m,e[16]=v):v=e[16];let x;return e[17]!==v||e[18]!==u||e[19]!==f?(x=n.jsxs("div",{className:"flex items-center gap-1 text-sm text-muted-foreground",children:[u,f,v]}),e[17]=v,e[18]=u,e[19]=f,e[20]=x):x=e[20],x}function Hr(t){const e=B.c(18),{title:s,children:i,footerLeft:r,footerRight:o,className:a}=t,l=a??"border-border";let c;e[0]!==l?(c=J("flex flex-col rounded-xl bg-background border shadow-md w-[calc(100%-16px)] max-w-[584px] mx-auto mb-[-16px]",l),e[0]=l,e[1]=c):c=e[1];let d;e[2]!==s?(d=n.jsx("div",{className:"flex items-center gap-2 p-4",children:n.jsx("p",{className:"flex-1 text-base font-medium text-foreground min-w-0",children:s})}),e[2]=s,e[3]=d):d=e[3];let u;e[4]!==i?(u=n.jsx("div",{className:"overflow-clip pb-4",children:i}),e[4]=i,e[5]=u):u=e[5];let h;e[6]!==r?(h=n.jsx("div",{children:r}),e[6]=r,e[7]=h):h=e[7];let f;e[8]!==o?(f=n.jsx("div",{className:"flex items-center gap-2",children:o}),e[8]=o,e[9]=f):f=e[9];let m;e[10]!==h||e[11]!==f?(m=n.jsx("div",{className:"border-t border-border px-3 py-3 pb-6",children:n.jsxs("div",{className:"flex items-center justify-between",children:[h,f]})}),e[10]=h,e[11]=f,e[12]=m):m=e[12];let p;return e[13]!==c||e[14]!==d||e[15]!==u||e[16]!==m?(p=n.jsxs("div",{className:c,children:[d,u,m]}),e[13]=c,e[14]=d,e[15]=u,e[16]=m,e[17]=p):p=e[17],p}const mx="User denied this tool call, give other alternatives.",px=[{value:"readonly",label:"Ask before edit"},{value:"auto",label:"Auto approve"}];function gx(t){const e=B.c(9),{onYolo:s}=t,[i,r]=yi();let o;e[0]!==s||e[1]!==i||e[2]!==r?(o=u=>{const h=u;r({...i,toolApprovalLevel:h}),h==="auto"&&s()},e[0]=s,e[1]=i,e[2]=r,e[3]=o):o=e[3];const a=o;let l;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=n.jsx(ti,{size:"xs",className:"text-xs text-muted-foreground border-border/60 bg-transparent hover:bg-accent/60 h-7 gap-1",onClick:xx,children:n.jsx(si,{})}),e[4]=l):l=e[4];let c;e[5]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx(Zs,{children:px.map(_x)}),e[5]=c):c=e[5];let d;return e[6]!==a||e[7]!==i.toolApprovalLevel?(d=n.jsxs(ei,{value:i.toolApprovalLevel,onValueChange:a,children:[l,c]}),e[6]=a,e[7]=i.toolApprovalLevel,e[8]=d):d=e[8],d}function _x(t){return n.jsx(Ht,{value:t.value,children:t.label},t.value)}function xx(t){return t.stopPropagation()}function vx(t){const e=B.c(5),{input:s}=t;if(s==null){let o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx("div",{className:"px-4 text-xs text-muted-foreground",children:"No input"}),e[0]=o):o=e[0],o}let i;try{let o;e[1]!==s?(o=JSON.stringify(s,null,2),e[1]=s,e[2]=o):o=e[2],i=o}catch{i=String(s)}let r;return e[3]!==i?(r=n.jsx("div",{className:"px-4",children:n.jsx("pre",{className:"text-xs font-mono text-muted-foreground/70 whitespace-pre-wrap wrap-break-word max-h-32 overflow-y-auto rounded-md bg-muted/30 px-3 py-2",children:i})}),e[3]=i,e[4]=r):r=e[4],r}function bx(t){const e=B.c(42),{approvals:s,onRespond:i}=t,[r,o]=S.useState(0),a=Math.min(r,s.length-1),l=s[a];if(!l)return null;let c;e[0]!==l.approvalId||e[1]!==i?(c=()=>{i(l.approvalId,!1,mx)},e[0]=l.approvalId,e[1]=i,e[2]=c):c=e[2];const d=c;let u;e[3]!==l.approvalId||e[4]!==i?(u=()=>{i(l.approvalId,!0)},e[3]=l.approvalId,e[4]=i,e[5]=u):u=e[5];const h=u;let f;e[6]!==s||e[7]!==i?(f=()=>{for(const N of s)i(N.approvalId,!0)},e[6]=s,e[7]=i,e[8]=f):f=e[8];const m=f;let p;e[9]!==a?(p=()=>{a>0&&o(a-1)},e[9]=a,e[10]=p):p=e[10];const g=p;let _;e[11]!==s.length||e[12]!==a?(_=()=>{a<s.length-1&&o(a+1)},e[11]=s.length,e[12]=a,e[13]=_):_=e[13];const v=_;let x;e[14]!==m?(x=n.jsx(gx,{onYolo:m}),e[14]=m,e[15]=x):x=e[15];let b;e[16]!==s.length||e[17]!==v||e[18]!==g||e[19]!==a?(b=n.jsx(Lu,{current:a,total:s.length,onPrev:g,onNext:v}),e[16]=s.length,e[17]=v,e[18]=g,e[19]=a,e[20]=b):b=e[20];let y;e[21]!==x||e[22]!==b?(y=n.jsxs("div",{className:"flex items-center gap-2",children:[x,b]}),e[21]=x,e[22]=b,e[23]=y):y=e[23];const C=y;let k;e[24]!==d?(k=n.jsx(ae,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2.5 text-xs text-muted-foreground [@media(hover:hover)]:hover:text-foreground active:scale-[0.97] transition-transform",onClick:d,children:"Deny"}),e[24]=d,e[25]=k):k=e[25];let w;e[26]!==s.length||e[27]!==m?(w=s.length>1&&n.jsx(ae,{type:"button",variant:"outline",size:"sm",className:"h-7 px-2.5 text-xs active:scale-[0.97] transition-transform",onClick:m,children:"Accept All"}),e[26]=s.length,e[27]=m,e[28]=w):w=e[28];let V;e[29]!==h?(V=n.jsx(ae,{type:"button",size:"sm",className:"h-7 px-2.5 text-xs active:scale-[0.97] transition-transform",onClick:h,children:"Accept"}),e[29]=h,e[30]=V):V=e[30];let j;e[31]!==w||e[32]!==V||e[33]!==k?(j=n.jsxs(n.Fragment,{children:[k,w,V]}),e[31]=w,e[32]=V,e[33]=k,e[34]=j):j=e[34];const I=j;let T;e[35]!==l.input?(T=n.jsx(vx,{input:l.input}),e[35]=l.input,e[36]=T):T=e[36];let R;return e[37]!==l.friendlyName||e[38]!==C||e[39]!==I||e[40]!==T?(R=n.jsx(Hr,{title:l.friendlyName,footerLeft:C,footerRight:I,children:T}),e[37]=l.friendlyName,e[38]=C,e[39]=I,e[40]=T,e[41]=R):R=e[41],R}function yx(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsxs("div",{className:"flex items-center gap-2 p-4 border border-dashed rounded-lg bg-accent/50 w-[calc(100%-16px)] max-w-[584px] mx-auto mb-2",children:[n.jsx(wg,{className:"size-5 text-muted-foreground shimmer"}),n.jsx("span",{className:"text-sm text-muted-foreground shimmer",children:"Preparing approval request..."})]}),t[0]=e):e=t[0],e}function Sx(t){const e=B.c(4),{approvals:s,isStreaming:i,onRespond:r}=t;if(i&&s.length===0){let a;return e[0]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx(yx,{}),e[0]=a):a=e[0],a}if(s.length===0)return null;let o;return e[1]!==s||e[2]!==r?(o=n.jsx(bx,{approvals:s,onRespond:r}),e[1]=s,e[2]=r,e[3]=o):o=e[3],o}function wx(t){const e=[];for(const s of t)if("state"in s&&s.state==="approval-requested"&&"approval"in s&&s.approval?.id&&"toolCallId"in s&&s.toolCallId){const i="toolName"in s&&typeof s.toolName=="string"?s.toolName:s.type.startsWith("tool-")?s.type.replace("tool-",""):"Tool";e.push({approvalId:s.approval.id,toolCallId:s.toolCallId,toolName:i,friendlyName:Hp(Wp(i)),input:s.input})}return e}function Vx(t){const e=B.c(15),{plan:s,onApprove:i,onDismiss:r}=t;let o;e[0]!==i||e[1]!==s.plan?(o=()=>{i(s.plan)},e[0]=i,e[1]=s.plan,e[2]=o):o=e[2];const a=o;let l;e[3]!==r?(l=n.jsx(ae,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2.5 text-xs text-muted-foreground [@media(hover:hover)]:hover:text-foreground active:scale-[0.97] transition-transform",onClick:r,children:"Keep iterating"}),e[3]=r,e[4]=l):l=e[4];let c;e[5]!==a?(c=n.jsx(ae,{type:"button",size:"sm",className:"h-7 px-2.5 text-xs bg-purple-600 hover:bg-purple-700 text-white active:scale-[0.97] transition-transform",onClick:a,children:"Let's go"}),e[5]=a,e[6]=c):c=e[6];let d;e[7]!==l||e[8]!==c?(d=n.jsxs(n.Fragment,{children:[l,c]}),e[7]=l,e[8]=c,e[9]=d):d=e[9];const u=d;let h;e[10]!==s.plan?(h=n.jsx("div",{className:"px-4 max-h-64 overflow-y-auto",children:n.jsx("div",{className:"prose prose-sm max-w-none text-sm",children:n.jsx(Kp,{id:"plan-preview",part:{type:"text",text:s.plan}})})}),e[10]=s.plan,e[11]=h):h=e[11];let f;return e[12]!==u||e[13]!==h?(f=n.jsx(Hr,{title:"Implementation Plan",footerRight:u,className:"border-dashed border-purple-500",children:h}),e[12]=u,e[13]=h,e[14]=f):f=e[14],f}function Cx(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsxs("div",{className:"flex items-center gap-2 p-4 border border-dashed border-purple-500/30 rounded-lg bg-purple-500/5 w-[calc(100%-16px)] max-w-[584px] mx-auto mb-2",children:[n.jsx(Jt,{className:"size-5 text-purple-500 shimmer"}),n.jsx("span",{className:"text-sm text-muted-foreground shimmer",children:"Preparing plan..."})]}),t[0]=e):e=t[0],e}function kx(t){const e=B.c(7),{plans:s,isStreaming:i,onApprove:r,onDismiss:o}=t;if(i&&s.length===0){let d;return e[0]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx(Cx,{}),e[0]=d):d=e[0],d}let a;e[1]!==s?(a=s.at(-1),e[1]=s,e[2]=a):a=e[2];const l=a;if(!l)return null;let c;return e[3]!==l||e[4]!==r||e[5]!==o?(c=n.jsx(Vx,{plan:l,onApprove:r,onDismiss:o}),e[3]=l,e[4]=r,e[5]=o,e[6]=c):c=e[6],c}function jx(t){const e=[];for(const s of t)if("type"in s&&s.type==="tool-propose_plan"&&"state"in s&&s.state==="input-available"&&"toolCallId"in s&&"input"in s){const i=s.input;e.push({toolCallId:s.toolCallId,plan:i.plan,state:s.state})}return e}const Dc=Ns({response:Et().min(1,"Response is required")}),Nx=Ns({response:Et().min(1,"Please select or enter an option")}),Ax=Ns({response:Zm(["yes","no"])});function Ex(t){switch(t.type){case"text":return Dc;case"choice":return Nx;case"confirm":return Ax;default:return Dc}}function Ix(t){const e={};for(const s of t)e[s.toolCallId]=Ex(s.input);return Ns(e)}function Rx(t){const e=B.c(6),{control:s,name:i,placeholder:r}=t;let o;e[0]!==r?(o=l=>{const{field:c}=l;return n.jsxs(Rt,{children:[n.jsx(Tt,{children:n.jsx("div",{className:"px-2",children:n.jsxs("div",{className:"flex items-center gap-3 px-2 py-3 rounded-lg bg-accent/50",children:[n.jsx("span",{className:"flex items-center justify-center size-6 rounded-md bg-muted shrink-0",children:n.jsx(Yh,{size:16,className:"text-muted-foreground"})}),n.jsx("input",{...c,type:"text",placeholder:r||"Type your response...",autoFocus:!0,"aria-label":"Text response input",className:"flex-1 text-sm bg-transparent outline-none placeholder:text-foreground/25 text-foreground min-w-0"})]})})}),n.jsx(Dt,{})]})},e[0]=r,e[1]=o):o=e[1];let a;return e[2]!==s||e[3]!==i||e[4]!==o?(a=n.jsx(It,{control:s,name:i,render:o}),e[2]=s,e[3]=i,e[4]=o,e[5]=a):a=e[5],a}function Ou(t,e){const s=B.c(4);let i,r;s[0]!==t||s[1]!==e?(i=()=>{const o=a=>{const l=a.target.tagName;if(l==="INPUT"||l==="TEXTAREA"||a.metaKey||a.ctrlKey||a.altKey)return;const c=Number.parseInt(a.key,10);c>=1&&c<=t&&(a.preventDefault(),e(c-1))};return document.addEventListener("keydown",o),()=>document.removeEventListener("keydown",o)},r=[t,e],s[0]=t,s[1]=e,s[2]=i,s[3]=r):(i=s[2],r=s[3]),S.useEffect(i,r)}function Tx(t){const e=B.c(9),{control:s,name:i,options:r}=t,[o,a]=S.useState(!1),l=S.useRef(null),c=S.useRef(null);let d;if(e[0]!==r?(d=f=>{c.current?.onChange(r[f]??""),a(!1)},e[0]=r,e[1]=d):d=e[1],Ou(r.length,d),r.length===0)return null;let u;e[2]!==o||e[3]!==r?(u=f=>{const{field:m}=f;c.current=m;const p=o||!!m.value&&!r.includes(m.value);return n.jsxs(Rt,{children:[n.jsx(Tt,{children:n.jsxs("div",{className:"flex flex-col px-2",role:"group","aria-label":"Choice options",children:[r.map((g,_)=>{const v=m.value===g;return n.jsxs("button",{type:"button",onClick:()=>{m.onChange(g??""),a(!1)},className:J("flex items-center gap-3 px-2 py-3 rounded-lg text-left transition-colors w-full",v&&"bg-accent/50",!v&&"hover:bg-accent/30"),"aria-label":`Select ${g}`,children:[n.jsx("span",{className:J("flex items-center justify-center size-6 rounded-md text-sm shrink-0",v?"bg-chart-1 text-white":"bg-muted text-foreground"),children:_+1}),n.jsx("span",{className:"text-sm text-foreground truncate",children:g})]},`${_}-${g}`)}),n.jsxs("div",{className:J("flex items-center gap-3 px-2 py-3 rounded-lg transition-colors w-full cursor-text",p&&"bg-accent/50",!p&&"hover:bg-accent/30"),onClick:()=>{a(!0),r.includes(m.value)&&m.onChange(""),setTimeout(()=>l.current?.focus(),0)},children:[n.jsx("span",{className:"flex items-center justify-center size-6 rounded-md bg-muted shrink-0",children:n.jsx(Yh,{size:16,className:"text-muted-foreground"})}),p?n.jsx("input",{ref:l,type:"text",value:m.value,onChange:g=>m.onChange(g.target.value),placeholder:"Something else...",autoFocus:!0,"aria-label":"Custom choice input",className:"flex-1 text-sm bg-transparent outline-none placeholder:text-foreground/25 text-foreground min-w-0"}):n.jsx("span",{className:"text-sm text-foreground/25",children:"Something else..."})]})]})}),n.jsx(Dt,{})]})},e[2]=o,e[3]=r,e[4]=u):u=e[4];let h;return e[5]!==s||e[6]!==i||e[7]!==u?(h=n.jsx(It,{control:s,name:i,render:u}),e[5]=s,e[6]=i,e[7]=u,e[8]=h):h=e[8],h}function Dx(t){const e=B.c(6),{control:s,name:i}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=["yes","no"],e[0]=r):r=e[0];const o=r,a=S.useRef(null);let l;e[1]===Symbol.for("react.memo_cache_sentinel")?(l=u=>{a.current?.onChange(o[u]??"")},e[1]=l):l=e[1],Ou(o.length,l);let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=u=>{const{field:h}=u;return a.current=h,n.jsxs(Rt,{children:[n.jsx(Tt,{children:n.jsx("div",{className:"flex gap-2 px-2",role:"group","aria-label":"Confirmation options",children:o.map(f=>{const m=h.value===f;return n.jsxs("button",{type:"button",onClick:()=>h.onChange(f),className:J("flex items-center gap-3 px-4 py-3 rounded-lg text-left transition-colors flex-1",m&&"bg-accent/50",!m&&"hover:bg-accent/30"),"aria-label":`Confirm ${f}`,children:[n.jsx("span",{className:J("flex items-center justify-center size-6 rounded-md text-sm shrink-0",m?"bg-chart-1 text-white":"bg-muted text-foreground"),children:f==="yes"?1:2}),n.jsx("span",{className:"text-sm text-foreground capitalize",children:f})]},f)})})}),n.jsx(Dt,{})]})},e[2]=c):c=e[2];let d;return e[3]!==s||e[4]!==i?(d=n.jsx(It,{control:s,name:i,render:c}),e[3]=s,e[4]=i,e[5]=d):d=e[5],d}function Mc(t){const e=B.c(13),{input:s,control:i,name:r}=t;switch(s.type){case"text":{let o;return e[0]!==i||e[1]!==s.default||e[2]!==r?(o=n.jsx(Rx,{control:i,name:r,placeholder:s.default}),e[0]=i,e[1]=s.default,e[2]=r,e[3]=o):o=e[3],o}case"choice":{let o;e[4]!==s.options?(o=s.options?.filter(Boolean)??[],e[4]=s.options,e[5]=o):o=e[5];const a=o;let l;return e[6]!==i||e[7]!==r||e[8]!==a?(l=n.jsx(Tx,{control:i,name:r,options:a}),e[6]=i,e[7]=r,e[8]=a,e[9]=l):l=e[9],l}case"confirm":{let o;return e[10]!==i||e[11]!==r?(o=n.jsx(Dx,{control:i,name:r}),e[10]=i,e[11]=r,e[12]=o):o=e[12],o}default:return null}}function Mx({parts:t,onSubmit:e}){const[s,i]=S.useState(t[0]?.toolCallId??""),r=Ix(t.map(x=>({toolCallId:x.toolCallId,input:x.input}))),o=Gi({resolver:Un(r),defaultValues:Object.fromEntries(t.map(x=>[x.toolCallId,{response:""}]))}),a=o.watch(),l=t.findIndex(x=>x.toolCallId===s),c=!!a[s]?.response,d=t.every(x=>!!a[x.toolCallId]?.response),u=x=>{for(const b of t){const y=x[b.toolCallId]?.response;y&&e(b,y)}},h=x=>t.find(b=>!x[b.toolCallId]?.response&&b.toolCallId!==s)??null,f=()=>{const x=o.getValues();if(t.every(y=>!!x[y.toolCallId]?.response))o.handleSubmit(u)();else{const y=h(x);y&&i(y.toolCallId)}},m=()=>{o.setValue(`${s}.response`,"user has skip this question"),f()},p=()=>{if(l>0){const x=t[l-1];x&&i(x.toolCallId)}},g=()=>{if(l<t.length-1){const x=t[l+1];x&&i(x.toolCallId)}},_=n.jsxs(n.Fragment,{children:[n.jsx(ae,{type:"button",variant:"outline",size:"sm",onClick:m,className:"h-7",children:"Skip"}),n.jsx(ae,{type:"button",size:"sm",disabled:!c,onClick:f,className:J("h-7",c?"":"opacity-50"),children:d?"Submit":"Next"})]}),v=n.jsx(Lu,{current:l,total:t.length,onPrev:p,onNext:g});if(t.length===1){const x=t[0];return x?.input?n.jsx($i,{...o,children:n.jsx("form",{onSubmit:o.handleSubmit(u),autoComplete:"off",children:n.jsx(Hr,{title:x.input?.prompt??"Question",footerRight:_,children:n.jsx(Mc,{input:x.input,control:o.control,name:`${x.toolCallId}.response`})})})}):null}return n.jsx($i,{...o,children:n.jsx("form",{onSubmit:o.handleSubmit(u),autoComplete:"off",children:n.jsx(Hh,{value:s,onValueChange:i,children:t.map(x=>n.jsx(Cr,{value:x.toolCallId,className:"mt-0",children:n.jsx(Hr,{title:x.input?.prompt??"Question",footerLeft:v,footerRight:_,children:n.jsx(Mc,{input:x.input,control:o.control,name:`${x.toolCallId}.response`})})},x.toolCallId))})})})}function Px(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsxs("div",{className:"flex items-center gap-2 p-4 border border-dashed rounded-lg bg-accent/50 w-[calc(100%-16px)] max-w-[584px] mx-auto mb-2",children:[n.jsx(Kg,{className:"size-5 text-muted-foreground shimmer"}),n.jsx("span",{className:"text-sm text-muted-foreground shimmer",children:"Preparing question..."})]}),t[0]=e):e=t[0],e}function Bu(t){const e=B.c(6),{userAskParts:s,isStreaming:i,onSubmit:r}=t;let o;e[0]!==s?(o=s.filter(Lx),e[0]=s,e[1]=o):o=e[1];const a=o;if(i){let c;return e[2]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx(Px,{}),e[2]=c):c=e[2],c}if(a.length===0)return null;let l;return e[3]!==r||e[4]!==a?(l=n.jsx(Mx,{parts:a,onSubmit:r}),e[3]=r,e[4]=a,e[5]=l):l=e[5],l}function Lx(t){return t.state==="input-available"}const Pc=new Map;function go(){const{org:t}=xe(),e=Be({connectionId:Pt,orgId:t.id}),s=jl(),i=s.find(_=>_.providerId==="deco"),{data:r,isLoading:o,refetch:a,isFetching:l}=Ki({queryKey:ct.aiProviderCredits(t.id,"deco"),enabled:!!i,staleTime:6e4,queryFn:async()=>{const _=await e.callTool({name:"AI_PROVIDER_CREDITS",arguments:{providerId:"deco"}});return _?.isError?null:_.structuredContent??null}}),c=r?.balanceCents??null,d=c!=null?c/100:null,u=S.useRef(new Map);if(c!=null){const _=Pc.get(t.id);u.current.get(t.id)&&_!=null&&c>_&&ne("credits_topped_up_detected",{organization_id:t.id,delta_cents:c-_,previous_balance_cents:_,new_balance_cents:c}),Pc.set(t.id,c),u.current.set(t.id,!0)}const h=!!i,f=c!=null&&c>0,m=c!=null&&c===0,p=c!=null&&c===200,g=s.length>0&&s.every(_=>_.providerId==="deco");return{hasDecoKey:h,decoKeyId:i?.id??null,balanceCents:c,balanceDollars:d,hasCredits:f,isZeroBalance:m,isInitialFreeCredit:p,hasOnlyDecoProvider:g,isLoading:o,isFetching:l,refetch:a}}function Ox(t){return t?t.message.startsWith("[CREDITS]"):!1}const Bx={usd:[{dollars:10,label:"Starter"},{dollars:20,label:"Popular"},{dollars:100,label:"Best value"}],brl:[{dollars:50,label:"Starter"},{dollars:100,label:"Popular"},{dollars:500,label:"Best value"}]},$x=["Access to 100+ AI models","Unified API, no separate keys needed","Pay only for what you use"];function $u(t){const e=B.c(43),{onDismiss:s}=t,{org:i}=xe(),r=Ge(),{decoKeyId:o}=go();let a;e[0]!==i.id?(a={connectionId:Pt,orgId:i.id},e[0]=i.id,e[1]=a):a=e[1];const l=Be(a),[c,d]=S.useState(""),[u,h]=S.useState(!1),[f,m]=S.useState("usd"),p=f==="brl"?"R$":"$";let g,_;e[2]!==i.id?(g=()=>{ne("credits_exhausted_shown",{organization_id:i.id})},_=[i.id],e[2]=i.id,e[3]=g,e[4]=_):(g=e[3],_=e[4]),S.useEffect(g,_);let v;e[5]!==l||e[6]!==f?(v=async D=>{const P=await l.callTool({name:"AI_PROVIDER_TOPUP_URL",arguments:{providerId:"deco",amountCents:D,currency:f}});if(P?.isError)throw new Error(P.content?.[0]?.text??"Failed to get top-up URL");return P.structuredContent?.url},e[5]=l,e[6]=f,e[7]=v):v=e[7];let x;e[8]!==s?(x=D=>{D&&window.open(D,"_blank","noopener,noreferrer"),s?.()},e[8]=s,e[9]=x):x=e[9];let b;e[10]!==v||e[11]!==x?(b={mutationFn:v,onSuccess:x,onError:Ux},e[10]=v,e[11]=x,e[12]=b):b=e[12];const{mutate:y,isPending:C}=qi(b),k=parseFloat(c),w=!isNaN(k)&&k>=1;let V;e[13]!==s?(V=D=>!D&&s?.(),e[13]=s,e[14]=V):V=e[14];let j;e[15]===Symbol.for("react.memo_cache_sentinel")?(j=["radial-gradient(ellipse 40% 200% at -5% 100%, rgba(165,149,255,0.5) 0%, transparent 100%)","radial-gradient(ellipse 40% 200% at 105% -10%, rgba(208,236,26,0.45) 0%, transparent 100%)"],e[15]=j):j=e[15];let I;e[16]===Symbol.for("react.memo_cache_sentinel")?(I=n.jsx("div",{className:"absolute inset-x-0 top-0 h-36 pointer-events-none",style:{backgroundImage:j.join(", "),maskImage:"linear-gradient(to bottom, black 0%, transparent 100%)",WebkitMaskImage:"linear-gradient(to bottom, black 0%, transparent 100%)"}}),e[16]=I):I=e[16];let T;e[17]===Symbol.for("react.memo_cache_sentinel")?(T=n.jsxs("div",{className:"relative px-8 pt-8 pb-2 overflow-hidden",children:[I,n.jsxs(hs,{className:"relative gap-4",children:[n.jsx("img",{src:"/logos/deco%20logo.svg",alt:"Deco AI Gateway",className:"size-9 rounded-lg object-contain dark:bg-white dark:p-0.5"}),n.jsxs("div",{children:[n.jsx(ds,{className:"text-xl font-semibold tracking-tight",children:"Top up to keep building"}),n.jsx(ao,{className:"mt-1.5 text-sm leading-relaxed",children:"Your credits are used up. Add more to continue using AI across all your agents."})]})]})]}),e[17]=T):T=e[17];let R;e[18]!==f||e[19]!==p||e[20]!==c||e[21]!==k||e[22]!==o||e[23]!==w||e[24]!==C||e[25]!==u||e[26]!==y?(R=o&&n.jsxs("div",{className:"px-8 pt-5 pb-6",children:[n.jsx("div",{className:"mb-4",children:n.jsxs(du,{type:"single",variant:"outline",size:"sm",value:f,onValueChange:D=>{D&&m(D)},children:[n.jsx(zr,{value:"usd",className:"h-8 px-3 text-xs",children:"USD"}),n.jsx(zr,{value:"brl",className:"h-8 px-3 text-xs",children:"BRL"})]})}),n.jsxs("div",{className:"rounded-xl border border-border p-5",children:[n.jsx("div",{className:"grid grid-cols-3 gap-2.5",children:Bx[f].map(D=>{const{dollars:P,label:O}=D;return n.jsxs("button",{type:"button",disabled:C,onClick:()=>{ne("credits_topup_clicked",{amount_cents:P*100,currency:f,tier_label:O,source:"exhausted_banner"}),y(P*100)},className:J("relative flex flex-col items-center gap-1 py-5 rounded-xl border transition-all duration-150 cursor-pointer","disabled:opacity-50 disabled:cursor-wait","border-border hover:border-foreground/20 hover:bg-muted/30"),children:[n.jsxs("span",{className:"text-2xl font-semibold tabular-nums text-foreground",children:[p,P]}),n.jsx("span",{className:"text-xs text-muted-foreground",children:O})]},P)})}),u?n.jsxs("div",{className:"flex gap-2 mt-3",children:[n.jsxs("div",{className:"relative flex-1",children:[n.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-sm text-muted-foreground select-none",children:p}),n.jsx(gt,{type:"number",min:"1",step:"1",placeholder:"50",value:c,onChange:D=>d(D.target.value),className:"h-10 text-sm pl-7",autoFocus:!0})]}),n.jsx(ae,{className:"h-10",disabled:!w||C,onClick:()=>{ne("credits_topup_clicked",{amount_cents:Math.round(k*100),currency:f,tier_label:"custom",source:"exhausted_banner"}),y(Math.round(k*100))},children:C?"Opening...":"Add"})]}):n.jsx("button",{type:"button",className:"w-full mt-3 text-xs text-muted-foreground hover:text-foreground transition-colors py-1",onClick:()=>h(!0),children:"Enter custom amount"})]}),n.jsx("div",{className:"mt-5 rounded-xl bg-muted/25 border border-border/50 p-4 space-y-3",children:$x.map(zx)})]}),e[18]=f,e[19]=p,e[20]=c,e[21]=k,e[22]=o,e[23]=w,e[24]=C,e[25]=u,e[26]=y,e[27]=R):R=e[27];let N;e[28]!==s?(N=n.jsx(ae,{variant:"ghost",size:"sm",onClick:s,children:"Dismiss"}),e[28]=s,e[29]=N):N=e[29];let A;e[30]!==r||e[31]!==s||e[32]!==i.slug?(A=n.jsx("button",{type:"button",className:"text-xs text-muted-foreground hover:text-foreground transition-colors",onClick:()=>{r({to:"/$org/settings/ai-providers",params:{org:i.slug}}),s?.()},children:"Manage providers"}),e[30]=r,e[31]=s,e[32]=i.slug,e[33]=A):A=e[33];let E;e[34]!==N||e[35]!==A?(E=n.jsxs("div",{className:"px-8 py-4 border-t border-border bg-muted/30 flex items-center justify-between",children:[N,A]}),e[34]=N,e[35]=A,e[36]=E):E=e[36];let M;e[37]!==R||e[38]!==E?(M=n.jsxs(ts,{className:"sm:max-w-[520px] gap-0 p-0 overflow-hidden",onOpenAutoFocus:Fx,children:[T,R,E]}),e[37]=R,e[38]=E,e[39]=M):M=e[39];let L;return e[40]!==M||e[41]!==V?(L=n.jsx(ss,{open:!0,onOpenChange:V,children:M}),e[40]=M,e[41]=V,e[42]=L):L=e[42],L}function zx(t){return n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("div",{className:"flex items-center justify-center size-5 rounded-full bg-[hsl(var(--chart-1))]/15 shrink-0",children:n.jsx(Jt,{size:12,className:"text-[hsl(var(--chart-1))]"})}),n.jsx("span",{className:"text-sm text-foreground/80",children:t})]},t)}function Fx(t){return t.preventDefault()}function Ux(t){ue.error(`Top-up failed: ${t.message}`)}const Hx={length:"Response reached the model's output limit. Different models have different limits. Try switching models or asking it to continue.","content-filter":"Response was filtered due to content policy.","tool-calls":"Response paused after tool execution to prevent infinite loops and save costs. Click continue to keep working."};function Wr(t){const e=B.c(32),{variant:s,onDismiss:i}=t,r=s==="error",o=r?"Error occurred":"Response incomplete",a=r?t.error.message:Hx[t.finishReason]??`Response stopped unexpectedly: ${t.finishReason}`,l=r?"border-destructive/30 bg-destructive/5":"border-amber-500/30 bg-amber-500/5",c=r?"text-destructive":"text-amber-600 dark:text-amber-500",d=r?oi:ul;let u;e[0]!==l?(u=J("flex items-start gap-2 px-3 py-2.5 rounded-lg border border-dashed text-sm w-full mb-2 shadow",l),e[0]=l,e[1]=u):u=e[1];let h;e[2]!==c?(h=J("mt-0.5 shrink-0",c),e[2]=c,e[3]=h):h=e[3];let f;e[4]!==d?(f=n.jsx(d,{size:16}),e[4]=d,e[5]=f):f=e[5];let m;e[6]!==h||e[7]!==f?(m=n.jsx("div",{className:h,children:f}),e[6]=h,e[7]=f,e[8]=m):m=e[8];let p;e[9]!==c?(p=J("text-xs mb-1 font-medium",c),e[9]=c,e[10]=p):p=e[10];let g;e[11]!==p||e[12]!==o?(g=n.jsx("div",{className:p,children:o}),e[11]=p,e[12]=o,e[13]=g):g=e[13];let _;e[14]!==a?(_=n.jsx("div",{className:"text-xs line-clamp-2 text-muted-foreground mb-2",children:a}),e[14]=a,e[15]=_):_=e[15];let v;e[16]!==r||e[17]!==t.onContinue||e[18]!==t.onFixInChat?(v=n.jsx("div",{className:"flex gap-2",children:r?n.jsxs(n.Fragment,{children:[n.jsx(ae,{size:"sm",variant:"outline",onClick:t.onFixInChat,className:"h-7 text-xs",children:"Fix in chat"}),n.jsx(ae,{size:"sm",variant:"outline",disabled:!0,className:"h-7 text-xs",children:"Report"})]}):n.jsx(ae,{size:"sm",variant:"outline",onClick:t.onContinue,className:"h-7 text-xs",children:"Continue"})}),e[16]=r,e[17]=t.onContinue,e[18]=t.onFixInChat,e[19]=v):v=e[19];let x;e[20]!==g||e[21]!==_||e[22]!==v?(x=n.jsxs("div",{className:"flex-1 min-w-0",children:[g,_,v]}),e[20]=g,e[21]=_,e[22]=v,e[23]=x):x=e[23];let b;e[24]===Symbol.for("react.memo_cache_sentinel")?(b=n.jsx(Js,{size:14}),e[24]=b):b=e[24];let y;e[25]!==i?(y=n.jsx("button",{type:"button",onClick:i,className:"text-muted-foreground hover:text-foreground transition-colors shrink-0",title:"Dismiss",children:b}),e[25]=i,e[26]=y):y=e[26];let C;return e[27]!==u||e[28]!==y||e[29]!==m||e[30]!==x?(C=n.jsx("div",{className:"px-0.5",children:n.jsxs("div",{className:u,children:[m,x,y]})}),e[27]=u,e[28]=y,e[29]=m,e[30]=x,e[31]=C):C=e[31],C}function _o(){const t=B.c(41),{error:e,clearError:s,finishReason:i,clearFinishReason:r,messages:o,isStreaming:a,isWaitingForApprovals:l,addToolOutput:c,addToolApprovalResponse:d,sendMessage:u}=Yi(),[h,f]=yi(),{virtualMcpId:m,createTaskWithMessage:p}=es();let g,_,v,x;if(t[0]!==o){const E=o.at(-1);x=E?.role==="assistant"?E.parts.filter(qx):null,g=x?.filter(Kx)?.length,_=E?.role==="assistant"?jx(E.parts):[],v=E?.role==="assistant"?wx(E.parts):[],t[0]=o,t[1]=g,t[2]=_,t[3]=v,t[4]=x}else g=t[1],_=t[2],v=t[3],x=t[4];const b=v;let y;t[5]!==e||t[6]!==u?(y=()=>{if(e){const M={type:"doc",content:[{type:"paragraph",content:[{type:"text",text:`I encountered this error: ${e.message}. Can you help me fix it?`}]}]};u(M)}},t[5]=e,t[6]=u,t[7]=y):y=t[7];const C=y;let k;t[8]!==u?(k=()=>{u({type:"doc",content:[{type:"paragraph",content:[{type:"text",text:"Please continue."}]}]})},t[8]=u,t[9]=k):k=t[9];const w=k;let V;t[10]!==c?(V=(E,M)=>{c({tool:"user_ask",toolCallId:E.toolCallId,output:{response:M}})},t[10]=c,t[11]=V):V=t[11];const j=V;let I;t[12]!==p||t[13]!==h||t[14]!==f||t[15]!==m?(I=E=>{f({...h,toolApprovalLevel:"auto"}),p({virtualMcpId:m,message:{parts:[{type:"text",text:`Implement this plan:
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/project-app-view-B680Vk1Z.js","assets/index-BR4Tv9I4.js","assets/index-DHRo5LVc.css","assets/task-status-CoVKDaYE.js","assets/agent-icon-FJlZxNBT.js","assets/AlertCircle-i753hIUr.js","assets/Tool01-DV6LLMyv.js","assets/SearchMd-BQ703EvX.js","assets/ArrowNarrowLeft-DyneV8jh.js","assets/XCircle-Cu_m9KsD.js","assets/ZapSquare-Bzu6OwXc.js","assets/Users03-AWMGi4Xo.js","assets/CheckCircle-BDNIuV_g.js","assets/ChevronDown-vRDN8zoj.js","assets/ChevronRight-P2x5wJJp.js","assets/ChevronUp-Dg737K7F.js","assets/Container-DsC3rtEa.js","assets/Star01-D8uixfU7.js","assets/Palette-CxbsG8jb.js","assets/index-BxuUqWWJ.js","assets/use-mobile-UG3f-VUD.js","assets/X-B19qdsWt.js","assets/LinkExternal01-Cw9xV77y.js","assets/Lock01-B4C5ICSW.js","assets/Sun-Dzvpwc78.js","assets/Play-F_qMNNeX.js","assets/Plus-BM77-3yZ.js","assets/Settings02-CZ-RzoRL.js","assets/Trash01-DeQUJecj.js","assets/Upload01-C7vhn2fS.js","assets/User01-CFTuPOYw.js","assets/Zap-kmaaq3eG.js","assets/scroll-area-CrjX3IME.js","assets/select-BQ3zutkO.js","assets/use-copy-BRihc-l2.js","assets/differenceInSeconds-NQ4PDo0z.js","assets/dialog-BG20y4ti.js","assets/content-blocks-o63cs2vh.js","assets/types-DA2UHbyR.js","assets/constants-CN6Il9QM.js","assets/chat-context-BQqGEJhg.js","assets/use-virtual-mcp-Doro-WnT.js","assets/use-collections-Bo1B5pfj.js","assets/use-ai-providers-LqR26vuo.js","assets/use-decopilot-events-cbOJk-u-.js","assets/create-sse-subscription-CxkOgzKf.js","assets/use-tasks-DkVJbPPF.js","assets/use-organization-settings-bbuIudaf.js","assets/shell-layout-DrONQ6vr.js","assets/required-auth-layout-9J8EILU3.js","assets/use-org-sso-eSfysoE_.js","assets/integration-icon-EHHTVGeJ.js","assets/use-mcp-tools-DqNbK4tC.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{o as Mt,r as S,p as Jm,q as Qm,e as B,s as xe,K as ct,n as Ki,a as qi,v as Ns,w as Un,x as Gi,j as n,B as ae,y as Et,c as J,E as As,z as ue,C as yi,_ as Zm,t as ne,f as Ge,D as ul,F as ep,R as Eh,G as tp,H as Vs,I as No,J as ms,L as sp,M as Ao,P as ip,Q as np,T as rp,U as op,V as Ih,W as ap,X as lp,Y as cp,Z as dp,$ as mc,l as Me,b as St,u as hp,a0 as bn,a1 as wr,a2 as fl,a3 as ml,g as Hn,a4 as Rh,d as Si,a5 as up,a6 as fp,a7 as mp,a8 as pp,a9 as Th,aa as Dh,ab as gp,ac as _p,ad as xp,ae as Ut,af as vp,ag as bp,ah as yp,ai as Sp,aj as nn,ak as wp,al as Vp,am as Cp,an as kp,ao as Mh,ap as jp,aq as Np,ar as Ap,as as Ep,at as Ip,au as Rp,av as Tp,aw as Dp,ax as Mp,ay as Pp,az as Ph,aA as Vr,aB as Lp,aC as Ti,aD as cr,aE as Lh,aF as Op,aG as Bp}from"./index-BR4Tv9I4.js";import{u as ai,a as Yi,b as es,A as $p,C as zp,t as Oh,c as da,d as Fp,e as no,f as pc}from"./chat-context-BQqGEJhg.js";import{d as ro,g as ni,c as Up,s as pl,t as Hp,a as Wp,M as Kp,i as qp,b as En,e as Gp,F as Yp,f as Bh,S as Xp,u as Jp,h as gc,j as Qp,k as Zp,l as ha,r as eg,m as tg,p as $h,n as sg,o as ig,q as gl,G as ng,L as rg,v as og,w as ag,x as lg,y as cg}from"./task-status-CoVKDaYE.js";import{S as In,u as oo,P as ua,a as dg,b as hg,c as ug,E as fg,i as mg,d as pg,e as zh}from"./scroll-area-CrjX3IME.js";import{T as Bi,u as Ps,a as st,b as it,c as nt}from"./use-mobile-UG3f-VUD.js";import{D as ds,a as hs,b as _l,c as ts,d as ss,e as ao}from"./dialog-BG20y4ti.js";import{D as lo,a as wi,b as Vi,c as Ci,d as gg,e as _g,f as xg}from"./drawer-Gt9dvwHd.js";import{C as Fh}from"./collection-search-CcNzJi6D.js";import{S as Pt,u as Be,g as co,i as Br,c as vg,W as ks,a as bg,b as xl}from"./constants-CN6Il9QM.js";import{u as Uh,g as vl,T as Hh,a as Cr,l as $r,b as Eo,c as yg}from"./tabs-B14EKG0Q.js";import{F as $i,a as It,b as Rt,c as os,d as Tt,e as Dt,f as Sg}from"./form-DVLM8o8l.js";import{I as gt}from"./input-C6wlfqbz.js";import{i as Wh,u as Wn,r as Kh}from"./shell-layout-DrONQ6vr.js";import{D as at,a as kr,b as jr,c as Es,d as Is,e as Rs,f as qh,g as Gh,h as _c}from"./dropdown-menu-D_gbsFgj.js";import{t as wg,i as Yh,n as Xh,A as gs,a as Jh,b as bl,s as ri,c as Vg,d as Cg,e as Qh,f as Zh,g as kg,h as yl,j as yn,k as jg,l as Sl,m as Ng,o as Ag,p as Kn,q as qn,r as Eg,u as xc,v as vc,w as Ig,x as Rg,y as bc,z as Tg,B as wl,C as eu,D as fa,E as Io,F as yc,G as Dg,H as Mg,I as Pg,J as Lg,K as tu,L as su,M as iu,N as nu,O as Sc,P as Og,Q as Sn,R as Bg,S as $g,T as zg,U as ru}from"./agent-icon-FJlZxNBT.js";import{n as ou,a as ma,i as Fg,b as Ug,c as Hg}from"./ZapSquare-Bzu6OwXc.js";import{i as Jt,t as Rn}from"./ChevronDown-vRDN8zoj.js";import{s as Li}from"./Star01-D8uixfU7.js";import{a as pa,t as Vl}from"./Tool01-DV6LLMyv.js";import{i as au}from"./Lock01-B4C5ICSW.js";import{s as Qt}from"./Plus-BM77-3yZ.js";import{i as lu}from"./Upload01-C7vhn2fS.js";import{i as Js}from"./X-B19qdsWt.js";import{i as oi}from"./AlertCircle-i753hIUr.js";import{S as Zs,a as ei,b as Ht,c as ti,d as si}from"./select-BQ3zutkO.js";import{i as Cl,a as kl,b as Wg}from"./SearchMd-BQ703EvX.js";import{i as ho,t as Kg,a as qg,b as Gg,c as Yg,d as Xg,e as zi,f as cu}from"./XCircle-Cu_m9KsD.js";import{T as du,a as zr}from"./toggle-group-xjN2RMip.js";import{u as jl,a as hu}from"./use-ai-providers-LqR26vuo.js";import{m as uo,g as Jg,i as Qg,a as uu,M as fu,N as Zg}from"./select-model-Cbrp8hD-.js";import{S as e_,A as t_,a as s_,b as i_,c as n_,R as mu,d as r_,e as o_}from"./accordion-Bcqp7xWC.js";import{r as pu,l as wn,u as a_,g as l_}from"./types-DA2UHbyR.js";import{u as fo,a as is,b as Nl}from"./use-virtual-mcp-Doro-WnT.js";import{u as Gn,a as mo,b as Al}from"./use-connection-NZXO3HH3.js";import{p as c_,q as wc}from"./question-004-sINsf4GQ.js";import{g as Vc}from"./ai-providers-logos-CS4PCiqI.js";import{g as gu,s as _u}from"./connection-slug-eyAPH6o3.js";import{u as xu,a as vu,g as d_,C as Ro}from"./connection-card-DKlghzN6.js";import{C as bu}from"./collection-tabs-DD0Qt8TU.js";import{g as yu}from"./constants-DBlKftLg.js";import{T as ga}from"./textarea-Bxm5HSBV.js";import{n as Nr}from"./Container-DsC3rtEa.js";import{c as h_,i as dr,a as Cc,E as u_,p as f_,b as m_,d as p_}from"./connection-form-helpers-ByqGzB7q.js";import{u as kc}from"./use-infinite-scroll-BE8Qm8G-.js";import{u as g_,C as __,a as jc,b as Nc,c as x_,d as v_,e as b_,f as y_}from"./command-rQqgIdbd.js";import{g as S_,e as w_,a as V_}from"./extract-connection-data-BkUkPjk1.js";import{B as Ac}from"./badge-OuHAk68F.js";import{i as El}from"./ChevronRight-P2x5wJJp.js";import{I as Ls}from"./integration-icon-EHHTVGeJ.js";import{S as Fi}from"./skeleton-CmnvTWJg.js";import{a as po}from"./Users03-AWMGi4Xo.js";import{G as Su,u as C_,I as Fr,S as wu,L as k_,a as j_,b as Vu}from"./lean-canvas-recruit-modal-D54L-ueX.js";import{u as Yn,a as Cu}from"./use-navigate-to-agent-CDgOtsNz.js";import{S as Ur}from"./switch-CM_vPUzz.js";import{u as ku}from"./use-create-virtual-mcp-DgwS04N8.js";import{i as N_}from"./CheckCircle-BDNIuV_g.js";import{P as li,a as ci,b as di}from"./popover-DL7_3A88.js";import{u as ki,a as A_}from"./use-mcp-tools-DqNbK4tC.js";import{E as Ui}from"./empty-state-B4p5HAyS.js";import{u as E_}from"./use-decopilot-events-cbOJk-u-.js";import{i as Hi}from"./Zap-kmaaq3eG.js";import{i as ju,S as Xn,a as Jn,b as vs,u as Qn,c as _s,d as Zt,e as Nu,f as Au,g as I_,h as Eu,j as Iu,P as ps,k as R_,l as T_,m as D_,n as M_,o as P_,p as L_}from"./index-BxuUqWWJ.js";import{A as Ec}from"./avatar-BeRTzZHX.js";import{n as O_,a as B_,i as $_}from"./Sun-Dzvpwc78.js";import{a as Zn}from"./Settings02-CZ-RzoRL.js";import{A as Il,a as Rl,b as Tl,c as Dl,d as Ml,e as Pl,f as Ll,g as Ru}from"./alert-dialog-BJ0hwa2l.js";import"./index-B3NgIo6R.js";import{u as Tu}from"./use-tasks-DkVJbPPF.js";import{u as z_}from"./use-status-sounds-e0qVVZe8.js";import{T as F_,u as Du}from"./tools-list-DqbhkVqY.js";import{u as To}from"./unwrap-tool-result-BYXdCQMg.js";import{C as U_,a as Ic}from"./card-64W2yOQo.js";import{L as Vn}from"./label-CMuBjs0l.js";import{i as Ar}from"./Play-F_qMNNeX.js";import{s as _a}from"./Trash01-DeQUJecj.js";import{C as H_}from"./checkbox-Cx3RPx8a.js";import{n as ji}from"./LinkExternal01-Cw9xV77y.js";import{V as W_}from"./view-mode-toggle-B0na2o09.js";import{U as K_}from"./user-DMxAeRCM.js";import{u as er,a as q_,b as G_,c as Y_,A as X_,d as J_}from"./automation-list-row-GPd6_cjS.js";import{S as Q_}from"./search-input-DmblMA4A.js";import"./use-collections-Bo1B5pfj.js";import"./use-organization-settings-bbuIudaf.js";import"./use-copy-BRihc-l2.js";import"./differenceInSeconds-NQ4PDo0z.js";import"./content-blocks-o63cs2vh.js";import"./required-auth-layout-9J8EILU3.js";import"./use-org-sso-eSfysoE_.js";import"./ArrowNarrowLeft-DyneV8jh.js";import"./ChevronUp-Dg737K7F.js";import"./Palette-CxbsG8jb.js";import"./User01-CFTuPOYw.js";import"./formatDistanceToNow-Cb2QZZJn.js";import"./use-registry-connections-DN_uk-6v.js";import"./useInfiniteQuery-C5UYrvtb.js";import"./infiniteQueryObserver-DjdUCzEf.js";import"./collections-BpO3SJDN.js";import"./index-BZ-_pOxX.js";import"./create-sse-subscription-CxkOgzKf.js";function Z_(t,e){const s=Mt(e);return ex({filters:{...t,status:"pending"}},s).length}function Rc(t,e){return t.findAll(e.filters).map(s=>e.select?e.select(s):s.state)}function ex(t={},e){const s=Mt(e).getMutationCache(),i=S.useRef(t),r=S.useRef(null);return r.current===null&&(r.current=Rc(s,t)),S.useEffect(()=>{i.current=t}),S.useSyncExternalStore(S.useCallback(o=>s.subscribe(()=>{const a=Jm(r.current,Rc(s,i.current));r.current!==a&&(r.current=a,Qm.schedule(o))}),[s]),()=>r.current,()=>r.current)}function tx(t,e){const s=B.c(37),{org:i,locator:r}=xe();let o;s[0]!==i.id?(o={connectionId:Pt,orgId:i.id},s[0]=i.id,s[1]=o):o=s[1];const a=Be(o),l=Mt();let c;s[2]!==t||s[3]!==i.id?(c=ct.ensureTask(i.id,t),s[2]=t,s[3]=i.id,s[4]=c):c=s[4];let d;s[5]!==a||s[6]!==t?(d=async()=>(await a.callTool({name:"COLLECTION_THREADS_GET",arguments:{id:t}})).structuredContent?.item??null,s[5]=a,s[6]=t,s[7]=d):d=s[7];let u;s[8]!==c||s[9]!==d?(u={queryKey:c,queryFn:d,retry:!1,refetchOnWindowFocus:!1},s[8]=c,s[9]=d,s[10]=u):u=s[10];const h=Ki(u);let f;s[11]!==a||s[12]!==e?(f=async b=>{const y=await a.callTool({name:"COLLECTION_THREADS_CREATE",arguments:{data:{id:b,virtual_mcp_id:e}}});if(y.isError){const k=y.content,w=Array.isArray(k)&&k[0]&&typeof k[0]=="object"?k[0].text??"Create failed":"Create failed";throw new Error(w)}return y.structuredContent.item},s[11]=a,s[12]=e,s[13]=f):f=s[13];let m;s[14]!==r||s[15]!==i.id||s[16]!==h||s[17]!==l?(m=()=>{l.invalidateQueries({predicate:b=>b.queryKey[1]===i.id&&b.queryKey[3]==="collection"&&b.queryKey[4]==="THREADS"}),l.invalidateQueries({queryKey:ct.tasksPrefix(r)}),h.refetch()},s[14]=r,s[15]=i.id,s[16]=h,s[17]=l,s[18]=m):m=s[18];let p;s[19]!==f||s[20]!==m?(p={mutationFn:f,onSuccess:m},s[19]=f,s[20]=m,s[21]=p):p=s[21];const g=qi(p);let _,v;if(s[22]!==g||s[23]!==t||s[24]!==h.data||s[25]!==h.isSuccess?(_=()=>{!h.isSuccess||h.data||g.isPending||g.variables!==t&&g.mutate(t)},v=[t,h.isSuccess,h.data,g],s[22]=g,s[23]=t,s[24]=h.data,s[25]=h.isSuccess,s[26]=_,s[27]=v):(_=s[26],v=s[27]),S.useEffect(_,v),h.isLoading){let b;return s[28]===Symbol.for("react.memo_cache_sentinel")?(b={status:"loading"},s[28]=b):b=s[28],b}if(h.isError){const b=h.error;let y;return s[29]!==b?(y={status:"error",error:b},s[29]=b,s[30]=y):y=s[30],y}if(h.isSuccess&&h.data){let b;return s[31]!==h.data?(b={status:"ready",task:h.data},s[31]=h.data,s[32]=b):b=s[32],b}if(g.isPending||h.isSuccess&&!h.data){let b;return s[33]===Symbol.for("react.memo_cache_sentinel")?(b={status:"creating"},s[33]=b):b=s[33],b}if(g.isError){let b;return s[34]!==g.error?(b={status:"error",error:g.error},s[34]=g.error,s[35]=b):b=s[35],b}let x;return s[36]===Symbol.for("react.memo_cache_sentinel")?(x={status:"loading"},s[36]=x):x=s[36],x}function sx(t){const e={};for(const s of t.arguments??[])e[s.name]=s.required?Et().min(1,"Required"):Et();return Ns(e)}function ix(t){const e={};for(const s of t.arguments??[])e[s.name]="";return e}function Ol(t){const e=B.c(65),{prompt:s,setPrompt:i,onSubmit:r}=t,o=S.useId();let a;if(e[0]!==s){const D=s?sx(s):Ns({});a=Un(D),e[0]=s,e[1]=a}else a=e[1];const c=a;let d;e[2]!==s?(d=s?ix(s):{},e[2]=s,e[3]=d):d=e[3];let u;e[4]!==c||e[5]!==d?(u={resolver:c,defaultValues:d,mode:"onChange"},e[4]=c,e[5]=d,e[6]=u):u=e[6];const h=Gi(u);let f;e[7]!==s?.arguments?(f=s?.arguments??[],e[7]=s?.arguments,e[8]=f):f=e[8];const m=f;let p;e[9]!==h||e[10]!==r||e[11]!==i?(p=async D=>{await r(D),i(null),h.reset()},e[9]=h,e[10]=r,e[11]=i,e[12]=p):p=e[12];const g=p;let _;e[13]!==h||e[14]!==i?(_=D=>{D||(h.reset(),i(null))},e[13]=h,e[14]=i,e[15]=_):_=e[15];const v=_;if(!s)return null;let x;e[16]!==s._meta||e[17]!==s.name||e[18]!==s.title?(x=s.title||ro(s.name,ni(s._meta)),e[16]=s._meta,e[17]=s.name,e[18]=s.title,e[19]=x):x=e[19];let b;e[20]!==x?(b=n.jsx(ds,{children:n.jsx("span",{className:"capitalize",children:x})}),e[20]=x,e[21]=b):b=e[21];let y;e[22]!==s.description?(y=s.description&&n.jsx("p",{className:"text-sm text-muted-foreground",children:s.description}),e[22]=s.description,e[23]=y):y=e[23];let C;e[24]!==y||e[25]!==b?(C=n.jsxs(hs,{children:[b,y]}),e[24]=y,e[25]=b,e[26]=C):C=e[26];let k;e[27]!==h||e[28]!==g?(k=D=>{D.stopPropagation(),h.handleSubmit(g)(D)},e[27]=h,e[28]=g,e[29]=k):k=e[29];let w;if(e[30]!==m||e[31]!==h.control||e[32]!==h.formState.isSubmitting){let D;e[34]!==h.control||e[35]!==h.formState.isSubmitting?(D=P=>n.jsx(It,{control:h.control,name:P.name,render:O=>{const{field:z}=O;return n.jsxs(Rt,{children:[n.jsxs(os,{className:"text-xs",children:[P.name,P.required?null:n.jsxs("span",{className:"text-muted-foreground font-normal",children:[" ","(optional)"]})]}),n.jsx(Tt,{children:n.jsx(gt,{...z,value:z.value??"",required:P.required,placeholder:P.description??"",className:"h-9",disabled:h.formState.isSubmitting})}),n.jsx(Dt,{})]})}},P.name),e[34]=h.control,e[35]=h.formState.isSubmitting,e[36]=D):D=e[36],w=m.map(D),e[30]=m,e[31]=h.control,e[32]=h.formState.isSubmitting,e[33]=w}else w=e[33];let V;e[37]!==v?(V=()=>v(!1),e[37]=v,e[38]=V):V=e[38];let j;e[39]!==h.formState.isSubmitting||e[40]!==V?(j=n.jsx(ae,{type:"button",variant:"ghost",onClick:V,disabled:h.formState.isSubmitting,children:"Cancel"}),e[39]=h.formState.isSubmitting,e[40]=V,e[41]=j):j=e[41];const I=!h.formState.isValid||h.formState.isSubmitting;let T;e[42]!==h.formState.isSubmitting?(T=h.formState.isSubmitting?n.jsxs("span",{className:"flex items-center gap-2",children:[n.jsx(In,{size:"xs"}),"Loading..."]}):"Use prompt",e[42]=h.formState.isSubmitting,e[43]=T):T=e[43];let R;e[44]!==o||e[45]!==I||e[46]!==T?(R=n.jsx(ae,{type:"submit",form:o,disabled:I,children:T}),e[44]=o,e[45]=I,e[46]=T,e[47]=R):R=e[47];let N;e[48]!==j||e[49]!==R?(N=n.jsxs(_l,{children:[j,R]}),e[48]=j,e[49]=R,e[50]=N):N=e[50];let A;e[51]!==o||e[52]!==k||e[53]!==w||e[54]!==N?(A=n.jsxs("form",{id:o,className:"space-y-4 py-4",autoComplete:"off",onSubmit:k,children:[w,N]}),e[51]=o,e[52]=k,e[53]=w,e[54]=N,e[55]=A):A=e[55];let E;e[56]!==h||e[57]!==A?(E=n.jsx($i,{...h,children:A}),e[56]=h,e[57]=A,e[58]=E):E=e[58];let M;e[59]!==C||e[60]!==E?(M=n.jsxs(ts,{className:"sm:max-w-lg max-h-[80vh] overflow-y-auto",children:[C,E]}),e[59]=C,e[60]=E,e[61]=M):M=e[61];let L;return e[62]!==v||e[63]!==M?(L=n.jsx(ss,{open:!0,onOpenChange:v,children:M}),e[62]=v,e[63]=M,e[64]=L):L=e[64],L}function nx(t){return!t||!t.content||t.content.length===0?!0:t.content.every(e=>e.type==="paragraph"?!e.content||e.content.length===0?!0:e.content.every(s=>s.type==="hardBreak"||s.type==="text"&&(!s.text||s.text.trim()==="")):!1)}function rx(t,e){return{type:"doc",content:[...t?.content??[],e].filter(Boolean)}}const Tc=3,Mu="inline-flex items-center gap-2 px-5 py-2.5 rounded-full bg-muted text-muted-foreground text-sm font-medium transition-colors cursor-pointer",ox="flex flex-col gap-1.5 p-4 rounded-xl bg-accent/40 text-sm leading-snug transition-colors cursor-pointer text-left";function Pu(t){const e=B.c(46),{item:s,onSelect:i,isLoading:r,isDisabled:o,variant:a}=t,l=a===void 0?"pill":a,{prompt:c}=s;let d;if(e[0]!==c._meta||e[1]!==c.name||e[2]!==c.title){const w=ni(c._meta);d=c.title??ro(c.name,w),e[0]=c._meta,e[1]=c.name,e[2]=c.title,e[3]=d}else d=e[3];const u=d,h=c.description||null;if(l==="card"){let w;e[4]!==i||e[5]!==c?(w=()=>i(c),e[4]=i,e[5]=c,e[6]=w):w=e[6];const V=o||r,j=r&&"bg-accent/40",I=(o||r)&&"cursor-not-allowed opacity-50";let T;e[7]!==j||e[8]!==I?(T=J(ox,"hover:bg-accent/60 text-foreground",j,I),e[7]=j,e[8]=I,e[9]=T):T=e[9];let R;e[10]!==u?(R=n.jsx("span",{className:"font-medium truncate capitalize",children:u}),e[10]=u,e[11]=R):R=e[11];let N;e[12]!==r?(N=r&&n.jsx(In,{size:"xs"}),e[12]=r,e[13]=N):N=e[13];let A;e[14]!==R||e[15]!==N?(A=n.jsxs("div",{className:"flex items-center justify-between gap-2",children:[R,N]}),e[14]=R,e[15]=N,e[16]=A):A=e[16];let E;e[17]!==h?(E=h&&n.jsx("span",{className:"text-xs text-muted-foreground line-clamp-2",children:h}),e[17]=h,e[18]=E):E=e[18];let M;return e[19]!==A||e[20]!==E||e[21]!==w||e[22]!==V||e[23]!==T?(M=n.jsxs("button",{type:"button",onClick:w,disabled:V,className:T,children:[A,E]}),e[19]=A,e[20]=E,e[21]=w,e[22]=V,e[23]=T,e[24]=M):M=e[24],M}let f;e[25]!==i||e[26]!==c?(f=()=>i(c),e[25]=i,e[26]=c,e[27]=f):f=e[27];const m=o||r,p=r&&"bg-muted/50",g=(o||r)&&"cursor-not-allowed opacity-50";let _;e[28]!==p||e[29]!==g?(_=J(Mu,"hover:bg-muted/70 hover:text-foreground",p,g),e[28]=p,e[29]=g,e[30]=_):_=e[30];let v;e[31]!==u?(v=n.jsx("span",{className:"capitalize",children:u}),e[31]=u,e[32]=v):v=e[32];let x;e[33]!==r?(x=r&&n.jsx(In,{size:"xs"}),e[33]=r,e[34]=x):x=e[34];let b;e[35]!==f||e[36]!==m||e[37]!==_||e[38]!==v||e[39]!==x?(b=n.jsx(st,{asChild:!0,children:n.jsxs("button",{type:"button",onClick:f,disabled:m,className:_,children:[v,x]})}),e[35]=f,e[36]=m,e[37]=_,e[38]=v,e[39]=x,e[40]=b):b=e[40];const y=h??u;let C;e[41]!==y?(C=n.jsx(it,{side:"top",className:"max-w-xs",children:n.jsx("p",{className:"text-xs",children:y})}),e[41]=y,e[42]=C):C=e[42];let k;return e[43]!==b||e[44]!==C?(k=n.jsxs(nt,{delayDuration:400,children:[b,C]}),e[43]=b,e[44]=C,e[45]=k):k=e[45],k}function ax(t){const e=B.c(41),{items:s,open:i,onOpenChange:r,onSelect:o,loadingPrompt:a}=t,[l,c]=S.useState(""),d=!!a;let u;e[0]!==s||e[1]!==l?(u=l.trim()?s.filter(V=>{const j=l.toLowerCase();return V.prompt.name.toLowerCase().includes(j)||(V.prompt.title??"").toLowerCase().includes(j)||(V.prompt.description??"").toLowerCase().includes(j)}):s,e[0]=s,e[1]=l,e[2]=u):u=e[2];const h=u,f=Ps();let m;e[3]!==h.length||e[4]!==l?(m=h.length===0&&n.jsxs("p",{className:"col-span-4 text-sm text-muted-foreground text-center py-8",children:["No prompts match “",l,"”"]}),e[3]=h.length,e[4]=l,e[5]=m):m=e[5];let p;if(e[6]!==h||e[7]!==d||e[8]!==a?.name||e[9]!==r||e[10]!==o){let V;e[12]!==d||e[13]!==a?.name||e[14]!==r||e[15]!==o?(V=j=>n.jsx(Pu,{item:j,variant:"card",onSelect:I=>{r(!1),o(I)},isLoading:a?.name===j.prompt.name,isDisabled:d&&a?.name!==j.prompt.name},j.prompt.name),e[12]=d,e[13]=a?.name,e[14]=r,e[15]=o,e[16]=V):V=e[16],p=h.map(V),e[6]=h,e[7]=d,e[8]=a?.name,e[9]=r,e[10]=o,e[11]=p}else p=e[11];let g;e[17]!==m||e[18]!==p?(g=n.jsx("div",{className:"flex-1 overflow-y-auto [scrollbar-gutter:stable]",children:n.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 gap-3 p-5",children:[m,p]})}),e[17]=m,e[18]=p,e[19]=g):g=e[19];const _=g;let v;e[20]===Symbol.for("react.memo_cache_sentinel")?(v=V=>{V.key==="Escape"&&c("")},e[20]=v):v=e[20];let x;e[21]!==l?(x=n.jsx(Fh,{value:l,onChange:c,placeholder:"Search prompts...",onKeyDown:v}),e[21]=l,e[22]=x):x=e[22];const b=x;if(f){let V;e[23]===Symbol.for("react.memo_cache_sentinel")?(V=n.jsx(lo,{className:"sr-only",children:n.jsx(wi,{children:"All prompts"})}),e[23]=V):V=e[23];let j;e[24]===Symbol.for("react.memo_cache_sentinel")?(j=n.jsx("div",{className:"flex items-center h-12 border-b border-border px-4 shrink-0",children:n.jsx("span",{className:"text-sm font-medium text-foreground",children:"Prompts"})}),e[24]=j):j=e[24];let I;e[25]!==_||e[26]!==b?(I=n.jsxs(Vi,{className:"h-[85vh] flex flex-col p-0 gap-0",children:[V,j,b,_]}),e[25]=_,e[26]=b,e[27]=I):I=e[27];let T;return e[28]!==r||e[29]!==i||e[30]!==I?(T=n.jsx(Bi,{delayDuration:400,children:n.jsx(Ci,{open:i,onOpenChange:r,children:I})}),e[28]=r,e[29]=i,e[30]=I,e[31]=T):T=e[31],T}let y;e[32]===Symbol.for("react.memo_cache_sentinel")?(y=n.jsx(hs,{className:"sr-only",children:n.jsx(ds,{children:"All prompts"})}),e[32]=y):y=e[32];let C;e[33]===Symbol.for("react.memo_cache_sentinel")?(C=n.jsx("div",{className:"flex items-center h-12 border-b border-border px-4 shrink-0",children:n.jsx("span",{className:"text-sm font-medium text-foreground",children:"Prompts"})}),e[33]=C):C=e[33];let k;e[34]!==_||e[35]!==b?(k=n.jsxs(ts,{className:"sm:max-w-[1100px] h-[680px] p-0 gap-0 overflow-hidden flex flex-col",children:[y,C,b,_]}),e[34]=_,e[35]=b,e[36]=k):k=e[36];let w;return e[37]!==r||e[38]!==i||e[39]!==k?(w=n.jsx(Bi,{delayDuration:400,children:n.jsx(ss,{open:i,onOpenChange:r,children:k})}),e[37]=r,e[38]=i,e[39]=k,e[40]=w):w=e[40],w}function lx(t){const e=B.c(29),{items:s,onSelect:i,loadingPrompt:r,className:o}=t,[a,l]=S.useState(!1);if(s.length===0)return null;let c,d,u;if(e[0]!==s||e[1]!==r||e[2]!==i){const v=s.slice(0,Tc);let x;e[6]!==s?(x=s.slice(Tc),e[6]=s,e[7]=x):x=e[7],c=x,d=!!r;let b;e[8]!==d||e[9]!==r?.name||e[10]!==i?(b=y=>n.jsx(Pu,{item:y,onSelect:i,isLoading:r?.name===y.prompt.name,isDisabled:d&&r?.name!==y.prompt.name},y.prompt.name),e[8]=d,e[9]=r?.name,e[10]=i,e[11]=b):b=e[11],u=v.map(b),e[0]=s,e[1]=r,e[2]=i,e[3]=c,e[4]=d,e[5]=u}else c=e[3],d=e[4],u=e[5];const h=u;let f;e[12]!==o?(f=J("w-full flex flex-wrap gap-2 justify-center",o),e[12]=o,e[13]=f):f=e[13];let m;e[14]!==c.length||e[15]!==d?(m=c.length>0&&n.jsxs("button",{type:"button",disabled:d,onClick:()=>l(!0),className:J(Mu,"hover:bg-muted/70 hover:text-foreground",d&&"opacity-50 cursor-not-allowed"),children:["+",c.length," more"]}),e[14]=c.length,e[15]=d,e[16]=m):m=e[16];let p;e[17]!==h||e[18]!==f||e[19]!==m?(p=n.jsxs("div",{className:f,children:[h,m]}),e[17]=h,e[18]=f,e[19]=m,e[20]=p):p=e[20];let g;e[21]!==s||e[22]!==r||e[23]!==a||e[24]!==i?(g=n.jsx(ax,{items:s,open:a,onOpenChange:l,onSelect:i,loadingPrompt:r}),e[21]=s,e[22]=r,e[23]=a,e[24]=i,e[25]=g):g=e[25];let _;return e[26]!==p||e[27]!==g?(_=n.jsxs(Bi,{delayDuration:400,children:[p,g]}),e[26]=p,e[27]=g,e[28]=_):_=e[28],_}function cx(){return null}function dx(t,e){switch(e.type){case"SELECT_PROMPT":return!e.prompt.arguments||e.prompt.arguments.length===0?{stage:"loading",prompt:e.prompt}:{stage:"idle"};case"START_LOADING":return{stage:"loading",prompt:e.prompt,arguments:e.arguments};case"RESET":return{stage:"idle"};default:return t}}function hx(t){const e=B.c(30),{connectionId:s}=t,{sendMessage:i}=Yi(),{tiptapDocRef:r}=ai(),{org:o}=xe();let a;e[0]!==s||e[1]!==o.id?(a={connectionId:s,orgId:o.id},e[0]=s,e[1]=o.id,e[2]=a):a=e[2];const l=Be(a);let c;e[3]!==l?(c={client:l,staleTime:6e4},e[3]=l,e[4]=c):c=e[4];const{data:d}=Uh(c);let u;e[5]!==d?.prompts?(u=d?.prompts??[],e[5]=d?.prompts,e[6]=u):u=e[6];const h=u;let f;e[7]!==h?(f=h.map(ux),e[7]=h,e[8]=f):f=e[8];const m=f;let p;e[9]===Symbol.for("react.memo_cache_sentinel")?(p={stage:"idle"},e[9]=p):p=e[9];const[g,_]=S.useReducer(dx,p),[v,x]=S.useState(null);let b;e[10]!==l||e[11]!==i||e[12]!==r?(b=async(A,E)=>{if(!l){ue.error("MCP client not available"),_({type:"RESET"});return}try{const M=await vl(l,A.name,E);_({type:"RESET"});const L=rx(r.current,{type:"paragraph",content:[Up({id:A.name,name:pl(A.name,ni(A._meta)),metadata:M.messages,char:"/"})]});await i(L)}catch(M){console.error("[ice-breakers] Failed to fetch prompt:",M),ue.error("Failed to load prompt. Please try again."),_({type:"RESET"})}},e[10]=l,e[11]=i,e[12]=r,e[13]=b):b=e[13];const y=b;let C;e[14]!==y?(C=async A=>{if(A.arguments&&A.arguments.length>0){_({type:"SELECT_PROMPT",prompt:A}),x(A);return}_({type:"START_LOADING",prompt:A}),await y(A)},e[14]=y,e[15]=C):C=e[15];const k=C;let w;e[16]!==v||e[17]!==y?(w=async A=>{v&&(_({type:"START_LOADING",prompt:v,arguments:A}),x(null),await y(v,A))},e[16]=v,e[17]=y,e[18]=w):w=e[18];const V=w;if(m.length===0)return null;const j=g.stage==="loading"?g.prompt:null;let I;e[19]!==k||e[20]!==m||e[21]!==j?(I=n.jsx(lx,{items:m,onSelect:k,loadingPrompt:j}),e[19]=k,e[20]=m,e[21]=j,e[22]=I):I=e[22];let T;e[23]===Symbol.for("react.memo_cache_sentinel")?(T=()=>{x(null),_({type:"RESET"})},e[23]=T):T=e[23];let R;e[24]!==v||e[25]!==V?(R=n.jsx(Ol,{prompt:v,setPrompt:T,onSubmit:V}),e[24]=v,e[25]=V,e[26]=R):R=e[26];let N;return e[27]!==I||e[28]!==R?(N=n.jsxs(n.Fragment,{children:[I,R]}),e[27]=I,e[28]=R,e[29]=N):N=e[29],N}function ux(t){return{prompt:t}}function fx(t){const e=B.c(13),{className:s}=t,{selectedVirtualMcp:i}=ai(),{org:r}=xe();let o;e[0]!==r.id?(o=co(r.id),e[0]=r.id,e[1]=o):o=e[1];const a=o.id,l=i?.id??a;let c;e[2]!==s?(c=J("w-full @container",s),e[2]=s,e[3]=c):c=e[3];const d=l??"default";let u;e[4]===Symbol.for("react.memo_cache_sentinel")?(u=n.jsx(cx,{}),e[4]=u):u=e[4];let h;e[5]!==l?(h=n.jsx(hx,{connectionId:l}),e[5]=l,e[6]=h):h=e[6];let f;e[7]!==d||e[8]!==h?(f=n.jsx(As,{fallback:null,children:n.jsx(S.Suspense,{fallback:u,children:h},d)}),e[7]=d,e[8]=h,e[9]=f):f=e[9];let m;return e[10]!==c||e[11]!==f?(m=n.jsx("div",{className:c,children:f}),e[10]=c,e[11]=f,e[12]=m):m=e[12],m}function Lu(t){const e=B.c(21),{current:s,total:i,onPrev:r,onNext:o}=t;if(i<=1)return null;const a=s===0,l=s===0?"opacity-30 cursor-not-allowed":"hover:text-foreground cursor-pointer";let c;e[0]!==l?(c=J("p-0.5 rounded transition-colors",l),e[0]=l,e[1]=c):c=e[1];let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx(Cl,{size:14}),e[2]=d):d=e[2];let u;e[3]!==r||e[4]!==a||e[5]!==c?(u=n.jsx("button",{type:"button",onClick:r,disabled:a,className:c,"aria-label":"Previous question",children:d}),e[3]=r,e[4]=a,e[5]=c,e[6]=u):u=e[6];const h=s+1;let f;e[7]!==h||e[8]!==i?(f=n.jsxs("span",{className:"tabular-nums text-xs",children:[h," of ",i]}),e[7]=h,e[8]=i,e[9]=f):f=e[9];const m=s===i-1,p=s===i-1?"opacity-30 cursor-not-allowed":"hover:text-foreground cursor-pointer";let g;e[10]!==p?(g=J("p-0.5 rounded transition-colors",p),e[10]=p,e[11]=g):g=e[11];let _;e[12]===Symbol.for("react.memo_cache_sentinel")?(_=n.jsx(ho,{size:14}),e[12]=_):_=e[12];let v;e[13]!==o||e[14]!==g||e[15]!==m?(v=n.jsx("button",{type:"button",onClick:o,disabled:m,className:g,"aria-label":"Next question",children:_}),e[13]=o,e[14]=g,e[15]=m,e[16]=v):v=e[16];let x;return e[17]!==v||e[18]!==u||e[19]!==f?(x=n.jsxs("div",{className:"flex items-center gap-1 text-sm text-muted-foreground",children:[u,f,v]}),e[17]=v,e[18]=u,e[19]=f,e[20]=x):x=e[20],x}function Hr(t){const e=B.c(18),{title:s,children:i,footerLeft:r,footerRight:o,className:a}=t,l=a??"border-border";let c;e[0]!==l?(c=J("flex flex-col rounded-xl bg-background border shadow-md w-[calc(100%-16px)] max-w-[584px] mx-auto mb-[-16px]",l),e[0]=l,e[1]=c):c=e[1];let d;e[2]!==s?(d=n.jsx("div",{className:"flex items-center gap-2 p-4",children:n.jsx("p",{className:"flex-1 text-base font-medium text-foreground min-w-0",children:s})}),e[2]=s,e[3]=d):d=e[3];let u;e[4]!==i?(u=n.jsx("div",{className:"overflow-clip pb-4",children:i}),e[4]=i,e[5]=u):u=e[5];let h;e[6]!==r?(h=n.jsx("div",{children:r}),e[6]=r,e[7]=h):h=e[7];let f;e[8]!==o?(f=n.jsx("div",{className:"flex items-center gap-2",children:o}),e[8]=o,e[9]=f):f=e[9];let m;e[10]!==h||e[11]!==f?(m=n.jsx("div",{className:"border-t border-border px-3 py-3 pb-6",children:n.jsxs("div",{className:"flex items-center justify-between",children:[h,f]})}),e[10]=h,e[11]=f,e[12]=m):m=e[12];let p;return e[13]!==c||e[14]!==d||e[15]!==u||e[16]!==m?(p=n.jsxs("div",{className:c,children:[d,u,m]}),e[13]=c,e[14]=d,e[15]=u,e[16]=m,e[17]=p):p=e[17],p}const mx="User denied this tool call, give other alternatives.",px=[{value:"readonly",label:"Ask before edit"},{value:"auto",label:"Auto approve"}];function gx(t){const e=B.c(9),{onYolo:s}=t,[i,r]=yi();let o;e[0]!==s||e[1]!==i||e[2]!==r?(o=u=>{const h=u;r({...i,toolApprovalLevel:h}),h==="auto"&&s()},e[0]=s,e[1]=i,e[2]=r,e[3]=o):o=e[3];const a=o;let l;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=n.jsx(ti,{size:"xs",className:"text-xs text-muted-foreground border-border/60 bg-transparent hover:bg-accent/60 h-7 gap-1",onClick:xx,children:n.jsx(si,{})}),e[4]=l):l=e[4];let c;e[5]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx(Zs,{children:px.map(_x)}),e[5]=c):c=e[5];let d;return e[6]!==a||e[7]!==i.toolApprovalLevel?(d=n.jsxs(ei,{value:i.toolApprovalLevel,onValueChange:a,children:[l,c]}),e[6]=a,e[7]=i.toolApprovalLevel,e[8]=d):d=e[8],d}function _x(t){return n.jsx(Ht,{value:t.value,children:t.label},t.value)}function xx(t){return t.stopPropagation()}function vx(t){const e=B.c(5),{input:s}=t;if(s==null){let o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx("div",{className:"px-4 text-xs text-muted-foreground",children:"No input"}),e[0]=o):o=e[0],o}let i;try{let o;e[1]!==s?(o=JSON.stringify(s,null,2),e[1]=s,e[2]=o):o=e[2],i=o}catch{i=String(s)}let r;return e[3]!==i?(r=n.jsx("div",{className:"px-4",children:n.jsx("pre",{className:"text-xs font-mono text-muted-foreground/70 whitespace-pre-wrap wrap-break-word max-h-32 overflow-y-auto rounded-md bg-muted/30 px-3 py-2",children:i})}),e[3]=i,e[4]=r):r=e[4],r}function bx(t){const e=B.c(42),{approvals:s,onRespond:i}=t,[r,o]=S.useState(0),a=Math.min(r,s.length-1),l=s[a];if(!l)return null;let c;e[0]!==l.approvalId||e[1]!==i?(c=()=>{i(l.approvalId,!1,mx)},e[0]=l.approvalId,e[1]=i,e[2]=c):c=e[2];const d=c;let u;e[3]!==l.approvalId||e[4]!==i?(u=()=>{i(l.approvalId,!0)},e[3]=l.approvalId,e[4]=i,e[5]=u):u=e[5];const h=u;let f;e[6]!==s||e[7]!==i?(f=()=>{for(const N of s)i(N.approvalId,!0)},e[6]=s,e[7]=i,e[8]=f):f=e[8];const m=f;let p;e[9]!==a?(p=()=>{a>0&&o(a-1)},e[9]=a,e[10]=p):p=e[10];const g=p;let _;e[11]!==s.length||e[12]!==a?(_=()=>{a<s.length-1&&o(a+1)},e[11]=s.length,e[12]=a,e[13]=_):_=e[13];const v=_;let x;e[14]!==m?(x=n.jsx(gx,{onYolo:m}),e[14]=m,e[15]=x):x=e[15];let b;e[16]!==s.length||e[17]!==v||e[18]!==g||e[19]!==a?(b=n.jsx(Lu,{current:a,total:s.length,onPrev:g,onNext:v}),e[16]=s.length,e[17]=v,e[18]=g,e[19]=a,e[20]=b):b=e[20];let y;e[21]!==x||e[22]!==b?(y=n.jsxs("div",{className:"flex items-center gap-2",children:[x,b]}),e[21]=x,e[22]=b,e[23]=y):y=e[23];const C=y;let k;e[24]!==d?(k=n.jsx(ae,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2.5 text-xs text-muted-foreground [@media(hover:hover)]:hover:text-foreground active:scale-[0.97] transition-transform",onClick:d,children:"Deny"}),e[24]=d,e[25]=k):k=e[25];let w;e[26]!==s.length||e[27]!==m?(w=s.length>1&&n.jsx(ae,{type:"button",variant:"outline",size:"sm",className:"h-7 px-2.5 text-xs active:scale-[0.97] transition-transform",onClick:m,children:"Accept All"}),e[26]=s.length,e[27]=m,e[28]=w):w=e[28];let V;e[29]!==h?(V=n.jsx(ae,{type:"button",size:"sm",className:"h-7 px-2.5 text-xs active:scale-[0.97] transition-transform",onClick:h,children:"Accept"}),e[29]=h,e[30]=V):V=e[30];let j;e[31]!==w||e[32]!==V||e[33]!==k?(j=n.jsxs(n.Fragment,{children:[k,w,V]}),e[31]=w,e[32]=V,e[33]=k,e[34]=j):j=e[34];const I=j;let T;e[35]!==l.input?(T=n.jsx(vx,{input:l.input}),e[35]=l.input,e[36]=T):T=e[36];let R;return e[37]!==l.friendlyName||e[38]!==C||e[39]!==I||e[40]!==T?(R=n.jsx(Hr,{title:l.friendlyName,footerLeft:C,footerRight:I,children:T}),e[37]=l.friendlyName,e[38]=C,e[39]=I,e[40]=T,e[41]=R):R=e[41],R}function yx(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsxs("div",{className:"flex items-center gap-2 p-4 border border-dashed rounded-lg bg-accent/50 w-[calc(100%-16px)] max-w-[584px] mx-auto mb-2",children:[n.jsx(wg,{className:"size-5 text-muted-foreground shimmer"}),n.jsx("span",{className:"text-sm text-muted-foreground shimmer",children:"Preparing approval request..."})]}),t[0]=e):e=t[0],e}function Sx(t){const e=B.c(4),{approvals:s,isStreaming:i,onRespond:r}=t;if(i&&s.length===0){let a;return e[0]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx(yx,{}),e[0]=a):a=e[0],a}if(s.length===0)return null;let o;return e[1]!==s||e[2]!==r?(o=n.jsx(bx,{approvals:s,onRespond:r}),e[1]=s,e[2]=r,e[3]=o):o=e[3],o}function wx(t){const e=[];for(const s of t)if("state"in s&&s.state==="approval-requested"&&"approval"in s&&s.approval?.id&&"toolCallId"in s&&s.toolCallId){const i="toolName"in s&&typeof s.toolName=="string"?s.toolName:s.type.startsWith("tool-")?s.type.replace("tool-",""):"Tool";e.push({approvalId:s.approval.id,toolCallId:s.toolCallId,toolName:i,friendlyName:Hp(Wp(i)),input:s.input})}return e}function Vx(t){const e=B.c(15),{plan:s,onApprove:i,onDismiss:r}=t;let o;e[0]!==i||e[1]!==s.plan?(o=()=>{i(s.plan)},e[0]=i,e[1]=s.plan,e[2]=o):o=e[2];const a=o;let l;e[3]!==r?(l=n.jsx(ae,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2.5 text-xs text-muted-foreground [@media(hover:hover)]:hover:text-foreground active:scale-[0.97] transition-transform",onClick:r,children:"Keep iterating"}),e[3]=r,e[4]=l):l=e[4];let c;e[5]!==a?(c=n.jsx(ae,{type:"button",size:"sm",className:"h-7 px-2.5 text-xs bg-purple-600 hover:bg-purple-700 text-white active:scale-[0.97] transition-transform",onClick:a,children:"Let's go"}),e[5]=a,e[6]=c):c=e[6];let d;e[7]!==l||e[8]!==c?(d=n.jsxs(n.Fragment,{children:[l,c]}),e[7]=l,e[8]=c,e[9]=d):d=e[9];const u=d;let h;e[10]!==s.plan?(h=n.jsx("div",{className:"px-4 max-h-64 overflow-y-auto",children:n.jsx("div",{className:"prose prose-sm max-w-none text-sm",children:n.jsx(Kp,{id:"plan-preview",part:{type:"text",text:s.plan}})})}),e[10]=s.plan,e[11]=h):h=e[11];let f;return e[12]!==u||e[13]!==h?(f=n.jsx(Hr,{title:"Implementation Plan",footerRight:u,className:"border-dashed border-purple-500",children:h}),e[12]=u,e[13]=h,e[14]=f):f=e[14],f}function Cx(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsxs("div",{className:"flex items-center gap-2 p-4 border border-dashed border-purple-500/30 rounded-lg bg-purple-500/5 w-[calc(100%-16px)] max-w-[584px] mx-auto mb-2",children:[n.jsx(Jt,{className:"size-5 text-purple-500 shimmer"}),n.jsx("span",{className:"text-sm text-muted-foreground shimmer",children:"Preparing plan..."})]}),t[0]=e):e=t[0],e}function kx(t){const e=B.c(7),{plans:s,isStreaming:i,onApprove:r,onDismiss:o}=t;if(i&&s.length===0){let d;return e[0]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx(Cx,{}),e[0]=d):d=e[0],d}let a;e[1]!==s?(a=s.at(-1),e[1]=s,e[2]=a):a=e[2];const l=a;if(!l)return null;let c;return e[3]!==l||e[4]!==r||e[5]!==o?(c=n.jsx(Vx,{plan:l,onApprove:r,onDismiss:o}),e[3]=l,e[4]=r,e[5]=o,e[6]=c):c=e[6],c}function jx(t){const e=[];for(const s of t)if("type"in s&&s.type==="tool-propose_plan"&&"state"in s&&s.state==="input-available"&&"toolCallId"in s&&"input"in s){const i=s.input;e.push({toolCallId:s.toolCallId,plan:i.plan,state:s.state})}return e}const Dc=Ns({response:Et().min(1,"Response is required")}),Nx=Ns({response:Et().min(1,"Please select or enter an option")}),Ax=Ns({response:Zm(["yes","no"])});function Ex(t){switch(t.type){case"text":return Dc;case"choice":return Nx;case"confirm":return Ax;default:return Dc}}function Ix(t){const e={};for(const s of t)e[s.toolCallId]=Ex(s.input);return Ns(e)}function Rx(t){const e=B.c(6),{control:s,name:i,placeholder:r}=t;let o;e[0]!==r?(o=l=>{const{field:c}=l;return n.jsxs(Rt,{children:[n.jsx(Tt,{children:n.jsx("div",{className:"px-2",children:n.jsxs("div",{className:"flex items-center gap-3 px-2 py-3 rounded-lg bg-accent/50",children:[n.jsx("span",{className:"flex items-center justify-center size-6 rounded-md bg-muted shrink-0",children:n.jsx(Yh,{size:16,className:"text-muted-foreground"})}),n.jsx("input",{...c,type:"text",placeholder:r||"Type your response...",autoFocus:!0,"aria-label":"Text response input",className:"flex-1 text-sm bg-transparent outline-none placeholder:text-foreground/25 text-foreground min-w-0"})]})})}),n.jsx(Dt,{})]})},e[0]=r,e[1]=o):o=e[1];let a;return e[2]!==s||e[3]!==i||e[4]!==o?(a=n.jsx(It,{control:s,name:i,render:o}),e[2]=s,e[3]=i,e[4]=o,e[5]=a):a=e[5],a}function Ou(t,e){const s=B.c(4);let i,r;s[0]!==t||s[1]!==e?(i=()=>{const o=a=>{const l=a.target.tagName;if(l==="INPUT"||l==="TEXTAREA"||a.metaKey||a.ctrlKey||a.altKey)return;const c=Number.parseInt(a.key,10);c>=1&&c<=t&&(a.preventDefault(),e(c-1))};return document.addEventListener("keydown",o),()=>document.removeEventListener("keydown",o)},r=[t,e],s[0]=t,s[1]=e,s[2]=i,s[3]=r):(i=s[2],r=s[3]),S.useEffect(i,r)}function Tx(t){const e=B.c(9),{control:s,name:i,options:r}=t,[o,a]=S.useState(!1),l=S.useRef(null),c=S.useRef(null);let d;if(e[0]!==r?(d=f=>{c.current?.onChange(r[f]??""),a(!1)},e[0]=r,e[1]=d):d=e[1],Ou(r.length,d),r.length===0)return null;let u;e[2]!==o||e[3]!==r?(u=f=>{const{field:m}=f;c.current=m;const p=o||!!m.value&&!r.includes(m.value);return n.jsxs(Rt,{children:[n.jsx(Tt,{children:n.jsxs("div",{className:"flex flex-col px-2",role:"group","aria-label":"Choice options",children:[r.map((g,_)=>{const v=m.value===g;return n.jsxs("button",{type:"button",onClick:()=>{m.onChange(g??""),a(!1)},className:J("flex items-center gap-3 px-2 py-3 rounded-lg text-left transition-colors w-full",v&&"bg-accent/50",!v&&"hover:bg-accent/30"),"aria-label":`Select ${g}`,children:[n.jsx("span",{className:J("flex items-center justify-center size-6 rounded-md text-sm shrink-0",v?"bg-chart-1 text-white":"bg-muted text-foreground"),children:_+1}),n.jsx("span",{className:"text-sm text-foreground truncate",children:g})]},`${_}-${g}`)}),n.jsxs("div",{className:J("flex items-center gap-3 px-2 py-3 rounded-lg transition-colors w-full cursor-text",p&&"bg-accent/50",!p&&"hover:bg-accent/30"),onClick:()=>{a(!0),r.includes(m.value)&&m.onChange(""),setTimeout(()=>l.current?.focus(),0)},children:[n.jsx("span",{className:"flex items-center justify-center size-6 rounded-md bg-muted shrink-0",children:n.jsx(Yh,{size:16,className:"text-muted-foreground"})}),p?n.jsx("input",{ref:l,type:"text",value:m.value,onChange:g=>m.onChange(g.target.value),placeholder:"Something else...",autoFocus:!0,"aria-label":"Custom choice input",className:"flex-1 text-sm bg-transparent outline-none placeholder:text-foreground/25 text-foreground min-w-0"}):n.jsx("span",{className:"text-sm text-foreground/25",children:"Something else..."})]})]})}),n.jsx(Dt,{})]})},e[2]=o,e[3]=r,e[4]=u):u=e[4];let h;return e[5]!==s||e[6]!==i||e[7]!==u?(h=n.jsx(It,{control:s,name:i,render:u}),e[5]=s,e[6]=i,e[7]=u,e[8]=h):h=e[8],h}function Dx(t){const e=B.c(6),{control:s,name:i}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=["yes","no"],e[0]=r):r=e[0];const o=r,a=S.useRef(null);let l;e[1]===Symbol.for("react.memo_cache_sentinel")?(l=u=>{a.current?.onChange(o[u]??"")},e[1]=l):l=e[1],Ou(o.length,l);let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=u=>{const{field:h}=u;return a.current=h,n.jsxs(Rt,{children:[n.jsx(Tt,{children:n.jsx("div",{className:"flex gap-2 px-2",role:"group","aria-label":"Confirmation options",children:o.map(f=>{const m=h.value===f;return n.jsxs("button",{type:"button",onClick:()=>h.onChange(f),className:J("flex items-center gap-3 px-4 py-3 rounded-lg text-left transition-colors flex-1",m&&"bg-accent/50",!m&&"hover:bg-accent/30"),"aria-label":`Confirm ${f}`,children:[n.jsx("span",{className:J("flex items-center justify-center size-6 rounded-md text-sm shrink-0",m?"bg-chart-1 text-white":"bg-muted text-foreground"),children:f==="yes"?1:2}),n.jsx("span",{className:"text-sm text-foreground capitalize",children:f})]},f)})})}),n.jsx(Dt,{})]})},e[2]=c):c=e[2];let d;return e[3]!==s||e[4]!==i?(d=n.jsx(It,{control:s,name:i,render:c}),e[3]=s,e[4]=i,e[5]=d):d=e[5],d}function Mc(t){const e=B.c(13),{input:s,control:i,name:r}=t;switch(s.type){case"text":{let o;return e[0]!==i||e[1]!==s.default||e[2]!==r?(o=n.jsx(Rx,{control:i,name:r,placeholder:s.default}),e[0]=i,e[1]=s.default,e[2]=r,e[3]=o):o=e[3],o}case"choice":{let o;e[4]!==s.options?(o=s.options?.filter(Boolean)??[],e[4]=s.options,e[5]=o):o=e[5];const a=o;let l;return e[6]!==i||e[7]!==r||e[8]!==a?(l=n.jsx(Tx,{control:i,name:r,options:a}),e[6]=i,e[7]=r,e[8]=a,e[9]=l):l=e[9],l}case"confirm":{let o;return e[10]!==i||e[11]!==r?(o=n.jsx(Dx,{control:i,name:r}),e[10]=i,e[11]=r,e[12]=o):o=e[12],o}default:return null}}function Mx({parts:t,onSubmit:e}){const[s,i]=S.useState(t[0]?.toolCallId??""),r=Ix(t.map(x=>({toolCallId:x.toolCallId,input:x.input}))),o=Gi({resolver:Un(r),defaultValues:Object.fromEntries(t.map(x=>[x.toolCallId,{response:""}]))}),a=o.watch(),l=t.findIndex(x=>x.toolCallId===s),c=!!a[s]?.response,d=t.every(x=>!!a[x.toolCallId]?.response),u=x=>{for(const b of t){const y=x[b.toolCallId]?.response;y&&e(b,y)}},h=x=>t.find(b=>!x[b.toolCallId]?.response&&b.toolCallId!==s)??null,f=()=>{const x=o.getValues();if(t.every(y=>!!x[y.toolCallId]?.response))o.handleSubmit(u)();else{const y=h(x);y&&i(y.toolCallId)}},m=()=>{o.setValue(`${s}.response`,"user has skip this question"),f()},p=()=>{if(l>0){const x=t[l-1];x&&i(x.toolCallId)}},g=()=>{if(l<t.length-1){const x=t[l+1];x&&i(x.toolCallId)}},_=n.jsxs(n.Fragment,{children:[n.jsx(ae,{type:"button",variant:"outline",size:"sm",onClick:m,className:"h-7",children:"Skip"}),n.jsx(ae,{type:"button",size:"sm",disabled:!c,onClick:f,className:J("h-7",c?"":"opacity-50"),children:d?"Submit":"Next"})]}),v=n.jsx(Lu,{current:l,total:t.length,onPrev:p,onNext:g});if(t.length===1){const x=t[0];return x?.input?n.jsx($i,{...o,children:n.jsx("form",{onSubmit:o.handleSubmit(u),autoComplete:"off",children:n.jsx(Hr,{title:x.input?.prompt??"Question",footerRight:_,children:n.jsx(Mc,{input:x.input,control:o.control,name:`${x.toolCallId}.response`})})})}):null}return n.jsx($i,{...o,children:n.jsx("form",{onSubmit:o.handleSubmit(u),autoComplete:"off",children:n.jsx(Hh,{value:s,onValueChange:i,children:t.map(x=>n.jsx(Cr,{value:x.toolCallId,className:"mt-0",children:n.jsx(Hr,{title:x.input?.prompt??"Question",footerLeft:v,footerRight:_,children:n.jsx(Mc,{input:x.input,control:o.control,name:`${x.toolCallId}.response`})})},x.toolCallId))})})})}function Px(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsxs("div",{className:"flex items-center gap-2 p-4 border border-dashed rounded-lg bg-accent/50 w-[calc(100%-16px)] max-w-[584px] mx-auto mb-2",children:[n.jsx(Kg,{className:"size-5 text-muted-foreground shimmer"}),n.jsx("span",{className:"text-sm text-muted-foreground shimmer",children:"Preparing question..."})]}),t[0]=e):e=t[0],e}function Bu(t){const e=B.c(6),{userAskParts:s,isStreaming:i,onSubmit:r}=t;let o;e[0]!==s?(o=s.filter(Lx),e[0]=s,e[1]=o):o=e[1];const a=o;if(i){let c;return e[2]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx(Px,{}),e[2]=c):c=e[2],c}if(a.length===0)return null;let l;return e[3]!==r||e[4]!==a?(l=n.jsx(Mx,{parts:a,onSubmit:r}),e[3]=r,e[4]=a,e[5]=l):l=e[5],l}function Lx(t){return t.state==="input-available"}const Pc=new Map;function go(){const{org:t}=xe(),e=Be({connectionId:Pt,orgId:t.id}),s=jl(),i=s.find(_=>_.providerId==="deco"),{data:r,isLoading:o,refetch:a,isFetching:l}=Ki({queryKey:ct.aiProviderCredits(t.id,"deco"),enabled:!!i,staleTime:6e4,queryFn:async()=>{const _=await e.callTool({name:"AI_PROVIDER_CREDITS",arguments:{providerId:"deco"}});return _?.isError?null:_.structuredContent??null}}),c=r?.balanceCents??null,d=c!=null?c/100:null,u=S.useRef(new Map);if(c!=null){const _=Pc.get(t.id);u.current.get(t.id)&&_!=null&&c>_&&ne("credits_topped_up_detected",{organization_id:t.id,delta_cents:c-_,previous_balance_cents:_,new_balance_cents:c}),Pc.set(t.id,c),u.current.set(t.id,!0)}const h=!!i,f=c!=null&&c>0,m=c!=null&&c===0,p=c!=null&&c===200,g=s.length>0&&s.every(_=>_.providerId==="deco");return{hasDecoKey:h,decoKeyId:i?.id??null,balanceCents:c,balanceDollars:d,hasCredits:f,isZeroBalance:m,isInitialFreeCredit:p,hasOnlyDecoProvider:g,isLoading:o,isFetching:l,refetch:a}}function Ox(t){return t?t.message.startsWith("[CREDITS]"):!1}const Bx={usd:[{dollars:10,label:"Starter"},{dollars:20,label:"Popular"},{dollars:100,label:"Best value"}],brl:[{dollars:50,label:"Starter"},{dollars:100,label:"Popular"},{dollars:500,label:"Best value"}]},$x=["Access to 100+ AI models","Unified API, no separate keys needed","Pay only for what you use"];function $u(t){const e=B.c(43),{onDismiss:s}=t,{org:i}=xe(),r=Ge(),{decoKeyId:o}=go();let a;e[0]!==i.id?(a={connectionId:Pt,orgId:i.id},e[0]=i.id,e[1]=a):a=e[1];const l=Be(a),[c,d]=S.useState(""),[u,h]=S.useState(!1),[f,m]=S.useState("usd"),p=f==="brl"?"R$":"$";let g,_;e[2]!==i.id?(g=()=>{ne("credits_exhausted_shown",{organization_id:i.id})},_=[i.id],e[2]=i.id,e[3]=g,e[4]=_):(g=e[3],_=e[4]),S.useEffect(g,_);let v;e[5]!==l||e[6]!==f?(v=async D=>{const P=await l.callTool({name:"AI_PROVIDER_TOPUP_URL",arguments:{providerId:"deco",amountCents:D,currency:f}});if(P?.isError)throw new Error(P.content?.[0]?.text??"Failed to get top-up URL");return P.structuredContent?.url},e[5]=l,e[6]=f,e[7]=v):v=e[7];let x;e[8]!==s?(x=D=>{D&&window.open(D,"_blank","noopener,noreferrer"),s?.()},e[8]=s,e[9]=x):x=e[9];let b;e[10]!==v||e[11]!==x?(b={mutationFn:v,onSuccess:x,onError:Ux},e[10]=v,e[11]=x,e[12]=b):b=e[12];const{mutate:y,isPending:C}=qi(b),k=parseFloat(c),w=!isNaN(k)&&k>=1;let V;e[13]!==s?(V=D=>!D&&s?.(),e[13]=s,e[14]=V):V=e[14];let j;e[15]===Symbol.for("react.memo_cache_sentinel")?(j=["radial-gradient(ellipse 40% 200% at -5% 100%, rgba(165,149,255,0.5) 0%, transparent 100%)","radial-gradient(ellipse 40% 200% at 105% -10%, rgba(208,236,26,0.45) 0%, transparent 100%)"],e[15]=j):j=e[15];let I;e[16]===Symbol.for("react.memo_cache_sentinel")?(I=n.jsx("div",{className:"absolute inset-x-0 top-0 h-36 pointer-events-none",style:{backgroundImage:j.join(", "),maskImage:"linear-gradient(to bottom, black 0%, transparent 100%)",WebkitMaskImage:"linear-gradient(to bottom, black 0%, transparent 100%)"}}),e[16]=I):I=e[16];let T;e[17]===Symbol.for("react.memo_cache_sentinel")?(T=n.jsxs("div",{className:"relative px-8 pt-8 pb-2 overflow-hidden",children:[I,n.jsxs(hs,{className:"relative gap-4",children:[n.jsx("img",{src:"/logos/deco%20logo.svg",alt:"Deco AI Gateway",className:"size-9 rounded-lg object-contain dark:bg-white dark:p-0.5"}),n.jsxs("div",{children:[n.jsx(ds,{className:"text-xl font-semibold tracking-tight",children:"Top up to keep building"}),n.jsx(ao,{className:"mt-1.5 text-sm leading-relaxed",children:"Your credits are used up. Add more to continue using AI across all your agents."})]})]})]}),e[17]=T):T=e[17];let R;e[18]!==f||e[19]!==p||e[20]!==c||e[21]!==k||e[22]!==o||e[23]!==w||e[24]!==C||e[25]!==u||e[26]!==y?(R=o&&n.jsxs("div",{className:"px-8 pt-5 pb-6",children:[n.jsx("div",{className:"mb-4",children:n.jsxs(du,{type:"single",variant:"outline",size:"sm",value:f,onValueChange:D=>{D&&m(D)},children:[n.jsx(zr,{value:"usd",className:"h-8 px-3 text-xs",children:"USD"}),n.jsx(zr,{value:"brl",className:"h-8 px-3 text-xs",children:"BRL"})]})}),n.jsxs("div",{className:"rounded-xl border border-border p-5",children:[n.jsx("div",{className:"grid grid-cols-3 gap-2.5",children:Bx[f].map(D=>{const{dollars:P,label:O}=D;return n.jsxs("button",{type:"button",disabled:C,onClick:()=>{ne("credits_topup_clicked",{amount_cents:P*100,currency:f,tier_label:O,source:"exhausted_banner"}),y(P*100)},className:J("relative flex flex-col items-center gap-1 py-5 rounded-xl border transition-all duration-150 cursor-pointer","disabled:opacity-50 disabled:cursor-wait","border-border hover:border-foreground/20 hover:bg-muted/30"),children:[n.jsxs("span",{className:"text-2xl font-semibold tabular-nums text-foreground",children:[p,P]}),n.jsx("span",{className:"text-xs text-muted-foreground",children:O})]},P)})}),u?n.jsxs("div",{className:"flex gap-2 mt-3",children:[n.jsxs("div",{className:"relative flex-1",children:[n.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-sm text-muted-foreground select-none",children:p}),n.jsx(gt,{type:"number",min:"1",step:"1",placeholder:"50",value:c,onChange:D=>d(D.target.value),className:"h-10 text-sm pl-7",autoFocus:!0})]}),n.jsx(ae,{className:"h-10",disabled:!w||C,onClick:()=>{ne("credits_topup_clicked",{amount_cents:Math.round(k*100),currency:f,tier_label:"custom",source:"exhausted_banner"}),y(Math.round(k*100))},children:C?"Opening...":"Add"})]}):n.jsx("button",{type:"button",className:"w-full mt-3 text-xs text-muted-foreground hover:text-foreground transition-colors py-1",onClick:()=>h(!0),children:"Enter custom amount"})]}),n.jsx("div",{className:"mt-5 rounded-xl bg-muted/25 border border-border/50 p-4 space-y-3",children:$x.map(zx)})]}),e[18]=f,e[19]=p,e[20]=c,e[21]=k,e[22]=o,e[23]=w,e[24]=C,e[25]=u,e[26]=y,e[27]=R):R=e[27];let N;e[28]!==s?(N=n.jsx(ae,{variant:"ghost",size:"sm",onClick:s,children:"Dismiss"}),e[28]=s,e[29]=N):N=e[29];let A;e[30]!==r||e[31]!==s||e[32]!==i.slug?(A=n.jsx("button",{type:"button",className:"text-xs text-muted-foreground hover:text-foreground transition-colors",onClick:()=>{r({to:"/$org/settings/ai-providers",params:{org:i.slug}}),s?.()},children:"Manage providers"}),e[30]=r,e[31]=s,e[32]=i.slug,e[33]=A):A=e[33];let E;e[34]!==N||e[35]!==A?(E=n.jsxs("div",{className:"px-8 py-4 border-t border-border bg-muted/30 flex items-center justify-between",children:[N,A]}),e[34]=N,e[35]=A,e[36]=E):E=e[36];let M;e[37]!==R||e[38]!==E?(M=n.jsxs(ts,{className:"sm:max-w-[520px] gap-0 p-0 overflow-hidden",onOpenAutoFocus:Fx,children:[T,R,E]}),e[37]=R,e[38]=E,e[39]=M):M=e[39];let L;return e[40]!==M||e[41]!==V?(L=n.jsx(ss,{open:!0,onOpenChange:V,children:M}),e[40]=M,e[41]=V,e[42]=L):L=e[42],L}function zx(t){return n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("div",{className:"flex items-center justify-center size-5 rounded-full bg-[hsl(var(--chart-1))]/15 shrink-0",children:n.jsx(Jt,{size:12,className:"text-[hsl(var(--chart-1))]"})}),n.jsx("span",{className:"text-sm text-foreground/80",children:t})]},t)}function Fx(t){return t.preventDefault()}function Ux(t){ue.error(`Top-up failed: ${t.message}`)}const Hx={length:"Response reached the model's output limit. Different models have different limits. Try switching models or asking it to continue.","content-filter":"Response was filtered due to content policy.","tool-calls":"Response paused after tool execution to prevent infinite loops and save costs. Click continue to keep working."};function Wr(t){const e=B.c(32),{variant:s,onDismiss:i}=t,r=s==="error",o=r?"Error occurred":"Response incomplete",a=r?t.error.message:Hx[t.finishReason]??`Response stopped unexpectedly: ${t.finishReason}`,l=r?"border-destructive/30 bg-destructive/5":"border-amber-500/30 bg-amber-500/5",c=r?"text-destructive":"text-amber-600 dark:text-amber-500",d=r?oi:ul;let u;e[0]!==l?(u=J("flex items-start gap-2 px-3 py-2.5 rounded-lg border border-dashed text-sm w-full mb-2 shadow",l),e[0]=l,e[1]=u):u=e[1];let h;e[2]!==c?(h=J("mt-0.5 shrink-0",c),e[2]=c,e[3]=h):h=e[3];let f;e[4]!==d?(f=n.jsx(d,{size:16}),e[4]=d,e[5]=f):f=e[5];let m;e[6]!==h||e[7]!==f?(m=n.jsx("div",{className:h,children:f}),e[6]=h,e[7]=f,e[8]=m):m=e[8];let p;e[9]!==c?(p=J("text-xs mb-1 font-medium",c),e[9]=c,e[10]=p):p=e[10];let g;e[11]!==p||e[12]!==o?(g=n.jsx("div",{className:p,children:o}),e[11]=p,e[12]=o,e[13]=g):g=e[13];let _;e[14]!==a?(_=n.jsx("div",{className:"text-xs line-clamp-2 text-muted-foreground mb-2",children:a}),e[14]=a,e[15]=_):_=e[15];let v;e[16]!==r||e[17]!==t.onContinue||e[18]!==t.onFixInChat?(v=n.jsx("div",{className:"flex gap-2",children:r?n.jsxs(n.Fragment,{children:[n.jsx(ae,{size:"sm",variant:"outline",onClick:t.onFixInChat,className:"h-7 text-xs",children:"Fix in chat"}),n.jsx(ae,{size:"sm",variant:"outline",disabled:!0,className:"h-7 text-xs",children:"Report"})]}):n.jsx(ae,{size:"sm",variant:"outline",onClick:t.onContinue,className:"h-7 text-xs",children:"Continue"})}),e[16]=r,e[17]=t.onContinue,e[18]=t.onFixInChat,e[19]=v):v=e[19];let x;e[20]!==g||e[21]!==_||e[22]!==v?(x=n.jsxs("div",{className:"flex-1 min-w-0",children:[g,_,v]}),e[20]=g,e[21]=_,e[22]=v,e[23]=x):x=e[23];let b;e[24]===Symbol.for("react.memo_cache_sentinel")?(b=n.jsx(Js,{size:14}),e[24]=b):b=e[24];let y;e[25]!==i?(y=n.jsx("button",{type:"button",onClick:i,className:"text-muted-foreground hover:text-foreground transition-colors shrink-0",title:"Dismiss",children:b}),e[25]=i,e[26]=y):y=e[26];let C;return e[27]!==u||e[28]!==y||e[29]!==m||e[30]!==x?(C=n.jsx("div",{className:"px-0.5",children:n.jsxs("div",{className:u,children:[m,x,y]})}),e[27]=u,e[28]=y,e[29]=m,e[30]=x,e[31]=C):C=e[31],C}function _o(){const t=B.c(41),{error:e,clearError:s,finishReason:i,clearFinishReason:r,messages:o,isStreaming:a,isWaitingForApprovals:l,addToolOutput:c,addToolApprovalResponse:d,sendMessage:u}=Yi(),[h,f]=yi(),{virtualMcpId:m,createTaskWithMessage:p}=es();let g,_,v,x;if(t[0]!==o){const E=o.at(-1);x=E?.role==="assistant"?E.parts.filter(qx):null,g=x?.filter(Kx)?.length,_=E?.role==="assistant"?jx(E.parts):[],v=E?.role==="assistant"?wx(E.parts):[],t[0]=o,t[1]=g,t[2]=_,t[3]=v,t[4]=x}else g=t[1],_=t[2],v=t[3],x=t[4];const b=v;let y;t[5]!==e||t[6]!==u?(y=()=>{if(e){const M={type:"doc",content:[{type:"paragraph",content:[{type:"text",text:`I encountered this error: ${e.message}. Can you help me fix it?`}]}]};u(M)}},t[5]=e,t[6]=u,t[7]=y):y=t[7];const C=y;let k;t[8]!==u?(k=()=>{u({type:"doc",content:[{type:"paragraph",content:[{type:"text",text:"Please continue."}]}]})},t[8]=u,t[9]=k):k=t[9];const w=k;let V;t[10]!==c?(V=(E,M)=>{c({tool:"user_ask",toolCallId:E.toolCallId,output:{response:M}})},t[10]=c,t[11]=V):V=t[11];const j=V;let I;t[12]!==p||t[13]!==h||t[14]!==f||t[15]!==m?(I=E=>{f({...h,toolApprovalLevel:"auto"}),p({virtualMcpId:m,message:{parts:[{type:"text",text:`Implement this plan:
|
|
3
3
|
|
|
4
4
|
${E}`}]}})},t[12]=p,t[13]=h,t[14]=f,t[15]=m,t[16]=I):I=t[16];const T=I,R=Wx;let N;t[17]!==d?(N=(E,M,L)=>{d({id:E,approved:M,...L?{reason:L}:{}})},t[17]=d,t[18]=N):N=t[18];const A=N;if(g){let E;return t[19]!==j||t[20]!==a||t[21]!==x?(E=n.jsx("div",{className:"absolute bottom-full left-0 right-0",children:n.jsx(Bu,{userAskParts:x,isStreaming:a,onSubmit:j})}),t[19]=j,t[20]=a,t[21]=x,t[22]=E):E=t[22],E}if(_.length>0){let E;return t[23]!==T||t[24]!==a||t[25]!==_?(E=n.jsx("div",{className:"absolute bottom-full left-0 right-0",children:n.jsx(kx,{plans:_,isStreaming:a,onApprove:T,onDismiss:R})}),t[23]=T,t[24]=a,t[25]=_,t[26]=E):E=t[26],E}if(b.length>0||a&&l){let E;return t[27]!==A||t[28]!==a||t[29]!==b?(E=n.jsx("div",{className:"absolute bottom-full left-0 right-0",children:n.jsx(Sx,{approvals:b,isStreaming:a,onRespond:A})}),t[27]=A,t[28]=a,t[29]=b,t[30]=E):E=t[30],E}if(!a&&e){if(Ox(e)){let M;return t[31]!==s?(M=n.jsx($u,{onDismiss:s}),t[31]=s,t[32]=M):M=t[32],M}let E;return t[33]!==s||t[34]!==e||t[35]!==C?(E=n.jsx("div",{className:"absolute bottom-full left-0 right-0 bg-background",children:n.jsx(Wr,{variant:"error",error:e,onDismiss:s,onFixInChat:C})}),t[33]=s,t[34]=e,t[35]=C,t[36]=E):E=t[36],E}if(!a&&i&&i!=="stop"&&!l){let E;return t[37]!==r||t[38]!==i||t[39]!==w?(E=n.jsx("div",{className:"absolute bottom-full left-0 right-0 bg-background",children:n.jsx(Wr,{variant:"warning",finishReason:i,onDismiss:r,onContinue:w})}),t[37]=r,t[38]=i,t[39]=w,t[40]=E):E=t[40],E}return null}function Wx(){document.querySelector("[data-chat-input]")?.focus()}function Kx(t){return t.state!=="output-available"}function qx(t){return t.type==="tool-user_ask"}_o.Error=function(e){return n.jsx(Wr,{variant:"error",error:e.error,onDismiss:e.onDismiss,onFixInChat:e.onFixInChat})};_o.Warning=function(e){return n.jsx(Wr,{variant:"warning",finishReason:e.finishReason,onDismiss:e.onDismiss,onContinue:e.onContinue})};_o.UserAskQuestion=Bu;async function Bl(t,e,s,i,r){if(!uo(e)){ue.error("Selected model does not support file uploads");return}const o=s.type||"application/octet-stream";if(!Qg(o,e)){const l=uu(e),c=e?.title??"This model";r?r({fileName:s.name,modelName:c,accepted:l}):ue.error(`"${s.name}" can't be attached`,{description:`${c} accepts ${l}. PowerPoint, Word, and Excel files aren't supported yet.`});return}const a=10*1024*1024;if(s.size>a){ue.error(`File "${s.name}" exceeds 10MB limit`);return}try{const l=new FileReader,c=new Promise((h,f)=>{l.onload=()=>{const m=l.result;if(typeof m!="string"){f(new Error("Failed to read file as data URL"));return}const p=m.includes(",")?m.split(",")[1]??m:m;h(p)},l.onerror=f});l.readAsDataURL(s);const d=await c,u={id:crypto.randomUUID(),name:s.name,mimeType:s.type||"application/octet-stream",size:s.size,data:d};qp(t,{from:i,to:i},u)}catch(l){console.error("Failed to process file:",l),ue.error(`Failed to load file "${s.name}"`)}}function Gx(t){const e=B.c(8),{editor:s,selectedModel:i,onUnsupportedFile:r}=t,o=S.useRef(Xx);let a,l;e[0]!==s||e[1]!==r||e[2]!==i?(a=()=>{o.current=async(u,h)=>{await Bl(s,i,u,h,r)}},l=[s,i,r],e[0]=s,e[1]=r,e[2]=i,e[3]=a,e[4]=l):(a=e[3],l=e[4]),S.useEffect(a,l);let c,d;return e[5]!==s?(c=()=>{if(s?.isDestroyed)return;const u=new ua("fileDropHandler");s.state.plugins.find(m=>m.spec.key===u)&&s.unregisterPlugin(u);const f=new dg({key:u,props:{handleDrop:(m,p,g,_)=>{if(_)return!1;const v=p.dataTransfer?.files;if(!v||v.length===0)return!1;p.preventDefault();const x=m.posAtCoords({left:p.clientX,top:p.clientY});if(!x)return!1;const b=Array.from(v),y=x.pos;for(const C of b)o.current?.(C,y);return!0},handlePaste:(m,p)=>{const g=p.clipboardData?.items;if(!g)return!1;const _=Array.from(g).filter(Yx);if(_.length===0)return!1;p.preventDefault();const{from:v}=m.state.selection;for(const x of _){const b=x.getAsFile();b&&o.current?.(b,v)}return!0}}});return s.registerPlugin(f),()=>{s?.isDestroyed||s.unregisterPlugin(u)}},d=[s],e[5]=s,e[6]=c,e[7]=d):(c=e[6],d=e[7]),S.useEffect(c,d),null}function Yx(t){return t.kind==="file"}function Xx(){return Promise.resolve()}function Jx(t){const e=B.c(24),{selectedModel:s,isStreaming:i,icon:r,onUnsupportedFile:o}=t,{editor:a}=oo(),l=S.useRef(null);let c;e[0]!==s?(c=uo(s),e[0]=s,e[1]=c):c=e[1];const d=c;let u;e[2]!==a||e[3]!==o||e[4]!==s?(u=async C=>{const k=C.target.files;if(!k||k.length===0||!a)return;const w=Array.from(k),{from:V}=a.state.selection,j=V;for(const I of w)await Bl(a,s,I,j,o);l.current&&(l.current.value="")},e[2]=a,e[3]=o,e[4]=s,e[5]=u):u=e[5];const h=u;if(!a||!d)return null;let f;e[6]!==s?(f=Jg(s),e[6]=s,e[7]=f):f=e[7];let m;e[8]!==h||e[9]!==i||e[10]!==f?(m=n.jsx("input",{ref:l,type:"file",multiple:!0,accept:f,className:"hidden",onChange:h,disabled:i}),e[8]=h,e[9]=i,e[10]=f,e[11]=m):m=e[11];const p=i||!d;let g;e[12]===Symbol.for("react.memo_cache_sentinel")?(g=()=>l.current?.click(),e[12]=g):g=e[12];let _;e[13]!==r?(_=r??n.jsx(Xh,{size:16}),e[13]=r,e[14]=_):_=e[14];let v;e[15]!==p||e[16]!==_?(v=n.jsx(st,{asChild:!0,children:n.jsx(ae,{type:"button",variant:"ghost",size:"icon",className:"text-muted-foreground/75",disabled:p,onClick:g,children:_})}),e[15]=p,e[16]=_,e[17]=v):v=e[17];let x;e[18]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsx(it,{side:"top",children:"Add file"}),e[18]=x):x=e[18];let b;e[19]!==v?(b=n.jsxs(nt,{children:[v,x]}),e[19]=v,e[20]=b):b=e[20];let y;return e[21]!==b||e[22]!==m?(y=n.jsxs(n.Fragment,{children:[m,b]}),e[21]=b,e[22]=m,e[23]=y):y=e[23],y}const Qx=["PowerPoint (.pptx)","Word documents (.docx)","Excel spreadsheets (.xlsx)"];function Zx(t){const e=B.c(29),{info:s,onClose:i}=t,r=s!==null;let o;e[0]!==i?(o=w=>!w&&i(),e[0]=i,e[1]=o):o=e[1];let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=["radial-gradient(ellipse 40% 200% at -5% 100%, rgba(251,191,36,0.35) 0%, transparent 100%)","radial-gradient(ellipse 40% 200% at 105% -10%, rgba(244,114,182,0.25) 0%, transparent 100%)"],e[2]=a):a=e[2];let l;e[3]===Symbol.for("react.memo_cache_sentinel")?(l=n.jsx("div",{className:"absolute inset-x-0 top-0 h-36 pointer-events-none",style:{backgroundImage:a.join(", "),maskImage:"linear-gradient(to bottom, black 0%, transparent 100%)",WebkitMaskImage:"linear-gradient(to bottom, black 0%, transparent 100%)"}}),e[3]=l):l=e[3];let c,d;e[4]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx("div",{className:"flex items-center justify-center size-9 rounded-lg bg-amber-500/15 text-amber-600 dark:text-amber-400",children:n.jsx(ul,{size:18})}),d=n.jsx(ds,{className:"text-xl font-semibold tracking-tight",children:"File type not supported"}),e[4]=c,e[5]=d):(c=e[4],d=e[5]);const u=s?.fileName;let h;e[6]!==u?(h=n.jsxs("div",{className:"relative px-8 pt-8 pb-2 overflow-hidden",children:[l,n.jsxs(hs,{className:"relative gap-4",children:[c,n.jsxs("div",{children:[d,n.jsxs(ao,{className:"mt-1.5 text-sm leading-relaxed",children:[n.jsxs("span",{className:"font-medium text-foreground",children:["“",u,"”"]})," ","can't be attached to this chat."]})]})]})]}),e[6]=u,e[7]=h):h=e[7];const f=s?.modelName;let m;e[8]!==f?(m=n.jsxs("div",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground mb-2",children:[f," accepts"]}),e[8]=f,e[9]=m):m=e[9];let p;e[10]===Symbol.for("react.memo_cache_sentinel")?(p=n.jsx(Xh,{size:14,className:"text-muted-foreground"}),e[10]=p):p=e[10];const g=s?.accepted;let _;e[11]!==g?(_=n.jsxs("div",{className:"flex items-center gap-2 text-sm text-foreground",children:[p,n.jsx("span",{className:"capitalize",children:g})]}),e[11]=g,e[12]=_):_=e[12];let v;e[13]!==m||e[14]!==_?(v=n.jsxs("div",{className:"rounded-xl border border-border p-4",children:[m,_]}),e[13]=m,e[14]=_,e[15]=v):v=e[15];let x;e[16]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsxs("div",{className:"rounded-xl bg-muted/25 border border-border/50 p-4 space-y-2",children:[n.jsx("div",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Not supported yet"}),Qx.map(e1)]}),e[16]=x):x=e[16];let b;e[17]!==v?(b=n.jsxs("div",{className:"px-8 pt-3 pb-6 space-y-3",children:[v,x]}),e[17]=v,e[18]=b):b=e[18];let y;e[19]!==i?(y=n.jsx("div",{className:"px-8 py-4 border-t border-border bg-muted/30 flex items-center justify-end",children:n.jsx(ae,{onClick:i,children:"Got it"})}),e[19]=i,e[20]=y):y=e[20];let C;e[21]!==b||e[22]!==y||e[23]!==h?(C=n.jsxs(ts,{className:"sm:max-w-[480px] gap-0 p-0 overflow-hidden",onOpenAutoFocus:t1,children:[h,b,y]}),e[21]=b,e[22]=y,e[23]=h,e[24]=C):C=e[24];let k;return e[25]!==r||e[26]!==C||e[27]!==o?(k=n.jsx(ss,{open:r,onOpenChange:o,children:C}),e[25]=r,e[26]=C,e[27]=o,e[28]=k):k=e[28],k}function e1(t){return n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("div",{className:"flex items-center justify-center size-5 rounded-full bg-muted shrink-0",children:n.jsx(Js,{size:10,className:"text-muted-foreground"})}),n.jsx("span",{className:"text-sm text-foreground/80",children:t})]},t)}function t1(t){return t.preventDefault()}function s1(){const t=B.c(3),[e,s]=S.useState(null);let i;t[0]===Symbol.for("react.memo_cache_sentinel")?(i=()=>s(null),t[0]=i):i=t[0];let r;return t[1]!==e?(r={unsupportedFile:e,onUnsupportedFile:s,clearUnsupportedFile:i},t[1]=e,t[2]=r):r=t[2],r}var i1=hg;var n1=["input:not([inert]):not([inert] *)","select:not([inert]):not([inert] *)","textarea:not([inert]):not([inert] *)","a[href]:not([inert]):not([inert] *)","button:not([inert]):not([inert] *)","[tabindex]:not(slot):not([inert]):not([inert] *)","audio[controls]:not([inert]):not([inert] *)","video[controls]:not([inert]):not([inert] *)",'[contenteditable]:not([contenteditable="false"]):not([inert]):not([inert] *)',"details>summary:first-of-type:not([inert]):not([inert] *)","details:not([inert]):not([inert] *)"],xa=n1.join(","),zu=typeof Element>"u",Tn=zu?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,Kr=!zu&&Element.prototype.getRootNode?function(t){var e;return t==null||(e=t.getRootNode)===null||e===void 0?void 0:e.call(t)}:function(t){return t?.ownerDocument},qr=function(e,s){var i;s===void 0&&(s=!0);var r=e==null||(i=e.getAttribute)===null||i===void 0?void 0:i.call(e,"inert"),o=r===""||r==="true",a=o||s&&e&&(typeof e.closest=="function"?e.closest("[inert]"):qr(e.parentNode));return a},r1=function(e){var s,i=e==null||(s=e.getAttribute)===null||s===void 0?void 0:s.call(e,"contenteditable");return i===""||i==="true"},o1=function(e,s,i){if(qr(e))return[];var r=Array.prototype.slice.apply(e.querySelectorAll(xa));return s&&Tn.call(e,xa)&&r.unshift(e),r=r.filter(i),r},va=function(e,s,i){for(var r=[],o=Array.from(e);o.length;){var a=o.shift();if(!qr(a,!1))if(a.tagName==="SLOT"){var l=a.assignedElements(),c=l.length?l:a.children,d=va(c,!0,i);i.flatten?r.push.apply(r,d):r.push({scopeParent:a,candidates:d})}else{var u=Tn.call(a,xa);u&&i.filter(a)&&(s||!e.includes(a))&&r.push(a);var h=a.shadowRoot||typeof i.getShadowRoot=="function"&&i.getShadowRoot(a),f=!qr(h,!1)&&(!i.shadowRootFilter||i.shadowRootFilter(a));if(h&&f){var m=va(h===!0?a.children:h.children,!0,i);i.flatten?r.push.apply(r,m):r.push({scopeParent:a,candidates:m})}else o.unshift.apply(o,a.children)}}return r},Fu=function(e){return!isNaN(parseInt(e.getAttribute("tabindex"),10))},Uu=function(e){if(!e)throw new Error("No node provided");return e.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(e.tagName)||r1(e))&&!Fu(e)?0:e.tabIndex},a1=function(e,s){var i=Uu(e);return i<0&&s&&!Fu(e)?0:i},l1=function(e,s){return e.tabIndex===s.tabIndex?e.documentOrder-s.documentOrder:e.tabIndex-s.tabIndex},Hu=function(e){return e.tagName==="INPUT"},c1=function(e){return Hu(e)&&e.type==="hidden"},d1=function(e){var s=e.tagName==="DETAILS"&&Array.prototype.slice.apply(e.children).some(function(i){return i.tagName==="SUMMARY"});return s},h1=function(e,s){for(var i=0;i<e.length;i++)if(e[i].checked&&e[i].form===s)return e[i]},u1=function(e){if(!e.name)return!0;var s=e.form||Kr(e),i=function(l){return s.querySelectorAll('input[type="radio"][name="'+l+'"]')},r;if(typeof window<"u"&&typeof window.CSS<"u"&&typeof window.CSS.escape=="function")r=i(window.CSS.escape(e.name));else try{r=i(e.name)}catch(a){return console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s",a.message),!1}var o=h1(r,e.form);return!o||o===e},f1=function(e){return Hu(e)&&e.type==="radio"},m1=function(e){return f1(e)&&!u1(e)},p1=function(e){var s,i=e&&Kr(e),r=(s=i)===null||s===void 0?void 0:s.host,o=!1;if(i&&i!==e){var a,l,c;for(o=!!((a=r)!==null&&a!==void 0&&(l=a.ownerDocument)!==null&&l!==void 0&&l.contains(r)||e!=null&&(c=e.ownerDocument)!==null&&c!==void 0&&c.contains(e));!o&&r;){var d,u,h;i=Kr(r),r=(d=i)===null||d===void 0?void 0:d.host,o=!!((u=r)!==null&&u!==void 0&&(h=u.ownerDocument)!==null&&h!==void 0&&h.contains(r))}}return o},Lc=function(e){var s=e.getBoundingClientRect(),i=s.width,r=s.height;return i===0&&r===0},g1=function(e,s){var i=s.displayCheck,r=s.getShadowRoot;if(i==="full-native"&&"checkVisibility"in e){var o=e.checkVisibility({checkOpacity:!1,opacityProperty:!1,contentVisibilityAuto:!0,visibilityProperty:!0,checkVisibilityCSS:!0});return!o}if(getComputedStyle(e).visibility==="hidden")return!0;var a=Tn.call(e,"details>summary:first-of-type"),l=a?e.parentElement:e;if(Tn.call(l,"details:not([open]) *"))return!0;if(!i||i==="full"||i==="full-native"||i==="legacy-full"){if(typeof r=="function"){for(var c=e;e;){var d=e.parentElement,u=Kr(e);if(d&&!d.shadowRoot&&r(d)===!0)return Lc(e);e.assignedSlot?e=e.assignedSlot:!d&&u!==e.ownerDocument?e=u.host:e=d}e=c}if(p1(e))return!e.getClientRects().length;if(i!=="legacy-full")return!0}else if(i==="non-zero-area")return Lc(e);return!1},_1=function(e){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(e.tagName))for(var s=e.parentElement;s;){if(s.tagName==="FIELDSET"&&s.disabled){for(var i=0;i<s.children.length;i++){var r=s.children.item(i);if(r.tagName==="LEGEND")return Tn.call(s,"fieldset[disabled] *")?!0:!r.contains(e)}return!0}s=s.parentElement}return!1},x1=function(e,s){return!(s.disabled||c1(s)||g1(s,e)||d1(s)||_1(s))},Oc=function(e,s){return!(m1(s)||Uu(s)<0||!x1(e,s))},v1=function(e){var s=parseInt(e.getAttribute("tabindex"),10);return!!(isNaN(s)||s>=0)},Wu=function(e){var s=[],i=[];return e.forEach(function(r,o){var a=!!r.scopeParent,l=a?r.scopeParent:r,c=a1(l,a),d=a?Wu(r.candidates):l;c===0?a?s.push.apply(s,d):s.push(l):i.push({documentOrder:o,tabIndex:c,item:r,isScope:a,content:d})}),i.sort(l1).reduce(function(r,o){return o.isScope?r.push.apply(r,o.content):r.push(o.content),r},[]).concat(s)},Ku=function(e,s){s=s||{};var i;return s.getShadowRoot?i=va([e],s.includeContainer,{filter:Oc.bind(null,s),flatten:!1,getShadowRoot:s.getShadowRoot,shadowRootFilter:v1}):i=o1(e,s.includeContainer,Oc.bind(null,s)),Wu(i)};function b1(){return/apple/i.test(navigator.vendor)}const Bc="data-floating-ui-focusable";function y1(t){let e=t.activeElement;for(;((s=e)==null||(s=s.shadowRoot)==null?void 0:s.activeElement)!=null;){var s;e=e.shadowRoot.activeElement}return e}function ba(t,e){if(!t||!e)return!1;const s=e.getRootNode==null?void 0:e.getRootNode();if(t.contains(e))return!0;if(s&&ep(s)){let i=e;for(;i;){if(t===i)return!0;i=i.parentNode||i.host}}return!1}function rn(t){return"composedPath"in t?t.composedPath()[0]:t.target}function Do(t,e){if(e==null)return!1;if("composedPath"in t)return t.composedPath().includes(e);const s=t;return s.target!=null&&e.contains(s.target)}function S1(t){return t.matches("html,body")}function Dn(t){return t?.ownerDocument||document}function w1(t){return t?t.hasAttribute(Bc)?t:t.querySelector("["+Bc+"]")||t:null}function Er(t,e,s){return s===void 0&&(s=!0),t.filter(r=>{var o;return r.parentId===e&&(!s||((o=r.context)==null?void 0:o.open))}).flatMap(r=>[r,...Er(t,r.id,s)])}function V1(t){return"nativeEvent"in t}var C1=typeof document<"u",k1=function(){},_i=C1?S.useLayoutEffect:k1;const j1={...Eh},N1=j1.useInsertionEffect,A1=N1||(t=>t());function Di(t){const e=S.useRef(()=>{});return A1(()=>{e.current=t}),S.useCallback(function(){for(var s=arguments.length,i=new Array(s),r=0;r<s;r++)i[r]=arguments[r];return e.current==null?void 0:e.current(...i)},[])}const qu=()=>({getShadowRoot:!0,displayCheck:typeof ResizeObserver=="function"&&ResizeObserver.toString().includes("[native code]")?"full":"none"});function Gu(t,e){const s=Ku(t,qu()),i=s.length;if(i===0)return;const r=y1(Dn(t)),o=s.indexOf(r),a=o===-1?e===1?0:i-1:o+e;return s[a]}function E1(t){return Gu(Dn(t).body,1)||t}function I1(t){return Gu(Dn(t).body,-1)||t}function Mo(t,e){const s=e||t.currentTarget,i=t.relatedTarget;return!i||!ba(s,i)}function R1(t){Ku(t,qu()).forEach(s=>{s.dataset.tabindex=s.getAttribute("tabindex")||"",s.setAttribute("tabindex","-1")})}function $c(t){t.querySelectorAll("[data-tabindex]").forEach(s=>{const i=s.dataset.tabindex;delete s.dataset.tabindex,i?s.setAttribute("tabindex",i):s.removeAttribute("tabindex")})}const T1="data-floating-ui-focusable",zc="active",Fc="selected",D1={...Eh};let Uc=!1,M1=0;const Hc=()=>"floating-ui-"+Math.random().toString(36).slice(2,6)+M1++;function P1(){const[t,e]=S.useState(()=>Uc?Hc():void 0);return _i(()=>{t==null&&e(Hc())},[]),S.useEffect(()=>{Uc=!0},[]),t}const L1=D1.useId,$l=L1||P1;function O1(){const t=new Map;return{emit(e,s){var i;(i=t.get(e))==null||i.forEach(r=>r(s))},on(e,s){t.has(e)||t.set(e,new Set),t.get(e).add(s)},off(e,s){var i;(i=t.get(e))==null||i.delete(s)}}}const B1=S.createContext(null),$1=S.createContext(null),Yu=()=>{var t;return((t=S.useContext(B1))==null?void 0:t.id)||null},Xu=()=>S.useContext($1);function zl(t){return"data-floating-ui-"+t}const z1={border:0,clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:0,position:"fixed",whiteSpace:"nowrap",width:"1px",top:0,left:0},Wc=S.forwardRef(function(e,s){const[i,r]=S.useState();_i(()=>{b1()&&r("button")},[]);const o={ref:s,tabIndex:0,role:i,"aria-hidden":i?void 0:!0,[zl("focus-guard")]:"",style:z1};return n.jsx("span",{...e,...o})}),F1={clipPath:"inset(50%)",position:"fixed",top:0,left:0},Ju=S.createContext(null),Kc=zl("portal");function U1(t){t===void 0&&(t={});const{id:e,root:s}=t,i=$l(),r=W1(),[o,a]=S.useState(null),l=S.useRef(null);return _i(()=>()=>{o?.remove(),queueMicrotask(()=>{l.current=null})},[o]),_i(()=>{if(!i||l.current)return;const c=e?document.getElementById(e):null;if(!c)return;const d=document.createElement("div");d.id=i,d.setAttribute(Kc,""),c.appendChild(d),l.current=d,a(d)},[e,i]),_i(()=>{if(s===null||!i||l.current)return;let c=s||r?.portalNode;c&&!op(c)&&(c=c.current),c=c||document.body;let d=null;e&&(d=document.createElement("div"),d.id=e,c.appendChild(d));const u=document.createElement("div");u.id=i,u.setAttribute(Kc,""),c=d||c,c.appendChild(u),l.current=u,a(u)},[e,s,i,r]),o}function H1(t){const{children:e,id:s,root:i,preserveTabOrder:r=!0}=t,o=U1({id:s,root:i}),[a,l]=S.useState(null),c=S.useRef(null),d=S.useRef(null),u=S.useRef(null),h=S.useRef(null),f=a?.modal,m=a?.open,p=!!a&&!a.modal&&a.open&&r&&!!(i||o);return S.useEffect(()=>{if(!o||!r||f)return;function g(_){o&&Mo(_)&&(_.type==="focusin"?$c:R1)(o)}return o.addEventListener("focusin",g,!0),o.addEventListener("focusout",g,!0),()=>{o.removeEventListener("focusin",g,!0),o.removeEventListener("focusout",g,!0)}},[o,r,f]),S.useEffect(()=>{o&&(m||$c(o))},[m,o]),n.jsxs(Ju.Provider,{value:S.useMemo(()=>({preserveTabOrder:r,beforeOutsideRef:c,afterOutsideRef:d,beforeInsideRef:u,afterInsideRef:h,portalNode:o,setFocusManagerState:l}),[r,o]),children:[p&&o&&n.jsx(Wc,{"data-type":"outside",ref:c,onFocus:g=>{if(Mo(g,o)){var _;(_=u.current)==null||_.focus()}else{const v=a?a.domReference:null,x=I1(v);x?.focus()}}}),p&&o&&n.jsx("span",{"aria-owns":o.id,style:F1}),o&&ms.createPortal(e,o),p&&o&&n.jsx(Wc,{"data-type":"outside",ref:d,onFocus:g=>{if(Mo(g,o)){var _;(_=h.current)==null||_.focus()}else{const v=a?a.domReference:null,x=E1(v);x?.focus(),a?.closeOnFocusOut&&a?.onOpenChange(!1,g.nativeEvent,"focus-out")}}})]})}const W1=()=>S.useContext(Ju),K1={pointerdown:"onPointerDown",mousedown:"onMouseDown",click:"onClick"},q1={pointerdown:"onPointerDownCapture",mousedown:"onMouseDownCapture",click:"onClickCapture"},qc=t=>{var e,s;return{escapeKey:typeof t=="boolean"?t:(e=t?.escapeKey)!=null?e:!1,outsidePress:typeof t=="boolean"?t:(s=t?.outsidePress)!=null?s:!0}};function G1(t,e){e===void 0&&(e={});const{open:s,onOpenChange:i,elements:r,dataRef:o}=t,{enabled:a=!0,escapeKey:l=!0,outsidePress:c=!0,outsidePressEvent:d="pointerdown",referencePress:u=!1,referencePressEvent:h="pointerdown",ancestorScroll:f=!1,bubbles:m,capture:p}=e,g=Xu(),_=Di(typeof c=="function"?c:()=>!1),v=typeof c=="function"?_:c,x=S.useRef(!1),{escapeKey:b,outsidePress:y}=qc(m),{escapeKey:C,outsidePress:k}=qc(p),w=S.useRef(!1),V=Di(A=>{var E;if(!s||!a||!l||A.key!=="Escape"||w.current)return;const M=(E=o.current.floatingContext)==null?void 0:E.nodeId,L=g?Er(g.nodesRef.current,M):[];if(!b&&(A.stopPropagation(),L.length>0)){let D=!0;if(L.forEach(P=>{var O;if((O=P.context)!=null&&O.open&&!P.context.dataRef.current.__escapeKeyBubbles){D=!1;return}}),!D)return}i(!1,V1(A)?A.nativeEvent:A,"escape-key")}),j=Di(A=>{var E;const M=()=>{var L;V(A),(L=rn(A))==null||L.removeEventListener("keydown",M)};(E=rn(A))==null||E.addEventListener("keydown",M)}),I=Di(A=>{var E;const M=o.current.insideReactTree;o.current.insideReactTree=!1;const L=x.current;if(x.current=!1,d==="click"&&L||M||typeof v=="function"&&!v(A))return;const D=rn(A),P="["+zl("inert")+"]",O=Dn(r.floating).querySelectorAll(P);let z=Vs(D)?D:null;for(;z&&!Ao(z);){const G=ip(z);if(Ao(G)||!Vs(G))break;z=G}if(O.length&&Vs(D)&&!S1(D)&&!ba(D,r.floating)&&Array.from(O).every(G=>!ba(z,G)))return;if(np(D)&&N){const G=Ao(D),H=rp(D),U=/auto|scroll/,Y=G||U.test(H.overflowX),W=G||U.test(H.overflowY),K=Y&&D.clientWidth>0&&D.scrollWidth>D.clientWidth,ee=W&&D.clientHeight>0&&D.scrollHeight>D.clientHeight,Z=H.direction==="rtl",X=ee&&(Z?A.offsetX<=D.offsetWidth-D.clientWidth:A.offsetX>D.clientWidth),ie=K&&A.offsetY>D.clientHeight;if(X||ie)return}const $=(E=o.current.floatingContext)==null?void 0:E.nodeId,q=g&&Er(g.nodesRef.current,$).some(G=>{var H;return Do(A,(H=G.context)==null?void 0:H.elements.floating)});if(Do(A,r.floating)||Do(A,r.domReference)||q)return;const F=g?Er(g.nodesRef.current,$):[];if(F.length>0){let G=!0;if(F.forEach(H=>{var U;if((U=H.context)!=null&&U.open&&!H.context.dataRef.current.__outsidePressBubbles){G=!1;return}}),!G)return}i(!1,A,"outside-press")}),T=Di(A=>{var E;const M=()=>{var L;I(A),(L=rn(A))==null||L.removeEventListener(d,M)};(E=rn(A))==null||E.addEventListener(d,M)});S.useEffect(()=>{if(!s||!a)return;o.current.__escapeKeyBubbles=b,o.current.__outsidePressBubbles=y;let A=-1;function E(O){i(!1,O,"ancestor-scroll")}function M(){window.clearTimeout(A),w.current=!0}function L(){A=window.setTimeout(()=>{w.current=!1},sp()?5:0)}const D=Dn(r.floating);l&&(D.addEventListener("keydown",C?j:V,C),D.addEventListener("compositionstart",M),D.addEventListener("compositionend",L)),v&&D.addEventListener(d,k?T:I,k);let P=[];return f&&(Vs(r.domReference)&&(P=No(r.domReference)),Vs(r.floating)&&(P=P.concat(No(r.floating))),!Vs(r.reference)&&r.reference&&r.reference.contextElement&&(P=P.concat(No(r.reference.contextElement)))),P=P.filter(O=>{var z;return O!==((z=D.defaultView)==null?void 0:z.visualViewport)}),P.forEach(O=>{O.addEventListener("scroll",E,{passive:!0})}),()=>{l&&(D.removeEventListener("keydown",C?j:V,C),D.removeEventListener("compositionstart",M),D.removeEventListener("compositionend",L)),v&&D.removeEventListener(d,k?T:I,k),P.forEach(O=>{O.removeEventListener("scroll",E)}),window.clearTimeout(A)}},[o,r,l,v,d,s,i,f,a,b,y,V,C,j,I,k,T]),S.useEffect(()=>{o.current.insideReactTree=!1},[o,v,d]);const R=S.useMemo(()=>({onKeyDown:V,...u&&{[K1[h]]:A=>{i(!1,A.nativeEvent,"reference-press")},...h!=="click"&&{onClick(A){i(!1,A.nativeEvent,"reference-press")}}}}),[V,i,u,h]),N=S.useMemo(()=>{function A(E){E.button===0&&(x.current=!0)}return{onKeyDown:V,onMouseDown:A,onMouseUp:A,[q1[d]]:()=>{o.current.insideReactTree=!0}}},[V,d,o]);return S.useMemo(()=>a?{reference:R,floating:N}:{},[a,R,N])}function Y1(t){const{open:e=!1,onOpenChange:s,elements:i}=t,r=$l(),o=S.useRef({}),[a]=S.useState(()=>O1()),l=Yu()!=null,[c,d]=S.useState(i.reference),u=Di((m,p,g)=>{o.current.openEvent=m?p:void 0,a.emit("openchange",{open:m,event:p,reason:g,nested:l}),s?.(m,p,g)}),h=S.useMemo(()=>({setPositionReference:d}),[]),f=S.useMemo(()=>({reference:c||i.reference||null,floating:i.floating||null,domReference:i.reference}),[c,i.reference,i.floating]);return S.useMemo(()=>({dataRef:o,open:e,onOpenChange:u,elements:f,events:a,floatingId:r,refs:h}),[e,u,f,a,r,h])}function X1(t){t===void 0&&(t={});const{nodeId:e}=t,s=Y1({...t,elements:{reference:null,floating:null,...t.elements}}),i=t.rootContext||s,r=i.elements,[o,a]=S.useState(null),[l,c]=S.useState(null),u=r?.domReference||o,h=S.useRef(null),f=Xu();_i(()=>{u&&(h.current=u)},[u]);const m=tp({...t,elements:{...r,...l&&{reference:l}}}),p=S.useCallback(b=>{const y=Vs(b)?{getBoundingClientRect:()=>b.getBoundingClientRect(),getClientRects:()=>b.getClientRects(),contextElement:b}:b;c(y),m.refs.setReference(y)},[m.refs]),g=S.useCallback(b=>{(Vs(b)||b===null)&&(h.current=b,a(b)),(Vs(m.refs.reference.current)||m.refs.reference.current===null||b!==null&&!Vs(b))&&m.refs.setReference(b)},[m.refs]),_=S.useMemo(()=>({...m.refs,setReference:g,setPositionReference:p,domReference:h}),[m.refs,g,p]),v=S.useMemo(()=>({...m.elements,domReference:u}),[m.elements,u]),x=S.useMemo(()=>({...m,...i,refs:_,elements:v,nodeId:e}),[m,_,v,e,i]);return _i(()=>{i.dataRef.current.floatingContext=x;const b=f?.nodesRef.current.find(y=>y.id===e);b&&(b.context=x)}),S.useMemo(()=>({...m,context:x,refs:_,elements:v}),[m,_,v,x])}function Po(t,e,s){const i=new Map,r=s==="item";let o=t;if(r&&t){const{[zc]:a,[Fc]:l,...c}=t;o=c}return{...s==="floating"&&{tabIndex:-1,[T1]:""},...o,...e.map(a=>{const l=a?a[s]:null;return typeof l=="function"?t?l(t):null:l}).concat(t).reduce((a,l)=>(l&&Object.entries(l).forEach(c=>{let[d,u]=c;if(!(r&&[zc,Fc].includes(d)))if(d.indexOf("on")===0){if(i.has(d)||i.set(d,[]),typeof u=="function"){var h;(h=i.get(d))==null||h.push(u),a[d]=function(){for(var f,m=arguments.length,p=new Array(m),g=0;g<m;g++)p[g]=arguments[g];return(f=i.get(d))==null?void 0:f.map(_=>_(...p)).find(_=>_!==void 0)}}}else a[d]=u}),a),{})}}function J1(t){t===void 0&&(t=[]);const e=t.map(l=>l?.reference),s=t.map(l=>l?.floating),i=t.map(l=>l?.item),r=S.useCallback(l=>Po(l,t,"reference"),e),o=S.useCallback(l=>Po(l,t,"floating"),s),a=S.useCallback(l=>Po(l,t,"item"),i);return S.useMemo(()=>({getReferenceProps:r,getFloatingProps:o,getItemProps:a}),[r,o,a])}const Q1=new Map([["select","listbox"],["combobox","listbox"],["label",!1]]);function Z1(t,e){var s,i;e===void 0&&(e={});const{open:r,elements:o,floatingId:a}=t,{enabled:l=!0,role:c="dialog"}=e,d=$l(),u=((s=o.domReference)==null?void 0:s.id)||d,h=S.useMemo(()=>{var x;return((x=w1(o.floating))==null?void 0:x.id)||a},[o.floating,a]),f=(i=Q1.get(c))!=null?i:c,p=Yu()!=null,g=S.useMemo(()=>f==="tooltip"||c==="label"?{["aria-"+(c==="label"?"labelledby":"describedby")]:r?h:void 0}:{"aria-expanded":r?"true":"false","aria-haspopup":f==="alertdialog"?"dialog":f,"aria-controls":r?h:void 0,...f==="listbox"&&{role:"combobox"},...f==="menu"&&{id:u},...f==="menu"&&p&&{role:"menuitem"},...c==="select"&&{"aria-autocomplete":"none"},...c==="combobox"&&{"aria-autocomplete":"list"}},[f,h,p,r,u,c]),_=S.useMemo(()=>{const x={id:h,...f&&{role:f}};return f==="tooltip"||c==="label"?x:{...x,...f==="menu"&&{"aria-labelledby":u}}},[f,h,u,c]),v=S.useCallback(x=>{let{active:b,selected:y}=x;const C={role:"option",...b&&{id:h+"-fui-option"}};switch(c){case"select":case"combobox":return{...C,"aria-selected":y}}return{}},[h,c]);return S.useMemo(()=>l?{reference:g,floating:_,item:v}:{},[l,g,_,v])}function ev(t){const e=B.c(26),{editor:s,query:i,items:r,onSelect:o,onClose:a}=t,[l,c]=S.useState(0),d=S.useRef(r),u=S.useRef(l),h=S.useRef(o),f=S.useRef(a),m=S.useDeferredValue(i);let p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p=()=>{c(0)},e[0]=p):p=e[0];let g;e[1]!==m?(g=[m],e[1]=m,e[2]=g):g=e[2],S.useEffect(p,g);let _,v;e[3]!==r.length||e[4]!==l?(_=()=>{l>=r.length&&r.length>0&&c(0)},v=[r.length,l],e[3]=r.length,e[4]=l,e[5]=_,e[6]=v):(_=e[5],v=e[6]),S.useEffect(_,v);let x,b;e[7]!==r?(x=()=>{d.current=r},b=[r],e[7]=r,e[8]=x,e[9]=b):(x=e[8],b=e[9]),S.useEffect(x,b);let y,C;e[10]!==l?(y=()=>{u.current=l},C=[l],e[10]=l,e[11]=y,e[12]=C):(y=e[11],C=e[12]),S.useEffect(y,C);let k,w;e[13]!==o?(w=()=>{h.current=o},k=[o],e[13]=o,e[14]=k,e[15]=w):(k=e[14],w=e[15]),S.useEffect(w,k);let V,j;e[16]!==a?(V=()=>{f.current=a},j=[a],e[16]=a,e[17]=V,e[18]=j):(V=e[17],j=e[18]),S.useEffect(V,j);let I;e[19]!==s.isDestroyed||e[20]!==s.view.dom?(I=()=>{const A=s.view.dom;if(s?.isDestroyed||!A)return;const E=L=>{const D=d.current;if(!D.length)return!1;const P=()=>c(z=>(z+1)%D.length),O=()=>c(z=>(z-1+D.length)%D.length);switch(L.key){case"ArrowUp":return L.preventDefault(),O(),!0;case"ArrowDown":return L.preventDefault(),P(),!0;case"Tab":return L.preventDefault(),L.shiftKey?O():P(),!0;case"Home":return L.preventDefault(),c(0),!0;case"End":return L.preventDefault(),c(D.length-1),!0;case"Enter":{if(L.isComposing)return!1;L.preventDefault();const z=u.current;return z!==-1&&D[z]&&h.current?.(D[z],z),!0}case"Escape":return L.preventDefault(),f.current?.(),!0;default:return!1}},M=L=>{E(L)};return A.addEventListener("keydown",M,!0),()=>{A?.removeEventListener("keydown",M,!0)}},e[19]=s.isDestroyed,e[20]=s.view.dom,e[21]=I):I=e[21];let T;e[22]!==s?(T=[s],e[22]=s,e[23]=T):T=e[23],S.useEffect(I,T);const R=r.length?l:void 0;let N;return e[24]!==R?(N={selectedIndex:R,setSelectedIndex:c},e[24]=R,e[25]=N):N=e[25],N}function tv(t,e){switch(e.type){case"SET_SELECTED_ITEM":return{...t,selectedItem:e.payload};case"ON_START":return{...t,open:!0,selectedItem:null,element:e.payload.element,query:e.payload.query,range:e.payload.range};case"ON_UPDATE":return{...t,element:e.payload.element,query:e.payload.query,range:e.payload.range};case"ON_EXIT":return{open:!1,element:null,query:"",range:null,selectedItem:null};default:return t}}const Qu=S.createContext(void 0);function Zu(){const t=S.useContext(Qu);if(!t)throw new Error("useSuggestionContext must be used within a SuggestionContext.Provider");return t}function sv({editor:t,char:e,pluginKey:s,allow:i,onOpenChange:r}){const[o,a]=S.useReducer(tv,{open:!1,element:null,query:"",range:null,selectedItem:null}),l=S.useRef(r);return l.current=r,S.useEffect(()=>{if(t?.isDestroyed)return;const c=s instanceof ua?s:new ua(s);t.state.plugins.find(h=>h.spec.key===c)&&t.unregisterPlugin(c);const u=e_({pluginKey:c,editor:t,char:e,allow(h){const f=t.state.doc.resolve(h.range.from);for(let m=f.depth;m>0;m--)if(f.node(m).type.name==="image")return!1;return!(i&&!i(h))},command(){},render:()=>({onStart:h=>{a({type:"ON_START",payload:{element:h.decorationNode??null,query:h.query,range:h.range}}),l.current?.(!0)},onUpdate:h=>{a({type:"ON_UPDATE",payload:{element:h.decorationNode??null,query:h.query,range:h.range}})},onKeyDown:h=>h.event.key==="Escape"?(a({type:"ON_EXIT"}),!0):!1,onExit:()=>{a({type:"ON_EXIT"}),l.current?.(!1)}}),items:()=>[]});return t.registerPlugin(u),()=>{t?.isDestroyed||t.unregisterPlugin(c)}},[t,s,e,a,i]),{state:o,dispatch:a}}function iv({editor:t,queryKey:e,queryFn:s,onSelect:i}){const{state:r,dispatch:o}=Zu(),a=S.useDeferredValue(r.query),{data:l}=Ih({queryKey:ct.suggestionItems(e,r.open,a),queryFn:()=>r.open?s({query:a}):[]}),c=()=>{o({type:"ON_EXIT"})},d=async(h,f)=>{if(!(r.selectedItem!==null||!r.range)){o({type:"SET_SELECTED_ITEM",payload:h});try{const{view:m}=t,g=m.state.selection.$to.nodeAfter?.text?.startsWith(" "),_=r.range?{...r.range}:{from:0,to:0};g&&r.range&&(_.to+=1),await i({range:_,item:h})===!1?o({type:"SET_SELECTED_ITEM",payload:null}):c()}catch{c()}}},{selectedIndex:u}=ev({editor:t,query:a,items:l,onSelect:d,onClose:c});return{selectedItem:r.selectedItem,items:l,selectedIndex:u,close:c,onSelect:d}}function nv({children:t}){const{state:e,dispatch:s}=Zu(),{open:i,element:r}=e,o=()=>{s({type:"ON_EXIT"})},{refs:a,floatingStyles:l,context:c}=X1({placement:"bottom-start",open:i,onOpenChange:f=>{f||o()},elements:{reference:r},middleware:[ap(10),lp(),cp()],whileElementsMounted:dp}),d=G1(c,{outsidePress:f=>!(f.target instanceof Element&&f.target.closest(".ProseMirror"))}),u=Z1(c,{role:"listbox"}),{getFloatingProps:h}=J1([d,u]);return i?n.jsx(H1,{children:n.jsx("div",{ref:a.setFloating,style:l,...h(),className:"z-50 w-auto min-w-[360px] max-w-[520px] rounded-lg border bg-popover p-0 text-popover-foreground shadow-md outline-hidden overflow-hidden",children:t})}):null}const rv=t=>{const e=B.c(29),{item:s,isSelected:i,onSelect:r,isLoading:o,ref:a}=t;let l;if(e[0]!==s){const k=ni(s._meta);l=s.title||ro(s.name,k),e[0]=s,e[1]=l}else l=e[1];const c=l,d=s.description||null,u=s.icon,h=i&&"bg-accent text-accent-foreground",f=o&&"pointer-events-none opacity-50";let m;e[2]!==h||e[3]!==f?(m=J("relative flex w-full cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors","hover:bg-accent hover:text-accent-foreground","focus:bg-accent focus:text-accent-foreground",h,f),e[2]=h,e[3]=f,e[4]=m):m=e[4];let p;e[5]!==u||e[6]!==c?(p=u!==void 0&&n.jsx(gs,{icon:u,name:c,size:"xs",className:"mr-2"}),e[5]=u,e[6]=c,e[7]=p):p=e[7];let g;e[8]!==c?(g=n.jsx("span",{className:"font-medium flex items-center truncate capitalize",children:c}),e[8]=c,e[9]=g):g=e[9];let _;e[10]!==o?(_=o&&n.jsx(In,{size:"xs"}),e[10]=o,e[11]=_):_=e[11];let v;e[12]!==g||e[13]!==_?(v=n.jsxs("div",{className:"flex items-center justify-between gap-2",children:[g,_]}),e[12]=g,e[13]=_,e[14]=v):v=e[14];let x;e[15]!==d?(x=d&&n.jsx("div",{className:"text-xs text-muted-foreground line-clamp-1",children:d}),e[15]=d,e[16]=x):x=e[16];let b;e[17]!==v||e[18]!==x?(b=n.jsxs("div",{className:"flex flex-col gap-0.5 flex-1 min-w-0",children:[v,x]}),e[17]=v,e[18]=x,e[19]=b):b=e[19];let y;e[20]!==s.drillable?(y=s.drillable&&n.jsx("kbd",{className:"shrink-0 ml-2 px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground bg-muted border border-border rounded",children:"↵"}),e[20]=s.drillable,e[21]=y):y=e[21];let C;return e[22]!==r||e[23]!==a||e[24]!==b||e[25]!==y||e[26]!==m||e[27]!==p?(C=n.jsxs("div",{ref:a,onClick:r,className:m,children:[p,b,y]}),e[22]=r,e[23]=a,e[24]=b,e[25]=y,e[26]=m,e[27]=p,e[28]=C):C=e[28],C},ov=t=>{const e=B.c(18),{editor:s,queryKey:i,queryFn:r,onSelect:o}=t;let a;e[0]!==s||e[1]!==o||e[2]!==r||e[3]!==i?(a={editor:s,queryKey:i,queryFn:r,onSelect:o},e[0]=s,e[1]=o,e[2]=r,e[3]=i,e[4]=a):a=e[4];const{items:l,selectedIndex:c,onSelect:d,selectedItem:u}=iv(a);if(!l.length){let p;return e[5]===Symbol.for("react.memo_cache_sentinel")?(p=n.jsx("div",{className:"min-w-[360px] max-w-[520px] bg-popover text-popover-foreground rounded-md border shadow-md p-3 text-sm",children:"No items found"}),e[5]=p):p=e[5],p}let h;e[6]===Symbol.for("react.memo_cache_sentinel")?(h={maxHeight:"min(320px, var(--radix-popover-content-available-height, 320px))"},e[6]=h):h=e[6];let f;if(e[7]!==d||e[8]!==l||e[9]!==c||e[10]!==u?.name){let p;e[12]!==d||e[13]!==c||e[14]!==u?.name?(p=(g,_)=>n.jsx(rv,{item:g,isSelected:_===c,ref:_===c?cv:void 0,onSelect:()=>d(g,_),isLoading:u?.name===g.name},g.name),e[12]=d,e[13]=c,e[14]=u?.name,e[15]=p):p=e[15],f=l.map(p),e[7]=d,e[8]=l,e[9]=c,e[10]=u?.name,e[11]=f}else f=e[11];let m;return e[16]!==f?(m=n.jsx("div",{className:"min-w-[360px] max-w-[520px] bg-popover text-popover-foreground rounded-md overflow-y-auto",style:h,children:n.jsx("div",{className:"p-1",children:f})}),e[16]=f,e[17]=m):m=e[17],m};function av(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx("div",{className:"p-1",children:[...Array(3)].map(lv)}),t[0]=e):e=t[0],e}function lv(t,e){return n.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1.5 animate-pulse",children:[n.jsx("div",{className:"h-4 w-24 bg-muted rounded"}),n.jsx("div",{className:"h-3 w-32 bg-muted rounded"})]},e)}function ef(t){const e=B.c(18),{editor:s,char:i,pluginKey:r,queryKey:o,queryFn:a,onSelect:l,allow:c,onOpenChange:d}=t;let u;e[0]!==c||e[1]!==i||e[2]!==s||e[3]!==d||e[4]!==r?(u={editor:s,char:i,pluginKey:r,allow:c,onOpenChange:d},e[0]=c,e[1]=i,e[2]=s,e[3]=d,e[4]=r,e[5]=u):u=e[5];const{state:h,dispatch:f}=sv(u);let m;e[6]!==f||e[7]!==h?(m={state:h,dispatch:f},e[6]=f,e[7]=h,e[8]=m):m=e[8];let p;e[9]===Symbol.for("react.memo_cache_sentinel")?(p=n.jsx(av,{}),e[9]=p):p=e[9];let g;e[10]!==s||e[11]!==l||e[12]!==a||e[13]!==o?(g=n.jsx(nv,{children:n.jsx(S.Suspense,{fallback:p,children:n.jsx(ov,{editor:s,queryKey:o,queryFn:a,onSelect:l})})}),e[10]=s,e[11]=l,e[12]=a,e[13]=o,e[14]=g):g=e[14];let _;return e[15]!==m||e[16]!==g?(_=n.jsx(Qu.Provider,{value:m,children:g}),e[15]=m,e[16]=g,e[17]=_):_=e[17],_}function cv(t){t&&t.scrollIntoView({block:"center",behavior:"smooth"})}const dv=[{name:"agents",title:"Agents",description:"Mention an agent to hand off work",kind:"category",drillable:!0},{name:"resources",title:"Resources",description:"Attach a resource as context",kind:"category",drillable:!0}],hv=({editor:t,virtualMcpId:e})=>{const s=Mt(),{org:i}=xe(),r=fo(),o=Be({connectionId:e,orgId:i.id}),a=ct.virtualMcpResources(e,i.id),[l,c]=S.useState("categories"),d=S.useRef(l);d.current=l;const u=S.useRef(null),h=S.useRef(!1),f=["at-mention",i.id,e??"default",l],m=async({item:_,range:v})=>{if(ne("chat_picker_item_selected",{picker:"@",item_kind:_.kind,item_name:_.name}),_.kind!=="category"&&(h.current=!0),_.kind==="category")return c(_.name==="agents"?"agents":"resources"),!1;if(_.kind==="agent"&&_.agentId){En(t,v,{id:_.agentId,name:_.name,metadata:{agentId:_.agentId,title:_.name},char:"@"}),c("categories");return}if(_.kind==="resource"&&_.uri&&o){try{const x=await pu(o,_.uri);En(t,v,{id:_.uri,name:_.uri,metadata:x.contents,char:"@"})}catch(x){console.error("[at-mention] Failed to fetch resource:",x),ue.error("Failed to load resource. Please try again.")}c("categories");return}},p=async _=>{const{query:v}=_,x=d.current;if(x==="categories"){if(!v.trim())return dv;const C=v.toLowerCase(),k=r.filter(V=>V.status==="active"&&(!V.id||!Br(V.id))&&V.id!==e&&(V.title.toLowerCase().includes(C)||V.description?.toLowerCase().includes(C))).map(V=>({name:V.title,title:V.title,description:V.description??void 0,icon:V.icon??null,kind:"agent",agentId:V.id})),w=await(async()=>{if(!o)return[];let V=s.getQueryData(a);return V||(V=await s.fetchQuery({queryKey:a,queryFn:()=>wn(o),staleTime:6e4})),(V?.resources??[]).filter(j=>j.uri.toLowerCase().includes(C)||j.name?.toLowerCase().includes(C)||j.description?.toLowerCase().includes(C)).map(j=>({name:j.name??j.uri,title:j.name,description:j.description,kind:"resource",uri:j.uri}))})();return[...k,...w]}if(x==="agents"){let C=r.filter(k=>k.status==="active"&&(!k.id||!Br(k.id))&&k.id!==e);if(v.trim()){const k=v.toLowerCase();C=C.filter(w=>w.title.toLowerCase().includes(k)||w.description?.toLowerCase().includes(k))}return C.map(k=>({name:k.title,title:k.title,description:k.description??void 0,icon:k.icon??null,kind:"agent",agentId:k.id}))}if(!o)return[];let b=s.getQueryData(a);b?s.fetchQuery({queryKey:a,queryFn:()=>wn(o),staleTime:6e4}).catch(()=>{}):b=await s.fetchQuery({queryKey:a,queryFn:()=>wn(o),staleTime:6e4});let y=b?.resources??[];if(v.trim()){const C=v.toLowerCase();y=y.filter(k=>k.uri.toLowerCase().includes(C)||k.name?.toLowerCase().includes(C)||k.description?.toLowerCase().includes(C))}return y.map(C=>({name:C.name??C.uri,title:C.name,description:C.description,kind:"resource",uri:C.uri}))},g=_=>{if(_)u.current=Date.now(),h.current=!1,ne("chat_picker_opened",{picker:"@"});else{const v=u.current;ne("chat_picker_closed",{picker:"@",outcome:h.current?"selected":"dismissed",duration_ms:v?Date.now()-v:null}),u.current=null,c("categories")}};return n.jsx(ef,{editor:t,char:"@",pluginKey:"atDropdownMenu",queryKey:f,queryFn:p,onSelect:m,onOpenChange:g})};function uv(t,e){const s=is(t),i=Gn(),r=new Map(i.map(c=>[c.id,c])),o=(s?.connections??[]).map(c=>c.connection_id),{data:a}=Ki({queryKey:ct.promptConnectionMap(e,o),queryFn:async()=>{const c={};return await Promise.all(o.map(async d=>{try{const u=await vg({connectionId:d,orgId:e}),h=await $r(u);for(const f of h.prompts)f.name in c||(c[f.name]=d)}catch{}})),c},staleTime:6e4,enabled:o.length>0}),l=new Map;for(const[c,d]of Object.entries(a??{})){const u=r.get(d);u&&l.set(c,u)}return l}async function Gc(t,e,s,i,r,o){try{const a=await vl(s,i,o);En(t,e,{id:i,name:pl(i,r),metadata:a.messages,char:"/"})}catch(a){console.error("[slash] Failed to fetch prompt:",a),ue.error("Failed to load prompt. Please try again.")}}async function fv(t,e,s,i){try{const r=await pu(s,i);En(t,e,{id:i,name:i,metadata:r.contents,char:"/"})}catch(r){console.error("[slash] Failed to fetch resource:",r),ue.error("Failed to load resource. Please try again.")}}const mv=({editor:t,virtualMcpId:e})=>{const s=Mt(),{org:i}=xe(),r=Be({connectionId:e,orgId:i.id}),o=uv(e,i.id),a=S.useRef(o);a.current=o;const l=ct.virtualMcpPrompts(e,i.id),c=ct.virtualMcpResources(e,i.id),d=["slash-mention",i.id,e??"default"],[u,h]=S.useState(null),f=S.useRef(null),m=S.useRef(!1),p=async({item:x,range:b})=>{if(ne("chat_picker_item_selected",{picker:"/",item_kind:x.kind,item_name:x.name}),m.current=!0,!!r)if(x.kind==="prompt"){if(x.arguments&&x.arguments.length>0){h({range:b,item:x});return}const y=ni(x._meta);await Gc(t,b,r,x.name,y)}else x.uri&&await fv(t,b,r,x.uri)},g=async x=>{if(!u||!r)return;const{range:b,item:y}=u,C=ni(y._meta);await Gc(t,b,r,y.name,C,x),h(null)},_=async x=>{const{query:b}=x;if(!r)return[];const[y,C]=await Promise.all([pv(s,l,r),gv(s,c,r)]),k=b.trim().toLowerCase(),w=(y??[]).filter(j=>!k||j.name.toLowerCase().includes(k)||j.title?.toLowerCase().includes(k)||j.description?.toLowerCase().includes(k)).map(j=>({name:j.name,title:j.title,description:j.description,icon:a.current.get(j.name)?.icon??null,kind:"prompt",arguments:j.arguments,_meta:j._meta})),V=(C??[]).filter(j=>!k||j.uri.toLowerCase().includes(k)||j.name?.toLowerCase().includes(k)||j.description?.toLowerCase().includes(k)).map(j=>({name:j.name??j.uri,title:j.name,description:j.description,kind:"resource",uri:j.uri}));return[...w,...V]},v=u?.item.kind==="prompt"?{name:u.item.name,arguments:u.item.arguments,description:u.item.description}:null;return n.jsxs(n.Fragment,{children:[n.jsx(ef,{editor:t,char:"/",pluginKey:"slashDropdownMenu",queryKey:d,queryFn:_,onSelect:p,onOpenChange:x=>{if(x)f.current=Date.now(),m.current=!1,ne("chat_picker_opened",{picker:"/"});else{const b=f.current;ne("chat_picker_closed",{picker:"/",outcome:m.current?"selected":"dismissed",duration_ms:b?Date.now()-b:null}),f.current=null}}}),n.jsx(Ol,{prompt:v,setPrompt:()=>h(null),onSubmit:g})]})};async function pv(t,e,s){let i=t.getQueryData(e);return i?t.fetchQuery({queryKey:e,queryFn:()=>$r(s),staleTime:6e4}).catch(()=>{}):i=await t.fetchQuery({queryKey:e,queryFn:()=>$r(s),staleTime:6e4}),i?.prompts??[]}async function gv(t,e,s){let i=t.getQueryData(e);return i?t.fetchQuery({queryKey:e,queryFn:()=>wn(s),staleTime:6e4}).catch(()=>{}):i=await t.fetchQuery({queryKey:e,queryFn:()=>wn(s),staleTime:6e4}),i?.resources??[]}function _v(t){return[mg.configure({heading:!1,blockquote:!1,codeBlock:!1,horizontalRule:!1,dropcursor:!1}),i1.configure({placeholder:()=>t.current??"Ask anything, / for prompts, @ for agents & resources...",showOnlyWhenEditable:!1}),Gp,Yp]}function tf({tiptapDoc:t,setTiptapDoc:e,disabled:s=!1,enterToSubmit:i=!1,placeholder:r,onSubmit:o,children:a}){const l=S.useRef(o),c=S.useRef(e),d=S.useRef(i),u=S.useRef(r),h=ug({extensions:_v(u),content:t||"",editorProps:{attributes:{"data-chat-input":"true",class:"prose prose-sm max-w-none focus:outline-none w-full h-full text-[15px] p-[18px]"},handleKeyDown:(f,m)=>m.key==="Enter"&&!m.shiftKey&&d.current?(m.preventDefault(),l.current?.(),!0):!1},onUpdate:({editor:f})=>{c.current(f?.getJSON())}});return S.useEffect(()=>{h?.setEditable(!s)},[h,s]),S.useEffect(()=>{l.current=o},[o]),S.useEffect(()=>{c.current=e},[e]),S.useEffect(()=>{d.current=i},[i]),S.useEffect(()=>{u.current=r},[r]),S.useEffect(()=>{if(h?.isDestroyed)return;const f=JSON.stringify(h?.getJSON()),m=JSON.stringify(t||{type:"doc",content:[]});f!==m&&h.commands.setContent(t||{type:"doc",content:[]})},[h,t]),n.jsx(fg.Provider,{value:{editor:h},children:a})}function sf(t){const e=B.c(26),{disabled:s,virtualMcpId:i,showFileUploader:r,selectedModel:o,onUnsupportedFile:a,ref:l,className:c}=t,d=s===void 0?!1:s,u=r===void 0?!1:r,{editor:h}=oo();let f,m;if(e[0]!==h?(f=()=>({focus:()=>{h?.commands.focus()},clear:()=>{h?.commands.clearContent(!0)},appendText:V=>{if(!h)return;const j=h.state.doc.textContent.trim()==="";h.commands.focus("end"),j||h.commands.insertContent(" "),h.commands.insertContent(V)},syncVoiceText:(V,j)=>{if(h&&(h.commands.setContent(V||{type:"doc",content:[]}),j)){h.commands.focus("end");const I=h.state.doc.textContent.trim().length>0;h.commands.insertContent(I?" "+j:j)}},restoreContent:V=>{h&&h.commands.setContent(V||{type:"doc",content:[]})}}),m=[h],e[0]=h,e[1]=f,e[2]=m):(f=e[1],m=e[2]),S.useImperativeHandle(l??null,f,m),!h)return null;const p=d&&"cursor-not-allowed opacity-70",g=d&&"[&_.ProseMirror]:cursor-not-allowed";let _;e[3]!==c||e[4]!==p||e[5]!==g?(_=J("overflow-y-auto relative flex-1 max-h-[164px] min-h-[20px] w-full flex flex-col",c,"[&_.ProseMirror]:outline-none [&_.ProseMirror]:min-h-[20px] [&_.ProseMirror]:flex-1","[&_.ProseMirror_p.is-editor-empty:first-child::before]:content-[attr(data-placeholder)]","[&_.ProseMirror_p.is-editor-empty:first-child::before]:text-muted-foreground","[&_.ProseMirror_p.is-editor-empty:first-child::before]:opacity-50","[&_.ProseMirror_p.is-editor-empty:first-child::before]:float-left","[&_.ProseMirror_p.is-editor-empty:first-child::before]:pointer-events-none","[&_.ProseMirror_p.is-editor-empty:first-child::before]:h-0",p,g),e[3]=c,e[4]=p,e[5]=g,e[6]=_):_=e[6];let v;e[7]!==h||e[8]!==_?(v=n.jsx(pg,{editor:h,className:_}),e[7]=h,e[8]=_,e[9]=v):v=e[9];const x=i??null;let b;e[10]!==h||e[11]!==x?(b=n.jsx(S.Suspense,{fallback:null,children:n.jsx(mv,{editor:h,virtualMcpId:x})}),e[10]=h,e[11]=x,e[12]=b):b=e[12];const y=i??null;let C;e[13]!==h||e[14]!==y?(C=n.jsx(S.Suspense,{fallback:null,children:n.jsx(hv,{editor:h,virtualMcpId:y})}),e[13]=h,e[14]=y,e[15]=C):C=e[15];let k;e[16]!==h||e[17]!==a||e[18]!==o||e[19]!==u?(k=u&&o?n.jsx(Gx,{editor:h,selectedModel:o,onUnsupportedFile:a}):null,e[16]=h,e[17]=a,e[18]=o,e[19]=u,e[20]=k):k=e[20];let w;return e[21]!==b||e[22]!==C||e[23]!==k||e[24]!==v?(w=n.jsxs(n.Fragment,{children:[v,b,C,k]}),e[21]=b,e[22]=C,e[23]=k,e[24]=v,e[25]=w):w=e[25],w}function ya(t){const e=B.c(3),[s]=yi();let i;return e[0]!==s.enableSounds||e[1]!==t?(i=()=>{s.enableSounds&&c_(t.dataUri).catch(o=>{console.warn(`[sound] ${t.name} playback failed:`,o)})},e[0]=s.enableSounds,e[1]=t,e[2]=i):i=e[2],i}const xv={name:"switch-005",dataUri:"data:audio/mpeg;base64,SUQzBAAAAAAAIlRTU0VAAAAOAAADTGF2ZjYyLjMuMTAwAAAAAAAAAAAAAAD/+1DAAAAAAAAAAAAAAAAAAAAAAABJbmZvAAAADwAAABkAABU4ABMTEx0dHR0nJycnMTExMTs7OztERERETk5OTlhYWFhiYmJibGxsbHZ2dnZ/f39/iYmJiZOTk5OdnZ2dp6enp7GxsbG7u7u7xMTExM7Ozs7Y2NjY4uLi4uzs7Oz29vb2/////wAAAABMYXZjNjIuMTEAAAAAAAAAAAAAAAAkBVYAAAAAAAAVOPCP8KUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//tQxAAACEwDXvQRAAG8Ii93HtACUCAABAKCJwfaCEHwfeoEAQdEAYygIHBOCAIAgCAJh9QIOg+D5/ygPh/wfB8DuKAgCHyn9QPh/5SCDv+CEHAQdxOD4B27c39tbckkqYbBAYAN9bNJLB+aXAf5wQAKdzxfbmrVIRQ4xNx3HwnoDmLhfMhgJiiw/HREXNCHqjvHEPEG8QjBYlxQNepJAT0kC8ip6JzSWj1TasoG+iyycbf2Uil1ovf1f/oUtR1qP+s1WSBFKoAAU02BDjMhuP/7UsQEgws8bRpd8YABJYPeBf9wCGXTGxBYcw5AJFMFMAmQQAhGAxgLBgHIAMYAAALhgAchipbe/91aU1VV4zcZj1Vf1XgYCIMBNrsBAIGs9/Ue4i/xFPeqCqwViI9/UeLf///rOngdA3OPHFjmOBv+EQnGahgaZxVplmkAH5JadDTQlNCEuGNiWYbCCONWdUJg6HXNazFdu1T+VgaEpOP70exv7f2/4b/yH//2/4cqCX/zWRUrIw+IPNMNlDnjAXQas/I4AzmYifA0tMSCgQDF//tSxBCDSzzi3k/sQwEyCtjJ/rBZAk+Uqj1YhA5YMCAAMwgOUchTkK7OR7LbMl0W1H6SvzG0Q2ZzfKUhnmTobv9DNhS1v7P8h//8Gv8gTRt1jReZ7YEjmMQg9hhwwMycHooasFmZyjcZGBKJD+IwbMCQQLoi+IQXCcIoydKoilI2MWFS5uJdDEu2taRrYI2ZSqKY50pJLv2NfjUAAuQAMfqVQ/T3PDQgMJMeEZ45hJzY6MNoFMxqTj1zNGQKJjAxEsSCBgQJBSIL0mcKYQJfVAn/+1LEGwLKlEKrD3MiYcuMkVa/wABB8Vh6M1q1epbvXwWBURhkyEhWZ/////////////9gjZ/Wt4w+4MNMCpE4TBYQl4w1IHvMDdA2zBngBMwc8COMDhCpDAfgOAAgrBgNYU+YC0FBGAkAMpgWoSCYAGESGBGAKBgXgJOdiOJmMCmNwCYNDJhYRPykRCJhTBnEUzlsjv4UNLj/z97n3Mv/7z1nZqyitYAZIqErIwMwJAqEw0GAAMFptJMaqFwB8CQIWlhuhuDAwNjfuwrQFAYXCf/7UsQVAA+9PTP42gYRdiIu9zBwAPbFUCi0DAhgNcS+7cDwVgM05A9bUDeuQMyE/u3CygVISgZhpIau/9PhdQG2C9DpxZZJmn/dn/Psmt0EFm////l84ThUTopE4VD/9JkubOGasTvN30C20G21qgUCkVCoUCgPMywrPCGly27V5q5t24vl/8jSlSAPCxzNseNCw3oh3NGBu4BZJ5hv7DRSfR/+eWG7nA8IKh2Olv5iz3q5m3//Joxo3JqNyYkSuGt/k6D4DeoBOHmHdl0dkZYA//tSxAUAC4B1Z/2DADEcA17Z/uhI4Yoik/TrZo+ww7UtmpW4LDWu2IacoJKJJeTSM+ZmAYBEiU+ZnnAwCn1VVVV6JUJQVnioKhrgqdKgqGpUFeCp0sDR3ztQNREDRUFioKuxKCpYGQBlRIBk+aLwb8KblGQVDdphPYTUdBOGbVpAaTF6ZdjEV0iRUZRCYkA4oUQDx5zqDugtXvza/7fuNNvfZ+j9v+T/2f//J/4cAAOTpE5K4zksR9MfIB+TDcQTI4gNs1XKAzEFUrGkxABYEBb/+1LEEYNKrEjgT/TCwYYVmUX+mHoKgWhKU5Eiw9SFIRmppw+3fYo4siPhUFeexM8KgIO6wVuPDDy01qeRaVbw357//y3+o8M0pBNlNLCGBzGKwyYw2IIFOE1WNTjRM6x8MlA1AxDhUHTAkEiyKpnbWrLcaOBotBUKbk1pypcWDAIK00AhKLGkUco6q9VWvM53mcaq3tVa8zjTM/tX//EDP//////////XAAmrwAAPoKwcw0ShDCZD/BQlhzinxQdorsOuXTEIC01ZkJyu4k/qPP/7UsQUAEjkrrkvZaPBIRXUoe5QObfMhYKX9RVgTPqCSCaSCaSC0XVdV1f/////6IAlguuAJSiDRNloNBsZg+0+Ts8MMCn81WUTRAlIi+GHECD0y8AWDIqswYsxGOSKVV7MqOni8tkVOip0fZX/////9HrMCbAz2EHGS4GKAAiRAAAYAcDdKd4G6Z/nwYgJ0ZAIgZyC8aPAs/iPBhwMpWDQNARltNS5Y61v//9i8Yl4SkFkIGTkAc0UBrIYLPA4MYBEy+YLMRuY4nhTC3hZA68H//tSxCoAyQC6mY6CkWDJBIsBz/QUrgNmahSzcrYw0/HhfnMAZBojDsgTFkDR5MDkG/DZEbk2FCmowqdqv2TYABiJwqqYjaQRGZ1URZ1DhSsdiHX/GBu0QpzIBNSaLqZ0ARkwFARxMrpt/Eh47mbQAhhU6sisFUxBTUUzLjEwMFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVX/+1LESoHHJCRaj/dmYAIAQAAQAARVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVTEFNRTMuMTAwVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVf/7UsSLg8AAAaQAAAAgAAA0gAAABFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVTEFNRTMuMTAwVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//tSxKGDwAABpAAAACAAADSAAAAEVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVMQU1FMy4xMDBVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//tSxKGDwAABpAAAACAAADSAAAAEVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVMQU1FMy4xMDBVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//tSxKGDwAABpAAAACAAADSAAAAEVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVMQU1FMy4xMDBVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVX/+1LEoYPAAAGkAAAAIAAANIAAAARVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVUxBTUUzLjEwMFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVf/7UsShg8AAAaQAAAAgAAA0gAAABFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVTEFNRTMuMTAwVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//tSxKGDwAABpAAAACAAADSAAAAEVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVMQU1FMy4xMDBVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVX/+1LEoYPAAAGkAAAAIAAANIAAAARVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVUxBTUUzLjEwMFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//tSxKGDwAABpAAAACAAADSAAAAEVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVMQU1FMy4xMDBVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//tSxKGDwAABpAAAACAAADSAAAAEVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVMQU1FMy4xMDBVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//tSxKGDwAABpAAAACAAADSAAAAEVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVMQU1FMy4xMDBVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//tSxKGDwAABpAAAACAAADSAAAAEVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVMQU1FMy4xMDBVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//tSxKGDwAABpAAAACAAADSAAAAEVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVMQU1FMy4xMDBVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV",duration:.609,format:"mp3",license:"CC0",author:"Kenney"},vv=[{src:"/connections/gmail.png",name:"Gmail"},{src:"/connections/perplexity.png",name:"Perplexity"},{src:"/connections/github.png",name:"GitHub"}];function bv(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx("div",{className:"flex items-center -space-x-1.5",children:vv.map(yv)}),t[0]=e):e=t[0],e}function yv(t){return n.jsx("img",{src:t.src,alt:t.name,className:"size-5 rounded-sm ring-1 ring-border object-cover bg-white"},t.name)}function Sv(t){const e=B.c(129),{disabled:s,onOpenConnections:i,virtualMcpId:r}=t,[o,a]=S.useState(!1),l=ya(xv),{org:c}=xe(),{editor:d}=oo();let u;e[0]!==c.id||e[1]!==r?(u={connectionId:r,orgId:c.id},e[0]=c.id,e[1]=r,e[2]=u):u=e[2];const h=Be(u);let f;e[3]!==c.id||e[4]!==r?(f=ct.virtualMcpPrompts(r,c.id),e[3]=c.id,e[4]=r,e[5]=f):f=e[5];const m=f;let p;e[6]!==h?(p=()=>$r(h),e[6]=h,e[7]=p):p=e[7];const g=o&&!!h;let _;e[8]!==m||e[9]!==p||e[10]!==g?(_={queryKey:m,queryFn:p,staleTime:6e4,enabled:g},e[8]=m,e[9]=p,e[10]=g,e[11]=_):_=e[11];const{data:v,isLoading:x}=Ki(_);let b;e[12]!==v?.prompts?(b=v?.prompts??[],e[12]=v?.prompts,e[13]=b):b=e[13];const y=b,[C,k]=S.useState(null),{credentialId:w,imageModel:V,setImageModel:j,deepResearchModel:I,setDeepResearchModel:T,chatMode:R,setChatMode:N,simpleModeEnabled:A}=ai(),E=R==="plan",[M,L]=S.useState(!1),[D,P]=S.useState(!1),{models:O,isLoading:z}=hu(M||D?w??void 0:void 0);let $,q,F,G,H,U,Y,W,K,ee,Z,X,ie;if(e[14]!==C||e[15]!==O||e[16]!==R||e[17]!==h||e[18]!==I||e[19]!==s||e[20]!==d||e[21]!==V||e[22]!==M||e[23]!==z||e[24]!==E||e[25]!==i||e[26]!==o||e[27]!==l||e[28]!==D||e[29]!==N||e[30]!==T||e[31]!==j||e[32]!==A){const te=O.filter(Vv),he=O.filter(wv);let we;e[46]!==R||e[47]!==E||e[48]!==l||e[49]!==N?(we=()=>{l();const pe=E?"default":"plan";ne("chat_mode_changed",{from_mode:R,to_mode:pe,source:"tools_popover"}),N(pe),a(!1)},e[46]=R,e[47]=E,e[48]=l,e[49]=N,e[50]=we):we=e[50];const Ee=we;let Ie;e[51]!==i?(Ie=()=>{i(),a(!1)},e[51]=i,e[52]=Ie):Ie=e[52],F=Ie;let De;e[53]!==h||e[54]!==d?(De=async(pe,$t)=>{if(!d||!h)return;const zt=ni(pe._meta),us={from:d.state.selection.from,to:d.state.selection.to};try{const sn=await vl(h,pe.name,$t);En(d,us,{id:pe.name,name:pl(pe.name,zt),metadata:sn.messages,char:"/"})}catch{ue.error("Failed to load prompt. Please try again.")}},e[53]=h,e[54]=d,e[55]=De):De=e[55];const Pe=De;let ye;e[56]!==Pe?(ye=async pe=>{a(!1);const $t=!!(pe.arguments&&pe.arguments.length>0);if(ne("chat_prompt_inserted",{prompt_name:pe.name,with_arguments:$t}),$t){k(pe);return}await Pe(pe)},e[56]=Pe,e[57]=ye):ye=e[57],H=ye;let Ae;e[58]!==C||e[59]!==Pe?(Ae=async pe=>{C&&(await Pe(C,pe),k(null))},e[58]=C,e[59]=Pe,e[60]=Ae):Ae=e[60],G=Ae;let fe;e[61]!==l||e[62]!==j?(fe=pe=>{l(),ne("chat_image_model_selected",{model_id:pe.modelId,model_title:pe.title,provider:pe.providerId??null}),j(pe),a(!1)},e[61]=l,e[62]=j,e[63]=fe):fe=e[63];const ke=fe;let Ze;e[64]!==l||e[65]!==T?(Ze=pe=>{l(),ne("chat_search_model_selected",{model_id:pe.modelId,model_title:pe.title,provider:pe.providerId??null}),T(pe),a(!1)},e[64]=l,e[65]=T,e[66]=Ze):Ze=e[66];const Ct=Ze;let ze;e[67]!==R||e[68]!==l||e[69]!==N?(ze=()=>{l();const pe=R==="gen-image"?"default":"gen-image";ne("chat_mode_changed",{from_mode:R,to_mode:pe,source:"tools_popover"}),N(pe),a(!1)},e[67]=R,e[68]=l,e[69]=N,e[70]=ze):ze=e[70];const Kt=ze;let kt;e[71]!==R||e[72]!==l||e[73]!==N?(kt=()=>{l();const pe=R==="web-search"?"default":"web-search";ne("chat_mode_changed",{from_mode:R,to_mode:pe,source:"tools_popover"}),N(pe),a(!1)},e[71]=R,e[72]=l,e[73]=N,e[74]=kt):kt=e[74];const Re=kt,Le=R==="gen-image",Ye=R==="web-search";q=Es,W=o,e[75]!==R||e[76]!==o?(K=pe=>{pe&&!o&&ne("chat_tools_popover_opened",{chat_mode:R}),a(pe)},e[75]=R,e[76]=o,e[77]=K):K=e[77];let qt,xt;e[78]===Symbol.for("react.memo_cache_sentinel")?(qt=n.jsx(Jh,{size:14}),xt=n.jsx("span",{className:"hidden sm:inline",children:"Tools"}),e[78]=qt,e[79]=xt):(qt=e[78],xt=e[79]),e[80]!==s?(ee=n.jsx(Is,{asChild:!0,children:n.jsxs(ae,{type:"button",variant:"ghost",size:"default",disabled:s,className:"text-muted-foreground hover:text-foreground",children:[qt,xt]})}),e[80]=s,e[81]=ee):ee=e[81],$=Rs,Z="start",X="w-52 p-1.5";const vt=E&&"text-violet-600 dark:text-violet-400";let bt;e[82]!==vt?(bt=J(vt),e[82]=vt,e[83]=bt):bt=e[83];const bs=E&&"text-violet-500";let Ue;e[84]!==bs?(Ue=J(bs),e[84]=bs,e[85]=Ue):Ue=e[85];let jt;e[86]!==Ue?(jt=n.jsx(ou,{size:16,className:Ue}),e[86]=Ue,e[87]=jt):jt=e[87];let Nt;e[88]===Symbol.for("react.memo_cache_sentinel")?(Nt=n.jsx("span",{className:"flex-1",children:"Plan mode"}),e[88]=Nt):Nt=e[88];let wt;e[89]!==E?(wt=E&&n.jsx("span",{className:"text-xs text-violet-500 font-medium",children:"On"}),e[89]=E,e[90]=wt):wt=e[90],e[91]!==Ee||e[92]!==bt||e[93]!==jt||e[94]!==wt?(ie=n.jsxs(at,{onClick:Ee,className:bt,children:[jt,Nt,wt]}),e[91]=Ee,e[92]=bt,e[93]=jt,e[94]=wt,e[95]=ie):ie=e[95],U=A?n.jsxs(at,{onClick:Kt,className:J(Le&&"text-pink-600 dark:text-pink-400"),children:[n.jsx(pa,{size:16,className:J(Le&&"text-pink-500")}),n.jsx("span",{className:"flex-1",children:"Create image"}),Le&&n.jsx("span",{className:"text-xs text-pink-500 font-medium",children:"On"})]}):n.jsxs(kr,{open:M,onOpenChange:L,children:[n.jsxs("div",{className:"flex items-center rounded-lg",children:[n.jsxs(at,{onClick:Kt,disabled:!V,className:J("flex-1 rounded-r-none pr-1",Le&&"text-pink-600 dark:text-pink-400"),children:[n.jsx(pa,{size:16,className:J(Le&&"text-pink-500")}),n.jsx("span",{className:"flex-1",children:"Create image"}),Le&&n.jsx("span",{className:"text-xs text-pink-500 font-medium",children:"On"})]}),n.jsx(mc,{className:J("flex items-center justify-center rounded-r-lg rounded-l-none px-1.5 py-1.5 text-muted-foreground outline-hidden select-none","hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground","data-[state=open]:bg-accent data-[state=open]:text-accent-foreground"),children:n.jsx(Rn,{size:14})})]}),n.jsx(jr,{className:"w-80 max-h-72 overflow-y-auto p-1.5",children:z?n.jsxs("div",{className:"flex items-center gap-2 px-2 py-3 text-sm text-muted-foreground",children:[n.jsx(Me,{size:14,className:"animate-spin"}),"Loading models…"]}):te.length===0?n.jsx("div",{className:"px-2 py-3 text-sm text-muted-foreground",children:"No image models available"}):te.map(pe=>{const $t=V?.modelId===pe.modelId,zt=Vc(pe),us=pe.title.includes(": ")?pe.title.split(": ").slice(1).join(": "):pe.title;return n.jsxs(at,{onClick:()=>ke(pe),className:"flex items-center gap-2",children:[n.jsx("img",{src:zt,alt:"",className:"size-4 shrink-0 rounded-sm dark:bg-white dark:p-px"}),n.jsx("span",{className:"flex-1 text-sm truncate",children:us}),$t&&n.jsx(Jt,{size:14,className:"text-pink-500 shrink-0"})]},pe.modelId)})})]}),Y=A?n.jsxs(at,{onClick:Re,className:J(Ye&&"text-blue-600 dark:text-blue-400"),children:[n.jsx(Li,{size:16,className:J(Ye&&"text-blue-500")}),n.jsx("span",{className:"flex-1",children:"Web search"}),Ye&&n.jsx("span",{className:"text-xs text-blue-500 font-medium",children:"On"})]}):I&&n.jsxs(kr,{open:D,onOpenChange:P,children:[n.jsxs("div",{className:"flex items-center rounded-lg",children:[n.jsxs(at,{onClick:Re,className:J("flex-1 rounded-r-none pr-1",Ye&&"text-blue-600 dark:text-blue-400"),children:[n.jsx(Li,{size:16,className:J(Ye&&"text-blue-500")}),n.jsx("span",{className:"flex-1",children:"Web search"}),Ye&&n.jsx("span",{className:"text-xs text-blue-500 font-medium",children:"On"})]}),n.jsx(mc,{className:J("flex items-center justify-center rounded-r-lg rounded-l-none px-1.5 py-1.5 text-muted-foreground outline-hidden select-none","hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground","data-[state=open]:bg-accent data-[state=open]:text-accent-foreground"),children:n.jsx(Rn,{size:14})})]}),n.jsx(jr,{className:"w-80 max-h-72 overflow-y-auto p-1.5",children:z?n.jsxs("div",{className:"flex items-center gap-2 px-2 py-3 text-sm text-muted-foreground",children:[n.jsx(Me,{size:14,className:"animate-spin"}),"Loading models…"]}):he.map(pe=>{const $t=I?.modelId===pe.modelId,zt=Vc(pe),us=pe.title.includes(": ")?pe.title.split(": ").slice(1).join(": "):pe.title;return n.jsxs(at,{onClick:()=>Ct(pe),className:"flex items-center gap-2",children:[n.jsx("img",{src:zt,alt:"",className:"size-4 shrink-0 rounded-sm dark:bg-white dark:p-px"}),n.jsx("span",{className:"flex-1 text-sm truncate",children:us}),$t&&n.jsx(Jt,{size:14,className:"text-blue-500 shrink-0"})]},pe.modelId)})})]}),e[14]=C,e[15]=O,e[16]=R,e[17]=h,e[18]=I,e[19]=s,e[20]=d,e[21]=V,e[22]=M,e[23]=z,e[24]=E,e[25]=i,e[26]=o,e[27]=l,e[28]=D,e[29]=N,e[30]=T,e[31]=j,e[32]=A,e[33]=$,e[34]=q,e[35]=F,e[36]=G,e[37]=H,e[38]=U,e[39]=Y,e[40]=W,e[41]=K,e[42]=ee,e[43]=Z,e[44]=X,e[45]=ie}else $=e[33],q=e[34],F=e[35],G=e[36],H=e[37],U=e[38],Y=e[39],W=e[40],K=e[41],ee=e[42],Z=e[43],X=e[44],ie=e[45];let re;e[96]===Symbol.for("react.memo_cache_sentinel")?(re=n.jsxs(qh,{className:"gap-2",children:[n.jsx("span",{className:"flex size-4 items-center justify-center text-base font-medium text-muted-foreground",children:"/"}),n.jsx("span",{className:"flex-1",children:"Prompts"})]}),e[96]=re):re=e[96];let de;e[97]!==H||e[98]!==x||e[99]!==y?(de=x?n.jsxs("div",{className:"flex items-center gap-2 px-2 py-3 text-sm text-muted-foreground",children:[n.jsx(Me,{size:14,className:"animate-spin"}),"Loading prompts…"]}):y.length===0?n.jsx("div",{className:"px-2 py-3 text-sm text-muted-foreground",children:"No prompts available"}):y.map(te=>n.jsxs(at,{onClick:()=>H(te),className:"flex flex-col items-start gap-0.5",children:[n.jsx("span",{className:"font-medium text-sm capitalize",children:te.title||ro(te.name,ni(te._meta))}),te.description&&n.jsx("span",{className:"text-xs text-muted-foreground line-clamp-2",children:te.description})]},te.name)),e[97]=H,e[98]=x,e[99]=y,e[100]=de):de=e[100];let me;e[101]!==de?(me=n.jsxs(kr,{children:[re,n.jsx(jr,{className:"w-80 max-h-72 overflow-y-auto p-1.5",children:de})]}),e[101]=de,e[102]=me):me=e[102];let le,se;e[103]===Symbol.for("react.memo_cache_sentinel")?(le=n.jsx(qg,{size:16}),se=n.jsx("span",{className:"flex-1",children:"Connections"}),e[103]=le,e[104]=se):(le=e[103],se=e[104]);let _e;e[105]===Symbol.for("react.memo_cache_sentinel")?(_e=n.jsx(S.Suspense,{children:n.jsx(bv,{})}),e[105]=_e):_e=e[105];let ge;e[106]!==F?(ge=n.jsxs(at,{onClick:F,children:[le,se,_e]}),e[106]=F,e[107]=ge):ge=e[107];let Se;e[108]!==$||e[109]!==U||e[110]!==Y||e[111]!==me||e[112]!==ge||e[113]!==Z||e[114]!==X||e[115]!==ie?(Se=n.jsxs($,{align:Z,className:X,children:[ie,U,Y,me,ge]}),e[108]=$,e[109]=U,e[110]=Y,e[111]=me,e[112]=ge,e[113]=Z,e[114]=X,e[115]=ie,e[116]=Se):Se=e[116];let ve;e[117]!==q||e[118]!==W||e[119]!==K||e[120]!==ee||e[121]!==Se?(ve=n.jsxs(q,{open:W,onOpenChange:K,children:[ee,Se]}),e[117]=q,e[118]=W,e[119]=K,e[120]=ee,e[121]=Se,e[122]=ve):ve=e[122];let Ne;e[123]!==C||e[124]!==G?(Ne=n.jsx(Ol,{prompt:C,setPrompt:k,onSubmit:G}),e[123]=C,e[124]=G,e[125]=Ne):Ne=e[125];let Te;return e[126]!==ve||e[127]!==Ne?(Te=n.jsxs(n.Fragment,{children:[ve,Ne]}),e[126]=ve,e[127]=Ne,e[128]=Te):Te=e[128],Te}function wv(t){const e=t.modelId.toLowerCase().replace(/[^a-z0-9]/g,"");return e.includes("sonar")||e.includes("deepresearch")}function Vv(t){return t.capabilities?.includes("image")}function Cv({open:t,onOpenChange:e,onCreated:s}){const{org:i}=xe(),{data:r}=St.useSession(),{stdioEnabled:o}=hp(),a=Ps(),l=mo(),c=xu(),u=vu(c,"").items,h=Gi({resolver:Un(h_),defaultValues:{title:"",description:null,icon:null,ui_type:"HTTP",connection_url:"",connection_token:null,npx_package:"",stdio_command:"",stdio_args:"",stdio_cwd:"",env_vars:[]}}),f=h.watch("ui_type"),m=h.watch("connection_url"),p=h.watch("npx_package"),g=dr({uiType:f,connectionUrl:m??"",npxPackage:p??""})??Cc({uiType:f,connectionUrl:m??"",registryItems:u}),_=w=>{const V=w.trim();if(!V)return;const j=!!h.formState.dirtyFields.title,I=!!h.formState.dirtyFields.description,T=!!h.formState.dirtyFields.env_vars,R=A=>{if(A&&(!j&&!h.getValues("title").trim()&&A.title&&h.setValue("title",A.title,{shouldDirty:!1}),!I&&!(h.getValues("description")??"").trim()&&A.description&&h.setValue("description",A.description,{shouldDirty:!1}),!T&&A.envVarKeys?.length)){const E=h.getValues("env_vars")??[],M=new Set(E.map(D=>D.key)),L=A.envVarKeys.filter(D=>!M.has(D));L.length>0&&h.setValue("env_vars",[...E,...L.map(D=>({key:D,value:""}))],{shouldDirty:!0})}},N=f_(V);if(N&&o){h.setValue("ui_type","NPX",{shouldDirty:!0}),h.setValue("npx_package",N.packageName,{shouldDirty:!0}),h.setValue("connection_url","",{shouldDirty:!0}),h.setValue("connection_token",null,{shouldDirty:!0}),R(dr({uiType:"NPX",npxPackage:N.packageName}));return}if(V.startsWith("http://")||V.startsWith("https://")){const A=f==="HTTP"||f==="SSE"||f==="Websocket"?f:"HTTP";h.setValue("ui_type",A,{shouldDirty:!0}),h.setValue("connection_url",V,{shouldDirty:!0}),R(dr({uiType:A,connectionUrl:V})??Cc({uiType:A,connectionUrl:V,registryItems:u}));return}f==="NPX"&&R(dr({uiType:"NPX",npxPackage:V}))},v=w=>{w||h.reset(),e(w)},x=async w=>{let V,j=null,I=null,T=null;w.ui_type==="NPX"?(V="STDIO",j="",T=m_(w.npx_package||"",w.env_vars||[])):w.ui_type==="STDIO"?(V="STDIO",j="",T=p_(w.stdio_command||"",w.stdio_args||"",w.stdio_cwd,w.env_vars||[])):(V=w.ui_type,j=w.connection_url||"",I=w.connection_token||null);const R=yu("conn");try{await l.create.mutateAsync({id:R,title:w.title,description:w.description||null,connection_type:V,connection_url:j,connection_token:I,created_at:new Date().toISOString(),updated_at:new Date().toISOString(),created_by:r?.user?.id||"system",organization_id:i.id,icon:w.icon??null,app_name:null,app_id:null,connection_headers:T,oauth_config:null,configuration_state:null,metadata:null,tools:null,bindings:null,status:"inactive"}),h.reset(),e(!1),s?.(R)}catch{ue.error("Failed to create connection")}},b="Create Connection",y="Create a custom connection in your organization. Fill in the details below.",C=h.formState.isSubmitting?"Saving...":"Create Connection",k=n.jsxs("div",{className:"grid gap-4",children:[n.jsx(It,{control:h.control,name:"ui_type",render:({field:w})=>n.jsxs(Rt,{children:[n.jsx(os,{children:"Type *"}),n.jsxs(ei,{value:w.value,onValueChange:w.onChange,children:[n.jsx(Tt,{children:n.jsx(ti,{children:n.jsx(si,{})})}),n.jsxs(Zs,{children:[n.jsx(Ht,{value:"HTTP",children:n.jsxs("span",{className:"flex items-center gap-2",children:[n.jsx(Li,{className:"w-4 h-4"}),"HTTP"]})}),n.jsx(Ht,{value:"SSE",children:n.jsxs("span",{className:"flex items-center gap-2",children:[n.jsx(Li,{className:"w-4 h-4"}),"SSE"]})}),n.jsx(Ht,{value:"Websocket",children:n.jsxs("span",{className:"flex items-center gap-2",children:[n.jsx(Li,{className:"w-4 h-4"}),"Websocket"]})}),o&&n.jsxs(n.Fragment,{children:[n.jsx(Ht,{value:"NPX",children:n.jsxs("span",{className:"flex items-center gap-2",children:[n.jsx(Nr,{className:"w-4 h-4"}),"NPX Package"]})}),n.jsx(Ht,{value:"STDIO",children:n.jsxs("span",{className:"flex items-center gap-2",children:[n.jsx(bl,{className:"w-4 h-4"}),"Custom Command"]})})]})]})]}),n.jsx(Dt,{})]})}),f==="NPX"&&n.jsx(It,{control:h.control,name:"npx_package",render:({field:w})=>n.jsxs(Rt,{children:[n.jsx(os,{children:"NPM Package *"}),n.jsx(Tt,{children:n.jsx(gt,{placeholder:"@perplexity-ai/mcp-server",...w,value:w.value??"",onPaste:V=>{const j=V.clipboardData.getData("text");j&&(V.preventDefault(),h.setValue("npx_package",j.trim(),{shouldDirty:!0}),_(j))},onBlur:V=>{_(V.target.value),w.onBlur()}})}),n.jsx(Dt,{})]})}),f==="STDIO"&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"grid grid-cols-2 gap-4 items-start",children:[n.jsx(It,{control:h.control,name:"stdio_command",render:({field:w})=>n.jsxs(Rt,{children:[n.jsx(os,{children:"Command *"}),n.jsx(Tt,{children:n.jsx(gt,{placeholder:"node, bun, python...",...w,value:w.value??""})}),n.jsx(Dt,{})]})}),n.jsx(It,{control:h.control,name:"stdio_args",render:({field:w})=>n.jsxs(Rt,{children:[n.jsx(os,{children:"Arguments"}),n.jsx(Tt,{children:n.jsx(gt,{placeholder:"arg1 arg2 --flag value",...w,value:w.value??""})}),n.jsx(Dt,{})]})})]}),n.jsx(It,{control:h.control,name:"stdio_cwd",render:({field:w})=>n.jsxs(Rt,{children:[n.jsx(os,{children:"Working Directory"}),n.jsx(Tt,{children:n.jsx(gt,{placeholder:"/path/to/project (optional)",...w,value:w.value??""})}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Directory where the command will be executed"}),n.jsx(Dt,{})]})})]}),(f==="NPX"||f==="STDIO")&&n.jsx(It,{control:h.control,name:"env_vars",render:({field:w})=>n.jsxs(Rt,{children:[n.jsx(os,{children:"Environment Variables"}),n.jsx(Tt,{children:n.jsx(u_,{value:w.value??[],onChange:w.onChange})}),n.jsx(Dt,{})]})}),f!=="NPX"&&f!=="STDIO"&&n.jsxs(n.Fragment,{children:[n.jsx(It,{control:h.control,name:"connection_url",render:({field:w})=>n.jsxs(Rt,{children:[n.jsx(os,{children:"URL *"}),n.jsx(Tt,{children:n.jsx(gt,{placeholder:"https://example.com/mcp",...w,value:w.value??"",onPaste:V=>{const j=V.clipboardData.getData("text");j&&(V.preventDefault(),h.setValue("connection_url",j.trim(),{shouldDirty:!0}),_(j))},onBlur:V=>{_(V.target.value),w.onBlur()}})}),n.jsx(Dt,{})]})}),n.jsx(It,{control:h.control,name:"connection_token",render:({field:w})=>n.jsxs(Rt,{children:[n.jsx(os,{children:g?.token?.label??"Token (optional)"}),n.jsx(Tt,{children:n.jsx(gt,{type:"password",placeholder:g?.token?.placeholder??"Bearer token or API key",className:"ph-no-capture",...w,value:w.value??""})}),g?.token?.helperText&&n.jsxs("p",{className:"text-xs text-muted-foreground",children:[g.token.helperText,g.id==="github"&&n.jsxs(n.Fragment,{children:[" ","·"," ",n.jsx("a",{className:"text-foreground underline underline-offset-4 hover:text-foreground/80",href:"https://github.com/settings/personal-access-tokens",target:"_blank",rel:"noreferrer",children:"Open GitHub PAT settings"})]})]}),n.jsx(Dt,{})]})})]}),n.jsx(It,{control:h.control,name:"title",render:({field:w})=>n.jsxs(Rt,{children:[n.jsx(os,{children:"Name *"}),n.jsx(Tt,{children:n.jsx(gt,{placeholder:"My Connection",...w})}),n.jsx(Dt,{})]})}),n.jsx(It,{control:h.control,name:"description",render:({field:w})=>n.jsxs(Rt,{children:[n.jsx(os,{children:"Description"}),n.jsx(Tt,{children:n.jsx(ga,{placeholder:"A brief description of this connection",rows:3,...w,value:w.value??""})}),n.jsx(Dt,{})]})})]});return a?n.jsx(Ci,{open:t,onOpenChange:v,children:n.jsxs(Vi,{className:"max-h-[90vh]",children:[n.jsx(lo,{className:"pb-2",children:n.jsxs("div",{className:"flex items-start justify-between gap-4",children:[n.jsxs("div",{className:"flex-1 text-left",children:[n.jsx(wi,{children:b}),n.jsx(gg,{className:"mt-1",children:y})]}),n.jsx(_g,{asChild:!0,children:n.jsx(ae,{variant:"ghost",size:"icon",className:"shrink-0 -mt-1",children:n.jsx(ri,{size:16})})})]})}),n.jsx($i,{...h,children:n.jsxs("form",{onSubmit:h.handleSubmit(x),children:[n.jsx("div",{className:"overflow-y-auto px-4 pb-4",children:k}),n.jsx(xg,{children:n.jsx(ae,{type:"submit",disabled:h.formState.isSubmitting,className:"w-full",children:C})})]})})]})}):n.jsx(ss,{open:t,onOpenChange:v,children:n.jsxs(ts,{className:"sm:max-w-[525px]",children:[n.jsxs(hs,{children:[n.jsx(ds,{children:b}),n.jsx(ao,{children:y})]}),n.jsx($i,{...h,children:n.jsxs("form",{onSubmit:h.handleSubmit(x),children:[n.jsx("div",{className:"py-4",children:k}),n.jsxs(_l,{children:[n.jsx(ae,{type:"button",variant:"outline",onClick:()=>v(!1),children:"Cancel"}),n.jsx(ae,{type:"submit",disabled:h.formState.isSubmitting,className:"min-w-40",children:C})]})]})})]})})}function kv(t){const e=B.c(79),{mode:s,agentId:i,addedConnectionIds:r,onAdd:o,onCloneAndAdd:a,onConnectAndAdd:l,connectingItemId:c,search:d,onCreateConnection:u,onBrowseNavigate:h,defaultTab:f}=t,m=s===void 0?"add":s,p=f===void 0?"connected":f,{org:g}=xe(),_=S.useDeferredValue(d),v=d!==_;let x;e[0]!==_?(x=_.toLowerCase(),e[0]=_,e[1]=x):x=e[1];const b=x;let y;e[2]!==p?(y=fe=>fe??p,e[2]=p,e[3]=y):y=e[3];const[C,k]=fl(ml.connectionsTab(g.slug)+(p==="all"?":home-modal":":agent-modal"),y);let w;e[4]!==C||e[5]!==k?(w=fe=>{fe!==C&&ne("connections_dialog_tab_changed",{to_tab:fe}),k(fe)},e[4]=C,e[5]=k,e[6]=w):w=e[6];const V=w;let j;e[7]!==g.id?(j={connectionId:Pt,orgId:g.id},e[7]=g.id,e[8]=j):j=e[8];const I=Be(j);let T,R,N;if(e[9]!==I||e[10]!==_||e[11]!==g.id){N=_?.trim()?{operator:"or",conditions:[{field:["title"],operator:"contains",value:_.trim()},{field:["description"],operator:"contains",value:_.trim()}]}:void 0;const fe={...N&&{where:N},orderBy:[{field:["updated_at"],direction:"asc"}],limit:100,offset:0},ke=JSON.stringify(fe);R=g_,T=ct.collectionListInfinite(I,g.id,"","CONNECTIONS",ke),e[9]=I,e[10]=_,e[11]=g.id,e[12]=T,e[13]=R,e[14]=N}else T=e[12],R=e[13],N=e[14];let A;e[15]!==I||e[16]!==N?(A=async fe=>{const{pageParam:ke}=fe,Ze=ke===void 0?0:ke;return(await I.callTool({name:"COLLECTION_CONNECTIONS_LIST",arguments:{...N&&{where:N},orderBy:[{field:["updated_at"],direction:"asc"}],limit:100,offset:Ze}})).structuredContent},e[15]=I,e[16]=N,e[17]=A):A=e[17];let E;e[18]!==T||e[19]!==A?(E={queryKey:T,queryFn:A,initialPageParam:0,getNextPageParam:Rv,staleTime:3e4},e[18]=T,e[19]=A,e[20]=E):E=e[20];const{data:M,fetchNextPage:L,hasNextPage:D,isFetchingNextPage:P}=R(E),O=M?.pages.flatMap(Iv)??[],z=d_(O),$=new Set(O.filter(Ev).map(Av)),q=xu(),F=vu(q,_),G=kc(F.loadMore,F.hasMore,F.isLoadingMore),H=kc(L,D??!1,P),U=C==="all"||!!b,Y=U?F.items.filter(fe=>{const ke=S_(fe);return!(ke&&$.has(ke))}):[],W=Y.filter(Nv),K=Y.filter(jv);let ee;e[21]!==r?(ee=fe=>fe.some(ke=>r.has(ke.id)),e[21]=r,e[22]=ee):ee=e[22];const Z=ee;let X;e[23]!==r||e[24]!==i||e[25]!==c||e[26]!==Z||e[27]!==m||e[28]!==o||e[29]!==h||e[30]!==a?(X=(fe,ke,Ze,Ct,ze)=>{const Kt=Z(ze),kt=ze.find(Le=>!r.has(Le.id)),Re=ze[0];if(m==="browse"){const Le=gu(Re);return n.jsx(Ro,{connection:{title:ke,icon:Ze,description:ze.length>1?`${ze.length} instances`:Ct??void 0},fallbackIcon:n.jsx(Nr,{}),headerActionsAlwaysVisible:!0,headerActions:n.jsxs(Ac,{variant:"secondary",className:"text-xs gap-1 font-normal",children:[n.jsx(Jt,{size:11})," Connected"]}),onClick:()=>{ne("connection_browse_clicked",{app_name:Re.app_name??null,connection_id:Re.id,instances_count:ze.length}),h?.(Le)}},fe)}return n.jsx(Ro,{connection:{title:ke,icon:Ze,description:Ct},fallbackIcon:n.jsx(Nr,{}),headerActionsAlwaysVisible:!0,headerActions:n.jsxs("div",{className:"flex items-center gap-1.5",children:[Kt&&n.jsxs(Ac,{variant:"secondary",className:"text-xs gap-1 font-normal",children:[n.jsx(Jt,{size:11})," Added"]}),n.jsx(ae,{variant:"outline",size:"sm",className:"h-7 px-3 text-xs font-medium",disabled:c!==null,onClick:Le=>{Le.stopPropagation(),kt?(ne("connection_add_clicked",{action:"use_existing",app_name:Re.app_name??null,connection_id:kt.id}),i&&ne("agent_connection_attached",{agent_id:i,connection_id:kt.id,app_name:Re.app_name??null,mode:"existing"}),o(kt.id)):(ne("connection_add_clicked",{action:"clone",app_name:Re.app_name??null,base_connection_id:Re.id}),a(Re))},children:"Add"})]})},fe)},e[23]=r,e[24]=i,e[25]=c,e[26]=Z,e[27]=m,e[28]=o,e[29]=h,e[30]=a,e[31]=X):X=e[31];const ie=X;let re;e[32]!==c||e[33]!==m||e[34]!==l?(re=fe=>{const ke=fe._meta?.["mcp.mesh"],Ze=ke?.friendlyName||ke?.friendly_name||fe.server?.title||fe.title||fe.server?.name||fe.name||fe.id||"",Ct=fe.server?.description||fe.description||null,ze=fe.server?.icons?.[0]?.src||V_(fe.server?.repository)||null;return n.jsx(Ro,{connection:{title:Ze,description:Ct,icon:ze},fallbackIcon:n.jsx(Nr,{}),headerActionsAlwaysVisible:!0,headerActions:n.jsx(ae,{variant:"outline",size:"sm",className:"h-7 px-3 text-xs font-medium",disabled:c!==null,onClick:Kt=>{Kt.stopPropagation(),ne("connection_add_clicked",{action:"connect_new",registry_item_id:fe.id,app_name:fe._meta?.["mcp.mesh"]?.friendlyName||fe.server?.name||fe.name||null}),l(fe)},children:c===fe.id?n.jsx(Me,{size:14,className:"animate-spin"}):m==="browse"?"Connect":"Add"})},`catalog-${fe.id}`)},e[32]=c,e[33]=m,e[34]=l,e[35]=re):re=e[35];const de=re;let me;e[36]!==C||e[37]!==V||e[38]!==u||e[39]!==b?(me=!b&&n.jsxs("div",{className:"flex items-center justify-between px-5 py-3 border-b border-border shrink-0",children:[n.jsx(bu,{tabs:[{id:"all",label:"All"},{id:"connected",label:"Connected"}],activeTab:C,onTabChange:fe=>V(fe)}),n.jsxs(ae,{variant:"outline",size:"sm",className:"h-7 px-2 text-sm",onClick:()=>{ne("connections_dialog_custom_clicked"),u()},children:[n.jsx(Qt,{size:12}),"Custom Connection"]})]}),e[36]=C,e[37]=V,e[38]=u,e[39]=b,e[40]=me):me=e[40];const le=v&&"opacity-50 pointer-events-none";let se;e[41]!==le?(se=J("flex-1 overflow-auto p-5 transition-opacity duration-150",le),e[41]=le,e[42]=se):se=e[42];const _e="grid grid-cols-[repeat(auto-fill,minmax(260px,1fr))] gap-4";let ge;e[43]!==ie?(ge=fe=>{if(fe.type==="group")return ie(fe.key,fe.title,fe.icon,null,fe.connections);const ke=fe.connection;return ie(ke.id,ke.title,ke.icon,ke.description??null,[ke])},e[43]=ie,e[44]=ge):ge=e[44];const Se=z.map(ge);let ve;e[45]!==H?(ve=n.jsx("div",{ref:H,className:"col-span-full h-1"}),e[45]=H,e[46]=ve):ve=e[46];let Ne;e[47]!==P?(Ne=P&&n.jsx("div",{className:"col-span-full flex justify-center py-6",children:n.jsx(Me,{size:24,className:"animate-spin text-muted-foreground"})}),e[47]=P,e[48]=Ne):Ne=e[48];const Te=U&&W.length>0&&n.jsxs("div",{className:"col-span-full flex items-center gap-2 mt-2",children:[n.jsx(Gg,{size:13,className:"text-muted-foreground shrink-0"}),n.jsx("span",{className:"text-sm font-medium text-muted-foreground whitespace-nowrap",children:"Verified"}),n.jsx("div",{className:"flex-1 h-px bg-border"})]}),te=U&&W.map(de),he=U&&K.length>0&&n.jsxs("div",{className:"col-span-full flex items-center gap-2 mt-2",children:[n.jsx("span",{className:"text-sm font-medium text-muted-foreground whitespace-nowrap",children:"All connections"}),n.jsx("div",{className:"flex-1 h-px bg-border"})]}),we=U&&K.map(de);let Ee;e[49]!==G||e[50]!==q||e[51]!==U?(Ee=U&&q.length>0&&n.jsx("div",{ref:G,className:"col-span-full h-1"}),e[49]=G,e[50]=q,e[51]=U,e[52]=Ee):Ee=e[52];let Ie;e[53]!==F.isLoadingMore||e[54]!==U?(Ie=U&&F.isLoadingMore&&n.jsx("div",{className:"col-span-full flex justify-center py-6",children:n.jsx(Me,{size:24,className:"animate-spin text-muted-foreground"})}),e[53]=F.isLoadingMore,e[54]=U,e[55]=Ie):Ie=e[55];let De;e[56]!==Se||e[57]!==ve||e[58]!==Ne||e[59]!==Te||e[60]!==te||e[61]!==he||e[62]!==we||e[63]!==Ee||e[64]!==Ie?(De=n.jsxs("div",{className:_e,children:[Se,ve,Ne,Te,te,he,we,Ee,Ie]}),e[56]=Se,e[57]=ve,e[58]=Ne,e[59]=Te,e[60]=te,e[61]=he,e[62]=we,e[63]=Ee,e[64]=Ie,e[65]=De):De=e[65];let Pe;e[66]!==C||e[67]!==z.length||e[68]!==K||e[69]!==d||e[70]!==W?(Pe=z.length===0&&W.length===0&&K.length===0&&n.jsx("div",{className:"flex items-center justify-center h-48 text-sm text-muted-foreground",children:d?`No connections match "${d}"`:C==="connected"?"No connections yet":"No connections available"}),e[66]=C,e[67]=z.length,e[68]=K,e[69]=d,e[70]=W,e[71]=Pe):Pe=e[71];let ye;e[72]!==se||e[73]!==De||e[74]!==Pe?(ye=n.jsxs("div",{className:se,children:[De,Pe]}),e[72]=se,e[73]=De,e[74]=Pe,e[75]=ye):ye=e[75];let Ae;return e[76]!==me||e[77]!==ye?(Ae=n.jsxs(n.Fragment,{children:[me,ye]}),e[76]=me,e[77]=ye,e[78]=Ae):Ae=e[78],Ae}function jv(t){return!t.verified&&!t._meta?.["mcp.mesh"]?.verified&&!t.meta?.verified}function Nv(t){return t.verified||t._meta?.["mcp.mesh"]?.verified||t.meta?.verified}function Av(t){return t.app_name}function Ev(t){return t.app_name}function Iv(t){return t?.items??[]}function Rv(t,e){if(t?.hasMore)return e.reduce(Tv,0)}function Tv(t,e){return t+(e?.items?.length??0)}function Fl({open:t,onOpenChange:e,defaultTab:s,initialSearch:i="",...r}){const o=r.mode??"add",a="agentId"in r?r.agentId:void 0,l="addedConnectionIds"in r?r.addedConnectionIds??new Set:new Set,c="onAdd"in r&&r.onAdd?r.onAdd:V=>{},d=(V,j,I)=>{a&&ne("agent_connection_attached",{agent_id:a,connection_id:V,app_name:j,mode:I})},[u,h]=S.useState(null),[f,m]=S.useState(i),[p,g]=S.useState(!1),{org:_}=xe(),{data:v}=St.useSession(),x=mo(),b=Mt(),y=Ge(),C=V=>{e(!1),y({to:"/$org/settings/connections/$appSlug",params:{org:_.slug,appSlug:V}})},k=async V=>{h(V.app_name??V.id);try{const I=`${V.title.replace(/\s*\(\d+\)\s*$/,"")} (${Date.now().toString(36).slice(-4)})`,R=(await x.create.mutateAsync({title:I,description:V.description??null,connection_type:V.connection_type,connection_url:V.connection_url??null,connection_token:null,icon:V.icon??null,app_name:V.app_name??null,app_id:V.app_id??null,connection_headers:V.connection_headers??null})).id,N=new URL(`/mcp/${R}`,window.location.origin),A=await bn({url:N.href,token:null});if(A.supportsOAuth&&!A.isAuthenticated){const{token:E,tokenInfo:M,error:L}=await wr({connectionId:R,scope:"offline_access"});if(L||!E){ne("connection_oauth_failed",{connection_id:R,flow:"clone",error:L??"no_token"}),ue.error(`Authentication failed: ${L??"no token received"}`),await x.delete.mutateAsync(R);return}if(ne("connection_oauth_succeeded",{connection_id:R,flow:"clone"}),M)try{(await fetch(`/api/connections/${R}/oauth-token`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({accessToken:M.accessToken,refreshToken:M.refreshToken,expiresIn:M.expiresIn,scope:M.scope,clientId:M.clientId,clientSecret:M.clientSecret,tokenEndpoint:M.tokenEndpoint})})).ok?await x.update.mutateAsync({id:R,data:{}}):await x.update.mutateAsync({id:R,data:{connection_token:E}})}catch{await x.update.mutateAsync({id:R,data:{connection_token:E}})}else await x.update.mutateAsync({id:R,data:{connection_token:E}});await b.invalidateQueries({queryKey:ct.isMCPAuthenticated(N.href,null)})}d(R,V.app_name??null,"clone"),c(R)}catch(j){console.error("Failed to add connection:",j),ue.error("Failed to add connection")}finally{h(null)}},w=async V=>{if(!(!_||!v?.user?.id)){h(V.id);try{const j=w_(V,_.id,v.user.id,{remoteIndex:0}),I=j.connection_type==="STDIO",T=!!j.connection_url,R=I&&j.connection_headers&&typeof j.connection_headers=="object"&&"command"in j.connection_headers;if(!T&&!R){ue.error("This MCP Server cannot be connected: no connection method available"),h(null);return}const{id:N}=await x.create.mutateAsync(j),A=new URL(`/mcp/${N}`,window.location.origin),E=await bn({url:A.href,token:null});if(E.supportsOAuth&&!E.isAuthenticated){const{token:M,tokenInfo:L,error:D}=await wr({connectionId:N,scope:"offline_access"});if(D||!M){ne("connection_oauth_failed",{connection_id:N,flow:"connect_new",error:D??"no_token"}),ue.error(`Authentication failed: ${D??"no token received"}`),d(N,j.app_name??null,"new"),c(N);return}if(ne("connection_oauth_succeeded",{connection_id:N,flow:"connect_new"}),L)try{(await fetch(`/api/connections/${N}/oauth-token`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({accessToken:L.accessToken,refreshToken:L.refreshToken,expiresIn:L.expiresIn,scope:L.scope,clientId:L.clientId,clientSecret:L.clientSecret,tokenEndpoint:L.tokenEndpoint})})).ok?await x.update.mutateAsync({id:N,data:{}}):await x.update.mutateAsync({id:N,data:{connection_token:M}})}catch{await x.update.mutateAsync({id:N,data:{connection_token:M}})}else await x.update.mutateAsync({id:N,data:{connection_token:M}});await b.invalidateQueries({queryKey:ct.isMCPAuthenticated(A.href,null)}),ue.success("Connected and authenticated")}else ue.success("Connected");d(N,j.app_name??null,"new"),c(N)}catch(j){console.error("Failed to connect:",j),ue.error("Failed to connect")}finally{h(null)}}};return n.jsxs(ss,{open:t,onOpenChange:e,children:[n.jsxs(ts,{className:"sm:max-w-5xl h-[85vh] max-h-[85vh] flex flex-col p-0 gap-0 overflow-hidden w-[95vw]",children:[n.jsx(hs,{className:"px-6 pt-5 pb-0 shrink-0",children:n.jsx(ds,{className:"text-base font-semibold",children:o==="browse"?"Connections":"Add Connection"})}),n.jsx("div",{className:"pt-3 shrink-0",children:n.jsx(Fh,{value:f,onChange:m,placeholder:"Search connections..."})}),n.jsx(S.Suspense,{fallback:n.jsx("div",{className:"flex-1 flex items-center justify-center",children:n.jsx(Me,{size:24,className:"animate-spin text-muted-foreground"})}),children:n.jsx(kv,{mode:o,agentId:a,addedConnectionIds:l,onAdd:c,onCloneAndAdd:k,onConnectAndAdd:w,connectingItemId:u,search:f,onCreateConnection:()=>g(!0),onBrowseNavigate:C,defaultTab:s})})]}),n.jsx(Cv,{open:p,onOpenChange:g,onCreated:async V=>{g(!1);const j=new URL(`/mcp/${V}`,window.location.origin),I=await bn({url:j.href,token:null});if(I.supportsOAuth&&!I.isAuthenticated){const{token:T,tokenInfo:R,error:N}=await wr({connectionId:V,scope:"offline_access"});if(N||!T){ne("connection_oauth_failed",{connection_id:V,flow:"custom_create",error:N??"no_token"}),ue.error(`Authentication failed: ${N??"no token received"}`),await x.delete.mutateAsync(V);return}if(ne("connection_oauth_succeeded",{connection_id:V,flow:"custom_create"}),R)try{(await fetch(`/api/connections/${V}/oauth-token`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({accessToken:R.accessToken,refreshToken:R.refreshToken,expiresIn:R.expiresIn,scope:R.scope,clientId:R.clientId,clientSecret:R.clientSecret,tokenEndpoint:R.tokenEndpoint})})).ok?await x.update.mutateAsync({id:V,data:{}}):await x.update.mutateAsync({id:V,data:{connection_token:T}})}catch{await x.update.mutateAsync({id:V,data:{connection_token:T}})}else await x.update.mutateAsync({id:V,data:{connection_token:T}});await b.invalidateQueries({queryKey:ct.isMCPAuthenticated(j.href,null)})}d(V,null,"custom"),c(V),e(!1)}})]})}const Dv=[{src:"/connections/github.png",name:"GitHub"},{src:"/connections/gmail.png",name:"Gmail"},{src:"/connections/linear.png",name:"Linear"},{src:"/connections/shopify.png",name:"Shopify"},{src:"/connections/firecrawl.png",name:"Firecrawl"},{src:"/connections/perplexity.png",name:"Perplexity"}];function Mv(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx("div",{className:"flex items-center -space-x-1",children:Dv.map(Pv)}),t[0]=e):e=t[0],e}function Pv(t){return n.jsx("img",{src:t.src,alt:t.name,className:"size-5 rounded-sm ring-2 ring-muted object-cover bg-white"},t.name)}function Lv(t){const e=B.c(6),{onClick:s}=t;let i,r,o,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=J("group relative z-10 flex items-center gap-3 w-full px-4 py-3","rounded-b-2xl","cursor-pointer"),r=n.jsx("p",{className:"flex-1 text-xs text-muted-foreground truncate text-left",children:"Connect tools and get more done"}),o=n.jsx(Mv,{}),a=n.jsx(El,{size:14,className:"shrink-0 text-muted-foreground/60 group-hover:text-muted-foreground transition-colors"}),e[0]=i,e[1]=r,e[2]=o,e[3]=a):(i=e[0],r=e[1],o=e[2],a=e[3]);let l;return e[4]!==s?(l=n.jsxs("button",{type:"button",onClick:s,className:i,children:[r,o,a]}),e[4]=s,e[5]=l):l=e[5],l}const fn=48;function Ov(){const t=B.c(9),[e,s]=S.useState("idle"),[i,r]=S.useState(""),[o,a]=S.useState(""),[l,c]=S.useState(zv),d=S.useRef(null),u=S.useRef(null),h=S.useRef(null),f=S.useRef(null),m=S.useRef(0),p=S.useRef(!1),g=S.useRef(""),_=S.useRef(""),v=typeof window<"u"&&!!(window.SpeechRecognition||window.webkitSpeechRecognition);let x;t[0]===Symbol.for("react.memo_cache_sentinel")?(x=()=>{m.current&&(cancelAnimationFrame(m.current),m.current=0),u.current?.close().catch($v),f.current?.getTracks().forEach(Bv),h.current=null,u.current=null,f.current=null},t[0]=x):x=t[0];const b=x;let y;if(t[1]===Symbol.for("react.memo_cache_sentinel")){const T=R=>{f.current=R;const N=new AudioContext;u.current=N;const A=N.createMediaStreamSource(R),E=N.createAnalyser();E.fftSize=128,E.smoothingTimeConstant=.8,A.connect(E),h.current=E;const M=new Uint8Array(E.frequencyBinCount),L=()=>{if(!h.current)return;h.current.getByteFrequencyData(M);const D=[];for(let P=0;P<fn;P++){const O=Math.floor(P/fn*M.length);D.push(Math.max(.04,(M[O]??0)/255))}c(D),m.current=requestAnimationFrame(L)};L()};y=async()=>{const R=window.SpeechRecognition||window.webkitSpeechRecognition;if(!R){s("unsupported");return}let N;try{N=await navigator.mediaDevices.getUserMedia({audio:!0})}catch{s("permission-denied");return}r(""),a(""),_.current="",g.current="",p.current=!0,s("recording"),T(N);const A=new R;d.current=A,A.interimResults=!0,A.continuous=!0,A.lang=navigator.language||"en-US",A.onresult=E=>{let M="",L="";for(let D=E.resultIndex;D<E.results.length;D++){const P=E.results[D],O=P?.[0]?.transcript??"";P?.isFinal?L=L+O:M=M+O}L&&(g.current=g.current+L,r(g.current)),_.current=M,a(M)},A.onend=()=>{if(p.current)try{A.start()}catch{}};try{A.start()}catch{s("idle")}},t[1]=y}else y=t[1];const C=y;let k;t[2]===Symbol.for("react.memo_cache_sentinel")?(k=()=>{p.current=!1,d.current?.stop(),b(),s("idle"),c(Array(fn).fill(.05)),a("");const T=(g.current+(_.current?" "+_.current:"")).trim();return r(""),g.current="",_.current="",T},t[2]=k):k=t[2];const w=k;let V;t[3]===Symbol.for("react.memo_cache_sentinel")?(V=()=>{p.current=!1,d.current?.abort(),b(),s("idle"),r(""),a(""),c(Array(fn).fill(.05)),g.current="",_.current=""},t[3]=V):V=t[3];const j=V;let I;return t[4]!==o||t[5]!==e||t[6]!==i||t[7]!==l?(I={status:e,transcript:i,interimTranscript:o,waveformData:l,isSupported:v,startRecording:C,stopRecording:w,cancelRecording:j},t[4]=o,t[5]=e,t[6]=i,t[7]=l,t[8]=I):I=t[8],I}function Bv(t){return t.stop()}function $v(){}function zv(){return Array(fn).fill(.05)}function Fv(t){const e=B.c(4),{data:s}=t;let i;e[0]!==s?(i=s.map(Uv),e[0]=s,e[1]=i):i=e[1];let r;return e[2]!==i?(r=n.jsx("div",{className:"flex items-center justify-center gap-[2px] h-10 overflow-hidden","aria-hidden":"true",children:i}),e[2]=i,e[3]=r):r=e[3],r}function Uv(t,e){return n.jsx("div",{className:"w-[2px] shrink-0 rounded-full bg-chart-2 transition-[height] duration-75 ease-out",style:{height:`${Math.max(4,Math.round(t*40))}px`}},e)}const Lo=[{value:"fast",label:"Fast",Icon:Zh,description:"Quicker responses"},{value:"smart",label:"Smart",Icon:Vl,description:"Balanced quality"},{value:"thinking",label:"Thinking",Icon:kg,description:"Deeper reasoning"}];function Hv(t){const e=B.c(17),{tier:s,onSelect:i}=t;let r;e[0]!==s?(r=Lo.find(m=>m.value===s)??Lo[1],e[0]=s,e[1]=r):r=e[1];const o=r,a=o.Icon;let l;e[2]!==a?(l=n.jsx(a,{size:14}),e[2]=a,e[3]=l):l=e[3];let c;e[4]!==o.label?(c=n.jsx("span",{className:"hidden sm:inline",children:o.label}),e[4]=o.label,e[5]=c):c=e[5];let d;e[6]!==l||e[7]!==c?(d=n.jsx(Is,{asChild:!0,children:n.jsxs(ae,{type:"button",variant:"ghost",size:"default",className:"text-muted-foreground hover:text-foreground",children:[l,c]})}),e[6]=l,e[7]=c,e[8]=d):d=e[8];let u;e[9]!==i||e[10]!==s?(u=Lo.map(m=>{const{value:p,label:g,Icon:_,description:v}=m;return n.jsxs(at,{onSelect:()=>i(p),children:[n.jsx(_,{size:16,className:"text-muted-foreground"}),n.jsxs("div",{className:"flex flex-col gap-0.5 flex-1",children:[n.jsx("span",{children:g}),n.jsx("span",{className:"text-xs text-muted-foreground font-normal",children:v})]}),s===p&&n.jsx("span",{className:"text-xs text-muted-foreground font-medium",children:"On"})]},p)}),e[9]=i,e[10]=s,e[11]=u):u=e[11];let h;e[12]!==u?(h=n.jsx(Rs,{align:"end",className:"w-52 p-1.5",children:u}),e[12]=u,e[13]=h):h=e[13];let f;return e[14]!==d||e[15]!==h?(f=n.jsxs(Es,{children:[d,h]}),e[14]=d,e[15]=h,e[16]=f):f=e[16],f}function Wv(t,e){const s=B.c(5),{editor:i}=oo(),[r,o]=S.useState(!1),a=S.useRef(0);let l,c;return s[0]!==i||s[1]!==e||s[2]!==t?(l=()=>{const d=m=>{m.dataTransfer?.types.includes("Files")&&(m.preventDefault(),a.current=a.current+1,o(!0))},u=m=>{m.preventDefault(),a.current=Math.max(0,a.current-1),a.current===0&&o(!1)},h=Kv,f=m=>{if(m.preventDefault(),a.current=0,o(!1),!i||!t||!uo(t))return;const p=m.dataTransfer?.files;if(!p||p.length===0)return;const{from:g}=i.state.selection;for(const _ of Array.from(p))Bl(i,t,_,g,e)};return window.addEventListener("dragenter",d),window.addEventListener("dragleave",u),window.addEventListener("dragover",h),window.addEventListener("drop",f),()=>{window.removeEventListener("dragenter",d),window.removeEventListener("dragleave",u),window.removeEventListener("dragover",h),window.removeEventListener("drop",f)}},c=[i,t,e],s[0]=i,s[1]=e,s[2]=t,s[3]=l,s[4]=c):(l=s[3],c=s[4]),S.useEffect(l,c),r}function Kv(t){t.dataTransfer?.types.includes("Files")&&t.preventDefault()}function qv(t){const e=B.c(11),{selectedModel:s,onUnsupportedFile:i}=t,r=Wv(s,i);let o;e[0]!==s?(o=uo(s),e[0]=s,e[1]=o):o=e[1];const a=o,l=r?"opacity-100":"opacity-0 pointer-events-none",c=a?"border-primary/40 text-primary/70":"border-destructive/30 text-destructive/70";let d;e[2]!==l||e[3]!==c?(d=J("absolute inset-0 z-20 rounded-xl flex flex-col items-center justify-center gap-2 bg-muted border-2 border-dashed transition-opacity",l,c),e[2]=l,e[3]=c,e[4]=d):d=e[4];let u;e[5]!==s||e[6]!==a?(u=a?n.jsxs(n.Fragment,{children:[n.jsx(lu,{size:24}),n.jsxs("span",{className:"text-sm font-medium",children:["Drop ",uu(s)," here"]})]}):n.jsxs(n.Fragment,{children:[n.jsx(au,{size:24}),n.jsx("span",{className:"text-sm font-medium",children:"This model can't read attachments — switch to one with vision or file support"})]}),e[5]=s,e[6]=a,e[7]=u):u=e[7];let h;return e[8]!==d||e[9]!==u?(h=n.jsx("div",{className:d,children:u}),e[8]=d,e[9]=u,e[10]=h):h=e[10],h}function Gv({onOpenContextPanel:t,showConnectionsBanner:e=!1}){const{messages:s,isStreaming:i,isRunInProgress:r,sendMessage:o,stop:a}=Yi(),{taskId:l,tasks:c}=es(),{selectedModel:d,selectedVirtualMcp:u,isModelsLoading:h,tiptapDocRef:f,imageModel:m,deepResearchModel:p,chatMode:g,setChatMode:_,simpleModeEnabled:v,simpleModeTier:x,setSimpleModeTier:b}=ai(),{data:y}=St.useSession(),C=y?.user?.id,{org:k}=xe(),w=co(k.id).id,V=ya(wc),[j,I]=S.useState(!1),{unsupportedFile:T,onUnsupportedFile:R,clearUnsupportedFile:N}=s1(),A=Ov(),E=S.useRef(void 0),M=async()=>{E.current=O,await A.startRecording();const re=A.status==="recording"?"started":A.status==="unsupported"?"unsupported":A.status==="permission-denied"?"permission_denied":"unknown";ne("chat_voice_started",{thread_id:l,outcome:re})},L=()=>{ne("chat_voice_confirmed",{thread_id:l});const re=A.stopRecording();H.current?.syncVoiceText(E.current,re),H.current?.focus()},D=()=>{ne("chat_voice_cancelled",{thread_id:l}),A.cancelRecording(),H.current?.restoreContent(E.current)};S.useEffect(()=>{if(A.status!=="recording")return;const re=(A.transcript+(A.interimTranscript?" "+A.interimTranscript:"")).trim();H.current?.syncVoiceText(E.current,re)},[A.transcript,A.interimTranscript,A.status]);const P=c.find(re=>re.id===l),[O,z]=S.useState(void 0),$=re=>{z(re),f.current=re},q=S.useRef(l);q.current!==l&&(q.current=l,z(void 0),f.current=void 0);const G=[...s].reverse().find(re=>re.role==="assistant")?.metadata?.modelLimits?.contextWindow??d?.limits?.contextWindow,H=S.useRef(null),U=g==="plan";S.useEffect(()=>{const re=de=>{Wh(de)&&de.code==="KeyL"&&(de.preventDefault(),de.shiftKey&&_(g==="plan"?"default":"plan"),H.current?.focus())};return document.addEventListener("keydown",re),()=>document.removeEventListener("keydown",re)},[g,_]);const Y=Bh(s),W=[...s].reverse().find(re=>re.role==="assistant"&&re.metadata?.usage)?.metadata?.usage,K=W?.contextTokens??(W?.totalTokens??0)-(W?.reasoningTokens??0),ee=ya(wc),Z=!i&&!!d&&!h&&!nx(O),X=i||r,ie=re=>{re?.preventDefault(),i?(ne("chat_message_stopped",{thread_id:l}),a()):r?(ne("chat_message_stopped",{thread_id:l}),a()):Z&&O&&(ne("chat_message_sent",{thread_id:l,mode:g,model_id:d?.modelId??null,model_provider:d?.providerId??null,virtual_mcp_id:u?.id??null,submission:re?"button_or_enter":"programmatic"}),ee(),o(O),$(void 0))};return C&&P?.created_by&&P.created_by!==C?n.jsxs("div",{className:"flex w-full items-center gap-2 px-3 py-2.5 rounded-xl border border-border bg-muted/40 text-muted-foreground",children:[n.jsx(au,{size:14,className:"shrink-0"}),n.jsx("span",{className:"text-sm",children:"Read only — you're viewing someone else's thread"})]}):n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"flex flex-col w-full justify-end",children:n.jsxs("div",{className:"relative rounded-2xl w-full flex flex-col",children:[e&&n.jsx("div",{className:"absolute inset-0 rounded-2xl pointer-events-none bg-muted/50"}),n.jsx(_o,{}),n.jsx(tf,{tiptapDoc:O,setTiptapDoc:$,disabled:i||!d,enterToSubmit:!0,onSubmit:ie,children:n.jsxs("form",{onSubmit:ie,className:J("w-full relative rounded-2xl min-h-[110px] md:min-h-[130px] flex flex-col bg-background dark:bg-muted card-shadow"),children:[n.jsx(qv,{selectedModel:d,onUnsupportedFile:R}),n.jsx("div",{className:"group/input relative flex flex-col gap-2 flex-1",children:n.jsx(sf,{ref:H,disabled:i||!d||A.status==="recording",virtualMcpId:u?.id??w,showFileUploader:!0,selectedModel:d,onUnsupportedFile:R})}),n.jsx("div",{className:"flex items-center justify-between p-2.5 gap-1",children:A.status==="recording"?n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"flex-1"}),n.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[n.jsx(Fv,{data:A.waveformData.slice(0,28)}),n.jsx("button",{type:"button",onClick:D,className:"flex items-center justify-center size-8 rounded-lg hover:bg-muted text-muted-foreground hover:text-foreground transition-colors","aria-label":"Cancel recording",children:n.jsx(Js,{size:16})}),n.jsx("button",{type:"button",onClick:L,className:"flex items-center justify-center size-8 rounded-lg bg-foreground text-background hover:opacity-80 transition-opacity","aria-label":"Use transcription",children:n.jsx(Jt,{size:16})})]})]}):n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"flex items-center gap-1.5 min-w-0 shrink-0",children:[n.jsx(Jx,{selectedModel:d,isStreaming:i,icon:n.jsx(Qt,{size:16}),onUnsupportedFile:R}),n.jsx(Sv,{disabled:i,onOpenConnections:()=>{ne("connections_dialog_opened",{source:"tools_popover",mode:"add"}),I(!0)},virtualMcpId:u?.id??w}),U&&n.jsxs("button",{type:"button",onClick:()=>{V(),ne("chat_mode_changed",{from_mode:"plan",to_mode:"default",source:"pill_dismiss"}),_("default")},className:"flex items-center gap-1.5 h-8 rounded-lg px-2.5 text-sm font-medium text-violet-600 dark:text-violet-400 hover:bg-violet-500/10 group whitespace-nowrap animate-in fade-in duration-200",children:[n.jsx(ou,{size:14,className:"shrink-0"}),"Plan mode",n.jsx(Js,{size:14,className:"shrink-0 hidden group-hover:block"})]}),g==="gen-image"&&m&&n.jsxs("button",{type:"button",onClick:()=>{V(),ne("chat_mode_changed",{from_mode:"gen-image",to_mode:"default",source:"pill_dismiss"}),_("default")},className:"flex items-center gap-1.5 h-8 rounded-lg px-2.5 text-sm font-medium text-pink-600 dark:text-pink-400 hover:bg-pink-500/10 group whitespace-nowrap animate-in fade-in duration-200",children:[n.jsx(pa,{size:14,className:"shrink-0"}),n.jsx("span",{className:"max-w-[120px] truncate",children:v?"Create image":m.title.includes(": ")?m.title.split(": ").slice(1).join(": "):m.title}),n.jsx(Js,{size:14,className:"shrink-0 hidden group-hover:block"})]}),g==="web-search"&&p&&n.jsxs("button",{type:"button",onClick:()=>{V(),ne("chat_mode_changed",{from_mode:"web-search",to_mode:"default",source:"pill_dismiss"}),_("default")},className:"flex items-center gap-1.5 h-8 rounded-lg px-2.5 text-sm font-medium text-blue-600 dark:text-blue-400 hover:bg-blue-500/10 group whitespace-nowrap animate-in fade-in duration-200",children:[n.jsx(Li,{size:14,className:"shrink-0"}),n.jsx("span",{className:"max-w-[120px] truncate",children:v?"Web search":p.title.includes(": ")?p.title.split(": ").slice(1).join(": "):p.title}),n.jsx(Js,{size:14,className:"shrink-0 hidden group-hover:block"})]}),G&&K>0&&n.jsx(Xp,{usage:Y,totalTokens:K,contextWindow:G,onOpenContextPanel:t})]}),n.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[v?n.jsx(Hv,{tier:x,onSelect:b}):n.jsx(fu,{placeholder:"Model",variant:"borderless",className:"h-8 text-sm py-2 min-w-0"}),A.isSupported&&!i&&!r&&n.jsx(ae,{type:"button",onClick:M,variant:"ghost",size:"icon",className:J("size-8 rounded-lg transition-colors",A.status==="permission-denied"?"text-destructive hover:text-destructive hover:bg-destructive/10":"text-muted-foreground hover:text-foreground"),title:A.status==="permission-denied"?"Microphone access denied — click to try again":"Voice input",children:n.jsx(Vg,{size:18})}),n.jsx(ae,{type:X?"button":"submit",onClick:re=>{X&&(re.preventDefault(),re.stopPropagation(),a())},variant:Z||X?"default":"ghost",size:"icon",disabled:!Z&&!X,className:J("size-8 rounded-lg transition-all",!Z&&!X&&"bg-muted text-muted-foreground hover:bg-muted hover:text-muted-foreground cursor-not-allowed"),title:i?"Stop generating":r?"Cancel run":"Send message (Enter)",children:X?n.jsx(Cg,{size:20}):n.jsx(Qh,{size:20})})]})]})})]})},l),e&&n.jsx(Lv,{onClick:()=>{ne("connections_banner_clicked",{source:"home_chat_input"}),ne("connections_dialog_opened",{source:"home_banner",mode:"add"}),I(!0)}})]})}),n.jsx(Fl,{mode:"browse",open:j,onOpenChange:I,defaultTab:"all"}),n.jsx(Zx,{info:T,onClose:N})]})}const Yv={usd:[{dollars:10,label:"Starter"},{dollars:20,label:"Popular"},{dollars:100,label:"Best value"}],brl:[{dollars:50,label:"Starter"},{dollars:100,label:"Popular"},{dollars:500,label:"Best value"}]};function nf(t){return`deco-credits-empty-dismissed:${t}`}function Xv(t){try{return localStorage.getItem(nf(t))==="1"}catch{return!1}}function Jv(){const t=B.c(49),{org:e}=xe(),s=Ge(),{decoKeyId:i}=go();let r;t[0]!==e.id?(r={connectionId:Pt,orgId:e.id},t[0]=e.id,t[1]=r):r=t[1];const o=Be(r),[a,l]=S.useState(!0),[c,d]=S.useState(""),[u,h]=S.useState(!1),[f,m]=S.useState("usd"),p=f==="brl"?"R$":"$";let g;t[2]!==e.id?(g=()=>{ne("credits_empty_state_dismissed",{organization_id:e.id}),l(!1);try{localStorage.setItem(nf(e.id),"1")}catch{}},t[2]=e.id,t[3]=g):g=t[3];const _=g;let v,x;t[4]!==a||t[5]!==e.id?(v=()=>{a&&ne("credits_empty_state_shown",{organization_id:e.id})},x=[a,e.id],t[4]=a,t[5]=e.id,t[6]=v,t[7]=x):(v=t[6],x=t[7]),S.useEffect(v,x);let b;t[8]!==o||t[9]!==f?(b=async $=>{const q=await o.callTool({name:"AI_PROVIDER_TOPUP_URL",arguments:{providerId:"deco",amountCents:$,currency:f}});if(q?.isError)throw new Error(q.content?.[0]?.text??"Failed to get top-up URL");return q.structuredContent?.url},t[8]=o,t[9]=f,t[10]=b):b=t[10];let y;t[11]!==_?(y=$=>{$&&window.open($,"_blank","noopener,noreferrer"),_()},t[11]=_,t[12]=y):y=t[12];let C;t[13]!==b||t[14]!==y?(C={mutationFn:b,onSuccess:y,onError:Zv},t[13]=b,t[14]=y,t[15]=C):C=t[15];const{mutate:k,isPending:w}=qi(C),V=parseFloat(c),j=!isNaN(V)&&V>=1;if(!a)return null;let I;t[16]!==_?(I=$=>!$&&_(),t[16]=_,t[17]=I):I=t[17];let T;t[18]===Symbol.for("react.memo_cache_sentinel")?(T=n.jsx("div",{className:"absolute inset-x-0 top-0 h-24 bg-gradient-to-b from-amber-500/8 to-transparent pointer-events-none rounded-t-lg"}),t[18]=T):T=t[18];let R;t[19]===Symbol.for("react.memo_cache_sentinel")?(R=n.jsx("div",{className:"flex items-center justify-center size-11 rounded-full bg-amber-100 dark:bg-amber-900/40 border border-amber-200/60 dark:border-amber-800/40 mx-auto",children:n.jsx(yl,{size:20,className:"text-amber-600 dark:text-amber-400"})}),t[19]=R):R=t[19];let N;t[20]===Symbol.for("react.memo_cache_sentinel")?(N=n.jsxs("div",{className:"relative px-6 pt-7 pb-5",children:[T,n.jsxs(hs,{className:"relative gap-3",children:[R,n.jsxs("div",{className:"text-center",children:[n.jsx(ds,{className:"text-lg font-semibold",children:"This workspace has no credits"}),n.jsx(ao,{className:"mt-2 text-[13px] leading-relaxed max-w-[320px] mx-auto",children:"Your free credits were used in another workspace. Add credits to use AI here."})]})]})]}),t[20]=N):N=t[20];let A;t[21]!==f||t[22]!==p||t[23]!==c||t[24]!==V||t[25]!==i||t[26]!==j||t[27]!==w||t[28]!==u||t[29]!==k?(A=i&&n.jsxs("div",{className:"px-6 pb-5",children:[n.jsx("div",{className:"mb-4",children:n.jsxs(du,{type:"single",variant:"outline",size:"sm",value:f,onValueChange:$=>{$&&m($)},children:[n.jsx(zr,{value:"usd",className:"h-8 px-3 text-xs",children:"USD"}),n.jsx(zr,{value:"brl",className:"h-8 px-3 text-xs",children:"BRL"})]})}),n.jsx("div",{className:"grid grid-cols-3 gap-2.5",children:Yv[f].map($=>{const{dollars:q,label:F}=$;return n.jsxs("button",{type:"button",disabled:w,onClick:()=>{ne("credits_topup_clicked",{amount_cents:q*100,currency:f,tier_label:F,source:"empty_state"}),k(q*100)},className:J("relative flex flex-col items-center gap-1 py-6 rounded-xl border transition-all duration-150 cursor-pointer","disabled:opacity-50 disabled:cursor-wait","border-border hover:border-foreground/20 hover:bg-muted/30"),children:[n.jsxs("span",{className:"text-2xl font-semibold tabular-nums text-foreground",children:[p,q]}),n.jsx("span",{className:"text-xs text-muted-foreground",children:F})]},q)})}),u?n.jsxs("div",{className:"flex gap-2 mt-3",children:[n.jsxs("div",{className:"relative flex-1",children:[n.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-sm text-muted-foreground select-none",children:p}),n.jsx(gt,{type:"number",min:"1",step:"1",placeholder:"50",value:c,onChange:$=>d($.target.value),className:"h-10 text-sm pl-7",autoFocus:!0})]}),n.jsx(ae,{className:"h-10",disabled:!j||w,onClick:()=>{ne("credits_topup_clicked",{amount_cents:Math.round(V*100),currency:f,tier_label:"custom",source:"empty_state"}),k(Math.round(V*100))},children:w?"Opening...":"Add"})]}):n.jsx("button",{type:"button",className:"w-full mt-2.5 text-xs text-muted-foreground hover:text-foreground transition-colors py-1",onClick:()=>h(!0),children:"Enter custom amount"})]}),t[21]=f,t[22]=p,t[23]=c,t[24]=V,t[25]=i,t[26]=j,t[27]=w,t[28]=u,t[29]=k,t[30]=A):A=t[30];let E;t[31]!==_||t[32]!==s||t[33]!==e.slug?(E=()=>{s({to:"/$org/settings/ai-providers",params:{org:e.slug}}),_()},t[31]=_,t[32]=s,t[33]=e.slug,t[34]=E):E=t[34];let M;t[35]===Symbol.for("react.memo_cache_sentinel")?(M=n.jsx(ho,{size:12,className:"transition-transform duration-150 group-hover:translate-x-0.5"}),t[35]=M):M=t[35];let L;t[36]!==E?(L=n.jsxs("button",{type:"button",className:"group flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors",onClick:E,children:["Use your own provider",M]}),t[36]=E,t[37]=L):L=t[37];let D;t[38]!==_?(D=n.jsx(ae,{variant:"ghost",size:"sm",className:"text-xs text-muted-foreground",onClick:_,children:"Skip for now"}),t[38]=_,t[39]=D):D=t[39];let P;t[40]!==L||t[41]!==D?(P=n.jsxs("div",{className:"px-6 py-3.5 border-t border-border bg-muted/30 flex items-center justify-between",children:[L,D]}),t[40]=L,t[41]=D,t[42]=P):P=t[42];let O;t[43]!==A||t[44]!==P?(O=n.jsxs(ts,{className:"sm:max-w-[500px] gap-0 p-0 overflow-hidden",onOpenAutoFocus:Qv,children:[N,A,P]}),t[43]=A,t[44]=P,t[45]=O):O=t[45];let z;return t[46]!==O||t[47]!==I?(z=n.jsx(ss,{open:!0,onOpenChange:I,children:O}),t[46]=O,t[47]=I,t[48]=z):z=t[48],z}function Qv(t){return t.preventDefault()}function Zv(t){ue.error(`Top-up failed: ${t.message}`)}function eb(t){const e=B.c(6),{balanceDollars:s}=t;let i;e[0]!==s?(i=s.toFixed(2),e[0]=s,e[1]=i):i=e[1];const r=i;let o,a;e[2]===Symbol.for("react.memo_cache_sentinel")?(o=J("inline-flex items-center gap-1.5 px-3 py-1 rounded-full","bg-emerald-50 dark:bg-emerald-950/30","border border-emerald-200/60 dark:border-emerald-800/40","animate-in fade-in-0 slide-in-from-bottom-2 duration-300"),a=n.jsx(yl,{size:13,className:"text-emerald-600 dark:text-emerald-400"}),e[2]=o,e[3]=a):(o=e[2],a=e[3]);let l;return e[4]!==r?(l=n.jsxs("div",{className:o,children:[a,n.jsxs("span",{className:"text-xs font-medium text-emerald-700 dark:text-emerald-300 tabular-nums",children:["$",r," in credits to get started"]})]}),e[4]=r,e[5]=l):l=e[5],l}function tb(){const t=B.c(8),{org:e}=xe(),s=Ge();let i;t[0]!==s||t[1]!==e.slug?(i=()=>s({to:"/$org/settings/ai-providers",params:{org:e.slug}}),t[0]=s,t[1]=e.slug,t[2]=i):i=t[2];let r,o,a;t[3]===Symbol.for("react.memo_cache_sentinel")?(r=J("inline-flex items-center gap-1.5 px-3 py-1 rounded-full cursor-pointer","bg-amber-50 dark:bg-amber-950/30","border border-amber-200/60 dark:border-amber-800/40","hover:bg-amber-100/60 dark:hover:bg-amber-900/30","transition-colors duration-150","animate-in fade-in-0 slide-in-from-bottom-2 duration-300"),o=n.jsx(oi,{size:13,className:"text-amber-600 dark:text-amber-400"}),a=n.jsx("span",{className:"text-xs font-medium text-amber-700 dark:text-amber-300",children:"No credits remaining · Add more"}),t[3]=r,t[4]=o,t[5]=a):(r=t[3],o=t[4],a=t[5]);let l;return t[6]!==i?(l=n.jsxs("button",{type:"button",onClick:i,className:r,children:[o,a]}),t[6]=i,t[7]=l):l=t[7],l}function sb(t){const e=B.c(11),{className:s}=t;let i;e[0]!==s?(i=J("flex h-full w-full flex-col bg-background",s),e[0]=s,e[1]=i):i=e[1];let r;e[2]===Symbol.for("react.memo_cache_sentinel")?(r=n.jsx("div",{className:"size-6 rounded-lg bg-muted animate-pulse"}),e[2]=r):r=e[2];let o;e[3]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsxs("div",{className:"flex items-center gap-3",children:[r,n.jsxs("div",{className:"flex flex-col gap-2",children:[n.jsx("div",{className:"h-3.5 w-28 rounded bg-muted animate-pulse"}),n.jsx("div",{className:"h-3 w-40 rounded bg-muted/60 animate-pulse"})]})]}),e[3]=o):o=e[3];let a;e[4]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx("div",{className:"flex items-center h-12 flex-none border-b border-border/80 px-4",children:n.jsxs("div",{className:"flex items-center justify-between gap-3 w-full",children:[o,n.jsxs("div",{className:"flex items-end gap-2",children:[n.jsx("div",{className:"h-6 w-6 rounded-full bg-muted animate-pulse"}),n.jsx("div",{className:"h-6 w-6 rounded-lg bg-muted animate-pulse"})]})]})}),e[4]=a):a=e[4];let l;e[5]===Symbol.for("react.memo_cache_sentinel")?(l=n.jsx("div",{className:"flex-1 overflow-hidden px-4 py-4",children:n.jsxs("div",{className:"mx-auto flex w-full max-w-2xl flex-col gap-4",children:[n.jsx(hr,{align:"right",width:"w-3/4"}),n.jsx(hr,{align:"left",width:"w-full",lines:3}),n.jsx(hr,{align:"right",width:"w-2/3"}),n.jsx(hr,{align:"left",width:"w-5/6",lines:2})]})}),e[5]=l):l=e[5];let c;e[6]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx("div",{className:"relative flex flex-1 flex-col gap-2 p-2.5",children:n.jsx("div",{className:"relative flex-1",children:n.jsxs("div",{className:"space-y-2 p-2",children:[n.jsx("div",{className:"h-3 w-full rounded bg-muted/40 animate-pulse"}),n.jsx("div",{className:"h-3 w-4/5 rounded bg-muted/40 animate-pulse"})]})})}),e[6]=c):c=e[6];let d;e[7]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx("div",{className:"flex items-center gap-1",children:n.jsx("div",{className:"size-8 rounded-full bg-muted/60 animate-pulse"})}),e[7]=d):d=e[7];let u;e[8]===Symbol.for("react.memo_cache_sentinel")?(u=n.jsx("div",{className:"px-4 py-4",children:n.jsx("div",{className:"mx-auto w-full max-w-2xl",children:n.jsxs("div",{className:"relative flex min-h-[130px] flex-col rounded-xl bg-background card-shadow",children:[c,n.jsxs("div",{className:"flex items-center justify-between px-2.5 pb-2.5",children:[d,n.jsxs("div",{className:"flex items-center gap-1",children:[n.jsx("div",{className:"h-8 w-32 rounded-lg bg-muted/60 animate-pulse"}),n.jsx("div",{className:"size-8 rounded-full bg-muted animate-pulse"})]})]})]})})}),e[8]=u):u=e[8];let h;return e[9]!==i?(h=n.jsxs("div",{className:i,children:[a,l,u]}),e[9]=i,e[10]=h):h=e[10],h}function hr(t){const e=B.c(22),{align:s,width:i,lines:r}=t,o=i===void 0?"w-full":i,a=r===void 0?1:r,l=s==="right"?"flex-row-reverse":"flex-row";let c;e[0]!==l?(c=J("flex w-full gap-4 px-4 py-2",l),e[0]=l,e[1]=c):c=e[1];const d=s==="right"?"ml-auto max-w-3/4 items-end":"w-full items-start";let u;e[2]!==d?(u=J("flex min-w-0 flex-col gap-2",d),e[2]=d,e[3]=u):u=e[3];let h;e[4]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx("div",{className:"h-3 w-16 rounded bg-muted/40 animate-pulse"}),e[4]=h):h=e[4];const f=s==="right"?"bg-muted":"bg-transparent border border-border/40";let m;e[5]!==f||e[6]!==o?(m=J("min-w-0 rounded-2xl p-4",f,o),e[5]=f,e[6]=o,e[7]=m):m=e[7];let p;e[8]!==a?(p=Array.from({length:a}),e[8]=a,e[9]=p):p=e[9];let g;e[10]!==a||e[11]!==p?(g=n.jsx("div",{className:"space-y-2",children:p.map((b,y)=>n.jsx("div",{className:J("h-3 rounded bg-muted-foreground/20 animate-pulse",y===a-1?"w-3/4":"w-full"),style:{animationDelay:`${y*.1}s`}},y))}),e[10]=a,e[11]=p,e[12]=g):g=e[12];let _;e[13]!==g||e[14]!==m?(_=n.jsx("div",{className:m,children:g}),e[13]=g,e[14]=m,e[15]=_):_=e[15];let v;e[16]!==_||e[17]!==u?(v=n.jsxs("div",{className:u,children:[h,_]}),e[16]=_,e[17]=u,e[18]=v):v=e[18];let x;return e[19]!==v||e[20]!==c?(x=n.jsx("div",{className:c,children:v}),e[19]=v,e[20]=c,e[21]=x):x=e[21],x}function ib(t){const e=B.c(5),{className:s,children:i}=t;let r;e[0]!==s?(r=J("flex flex-col h-full w-full bg-background transform-[translateZ(0)]",s),e[0]=s,e[1]=r):r=e[1];let o;return e[2]!==i||e[3]!==r?(o=n.jsx("div",{className:r,children:i}),e[2]=i,e[3]=r,e[4]=o):o=e[4],o}function nb(t){const e=B.c(5),{children:s,className:i}=t;let r;e[0]!==i?(r=J("flex-1 min-h-0 overflow-y-auto isolate",i),e[0]=i,e[1]=r):r=e[1];let o;return e[2]!==s||e[3]!==r?(o=n.jsx("div",{className:r,children:s}),e[2]=s,e[3]=r,e[4]=o):o=e[4],o}function rb(t){const e=B.c(2),{children:s}=t;let i;return e[0]!==s?(i=n.jsx("div",{className:"h-full w-full flex items-center justify-center max-w-2xl mx-auto",children:s}),e[0]=s,e[1]=i):i=e[1],i}function ob(){const t=B.c(16),{messages:e,status:s}=Yi(),i=Jp(e);let r;t[0]!==i?(r=i.at(-1),t[0]=i,t[1]=r):r=t[1];const o=r,a=s==="submitted"||s==="streaming";let l;if(t[2]!==a||t[3]!==o||t[4]!==i||t[5]!==e||t[6]!==s){const c=e.at(-1),d=!a&&c?.role==="assistant"&&c.parts.filter(cb).some(lb),u=!a&&c?.role==="assistant"&&c.parts.some(ab);let h;if(t[8]!==i||t[9]!==s){let m;t[11]!==i.length||t[12]!==s?(m=(p,g)=>n.jsx(gc,{pair:p,isLastPair:!1,status:g===i.length-1?s:void 0},`pair-${p.user.id}`),t[11]=i.length,t[12]=s,t[13]=m):m=t[13],h=i.slice(0,-1).map(m),t[8]=i,t[9]=s,t[10]=h}else h=t[10];let f;t[14]!==h?(f=n.jsx("div",{className:"flex flex-col min-w-0 max-w-2xl mx-auto w-full",children:h}),t[14]=h,t[15]=f):f=t[15],l=n.jsxs("div",{className:"w-full min-w-0 max-w-full overflow-y-auto h-full overflow-x-hidden",children:[f,o&&n.jsx("div",{className:J("min-h-full min-w-0 max-w-2xl mx-auto w-full",(d||u)&&"pb-60"),children:n.jsx(gc,{pair:o,isLastPair:!0,status:s},`pair-${o?.user.id}`)})]}),t[2]=a,t[3]=o,t[4]=i,t[5]=e,t[6]=s,t[7]=l}else l=t[7];return l}function ab(t){return"state"in t&&t.state==="approval-requested"}function lb(t){return t.state==="input-available"}function cb(t){return t.type==="tool-user_ask"}function db(t){const e=B.c(5),{children:s,className:i}=t;let r;e[0]!==i?(r=J("flex-none w-full mx-auto p-2 pt-0","max-w-2xl min-w-0",i),e[0]=i,e[1]=r):r=e[1];let o;return e[2]!==s||e[3]!==r?(o=n.jsx("div",{className:r,children:s}),e[2]=s,e[3]=r,e[4]=o):o=e[4],o}const $e=Object.assign(ib,{Main:nb,Messages:ob,EmptyState:rb,Footer:db,Input:Gv,Provider:zp,ActiveTaskProvider:$p,Skeleton:sb,IceBreakers:fx,NoAiProviderEmptyState:Zg,CreditsEmptyState:Jv,CreditsEyebrow:eb,NoCreditsEyebrow:tb,CreditsExhaustedBanner:$u}),hb=`You are an image generator agent. Every request of the user is somewhat related to creating, editing or varying an image. You have access to image generation tools
|
|
5
5
|
|
|
@@ -545,12 +545,12 @@ target:
|
|
|
545
545
|
• One issue per { kind, target.route } pair. Dedup uses those two fields from the body frontmatter.
|
|
546
546
|
• Always normalize route: lowercase host, no trailing slash (except "/"), no query string, no fragment.`)])),{type:"doc",content:c.map((d,u)=>u<c.length-1?Vb(d):d)}}function Vb(t){const e=t.content;if(!e||e.length===0)return t;const s=e[e.length-1];return!s||s.type!=="text"||typeof s.text!="string"?t:{...t,content:[...e.slice(0,-1),{...s,text:`${s.text}
|
|
547
547
|
|
|
548
|
-
`}]}}function ui(t){return{type:"paragraph",content:t}}function Ws(t){return{type:"text",text:t}}function Cb({agentId:t,title:e}){return{type:"mention",attrs:{id:t,name:e,char:"@",metadata:{agentId:t,title:e}}}}const mn="deco/site-diagnostics";function rf(t){const e=B.c(15),{open:s,onOpenChange:i}=t,[r,o]=S.useState(null);let a;e[0]!==i?(a=()=>{o(null),i(!1)},e[0]=i,e[1]=a):a=e[1];const l=a,c=s&&r===null;let d;e[2]!==r||e[3]!==i?(d=p=>{!p&&r===null&&i(!1)},e[2]=r,e[3]=i,e[4]=d):d=e[4];let u;e[5]!==c||e[6]!==d?(u=n.jsx(Su,{open:c,onOpenChange:d,title:"Set up self-healing repo",hideAutoRespondCheckbox:!0,onImportComplete:o}),e[5]=c,e[6]=d,e[7]=u):u=e[7];const h=s&&r!==null;let f;e[8]!==l||e[9]!==r||e[10]!==h?(f=n.jsx(kb,{open:h,payload:r,onClose:l}),e[8]=l,e[9]=r,e[10]=h,e[11]=f):f=e[11];let m;return e[12]!==u||e[13]!==f?(m=n.jsxs(n.Fragment,{children:[u,f]}),e[12]=u,e[13]=f,e[14]=m):m=e[14],m}function kb(t){const e=B.c(66),{open:s,payload:i,onClose:r}=t,{org:o}=xe(),a=Yn(),l=mo();let c;e[0]!==o.id?(c={connectionId:Pt,orgId:o.id},e[0]=o.id,e[1]=c):c=e[1];const d=Be(c),[u,h]=S.useState(""),[f,m]=S.useState(Ab);let p;e[2]!==s?(p={enabled:s},e[2]=s,e[3]=p):p=e[3];const{data:g}=C_(mn,p);let _;e[4]!==l||e[5]!==f||e[6]!==i||e[7]!==d||e[8]!==g||e[9]!==u?(_=async()=>{if(!i)throw new Error("No imported repo payload");const Y=Jc(u);if(!Y)throw new Error("Enter a valid https:// URL");const W=Sa.filter(X=>f[X.id]);if(W.length===0)return{succeeded:[],failed:[]};const K=await Tb({selfClient:d,createConnection:l.create.mutateAsync,registry:g}),ee=[],Z=[];for(const X of W)try{await Db({template:X,selfClient:d,siteDiagnosticsConnectionId:K,projectAgentId:i.virtualMcpId,owner:i.repo.owner,repo:i.repo.name,siteRootUrl:Y}),ee.push(X.title)}catch(ie){const re=ie;console.error(`Failed to set up ${X.title}:`,re),Z.push(X.title)}return{succeeded:ee,failed:Z}},e[4]=l,e[5]=f,e[6]=i,e[7]=d,e[8]=g,e[9]=u,e[10]=_):_=e[10];let v;e[11]!==a||e[12]!==r||e[13]!==i?.virtualMcpId?(v=Y=>{const{succeeded:W,failed:K}=Y;W.length>0?ue.success(`Self-healing repo ready — ${W.length} specialist${W.length>1?"s":""} set up`):K.length===0&&ue.success("Repo imported. Add specialists later from automations."),K.length>0&&ue.warning(`Could not set up: ${K.join(", ")}. You can add them later from the automations view.`);const ee=i?.virtualMcpId;r(),localStorage.setItem("mesh:sidebar-open",JSON.stringify(!1)),ee&&a(ee)},e[11]=a,e[12]=r,e[13]=i?.virtualMcpId,e[14]=v):v=e[14];let x;e[15]!==_||e[16]!==v?(x={mutationFn:_,onSuccess:v,onError:Nb},e[15]=_,e[16]=v,e[17]=x):x=e[17];const b=qi(x);let y;e[18]!==b.isPending||e[19]!==u?(y=Jc(u)!==null&&!b.isPending,e[18]=b.isPending,e[19]=u,e[20]=y):y=e[20];const C=y;let k;e[21]!==r||e[22]!==b.isPending?(k=Y=>{!Y&&!b.isPending&&r()},e[21]=r,e[22]=b.isPending,e[23]=k):k=e[23];let w;e[24]===Symbol.for("react.memo_cache_sentinel")?(w=n.jsx(hs,{className:"h-12 border-b border-border px-4 flex flex-row items-center shrink-0 space-y-0",children:n.jsx(ds,{className:"text-sm font-medium text-foreground",children:"Add specialist monitors"})}),e[24]=w):w=e[24];let V;e[25]===Symbol.for("react.memo_cache_sentinel")?(V=n.jsx("p",{className:"text-sm text-muted-foreground",children:"Specialists run on a daily schedule. Your repo agent collects their findings and opens GitHub issues, then writes the fixes."}),e[25]=V):V=e[25];let j;e[26]===Symbol.for("react.memo_cache_sentinel")?(j=n.jsx("label",{htmlFor:"self-healing-site-url",className:"text-xs font-medium text-foreground",children:"Production URL"}),e[26]=j):j=e[26];let I;e[27]===Symbol.for("react.memo_cache_sentinel")?(I=Y=>h(Y.target.value),e[27]=I):I=e[27];let T;e[28]!==u?(T=n.jsx(gt,{id:"self-healing-site-url",type:"url",placeholder:"https://example.com",value:u,onChange:I,autoFocus:!0}),e[28]=u,e[29]=T):T=e[29];let R;e[30]===Symbol.for("react.memo_cache_sentinel")?(R=n.jsx("p",{className:"text-xs text-muted-foreground",children:"The site the specialists will monitor."}),e[30]=R):R=e[30];let N;e[31]!==T?(N=n.jsxs("div",{className:"flex flex-col gap-1.5",children:[j,T,R]}),e[31]=T,e[32]=N):N=e[32];let A;e[33]!==f?(A=Sa.map(Y=>n.jsx(Eb,{template:Y,enabled:f[Y.id]??!1,onToggle:W=>m(K=>({...K,[Y.id]:W}))},Y.id)),e[33]=f,e[34]=A):A=e[34];let E,M;e[35]===Symbol.for("react.memo_cache_sentinel")?(E=Sb.map(jb),M=n.jsx(Rb,{}),e[35]=E,e[36]=M):(E=e[35],M=e[36]);let L;e[37]!==A?(L=n.jsxs("div",{className:"flex flex-col gap-2",children:[A,E,M]}),e[37]=A,e[38]=L):L=e[38];let D;e[39]!==N||e[40]!==L?(D=n.jsxs("div",{className:"flex-1 overflow-y-auto px-4 py-4 flex flex-col gap-4",children:[V,N,L]}),e[39]=N,e[40]=L,e[41]=D):D=e[41];let P;e[42]!==a||e[43]!==r||e[44]!==i?.virtualMcpId||e[45]!==b.isPending?(P=()=>{if(!b.isPending){const Y=i?.virtualMcpId;r(),Y&&a(Y)}},e[42]=a,e[43]=r,e[44]=i?.virtualMcpId,e[45]=b.isPending,e[46]=P):P=e[46];let O;e[47]!==b.isPending||e[48]!==P?(O=n.jsx("button",{type:"button",onClick:P,disabled:b.isPending,className:"text-xs text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50 cursor-pointer",children:"Skip for now"}),e[47]=b.isPending,e[48]=P,e[49]=O):O=e[49];let z;e[50]!==b?(z=()=>b.mutate(),e[50]=b,e[51]=z):z=e[51];const $=!C,q=b.isPending?"Setting up...":"Set up specialists";let F;e[52]!==z||e[53]!==$||e[54]!==q?(F=n.jsx(ae,{onClick:z,disabled:$,size:"sm",children:q}),e[52]=z,e[53]=$,e[54]=q,e[55]=F):F=e[55];let G;e[56]!==O||e[57]!==F?(G=n.jsxs("div",{className:"border-t border-border px-4 py-3 flex items-center justify-between gap-3 shrink-0",children:[O,F]}),e[56]=O,e[57]=F,e[58]=G):G=e[58];let H;e[59]!==D||e[60]!==G?(H=n.jsxs(ts,{className:"sm:max-w-[560px] max-h-[85svh] p-0 gap-0 overflow-hidden flex flex-col",children:[w,D,G]}),e[59]=D,e[60]=G,e[61]=H):H=e[61];let U;return e[62]!==s||e[63]!==H||e[64]!==k?(U=n.jsx(ss,{open:s,onOpenChange:k,children:H}),e[62]=s,e[63]=H,e[64]=k,e[65]=U):U=e[65],U}function jb(t){return n.jsx(Ib,{title:t.title,description:t.description,icon:t.icon},t.id)}function Nb(t){ue.error("Failed to set up specialists: "+(t instanceof Error?t.message:"Unknown error"))}function Ab(){const t={};for(const e of Sa)t[e.id]=!0;return t}function Eb(t){const e=B.c(20),{template:s,enabled:i,onToggle:r}=t,o=i?"bg-accent/30":"hover:bg-accent/30";let a;e[0]!==o?(a=J("flex items-center gap-3 rounded-lg border border-border px-3 py-3 cursor-pointer transition-colors",o),e[0]=o,e[1]=a):a=e[1];let l;e[2]!==s.icon||e[3]!==s.title?(l=n.jsx(gs,{icon:s.icon,name:s.title,size:"sm",className:"shrink-0"}),e[2]=s.icon,e[3]=s.title,e[4]=l):l=e[4];let c;e[5]!==s.title?(c=n.jsx("span",{className:"text-sm font-medium text-foreground leading-tight",children:s.title}),e[5]=s.title,e[6]=c):c=e[6];let d;e[7]!==s.description?(d=n.jsx("span",{className:"text-xs text-muted-foreground line-clamp-2",children:s.description}),e[7]=s.description,e[8]=d):d=e[8];let u;e[9]!==c||e[10]!==d?(u=n.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[c,d]}),e[9]=c,e[10]=d,e[11]=u):u=e[11];let h;e[12]!==i||e[13]!==r?(h=n.jsx(Ur,{checked:i,onCheckedChange:r,className:"shrink-0"}),e[12]=i,e[13]=r,e[14]=h):h=e[14];let f;return e[15]!==a||e[16]!==l||e[17]!==u||e[18]!==h?(f=n.jsxs("label",{className:a,children:[l,u,h]}),e[15]=a,e[16]=l,e[17]=u,e[18]=h,e[19]=f):f=e[19],f}function Ib(t){const e=B.c(14),{title:s,description:i,icon:r}=t;let o;e[0]!==r||e[1]!==s?(o=n.jsx(gs,{icon:r,name:s,size:"sm",className:"shrink-0"}),e[0]=r,e[1]=s,e[2]=o):o=e[2];let a;e[3]!==s?(a=n.jsx("span",{className:"text-sm font-medium text-foreground leading-tight",children:s}),e[3]=s,e[4]=a):a=e[4];let l;e[5]!==i?(l=n.jsx("span",{className:"text-xs text-muted-foreground line-clamp-2",children:i}),e[5]=i,e[6]=l):l=e[6];let c;e[7]!==a||e[8]!==l?(c=n.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[a,l]}),e[7]=a,e[8]=l,e[9]=c):c=e[9];let d;e[10]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx("span",{className:"text-[10px] font-medium uppercase tracking-wide text-muted-foreground shrink-0",children:"Coming soon"}),e[10]=d):d=e[10];let u;return e[11]!==o||e[12]!==c?(u=n.jsxs("div",{className:"flex items-center gap-3 rounded-lg border border-dashed border-border px-3 py-3 opacity-60",children:[o,c,d]}),e[11]=o,e[12]=c,e[13]=u):u=e[13],u}function Rb(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx("div",{className:"flex items-center justify-center rounded-lg border border-dashed border-border px-3 py-3 text-xs text-muted-foreground",children:"More specialists coming soon"}),t[0]=e):e=t[0],e}function Jc(t){const e=t.trim();if(!e)return null;try{const s=new URL(e);return s.protocol!=="https:"&&s.protocol!=="http:"?null:s.origin+(s.pathname==="/"?"":s.pathname)}catch{return null}}async function Tb({selfClient:t,createConnection:e,registry:s}){const r=(await t.callTool({name:"COLLECTION_CONNECTIONS_LIST",arguments:{where:{field:["app_id"],operator:"eq",value:mn},limit:1,offset:0}})).structuredContent?.items?.find(u=>u.app_id===mn);if(r)return r.id;const o=s?.server?.remotes?.[0]?.url;if(!o)throw new Error("Site Diagnostics MCP is not available in the registry right now.");const a=s?.title??s?.server?.title??s?.server?.name??"Site Diagnostics",l=s?.server?.icons?.[0]?.src??null,c=s?.server?.description??null;return(await e({title:a,description:c,icon:l,connection_type:"HTTP",connection_url:o,app_name:s?.server?.name??"site-diagnostics",app_id:mn,metadata:{type:"site-diagnostics",source:"store",registry_item_id:mn,verified:!0}})).id}async function Db({template:t,selfClient:e,siteDiagnosticsConnectionId:s,projectAgentId:i,owner:r,repo:o,siteRootUrl:a}){const l=`${o}: ${t.title}`,d=(await e.callTool({name:"AUTOMATION_LIST",arguments:{virtual_mcp_id:i}})).structuredContent?.automations?.find(h=>h.name===l);let u;if(!(d&&d.trigger_count>0)){if(d)u=d.id;else{const h=await Mb({template:t,selfClient:e,siteDiagnosticsConnectionId:s}),f=wb({template:t,specialistAgentId:h,owner:r,repo:o,siteRootUrl:a}),m=Oh(f),p=await e.callTool({name:"AUTOMATION_CREATE",arguments:{name:l,virtual_mcp_id:i,agent:{id:i},messages:m,active:!0}});u=(p.structuredContent??p).id}await e.callTool({name:"AUTOMATION_TRIGGER_ADD",arguments:{automation_id:u,type:"cron",cron_expression:t.cron}})}}async function Mb({template:t,selfClient:e,siteDiagnosticsConnectionId:s}){const r=(await e.callTool({name:"COLLECTION_VIRTUAL_MCP_LIST",arguments:{where:{field:["metadata","specialistId"],operator:"eq",value:t.id},limit:1,offset:0}})).structuredContent?.items?.find(l=>l.metadata?.specialistId===t.id);if(r)return r.id;const o=await e.callTool({name:"COLLECTION_VIRTUAL_MCP_CREATE",arguments:{data:{title:t.title,description:t.description,icon:t.icon,pinned:!1,metadata:{specialistId:t.id,instructions:t.instructions},connections:[{connection_id:s,selected_tools:t.siteDiagnosticsTools,selected_resources:null,selected_prompts:null}]}}});return(o.structuredContent??o).item.id}function Pb(t){try{const e=localStorage.getItem(`mesh:chat:recent-agents:${t}`);return e?JSON.parse(e):[]}catch{return[]}}function Ai(t){const e=B.c(21),{agent:s,onSpecialClick:i,tracking:r}=t,{org:o}=xe(),a=Ge();let l;e[0]!==s.id||e[1]!==s.title||e[2]!==a||e[3]!==i||e[4]!==o||e[5]!==r.action||e[6]!==r.template_id||e[7]!==r.tile_kind?(l=()=>{if(ne("home_agent_tile_clicked",{template_id:r.template_id,agent_id:s.id,agent_title:s.title,tile_kind:r.tile_kind,action:r.action}),i)i();else{const g=crypto.randomUUID();a({to:"/$org/$taskId",params:{org:o.slug,taskId:g},search:{virtualmcpid:s.id}})}},e[0]=s.id,e[1]=s.title,e[2]=a,e[3]=i,e[4]=o,e[5]=r.action,e[6]=r.template_id,e[7]=r.tile_kind,e[8]=l):l=e[8];const c=l;let d;e[9]===Symbol.for("react.memo_cache_sentinel")?(d=J("flex flex-col items-center gap-3 p-2 rounded-lg","transition-colors","cursor-pointer","w-[100px] shrink-0","group"),e[9]=d):d=e[9];const u=`Select agent ${s.title}`;let h;e[10]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx(po,{size:24}),e[10]=h):h=e[10];let f;e[11]!==s.icon||e[12]!==s.title?(f=n.jsx(Ls,{icon:s.icon,name:s.title,size:"md",fallbackIcon:h,className:"transition-transform group-hover:scale-110"}),e[11]=s.icon,e[12]=s.title,e[13]=f):f=e[13];let m;e[14]!==s.title?(m=n.jsx("p",{className:"text-xs sm:text-sm text-foreground text-center leading-tight line-clamp-2 break-words w-full",children:s.title}),e[14]=s.title,e[15]=m):m=e[15];let p;return e[16]!==c||e[17]!==u||e[18]!==f||e[19]!==m?(p=n.jsxs("button",{type:"button",onClick:c,className:d,"aria-label":u,children:[f,m]}),e[16]=c,e[17]=u,e[18]=f,e[19]=m,e[20]=p):p=e[20],p}function Lb(){const t=B.c(8),e=Ge(),{org:s}=xe();let i;t[0]===Symbol.for("react.memo_cache_sentinel")?(i=J("flex flex-col items-center gap-3 p-2 rounded-lg","transition-colors","cursor-pointer","w-[100px] shrink-0","group"),t[0]=i):i=t[0];let r;t[1]!==e||t[2]!==s.slug?(r=()=>{ne("home_see_all_agents_clicked"),e({to:"/$org/settings/agents",params:{org:s.slug}})},t[1]=e,t[2]=s.slug,t[3]=r):r=t[3];let o,a;t[4]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx("div",{className:"size-12 rounded-xl bg-accent flex items-center justify-center shrink-0 transition-transform group-hover:scale-110",children:n.jsx(El,{size:20,className:"text-foreground"})}),a=n.jsx("p",{className:"text-xs sm:text-sm text-foreground text-center leading-tight",children:"See all"}),t[4]=o,t[5]=a):(o=t[4],a=t[5]);let l;return t[6]!==r?(l=n.jsxs("button",{type:"button",className:i,"aria-label":"See all agents",onClick:r,children:[o,a]}),t[6]=r,t[7]=l):l=t[7],l}function Ob(){const t=B.c(9);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={navigateOnCreate:!0},t[0]=e):e=t[0];const{createVirtualMCP:s,isCreating:i}=ku(e);let r;t[1]!==s?(r=()=>{ne("home_create_agent_clicked"),s()},t[1]=s,t[2]=r):r=t[2];let o;t[3]===Symbol.for("react.memo_cache_sentinel")?(o=J("flex flex-col items-center gap-3 p-2 rounded-lg","transition-colors","cursor-pointer","w-[100px] shrink-0","group","disabled:opacity-50 disabled:cursor-not-allowed"),t[3]=o):o=t[3];let a,l;t[4]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx("div",{className:"size-12 rounded-xl bg-background border-2 border-dashed border-border flex items-center justify-center shrink-0 transition-transform group-hover:scale-110",children:n.jsx(Qt,{size:20,className:"text-muted-foreground"})}),l=n.jsx("p",{className:"text-xs sm:text-sm text-foreground text-center leading-tight",children:"Create agent"}),t[4]=a,t[5]=l):(a=t[4],l=t[5]);let c;return t[6]!==i||t[7]!==r?(c=n.jsxs("button",{type:"button",onClick:r,disabled:i,className:o,"aria-label":"Create agent",children:[a,l]}),t[6]=i,t[7]=r,t[8]=c):c=t[8],c}function Bb(){const t=B.c(104),e=fo(),{locator:s}=xe(),[i,r]=S.useState(!1),[o,a]=S.useState(!1),[l,c]=S.useState(!1),[d,u]=S.useState(!1),[h,f]=S.useState(!1),[m]=yi(),p=Yn();let g;t[0]===Symbol.for("react.memo_cache_sentinel")?(g=ks.find(Wb),t[0]=g):g=t[0];const _=g;let v;t[1]===Symbol.for("react.memo_cache_sentinel")?(v=ks.find(Hb),t[1]=v):v=t[1];const x=v;let b;t[2]===Symbol.for("react.memo_cache_sentinel")?(b=ks.find(Ub),t[2]=b):b=t[2];const y=b;let C;t[3]===Symbol.for("react.memo_cache_sentinel")?(C=ks.find(Fb),t[3]=C):C=t[3];const k=C;let w;t[4]===Symbol.for("react.memo_cache_sentinel")?(w=ks.find(zb),t[4]=w):w=t[4];const V=w;let j,I,T,R,N,A,E,M,L,D,P,O;if(t[5]!==s||t[6]!==p||t[7]!==m.experimental_vibecode||t[8]!==e){const ee=Pb(s),Z=e.filter($b).sort((ye,Ae)=>{const fe=ee.indexOf(ye.id),ke=ee.indexOf(Ae.id);return fe!==-1&&ke!==-1?fe-ke:fe!==-1?-1:ke!==-1?1:new Date(Ae.updated_at).getTime()-new Date(ye.updated_at).getTime()}).slice(0,4);let X;if(t[21]!==e){let ye;t[23]===Symbol.for("react.memo_cache_sentinel")?(ye=Ae=>Ae.id!==null&&(Ae.metadata?.type===x.id||Ae.title===x.title),t[23]=ye):ye=t[23],X=e.find(ye),t[21]=e,t[22]=X}else X=t[22];T=X;let ie;if(t[24]!==e){let ye;t[26]===Symbol.for("react.memo_cache_sentinel")?(ye=Ae=>Ae.id!==null&&(Ae.metadata?.type===y.id||Ae.title===y.title),t[26]=ye):ye=t[26],ie=e.find(ye),t[24]=e,t[25]=ie}else ie=t[25];j=ie;let re;if(t[27]!==e){let ye;t[29]===Symbol.for("react.memo_cache_sentinel")?(ye=Ae=>Ae.id!==null&&(Ae.metadata?.type===k.id||Ae.title===k.title),t[29]=ye):ye=t[29],re=e.find(ye),t[27]=e,t[28]=re}else re=t[28];I=re,R=Z.length>0,E="w-full max-md:overflow-x-auto max-md:[scrollbar-width:none] max-md:[&::-webkit-scrollbar]:hidden",M="flex flex-wrap justify-center gap-1.5 max-md:flex-nowrap max-md:justify-start md:max-h-52 md:overflow-hidden",t[30]===Symbol.for("react.memo_cache_sentinel")?(L=n.jsx(Ai,{agent:_,onSpecialClick:()=>r(!0),tracking:{template_id:_.id,tile_kind:"template",action:"open_modal"}},_.id),t[30]=L):L=t[30],t[31]!==m.experimental_vibecode?(D=m.experimental_vibecode&&n.jsx(Ai,{agent:V,onSpecialClick:()=>f(!0),tracking:{template_id:V.id,tile_kind:"template",action:"open_modal"}},V.id),t[31]=m.experimental_vibecode,t[32]=D):D=t[32];const de=T??x;let me;t[33]!==T||t[34]!==p?(me=T?()=>p(T.id):()=>a(!0),t[33]=T,t[34]=p,t[35]=me):me=t[35];const le=T?"existing":"template",se=T?"navigate":"open_modal";let _e;t[36]!==le||t[37]!==se?(_e={template_id:x.id,tile_kind:le,action:se},t[36]=le,t[37]=se,t[38]=_e):_e=t[38],t[39]!==de||t[40]!==me||t[41]!==_e?(P=n.jsx(Ai,{agent:de,onSpecialClick:me,tracking:_e},x.id),t[39]=de,t[40]=me,t[41]=_e,t[42]=P):P=t[42];const ge=j??y;let Se;t[43]!==j||t[44]!==p?(Se=j?()=>p(j.id):()=>c(!0),t[43]=j,t[44]=p,t[45]=Se):Se=t[45];const ve=j?"existing":"template",Ne=j?"navigate":"open_modal";let Te;t[46]!==ve||t[47]!==Ne?(Te={template_id:y.id,tile_kind:ve,action:Ne},t[46]=ve,t[47]=Ne,t[48]=Te):Te=t[48],t[49]!==ge||t[50]!==Se||t[51]!==Te?(O=n.jsx(Ai,{agent:ge,onSpecialClick:Se,tracking:Te},y.id),t[49]=ge,t[50]=Se,t[51]=Te,t[52]=O):O=t[52];const te=I??k;let he;t[53]!==I||t[54]!==p?(he=I?()=>p(I.id):()=>u(!0),t[53]=I,t[54]=p,t[55]=he):he=t[55];const we=I?"existing":"template",Ee=I?"navigate":"open_modal";let Ie;t[56]!==we||t[57]!==Ee?(Ie={template_id:k.id,tile_kind:we,action:Ee},t[56]=we,t[57]=Ee,t[58]=Ie):Ie=t[58],t[59]!==te||t[60]!==he||t[61]!==Ie?(N=n.jsx(Ai,{agent:te,onSpecialClick:he,tracking:Ie},k.id),t[59]=te,t[60]=he,t[61]=Ie,t[62]=N):N=t[62];let De;t[63]!==j?.id||t[64]!==I?.id||t[65]!==T?.id?(De=ye=>ye.id!==T?.id&&ye.id!==j?.id&&ye.id!==I?.id,t[63]=j?.id,t[64]=I?.id,t[65]=T?.id,t[66]=De):De=t[66];let Pe;t[67]!==p?(Pe=ye=>n.jsx(Ai,{agent:ye,onSpecialClick:()=>p(ye.id),tracking:{template_id:null,tile_kind:"recent",action:"navigate"}},ye.id??"default"),t[67]=p,t[68]=Pe):Pe=t[68],A=Z.filter(De).map(Pe),t[5]=s,t[6]=p,t[7]=m.experimental_vibecode,t[8]=e,t[9]=j,t[10]=I,t[11]=T,t[12]=R,t[13]=N,t[14]=A,t[15]=E,t[16]=M,t[17]=L,t[18]=D,t[19]=P,t[20]=O}else j=t[9],I=t[10],T=t[11],R=t[12],N=t[13],A=t[14],E=t[15],M=t[16],L=t[17],D=t[18],P=t[19],O=t[20];let z;t[69]===Symbol.for("react.memo_cache_sentinel")?(z=n.jsx(Ob,{}),t[69]=z):z=t[69];let $;t[70]!==R?($=R&&n.jsx(Lb,{}),t[70]=R,t[71]=$):$=t[71];let q;t[72]!==N||t[73]!==A||t[74]!==$||t[75]!==M||t[76]!==L||t[77]!==D||t[78]!==P||t[79]!==O?(q=n.jsxs("div",{className:M,children:[L,D,P,O,N,A,z,$]}),t[72]=N,t[73]=A,t[74]=$,t[75]=M,t[76]=L,t[77]=D,t[78]=P,t[79]=O,t[80]=q):q=t[80];let F;t[81]!==E||t[82]!==q?(F=n.jsx("div",{className:E,children:q}),t[81]=E,t[82]=q,t[83]=F):F=t[83];let G;t[84]!==i?(G=n.jsx(Fr,{open:i,onOpenChange:r}),t[84]=i,t[85]=G):G=t[85];let H;t[86]!==o||t[87]!==T?(H=n.jsx(wu,{open:o,onOpenChange:a,existingAgent:T}),t[86]=o,t[87]=T,t[88]=H):H=t[88];let U;t[89]!==l||t[90]!==j?(U=n.jsx(mb,{open:l,onOpenChange:c,existingAgent:j}),t[89]=l,t[90]=j,t[91]=U):U=t[91];let Y;t[92]!==d||t[93]!==I?(Y=n.jsx(xb,{open:d,onOpenChange:u,existingAgent:I}),t[92]=d,t[93]=I,t[94]=Y):Y=t[94];let W;t[95]!==h?(W=n.jsx(rf,{open:h,onOpenChange:f}),t[95]=h,t[96]=W):W=t[96];let K;return t[97]!==F||t[98]!==G||t[99]!==H||t[100]!==U||t[101]!==Y||t[102]!==W?(K=n.jsxs(n.Fragment,{children:[F,G,H,U,Y,W]}),t[97]=F,t[98]=G,t[99]=H,t[100]=U,t[101]=Y,t[102]=W,t[103]=K):K=t[103],K}function $b(t){return t.id!==null&&!Br(t.id)}function zb(t){return t.id==="self-healing-storefront"}function Fb(t){return t.id==="ai-research"}function Ub(t){return t.id==="ai-image"}function Hb(t){return t.id==="site-diagnostics"}function Wb(t){return t.id==="site-editor"}function Kb(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx("div",{className:"w-full max-md:overflow-x-auto max-md:[scrollbar-width:none] max-md:[&::-webkit-scrollbar]:hidden",children:n.jsx("div",{className:"flex flex-wrap justify-center gap-1.5 max-md:flex-nowrap max-md:justify-start md:max-h-52 md:overflow-hidden",children:Array.from({length:7}).map(qb)})}),t[0]=e):e=t[0],e}function qb(t,e){return n.jsxs("div",{className:"flex flex-col items-center gap-3 p-2 w-[100px] shrink-0",children:[n.jsx(Fi,{className:"size-12 rounded-xl shrink-0"}),n.jsx(Fi,{className:"h-3 sm:h-4 w-full"})]},e)}function Qc(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(S.Suspense,{fallback:n.jsx(Kb,{}),children:n.jsx(Bb,{})}),t[0]=e):e=t[0],e}function on(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}k`:String(t)}function Zc(t){if(!t)return"—";const e=typeof t=="string"?new Date(t):t;return isNaN(e.getTime())?"—":e.toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"})}function Gb(t){return t?t.replace(/-\d{8}(?:-[a-z0-9]+)*$/i,"").replace(/-/g," "):"—"}function Yb(t){const e=B.c(4),{items:s}=t;let i;e[0]!==s?(i=s.map(Xb),e[0]=s,e[1]=i):i=e[1];let r;return e[2]!==i?(r=n.jsx("div",{className:"grid grid-cols-2 gap-x-8 gap-y-6",children:i}),e[2]=i,e[3]=r):r=e[3],r}function Xb(t){return n.jsxs("div",{className:"flex flex-col gap-1 min-w-0",children:[n.jsx("span",{className:"text-xs text-muted-foreground truncate",children:t.label}),n.jsx("span",{className:"text-sm text-foreground tabular-nums truncate",children:t.value})]},t.label)}function Jb(t){const e=B.c(30),{userTokens:s,assistantTokens:i,otherTokens:r}=t,o=s+i+r,a=o>0?s/o*100:0,l=o>0?i/o*100:0,c=o>0?r/o*100:0;let d;e[0]!==a?(d=a>0&&n.jsx("div",{className:"h-full bg-chart-1",style:{width:`${a}%`}}),e[0]=a,e[1]=d):d=e[1];let u;e[2]!==l?(u=l>0&&n.jsx("div",{className:"h-full bg-chart-2",style:{width:`${l}%`}}),e[2]=l,e[3]=u):u=e[3];let h;e[4]!==c?(h=c>0&&n.jsx("div",{className:"h-full bg-muted-foreground/30",style:{width:`${c}%`}}),e[4]=c,e[5]=h):h=e[5];let f;e[6]!==d||e[7]!==u||e[8]!==h?(f=n.jsxs("div",{className:"flex h-2 w-full overflow-hidden rounded-full bg-muted",children:[d,u,h]}),e[6]=d,e[7]=u,e[8]=h,e[9]=f):f=e[9];let m;e[10]===Symbol.for("react.memo_cache_sentinel")?(m=n.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-chart-1 shrink-0"}),e[10]=m):m=e[10];let p;e[11]!==a?(p=a.toFixed(1),e[11]=a,e[12]=p):p=e[12];let g;e[13]!==p?(g=n.jsxs("div",{className:"flex items-center gap-1.5",children:[m,n.jsxs("span",{className:"text-xs text-muted-foreground",children:["User ",p,"%"]})]}),e[13]=p,e[14]=g):g=e[14];let _;e[15]===Symbol.for("react.memo_cache_sentinel")?(_=n.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-chart-2 shrink-0"}),e[15]=_):_=e[15];let v;e[16]!==l?(v=l.toFixed(1),e[16]=l,e[17]=v):v=e[17];let x;e[18]!==v?(x=n.jsxs("div",{className:"flex items-center gap-1.5",children:[_,n.jsxs("span",{className:"text-xs text-muted-foreground",children:["Assistant ",v,"%"]})]}),e[18]=v,e[19]=x):x=e[19];let b;e[20]!==c||e[21]!==r?(b=r>0&&n.jsxs("div",{className:"flex items-center gap-1.5",children:[n.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-muted-foreground/30 shrink-0"}),n.jsxs("span",{className:"text-xs text-muted-foreground",children:["Other ",c.toFixed(1),"%"]})]}),e[20]=c,e[21]=r,e[22]=b):b=e[22];let y;e[23]!==x||e[24]!==b||e[25]!==g?(y=n.jsxs("div",{className:"flex flex-wrap gap-x-3 gap-y-1",children:[g,x,b]}),e[23]=x,e[24]=b,e[25]=g,e[26]=y):y=e[26];let C;return e[27]!==y||e[28]!==f?(C=n.jsxs("div",{className:"flex flex-col gap-2",children:[f,y]}),e[27]=y,e[28]=f,e[29]=C):C=e[29],C}function Qb(t){const e=B.c(19),{part:s}=t,i=s.input?.agent_id,r=is(i),o=r?.title??"Subtask",a=r?.icon??null,l=s.state==="input-streaming"||s.state==="input-available"||s.state==="output-available"&&s.preliminary===!0,c=s.state==="output-error",d=s.state==="approval-requested";let u;e[0]!==a||e[1]!==o?(u=n.jsx(Ls,{icon:a,name:o,size:"xs",className:"size-6 rounded-md shrink-0"}),e[0]=a,e[1]=o,e[2]=u):u=e[2];const h=c?"text-destructive":"text-foreground";let f;e[3]!==h?(f=J("shrink-0 font-medium",h),e[3]=h,e[4]=f):f=e[4];let m;e[5]!==o||e[6]!==f?(m=n.jsx("span",{className:f,children:o}),e[5]=o,e[6]=f,e[7]=m):m=e[7];let p;e[8]!==s.input?(p=s.input?.prompt&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"text-muted-foreground/50",children:"·"}),n.jsx("span",{className:"truncate text-muted-foreground",children:s.input.prompt})]}),e[8]=s.input,e[9]=p):p=e[9];let g;e[10]!==d||e[11]!==c||e[12]!==l?(g=n.jsx("span",{className:"ml-auto shrink-0",children:l?n.jsx(Me,{size:12,className:"animate-spin text-muted-foreground"}):c?n.jsx(Yg,{size:12,className:"text-destructive"}):d?n.jsx(oi,{size:12,className:"text-warning"}):n.jsx(N_,{size:12,className:"text-emerald-500"})}),e[10]=d,e[11]=c,e[12]=l,e[13]=g):g=e[13];let _;return e[14]!==u||e[15]!==m||e[16]!==p||e[17]!==g?(_=n.jsxs("div",{className:"flex items-center gap-2 text-xs min-w-0",children:[u,m,p,g]}),e[14]=u,e[15]=m,e[16]=p,e[17]=g,e[18]=_):_=e[18],_}function Zb(t){const e=B.c(58),{onClose:s,back:i,className:r}=t,[o,a]=S.useState(null),{messages:l}=Yi(),{tasks:c,taskId:d}=es(),{selectedModel:u,selectedVirtualMcp:h}=ai();let f,m,p,g,_,v,x,b;if(e[0]!==i||e[1]!==r||e[2]!==l||e[3]!==s||e[4]!==o?.id||e[5]!==u||e[6]!==h?.title||e[7]!==d||e[8]!==c){b=Symbol.for("react.early_return_sentinel");e:{let k;e[17]!==d?(k=X=>X.id===d,e[17]=d,e[18]=k):k=e[18];const w=c.find(k),V=Bh(l),j=[...l].reverse().find(l0),I=j?.metadata?.usage,T=j?.metadata?.modelLimits?.contextWindow??u?.limits?.contextWindow??null,R=I?.contextTokens??I?.totalTokens??0,N=T&&T>0?(R/T*100).toFixed(1):null,A=l;let E;e[19]!==A?(E=A.filter(a0).reduce(o0,0),e[19]=A,e[20]=E):E=e[20];const M=E,L=l;let D;e[21]!==L?(D=L.filter(r0).reduce(n0,0),e[21]=L,e[22]=D):D=e[22];const P=D,O=Math.max(0,V.totalTokens-M-P),z=l[0],$=l.at(-1),q=z?.metadata?.created_at??w?.created_at,F=$?.metadata?.created_at??w?.updated_at,G=l.filter(i0),H=l.flatMap(t0),U=u?.modelId?Gb(u.modelId):"—",Y=h?.title??"Decopilot",W=[{label:"Session",value:w?.title??"New chat"},{label:"Messages",value:G.length},{label:"Agent",value:Y},{label:"Model",value:U},{label:"Context Limit",value:T?on(T):"—"},{label:"Session Tokens (billed)",value:V.totalTokens>0?on(V.totalTokens):"0"},{label:"Usage",value:N!==null?`${N}%`:"—"},{label:"Input Tokens",value:V.inputTokens>0?on(V.inputTokens):"0"},{label:"Output Tokens",value:V.outputTokens>0?on(V.outputTokens):"0"},{label:"Reasoning Tokens",value:V.reasoningTokens>0?on(V.reasoningTokens):"0"},{label:"Cost",value:V.cost>0?`$${V.cost<.001?V.cost.toFixed(6):V.cost.toFixed(4)}`:"$0.00"},{label:"Session Created",value:Zc(q)},{label:"Last Activity",value:Zc(F)}];if(!w&&G.length===0){let X;e[23]!==r?(X=J("flex flex-col h-full w-full border-l border-border bg-background",r),e[23]=r,e[24]=X):X=e[24];let ie;e[25]===Symbol.for("react.memo_cache_sentinel")?(ie=n.jsx("span",{className:"text-sm font-medium text-foreground",children:"Context"}),e[25]=ie):ie=e[25];let re;e[26]!==i?(re=i?n.jsx(ma,{size:14,className:"text-muted-foreground"}):n.jsx(ri,{size:14,className:"text-muted-foreground"}),e[26]=i,e[27]=re):re=e[27];let de;e[28]!==s||e[29]!==re?(de=n.jsxs("div",{className:"h-11 px-4 flex items-center justify-between shrink-0 border-b border-border/50",children:[ie,n.jsx("button",{type:"button",onClick:s,className:"flex size-6 items-center justify-center rounded hover:bg-accent transition-colors",children:re})]}),e[28]=s,e[29]=re,e[30]=de):de=e[30];let me;e[31]===Symbol.for("react.memo_cache_sentinel")?(me=n.jsx("div",{className:"flex-1 flex items-center justify-center px-4 text-center",children:n.jsx("p",{className:"text-xs text-muted-foreground",children:"Start a conversation to see context"})}),e[31]=me):me=e[31];let le;e[32]!==X||e[33]!==de?(le=n.jsxs("div",{className:X,children:[de,me]}),e[32]=X,e[33]=de,e[34]=le):le=e[34],b=le;break e}e[35]!==r?(v=J("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 K;e[37]===Symbol.for("react.memo_cache_sentinel")?(K=n.jsx("span",{className:"text-sm font-medium text-foreground",children:"Context"}),e[37]=K):K=e[37];let ee;e[38]!==i?(ee=i?n.jsx(ma,{size:14}):n.jsx(ri,{size:14}),e[38]=i,e[39]=ee):ee=e[39],e[40]!==s||e[41]!==ee?(x=n.jsxs("div",{className:"flex h-11 shrink-0 items-center justify-between border-b border-border/50 px-4",children:[K,n.jsx("button",{type:"button",onClick:s,className:"flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",children:ee})]}),e[40]=s,e[41]=ee,e[42]=x):x=e[42],f="flex flex-col gap-8 p-6",m=H.length>0&&n.jsxs("div",{className:"flex flex-col gap-3",children:[n.jsx("span",{className:"text-xs text-muted-foreground",children:"Subtasks"}),n.jsx("div",{className:"flex flex-col gap-1",children:H.map(e0)})]}),p=n.jsx(Yb,{items:W});let Z;e[43]===Symbol.for("react.memo_cache_sentinel")?(Z=n.jsx("span",{className:"text-xs text-muted-foreground",children:"Context Breakdown"}),e[43]=Z):Z=e[43],e[44]!==P||e[45]!==O||e[46]!==M?(g=n.jsxs("div",{className:"flex flex-col gap-3",children:[Z,n.jsx(Jb,{userTokens:M,assistantTokens:P,otherTokens:O})]}),e[44]=P,e[45]=O,e[46]=M,e[47]=g):g=e[47],_=G.length>0&&n.jsxs("div",{className:"flex flex-col gap-3",children:[n.jsx("span",{className:"text-xs text-muted-foreground",children:"Raw messages"}),n.jsx("div",{className:"flex flex-col gap-1",children:G.map(X=>{const ie=X.metadata?.created_at,re=o?.id===X.id;return n.jsxs("div",{className:"rounded-md border border-border/50 overflow-hidden",children:[n.jsxs("button",{type:"button",onClick:()=>a(re?null:X),className:"flex items-center justify-between gap-2 px-3 py-2 text-xs hover:bg-accent/50 w-full text-left cursor-pointer",children:[n.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[n.jsx("span",{className:J("shrink-0 font-medium",X.role==="user"?"text-chart-1":"text-chart-2"),children:X.role}),n.jsx("span",{className:"text-muted-foreground",children:"•"}),n.jsx("span",{className:"truncate text-muted-foreground font-mono",children:X.id})]}),ie&&n.jsx("span",{className:"shrink-0 text-muted-foreground tabular-nums",children:new Date(ie).toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"})})]}),re&&n.jsx("pre",{className:"text-xs font-mono bg-muted px-3 py-2 overflow-auto whitespace-pre-wrap break-all border-t border-border/50 max-h-64",children:JSON.stringify(X,null,2)})]},X.id)})})]})}e[0]=i,e[1]=r,e[2]=l,e[3]=s,e[4]=o?.id,e[5]=u,e[6]=h?.title,e[7]=d,e[8]=c,e[9]=f,e[10]=m,e[11]=p,e[12]=g,e[13]=_,e[14]=v,e[15]=x,e[16]=b}else f=e[9],m=e[10],p=e[11],g=e[12],_=e[13],v=e[14],x=e[15],b=e[16];if(b!==Symbol.for("react.early_return_sentinel"))return b;let y;e[48]!==f||e[49]!==m||e[50]!==p||e[51]!==g||e[52]!==_?(y=n.jsxs("div",{className:f,children:[m,p,g,_]}),e[48]=f,e[49]=m,e[50]=p,e[51]=g,e[52]=_,e[53]=y):y=e[53];let C;return e[54]!==v||e[55]!==x||e[56]!==y?(C=n.jsxs("div",{className:v,children:[x,y]}),e[54]=v,e[55]=x,e[56]=y,e[57]=C):C=e[57],C}function e0(t,e){return n.jsx(Qb,{part:t},e)}function t0(t){return(t.parts??[]).filter(s0)}function s0(t){return t.type==="tool-subtask"}function i0(t){return t.role!=="system"}function n0(t,e){const s=e.metadata?.usage;return t+(s?.outputTokens??0)}function r0(t){return t.role==="assistant"}function o0(t,e){const s=e.metadata?.usage;return t+(s?.inputTokens??0)}function a0(t){return t.role==="user"}function l0(t){return t.role==="assistant"&&t.metadata?.usage}const ed=["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"],td=["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 c0(){const t=ed[Math.floor(Math.random()*ed.length)],e=td[Math.floor(Math.random()*td.length)];return`deco/${t}-${e}`}function d0(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 h0(t){const e=B.c(25),{orgId:s,userId:i,connectionId:r,vmMap:o,owner:a,repo:l,enabled:c}=t,d=c===void 0?!0:c,u=r??null;let h;e[0]!==s||e[1]!==u?(h={connectionId:u,orgId:s},e[0]=s,e[1]=u,e[2]=h):h=e[2];const f=Be(h);let m;e[3]!==a||e[4]!==l?(m={owner:a,repo:l},e[3]=a,e[4]=l,e[5]=m):m=e[5];const p=d&&!!r&&!!a&&!!l;let g;e[6]!==f||e[7]!==m||e[8]!==p?(g={client:f,toolName:"list_branches",toolArguments:m,enabled:p,staleTime:3e4,select:p0},e[6]=f,e[7]=m,e[8]=p,e[9]=g):g=e[9];const{data:_,isLoading:v,isError:x}=ki(g);let b,y;e[10]!==i||e[11]!==o?(y=new Set(Object.keys(o?.[i]??{})),b=[...y].sort().map(m0),e[10]=i,e[11]=o,e[12]=b,e[13]=y):(b=e[12],y=e[13]);const C=b;let k;if(e[14]!==_||e[15]!==y){const I=Array.isArray(_)?_:_?.branches??[];let T;e[17]!==y?(T=R=>!y.has(R.name),e[17]=y,e[18]=T):T=e[18],k=I.filter(f0).filter(T).map(u0),e[14]=_,e[15]=y,e[16]=k}else k=e[16];const w=k,V=Array.isArray(_)?null:_?.default_branch??null;let j;return e[19]!==V||e[20]!==x||e[21]!==v||e[22]!==w||e[23]!==C?(j={yours:C,others:w,defaultBase:V,isLoading:v,isError:x},e[19]=V,e[20]=x,e[21]=v,e[22]=w,e[23]=C,e[24]=j):j=e[24],j}function u0(t){return{name:t.name,source:"other",author:typeof t.commit?.author=="string"?t.commit.author:t.commit?.author?.login??null}}function f0(t){return typeof t.name=="string"}function m0(t){return{name:t,source:"yours"}}function p0(t){return d0(t)}function g0(t){const e=B.c(41),{orgId:s,userId:i,connectionId:r,owner:o,repo:a,vmMap:l,value:c,onChange:d}=t,[u,h]=S.useState(!1);let f;e[0]!==r||e[1]!==u||e[2]!==s||e[3]!==o||e[4]!==a||e[5]!==i||e[6]!==l?(f={orgId:s,userId:i,connectionId:r,vmMap:l,owner:o,repo:a,enabled:u},e[0]=r,e[1]=u,e[2]=s,e[3]=o,e[4]=a,e[5]=i,e[6]=l,e[7]=f):f=e[7];const{yours:m,others:p,isLoading:g,isError:_}=h0(f);let v;e[8]!==d?(v=E=>{d(E),h(!1)},e[8]=d,e[9]=v):v=e[9];const x=v,b=c??"Select branch…";let y;e[10]===Symbol.for("react.memo_cache_sentinel")?(y=n.jsx(yn,{className:"h-3.5 w-3.5"}),e[10]=y):y=e[10];let C;e[11]!==b?(C=n.jsx(li,{asChild:!0,children:n.jsxs(ae,{variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 font-mono text-xs",children:[y,n.jsx("span",{className:"max-w-[200px] truncate",children:b})]})}),e[11]=b,e[12]=C):C=e[12];let k;e[13]===Symbol.for("react.memo_cache_sentinel")?(k=n.jsx(v_,{placeholder:"Search branches…"}),e[13]=k):k=e[13];let w;e[14]!==x?(w=n.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:[k,n.jsx(ae,{variant:"outline",size:"sm",className:"h-7 shrink-0",onClick:()=>x(c0()),children:"New"})]}),e[14]=x,e[15]=w):w=e[15];let V;e[16]!==_?(V=_&&n.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[16]=_,e[17]=V):V=e[17];let j;e[18]!==_||e[19]!==g||e[20]!==p.length||e[21]!==m.length?(j=!_&&!g&&m.length===0&&p.length===0&&n.jsx(__,{children:"No branches found."}),e[18]=_,e[19]=g,e[20]=p.length,e[21]=m.length,e[22]=j):j=e[22];let I;e[23]!==x||e[24]!==m?(I=m.length>0&&n.jsx(jc,{heading:"Your branches",children:m.map(E=>n.jsxs(Nc,{value:E.name,onSelect:()=>x(E.name),children:[n.jsx(yn,{className:"mr-2 h-4 w-4"}),n.jsx("span",{className:"flex-1 truncate",children:E.name})]},E.name))}),e[23]=x,e[24]=m,e[25]=I):I=e[25];let T;e[26]!==p||e[27]!==x?(T=p.length>0&&n.jsxs(n.Fragment,{children:[n.jsx(x_,{}),n.jsx(jc,{heading:"Other branches in repo",children:p.map(E=>n.jsxs(Nc,{value:E.name,onSelect:()=>x(E.name),children:[n.jsx(yn,{className:"mr-2 h-4 w-4"}),n.jsx("span",{className:"flex-1 truncate",children:E.name}),E.author&&n.jsxs("span",{className:"text-xs text-muted-foreground",children:["@",E.author]})]},E.name))})]}),e[26]=p,e[27]=x,e[28]=T):T=e[28];let R;e[29]!==T||e[30]!==V||e[31]!==j||e[32]!==I?(R=n.jsxs(b_,{children:[V,j,I,T]}),e[29]=T,e[30]=V,e[31]=j,e[32]=I,e[33]=R):R=e[33];let N;e[34]!==R||e[35]!==w?(N=n.jsx(ci,{className:"w-[min(420px,calc(100vw-2rem))] p-0",align:"start",children:n.jsxs(y_,{children:[w,R]})}),e[34]=R,e[35]=w,e[36]=N):N=e[36];let A;return e[37]!==u||e[38]!==N||e[39]!==C?(A=n.jsxs(di,{open:u,onOpenChange:h,children:[C,N]}),e[37]=u,e[38]=N,e[39]=C,e[40]=A):A=e[40],A}const _0=["radial-gradient(ellipse 25% 220% at -5% 120%, rgba(165,149,255,0.35) 0%, transparent 100%)","radial-gradient(ellipse 25% 220% at 105% -20%, rgba(208,236,26,0.32) 0%, transparent 100%)"].join(", "),x0="/decotexture.svg";function sd(t){const e=B.c(7),{onClick:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={backgroundImage:_0},e[0]=i):i=e[0];let r,o;e[1]===Symbol.for("react.memo_cache_sentinel")?(r=n.jsx("div",{className:"relative shrink-0 p-1.5 bg-[var(--brand-green-light)] rounded-lg border border-border",children:n.jsx(Ls,{icon:"/logos/deco%20logo.svg",name:"deco.cx",size:"xs",className:"border-0 rounded-none bg-transparent"})}),o=n.jsx("p",{className:"flex-1 relative text-sm font-medium text-foreground leading-none whitespace-nowrap",children:"Import your deco.cx site"}),e[1]=r,e[2]=o):(r=e[1],o=e[2]);let a;e[3]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx("img",{src:x0,alt:"","aria-hidden":!0,className:"absolute pointer-events-none",style:{width:"274.5px",height:"272.25px",left:"calc(50% + 145.5px)",top:"calc(50% + 40px)",transform:"translate(-50%, -50%)"}}),e[3]=a):a=e[3];let l;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=n.jsx("div",{className:"relative bg-background flex items-center justify-center size-8 rounded-md shrink-0",children:n.jsx(ho,{size:16,className:"text-foreground transition-transform group-hover:translate-x-0.5"})}),e[4]=l):l=e[4];let c;return e[5]!==s?(c=n.jsxs("button",{type:"button",onClick:s,className:"w-full relative flex items-center gap-4 px-4 py-4 rounded-lg border border-border bg-background overflow-hidden transition-colors text-left cursor-pointer group",style:i,children:[r,o,a,l]}),e[5]=s,e[6]=c):c=e[6],c}function v0(){const t=B.c(5),{data:e}=St.useSession();let s;t[0]!==e?.user?.email?(s=ct.decoProfile(e?.user?.email),t[0]=e?.user?.email,t[1]=s):s=t[1];const i=!!e?.user?.email;let r;t[2]!==s||t[3]!==i?(r={queryKey:s,queryFn:b0,enabled:i,staleTime:3e5},t[2]=s,t[3]=i,t[4]=r):r=t[4];const{data:o}=Ki(r);return o?.isDecoUser??!1}async function b0(){const t=await fetch("/api/deco-sites/profile");return t.ok?t.json():{isDecoUser:!1}}function y0(t){const e=B.c(56),{onOpenContextPanel:s}=t,{data:i}=St.useSession(),[r,o]=S.useState(!1),a=v0(),l=Ps(),{hasDecoKey:c,isZeroBalance:d,isInitialFreeCredit:u,balanceDollars:h,hasOnlyDecoProvider:f}=go();let m;e[0]!==i?.user?.name?(m=i?.user?.name?.split(" ")[0]||"there",e[0]=i?.user?.name,e[1]=m):m=e[1];const p=m,g=c&&u&&h!=null,_=c&&d&&f;if(l){let N;e[2]!==h||e[3]!==g?(N=g&&n.jsx("div",{className:"mb-4",children:n.jsx($e.CreditsEyebrow,{balanceDollars:h})}),e[2]=h,e[3]=g,e[4]=N):N=e[4];let A;e[5]!==_?(A=_&&n.jsx("div",{className:"mb-4",children:n.jsx($e.NoCreditsEyebrow,{})}),e[5]=_,e[6]=A):A=e[6];let E;e[7]!==p?(E=n.jsxs("p",{className:"text-3xl font-medium text-foreground text-center max-w-[280px]",children:["What's on your mind, ",p,"?"]}),e[7]=p,e[8]=E):E=e[8];let M;e[9]!==N||e[10]!==A||e[11]!==E?(M=n.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center w-full",children:[N,A,E]}),e[9]=N,e[10]=A,e[11]=E,e[12]=M):M=e[12];let L;e[13]===Symbol.for("react.memo_cache_sentinel")?(L=n.jsx(Qc,{}),e[13]=L):L=e[13];let D;e[14]!==s?(D=n.jsxs("div",{className:"w-full flex flex-col gap-4 pb-4",children:[L,n.jsx($e.Input,{onOpenContextPanel:s,showConnectionsBanner:!0})]}),e[14]=s,e[15]=D):D=e[15];let P;e[16]!==a?(P=a&&n.jsx("div",{className:"w-full",children:n.jsx(sd,{onClick:()=>o(!0)})}),e[16]=a,e[17]=P):P=e[17];let O;e[18]!==M||e[19]!==D||e[20]!==P?(O=n.jsxs("div",{className:"flex-1 relative flex flex-col items-center px-4",children:[M,D,P]}),e[18]=M,e[19]=D,e[20]=P,e[21]=O):O=e[21];let z;e[22]!==r?(z=n.jsx(Fr,{open:r,onOpenChange:o}),e[22]=r,e[23]=z):z=e[23];let $;return e[24]!==z||e[25]!==O?($=n.jsxs(n.Fragment,{children:[O,z]}),e[24]=z,e[25]=O,e[26]=$):$=e[26],$}let v;e[27]!==h||e[28]!==g?(v=g&&n.jsx("div",{className:"mb-4",children:n.jsx($e.CreditsEyebrow,{balanceDollars:h})}),e[27]=h,e[28]=g,e[29]=v):v=e[29];let x;e[30]!==_?(x=_&&n.jsx("div",{className:"mb-4",children:n.jsx($e.NoCreditsEyebrow,{})}),e[30]=_,e[31]=x):x=e[31];let b;e[32]!==p?(b=n.jsxs("p",{className:"text-3xl font-medium text-foreground",children:["What's on your mind, ",p,"?"]}),e[32]=p,e[33]=b):b=e[33];let y;e[34]!==v||e[35]!==x||e[36]!==b?(y=n.jsxs("div",{className:"text-center mb-10",children:[v,x,b]}),e[34]=v,e[35]=x,e[36]=b,e[37]=y):y=e[37];let C;e[38]!==s?(C=n.jsx("div",{className:"w-full",children:n.jsx($e.Input,{onOpenContextPanel:s,showConnectionsBanner:!0})}),e[38]=s,e[39]=C):C=e[39];let k;e[40]!==y||e[41]!==C?(k=n.jsxs("div",{className:"flex flex-col items-center w-full max-w-[672px]",children:[y,C]}),e[40]=y,e[41]=C,e[42]=k):k=e[42];let w;e[43]===Symbol.for("react.memo_cache_sentinel")?(w=n.jsx("div",{className:"w-full mt-10 mx-auto",children:n.jsx(Qc,{})}),e[43]=w):w=e[43];let V;e[44]!==k?(V=n.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center w-full",children:[k,w]}),e[44]=k,e[45]=V):V=e[45];let j;e[46]!==a?(j=a&&n.jsx("div",{className:"absolute bottom-6 left-0 right-0 px-10",children:n.jsx("div",{className:"w-full max-w-[500px] mx-auto",children:n.jsx(sd,{onClick:()=>o(!0)})})}),e[46]=a,e[47]=j):j=e[47];let I;e[48]!==j||e[49]!==V?(I=n.jsxs("div",{className:"flex-1 relative flex flex-col items-center px-10",children:[V,j]}),e[48]=j,e[49]=V,e[50]=I):I=e[50];let T;e[51]!==r?(T=n.jsx(Fr,{open:r,onOpenChange:o}),e[51]=r,e[52]=T):T=e[52];let R;return e[53]!==I||e[54]!==T?(R=n.jsxs(n.Fragment,{children:[I,T]}),e[53]=I,e[54]=T,e[55]=R):R=e[55],R}function S0(){const t=B.c(26),{org:e}=xe(),{selectedVirtualMcp:s}=ai(),{data:i}=St.useSession(),{currentBranch:r,setCurrentTaskBranch:o}=es();let a;t[0]!==e.id?(a=co(e.id),t[0]=e.id,t[1]=a):a=t[1];const c=s??a,d=is(c.id),u=i?.user?.id??"",h=d?.metadata?.githubRepo??null,f=!!h?.connectionId&&!!u;let m;t[2]===Symbol.for("react.memo_cache_sentinel")?(m=n.jsx(po,{size:32}),t[2]=m):m=t[2];let p;t[3]!==c.icon||t[4]!==c.title?(p=n.jsx(Ls,{icon:c.icon,name:c.title,size:"lg",fallbackIcon:m,className:"size-10 min-w-10 md:size-[60px]! md:min-w-[60px] rounded-xl md:rounded-[18px]!"}),t[3]=c.icon,t[4]=c.title,t[5]=p):p=t[5];let g;t[6]!==c.title?(g=n.jsx("h3",{className:"text-base md:text-xl font-medium text-foreground",children:c.title}),t[6]=c.title,t[7]=g):g=t[7];const _=c.description??"Ask anything about configuring model providers or using MCP Mesh.";let v;t[8]!==_?(v=n.jsx("div",{className:"text-muted-foreground text-center text-base max-w-md line-clamp-2",children:_}),t[8]=_,t[9]=v):v=t[9];let x;t[10]!==r||t[11]!==d?.metadata?.vmMap||t[12]!==h||t[13]!==e.id||t[14]!==o||t[15]!==f||t[16]!==u?(x=f&&n.jsx("div",{className:"mt-2",children:n.jsx(g0,{orgId:e.id,userId:u,connectionId:h.connectionId,owner:h.owner,repo:h.name,vmMap:d?.metadata?.vmMap,value:r??void 0,onChange:o})}),t[10]=r,t[11]=d?.metadata?.vmMap,t[12]=h,t[13]=e.id,t[14]=o,t[15]=f,t[16]=u,t[17]=x):x=t[17];let b;t[18]!==p||t[19]!==g||t[20]!==v||t[21]!==x?(b=n.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 md:gap-4 text-center",children:[p,g,v,x]}),t[18]=p,t[19]=g,t[20]=v,t[21]=x,t[22]=b):b=t[22];let y;t[23]===Symbol.for("react.memo_cache_sentinel")?(y=n.jsx("div",{className:"w-full max-w-3xl mx-auto",children:n.jsx($e.IceBreakers,{})}),t[23]=y):y=t[23];let C;return t[24]!==b?(C=n.jsxs("div",{className:"h-full w-full flex flex-col items-center justify-center gap-6 px-4",children:[b,y]}),t[24]=b,t[25]=C):C=t[25],C}function w0(t){const e=B.c(27),{variant:s}=t,{org:i}=xe(),r=jl(),{isChatEmpty:o}=Yi(),[a,l]=S.useState("chat"),c=go();if(r.length===0){let C;return e[0]===Symbol.for("react.memo_cache_sentinel")?(C=n.jsx($e,{className:"animate-in fade-in-0 duration-200",children:n.jsx($e.Main,{className:"flex flex-col items-center",children:n.jsx($e.EmptyState,{children:n.jsx($e.NoAiProviderEmptyState,{})})})}),e[0]=C):C=e[0],C}let d;e[1]!==c.hasDecoKey||e[2]!==c.hasOnlyDecoProvider||e[3]!==c.isLoading||e[4]!==c.isZeroBalance||e[5]!==o||e[6]!==i?(d=c.hasDecoKey&&c.isZeroBalance&&c.hasOnlyDecoProvider&&!c.isLoading&&o&&!Xv(i.id),e[1]=c.hasDecoKey,e[2]=c.hasOnlyDecoProvider,e[3]=c.isLoading,e[4]=c.isZeroBalance,e[5]=o,e[6]=i,e[7]=d):d=e[7];const u=d;let h;e[8]!==u?(h=u&&n.jsx($e.CreditsEmptyState,{}),e[8]=u,e[9]=h):h=e[9];const f=a!=="chat"?"opacity-0 pointer-events-none":"opacity-100";let m;e[10]!==f?(m=J("absolute inset-0 flex flex-col transition-opacity duration-100 ease-out",f),e[10]=f,e[11]=m):m=e[11];let p;e[12]!==o||e[13]!==s?(p=o?s==="home"?n.jsx(y0,{onOpenContextPanel:()=>l("context")}):n.jsxs(n.Fragment,{children:[n.jsx($e.Main,{children:n.jsx(S0,{})}),n.jsx($e.Footer,{children:n.jsx($e.Input,{onOpenContextPanel:()=>l("context")})})]}):n.jsxs(n.Fragment,{children:[n.jsx($e.Main,{children:n.jsx($e.Messages,{})}),n.jsx($e.Footer,{children:n.jsx($e.Input,{onOpenContextPanel:()=>l("context")})})]}),e[12]=o,e[13]=s,e[14]=p):p=e[14];let g;e[15]!==m||e[16]!==p?(g=n.jsx("div",{className:m,children:p}),e[15]=m,e[16]=p,e[17]=g):g=e[17];const _=a==="context"?"opacity-100":"opacity-0 pointer-events-none";let v;e[18]!==_?(v=J("absolute inset-0 flex flex-col transition-opacity duration-100 ease-out",_),e[18]=_,e[19]=v):v=e[19];let x;e[20]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsx(Zb,{back:!0,onClose:()=>l("chat")}),e[20]=x):x=e[20];let b;e[21]!==v?(b=n.jsx("div",{className:v,children:x}),e[21]=v,e[22]=b):b=e[22];let y;return e[23]!==b||e[24]!==h||e[25]!==g?(y=n.jsxs($e,{className:"relative overflow-hidden animate-in fade-in-0 duration-200",children:[h,g,b]}),e[23]=b,e[24]=h,e[25]=g,e[26]=y):y=e[26],y}function of(t){const e=B.c(4),{variant:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx($e.Skeleton,{}),e[0]=i):i=e[0];let r;e[1]===Symbol.for("react.memo_cache_sentinel")?(r=n.jsx($e.Skeleton,{}),e[1]=r):r=e[1];let o;return e[2]!==s?(o=n.jsx(As,{fallback:i,children:n.jsx(S.Suspense,{fallback:r,children:n.jsx(w0,{variant:s})})}),e[2]=s,e[3]=o):o=e[3],o}function V0(){const t=B.c(6),{org:e,locator:s}=xe(),i=Mt();let r;t[0]!==s||t[1]!==i?(r=()=>{i.invalidateQueries({queryKey:ct.tasksPrefix(s)})},t[0]=s,t[1]=i,t[2]=r):r=t[2];let o;t[3]!==e.id||t[4]!==r?(o={orgId:e.id,onTaskStatus:r},t[3]=e.id,t[4]=r,t[5]=o):o=t[5],E_(o)}function C0(t){const e=B.c(8),{virtualMcpId:s,size:i,showAutomationBadge:r}=t,o=i===void 0?"sm":i;let a;e[0]!==o||e[1]!==s?(a=s?n.jsx(k0,{virtualMcpId:s,size:o}):n.jsx(gs,{icon:null,name:"?",size:o}),e[0]=o,e[1]=s,e[2]=a):a=e[2];let l;e[3]!==r?(l=r&&n.jsx("span",{"aria-label":"Automation-triggered",className:"absolute -bottom-0.5 -right-0.5 flex size-4 items-center justify-center rounded-full bg-blue-500 border border-blue-600 text-white",children:n.jsx(Hi,{size:10,className:"text-white"})}),e[3]=r,e[4]=l):l=e[4];let c;return e[5]!==a||e[6]!==l?(c=n.jsxs("div",{className:"relative shrink-0",children:[a,l]}),e[5]=a,e[6]=l,e[7]=c):c=e[7],c}function k0(t){const e=B.c(6),{virtualMcpId:s,size:i}=t,r=is(s);if(!r){let l;return e[0]!==i?(l=n.jsx(gs,{icon:null,name:"?",size:i}),e[0]=i,e[1]=l):l=e[1],l}const o=r.icon??null;let a;return e[2]!==r.title||e[3]!==i||e[4]!==o?(a=n.jsx(gs,{icon:o,name:r.title,size:i}),e[2]=r.title,e[3]=i,e[4]=o,e[5]=a):a=e[5],a}function Fs(t){const e=t?.metadata?.githubRepo;return e?.connectionId&&t?.connections?.some(i=>i.connection_id===e.connectionId)?e:null}function j0(t){const e=B.c(42),{task:s,isActive:i,onClick:r,onArchive:o,showAutomationBadge:a}=t,l=Qp(s.status),c=l.icon,d=is(s.virtual_mcp_id);let u;e[0]!==d?(u=Fs(d),e[0]=d,e[1]=u):u=e[1];const h=u,f="button",m=0;let p;e[2]!==r?(p=O=>{O.target===O.currentTarget&&(O.key==="Enter"||O.key===" ")&&(O.preventDefault(),r())},e[2]=r,e[3]=p):p=e[3];const g=i?"bg-accent":"hover:bg-accent/60";let _;e[4]!==g?(_=J("group/row flex items-center gap-3 px-2 py-1.5 rounded-md cursor-pointer transition-colors",g),e[4]=g,e[5]=_):_=e[5];let v;e[6]!==a||e[7]!==s.virtual_mcp_id?(v=n.jsx(C0,{virtualMcpId:s.virtual_mcp_id,size:"xs",showAutomationBadge:a}),e[6]=a,e[7]=s.virtual_mcp_id,e[8]=v):v=e[8];const x=s.title||"Untitled task";let b;e[9]!==x?(b=n.jsx("div",{className:"text-sm text-foreground truncate",children:x}),e[9]=x,e[10]=b):b=e[10];let y;e[11]!==h||e[12]!==s.branch||e[13]!==s.updated_at?(y=s.updated_at&&n.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground min-w-0",children:[s.branch?n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"truncate font-mono",children:s.branch}),n.jsx("span",{className:"shrink-0",children:"·"})]}):h?n.jsxs(n.Fragment,{children:[n.jsxs("span",{className:"truncate",children:[h.owner,"/",h.name]}),n.jsx("span",{className:"shrink-0",children:"·"})]}):null,n.jsx("span",{className:"shrink-0",children:Zp(new Date(s.updated_at))})]}),e[11]=h,e[12]=s.branch,e[13]=s.updated_at,e[14]=y):y=e[14];let C;e[15]!==y||e[16]!==b?(C=n.jsxs("div",{className:"flex-1 min-w-0",children:[b,y]}),e[15]=y,e[16]=b,e[17]=C):C=e[17];const k="shrink-0 grid [grid-template-areas:'slot'] items-center justify-items-center",w="[grid-area:slot] flex size-7 items-center justify-center group-hover/row:invisible",V=l.label,j=14,I=J(l.iconClassName,s.status==="in_progress"&&"animate-spin");let T;e[18]!==c||e[19]!==I?(T=n.jsx(c,{size:j,className:I}),e[18]=c,e[19]=I,e[20]=T):T=e[20];let R;e[21]!==l||e[22]!==T?(R=n.jsx("span",{className:w,"aria-label":V,children:T}),e[21]=l,e[22]=T,e[23]=R):R=e[23];let N;e[24]!==o?(N=O=>{O.stopPropagation(),o()},e[24]=o,e[25]=N):N=e[25];let A;e[26]===Symbol.for("react.memo_cache_sentinel")?(A=n.jsx(jg,{size:14}),e[26]=A):A=e[26];let E;e[27]!==N?(E=n.jsx(st,{asChild:!0,children:n.jsx("button",{type:"button","aria-label":"Archive task",onClick:N,className:"[grid-area:slot] invisible group-hover/row:visible flex size-7 items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-muted",children:A})}),e[27]=N,e[28]=E):E=e[28];let M;e[29]===Symbol.for("react.memo_cache_sentinel")?(M=n.jsx(it,{side:"right",children:"Archive"}),e[29]=M):M=e[29];let L;e[30]!==E?(L=n.jsxs(nt,{children:[E,M]}),e[30]=E,e[31]=L):L=e[31];let D;e[32]!==R||e[33]!==L?(D=n.jsxs("div",{className:k,children:[R,L]}),e[32]=R,e[33]=L,e[34]=D):D=e[34];let P;return e[35]!==r||e[36]!==C||e[37]!==D||e[38]!==p||e[39]!==_||e[40]!==v?(P=n.jsxs("div",{role:f,tabIndex:m,onClick:r,onKeyDown:p,className:_,children:[v,C,D]}),e[35]=r,e[36]=C,e[37]=D,e[38]=p,e[39]=_,e[40]=v,e[41]=P):P=e[41],P}const af={all:"All tasks",manual:"Chats",automation:"Automation"},lf={all:"All members",mine:"Mine only"};function N0(t){const e=B.c(57),{title:s,tasks:i,activeTaskId:r,onSelect:o,onArchive:a,onNew:l,showNewButton:c,showAutomationBadge:d,emptyLabel:u,currentUserId:h}=t,[f,m]=S.useState("all"),[p,g]=S.useState("mine");let _;e[0]!==h||e[1]!==p||e[2]!==i?(_=p==="mine"&&h?i.filter(G=>G.created_by===h):i,e[0]=h,e[1]=p,e[2]=i,e[3]=_):_=e[3];const v=_;let x;e[4]!==f||e[5]!==v?(x=f==="automation"?v.filter(R0):f==="manual"?v.filter(I0):v,e[4]=f,e[5]=v,e[6]=x):x=e[6];const b=x;let y;e[7]!==s?(y=n.jsx("span",{children:s}),e[7]=s,e[8]=y):y=e[8];let C;e[9]!==p?(C=n.jsx(Is,{asChild:!0,children:n.jsx("button",{type:"button","aria-label":"Filter by member",className:"flex size-8 items-center justify-center rounded-md hover:bg-muted hover:text-foreground",children:p==="mine"?n.jsx(Ng,{size:16}):n.jsx(po,{size:16})})}),e[9]=p,e[10]=C):C=e[10];let k;e[11]!==p?(k=G=>{const H=G;H!==p&&ne("tasks_panel_member_filter_changed",{to_value:H}),g(H)},e[11]=p,e[12]=k):k=e[12];let w;e[13]===Symbol.for("react.memo_cache_sentinel")?(w=Object.keys(lf),e[13]=w):w=e[13];let V;e[14]===Symbol.for("react.memo_cache_sentinel")?(V=w.map(E0),e[14]=V):V=e[14];let j;e[15]!==p||e[16]!==k?(j=n.jsx(Rs,{align:"end",children:n.jsx(_c,{value:p,onValueChange:k,children:V})}),e[15]=p,e[16]=k,e[17]=j):j=e[17];let I;e[18]!==C||e[19]!==j?(I=n.jsxs(Es,{children:[C,j]}),e[18]=C,e[19]=j,e[20]=I):I=e[20];const T=f!=="all"&&"text-purple-500";let R;e[21]!==T?(R=J("flex size-8 items-center justify-center rounded-md hover:bg-muted hover:text-foreground",T),e[21]=T,e[22]=R):R=e[22];let N;e[23]===Symbol.for("react.memo_cache_sentinel")?(N=n.jsx(Xg,{size:16}),e[23]=N):N=e[23];let A;e[24]!==R?(A=n.jsx(Is,{asChild:!0,children:n.jsx("button",{type:"button","aria-label":"Filter tasks",className:R,children:N})}),e[24]=R,e[25]=A):A=e[25];let E;e[26]!==f?(E=G=>{const H=G;H!==f&&ne("tasks_panel_filter_changed",{to_value:H}),m(H)},e[26]=f,e[27]=E):E=e[27];let M;e[28]===Symbol.for("react.memo_cache_sentinel")?(M=Object.keys(af),e[28]=M):M=e[28];let L;e[29]===Symbol.for("react.memo_cache_sentinel")?(L=M.map(A0),e[29]=L):L=e[29];let D;e[30]!==f||e[31]!==E?(D=n.jsx(Rs,{align:"end",children:n.jsx(_c,{value:f,onValueChange:E,children:L})}),e[30]=f,e[31]=E,e[32]=D):D=e[32];let P;e[33]!==A||e[34]!==D?(P=n.jsxs(Es,{children:[A,D]}),e[33]=A,e[34]=D,e[35]=P):P=e[35];let O;e[36]!==l||e[37]!==c||e[38]!==s?(O=c&&l&&n.jsx("button",{type:"button",onClick:()=>{ne("tasks_panel_new_clicked"),l()},"aria-label":`New ${s.toLowerCase()}`,className:"flex size-8 items-center justify-center rounded-md hover:bg-muted hover:text-foreground",children:n.jsx(Sl,{size:16})}),e[36]=l,e[37]=c,e[38]=s,e[39]=O):O=e[39];let z;e[40]!==P||e[41]!==O||e[42]!==I?(z=n.jsxs("div",{className:"flex items-center gap-0.5",children:[I,P,O]}),e[40]=P,e[41]=O,e[42]=I,e[43]=z):z=e[43];let $;e[44]!==z||e[45]!==y?($=n.jsxs("div",{className:"pl-2 pr-1.5 h-7 flex items-center justify-between text-xs font-medium text-muted-foreground mb-1",children:[y,z]}),e[44]=z,e[45]=y,e[46]=$):$=e[46];let q;e[47]!==r||e[48]!==u||e[49]!==a||e[50]!==o||e[51]!==d||e[52]!==b?(q=b.length===0&&u?n.jsx("div",{className:"px-2 py-1.5 text-xs text-muted-foreground/70",children:u}):b.map(G=>n.jsx(j0,{task:G,isActive:r===G.id,onClick:()=>{r!==G.id&&ne("tasks_panel_task_clicked",{thread_id:G.id,virtual_mcp_id:G.virtual_mcp_id??null,from_automation:!!G.fromAutomation}),o(G)},onArchive:()=>{ne("tasks_panel_task_archived",{thread_id:G.id,virtual_mcp_id:G.virtual_mcp_id??null}),a(G)},showAutomationBadge:d||G.fromAutomation},G.id)),e[47]=r,e[48]=u,e[49]=a,e[50]=o,e[51]=d,e[52]=b,e[53]=q):q=e[53];let F;return e[54]!==$||e[55]!==q?(F=n.jsxs("div",{className:"flex flex-col gap-0.5 mt-1",children:[$,q]}),e[54]=$,e[55]=q,e[56]=F):F=e[56],F}function A0(t){return n.jsx(Gh,{value:t,children:af[t]},t)}function E0(t){return n.jsx(Gh,{value:t,children:lf[t]},t)}function I0(t){return!t.fromAutomation}function R0(t){return t.fromAutomation}function T0(){const t=B.c(22);V0();const{data:e}=St.useSession(),s=e?.user?.id;let i;t[0]===Symbol.for("react.memo_cache_sentinel")?(i={owner:"me",status:"open",hasTrigger:!1},t[0]=i):i=t[0];const{tasks:r}=da(i);let o;t[1]===Symbol.for("react.memo_cache_sentinel")?(o={owner:"all",status:"open",hasTrigger:!0},t[1]=o):o=t[1];const{tasks:a}=da(o),{setTaskId:l,createNewTask:c}=Wn();let d;t[2]===Symbol.for("react.memo_cache_sentinel")?(d={strict:!1},t[2]=d):d=t[2];const u=Hn(d),{locator:h,org:f}=xe(),m=Mt();let p;t[3]!==f.id?(p={connectionId:Pt,orgId:f.id},t[3]=f.id,t[4]=p):p=t[4];const g=Be(p),_=u.taskId??null;let v;t[5]!==a||t[6]!==r?(v=[...r,...a.map(M0)].sort(D0),t[5]=a,t[6]=r,t[7]=v):v=t[7];const x=v;let b;t[8]!==g||t[9]!==h||t[10]!==m?(b=async w=>{try{await Fp(g,w.id,{hidden:!0}),m.invalidateQueries({queryKey:ct.tasksPrefix(h)})}catch(V){const I=V;ue.error(`Failed to archive task: ${I.message}`)}},t[8]=g,t[9]=h,t[10]=m,t[11]=b):b=t[11];const y=b;if(x.length===0){let w;return t[12]===Symbol.for("react.memo_cache_sentinel")?(w=n.jsx("div",{className:"h-full flex items-center justify-center p-4",children:n.jsx(Ui,{image:n.jsx(Ag,{size:48,className:"text-muted-foreground"}),title:"No tasks yet",description:"Start a conversation to create your first task."})}),t[12]=w):w=t[12],w}let C;t[13]!==l?(C=w=>l(w.id,w.virtual_mcp_id),t[13]=l,t[14]=C):C=t[14];let k;return t[15]!==_||t[16]!==x||t[17]!==c||t[18]!==s||t[19]!==y||t[20]!==C?(k=n.jsx("div",{className:"flex flex-col h-full min-h-0 overflow-y-auto p-2 gap-3",children:n.jsx(N0,{title:"Tasks",tasks:x,activeTaskId:_,onSelect:C,onArchive:y,onNew:c,showNewButton:!0,currentUserId:s})}),t[15]=_,t[16]=x,t[17]=c,t[18]=s,t[19]=y,t[20]=C,t[21]=k):k=t[21],k}function D0(t,e){return(e.updated_at??"").localeCompare(t.updated_at??"")}function M0(t){return{...t,fromAutomation:!0}}function P0(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx("div",{className:"flex flex-col h-full p-2 gap-1.5",children:Array.from({length:6}).map(L0)}),t[0]=e):e=t[0],e}function L0(t,e){return n.jsx("div",{className:"h-10 rounded-md bg-muted/60 animate-pulse"},e)}function cf(){const t=B.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx($e.Skeleton,{}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx(As,{fallback:e,children:n.jsx(S.Suspense,{fallback:n.jsx(P0,{}),children:n.jsx(T0,{})})}),t[1]=s):s=t[1],s}function df(){const t=B.c(77),{org:e}=xe(),s=Ge(),i=Rh(),{setTasksOpen:r,openTab:o}=Wn(),a=e.slug,l=xe().project;let c;t[0]===Symbol.for("react.memo_cache_sentinel")?(c={strict:!1},t[0]=c):c=t[0];const d=Hn(c);let u;t[1]===Symbol.for("react.memo_cache_sentinel")?(u={strict:!1},t[1]=u):u=t[1];const h=Si(u),f=i.location.pathname;let m;t[2]!==l.enabledPlugins?(m=l.enabledPlugins??[],t[2]=l.enabledPlugins,t[3]=m):m=t[3];const p=m;let g;t[4]!==l.ui?(g=l.ui?.pinnedViews??[],t[4]=l.ui,t[5]=g):g=t[5];const _=g;let v,x,b,y;if(t[6]!==l.id||t[7]!==p||t[8]!==s||t[9]!==a||t[10]!==d.pluginId||t[11]!==d.taskId||t[12]!==h.virtualmcpid){let H;t[17]!==p?(H=ie=>p.includes(ie.pluginId),t[17]=p,t[18]=H):H=t[18];const U=up.filter(H),Y=h.virtualmcpid??l.id;x=!!h.virtualmcpid;const W=d.taskId??"",K=d.pluginId;let ee;t[19]!==K?(ee=ie=>K===ie,t[19]=K,t[20]=ee):ee=t[20],v=ee;let Z;t[21]!==W||t[22]!==s||t[23]!==a||t[24]!==Y?(Z=ie=>{const re=W||crypto.randomUUID();s({to:"/$org/$taskId/$pluginId",params:{org:a,taskId:re,pluginId:ie},search:de=>({...de,virtualmcpid:Y})})},t[21]=W,t[22]=s,t[23]=a,t[24]=Y,t[25]=Z):Z=t[25],b=Z;let X;t[26]!==v||t[27]!==b?(X=ie=>({key:ie.pluginId,label:ie.label,icon:ie.icon,isActive:v(ie.pluginId),onClick:()=>b(ie.pluginId)}),t[26]=v,t[27]=b,t[28]=X):X=t[28],y=U.map(X),t[6]=l.id,t[7]=p,t[8]=s,t[9]=a,t[10]=d.pluginId,t[11]=d.taskId,t[12]=h.virtualmcpid,t[13]=v,t[14]=x,t[15]=b,t[16]=y}else v=t[13],x=t[14],b=t[15],y=t[16];const C=y;let k;if(t[29]!==p||t[30]!==v||t[31]!==b){let H;t[33]!==p?(H=W=>p.includes(W.pluginId),t[33]=p,t[34]=H):H=t[34];const U=fp.filter(H);let Y;t[35]!==v||t[36]!==b?(Y=W=>({type:"group",group:{id:`${W.pluginId}-${W.id}`,label:W.label,items:W.items.map((K,ee)=>({key:`${W.pluginId}-${W.id}-${ee}`,label:K.label,icon:K.icon,isActive:v(W.pluginId),onClick:()=>b(W.pluginId)})),defaultExpanded:W.defaultExpanded??!0}}),t[35]=v,t[36]=b,t[37]=Y):Y=t[37],k=U.map(Y),t[29]=p,t[30]=v,t[31]=b,t[32]=k}else k=t[32];const w=k;let V;if(t[38]!==o||t[39]!==_){let H;t[41]!==o?(H=U=>{const Y=Kn(U.icon),W=Y.type==="icon"?qn(Y.name):null;return{key:`app-${U.connectionId}-${U.toolName}`,label:U.label||U.toolName,icon:W?n.jsx(W,{size:16,className:"text-muted-foreground"}):Y.type==="url"?n.jsx("img",{src:Y.url,alt:"",className:"size-4 rounded"}):n.jsx(ju,{size:16,className:"text-muted-foreground"}),isActive:!1,onClick:()=>o(ha(U.connectionId,U.toolName))}},t[41]=o,t[42]=H):H=t[42],V=_.map(H),t[38]=o,t[39]=_,t[40]=V}else V=t[40];const j=V;let I;t[43]!==j?(I=j.length>0?{type:"group",group:{id:"apps",label:"Apps",items:j,defaultExpanded:!0}}:null,t[43]=j,t[44]=I):I=t[44];const T=I;let R;t[45]===Symbol.for("react.memo_cache_sentinel")?(R=n.jsx(Eg,{className:"size-4!"}),t[45]=R):R=t[45];const N=f===`/${a}`||f===`/${a}/`;let A;t[46]!==s||t[47]!==a||t[48]!==r?(A=()=>{r(!1),s({to:"/$org",params:{org:a}})},t[46]=s,t[47]=a,t[48]=r,t[49]=A):A=t[49];let E;t[50]!==A||t[51]!==N?(E={key:"home",label:"Home",icon:R,isActive:N,onClick:A},t[50]=A,t[51]=N,t[52]=E):E=t[52];const M=E;let L;t[53]!==p?(L=p.includes(mp),t[53]=p,t[54]=L):L=t[54];const D=L;let P;t[55]===Symbol.for("react.memo_cache_sentinel")?(P=n.jsx(pp,{className:"size-4!"}),t[55]=P):P=t[55];let O;t[56]!==a||t[57]!==f?(O=f.startsWith(`/${a}/settings/workflows`),t[56]=a,t[57]=f,t[58]=O):O=t[58];let z;t[59]!==s||t[60]!==a?(z=()=>s({to:"/$org/settings/workflows",params:{org:a}}),t[59]=s,t[60]=a,t[61]=z):z=t[61];let $;t[62]!==O||t[63]!==z?($={key:"workflows",label:"Workflows",icon:P,isActive:O,onClick:z},t[62]=O,t[63]=z,t[64]=$):$=t[64];const q=$;let F;if(t[65]!==M||t[66]!==x||t[67]!==D||t[68]!==q){const H=[M];x&&D&&H.push(q),F={type:"items",items:H},t[65]=M,t[66]=x,t[67]=D,t[68]=q,t[69]=F}else F=t[69];let G;if(t[70]!==T||t[71]!==w||t[72]!==C||t[73]!==F){if(G=[F],C.length>0){let H;t[75]!==C?(H={type:"items",items:C},t[75]=C,t[76]=H):H=t[76],G.push(H)}w.length>0&&G.push(...w),T&&G.push(T),t[70]=T,t[71]=w,t[72]=C,t[73]=F,t[74]=G}else G=t[74];return G}function hf(t){const e=B.c(3),{children:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx("div",{className:"flex h-6 items-center",children:n.jsx("div",{className:"h-0.5 w-16 rounded-full bg-sidebar-foreground/15"})}),e[0]=i):i=e[0];let r;return e[1]!==s?(r=n.jsxs(Xn,{className:"pt-0 pr-0 pb-2 pl-0 mt-2",children:[i,n.jsx(Jn,{children:n.jsx(vs,{className:"gap-0.5",children:s})})]}),e[1]=s,e[2]=r):r=e[2],r}function O0(){const t=B.c(7),s=Th().logo??Dh,i=typeof s=="string"?s:s.light,r=typeof s=="string"?s:s.dark;let o;t[0]!==i?(o=n.jsx("img",{src:i,alt:"Logo",className:"size-6 object-contain dark:hidden"}),t[0]=i,t[1]=o):o=t[1];let a;t[2]!==r?(a=n.jsx("img",{src:r,alt:"Logo",className:"size-6 object-contain hidden dark:block"}),t[2]=r,t[3]=a):a=t[3];let l;return t[4]!==o||t[5]!==a?(l=n.jsx(Eu,{className:"flex items-center justify-center shrink-0 px-2 pb-0",children:n.jsxs("div",{className:"flex w-full aspect-square items-center justify-center",children:[o,a]})}),t[4]=o,t[5]=a,t[6]=l):l=t[6],l}function uf(t){const e=B.c(15),{item:s}=t,{isMobile:i,setOpenMobile:r}=Qn();let o;e[0]!==i||e[1]!==s||e[2]!==r?(o=()=>{ne("nav_item_clicked",{nav_key:s.key,nav_label:s.label,is_active:!!s.isActive,is_mobile:i}),s.onClick?.(),i&&r(!1)},e[0]=i,e[1]=s,e[2]=r,e[3]=o):o=e[3];const a=o,l=s.key,c=s.isActive&&"z-10";let d;e[4]!==c?(d=J(c),e[4]=c,e[5]=d):d=e[5];let u;e[6]!==a||e[7]!==s.icon||e[8]!==s.isActive||e[9]!==s.label?(u=n.jsx(_s,{onClick:a,isActive:s.isActive,tooltip:s.label,className:"bg-muted/75",children:s.icon}),e[6]=a,e[7]=s.icon,e[8]=s.isActive,e[9]=s.label,e[10]=u):u=e[10];let h;return e[11]!==s.key||e[12]!==d||e[13]!==u?(h=n.jsx(Zt,{className:d,children:u},l),e[11]=s.key,e[12]=d,e[13]=u,e[14]=h):h=e[14],h}function B0(t){const e=B.c(12),{section:s}=t;switch(s.type){case"divider":{let i;return e[0]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx(Nu,{className:"my-2"}),e[0]=i):i=e[0],i}case"spacer":{let i;return e[1]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx("div",{className:"flex-1"}),e[1]=i):i=e[1],i}case"group":{const i=s.group.label,r=s.group.defaultExpanded;let o;e[2]!==s.group.items?(o=s.group.items.map(z0),e[2]=s.group.items,e[3]=o):o=e[3];let a;return e[4]!==s.group.defaultExpanded||e[5]!==s.group.label||e[6]!==o?(a=n.jsx(hf,{label:i,defaultExpanded:r,children:o}),e[4]=s.group.defaultExpanded,e[5]=s.group.label,e[6]=o,e[7]=a):a=e[7],a}case"items":{let i;e[8]!==s.items?(i=s.items.map($0),e[8]=s.items,e[9]=i):i=e[9];let r;return e[10]!==i?(r=n.jsx(Xn,{className:"pt-0 pr-0 pb-0 pl-0",children:n.jsx(Jn,{children:n.jsx(vs,{className:"gap-1.5",children:i})})}),e[10]=i,e[11]=r):r=e[11],r}}}function $0(t){return n.jsx(uf,{item:t},t.key)}function z0(t){return n.jsx(uf,{item:t},t.key)}function F0(t){const e=B.c(14),{sections:s,header:i,footer:r,additionalContent:o,variant:a,contentClassName:l}=t,c=a===void 0?"sidebar":a;let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx(S.Suspense,{fallback:n.jsx("div",{className:"h-10 shrink-0"}),children:n.jsx(O0,{})}),e[0]=d):d=e[0];let u;e[1]!==l?(u=J("flex flex-col flex-1 px-2 py-2 gap-0",l),e[1]=l,e[2]=u):u=e[2];let h;e[3]!==s?(h=s.map(U0),e[3]=s,e[4]=h):h=e[4];let f;e[5]!==o||e[6]!==u||e[7]!==h?(f=n.jsxs(Au,{className:u,children:[h,o]}),e[5]=o,e[6]=u,e[7]=h,e[8]=f):f=e[8];let m;return e[9]!==r||e[10]!==i||e[11]!==f||e[12]!==c?(m=n.jsxs(I_,{variant:c,children:[d,i,f,r]}),e[9]=r,e[10]=i,e[11]=f,e[12]=c,e[13]=m):m=e[13],m}function U0(t,e){return n.jsx(B0,{section:t},e)}function ff(t){const e=B.c(2);let s;return e[0]!==t?(s=n.jsx(F0,{...t}),e[0]=t,e[1]=s):s=e[1],s}ff.Skeleton=function(){return n.jsx("div",{className:"flex flex-col gap-0.5",children:Array.from({length:8}).map((e,s)=>n.jsx("div",{className:"w-full h-8",children:n.jsx(Fi,{className:"h-full bg-sidebar-accent rounded-md"})},s))})};function H0(){const t=B.c(7),s=Th().logo??Dh,i=typeof s=="string"?s:s.light,r=typeof s=="string"?s:s.dark;let o;t[0]!==i?(o=n.jsx("img",{src:i,alt:"Logo",className:"size-6 object-contain dark:hidden"}),t[0]=i,t[1]=o):o=t[1];let a;t[2]!==r?(a=n.jsx("img",{src:r,alt:"Logo",className:"size-6 object-contain hidden dark:block"}),t[2]=r,t[3]=a):a=t[3];let l;return t[4]!==o||t[5]!==a?(l=n.jsx(Eu,{className:"flex items-center justify-center shrink-0 px-2 pb-0",children:n.jsxs("div",{className:"flex w-full aspect-square items-center justify-center",children:[o,a]})}),t[4]=o,t[5]=a,t[6]=l):l=t[6],l}function id(t){const e=B.c(15),{item:s,onClose:i}=t,r=s.isActive&&"z-10";let o;e[0]!==r?(o=J(r),e[0]=r,e[1]=o):o=e[1];let a;e[2]!==s||e[3]!==i?(a=()=>{s.onClick?.(),i()},e[2]=s,e[3]=i,e[4]=a):a=e[4];let l;e[5]!==s.icon?(l=n.jsx("span",{className:"[&>svg]:size-8",children:s.icon}),e[5]=s.icon,e[6]=l):l=e[6];let c;e[7]!==s.isActive||e[8]!==s.label||e[9]!==a||e[10]!==l?(c=n.jsx(_s,{onClick:a,isActive:s.isActive,tooltip:s.label,className:"bg-muted/75",children:l}),e[7]=s.isActive,e[8]=s.label,e[9]=a,e[10]=l,e[11]=c):c=e[11];let d;return e[12]!==o||e[13]!==c?(d=n.jsx(Zt,{className:o,children:c}),e[12]=o,e[13]=c,e[14]=d):d=e[14],d}function W0(t){const e=B.c(18),{section:s,onClose:i}=t;switch(s.type){case"divider":{let r;return e[0]===Symbol.for("react.memo_cache_sentinel")?(r=n.jsx(Nu,{className:"my-2"}),e[0]=r):r=e[0],r}case"spacer":{let r;return e[1]===Symbol.for("react.memo_cache_sentinel")?(r=n.jsx("div",{className:"flex-1"}),e[1]=r):r=e[1],r}case"group":{const r=s.group.label,o=s.group.defaultExpanded;let a;if(e[2]!==i||e[3]!==s.group.items){let c;e[5]!==i?(c=d=>n.jsx(id,{item:d,onClose:i},d.key),e[5]=i,e[6]=c):c=e[6],a=s.group.items.map(c),e[2]=i,e[3]=s.group.items,e[4]=a}else a=e[4];let l;return e[7]!==s.group.defaultExpanded||e[8]!==s.group.label||e[9]!==a?(l=n.jsx(hf,{label:r,defaultExpanded:o,children:a}),e[7]=s.group.defaultExpanded,e[8]=s.group.label,e[9]=a,e[10]=l):l=e[10],l}case"items":{let r;if(e[11]!==i||e[12]!==s.items){let a;e[14]!==i?(a=l=>n.jsx(id,{item:l,onClose:i},l.key),e[14]=i,e[15]=a):a=e[15],r=s.items.map(a),e[11]=i,e[12]=s.items,e[13]=r}else r=e[13];let o;return e[16]!==r?(o=n.jsx(Xn,{className:"pt-0 pr-0 pb-0 pl-0",children:n.jsx(Jn,{children:n.jsx(vs,{className:"gap-1.5",children:r})})}),e[16]=r,e[17]=o):o=e[17],o}}}function K0(t){const e=B.c(12),{sections:s,onClose:i,footer:r,additionalContent:o}=t;let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx(S.Suspense,{fallback:n.jsx("div",{className:"h-10 shrink-0"}),children:n.jsx(H0,{})}),e[0]=a):a=e[0];let l;if(e[1]!==i||e[2]!==s){let u;e[4]!==i?(u=(h,f)=>n.jsx(W0,{section:h,onClose:i},f),e[4]=i,e[5]=u):u=e[5],l=s.map(u),e[1]=i,e[2]=s,e[3]=l}else l=e[3];let c;e[6]!==o||e[7]!==l?(c=n.jsxs(Au,{className:"flex flex-col flex-1 px-2 py-2 gap-0",children:[l,o]}),e[6]=o,e[7]=l,e[8]=c):c=e[8];let d;return e[9]!==r||e[10]!==c?(d=n.jsxs("div",{className:"bg-sidebar flex h-full w-full flex-col","data-sidebar":"sidebar",children:[a,c,r]}),e[9]=r,e[10]=c,e[11]=d):d=e[11],d}function mf(t){return t.toLowerCase().trim().replace(/[^a-z0-9\s_-]+/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const q0=Ns({name:Et().min(2,"Organization name is required")});function G0(t){const e=B.c(41),{open:s,onOpenChange:i}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={resolver:Un(q0),defaultValues:{name:""}},e[0]=r):r=e[0];const o=Gi(r);let a;e[1]===Symbol.for("react.memo_cache_sentinel")?(a={mutationFn:X0,onSuccess:Y0},e[1]=a):a=e[1];const l=qi(a),c=l.error instanceof Error?l.error.message:l.error?"Failed to create organization.":null;let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsxs(Tl,{children:[n.jsx(Dl,{children:"Create a new organization"}),n.jsx(Ml,{children:"Set up a new organization to collaborate with others."})]}),e[2]=d):d=e[2];let u;if(e[3]!==l||e[4]!==o){let w;e[6]!==l?(w=V=>l.mutateAsync(V),e[6]=l,e[7]=w):w=e[7],u=o.handleSubmit(w),e[3]=l,e[4]=o,e[5]=u}else u=e[5];let h;e[8]!==o.formState.isSubmitting?(h=w=>{const{field:V}=w;return n.jsxs(Rt,{children:[n.jsx(os,{children:"Organization Name"}),n.jsx(Tt,{children:n.jsx(gt,{...V,placeholder:"Acme Inc.",disabled:o.formState.isSubmitting})}),n.jsx(Sg,{children:"The name of your company or organization"}),V.value&&n.jsxs("div",{className:"text-xs text-muted-foreground mt-1",children:["Organization URL:"," ",n.jsxs("span",{className:"font-mono",children:[typeof window<"u"?globalThis.location.origin:"","/",mf(V.value)]})]}),n.jsx(Dt,{})]})},e[8]=o.formState.isSubmitting,e[9]=h):h=e[9];let f;e[10]!==o.control||e[11]!==h?(f=n.jsx(It,{control:o.control,name:"name",render:h}),e[10]=o.control,e[11]=h,e[12]=f):f=e[12];let m;e[13]!==c?(m=c&&n.jsx("div",{className:"text-destructive text-sm mt-2",children:c}),e[13]=c,e[14]=m):m=e[14];let p;e[15]!==l||e[16]!==o?(p=()=>{l.reset(),o.reset()},e[15]=l,e[16]=o,e[17]=p):p=e[17];let g;e[18]!==o.formState.isSubmitting||e[19]!==p?(g=n.jsx(Il,{disabled:o.formState.isSubmitting,onClick:p,children:"Cancel"}),e[18]=o.formState.isSubmitting,e[19]=p,e[20]=g):g=e[20];const _=!o.formState.isValid||o.formState.isSubmitting;let v;e[21]!==o.formState.isSubmitting?(v=o.formState.isSubmitting?n.jsxs("span",{className:"flex items-center gap-2",children:[n.jsx(In,{size:"xs"})," Creating..."]}):"Create Organization",e[21]=o.formState.isSubmitting,e[22]=v):v=e[22];let x;e[23]!==_||e[24]!==v?(x=n.jsx(ae,{type:"submit",variant:"default",disabled:_,children:v}),e[23]=_,e[24]=v,e[25]=x):x=e[25];let b;e[26]!==x||e[27]!==g?(b=n.jsxs(Pl,{children:[g,x]}),e[26]=x,e[27]=g,e[28]=b):b=e[28];let y;e[29]!==b||e[30]!==u||e[31]!==f||e[32]!==m?(y=n.jsxs("form",{className:"space-y-6",onSubmit:u,autoComplete:"off",children:[f,m,b]}),e[29]=b,e[30]=u,e[31]=f,e[32]=m,e[33]=y):y=e[33];let C;e[34]!==o||e[35]!==y?(C=n.jsxs(Rl,{children:[d,n.jsx($i,{...o,children:y})]}),e[34]=o,e[35]=y,e[36]=C):C=e[36];let k;return e[37]!==i||e[38]!==s||e[39]!==C?(k=n.jsx(Ll,{open:s,onOpenChange:i,children:C}),e[37]=i,e[38]=s,e[39]=C,e[40]=k):k=e[40],k}function Y0(t){const{orgSlug:e}=t;window.location.href=`/${e}`}async function X0(t){const e=mf(t.name);if(!e)throw new Error("Organization slug is invalid");const s=await St.organization.create({name:t.name,slug:e});if(s?.error)throw new Error(s.error.message||"Failed to create organization");const i=s?.data?.slug??e;if(!i)throw new Error("Failed to create organization");return{orgSlug:i}}function wa(t){let e=0;for(let i=0;i<t.length;i++)e=t.charCodeAt(i)+((e<<5)-e);const s=Math.abs(e)%360;return{backgroundColor:`hsl(${s} 55% 70%)`,color:`hsl(${s} 55% 20%)`}}function J0(t){const e=B.c(13),{org:s,size:i}=t,r=i===void 0?"sm":i,o=r==="xs"?"size-5":"size-6",a=r==="xs"?"text-[9px]":"text-xs";let l;e[0]!==o?(l=J(o,"shrink-0 rounded-md flex items-center justify-center border border-border/50 overflow-hidden"),e[0]=o,e[1]=l):l=e[1];let c;e[2]!==s.logo||e[3]!==s.name?(c=s.logo?void 0:wa(s.name),e[2]=s.logo,e[3]=s.name,e[4]=c):c=e[4];let d;e[5]!==s.logo||e[6]!==s.name||e[7]!==a?(d=s.logo?n.jsx("img",{src:s.logo,alt:"",className:"size-full object-cover"}):n.jsx("span",{className:J("font-semibold leading-none",a),children:s.name.slice(0,2).toUpperCase()}),e[5]=s.logo,e[6]=s.name,e[7]=a,e[8]=d):d=e[8];let u;return e[9]!==l||e[10]!==c||e[11]!==d?(u=n.jsx("div",{className:l,style:c,children:d}),e[9]=l,e[10]=c,e[11]=d,e[12]=u):u=e[12],u}function ur(t){const e=B.c(22),{item:s,onClose:i}=t;if(s.href){const c=s.external?"_blank":void 0,d=s.external?"noopener noreferrer":void 0;let u;e[0]!==s.icon?(u=n.jsx("span",{className:"shrink-0 text-muted-foreground",children:s.icon}),e[0]=s.icon,e[1]=u):u=e[1];let h;e[2]!==s.label?(h=n.jsx("span",{className:"flex-1",children:s.label}),e[2]=s.label,e[3]=h):h=e[3];let f;return e[4]!==s.href||e[5]!==i||e[6]!==c||e[7]!==d||e[8]!==u||e[9]!==h?(f=n.jsxs("a",{href:s.href,target:c,rel:d,className:"flex items-center gap-2.5 px-3 py-2 rounded-md text-sm text-left w-full transition-colors text-foreground/80 hover:bg-sidebar-accent hover:text-foreground",onClick:i,children:[u,h]}),e[4]=s.href,e[5]=i,e[6]=c,e[7]=d,e[8]=u,e[9]=h,e[10]=f):f=e[10],f}let r;e[11]!==s||e[12]!==i?(r=()=>{s.onClick?.(),i()},e[11]=s,e[12]=i,e[13]=r):r=e[13];let o;e[14]!==s.icon?(o=n.jsx("span",{className:"shrink-0 text-muted-foreground",children:s.icon}),e[14]=s.icon,e[15]=o):o=e[15];let a;e[16]!==s.label?(a=n.jsx("span",{className:"flex-1",children:s.label}),e[16]=s.label,e[17]=a):a=e[17];let l;return e[18]!==r||e[19]!==o||e[20]!==a?(l=n.jsxs("button",{type:"button",onClick:r,className:"flex items-center gap-2.5 px-3 py-2 rounded-md text-sm text-left w-full transition-colors text-foreground/80 hover:bg-sidebar-accent hover:text-foreground",children:[o,a]}),e[18]=r,e[19]=o,e[20]=a,e[21]=l):l=e[21],l}function nd(t){const e=B.c(16),{sortedOrgs:s,orgParam:i,onSelectOrg:r,onCreateOrg:o}=t;let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx("span",{className:"text-sm font-medium text-muted-foreground/60",children:"Your Organizations"}),e[0]=a):a=e[0];let l;e[1]===Symbol.for("react.memo_cache_sentinel")?(l=n.jsx(Qt,{size:16}),e[1]=l):l=e[1];let c;e[2]!==o?(c=n.jsxs("div",{className:"flex items-center justify-between px-4 py-3",children:[a,n.jsx("button",{type:"button",onClick:o,className:"flex items-center justify-center size-7 rounded-md text-muted-foreground hover:bg-accent/50 hover:text-foreground transition-colors",children:l})]}),e[2]=o,e[3]=c):c=e[3];let d;if(e[4]!==r||e[5]!==i||e[6]!==s){let f;e[8]!==r||e[9]!==i?(f=m=>n.jsxs("button",{type:"button",onClick:()=>r(m.slug),className:J("flex items-center gap-3 px-3 py-2.5 rounded-md text-sm text-left w-full transition-colors",m.slug===i?"bg-accent text-accent-foreground":"text-foreground hover:bg-accent/50"),children:[n.jsx(J0,{org:m,size:"sm"}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsx("p",{className:"text-sm font-medium truncate",children:m.name}),n.jsx("p",{className:"text-xs text-muted-foreground truncate",children:m.slug})]}),m.slug===i&&n.jsx(Jt,{size:14,className:"ml-auto text-muted-foreground shrink-0"})]},m.id),e[8]=r,e[9]=i,e[10]=f):f=e[10],d=s.map(f),e[4]=r,e[5]=i,e[6]=s,e[7]=d}else d=e[7];let u;e[11]!==d?(u=n.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto p-1.5 flex flex-col gap-1",children:d}),e[11]=d,e[12]=u):u=e[12];let h;return e[13]!==c||e[14]!==u?(h=n.jsxs(n.Fragment,{children:[c,u]}),e[13]=c,e[14]=u,e[15]=h):h=e[15],h}function rd(t){const e=B.c(142),{user:s,userImage:i,menuItems:r,signOutItem:o,themeOptions:a,preferences:l,setPreferences:c,sortedOrgs:d,orgParam:u,onSelectOrg:h,onCreateOrg:f,close:m,isMobile:p}=t;if(p){const W=s?.name??"U";let K;e[0]!==W||e[1]!==i?(K=n.jsx(Ec,{url:i,fallback:W,shape:"circle",size:"sm",className:"shrink-0"}),e[0]=W,e[1]=i,e[2]=K):K=e[2];const ee=s?.name??"User";let Z;e[3]!==ee?(Z=n.jsx("p",{className:"text-sm font-medium truncate",children:ee}),e[3]=ee,e[4]=Z):Z=e[4];const X=s?.email;let ie;e[5]!==X?(ie=n.jsx("p",{className:"text-xs text-muted-foreground truncate",children:X}),e[5]=X,e[6]=ie):ie=e[6];let re;e[7]!==Z||e[8]!==ie?(re=n.jsxs("div",{className:"flex-1 min-w-0",children:[Z,ie]}),e[7]=Z,e[8]=ie,e[9]=re):re=e[9];let de;e[10]!==s?(de=()=>{s?.id&&navigator.clipboard.writeText(s.id).then(ty)},e[10]=s,e[11]=de):de=e[11];let me;e[12]===Symbol.for("react.memo_cache_sentinel")?(me=n.jsx(zi,{size:14}),e[12]=me):me=e[12];let le;e[13]!==de?(le=n.jsx(st,{asChild:!0,children:n.jsx("button",{type:"button",tabIndex:-1,onClick:de,className:"shrink-0 text-muted-foreground hover:text-foreground transition-colors",children:me})}),e[13]=de,e[14]=le):le=e[14];let se;e[15]===Symbol.for("react.memo_cache_sentinel")?(se=n.jsx(it,{side:"right",children:n.jsx("p",{className:"text-xs",children:"Copy user ID"})}),e[15]=se):se=e[15];let _e;e[16]!==le?(_e=n.jsx(Bi,{delayDuration:300,children:n.jsxs(nt,{children:[le,se]})}),e[16]=le,e[17]=_e):_e=e[17];let ge;e[18]!==_e||e[19]!==K||e[20]!==re?(ge=n.jsxs("div",{className:"flex items-center gap-3 px-4 py-4 border-b border-border",children:[K,re,_e]}),e[18]=_e,e[19]=K,e[20]=re,e[21]=ge):ge=e[21];let Se;e[22]!==f||e[23]!==h||e[24]!==u||e[25]!==d?(Se=n.jsx("div",{className:"border-b border-border pb-2",children:n.jsx(nd,{sortedOrgs:d,orgParam:u,onSelectOrg:h,onCreateOrg:f})}),e[22]=f,e[23]=h,e[24]=u,e[25]=d,e[26]=Se):Se=e[26];let ve;if(e[27]!==m||e[28]!==r){let ze;e[30]!==m?(ze=Kt=>n.jsx(ur,{item:Kt,onClose:m},Kt.key),e[30]=m,e[31]=ze):ze=e[31],ve=r.map(ze),e[27]=m,e[28]=r,e[29]=ve}else ve=e[29];let Ne;e[32]!==m||e[33]!==o?(Ne=n.jsx(ur,{item:o,onClose:m}),e[32]=m,e[33]=o,e[34]=Ne):Ne=e[34];let Te;e[35]!==ve||e[36]!==Ne?(Te=n.jsxs("nav",{className:"flex flex-col px-2 pt-2 pb-2 gap-0.5",children:[ve,Ne]}),e[35]=ve,e[36]=Ne,e[37]=Te):Te=e[37];let te;e[38]!==Se||e[39]!==Te?(te=n.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto",children:[Se,Te]}),e[38]=Se,e[39]=Te,e[40]=te):te=e[40];let he;if(e[41]!==l.theme||e[42]!==c||e[43]!==a){let ze;e[45]!==l.theme||e[46]!==c?(ze=Kt=>{const{value:kt,icon:Re,label:Le}=Kt;return n.jsx("button",{type:"button","aria-label":Le,onClick:()=>c(Ye=>({...Ye,theme:kt})),className:J("size-8 rounded-md flex items-center justify-center transition-colors",l.theme===kt?"bg-sidebar-accent text-foreground":"text-muted-foreground hover:bg-sidebar-accent/50 hover:text-foreground"),children:Re},kt)},e[45]=l.theme,e[46]=c,e[47]=ze):ze=e[47],he=a.map(ze),e[41]=l.theme,e[42]=c,e[43]=a,e[44]=he}else he=e[44];let we;e[48]!==he?(we=n.jsx("div",{className:"flex items-center gap-0.5",children:he}),e[48]=he,e[49]=we):we=e[49];const Ee=l.enableSounds?"Disable sounds":"Enable sounds";let Ie;e[50]!==c?(Ie=()=>c(ey),e[50]=c,e[51]=Ie):Ie=e[51];const De=l.enableSounds?"text-foreground hover:bg-sidebar-accent/50":"text-muted-foreground hover:bg-sidebar-accent/50 hover:text-foreground";let Pe;e[52]!==De?(Pe=J("size-8 rounded-md flex items-center justify-center transition-colors",De),e[52]=De,e[53]=Pe):Pe=e[53];let ye;e[54]!==l.enableSounds?(ye=l.enableSounds?n.jsx(xc,{size:14}):n.jsx(vc,{size:14}),e[54]=l.enableSounds,e[55]=ye):ye=e[55];let Ae;e[56]!==Ee||e[57]!==Ie||e[58]!==Pe||e[59]!==ye?(Ae=n.jsx("button",{type:"button","aria-label":Ee,onClick:Ie,className:Pe,children:ye}),e[56]=Ee,e[57]=Ie,e[58]=Pe,e[59]=ye,e[60]=Ae):Ae=e[60];let fe;e[61]===Symbol.for("react.memo_cache_sentinel")?(fe=n.jsxs("span",{className:"text-xs text-muted-foreground/60",children:["v","2.282.1"]}),e[61]=fe):fe=e[61];let ke;e[62]!==Ae?(ke=n.jsxs("div",{className:"flex items-center gap-2",children:[Ae,fe]}),e[62]=Ae,e[63]=ke):ke=e[63];let Ze;e[64]!==we||e[65]!==ke?(Ze=n.jsxs("div",{className:"flex items-center justify-between px-3 py-3 border-t border-border/50",children:[we,ke]}),e[64]=we,e[65]=ke,e[66]=Ze):Ze=e[66];let Ct;return e[67]!==ge||e[68]!==te||e[69]!==Ze?(Ct=n.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[ge,te,Ze]}),e[67]=ge,e[68]=te,e[69]=Ze,e[70]=Ct):Ct=e[70],Ct}const g=s?.name??"U";let _;e[71]!==g||e[72]!==i?(_=n.jsx(Ec,{url:i,fallback:g,shape:"circle",size:"sm",className:"shrink-0"}),e[71]=g,e[72]=i,e[73]=_):_=e[73];const v=s?.name??"User";let x;e[74]!==v?(x=n.jsx("p",{className:"text-sm font-medium truncate",children:v}),e[74]=v,e[75]=x):x=e[75];const b=s?.email;let y;e[76]!==b?(y=n.jsx("p",{className:"text-xs text-muted-foreground truncate",children:b}),e[76]=b,e[77]=y):y=e[77];let C;e[78]!==x||e[79]!==y?(C=n.jsxs("div",{className:"flex-1 min-w-0",children:[x,y]}),e[78]=x,e[79]=y,e[80]=C):C=e[80];let k;e[81]!==s?(k=()=>{s?.id&&navigator.clipboard.writeText(s.id).then(Z0)},e[81]=s,e[82]=k):k=e[82];let w;e[83]===Symbol.for("react.memo_cache_sentinel")?(w=n.jsx(zi,{size:14}),e[83]=w):w=e[83];let V;e[84]!==k?(V=n.jsx(st,{asChild:!0,children:n.jsx("button",{type:"button",tabIndex:-1,onClick:k,className:"shrink-0 text-muted-foreground hover:text-foreground transition-colors",children:w})}),e[84]=k,e[85]=V):V=e[85];let j;e[86]===Symbol.for("react.memo_cache_sentinel")?(j=n.jsx(it,{side:"right",children:n.jsx("p",{className:"text-xs",children:"Copy user ID"})}),e[86]=j):j=e[86];let I;e[87]!==V?(I=n.jsx(Bi,{delayDuration:300,children:n.jsxs(nt,{children:[V,j]})}),e[87]=V,e[88]=I):I=e[88];let T;e[89]!==I||e[90]!==_||e[91]!==C?(T=n.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 mx-1 mt-1",children:[_,C,I]}),e[89]=I,e[90]=_,e[91]=C,e[92]=T):T=e[92];let R;if(e[93]!==m||e[94]!==r){let W;e[96]!==m?(W=K=>n.jsx(ur,{item:K,onClose:m},K.key),e[96]=m,e[97]=W):W=e[97],R=r.map(W),e[93]=m,e[94]=r,e[95]=R}else R=e[95];let N;e[98]!==m||e[99]!==o?(N=n.jsx(ur,{item:o,onClose:m}),e[98]=m,e[99]=o,e[100]=N):N=e[100];let A;e[101]!==R||e[102]!==N?(A=n.jsxs("nav",{className:"flex-1 flex flex-col px-2 pt-1 overflow-y-auto",children:[R,N]}),e[101]=R,e[102]=N,e[103]=A):A=e[103];let E;if(e[104]!==l.theme||e[105]!==c||e[106]!==a){let W;e[108]!==l.theme||e[109]!==c?(W=K=>{const{value:ee,icon:Z,label:X}=K;return n.jsx("button",{type:"button","aria-label":X,onClick:()=>c(ie=>({...ie,theme:ee})),className:J("size-7 rounded-md flex items-center justify-center transition-colors",l.theme===ee?"bg-sidebar-accent text-foreground":"text-muted-foreground hover:bg-sidebar-accent/50 hover:text-foreground"),children:Z},ee)},e[108]=l.theme,e[109]=c,e[110]=W):W=e[110],E=a.map(W),e[104]=l.theme,e[105]=c,e[106]=a,e[107]=E}else E=e[107];let M;e[111]!==E?(M=n.jsx("div",{className:"flex items-center gap-0.5",children:E}),e[111]=E,e[112]=M):M=e[112];const L=l.enableSounds?"Disable sounds":"Enable sounds";let D;e[113]!==c?(D=()=>c(Q0),e[113]=c,e[114]=D):D=e[114];const P=l.enableSounds?"text-foreground hover:bg-sidebar-accent/50":"text-muted-foreground hover:bg-sidebar-accent/50 hover:text-foreground";let O;e[115]!==P?(O=J("size-7 rounded-md flex items-center justify-center transition-colors",P),e[115]=P,e[116]=O):O=e[116];let z;e[117]!==l.enableSounds?(z=l.enableSounds?n.jsx(xc,{size:14}):n.jsx(vc,{size:14}),e[117]=l.enableSounds,e[118]=z):z=e[118];let $;e[119]!==L||e[120]!==D||e[121]!==O||e[122]!==z?($=n.jsx("button",{type:"button","aria-label":L,onClick:D,className:O,children:z}),e[119]=L,e[120]=D,e[121]=O,e[122]=z,e[123]=$):$=e[123];let q;e[124]===Symbol.for("react.memo_cache_sentinel")?(q=n.jsxs("span",{className:"text-xs text-muted-foreground/60",children:["v","2.282.1"]}),e[124]=q):q=e[124];let F;e[125]!==$?(F=n.jsxs("div",{className:"flex items-center gap-2",children:[$,q]}),e[125]=$,e[126]=F):F=e[126];let G;e[127]!==M||e[128]!==F?(G=n.jsxs("div",{className:"flex items-center justify-between px-2 py-1.5 border-t border-border/50",children:[M,F]}),e[127]=M,e[128]=F,e[129]=G):G=e[129];let H;e[130]!==T||e[131]!==A||e[132]!==G?(H=n.jsxs("div",{className:"w-60 shrink-0 flex flex-col border-r border-border bg-sidebar/75",children:[T,A,G]}),e[130]=T,e[131]=A,e[132]=G,e[133]=H):H=e[133];let U;e[134]!==f||e[135]!==h||e[136]!==u||e[137]!==d?(U=n.jsx("div",{className:"flex-1 flex flex-col min-w-0 min-h-0 overflow-hidden",children:n.jsx(nd,{sortedOrgs:d,orgParam:u,onSelectOrg:h,onCreateOrg:f})}),e[134]=f,e[135]=h,e[136]=u,e[137]=d,e[138]=U):U=e[138];let Y;return e[139]!==H||e[140]!==U?(Y=n.jsxs("div",{className:"flex min-h-[380px] w-full overflow-hidden",children:[H,U]}),e[139]=H,e[140]=U,e[141]=Y):Y=e[141],Y}function Q0(t){return{...t,enableSounds:!t.enableSounds}}function Z0(){ue.success("User ID copied")}function ey(t){return{...t,enableSounds:!t.enableSounds}}function ty(){ue.success("User ID copied")}function pf(){const t=B.c(50),{data:e}=St.useSession(),{data:s}=St.useListOrganizations(),i=Ge();let r;t[0]===Symbol.for("react.memo_cache_sentinel")?(r={from:"/shell/$org",shouldThrow:!1},t[0]=r):r=t[0];const a=gp(r)?.params.org,[l,c]=yi(),d=Ps(),[u,h]=S.useState(!1),[f,m]=S.useState(!1),p=e?.user,g=p?.image;let _;if(t[1]!==d||t[2]!==i||t[3]!==u||t[4]!==a||t[5]!==s||t[6]!==l||t[7]!==c||t[8]!==p||t[9]!==g){const b=s?.find(Y=>Y.slug===a);let y;if(t[11]!==a||t[12]!==s){let Y;t[14]!==a?(Y=(W,K)=>W.slug===a?-1:K.slug===a?1:W.name.localeCompare(K.name),t[14]=a,t[15]=Y):Y=t[15],y=[...s??[]].sort(Y),t[11]=a,t[12]=s,t[13]=y}else y=t[13];const C=y;let k;t[16]!==i?(k=Y=>{h(!1),i({to:"/$org",params:{org:Y}})},t[16]=i,t[17]=k):k=t[17];const w=k;let V;t[18]===Symbol.for("react.memo_cache_sentinel")?(V=()=>h(!1),t[18]=V):V=t[18];const j=V;let I;t[19]===Symbol.for("react.memo_cache_sentinel")?(I=n.jsx(Zn,{size:16}),t[19]=I):I=t[19];let T;t[20]!==i||t[21]!==a?(T={key:"preferences",label:"Preferences",icon:I,onClick:()=>{i({to:"/$org/settings/profile",params:{org:a??""}})}},t[20]=i,t[21]=a,t[22]=T):T=t[22];let R;t[23]===Symbol.for("react.memo_cache_sentinel")?(R={key:"terms",label:"Terms of Use",icon:n.jsx(Ig,{size:16}),href:"https://www.decocms.com/terms-of-use",external:!0},t[23]=R):R=t[23];let N;t[24]===Symbol.for("react.memo_cache_sentinel")?(N={key:"privacy",label:"Privacy Policy",icon:n.jsx(Rg,{size:16}),href:"https://www.decocms.com/privacy-policy",external:!0},t[24]=N):N=t[24];let A;t[25]===Symbol.for("react.memo_cache_sentinel")?(A={key:"github",label:"decocms/studio",icon:n.jsx(_p,{className:"w-4 h-4"}),href:"https://github.com/decocms/studio",external:!0},t[25]=A):A=t[25];let E;t[26]===Symbol.for("react.memo_cache_sentinel")?(E={key:"community",label:"Community",icon:n.jsx(po,{size:16}),href:"https://decocms.com/discord",external:!0},t[26]=E):E=t[26];let M;t[27]===Symbol.for("react.memo_cache_sentinel")?(M={key:"homepage",label:"Homepage",icon:n.jsx(cu,{size:16}),href:"https://decocms.com",external:!0},t[27]=M):M=t[27];let L;t[28]!==T?(L=[T,R,N,A,E,M],t[28]=T,t[29]=L):L=t[29];const D=L;let P;t[30]===Symbol.for("react.memo_cache_sentinel")?(P={key:"logout",label:"Sign out",icon:n.jsx(Fg,{size:16}),onClick:iy},t[30]=P):P=t[30];const O=P;let z;t[31]===Symbol.for("react.memo_cache_sentinel")?(z={value:"light",icon:n.jsx(O_,{size:14}),label:"Light theme"},t[31]=z):z=t[31];let $;t[32]===Symbol.for("react.memo_cache_sentinel")?($={value:"dark",icon:n.jsx(B_,{size:14}),label:"Dark theme"},t[32]=$):$=t[32];let q;t[33]===Symbol.for("react.memo_cache_sentinel")?(q=[z,$,{value:"system",icon:n.jsx($_,{size:14}),label:"System theme"}],t[33]=q):q=t[33];const F=q;let G;t[34]===Symbol.for("react.memo_cache_sentinel")?(G=()=>{h(!1),m(!0)},t[34]=G):G=t[34];let H;t[35]!==w||t[36]!==d||t[37]!==D||t[38]!==a||t[39]!==l||t[40]!==c||t[41]!==C||t[42]!==p||t[43]!==g?(H={user:p,userImage:g,menuItems:D,signOutItem:O,themeOptions:F,preferences:l,setPreferences:c,sortedOrgs:C,orgParam:a,onSelectOrg:w,onCreateOrg:G,close:j,isMobile:d},t[35]=w,t[36]=d,t[37]=D,t[38]=a,t[39]=l,t[40]=c,t[41]=C,t[42]=p,t[43]=g,t[44]=H):H=t[44];const U=H;_=d?n.jsxs(Ci,{open:u,onOpenChange:h,direction:"bottom",children:[n.jsxs("button",{type:"button",onClick:()=>h(!0),className:"flex items-center gap-3 w-full px-3 py-2.5 rounded-lg transition-colors text-sm text-sidebar-foreground/70 hover:bg-sidebar-accent hover:text-sidebar-foreground",children:[n.jsx("div",{className:"shrink-0 size-5 rounded-md flex items-center justify-center border border-border/50 overflow-hidden",style:b?.logo?void 0:wa(b?.name??""),children:b?.logo?n.jsx("img",{src:b.logo,alt:"",className:"size-full object-cover"}):n.jsx("span",{className:"font-semibold leading-none text-[8px]",children:(b?.name??"?").slice(0,2).toUpperCase()})}),n.jsx("span",{className:"truncate",children:b?.name??"Account"})]}),n.jsxs(Vi,{className:"h-[80dvh] p-0",children:[n.jsx(wi,{className:"sr-only",children:"Account"}),n.jsx(rd,{...U})]})]}):n.jsxs(di,{open:u,onOpenChange:h,children:[n.jsx(li,{asChild:!0,children:n.jsx(_s,{tooltip:b?.name??"Account",className:"rounded-md",children:n.jsx("div",{className:"shrink-0 size-6 rounded-md flex items-center justify-center border border-border/50 overflow-hidden",style:b?.logo?void 0:wa(b?.name??""),children:b?.logo?n.jsx("img",{src:b.logo,alt:"",className:"size-full object-cover"}):n.jsx("span",{className:"font-semibold leading-none text-[9px]",children:(b?.name??"?").slice(0,2).toUpperCase()})})})}),n.jsx(ci,{side:"right",align:"end",sideOffset:18,collisionPadding:16,className:"w-[520px] p-0 flex max-h-[520px]",onCloseAutoFocus:sy,children:n.jsx(rd,{...U})})]}),t[1]=d,t[2]=i,t[3]=u,t[4]=a,t[5]=s,t[6]=l,t[7]=c,t[8]=p,t[9]=g,t[10]=_}else _=t[10];let v;t[45]!==f?(v=n.jsx(G0,{open:f,onOpenChange:m}),t[45]=f,t[46]=v):v=t[46];let x;return t[47]!==_||t[48]!==v?(x=n.jsxs(n.Fragment,{children:[_,v]}),t[47]=_,t[48]=v,t[49]=x):x=t[49],x}function sy(t){return t.preventDefault()}function iy(){ne("signed_out",{source:"account_popover"}),St.signOut()}function ny({invitation:t}){const[e,s]=S.useState(!1),[i,r]=S.useState(!1),o=Mt(),a=async()=>{s(!0);try{const c=await St.organization.acceptInvitation({invitationId:t.id});if(c.error)ue.error(c.error.message),s(!1);else{const d=await St.organization.setActive({organizationId:t.organizationId});ue.success("Invitation accepted!");const u=d?.data?.slug;window.location.href=u?`/${u}`:"/"}}catch{ue.error("Failed to accept invitation"),s(!1)}},l=async()=>{r(!0);try{const c=await St.organization.rejectInvitation({invitationId:t.id});c.error?(ue.error(c.error.message),r(!1)):(ue.success("Invitation declined"),o.invalidateQueries())}catch{ue.error("Failed to decline invitation"),r(!1)}};return n.jsxs("div",{className:"flex items-center gap-3 px-5 py-4 border-b border-border last:border-0 hover:bg-muted/25 transition-colors",children:[n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsx("p",{className:"text-xs text-muted-foreground",children:"You've been invited to join"}),n.jsx("p",{className:"text-sm font-medium truncate",children:t.organizationName??"Unknown organization"})]}),n.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[n.jsx(ae,{size:"icon",variant:"ghost",className:"size-7 text-green-600 hover:text-green-700 hover:bg-green-50 dark:hover:bg-green-950",onClick:a,disabled:e||i,"aria-label":"Accept invitation",children:n.jsx(Jt,{size:14})}),n.jsx(ae,{size:"icon",variant:"ghost",className:"size-7 text-muted-foreground hover:text-destructive hover:bg-destructive/10",onClick:l,disabled:e||i,"aria-label":"Decline invitation",children:n.jsx(ri,{size:14})})]})]})}function ry(){const t=S.useContext(xp),{data:e}=t.hooks.useListUserInvitations();return(e??[]).filter(i=>i.status==="pending"&&new Date(i.expiresAt)>new Date)}class oy extends S.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e,s){}render(){return this.state.hasError?null:this.props.children}}function ay(t){return t<=1?"text-destructive":t<=5?"text-amber-500 dark:text-amber-400":"text-foreground/70"}function ly(){const t=B.c(19),e=Ge(),{org:s}=xe();let i;t[0]!==s.id?(i={connectionId:Pt,orgId:s.id},t[0]=s.id,t[1]=i):i=t[1];const r=Be(i);let o;t[2]===Symbol.for("react.memo_cache_sentinel")?(o={providerId:"deco"},t[2]=o):o=t[2];let a;t[3]!==r?(a={client:r,toolName:"AI_PROVIDER_CREDITS",toolArguments:o,staleTime:6e4,select:cy},t[3]=r,t[4]=a):a=t[4];const{data:l,isPending:c,isError:d}=ki(a),u=l?.balanceCents!=null?l.balanceCents/100:null;let h;t[5]!==u||t[6]!==d||t[7]!==c?(h=c||d||u==null?"Credits":`Credits: $${u.toFixed(2)}`,t[5]=u,t[6]=d,t[7]=c,t[8]=h):h=t[8];const f=h;let m;t[9]!==u?(m=J(u!=null&&ay(u)),t[9]=u,t[10]=m):m=t[10];let p;t[11]!==e||t[12]!==s.slug?(p=()=>e({to:"/$org/settings/ai-providers",params:{org:s.slug}}),t[11]=e,t[12]=s.slug,t[13]=p):p=t[13];let g;t[14]===Symbol.for("react.memo_cache_sentinel")?(g=n.jsx(yl,{size:24}),t[14]=g):g=t[14];let _;return t[15]!==m||t[16]!==p||t[17]!==f?(_=n.jsx(vs,{children:n.jsx(Zt,{children:n.jsx(_s,{tooltip:f,className:m,onClick:p,children:g})})}),t[15]=m,t[16]=p,t[17]=f,t[18]=_):_=t[18],_}function cy(t){return t.structuredContent}function dy(){const t=B.c(1);if(!jl().some(hy))return null;let i;return t[0]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx(ly,{}),t[0]=i):i=t[0],i}function hy(t){return t.providerId==="deco"}function uy(){const t=B.c(3),[e,s]=S.useState(!1);let i;t[0]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx(vs,{children:n.jsx(Zt,{children:n.jsx(_s,{tooltip:"Connections",onClick:()=>{ne("connections_dialog_opened",{source:"sidebar_footer",mode:"browse"}),s(!0)},children:n.jsx(Ug,{size:24})})})}),t[0]=i):i=t[0];let r;return t[1]!==e?(r=n.jsxs(n.Fragment,{children:[i,n.jsx(Fl,{mode:"browse",open:e,onOpenChange:s,defaultTab:"all"})]}),t[1]=e,t[2]=r):r=t[2],r}function fy(){const t=B.c(11),e=ry();let s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx(bc,{size:24}),t[0]=s):s=t[0];let i;t[1]!==e.length?(i=e.length>0&&n.jsx("span",{className:"absolute top-1 right-1 size-2 rounded-full bg-red-500 pointer-events-none"}),t[1]=e.length,t[2]=i):i=t[2];let r;t[3]!==i?(r=n.jsx(vs,{children:n.jsx(Zt,{children:n.jsx(li,{asChild:!0,children:n.jsxs(_s,{tooltip:"Inbox",className:"relative",children:[s,i]})})})}),t[3]=i,t[4]=r):r=t[4];let o;t[5]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx("div",{className:"px-4 py-3 border-b border-border shrink-0",children:n.jsx("h3",{className:"text-sm font-medium",children:"Inbox"})}),t[5]=o):o=t[5];let a;t[6]!==e?(a=n.jsxs(ci,{side:"right",align:"start",sideOffset:16,collisionPadding:16,className:"w-[min(400px,calc(100vw-2rem))] p-0 h-[min(650px,calc(100dvh-4rem))] flex flex-col",children:[o,e.length===0?n.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-2 px-6 text-center",children:[n.jsx(bc,{size:24,className:"text-muted-foreground/50"}),n.jsx("p",{className:"text-sm font-medium text-foreground",children:"No invites pending"}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Organization invitations will appear here"})]}):n.jsx("div",{className:"overflow-y-auto flex-1",children:e.map(my)})]}),t[6]=e,t[7]=a):a=t[7];let l;return t[8]!==r||t[9]!==a?(l=n.jsxs(di,{children:[r,a]}),t[8]=r,t[9]=a,t[10]=l):l=t[10],l}function my(t){return n.jsx(ny,{invitation:t},t.id)}function py(){const t=B.c(6),e=Ge(),{org:s}=xe();let i;t[0]!==e||t[1]!==s.slug?(i=()=>e({to:"/$org/settings",params:{org:s.slug}}),t[0]=e,t[1]=s.slug,t[2]=i):i=t[2];let r;t[3]===Symbol.for("react.memo_cache_sentinel")?(r=n.jsx(Zn,{size:24}),t[3]=r):r=t[3];let o;return t[4]!==i?(o=n.jsx(vs,{children:n.jsx(Zt,{children:n.jsx(_s,{tooltip:"Settings",onClick:i,children:r})})}),t[4]=i,t[5]=o):o=t[5],o}function gy(){const t=B.c(5);let e,s,i,r;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(oy,{children:n.jsx(S.Suspense,{fallback:null,children:n.jsx(dy,{})})}),s=n.jsx(uy,{}),i=n.jsx(fy,{}),r=n.jsx(py,{}),t[0]=e,t[1]=s,t[2]=i,t[3]=r):(e=t[0],s=t[1],i=t[2],r=t[3]);let o;return t[4]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsxs(Iu,{className:"px-2 pb-3 gap-1",children:[e,s,i,r,n.jsx(vs,{children:n.jsx(Zt,{children:n.jsx(pf,{})})})]}),t[4]=o):o=t[4],o}function _y(){const t=B.c(10),e=Ge(),{org:s}=xe(),{setOpenMobile:i}=Qn();let r;t[0]!==e||t[1]!==s.slug||t[2]!==i?(r=()=>{e({to:"/$org/settings",params:{org:s.slug}}),i(!1)},t[0]=e,t[1]=s.slug,t[2]=i,t[3]=r):r=t[3];let o;t[4]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx(Zn,{}),t[4]=o):o=t[4];let a;t[5]!==r?(a=n.jsx(Zt,{children:n.jsx(_s,{tooltip:"Settings",onClick:r,children:o})}),t[5]=r,t[6]=a):a=t[6];let l;t[7]===Symbol.for("react.memo_cache_sentinel")?(l=n.jsx(Zt,{children:n.jsx(pf,{})}),t[7]=l):l=t[7];let c;return t[8]!==a?(c=n.jsx(Iu,{children:n.jsxs(vs,{children:[a,l]})}),t[8]=a,t[9]=c):c=t[9],c}function xy(){for(var t=arguments.length,e=new Array(t),s=0;s<t;s++)e[s]=arguments[s];return S.useMemo(()=>i=>{e.forEach(r=>r(i))},e)}const xo=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Xi(t){const e=Object.prototype.toString.call(t);return e==="[object Window]"||e==="[object global]"}function Ul(t){return"nodeType"in t}function Wt(t){var e,s;return t?Xi(t)?t:Ul(t)&&(e=(s=t.ownerDocument)==null?void 0:s.defaultView)!=null?e:window:window}function Hl(t){const{Document:e}=Wt(t);return t instanceof e}function tr(t){return Xi(t)?!1:t instanceof Wt(t).HTMLElement}function gf(t){return t instanceof Wt(t).SVGElement}function Ji(t){return t?Xi(t)?t.document:Ul(t)?Hl(t)?t:tr(t)||gf(t)?t.ownerDocument:document:document:document}const Ds=xo?S.useLayoutEffect:S.useEffect;function Wl(t){const e=S.useRef(t);return Ds(()=>{e.current=t}),S.useCallback(function(){for(var s=arguments.length,i=new Array(s),r=0;r<s;r++)i[r]=arguments[r];return e.current==null?void 0:e.current(...i)},[])}function vy(){const t=S.useRef(null),e=S.useCallback((i,r)=>{t.current=setInterval(i,r)},[]),s=S.useCallback(()=>{t.current!==null&&(clearInterval(t.current),t.current=null)},[]);return[e,s]}function Mn(t,e){e===void 0&&(e=[t]);const s=S.useRef(t);return Ds(()=>{s.current!==t&&(s.current=t)},e),s}function sr(t,e){const s=S.useRef();return S.useMemo(()=>{const i=t(s.current);return s.current=i,i},[...e])}function Gr(t){const e=Wl(t),s=S.useRef(null),i=S.useCallback(r=>{r!==s.current&&e?.(r,s.current),s.current=r},[]);return[s,i]}function Va(t){const e=S.useRef();return S.useEffect(()=>{e.current=t},[t]),e.current}let Bo={};function ir(t,e){return S.useMemo(()=>{if(e)return e;const s=Bo[t]==null?0:Bo[t]+1;return Bo[t]=s,t+"-"+s},[t,e])}function _f(t){return function(e){for(var s=arguments.length,i=new Array(s>1?s-1:0),r=1;r<s;r++)i[r-1]=arguments[r];return i.reduce((o,a)=>{const l=Object.entries(a);for(const[c,d]of l){const u=o[c];u!=null&&(o[c]=u+t*d)}return o},{...e})}}const Oi=_f(1),Pn=_f(-1);function by(t){return"clientX"in t&&"clientY"in t}function Kl(t){if(!t)return!1;const{KeyboardEvent:e}=Wt(t.target);return e&&t instanceof e}function yy(t){if(!t)return!1;const{TouchEvent:e}=Wt(t.target);return e&&t instanceof e}function Ca(t){if(yy(t)){if(t.touches&&t.touches.length){const{clientX:e,clientY:s}=t.touches[0];return{x:e,y:s}}else if(t.changedTouches&&t.changedTouches.length){const{clientX:e,clientY:s}=t.changedTouches[0];return{x:e,y:s}}}return by(t)?{x:t.clientX,y:t.clientY}:null}const Ln=Object.freeze({Translate:{toString(t){if(!t)return;const{x:e,y:s}=t;return"translate3d("+(e?Math.round(e):0)+"px, "+(s?Math.round(s):0)+"px, 0)"}},Scale:{toString(t){if(!t)return;const{scaleX:e,scaleY:s}=t;return"scaleX("+e+") scaleY("+s+")"}},Transform:{toString(t){if(t)return[Ln.Translate.toString(t),Ln.Scale.toString(t)].join(" ")}},Transition:{toString(t){let{property:e,duration:s,easing:i}=t;return e+" "+s+"ms "+i}}}),od="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function Sy(t){return t.matches(od)?t:t.querySelector(od)}const wy={display:"none"};function Vy(t){let{id:e,value:s}=t;return Ut.createElement("div",{id:e,style:wy},s)}function Cy(t){let{id:e,announcement:s,ariaLiveType:i="assertive"}=t;const r={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return Ut.createElement("div",{id:e,style:r,role:"status","aria-live":i,"aria-atomic":!0},s)}function ky(){const[t,e]=S.useState("");return{announce:S.useCallback(i=>{i!=null&&e(i)},[]),announcement:t}}const xf=S.createContext(null);function jy(t){const e=S.useContext(xf);S.useEffect(()=>{if(!e)throw new Error("useDndMonitor must be used within a children of <DndContext>");return e(t)},[t,e])}function Ny(){const[t]=S.useState(()=>new Set),e=S.useCallback(i=>(t.add(i),()=>t.delete(i)),[t]);return[S.useCallback(i=>{let{type:r,event:o}=i;t.forEach(a=>{var l;return(l=a[r])==null?void 0:l.call(a,o)})},[t]),e]}const Ay={draggable:`
|
|
548
|
+
`}]}}function ui(t){return{type:"paragraph",content:t}}function Ws(t){return{type:"text",text:t}}function Cb({agentId:t,title:e}){return{type:"mention",attrs:{id:t,name:e,char:"@",metadata:{agentId:t,title:e}}}}const mn="deco/site-diagnostics";function rf(t){const e=B.c(15),{open:s,onOpenChange:i}=t,[r,o]=S.useState(null);let a;e[0]!==i?(a=()=>{o(null),i(!1)},e[0]=i,e[1]=a):a=e[1];const l=a,c=s&&r===null;let d;e[2]!==r||e[3]!==i?(d=p=>{!p&&r===null&&i(!1)},e[2]=r,e[3]=i,e[4]=d):d=e[4];let u;e[5]!==c||e[6]!==d?(u=n.jsx(Su,{open:c,onOpenChange:d,title:"Set up self-healing repo",hideAutoRespondCheckbox:!0,onImportComplete:o}),e[5]=c,e[6]=d,e[7]=u):u=e[7];const h=s&&r!==null;let f;e[8]!==l||e[9]!==r||e[10]!==h?(f=n.jsx(kb,{open:h,payload:r,onClose:l}),e[8]=l,e[9]=r,e[10]=h,e[11]=f):f=e[11];let m;return e[12]!==u||e[13]!==f?(m=n.jsxs(n.Fragment,{children:[u,f]}),e[12]=u,e[13]=f,e[14]=m):m=e[14],m}function kb(t){const e=B.c(66),{open:s,payload:i,onClose:r}=t,{org:o}=xe(),a=Yn(),l=mo();let c;e[0]!==o.id?(c={connectionId:Pt,orgId:o.id},e[0]=o.id,e[1]=c):c=e[1];const d=Be(c),[u,h]=S.useState(""),[f,m]=S.useState(Ab);let p;e[2]!==s?(p={enabled:s},e[2]=s,e[3]=p):p=e[3];const{data:g}=C_(mn,p);let _;e[4]!==l||e[5]!==f||e[6]!==i||e[7]!==d||e[8]!==g||e[9]!==u?(_=async()=>{if(!i)throw new Error("No imported repo payload");const Y=Jc(u);if(!Y)throw new Error("Enter a valid https:// URL");const W=Sa.filter(X=>f[X.id]);if(W.length===0)return{succeeded:[],failed:[]};const K=await Tb({selfClient:d,createConnection:l.create.mutateAsync,registry:g}),ee=[],Z=[];for(const X of W)try{await Db({template:X,selfClient:d,siteDiagnosticsConnectionId:K,projectAgentId:i.virtualMcpId,owner:i.repo.owner,repo:i.repo.name,siteRootUrl:Y}),ee.push(X.title)}catch(ie){const re=ie;console.error(`Failed to set up ${X.title}:`,re),Z.push(X.title)}return{succeeded:ee,failed:Z}},e[4]=l,e[5]=f,e[6]=i,e[7]=d,e[8]=g,e[9]=u,e[10]=_):_=e[10];let v;e[11]!==a||e[12]!==r||e[13]!==i?.virtualMcpId?(v=Y=>{const{succeeded:W,failed:K}=Y;W.length>0?ue.success(`Self-healing repo ready — ${W.length} specialist${W.length>1?"s":""} set up`):K.length===0&&ue.success("Repo imported. Add specialists later from automations."),K.length>0&&ue.warning(`Could not set up: ${K.join(", ")}. You can add them later from the automations view.`);const ee=i?.virtualMcpId;r(),localStorage.setItem("mesh:sidebar-open",JSON.stringify(!1)),ee&&a(ee)},e[11]=a,e[12]=r,e[13]=i?.virtualMcpId,e[14]=v):v=e[14];let x;e[15]!==_||e[16]!==v?(x={mutationFn:_,onSuccess:v,onError:Nb},e[15]=_,e[16]=v,e[17]=x):x=e[17];const b=qi(x);let y;e[18]!==b.isPending||e[19]!==u?(y=Jc(u)!==null&&!b.isPending,e[18]=b.isPending,e[19]=u,e[20]=y):y=e[20];const C=y;let k;e[21]!==r||e[22]!==b.isPending?(k=Y=>{!Y&&!b.isPending&&r()},e[21]=r,e[22]=b.isPending,e[23]=k):k=e[23];let w;e[24]===Symbol.for("react.memo_cache_sentinel")?(w=n.jsx(hs,{className:"h-12 border-b border-border px-4 flex flex-row items-center shrink-0 space-y-0",children:n.jsx(ds,{className:"text-sm font-medium text-foreground",children:"Add specialist monitors"})}),e[24]=w):w=e[24];let V;e[25]===Symbol.for("react.memo_cache_sentinel")?(V=n.jsx("p",{className:"text-sm text-muted-foreground",children:"Specialists run on a daily schedule. Your repo agent collects their findings and opens GitHub issues, then writes the fixes."}),e[25]=V):V=e[25];let j;e[26]===Symbol.for("react.memo_cache_sentinel")?(j=n.jsx("label",{htmlFor:"self-healing-site-url",className:"text-xs font-medium text-foreground",children:"Production URL"}),e[26]=j):j=e[26];let I;e[27]===Symbol.for("react.memo_cache_sentinel")?(I=Y=>h(Y.target.value),e[27]=I):I=e[27];let T;e[28]!==u?(T=n.jsx(gt,{id:"self-healing-site-url",type:"url",placeholder:"https://example.com",value:u,onChange:I,autoFocus:!0}),e[28]=u,e[29]=T):T=e[29];let R;e[30]===Symbol.for("react.memo_cache_sentinel")?(R=n.jsx("p",{className:"text-xs text-muted-foreground",children:"The site the specialists will monitor."}),e[30]=R):R=e[30];let N;e[31]!==T?(N=n.jsxs("div",{className:"flex flex-col gap-1.5",children:[j,T,R]}),e[31]=T,e[32]=N):N=e[32];let A;e[33]!==f?(A=Sa.map(Y=>n.jsx(Eb,{template:Y,enabled:f[Y.id]??!1,onToggle:W=>m(K=>({...K,[Y.id]:W}))},Y.id)),e[33]=f,e[34]=A):A=e[34];let E,M;e[35]===Symbol.for("react.memo_cache_sentinel")?(E=Sb.map(jb),M=n.jsx(Rb,{}),e[35]=E,e[36]=M):(E=e[35],M=e[36]);let L;e[37]!==A?(L=n.jsxs("div",{className:"flex flex-col gap-2",children:[A,E,M]}),e[37]=A,e[38]=L):L=e[38];let D;e[39]!==N||e[40]!==L?(D=n.jsxs("div",{className:"flex-1 overflow-y-auto px-4 py-4 flex flex-col gap-4",children:[V,N,L]}),e[39]=N,e[40]=L,e[41]=D):D=e[41];let P;e[42]!==a||e[43]!==r||e[44]!==i?.virtualMcpId||e[45]!==b.isPending?(P=()=>{if(!b.isPending){const Y=i?.virtualMcpId;r(),Y&&a(Y)}},e[42]=a,e[43]=r,e[44]=i?.virtualMcpId,e[45]=b.isPending,e[46]=P):P=e[46];let O;e[47]!==b.isPending||e[48]!==P?(O=n.jsx("button",{type:"button",onClick:P,disabled:b.isPending,className:"text-xs text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50 cursor-pointer",children:"Skip for now"}),e[47]=b.isPending,e[48]=P,e[49]=O):O=e[49];let z;e[50]!==b?(z=()=>b.mutate(),e[50]=b,e[51]=z):z=e[51];const $=!C,q=b.isPending?"Setting up...":"Set up specialists";let F;e[52]!==z||e[53]!==$||e[54]!==q?(F=n.jsx(ae,{onClick:z,disabled:$,size:"sm",children:q}),e[52]=z,e[53]=$,e[54]=q,e[55]=F):F=e[55];let G;e[56]!==O||e[57]!==F?(G=n.jsxs("div",{className:"border-t border-border px-4 py-3 flex items-center justify-between gap-3 shrink-0",children:[O,F]}),e[56]=O,e[57]=F,e[58]=G):G=e[58];let H;e[59]!==D||e[60]!==G?(H=n.jsxs(ts,{className:"sm:max-w-[560px] max-h-[85svh] p-0 gap-0 overflow-hidden flex flex-col",children:[w,D,G]}),e[59]=D,e[60]=G,e[61]=H):H=e[61];let U;return e[62]!==s||e[63]!==H||e[64]!==k?(U=n.jsx(ss,{open:s,onOpenChange:k,children:H}),e[62]=s,e[63]=H,e[64]=k,e[65]=U):U=e[65],U}function jb(t){return n.jsx(Ib,{title:t.title,description:t.description,icon:t.icon},t.id)}function Nb(t){ue.error("Failed to set up specialists: "+(t instanceof Error?t.message:"Unknown error"))}function Ab(){const t={};for(const e of Sa)t[e.id]=!0;return t}function Eb(t){const e=B.c(20),{template:s,enabled:i,onToggle:r}=t,o=i?"bg-accent/30":"hover:bg-accent/30";let a;e[0]!==o?(a=J("flex items-center gap-3 rounded-lg border border-border px-3 py-3 cursor-pointer transition-colors",o),e[0]=o,e[1]=a):a=e[1];let l;e[2]!==s.icon||e[3]!==s.title?(l=n.jsx(gs,{icon:s.icon,name:s.title,size:"sm",className:"shrink-0"}),e[2]=s.icon,e[3]=s.title,e[4]=l):l=e[4];let c;e[5]!==s.title?(c=n.jsx("span",{className:"text-sm font-medium text-foreground leading-tight",children:s.title}),e[5]=s.title,e[6]=c):c=e[6];let d;e[7]!==s.description?(d=n.jsx("span",{className:"text-xs text-muted-foreground line-clamp-2",children:s.description}),e[7]=s.description,e[8]=d):d=e[8];let u;e[9]!==c||e[10]!==d?(u=n.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[c,d]}),e[9]=c,e[10]=d,e[11]=u):u=e[11];let h;e[12]!==i||e[13]!==r?(h=n.jsx(Ur,{checked:i,onCheckedChange:r,className:"shrink-0"}),e[12]=i,e[13]=r,e[14]=h):h=e[14];let f;return e[15]!==a||e[16]!==l||e[17]!==u||e[18]!==h?(f=n.jsxs("label",{className:a,children:[l,u,h]}),e[15]=a,e[16]=l,e[17]=u,e[18]=h,e[19]=f):f=e[19],f}function Ib(t){const e=B.c(14),{title:s,description:i,icon:r}=t;let o;e[0]!==r||e[1]!==s?(o=n.jsx(gs,{icon:r,name:s,size:"sm",className:"shrink-0"}),e[0]=r,e[1]=s,e[2]=o):o=e[2];let a;e[3]!==s?(a=n.jsx("span",{className:"text-sm font-medium text-foreground leading-tight",children:s}),e[3]=s,e[4]=a):a=e[4];let l;e[5]!==i?(l=n.jsx("span",{className:"text-xs text-muted-foreground line-clamp-2",children:i}),e[5]=i,e[6]=l):l=e[6];let c;e[7]!==a||e[8]!==l?(c=n.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[a,l]}),e[7]=a,e[8]=l,e[9]=c):c=e[9];let d;e[10]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx("span",{className:"text-[10px] font-medium uppercase tracking-wide text-muted-foreground shrink-0",children:"Coming soon"}),e[10]=d):d=e[10];let u;return e[11]!==o||e[12]!==c?(u=n.jsxs("div",{className:"flex items-center gap-3 rounded-lg border border-dashed border-border px-3 py-3 opacity-60",children:[o,c,d]}),e[11]=o,e[12]=c,e[13]=u):u=e[13],u}function Rb(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx("div",{className:"flex items-center justify-center rounded-lg border border-dashed border-border px-3 py-3 text-xs text-muted-foreground",children:"More specialists coming soon"}),t[0]=e):e=t[0],e}function Jc(t){const e=t.trim();if(!e)return null;try{const s=new URL(e);return s.protocol!=="https:"&&s.protocol!=="http:"?null:s.origin+(s.pathname==="/"?"":s.pathname)}catch{return null}}async function Tb({selfClient:t,createConnection:e,registry:s}){const r=(await t.callTool({name:"COLLECTION_CONNECTIONS_LIST",arguments:{where:{field:["app_id"],operator:"eq",value:mn},limit:1,offset:0}})).structuredContent?.items?.find(u=>u.app_id===mn);if(r)return r.id;const o=s?.server?.remotes?.[0]?.url;if(!o)throw new Error("Site Diagnostics MCP is not available in the registry right now.");const a=s?.title??s?.server?.title??s?.server?.name??"Site Diagnostics",l=s?.server?.icons?.[0]?.src??null,c=s?.server?.description??null;return(await e({title:a,description:c,icon:l,connection_type:"HTTP",connection_url:o,app_name:s?.server?.name??"site-diagnostics",app_id:mn,metadata:{type:"site-diagnostics",source:"store",registry_item_id:mn,verified:!0}})).id}async function Db({template:t,selfClient:e,siteDiagnosticsConnectionId:s,projectAgentId:i,owner:r,repo:o,siteRootUrl:a}){const l=`${o}: ${t.title}`,d=(await e.callTool({name:"AUTOMATION_LIST",arguments:{virtual_mcp_id:i}})).structuredContent?.automations?.find(h=>h.name===l);let u;if(!(d&&d.trigger_count>0)){if(d)u=d.id;else{const h=await Mb({template:t,selfClient:e,siteDiagnosticsConnectionId:s}),f=wb({template:t,specialistAgentId:h,owner:r,repo:o,siteRootUrl:a}),m=Oh(f),p=await e.callTool({name:"AUTOMATION_CREATE",arguments:{name:l,virtual_mcp_id:i,agent:{id:i},messages:m,active:!0}});u=(p.structuredContent??p).id}await e.callTool({name:"AUTOMATION_TRIGGER_ADD",arguments:{automation_id:u,type:"cron",cron_expression:t.cron}})}}async function Mb({template:t,selfClient:e,siteDiagnosticsConnectionId:s}){const r=(await e.callTool({name:"COLLECTION_VIRTUAL_MCP_LIST",arguments:{where:{field:["metadata","specialistId"],operator:"eq",value:t.id},limit:1,offset:0}})).structuredContent?.items?.find(l=>l.metadata?.specialistId===t.id);if(r)return r.id;const o=await e.callTool({name:"COLLECTION_VIRTUAL_MCP_CREATE",arguments:{data:{title:t.title,description:t.description,icon:t.icon,pinned:!1,metadata:{specialistId:t.id,instructions:t.instructions},connections:[{connection_id:s,selected_tools:t.siteDiagnosticsTools,selected_resources:null,selected_prompts:null}]}}});return(o.structuredContent??o).item.id}function Pb(t){try{const e=localStorage.getItem(`mesh:chat:recent-agents:${t}`);return e?JSON.parse(e):[]}catch{return[]}}function Ai(t){const e=B.c(21),{agent:s,onSpecialClick:i,tracking:r}=t,{org:o}=xe(),a=Ge();let l;e[0]!==s.id||e[1]!==s.title||e[2]!==a||e[3]!==i||e[4]!==o||e[5]!==r.action||e[6]!==r.template_id||e[7]!==r.tile_kind?(l=()=>{if(ne("home_agent_tile_clicked",{template_id:r.template_id,agent_id:s.id,agent_title:s.title,tile_kind:r.tile_kind,action:r.action}),i)i();else{const g=crypto.randomUUID();a({to:"/$org/$taskId",params:{org:o.slug,taskId:g},search:{virtualmcpid:s.id}})}},e[0]=s.id,e[1]=s.title,e[2]=a,e[3]=i,e[4]=o,e[5]=r.action,e[6]=r.template_id,e[7]=r.tile_kind,e[8]=l):l=e[8];const c=l;let d;e[9]===Symbol.for("react.memo_cache_sentinel")?(d=J("flex flex-col items-center gap-3 p-2 rounded-lg","transition-colors","cursor-pointer","w-[100px] shrink-0","group"),e[9]=d):d=e[9];const u=`Select agent ${s.title}`;let h;e[10]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx(po,{size:24}),e[10]=h):h=e[10];let f;e[11]!==s.icon||e[12]!==s.title?(f=n.jsx(Ls,{icon:s.icon,name:s.title,size:"md",fallbackIcon:h,className:"transition-transform group-hover:scale-110"}),e[11]=s.icon,e[12]=s.title,e[13]=f):f=e[13];let m;e[14]!==s.title?(m=n.jsx("p",{className:"text-xs sm:text-sm text-foreground text-center leading-tight line-clamp-2 break-words w-full",children:s.title}),e[14]=s.title,e[15]=m):m=e[15];let p;return e[16]!==c||e[17]!==u||e[18]!==f||e[19]!==m?(p=n.jsxs("button",{type:"button",onClick:c,className:d,"aria-label":u,children:[f,m]}),e[16]=c,e[17]=u,e[18]=f,e[19]=m,e[20]=p):p=e[20],p}function Lb(){const t=B.c(8),e=Ge(),{org:s}=xe();let i;t[0]===Symbol.for("react.memo_cache_sentinel")?(i=J("flex flex-col items-center gap-3 p-2 rounded-lg","transition-colors","cursor-pointer","w-[100px] shrink-0","group"),t[0]=i):i=t[0];let r;t[1]!==e||t[2]!==s.slug?(r=()=>{ne("home_see_all_agents_clicked"),e({to:"/$org/settings/agents",params:{org:s.slug}})},t[1]=e,t[2]=s.slug,t[3]=r):r=t[3];let o,a;t[4]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx("div",{className:"size-12 rounded-xl bg-accent flex items-center justify-center shrink-0 transition-transform group-hover:scale-110",children:n.jsx(El,{size:20,className:"text-foreground"})}),a=n.jsx("p",{className:"text-xs sm:text-sm text-foreground text-center leading-tight",children:"See all"}),t[4]=o,t[5]=a):(o=t[4],a=t[5]);let l;return t[6]!==r?(l=n.jsxs("button",{type:"button",className:i,"aria-label":"See all agents",onClick:r,children:[o,a]}),t[6]=r,t[7]=l):l=t[7],l}function Ob(){const t=B.c(9);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={navigateOnCreate:!0},t[0]=e):e=t[0];const{createVirtualMCP:s,isCreating:i}=ku(e);let r;t[1]!==s?(r=()=>{ne("home_create_agent_clicked"),s()},t[1]=s,t[2]=r):r=t[2];let o;t[3]===Symbol.for("react.memo_cache_sentinel")?(o=J("flex flex-col items-center gap-3 p-2 rounded-lg","transition-colors","cursor-pointer","w-[100px] shrink-0","group","disabled:opacity-50 disabled:cursor-not-allowed"),t[3]=o):o=t[3];let a,l;t[4]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx("div",{className:"size-12 rounded-xl bg-background border-2 border-dashed border-border flex items-center justify-center shrink-0 transition-transform group-hover:scale-110",children:n.jsx(Qt,{size:20,className:"text-muted-foreground"})}),l=n.jsx("p",{className:"text-xs sm:text-sm text-foreground text-center leading-tight",children:"Create agent"}),t[4]=a,t[5]=l):(a=t[4],l=t[5]);let c;return t[6]!==i||t[7]!==r?(c=n.jsxs("button",{type:"button",onClick:r,disabled:i,className:o,"aria-label":"Create agent",children:[a,l]}),t[6]=i,t[7]=r,t[8]=c):c=t[8],c}function Bb(){const t=B.c(104),e=fo(),{locator:s}=xe(),[i,r]=S.useState(!1),[o,a]=S.useState(!1),[l,c]=S.useState(!1),[d,u]=S.useState(!1),[h,f]=S.useState(!1),[m]=yi(),p=Yn();let g;t[0]===Symbol.for("react.memo_cache_sentinel")?(g=ks.find(Wb),t[0]=g):g=t[0];const _=g;let v;t[1]===Symbol.for("react.memo_cache_sentinel")?(v=ks.find(Hb),t[1]=v):v=t[1];const x=v;let b;t[2]===Symbol.for("react.memo_cache_sentinel")?(b=ks.find(Ub),t[2]=b):b=t[2];const y=b;let C;t[3]===Symbol.for("react.memo_cache_sentinel")?(C=ks.find(Fb),t[3]=C):C=t[3];const k=C;let w;t[4]===Symbol.for("react.memo_cache_sentinel")?(w=ks.find(zb),t[4]=w):w=t[4];const V=w;let j,I,T,R,N,A,E,M,L,D,P,O;if(t[5]!==s||t[6]!==p||t[7]!==m.experimental_vibecode||t[8]!==e){const ee=Pb(s),Z=e.filter($b).sort((ye,Ae)=>{const fe=ee.indexOf(ye.id),ke=ee.indexOf(Ae.id);return fe!==-1&&ke!==-1?fe-ke:fe!==-1?-1:ke!==-1?1:new Date(Ae.updated_at).getTime()-new Date(ye.updated_at).getTime()}).slice(0,4);let X;if(t[21]!==e){let ye;t[23]===Symbol.for("react.memo_cache_sentinel")?(ye=Ae=>Ae.id!==null&&(Ae.metadata?.type===x.id||Ae.title===x.title),t[23]=ye):ye=t[23],X=e.find(ye),t[21]=e,t[22]=X}else X=t[22];T=X;let ie;if(t[24]!==e){let ye;t[26]===Symbol.for("react.memo_cache_sentinel")?(ye=Ae=>Ae.id!==null&&(Ae.metadata?.type===y.id||Ae.title===y.title),t[26]=ye):ye=t[26],ie=e.find(ye),t[24]=e,t[25]=ie}else ie=t[25];j=ie;let re;if(t[27]!==e){let ye;t[29]===Symbol.for("react.memo_cache_sentinel")?(ye=Ae=>Ae.id!==null&&(Ae.metadata?.type===k.id||Ae.title===k.title),t[29]=ye):ye=t[29],re=e.find(ye),t[27]=e,t[28]=re}else re=t[28];I=re,R=Z.length>0,E="w-full max-md:overflow-x-auto max-md:[scrollbar-width:none] max-md:[&::-webkit-scrollbar]:hidden",M="flex flex-wrap justify-center gap-1.5 max-md:flex-nowrap max-md:justify-start md:max-h-52 md:overflow-hidden",t[30]===Symbol.for("react.memo_cache_sentinel")?(L=n.jsx(Ai,{agent:_,onSpecialClick:()=>r(!0),tracking:{template_id:_.id,tile_kind:"template",action:"open_modal"}},_.id),t[30]=L):L=t[30],t[31]!==m.experimental_vibecode?(D=m.experimental_vibecode&&n.jsx(Ai,{agent:V,onSpecialClick:()=>f(!0),tracking:{template_id:V.id,tile_kind:"template",action:"open_modal"}},V.id),t[31]=m.experimental_vibecode,t[32]=D):D=t[32];const de=T??x;let me;t[33]!==T||t[34]!==p?(me=T?()=>p(T.id):()=>a(!0),t[33]=T,t[34]=p,t[35]=me):me=t[35];const le=T?"existing":"template",se=T?"navigate":"open_modal";let _e;t[36]!==le||t[37]!==se?(_e={template_id:x.id,tile_kind:le,action:se},t[36]=le,t[37]=se,t[38]=_e):_e=t[38],t[39]!==de||t[40]!==me||t[41]!==_e?(P=n.jsx(Ai,{agent:de,onSpecialClick:me,tracking:_e},x.id),t[39]=de,t[40]=me,t[41]=_e,t[42]=P):P=t[42];const ge=j??y;let Se;t[43]!==j||t[44]!==p?(Se=j?()=>p(j.id):()=>c(!0),t[43]=j,t[44]=p,t[45]=Se):Se=t[45];const ve=j?"existing":"template",Ne=j?"navigate":"open_modal";let Te;t[46]!==ve||t[47]!==Ne?(Te={template_id:y.id,tile_kind:ve,action:Ne},t[46]=ve,t[47]=Ne,t[48]=Te):Te=t[48],t[49]!==ge||t[50]!==Se||t[51]!==Te?(O=n.jsx(Ai,{agent:ge,onSpecialClick:Se,tracking:Te},y.id),t[49]=ge,t[50]=Se,t[51]=Te,t[52]=O):O=t[52];const te=I??k;let he;t[53]!==I||t[54]!==p?(he=I?()=>p(I.id):()=>u(!0),t[53]=I,t[54]=p,t[55]=he):he=t[55];const we=I?"existing":"template",Ee=I?"navigate":"open_modal";let Ie;t[56]!==we||t[57]!==Ee?(Ie={template_id:k.id,tile_kind:we,action:Ee},t[56]=we,t[57]=Ee,t[58]=Ie):Ie=t[58],t[59]!==te||t[60]!==he||t[61]!==Ie?(N=n.jsx(Ai,{agent:te,onSpecialClick:he,tracking:Ie},k.id),t[59]=te,t[60]=he,t[61]=Ie,t[62]=N):N=t[62];let De;t[63]!==j?.id||t[64]!==I?.id||t[65]!==T?.id?(De=ye=>ye.id!==T?.id&&ye.id!==j?.id&&ye.id!==I?.id,t[63]=j?.id,t[64]=I?.id,t[65]=T?.id,t[66]=De):De=t[66];let Pe;t[67]!==p?(Pe=ye=>n.jsx(Ai,{agent:ye,onSpecialClick:()=>p(ye.id),tracking:{template_id:null,tile_kind:"recent",action:"navigate"}},ye.id??"default"),t[67]=p,t[68]=Pe):Pe=t[68],A=Z.filter(De).map(Pe),t[5]=s,t[6]=p,t[7]=m.experimental_vibecode,t[8]=e,t[9]=j,t[10]=I,t[11]=T,t[12]=R,t[13]=N,t[14]=A,t[15]=E,t[16]=M,t[17]=L,t[18]=D,t[19]=P,t[20]=O}else j=t[9],I=t[10],T=t[11],R=t[12],N=t[13],A=t[14],E=t[15],M=t[16],L=t[17],D=t[18],P=t[19],O=t[20];let z;t[69]===Symbol.for("react.memo_cache_sentinel")?(z=n.jsx(Ob,{}),t[69]=z):z=t[69];let $;t[70]!==R?($=R&&n.jsx(Lb,{}),t[70]=R,t[71]=$):$=t[71];let q;t[72]!==N||t[73]!==A||t[74]!==$||t[75]!==M||t[76]!==L||t[77]!==D||t[78]!==P||t[79]!==O?(q=n.jsxs("div",{className:M,children:[L,D,P,O,N,A,z,$]}),t[72]=N,t[73]=A,t[74]=$,t[75]=M,t[76]=L,t[77]=D,t[78]=P,t[79]=O,t[80]=q):q=t[80];let F;t[81]!==E||t[82]!==q?(F=n.jsx("div",{className:E,children:q}),t[81]=E,t[82]=q,t[83]=F):F=t[83];let G;t[84]!==i?(G=n.jsx(Fr,{open:i,onOpenChange:r}),t[84]=i,t[85]=G):G=t[85];let H;t[86]!==o||t[87]!==T?(H=n.jsx(wu,{open:o,onOpenChange:a,existingAgent:T}),t[86]=o,t[87]=T,t[88]=H):H=t[88];let U;t[89]!==l||t[90]!==j?(U=n.jsx(mb,{open:l,onOpenChange:c,existingAgent:j}),t[89]=l,t[90]=j,t[91]=U):U=t[91];let Y;t[92]!==d||t[93]!==I?(Y=n.jsx(xb,{open:d,onOpenChange:u,existingAgent:I}),t[92]=d,t[93]=I,t[94]=Y):Y=t[94];let W;t[95]!==h?(W=n.jsx(rf,{open:h,onOpenChange:f}),t[95]=h,t[96]=W):W=t[96];let K;return t[97]!==F||t[98]!==G||t[99]!==H||t[100]!==U||t[101]!==Y||t[102]!==W?(K=n.jsxs(n.Fragment,{children:[F,G,H,U,Y,W]}),t[97]=F,t[98]=G,t[99]=H,t[100]=U,t[101]=Y,t[102]=W,t[103]=K):K=t[103],K}function $b(t){return t.id!==null&&!Br(t.id)}function zb(t){return t.id==="self-healing-storefront"}function Fb(t){return t.id==="ai-research"}function Ub(t){return t.id==="ai-image"}function Hb(t){return t.id==="site-diagnostics"}function Wb(t){return t.id==="site-editor"}function Kb(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx("div",{className:"w-full max-md:overflow-x-auto max-md:[scrollbar-width:none] max-md:[&::-webkit-scrollbar]:hidden",children:n.jsx("div",{className:"flex flex-wrap justify-center gap-1.5 max-md:flex-nowrap max-md:justify-start md:max-h-52 md:overflow-hidden",children:Array.from({length:7}).map(qb)})}),t[0]=e):e=t[0],e}function qb(t,e){return n.jsxs("div",{className:"flex flex-col items-center gap-3 p-2 w-[100px] shrink-0",children:[n.jsx(Fi,{className:"size-12 rounded-xl shrink-0"}),n.jsx(Fi,{className:"h-3 sm:h-4 w-full"})]},e)}function Qc(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(S.Suspense,{fallback:n.jsx(Kb,{}),children:n.jsx(Bb,{})}),t[0]=e):e=t[0],e}function on(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}k`:String(t)}function Zc(t){if(!t)return"—";const e=typeof t=="string"?new Date(t):t;return isNaN(e.getTime())?"—":e.toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"})}function Gb(t){return t?t.replace(/-\d{8}(?:-[a-z0-9]+)*$/i,"").replace(/-/g," "):"—"}function Yb(t){const e=B.c(4),{items:s}=t;let i;e[0]!==s?(i=s.map(Xb),e[0]=s,e[1]=i):i=e[1];let r;return e[2]!==i?(r=n.jsx("div",{className:"grid grid-cols-2 gap-x-8 gap-y-6",children:i}),e[2]=i,e[3]=r):r=e[3],r}function Xb(t){return n.jsxs("div",{className:"flex flex-col gap-1 min-w-0",children:[n.jsx("span",{className:"text-xs text-muted-foreground truncate",children:t.label}),n.jsx("span",{className:"text-sm text-foreground tabular-nums truncate",children:t.value})]},t.label)}function Jb(t){const e=B.c(30),{userTokens:s,assistantTokens:i,otherTokens:r}=t,o=s+i+r,a=o>0?s/o*100:0,l=o>0?i/o*100:0,c=o>0?r/o*100:0;let d;e[0]!==a?(d=a>0&&n.jsx("div",{className:"h-full bg-chart-1",style:{width:`${a}%`}}),e[0]=a,e[1]=d):d=e[1];let u;e[2]!==l?(u=l>0&&n.jsx("div",{className:"h-full bg-chart-2",style:{width:`${l}%`}}),e[2]=l,e[3]=u):u=e[3];let h;e[4]!==c?(h=c>0&&n.jsx("div",{className:"h-full bg-muted-foreground/30",style:{width:`${c}%`}}),e[4]=c,e[5]=h):h=e[5];let f;e[6]!==d||e[7]!==u||e[8]!==h?(f=n.jsxs("div",{className:"flex h-2 w-full overflow-hidden rounded-full bg-muted",children:[d,u,h]}),e[6]=d,e[7]=u,e[8]=h,e[9]=f):f=e[9];let m;e[10]===Symbol.for("react.memo_cache_sentinel")?(m=n.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-chart-1 shrink-0"}),e[10]=m):m=e[10];let p;e[11]!==a?(p=a.toFixed(1),e[11]=a,e[12]=p):p=e[12];let g;e[13]!==p?(g=n.jsxs("div",{className:"flex items-center gap-1.5",children:[m,n.jsxs("span",{className:"text-xs text-muted-foreground",children:["User ",p,"%"]})]}),e[13]=p,e[14]=g):g=e[14];let _;e[15]===Symbol.for("react.memo_cache_sentinel")?(_=n.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-chart-2 shrink-0"}),e[15]=_):_=e[15];let v;e[16]!==l?(v=l.toFixed(1),e[16]=l,e[17]=v):v=e[17];let x;e[18]!==v?(x=n.jsxs("div",{className:"flex items-center gap-1.5",children:[_,n.jsxs("span",{className:"text-xs text-muted-foreground",children:["Assistant ",v,"%"]})]}),e[18]=v,e[19]=x):x=e[19];let b;e[20]!==c||e[21]!==r?(b=r>0&&n.jsxs("div",{className:"flex items-center gap-1.5",children:[n.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-muted-foreground/30 shrink-0"}),n.jsxs("span",{className:"text-xs text-muted-foreground",children:["Other ",c.toFixed(1),"%"]})]}),e[20]=c,e[21]=r,e[22]=b):b=e[22];let y;e[23]!==x||e[24]!==b||e[25]!==g?(y=n.jsxs("div",{className:"flex flex-wrap gap-x-3 gap-y-1",children:[g,x,b]}),e[23]=x,e[24]=b,e[25]=g,e[26]=y):y=e[26];let C;return e[27]!==y||e[28]!==f?(C=n.jsxs("div",{className:"flex flex-col gap-2",children:[f,y]}),e[27]=y,e[28]=f,e[29]=C):C=e[29],C}function Qb(t){const e=B.c(19),{part:s}=t,i=s.input?.agent_id,r=is(i),o=r?.title??"Subtask",a=r?.icon??null,l=s.state==="input-streaming"||s.state==="input-available"||s.state==="output-available"&&s.preliminary===!0,c=s.state==="output-error",d=s.state==="approval-requested";let u;e[0]!==a||e[1]!==o?(u=n.jsx(Ls,{icon:a,name:o,size:"xs",className:"size-6 rounded-md shrink-0"}),e[0]=a,e[1]=o,e[2]=u):u=e[2];const h=c?"text-destructive":"text-foreground";let f;e[3]!==h?(f=J("shrink-0 font-medium",h),e[3]=h,e[4]=f):f=e[4];let m;e[5]!==o||e[6]!==f?(m=n.jsx("span",{className:f,children:o}),e[5]=o,e[6]=f,e[7]=m):m=e[7];let p;e[8]!==s.input?(p=s.input?.prompt&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"text-muted-foreground/50",children:"·"}),n.jsx("span",{className:"truncate text-muted-foreground",children:s.input.prompt})]}),e[8]=s.input,e[9]=p):p=e[9];let g;e[10]!==d||e[11]!==c||e[12]!==l?(g=n.jsx("span",{className:"ml-auto shrink-0",children:l?n.jsx(Me,{size:12,className:"animate-spin text-muted-foreground"}):c?n.jsx(Yg,{size:12,className:"text-destructive"}):d?n.jsx(oi,{size:12,className:"text-warning"}):n.jsx(N_,{size:12,className:"text-emerald-500"})}),e[10]=d,e[11]=c,e[12]=l,e[13]=g):g=e[13];let _;return e[14]!==u||e[15]!==m||e[16]!==p||e[17]!==g?(_=n.jsxs("div",{className:"flex items-center gap-2 text-xs min-w-0",children:[u,m,p,g]}),e[14]=u,e[15]=m,e[16]=p,e[17]=g,e[18]=_):_=e[18],_}function Zb(t){const e=B.c(58),{onClose:s,back:i,className:r}=t,[o,a]=S.useState(null),{messages:l}=Yi(),{tasks:c,taskId:d}=es(),{selectedModel:u,selectedVirtualMcp:h}=ai();let f,m,p,g,_,v,x,b;if(e[0]!==i||e[1]!==r||e[2]!==l||e[3]!==s||e[4]!==o?.id||e[5]!==u||e[6]!==h?.title||e[7]!==d||e[8]!==c){b=Symbol.for("react.early_return_sentinel");e:{let k;e[17]!==d?(k=X=>X.id===d,e[17]=d,e[18]=k):k=e[18];const w=c.find(k),V=Bh(l),j=[...l].reverse().find(l0),I=j?.metadata?.usage,T=j?.metadata?.modelLimits?.contextWindow??u?.limits?.contextWindow??null,R=I?.contextTokens??I?.totalTokens??0,N=T&&T>0?(R/T*100).toFixed(1):null,A=l;let E;e[19]!==A?(E=A.filter(a0).reduce(o0,0),e[19]=A,e[20]=E):E=e[20];const M=E,L=l;let D;e[21]!==L?(D=L.filter(r0).reduce(n0,0),e[21]=L,e[22]=D):D=e[22];const P=D,O=Math.max(0,V.totalTokens-M-P),z=l[0],$=l.at(-1),q=z?.metadata?.created_at??w?.created_at,F=$?.metadata?.created_at??w?.updated_at,G=l.filter(i0),H=l.flatMap(t0),U=u?.modelId?Gb(u.modelId):"—",Y=h?.title??"Decopilot",W=[{label:"Session",value:w?.title??"New chat"},{label:"Messages",value:G.length},{label:"Agent",value:Y},{label:"Model",value:U},{label:"Context Limit",value:T?on(T):"—"},{label:"Session Tokens (billed)",value:V.totalTokens>0?on(V.totalTokens):"0"},{label:"Usage",value:N!==null?`${N}%`:"—"},{label:"Input Tokens",value:V.inputTokens>0?on(V.inputTokens):"0"},{label:"Output Tokens",value:V.outputTokens>0?on(V.outputTokens):"0"},{label:"Reasoning Tokens",value:V.reasoningTokens>0?on(V.reasoningTokens):"0"},{label:"Cost",value:V.cost>0?`$${V.cost<.001?V.cost.toFixed(6):V.cost.toFixed(4)}`:"$0.00"},{label:"Session Created",value:Zc(q)},{label:"Last Activity",value:Zc(F)}];if(!w&&G.length===0){let X;e[23]!==r?(X=J("flex flex-col h-full w-full border-l border-border bg-background",r),e[23]=r,e[24]=X):X=e[24];let ie;e[25]===Symbol.for("react.memo_cache_sentinel")?(ie=n.jsx("span",{className:"text-sm font-medium text-foreground",children:"Context"}),e[25]=ie):ie=e[25];let re;e[26]!==i?(re=i?n.jsx(ma,{size:14,className:"text-muted-foreground"}):n.jsx(ri,{size:14,className:"text-muted-foreground"}),e[26]=i,e[27]=re):re=e[27];let de;e[28]!==s||e[29]!==re?(de=n.jsxs("div",{className:"h-11 px-4 flex items-center justify-between shrink-0 border-b border-border/50",children:[ie,n.jsx("button",{type:"button",onClick:s,className:"flex size-6 items-center justify-center rounded hover:bg-accent transition-colors",children:re})]}),e[28]=s,e[29]=re,e[30]=de):de=e[30];let me;e[31]===Symbol.for("react.memo_cache_sentinel")?(me=n.jsx("div",{className:"flex-1 flex items-center justify-center px-4 text-center",children:n.jsx("p",{className:"text-xs text-muted-foreground",children:"Start a conversation to see context"})}),e[31]=me):me=e[31];let le;e[32]!==X||e[33]!==de?(le=n.jsxs("div",{className:X,children:[de,me]}),e[32]=X,e[33]=de,e[34]=le):le=e[34],b=le;break e}e[35]!==r?(v=J("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 K;e[37]===Symbol.for("react.memo_cache_sentinel")?(K=n.jsx("span",{className:"text-sm font-medium text-foreground",children:"Context"}),e[37]=K):K=e[37];let ee;e[38]!==i?(ee=i?n.jsx(ma,{size:14}):n.jsx(ri,{size:14}),e[38]=i,e[39]=ee):ee=e[39],e[40]!==s||e[41]!==ee?(x=n.jsxs("div",{className:"flex h-11 shrink-0 items-center justify-between border-b border-border/50 px-4",children:[K,n.jsx("button",{type:"button",onClick:s,className:"flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",children:ee})]}),e[40]=s,e[41]=ee,e[42]=x):x=e[42],f="flex flex-col gap-8 p-6",m=H.length>0&&n.jsxs("div",{className:"flex flex-col gap-3",children:[n.jsx("span",{className:"text-xs text-muted-foreground",children:"Subtasks"}),n.jsx("div",{className:"flex flex-col gap-1",children:H.map(e0)})]}),p=n.jsx(Yb,{items:W});let Z;e[43]===Symbol.for("react.memo_cache_sentinel")?(Z=n.jsx("span",{className:"text-xs text-muted-foreground",children:"Context Breakdown"}),e[43]=Z):Z=e[43],e[44]!==P||e[45]!==O||e[46]!==M?(g=n.jsxs("div",{className:"flex flex-col gap-3",children:[Z,n.jsx(Jb,{userTokens:M,assistantTokens:P,otherTokens:O})]}),e[44]=P,e[45]=O,e[46]=M,e[47]=g):g=e[47],_=G.length>0&&n.jsxs("div",{className:"flex flex-col gap-3",children:[n.jsx("span",{className:"text-xs text-muted-foreground",children:"Raw messages"}),n.jsx("div",{className:"flex flex-col gap-1",children:G.map(X=>{const ie=X.metadata?.created_at,re=o?.id===X.id;return n.jsxs("div",{className:"rounded-md border border-border/50 overflow-hidden",children:[n.jsxs("button",{type:"button",onClick:()=>a(re?null:X),className:"flex items-center justify-between gap-2 px-3 py-2 text-xs hover:bg-accent/50 w-full text-left cursor-pointer",children:[n.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[n.jsx("span",{className:J("shrink-0 font-medium",X.role==="user"?"text-chart-1":"text-chart-2"),children:X.role}),n.jsx("span",{className:"text-muted-foreground",children:"•"}),n.jsx("span",{className:"truncate text-muted-foreground font-mono",children:X.id})]}),ie&&n.jsx("span",{className:"shrink-0 text-muted-foreground tabular-nums",children:new Date(ie).toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"})})]}),re&&n.jsx("pre",{className:"text-xs font-mono bg-muted px-3 py-2 overflow-auto whitespace-pre-wrap break-all border-t border-border/50 max-h-64",children:JSON.stringify(X,null,2)})]},X.id)})})]})}e[0]=i,e[1]=r,e[2]=l,e[3]=s,e[4]=o?.id,e[5]=u,e[6]=h?.title,e[7]=d,e[8]=c,e[9]=f,e[10]=m,e[11]=p,e[12]=g,e[13]=_,e[14]=v,e[15]=x,e[16]=b}else f=e[9],m=e[10],p=e[11],g=e[12],_=e[13],v=e[14],x=e[15],b=e[16];if(b!==Symbol.for("react.early_return_sentinel"))return b;let y;e[48]!==f||e[49]!==m||e[50]!==p||e[51]!==g||e[52]!==_?(y=n.jsxs("div",{className:f,children:[m,p,g,_]}),e[48]=f,e[49]=m,e[50]=p,e[51]=g,e[52]=_,e[53]=y):y=e[53];let C;return e[54]!==v||e[55]!==x||e[56]!==y?(C=n.jsxs("div",{className:v,children:[x,y]}),e[54]=v,e[55]=x,e[56]=y,e[57]=C):C=e[57],C}function e0(t,e){return n.jsx(Qb,{part:t},e)}function t0(t){return(t.parts??[]).filter(s0)}function s0(t){return t.type==="tool-subtask"}function i0(t){return t.role!=="system"}function n0(t,e){const s=e.metadata?.usage;return t+(s?.outputTokens??0)}function r0(t){return t.role==="assistant"}function o0(t,e){const s=e.metadata?.usage;return t+(s?.inputTokens??0)}function a0(t){return t.role==="user"}function l0(t){return t.role==="assistant"&&t.metadata?.usage}const ed=["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"],td=["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 c0(){const t=ed[Math.floor(Math.random()*ed.length)],e=td[Math.floor(Math.random()*td.length)];return`deco/${t}-${e}`}function d0(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 h0(t){const e=B.c(25),{orgId:s,userId:i,connectionId:r,vmMap:o,owner:a,repo:l,enabled:c}=t,d=c===void 0?!0:c,u=r??null;let h;e[0]!==s||e[1]!==u?(h={connectionId:u,orgId:s},e[0]=s,e[1]=u,e[2]=h):h=e[2];const f=Be(h);let m;e[3]!==a||e[4]!==l?(m={owner:a,repo:l},e[3]=a,e[4]=l,e[5]=m):m=e[5];const p=d&&!!r&&!!a&&!!l;let g;e[6]!==f||e[7]!==m||e[8]!==p?(g={client:f,toolName:"list_branches",toolArguments:m,enabled:p,staleTime:3e4,select:p0},e[6]=f,e[7]=m,e[8]=p,e[9]=g):g=e[9];const{data:_,isLoading:v,isError:x}=ki(g);let b,y;e[10]!==i||e[11]!==o?(y=new Set(Object.keys(o?.[i]??{})),b=[...y].sort().map(m0),e[10]=i,e[11]=o,e[12]=b,e[13]=y):(b=e[12],y=e[13]);const C=b;let k;if(e[14]!==_||e[15]!==y){const I=Array.isArray(_)?_:_?.branches??[];let T;e[17]!==y?(T=R=>!y.has(R.name),e[17]=y,e[18]=T):T=e[18],k=I.filter(f0).filter(T).map(u0),e[14]=_,e[15]=y,e[16]=k}else k=e[16];const w=k,V=Array.isArray(_)?null:_?.default_branch??null;let j;return e[19]!==V||e[20]!==x||e[21]!==v||e[22]!==w||e[23]!==C?(j={yours:C,others:w,defaultBase:V,isLoading:v,isError:x},e[19]=V,e[20]=x,e[21]=v,e[22]=w,e[23]=C,e[24]=j):j=e[24],j}function u0(t){return{name:t.name,source:"other",author:typeof t.commit?.author=="string"?t.commit.author:t.commit?.author?.login??null}}function f0(t){return typeof t.name=="string"}function m0(t){return{name:t,source:"yours"}}function p0(t){return d0(t)}function g0(t){const e=B.c(41),{orgId:s,userId:i,connectionId:r,owner:o,repo:a,vmMap:l,value:c,onChange:d}=t,[u,h]=S.useState(!1);let f;e[0]!==r||e[1]!==u||e[2]!==s||e[3]!==o||e[4]!==a||e[5]!==i||e[6]!==l?(f={orgId:s,userId:i,connectionId:r,vmMap:l,owner:o,repo:a,enabled:u},e[0]=r,e[1]=u,e[2]=s,e[3]=o,e[4]=a,e[5]=i,e[6]=l,e[7]=f):f=e[7];const{yours:m,others:p,isLoading:g,isError:_}=h0(f);let v;e[8]!==d?(v=E=>{d(E),h(!1)},e[8]=d,e[9]=v):v=e[9];const x=v,b=c??"Select branch…";let y;e[10]===Symbol.for("react.memo_cache_sentinel")?(y=n.jsx(yn,{className:"h-3.5 w-3.5"}),e[10]=y):y=e[10];let C;e[11]!==b?(C=n.jsx(li,{asChild:!0,children:n.jsxs(ae,{variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 font-mono text-xs",children:[y,n.jsx("span",{className:"max-w-[200px] truncate",children:b})]})}),e[11]=b,e[12]=C):C=e[12];let k;e[13]===Symbol.for("react.memo_cache_sentinel")?(k=n.jsx(v_,{placeholder:"Search branches…"}),e[13]=k):k=e[13];let w;e[14]!==x?(w=n.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:[k,n.jsx(ae,{variant:"outline",size:"sm",className:"h-7 shrink-0",onClick:()=>x(c0()),children:"New"})]}),e[14]=x,e[15]=w):w=e[15];let V;e[16]!==_?(V=_&&n.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[16]=_,e[17]=V):V=e[17];let j;e[18]!==_||e[19]!==g||e[20]!==p.length||e[21]!==m.length?(j=!_&&!g&&m.length===0&&p.length===0&&n.jsx(__,{children:"No branches found."}),e[18]=_,e[19]=g,e[20]=p.length,e[21]=m.length,e[22]=j):j=e[22];let I;e[23]!==x||e[24]!==m?(I=m.length>0&&n.jsx(jc,{heading:"Your branches",children:m.map(E=>n.jsxs(Nc,{value:E.name,onSelect:()=>x(E.name),children:[n.jsx(yn,{className:"mr-2 h-4 w-4"}),n.jsx("span",{className:"flex-1 truncate",children:E.name})]},E.name))}),e[23]=x,e[24]=m,e[25]=I):I=e[25];let T;e[26]!==p||e[27]!==x?(T=p.length>0&&n.jsxs(n.Fragment,{children:[n.jsx(x_,{}),n.jsx(jc,{heading:"Other branches in repo",children:p.map(E=>n.jsxs(Nc,{value:E.name,onSelect:()=>x(E.name),children:[n.jsx(yn,{className:"mr-2 h-4 w-4"}),n.jsx("span",{className:"flex-1 truncate",children:E.name}),E.author&&n.jsxs("span",{className:"text-xs text-muted-foreground",children:["@",E.author]})]},E.name))})]}),e[26]=p,e[27]=x,e[28]=T):T=e[28];let R;e[29]!==T||e[30]!==V||e[31]!==j||e[32]!==I?(R=n.jsxs(b_,{children:[V,j,I,T]}),e[29]=T,e[30]=V,e[31]=j,e[32]=I,e[33]=R):R=e[33];let N;e[34]!==R||e[35]!==w?(N=n.jsx(ci,{className:"w-[min(420px,calc(100vw-2rem))] p-0",align:"start",children:n.jsxs(y_,{children:[w,R]})}),e[34]=R,e[35]=w,e[36]=N):N=e[36];let A;return e[37]!==u||e[38]!==N||e[39]!==C?(A=n.jsxs(di,{open:u,onOpenChange:h,children:[C,N]}),e[37]=u,e[38]=N,e[39]=C,e[40]=A):A=e[40],A}const _0=["radial-gradient(ellipse 25% 220% at -5% 120%, rgba(165,149,255,0.35) 0%, transparent 100%)","radial-gradient(ellipse 25% 220% at 105% -20%, rgba(208,236,26,0.32) 0%, transparent 100%)"].join(", "),x0="/decotexture.svg";function sd(t){const e=B.c(7),{onClick:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={backgroundImage:_0},e[0]=i):i=e[0];let r,o;e[1]===Symbol.for("react.memo_cache_sentinel")?(r=n.jsx("div",{className:"relative shrink-0 p-1.5 bg-[var(--brand-green-light)] rounded-lg border border-border",children:n.jsx(Ls,{icon:"/logos/deco%20logo.svg",name:"deco.cx",size:"xs",className:"border-0 rounded-none bg-transparent"})}),o=n.jsx("p",{className:"flex-1 relative text-sm font-medium text-foreground leading-none whitespace-nowrap",children:"Import your deco.cx site"}),e[1]=r,e[2]=o):(r=e[1],o=e[2]);let a;e[3]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx("img",{src:x0,alt:"","aria-hidden":!0,className:"absolute pointer-events-none",style:{width:"274.5px",height:"272.25px",left:"calc(50% + 145.5px)",top:"calc(50% + 40px)",transform:"translate(-50%, -50%)"}}),e[3]=a):a=e[3];let l;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=n.jsx("div",{className:"relative bg-background flex items-center justify-center size-8 rounded-md shrink-0",children:n.jsx(ho,{size:16,className:"text-foreground transition-transform group-hover:translate-x-0.5"})}),e[4]=l):l=e[4];let c;return e[5]!==s?(c=n.jsxs("button",{type:"button",onClick:s,className:"w-full relative flex items-center gap-4 px-4 py-4 rounded-lg border border-border bg-background overflow-hidden transition-colors text-left cursor-pointer group",style:i,children:[r,o,a,l]}),e[5]=s,e[6]=c):c=e[6],c}function v0(){const t=B.c(5),{data:e}=St.useSession();let s;t[0]!==e?.user?.email?(s=ct.decoProfile(e?.user?.email),t[0]=e?.user?.email,t[1]=s):s=t[1];const i=!!e?.user?.email;let r;t[2]!==s||t[3]!==i?(r={queryKey:s,queryFn:b0,enabled:i,staleTime:3e5},t[2]=s,t[3]=i,t[4]=r):r=t[4];const{data:o}=Ki(r);return o?.isDecoUser??!1}async function b0(){const t=await fetch("/api/deco-sites/profile");return t.ok?t.json():{isDecoUser:!1}}function y0(t){const e=B.c(56),{onOpenContextPanel:s}=t,{data:i}=St.useSession(),[r,o]=S.useState(!1),a=v0(),l=Ps(),{hasDecoKey:c,isZeroBalance:d,isInitialFreeCredit:u,balanceDollars:h,hasOnlyDecoProvider:f}=go();let m;e[0]!==i?.user?.name?(m=i?.user?.name?.split(" ")[0]||"there",e[0]=i?.user?.name,e[1]=m):m=e[1];const p=m,g=c&&u&&h!=null,_=c&&d&&f;if(l){let N;e[2]!==h||e[3]!==g?(N=g&&n.jsx("div",{className:"mb-4",children:n.jsx($e.CreditsEyebrow,{balanceDollars:h})}),e[2]=h,e[3]=g,e[4]=N):N=e[4];let A;e[5]!==_?(A=_&&n.jsx("div",{className:"mb-4",children:n.jsx($e.NoCreditsEyebrow,{})}),e[5]=_,e[6]=A):A=e[6];let E;e[7]!==p?(E=n.jsxs("p",{className:"text-3xl font-medium text-foreground text-center max-w-[280px]",children:["What's on your mind, ",p,"?"]}),e[7]=p,e[8]=E):E=e[8];let M;e[9]!==N||e[10]!==A||e[11]!==E?(M=n.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center w-full",children:[N,A,E]}),e[9]=N,e[10]=A,e[11]=E,e[12]=M):M=e[12];let L;e[13]===Symbol.for("react.memo_cache_sentinel")?(L=n.jsx(Qc,{}),e[13]=L):L=e[13];let D;e[14]!==s?(D=n.jsxs("div",{className:"w-full flex flex-col gap-4 pb-4",children:[L,n.jsx($e.Input,{onOpenContextPanel:s,showConnectionsBanner:!0})]}),e[14]=s,e[15]=D):D=e[15];let P;e[16]!==a?(P=a&&n.jsx("div",{className:"w-full",children:n.jsx(sd,{onClick:()=>o(!0)})}),e[16]=a,e[17]=P):P=e[17];let O;e[18]!==M||e[19]!==D||e[20]!==P?(O=n.jsxs("div",{className:"flex-1 relative flex flex-col items-center px-4",children:[M,D,P]}),e[18]=M,e[19]=D,e[20]=P,e[21]=O):O=e[21];let z;e[22]!==r?(z=n.jsx(Fr,{open:r,onOpenChange:o}),e[22]=r,e[23]=z):z=e[23];let $;return e[24]!==z||e[25]!==O?($=n.jsxs(n.Fragment,{children:[O,z]}),e[24]=z,e[25]=O,e[26]=$):$=e[26],$}let v;e[27]!==h||e[28]!==g?(v=g&&n.jsx("div",{className:"mb-4",children:n.jsx($e.CreditsEyebrow,{balanceDollars:h})}),e[27]=h,e[28]=g,e[29]=v):v=e[29];let x;e[30]!==_?(x=_&&n.jsx("div",{className:"mb-4",children:n.jsx($e.NoCreditsEyebrow,{})}),e[30]=_,e[31]=x):x=e[31];let b;e[32]!==p?(b=n.jsxs("p",{className:"text-3xl font-medium text-foreground",children:["What's on your mind, ",p,"?"]}),e[32]=p,e[33]=b):b=e[33];let y;e[34]!==v||e[35]!==x||e[36]!==b?(y=n.jsxs("div",{className:"text-center mb-10",children:[v,x,b]}),e[34]=v,e[35]=x,e[36]=b,e[37]=y):y=e[37];let C;e[38]!==s?(C=n.jsx("div",{className:"w-full",children:n.jsx($e.Input,{onOpenContextPanel:s,showConnectionsBanner:!0})}),e[38]=s,e[39]=C):C=e[39];let k;e[40]!==y||e[41]!==C?(k=n.jsxs("div",{className:"flex flex-col items-center w-full max-w-[672px]",children:[y,C]}),e[40]=y,e[41]=C,e[42]=k):k=e[42];let w;e[43]===Symbol.for("react.memo_cache_sentinel")?(w=n.jsx("div",{className:"w-full mt-10 mx-auto",children:n.jsx(Qc,{})}),e[43]=w):w=e[43];let V;e[44]!==k?(V=n.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center w-full",children:[k,w]}),e[44]=k,e[45]=V):V=e[45];let j;e[46]!==a?(j=a&&n.jsx("div",{className:"absolute bottom-6 left-0 right-0 px-10",children:n.jsx("div",{className:"w-full max-w-[500px] mx-auto",children:n.jsx(sd,{onClick:()=>o(!0)})})}),e[46]=a,e[47]=j):j=e[47];let I;e[48]!==j||e[49]!==V?(I=n.jsxs("div",{className:"flex-1 relative flex flex-col items-center px-10",children:[V,j]}),e[48]=j,e[49]=V,e[50]=I):I=e[50];let T;e[51]!==r?(T=n.jsx(Fr,{open:r,onOpenChange:o}),e[51]=r,e[52]=T):T=e[52];let R;return e[53]!==I||e[54]!==T?(R=n.jsxs(n.Fragment,{children:[I,T]}),e[53]=I,e[54]=T,e[55]=R):R=e[55],R}function S0(){const t=B.c(26),{org:e}=xe(),{selectedVirtualMcp:s}=ai(),{data:i}=St.useSession(),{currentBranch:r,setCurrentTaskBranch:o}=es();let a;t[0]!==e.id?(a=co(e.id),t[0]=e.id,t[1]=a):a=t[1];const c=s??a,d=is(c.id),u=i?.user?.id??"",h=d?.metadata?.githubRepo??null,f=!!h?.connectionId&&!!u;let m;t[2]===Symbol.for("react.memo_cache_sentinel")?(m=n.jsx(po,{size:32}),t[2]=m):m=t[2];let p;t[3]!==c.icon||t[4]!==c.title?(p=n.jsx(Ls,{icon:c.icon,name:c.title,size:"lg",fallbackIcon:m,className:"size-10 min-w-10 md:size-[60px]! md:min-w-[60px] rounded-xl md:rounded-[18px]!"}),t[3]=c.icon,t[4]=c.title,t[5]=p):p=t[5];let g;t[6]!==c.title?(g=n.jsx("h3",{className:"text-base md:text-xl font-medium text-foreground",children:c.title}),t[6]=c.title,t[7]=g):g=t[7];const _=c.description??"Ask anything about configuring model providers or using MCP Mesh.";let v;t[8]!==_?(v=n.jsx("div",{className:"text-muted-foreground text-center text-base max-w-md line-clamp-2",children:_}),t[8]=_,t[9]=v):v=t[9];let x;t[10]!==r||t[11]!==d?.metadata?.vmMap||t[12]!==h||t[13]!==e.id||t[14]!==o||t[15]!==f||t[16]!==u?(x=f&&n.jsx("div",{className:"mt-2",children:n.jsx(g0,{orgId:e.id,userId:u,connectionId:h.connectionId,owner:h.owner,repo:h.name,vmMap:d?.metadata?.vmMap,value:r??void 0,onChange:o})}),t[10]=r,t[11]=d?.metadata?.vmMap,t[12]=h,t[13]=e.id,t[14]=o,t[15]=f,t[16]=u,t[17]=x):x=t[17];let b;t[18]!==p||t[19]!==g||t[20]!==v||t[21]!==x?(b=n.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 md:gap-4 text-center",children:[p,g,v,x]}),t[18]=p,t[19]=g,t[20]=v,t[21]=x,t[22]=b):b=t[22];let y;t[23]===Symbol.for("react.memo_cache_sentinel")?(y=n.jsx("div",{className:"w-full max-w-3xl mx-auto",children:n.jsx($e.IceBreakers,{})}),t[23]=y):y=t[23];let C;return t[24]!==b?(C=n.jsxs("div",{className:"h-full w-full flex flex-col items-center justify-center gap-6 px-4",children:[b,y]}),t[24]=b,t[25]=C):C=t[25],C}function w0(t){const e=B.c(27),{variant:s}=t,{org:i}=xe(),r=jl(),{isChatEmpty:o}=Yi(),[a,l]=S.useState("chat"),c=go();if(r.length===0){let C;return e[0]===Symbol.for("react.memo_cache_sentinel")?(C=n.jsx($e,{className:"animate-in fade-in-0 duration-200",children:n.jsx($e.Main,{className:"flex flex-col items-center",children:n.jsx($e.EmptyState,{children:n.jsx($e.NoAiProviderEmptyState,{})})})}),e[0]=C):C=e[0],C}let d;e[1]!==c.hasDecoKey||e[2]!==c.hasOnlyDecoProvider||e[3]!==c.isLoading||e[4]!==c.isZeroBalance||e[5]!==o||e[6]!==i?(d=c.hasDecoKey&&c.isZeroBalance&&c.hasOnlyDecoProvider&&!c.isLoading&&o&&!Xv(i.id),e[1]=c.hasDecoKey,e[2]=c.hasOnlyDecoProvider,e[3]=c.isLoading,e[4]=c.isZeroBalance,e[5]=o,e[6]=i,e[7]=d):d=e[7];const u=d;let h;e[8]!==u?(h=u&&n.jsx($e.CreditsEmptyState,{}),e[8]=u,e[9]=h):h=e[9];const f=a!=="chat"?"opacity-0 pointer-events-none":"opacity-100";let m;e[10]!==f?(m=J("absolute inset-0 flex flex-col transition-opacity duration-100 ease-out",f),e[10]=f,e[11]=m):m=e[11];let p;e[12]!==o||e[13]!==s?(p=o?s==="home"?n.jsx(y0,{onOpenContextPanel:()=>l("context")}):n.jsxs(n.Fragment,{children:[n.jsx($e.Main,{children:n.jsx(S0,{})}),n.jsx($e.Footer,{children:n.jsx($e.Input,{onOpenContextPanel:()=>l("context")})})]}):n.jsxs(n.Fragment,{children:[n.jsx($e.Main,{children:n.jsx($e.Messages,{})}),n.jsx($e.Footer,{children:n.jsx($e.Input,{onOpenContextPanel:()=>l("context")})})]}),e[12]=o,e[13]=s,e[14]=p):p=e[14];let g;e[15]!==m||e[16]!==p?(g=n.jsx("div",{className:m,children:p}),e[15]=m,e[16]=p,e[17]=g):g=e[17];const _=a==="context"?"opacity-100":"opacity-0 pointer-events-none";let v;e[18]!==_?(v=J("absolute inset-0 flex flex-col transition-opacity duration-100 ease-out",_),e[18]=_,e[19]=v):v=e[19];let x;e[20]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsx(Zb,{back:!0,onClose:()=>l("chat")}),e[20]=x):x=e[20];let b;e[21]!==v?(b=n.jsx("div",{className:v,children:x}),e[21]=v,e[22]=b):b=e[22];let y;return e[23]!==b||e[24]!==h||e[25]!==g?(y=n.jsxs($e,{className:"relative overflow-hidden animate-in fade-in-0 duration-200",children:[h,g,b]}),e[23]=b,e[24]=h,e[25]=g,e[26]=y):y=e[26],y}function of(t){const e=B.c(4),{variant:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx($e.Skeleton,{}),e[0]=i):i=e[0];let r;e[1]===Symbol.for("react.memo_cache_sentinel")?(r=n.jsx($e.Skeleton,{}),e[1]=r):r=e[1];let o;return e[2]!==s?(o=n.jsx(As,{fallback:i,children:n.jsx(S.Suspense,{fallback:r,children:n.jsx(w0,{variant:s})})}),e[2]=s,e[3]=o):o=e[3],o}function V0(){const t=B.c(6),{org:e,locator:s}=xe(),i=Mt();let r;t[0]!==s||t[1]!==i?(r=()=>{i.invalidateQueries({queryKey:ct.tasksPrefix(s)})},t[0]=s,t[1]=i,t[2]=r):r=t[2];let o;t[3]!==e.id||t[4]!==r?(o={orgId:e.id,onTaskStatus:r},t[3]=e.id,t[4]=r,t[5]=o):o=t[5],E_(o)}function C0(t){const e=B.c(8),{virtualMcpId:s,size:i,showAutomationBadge:r}=t,o=i===void 0?"sm":i;let a;e[0]!==o||e[1]!==s?(a=s?n.jsx(k0,{virtualMcpId:s,size:o}):n.jsx(gs,{icon:null,name:"?",size:o}),e[0]=o,e[1]=s,e[2]=a):a=e[2];let l;e[3]!==r?(l=r&&n.jsx("span",{"aria-label":"Automation-triggered",className:"absolute -bottom-0.5 -right-0.5 flex size-4 items-center justify-center rounded-full bg-blue-500 border border-blue-600 text-white",children:n.jsx(Hi,{size:10,className:"text-white"})}),e[3]=r,e[4]=l):l=e[4];let c;return e[5]!==a||e[6]!==l?(c=n.jsxs("div",{className:"relative shrink-0",children:[a,l]}),e[5]=a,e[6]=l,e[7]=c):c=e[7],c}function k0(t){const e=B.c(6),{virtualMcpId:s,size:i}=t,r=is(s);if(!r){let l;return e[0]!==i?(l=n.jsx(gs,{icon:null,name:"?",size:i}),e[0]=i,e[1]=l):l=e[1],l}const o=r.icon??null;let a;return e[2]!==r.title||e[3]!==i||e[4]!==o?(a=n.jsx(gs,{icon:o,name:r.title,size:i}),e[2]=r.title,e[3]=i,e[4]=o,e[5]=a):a=e[5],a}function Fs(t){const e=t?.metadata?.githubRepo;return e?.connectionId&&t?.connections?.some(i=>i.connection_id===e.connectionId)?e:null}function j0(t){const e=B.c(42),{task:s,isActive:i,onClick:r,onArchive:o,showAutomationBadge:a}=t,l=Qp(s.status),c=l.icon,d=is(s.virtual_mcp_id);let u;e[0]!==d?(u=Fs(d),e[0]=d,e[1]=u):u=e[1];const h=u,f="button",m=0;let p;e[2]!==r?(p=O=>{O.target===O.currentTarget&&(O.key==="Enter"||O.key===" ")&&(O.preventDefault(),r())},e[2]=r,e[3]=p):p=e[3];const g=i?"bg-accent":"hover:bg-accent/60";let _;e[4]!==g?(_=J("group/row flex items-center gap-3 px-2 py-1.5 rounded-md cursor-pointer transition-colors",g),e[4]=g,e[5]=_):_=e[5];let v;e[6]!==a||e[7]!==s.virtual_mcp_id?(v=n.jsx(C0,{virtualMcpId:s.virtual_mcp_id,size:"xs",showAutomationBadge:a}),e[6]=a,e[7]=s.virtual_mcp_id,e[8]=v):v=e[8];const x=s.title||"Untitled task";let b;e[9]!==x?(b=n.jsx("div",{className:"text-sm text-foreground truncate",children:x}),e[9]=x,e[10]=b):b=e[10];let y;e[11]!==h||e[12]!==s.branch||e[13]!==s.updated_at?(y=s.updated_at&&n.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground min-w-0",children:[s.branch?n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"truncate font-mono",children:s.branch}),n.jsx("span",{className:"shrink-0",children:"·"})]}):h?n.jsxs(n.Fragment,{children:[n.jsxs("span",{className:"truncate",children:[h.owner,"/",h.name]}),n.jsx("span",{className:"shrink-0",children:"·"})]}):null,n.jsx("span",{className:"shrink-0",children:Zp(new Date(s.updated_at))})]}),e[11]=h,e[12]=s.branch,e[13]=s.updated_at,e[14]=y):y=e[14];let C;e[15]!==y||e[16]!==b?(C=n.jsxs("div",{className:"flex-1 min-w-0",children:[b,y]}),e[15]=y,e[16]=b,e[17]=C):C=e[17];const k="shrink-0 grid [grid-template-areas:'slot'] items-center justify-items-center",w="[grid-area:slot] flex size-7 items-center justify-center group-hover/row:invisible",V=l.label,j=14,I=J(l.iconClassName,s.status==="in_progress"&&"animate-spin");let T;e[18]!==c||e[19]!==I?(T=n.jsx(c,{size:j,className:I}),e[18]=c,e[19]=I,e[20]=T):T=e[20];let R;e[21]!==l||e[22]!==T?(R=n.jsx("span",{className:w,"aria-label":V,children:T}),e[21]=l,e[22]=T,e[23]=R):R=e[23];let N;e[24]!==o?(N=O=>{O.stopPropagation(),o()},e[24]=o,e[25]=N):N=e[25];let A;e[26]===Symbol.for("react.memo_cache_sentinel")?(A=n.jsx(jg,{size:14}),e[26]=A):A=e[26];let E;e[27]!==N?(E=n.jsx(st,{asChild:!0,children:n.jsx("button",{type:"button","aria-label":"Archive task",onClick:N,className:"[grid-area:slot] invisible group-hover/row:visible flex size-7 items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-muted",children:A})}),e[27]=N,e[28]=E):E=e[28];let M;e[29]===Symbol.for("react.memo_cache_sentinel")?(M=n.jsx(it,{side:"right",children:"Archive"}),e[29]=M):M=e[29];let L;e[30]!==E?(L=n.jsxs(nt,{children:[E,M]}),e[30]=E,e[31]=L):L=e[31];let D;e[32]!==R||e[33]!==L?(D=n.jsxs("div",{className:k,children:[R,L]}),e[32]=R,e[33]=L,e[34]=D):D=e[34];let P;return e[35]!==r||e[36]!==C||e[37]!==D||e[38]!==p||e[39]!==_||e[40]!==v?(P=n.jsxs("div",{role:f,tabIndex:m,onClick:r,onKeyDown:p,className:_,children:[v,C,D]}),e[35]=r,e[36]=C,e[37]=D,e[38]=p,e[39]=_,e[40]=v,e[41]=P):P=e[41],P}const af={all:"All tasks",manual:"Chats",automation:"Automation"},lf={all:"All members",mine:"Mine only"};function N0(t){const e=B.c(57),{title:s,tasks:i,activeTaskId:r,onSelect:o,onArchive:a,onNew:l,showNewButton:c,showAutomationBadge:d,emptyLabel:u,currentUserId:h}=t,[f,m]=S.useState("all"),[p,g]=S.useState("mine");let _;e[0]!==h||e[1]!==p||e[2]!==i?(_=p==="mine"&&h?i.filter(G=>G.created_by===h):i,e[0]=h,e[1]=p,e[2]=i,e[3]=_):_=e[3];const v=_;let x;e[4]!==f||e[5]!==v?(x=f==="automation"?v.filter(R0):f==="manual"?v.filter(I0):v,e[4]=f,e[5]=v,e[6]=x):x=e[6];const b=x;let y;e[7]!==s?(y=n.jsx("span",{children:s}),e[7]=s,e[8]=y):y=e[8];let C;e[9]!==p?(C=n.jsx(Is,{asChild:!0,children:n.jsx("button",{type:"button","aria-label":"Filter by member",className:"flex size-8 items-center justify-center rounded-md hover:bg-muted hover:text-foreground",children:p==="mine"?n.jsx(Ng,{size:16}):n.jsx(po,{size:16})})}),e[9]=p,e[10]=C):C=e[10];let k;e[11]!==p?(k=G=>{const H=G;H!==p&&ne("tasks_panel_member_filter_changed",{to_value:H}),g(H)},e[11]=p,e[12]=k):k=e[12];let w;e[13]===Symbol.for("react.memo_cache_sentinel")?(w=Object.keys(lf),e[13]=w):w=e[13];let V;e[14]===Symbol.for("react.memo_cache_sentinel")?(V=w.map(E0),e[14]=V):V=e[14];let j;e[15]!==p||e[16]!==k?(j=n.jsx(Rs,{align:"end",children:n.jsx(_c,{value:p,onValueChange:k,children:V})}),e[15]=p,e[16]=k,e[17]=j):j=e[17];let I;e[18]!==C||e[19]!==j?(I=n.jsxs(Es,{children:[C,j]}),e[18]=C,e[19]=j,e[20]=I):I=e[20];const T=f!=="all"&&"text-purple-500";let R;e[21]!==T?(R=J("flex size-8 items-center justify-center rounded-md hover:bg-muted hover:text-foreground",T),e[21]=T,e[22]=R):R=e[22];let N;e[23]===Symbol.for("react.memo_cache_sentinel")?(N=n.jsx(Xg,{size:16}),e[23]=N):N=e[23];let A;e[24]!==R?(A=n.jsx(Is,{asChild:!0,children:n.jsx("button",{type:"button","aria-label":"Filter tasks",className:R,children:N})}),e[24]=R,e[25]=A):A=e[25];let E;e[26]!==f?(E=G=>{const H=G;H!==f&&ne("tasks_panel_filter_changed",{to_value:H}),m(H)},e[26]=f,e[27]=E):E=e[27];let M;e[28]===Symbol.for("react.memo_cache_sentinel")?(M=Object.keys(af),e[28]=M):M=e[28];let L;e[29]===Symbol.for("react.memo_cache_sentinel")?(L=M.map(A0),e[29]=L):L=e[29];let D;e[30]!==f||e[31]!==E?(D=n.jsx(Rs,{align:"end",children:n.jsx(_c,{value:f,onValueChange:E,children:L})}),e[30]=f,e[31]=E,e[32]=D):D=e[32];let P;e[33]!==A||e[34]!==D?(P=n.jsxs(Es,{children:[A,D]}),e[33]=A,e[34]=D,e[35]=P):P=e[35];let O;e[36]!==l||e[37]!==c||e[38]!==s?(O=c&&l&&n.jsx("button",{type:"button",onClick:()=>{ne("tasks_panel_new_clicked"),l()},"aria-label":`New ${s.toLowerCase()}`,className:"flex size-8 items-center justify-center rounded-md hover:bg-muted hover:text-foreground",children:n.jsx(Sl,{size:16})}),e[36]=l,e[37]=c,e[38]=s,e[39]=O):O=e[39];let z;e[40]!==P||e[41]!==O||e[42]!==I?(z=n.jsxs("div",{className:"flex items-center gap-0.5",children:[I,P,O]}),e[40]=P,e[41]=O,e[42]=I,e[43]=z):z=e[43];let $;e[44]!==z||e[45]!==y?($=n.jsxs("div",{className:"pl-2 pr-1.5 h-7 flex items-center justify-between text-xs font-medium text-muted-foreground mb-1",children:[y,z]}),e[44]=z,e[45]=y,e[46]=$):$=e[46];let q;e[47]!==r||e[48]!==u||e[49]!==a||e[50]!==o||e[51]!==d||e[52]!==b?(q=b.length===0&&u?n.jsx("div",{className:"px-2 py-1.5 text-xs text-muted-foreground/70",children:u}):b.map(G=>n.jsx(j0,{task:G,isActive:r===G.id,onClick:()=>{r!==G.id&&ne("tasks_panel_task_clicked",{thread_id:G.id,virtual_mcp_id:G.virtual_mcp_id??null,from_automation:!!G.fromAutomation}),o(G)},onArchive:()=>{ne("tasks_panel_task_archived",{thread_id:G.id,virtual_mcp_id:G.virtual_mcp_id??null}),a(G)},showAutomationBadge:d||G.fromAutomation},G.id)),e[47]=r,e[48]=u,e[49]=a,e[50]=o,e[51]=d,e[52]=b,e[53]=q):q=e[53];let F;return e[54]!==$||e[55]!==q?(F=n.jsxs("div",{className:"flex flex-col gap-0.5 mt-1",children:[$,q]}),e[54]=$,e[55]=q,e[56]=F):F=e[56],F}function A0(t){return n.jsx(Gh,{value:t,children:af[t]},t)}function E0(t){return n.jsx(Gh,{value:t,children:lf[t]},t)}function I0(t){return!t.fromAutomation}function R0(t){return t.fromAutomation}function T0(){const t=B.c(22);V0();const{data:e}=St.useSession(),s=e?.user?.id;let i;t[0]===Symbol.for("react.memo_cache_sentinel")?(i={owner:"me",status:"open",hasTrigger:!1},t[0]=i):i=t[0];const{tasks:r}=da(i);let o;t[1]===Symbol.for("react.memo_cache_sentinel")?(o={owner:"all",status:"open",hasTrigger:!0},t[1]=o):o=t[1];const{tasks:a}=da(o),{setTaskId:l,createNewTask:c}=Wn();let d;t[2]===Symbol.for("react.memo_cache_sentinel")?(d={strict:!1},t[2]=d):d=t[2];const u=Hn(d),{locator:h,org:f}=xe(),m=Mt();let p;t[3]!==f.id?(p={connectionId:Pt,orgId:f.id},t[3]=f.id,t[4]=p):p=t[4];const g=Be(p),_=u.taskId??null;let v;t[5]!==a||t[6]!==r?(v=[...r,...a.map(M0)].sort(D0),t[5]=a,t[6]=r,t[7]=v):v=t[7];const x=v;let b;t[8]!==g||t[9]!==h||t[10]!==m?(b=async w=>{try{await Fp(g,w.id,{hidden:!0}),m.invalidateQueries({queryKey:ct.tasksPrefix(h)})}catch(V){const I=V;ue.error(`Failed to archive task: ${I.message}`)}},t[8]=g,t[9]=h,t[10]=m,t[11]=b):b=t[11];const y=b;if(x.length===0){let w;return t[12]===Symbol.for("react.memo_cache_sentinel")?(w=n.jsx("div",{className:"h-full flex items-center justify-center p-4",children:n.jsx(Ui,{image:n.jsx(Ag,{size:48,className:"text-muted-foreground"}),title:"No tasks yet",description:"Start a conversation to create your first task."})}),t[12]=w):w=t[12],w}let C;t[13]!==l?(C=w=>l(w.id,w.virtual_mcp_id),t[13]=l,t[14]=C):C=t[14];let k;return t[15]!==_||t[16]!==x||t[17]!==c||t[18]!==s||t[19]!==y||t[20]!==C?(k=n.jsx("div",{className:"flex flex-col h-full min-h-0 overflow-y-auto p-2 gap-3",children:n.jsx(N0,{title:"Tasks",tasks:x,activeTaskId:_,onSelect:C,onArchive:y,onNew:c,showNewButton:!0,currentUserId:s})}),t[15]=_,t[16]=x,t[17]=c,t[18]=s,t[19]=y,t[20]=C,t[21]=k):k=t[21],k}function D0(t,e){return(e.updated_at??"").localeCompare(t.updated_at??"")}function M0(t){return{...t,fromAutomation:!0}}function P0(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx("div",{className:"flex flex-col h-full p-2 gap-1.5",children:Array.from({length:6}).map(L0)}),t[0]=e):e=t[0],e}function L0(t,e){return n.jsx("div",{className:"h-10 rounded-md bg-muted/60 animate-pulse"},e)}function cf(){const t=B.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx($e.Skeleton,{}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx(As,{fallback:e,children:n.jsx(S.Suspense,{fallback:n.jsx(P0,{}),children:n.jsx(T0,{})})}),t[1]=s):s=t[1],s}function df(){const t=B.c(77),{org:e}=xe(),s=Ge(),i=Rh(),{setTasksOpen:r,openTab:o}=Wn(),a=e.slug,l=xe().project;let c;t[0]===Symbol.for("react.memo_cache_sentinel")?(c={strict:!1},t[0]=c):c=t[0];const d=Hn(c);let u;t[1]===Symbol.for("react.memo_cache_sentinel")?(u={strict:!1},t[1]=u):u=t[1];const h=Si(u),f=i.location.pathname;let m;t[2]!==l.enabledPlugins?(m=l.enabledPlugins??[],t[2]=l.enabledPlugins,t[3]=m):m=t[3];const p=m;let g;t[4]!==l.ui?(g=l.ui?.pinnedViews??[],t[4]=l.ui,t[5]=g):g=t[5];const _=g;let v,x,b,y;if(t[6]!==l.id||t[7]!==p||t[8]!==s||t[9]!==a||t[10]!==d.pluginId||t[11]!==d.taskId||t[12]!==h.virtualmcpid){let H;t[17]!==p?(H=ie=>p.includes(ie.pluginId),t[17]=p,t[18]=H):H=t[18];const U=up.filter(H),Y=h.virtualmcpid??l.id;x=!!h.virtualmcpid;const W=d.taskId??"",K=d.pluginId;let ee;t[19]!==K?(ee=ie=>K===ie,t[19]=K,t[20]=ee):ee=t[20],v=ee;let Z;t[21]!==W||t[22]!==s||t[23]!==a||t[24]!==Y?(Z=ie=>{const re=W||crypto.randomUUID();s({to:"/$org/$taskId/$pluginId",params:{org:a,taskId:re,pluginId:ie},search:de=>({...de,virtualmcpid:Y})})},t[21]=W,t[22]=s,t[23]=a,t[24]=Y,t[25]=Z):Z=t[25],b=Z;let X;t[26]!==v||t[27]!==b?(X=ie=>({key:ie.pluginId,label:ie.label,icon:ie.icon,isActive:v(ie.pluginId),onClick:()=>b(ie.pluginId)}),t[26]=v,t[27]=b,t[28]=X):X=t[28],y=U.map(X),t[6]=l.id,t[7]=p,t[8]=s,t[9]=a,t[10]=d.pluginId,t[11]=d.taskId,t[12]=h.virtualmcpid,t[13]=v,t[14]=x,t[15]=b,t[16]=y}else v=t[13],x=t[14],b=t[15],y=t[16];const C=y;let k;if(t[29]!==p||t[30]!==v||t[31]!==b){let H;t[33]!==p?(H=W=>p.includes(W.pluginId),t[33]=p,t[34]=H):H=t[34];const U=fp.filter(H);let Y;t[35]!==v||t[36]!==b?(Y=W=>({type:"group",group:{id:`${W.pluginId}-${W.id}`,label:W.label,items:W.items.map((K,ee)=>({key:`${W.pluginId}-${W.id}-${ee}`,label:K.label,icon:K.icon,isActive:v(W.pluginId),onClick:()=>b(W.pluginId)})),defaultExpanded:W.defaultExpanded??!0}}),t[35]=v,t[36]=b,t[37]=Y):Y=t[37],k=U.map(Y),t[29]=p,t[30]=v,t[31]=b,t[32]=k}else k=t[32];const w=k;let V;if(t[38]!==o||t[39]!==_){let H;t[41]!==o?(H=U=>{const Y=Kn(U.icon),W=Y.type==="icon"?qn(Y.name):null;return{key:`app-${U.connectionId}-${U.toolName}`,label:U.label||U.toolName,icon:W?n.jsx(W,{size:16,className:"text-muted-foreground"}):Y.type==="url"?n.jsx("img",{src:Y.url,alt:"",className:"size-4 rounded"}):n.jsx(ju,{size:16,className:"text-muted-foreground"}),isActive:!1,onClick:()=>o(ha(U.connectionId,U.toolName))}},t[41]=o,t[42]=H):H=t[42],V=_.map(H),t[38]=o,t[39]=_,t[40]=V}else V=t[40];const j=V;let I;t[43]!==j?(I=j.length>0?{type:"group",group:{id:"apps",label:"Apps",items:j,defaultExpanded:!0}}:null,t[43]=j,t[44]=I):I=t[44];const T=I;let R;t[45]===Symbol.for("react.memo_cache_sentinel")?(R=n.jsx(Eg,{className:"size-4!"}),t[45]=R):R=t[45];const N=f===`/${a}`||f===`/${a}/`;let A;t[46]!==s||t[47]!==a||t[48]!==r?(A=()=>{r(!1),s({to:"/$org",params:{org:a}})},t[46]=s,t[47]=a,t[48]=r,t[49]=A):A=t[49];let E;t[50]!==A||t[51]!==N?(E={key:"home",label:"Home",icon:R,isActive:N,onClick:A},t[50]=A,t[51]=N,t[52]=E):E=t[52];const M=E;let L;t[53]!==p?(L=p.includes(mp),t[53]=p,t[54]=L):L=t[54];const D=L;let P;t[55]===Symbol.for("react.memo_cache_sentinel")?(P=n.jsx(pp,{className:"size-4!"}),t[55]=P):P=t[55];let O;t[56]!==a||t[57]!==f?(O=f.startsWith(`/${a}/settings/workflows`),t[56]=a,t[57]=f,t[58]=O):O=t[58];let z;t[59]!==s||t[60]!==a?(z=()=>s({to:"/$org/settings/workflows",params:{org:a}}),t[59]=s,t[60]=a,t[61]=z):z=t[61];let $;t[62]!==O||t[63]!==z?($={key:"workflows",label:"Workflows",icon:P,isActive:O,onClick:z},t[62]=O,t[63]=z,t[64]=$):$=t[64];const q=$;let F;if(t[65]!==M||t[66]!==x||t[67]!==D||t[68]!==q){const H=[M];x&&D&&H.push(q),F={type:"items",items:H},t[65]=M,t[66]=x,t[67]=D,t[68]=q,t[69]=F}else F=t[69];let G;if(t[70]!==T||t[71]!==w||t[72]!==C||t[73]!==F){if(G=[F],C.length>0){let H;t[75]!==C?(H={type:"items",items:C},t[75]=C,t[76]=H):H=t[76],G.push(H)}w.length>0&&G.push(...w),T&&G.push(T),t[70]=T,t[71]=w,t[72]=C,t[73]=F,t[74]=G}else G=t[74];return G}function hf(t){const e=B.c(3),{children:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx("div",{className:"flex h-6 items-center",children:n.jsx("div",{className:"h-0.5 w-16 rounded-full bg-sidebar-foreground/15"})}),e[0]=i):i=e[0];let r;return e[1]!==s?(r=n.jsxs(Xn,{className:"pt-0 pr-0 pb-2 pl-0 mt-2",children:[i,n.jsx(Jn,{children:n.jsx(vs,{className:"gap-0.5",children:s})})]}),e[1]=s,e[2]=r):r=e[2],r}function O0(){const t=B.c(7),s=Th().logo??Dh,i=typeof s=="string"?s:s.light,r=typeof s=="string"?s:s.dark;let o;t[0]!==i?(o=n.jsx("img",{src:i,alt:"Logo",className:"size-6 object-contain dark:hidden"}),t[0]=i,t[1]=o):o=t[1];let a;t[2]!==r?(a=n.jsx("img",{src:r,alt:"Logo",className:"size-6 object-contain hidden dark:block"}),t[2]=r,t[3]=a):a=t[3];let l;return t[4]!==o||t[5]!==a?(l=n.jsx(Eu,{className:"flex items-center justify-center shrink-0 px-2 pb-0",children:n.jsxs("div",{className:"flex w-full aspect-square items-center justify-center",children:[o,a]})}),t[4]=o,t[5]=a,t[6]=l):l=t[6],l}function uf(t){const e=B.c(15),{item:s}=t,{isMobile:i,setOpenMobile:r}=Qn();let o;e[0]!==i||e[1]!==s||e[2]!==r?(o=()=>{ne("nav_item_clicked",{nav_key:s.key,nav_label:s.label,is_active:!!s.isActive,is_mobile:i}),s.onClick?.(),i&&r(!1)},e[0]=i,e[1]=s,e[2]=r,e[3]=o):o=e[3];const a=o,l=s.key,c=s.isActive&&"z-10";let d;e[4]!==c?(d=J(c),e[4]=c,e[5]=d):d=e[5];let u;e[6]!==a||e[7]!==s.icon||e[8]!==s.isActive||e[9]!==s.label?(u=n.jsx(_s,{onClick:a,isActive:s.isActive,tooltip:s.label,className:"bg-muted/75",children:s.icon}),e[6]=a,e[7]=s.icon,e[8]=s.isActive,e[9]=s.label,e[10]=u):u=e[10];let h;return e[11]!==s.key||e[12]!==d||e[13]!==u?(h=n.jsx(Zt,{className:d,children:u},l),e[11]=s.key,e[12]=d,e[13]=u,e[14]=h):h=e[14],h}function B0(t){const e=B.c(12),{section:s}=t;switch(s.type){case"divider":{let i;return e[0]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx(Nu,{className:"my-2"}),e[0]=i):i=e[0],i}case"spacer":{let i;return e[1]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx("div",{className:"flex-1"}),e[1]=i):i=e[1],i}case"group":{const i=s.group.label,r=s.group.defaultExpanded;let o;e[2]!==s.group.items?(o=s.group.items.map(z0),e[2]=s.group.items,e[3]=o):o=e[3];let a;return e[4]!==s.group.defaultExpanded||e[5]!==s.group.label||e[6]!==o?(a=n.jsx(hf,{label:i,defaultExpanded:r,children:o}),e[4]=s.group.defaultExpanded,e[5]=s.group.label,e[6]=o,e[7]=a):a=e[7],a}case"items":{let i;e[8]!==s.items?(i=s.items.map($0),e[8]=s.items,e[9]=i):i=e[9];let r;return e[10]!==i?(r=n.jsx(Xn,{className:"pt-0 pr-0 pb-0 pl-0",children:n.jsx(Jn,{children:n.jsx(vs,{className:"gap-1.5",children:i})})}),e[10]=i,e[11]=r):r=e[11],r}}}function $0(t){return n.jsx(uf,{item:t},t.key)}function z0(t){return n.jsx(uf,{item:t},t.key)}function F0(t){const e=B.c(14),{sections:s,header:i,footer:r,additionalContent:o,variant:a,contentClassName:l}=t,c=a===void 0?"sidebar":a;let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx(S.Suspense,{fallback:n.jsx("div",{className:"h-10 shrink-0"}),children:n.jsx(O0,{})}),e[0]=d):d=e[0];let u;e[1]!==l?(u=J("flex flex-col flex-1 px-2 py-2 gap-0",l),e[1]=l,e[2]=u):u=e[2];let h;e[3]!==s?(h=s.map(U0),e[3]=s,e[4]=h):h=e[4];let f;e[5]!==o||e[6]!==u||e[7]!==h?(f=n.jsxs(Au,{className:u,children:[h,o]}),e[5]=o,e[6]=u,e[7]=h,e[8]=f):f=e[8];let m;return e[9]!==r||e[10]!==i||e[11]!==f||e[12]!==c?(m=n.jsxs(I_,{variant:c,children:[d,i,f,r]}),e[9]=r,e[10]=i,e[11]=f,e[12]=c,e[13]=m):m=e[13],m}function U0(t,e){return n.jsx(B0,{section:t},e)}function ff(t){const e=B.c(2);let s;return e[0]!==t?(s=n.jsx(F0,{...t}),e[0]=t,e[1]=s):s=e[1],s}ff.Skeleton=function(){return n.jsx("div",{className:"flex flex-col gap-0.5",children:Array.from({length:8}).map((e,s)=>n.jsx("div",{className:"w-full h-8",children:n.jsx(Fi,{className:"h-full bg-sidebar-accent rounded-md"})},s))})};function H0(){const t=B.c(7),s=Th().logo??Dh,i=typeof s=="string"?s:s.light,r=typeof s=="string"?s:s.dark;let o;t[0]!==i?(o=n.jsx("img",{src:i,alt:"Logo",className:"size-6 object-contain dark:hidden"}),t[0]=i,t[1]=o):o=t[1];let a;t[2]!==r?(a=n.jsx("img",{src:r,alt:"Logo",className:"size-6 object-contain hidden dark:block"}),t[2]=r,t[3]=a):a=t[3];let l;return t[4]!==o||t[5]!==a?(l=n.jsx(Eu,{className:"flex items-center justify-center shrink-0 px-2 pb-0",children:n.jsxs("div",{className:"flex w-full aspect-square items-center justify-center",children:[o,a]})}),t[4]=o,t[5]=a,t[6]=l):l=t[6],l}function id(t){const e=B.c(15),{item:s,onClose:i}=t,r=s.isActive&&"z-10";let o;e[0]!==r?(o=J(r),e[0]=r,e[1]=o):o=e[1];let a;e[2]!==s||e[3]!==i?(a=()=>{s.onClick?.(),i()},e[2]=s,e[3]=i,e[4]=a):a=e[4];let l;e[5]!==s.icon?(l=n.jsx("span",{className:"[&>svg]:size-8",children:s.icon}),e[5]=s.icon,e[6]=l):l=e[6];let c;e[7]!==s.isActive||e[8]!==s.label||e[9]!==a||e[10]!==l?(c=n.jsx(_s,{onClick:a,isActive:s.isActive,tooltip:s.label,className:"bg-muted/75",children:l}),e[7]=s.isActive,e[8]=s.label,e[9]=a,e[10]=l,e[11]=c):c=e[11];let d;return e[12]!==o||e[13]!==c?(d=n.jsx(Zt,{className:o,children:c}),e[12]=o,e[13]=c,e[14]=d):d=e[14],d}function W0(t){const e=B.c(18),{section:s,onClose:i}=t;switch(s.type){case"divider":{let r;return e[0]===Symbol.for("react.memo_cache_sentinel")?(r=n.jsx(Nu,{className:"my-2"}),e[0]=r):r=e[0],r}case"spacer":{let r;return e[1]===Symbol.for("react.memo_cache_sentinel")?(r=n.jsx("div",{className:"flex-1"}),e[1]=r):r=e[1],r}case"group":{const r=s.group.label,o=s.group.defaultExpanded;let a;if(e[2]!==i||e[3]!==s.group.items){let c;e[5]!==i?(c=d=>n.jsx(id,{item:d,onClose:i},d.key),e[5]=i,e[6]=c):c=e[6],a=s.group.items.map(c),e[2]=i,e[3]=s.group.items,e[4]=a}else a=e[4];let l;return e[7]!==s.group.defaultExpanded||e[8]!==s.group.label||e[9]!==a?(l=n.jsx(hf,{label:r,defaultExpanded:o,children:a}),e[7]=s.group.defaultExpanded,e[8]=s.group.label,e[9]=a,e[10]=l):l=e[10],l}case"items":{let r;if(e[11]!==i||e[12]!==s.items){let a;e[14]!==i?(a=l=>n.jsx(id,{item:l,onClose:i},l.key),e[14]=i,e[15]=a):a=e[15],r=s.items.map(a),e[11]=i,e[12]=s.items,e[13]=r}else r=e[13];let o;return e[16]!==r?(o=n.jsx(Xn,{className:"pt-0 pr-0 pb-0 pl-0",children:n.jsx(Jn,{children:n.jsx(vs,{className:"gap-1.5",children:r})})}),e[16]=r,e[17]=o):o=e[17],o}}}function K0(t){const e=B.c(12),{sections:s,onClose:i,footer:r,additionalContent:o}=t;let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx(S.Suspense,{fallback:n.jsx("div",{className:"h-10 shrink-0"}),children:n.jsx(H0,{})}),e[0]=a):a=e[0];let l;if(e[1]!==i||e[2]!==s){let u;e[4]!==i?(u=(h,f)=>n.jsx(W0,{section:h,onClose:i},f),e[4]=i,e[5]=u):u=e[5],l=s.map(u),e[1]=i,e[2]=s,e[3]=l}else l=e[3];let c;e[6]!==o||e[7]!==l?(c=n.jsxs(Au,{className:"flex flex-col flex-1 px-2 py-2 gap-0",children:[l,o]}),e[6]=o,e[7]=l,e[8]=c):c=e[8];let d;return e[9]!==r||e[10]!==c?(d=n.jsxs("div",{className:"bg-sidebar flex h-full w-full flex-col","data-sidebar":"sidebar",children:[a,c,r]}),e[9]=r,e[10]=c,e[11]=d):d=e[11],d}function mf(t){return t.toLowerCase().trim().replace(/[^a-z0-9\s_-]+/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const q0=Ns({name:Et().min(2,"Organization name is required")});function G0(t){const e=B.c(41),{open:s,onOpenChange:i}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={resolver:Un(q0),defaultValues:{name:""}},e[0]=r):r=e[0];const o=Gi(r);let a;e[1]===Symbol.for("react.memo_cache_sentinel")?(a={mutationFn:X0,onSuccess:Y0},e[1]=a):a=e[1];const l=qi(a),c=l.error instanceof Error?l.error.message:l.error?"Failed to create organization.":null;let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsxs(Tl,{children:[n.jsx(Dl,{children:"Create a new organization"}),n.jsx(Ml,{children:"Set up a new organization to collaborate with others."})]}),e[2]=d):d=e[2];let u;if(e[3]!==l||e[4]!==o){let w;e[6]!==l?(w=V=>l.mutateAsync(V),e[6]=l,e[7]=w):w=e[7],u=o.handleSubmit(w),e[3]=l,e[4]=o,e[5]=u}else u=e[5];let h;e[8]!==o.formState.isSubmitting?(h=w=>{const{field:V}=w;return n.jsxs(Rt,{children:[n.jsx(os,{children:"Organization Name"}),n.jsx(Tt,{children:n.jsx(gt,{...V,placeholder:"Acme Inc.",disabled:o.formState.isSubmitting})}),n.jsx(Sg,{children:"The name of your company or organization"}),V.value&&n.jsxs("div",{className:"text-xs text-muted-foreground mt-1",children:["Organization URL:"," ",n.jsxs("span",{className:"font-mono",children:[typeof window<"u"?globalThis.location.origin:"","/",mf(V.value)]})]}),n.jsx(Dt,{})]})},e[8]=o.formState.isSubmitting,e[9]=h):h=e[9];let f;e[10]!==o.control||e[11]!==h?(f=n.jsx(It,{control:o.control,name:"name",render:h}),e[10]=o.control,e[11]=h,e[12]=f):f=e[12];let m;e[13]!==c?(m=c&&n.jsx("div",{className:"text-destructive text-sm mt-2",children:c}),e[13]=c,e[14]=m):m=e[14];let p;e[15]!==l||e[16]!==o?(p=()=>{l.reset(),o.reset()},e[15]=l,e[16]=o,e[17]=p):p=e[17];let g;e[18]!==o.formState.isSubmitting||e[19]!==p?(g=n.jsx(Il,{disabled:o.formState.isSubmitting,onClick:p,children:"Cancel"}),e[18]=o.formState.isSubmitting,e[19]=p,e[20]=g):g=e[20];const _=!o.formState.isValid||o.formState.isSubmitting;let v;e[21]!==o.formState.isSubmitting?(v=o.formState.isSubmitting?n.jsxs("span",{className:"flex items-center gap-2",children:[n.jsx(In,{size:"xs"})," Creating..."]}):"Create Organization",e[21]=o.formState.isSubmitting,e[22]=v):v=e[22];let x;e[23]!==_||e[24]!==v?(x=n.jsx(ae,{type:"submit",variant:"default",disabled:_,children:v}),e[23]=_,e[24]=v,e[25]=x):x=e[25];let b;e[26]!==x||e[27]!==g?(b=n.jsxs(Pl,{children:[g,x]}),e[26]=x,e[27]=g,e[28]=b):b=e[28];let y;e[29]!==b||e[30]!==u||e[31]!==f||e[32]!==m?(y=n.jsxs("form",{className:"space-y-6",onSubmit:u,autoComplete:"off",children:[f,m,b]}),e[29]=b,e[30]=u,e[31]=f,e[32]=m,e[33]=y):y=e[33];let C;e[34]!==o||e[35]!==y?(C=n.jsxs(Rl,{children:[d,n.jsx($i,{...o,children:y})]}),e[34]=o,e[35]=y,e[36]=C):C=e[36];let k;return e[37]!==i||e[38]!==s||e[39]!==C?(k=n.jsx(Ll,{open:s,onOpenChange:i,children:C}),e[37]=i,e[38]=s,e[39]=C,e[40]=k):k=e[40],k}function Y0(t){const{orgSlug:e}=t;window.location.href=`/${e}`}async function X0(t){const e=mf(t.name);if(!e)throw new Error("Organization slug is invalid");const s=await St.organization.create({name:t.name,slug:e});if(s?.error)throw new Error(s.error.message||"Failed to create organization");const i=s?.data?.slug??e;if(!i)throw new Error("Failed to create organization");return{orgSlug:i}}function wa(t){let e=0;for(let i=0;i<t.length;i++)e=t.charCodeAt(i)+((e<<5)-e);const s=Math.abs(e)%360;return{backgroundColor:`hsl(${s} 55% 70%)`,color:`hsl(${s} 55% 20%)`}}function J0(t){const e=B.c(13),{org:s,size:i}=t,r=i===void 0?"sm":i,o=r==="xs"?"size-5":"size-6",a=r==="xs"?"text-[9px]":"text-xs";let l;e[0]!==o?(l=J(o,"shrink-0 rounded-md flex items-center justify-center border border-border/50 overflow-hidden"),e[0]=o,e[1]=l):l=e[1];let c;e[2]!==s.logo||e[3]!==s.name?(c=s.logo?void 0:wa(s.name),e[2]=s.logo,e[3]=s.name,e[4]=c):c=e[4];let d;e[5]!==s.logo||e[6]!==s.name||e[7]!==a?(d=s.logo?n.jsx("img",{src:s.logo,alt:"",className:"size-full object-cover"}):n.jsx("span",{className:J("font-semibold leading-none",a),children:s.name.slice(0,2).toUpperCase()}),e[5]=s.logo,e[6]=s.name,e[7]=a,e[8]=d):d=e[8];let u;return e[9]!==l||e[10]!==c||e[11]!==d?(u=n.jsx("div",{className:l,style:c,children:d}),e[9]=l,e[10]=c,e[11]=d,e[12]=u):u=e[12],u}function ur(t){const e=B.c(22),{item:s,onClose:i}=t;if(s.href){const c=s.external?"_blank":void 0,d=s.external?"noopener noreferrer":void 0;let u;e[0]!==s.icon?(u=n.jsx("span",{className:"shrink-0 text-muted-foreground",children:s.icon}),e[0]=s.icon,e[1]=u):u=e[1];let h;e[2]!==s.label?(h=n.jsx("span",{className:"flex-1",children:s.label}),e[2]=s.label,e[3]=h):h=e[3];let f;return e[4]!==s.href||e[5]!==i||e[6]!==c||e[7]!==d||e[8]!==u||e[9]!==h?(f=n.jsxs("a",{href:s.href,target:c,rel:d,className:"flex items-center gap-2.5 px-3 py-2 rounded-md text-sm text-left w-full transition-colors text-foreground/80 hover:bg-sidebar-accent hover:text-foreground",onClick:i,children:[u,h]}),e[4]=s.href,e[5]=i,e[6]=c,e[7]=d,e[8]=u,e[9]=h,e[10]=f):f=e[10],f}let r;e[11]!==s||e[12]!==i?(r=()=>{s.onClick?.(),i()},e[11]=s,e[12]=i,e[13]=r):r=e[13];let o;e[14]!==s.icon?(o=n.jsx("span",{className:"shrink-0 text-muted-foreground",children:s.icon}),e[14]=s.icon,e[15]=o):o=e[15];let a;e[16]!==s.label?(a=n.jsx("span",{className:"flex-1",children:s.label}),e[16]=s.label,e[17]=a):a=e[17];let l;return e[18]!==r||e[19]!==o||e[20]!==a?(l=n.jsxs("button",{type:"button",onClick:r,className:"flex items-center gap-2.5 px-3 py-2 rounded-md text-sm text-left w-full transition-colors text-foreground/80 hover:bg-sidebar-accent hover:text-foreground",children:[o,a]}),e[18]=r,e[19]=o,e[20]=a,e[21]=l):l=e[21],l}function nd(t){const e=B.c(16),{sortedOrgs:s,orgParam:i,onSelectOrg:r,onCreateOrg:o}=t;let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx("span",{className:"text-sm font-medium text-muted-foreground/60",children:"Your Organizations"}),e[0]=a):a=e[0];let l;e[1]===Symbol.for("react.memo_cache_sentinel")?(l=n.jsx(Qt,{size:16}),e[1]=l):l=e[1];let c;e[2]!==o?(c=n.jsxs("div",{className:"flex items-center justify-between px-4 py-3",children:[a,n.jsx("button",{type:"button",onClick:o,className:"flex items-center justify-center size-7 rounded-md text-muted-foreground hover:bg-accent/50 hover:text-foreground transition-colors",children:l})]}),e[2]=o,e[3]=c):c=e[3];let d;if(e[4]!==r||e[5]!==i||e[6]!==s){let f;e[8]!==r||e[9]!==i?(f=m=>n.jsxs("button",{type:"button",onClick:()=>r(m.slug),className:J("flex items-center gap-3 px-3 py-2.5 rounded-md text-sm text-left w-full transition-colors",m.slug===i?"bg-accent text-accent-foreground":"text-foreground hover:bg-accent/50"),children:[n.jsx(J0,{org:m,size:"sm"}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsx("p",{className:"text-sm font-medium truncate",children:m.name}),n.jsx("p",{className:"text-xs text-muted-foreground truncate",children:m.slug})]}),m.slug===i&&n.jsx(Jt,{size:14,className:"ml-auto text-muted-foreground shrink-0"})]},m.id),e[8]=r,e[9]=i,e[10]=f):f=e[10],d=s.map(f),e[4]=r,e[5]=i,e[6]=s,e[7]=d}else d=e[7];let u;e[11]!==d?(u=n.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto p-1.5 flex flex-col gap-1",children:d}),e[11]=d,e[12]=u):u=e[12];let h;return e[13]!==c||e[14]!==u?(h=n.jsxs(n.Fragment,{children:[c,u]}),e[13]=c,e[14]=u,e[15]=h):h=e[15],h}function rd(t){const e=B.c(142),{user:s,userImage:i,menuItems:r,signOutItem:o,themeOptions:a,preferences:l,setPreferences:c,sortedOrgs:d,orgParam:u,onSelectOrg:h,onCreateOrg:f,close:m,isMobile:p}=t;if(p){const W=s?.name??"U";let K;e[0]!==W||e[1]!==i?(K=n.jsx(Ec,{url:i,fallback:W,shape:"circle",size:"sm",className:"shrink-0"}),e[0]=W,e[1]=i,e[2]=K):K=e[2];const ee=s?.name??"User";let Z;e[3]!==ee?(Z=n.jsx("p",{className:"text-sm font-medium truncate",children:ee}),e[3]=ee,e[4]=Z):Z=e[4];const X=s?.email;let ie;e[5]!==X?(ie=n.jsx("p",{className:"text-xs text-muted-foreground truncate",children:X}),e[5]=X,e[6]=ie):ie=e[6];let re;e[7]!==Z||e[8]!==ie?(re=n.jsxs("div",{className:"flex-1 min-w-0",children:[Z,ie]}),e[7]=Z,e[8]=ie,e[9]=re):re=e[9];let de;e[10]!==s?(de=()=>{s?.id&&navigator.clipboard.writeText(s.id).then(ty)},e[10]=s,e[11]=de):de=e[11];let me;e[12]===Symbol.for("react.memo_cache_sentinel")?(me=n.jsx(zi,{size:14}),e[12]=me):me=e[12];let le;e[13]!==de?(le=n.jsx(st,{asChild:!0,children:n.jsx("button",{type:"button",tabIndex:-1,onClick:de,className:"shrink-0 text-muted-foreground hover:text-foreground transition-colors",children:me})}),e[13]=de,e[14]=le):le=e[14];let se;e[15]===Symbol.for("react.memo_cache_sentinel")?(se=n.jsx(it,{side:"right",children:n.jsx("p",{className:"text-xs",children:"Copy user ID"})}),e[15]=se):se=e[15];let _e;e[16]!==le?(_e=n.jsx(Bi,{delayDuration:300,children:n.jsxs(nt,{children:[le,se]})}),e[16]=le,e[17]=_e):_e=e[17];let ge;e[18]!==_e||e[19]!==K||e[20]!==re?(ge=n.jsxs("div",{className:"flex items-center gap-3 px-4 py-4 border-b border-border",children:[K,re,_e]}),e[18]=_e,e[19]=K,e[20]=re,e[21]=ge):ge=e[21];let Se;e[22]!==f||e[23]!==h||e[24]!==u||e[25]!==d?(Se=n.jsx("div",{className:"border-b border-border pb-2",children:n.jsx(nd,{sortedOrgs:d,orgParam:u,onSelectOrg:h,onCreateOrg:f})}),e[22]=f,e[23]=h,e[24]=u,e[25]=d,e[26]=Se):Se=e[26];let ve;if(e[27]!==m||e[28]!==r){let ze;e[30]!==m?(ze=Kt=>n.jsx(ur,{item:Kt,onClose:m},Kt.key),e[30]=m,e[31]=ze):ze=e[31],ve=r.map(ze),e[27]=m,e[28]=r,e[29]=ve}else ve=e[29];let Ne;e[32]!==m||e[33]!==o?(Ne=n.jsx(ur,{item:o,onClose:m}),e[32]=m,e[33]=o,e[34]=Ne):Ne=e[34];let Te;e[35]!==ve||e[36]!==Ne?(Te=n.jsxs("nav",{className:"flex flex-col px-2 pt-2 pb-2 gap-0.5",children:[ve,Ne]}),e[35]=ve,e[36]=Ne,e[37]=Te):Te=e[37];let te;e[38]!==Se||e[39]!==Te?(te=n.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto",children:[Se,Te]}),e[38]=Se,e[39]=Te,e[40]=te):te=e[40];let he;if(e[41]!==l.theme||e[42]!==c||e[43]!==a){let ze;e[45]!==l.theme||e[46]!==c?(ze=Kt=>{const{value:kt,icon:Re,label:Le}=Kt;return n.jsx("button",{type:"button","aria-label":Le,onClick:()=>c(Ye=>({...Ye,theme:kt})),className:J("size-8 rounded-md flex items-center justify-center transition-colors",l.theme===kt?"bg-sidebar-accent text-foreground":"text-muted-foreground hover:bg-sidebar-accent/50 hover:text-foreground"),children:Re},kt)},e[45]=l.theme,e[46]=c,e[47]=ze):ze=e[47],he=a.map(ze),e[41]=l.theme,e[42]=c,e[43]=a,e[44]=he}else he=e[44];let we;e[48]!==he?(we=n.jsx("div",{className:"flex items-center gap-0.5",children:he}),e[48]=he,e[49]=we):we=e[49];const Ee=l.enableSounds?"Disable sounds":"Enable sounds";let Ie;e[50]!==c?(Ie=()=>c(ey),e[50]=c,e[51]=Ie):Ie=e[51];const De=l.enableSounds?"text-foreground hover:bg-sidebar-accent/50":"text-muted-foreground hover:bg-sidebar-accent/50 hover:text-foreground";let Pe;e[52]!==De?(Pe=J("size-8 rounded-md flex items-center justify-center transition-colors",De),e[52]=De,e[53]=Pe):Pe=e[53];let ye;e[54]!==l.enableSounds?(ye=l.enableSounds?n.jsx(xc,{size:14}):n.jsx(vc,{size:14}),e[54]=l.enableSounds,e[55]=ye):ye=e[55];let Ae;e[56]!==Ee||e[57]!==Ie||e[58]!==Pe||e[59]!==ye?(Ae=n.jsx("button",{type:"button","aria-label":Ee,onClick:Ie,className:Pe,children:ye}),e[56]=Ee,e[57]=Ie,e[58]=Pe,e[59]=ye,e[60]=Ae):Ae=e[60];let fe;e[61]===Symbol.for("react.memo_cache_sentinel")?(fe=n.jsxs("span",{className:"text-xs text-muted-foreground/60",children:["v","2.282.2"]}),e[61]=fe):fe=e[61];let ke;e[62]!==Ae?(ke=n.jsxs("div",{className:"flex items-center gap-2",children:[Ae,fe]}),e[62]=Ae,e[63]=ke):ke=e[63];let Ze;e[64]!==we||e[65]!==ke?(Ze=n.jsxs("div",{className:"flex items-center justify-between px-3 py-3 border-t border-border/50",children:[we,ke]}),e[64]=we,e[65]=ke,e[66]=Ze):Ze=e[66];let Ct;return e[67]!==ge||e[68]!==te||e[69]!==Ze?(Ct=n.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[ge,te,Ze]}),e[67]=ge,e[68]=te,e[69]=Ze,e[70]=Ct):Ct=e[70],Ct}const g=s?.name??"U";let _;e[71]!==g||e[72]!==i?(_=n.jsx(Ec,{url:i,fallback:g,shape:"circle",size:"sm",className:"shrink-0"}),e[71]=g,e[72]=i,e[73]=_):_=e[73];const v=s?.name??"User";let x;e[74]!==v?(x=n.jsx("p",{className:"text-sm font-medium truncate",children:v}),e[74]=v,e[75]=x):x=e[75];const b=s?.email;let y;e[76]!==b?(y=n.jsx("p",{className:"text-xs text-muted-foreground truncate",children:b}),e[76]=b,e[77]=y):y=e[77];let C;e[78]!==x||e[79]!==y?(C=n.jsxs("div",{className:"flex-1 min-w-0",children:[x,y]}),e[78]=x,e[79]=y,e[80]=C):C=e[80];let k;e[81]!==s?(k=()=>{s?.id&&navigator.clipboard.writeText(s.id).then(Z0)},e[81]=s,e[82]=k):k=e[82];let w;e[83]===Symbol.for("react.memo_cache_sentinel")?(w=n.jsx(zi,{size:14}),e[83]=w):w=e[83];let V;e[84]!==k?(V=n.jsx(st,{asChild:!0,children:n.jsx("button",{type:"button",tabIndex:-1,onClick:k,className:"shrink-0 text-muted-foreground hover:text-foreground transition-colors",children:w})}),e[84]=k,e[85]=V):V=e[85];let j;e[86]===Symbol.for("react.memo_cache_sentinel")?(j=n.jsx(it,{side:"right",children:n.jsx("p",{className:"text-xs",children:"Copy user ID"})}),e[86]=j):j=e[86];let I;e[87]!==V?(I=n.jsx(Bi,{delayDuration:300,children:n.jsxs(nt,{children:[V,j]})}),e[87]=V,e[88]=I):I=e[88];let T;e[89]!==I||e[90]!==_||e[91]!==C?(T=n.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 mx-1 mt-1",children:[_,C,I]}),e[89]=I,e[90]=_,e[91]=C,e[92]=T):T=e[92];let R;if(e[93]!==m||e[94]!==r){let W;e[96]!==m?(W=K=>n.jsx(ur,{item:K,onClose:m},K.key),e[96]=m,e[97]=W):W=e[97],R=r.map(W),e[93]=m,e[94]=r,e[95]=R}else R=e[95];let N;e[98]!==m||e[99]!==o?(N=n.jsx(ur,{item:o,onClose:m}),e[98]=m,e[99]=o,e[100]=N):N=e[100];let A;e[101]!==R||e[102]!==N?(A=n.jsxs("nav",{className:"flex-1 flex flex-col px-2 pt-1 overflow-y-auto",children:[R,N]}),e[101]=R,e[102]=N,e[103]=A):A=e[103];let E;if(e[104]!==l.theme||e[105]!==c||e[106]!==a){let W;e[108]!==l.theme||e[109]!==c?(W=K=>{const{value:ee,icon:Z,label:X}=K;return n.jsx("button",{type:"button","aria-label":X,onClick:()=>c(ie=>({...ie,theme:ee})),className:J("size-7 rounded-md flex items-center justify-center transition-colors",l.theme===ee?"bg-sidebar-accent text-foreground":"text-muted-foreground hover:bg-sidebar-accent/50 hover:text-foreground"),children:Z},ee)},e[108]=l.theme,e[109]=c,e[110]=W):W=e[110],E=a.map(W),e[104]=l.theme,e[105]=c,e[106]=a,e[107]=E}else E=e[107];let M;e[111]!==E?(M=n.jsx("div",{className:"flex items-center gap-0.5",children:E}),e[111]=E,e[112]=M):M=e[112];const L=l.enableSounds?"Disable sounds":"Enable sounds";let D;e[113]!==c?(D=()=>c(Q0),e[113]=c,e[114]=D):D=e[114];const P=l.enableSounds?"text-foreground hover:bg-sidebar-accent/50":"text-muted-foreground hover:bg-sidebar-accent/50 hover:text-foreground";let O;e[115]!==P?(O=J("size-7 rounded-md flex items-center justify-center transition-colors",P),e[115]=P,e[116]=O):O=e[116];let z;e[117]!==l.enableSounds?(z=l.enableSounds?n.jsx(xc,{size:14}):n.jsx(vc,{size:14}),e[117]=l.enableSounds,e[118]=z):z=e[118];let $;e[119]!==L||e[120]!==D||e[121]!==O||e[122]!==z?($=n.jsx("button",{type:"button","aria-label":L,onClick:D,className:O,children:z}),e[119]=L,e[120]=D,e[121]=O,e[122]=z,e[123]=$):$=e[123];let q;e[124]===Symbol.for("react.memo_cache_sentinel")?(q=n.jsxs("span",{className:"text-xs text-muted-foreground/60",children:["v","2.282.2"]}),e[124]=q):q=e[124];let F;e[125]!==$?(F=n.jsxs("div",{className:"flex items-center gap-2",children:[$,q]}),e[125]=$,e[126]=F):F=e[126];let G;e[127]!==M||e[128]!==F?(G=n.jsxs("div",{className:"flex items-center justify-between px-2 py-1.5 border-t border-border/50",children:[M,F]}),e[127]=M,e[128]=F,e[129]=G):G=e[129];let H;e[130]!==T||e[131]!==A||e[132]!==G?(H=n.jsxs("div",{className:"w-60 shrink-0 flex flex-col border-r border-border bg-sidebar/75",children:[T,A,G]}),e[130]=T,e[131]=A,e[132]=G,e[133]=H):H=e[133];let U;e[134]!==f||e[135]!==h||e[136]!==u||e[137]!==d?(U=n.jsx("div",{className:"flex-1 flex flex-col min-w-0 min-h-0 overflow-hidden",children:n.jsx(nd,{sortedOrgs:d,orgParam:u,onSelectOrg:h,onCreateOrg:f})}),e[134]=f,e[135]=h,e[136]=u,e[137]=d,e[138]=U):U=e[138];let Y;return e[139]!==H||e[140]!==U?(Y=n.jsxs("div",{className:"flex min-h-[380px] w-full overflow-hidden",children:[H,U]}),e[139]=H,e[140]=U,e[141]=Y):Y=e[141],Y}function Q0(t){return{...t,enableSounds:!t.enableSounds}}function Z0(){ue.success("User ID copied")}function ey(t){return{...t,enableSounds:!t.enableSounds}}function ty(){ue.success("User ID copied")}function pf(){const t=B.c(50),{data:e}=St.useSession(),{data:s}=St.useListOrganizations(),i=Ge();let r;t[0]===Symbol.for("react.memo_cache_sentinel")?(r={from:"/shell/$org",shouldThrow:!1},t[0]=r):r=t[0];const a=gp(r)?.params.org,[l,c]=yi(),d=Ps(),[u,h]=S.useState(!1),[f,m]=S.useState(!1),p=e?.user,g=p?.image;let _;if(t[1]!==d||t[2]!==i||t[3]!==u||t[4]!==a||t[5]!==s||t[6]!==l||t[7]!==c||t[8]!==p||t[9]!==g){const b=s?.find(Y=>Y.slug===a);let y;if(t[11]!==a||t[12]!==s){let Y;t[14]!==a?(Y=(W,K)=>W.slug===a?-1:K.slug===a?1:W.name.localeCompare(K.name),t[14]=a,t[15]=Y):Y=t[15],y=[...s??[]].sort(Y),t[11]=a,t[12]=s,t[13]=y}else y=t[13];const C=y;let k;t[16]!==i?(k=Y=>{h(!1),i({to:"/$org",params:{org:Y}})},t[16]=i,t[17]=k):k=t[17];const w=k;let V;t[18]===Symbol.for("react.memo_cache_sentinel")?(V=()=>h(!1),t[18]=V):V=t[18];const j=V;let I;t[19]===Symbol.for("react.memo_cache_sentinel")?(I=n.jsx(Zn,{size:16}),t[19]=I):I=t[19];let T;t[20]!==i||t[21]!==a?(T={key:"preferences",label:"Preferences",icon:I,onClick:()=>{i({to:"/$org/settings/profile",params:{org:a??""}})}},t[20]=i,t[21]=a,t[22]=T):T=t[22];let R;t[23]===Symbol.for("react.memo_cache_sentinel")?(R={key:"terms",label:"Terms of Use",icon:n.jsx(Ig,{size:16}),href:"https://www.decocms.com/terms-of-use",external:!0},t[23]=R):R=t[23];let N;t[24]===Symbol.for("react.memo_cache_sentinel")?(N={key:"privacy",label:"Privacy Policy",icon:n.jsx(Rg,{size:16}),href:"https://www.decocms.com/privacy-policy",external:!0},t[24]=N):N=t[24];let A;t[25]===Symbol.for("react.memo_cache_sentinel")?(A={key:"github",label:"decocms/studio",icon:n.jsx(_p,{className:"w-4 h-4"}),href:"https://github.com/decocms/studio",external:!0},t[25]=A):A=t[25];let E;t[26]===Symbol.for("react.memo_cache_sentinel")?(E={key:"community",label:"Community",icon:n.jsx(po,{size:16}),href:"https://decocms.com/discord",external:!0},t[26]=E):E=t[26];let M;t[27]===Symbol.for("react.memo_cache_sentinel")?(M={key:"homepage",label:"Homepage",icon:n.jsx(cu,{size:16}),href:"https://decocms.com",external:!0},t[27]=M):M=t[27];let L;t[28]!==T?(L=[T,R,N,A,E,M],t[28]=T,t[29]=L):L=t[29];const D=L;let P;t[30]===Symbol.for("react.memo_cache_sentinel")?(P={key:"logout",label:"Sign out",icon:n.jsx(Fg,{size:16}),onClick:iy},t[30]=P):P=t[30];const O=P;let z;t[31]===Symbol.for("react.memo_cache_sentinel")?(z={value:"light",icon:n.jsx(O_,{size:14}),label:"Light theme"},t[31]=z):z=t[31];let $;t[32]===Symbol.for("react.memo_cache_sentinel")?($={value:"dark",icon:n.jsx(B_,{size:14}),label:"Dark theme"},t[32]=$):$=t[32];let q;t[33]===Symbol.for("react.memo_cache_sentinel")?(q=[z,$,{value:"system",icon:n.jsx($_,{size:14}),label:"System theme"}],t[33]=q):q=t[33];const F=q;let G;t[34]===Symbol.for("react.memo_cache_sentinel")?(G=()=>{h(!1),m(!0)},t[34]=G):G=t[34];let H;t[35]!==w||t[36]!==d||t[37]!==D||t[38]!==a||t[39]!==l||t[40]!==c||t[41]!==C||t[42]!==p||t[43]!==g?(H={user:p,userImage:g,menuItems:D,signOutItem:O,themeOptions:F,preferences:l,setPreferences:c,sortedOrgs:C,orgParam:a,onSelectOrg:w,onCreateOrg:G,close:j,isMobile:d},t[35]=w,t[36]=d,t[37]=D,t[38]=a,t[39]=l,t[40]=c,t[41]=C,t[42]=p,t[43]=g,t[44]=H):H=t[44];const U=H;_=d?n.jsxs(Ci,{open:u,onOpenChange:h,direction:"bottom",children:[n.jsxs("button",{type:"button",onClick:()=>h(!0),className:"flex items-center gap-3 w-full px-3 py-2.5 rounded-lg transition-colors text-sm text-sidebar-foreground/70 hover:bg-sidebar-accent hover:text-sidebar-foreground",children:[n.jsx("div",{className:"shrink-0 size-5 rounded-md flex items-center justify-center border border-border/50 overflow-hidden",style:b?.logo?void 0:wa(b?.name??""),children:b?.logo?n.jsx("img",{src:b.logo,alt:"",className:"size-full object-cover"}):n.jsx("span",{className:"font-semibold leading-none text-[8px]",children:(b?.name??"?").slice(0,2).toUpperCase()})}),n.jsx("span",{className:"truncate",children:b?.name??"Account"})]}),n.jsxs(Vi,{className:"h-[80dvh] p-0",children:[n.jsx(wi,{className:"sr-only",children:"Account"}),n.jsx(rd,{...U})]})]}):n.jsxs(di,{open:u,onOpenChange:h,children:[n.jsx(li,{asChild:!0,children:n.jsx(_s,{tooltip:b?.name??"Account",className:"rounded-md",children:n.jsx("div",{className:"shrink-0 size-6 rounded-md flex items-center justify-center border border-border/50 overflow-hidden",style:b?.logo?void 0:wa(b?.name??""),children:b?.logo?n.jsx("img",{src:b.logo,alt:"",className:"size-full object-cover"}):n.jsx("span",{className:"font-semibold leading-none text-[9px]",children:(b?.name??"?").slice(0,2).toUpperCase()})})})}),n.jsx(ci,{side:"right",align:"end",sideOffset:18,collisionPadding:16,className:"w-[520px] p-0 flex max-h-[520px]",onCloseAutoFocus:sy,children:n.jsx(rd,{...U})})]}),t[1]=d,t[2]=i,t[3]=u,t[4]=a,t[5]=s,t[6]=l,t[7]=c,t[8]=p,t[9]=g,t[10]=_}else _=t[10];let v;t[45]!==f?(v=n.jsx(G0,{open:f,onOpenChange:m}),t[45]=f,t[46]=v):v=t[46];let x;return t[47]!==_||t[48]!==v?(x=n.jsxs(n.Fragment,{children:[_,v]}),t[47]=_,t[48]=v,t[49]=x):x=t[49],x}function sy(t){return t.preventDefault()}function iy(){ne("signed_out",{source:"account_popover"}),St.signOut()}function ny({invitation:t}){const[e,s]=S.useState(!1),[i,r]=S.useState(!1),o=Mt(),a=async()=>{s(!0);try{const c=await St.organization.acceptInvitation({invitationId:t.id});if(c.error)ue.error(c.error.message),s(!1);else{const d=await St.organization.setActive({organizationId:t.organizationId});ue.success("Invitation accepted!");const u=d?.data?.slug;window.location.href=u?`/${u}`:"/"}}catch{ue.error("Failed to accept invitation"),s(!1)}},l=async()=>{r(!0);try{const c=await St.organization.rejectInvitation({invitationId:t.id});c.error?(ue.error(c.error.message),r(!1)):(ue.success("Invitation declined"),o.invalidateQueries())}catch{ue.error("Failed to decline invitation"),r(!1)}};return n.jsxs("div",{className:"flex items-center gap-3 px-5 py-4 border-b border-border last:border-0 hover:bg-muted/25 transition-colors",children:[n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsx("p",{className:"text-xs text-muted-foreground",children:"You've been invited to join"}),n.jsx("p",{className:"text-sm font-medium truncate",children:t.organizationName??"Unknown organization"})]}),n.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[n.jsx(ae,{size:"icon",variant:"ghost",className:"size-7 text-green-600 hover:text-green-700 hover:bg-green-50 dark:hover:bg-green-950",onClick:a,disabled:e||i,"aria-label":"Accept invitation",children:n.jsx(Jt,{size:14})}),n.jsx(ae,{size:"icon",variant:"ghost",className:"size-7 text-muted-foreground hover:text-destructive hover:bg-destructive/10",onClick:l,disabled:e||i,"aria-label":"Decline invitation",children:n.jsx(ri,{size:14})})]})]})}function ry(){const t=S.useContext(xp),{data:e}=t.hooks.useListUserInvitations();return(e??[]).filter(i=>i.status==="pending"&&new Date(i.expiresAt)>new Date)}class oy extends S.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e,s){}render(){return this.state.hasError?null:this.props.children}}function ay(t){return t<=1?"text-destructive":t<=5?"text-amber-500 dark:text-amber-400":"text-foreground/70"}function ly(){const t=B.c(19),e=Ge(),{org:s}=xe();let i;t[0]!==s.id?(i={connectionId:Pt,orgId:s.id},t[0]=s.id,t[1]=i):i=t[1];const r=Be(i);let o;t[2]===Symbol.for("react.memo_cache_sentinel")?(o={providerId:"deco"},t[2]=o):o=t[2];let a;t[3]!==r?(a={client:r,toolName:"AI_PROVIDER_CREDITS",toolArguments:o,staleTime:6e4,select:cy},t[3]=r,t[4]=a):a=t[4];const{data:l,isPending:c,isError:d}=ki(a),u=l?.balanceCents!=null?l.balanceCents/100:null;let h;t[5]!==u||t[6]!==d||t[7]!==c?(h=c||d||u==null?"Credits":`Credits: $${u.toFixed(2)}`,t[5]=u,t[6]=d,t[7]=c,t[8]=h):h=t[8];const f=h;let m;t[9]!==u?(m=J(u!=null&&ay(u)),t[9]=u,t[10]=m):m=t[10];let p;t[11]!==e||t[12]!==s.slug?(p=()=>e({to:"/$org/settings/ai-providers",params:{org:s.slug}}),t[11]=e,t[12]=s.slug,t[13]=p):p=t[13];let g;t[14]===Symbol.for("react.memo_cache_sentinel")?(g=n.jsx(yl,{size:24}),t[14]=g):g=t[14];let _;return t[15]!==m||t[16]!==p||t[17]!==f?(_=n.jsx(vs,{children:n.jsx(Zt,{children:n.jsx(_s,{tooltip:f,className:m,onClick:p,children:g})})}),t[15]=m,t[16]=p,t[17]=f,t[18]=_):_=t[18],_}function cy(t){return t.structuredContent}function dy(){const t=B.c(1);if(!jl().some(hy))return null;let i;return t[0]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx(ly,{}),t[0]=i):i=t[0],i}function hy(t){return t.providerId==="deco"}function uy(){const t=B.c(3),[e,s]=S.useState(!1);let i;t[0]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx(vs,{children:n.jsx(Zt,{children:n.jsx(_s,{tooltip:"Connections",onClick:()=>{ne("connections_dialog_opened",{source:"sidebar_footer",mode:"browse"}),s(!0)},children:n.jsx(Ug,{size:24})})})}),t[0]=i):i=t[0];let r;return t[1]!==e?(r=n.jsxs(n.Fragment,{children:[i,n.jsx(Fl,{mode:"browse",open:e,onOpenChange:s,defaultTab:"all"})]}),t[1]=e,t[2]=r):r=t[2],r}function fy(){const t=B.c(11),e=ry();let s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx(bc,{size:24}),t[0]=s):s=t[0];let i;t[1]!==e.length?(i=e.length>0&&n.jsx("span",{className:"absolute top-1 right-1 size-2 rounded-full bg-red-500 pointer-events-none"}),t[1]=e.length,t[2]=i):i=t[2];let r;t[3]!==i?(r=n.jsx(vs,{children:n.jsx(Zt,{children:n.jsx(li,{asChild:!0,children:n.jsxs(_s,{tooltip:"Inbox",className:"relative",children:[s,i]})})})}),t[3]=i,t[4]=r):r=t[4];let o;t[5]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx("div",{className:"px-4 py-3 border-b border-border shrink-0",children:n.jsx("h3",{className:"text-sm font-medium",children:"Inbox"})}),t[5]=o):o=t[5];let a;t[6]!==e?(a=n.jsxs(ci,{side:"right",align:"start",sideOffset:16,collisionPadding:16,className:"w-[min(400px,calc(100vw-2rem))] p-0 h-[min(650px,calc(100dvh-4rem))] flex flex-col",children:[o,e.length===0?n.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-2 px-6 text-center",children:[n.jsx(bc,{size:24,className:"text-muted-foreground/50"}),n.jsx("p",{className:"text-sm font-medium text-foreground",children:"No invites pending"}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Organization invitations will appear here"})]}):n.jsx("div",{className:"overflow-y-auto flex-1",children:e.map(my)})]}),t[6]=e,t[7]=a):a=t[7];let l;return t[8]!==r||t[9]!==a?(l=n.jsxs(di,{children:[r,a]}),t[8]=r,t[9]=a,t[10]=l):l=t[10],l}function my(t){return n.jsx(ny,{invitation:t},t.id)}function py(){const t=B.c(6),e=Ge(),{org:s}=xe();let i;t[0]!==e||t[1]!==s.slug?(i=()=>e({to:"/$org/settings",params:{org:s.slug}}),t[0]=e,t[1]=s.slug,t[2]=i):i=t[2];let r;t[3]===Symbol.for("react.memo_cache_sentinel")?(r=n.jsx(Zn,{size:24}),t[3]=r):r=t[3];let o;return t[4]!==i?(o=n.jsx(vs,{children:n.jsx(Zt,{children:n.jsx(_s,{tooltip:"Settings",onClick:i,children:r})})}),t[4]=i,t[5]=o):o=t[5],o}function gy(){const t=B.c(5);let e,s,i,r;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(oy,{children:n.jsx(S.Suspense,{fallback:null,children:n.jsx(dy,{})})}),s=n.jsx(uy,{}),i=n.jsx(fy,{}),r=n.jsx(py,{}),t[0]=e,t[1]=s,t[2]=i,t[3]=r):(e=t[0],s=t[1],i=t[2],r=t[3]);let o;return t[4]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsxs(Iu,{className:"px-2 pb-3 gap-1",children:[e,s,i,r,n.jsx(vs,{children:n.jsx(Zt,{children:n.jsx(pf,{})})})]}),t[4]=o):o=t[4],o}function _y(){const t=B.c(10),e=Ge(),{org:s}=xe(),{setOpenMobile:i}=Qn();let r;t[0]!==e||t[1]!==s.slug||t[2]!==i?(r=()=>{e({to:"/$org/settings",params:{org:s.slug}}),i(!1)},t[0]=e,t[1]=s.slug,t[2]=i,t[3]=r):r=t[3];let o;t[4]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx(Zn,{}),t[4]=o):o=t[4];let a;t[5]!==r?(a=n.jsx(Zt,{children:n.jsx(_s,{tooltip:"Settings",onClick:r,children:o})}),t[5]=r,t[6]=a):a=t[6];let l;t[7]===Symbol.for("react.memo_cache_sentinel")?(l=n.jsx(Zt,{children:n.jsx(pf,{})}),t[7]=l):l=t[7];let c;return t[8]!==a?(c=n.jsx(Iu,{children:n.jsxs(vs,{children:[a,l]})}),t[8]=a,t[9]=c):c=t[9],c}function xy(){for(var t=arguments.length,e=new Array(t),s=0;s<t;s++)e[s]=arguments[s];return S.useMemo(()=>i=>{e.forEach(r=>r(i))},e)}const xo=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Xi(t){const e=Object.prototype.toString.call(t);return e==="[object Window]"||e==="[object global]"}function Ul(t){return"nodeType"in t}function Wt(t){var e,s;return t?Xi(t)?t:Ul(t)&&(e=(s=t.ownerDocument)==null?void 0:s.defaultView)!=null?e:window:window}function Hl(t){const{Document:e}=Wt(t);return t instanceof e}function tr(t){return Xi(t)?!1:t instanceof Wt(t).HTMLElement}function gf(t){return t instanceof Wt(t).SVGElement}function Ji(t){return t?Xi(t)?t.document:Ul(t)?Hl(t)?t:tr(t)||gf(t)?t.ownerDocument:document:document:document}const Ds=xo?S.useLayoutEffect:S.useEffect;function Wl(t){const e=S.useRef(t);return Ds(()=>{e.current=t}),S.useCallback(function(){for(var s=arguments.length,i=new Array(s),r=0;r<s;r++)i[r]=arguments[r];return e.current==null?void 0:e.current(...i)},[])}function vy(){const t=S.useRef(null),e=S.useCallback((i,r)=>{t.current=setInterval(i,r)},[]),s=S.useCallback(()=>{t.current!==null&&(clearInterval(t.current),t.current=null)},[]);return[e,s]}function Mn(t,e){e===void 0&&(e=[t]);const s=S.useRef(t);return Ds(()=>{s.current!==t&&(s.current=t)},e),s}function sr(t,e){const s=S.useRef();return S.useMemo(()=>{const i=t(s.current);return s.current=i,i},[...e])}function Gr(t){const e=Wl(t),s=S.useRef(null),i=S.useCallback(r=>{r!==s.current&&e?.(r,s.current),s.current=r},[]);return[s,i]}function Va(t){const e=S.useRef();return S.useEffect(()=>{e.current=t},[t]),e.current}let Bo={};function ir(t,e){return S.useMemo(()=>{if(e)return e;const s=Bo[t]==null?0:Bo[t]+1;return Bo[t]=s,t+"-"+s},[t,e])}function _f(t){return function(e){for(var s=arguments.length,i=new Array(s>1?s-1:0),r=1;r<s;r++)i[r-1]=arguments[r];return i.reduce((o,a)=>{const l=Object.entries(a);for(const[c,d]of l){const u=o[c];u!=null&&(o[c]=u+t*d)}return o},{...e})}}const Oi=_f(1),Pn=_f(-1);function by(t){return"clientX"in t&&"clientY"in t}function Kl(t){if(!t)return!1;const{KeyboardEvent:e}=Wt(t.target);return e&&t instanceof e}function yy(t){if(!t)return!1;const{TouchEvent:e}=Wt(t.target);return e&&t instanceof e}function Ca(t){if(yy(t)){if(t.touches&&t.touches.length){const{clientX:e,clientY:s}=t.touches[0];return{x:e,y:s}}else if(t.changedTouches&&t.changedTouches.length){const{clientX:e,clientY:s}=t.changedTouches[0];return{x:e,y:s}}}return by(t)?{x:t.clientX,y:t.clientY}:null}const Ln=Object.freeze({Translate:{toString(t){if(!t)return;const{x:e,y:s}=t;return"translate3d("+(e?Math.round(e):0)+"px, "+(s?Math.round(s):0)+"px, 0)"}},Scale:{toString(t){if(!t)return;const{scaleX:e,scaleY:s}=t;return"scaleX("+e+") scaleY("+s+")"}},Transform:{toString(t){if(t)return[Ln.Translate.toString(t),Ln.Scale.toString(t)].join(" ")}},Transition:{toString(t){let{property:e,duration:s,easing:i}=t;return e+" "+s+"ms "+i}}}),od="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function Sy(t){return t.matches(od)?t:t.querySelector(od)}const wy={display:"none"};function Vy(t){let{id:e,value:s}=t;return Ut.createElement("div",{id:e,style:wy},s)}function Cy(t){let{id:e,announcement:s,ariaLiveType:i="assertive"}=t;const r={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return Ut.createElement("div",{id:e,style:r,role:"status","aria-live":i,"aria-atomic":!0},s)}function ky(){const[t,e]=S.useState("");return{announce:S.useCallback(i=>{i!=null&&e(i)},[]),announcement:t}}const xf=S.createContext(null);function jy(t){const e=S.useContext(xf);S.useEffect(()=>{if(!e)throw new Error("useDndMonitor must be used within a children of <DndContext>");return e(t)},[t,e])}function Ny(){const[t]=S.useState(()=>new Set),e=S.useCallback(i=>(t.add(i),()=>t.delete(i)),[t]);return[S.useCallback(i=>{let{type:r,event:o}=i;t.forEach(a=>{var l;return(l=a[r])==null?void 0:l.call(a,o)})},[t]),e]}const Ay={draggable:`
|
|
549
549
|
To pick up a draggable item, press the space bar.
|
|
550
550
|
While dragging, use the arrow keys to move the item.
|
|
551
551
|
Press space again to drop the item in its new position, or press escape to cancel.
|
|
552
552
|
`},Ey={onDragStart(t){let{active:e}=t;return"Picked up draggable item "+e.id+"."},onDragOver(t){let{active:e,over:s}=t;return s?"Draggable item "+e.id+" was moved over droppable area "+s.id+".":"Draggable item "+e.id+" is no longer over a droppable area."},onDragEnd(t){let{active:e,over:s}=t;return s?"Draggable item "+e.id+" was dropped over droppable area "+s.id:"Draggable item "+e.id+" was dropped."},onDragCancel(t){let{active:e}=t;return"Dragging was cancelled. Draggable item "+e.id+" was dropped."}};function Iy(t){let{announcements:e=Ey,container:s,hiddenTextDescribedById:i,screenReaderInstructions:r=Ay}=t;const{announce:o,announcement:a}=ky(),l=ir("DndLiveRegion"),[c,d]=S.useState(!1);if(S.useEffect(()=>{d(!0)},[]),jy(S.useMemo(()=>({onDragStart(h){let{active:f}=h;o(e.onDragStart({active:f}))},onDragMove(h){let{active:f,over:m}=h;e.onDragMove&&o(e.onDragMove({active:f,over:m}))},onDragOver(h){let{active:f,over:m}=h;o(e.onDragOver({active:f,over:m}))},onDragEnd(h){let{active:f,over:m}=h;o(e.onDragEnd({active:f,over:m}))},onDragCancel(h){let{active:f,over:m}=h;o(e.onDragCancel({active:f,over:m}))}}),[o,e])),!c)return null;const u=Ut.createElement(Ut.Fragment,null,Ut.createElement(Vy,{id:i,value:r.draggable}),Ut.createElement(Cy,{id:l,announcement:a}));return s?ms.createPortal(u,s):u}var lt;(function(t){t.DragStart="dragStart",t.DragMove="dragMove",t.DragEnd="dragEnd",t.DragCancel="dragCancel",t.DragOver="dragOver",t.RegisterDroppable="registerDroppable",t.SetDroppableDisabled="setDroppableDisabled",t.UnregisterDroppable="unregisterDroppable"})(lt||(lt={}));function Yr(){}function ad(t,e){return S.useMemo(()=>({sensor:t,options:e??{}}),[t,e])}function Ry(){for(var t=arguments.length,e=new Array(t),s=0;s<t;s++)e[s]=arguments[s];return S.useMemo(()=>[...e].filter(i=>i!=null),[...e])}const xs=Object.freeze({x:0,y:0});function vf(t,e){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function bf(t,e){let{data:{value:s}}=t,{data:{value:i}}=e;return s-i}function Ty(t,e){let{data:{value:s}}=t,{data:{value:i}}=e;return i-s}function ld(t){let{left:e,top:s,height:i,width:r}=t;return[{x:e,y:s},{x:e+r,y:s},{x:e,y:s+i},{x:e+r,y:s+i}]}function yf(t,e){if(!t||t.length===0)return null;const[s]=t;return s[e]}function cd(t,e,s){return e===void 0&&(e=t.left),s===void 0&&(s=t.top),{x:e+t.width*.5,y:s+t.height*.5}}const Dy=t=>{let{collisionRect:e,droppableRects:s,droppableContainers:i}=t;const r=cd(e,e.left,e.top),o=[];for(const a of i){const{id:l}=a,c=s.get(l);if(c){const d=vf(cd(c),r);o.push({id:l,data:{droppableContainer:a,value:d}})}}return o.sort(bf)},My=t=>{let{collisionRect:e,droppableRects:s,droppableContainers:i}=t;const r=ld(e),o=[];for(const a of i){const{id:l}=a,c=s.get(l);if(c){const d=ld(c),u=r.reduce((f,m,p)=>f+vf(d[p],m),0),h=Number((u/4).toFixed(4));o.push({id:l,data:{droppableContainer:a,value:h}})}}return o.sort(bf)};function Py(t,e){const s=Math.max(e.top,t.top),i=Math.max(e.left,t.left),r=Math.min(e.left+e.width,t.left+t.width),o=Math.min(e.top+e.height,t.top+t.height),a=r-i,l=o-s;if(i<r&&s<o){const c=e.width*e.height,d=t.width*t.height,u=a*l,h=u/(c+d-u);return Number(h.toFixed(4))}return 0}const Ly=t=>{let{collisionRect:e,droppableRects:s,droppableContainers:i}=t;const r=[];for(const o of i){const{id:a}=o,l=s.get(a);if(l){const c=Py(l,e);c>0&&r.push({id:a,data:{droppableContainer:o,value:c}})}}return r.sort(Ty)};function Oy(t,e,s){return{...t,scaleX:e&&s?e.width/s.width:1,scaleY:e&&s?e.height/s.height:1}}function Sf(t,e){return t&&e?{x:t.left-e.left,y:t.top-e.top}:xs}function By(t){return function(s){for(var i=arguments.length,r=new Array(i>1?i-1:0),o=1;o<i;o++)r[o-1]=arguments[o];return r.reduce((a,l)=>({...a,top:a.top+t*l.y,bottom:a.bottom+t*l.y,left:a.left+t*l.x,right:a.right+t*l.x}),{...s})}}const $y=By(1);function zy(t){if(t.startsWith("matrix3d(")){const e=t.slice(9,-1).split(/, /);return{x:+e[12],y:+e[13],scaleX:+e[0],scaleY:+e[5]}}else if(t.startsWith("matrix(")){const e=t.slice(7,-1).split(/, /);return{x:+e[4],y:+e[5],scaleX:+e[0],scaleY:+e[3]}}return null}function Fy(t,e,s){const i=zy(e);if(!i)return t;const{scaleX:r,scaleY:o,x:a,y:l}=i,c=t.left-a-(1-r)*parseFloat(s),d=t.top-l-(1-o)*parseFloat(s.slice(s.indexOf(" ")+1)),u=r?t.width/r:t.width,h=o?t.height/o:t.height;return{width:u,height:h,top:d,right:c+u,bottom:d+h,left:c}}const Uy={ignoreTransform:!1};function Qi(t,e){e===void 0&&(e=Uy);let s=t.getBoundingClientRect();if(e.ignoreTransform){const{transform:d,transformOrigin:u}=Wt(t).getComputedStyle(t);d&&(s=Fy(s,d,u))}const{top:i,left:r,width:o,height:a,bottom:l,right:c}=s;return{top:i,left:r,width:o,height:a,bottom:l,right:c}}function dd(t){return Qi(t,{ignoreTransform:!0})}function Hy(t){const e=t.innerWidth,s=t.innerHeight;return{top:0,left:0,right:e,bottom:s,width:e,height:s}}function Wy(t,e){return e===void 0&&(e=Wt(t).getComputedStyle(t)),e.position==="fixed"}function Ky(t,e){e===void 0&&(e=Wt(t).getComputedStyle(t));const s=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(r=>{const o=e[r];return typeof o=="string"?s.test(o):!1})}function vo(t,e){const s=[];function i(r){if(e!=null&&s.length>=e||!r)return s;if(Hl(r)&&r.scrollingElement!=null&&!s.includes(r.scrollingElement))return s.push(r.scrollingElement),s;if(!tr(r)||gf(r)||s.includes(r))return s;const o=Wt(t).getComputedStyle(r);return r!==t&&Ky(r,o)&&s.push(r),Wy(r,o)?s:i(r.parentNode)}return t?i(t):s}function wf(t){const[e]=vo(t,1);return e??null}function $o(t){return!xo||!t?null:Xi(t)?t:Ul(t)?Hl(t)||t===Ji(t).scrollingElement?window:tr(t)?t:null:null}function Vf(t){return Xi(t)?t.scrollX:t.scrollLeft}function Cf(t){return Xi(t)?t.scrollY:t.scrollTop}function ka(t){return{x:Vf(t),y:Cf(t)}}var ut;(function(t){t[t.Forward=1]="Forward",t[t.Backward=-1]="Backward"})(ut||(ut={}));function kf(t){return!xo||!t?!1:t===document.scrollingElement}function jf(t){const e={x:0,y:0},s=kf(t)?{height:window.innerHeight,width:window.innerWidth}:{height:t.clientHeight,width:t.clientWidth},i={x:t.scrollWidth-s.width,y:t.scrollHeight-s.height},r=t.scrollTop<=e.y,o=t.scrollLeft<=e.x,a=t.scrollTop>=i.y,l=t.scrollLeft>=i.x;return{isTop:r,isLeft:o,isBottom:a,isRight:l,maxScroll:i,minScroll:e}}const qy={x:.2,y:.2};function Gy(t,e,s,i,r){let{top:o,left:a,right:l,bottom:c}=s;i===void 0&&(i=10),r===void 0&&(r=qy);const{isTop:d,isBottom:u,isLeft:h,isRight:f}=jf(t),m={x:0,y:0},p={x:0,y:0},g={height:e.height*r.y,width:e.width*r.x};return!d&&o<=e.top+g.height?(m.y=ut.Backward,p.y=i*Math.abs((e.top+g.height-o)/g.height)):!u&&c>=e.bottom-g.height&&(m.y=ut.Forward,p.y=i*Math.abs((e.bottom-g.height-c)/g.height)),!f&&l>=e.right-g.width?(m.x=ut.Forward,p.x=i*Math.abs((e.right-g.width-l)/g.width)):!h&&a<=e.left+g.width&&(m.x=ut.Backward,p.x=i*Math.abs((e.left+g.width-a)/g.width)),{direction:m,speed:p}}function Yy(t){if(t===document.scrollingElement){const{innerWidth:o,innerHeight:a}=window;return{top:0,left:0,right:o,bottom:a,width:o,height:a}}const{top:e,left:s,right:i,bottom:r}=t.getBoundingClientRect();return{top:e,left:s,right:i,bottom:r,width:t.clientWidth,height:t.clientHeight}}function Nf(t){return t.reduce((e,s)=>Oi(e,ka(s)),xs)}function Xy(t){return t.reduce((e,s)=>e+Vf(s),0)}function Jy(t){return t.reduce((e,s)=>e+Cf(s),0)}function Qy(t,e){if(e===void 0&&(e=Qi),!t)return;const{top:s,left:i,bottom:r,right:o}=e(t);wf(t)&&(r<=0||o<=0||s>=window.innerHeight||i>=window.innerWidth)&&t.scrollIntoView({block:"center",inline:"center"})}const Zy=[["x",["left","right"],Xy],["y",["top","bottom"],Jy]];class ql{constructor(e,s){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const i=vo(s),r=Nf(i);this.rect={...e},this.width=e.width,this.height=e.height;for(const[o,a,l]of Zy)for(const c of a)Object.defineProperty(this,c,{get:()=>{const d=l(i),u=r[o]-d;return this.rect[c]+u},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class Cn{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(s=>{var i;return(i=this.target)==null?void 0:i.removeEventListener(...s)})},this.target=e}add(e,s,i){var r;(r=this.target)==null||r.addEventListener(e,s,i),this.listeners.push([e,s,i])}}function e2(t){const{EventTarget:e}=Wt(t);return t instanceof e?t:Ji(t)}function zo(t,e){const s=Math.abs(t.x),i=Math.abs(t.y);return typeof e=="number"?Math.sqrt(s**2+i**2)>e:"x"in e&&"y"in e?s>e.x&&i>e.y:"x"in e?s>e.x:"y"in e?i>e.y:!1}var as;(function(t){t.Click="click",t.DragStart="dragstart",t.Keydown="keydown",t.ContextMenu="contextmenu",t.Resize="resize",t.SelectionChange="selectionchange",t.VisibilityChange="visibilitychange"})(as||(as={}));function hd(t){t.preventDefault()}function t2(t){t.stopPropagation()}var je;(function(t){t.Space="Space",t.Down="ArrowDown",t.Right="ArrowRight",t.Left="ArrowLeft",t.Up="ArrowUp",t.Esc="Escape",t.Enter="Enter",t.Tab="Tab"})(je||(je={}));const Af={start:[je.Space,je.Enter],cancel:[je.Esc],end:[je.Space,je.Enter,je.Tab]},s2=(t,e)=>{let{currentCoordinates:s}=e;switch(t.code){case je.Right:return{...s,x:s.x+25};case je.Left:return{...s,x:s.x-25};case je.Down:return{...s,y:s.y+25};case je.Up:return{...s,y:s.y-25}}};class Gl{constructor(e){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=e;const{event:{target:s}}=e;this.props=e,this.listeners=new Cn(Ji(s)),this.windowListeners=new Cn(Wt(s)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(as.Resize,this.handleCancel),this.windowListeners.add(as.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(as.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:e,onStart:s}=this.props,i=e.node.current;i&&Qy(i),s(xs)}handleKeyDown(e){if(Kl(e)){const{active:s,context:i,options:r}=this.props,{keyboardCodes:o=Af,coordinateGetter:a=s2,scrollBehavior:l="smooth"}=r,{code:c}=e;if(o.end.includes(c)){this.handleEnd(e);return}if(o.cancel.includes(c)){this.handleCancel(e);return}const{collisionRect:d}=i.current,u=d?{x:d.left,y:d.top}:xs;this.referenceCoordinates||(this.referenceCoordinates=u);const h=a(e,{active:s,context:i.current,currentCoordinates:u});if(h){const f=Pn(h,u),m={x:0,y:0},{scrollableAncestors:p}=i.current;for(const g of p){const _=e.code,{isTop:v,isRight:x,isLeft:b,isBottom:y,maxScroll:C,minScroll:k}=jf(g),w=Yy(g),V={x:Math.min(_===je.Right?w.right-w.width/2:w.right,Math.max(_===je.Right?w.left:w.left+w.width/2,h.x)),y:Math.min(_===je.Down?w.bottom-w.height/2:w.bottom,Math.max(_===je.Down?w.top:w.top+w.height/2,h.y))},j=_===je.Right&&!x||_===je.Left&&!b,I=_===je.Down&&!y||_===je.Up&&!v;if(j&&V.x!==h.x){const T=g.scrollLeft+f.x,R=_===je.Right&&T<=C.x||_===je.Left&&T>=k.x;if(R&&!f.y){g.scrollTo({left:T,behavior:l});return}R?m.x=g.scrollLeft-T:m.x=_===je.Right?g.scrollLeft-C.x:g.scrollLeft-k.x,m.x&&g.scrollBy({left:-m.x,behavior:l});break}else if(I&&V.y!==h.y){const T=g.scrollTop+f.y,R=_===je.Down&&T<=C.y||_===je.Up&&T>=k.y;if(R&&!f.x){g.scrollTo({top:T,behavior:l});return}R?m.y=g.scrollTop-T:m.y=_===je.Down?g.scrollTop-C.y:g.scrollTop-k.y,m.y&&g.scrollBy({top:-m.y,behavior:l});break}}this.handleMove(e,Oi(Pn(h,this.referenceCoordinates),m))}}}handleMove(e,s){const{onMove:i}=this.props;e.preventDefault(),i(s)}handleEnd(e){const{onEnd:s}=this.props;e.preventDefault(),this.detach(),s()}handleCancel(e){const{onCancel:s}=this.props;e.preventDefault(),this.detach(),s()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}Gl.activators=[{eventName:"onKeyDown",handler:(t,e,s)=>{let{keyboardCodes:i=Af,onActivation:r}=e,{active:o}=s;const{code:a}=t.nativeEvent;if(i.start.includes(a)){const l=o.activatorNode.current;return l&&t.target!==l?!1:(t.preventDefault(),r?.({event:t.nativeEvent}),!0)}return!1}}];function ud(t){return!!(t&&"distance"in t)}function fd(t){return!!(t&&"delay"in t)}class Yl{constructor(e,s,i){var r;i===void 0&&(i=e2(e.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=e,this.events=s;const{event:o}=e,{target:a}=o;this.props=e,this.events=s,this.document=Ji(a),this.documentListeners=new Cn(this.document),this.listeners=new Cn(i),this.windowListeners=new Cn(Wt(a)),this.initialCoordinates=(r=Ca(o))!=null?r:xs,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:e,props:{options:{activationConstraint:s,bypassActivationConstraint:i}}}=this;if(this.listeners.add(e.move.name,this.handleMove,{passive:!1}),this.listeners.add(e.end.name,this.handleEnd),e.cancel&&this.listeners.add(e.cancel.name,this.handleCancel),this.windowListeners.add(as.Resize,this.handleCancel),this.windowListeners.add(as.DragStart,hd),this.windowListeners.add(as.VisibilityChange,this.handleCancel),this.windowListeners.add(as.ContextMenu,hd),this.documentListeners.add(as.Keydown,this.handleKeydown),s){if(i!=null&&i({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(fd(s)){this.timeoutId=setTimeout(this.handleStart,s.delay),this.handlePending(s);return}if(ud(s)){this.handlePending(s);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(e,s){const{active:i,onPending:r}=this.props;r(i,e,this.initialCoordinates,s)}handleStart(){const{initialCoordinates:e}=this,{onStart:s}=this.props;e&&(this.activated=!0,this.documentListeners.add(as.Click,t2,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(as.SelectionChange,this.removeTextSelection),s(e))}handleMove(e){var s;const{activated:i,initialCoordinates:r,props:o}=this,{onMove:a,options:{activationConstraint:l}}=o;if(!r)return;const c=(s=Ca(e))!=null?s:xs,d=Pn(r,c);if(!i&&l){if(ud(l)){if(l.tolerance!=null&&zo(d,l.tolerance))return this.handleCancel();if(zo(d,l.distance))return this.handleStart()}if(fd(l)&&zo(d,l.tolerance))return this.handleCancel();this.handlePending(l,d);return}e.cancelable&&e.preventDefault(),a(c)}handleEnd(){const{onAbort:e,onEnd:s}=this.props;this.detach(),this.activated||e(this.props.active),s()}handleCancel(){const{onAbort:e,onCancel:s}=this.props;this.detach(),this.activated||e(this.props.active),s()}handleKeydown(e){e.code===je.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}}const i2={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class Xl extends Yl{constructor(e){const{event:s}=e,i=Ji(s.target);super(e,i2,i)}}Xl.activators=[{eventName:"onPointerDown",handler:(t,e)=>{let{nativeEvent:s}=t,{onActivation:i}=e;return!s.isPrimary||s.button!==0?!1:(i?.({event:s}),!0)}}];const n2={move:{name:"mousemove"},end:{name:"mouseup"}};var ja;(function(t){t[t.RightClick=2]="RightClick"})(ja||(ja={}));class r2 extends Yl{constructor(e){super(e,n2,Ji(e.event.target))}}r2.activators=[{eventName:"onMouseDown",handler:(t,e)=>{let{nativeEvent:s}=t,{onActivation:i}=e;return s.button===ja.RightClick?!1:(i?.({event:s}),!0)}}];const Fo={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class o2 extends Yl{constructor(e){super(e,Fo)}static setup(){return window.addEventListener(Fo.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(Fo.move.name,e)};function e(){}}}o2.activators=[{eventName:"onTouchStart",handler:(t,e)=>{let{nativeEvent:s}=t,{onActivation:i}=e;const{touches:r}=s;return r.length>1?!1:(i?.({event:s}),!0)}}];var kn;(function(t){t[t.Pointer=0]="Pointer",t[t.DraggableRect=1]="DraggableRect"})(kn||(kn={}));var Xr;(function(t){t[t.TreeOrder=0]="TreeOrder",t[t.ReversedTreeOrder=1]="ReversedTreeOrder"})(Xr||(Xr={}));function a2(t){let{acceleration:e,activator:s=kn.Pointer,canScroll:i,draggingRect:r,enabled:o,interval:a=5,order:l=Xr.TreeOrder,pointerCoordinates:c,scrollableAncestors:d,scrollableAncestorRects:u,delta:h,threshold:f}=t;const m=c2({delta:h,disabled:!o}),[p,g]=vy(),_=S.useRef({x:0,y:0}),v=S.useRef({x:0,y:0}),x=S.useMemo(()=>{switch(s){case kn.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case kn.DraggableRect:return r}},[s,r,c]),b=S.useRef(null),y=S.useCallback(()=>{const k=b.current;if(!k)return;const w=_.current.x*v.current.x,V=_.current.y*v.current.y;k.scrollBy(w,V)},[]),C=S.useMemo(()=>l===Xr.TreeOrder?[...d].reverse():d,[l,d]);S.useEffect(()=>{if(!o||!d.length||!x){g();return}for(const k of C){if(i?.(k)===!1)continue;const w=d.indexOf(k),V=u[w];if(!V)continue;const{direction:j,speed:I}=Gy(k,V,x,e,f);for(const T of["x","y"])m[T][j[T]]||(I[T]=0,j[T]=0);if(I.x>0||I.y>0){g(),b.current=k,p(y,a),_.current=I,v.current=j;return}}_.current={x:0,y:0},v.current={x:0,y:0},g()},[e,y,i,g,o,a,JSON.stringify(x),JSON.stringify(m),p,d,C,u,JSON.stringify(f)])}const l2={x:{[ut.Backward]:!1,[ut.Forward]:!1},y:{[ut.Backward]:!1,[ut.Forward]:!1}};function c2(t){let{delta:e,disabled:s}=t;const i=Va(e);return sr(r=>{if(s||!i||!r)return l2;const o={x:Math.sign(e.x-i.x),y:Math.sign(e.y-i.y)};return{x:{[ut.Backward]:r.x[ut.Backward]||o.x===-1,[ut.Forward]:r.x[ut.Forward]||o.x===1},y:{[ut.Backward]:r.y[ut.Backward]||o.y===-1,[ut.Forward]:r.y[ut.Forward]||o.y===1}}},[s,e,i])}function d2(t,e){const s=e!=null?t.get(e):void 0,i=s?s.node.current:null;return sr(r=>{var o;return e==null?null:(o=i??r)!=null?o:null},[i,e])}function h2(t,e){return S.useMemo(()=>t.reduce((s,i)=>{const{sensor:r}=i,o=r.activators.map(a=>({eventName:a.eventName,handler:e(a.handler,i)}));return[...s,...o]},[]),[t,e])}var On;(function(t){t[t.Always=0]="Always",t[t.BeforeDragging=1]="BeforeDragging",t[t.WhileDragging=2]="WhileDragging"})(On||(On={}));var Na;(function(t){t.Optimized="optimized"})(Na||(Na={}));const md=new Map;function u2(t,e){let{dragging:s,dependencies:i,config:r}=e;const[o,a]=S.useState(null),{frequency:l,measure:c,strategy:d}=r,u=S.useRef(t),h=_(),f=Mn(h),m=S.useCallback(function(v){v===void 0&&(v=[]),!f.current&&a(x=>x===null?v:x.concat(v.filter(b=>!x.includes(b))))},[f]),p=S.useRef(null),g=sr(v=>{if(h&&!s)return md;if(!v||v===md||u.current!==t||o!=null){const x=new Map;for(let b of t){if(!b)continue;if(o&&o.length>0&&!o.includes(b.id)&&b.rect.current){x.set(b.id,b.rect.current);continue}const y=b.node.current,C=y?new ql(c(y),y):null;b.rect.current=C,C&&x.set(b.id,C)}return x}return v},[t,o,s,h,c]);return S.useEffect(()=>{u.current=t},[t]),S.useEffect(()=>{h||m()},[s,h]),S.useEffect(()=>{o&&o.length>0&&a(null)},[JSON.stringify(o)]),S.useEffect(()=>{h||typeof l!="number"||p.current!==null||(p.current=setTimeout(()=>{m(),p.current=null},l))},[l,h,m,...i]),{droppableRects:g,measureDroppableContainers:m,measuringScheduled:o!=null};function _(){switch(d){case On.Always:return!1;case On.BeforeDragging:return s;default:return!s}}}function Ef(t,e){return sr(s=>t?s||(typeof e=="function"?e(t):t):null,[e,t])}function f2(t,e){return Ef(t,e)}function m2(t){let{callback:e,disabled:s}=t;const i=Wl(e),r=S.useMemo(()=>{if(s||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:o}=window;return new o(i)},[i,s]);return S.useEffect(()=>()=>r?.disconnect(),[r]),r}function bo(t){let{callback:e,disabled:s}=t;const i=Wl(e),r=S.useMemo(()=>{if(s||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:o}=window;return new o(i)},[s]);return S.useEffect(()=>()=>r?.disconnect(),[r]),r}function p2(t){return new ql(Qi(t),t)}function pd(t,e,s){e===void 0&&(e=p2);const[i,r]=S.useState(null);function o(){r(c=>{if(!t)return null;if(t.isConnected===!1){var d;return(d=c??s)!=null?d:null}const u=e(t);return JSON.stringify(c)===JSON.stringify(u)?c:u})}const a=m2({callback(c){if(t)for(const d of c){const{type:u,target:h}=d;if(u==="childList"&&h instanceof HTMLElement&&h.contains(t)){o();break}}}}),l=bo({callback:o});return Ds(()=>{o(),t?(l?.observe(t),a?.observe(document.body,{childList:!0,subtree:!0})):(l?.disconnect(),a?.disconnect())},[t]),i}function g2(t){const e=Ef(t);return Sf(t,e)}const gd=[];function _2(t){const e=S.useRef(t),s=sr(i=>t?i&&i!==gd&&t&&e.current&&t.parentNode===e.current.parentNode?i:vo(t):gd,[t]);return S.useEffect(()=>{e.current=t},[t]),s}function x2(t){const[e,s]=S.useState(null),i=S.useRef(t),r=S.useCallback(o=>{const a=$o(o.target);a&&s(l=>l?(l.set(a,ka(a)),new Map(l)):null)},[]);return S.useEffect(()=>{const o=i.current;if(t!==o){a(o);const l=t.map(c=>{const d=$o(c);return d?(d.addEventListener("scroll",r,{passive:!0}),[d,ka(d)]):null}).filter(c=>c!=null);s(l.length?new Map(l):null),i.current=t}return()=>{a(t),a(o)};function a(l){l.forEach(c=>{const d=$o(c);d?.removeEventListener("scroll",r)})}},[r,t]),S.useMemo(()=>t.length?e?Array.from(e.values()).reduce((o,a)=>Oi(o,a),xs):Nf(t):xs,[t,e])}function _d(t,e){e===void 0&&(e=[]);const s=S.useRef(null);return S.useEffect(()=>{s.current=null},e),S.useEffect(()=>{const i=t!==xs;i&&!s.current&&(s.current=t),!i&&s.current&&(s.current=null)},[t]),s.current?Pn(t,s.current):xs}function v2(t){S.useEffect(()=>{if(!xo)return;const e=t.map(s=>{let{sensor:i}=s;return i.setup==null?void 0:i.setup()});return()=>{for(const s of e)s?.()}},t.map(e=>{let{sensor:s}=e;return s}))}function b2(t,e){return S.useMemo(()=>t.reduce((s,i)=>{let{eventName:r,handler:o}=i;return s[r]=a=>{o(a,e)},s},{}),[t,e])}function If(t){return S.useMemo(()=>t?Hy(t):null,[t])}const xd=[];function y2(t,e){e===void 0&&(e=Qi);const[s]=t,i=If(s?Wt(s):null),[r,o]=S.useState(xd);function a(){o(()=>t.length?t.map(c=>kf(c)?i:new ql(e(c),c)):xd)}const l=bo({callback:a});return Ds(()=>{l?.disconnect(),a(),t.forEach(c=>l?.observe(c))},[t]),r}function S2(t){if(!t)return null;if(t.children.length>1)return t;const e=t.children[0];return tr(e)?e:t}function w2(t){let{measure:e}=t;const[s,i]=S.useState(null),r=S.useCallback(d=>{for(const{target:u}of d)if(tr(u)){i(h=>{const f=e(u);return h?{...h,width:f.width,height:f.height}:f});break}},[e]),o=bo({callback:r}),a=S.useCallback(d=>{const u=S2(d);o?.disconnect(),u&&o?.observe(u),i(u?e(u):null)},[e,o]),[l,c]=Gr(a);return S.useMemo(()=>({nodeRef:l,rect:s,setRef:c}),[s,l,c])}const V2=[{sensor:Xl,options:{}},{sensor:Gl,options:{}}],C2={current:{}},Ir={draggable:{measure:dd},droppable:{measure:dd,strategy:On.WhileDragging,frequency:Na.Optimized},dragOverlay:{measure:Qi}};class jn extends Map{get(e){var s;return e!=null&&(s=super.get(e))!=null?s:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(e=>{let{disabled:s}=e;return!s})}getNodeFor(e){var s,i;return(s=(i=this.get(e))==null?void 0:i.node.current)!=null?s:void 0}}const k2={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new jn,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:Yr},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Ir,measureDroppableContainers:Yr,windowRect:null,measuringScheduled:!1},j2={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:Yr,draggableNodes:new Map,over:null,measureDroppableContainers:Yr},yo=S.createContext(j2),Rf=S.createContext(k2);function N2(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new jn}}}function A2(t,e){switch(e.type){case lt.DragStart:return{...t,draggable:{...t.draggable,initialCoordinates:e.initialCoordinates,active:e.active}};case lt.DragMove:return t.draggable.active==null?t:{...t,draggable:{...t.draggable,translate:{x:e.coordinates.x-t.draggable.initialCoordinates.x,y:e.coordinates.y-t.draggable.initialCoordinates.y}}};case lt.DragEnd:case lt.DragCancel:return{...t,draggable:{...t.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case lt.RegisterDroppable:{const{element:s}=e,{id:i}=s,r=new jn(t.droppable.containers);return r.set(i,s),{...t,droppable:{...t.droppable,containers:r}}}case lt.SetDroppableDisabled:{const{id:s,key:i,disabled:r}=e,o=t.droppable.containers.get(s);if(!o||i!==o.key)return t;const a=new jn(t.droppable.containers);return a.set(s,{...o,disabled:r}),{...t,droppable:{...t.droppable,containers:a}}}case lt.UnregisterDroppable:{const{id:s,key:i}=e,r=t.droppable.containers.get(s);if(!r||i!==r.key)return t;const o=new jn(t.droppable.containers);return o.delete(s),{...t,droppable:{...t.droppable,containers:o}}}default:return t}}function E2(t){let{disabled:e}=t;const{active:s,activatorEvent:i,draggableNodes:r}=S.useContext(yo),o=Va(i),a=Va(s?.id);return S.useEffect(()=>{if(!e&&!i&&o&&a!=null){if(!Kl(o)||document.activeElement===o.target)return;const l=r.get(a);if(!l)return;const{activatorNode:c,node:d}=l;if(!c.current&&!d.current)return;requestAnimationFrame(()=>{for(const u of[c.current,d.current]){if(!u)continue;const h=Sy(u);if(h){h.focus();break}}})}},[i,e,r,a,o]),null}function I2(t,e){let{transform:s,...i}=e;return t!=null&&t.length?t.reduce((r,o)=>o({transform:r,...i}),s):s}function R2(t){return S.useMemo(()=>({draggable:{...Ir.draggable,...t?.draggable},droppable:{...Ir.droppable,...t?.droppable},dragOverlay:{...Ir.dragOverlay,...t?.dragOverlay}}),[t?.draggable,t?.droppable,t?.dragOverlay])}function T2(t){let{activeNode:e,measure:s,initialRect:i,config:r=!0}=t;const o=S.useRef(!1),{x:a,y:l}=typeof r=="boolean"?{x:r,y:r}:r;Ds(()=>{if(!a&&!l||!e){o.current=!1;return}if(o.current||!i)return;const d=e?.node.current;if(!d||d.isConnected===!1)return;const u=s(d),h=Sf(u,i);if(a||(h.x=0),l||(h.y=0),o.current=!0,Math.abs(h.x)>0||Math.abs(h.y)>0){const f=wf(d);f&&f.scrollBy({top:h.y,left:h.x})}},[e,a,l,i,s])}const Tf=S.createContext({...xs,scaleX:1,scaleY:1});var Ys;(function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Initializing=1]="Initializing",t[t.Initialized=2]="Initialized"})(Ys||(Ys={}));const D2=S.memo(function(e){var s,i,r,o;let{id:a,accessibility:l,autoScroll:c=!0,children:d,sensors:u=V2,collisionDetection:h=Ly,measuring:f,modifiers:m,...p}=e;const g=S.useReducer(A2,void 0,N2),[_,v]=g,[x,b]=Ny(),[y,C]=S.useState(Ys.Uninitialized),k=y===Ys.Initialized,{draggable:{active:w,nodes:V,translate:j},droppable:{containers:I}}=_,T=w!=null?V.get(w):null,R=S.useRef({initial:null,translated:null}),N=S.useMemo(()=>{var Re;return w!=null?{id:w,data:(Re=T?.data)!=null?Re:C2,rect:R}:null},[w,T]),A=S.useRef(null),[E,M]=S.useState(null),[L,D]=S.useState(null),P=Mn(p,Object.values(p)),O=ir("DndDescribedBy",a),z=S.useMemo(()=>I.getEnabled(),[I]),$=R2(f),{droppableRects:q,measureDroppableContainers:F,measuringScheduled:G}=u2(z,{dragging:k,dependencies:[j.x,j.y],config:$.droppable}),H=d2(V,w),U=S.useMemo(()=>L?Ca(L):null,[L]),Y=kt(),W=f2(H,$.draggable.measure);T2({activeNode:w!=null?V.get(w):null,config:Y.layoutShiftCompensation,initialRect:W,measure:$.draggable.measure});const K=pd(H,$.draggable.measure,W),ee=pd(H?H.parentElement:null),Z=S.useRef({activatorEvent:null,active:null,activeNode:H,collisionRect:null,collisions:null,droppableRects:q,draggableNodes:V,draggingNode:null,draggingNodeRect:null,droppableContainers:I,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),X=I.getNodeFor((s=Z.current.over)==null?void 0:s.id),ie=w2({measure:$.dragOverlay.measure}),re=(i=ie.nodeRef.current)!=null?i:H,de=k?(r=ie.rect)!=null?r:K:null,me=!!(ie.nodeRef.current&&ie.rect),le=g2(me?null:K),se=If(re?Wt(re):null),_e=_2(k?X??H:null),ge=y2(_e),Se=I2(m,{transform:{x:j.x-le.x,y:j.y-le.y,scaleX:1,scaleY:1},activatorEvent:L,active:N,activeNodeRect:K,containerNodeRect:ee,draggingNodeRect:de,over:Z.current.over,overlayNodeRect:ie.rect,scrollableAncestors:_e,scrollableAncestorRects:ge,windowRect:se}),ve=U?Oi(U,j):null,Ne=x2(_e),Te=_d(Ne),te=_d(Ne,[K]),he=Oi(Se,Te),we=de?$y(de,Se):null,Ee=N&&we?h({active:N,collisionRect:we,droppableRects:q,droppableContainers:z,pointerCoordinates:ve}):null,Ie=yf(Ee,"id"),[De,Pe]=S.useState(null),ye=me?Se:Oi(Se,te),Ae=Oy(ye,(o=De?.rect)!=null?o:null,K),fe=S.useRef(null),ke=S.useCallback((Re,Le)=>{let{sensor:Ye,options:qt}=Le;if(A.current==null)return;const xt=V.get(A.current);if(!xt)return;const vt=Re.nativeEvent,bt=new Ye({active:A.current,activeNode:xt,event:vt,options:qt,context:Z,onAbort(Ue){if(!V.get(Ue))return;const{onDragAbort:Nt}=P.current,wt={id:Ue};Nt?.(wt),x({type:"onDragAbort",event:wt})},onPending(Ue,jt,Nt,wt){if(!V.get(Ue))return;const{onDragPending:$t}=P.current,zt={id:Ue,constraint:jt,initialCoordinates:Nt,offset:wt};$t?.(zt),x({type:"onDragPending",event:zt})},onStart(Ue){const jt=A.current;if(jt==null)return;const Nt=V.get(jt);if(!Nt)return;const{onDragStart:wt}=P.current,pe={activatorEvent:vt,active:{id:jt,data:Nt.data,rect:R}};ms.unstable_batchedUpdates(()=>{wt?.(pe),C(Ys.Initializing),v({type:lt.DragStart,initialCoordinates:Ue,active:jt}),x({type:"onDragStart",event:pe}),M(fe.current),D(vt)})},onMove(Ue){v({type:lt.DragMove,coordinates:Ue})},onEnd:bs(lt.DragEnd),onCancel:bs(lt.DragCancel)});fe.current=bt;function bs(Ue){return async function(){const{active:Nt,collisions:wt,over:pe,scrollAdjustedTranslate:$t}=Z.current;let zt=null;if(Nt&&$t){const{cancelDrop:us}=P.current;zt={activatorEvent:vt,active:Nt,collisions:wt,delta:$t,over:pe},Ue===lt.DragEnd&&typeof us=="function"&&await Promise.resolve(us(zt))&&(Ue=lt.DragCancel)}A.current=null,ms.unstable_batchedUpdates(()=>{v({type:Ue}),C(Ys.Uninitialized),Pe(null),M(null),D(null),fe.current=null;const us=Ue===lt.DragEnd?"onDragEnd":"onDragCancel";if(zt){const sn=P.current[us];sn?.(zt),x({type:us,event:zt})}})}}},[V]),Ze=S.useCallback((Re,Le)=>(Ye,qt)=>{const xt=Ye.nativeEvent,vt=V.get(qt);if(A.current!==null||!vt||xt.dndKit||xt.defaultPrevented)return;const bt={active:vt};Re(Ye,Le.options,bt)===!0&&(xt.dndKit={capturedBy:Le.sensor},A.current=qt,ke(Ye,Le))},[V,ke]),Ct=h2(u,Ze);v2(u),Ds(()=>{K&&y===Ys.Initializing&&C(Ys.Initialized)},[K,y]),S.useEffect(()=>{const{onDragMove:Re}=P.current,{active:Le,activatorEvent:Ye,collisions:qt,over:xt}=Z.current;if(!Le||!Ye)return;const vt={active:Le,activatorEvent:Ye,collisions:qt,delta:{x:he.x,y:he.y},over:xt};ms.unstable_batchedUpdates(()=>{Re?.(vt),x({type:"onDragMove",event:vt})})},[he.x,he.y]),S.useEffect(()=>{const{active:Re,activatorEvent:Le,collisions:Ye,droppableContainers:qt,scrollAdjustedTranslate:xt}=Z.current;if(!Re||A.current==null||!Le||!xt)return;const{onDragOver:vt}=P.current,bt=qt.get(Ie),bs=bt&&bt.rect.current?{id:bt.id,rect:bt.rect.current,data:bt.data,disabled:bt.disabled}:null,Ue={active:Re,activatorEvent:Le,collisions:Ye,delta:{x:xt.x,y:xt.y},over:bs};ms.unstable_batchedUpdates(()=>{Pe(bs),vt?.(Ue),x({type:"onDragOver",event:Ue})})},[Ie]),Ds(()=>{Z.current={activatorEvent:L,active:N,activeNode:H,collisionRect:we,collisions:Ee,droppableRects:q,draggableNodes:V,draggingNode:re,draggingNodeRect:de,droppableContainers:I,over:De,scrollableAncestors:_e,scrollAdjustedTranslate:he},R.current={initial:de,translated:we}},[N,H,Ee,we,V,re,de,q,I,De,_e,he]),a2({...Y,delta:j,draggingRect:we,pointerCoordinates:ve,scrollableAncestors:_e,scrollableAncestorRects:ge});const ze=S.useMemo(()=>({active:N,activeNode:H,activeNodeRect:K,activatorEvent:L,collisions:Ee,containerNodeRect:ee,dragOverlay:ie,draggableNodes:V,droppableContainers:I,droppableRects:q,over:De,measureDroppableContainers:F,scrollableAncestors:_e,scrollableAncestorRects:ge,measuringConfiguration:$,measuringScheduled:G,windowRect:se}),[N,H,K,L,Ee,ee,ie,V,I,q,De,F,_e,ge,$,G,se]),Kt=S.useMemo(()=>({activatorEvent:L,activators:Ct,active:N,activeNodeRect:K,ariaDescribedById:{draggable:O},dispatch:v,draggableNodes:V,over:De,measureDroppableContainers:F}),[L,Ct,N,K,v,O,V,De,F]);return Ut.createElement(xf.Provider,{value:b},Ut.createElement(yo.Provider,{value:Kt},Ut.createElement(Rf.Provider,{value:ze},Ut.createElement(Tf.Provider,{value:Ae},d)),Ut.createElement(E2,{disabled:l?.restoreFocus===!1})),Ut.createElement(Iy,{...l,hiddenTextDescribedById:O}));function kt(){const Re=E?.autoScrollEnabled===!1,Le=typeof c=="object"?c.enabled===!1:c===!1,Ye=k&&!Re&&!Le;return typeof c=="object"?{...c,enabled:Ye}:{enabled:Ye}}}),M2=S.createContext(null),vd="button",P2="Draggable";function L2(t){let{id:e,data:s,disabled:i=!1,attributes:r}=t;const o=ir(P2),{activators:a,activatorEvent:l,active:c,activeNodeRect:d,ariaDescribedById:u,draggableNodes:h,over:f}=S.useContext(yo),{role:m=vd,roleDescription:p="draggable",tabIndex:g=0}=r??{},_=c?.id===e,v=S.useContext(_?Tf:M2),[x,b]=Gr(),[y,C]=Gr(),k=b2(a,e),w=Mn(s);Ds(()=>(h.set(e,{id:e,key:o,node:x,activatorNode:y,data:w}),()=>{const j=h.get(e);j&&j.key===o&&h.delete(e)}),[h,e]);const V=S.useMemo(()=>({role:m,tabIndex:g,"aria-disabled":i,"aria-pressed":_&&m===vd?!0:void 0,"aria-roledescription":p,"aria-describedby":u.draggable}),[i,m,g,_,p,u.draggable]);return{active:c,activatorEvent:l,activeNodeRect:d,attributes:V,isDragging:_,listeners:i?void 0:k,node:x,over:f,setNodeRef:b,setActivatorNodeRef:C,transform:v}}function O2(){return S.useContext(Rf)}const B2="Droppable",$2={timeout:25};function z2(t){let{data:e,disabled:s=!1,id:i,resizeObserverConfig:r}=t;const o=ir(B2),{active:a,dispatch:l,over:c,measureDroppableContainers:d}=S.useContext(yo),u=S.useRef({disabled:s}),h=S.useRef(!1),f=S.useRef(null),m=S.useRef(null),{disabled:p,updateMeasurementsFor:g,timeout:_}={...$2,...r},v=Mn(g??i),x=S.useCallback(()=>{if(!h.current){h.current=!0;return}m.current!=null&&clearTimeout(m.current),m.current=setTimeout(()=>{d(Array.isArray(v.current)?v.current:[v.current]),m.current=null},_)},[_]),b=bo({callback:x,disabled:p||!a}),y=S.useCallback((V,j)=>{b&&(j&&(b.unobserve(j),h.current=!1),V&&b.observe(V))},[b]),[C,k]=Gr(y),w=Mn(e);return S.useEffect(()=>{!b||!C.current||(b.disconnect(),h.current=!1,b.observe(C.current))},[C,b]),S.useEffect(()=>(l({type:lt.RegisterDroppable,element:{id:i,key:o,disabled:s,node:C,rect:f,data:w}}),()=>l({type:lt.UnregisterDroppable,key:o,id:i})),[i]),S.useEffect(()=>{s!==u.current.disabled&&(l({type:lt.SetDroppableDisabled,id:i,key:o,disabled:s}),u.current.disabled=s)},[i,o,s,l]),{active:a,rect:f,isOver:c?.id===i,node:C,over:c,setNodeRef:k}}function Jl(t,e,s){const i=t.slice();return i.splice(s<0?i.length+s:s,0,i.splice(e,1)[0]),i}function F2(t,e){return t.reduce((s,i,r)=>{const o=e.get(i);return o&&(s[r]=o),s},Array(t.length))}function fr(t){return t!==null&&t>=0}function U2(t,e){if(t===e)return!0;if(t.length!==e.length)return!1;for(let s=0;s<t.length;s++)if(t[s]!==e[s])return!1;return!0}function H2(t){return typeof t=="boolean"?{draggable:t,droppable:t}:t}const Df=t=>{let{rects:e,activeIndex:s,overIndex:i,index:r}=t;const o=Jl(e,i,s),a=e[r],l=o[r];return!l||!a?null:{x:l.left-a.left,y:l.top-a.top,scaleX:l.width/a.width,scaleY:l.height/a.height}},mr={scaleX:1,scaleY:1},W2=t=>{var e;let{activeIndex:s,activeNodeRect:i,index:r,rects:o,overIndex:a}=t;const l=(e=o[s])!=null?e:i;if(!l)return null;if(r===s){const d=o[a];return d?{x:0,y:s<a?d.top+d.height-(l.top+l.height):d.top-l.top,...mr}:null}const c=K2(o,r,s);return r>s&&r<=a?{x:0,y:-l.height-c,...mr}:r<s&&r>=a?{x:0,y:l.height+c,...mr}:{x:0,y:0,...mr}};function K2(t,e,s){const i=t[e],r=t[e-1],o=t[e+1];return i?s<e?r?i.top-(r.top+r.height):o?o.top-(i.top+i.height):0:o?o.top-(i.top+i.height):r?i.top-(r.top+r.height):0:0}const Mf="Sortable",Pf=Ut.createContext({activeIndex:-1,containerId:Mf,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:Df,disabled:{draggable:!1,droppable:!1}});function q2(t){let{children:e,id:s,items:i,strategy:r=Df,disabled:o=!1}=t;const{active:a,dragOverlay:l,droppableRects:c,over:d,measureDroppableContainers:u}=O2(),h=ir(Mf,s),f=l.rect!==null,m=S.useMemo(()=>i.map(k=>typeof k=="object"&&"id"in k?k.id:k),[i]),p=a!=null,g=a?m.indexOf(a.id):-1,_=d?m.indexOf(d.id):-1,v=S.useRef(m),x=!U2(m,v.current),b=_!==-1&&g===-1||x,y=H2(o);Ds(()=>{x&&p&&u(m)},[x,m,p,u]),S.useEffect(()=>{v.current=m},[m]);const C=S.useMemo(()=>({activeIndex:g,containerId:h,disabled:y,disableTransforms:b,items:m,overIndex:_,useDragOverlay:f,sortedRects:F2(m,c),strategy:r}),[g,h,y.draggable,y.droppable,b,m,_,c,f,r]);return Ut.createElement(Pf.Provider,{value:C},e)}const G2=t=>{let{id:e,items:s,activeIndex:i,overIndex:r}=t;return Jl(s,i,r).indexOf(e)},Y2=t=>{let{containerId:e,isSorting:s,wasDragging:i,index:r,items:o,newIndex:a,previousItems:l,previousContainerId:c,transition:d}=t;return!d||!i||l!==o&&r===a?!1:s?!0:a!==r&&e===c},X2={duration:200,easing:"ease"},Lf="transform",J2=Ln.Transition.toString({property:Lf,duration:0,easing:"linear"}),Q2={roleDescription:"sortable"};function Z2(t){let{disabled:e,index:s,node:i,rect:r}=t;const[o,a]=S.useState(null),l=S.useRef(s);return Ds(()=>{if(!e&&s!==l.current&&i.current){const c=r.current;if(c){const d=Qi(i.current,{ignoreTransform:!0}),u={x:c.left-d.left,y:c.top-d.top,scaleX:c.width/d.width,scaleY:c.height/d.height};(u.x||u.y)&&a(u)}}s!==l.current&&(l.current=s)},[e,s,i,r]),S.useEffect(()=>{o&&a(null)},[o]),o}function eS(t){let{animateLayoutChanges:e=Y2,attributes:s,disabled:i,data:r,getNewIndex:o=G2,id:a,strategy:l,resizeObserverConfig:c,transition:d=X2}=t;const{items:u,containerId:h,activeIndex:f,disabled:m,disableTransforms:p,sortedRects:g,overIndex:_,useDragOverlay:v,strategy:x}=S.useContext(Pf),b=tS(i,m),y=u.indexOf(a),C=S.useMemo(()=>({sortable:{containerId:h,index:y,items:u},...r}),[h,r,y,u]),k=S.useMemo(()=>u.slice(u.indexOf(a)),[u,a]),{rect:w,node:V,isOver:j,setNodeRef:I}=z2({id:a,data:C,disabled:b.droppable,resizeObserverConfig:{updateMeasurementsFor:k,...c}}),{active:T,activatorEvent:R,activeNodeRect:N,attributes:A,setNodeRef:E,listeners:M,isDragging:L,over:D,setActivatorNodeRef:P,transform:O}=L2({id:a,data:C,attributes:{...Q2,...s},disabled:b.draggable}),z=xy(I,E),$=!!T,q=$&&!p&&fr(f)&&fr(_),F=!v&&L,G=F&&q?O:null,U=q?G??(l??x)({rects:g,activeNodeRect:N,activeIndex:f,overIndex:_,index:y}):null,Y=fr(f)&&fr(_)?o({id:a,items:u,activeIndex:f,overIndex:_}):y,W=T?.id,K=S.useRef({activeId:W,items:u,newIndex:Y,containerId:h}),ee=u!==K.current.items,Z=e({active:T,containerId:h,isDragging:L,isSorting:$,id:a,index:y,items:u,newIndex:K.current.newIndex,previousItems:K.current.items,previousContainerId:K.current.containerId,transition:d,wasDragging:K.current.activeId!=null}),X=Z2({disabled:!Z,index:y,node:V,rect:w});return S.useEffect(()=>{$&&K.current.newIndex!==Y&&(K.current.newIndex=Y),h!==K.current.containerId&&(K.current.containerId=h),u!==K.current.items&&(K.current.items=u)},[$,Y,h,u]),S.useEffect(()=>{if(W===K.current.activeId)return;if(W!=null&&K.current.activeId==null){K.current.activeId=W;return}const re=setTimeout(()=>{K.current.activeId=W},50);return()=>clearTimeout(re)},[W]),{active:T,activeIndex:f,attributes:A,data:C,rect:w,index:y,newIndex:Y,items:u,isOver:j,isSorting:$,isDragging:L,listeners:M,node:V,overIndex:_,over:D,setNodeRef:z,setActivatorNodeRef:P,setDroppableNodeRef:I,setDraggableNodeRef:E,transform:X??U,transition:ie()};function ie(){if(X||ee&&K.current.newIndex===y)return J2;if(!(F&&!Kl(R)||!d)&&($||Z))return Ln.Transition.toString({...d,property:Lf})}}function tS(t,e){var s,i;return typeof t=="boolean"?{draggable:t,droppable:!1}:{draggable:(s=t?.draggable)!=null?s:e.draggable,droppable:(i=t?.droppable)!=null?i:e.droppable}}function Jr(t){if(!t)return!1;const e=t.data.current;return!!(e&&"sortable"in e&&typeof e.sortable=="object"&&"containerId"in e.sortable&&"items"in e.sortable&&"index"in e.sortable)}const sS=[je.Down,je.Right,je.Up,je.Left],iS=(t,e)=>{let{context:{active:s,collisionRect:i,droppableRects:r,droppableContainers:o,over:a,scrollableAncestors:l}}=e;if(sS.includes(t.code)){if(t.preventDefault(),!s||!i)return;const c=[];o.getEnabled().forEach(h=>{if(!h||h!=null&&h.disabled)return;const f=r.get(h.id);if(f)switch(t.code){case je.Down:i.top<f.top&&c.push(h);break;case je.Up:i.top>f.top&&c.push(h);break;case je.Left:i.left>f.left&&c.push(h);break;case je.Right:i.left<f.left&&c.push(h);break}});const d=My({collisionRect:i,droppableRects:r,droppableContainers:c});let u=yf(d,"id");if(u===a?.id&&d.length>1&&(u=d[1].id),u!=null){const h=o.get(s.id),f=o.get(u),m=f?r.get(f.id):null,p=f?.node.current;if(p&&m&&h&&f){const _=vo(p).some((k,w)=>l[w]!==k),v=Of(h,f),x=nS(h,f),b=_||!v?{x:0,y:0}:{x:x?i.width-m.width:0,y:x?i.height-m.height:0},y={x:m.left,y:m.top};return b.x&&b.y?y:Pn(y,b)}}}};function Of(t,e){return!Jr(t)||!Jr(e)?!1:t.data.current.sortable.containerId===e.data.current.sortable.containerId}function nS(t,e){return!Jr(t)||!Jr(e)||!Of(t,e)?!1:t.data.current.sortable.index<e.data.current.sortable.index}function rS(t){const e=B.c(21),{value:s,onChange:i,placeholder:r,onKeyDown:o,className:a,isSearching:l,disabled:c}=t,d=r===void 0?"Search...":r;let u;e[0]!==a?(u=J("shrink-0 w-full border-b border-border h-12",a),e[0]=a,e[1]=u):u=e[1];const h=c?"cursor-not-allowed opacity-50":"cursor-text";let f;e[2]!==h?(f=J("flex items-center gap-2.5 h-12 px-4",h),e[2]=h,e[3]=f):f=e[3];let m;e[4]!==l?(m=l?n.jsx(Me,{size:16,className:"animate-spin text-muted-foreground shrink-0"}):n.jsx(kl,{size:16,className:"text-muted-foreground shrink-0"}),e[4]=l,e[5]=m):m=e[5];let p;e[6]!==i?(p=x=>i(x.target.value),e[6]=i,e[7]=p):p=e[7];let g;e[8]!==c||e[9]!==o||e[10]!==d||e[11]!==p||e[12]!==s?(g=n.jsx("input",{type:"text",value:s,onChange:p,onKeyDown:o,placeholder:d,disabled:c,className:"flex-1 min-w-0 bg-transparent text-sm text-foreground placeholder:text-muted-foreground/50 outline-none"}),e[8]=c,e[9]=o,e[10]=d,e[11]=p,e[12]=s,e[13]=g):g=e[13];let _;e[14]!==f||e[15]!==m||e[16]!==g?(_=n.jsxs("label",{className:f,children:[m,g]}),e[14]=f,e[15]=m,e[16]=g,e[17]=_):_=e[17];let v;return e[18]!==u||e[19]!==_?(v=n.jsx("div",{className:u,children:_}),e[18]=u,e[19]=_,e[20]=v):v=e[20],v}var Ql="ContextMenu",[oS]=jp(Ql,[Mh]),Lt=Mh(),[aS,Bf]=oS(Ql),$f=t=>{const{__scopeContextMenu:e,children:s,onOpenChange:i,dir:r,modal:o=!0}=t,[a,l]=S.useState(!1),c=Lt(e),d=vp(i),u=S.useCallback(h=>{l(h),d(h)},[d]);return n.jsx(aS,{scope:e,open:a,onOpenChange:u,modal:o,children:n.jsx(bp,{...c,dir:r,open:a,onOpenChange:u,modal:o,children:s})})};$f.displayName=Ql;var zf="ContextMenuTrigger",Ff=S.forwardRef((t,e)=>{const{__scopeContextMenu:s,disabled:i=!1,...r}=t,o=Bf(zf,s),a=Lt(s),l=S.useRef({x:0,y:0}),c=S.useRef({getBoundingClientRect:()=>DOMRect.fromRect({width:0,height:0,...l.current})}),d=S.useRef(0),u=S.useCallback(()=>window.clearTimeout(d.current),[]),h=f=>{l.current={x:f.clientX,y:f.clientY},o.onOpenChange(!0)};return S.useEffect(()=>u,[u]),S.useEffect(()=>{i&&u()},[i,u]),n.jsxs(n.Fragment,{children:[n.jsx(yp,{...a,virtualRef:c}),n.jsx(Sp.span,{"data-state":o.open?"open":"closed","data-disabled":i?"":void 0,...r,ref:e,style:{WebkitTouchCallout:"none",...t.style},onContextMenu:i?t.onContextMenu:nn(t.onContextMenu,f=>{u(),h(f),f.preventDefault()}),onPointerDown:i?t.onPointerDown:nn(t.onPointerDown,pr(f=>{u(),d.current=window.setTimeout(()=>h(f),700)})),onPointerMove:i?t.onPointerMove:nn(t.onPointerMove,pr(u)),onPointerCancel:i?t.onPointerCancel:nn(t.onPointerCancel,pr(u)),onPointerUp:i?t.onPointerUp:nn(t.onPointerUp,pr(u))})]})});Ff.displayName=zf;var lS="ContextMenuPortal",Uf=t=>{const{__scopeContextMenu:e,...s}=t,i=Lt(e);return n.jsx(wp,{...i,...s})};Uf.displayName=lS;var Hf="ContextMenuContent",Wf=S.forwardRef((t,e)=>{const{__scopeContextMenu:s,...i}=t,r=Bf(Hf,s),o=Lt(s),a=S.useRef(!1);return n.jsx(Vp,{...o,...i,ref:e,side:"right",sideOffset:2,align:"start",onCloseAutoFocus:l=>{t.onCloseAutoFocus?.(l),!l.defaultPrevented&&a.current&&l.preventDefault(),a.current=!1},onInteractOutside:l=>{t.onInteractOutside?.(l),!l.defaultPrevented&&!r.modal&&(a.current=!0)},style:{...t.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-context-menu-content-available-width":"var(--radix-popper-available-width)","--radix-context-menu-content-available-height":"var(--radix-popper-available-height)","--radix-context-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-context-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Wf.displayName=Hf;var cS="ContextMenuGroup",dS=S.forwardRef((t,e)=>{const{__scopeContextMenu:s,...i}=t,r=Lt(s);return n.jsx(Np,{...r,...i,ref:e})});dS.displayName=cS;var hS="ContextMenuLabel",uS=S.forwardRef((t,e)=>{const{__scopeContextMenu:s,...i}=t,r=Lt(s);return n.jsx(Ap,{...r,...i,ref:e})});uS.displayName=hS;var fS="ContextMenuItem",Kf=S.forwardRef((t,e)=>{const{__scopeContextMenu:s,...i}=t,r=Lt(s);return n.jsx(Cp,{...r,...i,ref:e})});Kf.displayName=fS;var mS="ContextMenuCheckboxItem",pS=S.forwardRef((t,e)=>{const{__scopeContextMenu:s,...i}=t,r=Lt(s);return n.jsx(Ep,{...r,...i,ref:e})});pS.displayName=mS;var gS="ContextMenuRadioGroup",_S=S.forwardRef((t,e)=>{const{__scopeContextMenu:s,...i}=t,r=Lt(s);return n.jsx(Ip,{...r,...i,ref:e})});_S.displayName=gS;var xS="ContextMenuRadioItem",vS=S.forwardRef((t,e)=>{const{__scopeContextMenu:s,...i}=t,r=Lt(s);return n.jsx(Rp,{...r,...i,ref:e})});vS.displayName=xS;var bS="ContextMenuItemIndicator",yS=S.forwardRef((t,e)=>{const{__scopeContextMenu:s,...i}=t,r=Lt(s);return n.jsx(Tp,{...r,...i,ref:e})});yS.displayName=bS;var SS="ContextMenuSeparator",qf=S.forwardRef((t,e)=>{const{__scopeContextMenu:s,...i}=t,r=Lt(s);return n.jsx(kp,{...r,...i,ref:e})});qf.displayName=SS;var wS="ContextMenuArrow",VS=S.forwardRef((t,e)=>{const{__scopeContextMenu:s,...i}=t,r=Lt(s);return n.jsx(Dp,{...r,...i,ref:e})});VS.displayName=wS;var CS="ContextMenuSubTrigger",kS=S.forwardRef((t,e)=>{const{__scopeContextMenu:s,...i}=t,r=Lt(s);return n.jsx(Mp,{...r,...i,ref:e})});kS.displayName=CS;var jS="ContextMenuSubContent",NS=S.forwardRef((t,e)=>{const{__scopeContextMenu:s,...i}=t,r=Lt(s);return n.jsx(Pp,{...r,...i,ref:e,style:{...t.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-context-menu-content-available-width":"var(--radix-popper-available-width)","--radix-context-menu-content-available-height":"var(--radix-popper-available-height)","--radix-context-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-context-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});NS.displayName=jS;function pr(t){return e=>e.pointerType!=="mouse"?t(e):void 0}var AS=$f,ES=Ff,IS=Uf,RS=Wf,TS=Kf,DS=qf;function MS(t){const e=B.c(4);let s;e[0]!==t?({...s}=t,e[0]=t,e[1]=s):s=e[1];let i;return e[2]!==s?(i=n.jsx(AS,{"data-slot":"context-menu",...s}),e[2]=s,e[3]=i):i=e[3],i}function PS(t){const e=B.c(4);let s;e[0]!==t?({...s}=t,e[0]=t,e[1]=s):s=e[1];let i;return e[2]!==s?(i=n.jsx(ES,{"data-slot":"context-menu-trigger",...s}),e[2]=s,e[3]=i):i=e[3],i}function LS(t){const e=B.c(8);let s,i;e[0]!==t?({className:s,...i}=t,e[0]=t,e[1]=s,e[2]=i):(s=e[1],i=e[2]);let r;e[3]!==s?(r=J("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 max-h-(--radix-context-menu-content-available-height) min-w-[8rem] origin-(--radix-context-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border p-1 shadow-md",s),e[3]=s,e[4]=r):r=e[4];let o;return e[5]!==i||e[6]!==r?(o=n.jsx(IS,{children:n.jsx(RS,{"data-slot":"context-menu-content",className:r,...i})}),e[5]=i,e[6]=r,e[7]=o):o=e[7],o}function bd(t){const e=B.c(12);let s,i,r,o;e[0]!==t?({className:s,inset:i,variant:o,...r}=t,e[0]=t,e[1]=s,e[2]=i,e[3]=r,e[4]=o):(s=e[1],i=e[2],r=e[3],o=e[4]);const a=o===void 0?"default":o;let l;e[5]!==s?(l=J("focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:!text-destructive [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",s),e[5]=s,e[6]=l):l=e[6];let c;return e[7]!==i||e[8]!==r||e[9]!==l||e[10]!==a?(c=n.jsx(TS,{"data-slot":"context-menu-item","data-inset":i,"data-variant":a,className:l,...r}),e[7]=i,e[8]=r,e[9]=l,e[10]=a,e[11]=c):c=e[11],c}function OS(t){const e=B.c(8);let s,i;e[0]!==t?({className:s,...i}=t,e[0]=t,e[1]=s,e[2]=i):(s=e[1],i=e[2]);let r;e[3]!==s?(r=J("bg-border -mx-1 my-1 h-px",s),e[3]=s,e[4]=r):r=e[4];let o;return e[5]!==i||e[6]!==r?(o=n.jsx(DS,{"data-slot":"context-menu-separator",className:r,...i}),e[5]=i,e[6]=r,e[7]=o):o=e[7],o}function Gf(t){const e=Ge(),s=Mt(),i=Tu(),{locator:r}=xe(),o=Hn({strict:!1}),a=Si({strict:!1});return async l=>{const c=crypto.randomUUID(),d=l===a.virtualmcpid?Kh(s,r,o.taskId??""):null;try{await i.create.mutateAsync({id:c,virtual_mcp_id:l,...d?{branch:d}:{}})}catch{}e({to:"/$org/$taskId",params:{org:t,taskId:c},search:{virtualmcpid:l}})}}function BS({agent:t,org:e,onUnpin:s,isDragging:i}){const r=Ge(),{isMobile:o,setOpenMobile:a}=Qn(),l=Gf(e),d=Rh({select:b=>b.location.pathname}).startsWith(`/${e}/${t.id}`),[u,h]=S.useState(null),f=S.useRef(null),m=S.useRef(null),p=S.useRef(!1);p.current=!!i,i&&(u||m.current)&&(m.current&&(clearTimeout(m.current),m.current=null),u&&h(null));const g=b=>{if(p.current)return;const y=b.currentTarget.getBoundingClientRect();m.current=setTimeout(()=>{p.current||h(y)},550)},_=b=>{m.current&&(clearTimeout(m.current),m.current=null),!(f.current&&b.relatedTarget instanceof Node&&f.current.contains(b.relatedTarget))&&h(null)},v=u?Math.round(u.height*.9):0,x=u?u.width+v:0;return n.jsx(MS,{children:n.jsxs(Zt,{className:J(u&&"z-[55]"),children:[n.jsx(PS,{asChild:!0,children:n.jsx(_s,{tooltip:u?void 0:t.title,isActive:d,onClick:()=>{ne("sidebar_agent_pin_clicked",{agent_id:t.id,agent_title:t.title}),l(t.id),o&&a(!1)},onMouseEnter:g,onMouseLeave:_,children:n.jsx(gs,{icon:t.icon,name:t.title,size:"xs",className:"w-full h-full [&_svg]:w-1/2 [&_svg]:h-1/2"})})}),n.jsxs(LS,{children:[n.jsxs(bd,{onClick:()=>{const b=crypto.randomUUID();r({to:"/$org/$taskId",params:{org:e,taskId:b},search:{virtualmcpid:t.id}})},children:[n.jsx(Zn,{size:14}),"Settings"]}),n.jsx(OS,{}),n.jsxs(bd,{onClick:()=>{s(),d&&r({to:"/$org",params:{org:e}})},className:"",children:[n.jsx(Js,{size:14}),"Unpin"]})]}),u&&ms.createPortal(n.jsx("button",{ref:f,type:"button",onMouseLeave:()=>h(null),onClick:b=>{b.stopPropagation(),h(null),s(),r({to:"/$org",params:{org:e}})},className:J("flex items-center justify-center","bg-sidebar-accent text-muted-foreground","rounded-xl cursor-pointer","animate-in fade-in-0 slide-in-from-right-2","duration-150 [animation-timing-function:cubic-bezier(0.165,0.84,0.44,1)]","hover:text-foreground transition-colors"),style:{position:"fixed",top:u.top,left:u.left,height:u.height,width:x,paddingLeft:u.width,zIndex:50,boxShadow:"inset 0 0 0.5px 1px hsla(0, 0%, 100%, 0.075), 0 0 0 0.5px hsla(0, 0%, 0%, 0.12)"},children:n.jsx(Js,{size:14})}),document.body)]})})}function $S(t){const e=B.c(18);let s;e[0]!==t.agent.id?(s={id:t.agent.id},e[0]=t.agent.id,e[1]=s):s=e[1];const{attributes:i,listeners:r,setNodeRef:o,transform:a,transition:l,isDragging:c}=eS(s);let d;e[2]!==a?(d=Ln.Transform.toString(a?{...a,x:0}:null),e[2]=a,e[3]=d):d=e[3];const u=c?.5:void 0,h=c?100:void 0;let f;e[4]!==d||e[5]!==u||e[6]!==h||e[7]!==l?(f={transform:d,transition:l,opacity:u,zIndex:h},e[4]=d,e[5]=u,e[6]=h,e[7]=l,e[8]=f):f=e[8];const m=f;let p;e[9]!==c||e[10]!==t?(p=n.jsx(BS,{...t,isDragging:c}),e[9]=c,e[10]=t,e[11]=p):p=e[11];let g;return e[12]!==i||e[13]!==r||e[14]!==o||e[15]!==m||e[16]!==p?(g=n.jsx("div",{ref:o,style:m,...i,...r,tabIndex:-1,className:"w-full",children:p}),e[12]=i,e[13]=r,e[14]=o,e[15]=m,e[16]=p,e[17]=g):g=e[17],g}function zS(t){const e=B.c(9),{agent:s,onClick:i}=t;let r;e[0]!==s.icon||e[1]!==s.title?(r=n.jsx(gs,{icon:s.icon,name:s.title,size:"md",className:"transition-transform group-hover:scale-105"}),e[0]=s.icon,e[1]=s.title,e[2]=r):r=e[2];let o;e[3]!==s.title?(o=n.jsx("span",{className:"text-xs leading-tight text-center text-muted-foreground group-hover:text-foreground line-clamp-2 w-full",children:s.title}),e[3]=s.title,e[4]=o):o=e[4];let a;return e[5]!==i||e[6]!==r||e[7]!==o?(a=n.jsxs("button",{type:"button",onClick:i,className:"flex flex-col items-center gap-2 p-3 rounded-xl transition-colors hover:bg-accent cursor-pointer group",children:[r,o]}),e[5]=i,e[6]=r,e[7]=o,e[8]=a):a=e[8],a}function FS(t){const e=B.c(76),{onClose:s,onOpenImportDeco:i,onOpenGithubImport:r,onOpenSelfHealing:o,onOpenDiagnosticsModal:a,onOpenLeanCanvasModal:l,onOpenStudioPackModal:c}=t,[d,u]=S.useState(""),h=fo(),{org:f}=xe();let m;e[0]!==h?(m=h.filter(GS).map(qS),e[0]=h,e[1]=m):m=e[1];const p=m,{pin:g,isPinned:_}=Cu(f.id,p);let v;e[2]===Symbol.for("react.memo_cache_sentinel")?(v={navigateOnCreate:!0},e[2]=v):v=e[2];const{createVirtualMCP:x,isCreating:b}=ku(v),[y]=yi(),C=Gf(f.slug),k=Yn();let w,V,j,I,T,R,N,A;if(e[3]!==h||e[4]!==x||e[5]!==b||e[6]!==_||e[7]!==k||e[8]!==C||e[9]!==s||e[10]!==a||e[11]!==r||e[12]!==i||e[13]!==l||e[14]!==o||e[15]!==c||e[16]!==g||e[17]!==y.experimental_vibecode||e[18]!==d){const z=d.toLowerCase();A=h.filter(KS).filter(se=>!d||se.title.toLowerCase().includes(z));let $;e[27]!==h?($=h.some(WS),e[27]=h,e[28]=$):$=e[28];const q=$;w=ks.filter(se=>(!d||se.title.toLowerCase().includes(z))&&!(se.id==="studio-pack"&&q)&&!(se.id==="self-healing-storefront"&&!y.experimental_vibecode));let F;e[29]===Symbol.for("react.memo_cache_sentinel")?(F=ks.find(HS),e[29]=F):F=e[29];const G=F,H=G?h.find(se=>se.metadata?.type===G.id):void 0;let U;e[30]===Symbol.for("react.memo_cache_sentinel")?(U=ks.find(US),e[30]=U):U=e[30];const Y=U,W=Y?h.find(se=>se.metadata?.type===Y.id):void 0;let K;e[31]!==_||e[32]!==C||e[33]!==s||e[34]!==g?(K=se=>{_(se.id)||g(se.id),s(),u(""),C(se.id)},e[31]=_,e[32]=C,e[33]=s,e[34]=g,e[35]=K):K=e[35];const ee=K,Z=se=>{s(),u(""),se==="self-healing-storefront"?o():se==="site-editor"?i():se==="site-diagnostics"?H?k(H.id):a():se==="lean-canvas"?W?k(W.id):l():se==="studio-pack"?c():C(se)};R="flex flex-col max-h-[min(640px,80dvh)]",e[36]!==d?(N=n.jsx(rS,{value:d,onChange:u,placeholder:"Search agents..."}),e[36]=d,e[37]=N):N=e[37],V="overflow-y-auto flex-1 min-h-0 px-3 pb-3",e[38]===Symbol.for("react.memo_cache_sentinel")?(j=n.jsx("div",{className:"px-1 pt-3 pb-2",children:n.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Agents"})}),e[38]=j):j=e[38];let X;e[39]!==x||e[40]!==s?(X=async()=>{ne("agent_create_new_clicked",{source:"browse_popover"}),await x(),s()},e[39]=x,e[40]=s,e[41]=X):X=e[41];let ie,re;e[42]===Symbol.for("react.memo_cache_sentinel")?(ie=n.jsx("div",{className:"w-12 h-12 rounded-xl border-2 border-dashed border-border flex items-center justify-center shrink-0 transition-transform group-hover:scale-105",children:n.jsx(Qt,{size:16,className:"text-muted-foreground"})}),re=n.jsx("span",{className:"text-xs leading-tight text-center text-muted-foreground group-hover:text-foreground",children:"Create new"}),e[42]=ie,e[43]=re):(ie=e[42],re=e[43]);let de;e[44]!==b||e[45]!==X?(de=n.jsxs("button",{type:"button",disabled:b,onClick:X,className:"flex flex-col items-center gap-2 p-3 rounded-xl transition-colors hover:bg-accent cursor-pointer group disabled:opacity-50 disabled:cursor-not-allowed",children:[ie,re]}),e[44]=b,e[45]=X,e[46]=de):de=e[46];let me;e[47]!==s||e[48]!==r||e[49]!==y.experimental_vibecode?(me=y.experimental_vibecode&&n.jsxs("button",{type:"button",onClick:()=>{ne("agent_import_clicked",{source:"github"}),r(),s()},className:"flex flex-col items-center gap-2 p-3 rounded-xl transition-colors hover:bg-accent cursor-pointer group",children:[n.jsx("div",{className:"w-12 h-12 rounded-xl border-2 border-border flex items-center justify-center shrink-0 transition-transform group-hover:scale-105",children:n.jsx(Vu,{className:"size-5 text-muted-foreground"})}),n.jsx("span",{className:"text-xs leading-tight text-center text-muted-foreground group-hover:text-foreground",children:"Import GitHub"})]}),e[47]=s,e[48]=r,e[49]=y.experimental_vibecode,e[50]=me):me=e[50];let le;e[51]!==ee?(le=se=>n.jsx(zS,{agent:se,onClick:()=>ee(se)},se.id),e[51]=ee,e[52]=le):le=e[52],I=n.jsxs("div",{className:"grid grid-cols-3 gap-1",children:[de,me,A.map(le)]}),T=w.length>0&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"px-1 pt-4 pb-2",children:n.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Agent templates"})}),n.jsx("div",{className:"grid grid-cols-3 gap-1",children:w.map(se=>n.jsxs("button",{type:"button",onClick:()=>{ne("agent_template_clicked",{template_id:se.id,template_title:se.title}),Z(se.id)},className:"flex flex-col items-center gap-2 p-3 rounded-xl transition-colors hover:bg-accent cursor-pointer group disabled:opacity-50 disabled:cursor-not-allowed",children:[n.jsx(gs,{icon:se.icon,name:se.title,size:"md",className:"transition-transform group-hover:scale-105"}),n.jsx("span",{className:"text-xs leading-tight text-center text-muted-foreground group-hover:text-foreground line-clamp-2 w-full",children:se.title})]},se.id))})]}),e[3]=h,e[4]=x,e[5]=b,e[6]=_,e[7]=k,e[8]=C,e[9]=s,e[10]=a,e[11]=r,e[12]=i,e[13]=l,e[14]=o,e[15]=c,e[16]=g,e[17]=y.experimental_vibecode,e[18]=d,e[19]=w,e[20]=V,e[21]=j,e[22]=I,e[23]=T,e[24]=R,e[25]=N,e[26]=A}else w=e[19],V=e[20],j=e[21],I=e[22],T=e[23],R=e[24],N=e[25],A=e[26];let E;e[53]!==w||e[54]!==b||e[55]!==d||e[56]!==A.length?(E=A.length===0&&w.length===0&&!b&&n.jsx("div",{className:"flex items-center justify-center py-6 text-xs text-muted-foreground",children:d?"No agents found":"No agents yet"}),e[53]=w,e[54]=b,e[55]=d,e[56]=A.length,e[57]=E):E=e[57];let M;e[58]!==V||e[59]!==j||e[60]!==I||e[61]!==T||e[62]!==E?(M=n.jsxs("div",{className:V,children:[j,I,T,E]}),e[58]=V,e[59]=j,e[60]=I,e[61]=T,e[62]=E,e[63]=M):M=e[63];let L;e[64]!==f.slug?(L={org:f.slug},e[64]=f.slug,e[65]=L):L=e[65];let D;e[66]!==s?(D=()=>s(),e[66]=s,e[67]=D):D=e[67];let P;e[68]!==L||e[69]!==D?(P=n.jsx("div",{className:"border-t border-border px-3 py-2.5",children:n.jsx(Ph,{to:"/$org/settings/agents",params:L,onClick:D,className:"text-xs text-muted-foreground hover:text-foreground transition-colors flex items-center justify-center",children:"See all agents"})}),e[68]=L,e[69]=D,e[70]=P):P=e[70];let O;return e[71]!==M||e[72]!==P||e[73]!==R||e[74]!==N?(O=n.jsxs("div",{className:R,children:[N,M,P]}),e[71]=M,e[72]=P,e[73]=R,e[74]=N,e[75]=O):O=e[75],O}function US(t){return t.id==="lean-canvas"}function HS(t){return t.id==="site-diagnostics"}function WS(t){return bg(t.id)}function KS(t){return!Br(t.id)}function qS(t){return t.id}function GS(t){return t.pinned}function YS(){const t=B.c(30),[e,s]=S.useState(!1),[i,r]=S.useState(!1),[o,a]=S.useState(!1),[l,c]=S.useState(!1),[d,u]=S.useState(!1),[h,f]=S.useState(!1),[m,p]=S.useState(!1),g=Ps(),{setOpenMobile:_}=Qn();let v;t[0]!==g||t[1]!==_?(v=()=>{s(!1),g&&_(!1)},t[0]=g,t[1]=_,t[2]=v):v=t[2];const x=v;let b;t[3]!==x||t[4]!==e?(b=e&&n.jsx(S.Suspense,{fallback:n.jsx("div",{className:"flex items-center justify-center py-8",children:n.jsx(Fi,{className:"h-4 w-24"})}),children:n.jsx(FS,{onClose:x,onOpenImportDeco:()=>r(!0),onOpenGithubImport:()=>{a(!0),x()},onOpenSelfHealing:()=>{c(!0),x()},onOpenDiagnosticsModal:()=>u(!0),onOpenLeanCanvasModal:()=>f(!0),onOpenStudioPackModal:()=>p(!0)})}),t[3]=x,t[4]=e,t[5]=b):b=t[5];const y=b;let C;t[6]!==g||t[7]!==e||t[8]!==y?(C=g?n.jsxs(n.Fragment,{children:[n.jsx(Zt,{children:n.jsx(_s,{tooltip:"Browse agents",className:"bg-muted/75 hover:bg-sidebar-accent",onClick:()=>{ne("agent_browser_opened",{surface:"mobile_drawer"}),s(!0)},children:n.jsx(Qt,{className:"!opacity-100"})})}),n.jsx(Ci,{open:e,onOpenChange:s,direction:"bottom",children:n.jsxs(Vi,{className:"max-h-[85dvh] p-0",children:[n.jsx(wi,{className:"sr-only",children:"Browse agents"}),y]})})]}):n.jsxs(di,{open:e,onOpenChange:N=>{N&&!e&&ne("agent_browser_opened",{surface:"desktop_popover"}),s(N)},children:[n.jsx(Zt,{children:n.jsx(li,{asChild:!0,children:n.jsx(_s,{tooltip:"Browse agents",className:"bg-muted/75 hover:bg-sidebar-accent",children:n.jsx(Qt,{className:"!opacity-100"})})})}),n.jsx(ci,{className:"w-[380px] p-0 overflow-hidden",side:"right",align:"start",children:y})]}),t[6]=g,t[7]=e,t[8]=y,t[9]=C):C=t[9];let k;t[10]!==i?(k=n.jsx(Fr,{open:i,onOpenChange:r}),t[10]=i,t[11]=k):k=t[11];let w;t[12]!==o?(w=n.jsx(Su,{open:o,onOpenChange:a}),t[12]=o,t[13]=w):w=t[13];let V;t[14]!==l?(V=n.jsx(rf,{open:l,onOpenChange:c}),t[14]=l,t[15]=V):V=t[15];let j;t[16]!==d?(j=n.jsx(wu,{open:d,onOpenChange:u}),t[16]=d,t[17]=j):j=t[17];let I;t[18]!==h?(I=n.jsx(k_,{open:h,onOpenChange:f}),t[18]=h,t[19]=I):I=t[19];let T;t[20]!==m?(T=n.jsx(j_,{open:m,onOpenChange:p}),t[20]=m,t[21]=T):T=t[21];let R;return t[22]!==C||t[23]!==k||t[24]!==w||t[25]!==V||t[26]!==j||t[27]!==I||t[28]!==T?(R=n.jsxs(n.Fragment,{children:[C,k,w,V,j,I,T]}),t[22]=C,t[23]=k,t[24]=w,t[25]=V,t[26]=j,t[27]=I,t[28]=T,t[29]=R):R=t[29],R}function XS(){const t=B.c(34),e=fo(),{org:s}=xe();let i;t[0]!==e?(i=e.filter(ew).map(ZS),t[0]=e,t[1]=i):i=t[1];const r=i,{pinnedIds:o,unpin:a,reorder:l}=Cu(s.id,r),c=new Map(e.map(QS)),d=o.map(D=>c.get(D)).filter(JS);let u;t[2]===Symbol.for("react.memo_cache_sentinel")?(u={activationConstraint:{distance:5}},t[2]=u):u=t[2];let h;t[3]===Symbol.for("react.memo_cache_sentinel")?(h={coordinateGetter:iS},t[3]=h):h=t[3];const f=Ry(ad(Xl,u),ad(Gl,h));let m;t[4]!==o||t[5]!==l?(m=D=>{const{active:P,over:O}=D;if(!O||P.id===O.id)return;const z=o.indexOf(P.id),$=o.indexOf(O.id);z===-1||$===-1||l(Jl([...o],z,$))},t[4]=o,t[5]=l,t[6]=m):m=t[6];const p=m,g=Xn,_="py-0 px-0 mt-2 flex-1 min-h-0";let v;t[7]===Symbol.for("react.memo_cache_sentinel")?(v=n.jsx("div",{className:"h-px bg-border mx-2 mb-2"}),t[7]=v):v=t[7];const x=Jn,b="flex flex-1 min-h-0 flex-col overflow-y-auto [scrollbar-width:none] [-ms-overflow-style:none] [&::-webkit-scrollbar]:hidden",y=vs,C="gap-2";let k;t[8]===Symbol.for("react.memo_cache_sentinel")?(k=n.jsx(YS,{}),t[8]=k):k=t[8];const w=D2,V=Dy,j=q2,I=W2;let T;t[9]!==s.slug||t[10]!==a?(T=D=>n.jsx($S,{agent:D,org:s.slug,onUnpin:()=>a(D.id)},D.id),t[9]=s.slug,t[10]=a,t[11]=T):T=t[11];const R=d.map(T);let N;t[12]!==j||t[13]!==o||t[14]!==I||t[15]!==R?(N=n.jsx(j,{items:o,strategy:I,children:R}),t[12]=j,t[13]=o,t[14]=I,t[15]=R,t[16]=N):N=t[16];let A;t[17]!==w||t[18]!==p||t[19]!==f||t[20]!==N||t[21]!==V?(A=n.jsx(w,{sensors:f,collisionDetection:V,onDragEnd:p,children:N}),t[17]=w,t[18]=p,t[19]=f,t[20]=N,t[21]=V,t[22]=A):A=t[22];let E;t[23]!==y||t[24]!==A||t[25]!==k?(E=n.jsxs(y,{className:C,children:[k,A]}),t[23]=y,t[24]=A,t[25]=k,t[26]=E):E=t[26];let M;t[27]!==x||t[28]!==E?(M=n.jsx(x,{className:b,children:E}),t[27]=x,t[28]=E,t[29]=M):M=t[29];let L;return t[30]!==g||t[31]!==M||t[32]!==v?(L=n.jsxs(g,{className:_,children:[v,M]}),t[30]=g,t[31]=M,t[32]=v,t[33]=L):L=t[33],L}function JS(t){return!!t}function QS(t){return[t.id,t]}function ZS(t){return t.id}function ew(t){return t.pinned}function Yf(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(S.Suspense,{fallback:n.jsx(Xn,{className:"py-0 px-0",children:n.jsx(Jn,{children:n.jsx(vs,{className:"gap-2",children:n.jsx(Zt,{children:n.jsxs("div",{className:"flex items-center gap-2 px-2 py-2",children:[n.jsx(Fi,{className:"h-4 w-4 rounded"}),n.jsx(Fi,{className:"h-4 flex-1"})]})})})})}),children:n.jsx(XS,{})}),t[0]=e):e=t[0],e}function tw(){const t=B.c(4),e=df();let s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx(gy,{}),t[0]=s):s=t[0];let i;t[1]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx(As,{children:n.jsx(S.Suspense,{fallback:null,children:n.jsx(Yf,{})})}),t[1]=i):i=t[1];let r;return t[2]!==e?(r=n.jsx(ff,{sections:e,footer:s,additionalContent:i}),t[2]=e,t[3]=r):r=t[3],r}function sw(t){const e=B.c(5),{onClose:s}=t,i=df();let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=n.jsx(_y,{}),e[0]=r):r=e[0];let o;e[1]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx(As,{children:n.jsx(S.Suspense,{fallback:null,children:n.jsx(Yf,{})})}),e[1]=o):o=e[1];let a;return e[2]!==s||e[3]!==i?(a=n.jsx(K0,{sections:i,onClose:s,footer:r,additionalContent:o}),e[2]=s,e[3]=i,e[4]=a):a=e[4],a}async function iw(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 Xf=["VM_START"],gr=new Map,nw=t=>`${t.virtualMcpId}::${t.branch??""}`;function Zl(t){const e=Mt();return qi({mutationKey:Xf,mutationFn:async s=>{const i=nw(s),r=gr.get(i);if(r)return r;const o=(async()=>(await iw(t,"VM_START",s)).structuredContent)();gr.set(i,o);try{return await o}finally{gr.get(i)===o&&gr.delete(i)}},onSuccess:()=>{Vr(e)}})}function rw(t,e){const s=B.c(3);let i;return s[0]!==e||s[1]!==t?(i={mutationKey:Xf,predicate:o=>{if(!t)return!1;const a=o.state.variables;return!a||a.virtualMcpId!==t?!1:(a.branch??"")===(e??"")}},s[0]=e,s[1]=t,s[2]=i):i=s[2],Z_(i)>0}function ow(t,e){return t===1?!0:t===0?!1:e}function aw(t){const e=t.entityMetadata?.defaultMainView??null,s=e==null||e.type==="chat",i=t.mainParamPresent?t.mainParamValue!=="0":!s,r=s?!0:t.entityMetadata?.chatDefaultOpen??!1;return{mainOpen:i,chatOpen:r}}function yd(t,e){return t&&e?{chat:45,main:55}:t&&!e?{chat:100,main:0}:!t&&e?{chat:0,main:100}:{chat:0,main:0}}function lw(t,e){return t===1?!0:t===0?!1:e}function cw(t,e){const s=Ge(),i=Si({strict:!1}),r=Hn({strict:!1}),o=Mt(),a=Tu(),{locator:l}=xe(),{virtualMcpId:c,orgSlug:d,isAgentRoute:u}=e,h=aw({entityMetadata:t,mainParamPresent:i.main!==void 0,mainParamValue:i.main}),f=lw(i.chat,h.chatOpen),m=h.mainOpen,p=S.useRef(crypto.randomUUID()),g=r.taskId??p.current,_="/$org/$taskId",v=I=>({org:d,taskId:I}),x=u?{virtualmcpid:c}:{},b=(I,T)=>{s({to:_,params:v(g),search:R=>({...R,...I}),replace:T?.replace??!1})},y=(I,T)=>{s({to:_,params:v(I),search:R=>{const N={};return T?N.virtualmcpid=T:u&&(N.virtualmcpid=c),R.tasks&&(N.tasks=R.tasks),N}})},C=()=>{m?b({main:"0"},{replace:!0}):b({main:eg(t)},{replace:!0})},k=()=>{b({chat:f?0:1},{replace:!0})},w=()=>{f||b({chat:1},{replace:!0})},V=async()=>{const I=crypto.randomUUID(),T=Kh(o,l,g);try{await a.create.mutateAsync({id:I,virtual_mcp_id:c,...T?{branch:T}:{}})}catch{}s({to:_,params:v(I),search:R=>{const N={...x,chat:1};return R.tasks&&(N.tasks=R.tasks),N}})},j=I=>{b({main:I},{replace:!0})};return{taskId:g,mainOpen:m,chatOpen:f,mainParam:i.main,setTaskId:y,toggleMain:C,toggleChat:k,openChat:w,createNewTask:V,openTab:j}}const ec=S.createContext(null);function dw(t){const e=B.c(15),{children:s}=t,i=Ge();let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={strict:!1},e[0]=r):r=e[0];const o=Si(r);let a;e[1]===Symbol.for("react.memo_cache_sentinel")?(a={owner:"all",status:"open"},e[1]=a):a=e[1];const{tasks:l}=da(a);let c;e[2]!==o.tasks||e[3]!==l.length?(c=()=>ow(o.tasks,l.length>0),e[2]=o.tasks,e[3]=l.length,e[4]=c):c=e[4];const[d,u]=S.useState(c);let h,f;e[5]!==i||e[6]!==d?(h=()=>{i({search:(v=>({...v,tasks:d?1:0})),replace:!0})},f=[d,i],e[5]=i,e[6]=d,e[7]=h,e[8]=f):(h=e[7],f=e[8]),S.useEffect(h,f);let m;e[9]===Symbol.for("react.memo_cache_sentinel")?(m=()=>u(hw),e[9]=m):m=e[9];const p=m;let g;e[10]!==d?(g={tasksOpen:d,toggleTasks:p},e[10]=d,e[11]=g):g=e[11];let _;return e[12]!==s||e[13]!==g?(_=n.jsx(ec.Provider,{value:g,children:s}),e[12]=s,e[13]=g,e[14]=_):_=e[14],_}function hw(t){return!t}function Jf(){const t=S.useContext(ec);if(!t)throw new Error("useTasksPanelState must be used inside <TasksPanelStateProvider>");return t}function uw(){return S.useContext(ec)}const Qf=S.createContext(null);function hi(){const t=S.use(Qf);if(!t)throw new Error("Toolbar.* must be used inside <Toolbar>");return t}function He(t){const e=B.c(10),{children:s}=t,[i,r]=S.useState(null),[o,a]=S.useState(null),[l,c]=S.useState(null),[d,u]=S.useState(null);let h;e[0]!==l||e[1]!==d||e[2]!==o||e[3]!==i?(h={togglesEl:i,setTogglesEl:r,tabsEl:o,setTabsEl:a,centerEl:l,setCenterEl:c,rightEl:d,setRightEl:u},e[0]=l,e[1]=d,e[2]=o,e[3]=i,e[4]=h):h=e[4];let f;e[5]!==s?(f=n.jsx("div",{className:"flex flex-col h-full min-h-0",children:s}),e[5]=s,e[6]=f):f=e[6];let m;return e[7]!==h||e[8]!==f?(m=n.jsx(Qf,{value:h,children:f}),e[7]=h,e[8]=f,e[9]=m):m=e[9],m}function fw(t){const e=B.c(2),{children:s}=t;let i;return e[0]!==s?(i=n.jsx("div",{className:"shrink-0 grid grid-cols-3 items-center pl-1 pr-2 pt-0.25 h-12",children:s}),e[0]=s,e[1]=i):i=e[1],i}function mw(t){const e=B.c(2),{children:s}=t;let i;return e[0]!==s?(i=n.jsx("div",{className:"flex items-center gap-0.5 min-w-0 justify-self-start",children:s}),e[0]=s,e[1]=i):i=e[1],i}function pw(t){const e=B.c(2),{children:s}=t;let i;return e[0]!==s?(i=n.jsx("div",{className:"flex items-center justify-end gap-0.5 min-w-0 justify-self-end",children:s}),e[0]=s,e[1]=i):i=e[1],i}function gw(){const t=B.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx("button",{type:"button",onClick:xw,className:"flex size-7 shrink-0 items-center justify-center rounded-md text-sidebar-foreground/60 hover:bg-sidebar-accent hover:text-sidebar-foreground transition-colors",title:"Go back",children:n.jsx(ma,{size:16})}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsxs(n.Fragment,{children:[e,n.jsx("button",{type:"button",onClick:_w,className:"flex size-7 shrink-0 items-center justify-center rounded-md text-sidebar-foreground/60 hover:bg-sidebar-accent hover:text-sidebar-foreground transition-colors",title:"Go forward",children:n.jsx(El,{size:16})})]}),t[1]=s):s=t[1],s}function _w(){return window.history.forward()}function xw(){return window.history.back()}function vw(){const t=B.c(2),{setCenterEl:e}=hi();let s;return t[0]!==e?(s=n.jsx("div",{ref:e,className:"min-w-0 flex items-center justify-center gap-2"}),t[0]=e,t[1]=s):s=t[1],s}function bw(t){const e=B.c(3),{children:s}=t,{centerEl:i}=hi();if(!i)return null;let r;return e[0]!==i||e[1]!==s?(r=ms.createPortal(s,i),e[0]=i,e[1]=s,e[2]=r):r=e[2],r}function yw(){const t=B.c(2),{setTabsEl:e}=hi();let s;return t[0]!==e?(s=n.jsx("div",{ref:e,className:"shrink-0 flex items-center overflow-x-auto"}),t[0]=e,t[1]=s):s=t[1],s}function Sw(t){const e=B.c(3),{children:s}=t,{tabsEl:i}=hi();if(!i)return null;let r;return e[0]!==s||e[1]!==i?(r=ms.createPortal(s,i),e[0]=s,e[1]=i,e[2]=r):r=e[2],r}function ww(){const t=B.c(2),{setTogglesEl:e}=hi();let s;return t[0]!==e?(s=n.jsx("div",{ref:e,className:"flex items-center gap-0.5 shrink-0 ml-0.5"}),t[0]=e,t[1]=s):s=t[1],s}function Vw(t){const e=B.c(3),{children:s}=t,{togglesEl:i}=hi();if(!i)return null;let r;return e[0]!==s||e[1]!==i?(r=ms.createPortal(s,i),e[0]=s,e[1]=i,e[2]=r):r=e[2],r}function Cw(){const t=B.c(2),{setRightEl:e}=hi();let s;return t[0]!==e?(s=n.jsx("div",{ref:e,className:"flex items-center justify-end gap-0.5 shrink-0"}),t[0]=e,t[1]=s):s=t[1],s}function kw(t){const e=B.c(3),{children:s}=t,{rightEl:i}=hi();if(!i)return null;let r;return e[0]!==s||e[1]!==i?(r=ms.createPortal(s,i),e[0]=s,e[1]=i,e[2]=r):r=e[2],r}He.Header=fw;He.LeftColumn=mw;He.RightColumn=pw;He.Nav=gw;He.CenterSlot=vw;He.Center=bw;He.TabsSlot=yw;He.Tabs=Sw;He.TogglesSlot=ww;He.Toggles=Vw;He.RightSlot=Cw;He.Right=kw;const jw=280;function Nw(){const t=B.c(2),{tasksOpen:e}=Jf();if(!e)return null;let s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s={width:`${jw}px`},t[0]=s):s=t[0];let i;return t[1]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx("aside",{className:"shrink-0 h-full bg-sidebar pb-1",style:s,children:n.jsx("div",{className:"h-full p-0.5 pt-0.25",children:n.jsx("div",{className:"h-full bg-background rounded-[0.75rem] overflow-hidden card-shadow",children:n.jsx(cf,{})})})}),t[1]=i):i=t[1],i}function Aw(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(S.Suspense,{fallback:null,children:n.jsx(Nw,{})}),t[0]=e):e=t[0],e}const Ew={settings:Tg,automations:Zh,env:bl,preview:cu,git:yn};function Sd(t){const e=Kn(t);if(e.type==="icon"){const s=qn(e.name);return s?{kind:"component",Component:s}:null}return e.type==="url"?{kind:"url",src:e.url}:null}function Uo(t){if(t.kind==="system")return{kind:"component",Component:Ew[t.tabId]};const e=Sd(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=Sd(s.icon);return i||{kind:"fallback"}}function Iw(t){const{org:e}=xe(),s=Be({connectionId:Pt,orgId:e.id}),{data:i}=Ih({queryKey:ct.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 Zf(t){const e=B.c(8),s=Ge();let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={strict:!1},e[0]=i):i=e[0];const r=Si(i),o=is(t.virtualMcpId),a=Iw(t.taskId),{currentBranch:l}=es(),c=o?.metadata?.ui??null,d=c?.layout??null,u=d?.tabs??[],h=c?.pinnedViews??[],f=a?.expanded_tools??[],m=!!(o&&Fs(o));let p;e[1]===Symbol.for("react.memo_cache_sentinel")?(p={includeVirtual:!0},e[1]=p):p=e[1];const g=Gn(p),{activeTab:_,mainOpen:v}=tg({mainParam:r.main,metadata:d?{defaultMainView:d.defaultMainView??null,tabs:u.map(Rw)}:null}),x=$h(_),b=[];m&&(b.push({id:"preview",title:"Preview"}),b.push({id:"env",title:"Terminal"}),b.push({id:"git",title:l??"git"})),b.push({id:"settings",title:"Settings"}),b.push({id:"automations",title:"Automations"});const y=new Map;for(const j of f){const I=ha(j.appId,j.toolName);y.set(I,{id:I,title:j.toolName,appId:j.appId,iconKey:j.toolName})}for(const j of h){const I=ha(j.connectionId,j.toolName);y.set(I,{id:I,title:j.label||j.toolName,appId:j.connectionId,iconKey:j.toolName,iconUrl:j.icon??null})}let C;e[2]!==g?(C=j=>({id:j.id,title:j.title,kind:"agent",icon:Uo({tabId:j.id,kind:"agent",appId:j.view.appId,connections:g})}),e[2]=g,e[3]=C):C=e[3];const k=[...u.map(C),...Array.from(y.values()).map(j=>({id:j.id,title:j.title,kind:"expanded",icon:Uo({tabId:j.iconKey,kind:"expanded",appId:j.appId,iconUrl:j.iconUrl,connections:g})})),...b.map(j=>({id:j.id,title:j.title,kind:"system",icon:Uo({tabId:j.id,kind:"system",connections:g})}))];let w;return e[4]!==_||e[5]!==v||e[6]!==s?(w=j=>{const I=sg({clickedId:j,activeTab:_,mainOpen:v});s({to:".",search:T=>({...T,main:I}),replace:!0})},e[4]=_,e[5]=v,e[6]=s,e[7]=w):w=e[7],{activeTab:_,mainOpen:v,setActiveTab:w,systemTabs:b,layoutTabs:u,expandedTools:f,automationTabParsed:x,tabs:k}}function Rw(t){return{id:t.id}}function Tw(t){const e=B.c(84),{value:s,onChange:i,onColorChange:r,name:o,size:a,className:l,avatarClassName:c,showHoverOverlay:d,disabled:u}=t,h=a===void 0?"lg":a,f=d===void 0?!0:d,m=u===void 0?!1:u,[p,g]=S.useState(!1),[_,v]=S.useState("icons"),[x,b]=S.useState(""),[y,C]=S.useState("blue");let k;e[0]!==s?(k=Kn(s),e[0]=s,e[1]=k):k=e[1];const w=k,V=w.type==="icon"||w.type==="url"&&w.color?w.color:y;let j;e[2]!==i||e[3]!==V?(j=ve=>{i(Io(ve,V))},e[2]=i,e[3]=V,e[4]=j):j=e[4];const I=j;let T;e[5]!==i||e[6]!==r||e[7]!==w.name||e[8]!==w.type||e[9]!==w.url?(T=ve=>{C(ve),r?.(ve),w.type==="icon"?i(Io(w.name,ve)):w.type==="url"&&i(yc(w.url,ve))},e[5]=i,e[6]=r,e[7]=w.name,e[8]=w.type,e[9]=w.url,e[10]=T):T=e[10];const R=T;let N;e[11]!==i||e[12]!==V?(N=ve=>{i(yc(ve,V)),g(!1)},e[11]=i,e[12]=V,e[13]=N):N=e[13];const A=N;let E;e[14]!==i||e[15]!==V?(E=()=>{const ve=wl(),Ne=ve[Math.floor(Math.random()*ve.length)];i(Io(Ne,V))},e[14]=i,e[15]=V,e[16]=E):E=e[16];const M=E;let L,D,P,O,z,$,q,F;if(e[17]!==l||e[18]!==m||e[19]!==p||e[20]!==h){const ve={xs:"rounded-md",sm:"rounded-lg","sm+":"rounded-xl",md:"rounded-xl",lg:"rounded-2xl",xl:"rounded-2xl"};D=di,$=m?!1:p,q=g,L=li,z=!0,F="button",P=m,O=J("relative group overflow-hidden",m?"cursor-default opacity-50":"cursor-pointer",ve[h],l),e[17]=l,e[18]=m,e[19]=p,e[20]=h,e[21]=L,e[22]=D,e[23]=P,e[24]=O,e[25]=z,e[26]=$,e[27]=q,e[28]=F}else L=e[21],D=e[22],P=e[23],O=e[24],z=e[25],$=e[26],q=e[27],F=e[28];let G;e[29]!==c||e[30]!==o||e[31]!==h||e[32]!==s?(G=n.jsx(gs,{icon:s,name:o,size:h,className:c}),e[29]=c,e[30]=o,e[31]=h,e[32]=s,e[33]=G):G=e[33];let H;e[34]!==m||e[35]!==f?(H=f&&!m&&n.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/50 opacity-0 group-hover:opacity-100 transition-opacity",children:n.jsx(Sl,{size:16,className:"text-white"})}),e[34]=m,e[35]=f,e[36]=H):H=e[36];let U;e[37]!==P||e[38]!==O||e[39]!==G||e[40]!==H||e[41]!==F?(U=n.jsxs("button",{type:F,disabled:P,className:O,children:[G,H]}),e[37]=P,e[38]=O,e[39]=G,e[40]=H,e[41]=F,e[42]=U):U=e[42];let Y;e[43]!==L||e[44]!==z||e[45]!==U?(Y=n.jsx(L,{asChild:z,children:U}),e[43]=L,e[44]=z,e[45]=U,e[46]=Y):Y=e[46];let W;e[47]!==o||e[48]!==s?(W=n.jsx("div",{className:"flex items-center justify-center py-4",children:n.jsx(gs,{icon:s,name:o,size:"xl"})}),e[47]=o,e[48]=s,e[49]=W):W=e[49];let K;e[50]===Symbol.for("react.memo_cache_sentinel")?(K=()=>v("icons"),e[50]=K):K=e[50];const ee=_==="icons"?"border-foreground text-foreground":"border-transparent text-muted-foreground hover:text-foreground";let Z;e[51]!==ee?(Z=J("px-3 py-2 text-sm font-medium border-b-2 -mb-px transition-colors",ee),e[51]=ee,e[52]=Z):Z=e[52];let X;e[53]!==Z?(X=n.jsx("button",{type:"button",onClick:K,className:Z,children:"Icons"}),e[53]=Z,e[54]=X):X=e[54];let ie;e[55]===Symbol.for("react.memo_cache_sentinel")?(ie=()=>v("upload"),e[55]=ie):ie=e[55];const re=_==="upload"?"border-foreground text-foreground":"border-transparent text-muted-foreground hover:text-foreground";let de;e[56]!==re?(de=J("px-3 py-2 text-sm font-medium border-b-2 -mb-px transition-colors",re),e[56]=re,e[57]=de):de=e[57];let me;e[58]!==de?(me=n.jsx("button",{type:"button",onClick:ie,className:de,children:"Upload"}),e[58]=de,e[59]=me):me=e[59];let le;e[60]===Symbol.for("react.memo_cache_sentinel")?(le=n.jsx("div",{className:"flex-1"}),e[60]=le):le=e[60];let se;e[61]!==X||e[62]!==me?(se=n.jsxs("div",{className:"flex items-center border-b border-border px-3",children:[X,me,le]}),e[61]=X,e[62]=me,e[63]=se):se=e[63];let _e;e[64]!==R||e[65]!==M||e[66]!==I||e[67]!==A||e[68]!==w.name||e[69]!==w.type||e[70]!==x||e[71]!==V||e[72]!==_?(_e=_==="icons"?n.jsx(Lw,{search:x,onSearchChange:b,selectedColor:V,onColorChange:R,onSelectIcon:I,onRandom:M,currentIconName:w.type==="icon"?w.name:null}):n.jsx(Ow,{onUpload:A}),e[64]=R,e[65]=M,e[66]=I,e[67]=A,e[68]=w.name,e[69]=w.type,e[70]=x,e[71]=V,e[72]=_,e[73]=_e):_e=e[73];let ge;e[74]!==W||e[75]!==se||e[76]!==_e?(ge=n.jsx(ci,{align:"start",className:"w-80 p-0",onOpenAutoFocus:Dw,children:n.jsxs("div",{className:"flex flex-col",children:[W,se,_e]})}),e[74]=W,e[75]=se,e[76]=_e,e[77]=ge):ge=e[77];let Se;return e[78]!==D||e[79]!==$||e[80]!==q||e[81]!==Y||e[82]!==ge?(Se=n.jsxs(D,{open:$,onOpenChange:q,children:[Y,ge]}),e[78]=D,e[79]=$,e[80]=q,e[81]=Y,e[82]=ge,e[83]=Se):Se=e[83],Se}function Dw(t){return t.preventDefault()}function Mw(t){const e=B.c(27),{selectedColor:s,onColorChange:i}=t,[r,o]=S.useState(!1);let a,l,c,d,u,h,f;if(e[0]!==r||e[1]!==s){const x=eu(s);l=di,h=r,f=o,a=li,u=!0,c="button",d=J("h-6 w-6 rounded-full shrink-0 ring-2 ring-offset-2 ring-offset-background transition-all cursor-pointer hover:scale-110",x.dot,"ring-foreground/20"),e[0]=r,e[1]=s,e[2]=a,e[3]=l,e[4]=c,e[5]=d,e[6]=u,e[7]=h,e[8]=f}else a=e[2],l=e[3],c=e[4],d=e[5],u=e[6],h=e[7],f=e[8];let m;e[9]!==c||e[10]!==d?(m=n.jsx("button",{type:c,className:d,title:"Change color"}),e[9]=c,e[10]=d,e[11]=m):m=e[11];let p;e[12]!==a||e[13]!==u||e[14]!==m?(p=n.jsx(a,{asChild:u,children:m}),e[12]=a,e[13]=u,e[14]=m,e[15]=p):p=e[15];let g;e[16]!==i||e[17]!==s?(g=Mg.map(x=>n.jsx("button",{type:"button",onClick:()=>{i(x.name),o(!1)},className:J("h-5 w-5 rounded-full transition-all shrink-0 cursor-pointer",x.dot,s===x.name?"ring-2 ring-offset-1 ring-offset-background ring-foreground/30 scale-110":"hover:scale-110"),title:x.name},x.name)),e[16]=i,e[17]=s,e[18]=g):g=e[18];let _;e[19]!==g?(_=n.jsx(ci,{align:"start",side:"right",sideOffset:8,className:"w-auto p-2",onOpenAutoFocus:Pw,children:n.jsx("div",{className:"grid grid-cols-4 gap-1",children:g})}),e[19]=g,e[20]=_):_=e[20];let v;return e[21]!==l||e[22]!==h||e[23]!==f||e[24]!==p||e[25]!==_?(v=n.jsxs(l,{open:h,onOpenChange:f,children:[p,_]}),e[21]=l,e[22]=h,e[23]=f,e[24]=p,e[25]=_,e[26]=v):v=e[26],v}function Pw(t){return t.preventDefault()}function Lw(t){const e=B.c(44),{search:s,onSearchChange:i,selectedColor:r,onColorChange:o,onSelectIcon:a,onRandom:l,currentIconName:c}=t;let d,u,h,f,m,p,g;if(e[0]!==c||e[1]!==o||e[2]!==l||e[3]!==i||e[4]!==a||e[5]!==s||e[6]!==r){const y=wl(),C=eu(r);u=s.trim()?y.filter(R=>{const N=fa(R),A=s.toLowerCase();return N.includes(A)||R.toLowerCase().includes(A)}):y,p="flex flex-col";let k;e[14]===Symbol.for("react.memo_cache_sentinel")?(k=n.jsx(kl,{size:14,className:"absolute left-2 top-1/2 -translate-y-1/2 text-muted-foreground pointer-events-none"}),e[14]=k):k=e[14];let w;e[15]!==i?(w=R=>i(R.target.value),e[15]=i,e[16]=w):w=e[16];let V;e[17]!==s||e[18]!==w?(V=n.jsxs("div",{className:"relative flex-1",children:[k,n.jsx(gt,{value:s,onChange:w,placeholder:"Filter...",className:"h-8 text-xs pl-7"})]}),e[17]=s,e[18]=w,e[19]=V):V=e[19];let j;e[20]===Symbol.for("react.memo_cache_sentinel")?(j=n.jsx(Dg,{size:14,className:"text-muted-foreground"}),e[20]=j):j=e[20];let I;e[21]!==l?(I=n.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:j}),e[21]=l,e[22]=I):I=e[22];let T;e[23]!==o||e[24]!==r?(T=n.jsx(Mw,{selectedColor:r,onColorChange:o}),e[23]=o,e[24]=r,e[25]=T):T=e[25],e[26]!==I||e[27]!==T||e[28]!==V?(g=n.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",children:[V,I,T]}),e[26]=I,e[27]=T,e[28]=V,e[29]=g):g=e[29],d=zh,m="h-56",h="grid grid-cols-9 gap-0.5 px-2 pb-2",f=u.map(R=>{const N=qn(R);return N?n.jsx("button",{type:"button",onClick:()=>a(R),className:J("h-8 w-8 flex items-center justify-center rounded-md transition-colors cursor-pointer",c===R?J(C.bg,C.text):J(C.text,"hover:bg-accent")),title:R,children:n.jsx(N,{size:18})},R):null}),e[0]=c,e[1]=o,e[2]=l,e[3]=i,e[4]=a,e[5]=s,e[6]=r,e[7]=d,e[8]=u,e[9]=h,e[10]=f,e[11]=m,e[12]=p,e[13]=g}else d=e[7],u=e[8],h=e[9],f=e[10],m=e[11],p=e[12],g=e[13];let _;e[30]!==h||e[31]!==f?(_=n.jsx("div",{className:h,children:f}),e[30]=h,e[31]=f,e[32]=_):_=e[32];let v;e[33]!==u.length?(v=u.length===0&&n.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 x;e[35]!==d||e[36]!==m||e[37]!==_||e[38]!==v?(x=n.jsxs(d,{className:m,children:[_,v]}),e[35]=d,e[36]=m,e[37]=_,e[38]=v,e[39]=x):x=e[39];let b;return e[40]!==p||e[41]!==g||e[42]!==x?(b=n.jsxs("div",{className:p,children:[g,x]}),e[40]=p,e[41]=g,e[42]=x,e[43]=b):b=e[43],b}function Ow(t){const e=B.c(27),{onUpload:s}=t,i=S.useRef(null);let r;e[0]!==s?(r=k=>{const w=k.target.files?.[0];if(!w)return;if(w.size>2097152){ue.error("Image must be smaller than 2MB"),k.target.value="";return}const V=new FileReader;V.onerror=()=>{ue.error("Failed to read image file"),i.current&&(i.current.value="")},V.onloadend=()=>{V.readyState===FileReader.DONE&&V.result&&s(V.result),i.current&&(i.current.value="")},V.readAsDataURL(w)},e[0]=s,e[1]=r):r=e[1];const o=r,[a,l]=S.useState("");let c;e[2]!==s||e[3]!==a?(c=()=>{const k=a.trim();k&&(s(k),l(""))},e[2]=s,e[3]=a,e[4]=c):c=e[4];const d=c;let u;e[5]!==o?(u=n.jsx("input",{type:"file",ref:i,className:"hidden",accept:"image/*",onChange:o}),e[5]=o,e[6]=u):u=e[6];let h;e[7]===Symbol.for("react.memo_cache_sentinel")?(h=()=>i.current?.click(),e[7]=h):h=e[7];let f;e[8]===Symbol.for("react.memo_cache_sentinel")?(f=n.jsxs("button",{type:"button",onClick:h,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:[n.jsx(lu,{size:20}),n.jsx("span",{className:"text-xs",children:"Click to upload an image (max 2MB)"})]}),e[8]=f):f=e[8];let m;e[9]===Symbol.for("react.memo_cache_sentinel")?(m=n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"text-xs text-muted-foreground",children:"or"}),n.jsx("div",{className:"flex-1 h-px bg-border"})]}),e[9]=m):m=e[9];let p;e[10]===Symbol.for("react.memo_cache_sentinel")?(p=k=>l(k.target.value),e[10]=p):p=e[10];let g;e[11]!==d?(g=k=>{k.key==="Enter"&&(k.preventDefault(),d())},e[11]=d,e[12]=g):g=e[12];let _;e[13]!==a||e[14]!==g?(_=n.jsx(gt,{value:a,onChange:p,placeholder:"Paste image URL...",className:"h-8 text-xs flex-1",onKeyDown:g}),e[13]=a,e[14]=g,e[15]=_):_=e[15];let v;e[16]!==a?(v=a.trim(),e[16]=a,e[17]=v):v=e[17];const x=!v;let b;e[18]!==d||e[19]!==x?(b=n.jsx(ae,{variant:"outline",size:"sm",className:"h-8 px-3 text-xs shrink-0",onClick:d,disabled:x,children:"Apply"}),e[18]=d,e[19]=x,e[20]=b):b=e[20];let y;e[21]!==b||e[22]!==_?(y=n.jsxs("div",{className:"flex items-center gap-1.5",children:[_,b]}),e[21]=b,e[22]=_,e[23]=y):y=e[23];let C;return e[24]!==y||e[25]!==u?(C=n.jsxs("div",{className:"flex flex-col gap-3 p-4",children:[u,f,m,y]}),e[24]=y,e[25]=u,e[26]=C):C=e[26],C}function Bw(t){const e=B.c(5),{value:s}=t;let i;if(e[0]!==s){i=Symbol.for("react.early_return_sentinel");e:{const o=Kn(s);if(o.type==="icon"){const a=qn(o.name);if(a){let l;e[2]!==a?(l=n.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=n.jsx(ju,{size:16,className:"text-muted-foreground"}),e[4]=r):r=e[4],r}function $w(t){const e=B.c(66),{value:s,onChange:i,className:r,disabled:o}=t,[a,l]=S.useState(!1),[c,d]=S.useState("");let u;e[0]!==s?(u=Kn(s),e[0]=s,e[1]=u):u=e[1];const h=u,f=h.type==="icon"?h.name:null;let m,p,g,_,v,x,b,y,C,k,w,V,j,I,T;if(e[2]!==r||e[3]!==f||e[4]!==o||e[5]!==i||e[6]!==a||e[7]!==c||e[8]!==s){const D=wl();_=c.trim()?D.filter(G=>{const H=c.toLowerCase();return fa(G).includes(H)||G.toLowerCase().includes(H)}):D,g=di,v=o?!1:a,x=l;const P=o?"cursor-default opacity-50":"cursor-pointer hover:bg-accent";let O;e[24]!==r||e[25]!==P?(O=J("size-7 shrink-0 rounded-md transition-colors flex items-center justify-center",P,r),e[24]=r,e[25]=P,e[26]=O):O=e[26];let z;e[27]!==s?(z=n.jsx(Bw,{value:s}),e[27]=s,e[28]=z):z=e[28],e[29]!==o||e[30]!==O||e[31]!==z?(b=n.jsx(li,{asChild:!0,children:n.jsx("button",{type:"button",disabled:o,className:O,children:z})}),e[29]=o,e[30]=O,e[31]=z,e[32]=b):b=e[32],p=ci,j="start",I="w-64 p-0",T=zw,w="flex flex-col";let $;e[33]===Symbol.for("react.memo_cache_sentinel")?($=n.jsx(kl,{size:14,className:"absolute left-2 top-1/2 -translate-y-1/2 text-muted-foreground pointer-events-none"}),e[33]=$):$=e[33];let q;e[34]===Symbol.for("react.memo_cache_sentinel")?(q=G=>d(G.target.value),e[34]=q):q=e[34],e[35]!==c?(V=n.jsx("div",{className:"px-2 py-2",children:n.jsxs("div",{className:"relative",children:[$,n.jsx(gt,{value:c,onChange:q,placeholder:"Filter...",className:"h-7 text-xs pl-7"})]})}),e[35]=c,e[36]=V):V=e[36],m=zh,k="h-48",y="grid grid-cols-8 gap-0.5 px-2 pb-2";let F;e[37]!==f||e[38]!==i?(F=G=>{const H=qn(G);return H?n.jsx("button",{type:"button",onClick:()=>{i(`icon://${G}`),l(!1)},className:J("h-7 w-7 flex items-center justify-center rounded-md transition-colors cursor-pointer",f===G?"bg-accent text-foreground":"text-muted-foreground hover:bg-accent hover:text-foreground"),title:fa(G),children:n.jsx(H,{size:16})},G):null},e[37]=f,e[38]=i,e[39]=F):F=e[39],C=_.map(F),e[2]=r,e[3]=f,e[4]=o,e[5]=i,e[6]=a,e[7]=c,e[8]=s,e[9]=m,e[10]=p,e[11]=g,e[12]=_,e[13]=v,e[14]=x,e[15]=b,e[16]=y,e[17]=C,e[18]=k,e[19]=w,e[20]=V,e[21]=j,e[22]=I,e[23]=T}else m=e[9],p=e[10],g=e[11],_=e[12],v=e[13],x=e[14],b=e[15],y=e[16],C=e[17],k=e[18],w=e[19],V=e[20],j=e[21],I=e[22],T=e[23];let R;e[40]!==y||e[41]!==C?(R=n.jsx("div",{className:y,children:C}),e[40]=y,e[41]=C,e[42]=R):R=e[42];let N;e[43]!==_.length?(N=_.length===0&&n.jsx("div",{className:"flex items-center justify-center py-6 text-xs text-muted-foreground",children:"No icons found"}),e[43]=_.length,e[44]=N):N=e[44];let A;e[45]!==m||e[46]!==R||e[47]!==N||e[48]!==k?(A=n.jsxs(m,{className:k,children:[R,N]}),e[45]=m,e[46]=R,e[47]=N,e[48]=k,e[49]=A):A=e[49];let E;e[50]!==A||e[51]!==w||e[52]!==V?(E=n.jsxs("div",{className:w,children:[V,A]}),e[50]=A,e[51]=w,e[52]=V,e[53]=E):E=e[53];let M;e[54]!==p||e[55]!==E||e[56]!==j||e[57]!==I||e[58]!==T?(M=n.jsx(p,{align:j,className:I,onOpenAutoFocus:T,children:E}),e[54]=p,e[55]=E,e[56]=j,e[57]=I,e[58]=T,e[59]=M):M=e[59];let L;return e[60]!==g||e[61]!==v||e[62]!==x||e[63]!==b||e[64]!==M?(L=n.jsxs(g,{open:v,onOpenChange:x,children:[b,M]}),e[60]=g,e[61]=v,e[62]=x,e[63]=b,e[64]=M,e[65]=L):L=e[65],L}function zw(t){return t.preventDefault()}function Rr(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx("div",{className:"flex items-center justify-center h-32",children:n.jsx(Me,{className:"animate-spin text-muted-foreground",size:24})}),t[0]=e):e=t[0],e}function Ho(t){return({error:e})=>e?.message?.includes("Method not found")||e?.code===-32601?n.jsx("div",{className:"flex-1 overflow-auto px-4 py-3 space-y-1",children:n.jsx("div",{className:"flex items-center justify-center h-32 text-sm text-muted-foreground",children:t})}):n.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center h-full p-6 text-center space-y-4",children:[n.jsx("div",{className:"bg-destructive/10 p-3 rounded-full",children:n.jsx(ul,{className:"h-6 w-6 text-destructive"})}),n.jsxs("div",{className:"space-y-2",children:[n.jsx("h3",{className:"text-lg font-medium",children:"Something went wrong"}),n.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 Fw(t){const e=B.c(23),{item:s,isSelected:i,onToggle:r,disabled:o}=t,a=o?"cursor-not-allowed opacity-50":"cursor-pointer",l=i?"bg-accent/25":"hover:bg-muted/50";let c;e[0]!==a||e[1]!==l?(c=J("flex items-start gap-3 p-4 rounded-lg transition-colors",a,l),e[0]=a,e[1]=l,e[2]=c):c=e[2];let d;e[3]!==s.name?(d=n.jsx("p",{className:"text-sm font-medium leading-none truncate",children:s.name}),e[3]=s.name,e[4]=d):d=e[4];let u;e[5]!==s.tags?(u=s.tags&&n.jsx("span",{className:"shrink-0",children:s.tags}),e[5]=s.tags,e[6]=u):u=e[6];let h;e[7]!==d||e[8]!==u?(h=n.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[d,u]}),e[7]=d,e[8]=u,e[9]=h):h=e[9];let f;e[10]!==s.description?(f=s.description&&n.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 m;e[12]!==h||e[13]!==f?(m=n.jsxs("div",{className:"flex-1 min-w-0 space-y-2",children:[h,f]}),e[12]=h,e[13]=f,e[14]=m):m=e[14];let p;e[15]!==o||e[16]!==i||e[17]!==r?(p=n.jsx(H_,{checked:i,onCheckedChange:r,disabled:o,className:"mt-0.5"}),e[15]=o,e[16]=i,e[17]=r,e[18]=p):p=e[18];let g;return e[19]!==c||e[20]!==m||e[21]!==p?(g=n.jsxs("label",{className:c,children:[m,p]}),e[19]=c,e[20]=m,e[21]=p,e[22]=g):g=e[22],g}function tc(t){const e=B.c(13),{items:s,selections:i,onToggle:r,emptyMessage:o,disabled:a}=t;let l,c,d;if(e[0]!==a||e[1]!==o||e[2]!==s||e[3]!==r||e[4]!==i){d=Symbol.for("react.early_return_sentinel");e:{const h=s.map(Uw);if(s.length===0){let f;e[8]!==o?(f=n.jsx("div",{className:"flex-1 overflow-auto px-4 py-3 space-y-1",children:n.jsx("div",{className:"flex items-center justify-center h-32 text-sm text-muted-foreground",children:o})}),e[8]=o,e[9]=f):f=e[9],d=f;break e}l="flex-1 overflow-auto px-4 py-3 space-y-1",c=s.map(f=>n.jsx(Fw,{item:f,isSelected:i===null||i?.includes(f.id),onToggle:()=>r(f.id,h),disabled:a},f.id))}e[0]=a,e[1]=o,e[2]=s,e[3]=r,e[4]=i,e[5]=l,e[6]=c,e[7]=d}else l=e[5],c=e[6],d=e[7];if(d!==Symbol.for("react.early_return_sentinel"))return d;let u;return e[10]!==l||e[11]!==c?(u=n.jsx("div",{className:l,children:c}),e[10]=l,e[11]=c,e[12]=u):u=e[12],u}function Uw(t){return t.id}function Hw(t){const e=B.c(12),{connectionId:s,selections:i,onToggle:r,disabled:o}=t,{org:a}=xe();let l;e[0]!==s||e[1]!==a.id?(l={connectionId:s,orgId:a.id},e[0]=s,e[1]=a.id,e[2]=l):l=e[2];const c=Be(l);let d;e[3]!==c?(d={client:c},e[3]=c,e[4]=d):d=e[4];const{data:u}=A_(d);let h;e[5]!==u.tools?(h=u.tools.map(Ww),e[5]=u.tools,e[6]=h):h=e[6];const f=h;let m;return e[7]!==o||e[8]!==f||e[9]!==r||e[10]!==i?(m=n.jsx(tc,{items:f,selections:i,onToggle:r,emptyMessage:"No tools available",disabled:o}),e[7]=o,e[8]=f,e[9]=r,e[10]=i,e[11]=m):m=e[11],m}function Ww(t){return{id:t.name,name:t.name,description:t.description,tags:n.jsx(F_,{annotations:t.annotations,_meta:t._meta})}}function Kw(t){const e=B.c(12),{connectionId:s,selections:i,onToggle:r,disabled:o}=t,{org:a}=xe();let l;e[0]!==s||e[1]!==a.id?(l={connectionId:s,orgId:a.id},e[0]=s,e[1]=a.id,e[2]=l):l=e[2];const c=Be(l);let d;e[3]!==c?(d={client:c},e[3]=c,e[4]=d):d=e[4];const{data:u}=a_(d);let h;e[5]!==u.resources?(h=u.resources.map(qw),e[5]=u.resources,e[6]=h):h=e[6];const f=h;let m;return e[7]!==o||e[8]!==f||e[9]!==r||e[10]!==i?(m=n.jsx(tc,{items:f,selections:i,onToggle:r,emptyMessage:"No resources available",disabled:o}),e[7]=o,e[8]=f,e[9]=r,e[10]=i,e[11]=m):m=e[11],m}function qw(t){return{id:t.name||t.uri,name:t.name||t.uri,description:t.description}}function Gw(t){const e=B.c(12),{connectionId:s,selections:i,onToggle:r,disabled:o}=t,{org:a}=xe();let l;e[0]!==s||e[1]!==a.id?(l={connectionId:s,orgId:a.id},e[0]=s,e[1]=a.id,e[2]=l):l=e[2];const c=Be(l);let d;e[3]!==c?(d={client:c},e[3]=c,e[4]=d):d=e[4];const{data:u}=Uh(d);let h;e[5]!==u.prompts?(h=u.prompts.map(Yw),e[5]=u.prompts,e[6]=h):h=e[6];const f=h;let m;return e[7]!==o||e[8]!==f||e[9]!==r||e[10]!==i?(m=n.jsx(tc,{items:f,selections:i,onToggle:r,emptyMessage:"No prompts available",disabled:o}),e[7]=o,e[8]=f,e[9]=r,e[10]=i,e[11]=m):m=e[11],m}function Yw(t){return{id:t.name,name:t.name,description:t.description}}function Xw(t){const e=B.c(54),{currentConnection:s,activeTab:i,selectedId:r,formData:o,toggleTool:a,toggleResource:l,togglePrompt:c,toggleAllTools:d,toggleAllResources:u,toggleAllPrompts:h,onTabChange:f}=t,m=o[r],p=i==="tools"?m?.tools===null:i==="resources"?m?.resources===null:m?.prompts===null;let g;e[0]!==i||e[1]!==r||e[2]!==h||e[3]!==u||e[4]!==d?(g=()=>{i==="tools"?d(r):i==="resources"?u(r):h(r)},e[0]=i,e[1]=r,e[2]=h,e[3]=u,e[4]=d,e[5]=g):g=e[5];const _=g;let v;e[6]!==s.icon||e[7]!==s.title?(v=n.jsx(Ls,{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 x;e[9]!==s.title?(x=n.jsx("h2",{className:"text-base font-semibold truncate",children:s.title}),e[9]=s.title,e[10]=x):x=e[10];let b;e[11]!==s.description?(b=s.description&&n.jsx("p",{className:"text-xs text-muted-foreground truncate",children:s.description}),e[11]=s.description,e[12]=b):b=e[12];let y;e[13]!==x||e[14]!==b?(y=n.jsxs("div",{className:"flex-1 min-w-0",children:[x,b]}),e[13]=x,e[14]=b,e[15]=y):y=e[15];let C;e[16]!==v||e[17]!==y?(C=n.jsx("div",{className:"px-6 pt-5 pb-4 shrink-0",children:n.jsxs("div",{className:"flex items-center gap-3",children:[v,y]})}),e[16]=v,e[17]=y,e[18]=C):C=e[18];let k;e[19]===Symbol.for("react.memo_cache_sentinel")?(k=[{id:"tools",label:"Tools"},{id:"resources",label:"Resources"},{id:"prompts",label:"Prompts"}],e[19]=k):k=e[19];let w;e[20]!==f?(w=L=>f(L),e[20]=f,e[21]=w):w=e[21];let V;e[22]!==i||e[23]!==w?(V=n.jsx(bu,{tabs:k,activeTab:i,onTabChange:w}),e[22]=i,e[23]=w,e[24]=V):V=e[24];const j=p?"Deselect all":"Select all";let I;e[25]!==_||e[26]!==j?(I=n.jsx("button",{type:"button",onClick:_,className:"text-xs text-muted-foreground hover:text-foreground transition-colors",children:j}),e[25]=_,e[26]=j,e[27]=I):I=e[27];let T;e[28]!==I||e[29]!==V?(T=n.jsxs("div",{className:"flex items-center justify-between px-6 py-3 border-t border-border shrink-0",children:[V,I]}),e[28]=I,e[29]=V,e[30]=T):T=e[30];let R;e[31]!==i||e[32]!==o||e[33]!==r||e[34]!==a?(R=i==="tools"&&n.jsx(As,{fallback:Ho("Tools not supported by this server"),children:n.jsx(S.Suspense,{fallback:n.jsx(Rr,{}),children:n.jsx(Hw,{connectionId:r,selections:o[r]?o[r].tools:[],onToggle:(L,D)=>a(r,L,D)})})}),e[31]=i,e[32]=o,e[33]=r,e[34]=a,e[35]=R):R=e[35];let N;e[36]!==i||e[37]!==o||e[38]!==r||e[39]!==l?(N=i==="resources"&&n.jsx(As,{fallback:Ho("Resources not supported by this server"),children:n.jsx(S.Suspense,{fallback:n.jsx(Rr,{}),children:n.jsx(Kw,{connectionId:r,selections:o[r]?o[r].resources:[],onToggle:(L,D)=>l(r,L,D)})})}),e[36]=i,e[37]=o,e[38]=r,e[39]=l,e[40]=N):N=e[40];let A;e[41]!==i||e[42]!==o||e[43]!==r||e[44]!==c?(A=i==="prompts"&&n.jsx(As,{fallback:Ho("Prompts not supported by this server"),children:n.jsx(S.Suspense,{fallback:n.jsx(Rr,{}),children:n.jsx(Gw,{connectionId:r,selections:o[r]?o[r].prompts:[],onToggle:(L,D)=>c(r,L,D)})})}),e[41]=i,e[42]=o,e[43]=r,e[44]=c,e[45]=A):A=e[45];let E;e[46]!==R||e[47]!==N||e[48]!==A?(E=n.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[R,N,A]}),e[46]=R,e[47]=N,e[48]=A,e[49]=E):E=e[49];let M;return e[50]!==T||e[51]!==E||e[52]!==C?(M=n.jsxs(n.Fragment,{children:[C,T,E]}),e[50]=T,e[51]=E,e[52]=C,e[53]=M):M=e[53],M}function Jw(t){const e=B.c(11),{connectionId:s,onAuthenticate:i,children:r}=t;let o;e[0]!==s?(o={connectionId:s},e[0]=s,e[1]=o):o=e[1];const a=Du(o);if(a.supportsOAuth&&!a.isAuthenticated){let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx("div",{className:"flex items-center justify-center size-12 rounded-full bg-muted",children:n.jsx(Pg,{size:22,className:"text-muted-foreground"})}),e[2]=d):d=e[2];let u;e[3]===Symbol.for("react.memo_cache_sentinel")?(u=n.jsxs("div",{className:"space-y-1",children:[n.jsx("p",{className:"text-sm font-medium",children:"Authorization required"}),n.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 h;e[4]!==s||e[5]!==i?(h=i&&n.jsx(ae,{variant:"outline",size:"sm",onClick:()=>i(s),children:"Authorize"}),e[4]=s,e[5]=i,e[6]=h):h=e[6];let f;return e[7]!==h?(f=n.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-4 p-8 text-center",children:[d,u,h]}),e[7]=h,e[8]=f):f=e[8],f}let c;return e[9]!==r?(c=n.jsx(n.Fragment,{children:r}),e[9]=r,e[10]=c):c=e[10],c}function Qw(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 wd(t){return Object.entries(t).map(([e,s])=>({connection_id:e,selected_tools:s.tools,selected_resources:s.resources,selected_prompts:s.prompts}))}function Zw(t,e){return e.type==="SET_ACTIVE_TAB"?{...t,activeTab:e.payload}:t}function eV(t){const e=B.c(49),{open:s,onOpenChange:i,selectedId:r,form:o,connections:a,onAuthenticate:l}=t;let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c={activeTab:"tools"},e[0]=c):c=e[0];const[d,u]=S.useReducer(Zw,c),h=Al(r??"");let f;e[1]!==a?(f=a??[],e[1]=a,e[2]=f):f=e[2];let m;e[3]!==f?(m=Qw(f),e[3]=f,e[4]=m):m=e[4];const p=m;let g;e[5]!==o||e[6]!==p?(g=($,q,F,G)=>{const H=p[$]?.[q];let U;H===null?U=G.filter(W=>W!==F):H?.includes(F)?U=H.filter(W=>W!==F):(U=[...H??[],F],U.length===G.length&&(U=null));const Y={...p};Y[$]?Y[$]={...Y[$]}:Y[$]={tools:null,resources:null,prompts:null},Y[$][q]=U,o.setValue("connections",wd(Y),{shouldDirty:!0,shouldTouch:!0})},e[5]=o,e[6]=p,e[7]=g):g=e[7];const _=g;let v;e[8]!==o||e[9]!==p?(v=($,q)=>{const G=p[$]?.[q]===null?[]:null,H={...p};H[$]?H[$]={...H[$]}:H[$]={tools:null,resources:null,prompts:null},H[$][q]=G,o.setValue("connections",wd(H),{shouldDirty:!0,shouldTouch:!0})},e[8]=o,e[9]=p,e[10]=v):v=e[10];const x=v;let b;e[11]!==_?(b=($,q,F)=>_($,"tools",q,F),e[11]=_,e[12]=b):b=e[12];const y=b;let C;e[13]!==_?(C=($,q,F)=>_($,"resources",q,F),e[13]=_,e[14]=C):C=e[14];const k=C;let w;e[15]!==_?(w=($,q,F)=>_($,"prompts",q,F),e[15]=_,e[16]=w):w=e[16];const V=w;let j;e[17]!==x?(j=$=>x($,"tools"),e[17]=x,e[18]=j):j=e[18];const I=j;let T;e[19]!==x?(T=$=>x($,"resources"),e[19]=x,e[20]=T):T=e[20];const R=T;let N;e[21]!==x?(N=$=>x($,"prompts"),e[21]=x,e[22]=N):N=e[22];const A=N;if(!r||!h)return null;let E;e[23]===Symbol.for("react.memo_cache_sentinel")?(E=n.jsx(Rr,{}),e[23]=E):E=e[23];let M;e[24]===Symbol.for("react.memo_cache_sentinel")?(M=$=>u({type:"SET_ACTIVE_TAB",payload:$}),e[24]=M):M=e[24];let L;e[25]!==h||e[26]!==d.activeTab||e[27]!==p||e[28]!==r||e[29]!==A||e[30]!==R||e[31]!==I||e[32]!==V||e[33]!==k||e[34]!==y?(L=n.jsx(Xw,{currentConnection:h,activeTab:d.activeTab,selectedId:r,formData:p,toggleTool:y,toggleResource:k,togglePrompt:V,toggleAllTools:I,toggleAllResources:R,toggleAllPrompts:A,onTabChange:M},r),e[25]=h,e[26]=d.activeTab,e[27]=p,e[28]=r,e[29]=A,e[30]=R,e[31]=I,e[32]=V,e[33]=k,e[34]=y,e[35]=L):L=e[35];let D;e[36]!==l||e[37]!==r||e[38]!==L?(D=n.jsx(S.Suspense,{fallback:E,children:n.jsx(Jw,{connectionId:r,onAuthenticate:l,children:L})}),e[36]=l,e[37]=r,e[38]=L,e[39]=D):D=e[39];let P;e[40]!==i?(P=n.jsx(_l,{className:"px-6 py-4 border-t border-border shrink-0",children:n.jsx(ae,{variant:"outline",onClick:()=>i(!1),children:"Done"})}),e[40]=i,e[41]=P):P=e[41];let O;e[42]!==D||e[43]!==P?(O=n.jsxs(ts,{className:"sm:max-w-2xl h-[75vh] max-h-[75vh] flex flex-col p-0 gap-0 overflow-hidden w-[95vw]",children:[D,P]}),e[42]=D,e[43]=P,e[44]=O):O=e[44];let z;return e[45]!==i||e[46]!==s||e[47]!==O?(z=n.jsx(ss,{open:s,onOpenChange:i,children:O}),e[45]=i,e[46]=s,e[47]=O,e[48]=z):z=e[48],z}const Wo={tools:null,resources:null,prompts:null},tV=Lp.pick({status:!0,title:!0,description:!0,icon:!0,metadata:!0,connections:!0});function sV(t){const s=new TextEncoder().encode(t),i=Array.from(s,r=>String.fromCharCode(r)).join("");return btoa(i)}function iV(t){const e=B.c(11),{url:s,agentId:i}=t,[r,o]=S.useState(!1);let a;e[0]!==i||e[1]!==s?(a=async()=>{ne("agent_connect_action",{agent_id:i,action:"copy_url"}),await navigator.clipboard.writeText(s),o(!0),ue.success("Agent URL copied to clipboard"),setTimeout(()=>o(!1),2e3)},e[0]=i,e[1]=s,e[2]=a):a=e[2];const l=a;let c;e[3]!==r?(c=r?n.jsx(Jt,{size:20,className:"text-green-600"}):n.jsx(zi,{size:20}),e[3]=r,e[4]=c):c=e[4];const d=r?"Copied!":"Copy URL";let u;e[5]!==d?(u=n.jsx("span",{className:"text-xs font-medium",children:d}),e[5]=d,e[6]=u):u=e[6];let h;return e[7]!==l||e[8]!==c||e[9]!==u?(h=n.jsxs(ae,{type:"button",variant:"outline",onClick:l,className:"h-auto py-3 px-4 flex flex-col items-center gap-2",children:[c,u]}),e[7]=l,e[8]=c,e[9]=u,e[10]=h):h=e[10],h}function nV(t){const e=B.c(8),{url:s,serverName:i,agentId:r}=t;let o;e[0]!==r||e[1]!==i||e[2]!==s?(o=()=>{ne("agent_connect_action",{agent_id:r,action:"install_cursor"});const u=_u(i),f=sV(JSON.stringify({type:"http",url:s,headers:{"x-mesh-client":"Cursor"}},null,2)),m=`cursor://anysphere.cursor-deeplink/mcp/install?name=${encodeURIComponent(u)}&config=${encodeURIComponent(f)}`;window.open(m,"_blank"),ue.success("Opening Cursor...")},e[0]=r,e[1]=i,e[2]=s,e[3]=o):o=e[3];const a=o;let l,c;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=n.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%)"}}),c=n.jsx("span",{className:"text-xs font-medium",children:"Install on Cursor"}),e[4]=l,e[5]=c):(l=e[4],c=e[5]);let d;return e[6]!==a?(d=n.jsxs(ae,{type:"button",variant:"outline",onClick:a,className:"h-auto py-3 px-4 flex flex-col items-center gap-2",children:[l,c]}),e[6]=a,e[7]=d):d=e[7],d}function rV(t){const e=B.c(12),{url:s,serverName:i,agentId:r}=t,[o,a]=S.useState(!1);let l;e[0]!==r||e[1]!==i||e[2]!==s?(l=async()=>{ne("agent_connect_action",{agent_id:r,action:"install_claude_code"});const m=_u(i),g=JSON.stringify({type:"http",url:s,headers:{"x-mesh-client":"Claude Code"}},null,2),_=`claude mcp add-json "${m}" '${g.replace(/'/g,"'\\''")}' --scope user`;await navigator.clipboard.writeText(_),a(!0),ue.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 c=l;let d;e[4]!==o?(d=o?n.jsx(Jt,{size:20,className:"text-green-600"}):n.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]=o,e[5]=d):d=e[5];const u=o?"Copied!":"Install on Claude Code";let h;e[6]!==u?(h=n.jsx("span",{className:"text-xs font-medium",children:u}),e[6]=u,e[7]=h):h=e[7];let f;return e[8]!==c||e[9]!==d||e[10]!==h?(f=n.jsxs(ae,{type:"button",variant:"outline",onClick:c,className:"h-auto py-3 px-4 flex flex-col items-center gap-2",children:[d,h]}),e[8]=c,e[9]=d,e[10]=h,e[11]=f):f=e[11],f}function oV({virtualMcp:t}){const{org:e}=xe(),s=Be({connectionId:Pt,orgId:e.id}),[i,r]=S.useState(null),[o,a]=S.useState(!1),[l,c]=S.useState(!1),d=t.id,u=t.title||`agent-${d.slice(0,8)}`,h=i?`bunx @decocms/typegen@latest --mcp ${d} --key ${i} --output client.ts`:`bunx @decocms/typegen@latest --mcp ${d} --key <api-key> --output client.ts`,f=async()=>{a(!0);try{const g=(await s.callTool({name:"API_KEY_CREATE",arguments:{name:`typegen-${u}`,permissions:{[d]:["*"]}}})).structuredContent?.key;if(!g)throw new Error("No key in response");r(g),ne("agent_typegen_key_generated",{agent_id:d})}catch{ne("agent_typegen_key_failed",{agent_id:d}),ue.error("Failed to generate API key")}finally{a(!1)}},m=async()=>{ne("agent_connect_action",{agent_id:d,action:"typegen_copy_command",has_api_key:!!i}),await navigator.clipboard.writeText(h),c(!0),ue.success("Command copied to clipboard"),setTimeout(()=>c(!1),2e3)};return n.jsxs("div",{className:"flex min-w-0 flex-col gap-3",children:[n.jsxs("div",{className:"flex items-start justify-between gap-3",children:[n.jsxs("div",{className:"flex flex-col gap-0.5",children:[n.jsx("h4",{className:"text-sm font-medium text-foreground",children:"Generate typed client"}),n.jsxs("p",{className:"text-xs text-muted-foreground",children:["Introspects this agent and writes a typed"," ",n.jsx("code",{className:"font-mono",children:"client.ts"})," you can import directly."]})]}),!i&&n.jsxs(ae,{type:"button",variant:"outline",size:"sm",className:"shrink-0 gap-1.5",onClick:f,disabled:o,children:[o?n.jsx(Me,{size:14,className:"animate-spin"}):n.jsx(Wg,{size:14}),n.jsx("span",{children:o?"Generating…":"Generate API key"})]})]}),i&&n.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."}),n.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Generate client"}),n.jsx("div",{className:"rounded-md border border-input bg-muted/50 px-3 py-2.5",children:n.jsxs("div",{className:"flex items-start gap-2",children:[n.jsx("code",{className:"min-w-0 flex-1 break-all font-mono text-xs text-muted-foreground",children:h}),n.jsx(ae,{type:"button",variant:"ghost",size:"icon",className:"size-6 shrink-0",onClick:m,children:l?n.jsx(Jt,{size:12,className:"text-green-600"}):n.jsx(zi,{size:12})})]})}),n.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Runtime variables"}),n.jsx(aV,{apiKey:i,agentId:d})]})}function aV(t){const e=B.c(21),{apiKey:s,agentId:i}=t,[r,o]=S.useState(!1),a=window.location.origin,l=s?`MESH_API_KEY=${s}`:"MESH_API_KEY=<api-key>",c=`MESH_BASE_URL=${a}`,d=`${l}
|
|
553
|
-
${c}`;let u;e[0]!==i||e[1]!==s||e[2]!==d?(u=async()=>{ne("agent_connect_action",{agent_id:i,action:"typegen_copy_env",has_api_key:!!s}),await navigator.clipboard.writeText(d),o(!0),setTimeout(()=>o(!1),2e3)},e[0]=i,e[1]=s,e[2]=d,e[3]=u):u=e[3];const h=u,f=!s;let m;e[4]!==f?(m=J({"opacity-50":f}),e[4]=f,e[5]=m):m=e[5];let p;e[6]!==l||e[7]!==m?(p=n.jsx("span",{className:m,children:l}),e[6]=l,e[7]=m,e[8]=p):p=e[8];let g,_;e[9]===Symbol.for("react.memo_cache_sentinel")?(g=n.jsx("br",{}),_=n.jsx("span",{children:c}),e[9]=g,e[10]=_):(g=e[9],_=e[10]);let v;e[11]!==p?(v=n.jsxs("code",{className:"min-w-0 flex-1 font-mono text-xs text-muted-foreground",children:[p,g,_]}),e[11]=p,e[12]=v):v=e[12];let x;e[13]!==r?(x=r?n.jsx(Jt,{size:12,className:"text-green-600"}):n.jsx(zi,{size:12}),e[13]=r,e[14]=x):x=e[14];let b;e[15]!==h||e[16]!==x?(b=n.jsx(ae,{type:"button",variant:"ghost",size:"icon",className:"size-6 shrink-0",onClick:h,children:x}),e[15]=h,e[16]=x,e[17]=b):b=e[17];let y;return e[18]!==v||e[19]!==b?(y=n.jsx("div",{className:"rounded-md border border-input bg-muted/50 px-3 py-2.5",children:n.jsxs("div",{className:"flex items-start gap-2",children:[v,b]})}),e[18]=v,e[19]=b,e[20]=y):y=e[20],y}function lV(t){const e=B.c(3),{virtualMcp:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx("div",{className:"h-20 animate-pulse rounded-md bg-muted"}),e[0]=i):i=e[0];let r;return e[1]!==s?(r=n.jsx(S.Suspense,{fallback:i,children:n.jsx(oV,{virtualMcp:s})}),e[1]=s,e[2]=r):r=e[2],r}function cV(t){const e=B.c(37),{open:s,onOpenChange:i,virtualMcp:r}=t,o=`/mcp/virtual-mcp/${r.id}`;let a;e[0]!==o?(a=new URL(o,window.location.origin),e[0]=o,e[1]=a):a=e[1];const l=a;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 d=c,u=Ps();let h;e[5]!==r.id||e[6]!==l.href?(h=n.jsx(iV,{url:l.href,agentId:r.id}),e[5]=r.id,e[6]=l.href,e[7]=h):h=e[7];let f,m;e[8]!==d||e[9]!==r.id||e[10]!==l.href?(f=n.jsx(nV,{url:l.href,serverName:d,agentId:r.id}),m=n.jsx(rV,{url:l.href,serverName:d,agentId:r.id}),e[8]=d,e[9]=r.id,e[10]=l.href,e[11]=f,e[12]=m):(f=e[11],m=e[12]);let p;e[13]!==h||e[14]!==f||e[15]!==m?(p=n.jsx("div",{className:"flex flex-col gap-3 pt-2",children:n.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[h,f,m]})}),e[13]=h,e[14]=f,e[15]=m,e[16]=p):p=e[16];let g;e[17]===Symbol.for("react.memo_cache_sentinel")?(g=n.jsx("div",{className:"border-t border-border"}),e[17]=g):g=e[17];let _;e[18]!==r?(_=n.jsx(lV,{virtualMcp:r}),e[18]=r,e[19]=_):_=e[19];let v;e[20]!==p||e[21]!==_?(v=n.jsxs("div",{className:"flex flex-col gap-6",children:[p,g,_]}),e[20]=p,e[21]=_,e[22]=v):v=e[22];const x=v;if(u){let k;e[23]===Symbol.for("react.memo_cache_sentinel")?(k=n.jsx(wi,{className:"mt-4 mb-4 text-base font-semibold",children:"Connect"}),e[23]=k):k=e[23];let w;e[24]!==x?(w=n.jsx(Vi,{children:n.jsxs("div",{className:"flex-1 overflow-y-auto px-4 pb-6 [touch-action:pan-y]",children:[k,x]})}),e[24]=x,e[25]=w):w=e[25];let V;return e[26]!==i||e[27]!==s||e[28]!==w?(V=n.jsx(Ci,{open:s,onOpenChange:i,children:w}),e[26]=i,e[27]=s,e[28]=w,e[29]=V):V=e[29],V}let b;e[30]===Symbol.for("react.memo_cache_sentinel")?(b=n.jsx(hs,{children:n.jsx(ds,{children:"Connect"})}),e[30]=b):b=e[30];let y;e[31]!==x?(y=n.jsxs(ts,{className:"max-h-[80vh] overflow-y-auto sm:max-w-2xl",children:[b,x]}),e[31]=x,e[32]=y):y=e[32];let C;return e[33]!==i||e[34]!==s||e[35]!==y?(C=n.jsx(ss,{open:s,onOpenChange:i,children:y}),e[33]=i,e[34]=s,e[35]=y,e[36]=C):C=e[36],C}function dV(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 hV(t){const e=B.c(22),{connection_id:s,usedConnectionIds:i,onOpenSettings:r,onRemove:o,onAuthenticate:a,onSwitchInstance:l,onNewInstance:c}=t,d=Al(s),{org:u}=xe();if(!d)return null;let h;e[0]!==d?(h=gu(d),e[0]=d,e[1]=h):h=e[1];const f=h;let m;e[2]!==s?(m=n.jsx(pV,{connection_id:s}),e[2]=s,e[3]=m):m=e[3];let p;e[4]!==d.app_name||e[5]!==d.connection_type||e[6]!==d.description||e[7]!==d.icon||e[8]!==d.title||e[9]!==s||e[10]!==a||e[11]!==c||e[12]!==r||e[13]!==o||e[14]!==l||e[15]!==u.slug||e[16]!==f||e[17]!==i?(p=n.jsx(mV,{connection_id:s,connectionTitle:d.title,connectionDescription:d.description,connectionIcon:d.icon,connectionType:d.connection_type,slug:f,orgSlug:u.slug,appName:d.app_name,usedConnectionIds:i,onOpenSettings:r,onRemove:o,onAuthenticate:a,onSwitchInstance:l,onNewInstance:c}),e[4]=d.app_name,e[5]=d.connection_type,e[6]=d.description,e[7]=d.icon,e[8]=d.title,e[9]=s,e[10]=a,e[11]=c,e[12]=r,e[13]=o,e[14]=l,e[15]=u.slug,e[16]=f,e[17]=i,e[18]=p):p=e[18];let g;return e[19]!==m||e[20]!==p?(g=n.jsx(S.Suspense,{fallback:m,children:p}),e[19]=m,e[20]=p,e[21]=g):g=e[21],g}const Vd="__new_instance__";async function uV(t,e){const s=t?.idToken??null;if(s){const r=Cd(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 o=await r.json(),a=typeof o.email=="string"?o.email:typeof o.upn=="string"?o.upn:typeof o.preferred_username=="string"?o.preferred_username:null;if(a)return a}}catch{}return Cd(e)}function Cd(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 fV(t){const e=B.c(23),{appName:s,connectionId:i,usedConnectionIds:r,onSwitchInstance:o,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 c=Gn(l);if(c.length<=1)return null;let d;e[2]!==i||e[3]!==a||e[4]!==o?(d=g=>{g===Vd?a?.():o(i,g)},e[2]=i,e[3]=a,e[4]=o,e[5]=d):d=e[5];let u;e[6]===Symbol.for("react.memo_cache_sentinel")?(u=n.jsx(ti,{size:"sm",className:"w-auto text-xs gap-1 px-2 shadow-none",children:n.jsx(si,{})}),e[6]=u):u=e[6];let h;if(e[7]!==i||e[8]!==c||e[9]!==r){let g;e[11]!==i||e[12]!==r?(g=_=>n.jsx(Ht,{value:_.id,className:"text-xs",disabled:_.id!==i&&r.has(_.id),children:_.title},_.id),e[11]=i,e[12]=r,e[13]=g):g=e[13],h=c.map(g),e[7]=i,e[8]=c,e[9]=r,e[10]=h}else h=e[10];let f;e[14]!==a?(f=a&&n.jsx(Ht,{value:Vd,className:"text-xs text-muted-foreground",children:"+ New instance"}),e[14]=a,e[15]=f):f=e[15];let m;e[16]!==h||e[17]!==f?(m=n.jsxs(Zs,{children:[h,f]}),e[16]=h,e[17]=f,e[18]=m):m=e[18];let p;return e[19]!==i||e[20]!==d||e[21]!==m?(p=n.jsxs(ei,{value:i,onValueChange:d,children:[u,m]}),e[19]=i,e[20]=d,e[21]=m,e[22]=p):p=e[22],p}function mV(t){const e=B.c(55),{connection_id:s,connectionTitle:i,connectionDescription:r,connectionIcon:o,connectionType:a,slug:l,orgSlug:c,appName:d,usedConnectionIds:u,onOpenSettings:h,onRemove:f,onAuthenticate:m,onSwitchInstance:p,onNewInstance:g}=t;let _;e[0]!==s?(_={connectionId:s},e[0]=s,e[1]=_):_=e[1];const v=Du(_),b=!(a==="VIRTUAL")&&v.supportsOAuth&&!v.isAuthenticated,y=b?"border-destructive/50 bg-destructive/5":"border-border";let C;e[2]!==y?(C=J("rounded-xl border overflow-hidden transition-colors",y),e[2]=y,e[3]=C):C=e[3];let k;e[4]!==c||e[5]!==l?(k={org:c,appSlug:l},e[4]=c,e[5]=l,e[6]=k):k=e[6];let w;e[7]!==o||e[8]!==i?(w=n.jsx(Ls,{icon:o,name:i,size:"sm",className:"shrink-0"}),e[7]=o,e[8]=i,e[9]=w):w=e[9];let V;e[10]!==i?(V=n.jsx("p",{className:"text-sm font-medium truncate",children:i}),e[10]=i,e[11]=V):V=e[11];let j;e[12]!==r||e[13]!==b?(j=b?n.jsx("span",{className:"text-xs text-destructive font-medium",children:"Needs authorization"}):r&&n.jsx("p",{className:"text-xs text-muted-foreground truncate",children:r}),e[12]=r,e[13]=b,e[14]=j):j=e[14];let I;e[15]!==V||e[16]!==j?(I=n.jsxs("div",{className:"flex-1 min-w-0",children:[V,j]}),e[15]=V,e[16]=j,e[17]=I):I=e[17];let T;e[18]!==s||e[19]!==b||e[20]!==m?(T=b?n.jsx(ae,{variant:"outline",size:"sm",className:"h-7 text-xs shrink-0",onClick:G=>{G.preventDefault(),G.stopPropagation(),m(s)},children:"Authorize"}):n.jsxs(nt,{delayDuration:0,children:[n.jsx(st,{asChild:!0,children:n.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:n.jsx(Zn,{size:16})})}),n.jsx(it,{side:"bottom",children:"Connection settings"})]}),e[18]=s,e[19]=b,e[20]=m,e[21]=T):T=e[21];let R;e[22]!==k||e[23]!==w||e[24]!==I||e[25]!==T?(R=n.jsxs(Ph,{to:"/$org/settings/connections/$appSlug",params:k,className:"flex items-center gap-3 px-4 py-3 cursor-pointer hover:bg-muted/50 transition-colors",children:[w,I,T]}),e[22]=k,e[23]=w,e[24]=I,e[25]=T,e[26]=R):R=e[26];let N;e[27]!==d||e[28]!==s||e[29]!==g||e[30]!==p||e[31]!==u?(N=d&&n.jsx(fV,{appName:d,connectionId:s,usedConnectionIds:u,onSwitchInstance:p,onNewInstance:g}),e[27]=d,e[28]=s,e[29]=g,e[30]=p,e[31]=u,e[32]=N):N=e[32];let A;e[33]===Symbol.for("react.memo_cache_sentinel")?(A=n.jsx(Jh,{size:13}),e[33]=A):A=e[33];let E;e[34]!==h?(E=n.jsx(st,{asChild:!0,children:n.jsx(ae,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:h,"aria-label":"Configure resources",children:A})}),e[34]=h,e[35]=E):E=e[35];let M;e[36]===Symbol.for("react.memo_cache_sentinel")?(M=n.jsx(it,{side:"bottom",children:"Configure resources"}),e[36]=M):M=e[36];let L;e[37]!==E?(L=n.jsxs(nt,{delayDuration:0,children:[E,M]}),e[37]=E,e[38]=L):L=e[38];let D;e[39]===Symbol.for("react.memo_cache_sentinel")?(D=n.jsx(ri,{size:13}),e[39]=D):D=e[39];let P;e[40]!==f?(P=n.jsx(st,{asChild:!0,children:n.jsx(ae,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-destructive",onClick:f,"aria-label":"Remove connection",children:D})}),e[40]=f,e[41]=P):P=e[41];let O;e[42]===Symbol.for("react.memo_cache_sentinel")?(O=n.jsx(it,{side:"bottom",children:"Remove"}),e[42]=O):O=e[42];let z;e[43]!==P?(z=n.jsxs(nt,{delayDuration:0,children:[P,O]}),e[43]=P,e[44]=z):z=e[44];let $;e[45]!==L||e[46]!==z?($=n.jsxs("div",{className:"flex items-center gap-0.5 ml-auto",children:[L,z]}),e[45]=L,e[46]=z,e[47]=$):$=e[47];let q;e[48]!==N||e[49]!==$?(q=n.jsxs("div",{className:"flex items-center gap-3 px-4 py-2 border-t border-border bg-muted/25",children:[N,$]}),e[48]=N,e[49]=$,e[50]=q):q=e[50];let F;return e[51]!==R||e[52]!==q||e[53]!==C?(F=n.jsxs("div",{className:C,children:[R,q]}),e[51]=R,e[52]=q,e[53]=C,e[54]=F):F=e[54],F}function pV(t){const e=B.c(17),{connection_id:s}=t,i=Al(s);if(!i){let h;return e[0]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx(em,{}),e[0]=h):h=e[0],h}let r;e[1]!==i.icon||e[2]!==i.title?(r=n.jsx(Ls,{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 o;e[4]!==i.title?(o=n.jsx("p",{className:"text-sm font-medium truncate",children:i.title}),e[4]=i.title,e[5]=o):o=e[5];let a;e[6]!==i.description?(a=i.description&&n.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]!==o||e[9]!==a?(l=n.jsxs("div",{className:"flex-1 min-w-0",children:[o,a]}),e[8]=o,e[9]=a,e[10]=l):l=e[10];let c;e[11]!==r||e[12]!==l?(c=n.jsxs("div",{className:"flex items-center gap-3 px-4 py-3",children:[r,l]}),e[11]=r,e[12]=l,e[13]=c):c=e[13];let d;e[14]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx("div",{className:"flex items-center px-4 py-2 border-t border-border bg-muted/25",children:n.jsx("div",{className:"h-5 w-20 rounded bg-muted animate-pulse"})}),e[14]=d):d=e[14];let u;return e[15]!==c?(u=n.jsxs("div",{className:"rounded-xl border border-border overflow-hidden",children:[c,d]}),e[15]=c,e[16]=u):u=e[16],u}function em(){const t=B.c(3);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.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=n.jsxs("div",{className:"flex items-center gap-3 px-4 py-3",children:[e,n.jsxs("div",{className:"flex-1 space-y-1.5",children:[n.jsx("div",{className:"h-4 w-32 rounded bg-muted animate-pulse"}),n.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=n.jsxs("div",{className:"rounded-xl border border-border overflow-hidden",children:[s,n.jsx("div",{className:"flex items-center px-4 py-2 border-t border-border bg-muted/25",children:n.jsx("div",{className:"h-5 w-20 rounded bg-muted animate-pulse"})})]}),t[2]=i):i=t[2],i}function gV({virtualMcpId:t}){const{org:e}=xe(),s=Be({connectionId:Pt,orgId:e.id}),i=Mt(),r=is(t),o=(r?.connections??[]).map(P=>P.connection_id).sort(),{data:a}=Ki({queryKey:ct.projectConnectionDetails(t,o),enabled:o.length>0,queryFn:async()=>await Promise.all(o.map(async O=>{try{const z=await s.callTool({name:"COLLECTION_CONNECTIONS_GET",arguments:{id:O}}),{item:$}=To(z),q=($?.tools??[]).filter(F=>!!l_(F._meta)).map(F=>({name:F.name,description:F.description}));return{fetchOk:!0,id:O,title:$?.title??O,icon:$?.icon??null,uiTools:q}}catch{return{fetchOk:!1,id:O,title:O,icon:null,uiTools:[]}}}))}),l=(a??[]).filter(P=>P.uiTools.length>0),c=new Set(ig),d=r?.metadata?.ui,u=d?.pinnedViews??[],h=d?.layout?.defaultMainView??null,f=d?.layout?.chatDefaultOpen??!1,m=!h||h.type==="chat"?"chat":h.type==="settings"?"layout":c.has(h.type)?h.type:`${h.type}:${h.id??""}:${h.toolName??""}`,[p,g]=S.useState(u),[_,v]=S.useState(m),[x,b]=S.useState(f),[y,C]=S.useState(!1),k=P=>{const[O,z,$]=P.split(":");return O?O==="chat"?{type:O}:c.has(O)?{type:O}:O==="ext-apps"&&z?{type:"ext-apps",id:z,toolName:$||void 0}:null:null},w=S.useRef(!1);if(a&&a.length>0&&!w.current){w.current=!0;const P=new Set((a??[]).filter($=>$.fetchOk).map($=>$.id)),O=new Set(l.flatMap($=>$.uiTools.map(q=>`${$.id}:${q.name}`))),z=u.filter($=>!P.has($.connectionId)||O.has(`${$.connectionId}:${$.toolName}`));if(z.length!==u.length){g(z);let $=_;h?.type==="ext-apps"&&!z.some(q=>q.connectionId===h.id&&q.toolName===h.toolName)&&($="chat",v($)),s.callTool({name:"VIRTUAL_MCP_PINNED_VIEWS_UPDATE",arguments:{virtualMcpId:t,pinnedViews:z,layout:{defaultMainView:k($),chatDefaultOpen:x}}}).then(q=>{To(q),i.invalidateQueries({predicate:F=>Array.isArray(F.queryKey)&&F.queryKey.includes("collection")&&F.queryKey.includes("VIRTUAL_MCP")})}).catch(()=>{g(u),v(m)})}}const V=(P,O,z)=>{C(!0),(async()=>{try{const q=await s.callTool({name:"VIRTUAL_MCP_PINNED_VIEWS_UPDATE",arguments:{virtualMcpId:t,pinnedViews:P,layout:{defaultMainView:k(O),chatDefaultOpen:z??x}}});To(q),i.invalidateQueries({predicate:F=>Array.isArray(F.queryKey)&&F.queryKey.includes("collection")&&F.queryKey.includes("VIRTUAL_MCP")}),ue.success("Layout updated")}catch(q){ue.error("Failed to update layout: "+(q instanceof Error?q.message:"Unknown error"))}finally{C(!1)}})()},j=(P,O)=>{const z=p.some(F=>F.connectionId===P&&F.toolName===O);let $,q=_;if(z){$=p.filter(G=>!(G.connectionId===P&&G.toolName===O));const F=`ext-apps:${P}:${O}`;_===F&&(q="chat",v(q))}else $=[...p,{connectionId:P,toolName:O,label:O.replace(/_/g," "),icon:null}];g($),V($,q)},I=(P,O,z)=>{g($=>$.map(q=>q.connectionId===P&&q.toolName===O?{...q,label:z}:q))},T=()=>{V(p,_)},R=(P,O,z)=>{g(q=>q.map(F=>F.connectionId===P&&F.toolName===O?{...F,icon:z}:F));const $=p.map(q=>q.connectionId===P&&q.toolName===O?{...q,icon:z}:q);V($,_)},N=P=>{v(P),V(p,P)},A=o.length===0,E=a&&l.length===0,M=!!Fs(r),L=[{value:"chat",label:"Chat"},{value:"instructions",label:"Instructions"},{value:"connections",label:"Connections"},{value:"layout",label:"Layout"}];M&&(L.push({value:"env",label:"Terminal"}),L.push({value:"preview",label:"Preview"}));for(const P of p)L.push({value:`ext-apps:${P.connectionId}:${P.toolName}`,label:P.label||P.toolName});const D=l.length>0||A||E;return n.jsxs("div",{className:"flex flex-col gap-3",children:[n.jsx("div",{className:"flex items-center justify-between gap-3",children:n.jsx("h2",{className:"text-sm font-medium text-foreground",children:"Layout"})}),n.jsxs(U_,{className:"p-6 gap-5",children:[n.jsxs(Ic,{className:"p-0 space-y-5",children:[n.jsxs("div",{className:"flex items-center justify-between gap-4",children:[n.jsxs("div",{className:"space-y-0.5 min-w-0",children:[n.jsx(Vn,{className:"font-normal text-foreground",children:"Main view"}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"What users see when they first open this agent."})]}),n.jsxs(ei,{value:_,onValueChange:N,children:[n.jsx(ti,{className:"w-44 h-8 text-sm capitalize shrink-0",children:n.jsx(si,{})}),n.jsx(Zs,{children:L.map(P=>n.jsx(Ht,{value:P.value,className:"capitalize",children:P.label},P.value))})]})]}),n.jsxs("div",{className:"flex items-center justify-between gap-4",children:[n.jsxs("div",{className:"space-y-0.5 min-w-0",children:[n.jsx(Vn,{className:"font-normal text-foreground",children:"Show chat"}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Display the chat panel alongside the main view."})]}),n.jsxs(nt,{delayDuration:0,children:[n.jsx(st,{asChild:!0,children:n.jsx("span",{className:"shrink-0",children:n.jsx(Ur,{checked:_==="chat"?!0:x,disabled:_==="chat"||y,onCheckedChange:P=>{b(P),V(p,_,P)}})})}),_==="chat"&&n.jsx(it,{side:"top",children:"Chat is always shown when it is the default view"})]})]})]}),D&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"border-t border-border -mx-6"}),n.jsxs(Ic,{className:"p-0 space-y-3",children:[n.jsx("div",{className:"flex items-center justify-between gap-4",children:n.jsxs("div",{className:"space-y-0.5 min-w-0",children:[n.jsx(Vn,{className:"font-normal text-foreground",children:"Pinned views"}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Surface interactive tools as top-level tabs in the agent."})]})}),A&&n.jsx("p",{className:"text-xs text-muted-foreground",children:"Add a connection above to configure pinned views."}),E&&!A&&n.jsx("p",{className:"text-xs text-muted-foreground",children:"None of the connected servers expose interactive tools."}),l.length>0&&n.jsx("div",{className:"space-y-4 pt-1",children:l.map((P,O)=>n.jsxs("div",{children:[O>0&&n.jsx("div",{className:"border-t border-border -mx-6 mb-4"}),n.jsxs("div",{className:"flex items-center gap-2 mb-2.5",children:[n.jsx(Ls,{icon:P.icon,name:P.title,size:"xs",className:"shrink-0"}),n.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:P.title})]}),n.jsx("div",{className:"space-y-1.5",children:P.uiTools.map(z=>{const $=p.some(F=>F.connectionId===P.id&&F.toolName===z.name),q=p.find(F=>F.connectionId===P.id&&F.toolName===z.name);return n.jsxs("div",{className:J("flex items-center justify-between gap-3 px-3 py-2 rounded-lg border transition-colors",$?"bg-accent/40 border-border":"bg-transparent border-border"),children:[n.jsxs("div",{className:"min-w-0 flex-1 flex items-center gap-2",children:[n.jsx($w,{value:q?.icon??null,onChange:F=>R(P.id,z.name,F),disabled:!$||y}),n.jsx(gt,{value:$&&q?q.label:z.name.replace(/_/g," "),onChange:F=>I(P.id,z.name,F.target.value),onBlur:T,className:"h-7 text-sm w-40 capitalize",disabled:!$||y,readOnly:!$})]}),n.jsx(Ur,{checked:$,onCheckedChange:()=>j(P.id,z.name),disabled:y})]},z.name)})})]},P.id))})]})]})]})]})}function _V({virtualMcp:t,hideOwnTitle:e}){const{org:s}=xe(),i=Nl(),r=mo(),o=Mt(),a=Be({connectionId:Pt,orgId:s.id}),l=Gi({resolver:Un(tV),defaultValues:t}),c=l.watch("connections"),d=!!Fs(t),[u,h]=S.useReducer(dV,{shareDialogOpen:!1,addDialogOpen:!1,settingsDialogOpen:!1,settingsConnectionId:null}),[f,m]=S.useState(!1),{createTaskWithMessage:p}=es(),{setChatMode:g}=ai(),{createNewTask:_}=Wn(),v=()=>{const U=l.getValues("metadata.instructions");U?.trim()&&(I(),ne("agent_instructions_improve_clicked",{agent_id:t.id,instructions_length:U.length}),g("plan"),p({virtualMcpId:xl(s.id),message:{parts:[{type:"text",text:`/writing-prompts ${t.id}
|
|
553
|
+
${c}`;let u;e[0]!==i||e[1]!==s||e[2]!==d?(u=async()=>{ne("agent_connect_action",{agent_id:i,action:"typegen_copy_env",has_api_key:!!s}),await navigator.clipboard.writeText(d),o(!0),setTimeout(()=>o(!1),2e3)},e[0]=i,e[1]=s,e[2]=d,e[3]=u):u=e[3];const h=u,f=!s;let m;e[4]!==f?(m=J({"opacity-50":f}),e[4]=f,e[5]=m):m=e[5];let p;e[6]!==l||e[7]!==m?(p=n.jsx("span",{className:m,children:l}),e[6]=l,e[7]=m,e[8]=p):p=e[8];let g,_;e[9]===Symbol.for("react.memo_cache_sentinel")?(g=n.jsx("br",{}),_=n.jsx("span",{children:c}),e[9]=g,e[10]=_):(g=e[9],_=e[10]);let v;e[11]!==p?(v=n.jsxs("code",{className:"min-w-0 flex-1 font-mono text-xs text-muted-foreground",children:[p,g,_]}),e[11]=p,e[12]=v):v=e[12];let x;e[13]!==r?(x=r?n.jsx(Jt,{size:12,className:"text-green-600"}):n.jsx(zi,{size:12}),e[13]=r,e[14]=x):x=e[14];let b;e[15]!==h||e[16]!==x?(b=n.jsx(ae,{type:"button",variant:"ghost",size:"icon",className:"size-6 shrink-0",onClick:h,children:x}),e[15]=h,e[16]=x,e[17]=b):b=e[17];let y;return e[18]!==v||e[19]!==b?(y=n.jsx("div",{className:"rounded-md border border-input bg-muted/50 px-3 py-2.5",children:n.jsxs("div",{className:"flex items-start gap-2",children:[v,b]})}),e[18]=v,e[19]=b,e[20]=y):y=e[20],y}function lV(t){const e=B.c(3),{virtualMcp:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx("div",{className:"h-20 animate-pulse rounded-md bg-muted"}),e[0]=i):i=e[0];let r;return e[1]!==s?(r=n.jsx(S.Suspense,{fallback:i,children:n.jsx(oV,{virtualMcp:s})}),e[1]=s,e[2]=r):r=e[2],r}function cV(t){const e=B.c(37),{open:s,onOpenChange:i,virtualMcp:r}=t,o=`/mcp/virtual-mcp/${r.id}`;let a;e[0]!==o?(a=new URL(o,window.location.origin),e[0]=o,e[1]=a):a=e[1];const l=a;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 d=c,u=Ps();let h;e[5]!==r.id||e[6]!==l.href?(h=n.jsx(iV,{url:l.href,agentId:r.id}),e[5]=r.id,e[6]=l.href,e[7]=h):h=e[7];let f,m;e[8]!==d||e[9]!==r.id||e[10]!==l.href?(f=n.jsx(nV,{url:l.href,serverName:d,agentId:r.id}),m=n.jsx(rV,{url:l.href,serverName:d,agentId:r.id}),e[8]=d,e[9]=r.id,e[10]=l.href,e[11]=f,e[12]=m):(f=e[11],m=e[12]);let p;e[13]!==h||e[14]!==f||e[15]!==m?(p=n.jsx("div",{className:"flex flex-col gap-3 pt-2",children:n.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[h,f,m]})}),e[13]=h,e[14]=f,e[15]=m,e[16]=p):p=e[16];let g;e[17]===Symbol.for("react.memo_cache_sentinel")?(g=n.jsx("div",{className:"border-t border-border"}),e[17]=g):g=e[17];let _;e[18]!==r?(_=n.jsx(lV,{virtualMcp:r}),e[18]=r,e[19]=_):_=e[19];let v;e[20]!==p||e[21]!==_?(v=n.jsxs("div",{className:"flex flex-col gap-6",children:[p,g,_]}),e[20]=p,e[21]=_,e[22]=v):v=e[22];const x=v;if(u){let k;e[23]===Symbol.for("react.memo_cache_sentinel")?(k=n.jsx(wi,{className:"mt-4 mb-4 text-base font-semibold",children:"Connect"}),e[23]=k):k=e[23];let w;e[24]!==x?(w=n.jsx(Vi,{children:n.jsxs("div",{className:"flex-1 overflow-y-auto px-4 pb-6 [touch-action:pan-y]",children:[k,x]})}),e[24]=x,e[25]=w):w=e[25];let V;return e[26]!==i||e[27]!==s||e[28]!==w?(V=n.jsx(Ci,{open:s,onOpenChange:i,children:w}),e[26]=i,e[27]=s,e[28]=w,e[29]=V):V=e[29],V}let b;e[30]===Symbol.for("react.memo_cache_sentinel")?(b=n.jsx(hs,{children:n.jsx(ds,{children:"Connect"})}),e[30]=b):b=e[30];let y;e[31]!==x?(y=n.jsxs(ts,{className:"max-h-[80vh] overflow-y-auto sm:max-w-2xl",children:[b,x]}),e[31]=x,e[32]=y):y=e[32];let C;return e[33]!==i||e[34]!==s||e[35]!==y?(C=n.jsx(ss,{open:s,onOpenChange:i,children:y}),e[33]=i,e[34]=s,e[35]=y,e[36]=C):C=e[36],C}function dV(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 hV(t){const e=B.c(22),{connection_id:s,usedConnectionIds:i,onOpenSettings:r,onRemove:o,onAuthenticate:a,onSwitchInstance:l,onNewInstance:c}=t,d=Al(s),{org:u}=xe();if(!d)return null;let h;e[0]!==d?(h=gu(d),e[0]=d,e[1]=h):h=e[1];const f=h;let m;e[2]!==s?(m=n.jsx(pV,{connection_id:s}),e[2]=s,e[3]=m):m=e[3];let p;e[4]!==d.app_name||e[5]!==d.connection_type||e[6]!==d.description||e[7]!==d.icon||e[8]!==d.title||e[9]!==s||e[10]!==a||e[11]!==c||e[12]!==r||e[13]!==o||e[14]!==l||e[15]!==u.slug||e[16]!==f||e[17]!==i?(p=n.jsx(mV,{connection_id:s,connectionTitle:d.title,connectionDescription:d.description,connectionIcon:d.icon,connectionType:d.connection_type,slug:f,orgSlug:u.slug,appName:d.app_name,usedConnectionIds:i,onOpenSettings:r,onRemove:o,onAuthenticate:a,onSwitchInstance:l,onNewInstance:c}),e[4]=d.app_name,e[5]=d.connection_type,e[6]=d.description,e[7]=d.icon,e[8]=d.title,e[9]=s,e[10]=a,e[11]=c,e[12]=r,e[13]=o,e[14]=l,e[15]=u.slug,e[16]=f,e[17]=i,e[18]=p):p=e[18];let g;return e[19]!==m||e[20]!==p?(g=n.jsx(S.Suspense,{fallback:m,children:p}),e[19]=m,e[20]=p,e[21]=g):g=e[21],g}const Vd="__new_instance__";async function uV(t,e){const s=t?.idToken??null;if(s){const r=Cd(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 o=await r.json(),a=typeof o.email=="string"?o.email:typeof o.upn=="string"?o.upn:typeof o.preferred_username=="string"?o.preferred_username:null;if(a)return a}}catch{}return Cd(e)}function Cd(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 fV(t){const e=B.c(23),{appName:s,connectionId:i,usedConnectionIds:r,onSwitchInstance:o,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 c=Gn(l);if(c.length<=1)return null;let d;e[2]!==i||e[3]!==a||e[4]!==o?(d=g=>{g===Vd?a?.():o(i,g)},e[2]=i,e[3]=a,e[4]=o,e[5]=d):d=e[5];let u;e[6]===Symbol.for("react.memo_cache_sentinel")?(u=n.jsx(ti,{size:"sm",className:"w-auto text-xs gap-1 px-2 shadow-none",children:n.jsx(si,{})}),e[6]=u):u=e[6];let h;if(e[7]!==i||e[8]!==c||e[9]!==r){let g;e[11]!==i||e[12]!==r?(g=_=>n.jsx(Ht,{value:_.id,className:"text-xs",disabled:_.id!==i&&r.has(_.id),children:_.title},_.id),e[11]=i,e[12]=r,e[13]=g):g=e[13],h=c.map(g),e[7]=i,e[8]=c,e[9]=r,e[10]=h}else h=e[10];let f;e[14]!==a?(f=a&&n.jsx(Ht,{value:Vd,className:"text-xs text-muted-foreground",children:"+ New instance"}),e[14]=a,e[15]=f):f=e[15];let m;e[16]!==h||e[17]!==f?(m=n.jsxs(Zs,{children:[h,f]}),e[16]=h,e[17]=f,e[18]=m):m=e[18];let p;return e[19]!==i||e[20]!==d||e[21]!==m?(p=n.jsxs(ei,{value:i,onValueChange:d,children:[u,m]}),e[19]=i,e[20]=d,e[21]=m,e[22]=p):p=e[22],p}function mV(t){const e=B.c(55),{connection_id:s,connectionTitle:i,connectionDescription:r,connectionIcon:o,connectionType:a,slug:l,orgSlug:c,appName:d,usedConnectionIds:u,onOpenSettings:h,onRemove:f,onAuthenticate:m,onSwitchInstance:p,onNewInstance:g}=t;let _;e[0]!==s?(_={connectionId:s},e[0]=s,e[1]=_):_=e[1];const v=Du(_),b=!(a==="VIRTUAL")&&v.supportsOAuth&&!v.isAuthenticated,y=b?"border-destructive/50 bg-destructive/5":"border-border";let C;e[2]!==y?(C=J("rounded-xl border overflow-hidden transition-colors",y),e[2]=y,e[3]=C):C=e[3];let k;e[4]!==c||e[5]!==l?(k={org:c,appSlug:l},e[4]=c,e[5]=l,e[6]=k):k=e[6];let w;e[7]!==o||e[8]!==i?(w=n.jsx(Ls,{icon:o,name:i,size:"sm",className:"shrink-0"}),e[7]=o,e[8]=i,e[9]=w):w=e[9];let V;e[10]!==i?(V=n.jsx("p",{className:"text-sm font-medium truncate",children:i}),e[10]=i,e[11]=V):V=e[11];let j;e[12]!==r||e[13]!==b?(j=b?n.jsx("span",{className:"text-xs text-destructive font-medium",children:"Needs authorization"}):r&&n.jsx("p",{className:"text-xs text-muted-foreground truncate",children:r}),e[12]=r,e[13]=b,e[14]=j):j=e[14];let I;e[15]!==V||e[16]!==j?(I=n.jsxs("div",{className:"flex-1 min-w-0",children:[V,j]}),e[15]=V,e[16]=j,e[17]=I):I=e[17];let T;e[18]!==s||e[19]!==b||e[20]!==m?(T=b?n.jsx(ae,{variant:"outline",size:"sm",className:"h-7 text-xs shrink-0",onClick:G=>{G.preventDefault(),G.stopPropagation(),m(s)},children:"Authorize"}):n.jsxs(nt,{delayDuration:0,children:[n.jsx(st,{asChild:!0,children:n.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:n.jsx(Zn,{size:16})})}),n.jsx(it,{side:"bottom",children:"Connection settings"})]}),e[18]=s,e[19]=b,e[20]=m,e[21]=T):T=e[21];let R;e[22]!==k||e[23]!==w||e[24]!==I||e[25]!==T?(R=n.jsxs(Ph,{to:"/$org/settings/connections/$appSlug",params:k,className:"flex items-center gap-3 px-4 py-3 cursor-pointer hover:bg-muted/50 transition-colors",children:[w,I,T]}),e[22]=k,e[23]=w,e[24]=I,e[25]=T,e[26]=R):R=e[26];let N;e[27]!==d||e[28]!==s||e[29]!==g||e[30]!==p||e[31]!==u?(N=d&&n.jsx(fV,{appName:d,connectionId:s,usedConnectionIds:u,onSwitchInstance:p,onNewInstance:g}),e[27]=d,e[28]=s,e[29]=g,e[30]=p,e[31]=u,e[32]=N):N=e[32];let A;e[33]===Symbol.for("react.memo_cache_sentinel")?(A=n.jsx(Jh,{size:13}),e[33]=A):A=e[33];let E;e[34]!==h?(E=n.jsx(st,{asChild:!0,children:n.jsx(ae,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:h,"aria-label":"Configure resources",children:A})}),e[34]=h,e[35]=E):E=e[35];let M;e[36]===Symbol.for("react.memo_cache_sentinel")?(M=n.jsx(it,{side:"bottom",children:"Configure resources"}),e[36]=M):M=e[36];let L;e[37]!==E?(L=n.jsxs(nt,{delayDuration:0,children:[E,M]}),e[37]=E,e[38]=L):L=e[38];let D;e[39]===Symbol.for("react.memo_cache_sentinel")?(D=n.jsx(ri,{size:13}),e[39]=D):D=e[39];let P;e[40]!==f?(P=n.jsx(st,{asChild:!0,children:n.jsx(ae,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-destructive",onClick:f,"aria-label":"Remove connection",children:D})}),e[40]=f,e[41]=P):P=e[41];let O;e[42]===Symbol.for("react.memo_cache_sentinel")?(O=n.jsx(it,{side:"bottom",children:"Remove"}),e[42]=O):O=e[42];let z;e[43]!==P?(z=n.jsxs(nt,{delayDuration:0,children:[P,O]}),e[43]=P,e[44]=z):z=e[44];let $;e[45]!==L||e[46]!==z?($=n.jsxs("div",{className:"flex items-center gap-0.5 ml-auto",children:[L,z]}),e[45]=L,e[46]=z,e[47]=$):$=e[47];let q;e[48]!==N||e[49]!==$?(q=n.jsxs("div",{className:"flex items-center gap-3 px-4 py-2 border-t border-border bg-muted/25",children:[N,$]}),e[48]=N,e[49]=$,e[50]=q):q=e[50];let F;return e[51]!==R||e[52]!==q||e[53]!==C?(F=n.jsxs("div",{className:C,children:[R,q]}),e[51]=R,e[52]=q,e[53]=C,e[54]=F):F=e[54],F}function pV(t){const e=B.c(17),{connection_id:s}=t,i=Al(s);if(!i){let h;return e[0]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx(em,{}),e[0]=h):h=e[0],h}let r;e[1]!==i.icon||e[2]!==i.title?(r=n.jsx(Ls,{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 o;e[4]!==i.title?(o=n.jsx("p",{className:"text-sm font-medium truncate",children:i.title}),e[4]=i.title,e[5]=o):o=e[5];let a;e[6]!==i.description?(a=i.description&&n.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]!==o||e[9]!==a?(l=n.jsxs("div",{className:"flex-1 min-w-0",children:[o,a]}),e[8]=o,e[9]=a,e[10]=l):l=e[10];let c;e[11]!==r||e[12]!==l?(c=n.jsxs("div",{className:"flex items-center gap-3 px-4 py-3",children:[r,l]}),e[11]=r,e[12]=l,e[13]=c):c=e[13];let d;e[14]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx("div",{className:"flex items-center px-4 py-2 border-t border-border bg-muted/25",children:n.jsx("div",{className:"h-5 w-20 rounded bg-muted animate-pulse"})}),e[14]=d):d=e[14];let u;return e[15]!==c?(u=n.jsxs("div",{className:"rounded-xl border border-border overflow-hidden",children:[c,d]}),e[15]=c,e[16]=u):u=e[16],u}function em(){const t=B.c(3);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.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=n.jsxs("div",{className:"flex items-center gap-3 px-4 py-3",children:[e,n.jsxs("div",{className:"flex-1 space-y-1.5",children:[n.jsx("div",{className:"h-4 w-32 rounded bg-muted animate-pulse"}),n.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=n.jsxs("div",{className:"rounded-xl border border-border overflow-hidden",children:[s,n.jsx("div",{className:"flex items-center px-4 py-2 border-t border-border bg-muted/25",children:n.jsx("div",{className:"h-5 w-20 rounded bg-muted animate-pulse"})})]}),t[2]=i):i=t[2],i}function gV({virtualMcpId:t}){const{org:e}=xe(),s=Be({connectionId:Pt,orgId:e.id}),i=Mt(),r=is(t),o=(r?.connections??[]).map(P=>P.connection_id).sort(),{data:a}=Ki({queryKey:ct.projectConnectionDetails(t,o),enabled:o.length>0,queryFn:async()=>await Promise.all(o.map(async O=>{try{const z=await s.callTool({name:"COLLECTION_CONNECTIONS_GET",arguments:{id:O}}),{item:$}=To(z),q=($?.tools??[]).filter(F=>!!l_(F._meta)).map(F=>({name:F.name,description:F.description}));return{fetchOk:!0,id:O,title:$?.title??O,icon:$?.icon??null,uiTools:q}}catch{return{fetchOk:!1,id:O,title:O,icon:null,uiTools:[]}}}))}),l=(a??[]).filter(P=>P.uiTools.length>0),c=new Set(ig),d=r?.metadata?.ui,u=d?.pinnedViews??[],h=d?.layout?.defaultMainView??null,f=d?.layout?.chatDefaultOpen??!1,m=!h||h.type==="chat"?"chat":h.type==="instructions"||h.type==="connections"||h.type==="layout"?"settings":c.has(h.type)?h.type:`${h.type}:${h.id??""}:${h.toolName??""}`,[p,g]=S.useState(u),[_,v]=S.useState(m),[x,b]=S.useState(f),[y,C]=S.useState(!1),k=P=>{const[O,z,$]=P.split(":");return O?O==="chat"?{type:O}:c.has(O)?{type:O}:O==="ext-apps"&&z?{type:"ext-apps",id:z,toolName:$||void 0}:null:null},w=S.useRef(!1);if(a&&a.length>0&&!w.current){w.current=!0;const P=new Set((a??[]).filter($=>$.fetchOk).map($=>$.id)),O=new Set(l.flatMap($=>$.uiTools.map(q=>`${$.id}:${q.name}`))),z=u.filter($=>!P.has($.connectionId)||O.has(`${$.connectionId}:${$.toolName}`));if(z.length!==u.length){g(z);let $=_;h?.type==="ext-apps"&&!z.some(q=>q.connectionId===h.id&&q.toolName===h.toolName)&&($="chat",v($)),s.callTool({name:"VIRTUAL_MCP_PINNED_VIEWS_UPDATE",arguments:{virtualMcpId:t,pinnedViews:z,layout:{defaultMainView:k($),chatDefaultOpen:x}}}).then(q=>{To(q),i.invalidateQueries({predicate:F=>Array.isArray(F.queryKey)&&F.queryKey.includes("collection")&&F.queryKey.includes("VIRTUAL_MCP")})}).catch(()=>{g(u),v(m)})}}const V=(P,O,z)=>{C(!0),(async()=>{try{const q=await s.callTool({name:"VIRTUAL_MCP_PINNED_VIEWS_UPDATE",arguments:{virtualMcpId:t,pinnedViews:P,layout:{defaultMainView:k(O),chatDefaultOpen:z??x}}});To(q),i.invalidateQueries({predicate:F=>Array.isArray(F.queryKey)&&F.queryKey.includes("collection")&&F.queryKey.includes("VIRTUAL_MCP")}),ue.success("Layout updated")}catch(q){ue.error("Failed to update layout: "+(q instanceof Error?q.message:"Unknown error"))}finally{C(!1)}})()},j=(P,O)=>{const z=p.some(F=>F.connectionId===P&&F.toolName===O);let $,q=_;if(z){$=p.filter(G=>!(G.connectionId===P&&G.toolName===O));const F=`ext-apps:${P}:${O}`;_===F&&(q="chat",v(q))}else $=[...p,{connectionId:P,toolName:O,label:O.replace(/_/g," "),icon:null}];g($),V($,q)},I=(P,O,z)=>{g($=>$.map(q=>q.connectionId===P&&q.toolName===O?{...q,label:z}:q))},T=()=>{V(p,_)},R=(P,O,z)=>{g(q=>q.map(F=>F.connectionId===P&&F.toolName===O?{...F,icon:z}:F));const $=p.map(q=>q.connectionId===P&&q.toolName===O?{...q,icon:z}:q);V($,_)},N=P=>{v(P),V(p,P)},A=o.length===0,E=a&&l.length===0,M=!!Fs(r),L=[{value:"chat",label:"Chat"},{value:"settings",label:"Settings"},{value:"automations",label:"Automations"}];M&&(L.push({value:"env",label:"Terminal"}),L.push({value:"preview",label:"Preview"}));for(const P of p)L.push({value:`ext-apps:${P.connectionId}:${P.toolName}`,label:P.label||P.toolName});const D=l.length>0||A||E;return n.jsxs("div",{className:"flex flex-col gap-3",children:[n.jsx("div",{className:"flex items-center justify-between gap-3",children:n.jsx("h2",{className:"text-sm font-medium text-foreground",children:"Layout"})}),n.jsxs(U_,{className:"p-6 gap-5",children:[n.jsxs(Ic,{className:"p-0 space-y-5",children:[n.jsxs("div",{className:"flex items-center justify-between gap-4",children:[n.jsxs("div",{className:"space-y-0.5 min-w-0",children:[n.jsx(Vn,{className:"font-normal text-foreground",children:"Main view"}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"What users see when they first open this agent."})]}),n.jsxs(ei,{value:_,onValueChange:N,children:[n.jsx(ti,{className:"w-44 h-8 text-sm capitalize shrink-0",children:n.jsx(si,{})}),n.jsx(Zs,{children:L.map(P=>n.jsx(Ht,{value:P.value,className:"capitalize",children:P.label},P.value))})]})]}),n.jsxs("div",{className:"flex items-center justify-between gap-4",children:[n.jsxs("div",{className:"space-y-0.5 min-w-0",children:[n.jsx(Vn,{className:"font-normal text-foreground",children:"Show chat"}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Display the chat panel alongside the main view."})]}),n.jsxs(nt,{delayDuration:0,children:[n.jsx(st,{asChild:!0,children:n.jsx("span",{className:"shrink-0",children:n.jsx(Ur,{checked:_==="chat"?!0:x,disabled:_==="chat"||y,onCheckedChange:P=>{b(P),V(p,_,P)}})})}),_==="chat"&&n.jsx(it,{side:"top",children:"Chat is always shown when it is the default view"})]})]})]}),D&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"border-t border-border -mx-6"}),n.jsxs(Ic,{className:"p-0 space-y-3",children:[n.jsx("div",{className:"flex items-center justify-between gap-4",children:n.jsxs("div",{className:"space-y-0.5 min-w-0",children:[n.jsx(Vn,{className:"font-normal text-foreground",children:"Pinned views"}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Surface interactive tools as top-level tabs in the agent."})]})}),A&&n.jsx("p",{className:"text-xs text-muted-foreground",children:"Add a connection above to configure pinned views."}),E&&!A&&n.jsx("p",{className:"text-xs text-muted-foreground",children:"None of the connected servers expose interactive tools."}),l.length>0&&n.jsx("div",{className:"space-y-4 pt-1",children:l.map((P,O)=>n.jsxs("div",{children:[O>0&&n.jsx("div",{className:"border-t border-border -mx-6 mb-4"}),n.jsxs("div",{className:"flex items-center gap-2 mb-2.5",children:[n.jsx(Ls,{icon:P.icon,name:P.title,size:"xs",className:"shrink-0"}),n.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:P.title})]}),n.jsx("div",{className:"space-y-1.5",children:P.uiTools.map(z=>{const $=p.some(F=>F.connectionId===P.id&&F.toolName===z.name),q=p.find(F=>F.connectionId===P.id&&F.toolName===z.name);return n.jsxs("div",{className:J("flex items-center justify-between gap-3 px-3 py-2 rounded-lg border transition-colors",$?"bg-accent/40 border-border":"bg-transparent border-border"),children:[n.jsxs("div",{className:"min-w-0 flex-1 flex items-center gap-2",children:[n.jsx($w,{value:q?.icon??null,onChange:F=>R(P.id,z.name,F),disabled:!$||y}),n.jsx(gt,{value:$&&q?q.label:z.name.replace(/_/g," "),onChange:F=>I(P.id,z.name,F.target.value),onBlur:T,className:"h-7 text-sm w-40 capitalize",disabled:!$||y,readOnly:!$})]}),n.jsx(Ur,{checked:$,onCheckedChange:()=>j(P.id,z.name),disabled:y})]},z.name)})})]},P.id))})]})]})]})]})}function _V({virtualMcp:t,hideOwnTitle:e}){const{org:s}=xe(),i=Nl(),r=mo(),o=Mt(),a=Be({connectionId:Pt,orgId:s.id}),l=Gi({resolver:Un(tV),defaultValues:t}),c=l.watch("connections"),d=!!Fs(t),[u,h]=S.useReducer(dV,{shareDialogOpen:!1,addDialogOpen:!1,settingsDialogOpen:!1,settingsConnectionId:null}),[f,m]=S.useState(!1),{createTaskWithMessage:p}=es(),{setChatMode:g}=ai(),{createNewTask:_}=Wn(),v=()=>{const U=l.getValues("metadata.instructions");U?.trim()&&(I(),ne("agent_instructions_improve_clicked",{agent_id:t.id,instructions_length:U.length}),g("plan"),p({virtualMcpId:xl(s.id),message:{parts:[{type:"text",text:`/writing-prompts ${t.id}
|
|
554
554
|
|
|
555
555
|
<instructions>
|
|
556
556
|
${U}
|
|
@@ -736,4 +736,4 @@ ${te}
|
|
|
736
736
|
|
|
737
737
|
<message>
|
|
738
738
|
${se}
|
|
739
|
-
</message>`}]}}))},L=e.models?.credentialId||m||"",D=e.models?.thinking?.id||p?.modelId||"",P=Gi({defaultValues:{name:e.name,active:e.active,credential_id:L,model_id:D}}),O=P.watch("active"),z=P.watch("credential_id"),$=P.watch("model_id"),{models:q,isLoading:F}=hu(z||void 0),G=q.find(le=>le.modelId===$)??null,H=S.useRef(null),U=S.useRef(new Set),Y=S.useRef(0),W=S.useRef(null),K=3e4,ee=()=>{W.current&&(clearTimeout(W.current),W.current=null),H.current!==null&&(ne("automation_updated",{automation_id:t,agent_id:o,fields:Array.from(U.current),save_count:Y.current,edit_duration_ms:Date.now()-H.current}),H.current=null,U.current=new Set,Y.current=0)},Z=async()=>{if(!(Object.keys(P.formState.dirtyFields).length>0)&&!E.current)return!0;const se=Object.keys(P.formState.dirtyFields),_e=E.current;E.current=!1;const ge=P.getValues();try{const Se=ge.credential_id&&ge.model_id?ge.credential_id:"",ve=ge.credential_id&&ge.model_id?ge.model_id:"",Ne={id:t,name:ge.name,active:ge.active,agent:{id:o},models:{credentialId:Se,thinking:{id:ve}},messages:Oh(b),temperature:0};await l.mutateAsync(Ne),H.current===null&&(H.current=Date.now());for(const Te of se)U.current.add(Te);return _e&&U.current.add("messages"),Y.current+=1,W.current&&clearTimeout(W.current),W.current=setTimeout(ee,K),P.reset({...ge,credential_id:Se,model_id:ve}),!0}catch{return E.current=!0,!1}},X=()=>{A.current&&clearTimeout(A.current),A.current=setTimeout(()=>{Z()},1e3)},ie=async()=>(A.current&&clearTimeout(A.current),Z()),re=le=>{if(y(le),!N.current){N.current=!0;return}E.current=!0,X()},de=S.useRef(!1);de.current||(de.current=!0,P.watch(()=>{X()}));const me=async()=>{ne("automation_test_clicked",{automation_id:t,agent_id:o});const le=await ie();if(ee(),!le)return;if(!b){ue.error("No instructions configured for this automation");return}G&&z&&f({...G,keyId:z}),v({..._,toolApprovalLevel:"auto"});const se=pc(b);h({message:{tiptapDoc:b,parts:se},virtualMcpId:o||void 0})};return n.jsxs(n.Fragment,{children:[i&&n.jsx("div",{className:"flex items-center pb-4 shrink-0",children:n.jsxs(ae,{variant:"ghost",size:"sm",onClick:i,children:[n.jsx(Cl,{size:14}),"Back to list"]})}),n.jsxs("div",{className:"flex flex-col gap-8",children:[n.jsxs("div",{className:"flex flex-col gap-1.5",children:[n.jsxs("div",{className:"flex items-center justify-between gap-4",children:[n.jsx(gt,{...P.register("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"}}),r&&n.jsx(ae,{variant:"ghost",size:"icon",className:"text-muted-foreground hover:text-destructive shrink-0",onClick:r,children:n.jsx(_a,{size:14})})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Ti,{control:P.control,name:"active",render:({field:le})=>n.jsx(Ur,{checked:le.value,onCheckedChange:se=>{le.onChange(se),setTimeout(()=>ie(),0)},className:"cursor-pointer"})}),n.jsx("span",{className:"text-sm text-muted-foreground",children:O?"Active":"Inactive"}),n.jsx("span",{className:"text-muted-foreground/50 text-sm",children:"·"}),n.jsx(K_,{id:e.created_by,size:"2xs",className:"text-sm text-muted-foreground"})]})]}),n.jsxs("div",{className:"flex flex-col gap-2.5",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Starter"}),n.jsx(Jj,{automationId:t,open:C,onOpenChange:k,onCustomSelect:()=>{V(!0),R(!1),I("")},onEventSelect:()=>{R(!0),V(!1)}})]}),e.triggers.length===0&&!w?n.jsx("div",{className:"rounded-lg border border-dashed border-border px-4 py-6 text-center",children:n.jsxs("p",{className:"text-sm text-muted-foreground",children:["When should this automation run?"," ",n.jsx("button",{type:"button",className:"text-foreground underline underline-offset-2 cursor-pointer hover:text-foreground/80 transition-colors",onClick:()=>k(!0),children:"Add a starter"})," ","to get going."]})}):n.jsx("div",{className:"flex flex-col gap-2",children:e.triggers.map(le=>n.jsx(Qj,{trigger:le,automationId:t,connectionName:le.connection_id?u.get(le.connection_id):void 0},le.id))}),w&&n.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2.5 rounded-lg border border-border bg-background group",children:[n.jsx(Sn,{size:14,className:"text-muted-foreground shrink-0"}),n.jsx("input",{type:"text",value:j,onChange:le=>I(le.target.value),onBlur:async()=>{const le=j.trim();if(!(!le||!An(le)))try{await c.mutateAsync({automation_id:t,type:"cron",cron_expression:le}),ne("automation_trigger_added",{automation_id:t,trigger_type:"cron"}),ue.success("Starter added"),V(!1),I("")}catch{ue.error("Failed to add starter")}},onKeyDown:async le=>{const se=j.trim();le.key==="Enter"&&se&&An(se)&&le.target.blur(),le.key==="Escape"&&(V(!1),I(""))},placeholder:"0 9 * * 1-5",className:"flex-1 text-sm font-mono bg-transparent outline-none placeholder:text-muted-foreground/40",autoFocus:!0}),j&&!An(j)&&n.jsx("span",{className:"text-xs text-muted-foreground/60 shrink-0",children:"invalid"}),c.isPending&&n.jsx(Me,{size:13,className:"animate-spin text-muted-foreground shrink-0"}),n.jsx("button",{type:"button",className:"shrink-0 p-0.5 rounded text-muted-foreground opacity-0 group-hover:opacity-100 hover:text-foreground transition-opacity",onClick:()=>{V(!1),I("")},children:n.jsx(ri,{size:13})})]}),T&&n.jsx(S.Suspense,{fallback:n.jsxs("div",{className:"flex items-center gap-2 px-3 py-3 rounded-lg border border-border bg-background",children:[n.jsx(Me,{size:13,className:"animate-spin text-muted-foreground"}),n.jsx("span",{className:"text-sm text-muted-foreground",children:"Loading connections..."})]}),children:n.jsx(e5,{automationId:t,onDone:()=>R(!1)})})]}),n.jsxs("div",{className:"flex flex-col gap-2.5",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Instructions"}),n.jsxs(ae,{variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",disabled:!b,onClick:M,children:[n.jsx(Vl,{size:13}),"Improve"]})]}),n.jsx(tf,{tiptapDoc:b,setTiptapDoc:re,placeholder:"What should this automation do?",children:n.jsxs("div",{className:"rounded-xl border border-border min-h-[120px] flex flex-col",children:[n.jsx(sf,{virtualMcpId:o||null,className:"max-h-[45vh]"}),n.jsxs("div",{className:"flex items-center justify-end gap-1.5 p-2.5",children:[n.jsx(fu,{model:G,isLoading:F,credentialId:z||null,onCredentialChange:le=>{P.setValue("credential_id",le??"",{shouldDirty:!0}),P.setValue("model_id","",{shouldDirty:!0})},onModelChange:le=>P.setValue("model_id",le.modelId,{shouldDirty:!0}),placeholder:"Model"}),n.jsxs(nt,{children:[n.jsx(st,{asChild:!0,children:n.jsxs(ae,{type:"button",variant:"default",className:"h-8 gap-1.5 rounded-md px-3 text-sm font-medium",onClick:me,disabled:!o,children:[n.jsx(Qh,{size:16}),"Test"]})}),n.jsx(it,{children:"Test Automation"})]})]})]})})]})]})]})}function r5(t){const e=B.c(6),{tabId:s,virtualMcpId:i}=t;let r;e[0]!==s?(r=$h(s),e[0]=s,e[1]=r):r=e[1];const o=r;if(!o)return null;let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx("div",{className:"flex-1 flex items-center justify-center",children:n.jsx(Me,{size:20,className:"animate-spin text-muted-foreground"})}),e[2]=a):a=e[2];let l;return e[3]!==o.id||e[4]!==i?(l=n.jsx(ps,{children:n.jsx(ps.Content,{children:n.jsx(ps.Body,{children:n.jsx(S.Suspense,{fallback:a,children:n.jsx(o5,{id:o.id,virtualMcpId:i})})})})}),e[3]=o.id,e[4]=i,e[5]=l):l=e[5],l}function o5(t){const e=B.c(9),{id:s,virtualMcpId:i}=t,r=Ge(),{data:o,isLoading:a}=G_(s);let l;e[0]!==r?(l=()=>r({to:".",search:a5,replace:!0}),e[0]=r,e[1]=l):l=e[1];const c=l;if(a){let u;return e[2]===Symbol.for("react.memo_cache_sentinel")?(u=n.jsx("div",{className:"flex-1 flex items-center justify-center",children:n.jsx(Me,{size:20,className:"animate-spin text-muted-foreground"})}),e[2]=u):u=e[2],u}if(!o){let u;return e[3]===Symbol.for("react.memo_cache_sentinel")?(u=n.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:"Automation not found"}),e[3]=u):u=e[3],u}let d;return e[4]!==o||e[5]!==s||e[6]!==c||e[7]!==i?(d=n.jsx(n5,{automationId:s,automation:o,virtualMcpId:i,onBack:c}),e[4]=o,e[5]=s,e[6]=c,e[7]=i,e[8]=d):d=e[8],d}function a5(t){return{...t,main:"automations"}}function l5(t){const e=B.c(19),{virtualMcpId:s}=t,i=Ge(),{data:r}=Y_(s),o=r===void 0?[]:r,{create:a}=er(),[l,c]=S.useState(""),d=l.toLowerCase(),u=o.filter(j=>j.name.toLowerCase().includes(d));let h;e[0]!==i?(h=j=>i({to:".",search:I=>({...I,main:"automation:"+j}),replace:!0}),e[0]=i,e[1]=h):h=e[1];const f=h,m=async()=>{if(a.isPending)return;ne("automation_new_clicked",{virtual_mcp_id:s,existing_count:o.length});const j=await a.mutateAsync(J_(s));f(j.id)},p=ps,g=ps,_=ps;let v;e[2]===Symbol.for("react.memo_cache_sentinel")?(v=n.jsx(Qt,{size:14}),e[2]=v):v=e[2];let x;e[3]!==a.isPending||e[4]!==m?(x=n.jsx(ps.Title,{actions:n.jsxs(ae,{size:"sm",onClick:m,disabled:a.isPending,children:[v,"New automation"]}),children:"Automations"}),e[3]=a.isPending,e[4]=m,e[5]=x):x=e[5];const b=o.length>0&&n.jsx(Q_,{value:l,onChange:c,placeholder:"Search automations...",className:"w-full md:w-[375px]"});let y;e[6]!==x||e[7]!==b?(y=n.jsxs("div",{className:"flex flex-col gap-6",children:[x,b]}),e[6]=x,e[7]=b,e[8]=y):y=e[8];const C=o.length===0?n.jsx("div",{className:"flex items-center justify-center py-20",children:n.jsx(Ui,{image:n.jsx(Hi,{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:n.jsxs(ae,{size:"sm",onClick:m,disabled:a.isPending,children:[n.jsx(Qt,{size:14}),"New automation"]})})}):u.length===0?n.jsx("div",{className:"flex items-center justify-center py-20",children:n.jsx(Ui,{image:n.jsx(Hi,{size:48,className:"text-muted-foreground"}),title:"No automations found",description:`No automations match "${l}"`})}):n.jsx("div",{className:"mt-6 rounded-xl border border-border overflow-hidden",children:u.map(j=>n.jsx(X_,{automation:j,onClick:()=>f(j.id)},j.id))});let k;e[9]!==_.Body||e[10]!==y||e[11]!==C?(k=n.jsxs(_.Body,{children:[y,C]}),e[9]=_.Body,e[10]=y,e[11]=C,e[12]=k):k=e[12];let w;e[13]!==k||e[14]!==g.Content?(w=n.jsx(g.Content,{children:k}),e[13]=k,e[14]=g.Content,e[15]=w):w=e[15];let V;return e[16]!==p||e[17]!==w?(V=n.jsx(p,{children:w}),e[16]=p,e[17]=w,e[18]=V):V=e[18],V}function c5(t){const e=B.c(3),{virtualMcpId:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx("div",{className:"flex-1 flex items-center justify-center",children:n.jsx(Me,{size:20,className:"animate-spin text-muted-foreground"})}),e[0]=i):i=e[0];let r;return e[1]!==s?(r=n.jsx(S.Suspense,{fallback:i,children:n.jsx(l5,{virtualMcpId:s})}),e[1]=s,e[2]=r):r=e[2],r}const wh=S.lazy(()=>Op(()=>import("./project-app-view-BgI1ObN0.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])).then(t=>({default:t.AppViewContent})));function d5(t){const e=B.c(35),{taskId:s,virtualMcpId:i}=t;let r;e[0]!==s||e[1]!==i?(r={virtualMcpId:i,taskId:s},e[0]=s,e[1]=i,e[2]=r):r=e[2];const{activeTab:o,layoutTabs:a,automationTabParsed:l}=Zf(r);if(og(o)){let m;return e[3]!==i?(m=n.jsx(kd,{virtualMcpId:i}),e[3]=i,e[4]=m):m=e[4],m}if(o==="git"){let m;return e[5]!==i?(m=n.jsx(XV,{virtualMcpId:i}),e[5]=i,e[6]=m):m=e[6],m}if(o==="automations"){let m;return e[7]!==i?(m=n.jsx(c5,{virtualMcpId:i}),e[7]=i,e[8]=m):m=e[8],m}if(o==="env"){let m;return e[9]!==i?(m=n.jsx(Wj,{virtualMcpId:i}),e[9]=i,e[10]=m):m=e[10],m}if(o==="preview"){let m;return e[11]!==i?(m=n.jsx(jC,{virtualMcpId:i}),e[11]=i,e[12]=m):m=e[12],m}if(l){let m;return e[13]!==o||e[14]!==i?(m=n.jsx(r5,{tabId:o,virtualMcpId:i}),e[13]=o,e[14]=i,e[15]=m):m=e[15],m}let c;e[16]!==o?(c=ag(o),e[16]=o,e[17]=c):c=e[17];const d=c;if(d){let m;e[18]===Symbol.for("react.memo_cache_sentinel")?(m=n.jsx("div",{className:"h-full w-full flex items-center justify-center",children:n.jsx(Me,{size:20,className:"animate-spin text-muted-foreground"})}),e[18]=m):m=e[18];let p;return e[19]!==o||e[20]!==d.connectionId||e[21]!==d.toolName?(p=n.jsx(S.Suspense,{fallback:m,children:n.jsx(wh,{connectionId:d.connectionId,toolName:d.toolName},o)}),e[19]=o,e[20]=d.connectionId,e[21]=d.toolName,e[22]=p):p=e[22],p}let u;if(e[23]!==o||e[24]!==a){let m;e[26]!==o?(m=p=>p.id===o,e[26]=o,e[27]=m):m=e[27],u=a.find(m),e[23]=o,e[24]=a,e[25]=u}else u=e[25];const h=u;if(h){let m;e[28]===Symbol.for("react.memo_cache_sentinel")?(m=n.jsx("div",{className:"h-full w-full flex items-center justify-center",children:n.jsx(Me,{size:20,className:"animate-spin text-muted-foreground"})}),e[28]=m):m=e[28];let p;return e[29]!==o||e[30]!==h.id||e[31]!==h.view.appId?(p=n.jsx(S.Suspense,{fallback:m,children:n.jsx(wh,{connectionId:h.view.appId,toolName:h.id},o)}),e[29]=o,e[30]=h.id,e[31]=h.view.appId,e[32]=p):p=e[32],p}let f;return e[33]!==i?(f=n.jsx(kd,{virtualMcpId:i}),e[33]=i,e[34]=f):f=e[34],f}function h5(t){const e=B.c(7),{children:s,defaultSize:i}=t,[,r]=S.useTransition();let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=ml.decoChatPanelWidth(),e[0]=o):o=e[0];const[a,l]=fl(o,45),c=i>0&&i<100?a:i;let d;e[1]!==l?(d=f=>r(()=>{f>0&&f<100&&l(f)}),e[1]=l,e[2]=d):d=e[2];const u=d;let h;return e[3]!==s||e[4]!==c||e[5]!==u?(h=n.jsx(mu,{defaultSize:c,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]=c,e[5]=u,e[6]=h):h=e[6],h}function u5(t){const e=B.c(31),{virtualMcpId:s,taskId:i,chatOpen:r,mainOpen:o,variant:a,chatContent:l}=t;let c;e[0]!==r||e[1]!==o?(c=yd(r,o),e[0]=r,e[1]=o,e[2]=c):c=e[2];const d=c;let u;e[3]===Symbol.for("react.memo_cache_sentinel")?(u=ml.decoChatPanelWidth(),e[3]=u):u=e[3];const[h]=fl(u,45),f=S.useRef(null);let m,p;e[4]!==r||e[5]!==o||e[6]!==h?(m=()=>{const T=f.current;if(!T)return;const R=yd(r,o),N=R.chat>0&&R.chat<100?h:R.chat,A=R.chat>0&&R.chat<100?100-h:R.main;T.setLayout([N,A])},p=[r,o,h],e[4]=r,e[5]=o,e[6]=h,e[7]=m,e[8]=p):(m=e[7],p=e[8]),S.useEffect(m,p);const g=`${s}-${i}`;let _;e[9]===Symbol.for("react.memo_cache_sentinel")?(_={overflow:"visible"},e[9]=_):_=e[9];let v;e[10]!==l||e[11]!==a?(v=l??n.jsx(of,{variant:a}),e[10]=l,e[11]=a,e[12]=v):v=e[12];let x;e[13]!==v?(x=n.jsx("div",{className:"h-full p-0.5 pt-0.25",children:n.jsx("div",{className:"h-full bg-background rounded-[0.75rem] overflow-hidden card-shadow",children:v})}),e[13]=v,e[14]=x):x=e[14];let b;e[15]!==d.chat||e[16]!==x?(b=n.jsx(h5,{defaultSize:d.chat,children:x}),e[15]=d.chat,e[16]=x,e[17]=b):b=e[17];let y;e[18]===Symbol.for("react.memo_cache_sentinel")?(y=n.jsx(r_,{className:"bg-sidebar"}),e[18]=y):y=e[18];const C=d.main;let k;e[19]===Symbol.for("react.memo_cache_sentinel")?(k={overflow:"visible"},e[19]=k):k=e[19];let w;e[20]===Symbol.for("react.memo_cache_sentinel")?(w=J("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[20]=w):w=e[20];let V;e[21]!==i||e[22]!==s?(V=n.jsx("div",{className:"h-full p-0.5 pt-0.25",children:n.jsx("div",{className:w,children:n.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:n.jsx(d5,{taskId:i,virtualMcpId:s})})})}),e[21]=i,e[22]=s,e[23]=V):V=e[23];let j;e[24]!==d.main||e[25]!==V?(j=n.jsx(mu,{className:"min-w-0 flex flex-col",order:2,defaultSize:C,style:k,collapsible:!0,collapsedSize:0,minSize:20,children:V}),e[24]=d.main,e[25]=V,e[26]=j):j=e[26];let I;return e[27]!==j||e[28]!==g||e[29]!==b?(I=n.jsxs(o_,{ref:f,direction:"horizontal",className:"flex-1 min-h-0 pb-1 pr-1 pl-0 pt-0",style:_,children:[b,y,j]},g),e[27]=j,e[28]=g,e[29]=b,e[30]=I):I=e[30],I}const la="flex size-7 shrink-0 items-center justify-center rounded-md transition-colors",Vh="bg-sidebar-accent text-sidebar-foreground",ca="text-sidebar-foreground/60 hover:bg-sidebar-accent hover:text-sidebar-foreground";function f5(t){const e=B.c(38),{isDecopilot:s,chatOpen:i,toggleChat:r,onNewTask:o}=t,{tasksOpen:a,toggleTasks:l}=Jf(),c=!!o;let d;e[0]!==a||e[1]!==l?(d=()=>{ne("agent_toolbar_toggled",{button:"tasks",next_state:a?"closed":"open"}),l()},e[0]=a,e[1]=l,e[2]=d):d=e[2];const u=a?Vh:ca;let h;e[3]!==u?(h=J(la,u),e[3]=u,e[4]=h):h=e[4];let f;e[5]===Symbol.for("react.memo_cache_sentinel")?(f=n.jsx(zg,{size:16}),e[5]=f):f=e[5];let m;e[6]!==d||e[7]!==h||e[8]!==a?(m=n.jsx(st,{asChild:!0,children:n.jsx("button",{type:"button",onClick:d,"aria-pressed":a,className:h,children:f})}),e[6]=d,e[7]=h,e[8]=a,e[9]=m):m=e[9];let p;e[10]===Symbol.for("react.memo_cache_sentinel")?(p=n.jsx(it,{side:"bottom",children:"Tasks"}),e[10]=p):p=e[10];let g;e[11]!==m?(g=n.jsxs(nt,{delayDuration:300,children:[m,p]}),e[11]=m,e[12]=g):g=e[12];let _;e[13]!==i||e[14]!==s||e[15]!==r?(_=!s&&n.jsxs(nt,{delayDuration:300,children:[n.jsx(st,{asChild:!0,children:n.jsx("button",{type:"button",onClick:()=>{ne("agent_toolbar_toggled",{button:"chat",next_state:i?"closed":"open"}),r()},"aria-pressed":i,className:J(la,i?Vh:ca),children:n.jsx($g,{size:16})})}),n.jsx(it,{side:"bottom",children:"Chat"})]}),e[13]=i,e[14]=s,e[15]=r,e[16]=_):_=e[16];const v=c?"grid-cols-[1fr]":"grid-cols-[0fr]";let x;e[17]!==v?(x=J("grid transition-[grid-template-columns] duration-200 ease-[var(--ease-out-quart)]",v),e[17]=v,e[18]=x):x=e[18];const b=!c,y=c?0:-1,C=!c,k=c?"translate-x-0 opacity-100":"-translate-x-2 opacity-0";let w;e[19]!==k?(w=J(la,ca,"transition-[transform,opacity] duration-200 ease-[var(--ease-out-quart)] will-change-transform",k),e[19]=k,e[20]=w):w=e[20];let V;e[21]===Symbol.for("react.memo_cache_sentinel")?(V=n.jsx(Sl,{size:16}),e[21]=V):V=e[21];let j;e[22]!==o||e[23]!==b||e[24]!==y||e[25]!==C||e[26]!==w?(j=n.jsx(st,{asChild:!0,children:n.jsx("button",{type:"button",onClick:o,disabled:b,tabIndex:y,"aria-hidden":C,className:w,children:V})}),e[22]=o,e[23]=b,e[24]=y,e[25]=C,e[26]=w,e[27]=j):j=e[27];let I;e[28]===Symbol.for("react.memo_cache_sentinel")?(I=n.jsx(it,{side:"bottom",children:"New task"}),e[28]=I):I=e[28];let T;e[29]!==j?(T=n.jsx("div",{className:"overflow-hidden",children:n.jsxs(nt,{delayDuration:300,children:[j,I]})}),e[29]=j,e[30]=T):T=e[30];let R;e[31]!==x||e[32]!==T?(R=n.jsx("div",{className:x,children:T}),e[31]=x,e[32]=T,e[33]=R):R=e[33];let N;return e[34]!==R||e[35]!==g||e[36]!==_?(N=n.jsxs(n.Fragment,{children:[g,_,R]}),e[34]=R,e[35]=g,e[36]=_,e[37]=N):N=e[37],N}function m5(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(h=>h.id===e))return{visible:i,overflow:r};const a=r.findIndex(h=>h.id===e);if(a===-1)return{visible:i,overflow:r};const l=i[i.length-1],c=r[a],d=[...i.slice(0,-1),c],u=[l,...r.slice(0,a),...r.slice(a+1)];return{visible:d,overflow:u}}function p5(t){const e=B.c(13),{title:s,icon:i,active:r,onClick:o}=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=J("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 c;e[2]!==i?(c=n.jsx("span",{className:"flex size-5 items-center justify-center shrink-0",children:n.jsx(g5,{icon:i})}),e[2]=i,e[3]=c):c=e[3];let d;e[4]!==s?(d=n.jsx("span",{className:"whitespace-nowrap text-sm font-medium leading-none",children:s}),e[4]=s,e[5]=d):d=e[5];let u;return e[6]!==r||e[7]!==o||e[8]!==l||e[9]!==c||e[10]!==d||e[11]!==s?(u=n.jsxs("button",{type:"button",onClick:o,"aria-pressed":r,"aria-label":s,className:l,children:[c,d]}),e[6]=r,e[7]=o,e[8]=l,e[9]=c,e[10]=d,e[11]=s,e[12]=u):u=e[12],u}function g5(t){const e=B.c(5),{icon:s}=t;if(s.kind==="component"){const{Component:r}=s;let o;return e[0]!==r?(o=n.jsx(r,{className:"size-4"}),e[0]=r,e[1]=o):o=e[1],o}if(s.kind==="url"){let r;return e[2]!==s.src?(r=n.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=n.jsx(ru,{className:"size-4"}),e[4]=i):i=e[4],i}function _5(t){const e=B.c(13),{overflow:s,onSelect:i}=t,[r,o]=S.useState(!1);let a;e[0]!==i?(a=f=>{o(!1),i(f)},e[0]=i,e[1]=a):a=e[1];const l=a;let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx(li,{asChild:!0,children:n.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:n.jsx(su,{className:"size-4"})})}),e[2]=c):c=e[2];let d;if(e[3]!==l||e[4]!==s){let f;e[6]!==l?(f=m=>n.jsx("li",{children:n.jsxs("button",{type:"button",onClick:()=>l(m.id),className:"w-full flex items-center gap-2 px-3 py-2 rounded-md hover:bg-accent text-sm text-foreground",children:[n.jsx("span",{className:"flex size-5 items-center justify-center shrink-0",children:n.jsx(x5,{icon:m.icon})}),n.jsx("span",{className:"truncate",children:m.title})]})},m.id),e[6]=l,e[7]=f):f=e[7],d=s.map(f),e[3]=l,e[4]=s,e[5]=d}else d=e[5];let u;e[8]!==d?(u=n.jsx(ci,{align:"end",className:"w-56 p-1",children:n.jsx("ul",{className:"flex flex-col",children:d})}),e[8]=d,e[9]=u):u=e[9];let h;return e[10]!==r||e[11]!==u?(h=n.jsxs(di,{open:r,onOpenChange:o,children:[c,u]}),e[10]=r,e[11]=u,e[12]=h):h=e[12],h}function x5(t){const e=B.c(5),{icon:s}=t;if(s.kind==="component"){const{Component:r}=s;let o;return e[0]!==r?(o=n.jsx(r,{className:"size-4"}),e[0]=r,e[1]=o):o=e[1],o}if(s.kind==="url"){let r;return e[2]!==s.src?(r=n.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=n.jsx(ru,{className:"size-4"}),e[4]=i):i=e[4],i}const v5=6;function b5(t){const e=B.c(20),{virtualMcpId:s,taskId:i}=t,r=Ge();let o;e[0]!==i||e[1]!==s?(o={virtualMcpId:s,taskId:i},e[0]=i,e[1]=s,e[2]=o):o=e[2];const{tabs:a,activeTab:l,mainOpen:c,setActiveTab:d}=Zf(o);let u,h,f,m;if(e[3]!==l||e[4]!==c||e[5]!==r||e[6]!==d||e[7]!==a||e[8]!==s){const _=lg({activeTab:l,mainOpen:c}),v=k=>k.id==="automations"?_:c&&k.id===l,b=a.find(k=>v(k))?.id??null,{visible:y,overflow:C}=m5(a,b,v5);h=C,u=k=>{const w=a.find(j=>j.id===k),V=b===k&&c;if(ne("main_panel_tab_clicked",{virtual_mcp_id:s,tab_id:k,tab_kind:w?.kind??null,was_active:V}),k==="automations"){const j=cg({activeTab:l,mainOpen:c});r({to:".",search:I=>({...I,main:j}),replace:!0});return}d(k)},f="flex items-center min-w-0 ml-auto gap-0.5",m=y.map(k=>n.jsx(p5,{title:k.title,icon:k.icon,active:v(k),onClick:()=>u(k.id)},k.id)),e[3]=l,e[4]=c,e[5]=r,e[6]=d,e[7]=a,e[8]=s,e[9]=u,e[10]=h,e[11]=f,e[12]=m}else u=e[9],h=e[10],f=e[11],m=e[12];let p;e[13]!==u||e[14]!==h?(p=h.length>0&&n.jsx(_5,{overflow:h,onSelect:u}),e[13]=u,e[14]=h,e[15]=p):p=e[15];let g;return e[16]!==f||e[17]!==m||e[18]!==p?(g=n.jsxs("div",{className:f,children:[m,p]}),e[16]=f,e[17]=m,e[18]=p,e[19]=g):g=e[19],g}function y5(t){const e=B.c(12);let s,i,r,o;e[0]!==t?({className:s,orientation:r,decorative:o,...i}=t,e[0]=t,e[1]=s,e[2]=i,e[3]=r,e[4]=o):(s=e[1],i=e[2],r=e[3],o=e[4]);const a=r===void 0?"horizontal":r,l=o===void 0?!0:o;let c;e[5]!==s?(c=J("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]=c):c=e[6];let d;return e[7]!==l||e[8]!==a||e[9]!==i||e[10]!==c?(d=n.jsx(Bp,{"data-slot":"separator-root",decorative:l,orientation:a,className:c,...i}),e[7]=l,e[8]=a,e[9]=i,e[10]=c,e[11]=d):d=e[11],d}function S5(t){const e=B.c(20),{prNumber:s,disabled:i,send:r}=t;let o;e[0]!==s||e[1]!==r?(o=()=>r(BV({prNumber:s})),e[0]=s,e[1]=r,e[2]=o):o=e[2];const a=o;let l;e[3]!==s||e[4]!==r?(l=()=>r(OV({prNumber:s})),e[3]=s,e[4]=r,e[5]=l):l=e[5];const c=l;let d;e[6]!==i||e[7]!==a?(d=n.jsx(ae,{size:"sm",className:"rounded-r-none border-r border-primary-foreground/20",disabled:i,onClick:a,children:"Publish"}),e[6]=i,e[7]=a,e[8]=d):d=e[8];let u;e[9]===Symbol.for("react.memo_cache_sentinel")?(u=n.jsx(Rn,{className:"h-3.5 w-3.5"}),e[9]=u):u=e[9];let h;e[10]!==i?(h=n.jsx(Is,{asChild:!0,children:n.jsx(ae,{size:"sm",className:"rounded-l-none px-2",disabled:i,"aria-label":"More actions",children:u})}),e[10]=i,e[11]=h):h=e[11];let f;e[12]!==c?(f=n.jsx(Rs,{align:"end",children:n.jsx(at,{onClick:c,children:"Review"})}),e[12]=c,e[13]=f):f=e[13];let m;e[14]!==h||e[15]!==f?(m=n.jsxs(Es,{children:[h,f]}),e[14]=h,e[15]=f,e[16]=m):m=e[16];let p;return e[17]!==d||e[18]!==m?(p=n.jsxs("div",{className:"inline-flex items-stretch rounded-md",children:[d,m]}),e[17]=d,e[18]=m,e[19]=p):p=e[19],p}const w5=new Set(["failure","timed_out","cancelled","action_required"]);function V5(t){return t.status==="completed"&&w5.has(t.conclusion)}function C5(t){return t.status==="queued"||t.status==="in_progress"}function k5(t){const{branchStatus:e,pr:s,checks:i,reviews:r}=t;if(!e)return null;if(e.workingTreeDirty||e.unpushed>0)return{label:"Save changes",action:"commit-and-push"};if(s?.merged)return!!e.headSha&&!!s.headSha&&e.headSha!==s.headSha?{label:"Submit for review",action:"create-pr"}:null;if(e.aheadOfBase>0){if(s&&s.state==="closed"&&!s.merged)return{label:"Reopen",action:"reopen"};if(!s)return{label:"Submit for review",action:"create-pr"};if((r?.mergeableState??"unknown")==="dirty")return{label:`Sync with ${s.base}`,action:"rebase"};const l=i.filter(V5).map(c=>c.name);return l.length>0?{label:"Fix tests",action:"fix-checks",meta:{failingChecks:l}}:i.some(C5)?{label:"Running tests…",disabled:!0}:r?.draft?{label:"Mark ready",action:"mark-ready"}:(r?.unresolvedConversations??0)>0?{label:"Address feedback",action:"resolve-comments"}:r?.missingRequiredApprovals?{label:"Awaiting review",disabled:!0}:{label:"Publish",action:"merge-split"}}return null}function j5(){return Zi().branchStatus}const N5=6e4,A5=3e4;function E5(t){const e=B.c(11);let s;e[0]!==t.connectionId||e[1]!==t.orgId?(s={connectionId:t.connectionId,orgId:t.orgId},e[0]=t.connectionId,e[1]=t.orgId,e[2]=s):s=e[2];const i=Be(s),r=t.prNumber??0;let o;e[3]!==t.owner||e[4]!==t.repo||e[5]!==r?(o={method:"get",owner:t.owner,repo:t.repo,pullNumber:r},e[3]=t.owner,e[4]=t.repo,e[5]=r,e[6]=o):o=e[6];const a=!!t.prNumber;let l;return e[7]!==i||e[8]!==o||e[9]!==a?(l={client:i,toolName:"pull_request_read",toolArguments:o,enabled:a,refetchInterval:N5,refetchIntervalInBackground:!1,staleTime:A5,select:I5},e[7]=i,e[8]=o,e[9]=a,e[10]=l):l=e[10],ki(l)}function I5(t){const e=nr(t);if(!e)return null;const s=e.mergeable_state??"unknown",i=!!(e.draft??!1),r=Number(e.review_comments??0),o=s==="blocked"&&r>0?r:0;return{draft:i,mergeableState:s,unresolvedConversations:o,missingRequiredApprovals:s==="blocked"&&o===0}}function R5(t){const e=B.c(38),{virtualMcpId:s}=t,{org:i}=xe(),r=is(s),{currentBranch:o}=es(),a=no(),l=r?.metadata?.githubRepo??null,c=j5(),d=l?.connectionId??"",u=l?.owner??"",h=l?.name??"",f=o??null;let m;e[0]!==i.id||e[1]!==d||e[2]!==u||e[3]!==h||e[4]!==f?(m={orgId:i.id,connectionId:d,owner:u,repo:h,branch:f},e[0]=i.id,e[1]=d,e[2]=u,e[3]=h,e[4]=f,e[5]=m):m=e[5];const g=tm(m).data??null,_=l?.connectionId??"",v=l?.owner??"",x=l?.name??"",b=g&&g.state==="open"?g.number:null;let y;e[6]!==i.id||e[7]!==_||e[8]!==v||e[9]!==x||e[10]!==b?(y={orgId:i.id,connectionId:_,owner:v,repo:x,prNumber:b},e[6]=i.id,e[7]=_,e[8]=v,e[9]=x,e[10]=b,e[11]=y):y=e[11];const C=im(y),k=l?.connectionId??"",w=l?.owner??"",V=l?.name??"",j=g&&g.state==="open"?g.number:null;let I;e[12]!==i.id||e[13]!==k||e[14]!==w||e[15]!==V||e[16]!==j?(I={orgId:i.id,connectionId:k,owner:w,repo:V,prNumber:j},e[12]=i.id,e[13]=k,e[14]=w,e[15]=V,e[16]=j,e[17]=I):I=e[17];const T=E5(I);if(!l?.connectionId||!o)return null;let R;e[18]!==c||e[19]!==C.data||e[20]!==g||e[21]!==T.data?(R=k5({branchStatus:c,pr:g,checks:C.data??[],reviews:T.data??null}),e[18]=c,e[19]=C.data,e[20]=g,e[21]=T.data,e[22]=R):R=e[22];const N=R;if(!N)return null;let A;e[23]!==a?(A=$=>a.sendMessage({parts:[{type:"text",text:$}]}),e[23]=a,e[24]=A):A=e[24];const E=A,M=a.isStreaming;let L;e[25]!==o||e[26]!==N||e[27]!==M||e[28]!==g||e[29]!==E?(L=$=>{if(!M)switch($){case"commit-and-push":{E(EV({branch:o}));return}case"create-pr":{E(IV({branch:o}));return}case"reopen":{g&&E(RV({prNumber:g.number}));return}case"rebase":{E(TV({branch:o}));return}case"fix-checks":{g&&E(MV({prNumber:g.number,failingChecks:N.meta?.failingChecks??[]}));return}case"mark-ready":{g&&E(PV({prNumber:g.number}));return}case"resolve-comments":{g&&E(LV({prNumber:g.number}));return}case"merge-split":return}},e[25]=o,e[26]=N,e[27]=M,e[28]=g,e[29]=E,e[30]=L):L=e[30];const D=L;let P;e[31]===Symbol.for("react.memo_cache_sentinel")?(P=n.jsx(y5,{orientation:"vertical",className:"mx-2 data-[orientation=vertical]:h-5"}),e[31]=P):P=e[31];const O=g?.number;let z;return e[32]!==N||e[33]!==M||e[34]!==D||e[35]!==E||e[36]!==O?(z=n.jsxs(n.Fragment,{children:[P,n.jsx(T5,{button:N,isStreaming:M,onActivate:D,prNumber:O,send:E})]}),e[32]=N,e[33]=M,e[34]=D,e[35]=E,e[36]=O,e[37]=z):z=e[37],z}function T5(t){const e=B.c(18),{button:s,isStreaming:i}=t,r=!!s.disabled||i,o=i?"Chat is running":null;if(s.action==="merge-split"&&t.prNumber!=null){let u;e[0]!==r||e[1]!==t.prNumber||e[2]!==t.send?(u=n.jsx(S5,{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 h;return e[4]!==u||e[5]!==o?(h=n.jsx(Ch,{label:o,children:u}),e[4]=u,e[5]=o,e[6]=h):h=e[6],h}const a=s.disabled?"outline":"default";let l;e[7]!==s.action||e[8]!==t?(l=()=>t.onActivate(s.action),e[7]=s.action,e[8]=t,e[9]=l):l=e[9];let c;e[10]!==s.label||e[11]!==r||e[12]!==a||e[13]!==l?(c=n.jsx(ae,{size:"sm",variant:a,disabled:r,onClick:l,children:s.label}),e[10]=s.label,e[11]=r,e[12]=a,e[13]=l,e[14]=c):c=e[14];let d;return e[15]!==c||e[16]!==o?(d=n.jsx(Ch,{label:o,children:c}),e[15]=c,e[16]=o,e[17]=d):d=e[17],d}function Ch(t){const e=B.c(9),{label:s,children:i}=t;if(!s){let l;return e[0]!==i?(l=n.jsx(n.Fragment,{children:i}),e[0]=i,e[1]=l):l=e[1],l}let r;e[2]!==i?(r=n.jsx(st,{asChild:!0,children:n.jsx("span",{children:i})}),e[2]=i,e[3]=r):r=e[3];let o;e[4]!==s?(o=n.jsx(it,{children:s}),e[4]=s,e[5]=o):o=e[5];let a;return e[6]!==r||e[7]!==o?(a=n.jsx(Bi,{children:n.jsxs(nt,{children:[r,o]})}),e[6]=r,e[7]=o,e[8]=a):a=e[8],a}function D5(t){const e=B.c(2),{virtualMcp:s}=t;if(!!!(s.metadata?.githubRepo??null)?.connectionId)return null;let o;return e[0]!==s.id?(o=n.jsx(He.Right,{children:n.jsx(R5,{virtualMcpId:s.id})}),e[0]=s.id,e[1]=o):o=e[1],o}const Mi=S.createContext(null);function fc(){return S.use(Mi)}function kh(t){const e=B.c(8),{children:s,variant:i}=t,{taskId:r}=es();let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=n.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]=o):o=e[0];let a;e[1]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx($e.Skeleton,{}),e[1]=a):a=e[1];let l;e[2]!==s||e[3]!==i?(l=s??n.jsx(of,{variant:i}),e[2]=s,e[3]=i,e[4]=l):l=e[4];let c;return e[5]!==l||e[6]!==r?(c=n.jsx(As,{fallback:o,children:n.jsx(S.Suspense,{fallback:a,children:n.jsx($e.ActiveTaskProvider,{taskId:r,children:l})})}),e[5]=l,e[6]=r,e[7]=c):c=e[7],c}function jh(t){const e=B.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],S.useLayoutEffect(r),null}function M5(t){const e=B.c(3),{onOpenSidebar:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx(Hg,{size:20}),e[0]=i):i=e[0];let r;return e[1]!==s?(r=n.jsx("div",{className:"shrink-0 flex items-center justify-between px-3 h-12 bg-background border-b border-border",children:n.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 Nh(t){const e=B.c(16),{virtualMcpId:s,hasActiveGithubRepo:i,vmMap:r,children:o}=t,{org:a}=xe(),{currentBranch:l}=es(),{data:c}=St.useSession(),d=c?.user?.id,u=d&&l?r?.[d]?.[l]??null:null;let h;e[0]!==u?(h=u?.previewUrl?u.previewUrl.replace(/\/$/,""):null,e[0]=u,e[1]=h):h=e[1];const f=h;let m;e[2]!==a.id?(m={connectionId:Pt,orgId:a.id},e[2]=a.id,e[3]=m):m=e[3];const p=Be(m),{mutate:g}=Zl(p);let _;e[4]===Symbol.for("react.memo_cache_sentinel")?(_=new Set,e[4]=_):_=e[4];const v=S.useRef(_);let x,b;e[5]!==l||e[6]!==i||e[7]!==g||e[8]!==d||e[9]!==s||e[10]!==r?(x=()=>{i&&d&&l&&(r?.[d]?.[l]||v.current.has(l)||(v.current.add(l),g({virtualMcpId:s,branch:l},{onError:P5})))},b=[i,d,l,r,s,g],e[5]=l,e[6]=i,e[7]=g,e[8]=d,e[9]=s,e[10]=r,e[11]=x,e[12]=b):(x=e[11],b=e[12]),S.useEffect(x,b);let y;return e[13]!==o||e[14]!==f?(y=n.jsx(hC,{daemonBaseUrl:f,children:o}),e[13]=o,e[14]=f,e[15]=y):y=e[15],y}function P5(t){console.error("[auto-start-vm] failed:",t)}function Ah(){const t=B.c(106),e=Ps(),s=Ge(),{org:i}=xe(),r=uw()?.tasksOpen??!1;z_(i.id);let o;t[0]===Symbol.for("react.memo_cache_sentinel")?(o={strict:!1},t[0]=o):o=t[0];const a=Hn(o),l=a.org??"";let c;t[1]===Symbol.for("react.memo_cache_sentinel")?(c={strict:!1},t[1]=c):c=t[1];const d=Si(c);let u;t[2]!==i.id||t[3]!==d.virtualmcpid?(u=d.virtualmcpid??co(i.id).id,t[2]=i.id,t[3]=d.virtualmcpid,t[4]=u):u=t[4];const h=u;let f;t[5]!==i.id?(f=xl(i.id),t[5]=i.id,t[6]=f):f=t[6];const m=h===f,p=!m,g=tx(a.taskId??"",h),_=is(h),v=_?.metadata?.ui?.layout??null;let x;t[7]!==v?(x=v?{defaultMainView:v.defaultMainView??null,chatDefaultOpen:v.chatDefaultOpen??null}:null,t[7]=v,t[8]=x):x=t[8];const b=x;let y;t[9]!==_?(y=_&&Fs(_),t[9]=_,t[10]=y):y=t[10];const C=!!y;let k;t[11]!==p||t[12]!==l||t[13]!==h?(k={virtualMcpId:h,orgSlug:l,isAgentRoute:p},t[11]=p,t[12]=l,t[13]=h,t[14]=k):k=t[14];const w=cw(b,k),{setOpenMobile:V,openMobile:j}=Qn(),I=V,T=S.useRef(null);let R,N;t[15]===Symbol.for("react.memo_cache_sentinel")?(R=()=>{const W=K=>{Wh(K)&&K.shiftKey&&K.code==="KeyS"&&!K.repeat&&(K.preventDefault(),T.current?.())};return document.addEventListener("keydown",W),()=>document.removeEventListener("keydown",W)},N=[],t[15]=R,t[16]=N):(R=t[15],N=t[16]),S.useEffect(R,N);const A=h;let E;t[17]!==_||t[18]!==h?(E={virtualMcpId:h,entity:_},t[17]=_,t[18]=h,t[19]=E):E=t[19];const M=E;if(g.status==="creating"||g.status==="loading"){let W;t[20]===Symbol.for("react.memo_cache_sentinel")?(W=n.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:n.jsxs("div",{className:"flex h-full items-center justify-center bg-background card-shadow rounded-[0.75rem] text-sm text-muted-foreground",children:[n.jsx(Me,{className:"size-4 animate-spin mr-2"}),"Creating task…"]})}),t[20]=W):W=t[20];let K;return t[21]!==M?(K=n.jsx(Mi,{value:M,children:W}),t[21]=M,t[22]=K):K=t[22],K}if(g.status==="error"){let W;t[23]===Symbol.for("react.memo_cache_sentinel")?(W=n.jsx("div",{className:"font-medium",children:"Task unavailable"}),t[23]=W):W=t[23];let K;t[24]!==g.error.message?(K=n.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:n.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:[W,n.jsx("div",{className:"text-muted-foreground",children:g.error.message})]})}),t[24]=g.error.message,t[25]=K):K=t[25];let ee;return t[26]!==M||t[27]!==K?(ee=n.jsx(Mi,{value:M,children:K}),t[26]=M,t[27]=K,t[28]=ee):ee=t[28],ee}if(!_){let W;t[29]===Symbol.for("react.memo_cache_sentinel")?(W=n.jsx(oi,{size:48,className:"text-muted-foreground"}),t[29]=W):W=t[29];const K=`The agent "${h}" does not exist in this organization.`;let ee;t[30]!==s||t[31]!==l?(ee=n.jsx(ae,{variant:"outline",onClick:()=>s({to:"/$org",params:{org:l}}),children:"Go to organization home"}),t[30]=s,t[31]=l,t[32]=ee):ee=t[32];let Z;t[33]!==K||t[34]!==ee?(Z=n.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:n.jsx("div",{className:"flex flex-col h-full bg-background overflow-hidden card-shadow rounded-[0.75rem]",children:n.jsx(Ui,{image:W,title:"Agent not found",description:K,actions:ee})})}),t[33]=K,t[34]=ee,t[35]=Z):Z=t[35];let X;return t[36]!==M||t[37]!==Z?(X=n.jsx(Mi,{value:M,children:Z}),t[36]=M,t[37]=Z,t[38]=X):X=t[38],X}if(e){let W;t[39]===Symbol.for("react.memo_cache_sentinel")?(W=n.jsx(M_,{className:"sr-only",children:"Navigation"}),t[39]=W):W=t[39];let K;t[40]!==I?(K=n.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:n.jsx(sw,{onClose:()=>I(!1)})}),t[40]=I,t[41]=K):K=t[41];let ee;t[42]===Symbol.for("react.memo_cache_sentinel")?(ee=n.jsx("div",{className:"flex-1 min-w-0 overflow-hidden",children:n.jsx(cf,{})}),t[42]=ee):ee=t[42];let Z;t[43]!==K?(Z=n.jsxs(P_,{side:"left",hideCloseButton:!0,className:"w-[calc(100vw-3rem)] sm:max-w-md! p-0",children:[W,n.jsxs("div",{className:"flex h-full",children:[K,ee]})]}),t[43]=K,t[44]=Z):Z=t[44];let X;t[45]!==j||t[46]!==I||t[47]!==Z?(X=n.jsx(L_,{open:j,onOpenChange:I,children:Z}),t[45]=j,t[46]=I,t[47]=Z,t[48]=X):X=t[48];const ie=X,re=_?.metadata?.vmMap;let de;t[49]!==w.createNewTask?(de=n.jsx(jh,{onNewTaskRef:T,createNewTask:w.createNewTask}),t[49]=w.createNewTask,t[50]=de):de=t[50];let me;t[51]!==I?(me=n.jsx(M5,{onOpenSidebar:()=>I(!0)}),t[51]=I,t[52]=me):me=t[52];const le=m?"home":void 0;let se;t[53]!==le?(se=n.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:n.jsx(kh,{variant:le})}),t[53]=le,t[54]=se):se=t[54];let _e;t[55]!==C||t[56]!==ie||t[57]!==re||t[58]!==de||t[59]!==me||t[60]!==se||t[61]!==h?(_e=n.jsxs(Nh,{virtualMcpId:h,hasActiveGithubRepo:C,vmMap:re,children:[de,me,se,ie]}),t[55]=C,t[56]=ie,t[57]=re,t[58]=de,t[59]=me,t[60]=se,t[61]=h,t[62]=_e):_e=t[62];let ge;t[63]!==A||t[64]!==_e?(ge=n.jsx("div",{className:"flex flex-col flex-1 bg-background min-h-0",children:n.jsx($e.Provider,{virtualMcpId:A,children:_e},A)}),t[63]=A,t[64]=_e,t[65]=ge):ge=t[65];let Se;return t[66]!==M||t[67]!==ge?(Se=n.jsx(Mi,{value:M,children:ge}),t[66]=M,t[67]=ge,t[68]=Se):Se=t[68],Se}const L=r?void 0:w.createNewTask;let D;t[69]!==m||t[70]!==w.chatOpen||t[71]!==w.toggleChat||t[72]!==L?(D=n.jsx(He.Toggles,{children:n.jsx(f5,{isDecopilot:m,chatOpen:w.chatOpen,toggleChat:w.toggleChat,onNewTask:L})}),t[69]=m,t[70]=w.chatOpen,t[71]=w.toggleChat,t[72]=L,t[73]=D):D=t[73];let P;t[74]!==m||t[75]!==w.taskId||t[76]!==h?(P=!m&&n.jsx(He.Tabs,{children:n.jsx(b5,{virtualMcpId:h,taskId:w.taskId})}),t[74]=m,t[75]=w.taskId,t[76]=h,t[77]=P):P=t[77];const O=_?.metadata?.vmMap;let z;t[78]!==_||t[79]!==m?(z=!m&&n.jsx(D5,{virtualMcp:_}),t[78]=_,t[79]=m,t[80]=z):z=t[80];let $;t[81]!==w.createNewTask?($=n.jsx(jh,{onNewTaskRef:T,createNewTask:w.createNewTask}),t[81]=w.createNewTask,t[82]=$):$=t[82];const q=m?"home":void 0;let F;t[83]!==q?(F=n.jsx(kh,{variant:q}),t[83]=q,t[84]=F):F=t[84];let G;t[85]!==w.chatOpen||t[86]!==w.mainOpen||t[87]!==w.taskId||t[88]!==F||t[89]!==h?(G=n.jsx(u5,{virtualMcpId:h,taskId:w.taskId,chatOpen:w.chatOpen,mainOpen:w.mainOpen,chatContent:F}),t[85]=w.chatOpen,t[86]=w.mainOpen,t[87]=w.taskId,t[88]=F,t[89]=h,t[90]=G):G=t[90];let H;t[91]!==C||t[92]!==O||t[93]!==z||t[94]!==$||t[95]!==G||t[96]!==h?(H=n.jsxs(Nh,{virtualMcpId:h,hasActiveGithubRepo:C,vmMap:O,children:[z,$,G]}),t[91]=C,t[92]=O,t[93]=z,t[94]=$,t[95]=G,t[96]=h,t[97]=H):H=t[97];let U;t[98]!==A||t[99]!==P||t[100]!==H?(U=n.jsxs($e.Provider,{virtualMcpId:A,children:[P,H]},A),t[98]=A,t[99]=P,t[100]=H,t[101]=U):U=t[101];let Y;return t[102]!==M||t[103]!==D||t[104]!==U?(Y=n.jsxs(Mi,{value:M,children:[D,U]}),t[102]=M,t[103]=D,t[104]=U,t[105]=Y):Y=t[105],Y}function EN(){const t=B.c(5),e=Ps();let s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s={"--sidebar-width-icon":"3.5rem"},t[0]=s):s=t[0];let i;t[1]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx(tw,{}),t[1]=i):i=t[1];let r;t[2]===Symbol.for("react.memo_cache_sentinel")?(r={background:"transparent",containerType:"inline-size"},t[2]=r):r=t[2];let o;return t[3]!==e?(o=n.jsx(R_,{defaultOpen:!1,children:n.jsx("div",{className:"flex flex-col h-dvh overflow-hidden",children:n.jsxs(T_,{className:"flex-1 bg-sidebar",style:s,children:[i,n.jsx(D_,{className:"flex flex-col",style:r,children:e?n.jsx(S.Suspense,{fallback:n.jsx("div",{className:"flex-1 flex items-center justify-center",children:n.jsx(Me,{size:20,className:"animate-spin text-muted-foreground"})}),children:n.jsx(Ah,{})}):n.jsx(S.Suspense,{fallback:n.jsx("div",{className:"flex-1 flex items-center justify-center",children:n.jsx(Me,{size:20,className:"animate-spin text-muted-foreground"})}),children:n.jsx(dw,{children:n.jsxs(He,{children:[n.jsxs(He.Header,{children:[n.jsxs(He.LeftColumn,{children:[n.jsx(He.Nav,{}),n.jsx(He.TogglesSlot,{})]}),n.jsx(He.CenterSlot,{}),n.jsxs(He.RightColumn,{children:[n.jsx(He.TabsSlot,{}),n.jsx(He.RightSlot,{})]})]}),n.jsxs("div",{className:"flex-1 min-h-0 flex flex-row",children:[n.jsx(Aw,{}),n.jsx("div",{className:"flex-1 min-w-0 flex flex-col",children:n.jsx(S.Suspense,{fallback:n.jsx("div",{className:"flex-1 flex items-center justify-center",children:n.jsx(Me,{size:20,className:"animate-spin text-muted-foreground"})}),children:n.jsx(Ah,{})})})]})]})})})})]})})}),t[3]=e,t[4]=o):o=t[4],o}export{EN as default,fc as useInsetContext};
|
|
739
|
+
</message>`}]}}))},L=e.models?.credentialId||m||"",D=e.models?.thinking?.id||p?.modelId||"",P=Gi({defaultValues:{name:e.name,active:e.active,credential_id:L,model_id:D}}),O=P.watch("active"),z=P.watch("credential_id"),$=P.watch("model_id"),{models:q,isLoading:F}=hu(z||void 0),G=q.find(le=>le.modelId===$)??null,H=S.useRef(null),U=S.useRef(new Set),Y=S.useRef(0),W=S.useRef(null),K=3e4,ee=()=>{W.current&&(clearTimeout(W.current),W.current=null),H.current!==null&&(ne("automation_updated",{automation_id:t,agent_id:o,fields:Array.from(U.current),save_count:Y.current,edit_duration_ms:Date.now()-H.current}),H.current=null,U.current=new Set,Y.current=0)},Z=async()=>{if(!(Object.keys(P.formState.dirtyFields).length>0)&&!E.current)return!0;const se=Object.keys(P.formState.dirtyFields),_e=E.current;E.current=!1;const ge=P.getValues();try{const Se=ge.credential_id&&ge.model_id?ge.credential_id:"",ve=ge.credential_id&&ge.model_id?ge.model_id:"",Ne={id:t,name:ge.name,active:ge.active,agent:{id:o},models:{credentialId:Se,thinking:{id:ve}},messages:Oh(b),temperature:0};await l.mutateAsync(Ne),H.current===null&&(H.current=Date.now());for(const Te of se)U.current.add(Te);return _e&&U.current.add("messages"),Y.current+=1,W.current&&clearTimeout(W.current),W.current=setTimeout(ee,K),P.reset({...ge,credential_id:Se,model_id:ve}),!0}catch{return E.current=!0,!1}},X=()=>{A.current&&clearTimeout(A.current),A.current=setTimeout(()=>{Z()},1e3)},ie=async()=>(A.current&&clearTimeout(A.current),Z()),re=le=>{if(y(le),!N.current){N.current=!0;return}E.current=!0,X()},de=S.useRef(!1);de.current||(de.current=!0,P.watch(()=>{X()}));const me=async()=>{ne("automation_test_clicked",{automation_id:t,agent_id:o});const le=await ie();if(ee(),!le)return;if(!b){ue.error("No instructions configured for this automation");return}G&&z&&f({...G,keyId:z}),v({..._,toolApprovalLevel:"auto"});const se=pc(b);h({message:{tiptapDoc:b,parts:se},virtualMcpId:o||void 0})};return n.jsxs(n.Fragment,{children:[i&&n.jsx("div",{className:"flex items-center pb-4 shrink-0",children:n.jsxs(ae,{variant:"ghost",size:"sm",onClick:i,children:[n.jsx(Cl,{size:14}),"Back to list"]})}),n.jsxs("div",{className:"flex flex-col gap-8",children:[n.jsxs("div",{className:"flex flex-col gap-1.5",children:[n.jsxs("div",{className:"flex items-center justify-between gap-4",children:[n.jsx(gt,{...P.register("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"}}),r&&n.jsx(ae,{variant:"ghost",size:"icon",className:"text-muted-foreground hover:text-destructive shrink-0",onClick:r,children:n.jsx(_a,{size:14})})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Ti,{control:P.control,name:"active",render:({field:le})=>n.jsx(Ur,{checked:le.value,onCheckedChange:se=>{le.onChange(se),setTimeout(()=>ie(),0)},className:"cursor-pointer"})}),n.jsx("span",{className:"text-sm text-muted-foreground",children:O?"Active":"Inactive"}),n.jsx("span",{className:"text-muted-foreground/50 text-sm",children:"·"}),n.jsx(K_,{id:e.created_by,size:"2xs",className:"text-sm text-muted-foreground"})]})]}),n.jsxs("div",{className:"flex flex-col gap-2.5",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Starter"}),n.jsx(Jj,{automationId:t,open:C,onOpenChange:k,onCustomSelect:()=>{V(!0),R(!1),I("")},onEventSelect:()=>{R(!0),V(!1)}})]}),e.triggers.length===0&&!w?n.jsx("div",{className:"rounded-lg border border-dashed border-border px-4 py-6 text-center",children:n.jsxs("p",{className:"text-sm text-muted-foreground",children:["When should this automation run?"," ",n.jsx("button",{type:"button",className:"text-foreground underline underline-offset-2 cursor-pointer hover:text-foreground/80 transition-colors",onClick:()=>k(!0),children:"Add a starter"})," ","to get going."]})}):n.jsx("div",{className:"flex flex-col gap-2",children:e.triggers.map(le=>n.jsx(Qj,{trigger:le,automationId:t,connectionName:le.connection_id?u.get(le.connection_id):void 0},le.id))}),w&&n.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2.5 rounded-lg border border-border bg-background group",children:[n.jsx(Sn,{size:14,className:"text-muted-foreground shrink-0"}),n.jsx("input",{type:"text",value:j,onChange:le=>I(le.target.value),onBlur:async()=>{const le=j.trim();if(!(!le||!An(le)))try{await c.mutateAsync({automation_id:t,type:"cron",cron_expression:le}),ne("automation_trigger_added",{automation_id:t,trigger_type:"cron"}),ue.success("Starter added"),V(!1),I("")}catch{ue.error("Failed to add starter")}},onKeyDown:async le=>{const se=j.trim();le.key==="Enter"&&se&&An(se)&&le.target.blur(),le.key==="Escape"&&(V(!1),I(""))},placeholder:"0 9 * * 1-5",className:"flex-1 text-sm font-mono bg-transparent outline-none placeholder:text-muted-foreground/40",autoFocus:!0}),j&&!An(j)&&n.jsx("span",{className:"text-xs text-muted-foreground/60 shrink-0",children:"invalid"}),c.isPending&&n.jsx(Me,{size:13,className:"animate-spin text-muted-foreground shrink-0"}),n.jsx("button",{type:"button",className:"shrink-0 p-0.5 rounded text-muted-foreground opacity-0 group-hover:opacity-100 hover:text-foreground transition-opacity",onClick:()=>{V(!1),I("")},children:n.jsx(ri,{size:13})})]}),T&&n.jsx(S.Suspense,{fallback:n.jsxs("div",{className:"flex items-center gap-2 px-3 py-3 rounded-lg border border-border bg-background",children:[n.jsx(Me,{size:13,className:"animate-spin text-muted-foreground"}),n.jsx("span",{className:"text-sm text-muted-foreground",children:"Loading connections..."})]}),children:n.jsx(e5,{automationId:t,onDone:()=>R(!1)})})]}),n.jsxs("div",{className:"flex flex-col gap-2.5",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Instructions"}),n.jsxs(ae,{variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",disabled:!b,onClick:M,children:[n.jsx(Vl,{size:13}),"Improve"]})]}),n.jsx(tf,{tiptapDoc:b,setTiptapDoc:re,placeholder:"What should this automation do?",children:n.jsxs("div",{className:"rounded-xl border border-border min-h-[120px] flex flex-col",children:[n.jsx(sf,{virtualMcpId:o||null,className:"max-h-[45vh]"}),n.jsxs("div",{className:"flex items-center justify-end gap-1.5 p-2.5",children:[n.jsx(fu,{model:G,isLoading:F,credentialId:z||null,onCredentialChange:le=>{P.setValue("credential_id",le??"",{shouldDirty:!0}),P.setValue("model_id","",{shouldDirty:!0})},onModelChange:le=>P.setValue("model_id",le.modelId,{shouldDirty:!0}),placeholder:"Model"}),n.jsxs(nt,{children:[n.jsx(st,{asChild:!0,children:n.jsxs(ae,{type:"button",variant:"default",className:"h-8 gap-1.5 rounded-md px-3 text-sm font-medium",onClick:me,disabled:!o,children:[n.jsx(Qh,{size:16}),"Test"]})}),n.jsx(it,{children:"Test Automation"})]})]})]})})]})]})]})}function r5(t){const e=B.c(6),{tabId:s,virtualMcpId:i}=t;let r;e[0]!==s?(r=$h(s),e[0]=s,e[1]=r):r=e[1];const o=r;if(!o)return null;let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx("div",{className:"flex-1 flex items-center justify-center",children:n.jsx(Me,{size:20,className:"animate-spin text-muted-foreground"})}),e[2]=a):a=e[2];let l;return e[3]!==o.id||e[4]!==i?(l=n.jsx(ps,{children:n.jsx(ps.Content,{children:n.jsx(ps.Body,{children:n.jsx(S.Suspense,{fallback:a,children:n.jsx(o5,{id:o.id,virtualMcpId:i})})})})}),e[3]=o.id,e[4]=i,e[5]=l):l=e[5],l}function o5(t){const e=B.c(9),{id:s,virtualMcpId:i}=t,r=Ge(),{data:o,isLoading:a}=G_(s);let l;e[0]!==r?(l=()=>r({to:".",search:a5,replace:!0}),e[0]=r,e[1]=l):l=e[1];const c=l;if(a){let u;return e[2]===Symbol.for("react.memo_cache_sentinel")?(u=n.jsx("div",{className:"flex-1 flex items-center justify-center",children:n.jsx(Me,{size:20,className:"animate-spin text-muted-foreground"})}),e[2]=u):u=e[2],u}if(!o){let u;return e[3]===Symbol.for("react.memo_cache_sentinel")?(u=n.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:"Automation not found"}),e[3]=u):u=e[3],u}let d;return e[4]!==o||e[5]!==s||e[6]!==c||e[7]!==i?(d=n.jsx(n5,{automationId:s,automation:o,virtualMcpId:i,onBack:c}),e[4]=o,e[5]=s,e[6]=c,e[7]=i,e[8]=d):d=e[8],d}function a5(t){return{...t,main:"automations"}}function l5(t){const e=B.c(19),{virtualMcpId:s}=t,i=Ge(),{data:r}=Y_(s),o=r===void 0?[]:r,{create:a}=er(),[l,c]=S.useState(""),d=l.toLowerCase(),u=o.filter(j=>j.name.toLowerCase().includes(d));let h;e[0]!==i?(h=j=>i({to:".",search:I=>({...I,main:"automation:"+j}),replace:!0}),e[0]=i,e[1]=h):h=e[1];const f=h,m=async()=>{if(a.isPending)return;ne("automation_new_clicked",{virtual_mcp_id:s,existing_count:o.length});const j=await a.mutateAsync(J_(s));f(j.id)},p=ps,g=ps,_=ps;let v;e[2]===Symbol.for("react.memo_cache_sentinel")?(v=n.jsx(Qt,{size:14}),e[2]=v):v=e[2];let x;e[3]!==a.isPending||e[4]!==m?(x=n.jsx(ps.Title,{actions:n.jsxs(ae,{size:"sm",onClick:m,disabled:a.isPending,children:[v,"New automation"]}),children:"Automations"}),e[3]=a.isPending,e[4]=m,e[5]=x):x=e[5];const b=o.length>0&&n.jsx(Q_,{value:l,onChange:c,placeholder:"Search automations...",className:"w-full md:w-[375px]"});let y;e[6]!==x||e[7]!==b?(y=n.jsxs("div",{className:"flex flex-col gap-6",children:[x,b]}),e[6]=x,e[7]=b,e[8]=y):y=e[8];const C=o.length===0?n.jsx("div",{className:"flex items-center justify-center py-20",children:n.jsx(Ui,{image:n.jsx(Hi,{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:n.jsxs(ae,{size:"sm",onClick:m,disabled:a.isPending,children:[n.jsx(Qt,{size:14}),"New automation"]})})}):u.length===0?n.jsx("div",{className:"flex items-center justify-center py-20",children:n.jsx(Ui,{image:n.jsx(Hi,{size:48,className:"text-muted-foreground"}),title:"No automations found",description:`No automations match "${l}"`})}):n.jsx("div",{className:"mt-6 rounded-xl border border-border overflow-hidden",children:u.map(j=>n.jsx(X_,{automation:j,onClick:()=>f(j.id)},j.id))});let k;e[9]!==_.Body||e[10]!==y||e[11]!==C?(k=n.jsxs(_.Body,{children:[y,C]}),e[9]=_.Body,e[10]=y,e[11]=C,e[12]=k):k=e[12];let w;e[13]!==k||e[14]!==g.Content?(w=n.jsx(g.Content,{children:k}),e[13]=k,e[14]=g.Content,e[15]=w):w=e[15];let V;return e[16]!==p||e[17]!==w?(V=n.jsx(p,{children:w}),e[16]=p,e[17]=w,e[18]=V):V=e[18],V}function c5(t){const e=B.c(3),{virtualMcpId:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx("div",{className:"flex-1 flex items-center justify-center",children:n.jsx(Me,{size:20,className:"animate-spin text-muted-foreground"})}),e[0]=i):i=e[0];let r;return e[1]!==s?(r=n.jsx(S.Suspense,{fallback:i,children:n.jsx(l5,{virtualMcpId:s})}),e[1]=s,e[2]=r):r=e[2],r}const wh=S.lazy(()=>Op(()=>import("./project-app-view-B680Vk1Z.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])).then(t=>({default:t.AppViewContent})));function d5(t){const e=B.c(35),{taskId:s,virtualMcpId:i}=t;let r;e[0]!==s||e[1]!==i?(r={virtualMcpId:i,taskId:s},e[0]=s,e[1]=i,e[2]=r):r=e[2];const{activeTab:o,layoutTabs:a,automationTabParsed:l}=Zf(r);if(og(o)){let m;return e[3]!==i?(m=n.jsx(kd,{virtualMcpId:i}),e[3]=i,e[4]=m):m=e[4],m}if(o==="git"){let m;return e[5]!==i?(m=n.jsx(XV,{virtualMcpId:i}),e[5]=i,e[6]=m):m=e[6],m}if(o==="automations"){let m;return e[7]!==i?(m=n.jsx(c5,{virtualMcpId:i}),e[7]=i,e[8]=m):m=e[8],m}if(o==="env"){let m;return e[9]!==i?(m=n.jsx(Wj,{virtualMcpId:i}),e[9]=i,e[10]=m):m=e[10],m}if(o==="preview"){let m;return e[11]!==i?(m=n.jsx(jC,{virtualMcpId:i}),e[11]=i,e[12]=m):m=e[12],m}if(l){let m;return e[13]!==o||e[14]!==i?(m=n.jsx(r5,{tabId:o,virtualMcpId:i}),e[13]=o,e[14]=i,e[15]=m):m=e[15],m}let c;e[16]!==o?(c=ag(o),e[16]=o,e[17]=c):c=e[17];const d=c;if(d){let m;e[18]===Symbol.for("react.memo_cache_sentinel")?(m=n.jsx("div",{className:"h-full w-full flex items-center justify-center",children:n.jsx(Me,{size:20,className:"animate-spin text-muted-foreground"})}),e[18]=m):m=e[18];let p;return e[19]!==o||e[20]!==d.connectionId||e[21]!==d.toolName?(p=n.jsx(S.Suspense,{fallback:m,children:n.jsx(wh,{connectionId:d.connectionId,toolName:d.toolName},o)}),e[19]=o,e[20]=d.connectionId,e[21]=d.toolName,e[22]=p):p=e[22],p}let u;if(e[23]!==o||e[24]!==a){let m;e[26]!==o?(m=p=>p.id===o,e[26]=o,e[27]=m):m=e[27],u=a.find(m),e[23]=o,e[24]=a,e[25]=u}else u=e[25];const h=u;if(h){let m;e[28]===Symbol.for("react.memo_cache_sentinel")?(m=n.jsx("div",{className:"h-full w-full flex items-center justify-center",children:n.jsx(Me,{size:20,className:"animate-spin text-muted-foreground"})}),e[28]=m):m=e[28];let p;return e[29]!==o||e[30]!==h.id||e[31]!==h.view.appId?(p=n.jsx(S.Suspense,{fallback:m,children:n.jsx(wh,{connectionId:h.view.appId,toolName:h.id},o)}),e[29]=o,e[30]=h.id,e[31]=h.view.appId,e[32]=p):p=e[32],p}let f;return e[33]!==i?(f=n.jsx(kd,{virtualMcpId:i}),e[33]=i,e[34]=f):f=e[34],f}function h5(t){const e=B.c(7),{children:s,defaultSize:i}=t,[,r]=S.useTransition();let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=ml.decoChatPanelWidth(),e[0]=o):o=e[0];const[a,l]=fl(o,45),c=i>0&&i<100?a:i;let d;e[1]!==l?(d=f=>r(()=>{f>0&&f<100&&l(f)}),e[1]=l,e[2]=d):d=e[2];const u=d;let h;return e[3]!==s||e[4]!==c||e[5]!==u?(h=n.jsx(mu,{defaultSize:c,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]=c,e[5]=u,e[6]=h):h=e[6],h}function u5(t){const e=B.c(31),{virtualMcpId:s,taskId:i,chatOpen:r,mainOpen:o,variant:a,chatContent:l}=t;let c;e[0]!==r||e[1]!==o?(c=yd(r,o),e[0]=r,e[1]=o,e[2]=c):c=e[2];const d=c;let u;e[3]===Symbol.for("react.memo_cache_sentinel")?(u=ml.decoChatPanelWidth(),e[3]=u):u=e[3];const[h]=fl(u,45),f=S.useRef(null);let m,p;e[4]!==r||e[5]!==o||e[6]!==h?(m=()=>{const T=f.current;if(!T)return;const R=yd(r,o),N=R.chat>0&&R.chat<100?h:R.chat,A=R.chat>0&&R.chat<100?100-h:R.main;T.setLayout([N,A])},p=[r,o,h],e[4]=r,e[5]=o,e[6]=h,e[7]=m,e[8]=p):(m=e[7],p=e[8]),S.useEffect(m,p);const g=`${s}-${i}`;let _;e[9]===Symbol.for("react.memo_cache_sentinel")?(_={overflow:"visible"},e[9]=_):_=e[9];let v;e[10]!==l||e[11]!==a?(v=l??n.jsx(of,{variant:a}),e[10]=l,e[11]=a,e[12]=v):v=e[12];let x;e[13]!==v?(x=n.jsx("div",{className:"h-full p-0.5 pt-0.25",children:n.jsx("div",{className:"h-full bg-background rounded-[0.75rem] overflow-hidden card-shadow",children:v})}),e[13]=v,e[14]=x):x=e[14];let b;e[15]!==d.chat||e[16]!==x?(b=n.jsx(h5,{defaultSize:d.chat,children:x}),e[15]=d.chat,e[16]=x,e[17]=b):b=e[17];let y;e[18]===Symbol.for("react.memo_cache_sentinel")?(y=n.jsx(r_,{className:"bg-sidebar"}),e[18]=y):y=e[18];const C=d.main;let k;e[19]===Symbol.for("react.memo_cache_sentinel")?(k={overflow:"visible"},e[19]=k):k=e[19];let w;e[20]===Symbol.for("react.memo_cache_sentinel")?(w=J("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[20]=w):w=e[20];let V;e[21]!==i||e[22]!==s?(V=n.jsx("div",{className:"h-full p-0.5 pt-0.25",children:n.jsx("div",{className:w,children:n.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:n.jsx(d5,{taskId:i,virtualMcpId:s})})})}),e[21]=i,e[22]=s,e[23]=V):V=e[23];let j;e[24]!==d.main||e[25]!==V?(j=n.jsx(mu,{className:"min-w-0 flex flex-col",order:2,defaultSize:C,style:k,collapsible:!0,collapsedSize:0,minSize:20,children:V}),e[24]=d.main,e[25]=V,e[26]=j):j=e[26];let I;return e[27]!==j||e[28]!==g||e[29]!==b?(I=n.jsxs(o_,{ref:f,direction:"horizontal",className:"flex-1 min-h-0 pb-1 pr-1 pl-0 pt-0",style:_,children:[b,y,j]},g),e[27]=j,e[28]=g,e[29]=b,e[30]=I):I=e[30],I}const la="flex size-7 shrink-0 items-center justify-center rounded-md transition-colors",Vh="bg-sidebar-accent text-sidebar-foreground",ca="text-sidebar-foreground/60 hover:bg-sidebar-accent hover:text-sidebar-foreground";function f5(t){const e=B.c(38),{isDecopilot:s,chatOpen:i,toggleChat:r,onNewTask:o}=t,{tasksOpen:a,toggleTasks:l}=Jf(),c=!!o;let d;e[0]!==a||e[1]!==l?(d=()=>{ne("agent_toolbar_toggled",{button:"tasks",next_state:a?"closed":"open"}),l()},e[0]=a,e[1]=l,e[2]=d):d=e[2];const u=a?Vh:ca;let h;e[3]!==u?(h=J(la,u),e[3]=u,e[4]=h):h=e[4];let f;e[5]===Symbol.for("react.memo_cache_sentinel")?(f=n.jsx(zg,{size:16}),e[5]=f):f=e[5];let m;e[6]!==d||e[7]!==h||e[8]!==a?(m=n.jsx(st,{asChild:!0,children:n.jsx("button",{type:"button",onClick:d,"aria-pressed":a,className:h,children:f})}),e[6]=d,e[7]=h,e[8]=a,e[9]=m):m=e[9];let p;e[10]===Symbol.for("react.memo_cache_sentinel")?(p=n.jsx(it,{side:"bottom",children:"Tasks"}),e[10]=p):p=e[10];let g;e[11]!==m?(g=n.jsxs(nt,{delayDuration:300,children:[m,p]}),e[11]=m,e[12]=g):g=e[12];let _;e[13]!==i||e[14]!==s||e[15]!==r?(_=!s&&n.jsxs(nt,{delayDuration:300,children:[n.jsx(st,{asChild:!0,children:n.jsx("button",{type:"button",onClick:()=>{ne("agent_toolbar_toggled",{button:"chat",next_state:i?"closed":"open"}),r()},"aria-pressed":i,className:J(la,i?Vh:ca),children:n.jsx($g,{size:16})})}),n.jsx(it,{side:"bottom",children:"Chat"})]}),e[13]=i,e[14]=s,e[15]=r,e[16]=_):_=e[16];const v=c?"grid-cols-[1fr]":"grid-cols-[0fr]";let x;e[17]!==v?(x=J("grid transition-[grid-template-columns] duration-200 ease-[var(--ease-out-quart)]",v),e[17]=v,e[18]=x):x=e[18];const b=!c,y=c?0:-1,C=!c,k=c?"translate-x-0 opacity-100":"-translate-x-2 opacity-0";let w;e[19]!==k?(w=J(la,ca,"transition-[transform,opacity] duration-200 ease-[var(--ease-out-quart)] will-change-transform",k),e[19]=k,e[20]=w):w=e[20];let V;e[21]===Symbol.for("react.memo_cache_sentinel")?(V=n.jsx(Sl,{size:16}),e[21]=V):V=e[21];let j;e[22]!==o||e[23]!==b||e[24]!==y||e[25]!==C||e[26]!==w?(j=n.jsx(st,{asChild:!0,children:n.jsx("button",{type:"button",onClick:o,disabled:b,tabIndex:y,"aria-hidden":C,className:w,children:V})}),e[22]=o,e[23]=b,e[24]=y,e[25]=C,e[26]=w,e[27]=j):j=e[27];let I;e[28]===Symbol.for("react.memo_cache_sentinel")?(I=n.jsx(it,{side:"bottom",children:"New task"}),e[28]=I):I=e[28];let T;e[29]!==j?(T=n.jsx("div",{className:"overflow-hidden",children:n.jsxs(nt,{delayDuration:300,children:[j,I]})}),e[29]=j,e[30]=T):T=e[30];let R;e[31]!==x||e[32]!==T?(R=n.jsx("div",{className:x,children:T}),e[31]=x,e[32]=T,e[33]=R):R=e[33];let N;return e[34]!==R||e[35]!==g||e[36]!==_?(N=n.jsxs(n.Fragment,{children:[g,_,R]}),e[34]=R,e[35]=g,e[36]=_,e[37]=N):N=e[37],N}function m5(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(h=>h.id===e))return{visible:i,overflow:r};const a=r.findIndex(h=>h.id===e);if(a===-1)return{visible:i,overflow:r};const l=i[i.length-1],c=r[a],d=[...i.slice(0,-1),c],u=[l,...r.slice(0,a),...r.slice(a+1)];return{visible:d,overflow:u}}function p5(t){const e=B.c(13),{title:s,icon:i,active:r,onClick:o}=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=J("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 c;e[2]!==i?(c=n.jsx("span",{className:"flex size-5 items-center justify-center shrink-0",children:n.jsx(g5,{icon:i})}),e[2]=i,e[3]=c):c=e[3];let d;e[4]!==s?(d=n.jsx("span",{className:"whitespace-nowrap text-sm font-medium leading-none",children:s}),e[4]=s,e[5]=d):d=e[5];let u;return e[6]!==r||e[7]!==o||e[8]!==l||e[9]!==c||e[10]!==d||e[11]!==s?(u=n.jsxs("button",{type:"button",onClick:o,"aria-pressed":r,"aria-label":s,className:l,children:[c,d]}),e[6]=r,e[7]=o,e[8]=l,e[9]=c,e[10]=d,e[11]=s,e[12]=u):u=e[12],u}function g5(t){const e=B.c(5),{icon:s}=t;if(s.kind==="component"){const{Component:r}=s;let o;return e[0]!==r?(o=n.jsx(r,{className:"size-4"}),e[0]=r,e[1]=o):o=e[1],o}if(s.kind==="url"){let r;return e[2]!==s.src?(r=n.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=n.jsx(ru,{className:"size-4"}),e[4]=i):i=e[4],i}function _5(t){const e=B.c(13),{overflow:s,onSelect:i}=t,[r,o]=S.useState(!1);let a;e[0]!==i?(a=f=>{o(!1),i(f)},e[0]=i,e[1]=a):a=e[1];const l=a;let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx(li,{asChild:!0,children:n.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:n.jsx(su,{className:"size-4"})})}),e[2]=c):c=e[2];let d;if(e[3]!==l||e[4]!==s){let f;e[6]!==l?(f=m=>n.jsx("li",{children:n.jsxs("button",{type:"button",onClick:()=>l(m.id),className:"w-full flex items-center gap-2 px-3 py-2 rounded-md hover:bg-accent text-sm text-foreground",children:[n.jsx("span",{className:"flex size-5 items-center justify-center shrink-0",children:n.jsx(x5,{icon:m.icon})}),n.jsx("span",{className:"truncate",children:m.title})]})},m.id),e[6]=l,e[7]=f):f=e[7],d=s.map(f),e[3]=l,e[4]=s,e[5]=d}else d=e[5];let u;e[8]!==d?(u=n.jsx(ci,{align:"end",className:"w-56 p-1",children:n.jsx("ul",{className:"flex flex-col",children:d})}),e[8]=d,e[9]=u):u=e[9];let h;return e[10]!==r||e[11]!==u?(h=n.jsxs(di,{open:r,onOpenChange:o,children:[c,u]}),e[10]=r,e[11]=u,e[12]=h):h=e[12],h}function x5(t){const e=B.c(5),{icon:s}=t;if(s.kind==="component"){const{Component:r}=s;let o;return e[0]!==r?(o=n.jsx(r,{className:"size-4"}),e[0]=r,e[1]=o):o=e[1],o}if(s.kind==="url"){let r;return e[2]!==s.src?(r=n.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=n.jsx(ru,{className:"size-4"}),e[4]=i):i=e[4],i}const v5=6;function b5(t){const e=B.c(20),{virtualMcpId:s,taskId:i}=t,r=Ge();let o;e[0]!==i||e[1]!==s?(o={virtualMcpId:s,taskId:i},e[0]=i,e[1]=s,e[2]=o):o=e[2];const{tabs:a,activeTab:l,mainOpen:c,setActiveTab:d}=Zf(o);let u,h,f,m;if(e[3]!==l||e[4]!==c||e[5]!==r||e[6]!==d||e[7]!==a||e[8]!==s){const _=lg({activeTab:l,mainOpen:c}),v=k=>k.id==="automations"?_:c&&k.id===l,b=a.find(k=>v(k))?.id??null,{visible:y,overflow:C}=m5(a,b,v5);h=C,u=k=>{const w=a.find(j=>j.id===k),V=b===k&&c;if(ne("main_panel_tab_clicked",{virtual_mcp_id:s,tab_id:k,tab_kind:w?.kind??null,was_active:V}),k==="automations"){const j=cg({activeTab:l,mainOpen:c});r({to:".",search:I=>({...I,main:j}),replace:!0});return}d(k)},f="flex items-center min-w-0 ml-auto gap-0.5",m=y.map(k=>n.jsx(p5,{title:k.title,icon:k.icon,active:v(k),onClick:()=>u(k.id)},k.id)),e[3]=l,e[4]=c,e[5]=r,e[6]=d,e[7]=a,e[8]=s,e[9]=u,e[10]=h,e[11]=f,e[12]=m}else u=e[9],h=e[10],f=e[11],m=e[12];let p;e[13]!==u||e[14]!==h?(p=h.length>0&&n.jsx(_5,{overflow:h,onSelect:u}),e[13]=u,e[14]=h,e[15]=p):p=e[15];let g;return e[16]!==f||e[17]!==m||e[18]!==p?(g=n.jsxs("div",{className:f,children:[m,p]}),e[16]=f,e[17]=m,e[18]=p,e[19]=g):g=e[19],g}function y5(t){const e=B.c(12);let s,i,r,o;e[0]!==t?({className:s,orientation:r,decorative:o,...i}=t,e[0]=t,e[1]=s,e[2]=i,e[3]=r,e[4]=o):(s=e[1],i=e[2],r=e[3],o=e[4]);const a=r===void 0?"horizontal":r,l=o===void 0?!0:o;let c;e[5]!==s?(c=J("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]=c):c=e[6];let d;return e[7]!==l||e[8]!==a||e[9]!==i||e[10]!==c?(d=n.jsx(Bp,{"data-slot":"separator-root",decorative:l,orientation:a,className:c,...i}),e[7]=l,e[8]=a,e[9]=i,e[10]=c,e[11]=d):d=e[11],d}function S5(t){const e=B.c(20),{prNumber:s,disabled:i,send:r}=t;let o;e[0]!==s||e[1]!==r?(o=()=>r(BV({prNumber:s})),e[0]=s,e[1]=r,e[2]=o):o=e[2];const a=o;let l;e[3]!==s||e[4]!==r?(l=()=>r(OV({prNumber:s})),e[3]=s,e[4]=r,e[5]=l):l=e[5];const c=l;let d;e[6]!==i||e[7]!==a?(d=n.jsx(ae,{size:"sm",className:"rounded-r-none border-r border-primary-foreground/20",disabled:i,onClick:a,children:"Publish"}),e[6]=i,e[7]=a,e[8]=d):d=e[8];let u;e[9]===Symbol.for("react.memo_cache_sentinel")?(u=n.jsx(Rn,{className:"h-3.5 w-3.5"}),e[9]=u):u=e[9];let h;e[10]!==i?(h=n.jsx(Is,{asChild:!0,children:n.jsx(ae,{size:"sm",className:"rounded-l-none px-2",disabled:i,"aria-label":"More actions",children:u})}),e[10]=i,e[11]=h):h=e[11];let f;e[12]!==c?(f=n.jsx(Rs,{align:"end",children:n.jsx(at,{onClick:c,children:"Review"})}),e[12]=c,e[13]=f):f=e[13];let m;e[14]!==h||e[15]!==f?(m=n.jsxs(Es,{children:[h,f]}),e[14]=h,e[15]=f,e[16]=m):m=e[16];let p;return e[17]!==d||e[18]!==m?(p=n.jsxs("div",{className:"inline-flex items-stretch rounded-md",children:[d,m]}),e[17]=d,e[18]=m,e[19]=p):p=e[19],p}const w5=new Set(["failure","timed_out","cancelled","action_required"]);function V5(t){return t.status==="completed"&&w5.has(t.conclusion)}function C5(t){return t.status==="queued"||t.status==="in_progress"}function k5(t){const{branchStatus:e,pr:s,checks:i,reviews:r}=t;if(!e)return null;if(e.workingTreeDirty||e.unpushed>0)return{label:"Save changes",action:"commit-and-push"};if(s?.merged)return!!e.headSha&&!!s.headSha&&e.headSha!==s.headSha?{label:"Submit for review",action:"create-pr"}:null;if(e.aheadOfBase>0){if(s&&s.state==="closed"&&!s.merged)return{label:"Reopen",action:"reopen"};if(!s)return{label:"Submit for review",action:"create-pr"};if((r?.mergeableState??"unknown")==="dirty")return{label:`Sync with ${s.base}`,action:"rebase"};const l=i.filter(V5).map(c=>c.name);return l.length>0?{label:"Fix tests",action:"fix-checks",meta:{failingChecks:l}}:i.some(C5)?{label:"Running tests…",disabled:!0}:r?.draft?{label:"Mark ready",action:"mark-ready"}:(r?.unresolvedConversations??0)>0?{label:"Address feedback",action:"resolve-comments"}:r?.missingRequiredApprovals?{label:"Awaiting review",disabled:!0}:{label:"Publish",action:"merge-split"}}return null}function j5(){return Zi().branchStatus}const N5=6e4,A5=3e4;function E5(t){const e=B.c(11);let s;e[0]!==t.connectionId||e[1]!==t.orgId?(s={connectionId:t.connectionId,orgId:t.orgId},e[0]=t.connectionId,e[1]=t.orgId,e[2]=s):s=e[2];const i=Be(s),r=t.prNumber??0;let o;e[3]!==t.owner||e[4]!==t.repo||e[5]!==r?(o={method:"get",owner:t.owner,repo:t.repo,pullNumber:r},e[3]=t.owner,e[4]=t.repo,e[5]=r,e[6]=o):o=e[6];const a=!!t.prNumber;let l;return e[7]!==i||e[8]!==o||e[9]!==a?(l={client:i,toolName:"pull_request_read",toolArguments:o,enabled:a,refetchInterval:N5,refetchIntervalInBackground:!1,staleTime:A5,select:I5},e[7]=i,e[8]=o,e[9]=a,e[10]=l):l=e[10],ki(l)}function I5(t){const e=nr(t);if(!e)return null;const s=e.mergeable_state??"unknown",i=!!(e.draft??!1),r=Number(e.review_comments??0),o=s==="blocked"&&r>0?r:0;return{draft:i,mergeableState:s,unresolvedConversations:o,missingRequiredApprovals:s==="blocked"&&o===0}}function R5(t){const e=B.c(38),{virtualMcpId:s}=t,{org:i}=xe(),r=is(s),{currentBranch:o}=es(),a=no(),l=r?.metadata?.githubRepo??null,c=j5(),d=l?.connectionId??"",u=l?.owner??"",h=l?.name??"",f=o??null;let m;e[0]!==i.id||e[1]!==d||e[2]!==u||e[3]!==h||e[4]!==f?(m={orgId:i.id,connectionId:d,owner:u,repo:h,branch:f},e[0]=i.id,e[1]=d,e[2]=u,e[3]=h,e[4]=f,e[5]=m):m=e[5];const g=tm(m).data??null,_=l?.connectionId??"",v=l?.owner??"",x=l?.name??"",b=g&&g.state==="open"?g.number:null;let y;e[6]!==i.id||e[7]!==_||e[8]!==v||e[9]!==x||e[10]!==b?(y={orgId:i.id,connectionId:_,owner:v,repo:x,prNumber:b},e[6]=i.id,e[7]=_,e[8]=v,e[9]=x,e[10]=b,e[11]=y):y=e[11];const C=im(y),k=l?.connectionId??"",w=l?.owner??"",V=l?.name??"",j=g&&g.state==="open"?g.number:null;let I;e[12]!==i.id||e[13]!==k||e[14]!==w||e[15]!==V||e[16]!==j?(I={orgId:i.id,connectionId:k,owner:w,repo:V,prNumber:j},e[12]=i.id,e[13]=k,e[14]=w,e[15]=V,e[16]=j,e[17]=I):I=e[17];const T=E5(I);if(!l?.connectionId||!o)return null;let R;e[18]!==c||e[19]!==C.data||e[20]!==g||e[21]!==T.data?(R=k5({branchStatus:c,pr:g,checks:C.data??[],reviews:T.data??null}),e[18]=c,e[19]=C.data,e[20]=g,e[21]=T.data,e[22]=R):R=e[22];const N=R;if(!N)return null;let A;e[23]!==a?(A=$=>a.sendMessage({parts:[{type:"text",text:$}]}),e[23]=a,e[24]=A):A=e[24];const E=A,M=a.isStreaming;let L;e[25]!==o||e[26]!==N||e[27]!==M||e[28]!==g||e[29]!==E?(L=$=>{if(!M)switch($){case"commit-and-push":{E(EV({branch:o}));return}case"create-pr":{E(IV({branch:o}));return}case"reopen":{g&&E(RV({prNumber:g.number}));return}case"rebase":{E(TV({branch:o}));return}case"fix-checks":{g&&E(MV({prNumber:g.number,failingChecks:N.meta?.failingChecks??[]}));return}case"mark-ready":{g&&E(PV({prNumber:g.number}));return}case"resolve-comments":{g&&E(LV({prNumber:g.number}));return}case"merge-split":return}},e[25]=o,e[26]=N,e[27]=M,e[28]=g,e[29]=E,e[30]=L):L=e[30];const D=L;let P;e[31]===Symbol.for("react.memo_cache_sentinel")?(P=n.jsx(y5,{orientation:"vertical",className:"mx-2 data-[orientation=vertical]:h-5"}),e[31]=P):P=e[31];const O=g?.number;let z;return e[32]!==N||e[33]!==M||e[34]!==D||e[35]!==E||e[36]!==O?(z=n.jsxs(n.Fragment,{children:[P,n.jsx(T5,{button:N,isStreaming:M,onActivate:D,prNumber:O,send:E})]}),e[32]=N,e[33]=M,e[34]=D,e[35]=E,e[36]=O,e[37]=z):z=e[37],z}function T5(t){const e=B.c(18),{button:s,isStreaming:i}=t,r=!!s.disabled||i,o=i?"Chat is running":null;if(s.action==="merge-split"&&t.prNumber!=null){let u;e[0]!==r||e[1]!==t.prNumber||e[2]!==t.send?(u=n.jsx(S5,{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 h;return e[4]!==u||e[5]!==o?(h=n.jsx(Ch,{label:o,children:u}),e[4]=u,e[5]=o,e[6]=h):h=e[6],h}const a=s.disabled?"outline":"default";let l;e[7]!==s.action||e[8]!==t?(l=()=>t.onActivate(s.action),e[7]=s.action,e[8]=t,e[9]=l):l=e[9];let c;e[10]!==s.label||e[11]!==r||e[12]!==a||e[13]!==l?(c=n.jsx(ae,{size:"sm",variant:a,disabled:r,onClick:l,children:s.label}),e[10]=s.label,e[11]=r,e[12]=a,e[13]=l,e[14]=c):c=e[14];let d;return e[15]!==c||e[16]!==o?(d=n.jsx(Ch,{label:o,children:c}),e[15]=c,e[16]=o,e[17]=d):d=e[17],d}function Ch(t){const e=B.c(9),{label:s,children:i}=t;if(!s){let l;return e[0]!==i?(l=n.jsx(n.Fragment,{children:i}),e[0]=i,e[1]=l):l=e[1],l}let r;e[2]!==i?(r=n.jsx(st,{asChild:!0,children:n.jsx("span",{children:i})}),e[2]=i,e[3]=r):r=e[3];let o;e[4]!==s?(o=n.jsx(it,{children:s}),e[4]=s,e[5]=o):o=e[5];let a;return e[6]!==r||e[7]!==o?(a=n.jsx(Bi,{children:n.jsxs(nt,{children:[r,o]})}),e[6]=r,e[7]=o,e[8]=a):a=e[8],a}function D5(t){const e=B.c(2),{virtualMcp:s}=t;if(!!!(s.metadata?.githubRepo??null)?.connectionId)return null;let o;return e[0]!==s.id?(o=n.jsx(He.Right,{children:n.jsx(R5,{virtualMcpId:s.id})}),e[0]=s.id,e[1]=o):o=e[1],o}const Mi=S.createContext(null);function fc(){return S.use(Mi)}function kh(t){const e=B.c(8),{children:s,variant:i}=t,{taskId:r}=es();let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=n.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]=o):o=e[0];let a;e[1]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx($e.Skeleton,{}),e[1]=a):a=e[1];let l;e[2]!==s||e[3]!==i?(l=s??n.jsx(of,{variant:i}),e[2]=s,e[3]=i,e[4]=l):l=e[4];let c;return e[5]!==l||e[6]!==r?(c=n.jsx(As,{fallback:o,children:n.jsx(S.Suspense,{fallback:a,children:n.jsx($e.ActiveTaskProvider,{taskId:r,children:l})})}),e[5]=l,e[6]=r,e[7]=c):c=e[7],c}function jh(t){const e=B.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],S.useLayoutEffect(r),null}function M5(t){const e=B.c(3),{onOpenSidebar:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx(Hg,{size:20}),e[0]=i):i=e[0];let r;return e[1]!==s?(r=n.jsx("div",{className:"shrink-0 flex items-center justify-between px-3 h-12 bg-background border-b border-border",children:n.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 Nh(t){const e=B.c(16),{virtualMcpId:s,hasActiveGithubRepo:i,vmMap:r,children:o}=t,{org:a}=xe(),{currentBranch:l}=es(),{data:c}=St.useSession(),d=c?.user?.id,u=d&&l?r?.[d]?.[l]??null:null;let h;e[0]!==u?(h=u?.previewUrl?u.previewUrl.replace(/\/$/,""):null,e[0]=u,e[1]=h):h=e[1];const f=h;let m;e[2]!==a.id?(m={connectionId:Pt,orgId:a.id},e[2]=a.id,e[3]=m):m=e[3];const p=Be(m),{mutate:g}=Zl(p);let _;e[4]===Symbol.for("react.memo_cache_sentinel")?(_=new Set,e[4]=_):_=e[4];const v=S.useRef(_);let x,b;e[5]!==l||e[6]!==i||e[7]!==g||e[8]!==d||e[9]!==s||e[10]!==r?(x=()=>{i&&d&&l&&(r?.[d]?.[l]||v.current.has(l)||(v.current.add(l),g({virtualMcpId:s,branch:l},{onError:P5})))},b=[i,d,l,r,s,g],e[5]=l,e[6]=i,e[7]=g,e[8]=d,e[9]=s,e[10]=r,e[11]=x,e[12]=b):(x=e[11],b=e[12]),S.useEffect(x,b);let y;return e[13]!==o||e[14]!==f?(y=n.jsx(hC,{daemonBaseUrl:f,children:o}),e[13]=o,e[14]=f,e[15]=y):y=e[15],y}function P5(t){console.error("[auto-start-vm] failed:",t)}function Ah(){const t=B.c(106),e=Ps(),s=Ge(),{org:i}=xe(),r=uw()?.tasksOpen??!1;z_(i.id);let o;t[0]===Symbol.for("react.memo_cache_sentinel")?(o={strict:!1},t[0]=o):o=t[0];const a=Hn(o),l=a.org??"";let c;t[1]===Symbol.for("react.memo_cache_sentinel")?(c={strict:!1},t[1]=c):c=t[1];const d=Si(c);let u;t[2]!==i.id||t[3]!==d.virtualmcpid?(u=d.virtualmcpid??co(i.id).id,t[2]=i.id,t[3]=d.virtualmcpid,t[4]=u):u=t[4];const h=u;let f;t[5]!==i.id?(f=xl(i.id),t[5]=i.id,t[6]=f):f=t[6];const m=h===f,p=!m,g=tx(a.taskId??"",h),_=is(h),v=_?.metadata?.ui?.layout??null;let x;t[7]!==v?(x=v?{defaultMainView:v.defaultMainView??null,chatDefaultOpen:v.chatDefaultOpen??null}:null,t[7]=v,t[8]=x):x=t[8];const b=x;let y;t[9]!==_?(y=_&&Fs(_),t[9]=_,t[10]=y):y=t[10];const C=!!y;let k;t[11]!==p||t[12]!==l||t[13]!==h?(k={virtualMcpId:h,orgSlug:l,isAgentRoute:p},t[11]=p,t[12]=l,t[13]=h,t[14]=k):k=t[14];const w=cw(b,k),{setOpenMobile:V,openMobile:j}=Qn(),I=V,T=S.useRef(null);let R,N;t[15]===Symbol.for("react.memo_cache_sentinel")?(R=()=>{const W=K=>{Wh(K)&&K.shiftKey&&K.code==="KeyS"&&!K.repeat&&(K.preventDefault(),T.current?.())};return document.addEventListener("keydown",W),()=>document.removeEventListener("keydown",W)},N=[],t[15]=R,t[16]=N):(R=t[15],N=t[16]),S.useEffect(R,N);const A=h;let E;t[17]!==_||t[18]!==h?(E={virtualMcpId:h,entity:_},t[17]=_,t[18]=h,t[19]=E):E=t[19];const M=E;if(g.status==="creating"||g.status==="loading"){let W;t[20]===Symbol.for("react.memo_cache_sentinel")?(W=n.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:n.jsxs("div",{className:"flex h-full items-center justify-center bg-background card-shadow rounded-[0.75rem] text-sm text-muted-foreground",children:[n.jsx(Me,{className:"size-4 animate-spin mr-2"}),"Creating task…"]})}),t[20]=W):W=t[20];let K;return t[21]!==M?(K=n.jsx(Mi,{value:M,children:W}),t[21]=M,t[22]=K):K=t[22],K}if(g.status==="error"){let W;t[23]===Symbol.for("react.memo_cache_sentinel")?(W=n.jsx("div",{className:"font-medium",children:"Task unavailable"}),t[23]=W):W=t[23];let K;t[24]!==g.error.message?(K=n.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:n.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:[W,n.jsx("div",{className:"text-muted-foreground",children:g.error.message})]})}),t[24]=g.error.message,t[25]=K):K=t[25];let ee;return t[26]!==M||t[27]!==K?(ee=n.jsx(Mi,{value:M,children:K}),t[26]=M,t[27]=K,t[28]=ee):ee=t[28],ee}if(!_){let W;t[29]===Symbol.for("react.memo_cache_sentinel")?(W=n.jsx(oi,{size:48,className:"text-muted-foreground"}),t[29]=W):W=t[29];const K=`The agent "${h}" does not exist in this organization.`;let ee;t[30]!==s||t[31]!==l?(ee=n.jsx(ae,{variant:"outline",onClick:()=>s({to:"/$org",params:{org:l}}),children:"Go to organization home"}),t[30]=s,t[31]=l,t[32]=ee):ee=t[32];let Z;t[33]!==K||t[34]!==ee?(Z=n.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:n.jsx("div",{className:"flex flex-col h-full bg-background overflow-hidden card-shadow rounded-[0.75rem]",children:n.jsx(Ui,{image:W,title:"Agent not found",description:K,actions:ee})})}),t[33]=K,t[34]=ee,t[35]=Z):Z=t[35];let X;return t[36]!==M||t[37]!==Z?(X=n.jsx(Mi,{value:M,children:Z}),t[36]=M,t[37]=Z,t[38]=X):X=t[38],X}if(e){let W;t[39]===Symbol.for("react.memo_cache_sentinel")?(W=n.jsx(M_,{className:"sr-only",children:"Navigation"}),t[39]=W):W=t[39];let K;t[40]!==I?(K=n.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:n.jsx(sw,{onClose:()=>I(!1)})}),t[40]=I,t[41]=K):K=t[41];let ee;t[42]===Symbol.for("react.memo_cache_sentinel")?(ee=n.jsx("div",{className:"flex-1 min-w-0 overflow-hidden",children:n.jsx(cf,{})}),t[42]=ee):ee=t[42];let Z;t[43]!==K?(Z=n.jsxs(P_,{side:"left",hideCloseButton:!0,className:"w-[calc(100vw-3rem)] sm:max-w-md! p-0",children:[W,n.jsxs("div",{className:"flex h-full",children:[K,ee]})]}),t[43]=K,t[44]=Z):Z=t[44];let X;t[45]!==j||t[46]!==I||t[47]!==Z?(X=n.jsx(L_,{open:j,onOpenChange:I,children:Z}),t[45]=j,t[46]=I,t[47]=Z,t[48]=X):X=t[48];const ie=X,re=_?.metadata?.vmMap;let de;t[49]!==w.createNewTask?(de=n.jsx(jh,{onNewTaskRef:T,createNewTask:w.createNewTask}),t[49]=w.createNewTask,t[50]=de):de=t[50];let me;t[51]!==I?(me=n.jsx(M5,{onOpenSidebar:()=>I(!0)}),t[51]=I,t[52]=me):me=t[52];const le=m?"home":void 0;let se;t[53]!==le?(se=n.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:n.jsx(kh,{variant:le})}),t[53]=le,t[54]=se):se=t[54];let _e;t[55]!==C||t[56]!==ie||t[57]!==re||t[58]!==de||t[59]!==me||t[60]!==se||t[61]!==h?(_e=n.jsxs(Nh,{virtualMcpId:h,hasActiveGithubRepo:C,vmMap:re,children:[de,me,se,ie]}),t[55]=C,t[56]=ie,t[57]=re,t[58]=de,t[59]=me,t[60]=se,t[61]=h,t[62]=_e):_e=t[62];let ge;t[63]!==A||t[64]!==_e?(ge=n.jsx("div",{className:"flex flex-col flex-1 bg-background min-h-0",children:n.jsx($e.Provider,{virtualMcpId:A,children:_e},A)}),t[63]=A,t[64]=_e,t[65]=ge):ge=t[65];let Se;return t[66]!==M||t[67]!==ge?(Se=n.jsx(Mi,{value:M,children:ge}),t[66]=M,t[67]=ge,t[68]=Se):Se=t[68],Se}const L=r?void 0:w.createNewTask;let D;t[69]!==m||t[70]!==w.chatOpen||t[71]!==w.toggleChat||t[72]!==L?(D=n.jsx(He.Toggles,{children:n.jsx(f5,{isDecopilot:m,chatOpen:w.chatOpen,toggleChat:w.toggleChat,onNewTask:L})}),t[69]=m,t[70]=w.chatOpen,t[71]=w.toggleChat,t[72]=L,t[73]=D):D=t[73];let P;t[74]!==m||t[75]!==w.taskId||t[76]!==h?(P=!m&&n.jsx(He.Tabs,{children:n.jsx(b5,{virtualMcpId:h,taskId:w.taskId})}),t[74]=m,t[75]=w.taskId,t[76]=h,t[77]=P):P=t[77];const O=_?.metadata?.vmMap;let z;t[78]!==_||t[79]!==m?(z=!m&&n.jsx(D5,{virtualMcp:_}),t[78]=_,t[79]=m,t[80]=z):z=t[80];let $;t[81]!==w.createNewTask?($=n.jsx(jh,{onNewTaskRef:T,createNewTask:w.createNewTask}),t[81]=w.createNewTask,t[82]=$):$=t[82];const q=m?"home":void 0;let F;t[83]!==q?(F=n.jsx(kh,{variant:q}),t[83]=q,t[84]=F):F=t[84];let G;t[85]!==w.chatOpen||t[86]!==w.mainOpen||t[87]!==w.taskId||t[88]!==F||t[89]!==h?(G=n.jsx(u5,{virtualMcpId:h,taskId:w.taskId,chatOpen:w.chatOpen,mainOpen:w.mainOpen,chatContent:F}),t[85]=w.chatOpen,t[86]=w.mainOpen,t[87]=w.taskId,t[88]=F,t[89]=h,t[90]=G):G=t[90];let H;t[91]!==C||t[92]!==O||t[93]!==z||t[94]!==$||t[95]!==G||t[96]!==h?(H=n.jsxs(Nh,{virtualMcpId:h,hasActiveGithubRepo:C,vmMap:O,children:[z,$,G]}),t[91]=C,t[92]=O,t[93]=z,t[94]=$,t[95]=G,t[96]=h,t[97]=H):H=t[97];let U;t[98]!==A||t[99]!==P||t[100]!==H?(U=n.jsxs($e.Provider,{virtualMcpId:A,children:[P,H]},A),t[98]=A,t[99]=P,t[100]=H,t[101]=U):U=t[101];let Y;return t[102]!==M||t[103]!==D||t[104]!==U?(Y=n.jsxs(Mi,{value:M,children:[D,U]}),t[102]=M,t[103]=D,t[104]=U,t[105]=Y):Y=t[105],Y}function EN(){const t=B.c(5),e=Ps();let s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s={"--sidebar-width-icon":"3.5rem"},t[0]=s):s=t[0];let i;t[1]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx(tw,{}),t[1]=i):i=t[1];let r;t[2]===Symbol.for("react.memo_cache_sentinel")?(r={background:"transparent",containerType:"inline-size"},t[2]=r):r=t[2];let o;return t[3]!==e?(o=n.jsx(R_,{defaultOpen:!1,children:n.jsx("div",{className:"flex flex-col h-dvh overflow-hidden",children:n.jsxs(T_,{className:"flex-1 bg-sidebar",style:s,children:[i,n.jsx(D_,{className:"flex flex-col",style:r,children:e?n.jsx(S.Suspense,{fallback:n.jsx("div",{className:"flex-1 flex items-center justify-center",children:n.jsx(Me,{size:20,className:"animate-spin text-muted-foreground"})}),children:n.jsx(Ah,{})}):n.jsx(S.Suspense,{fallback:n.jsx("div",{className:"flex-1 flex items-center justify-center",children:n.jsx(Me,{size:20,className:"animate-spin text-muted-foreground"})}),children:n.jsx(dw,{children:n.jsxs(He,{children:[n.jsxs(He.Header,{children:[n.jsxs(He.LeftColumn,{children:[n.jsx(He.Nav,{}),n.jsx(He.TogglesSlot,{})]}),n.jsx(He.CenterSlot,{}),n.jsxs(He.RightColumn,{children:[n.jsx(He.TabsSlot,{}),n.jsx(He.RightSlot,{})]})]}),n.jsxs("div",{className:"flex-1 min-h-0 flex flex-row",children:[n.jsx(Aw,{}),n.jsx("div",{className:"flex-1 min-w-0 flex flex-col",children:n.jsx(S.Suspense,{fallback:n.jsx("div",{className:"flex-1 flex items-center justify-center",children:n.jsx(Me,{size:20,className:"animate-spin text-muted-foreground"})}),children:n.jsx(Ah,{})})})]})]})})})})]})})}),t[3]=e,t[4]=o):o=t[4],o}export{EN as default,fc as useInsetContext};
|