import{c as P,e as A,j as l,E as y,r as R,u as T}from"./index-oE_2MbI2.js";import{u as v}from"./use-connection-7qXdMybp.js";import{u as S}from"./constants-uA8MqaDa.js";import{u as U}from"./use-mcp-tools-BBd1wh9l.js";import{c as E,M as H}from"./mcp-app-renderer-B-WbfS4U.js";import{g as O,M as $}from"./types-CZfjx8QG.js";import{u as w}from"./context-3GupwOmI.js";import{P as _,u as D}from"./index-nULh3Jbz.js";import"./use-collections-BV71cmYk.js";import"./useMutation-DdGCKlze.js";import"./useQuery-B63y3s7J.js";import"./decopilot-events-DV5WFiTr.js";import"./use-virtual-mcp-DTCdJgfP.js";import"./use-llm-B7UO9DI8.js";import"./use-binding-CD2rnHew.js";import"./binder-GLGY8d7n.js";import"./localstorage-keys-CKFbpBwk.js";import"./use-preferences-wIlCfDgU.js";import"./checkbox-DqLJvt0U.js";import"./Check-_ISbUca5.js";import"./input-BC5yyfKN.js";import"./dialog-Dd4Env_T.js";import"./X-yceQDp_o.js";import"./select-CxPd29YM.js";import"./index-C61JJs1z.js";import"./ChevronDown-CJ2cKOCp.js";import"./skeleton-C27NGY_0.js";import"./AlignLeft-CI8EzNNL.js";import"./ArrowLeft-B2yP6vhy.js";import"./Image01-MBqu9WJ7.js";import"./RefreshCcw01-DOnZ44OA.js";import"./SearchMd-BrEq0pjT.js";import"./Settings01-CPifi92B.js";import"./useSuspenseInfiniteQuery-3Im9HP3l.js";import"./infiniteQueryObserver-BzTvfVsR.js";import"./tooltip-CfJyDfiQ.js";const b={};function k(t){const e=P.c(22),{client:o,resourceURI:a,tool:c,connectionId:p}=t,{sendMessage:m,setAppContext:i,clearAppContext:n}=w(),[,f]=D(),r=`${p}:${c.name}`;let d;e[0]!==o||e[1]!==c.name?(d={client:o,toolName:c.name,toolArguments:b},e[0]=o,e[1]=c.name,e[2]=d):d=e[2];const{data:u}=U(d);let s;e[3]!==m||e[4]!==f?(s=I=>{const M=E(I.content);M.content.length>0&&(f(!0),m(M))},e[3]=m,e[4]=f,e[5]=s):s=e[5];const g=s,N=c;let x;e[6]!==N?(x={tool:N},e[6]=N,e[7]=x):x=e[7];let h;e[8]!==i||e[9]!==r?(h=I=>i(r,I),e[8]=i,e[9]=r,e[10]=h):h=e[10];let j;e[11]!==n||e[12]!==r?(j=()=>n(r),e[11]=n,e[12]=r,e[13]=j):j=e[13];let C;return e[14]!==o||e[15]!==g||e[16]!==a||e[17]!==x||e[18]!==h||e[19]!==j||e[20]!==u?(C=l.jsx(H,{resourceURI:a,toolInfo:x,toolInput:b,toolResult:u,displayMode:"fullscreen",minHeight:$.fullscreen.minHeight,maxHeight:$.fullscreen.maxHeight,client:o,onMessage:g,onUpdateModelContext:h,onTeardown:j,className:"h-full"}),e[14]=o,e[15]=g,e[16]=a,e[17]=x,e[18]=h,e[19]=j,e[20]=u,e[21]=C):C=e[21],C}function L(t){const e=P.c(17),{connectionId:o,toolName:a}=t,{org:c}=T();let p;e[0]!==o||e[1]!==c.id?(p={connectionId:o,orgId:c.id},e[0]=o,e[1]=c.id,e[2]=p):p=e[2];const m=S(p),i=v(o),n=decodeURIComponent(a);let f,r;if(e[3]!==i?.tools||e[4]!==n){let s;e[7]!==n?(s=g=>g.name===n,e[7]=n,e[8]=s):s=e[8],r=(i?.tools??[]).find(s),f=r?._meta?O(r._meta):void 0,e[3]=i?.tools,e[4]=n,e[5]=f,e[6]=r}else f=e[5],r=e[6];const d=f;if(!i){let s;return e[9]===Symbol.for("react.memo_cache_sentinel")?(s=l.jsx("div",{className:"flex items-center justify-center h-full",children:l.jsx("p",{className:"text-sm text-muted-foreground",children:"Connection not found"})}),e[9]=s):s=e[9],s}if(!r||!d){let s;return e[10]!==n?(s=l.jsx("div",{className:"flex items-center justify-center h-full",children:l.jsxs("p",{className:"text-sm text-muted-foreground",children:['Tool "',n,'" not found or has no UI']})}),e[10]=n,e[11]=s):s=e[11],s}let u;return e[12]!==m||e[13]!==o||e[14]!==d||e[15]!==r?(u=l.jsx(k,{client:m,resourceURI:d,tool:r,connectionId:o}),e[12]=m,e[13]=o,e[14]=d,e[15]=r,e[16]=u):u=e[16],u}function Pe(){const t=P.c(9);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={from:"/shell/$org/$project/apps/$connectionId/$toolName"},t[0]=e):e=t[0];const{connectionId:o,toolName:a}=A(e);let c;t[1]===Symbol.for("react.memo_cache_sentinel")?(c=l.jsx(_.Header,{}),t[1]=c):c=t[1];const p=`${o}:${a}`;let m;t[2]===Symbol.for("react.memo_cache_sentinel")?(m=l.jsx("div",{className:"flex items-center justify-center h-full",children:l.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[l.jsx("div",{className:"size-4 border-2 border-current border-t-transparent rounded-full animate-spin"}),l.jsx("span",{className:"text-sm",children:"Loading app..."})]})}),t[2]=m):m=t[2];let i;t[3]!==o||t[4]!==a?(i=l.jsx(R.Suspense,{fallback:m,children:l.jsx(L,{connectionId:o,toolName:a})}),t[3]=o,t[4]=a,t[5]=i):i=t[5];let n;return t[6]!==p||t[7]!==i?(n=l.jsxs(_,{children:[c,l.jsx(_.Content,{className:"overflow-hidden",children:l.jsx(y,{fallback:void 0,children:i},p)})]}),t[6]=p,t[7]=i,t[8]=n):n=t[8],n}export{Pe as default};
