import{c as x,e as N,j as i,r as I,E as _,u as P}from"./index-DAmbTOxS.js";import{u as C}from"./use-connection-DE-37ZRw.js";import{u as M}from"./constants-xmw1fMHh.js";import{u as R}from"./use-mcp-tools-NDarjnlp.js";import{M as $}from"./mcp-app-renderer--eX10QZ5.js";import{g as b,M as h}from"./types-tRNNwmgc.js";import"./use-collections-6zQXOG_F.js";import"./useMutation-CD3w4aw8.js";import"./useQuery-B4nMPmUe.js";import"./use-mcp-resources-D8ui0z-w.js";const j={};function y(t){const e=x.c(10),{client:o,resourceURI:m,tool:a}=t;let n;e[0]!==o||e[1]!==a.name?(n={client:o,toolName:a.name,toolArguments:j},e[0]=o,e[1]=a.name,e[2]=n):n=e[2];const{data:l}=R(n),c=a;let s;e[3]!==c?(s={tool:c},e[3]=c,e[4]=s):s=e[4];let f;return e[5]!==o||e[6]!==m||e[7]!==s||e[8]!==l?(f=i.jsx($,{resourceURI:m,toolInfo:s,toolInput:j,toolResult:l,displayMode:"fullscreen",minHeight:h.fullscreen.minHeight,maxHeight:h.fullscreen.maxHeight,client:o,className:"h-full"}),e[5]=o,e[6]=m,e[7]=s,e[8]=l,e[9]=f):f=e[9],f}function v(t){const e=x.c(16),{connectionId:o,toolName:m}=t,{org:a}=P();let n;e[0]!==o||e[1]!==a.id?(n={connectionId:o,orgId:a.id},e[0]=o,e[1]=a.id,e[2]=n):n=e[2];const l=M(n),c=C(o),s=decodeURIComponent(m);let f,d;if(e[3]!==c?.tools||e[4]!==s){let r;e[7]!==s?(r=g=>g.name===s,e[7]=s,e[8]=r):r=e[8],d=(c?.tools??[]).find(r),f=d?._meta?b(d._meta):void 0,e[3]=c?.tools,e[4]=s,e[5]=f,e[6]=d}else f=e[5],d=e[6];const u=f;if(!c){let r;return e[9]===Symbol.for("react.memo_cache_sentinel")?(r=i.jsx("div",{className:"flex items-center justify-center h-full",children:i.jsx("p",{className:"text-sm text-muted-foreground",children:"Connection not found"})}),e[9]=r):r=e[9],r}if(!d||!u){let r;return e[10]!==s?(r=i.jsx("div",{className:"flex items-center justify-center h-full",children:i.jsxs("p",{className:"text-sm text-muted-foreground",children:['Tool "',s,'" not found or has no UI']})}),e[10]=s,e[11]=r):r=e[11],r}let p;return e[12]!==l||e[13]!==u||e[14]!==d?(p=i.jsx(y,{client:l,resourceURI:u,tool:d}),e[12]=l,e[13]=u,e[14]=d,e[15]=p):p=e[15],p}function D(){const t=x.c(8);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:m}=N(e),a=`${o}:${m}`;let n;t[1]===Symbol.for("react.memo_cache_sentinel")?(n=i.jsx("div",{className:"flex items-center justify-center h-full",children:i.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[i.jsx("div",{className:"size-4 border-2 border-current border-t-transparent rounded-full animate-spin"}),i.jsx("span",{className:"text-sm",children:"Loading app..."})]})}),t[1]=n):n=t[1];let l;t[2]!==o||t[3]!==m?(l=i.jsx(I.Suspense,{fallback:n,children:i.jsx(v,{connectionId:o,toolName:m})}),t[2]=o,t[3]=m,t[4]=l):l=t[4];let c;return t[5]!==a||t[6]!==l?(c=i.jsx(_,{fallback:void 0,children:l},a),t[5]=a,t[6]=l,t[7]=c):c=t[7],c}export{D as default};
