import{c as h,e as _,j as n,E as P,r as I,u as C}from"./index-U8yTDca7.js";import{u as b}from"./use-connection-iQvUBAn8.js";import{u as y}from"./constants-DTB7OETZ.js";import{u as M}from"./use-mcp-tools-BfrLEufs.js";import{M as R}from"./mcp-app-renderer-BS-Ag69A.js";import{g as $,M as j}from"./types-BmXorGle.js";import{P as x}from"./index-DBJYDzwg.js";import"./use-collections-CN2TJbh7.js";import"./useMutation-DytEPkqh.js";import"./useQuery-5ZDNJc1s.js";import"./use-mcp-resources-CXWxuBPP.js";import"./localstorage-keys-BqiTN_31.js";import"./tooltip-Az0qqeXN.js";import"./index-Ds-_NbMX.js";const g={};function v(t){const e=h.c(10),{client:s,resourceURI:m,tool:i}=t;let c;e[0]!==s||e[1]!==i.name?(c={client:s,toolName:i.name,toolArguments:g},e[0]=s,e[1]=i.name,e[2]=c):c=e[2];const{data:a}=M(c),l=i;let o;e[3]!==l?(o={tool:l},e[3]=l,e[4]=o):o=e[4];let f;return e[5]!==s||e[6]!==m||e[7]!==o||e[8]!==a?(f=n.jsx(R,{resourceURI:m,toolInfo:o,toolInput:g,toolResult:a,displayMode:"fullscreen",minHeight:j.fullscreen.minHeight,maxHeight:j.fullscreen.maxHeight,client:s,className:"h-full"}),e[5]=s,e[6]=m,e[7]=o,e[8]=a,e[9]=f):f=e[9],f}function A(t){const e=h.c(16),{connectionId:s,toolName:m}=t,{org:i}=C();let c;e[0]!==s||e[1]!==i.id?(c={connectionId:s,orgId:i.id},e[0]=s,e[1]=i.id,e[2]=c):c=e[2];const a=y(c),l=b(s),o=decodeURIComponent(m);let f,d;if(e[3]!==l?.tools||e[4]!==o){let r;e[7]!==o?(r=N=>N.name===o,e[7]=o,e[8]=r):r=e[8],d=(l?.tools??[]).find(r),f=d?._meta?$(d._meta):void 0,e[3]=l?.tools,e[4]=o,e[5]=f,e[6]=d}else f=e[5],d=e[6];const u=f;if(!l){let r;return e[9]===Symbol.for("react.memo_cache_sentinel")?(r=n.jsx("div",{className:"flex items-center justify-center h-full",children:n.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]!==o?(r=n.jsx("div",{className:"flex items-center justify-center h-full",children:n.jsxs("p",{className:"text-sm text-muted-foreground",children:['Tool "',o,'" not found or has no UI']})}),e[10]=o,e[11]=r):r=e[11],r}let p;return e[12]!==a||e[13]!==u||e[14]!==d?(p=n.jsx(v,{client:a,resourceURI:u,tool:d}),e[12]=a,e[13]=u,e[14]=d,e[15]=p):p=e[15],p}function q(){const t=h.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:s,toolName:m}=_(e);let i;t[1]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx(x.Header,{}),t[1]=i):i=t[1];const c=`${s}:${m}`;let a;t[2]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx("div",{className:"flex items-center justify-center h-full",children:n.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[n.jsx("div",{className:"size-4 border-2 border-current border-t-transparent rounded-full animate-spin"}),n.jsx("span",{className:"text-sm",children:"Loading app..."})]})}),t[2]=a):a=t[2];let l;t[3]!==s||t[4]!==m?(l=n.jsx(I.Suspense,{fallback:a,children:n.jsx(A,{connectionId:s,toolName:m})}),t[3]=s,t[4]=m,t[5]=l):l=t[5];let o;return t[6]!==c||t[7]!==l?(o=n.jsxs(x,{children:[i,n.jsx(x.Content,{className:"overflow-hidden",children:n.jsx(P,{fallback:void 0,children:l},c)})]}),t[6]=c,t[7]=l,t[8]=o):o=t[8],o}export{q as default};
