@mcp-use/inspector 20.0.0-beta.31 → 20.0.0-beta.32
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/app/inspector.js.gz +0 -0
- package/dist/cli.js +1 -1
- package/dist/client/index.js +29 -29
- package/dist/server/index.js +1 -1
- package/package.json +4 -4
package/dist/client/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
var cv=Object.defineProperty;var dv=(e,t,n)=>t in e?cv(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var ot=(e,t,n)=>dv(e,typeof t!="symbol"?t+"":t,n);var Hs=class{constructor(t){ot(this,"name","mcp_tool_execution");ot(this,"properties");this.properties={tool_name:t.toolName,server_id:t.serverId,success:t.success,duration:t.duration,error:t.error}}},Us=class{constructor(t){ot(this,"name","mcp_resource_read");ot(this,"properties");this.properties={resource_uri:t.resourceUri,server_id:t.serverId,success:t.success,error:t.error}}},Fs=class{constructor(t){ot(this,"name","mcp_prompt_call");ot(this,"properties");this.properties={prompt_name:t.promptName,server_id:t.serverId,success:t.success,error:t.error}}};var $s=class{constructor(t){ot(this,"name","mcp_chat_message");ot(this,"properties");this.properties={server_id:t.serverId,provider:t.provider,model:t.model,message_count:t.messageCount,tool_calls_count:t.toolCallsCount,success:t.success,execution_mode:t.executionMode,duration:t.duration,error:t.error}}};var Xa=class{constructor(t){ot(this,"name","mcp_tool_saved");ot(this,"properties");this.properties={tool_name:t.toolName,server_id:t.serverId}}};var Za=class{constructor(t){ot(this,"name","mcp_chat_configured");ot(this,"properties");this.properties={provider:t.provider,model:t.model}}};var ei=class{constructor(t){ot(this,"name","mcp_add_to_client");ot(this,"properties");this.properties={client:t.client}}};import{Tel as lT,setTelemetrySource as cT}from"@mcp-use/client";import{Tel as uv}from"@mcp-use/client";function mv(){if(typeof window>"u")return"standalone";let e=window.__MCP_INSPECTOR_MODE__;return e==="standalone"||e==="embedded"||e==="cloud"?e:"standalone"}async function Lt(e){await uv.getInstance().capture({name:e.name,properties:{...e.properties,package:"inspector",mode:mv()}})}import{cloneElement as bv,forwardRef as yv,isValidElement as xv}from"react";import{Button as tm}from"@base-ui/react/button";import{cva as wv}from"class-variance-authority";import{clsx as pv}from"clsx";import{twMerge as fv}from"tailwind-merge";function C(...e){return fv(pv(e))}import{createContext as gv,useContext as hv,useState as PT,useEffect as RT,useRef as MT,useCallback as IT,useMemo as ET}from"react";import{jsx as DT}from"react/jsx-runtime";var Vs={pill:{item:"rounded-[20px]",bg:"rounded-[20px]",focusRing:"rounded-[22px]",mergedBg:"rounded-2xl",container:"rounded-3xl",button:"rounded-[20px]",input:"rounded-[20px]",bgRadius:20,mergedRadius:16},rounded:{item:"rounded-lg",bg:"rounded-lg",focusRing:"rounded-[10px]",mergedBg:"rounded-lg",container:"rounded-xl",button:"rounded-lg",input:"rounded-lg",bgRadius:8,mergedRadius:8}},vv=gv(null);function pt(){let e=hv(vv);return e?e.classes:Vs.pill}import{Fragment as Kl,jsx as Ut,jsxs as ti}from"react/jsx-runtime";var Cv=wv(["group relative isolate inline-flex items-center justify-center outline-none cursor-pointer","[&_svg]:pointer-events-none [&_svg]:shrink-0","transition-colors duration-80","disabled:opacity-50 disabled:pointer-events-none","focus-visible:ring-1 focus-visible:ring-[color:var(--focus-ring,#6B97FF)]"],{variants:{variant:{primary:"text-background",secondary:"text-foreground",tertiary:"border border-border text-foreground",ghost:"text-muted-foreground hover:text-foreground",destructive:"text-white"},size:{sm:"h-7 px-3 text-[12px] gap-1 [&_svg:not([class*='size-'])]:size-3.5",md:"h-8 px-4 text-[13px] gap-1.5 [&_svg:not([class*='size-'])]:size-4",lg:"h-9 px-5 text-[14px] gap-1.5 [&_svg:not([class*='size-'])]:size-4","icon-sm":"h-8 w-8 p-0 [&_svg]:h-3.5 [&_svg]:w-3.5",icon:"h-9 w-9 p-0 [&_svg]:h-4 [&_svg]:w-4","icon-lg":"h-10 w-10 p-0 [&_svg]:h-5 [&_svg]:w-5"},iconLeft:{true:""},iconRight:{true:""}},compoundVariants:[{size:"sm",iconLeft:!0,className:"pl-[6px]"},{size:"md",iconLeft:!0,className:"pl-[10px]"},{size:"lg",iconLeft:!0,className:"pl-[14px]"},{size:"sm",iconRight:!0,className:"pr-[6px]"},{size:"md",iconRight:!0,className:"pr-[10px]"},{size:"lg",iconRight:!0,className:"pr-[14px]"}],defaultVariants:{variant:"primary",size:"md"}}),Nv={primary:"bg-foreground group-hover:bg-foreground/90 group-active:bg-foreground/80",secondary:"bg-accent group-hover:bg-accent/80 group-active:bg-accent",tertiary:"bg-transparent group-hover:bg-hover group-active:bg-active",ghost:"bg-transparent group-hover:bg-hover group-active:bg-active",destructive:"bg-destructive group-hover:bg-destructive/90 group-active:bg-destructive/80"},kv={primary:"bg-foreground/80",secondary:"bg-accent",tertiary:"bg-active",ghost:"bg-active",destructive:"bg-destructive/80"},nm={default:"primary",destructive:"destructive",outline:"tertiary",secondary:"secondary",ghost:"ghost",link:"ghost"},om={default:"md",xs:"sm",sm:"sm",lg:"lg",icon:"icon","icon-xs":"icon-sm","icon-sm":"icon-sm","icon-lg":"icon-lg"};function Sv(e){return typeof e=="string"||typeof e=="number"}function Wl({children:e}){return Sv(e)?Ut("span",{className:"[text-box:trim-both_cap_alphabetic]",children:e}):Ut("span",{className:"inline-flex items-center gap-1",children:e})}var vr="sm:h-8 sm:min-h-8 sm:px-4 sm:text-[13px] sm:[&_svg:not([class*='size-'])]:size-4",rm="hidden sm:inline shrink-0 text-[10px] leading-none border border-current/30 p-1 rounded-full",js=C(vr,"pr-1! sm:pr-2!");function Tv({variant:e,size:t,className:n}){let o=e&&e in nm?nm[e]:e,r=t&&t in om?om[t]:t;return{variant:o,size:r,className:C(o==="ghost"&&(e==="link"?"underline-offset-4 hover:underline":void 0),n)}}var E=yv(({className:e,variant:t,size:n,render:o,nativeButton:r=!0,loading:s=!1,leadingIcon:a,trailingIcon:i,active:d=!1,disabled:l,children:u,style:h,...c},m)=>{let p=Tv({variant:t,size:n,className:e});t=p.variant,n=p.size,e=p.className;let x=o&&xv(o)?o:null,f=x&&x.props.children!=null?x.props.children:u,b=n==="icon"||n==="icon-sm"||n==="icon-lg",g=n==="sm"?14:n==="lg"?20:16,v=n==="sm"?"h-7 w-7":n==="lg"||n==="icon"?"h-9 w-9":n==="icon-lg"?"h-10 w-10":"h-8 w-8",y=pt(),w=d?kv[t??"primary"]:Nv[t??"primary"],N=ti(Kl,{children:[Ut("span",{"aria-hidden":!0,className:C("absolute inset-0 rounded-[inherit] transition-[background-color,transform] duration-80 group-active:scale-[0.98]",w)}),Ut("span",{className:"relative inline-flex items-center justify-center gap-[inherit]",children:s?ti(Kl,{children:[ti("span",{className:"inline-flex items-center justify-center gap-[inherit] opacity-0",children:[a&&!b&&Ut(a,{size:g,strokeWidth:2}),Ut(Wl,{children:f}),i&&!b&&Ut(i,{size:g,strokeWidth:2})]}),Ut("span",{className:"absolute inset-0 flex items-center justify-center",children:Ut("svg",{className:v,viewBox:"0 0 24 24",fill:"none",children:Ut("path",{d:"M 12 12 C 14 8.5 19 8.5 19 12 C 19 15.5 14 15.5 12 12 C 10 8.5 5 8.5 5 12 C 5 15.5 10 15.5 12 12 Z",stroke:"currentColor",strokeWidth:"1.125",strokeLinecap:"round",pathLength:"100",style:{strokeDasharray:"15 85",animation:"spinner-move 2s linear infinite, spinner-dash 4s ease-in-out infinite"}})})})]}):b?Ut("span",{className:"inline-flex items-center justify-center [&_svg]:stroke-[1.5] [&_svg]:transition-[stroke-width] [&_svg]:duration-80 group-hover:[&_svg]:stroke-[2]",children:f}):a||i?ti(Kl,{children:[a&&Ut(a,{size:g,strokeWidth:1.5,className:"transition-[stroke-width] duration-80 group-hover:stroke-[2]"}),Ut(Wl,{children:f}),i&&Ut(i,{size:g,strokeWidth:1.5,className:"transition-[stroke-width] duration-80 group-hover:stroke-[2]"})]}):Ut(Wl,{children:f})})]}),T=C(Cv({variant:t,size:n,iconLeft:!b&&!!a,iconRight:!b&&!!i}),y.button,e);if(x){let L=x.props;return Ut(tm,{ref:m,render:bv(x,{className:C(T,L.className),style:{...h,...L.style}}),nativeButton:r,disabled:l||s,...c,children:N})}return Ut(tm,{ref:m,className:T,disabled:l||s,style:h,...c,children:N})});E.displayName="Button";import{createContext as Pv,useContext as Rv}from"react";import{ChevronRight as Mv,ChevronDown as Iv,X as Ev,Copy as Av,Menu as Dv,Dot as Lv,Monitor as _v,Sun as Ov,Moon as zv,RectangleHorizontal as Bv,Circle as Hv,SquareLibrary as Uv,Clock as Fv,Star as $v,Settings as Vv,Plus as jv,ArrowLeft as qv,ArrowRight as Wv,ArrowUp as Kv,Search as Jv,Loader as Gv,Users as Yv,Lock as Qv,Mail as Xv,Bell as Zv,Shield as eb,Palette as tb,Lightbulb as nb,Rocket as ob,Heart as rb,Paintbrush as sb,Brain as ab,Globe as ib,User as lb,ImageIcon as cb,Link as db,Check as ub,RotateCcw as mb,Play as pb,Pause as fb,Pipette as gb,Home as hb,MessageCircle as vb,Inbox as bb,Pencil as yb,SkipForward as xb,CornerDownRight as wb}from"lucide-react";var Cb={"chevron-right":Mv,"chevron-down":Iv,pipette:gb,x:Ev,copy:Av,menu:Dv,dot:Lv,monitor:_v,sun:Ov,moon:zv,"rectangle-horizontal":Bv,circle:Hv,"square-library":Uv,clock:Fv,star:$v,settings:Vv,plus:jv,"arrow-left":qv,"arrow-right":Wv,"arrow-up":Kv,search:Jv,loader:Gv,users:Yv,lock:Qv,mail:Xv,bell:Zv,shield:eb,palette:tb,lightbulb:nb,rocket:ob,heart:rb,paintbrush:sb,brain:ab,globe:ib,user:lb,image:cb,link:db,check:ub,"rotate-ccw":mb,play:pb,pause:fb,home:hb,"message-circle":vb,inbox:bb,pencil:yb,"skip-forward":xb,"corner-down-right":wb},Nb=Pv(null);function br(e){return(Rv(Nb)??Cb)[e]}var se={fast:{type:"spring",duration:.08,bounce:0,exit:{duration:.06}},moderate:{type:"spring",duration:.16,bounce:0,exit:{duration:.12}},slow:{type:"spring",duration:.24,bounce:.12,exit:{duration:.16}}},ni=e=>Math.round(e.exit.duration*1e3)+100;var kb={1:"bg-surface-1",2:"bg-surface-2",3:"bg-surface-3",4:"bg-surface-4",5:"bg-surface-5",6:"bg-surface-6",7:"bg-surface-7",8:"bg-surface-8"},Sb={1:"shadow-surface-1",2:"shadow-surface-2",3:"shadow-surface-3",4:"shadow-surface-4",5:"shadow-surface-5",6:"shadow-surface-6",7:"shadow-surface-7",8:"shadow-surface-8"};function oi(e,t=e){let n=Math.round(Math.max(1,Math.min(8,e))),o=Math.round(Math.max(1,Math.min(8,t)));return`${kb[n]} ${Sb[o]}`}import{createContext as Tb,useContext as Pb}from"react";import{jsx as Rb}from"react/jsx-runtime";var sm=Tb(1);function ri(){return Pb(sm)}function si({value:e,children:t}){return Rb(sm.Provider,{value:Math.max(1,Math.min(8,e)),children:t})}import{Dialog as Do}from"@base-ui/react/dialog";import{motion as am}from"motion/react";import{createContext as Mb,forwardRef as Jl,useCallback as Ib,useContext as Gl,useLayoutEffect as Eb,useState as im}from"react";import{jsx as Tt,jsxs as qs}from"react/jsx-runtime";var Ab=4,Db="h-14",ai=Mb(null);function lm({className:e}){let t=br("x");return Tt(Do.Close,{render:qs(E,{variant:"ghost",size:"icon-sm",className:e,children:[Tt(t,{}),Tt("span",{className:"sr-only",children:"Close"})]})})}function fn({children:e,open:t,defaultOpen:n,onOpenChange:o,modal:r}){return Tt(Do.Root,{open:t,defaultOpen:n,onOpenChange:s=>o?.(s),modal:r,children:e})}function Yl(e){return Tt(Do.Trigger,{"data-slot":"dialog-trigger",...e})}var on=Jl(({className:e,children:t,size:n="sm",scrollable:o=!1,container:r,...s},a)=>{let i=pt(),d=ri(),l=Math.min(d+Ab,8),[u,h]=im(!1),c=Ib(m=>{h(m)},[]);return qs(Do.Portal,{container:r??void 0,children:[Tt(Do.Backdrop,{render:(m,p)=>{let x=p.transitionStatus==="ending",{style:f,onDrag:b,onDragStart:g,onDragEnd:v,onAnimationStart:y,onAnimationEnd:w,onAnimationIteration:N,...T}=m;return Tt(am.div,{...T,className:C(r?"absolute":"fixed","inset-0 z-50 bg-black/40 dark:bg-black/80"),initial:{opacity:0},animate:{opacity:x?0:1},transition:x?se.slow.exit:se.slow})}}),Tt(Do.Popup,{ref:a,render:(m,p)=>{let x=p.transitionStatus==="ending",{style:f,onDrag:b,onDragStart:g,onDragEnd:v,onAnimationStart:y,onAnimationEnd:w,onAnimationIteration:N,...T}=m;return Tt(am.div,{...T,...s,className:C(r?"absolute":"fixed","left-1/2 top-1/2 z-50 w-[calc(100%-2rem)]",oi(l),"p-6 focus:outline-none",n==="sm"&&"max-w-[400px]",n==="lg"&&"max-w-[540px]",i.container,o&&"flex flex-col overflow-hidden p-0",e),style:{...f,...s.style},initial:{opacity:0,scale:.97,x:"-50%",y:"-50%"},animate:{opacity:x?0:1,scale:x?.97:1,x:"-50%",y:"-50%"},transition:x?se.slow.exit:se.slow,children:Tt(si,{value:l,children:qs(ai.Provider,{value:{scrollable:o,setStickyHeader:c},children:[t,!u&&Tt(lm,{className:"absolute right-3 top-3 z-20"})]})})})}})]})});on.displayName="DialogContent";function Qt({className:e,sticky:t,children:n,...o}){let r=Gl(ai);return Eb(()=>{if(t)return r?.setStickyHeader(!0),()=>r?.setStickyHeader(!1)},[t,r]),t?qs("div",{className:C("sticky top-0 z-10 mb-0 flex shrink-0 items-center gap-2 border-b border-border/50 bg-white/50 px-6 backdrop-blur-xs dark:bg-black/50",Db,e),...o,children:[n,Tt(lm,{className:"ml-auto shrink-0"})]}):Tt("div",{className:C("mb-4 flex flex-col gap-1.5",r?.scrollable&&"px-6 pt-6",e),...o,children:n})}function Un({className:e,...t}){let n=Gl(ai);return Tt("div",{className:C("flex-1 min-h-0 overflow-y-auto overscroll-none pt-2",n?.scrollable?"px-6 pb-6":"-mx-6 px-6",e),...t})}function ii({className:e,onCopy:t,children:n,...o}){let r=br("copy"),s=br("check"),[a,i]=im(!1),d=async()=>{if(t)try{await t(),i(!0),setTimeout(()=>i(!1),2e3)}catch{}};return qs("div",{className:C("group/json relative -mx-6 bg-muted/20 px-6 pt-6 pb-4",e),...o,children:[t?Tt("div",{className:"absolute top-2 right-2 z-10 opacity-0 transition-opacity group-hover/json:opacity-100",children:Tt(E,{variant:"ghost",size:"icon-sm",onClick:d,title:"Copy",children:a?Tt(s,{className:"text-green-600"}):Tt(r,{})})}):null,n]})}function li({className:e,...t}){let n=Gl(ai);return Tt("div",{className:C("mt-6 flex justify-end gap-2",n?.scrollable&&"px-6 pb-6",e),...t})}var qt=Jl(({className:e,...t},n)=>Tt(Do.Title,{ref:n,className:C("m-0 text-[16px] leading-none text-foreground",e),style:{fontVariationSettings:"'wght' 700"},...t}));qt.displayName="DialogTitle";var ho=Jl(({className:e,...t},n)=>Tt(Do.Description,{ref:n,className:C("text-[13px] text-muted-foreground",e),...t}));ho.displayName="DialogDescription";import*as gn from"react";import{Menu as OP}from"@base-ui/react/menu";import{CheckIcon as BP}from"lucide-react";import{useRef as ec,useState as tc,useEffect as Zl,useCallback as gm,useMemo as hm,createContext as qb,useContext as Wb,forwardRef as ui}from"react";import{motion as wr,AnimatePresence as ns}from"motion/react";import{Menu as Oo}from"@base-ui/react/menu";import{createContext as Lb,useContext as _b,useRef as cm,useEffect as dm,forwardRef as Ob}from"react";import{motion as um,AnimatePresence as zb}from"motion/react";var yt={normal:"'wght' 400, 'opsz' 14",medium:"'wght' 450, 'opsz' 15",semibold:"'wght' 550, 'opsz' 20",bold:"'wght' 700, 'opsz' 25"},Lo="px-4 pt-3 pb-3",_o="text-[15px] text-foreground [font-variation-settings:'wght'_550,'opsz'_20]";function ci(e){return`sticky top-0 z-30 border-b bg-background/80 backdrop-blur-md transition-[border-color] duration-200 supports-[backdrop-filter]:bg-background/70 ${e?"border-border/80":"border-transparent"}`}import{Fragment as Ub,jsx as eo,jsxs as Ql}from"react/jsx-runtime";var Bb=Vs.rounded,di=Lb(null);function Hb(){let e=_b(di);if(!e)throw new Error("useDropdown must be used within a Dropdown");return e}var yr=Ob(({icon:e,label:t,customContent:n,index:o,checked:r,onSelect:s,disabled:a,closeOnClick:i,className:d,onClick:l,...u},h)=>{let c=cm(null),m=cm(!1),{registerItem:p,activeIndex:x,checkedIndex:f,renderMenuItem:b}=Hb();dm(()=>(p(o,c.current),()=>p(o,null)),[o,p]),dm(()=>{m.current=!0},[]);let g=x===o,v=!m.current,y=P=>{c.current=P,typeof h=="function"?h(P):h&&(h.current=P)},w=a?void 0:P=>{l?.(P),s?.()},N=C(`relative z-10 flex h-9 items-center gap-2 ${Bb.item} px-2 cursor-pointer outline-none`,a&&"opacity-50 pointer-events-none",d),T=t??(typeof n=="string"?n:"Menu item"),L=n??Ql(Ub,{children:[e&&Ql("span",{className:"inline-grid",children:[eo("span",{className:"col-start-1 row-start-1 invisible",children:eo(e,{size:16,strokeWidth:2})}),eo(e,{size:16,strokeWidth:g||r?2:1.5,className:C("col-start-1 row-start-1 transition-[color,stroke-width] duration-80",g||r?"text-foreground":"text-muted-foreground")})]}),Ql("span",{className:"inline-grid flex-1 text-[13px]",children:[eo("span",{className:"col-start-1 row-start-1 invisible [text-box:trim-both_cap_alphabetic]",style:{fontVariationSettings:yt.semibold},"aria-hidden":"true",children:T}),eo("span",{className:C("col-start-1 row-start-1 transition-[color,font-variation-settings] duration-80 [text-box:trim-both_cap_alphabetic]",g||r?"text-foreground":"text-muted-foreground"),style:{fontVariationSettings:r?yt.semibold:yt.normal},children:T})]}),eo(zb,{children:r&&eo(um.svg,{width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",className:"text-foreground shrink-0",initial:{opacity:1},animate:{opacity:1},exit:{opacity:1},children:eo(um.path,{d:"M4 12L9 17L20 6",initial:{pathLength:v?1:0},animate:{pathLength:1,transition:{duration:.08,ease:"easeOut"}},exit:{pathLength:0,transition:{duration:.04,ease:"easeIn"}}})},"check")})]});return b?b({radio:typeof r=="boolean",value:o,disabled:a,label:T,closeOnClick:i??!0,element:eo("div",{ref:y,"data-proximity-index":o,"aria-label":T,onClick:w,className:N,...u}),children:L}):eo("div",{ref:y,"data-proximity-index":o,tabIndex:!a&&o===(f??0)?0:-1,role:typeof r=="boolean"?"menuitemradio":"menuitem","aria-checked":typeof r=="boolean"?r:void 0,"aria-disabled":a||void 0,"aria-label":T,onClick:w,onKeyDown:P=>{a||(P.key===" "||P.key==="Enter")&&(P.preventDefault(),s?.())},className:N,...u,children:L})});yr.displayName="MenuItem";import{useRef as Zr,useState as mm,useCallback as es,useEffect as Xl}from"react";function pm(e,t){let n=e.getBoundingClientRect(),o=t==="x"?e.offsetWidth:e.offsetHeight,r=t==="x"?n.width:n.height;return o>0?r/o:1}function Fb(e,t){let n=e.getBoundingClientRect(),o=pm(e,"x"),r=pm(e,"y"),s=[];return t.forEach((a,i)=>{let d=a.getBoundingClientRect();s[i]={top:(d.top-n.top)/r+e.scrollTop,left:(d.left-n.left)/o+e.scrollLeft,width:a.offsetWidth,height:a.offsetHeight}}),s}function $b(e,t,n,o){let r=o==="x"?t:n,s=null,a=1/0,i=null;return e.forEach((d,l)=>{let u=d.getBoundingClientRect(),h=o==="x"?u.left:u.top,c=o==="x"?u.right:u.bottom;r>=h&&r<=c&&(i=l);let m=(h+c)/2,p=Math.abs(r-m);p<a&&(a=p,s=l)}),i??s}function Vb(e,t){if(e.length!==t.length)return!0;for(let n=0;n<t.length;n++){let o=e[n],r=t[n];if(o!==r&&(!o||!r||o.top!==r.top||o.left!==r.left||o.width!==r.width||o.height!==r.height))return!0}return!1}function xr(e,t={}){let{axis:n="y"}=t,o=Zr(new Map),[r,s]=mm(null),[a,i]=mm([]),d=Zr([]),l=Zr(0),u=Zr(null),h=Zr(null),c=Zr(null),m=es(()=>{let v=e.current;if(!v)return;let y=Fb(v,o.current);Vb(d.current,y)&&(d.current=y,i(y))},[e]),p=es((v,y)=>{s($b(o.current,v,y,n))},[n]),x=es((v,y)=>{y?o.current.set(v,y):o.current.delete(v),h.current!==null&&cancelAnimationFrame(h.current),h.current=requestAnimationFrame(()=>{h.current=null,m()})},[m]),f=es(v=>{c.current={x:v.clientX,y:v.clientY},u.current!==null&&cancelAnimationFrame(u.current),u.current=requestAnimationFrame(()=>{u.current=null,m(),p(v.clientX,v.clientY)})},[m,p]),b=es(()=>{l.current+=1},[]),g=es(()=>{u.current!==null&&(cancelAnimationFrame(u.current),u.current=null),c.current=null,s(null)},[]);return Xl(()=>{let v=e.current;if(!v||typeof ResizeObserver>"u")return;let y=new ResizeObserver(()=>{h.current!==null&&cancelAnimationFrame(h.current),h.current=requestAnimationFrame(()=>{h.current=null,m()})});return y.observe(v),()=>y.disconnect()},[e,m]),Xl(()=>{let v=e.current;if(!v)return;let y=()=>{m();let w=c.current;w&&p(w.x,w.y)};return v.addEventListener("scroll",y,{capture:!0,passive:!0}),()=>v.removeEventListener("scroll",y,{capture:!0})},[e,m,p]),Xl(()=>()=>{u.current!==null&&cancelAnimationFrame(u.current),h.current!==null&&cancelAnimationFrame(h.current)},[]),{activeIndex:r,setActiveIndex:s,itemRects:a,sessionRef:l,handlers:{onMouseMove:f,onMouseEnter:b,onMouseLeave:g},registerItem:x,measureItems:m}}import{forwardRef as jb}from"react";import{jsx as fm}from"react/jsx-runtime";var ts=jb(({offset:e,shadowLevel:t,className:n,children:o,...r},s)=>{let a=ri(),i=Math.min(a+e,8);return fm(si,{value:i,children:fm("div",{ref:s,className:C(oi(i,t??i),n),...r,children:o})})});ts.displayName="Elevated";import{jsx as it,jsxs as xm}from"react/jsx-runtime";var zo=Vs.rounded,Kb=ui(({children:e,checkedIndex:t,className:n,...o},r)=>{let s=ec(null),{activeIndex:a,setActiveIndex:i,itemRects:d,sessionRef:l,handlers:u,registerItem:h,measureItems:c}=xr(s);Zl(()=>{c()},[c,e]);let[m,p]=tc(null),x=a!==null?d[a]:null,f=t!=null?d[t]:null,b=m!==null?d[m]:null,g=a!==null&&a!==t;return it(di.Provider,{value:{registerItem:h,activeIndex:a,checkedIndex:t},children:xm(ts,{offset:2,shadowLevel:3,ref:v=>{s.current=v,typeof r=="function"?r(v):r&&(r.current=v)},onMouseEnter:u.onMouseEnter,onMouseMove:u.onMouseMove,onMouseLeave:u.onMouseLeave,onFocus:v=>{let y=v.target.closest("[data-proximity-index]")?.getAttribute("data-proximity-index");if(y!=null){let w=Number(y);i(w),p(v.target.matches(":focus-visible")?w:null)}},onBlur:v=>{s.current?.contains(v.relatedTarget)||(p(null),i(null))},onKeyDown:v=>{let y=Array.from(s.current?.querySelectorAll('[role="menuitem"], [role="menuitemradio"]')??[]),w=y.indexOf(v.target);if(w!==-1)if(["ArrowDown","ArrowUp","ArrowRight","ArrowLeft"].includes(v.key)){v.preventDefault();let N=["ArrowDown","ArrowRight"].includes(v.key)?(w+1)%y.length:(w-1+y.length)%y.length;y[N].focus()}else v.key==="Home"?(v.preventDefault(),y[0]?.focus()):v.key==="End"&&(v.preventDefault(),y[y.length-1]?.focus())},role:"group",className:C(`relative flex flex-col gap-0.5 w-72 max-w-full ${zo.container} p-1 select-none`,n),...o,children:[it(ns,{children:f&&it(wr.div,{className:`absolute ${zo.bg} bg-active pointer-events-none`,initial:!1,animate:{top:f.top,left:f.left,width:f.width,height:f.height,opacity:g?.8:1},exit:{opacity:0,transition:se.moderate.exit},transition:{...se.moderate,opacity:{duration:.08}}})}),it(ns,{children:x&&it(wr.div,{className:`absolute ${zo.bg} bg-hover pointer-events-none`,initial:{opacity:0,top:f?.top??x.top,left:f?.left??x.left,width:f?.width??x.width,height:f?.height??x.height},animate:{opacity:1,top:x.top,left:x.left,width:x.width,height:x.height},exit:{opacity:0,transition:se.fast.exit},transition:{...se.fast,opacity:{duration:.08}}},l.current)}),it(ns,{children:b&&it(wr.div,{className:`absolute ${zo.focusRing} pointer-events-none z-20 border border-[color:var(--focus-ring,#6B97FF)]`,initial:!1,animate:{left:b.left-2,top:b.top-2,width:b.width+4,height:b.height+4},exit:{opacity:0,transition:se.fast.exit},transition:{...se.fast,opacity:{duration:.08}}})}),e]})})});Kb.displayName="Dropdown";var vm=qb(null);function Jb(){let e=Wb(vm);if(!e)throw new Error("DropdownMenu compound components must be inside <DropdownMenu>");return e}function nc({children:e,open:t,defaultOpen:n=!1,onOpenChange:o,disabled:r=!1}){let[s,a]=tc(n),i=t!==void 0?t:s,d=ec(null),l=gm(h=>{t===void 0&&a(h),o?.(h)},[t,o]),u=hm(()=>({open:i,actionsRef:d}),[i]);return it(vm.Provider,{value:u,children:it(Oo.Root,{open:i,onOpenChange:l,actionsRef:d,disabled:r,modal:!1,children:e})})}nc.displayName="DropdownMenu";var bm=Oo.Trigger,oc=ui(({className:e,children:t,checkedIndex:n,side:o="bottom",align:r="start",sideOffset:s=6},a)=>{let{open:i,actionsRef:d}=Jb(),l=ec(null),{activeIndex:u,setActiveIndex:h,itemRects:c,sessionRef:m,handlers:p,registerItem:x,measureItems:f}=xr(l),[b,g]=tc(null);Zl(()=>{if(i)return;let P=setTimeout(()=>d.current?.unmount(),ni(se.fast));return()=>clearTimeout(P)},[i,d]),Zl(()=>{if(!i)return;let P,R=requestAnimationFrame(()=>{P=requestAnimationFrame(()=>{f()})});return()=>{cancelAnimationFrame(R),cancelAnimationFrame(P)}},[i,f]);let v=u!==null?c[u]:null,y=n!=null?c[n]:null,w=b!==null?c[b]:null,N=u!==null&&u!==n,T=gm(({radio:P,value:R,disabled:D,label:k,closeOnClick:S,element:A,children:_})=>P?it(Oo.RadioItem,{value:R,disabled:D,label:k,closeOnClick:S,render:A,children:_}):it(Oo.Item,{disabled:D,label:k,closeOnClick:S,render:A,children:_}),[]),L=hm(()=>({registerItem:x,activeIndex:u,checkedIndex:n,inMenu:!0,renderMenuItem:T}),[x,u,n,T]);return it(Oo.Portal,{children:it(Oo.Positioner,{side:o,align:r,sideOffset:s,className:"z-50 outline-none",children:it(wr.div,{initial:{opacity:0,y:-4,scaleY:.96},animate:i?{opacity:1,y:0,scaleY:1}:{opacity:0,y:-4,scaleY:.96},transition:i?se.fast:se.fast.exit,style:{transformOrigin:"top center"},onAnimationComplete:()=>{i||d.current?.unmount()},children:it(di.Provider,{value:L,children:xm(Oo.Popup,{render:it(ts,{offset:2,shadowLevel:3,ref:P=>{l.current=P,typeof a=="function"?a(P):a&&(a.current=P)}}),onMouseEnter:()=>{p.onMouseEnter(),g(null)},onMouseMove:p.onMouseMove,onMouseLeave:p.onMouseLeave,onFocus:P=>{let R=P.target.closest("[data-proximity-index]")?.getAttribute("data-proximity-index");if(R!=null){let D=Number(R);h(D),g(P.target.matches(":focus-visible")?D:null)}},onBlur:P=>{l.current?.contains(P.relatedTarget)||(g(null),h(null))},className:C(`relative flex flex-col gap-0.5 w-72 max-w-full min-w-[var(--anchor-width)] max-h-[min(480px,var(--available-height))] overflow-y-auto ${zo.container} p-1 select-none outline-none`,e),children:[it(ns,{children:y&&it(wr.div,{className:`absolute ${zo.bg} bg-active pointer-events-none`,initial:!1,animate:{top:y.top,left:y.left,width:y.width,height:y.height,opacity:N?.8:1},exit:{opacity:0,transition:se.moderate.exit},transition:{...se.moderate,opacity:{duration:.08}}})}),it(ns,{children:v&&it(wr.div,{className:`absolute ${zo.bg} bg-hover pointer-events-none`,initial:{opacity:0,top:y?.top??v.top,left:y?.left??v.left,width:y?.width??v.width,height:y?.height??v.height},animate:{opacity:1,top:v.top,left:v.left,width:v.width,height:v.height},exit:{opacity:0,transition:se.fast.exit},transition:{...se.fast,opacity:{duration:.08}}},m.current)}),it(ns,{children:w&&it(wr.div,{className:`absolute ${zo.focusRing} pointer-events-none z-20 border border-[color:var(--focus-ring,#6B97FF)]`,initial:!1,animate:{left:w.left-2,top:w.top-2,width:w.width+4,height:w.height+4},exit:{opacity:0,transition:se.fast.exit},transition:{...se.fast,opacity:{duration:.08}}})}),n!=null?it(Oo.RadioGroup,{value:n,className:"contents",children:t}):t]})})})})})});oc.displayName="DropdownContent";var ym=ui(({className:e,...t},n)=>it("div",{ref:n,className:C("px-2 py-1.5 text-[11px] text-muted-foreground",e),...t}));ym.displayName="DropdownLabel";var rc=ui(({className:e,...t},n)=>it("div",{ref:n,role:"separator",className:C("my-1 -mx-1 h-px bg-border/60",e),...t}));rc.displayName="DropdownSeparator";import{jsx as Bo,jsxs as VP}from"react/jsx-runtime";var wm=gn.createContext(null);function Gb(){let e=gn.useContext(wm);if(!e)throw new Error("Dropdown menu items must be inside DropdownMenuContent");return e.next()}function sc(e){return typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map(sc).filter(Boolean).join(" ").trim():gn.isValidElement(e)?sc(e.props.children):"Menu item"}function Cr(e){return Bo(nc,{"data-slot":"dropdown-menu",...e})}function Ho(e){return Bo(bm,{"data-slot":"dropdown-menu-trigger",...e})}function Nr({className:e,align:t="start",side:n="bottom",sideOffset:o=6,children:r,forceMount:s,...a}){let i=gn.useRef(0),d=gn.useMemo(()=>({next:()=>i.current++}),[]);return i.current=0,Bo(wm.Provider,{value:d,children:Bo(oc,{"data-slot":"dropdown-menu-content",className:e,align:t,side:n,sideOffset:o,...a,children:r})})}function Nn({className:e,inset:t,variant:n="default",render:o,children:r,onSelect:s,onClick:a,disabled:i,...d}){let l=Gb(),u=sc(o??r),h=()=>{s?.(new Event("select"))};if(o&&gn.isValidElement(o)){let c=o;return Bo(yr,{index:l,label:u,disabled:i,customContent:gn.cloneElement(c,{className:C("relative z-10 flex h-9 w-full items-center gap-2 rounded-lg px-2 text-[13px] outline-none",t&&"pl-8",n==="destructive"&&"text-destructive",c.props.className,e),onClick:m=>{c.props.onClick?.(m),a?.(m),m.defaultPrevented||h()}}),onSelect:h,...d})}return Bo(yr,{index:l,label:u,disabled:i,className:C(t&&"pl-8",n==="destructive"&&"text-destructive",e),customContent:Bo("span",{className:"flex w-full min-w-0 items-center gap-2 text-[13px] text-inherit",children:r}),onClick:a,onSelect:h,...d})}function Cm({className:e,...t}){return Bo(rc,{"data-slot":"dropdown-menu-separator",className:e,...t})}function to(e){return e.replace(/[^a-zA-Z0-9-_]/g,"_").toLowerCase()}function mi(e){return`'${e.replace(/'/g,"'\\''")}'`}function kr(e){return e.replace(/[^a-zA-Z0-9]/g,"_").toUpperCase().replace(/^_+|_+$/g,"")}function Nm(e,t,n){let o={url:e};if(n&&Object.keys(n).length>0){let a={};for(let[i]of Object.entries(n)){let d=kr(i);a[i]=`{{${d}}}`}o.headers=a}let r=JSON.stringify(o);return`cursor://anysphere.cursor-deeplink/mcp/install?config=${btoa(r)}&name=${encodeURIComponent(to(t))}`}function km(e,t,n){let o={url:e,name:to(t),type:"http"};if(n&&Object.keys(n).length>0){let a={};for(let[i]of Object.entries(n)){let d=kr(i);a[i]=`your-${d}-value`}o.headers=a}let r=JSON.stringify(o);return`vscode:mcp/install?${encodeURIComponent(r)}`}function Sm(e,t,n){let o={url:e,name:to(t),type:"http"};if(n&&Object.keys(n).length>0){let a={};for(let[i]of Object.entries(n)){let d=kr(i);a[i]=`your-${d}-value`}o.headers=a}let r=JSON.stringify(o);return`vscode-insiders:mcp/install?${encodeURIComponent(r)}`}function Yb(e,t,n){let o={url:e,name:to(t)};if(n&&Object.keys(n).length>0){let r={};for(let[s]of Object.entries(n)){let a=kr(s);r[s]=`your-${a}-value`}o.headers=r}return o}function Tm(e,t,n){try{let o=Yb(e,t,n),r=JSON.stringify(o,null,2),s=globalThis.Blob,a=new s([r],{type:"application/json"}),i=URL.createObjectURL(a),d=document.createElement("a");d.href=i,d.download=`${to(t)}.mcpb`,document.body.appendChild(d),d.click(),document.body.removeChild(d),URL.revokeObjectURL(i)}catch(o){throw console.error("Failed to download .mcpb file:",o),o}}function Pm(e,t,n){let r=`claude mcp add --transport http "${to(t)}" \\
|
|
1
|
+
var lv=Object.defineProperty;var cv=(e,t,n)=>t in e?lv(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var ot=(e,t,n)=>cv(e,typeof t!="symbol"?t+"":t,n);var Hs=class{constructor(t){ot(this,"name","mcp_tool_execution");ot(this,"properties");this.properties={tool_name:t.toolName,server_id:t.serverId,success:t.success,duration:t.duration,error:t.error}}},Us=class{constructor(t){ot(this,"name","mcp_resource_read");ot(this,"properties");this.properties={resource_uri:t.resourceUri,server_id:t.serverId,success:t.success,error:t.error}}},Fs=class{constructor(t){ot(this,"name","mcp_prompt_call");ot(this,"properties");this.properties={prompt_name:t.promptName,server_id:t.serverId,success:t.success,error:t.error}}};var $s=class{constructor(t){ot(this,"name","mcp_chat_message");ot(this,"properties");this.properties={server_id:t.serverId,provider:t.provider,model:t.model,message_count:t.messageCount,tool_calls_count:t.toolCallsCount,success:t.success,execution_mode:t.executionMode,duration:t.duration,error:t.error}}};var Xa=class{constructor(t){ot(this,"name","mcp_tool_saved");ot(this,"properties");this.properties={tool_name:t.toolName,server_id:t.serverId}}};var Za=class{constructor(t){ot(this,"name","mcp_chat_configured");ot(this,"properties");this.properties={provider:t.provider,model:t.model}}};var ei=class{constructor(t){ot(this,"name","mcp_add_to_client");ot(this,"properties");this.properties={client:t.client}}};import{Tel as iT,setTelemetrySource as lT}from"@mcp-use/client";import{Tel as dv}from"@mcp-use/client";function uv(){if(typeof window>"u")return"standalone";let e=window.__MCP_INSPECTOR_MODE__;return e==="standalone"||e==="embedded"||e==="cloud"?e:"standalone"}async function Lt(e){await dv.getInstance().capture({name:e.name,properties:{...e.properties,package:"inspector",mode:uv()}})}import{cloneElement as vv,forwardRef as bv,isValidElement as yv}from"react";import{Button as Zu}from"@base-ui/react/button";import{cva as xv}from"class-variance-authority";import{clsx as mv}from"clsx";import{twMerge as pv}from"tailwind-merge";function C(...e){return pv(mv(e))}import{createContext as fv,useContext as gv,useState as TT,useEffect as PT,useRef as RT,useCallback as MT,useMemo as IT}from"react";import{jsx as AT}from"react/jsx-runtime";var Vs={pill:{item:"rounded-[20px]",bg:"rounded-[20px]",focusRing:"rounded-[22px]",mergedBg:"rounded-2xl",container:"rounded-3xl",button:"rounded-[20px]",input:"rounded-[20px]",bgRadius:20,mergedRadius:16},rounded:{item:"rounded-lg",bg:"rounded-lg",focusRing:"rounded-[10px]",mergedBg:"rounded-lg",container:"rounded-xl",button:"rounded-lg",input:"rounded-lg",bgRadius:8,mergedRadius:8}},hv=fv(null);function pt(){let e=gv(hv);return e?e.classes:Vs.pill}import{Fragment as Kl,jsx as Ut,jsxs as ti}from"react/jsx-runtime";var wv=xv(["group relative isolate inline-flex items-center justify-center outline-none cursor-pointer","[&_svg]:pointer-events-none [&_svg]:shrink-0","transition-colors duration-80","disabled:opacity-50 disabled:pointer-events-none","focus-visible:ring-1 focus-visible:ring-[color:var(--focus-ring,#6B97FF)]"],{variants:{variant:{primary:"text-background",secondary:"text-foreground",tertiary:"border border-border text-foreground",ghost:"text-muted-foreground hover:text-foreground",destructive:"text-white"},size:{sm:"h-7 px-3 text-[12px] gap-1 [&_svg:not([class*='size-'])]:size-3.5",md:"h-8 px-4 text-[13px] gap-1.5 [&_svg:not([class*='size-'])]:size-4",lg:"h-9 px-5 text-[14px] gap-1.5 [&_svg:not([class*='size-'])]:size-4","icon-sm":"h-8 w-8 p-0 [&_svg]:h-3.5 [&_svg]:w-3.5",icon:"h-9 w-9 p-0 [&_svg]:h-4 [&_svg]:w-4","icon-lg":"h-10 w-10 p-0 [&_svg]:h-5 [&_svg]:w-5"},iconLeft:{true:""},iconRight:{true:""}},compoundVariants:[{size:"sm",iconLeft:!0,className:"pl-[6px]"},{size:"md",iconLeft:!0,className:"pl-[10px]"},{size:"lg",iconLeft:!0,className:"pl-[14px]"},{size:"sm",iconRight:!0,className:"pr-[6px]"},{size:"md",iconRight:!0,className:"pr-[10px]"},{size:"lg",iconRight:!0,className:"pr-[14px]"}],defaultVariants:{variant:"primary",size:"md"}}),Cv={primary:"bg-foreground group-hover:bg-foreground/90 group-active:bg-foreground/80",secondary:"bg-accent group-hover:bg-accent/80 group-active:bg-accent",tertiary:"bg-transparent group-hover:bg-hover group-active:bg-active",ghost:"bg-transparent group-hover:bg-hover group-active:bg-active",destructive:"bg-destructive group-hover:bg-destructive/90 group-active:bg-destructive/80"},Nv={primary:"bg-foreground/80",secondary:"bg-accent",tertiary:"bg-active",ghost:"bg-active",destructive:"bg-destructive/80"},em={default:"primary",destructive:"destructive",outline:"tertiary",secondary:"secondary",ghost:"ghost",link:"ghost"},tm={default:"md",xs:"sm",sm:"sm",lg:"lg",icon:"icon","icon-xs":"icon-sm","icon-sm":"icon-sm","icon-lg":"icon-lg"};function kv(e){return typeof e=="string"||typeof e=="number"}function Wl({children:e}){return kv(e)?Ut("span",{className:"[text-box:trim-both_cap_alphabetic]",children:e}):Ut("span",{className:"inline-flex items-center gap-1",children:e})}var vr="sm:h-8 sm:min-h-8 sm:px-4 sm:text-[13px] sm:[&_svg:not([class*='size-'])]:size-4",nm="hidden sm:inline shrink-0 text-[10px] leading-none border border-current/30 p-1 rounded-full",js=C(vr,"pr-1! sm:pr-2!");function Sv({variant:e,size:t,className:n}){let o=e&&e in em?em[e]:e,r=t&&t in tm?tm[t]:t;return{variant:o,size:r,className:C(o==="ghost"&&(e==="link"?"underline-offset-4 hover:underline":void 0),n)}}var E=bv(({className:e,variant:t,size:n,render:o,nativeButton:r=!0,loading:s=!1,leadingIcon:a,trailingIcon:i,active:d=!1,disabled:l,children:u,style:h,...c},m)=>{let p=Sv({variant:t,size:n,className:e});t=p.variant,n=p.size,e=p.className;let x=o&&yv(o)?o:null,f=x&&x.props.children!=null?x.props.children:u,b=n==="icon"||n==="icon-sm"||n==="icon-lg",g=n==="sm"?14:n==="lg"?20:16,v=n==="sm"?"h-7 w-7":n==="lg"||n==="icon"?"h-9 w-9":n==="icon-lg"?"h-10 w-10":"h-8 w-8",y=pt(),w=d?Nv[t??"primary"]:Cv[t??"primary"],N=ti(Kl,{children:[Ut("span",{"aria-hidden":!0,className:C("absolute inset-0 rounded-[inherit] transition-[background-color,transform] duration-80 group-active:scale-[0.98]",w)}),Ut("span",{className:"relative inline-flex items-center justify-center gap-[inherit]",children:s?ti(Kl,{children:[ti("span",{className:"inline-flex items-center justify-center gap-[inherit] opacity-0",children:[a&&!b&&Ut(a,{size:g,strokeWidth:2}),Ut(Wl,{children:f}),i&&!b&&Ut(i,{size:g,strokeWidth:2})]}),Ut("span",{className:"absolute inset-0 flex items-center justify-center",children:Ut("svg",{className:v,viewBox:"0 0 24 24",fill:"none",children:Ut("path",{d:"M 12 12 C 14 8.5 19 8.5 19 12 C 19 15.5 14 15.5 12 12 C 10 8.5 5 8.5 5 12 C 5 15.5 10 15.5 12 12 Z",stroke:"currentColor",strokeWidth:"1.125",strokeLinecap:"round",pathLength:"100",style:{strokeDasharray:"15 85",animation:"spinner-move 2s linear infinite, spinner-dash 4s ease-in-out infinite"}})})})]}):b?Ut("span",{className:"inline-flex items-center justify-center [&_svg]:stroke-[1.5] [&_svg]:transition-[stroke-width] [&_svg]:duration-80 group-hover:[&_svg]:stroke-[2]",children:f}):a||i?ti(Kl,{children:[a&&Ut(a,{size:g,strokeWidth:1.5,className:"transition-[stroke-width] duration-80 group-hover:stroke-[2]"}),Ut(Wl,{children:f}),i&&Ut(i,{size:g,strokeWidth:1.5,className:"transition-[stroke-width] duration-80 group-hover:stroke-[2]"})]}):Ut(Wl,{children:f})})]}),T=C(wv({variant:t,size:n,iconLeft:!b&&!!a,iconRight:!b&&!!i}),y.button,e);if(x){let L=x.props;return Ut(Zu,{ref:m,render:vv(x,{className:C(T,L.className),style:{...h,...L.style}}),nativeButton:r,disabled:l||s,...c,children:N})}return Ut(Zu,{ref:m,className:T,disabled:l||s,style:h,...c,children:N})});E.displayName="Button";import{createContext as Tv,useContext as Pv}from"react";import{ChevronRight as Rv,ChevronDown as Mv,X as Iv,Copy as Ev,Menu as Av,Dot as Dv,Monitor as Lv,Sun as _v,Moon as Ov,RectangleHorizontal as zv,Circle as Bv,SquareLibrary as Hv,Clock as Uv,Star as Fv,Settings as $v,Plus as Vv,ArrowLeft as jv,ArrowRight as qv,ArrowUp as Wv,Search as Kv,Loader as Jv,Users as Gv,Lock as Yv,Mail as Qv,Bell as Xv,Shield as Zv,Palette as eb,Lightbulb as tb,Rocket as nb,Heart as ob,Paintbrush as rb,Brain as sb,Globe as ab,User as ib,ImageIcon as lb,Link as cb,Check as db,RotateCcw as ub,Play as mb,Pause as pb,Pipette as fb,Home as gb,MessageCircle as hb,Inbox as vb,Pencil as bb,SkipForward as yb,CornerDownRight as xb}from"lucide-react";var wb={"chevron-right":Rv,"chevron-down":Mv,pipette:fb,x:Iv,copy:Ev,menu:Av,dot:Dv,monitor:Lv,sun:_v,moon:Ov,"rectangle-horizontal":zv,circle:Bv,"square-library":Hv,clock:Uv,star:Fv,settings:$v,plus:Vv,"arrow-left":jv,"arrow-right":qv,"arrow-up":Wv,search:Kv,loader:Jv,users:Gv,lock:Yv,mail:Qv,bell:Xv,shield:Zv,palette:eb,lightbulb:tb,rocket:nb,heart:ob,paintbrush:rb,brain:sb,globe:ab,user:ib,image:lb,link:cb,check:db,"rotate-ccw":ub,play:mb,pause:pb,home:gb,"message-circle":hb,inbox:vb,pencil:bb,"skip-forward":yb,"corner-down-right":xb},Cb=Tv(null);function br(e){return(Pv(Cb)??wb)[e]}var se={fast:{type:"spring",duration:.08,bounce:0,exit:{duration:.06}},moderate:{type:"spring",duration:.16,bounce:0,exit:{duration:.12}},slow:{type:"spring",duration:.24,bounce:.12,exit:{duration:.16}}},ni=e=>Math.round(e.exit.duration*1e3)+100;var Nb={1:"bg-surface-1",2:"bg-surface-2",3:"bg-surface-3",4:"bg-surface-4",5:"bg-surface-5",6:"bg-surface-6",7:"bg-surface-7",8:"bg-surface-8"},kb={1:"shadow-surface-1",2:"shadow-surface-2",3:"shadow-surface-3",4:"shadow-surface-4",5:"shadow-surface-5",6:"shadow-surface-6",7:"shadow-surface-7",8:"shadow-surface-8"};function oi(e,t=e){let n=Math.round(Math.max(1,Math.min(8,e))),o=Math.round(Math.max(1,Math.min(8,t)));return`${Nb[n]} ${kb[o]}`}import{createContext as Sb,useContext as Tb}from"react";import{jsx as Pb}from"react/jsx-runtime";var om=Sb(1);function ri(){return Tb(om)}function si({value:e,children:t}){return Pb(om.Provider,{value:Math.max(1,Math.min(8,e)),children:t})}import{Dialog as Do}from"@base-ui/react/dialog";import{motion as rm}from"motion/react";import{createContext as Rb,forwardRef as Jl,useCallback as Mb,useContext as Gl,useLayoutEffect as Ib,useState as sm}from"react";import{jsx as Tt,jsxs as qs}from"react/jsx-runtime";var Eb=4,Ab="h-14",ai=Rb(null);function am({className:e}){let t=br("x");return Tt(Do.Close,{render:qs(E,{variant:"ghost",size:"icon-sm",className:e,children:[Tt(t,{}),Tt("span",{className:"sr-only",children:"Close"})]})})}function fn({children:e,open:t,defaultOpen:n,onOpenChange:o,modal:r}){return Tt(Do.Root,{open:t,defaultOpen:n,onOpenChange:s=>o?.(s),modal:r,children:e})}function Yl(e){return Tt(Do.Trigger,{"data-slot":"dialog-trigger",...e})}var on=Jl(({className:e,children:t,size:n="sm",scrollable:o=!1,container:r,...s},a)=>{let i=pt(),d=ri(),l=Math.min(d+Eb,8),[u,h]=sm(!1),c=Mb(m=>{h(m)},[]);return qs(Do.Portal,{container:r??void 0,children:[Tt(Do.Backdrop,{render:(m,p)=>{let x=p.transitionStatus==="ending",{style:f,onDrag:b,onDragStart:g,onDragEnd:v,onAnimationStart:y,onAnimationEnd:w,onAnimationIteration:N,...T}=m;return Tt(rm.div,{...T,className:C(r?"absolute":"fixed","inset-0 z-50 bg-black/40 dark:bg-black/80"),initial:{opacity:0},animate:{opacity:x?0:1},transition:x?se.slow.exit:se.slow})}}),Tt(Do.Popup,{ref:a,render:(m,p)=>{let x=p.transitionStatus==="ending",{style:f,onDrag:b,onDragStart:g,onDragEnd:v,onAnimationStart:y,onAnimationEnd:w,onAnimationIteration:N,...T}=m;return Tt(rm.div,{...T,...s,className:C(r?"absolute":"fixed","left-1/2 top-1/2 z-50 w-[calc(100%-2rem)]",oi(l),"p-6 focus:outline-none",n==="sm"&&"max-w-[400px]",n==="lg"&&"max-w-[540px]",i.container,o&&"flex flex-col overflow-hidden p-0",e),style:{...f,...s.style},initial:{opacity:0,scale:.97,x:"-50%",y:"-50%"},animate:{opacity:x?0:1,scale:x?.97:1,x:"-50%",y:"-50%"},transition:x?se.slow.exit:se.slow,children:Tt(si,{value:l,children:qs(ai.Provider,{value:{scrollable:o,setStickyHeader:c},children:[t,!u&&Tt(am,{className:"absolute right-3 top-3 z-20"})]})})})}})]})});on.displayName="DialogContent";function Qt({className:e,sticky:t,children:n,...o}){let r=Gl(ai);return Ib(()=>{if(t)return r?.setStickyHeader(!0),()=>r?.setStickyHeader(!1)},[t,r]),t?qs("div",{className:C("sticky top-0 z-10 mb-0 flex shrink-0 items-center gap-2 border-b border-border/50 bg-white/50 px-6 backdrop-blur-xs dark:bg-black/50",Ab,e),...o,children:[n,Tt(am,{className:"ml-auto shrink-0"})]}):Tt("div",{className:C("mb-4 flex flex-col gap-1.5",r?.scrollable&&"px-6 pt-6",e),...o,children:n})}function Hn({className:e,...t}){let n=Gl(ai);return Tt("div",{className:C("flex-1 min-h-0 overflow-y-auto overscroll-none pt-2",n?.scrollable?"px-6 pb-6":"-mx-6 px-6",e),...t})}function ii({className:e,onCopy:t,children:n,...o}){let r=br("copy"),s=br("check"),[a,i]=sm(!1),d=async()=>{if(t)try{await t(),i(!0),setTimeout(()=>i(!1),2e3)}catch{}};return qs("div",{className:C("group/json relative -mx-6 bg-muted/20 px-6 pt-6 pb-4",e),...o,children:[t?Tt("div",{className:"absolute top-2 right-2 z-10 opacity-0 transition-opacity group-hover/json:opacity-100",children:Tt(E,{variant:"ghost",size:"icon-sm",onClick:d,title:"Copy",children:a?Tt(s,{className:"text-green-600"}):Tt(r,{})})}):null,n]})}function li({className:e,...t}){let n=Gl(ai);return Tt("div",{className:C("mt-6 flex justify-end gap-2",n?.scrollable&&"px-6 pb-6",e),...t})}var qt=Jl(({className:e,...t},n)=>Tt(Do.Title,{ref:n,className:C("m-0 text-[16px] leading-none text-foreground",e),style:{fontVariationSettings:"'wght' 700"},...t}));qt.displayName="DialogTitle";var ho=Jl(({className:e,...t},n)=>Tt(Do.Description,{ref:n,className:C("text-[13px] text-muted-foreground",e),...t}));ho.displayName="DialogDescription";import*as gn from"react";import{Menu as _P}from"@base-ui/react/menu";import{CheckIcon as zP}from"lucide-react";import{useRef as ec,useState as tc,useEffect as Zl,useCallback as pm,useMemo as fm,createContext as jb,useContext as qb,forwardRef as ui}from"react";import{motion as wr,AnimatePresence as ns}from"motion/react";import{Menu as Oo}from"@base-ui/react/menu";import{createContext as Db,useContext as Lb,useRef as im,useEffect as lm,forwardRef as _b}from"react";import{motion as cm,AnimatePresence as Ob}from"motion/react";var yt={normal:"'wght' 400, 'opsz' 14",medium:"'wght' 450, 'opsz' 15",semibold:"'wght' 550, 'opsz' 20",bold:"'wght' 700, 'opsz' 25"},Lo="px-4 pt-3 pb-3",_o="text-[15px] text-foreground [font-variation-settings:'wght'_550,'opsz'_20]";function ci(e){return`sticky top-0 z-30 border-b bg-background/80 backdrop-blur-md transition-[border-color] duration-200 supports-[backdrop-filter]:bg-background/70 ${e?"border-border/80":"border-transparent"}`}import{Fragment as Hb,jsx as Zn,jsxs as Ql}from"react/jsx-runtime";var zb=Vs.rounded,di=Db(null);function Bb(){let e=Lb(di);if(!e)throw new Error("useDropdown must be used within a Dropdown");return e}var yr=_b(({icon:e,label:t,customContent:n,index:o,checked:r,onSelect:s,disabled:a,closeOnClick:i,className:d,onClick:l,...u},h)=>{let c=im(null),m=im(!1),{registerItem:p,activeIndex:x,checkedIndex:f,renderMenuItem:b}=Bb();lm(()=>(p(o,c.current),()=>p(o,null)),[o,p]),lm(()=>{m.current=!0},[]);let g=x===o,v=!m.current,y=P=>{c.current=P,typeof h=="function"?h(P):h&&(h.current=P)},w=a?void 0:P=>{l?.(P),s?.()},N=C(`relative z-10 flex h-9 items-center gap-2 ${zb.item} px-2 cursor-pointer outline-none`,a&&"opacity-50 pointer-events-none",d),T=t??(typeof n=="string"?n:"Menu item"),L=n??Ql(Hb,{children:[e&&Ql("span",{className:"inline-grid",children:[Zn("span",{className:"col-start-1 row-start-1 invisible",children:Zn(e,{size:16,strokeWidth:2})}),Zn(e,{size:16,strokeWidth:g||r?2:1.5,className:C("col-start-1 row-start-1 transition-[color,stroke-width] duration-80",g||r?"text-foreground":"text-muted-foreground")})]}),Ql("span",{className:"inline-grid flex-1 text-[13px]",children:[Zn("span",{className:"col-start-1 row-start-1 invisible [text-box:trim-both_cap_alphabetic]",style:{fontVariationSettings:yt.semibold},"aria-hidden":"true",children:T}),Zn("span",{className:C("col-start-1 row-start-1 transition-[color,font-variation-settings] duration-80 [text-box:trim-both_cap_alphabetic]",g||r?"text-foreground":"text-muted-foreground"),style:{fontVariationSettings:r?yt.semibold:yt.normal},children:T})]}),Zn(Ob,{children:r&&Zn(cm.svg,{width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",className:"text-foreground shrink-0",initial:{opacity:1},animate:{opacity:1},exit:{opacity:1},children:Zn(cm.path,{d:"M4 12L9 17L20 6",initial:{pathLength:v?1:0},animate:{pathLength:1,transition:{duration:.08,ease:"easeOut"}},exit:{pathLength:0,transition:{duration:.04,ease:"easeIn"}}})},"check")})]});return b?b({radio:typeof r=="boolean",value:o,disabled:a,label:T,closeOnClick:i??!0,element:Zn("div",{ref:y,"data-proximity-index":o,"aria-label":T,onClick:w,className:N,...u}),children:L}):Zn("div",{ref:y,"data-proximity-index":o,tabIndex:!a&&o===(f??0)?0:-1,role:typeof r=="boolean"?"menuitemradio":"menuitem","aria-checked":typeof r=="boolean"?r:void 0,"aria-disabled":a||void 0,"aria-label":T,onClick:w,onKeyDown:P=>{a||(P.key===" "||P.key==="Enter")&&(P.preventDefault(),s?.())},className:N,...u,children:L})});yr.displayName="MenuItem";import{useRef as Zr,useState as dm,useCallback as es,useEffect as Xl}from"react";function um(e,t){let n=e.getBoundingClientRect(),o=t==="x"?e.offsetWidth:e.offsetHeight,r=t==="x"?n.width:n.height;return o>0?r/o:1}function Ub(e,t){let n=e.getBoundingClientRect(),o=um(e,"x"),r=um(e,"y"),s=[];return t.forEach((a,i)=>{let d=a.getBoundingClientRect();s[i]={top:(d.top-n.top)/r+e.scrollTop,left:(d.left-n.left)/o+e.scrollLeft,width:a.offsetWidth,height:a.offsetHeight}}),s}function Fb(e,t,n,o){let r=o==="x"?t:n,s=null,a=1/0,i=null;return e.forEach((d,l)=>{let u=d.getBoundingClientRect(),h=o==="x"?u.left:u.top,c=o==="x"?u.right:u.bottom;r>=h&&r<=c&&(i=l);let m=(h+c)/2,p=Math.abs(r-m);p<a&&(a=p,s=l)}),i??s}function $b(e,t){if(e.length!==t.length)return!0;for(let n=0;n<t.length;n++){let o=e[n],r=t[n];if(o!==r&&(!o||!r||o.top!==r.top||o.left!==r.left||o.width!==r.width||o.height!==r.height))return!0}return!1}function xr(e,t={}){let{axis:n="y"}=t,o=Zr(new Map),[r,s]=dm(null),[a,i]=dm([]),d=Zr([]),l=Zr(0),u=Zr(null),h=Zr(null),c=Zr(null),m=es(()=>{let v=e.current;if(!v)return;let y=Ub(v,o.current);$b(d.current,y)&&(d.current=y,i(y))},[e]),p=es((v,y)=>{s(Fb(o.current,v,y,n))},[n]),x=es((v,y)=>{y?o.current.set(v,y):o.current.delete(v),h.current!==null&&cancelAnimationFrame(h.current),h.current=requestAnimationFrame(()=>{h.current=null,m()})},[m]),f=es(v=>{c.current={x:v.clientX,y:v.clientY},u.current!==null&&cancelAnimationFrame(u.current),u.current=requestAnimationFrame(()=>{u.current=null,m(),p(v.clientX,v.clientY)})},[m,p]),b=es(()=>{l.current+=1},[]),g=es(()=>{u.current!==null&&(cancelAnimationFrame(u.current),u.current=null),c.current=null,s(null)},[]);return Xl(()=>{let v=e.current;if(!v||typeof ResizeObserver>"u")return;let y=new ResizeObserver(()=>{h.current!==null&&cancelAnimationFrame(h.current),h.current=requestAnimationFrame(()=>{h.current=null,m()})});return y.observe(v),()=>y.disconnect()},[e,m]),Xl(()=>{let v=e.current;if(!v)return;let y=()=>{m();let w=c.current;w&&p(w.x,w.y)};return v.addEventListener("scroll",y,{capture:!0,passive:!0}),()=>v.removeEventListener("scroll",y,{capture:!0})},[e,m,p]),Xl(()=>()=>{u.current!==null&&cancelAnimationFrame(u.current),h.current!==null&&cancelAnimationFrame(h.current)},[]),{activeIndex:r,setActiveIndex:s,itemRects:a,sessionRef:l,handlers:{onMouseMove:f,onMouseEnter:b,onMouseLeave:g},registerItem:x,measureItems:m}}import{forwardRef as Vb}from"react";import{jsx as mm}from"react/jsx-runtime";var ts=Vb(({offset:e,shadowLevel:t,className:n,children:o,...r},s)=>{let a=ri(),i=Math.min(a+e,8);return mm(si,{value:i,children:mm("div",{ref:s,className:C(oi(i,t??i),n),...r,children:o})})});ts.displayName="Elevated";import{jsx as it,jsxs as bm}from"react/jsx-runtime";var zo=Vs.rounded,Wb=ui(({children:e,checkedIndex:t,className:n,...o},r)=>{let s=ec(null),{activeIndex:a,setActiveIndex:i,itemRects:d,sessionRef:l,handlers:u,registerItem:h,measureItems:c}=xr(s);Zl(()=>{c()},[c,e]);let[m,p]=tc(null),x=a!==null?d[a]:null,f=t!=null?d[t]:null,b=m!==null?d[m]:null,g=a!==null&&a!==t;return it(di.Provider,{value:{registerItem:h,activeIndex:a,checkedIndex:t},children:bm(ts,{offset:2,shadowLevel:3,ref:v=>{s.current=v,typeof r=="function"?r(v):r&&(r.current=v)},onMouseEnter:u.onMouseEnter,onMouseMove:u.onMouseMove,onMouseLeave:u.onMouseLeave,onFocus:v=>{let y=v.target.closest("[data-proximity-index]")?.getAttribute("data-proximity-index");if(y!=null){let w=Number(y);i(w),p(v.target.matches(":focus-visible")?w:null)}},onBlur:v=>{s.current?.contains(v.relatedTarget)||(p(null),i(null))},onKeyDown:v=>{let y=Array.from(s.current?.querySelectorAll('[role="menuitem"], [role="menuitemradio"]')??[]),w=y.indexOf(v.target);if(w!==-1)if(["ArrowDown","ArrowUp","ArrowRight","ArrowLeft"].includes(v.key)){v.preventDefault();let N=["ArrowDown","ArrowRight"].includes(v.key)?(w+1)%y.length:(w-1+y.length)%y.length;y[N].focus()}else v.key==="Home"?(v.preventDefault(),y[0]?.focus()):v.key==="End"&&(v.preventDefault(),y[y.length-1]?.focus())},role:"group",className:C(`relative flex flex-col gap-0.5 w-72 max-w-full ${zo.container} p-1 select-none`,n),...o,children:[it(ns,{children:f&&it(wr.div,{className:`absolute ${zo.bg} bg-active pointer-events-none`,initial:!1,animate:{top:f.top,left:f.left,width:f.width,height:f.height,opacity:g?.8:1},exit:{opacity:0,transition:se.moderate.exit},transition:{...se.moderate,opacity:{duration:.08}}})}),it(ns,{children:x&&it(wr.div,{className:`absolute ${zo.bg} bg-hover pointer-events-none`,initial:{opacity:0,top:f?.top??x.top,left:f?.left??x.left,width:f?.width??x.width,height:f?.height??x.height},animate:{opacity:1,top:x.top,left:x.left,width:x.width,height:x.height},exit:{opacity:0,transition:se.fast.exit},transition:{...se.fast,opacity:{duration:.08}}},l.current)}),it(ns,{children:b&&it(wr.div,{className:`absolute ${zo.focusRing} pointer-events-none z-20 border border-[color:var(--focus-ring,#6B97FF)]`,initial:!1,animate:{left:b.left-2,top:b.top-2,width:b.width+4,height:b.height+4},exit:{opacity:0,transition:se.fast.exit},transition:{...se.fast,opacity:{duration:.08}}})}),e]})})});Wb.displayName="Dropdown";var gm=jb(null);function Kb(){let e=qb(gm);if(!e)throw new Error("DropdownMenu compound components must be inside <DropdownMenu>");return e}function nc({children:e,open:t,defaultOpen:n=!1,onOpenChange:o,disabled:r=!1}){let[s,a]=tc(n),i=t!==void 0?t:s,d=ec(null),l=pm(h=>{t===void 0&&a(h),o?.(h)},[t,o]),u=fm(()=>({open:i,actionsRef:d}),[i]);return it(gm.Provider,{value:u,children:it(Oo.Root,{open:i,onOpenChange:l,actionsRef:d,disabled:r,modal:!1,children:e})})}nc.displayName="DropdownMenu";var hm=Oo.Trigger,oc=ui(({className:e,children:t,checkedIndex:n,side:o="bottom",align:r="start",sideOffset:s=6},a)=>{let{open:i,actionsRef:d}=Kb(),l=ec(null),{activeIndex:u,setActiveIndex:h,itemRects:c,sessionRef:m,handlers:p,registerItem:x,measureItems:f}=xr(l),[b,g]=tc(null);Zl(()=>{if(i)return;let P=setTimeout(()=>d.current?.unmount(),ni(se.fast));return()=>clearTimeout(P)},[i,d]),Zl(()=>{if(!i)return;let P,R=requestAnimationFrame(()=>{P=requestAnimationFrame(()=>{f()})});return()=>{cancelAnimationFrame(R),cancelAnimationFrame(P)}},[i,f]);let v=u!==null?c[u]:null,y=n!=null?c[n]:null,w=b!==null?c[b]:null,N=u!==null&&u!==n,T=pm(({radio:P,value:R,disabled:D,label:k,closeOnClick:S,element:A,children:_})=>P?it(Oo.RadioItem,{value:R,disabled:D,label:k,closeOnClick:S,render:A,children:_}):it(Oo.Item,{disabled:D,label:k,closeOnClick:S,render:A,children:_}),[]),L=fm(()=>({registerItem:x,activeIndex:u,checkedIndex:n,inMenu:!0,renderMenuItem:T}),[x,u,n,T]);return it(Oo.Portal,{children:it(Oo.Positioner,{side:o,align:r,sideOffset:s,className:"z-50 outline-none",children:it(wr.div,{initial:{opacity:0,y:-4,scaleY:.96},animate:i?{opacity:1,y:0,scaleY:1}:{opacity:0,y:-4,scaleY:.96},transition:i?se.fast:se.fast.exit,style:{transformOrigin:"top center"},onAnimationComplete:()=>{i||d.current?.unmount()},children:it(di.Provider,{value:L,children:bm(Oo.Popup,{render:it(ts,{offset:2,shadowLevel:3,ref:P=>{l.current=P,typeof a=="function"?a(P):a&&(a.current=P)}}),onMouseEnter:()=>{p.onMouseEnter(),g(null)},onMouseMove:p.onMouseMove,onMouseLeave:p.onMouseLeave,onFocus:P=>{let R=P.target.closest("[data-proximity-index]")?.getAttribute("data-proximity-index");if(R!=null){let D=Number(R);h(D),g(P.target.matches(":focus-visible")?D:null)}},onBlur:P=>{l.current?.contains(P.relatedTarget)||(g(null),h(null))},className:C(`relative flex flex-col gap-0.5 w-72 max-w-full min-w-[var(--anchor-width)] max-h-[min(480px,var(--available-height))] overflow-y-auto ${zo.container} p-1 select-none outline-none`,e),children:[it(ns,{children:y&&it(wr.div,{className:`absolute ${zo.bg} bg-active pointer-events-none`,initial:!1,animate:{top:y.top,left:y.left,width:y.width,height:y.height,opacity:N?.8:1},exit:{opacity:0,transition:se.moderate.exit},transition:{...se.moderate,opacity:{duration:.08}}})}),it(ns,{children:v&&it(wr.div,{className:`absolute ${zo.bg} bg-hover pointer-events-none`,initial:{opacity:0,top:y?.top??v.top,left:y?.left??v.left,width:y?.width??v.width,height:y?.height??v.height},animate:{opacity:1,top:v.top,left:v.left,width:v.width,height:v.height},exit:{opacity:0,transition:se.fast.exit},transition:{...se.fast,opacity:{duration:.08}}},m.current)}),it(ns,{children:w&&it(wr.div,{className:`absolute ${zo.focusRing} pointer-events-none z-20 border border-[color:var(--focus-ring,#6B97FF)]`,initial:!1,animate:{left:w.left-2,top:w.top-2,width:w.width+4,height:w.height+4},exit:{opacity:0,transition:se.fast.exit},transition:{...se.fast,opacity:{duration:.08}}})}),n!=null?it(Oo.RadioGroup,{value:n,className:"contents",children:t}):t]})})})})})});oc.displayName="DropdownContent";var vm=ui(({className:e,...t},n)=>it("div",{ref:n,className:C("px-2 py-1.5 text-[11px] text-muted-foreground",e),...t}));vm.displayName="DropdownLabel";var rc=ui(({className:e,...t},n)=>it("div",{ref:n,role:"separator",className:C("my-1 -mx-1 h-px bg-border/60",e),...t}));rc.displayName="DropdownSeparator";import{jsx as Bo,jsxs as $P}from"react/jsx-runtime";var ym=gn.createContext(null);function Jb(){let e=gn.useContext(ym);if(!e)throw new Error("Dropdown menu items must be inside DropdownMenuContent");return e.next()}function sc(e){return typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map(sc).filter(Boolean).join(" ").trim():gn.isValidElement(e)?sc(e.props.children):"Menu item"}function Cr(e){return Bo(nc,{"data-slot":"dropdown-menu",...e})}function Ho(e){return Bo(hm,{"data-slot":"dropdown-menu-trigger",...e})}function Nr({className:e,align:t="start",side:n="bottom",sideOffset:o=6,children:r,forceMount:s,...a}){let i=gn.useRef(0),d=gn.useMemo(()=>({next:()=>i.current++}),[]);return i.current=0,Bo(ym.Provider,{value:d,children:Bo(oc,{"data-slot":"dropdown-menu-content",className:e,align:t,side:n,sideOffset:o,...a,children:r})})}function Nn({className:e,inset:t,variant:n="default",render:o,children:r,onSelect:s,onClick:a,disabled:i,...d}){let l=Jb(),u=sc(o??r),h=()=>{s?.(new Event("select"))};if(o&&gn.isValidElement(o)){let c=o;return Bo(yr,{index:l,label:u,disabled:i,customContent:gn.cloneElement(c,{className:C("relative z-10 flex h-9 w-full items-center gap-2 rounded-lg px-2 text-[13px] outline-none",t&&"pl-8",n==="destructive"&&"text-destructive",c.props.className,e),onClick:m=>{c.props.onClick?.(m),a?.(m),m.defaultPrevented||h()}}),onSelect:h,...d})}return Bo(yr,{index:l,label:u,disabled:i,className:C(t&&"pl-8",n==="destructive"&&"text-destructive",e),customContent:Bo("span",{className:"flex w-full min-w-0 items-center gap-2 text-[13px] text-inherit",children:r}),onClick:a,onSelect:h,...d})}function xm({className:e,...t}){return Bo(rc,{"data-slot":"dropdown-menu-separator",className:e,...t})}function eo(e){return e.replace(/[^a-zA-Z0-9-_]/g,"_").toLowerCase()}function mi(e){return`'${e.replace(/'/g,"'\\''")}'`}function kr(e){return e.replace(/[^a-zA-Z0-9]/g,"_").toUpperCase().replace(/^_+|_+$/g,"")}function wm(e,t,n){let o={url:e};if(n&&Object.keys(n).length>0){let a={};for(let[i]of Object.entries(n)){let d=kr(i);a[i]=`{{${d}}}`}o.headers=a}let r=JSON.stringify(o);return`cursor://anysphere.cursor-deeplink/mcp/install?config=${btoa(r)}&name=${encodeURIComponent(eo(t))}`}function Cm(e,t,n){let o={url:e,name:eo(t),type:"http"};if(n&&Object.keys(n).length>0){let a={};for(let[i]of Object.entries(n)){let d=kr(i);a[i]=`your-${d}-value`}o.headers=a}let r=JSON.stringify(o);return`vscode:mcp/install?${encodeURIComponent(r)}`}function Nm(e,t,n){let o={url:e,name:eo(t),type:"http"};if(n&&Object.keys(n).length>0){let a={};for(let[i]of Object.entries(n)){let d=kr(i);a[i]=`your-${d}-value`}o.headers=a}let r=JSON.stringify(o);return`vscode-insiders:mcp/install?${encodeURIComponent(r)}`}function Gb(e,t,n){let o={url:e,name:eo(t)};if(n&&Object.keys(n).length>0){let r={};for(let[s]of Object.entries(n)){let a=kr(s);r[s]=`your-${a}-value`}o.headers=r}return o}function km(e,t,n){try{let o=Gb(e,t,n),r=JSON.stringify(o,null,2),s=globalThis.Blob,a=new s([r],{type:"application/json"}),i=URL.createObjectURL(a),d=document.createElement("a");d.href=i,d.download=`${eo(t)}.mcpb`,document.body.appendChild(d),d.click(),document.body.removeChild(d),URL.revokeObjectURL(i)}catch(o){throw console.error("Failed to download .mcpb file:",o),o}}function Sm(e,t,n){let r=`claude mcp add --transport http "${eo(t)}" \\
|
|
2
2
|
${mi(e)}`,s=[];if(n&&Object.keys(n).length>0)for(let[a]of Object.entries(n)){let i=kr(a);r+=` \\
|
|
3
|
-
--header ${mi(`${a}:\${${i}}`)}`,s.push({name:i,header:a})}return{command:r,envVars:s}}function
|
|
4
|
-
--header ${mi(`${a}:\${${i}}`)}`,s.push({name:i,header:a})}return{command:r,envVars:s}}function
|
|
3
|
+
--header ${mi(`${a}:\${${i}}`)}`,s.push({name:i,header:a})}return{command:r,envVars:s}}function Tm(e,t,n){let r=`gemini mcp add --transport http "${eo(t)}" ${mi(e)}`,s=[];if(n&&Object.keys(n).length>0)for(let[a]of Object.entries(n)){let i=kr(a);r+=` \\
|
|
4
|
+
--header ${mi(`${a}:\${${i}}`)}`,s.push({name:i,header:a})}return{command:r,envVars:s}}function Pm(e,t,n){let r=`[mcp_servers.${eo(t)}]
|
|
5
5
|
url = "${e}"`,s=[];if(n&&Object.keys(n).length>0){let a=[];for(let[i]of Object.entries(n)){let d=kr(i);a.push(`"${i}" = "your-${d}-value"`),s.push({name:d,header:i})}if(r+=`
|
|
6
6
|
http_headers = { ${a.join(", ")} }`,s.length>0){r+=`
|
|
7
7
|
|
|
@@ -9,7 +9,7 @@ http_headers = { ${a.join(", ")} }`,s.length>0){r+=`
|
|
|
9
9
|
# env_http_headers = { `;let i=s.map(({name:d,header:l})=>`"${l}" = "${d}"`);r+=i.join(", "),r+=" }"}}return{config:r,envVars:s}}function ac(e){if(e.length===0)return"";let t=`Set these environment variables in your shell:
|
|
10
10
|
|
|
11
11
|
`;for(let{name:n}of e)t+=`export ${n}="your-${n}-value"
|
|
12
|
-
`;return t}function
|
|
12
|
+
`;return t}function jP(e,t,n,o){let r=n||eo(t),s={url:e};o&&Object.keys(o).length>0&&(s.headers=o);let i=JSON.stringify(s,null,4).split(`
|
|
13
13
|
`).map((d,l)=>l===0?d:" "+d).join(`
|
|
14
14
|
`);return`import { MCPClient } from "@mcp-use/client";
|
|
15
15
|
|
|
@@ -33,7 +33,7 @@ console.log('Available resources:', resources.map(resource => resource.uri));
|
|
|
33
33
|
// const result = await connection.callTool("toolName", { param: "value" });
|
|
34
34
|
|
|
35
35
|
// Read a resource (example)
|
|
36
|
-
// const resourceContent = await connection.readResource("resource-uri");`}function
|
|
36
|
+
// const resourceContent = await connection.readResource("resource-uri");`}function qP(e,t,n,o){let r=n||eo(t),s={url:e};o&&Object.keys(o).length>0&&(s.headers=o);let i=JSON.stringify(s,null,4).split(`
|
|
37
37
|
`).map((d,l)=>l===0?d:" "+d).join(`
|
|
38
38
|
`);return`from mcp_use import MCPClient
|
|
39
39
|
|
|
@@ -59,12 +59,12 @@ print(f"Available resources: {[resource.name for resource in resources]}")
|
|
|
59
59
|
# result = await session.call_tool("tool_name", {"param": "value"})
|
|
60
60
|
|
|
61
61
|
# Read a resource (example)
|
|
62
|
-
# resource_content = await session.read_resource("resource_uri")`}function Qb(e){let t=document.createElement("textarea");t.value=e,t.style.cssText="position:fixed;top:-9999px;left:-9999px;opacity:0",document.body.appendChild(t),t.focus(),t.select();try{return document.execCommand("copy")}finally{document.body.removeChild(t)}}async function Xe(e){if(!Qb(e)){if(navigator.clipboard?.writeText)return navigator.clipboard.writeText(e);throw new Error("copy failed")}}function Im(e){if(e==null)return"/mcp";let t=e.trim().replace(/\/{2,}/g,"/").replace(/\/+$/,"");return t===""||t==="/"?"":(t.startsWith("/")||(t=`/${t}`),t)}function Xb(){if(typeof window>"u")return"";let e=window.location.pathname||"",n=e.indexOf("/inspector");return n<=0?"":Im(e.slice(0,n))}function Zb(){if(typeof window>"u")return"";let e=window.__MCP_BASE_PATH__;return e!=null?Im(e):Xb()}function Ws(){return`${Zb()}/inspector`}function Em(e){let t=e.replace(/^\/+/,"");return`${Ws()}/api/${t}`}function Ks(e){let t=typeof window>"u"?void 0:window.__MCP_INSPECTOR_MODE__;return typeof window<"u"&&t!=="cloud"?`${Ws()}/assets/providers/${e}`:`https://inspector-cdn.mcp-use.com/providers/${e}`}import{Check as lc,ChevronDown as ey,Copy as cc,Plus as ty}from"lucide-react";import{useState as dc,isValidElement as ny}from"react";import{jsx as Am,jsxs as ZP}from"react/jsx-runtime";function ic({className:e}){return Am("svg",{viewBox:"0 0 24 24",className:e,fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:Am("path",{d:"M23.15 2.587L18.21.21a1.494 1.494 0 0 0-1.705.29l-9.46 8.63-4.12-3.128a.999.999 0 0 0-1.276.057L.327 7.261A1 1 0 0 0 .326 8.74L3.899 12 .326 15.26a1 1 0 0 0 .001 1.479L1.65 17.94a.999.999 0 0 0 1.276.057l4.12-3.128 9.46 8.63a1.492 1.492 0 0 0 1.704.29l4.942-2.377A1.5 1.5 0 0 0 24 20.06V3.939a1.5 1.5 0 0 0-.85-1.352zm-5.146 14.861L10.826 12l7.178-5.448v10.896z"})})}import{Fragment as pi,jsx as te,jsxs as Me}from"react/jsx-runtime";var Uo="flex h-10 items-center gap-2";function oy({serverConfig:e,additionalItems:t=[],showClients:n={cursor:!0,vsCode:!0,vsCodeInsiders:!0,claudeDesktop:!0,claudeCode:!0,geminiCli:!0,codexCli:!0},className:o="",onSuccess:r,onError:s,trigger:a}){let[i,d]=dc(!1),[l,u]=dc(null),[h,c]=dc(!1),{url:m,name:p,headers:x}=e,f=S=>{try{Lt(new ei({client:S})).catch(()=>{})}catch{}},b=()=>{f("cursor");try{let S=Nm(m,p,x);window.location.href=S,r?.("Cursor")}catch(S){console.error("Failed to generate Cursor deep link:",S),s?.(S)}},g=()=>{f("vscode");try{let S=km(m,p,x);window.location.href=S,r?.("VS Code")}catch(S){console.error("Failed to generate VS Code deep link:",S),s?.(S)}},v=()=>{f("vscode-insiders");try{let S=Sm(m,p,x);window.location.href=S,r?.("VS Code Insiders")}catch(S){console.error("Failed to generate VS Code Insiders deep link:",S),s?.(S)}},y=()=>{f("claude-desktop");try{Tm(m,p,x),r?.("Claude Desktop")}catch(S){console.error("Failed to download .mcpb file:",S),s?.(S)}},w=()=>{f("claude-code"),u("claude-code"),d(!0)},N=()=>{f("gemini-cli"),u("gemini-cli"),d(!0)},T=()=>{f("codex-cli"),u("codex-cli"),d(!0)},L=async S=>{try{await Xe(S),c(!0),setTimeout(()=>c(!1),2e3)}catch(A){console.error("Failed to copy:",A),s?.(A)}},P=()=>{if(l==="claude-code"){let{command:S,envVars:A}=Pm(m,p,x),_=ac(A);return Me(pi,{children:[Me(Qt,{children:[te(qt,{children:"Add to Claude Code"}),te(ho,{children:"Execute the following command in your shell to add this server to Claude Code."})]}),Me(Un,{className:"space-y-4",children:[Me("div",{children:[te("h5",{className:"font-semibold text-sm mb-2",children:"Instructions"}),Me("ol",{className:"space-y-2 text-xs text-muted-foreground",children:[Me("li",{className:"flex gap-2",children:[te("span",{className:"font-semibold text-foreground",children:"1."}),te("span",{children:"Ensure the Claude Code executable is available in your path"})]}),Me("li",{className:"flex gap-2",children:[te("span",{className:"font-semibold text-foreground",children:"2."}),te("span",{children:"Execute the following snippet in your shell:"})]})]})]}),Me("div",{className:"relative",children:[te("div",{className:"absolute top-2 right-2 z-10",children:te(E,{variant:"ghost",size:"sm",className:"h-7 px-2 bg-background hover:bg-accent border border-border",onClick:()=>L(S),children:h?te(lc,{className:"size-3.5 text-green-600"}):te(cc,{className:"size-3.5"})})}),te("pre",{className:"bg-muted p-3 pr-14 rounded-md text-xs overflow-x-auto",children:te("code",{children:S})})]}),_&&Me("div",{children:[te("h5",{className:"font-semibold text-sm mb-2",children:"Environment Variables"}),te("p",{className:"text-xs text-muted-foreground mb-2",children:"After installation, set these environment variables in your shell:"}),te("pre",{className:"bg-muted p-3 rounded-md text-xs overflow-x-auto",children:te("code",{children:_})})]}),Me("p",{className:"text-xs text-muted-foreground",children:["The MCP configuration supports environment variable expansion using ",te("code",{className:"text-foreground",children:"${VAR}"})," ","syntax."]})]})]})}if(l==="gemini-cli"){let{command:S,envVars:A}=Rm(m,p,x),_=ac(A);return Me(pi,{children:[Me(Qt,{children:[te(qt,{children:"Add to Gemini CLI"}),te(ho,{children:"Execute the following command in your shell to add this server to Gemini CLI."})]}),Me(Un,{className:"space-y-4",children:[Me("div",{children:[te("h5",{className:"font-semibold text-sm mb-2",children:"Instructions"}),Me("ol",{className:"space-y-2 text-xs text-muted-foreground",children:[Me("li",{className:"flex gap-2",children:[te("span",{className:"font-semibold text-foreground",children:"1."}),te("span",{children:"Ensure the Gemini CLI executable is available in your path"})]}),_&&Me("li",{className:"flex gap-2",children:[te("span",{className:"font-semibold text-foreground",children:"2."}),te("span",{children:"Set these environment variables in your shell before running the command:"})]}),Me("li",{className:"flex gap-2",children:[te("span",{className:"font-semibold text-foreground",children:_?"3.":"2."}),te("span",{children:"Execute the following snippet in your shell:"})]})]})]}),_&&Me("div",{children:[te("h5",{className:"font-semibold text-sm mb-2",children:"Environment Variables"}),te("pre",{className:"bg-muted p-3 rounded-md text-xs overflow-x-auto",children:te("code",{children:_})})]}),Me("div",{className:"relative",children:[te("div",{className:"absolute top-2 right-2 z-10",children:te(E,{variant:"ghost",size:"sm",className:"h-7 px-2 bg-background hover:bg-accent border border-border",onClick:()=>L(S),children:h?te(lc,{className:"size-3.5 text-green-600"}):te(cc,{className:"size-3.5"})})}),te("pre",{className:"bg-muted p-3 pr-14 rounded-md text-xs overflow-x-auto",children:te("code",{children:S})})]}),te("p",{className:"text-xs text-muted-foreground",children:"Restart Gemini CLI to load the new configuration."})]})]})}if(l==="codex-cli"){let{config:S,envVars:A}=Mm(m,p,x);return Me(pi,{children:[Me(Qt,{children:[te(qt,{children:"Add to Codex CLI"}),Me(ho,{children:["Add this configuration to your"," ",te("code",{className:"text-foreground",children:"~/.codex/config.toml"})," ","file."]})]}),Me(Un,{className:"space-y-4",children:[Me("div",{children:[te("h5",{className:"font-semibold text-sm mb-2",children:"Instructions"}),Me("p",{className:"text-xs text-muted-foreground",children:["Add this configuration to your"," ",te("code",{className:"text-foreground",children:"~/.codex/config.toml"}),":"]})]}),Me("div",{className:"relative",children:[te("div",{className:"absolute top-2 right-2 z-10",children:te(E,{variant:"ghost",size:"sm",className:"h-7 px-2 bg-background hover:bg-accent border border-border",onClick:()=>L(S),children:h?te(lc,{className:"size-3.5 text-green-600"}):te(cc,{className:"size-3.5"})})}),te("pre",{className:"bg-muted p-3 pr-14 rounded-md text-xs overflow-x-auto",children:te("code",{children:S})})]}),A.length>0&&te("div",{children:Me("p",{className:"text-xs text-muted-foreground",children:["(optional) If you would rather use variables from your system's environment, replace the"," ",te("code",{className:"text-foreground",children:"http_headers"})," key with the ",te("code",{className:"text-foreground",children:"env_http_headers"})," ","key as shown in the commented section above."]})}),te("p",{className:"text-xs text-muted-foreground",children:"Restart Codex CLI to load the new configuration."})]})]})}return null},R=Me(E,{variant:"ghost",className:`bg-zinc-200 dark:bg-zinc-800 hover:bg-zinc-300 dark:hover:bg-zinc-700 rounded-full transition-colors px-3 flex items-center justify-center ${o}`,children:[Me("span",{className:"xl:hidden hidden sm:flex items-center gap-1",children:[te(ty,{className:"size-3"}),"Client"]}),Me("span",{className:"hidden xl:flex items-center gap-1",children:["Add to Client",te(ey,{className:"size-3"})]})]}),D=a?typeof a=="function"?a({isOpen:!1,onClick:()=>{}}):a:R,k=ny(D)?D:R;return Me(pi,{children:[Me(Cr,{children:[te(Ho,{render:k,nativeButton:!0}),Me(Nr,{align:"end",className:"w-auto min-w-[300px]",children:[t.map(S=>Me(Nn,{onClick:async()=>{await S.onClick()},className:Uo,children:[S.icon,te("span",{className:"min-w-0 max-w-full whitespace-nowrap",children:S.label})]},S.id)),t.length>0&&te(Cm,{}),n.cursor&&Me(Nn,{onClick:b,className:Uo,children:[te("img",{src:"https://cdn.simpleicons.org/cursor",alt:"Cursor",className:"h-4 w-4"}),te("span",{className:"min-w-0 max-w-full whitespace-nowrap",children:"Cursor"})]}),n.claudeCode&&Me(Nn,{onClick:w,className:Uo,children:[te("img",{src:"https://cdn.simpleicons.org/claude",alt:"Claude",className:"h-4 w-4"}),te("span",{className:"min-w-0 max-w-full whitespace-nowrap",children:"Claude Code"})]}),n.claudeDesktop&&Me(Nn,{onClick:y,className:Uo,children:[te("img",{src:"https://cdn.simpleicons.org/claude",alt:"Claude",className:"h-4 w-4"}),te("span",{className:"min-w-0 max-w-full whitespace-nowrap",children:"Claude Desktop"})]}),n.vsCode&&Me(Nn,{onClick:g,className:Uo,children:[te(ic,{className:"h-4 w-4 text-blue-500"}),te("span",{className:"min-w-0 max-w-full whitespace-nowrap",children:"VS Code"})]}),n.vsCodeInsiders&&Me(Nn,{onClick:v,className:Uo,children:[te(ic,{className:"h-4 w-4 text-teal-400"}),te("span",{className:"min-w-0 max-w-full whitespace-nowrap",children:"VS Code Insiders"})]}),n.geminiCli&&Me(Nn,{onClick:N,className:Uo,children:[te("img",{src:"https://cdn.simpleicons.org/googlegemini",alt:"Gemini",className:"h-4 w-4"}),te("span",{className:"min-w-0 max-w-full whitespace-nowrap",children:"Gemini CLI"})]}),n.codexCli&&Me(Nn,{onClick:T,className:Uo,children:[te("img",{src:Ks("openai.png"),alt:"Codex",className:"h-4 w-4"}),te("span",{className:"min-w-0 max-w-full whitespace-nowrap",children:"Codex CLI"})]})]})]}),te(fn,{open:i,onOpenChange:d,children:te(on,{scrollable:!0,className:"max-w-3xl max-h-[80vh]",children:P()})})]})}import{jsx as ry}from"react/jsx-runtime";function Ge({className:e,type:t,...n}){return ry("input",{type:t,"data-slot":"input",className:C("file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm","focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]","aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",e),...n})}import{jsx as sy}from"react/jsx-runtime";function nt({className:e,...t}){return sy("label",{"data-slot":"label",className:C("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",e),...t})}import{forwardRef as gc,useRef as fi,useState as fc,useEffect as Dm,useCallback as uc,useId as ay}from"react";import{motion as iy,useMotionValue as ly,animate as mc}from"motion/react";import{Switch as vi}from"@base-ui/react/switch";import{jsx as Fo,jsxs as py}from"react/jsx-runtime";var hi=34,cy=20,vo=16,Xt=2,gi=hi-vo-Xt*2,dy=2,pc=4,Lm=4,uy=2;function my(e){return"label"in e&&typeof e.label=="string"}var _m=gc(({label:e,checked:t,onToggle:n,disabled:o=!1,thumbTransition:r,uncheckedTrackColor:s,uncheckedTrackColorHovered:a,className:i,...d},l)=>{let u=ay(),h=fi(!1),[c,m]=fc(!1),[p,x]=fc(!1),f=fi(!1),b=fi(!1),g=fi(null),v=ly(t?Xt+gi:Xt);Dm(()=>{h.current=!0},[]);let y=p?vo+pc:c?vo+dy:vo,w=p?vo-Lm:vo,N=p?Xt+Lm/2:Xt,T=y-vo,L=t?Xt+gi-T:Xt;Dm(()=>{f.current||(h.current?mc(v,L,r??se.moderate):v.set(L))},[L,v,r]);let P=uc(k=>{o||k.pointerType==="mouse"&&k.button!==0||(x(!0),f.current=!1,b.current=!1,g.current={clientX:k.clientX,originX:v.get()},k.currentTarget.setPointerCapture(k.pointerId))},[o,v]),R=uc(k=>{if(!g.current)return;let S=k.clientX-g.current.clientX;if(!f.current){if(Math.abs(S)<uy)return;f.current=!0}let A=Xt,_=vo+pc,K=hi-Xt-_,$=g.current.originX+S;v.set(Math.max(A,Math.min(K,$)))},[v]),D=uc(k=>{if(g.current){if(x(!1),f.current){if(b.current=!0,f.current=!1,k){let S=v.get(),A=Xt,_=vo+pc,K=hi-Xt-_,$=(A+K)/2;if(S>$!==t)n();else{let ae=t?Xt+gi:Xt;mc(v,ae,r??se.moderate)}}requestAnimationFrame(()=>{b.current=!1})}g.current=null}},[t,n,v,r]);return py("div",{ref:l,className:C("relative z-10 flex items-center gap-2.5 px-3 py-2 cursor-pointer select-none touch-none",o&&"opacity-50 pointer-events-none",i),onPointerEnter:k=>{k.pointerType==="mouse"&&m(!0)},onPointerLeave:()=>m(!1),onPointerDown:P,onPointerMove:R,onPointerUp:()=>D(!0),onPointerCancel:()=>{if(g.current){if(x(!1),f.current){f.current=!1;let k=t?Xt+gi:Xt;mc(v,k,r??se.moderate)}g.current=null}},onClick:()=>{o||b.current||n()},...d,children:[Fo(vi.Root,{checked:t,"aria-labelledby":u,onCheckedChange:()=>{b.current||n()},disabled:o,tabIndex:0,className:C("relative shrink-0 rounded-full outline-none cursor-pointer","transition-colors duration-80","focus-visible:ring-1 focus-visible:ring-[color:var(--focus-ring,#6B97FF)] focus-visible:ring-offset-2 focus-visible:ring-offset-background"),style:{width:hi,height:cy,backgroundColor:t?c?"color-mix(in oklab, var(--primary) 88%, black)":"var(--primary)":c?a??"color-mix(in oklab, var(--accent), rgb(var(--overlay)) 10%)":s??"var(--accent)"},onClick:k=>k.stopPropagation(),children:Fo(vi.Thumb,{render:k=>{let{style:S,onDrag:A,onDragStart:_,onDragEnd:K,onAnimationStart:$,onAnimationEnd:oe,onAnimationIteration:ae,...ie}=k;return Fo(iy.span,{...ie,className:"absolute top-0 left-0 block rounded-full bg-white shadow-sm",initial:!1,style:{...S,x:v},animate:{y:N,width:y,height:w},transition:h.current?r??se.moderate:{duration:0}})}})}),Fo("span",{id:u,className:C("text-[13px] [text-box:trim-both_cap_alphabetic] transition-[color] duration-80",t?"text-foreground":"text-muted-foreground"),children:e})]})});_m.displayName="FluidSwitch";var Om=gc(({checked:e,defaultChecked:t=!1,onCheckedChange:n,disabled:o=!1,className:r},s)=>{let[a,i]=fc(t),d=e??a,l=u=>{e===void 0&&i(u),n?.(u)};return Fo(vi.Root,{ref:s,checked:d,disabled:o,onCheckedChange:l,className:C("peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-xs transition-colors duration-80","focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[color:var(--focus-ring,#6B97FF)]","disabled:cursor-not-allowed disabled:opacity-50","data-checked:bg-primary data-unchecked:bg-input",r),children:Fo(vi.Thumb,{className:C("pointer-events-none block size-4 rounded-full bg-background shadow-sm ring-0 transition-transform duration-80","data-checked:translate-x-4 data-unchecked:translate-x-0")})})});Om.displayName="ShadcnSwitch";var os=gc((e,t)=>my(e)?Fo(_m,{ref:t,...e}):Fo(Om,{ref:t,...e}));os.displayName="Switch";import{jsx as fy}from"react/jsx-runtime";function no({className:e,...t}){return fy("textarea",{"data-slot":"textarea",className:C("border-input placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 flex field-sizing-content min-h-16 w-full rounded-md border bg-transparent px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),...t})}import{Children as zm,forwardRef as Ys,isValidElement as Bm,useRef as Gs,useEffect as yi,useState as xi,useCallback as gy,useMemo as wi,createContext as hc,useContext as vc}from"react";import{motion as rs,AnimatePresence as bi}from"motion/react";import{cva as hy}from"class-variance-authority";import{Select as $o}from"@base-ui/react/select";import{jsx as Ke,jsxs as Js}from"react/jsx-runtime";var Hm=hc(null);function Um(){let e=vc(Hm);if(!e)throw new Error("Select compound components must be inside <Select>");return e}var Fm=hc(null);function $m(e,t=[]){return zm.forEach(e,n=>{if(!Bm(n))return;let o=n.props;typeof o.value=="string"?t.push({value:o.value,label:o.label??(typeof o.children=="string"?o.children:o.value)}):o.children&&$m(o.children,t)}),t}function kn({children:e,value:t,defaultValue:n,onValueChange:o,disabled:r=!1,name:s,required:a}){let[i,d]=xi(n??""),[l,u]=xi(!1),h=Gs(null),c=t!==void 0?t:i,m=wi(()=>$m(e),[e]),p=gy(f=>{let b=f??"";t===void 0&&d(b),o?.(b)},[t,o]),x=wi(()=>({value:c,open:l,actionsRef:h}),[c,l]);return Ke(Hm.Provider,{value:x,children:Ke($o.Root,{value:c===""?null:c,onValueChange:p,open:l,onOpenChange:u,actionsRef:h,items:m,disabled:r,name:s,required:a,modal:!1,children:e})})}kn.displayName="Select";var vy=hy(["group inline-flex items-center justify-between gap-2 outline-none cursor-pointer","text-[13px] h-9 px-3 min-w-[160px]","transition-all duration-80","disabled:opacity-50 disabled:pointer-events-none","focus-visible:ring-1 focus-visible:ring-[color:var(--focus-ring,#6B97FF)]"],{variants:{variant:{bordered:"border border-border bg-transparent text-foreground hover:bg-hover",borderless:"border border-transparent bg-transparent text-foreground hover:bg-hover"}},defaultVariants:{variant:"bordered"}}),Vm=Ys(({className:e,variant:t,icon:n,leading:o,placeholder:r="Select\u2026",error:s,...a},i)=>{let d=pt();return Js("div",{className:"flex flex-col gap-1",children:[Js($o.Trigger,{ref:i,"aria-invalid":!!s||void 0,className:C(vy({variant:t}),d.input,s&&"border-destructive/50 hover:border-destructive/50",e),...a,children:[Js("span",{className:"flex items-center gap-2 min-w-0 flex-1",children:[o,!o&&n&&Ke(n,{size:16,strokeWidth:1.5,className:"shrink-0 text-muted-foreground transition-[color,stroke-width] duration-80 group-hover:text-foreground group-hover:stroke-[2]"}),Ke($o.Value,{placeholder:r,className:"min-w-0 flex-1 text-left truncate [text-box:trim-both_cap_alphabetic] py-1 -my-1 data-[placeholder]:text-muted-foreground"})]}),Ke("svg",{width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0 text-muted-foreground transition-colors duration-80 group-hover:text-foreground",children:Ke("path",{d:"M6 9l6 6 6-6"})})]}),s&&Ke("span",{className:"text-[12px] text-destructive pl-3",children:s})]})});Vm.displayName="SelectTrigger";var jm=Ys(({className:e,children:t},n)=>{let{open:o,value:r,actionsRef:s}=Um(),a=pt(),i=Gs(null),{activeIndex:d,setActiveIndex:l,itemRects:u,sessionRef:h,handlers:c,registerItem:m,measureItems:p}=xr(i),[x,f]=xi(null),[b,g]=xi(void 0);yi(()=>{if(o)return;let L=setTimeout(()=>s.current?.unmount(),ni(se.fast));return()=>clearTimeout(L)},[o,s]),yi(()=>{if(!o)return;let L,P=requestAnimationFrame(()=>{L=requestAnimationFrame(()=>{p();let R=i.current;if(R){let k=Array.from(R.querySelectorAll("[data-proximity-index]")).findIndex(S=>S.getAttribute("data-value")===r);g(k!==-1?k:void 0)}})});return()=>{cancelAnimationFrame(P),cancelAnimationFrame(L)}},[o,p,r]);let v=d!==null?u[d]:null,y=b!=null?u[b]:null,w=x!==null?u[x]:null,N=d!==null&&d!==b,T=wi(()=>({registerItem:m,activeIndex:d,checkedIndex:b}),[m,d,b]);return Ke($o.Portal,{children:Ke($o.Positioner,{side:"bottom",align:"start",sideOffset:6,alignItemWithTrigger:!1,className:"z-50 outline-none",children:Ke(rs.div,{initial:{opacity:0,y:-4,scaleY:.96},animate:o?{opacity:1,y:0,scaleY:1}:{opacity:0,y:-4,scaleY:.96},transition:o?se.fast:se.fast.exit,style:{transformOrigin:"top center"},onAnimationComplete:()=>{o||s.current?.unmount()},children:Ke(Fm.Provider,{value:T,children:Js($o.Popup,{render:Ke(ts,{offset:2,shadowLevel:3,ref:L=>{i.current=L,typeof n=="function"?n(L):n&&(n.current=L)}}),onMouseEnter:()=>{c.onMouseEnter(),f(null)},onMouseMove:c.onMouseMove,onMouseLeave:c.onMouseLeave,onFocus:L=>{let P=L.target.closest("[data-proximity-index]")?.getAttribute("data-proximity-index");if(P!=null){let R=Number(P);l(R),f(L.target.matches(":focus-visible")?R:null)}},onBlur:L=>{i.current?.contains(L.relatedTarget)||(f(null),l(null))},className:C(`relative flex flex-col gap-0.5 min-w-[var(--anchor-width)] max-h-[min(300px,var(--available-height))] overflow-y-auto ${a.container} p-1 select-none outline-none`,e),children:[Ke(bi,{children:y&&Ke(rs.div,{className:`absolute ${a.bg} bg-active pointer-events-none`,initial:!1,animate:{top:y.top,left:y.left,width:y.width,height:y.height,opacity:N?.8:1},exit:{opacity:0,transition:se.moderate.exit},transition:{...se.moderate,opacity:{duration:.08}}})}),Ke(bi,{children:v&&Ke(rs.div,{className:`absolute ${a.bg} bg-hover pointer-events-none`,initial:{opacity:0,top:y?.top??v.top,left:y?.left??v.left,width:y?.width??v.width,height:y?.height??v.height},animate:{opacity:1,top:v.top,left:v.left,width:v.width,height:v.height},exit:{opacity:0,transition:se.fast.exit},transition:{...se.fast,opacity:{duration:.08}}},h.current)}),Ke(bi,{children:w&&Ke(rs.div,{className:`absolute ${a.focusRing} pointer-events-none z-20 border border-[color:var(--focus-ring,#6B97FF)]`,initial:!1,animate:{left:w.left-2,top:w.top-2,width:w.width+4,height:w.height+4},exit:{opacity:0,transition:se.fast.exit},transition:{...se.fast,opacity:{duration:.08}}})}),t]})})})})})});jm.displayName="SelectContent";var qm=Ys(({className:e,children:t,icon:n,value:o,index:r,disabled:s=!1,...a},i)=>{let d=Um(),l=vc(Fm),u=Gs(null),h=pt(),c=Gs(!1);yi(()=>{c.current=!0},[]),yi(()=>(l?.registerItem(r,u.current),()=>l?.registerItem(r,null)),[r,l]);let m=l?.activeIndex===r,p=d.value===o,x=!c.current;return Js($o.Item,{value:o,disabled:s,label:typeof t=="string"?t:void 0,render:Ke("div",{ref:f=>{u.current=f,typeof i=="function"?i(f):i&&(i.current=f)},"data-proximity-index":r,"data-value":o,className:C(`relative z-10 flex h-9 items-center gap-2 ${h.item} px-2 text-[13px] cursor-pointer outline-none select-none`,"transition-[color] duration-80",m||p?"text-foreground":"text-muted-foreground",s&&"opacity-50 pointer-events-none",e),...a}),children:[n&&Ke(n,{size:16,strokeWidth:m||p?2:1.5,className:"shrink-0 transition-[color,stroke-width] duration-80"}),Ke($o.ItemText,{render:Ke("span",{className:"flex-1 min-w-0 truncate [text-box:trim-both_cap_alphabetic] py-1 -my-1"}),children:t}),Ke(bi,{children:p&&Ke(rs.svg,{width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0 text-foreground",initial:{opacity:1},animate:{opacity:1},exit:{opacity:1},children:Ke(rs.path,{d:"M4 12L9 17L20 6",initial:{pathLength:x?1:0},animate:{pathLength:1,transition:{duration:.08,ease:"easeOut"}},exit:{pathLength:0,transition:{duration:.04,ease:"easeIn"}}})},"check")})]})});qm.displayName="SelectItem";function by({children:e,className:t,...n}){return Ke("div",{role:"group",className:t,...n,children:e})}by.displayName="SelectGroup";var yy=Ys(({className:e,...t},n)=>Ke("div",{ref:n,className:C("px-2 py-1.5 text-[11px] text-muted-foreground",e),...t}));yy.displayName="SelectLabel";var xy=Ys(({className:e,...t},n)=>Ke("div",{ref:n,role:"separator",className:C("my-1 -mx-1 h-px bg-border/60",e),...t}));xy.displayName="SelectSeparator";var Wm=hc(null);function Fn({placeholder:e}){return null}Fn.displayName="SelectValue";function $n({children:e,...t}){let n=Gs(0),o=wi(()=>({next:()=>n.current++}),[]);return n.current=0,Ke(Wm.Provider,{value:o,children:Ke(jm,{...t,children:e})})}function Wt({index:e,label:t,children:n,...o}){let r=vc(Wm),s=e??r?.next()??0;return Ke(qm,{index:s,...o,children:n})}function Vn({children:e,placeholder:t,...n}){let o=t;return zm.forEach(e,r=>{Bm(r)&&r.type===Fn&&(o=r.props.placeholder??o)}),Ke(Vm,{placeholder:o,...n})}function bc(e,t){if(!e?.$ref)return e;let n=e.$ref;if(!n.startsWith("#/"))return e;let o=n.substring(2).split("/"),r=t;for(let s of o)if(r&&typeof r=="object"&&s in r)r=r[s];else return e;return r}function wy(e,t){if(e?.anyOf&&Array.isArray(e.anyOf)){let n=e.anyOf.find(o=>bc(o,t)?.type!=="null");if(n)return{...bc(n,t),nullable:!0}}return e}function yc(e,t){let n=wy(e||{},t);return n=bc(n,t),n}function Ci(e,t){let n=yc(e,t);if(typeof n.type=="string")return n.type;if(Array.isArray(n.type)){let o=n.type.find(r=>r!=="null");return typeof o=="string"?o:void 0}}function Km(e){let t=e?.enum;return Array.isArray(t)&&t.every(n=>typeof n=="string")?t:null}function Jm(e){let t=e.trim().toLowerCase();return["true","1","yes","on"].includes(t)?!0:["false","0","no","off"].includes(t)?!1:e}function Gm(e,t){if(t==="number"||t==="integer"){let n=e.trim();if(!n)return e;let o=Number(n);return Number.isFinite(o)?o:e}return t==="boolean"?Jm(e):e}function Ym(e,t){if(e===void 0)return e;if(t==="object"||t==="array"){if(typeof e=="string")try{return JSON.parse(e)}catch{return e}return e}if(t==="number"||t==="integer"){if(typeof e=="number")return e;if(typeof e=="string"){let n=e.trim();if(!n)return e;let o=Number(n);return Number.isFinite(o)?o:e}return e}return t==="boolean"?typeof e=="boolean"?e:typeof e=="string"?Jm(e):e:e}function Cy(e){let t="",n=0,o=!1,r=!1;for(;n<e.length;){let s=e[n];if(r){t+=s,r=!1,n++;continue}if(s==="\\"){r=!0,t+=s,n++;continue}if(s==="`"){o?(t+='"',o=!1):(t+='"',o=!0),n++;continue}if(o&&s==='"'){t+='\\"',n++;continue}t+=s,n++}return t}function Qm(e){if(!e||typeof e!="string")return null;let t=e.trim();if(!t.startsWith("{"))return null;try{let n=JSON.parse(t);if(n&&typeof n=="object"&&!Array.isArray(n))return n}catch{try{let n=Cy(t),o=JSON.parse(n);if(o&&typeof o=="object"&&!Array.isArray(o))return o}catch{return null}}return null}import{jsx as _t,jsxs as rn}from"react/jsx-runtime";function xc({selectedTool:e,toolArgs:t,onArgChange:n,onBulkPaste:o,autoFilledFields:r,setFields:s,sendEmptyFields:a,onToggleEmpty:i}){let d=e?.inputSchema?.properties||{},l=e?.inputSchema?.required||[],u=Object.keys(d).length>0,h=async(c,m)=>{if(!o)return;let p=c.clipboardData.getData("text");await o(p,m)&&c.preventDefault()};return u?_t("div",{className:"space-y-4",children:Object.entries(d).map(([c,m])=>{let p=e?.inputSchema||{},x=yc(m,p),f=Km(x),b=x.type==="string"&&f!==null,g=x,v=l.includes(c),y=t[c],w="";y!=null&&(typeof y=="string"?w=y:typeof y=="object"&&y!==null?w=JSON.stringify(y,null,2):w=String(y));let N=g.type==="object"||g.type==="array",T=N?g.type==="array"?"array":"object":"string",L=s?.has(c)??!0,P=i&&(g.type==="string"||N);return N?rn("div",{className:"space-y-2",children:[rn("div",{className:"flex items-start justify-between gap-2",children:[rn("div",{className:"min-w-0 flex-1",children:[rn(nt,{htmlFor:c,className:"text-sm font-medium",children:[c,v&&_t("span",{className:"text-red-500 ml-1",children:"*"})]}),g?.description&&_t("p",{className:"mt-0.5 text-xs text-gray-500 dark:text-gray-400",children:g.description})]}),P&&i&&rn("div",{className:"flex items-center gap-2 shrink-0",children:[_t("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:T==="array"?"Send empty array explicitly":"Send empty object explicitly"}),_t(os,{checked:a?.has(c)??!1,onCheckedChange:R=>i(c,T,R),"aria-label":T==="array"?"Send empty array":"Send empty object",title:T==="array"?"Send empty array []":"Send empty object {}"})]})]}),_t(no,{id:c,"data-testid":`tool-param-${c}`,value:w,onChange:R=>n(c,R.target.value),onPaste:R=>h(R,c),placeholder:`Enter ${c}`,disabled:a?.has(c)??!1,className:`min-h-[100px] ${L?"":"opacity-70"} ${r?.has(c)?"animate-pulse ring-2 ring-green-500 dark:ring-green-400":""}`})]},c):b&&f?rn("div",{className:"space-y-2",children:[rn("div",{children:[rn(nt,{htmlFor:c,className:"text-sm font-medium",children:[c,v&&_t("span",{className:"text-red-500 ml-1",children:"*"})]}),g.description&&_t("p",{className:"mt-0.5 text-xs text-gray-500 dark:text-gray-400",children:g.description})]}),rn(kn,{value:String(t[c]||""),onValueChange:R=>n(c,R),children:[_t(Vn,{id:c,className:`w-full ${L?"":"opacity-70"}`,"data-testid":`tool-param-${c}`,children:_t(Fn,{placeholder:"Select an option"})}),_t($n,{children:f.map((R,D)=>_t(Wt,{value:R,children:g.enumNames?.[D]||R},R))})]})]},c):rn("div",{className:"space-y-2",children:[rn("div",{className:"flex items-start justify-between gap-2",children:[rn("div",{className:"min-w-0 flex-1",children:[rn(nt,{htmlFor:c,className:"text-sm font-medium",children:[c,v&&_t("span",{className:"text-red-500 ml-1",children:"*"})]}),g?.description&&_t("p",{className:"mt-0.5 text-xs text-gray-500 dark:text-gray-400",children:g.description})]}),P&&i&&rn("div",{className:"flex items-center gap-2 shrink-0",children:[_t("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:"Send empty string"}),_t(os,{checked:a?.has(c)??!1,onCheckedChange:R=>i(c,"string",R),"aria-label":"Send empty string",title:"Send empty string"})]})]}),_t(Ge,{id:c,"data-testid":`tool-param-${c}`,value:w,onChange:R=>n(c,R.target.value),onPaste:R=>h(R,c),placeholder:`Enter ${c}`,disabled:a?.has(c)??!1,className:`${L?"":"opacity-70"} ${r?.has(c)?"animate-pulse ring-2 ring-green-500 dark:ring-green-400":""}`})]},c)})}):_t("div",{className:"flex items-center justify-center h-32 text-gray-500 dark:text-gray-400 text-sm",children:"No parameters required"})}import{Check as n0,Copy as o0,History as cf,Maximize as r0,Minimize as s0,Play as a0,Zap as i0}from"lucide-react";import l0,{useCallback as Oc,useEffect as ra,useMemo as so,useRef as c0,useState as Rr}from"react";import{toast as d0}from"sonner";import{getViewResourceUri as u0,isViewTool as m0}from"@mcp-use/client/react";import{ViewRenderer as Yy}from"@mcp-use/client/react";import{useMcpClient as $y}from"@mcp-use/client/react";import{X as Vy}from"lucide-react";import{useCallback as ss,useEffect as jy,useMemo as Pc,useRef as Rc}from"react";var wc=class{constructor(){ot(this,"listeners",new Set)}publish(t){this.listeners.forEach(n=>{try{n(t)}catch(o){console.error("[ConsoleLogBus] Error in listener:",o)}})}subscribe(t){return this.listeners.add(t),()=>this.listeners.delete(t)}},Ni=new wc;function Cc(e){let t=u=>u.replace(/['"<>;]/g,"").trim(),n=(e.connectDomains||[]).map(t).filter(Boolean),o=(e.resourceDomains||[]).map(t).filter(Boolean),r=(e.frameDomains||[]).map(t).filter(Boolean),s=(e.baseUriDomains||[]).map(t).filter(Boolean),a=n.length>0?n.join(" "):"'none'",i=o.length>0?["data:","blob:",...o].join(" "):"data: blob:",d=r.length>0?r.join(" "):"'none'",l=s.length>0?s.join(" "):"'none'";return["default-src 'none'",`script-src 'unsafe-inline' ${i}`,`style-src 'unsafe-inline' ${i}`,`img-src ${i}`,`font-src ${i}`,`media-src ${i}`,`connect-src ${a}`,`frame-src ${d}`,"object-src 'none'",`base-uri ${l}`].join("; ")}function Xm(e){if(!e)return{};let t={};for(let n of e.split(";")){let[o,...r]=n.trim().split(/\s+/);o&&(t[o.toLowerCase()]=r)}return t}function Zm(e){return e?Xm(Cc(e)):{}}function ep(e){return Xm(e)}function Ny(e){let t={};for(let n of e){let o=(n.effectiveDirective||n.directive||"unknown").toLowerCase(),r=n.blockedUri||"(inline)";t[o]=Array.from(new Set([...t[o]??[],r])).sort()}return t}function tp(e,t){return Array.from(new Set([...Object.keys(e),...Object.keys(t)])).sort().map(o=>{let r=e[o]??[],s=t[o]??[],a=Array.from(new Set(r)).sort(),i=Array.from(new Set(s)).sort(),d=a.length===i.length&&a.every((l,u)=>l===i[u]);return{directive:o,requested:r,effective:s,status:d?"same":r.length===0?"added":s.length===0?"missing":"changed"}})}function np(e){let t=[];e.declared||t.push({severity:"warning",title:"No widget CSP declared",detail:"Widget-declared mode blocks external connections and resources."}),e.mode==="permissive"&&t.push({severity:"info",title:"Permissive mode",detail:"Observed violations are requests a declared policy would block."});let n=Ny(e.violations);for(let[o,r]of Object.entries(n))t.push({severity:e.mode==="permissive"?"warning":"error",title:`${r.length} blocked by ${o}`,detail:r.join(", ")});return t.length===0&&t.push({severity:"info",title:"No CSP issues observed",detail:e.effectivePolicy?"The effective policy has not produced violations.":"Load the widget to observe its effective policy."}),t}var ky=/(?:^|\/)notifications\//;function Sy(e){let t=e;return typeof t?.method=="string"?t.method:null}function ki(e){let t=e.message;if(t?.id!==void 0&&t.id!==null||t?.result!==void 0||t?.error!==void 0)return null;let n=Sy(e.message);return!n||!ky.test(n)?null:[e.source,e.serverId,e.widgetId??"",e.direction,n].join("|")}function op(e,t,n=Date.now()){let o=ki(e),r=ki(t);if(!o||o!==r)return!1;let s=Date.parse(e.timestamp);return Number.isNaN(s)?!1:n-s<=300}function rp(e,t){return{...e,timestamp:t.timestamp,message:t.message,repeatCount:(e.repeatCount??1)+1}}var Nc=class{constructor(t=1e3){this.maxEntries=t;ot(this,"entries",[]);ot(this,"listeners",new Set);ot(this,"nextId",0);ot(this,"emitFrame",null);ot(this,"getSnapshot",()=>this.entries);ot(this,"subscribe",t=>(this.listeners.add(t),()=>this.listeners.delete(t)))}publish(t){let n=this.entries[this.entries.length-1];if(n&&op(n,t,Date.parse(t.timestamp))){this.entries[this.entries.length-1]=rp(n,t),this.scheduleEmit();return}this.entries.push({...t,id:`rpc-${++this.nextId}`}),this.entries.length>this.maxEntries&&this.entries.splice(0,this.entries.length-this.maxEntries),this.scheduleEmit()}clear(t={}){let n=new Set(t.serverIds??[]),o=new Set(t.sources??[]);n.size===0&&o.size===0?this.entries=[]:this.entries=this.entries.filter(r=>!((n.size===0||n.has(r.serverId))&&(o.size===0||o.has(r.source)))),this.scheduleEmit()}peekCoalesceKey(t){return ki(t)}scheduleEmit(){if(this.emitFrame===null){if(typeof requestAnimationFrame>"u"){this.emit();return}this.emitFrame=requestAnimationFrame(()=>{this.emitFrame=null,this.emit()})}}emit(){this.listeners.forEach(t=>t())}},kc=new Nc;function sp(e,t,n){let o={get sessionId(){return e.sessionId},set sessionId(r){e.sessionId=r},setProtocolVersion:e.setProtocolVersion?r=>e.setProtocolVersion?.(r):void 0,async start(){return e.start()},async send(r,s){return kc.publish({source:"widget",serverId:t,widgetId:n,direction:"send",timestamp:new Date().toISOString(),message:r}),e.send(r,s)},async close(){return e.close()},onclose:void 0,onerror:void 0,onmessage:void 0};return Object.defineProperty(o,"onmessage",{configurable:!0,enumerable:!0,get(){return e.onmessage},set(r){if(!r){e.onmessage=void 0;return}e.onmessage=(s,a)=>{kc.publish({source:"widget",serverId:t,widgetId:n,direction:"receive",timestamp:new Date().toISOString(),message:s}),r(s,a)}}}),Object.defineProperty(o,"onclose",{configurable:!0,enumerable:!0,get(){return e.onclose},set(r){e.onclose=r}}),Object.defineProperty(o,"onerror",{configurable:!0,enumerable:!0,get(){return e.onerror},set(r){e.onerror=r}}),o}import{createContext as Ty,use as Py,useEffect as Sc,useState as ap}from"react";import{jsx as My}from"react/jsx-runtime";var ip=Ty(void 0);function oo(){let e=Py(ip);if(e===void 0)throw new Error("useTheme must be used within a ThemeProvider");return e}function Ry({children:e,defaultTheme:t="system",storageKey:n="theme",forcedTheme:o}){let[r,s]=ap(o||t),[a,i]=ap(!1),d=()=>typeof window>"u"?"light":window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",l=r==="system"?d():r,u=c=>{let m=document.documentElement,p=c==="system"?d():c;m.classList.remove("light","dark"),m.classList.add(p),o||localStorage.setItem(n,c)};return Sc(()=>{i(!0);let c=localStorage.getItem(n),m=o||c||t;s(m),u(m)},[t,n,o]),Sc(()=>{if(r!=="system")return;let c=window.matchMedia("(prefers-color-scheme: dark)"),m=()=>{u("system")};return c.addEventListener("change",m),()=>c.removeEventListener("change",m)},[r]),Sc(()=>{a&&u(r)},[r,a]),My(ip,{value:{theme:r,setTheme:c=>{if(o){console.warn("[ThemeProvider] Theme is forced via URL parameter, ignoring setTheme call");return}s(c)},resolvedTheme:l},children:e})}import{createContext as Iy,use as Ey,useCallback as Sn,useMemo as Ay,useRef as Dy,useState as Ly}from"react";import{jsx as zy}from"react/jsx-runtime";var lp=Iy(void 0),_y={deviceType:"desktop",customViewport:{width:768,height:1024},cspMode:"permissive",displayModeOverride:null,capabilities:{hover:!0,touch:!1},safeAreaInsets:{top:0,right:0,bottom:0,left:0},locale:"en-US",timeZone:Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"};function Oy({children:e}){let[t,n]=Ly({activeWidgetId:null,widgets:new Map,playground:_y}),o=Sn(b=>{n(g=>({...g,activeWidgetId:b}))},[]),r=Sn((b,g)=>{n(v=>{if(v.widgets.has(b))return v;let y=new Map(v.widgets);return y.set(b,{...g,cspViolations:[]}),{...v,widgets:y}})},[]),s=Sn(b=>{n(g=>{let v=new Map(g.widgets);return v.delete(b),{...g,widgets:v,activeWidgetId:g.activeWidgetId===b?null:g.activeWidgetId}})},[]),a=Dy(t);a.current=t;let i=Sn(b=>a.current.widgets.get(b),[]),d=Sn((b,g)=>{n(v=>{let y=v.widgets.get(b);if(!y)return v;let w={cspViolations:[...y.cspViolations,g]};g.originalPolicy&&y.effectivePolicy===void 0&&(w.effectivePolicy=g.originalPolicy);let N=new Map(v.widgets);return N.set(b,{...y,...w}),{...v,widgets:N}})},[]),l=Sn(b=>{n(g=>{let v=g.widgets.get(b);if(!v)return g;let y=new Map(g.widgets);return y.set(b,{...v,cspViolations:[]}),{...g,widgets:y}})},[]),u=Sn((b,g)=>{n(v=>{let y=v.widgets.get(b);if(!y)return v;let w=new Map(v.widgets);return w.set(b,{...y,modelContext:g}),{...v,widgets:w}})},[]),h=Sn((b,g)=>{n(v=>{let y=v.widgets.get(b);if(!y)return v;let w=new Map(v.widgets);return w.set(b,{...y,widgetState:g}),{...v,widgets:w}})},[]),c=Sn((b,g,v)=>{n(y=>{let w=y.widgets.get(b);if(!w)return y;let N=new Map(y.widgets);return N.set(b,{...w,declaredCsp:g,...v!==void 0&&{effectivePolicy:v}}),{...y,widgets:N}})},[]),m=Sn(b=>{n(g=>({...g,playground:{...g.playground,...b}}))},[]),p=Sn(()=>{n(b=>({...b,widgets:new Map,activeWidgetId:null}))},[]),x=Sn(()=>{let b=new Map;for(let[g,v]of t.widgets)v.modelContext&&b.set(g,v.modelContext);return b},[t.widgets]),f=Ay(()=>({...t,setActiveWidget:o,addWidget:r,removeWidget:s,getWidget:i,addCspViolation:d,clearCspViolations:l,setWidgetModelContext:u,setWidgetState:h,setWidgetDeclaredCsp:c,updatePlaygroundSettings:m,clearAllWidgets:p,getAllModelContexts:x}),[t,o,r,s,i,d,l,u,h,c,m,p,x]);return zy(lp,{value:f,children:e})}function Vo(){let e=Ey(lp);if(!e)throw new Error("useWidgetDebug must be used within WidgetDebugProvider");return e}var Tc={mobile:{width:390,height:844,name:"iPhone 14"},desktop:{width:1440,height:900,name:"Desktop"}};import{useMemo as By}from"react";function cp(e){return By(()=>({maxWidth:Tc[e].width,maxHeight:Tc[e].height}),[e])}import{useMemo as Hy}from"react";function sn(e,t){return e.getPropertyValue(t).trim()}function Uy(){if(typeof window>"u")return{};let e=getComputedStyle(document.documentElement),t={},n=(b,g)=>{g&&(t[b]=g)},o=sn(e,"--background"),r=sn(e,"--foreground"),s=sn(e,"--card"),a=sn(e,"--muted"),i=sn(e,"--muted-foreground"),d=sn(e,"--primary"),l=sn(e,"--primary-foreground"),u=sn(e,"--secondary"),h=sn(e,"--accent"),c=sn(e,"--accent-foreground"),m=sn(e,"--destructive"),p=sn(e,"--border"),x=sn(e,"--ring"),f=sn(e,"--radius");return n("--color-background-primary",o),n("--color-background-secondary",s||u),n("--color-background-tertiary",a||h),n("--color-background-inverse",d),n("--color-background-ghost",h||a),n("--color-background-danger",m),n("--color-text-primary",r),n("--color-text-secondary",i),n("--color-text-tertiary",i),n("--color-text-inverse",l),n("--color-text-ghost",c||i),n("--color-text-danger",m),n("--color-border-primary",p),n("--color-border-secondary",p),n("--color-border-tertiary",p),n("--color-ring-primary",x||p),n("--border-radius-sm",f),n("--border-radius-md",f),n("--border-radius-lg",f),n("--font-sans","system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, sans-serif"),t}function dp({theme:e,displayMode:t,maxWidth:n,maxHeight:o,playground:r,deviceType:s,toolCallId:a,toolName:i,toolInput:d,toolOutput:l,toolMetadata:u,tool:h}){return Hy(()=>({theme:e,displayMode:t,availableDisplayModes:["inline","pip","fullscreen"],containerDimensions:{maxHeight:o,maxWidth:n},locale:r.locale,timeZone:r.timeZone,platform:s==="mobile"?"mobile":"web",userAgent:"mcp-use-inspector/0.16.2",deviceCapabilities:r.capabilities,safeAreaInsets:r.safeAreaInsets,styles:{variables:Uy()},toolInfo:h?{id:a,tool:h}:void 0}),[e,t,o,n,r.locale,r.timeZone,r.capabilities,r.safeAreaInsets,s,a,i,d,l,u,h])}function Fy(e){let t=e.name?.trim(),n=e.url?.trim();return t&&t!==n?t:""}function Si(e){return Fy(e)||e.serverInfo?.title?.trim()||e.serverInfo?.name?.trim()||e.name?.trim()||e.url?.trim()||"Unknown server"}function up(e){let t=e.serverInfo?.icons;return t&&t.length>0?t[0].src:e.serverInfo?.icon?e.serverInfo.icon:null}import{jsx as mp}from"react/jsx-runtime";var qy={name:"mcp-use-inspector",version:"11.0.0"};function Wy(e,t){let n=Rc(e);n.current=e;let o=Rc(t);return o.current=t,Pc(()=>e?{callTool:(r,s,a)=>n.current.callTool(r,s??{},a),readResource:r=>o.current(r),get resources(){return n.current?.resources}}:null,[e?.id])}function Ti(e){let{serverId:t,viewId:n,resourceUri:o,toolName:r,toolInput:s,toolOutput:a,toolMetadata:i,tool:d,readResource:l,displayMode:u,onDisplayModeChange:h,inlineMaxWidth:c,chromeless:m,onReady:p}=e,{resolvedTheme:x}=oo(),{servers:f}=$y(),b=f.find(O=>O.id===t),{playground:g,addWidget:v,removeWidget:y,addCspViolation:w,setWidgetModelContext:N,setWidgetDeclaredCsp:T}=Vo(),L=g.cspMode==="permissive"?"permissive":"widget-declared",{maxWidth:P,maxHeight:R}=cp(g.deviceType),D=dp({theme:x,displayMode:u??"inline",maxWidth:P,maxHeight:R,playground:g,deviceType:g.deviceType,toolCallId:n,toolName:r,toolInput:s,toolOutput:a,toolMetadata:i,tool:d}),k=Rc(D);k.current=D;let S=Wy(b,l),A=Pc(()=>S?{kind:"live",connection:S,resourceUri:o}:null,[S,o]),_=ss(O=>sp(O,t,n),[t,n]),K=ss(O=>{v(n,{toolName:r,protocol:"mcp-apps",hostContext:k.current});let W=O.declaredCsp,j;L==="permissive"?j=["default-src * 'unsafe-inline' 'unsafe-eval' data: blob: filesystem: about:","script-src * 'unsafe-inline' 'unsafe-eval' data: blob:","style-src * 'unsafe-inline' data: blob:","img-src * data: blob: https: http:","media-src * data: blob: https: http:","font-src * data: blob: https: http:","connect-src * data: blob: https: http: ws: wss: about:","frame-src * data: blob: https: http: about:","object-src * data: blob:","base-uri *","form-action *"].join("; "):W&&(j=Cc(W)),T(n,W,j)},[v,n,r,L,T]);jy(()=>()=>y(n),[n,y]);let $=ss(O=>{w(n,{directive:O.directive,effectiveDirective:O.effectiveDirective??O.directive,blockedUri:O.blockedUri,sourceFile:O.sourceFile??void 0,lineNumber:O.lineNumber??void 0,columnNumber:O.columnNumber??void 0,originalPolicy:O.originalPolicy,timestamp:O.timestamp})},[w,n]),oe=ss(({content:O,structuredContent:W})=>{N(n,{content:O,structuredContent:W});try{localStorage.setItem(`mcp-use:widget-state:${n}`,JSON.stringify(W))}catch{}},[N,n]),ae=ss(({level:O,data:W})=>{let j=O==="warning"?"warn":O==="error"?"error":"log";Ni.publish({level:j,args:Array.isArray(W)?W:[W],timestamp:new Date().toISOString(),url:o})},[o]),ie=Pc(()=>({title:b?Si(b):"MCP Server",iconUrl:b?up(b):null}),[b]),ne=ss(({onClick:O,"data-testid":W,"aria-label":j})=>mp(E,{type:"button",variant:"tertiary",size:"icon-sm",className:"rounded-full shadow-sm","data-testid":W,"aria-label":j,onClick:O,children:mp(Vy,{})}),[]);if(!A)return null;let z=c??(g.deviceType==="mobile"?P:void 0);return{source:A,hostInfo:qy,hostContext:D,cspMode:L,wrapTransport:_,onCspViolation:$,onModelContextUpdate:oe,onLog:ae,onResourceResolved:K,displayMode:u,onDisplayModeChange:h,inlineMaxWidth:z,chromeless:m,onReady:p,mockOpenAiFileApis:!0,fullscreenHeader:ie,renderFullscreenClose:ne}}import{jsx as Ky}from"react/jsx-runtime";function jo({children:e,className:t,noWrapper:n}){return n?e:Ky("div",{className:C("flex flex-1 items-center justify-center bg-zinc-50 dark:bg-zinc-800","[background-image:radial-gradient(circle,rgba(0,0,0,0.12)_1px,transparent_1px)]","dark:[background-image:radial-gradient(circle,rgba(255,255,255,0.1)_1px,transparent_1px)]","bg-[length:32px_32px]",t),children:e})}import{Loader2Icon as Jy}from"lucide-react";import{jsx as Gy}from"react/jsx-runtime";function Kt({className:e,...t}){return Gy(Jy,{role:"status","aria-label":"Loading",className:C("size-4 animate-spin",e),...t})}import{jsx as as}from"react/jsx-runtime";function Pi({serverId:e,viewId:t,toolName:n,resourceUri:o,toolInput:r,toolOutput:s,toolMetadata:a,readResource:i,customProps:d,displayMode:l,onDisplayModeChange:u,onSendFollowUp:h,onWidgetHeightChange:c,partialToolInput:m,cancelled:p,noWrapper:x=!1,className:f}){let b=Ti({serverId:e,viewId:t,resourceUri:o,toolName:n,toolInput:r,toolOutput:s,toolMetadata:a,readResource:i,displayMode:l,onDisplayModeChange:u});if(!b){let w=as(Kt,{className:"size-5"});return x?as("div",{className:"flex h-full w-full min-h-0 flex-1 items-center justify-center",children:w}):as(jo,{className:"w-full h-full min-h-[240px]",children:w})}let g=C(l==="inline"?"w-full h-full flex items-center justify-center relative p-4 min-h-0":"w-full h-full relative p-4",f),v=d?JSON.stringify(d):"no-custom-props",y=as(Yy,{viewId:t,toolName:n,toolInput:r,toolOutput:s,customProps:d,partialToolInput:m,cancelled:p,className:g,onMessage:w=>{w.length>0&&h&&h(w)},onInlineHeightChange:l==="inline"?c:void 0,...b},v);return x?as("div",{className:"flex h-full w-full min-h-0 flex-1 flex-col",children:y}):as(jo,{className:"w-full h-full min-h-[240px]",children:y})}import{Braces as Qp,ChevronDown as $x,ChevronRight as Vx,Clock as jx,Copy as Xp,Maximize2 as qx,Monitor as sf,Moon as Wx,MousePointer2 as Kx,PictureInPicture as Jx,Pointer as Gx,Settings as Yx,ShieldCheck as Zp,ShieldOff as ef,Smartphone as af,SquareDashedMousePointer as Qx,Sun as Xx,Trash2 as Zx}from"lucide-react";import{useCallback as e0,useEffect as Bi,useMemo as oa,useRef as t0,useState as yo}from"react";import{toast as _c}from"sonner";var Qy=[{value:"en-US",label:"English (US)"},{value:"en-GB",label:"English (UK)"},{value:"en-CA",label:"English (Canada)"},{value:"en-AU",label:"English (Australia)"},{value:"en-IN",label:"English (India)"},{value:"es-ES",label:"Spanish (Spain)"},{value:"es-MX",label:"Spanish (Mexico)"},{value:"es-AR",label:"Spanish (Argentina)"},{value:"es-CO",label:"Spanish (Colombia)"},{value:"fr-FR",label:"French (France)"},{value:"fr-CA",label:"French (Canada)"},{value:"fr-BE",label:"French (Belgium)"},{value:"fr-CH",label:"French (Switzerland)"},{value:"de-DE",label:"German (Germany)"},{value:"de-AT",label:"German (Austria)"},{value:"de-CH",label:"German (Switzerland)"},{value:"pt-BR",label:"Portuguese (Brazil)"},{value:"pt-PT",label:"Portuguese (Portugal)"},{value:"zh-CN",label:"Chinese (Simplified, China)"},{value:"zh-TW",label:"Chinese (Traditional, Taiwan)"},{value:"zh-HK",label:"Chinese (Traditional, Hong Kong)"},{value:"ja-JP",label:"Japanese (Japan)"},{value:"ko-KR",label:"Korean (Korea)"},{value:"ar-SA",label:"Arabic (Saudi Arabia)"},{value:"ar-EG",label:"Arabic (Egypt)"},{value:"hi-IN",label:"Hindi (India)"},{value:"ru-RU",label:"Russian (Russia)"},{value:"it-IT",label:"Italian (Italy)"},{value:"nl-NL",label:"Dutch (Netherlands)"},{value:"nl-BE",label:"Dutch (Belgium)"},{value:"pl-PL",label:"Polish (Poland)"},{value:"sv-SE",label:"Swedish (Sweden)"},{value:"no-NO",label:"Norwegian (Norway)"},{value:"da-DK",label:"Danish (Denmark)"},{value:"fi-FI",label:"Finnish (Finland)"},{value:"tr-TR",label:"Turkish (Turkey)"},{value:"el-GR",label:"Greek (Greece)"},{value:"cs-CZ",label:"Czech (Czech Republic)"},{value:"hu-HU",label:"Hungarian (Hungary)"},{value:"ro-RO",label:"Romanian (Romania)"},{value:"th-TH",label:"Thai (Thailand)"},{value:"vi-VN",label:"Vietnamese (Vietnam)"},{value:"id-ID",label:"Indonesian (Indonesia)"},{value:"ms-MY",label:"Malay (Malaysia)"},{value:"tl-PH",label:"Tagalog (Philippines)"},{value:"he-IL",label:"Hebrew (Israel)"},{value:"uk-UA",label:"Ukrainian (Ukraine)"},{value:"bg-BG",label:"Bulgarian (Bulgaria)"},{value:"hr-HR",label:"Croatian (Croatia)"},{value:"sk-SK",label:"Slovak (Slovakia)"},{value:"sl-SI",label:"Slovenian (Slovenia)"},{value:"sr-RS",label:"Serbian (Serbia)"},{value:"bn-BD",label:"Bengali (Bangladesh)"},{value:"ta-IN",label:"Tamil (India)"},{value:"te-IN",label:"Telugu (India)"},{value:"mr-IN",label:"Marathi (India)"},{value:"ur-PK",label:"Urdu (Pakistan)"},{value:"fa-IR",label:"Persian (Iran)"},{value:"sw-KE",label:"Swahili (Kenya)"}],pp=Qy;function Xy(){return Intl.supportedValuesOf("timeZone").map(t=>({value:t,label:t.replace(/_/g," ")}))}var fp=Xy();import{useCallback as Ri,useEffect as gp,useState as hp}from"react";var vp=e=>`mcp-inspector-resource-props-${e}`;function bp(e){let[t,n]=hp([]),[o,r]=hp(null);gp(()=>{(()=>{try{let u=vp(e),h=localStorage.getItem(u);if(h){let c=JSON.parse(h);n(c.presets||[]),r(c.activePresetId||null)}else n([]),r(null)}catch(u){console.error("[useResourceProps] Failed to load presets:",u),n([]),r(null)}})()},[e]),gp(()=>{let l=vp(e),u={presets:t,activePresetId:o};localStorage.setItem(l,JSON.stringify(u))},[e,t,o]);let s=Ri(l=>{n(u=>{let h=u.findIndex(m=>m.id===l.id),c;return h>=0?(c=[...u],c[h]=l):c=[...u,l],c})},[]),a=Ri(l=>{n(u=>u.filter(h=>h.id!==l)),r(u=>u===l?null:u)},[]),i=Ri(l=>{r(l)},[]),d=Ri(()=>o&&t.find(u=>u.id===o)?.props||null,[o,t]);return{presets:t,activePresetId:o,savePreset:s,deletePreset:a,setActivePreset:i,getActiveProps:d}}import{ChevronDown as mx,ChevronRight as px,Copy as Ep,Search as fx,TerminalIcon as Ic,TrashIcon as gx,X as hx}from"lucide-react";import{useCallback as vx,useEffect as Ec,useMemo as ds,useRef as Tp,useState as Qs}from"react";import{toast as Di}from"sonner";import{useCallback as yp,useEffect as xp,useRef as Zy,useState as wp}from"react";function Cp(e={}){let{enabled:t=!0,maxLogs:n=1e3,proxyToPageConsole:o=!1}=e,[r,s]=wp([]),[a,i]=wp(!1),d=Zy(0),l=yp(h=>{if(!t)return;let c={...h,id:`log-${++d.current}-${Date.now()}`};if(s(m=>[...m,c].slice(-n)),o){let m="[WIDGET CONSOLE]",p=h.args.map(x=>{if(typeof x=="object"&&x!==null)try{return JSON.stringify(x,null,2)}catch{return String(x)}return x});switch(h.level){case"error":console.error(m,...p);break;case"warn":console.warn(m,...p);break;case"info":console.info(m,...p);break;case"debug":console.debug(m,...p);break;case"trace":console.trace(m,...p);break;default:console.log(m,...p)}}},[t,n,o]),u=yp(()=>{s([]),d.current=0},[]);return xp(()=>{if(!t)return;let h=c=>{c.data&&c.data.type==="iframe-console-log"&&c.data.level&&Array.isArray(c.data.args)&&l({level:c.data.level,args:c.data.args,timestamp:c.data.timestamp||new Date().toISOString(),url:c.data.url})};return window.addEventListener("message",h),()=>{window.removeEventListener("message",h)}},[t,l]),xp(()=>{if(t)return Ni.subscribe(l)},[t,l]),{logs:r,addLog:l,clearLogs:u,isOpen:a,setIsOpen:i}}import{Dialog as qo}from"@base-ui/react/dialog";import{XIcon as ex}from"lucide-react";import{jsx as jn,jsxs as Mc}from"react/jsx-runtime";function is({...e}){return jn(qo.Root,{"data-slot":"sheet",...e})}function Mi(e){return jn(qo.Trigger,{"data-slot":"sheet-trigger",...e})}function tx({...e}){return jn(qo.Portal,{"data-slot":"sheet-portal",...e})}function nx({className:e,container:t,...n}){return jn(qo.Backdrop,{"data-slot":"sheet-overlay",className:C("inset-0 z-50 bg-black/50 transition-opacity duration-150 data-ending-style:opacity-0 data-starting-style:opacity-0",t?"absolute":"fixed",e),...n})}function ls({className:e,children:t,side:n="right",showCloseButton:o=!0,container:r,...s}){return Mc(tx,{container:r??void 0,children:[jn(nx,{container:r}),Mc(qo.Popup,{"data-slot":"sheet-content","data-side":n,className:C("z-50 flex flex-col gap-4 bg-popover bg-clip-padding text-sm text-popover-foreground shadow-lg transition duration-200 ease-in-out data-ending-style:opacity-0 data-starting-style:opacity-0 data-[side=bottom]:inset-x-0 data-[side=bottom]:bottom-0 data-[side=bottom]:h-auto data-[side=bottom]:border-t data-[side=bottom]:data-ending-style:translate-y-[2.5rem] data-[side=bottom]:data-starting-style:translate-y-[2.5rem] data-[side=left]:inset-y-0 data-[side=left]:left-0 data-[side=left]:h-full data-[side=left]:w-3/4 data-[side=left]:border-r data-[side=left]:data-ending-style:translate-x-[-2.5rem] data-[side=left]:data-starting-style:translate-x-[-2.5rem] data-[side=right]:inset-y-0 data-[side=right]:right-0 data-[side=right]:h-full data-[side=right]:w-3/4 data-[side=right]:border-l data-[side=right]:data-ending-style:translate-x-[2.5rem] data-[side=right]:data-starting-style:translate-x-[2.5rem] data-[side=top]:inset-x-0 data-[side=top]:top-0 data-[side=top]:h-auto data-[side=top]:border-b data-[side=top]:data-ending-style:translate-y-[-2.5rem] data-[side=top]:data-starting-style:translate-y-[-2.5rem] data-[side=left]:sm:max-w-sm data-[side=right]:sm:max-w-sm",r?"absolute":"fixed",e),...s,children:[t,o&&Mc(qo.Close,{"data-slot":"sheet-close",render:jn(E,{variant:"ghost",className:"absolute top-4 right-4",size:"icon-sm"}),children:[jn(ex,{}),jn("span",{className:"sr-only",children:"Close"})]})]})]})}function Ii({className:e,...t}){return jn("div",{"data-slot":"sheet-header",className:C("flex flex-col gap-1.5 p-4",e),...t})}function Ei({className:e,...t}){return jn(qo.Title,{"data-slot":"sheet-title",className:C("font-medium text-foreground",e),...t})}function Np({className:e,...t}){return jn(qo.Description,{"data-slot":"sheet-description",className:C("text-sm text-muted-foreground",e),...t})}import*as Ai from"react";import{createContext as Sp,useContext as kp,useState as ox}from"react";import{Tooltip as cs}from"@base-ui/react/tooltip";import{motion as rx}from"motion/react";import{Fragment as ux,jsx as Wo,jsxs as dx}from"react/jsx-runtime";var sx=Sp(null),ax=200,ix=Sp(!1);function lx(e){switch(e){case"top":return{y:4};case"bottom":return{y:-4};case"left":return{x:4};case"right":return{x:-4};default:return{y:4}}}function cx({content:e,children:t,side:n="top",sideOffset:o=8,delayDuration:r,className:s,forceOpen:a,onOpenChange:i}){let[d,l]=ox(!1),u=a!==void 0?a:d,h=pt(),c=kp(sx),m=kp(ix),p=lx(n),x=dx(cs.Root,{open:u,onOpenChange:f=>{l(f),i?.(f)},children:[Wo(cs.Trigger,{render:t,delay:r}),Wo(cs.Portal,{container:c??void 0,children:Wo(cs.Positioner,{side:n,sideOffset:o,className:"z-50",children:Wo(cs.Popup,{render:(f,b)=>{let g=b.transitionStatus==="ending",{style:v,onDrag:y,onDragStart:w,onDragEnd:N,onAnimationStart:T,onAnimationEnd:L,onAnimationIteration:P,...R}=f;return Wo(rx.div,{...R,className:C("bg-foreground text-background text-[12px] px-2 py-1","[text-box:trim-both_cap_alphabetic] supports-[text-box:trim-both]:py-2",h.bg,s),style:{...v,fontVariationSettings:yt.medium},initial:{opacity:0,...p},animate:g?{opacity:0,...p}:{opacity:1,x:0,y:0},transition:g?se.fast.exit:se.fast})},children:e})})})]});return m?x:Wo(cs.Provider,{delay:r??ax,children:x})}function we(e){return null}we.displayName="TooltipTrigger";function Ce(e){return null}Ce.displayName="TooltipContent";function ke({children:e,delayDuration:t,open:n,onOpenChange:o}){let r=null,s=null,a="top",i,d;return Ai.Children.forEach(e,l=>{if(Ai.isValidElement(l)&&(l.type===we&&(r=l.props.render),l.type===Ce)){let u=l.props;s=u.children,a=u.side??"top",i=u.className,d=u.sideOffset}}),r?Wo(cx,{content:s,side:a,sideOffset:d,className:i,delayDuration:t,forceOpen:n,onOpenChange:o,children:r}):Wo(ux,{children:e})}import{Fragment as Cx,jsx as ze,jsxs as lt}from"react/jsx-runtime";var Pp=200,bx=.9;function Ac(e){if(e===null)return"null";if(e===void 0)return"undefined";if(typeof e=="string")return e;if(typeof e=="object")try{return JSON.stringify(e,null,2)}catch{return String(e)}return String(e)}function Dc(e){if(e.length===0)return[];let t=e[0];if(typeof t!="string"||!/%[oOdisfc]/.test(t))return e.map(Ac);let n=e.slice(1),o=0,r="";for(let a=0;a<t.length;a++){let i=t[a];if(i==="%"&&a+1<t.length){let d=t[a+1],l=n[o++];switch(d){case"o":case"O":r+=Ac(l),a++;break;case"s":r+=l===void 0?"undefined":String(l),a++;break;case"d":case"i":r+=String(Number.parseInt(String(l??""),10)||0),a++;break;case"f":r+=String(Number.parseFloat(String(l??""))||0),a++;break;case"c":a++;break;default:r+=i}continue}r+=i}let s=[r.trim()];for(;o<n.length;)s.push(Ac(n[o++]));return s.filter(a=>a.length>0)}function yx({level:e}){return ze("span",{className:C("px-1.5 py-0.5 text-[11px] font-mono font-semibold rounded-full text-white shrink-0",{log:"bg-zinc-500",info:"bg-blue-500",warn:"bg-yellow-500",error:"bg-red-500",debug:"bg-purple-500",trace:"bg-gray-500"}[e]),children:e.toUpperCase()})}function xx({log:e}){let[t,n]=Qs(!1),o=ds(()=>{try{return new Date(e.timestamp).toLocaleTimeString()}catch{return""}},[e.timestamp]),r=ds(()=>Dc(e.args),[e.args]),s=ds(()=>{if(r.length===0)return"";let l=r[0].replace(/\s*\n\s*/g," ").trim(),u=l.length>120?l.slice(0,120)+"\u2026":l,h=r.length>1?` +${r.length-1}`:"";return u+h},[r]),a=async l=>{l.stopPropagation();try{let u=r.join(`
|
|
63
|
-
`);await Xe(u),Di.success("Copied to clipboard")}catch{Di.error("Failed to copy")}},i=C("font-mono text-xs border-b border-zinc-200 dark:border-zinc-800",e.level==="error"&&"bg-red-50/30 dark:bg-red-950/10",e.level==="warn"&&"bg-yellow-50/30 dark:bg-yellow-950/10"),d=C("cursor-pointer select-none",e.level==="error"&&"hover:bg-red-50/50 dark:hover:bg-red-950/20",e.level==="warn"&&"hover:bg-yellow-50/50 dark:hover:bg-yellow-950/20",e.level!=="error"&&e.level!=="warn"&&"hover:bg-zinc-100/70 dark:hover:bg-zinc-800/40");return lt("div",{className:C(i,"group"),children:[lt("div",{className:C("flex items-center gap-2 px-2 py-1.5",d),onClick:()=>n(l=>!l),children:[ze("span",{className:"text-zinc-400 dark:text-zinc-500 shrink-0",children:t?ze(
|
|
62
|
+
# resource_content = await session.read_resource("resource_uri")`}function Yb(e){let t=document.createElement("textarea");t.value=e,t.style.cssText="position:fixed;top:-9999px;left:-9999px;opacity:0",document.body.appendChild(t),t.focus(),t.select();try{return document.execCommand("copy")}finally{document.body.removeChild(t)}}async function Xe(e){if(!Yb(e)){if(navigator.clipboard?.writeText)return navigator.clipboard.writeText(e);throw new Error("copy failed")}}function Rm(e){if(e==null)return"/mcp";let t=e.trim().replace(/\/{2,}/g,"/").replace(/\/+$/,"");return t===""||t==="/"?"":(t.startsWith("/")||(t=`/${t}`),t)}function Qb(){if(typeof window>"u")return"";let e=window.location.pathname||"",n=e.indexOf("/inspector");return n<=0?"":Rm(e.slice(0,n))}function Xb(){if(typeof window>"u")return"";let e=window.__MCP_BASE_PATH__;return e!=null?Rm(e):Qb()}function Ws(){return`${Xb()}/inspector`}function Mm(e){let t=e.replace(/^\/+/,"");return`${Ws()}/api/${t}`}function Ks(e){let t=typeof window>"u"?void 0:window.__MCP_INSPECTOR_MODE__;return typeof window<"u"&&t!=="cloud"?`${Ws()}/assets/providers/${e}`:`https://inspector-cdn.mcp-use.com/providers/${e}`}import{Check as lc,ChevronDown as Zb,Copy as cc,Plus as ey}from"lucide-react";import{useState as dc,isValidElement as ty}from"react";import{jsx as Im,jsxs as XP}from"react/jsx-runtime";function ic({className:e}){return Im("svg",{viewBox:"0 0 24 24",className:e,fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:Im("path",{d:"M23.15 2.587L18.21.21a1.494 1.494 0 0 0-1.705.29l-9.46 8.63-4.12-3.128a.999.999 0 0 0-1.276.057L.327 7.261A1 1 0 0 0 .326 8.74L3.899 12 .326 15.26a1 1 0 0 0 .001 1.479L1.65 17.94a.999.999 0 0 0 1.276.057l4.12-3.128 9.46 8.63a1.492 1.492 0 0 0 1.704.29l4.942-2.377A1.5 1.5 0 0 0 24 20.06V3.939a1.5 1.5 0 0 0-.85-1.352zm-5.146 14.861L10.826 12l7.178-5.448v10.896z"})})}import{Fragment as pi,jsx as te,jsxs as Me}from"react/jsx-runtime";var Uo="flex h-10 items-center gap-2";function ny({serverConfig:e,additionalItems:t=[],showClients:n={cursor:!0,vsCode:!0,vsCodeInsiders:!0,claudeDesktop:!0,claudeCode:!0,geminiCli:!0,codexCli:!0},className:o="",onSuccess:r,onError:s,trigger:a}){let[i,d]=dc(!1),[l,u]=dc(null),[h,c]=dc(!1),{url:m,name:p,headers:x}=e,f=S=>{try{Lt(new ei({client:S})).catch(()=>{})}catch{}},b=()=>{f("cursor");try{let S=wm(m,p,x);window.location.href=S,r?.("Cursor")}catch(S){console.error("Failed to generate Cursor deep link:",S),s?.(S)}},g=()=>{f("vscode");try{let S=Cm(m,p,x);window.location.href=S,r?.("VS Code")}catch(S){console.error("Failed to generate VS Code deep link:",S),s?.(S)}},v=()=>{f("vscode-insiders");try{let S=Nm(m,p,x);window.location.href=S,r?.("VS Code Insiders")}catch(S){console.error("Failed to generate VS Code Insiders deep link:",S),s?.(S)}},y=()=>{f("claude-desktop");try{km(m,p,x),r?.("Claude Desktop")}catch(S){console.error("Failed to download .mcpb file:",S),s?.(S)}},w=()=>{f("claude-code"),u("claude-code"),d(!0)},N=()=>{f("gemini-cli"),u("gemini-cli"),d(!0)},T=()=>{f("codex-cli"),u("codex-cli"),d(!0)},L=async S=>{try{await Xe(S),c(!0),setTimeout(()=>c(!1),2e3)}catch(A){console.error("Failed to copy:",A),s?.(A)}},P=()=>{if(l==="claude-code"){let{command:S,envVars:A}=Sm(m,p,x),_=ac(A);return Me(pi,{children:[Me(Qt,{children:[te(qt,{children:"Add to Claude Code"}),te(ho,{children:"Execute the following command in your shell to add this server to Claude Code."})]}),Me(Hn,{className:"space-y-4",children:[Me("div",{children:[te("h5",{className:"font-semibold text-sm mb-2",children:"Instructions"}),Me("ol",{className:"space-y-2 text-xs text-muted-foreground",children:[Me("li",{className:"flex gap-2",children:[te("span",{className:"font-semibold text-foreground",children:"1."}),te("span",{children:"Ensure the Claude Code executable is available in your path"})]}),Me("li",{className:"flex gap-2",children:[te("span",{className:"font-semibold text-foreground",children:"2."}),te("span",{children:"Execute the following snippet in your shell:"})]})]})]}),Me("div",{className:"relative",children:[te("div",{className:"absolute top-2 right-2 z-10",children:te(E,{variant:"ghost",size:"sm",className:"h-7 px-2 bg-background hover:bg-accent border border-border",onClick:()=>L(S),children:h?te(lc,{className:"size-3.5 text-green-600"}):te(cc,{className:"size-3.5"})})}),te("pre",{className:"bg-muted p-3 pr-14 rounded-md text-xs overflow-x-auto",children:te("code",{children:S})})]}),_&&Me("div",{children:[te("h5",{className:"font-semibold text-sm mb-2",children:"Environment Variables"}),te("p",{className:"text-xs text-muted-foreground mb-2",children:"After installation, set these environment variables in your shell:"}),te("pre",{className:"bg-muted p-3 rounded-md text-xs overflow-x-auto",children:te("code",{children:_})})]}),Me("p",{className:"text-xs text-muted-foreground",children:["The MCP configuration supports environment variable expansion using ",te("code",{className:"text-foreground",children:"${VAR}"})," ","syntax."]})]})]})}if(l==="gemini-cli"){let{command:S,envVars:A}=Tm(m,p,x),_=ac(A);return Me(pi,{children:[Me(Qt,{children:[te(qt,{children:"Add to Gemini CLI"}),te(ho,{children:"Execute the following command in your shell to add this server to Gemini CLI."})]}),Me(Hn,{className:"space-y-4",children:[Me("div",{children:[te("h5",{className:"font-semibold text-sm mb-2",children:"Instructions"}),Me("ol",{className:"space-y-2 text-xs text-muted-foreground",children:[Me("li",{className:"flex gap-2",children:[te("span",{className:"font-semibold text-foreground",children:"1."}),te("span",{children:"Ensure the Gemini CLI executable is available in your path"})]}),_&&Me("li",{className:"flex gap-2",children:[te("span",{className:"font-semibold text-foreground",children:"2."}),te("span",{children:"Set these environment variables in your shell before running the command:"})]}),Me("li",{className:"flex gap-2",children:[te("span",{className:"font-semibold text-foreground",children:_?"3.":"2."}),te("span",{children:"Execute the following snippet in your shell:"})]})]})]}),_&&Me("div",{children:[te("h5",{className:"font-semibold text-sm mb-2",children:"Environment Variables"}),te("pre",{className:"bg-muted p-3 rounded-md text-xs overflow-x-auto",children:te("code",{children:_})})]}),Me("div",{className:"relative",children:[te("div",{className:"absolute top-2 right-2 z-10",children:te(E,{variant:"ghost",size:"sm",className:"h-7 px-2 bg-background hover:bg-accent border border-border",onClick:()=>L(S),children:h?te(lc,{className:"size-3.5 text-green-600"}):te(cc,{className:"size-3.5"})})}),te("pre",{className:"bg-muted p-3 pr-14 rounded-md text-xs overflow-x-auto",children:te("code",{children:S})})]}),te("p",{className:"text-xs text-muted-foreground",children:"Restart Gemini CLI to load the new configuration."})]})]})}if(l==="codex-cli"){let{config:S,envVars:A}=Pm(m,p,x);return Me(pi,{children:[Me(Qt,{children:[te(qt,{children:"Add to Codex CLI"}),Me(ho,{children:["Add this configuration to your"," ",te("code",{className:"text-foreground",children:"~/.codex/config.toml"})," ","file."]})]}),Me(Hn,{className:"space-y-4",children:[Me("div",{children:[te("h5",{className:"font-semibold text-sm mb-2",children:"Instructions"}),Me("p",{className:"text-xs text-muted-foreground",children:["Add this configuration to your"," ",te("code",{className:"text-foreground",children:"~/.codex/config.toml"}),":"]})]}),Me("div",{className:"relative",children:[te("div",{className:"absolute top-2 right-2 z-10",children:te(E,{variant:"ghost",size:"sm",className:"h-7 px-2 bg-background hover:bg-accent border border-border",onClick:()=>L(S),children:h?te(lc,{className:"size-3.5 text-green-600"}):te(cc,{className:"size-3.5"})})}),te("pre",{className:"bg-muted p-3 pr-14 rounded-md text-xs overflow-x-auto",children:te("code",{children:S})})]}),A.length>0&&te("div",{children:Me("p",{className:"text-xs text-muted-foreground",children:["(optional) If you would rather use variables from your system's environment, replace the"," ",te("code",{className:"text-foreground",children:"http_headers"})," key with the ",te("code",{className:"text-foreground",children:"env_http_headers"})," ","key as shown in the commented section above."]})}),te("p",{className:"text-xs text-muted-foreground",children:"Restart Codex CLI to load the new configuration."})]})]})}return null},R=Me(E,{variant:"ghost",className:`bg-zinc-200 dark:bg-zinc-800 hover:bg-zinc-300 dark:hover:bg-zinc-700 rounded-full transition-colors px-3 flex items-center justify-center ${o}`,children:[Me("span",{className:"xl:hidden hidden sm:flex items-center gap-1",children:[te(ey,{className:"size-3"}),"Client"]}),Me("span",{className:"hidden xl:flex items-center gap-1",children:["Add to Client",te(Zb,{className:"size-3"})]})]}),D=a?typeof a=="function"?a({isOpen:!1,onClick:()=>{}}):a:R,k=ty(D)?D:R;return Me(pi,{children:[Me(Cr,{children:[te(Ho,{render:k,nativeButton:!0}),Me(Nr,{align:"end",className:"w-auto min-w-[300px]",children:[t.map(S=>Me(Nn,{onClick:async()=>{await S.onClick()},className:Uo,children:[S.icon,te("span",{className:"min-w-0 max-w-full whitespace-nowrap",children:S.label})]},S.id)),t.length>0&&te(xm,{}),n.cursor&&Me(Nn,{onClick:b,className:Uo,children:[te("img",{src:"https://cdn.simpleicons.org/cursor",alt:"Cursor",className:"h-4 w-4"}),te("span",{className:"min-w-0 max-w-full whitespace-nowrap",children:"Cursor"})]}),n.claudeCode&&Me(Nn,{onClick:w,className:Uo,children:[te("img",{src:"https://cdn.simpleicons.org/claude",alt:"Claude",className:"h-4 w-4"}),te("span",{className:"min-w-0 max-w-full whitespace-nowrap",children:"Claude Code"})]}),n.claudeDesktop&&Me(Nn,{onClick:y,className:Uo,children:[te("img",{src:"https://cdn.simpleicons.org/claude",alt:"Claude",className:"h-4 w-4"}),te("span",{className:"min-w-0 max-w-full whitespace-nowrap",children:"Claude Desktop"})]}),n.vsCode&&Me(Nn,{onClick:g,className:Uo,children:[te(ic,{className:"h-4 w-4 text-blue-500"}),te("span",{className:"min-w-0 max-w-full whitespace-nowrap",children:"VS Code"})]}),n.vsCodeInsiders&&Me(Nn,{onClick:v,className:Uo,children:[te(ic,{className:"h-4 w-4 text-teal-400"}),te("span",{className:"min-w-0 max-w-full whitespace-nowrap",children:"VS Code Insiders"})]}),n.geminiCli&&Me(Nn,{onClick:N,className:Uo,children:[te("img",{src:"https://cdn.simpleicons.org/googlegemini",alt:"Gemini",className:"h-4 w-4"}),te("span",{className:"min-w-0 max-w-full whitespace-nowrap",children:"Gemini CLI"})]}),n.codexCli&&Me(Nn,{onClick:T,className:Uo,children:[te("img",{src:Ks("openai.png"),alt:"Codex",className:"h-4 w-4"}),te("span",{className:"min-w-0 max-w-full whitespace-nowrap",children:"Codex CLI"})]})]})]}),te(fn,{open:i,onOpenChange:d,children:te(on,{scrollable:!0,className:"max-w-3xl max-h-[80vh]",children:P()})})]})}import{jsx as oy}from"react/jsx-runtime";function Ge({className:e,type:t,...n}){return oy("input",{type:t,"data-slot":"input",className:C("file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm","focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]","aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",e),...n})}import{jsx as ry}from"react/jsx-runtime";function nt({className:e,...t}){return ry("label",{"data-slot":"label",className:C("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",e),...t})}import{forwardRef as gc,useRef as fi,useState as fc,useEffect as Em,useCallback as uc,useId as sy}from"react";import{motion as ay,useMotionValue as iy,animate as mc}from"motion/react";import{Switch as vi}from"@base-ui/react/switch";import{jsx as Fo,jsxs as my}from"react/jsx-runtime";var hi=34,ly=20,vo=16,Xt=2,gi=hi-vo-Xt*2,cy=2,pc=4,Am=4,dy=2;function uy(e){return"label"in e&&typeof e.label=="string"}var Dm=gc(({label:e,checked:t,onToggle:n,disabled:o=!1,thumbTransition:r,uncheckedTrackColor:s,uncheckedTrackColorHovered:a,className:i,...d},l)=>{let u=sy(),h=fi(!1),[c,m]=fc(!1),[p,x]=fc(!1),f=fi(!1),b=fi(!1),g=fi(null),v=iy(t?Xt+gi:Xt);Em(()=>{h.current=!0},[]);let y=p?vo+pc:c?vo+cy:vo,w=p?vo-Am:vo,N=p?Xt+Am/2:Xt,T=y-vo,L=t?Xt+gi-T:Xt;Em(()=>{f.current||(h.current?mc(v,L,r??se.moderate):v.set(L))},[L,v,r]);let P=uc(k=>{o||k.pointerType==="mouse"&&k.button!==0||(x(!0),f.current=!1,b.current=!1,g.current={clientX:k.clientX,originX:v.get()},k.currentTarget.setPointerCapture(k.pointerId))},[o,v]),R=uc(k=>{if(!g.current)return;let S=k.clientX-g.current.clientX;if(!f.current){if(Math.abs(S)<dy)return;f.current=!0}let A=Xt,_=vo+pc,K=hi-Xt-_,$=g.current.originX+S;v.set(Math.max(A,Math.min(K,$)))},[v]),D=uc(k=>{if(g.current){if(x(!1),f.current){if(b.current=!0,f.current=!1,k){let S=v.get(),A=Xt,_=vo+pc,K=hi-Xt-_,$=(A+K)/2;if(S>$!==t)n();else{let ae=t?Xt+gi:Xt;mc(v,ae,r??se.moderate)}}requestAnimationFrame(()=>{b.current=!1})}g.current=null}},[t,n,v,r]);return my("div",{ref:l,className:C("relative z-10 flex items-center gap-2.5 px-3 py-2 cursor-pointer select-none touch-none",o&&"opacity-50 pointer-events-none",i),onPointerEnter:k=>{k.pointerType==="mouse"&&m(!0)},onPointerLeave:()=>m(!1),onPointerDown:P,onPointerMove:R,onPointerUp:()=>D(!0),onPointerCancel:()=>{if(g.current){if(x(!1),f.current){f.current=!1;let k=t?Xt+gi:Xt;mc(v,k,r??se.moderate)}g.current=null}},onClick:()=>{o||b.current||n()},...d,children:[Fo(vi.Root,{checked:t,"aria-labelledby":u,onCheckedChange:()=>{b.current||n()},disabled:o,tabIndex:0,className:C("relative shrink-0 rounded-full outline-none cursor-pointer","transition-colors duration-80","focus-visible:ring-1 focus-visible:ring-[color:var(--focus-ring,#6B97FF)] focus-visible:ring-offset-2 focus-visible:ring-offset-background"),style:{width:hi,height:ly,backgroundColor:t?c?"color-mix(in oklab, var(--primary) 88%, black)":"var(--primary)":c?a??"color-mix(in oklab, var(--accent), rgb(var(--overlay)) 10%)":s??"var(--accent)"},onClick:k=>k.stopPropagation(),children:Fo(vi.Thumb,{render:k=>{let{style:S,onDrag:A,onDragStart:_,onDragEnd:K,onAnimationStart:$,onAnimationEnd:oe,onAnimationIteration:ae,...ie}=k;return Fo(ay.span,{...ie,className:"absolute top-0 left-0 block rounded-full bg-white shadow-sm",initial:!1,style:{...S,x:v},animate:{y:N,width:y,height:w},transition:h.current?r??se.moderate:{duration:0}})}})}),Fo("span",{id:u,className:C("text-[13px] [text-box:trim-both_cap_alphabetic] transition-[color] duration-80",t?"text-foreground":"text-muted-foreground"),children:e})]})});Dm.displayName="FluidSwitch";var Lm=gc(({checked:e,defaultChecked:t=!1,onCheckedChange:n,disabled:o=!1,className:r},s)=>{let[a,i]=fc(t),d=e??a,l=u=>{e===void 0&&i(u),n?.(u)};return Fo(vi.Root,{ref:s,checked:d,disabled:o,onCheckedChange:l,className:C("peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-xs transition-colors duration-80","focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[color:var(--focus-ring,#6B97FF)]","disabled:cursor-not-allowed disabled:opacity-50","data-checked:bg-primary data-unchecked:bg-input",r),children:Fo(vi.Thumb,{className:C("pointer-events-none block size-4 rounded-full bg-background shadow-sm ring-0 transition-transform duration-80","data-checked:translate-x-4 data-unchecked:translate-x-0")})})});Lm.displayName="ShadcnSwitch";var os=gc((e,t)=>uy(e)?Fo(Dm,{ref:t,...e}):Fo(Lm,{ref:t,...e}));os.displayName="Switch";import{jsx as py}from"react/jsx-runtime";function to({className:e,...t}){return py("textarea",{"data-slot":"textarea",className:C("border-input placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 flex field-sizing-content min-h-16 w-full rounded-md border bg-transparent px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),...t})}import{Children as _m,forwardRef as Ys,isValidElement as Om,useRef as Gs,useEffect as yi,useState as xi,useCallback as fy,useMemo as wi,createContext as hc,useContext as vc}from"react";import{motion as rs,AnimatePresence as bi}from"motion/react";import{cva as gy}from"class-variance-authority";import{Select as $o}from"@base-ui/react/select";import{jsx as Ke,jsxs as Js}from"react/jsx-runtime";var zm=hc(null);function Bm(){let e=vc(zm);if(!e)throw new Error("Select compound components must be inside <Select>");return e}var Hm=hc(null);function Um(e,t=[]){return _m.forEach(e,n=>{if(!Om(n))return;let o=n.props;typeof o.value=="string"?t.push({value:o.value,label:o.label??(typeof o.children=="string"?o.children:o.value)}):o.children&&Um(o.children,t)}),t}function kn({children:e,value:t,defaultValue:n,onValueChange:o,disabled:r=!1,name:s,required:a}){let[i,d]=xi(n??""),[l,u]=xi(!1),h=Gs(null),c=t!==void 0?t:i,m=wi(()=>Um(e),[e]),p=fy(f=>{let b=f??"";t===void 0&&d(b),o?.(b)},[t,o]),x=wi(()=>({value:c,open:l,actionsRef:h}),[c,l]);return Ke(zm.Provider,{value:x,children:Ke($o.Root,{value:c===""?null:c,onValueChange:p,open:l,onOpenChange:u,actionsRef:h,items:m,disabled:r,name:s,required:a,modal:!1,children:e})})}kn.displayName="Select";var hy=gy(["group inline-flex items-center justify-between gap-2 outline-none cursor-pointer","text-[13px] h-9 px-3 min-w-[160px]","transition-all duration-80","disabled:opacity-50 disabled:pointer-events-none","focus-visible:ring-1 focus-visible:ring-[color:var(--focus-ring,#6B97FF)]"],{variants:{variant:{bordered:"border border-border bg-transparent text-foreground hover:bg-hover",borderless:"border border-transparent bg-transparent text-foreground hover:bg-hover"}},defaultVariants:{variant:"bordered"}}),Fm=Ys(({className:e,variant:t,icon:n,leading:o,placeholder:r="Select\u2026",error:s,...a},i)=>{let d=pt();return Js("div",{className:"flex flex-col gap-1",children:[Js($o.Trigger,{ref:i,"aria-invalid":!!s||void 0,className:C(hy({variant:t}),d.input,s&&"border-destructive/50 hover:border-destructive/50",e),...a,children:[Js("span",{className:"flex items-center gap-2 min-w-0 flex-1",children:[o,!o&&n&&Ke(n,{size:16,strokeWidth:1.5,className:"shrink-0 text-muted-foreground transition-[color,stroke-width] duration-80 group-hover:text-foreground group-hover:stroke-[2]"}),Ke($o.Value,{placeholder:r,className:"min-w-0 flex-1 text-left truncate [text-box:trim-both_cap_alphabetic] py-1 -my-1 data-[placeholder]:text-muted-foreground"})]}),Ke("svg",{width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0 text-muted-foreground transition-colors duration-80 group-hover:text-foreground",children:Ke("path",{d:"M6 9l6 6 6-6"})})]}),s&&Ke("span",{className:"text-[12px] text-destructive pl-3",children:s})]})});Fm.displayName="SelectTrigger";var $m=Ys(({className:e,children:t},n)=>{let{open:o,value:r,actionsRef:s}=Bm(),a=pt(),i=Gs(null),{activeIndex:d,setActiveIndex:l,itemRects:u,sessionRef:h,handlers:c,registerItem:m,measureItems:p}=xr(i),[x,f]=xi(null),[b,g]=xi(void 0);yi(()=>{if(o)return;let L=setTimeout(()=>s.current?.unmount(),ni(se.fast));return()=>clearTimeout(L)},[o,s]),yi(()=>{if(!o)return;let L,P=requestAnimationFrame(()=>{L=requestAnimationFrame(()=>{p();let R=i.current;if(R){let k=Array.from(R.querySelectorAll("[data-proximity-index]")).findIndex(S=>S.getAttribute("data-value")===r);g(k!==-1?k:void 0)}})});return()=>{cancelAnimationFrame(P),cancelAnimationFrame(L)}},[o,p,r]);let v=d!==null?u[d]:null,y=b!=null?u[b]:null,w=x!==null?u[x]:null,N=d!==null&&d!==b,T=wi(()=>({registerItem:m,activeIndex:d,checkedIndex:b}),[m,d,b]);return Ke($o.Portal,{children:Ke($o.Positioner,{side:"bottom",align:"start",sideOffset:6,alignItemWithTrigger:!1,className:"z-50 outline-none",children:Ke(rs.div,{initial:{opacity:0,y:-4,scaleY:.96},animate:o?{opacity:1,y:0,scaleY:1}:{opacity:0,y:-4,scaleY:.96},transition:o?se.fast:se.fast.exit,style:{transformOrigin:"top center"},onAnimationComplete:()=>{o||s.current?.unmount()},children:Ke(Hm.Provider,{value:T,children:Js($o.Popup,{render:Ke(ts,{offset:2,shadowLevel:3,ref:L=>{i.current=L,typeof n=="function"?n(L):n&&(n.current=L)}}),onMouseEnter:()=>{c.onMouseEnter(),f(null)},onMouseMove:c.onMouseMove,onMouseLeave:c.onMouseLeave,onFocus:L=>{let P=L.target.closest("[data-proximity-index]")?.getAttribute("data-proximity-index");if(P!=null){let R=Number(P);l(R),f(L.target.matches(":focus-visible")?R:null)}},onBlur:L=>{i.current?.contains(L.relatedTarget)||(f(null),l(null))},className:C(`relative flex flex-col gap-0.5 min-w-[var(--anchor-width)] max-h-[min(300px,var(--available-height))] overflow-y-auto ${a.container} p-1 select-none outline-none`,e),children:[Ke(bi,{children:y&&Ke(rs.div,{className:`absolute ${a.bg} bg-active pointer-events-none`,initial:!1,animate:{top:y.top,left:y.left,width:y.width,height:y.height,opacity:N?.8:1},exit:{opacity:0,transition:se.moderate.exit},transition:{...se.moderate,opacity:{duration:.08}}})}),Ke(bi,{children:v&&Ke(rs.div,{className:`absolute ${a.bg} bg-hover pointer-events-none`,initial:{opacity:0,top:y?.top??v.top,left:y?.left??v.left,width:y?.width??v.width,height:y?.height??v.height},animate:{opacity:1,top:v.top,left:v.left,width:v.width,height:v.height},exit:{opacity:0,transition:se.fast.exit},transition:{...se.fast,opacity:{duration:.08}}},h.current)}),Ke(bi,{children:w&&Ke(rs.div,{className:`absolute ${a.focusRing} pointer-events-none z-20 border border-[color:var(--focus-ring,#6B97FF)]`,initial:!1,animate:{left:w.left-2,top:w.top-2,width:w.width+4,height:w.height+4},exit:{opacity:0,transition:se.fast.exit},transition:{...se.fast,opacity:{duration:.08}}})}),t]})})})})})});$m.displayName="SelectContent";var Vm=Ys(({className:e,children:t,icon:n,value:o,index:r,disabled:s=!1,...a},i)=>{let d=Bm(),l=vc(Hm),u=Gs(null),h=pt(),c=Gs(!1);yi(()=>{c.current=!0},[]),yi(()=>(l?.registerItem(r,u.current),()=>l?.registerItem(r,null)),[r,l]);let m=l?.activeIndex===r,p=d.value===o,x=!c.current;return Js($o.Item,{value:o,disabled:s,label:typeof t=="string"?t:void 0,render:Ke("div",{ref:f=>{u.current=f,typeof i=="function"?i(f):i&&(i.current=f)},"data-proximity-index":r,"data-value":o,className:C(`relative z-10 flex h-9 items-center gap-2 ${h.item} px-2 text-[13px] cursor-pointer outline-none select-none`,"transition-[color] duration-80",m||p?"text-foreground":"text-muted-foreground",s&&"opacity-50 pointer-events-none",e),...a}),children:[n&&Ke(n,{size:16,strokeWidth:m||p?2:1.5,className:"shrink-0 transition-[color,stroke-width] duration-80"}),Ke($o.ItemText,{render:Ke("span",{className:"flex-1 min-w-0 truncate [text-box:trim-both_cap_alphabetic] py-1 -my-1"}),children:t}),Ke(bi,{children:p&&Ke(rs.svg,{width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0 text-foreground",initial:{opacity:1},animate:{opacity:1},exit:{opacity:1},children:Ke(rs.path,{d:"M4 12L9 17L20 6",initial:{pathLength:x?1:0},animate:{pathLength:1,transition:{duration:.08,ease:"easeOut"}},exit:{pathLength:0,transition:{duration:.04,ease:"easeIn"}}})},"check")})]})});Vm.displayName="SelectItem";function vy({children:e,className:t,...n}){return Ke("div",{role:"group",className:t,...n,children:e})}vy.displayName="SelectGroup";var by=Ys(({className:e,...t},n)=>Ke("div",{ref:n,className:C("px-2 py-1.5 text-[11px] text-muted-foreground",e),...t}));by.displayName="SelectLabel";var yy=Ys(({className:e,...t},n)=>Ke("div",{ref:n,role:"separator",className:C("my-1 -mx-1 h-px bg-border/60",e),...t}));yy.displayName="SelectSeparator";var jm=hc(null);function Un({placeholder:e}){return null}Un.displayName="SelectValue";function Fn({children:e,...t}){let n=Gs(0),o=wi(()=>({next:()=>n.current++}),[]);return n.current=0,Ke(jm.Provider,{value:o,children:Ke($m,{...t,children:e})})}function Wt({index:e,label:t,children:n,...o}){let r=vc(jm),s=e??r?.next()??0;return Ke(Vm,{index:s,...o,children:n})}function $n({children:e,placeholder:t,...n}){let o=t;return _m.forEach(e,r=>{Om(r)&&r.type===Un&&(o=r.props.placeholder??o)}),Ke(Fm,{placeholder:o,...n})}function bc(e,t){if(!e?.$ref)return e;let n=e.$ref;if(!n.startsWith("#/"))return e;let o=n.substring(2).split("/"),r=t;for(let s of o)if(r&&typeof r=="object"&&s in r)r=r[s];else return e;return r}function xy(e,t){if(e?.anyOf&&Array.isArray(e.anyOf)){let n=e.anyOf.find(o=>bc(o,t)?.type!=="null");if(n)return{...bc(n,t),nullable:!0}}return e}function yc(e,t){let n=xy(e||{},t);return n=bc(n,t),n}function Ci(e,t){let n=yc(e,t);if(typeof n.type=="string")return n.type;if(Array.isArray(n.type)){let o=n.type.find(r=>r!=="null");return typeof o=="string"?o:void 0}}function qm(e){let t=e?.enum;return Array.isArray(t)&&t.every(n=>typeof n=="string")?t:null}function Wm(e){let t=e.trim().toLowerCase();return["true","1","yes","on"].includes(t)?!0:["false","0","no","off"].includes(t)?!1:e}function Km(e,t){if(t==="number"||t==="integer"){let n=e.trim();if(!n)return e;let o=Number(n);return Number.isFinite(o)?o:e}return t==="boolean"?Wm(e):e}function Jm(e,t){if(e===void 0)return e;if(t==="object"||t==="array"){if(typeof e=="string")try{return JSON.parse(e)}catch{return e}return e}if(t==="number"||t==="integer"){if(typeof e=="number")return e;if(typeof e=="string"){let n=e.trim();if(!n)return e;let o=Number(n);return Number.isFinite(o)?o:e}return e}return t==="boolean"?typeof e=="boolean"?e:typeof e=="string"?Wm(e):e:e}function wy(e){let t="",n=0,o=!1,r=!1;for(;n<e.length;){let s=e[n];if(r){t+=s,r=!1,n++;continue}if(s==="\\"){r=!0,t+=s,n++;continue}if(s==="`"){o?(t+='"',o=!1):(t+='"',o=!0),n++;continue}if(o&&s==='"'){t+='\\"',n++;continue}t+=s,n++}return t}function Gm(e){if(!e||typeof e!="string")return null;let t=e.trim();if(!t.startsWith("{"))return null;try{let n=JSON.parse(t);if(n&&typeof n=="object"&&!Array.isArray(n))return n}catch{try{let n=wy(t),o=JSON.parse(n);if(o&&typeof o=="object"&&!Array.isArray(o))return o}catch{return null}}return null}import{jsx as _t,jsxs as rn}from"react/jsx-runtime";function xc({selectedTool:e,toolArgs:t,onArgChange:n,onBulkPaste:o,autoFilledFields:r,setFields:s,sendEmptyFields:a,onToggleEmpty:i}){let d=e?.inputSchema?.properties||{},l=e?.inputSchema?.required||[],u=Object.keys(d).length>0,h=async(c,m)=>{if(!o)return;let p=c.clipboardData.getData("text");await o(p,m)&&c.preventDefault()};return u?_t("div",{className:"space-y-4",children:Object.entries(d).map(([c,m])=>{let p=e?.inputSchema||{},x=yc(m,p),f=qm(x),b=x.type==="string"&&f!==null,g=x,v=l.includes(c),y=t[c],w="";y!=null&&(typeof y=="string"?w=y:typeof y=="object"&&y!==null?w=JSON.stringify(y,null,2):w=String(y));let N=g.type==="object"||g.type==="array",T=N?g.type==="array"?"array":"object":"string",L=s?.has(c)??!0,P=i&&(g.type==="string"||N);return N?rn("div",{className:"space-y-2",children:[rn("div",{className:"flex items-start justify-between gap-2",children:[rn("div",{className:"min-w-0 flex-1",children:[rn(nt,{htmlFor:c,className:"text-sm font-medium",children:[c,v&&_t("span",{className:"text-red-500 ml-1",children:"*"})]}),g?.description&&_t("p",{className:"mt-0.5 text-xs text-gray-500 dark:text-gray-400",children:g.description})]}),P&&i&&rn("div",{className:"flex items-center gap-2 shrink-0",children:[_t("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:T==="array"?"Send empty array explicitly":"Send empty object explicitly"}),_t(os,{checked:a?.has(c)??!1,onCheckedChange:R=>i(c,T,R),"aria-label":T==="array"?"Send empty array":"Send empty object",title:T==="array"?"Send empty array []":"Send empty object {}"})]})]}),_t(to,{id:c,"data-testid":`tool-param-${c}`,value:w,onChange:R=>n(c,R.target.value),onPaste:R=>h(R,c),placeholder:`Enter ${c}`,disabled:a?.has(c)??!1,className:`min-h-[100px] ${L?"":"opacity-70"} ${r?.has(c)?"animate-pulse ring-2 ring-green-500 dark:ring-green-400":""}`})]},c):b&&f?rn("div",{className:"space-y-2",children:[rn("div",{children:[rn(nt,{htmlFor:c,className:"text-sm font-medium",children:[c,v&&_t("span",{className:"text-red-500 ml-1",children:"*"})]}),g.description&&_t("p",{className:"mt-0.5 text-xs text-gray-500 dark:text-gray-400",children:g.description})]}),rn(kn,{value:String(t[c]||""),onValueChange:R=>n(c,R),children:[_t($n,{id:c,className:`w-full ${L?"":"opacity-70"}`,"data-testid":`tool-param-${c}`,children:_t(Un,{placeholder:"Select an option"})}),_t(Fn,{children:f.map((R,D)=>_t(Wt,{value:R,children:g.enumNames?.[D]||R},R))})]})]},c):rn("div",{className:"space-y-2",children:[rn("div",{className:"flex items-start justify-between gap-2",children:[rn("div",{className:"min-w-0 flex-1",children:[rn(nt,{htmlFor:c,className:"text-sm font-medium",children:[c,v&&_t("span",{className:"text-red-500 ml-1",children:"*"})]}),g?.description&&_t("p",{className:"mt-0.5 text-xs text-gray-500 dark:text-gray-400",children:g.description})]}),P&&i&&rn("div",{className:"flex items-center gap-2 shrink-0",children:[_t("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:"Send empty string"}),_t(os,{checked:a?.has(c)??!1,onCheckedChange:R=>i(c,"string",R),"aria-label":"Send empty string",title:"Send empty string"})]})]}),_t(Ge,{id:c,"data-testid":`tool-param-${c}`,value:w,onChange:R=>n(c,R.target.value),onPaste:R=>h(R,c),placeholder:`Enter ${c}`,disabled:a?.has(c)??!1,className:`${L?"":"opacity-70"} ${r?.has(c)?"animate-pulse ring-2 ring-green-500 dark:ring-green-400":""}`})]},c)})}):_t("div",{className:"flex items-center justify-center h-32 text-gray-500 dark:text-gray-400 text-sm",children:"No parameters required"})}import{Check as t0,Copy as n0,History as af,Maximize as o0,Minimize as r0,Play as s0,Zap as a0}from"lucide-react";import i0,{useCallback as Oc,useEffect as ra,useMemo as ro,useRef as l0,useState as Rr}from"react";import{toast as c0}from"sonner";import{getViewResourceUri as d0,isViewTool as u0}from"@mcp-use/client/react";import{ViewRenderer as Gy}from"@mcp-use/client/react";import{useMcpClient as Fy}from"@mcp-use/client/react";import{X as $y}from"lucide-react";import{useCallback as ss,useEffect as Vy,useMemo as Pc,useRef as Rc}from"react";var wc=class{constructor(){ot(this,"listeners",new Set)}publish(t){this.listeners.forEach(n=>{try{n(t)}catch(o){console.error("[ConsoleLogBus] Error in listener:",o)}})}subscribe(t){return this.listeners.add(t),()=>this.listeners.delete(t)}},Ni=new wc;function Cc(e){let t=u=>u.replace(/['"<>;]/g,"").trim(),n=(e.connectDomains||[]).map(t).filter(Boolean),o=(e.resourceDomains||[]).map(t).filter(Boolean),r=(e.frameDomains||[]).map(t).filter(Boolean),s=(e.baseUriDomains||[]).map(t).filter(Boolean),a=n.length>0?n.join(" "):"'none'",i=o.length>0?["data:","blob:",...o].join(" "):"data: blob:",d=r.length>0?r.join(" "):"'none'",l=s.length>0?s.join(" "):"'none'";return["default-src 'none'",`script-src 'unsafe-inline' ${i}`,`style-src 'unsafe-inline' ${i}`,`img-src ${i}`,`font-src ${i}`,`media-src ${i}`,`connect-src ${a}`,`frame-src ${d}`,"object-src 'none'",`base-uri ${l}`].join("; ")}function Ym(e){if(!e)return{};let t={};for(let n of e.split(";")){let[o,...r]=n.trim().split(/\s+/);o&&(t[o.toLowerCase()]=r)}return t}function Qm(e){return e?Ym(Cc(e)):{}}function Xm(e){return Ym(e)}function Cy(e){let t={};for(let n of e){let o=(n.effectiveDirective||n.directive||"unknown").toLowerCase(),r=n.blockedUri||"(inline)";t[o]=Array.from(new Set([...t[o]??[],r])).sort()}return t}function Zm(e,t){return Array.from(new Set([...Object.keys(e),...Object.keys(t)])).sort().map(o=>{let r=e[o]??[],s=t[o]??[],a=Array.from(new Set(r)).sort(),i=Array.from(new Set(s)).sort(),d=a.length===i.length&&a.every((l,u)=>l===i[u]);return{directive:o,requested:r,effective:s,status:d?"same":r.length===0?"added":s.length===0?"missing":"changed"}})}function ep(e){let t=[];e.declared||t.push({severity:"warning",title:"No widget CSP declared",detail:"Widget-declared mode blocks external connections and resources."}),e.mode==="permissive"&&t.push({severity:"info",title:"Permissive mode",detail:"Observed violations are requests a declared policy would block."});let n=Cy(e.violations);for(let[o,r]of Object.entries(n))t.push({severity:e.mode==="permissive"?"warning":"error",title:`${r.length} blocked by ${o}`,detail:r.join(", ")});return t.length===0&&t.push({severity:"info",title:"No CSP issues observed",detail:e.effectivePolicy?"The effective policy has not produced violations.":"Load the widget to observe its effective policy."}),t}var Ny=/(?:^|\/)notifications\//;function ky(e){let t=e;return typeof t?.method=="string"?t.method:null}function ki(e){let t=e.message;if(t?.id!==void 0&&t.id!==null||t?.result!==void 0||t?.error!==void 0)return null;let n=ky(e.message);return!n||!Ny.test(n)?null:[e.source,e.serverId,e.widgetId??"",e.direction,n].join("|")}function tp(e,t,n=Date.now()){let o=ki(e),r=ki(t);if(!o||o!==r)return!1;let s=Date.parse(e.timestamp);return Number.isNaN(s)?!1:n-s<=300}function np(e,t){return{...e,timestamp:t.timestamp,message:t.message,repeatCount:(e.repeatCount??1)+1}}var Nc=class{constructor(t=1e3){this.maxEntries=t;ot(this,"entries",[]);ot(this,"listeners",new Set);ot(this,"nextId",0);ot(this,"emitFrame",null);ot(this,"getSnapshot",()=>this.entries);ot(this,"subscribe",t=>(this.listeners.add(t),()=>this.listeners.delete(t)))}publish(t){let n=this.entries[this.entries.length-1];if(n&&tp(n,t,Date.parse(t.timestamp))){this.entries[this.entries.length-1]=np(n,t),this.scheduleEmit();return}this.entries.push({...t,id:`rpc-${++this.nextId}`}),this.entries.length>this.maxEntries&&this.entries.splice(0,this.entries.length-this.maxEntries),this.scheduleEmit()}clear(t={}){let n=new Set(t.serverIds??[]),o=new Set(t.sources??[]);n.size===0&&o.size===0?this.entries=[]:this.entries=this.entries.filter(r=>!((n.size===0||n.has(r.serverId))&&(o.size===0||o.has(r.source)))),this.scheduleEmit()}peekCoalesceKey(t){return ki(t)}scheduleEmit(){if(this.emitFrame===null){if(typeof requestAnimationFrame>"u"){this.emit();return}this.emitFrame=requestAnimationFrame(()=>{this.emitFrame=null,this.emit()})}}emit(){this.listeners.forEach(t=>t())}},kc=new Nc;function op(e,t,n){let o={get sessionId(){return e.sessionId},set sessionId(r){e.sessionId=r},setProtocolVersion:e.setProtocolVersion?r=>e.setProtocolVersion?.(r):void 0,async start(){return e.start()},async send(r,s){return kc.publish({source:"widget",serverId:t,widgetId:n,direction:"send",timestamp:new Date().toISOString(),message:r}),e.send(r,s)},async close(){return e.close()},onclose:void 0,onerror:void 0,onmessage:void 0};return Object.defineProperty(o,"onmessage",{configurable:!0,enumerable:!0,get(){return e.onmessage},set(r){if(!r){e.onmessage=void 0;return}e.onmessage=(s,a)=>{kc.publish({source:"widget",serverId:t,widgetId:n,direction:"receive",timestamp:new Date().toISOString(),message:s}),r(s,a)}}}),Object.defineProperty(o,"onclose",{configurable:!0,enumerable:!0,get(){return e.onclose},set(r){e.onclose=r}}),Object.defineProperty(o,"onerror",{configurable:!0,enumerable:!0,get(){return e.onerror},set(r){e.onerror=r}}),o}import{createContext as Sy,use as Ty,useEffect as Sc,useState as rp}from"react";import{jsx as Ry}from"react/jsx-runtime";var sp=Sy(void 0);function no(){let e=Ty(sp);if(e===void 0)throw new Error("useTheme must be used within a ThemeProvider");return e}function Py({children:e,defaultTheme:t="system",storageKey:n="theme",forcedTheme:o}){let[r,s]=rp(o||t),[a,i]=rp(!1),d=()=>typeof window>"u"?"light":window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",l=r==="system"?d():r,u=c=>{let m=document.documentElement,p=c==="system"?d():c;m.classList.remove("light","dark"),m.classList.add(p),o||localStorage.setItem(n,c)};return Sc(()=>{i(!0);let c=localStorage.getItem(n),m=o||c||t;s(m),u(m)},[t,n,o]),Sc(()=>{if(r!=="system")return;let c=window.matchMedia("(prefers-color-scheme: dark)"),m=()=>{u("system")};return c.addEventListener("change",m),()=>c.removeEventListener("change",m)},[r]),Sc(()=>{a&&u(r)},[r,a]),Ry(sp,{value:{theme:r,setTheme:c=>{if(o){console.warn("[ThemeProvider] Theme is forced via URL parameter, ignoring setTheme call");return}s(c)},resolvedTheme:l},children:e})}import{createContext as My,use as Iy,useCallback as Sn,useMemo as Ey,useRef as Ay,useState as Dy}from"react";import{jsx as Oy}from"react/jsx-runtime";var ap=My(void 0),Ly={deviceType:"desktop",customViewport:{width:768,height:1024},cspMode:"permissive",displayModeOverride:null,capabilities:{hover:!0,touch:!1},safeAreaInsets:{top:0,right:0,bottom:0,left:0},locale:"en-US",timeZone:Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"};function _y({children:e}){let[t,n]=Dy({activeWidgetId:null,widgets:new Map,playground:Ly}),o=Sn(b=>{n(g=>({...g,activeWidgetId:b}))},[]),r=Sn((b,g)=>{n(v=>{if(v.widgets.has(b))return v;let y=new Map(v.widgets);return y.set(b,{...g,cspViolations:[]}),{...v,widgets:y}})},[]),s=Sn(b=>{n(g=>{let v=new Map(g.widgets);return v.delete(b),{...g,widgets:v,activeWidgetId:g.activeWidgetId===b?null:g.activeWidgetId}})},[]),a=Ay(t);a.current=t;let i=Sn(b=>a.current.widgets.get(b),[]),d=Sn((b,g)=>{n(v=>{let y=v.widgets.get(b);if(!y)return v;let w={cspViolations:[...y.cspViolations,g]};g.originalPolicy&&y.effectivePolicy===void 0&&(w.effectivePolicy=g.originalPolicy);let N=new Map(v.widgets);return N.set(b,{...y,...w}),{...v,widgets:N}})},[]),l=Sn(b=>{n(g=>{let v=g.widgets.get(b);if(!v)return g;let y=new Map(g.widgets);return y.set(b,{...v,cspViolations:[]}),{...g,widgets:y}})},[]),u=Sn((b,g)=>{n(v=>{let y=v.widgets.get(b);if(!y)return v;let w=new Map(v.widgets);return w.set(b,{...y,modelContext:g}),{...v,widgets:w}})},[]),h=Sn((b,g)=>{n(v=>{let y=v.widgets.get(b);if(!y)return v;let w=new Map(v.widgets);return w.set(b,{...y,widgetState:g}),{...v,widgets:w}})},[]),c=Sn((b,g,v)=>{n(y=>{let w=y.widgets.get(b);if(!w)return y;let N=new Map(y.widgets);return N.set(b,{...w,declaredCsp:g,...v!==void 0&&{effectivePolicy:v}}),{...y,widgets:N}})},[]),m=Sn(b=>{n(g=>({...g,playground:{...g.playground,...b}}))},[]),p=Sn(()=>{n(b=>({...b,widgets:new Map,activeWidgetId:null}))},[]),x=Sn(()=>{let b=new Map;for(let[g,v]of t.widgets)v.modelContext&&b.set(g,v.modelContext);return b},[t.widgets]),f=Ey(()=>({...t,setActiveWidget:o,addWidget:r,removeWidget:s,getWidget:i,addCspViolation:d,clearCspViolations:l,setWidgetModelContext:u,setWidgetState:h,setWidgetDeclaredCsp:c,updatePlaygroundSettings:m,clearAllWidgets:p,getAllModelContexts:x}),[t,o,r,s,i,d,l,u,h,c,m,p,x]);return Oy(ap,{value:f,children:e})}function Vo(){let e=Iy(ap);if(!e)throw new Error("useWidgetDebug must be used within WidgetDebugProvider");return e}var Tc={mobile:{width:390,height:844,name:"iPhone 14"},desktop:{width:1440,height:900,name:"Desktop"}};import{useMemo as zy}from"react";function ip(e){return zy(()=>({maxWidth:Tc[e].width,maxHeight:Tc[e].height}),[e])}import{useMemo as By}from"react";function sn(e,t){return e.getPropertyValue(t).trim()}function Hy(){if(typeof window>"u")return{};let e=getComputedStyle(document.documentElement),t={},n=(b,g)=>{g&&(t[b]=g)},o=sn(e,"--background"),r=sn(e,"--foreground"),s=sn(e,"--card"),a=sn(e,"--muted"),i=sn(e,"--muted-foreground"),d=sn(e,"--primary"),l=sn(e,"--primary-foreground"),u=sn(e,"--secondary"),h=sn(e,"--accent"),c=sn(e,"--accent-foreground"),m=sn(e,"--destructive"),p=sn(e,"--border"),x=sn(e,"--ring"),f=sn(e,"--radius");return n("--color-background-primary",o),n("--color-background-secondary",s||u),n("--color-background-tertiary",a||h),n("--color-background-inverse",d),n("--color-background-ghost",h||a),n("--color-background-danger",m),n("--color-text-primary",r),n("--color-text-secondary",i),n("--color-text-tertiary",i),n("--color-text-inverse",l),n("--color-text-ghost",c||i),n("--color-text-danger",m),n("--color-border-primary",p),n("--color-border-secondary",p),n("--color-border-tertiary",p),n("--color-ring-primary",x||p),n("--border-radius-sm",f),n("--border-radius-md",f),n("--border-radius-lg",f),n("--font-sans","system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, sans-serif"),t}function lp({theme:e,displayMode:t,maxWidth:n,maxHeight:o,playground:r,deviceType:s,toolCallId:a,toolName:i,toolInput:d,toolOutput:l,toolMetadata:u,tool:h}){return By(()=>({theme:e,displayMode:t,availableDisplayModes:["inline","pip","fullscreen"],containerDimensions:{maxHeight:o,maxWidth:n},locale:r.locale,timeZone:r.timeZone,platform:s==="mobile"?"mobile":"web",userAgent:"mcp-use-inspector/0.16.2",deviceCapabilities:r.capabilities,safeAreaInsets:r.safeAreaInsets,styles:{variables:Hy()},toolInfo:h?{id:a,tool:h}:void 0}),[e,t,o,n,r.locale,r.timeZone,r.capabilities,r.safeAreaInsets,s,a,i,d,l,u,h])}function Uy(e){let t=e.name?.trim(),n=e.url?.trim();return t&&t!==n?t:""}function Si(e){return Uy(e)||e.serverInfo?.title?.trim()||e.serverInfo?.name?.trim()||e.name?.trim()||e.url?.trim()||"Unknown server"}function cp(e){let t=e.serverInfo?.icons;return t&&t.length>0?t[0].src:e.serverInfo?.icon?e.serverInfo.icon:null}import{jsx as dp}from"react/jsx-runtime";var jy={name:"mcp-use-inspector",version:"11.0.0"};function qy(e,t){let n=Rc(e);n.current=e;let o=Rc(t);return o.current=t,Pc(()=>e?{callTool:(r,s,a)=>n.current.callTool(r,s??{},a),readResource:r=>o.current(r),get resources(){return n.current?.resources}}:null,[e?.id])}function Ti(e){let{serverId:t,viewId:n,resourceUri:o,toolName:r,toolInput:s,toolOutput:a,toolMetadata:i,tool:d,readResource:l,displayMode:u,onDisplayModeChange:h,inlineMaxWidth:c,chromeless:m,onReady:p}=e,{resolvedTheme:x}=no(),{servers:f}=Fy(),b=f.find(O=>O.id===t),{playground:g,addWidget:v,removeWidget:y,addCspViolation:w,setWidgetModelContext:N,setWidgetDeclaredCsp:T}=Vo(),L=g.cspMode==="permissive"?"permissive":"widget-declared",{maxWidth:P,maxHeight:R}=ip(g.deviceType),D=lp({theme:x,displayMode:u??"inline",maxWidth:P,maxHeight:R,playground:g,deviceType:g.deviceType,toolCallId:n,toolName:r,toolInput:s,toolOutput:a,toolMetadata:i,tool:d}),k=Rc(D);k.current=D;let S=qy(b,l),A=Pc(()=>S?{kind:"live",connection:S,resourceUri:o}:null,[S,o]),_=ss(O=>op(O,t,n),[t,n]),K=ss(O=>{v(n,{toolName:r,protocol:"mcp-apps",hostContext:k.current});let W=O.declaredCsp,j;L==="permissive"?j=["default-src * 'unsafe-inline' 'unsafe-eval' data: blob: filesystem: about:","script-src * 'unsafe-inline' 'unsafe-eval' data: blob:","style-src * 'unsafe-inline' data: blob:","img-src * data: blob: https: http:","media-src * data: blob: https: http:","font-src * data: blob: https: http:","connect-src * data: blob: https: http: ws: wss: about:","frame-src * data: blob: https: http: about:","object-src * data: blob:","base-uri *","form-action *"].join("; "):W&&(j=Cc(W)),T(n,W,j)},[v,n,r,L,T]);Vy(()=>()=>y(n),[n,y]);let $=ss(O=>{w(n,{directive:O.directive,effectiveDirective:O.effectiveDirective??O.directive,blockedUri:O.blockedUri,sourceFile:O.sourceFile??void 0,lineNumber:O.lineNumber??void 0,columnNumber:O.columnNumber??void 0,originalPolicy:O.originalPolicy,timestamp:O.timestamp})},[w,n]),oe=ss(({content:O,structuredContent:W})=>{N(n,{content:O,structuredContent:W});try{localStorage.setItem(`mcp-use:widget-state:${n}`,JSON.stringify(W))}catch{}},[N,n]),ae=ss(({level:O,data:W})=>{let j=O==="warning"?"warn":O==="error"?"error":"log";Ni.publish({level:j,args:Array.isArray(W)?W:[W],timestamp:new Date().toISOString(),url:o})},[o]),ie=Pc(()=>({title:b?Si(b):"MCP Server",iconUrl:b?cp(b):null}),[b]),ne=ss(({onClick:O,"data-testid":W,"aria-label":j})=>dp(E,{type:"button",variant:"tertiary",size:"icon-sm",className:"rounded-full shadow-sm","data-testid":W,"aria-label":j,onClick:O,children:dp($y,{})}),[]);if(!A)return null;let z=c??(g.deviceType==="mobile"?P:void 0);return{source:A,hostInfo:jy,hostContext:D,cspMode:L,wrapTransport:_,onCspViolation:$,onModelContextUpdate:oe,onLog:ae,onResourceResolved:K,displayMode:u,onDisplayModeChange:h,inlineMaxWidth:z,chromeless:m,onReady:p,mockOpenAiFileApis:!0,fullscreenHeader:ie,renderFullscreenClose:ne}}import{jsx as Wy}from"react/jsx-runtime";function jo({children:e,className:t,noWrapper:n}){return n?e:Wy("div",{className:C("flex flex-1 items-center justify-center bg-zinc-50 dark:bg-zinc-800","[background-image:radial-gradient(circle,rgba(0,0,0,0.12)_1px,transparent_1px)]","dark:[background-image:radial-gradient(circle,rgba(255,255,255,0.1)_1px,transparent_1px)]","bg-[length:32px_32px]",t),children:e})}import{Loader2Icon as Ky}from"lucide-react";import{jsx as Jy}from"react/jsx-runtime";function Kt({className:e,...t}){return Jy(Ky,{role:"status","aria-label":"Loading",className:C("size-4 animate-spin",e),...t})}import{jsx as as}from"react/jsx-runtime";function Pi({serverId:e,viewId:t,toolName:n,resourceUri:o,toolInput:r,toolOutput:s,toolMetadata:a,readResource:i,customProps:d,displayMode:l,onDisplayModeChange:u,onSendFollowUp:h,onWidgetHeightChange:c,partialToolInput:m,cancelled:p,noWrapper:x=!1,className:f}){let b=Ti({serverId:e,viewId:t,resourceUri:o,toolName:n,toolInput:r,toolOutput:s,toolMetadata:a,readResource:i,displayMode:l,onDisplayModeChange:u});if(!b){let w=as(Kt,{className:"size-5"});return x?as("div",{className:"flex h-full w-full min-h-0 flex-1 items-center justify-center",children:w}):as(jo,{className:"w-full h-full min-h-[240px]",children:w})}let g=C(l==="inline"?"w-full h-full flex items-center justify-center relative p-4 min-h-0":"w-full h-full relative p-4",f),v=d?JSON.stringify(d):"no-custom-props",y=as(Gy,{viewId:t,toolName:n,toolInput:r,toolOutput:s,customProps:d,partialToolInput:m,cancelled:p,className:g,onMessage:w=>{w.length>0&&h&&h(w)},onInlineHeightChange:l==="inline"?c:void 0,...b},v);return x?as("div",{className:"flex h-full w-full min-h-0 flex-1 flex-col",children:y}):as(jo,{className:"w-full h-full min-h-[240px]",children:y})}import{Braces as Gp,ChevronDown as Fx,ChevronRight as $x,Clock as Vx,Copy as Yp,Maximize2 as jx,Monitor as of,Moon as qx,MousePointer2 as Wx,PictureInPicture as Kx,Pointer as Jx,Settings as Gx,ShieldCheck as Qp,ShieldOff as Xp,Smartphone as rf,SquareDashedMousePointer as Yx,Sun as Qx,Trash2 as Xx}from"lucide-react";import{useCallback as Zx,useEffect as Bi,useMemo as oa,useRef as e0,useState as yo}from"react";import{toast as _c}from"sonner";var Yy=[{value:"en-US",label:"English (US)"},{value:"en-GB",label:"English (UK)"},{value:"en-CA",label:"English (Canada)"},{value:"en-AU",label:"English (Australia)"},{value:"en-IN",label:"English (India)"},{value:"es-ES",label:"Spanish (Spain)"},{value:"es-MX",label:"Spanish (Mexico)"},{value:"es-AR",label:"Spanish (Argentina)"},{value:"es-CO",label:"Spanish (Colombia)"},{value:"fr-FR",label:"French (France)"},{value:"fr-CA",label:"French (Canada)"},{value:"fr-BE",label:"French (Belgium)"},{value:"fr-CH",label:"French (Switzerland)"},{value:"de-DE",label:"German (Germany)"},{value:"de-AT",label:"German (Austria)"},{value:"de-CH",label:"German (Switzerland)"},{value:"pt-BR",label:"Portuguese (Brazil)"},{value:"pt-PT",label:"Portuguese (Portugal)"},{value:"zh-CN",label:"Chinese (Simplified, China)"},{value:"zh-TW",label:"Chinese (Traditional, Taiwan)"},{value:"zh-HK",label:"Chinese (Traditional, Hong Kong)"},{value:"ja-JP",label:"Japanese (Japan)"},{value:"ko-KR",label:"Korean (Korea)"},{value:"ar-SA",label:"Arabic (Saudi Arabia)"},{value:"ar-EG",label:"Arabic (Egypt)"},{value:"hi-IN",label:"Hindi (India)"},{value:"ru-RU",label:"Russian (Russia)"},{value:"it-IT",label:"Italian (Italy)"},{value:"nl-NL",label:"Dutch (Netherlands)"},{value:"nl-BE",label:"Dutch (Belgium)"},{value:"pl-PL",label:"Polish (Poland)"},{value:"sv-SE",label:"Swedish (Sweden)"},{value:"no-NO",label:"Norwegian (Norway)"},{value:"da-DK",label:"Danish (Denmark)"},{value:"fi-FI",label:"Finnish (Finland)"},{value:"tr-TR",label:"Turkish (Turkey)"},{value:"el-GR",label:"Greek (Greece)"},{value:"cs-CZ",label:"Czech (Czech Republic)"},{value:"hu-HU",label:"Hungarian (Hungary)"},{value:"ro-RO",label:"Romanian (Romania)"},{value:"th-TH",label:"Thai (Thailand)"},{value:"vi-VN",label:"Vietnamese (Vietnam)"},{value:"id-ID",label:"Indonesian (Indonesia)"},{value:"ms-MY",label:"Malay (Malaysia)"},{value:"tl-PH",label:"Tagalog (Philippines)"},{value:"he-IL",label:"Hebrew (Israel)"},{value:"uk-UA",label:"Ukrainian (Ukraine)"},{value:"bg-BG",label:"Bulgarian (Bulgaria)"},{value:"hr-HR",label:"Croatian (Croatia)"},{value:"sk-SK",label:"Slovak (Slovakia)"},{value:"sl-SI",label:"Slovenian (Slovenia)"},{value:"sr-RS",label:"Serbian (Serbia)"},{value:"bn-BD",label:"Bengali (Bangladesh)"},{value:"ta-IN",label:"Tamil (India)"},{value:"te-IN",label:"Telugu (India)"},{value:"mr-IN",label:"Marathi (India)"},{value:"ur-PK",label:"Urdu (Pakistan)"},{value:"fa-IR",label:"Persian (Iran)"},{value:"sw-KE",label:"Swahili (Kenya)"}],up=Yy;function Qy(){return Intl.supportedValuesOf("timeZone").map(t=>({value:t,label:t.replace(/_/g," ")}))}var mp=Qy();import{useCallback as Ri,useEffect as pp,useState as fp}from"react";var gp=e=>`mcp-inspector-resource-props-${e}`;function hp(e){let[t,n]=fp([]),[o,r]=fp(null);pp(()=>{(()=>{try{let u=gp(e),h=localStorage.getItem(u);if(h){let c=JSON.parse(h);n(c.presets||[]),r(c.activePresetId||null)}else n([]),r(null)}catch(u){console.error("[useResourceProps] Failed to load presets:",u),n([]),r(null)}})()},[e]),pp(()=>{let l=gp(e),u={presets:t,activePresetId:o};localStorage.setItem(l,JSON.stringify(u))},[e,t,o]);let s=Ri(l=>{n(u=>{let h=u.findIndex(m=>m.id===l.id),c;return h>=0?(c=[...u],c[h]=l):c=[...u,l],c})},[]),a=Ri(l=>{n(u=>u.filter(h=>h.id!==l)),r(u=>u===l?null:u)},[]),i=Ri(l=>{r(l)},[]),d=Ri(()=>o&&t.find(u=>u.id===o)?.props||null,[o,t]);return{presets:t,activePresetId:o,savePreset:s,deletePreset:a,setActivePreset:i,getActiveProps:d}}import{ChevronDown as ux,ChevronRight as mx,Copy as Mp,Search as px,TerminalIcon as Ic,TrashIcon as fx,X as gx}from"lucide-react";import{useCallback as hx,useEffect as Ec,useMemo as ds,useRef as kp,useState as Qs}from"react";import{toast as Di}from"sonner";import{useCallback as vp,useEffect as bp,useRef as Xy,useState as yp}from"react";function xp(e={}){let{enabled:t=!0,maxLogs:n=1e3,proxyToPageConsole:o=!1}=e,[r,s]=yp([]),[a,i]=yp(!1),d=Xy(0),l=vp(h=>{if(!t)return;let c={...h,id:`log-${++d.current}-${Date.now()}`};if(s(m=>[...m,c].slice(-n)),o){let m="[WIDGET CONSOLE]",p=h.args.map(x=>{if(typeof x=="object"&&x!==null)try{return JSON.stringify(x,null,2)}catch{return String(x)}return x});switch(h.level){case"error":console.error(m,...p);break;case"warn":console.warn(m,...p);break;case"info":console.info(m,...p);break;case"debug":console.debug(m,...p);break;case"trace":console.trace(m,...p);break;default:console.log(m,...p)}}},[t,n,o]),u=vp(()=>{s([]),d.current=0},[]);return bp(()=>{if(!t)return;let h=c=>{c.data&&c.data.type==="iframe-console-log"&&c.data.level&&Array.isArray(c.data.args)&&l({level:c.data.level,args:c.data.args,timestamp:c.data.timestamp||new Date().toISOString(),url:c.data.url})};return window.addEventListener("message",h),()=>{window.removeEventListener("message",h)}},[t,l]),bp(()=>{if(t)return Ni.subscribe(l)},[t,l]),{logs:r,addLog:l,clearLogs:u,isOpen:a,setIsOpen:i}}import{Dialog as qo}from"@base-ui/react/dialog";import{XIcon as Zy}from"lucide-react";import{jsx as Vn,jsxs as Mc}from"react/jsx-runtime";function is({...e}){return Vn(qo.Root,{"data-slot":"sheet",...e})}function Mi(e){return Vn(qo.Trigger,{"data-slot":"sheet-trigger",...e})}function ex({...e}){return Vn(qo.Portal,{"data-slot":"sheet-portal",...e})}function tx({className:e,container:t,...n}){return Vn(qo.Backdrop,{"data-slot":"sheet-overlay",className:C("inset-0 z-50 bg-black/50 transition-opacity duration-150 data-ending-style:opacity-0 data-starting-style:opacity-0",t?"absolute":"fixed",e),...n})}function ls({className:e,children:t,side:n="right",showCloseButton:o=!0,container:r,...s}){return Mc(ex,{container:r??void 0,children:[Vn(tx,{container:r}),Mc(qo.Popup,{"data-slot":"sheet-content","data-side":n,className:C("z-50 flex flex-col gap-4 bg-popover bg-clip-padding text-sm text-popover-foreground shadow-lg transition duration-200 ease-in-out data-ending-style:opacity-0 data-starting-style:opacity-0 data-[side=bottom]:inset-x-0 data-[side=bottom]:bottom-0 data-[side=bottom]:h-auto data-[side=bottom]:border-t data-[side=bottom]:data-ending-style:translate-y-[2.5rem] data-[side=bottom]:data-starting-style:translate-y-[2.5rem] data-[side=left]:inset-y-0 data-[side=left]:left-0 data-[side=left]:h-full data-[side=left]:w-3/4 data-[side=left]:border-r data-[side=left]:data-ending-style:translate-x-[-2.5rem] data-[side=left]:data-starting-style:translate-x-[-2.5rem] data-[side=right]:inset-y-0 data-[side=right]:right-0 data-[side=right]:h-full data-[side=right]:w-3/4 data-[side=right]:border-l data-[side=right]:data-ending-style:translate-x-[2.5rem] data-[side=right]:data-starting-style:translate-x-[2.5rem] data-[side=top]:inset-x-0 data-[side=top]:top-0 data-[side=top]:h-auto data-[side=top]:border-b data-[side=top]:data-ending-style:translate-y-[-2.5rem] data-[side=top]:data-starting-style:translate-y-[-2.5rem] data-[side=left]:sm:max-w-sm data-[side=right]:sm:max-w-sm",r?"absolute":"fixed",e),...s,children:[t,o&&Mc(qo.Close,{"data-slot":"sheet-close",render:Vn(E,{variant:"ghost",className:"absolute top-4 right-4",size:"icon-sm"}),children:[Vn(Zy,{}),Vn("span",{className:"sr-only",children:"Close"})]})]})]})}function Ii({className:e,...t}){return Vn("div",{"data-slot":"sheet-header",className:C("flex flex-col gap-1.5 p-4",e),...t})}function Ei({className:e,...t}){return Vn(qo.Title,{"data-slot":"sheet-title",className:C("font-medium text-foreground",e),...t})}function wp({className:e,...t}){return Vn(qo.Description,{"data-slot":"sheet-description",className:C("text-sm text-muted-foreground",e),...t})}import*as Ai from"react";import{createContext as Np,useContext as Cp,useState as nx}from"react";import{Tooltip as cs}from"@base-ui/react/tooltip";import{motion as ox}from"motion/react";import{Fragment as dx,jsx as Wo,jsxs as cx}from"react/jsx-runtime";var rx=Np(null),sx=200,ax=Np(!1);function ix(e){switch(e){case"top":return{y:4};case"bottom":return{y:-4};case"left":return{x:4};case"right":return{x:-4};default:return{y:4}}}function lx({content:e,children:t,side:n="top",sideOffset:o=8,delayDuration:r,className:s,forceOpen:a,onOpenChange:i}){let[d,l]=nx(!1),u=a!==void 0?a:d,h=pt(),c=Cp(rx),m=Cp(ax),p=ix(n),x=cx(cs.Root,{open:u,onOpenChange:f=>{l(f),i?.(f)},children:[Wo(cs.Trigger,{render:t,delay:r}),Wo(cs.Portal,{container:c??void 0,children:Wo(cs.Positioner,{side:n,sideOffset:o,className:"z-50",children:Wo(cs.Popup,{render:(f,b)=>{let g=b.transitionStatus==="ending",{style:v,onDrag:y,onDragStart:w,onDragEnd:N,onAnimationStart:T,onAnimationEnd:L,onAnimationIteration:P,...R}=f;return Wo(ox.div,{...R,className:C("bg-foreground text-background text-[12px] px-2 py-1","[text-box:trim-both_cap_alphabetic] supports-[text-box:trim-both]:py-2",h.bg,s),style:{...v,fontVariationSettings:yt.medium},initial:{opacity:0,...p},animate:g?{opacity:0,...p}:{opacity:1,x:0,y:0},transition:g?se.fast.exit:se.fast})},children:e})})})]});return m?x:Wo(cs.Provider,{delay:r??sx,children:x})}function we(e){return null}we.displayName="TooltipTrigger";function Ce(e){return null}Ce.displayName="TooltipContent";function ke({children:e,delayDuration:t,open:n,onOpenChange:o}){let r=null,s=null,a="top",i,d;return Ai.Children.forEach(e,l=>{if(Ai.isValidElement(l)&&(l.type===we&&(r=l.props.render),l.type===Ce)){let u=l.props;s=u.children,a=u.side??"top",i=u.className,d=u.sideOffset}}),r?Wo(lx,{content:s,side:a,sideOffset:d,className:i,delayDuration:t,forceOpen:n,onOpenChange:o,children:r}):Wo(dx,{children:e})}import{Fragment as wx,jsx as ze,jsxs as lt}from"react/jsx-runtime";var Sp=200,vx=.9;function Ac(e){if(e===null)return"null";if(e===void 0)return"undefined";if(typeof e=="string")return e;if(typeof e=="object")try{return JSON.stringify(e,null,2)}catch{return String(e)}return String(e)}function Dc(e){if(e.length===0)return[];let t=e[0];if(typeof t!="string"||!/%[oOdisfc]/.test(t))return e.map(Ac);let n=e.slice(1),o=0,r="";for(let a=0;a<t.length;a++){let i=t[a];if(i==="%"&&a+1<t.length){let d=t[a+1],l=n[o++];switch(d){case"o":case"O":r+=Ac(l),a++;break;case"s":r+=l===void 0?"undefined":String(l),a++;break;case"d":case"i":r+=String(Number.parseInt(String(l??""),10)||0),a++;break;case"f":r+=String(Number.parseFloat(String(l??""))||0),a++;break;case"c":a++;break;default:r+=i}continue}r+=i}let s=[r.trim()];for(;o<n.length;)s.push(Ac(n[o++]));return s.filter(a=>a.length>0)}function bx({level:e}){return ze("span",{className:C("px-1.5 py-0.5 text-[11px] font-mono font-semibold rounded-full text-white shrink-0",{log:"bg-zinc-500",info:"bg-blue-500",warn:"bg-yellow-500",error:"bg-red-500",debug:"bg-purple-500",trace:"bg-gray-500"}[e]),children:e.toUpperCase()})}function yx({log:e}){let[t,n]=Qs(!1),o=ds(()=>{try{return new Date(e.timestamp).toLocaleTimeString()}catch{return""}},[e.timestamp]),r=ds(()=>Dc(e.args),[e.args]),s=ds(()=>{if(r.length===0)return"";let l=r[0].replace(/\s*\n\s*/g," ").trim(),u=l.length>120?l.slice(0,120)+"\u2026":l,h=r.length>1?` +${r.length-1}`:"";return u+h},[r]),a=async l=>{l.stopPropagation();try{let u=r.join(`
|
|
63
|
+
`);await Xe(u),Di.success("Copied to clipboard")}catch{Di.error("Failed to copy")}},i=C("font-mono text-xs border-b border-zinc-200 dark:border-zinc-800",e.level==="error"&&"bg-red-50/30 dark:bg-red-950/10",e.level==="warn"&&"bg-yellow-50/30 dark:bg-yellow-950/10"),d=C("cursor-pointer select-none",e.level==="error"&&"hover:bg-red-50/50 dark:hover:bg-red-950/20",e.level==="warn"&&"hover:bg-yellow-50/50 dark:hover:bg-yellow-950/20",e.level!=="error"&&e.level!=="warn"&&"hover:bg-zinc-100/70 dark:hover:bg-zinc-800/40");return lt("div",{className:C(i,"group"),children:[lt("div",{className:C("flex items-center gap-2 px-2 py-1.5",d),onClick:()=>n(l=>!l),children:[ze("span",{className:"text-zinc-400 dark:text-zinc-500 shrink-0",children:t?ze(ux,{className:"size-3"}):ze(mx,{className:"size-3"})}),ze(bx,{level:e.level}),ze("span",{className:"text-zinc-500 dark:text-zinc-400 text-[10px] shrink-0",children:o}),!t&&ze("span",{className:C("truncate text-[11px]",e.level==="error"&&"text-red-700 dark:text-red-400",e.level==="warn"&&"text-yellow-700 dark:text-yellow-400",e.level!=="error"&&e.level!=="warn"&&"text-zinc-700 dark:text-zinc-300"),children:s}),t&&e.url&&ze("span",{className:"text-zinc-400 dark:text-zinc-500 text-[10px] truncate flex-1",children:(()=>{try{return new URL(e.url).pathname}catch{return e.url}})()}),t&&ze("button",{onClick:a,"aria-label":"Copy log",className:"ml-auto shrink-0 opacity-0 group-hover:opacity-100 transition-opacity p-0.5 rounded text-zinc-400 hover:text-zinc-700 dark:hover:text-zinc-200",children:ze(Mp,{className:"size-3"})})]}),t&&ze("div",{className:"pl-8 pr-2 pb-2 select-text",children:r.map((l,u)=>ze("pre",{className:C("whitespace-pre-wrap wrap-break-word text-[11px]",e.level==="error"&&"text-red-700 dark:text-red-400",e.level==="warn"&&"text-yellow-700 dark:text-yellow-400",e.level!=="error"&&e.level!=="warn"&&"text-zinc-700 dark:text-zinc-300"),children:l},u))})]})}var Tp="mcp-inspector-console-proxy-enabled",Pp="mcp-inspector-console-height",xx=["log","info","warn","error","debug","trace"],Rp={log:"text-zinc-500",info:"text-blue-500",warn:"text-yellow-500",error:"text-red-500",debug:"text-purple-500",trace:"text-gray-500"};function Ip({iframeId:e,enabled:t=!0}){let[n,o]=Qs(()=>{if(typeof window>"u")return!0;try{return localStorage.getItem(Tp)==="true"}catch{return!0}}),[r,s]=Qs(()=>{if(typeof window>"u")return 400;try{let P=localStorage.getItem(Pp);return P?Math.max(Sp,parseInt(P,10)):400}catch{return 400}}),a=kp(!1),i=hx(P=>{P.preventDefault(),a.current=!0;let R=k=>{if(!a.current)return;let S=Math.floor(window.innerHeight*vx),A=Math.min(S,Math.max(Sp,window.innerHeight-k.clientY));s(A)},D=()=>{a.current=!1,window.removeEventListener("mousemove",R),window.removeEventListener("mouseup",D)};window.addEventListener("mousemove",R),window.addEventListener("mouseup",D)},[]);Ec(()=>{try{localStorage.setItem(Pp,String(r))}catch{}},[r]);let[d,l]=Qs("all"),[u,h]=Qs(""),{logs:c,clearLogs:m,isOpen:p,setIsOpen:x}=xp({enabled:t,proxyToPageConsole:n}),f=kp(null);Ec(()=>{try{localStorage.setItem(Tp,String(n))}catch{}},[n]);let b=ds(()=>{let P={log:0,info:0,warn:0,error:0,debug:0,trace:0};for(let R of c)P[R.level]++;return P},[c]),g=b.error,v=b.warn,y=b.log+b.info+b.debug+b.trace,w=c.length,N=ds(()=>g>0?"bg-red-500":v>0?"bg-yellow-500":(y>0,"bg-zinc-500"),[g,v,y]),T=ds(()=>{let P=d==="all"?c:c.filter(D=>D.level===d),R=u.trim().toLowerCase();return R&&(P=P.filter(D=>{let k=Dc(D.args).join(" ").toLowerCase(),S=(D.url??"").toLowerCase();return k.includes(R)||S.includes(R)})),P},[c,d,u]);Ec(()=>{p&&!u&&f.current&&(f.current.scrollTop=f.current.scrollHeight)},[T,p,u]);let L=async()=>{try{let P=T.map(R=>{let D=new Date(R.timestamp).toLocaleTimeString(),k=R.level.toUpperCase(),S=R.url?` ${R.url}`:"",A=Dc(R.args).join(`
|
|
64
64
|
`);return`[${k}] ${D}${S}
|
|
65
65
|
${A}`}).join(`
|
|
66
66
|
|
|
67
|
-
`);await Xe(P),Di.success(`Copied ${T.length} logs to clipboard`)}catch{Di.error("Failed to copy logs to clipboard")}};return lt(is,{open:p,onOpenChange:x,children:[ze(Mi,{render:lt(ke,{children:[ze(we,{render:lt(E,{variant:"outline",size:"sm",className:"relative bg-white/90 dark:bg-zinc-900/90 backdrop-blur-sm shadow-sm hover:bg-white dark:hover:bg-zinc-900",onClick:()=>x(!0),children:[ze(Ic,{className:"size-4"}),w>0&&ze("span",{className:C("ml-2 px-1.5 py-0.5 text-xs rounded-full text-white font-semibold",N),children:w})]}),nativeButton:!0}),ze(Ce,{children:lt("div",{className:"text-xs space-y-1",children:[lt("p",{className:"font-semibold",children:[w," console ",w===1?"log":"logs"]}),g>0&<("p",{className:"text-red-400",children:[g," error",g!==1?"s":""]}),v>0&<("p",{className:"text-yellow-400",children:[v," warning",v!==1?"s":""]}),y>0&<("p",{className:"text-zinc-400",children:[y," info"]})]})})]}),nativeButton:!1}),lt(ls,{side:"bottom",className:"flex flex-col p-0 transition-none m-0 gap-0",style:{height:r},children:[ze("div",{className:"h-1.5 w-full shrink-0 cursor-ns-resize bg-zinc-200 dark:bg-zinc-700 hover:bg-zinc-300 dark:hover:bg-zinc-600 transition-colors",onMouseDown:i}),lt(Ii,{className:"px-4 py-4 m-0 border-b border-zinc-200 dark:border-zinc-800 shrink-0",children:[lt("div",{className:"flex items-center justify-between",children:[lt(Ei,{className:"flex items-center gap-2",children:[ze(Ic,{className:"size-4"}),"Widget Console Logs",c.length>0&<("span",{className:"text-sm font-normal text-zinc-500 dark:text-zinc-400",children:["(",c.length," ",c.length===1?"log":"logs",")"]})]}),lt("div",{className:"flex items-center gap-4 pr-4",children:[lt("div",{className:"flex items-center gap-2",children:[ze(os,{id:"proxy-console-toggle",checked:n,onCheckedChange:o}),ze(nt,{htmlFor:"proxy-console-toggle",className:"text-sm font-normal cursor-pointer",children:"Proxy logs to page console"})]}),c.length>0&<(
|
|
67
|
+
`);await Xe(P),Di.success(`Copied ${T.length} logs to clipboard`)}catch{Di.error("Failed to copy logs to clipboard")}};return lt(is,{open:p,onOpenChange:x,children:[ze(Mi,{render:lt(ke,{children:[ze(we,{render:lt(E,{variant:"outline",size:"sm",className:"relative bg-white/90 dark:bg-zinc-900/90 backdrop-blur-sm shadow-sm hover:bg-white dark:hover:bg-zinc-900",onClick:()=>x(!0),children:[ze(Ic,{className:"size-4"}),w>0&&ze("span",{className:C("ml-2 px-1.5 py-0.5 text-xs rounded-full text-white font-semibold",N),children:w})]}),nativeButton:!0}),ze(Ce,{children:lt("div",{className:"text-xs space-y-1",children:[lt("p",{className:"font-semibold",children:[w," console ",w===1?"log":"logs"]}),g>0&<("p",{className:"text-red-400",children:[g," error",g!==1?"s":""]}),v>0&<("p",{className:"text-yellow-400",children:[v," warning",v!==1?"s":""]}),y>0&<("p",{className:"text-zinc-400",children:[y," info"]})]})})]}),nativeButton:!1}),lt(ls,{side:"bottom",className:"flex flex-col p-0 transition-none m-0 gap-0",style:{height:r},children:[ze("div",{className:"h-1.5 w-full shrink-0 cursor-ns-resize bg-zinc-200 dark:bg-zinc-700 hover:bg-zinc-300 dark:hover:bg-zinc-600 transition-colors",onMouseDown:i}),lt(Ii,{className:"px-4 py-4 m-0 border-b border-zinc-200 dark:border-zinc-800 shrink-0",children:[lt("div",{className:"flex items-center justify-between",children:[lt(Ei,{className:"flex items-center gap-2",children:[ze(Ic,{className:"size-4"}),"Widget Console Logs",c.length>0&<("span",{className:"text-sm font-normal text-zinc-500 dark:text-zinc-400",children:["(",c.length," ",c.length===1?"log":"logs",")"]})]}),lt("div",{className:"flex items-center gap-4 pr-4",children:[lt("div",{className:"flex items-center gap-2",children:[ze(os,{id:"proxy-console-toggle",checked:n,onCheckedChange:o}),ze(nt,{htmlFor:"proxy-console-toggle",className:"text-sm font-normal cursor-pointer",children:"Proxy logs to page console"})]}),c.length>0&<(wx,{children:[lt(E,{variant:"ghost",size:"sm",onClick:L,className:"-my-2",children:[ze(Mp,{className:"size-4 mr-1"}),"Copy All"]}),lt(E,{variant:"ghost",size:"sm",onClick:m,className:"-my-2",children:[ze(fx,{className:"size-4 mr-1"}),"Clear"]})]})]})]}),lt("div",{className:"flex items-center gap-1 pt-1",children:[lt("button",{onClick:()=>l("all"),className:C("px-2 py-0.5 text-xs rounded font-medium transition-colors",d==="all"?"bg-zinc-200 dark:bg-zinc-700 text-zinc-900 dark:text-zinc-100":"text-zinc-500 dark:text-zinc-400 hover:bg-zinc-100 dark:hover:bg-zinc-800"),children:["All",w>0&&ze("span",{className:"ml-1 text-[10px] opacity-70",children:w})]}),xx.map(P=>{let R=b[P];return lt("button",{onClick:()=>l(d===P?"all":P),className:C("px-2 py-0.5 text-xs rounded font-medium transition-colors",d===P?"bg-zinc-200 dark:bg-zinc-700 text-zinc-900 dark:text-zinc-100":"text-zinc-500 dark:text-zinc-400 hover:bg-zinc-100 dark:hover:bg-zinc-800"),children:[ze("span",{className:C(R>0&&Rp[P]),children:P.charAt(0).toUpperCase()+P.slice(1)}),R>0&&ze("span",{className:C("ml-1 text-[10px]",Rp[P]),children:R})]},P)}),lt("div",{className:"ml-auto flex items-center gap-1 relative",children:[ze(px,{className:"absolute left-2 size-3 text-zinc-400 dark:text-zinc-500 pointer-events-none"}),ze("input",{type:"text",placeholder:"Filter logs\u2026",value:u,onChange:P=>h(P.target.value),className:"pl-6 pr-6 py-0.5 text-xs rounded border border-zinc-200 dark:border-zinc-700 bg-white dark:bg-zinc-900 text-zinc-900 dark:text-zinc-100 placeholder-zinc-400 dark:placeholder-zinc-500 focus:outline-none focus:ring-1 focus:ring-zinc-400 dark:focus:ring-zinc-500 w-44"}),u&&ze("button",{onClick:()=>h(""),"aria-label":"Clear search",className:"absolute right-1.5 text-zinc-400 hover:text-zinc-600 dark:hover:text-zinc-300",children:ze(gx,{className:"size-3"})})]})]})]}),ze("div",{ref:f,className:"flex-1 overflow-auto bg-zinc-50 dark:bg-zinc-950",children:T.length===0?ze("div",{className:"flex items-center justify-center h-full text-zinc-500 dark:text-zinc-400",children:lt("div",{className:"text-center",children:[ze(Ic,{className:"size-8 mx-auto mb-2 opacity-50"}),ze("p",{className:"text-sm",children:c.length===0?"No console logs yet":u?`No logs match "${u}"`:"No logs match the current filter"}),ze("p",{className:"text-xs mt-1",children:c.length===0?"Logs from iframes will appear here":`${c.length} log${c.length!==1?"s":""} hidden by filter`})]})}):ze("div",{children:T.map(P=>ze(yx,{log:P},P.id))})})]})]})}import{completeChat as Ep}from"@mcp-use/agent";import{useCallback as Cx}from"react";function Ap(e){let t=e.trim(),n=t.match(/```(?:json)?\s*([\s\S]*?)```/);n&&(t=n[1].trim());let o=t.indexOf("{");if(o<0)return null;let r=0;for(let s=o;s<t.length;s++)if(t[s]==="{")r++;else if(t[s]==="}"&&(r--,r===0))try{return JSON.parse(t.slice(o,s+1))}catch{return null}return null}function Dp({llmConfig:e}){return{generateProps:Cx(async({resource:n,resourceAnnotations:o,propsSchema:r})=>{if(!e)throw new Error("LLM config is not available");let s=n.mimeType||o?.mimeType||"unknown",a=n.description||o?.description||"N/A";if(r?.properties){let m=Object.keys(r.properties).map(v=>{let y=r.properties[v],w=` - ${v} (${y.type||"string"})`,N=y.description?`: ${y.description}`:"",T="";return y.type==="array"&&y.items?.type==="object"&&y.items?.properties&&(T=` \u2014 array of objects with keys: {${Object.keys(y.items.properties).join(", ")}}`),`${w}${T}${N}`}).join(`
|
|
68
68
|
`),p="You are helping a developer configure props for a UI widget. The widget has a defined schema with specific props. Generate appropriate values for ONLY the props listed in the schema. Return ONLY a JSON object with these exact keys. For array props, each item must match the specified structure.",x=`Widget: ${n.name||n.uri}
|
|
69
69
|
Description: ${a}
|
|
70
70
|
|
|
@@ -72,7 +72,7 @@ Props Schema:
|
|
|
72
72
|
${m}
|
|
73
73
|
|
|
74
74
|
Generate appropriate default/example values for these props. Return ONLY a JSON object with the exact prop names as keys.
|
|
75
|
-
Example: {"query": "example search term", "results": [{"fruit": "Apple", "color": "red"}]}`,f=[{role:"system",content:p},{role:"user",content:x}],b=await
|
|
75
|
+
Example: {"query": "example search term", "results": [{"fruit": "Apple", "color": "red"}]}`,f=[{role:"system",content:p},{role:"user",content:x}],b=await Ep({config:{provider:e.provider,model:e.model,apiKey:e.apiKey,temperature:e.temperature,baseUrl:e.baseUrl},messages:f}),g=Ap(b);if(g)return Object.entries(g).map(([v,y])=>({key:v,value:typeof y=="object"&&y!==null?JSON.stringify(y):String(y)}));throw new Error("Could not parse props from LLM response")}let i=n.uri?.startsWith("ui://")||n.mimeType==="text/html;profile=mcp-app"||!!o?.ui,d=i?`You are helping preview an MCP App widget in the inspector.
|
|
76
76
|
Generate sample tool result data (structuredContent) that the widget receives via useToolContext().
|
|
77
77
|
Return ONLY a JSON object with realistic sample data the widget needs to render \u2014 query strings, item arrays, IDs, labels, etc.
|
|
78
78
|
Do NOT generate UI styling props like theme, width, height, or showFilters unless explicitly required.
|
|
@@ -91,17 +91,17 @@ Return ONLY JSON.`:`Resource Information:
|
|
|
91
91
|
- Type: ${s}
|
|
92
92
|
- Description: ${a}
|
|
93
93
|
|
|
94
|
-
Based on this information, suggest 3-5 common customizable properties like theme, dimensions, colors, titles, or configuration options that would be useful for this type of resource. Keep it simple and practical.`,u=[{role:"system",content:d},{role:"user",content:l}],h=await
|
|
95
|
-
`),p=[];for(let x of m){let f=x.match(/^\s*["']?(\w+)["']?\s*[:=]\s*["']?(.+?)["']?\s*,?\s*$/);f&&p.push({key:f[1].trim(),value:f[2].trim().replace(/^["']|["']$/g,"")})}if(p.length>0)return p;throw new Error("Could not parse props from LLM response")}catch(c){throw console.error("[usePropsLLM] Failed to parse LLM response:",c),new Error(`Failed to parse props from LLM response: ${h.slice(0,100)}...`)}},[e]),isAvailable:e!==null}}import{Loader2 as Tx,Plus as Px,Sparkles as Rx,Trash2 as Mx}from"lucide-react";import{useEffect as Ix,useMemo as Ex,useState as Xs}from"react";import{toast as Tr}from"sonner";import{jsx as Tn,jsxs as Sr}from"react/jsx-runtime";function Op(e,t){if(!e?.$ref)return e;let n=e.$ref;if(n.startsWith("#/")){let o=n.substring(2).split("/"),r=t;for(let s of o)if(r&&typeof r=="object"&&s in r)r=r[s];else return console.warn(`Could not resolve $ref: ${n}`),e;return r}return e}function kx(e,t){if(e.anyOf&&Array.isArray(e.anyOf)){let n=e.anyOf.find(o=>o.type!=="null");if(n)return{...Op(n,t),nullable:!0}}return e}function Sx(e){return Array.isArray(e.enum)?e.enum:null}function zp({name:e,schema:t,value:n,onChange:o,required:r=!1,disabled:s=!1,rootSchema:a}){let i=a||t,d=kx(t,i);d=Op(d,i);let l=Sx(d),u=d.type==="string"&&l!==null,h=d;return h.type==="object"||h.type==="array"?Sr("div",{className:"space-y-2",children:[Sr(nt,{htmlFor:e,className:"text-sm font-medium",children:[e,r&&Tn("span",{className:"text-red-500 ml-1",children:"*"})]}),Tn(no,{id:e,value:n,onChange:m=>o(m.target.value),placeholder:h?.description||h?.default?JSON.stringify(h.default,null,2):`Enter ${e}`,className:"min-h-[100px]",disabled:s}),h?.description&&Tn("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:h.description})]}):u&&l?Sr("div",{className:"space-y-2",children:[Sr(nt,{htmlFor:e,className:"text-sm font-medium",children:[e,r&&Tn("span",{className:"text-red-500 ml-1",children:"*"})]}),Sr(kn,{value:n||"",onValueChange:o,disabled:s,children:[Tn(Vn,{id:e,className:"w-full",children:Tn(Fn,{placeholder:h.description||"Select an option"})}),Tn($n,{children:l.map((m,p)=>Tn(Wt,{value:m,children:h.enumNames?.[p]||m},m))})]}),h.description&&Tn("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:h.description})]}):Sr("div",{className:"space-y-2",children:[Sr(nt,{htmlFor:e,className:"text-sm font-medium",children:[e,r&&Tn("span",{className:"text-red-500 ml-1",children:"*"})]}),Tn(Ge,{id:e,value:n,onChange:m=>o(m.target.value),placeholder:h?.description||(h?.default!==void 0?String(h.default):`Enter ${e}`),type:h.type==="number"?"number":"text",disabled:s}),h?.description&&Tn("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:h.description})]})}import{Fragment as Bp,jsx as Et,jsxs as Ft}from"react/jsx-runtime";function Hp({open:e,onOpenChange:t,onSave:n,existingPresets:o,resource:r,resourceAnnotations:s,llmConfig:a,editingPreset:i}){let d=Ex(()=>{let D=A=>{if(!A)return null;if(A.type==="object"&&A.properties)return A;let _=A?.def?.shape??A?._def?.shape;if(_&&typeof _=="object"){let K={},$=[],oe=ne=>({ZodString:"string",string:"string",ZodNumber:"number",number:"number",ZodBoolean:"boolean",boolean:"boolean",ZodArray:"array",array:"array",ZodObject:"object",object:"object"})[ne]||"string",ae=ne=>ne?.typeName??ne?.type??"",ie=ne=>{let z=ne?._def??ne?.def??{},O=ne,W=ae(z);for(;W==="ZodOptional"||W==="ZodDefault"||W==="ZodNullable";){O=z.innerType??O;let U=O?._def??O?.def??{};W=ae(U)}let j=oe(W);if(j==="array"){let U=O?._def?.type??O?.def?.element??O?.element;if(U){let H=U._def??U.def??{};if(oe(ae(H))==="object"){let Te=H.shape??U._def?.shape??U.def?.shape??{};return{type:"array",items:{type:"object",properties:Object.fromEntries(Object.entries(Te).map(([Pe,le])=>{let de=le?._def??le?.def??{};return[Pe,{type:oe(ae(de))}]}))}}}}return{type:"array"}}return{type:j}};for(let[ne,z]of Object.entries(_)){let O=z,W=O?._def??O?.def??{},j=ae(W),U=j==="ZodOptional"||j==="ZodDefault"||j==="ZodNullable",H=ie(O);K[ne]={type:H.type,...H.items&&{items:H.items},description:O?.description??W.description},U||$.push(ne)}if(Object.keys(K).length>0)return{type:"object",properties:K,required:$.length>0?$:void 0}}return null},k=s;if(k?.["mcp-use/propsSchema"])return D(k["mcp-use/propsSchema"]);let S=r.annotations;return S?.["mcp-use/propsSchema"]?D(S["mcp-use/propsSchema"]):null},[s,r.annotations,r.uri,r.name]),l=!!d,[u,h]=Xs(""),[c,m]=Xs({}),[p,x]=Xs([{id:crypto.randomUUID(),key:"",value:""}]),[f,b]=Xs(!1),[g,v]=Xs(null),{generateProps:y,isAvailable:w}=_p({llmConfig:a});Ix(()=>{if(e){if(i)if(h(i.name),l)m(i.props);else{let D=Object.entries(i.props).map(([k,S])=>({id:crypto.randomUUID(),key:k,value:S}));x(D.length>0?D:[{id:crypto.randomUUID(),key:"",value:""}])}else h(""),l?m({}):x([{id:crypto.randomUUID(),key:"",value:""}]);v(null)}},[e,i,l]);let N=()=>{x([...p,{id:crypto.randomUUID(),key:"",value:""}])},T=D=>{p.length>1&&x(p.filter(k=>k.id!==D))},L=(D,k,S)=>{x(p.map(A=>A.id===D?{...A,[k]:S}:A))},P=async()=>{if(!w){Tr.error("LLM not configured",{description:"Please configure LLM in the Chat tab first."});return}b(!0),v(null);try{let D=await y({resource:r,resourceAnnotations:s,propsSchema:l?d:void 0});if(l){let k={};for(let S of D)d.properties?.[S.key]&&(k[S.key]=S.value);m(k)}else x(D.map(k=>({id:crypto.randomUUID(),key:k.key,value:k.value})));Tr.success("Props generated successfully",{description:`Generated ${D.length} prop(s) using ${a?.provider}`})}catch(D){let k=D instanceof Error?D.message:"Failed to generate props";v(k),Tr.error("LLM Generation Failed",{description:k})}finally{b(!1)}},R=()=>{if(!u.trim()){Tr.error("Preset name required",{description:"Please enter a name for this preset."});return}if(o.find(A=>A.name.toLowerCase()===u.toLowerCase()&&A.id!==i?.id)){Tr.error("Duplicate preset name",{description:"A preset with this name already exists."});return}let k;if(l)k={...c};else{k={};for(let A of p)A.key.trim()&&(k[A.key.trim()]=A.value)}if(Object.keys(k).length===0){Tr.error("No props defined",{description:"Please add at least one prop with a key."});return}let S={id:i?.id||crypto.randomUUID(),name:u.trim(),props:k};n(S),t(!1),Tr.success(i?"Preset updated":"Preset created",{description:`Preset "${S.name}" saved successfully.`})};return Et(fn,{open:e,onOpenChange:t,children:Ft(on,{scrollable:!0,className:"sm:max-w-[600px] max-h-[80vh]","data-testid":"props-config-dialog",children:[Ft(Qt,{children:[Et(qt,{children:i?"Edit Preset":"Create Props Preset"}),Ft(ho,{children:["Configure props for ",r.name||r.uri,". You can manually add key-value pairs or generate them with AI."]})]}),Ft(Un,{className:"space-y-4 py-4",children:[Ft("div",{className:"space-y-2",children:[Et(nt,{htmlFor:"preset-name",children:"Preset Name"}),Et(Ge,{id:"preset-name","data-testid":"props-config-preset-name",value:u,onChange:D=>h(D.target.value),placeholder:"e.g., Dark Theme, Production Config",disabled:f})]}),Ft("div",{className:"space-y-2 p-3 bg-muted rounded-lg",children:[Ft("div",{className:"flex items-center justify-between",children:[Et(nt,{className:"text-sm font-medium",children:"Generate with AI"}),w&&Ft("span",{className:"text-xs text-muted-foreground",children:["Using ",a?.provider," (",a?.model,")"]})]}),w?Et(E,{onClick:P,disabled:f,size:"sm",variant:"outline",className:"w-full","data-testid":"props-config-generate-llm-button",children:f?Ft("span",{"data-testid":"props-config-generating",className:"flex items-center gap-2",children:[Et(Tx,{className:"h-4 w-4 mr-2 animate-spin"}),"Generating..."]}):Ft(Bp,{children:[Et(Rx,{className:"h-4 w-4 mr-2"}),"Generate Props with LLM"]})}):Et("p",{className:"text-xs text-muted-foreground",children:"LLM not configured. Please configure LLM in the Chat tab to use this feature."}),g&&Et("p",{className:"text-xs text-destructive","data-testid":"props-config-error",children:g})]}),Ft("div",{className:"space-y-3",children:[Et(nt,{className:"text-sm font-medium",children:"Props"}),l?Et("div",{className:"space-y-4",children:Object.entries(d.properties||{}).map(([D,k])=>Et(zp,{name:D,schema:k,value:c[D]||"",onChange:S=>m(A=>({...A,[D]:S})),required:d.required?.includes(D),disabled:f,rootSchema:d},D))}):Ft(Bp,{children:[Et("div",{className:"flex items-center justify-between",children:Ft(E,{onClick:N,size:"sm",variant:"ghost",disabled:f,"data-testid":"props-config-add-prop",children:[Et(Px,{className:"h-4 w-4 mr-1"}),"Add Prop"]})}),p.map((D,k)=>Ft("div",{className:"flex items-center gap-2",children:[Ft("div",{className:"flex-1 grid grid-cols-2 gap-2",children:[Et(Ge,{placeholder:"Key",value:D.key,onChange:S=>L(D.id,"key",S.target.value),disabled:f,"data-testid":`props-config-key-${k}`}),Et(Ge,{placeholder:"Value",value:D.value,onChange:S=>L(D.id,"value",S.target.value),disabled:f,"data-testid":`props-config-value-${k}`})]}),Et(E,{variant:"ghost",size:"sm",onClick:()=>T(D.id),disabled:p.length===1||f,className:"h-9 w-9 p-0","data-testid":`props-config-remove-${k}`,children:Et(Mx,{className:"h-4 w-4 text-muted-foreground"})})]},D.id))]})]})]}),Ft(li,{children:[Et(E,{variant:"outline",onClick:()=>t(!1),disabled:f,"data-testid":"props-config-cancel-button",children:"Cancel"}),Ft(E,{onClick:R,disabled:f,"data-testid":"props-config-save-button",children:[i?"Update":"Create"," Preset"]})]})]})})}function Up(e){if(e===0)return"0 Bytes";let t=1024,n=["Bytes","KB","MB","GB"],o=Math.floor(Math.log(e)/Math.log(t));return Math.round(e/Math.pow(t,o)*100)/100+" "+n[o]}function Fp(e){if(e===0)return"0 B";let t=1024,n=["B","KB","MB"],o=Math.floor(Math.log(e)/Math.log(t));return`${parseFloat((e/Math.pow(t,o)).toFixed(1))} ${n[o]}`}var $p=100*1024,Vp=1024*20;function Li(e,t){if(e==null)return e;if(typeof e=="string")return e.length>t?e.substring(0,t)+"... (truncated)":e;if(Array.isArray(e))return e.map(n=>Li(n,t));if(typeof e=="object"){let n={};for(let o in e)Object.prototype.hasOwnProperty.call(e,o)&&(n[o]=Li(e[o],t));return n}return e}function jp(e){let t=JSON.stringify(e,null,2);return new TextEncoder().encode(t).length>$p?Li(e,Vp):e}function _i(e){let t=JSON.stringify(e,null,2),n=new TextEncoder().encode(t).length,o=n>$p,r;if(o){let a=Li(e,Vp);r=JSON.stringify(a,null,2)}else r=t;let s=Up(n);return{isLarge:o,size:n,sizeFormatted:s,preview:r,full:t}}function Oi(e,t){try{let n=JSON.stringify(e,null,2),o=globalThis.Blob,r=new o([n],{type:"application/json"}),s=URL.createObjectURL(r),a=document.createElement("a");a.href=s,a.download=t||`data-${Date.now()}.json`,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(s)}catch(n){throw console.error("Failed to download JSON:",n),n}}import{jsx as Lx}from"react/jsx-runtime";var Ax={key:"text-sky-600 dark:text-sky-400",string:"text-emerald-600 dark:text-emerald-400",number:"text-amber-600 dark:text-amber-400",boolean:"text-violet-600 dark:text-violet-400",null:"text-zinc-500 dark:text-zinc-400",punctuation:"text-muted-foreground"};function Dx(e){let t=[],n=0,o=(r,s)=>{s&&t.push({kind:r,text:s})};for(;n<e.length;){let r=e[n];if(r==='"'){let s=n;for(n++;n<e.length;){if(e[n]==="\\"){n+=2;continue}if(e[n]==='"'){n++;break}n++}let a=e.slice(s,n),i=n;for(;i<e.length&&/[ \t]/.test(e[i]);)i++;let d=e[i]===":";o(d?"key":"string",a);continue}if(/[0-9-]/.test(r)){let s=n;for(e[n]==="-"&&n++;n<e.length&&/[0-9.eE+-]/.test(e[n]);)n++;o("number",e.slice(s,n));continue}if(e.startsWith("true",n)||e.startsWith("false",n)){let s=e.startsWith("true",n)?"true":"false";o("boolean",s),n+=s.length;continue}if(e.startsWith("null",n)){o("null","null"),n+=4;continue}if(/[{}[\],:]/.test(r)){o("punctuation",r),n++;continue}o("punctuation",r),n++}return t}function Lc(e){return Dx(e).map((t,n)=>Lx("span",{className:Ax[t.kind],children:t.text},n))}import{Download as Hx}from"lucide-react";import{ChevronRight as _x}from"lucide-react";import{useState as Ox}from"react";import{Fragment as zi,jsx as xt,jsxs as ro}from"react/jsx-runtime";var Zt={string:"text-emerald-600 dark:text-emerald-400",number:"text-amber-600 dark:text-amber-400",boolean:"text-violet-600 dark:text-violet-400",null:"text-zinc-500 dark:text-zinc-400",key:"text-sky-600 dark:text-sky-400",punctuation:"text-muted-foreground"};function zx(e){return e===null?xt("span",{className:Zt.null,children:"null"}):typeof e=="string"?xt("span",{className:Zt.string,children:JSON.stringify(e)}):typeof e=="number"?xt("span",{className:Zt.number,children:String(e)}):typeof e=="boolean"?xt("span",{className:Zt.boolean,children:String(e)}):xt("span",{className:Zt.string,children:JSON.stringify(e)})}function Bx(e){return Array.isArray(e)?`[${e.length}]`:`{${Object.keys(e).length}}`}function qp({label:e,value:t,depth:n,defaultExpanded:o}){let r=t!==null&&typeof t=="object"&&!Array.isArray(t)?Object.keys(t).length>0:Array.isArray(t)?t.length>0:!1,[s,a]=Ox(r&&(o||n===0));if(!r){let c=Array.isArray(t)?"[]":"{}";return t!==null&&typeof t=="object"?ro("div",{className:"font-mono text-[0.8rem] leading-relaxed",style:{paddingLeft:n*12},children:[e!=null&&ro(zi,{children:[xt("span",{className:Zt.key,children:JSON.stringify(e)}),xt("span",{className:Zt.punctuation,children:": "})]}),xt("span",{className:Zt.punctuation,children:c})]}):ro("div",{className:"font-mono text-[0.8rem] leading-relaxed",style:{paddingLeft:n*12},children:[e!=null&&ro(zi,{children:[xt("span",{className:Zt.key,children:JSON.stringify(e)}),xt("span",{className:Zt.punctuation,children:": "})]}),zx(t)]})}let i=Array.isArray(t)?t.map((h,c)=>[String(c),h]):Object.entries(t),d=Array.isArray(t),l=d?"[":"{",u=d?"]":"}";return ro("div",{className:"font-mono text-[0.8rem] leading-relaxed",children:[ro("div",{className:"flex items-start gap-0.5",style:{paddingLeft:n*12},children:[xt("button",{type:"button","aria-expanded":s,onClick:()=>a(h=>!h),className:"mt-0.5 inline-flex shrink-0 items-center justify-center rounded-sm text-muted-foreground hover:text-foreground",children:xt(_x,{className:C("h-3.5 w-3.5 transition-transform",s&&"rotate-90")})}),ro("div",{className:"min-w-0 flex-1",children:[e!=null&&ro(zi,{children:[xt("span",{className:Zt.key,children:JSON.stringify(e)}),xt("span",{className:Zt.punctuation,children:": "})]}),xt("span",{className:Zt.punctuation,children:l}),!s&&ro(zi,{children:[xt("button",{type:"button",onClick:()=>a(!0),className:"mx-1 text-xs text-muted-foreground hover:text-foreground",children:Bx(t)}),xt("span",{className:Zt.punctuation,children:u})]})]})]}),s&&ro("div",{children:[i.map(([h,c])=>xt(qp,{label:h,value:c,depth:n+1,defaultExpanded:o},`${n}-${h}`)),xt("div",{style:{paddingLeft:n*12},children:xt("span",{className:Zt.punctuation,children:u})})]})]})}function Wp({data:e,defaultExpanded:t=!0,className:n}){return xt("div",{className:C("text-gray-900 dark:text-gray-100 [overflow-wrap:anywhere]",n),"data-testid":"collapsible-json",children:xt(qp,{value:e,depth:0,defaultExpanded:t})})}import{jsx as bo,jsxs as us}from"react/jsx-runtime";var Kp="font-mono text-[0.8rem] text-gray-900 dark:text-gray-100 whitespace-pre-wrap break-words [overflow-wrap:anywhere]";function wt({data:e,filename:t,className:n,collapsible:o=!1,defaultExpanded:r=!0,...s}){let a=_i(e),i=jp(e),d=()=>{Oi(e,t)},l=a.isLarge?bo("div",{className:"mb-3 p-3 bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-lg",children:us("div",{className:"flex items-center justify-between gap-2",children:[us("div",{className:"flex-1",children:[us("p",{className:"text-sm font-medium text-yellow-800 dark:text-yellow-300 mb-1",children:["JSON is too large (",a.sizeFormatted,")"]}),bo("p",{className:"text-xs text-yellow-700 dark:text-yellow-400",children:"Showing full structure with truncated values. Download the full JSON file to see complete values."})]}),us(E,{variant:"outline",size:"sm",onClick:d,className:"shrink-0",children:[bo(Hx,{className:"h-4 w-4 mr-1"}),"Download"]})]})}):null;return o?us("div",{className:n,...s,children:[l,bo(Wp,{data:i,defaultExpanded:r})]}):a.isLarge?us("div",{className:n,...s,children:[l,bo("pre",{className:Kp,children:bo("code",{children:Lc(a.preview)})})]}):bo("div",{className:n,...s,children:bo("pre",{className:Kp,children:bo("code",{children:Lc(a.preview)})})})}import{jsx as Ko,jsxs as Zs}from"react/jsx-runtime";function Jp({value:e,onChange:t}){let n=(o,r)=>{let s=parseInt(r,10);isNaN(s)||t({...e,[o]:s})};return Zs("div",{className:"grid grid-cols-2 gap-2",children:[Zs("div",{className:"space-y-1",children:[Ko("label",{className:"text-xs text-muted-foreground",children:"Top"}),Ko(Ge,{type:"number",min:"0",value:e.top,onChange:o=>n("top",o.target.value),className:"h-8","data-testid":"debugger-safe-area-top"})]}),Zs("div",{className:"space-y-1",children:[Ko("label",{className:"text-xs text-muted-foreground",children:"Right"}),Ko(Ge,{type:"number",min:"0",value:e.right,onChange:o=>n("right",o.target.value),className:"h-8","data-testid":"debugger-safe-area-right"})]}),Zs("div",{className:"space-y-1",children:[Ko("label",{className:"text-xs text-muted-foreground",children:"Bottom"}),Ko(Ge,{type:"number",min:"0",value:e.bottom,onChange:o=>n("bottom",o.target.value),className:"h-8","data-testid":"debugger-safe-area-bottom"})]}),Zs("div",{className:"space-y-1",children:[Ko("label",{className:"text-xs text-muted-foreground",children:"Left"}),Ko(Ge,{type:"number",min:"0",value:e.left,onChange:o=>n("left",o.target.value),className:"h-8","data-testid":"debugger-safe-area-left"})]})]})}function Gp(e,t){let n=new Set(t?.connectDomains??[]),o=new Set(t?.resourceDomains??[]),r=new Set(t?.frameDomains??[]),s=new Set(["script-src","style-src","img-src","font-src","media-src"]),a="connect-src",i="frame-src";for(let l of e){let u=(l.blockedUri||"").trim();if(!u||u==="(inline)"||u.startsWith("blob:")||u.startsWith("data:"))continue;let h=null;try{h=new URL(u).origin}catch{continue}if(!h)continue;let c=(l.effectiveDirective||l.directive||"").toLowerCase();c===a?(n.add(h),h.startsWith("http://")?n.add(h.replace("http://","ws://")):h.startsWith("https://")&&n.add(h.replace("https://","wss://"))):s.has(c)?o.add(h):c===i&&r.add(h)}let d={connectDomains:Array.from(n).sort(),resourceDomains:Array.from(o).sort()};return r.size>0&&(d.frameDomains=Array.from(r).sort()),d}var Ux="https://raw.githubusercontent.com/modelcontextprotocol/ext-apps/bcfffb6585ea4fb1e3a9da39fb8911b83399fa71/specification/2026-01-26/apps.mdx",Fx="https://mcp-use.com/docs/typescript/server/csp";function Yp(e,t,n,o){let r=["Fix the Content Security Policy (CSP) for this MCP Apps widget. The widget has CSP violations that block network requests and resources.","","**References:**",`- MCP Apps CSP spec: ${Ux}`,`- mcp-use CSP docs: ${Fx}`,""];if(r.push("**Current declared CSP:**"),e?(r.push(`connectDomains: ${JSON.stringify(e.connectDomains??[])}`),r.push(`resourceDomains: ${JSON.stringify(e.resourceDomains??[])}`),r.push(`frameDomains: ${JSON.stringify(e.frameDomains??[])}`),r.push(`baseUriDomains: ${JSON.stringify(e.baseUriDomains??[])}`)):r.push("No CSP declared."),r.push(""),t&&(r.push("**Effective policy (originalPolicy):**"),r.push("```"),r.push(t),r.push("```"),r.push("")),n.length>0){r.push(`**Blocked requests (${n.length}):**`);for(let s of n){let a=s.effectiveDirective||s.directive,i=s.blockedUri||"(inline)";r.push(`- ${a}: ${i}`)}r.push("")}return o?(r.push("**Apply this CSP config to fix the violations:**"),r.push("Add these domains to the widget's CSP metadata (resource _meta.ui.csp). Use camelCase for MCP Apps (connectDomains, resourceDomains)."),r.push(""),r.push("```json"),r.push(JSON.stringify({connectDomains:o.connectDomains,resourceDomains:o.resourceDomains,...o.frameDomains?.length?{frameDomains:o.frameDomains}:{}},null,2)),r.push("```")):r.push("No blocked requests - no fix needed."),r.join(`
|
|
96
|
-
`)}import{Popover as ea}from"@base-ui/react/popover";import{jsx as ta}from"react/jsx-runtime";function Jo({...e}){return ta(ea.Root,{"data-slot":"popover",...e})}function Go(e){return ta(ea.Trigger,{"data-slot":"popover-trigger",...e})}function Yo({className:e,align:t="center",alignOffset:n=0,side:o="bottom",sideOffset:r=4,...s}){return ta(ea.Portal,{children:ta(ea.Positioner,{align:t,alignOffset:n,side:o,sideOffset:r,className:"isolate z-50",children:ta(ea.Popup,{"data-slot":"popover-content",className:C("z-50 flex w-72 origin-(--transform-origin) flex-col gap-4 rounded-md bg-popover p-4 text-sm text-popover-foreground shadow-md ring-1 ring-foreground/10 outline-hidden duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-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 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",e),...s})})})}import{Fragment as rf,jsx as F,jsxs as ve}from"react/jsx-runtime";var Pr="__no_props__",na="__tool_props__",tf="__create_preset__",nf=[{value:"desktop",label:"Desktop",icon:sf},{value:"mobile",label:"Mobile",icon:af}];function of({options:e,value:t,onValueChange:n,placeholder:o,contentTestId:r,searchTestId:s,optionTestId:a,trigger:i}){let[d,l]=yo(!1),[u,h]=yo(""),c=t0(null);Bi(()=>{if(!d){h("");return}let x=requestAnimationFrame(()=>c.current?.focus());return()=>cancelAnimationFrame(x)},[d]);let m=oa(()=>{let x=u.trim().toLowerCase();return x?e.filter(f=>f.label.toLowerCase().includes(x)||f.value.toLowerCase().includes(x)):[...e]},[e,u]),p=m.findIndex(x=>x.value===t);return ve(Cr,{open:d,onOpenChange:l,children:[i,ve(Nr,{"data-testid":r,checkedIndex:p>=0?p:void 0,className:"w-80 overflow-hidden",children:[F("div",{className:"border-b border-border p-2",onKeyDown:x=>x.stopPropagation(),children:F(Ge,{ref:c,value:u,onChange:x=>h(x.target.value),placeholder:o,"data-testid":s,className:"h-8"})}),F("div",{className:"max-h-64 overflow-y-auto",children:m.length===0?F("p",{className:"px-3 py-4 text-xs text-muted-foreground",children:"No results found."}):m.map((x,f)=>F(yr,{index:f,label:x.label,checked:t===x.value,"data-testid":a(x.value),onSelect:()=>{n(x.value),l(!1)}},x.value))})]})]})}function Hi({displayMode:e,onDisplayModeChange:t,toolCallId:n,propsContext:o,resourceUri:r,toolInput:s,resourceAnnotations:a,llmConfig:i,resource:d,onPropsChange:l,requiredProps:u}){let{resolvedTheme:h,setTheme:c}=oo(),{playground:m,updatePlaygroundSettings:p,widgets:x,clearCspViolations:f}=Vo(),b=x.get(n),g=b?.cspViolations??[],v=b?.declaredCsp,y=b?.effectivePolicy,w=g.length>0?Gp(g,v):null,N=g.length>0?Yp(v,y,g,w):"",T=e==="fullscreen",L=e==="pip",{presets:P,activePresetId:R,savePreset:D,deletePreset:k,setActivePreset:S,getActiveProps:A}=bp(r),[_,K]=yo(!1),oe=!!u?.length&&!R,[ae,ie]=yo(()=>oe);Bi(()=>{oe&&ie(!0)},[oe]);let[ne,z]=yo(null),[O,W]=yo(!1),[j,U]=yo("mode"),[H,Te]=yo(!0),Pe=oa(()=>Zm(v),[v]),le=oa(()=>ep(y),[y]),de=oa(()=>tp(Pe,le),[Pe,le]),De=oa(()=>np({mode:m.cspMode,declared:v,effectivePolicy:y,violations:g}),[m.cspMode,v,y,g]),Re=e0(()=>o==="tool"&&s?na:Pr,[o,s]),[Oe,Be]=yo(Re());Bi(()=>{R&&o!=="tool"?Be(R):Oe!==Pr&&Oe!==na&&Be(Re())},[R,Oe,Re,o]),Bi(()=>{if(l){if(Oe===Pr||Oe===na)l(null);else if(R&&Oe===R){let M=A();M&&l(M)}}},[Oe,R,s,A,l,P]);let tt=M=>{if(M===tf){z(null),K(!0);return}if(M===Pr||M===na)S(null),Be(M),l?.(null);else{S(M),Be(M);let Ne=P.find(gt=>gt.id===M);l?.(Ne?.props??null)}},V=M=>{D(M),S(M.id),Be(M.id),l?.(M.props)},ce=(M,Ne)=>{Ne.stopPropagation();let gt=P.find(qe=>qe.id===M);gt&&(k(M),_c.success("Preset deleted",{description:`Preset "${gt.name}" has been deleted.`}))},Fe=(M,Ne)=>{Ne.stopPropagation(),z(M),K(!0)},Y=()=>m.deviceType==="mobile"?F(af,{className:"size-3"}):F(sf,{className:"size-3"}),q=nf.findIndex(M=>M.value===m.deviceType);return ve("div",{className:"flex items-center gap-2",children:[!T&&!L&&ve(rf,{children:[ve(ke,{children:[F(we,{render:F(E,{"data-testid":"debugger-fullscreen-button",variant:"outline",size:"sm",className:"bg-white/90 dark:bg-zinc-900/90 backdrop-blur-sm shadow-sm hover:bg-white dark:hover:bg-zinc-900",onClick:()=>t("fullscreen"),children:F(qx,{className:"size-4"})}),nativeButton:!0}),F(Ce,{children:"Enter fullscreen mode"})]}),ve(ke,{children:[F(we,{render:F(E,{"data-testid":"debugger-pip-button",variant:"outline",size:"sm",className:"bg-white/90 dark:bg-zinc-900/90 backdrop-blur-sm shadow-sm hover:bg-white dark:hover:bg-zinc-900",onClick:()=>t("pip"),children:F(Jx,{className:"size-4"})}),nativeButton:!0}),F(Ce,{children:"Picture-in-picture"})]})]}),ve(Cr,{children:[ve(ke,{children:[F(we,{render:F(Ho,{render:F(E,{"data-testid":"debugger-device-button",variant:"outline",size:"sm",className:"h-8 w-8 p-0 bg-white/90 dark:bg-zinc-900/90 backdrop-blur-sm shadow-sm hover:bg-white dark:hover:bg-zinc-900",children:Y()}),nativeButton:!0}),nativeButton:!0}),ve(Ce,{children:["Device: ",m.deviceType]})]}),F(Nr,{"data-testid":"debugger-device-dialog",checkedIndex:q>=0?q:void 0,className:"w-56",children:nf.map((M,Ne)=>F(yr,{index:Ne,icon:M.icon,label:M.label,checked:m.deviceType===M.value,"data-testid":`debugger-device-option-${M.value}`,onSelect:()=>p({deviceType:M.value})},M.value))})]}),ve(ke,{children:[F(we,{render:F(E,{"data-testid":"debugger-theme-button",variant:"outline",size:"sm",className:"h-8 w-8 p-0 bg-white/90 dark:bg-zinc-900/90 backdrop-blur-sm shadow-sm hover:bg-white dark:hover:bg-zinc-900",onClick:()=>{c(h==="dark"?"light":"dark")},children:h==="dark"?F(Wx,{className:"size-3.5"}):F(Xx,{className:"size-3.5"})}),nativeButton:!0}),ve(Ce,{children:["Theme: ",h==="dark"?"Dark":"Light"]})]}),F(of,{options:pp,value:m.locale,onValueChange:M=>p({locale:M}),placeholder:"Search locales...",contentTestId:"debugger-locale-dialog",searchTestId:"debugger-locale-search",optionTestId:M=>`debugger-locale-option-${M}`,trigger:ve(ke,{children:[F(we,{render:F(Ho,{render:F(E,{"data-testid":"debugger-locale-button",variant:"outline",size:"sm",className:"h-8 min-w-[50px] px-2 bg-white/90 dark:bg-zinc-900/90 backdrop-blur-sm shadow-sm hover:bg-white dark:hover:bg-zinc-900",children:F("span",{className:"text-xs font-mono",children:m.locale})}),nativeButton:!0}),nativeButton:!0}),F(Ce,{children:"Locale"})]})}),F(of,{options:fp,value:m.timeZone,onValueChange:M=>p({timeZone:M}),placeholder:"Search timezones...",contentTestId:"debugger-timezone-dialog",searchTestId:"debugger-timezone-search",optionTestId:M=>`debugger-timezone-option-${M.replace(/\//g,"-")}`,trigger:ve(ke,{children:[F(we,{render:F(Ho,{render:F(E,{"data-testid":"debugger-timezone-button",variant:"outline",size:"sm",className:"h-8 w-8 p-0 bg-white/90 dark:bg-zinc-900/90 backdrop-blur-sm shadow-sm hover:bg-white dark:hover:bg-zinc-900",children:F(jx,{className:"size-3.5"})}),nativeButton:!0}),nativeButton:!0}),ve(Ce,{children:["Timezone: ",m.timeZone]})]})}),ve(fn,{open:O,onOpenChange:W,children:[ve(ke,{children:[F(we,{render:F(Yl,{render:ve(E,{"data-testid":"debugger-csp-button",variant:"outline",size:"sm",className:"relative h-8 w-8 p-0 bg-white/90 dark:bg-zinc-900/90 backdrop-blur-sm shadow-sm hover:bg-white dark:hover:bg-zinc-900",children:[m.cspMode==="permissive"?F(ef,{className:"size-3.5"}):F(Zp,{className:"size-3.5"}),g.length>0&&F("span",{className:`absolute -top-1.5 -right-1.5 flex h-4 min-w-4 items-center justify-center rounded-full px-0.5 text-[9px] font-bold text-white leading-none ${m.cspMode==="permissive"?"bg-yellow-500":"bg-red-500"}`,children:g.length>99?"99+":g.length})]}),nativeButton:!0}),nativeButton:!0}),ve(Ce,{children:["CSP:"," ",m.cspMode==="permissive"?"Permissive":"Declared",g.length>0&&` \xB7 ${g.length} ${m.cspMode==="permissive"?"would be blocked":"blocked"}`]})]}),ve(on,{scrollable:!0,className:"sm:max-w-[520px] max-h-[85vh]","data-testid":"debugger-csp-dialog",children:[F(Qt,{children:F(qt,{children:"CSP Mode"})}),ve(Un,{className:"space-y-3",children:[F("div",{role:"tablist","aria-label":"CSP diagnostics",className:"grid grid-cols-3 rounded-md border border-zinc-200 dark:border-zinc-700 p-1",children:[["mode","Mode"],["diff","Policy Diff"],["findings","Findings"]].map(([M,Ne])=>F("button",{type:"button",role:"tab","aria-selected":j===M,onClick:()=>U(M),className:`rounded px-2 py-1.5 text-xs font-medium ${j===M?"bg-zinc-100 dark:bg-zinc-800":"text-muted-foreground"}`,children:Ne},M))}),j==="mode"&&ve("div",{role:"tabpanel",className:"space-y-2",children:[ve(E,{"data-testid":"debugger-csp-option-permissive",variant:m.cspMode==="permissive"?"default":"outline",className:"w-full justify-start",onClick:()=>p({cspMode:"permissive"}),children:[F(ef,{className:"size-4 mr-2"}),"Permissive"]}),ve(E,{"data-testid":"debugger-csp-option-widget-declared",variant:m.cspMode==="widget-declared"?"default":"outline",className:"w-full justify-start",onClick:()=>p({cspMode:"widget-declared"}),children:[F(Zp,{className:"size-4 mr-2"}),"Widget-Declared"]}),F("p",{className:"text-xs text-muted-foreground",children:"Permissive records would-be blocks; Widget-Declared enforces the resource metadata policy."})]}),j==="diff"&&ve("div",{role:"tabpanel",className:"space-y-2",children:[de.length?F("div",{className:"max-h-64 overflow-y-auto rounded border border-zinc-200 dark:border-zinc-700",children:de.map(M=>ve("div",{className:"border-b border-zinc-100 dark:border-zinc-800 p-2 text-xs last:border-0",children:[ve("div",{className:"flex items-center justify-between",children:[F("code",{children:M.directive}),F("span",{className:"text-[10px] uppercase text-muted-foreground",children:M.status})]}),ve("div",{className:"mt-1 font-mono text-[10px] text-muted-foreground break-all",children:["requested: ",M.requested.join(" ")||"\u2014",F("br",{}),"effective: ",M.effective.join(" ")||"\u2014"]})]},M.directive))}):F("p",{className:"text-xs text-muted-foreground",children:"No requested or effective policy data yet."}),y&&ve(E,{variant:"outline",size:"sm",onClick:async()=>{try{await Xe(y),_c.success("Policy copied to clipboard")}catch{_c.error("Failed to copy")}},children:[F(Xp,{className:"size-3.5 mr-2"}),"Copy effective policy"]})]}),j==="findings"&&ve("div",{role:"tabpanel",className:"space-y-2",children:[F("div",{className:"space-y-1.5",children:De.map((M,Ne)=>ve("div",{className:"rounded border border-zinc-200 dark:border-zinc-700 p-2",children:[F("div",{className:"text-xs font-medium",children:M.title}),F("div",{className:"text-[11px] text-muted-foreground break-all",children:M.detail})]},`${M.title}-${Ne}`))}),g.length>0&&ve(rf,{children:[ve("div",{className:"flex items-center justify-between",children:[ve("span",{className:"text-xs font-medium",children:[g.length," observed request",g.length===1?"":"s"]}),F("button",{className:"text-xs text-muted-foreground underline",onClick:()=>f(n),children:"Clear"})]}),ve("div",{className:"border border-amber-200 dark:border-amber-800 rounded-md overflow-hidden",children:[ve("div",{className:"flex items-center justify-between bg-amber-50 dark:bg-amber-950/30 px-3 py-2",children:[ve("button",{type:"button",className:"flex items-center gap-2 text-xs font-medium text-amber-800 dark:text-amber-200",onClick:()=>Te(M=>!M),children:[H?F($x,{className:"size-3.5"}):F(Vx,{className:"size-3.5"}),"Prompt for Agents"]}),F(E,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>{Xe(N)},"aria-label":"Copy prompt for agents",children:F(Xp,{className:"size-3.5"})})]}),H&&F("pre",{className:"max-h-48 overflow-auto whitespace-pre-wrap p-2 text-[11px]","data-testid":"debugger-csp-prompt-for-agents",children:N})]})]})]})]})]})]}),ve(ke,{children:[F(we,{render:F(E,{"data-testid":"debugger-touch-button",variant:"outline",size:"sm",className:`h-8 w-8 p-0 bg-white/90 dark:bg-zinc-900/90 backdrop-blur-sm shadow-sm hover:bg-white dark:hover:bg-zinc-900 ${m.capabilities.touch?"border-blue-500 dark:border-blue-400":""}`,onClick:()=>{let M={...m.capabilities,touch:!m.capabilities.touch};p({capabilities:M})},children:F(Gx,{className:`size-3.5 ${m.capabilities.touch?"text-blue-600 dark:text-blue-400":""}`})}),nativeButton:!0}),ve(Ce,{children:["Touch: ",m.capabilities.touch?"Enabled":"Disabled"]})]}),ve(ke,{children:[F(we,{render:F(E,{"data-testid":"debugger-hover-button",variant:"outline",size:"sm",className:`h-8 w-8 p-0 bg-white/90 dark:bg-zinc-900/90 backdrop-blur-sm shadow-sm hover:bg-white dark:hover:bg-zinc-900 ${m.capabilities.hover?"border-blue-500 dark:border-blue-400":""}`,onClick:()=>{let M={...m.capabilities,hover:!m.capabilities.hover};p({capabilities:M})},children:F(Kx,{className:`size-3.5 ${m.capabilities.hover?"text-blue-600 dark:text-blue-400":""}`})}),nativeButton:!0}),ve(Ce,{children:["Hover: ",m.capabilities.hover?"Enabled":"Disabled"]})]}),ve(Jo,{children:[F(Go,{render:F(E,{"data-testid":"debugger-safe-area-button",variant:"outline",size:"sm",className:"h-8 w-8 p-0 bg-white/90 dark:bg-zinc-900/90 backdrop-blur-sm shadow-sm hover:bg-white dark:hover:bg-zinc-900",children:F(Qx,{className:"size-3.5"})}),nativeButton:!0}),F(Yo,{className:"w-64 p-3","data-testid":"debugger-safe-area-dialog",children:ve("div",{className:"space-y-2",children:[F("label",{className:"text-xs font-medium",children:"Safe Area Insets"}),F(Jp,{value:m.safeAreaInsets,onChange:M=>{p({safeAreaInsets:M})}})]})})]}),o==="tool"?ve(fn,{children:[ve(ke,{children:[F(we,{render:F(Yl,{render:F(E,{variant:"outline",size:"sm",className:"h-8 w-8 p-0 bg-white/90 dark:bg-zinc-900/90 backdrop-blur-sm shadow-sm hover:bg-white dark:hover:bg-zinc-900","data-testid":"debugger-props-button",children:F(Qp,{className:"size-3.5"})}),nativeButton:!0}),nativeButton:!0}),F(Ce,{children:"View Tool Props"})]}),ve(on,{scrollable:!0,className:"sm:max-w-[600px] max-h-[85vh]","data-testid":"debugger-props-dialog",children:[F(Qt,{children:F(qt,{children:"Tool Props"})}),F(Un,{children:F(ii,{children:F(wt,{data:s??{},filename:"tool-props.json"})})})]})]}):ve(Jo,{open:ae,onOpenChange:ie,children:[ve(ke,{children:[F(we,{render:F(Go,{render:F(E,{variant:"outline",size:"sm",className:`h-8 w-8 p-0 backdrop-blur-sm shadow-sm ${oe?"bg-amber-50 dark:bg-amber-950/40 border-amber-300 dark:border-amber-700 hover:bg-amber-100 dark:hover:bg-amber-900/50 animate-pulse":"bg-white/90 dark:bg-zinc-900/90 hover:bg-white dark:hover:bg-zinc-900"}`,"data-testid":"debugger-props-button",children:F(Qp,{className:`size-3.5 ${oe?"text-amber-500":""}`})}),nativeButton:!0}),nativeButton:!0}),ve(Ce,{children:["Props:"," ",Oe===Pr?"No Props":Oe===na?"Tool Props":P.find(M=>M.id===Oe)?.name||"Custom"]})]}),ve(Yo,{className:"w-64 p-2","data-testid":"debugger-props-popover",children:[oe&&ve("div",{className:"mb-2 rounded-md border border-amber-200 dark:border-amber-800/50 bg-amber-50 dark:bg-amber-950/30 px-3 py-2",children:[F("p",{className:"text-xs font-medium text-amber-700 dark:text-amber-300 mb-0.5",children:"Props required to render this widget:"}),F("p",{className:"text-xs font-mono text-amber-600 dark:text-amber-400",children:u.join(", ")}),F("p",{className:"text-xs text-amber-500 dark:text-amber-400 mt-1",children:"Create a preset below to set them."})]}),ve("div",{className:"space-y-1",children:[F(E,{variant:Oe===Pr?"secondary":"ghost",size:"sm",className:"w-full justify-start",onClick:()=>tt(Pr),"data-testid":"debugger-props-no-props",children:"No Props"}),P.map(M=>ve("div",{className:"relative group flex items-center",children:[F(E,{variant:Oe===M.id?"secondary":"ghost",size:"sm",className:"w-full justify-start pr-14",onClick:()=>tt(M.id),"data-testid":`debugger-props-preset-${M.id}`,children:M.name}),ve("div",{className:"absolute right-2 flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[F(E,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:Ne=>Fe(M,Ne),"data-testid":`debugger-props-edit-${M.id}`,children:F(Yx,{className:"h-3 w-3"})}),F(E,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:Ne=>ce(M.id,Ne),"data-testid":`debugger-props-delete-${M.id}`,children:F(Zx,{className:"h-3 w-3 text-destructive"})})]})]},M.id)),F(E,{variant:"ghost",size:"sm",className:"w-full justify-start text-primary",onClick:()=>tt(tf),"data-testid":"debugger-props-create-preset",children:"+ Create Preset..."})]})]})]}),F(Ap,{iframeId:n,enabled:!0}),d&&F(Hp,{open:_,onOpenChange:K,onSave:V,existingPresets:P,resource:d,resourceAnnotations:a,llmConfig:i||null,editingPreset:ne})]})}import{jsx as Ui,jsxs as lf}from"react/jsx-runtime";function ms({message:e,className:t="",vertical:n,noBorder:o}){return Ui("div",{className:C(`mt-2 rounded-md p-6 ${t}`,!o&&"border"),children:lf("p",{className:C("text-sm text-muted-foreground flex items-center gap-4",n&&"flex-col"),children:[lf("svg",{viewBox:"-6 -6 512 512",xmlns:"http://www.w3.org/2000/svg",className:"size-14 shrink-0 stroke-black dark:stroke-white",fill:"none",strokeWidth:"4.8",strokeLinecap:"round",strokeLinejoin:"round",children:[Ui("path",{d:"M105.933 0C164.437 0.000116002 211.865 47.607 211.865 106.333C211.865 131.829 210.493 158.403 221.068 181.602L228.975 198.947C243.584 230.997 269.265 256.7 301.303 271.336L316.155 278.121C340.142 289.079 367.694 287.335 394.066 287.335C452.571 287.335 499.999 334.942 499.999 393.668C499.999 452.394 452.571 500.001 394.066 500.001C335.562 500.001 288.134 452.394 288.134 393.668C288.134 368.974 289.24 343.275 278.992 320.807L270.586 302.38C255.948 270.29 230.214 244.565 198.118 229.939L180.164 221.758C157.282 211.331 131.078 212.666 105.933 212.666C47.4278 212.666 4.86252e-05 165.059 0 106.333C0 47.607 47.4278 0 105.933 0Z"}),Ui("circle",{cx:"100.426",cy:"399.575",r:"100.426"}),Ui("path",{d:"M500 100.426C500 155.889 455.037 200.851 399.574 200.851C344.11 200.851 299.148 155.889 299.148 100.426C299.148 44.962 344.11 0 399.574 0C455.037 0 500 44.962 500 100.426Z"})]}),e]})})}import{jsx as X,jsxs as Ae}from"react/jsx-runtime";function p0({timestamp:e}){let[t,n]=Rr(()=>zc(e));return ra(()=>{let o=()=>n(zc(e));o();let r=setInterval(o,1e3);return()=>clearInterval(r)},[e]),X("span",{children:t})}function zc(e){let n=Date.now()-e,o=Math.floor(n/1e3),r=Math.floor(o/60),s=Math.floor(r/60),a=Math.floor(s/24);return o<10?"now":o<60?`${o}s ago`:r<60?`${r}m ago`:s<24?`${s}h ago`:`${a}d ago`}function df(e){if(!e?.isError)return null;let t=e.content;if(Array.isArray(t)){let n=t.filter(o=>o.type==="text").map(o=>o.text).filter(Boolean);if(n.length>0)return n.join(`
|
|
97
|
-
`)}return"An error occurred"}function
|
|
98
|
-
`),W=z.filter(H=>H.type==="image").length,j=z.filter(H=>H.type==="resource").length,U=[W>0&&`${W} image${W>1?"s":""}`,j>0&&`${j} resource${j>1?"s":""}`].filter(Boolean).join(", ");d0.info("Widget follow-up",{description:[O,U].filter(Boolean).join(" \u2014 "),duration:5e3})},[]),A=so(()=>N&&m0(N.toolMeta)?"mcp-apps":null,[N]),_=so(()=>N?.toolMeta?u0(N.toolMeta):null,[N?.toolMeta]),K=so(()=>A==="mcp-apps"&&!!_,[A,_]),$=so(()=>N?.result?.content||[],[N]),oe=so(()=>_||null,[_]),ae=so(()=>!!($&&$.length>0||N?.result?.structuredContent),[$,N]),ie=so(()=>!K&&ae,[K,ae]),ne=so(()=>{let z=[];return K&&_&&z.push({mode:"mcp-apps",label:"Component (MCP Apps)"}),z.push({mode:"json",label:"Raw JSON"}),z},[K,_]);return ra(()=>{if(ne.length===0)return;let z=m&&ne.some(W=>W.mode===m),O=ne.find(W=>W.mode!=="json");if(O){let W=v.current;if(v.current=!0,!m||!z||m==="json"&&!W){p(O.mode);return}}else(!m||!z)&&p("json")},[ne,m]),ra(()=>{d&&(e.length===0||m!=="mcp-apps"||x!=="inline"||!K)&&d(null)},[d,e.length,m,x,K]),e.length===0?X("div",{className:"flex flex-col h-full bg-white dark:bg-black",children:X("div",{className:"flex-1 overflow-y-auto h-full",children:X("div",{className:"flex items-center justify-center h-full",children:X("div",{className:"text-center",children:X(ms,{vertical:!0,noBorder:!0,message:"No Results yet"})})})})}):Ae("div",{className:"relative flex flex-col h-full bg-white dark:bg-black",children:[X("div",{className:"flex-1 overflow-y-auto h-full",children:Ae("div",{className:"space-y-0 flex flex-col flex-1 h-full",children:[Ae("div",{className:`sticky top-0 z-40 flex items-center gap-2 px-4 pt-2 backdrop-blur-xs bg-white/50 dark:bg-black/50 ${K||ie?"border-b border-gray-200 dark:border-zinc-600 pb-2":""}`,children:[X("h3",{className:"text-sm font-medium hidden sm:block",children:"Response"}),N.duration!==void 0&&Ae("div",{className:"hidden sm:flex items-center gap-1",children:[X(i0,{className:"h-3 w-3 text-gray-400"}),Ae("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:[N.duration,"ms"]})]}),K&&X("div",{className:"flex items-center gap-4 sm:ml-4",children:X("div",{className:"flex items-center gap-2",children:ne.map((z,O)=>Ae(l0.Fragment,{children:[O>0&&X("span",{className:"text-xs text-zinc-400",children:"|"}),X("button",{"data-testid":`tool-result-view-${z.mode}`,onClick:()=>p(z.mode),className:`text-xs font-medium ${m===z.mode?"text-black dark:text-white":"text-zinc-500 dark:text-zinc-400"}`,children:z.label})]},z.mode))})}),ie&&Ae("div",{className:"flex items-center gap-2 sm:ml-4",children:[X("button",{onClick:()=>c(!0),className:`text-xs font-medium ${h?"text-black dark:text-white":"text-zinc-500 dark:text-zinc-400"}`,children:"Formatted"}),X("span",{className:"text-xs text-zinc-400",children:"|"}),X("button",{onClick:()=>c(!1),className:`text-xs font-medium ${h?"text-zinc-500 dark:text-zinc-400":"text-black dark:text-white"}`,children:"Raw"})]}),Ae("div",{className:"ml-auto flex items-center gap-1",children:[a&&i&&Ae(E,{"data-testid":"tool-result-rerun",variant:"ghost",size:"sm",onClick:i,title:"Re-run with same arguments",children:[X(a0,{className:"h-4 w-4"}),X("span",{className:"hidden sm:inline ml-1",children:"Re-run"})]}),K&&s&&X(E,{"data-testid":"tool-result-maximize",variant:"ghost",size:"sm",onClick:s,title:a?"Restore":"Maximize",children:a?X(s0,{className:"h-4 w-4"}):X(r0,{className:"h-4 w-4"})}),w.length>1&&Ae(kn,{value:l.toString(),onValueChange:z=>u(parseInt(z)),children:[X(Vn,{className:"w-[140px] h-8 text-xs",leading:Ae("div",{className:"flex items-center gap-1",children:[X(cf,{className:"h-3 w-3"}),X(p0,{timestamp:N.timestamp})]})}),X($n,{children:w.map((z,O)=>X(Wt,{value:O.toString(),children:Ae("div",{className:"flex items-center gap-2",children:[X(cf,{className:"h-3 w-3"}),X("span",{children:zc(z.timestamp)}),Ae("span",{className:"text-xs text-muted-foreground",children:["(",new Date(z.timestamp).toLocaleTimeString(),")"]})]})},O))})]}),X(E,{"data-testid":`tool-result-copy-${T}`,variant:"ghost",size:"sm",onClick:()=>r(T,P),children:t===T?X(n0,{className:"h-4 w-4"}):X(o0,{className:"h-4 w-4"})})]})]}),(()=>{let z=N.error||df(N.result);return z?Ae("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded p-3 mx-4 mt-4",children:[X("p",{className:"text-red-800 dark:text-red-300 font-medium",children:"Error:"}),X("p",{className:"text-red-700 dark:text-red-400 text-sm",children:z})]}):(()=>{if(!m)return X("div",{className:"flex items-center justify-center w-full h-[200px]",children:X(Kt,{className:"size-5"})});switch(m){case"mcp-apps":return!K||!_?X("div",{className:"px-4 pt-4",children:X("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded p-3",children:X("p",{className:"text-sm text-red-600 dark:text-red-400",children:"MCP Apps resource not available"})})}):Ae(jo,{className:"relative flex flex-1 w-full min-h-[240px] items-stretch",children:[X("div",{className:"absolute top-2 right-2 z-30 flex items-center gap-2",children:X(Hi,{toolCallId:`tool-${N.timestamp}`,displayMode:x,onDisplayModeChange:f,propsContext:"tool",resourceUri:_,toolInput:N.args,resourceAnnotations:N.toolMeta,llmConfig:null,resource:null,onPropsChange:g})}),X("div",{className:"flex min-h-0 flex-1 flex-col pt-11",children:X(Pi,{serverId:n,viewId:`tool-${N.timestamp}`,toolName:N.toolName,toolInput:R,toolOutput:D,toolMetadata:N.toolMeta,resourceUri:_,readResource:k,customProps:b||void 0,displayMode:x,onDisplayModeChange:f,onSendFollowUp:S,onWidgetHeightChange:d?W=>d(W):void 0,noWrapper:!0},`mcp-apps-${N.timestamp}`)})]});case"json":{if(ie&&h){let W=N.result?.structuredContent;return Ae("div",{className:"px-4 pt-4 space-y-4","data-testid":"tool-execution-results-content",children:[W&&Ae("div",{className:"space-y-2","data-testid":"tool-execution-results-structured-content",children:[X("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"Structured Content"}),X(wt,{data:W,filename:`structured-content-${N.toolName}-${Date.now()}.json`})]}),$&&$.length>0&&X(g0,{content:$}),!W&&(!$||$.length===0)&&X("div",{className:"text-sm text-gray-500 dark:text-gray-400","data-testid":"tool-execution-results-no-content",children:"No content to display"})]})}return X("div",{className:"px-4 pt-4",children:X(wt,{data:N.result,filename:`tool-result-${N.toolName}-${Date.now()}.json`})})}default:return null}})()})()]})}),oe&&m==="mcp-apps"&&X("div",{className:"absolute bottom-0 left-1/2 -translate-x-1/2 z-40 pointer-events-none",children:X("span",{className:"text-[11px] bg-gray-200 dark:bg-zinc-800 text-gray-500 dark:text-gray-400 px-3 py-0.5 rounded-t-xl font-mono max-w-[320px] truncate block",children:oe})})]})}import{isViewTool as h0}from"@mcp-use/client/react";import{useMemo as $i,useState as v0}from"react";import{Fragment as y0,jsx as xo,jsxs as uf}from"react/jsx-runtime";function b0({widgetId:e}){let{getWidget:t}=Vo(),o=t(e)?.modelContext;if(!o?.content?.length&&!o?.structuredContent)return null;let r=o.content?.map(s=>s.text).join(" ")??JSON.stringify(o.structuredContent).slice(0,80);return uf("div",{className:"flex items-center gap-1.5 px-3 py-1.5 text-[11px] text-muted-foreground bg-muted/30 border border-border/40 rounded-md mt-1",children:[xo("span",{className:"inline-block w-1.5 h-1.5 rounded-full bg-blue-400 shrink-0"}),xo("span",{className:"font-medium",children:"State synced to model"}),xo("span",{className:"truncate opacity-60 max-w-[300px]",children:r})]})}function Vi({toolName:e,toolArgs:t,result:n,serverId:o,readResource:r,toolMeta:s,onSendFollowUp:a,partialToolArgs:i,cancelled:d}){let l=$i(()=>`chat-tool-${e}-${Date.now()}-${Math.random().toString(36).substring(2,11)}`,[e]),[u,h]=v0("inline"),c=$i(()=>{if(!n)return null;if(typeof n=="string")try{return JSON.parse(n)}catch{return n}return n},[n]),m=h0(s),p=m?s?.ui?.resourceUri??null:null,x=$i(()=>t,[e,c]),f=$i(()=>c,[e,c]);return m&&p&&o&&r?uf(y0,{children:[xo(Pi,{serverId:o,viewId:l,toolName:e,resourceUri:p,toolInput:x,toolOutput:f,toolMetadata:s,readResource:r,displayMode:u,onDisplayModeChange:h,onSendFollowUp:a,partialToolInput:i,cancelled:d,noWrapper:!0,className:"my-4"}),xo(b0,{widgetId:l})]}):m&&!p?xo("div",{className:"flex items-center justify-center w-full h-[200px] rounded border",children:xo(Kt,{className:"size-5"})}):m&&(!o||!r)?xo("div",{className:"my-4 p-4 bg-red-50/30 dark:bg-red-950/20 border border-red-200/50 dark:border-red-800/50 rounded-lg",children:xo("p",{className:"text-sm text-red-600 dark:text-red-400",children:"Cannot render widget: Missing required props (serverId or readResource)"})}):null}import{ViewRenderer as G3,isViewTool as Y3,getViewResourceUri as Q3}from"@mcp-use/client/react";import{createContext as x0,use as w0,useCallback as Pn,useState as C0}from"react";import{jsx as k0}from"react/jsx-runtime";var mf=x0(void 0);function N0({children:e}){let t=typeof window<"u"?window.__MANUFACT_CHAT_URL__:void 0,n=typeof import.meta<"u"?import.meta.env?.VITE_MANUFACT_CHAT_URL:void 0,o=t?.trim()||n?.trim()||"https://cloud.manufact.com/api/v1/inspector/chat/stream",[r,s]=C0({selectedServerId:null,activeTab:"tools",selectedToolName:null,selectedPromptName:null,selectedResourceUri:null,selectedSamplingRequestId:null,selectedElicitationRequestId:null,tunnelUrl:null,isTunnelStarting:!1,isEmbedded:!1,embeddedConfig:{chatApiUrl:o,chatStreamProtocol:"data-stream",chatEnableFreeTierUpgrade:!0}}),a=Pn(v=>{s(y=>({...y,selectedServerId:v}))},[]),i=Pn(v=>{s(y=>({...y,activeTab:v}))},[]),d=Pn(v=>{s(y=>({...y,selectedToolName:v}))},[]),l=Pn(v=>{s(y=>({...y,selectedPromptName:v}))},[]),u=Pn(v=>{s(y=>({...y,selectedResourceUri:v}))},[]),h=Pn(v=>{s(y=>({...y,selectedSamplingRequestId:v}))},[]),c=Pn(v=>{s(y=>({...y,selectedElicitationRequestId:v}))},[]),m=Pn(v=>{s(y=>({...y,tunnelUrl:v}))},[]),p=Pn(v=>{s(y=>({...y,isTunnelStarting:v}))},[]),x=Pn((v,y={})=>{s(w=>({...w,isEmbedded:v,embeddedConfig:{...y,chatApiUrl:y.chatApiUrl?.trim()||o,chatStreamProtocol:y.chatStreamProtocol??"data-stream",chatEnableFreeTierUpgrade:y.chatEnableFreeTierUpgrade??!0}}))},[o]),f=Pn((v,y,w)=>{console.warn("[InspectorContext] navigateToItem called:",{serverId:v,tab:y,itemIdentifier:w}),s(N=>({...N,selectedServerId:v,activeTab:y,selectedToolName:y==="tools"&&w||null,selectedPromptName:y==="prompts"&&w||null,selectedResourceUri:y==="resources"&&w||null,selectedSamplingRequestId:y==="sampling"&&w||null,selectedElicitationRequestId:y==="elicitation"&&w||null}))},[]),b=Pn(()=>{s(v=>({...v,selectedToolName:null,selectedPromptName:null,selectedResourceUri:null,selectedSamplingRequestId:null,selectedElicitationRequestId:null}))},[]),g={...r,setSelectedServerId:a,setActiveTab:i,setSelectedToolName:d,setSelectedPromptName:l,setSelectedResourceUri:u,setSelectedSamplingRequestId:h,setSelectedElicitationRequestId:c,setTunnelUrl:m,setIsTunnelStarting:p,setEmbeddedMode:x,navigateToItem:f,clearSelection:b};return k0(mf,{value:g,children:e})}function wo(){let e=w0(mf);if(!e)throw new Error("useInspector must be used within InspectorProvider");return e}import{GripVerticalIcon as S0}from"lucide-react";import*as Mr from"react-resizable-panels";import{jsx as sa}from"react/jsx-runtime";var{usePanelRef:Ir}=Mr;function Qo({className:e,...t}){return sa(Mr.Group,{"data-slot":"resizable-panel-group",className:C("flex h-full w-full aria-[orientation=vertical]:flex-col",e),...t})}function hn({...e}){return sa(Mr.Panel,{"data-slot":"resizable-panel",...e})}function Xo({withHandle:e,className:t,...n}){return sa(Mr.Separator,{"data-slot":"resizable-handle",className:C("relative z-50 box-content shrink-0","focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1","before:pointer-events-none before:absolute before:bg-zinc-200 before:transition-[height,width,background-color] before:duration-200 before:ease-out dark:before:bg-zinc-700","hover:before:bg-foreground/35 dark:hover:before:bg-foreground/45","aria-[orientation=horizontal]:h-px aria-[orientation=horizontal]:w-full aria-[orientation=horizontal]:py-1.5 aria-[orientation=horizontal]:-my-1.5","aria-[orientation=horizontal]:before:inset-x-0 aria-[orientation=horizontal]:before:top-1.5 aria-[orientation=horizontal]:before:h-px","hover:aria-[orientation=horizontal]:before:h-0.5","aria-[orientation=vertical]:h-full aria-[orientation=vertical]:w-px aria-[orientation=vertical]:px-1.5 aria-[orientation=vertical]:-mx-1.5","aria-[orientation=vertical]:before:inset-y-0 aria-[orientation=vertical]:before:left-1.5 aria-[orientation=vertical]:before:w-px","hover:aria-[orientation=vertical]:before:w-0.5","[&[aria-orientation=horizontal]>div]:rotate-90",t),...n,children:e&&sa("div",{className:"pointer-events-none absolute top-1/2 left-1/2 z-10 flex h-4 w-3 -translate-x-1/2 -translate-y-1/2 items-center justify-center rounded-xs border border-zinc-200 bg-background shadow-sm dark:border-zinc-700",children:sa(S0,{className:"size-2.5 text-muted-foreground"})})})}import{AnimatePresence as cw,motion as Xc}from"motion/react";import{ChevronLeft as dw,Database as Nf,Wrench as kf}from"lucide-react";import{useCallback as bn,useEffect as Sf,useMemo as Tf,useRef as Ji,useState as Mn}from"react";import{useState as T0}from"react";import{jsx as pf}from"react/jsx-runtime";function ao({className:e,scrollRef:t,children:n}){let[o,r]=T0(!1);return pf("div",{ref:t,className:C("h-full overflow-y-auto overscroll-none",e),onScroll:s=>r(s.currentTarget.scrollTop>0),children:pf("div",{className:"flex min-h-full flex-col",children:n(o)})})}import{jsx as aa,jsxs as ff}from"react/jsx-runtime";function qn({id:e,isSelected:t,isFocused:n,title:o,description:r,metadata:s,onClick:a,className:i,"data-testid":d}){return aa("button",{id:e,"data-testid":d,type:"button",onClick:a,className:C("w-full text-left cursor-pointer p-2 sm:p-4 border-b dark:border-zinc-700 hover:bg-gray-50 dark:hover:bg-zinc-800/50 transition-colors group",t&&"bg-zinc-50 dark:bg-zinc-800 border-l-4 border-l-zinc-500",n&&"ring-2 ring-zinc-500 dark:ring-zinc-400 ring-inset",i),children:ff("div",{className:"flex items-start gap-2 sm:gap-3",children:[ff("div",{className:"flex-1 min-w-0",children:[aa("div",{className:"flex items-center gap-2 mb-1",children:aa("h3",{className:C("font-medium truncate font-mono text-sm"),children:o})}),r&&aa("p",{className:"text-sm text-gray-600 dark:text-gray-400 line-clamp-2",children:r})]}),s&&aa("div",{className:"flex-shrink-0 flex items-center self-center",children:s})]})})}import{forwardRef as P0}from"react";import{cva as R0}from"class-variance-authority";import{jsx as ji}from"react/jsx-runtime";var M0={gray:"#a3a3a3",red:"#ef4444",orange:"#f97316",amber:"#f59e0b",yellow:"#eab308",lime:"#84cc16",green:"#22c55e",emerald:"#10b981",teal:"#14b8a6",cyan:"#06b6d4",blue:"#3b82f6",indigo:"#6366f1",violet:"#8b5cf6",purple:"#a855f7",fuchsia:"#d946ef",pink:"#ec4899",rose:"#f43f5e"},I0=R0("inline-flex items-center font-medium whitespace-nowrap",{variants:{variant:{solid:"",outline:"border border-border text-foreground"},size:{sm:"h-5 px-2 text-[11px] gap-1",md:"h-6 px-2.5 text-[12px] gap-1.5",lg:"h-7 px-3 text-[13px] gap-1.5"}},defaultVariants:{variant:"solid",size:"md"}}),gf={default:{variant:"solid",color:"blue"},secondary:{variant:"solid",color:"green"},destructive:{variant:"solid",color:"red"},outline:{variant:"outline",color:"gray"}};function E0(e){return typeof e=="string"||typeof e=="number"}function A0({children:e}){return E0(e)?ji("span",{className:"[text-box:trim-both_cap_alphabetic]",children:e}):ji("span",{className:"inline-flex items-center gap-1",children:e})}var Jt=P0(({className:e,variant:t="solid",size:n="md",color:o,children:r,style:s,...a},i)=>{let d=t&&t in gf?gf[t]:null,l=d?.variant??t,u=o??d?.color??"gray",h=pt(),c=M0[u],p=l==="solid"?u==="gray"?{backgroundColor:"var(--accent)",color:"var(--foreground)"}:{color:"var(--foreground)",backgroundColor:`color-mix(in srgb, ${c} 15%, var(--background))`}:{};return ji("span",{ref:i,className:C(I0({variant:l,size:n}),h.item,e),style:{...p,...s},...a,children:ji(A0,{children:r})})});Jt.displayName="Badge";import{RefreshCw as L0,Search as _0}from"lucide-react";import{jsx as D0}from"react/jsx-runtime";function ps({className:e,...t}){return D0("kbd",{"data-slot":"kbd",className:C("bg-muted text-muted-foreground pointer-events-none inline-flex h-5 w-fit min-w-5 items-center justify-center gap-1 rounded-sm px-1 font-sans text-xs font-medium select-none","[&_svg:not([class*='size-'])]:size-3","[[data-slot=tooltip-content]_&]:bg-background/20 [[data-slot=tooltip-content]_&]:text-background dark:[[data-slot=tooltip-content]_&]:bg-background/10",e),...t})}import{Fragment as hf,jsx as an,jsxs as Co}from"react/jsx-runtime";var O0="h-3.5 w-3.5 shrink-0 text-muted-foreground";function Er({activeTab:e,isSearchExpanded:t,searchQuery:n,primaryTabTitle:o,secondaryTabTitle:r,primaryCount:s,secondaryCount:a,secondaryIcon:i,primaryIcon:d,searchPlaceholder:l="Search...",onSearchExpand:u,onSearchChange:h,onSearchBlur:c,onTabSwitch:m,searchInputRef:p,primaryTabName:x,onRefresh:f,isRefreshing:b=!1,isScrolled:g=!1}){let v=e===x,y=v?d:i,w=v?o:r;return Co("div",{className:`flex flex-row items-center justify-between gap-2 ${ci(g)} ${Lo}`,children:[an("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:t?an(Ge,{ref:p,placeholder:l,value:n,onChange:N=>h(N.target.value),onBlur:c,className:"h-8 border-gray-300 dark:border-zinc-600"}):Co(hf,{children:[Co("h2",{className:`${_o} flex items-center gap-1.5`,children:[an(y,{className:O0,"aria-hidden":!0}),w]}),v&&Co(hf,{children:[an(Jt,{className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",variant:"outline",children:s}),Co(ke,{children:[an(we,{render:an(E,{variant:"ghost",size:"sm",onClick:u,className:"h-8 w-8 p-0",children:an(_0,{className:"h-4 w-4"})}),nativeButton:!0}),Co(Ce,{side:"bottom",className:"flex gap-2",children:["Search",an(ps,{children:"F"})]})]}),f&&Co(ke,{children:[an(we,{render:an(E,{variant:"ghost",size:"sm",onClick:f,disabled:b,className:"h-8 w-8 p-0",children:an(L0,{className:`h-4 w-4 ${b?"animate-spin":""}`})}),nativeButton:!0}),Co(Ce,{side:"bottom",className:"flex gap-2",children:["Refresh list",an(ps,{children:"R"})]})]})]})]})}),Co(E,{variant:"ghost",size:"sm",onClick:m,className:"gap-2 flex-shrink-0",children:[an("span",{className:"hidden sm:inline",children:v?r:o}),v&&a>0&&an(Jt,{className:"bg-purple-500/20 text-purple-600 dark:text-purple-400 border-transparent",variant:"outline",children:a})]})]})}import{RefreshCw as z0,Search as B0}from"lucide-react";import{Fragment as H0,jsx as $t,jsxs as Zo}from"react/jsx-runtime";function qi({title:e,count:t,icon:n,isSearchExpanded:o,searchQuery:r,searchPlaceholder:s,onSearchExpand:a,onSearchChange:i,onSearchBlur:d,searchInputRef:l,titleTestId:u,bulkAction:h,onRefresh:c,isRefreshing:m=!1,isScrolled:p=!1}){let x=h?.icon;return Zo("div",{className:`flex flex-row items-center justify-between gap-2 ${ci(p)} ${Lo}`,children:[$t("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:o?$t(Ge,{ref:l,placeholder:s,value:r,onChange:b=>i(b.target.value),onBlur:d,className:"h-8 border-gray-300 dark:border-zinc-600"}):Zo(H0,{children:[Zo("h2",{className:`${_o} flex items-center gap-1.5`,"data-testid":u,children:[n?$t(n,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground","aria-hidden":!0}):null,e]}),$t(Jt,{className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",variant:"outline",children:t}),Zo(ke,{children:[$t(we,{render:$t(E,{variant:"ghost",size:"sm",onClick:a,className:"h-8 w-8 p-0",children:$t(B0,{className:"h-4 w-4"})}),nativeButton:!0}),Zo(Ce,{side:"bottom",className:"flex gap-2",children:["Search",$t(ps,{children:"F"})]})]}),c&&Zo(ke,{children:[$t(we,{render:$t(E,{variant:"ghost",size:"sm",onClick:c,disabled:m,className:"h-8 w-8 p-0",children:$t(z0,{className:`h-4 w-4 ${m?"animate-spin":""}`})}),nativeButton:!0}),Zo(Ce,{side:"bottom",className:"flex gap-2",children:["Refresh list",$t(ps,{children:"R"})]})]})]})}),h&&x&&$t("div",{className:"flex items-center gap-2",children:Zo(ke,{children:[$t(we,{render:$t(E,{variant:"ghost",size:"sm",onClick:h.onClick,disabled:h.disabled,className:"h-8 w-8 p-0",children:$t(x,{className:"h-4 w-4"})}),nativeButton:!0}),$t(Ce,{side:"bottom",children:h.label})]})})]})}import{AlertTriangle as Q1,Check as X1,Loader2 as Z1,XCircle as eA}from"lucide-react";import{jsx as nA}from"react/jsx-runtime";import{Database as U0,Trash2 as F0}from"lucide-react";import{jsx as vn,jsxs as Bc}from"react/jsx-runtime";function Hc({savedRequests:e,selectedRequest:t,onLoadRequest:n,onDeleteRequest:o,focusedIndex:r}){if(e.length===0)return Bc("div",{className:"flex flex-1 flex-col items-center justify-center p-4 text-center",children:[vn(U0,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),vn("p",{className:"text-gray-500 dark:text-gray-400 mb-2",children:"No saved requests yet"}),vn("p",{className:"text-xs text-gray-400 dark:text-gray-500",children:"Execute a tool and click Save to store requests"})]});let s=(a,i)=>{a.stopPropagation(),i()};return vn("div",{children:e.map((a,i)=>Bc("div",{className:"relative group",children:[vn(qn,{id:`saved-${a.id}`,isSelected:t?.id===a.id,isFocused:r===i,title:a.name,description:a.toolName,metadata:vn("div",{className:"flex flex-col gap-1",children:vn("span",{className:"text-xs text-gray-400 dark:text-gray-500",children:new Date(a.savedAt).toLocaleString()})}),onClick:()=>n(a)}),vn("div",{className:"absolute top-1/2 right-2 -translate-y-1/2 opacity-0 group-hover:opacity-100 transition-opacity z-10",children:Bc(ke,{children:[vn(we,{render:vn(E,{variant:"secondary",size:"sm",onClick:d=>s(d,()=>o(a.id)),className:"h-8 w-8 p-0",children:vn(F0,{className:"h-4 w-4"})}),nativeButton:!0}),vn(Ce,{children:vn("p",{children:"Delete saved request"})})]})})]},a.id))})}import{Save as $0}from"lucide-react";import{jsx as fs,jsxs as ia}from"react/jsx-runtime";function Uc({isOpen:e,requestName:t,defaultPlaceholder:n,onRequestNameChange:o,onSave:r,onCancel:s}){return e?fs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:s,children:ia("div",{className:"bg-white dark:bg-zinc-800 rounded-lg p-6 w-[400px] shadow-xl border border-gray-200 dark:border-zinc-700",onClick:a=>a.stopPropagation(),children:[fs("h3",{className:"text-lg font-semibold mb-4 text-gray-900 dark:text-gray-100",children:"Save Request"}),ia("div",{className:"space-y-4",children:[ia("div",{children:[fs(nt,{htmlFor:"request-name",children:"Request Name (optional)"}),fs(Ge,{id:"request-name",value:t,onChange:a=>o(a.target.value),placeholder:n,className:"mt-2",onKeyDown:a=>{a.key==="Enter"&&r()},autoFocus:!0})]}),ia("div",{className:"flex justify-end gap-2",children:[fs(E,{variant:"outline",onClick:s,children:"Cancel"}),ia(E,{onClick:r,children:[fs($0,{className:"h-4 w-4 mr-2"}),"Save"]})]})]})]})}):null}import{Check as V0,ChevronDown as j0,ChevronUp as q0,Code as W0,Copy as K0,Play as J0,Save as G0,X as Y0}from"lucide-react";import{useEffect as vf,useRef as Q0,useState as la}from"react";import{Fragment as gs,jsx as ye,jsxs as Pt}from"react/jsx-runtime";function Fc({selectedTool:e,toolArgs:t,payloadToSend:n,isExecuting:o,isConnected:r,onArgChange:s,onExecute:a,onSave:i,onCancel:d,onBulkPaste:l,autoFilledFields:u,setFields:h,sendEmptyFields:c,onToggleEmpty:m}){let p="hidden @[700px]/tool-exec:inline",x="hidden @[700px]/tool-exec:inline shrink-0 text-[10px] leading-none border border-current/30 p-1 rounded-full",f="@max-[699px]/tool-exec:size-8 @max-[699px]/tool-exec:min-w-8 @max-[699px]/tool-exec:shrink-0 @max-[699px]/tool-exec:gap-0 @max-[699px]/tool-exec:rounded-full @max-[699px]/tool-exec:!px-0 @max-[699px]/tool-exec:!py-0",b="@max-[699px]/tool-exec:!pr-0",[g,v]=la(!1),[y,w]=la(!1),[N,T]=la(!1),[L,P]=la(!1),[R,D]=la(!1),k=Q0(null);vf(()=>{if(k.current&&e?.description){let _=k.current,K=parseFloat(getComputedStyle(_).lineHeight),$=_.scrollHeight,oe=Math.round($/K);D(oe>3),P(!1)}},[e?.description]);let S=async()=>{e&&await Xe(JSON.stringify(e,null,2))},A=async()=>{if(e)try{await Xe(JSON.stringify(n??t,null,2)),T(!0),setTimeout(()=>T(!1),2e3)}catch{}};return vf(()=>{let _=K=>{(K.metaKey||K.ctrlKey)&&K.key==="Enter"&&e&&!o&&r&&(K.preventDefault(),a()),K.key==="Escape"&&o&&d&&(K.preventDefault(),d())};return document.addEventListener("keydown",_),()=>document.removeEventListener("keydown",_)},[e,o,r,a,d]),e?Pt("div",{className:"flex flex-col h-full @container/tool-exec",children:[ye("div",{className:"shrink-0 p-3 sm:p-5 pt-3 sm:pt-4 pb-2 sm:pb-2 sm:pr-4",children:ye("div",{children:Pt("div",{className:"flex flex-row items-center justify-between mb-0 gap-2",children:[ye("h3",{className:"text-base sm:text-lg font-semibold","data-testid":"tool-execution-title",children:e.name}),Pt("div",{className:"flex gap-2 shrink-0",children:[Pt(ke,{children:[ye(we,{render:Pt(E,{"data-testid":"tool-execution-metadata-button",variant:y?"default":"outline",onClick:()=>w(!y),disabled:o,size:"sm",className:C(vr,f),title:"View tool metadata",children:[ye(W0,{}),ye("span",{className:p,children:"Metadata"})]}),nativeButton:!0}),ye(Ce,{children:ye("p",{children:"View tool definition metadata"})})]}),Pt(ke,{children:[ye(we,{render:Pt(E,{"data-testid":"tool-execution-copy-payload-button",variant:"outline",onClick:A,disabled:o,size:"sm",className:C(vr,f),title:"Copy payload as JSON",children:[N?ye(V0,{className:"text-green-600"}):ye(K0,{}),ye("span",{className:p,children:N?"Copied!":"Payload"})]}),nativeButton:!0}),ye(Ce,{children:ye("p",{children:"Copy payload as JSON"})})]}),Pt(ke,{children:[ye(we,{render:Pt(E,{"data-testid":"tool-execution-save-button",variant:"outline",onClick:i,disabled:o,size:"sm",className:C(vr,f),title:"Save request",children:[ye(G0,{}),ye("span",{className:p,children:"Save"})]}),nativeButton:!0}),ye(Ce,{children:ye("p",{children:"Save request"})})]}),o&&d?Pt(ke,{open:g?void 0:!1,children:[ye(we,{render:ye("div",{onMouseEnter:()=>v(!0),onMouseLeave:()=>v(!1),className:"relative",children:ye(E,{"data-testid":"tool-execution-cancel-button",onClick:d,variant:g?"destructive":"default",size:"sm",className:C(js,f,b,"transition-all"),children:g?Pt(gs,{children:[ye(Y0,{}),ye("span",{className:p,children:"Cancel"}),ye("span",{className:x,children:"Esc"})]}):Pt(gs,{children:[ye(Kt,{}),ye("span",{className:p,children:"Executing..."})]})})}),nativeButton:!1}),ye(Ce,{children:ye("p",{children:"Hover to cancel (or press Esc)"})})]}):ye(E,{"data-testid":"tool-execution-execute-button",onClick:a,disabled:o||!r,size:"sm",className:C(js,f,b),children:o?Pt(gs,{children:[ye(Kt,{}),ye("span",{className:p,children:"Executing..."})]}):Pt(gs,{children:[ye(J0,{}),ye("span",{className:p,children:"Execute"}),ye("span",{className:x,children:"\u2318\u21B5"})]})})]})]})})}),Pt("div",{className:"flex-1 overflow-y-auto px-3 sm:px-5 pb-4 pr-3",children:[e.description&&Pt("div",{className:"relative mb-6",children:[Pt("div",{className:"relative",children:[ye("p",{ref:k,"data-testid":"tool-execution-description",className:`text-sm text-gray-600 dark:text-gray-400 leading-relaxed transition-all duration-300 ${!L&&R?"line-clamp-3":""}`,children:e.description}),R&&!L&&ye("div",{className:"absolute bottom-0 left-0 right-0 h-[1.4em] bg-linear-to-t from-white/95 dark:from-black/95 via-white/55 dark:via-black/55 to-transparent pointer-events-none"})]}),R&&ye("div",{className:"flex justify-end",children:ye("button",{onClick:()=>P(!L),className:"relative z-10 inline-flex items-center gap-1 text-xs text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 mt-1 transition-colors",children:L?Pt(gs,{children:["Show less",ye(q0,{className:"h-3 w-3"})]}):Pt(gs,{children:["Show more",ye(j0,{className:"h-3 w-3"})]})})})]}),ye(xc,{selectedTool:e,toolArgs:t,onArgChange:s,onBulkPaste:l,autoFilledFields:u,setFields:h,sendEmptyFields:c,onToggleEmpty:m})]}),ye(fn,{open:y,onOpenChange:w,children:Pt(on,{scrollable:!0,className:"max-w-3xl max-h-[80vh]",children:[ye(Qt,{sticky:!0,children:ye(qt,{children:"Tool Definition"})}),ye(Un,{children:ye(ii,{onCopy:S,children:ye(wt,{data:e,filename:`tool-definition-${e.name}-${Date.now()}.json`})})})]})})]}):Pt("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[ye("p",{className:"text-gray-500 dark:text-gray-400 mb-2",children:"Select a tool to get started"}),ye("p",{className:"text-xs text-gray-400 dark:text-gray-500",children:"Choose a tool from the list to view its details and execute it"})]})}import{PanelsTopLeft as X0,Wrench as Z0}from"lucide-react";import{isViewTool as ew}from"@mcp-use/client/react";import{jsx as No,jsxs as Wi}from"react/jsx-runtime";function $c({tools:e,selectedTool:t,onToolSelect:n,focusedIndex:o}){if(e.length===0)return Wi("div",{className:"flex flex-1 flex-col items-center justify-center p-4 text-center",children:[No(Z0,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),No("p",{className:"text-gray-500 dark:text-gray-400",children:"No tools available"})]});let r=e.some(s=>s.inputSchema?.properties&&Object.keys(s.inputSchema.properties).length>0);return No("div",{children:e.map((s,a)=>{let i=s._meta,d=ew(i)?"mcp-apps":null,l=s.inputSchema?.properties,u=l?Object.keys(l).length:0,h=r&&u>0&&Wi(Jt,{variant:"outline",className:"text-xs border-gray-300 dark:border-zinc-600 text-gray-600 dark:text-gray-400",children:[u," params"]}),m=d==="mcp-apps"||h?Wi("div",{className:"flex items-center gap-1.5",children:[d==="mcp-apps"&&Wi(ke,{children:[No(we,{render:No("span",{className:"inline-flex",children:No(X0,{className:"h-3.5 w-3.5"})}),nativeButton:!1}),No(Ce,{children:No("p",{children:"UI widget"})})]}),h]}):void 0;return No(qn,{id:`tool-${s.name}`,"data-testid":`tool-item-${s.name}`,isSelected:t?.name===s.name,isFocused:o===a,title:s.name,description:s.description,metadata:m,onClick:()=>n(s)},s.name)})})}import{AlertDialog as Ar}from"@base-ui/react/alert-dialog";import{jsx as Rn,jsxs as ow}from"react/jsx-runtime";function Vc({...e}){return Rn(Ar.Root,{"data-slot":"alert-dialog",...e})}function tw({...e}){return Rn(Ar.Portal,{"data-slot":"alert-dialog-portal",...e})}function nw({className:e,...t}){return Rn(Ar.Backdrop,{"data-slot":"alert-dialog-overlay",className:C("fixed inset-0 isolate z-50 bg-black/50 duration-100 data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0",e),...t})}function jc({className:e,size:t="default",...n}){return ow(tw,{children:[Rn(nw,{}),Rn(Ar.Popup,{"data-slot":"alert-dialog-content","data-size":t,className:C("group/alert-dialog-content fixed top-1/2 left-1/2 z-50 grid w-full -translate-x-1/2 -translate-y-1/2 gap-6 rounded-xl bg-popover p-6 text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none data-[size=default]:max-w-xs data-[size=sm]:max-w-xs data-[size=default]:sm:max-w-lg data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",e),...n})]})}function qc({className:e,...t}){return Rn("div",{"data-slot":"alert-dialog-header",className:C("grid grid-rows-[auto_1fr] place-items-center gap-1.5 text-center has-data-[slot=alert-dialog-media]:grid-rows-[auto_auto_1fr] has-data-[slot=alert-dialog-media]:gap-x-6 sm:group-data-[size=default]/alert-dialog-content:place-items-start sm:group-data-[size=default]/alert-dialog-content:text-left sm:group-data-[size=default]/alert-dialog-content:has-data-[slot=alert-dialog-media]:grid-rows-[auto_1fr]",e),...t})}function Wc({className:e,...t}){return Rn("div",{"data-slot":"alert-dialog-footer",className:C("flex flex-col-reverse gap-2 group-data-[size=sm]/alert-dialog-content:grid group-data-[size=sm]/alert-dialog-content:grid-cols-2 sm:flex-row sm:justify-end",e),...t})}function Kc({className:e,...t}){return Rn(Ar.Title,{"data-slot":"alert-dialog-title",className:C("text-lg font-medium sm:group-data-[size=default]/alert-dialog-content:group-has-data-[slot=alert-dialog-media]/alert-dialog-content:col-start-2",e),...t})}function Jc({className:e,...t}){return Rn(Ar.Description,{"data-slot":"alert-dialog-description",className:C("text-sm text-balance text-muted-foreground md:text-pretty *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground",e),...t})}function Gc({className:e,...t}){return Rn(E,{"data-slot":"alert-dialog-action",className:C(e),...t})}function Yc({className:e,variant:t="outline",size:n="default",...o}){return Rn(Ar.Close,{"data-slot":"alert-dialog-cancel",className:C(e),render:Rn(E,{variant:t,size:n}),...o})}import{useCallback as rw,useEffect as bf,useState as sw}from"react";var Qc="mcp-inspector-saved-requests";function yf(){let[e,t]=sw([]);bf(()=>{try{let o=localStorage.getItem(Qc);o&&t(JSON.parse(o))}catch(o){console.error("[useSavedRequests] Failed to load saved requests:",o)}},[]),bf(()=>{let o=r=>{if(r.key===Qc&&r.newValue)try{t(JSON.parse(r.newValue))}catch(s){console.error("[useSavedRequests] Failed to parse saved requests:",s)}};return window.addEventListener("storage",o),()=>window.removeEventListener("storage",o)},[]);let n=rw(o=>{try{localStorage.setItem(Qc,JSON.stringify(o)),t(o)}catch(r){console.error("[useSavedRequests] Failed to save requests:",r)}},[]);return{savedRequests:e,saveSavedRequests:n}}import{useCallback as ca,useMemo as aw,useState as Ki}from"react";function xf({selectedTool:e,payloadToSend:t,toolArgs:n,callTool:o,readResource:r,serverId:s}){let[a,i]=Ki([]),[d,l]=Ki(!1),[u,h]=Ki(null),[c,m]=Ki(null),p=ca(async()=>{if(!e||d)return;let y=new AbortController;m(y),l(!0);let w=Date.now();try{let N=t,T=e?._meta||e?.metadata,P=T?.ui?.resourceUri;if(P&&typeof P=="string"){try{await r(P)}catch{}i([{toolName:e.name,args:N,result:null,timestamp:w,duration:0,toolMeta:T}])}let R=await o(e.name,N,{timeout:6e5,resetTimeoutOnProgress:!0,signal:y.signal}),D=Date.now()-w,k=R?._meta??T;Lt(new Hs({toolName:e.name,serverId:s,success:!0,duration:D})).catch(()=>{}),window.dispatchEvent(new Event("mcp-tool-executed")),i(P&&typeof P=="string"?S=>S.map((A,_)=>_===0?{...A,result:R,duration:D,toolMeta:k}:A):S=>[{toolName:e.name,args:n,result:R,timestamp:w,duration:D,toolMeta:k},...S])}catch(N){let T=Date.now()-w;Lt(new Hs({toolName:e.name,serverId:s,success:!1,duration:T,error:N instanceof Error?N.message:String(N)})).catch(()=>{}),window.dispatchEvent(new Event("mcp-tool-executed"));let L=e?._meta||e?.metadata,P={toolName:e.name,args:n,result:null,error:N instanceof Error?N.message:String(N),timestamp:w,duration:T,toolMeta:L},R=L?.ui?.resourceUri;i(R?[P]:D=>[P,...D])}finally{l(!1)}},[e,t,n,d,o,r,s]),x=ca(async(y,w)=>{try{await Xe(w),h(y),setTimeout(()=>h(null),2e3)}catch(N){console.error("[ToolsTab] Failed to copy result:",N)}},[]),f=ca(y=>{i(w=>w.filter((N,T)=>T!==y))},[]),b=aw(()=>e?a.filter(y=>y.toolName===e.name):[],[a,e]),g=ca(y=>{let w=b[y];if(!w)return;let N=window.open("","_blank","width=800,height=600");N&&(N.document.write(`
|
|
94
|
+
Based on this information, suggest 3-5 common customizable properties like theme, dimensions, colors, titles, or configuration options that would be useful for this type of resource. Keep it simple and practical.`,u=[{role:"system",content:d},{role:"user",content:l}],h=await Ep({config:{provider:e.provider,model:e.model,apiKey:e.apiKey,temperature:e.temperature,baseUrl:e.baseUrl},messages:u});try{let c=Ap(h);if(c)return Object.entries(c).map(([x,f])=>({key:x,value:typeof f=="object"&&f!==null?JSON.stringify(f):String(f)}));let m=h.split(`
|
|
95
|
+
`),p=[];for(let x of m){let f=x.match(/^\s*["']?(\w+)["']?\s*[:=]\s*["']?(.+?)["']?\s*,?\s*$/);f&&p.push({key:f[1].trim(),value:f[2].trim().replace(/^["']|["']$/g,"")})}if(p.length>0)return p;throw new Error("Could not parse props from LLM response")}catch(c){throw console.error("[usePropsLLM] Failed to parse LLM response:",c),new Error(`Failed to parse props from LLM response: ${h.slice(0,100)}...`)}},[e]),isAvailable:e!==null}}import{Loader2 as Sx,Plus as Tx,Sparkles as Px,Trash2 as Rx}from"lucide-react";import{useEffect as Mx,useMemo as Ix,useState as Xs}from"react";import{toast as Tr}from"sonner";import{jsx as Tn,jsxs as Sr}from"react/jsx-runtime";function Lp(e,t){if(!e?.$ref)return e;let n=e.$ref;if(n.startsWith("#/")){let o=n.substring(2).split("/"),r=t;for(let s of o)if(r&&typeof r=="object"&&s in r)r=r[s];else return console.warn(`Could not resolve $ref: ${n}`),e;return r}return e}function Nx(e,t){if(e.anyOf&&Array.isArray(e.anyOf)){let n=e.anyOf.find(o=>o.type!=="null");if(n)return{...Lp(n,t),nullable:!0}}return e}function kx(e){return Array.isArray(e.enum)?e.enum:null}function _p({name:e,schema:t,value:n,onChange:o,required:r=!1,disabled:s=!1,rootSchema:a}){let i=a||t,d=Nx(t,i);d=Lp(d,i);let l=kx(d),u=d.type==="string"&&l!==null,h=d;return h.type==="object"||h.type==="array"?Sr("div",{className:"space-y-2",children:[Sr(nt,{htmlFor:e,className:"text-sm font-medium",children:[e,r&&Tn("span",{className:"text-red-500 ml-1",children:"*"})]}),Tn(to,{id:e,value:n,onChange:m=>o(m.target.value),placeholder:h?.description||h?.default?JSON.stringify(h.default,null,2):`Enter ${e}`,className:"min-h-[100px]",disabled:s}),h?.description&&Tn("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:h.description})]}):u&&l?Sr("div",{className:"space-y-2",children:[Sr(nt,{htmlFor:e,className:"text-sm font-medium",children:[e,r&&Tn("span",{className:"text-red-500 ml-1",children:"*"})]}),Sr(kn,{value:n||"",onValueChange:o,disabled:s,children:[Tn($n,{id:e,className:"w-full",children:Tn(Un,{placeholder:h.description||"Select an option"})}),Tn(Fn,{children:l.map((m,p)=>Tn(Wt,{value:m,children:h.enumNames?.[p]||m},m))})]}),h.description&&Tn("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:h.description})]}):Sr("div",{className:"space-y-2",children:[Sr(nt,{htmlFor:e,className:"text-sm font-medium",children:[e,r&&Tn("span",{className:"text-red-500 ml-1",children:"*"})]}),Tn(Ge,{id:e,value:n,onChange:m=>o(m.target.value),placeholder:h?.description||(h?.default!==void 0?String(h.default):`Enter ${e}`),type:h.type==="number"?"number":"text",disabled:s}),h?.description&&Tn("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:h.description})]})}import{Fragment as Op,jsx as Et,jsxs as Ft}from"react/jsx-runtime";function zp({open:e,onOpenChange:t,onSave:n,existingPresets:o,resource:r,resourceAnnotations:s,llmConfig:a,editingPreset:i}){let d=Ix(()=>{let D=A=>{if(!A)return null;if(A.type==="object"&&A.properties)return A;let _=A?.def?.shape??A?._def?.shape;if(_&&typeof _=="object"){let K={},$=[],oe=ne=>({ZodString:"string",string:"string",ZodNumber:"number",number:"number",ZodBoolean:"boolean",boolean:"boolean",ZodArray:"array",array:"array",ZodObject:"object",object:"object"})[ne]||"string",ae=ne=>ne?.typeName??ne?.type??"",ie=ne=>{let z=ne?._def??ne?.def??{},O=ne,W=ae(z);for(;W==="ZodOptional"||W==="ZodDefault"||W==="ZodNullable";){O=z.innerType??O;let U=O?._def??O?.def??{};W=ae(U)}let j=oe(W);if(j==="array"){let U=O?._def?.type??O?.def?.element??O?.element;if(U){let H=U._def??U.def??{};if(oe(ae(H))==="object"){let Te=H.shape??U._def?.shape??U.def?.shape??{};return{type:"array",items:{type:"object",properties:Object.fromEntries(Object.entries(Te).map(([Pe,le])=>{let de=le?._def??le?.def??{};return[Pe,{type:oe(ae(de))}]}))}}}}return{type:"array"}}return{type:j}};for(let[ne,z]of Object.entries(_)){let O=z,W=O?._def??O?.def??{},j=ae(W),U=j==="ZodOptional"||j==="ZodDefault"||j==="ZodNullable",H=ie(O);K[ne]={type:H.type,...H.items&&{items:H.items},description:O?.description??W.description},U||$.push(ne)}if(Object.keys(K).length>0)return{type:"object",properties:K,required:$.length>0?$:void 0}}return null},k=s;if(k?.["mcp-use/propsSchema"])return D(k["mcp-use/propsSchema"]);let S=r.annotations;return S?.["mcp-use/propsSchema"]?D(S["mcp-use/propsSchema"]):null},[s,r.annotations,r.uri,r.name]),l=!!d,[u,h]=Xs(""),[c,m]=Xs({}),[p,x]=Xs([{id:crypto.randomUUID(),key:"",value:""}]),[f,b]=Xs(!1),[g,v]=Xs(null),{generateProps:y,isAvailable:w}=Dp({llmConfig:a});Mx(()=>{if(e){if(i)if(h(i.name),l)m(i.props);else{let D=Object.entries(i.props).map(([k,S])=>({id:crypto.randomUUID(),key:k,value:S}));x(D.length>0?D:[{id:crypto.randomUUID(),key:"",value:""}])}else h(""),l?m({}):x([{id:crypto.randomUUID(),key:"",value:""}]);v(null)}},[e,i,l]);let N=()=>{x([...p,{id:crypto.randomUUID(),key:"",value:""}])},T=D=>{p.length>1&&x(p.filter(k=>k.id!==D))},L=(D,k,S)=>{x(p.map(A=>A.id===D?{...A,[k]:S}:A))},P=async()=>{if(!w){Tr.error("LLM not configured",{description:"Please configure LLM in the Chat tab first."});return}b(!0),v(null);try{let D=await y({resource:r,resourceAnnotations:s,propsSchema:l?d:void 0});if(l){let k={};for(let S of D)d.properties?.[S.key]&&(k[S.key]=S.value);m(k)}else x(D.map(k=>({id:crypto.randomUUID(),key:k.key,value:k.value})));Tr.success("Props generated successfully",{description:`Generated ${D.length} prop(s) using ${a?.provider}`})}catch(D){let k=D instanceof Error?D.message:"Failed to generate props";v(k),Tr.error("LLM Generation Failed",{description:k})}finally{b(!1)}},R=()=>{if(!u.trim()){Tr.error("Preset name required",{description:"Please enter a name for this preset."});return}if(o.find(A=>A.name.toLowerCase()===u.toLowerCase()&&A.id!==i?.id)){Tr.error("Duplicate preset name",{description:"A preset with this name already exists."});return}let k;if(l)k={...c};else{k={};for(let A of p)A.key.trim()&&(k[A.key.trim()]=A.value)}if(Object.keys(k).length===0){Tr.error("No props defined",{description:"Please add at least one prop with a key."});return}let S={id:i?.id||crypto.randomUUID(),name:u.trim(),props:k};n(S),t(!1),Tr.success(i?"Preset updated":"Preset created",{description:`Preset "${S.name}" saved successfully.`})};return Et(fn,{open:e,onOpenChange:t,children:Ft(on,{scrollable:!0,className:"sm:max-w-[600px] max-h-[80vh]","data-testid":"props-config-dialog",children:[Ft(Qt,{children:[Et(qt,{children:i?"Edit Preset":"Create Props Preset"}),Ft(ho,{children:["Configure props for ",r.name||r.uri,". You can manually add key-value pairs or generate them with AI."]})]}),Ft(Hn,{className:"space-y-4 py-4",children:[Ft("div",{className:"space-y-2",children:[Et(nt,{htmlFor:"preset-name",children:"Preset Name"}),Et(Ge,{id:"preset-name","data-testid":"props-config-preset-name",value:u,onChange:D=>h(D.target.value),placeholder:"e.g., Dark Theme, Production Config",disabled:f})]}),Ft("div",{className:"space-y-2 p-3 bg-muted rounded-lg",children:[Ft("div",{className:"flex items-center justify-between",children:[Et(nt,{className:"text-sm font-medium",children:"Generate with AI"}),w&&Ft("span",{className:"text-xs text-muted-foreground",children:["Using ",a?.provider," (",a?.model,")"]})]}),w?Et(E,{onClick:P,disabled:f,size:"sm",variant:"outline",className:"w-full","data-testid":"props-config-generate-llm-button",children:f?Ft("span",{"data-testid":"props-config-generating",className:"flex items-center gap-2",children:[Et(Sx,{className:"h-4 w-4 mr-2 animate-spin"}),"Generating..."]}):Ft(Op,{children:[Et(Px,{className:"h-4 w-4 mr-2"}),"Generate Props with LLM"]})}):Et("p",{className:"text-xs text-muted-foreground",children:"LLM not configured. Please configure LLM in the Chat tab to use this feature."}),g&&Et("p",{className:"text-xs text-destructive","data-testid":"props-config-error",children:g})]}),Ft("div",{className:"space-y-3",children:[Et(nt,{className:"text-sm font-medium",children:"Props"}),l?Et("div",{className:"space-y-4",children:Object.entries(d.properties||{}).map(([D,k])=>Et(_p,{name:D,schema:k,value:c[D]||"",onChange:S=>m(A=>({...A,[D]:S})),required:d.required?.includes(D),disabled:f,rootSchema:d},D))}):Ft(Op,{children:[Et("div",{className:"flex items-center justify-between",children:Ft(E,{onClick:N,size:"sm",variant:"ghost",disabled:f,"data-testid":"props-config-add-prop",children:[Et(Tx,{className:"h-4 w-4 mr-1"}),"Add Prop"]})}),p.map((D,k)=>Ft("div",{className:"flex items-center gap-2",children:[Ft("div",{className:"flex-1 grid grid-cols-2 gap-2",children:[Et(Ge,{placeholder:"Key",value:D.key,onChange:S=>L(D.id,"key",S.target.value),disabled:f,"data-testid":`props-config-key-${k}`}),Et(Ge,{placeholder:"Value",value:D.value,onChange:S=>L(D.id,"value",S.target.value),disabled:f,"data-testid":`props-config-value-${k}`})]}),Et(E,{variant:"ghost",size:"sm",onClick:()=>T(D.id),disabled:p.length===1||f,className:"h-9 w-9 p-0","data-testid":`props-config-remove-${k}`,children:Et(Rx,{className:"h-4 w-4 text-muted-foreground"})})]},D.id))]})]})]}),Ft(li,{children:[Et(E,{variant:"outline",onClick:()=>t(!1),disabled:f,"data-testid":"props-config-cancel-button",children:"Cancel"}),Ft(E,{onClick:R,disabled:f,"data-testid":"props-config-save-button",children:[i?"Update":"Create"," Preset"]})]})]})})}function Bp(e){if(e===0)return"0 Bytes";let t=1024,n=["Bytes","KB","MB","GB"],o=Math.floor(Math.log(e)/Math.log(t));return Math.round(e/Math.pow(t,o)*100)/100+" "+n[o]}function Hp(e){if(e===0)return"0 B";let t=1024,n=["B","KB","MB"],o=Math.floor(Math.log(e)/Math.log(t));return`${parseFloat((e/Math.pow(t,o)).toFixed(1))} ${n[o]}`}var Up=100*1024,Fp=1024*20;function Li(e,t){if(e==null)return e;if(typeof e=="string")return e.length>t?e.substring(0,t)+"... (truncated)":e;if(Array.isArray(e))return e.map(n=>Li(n,t));if(typeof e=="object"){let n={};for(let o in e)Object.prototype.hasOwnProperty.call(e,o)&&(n[o]=Li(e[o],t));return n}return e}function $p(e){let t=JSON.stringify(e,null,2);return new TextEncoder().encode(t).length>Up?Li(e,Fp):e}function _i(e){let t=JSON.stringify(e,null,2),n=new TextEncoder().encode(t).length,o=n>Up,r;if(o){let a=Li(e,Fp);r=JSON.stringify(a,null,2)}else r=t;let s=Bp(n);return{isLarge:o,size:n,sizeFormatted:s,preview:r,full:t}}function Oi(e,t){try{let n=JSON.stringify(e,null,2),o=globalThis.Blob,r=new o([n],{type:"application/json"}),s=URL.createObjectURL(r),a=document.createElement("a");a.href=s,a.download=t||`data-${Date.now()}.json`,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(s)}catch(n){throw console.error("Failed to download JSON:",n),n}}import{jsx as Dx}from"react/jsx-runtime";var Ex={key:"text-sky-600 dark:text-sky-400",string:"text-emerald-600 dark:text-emerald-400",number:"text-amber-600 dark:text-amber-400",boolean:"text-violet-600 dark:text-violet-400",null:"text-zinc-500 dark:text-zinc-400",punctuation:"text-muted-foreground"};function Ax(e){let t=[],n=0,o=(r,s)=>{s&&t.push({kind:r,text:s})};for(;n<e.length;){let r=e[n];if(r==='"'){let s=n;for(n++;n<e.length;){if(e[n]==="\\"){n+=2;continue}if(e[n]==='"'){n++;break}n++}let a=e.slice(s,n),i=n;for(;i<e.length&&/[ \t]/.test(e[i]);)i++;let d=e[i]===":";o(d?"key":"string",a);continue}if(/[0-9-]/.test(r)){let s=n;for(e[n]==="-"&&n++;n<e.length&&/[0-9.eE+-]/.test(e[n]);)n++;o("number",e.slice(s,n));continue}if(e.startsWith("true",n)||e.startsWith("false",n)){let s=e.startsWith("true",n)?"true":"false";o("boolean",s),n+=s.length;continue}if(e.startsWith("null",n)){o("null","null"),n+=4;continue}if(/[{}[\],:]/.test(r)){o("punctuation",r),n++;continue}o("punctuation",r),n++}return t}function Lc(e){return Ax(e).map((t,n)=>Dx("span",{className:Ex[t.kind],children:t.text},n))}import{Download as Bx}from"lucide-react";import{ChevronRight as Lx}from"lucide-react";import{useState as _x}from"react";import{Fragment as zi,jsx as xt,jsxs as oo}from"react/jsx-runtime";var Zt={string:"text-emerald-600 dark:text-emerald-400",number:"text-amber-600 dark:text-amber-400",boolean:"text-violet-600 dark:text-violet-400",null:"text-zinc-500 dark:text-zinc-400",key:"text-sky-600 dark:text-sky-400",punctuation:"text-muted-foreground"};function Ox(e){return e===null?xt("span",{className:Zt.null,children:"null"}):typeof e=="string"?xt("span",{className:Zt.string,children:JSON.stringify(e)}):typeof e=="number"?xt("span",{className:Zt.number,children:String(e)}):typeof e=="boolean"?xt("span",{className:Zt.boolean,children:String(e)}):xt("span",{className:Zt.string,children:JSON.stringify(e)})}function zx(e){return Array.isArray(e)?`[${e.length}]`:`{${Object.keys(e).length}}`}function Vp({label:e,value:t,depth:n,defaultExpanded:o}){let r=t!==null&&typeof t=="object"&&!Array.isArray(t)?Object.keys(t).length>0:Array.isArray(t)?t.length>0:!1,[s,a]=_x(r&&(o||n===0));if(!r){let c=Array.isArray(t)?"[]":"{}";return t!==null&&typeof t=="object"?oo("div",{className:"font-mono text-[0.8rem] leading-relaxed",style:{paddingLeft:n*12},children:[e!=null&&oo(zi,{children:[xt("span",{className:Zt.key,children:JSON.stringify(e)}),xt("span",{className:Zt.punctuation,children:": "})]}),xt("span",{className:Zt.punctuation,children:c})]}):oo("div",{className:"font-mono text-[0.8rem] leading-relaxed",style:{paddingLeft:n*12},children:[e!=null&&oo(zi,{children:[xt("span",{className:Zt.key,children:JSON.stringify(e)}),xt("span",{className:Zt.punctuation,children:": "})]}),Ox(t)]})}let i=Array.isArray(t)?t.map((h,c)=>[String(c),h]):Object.entries(t),d=Array.isArray(t),l=d?"[":"{",u=d?"]":"}";return oo("div",{className:"font-mono text-[0.8rem] leading-relaxed",children:[oo("div",{className:"flex items-start gap-0.5",style:{paddingLeft:n*12},children:[xt("button",{type:"button","aria-expanded":s,onClick:()=>a(h=>!h),className:"mt-0.5 inline-flex shrink-0 items-center justify-center rounded-sm text-muted-foreground hover:text-foreground",children:xt(Lx,{className:C("h-3.5 w-3.5 transition-transform",s&&"rotate-90")})}),oo("div",{className:"min-w-0 flex-1",children:[e!=null&&oo(zi,{children:[xt("span",{className:Zt.key,children:JSON.stringify(e)}),xt("span",{className:Zt.punctuation,children:": "})]}),xt("span",{className:Zt.punctuation,children:l}),!s&&oo(zi,{children:[xt("button",{type:"button",onClick:()=>a(!0),className:"mx-1 text-xs text-muted-foreground hover:text-foreground",children:zx(t)}),xt("span",{className:Zt.punctuation,children:u})]})]})]}),s&&oo("div",{children:[i.map(([h,c])=>xt(Vp,{label:h,value:c,depth:n+1,defaultExpanded:o},`${n}-${h}`)),xt("div",{style:{paddingLeft:n*12},children:xt("span",{className:Zt.punctuation,children:u})})]})]})}function jp({data:e,defaultExpanded:t=!0,className:n}){return xt("div",{className:C("text-gray-900 dark:text-gray-100 [overflow-wrap:anywhere]",n),"data-testid":"collapsible-json",children:xt(Vp,{value:e,depth:0,defaultExpanded:t})})}import{jsx as bo,jsxs as us}from"react/jsx-runtime";var qp="font-mono text-[0.8rem] text-gray-900 dark:text-gray-100 whitespace-pre-wrap break-words [overflow-wrap:anywhere]";function wt({data:e,filename:t,className:n,collapsible:o=!1,defaultExpanded:r=!0,...s}){let a=_i(e),i=$p(e),d=()=>{Oi(e,t)},l=a.isLarge?bo("div",{className:"mb-3 p-3 bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-lg",children:us("div",{className:"flex items-center justify-between gap-2",children:[us("div",{className:"flex-1",children:[us("p",{className:"text-sm font-medium text-yellow-800 dark:text-yellow-300 mb-1",children:["JSON is too large (",a.sizeFormatted,")"]}),bo("p",{className:"text-xs text-yellow-700 dark:text-yellow-400",children:"Showing full structure with truncated values. Download the full JSON file to see complete values."})]}),us(E,{variant:"outline",size:"sm",onClick:d,className:"shrink-0",children:[bo(Bx,{className:"h-4 w-4 mr-1"}),"Download"]})]})}):null;return o?us("div",{className:n,...s,children:[l,bo(jp,{data:i,defaultExpanded:r})]}):a.isLarge?us("div",{className:n,...s,children:[l,bo("pre",{className:qp,children:bo("code",{children:Lc(a.preview)})})]}):bo("div",{className:n,...s,children:bo("pre",{className:qp,children:bo("code",{children:Lc(a.preview)})})})}import{jsx as Ko,jsxs as Zs}from"react/jsx-runtime";function Wp({value:e,onChange:t}){let n=(o,r)=>{let s=parseInt(r,10);isNaN(s)||t({...e,[o]:s})};return Zs("div",{className:"grid grid-cols-2 gap-2",children:[Zs("div",{className:"space-y-1",children:[Ko("label",{className:"text-xs text-muted-foreground",children:"Top"}),Ko(Ge,{type:"number",min:"0",value:e.top,onChange:o=>n("top",o.target.value),className:"h-8","data-testid":"debugger-safe-area-top"})]}),Zs("div",{className:"space-y-1",children:[Ko("label",{className:"text-xs text-muted-foreground",children:"Right"}),Ko(Ge,{type:"number",min:"0",value:e.right,onChange:o=>n("right",o.target.value),className:"h-8","data-testid":"debugger-safe-area-right"})]}),Zs("div",{className:"space-y-1",children:[Ko("label",{className:"text-xs text-muted-foreground",children:"Bottom"}),Ko(Ge,{type:"number",min:"0",value:e.bottom,onChange:o=>n("bottom",o.target.value),className:"h-8","data-testid":"debugger-safe-area-bottom"})]}),Zs("div",{className:"space-y-1",children:[Ko("label",{className:"text-xs text-muted-foreground",children:"Left"}),Ko(Ge,{type:"number",min:"0",value:e.left,onChange:o=>n("left",o.target.value),className:"h-8","data-testid":"debugger-safe-area-left"})]})]})}function Kp(e,t){let n=new Set(t?.connectDomains??[]),o=new Set(t?.resourceDomains??[]),r=new Set(t?.frameDomains??[]),s=new Set(["script-src","style-src","img-src","font-src","media-src"]),a="connect-src",i="frame-src";for(let l of e){let u=(l.blockedUri||"").trim();if(!u||u==="(inline)"||u.startsWith("blob:")||u.startsWith("data:"))continue;let h=null;try{h=new URL(u).origin}catch{continue}if(!h)continue;let c=(l.effectiveDirective||l.directive||"").toLowerCase();c===a?(n.add(h),h.startsWith("http://")?n.add(h.replace("http://","ws://")):h.startsWith("https://")&&n.add(h.replace("https://","wss://"))):s.has(c)?o.add(h):c===i&&r.add(h)}let d={connectDomains:Array.from(n).sort(),resourceDomains:Array.from(o).sort()};return r.size>0&&(d.frameDomains=Array.from(r).sort()),d}var Hx="https://raw.githubusercontent.com/modelcontextprotocol/ext-apps/bcfffb6585ea4fb1e3a9da39fb8911b83399fa71/specification/2026-01-26/apps.mdx",Ux="https://mcp-use.com/docs/typescript/server/csp";function Jp(e,t,n,o){let r=["Fix the Content Security Policy (CSP) for this MCP Apps widget. The widget has CSP violations that block network requests and resources.","","**References:**",`- MCP Apps CSP spec: ${Hx}`,`- mcp-use CSP docs: ${Ux}`,""];if(r.push("**Current declared CSP:**"),e?(r.push(`connectDomains: ${JSON.stringify(e.connectDomains??[])}`),r.push(`resourceDomains: ${JSON.stringify(e.resourceDomains??[])}`),r.push(`frameDomains: ${JSON.stringify(e.frameDomains??[])}`),r.push(`baseUriDomains: ${JSON.stringify(e.baseUriDomains??[])}`)):r.push("No CSP declared."),r.push(""),t&&(r.push("**Effective policy (originalPolicy):**"),r.push("```"),r.push(t),r.push("```"),r.push("")),n.length>0){r.push(`**Blocked requests (${n.length}):**`);for(let s of n){let a=s.effectiveDirective||s.directive,i=s.blockedUri||"(inline)";r.push(`- ${a}: ${i}`)}r.push("")}return o?(r.push("**Apply this CSP config to fix the violations:**"),r.push("Add these domains to the widget's CSP metadata (resource _meta.ui.csp). Use camelCase for MCP Apps (connectDomains, resourceDomains)."),r.push(""),r.push("```json"),r.push(JSON.stringify({connectDomains:o.connectDomains,resourceDomains:o.resourceDomains,...o.frameDomains?.length?{frameDomains:o.frameDomains}:{}},null,2)),r.push("```")):r.push("No blocked requests - no fix needed."),r.join(`
|
|
96
|
+
`)}import{Popover as ea}from"@base-ui/react/popover";import{jsx as ta}from"react/jsx-runtime";function Jo({...e}){return ta(ea.Root,{"data-slot":"popover",...e})}function Go(e){return ta(ea.Trigger,{"data-slot":"popover-trigger",...e})}function Yo({className:e,align:t="center",alignOffset:n=0,side:o="bottom",sideOffset:r=4,...s}){return ta(ea.Portal,{children:ta(ea.Positioner,{align:t,alignOffset:n,side:o,sideOffset:r,className:"isolate z-50",children:ta(ea.Popup,{"data-slot":"popover-content",className:C("z-50 flex w-72 origin-(--transform-origin) flex-col gap-4 rounded-md bg-popover p-4 text-sm text-popover-foreground shadow-md ring-1 ring-foreground/10 outline-hidden duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-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 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",e),...s})})})}import{Fragment as nf,jsx as F,jsxs as ve}from"react/jsx-runtime";var Pr="__no_props__",na="__tool_props__",Zp="__create_preset__",ef=[{value:"desktop",label:"Desktop",icon:of},{value:"mobile",label:"Mobile",icon:rf}];function tf({options:e,value:t,onValueChange:n,placeholder:o,contentTestId:r,searchTestId:s,optionTestId:a,trigger:i}){let[d,l]=yo(!1),[u,h]=yo(""),c=e0(null);Bi(()=>{if(!d){h("");return}let x=requestAnimationFrame(()=>c.current?.focus());return()=>cancelAnimationFrame(x)},[d]);let m=oa(()=>{let x=u.trim().toLowerCase();return x?e.filter(f=>f.label.toLowerCase().includes(x)||f.value.toLowerCase().includes(x)):[...e]},[e,u]),p=m.findIndex(x=>x.value===t);return ve(Cr,{open:d,onOpenChange:l,children:[i,ve(Nr,{"data-testid":r,checkedIndex:p>=0?p:void 0,className:"w-80 overflow-hidden",children:[F("div",{className:"border-b border-border p-2",onKeyDown:x=>x.stopPropagation(),children:F(Ge,{ref:c,value:u,onChange:x=>h(x.target.value),placeholder:o,"data-testid":s,className:"h-8"})}),F("div",{className:"max-h-64 overflow-y-auto",children:m.length===0?F("p",{className:"px-3 py-4 text-xs text-muted-foreground",children:"No results found."}):m.map((x,f)=>F(yr,{index:f,label:x.label,checked:t===x.value,"data-testid":a(x.value),onSelect:()=>{n(x.value),l(!1)}},x.value))})]})]})}function Hi({displayMode:e,onDisplayModeChange:t,toolCallId:n,propsContext:o,resourceUri:r,toolInput:s,resourceAnnotations:a,llmConfig:i,resource:d,onPropsChange:l,requiredProps:u}){let{resolvedTheme:h,setTheme:c}=no(),{playground:m,updatePlaygroundSettings:p,widgets:x,clearCspViolations:f}=Vo(),b=x.get(n),g=b?.cspViolations??[],v=b?.declaredCsp,y=b?.effectivePolicy,w=g.length>0?Kp(g,v):null,N=g.length>0?Jp(v,y,g,w):"",T=e==="fullscreen",L=e==="pip",{presets:P,activePresetId:R,savePreset:D,deletePreset:k,setActivePreset:S,getActiveProps:A}=hp(r),[_,K]=yo(!1),oe=!!u?.length&&!R,[ae,ie]=yo(()=>oe);Bi(()=>{oe&&ie(!0)},[oe]);let[ne,z]=yo(null),[O,W]=yo(!1),[j,U]=yo("mode"),[H,Te]=yo(!0),Pe=oa(()=>Qm(v),[v]),le=oa(()=>Xm(y),[y]),de=oa(()=>Zm(Pe,le),[Pe,le]),De=oa(()=>ep({mode:m.cspMode,declared:v,effectivePolicy:y,violations:g}),[m.cspMode,v,y,g]),Re=Zx(()=>o==="tool"&&s?na:Pr,[o,s]),[Oe,Be]=yo(Re());Bi(()=>{R&&o!=="tool"?Be(R):Oe!==Pr&&Oe!==na&&Be(Re())},[R,Oe,Re,o]),Bi(()=>{if(l){if(Oe===Pr||Oe===na)l(null);else if(R&&Oe===R){let M=A();M&&l(M)}}},[Oe,R,s,A,l,P]);let tt=M=>{if(M===Zp){z(null),K(!0);return}if(M===Pr||M===na)S(null),Be(M),l?.(null);else{S(M),Be(M);let Ne=P.find(gt=>gt.id===M);l?.(Ne?.props??null)}},V=M=>{D(M),S(M.id),Be(M.id),l?.(M.props)},ce=(M,Ne)=>{Ne.stopPropagation();let gt=P.find(qe=>qe.id===M);gt&&(k(M),_c.success("Preset deleted",{description:`Preset "${gt.name}" has been deleted.`}))},Fe=(M,Ne)=>{Ne.stopPropagation(),z(M),K(!0)},Y=()=>m.deviceType==="mobile"?F(rf,{className:"size-3"}):F(of,{className:"size-3"}),q=ef.findIndex(M=>M.value===m.deviceType);return ve("div",{className:"flex items-center gap-2",children:[!T&&!L&&ve(nf,{children:[ve(ke,{children:[F(we,{render:F(E,{"data-testid":"debugger-fullscreen-button",variant:"outline",size:"sm",className:"bg-white/90 dark:bg-zinc-900/90 backdrop-blur-sm shadow-sm hover:bg-white dark:hover:bg-zinc-900",onClick:()=>t("fullscreen"),children:F(jx,{className:"size-4"})}),nativeButton:!0}),F(Ce,{children:"Enter fullscreen mode"})]}),ve(ke,{children:[F(we,{render:F(E,{"data-testid":"debugger-pip-button",variant:"outline",size:"sm",className:"bg-white/90 dark:bg-zinc-900/90 backdrop-blur-sm shadow-sm hover:bg-white dark:hover:bg-zinc-900",onClick:()=>t("pip"),children:F(Kx,{className:"size-4"})}),nativeButton:!0}),F(Ce,{children:"Picture-in-picture"})]})]}),ve(Cr,{children:[ve(ke,{children:[F(we,{render:F(Ho,{render:F(E,{"data-testid":"debugger-device-button",variant:"outline",size:"sm",className:"h-8 w-8 p-0 bg-white/90 dark:bg-zinc-900/90 backdrop-blur-sm shadow-sm hover:bg-white dark:hover:bg-zinc-900",children:Y()}),nativeButton:!0}),nativeButton:!0}),ve(Ce,{children:["Device: ",m.deviceType]})]}),F(Nr,{"data-testid":"debugger-device-dialog",checkedIndex:q>=0?q:void 0,className:"w-56",children:ef.map((M,Ne)=>F(yr,{index:Ne,icon:M.icon,label:M.label,checked:m.deviceType===M.value,"data-testid":`debugger-device-option-${M.value}`,onSelect:()=>p({deviceType:M.value})},M.value))})]}),ve(ke,{children:[F(we,{render:F(E,{"data-testid":"debugger-theme-button",variant:"outline",size:"sm",className:"h-8 w-8 p-0 bg-white/90 dark:bg-zinc-900/90 backdrop-blur-sm shadow-sm hover:bg-white dark:hover:bg-zinc-900",onClick:()=>{c(h==="dark"?"light":"dark")},children:h==="dark"?F(qx,{className:"size-3.5"}):F(Qx,{className:"size-3.5"})}),nativeButton:!0}),ve(Ce,{children:["Theme: ",h==="dark"?"Dark":"Light"]})]}),F(tf,{options:up,value:m.locale,onValueChange:M=>p({locale:M}),placeholder:"Search locales...",contentTestId:"debugger-locale-dialog",searchTestId:"debugger-locale-search",optionTestId:M=>`debugger-locale-option-${M}`,trigger:ve(ke,{children:[F(we,{render:F(Ho,{render:F(E,{"data-testid":"debugger-locale-button",variant:"outline",size:"sm",className:"h-8 min-w-[50px] px-2 bg-white/90 dark:bg-zinc-900/90 backdrop-blur-sm shadow-sm hover:bg-white dark:hover:bg-zinc-900",children:F("span",{className:"text-xs font-mono",children:m.locale})}),nativeButton:!0}),nativeButton:!0}),F(Ce,{children:"Locale"})]})}),F(tf,{options:mp,value:m.timeZone,onValueChange:M=>p({timeZone:M}),placeholder:"Search timezones...",contentTestId:"debugger-timezone-dialog",searchTestId:"debugger-timezone-search",optionTestId:M=>`debugger-timezone-option-${M.replace(/\//g,"-")}`,trigger:ve(ke,{children:[F(we,{render:F(Ho,{render:F(E,{"data-testid":"debugger-timezone-button",variant:"outline",size:"sm",className:"h-8 w-8 p-0 bg-white/90 dark:bg-zinc-900/90 backdrop-blur-sm shadow-sm hover:bg-white dark:hover:bg-zinc-900",children:F(Vx,{className:"size-3.5"})}),nativeButton:!0}),nativeButton:!0}),ve(Ce,{children:["Timezone: ",m.timeZone]})]})}),ve(fn,{open:O,onOpenChange:W,children:[ve(ke,{children:[F(we,{render:F(Yl,{render:ve(E,{"data-testid":"debugger-csp-button",variant:"outline",size:"sm",className:"relative h-8 w-8 p-0 bg-white/90 dark:bg-zinc-900/90 backdrop-blur-sm shadow-sm hover:bg-white dark:hover:bg-zinc-900",children:[m.cspMode==="permissive"?F(Xp,{className:"size-3.5"}):F(Qp,{className:"size-3.5"}),g.length>0&&F("span",{className:`absolute -top-1.5 -right-1.5 flex h-4 min-w-4 items-center justify-center rounded-full px-0.5 text-[9px] font-bold text-white leading-none ${m.cspMode==="permissive"?"bg-yellow-500":"bg-red-500"}`,children:g.length>99?"99+":g.length})]}),nativeButton:!0}),nativeButton:!0}),ve(Ce,{children:["CSP:"," ",m.cspMode==="permissive"?"Permissive":"Declared",g.length>0&&` \xB7 ${g.length} ${m.cspMode==="permissive"?"would be blocked":"blocked"}`]})]}),ve(on,{scrollable:!0,className:"sm:max-w-[520px] max-h-[85vh]","data-testid":"debugger-csp-dialog",children:[F(Qt,{children:F(qt,{children:"CSP Mode"})}),ve(Hn,{className:"space-y-3",children:[F("div",{role:"tablist","aria-label":"CSP diagnostics",className:"grid grid-cols-3 rounded-md border border-zinc-200 dark:border-zinc-700 p-1",children:[["mode","Mode"],["diff","Policy Diff"],["findings","Findings"]].map(([M,Ne])=>F("button",{type:"button",role:"tab","aria-selected":j===M,onClick:()=>U(M),className:`rounded px-2 py-1.5 text-xs font-medium ${j===M?"bg-zinc-100 dark:bg-zinc-800":"text-muted-foreground"}`,children:Ne},M))}),j==="mode"&&ve("div",{role:"tabpanel",className:"space-y-2",children:[ve(E,{"data-testid":"debugger-csp-option-permissive",variant:m.cspMode==="permissive"?"default":"outline",className:"w-full justify-start",onClick:()=>p({cspMode:"permissive"}),children:[F(Xp,{className:"size-4 mr-2"}),"Permissive"]}),ve(E,{"data-testid":"debugger-csp-option-widget-declared",variant:m.cspMode==="widget-declared"?"default":"outline",className:"w-full justify-start",onClick:()=>p({cspMode:"widget-declared"}),children:[F(Qp,{className:"size-4 mr-2"}),"Widget-Declared"]}),F("p",{className:"text-xs text-muted-foreground",children:"Permissive records would-be blocks; Widget-Declared enforces the resource metadata policy."})]}),j==="diff"&&ve("div",{role:"tabpanel",className:"space-y-2",children:[de.length?F("div",{className:"max-h-64 overflow-y-auto rounded border border-zinc-200 dark:border-zinc-700",children:de.map(M=>ve("div",{className:"border-b border-zinc-100 dark:border-zinc-800 p-2 text-xs last:border-0",children:[ve("div",{className:"flex items-center justify-between",children:[F("code",{children:M.directive}),F("span",{className:"text-[10px] uppercase text-muted-foreground",children:M.status})]}),ve("div",{className:"mt-1 font-mono text-[10px] text-muted-foreground break-all",children:["requested: ",M.requested.join(" ")||"\u2014",F("br",{}),"effective: ",M.effective.join(" ")||"\u2014"]})]},M.directive))}):F("p",{className:"text-xs text-muted-foreground",children:"No requested or effective policy data yet."}),y&&ve(E,{variant:"outline",size:"sm",onClick:async()=>{try{await Xe(y),_c.success("Policy copied to clipboard")}catch{_c.error("Failed to copy")}},children:[F(Yp,{className:"size-3.5 mr-2"}),"Copy effective policy"]})]}),j==="findings"&&ve("div",{role:"tabpanel",className:"space-y-2",children:[F("div",{className:"space-y-1.5",children:De.map((M,Ne)=>ve("div",{className:"rounded border border-zinc-200 dark:border-zinc-700 p-2",children:[F("div",{className:"text-xs font-medium",children:M.title}),F("div",{className:"text-[11px] text-muted-foreground break-all",children:M.detail})]},`${M.title}-${Ne}`))}),g.length>0&&ve(nf,{children:[ve("div",{className:"flex items-center justify-between",children:[ve("span",{className:"text-xs font-medium",children:[g.length," observed request",g.length===1?"":"s"]}),F("button",{className:"text-xs text-muted-foreground underline",onClick:()=>f(n),children:"Clear"})]}),ve("div",{className:"border border-amber-200 dark:border-amber-800 rounded-md overflow-hidden",children:[ve("div",{className:"flex items-center justify-between bg-amber-50 dark:bg-amber-950/30 px-3 py-2",children:[ve("button",{type:"button",className:"flex items-center gap-2 text-xs font-medium text-amber-800 dark:text-amber-200",onClick:()=>Te(M=>!M),children:[H?F(Fx,{className:"size-3.5"}):F($x,{className:"size-3.5"}),"Prompt for Agents"]}),F(E,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>{Xe(N)},"aria-label":"Copy prompt for agents",children:F(Yp,{className:"size-3.5"})})]}),H&&F("pre",{className:"max-h-48 overflow-auto whitespace-pre-wrap p-2 text-[11px]","data-testid":"debugger-csp-prompt-for-agents",children:N})]})]})]})]})]})]}),ve(ke,{children:[F(we,{render:F(E,{"data-testid":"debugger-touch-button",variant:"outline",size:"sm",className:`h-8 w-8 p-0 bg-white/90 dark:bg-zinc-900/90 backdrop-blur-sm shadow-sm hover:bg-white dark:hover:bg-zinc-900 ${m.capabilities.touch?"border-blue-500 dark:border-blue-400":""}`,onClick:()=>{let M={...m.capabilities,touch:!m.capabilities.touch};p({capabilities:M})},children:F(Jx,{className:`size-3.5 ${m.capabilities.touch?"text-blue-600 dark:text-blue-400":""}`})}),nativeButton:!0}),ve(Ce,{children:["Touch: ",m.capabilities.touch?"Enabled":"Disabled"]})]}),ve(ke,{children:[F(we,{render:F(E,{"data-testid":"debugger-hover-button",variant:"outline",size:"sm",className:`h-8 w-8 p-0 bg-white/90 dark:bg-zinc-900/90 backdrop-blur-sm shadow-sm hover:bg-white dark:hover:bg-zinc-900 ${m.capabilities.hover?"border-blue-500 dark:border-blue-400":""}`,onClick:()=>{let M={...m.capabilities,hover:!m.capabilities.hover};p({capabilities:M})},children:F(Wx,{className:`size-3.5 ${m.capabilities.hover?"text-blue-600 dark:text-blue-400":""}`})}),nativeButton:!0}),ve(Ce,{children:["Hover: ",m.capabilities.hover?"Enabled":"Disabled"]})]}),ve(Jo,{children:[F(Go,{render:F(E,{"data-testid":"debugger-safe-area-button",variant:"outline",size:"sm",className:"h-8 w-8 p-0 bg-white/90 dark:bg-zinc-900/90 backdrop-blur-sm shadow-sm hover:bg-white dark:hover:bg-zinc-900",children:F(Yx,{className:"size-3.5"})}),nativeButton:!0}),F(Yo,{className:"w-64 p-3","data-testid":"debugger-safe-area-dialog",children:ve("div",{className:"space-y-2",children:[F("label",{className:"text-xs font-medium",children:"Safe Area Insets"}),F(Wp,{value:m.safeAreaInsets,onChange:M=>{p({safeAreaInsets:M})}})]})})]}),o==="tool"?ve(fn,{children:[ve(ke,{children:[F(we,{render:F(Yl,{render:F(E,{variant:"outline",size:"sm",className:"h-8 w-8 p-0 bg-white/90 dark:bg-zinc-900/90 backdrop-blur-sm shadow-sm hover:bg-white dark:hover:bg-zinc-900","data-testid":"debugger-props-button",children:F(Gp,{className:"size-3.5"})}),nativeButton:!0}),nativeButton:!0}),F(Ce,{children:"View Tool Props"})]}),ve(on,{scrollable:!0,className:"sm:max-w-[600px] max-h-[85vh]","data-testid":"debugger-props-dialog",children:[F(Qt,{children:F(qt,{children:"Tool Props"})}),F(Hn,{children:F(ii,{children:F(wt,{data:s??{},filename:"tool-props.json"})})})]})]}):ve(Jo,{open:ae,onOpenChange:ie,children:[ve(ke,{children:[F(we,{render:F(Go,{render:F(E,{variant:"outline",size:"sm",className:`h-8 w-8 p-0 backdrop-blur-sm shadow-sm ${oe?"bg-amber-50 dark:bg-amber-950/40 border-amber-300 dark:border-amber-700 hover:bg-amber-100 dark:hover:bg-amber-900/50 animate-pulse":"bg-white/90 dark:bg-zinc-900/90 hover:bg-white dark:hover:bg-zinc-900"}`,"data-testid":"debugger-props-button",children:F(Gp,{className:`size-3.5 ${oe?"text-amber-500":""}`})}),nativeButton:!0}),nativeButton:!0}),ve(Ce,{children:["Props:"," ",Oe===Pr?"No Props":Oe===na?"Tool Props":P.find(M=>M.id===Oe)?.name||"Custom"]})]}),ve(Yo,{className:"w-64 p-2","data-testid":"debugger-props-popover",children:[oe&&ve("div",{className:"mb-2 rounded-md border border-amber-200 dark:border-amber-800/50 bg-amber-50 dark:bg-amber-950/30 px-3 py-2",children:[F("p",{className:"text-xs font-medium text-amber-700 dark:text-amber-300 mb-0.5",children:"Props required to render this widget:"}),F("p",{className:"text-xs font-mono text-amber-600 dark:text-amber-400",children:u.join(", ")}),F("p",{className:"text-xs text-amber-500 dark:text-amber-400 mt-1",children:"Create a preset below to set them."})]}),ve("div",{className:"space-y-1",children:[F(E,{variant:Oe===Pr?"secondary":"ghost",size:"sm",className:"w-full justify-start",onClick:()=>tt(Pr),"data-testid":"debugger-props-no-props",children:"No Props"}),P.map(M=>ve("div",{className:"relative group flex items-center",children:[F(E,{variant:Oe===M.id?"secondary":"ghost",size:"sm",className:"w-full justify-start pr-14",onClick:()=>tt(M.id),"data-testid":`debugger-props-preset-${M.id}`,children:M.name}),ve("div",{className:"absolute right-2 flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[F(E,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:Ne=>Fe(M,Ne),"data-testid":`debugger-props-edit-${M.id}`,children:F(Gx,{className:"h-3 w-3"})}),F(E,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:Ne=>ce(M.id,Ne),"data-testid":`debugger-props-delete-${M.id}`,children:F(Xx,{className:"h-3 w-3 text-destructive"})})]})]},M.id)),F(E,{variant:"ghost",size:"sm",className:"w-full justify-start text-primary",onClick:()=>tt(Zp),"data-testid":"debugger-props-create-preset",children:"+ Create Preset..."})]})]})]}),F(Ip,{iframeId:n,enabled:!0}),d&&F(zp,{open:_,onOpenChange:K,onSave:V,existingPresets:P,resource:d,resourceAnnotations:a,llmConfig:i||null,editingPreset:ne})]})}import{jsx as Ui,jsxs as sf}from"react/jsx-runtime";function ms({message:e,className:t="",vertical:n,noBorder:o}){return Ui("div",{className:C(`mt-2 rounded-md p-6 ${t}`,!o&&"border"),children:sf("p",{className:C("text-sm text-muted-foreground flex items-center gap-4",n&&"flex-col"),children:[sf("svg",{viewBox:"-6 -6 512 512",xmlns:"http://www.w3.org/2000/svg",className:"size-14 shrink-0 stroke-black dark:stroke-white",fill:"none",strokeWidth:"4.8",strokeLinecap:"round",strokeLinejoin:"round",children:[Ui("path",{d:"M105.933 0C164.437 0.000116002 211.865 47.607 211.865 106.333C211.865 131.829 210.493 158.403 221.068 181.602L228.975 198.947C243.584 230.997 269.265 256.7 301.303 271.336L316.155 278.121C340.142 289.079 367.694 287.335 394.066 287.335C452.571 287.335 499.999 334.942 499.999 393.668C499.999 452.394 452.571 500.001 394.066 500.001C335.562 500.001 288.134 452.394 288.134 393.668C288.134 368.974 289.24 343.275 278.992 320.807L270.586 302.38C255.948 270.29 230.214 244.565 198.118 229.939L180.164 221.758C157.282 211.331 131.078 212.666 105.933 212.666C47.4278 212.666 4.86252e-05 165.059 0 106.333C0 47.607 47.4278 0 105.933 0Z"}),Ui("circle",{cx:"100.426",cy:"399.575",r:"100.426"}),Ui("path",{d:"M500 100.426C500 155.889 455.037 200.851 399.574 200.851C344.11 200.851 299.148 155.889 299.148 100.426C299.148 44.962 344.11 0 399.574 0C455.037 0 500 44.962 500 100.426Z"})]}),e]})})}import{jsx as X,jsxs as Ae}from"react/jsx-runtime";function m0({timestamp:e}){let[t,n]=Rr(()=>zc(e));return ra(()=>{let o=()=>n(zc(e));o();let r=setInterval(o,1e3);return()=>clearInterval(r)},[e]),X("span",{children:t})}function zc(e){let n=Date.now()-e,o=Math.floor(n/1e3),r=Math.floor(o/60),s=Math.floor(r/60),a=Math.floor(s/24);return o<10?"now":o<60?`${o}s ago`:r<60?`${r}m ago`:s<24?`${s}h ago`:`${a}d ago`}function lf(e){if(!e?.isError)return null;let t=e.content;if(Array.isArray(t)){let n=t.filter(o=>o.type==="text").map(o=>o.text).filter(Boolean);if(n.length>0)return n.join(`
|
|
97
|
+
`)}return"An error occurred"}function p0(e){try{return JSON.parse(e),!0}catch{return!1}}function f0({content:e}){let[t,n]=Rr(new Set),o=Oc(r=>{n(s=>{let a=new Set(s);return a.has(r)?a.delete(r):a.add(r),a})},[]);return!Array.isArray(e)||e.length===0?X("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:"No content"}):X("div",{className:"space-y-4",children:e.map((r,s)=>{if(r.type==="text"){let a=r.text||"",i=t.has(s),d=p0(a),l=d?(()=>{try{return JSON.parse(a)}catch{return null}})():null;return Ae("div",{className:"space-y-2",children:[Ae("div",{className:"flex items-center justify-between gap-2",children:[Ae("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:["Text Content",i?" (formatted)":""]}),d&&X("button",{type:"button",onClick:()=>o(s),className:"text-xs text-blue-600 dark:text-blue-400 hover:underline","data-testid":`tool-result-format-toggle-${s}`,children:i?"Show as text":"Try to format"})]}),i&&l!==null?X(wt,{data:l,filename:`content-${s}.json`}):X("div",{className:"bg-gray-50 dark:bg-zinc-900 rounded-lg p-3 font-mono text-sm whitespace-pre-wrap break-words","data-testid":"tool-execution-results-text-content",children:a})]},s)}if(r.type==="image")return Ae("div",{className:"space-y-2",children:[X("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"Image Content"}),Ae("div",{className:"bg-gray-50 dark:bg-zinc-900 rounded-lg p-3",children:[X("img",{src:`data:${r.mimeType||"image/png"};base64,${r.data}`,alt:"Result",className:"max-w-full rounded","data-testid":"tool-execution-results-image-content"}),r.annotations&&X("div",{className:"mt-2 text-xs text-gray-500 dark:text-gray-400",children:X(wt,{data:r.annotations,filename:`image-annotations-${s}.json`,"data-testid":"tool-execution-results-image-annotations"})})]})]},s);if(r.type==="audio")return Ae("div",{className:"space-y-2",children:[X("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"Audio Content"}),Ae("div",{className:"bg-gray-50 dark:bg-zinc-900 rounded-lg p-3",children:[X("audio",{controls:!0,src:`data:${r.mimeType||"audio/wav"};base64,${r.data}`,className:"w-full","data-testid":"tool-execution-results-audio-content"}),r.annotations&&X("div",{className:"mt-2 text-xs text-gray-500 dark:text-gray-400",children:X(wt,{data:r.annotations,filename:`audio-annotations-${s}.json`,"data-testid":"tool-execution-results-audio-annotations"})})]})]},s);if(r.type==="resource_link")return Ae("div",{className:"space-y-2",children:[X("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"Resource Link"}),Ae("div",{className:"bg-gray-50 dark:bg-zinc-900 rounded-lg p-3 space-y-2",children:[Ae("div",{className:"font-mono text-sm break-all",children:[X("span",{className:"text-gray-600 dark:text-gray-400",children:"URI:"})," ",r.uri]}),r.name&&Ae("div",{className:"text-sm",children:[X("span",{className:"text-gray-600 dark:text-gray-400",children:"Name:"})," ",r.name]}),r.description&&Ae("div",{className:"text-sm",children:[X("span",{className:"text-gray-600 dark:text-gray-400",children:"Description:"})," ",r.description]}),r.mimeType&&Ae("div",{className:"text-sm",children:[X("span",{className:"text-gray-600 dark:text-gray-400",children:"MIME Type:"})," ",r.mimeType]}),r.annotations&&Ae("div",{className:"mt-2",children:[X("div",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"Annotations:"}),X(wt,{data:r.annotations,filename:`resource-link-annotations-${s}.json`,"data-testid":"tool-execution-results-resource-link-annotations"})]})]})]},s);if(r.type==="resource"){let a=r.resource||{};return Ae("div",{className:"space-y-2",children:[X("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"Embedded Resource"}),Ae("div",{className:"bg-gray-50 dark:bg-zinc-900 rounded-lg p-3 space-y-2",children:[Ae("div",{className:"font-mono text-sm break-all","data-testid":"tool-execution-results-resource-uri",children:[X("span",{className:"text-gray-600 dark:text-gray-400",children:"URI:"})," ",a.uri]}),a.mimeType&&Ae("div",{className:"text-sm",children:[X("span",{className:"text-gray-600 dark:text-gray-400","data-testid":"tool-execution-results-mime-type",children:"MIME Type:"})," ",a.mimeType]}),a.text&&Ae("div",{"data-testid":"tool-execution-results-resource-text-content",children:[X("div",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"Content:"}),X("div",{className:"bg-white dark:bg-black rounded p-2 font-mono text-sm whitespace-pre-wrap break-words max-h-60 overflow-y-auto",children:a.text})]}),a.blob&&Ae("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:["[Binary content: ",a.blob.length||0," bytes]"]}),a.annotations&&Ae("div",{className:"mt-2",children:[X("div",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"Annotations:"}),X(wt,{data:a.annotations,filename:`resource-annotations-${s}.json`,"data-testid":"tool-execution-results-resource-annotations"})]})]})]},s)}return Ae("div",{className:"space-y-2",children:[Ae("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:["Unknown Content Type: ",r.type||"N/A"]}),X(wt,{data:r,filename:`content-${s}.json`,"data-testid":"tool-execution-results-unknown-content"})]},s)})})}function Fi({results:e,copiedResult:t,serverId:n,readResource:o,onCopy:r,onMaximize:s,isMaximized:a=!1,onRerunTool:i,onWidgetHeightChange:d}){let[l,u]=Rr(0),[h,c]=Rr(!0),[m,p]=Rr(null),[x,f]=Rr("inline"),[b,g]=Rr(null),v=l0(!1),y=e[0],w=y?e.filter(z=>z.toolName===y.toolName):[],N=w[l]||w[0],T=e.findIndex(z=>z===N),L=N?N.error||lf(N.result):null,P=L??(N!=null?JSON.stringify(N.result,null,2):"");ra(()=>{w.length>0&&l>=w.length&&u(0)},[w.length,l]),ra(()=>{v.current=!1,p(null)},[y?.toolName]);let R=ro(()=>N?.args,[N?.timestamp,l]),D=ro(()=>N?.result,[N?.timestamp,N?.duration,l]),k=Oc(z=>o(z),[o]),S=Oc(z=>{let O=z.filter(H=>H.type==="text"&&"text"in H).map(H=>H.text).join(`
|
|
98
|
+
`),W=z.filter(H=>H.type==="image").length,j=z.filter(H=>H.type==="resource").length,U=[W>0&&`${W} image${W>1?"s":""}`,j>0&&`${j} resource${j>1?"s":""}`].filter(Boolean).join(", ");c0.info("Widget follow-up",{description:[O,U].filter(Boolean).join(" \u2014 "),duration:5e3})},[]),A=ro(()=>N&&u0(N.toolMeta)?"mcp-apps":null,[N]),_=ro(()=>N?.toolMeta?d0(N.toolMeta):null,[N?.toolMeta]),K=ro(()=>A==="mcp-apps"&&!!_,[A,_]),$=ro(()=>N?.result?.content||[],[N]),oe=ro(()=>_||null,[_]),ae=ro(()=>!!($&&$.length>0||N?.result?.structuredContent),[$,N]),ie=ro(()=>!K&&ae,[K,ae]),ne=ro(()=>{let z=[];return K&&_&&z.push({mode:"mcp-apps",label:"Component (MCP Apps)"}),z.push({mode:"json",label:"Raw JSON"}),z},[K,_]);return ra(()=>{if(ne.length===0)return;let z=m&&ne.some(W=>W.mode===m),O=ne.find(W=>W.mode!=="json");if(O){let W=v.current;if(v.current=!0,!m||!z||m==="json"&&!W){p(O.mode);return}}else(!m||!z)&&p("json")},[ne,m]),ra(()=>{d&&(e.length===0||m!=="mcp-apps"||x!=="inline"||!K)&&d(null)},[d,e.length,m,x,K]),e.length===0?X("div",{className:"flex flex-col h-full bg-white dark:bg-black",children:X("div",{className:"flex-1 overflow-y-auto h-full",children:X("div",{className:"flex items-center justify-center h-full",children:X("div",{className:"text-center",children:X(ms,{vertical:!0,noBorder:!0,message:"No Results yet"})})})})}):Ae("div",{className:"relative flex flex-col h-full bg-white dark:bg-black",children:[X("div",{className:"flex-1 overflow-y-auto h-full",children:Ae("div",{className:"space-y-0 flex flex-col flex-1 h-full",children:[Ae("div",{className:`sticky top-0 z-40 flex items-center gap-2 px-4 pt-2 backdrop-blur-xs bg-white/50 dark:bg-black/50 ${K||ie?"border-b border-gray-200 dark:border-zinc-600 pb-2":""}`,children:[X("h3",{className:"text-sm font-medium hidden sm:block",children:"Response"}),N.duration!==void 0&&Ae("div",{className:"hidden sm:flex items-center gap-1",children:[X(a0,{className:"h-3 w-3 text-gray-400"}),Ae("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:[N.duration,"ms"]})]}),K&&X("div",{className:"flex items-center gap-4 sm:ml-4",children:X("div",{className:"flex items-center gap-2",children:ne.map((z,O)=>Ae(i0.Fragment,{children:[O>0&&X("span",{className:"text-xs text-zinc-400",children:"|"}),X("button",{"data-testid":`tool-result-view-${z.mode}`,onClick:()=>p(z.mode),className:`text-xs font-medium ${m===z.mode?"text-black dark:text-white":"text-zinc-500 dark:text-zinc-400"}`,children:z.label})]},z.mode))})}),ie&&Ae("div",{className:"flex items-center gap-2 sm:ml-4",children:[X("button",{onClick:()=>c(!0),className:`text-xs font-medium ${h?"text-black dark:text-white":"text-zinc-500 dark:text-zinc-400"}`,children:"Formatted"}),X("span",{className:"text-xs text-zinc-400",children:"|"}),X("button",{onClick:()=>c(!1),className:`text-xs font-medium ${h?"text-zinc-500 dark:text-zinc-400":"text-black dark:text-white"}`,children:"Raw"})]}),Ae("div",{className:"ml-auto flex items-center gap-1",children:[a&&i&&Ae(E,{"data-testid":"tool-result-rerun",variant:"ghost",size:"sm",onClick:i,title:"Re-run with same arguments",children:[X(s0,{className:"h-4 w-4"}),X("span",{className:"hidden sm:inline ml-1",children:"Re-run"})]}),K&&s&&X(E,{"data-testid":"tool-result-maximize",variant:"ghost",size:"sm",onClick:s,title:a?"Restore":"Maximize",children:a?X(r0,{className:"h-4 w-4"}):X(o0,{className:"h-4 w-4"})}),w.length>1&&Ae(kn,{value:l.toString(),onValueChange:z=>u(parseInt(z)),children:[X($n,{className:"w-[140px] h-8 text-xs",leading:Ae("div",{className:"flex items-center gap-1",children:[X(af,{className:"h-3 w-3"}),X(m0,{timestamp:N.timestamp})]})}),X(Fn,{children:w.map((z,O)=>X(Wt,{value:O.toString(),children:Ae("div",{className:"flex items-center gap-2",children:[X(af,{className:"h-3 w-3"}),X("span",{children:zc(z.timestamp)}),Ae("span",{className:"text-xs text-muted-foreground",children:["(",new Date(z.timestamp).toLocaleTimeString(),")"]})]})},O))})]}),X(E,{"data-testid":`tool-result-copy-${T}`,variant:"ghost",size:"sm",onClick:()=>r(T,P),children:t===T?X(t0,{className:"h-4 w-4"}):X(n0,{className:"h-4 w-4"})})]})]}),(()=>{let z=N.error||lf(N.result);return z?Ae("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded p-3 mx-4 mt-4",children:[X("p",{className:"text-red-800 dark:text-red-300 font-medium",children:"Error:"}),X("p",{className:"text-red-700 dark:text-red-400 text-sm",children:z})]}):(()=>{if(!m)return X("div",{className:"flex items-center justify-center w-full h-[200px]",children:X(Kt,{className:"size-5"})});switch(m){case"mcp-apps":return!K||!_?X("div",{className:"px-4 pt-4",children:X("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded p-3",children:X("p",{className:"text-sm text-red-600 dark:text-red-400",children:"MCP Apps resource not available"})})}):Ae(jo,{className:"relative flex flex-1 w-full min-h-[240px] items-stretch",children:[X("div",{className:"absolute top-2 right-2 z-30 flex items-center gap-2",children:X(Hi,{toolCallId:`tool-${N.timestamp}`,displayMode:x,onDisplayModeChange:f,propsContext:"tool",resourceUri:_,toolInput:N.args,resourceAnnotations:N.toolMeta,llmConfig:null,resource:null,onPropsChange:g})}),X("div",{className:"flex min-h-0 flex-1 flex-col pt-11",children:X(Pi,{serverId:n,viewId:`tool-${N.timestamp}`,toolName:N.toolName,toolInput:R,toolOutput:D,toolMetadata:N.toolMeta,resourceUri:_,readResource:k,customProps:b||void 0,displayMode:x,onDisplayModeChange:f,onSendFollowUp:S,onWidgetHeightChange:d?W=>d(W):void 0,noWrapper:!0},`mcp-apps-${N.timestamp}`)})]});case"json":{if(ie&&h){let W=N.result?.structuredContent;return Ae("div",{className:"px-4 pt-4 space-y-4","data-testid":"tool-execution-results-content",children:[W&&Ae("div",{className:"space-y-2","data-testid":"tool-execution-results-structured-content",children:[X("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"Structured Content"}),X(wt,{data:W,filename:`structured-content-${N.toolName}-${Date.now()}.json`})]}),$&&$.length>0&&X(f0,{content:$}),!W&&(!$||$.length===0)&&X("div",{className:"text-sm text-gray-500 dark:text-gray-400","data-testid":"tool-execution-results-no-content",children:"No content to display"})]})}return X("div",{className:"px-4 pt-4",children:X(wt,{data:N.result,filename:`tool-result-${N.toolName}-${Date.now()}.json`})})}default:return null}})()})()]})}),oe&&m==="mcp-apps"&&X("div",{className:"absolute bottom-0 left-1/2 -translate-x-1/2 z-40 pointer-events-none",children:X("span",{className:"text-[11px] bg-gray-200 dark:bg-zinc-800 text-gray-500 dark:text-gray-400 px-3 py-0.5 rounded-t-xl font-mono max-w-[320px] truncate block",children:oe})})]})}import{isViewTool as g0}from"@mcp-use/client/react";import{useMemo as $i,useState as h0}from"react";import{Fragment as b0,jsx as xo,jsxs as cf}from"react/jsx-runtime";function v0({widgetId:e}){let{getWidget:t}=Vo(),o=t(e)?.modelContext;if(!o?.content?.length&&!o?.structuredContent)return null;let r=o.content?.map(s=>s.text).join(" ")??JSON.stringify(o.structuredContent).slice(0,80);return cf("div",{className:"flex items-center gap-1.5 px-3 py-1.5 text-[11px] text-muted-foreground bg-muted/30 border border-border/40 rounded-md mt-1",children:[xo("span",{className:"inline-block w-1.5 h-1.5 rounded-full bg-blue-400 shrink-0"}),xo("span",{className:"font-medium",children:"State synced to model"}),xo("span",{className:"truncate opacity-60 max-w-[300px]",children:r})]})}function Vi({toolName:e,toolArgs:t,result:n,serverId:o,readResource:r,toolMeta:s,onSendFollowUp:a,partialToolArgs:i,cancelled:d}){let l=$i(()=>`chat-tool-${e}-${Date.now()}-${Math.random().toString(36).substring(2,11)}`,[e]),[u,h]=h0("inline"),c=$i(()=>{if(!n)return null;if(typeof n=="string")try{return JSON.parse(n)}catch{return n}return n},[n]),m=g0(s),p=m?s?.ui?.resourceUri??null:null,x=$i(()=>t,[e,c]),f=$i(()=>c,[e,c]);return m&&p&&o&&r?cf(b0,{children:[xo(Pi,{serverId:o,viewId:l,toolName:e,resourceUri:p,toolInput:x,toolOutput:f,toolMetadata:s,readResource:r,displayMode:u,onDisplayModeChange:h,onSendFollowUp:a,partialToolInput:i,cancelled:d,noWrapper:!0,className:"my-4"}),xo(v0,{widgetId:l})]}):m&&!p?xo("div",{className:"flex items-center justify-center w-full h-[200px] rounded border",children:xo(Kt,{className:"size-5"})}):m&&(!o||!r)?xo("div",{className:"my-4 p-4 bg-red-50/30 dark:bg-red-950/20 border border-red-200/50 dark:border-red-800/50 rounded-lg",children:xo("p",{className:"text-sm text-red-600 dark:text-red-400",children:"Cannot render widget: Missing required props (serverId or readResource)"})}):null}import{ViewRenderer as J3,isViewTool as G3,getViewResourceUri as Y3}from"@mcp-use/client/react";import{createContext as y0,use as x0,useCallback as Pn,useState as w0}from"react";import{jsx as N0}from"react/jsx-runtime";var df=y0(void 0);function C0({children:e}){let t=typeof window<"u"?window.__MANUFACT_CHAT_URL__:void 0,n=typeof import.meta<"u"?import.meta.env?.VITE_MANUFACT_CHAT_URL:void 0,o=t?.trim()||n?.trim()||"https://cloud.manufact.com/api/v1/inspector/chat/stream",[r,s]=w0({selectedServerId:null,activeTab:"tools",selectedToolName:null,selectedPromptName:null,selectedResourceUri:null,selectedSamplingRequestId:null,selectedElicitationRequestId:null,tunnelUrl:null,isTunnelStarting:!1,isEmbedded:!1,embeddedConfig:{chatApiUrl:o,chatStreamProtocol:"data-stream",chatEnableFreeTierUpgrade:!0}}),a=Pn(v=>{s(y=>({...y,selectedServerId:v}))},[]),i=Pn(v=>{s(y=>({...y,activeTab:v}))},[]),d=Pn(v=>{s(y=>({...y,selectedToolName:v}))},[]),l=Pn(v=>{s(y=>({...y,selectedPromptName:v}))},[]),u=Pn(v=>{s(y=>({...y,selectedResourceUri:v}))},[]),h=Pn(v=>{s(y=>({...y,selectedSamplingRequestId:v}))},[]),c=Pn(v=>{s(y=>({...y,selectedElicitationRequestId:v}))},[]),m=Pn(v=>{s(y=>({...y,tunnelUrl:v}))},[]),p=Pn(v=>{s(y=>({...y,isTunnelStarting:v}))},[]),x=Pn((v,y={})=>{s(w=>({...w,isEmbedded:v,embeddedConfig:{...y,chatApiUrl:y.chatApiUrl?.trim()||o,chatStreamProtocol:y.chatStreamProtocol??"data-stream",chatEnableFreeTierUpgrade:y.chatEnableFreeTierUpgrade??!0}}))},[o]),f=Pn((v,y,w)=>{console.warn("[InspectorContext] navigateToItem called:",{serverId:v,tab:y,itemIdentifier:w}),s(N=>({...N,selectedServerId:v,activeTab:y,selectedToolName:y==="tools"&&w||null,selectedPromptName:y==="prompts"&&w||null,selectedResourceUri:y==="resources"&&w||null,selectedSamplingRequestId:y==="sampling"&&w||null,selectedElicitationRequestId:y==="elicitation"&&w||null}))},[]),b=Pn(()=>{s(v=>({...v,selectedToolName:null,selectedPromptName:null,selectedResourceUri:null,selectedSamplingRequestId:null,selectedElicitationRequestId:null}))},[]),g={...r,setSelectedServerId:a,setActiveTab:i,setSelectedToolName:d,setSelectedPromptName:l,setSelectedResourceUri:u,setSelectedSamplingRequestId:h,setSelectedElicitationRequestId:c,setTunnelUrl:m,setIsTunnelStarting:p,setEmbeddedMode:x,navigateToItem:f,clearSelection:b};return N0(df,{value:g,children:e})}function wo(){let e=x0(df);if(!e)throw new Error("useInspector must be used within InspectorProvider");return e}import{GripVerticalIcon as k0}from"lucide-react";import*as Mr from"react-resizable-panels";import{jsx as sa}from"react/jsx-runtime";var{usePanelRef:Ir}=Mr;function Qo({className:e,...t}){return sa(Mr.Group,{"data-slot":"resizable-panel-group",className:C("flex h-full w-full aria-[orientation=vertical]:flex-col",e),...t})}function hn({...e}){return sa(Mr.Panel,{"data-slot":"resizable-panel",...e})}function Xo({withHandle:e,className:t,...n}){return sa(Mr.Separator,{"data-slot":"resizable-handle",className:C("relative z-50 box-content shrink-0","focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1","before:pointer-events-none before:absolute before:bg-zinc-200 before:transition-[height,width,background-color] before:duration-200 before:ease-out dark:before:bg-zinc-700","hover:before:bg-foreground/35 dark:hover:before:bg-foreground/45","aria-[orientation=horizontal]:h-px aria-[orientation=horizontal]:w-full aria-[orientation=horizontal]:py-1.5 aria-[orientation=horizontal]:-my-1.5","aria-[orientation=horizontal]:before:inset-x-0 aria-[orientation=horizontal]:before:top-1.5 aria-[orientation=horizontal]:before:h-px","hover:aria-[orientation=horizontal]:before:h-0.5","aria-[orientation=vertical]:h-full aria-[orientation=vertical]:w-px aria-[orientation=vertical]:px-1.5 aria-[orientation=vertical]:-mx-1.5","aria-[orientation=vertical]:before:inset-y-0 aria-[orientation=vertical]:before:left-1.5 aria-[orientation=vertical]:before:w-px","hover:aria-[orientation=vertical]:before:w-0.5","[&[aria-orientation=horizontal]>div]:rotate-90",t),...n,children:e&&sa("div",{className:"pointer-events-none absolute top-1/2 left-1/2 z-10 flex h-4 w-3 -translate-x-1/2 -translate-y-1/2 items-center justify-center rounded-xs border border-zinc-200 bg-background shadow-sm dark:border-zinc-700",children:sa(k0,{className:"size-2.5 text-muted-foreground"})})})}import{AnimatePresence as lw,motion as Xc}from"motion/react";import{ChevronLeft as cw,Database as wf,Wrench as Cf}from"lucide-react";import{useCallback as bn,useEffect as Nf,useMemo as kf,useRef as Ji,useState as Mn}from"react";import{useState as S0}from"react";import{jsx as uf}from"react/jsx-runtime";function so({className:e,scrollRef:t,children:n}){let[o,r]=S0(!1);return uf("div",{ref:t,className:C("h-full overflow-y-auto overscroll-none",e),onScroll:s=>r(s.currentTarget.scrollTop>0),children:uf("div",{className:"flex min-h-full flex-col",children:n(o)})})}import{jsx as aa,jsxs as mf}from"react/jsx-runtime";function jn({id:e,isSelected:t,isFocused:n,title:o,description:r,metadata:s,onClick:a,className:i,"data-testid":d}){return aa("button",{id:e,"data-testid":d,type:"button",onClick:a,className:C("w-full text-left cursor-pointer p-2 sm:p-4 border-b dark:border-zinc-700 hover:bg-gray-50 dark:hover:bg-zinc-800/50 transition-colors group",t&&"bg-zinc-50 dark:bg-zinc-800 border-l-4 border-l-zinc-500",n&&"ring-2 ring-zinc-500 dark:ring-zinc-400 ring-inset",i),children:mf("div",{className:"flex items-start gap-2 sm:gap-3",children:[mf("div",{className:"flex-1 min-w-0",children:[aa("div",{className:"flex items-center gap-2 mb-1",children:aa("h3",{className:C("font-medium truncate font-mono text-sm"),children:o})}),r&&aa("p",{className:"text-sm text-gray-600 dark:text-gray-400 line-clamp-2",children:r})]}),s&&aa("div",{className:"flex-shrink-0 flex items-center self-center",children:s})]})})}import{forwardRef as T0}from"react";import{cva as P0}from"class-variance-authority";import{jsx as ji}from"react/jsx-runtime";var R0={gray:"#a3a3a3",red:"#ef4444",orange:"#f97316",amber:"#f59e0b",yellow:"#eab308",lime:"#84cc16",green:"#22c55e",emerald:"#10b981",teal:"#14b8a6",cyan:"#06b6d4",blue:"#3b82f6",indigo:"#6366f1",violet:"#8b5cf6",purple:"#a855f7",fuchsia:"#d946ef",pink:"#ec4899",rose:"#f43f5e"},M0=P0("inline-flex items-center font-medium whitespace-nowrap",{variants:{variant:{solid:"",outline:"border border-border text-foreground"},size:{sm:"h-5 px-2 text-[11px] gap-1",md:"h-6 px-2.5 text-[12px] gap-1.5",lg:"h-7 px-3 text-[13px] gap-1.5"}},defaultVariants:{variant:"solid",size:"md"}}),pf={default:{variant:"solid",color:"blue"},secondary:{variant:"solid",color:"green"},destructive:{variant:"solid",color:"red"},outline:{variant:"outline",color:"gray"}};function I0(e){return typeof e=="string"||typeof e=="number"}function E0({children:e}){return I0(e)?ji("span",{className:"[text-box:trim-both_cap_alphabetic]",children:e}):ji("span",{className:"inline-flex items-center gap-1",children:e})}var Jt=T0(({className:e,variant:t="solid",size:n="md",color:o,children:r,style:s,...a},i)=>{let d=t&&t in pf?pf[t]:null,l=d?.variant??t,u=o??d?.color??"gray",h=pt(),c=R0[u],p=l==="solid"?u==="gray"?{backgroundColor:"var(--accent)",color:"var(--foreground)"}:{color:"var(--foreground)",backgroundColor:`color-mix(in srgb, ${c} 15%, var(--background))`}:{};return ji("span",{ref:i,className:C(M0({variant:l,size:n}),h.item,e),style:{...p,...s},...a,children:ji(E0,{children:r})})});Jt.displayName="Badge";import{RefreshCw as D0,Search as L0}from"lucide-react";import{jsx as A0}from"react/jsx-runtime";function ps({className:e,...t}){return A0("kbd",{"data-slot":"kbd",className:C("bg-muted text-muted-foreground pointer-events-none inline-flex h-5 w-fit min-w-5 items-center justify-center gap-1 rounded-sm px-1 font-sans text-xs font-medium select-none","[&_svg:not([class*='size-'])]:size-3","[[data-slot=tooltip-content]_&]:bg-background/20 [[data-slot=tooltip-content]_&]:text-background dark:[[data-slot=tooltip-content]_&]:bg-background/10",e),...t})}import{Fragment as ff,jsx as an,jsxs as Co}from"react/jsx-runtime";var _0="h-3.5 w-3.5 shrink-0 text-muted-foreground";function Er({activeTab:e,isSearchExpanded:t,searchQuery:n,primaryTabTitle:o,secondaryTabTitle:r,primaryCount:s,secondaryCount:a,secondaryIcon:i,primaryIcon:d,searchPlaceholder:l="Search...",onSearchExpand:u,onSearchChange:h,onSearchBlur:c,onTabSwitch:m,searchInputRef:p,primaryTabName:x,onRefresh:f,isRefreshing:b=!1,isScrolled:g=!1}){let v=e===x,y=v?d:i,w=v?o:r;return Co("div",{className:`flex flex-row items-center justify-between gap-2 ${ci(g)} ${Lo}`,children:[an("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:t?an(Ge,{ref:p,placeholder:l,value:n,onChange:N=>h(N.target.value),onBlur:c,className:"h-8 border-gray-300 dark:border-zinc-600"}):Co(ff,{children:[Co("h2",{className:`${_o} flex items-center gap-1.5`,children:[an(y,{className:_0,"aria-hidden":!0}),w]}),v&&Co(ff,{children:[an(Jt,{className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",variant:"outline",children:s}),Co(ke,{children:[an(we,{render:an(E,{variant:"ghost",size:"sm",onClick:u,className:"h-8 w-8 p-0",children:an(L0,{className:"h-4 w-4"})}),nativeButton:!0}),Co(Ce,{side:"bottom",className:"flex gap-2",children:["Search",an(ps,{children:"F"})]})]}),f&&Co(ke,{children:[an(we,{render:an(E,{variant:"ghost",size:"sm",onClick:f,disabled:b,className:"h-8 w-8 p-0",children:an(D0,{className:`h-4 w-4 ${b?"animate-spin":""}`})}),nativeButton:!0}),Co(Ce,{side:"bottom",className:"flex gap-2",children:["Refresh list",an(ps,{children:"R"})]})]})]})]})}),Co(E,{variant:"ghost",size:"sm",onClick:m,className:"gap-2 flex-shrink-0",children:[an("span",{className:"hidden sm:inline",children:v?r:o}),v&&a>0&&an(Jt,{className:"bg-purple-500/20 text-purple-600 dark:text-purple-400 border-transparent",variant:"outline",children:a})]})]})}import{RefreshCw as O0,Search as z0}from"lucide-react";import{Fragment as B0,jsx as $t,jsxs as Zo}from"react/jsx-runtime";function qi({title:e,count:t,icon:n,isSearchExpanded:o,searchQuery:r,searchPlaceholder:s,onSearchExpand:a,onSearchChange:i,onSearchBlur:d,searchInputRef:l,titleTestId:u,bulkAction:h,onRefresh:c,isRefreshing:m=!1,isScrolled:p=!1}){let x=h?.icon;return Zo("div",{className:`flex flex-row items-center justify-between gap-2 ${ci(p)} ${Lo}`,children:[$t("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:o?$t(Ge,{ref:l,placeholder:s,value:r,onChange:b=>i(b.target.value),onBlur:d,className:"h-8 border-gray-300 dark:border-zinc-600"}):Zo(B0,{children:[Zo("h2",{className:`${_o} flex items-center gap-1.5`,"data-testid":u,children:[n?$t(n,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground","aria-hidden":!0}):null,e]}),$t(Jt,{className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",variant:"outline",children:t}),Zo(ke,{children:[$t(we,{render:$t(E,{variant:"ghost",size:"sm",onClick:a,className:"h-8 w-8 p-0",children:$t(z0,{className:"h-4 w-4"})}),nativeButton:!0}),Zo(Ce,{side:"bottom",className:"flex gap-2",children:["Search",$t(ps,{children:"F"})]})]}),c&&Zo(ke,{children:[$t(we,{render:$t(E,{variant:"ghost",size:"sm",onClick:c,disabled:m,className:"h-8 w-8 p-0",children:$t(O0,{className:`h-4 w-4 ${m?"animate-spin":""}`})}),nativeButton:!0}),Zo(Ce,{side:"bottom",className:"flex gap-2",children:["Refresh list",$t(ps,{children:"R"})]})]})]})}),h&&x&&$t("div",{className:"flex items-center gap-2",children:Zo(ke,{children:[$t(we,{render:$t(E,{variant:"ghost",size:"sm",onClick:h.onClick,disabled:h.disabled,className:"h-8 w-8 p-0",children:$t(x,{className:"h-4 w-4"})}),nativeButton:!0}),$t(Ce,{side:"bottom",children:h.label})]})})]})}import{AlertTriangle as Y1,Check as Q1,Loader2 as X1,XCircle as Z1}from"lucide-react";import{jsx as tA}from"react/jsx-runtime";import{Database as H0,Trash2 as U0}from"lucide-react";import{jsx as vn,jsxs as Bc}from"react/jsx-runtime";function Hc({savedRequests:e,selectedRequest:t,onLoadRequest:n,onDeleteRequest:o,focusedIndex:r}){if(e.length===0)return Bc("div",{className:"flex flex-1 flex-col items-center justify-center p-4 text-center",children:[vn(H0,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),vn("p",{className:"text-gray-500 dark:text-gray-400 mb-2",children:"No saved requests yet"}),vn("p",{className:"text-xs text-gray-400 dark:text-gray-500",children:"Execute a tool and click Save to store requests"})]});let s=(a,i)=>{a.stopPropagation(),i()};return vn("div",{children:e.map((a,i)=>Bc("div",{className:"relative group",children:[vn(jn,{id:`saved-${a.id}`,isSelected:t?.id===a.id,isFocused:r===i,title:a.name,description:a.toolName,metadata:vn("div",{className:"flex flex-col gap-1",children:vn("span",{className:"text-xs text-gray-400 dark:text-gray-500",children:new Date(a.savedAt).toLocaleString()})}),onClick:()=>n(a)}),vn("div",{className:"absolute top-1/2 right-2 -translate-y-1/2 opacity-0 group-hover:opacity-100 transition-opacity z-10",children:Bc(ke,{children:[vn(we,{render:vn(E,{variant:"secondary",size:"sm",onClick:d=>s(d,()=>o(a.id)),className:"h-8 w-8 p-0",children:vn(U0,{className:"h-4 w-4"})}),nativeButton:!0}),vn(Ce,{children:vn("p",{children:"Delete saved request"})})]})})]},a.id))})}import{Save as F0}from"lucide-react";import{jsx as fs,jsxs as ia}from"react/jsx-runtime";function Uc({isOpen:e,requestName:t,defaultPlaceholder:n,onRequestNameChange:o,onSave:r,onCancel:s}){return e?fs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:s,children:ia("div",{className:"bg-white dark:bg-zinc-800 rounded-lg p-6 w-[400px] shadow-xl border border-gray-200 dark:border-zinc-700",onClick:a=>a.stopPropagation(),children:[fs("h3",{className:"text-lg font-semibold mb-4 text-gray-900 dark:text-gray-100",children:"Save Request"}),ia("div",{className:"space-y-4",children:[ia("div",{children:[fs(nt,{htmlFor:"request-name",children:"Request Name (optional)"}),fs(Ge,{id:"request-name",value:t,onChange:a=>o(a.target.value),placeholder:n,className:"mt-2",onKeyDown:a=>{a.key==="Enter"&&r()},autoFocus:!0})]}),ia("div",{className:"flex justify-end gap-2",children:[fs(E,{variant:"outline",onClick:s,children:"Cancel"}),ia(E,{onClick:r,children:[fs(F0,{className:"h-4 w-4 mr-2"}),"Save"]})]})]})]})}):null}import{Check as $0,ChevronDown as V0,ChevronUp as j0,Code as q0,Copy as W0,Play as K0,Save as J0,X as G0}from"lucide-react";import{useEffect as gf,useRef as Y0,useState as la}from"react";import{Fragment as gs,jsx as ye,jsxs as Pt}from"react/jsx-runtime";function Fc({selectedTool:e,toolArgs:t,payloadToSend:n,isExecuting:o,isConnected:r,onArgChange:s,onExecute:a,onSave:i,onCancel:d,onBulkPaste:l,autoFilledFields:u,setFields:h,sendEmptyFields:c,onToggleEmpty:m}){let p="hidden @[700px]/tool-exec:inline",x="hidden @[700px]/tool-exec:inline shrink-0 text-[10px] leading-none border border-current/30 p-1 rounded-full",f="@max-[699px]/tool-exec:size-8 @max-[699px]/tool-exec:min-w-8 @max-[699px]/tool-exec:shrink-0 @max-[699px]/tool-exec:gap-0 @max-[699px]/tool-exec:rounded-full @max-[699px]/tool-exec:!px-0 @max-[699px]/tool-exec:!py-0",b="@max-[699px]/tool-exec:!pr-0",[g,v]=la(!1),[y,w]=la(!1),[N,T]=la(!1),[L,P]=la(!1),[R,D]=la(!1),k=Y0(null);gf(()=>{if(k.current&&e?.description){let _=k.current,K=parseFloat(getComputedStyle(_).lineHeight),$=_.scrollHeight,oe=Math.round($/K);D(oe>3),P(!1)}},[e?.description]);let S=async()=>{e&&await Xe(JSON.stringify(e,null,2))},A=async()=>{if(e)try{await Xe(JSON.stringify(n??t,null,2)),T(!0),setTimeout(()=>T(!1),2e3)}catch{}};return gf(()=>{let _=K=>{(K.metaKey||K.ctrlKey)&&K.key==="Enter"&&e&&!o&&r&&(K.preventDefault(),a()),K.key==="Escape"&&o&&d&&(K.preventDefault(),d())};return document.addEventListener("keydown",_),()=>document.removeEventListener("keydown",_)},[e,o,r,a,d]),e?Pt("div",{className:"flex flex-col h-full @container/tool-exec",children:[ye("div",{className:"shrink-0 p-3 sm:p-5 pt-3 sm:pt-4 pb-2 sm:pb-2 sm:pr-4",children:ye("div",{children:Pt("div",{className:"flex flex-row items-center justify-between mb-0 gap-2",children:[ye("h3",{className:"text-base sm:text-lg font-semibold","data-testid":"tool-execution-title",children:e.name}),Pt("div",{className:"flex gap-2 shrink-0",children:[Pt(ke,{children:[ye(we,{render:Pt(E,{"data-testid":"tool-execution-metadata-button",variant:y?"default":"outline",onClick:()=>w(!y),disabled:o,size:"sm",className:C(vr,f),title:"View tool metadata",children:[ye(q0,{}),ye("span",{className:p,children:"Metadata"})]}),nativeButton:!0}),ye(Ce,{children:ye("p",{children:"View tool definition metadata"})})]}),Pt(ke,{children:[ye(we,{render:Pt(E,{"data-testid":"tool-execution-copy-payload-button",variant:"outline",onClick:A,disabled:o,size:"sm",className:C(vr,f),title:"Copy payload as JSON",children:[N?ye($0,{className:"text-green-600"}):ye(W0,{}),ye("span",{className:p,children:N?"Copied!":"Payload"})]}),nativeButton:!0}),ye(Ce,{children:ye("p",{children:"Copy payload as JSON"})})]}),Pt(ke,{children:[ye(we,{render:Pt(E,{"data-testid":"tool-execution-save-button",variant:"outline",onClick:i,disabled:o,size:"sm",className:C(vr,f),title:"Save request",children:[ye(J0,{}),ye("span",{className:p,children:"Save"})]}),nativeButton:!0}),ye(Ce,{children:ye("p",{children:"Save request"})})]}),o&&d?Pt(ke,{open:g?void 0:!1,children:[ye(we,{render:ye("div",{onMouseEnter:()=>v(!0),onMouseLeave:()=>v(!1),className:"relative",children:ye(E,{"data-testid":"tool-execution-cancel-button",onClick:d,variant:g?"destructive":"default",size:"sm",className:C(js,f,b,"transition-all"),children:g?Pt(gs,{children:[ye(G0,{}),ye("span",{className:p,children:"Cancel"}),ye("span",{className:x,children:"Esc"})]}):Pt(gs,{children:[ye(Kt,{}),ye("span",{className:p,children:"Executing..."})]})})}),nativeButton:!1}),ye(Ce,{children:ye("p",{children:"Hover to cancel (or press Esc)"})})]}):ye(E,{"data-testid":"tool-execution-execute-button",onClick:a,disabled:o||!r,size:"sm",className:C(js,f,b),children:o?Pt(gs,{children:[ye(Kt,{}),ye("span",{className:p,children:"Executing..."})]}):Pt(gs,{children:[ye(K0,{}),ye("span",{className:p,children:"Execute"}),ye("span",{className:x,children:"\u2318\u21B5"})]})})]})]})})}),Pt("div",{className:"flex-1 overflow-y-auto px-3 sm:px-5 pb-4 pr-3",children:[e.description&&Pt("div",{className:"relative mb-6",children:[Pt("div",{className:"relative",children:[ye("p",{ref:k,"data-testid":"tool-execution-description",className:`text-sm text-gray-600 dark:text-gray-400 leading-relaxed transition-all duration-300 ${!L&&R?"line-clamp-3":""}`,children:e.description}),R&&!L&&ye("div",{className:"absolute bottom-0 left-0 right-0 h-[1.4em] bg-linear-to-t from-white/95 dark:from-black/95 via-white/55 dark:via-black/55 to-transparent pointer-events-none"})]}),R&&ye("div",{className:"flex justify-end",children:ye("button",{onClick:()=>P(!L),className:"relative z-10 inline-flex items-center gap-1 text-xs text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 mt-1 transition-colors",children:L?Pt(gs,{children:["Show less",ye(j0,{className:"h-3 w-3"})]}):Pt(gs,{children:["Show more",ye(V0,{className:"h-3 w-3"})]})})})]}),ye(xc,{selectedTool:e,toolArgs:t,onArgChange:s,onBulkPaste:l,autoFilledFields:u,setFields:h,sendEmptyFields:c,onToggleEmpty:m})]}),ye(fn,{open:y,onOpenChange:w,children:Pt(on,{scrollable:!0,className:"max-w-3xl max-h-[80vh]",children:[ye(Qt,{sticky:!0,children:ye(qt,{children:"Tool Definition"})}),ye(Hn,{children:ye(ii,{onCopy:S,children:ye(wt,{data:e,filename:`tool-definition-${e.name}-${Date.now()}.json`})})})]})})]}):Pt("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[ye("p",{className:"text-gray-500 dark:text-gray-400 mb-2",children:"Select a tool to get started"}),ye("p",{className:"text-xs text-gray-400 dark:text-gray-500",children:"Choose a tool from the list to view its details and execute it"})]})}import{PanelsTopLeft as Q0,Wrench as X0}from"lucide-react";import{isViewTool as Z0}from"@mcp-use/client/react";import{jsx as No,jsxs as Wi}from"react/jsx-runtime";function $c({tools:e,selectedTool:t,onToolSelect:n,focusedIndex:o}){if(e.length===0)return Wi("div",{className:"flex flex-1 flex-col items-center justify-center p-4 text-center",children:[No(X0,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),No("p",{className:"text-gray-500 dark:text-gray-400",children:"No tools available"})]});let r=e.some(s=>s.inputSchema?.properties&&Object.keys(s.inputSchema.properties).length>0);return No("div",{children:e.map((s,a)=>{let i=s._meta,d=Z0(i)?"mcp-apps":null,l=s.inputSchema?.properties,u=l?Object.keys(l).length:0,h=r&&u>0&&Wi(Jt,{variant:"outline",className:"text-xs border-gray-300 dark:border-zinc-600 text-gray-600 dark:text-gray-400",children:[u," params"]}),m=d==="mcp-apps"||h?Wi("div",{className:"flex items-center gap-1.5",children:[d==="mcp-apps"&&Wi(ke,{children:[No(we,{render:No("span",{className:"inline-flex",children:No(Q0,{className:"h-3.5 w-3.5"})}),nativeButton:!1}),No(Ce,{children:No("p",{children:"UI widget"})})]}),h]}):void 0;return No(jn,{id:`tool-${s.name}`,"data-testid":`tool-item-${s.name}`,isSelected:t?.name===s.name,isFocused:o===a,title:s.name,description:s.description,metadata:m,onClick:()=>n(s)},s.name)})})}import{AlertDialog as Ar}from"@base-ui/react/alert-dialog";import{jsx as Rn,jsxs as nw}from"react/jsx-runtime";function Vc({...e}){return Rn(Ar.Root,{"data-slot":"alert-dialog",...e})}function ew({...e}){return Rn(Ar.Portal,{"data-slot":"alert-dialog-portal",...e})}function tw({className:e,...t}){return Rn(Ar.Backdrop,{"data-slot":"alert-dialog-overlay",className:C("fixed inset-0 isolate z-50 bg-black/50 duration-100 data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0",e),...t})}function jc({className:e,size:t="default",...n}){return nw(ew,{children:[Rn(tw,{}),Rn(Ar.Popup,{"data-slot":"alert-dialog-content","data-size":t,className:C("group/alert-dialog-content fixed top-1/2 left-1/2 z-50 grid w-full -translate-x-1/2 -translate-y-1/2 gap-6 rounded-xl bg-popover p-6 text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none data-[size=default]:max-w-xs data-[size=sm]:max-w-xs data-[size=default]:sm:max-w-lg data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",e),...n})]})}function qc({className:e,...t}){return Rn("div",{"data-slot":"alert-dialog-header",className:C("grid grid-rows-[auto_1fr] place-items-center gap-1.5 text-center has-data-[slot=alert-dialog-media]:grid-rows-[auto_auto_1fr] has-data-[slot=alert-dialog-media]:gap-x-6 sm:group-data-[size=default]/alert-dialog-content:place-items-start sm:group-data-[size=default]/alert-dialog-content:text-left sm:group-data-[size=default]/alert-dialog-content:has-data-[slot=alert-dialog-media]:grid-rows-[auto_1fr]",e),...t})}function Wc({className:e,...t}){return Rn("div",{"data-slot":"alert-dialog-footer",className:C("flex flex-col-reverse gap-2 group-data-[size=sm]/alert-dialog-content:grid group-data-[size=sm]/alert-dialog-content:grid-cols-2 sm:flex-row sm:justify-end",e),...t})}function Kc({className:e,...t}){return Rn(Ar.Title,{"data-slot":"alert-dialog-title",className:C("text-lg font-medium sm:group-data-[size=default]/alert-dialog-content:group-has-data-[slot=alert-dialog-media]/alert-dialog-content:col-start-2",e),...t})}function Jc({className:e,...t}){return Rn(Ar.Description,{"data-slot":"alert-dialog-description",className:C("text-sm text-balance text-muted-foreground md:text-pretty *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground",e),...t})}function Gc({className:e,...t}){return Rn(E,{"data-slot":"alert-dialog-action",className:C(e),...t})}function Yc({className:e,variant:t="outline",size:n="default",...o}){return Rn(Ar.Close,{"data-slot":"alert-dialog-cancel",className:C(e),render:Rn(E,{variant:t,size:n}),...o})}import{useCallback as ow,useEffect as hf,useState as rw}from"react";var Qc="mcp-inspector-saved-requests";function vf(){let[e,t]=rw([]);hf(()=>{try{let o=localStorage.getItem(Qc);o&&t(JSON.parse(o))}catch(o){console.error("[useSavedRequests] Failed to load saved requests:",o)}},[]),hf(()=>{let o=r=>{if(r.key===Qc&&r.newValue)try{t(JSON.parse(r.newValue))}catch(s){console.error("[useSavedRequests] Failed to parse saved requests:",s)}};return window.addEventListener("storage",o),()=>window.removeEventListener("storage",o)},[]);let n=ow(o=>{try{localStorage.setItem(Qc,JSON.stringify(o)),t(o)}catch(r){console.error("[useSavedRequests] Failed to save requests:",r)}},[]);return{savedRequests:e,saveSavedRequests:n}}import{useCallback as ca,useMemo as sw,useState as Ki}from"react";function bf({selectedTool:e,payloadToSend:t,toolArgs:n,callTool:o,readResource:r,serverId:s}){let[a,i]=Ki([]),[d,l]=Ki(!1),[u,h]=Ki(null),[c,m]=Ki(null),p=ca(async()=>{if(!e||d)return;let y=new AbortController;m(y),l(!0);let w=Date.now();try{let N=t,T=e?._meta||e?.metadata,P=T?.ui?.resourceUri;if(P&&typeof P=="string"){try{await r(P)}catch{}i([{toolName:e.name,args:N,result:null,timestamp:w,duration:0,toolMeta:T}])}let R=await o(e.name,N,{timeout:6e5,resetTimeoutOnProgress:!0,signal:y.signal}),D=Date.now()-w,k=R?._meta??T;Lt(new Hs({toolName:e.name,serverId:s,success:!0,duration:D})).catch(()=>{}),window.dispatchEvent(new Event("mcp-tool-executed")),i(P&&typeof P=="string"?S=>S.map((A,_)=>_===0?{...A,result:R,duration:D,toolMeta:k}:A):S=>[{toolName:e.name,args:n,result:R,timestamp:w,duration:D,toolMeta:k},...S])}catch(N){let T=Date.now()-w;Lt(new Hs({toolName:e.name,serverId:s,success:!1,duration:T,error:N instanceof Error?N.message:String(N)})).catch(()=>{}),window.dispatchEvent(new Event("mcp-tool-executed"));let L=e?._meta||e?.metadata,P={toolName:e.name,args:n,result:null,error:N instanceof Error?N.message:String(N),timestamp:w,duration:T,toolMeta:L},R=L?.ui?.resourceUri;i(R?[P]:D=>[P,...D])}finally{l(!1)}},[e,t,n,d,o,r,s]),x=ca(async(y,w)=>{try{await Xe(w),h(y),setTimeout(()=>h(null),2e3)}catch(N){console.error("[ToolsTab] Failed to copy result:",N)}},[]),f=ca(y=>{i(w=>w.filter((N,T)=>T!==y))},[]),b=sw(()=>e?a.filter(y=>y.toolName===e.name):[],[a,e]),g=ca(y=>{let w=b[y];if(!w)return;let N=window.open("","_blank","width=800,height=600");N&&(N.document.write(`
|
|
99
99
|
<html>
|
|
100
100
|
<head><title>${w.toolName} Result</title></head>
|
|
101
101
|
<body><pre>${JSON.stringify(w.result,null,2)}</pre></body>
|
|
102
102
|
</html>
|
|
103
|
-
`),N.document.close())},[b]),v=ca(()=>{c?.abort(),m(null),l(!1)},[c]);return{results:a,setResults:i,isExecuting:d,copiedResult:u,executeTool:p,handleCopyResult:x,handleDeleteResult:f,handleFullscreen:g,filteredResults:b,cancelExecution:v}}import{useCallback as wf,useEffect as ko,useImperativeHandle as iw,useRef as lw,useState as da}from"react";function Cf({ref:e,activeTab:t,filteredTools:n,savedRequests:o,searchQuery:r,setSearchQuery:s,selectedTool:a,results:i,isExecuting:d,handleToolSelect:l,loadSavedRequest:u,refreshTools:h,selectedToolName:c,tools:m,setSelectedToolName:p}){let[x,f]=da(!1),[b,g]=da(-1),v=lw(null),[y,w]=da(!1),[N,T]=da("list"),[L,P]=da(!1);ko(()=>{let k=()=>w(window.innerWidth<1024);return k(),window.addEventListener("resize",k),()=>window.removeEventListener("resize",k)},[]),ko(()=>{T(a?"detail":"list")},[a]),ko(()=>{if(!y||i.length===0)return;let k=i[0];(!d||k?.result===null)&&T("response")},[i,d,y]),iw(e,()=>({focusSearch:()=>{f(!0),setTimeout(()=>v.current?.focus(),0)},blurSearch:()=>{s(""),f(!1),v.current?.blur()}})),ko(()=>{x&&v.current?.focus()},[x]);let R=wf(()=>{r.trim()||f(!1)},[r]),D=wf(async()=>{if(h){P(!0);try{await h()}finally{P(!1)}}},[h]);return ko(()=>{t!=="tools"&&f(!1)},[t]),ko(()=>{g(-1)},[r,t]),ko(()=>{let k=S=>{let A=S.target;if(A.tagName==="INPUT"||A.tagName==="TEXTAREA"||A.contentEditable==="true"||S.metaKey||S.ctrlKey||S.altKey)return;let K=t==="tools"?n:o;if(S.key==="ArrowDown")S.preventDefault(),g($=>$+1>=K.length?0:$+1);else if(S.key==="ArrowUp")S.preventDefault(),g($=>$-1<0?K.length-1:$-1);else if(S.key==="Enter"&&b>=0)if(S.preventDefault(),t==="tools"){let $=n[b];$&&l($)}else{let $=o[b];$&&u($)}};return document.addEventListener("keydown",k),()=>document.removeEventListener("keydown",k)},[b,n,o,t,l,u]),ko(()=>{if(b>=0){let k=t==="tools"?`tool-${n[b]?.name}`:`saved-${o[b]?.id}`;document.getElementById(k)?.scrollIntoView({behavior:"smooth",block:"nearest"})}},[b,n,o,t]),ko(()=>{if(!c||m.length===0)return;let k=m.find(S=>S.name===c);if(k){p(null);let S=setTimeout(()=>{l(k),document.getElementById(`tool-${k.name}`)?.scrollIntoView({behavior:"smooth",block:"nearest"})},100);return()=>clearTimeout(S)}},[c,m,l,p]),{isSearchExpanded:x,setIsSearchExpanded:f,focusedIndex:b,searchInputRef:v,isMobile:y,mobileView:N,setMobileView:T,isRefreshing:L,handleSearchBlur:R,handleRefresh:D}}import{Fragment as Gi,jsx as be,jsxs as rt}from"react/jsx-runtime";var Pf=200,uw=140;function Rf({ref:e,tools:t,callTool:n,readResource:o,serverId:r,isConnected:s,refreshTools:a}){let[i,d]=Mn(null),[l,u]=Mn(null),{selectedToolName:h,setSelectedToolName:c}=wo(),[m,p]=Mn({}),[x,f]=Mn(new Set),[b,g]=Mn(new Set),[v,y]=Mn(""),[w,N]=Mn("tools"),{savedRequests:T,saveSavedRequests:L}=yf(),[P,R]=Mn(!1),[D,k]=Mn(""),[S,A]=Mn(!1),[_,K]=Mn({open:!1,parsedObject:{},fieldsToUpdate:[],newFields:[],resolve:null}),[$,oe]=Mn(new Set),ae=Ir(),ie=Ir(),ne=Ir(),z=Ji(null),O=Ji(!1),W=Ji(!1),j=Ji(!0),U=bn(()=>{S?(ae.current&&ae.current.expand(),ie.current&&ie.current.expand(),A(!1)):(ae.current&&ae.current.collapse(),ie.current&&ie.current.collapse(),A(!0))},[S,ae,ie]),H=Tf(()=>{if(!v.trim())return t;let Q=v.toLowerCase();return t.filter(ee=>ee.name.toLowerCase().includes(Q)||ee.description?.toLowerCase().includes(Q))},[t,v]),Te=bn(Q=>{d(Q);let ee={},me=new Set;Q.inputSchema?.properties&&Object.entries(Q.inputSchema.properties).forEach(([xe,he])=>{let et=he;et.default!==void 0&&(ee[xe]=et.default,me.add(xe))}),p(ee),f(me),g(new Set)},[]),Pe=bn(Q=>{let ee=t.find(me=>me.name===Q.toolName);ee&&(d(ee),p(Q.args),f(new Set(Object.keys(Q.args))),g(new Set),u(Q))},[t]);Sf(()=>{if(i){let Q=t.find(ee=>ee.name===i.name);Q?Q!==i&&(JSON.stringify(Q.inputSchema)!==JSON.stringify(i.inputSchema)||Q.description!==i.description||JSON.stringify(Q?._meta)!==JSON.stringify(i?._meta))&&d(Q):(d(null),c(null))}},[t,i,c]);let le=bn((Q,ee)=>{let me=i?.inputSchema||{},xe=i?.inputSchema?.properties?.[Q],he=xe?Ci(xe,me):"string",et;he==="object"||he==="array"||he==="string"?et=ee:et=Gm(ee,he),p(Dt=>({...Dt,[Q]:et}));let Yt=String(ee).trim()==="";f(Dt=>{let vt=new Set(Dt);return Yt?vt.delete(Q):vt.add(Q),vt}),g(Dt=>{let vt=new Set(Dt);return vt.delete(Q),vt})},[i]),de=bn((Q,ee,me)=>{if(me){let xe=ee==="array"?"[]":ee==="object"?"{}":"";p(he=>({...he,[Q]:xe})),f(he=>new Set(he).add(Q)),g(he=>new Set(he).add(Q))}else g(xe=>{let he=new Set(xe);return he.delete(Q),he}),f(xe=>{let he=new Set(xe);return he.delete(Q),he})},[]),De=bn(async(Q,ee)=>{if(!i)return!1;let me=Qm(Q);if(!me)return!1;let xe=i.inputSchema?.properties||{},he=Object.keys(xe),et=i.inputSchema||{},ht=[],Yt=[];return Object.entries(me).forEach(([Dt,vt])=>{if(he.includes(Dt)){let Kr=xe[Dt],po=Ci(Kr,et),kt=vt;po==="object"||po==="array"?typeof vt=="object"&&vt!==null?kt=JSON.stringify(vt,null,2):typeof vt=="string"&&(kt=vt):typeof vt=="object"&&vt!==null?kt=JSON.stringify(vt):kt=String(vt);let He=m[Dt];He!=null&&He!==""?ht.push({key:Dt,oldValue:He,newValue:kt}):(Yt.push(Dt),le(Dt,String(kt)))}}),ht.length===0&&Yt.length===0?!1:ht.length===0?(oe(new Set(Yt)),setTimeout(()=>oe(new Set),2e3),!0):new Promise(Dt=>{K({open:!0,parsedObject:me,fieldsToUpdate:ht,newFields:Yt,resolve:Dt})})},[i,m,le]),Re=bn(()=>{if(!_.resolve)return;_.fieldsToUpdate.forEach(({key:ee,newValue:me})=>{le(ee,String(me))});let Q=[..._.fieldsToUpdate.map(ee=>ee.key),..._.newFields];oe(new Set(Q)),setTimeout(()=>oe(new Set),2e3),_.resolve(!0),K({open:!1,parsedObject:{},fieldsToUpdate:[],newFields:[],resolve:null})},[_,le]),Oe=bn(()=>{_.resolve&&(_.resolve(!1),K({open:!1,parsedObject:{},fieldsToUpdate:[],newFields:[],resolve:null}))},[_]),Be=Tf(()=>{if(!i?.inputSchema?.properties)return{};let Q=i.inputSchema||{},ee={};for(let me of x){let xe=i.inputSchema.properties[me];if(!xe)continue;let he=Ci(xe,Q),et=b.has(me)?he==="array"?"[]":he==="object"?"{}":"":m[me];ee[me]=Ym(et,he)}return ee},[i,m,x,b]),{isExecuting:tt,copiedResult:V,executeTool:ce,handleCopyResult:Fe,handleDeleteResult:Y,handleFullscreen:q,filteredResults:M,cancelExecution:Ne,results:gt}=xf({selectedTool:i,payloadToSend:Be,toolArgs:m,callTool:n,readResource:o,serverId:r}),qe=M[0]?.timestamp;Sf(()=>{O.current=!1,j.current=!0;let Q=requestAnimationFrame(()=>{j.current=!1});return()=>cancelAnimationFrame(Q)},[qe]);let ut=bn(()=>{W.current||j.current||(O.current=!0)},[]),Bt=bn(Q=>{if(Q===null||S||O.current)return;let ee=ne.current,me=z.current;if(!ee||!me)return;let xe=me.offsetHeight;if(xe<=0)return;let he=ee.getSize().inPixels,et=Q+uw,ht=xe-Pf;if(et<=he||ht<=he)return;let Yt=Math.min(et,ht);Yt<=he||(W.current=!0,ee.resize(Yt),requestAnimationFrame(()=>{W.current=!1}))},[S,ne]),{isSearchExpanded:It,setIsSearchExpanded:wn,focusedIndex:mn,searchInputRef:mo,isMobile:zn,mobileView:Nt,setMobileView:at,isRefreshing:re,handleSearchBlur:pe,handleRefresh:Ze}=Cf({ref:e,activeTab:w,filteredTools:H,savedRequests:T,searchQuery:v,setSearchQuery:y,selectedTool:i,results:gt,isExecuting:tt,handleToolSelect:Te,loadSavedRequest:Pe,refreshTools:a,selectedToolName:h,tools:t,setSelectedToolName:c}),We=bn(()=>{i&&(k(""),R(!0))},[i]),J=bn(()=>{if(!i)return;let Q={id:`${Date.now()}-${Math.random()}`,name:D.trim()||`${i.name} - ${new Date().toLocaleString()}`,toolName:i.name,args:Be,savedAt:Date.now(),serverId:i._serverId,serverName:i._serverName};L([...T,Q]),Lt(new Xa({toolName:i.name,serverId:r})).catch(()=>{}),R(!1),k("")},[i,D,Be,T,L,r]),$e=bn(Q=>{L(T.filter(ee=>ee.id!==Q)),l?.id===Q&&u(null)},[T,L,l]);return zn?rt("div",{className:"h-full flex flex-col overflow-hidden relative bg-background",children:[Nt!=="list"&&rt("div",{className:"flex items-center gap-2 p-2 border-b shrink-0 bg-background z-10",children:[be(E,{variant:"ghost",size:"sm",onClick:()=>{Nt==="response"?at("detail"):(d(null),at("list"))},className:"p-0 h-8 w-8",children:be(dw,{className:"h-4 w-4"})}),rt("div",{className:"flex items-center text-sm font-medium",children:[be("button",{onClick:()=>{d(null),at("list")},className:"text-muted-foreground hover:text-foreground hover:underline cursor-pointer",children:"Tools"}),Nt==="detail"&&rt(Gi,{children:[be("span",{className:"mx-2 text-muted-foreground",children:"/"}),be("button",{onClick:()=>{at("response")},className:Nt==="detail"?"text-foreground hover:underline":Nt==="response"?"text-muted-foreground hover:text-foreground hover:underline cursor-pointer":"text-muted-foreground",children:"Execute"})]}),Nt==="response"&&rt(Gi,{children:[be("span",{className:"mx-2 text-muted-foreground",children:"/"}),be("span",{className:"text-foreground",children:"Response"})]})]})]}),be("div",{className:"flex-1 relative overflow-hidden",children:rt(cw,{initial:!1,mode:"popLayout",children:[Nt==="list"&&be(Xc.div,{initial:{x:"-100%"},animate:{x:0},exit:{x:"-100%"},transition:{type:"spring",stiffness:300,damping:30},className:"absolute inset-0 flex flex-col bg-background z-0",children:be(ao,{children:Q=>rt(Gi,{children:[be(Er,{isScrolled:Q,activeTab:w,isSearchExpanded:It,searchQuery:v,primaryTabName:"tools",secondaryTabName:"saved",primaryTabTitle:"Tools",secondaryTabTitle:"Saved",primaryCount:H.length,secondaryCount:T.length,primaryIcon:kf,secondaryIcon:Nf,searchPlaceholder:"Search tools...",onSearchExpand:()=>wn(!0),onSearchChange:y,onSearchBlur:pe,onTabSwitch:()=>N(w==="tools"?"saved":"tools"),searchInputRef:mo,onRefresh:a?Ze:void 0,isRefreshing:re}),w==="tools"?be($c,{tools:H,selectedTool:i,onToolSelect:Te,focusedIndex:mn}):be(Hc,{savedRequests:T,selectedRequest:l,onLoadRequest:Pe,onDeleteRequest:$e,focusedIndex:mn})]})})},"list"),Nt==="detail"&&be(Xc.div,{initial:{x:"100%"},animate:{x:0},exit:{x:"-100%"},transition:{type:"spring",stiffness:300,damping:30},className:"absolute inset-0 bg-background z-10",children:be(Fc,{selectedTool:i,toolArgs:m,payloadToSend:Be,isExecuting:tt,isConnected:s,onArgChange:le,onExecute:ce,onSave:We,onBulkPaste:De,autoFilledFields:$,setFields:x,sendEmptyFields:b,onToggleEmpty:de})},"detail"),Nt==="response"&&be(Xc.div,{initial:{x:"100%"},animate:{x:0},exit:{x:"100%"},transition:{type:"spring",stiffness:300,damping:30},className:"absolute inset-0 bg-background z-20",children:be(Fi,{results:M,copiedResult:V,serverId:r,readResource:o,onCopy:Fe,onDelete:Y,onFullscreen:q,onRerunTool:ce})},"response")]})}),be(Uc,{isOpen:P,requestName:D,defaultPlaceholder:`${i?.name} - ${new Date().toLocaleString()}`,onRequestNameChange:k,onSave:J,onCancel:()=>R(!1)}),be(Vc,{open:_.open,onOpenChange:Q=>{Q||Oe()},children:rt(jc,{children:[rt(qc,{children:[be(Kc,{children:"Auto-fill fields from pasted object?"}),rt(Jc,{children:[_.fieldsToUpdate.length>0&&rt("div",{className:"mb-3",children:[be("p",{className:"font-medium mb-2",children:"The following fields will be updated:"}),be("ul",{className:"text-sm space-y-1 max-h-[200px] overflow-y-auto",children:_.fieldsToUpdate.map(({key:Q,oldValue:ee,newValue:me})=>rt("li",{className:"font-mono",children:[rt("span",{className:"font-semibold",children:[Q,":"]})," ",be("span",{className:"text-red-600 dark:text-red-400 line-through",children:typeof ee=="object"?JSON.stringify(ee).substring(0,30)+"...":String(ee).substring(0,30)})," ","\u2192"," ",be("span",{className:"text-green-600 dark:text-green-400",children:typeof me=="string"&&me.length>30?me.substring(0,30)+"...":String(me).substring(0,30)})]},Q))})]}),_.newFields.length>0&&rt("div",{children:[be("p",{className:"font-medium mb-1",children:"New fields to be filled:"}),be("p",{className:"text-sm font-mono",children:_.newFields.join(", ")})]})]})]}),rt(Wc,{children:[be(Yc,{onClick:Oe,children:"Cancel"}),be(Gc,{onClick:Re,children:"Auto-fill"})]})]})})]}):rt(Qo,{orientation:"horizontal",className:"h-full",children:[be(hn,{id:"left-panel",defaultSize:"33%",minSize:250,collapsedSize:0,collapsible:!0,className:"flex flex-col h-full relative",panelRef:ae,children:be("div",{className:"flex h-full flex-col overflow-hidden",children:be(ao,{children:Q=>rt(Gi,{children:[be(Er,{isScrolled:Q,activeTab:w,isSearchExpanded:It,searchQuery:v,primaryTabName:"tools",secondaryTabName:"saved",primaryTabTitle:"Tools",secondaryTabTitle:"Saved",primaryCount:H.length,secondaryCount:T.length,primaryIcon:kf,secondaryIcon:Nf,searchPlaceholder:"Search tools...",onSearchExpand:()=>wn(!0),onSearchChange:y,onSearchBlur:pe,onTabSwitch:()=>N(w==="tools"?"saved":"tools"),searchInputRef:mo,onRefresh:a?Ze:void 0,isRefreshing:re}),w==="tools"?be($c,{tools:H,selectedTool:i,onToolSelect:Te,focusedIndex:mn}):be(Hc,{savedRequests:T,selectedRequest:l,onLoadRequest:Pe,onDeleteRequest:$e,focusedIndex:mn})]})})})}),be(Xo,{withHandle:!0}),be(hn,{defaultSize:"67%",children:rt(Qo,{orientation:"vertical",elementRef:z,onLayoutChanged:ut,children:[be(hn,{id:"tool-params",defaultSize:"40%",minSize:`${Pf}px`,collapsible:!0,panelRef:ie,children:be(Fc,{selectedTool:i,toolArgs:m,payloadToSend:Be,isExecuting:tt,isConnected:s,onArgChange:le,onExecute:ce,onSave:We,onCancel:Ne,onBulkPaste:De,autoFilledFields:$,setFields:x,sendEmptyFields:b,onToggleEmpty:de})}),be(Xo,{withHandle:!0}),be(hn,{id:"tool-result",defaultSize:"60%",panelRef:ne,children:be("div",{className:"flex flex-col h-full",children:be(Fi,{results:M,copiedResult:V,serverId:r,readResource:o,onCopy:Fe,onDelete:Y,onFullscreen:q,onMaximize:U,isMaximized:S,onRerunTool:ce,onWidgetHeightChange:Bt})})})]})}),be(Uc,{isOpen:P,requestName:D,defaultPlaceholder:`${i?.name} - ${new Date().toLocaleString()}`,onRequestNameChange:k,onSave:J,onCancel:()=>R(!1)}),be(Vc,{open:_.open,onOpenChange:Q=>{Q||Oe()},children:rt(jc,{children:[rt(qc,{children:[be(Kc,{children:"Auto-fill fields from pasted object?"}),rt(Jc,{children:[_.fieldsToUpdate.length>0&&rt("div",{className:"mb-3",children:[be("p",{className:"font-medium mb-2",children:"The following fields will be updated:"}),be("ul",{className:"text-sm space-y-1 max-h-[200px] overflow-y-auto",children:_.fieldsToUpdate.map(({key:Q,oldValue:ee,newValue:me})=>rt("li",{className:"font-mono",children:[rt("span",{className:"font-semibold",children:[Q,":"]})," ",be("span",{className:"text-red-600 dark:text-red-400 line-through",children:typeof ee=="object"?JSON.stringify(ee).substring(0,30)+"...":String(ee).substring(0,30)})," ","\u2192"," ",be("span",{className:"text-green-600 dark:text-green-400",children:typeof me=="string"&&me.length>30?me.substring(0,30)+"...":String(me).substring(0,30)})]},Q))})]}),_.newFields.length>0&&rt("div",{children:[be("p",{className:"font-medium mb-1",children:"New fields to be filled:"}),be("p",{className:"text-sm font-mono",children:_.newFields.join(", ")})]})]})]}),rt(Wc,{children:[be(Yc,{onClick:Oe,children:"Cancel"}),be(Gc,{onClick:Re,children:"Auto-fill"})]})]})})]})}Rf.displayName="ToolsTab";import{AnimatePresence as zw,motion as Lf}from"motion/react";import{ChevronLeft as Bw,FolderOpen as _f}from"lucide-react";import{useCallback as vs,useEffect as tr,useImperativeHandle as Hw,useMemo as Uw,useRef as Of,useState as In}from"react";import{Brush as mw,Check as pw,Clock as fw,Code as gw,Copy as hw,Download as vw,Maximize as bw,Zap as yw}from"lucide-react";import{useCallback as xw,useMemo as If,useState as Mf}from"react";import{ViewRenderer as ww,isViewResource as Cw,isViewTool as Nw}from"@mcp-use/client/react";import{jsx as Ve,jsxs as Wn}from"react/jsx-runtime";function kw(e){if("error"in e&&e.error&&typeof e.error=="string")return e.error;if(!("isError"in e&&e.isError))return null;if("contents"in e&&Array.isArray(e.contents)){let t=e.contents.filter(n=>"text"in n).map(n=>n.text).filter(Boolean);if(t.length>0)return t.join(`
|
|
104
|
-
`)}return"An error occurred"}function Sw({serverId:e,viewId:t,resourceUri:n,toolOutput:o,toolMetadata:r,readResource:s,customProps:a,displayMode:i,onDisplayModeChange:d}){let l=If(()=>({}),[]),u=Ti({serverId:e,viewId:t,resourceUri:n,toolName:n,toolInput:l,toolOutput:o,toolMetadata:r,readResource:s,displayMode:i,onDisplayModeChange:d});if(!u)return Ve(jo,{className:"w-full h-full min-h-[240px]",children:Ve(Kt,{className:"size-5"})});let h=i==="inline"?"w-full h-full flex items-center justify-center relative p-4 min-h-0":"w-full h-full relative p-4",c=a?JSON.stringify(a):"no-custom-props";return Ve(jo,{className:"w-full h-full min-h-[240px]",children:Ve(ww,{viewId:t,toolName:n,toolInput:l,toolOutput:o,customProps:a,className:h,...u},c)})}function Zc({result:e,isLoading:t,previewMode:n,serverId:o,readResource:r,onTogglePreview:s,onCopy:a,onDownload:i,onFullscreen:d,isCopied:l=!1,selectedResource:u,llmConfig:h}){let[c,m]=Mf(null),p=xw(R=>{m(R)},[]),[x,f]=Mf("inline"),b=e?.result&&"contents"in e.result&&Array.isArray(e.result.contents)?e.result.contents[0]?._meta||{}:{},g={...e?.resourceAnnotations,...b},v=If(()=>{let R=g?.["mcp-use/propsSchema"];if(!R)return[];let D=R.def?.shape;return D?Object.entries(D).filter(([,k])=>{let S=k?.def?.type??k?.type;return S!=="optional"&&S!=="default"}).map(([k])=>k):R.required??[]},[g]),y=Nw(g)?"mcp-apps":null,w=e?.result&&"contents"in e.result&&Array.isArray(e.result.contents)&&e.result.contents.some(R=>Cw(R.mimeType)),N=g?.ui?.resourceUri||b?.ui?.resourceUri||(w?e.uri:void 0),T=(y==="mcp-apps"||w)&&!!N,L=v.length>0&&!c;if(t)return Ve("div",{className:"flex absolute left-0 top-0 items-center justify-center w-full h-full",children:Ve(Kt,{className:"size-5"})});if(!e)return Wn("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[Ve("p",{className:"text-gray-500 dark:text-gray-400 mb-2",children:"Select a resource to view its contents"}),Ve("p",{className:"text-xs text-gray-400 dark:text-gray-500",children:"Choose a resource from the list to see its data"})]});let P=e.error||(e.result?kw(e.result):null);return P?Ve("div",{className:"p-4",children:Wn("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded p-3",children:[Ve("p",{className:"text-red-800 dark:text-red-300 font-medium",children:"Error:"}),Ve("p",{className:"text-red-700 dark:text-red-400 text-sm",children:P})]})}):Wn("div",{className:"flex flex-col h-full",children:[Wn("div",{className:"shrink-0 px-4 py-3 border-b border-gray-200 dark:border-zinc-700 flex items-center justify-between",children:[Wn("div",{className:"flex items-center gap-2",children:[Wn("div",{className:"flex items-center gap-1",children:[Ve(fw,{className:"h-3 w-3 text-gray-400"}),Ve("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:new Date(e.timestamp).toLocaleTimeString()})]}),(()=>{let R=e?.duration??e.result?.duration??e.result?.metrics?.durationMs;return R!==void 0?Wn("div",{className:"flex items-center gap-1",children:[Ve(yw,{className:"h-3 w-3 text-gray-400"}),Wn("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:[R,"ms"]})]}):null})(),T&&Ve(Jt,{variant:"outline",className:"text-xs bg-green-50 dark:bg-green-900/20 border-none border-green-200 dark:border-green-800/50 text-green-600 dark:text-green-400",children:"MCP Apps"})]}),Wn("div",{className:"flex items-center gap-1",children:[T&&Wn(E,{variant:"ghost",size:"sm",onClick:s,className:n?"":"text-purple-600 dark:text-purple-400",children:[n?Ve(gw,{className:"h-4 w-4 mr-1"}):Ve(mw,{className:"h-4 w-4 mr-1"}),n?"JSON":"Preview"]}),Ve(E,{variant:"ghost",size:"sm",onClick:a,children:l?Ve(pw,{className:"h-4 w-4"}):Ve(hw,{className:"h-4 w-4"})}),Ve(E,{variant:"ghost",size:"sm",onClick:i,children:Ve(vw,{className:"h-4 w-4"})}),Ve(E,{variant:"ghost",size:"sm",onClick:d,children:Ve(bw,{className:"h-4 w-4"})})]})]}),Ve("div",{className:"flex-1 overflow-y-auto relative",children:T&&o&&r&&N?n?Wn("div",{className:"flex flex-1 h-full relative flex-col min-h-0","data-testid":"resource-widget-preview",children:[Ve("div",{className:"absolute top-2 right-2 z-10 flex items-center gap-2",children:Ve(Hi,{toolCallId:`resource-${e.timestamp}`,displayMode:x,onDisplayModeChange:f,propsContext:"resource",resourceUri:e.uri,resourceAnnotations:g,llmConfig:h||null,resource:u||null,onPropsChange:p,requiredProps:v.length>0&&!c?v:void 0})}),L?Ve("div",{className:"flex items-center justify-center w-full h-full min-h-[200px] rounded-xl border-2 border-dashed border-gray-300 dark:border-zinc-600 bg-gray-50 dark:bg-zinc-800/50 m-4",children:Ve("p",{className:"text-sm text-gray-500 dark:text-gray-400 text-center px-6",children:"This widget requires props, set or generate them in the props debugger"})}):Ve(Sw,{serverId:o,viewId:`resource-${e.timestamp}`,resourceUri:N,toolOutput:e.result,toolMetadata:g,readResource:r,customProps:c||void 0,displayMode:x,onDisplayModeChange:f})]}):Ve("div",{className:"px-4 pt-4","data-testid":"resource-result-json",children:Ve(wt,{data:e.result,filename:`resource-${e.uri.replace(/[^a-zA-Z0-9]/g,"-")}-mcp-apps-${Date.now()}.json`})}):Ve("div",{className:"px-4 pt-4","data-testid":"resource-result-json",children:Ve(wt,{data:e.result,filename:`resource-${e.uri.replace(/[^a-zA-Z0-9]/g,"-")}-${Date.now()}.json`})})})]})}import{Database as Tw}from"lucide-react";import{jsx as Dr,jsxs as Ef}from"react/jsx-runtime";function ed({resources:e,selectedResource:t,onResourceSelect:n,focusedIndex:o}){return e.length===0?Ef("div",{className:"flex flex-1 flex-col items-center justify-center p-4 text-center",children:[Dr(Tw,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),Dr("p",{className:"text-gray-500 dark:text-gray-400",children:"No resources available"})]}):Dr("div",{children:e.map((r,s)=>{let a=[r.description,r.mimeType&&Dr("span",{className:"font-mono",children:r.mimeType},"mime")].filter(Boolean);return Dr(qn,{id:`resource-${r.uri}`,"data-testid":`resource-item-${r.name}`,isSelected:t?.uri===r.uri,isFocused:o===s,title:r.name,description:a.length>0?Ef("span",{className:"flex flex-col gap-1",children:[r.description&&Dr("span",{children:r.description}),r.mimeType&&Dr("span",{className:"text-xs text-gray-500 dark:text-gray-500 font-mono",children:r.mimeType})]}):void 0,onClick:()=>n(r)},r.uri)})})}import{useCallback as hs,useEffect as nd,useRef as Ow,useState as Kn}from"react";import{DEFAULT_OLLAMA_BASE_URL as Pw}from"@mcp-use/agent";var td={openai:"gpt-5.6-terra","openai-compatible":"",anthropic:"claude-haiku-4-5-20251001",google:"gemini-2.5-flash",openrouter:"meta-llama/llama-3.1-8b-instruct:free",ollama:"qwen3"},Rw={ollama:Pw};function Lr(e){return e!=="ollama"&&e!=="openai-compatible"}function So(e){return e==="ollama"||e==="openai-compatible"}function er(e){return Rw[e]??""}function Yi(e){let t=0;for(let n=0;n<e.length;n++){let o=e.charCodeAt(n);t=(t<<5)-t+o,t=t&t}return Math.abs(t).toString(16)}var Mw=10*1024*1024,Iw=20*1024*1024,Ew=["image/png","image/jpeg","image/jpg","image/gif","image/webp","image/svg+xml"];function Aw(e){return Ew.includes(e.type)}function Dw(e){return e.size<=Mw}function Qi(e){return e.reduce((n,o)=>n+(o.size||0),0)<=Iw}function Lw(e){return new Promise((t,n)=>{let o=new FileReader;o.onload=()=>{let r=o.result,s=r.includes(",")?r.split(",")[1]:r;t(s)},o.onerror=()=>{n(new Error(`Failed to read file: ${e.name}`))},o.readAsDataURL(e)})}async function Xi(e){if(!Aw(e))throw new Error(`Unsupported file type: ${e.type}. Only images are supported.`);if(!Dw(e))throw new Error(`File too large: ${e.name}. Maximum size is 10MB.`);return{type:"image",data:await Lw(e),mimeType:e.type,name:e.name,size:e.size}}var Af="mcp-inspector:chat-mode";function _w(){try{let e=localStorage.getItem(Af);if(e==="byok"||e==="managed")return e}catch{}return null}function Zi(e){try{localStorage.setItem(Af,e)}catch{}}function Df(e,t){let n=_w();if(n==="byok")return!0;if(n==="managed"||e)return!1;try{if(localStorage.getItem("mcp-inspector-llm-config"))return!0}catch{}return!!t}function ua({mcpServerUrl:e}){let[t,n]=Kn(null),[o,r]=Kn(null),[s,a]=Kn(!1),[i,d]=Kn("openai"),[l,u]=Kn(""),[h,c]=Kn(td.openai),[m,p]=Kn(er("openai")),x=hs(()=>{let A=localStorage.getItem("mcp-inspector-api-keys");if(A)try{return JSON.parse(A)}catch(_){return console.error("Failed to load API keys:",_),{}}return{}},[]),f=hs(A=>{localStorage.setItem("mcp-inspector-api-keys",JSON.stringify(A))},[]),b=hs(()=>{let A=localStorage.getItem("mcp-inspector-base-urls");if(A)try{return JSON.parse(A)}catch(_){return console.error("Failed to load base URLs:",_),{}}return{}},[]),g=hs(A=>{localStorage.setItem("mcp-inspector-base-urls",JSON.stringify(A))},[]),[v,y]=Kn("none"),[w,N]=Kn(""),[T,L]=Kn(""),[P,R]=Kn("");nd(()=>{let A=()=>{let $=localStorage.getItem("mcp-inspector-llm-config"),oe=x(),ae=b();if($)try{let ie=JSON.parse($);n(ie),d(ie.provider),u(oe[ie.provider]||ie.apiKey||""),c(ie.model),p(ae[ie.provider]||ie.baseUrl||er(ie.provider))}catch(ie){console.error("Failed to load LLM config:",ie)}};A();let _=()=>{A()},K=$=>{($.key==="mcp-inspector-llm-config"||$.key==="mcp-inspector-api-keys"||$.key==="mcp-inspector-base-urls")&&A()};return window.addEventListener("llm-config-updated",_),window.addEventListener("storage",K),()=>{window.removeEventListener("llm-config-updated",_),window.removeEventListener("storage",K)}},[x,b]),nd(()=>{let A=localStorage.getItem("mcp-inspector-auth-config");if(A)try{let _=JSON.parse(A);r(_),y(_.type),_.username&&N(_.username),_.password&&L(_.password),_.token&&R(_.token)}catch(_){console.error("Failed to load auth config:",_)}else try{let _="mcp:auth",K=Yi(e),$=`${_}_${K}_tokens`;localStorage.getItem($)&&(r({type:"oauth"}),y("oauth"))}catch(_){console.error("Failed to check for OAuth tokens:",_)}},[e]);let D=Ow(i);nd(()=>{let A=D.current!==i;D.current=i,A&&!So(i)&&c(td[i]);let _=x(),K=b();u(_[i]||""),p(K[i]||er(i))},[i,x,b]);let k=hs(()=>{if(Lr(i)&&!l.trim()||So(i)&&!m.trim())return!1;let A=x();if(A[i]=l,f(A),So(i)&&m.trim()){let $=b();$[i]=m.trim(),g($)}let _={provider:i,apiKey:l,model:h,...So(i)?{baseUrl:m.trim()||er(i)}:{}},K={type:v,...v==="basic"&&{username:w.trim(),password:T.trim()},...v==="bearer"&&{token:P.trim()}};n(_),r(K),localStorage.setItem("mcp-inspector-llm-config",JSON.stringify(_)),localStorage.setItem("mcp-inspector-auth-config",JSON.stringify(K)),window.dispatchEvent(new CustomEvent("llm-config-updated"));try{Lt(new Za({provider:i,model:h})).catch(()=>{})}catch{}return a(!1),!0},[i,l,h,m,v,w,T,P,x,f,b,g]),S=hs(()=>{n(null),r(null);let A=x();delete A[i],f(A);let _=b();delete _[i],g(_),u(""),p(er(i)),N(""),L(""),R(""),y("none"),localStorage.removeItem("mcp-inspector-llm-config"),localStorage.removeItem("mcp-inspector-auth-config"),Zi("managed")},[i,x,f,b,g]);return{llmConfig:t,authConfig:o,configDialogOpen:s,setConfigDialogOpen:a,tempProvider:i,setTempProvider:d,tempApiKey:l,setTempApiKey:u,tempModel:h,setTempModel:c,tempBaseUrl:m,setTempBaseUrl:p,tempAuthType:v,saveLLMConfig:k,clearConfig:S}}import{Fragment as od,jsx as Ct,jsxs as nr}from"react/jsx-runtime";function zf({ref:e,resources:t,readResource:n,serverId:o,isConnected:r,mcpServerUrl:s,refreshResources:a}){let[i,d]=In(!1),[l,u]=In(null),{selectedResourceUri:h,setSelectedResourceUri:c}=wo(),{llmConfig:m}=ua({mcpServerUrl:s}),[p,x]=In(null),[f,b]=In(!1),[g,v]=In(""),[y]=In("resources"),[w,N]=In(!0),[T,L]=In(!1),[P,R]=In(-1),[D,k]=In(!1),S=Of(null),A=Of(null),[_,K]=In(!1),[$,oe]=In("list");tr(()=>{let U=()=>{K(window.innerWidth<1024)};return U(),window.addEventListener("resize",U),()=>window.removeEventListener("resize",U)},[]),tr(()=>{oe(l?"detail":"list")},[l]),Hw(e,()=>({focusSearch:()=>{L(!0),setTimeout(()=>{S.current&&S.current.focus()},0)},blurSearch:()=>{v(""),L(!1),S.current&&S.current.blur()}})),tr(()=>{T&&S.current&&S.current.focus()},[T]);let ae=vs(()=>{g.trim()||L(!1)},[g]),ie=vs(async()=>{if(a){d(!0);try{await a()}finally{d(!1)}}},[a]),ne=Uw(()=>{if(!g)return t;let U=g.toLowerCase();return t.filter(H=>H.name.toLowerCase().includes(U)||H.description?.toLowerCase().includes(U)||H.uri.toLowerCase().includes(U))},[t,g]),z=vs(async U=>{if(u(U),r){b(!0);let H=Date.now();try{let Te=await n(U.uri);Lt(new Us({resourceUri:U.uri,serverId:o,success:!0})).catch(()=>{}),x({uri:U.uri,result:Te,timestamp:H,resourceAnnotations:{...U.annotations,...U._meta||{}}})}catch(Te){Lt(new Us({resourceUri:U.uri,serverId:o,success:!1,error:Te instanceof Error?Te.message:"Unknown error"})).catch(()=>{}),x({uri:U.uri,result:{contents:[],_meta:{}},error:Te instanceof Error?Te.message:"Unknown error",timestamp:H,resourceAnnotations:{...U.annotations,...U._meta||{}}})}finally{b(!1)}}},[n,o,r]);tr(()=>{R(-1)},[g,y]),tr(()=>{let U=H=>{let Te=H.target;if(Te.tagName==="INPUT"||Te.tagName==="TEXTAREA"||Te.contentEditable==="true"||H.metaKey||H.ctrlKey||H.altKey)return;let le=ne;if(H.key==="ArrowDown")H.preventDefault(),R(de=>{let De=de+1;return De>=le.length?0:De});else if(H.key==="ArrowUp")H.preventDefault(),R(de=>{let De=de-1;return De<0?le.length-1:De});else if(H.key==="Enter"&&P>=0){H.preventDefault();let de=ne[P];de&&z(de)}};return document.addEventListener("keydown",U),()=>document.removeEventListener("keydown",U)},[P,ne,z]),tr(()=>{if(P>=0){let U=`resource-${ne[P]?.uri}`,H=document.getElementById(U);H&&H.scrollIntoView({behavior:"smooth",block:"nearest"})}},[P,ne]),tr(()=>{if(h&&t.length>0){let U=t.find(H=>H.uri===h);U&&l?.uri!==U.uri&&(c(null),setTimeout(()=>{z(U);let H=document.getElementById(`resource-${U.uri}`);H&&H.scrollIntoView({behavior:"smooth",block:"nearest"})},100))}},[h,t,l,z,c]),tr(()=>{if(l){let U=t.find(H=>H.uri===l.uri);U&&U!==l&&(U.description!==l.description||U.mimeType!==l.mimeType||U.name!==l.name)&&u(U)}},[t,l]);let O=vs(async()=>{if(p)try{await Xe(JSON.stringify(p.result,null,2)),k(!0),setTimeout(()=>k(!1),2e3)}catch(U){console.error("[ResourcesTab] Failed to copy result:",U)}},[p]),W=vs(()=>{if(p)try{let U=new globalThis.Blob([JSON.stringify(p.result,null,2)],{type:"application/json"}),H=URL.createObjectURL(U),Te=document.createElement("a");Te.href=H,Te.download=`resource-${Date.now()}.json`,document.body.appendChild(Te),Te.click(),document.body.removeChild(Te),URL.revokeObjectURL(H)}catch(U){console.error("[ResourcesTab] Failed to download result:",U)}},[p]),j=vs(async()=>{if(A.current)try{document.fullscreenElement?await document.exitFullscreen():await A.current.requestFullscreen()}catch(U){console.error("[ResourcesTab] Failed to toggle fullscreen:",U)}},[]);return _?nr("div",{className:"h-full flex flex-col overflow-hidden relative bg-background",children:[$!=="list"&&nr("div",{className:"flex items-center gap-2 p-2 border-b shrink-0 bg-background z-10",children:[Ct(E,{variant:"ghost",size:"sm",onClick:()=>{u(null),oe("list")},className:"p-0 h-8 w-8",children:Ct(Bw,{className:"h-4 w-4"})}),nr("div",{className:"flex items-center text-sm font-medium",children:[Ct("button",{onClick:()=>{u(null),oe("list")},className:"text-muted-foreground hover:text-foreground hover:underline cursor-pointer",children:"Resources"}),$==="detail"&&nr(od,{children:[Ct("span",{className:"mx-2 text-muted-foreground",children:"/"}),Ct("span",{className:"text-foreground",children:"Content"})]})]})]}),Ct("div",{className:"flex-1 relative overflow-hidden",children:nr(zw,{initial:!1,mode:"popLayout",children:[$==="list"&&Ct(Lf.div,{initial:{x:"-100%"},animate:{x:0},exit:{x:"-100%"},transition:{type:"spring",stiffness:300,damping:30},className:"absolute inset-0 flex flex-col bg-background z-0",children:Ct(ao,{children:U=>nr(od,{children:[Ct(qi,{isScrolled:U,title:"Resources",icon:_f,count:ne.length,isSearchExpanded:T,searchQuery:g,searchPlaceholder:"Search resources...",onSearchExpand:()=>L(!0),onSearchChange:v,onSearchBlur:ae,searchInputRef:S,onRefresh:a?ie:void 0,isRefreshing:i}),Ct(ed,{resources:ne,selectedResource:l,onResourceSelect:z,focusedIndex:P})]})})},"list"),$==="detail"&&Ct(Lf.div,{initial:{x:"100%"},animate:{x:0},exit:{x:"100%"},transition:{type:"spring",stiffness:300,damping:30},className:"absolute inset-0 bg-white dark:bg-zinc-900 z-10",children:Ct("div",{ref:A,className:"h-full",children:Ct(Zc,{result:p,isLoading:f,previewMode:w,serverId:o,readResource:n,onTogglePreview:()=>N(!w),onCopy:O,onDownload:W,onFullscreen:j,isCopied:D,selectedResource:l,llmConfig:m})})},"detail")]})})]}):nr(Qo,{orientation:"horizontal",className:"h-full",children:[Ct(hn,{defaultSize:"33%",children:Ct("div",{className:"flex h-full flex-col overflow-hidden border-r dark:border-zinc-700",children:Ct(ao,{children:U=>nr(od,{children:[Ct(qi,{isScrolled:U,title:"Resources",icon:_f,count:ne.length,isSearchExpanded:T,searchQuery:g,searchPlaceholder:"Search resources...",onSearchExpand:()=>L(!0),onSearchChange:v,onSearchBlur:ae,searchInputRef:S,onRefresh:a?ie:void 0,isRefreshing:i}),Ct(ed,{resources:ne,selectedResource:l,onResourceSelect:z,focusedIndex:P})]})})})}),Ct(Xo,{}),Ct(hn,{defaultSize:"67%",children:Ct("div",{ref:A,className:"h-full bg-white dark:bg-zinc-900",children:Ct(Zc,{result:p,isLoading:f,previewMode:w,serverId:o,readResource:n,onTogglePreview:()=>N(!w),onCopy:O,onDownload:W,onFullscreen:j,isCopied:D,selectedResource:l,llmConfig:m})})})]})}zf.displayName="ResourcesTab";import{AnimatePresence as yC,motion as hd}from"motion/react";import{ChevronLeft as xC,Clock as qf,MessageSquare as Wf}from"lucide-react";import{useCallback as Po,useEffect as Ro,useImperativeHandle as wC,useRef as CC,useState as An}from"react";import{Play as Fw,Save as $w}from"lucide-react";import{useEffect as Vw}from"react";import{jsx as ln,jsxs as En}from"react/jsx-runtime";function Bf({selectedPrompt:e,promptArgs:t,onArgChange:n}){let o=e?.arguments||[];if(!(o.length>0))return ln("div",{className:"flex items-center justify-center h-32 text-gray-500 dark:text-gray-400 text-sm",children:"No arguments required"});let s=a=>{let i=a.name,d=t[i],l=typeof d=="string"?d:JSON.stringify(d);return a.type==="boolean"?En("div",{className:"space-y-2",children:[En("div",{children:[En(nt,{htmlFor:i,className:"text-sm font-medium",children:[i,a.required&&ln("span",{className:"text-red-500 ml-1",children:"*"})]}),a.description&&ln("p",{className:"mt-0.5 text-xs text-gray-500 dark:text-gray-400",children:a.description})]}),ln("input",{id:i,type:"checkbox",checked:!!d,onChange:u=>n(i,u.target.checked),className:"rounded","aria-label":`Toggle ${i}`})]},i):a.type==="number"?En("div",{className:"space-y-2",children:[En("div",{children:[En(nt,{htmlFor:i,className:"text-sm font-medium",children:[i,a.required&&ln("span",{className:"text-red-500 ml-1",children:"*"})]}),a.description&&ln("p",{className:"mt-0.5 text-xs text-gray-500 dark:text-gray-400",children:a.description})]}),ln(Ge,{id:i,type:"number",value:Number(d)||0,onChange:u=>n(i,Number(u.target.value)),placeholder:`Enter ${i}`})]},i):a.type==="array"||a.type==="object"?En("div",{className:"space-y-2",children:[En("div",{children:[En(nt,{htmlFor:i,className:"text-sm font-medium",children:[i,a.required&&ln("span",{className:"text-red-500 ml-1",children:"*"})]}),a.description&&ln("p",{className:"mt-0.5 text-xs text-gray-500 dark:text-gray-400",children:a.description})]}),ln(no,{id:i,value:l,onChange:u=>{try{let h=JSON.parse(u.target.value);n(i,h)}catch{n(i,u.target.value)}},placeholder:`Enter ${i} as JSON`,className:"font-mono text-sm min-h-[100px]"})]},i):En("div",{className:"space-y-2",children:[En("div",{children:[En(nt,{htmlFor:i,className:"text-sm font-medium",children:[i,a.required&&ln("span",{className:"text-red-500 ml-1",children:"*"})]}),a.description&&ln("p",{className:"mt-0.5 text-xs text-gray-500 dark:text-gray-400",children:a.description})]}),ln(Ge,{id:i,"data-testid":`prompt-param-${i}`,value:l,onChange:u=>n(i,u.target.value),placeholder:`Enter ${i}`})]},i)};return ln("div",{className:"space-y-4",children:o.map(a=>s(a))})}import{Fragment as Hf,jsx as en,jsxs as or}from"react/jsx-runtime";function rd({selectedPrompt:e,promptArgs:t,isExecuting:n,isConnected:o,onArgChange:r,onExecute:s,onSave:a}){return Vw(()=>{let i=d=>{(d.metaKey||d.ctrlKey)&&d.key==="Enter"&&e&&!n&&o&&(d.preventDefault(),s())};return document.addEventListener("keydown",i),()=>document.removeEventListener("keydown",i)},[e,n,o,s]),e?or("div",{className:"flex flex-col h-full",children:[en("div",{className:"flex-shrink-0 p-3 sm:p-6 pt-3 pb-4 pr-3",children:or("div",{children:[or("div",{className:"flex flex-row items-center justify-between mb-0 gap-2",children:[en("h3",{className:"text-base sm:text-lg font-semibold",children:e.name}),or("div",{className:"flex gap-2 flex-shrink-0",children:[en(E,{onClick:s,disabled:n||!o,size:"sm",className:js,"data-testid":"prompt-execute-button",children:n?or(Hf,{children:[en(Kt,{}),en("span",{className:"hidden sm:inline",children:"Executing..."})]}):or(Hf,{children:[en(Fw,{}),en("span",{className:"hidden sm:inline",children:"Execute"}),en("span",{className:rm,children:"\u2318\u21B5"})]})}),or(E,{variant:"outline",onClick:a,disabled:n,size:"sm",className:C(vr,"gap-2"),children:[en($w,{}),en("span",{className:"hidden sm:inline",children:"Save"})]})]})]}),e.description&&en("p",{className:"text-sm text-gray-600 dark:text-gray-400 leading-relaxed mt-2",children:e.description})]})}),en("div",{className:"flex-1 overflow-y-auto px-3 sm:px-6 pb-4 pr-3",children:en(Bf,{selectedPrompt:e,promptArgs:t,onArgChange:r})})]}):or("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[en("p",{className:"text-gray-500 dark:text-gray-400 mb-2",children:"Select a prompt to get started"}),en("p",{className:"text-xs text-gray-400 dark:text-gray-500",children:"Choose a prompt from the list to view its details and execute it"})]})}import{Check as aC,Copy as iC,History as lC,Maximize as $f,Minimize as cC,Trash2 as dC,Zap as uC}from"lucide-react";import{useEffect as Vf,useState as md}from"react";import{Check as eC,Copy as tC}from"lucide-react";import{useState as nC}from"react";import{Check as qw,Copy as Ww}from"lucide-react";import Kw from"markdown-to-jsx";import{useState as Jw}from"react";import{Checkbox as Uf}from"@base-ui/react/checkbox";import{CheckIcon as jw}from"lucide-react";import{jsx as sd}from"react/jsx-runtime";function ma({className:e,...t}){return sd(Uf.Root,{"data-slot":"checkbox",className:C("peer relative flex size-4 shrink-0 items-center justify-center rounded-[4px] border border-input shadow-xs transition-shadow outline-none group-has-disabled/field:opacity-50 after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 aria-invalid:aria-checked:border-primary dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:border-primary data-checked:bg-primary data-checked:text-primary-foreground dark:data-checked:bg-primary",e),...t,children:sd(Uf.Indicator,{"data-slot":"checkbox-indicator",className:"grid place-content-center text-current transition-none [&>svg]:size-3.5",children:sd(jw,{})})})}import*as Or from"react";import{jsx as _r}from"react/jsx-runtime";var ad=Or.forwardRef(({className:e,...t},n)=>_r("div",{className:"relative w-full overflow-auto",children:_r("table",{ref:n,className:C("w-full caption-bottom text-sm",e),...t})}));ad.displayName="Table";var id=Or.forwardRef(({className:e,...t},n)=>_r("thead",{ref:n,className:C("[&_tr]:border-b",e),...t}));id.displayName="TableHeader";var ld=Or.forwardRef(({className:e,...t},n)=>_r("tbody",{ref:n,className:C("[&_tr:last-child]:border-0",e),...t}));ld.displayName="TableBody";var cd=Or.forwardRef(({className:e,...t},n)=>_r("tr",{ref:n,className:C("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",e),...t}));cd.displayName="TableRow";var dd=Or.forwardRef(({className:e,...t},n)=>_r("th",{ref:n,className:C("h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",e),...t}));dd.displayName="TableHead";var ud=Or.forwardRef(({className:e,...t},n)=>_r("td",{ref:n,className:C("p-4 align-middle [&:has([role=checkbox])]:pr-0",e),...t}));ud.displayName="TableCell";import{Fragment as Zw,jsx as Le,jsxs as pa}from"react/jsx-runtime";function Gw({children:e,className:t}){let n="text";if(t){let i=t.match(/(?:lang(?:uage)?-)(\w+)/);i?n=i[1]:n=t.replace(/^(lang-|language-)\s*/,"").trim()}let[o,r]=Jw(!1),s=String(e).trim();return pa("div",{className:"my-4 relative group/code bg-muted rounded-md p-0",children:[pa("div",{className:"flex items-center justify-between mb-2 absolute top-0 left-0 w-full",children:[Le("div",{className:"text-[10px] font-mono text-muted-foreground/50 bg-transparent px-2 py-0 rounded",children:n}),Le("button",{className:"opacity-0 group-hover/code:opacity-100 transition-opacity text-muted-foreground hover:text-foreground text-xs flex items-center gap-1 px-2 py-1 rounded hover:bg-muted",onClick:async()=>{await Xe(s),r(!0),setTimeout(()=>r(!1),2e3)},title:"Copy code",children:o?Le(qw,{className:"h-3.5 w-3.5"}):Le(Ww,{className:"h-3.5 w-3.5"})})]}),Le("pre",{className:"text-sm m-0 p-4 pt-8 rounded-lg font-mono overflow-x-auto",style:{background:"var(--muted)"},children:Le("code",{children:s})})]})}function Yw({children:e}){return Le("code",{className:"bg-muted px-1.5 py-0.5 rounded text-sm font-mono",children:e})}function Qw({children:e,className:t}){return t?Le(Gw,{className:t,children:e}):Le(Yw,{children:e})}function Xw({children:e}){if(typeof e=="string"){let t=e.match(/^\[([ xX])\]\s*(.*)/);if(t){let n=t[1].toLowerCase()==="x",o=t[2];return pa("li",{className:"text-foreground flex items-center gap-2",children:[Le(ma,{checked:n,disabled:!0}),Le("span",{children:o})]})}}if(Array.isArray(e)&&e.length>0){let t=e[0];if(typeof t=="string"){let n=t.match(/^\[([ xX])\]\s*(.*)/);if(n){let o=n[1].toLowerCase()==="x",r=n[2];return pa("li",{className:"text-foreground flex items-center gap-2",children:[Le(ma,{checked:o,disabled:!0}),pa("span",{children:[r,e.slice(1)]})]})}}}return Le("li",{className:"text-foreground",children:e})}function bs({content:e,className:t}){let n=Le(Kw,{options:{overrides:{code:Qw,pre:({children:o})=>Le(Zw,{children:o}),h1:({children:o})=>Le("h1",{className:"text-xl font-bold text-foreground mb-2 mt-4",children:o}),h2:({children:o})=>Le("h2",{className:"text-lg font-bold text-foreground mb-2 mt-4",children:o}),h3:({children:o})=>Le("h3",{className:"text-base font-bold text-foreground mb-2 mt-4",children:o}),h4:({children:o})=>Le("h4",{className:"text-sm font-bold text-foreground mb-2 mt-4",children:o}),h5:({children:o})=>Le("h5",{className:"text-sm font-bold text-foreground mb-2 mt-4",children:o}),h6:({children:o})=>Le("h6",{className:"text-sm font-bold text-foreground mb-2 mt-4",children:o}),p:({children:o})=>Le("p",{className:"text-foreground mb-2 leading-relaxed",children:o}),ul:({children:o})=>Le("ul",{className:"list-disc list-outside pl-6 mb-3 space-y-1",children:o}),ol:({children:o})=>Le("ol",{className:"list-decimal list-outside pl-6 mb-3 space-y-1",children:o}),li:Xw,table:({children:o})=>Le("div",{className:"my-4",children:Le(ad,{children:o})}),thead:({children:o})=>Le(id,{children:o}),tbody:({children:o})=>Le(ld,{children:o}),tr:({children:o})=>Le(cd,{children:o}),th:({children:o})=>Le(dd,{children:o}),td:({children:o})=>Le(ud,{children:o}),blockquote:({children:o})=>Le("blockquote",{className:"border-l-4 border-muted-foreground pl-4 italic text-muted-foreground mb-3",children:o}),a:({children:o,href:r})=>Le("a",{href:r,className:"text-primary hover:underline",target:"_blank",rel:"noopener noreferrer",children:o}),strong:({children:o})=>Le("strong",{className:"font-semibold text-foreground",children:o}),em:({children:o})=>Le("em",{className:"italic text-foreground",children:o}),img:({src:o,alt:r})=>Le("img",{src:o,alt:r||"",className:"max-w-full max-h-[500px] object-contain rounded-lg my-4 border border-border",loading:"lazy"}),hr:()=>Le("hr",{className:"my-4 border-t border-border"})}},children:e});return t?Le("div",{className:t,children:n}):n}import{jsx as cn,jsxs as ys}from"react/jsx-runtime";function oC(e){switch(e){case"system":return"default";case"user":return"outline";case"assistant":return"secondary";default:return"outline"}}function rC(e){return e.charAt(0).toUpperCase()+e.slice(1)}function sC(e){return typeof e=="string"?e:e.text?e.text:e.type==="resource"&&e.resource?.text?e.resource.text:e.type==="image"?`[Image: ${e.mimeType||"unknown type"}]`:JSON.stringify(e,null,2)}function Ff({message:e,index:t}){let[n,o]=nC(!1),r=async()=>{let a=sC(e.content);await Xe(a),o(!0),setTimeout(()=>o(!1),2e3)},s=()=>{let a=e.content;return typeof a=="string"?cn(bs,{content:a}):a.type==="text"&&a.text?cn(bs,{content:a.text}):a.type==="image"?ys("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[ys("span",{className:"font-mono bg-muted px-2 py-1 rounded",children:["Image: ",a.mimeType||"unknown type"]}),a.data&&cn("img",{src:`data:${a.mimeType};base64,${a.data}`,alt:"Prompt image",className:"max-w-full max-h-[300px] object-contain rounded-lg border border-border mt-2"})]}):a.type==="resource"&&a.resource?ys("div",{className:"space-y-2",children:[ys("div",{className:"flex items-center gap-2 text-sm",children:[cn("span",{className:"text-muted-foreground font-medium",children:"Resource:"}),cn("code",{className:"bg-muted px-2 py-0.5 rounded text-xs font-mono",children:a.resource.uri})]}),a.resource.text&&cn("div",{className:"mt-2",children:cn(bs,{content:a.resource.text})})]}):cn("pre",{className:"bg-muted p-3 rounded-lg text-sm overflow-x-auto",children:cn("code",{children:JSON.stringify(a,null,2)})})};return ys("div",{className:"border border-border rounded-lg overflow-hidden bg-white dark:bg-zinc-900",children:[ys("div",{className:"flex items-center justify-between px-4 py-2 bg-muted/30 border-b border-border",children:[cn(Jt,{variant:oC(e.role),children:rC(e.role)}),cn(E,{variant:"ghost",size:"sm",onClick:r,className:"h-6 px-2",title:"Copy message content",children:n?cn(eC,{className:"h-3.5 w-3.5"}):cn(tC,{className:"h-3.5 w-3.5"})})]}),cn("div",{className:"px-4 py-3","data-testid":`prompt-message-content-${t}`,children:s()})]})}import{jsx as Ue,jsxs as To}from"react/jsx-runtime";function mC(e){let n=Date.now()-e,o=Math.floor(n/1e3),r=Math.floor(o/60),s=Math.floor(r/60),a=Math.floor(s/24);return o<10?"now":o<60?`${o}s ago`:r<60?`${r}m ago`:s<24?`${s}h ago`:`${a}d ago`}function pC(e){return"isError"in e&&!e.isError?null:"error"in e&&e.error?String(e.error):"isError"in e&&e.isError?"An error occurred":null}function pd({results:e,copiedResult:t,previewMode:n=!0,onCopy:o,onDelete:r,onFullscreen:s,onTogglePreview:a,onMaximize:i,isMaximized:d=!1}){let[l,u]=md(0),[h,c]=md(""),[m,p]=md(!0),x=e[0],f=x?e.filter(w=>w.promptName===x.promptName):[],b=f[l]||f[0],g=e.findIndex(w=>w===b);if(Vf(()=>{f.length>0&&l>=f.length&&u(0)},[f.length,l]),Vf(()=>{let w=()=>{b&&c(mC(b.timestamp))};w();let N=setInterval(w,1e3);return()=>clearInterval(N)},[b]),e.length===0)return Ue("div",{className:"flex flex-col h-full bg-white dark:bg-black border-t dark:border-zinc-700",children:Ue("div",{className:"flex-1 overflow-y-auto h-full",children:Ue("div",{className:"flex items-center justify-center h-full",children:Ue("div",{className:"text-center",children:Ue(ms,{vertical:!0,noBorder:!0,message:"No Results yet"})})})})});let v=b.error||pC(b.result),y="messages"in b.result&&Array.isArray(b.result.messages);return Ue("div",{className:"flex flex-col h-full bg-white dark:bg-black border-t dark:border-zinc-700",children:Ue("div",{className:"flex-1 overflow-y-auto h-full",children:To("div",{className:"space-y-0 flex-1 h-full flex flex-col",children:[To("div",{className:"flex items-center gap-2 px-4 pt-2 border-b border-gray-200 dark:border-zinc-600 pb-2",children:[Ue("h3",{className:"text-sm font-medium hidden sm:block",children:"Response"}),b.duration!==void 0&&To("div",{className:"hidden sm:flex items-center gap-1",children:[Ue(uC,{className:"h-3 w-3 text-gray-400"}),To("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:[b.duration,"ms"]})]}),y&&Ue("div",{className:"flex items-center gap-4 sm:ml-4",children:To("div",{className:"flex items-center gap-2",children:[Ue("button",{onClick:()=>p(!0),className:`text-xs font-medium ${m?"text-black dark:text-white":"text-zinc-500 dark:text-zinc-400"}`,children:"Formatted"}),Ue("span",{className:"text-xs text-zinc-400",children:"|"}),Ue("button",{onClick:()=>p(!1),className:`text-xs font-medium ${m?"text-zinc-500 dark:text-zinc-400":"text-black dark:text-white"}`,children:"Raw"})]})}),To("div",{className:"ml-auto flex items-center gap-1",children:[f.length>1&&To("div",{className:"flex items-center gap-2 mr-2",children:[Ue(lC,{className:"h-3 w-3 text-gray-400"}),To(kn,{value:l.toString(),onValueChange:w=>u(parseInt(w)),children:[Ue(Vn,{className:"h-7 w-[120px] text-xs",children:Ue(Fn,{})}),Ue($n,{children:f.map((w,N)=>Ue(Wt,{value:N.toString(),children:N===0?"Latest":`${N+1} call ago`},N))})]})]}),Ue("span",{className:"text-xs text-gray-500 dark:text-gray-400 mr-2",children:h}),Ue(E,{variant:"ghost",size:"sm",onClick:()=>o(g,b.result),className:"h-7 w-7 p-0",title:"Copy result",children:t===g?Ue(aC,{className:"h-4 w-4"}):Ue(iC,{className:"h-4 w-4"})}),r&&Ue(E,{variant:"ghost",size:"sm",onClick:()=>r(g),className:"h-7 w-7 p-0",title:"Delete result",children:Ue(dC,{className:"h-4 w-4"})}),s&&Ue(E,{variant:"ghost",size:"sm",onClick:()=>s(g),className:"h-7 w-7 p-0 sm:hidden",title:"Fullscreen",children:Ue($f,{className:"h-4 w-4"})}),i&&Ue(E,{variant:"ghost",size:"sm",onClick:i,className:"h-7 w-7 p-0 hidden sm:flex",title:d?"Restore":"Maximize",children:d?Ue(cC,{className:"h-4 w-4"}):Ue($f,{className:"h-4 w-4"})})]})]}),Ue("div",{className:"flex-1 overflow-y-auto p-4",children:v?To("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded p-3",children:[Ue("p",{className:"text-red-800 dark:text-red-300 font-medium",children:"Error:"}),Ue("p",{className:"text-red-700 dark:text-red-400 text-sm",children:v})]}):m&&y?Ue("div",{className:"space-y-3",children:("messages"in b.result?b.result.messages:[]).map((w,N)=>Ue(Ff,{message:w,index:N},N))}):Ue(wt,{data:b.result,filename:`prompt-result-${b.promptName}-${Date.now()}.json`})})]})})})}import{MessageSquare as fC}from"lucide-react";import{jsx as el,jsxs as jf}from"react/jsx-runtime";function fd({prompts:e,selectedPrompt:t,onPromptSelect:n,focusedIndex:o}){return e.length===0?jf("div",{className:"flex flex-1 flex-col items-center justify-center p-4 text-center",children:[el(fC,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),el("p",{className:"text-gray-500 dark:text-gray-400",children:"No prompts available"})]}):el("div",{children:e.map((r,s)=>el(qn,{id:`prompt-${r.name}`,"data-testid":`prompt-item-${r.name}`,isSelected:t?.name===r.name,isFocused:o===s,title:r.name,description:r.description,metadata:r.arguments&&r.arguments.length>0&&jf(Jt,{variant:"outline",className:"text-xs border-gray-300 dark:border-zinc-600 text-gray-600 dark:text-gray-400",children:[r.arguments.length," args"]}),onClick:()=>n(r)},r.name))})}import{Clock as gC}from"lucide-react";import{jsx as fa,jsxs as hC}from"react/jsx-runtime";function gd({savedPrompts:e,selectedPrompt:t,onLoadPrompt:n,onDeletePrompt:o,focusedIndex:r}){return e.length===0?hC("div",{className:"flex flex-1 flex-col items-center justify-center p-4 text-center",children:[fa(gC,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),fa("p",{className:"text-gray-500 dark:text-gray-400",children:"No history"}),fa("p",{className:"text-sm text-gray-400 dark:text-gray-500 mt-1",children:"Prompts you execute will appear here"})]}):fa("div",{children:e.map((s,a)=>fa(qn,{id:`saved-prompt-${s.id}`,isSelected:t?.id===s.id,isFocused:r===a,title:s.name,description:`${s.promptName} - ${new Date(s.savedAt).toLocaleString()}`,onClick:()=>n(s)},s.id))})}import{useState as ga,useCallback as xs,useEffect as vC,useMemo as bC}from"react";function ha({prompts:e,callPrompt:t,serverId:n}){let[o,r]=ga(null),[s,a]=ga({}),[i,d]=ga([]),[l,u]=ga(!1),[h,c]=ga(""),m=bC(()=>{if(!h.trim())return e;let y=h.toLowerCase();return e.filter(w=>w.name.toLowerCase().includes(y)||w.description?.toLowerCase().includes(y))},[e,h]),p=xs(y=>{r(y);let w={};y.arguments&&y.arguments.forEach(N=>{w[N.name]=""}),a(w)},[]),x=xs((y,w)=>{a(N=>({...N,[y]:w}))},[]),f=xs(async(y,w)=>{if(l)return;u(!0);let N=Date.now();try{let T=await t(y.name,w),L=Date.now()-N;Lt(new Fs({promptName:y.name,serverId:n,success:!0})).catch(()=>{}),d(P=>[{promptName:y.name,args:w,result:T,timestamp:N,duration:L},...P])}catch(T){Lt(new Fs({promptName:y.name,serverId:n,success:!1,error:T instanceof Error?T.message:"Unknown error"})).catch(()=>{});let L=T instanceof Error?T.message:String(T),P={promptName:y.name,args:w,result:{error:L,isError:!0},error:L,timestamp:N,duration:Date.now()-N};d(R=>[P,...R])}finally{u(!1)}},[l,t,n]),b=xs(y=>{d(w=>w.filter((N,T)=>T!==y))},[]),g=xs(()=>{d([])},[]);vC(()=>{if(o){let y=e.find(w=>w.name===o.name);if(!y){r(null);return}y!==o&&(JSON.stringify(y.arguments)!==JSON.stringify(o.arguments)||y.description!==o.description)&&r(y)}},[e,o]);let v=xs(async()=>{!o||l||f(o,s)},[o,s,l,f]);return{filteredPrompts:m,selectedPrompt:o,setSelectedPrompt:r,results:i,handleDeleteResult:b,promptArgs:s,setPromptArgs:a,isExecuting:l,handlePromptSelect:p,handleArgChange:x,executePrompt:f,executeSelectedPrompt:v,searchQuery:h,setSearchQuery:c,clearPromptResults:g}}import{Fragment as tl,jsx as Je,jsxs as io}from"react/jsx-runtime";var Kf="mcp-inspector-saved-prompts";function Jf({ref:e,prompts:t,callPrompt:n,serverId:o,isConnected:r,refreshPrompts:s}){let[a,i]=An(!1),[d,l]=An(null),{selectedPromptName:u,setSelectedPromptName:h}=wo(),[c,m]=An(null),[p,x]=An("prompts"),[f,b]=An([]),[g,v]=An(!1),[y,w]=An(""),[N,T]=An(!1),[L,P]=An(-1),R=CC(null),[D,k]=An(!1),[S,A]=An("list"),[_,K]=An(!1),{filteredPrompts:$,selectedPrompt:oe,setSelectedPrompt:ae,results:ie,handleDeleteResult:ne,promptArgs:z,setPromptArgs:O,isExecuting:W,handlePromptSelect:j,handleArgChange:U,executeSelectedPrompt:H,searchQuery:Te,setSearchQuery:Pe}=ha({prompts:t,callPrompt:n,serverId:o}),le=Ir(),de=Ir();Ro(()=>{let q=()=>{k(window.innerWidth<1024)};return q(),window.addEventListener("resize",q),()=>window.removeEventListener("resize",q)},[]),Ro(()=>{A(oe?"detail":"list")},[oe]),Ro(()=>{D&&ie.length>0&&!W&&A("response")},[ie,W,D]),wC(e,()=>({focusSearch:()=>{T(!0),setTimeout(()=>{R.current&&R.current.focus()},0)},blurSearch:()=>{Pe(""),T(!1),R.current&&R.current.blur()}})),Ro(()=>{try{let q=localStorage.getItem(Kf);if(q){let M=JSON.parse(q);b(M)}}catch(q){console.error("[PromptsTab] Failed to load saved prompts:",q)}},[]);let De=Po(q=>{try{localStorage.setItem(Kf,JSON.stringify(q))}catch(M){console.error("[PromptsTab] Failed to save prompts:",M)}},[]);Ro(()=>{N&&R.current&&R.current.focus()},[N]);let Re=Po(()=>{Te.trim()||T(!1)},[Te]),Oe=Po(async()=>{if(s){i(!0);try{await s()}finally{i(!1)}}},[s]),Be=Po(q=>{let M=t.find(Ne=>Ne.name===q.promptName);M&&(ae(M),O(q.args),l(q))},[t,ae,O]);Ro(()=>{P(-1)},[Te,p]),Ro(()=>{let q=M=>{let Ne=M.target;if(Ne.tagName==="INPUT"||Ne.tagName==="TEXTAREA"||Ne.contentEditable==="true"||M.metaKey||M.ctrlKey||M.altKey)return;let qe=p==="prompts"?$:f;if(M.key==="ArrowDown")M.preventDefault(),P(ut=>{let Bt=ut+1;return Bt>=qe.length?0:Bt});else if(M.key==="ArrowUp")M.preventDefault(),P(ut=>{let Bt=ut-1;return Bt<0?qe.length-1:Bt});else if(M.key==="Enter"&&L>=0)if(M.preventDefault(),p==="prompts"){let ut=$[L];ut&&j(ut)}else{let ut=f[L];ut&&Be(ut)}};return document.addEventListener("keydown",q),()=>document.removeEventListener("keydown",q)},[L,$,f,p,j,Be]),Ro(()=>{if(L>=0){let q=p==="prompts"?`prompt-${$[L]?.name}`:`saved-prompt-${f[L]?.id}`,M=document.getElementById(q);M&&M.scrollIntoView({behavior:"smooth",block:"nearest"})}},[L,$,f,p]),Ro(()=>{if(console.warn("[PromptsTab] Auto-selection effect triggered:",{selectedPromptName:u,promptsCount:t.length,currentSelectedPrompt:oe?.name}),u&&t.length>0){let q=t.find(M=>M.name===u);if(console.warn("[PromptsTab] Prompt lookup result:",{selectedPromptName:u,promptFound:!!q,promptName:q?.name,shouldSelect:q&&oe?.name!==q.name}),q&&oe?.name!==q.name){console.warn("[PromptsTab] Selecting prompt:",q.name),h(null);let M=setTimeout(()=>{j(q);let Ne=document.getElementById(`prompt-${q.name}`);Ne&&(console.warn("[PromptsTab] Scrolling to prompt element"),Ne.scrollIntoView({behavior:"smooth",block:"nearest"}))},100);return()=>clearTimeout(M)}}},[u,t,oe,j,h]);let tt=Po(async(q,M)=>{try{await Xe(JSON.stringify(M,null,2)),m(q),setTimeout(()=>m(null),2e3)}catch(Ne){console.error("[PromptsTab] Failed to copy result:",Ne)}},[]),V=Po(q=>{if(D)A("response");else{let M=ie[q];if(M){let Ne=window.open("","_blank","width=800,height=600");if(Ne){let gt=M.result;Ne.document.write(`
|
|
103
|
+
`),N.document.close())},[b]),v=ca(()=>{c?.abort(),m(null),l(!1)},[c]);return{results:a,setResults:i,isExecuting:d,copiedResult:u,executeTool:p,handleCopyResult:x,handleDeleteResult:f,handleFullscreen:g,filteredResults:b,cancelExecution:v}}import{useCallback as yf,useEffect as ko,useImperativeHandle as aw,useRef as iw,useState as da}from"react";function xf({ref:e,activeTab:t,filteredTools:n,savedRequests:o,searchQuery:r,setSearchQuery:s,selectedTool:a,results:i,isExecuting:d,handleToolSelect:l,loadSavedRequest:u,refreshTools:h,selectedToolName:c,tools:m,setSelectedToolName:p}){let[x,f]=da(!1),[b,g]=da(-1),v=iw(null),[y,w]=da(!1),[N,T]=da("list"),[L,P]=da(!1);ko(()=>{let k=()=>w(window.innerWidth<1024);return k(),window.addEventListener("resize",k),()=>window.removeEventListener("resize",k)},[]),ko(()=>{T(a?"detail":"list")},[a]),ko(()=>{if(!y||i.length===0)return;let k=i[0];(!d||k?.result===null)&&T("response")},[i,d,y]),aw(e,()=>({focusSearch:()=>{f(!0),setTimeout(()=>v.current?.focus(),0)},blurSearch:()=>{s(""),f(!1),v.current?.blur()}})),ko(()=>{x&&v.current?.focus()},[x]);let R=yf(()=>{r.trim()||f(!1)},[r]),D=yf(async()=>{if(h){P(!0);try{await h()}finally{P(!1)}}},[h]);return ko(()=>{t!=="tools"&&f(!1)},[t]),ko(()=>{g(-1)},[r,t]),ko(()=>{let k=S=>{let A=S.target;if(A.tagName==="INPUT"||A.tagName==="TEXTAREA"||A.contentEditable==="true"||S.metaKey||S.ctrlKey||S.altKey)return;let K=t==="tools"?n:o;if(S.key==="ArrowDown")S.preventDefault(),g($=>$+1>=K.length?0:$+1);else if(S.key==="ArrowUp")S.preventDefault(),g($=>$-1<0?K.length-1:$-1);else if(S.key==="Enter"&&b>=0)if(S.preventDefault(),t==="tools"){let $=n[b];$&&l($)}else{let $=o[b];$&&u($)}};return document.addEventListener("keydown",k),()=>document.removeEventListener("keydown",k)},[b,n,o,t,l,u]),ko(()=>{if(b>=0){let k=t==="tools"?`tool-${n[b]?.name}`:`saved-${o[b]?.id}`;document.getElementById(k)?.scrollIntoView({behavior:"smooth",block:"nearest"})}},[b,n,o,t]),ko(()=>{if(!c||m.length===0)return;let k=m.find(S=>S.name===c);if(k){p(null);let S=setTimeout(()=>{l(k),document.getElementById(`tool-${k.name}`)?.scrollIntoView({behavior:"smooth",block:"nearest"})},100);return()=>clearTimeout(S)}},[c,m,l,p]),{isSearchExpanded:x,setIsSearchExpanded:f,focusedIndex:b,searchInputRef:v,isMobile:y,mobileView:N,setMobileView:T,isRefreshing:L,handleSearchBlur:R,handleRefresh:D}}import{Fragment as Gi,jsx as be,jsxs as rt}from"react/jsx-runtime";var Sf=200,dw=140;function Tf({ref:e,tools:t,callTool:n,readResource:o,serverId:r,isConnected:s,refreshTools:a}){let[i,d]=Mn(null),[l,u]=Mn(null),{selectedToolName:h,setSelectedToolName:c}=wo(),[m,p]=Mn({}),[x,f]=Mn(new Set),[b,g]=Mn(new Set),[v,y]=Mn(""),[w,N]=Mn("tools"),{savedRequests:T,saveSavedRequests:L}=vf(),[P,R]=Mn(!1),[D,k]=Mn(""),[S,A]=Mn(!1),[_,K]=Mn({open:!1,parsedObject:{},fieldsToUpdate:[],newFields:[],resolve:null}),[$,oe]=Mn(new Set),ae=Ir(),ie=Ir(),ne=Ir(),z=Ji(null),O=Ji(!1),W=Ji(!1),j=Ji(!0),U=bn(()=>{S?(ae.current&&ae.current.expand(),ie.current&&ie.current.expand(),A(!1)):(ae.current&&ae.current.collapse(),ie.current&&ie.current.collapse(),A(!0))},[S,ae,ie]),H=kf(()=>{if(!v.trim())return t;let Q=v.toLowerCase();return t.filter(ee=>ee.name.toLowerCase().includes(Q)||ee.description?.toLowerCase().includes(Q))},[t,v]),Te=bn(Q=>{d(Q);let ee={},me=new Set;Q.inputSchema?.properties&&Object.entries(Q.inputSchema.properties).forEach(([xe,he])=>{let et=he;et.default!==void 0&&(ee[xe]=et.default,me.add(xe))}),p(ee),f(me),g(new Set)},[]),Pe=bn(Q=>{let ee=t.find(me=>me.name===Q.toolName);ee&&(d(ee),p(Q.args),f(new Set(Object.keys(Q.args))),g(new Set),u(Q))},[t]);Nf(()=>{if(i){let Q=t.find(ee=>ee.name===i.name);Q?Q!==i&&(JSON.stringify(Q.inputSchema)!==JSON.stringify(i.inputSchema)||Q.description!==i.description||JSON.stringify(Q?._meta)!==JSON.stringify(i?._meta))&&d(Q):(d(null),c(null))}},[t,i,c]);let le=bn((Q,ee)=>{let me=i?.inputSchema||{},xe=i?.inputSchema?.properties?.[Q],he=xe?Ci(xe,me):"string",et;he==="object"||he==="array"||he==="string"?et=ee:et=Km(ee,he),p(Dt=>({...Dt,[Q]:et}));let Yt=String(ee).trim()==="";f(Dt=>{let vt=new Set(Dt);return Yt?vt.delete(Q):vt.add(Q),vt}),g(Dt=>{let vt=new Set(Dt);return vt.delete(Q),vt})},[i]),de=bn((Q,ee,me)=>{if(me){let xe=ee==="array"?"[]":ee==="object"?"{}":"";p(he=>({...he,[Q]:xe})),f(he=>new Set(he).add(Q)),g(he=>new Set(he).add(Q))}else g(xe=>{let he=new Set(xe);return he.delete(Q),he}),f(xe=>{let he=new Set(xe);return he.delete(Q),he})},[]),De=bn(async(Q,ee)=>{if(!i)return!1;let me=Gm(Q);if(!me)return!1;let xe=i.inputSchema?.properties||{},he=Object.keys(xe),et=i.inputSchema||{},ht=[],Yt=[];return Object.entries(me).forEach(([Dt,vt])=>{if(he.includes(Dt)){let Kr=xe[Dt],po=Ci(Kr,et),kt=vt;po==="object"||po==="array"?typeof vt=="object"&&vt!==null?kt=JSON.stringify(vt,null,2):typeof vt=="string"&&(kt=vt):typeof vt=="object"&&vt!==null?kt=JSON.stringify(vt):kt=String(vt);let He=m[Dt];He!=null&&He!==""?ht.push({key:Dt,oldValue:He,newValue:kt}):(Yt.push(Dt),le(Dt,String(kt)))}}),ht.length===0&&Yt.length===0?!1:ht.length===0?(oe(new Set(Yt)),setTimeout(()=>oe(new Set),2e3),!0):new Promise(Dt=>{K({open:!0,parsedObject:me,fieldsToUpdate:ht,newFields:Yt,resolve:Dt})})},[i,m,le]),Re=bn(()=>{if(!_.resolve)return;_.fieldsToUpdate.forEach(({key:ee,newValue:me})=>{le(ee,String(me))});let Q=[..._.fieldsToUpdate.map(ee=>ee.key),..._.newFields];oe(new Set(Q)),setTimeout(()=>oe(new Set),2e3),_.resolve(!0),K({open:!1,parsedObject:{},fieldsToUpdate:[],newFields:[],resolve:null})},[_,le]),Oe=bn(()=>{_.resolve&&(_.resolve(!1),K({open:!1,parsedObject:{},fieldsToUpdate:[],newFields:[],resolve:null}))},[_]),Be=kf(()=>{if(!i?.inputSchema?.properties)return{};let Q=i.inputSchema||{},ee={};for(let me of x){let xe=i.inputSchema.properties[me];if(!xe)continue;let he=Ci(xe,Q),et=b.has(me)?he==="array"?"[]":he==="object"?"{}":"":m[me];ee[me]=Jm(et,he)}return ee},[i,m,x,b]),{isExecuting:tt,copiedResult:V,executeTool:ce,handleCopyResult:Fe,handleDeleteResult:Y,handleFullscreen:q,filteredResults:M,cancelExecution:Ne,results:gt}=bf({selectedTool:i,payloadToSend:Be,toolArgs:m,callTool:n,readResource:o,serverId:r}),qe=M[0]?.timestamp;Nf(()=>{O.current=!1,j.current=!0;let Q=requestAnimationFrame(()=>{j.current=!1});return()=>cancelAnimationFrame(Q)},[qe]);let ut=bn(()=>{W.current||j.current||(O.current=!0)},[]),Bt=bn(Q=>{if(Q===null||S||O.current)return;let ee=ne.current,me=z.current;if(!ee||!me)return;let xe=me.offsetHeight;if(xe<=0)return;let he=ee.getSize().inPixels,et=Q+dw,ht=xe-Sf;if(et<=he||ht<=he)return;let Yt=Math.min(et,ht);Yt<=he||(W.current=!0,ee.resize(Yt),requestAnimationFrame(()=>{W.current=!1}))},[S,ne]),{isSearchExpanded:It,setIsSearchExpanded:wn,focusedIndex:mn,searchInputRef:mo,isMobile:On,mobileView:Nt,setMobileView:at,isRefreshing:re,handleSearchBlur:pe,handleRefresh:Ze}=xf({ref:e,activeTab:w,filteredTools:H,savedRequests:T,searchQuery:v,setSearchQuery:y,selectedTool:i,results:gt,isExecuting:tt,handleToolSelect:Te,loadSavedRequest:Pe,refreshTools:a,selectedToolName:h,tools:t,setSelectedToolName:c}),We=bn(()=>{i&&(k(""),R(!0))},[i]),J=bn(()=>{if(!i)return;let Q={id:`${Date.now()}-${Math.random()}`,name:D.trim()||`${i.name} - ${new Date().toLocaleString()}`,toolName:i.name,args:Be,savedAt:Date.now(),serverId:i._serverId,serverName:i._serverName};L([...T,Q]),Lt(new Xa({toolName:i.name,serverId:r})).catch(()=>{}),R(!1),k("")},[i,D,Be,T,L,r]),$e=bn(Q=>{L(T.filter(ee=>ee.id!==Q)),l?.id===Q&&u(null)},[T,L,l]);return On?rt("div",{className:"h-full flex flex-col overflow-hidden relative bg-background",children:[Nt!=="list"&&rt("div",{className:"flex items-center gap-2 p-2 border-b shrink-0 bg-background z-10",children:[be(E,{variant:"ghost",size:"sm",onClick:()=>{Nt==="response"?at("detail"):(d(null),at("list"))},className:"p-0 h-8 w-8",children:be(cw,{className:"h-4 w-4"})}),rt("div",{className:"flex items-center text-sm font-medium",children:[be("button",{onClick:()=>{d(null),at("list")},className:"text-muted-foreground hover:text-foreground hover:underline cursor-pointer",children:"Tools"}),Nt==="detail"&&rt(Gi,{children:[be("span",{className:"mx-2 text-muted-foreground",children:"/"}),be("button",{onClick:()=>{at("response")},className:Nt==="detail"?"text-foreground hover:underline":Nt==="response"?"text-muted-foreground hover:text-foreground hover:underline cursor-pointer":"text-muted-foreground",children:"Execute"})]}),Nt==="response"&&rt(Gi,{children:[be("span",{className:"mx-2 text-muted-foreground",children:"/"}),be("span",{className:"text-foreground",children:"Response"})]})]})]}),be("div",{className:"flex-1 relative overflow-hidden",children:rt(lw,{initial:!1,mode:"popLayout",children:[Nt==="list"&&be(Xc.div,{initial:{x:"-100%"},animate:{x:0},exit:{x:"-100%"},transition:{type:"spring",stiffness:300,damping:30},className:"absolute inset-0 flex flex-col bg-background z-0",children:be(so,{children:Q=>rt(Gi,{children:[be(Er,{isScrolled:Q,activeTab:w,isSearchExpanded:It,searchQuery:v,primaryTabName:"tools",secondaryTabName:"saved",primaryTabTitle:"Tools",secondaryTabTitle:"Saved",primaryCount:H.length,secondaryCount:T.length,primaryIcon:Cf,secondaryIcon:wf,searchPlaceholder:"Search tools...",onSearchExpand:()=>wn(!0),onSearchChange:y,onSearchBlur:pe,onTabSwitch:()=>N(w==="tools"?"saved":"tools"),searchInputRef:mo,onRefresh:a?Ze:void 0,isRefreshing:re}),w==="tools"?be($c,{tools:H,selectedTool:i,onToolSelect:Te,focusedIndex:mn}):be(Hc,{savedRequests:T,selectedRequest:l,onLoadRequest:Pe,onDeleteRequest:$e,focusedIndex:mn})]})})},"list"),Nt==="detail"&&be(Xc.div,{initial:{x:"100%"},animate:{x:0},exit:{x:"-100%"},transition:{type:"spring",stiffness:300,damping:30},className:"absolute inset-0 bg-background z-10",children:be(Fc,{selectedTool:i,toolArgs:m,payloadToSend:Be,isExecuting:tt,isConnected:s,onArgChange:le,onExecute:ce,onSave:We,onBulkPaste:De,autoFilledFields:$,setFields:x,sendEmptyFields:b,onToggleEmpty:de})},"detail"),Nt==="response"&&be(Xc.div,{initial:{x:"100%"},animate:{x:0},exit:{x:"100%"},transition:{type:"spring",stiffness:300,damping:30},className:"absolute inset-0 bg-background z-20",children:be(Fi,{results:M,copiedResult:V,serverId:r,readResource:o,onCopy:Fe,onDelete:Y,onFullscreen:q,onRerunTool:ce})},"response")]})}),be(Uc,{isOpen:P,requestName:D,defaultPlaceholder:`${i?.name} - ${new Date().toLocaleString()}`,onRequestNameChange:k,onSave:J,onCancel:()=>R(!1)}),be(Vc,{open:_.open,onOpenChange:Q=>{Q||Oe()},children:rt(jc,{children:[rt(qc,{children:[be(Kc,{children:"Auto-fill fields from pasted object?"}),rt(Jc,{children:[_.fieldsToUpdate.length>0&&rt("div",{className:"mb-3",children:[be("p",{className:"font-medium mb-2",children:"The following fields will be updated:"}),be("ul",{className:"text-sm space-y-1 max-h-[200px] overflow-y-auto",children:_.fieldsToUpdate.map(({key:Q,oldValue:ee,newValue:me})=>rt("li",{className:"font-mono",children:[rt("span",{className:"font-semibold",children:[Q,":"]})," ",be("span",{className:"text-red-600 dark:text-red-400 line-through",children:typeof ee=="object"?JSON.stringify(ee).substring(0,30)+"...":String(ee).substring(0,30)})," ","\u2192"," ",be("span",{className:"text-green-600 dark:text-green-400",children:typeof me=="string"&&me.length>30?me.substring(0,30)+"...":String(me).substring(0,30)})]},Q))})]}),_.newFields.length>0&&rt("div",{children:[be("p",{className:"font-medium mb-1",children:"New fields to be filled:"}),be("p",{className:"text-sm font-mono",children:_.newFields.join(", ")})]})]})]}),rt(Wc,{children:[be(Yc,{onClick:Oe,children:"Cancel"}),be(Gc,{onClick:Re,children:"Auto-fill"})]})]})})]}):rt(Qo,{orientation:"horizontal",className:"h-full",children:[be(hn,{id:"left-panel",defaultSize:"33%",minSize:250,collapsedSize:0,collapsible:!0,className:"flex flex-col h-full relative",panelRef:ae,children:be("div",{className:"flex h-full flex-col overflow-hidden",children:be(so,{children:Q=>rt(Gi,{children:[be(Er,{isScrolled:Q,activeTab:w,isSearchExpanded:It,searchQuery:v,primaryTabName:"tools",secondaryTabName:"saved",primaryTabTitle:"Tools",secondaryTabTitle:"Saved",primaryCount:H.length,secondaryCount:T.length,primaryIcon:Cf,secondaryIcon:wf,searchPlaceholder:"Search tools...",onSearchExpand:()=>wn(!0),onSearchChange:y,onSearchBlur:pe,onTabSwitch:()=>N(w==="tools"?"saved":"tools"),searchInputRef:mo,onRefresh:a?Ze:void 0,isRefreshing:re}),w==="tools"?be($c,{tools:H,selectedTool:i,onToolSelect:Te,focusedIndex:mn}):be(Hc,{savedRequests:T,selectedRequest:l,onLoadRequest:Pe,onDeleteRequest:$e,focusedIndex:mn})]})})})}),be(Xo,{withHandle:!0}),be(hn,{defaultSize:"67%",children:rt(Qo,{orientation:"vertical",elementRef:z,onLayoutChanged:ut,children:[be(hn,{id:"tool-params",defaultSize:"40%",minSize:`${Sf}px`,collapsible:!0,panelRef:ie,children:be(Fc,{selectedTool:i,toolArgs:m,payloadToSend:Be,isExecuting:tt,isConnected:s,onArgChange:le,onExecute:ce,onSave:We,onCancel:Ne,onBulkPaste:De,autoFilledFields:$,setFields:x,sendEmptyFields:b,onToggleEmpty:de})}),be(Xo,{withHandle:!0}),be(hn,{id:"tool-result",defaultSize:"60%",panelRef:ne,children:be("div",{className:"flex flex-col h-full",children:be(Fi,{results:M,copiedResult:V,serverId:r,readResource:o,onCopy:Fe,onDelete:Y,onFullscreen:q,onMaximize:U,isMaximized:S,onRerunTool:ce,onWidgetHeightChange:Bt})})})]})}),be(Uc,{isOpen:P,requestName:D,defaultPlaceholder:`${i?.name} - ${new Date().toLocaleString()}`,onRequestNameChange:k,onSave:J,onCancel:()=>R(!1)}),be(Vc,{open:_.open,onOpenChange:Q=>{Q||Oe()},children:rt(jc,{children:[rt(qc,{children:[be(Kc,{children:"Auto-fill fields from pasted object?"}),rt(Jc,{children:[_.fieldsToUpdate.length>0&&rt("div",{className:"mb-3",children:[be("p",{className:"font-medium mb-2",children:"The following fields will be updated:"}),be("ul",{className:"text-sm space-y-1 max-h-[200px] overflow-y-auto",children:_.fieldsToUpdate.map(({key:Q,oldValue:ee,newValue:me})=>rt("li",{className:"font-mono",children:[rt("span",{className:"font-semibold",children:[Q,":"]})," ",be("span",{className:"text-red-600 dark:text-red-400 line-through",children:typeof ee=="object"?JSON.stringify(ee).substring(0,30)+"...":String(ee).substring(0,30)})," ","\u2192"," ",be("span",{className:"text-green-600 dark:text-green-400",children:typeof me=="string"&&me.length>30?me.substring(0,30)+"...":String(me).substring(0,30)})]},Q))})]}),_.newFields.length>0&&rt("div",{children:[be("p",{className:"font-medium mb-1",children:"New fields to be filled:"}),be("p",{className:"text-sm font-mono",children:_.newFields.join(", ")})]})]})]}),rt(Wc,{children:[be(Yc,{onClick:Oe,children:"Cancel"}),be(Gc,{onClick:Re,children:"Auto-fill"})]})]})})]})}Tf.displayName="ToolsTab";import{AnimatePresence as Ow,motion as Af}from"motion/react";import{ChevronLeft as zw,FolderOpen as Df}from"lucide-react";import{useCallback as vs,useEffect as tr,useImperativeHandle as Bw,useMemo as Hw,useRef as Lf,useState as In}from"react";import{Brush as uw,Check as mw,Clock as pw,Code as fw,Copy as gw,Download as hw,Maximize as vw,Zap as bw}from"lucide-react";import{useCallback as yw,useMemo as Rf,useState as Pf}from"react";import{ViewRenderer as xw,isViewResource as ww,isViewTool as Cw}from"@mcp-use/client/react";import{jsx as Ve,jsxs as qn}from"react/jsx-runtime";function Nw(e){if("error"in e&&e.error&&typeof e.error=="string")return e.error;if(!("isError"in e&&e.isError))return null;if("contents"in e&&Array.isArray(e.contents)){let t=e.contents.filter(n=>"text"in n).map(n=>n.text).filter(Boolean);if(t.length>0)return t.join(`
|
|
104
|
+
`)}return"An error occurred"}function kw({serverId:e,viewId:t,resourceUri:n,toolOutput:o,toolMetadata:r,readResource:s,customProps:a,displayMode:i,onDisplayModeChange:d}){let l=Rf(()=>({}),[]),u=Ti({serverId:e,viewId:t,resourceUri:n,toolName:n,toolInput:l,toolOutput:o,toolMetadata:r,readResource:s,displayMode:i,onDisplayModeChange:d});if(!u)return Ve(jo,{className:"w-full h-full min-h-[240px]",children:Ve(Kt,{className:"size-5"})});let h=i==="inline"?"w-full h-full flex items-center justify-center relative p-4 min-h-0":"w-full h-full relative p-4",c=a?JSON.stringify(a):"no-custom-props";return Ve(jo,{className:"w-full h-full min-h-[240px]",children:Ve(xw,{viewId:t,toolName:n,toolInput:l,toolOutput:o,customProps:a,className:h,...u},c)})}function Zc({result:e,isLoading:t,previewMode:n,serverId:o,readResource:r,onTogglePreview:s,onCopy:a,onDownload:i,onFullscreen:d,isCopied:l=!1,selectedResource:u,llmConfig:h}){let[c,m]=Pf(null),p=yw(R=>{m(R)},[]),[x,f]=Pf("inline"),b=e?.result&&"contents"in e.result&&Array.isArray(e.result.contents)?e.result.contents[0]?._meta||{}:{},g={...e?.resourceAnnotations,...b},v=Rf(()=>{let R=g?.["mcp-use/propsSchema"];if(!R)return[];let D=R.def?.shape;return D?Object.entries(D).filter(([,k])=>{let S=k?.def?.type??k?.type;return S!=="optional"&&S!=="default"}).map(([k])=>k):R.required??[]},[g]),y=Cw(g)?"mcp-apps":null,w=e?.result&&"contents"in e.result&&Array.isArray(e.result.contents)&&e.result.contents.some(R=>ww(R.mimeType)),N=g?.ui?.resourceUri||b?.ui?.resourceUri||(w?e.uri:void 0),T=(y==="mcp-apps"||w)&&!!N,L=v.length>0&&!c;if(t)return Ve("div",{className:"flex absolute left-0 top-0 items-center justify-center w-full h-full",children:Ve(Kt,{className:"size-5"})});if(!e)return qn("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[Ve("p",{className:"text-gray-500 dark:text-gray-400 mb-2",children:"Select a resource to view its contents"}),Ve("p",{className:"text-xs text-gray-400 dark:text-gray-500",children:"Choose a resource from the list to see its data"})]});let P=e.error||(e.result?Nw(e.result):null);return P?Ve("div",{className:"p-4",children:qn("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded p-3",children:[Ve("p",{className:"text-red-800 dark:text-red-300 font-medium",children:"Error:"}),Ve("p",{className:"text-red-700 dark:text-red-400 text-sm",children:P})]})}):qn("div",{className:"flex flex-col h-full",children:[qn("div",{className:"shrink-0 px-4 py-3 border-b border-gray-200 dark:border-zinc-700 flex items-center justify-between",children:[qn("div",{className:"flex items-center gap-2",children:[qn("div",{className:"flex items-center gap-1",children:[Ve(pw,{className:"h-3 w-3 text-gray-400"}),Ve("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:new Date(e.timestamp).toLocaleTimeString()})]}),(()=>{let R=e?.duration??e.result?.duration??e.result?.metrics?.durationMs;return R!==void 0?qn("div",{className:"flex items-center gap-1",children:[Ve(bw,{className:"h-3 w-3 text-gray-400"}),qn("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:[R,"ms"]})]}):null})(),T&&Ve(Jt,{variant:"outline",className:"text-xs bg-green-50 dark:bg-green-900/20 border-none border-green-200 dark:border-green-800/50 text-green-600 dark:text-green-400",children:"MCP Apps"})]}),qn("div",{className:"flex items-center gap-1",children:[T&&qn(E,{variant:"ghost",size:"sm",onClick:s,className:n?"":"text-purple-600 dark:text-purple-400",children:[n?Ve(fw,{className:"h-4 w-4 mr-1"}):Ve(uw,{className:"h-4 w-4 mr-1"}),n?"JSON":"Preview"]}),Ve(E,{variant:"ghost",size:"sm",onClick:a,children:l?Ve(mw,{className:"h-4 w-4"}):Ve(gw,{className:"h-4 w-4"})}),Ve(E,{variant:"ghost",size:"sm",onClick:i,children:Ve(hw,{className:"h-4 w-4"})}),Ve(E,{variant:"ghost",size:"sm",onClick:d,children:Ve(vw,{className:"h-4 w-4"})})]})]}),Ve("div",{className:"flex-1 overflow-y-auto relative",children:T&&o&&r&&N?n?qn("div",{className:"flex flex-1 h-full relative flex-col min-h-0","data-testid":"resource-widget-preview",children:[Ve("div",{className:"absolute top-2 right-2 z-10 flex items-center gap-2",children:Ve(Hi,{toolCallId:`resource-${e.timestamp}`,displayMode:x,onDisplayModeChange:f,propsContext:"resource",resourceUri:e.uri,resourceAnnotations:g,llmConfig:h||null,resource:u||null,onPropsChange:p,requiredProps:v.length>0&&!c?v:void 0})}),L?Ve("div",{className:"flex items-center justify-center w-full h-full min-h-[200px] rounded-xl border-2 border-dashed border-gray-300 dark:border-zinc-600 bg-gray-50 dark:bg-zinc-800/50 m-4",children:Ve("p",{className:"text-sm text-gray-500 dark:text-gray-400 text-center px-6",children:"This widget requires props, set or generate them in the props debugger"})}):Ve(kw,{serverId:o,viewId:`resource-${e.timestamp}`,resourceUri:N,toolOutput:e.result,toolMetadata:g,readResource:r,customProps:c||void 0,displayMode:x,onDisplayModeChange:f})]}):Ve("div",{className:"px-4 pt-4","data-testid":"resource-result-json",children:Ve(wt,{data:e.result,filename:`resource-${e.uri.replace(/[^a-zA-Z0-9]/g,"-")}-mcp-apps-${Date.now()}.json`})}):Ve("div",{className:"px-4 pt-4","data-testid":"resource-result-json",children:Ve(wt,{data:e.result,filename:`resource-${e.uri.replace(/[^a-zA-Z0-9]/g,"-")}-${Date.now()}.json`})})})]})}import{Database as Sw}from"lucide-react";import{jsx as Dr,jsxs as Mf}from"react/jsx-runtime";function ed({resources:e,selectedResource:t,onResourceSelect:n,focusedIndex:o}){return e.length===0?Mf("div",{className:"flex flex-1 flex-col items-center justify-center p-4 text-center",children:[Dr(Sw,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),Dr("p",{className:"text-gray-500 dark:text-gray-400",children:"No resources available"})]}):Dr("div",{children:e.map((r,s)=>{let a=[r.description,r.mimeType&&Dr("span",{className:"font-mono",children:r.mimeType},"mime")].filter(Boolean);return Dr(jn,{id:`resource-${r.uri}`,"data-testid":`resource-item-${r.name}`,isSelected:t?.uri===r.uri,isFocused:o===s,title:r.name,description:a.length>0?Mf("span",{className:"flex flex-col gap-1",children:[r.description&&Dr("span",{children:r.description}),r.mimeType&&Dr("span",{className:"text-xs text-gray-500 dark:text-gray-500 font-mono",children:r.mimeType})]}):void 0,onClick:()=>n(r)},r.uri)})})}import{useCallback as hs,useEffect as nd,useRef as _w,useState as Wn}from"react";import{DEFAULT_OLLAMA_BASE_URL as Tw}from"@mcp-use/agent";var td={openai:"gpt-5.6-terra","openai-compatible":"",anthropic:"claude-haiku-4-5-20251001",google:"gemini-2.5-flash",openrouter:"meta-llama/llama-3.1-8b-instruct:free",ollama:"qwen3"},Pw={ollama:Tw};function Lr(e){return e!=="ollama"&&e!=="openai-compatible"}function So(e){return e==="ollama"||e==="openai-compatible"}function er(e){return Pw[e]??""}function Yi(e){let t=0;for(let n=0;n<e.length;n++){let o=e.charCodeAt(n);t=(t<<5)-t+o,t=t&t}return Math.abs(t).toString(16)}var Rw=10*1024*1024,Mw=20*1024*1024,Iw=["image/png","image/jpeg","image/jpg","image/gif","image/webp","image/svg+xml"];function Ew(e){return Iw.includes(e.type)}function Aw(e){return e.size<=Rw}function Qi(e){return e.reduce((n,o)=>n+(o.size||0),0)<=Mw}function Dw(e){return new Promise((t,n)=>{let o=new FileReader;o.onload=()=>{let r=o.result,s=r.includes(",")?r.split(",")[1]:r;t(s)},o.onerror=()=>{n(new Error(`Failed to read file: ${e.name}`))},o.readAsDataURL(e)})}async function Xi(e){if(!Ew(e))throw new Error(`Unsupported file type: ${e.type}. Only images are supported.`);if(!Aw(e))throw new Error(`File too large: ${e.name}. Maximum size is 10MB.`);return{type:"image",data:await Dw(e),mimeType:e.type,name:e.name,size:e.size}}var If="mcp-inspector:chat-mode";function Lw(){try{let e=localStorage.getItem(If);if(e==="byok"||e==="managed")return e}catch{}return null}function Zi(e){try{localStorage.setItem(If,e)}catch{}}function Ef(e,t){let n=Lw();if(n==="byok")return!0;if(n==="managed"||e)return!1;try{if(localStorage.getItem("mcp-inspector-llm-config"))return!0}catch{}return!!t}function ua({mcpServerUrl:e}){let[t,n]=Wn(null),[o,r]=Wn(null),[s,a]=Wn(!1),[i,d]=Wn("openai"),[l,u]=Wn(""),[h,c]=Wn(td.openai),[m,p]=Wn(er("openai")),x=hs(()=>{let A=localStorage.getItem("mcp-inspector-api-keys");if(A)try{return JSON.parse(A)}catch(_){return console.error("Failed to load API keys:",_),{}}return{}},[]),f=hs(A=>{localStorage.setItem("mcp-inspector-api-keys",JSON.stringify(A))},[]),b=hs(()=>{let A=localStorage.getItem("mcp-inspector-base-urls");if(A)try{return JSON.parse(A)}catch(_){return console.error("Failed to load base URLs:",_),{}}return{}},[]),g=hs(A=>{localStorage.setItem("mcp-inspector-base-urls",JSON.stringify(A))},[]),[v,y]=Wn("none"),[w,N]=Wn(""),[T,L]=Wn(""),[P,R]=Wn("");nd(()=>{let A=()=>{let $=localStorage.getItem("mcp-inspector-llm-config"),oe=x(),ae=b();if($)try{let ie=JSON.parse($);n(ie),d(ie.provider),u(oe[ie.provider]||ie.apiKey||""),c(ie.model),p(ae[ie.provider]||ie.baseUrl||er(ie.provider))}catch(ie){console.error("Failed to load LLM config:",ie)}};A();let _=()=>{A()},K=$=>{($.key==="mcp-inspector-llm-config"||$.key==="mcp-inspector-api-keys"||$.key==="mcp-inspector-base-urls")&&A()};return window.addEventListener("llm-config-updated",_),window.addEventListener("storage",K),()=>{window.removeEventListener("llm-config-updated",_),window.removeEventListener("storage",K)}},[x,b]),nd(()=>{let A=localStorage.getItem("mcp-inspector-auth-config");if(A)try{let _=JSON.parse(A);r(_),y(_.type),_.username&&N(_.username),_.password&&L(_.password),_.token&&R(_.token)}catch(_){console.error("Failed to load auth config:",_)}else try{let _="mcp:auth",K=Yi(e),$=`${_}_${K}_tokens`;localStorage.getItem($)&&(r({type:"oauth"}),y("oauth"))}catch(_){console.error("Failed to check for OAuth tokens:",_)}},[e]);let D=_w(i);nd(()=>{let A=D.current!==i;D.current=i,A&&!So(i)&&c(td[i]);let _=x(),K=b();u(_[i]||""),p(K[i]||er(i))},[i,x,b]);let k=hs(()=>{if(Lr(i)&&!l.trim()||So(i)&&!m.trim())return!1;let A=x();if(A[i]=l,f(A),So(i)&&m.trim()){let $=b();$[i]=m.trim(),g($)}let _={provider:i,apiKey:l,model:h,...So(i)?{baseUrl:m.trim()||er(i)}:{}},K={type:v,...v==="basic"&&{username:w.trim(),password:T.trim()},...v==="bearer"&&{token:P.trim()}};n(_),r(K),localStorage.setItem("mcp-inspector-llm-config",JSON.stringify(_)),localStorage.setItem("mcp-inspector-auth-config",JSON.stringify(K)),window.dispatchEvent(new CustomEvent("llm-config-updated"));try{Lt(new Za({provider:i,model:h})).catch(()=>{})}catch{}return a(!1),!0},[i,l,h,m,v,w,T,P,x,f,b,g]),S=hs(()=>{n(null),r(null);let A=x();delete A[i],f(A);let _=b();delete _[i],g(_),u(""),p(er(i)),N(""),L(""),R(""),y("none"),localStorage.removeItem("mcp-inspector-llm-config"),localStorage.removeItem("mcp-inspector-auth-config"),Zi("managed")},[i,x,f,b,g]);return{llmConfig:t,authConfig:o,configDialogOpen:s,setConfigDialogOpen:a,tempProvider:i,setTempProvider:d,tempApiKey:l,setTempApiKey:u,tempModel:h,setTempModel:c,tempBaseUrl:m,setTempBaseUrl:p,tempAuthType:v,saveLLMConfig:k,clearConfig:S}}import{Fragment as od,jsx as Ct,jsxs as nr}from"react/jsx-runtime";function _f({ref:e,resources:t,readResource:n,serverId:o,isConnected:r,mcpServerUrl:s,refreshResources:a}){let[i,d]=In(!1),[l,u]=In(null),{selectedResourceUri:h,setSelectedResourceUri:c}=wo(),{llmConfig:m}=ua({mcpServerUrl:s}),[p,x]=In(null),[f,b]=In(!1),[g,v]=In(""),[y]=In("resources"),[w,N]=In(!0),[T,L]=In(!1),[P,R]=In(-1),[D,k]=In(!1),S=Lf(null),A=Lf(null),[_,K]=In(!1),[$,oe]=In("list");tr(()=>{let U=()=>{K(window.innerWidth<1024)};return U(),window.addEventListener("resize",U),()=>window.removeEventListener("resize",U)},[]),tr(()=>{oe(l?"detail":"list")},[l]),Bw(e,()=>({focusSearch:()=>{L(!0),setTimeout(()=>{S.current&&S.current.focus()},0)},blurSearch:()=>{v(""),L(!1),S.current&&S.current.blur()}})),tr(()=>{T&&S.current&&S.current.focus()},[T]);let ae=vs(()=>{g.trim()||L(!1)},[g]),ie=vs(async()=>{if(a){d(!0);try{await a()}finally{d(!1)}}},[a]),ne=Hw(()=>{if(!g)return t;let U=g.toLowerCase();return t.filter(H=>H.name.toLowerCase().includes(U)||H.description?.toLowerCase().includes(U)||H.uri.toLowerCase().includes(U))},[t,g]),z=vs(async U=>{if(u(U),r){b(!0);let H=Date.now();try{let Te=await n(U.uri);Lt(new Us({resourceUri:U.uri,serverId:o,success:!0})).catch(()=>{}),x({uri:U.uri,result:Te,timestamp:H,resourceAnnotations:{...U.annotations,...U._meta||{}}})}catch(Te){Lt(new Us({resourceUri:U.uri,serverId:o,success:!1,error:Te instanceof Error?Te.message:"Unknown error"})).catch(()=>{}),x({uri:U.uri,result:{contents:[],_meta:{}},error:Te instanceof Error?Te.message:"Unknown error",timestamp:H,resourceAnnotations:{...U.annotations,...U._meta||{}}})}finally{b(!1)}}},[n,o,r]);tr(()=>{R(-1)},[g,y]),tr(()=>{let U=H=>{let Te=H.target;if(Te.tagName==="INPUT"||Te.tagName==="TEXTAREA"||Te.contentEditable==="true"||H.metaKey||H.ctrlKey||H.altKey)return;let le=ne;if(H.key==="ArrowDown")H.preventDefault(),R(de=>{let De=de+1;return De>=le.length?0:De});else if(H.key==="ArrowUp")H.preventDefault(),R(de=>{let De=de-1;return De<0?le.length-1:De});else if(H.key==="Enter"&&P>=0){H.preventDefault();let de=ne[P];de&&z(de)}};return document.addEventListener("keydown",U),()=>document.removeEventListener("keydown",U)},[P,ne,z]),tr(()=>{if(P>=0){let U=`resource-${ne[P]?.uri}`,H=document.getElementById(U);H&&H.scrollIntoView({behavior:"smooth",block:"nearest"})}},[P,ne]),tr(()=>{if(h&&t.length>0){let U=t.find(H=>H.uri===h);U&&l?.uri!==U.uri&&(c(null),setTimeout(()=>{z(U);let H=document.getElementById(`resource-${U.uri}`);H&&H.scrollIntoView({behavior:"smooth",block:"nearest"})},100))}},[h,t,l,z,c]),tr(()=>{if(l){let U=t.find(H=>H.uri===l.uri);U&&U!==l&&(U.description!==l.description||U.mimeType!==l.mimeType||U.name!==l.name)&&u(U)}},[t,l]);let O=vs(async()=>{if(p)try{await Xe(JSON.stringify(p.result,null,2)),k(!0),setTimeout(()=>k(!1),2e3)}catch(U){console.error("[ResourcesTab] Failed to copy result:",U)}},[p]),W=vs(()=>{if(p)try{let U=new globalThis.Blob([JSON.stringify(p.result,null,2)],{type:"application/json"}),H=URL.createObjectURL(U),Te=document.createElement("a");Te.href=H,Te.download=`resource-${Date.now()}.json`,document.body.appendChild(Te),Te.click(),document.body.removeChild(Te),URL.revokeObjectURL(H)}catch(U){console.error("[ResourcesTab] Failed to download result:",U)}},[p]),j=vs(async()=>{if(A.current)try{document.fullscreenElement?await document.exitFullscreen():await A.current.requestFullscreen()}catch(U){console.error("[ResourcesTab] Failed to toggle fullscreen:",U)}},[]);return _?nr("div",{className:"h-full flex flex-col overflow-hidden relative bg-background",children:[$!=="list"&&nr("div",{className:"flex items-center gap-2 p-2 border-b shrink-0 bg-background z-10",children:[Ct(E,{variant:"ghost",size:"sm",onClick:()=>{u(null),oe("list")},className:"p-0 h-8 w-8",children:Ct(zw,{className:"h-4 w-4"})}),nr("div",{className:"flex items-center text-sm font-medium",children:[Ct("button",{onClick:()=>{u(null),oe("list")},className:"text-muted-foreground hover:text-foreground hover:underline cursor-pointer",children:"Resources"}),$==="detail"&&nr(od,{children:[Ct("span",{className:"mx-2 text-muted-foreground",children:"/"}),Ct("span",{className:"text-foreground",children:"Content"})]})]})]}),Ct("div",{className:"flex-1 relative overflow-hidden",children:nr(Ow,{initial:!1,mode:"popLayout",children:[$==="list"&&Ct(Af.div,{initial:{x:"-100%"},animate:{x:0},exit:{x:"-100%"},transition:{type:"spring",stiffness:300,damping:30},className:"absolute inset-0 flex flex-col bg-background z-0",children:Ct(so,{children:U=>nr(od,{children:[Ct(qi,{isScrolled:U,title:"Resources",icon:Df,count:ne.length,isSearchExpanded:T,searchQuery:g,searchPlaceholder:"Search resources...",onSearchExpand:()=>L(!0),onSearchChange:v,onSearchBlur:ae,searchInputRef:S,onRefresh:a?ie:void 0,isRefreshing:i}),Ct(ed,{resources:ne,selectedResource:l,onResourceSelect:z,focusedIndex:P})]})})},"list"),$==="detail"&&Ct(Af.div,{initial:{x:"100%"},animate:{x:0},exit:{x:"100%"},transition:{type:"spring",stiffness:300,damping:30},className:"absolute inset-0 bg-white dark:bg-zinc-900 z-10",children:Ct("div",{ref:A,className:"h-full",children:Ct(Zc,{result:p,isLoading:f,previewMode:w,serverId:o,readResource:n,onTogglePreview:()=>N(!w),onCopy:O,onDownload:W,onFullscreen:j,isCopied:D,selectedResource:l,llmConfig:m})})},"detail")]})})]}):nr(Qo,{orientation:"horizontal",className:"h-full",children:[Ct(hn,{defaultSize:"33%",children:Ct("div",{className:"flex h-full flex-col overflow-hidden border-r dark:border-zinc-700",children:Ct(so,{children:U=>nr(od,{children:[Ct(qi,{isScrolled:U,title:"Resources",icon:Df,count:ne.length,isSearchExpanded:T,searchQuery:g,searchPlaceholder:"Search resources...",onSearchExpand:()=>L(!0),onSearchChange:v,onSearchBlur:ae,searchInputRef:S,onRefresh:a?ie:void 0,isRefreshing:i}),Ct(ed,{resources:ne,selectedResource:l,onResourceSelect:z,focusedIndex:P})]})})})}),Ct(Xo,{}),Ct(hn,{defaultSize:"67%",children:Ct("div",{ref:A,className:"h-full bg-white dark:bg-zinc-900",children:Ct(Zc,{result:p,isLoading:f,previewMode:w,serverId:o,readResource:n,onTogglePreview:()=>N(!w),onCopy:O,onDownload:W,onFullscreen:j,isCopied:D,selectedResource:l,llmConfig:m})})})]})}_f.displayName="ResourcesTab";import{AnimatePresence as bC,motion as hd}from"motion/react";import{ChevronLeft as yC,Clock as Vf,MessageSquare as jf}from"lucide-react";import{useCallback as Po,useEffect as Ro,useImperativeHandle as xC,useRef as wC,useState as An}from"react";import{Play as Uw,Save as Fw}from"lucide-react";import{useEffect as $w}from"react";import{jsx as ln,jsxs as En}from"react/jsx-runtime";function Of({selectedPrompt:e,promptArgs:t,onArgChange:n}){let o=e?.arguments||[];if(!(o.length>0))return ln("div",{className:"flex items-center justify-center h-32 text-gray-500 dark:text-gray-400 text-sm",children:"No arguments required"});let s=a=>{let i=a.name,d=t[i],l=typeof d=="string"?d:JSON.stringify(d);return a.type==="boolean"?En("div",{className:"space-y-2",children:[En("div",{children:[En(nt,{htmlFor:i,className:"text-sm font-medium",children:[i,a.required&&ln("span",{className:"text-red-500 ml-1",children:"*"})]}),a.description&&ln("p",{className:"mt-0.5 text-xs text-gray-500 dark:text-gray-400",children:a.description})]}),ln("input",{id:i,type:"checkbox",checked:!!d,onChange:u=>n(i,u.target.checked),className:"rounded","aria-label":`Toggle ${i}`})]},i):a.type==="number"?En("div",{className:"space-y-2",children:[En("div",{children:[En(nt,{htmlFor:i,className:"text-sm font-medium",children:[i,a.required&&ln("span",{className:"text-red-500 ml-1",children:"*"})]}),a.description&&ln("p",{className:"mt-0.5 text-xs text-gray-500 dark:text-gray-400",children:a.description})]}),ln(Ge,{id:i,type:"number",value:Number(d)||0,onChange:u=>n(i,Number(u.target.value)),placeholder:`Enter ${i}`})]},i):a.type==="array"||a.type==="object"?En("div",{className:"space-y-2",children:[En("div",{children:[En(nt,{htmlFor:i,className:"text-sm font-medium",children:[i,a.required&&ln("span",{className:"text-red-500 ml-1",children:"*"})]}),a.description&&ln("p",{className:"mt-0.5 text-xs text-gray-500 dark:text-gray-400",children:a.description})]}),ln(to,{id:i,value:l,onChange:u=>{try{let h=JSON.parse(u.target.value);n(i,h)}catch{n(i,u.target.value)}},placeholder:`Enter ${i} as JSON`,className:"font-mono text-sm min-h-[100px]"})]},i):En("div",{className:"space-y-2",children:[En("div",{children:[En(nt,{htmlFor:i,className:"text-sm font-medium",children:[i,a.required&&ln("span",{className:"text-red-500 ml-1",children:"*"})]}),a.description&&ln("p",{className:"mt-0.5 text-xs text-gray-500 dark:text-gray-400",children:a.description})]}),ln(Ge,{id:i,"data-testid":`prompt-param-${i}`,value:l,onChange:u=>n(i,u.target.value),placeholder:`Enter ${i}`})]},i)};return ln("div",{className:"space-y-4",children:o.map(a=>s(a))})}import{Fragment as zf,jsx as en,jsxs as or}from"react/jsx-runtime";function rd({selectedPrompt:e,promptArgs:t,isExecuting:n,isConnected:o,onArgChange:r,onExecute:s,onSave:a}){return $w(()=>{let i=d=>{(d.metaKey||d.ctrlKey)&&d.key==="Enter"&&e&&!n&&o&&(d.preventDefault(),s())};return document.addEventListener("keydown",i),()=>document.removeEventListener("keydown",i)},[e,n,o,s]),e?or("div",{className:"flex flex-col h-full",children:[en("div",{className:"flex-shrink-0 p-3 sm:p-6 pt-3 pb-4 pr-3",children:or("div",{children:[or("div",{className:"flex flex-row items-center justify-between mb-0 gap-2",children:[en("h3",{className:"text-base sm:text-lg font-semibold",children:e.name}),or("div",{className:"flex gap-2 flex-shrink-0",children:[en(E,{onClick:s,disabled:n||!o,size:"sm",className:js,"data-testid":"prompt-execute-button",children:n?or(zf,{children:[en(Kt,{}),en("span",{className:"hidden sm:inline",children:"Executing..."})]}):or(zf,{children:[en(Uw,{}),en("span",{className:"hidden sm:inline",children:"Execute"}),en("span",{className:nm,children:"\u2318\u21B5"})]})}),or(E,{variant:"outline",onClick:a,disabled:n,size:"sm",className:C(vr,"gap-2"),children:[en(Fw,{}),en("span",{className:"hidden sm:inline",children:"Save"})]})]})]}),e.description&&en("p",{className:"text-sm text-gray-600 dark:text-gray-400 leading-relaxed mt-2",children:e.description})]})}),en("div",{className:"flex-1 overflow-y-auto px-3 sm:px-6 pb-4 pr-3",children:en(Of,{selectedPrompt:e,promptArgs:t,onArgChange:r})})]}):or("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[en("p",{className:"text-gray-500 dark:text-gray-400 mb-2",children:"Select a prompt to get started"}),en("p",{className:"text-xs text-gray-400 dark:text-gray-500",children:"Choose a prompt from the list to view its details and execute it"})]})}import{Check as sC,Copy as aC,History as iC,Maximize as Uf,Minimize as lC,Trash2 as cC,Zap as dC}from"lucide-react";import{useEffect as Ff,useState as md}from"react";import{Check as Zw,Copy as eC}from"lucide-react";import{useState as tC}from"react";import{Check as jw,Copy as qw}from"lucide-react";import Ww from"markdown-to-jsx";import{useState as Kw}from"react";import{Checkbox as Bf}from"@base-ui/react/checkbox";import{CheckIcon as Vw}from"lucide-react";import{jsx as sd}from"react/jsx-runtime";function ma({className:e,...t}){return sd(Bf.Root,{"data-slot":"checkbox",className:C("peer relative flex size-4 shrink-0 items-center justify-center rounded-[4px] border border-input shadow-xs transition-shadow outline-none group-has-disabled/field:opacity-50 after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 aria-invalid:aria-checked:border-primary dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:border-primary data-checked:bg-primary data-checked:text-primary-foreground dark:data-checked:bg-primary",e),...t,children:sd(Bf.Indicator,{"data-slot":"checkbox-indicator",className:"grid place-content-center text-current transition-none [&>svg]:size-3.5",children:sd(Vw,{})})})}import*as Or from"react";import{jsx as _r}from"react/jsx-runtime";var ad=Or.forwardRef(({className:e,...t},n)=>_r("div",{className:"relative w-full overflow-auto",children:_r("table",{ref:n,className:C("w-full caption-bottom text-sm",e),...t})}));ad.displayName="Table";var id=Or.forwardRef(({className:e,...t},n)=>_r("thead",{ref:n,className:C("[&_tr]:border-b",e),...t}));id.displayName="TableHeader";var ld=Or.forwardRef(({className:e,...t},n)=>_r("tbody",{ref:n,className:C("[&_tr:last-child]:border-0",e),...t}));ld.displayName="TableBody";var cd=Or.forwardRef(({className:e,...t},n)=>_r("tr",{ref:n,className:C("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",e),...t}));cd.displayName="TableRow";var dd=Or.forwardRef(({className:e,...t},n)=>_r("th",{ref:n,className:C("h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",e),...t}));dd.displayName="TableHead";var ud=Or.forwardRef(({className:e,...t},n)=>_r("td",{ref:n,className:C("p-4 align-middle [&:has([role=checkbox])]:pr-0",e),...t}));ud.displayName="TableCell";import{Fragment as Xw,jsx as Le,jsxs as pa}from"react/jsx-runtime";function Jw({children:e,className:t}){let n="text";if(t){let i=t.match(/(?:lang(?:uage)?-)(\w+)/);i?n=i[1]:n=t.replace(/^(lang-|language-)\s*/,"").trim()}let[o,r]=Kw(!1),s=String(e).trim();return pa("div",{className:"my-4 relative group/code bg-muted rounded-md p-0",children:[pa("div",{className:"flex items-center justify-between mb-2 absolute top-0 left-0 w-full",children:[Le("div",{className:"text-[10px] font-mono text-muted-foreground/50 bg-transparent px-2 py-0 rounded",children:n}),Le("button",{className:"opacity-0 group-hover/code:opacity-100 transition-opacity text-muted-foreground hover:text-foreground text-xs flex items-center gap-1 px-2 py-1 rounded hover:bg-muted",onClick:async()=>{await Xe(s),r(!0),setTimeout(()=>r(!1),2e3)},title:"Copy code",children:o?Le(jw,{className:"h-3.5 w-3.5"}):Le(qw,{className:"h-3.5 w-3.5"})})]}),Le("pre",{className:"text-sm m-0 p-4 pt-8 rounded-lg font-mono overflow-x-auto",style:{background:"var(--muted)"},children:Le("code",{children:s})})]})}function Gw({children:e}){return Le("code",{className:"bg-muted px-1.5 py-0.5 rounded text-sm font-mono",children:e})}function Yw({children:e,className:t}){return t?Le(Jw,{className:t,children:e}):Le(Gw,{children:e})}function Qw({children:e}){if(typeof e=="string"){let t=e.match(/^\[([ xX])\]\s*(.*)/);if(t){let n=t[1].toLowerCase()==="x",o=t[2];return pa("li",{className:"text-foreground flex items-center gap-2",children:[Le(ma,{checked:n,disabled:!0}),Le("span",{children:o})]})}}if(Array.isArray(e)&&e.length>0){let t=e[0];if(typeof t=="string"){let n=t.match(/^\[([ xX])\]\s*(.*)/);if(n){let o=n[1].toLowerCase()==="x",r=n[2];return pa("li",{className:"text-foreground flex items-center gap-2",children:[Le(ma,{checked:o,disabled:!0}),pa("span",{children:[r,e.slice(1)]})]})}}}return Le("li",{className:"text-foreground",children:e})}function bs({content:e,className:t}){let n=Le(Ww,{options:{overrides:{code:Yw,pre:({children:o})=>Le(Xw,{children:o}),h1:({children:o})=>Le("h1",{className:"text-xl font-bold text-foreground mb-2 mt-4",children:o}),h2:({children:o})=>Le("h2",{className:"text-lg font-bold text-foreground mb-2 mt-4",children:o}),h3:({children:o})=>Le("h3",{className:"text-base font-bold text-foreground mb-2 mt-4",children:o}),h4:({children:o})=>Le("h4",{className:"text-sm font-bold text-foreground mb-2 mt-4",children:o}),h5:({children:o})=>Le("h5",{className:"text-sm font-bold text-foreground mb-2 mt-4",children:o}),h6:({children:o})=>Le("h6",{className:"text-sm font-bold text-foreground mb-2 mt-4",children:o}),p:({children:o})=>Le("p",{className:"text-foreground mb-2 leading-relaxed",children:o}),ul:({children:o})=>Le("ul",{className:"list-disc list-outside pl-6 mb-3 space-y-1",children:o}),ol:({children:o})=>Le("ol",{className:"list-decimal list-outside pl-6 mb-3 space-y-1",children:o}),li:Qw,table:({children:o})=>Le("div",{className:"my-4",children:Le(ad,{children:o})}),thead:({children:o})=>Le(id,{children:o}),tbody:({children:o})=>Le(ld,{children:o}),tr:({children:o})=>Le(cd,{children:o}),th:({children:o})=>Le(dd,{children:o}),td:({children:o})=>Le(ud,{children:o}),blockquote:({children:o})=>Le("blockquote",{className:"border-l-4 border-muted-foreground pl-4 italic text-muted-foreground mb-3",children:o}),a:({children:o,href:r})=>Le("a",{href:r,className:"text-primary hover:underline",target:"_blank",rel:"noopener noreferrer",children:o}),strong:({children:o})=>Le("strong",{className:"font-semibold text-foreground",children:o}),em:({children:o})=>Le("em",{className:"italic text-foreground",children:o}),img:({src:o,alt:r})=>Le("img",{src:o,alt:r||"",className:"max-w-full max-h-[500px] object-contain rounded-lg my-4 border border-border",loading:"lazy"}),hr:()=>Le("hr",{className:"my-4 border-t border-border"})}},children:e});return t?Le("div",{className:t,children:n}):n}import{jsx as cn,jsxs as ys}from"react/jsx-runtime";function nC(e){switch(e){case"system":return"default";case"user":return"outline";case"assistant":return"secondary";default:return"outline"}}function oC(e){return e.charAt(0).toUpperCase()+e.slice(1)}function rC(e){return typeof e=="string"?e:e.text?e.text:e.type==="resource"&&e.resource?.text?e.resource.text:e.type==="image"?`[Image: ${e.mimeType||"unknown type"}]`:JSON.stringify(e,null,2)}function Hf({message:e,index:t}){let[n,o]=tC(!1),r=async()=>{let a=rC(e.content);await Xe(a),o(!0),setTimeout(()=>o(!1),2e3)},s=()=>{let a=e.content;return typeof a=="string"?cn(bs,{content:a}):a.type==="text"&&a.text?cn(bs,{content:a.text}):a.type==="image"?ys("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[ys("span",{className:"font-mono bg-muted px-2 py-1 rounded",children:["Image: ",a.mimeType||"unknown type"]}),a.data&&cn("img",{src:`data:${a.mimeType};base64,${a.data}`,alt:"Prompt image",className:"max-w-full max-h-[300px] object-contain rounded-lg border border-border mt-2"})]}):a.type==="resource"&&a.resource?ys("div",{className:"space-y-2",children:[ys("div",{className:"flex items-center gap-2 text-sm",children:[cn("span",{className:"text-muted-foreground font-medium",children:"Resource:"}),cn("code",{className:"bg-muted px-2 py-0.5 rounded text-xs font-mono",children:a.resource.uri})]}),a.resource.text&&cn("div",{className:"mt-2",children:cn(bs,{content:a.resource.text})})]}):cn("pre",{className:"bg-muted p-3 rounded-lg text-sm overflow-x-auto",children:cn("code",{children:JSON.stringify(a,null,2)})})};return ys("div",{className:"border border-border rounded-lg overflow-hidden bg-white dark:bg-zinc-900",children:[ys("div",{className:"flex items-center justify-between px-4 py-2 bg-muted/30 border-b border-border",children:[cn(Jt,{variant:nC(e.role),children:oC(e.role)}),cn(E,{variant:"ghost",size:"sm",onClick:r,className:"h-6 px-2",title:"Copy message content",children:n?cn(Zw,{className:"h-3.5 w-3.5"}):cn(eC,{className:"h-3.5 w-3.5"})})]}),cn("div",{className:"px-4 py-3","data-testid":`prompt-message-content-${t}`,children:s()})]})}import{jsx as Ue,jsxs as To}from"react/jsx-runtime";function uC(e){let n=Date.now()-e,o=Math.floor(n/1e3),r=Math.floor(o/60),s=Math.floor(r/60),a=Math.floor(s/24);return o<10?"now":o<60?`${o}s ago`:r<60?`${r}m ago`:s<24?`${s}h ago`:`${a}d ago`}function mC(e){return"isError"in e&&!e.isError?null:"error"in e&&e.error?String(e.error):"isError"in e&&e.isError?"An error occurred":null}function pd({results:e,copiedResult:t,previewMode:n=!0,onCopy:o,onDelete:r,onFullscreen:s,onTogglePreview:a,onMaximize:i,isMaximized:d=!1}){let[l,u]=md(0),[h,c]=md(""),[m,p]=md(!0),x=e[0],f=x?e.filter(w=>w.promptName===x.promptName):[],b=f[l]||f[0],g=e.findIndex(w=>w===b);if(Ff(()=>{f.length>0&&l>=f.length&&u(0)},[f.length,l]),Ff(()=>{let w=()=>{b&&c(uC(b.timestamp))};w();let N=setInterval(w,1e3);return()=>clearInterval(N)},[b]),e.length===0)return Ue("div",{className:"flex flex-col h-full bg-white dark:bg-black border-t dark:border-zinc-700",children:Ue("div",{className:"flex-1 overflow-y-auto h-full",children:Ue("div",{className:"flex items-center justify-center h-full",children:Ue("div",{className:"text-center",children:Ue(ms,{vertical:!0,noBorder:!0,message:"No Results yet"})})})})});let v=b.error||mC(b.result),y="messages"in b.result&&Array.isArray(b.result.messages);return Ue("div",{className:"flex flex-col h-full bg-white dark:bg-black border-t dark:border-zinc-700",children:Ue("div",{className:"flex-1 overflow-y-auto h-full",children:To("div",{className:"space-y-0 flex-1 h-full flex flex-col",children:[To("div",{className:"flex items-center gap-2 px-4 pt-2 border-b border-gray-200 dark:border-zinc-600 pb-2",children:[Ue("h3",{className:"text-sm font-medium hidden sm:block",children:"Response"}),b.duration!==void 0&&To("div",{className:"hidden sm:flex items-center gap-1",children:[Ue(dC,{className:"h-3 w-3 text-gray-400"}),To("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:[b.duration,"ms"]})]}),y&&Ue("div",{className:"flex items-center gap-4 sm:ml-4",children:To("div",{className:"flex items-center gap-2",children:[Ue("button",{onClick:()=>p(!0),className:`text-xs font-medium ${m?"text-black dark:text-white":"text-zinc-500 dark:text-zinc-400"}`,children:"Formatted"}),Ue("span",{className:"text-xs text-zinc-400",children:"|"}),Ue("button",{onClick:()=>p(!1),className:`text-xs font-medium ${m?"text-zinc-500 dark:text-zinc-400":"text-black dark:text-white"}`,children:"Raw"})]})}),To("div",{className:"ml-auto flex items-center gap-1",children:[f.length>1&&To("div",{className:"flex items-center gap-2 mr-2",children:[Ue(iC,{className:"h-3 w-3 text-gray-400"}),To(kn,{value:l.toString(),onValueChange:w=>u(parseInt(w)),children:[Ue($n,{className:"h-7 w-[120px] text-xs",children:Ue(Un,{})}),Ue(Fn,{children:f.map((w,N)=>Ue(Wt,{value:N.toString(),children:N===0?"Latest":`${N+1} call ago`},N))})]})]}),Ue("span",{className:"text-xs text-gray-500 dark:text-gray-400 mr-2",children:h}),Ue(E,{variant:"ghost",size:"sm",onClick:()=>o(g,b.result),className:"h-7 w-7 p-0",title:"Copy result",children:t===g?Ue(sC,{className:"h-4 w-4"}):Ue(aC,{className:"h-4 w-4"})}),r&&Ue(E,{variant:"ghost",size:"sm",onClick:()=>r(g),className:"h-7 w-7 p-0",title:"Delete result",children:Ue(cC,{className:"h-4 w-4"})}),s&&Ue(E,{variant:"ghost",size:"sm",onClick:()=>s(g),className:"h-7 w-7 p-0 sm:hidden",title:"Fullscreen",children:Ue(Uf,{className:"h-4 w-4"})}),i&&Ue(E,{variant:"ghost",size:"sm",onClick:i,className:"h-7 w-7 p-0 hidden sm:flex",title:d?"Restore":"Maximize",children:d?Ue(lC,{className:"h-4 w-4"}):Ue(Uf,{className:"h-4 w-4"})})]})]}),Ue("div",{className:"flex-1 overflow-y-auto p-4",children:v?To("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded p-3",children:[Ue("p",{className:"text-red-800 dark:text-red-300 font-medium",children:"Error:"}),Ue("p",{className:"text-red-700 dark:text-red-400 text-sm",children:v})]}):m&&y?Ue("div",{className:"space-y-3",children:("messages"in b.result?b.result.messages:[]).map((w,N)=>Ue(Hf,{message:w,index:N},N))}):Ue(wt,{data:b.result,filename:`prompt-result-${b.promptName}-${Date.now()}.json`})})]})})})}import{MessageSquare as pC}from"lucide-react";import{jsx as el,jsxs as $f}from"react/jsx-runtime";function fd({prompts:e,selectedPrompt:t,onPromptSelect:n,focusedIndex:o}){return e.length===0?$f("div",{className:"flex flex-1 flex-col items-center justify-center p-4 text-center",children:[el(pC,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),el("p",{className:"text-gray-500 dark:text-gray-400",children:"No prompts available"})]}):el("div",{children:e.map((r,s)=>el(jn,{id:`prompt-${r.name}`,"data-testid":`prompt-item-${r.name}`,isSelected:t?.name===r.name,isFocused:o===s,title:r.name,description:r.description,metadata:r.arguments&&r.arguments.length>0&&$f(Jt,{variant:"outline",className:"text-xs border-gray-300 dark:border-zinc-600 text-gray-600 dark:text-gray-400",children:[r.arguments.length," args"]}),onClick:()=>n(r)},r.name))})}import{Clock as fC}from"lucide-react";import{jsx as fa,jsxs as gC}from"react/jsx-runtime";function gd({savedPrompts:e,selectedPrompt:t,onLoadPrompt:n,onDeletePrompt:o,focusedIndex:r}){return e.length===0?gC("div",{className:"flex flex-1 flex-col items-center justify-center p-4 text-center",children:[fa(fC,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),fa("p",{className:"text-gray-500 dark:text-gray-400",children:"No history"}),fa("p",{className:"text-sm text-gray-400 dark:text-gray-500 mt-1",children:"Prompts you execute will appear here"})]}):fa("div",{children:e.map((s,a)=>fa(jn,{id:`saved-prompt-${s.id}`,isSelected:t?.id===s.id,isFocused:r===a,title:s.name,description:`${s.promptName} - ${new Date(s.savedAt).toLocaleString()}`,onClick:()=>n(s)},s.id))})}import{useState as ga,useCallback as xs,useEffect as hC,useMemo as vC}from"react";function ha({prompts:e,callPrompt:t,serverId:n}){let[o,r]=ga(null),[s,a]=ga({}),[i,d]=ga([]),[l,u]=ga(!1),[h,c]=ga(""),m=vC(()=>{if(!h.trim())return e;let y=h.toLowerCase();return e.filter(w=>w.name.toLowerCase().includes(y)||w.description?.toLowerCase().includes(y))},[e,h]),p=xs(y=>{r(y);let w={};y.arguments&&y.arguments.forEach(N=>{w[N.name]=""}),a(w)},[]),x=xs((y,w)=>{a(N=>({...N,[y]:w}))},[]),f=xs(async(y,w)=>{if(l)return;u(!0);let N=Date.now();try{let T=await t(y.name,w),L=Date.now()-N;Lt(new Fs({promptName:y.name,serverId:n,success:!0})).catch(()=>{}),d(P=>[{promptName:y.name,args:w,result:T,timestamp:N,duration:L},...P])}catch(T){Lt(new Fs({promptName:y.name,serverId:n,success:!1,error:T instanceof Error?T.message:"Unknown error"})).catch(()=>{});let L=T instanceof Error?T.message:String(T),P={promptName:y.name,args:w,result:{error:L,isError:!0},error:L,timestamp:N,duration:Date.now()-N};d(R=>[P,...R])}finally{u(!1)}},[l,t,n]),b=xs(y=>{d(w=>w.filter((N,T)=>T!==y))},[]),g=xs(()=>{d([])},[]);hC(()=>{if(o){let y=e.find(w=>w.name===o.name);if(!y){r(null);return}y!==o&&(JSON.stringify(y.arguments)!==JSON.stringify(o.arguments)||y.description!==o.description)&&r(y)}},[e,o]);let v=xs(async()=>{!o||l||f(o,s)},[o,s,l,f]);return{filteredPrompts:m,selectedPrompt:o,setSelectedPrompt:r,results:i,handleDeleteResult:b,promptArgs:s,setPromptArgs:a,isExecuting:l,handlePromptSelect:p,handleArgChange:x,executePrompt:f,executeSelectedPrompt:v,searchQuery:h,setSearchQuery:c,clearPromptResults:g}}import{Fragment as tl,jsx as Je,jsxs as ao}from"react/jsx-runtime";var qf="mcp-inspector-saved-prompts";function Wf({ref:e,prompts:t,callPrompt:n,serverId:o,isConnected:r,refreshPrompts:s}){let[a,i]=An(!1),[d,l]=An(null),{selectedPromptName:u,setSelectedPromptName:h}=wo(),[c,m]=An(null),[p,x]=An("prompts"),[f,b]=An([]),[g,v]=An(!1),[y,w]=An(""),[N,T]=An(!1),[L,P]=An(-1),R=wC(null),[D,k]=An(!1),[S,A]=An("list"),[_,K]=An(!1),{filteredPrompts:$,selectedPrompt:oe,setSelectedPrompt:ae,results:ie,handleDeleteResult:ne,promptArgs:z,setPromptArgs:O,isExecuting:W,handlePromptSelect:j,handleArgChange:U,executeSelectedPrompt:H,searchQuery:Te,setSearchQuery:Pe}=ha({prompts:t,callPrompt:n,serverId:o}),le=Ir(),de=Ir();Ro(()=>{let q=()=>{k(window.innerWidth<1024)};return q(),window.addEventListener("resize",q),()=>window.removeEventListener("resize",q)},[]),Ro(()=>{A(oe?"detail":"list")},[oe]),Ro(()=>{D&&ie.length>0&&!W&&A("response")},[ie,W,D]),xC(e,()=>({focusSearch:()=>{T(!0),setTimeout(()=>{R.current&&R.current.focus()},0)},blurSearch:()=>{Pe(""),T(!1),R.current&&R.current.blur()}})),Ro(()=>{try{let q=localStorage.getItem(qf);if(q){let M=JSON.parse(q);b(M)}}catch(q){console.error("[PromptsTab] Failed to load saved prompts:",q)}},[]);let De=Po(q=>{try{localStorage.setItem(qf,JSON.stringify(q))}catch(M){console.error("[PromptsTab] Failed to save prompts:",M)}},[]);Ro(()=>{N&&R.current&&R.current.focus()},[N]);let Re=Po(()=>{Te.trim()||T(!1)},[Te]),Oe=Po(async()=>{if(s){i(!0);try{await s()}finally{i(!1)}}},[s]),Be=Po(q=>{let M=t.find(Ne=>Ne.name===q.promptName);M&&(ae(M),O(q.args),l(q))},[t,ae,O]);Ro(()=>{P(-1)},[Te,p]),Ro(()=>{let q=M=>{let Ne=M.target;if(Ne.tagName==="INPUT"||Ne.tagName==="TEXTAREA"||Ne.contentEditable==="true"||M.metaKey||M.ctrlKey||M.altKey)return;let qe=p==="prompts"?$:f;if(M.key==="ArrowDown")M.preventDefault(),P(ut=>{let Bt=ut+1;return Bt>=qe.length?0:Bt});else if(M.key==="ArrowUp")M.preventDefault(),P(ut=>{let Bt=ut-1;return Bt<0?qe.length-1:Bt});else if(M.key==="Enter"&&L>=0)if(M.preventDefault(),p==="prompts"){let ut=$[L];ut&&j(ut)}else{let ut=f[L];ut&&Be(ut)}};return document.addEventListener("keydown",q),()=>document.removeEventListener("keydown",q)},[L,$,f,p,j,Be]),Ro(()=>{if(L>=0){let q=p==="prompts"?`prompt-${$[L]?.name}`:`saved-prompt-${f[L]?.id}`,M=document.getElementById(q);M&&M.scrollIntoView({behavior:"smooth",block:"nearest"})}},[L,$,f,p]),Ro(()=>{if(console.warn("[PromptsTab] Auto-selection effect triggered:",{selectedPromptName:u,promptsCount:t.length,currentSelectedPrompt:oe?.name}),u&&t.length>0){let q=t.find(M=>M.name===u);if(console.warn("[PromptsTab] Prompt lookup result:",{selectedPromptName:u,promptFound:!!q,promptName:q?.name,shouldSelect:q&&oe?.name!==q.name}),q&&oe?.name!==q.name){console.warn("[PromptsTab] Selecting prompt:",q.name),h(null);let M=setTimeout(()=>{j(q);let Ne=document.getElementById(`prompt-${q.name}`);Ne&&(console.warn("[PromptsTab] Scrolling to prompt element"),Ne.scrollIntoView({behavior:"smooth",block:"nearest"}))},100);return()=>clearTimeout(M)}}},[u,t,oe,j,h]);let tt=Po(async(q,M)=>{try{await Xe(JSON.stringify(M,null,2)),m(q),setTimeout(()=>m(null),2e3)}catch(Ne){console.error("[PromptsTab] Failed to copy result:",Ne)}},[]),V=Po(q=>{if(D)A("response");else{let M=ie[q];if(M){let Ne=window.open("","_blank","width=800,height=600");if(Ne){let gt=M.result;Ne.document.write(`
|
|
105
105
|
<html>
|
|
106
106
|
<head>
|
|
107
107
|
<title>${M.promptName} Result</title>
|
|
@@ -115,7 +115,7 @@ Based on this information, suggest 3-5 common customizable properties like theme
|
|
|
115
115
|
<pre>${JSON.stringify(gt,null,2)}</pre>
|
|
116
116
|
</body>
|
|
117
117
|
</html>
|
|
118
|
-
`),Ne.document.close()}}}},[D,ie]),ce=Po(()=>{_?(le.current&&le.current.expand(),de.current&&de.current.expand(),K(!1)):(le.current&&le.current.collapse(),de.current&&de.current.collapse(),K(!0))},[_,le,de]),Fe=Po(()=>{oe&&(w(""),v(!0))},[oe]),Y=Po(q=>{De(f.filter(M=>M.id!==q)),d?.id===q&&l(null)},[f,De,d]);return D?io("div",{className:"h-full flex flex-col overflow-hidden relative bg-background",children:[S!=="list"&&io("div",{className:"flex items-center gap-2 p-2 border-b shrink-0 bg-background z-10",children:[Je(E,{variant:"ghost",size:"sm",onClick:()=>{S==="response"?A("detail"):(ae(null),A("list"))},className:"p-0 h-8 w-8",children:Je(xC,{className:"h-4 w-4"})}),io("div",{className:"flex items-center text-sm font-medium",children:[Je("button",{onClick:()=>{ae(null),A("list")},className:"text-muted-foreground hover:text-foreground hover:underline cursor-pointer",children:"Prompts"}),S==="detail"&&io(tl,{children:[Je("span",{className:"mx-2 text-muted-foreground",children:"/"}),Je("button",{onClick:()=>{A("response")},className:S==="detail"?"text-foreground hover:underline":S==="response"?"text-muted-foreground hover:text-foreground hover:underline cursor-pointer":"text-muted-foreground",children:"Execute"})]}),S==="response"&&io(tl,{children:[Je("span",{className:"mx-2 text-muted-foreground",children:"/"}),Je("span",{className:"text-foreground",children:"Response"})]})]})]}),Je("div",{className:"flex-1 relative overflow-hidden",children:io(yC,{initial:!1,mode:"popLayout",children:[S==="list"&&Je(hd.div,{initial:{x:"-100%"},animate:{x:0},exit:{x:"-100%"},transition:{type:"spring",stiffness:300,damping:30},className:"absolute inset-0 flex flex-col bg-background z-0",children:Je(ao,{children:q=>io(tl,{children:[Je(Er,{isScrolled:q,activeTab:p,isSearchExpanded:N,searchQuery:Te,primaryTabName:"prompts",secondaryTabName:"saved",primaryTabTitle:"Prompts",secondaryTabTitle:"History",primaryCount:$.length,secondaryCount:f.length,primaryIcon:Wf,secondaryIcon:qf,searchPlaceholder:"Search prompts...",onSearchExpand:()=>T(!0),onSearchChange:Pe,onSearchBlur:Re,onTabSwitch:()=>x(p==="prompts"?"saved":"prompts"),searchInputRef:R,onRefresh:s?Oe:void 0,isRefreshing:a}),p==="prompts"?Je(fd,{prompts:$,selectedPrompt:oe,onPromptSelect:j,focusedIndex:L}):Je(gd,{savedPrompts:f,selectedPrompt:d,onLoadPrompt:Be,onDeletePrompt:Y,focusedIndex:L})]})})},"list"),S==="detail"&&Je(hd.div,{initial:{x:"100%"},animate:{x:0},exit:{x:"-100%"},transition:{type:"spring",stiffness:300,damping:30},className:"absolute inset-0 bg-background z-10",children:Je(rd,{selectedPrompt:oe,promptArgs:z,isExecuting:W,isConnected:r,onArgChange:U,onExecute:H,onSave:Fe})},"detail"),S==="response"&&Je(hd.div,{initial:{x:"100%"},animate:{x:0},exit:{x:"100%"},transition:{type:"spring",stiffness:300,damping:30},className:"absolute inset-0 bg-background z-20",children:Je(pd,{results:ie,copiedResult:c,onCopy:tt,onDelete:ne,onFullscreen:V})},"response")]})})]}):io(Qo,{orientation:"horizontal",className:"h-full",children:[Je(hn,{id:"left-panel",panelRef:le,defaultSize:"33%",collapsible:!0,className:"flex flex-col h-full relative",children:Je("div",{className:"flex h-full flex-col overflow-hidden border-r dark:border-zinc-700",children:Je(ao,{children:q=>io(tl,{children:[Je(Er,{isScrolled:q,activeTab:p,isSearchExpanded:N,searchQuery:Te,primaryTabName:"prompts",secondaryTabName:"saved",primaryTabTitle:"Prompts",secondaryTabTitle:"History",primaryCount:$.length,secondaryCount:f.length,primaryIcon:Wf,secondaryIcon:qf,searchPlaceholder:"Search prompts...",onSearchExpand:()=>T(!0),onSearchChange:Pe,onSearchBlur:Re,onTabSwitch:()=>x(p==="prompts"?"saved":"prompts"),searchInputRef:R,onRefresh:s?Oe:void 0,isRefreshing:a}),p==="prompts"?Je(fd,{prompts:$,selectedPrompt:oe,onPromptSelect:j,focusedIndex:L}):Je(gd,{savedPrompts:f,selectedPrompt:d,onLoadPrompt:Be,onDeletePrompt:Y,focusedIndex:L})]})})})}),Je(Xo,{withHandle:!0}),Je(hn,{defaultSize:"67%",children:io(Qo,{orientation:"vertical",children:[Je(hn,{panelRef:de,defaultSize:"40%",collapsible:!0,children:Je(rd,{selectedPrompt:oe,promptArgs:z,isExecuting:W,isConnected:r,onArgChange:U,onExecute:H,onSave:Fe})}),Je(Xo,{withHandle:!0}),Je(hn,{defaultSize:"60%",children:Je("div",{className:"flex flex-col h-full",children:Je(pd,{results:ie,copiedResult:c,onCopy:tt,onDelete:ne,onFullscreen:V,onMaximize:ce,isMaximized:_})})})]})})]})}Jf.displayName="PromptsTab";import{useCallback as je,useEffect as mr,useMemo as jh,useRef as Hl,useState as xn}from"react";import{toast as As}from"sonner";import{History as QS}from"lucide-react";import*as Yf from"react";import{jsx as Gf}from"react/jsx-runtime";var vd=Yf.forwardRef(({className:e,children:t,...n},o)=>Gf("div",{ref:o,"data-slot":"scroll-area",className:C("relative overflow-hidden",e),...n,children:Gf("div",{"data-slot":"scroll-area-viewport",className:"h-full w-full overflow-y-auto overflow-x-hidden",children:t})}));vd.displayName="ScrollArea";import{Loader2 as zC}from"lucide-react";import{useEffect as BC,useRef as tg}from"react";import{jsx as bd,jsxs as NC}from"react/jsx-runtime";function yd({count:e}){return bd("div",{className:`flex flex-row absolute top-0 right-0 z-10 w-full items-center justify-between gap-2 ${Lo}`,children:NC("div",{className:"flex items-center gap-2 rounded-full",children:[bd("h2",{className:_o,children:"Chat History"}),bd(Jt,{className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",variant:"outline",children:e})]})})}import{jsx as kC}from"react/jsx-runtime";function nl({className:e,...t}){return kC("div",{"data-slot":"skeleton",className:C("animate-pulse rounded-md bg-muted",e),...t})}import{Search as LC}from"lucide-react";import*as eg from"react";import{useEffect as Qf,useRef as Nd,useState as kd}from"react";import{completeChat as SC,providerConfigFromOptions as TC}from"@mcp-use/agent";var zr="New Chat",rr="Chat";function sr(e){return e===zr||e===rr}var PC="Generate a concise title (maximum 60 characters) for this chat based on the user's first message. Name the subject matter, task, or question \u2014 not the act of chatting. Never output meta phrases (e.g. do not use: greeting, introduction, initiation, conversation start, chat session). If there is no specific topic yet, reply with exactly: Chat. Return only the title, no quotes or extra text.",RC=["greeting","initiation","conversation start","introduction to","chat session","starting a chat","beginning of"];function MC(e){return typeof e.content=="string"?e.content.trim():String(e.content??"").trim()}function wd(e){for(let t of e){if(t.role!=="user")continue;let n=MC(t);if(n)return n}return null}function IC(e){let t=e.toLowerCase();for(let n of RC)if(t.includes(n))return!0;return!1}function EC(e){let t=e.trim().split(/\r?\n/)[0].trim();if(!t)return!0;if(t.length>48)return!1;let n=t.replace(/\s+/g," ").toLowerCase();return/^(hi|hello|hey|greetings?)[!.]?$/i.test(n)||/^(good morning|good afternoon|good evening)[!.]?$/i.test(n)||/^(hi|hello|hey)\s+(there|all|team|everyone)[!.]?$/i.test(n)}function xd(e){return e.length>60?`${e.substring(0,57)}...`:e}function AC(e){return e?.model?.trim()?e.provider==="ollama"?!0:!!e.apiKey?.trim():!1}async function Cd(e,t,n){let o=t.trim();if(!o||!AC(e))return null;if(EC(o))return xd(o);try{let r=TC(e.provider,e.model,{apiKey:e.apiKey,temperature:e.temperature,baseUrl:e.baseUrl,maxTokens:128}),s=(await SC({config:r,messages:[{role:"system",content:PC},{role:"user",content:o}],signal:n})).trim();if(!s)return null;let a=xd(s);return a===rr||IC(a)?xd(o):a}catch{return null}}import{jsx as DC}from"react/jsx-runtime";var Xf=28,Zf=3,Sd=.72;function va({chatId:e,title:t,className:n,onRevealComplete:o}){let[r,s]=kd(t),[a,i]=kd(0),[d,l]=kd(1),u=Nd(t),h=Nd(null),c=Nd(e);return Qf(()=>{if(c.current!==e){c.current=e,u.current=t,h.current=null,s(t),i(0),l(1);return}},[e,t]),Qf(()=>{let m=`${e}:${t}`;if(h.current===m){s(t),i(0),l(1);return}let p=u.current,x=sr(p)&&!sr(t)&&t!==p;if(u.current=t,!x){s(t),i(0),l(1);return}h.current=m;let f=0,b=t.length;s(""),i(Zf),l(Sd);let g,v=()=>{f+=1;let y=b>0?f/b:1;s(t.slice(0,f)),i(Zf*(1-y)),l(Sd+(1-Sd)*y),f<b?g=setTimeout(v,Xf):o?.()};return g=setTimeout(v,Xf),()=>{g&&clearTimeout(g)}},[e,t,o]),DC("span",{className:C("block truncate transition-[filter,opacity] duration-75",n),style:{filter:a>0?`blur(${a}px)`:void 0,opacity:d},children:r})}import{jsx as At,jsxs as Br}from"react/jsx-runtime";function Td({compact:e,hideAgentName:t}){return Br("div",{className:C("flex items-center justify-between py-3 gap-2",e?"px-4":"px-3 rounded-lg"),children:[Br("div",{className:C("flex-1 min-w-0 flex flex-col gap-1",t?"gap-1.5":"gap-1"),children:[At(nl,{className:"h-4 w-3/4"}),!t&&At(nl,{className:"h-3 w-1/2"})]}),At(nl,{className:"h-3 w-14 shrink-0"})]})}function Pd({chats:e,onDelete:t,onSelect:n,compact:o,hideAgentName:r,isLoading:s,currentChatId:a}){let[i,d]=eg.useState(""),l=e.filter(p=>p.type!=="agent_execution"),u=l.filter(p=>(p.title??"").toLowerCase().includes(i.toLowerCase())),h=p=>{let x=new Date(p),f=new Date;if(x.toDateString()===f.toDateString())return x.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});let g=new Date(f);if(g.setDate(g.getDate()-1),x.toDateString()===g.toDateString())return"Yesterday";let y=f.getTime()-x.getTime(),w=Math.floor(y/(1e3*60*60*24));return w<7?`${w} days ago`:x.toLocaleDateString("en-US",{month:"short",day:"numeric"})},c=p=>Br("div",{className:C("flex items-center justify-between py-3 hover:bg-muted/50 transition-colors gap-2 cursor-pointer",o?"px-4":"px-3 rounded-lg",a===p.id&&"bg-muted/50"),children:[Br("div",{className:C("flex-1 min-w-0 flex overflow-hidden",r?"flex-col":"flex-col gap-1"),children:[At("p",{className:"text-sm font-medium truncate w-full",children:At(va,{chatId:p.id,title:p.title},`${p.id}:${p.title}`)}),!r&&At("p",{className:"text-xs text-muted-foreground truncate w-full",children:p.agent_name})]}),At("div",{className:"flex items-center gap-2 shrink-0",children:At("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:h(p.updated_at)})})]});return Br("div",{className:"flex h-full w-full flex-col",children:[At("div",{className:"mb-4 px-3 sm:px-5",children:Br("div",{className:"relative",children:[At(LC,{className:"absolute left-3 top-2.5 h-4 w-4 text-muted-foreground"}),At(Ge,{placeholder:"Search chats...",value:i,onChange:p=>d(p.target.value),className:"pl-9 h-8 border-gray-300 dark:border-zinc-600"})]})}),At("div",{className:"min-h-0 flex-1",children:s&&l.length===0?Br("div",{className:"space-y-1",children:[At(Td,{compact:o,hideAgentName:r}),At(Td,{compact:o,hideAgentName:r}),At(Td,{compact:o,hideAgentName:r})]}):l.length===0?At("div",{className:"flex flex-1 flex-col items-center justify-center p-4 text-center min-h-[12rem]",children:At(ms,{vertical:!0,noBorder:!0,message:"No chats",className:"mt-0"})}):u.length===0?null:At("div",{className:"space-y-1",children:u.map(p=>n?At("button",{type:"button",onClick:()=>n(p.id),className:"block w-full text-left group cursor-pointer",children:c(p)},p.id):At("div",{className:"block group cursor-pointer",children:c(p)},p.id))})})]})}import{useCallback as ol,useEffect as rl,useRef as _C,useState as ba}from"react";var OC=20;function Rd({provider:e,enabled:t=!0,agentId:n,refetchKey:o,refetchInterval:r=!1}){let[s,a]=ba(1),[i,d]=ba([]),[l,u]=ba(0),[h,c]=ba(!1),[m,p]=ba(null),x=_C(void 0),f=ol(async()=>{if(t){c(!0),p(null);try{let w=await e.listChats({...n?{agentId:n}:{},take:OC*s,skip:0});d(w.items),u(w.total)}catch(w){p(w instanceof Error?w:new Error(String(w)))}finally{c(!1)}}},[e,t,n,s]);rl(()=>{t&&a(1)},[t]),rl(()=>{f()},[f]),rl(()=>{o!==void 0&&o!==x.current&&(x.current=o,t&&f())},[o,t,f]),rl(()=>{if(!t||!r)return;let w=setInterval(()=>{f()},r);return()=>clearInterval(w)},[t,r,f]);let b=l>i.length,g=ol(()=>{b&&!h&&a(w=>w+1)},[b,h]),v=ol(()=>{f()},[f]),y=ol(async w=>{await e.deleteChat(w),await f()},[e,f]);return{chats:i,total:l,isLoading:h,error:m,hasNextPage:b,loadMore:g,refetch:v,deleteChat:y}}import{jsx as Hr,jsxs as Md}from"react/jsx-runtime";function Id({provider:e,open:t,onOpenChange:n,currentChatId:o,container:r,agentId:s,agentDisplayNameFallback:a,onSelectChat:i,variant:d="drawer",containerClassName:l,refetchKey:u,refetchInterval:h=!1,onCurrentChatDeleted:c,onDeleteSuccess:m,onDeleteError:p}){let x=tg(null),f=tg(null),{chats:b,isLoading:g,hasNextPage:v,loadMore:y,deleteChat:w}=Rd({provider:e,enabled:t,agentId:s,refetchKey:u,refetchInterval:a?h||3e3:h});BC(()=>{if(!t||!f.current)return;let D=new IntersectionObserver(k=>{k[0]?.isIntersecting&&y()},{threshold:.5});return D.observe(f.current),()=>{D.disconnect()}},[t,v,g,y]);let N=async D=>{try{await w(D),m?.(),D===o&&c?.()}catch(k){console.error("Failed to delete chat:",k),p?.(k)}},T=b.map(D=>({...D,title:D.title||"New Chat",agent_name:D.agent_name??a??"Unknown Agent"})),L=T.filter(D=>D.type!=="agent_execution").length,P=Hr(Pd,{chats:T,onDelete:N,compact:d==="inline",hideAgentName:!!a,isLoading:g&&b.length===0,currentChatId:o,onSelect:i?D=>{i(D),n(!1)}:void 0}),R=Md("div",{className:"relative flex h-full min-h-0 flex-col",children:[Hr(yd,{count:L}),Md(vd,{ref:x,className:C("min-h-0 flex-1 w-full pt-14 sm:pt-16 [&_[data-slot=scroll-area-viewport]]:block!",d==="inline"?"p-0":"px-3 sm:px-5"),children:[P,v&&Hr("div",{ref:f,className:"py-4 flex items-center justify-center",children:Md("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[Hr(zC,{className:"h-4 w-4 animate-spin"}),"Loading more..."]})})]})]});return d==="inline"?Hr("div",{className:C("flex h-full min-h-0 flex-col",l),children:R}):Hr(is,{open:t,onOpenChange:n,children:Hr(ls,{side:"left",className:"w-[400px] sm:w-[400px] border-zinc-200 p-0 dark:border-zinc-700",container:r,children:R})})}import{ArrowLeftFromLine as HC}from"lucide-react";import{jsx as sl,jsxs as ng}from"react/jsx-runtime";function Ed({onCollapse:e}){return ng(ke,{children:[sl(we,{render:ng(E,{type:"button",variant:"ghost",size:"icon-sm",tabIndex:-1,"aria-label":"Collapse",onClick:e,className:"border-border absolute top-1/2 right-0 z-30 size-7 min-h-7 min-w-7 -translate-y-1/2 translate-x-1/2 rounded-full border bg-background",children:[sl(HC,{className:"size-4"}),sl("span",{className:"sr-only",children:"Collapse"})]}),nativeButton:!0}),sl(Ce,{side:"right",children:"Collapse"})]})}var rg="mcp-inspector-chats",og="New Chat";function ws(){try{let e=localStorage.getItem(rg);if(!e)return{sessions:[],messages:{}};let t=JSON.parse(e);return{sessions:Array.isArray(t.sessions)?t.sessions:[],messages:t.messages&&typeof t.messages=="object"?t.messages:{}}}catch{return{sessions:[],messages:{}}}}function al(e){localStorage.setItem(rg,JSON.stringify(e))}function Ad(){return new Date().toISOString()}function UC(e){let t=e.find(o=>o.role==="user");if(!t)return;let n=typeof t.content=="string"?t.content.trim():String(t.content??"").trim();if(n)return n.length>40?`${n.slice(0,40)}\u2026`:n}var ya=class{constructor(){ot(this,"saveTimers",new Map)}async listChats(t){let{sessions:n}=ws(),o=n;t.agentId&&(o=n.filter(i=>i.agent_id===t.agentId)),o=[...o].sort((i,d)=>new Date(d.updated_at).getTime()-new Date(i.updated_at).getTime());let r=o.length,s=t.skip??0,a=t.take??r;return{items:o.slice(s,s+a),total:r}}async getMessages(t){let{messages:n}=ws();return n[t]??[]}async createChat(t){let n=ws(),o=Ad(),r={id:crypto.randomUUID(),title:t.title??og,agent_id:t.agentId,agent_name:t.agentName??"MCP Server",created_at:o,updated_at:o};return n.sessions.push(r),n.messages[r.id]=[],al(n),r}async updateChat(t,n){let o=ws(),r=o.sessions.findIndex(a=>a.id===t);if(r===-1)throw new Error(`Chat not found: ${t}`);let s=o.sessions[r];return n.title!==void 0&&(s.title=n.title),s.updated_at=Ad(),o.sessions[r]=s,al(o),s}async deleteChat(t){let n=ws();n.sessions=n.sessions.filter(o=>o.id!==t),delete n.messages[t],al(n)}async saveMessages(t,n){let o=this.saveTimers.get(t);o&&clearTimeout(o),await new Promise(r=>{let s=setTimeout(()=>{this.saveTimers.delete(t);let a=ws();a.messages[t]=n;let i=a.sessions.findIndex(d=>d.id===t);if(i!==-1){let d=a.sessions[i];if(d.updated_at=Ad(),d.title===og){let l=UC(n);l&&(d.title=l)}a.sessions[i]=d}al(a),r()},500);this.saveTimers.set(t,s)})}};import{useEffect as sg,useRef as FC}from"react";function Dd({activeChatId:e,storage:t,messages:n,isLoading:o,effectiveClientSide:r,llmConfig:s,activeChatTitle:a,titleGenerationReady:i=!0,onTitleGenerated:d,onHistoryRefetch:l}){let u=FC(null);sg(()=>{u.current=null},[e]),sg(()=>{if(!e||!t||o||!i||a&&!sr(a))return;let h=wd(n);if(!h)return;let c=`${e}:${h}`;if(u.current===c)return;u.current=c;let m=!1;return(async()=>{let p=null;if(t.generateTitle?p=await t.generateTitle(e):r&&s&&(p=await Cd(s,h),p&&await t.updateChat(e,{title:p})),!m){if(!p||p===zr){u.current=null;return}l?.(),d?.(e,p)}})().catch(()=>{m||(u.current=null)}),()=>{m=!0}},[e,t,n,o,r,s,a,i,d,l])}import{useEffect as dg,useRef as tN,useState as nN}from"react";import{useEffect as $C,useRef as Ld}from"react";import{jsx as ag}from"react/jsx-runtime";var VC=`#version 300 es
|
|
118
|
+
`),Ne.document.close()}}}},[D,ie]),ce=Po(()=>{_?(le.current&&le.current.expand(),de.current&&de.current.expand(),K(!1)):(le.current&&le.current.collapse(),de.current&&de.current.collapse(),K(!0))},[_,le,de]),Fe=Po(()=>{oe&&(w(""),v(!0))},[oe]),Y=Po(q=>{De(f.filter(M=>M.id!==q)),d?.id===q&&l(null)},[f,De,d]);return D?ao("div",{className:"h-full flex flex-col overflow-hidden relative bg-background",children:[S!=="list"&&ao("div",{className:"flex items-center gap-2 p-2 border-b shrink-0 bg-background z-10",children:[Je(E,{variant:"ghost",size:"sm",onClick:()=>{S==="response"?A("detail"):(ae(null),A("list"))},className:"p-0 h-8 w-8",children:Je(yC,{className:"h-4 w-4"})}),ao("div",{className:"flex items-center text-sm font-medium",children:[Je("button",{onClick:()=>{ae(null),A("list")},className:"text-muted-foreground hover:text-foreground hover:underline cursor-pointer",children:"Prompts"}),S==="detail"&&ao(tl,{children:[Je("span",{className:"mx-2 text-muted-foreground",children:"/"}),Je("button",{onClick:()=>{A("response")},className:S==="detail"?"text-foreground hover:underline":S==="response"?"text-muted-foreground hover:text-foreground hover:underline cursor-pointer":"text-muted-foreground",children:"Execute"})]}),S==="response"&&ao(tl,{children:[Je("span",{className:"mx-2 text-muted-foreground",children:"/"}),Je("span",{className:"text-foreground",children:"Response"})]})]})]}),Je("div",{className:"flex-1 relative overflow-hidden",children:ao(bC,{initial:!1,mode:"popLayout",children:[S==="list"&&Je(hd.div,{initial:{x:"-100%"},animate:{x:0},exit:{x:"-100%"},transition:{type:"spring",stiffness:300,damping:30},className:"absolute inset-0 flex flex-col bg-background z-0",children:Je(so,{children:q=>ao(tl,{children:[Je(Er,{isScrolled:q,activeTab:p,isSearchExpanded:N,searchQuery:Te,primaryTabName:"prompts",secondaryTabName:"saved",primaryTabTitle:"Prompts",secondaryTabTitle:"History",primaryCount:$.length,secondaryCount:f.length,primaryIcon:jf,secondaryIcon:Vf,searchPlaceholder:"Search prompts...",onSearchExpand:()=>T(!0),onSearchChange:Pe,onSearchBlur:Re,onTabSwitch:()=>x(p==="prompts"?"saved":"prompts"),searchInputRef:R,onRefresh:s?Oe:void 0,isRefreshing:a}),p==="prompts"?Je(fd,{prompts:$,selectedPrompt:oe,onPromptSelect:j,focusedIndex:L}):Je(gd,{savedPrompts:f,selectedPrompt:d,onLoadPrompt:Be,onDeletePrompt:Y,focusedIndex:L})]})})},"list"),S==="detail"&&Je(hd.div,{initial:{x:"100%"},animate:{x:0},exit:{x:"-100%"},transition:{type:"spring",stiffness:300,damping:30},className:"absolute inset-0 bg-background z-10",children:Je(rd,{selectedPrompt:oe,promptArgs:z,isExecuting:W,isConnected:r,onArgChange:U,onExecute:H,onSave:Fe})},"detail"),S==="response"&&Je(hd.div,{initial:{x:"100%"},animate:{x:0},exit:{x:"100%"},transition:{type:"spring",stiffness:300,damping:30},className:"absolute inset-0 bg-background z-20",children:Je(pd,{results:ie,copiedResult:c,onCopy:tt,onDelete:ne,onFullscreen:V})},"response")]})})]}):ao(Qo,{orientation:"horizontal",className:"h-full",children:[Je(hn,{id:"left-panel",panelRef:le,defaultSize:"33%",collapsible:!0,className:"flex flex-col h-full relative",children:Je("div",{className:"flex h-full flex-col overflow-hidden border-r dark:border-zinc-700",children:Je(so,{children:q=>ao(tl,{children:[Je(Er,{isScrolled:q,activeTab:p,isSearchExpanded:N,searchQuery:Te,primaryTabName:"prompts",secondaryTabName:"saved",primaryTabTitle:"Prompts",secondaryTabTitle:"History",primaryCount:$.length,secondaryCount:f.length,primaryIcon:jf,secondaryIcon:Vf,searchPlaceholder:"Search prompts...",onSearchExpand:()=>T(!0),onSearchChange:Pe,onSearchBlur:Re,onTabSwitch:()=>x(p==="prompts"?"saved":"prompts"),searchInputRef:R,onRefresh:s?Oe:void 0,isRefreshing:a}),p==="prompts"?Je(fd,{prompts:$,selectedPrompt:oe,onPromptSelect:j,focusedIndex:L}):Je(gd,{savedPrompts:f,selectedPrompt:d,onLoadPrompt:Be,onDeletePrompt:Y,focusedIndex:L})]})})})}),Je(Xo,{withHandle:!0}),Je(hn,{defaultSize:"67%",children:ao(Qo,{orientation:"vertical",children:[Je(hn,{panelRef:de,defaultSize:"40%",collapsible:!0,children:Je(rd,{selectedPrompt:oe,promptArgs:z,isExecuting:W,isConnected:r,onArgChange:U,onExecute:H,onSave:Fe})}),Je(Xo,{withHandle:!0}),Je(hn,{defaultSize:"60%",children:Je("div",{className:"flex flex-col h-full",children:Je(pd,{results:ie,copiedResult:c,onCopy:tt,onDelete:ne,onFullscreen:V,onMaximize:ce,isMaximized:_})})})]})})]})}Wf.displayName="PromptsTab";import{useCallback as je,useEffect as mr,useMemo as Vh,useRef as Hl,useState as xn}from"react";import{toast as As}from"sonner";import{History as YS}from"lucide-react";import*as Jf from"react";import{jsx as Kf}from"react/jsx-runtime";var vd=Jf.forwardRef(({className:e,children:t,...n},o)=>Kf("div",{ref:o,"data-slot":"scroll-area",className:C("relative overflow-hidden",e),...n,children:Kf("div",{"data-slot":"scroll-area-viewport",className:"h-full w-full overflow-y-auto overflow-x-hidden",children:t})}));vd.displayName="ScrollArea";import{Loader2 as OC}from"lucide-react";import{useEffect as zC,useRef as Zf}from"react";import{jsx as bd,jsxs as CC}from"react/jsx-runtime";function yd({count:e}){return bd("div",{className:`flex flex-row absolute top-0 right-0 z-10 w-full items-center justify-between gap-2 ${Lo}`,children:CC("div",{className:"flex items-center gap-2 rounded-full",children:[bd("h2",{className:_o,children:"Chat History"}),bd(Jt,{className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",variant:"outline",children:e})]})})}import{jsx as NC}from"react/jsx-runtime";function nl({className:e,...t}){return NC("div",{"data-slot":"skeleton",className:C("animate-pulse rounded-md bg-muted",e),...t})}import{Search as DC}from"lucide-react";import*as Xf from"react";import{useEffect as Gf,useRef as Nd,useState as kd}from"react";import{completeChat as kC,providerConfigFromOptions as SC}from"@mcp-use/agent";var zr="New Chat",rr="Chat";function sr(e){return e===zr||e===rr}var TC="Generate a concise title (maximum 60 characters) for this chat based on the user's first message. Name the subject matter, task, or question \u2014 not the act of chatting. Never output meta phrases (e.g. do not use: greeting, introduction, initiation, conversation start, chat session). If there is no specific topic yet, reply with exactly: Chat. Return only the title, no quotes or extra text.",PC=["greeting","initiation","conversation start","introduction to","chat session","starting a chat","beginning of"];function RC(e){return typeof e.content=="string"?e.content.trim():String(e.content??"").trim()}function wd(e){for(let t of e){if(t.role!=="user")continue;let n=RC(t);if(n)return n}return null}function MC(e){let t=e.toLowerCase();for(let n of PC)if(t.includes(n))return!0;return!1}function IC(e){let t=e.trim().split(/\r?\n/)[0].trim();if(!t)return!0;if(t.length>48)return!1;let n=t.replace(/\s+/g," ").toLowerCase();return/^(hi|hello|hey|greetings?)[!.]?$/i.test(n)||/^(good morning|good afternoon|good evening)[!.]?$/i.test(n)||/^(hi|hello|hey)\s+(there|all|team|everyone)[!.]?$/i.test(n)}function xd(e){return e.length>60?`${e.substring(0,57)}...`:e}function EC(e){return e?.model?.trim()?e.provider==="ollama"?!0:!!e.apiKey?.trim():!1}async function Cd(e,t,n){let o=t.trim();if(!o||!EC(e))return null;if(IC(o))return xd(o);try{let r=SC(e.provider,e.model,{apiKey:e.apiKey,temperature:e.temperature,baseUrl:e.baseUrl,maxTokens:128}),s=(await kC({config:r,messages:[{role:"system",content:TC},{role:"user",content:o}],signal:n})).trim();if(!s)return null;let a=xd(s);return a===rr||MC(a)?xd(o):a}catch{return null}}import{jsx as AC}from"react/jsx-runtime";var Yf=28,Qf=3,Sd=.72;function va({chatId:e,title:t,className:n,onRevealComplete:o}){let[r,s]=kd(t),[a,i]=kd(0),[d,l]=kd(1),u=Nd(t),h=Nd(null),c=Nd(e);return Gf(()=>{if(c.current!==e){c.current=e,u.current=t,h.current=null,s(t),i(0),l(1);return}},[e,t]),Gf(()=>{let m=`${e}:${t}`;if(h.current===m){s(t),i(0),l(1);return}let p=u.current,x=sr(p)&&!sr(t)&&t!==p;if(u.current=t,!x){s(t),i(0),l(1);return}h.current=m;let f=0,b=t.length;s(""),i(Qf),l(Sd);let g,v=()=>{f+=1;let y=b>0?f/b:1;s(t.slice(0,f)),i(Qf*(1-y)),l(Sd+(1-Sd)*y),f<b?g=setTimeout(v,Yf):o?.()};return g=setTimeout(v,Yf),()=>{g&&clearTimeout(g)}},[e,t,o]),AC("span",{className:C("block truncate transition-[filter,opacity] duration-75",n),style:{filter:a>0?`blur(${a}px)`:void 0,opacity:d},children:r})}import{jsx as At,jsxs as Br}from"react/jsx-runtime";function Td({compact:e,hideAgentName:t}){return Br("div",{className:C("flex items-center justify-between py-3 gap-2",e?"px-4":"px-3 rounded-lg"),children:[Br("div",{className:C("flex-1 min-w-0 flex flex-col gap-1",t?"gap-1.5":"gap-1"),children:[At(nl,{className:"h-4 w-3/4"}),!t&&At(nl,{className:"h-3 w-1/2"})]}),At(nl,{className:"h-3 w-14 shrink-0"})]})}function Pd({chats:e,onDelete:t,onSelect:n,compact:o,hideAgentName:r,isLoading:s,currentChatId:a}){let[i,d]=Xf.useState(""),l=e.filter(p=>p.type!=="agent_execution"),u=l.filter(p=>(p.title??"").toLowerCase().includes(i.toLowerCase())),h=p=>{let x=new Date(p),f=new Date;if(x.toDateString()===f.toDateString())return x.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});let g=new Date(f);if(g.setDate(g.getDate()-1),x.toDateString()===g.toDateString())return"Yesterday";let y=f.getTime()-x.getTime(),w=Math.floor(y/(1e3*60*60*24));return w<7?`${w} days ago`:x.toLocaleDateString("en-US",{month:"short",day:"numeric"})},c=p=>Br("div",{className:C("flex items-center justify-between py-3 hover:bg-muted/50 transition-colors gap-2 cursor-pointer",o?"px-4":"px-3 rounded-lg",a===p.id&&"bg-muted/50"),children:[Br("div",{className:C("flex-1 min-w-0 flex overflow-hidden",r?"flex-col":"flex-col gap-1"),children:[At("p",{className:"text-sm font-medium truncate w-full",children:At(va,{chatId:p.id,title:p.title},`${p.id}:${p.title}`)}),!r&&At("p",{className:"text-xs text-muted-foreground truncate w-full",children:p.agent_name})]}),At("div",{className:"flex items-center gap-2 shrink-0",children:At("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:h(p.updated_at)})})]});return Br("div",{className:"flex h-full w-full flex-col",children:[At("div",{className:"mb-4 px-3 sm:px-5",children:Br("div",{className:"relative",children:[At(DC,{className:"absolute left-3 top-2.5 h-4 w-4 text-muted-foreground"}),At(Ge,{placeholder:"Search chats...",value:i,onChange:p=>d(p.target.value),className:"pl-9 h-8 border-gray-300 dark:border-zinc-600"})]})}),At("div",{className:"min-h-0 flex-1",children:s&&l.length===0?Br("div",{className:"space-y-1",children:[At(Td,{compact:o,hideAgentName:r}),At(Td,{compact:o,hideAgentName:r}),At(Td,{compact:o,hideAgentName:r})]}):l.length===0?At("div",{className:"flex flex-1 flex-col items-center justify-center p-4 text-center min-h-[12rem]",children:At(ms,{vertical:!0,noBorder:!0,message:"No chats",className:"mt-0"})}):u.length===0?null:At("div",{className:"space-y-1",children:u.map(p=>n?At("button",{type:"button",onClick:()=>n(p.id),className:"block w-full text-left group cursor-pointer",children:c(p)},p.id):At("div",{className:"block group cursor-pointer",children:c(p)},p.id))})})]})}import{useCallback as ol,useEffect as rl,useRef as LC,useState as ba}from"react";var _C=20;function Rd({provider:e,enabled:t=!0,agentId:n,refetchKey:o,refetchInterval:r=!1}){let[s,a]=ba(1),[i,d]=ba([]),[l,u]=ba(0),[h,c]=ba(!1),[m,p]=ba(null),x=LC(void 0),f=ol(async()=>{if(t){c(!0),p(null);try{let w=await e.listChats({...n?{agentId:n}:{},take:_C*s,skip:0});d(w.items),u(w.total)}catch(w){p(w instanceof Error?w:new Error(String(w)))}finally{c(!1)}}},[e,t,n,s]);rl(()=>{t&&a(1)},[t]),rl(()=>{f()},[f]),rl(()=>{o!==void 0&&o!==x.current&&(x.current=o,t&&f())},[o,t,f]),rl(()=>{if(!t||!r)return;let w=setInterval(()=>{f()},r);return()=>clearInterval(w)},[t,r,f]);let b=l>i.length,g=ol(()=>{b&&!h&&a(w=>w+1)},[b,h]),v=ol(()=>{f()},[f]),y=ol(async w=>{await e.deleteChat(w),await f()},[e,f]);return{chats:i,total:l,isLoading:h,error:m,hasNextPage:b,loadMore:g,refetch:v,deleteChat:y}}import{jsx as Hr,jsxs as Md}from"react/jsx-runtime";function Id({provider:e,open:t,onOpenChange:n,currentChatId:o,container:r,agentId:s,agentDisplayNameFallback:a,onSelectChat:i,variant:d="drawer",containerClassName:l,refetchKey:u,refetchInterval:h=!1,onCurrentChatDeleted:c,onDeleteSuccess:m,onDeleteError:p}){let x=Zf(null),f=Zf(null),{chats:b,isLoading:g,hasNextPage:v,loadMore:y,deleteChat:w}=Rd({provider:e,enabled:t,agentId:s,refetchKey:u,refetchInterval:a?h||3e3:h});zC(()=>{if(!t||!f.current)return;let D=new IntersectionObserver(k=>{k[0]?.isIntersecting&&y()},{threshold:.5});return D.observe(f.current),()=>{D.disconnect()}},[t,v,g,y]);let N=async D=>{try{await w(D),m?.(),D===o&&c?.()}catch(k){console.error("Failed to delete chat:",k),p?.(k)}},T=b.map(D=>({...D,title:D.title||"New Chat",agent_name:D.agent_name??a??"Unknown Agent"})),L=T.filter(D=>D.type!=="agent_execution").length,P=Hr(Pd,{chats:T,onDelete:N,compact:d==="inline",hideAgentName:!!a,isLoading:g&&b.length===0,currentChatId:o,onSelect:i?D=>{i(D),n(!1)}:void 0}),R=Md("div",{className:"relative flex h-full min-h-0 flex-col",children:[Hr(yd,{count:L}),Md(vd,{ref:x,className:C("min-h-0 flex-1 w-full pt-14 sm:pt-16 [&_[data-slot=scroll-area-viewport]]:block!",d==="inline"?"p-0":"px-3 sm:px-5"),children:[P,v&&Hr("div",{ref:f,className:"py-4 flex items-center justify-center",children:Md("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[Hr(OC,{className:"h-4 w-4 animate-spin"}),"Loading more..."]})})]})]});return d==="inline"?Hr("div",{className:C("flex h-full min-h-0 flex-col",l),children:R}):Hr(is,{open:t,onOpenChange:n,children:Hr(ls,{side:"left",className:"w-[400px] sm:w-[400px] border-zinc-200 p-0 dark:border-zinc-700",container:r,children:R})})}import{ArrowLeftFromLine as BC}from"lucide-react";import{jsx as sl,jsxs as eg}from"react/jsx-runtime";function Ed({onCollapse:e}){return eg(ke,{children:[sl(we,{render:eg(E,{type:"button",variant:"ghost",size:"icon-sm",tabIndex:-1,"aria-label":"Collapse",onClick:e,className:"border-border absolute top-1/2 right-0 z-30 size-7 min-h-7 min-w-7 -translate-y-1/2 translate-x-1/2 rounded-full border bg-background",children:[sl(BC,{className:"size-4"}),sl("span",{className:"sr-only",children:"Collapse"})]}),nativeButton:!0}),sl(Ce,{side:"right",children:"Collapse"})]})}var ng="mcp-inspector-chats",tg="New Chat";function ws(){try{let e=localStorage.getItem(ng);if(!e)return{sessions:[],messages:{}};let t=JSON.parse(e);return{sessions:Array.isArray(t.sessions)?t.sessions:[],messages:t.messages&&typeof t.messages=="object"?t.messages:{}}}catch{return{sessions:[],messages:{}}}}function al(e){localStorage.setItem(ng,JSON.stringify(e))}function Ad(){return new Date().toISOString()}function HC(e){let t=e.find(o=>o.role==="user");if(!t)return;let n=typeof t.content=="string"?t.content.trim():String(t.content??"").trim();if(n)return n.length>40?`${n.slice(0,40)}\u2026`:n}var ya=class{constructor(){ot(this,"saveTimers",new Map)}async listChats(t){let{sessions:n}=ws(),o=n;t.agentId&&(o=n.filter(i=>i.agent_id===t.agentId)),o=[...o].sort((i,d)=>new Date(d.updated_at).getTime()-new Date(i.updated_at).getTime());let r=o.length,s=t.skip??0,a=t.take??r;return{items:o.slice(s,s+a),total:r}}async getMessages(t){let{messages:n}=ws();return n[t]??[]}async createChat(t){let n=ws(),o=Ad(),r={id:crypto.randomUUID(),title:t.title??tg,agent_id:t.agentId,agent_name:t.agentName??"MCP Server",created_at:o,updated_at:o};return n.sessions.push(r),n.messages[r.id]=[],al(n),r}async updateChat(t,n){let o=ws(),r=o.sessions.findIndex(a=>a.id===t);if(r===-1)throw new Error(`Chat not found: ${t}`);let s=o.sessions[r];return n.title!==void 0&&(s.title=n.title),s.updated_at=Ad(),o.sessions[r]=s,al(o),s}async deleteChat(t){let n=ws();n.sessions=n.sessions.filter(o=>o.id!==t),delete n.messages[t],al(n)}async saveMessages(t,n){let o=this.saveTimers.get(t);o&&clearTimeout(o),await new Promise(r=>{let s=setTimeout(()=>{this.saveTimers.delete(t);let a=ws();a.messages[t]=n;let i=a.sessions.findIndex(d=>d.id===t);if(i!==-1){let d=a.sessions[i];if(d.updated_at=Ad(),d.title===tg){let l=HC(n);l&&(d.title=l)}a.sessions[i]=d}al(a),r()},500);this.saveTimers.set(t,s)})}};import{useEffect as og,useRef as UC}from"react";function Dd({activeChatId:e,storage:t,messages:n,isLoading:o,effectiveClientSide:r,llmConfig:s,activeChatTitle:a,titleGenerationReady:i=!0,onTitleGenerated:d,onHistoryRefetch:l}){let u=UC(null);og(()=>{u.current=null},[e]),og(()=>{if(!e||!t||o||!i||a&&!sr(a))return;let h=wd(n);if(!h)return;let c=`${e}:${h}`;if(u.current===c)return;u.current=c;let m=!1;return(async()=>{let p=null;if(t.generateTitle?p=await t.generateTitle(e):r&&s&&(p=await Cd(s,h),p&&await t.updateChat(e,{title:p})),!m){if(!p||p===zr){u.current=null;return}l?.(),d?.(e,p)}})().catch(()=>{m||(u.current=null)}),()=>{m=!0}},[e,t,n,o,r,s,a,i,d,l])}import{useEffect as lg,useRef as eN,useState as tN}from"react";import{useEffect as FC,useRef as Ld}from"react";import{jsx as rg}from"react/jsx-runtime";var $C=`#version 300 es
|
|
119
119
|
precision mediump float;
|
|
120
120
|
in vec4 a_position;
|
|
121
121
|
uniform vec2 u_resolution;
|
|
@@ -128,7 +128,7 @@ void main(){
|
|
|
128
128
|
float box=min(u_resolution.x,u_resolution.y);
|
|
129
129
|
vec2 scale=box>0.0?u_resolution/box:vec2(1.);
|
|
130
130
|
v_objectUV=uv*scale;
|
|
131
|
-
}`,
|
|
131
|
+
}`,VC=`#version 300 es
|
|
132
132
|
precision mediump float;
|
|
133
133
|
uniform float u_time;
|
|
134
134
|
uniform vec4 u_colors[4];
|
|
@@ -194,23 +194,23 @@ void main(){
|
|
|
194
194
|
color=mix(color,grainOC,.35*grainOS);
|
|
195
195
|
opacity+=.5*grainOS;
|
|
196
196
|
fragColor=vec4(color,clamp(opacity,0.,1.));
|
|
197
|
-
}`;function qC(e){return[parseInt(e.slice(1,3),16)/255,parseInt(e.slice(3,5),16)/255,parseInt(e.slice(5,7),16)/255,1]}function il({className:e,colors:t=["#e0eaff","#f9ffbd","#dedede","#ffffff"],distortion:n=.8,swirl:o=.1,grainMixer:r=0,grainOverlay:s=.2,speed:a=1}){let i=Ld(null),d=Ld(null),l=Ld({colors:t,distortion:n,swirl:o,grainMixer:r,grainOverlay:s,speed:a});return l.current={colors:t,distortion:n,swirl:o,grainMixer:r,grainOverlay:s,speed:a},$C(()=>{let u=i.current,h=d.current;if(!u||!h)return;let c=u.getContext("webgl2");if(!c)return;let m=($,oe)=>{let ae=c.createShader($);return ae?(c.shaderSource(ae,oe),c.compileShader(ae),c.getShaderParameter(ae,c.COMPILE_STATUS)?ae:(console.error(c.getShaderInfoLog(ae)),null)):null},p=m(c.VERTEX_SHADER,VC),x=m(c.FRAGMENT_SHADER,jC);if(!p||!x)return;let f=c.createProgram();if(!f)return;if(c.attachShader(f,p),c.attachShader(f,x),c.linkProgram(f),!c.getProgramParameter(f,c.LINK_STATUS)){console.error(c.getProgramInfoLog(f));return}c.useProgram(f);let b=c.getAttribLocation(f,"a_position"),g=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,g),c.bufferData(c.ARRAY_BUFFER,new Float32Array([-1,-1,1,-1,-1,1,-1,1,1,-1,1,1]),c.STATIC_DRAW),c.enableVertexAttribArray(b),c.vertexAttribPointer(b,2,c.FLOAT,!1,0,0);let v=c.getUniformLocation(f,"u_time"),y=c.getUniformLocation(f,"u_resolution"),w=[0,1,2,3].map($=>c.getUniformLocation(f,`u_colors[${$}]`)),N=c.getUniformLocation(f,"u_colorsCount"),T=c.getUniformLocation(f,"u_distortion"),L=c.getUniformLocation(f,"u_swirl"),P=c.getUniformLocation(f,"u_grainMixer"),R=c.getUniformLocation(f,"u_grainOverlay"),D=0,k=performance.now(),S=0,A=()=>{let $=Math.min(2,window.devicePixelRatio||1);u.width=Math.floor(h.clientWidth*$),u.height=Math.floor(h.clientHeight*$),c.viewport(0,0,u.width,u.height)},_=$=>{if(document.hidden){k=$,S=requestAnimationFrame(_);return}let{colors:oe,distortion:ae,swirl:ie,grainMixer:ne,grainOverlay:z,speed:O}=l.current,W=$-k;k=$,D+=W*O;let j=oe.map(qC);c.uniform1f(v,D*.001),c.uniform2f(y,u.width,u.height);for(let U=0;U<4;U++){let H=w[U];H&&c.uniform4fv(H,j[U]??[1,1,1,1])}c.uniform1f(N,j.length),c.uniform1f(T,ae),c.uniform1f(L,ie),c.uniform1f(P,ne),c.uniform1f(R,z),c.drawArrays(c.TRIANGLES,0,6),S=requestAnimationFrame(_)};A();let K=new ResizeObserver(A);return K.observe(h),S=requestAnimationFrame(_),()=>{cancelAnimationFrame(S),K.disconnect()}},[]),ag("div",{ref:d,className:e,children:ag("canvas",{ref:i,className:"h-full w-full","aria-hidden":!0})})}var WC=["#e0eaff","#f9ffbd","#dedede","#ffffff"],KC=["#27272a","#9a9448","#3f3f46","#18181b"];function ll(e){return e==="dark"?KC:WC}import{useCallback as JC,useState as GC}from"react";import{Play as YC,Square as QC}from"lucide-react";import{jsx as Cs,jsxs as eN}from"react/jsx-runtime";var ig="mcp-inspector-chat-mesh-animation-paused";function XC(e){try{return localStorage.getItem(e)==="true"}catch{return!1}}function lg(e){let[t,n]=GC(()=>XC(e)),o=JC(()=>{n(r=>{let s=!r;try{localStorage.setItem(e,s?"true":"false")}catch{}return s})},[e]);return{paused:t,toggle:o}}var ZC="z-50 flex h-7 w-7 cursor-pointer items-center justify-center rounded-full border border-zinc-500/60 bg-transparent text-zinc-600 transition-colors hover:border-zinc-500 hover:text-zinc-800 dark:border-zinc-500/50 dark:text-zinc-400 dark:hover:border-zinc-400 dark:hover:text-zinc-200";function cg({paused:e,onToggle:t,className:n}){return eN(ke,{children:[Cs(we,{render:Cs("button",{type:"button",onClick:t,"aria-label":e?"Resume animation":"Pause animation",className:C(ZC,n),children:e?Cs(YC,{className:"ml-px h-3 w-3",fill:"currentColor"}):Cs(QC,{className:"h-2.5 w-2.5",fill:"currentColor"})}),nativeButton:!0}),Cs(Ce,{side:"left",children:Cs("p",{children:e?"Resume animation":"Pause animation"})})]})}import{jsx as xa,jsxs as mg}from"react/jsx-runtime";var oN=.54,rN=.4,ug="linear-gradient(to top, black 0%, black 12%, rgba(0,0,0,0.55) 38%, transparent 100%)";function pg({className:e,children:t,shaderPhase:n="hidden",onShaderFadeComplete:o,meshAnimationPaused:r=!1,...s}){let a=tN(null),[i,d]=nN(!1),{resolvedTheme:l}=oo(),u=ll(l),h=l==="dark",{paused:c,toggle:m}=lg(ig),p=c||r;dg(()=>{let g=window.requestAnimationFrame(()=>d(!0));return()=>window.cancelAnimationFrame(g)},[]),dg(()=>{n==="fading"&&!i&&o?.()},[n,i,o]);let x=n!=="hidden",f=n==="visible"&&i,b=g=>{g.propertyName==="opacity"&&n==="fading"&&o?.()};return mg("div",{ref:a,className:C("relative flex min-h-0 flex-1 flex-col overflow-hidden bg-background",e),...s,children:[x&&xa("div",{className:C("pointer-events-none absolute inset-x-0 bottom-0 z-0 transition-opacity duration-500",f?"opacity-100":"opacity-0"),style:{height:`${oN*100}%`},"aria-hidden":!0,onTransitionEnd:b,children:mg("div",{className:C("absolute inset-0",i?h?"opacity-90":"opacity-75":"opacity-0"),style:{maskImage:ug,WebkitMaskImage:ug},children:[xa("div",{className:"absolute inset-0 bg-[#edf2ff] dark:hidden"}),xa(il,{className:"absolute inset-0 h-full w-full",colors:[...u],distortion:.8,swirl:.1,grainMixer:0,grainOverlay:h?.12:.3,speed:p?0:rN})]})}),x&&xa(cg,{paused:c,onToggle:m,className:"absolute bottom-3 right-3 sm:bottom-5 sm:right-5"}),xa("div",{className:"relative z-10 flex min-h-0 flex-1 flex-col",children:t})]})}function fg(e){return e?e.apiKey==="server-managed"||e.baseUrl?.includes("/inspector/llm")===!0:!1}function wa(e){if(!(e instanceof Error))return!1;let t=e.message.toLowerCase();return t.includes("failed to fetch")||t.includes("networkerror")||t.includes("network request failed")||t.includes("load failed")}function _d(e,t){if(!t)return e>=502&&e<=504?{kind:"cloud_unavailable"}:null;if(e===402)return{kind:"credits_exhausted",billingUrl:typeof t.upgradeUrl=="string"?t.upgradeUrl:typeof t.billingUrl=="string"?t.billingUrl:void 0,message:typeof t.message=="string"?t.message:"You've used your included free plan credits."};if(e===429){if(t.loginRequired&&t.loginUrl)return{kind:"login_required",loginUrl:String(t.loginUrl)};if(t.creditsExhausted)return{kind:"credits_exhausted",billingUrl:typeof t.billingUrl=="string"?t.billingUrl:void 0,message:typeof t.message=="string"?t.message:"You've used your included free plan credits."};if(t.error==="free_org_rate_limited"||typeof t.reason=="string")return{kind:"credits_exhausted",message:typeof t.message=="string"?t.message:"You've reached your included chat quota for this workspace."}}return e>=502&&e<=504?{kind:"cloud_unavailable"}:null}function sN(e){let t=e.match(/^OpenAI request failed \((\d+) /);if(!t)return null;let n=Number(t[1]),o=e.indexOf("{");if(o===-1)return null;try{let r=JSON.parse(e.slice(o));if(r&&typeof r=="object"&&!Array.isArray(r))return{status:n,body:r}}catch{}return null}function gg(e){if(e instanceof Error&&e.name==="LlmRequestError"){let t=e.status??0,n=e.body,o=n&&typeof n=="object"&&!Array.isArray(n)?n:void 0;return _d(t,o)}if(e instanceof Error){let t=sN(e.message);if(t)return _d(t.status,t.body)}return wa(e)?{kind:"cloud_unavailable"}:null}function hg(e,t){return _d(e,t)}import{ChevronDown as aN,Key as iN}from"lucide-react";import{jsx as Dn,jsxs as Od}from"react/jsx-runtime";var lN="https://cdn.mcp-use.com/mcpuse_logo_circle_dark.svg";function vg({symbolSize:e=14,className:t,textClassName:n}){return Od("span",{className:C("inline-flex items-center gap-1.5 text-black dark:text-white",t),children:[Dn(cN,{size:e}),Dn("span",{className:C("font-medium leading-none text-current [font-family:var(--font-family-outfit)]",n),children:"Manufact"})]})}function cN({size:e=14,className:t}){return Od("svg",{width:e,height:e,viewBox:"0 0 480 480","aria-hidden":!0,className:C("block shrink-0",t),children:[Dn("path",{d:"M101.7 0 C157.9 0 203.4 45.7 203.4 102.1 C203.4 126.6 202.1 152.1 212.2 174.3 L219.8 191 C233.8 221.8 258.5 246.4 289.2 260.5 L303.5 267 C326.5 277.5 353 275.8 378.3 275.8 C434.5 275.8 480 321.5 480 377.9 C480 434.3 434.5 480 378.3 480 C322.1 480 276.6 434.3 276.6 377.9 C276.6 354.2 277.7 329.6 267.8 308 L259.8 290.3 C245.7 259.5 221 234.8 190.2 220.7 L173 212.9 C151 202.9 125.8 204.2 101.7 204.2 C45.5 204.2 0 158.5 0 102.1 C0 45.7 45.5 0 101.7 0 Z",fill:"currentColor"}),Dn("circle",{cx:"96.4",cy:"383.6",r:"96.4",fill:"currentColor"}),Dn("circle",{cx:"383.6",cy:"96.4",r:"96.4",fill:"currentColor"})]})}var dN='<svg width="512" height="512" viewBox="0 0 512 512" xmlns="http://www.w3.org/2000/svg" fill="#94A3B8" stroke="#94A3B8"><g><path fill="none" d="M3 248.945C18 248.945 76 236 106 219C136 202 136 202 198 158C276.497 102.293 332 120.945 423 120.945" stroke-width="90"/><path d="M511 121.5L357.25 210.268L357.25 32.7324L511 121.5Z"/><path fill="none" d="M0 249C15 249 73 261.945 103 278.945C133 295.945 133 295.945 195 339.945C273.497 395.652 329 377 420 377" stroke-width="90"/><path d="M508 376.445L354.25 287.678L354.25 465.213L508 376.445Z"/></g></svg>',uN=`data:image/svg+xml,${encodeURIComponent(dN)}`,mN={openai:"OpenAI",anthropic:"Anthropic",google:"Google"};function pN(e){let t=e.split("/")[0]?.toLowerCase();return t==="openai"||t==="anthropic"||t==="google"?t:"openrouter"}function Ca(e,t){let n=e.trim(),o=mN[t];if(o){let s=o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),a=new RegExp(`^${s}\\s*:\\s*`,"i"),i=n.replace(a,"").trim();if(i.length>0)return i}let r=n.indexOf(": ");return r>0&&r<48?n.slice(r+2).trim():n}function bg({provider:e,model:t,displayName:n,mode:o="byok",className:r,...s}){let a=n??t,i=o==="managed"&&e==="openai-compatible"?pN(t):e;return Od("button",{type:"button",className:C("inline-flex items-center gap-1.5 min-w-0 border-0 bg-transparent p-1","font-mono text-[11px] text-muted-foreground cursor-pointer","hover:text-foreground transition-colors","rounded-md outline-none focus-visible:ring-1 focus-visible:ring-ring",r),...s,children:[o==="managed"?Dn("img",{src:lN,alt:"Manufact",className:"h-3.5 w-3.5 shrink-0 rounded-full object-cover"}):Dn(iN,{className:"size-3 shrink-0 opacity-70","aria-hidden":!0}),Dn(Jn,{provider:i,className:"shrink-0"}),Dn("span",{className:"whitespace-nowrap",children:a}),Dn(aN,{className:"size-3 shrink-0 opacity-60","aria-hidden":!0})]})}function Ot(e){switch(e){case"openai":return"OpenAI";case"openai-compatible":return"OpenAI Compatible";case"anthropic":return"Anthropic";case"google":return"Google";case"openrouter":return"OpenRouter";case"ollama":return"Ollama";default:return e}}function fN(e,t){switch(e){case"openai":case"anthropic":case"google":return Ks(`${e}.png`);case"ollama":return Ks(`${t==="dark"?"ollama_dark":"ollama_light"}.png`);case"openrouter":return uN;case"openai-compatible":return null;default:return null}}function Jn({provider:e,className:t}){let{resolvedTheme:n}=oo();if(e==="openai-compatible")return null;let o=fN(e,n);if(o){let r=e==="ollama"?"h-3.5 w-3.5 object-contain":"h-4 w-4 rounded-full object-cover";return Dn("img",{src:o,alt:Ot(e),className:C(r,t)})}return Dn("div",{"aria-label":Ot(e),className:C("flex h-4 w-4 items-center justify-center rounded-full bg-neutral-900 text-[9px] font-semibold text-white dark:bg-neutral-100 dark:text-neutral-900",t),children:Ot(e).charAt(0)})}import{useCallback as cl,useEffect as gN,useSyncExternalStore as hN}from"react";var $d="openid profile email offline_access",xg="mcp-inspector:manufact-auth",vN="manufact:session-changed",Na={loaded:!0,authorizing:!1,accessToken:null,user:null,mode:null},Ur=new Map,Ud=new Set,zd=new Map,Bd=new Map,wg=null,Hd=!1;typeof window<"u"&&window.addEventListener("message",e=>{if(e.data?.type!=="manufact:invalidate-oauth-client")return;for(let n of Ur.keys())_n()?.removeItem(dn(n,"client"));let t=wg;!t||Hd||(Hd=!0,Tg(t,{isRetry:!0}).finally(()=>{Hd=!1}))});function bN(e){let t=Ur.get(e);if(t)return t;let n={...Na,loaded:!1};return Ur.set(e,n),n}function _n(){return typeof window>"u"?null:window.localStorage}function ml(e){return new URL(e).origin}function Cg(e,t){let n=new URL(e),o=new URL(t),r=new Set(["localhost","127.0.0.1"]);return r.has(n.hostname)&&r.has(o.hostname)?n.origin===o.origin:(n.hostname==="manufact.com"||n.hostname.endsWith(".manufact.com"))&&(o.hostname==="manufact.com"||o.hostname.endsWith(".manufact.com"))}function Vd(e){let t=window.__MANUFACT_LOGIN_URL__;if(t)return new URL(t).origin;let n=new URL(e);return n.hostname==="localhost"||n.hostname==="127.0.0.1"?`${n.protocol}//${n.hostname}:3000`:`${n.protocol}//manufact.com`}function yN(e){return`${Vd(e)}/login`}function xN(e){return`${Vd(e)}/auth/embedded-sign-out`}function dn(e,t){return`${xg}:${t}:${e}`}function wN(e){return _n()?.getItem(dn(e,"skip-session"))==="1"}function ul(e,t){let n=dn(e,"skip-session");t?_n()?.setItem(n,"1"):_n()?.removeItem(n)}function CN(e){return`${xg}:state:${e}`}function Ns(e){let t=_n()?.getItem(e);if(!t)return null;try{return JSON.parse(t)}catch{return _n()?.removeItem(e),null}}function jd(e,t){_n()?.setItem(e,JSON.stringify(t))}function Ln(e,t){Ur.set(e,{...Ur.get(e)??Na,...t}),Ud.forEach(n=>n()),window.dispatchEvent(new CustomEvent(vN))}function Ng(e){let t="";return e.forEach(n=>{t+=String.fromCharCode(n)}),btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function Fd(e=32){let t=new Uint8Array(e);return crypto.getRandomValues(t),Ng(t)}async function kg(e){let t=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(e));return Ng(new Uint8Array(t))}async function pl(e){let t=await fetch(`${e}/api/auth/.well-known/openid-configuration`);if(!t.ok)throw new Error("Manufact OAuth discovery failed");return await t.json()}function Sg(){return`${window.location.origin}${Ws()}/auth/callback`}function yg(e){return e==="localhost"||e==="127.0.0.1"}function NN(e){try{let t=new URL(e).hostname,n=typeof window<"u"?new URL(window.location.href).hostname:"";return yg(t)&&yg(n)}catch{return!1}}async function kN(e,t,n){let o=new URL(`${e}/api/auth/oauth2/authorize`);o.searchParams.set("response_type","code"),o.searchParams.set("client_id",t),o.searchParams.set("redirect_uri",n),o.searchParams.set("scope",$d),o.searchParams.set("code_challenge",await kg(Fd(32))),o.searchParams.set("code_challenge_method","S256"),o.searchParams.set("state","client-probe"),o.searchParams.set("prompt","none");try{let r=await fetch(o.toString(),{method:"GET",redirect:"manual",credentials:"include"}),s=r.headers.get("location")??"";return s.includes("/auth/error")&&s.includes("invalid_client")?!1:r.status>=300&&r.status<400||r.type==="opaqueredirect"?!!s&&!s.includes("/auth/error"):!0}catch{return!1}}async function SN(e,t){let n=Sg(),o=dn(e,"client"),r=Ns(o),s=NN(e);if(!s&&r?.client_id&&r.redirect_uri===n){if(await kN(e,r.client_id,n))return r;_n()?.removeItem(o)}else s&&r?.client_id&&_n()?.removeItem(o);if(!t.registration_endpoint)throw new Error("Manufact OAuth registration is unavailable");let a=await fetch(t.registration_endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_name:"mcp-use Inspector",redirect_uris:[n],grant_types:["authorization_code","refresh_token"],response_types:["code"],token_endpoint_auth_method:"none",scope:$d})});if(!a.ok)throw new Error("Could not register Inspector with Manufact");let i=await a.json();if(!i.client_id)throw new Error("Manufact returned no OAuth client ID");let d={...i,redirect_uri:n};return jd(o,d),d}async function TN(e,t){let n=await fetch(e,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(t)}),o=await n.json().catch(()=>({}));if(!n.ok||!o.access_token)throw new Error(o.error_description??"Manufact token exchange failed");return{access_token:o.access_token,refresh_token:o.refresh_token,token_type:o.token_type,expires_at:Date.now()+(o.expires_in??3600)*1e3}}async function PN(e,t){if(!t.refresh_token)return null;let n=Bd.get(e);if(n)return n;let o=(async()=>{try{let r=await pl(e),s=Ns(dn(e,"client"));if(!s?.client_id)return null;let a=await TN(r.token_endpoint,{grant_type:"refresh_token",refresh_token:t.refresh_token,client_id:s.client_id}),i={...a,refresh_token:a.refresh_token??t.refresh_token};return jd(dn(e,"tokens"),i),i}catch{return _n()?.removeItem(dn(e,"tokens")),null}finally{Bd.delete(e)}})();return Bd.set(e,o),o}async function RN(e){let t=Ns(dn(e,"tokens"));return t?.access_token?t.expires_at>Date.now()+3e4?t:PN(e,t):null}async function MN(e,t){let n=await pl(e);if(!n.userinfo_endpoint)return null;let o=await fetch(n.userinfo_endpoint,{headers:{Authorization:`Bearer ${t}`}});if(!o.ok)return null;let r=await o.json();return r.sub?{id:r.sub,name:r.name,email:r.email,image:r.picture}:null}async function qd(e){try{let t=await fetch(`${e}/api/auth/get-session`,{credentials:"include"});return t.ok?(await t.json())?.user??null:null}catch{return null}}async function dl(e){let t=zd.get(e);if(t)return t;Ur.set(e,{...Ur.get(e)??Na,loaded:!1});let n=(async()=>{try{let o=typeof window<"u"?window.location.href:e,r=Cg(o,e),s=wN(e),a=await RN(e),i=a?await MN(e,a.access_token):null;if(i&&a){ul(e,!1),Ln(e,{loaded:!0,accessToken:a.access_token,user:i,mode:"oauth"});return}a&&!i&&_n()?.removeItem(dn(e,"tokens"));let d=r&&!s?await qd(e):null;if(d){Ln(e,{loaded:!0,accessToken:null,user:d,mode:"session"});return}Ln(e,{loaded:!0,accessToken:null,user:null,mode:null})}catch{Ln(e,{loaded:!0,accessToken:null,user:null,mode:null})}})().finally(()=>zd.delete(e));return zd.set(e,n),n}async function Tg(e,t){let n=ml(e);wg=e,ul(n,!1);let o=window.open("","manufact-oauth","width=600,height=700,resizable=yes,scrollbars=yes");if(!o)throw new Error("Allow popups to sign in with Manufact");if(Ln(n,{authorizing:!0}),Cg(window.location.href,n)){o.location.href=yN(n);let r=window.setInterval(async()=>{if(o.closed){window.clearInterval(r),Ln(n,{authorizing:!1});return}let s=await qd(n);s&&(window.clearInterval(r),o.close(),Ln(n,{loaded:!0,authorizing:!1,accessToken:null,user:s,mode:"session"}))},1e3);return}try{let r=await pl(n),s=await SN(n,r),a=Fd(64),i=Fd(),d=Sg();jd(CN(i),{authOrigin:n,clientId:s.client_id,redirectUri:d,codeVerifier:a,expiresAt:Date.now()+600*1e3});let l=new URL(r.authorization_endpoint);l.searchParams.set("response_type","code"),l.searchParams.set("client_id",s.client_id),l.searchParams.set("redirect_uri",d),l.searchParams.set("scope",$d),l.searchParams.set("state",i),l.searchParams.set("code_challenge",await kg(a)),l.searchParams.set("code_challenge_method","S256"),l.searchParams.set("prompt","consent"),o.location.href=l.toString();let u=window.setInterval(()=>{o.closed&&(window.clearInterval(u),dl(n).finally(()=>Ln(n,{authorizing:!1})))},500)}catch(r){throw o.close(),Ln(n,{authorizing:!1}),r}}function IN(e){let t=ml(e);_n()?.removeItem(dn(t,"tokens")),Ln(t,{loaded:!0,authorizing:!1,accessToken:null,user:null,mode:null})}async function EN(e){let t=Ns(dn(e,"tokens")),n=Ns(dn(e,"client")),o=t?.refresh_token??t?.access_token;if(!n?.client_id||!o)return null;try{let s=(await pl(e)).revocation_endpoint??`${e}/api/auth/oauth2/revoke`;return(await fetch(s,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({client_id:n.client_id,token:o,token_type_hint:t?.refresh_token?"refresh_token":"access_token"})})).status}catch{return-1}}async function AN(e){let t=Vd(e),n=window.open(xN(e),"manufact-sign-out","width=420,height=320");return n?new Promise(o=>{let r=!1,s=l=>{r||(r=!0,window.clearTimeout(a),window.clearInterval(d),window.removeEventListener("message",i),o(l))},a=window.setTimeout(()=>{s({attempted:!0,signOutOk:!1,signOutStatus:null})},3e4),i=l=>{l.origin===t&&l.data?.type==="manufact:sign-out-complete"&&s({attempted:!0,signOutOk:!0,signOutStatus:200})},d=window.setInterval(()=>{n.closed&&qd(e).then(l=>{s({attempted:!0,signOutOk:!l,signOutStatus:l?401:200})})},500);window.addEventListener("message",i)}):{attempted:!0,signOutOk:!1,signOutStatus:null}}async function DN(e,t){let n=ml(e),o=!!Ns(dn(n,"tokens"))?.access_token;t==="oauth"||o?(await EN(n),ul(n,!0)):t==="session"&&(await AN(n),ul(n,!1)),IN(e)}function Pg(e){let t=e?ml(e):null,n=cl(s=>(Ud.add(s),()=>Ud.delete(s)),[]),o=cl(()=>t?bN(t):Na,[t]),r=hN(n,o,()=>Na);return gN(()=>{if(!t)return;dl(t);let s=i=>{i.origin===window.location.origin&&i.data?.type==="manufact:oauth-complete"&&i.data.authOrigin===t&&dl(t).finally(()=>Ln(t,{authorizing:!1}))},a=i=>{i.key!==dn(t,"tokens")||!i.newValue||dl(t).finally(()=>Ln(t,{authorizing:!1}))};return window.addEventListener("message",s),window.addEventListener("storage",a),()=>{window.removeEventListener("message",s),window.removeEventListener("storage",a)}},[t]),{...r,authorize:cl(async()=>{e&&await Tg(e)},[e]),logout:cl(async()=>{e&&await DN(e,r.mode)},[e,r.mode])}}function Rg(e){return Pg(e)}import{useEffect as LN}from"react";function Mg(e){LN(()=>{let t=n=>{let o=n.target,r=o.tagName==="INPUT"||o.tagName==="TEXTAREA"||o.contentEditable==="true";if((n.metaKey||n.ctrlKey)&&n.key==="k"){n.preventDefault(),e.onCommandPalette?.();return}if((n.metaKey||n.ctrlKey)&&n.key==="o"&&e.onNewChat){n.preventDefault(),e.onNewChat();return}if(n.key==="Escape"){n.preventDefault(),document.activeElement instanceof HTMLElement&&document.activeElement.blur(),e.onBlurSearch?.();return}if(!r&&!(n.metaKey||n.ctrlKey||n.altKey||n.shiftKey))switch(n.key.toLowerCase()){case"t":n.preventDefault(),e.onToolsTab?.();break;case"p":n.preventDefault(),e.onPromptsTab?.();break;case"r":n.preventDefault(),e.onResourcesTab?.();break;case"c":n.preventDefault(),e.onChatTab?.();break;case"h":n.preventDefault(),e.onHome?.();break;case"f":n.preventDefault(),e.onFocusSearch?.();break;default:break}};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[e])}import{Copy as dk,Download as uk,SquarePen as mk}from"lucide-react";import{Check as _g,ChevronsUpDown as Og,Eye as qN,EyeOff as WN,Key as KN,Loader2 as zg}from"lucide-react";import{useEffect as eu,useRef as JN,useState as $r}from"react";import{Tabs as Jd}from"@base-ui/react/tabs";import{AnimatePresence as Gd,motion as fl}from"motion/react";import{createContext as BN,forwardRef as Xd,useCallback as Kd,useContext as HN,useEffect as Yd,useRef as gl,useState as UN}from"react";import{useCallback as ks,useEffect as Wd,useRef as Ss,useState as Ig}from"react";function Eg(e,t){let n=e.getBoundingClientRect(),o=t==="x"?e.offsetWidth:e.offsetHeight,r=t==="x"?n.width:n.height;return o>0?r/o:1}function _N(e,t){let n=e.getBoundingClientRect(),o=Eg(e,"x"),r=Eg(e,"y"),s=[];return t.forEach((a,i)=>{let d=a.getBoundingClientRect();s[i]={top:(d.top-n.top)/r+e.scrollTop,left:(d.left-n.left)/o+e.scrollLeft,width:a.offsetWidth,height:a.offsetHeight}}),s}function ON(e,t,n,o){let r=o==="x"?t:n,s=null,a=1/0,i=null;return e.forEach((d,l)=>{let u=d.getBoundingClientRect(),h=o==="x"?u.left:u.top,c=o==="x"?u.right:u.bottom;r>=h&&r<=c&&(i=l);let m=(h+c)/2,p=Math.abs(r-m);p<a&&(a=p,s=l)}),i??s}function zN(e,t){if(e.length!==t.length)return!0;for(let n=0;n<t.length;n++){let o=e[n],r=t[n];if(o!==r&&(!o||!r||o.top!==r.top||o.left!==r.left||o.width!==r.width||o.height!==r.height))return!0}return!1}function Ag(e,t={}){let{axis:n="y"}=t,o=Ss(new Map),[r,s]=Ig(null),[a,i]=Ig([]),d=Ss([]),l=Ss(0),u=Ss(null),h=Ss(null),c=Ss(null),m=ks(()=>{let v=e.current;if(!v)return;let y=_N(v,o.current);zN(d.current,y)&&(d.current=y,i(y))},[e]),p=ks((v,y)=>{s(ON(o.current,v,y,n))},[n]),x=ks((v,y)=>{y?o.current.set(v,y):o.current.delete(v),h.current!==null&&cancelAnimationFrame(h.current),h.current=requestAnimationFrame(()=>{h.current=null,m()})},[m]),f=ks(v=>{c.current={x:v.clientX,y:v.clientY},u.current!==null&&cancelAnimationFrame(u.current),u.current=requestAnimationFrame(()=>{u.current=null,m(),p(v.clientX,v.clientY)})},[m,p]),b=ks(()=>{l.current+=1},[]),g=ks(()=>{u.current!==null&&(cancelAnimationFrame(u.current),u.current=null),c.current=null,s(null)},[]);return Wd(()=>{let v=e.current;if(!v||typeof ResizeObserver>"u")return;let y=new ResizeObserver(()=>{h.current!==null&&cancelAnimationFrame(h.current),h.current=requestAnimationFrame(()=>{h.current=null,m()})});return y.observe(v),()=>y.disconnect()},[e,m]),Wd(()=>{let v=e.current;if(!v)return;let y=()=>{m();let w=c.current;w&&p(w.x,w.y)};return v.addEventListener("scroll",y,{capture:!0,passive:!0}),()=>v.removeEventListener("scroll",y,{capture:!0})},[e,m,p]),Wd(()=>()=>{u.current!==null&&cancelAnimationFrame(u.current),h.current!==null&&cancelAnimationFrame(h.current)},[]),{activeIndex:r,setActiveIndex:s,itemRects:a,sessionRef:l,handlers:{onMouseMove:f,onMouseEnter:b,onMouseLeave:g},registerItem:x,measureItems:m}}import{jsx as yn,jsxs as Qd}from"react/jsx-runtime";var Dg=BN(null);function FN(){let e=HN(Dg);if(!e)throw new Error("useTabsSubtle must be used within a TabsSubtle");return e}var ka=Xd(({children:e,selectedIndex:t,onSelect:n,idPrefix:o,activeLabel:r=!1,className:s,...a},i)=>{let d=gl(null),l=gl(!1),u=pt(),{activeIndex:h,setActiveIndex:c,itemRects:m,handlers:p,registerItem:x,measureItems:f}=Ag(d,{axis:"x"}),b=gl(new Map),g=Kd((k,S)=>{x(k,S),S?b.current.set(k,S):b.current.delete(k)},[x]);Yd(()=>{f()},[f,e]),Yd(()=>{let k=b.current;if(k.size===0)return;let S=new ResizeObserver(()=>f());return k.forEach(A=>S.observe(A)),()=>S.disconnect()},[f,e]);let v=Kd(k=>{l.current=!0,p.onMouseMove(k)},[p]),y=Kd(()=>{l.current=!1,p.onMouseLeave()},[p]),[w,N]=UN(null),T=m[t],L=h!==null?m[h]:null,P=w!==null?m[w]:null,R=h===t,D=h!==null&&!R;return yn(Dg.Provider,{value:{registerTab:g,hoveredIndex:h,selectedIndex:t,idPrefix:o,activeLabel:r},children:yn(Jd.Root,{value:t,onValueChange:k=>{typeof k=="number"&&n(k)},render:Qd(Jd.List,{activateOnFocus:!1,ref:k=>{d.current=k,typeof i=="function"?i(k):i&&(i.current=k)},onMouseMove:v,onMouseLeave:y,onFocus:k=>{let S=k.target.closest("[data-proximity-index]")?.getAttribute("data-proximity-index");if(S!=null){let A=Number(S);c(A),N(k.target.matches(":focus-visible")?A:null)}},onBlur:k=>{d.current?.contains(k.relatedTarget)||(N(null),!l.current&&c(null))},className:C("relative flex items-center gap-0.5 select-none overflow-x-auto max-w-full -mx-1 px-1 -my-1 py-1",s),...a,children:[T&&yn(fl.div,{className:C("absolute bg-accent pointer-events-none",u.bg),initial:!1,animate:{left:T.left,width:T.width,top:T.top,height:T.height,opacity:D?.8:1},transition:{...se.moderate,opacity:{duration:.08}}}),yn(Gd,{children:L&&!R&&T&&yn(fl.div,{className:C("absolute bg-accent pointer-events-none",u.bg),initial:{left:T.left,width:T.width,top:T.top,height:T.height,opacity:0},animate:{left:L.left,width:L.width,top:L.top,height:L.height,opacity:.4},exit:!l.current&&T?{left:T.left,width:T.width,top:T.top,height:T.height,opacity:0,transition:{...se.moderate,opacity:{duration:.06}}}:{opacity:0,transition:se.fast.exit},transition:{...se.fast,opacity:{duration:.08}}})}),yn(Gd,{children:P&&yn(fl.div,{className:C("absolute pointer-events-none z-20 border border-[color:var(--focus-ring,#6B97FF)]",u.focusRing),initial:!1,animate:{left:P.left-2,top:P.top-2,width:P.width+4,height:P.height+4},exit:{opacity:0,transition:se.fast.exit},transition:{...se.fast,opacity:{duration:.08}}})}),e]})})})});ka.displayName="TabsSubtle";var Fr=Xd(({icon:e,label:t,index:n,className:o,...r},s)=>{let a=gl(null),i=pt(),{registerTab:d,hoveredIndex:l,selectedIndex:u,idPrefix:h,activeLabel:c}=FN();Yd(()=>(d(n,a.current),()=>d(n,null)),[n,d]);let m=u===n,p=l===n||m,x=c&&!!e,f=!x||m,b=Qd("span",{className:"inline-grid",children:[yn("span",{className:"col-start-1 row-start-1 invisible [text-box:trim-both_cap_alphabetic]",style:{fontVariationSettings:yt.semibold},"aria-hidden":"true",children:t}),yn("span",{className:C("col-start-1 row-start-1 transition-[color,font-variation-settings] duration-80 [text-box:trim-both_cap_alphabetic]",p?"text-foreground":"text-muted-foreground"),style:{fontVariationSettings:m?yt.semibold:yt.normal},children:t})]});return Qd(Jd.Tab,{ref:g=>{let v=g;a.current=v,typeof s=="function"?s(v):s&&(s.current=v)},value:n,"data-proximity-index":n,id:h?`${h}-tab-${n}`:void 0,"aria-controls":h?`${h}-panel-${n}`:void 0,"aria-label":x&&!f?t:void 0,className:C("relative z-10 flex items-center px-2 cursor-pointer bg-transparent border-none outline-none text-xs",x?"h-7":"h-7 gap-1.5",i.bg,o),...r,children:[e&&yn(e,{size:14,strokeWidth:p?2:1.5,className:C("shrink-0 transition-[color,stroke-width] duration-80",p?"text-foreground":"text-muted-foreground")}),x?yn(Gd,{children:f&&yn(fl.span,{className:"overflow-hidden",initial:{width:0,opacity:0,marginLeft:0},animate:{width:"auto",opacity:1,marginLeft:6},exit:{width:0,opacity:0,marginLeft:0},transition:{...se.fast,opacity:{duration:.06}},children:b},"label")}):b]})});Fr.displayName="TabsSubtleItem";var $N=Xd(({index:e,selectedIndex:t,idPrefix:n,children:o,className:r,...s},a)=>{let i=t===e;return yn("div",{ref:a,id:`${n}-panel-${e}`,role:"tabpanel","aria-labelledby":`${n}-tab-${e}`,hidden:!i,tabIndex:-1,className:C("outline-none",r),...s,children:i&&o})});$N.displayName="TabsSubtlePanel";import*as Rt from"react";import{jsx as ar,jsxs as jN}from"react/jsx-runtime";var Lg=Rt.createContext(null);function Zd(){let e=Rt.useContext(Lg);if(!e)throw new Error("Command components must be used within <Command>");return e}function VN(e,t){return t?e.toLowerCase().includes(t.toLowerCase()):!0}var hl=Rt.forwardRef(({className:e,...t},n)=>{let[o,r]=Rt.useState(""),[s,a]=Rt.useState(null),[i,d]=Rt.useState(0),l=Rt.useCallback(()=>(d(u=>u+1),()=>d(u=>Math.max(0,u-1))),[]);return ar(Lg.Provider,{value:{search:o,setSearch:r,activeValue:s,setActiveValue:a,visibleCount:i,registerVisible:l},children:ar("div",{ref:n,className:C("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t})})});hl.displayName="Command";var vl=Rt.forwardRef(({className:e,...t},n)=>{let{search:o,setSearch:r}=Zd();return ar("div",{className:"flex items-center border-b px-3",children:ar("input",{ref:n,value:o,onChange:s=>r(s.target.value),className:C("flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",e),...t})})});vl.displayName="CommandInput";var bl=Rt.forwardRef(({className:e,...t},n)=>ar("div",{ref:n,className:C("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));bl.displayName="CommandList";var yl=Rt.forwardRef(({className:e,...t},n)=>{let{visibleCount:o}=Zd();return o>0?null:ar("div",{ref:n,className:C("py-6 text-center text-sm",e),...t})});yl.displayName="CommandEmpty";var xl=Rt.forwardRef(({className:e,heading:t,children:n,...o},r)=>jN("div",{ref:r,className:C("overflow-hidden p-1 text-foreground [&_[data-command-group-heading]]:px-2 [&_[data-command-group-heading]]:py-1.5 [&_[data-command-group-heading]]:text-xs [&_[data-command-group-heading]]:font-medium [&_[data-command-group-heading]]:text-muted-foreground",e),...o,children:[t?ar("div",{"data-command-group-heading":"",children:t}):null,n]}));xl.displayName="CommandGroup";var wl=Rt.forwardRef(({className:e,value:t,keywords:n,onSelect:o,disabled:r,onClick:s,...a},i)=>{let{search:d,activeValue:l,setActiveValue:u,registerVisible:h}=Zd(),c=Array.isArray(n)?n.join(" "):n,m=c?`${t} ${c}`:t,p=VN(m,d),x=l===t;return Rt.useLayoutEffect(()=>{if(p)return h()},[p,h]),Rt.useEffect(()=>{p&&l===null&&!r&&u(t)},[p,l,r,u,t]),p?ar("div",{ref:i,role:"option","aria-selected":x,"data-selected":x,"data-disabled":r,className:C("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50",e),onMouseEnter:()=>!r&&u(t),onClick:f=>{s?.(f),r||o?.(t)},...a}):null});wl.displayName="CommandItem";import{buildOllamaApiUrl as GN,normalizeOllamaBaseUrl as YN,OllamaCorsError as QN}from"@mcp-use/agent";import{Fragment as ck,jsx as G,jsxs as _e}from"react/jsx-runtime";var tu="mcp-inspector-models-cache",XN=1440*60*1e3;function Bg(){try{let e=localStorage.getItem(tu);if(e)return JSON.parse(e)}catch(e){console.error("Failed to load models cache:",e)}return{}}function ZN(e,t){try{let n=Bg();n[e]={models:t,timestamp:Date.now()},localStorage.setItem(tu,JSON.stringify(n))}catch(n){console.error("Failed to save models cache:",n)}}function ek(e){try{let t=Bg(),n=t[e];if(n){if(Date.now()-n.timestamp<XN)return n.models;delete t[e],localStorage.setItem(tu,JSON.stringify(t))}}catch(t){console.error("Failed to get cached models:",t)}return null}function tk(e,t){if(!So(e)||!t?.trim())return e;let n=e==="ollama"?YN(t):t.trim().toLowerCase();return`${e}:${n}`}var nk="chat-config-source";function Sa(e){return e==="openai"||e==="anthropic"||e==="google"?e:"openrouter"}async function ok(e,t){let n={};t&&(n.Authorization=`Bearer ${t}`);let o;try{o=await fetch(`${e}/models`,{headers:n})}catch{throw new Error("Failed to reach the server. Check the URL is correct and that CORS is enabled on the server.")}if(!o.ok)throw new Error(`Failed to fetch models: ${o.statusText}`);if(!(o.headers.get("content-type")??"").includes("application/json"))throw new Error("Invalid URL \u2014 response was not JSON");let s=await o.json();if(!Array.isArray(s?.data))throw new Error("Unexpected response format \u2014 expected { data: [...] } from the OpenAI-compatible endpoint");return s.data.map(a=>({id:a.id}))}async function rk(e){let t=await fetch("https://api.openai.com/v1/models",{headers:{Authorization:`Bearer ${e}`}});if(!t.ok)throw new Error(`Failed to fetch OpenAI models: ${t.statusText}`);return(await t.json()).data.map(o=>({id:o.id}))}async function sk(e){let t=await fetch("https://api.anthropic.com/v1/models",{headers:{"x-api-key":e,"anthropic-version":"2023-06-01","anthropic-dangerous-direct-browser-access":"true"}});if(!t.ok)throw new Error(`Failed to fetch Anthropic models: ${t.statusText}`);return(await t.json()).data.map(o=>({id:o.id,displayName:o.display_name}))}async function ak(e){let t=await fetch(`https://generativelanguage.googleapis.com/v1beta/models?key=${e}`);if(!t.ok)throw new Error(`Failed to fetch Google models: ${t.statusText}`);return((await t.json()).models||[]).map(o=>({id:o.name,displayName:o.displayName}))}async function ik(e){let t=await fetch("https://openrouter.ai/api/v1/models",{headers:{Authorization:`Bearer ${e}`}});if(!t.ok)throw new Error(`Failed to fetch OpenRouter models: ${t.statusText}`);return(await t.json()).data.map(o=>({id:o.id,displayName:o.name}))}async function lk(e,t){let n;try{n=await fetch(GN(e,"/api/tags"),{headers:{...t.trim()?{Authorization:`Bearer ${t.trim()}`}:{}}})}catch(r){throw new QN(r)}if(!n.ok)throw new Error(`Failed to fetch Ollama models: ${n.statusText}`);return((await n.json()).models||[]).map(r=>({id:r.model||r.name||""}))}function Ta({open:e,onOpenChange:t,tempProvider:n,tempModel:o,tempApiKey:r,tempBaseUrl:s,onProviderChange:a,onModelChange:i,onApiKeyChange:d,onBaseUrlChange:l,onSave:u,onClear:h,showClearButton:c=!1,buttonLabel:m="Configure API Key",hostedInspector:p=!1,freeTierInfo:x,managedCloudInfo:f,useManagedCloud:b=!1,onSaveManagedCloud:g}){let{resolvedTheme:v}=oo(),y=ll(v),w=v==="dark",[N,T]=$r([]),[L,P]=$r(!1),[R,D]=$r(null),[k,S]=$r(!1),[A,_]=$r(!1),[K,$]=$r(!1),[oe,ae]=$r(b?0:1),ie=tk(n,s),ne=!!(p||x||f),z=!!(f&&oe===0);eu(()=>{e&&ae(b?0:1)},[e,b]),eu(()=>{let Y=Lr(n),q=So(n);if(z||!e||!n||Y&&!r.trim()||q&&!s.trim()){T([]),D(null);return}let Ne=setTimeout(async()=>{let gt=ek(ie);if(gt){T(gt),D(null);return}P(!0),D(null);try{let qe=[];n==="openai-compatible"?qe=await ok(s,r):n==="openai"?qe=await rk(r):n==="anthropic"?qe=await sk(r):n==="google"?qe=await ak(r):n==="openrouter"?qe=await ik(r):n==="ollama"&&(qe=await lk(s,r)),ZN(ie,qe),T(qe)}catch(qe){D(qe instanceof Error?qe.message:"Failed to fetch models. Please check your API key."),T([])}finally{P(!1)}},500);return()=>clearTimeout(Ne)},[r,s,n,e,ie,z]);let O=JN(null);eu(()=>{if(!e||z){e||(O.current=null);return}let Y=O.current;Y!==null&&Y!==n&&i(""),O.current=n},[n,e,i,z]);let W=So(n),j=!Lr(n),U=e&&(!Lr(n)||!!r.trim())&&(!W||!!s.trim()),H=j?"API Key (optional)":"API Key",Te=j?n==="ollama"?"Leave empty for local Ollama":"Enter your API key (optional)":"Enter your API key",Pe=n==="openai-compatible"?"http://localhost:11434/v1":er(n),le=n==="openai-compatible"?"Base URL of your OpenAI-compatible API. Local servers must have CORS enabled.":null,de=n==="ollama"?"Optional for local Ollama. Stored locally and never sent to our servers.":"Your API key is stored locally and never sent to our servers.",De=f?f.models.reduce((Y,q)=>(Y[q.provider]||(Y[q.provider]=[]),Y[q.provider].push(q),Y),{}):{},Re=f?.models.find(Y=>Y.id===f.selectedModelId),Oe=Object.keys(De),Be=Re?.provider??Oe[0]??"",tt=Be?De[Be]??[]:[],V=!!h&&c&&(!f||oe===1),ce=()=>{if(z&&g){g();return}u()},Fe=z?!!(f?.isLoading||!f?.selectedModelId||f?.models.length===0):Lr(n)&&!r.trim()||W&&!s.trim()||!o.trim();return G(fn,{open:e,onOpenChange:t,children:_e(on,{className:"max-w-md","data-testid":"chat-config-dialog",children:[_e(Qt,{children:[G(qt,{children:ne?"Configure Chat":"LLM Provider Configuration"}),G(ho,{children:f?"Pick a Manufact cloud model or bring your own API key.":x?"Chat requires an LLM. You can chat for free if you have a Manufact account, or you can use your own API key (not sent to Manufact).":"Configure your LLM provider and API key to start chatting with the MCP server"})]}),_e("div",{className:"space-y-4",children:[x&&_e("button",{type:"button",onClick:x.onLoginClick,"data-testid":"chat-config-sign-in-card",className:"relative w-full cursor-pointer overflow-hidden rounded-2xl border-0 text-left transition-opacity hover:opacity-95 active:opacity-90",children:[G("div",{className:"absolute inset-0 bg-[#edf2ff] dark:bg-background","aria-hidden":!0}),G("div",{className:"absolute inset-0 dark:opacity-90",children:G(il,{className:"absolute inset-0 h-full w-full",colors:[...y],grainOverlay:w?.1:.15})}),_e("div",{className:"relative flex items-center justify-between gap-4 px-4 py-3.5",children:[_e("div",{className:"text-sm font-medium text-foreground",children:[G("p",{children:"Chat for free with a"}),_e("p",{className:"mt-1 flex items-center gap-1.5",children:[G(vg,{symbolSize:14,textClassName:"text-sm"}),"account"]})]}),G(E,{size:"sm",render:G("span",{"aria-hidden":"true"}),nativeButton:!1,tabIndex:-1,className:"pointer-events-none shrink-0",children:"Sign in"})]})]}),f&&G("div",{className:"flex justify-center",children:_e(ka,{selectedIndex:oe,onSelect:ae,idPrefix:nk,className:"w-fit",children:[G(Fr,{index:0,label:"Manufact cloud"}),G(Fr,{index:1,label:"API key"})]})}),_e("div",{className:C("space-y-2",f&&"!mt-2"),children:[G(nt,{children:"Provider"}),z?_e(kn,{value:Be,onValueChange:Y=>{let q=f?.models.find(M=>M.provider===Y);q&&f?.onModelChange(q.id)},children:[G(Vn,{className:"rounded-md",leading:Be?G(Jn,{provider:Sa(Be),className:"shrink-0"}):void 0,children:G(Fn,{})}),G($n,{children:Oe.map(Y=>G(Wt,{value:Y,label:Ot(Sa(Y)),children:_e("div",{className:"flex items-center gap-2",children:[G(Jn,{provider:Sa(Y)}),G("span",{children:Ot(Sa(Y))})]})},Y))})]}):_e(kn,{value:n,onValueChange:Y=>a(Y),children:[G(Vn,{className:"rounded-md",leading:G(Jn,{provider:n,className:"shrink-0"}),children:G(Fn,{})}),_e($n,{children:[G(Wt,{value:"openai",label:Ot("openai"),children:_e("div",{className:"flex items-center gap-2",children:[G(Jn,{provider:"openai"}),G("span",{children:Ot("openai")})]})}),G(Wt,{value:"anthropic",label:Ot("anthropic"),children:_e("div",{className:"flex items-center gap-2",children:[G(Jn,{provider:"anthropic"}),G("span",{children:Ot("anthropic")})]})}),G(Wt,{value:"google",label:Ot("google"),children:_e("div",{className:"flex items-center gap-2",children:[G(Jn,{provider:"google"}),G("span",{children:Ot("google")})]})}),G(Wt,{value:"ollama",label:Ot("ollama"),children:_e("div",{className:"flex items-center gap-2",children:[G(Jn,{provider:"ollama"}),G("span",{children:Ot("ollama")})]})}),G(Wt,{value:"openrouter",label:Ot("openrouter"),children:_e("div",{className:"flex items-center gap-2",children:[G(Jn,{provider:"openrouter"}),G("span",{children:Ot("openrouter")})]})}),G(Wt,{value:"openai-compatible",label:Ot("openai-compatible"),children:G("div",{className:"flex items-center gap-2",children:G("span",{children:Ot("openai-compatible")})})})]})]})]}),!z&&W&&_e("div",{className:"space-y-2",children:[G(nt,{children:"Base URL"}),G(Ge,{value:s,onChange:Y=>l(Y.target.value),placeholder:Pe,"data-testid":"chat-config-base-url-input"}),le&&G("p",{className:"text-xs text-muted-foreground",children:le})]}),!z&&_e("div",{className:"space-y-2",children:[G(nt,{children:H}),_e("div",{className:"relative",children:[G(Ge,{type:K?"text":"password",value:r,onChange:Y=>d(Y.target.value),placeholder:Te,className:"pr-10","data-testid":"chat-config-api-key-input"}),G(E,{type:"button",variant:"ghost",size:"sm",className:"absolute right-0 top-0 h-full px-3 py-2 hover:bg-transparent",onClick:()=>$(!K),children:K?G(WN,{className:"h-4 w-4 text-muted-foreground"}):G(qN,{className:"h-4 w-4 text-muted-foreground"})})]}),G("p",{className:"text-xs text-muted-foreground",children:de})]}),z?_e("div",{className:"space-y-2",children:[G(nt,{children:"Model"}),f?.isLoading?_e("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[G(zg,{className:"h-4 w-4 animate-spin"}),G("span",{children:"Loading models\u2026"})]}):tt.length>0?_e(Jo,{open:A,modal:!0,onOpenChange:_,children:[G(Go,{render:_e(E,{variant:"outline",role:"combobox","aria-expanded":A,className:"w-full justify-between rounded-md","data-testid":"chat-config-cloud-model-select",children:[G("span",{className:"inline-flex min-w-0 items-center gap-2 truncate",children:Re?_e(ck,{children:[G(Jn,{provider:Sa(Re.provider),className:"shrink-0"}),G("span",{className:"truncate",children:Ca(Re.name,Re.provider)})]}):"Select a model\u2026"}),G(Og,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]}),nativeButton:!0}),G(Yo,{className:"w-full p-0",align:"start",children:_e(hl,{children:[G(vl,{placeholder:"Search models\u2026",className:"h-9"}),_e(bl,{children:[G(yl,{children:"No model found."}),G(xl,{children:tt.map(Y=>_e(wl,{value:Y.id,keywords:[Y.name,Y.id,Y.provider],onSelect:q=>{f?.onModelChange(q),_(!1)},children:[Ca(Y.name,Y.provider),G(_g,{className:C("ml-auto h-4 w-4",f?.selectedModelId===Y.id?"opacity-100":"opacity-0")})]},Y.id))})]})]})})]}):G("p",{className:"text-sm text-muted-foreground",children:"Cloud models unavailable \u2014 try again or use your own key."})]}):U&&_e("div",{className:"space-y-2",children:[G(nt,{children:"Model"}),L?_e("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[G(zg,{className:"h-4 w-4 animate-spin"}),G("span",{children:"Loading models..."})]}):R?G("div",{className:"text-sm text-destructive",children:R}):N.length>0?_e(Jo,{open:k,modal:!0,onOpenChange:S,children:[G(Go,{render:_e(E,{variant:"outline",role:"combobox","aria-expanded":k,className:"w-full justify-between rounded-md","data-testid":"chat-config-model-select",children:[G("span",{className:"truncate",children:o&&(N.find(Y=>Y.id===o)?.displayName||N.find(Y=>Y.id===o)?.id)||"Select a model..."}),G(Og,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]}),nativeButton:!0}),G(Yo,{className:"w-full p-0",align:"start",children:_e(hl,{children:[G(vl,{placeholder:"Search models...",className:"h-9"}),_e(bl,{children:[G(yl,{children:"No model found."}),G(xl,{children:N.map(Y=>_e(wl,{value:Y.id,keywords:Y.displayName,onSelect:q=>{i(q===o?"":q),S(!1)},children:[Y.displayName||Y.id,G(_g,{className:C("ml-auto h-4 w-4",o===Y.id?"opacity-100":"opacity-0")})]},Y.id))})]})]})})]}):G(Ge,{value:o,onChange:Y=>i(Y.target.value),placeholder:"Enter model name manually","data-testid":"chat-config-model-input"})]}),_e("div",{className:"flex justify-between",children:[V&&G(E,{variant:"outline",onClick:h,children:"Clear Config"}),_e(E,{onClick:ce,disabled:Fe,className:V?"ml-auto":"","data-testid":"chat-config-save-button",children:[G(KN,{className:"h-4 w-4 mr-2"}),"Save Configuration"]})]})]})]})})}var nu="rounded-full bg-background/80 backdrop-blur-md supports-[backdrop-filter]:bg-background/60 dark:bg-zinc-950/75 dark:supports-[backdrop-filter]:bg-zinc-950/55",ou=C(nu,"w-fit"),Cl=C(nu,"h-9 gap-1.5 px-3");import{jsx as Mt,jsxs as lo}from"react/jsx-runtime";var pk="chat-view";function ru({llmConfig:e,hasMessages:t,configDialogOpen:n,onConfigDialogOpenChange:o,onClearChat:r,tempProvider:s,tempModel:a,tempApiKey:i,tempBaseUrl:d,onProviderChange:l,onModelChange:u,onApiKeyChange:h,onBaseUrlChange:c,onSaveConfig:m,onClearConfig:p,hideConfigButton:x,hostedInspector:f,freeTierInfo:b,managedCloudInfo:g,useManagedCloud:v,onSaveManagedCloud:y,showClearButton:w,clearButtonLabel:N,hideTitle:T,clearButtonHideIcon:L,clearButtonHideShortcut:P,clearButtonVariant:R,hideClearButton:D,onCopyChat:k,onExportChat:S,activeChatId:A,chatTitle:_,showViewToggle:K,viewIndex:$=0,onViewIndexChange:oe,elevatedHeader:ae}){return lo("div",{className:C("relative flex w-full items-center gap-2 overflow-visible",Lo,ae?"pointer-events-none absolute top-0 right-0 z-50":"absolute top-0 right-0 z-10"),children:[Mt("div",{className:C("flex min-w-0 flex-1 items-center",ae&&"pointer-events-auto"),children:!T&&Mt("h2",{className:C(_o,ou),children:A?Mt(va,{chatId:A,title:_??rr},A):rr})}),K&&oe&&Mt("div",{className:C("absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 overflow-visible px-1",ae&&"pointer-events-auto"),children:lo(ka,{selectedIndex:$,onSelect:oe,idPrefix:pk,className:"shrink-0 overflow-visible","data-testid":"chat-view-tabs",children:[Mt(Fr,{label:"Conv",index:0}),Mt(Fr,{label:"Raw",index:1})]})}),lo("div",{className:C("ml-auto flex shrink-0 items-center gap-2",ae&&"pointer-events-auto"),children:[!D&&t&&lo("div",{className:"flex items-center gap-1",children:[k&&lo(E,{"data-testid":"chat-copy-button",variant:"ghost",size:"sm",className:Cl,onClick:k,children:[Mt(dk,{className:"h-4 w-4"}),Mt("span",{className:"hidden sm:inline",children:"Copy"})]}),S&&lo(Cr,{children:[Mt(Ho,{render:lo(E,{"data-testid":"chat-export-button",variant:"ghost",size:"sm",className:Cl,children:[Mt(uk,{className:"h-4 w-4"}),Mt("span",{className:"hidden sm:inline",children:"Export"})]}),nativeButton:!0}),lo(Nr,{align:"end",children:[Mt(Nn,{"data-testid":"chat-export-json",onClick:()=>S("json"),children:"Export as JSON"}),Mt(Nn,{"data-testid":"chat-export-markdown",onClick:()=>S("markdown"),children:"Export as Markdown"})]})]}),Mt("div",{className:"w-px h-4 bg-border mx-1"}),lo(ke,{children:[Mt(we,{render:lo(E,{variant:R??"default",size:"default",className:`p-2 cursor-pointer ${P?"sm:px-3":"sm:pr-1 sm:pl-3"}`,onClick:r,children:[!L&&Mt(mk,{className:"h-4 w-4 sm:mr-2"}),Mt("span",{className:"hidden sm:inline",children:N??"New Chat"}),!P&&Mt("span",{className:"hidden sm:inline text-[12px] border text-zinc-300 p-1 rounded-full border-zinc-300 dark:text-zinc-600 dark:border-zinc-500 ml-2",children:"\u2318O"})]}),nativeButton:!0}),Mt(Ce,{children:Mt("p",{children:N??"New Chat"})})]})]}),(!x||f||b||g)&&Mt(Ta,{open:n,onOpenChange:o,tempProvider:s,tempModel:a,tempApiKey:i,tempBaseUrl:d,onProviderChange:l,onModelChange:u,onApiKeyChange:h,onBaseUrlChange:c,onSave:m,onClear:p,showClearButton:w??(!!e&&!b&&!g),buttonLabel:e?"Change API Key":"Configure API Key",hostedInspector:f,freeTierInfo:b,managedCloudInfo:g,useManagedCloud:v,onSaveManagedCloud:y})]})]})}import{ArrowUp as Yk,Loader2 as Qk}from"lucide-react";import{Image as vk,Paperclip as bk,X as yk}from"lucide-react";import{useRef as xk}from"react";import{Wrench as fk}from"lucide-react";import{useCallback as Hg,useMemo as gk,useState as hk}from"react";import{jsx as Mo,jsxs as ir}from"react/jsx-runtime";function Ug({tools:e,disabledTools:t,onDisabledToolsChange:n,disabled:o}){let[r,s]=hk(!1),a=e.length-t.size,i=t.size===0,d=t.size>0&&t.size<e.length,l=Hg(c=>{let m=new Set(t);m.has(c)?m.delete(c):m.add(c),n(m)},[t,n]),u=Hg(()=>{n(i?new Set(e.map(c=>c.name)):new Set)},[i,e,n]),h=gk(()=>[...e].sort((c,m)=>c.name.localeCompare(m.name)),[e]);return e.length===0?null:ir(Jo,{open:r,onOpenChange:s,children:[ir(ke,{children:[Mo(we,{render:Mo(Go,{render:ir(E,{variant:"ghost",size:"sm",disabled:o,className:C("h-auto gap-1 rounded-full px-2 py-2",d?"text-amber-500 dark:text-amber-400":"text-muted-foreground hover:text-foreground"),type:"button","data-testid":"chat-tool-selector",children:[Mo(fk,{className:"h-4 w-4 shrink-0"}),d&&Mo("span",{className:"flex h-3.5 min-w-3.5 items-center justify-center rounded-full bg-amber-500 px-1 text-[9px] font-bold leading-none text-white",children:a})]}),nativeButton:!0}),nativeButton:!0}),Mo(Ce,{side:"top",children:ir("p",{children:["Tools (",a,"/",e.length,")"]})})]}),ir(Yo,{className:"w-72 gap-0 p-0",align:"start",side:"top",sideOffset:8,children:[ir("div",{className:"flex items-center justify-between px-3 py-2 border-b",children:[ir("span",{className:"text-xs font-medium text-muted-foreground",children:["Allowed Tools (",a,"/",e.length,")"]}),Mo(E,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:u,type:"button",children:i?"Disable All":"Enable All"})]}),Mo("div",{className:"max-h-64 overflow-y-auto",children:h.map(c=>{let m=!t.has(c.name);return ir("button",{type:"button",className:"flex items-center gap-2.5 w-full px-3 py-1.5 text-left hover:bg-accent/50 transition-colors cursor-pointer",onClick:()=>l(c.name),children:[Mo(ma,{checked:m,className:"pointer-events-none",tabIndex:-1}),Mo("span",{className:"min-w-0 flex-1 truncate text-sm font-mono",children:c.name})]},c.name)})})]})]})}import{jsx as On,jsxs as Pa}from"react/jsx-runtime";function Fg({inputValue:e,isConnected:t,isLoading:n,textareaRef:o,attachments:r,placeholder:s="Ask a question",className:a,showAttachButton:i=!0,tools:d,disabledTools:l,onDisabledToolsChange:u,onInputChange:h,onKeyDown:c,onKeyUp:m,onClick:p,onAttachmentAdd:x,onAttachmentRemove:f,inlineControls:b,trailingControls:g}){let v=pt(),y=xk(null),w=T=>{let L=T.target.files;if(L&&L.length>0)for(let P=0;P<L.length;P++)x(L[P]);y.current&&(y.current.value="")},N=r.length>0;return Pa("div",{className:"relative w-full",children:[N&&On("div",{className:"absolute top-0 left-0 right-0 z-20 p-3 flex gap-2 flex-wrap",children:r.map((T,L)=>Pa("div",{className:"relative group bg-zinc-100/90 dark:bg-zinc-900/90 backdrop-blur-sm rounded-lg p-2 flex items-center gap-2 border border-zinc-200 dark:border-zinc-700","data-testid":`chat-attachment-${L}`,children:[On(vk,{className:"h-4 w-4 text-muted-foreground shrink-0"}),Pa("div",{className:"flex flex-col min-w-0",children:[On("span",{className:"text-xs font-medium truncate max-w-[150px]",children:T.name||"Image"}),T.size&&On("span",{className:"text-xs text-muted-foreground",children:Fp(T.size)})]}),On("button",{onClick:()=>f(L),className:"shrink-0 p-1 rounded-full hover:bg-zinc-200 dark:hover:bg-zinc-800 transition-colors",title:"Remove attachment",type:"button","data-testid":`chat-attachment-remove-${L}`,children:On(yk,{className:"h-3 w-3"})})]},L))}),On(no,{ref:o,value:e,onChange:T=>h(T.target.value),onKeyDown:c,onKeyUp:m,onClick:p,placeholder:t?s:"Server not connected",className:C("p-4 min-h-[150px] max-h-[300px]",v.container,N&&"pt-20",a),disabled:!t||n,"data-testid":"chat-input"}),On("input",{ref:y,type:"file",accept:"image/*",multiple:!0,onChange:w,className:"hidden","aria-label":"Upload images"}),Pa("div",{className:"absolute inset-x-0 bottom-0 flex items-center justify-between gap-2 p-3",children:[Pa("div",{className:"flex min-w-0 flex-1 items-center gap-1",children:[i&&On(E,{variant:"ghost",size:"sm",onClick:()=>y.current?.click(),disabled:!t||n,className:"h-auto w-auto aspect-square rounded-full p-2 text-muted-foreground hover:text-foreground",title:"Attach images",type:"button","data-testid":"chat-attach-button",children:On(bk,{className:"h-4 w-4"})}),d&&d.length>0&&l&&u&&On(Ug,{tools:d,disabledTools:l,onDisabledToolsChange:u,disabled:!t||n}),b]}),g?On("div",{className:"flex shrink-0 items-center gap-1.5",children:g}):null]})]})}import{MessageSquare as wk,X as Ck}from"lucide-react";import{jsx as Ra,jsxs as Nk}from"react/jsx-runtime";function $g({promptResults:e,onDeletePromptResult:t}){return Ra("div",{className:"absolute top-4 left-4 right-4 flex gap-2 overflow-x-auto z-20 flex-nowrap",style:{scrollbarWidth:"none",msOverflowStyle:"none"},children:e.map(({promptName:n},o)=>Nk(E,{type:"button",className:"flex items-center gap-2 bg-zinc-200 text-zinc-700 dark:text-zinc-300 text-[10px] px-1.5 py-0.5 dark:bg-zinc-700 rounded-lg border border-zinc-200 dark:border-zinc-300 font-medium hover:bg-zinc-300 dark:hover:bg-zinc-600",children:[Ra(wk,{className:"h-3.5 w-3.5 shrink-0"}),Ra("span",{className:"truncate",title:n,children:n}),Ra("span",{className:"ml-1 h-4 w-4 rounded-full bg-zinc-400 dark:bg-zinc-600 hover:bg-zinc-500 dark:hover:bg-zinc-500 flex items-center justify-center cursor-pointer shrink-0 transition-colors",onClick:r=>{r.stopPropagation(),t(o)},title:"Remove prompt",role:"button",tabIndex:0,children:Ra(Ck,{className:"h-2.5 w-2.5 text-white"})})]},o))})}import{MessageSquare as kk}from"lucide-react";import{useEffect as Sk}from"react";import{jsx as lr,jsxs as Nl}from"react/jsx-runtime";function Vg({isOpen:e,focusedIndex:t,prompts:n,selectedPrompt:o,onPromptSelect:r}){return e?(Sk(()=>{if(t>=0){let s=document.getElementById(`prompt-${t}`);s&&s.scrollIntoView({behavior:"smooth",block:"nearest"})}},[t]),lr("div",{className:"absolute bottom-full left-0 right-0 max-w-3xl w-full max-h-[300px] overflow-y-auto rounded-lg border border-zinc-200 dark:border-zinc-800 bg-white dark:bg-zinc-900 shadow-lg z-30 flex flex-col gap-2 mb-1","data-testid":"chat-prompts-dropdown",children:Nl("div",{className:"p-2",children:[lr("div",{className:"text-xs font-medium text-zinc-900 dark:text-zinc-100 mb-2",children:"Prompts"}),n.map((s,a)=>Nl(ke,{children:[lr(we,{render:Nl(E,{id:`prompt-${a}`,type:"button",variant:"ghost",className:C("w-full flex items-center px-3 py-2 rounded-md hover:bg-zinc-200 dark:hover:bg-zinc-700 transition-colors text-left justify-start",t===a&&"bg-zinc-200 dark:bg-zinc-700"),onClick:()=>r(s),"data-testid":`chat-prompt-option-${a}`,children:[lr("div",{className:"flex items-center justify-center shrink-0",children:lr(kk,{className:"h-4 w-4 text-zinc-600 dark:text-zinc-400"})}),lr("div",{className:"flex-1 min-w-0",children:Nl("div",{className:"text-sm font-medium text-zinc-900 dark:text-zinc-100 flex items-center gap-2",children:[s.name,o?.name===s.name&&lr(Kt,{className:"size-3 text-zinc-600 dark:text-zinc-400"})]})})]}),nativeButton:!0}),lr(Ce,{children:s.description})]},a))]})})):null}import{motion as Vk}from"motion/react";import{useMemo as oh,useState as rh}from"react";import{ExternalLink as $k}from"lucide-react";import{toast as sh}from"sonner";import{forwardRef as Lk,useCallback as un,useEffect as Gn,useId as _k,useMemo as Ia,useRef as Io,useState as Vr}from"react";import{AnimatePresence as Rs,motion as co}from"motion/react";import{RadioGroup as Ok}from"@base-ui/react/radio-group";import{Radio as zk}from"@base-ui/react/radio";import{CheckboxGroup as Bk}from"@base-ui/react/checkbox-group";import{Checkbox as Hk}from"@base-ui/react/checkbox";import{Field as cu}from"@base-ui/react/field";import{useEffect as lu,useLayoutEffect as Tk,useRef as su,useState as Pk}from"react";import{AnimatePresence as Rk,motion as Mk}from"motion/react";import{jsx as qg}from"react/jsx-runtime";var Ik=typeof window<"u"?Tk:lu,Ts=se.moderate,Ma=.07,Ek=(Ts.duration+Ma)*1e3+80,Ak=Ts.duration*1e3+80;function au(e,t){let n=t.filter(s=>s.start>=e.start&&s.end<=e.end).sort((s,a)=>s.start-a.start);if(n.length!==2)return null;let[o,r]=n;return r.start===o.end+2?{up:o,lo:r,gap:o.end+1}:null}function Dk(e,t,n,o){let r=n[e],s=n[t];if(!r||!s)return null;if(o==="y")return{top:r.top,left:Math.min(r.left,s.left),width:Math.max(r.width,s.width),height:s.top+s.height-r.top};let a=Math.min(r.left,s.left),i=Math.max(r.left+r.width,s.left+s.width);return{top:Math.min(r.top,s.top),left:a,width:i-a,height:Math.max(r.height,s.height)}}function Wg(e,t){return t==="y"?e.top+e.height/2:e.left+e.width/2}function kl(e,t){return t==="y"?[e,e,0,0]:[e,0,0,e]}function cr(e,t){return t==="y"?[0,0,e,e]:[0,e,e,0]}function iu(e){return[e,e,e,e]}function jg(e,t,n,o,r){let s=Wg(n,o);if(o==="y"){let i=t.top+t.height;e.height=s-e.top,e.radii=kl(r,o),e.instant=!0,t.top=s,t.height=i-s,t.radii=cr(r,o),t.instant=!0,t.enterFrom={top:s,left:t.left,width:t.width,height:i-s,radii:cr(r,o)};return}let a=t.left+t.width;e.width=s-e.left,e.radii=kl(r,o),e.instant=!0,t.left=s,t.width=a-s,t.radii=cr(r,o),t.instant=!0,t.enterFrom={top:t.top,left:s,width:a-s,height:t.height,radii:cr(r,o)}}function Kg(e,t,n,o="y"){let[r,s]=Pk([]),a=su([]),i=su(0),d=su(new Map),l=e.map(c=>`${c.id}:${c.start}-${c.end}`).join("|");Ik(()=>{let c=a.current,m=e,p=[];for(let f of m){let b=au(f,c);b&&(f.id===b.up.id||f.id===b.lo.id)&&p.push({tid:++i.current,kind:"merge",survivorId:f.id,otherId:f.id===b.up.id?b.lo.id:b.up.id,gapIndex:b.gap,phase:"converge"})}for(let f of c){let b=au(f,m);b&&p.push({tid:++i.current,kind:"split",survivorId:b.up.id,otherId:b.lo.id,gapIndex:b.gap,phase:"splitIn"})}a.current=m.map(f=>({...f}));for(let f of p)d.current.set(f.tid,setTimeout(()=>{d.current.delete(f.tid),s(b=>b.some(g=>g.tid===f.tid)?b.flatMap(g=>g.tid!==f.tid?[g]:g.kind==="merge"?[{...g,phase:"commit"}]:[]):b)},f.kind==="merge"?Ek:Ak));let x=f=>f.kind==="merge"?m.some(b=>b.id===f.survivorId&&f.gapIndex>b.start&&f.gapIndex<b.end):m.some(b=>b.id===f.survivorId&&b.end===f.gapIndex-1)&&m.some(b=>b.id===f.otherId&&b.start===f.gapIndex+1);s(f=>{for(let b of f){if(x(b))continue;let g=d.current.get(b.tid);g!==void 0&&(clearTimeout(g),d.current.delete(b.tid))}return[...f.filter(x),...p]})},[l]),lu(()=>{let c=d.current;return()=>c.forEach(clearTimeout)},[]),lu(()=>{r.some(c=>c.phase==="splitIn"||c.phase==="commit")&&s(c=>c.flatMap(m=>m.phase==="commit"?[]:[{...m,phase:m.phase==="splitIn"?"diverge":m.phase}]))},[r]);let u=[];for(let c of e){let m=Dk(c.start,c.end,t,o);m&&u.push({key:`sel-${c.id}`,...m,radii:iu(n),instant:!1,exitInstant:!1,delayCorners:!1})}let h=new Map(u.map(c=>[c.key,c]));for(let c of r){let m=t[c.gapIndex],p=h.get(`sel-${c.survivorId}`);if(!m||!p)continue;let x=Wg(m,o);if(c.kind==="merge"){if(c.phase==="commit"){p.instant=!0,o==="y"?u.push({key:`sel-${c.otherId}`,top:x,left:p.left,width:p.width,height:p.top+p.height-x,radii:cr(n,o),instant:!0,exitInstant:!0,delayCorners:!1,opacity:0}):u.push({key:`sel-${c.otherId}`,top:p.top,left:x,width:p.left+p.width-x,height:p.height,radii:cr(n,o),instant:!0,exitInstant:!0,delayCorners:!1,opacity:0});continue}let f=Math.min(Ma+.03,Math.max(Ma,Ma+x/Math.max(o==="y"?m.height:m.width,1)*.002));if(o==="y"){let b=p.top+p.height;p.height=x-p.top,p.radii=kl(n,o),p.delayCorners=!0,p.cornerDelay=f,u.push({key:`sel-${c.otherId}`,top:x,left:p.left,width:p.width,height:b-x,radii:cr(n,o),enterFrom:{top:x,left:p.left,width:p.width,height:b-x,radii:iu(n)},instant:!1,exitInstant:!0,delayCorners:!0,cornerDelay:f})}else{let b=p.left+p.width;p.width=x-p.left,p.radii=kl(n,o),p.delayCorners=!0,p.cornerDelay=f,u.push({key:`sel-${c.otherId}`,top:p.top,left:x,width:b-x,height:p.height,radii:cr(n,o),enterFrom:{top:p.top,left:x,width:b-x,height:p.height,radii:iu(n)},instant:!1,exitInstant:!0,delayCorners:!0,cornerDelay:f})}}else if(c.phase==="splitIn"){let f=h.get(`sel-${c.otherId}`);if(!f)continue;jg(p,f,m,o,n)}}for(let c of a.current){let m=au(c,e),p=m&&t[m.gap];if(!m||!p)continue;let x=h.get(`sel-${m.up.id}`),f=h.get(`sel-${m.lo.id}`);!x||!f||jg(x,f,p,o,n)}return u}function Jg({blocks:e,dimmed:t}){return qg(Rk,{children:e.map(n=>{let o=n.delayCorners?{...Ts,delay:n.cornerDelay??Ma}:Ts,r=n.opacity??(t?.8:1);return qg(Mk.div,{"aria-hidden":!0,className:"absolute bg-active pointer-events-none",initial:n.enterFrom?{opacity:r,top:n.enterFrom.top,left:n.enterFrom.left,width:n.enterFrom.width,height:n.enterFrom.height,borderTopLeftRadius:n.enterFrom.radii[0],borderTopRightRadius:n.enterFrom.radii[1],borderBottomRightRadius:n.enterFrom.radii[2],borderBottomLeftRadius:n.enterFrom.radii[3]}:!1,animate:{top:n.top,left:n.left,width:n.width,height:n.height,borderTopLeftRadius:n.radii[0],borderTopRightRadius:n.radii[1],borderBottomRightRadius:n.radii[2],borderBottomLeftRadius:n.radii[3],opacity:r},exit:{opacity:0,transition:n.exitInstant?{duration:0}:Ts.exit},transition:n.instant?{duration:0}:{...Ts,borderTopLeftRadius:o,borderTopRightRadius:o,borderBottomRightRadius:o,borderBottomLeftRadius:o,opacity:{duration:.08}}},n.key)})})}import{Fragment as Yg,jsx as fe,jsxs as Vt}from"react/jsx-runtime";function Uk(e,t){return e.id??`q-${t}`}function Sl(e,t){return e.id??`o-${t}`}var Ps=[],du=Lk(function({questions:t,currentIndex:n,defaultCurrentIndex:o=0,onCurrentIndexChange:r,answers:s,defaultAnswers:a,onAnswersChange:i,onComplete:d,onSkip:l,skipLabel:u="Skip",intro:h,onCancel:c,cancelLabel:m="Cancel",footerLeading:p,className:x,...f},b){let[g,v]=Vr(o),y=n!==void 0,w=y?n:g,N=un(I=>{y||v(I),r?.(I)},[y,r]),[T,L]=Vr(a??{}),P=s!==void 0,R=P?s:T,D=Io(R);Gn(()=>{D.current=R},[R]);let k=un(I=>{let Z=I(D.current);return D.current=Z,P||L(Z),i?.(Z),Z},[P,i]),S=pt(),A=br("arrow-left"),_=br("arrow-right"),K=Ia(()=>function(Z){return fe(A,{...Z,className:C(Z.className,"hidden sm:block")})},[A]),$=Ia(()=>function(Z){return fe(_,{...Z,className:C(Z.className,"hidden sm:block")})},[_]),[oe]=Vr(()=>{if(typeof navigator>"u")return!1;let I=navigator,Z=I.userAgentData?.platform||I.platform||"";return/mac/i.test(Z)}),ae=_k(),ie=t.length,ne=Math.max(0,Math.min(w,Math.max(0,ie-1))),z=t[ne],O=z?Uk(z,ne):"",W=R[O],j=!!z?.multiSelect,U=z?.skippable!==!1,H=!!z?.freeText,Te=z?.freeTextMultiline!==!1,Pe=!H&&!!z?.allowOther,le=Ia(()=>W?.selectedIds??[],[W]),de=W?.otherText??"",De=z?.options??[],Re=Pe?De.length:-1,Oe=De.length+(Pe?1:0),Be=Io(null),tt=!!z;Gn(()=>{if(!tt)return;let I=Be.current;if(I)return Ps.push(I),()=>{let Z=Ps.indexOf(I);Z!==-1&&Ps.splice(Z,1)}},[tt]);let V=Io(null),ce=Io(null),Fe=Io(0),Y=Io(new Map),{activeIndex:q,setActiveIndex:M,itemRects:Ne,sessionRef:gt,handlers:qe,registerItem:ut,measureItems:Bt}=xr(V);Gn(()=>{Bt()},[Bt,O,Oe,S]);let[It,wn]=Vr(!1);Gn(()=>{wn(!1)},[O]),Gn(()=>{let I=ce.current;if(!I)return;I.style.height="0px",I.style.height=`${I.scrollHeight}px`;let Z=parseFloat(window.getComputedStyle(I).lineHeight)||18;wn(I.scrollHeight>Z*1.5),Bt()},[de,Bt,O]),Gn(()=>{H&&ce.current?.focus({preventScroll:!0})},[H,O]);let mn=Io(null),[mo,zn]=Vr("auto");Gn(()=>{let I=mn.current;if(!I)return;let Z=()=>zn(I.offsetHeight);Z();let Se=new ResizeObserver(Z);return Se.observe(I),()=>Se.disconnect()},[]);let[Nt,at]=Vr(null),[re,pe]=Vr(null);Gn(()=>{M(null),at(null),pe(null)},[ne,M]);let Ze=Io(!1),We=un(()=>{V.current?.contains(document.activeElement)&&(Ze.current=!0)},[]);Gn(()=>{if(!Ze.current)return;Ze.current=!1,V.current?.querySelector('[data-proximity-index="0"]')?.focus()},[ne]);let J=un(I=>{ne>=ie-1?d?.(I):(We(),N(ne+1))},[ne,ie,d,N,We]),$e=un(I=>{if(!z)return;let Z=D.current[O]?.otherText,Se=k(ct=>({...ct,[O]:{questionId:O,selectedIds:[I],otherText:Z||void 0,skipped:!1}}));J(Se)},[z,O,k,J]),Q=un(I=>{z&&k(Z=>{let Se=Z[O],ct=new Set(Se?.selectedIds??[]);return ct.has(I)?ct.delete(I):ct.add(I),{...Z,[O]:{questionId:O,selectedIds:Array.from(ct),otherText:Se?.otherText,skipped:!1}}})},[z,O,k]),ee=un(I=>{z&&k(Z=>({...Z,[O]:{questionId:O,selectedIds:I,otherText:Z[O]?.otherText,skipped:!1}}))},[z,O,k]),me=un(I=>{z&&(pe(null),k(Z=>({...Z,[O]:{questionId:O,selectedIds:Z[O]?.selectedIds??[],otherText:I,skipped:!1}})))},[z,O,k]),xe=un(()=>{if(!z)return;let I=(D.current[O]?.otherText??"").trim();if(!I)return;if(z.freeText&&z.freeTextValidate){let Se=z.freeTextValidate(I);if(Se){pe(Se);return}}pe(null);let Z=k(Se=>({...Se,[O]:{questionId:O,selectedIds:Se[O]?.selectedIds??[],otherText:I,skipped:!1}}));J(Z)},[z,O,k,J]),he=un(()=>{if(!z)return;let I=k(Z=>({...Z,[O]:{questionId:O,selectedIds:Z[O]?.selectedIds??[],otherText:Z[O]?.otherText,skipped:!0}}));l?.(O,ne),J(I)},[z,O,k,l,ne,J]),et=un(()=>{c?.()},[c]),ht=un(()=>{J(R)},[J,R]),Yt=un(()=>{ne>0&&(We(),N(ne-1))},[ne,N,We]);Gn(()=>{if(!z)return;let I=Z=>{if(Z.metaKey||Z.ctrlKey||Z.altKey)return;let Se=Z.target;if(!Se)return;let ct=Se.tagName;if(ct==="INPUT"||ct==="TEXTAREA"||Se.isContentEditable)return;let St=Be.current;if(!St||!St.contains(Se)&&(Ps.some(Hn=>Hn!==St&&Hn.contains(Se))||Ps[Ps.length-1]!==St))return;let dt=Z.key;if(dt<"1"||dt>"9")return;let bt=parseInt(dt,10)-1;if(bt>=0&&bt<De.length){Z.preventDefault();let Hn=Sl(De[bt],bt);j?Q(Hn):$e(Hn)}else bt===De.length&&Pe&&(Z.preventDefault(),ce.current?.focus())};return document.addEventListener("keydown",I),()=>document.removeEventListener("keydown",I)},[z,De,j,Pe,$e,Q]);let Dt=I=>{V.current?.querySelector(`[data-proximity-index="${I}"]`)?.focus()},vt=un(I=>{M(I),Pe&&I===Re?ce.current?.focus():Dt(I)},[Pe,Re,M]),Kr=I=>{let Z=I.target,Se=Z.tagName==="INPUT"||Z.tagName==="TEXTAREA"||Z.isContentEditable;if(Se&&I.key!=="ArrowDown"&&I.key!=="ArrowUp")return;if(Se&&(I.key==="ArrowUp"||I.key==="ArrowDown")&&Z.tagName==="TEXTAREA"){let St=Z;if(I.key==="ArrowUp"&&St.selectionStart>0||I.key==="ArrowDown"&&St.selectionEnd<St.value.length)return}let ct=I.preventBaseUIHandler;if(I.key==="ArrowLeft"||I.key==="ArrowRight"){I.preventDefault(),I.stopPropagation(),ct?.(),I.key==="ArrowLeft"?ne>0&&Yt():U&&ie>1&&he();return}if(Oe!==0&&(I.key==="ArrowDown"||I.key==="ArrowUp"||I.key==="Home"||I.key==="End")){I.preventDefault(),I.stopPropagation(),ct?.();let St;if(I.key==="Home")St=0;else if(I.key==="End")St=Oe-1;else{let dt=Se?Re:q??-1;St=I.key==="ArrowDown"?dt+1:dt-1,St=(St+Oe)%Oe}vt(St)}},po=I=>{if(I.key!=="Enter"||!(oe?I.metaKey:I.ctrlKey)||!(j||H))return;if(I.preventDefault(),H){de.trim().length>0&&xe();return}(le.length>0||de.trim().length>0)&&ht()};if(!z)return fe("div",{ref:b,className:C("w-full max-w-[520px] p-5 bg-card border border-border",S.container,x),...f,children:fe("p",{className:"text-[13px] text-muted-foreground",children:"No questions."})});let kt=q!==null?Ne[q]:null,He=Nt!==null&&!(Pe&&Nt===Re)?Ne[Nt]:null,fo=Ia(()=>{let I=new Set;return De.forEach((Z,Se)=>{le.includes(Sl(Z,Se))&&I.add(Se)}),Pe&&de.length>0&&I.add(Re),I},[De,le,Pe,de,Re]),Ul=Ia(()=>{let I=[],Z=[...fo].sort((dt,bt)=>dt-bt);for(let dt of Z){let bt=I[I.length-1];bt&&dt===bt.end+1?bt.end=dt:I.push({start:dt,end:dt})}let Se=new Set,ct=new Map,St=I.map(dt=>{let bt=null;for(let pn=dt.start;pn<=dt.end;pn++){let Zn=Y.current.get(pn);if(Zn!==void 0&&!Se.has(Zn)){bt=Zn;break}}let Hn=bt??++Fe.current;Se.add(Hn);for(let pn=dt.start;pn<=dt.end;pn++)ct.set(pn,Hn);return{...dt,id:Hn}});return Y.current=ct,St},[fo]),$a=q!==null&&!fo.has(q),Fl=Kg(Ul,Ne,S.bgRadius),Bn=ie>1&&ne>0,Xn=c!=null,Ye=!Xn&&ie>1&&U,nn=j||H,fr=Bn||Ye||nn||Xn||p!=null,Cn=De.findIndex((I,Z)=>le.includes(Sl(I,Z))),gr=Vt("div",{ref:V,role:j?"group":"radiogroup","aria-labelledby":`${ae}-${O}-title`,onMouseEnter:qe.onMouseEnter,onMouseMove:qe.onMouseMove,onMouseLeave:qe.onMouseLeave,onFocus:I=>{let Z=I.target.closest("[data-proximity-index]")?.getAttribute("data-proximity-index");if(Z!=null){let Se=Number(Z);M(Se),at(I.target.matches(":focus-visible")?Se:null)}},onBlur:I=>{V.current?.contains(I.relatedTarget)||(at(null),M(null))},onKeyDown:Kr,className:"relative flex flex-col gap-0.5 -mx-3",children:[fe(Rs,{children:(()=>{if(!Pe)return null;let I=Ne[Re],Z=Nt===Re&&de.length===0;return!I||!Z?null:fe(co.div,{"aria-hidden":!0,className:C("absolute pointer-events-none bg-card ring-1 ring-inset ring-border",S.bg),initial:{opacity:0,top:I.top,left:I.left,width:I.width,height:I.height},animate:{opacity:1,top:I.top,left:I.left,width:I.width,height:I.height},exit:{opacity:0,transition:se.fast.exit},transition:{...se.fast,opacity:{duration:.08}}},"other-input")})()}),fe(Rs,{children:kt&&fe(co.div,{"aria-hidden":!0,className:C("absolute pointer-events-none bg-hover",S.bg),initial:{opacity:0,top:kt.top,left:kt.left,width:kt.width,height:kt.height},animate:{opacity:1,top:kt.top,left:kt.left,width:kt.width,height:kt.height},exit:{opacity:0,transition:se.fast.exit},transition:{...se.fast,opacity:{duration:.08}}},`hover-${gt.current}`)}),fe(Jg,{blocks:Fl,dimmed:$a}),fe(Rs,{children:He&&fe(co.div,{"aria-hidden":!0,className:C("absolute pointer-events-none border border-[color:var(--focus-ring,#6B97FF)] z-20",S.focusRing),initial:{opacity:0,top:He.top-2,left:He.left-2,width:He.width+4,height:He.height+4},animate:{opacity:1,top:He.top-2,left:He.left-2,width:He.width+4,height:He.height+4},exit:{opacity:0,transition:se.fast.exit},transition:{...se.fast,opacity:{duration:.08}}})}),De.map((I,Z)=>{let Se=Sl(I,Z),ct=le.includes(Se),dt=!j&&q===Z;return fe(Gg,{index:Z,registerItem:ut,role:j?"checkbox":"radio",isSelected:ct,tabIndex:Z===Cn||Cn===-1&&Z===0?0:-1,onClick:()=>j?Q(Se):$e(Se),onKeyDown:bt=>{(bt.key===" "||bt.key==="Enter")&&!bt.metaKey&&!bt.ctrlKey&&(bt.preventDefault(),j?Q(Se):$e(Se))},shape:S,"aria-checked":ct,chipContent:Z+1,chipFilled:ct,isMulti:j,showArrow:dt,bodyLayout:z.layout==="stacked"?"stacked":"inline",topAlign:z.layout==="stacked",chipPosition:z.chipPosition??"right",arrowIcon:fe(_,{size:14,strokeWidth:2,className:"h-3.5 w-3.5"}),hiddenControl:j?fe(Hk.Root,{name:Se,className:"sr-only",tabIndex:-1,"aria-hidden":!0}):fe(zk.Root,{value:Se,className:"sr-only",tabIndex:-1,"aria-hidden":!0}),children:z.layout==="stacked"?Vt(Yg,{children:[Vt("span",{className:"inline-grid",children:[fe("span",{className:"col-start-1 row-start-1 invisible",style:{fontVariationSettings:yt.semibold},"aria-hidden":"true",children:I.title}),fe("span",{className:"col-start-1 row-start-1 text-foreground transition-[color,font-variation-settings] duration-80",style:{fontVariationSettings:ct?yt.semibold:yt.medium},children:I.title})]}),I.description&&fe("span",{className:"text-[12px] text-muted-foreground leading-snug",children:I.description})]}):Vt("span",{children:[Vt("span",{className:"inline-grid",children:[fe("span",{className:"col-start-1 row-start-1 invisible",style:{fontVariationSettings:yt.semibold},"aria-hidden":"true",children:I.title}),fe("span",{className:"col-start-1 row-start-1 text-foreground transition-[color,font-variation-settings] duration-80",style:{fontVariationSettings:ct?yt.semibold:yt.medium},children:I.title})]}),I.description&&Vt(Yg,{children:[" ",fe("span",{className:"text-muted-foreground",children:I.description})]})]})},Se)}),Pe&&fe(Gg,{index:Re,registerItem:ut,role:null,isSelected:de.length>0,tabIndex:-1,onClick:()=>ce.current?.focus(),shape:S,chipContent:Re+1,chipFilled:de.length>0,isMulti:j,topAlign:It,chipPosition:z.chipPosition??"right",ariaLabel:z.otherPlaceholder??"Describe in your own words",showArrow:!j&&(Nt===Re||q===Re)&&de.trim().length>0,arrowIcon:fe(_,{size:14,strokeWidth:2,className:"h-3.5 w-3.5"}),onArrowClick:!j&&de.trim().length>0?xe:void 0,children:fe("span",{className:"inline-grid w-full",children:fe("textarea",{ref:ce,rows:1,value:de,placeholder:z.otherPlaceholder??"Describe in your own words\u2026","aria-label":z.otherPlaceholder??"Describe in your own words",onChange:I=>me(I.target.value),onKeyDown:I=>{I.key==="Enter"&&(I.shiftKey||j||(I.preventDefault(),xe()))},onClick:I=>I.stopPropagation(),className:C("col-start-1 row-start-1 block w-full bg-transparent border-0 p-0 m-0 outline-none resize-none overflow-hidden text-[13px] leading-snug text-foreground placeholder:text-muted-foreground"),style:{fontVariationSettings:yt.medium}})})})]});return Vt("div",{ref:I=>{Be.current=I,typeof b=="function"?b(I):b&&(b.current=I)},className:C("relative w-full max-w-[520px] overflow-hidden bg-card border border-border",S.container,x),...f,onKeyDown:I=>{f.onKeyDown?.(I),po(I)},children:[fe("div",{className:"flex items-center px-4 sm:px-5 pt-4 sm:pt-5 pb-2 text-[12px] text-muted-foreground",children:Vt("span",{children:["Question ",ne+1," of ",ie]})}),h!=null&&fe("div",{className:"px-4 sm:px-5 pb-3 text-[13px] leading-snug text-muted-foreground",children:h}),Vt(cu.Root,{invalid:re!==null,className:"contents",children:[fe(co.div,{animate:{height:mo},initial:!1,transition:se.slow,className:"overflow-hidden",children:fe("div",{ref:mn,className:C("px-4 sm:px-5",fr?"pb-1":"pb-2.5 sm:pb-3"),children:Vt("div",{className:"flex flex-col gap-2",children:[fe("h3",{id:`${ae}-${O}-title`,className:"text-[16px] text-foreground leading-snug",style:{fontVariationSettings:yt.semibold},children:z.title}),H?fe("div",{onClick:()=>ce.current?.focus(),className:C("relative mt-1 -mx-3 px-3 py-2.5 cursor-text transition-colors",Te?"min-h-[76px]":"min-h-10",S.bg,de.length>0?"bg-active":"hover:bg-hover focus-within:bg-card focus-within:ring-1 focus-within:ring-inset focus-within:ring-border"),children:fe(cu.Control,{value:de,onValueChange:me,render:fe("textarea",{ref:ce,rows:1,placeholder:z.freeTextPlaceholder??"Type your answer\u2026","aria-labelledby":`${ae}-${O}-title`,onKeyDown:I=>{I.key==="Enter"&&(I.shiftKey||I.metaKey||I.ctrlKey||Te||(I.preventDefault(),xe()))},className:"block w-full bg-transparent border-0 p-0 m-0 outline-none resize-none overflow-hidden text-[13px] leading-snug text-foreground placeholder:text-muted-foreground",style:{fontVariationSettings:yt.medium}})})}):j?fe(Bk,{value:le,onValueChange:ee,render:gr}):fe(Ok,{value:le[0]??null,onValueChange:I=>{typeof I=="string"&&$e(I)},render:gr})]},O)})}),fr&&fe("div",{className:"px-4 sm:px-5 pt-1 pb-2",children:Vt("div",{className:"flex items-center justify-between gap-2 -mx-2 sm:-mx-3",children:[Vt("div",{className:"relative flex flex-1 min-w-0 items-center gap-2",children:[p!=null&&fe("div",{className:"shrink-0 px-2 sm:px-3",children:p}),fe(Rs,{mode:"popLayout",initial:!1,children:Bn&&fe(co.div,{layout:"position",initial:{opacity:0,scale:.85},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.85},transition:{...se.fast,opacity:{duration:.1}},children:fe(E,{variant:"ghost",size:"sm",leadingIcon:K,onClick:Yt,className:"pl-3 sm:pl-[6px]",children:"Back"})},"back")}),re&&fe(cu.Error,{match:!0,render:fe(co.p,{role:"alert",initial:{opacity:0,y:-2},animate:{opacity:1,y:0},transition:{...se.fast,opacity:{duration:.12}},className:"min-w-0 px-2 sm:px-3 text-left text-[12px] leading-snug text-destructive"}),children:re},"ft-error")]}),fe("div",{className:"relative flex items-center gap-2",children:Vt(Rs,{mode:"popLayout",initial:!1,children:[Xn&&fe(co.div,{layout:"position",initial:{opacity:0,scale:.85},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.85},transition:{...se.fast,opacity:{duration:.1}},children:fe(E,{variant:"ghost",size:"sm",trailingIcon:$,onClick:et,className:"pr-3 sm:pr-[6px]",children:m})},"cancel"),Ye&&fe(co.div,{layout:"position",initial:{opacity:0,scale:.85},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.85},transition:{...se.fast,opacity:{duration:.1}},children:fe(E,{variant:"ghost",size:"sm",trailingIcon:$,onClick:he,className:"pr-3 sm:pr-[6px]",children:u})},"skip"),nn&&fe(co.div,{layout:"position",initial:{opacity:0,scale:.85},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.85},transition:{...se.fast,opacity:{duration:.1}},children:fe(E,{variant:"primary",size:"sm",onClick:H?xe:ht,disabled:(H||le.length===0)&&de.trim().length===0,className:"pr-3 sm:pr-[6px]",children:Vt("span",{className:"inline-flex items-center gap-1.5",children:[z.nextLabel??(ne>=ie-1?"Finish":"Continue"),fe("span",{className:"hidden sm:contents",children:Vt(Fk,{shape:S,tone:"inverted",children:[oe?"\u2318":"\u2303","\u21B5"]})})]})})},"continue")]})})]})})]})]})});du.displayName="AskUserQuestions";function Fk({children:e,tone:t="muted",shape:n}){return fe("kbd",{"aria-hidden":!0,suppressHydrationWarning:!0,className:C("inline-flex items-center justify-center gap-0.5 px-1 min-w-[18px] h-[18px] text-[11px] leading-none font-sans tracking-wide",t==="inverted"?"bg-background/15 text-background":"bg-foreground/10 text-muted-foreground",n.bg),children:e})}function Gg({index:e,registerItem:t,role:n,isSelected:o,tabIndex:r,onClick:s,onKeyDown:a,shape:i,chipContent:d,chipFilled:l,isMulti:u,ariaLabel:h,showArrow:c,arrowIcon:m,onArrowClick:p,bodyLayout:x="inline",topAlign:f=!1,chipPosition:b="right",hiddenControl:g,children:v,...y}){let w=Io(null);Gn(()=>(t(e,w.current),()=>t(e,null)),[e,t]);let N=fe(Rs,{children:c&&fe(co.span,{"aria-hidden":!p,role:p?"button":void 0,onClick:p?P=>{P.stopPropagation(),p()}:void 0,className:C("absolute inset-0 inline-flex items-center justify-center bg-foreground text-background",i.bg,p&&"cursor-pointer"),initial:{opacity:0,scale:.6},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.6,transition:se.fast.exit},transition:{...se.fast,opacity:{duration:.08}},children:m})}),T=Vt("span",{className:C("shrink-0 w-7 h-7 relative inline-flex items-center justify-center",f&&(x==="stacked"?"-mt-[1px]":"-mt-[5px]")),children:[fe("span",{"aria-hidden":!0,className:C("absolute inline-flex items-center justify-center w-5 h-5 text-[11px] transition-[opacity,font-variation-settings] duration-80",u&&i.bg,u?l?"bg-foreground text-background":"border border-border text-muted-foreground":l?"text-foreground":"text-muted-foreground",b==="right"&&c&&"opacity-0"),style:{fontVariationSettings:l?yt.semibold:yt.medium},children:d}),b==="right"&&N]}),L=b==="left"&&!u&&fe("span",{className:C("shrink-0 w-7 h-7 relative inline-flex items-center justify-center",f&&(x==="stacked"?"-mt-[1px]":"-mt-[5px]")),children:N});return Vt("div",{ref:w,"data-proximity-index":e,"data-state":o?"checked":"unchecked",role:n??void 0,"aria-checked":n==="radio"||n==="checkbox"?!!y["aria-checked"]:void 0,"aria-label":h,tabIndex:r,onMouseDown:P=>{let R=P.target.closest('button:not([tabindex="-1"]), a[href], input, select, textarea, [tabindex]:not([tabindex="-1"])');R&&R!==P.currentTarget||(P.preventDefault(),P.currentTarget.focus())},onClick:s,onKeyDown:a,className:C("relative z-10 flex cursor-pointer select-none outline-none",b==="left"?"gap-2":"gap-3",f?"items-start":"items-center",x==="stacked"?"min-h-14 py-2":"min-h-10 py-1.5",b==="left"?u?"pl-1.5 pr-3":"pl-1.5 pr-1.5":"pl-3 pr-1.5",i.item),children:[b==="left"&&T,fe("span",{className:C("min-w-0 flex-1 text-[13px] leading-snug",x==="stacked"?"flex flex-col gap-0.5":"inline-flex items-center gap-0"),children:v}),b==="right"?T:L,g]})}function Tl(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.const=="string"&&(t.title===void 0||typeof t.title=="string")}function Qg(e){let t=Array.isArray(e.oneOf)?e.oneOf.filter(Tl):[],n=Array.isArray(e.anyOf)?e.anyOf.filter(Tl):[];return t.length>0?t:n}function Xg(e){let t=e.items&&typeof e.items=="object"?e.items:{},n=Array.isArray(t.anyOf)?t.anyOf.filter(Tl):[],o=Array.isArray(t.oneOf)?t.oneOf.filter(Tl):[];return n.length>0?n:o}function Zg(e){if(e.mode==="url"&&"url"in e)return[{id:"__url_confirm__",title:"Confirm completion",layout:"stacked",options:[{id:"confirmed",title:"I've completed the required action",description:e.url}],skippable:!1,nextLabel:"Confirm"}];let t="requestedSchema"in e?e.requestedSchema:void 0;if(!t||t.type!=="object"||!t.properties)return[{id:"__freeform__",title:"Your response",freeText:!0,freeTextPlaceholder:"Type your response\u2026",skippable:!1}];let n=t.properties,o=t.required??[];return Object.entries(n).map(([r,s])=>{let a=s,i=o.includes(r),d=a.title||r,l=a.description,u=a.type||"string",h=Qg(a),c=Xg(a),m=Array.isArray(a.enum),p=u==="array"&&Array.isArray(a.items?.enum),x=u==="array"&&c.length>0,f={id:r,title:d,skippable:!i,layout:l&&l.length>60?"stacked":"inline"};if(u==="boolean")return{...f,options:[{id:"true",title:"Yes"},{id:"false",title:"No"}]};if(x||p){let b=x?c:a.items.enum.map(g=>({const:g,title:g}))??[];return{...f,multiSelect:!0,options:b.map(g=>({id:g.const,title:g.title||g.const}))}}if(h.length>0)return{...f,layout:"stacked",options:h.map(b=>({id:b.const,title:b.title||b.const}))};if(m){let b=a.enum,g=a.enumNames;return{...f,options:b.map((v,y)=>({id:v,title:g?.[y]||v}))}}return u==="number"||u==="integer"?{...f,freeText:!0,freeTextMultiline:!1,freeTextPlaceholder:a.default!==void 0?String(a.default):"Enter a number\u2026",freeTextValidate:b=>{let g=b.trim();if(!g)return i?"Required":null;let v=u==="integer"?parseInt(g,10):parseFloat(g);return Number.isNaN(v)?"Enter a valid number":null}}:u==="string"&&(a.format==="textarea"||(a.maxLength??0)>100)?{...f,freeText:!0,freeTextPlaceholder:a.default||"Type your answer\u2026"}:{...f,freeText:!0,freeTextMultiline:!1,freeTextPlaceholder:a.default!==void 0?String(a.default):"Type your answer\u2026",freeTextValidate:b=>!b.trim()&&i?"Required":null}})}function eh(e,t,n){if(n.mode==="url")return{};let o="requestedSchema"in n?n.requestedSchema:void 0,r=o?.type==="object"&&o.properties?o.properties:{},s={};for(let a of e){let i=a.id??"";if(i==="__freeform__"){let h=t[i]?.otherText?.trim();h&&(s.response=h);continue}let d=t[i];if(!d||d.skipped)continue;let u=r[i]?.type||"string";if(a.freeText){let h=d.otherText?.trim()??"";if(!h)continue;s[i]=u==="number"||u==="integer"?u==="integer"?parseInt(h,10):parseFloat(h):h;continue}if(a.multiSelect){s[i]=d.selectedIds;continue}if(u==="boolean"){s[i]=d.selectedIds[0]==="true";continue}d.selectedIds[0]!==void 0&&(s[i]=d.selectedIds[0])}return s}function th(e,t,n){if(n.mode==="url")return[];let o="requestedSchema"in n?n.requestedSchema:void 0;return(o?.type==="object"?o.required??[]:[]).filter(s=>{let a=t[s];if(!a||a.skipped)return!0;let i=e.find(d=>d.id===s);return i?i.freeText?!a.otherText?.trim():(i.multiSelect,a.selectedIds.length===0):!0})}function nh(e,t){if(t.mode==="url")return{};let n="requestedSchema"in t?t.requestedSchema:void 0,o=n?.type==="object"&&n.properties?n.properties:{},r={};for(let s of e){let a=s.id;if(!a||a.startsWith("__"))continue;let i=o[a];if(!(!i||i.default===void 0)){if(s.freeText){r[a]={questionId:a,selectedIds:[],otherText:String(i.default),skipped:!1};continue}if(s.multiSelect&&Array.isArray(i.default)){r[a]={questionId:a,selectedIds:i.default.map(String),skipped:!1};continue}if(i.type==="boolean"){r[a]={questionId:a,selectedIds:[String(i.default)],skipped:!1};continue}r[a]={questionId:a,selectedIds:[String(i.default)],skipped:!1}}}return r}import{jsx as Ea,jsxs as Pl}from"react/jsx-runtime";function ah({request:e,onApprove:t,onReject:n,testId:o="inline-elicitation",actionTestIdPrefix:r="inline-elicitation"}){let[s,a]=rh(!1),[i,d]=rh(""),l=oh(()=>Zg(e.request),[e.request]),u=oh(()=>nh(l,e.request),[l,e.request]),c=(e.request.mode||"form")==="url",m=c&&"url"in e.request?e.request.url:void 0,p=(b,g)=>{a(!0),d(b),t(e.id,g)},x=b=>{if(s)return;if(c){if(!b.__url_confirm__?.selectedIds.includes("confirmed")){sh.error("Confirm you've completed the external action");return}p("accepted",{action:"accept"});return}let g=th(l,b,e.request);if(g.length>0){sh.error("Missing required fields",{description:`Please fill in: ${g.join(", ")}`});return}p("accepted",{action:"accept",content:eh(l,b,e.request)})};if(s)return Pl("p",{className:"text-sm text-muted-foreground","data-testid":`${o}-responded`,children:["Elicitation ",i," \u2014 the tool will continue executing."]});let f=Pl("div",{className:"space-y-2",children:[Ea("p",{className:"text-foreground/90",children:e.request.message}),c&&m&&Pl("div",{className:"flex items-center gap-2 rounded-md border bg-muted/40 p-2",children:[Ea("code",{className:"flex-1 text-xs font-mono break-all",children:m}),Pl(E,{size:"sm",variant:"outline",onClick:()=>window.open(m,"_blank"),"data-testid":`${r}-open-url`,children:[Ea($k,{className:"h-3 w-3 mr-1"}),"Open"]})]})]});return Ea(du,{questions:l,defaultAnswers:u,onComplete:x,intro:f,onCancel:()=>n(e.id,"User cancelled elicitation request"),cancelLabel:"Cancel",footerLeading:Ea("button",{type:"button",className:"shrink-0 cursor-pointer text-[12px] text-muted-foreground underline-offset-2 hover:text-foreground hover:underline",onClick:()=>p("declined",{action:"decline"}),"data-testid":`${r}-decline-button`,children:"Decline"}),className:"w-full max-w-none shadow-lg","data-testid":o})}import{jsx as uu}from"react/jsx-runtime";function ih({requests:e,onApprove:t,onReject:n}){return e.length===0?null:uu("div",{className:"mb-3 space-y-3 pointer-events-auto","data-testid":"floating-elicitation-stack",children:e.map(o=>uu(Vk.div,{initial:{opacity:0,y:12,scale:.98},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:8,scale:.98},transition:se.moderate,children:uu(ah,{request:o,onApprove:t,onReject:n})},o.id))})}import{Check as jk,Loader2 as qk,Settings2 as Wk}from"lucide-react";import{useCallback as Kk,useEffect as Jk,useState as mu}from"react";var jr="You are a helpful assistant with access to MCP tools. Help users interact with the MCP server.";import{jsx as Yn,jsxs as Aa}from"react/jsx-runtime";function Gk(e){let t=e?.trim();return t?t!==jr:!1}function lh({value:e,onSave:t,disabled:n,isSaving:o=!1,compact:r=!1}){let[s,a]=mu(!1),[i,d]=mu(e??""),[l,u]=mu(!1);Jk(()=>{d(e??"")},[e]);let h=Kk(async()=>{u(!0);try{await t(i),a(!1)}finally{u(!1)}},[i,t]),c=o||l,m=Gk(e),p=Aa("button",{type:"button","data-testid":"chat-system-prompt-button",onClick:()=>a(!0),disabled:n,className:r?C("inline-flex h-auto w-auto aspect-square items-center justify-center rounded-full p-2 transition-colors disabled:pointer-events-none disabled:opacity-50",m?"text-amber-500 dark:text-amber-400":"text-muted-foreground hover:text-foreground"):C("inline-flex h-9 items-center justify-center gap-1.5 rounded-full border border-input bg-secondary px-3 text-sm font-medium shadow-xs transition-colors hover:bg-secondary/80 disabled:pointer-events-none disabled:opacity-50",m?"text-amber-600 dark:text-amber-400":"text-secondary-foreground"),children:[Yn(Wk,{className:"h-4 w-4"}),!r&&Yn("span",{className:"hidden sm:inline",children:"System Prompt"})]});return Aa(fn,{open:s,onOpenChange:a,children:[r?Aa(ke,{children:[Yn(we,{render:p,nativeButton:!0}),Yn(Ce,{side:"top",children:Yn("p",{children:m?"Custom system prompt":"System Prompt"})})]}):p,Aa(on,{className:"sm:max-w-xl",children:[Yn(Qt,{children:Yn(qt,{children:"System Prompt"})}),Yn(no,{value:i,onChange:x=>d(x.target.value),placeholder:"Describe the assistant's behavior...",className:"min-h-[160px] text-sm"}),Yn(li,{children:Aa(E,{size:"sm",onClick:h,disabled:c||i===(e??""),className:"gap-1.5",children:[c?Yn(qk,{className:"h-3.5 w-3.5 animate-spin"}):Yn(jk,{className:"h-3.5 w-3.5"}),"Save"]})})]})]})}import{Fragment as Xk,jsx as tn,jsxs as pu}from"react/jsx-runtime";function Da({inputValue:e,isConnected:t,isLoading:n,textareaRef:o,llmConfig:r,promptsDropdownOpen:s,promptFocusedIndex:a,prompts:i,selectedPrompt:d,promptResults:l,attachments:u,tools:h,disabledTools:c,onDisabledToolsChange:m,onInputChange:p,onKeyDown:x,onKeyUp:f,onClick:b,onSendMessage:g,onStopStreaming:v,onConfigDialogOpenChange:y,onPromptSelect:w,onDeletePromptResult:N,onAttachmentAdd:T,onAttachmentRemove:L,hideModelBadge:P,freeTierInfo:R,managedCloudInfo:D,modelBadgeMode:k="byok",modelDisplayName:S,followups:A=[],onFollowupSelect:_,pendingElicitationRequests:K,onApproveElicitation:$,onRejectElicitation:oe,systemPromptProvider:ae}){let ie=e.trim()||l.length>0||u.length>0,ne=(K?.length??0)>0,z=r&&(!P||R||D)?pu(ke,{children:[tn(we,{render:tn(bg,{provider:r.provider,model:r.model,displayName:S,mode:k,className:"shrink-0",onClick:()=>y(!0)}),nativeButton:!0}),tn(Ce,{children:tn("p",{children:D||R?"Change model":"Change API Key"})})]}):null;return tn("div",{className:"w-full flex shrink-0 flex-col items-center px-2 pb-2 pt-0 sm:px-4 sm:pb-2 text-foreground",children:pu("div",{className:"relative w-full max-w-3xl backdrop-blur-xl",children:[ne&&$&&oe&&tn(ih,{requests:K,onApprove:$,onReject:oe}),A.length>0&&tn("div",{className:"mb-2 flex flex-wrap gap-2",children:A.map(O=>tn(E,{type:"button",variant:"outline",size:"sm",className:"rounded-full",onClick:()=>_?.(O),disabled:n||!t,children:O},O))}),tn(Vg,{isOpen:s,prompts:i,selectedPrompt:d,focusedIndex:a,onPromptSelect:w}),tn($g,{promptResults:l,onDeletePromptResult:N}),tn(Fg,{inputValue:e,isConnected:t,isLoading:n,textareaRef:o,attachments:u,placeholder:"Ask a question or request an action...",className:C("bg-white/80 dark:text-white dark:bg-black backdrop-blur-sm border-gray-200 dark:border-zinc-800",l.length>0&&"pt-16"),tools:h,disabledTools:c,onDisabledToolsChange:m,onInputChange:p,onKeyDown:x,onKeyUp:f,onClick:b,onAttachmentAdd:T,onAttachmentRemove:L,inlineControls:r&&ae?tn(lh,{compact:!0,value:ae.prompt,onSave:ae.savePrompt,disabled:!t||n||ae.disabled,isSaving:ae.isSaving}):null,trailingControls:pu(Xk,{children:[z,tn(E,{type:"button",size:"sm",className:C("h-8 w-8 rounded-full p-0",n&&"animate-spin",!ie&&!n&&"bg-zinc-400"),disabled:!n&&(!ie||!t||ne),title:n?"Stop streaming":"Send",onClick:n?v:g,"data-testid":"chat-send-button",children:n?tn(Qk,{className:"h-3.5 w-3.5 animate-spin"}):tn(Yk,{className:"h-3.5 w-3.5"})})]})})]})})}import{AnimatePresence as Zk,motion as eS,useInView as tS}from"motion/react";import{useRef as nS}from"react";import{jsx as ch}from"react/jsx-runtime";function dh({children:e,className:t,variant:n,duration:o=.4,delay:r=0,offset:s=6,direction:a="down",inView:i=!1,inViewMargin:d="-50px",blur:l="6px",...u}){let h=nS(null),c=tS(h,{once:!0,margin:d}),m=!i||c,p={hidden:{[a==="left"||a==="right"?"x":"y"]:a==="right"||a==="down"?-s:s,opacity:0,filter:`blur(${l})`},visible:{[a==="left"||a==="right"?"x":"y"]:0,opacity:1,filter:"blur(0px)"}},x=n||p;return ch(Zk,{children:ch(eS.div,{ref:h,initial:"hidden",animate:m?"visible":"hidden",exit:"hidden",variants:x,transition:{delay:.04+r,duration:o,ease:"easeOut"},className:t,...u,children:e})})}import{jsx as La,jsxs as Rl}from"react/jsx-runtime";function fu({serverDisplayName:e,composerNotice:t,quickQuestions:n=[],onQuickQuestionSelect:o,...r}){return La("div",{className:"flex h-full flex-col items-center justify-center",children:Rl(dh,{className:"w-full max-w-4xl mx-auto px-2 sm:px-4",children:[Rl("div",{className:"text-center mb-6 sm:mb-8",children:[Rl("h1",{className:"text-2xl sm:text-4xl font-light mb-2 dark:text-white","data-testid":"chat-landing-header",children:["Chat with ",e]}),La("p",{className:"mx-auto max-w-xl text-sm text-muted-foreground sm:text-base","data-testid":"chat-landing-description",children:"Chat, inspect traces, preview widgets, and more."})]}),Rl("div",{className:"space-y-6",children:[t,La(Da,{...r}),n.length>0&&La("div",{className:"flex flex-wrap items-center justify-center gap-2 px-2",children:n.map(s=>La(E,{type:"button",variant:"outline",size:"sm",className:"rounded-full bg-white/70 dark:bg-black/50 text-gray-900 dark:text-white",onClick:()=>o?.(s),disabled:r.isLoading||!r.isConnected,children:s},s))})]})]})})}import{Key as oS,Settings as rS}from"lucide-react";import{jsx as Ml,jsxs as uh}from"react/jsx-runtime";function gu({onConfigureClick:e}){return uh("div",{className:"flex flex-col items-center justify-center h-full text-center",children:[Ml(oS,{className:"h-12 w-12 text-muted-foreground mb-4"}),Ml("h3",{className:"text-lg font-semibold mb-2",children:"Configure Your LLM Provider"}),Ml("p",{className:"text-sm text-muted-foreground mb-4 max-w-md",children:"To start chatting with the MCP server, you need to configure your LLM provider and API key. Your credentials are stored locally and used only for this chat."}),uh(E,{onClick:e,"data-testid":"chat-configure-api-key-button",children:[Ml(rS,{className:"h-4 w-4 mr-2"}),"Configure API Key"]})]})}import{motion as sS}from"motion/react";import{useMemo as aS}from"react";import{jsx as iS}from"react/jsx-runtime";function mh({children:e,as:t="p",className:n,duration:o=2,spread:r=2}){let s=sS.create(t),a=aS(()=>e.length*r,[e,r]);return iS(s,{className:C("relative inline-block bg-[length:250%_100%,auto] bg-clip-text","text-transparent [--base-color:#a1a1aa] [--base-gradient-color:#000]","[--bg:linear-gradient(90deg,#0000_calc(50%-var(--spread)),var(--base-gradient-color),#0000_calc(50%+var(--spread)))] [background-repeat:no-repeat,padding-box]","dark:[--base-color:#71717a] dark:[--base-gradient-color:#ffffff] dark:[--bg:linear-gradient(90deg,#0000_calc(50%-var(--spread)),var(--base-gradient-color),#0000_calc(50%+var(--spread)))]",n),initial:{backgroundPosition:"100% center"},animate:{backgroundPosition:"0% center"},transition:{repeat:1/0,duration:o,ease:"linear"},style:{"--spread":`${a}px`,backgroundImage:"var(--bg), linear-gradient(var(--base-color), var(--base-color))"},children:e})}import{memo as IS,useCallback as ES,useMemo as AS}from"react";import{memo as lS,useMemo as cS}from"react";import{jsx as ph,jsxs as uS}from"react/jsx-runtime";function dS(e){let t=e.match(/```/g);return t&&t.length%2===1?`${e}
|
|
198
|
-
\`\`\``:e}var fh=lS(function({content:t,isStreaming:n=!1}){let o=cS(()=>n?dS(t):t,[t,n]);return uS("div",{children:[ph(bs,{className:C("text-[14px] leading-relaxed text-foreground","[&_p]:mb-2 [&_p:last-child]:mb-0","[&_pre]:my-3 [&_ul]:mb-2 [&_ol]:mb-2"),content:o}),n?ph("span",{className:"inline-block w-0.5 h-[1em] ml-0.5 -mt-1 align-middle bg-foreground/60 animate-pulse","aria-hidden":!0}):null]})});import{forwardRef as bS}from"react";import{motion as yS}from"motion/react";import{useEffect as mS,useState as pS}from"react";function gh(){let[e,t]=pS(!1);return mS(()=>{if(typeof window>"u")return;let n=new AbortController,{signal:o}=n,r=()=>{let a="ontouchstart"in window||navigator.maxTouchPoints>0,i=window.matchMedia("(pointer: coarse)").matches;t(a&&i)};return window.matchMedia("(pointer: coarse)").addEventListener("change",r,{signal:o}),window.addEventListener("pointerdown",r,{signal:o}),r(),()=>n.abort()},[]),e}import{useEffect as fS,useState as gS}from"react";import{jsx as dr,jsxs as vS}from"react/jsx-runtime";function hS({size:e}){return vS("svg",{width:Math.max(16,e*.35),height:Math.max(16,e*.35),viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[dr("path",{d:"M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z"}),dr("path",{d:"M14 3v5h5"})]})}function hh({file:e,size:t,className:n}){let o=pt(),r=e.type.startsWith("image/"),[s,a]=gS(null);fS(()=>{if(!r){a(null);return}let d=URL.createObjectURL(e);return a(d),()=>URL.revokeObjectURL(d)},[r,e]);let i=r&&!s;return dr("div",{className:C("relative shrink-0 overflow-hidden bg-accent border border-border",o.bg,n),style:{width:t,height:t},children:s?dr("img",{src:s,alt:e.name,className:"absolute inset-0 w-full h-full object-cover"}):i?dr("div",{className:"absolute inset-0 flex items-center justify-center",children:dr("div",{className:"w-6 h-6 rounded-full border-2 border-border border-t-muted-foreground animate-spin","aria-label":"Loading preview",role:"status"})}):dr("div",{className:"absolute inset-0 flex items-center justify-center text-muted-foreground",role:"img","aria-label":e.name,children:dr(hS,{size:t})})})}import{jsx as _a,jsxs as vh}from"react/jsx-runtime";var Oa=bS(({from:e,files:t,thumbnailSize:n=64,time:o,actions:r,children:s,className:a,...i},d)=>{let l=pt(),u=e==="user",h=gh(),c=u&&o!=null;return vh(yS.div,{ref:d,layout:"position",initial:{opacity:0,y:8,scale:.96},animate:{opacity:1,y:0,scale:1},transition:se.moderate,style:{transformOrigin:u?"bottom right":"bottom left"},className:C("group flex max-w-[80%] flex-col gap-1.5",u?"items-end self-end":"items-start self-start",a),...i,children:[t&&t.length>0&&_a("div",{className:C("flex flex-wrap gap-1.5",u?"justify-end":"justify-start"),children:t.map((m,p)=>_a(hh,{file:m,size:n},`${m.name}-${m.size}-${m.lastModified}-${p}`))}),s!=null&&s!==""&&_a("div",{className:C("py-2 text-[14px] whitespace-pre-wrap break-words",u?C(l.bg,"px-3.5 text-pretty bg-[color-mix(in_oklab,var(--accent),var(--background)_45%)] text-accent-foreground"):"text-foreground"),children:s}),(c||r!=null)&&vh("div",{className:C("flex items-center gap-2 px-1 text-[12px] leading-none text-muted-foreground select-none",!h&&["opacity-0 pointer-events-none transition-opacity duration-150","group-hover:opacity-100 group-hover:pointer-events-auto","group-focus-within:opacity-100 group-focus-within:pointer-events-auto"]),children:[c&&_a("span",{className:"tabular-nums",children:o}),r!=null&&_a("span",{className:"flex items-center gap-0.5",children:r})]})]})});Oa.displayName="ChatMessage";import{Check as xS,Copy as wS}from"lucide-react";import{useState as CS}from"react";import{jsx as hu}from"react/jsx-runtime";function bh({text:e}){let[t,n]=CS(!1);return hu("button",{type:"button",className:"text-muted-foreground hover:text-foreground flex items-center rounded p-0.5",onClick:async()=>{await Xe(e),n(!0),setTimeout(()=>n(!1),2e3)},title:"Copy message content","data-testid":"copy-button",children:t?hu(xS,{className:"h-3.5 w-3.5"}):hu(wS,{className:"h-3.5 w-3.5"})})}import{Fragment as wh,jsx as xh,jsxs as Ch}from"react/jsx-runtime";function yh(e,t){let n=e===1?"token":"tokens";return`${e.toLocaleString()} ${n} ${t}`}function Il({variant:e,copyText:t,inputTokens:n,outputTokens:o}){let r=!!t,s=e==="user"&&n!=null?yh(n,"in"):e==="assistant"&&o!=null?yh(o,"out"):null;if(!r&&!s)return null;let a=r?xh(bh,{text:t}):null,i=s?xh("span",{className:"tabular-nums",title:e==="user"?"Input tokens":"Output tokens","data-testid":e==="user"?"message-input-tokens":"message-output-tokens",children:s}):null;return e==="user"?Ch(wh,{children:[i,a]}):Ch(wh,{children:[a,i]})}import{jsx as El,jsxs as NS}from"react/jsx-runtime";function vu({content:e,timestamp:t,_isStreaming:n,outputTokens:o}){return!e||e.length===0?null:NS("div",{"data-testid":"chat-message-assistant",children:[El(Oa,{from:"assistant",actions:El(Il,{variant:"assistant",copyText:e,outputTokens:o}),"data-testid":"chat-message-content",children:El(fh,{content:e,isStreaming:n})}),t!=null&&El("span",{className:"sr-only",children:new Date(t).toLocaleTimeString()})]})}import{Check as Nh,Copy as bu,Loader2 as kh,Wrench as Sh,X as kS}from"lucide-react";import{jsx as st,jsxs as Gt}from"react/jsx-runtime";function yu({toolName:e,args:t,result:n,state:o="result",partialArgs:r}){let s=o==="call"&&r?r:t,a=()=>{switch(o){case"call":return st(kh,{className:"h-4 w-4 animate-spin text-blue-500 dark:text-blue-400"});case"result":return st(Nh,{className:"h-4 w-4 text-emerald-800 dark:text-emerald-400"});case"error":return st(kS,{className:"h-4 w-4 text-red-500 dark:text-red-400"});default:return st(Nh,{className:"h-4 w-4 text-emerald-800 dark:text-emerald-400"})}},i=()=>{switch(o){case"call":return" bg-blue-500/20 dark:bg-blue-500/20";case"result":return" bg-emerald-500/20 dark:bg-emerald-500/20";case"error":return" bg-red-500/20 dark:bg-red-500/20";default:return" bg-emerald-500/20 dark:bg-emerald-500/20"}},d=l=>typeof l=="object"?_i(l).preview:String(l);return Gt(is,{children:[st(Mi,{render:Gt("div",{className:"flex max-w-min items-center gap-3 p-1 rounded-full border bg-card hover:bg-accent/50 transition-colors cursor-pointer my-4","data-testid":`chat-tool-call-${e}`,children:[st("div",{className:"w-8 h-8 rounded-full bg-zinc-100 dark:bg-zinc-900 border border-zinc-200 dark:border-zinc-800 flex items-center justify-center shrink-0",children:st(Sh,{className:"size-4 text-muted-foreground"})}),st("div",{className:"flex-1 min-w-0",children:st("div",{className:"flex items-center gap-2",children:Gt("span",{className:"text-sm font-medium truncate",children:[e,"(",Object.keys(s).length>0?Gt("span",{className:"bg-muted-foreground/20 rounded-full px-1.5 mx-1 py-0.5 text-xs",children:[Object.keys(s).length," args"]}):"",")"]})})}),st("div",{className:C("w-8 h-8 rounded-full flex items-center justify-center",i()),"data-testid":`chat-tool-call-status-${o}`,children:a()})]}),nativeButton:!1}),Gt(ls,{side:"right",className:"w-[400px] sm:w-[540px] p-4 overflow-y-auto","data-testid":"chat-tool-drawer",children:[Gt(Ii,{children:[Gt(Ei,{className:"flex items-center gap-2",children:[st(Sh,{className:"h-5 w-5"}),"Tool Call Details"]}),Gt(Np,{className:"flex items-center gap-2",children:[e," \u2014 ",o,o==="call"&&Gt("span",{className:"flex items-center gap-1 text-blue-500 dark:text-blue-400",children:[st(kh,{className:"h-3 w-3 animate-spin"}),"streaming\u2026"]})]})]}),Gt("div",{className:"flex flex-col gap-6 py-4",children:[Gt("div",{children:[st("h3",{className:"text-sm font-medium mb-2",children:"Arguments"}),Gt("div",{className:"relative","data-testid":"chat-tool-drawer-args",children:[st("pre",{className:"text-xs bg-muted/50 rounded-lg p-3 overflow-x-auto border font-mono leading-relaxed max-h-48 whitespace-pre-wrap break-words",children:d(s)}),st(E,{variant:"ghost",size:"sm",onClick:()=>Xe(d(s)),className:"absolute top-2 right-2 h-6 w-6 p-0 opacity-70 hover:opacity-100",title:"Copy arguments",children:st(bu,{className:"h-3 w-3"})})]})]}),n&&Gt("div",{children:[st("h3",{className:"text-sm font-medium mb-2",children:"Result"}),st("div",{className:"relative","data-testid":"chat-tool-drawer-result",children:typeof n=="string"?Gt("div",{className:C("p-3 rounded-lg border text-sm leading-relaxed max-h-48 overflow-x-auto whitespace-pre-wrap break-words max-w-full",o==="error"?"bg-destructive/10 border-destructive/20 text-destructive-foreground":"bg-muted/30 border-border"),children:[n.startsWith("Error")?Gt("div",{className:"font-mono",children:[st("div",{className:"font-semibold text-destructive mb-1",children:"Error:"}),st("div",{className:"whitespace-pre-wrap break-words",children:n.replace(/^Error:\s*/,"")})]}):st("div",{className:"whitespace-pre-wrap font-mono break-words",children:n}),st(E,{variant:"ghost",size:"sm",onClick:()=>Xe(n),className:"absolute top-2 right-2 h-6 w-6 p-0 opacity-70 hover:opacity-100",title:"Copy result",children:st(bu,{className:"h-3 w-3"})})]}):Gt("div",{className:C("p-3 rounded-lg border text-sm leading-relaxed max-h-96 overflow-y-auto max-w-full",o==="error"?"bg-destructive/10 border-destructive/20 text-destructive-foreground":"bg-muted/30 border-border"),children:[st(wt,{data:n,filename:`tool-call-${e}-result-${Date.now()}.json`}),st(E,{variant:"ghost",size:"sm",onClick:()=>Xe(JSON.stringify(n,null,2)),className:"absolute top-2 right-2 h-6 w-6 p-0 opacity-70 hover:opacity-100",title:"Copy result",children:st(bu,{className:"h-3 w-3"})})]})})]})]})]})]})}import{useMemo as SS}from"react";import{jsx as xu}from"react/jsx-runtime";function TS(e){let t=atob(e.data),n=new Uint8Array(t.length);for(let o=0;o<t.length;o++)n[o]=t.charCodeAt(o);return new File([n],e.name||"attachment",{type:e.mimeType})}function Th({content:e,timestamp:t,attachments:n,inputTokens:o}){let r=SS(()=>n?.map(TS),[n]);return(!e||e.length===0)&&(!n||n.length===0)?null:xu("div",{"data-testid":"chat-message-user",className:"flex flex-col items-end",children:xu(Oa,{from:"user",files:r,time:t?new Date(t).toLocaleTimeString():void 0,actions:e||o!=null?xu(Il,{variant:"user",copyText:e||void 0,inputTokens:o}):void 0,"data-testid":"chat-message-content",children:e&&e.length>0?e:void 0})})}import{isViewTool as DS}from"@mcp-use/client/react";var ur={events:[],spans:[]};function Dl(e){if(!e||typeof e!="object")return;let t=e,n=(...a)=>{for(let i of a)if(typeof t[i]=="number")return t[i]},o=n("inputTokens","input_tokens","promptTokens"),r=n("outputTokens","output_tokens","completionTokens"),s=n("totalTokens","total_tokens")??(o!==void 0&&r!==void 0?o+r:void 0);if(!(o===void 0&&r===void 0&&s===void 0))return{inputTokens:o,outputTokens:r,totalTokens:s}}var PS=new Set(["apikey","authorization","accesstoken","refreshtoken","password","cookie","secret"]);function Al(e){return Array.isArray(e)?e.map(Al):!e||typeof e!="object"?e:Object.fromEntries(Object.entries(e).map(([t,n])=>[t,PS.has(t.toLowerCase().replace(/[_-]/g,""))?"[REDACTED]":Al(n)]))}function Ph(e,t=120){let n;try{n=JSON.stringify(e)}catch{n=String(e)}return n.length>t?`${n.slice(0,t)}\u2026`:n}function qr(e){switch(e.type){case"request":return"LLM request";case"text-delta":return e.delta.trim()||"Text delta";case"tool-call-start":return e.toolName;case"tool-call-args":return Ph(e.args);case"tool-result":return Ph(e.result);case"usage":return`${e.usage.totalTokens??"?"} tokens`;case"error":return e.message;case"done":return"Completed";default:return e}}function wu(e,t){let n=(o,r)=>o===void 0&&r===void 0?void 0:(o??0)+(r??0);return{inputTokens:n(e?.inputTokens,t.inputTokens),outputTokens:n(e?.outputTokens,t.outputTokens),totalTokens:n(e?.totalTokens,t.totalTokens),cachedInputTokens:n(e?.cachedInputTokens,t.cachedInputTokens),reasoningTokens:n(e?.reasoningTokens,t.reasoningTokens)}}function Ll(e,t){let n=e.spans.map(s=>({...s})),o=e.usage,r=[...n].reverse().find(s=>s.kind==="llm"&&s.status==="running");if(t.type==="request")n.push({id:`llm-${t.id}`,kind:"llm",name:"LLM",status:"running",startedAt:t.timestamp,preview:qr(t)});else if((t.type==="text-delta"||t.type==="tool-call-start")&&!r)r={id:`llm-${t.id}`,kind:"llm",name:"LLM",status:"running",startedAt:t.timestamp,preview:t.type==="text-delta"?qr(t):"LLM response"},n.push(r),t.type==="tool-call-start"&&n.push({id:t.toolCallId,kind:"tool",name:t.toolName,status:"running",startedAt:t.timestamp,preview:qr(t)});else if(t.type==="tool-call-start")n.push({id:t.toolCallId,kind:"tool",name:t.toolName,status:"running",startedAt:t.timestamp,preview:qr(t)});else if(t.type==="tool-call-args"){let s=n.find(a=>a.id===t.toolCallId);s&&(s.preview=qr(t))}else if(t.type==="tool-result"){let s=t.toolCallId?n.find(a=>a.id===t.toolCallId):[...n].reverse().find(a=>a.kind==="tool"&&a.name===t.toolName&&a.status==="running");s&&(s.status=t.isError?"error":"success",s.endedAt=t.timestamp,s.preview=qr(t))}else t.type==="usage"?(o=wu(o,t.usage),r&&(r.usage=wu(r.usage,t.usage))):(t.type==="error"||t.type==="done")&&r&&(r.status=t.type==="error"?"error":"success",r.endedAt=t.timestamp,r.preview=qr(t));return{events:[...e.events,t],spans:n,usage:o}}function Cu(e,t){let n=[],o=null;for(let r of e)r.type==="request"?(o&&n.push(o),o={request:r,response:[]}):o&&o.response.push(r);return o&&n.push(o),{turns:n,tokenUsage:t??null}}function RS(e){let t;for(let n of e)n.type==="usage"&&(t=wu(t,n.usage));return t}function MS(e){let t=[],n=0;for(;n<e.length;){if(e[n]?.role!=="user"){n++;continue}let o=e[n].id;n++;let r=null;for(;n<e.length&&e[n]?.role==="assistant";)r=e[n].id,n++;t.push({userId:o,assistantId:r})}return t}function Rh(e,t){let{turns:n}=Cu(t),o=MS(e),r=new Map,s=Math.min(n.length,o.length);for(let a=0;a<s;a++){let i=RS(n[a].response);if(!i)continue;let{userId:d,assistantId:l}=o[a];i.inputTokens!=null&&r.set(d,{...r.get(d),inputTokens:i.inputTokens}),l!=null&&i.outputTokens!=null&&r.set(l,{...r.get(l),outputTokens:i.outputTokens})}return r}import{Fragment as LS,jsx as zt,jsxs as _l}from"react/jsx-runtime";var Nu=IS(({messages:e,isLoading:t,serverId:n,readResource:o,tools:r,sendMessage:s,messagesEndRef:a,traceEvents:i=[]})=>{let d=AS(()=>Rh(e,i),[e,i]),l=g=>{let v=N=>N.replace(/-/g,"_"),y=v(g);return r?.find(N=>v(N.name)===y)?._meta},u=g=>{let v=l(g);return DS(v)},h=ES(g=>{let v=g.filter(w=>w.type==="text"&&"text"in w).map(w=>w.text).join(`
|
|
199
|
-
`),y=g.filter(w=>w.type==="image"&&"data"in w&&"mimeType"in w).map(w=>({type:"image",data:w.data,mimeType:w.mimeType}));s?.(v,y.length>0?y:void 0)},[s]),c=t&&(()=>{if(e.length===0)return!0;let g=e[e.length-1];if(g.role==="user")return!0;if(g.role==="assistant"){if(g.parts&&g.parts.length>0)return!1;let v=typeof g.content=="string"?g.content:Array.isArray(g.content)?g.content.map(w=>typeof w=="string"?w:w.text||JSON.stringify(w)).join(""):JSON.stringify(g.content);return!(v&&v.trim().length>0)}return!1})(),m=e[e.length-1],p=t&&m?.role==="assistant",x=g=>{for(let v=g.length-1;v>=0;v--)if(g[v]?.type==="text")return v;return-1},f=(g,v,y)=>p&&g.id===m?.id&&v===x(y),b=g=>p&&g.id===m?.id;return _l("div",{className:"space-y-6 max-w-3xl mx-auto px-2",children:[e.map(g=>{let v=typeof g.content=="string"?g.content:Array.isArray(g.content)?g.content.map(y=>typeof y=="string"?y:y.text||JSON.stringify(y)).join(""):JSON.stringify(g.content);if(g.role==="user")return zt(
|
|
200
|
-
`)}else r.content&&typeof r.content=="object"&&(r.content.type==="text"&&r.content.text?s=r.content.text:r.content.type==="image"&&r.content.data?a.push({type:"image",data:r.content.data,mimeType:r.content.mimeType||"image/png"}):s=JSON.stringify(r.content));!s&&a.length===0&&(s="[no content]");let i={id:`prompt-${n.promptName}-${n.timestamp}-${t.length}`,role:r.role,content:s||"",timestamp:n.timestamp,attachments:a.length>0?a:void 0};t.push(i)}}return t};function Bl(e){if(!e)return;let t=
|
|
197
|
+
}`;function jC(e){return[parseInt(e.slice(1,3),16)/255,parseInt(e.slice(3,5),16)/255,parseInt(e.slice(5,7),16)/255,1]}function il({className:e,colors:t=["#e0eaff","#f9ffbd","#dedede","#ffffff"],distortion:n=.8,swirl:o=.1,grainMixer:r=0,grainOverlay:s=.2,speed:a=1}){let i=Ld(null),d=Ld(null),l=Ld({colors:t,distortion:n,swirl:o,grainMixer:r,grainOverlay:s,speed:a});return l.current={colors:t,distortion:n,swirl:o,grainMixer:r,grainOverlay:s,speed:a},FC(()=>{let u=i.current,h=d.current;if(!u||!h)return;let c=u.getContext("webgl2");if(!c)return;let m=($,oe)=>{let ae=c.createShader($);return ae?(c.shaderSource(ae,oe),c.compileShader(ae),c.getShaderParameter(ae,c.COMPILE_STATUS)?ae:(console.error(c.getShaderInfoLog(ae)),null)):null},p=m(c.VERTEX_SHADER,$C),x=m(c.FRAGMENT_SHADER,VC);if(!p||!x)return;let f=c.createProgram();if(!f)return;if(c.attachShader(f,p),c.attachShader(f,x),c.linkProgram(f),!c.getProgramParameter(f,c.LINK_STATUS)){console.error(c.getProgramInfoLog(f));return}c.useProgram(f);let b=c.getAttribLocation(f,"a_position"),g=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,g),c.bufferData(c.ARRAY_BUFFER,new Float32Array([-1,-1,1,-1,-1,1,-1,1,1,-1,1,1]),c.STATIC_DRAW),c.enableVertexAttribArray(b),c.vertexAttribPointer(b,2,c.FLOAT,!1,0,0);let v=c.getUniformLocation(f,"u_time"),y=c.getUniformLocation(f,"u_resolution"),w=[0,1,2,3].map($=>c.getUniformLocation(f,`u_colors[${$}]`)),N=c.getUniformLocation(f,"u_colorsCount"),T=c.getUniformLocation(f,"u_distortion"),L=c.getUniformLocation(f,"u_swirl"),P=c.getUniformLocation(f,"u_grainMixer"),R=c.getUniformLocation(f,"u_grainOverlay"),D=0,k=performance.now(),S=0,A=()=>{let $=Math.min(2,window.devicePixelRatio||1);u.width=Math.floor(h.clientWidth*$),u.height=Math.floor(h.clientHeight*$),c.viewport(0,0,u.width,u.height)},_=$=>{if(document.hidden){k=$,S=requestAnimationFrame(_);return}let{colors:oe,distortion:ae,swirl:ie,grainMixer:ne,grainOverlay:z,speed:O}=l.current,W=$-k;k=$,D+=W*O;let j=oe.map(jC);c.uniform1f(v,D*.001),c.uniform2f(y,u.width,u.height);for(let U=0;U<4;U++){let H=w[U];H&&c.uniform4fv(H,j[U]??[1,1,1,1])}c.uniform1f(N,j.length),c.uniform1f(T,ae),c.uniform1f(L,ie),c.uniform1f(P,ne),c.uniform1f(R,z),c.drawArrays(c.TRIANGLES,0,6),S=requestAnimationFrame(_)};A();let K=new ResizeObserver(A);return K.observe(h),S=requestAnimationFrame(_),()=>{cancelAnimationFrame(S),K.disconnect()}},[]),rg("div",{ref:d,className:e,children:rg("canvas",{ref:i,className:"h-full w-full","aria-hidden":!0})})}var qC=["#e0eaff","#f9ffbd","#dedede","#ffffff"],WC=["#27272a","#9a9448","#3f3f46","#18181b"];function ll(e){return e==="dark"?WC:qC}import{useCallback as KC,useState as JC}from"react";import{Play as GC,Square as YC}from"lucide-react";import{jsx as Cs,jsxs as ZC}from"react/jsx-runtime";var sg="mcp-inspector-chat-mesh-animation-paused";function QC(e){try{return localStorage.getItem(e)==="true"}catch{return!1}}function ag(e){let[t,n]=JC(()=>QC(e)),o=KC(()=>{n(r=>{let s=!r;try{localStorage.setItem(e,s?"true":"false")}catch{}return s})},[e]);return{paused:t,toggle:o}}var XC="z-50 flex h-7 w-7 cursor-pointer items-center justify-center rounded-full border border-zinc-500/60 bg-transparent text-zinc-600 transition-colors hover:border-zinc-500 hover:text-zinc-800 dark:border-zinc-500/50 dark:text-zinc-400 dark:hover:border-zinc-400 dark:hover:text-zinc-200";function ig({paused:e,onToggle:t,className:n}){return ZC(ke,{children:[Cs(we,{render:Cs("button",{type:"button",onClick:t,"aria-label":e?"Resume animation":"Pause animation",className:C(XC,n),children:e?Cs(GC,{className:"ml-px h-3 w-3",fill:"currentColor"}):Cs(YC,{className:"h-2.5 w-2.5",fill:"currentColor"})}),nativeButton:!0}),Cs(Ce,{side:"left",children:Cs("p",{children:e?"Resume animation":"Pause animation"})})]})}import{jsx as xa,jsxs as dg}from"react/jsx-runtime";var nN=.54,oN=.4,cg="linear-gradient(to top, black 0%, black 12%, rgba(0,0,0,0.55) 38%, transparent 100%)";function ug({className:e,children:t,shaderPhase:n="hidden",onShaderFadeComplete:o,meshAnimationPaused:r=!1,...s}){let a=eN(null),[i,d]=tN(!1),{resolvedTheme:l}=no(),u=ll(l),h=l==="dark",{paused:c,toggle:m}=ag(sg),p=c||r;lg(()=>{let g=window.requestAnimationFrame(()=>d(!0));return()=>window.cancelAnimationFrame(g)},[]),lg(()=>{n==="fading"&&!i&&o?.()},[n,i,o]);let x=n!=="hidden",f=n==="visible"&&i,b=g=>{g.propertyName==="opacity"&&n==="fading"&&o?.()};return dg("div",{ref:a,className:C("relative flex min-h-0 flex-1 flex-col overflow-hidden bg-background",e),...s,children:[x&&xa("div",{className:C("pointer-events-none absolute inset-x-0 bottom-0 z-0 transition-opacity duration-500",f?"opacity-100":"opacity-0"),style:{height:`${nN*100}%`},"aria-hidden":!0,onTransitionEnd:b,children:dg("div",{className:C("absolute inset-0",i?h?"opacity-90":"opacity-75":"opacity-0"),style:{maskImage:cg,WebkitMaskImage:cg},children:[xa("div",{className:"absolute inset-0 bg-[#edf2ff] dark:hidden"}),xa(il,{className:"absolute inset-0 h-full w-full",colors:[...u],distortion:.8,swirl:.1,grainMixer:0,grainOverlay:h?.12:.3,speed:p?0:oN})]})}),x&&xa(ig,{paused:c,onToggle:m,className:"absolute bottom-3 right-3 sm:bottom-5 sm:right-5"}),xa("div",{className:"relative z-10 flex min-h-0 flex-1 flex-col",children:t})]})}function mg(e){return e?e.apiKey==="server-managed"||e.baseUrl?.includes("/inspector/llm")===!0:!1}function wa(e){if(!(e instanceof Error))return!1;let t=e.message.toLowerCase();return t.includes("failed to fetch")||t.includes("networkerror")||t.includes("network request failed")||t.includes("load failed")}function _d(e,t){if(!t)return e>=502&&e<=504?{kind:"cloud_unavailable"}:null;if(e===402)return{kind:"credits_exhausted",billingUrl:typeof t.upgradeUrl=="string"?t.upgradeUrl:typeof t.billingUrl=="string"?t.billingUrl:void 0,message:typeof t.message=="string"?t.message:"You've used your included free plan credits."};if(e===429){if(t.loginRequired&&t.loginUrl)return{kind:"login_required",loginUrl:String(t.loginUrl)};if(t.creditsExhausted)return{kind:"credits_exhausted",billingUrl:typeof t.billingUrl=="string"?t.billingUrl:void 0,message:typeof t.message=="string"?t.message:"You've used your included free plan credits."};if(t.error==="free_org_rate_limited"||typeof t.reason=="string")return{kind:"credits_exhausted",message:typeof t.message=="string"?t.message:"You've reached your included chat quota for this workspace."}}return e>=502&&e<=504?{kind:"cloud_unavailable"}:null}function rN(e){let t=e.match(/^OpenAI request failed \((\d+) /);if(!t)return null;let n=Number(t[1]),o=e.indexOf("{");if(o===-1)return null;try{let r=JSON.parse(e.slice(o));if(r&&typeof r=="object"&&!Array.isArray(r))return{status:n,body:r}}catch{}return null}function pg(e){if(e instanceof Error&&e.name==="LlmRequestError"){let t=e.status??0,n=e.body,o=n&&typeof n=="object"&&!Array.isArray(n)?n:void 0;return _d(t,o)}if(e instanceof Error){let t=rN(e.message);if(t)return _d(t.status,t.body)}return wa(e)?{kind:"cloud_unavailable"}:null}function fg(e,t){return _d(e,t)}import{ChevronDown as sN,Key as aN}from"lucide-react";import{jsx as Dn,jsxs as Od}from"react/jsx-runtime";var iN="https://cdn.mcp-use.com/mcpuse_logo_circle_dark.svg";function gg({symbolSize:e=14,className:t,textClassName:n}){return Od("span",{className:C("inline-flex items-center gap-1.5 text-black dark:text-white",t),children:[Dn(lN,{size:e}),Dn("span",{className:C("font-medium leading-none text-current [font-family:var(--font-family-outfit)]",n),children:"Manufact"})]})}function lN({size:e=14,className:t}){return Od("svg",{width:e,height:e,viewBox:"0 0 480 480","aria-hidden":!0,className:C("block shrink-0",t),children:[Dn("path",{d:"M101.7 0 C157.9 0 203.4 45.7 203.4 102.1 C203.4 126.6 202.1 152.1 212.2 174.3 L219.8 191 C233.8 221.8 258.5 246.4 289.2 260.5 L303.5 267 C326.5 277.5 353 275.8 378.3 275.8 C434.5 275.8 480 321.5 480 377.9 C480 434.3 434.5 480 378.3 480 C322.1 480 276.6 434.3 276.6 377.9 C276.6 354.2 277.7 329.6 267.8 308 L259.8 290.3 C245.7 259.5 221 234.8 190.2 220.7 L173 212.9 C151 202.9 125.8 204.2 101.7 204.2 C45.5 204.2 0 158.5 0 102.1 C0 45.7 45.5 0 101.7 0 Z",fill:"currentColor"}),Dn("circle",{cx:"96.4",cy:"383.6",r:"96.4",fill:"currentColor"}),Dn("circle",{cx:"383.6",cy:"96.4",r:"96.4",fill:"currentColor"})]})}var cN='<svg width="512" height="512" viewBox="0 0 512 512" xmlns="http://www.w3.org/2000/svg" fill="#94A3B8" stroke="#94A3B8"><g><path fill="none" d="M3 248.945C18 248.945 76 236 106 219C136 202 136 202 198 158C276.497 102.293 332 120.945 423 120.945" stroke-width="90"/><path d="M511 121.5L357.25 210.268L357.25 32.7324L511 121.5Z"/><path fill="none" d="M0 249C15 249 73 261.945 103 278.945C133 295.945 133 295.945 195 339.945C273.497 395.652 329 377 420 377" stroke-width="90"/><path d="M508 376.445L354.25 287.678L354.25 465.213L508 376.445Z"/></g></svg>',dN=`data:image/svg+xml,${encodeURIComponent(cN)}`,uN={openai:"OpenAI",anthropic:"Anthropic",google:"Google"};function mN(e){let t=e.split("/")[0]?.toLowerCase();return t==="openai"||t==="anthropic"||t==="google"?t:"openrouter"}function Ca(e,t){let n=e.trim(),o=uN[t];if(o){let s=o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),a=new RegExp(`^${s}\\s*:\\s*`,"i"),i=n.replace(a,"").trim();if(i.length>0)return i}let r=n.indexOf(": ");return r>0&&r<48?n.slice(r+2).trim():n}function hg({provider:e,model:t,displayName:n,mode:o="byok",className:r,...s}){let a=n??t,i=o==="managed"&&e==="openai-compatible"?mN(t):e;return Od("button",{type:"button",className:C("inline-flex items-center gap-1.5 min-w-0 border-0 bg-transparent p-1","font-mono text-[11px] text-muted-foreground cursor-pointer","hover:text-foreground transition-colors","rounded-md outline-none focus-visible:ring-1 focus-visible:ring-ring",r),...s,children:[o==="managed"?Dn("img",{src:iN,alt:"Manufact",className:"h-3.5 w-3.5 shrink-0 rounded-full object-cover"}):Dn(aN,{className:"size-3 shrink-0 opacity-70","aria-hidden":!0}),Dn(Kn,{provider:i,className:"shrink-0"}),Dn("span",{className:"whitespace-nowrap",children:a}),Dn(sN,{className:"size-3 shrink-0 opacity-60","aria-hidden":!0})]})}function Ot(e){switch(e){case"openai":return"OpenAI";case"openai-compatible":return"OpenAI Compatible";case"anthropic":return"Anthropic";case"google":return"Google";case"openrouter":return"OpenRouter";case"ollama":return"Ollama";default:return e}}function pN(e,t){switch(e){case"openai":case"anthropic":case"google":return Ks(`${e}.png`);case"ollama":return Ks(`${t==="dark"?"ollama_dark":"ollama_light"}.png`);case"openrouter":return dN;case"openai-compatible":return null;default:return null}}function Kn({provider:e,className:t}){let{resolvedTheme:n}=no();if(e==="openai-compatible")return null;let o=pN(e,n);if(o){let r=e==="ollama"?"h-3.5 w-3.5 object-contain":"h-4 w-4 rounded-full object-cover";return Dn("img",{src:o,alt:Ot(e),className:C(r,t)})}return Dn("div",{"aria-label":Ot(e),className:C("flex h-4 w-4 items-center justify-center rounded-full bg-neutral-900 text-[9px] font-semibold text-white dark:bg-neutral-100 dark:text-neutral-900",t),children:Ot(e).charAt(0)})}import{useCallback as cl,useEffect as fN,useSyncExternalStore as gN}from"react";var $d="openid profile email offline_access",bg="mcp-inspector:manufact-auth",hN="manufact:session-changed",Na={loaded:!0,authorizing:!1,accessToken:null,user:null,mode:null},Ur=new Map,Ud=new Set,zd=new Map,Bd=new Map,yg=null,Hd=!1;typeof window<"u"&&window.addEventListener("message",e=>{if(e.data?.type!=="manufact:invalidate-oauth-client")return;for(let n of Ur.keys())Ln()?.removeItem(dn(n,"client"));let t=yg;!t||Hd||(Hd=!0,Sg(t,{isRetry:!0}).finally(()=>{Hd=!1}))});function vN(e){let t=Ur.get(e);if(t)return t;let n={...Na,loaded:!1};return Ur.set(e,n),n}function Ln(){return typeof window>"u"?null:window.localStorage}function ml(e){return new URL(e).origin}function bN(e,t){let n=new URL(e),o=new URL(t),r=new Set(["localhost","127.0.0.1"]);return r.has(n.hostname)&&r.has(o.hostname)?n.origin===o.origin:(n.hostname==="manufact.com"||n.hostname.endsWith(".manufact.com"))&&(o.hostname==="manufact.com"||o.hostname.endsWith(".manufact.com"))}function xg(e){let t=window.__MANUFACT_LOGIN_URL__;if(t)return new URL(t).origin;let n=new URL(e);return n.hostname==="localhost"||n.hostname==="127.0.0.1"?`${n.protocol}//${n.hostname}:3000`:`${n.protocol}//manufact.com`}function yN(e){return`${xg(e)}/auth/embedded-sign-out`}function dn(e,t){return`${bg}:${t}:${e}`}function xN(e){return Ln()?.getItem(dn(e,"skip-session"))==="1"}function ul(e,t){let n=dn(e,"skip-session");t?Ln()?.setItem(n,"1"):Ln()?.removeItem(n)}function wN(e){return`${bg}:state:${e}`}function Ns(e){let t=Ln()?.getItem(e);if(!t)return null;try{return JSON.parse(t)}catch{return Ln()?.removeItem(e),null}}function Vd(e,t){Ln()?.setItem(e,JSON.stringify(t))}function io(e,t){Ur.set(e,{...Ur.get(e)??Na,...t}),Ud.forEach(n=>n()),window.dispatchEvent(new CustomEvent(hN))}function wg(e){let t="";return e.forEach(n=>{t+=String.fromCharCode(n)}),btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function Fd(e=32){let t=new Uint8Array(e);return crypto.getRandomValues(t),wg(t)}async function Cg(e){let t=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(e));return wg(new Uint8Array(t))}async function pl(e){let t=await fetch(`${e}/api/auth/.well-known/openid-configuration`);if(!t.ok)throw new Error("Manufact OAuth discovery failed");return await t.json()}function Ng(){return`${window.location.origin}${Ws()}/auth/callback`}function vg(e){return e==="localhost"||e==="127.0.0.1"}function CN(e){try{let t=new URL(e).hostname,n=typeof window<"u"?new URL(window.location.href).hostname:"";return vg(t)&&vg(n)}catch{return!1}}async function NN(e,t,n){let o=new URL(`${e}/api/auth/oauth2/authorize`);o.searchParams.set("response_type","code"),o.searchParams.set("client_id",t),o.searchParams.set("redirect_uri",n),o.searchParams.set("scope",$d),o.searchParams.set("code_challenge",await Cg(Fd(32))),o.searchParams.set("code_challenge_method","S256"),o.searchParams.set("state","client-probe"),o.searchParams.set("prompt","none");try{let r=await fetch(o.toString(),{method:"GET",redirect:"manual",credentials:"include"}),s=r.headers.get("location")??"";return s.includes("/auth/error")&&s.includes("invalid_client")?!1:r.status>=300&&r.status<400||r.type==="opaqueredirect"?!!s&&!s.includes("/auth/error"):!0}catch{return!1}}async function kN(e,t){let n=Ng(),o=dn(e,"client"),r=Ns(o),s=CN(e);if(!s&&r?.client_id&&r.redirect_uri===n){if(await NN(e,r.client_id,n))return r;Ln()?.removeItem(o)}else s&&r?.client_id&&Ln()?.removeItem(o);if(!t.registration_endpoint)throw new Error("Manufact OAuth registration is unavailable");let a=await fetch(t.registration_endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_name:"mcp-use Inspector",redirect_uris:[n],grant_types:["authorization_code","refresh_token"],response_types:["code"],token_endpoint_auth_method:"none",scope:$d})});if(!a.ok)throw new Error("Could not register Inspector with Manufact");let i=await a.json();if(!i.client_id)throw new Error("Manufact returned no OAuth client ID");let d={...i,redirect_uri:n};return Vd(o,d),d}async function SN(e,t){let n=await fetch(e,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(t)}),o=await n.json().catch(()=>({}));if(!n.ok||!o.access_token)throw new Error(o.error_description??"Manufact token exchange failed");return{access_token:o.access_token,refresh_token:o.refresh_token,token_type:o.token_type,expires_at:Date.now()+(o.expires_in??3600)*1e3}}async function TN(e,t){if(!t.refresh_token)return null;let n=Bd.get(e);if(n)return n;let o=(async()=>{try{let r=await pl(e),s=Ns(dn(e,"client"));if(!s?.client_id)return null;let a=await SN(r.token_endpoint,{grant_type:"refresh_token",refresh_token:t.refresh_token,client_id:s.client_id}),i={...a,refresh_token:a.refresh_token??t.refresh_token};return Vd(dn(e,"tokens"),i),i}catch{return Ln()?.removeItem(dn(e,"tokens")),null}finally{Bd.delete(e)}})();return Bd.set(e,o),o}async function PN(e){let t=Ns(dn(e,"tokens"));return t?.access_token?t.expires_at>Date.now()+3e4?t:TN(e,t):null}async function RN(e,t){let n=await pl(e);if(!n.userinfo_endpoint)return null;let o=await fetch(n.userinfo_endpoint,{headers:{Authorization:`Bearer ${t}`}});if(!o.ok)return null;let r=await o.json();return r.sub?{id:r.sub,name:r.name,email:r.email,image:r.picture}:null}async function kg(e){try{let t=await fetch(`${e}/api/auth/get-session`,{credentials:"include"});return t.ok?(await t.json())?.user??null:null}catch{return null}}async function dl(e){let t=zd.get(e);if(t)return t;Ur.set(e,{...Ur.get(e)??Na,loaded:!1});let n=(async()=>{try{let o=typeof window<"u"?window.location.href:e,r=bN(o,e),s=xN(e),a=await PN(e),i=a?await RN(e,a.access_token):null;if(i&&a){ul(e,!1),io(e,{loaded:!0,accessToken:a.access_token,user:i,mode:"oauth"});return}a&&!i&&Ln()?.removeItem(dn(e,"tokens"));let d=r&&!s?await kg(e):null;if(d){io(e,{loaded:!0,accessToken:null,user:d,mode:"session"});return}io(e,{loaded:!0,accessToken:null,user:null,mode:null})}catch{io(e,{loaded:!0,accessToken:null,user:null,mode:null})}})().finally(()=>zd.delete(e));return zd.set(e,n),n}async function Sg(e,t){let n=ml(e);yg=e,ul(n,!1);let o=window.open("","manufact-oauth","width=600,height=700,resizable=yes,scrollbars=yes");if(!o)throw new Error("Allow popups to sign in with Manufact");io(n,{authorizing:!0});try{let r=await pl(n),s=await kN(n,r),a=Fd(64),i=Fd(),d=Ng();Vd(wN(i),{authOrigin:n,clientId:s.client_id,redirectUri:d,codeVerifier:a,expiresAt:Date.now()+600*1e3});let l=new URL(r.authorization_endpoint);l.searchParams.set("response_type","code"),l.searchParams.set("client_id",s.client_id),l.searchParams.set("redirect_uri",d),l.searchParams.set("scope",$d),l.searchParams.set("state",i),l.searchParams.set("code_challenge",await Cg(a)),l.searchParams.set("code_challenge_method","S256"),l.searchParams.set("prompt","consent"),o.location.href=l.toString();let u=window.setInterval(()=>{o.closed&&(window.clearInterval(u),dl(n).finally(()=>io(n,{authorizing:!1})))},500)}catch(r){throw o.close(),io(n,{authorizing:!1}),r}}function MN(e){let t=ml(e);Ln()?.removeItem(dn(t,"tokens")),io(t,{loaded:!0,authorizing:!1,accessToken:null,user:null,mode:null})}async function IN(e){let t=Ns(dn(e,"tokens")),n=Ns(dn(e,"client")),o=t?.refresh_token??t?.access_token;if(!n?.client_id||!o)return null;try{let s=(await pl(e)).revocation_endpoint??`${e}/api/auth/oauth2/revoke`;return(await fetch(s,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({client_id:n.client_id,token:o,token_type_hint:t?.refresh_token?"refresh_token":"access_token"})})).status}catch{return-1}}async function EN(e){let t=xg(e),n=window.open(yN(e),"manufact-sign-out","width=420,height=320");return n?new Promise(o=>{let r=!1,s=l=>{r||(r=!0,window.clearTimeout(a),window.clearInterval(d),window.removeEventListener("message",i),o(l))},a=window.setTimeout(()=>{s({attempted:!0,signOutOk:!1,signOutStatus:null})},3e4),i=l=>{l.origin===t&&l.data?.type==="manufact:sign-out-complete"&&s({attempted:!0,signOutOk:!0,signOutStatus:200})},d=window.setInterval(()=>{n.closed&&kg(e).then(l=>{s({attempted:!0,signOutOk:!l,signOutStatus:l?401:200})})},500);window.addEventListener("message",i)}):{attempted:!0,signOutOk:!1,signOutStatus:null}}async function AN(e,t){let n=ml(e),o=!!Ns(dn(n,"tokens"))?.access_token;t==="oauth"||o?(await IN(n),ul(n,!0)):t==="session"&&(await EN(n),ul(n,!1)),MN(e)}function Tg(e){let t=e?ml(e):null,n=cl(s=>(Ud.add(s),()=>Ud.delete(s)),[]),o=cl(()=>t?vN(t):Na,[t]),r=gN(n,o,()=>Na);return fN(()=>{if(!t)return;dl(t);let s=i=>{i.origin===window.location.origin&&i.data?.type==="manufact:oauth-complete"&&i.data.authOrigin===t&&dl(t).finally(()=>io(t,{authorizing:!1}))},a=i=>{i.key!==dn(t,"tokens")||!i.newValue||dl(t).finally(()=>io(t,{authorizing:!1}))};return window.addEventListener("message",s),window.addEventListener("storage",a),()=>{window.removeEventListener("message",s),window.removeEventListener("storage",a)}},[t]),{...r,authorize:cl(async()=>{e&&await Sg(e)},[e]),logout:cl(async()=>{e&&await AN(e,r.mode)},[e,r.mode])}}function Pg(e){return Tg(e)}import{useEffect as DN}from"react";function Rg(e){DN(()=>{let t=n=>{let o=n.target,r=o.tagName==="INPUT"||o.tagName==="TEXTAREA"||o.contentEditable==="true";if((n.metaKey||n.ctrlKey)&&n.key==="k"){n.preventDefault(),e.onCommandPalette?.();return}if((n.metaKey||n.ctrlKey)&&n.key==="o"&&e.onNewChat){n.preventDefault(),e.onNewChat();return}if(n.key==="Escape"){n.preventDefault(),document.activeElement instanceof HTMLElement&&document.activeElement.blur(),e.onBlurSearch?.();return}if(!r&&!(n.metaKey||n.ctrlKey||n.altKey||n.shiftKey))switch(n.key.toLowerCase()){case"t":n.preventDefault(),e.onToolsTab?.();break;case"p":n.preventDefault(),e.onPromptsTab?.();break;case"r":n.preventDefault(),e.onResourcesTab?.();break;case"c":n.preventDefault(),e.onChatTab?.();break;case"h":n.preventDefault(),e.onHome?.();break;case"f":n.preventDefault(),e.onFocusSearch?.();break;default:break}};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[e])}import{Copy as ck,Download as dk,SquarePen as uk}from"lucide-react";import{Check as Lg,ChevronsUpDown as _g,Eye as jN,EyeOff as qN,Key as WN,Loader2 as Og}from"lucide-react";import{useEffect as Xd,useRef as KN,useState as $r}from"react";import{Tabs as Wd}from"@base-ui/react/tabs";import{AnimatePresence as Kd,motion as fl}from"motion/react";import{createContext as zN,forwardRef as Yd,useCallback as qd,useContext as BN,useEffect as Jd,useRef as gl,useState as HN}from"react";import{useCallback as ks,useEffect as jd,useRef as Ss,useState as Mg}from"react";function Ig(e,t){let n=e.getBoundingClientRect(),o=t==="x"?e.offsetWidth:e.offsetHeight,r=t==="x"?n.width:n.height;return o>0?r/o:1}function LN(e,t){let n=e.getBoundingClientRect(),o=Ig(e,"x"),r=Ig(e,"y"),s=[];return t.forEach((a,i)=>{let d=a.getBoundingClientRect();s[i]={top:(d.top-n.top)/r+e.scrollTop,left:(d.left-n.left)/o+e.scrollLeft,width:a.offsetWidth,height:a.offsetHeight}}),s}function _N(e,t,n,o){let r=o==="x"?t:n,s=null,a=1/0,i=null;return e.forEach((d,l)=>{let u=d.getBoundingClientRect(),h=o==="x"?u.left:u.top,c=o==="x"?u.right:u.bottom;r>=h&&r<=c&&(i=l);let m=(h+c)/2,p=Math.abs(r-m);p<a&&(a=p,s=l)}),i??s}function ON(e,t){if(e.length!==t.length)return!0;for(let n=0;n<t.length;n++){let o=e[n],r=t[n];if(o!==r&&(!o||!r||o.top!==r.top||o.left!==r.left||o.width!==r.width||o.height!==r.height))return!0}return!1}function Eg(e,t={}){let{axis:n="y"}=t,o=Ss(new Map),[r,s]=Mg(null),[a,i]=Mg([]),d=Ss([]),l=Ss(0),u=Ss(null),h=Ss(null),c=Ss(null),m=ks(()=>{let v=e.current;if(!v)return;let y=LN(v,o.current);ON(d.current,y)&&(d.current=y,i(y))},[e]),p=ks((v,y)=>{s(_N(o.current,v,y,n))},[n]),x=ks((v,y)=>{y?o.current.set(v,y):o.current.delete(v),h.current!==null&&cancelAnimationFrame(h.current),h.current=requestAnimationFrame(()=>{h.current=null,m()})},[m]),f=ks(v=>{c.current={x:v.clientX,y:v.clientY},u.current!==null&&cancelAnimationFrame(u.current),u.current=requestAnimationFrame(()=>{u.current=null,m(),p(v.clientX,v.clientY)})},[m,p]),b=ks(()=>{l.current+=1},[]),g=ks(()=>{u.current!==null&&(cancelAnimationFrame(u.current),u.current=null),c.current=null,s(null)},[]);return jd(()=>{let v=e.current;if(!v||typeof ResizeObserver>"u")return;let y=new ResizeObserver(()=>{h.current!==null&&cancelAnimationFrame(h.current),h.current=requestAnimationFrame(()=>{h.current=null,m()})});return y.observe(v),()=>y.disconnect()},[e,m]),jd(()=>{let v=e.current;if(!v)return;let y=()=>{m();let w=c.current;w&&p(w.x,w.y)};return v.addEventListener("scroll",y,{capture:!0,passive:!0}),()=>v.removeEventListener("scroll",y,{capture:!0})},[e,m,p]),jd(()=>()=>{u.current!==null&&cancelAnimationFrame(u.current),h.current!==null&&cancelAnimationFrame(h.current)},[]),{activeIndex:r,setActiveIndex:s,itemRects:a,sessionRef:l,handlers:{onMouseMove:f,onMouseEnter:b,onMouseLeave:g},registerItem:x,measureItems:m}}import{jsx as yn,jsxs as Gd}from"react/jsx-runtime";var Ag=zN(null);function UN(){let e=BN(Ag);if(!e)throw new Error("useTabsSubtle must be used within a TabsSubtle");return e}var ka=Yd(({children:e,selectedIndex:t,onSelect:n,idPrefix:o,activeLabel:r=!1,className:s,...a},i)=>{let d=gl(null),l=gl(!1),u=pt(),{activeIndex:h,setActiveIndex:c,itemRects:m,handlers:p,registerItem:x,measureItems:f}=Eg(d,{axis:"x"}),b=gl(new Map),g=qd((k,S)=>{x(k,S),S?b.current.set(k,S):b.current.delete(k)},[x]);Jd(()=>{f()},[f,e]),Jd(()=>{let k=b.current;if(k.size===0)return;let S=new ResizeObserver(()=>f());return k.forEach(A=>S.observe(A)),()=>S.disconnect()},[f,e]);let v=qd(k=>{l.current=!0,p.onMouseMove(k)},[p]),y=qd(()=>{l.current=!1,p.onMouseLeave()},[p]),[w,N]=HN(null),T=m[t],L=h!==null?m[h]:null,P=w!==null?m[w]:null,R=h===t,D=h!==null&&!R;return yn(Ag.Provider,{value:{registerTab:g,hoveredIndex:h,selectedIndex:t,idPrefix:o,activeLabel:r},children:yn(Wd.Root,{value:t,onValueChange:k=>{typeof k=="number"&&n(k)},render:Gd(Wd.List,{activateOnFocus:!1,ref:k=>{d.current=k,typeof i=="function"?i(k):i&&(i.current=k)},onMouseMove:v,onMouseLeave:y,onFocus:k=>{let S=k.target.closest("[data-proximity-index]")?.getAttribute("data-proximity-index");if(S!=null){let A=Number(S);c(A),N(k.target.matches(":focus-visible")?A:null)}},onBlur:k=>{d.current?.contains(k.relatedTarget)||(N(null),!l.current&&c(null))},className:C("relative flex items-center gap-0.5 select-none overflow-x-auto max-w-full -mx-1 px-1 -my-1 py-1",s),...a,children:[T&&yn(fl.div,{className:C("absolute bg-accent pointer-events-none",u.bg),initial:!1,animate:{left:T.left,width:T.width,top:T.top,height:T.height,opacity:D?.8:1},transition:{...se.moderate,opacity:{duration:.08}}}),yn(Kd,{children:L&&!R&&T&&yn(fl.div,{className:C("absolute bg-accent pointer-events-none",u.bg),initial:{left:T.left,width:T.width,top:T.top,height:T.height,opacity:0},animate:{left:L.left,width:L.width,top:L.top,height:L.height,opacity:.4},exit:!l.current&&T?{left:T.left,width:T.width,top:T.top,height:T.height,opacity:0,transition:{...se.moderate,opacity:{duration:.06}}}:{opacity:0,transition:se.fast.exit},transition:{...se.fast,opacity:{duration:.08}}})}),yn(Kd,{children:P&&yn(fl.div,{className:C("absolute pointer-events-none z-20 border border-[color:var(--focus-ring,#6B97FF)]",u.focusRing),initial:!1,animate:{left:P.left-2,top:P.top-2,width:P.width+4,height:P.height+4},exit:{opacity:0,transition:se.fast.exit},transition:{...se.fast,opacity:{duration:.08}}})}),e]})})})});ka.displayName="TabsSubtle";var Fr=Yd(({icon:e,label:t,index:n,className:o,...r},s)=>{let a=gl(null),i=pt(),{registerTab:d,hoveredIndex:l,selectedIndex:u,idPrefix:h,activeLabel:c}=UN();Jd(()=>(d(n,a.current),()=>d(n,null)),[n,d]);let m=u===n,p=l===n||m,x=c&&!!e,f=!x||m,b=Gd("span",{className:"inline-grid",children:[yn("span",{className:"col-start-1 row-start-1 invisible [text-box:trim-both_cap_alphabetic]",style:{fontVariationSettings:yt.semibold},"aria-hidden":"true",children:t}),yn("span",{className:C("col-start-1 row-start-1 transition-[color,font-variation-settings] duration-80 [text-box:trim-both_cap_alphabetic]",p?"text-foreground":"text-muted-foreground"),style:{fontVariationSettings:m?yt.semibold:yt.normal},children:t})]});return Gd(Wd.Tab,{ref:g=>{let v=g;a.current=v,typeof s=="function"?s(v):s&&(s.current=v)},value:n,"data-proximity-index":n,id:h?`${h}-tab-${n}`:void 0,"aria-controls":h?`${h}-panel-${n}`:void 0,"aria-label":x&&!f?t:void 0,className:C("relative z-10 flex items-center px-2 cursor-pointer bg-transparent border-none outline-none text-xs",x?"h-7":"h-7 gap-1.5",i.bg,o),...r,children:[e&&yn(e,{size:14,strokeWidth:p?2:1.5,className:C("shrink-0 transition-[color,stroke-width] duration-80",p?"text-foreground":"text-muted-foreground")}),x?yn(Kd,{children:f&&yn(fl.span,{className:"overflow-hidden",initial:{width:0,opacity:0,marginLeft:0},animate:{width:"auto",opacity:1,marginLeft:6},exit:{width:0,opacity:0,marginLeft:0},transition:{...se.fast,opacity:{duration:.06}},children:b},"label")}):b]})});Fr.displayName="TabsSubtleItem";var FN=Yd(({index:e,selectedIndex:t,idPrefix:n,children:o,className:r,...s},a)=>{let i=t===e;return yn("div",{ref:a,id:`${n}-panel-${e}`,role:"tabpanel","aria-labelledby":`${n}-tab-${e}`,hidden:!i,tabIndex:-1,className:C("outline-none",r),...s,children:i&&o})});FN.displayName="TabsSubtlePanel";import*as Rt from"react";import{jsx as ar,jsxs as VN}from"react/jsx-runtime";var Dg=Rt.createContext(null);function Qd(){let e=Rt.useContext(Dg);if(!e)throw new Error("Command components must be used within <Command>");return e}function $N(e,t){return t?e.toLowerCase().includes(t.toLowerCase()):!0}var hl=Rt.forwardRef(({className:e,...t},n)=>{let[o,r]=Rt.useState(""),[s,a]=Rt.useState(null),[i,d]=Rt.useState(0),l=Rt.useCallback(()=>(d(u=>u+1),()=>d(u=>Math.max(0,u-1))),[]);return ar(Dg.Provider,{value:{search:o,setSearch:r,activeValue:s,setActiveValue:a,visibleCount:i,registerVisible:l},children:ar("div",{ref:n,className:C("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t})})});hl.displayName="Command";var vl=Rt.forwardRef(({className:e,...t},n)=>{let{search:o,setSearch:r}=Qd();return ar("div",{className:"flex items-center border-b px-3",children:ar("input",{ref:n,value:o,onChange:s=>r(s.target.value),className:C("flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",e),...t})})});vl.displayName="CommandInput";var bl=Rt.forwardRef(({className:e,...t},n)=>ar("div",{ref:n,className:C("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));bl.displayName="CommandList";var yl=Rt.forwardRef(({className:e,...t},n)=>{let{visibleCount:o}=Qd();return o>0?null:ar("div",{ref:n,className:C("py-6 text-center text-sm",e),...t})});yl.displayName="CommandEmpty";var xl=Rt.forwardRef(({className:e,heading:t,children:n,...o},r)=>VN("div",{ref:r,className:C("overflow-hidden p-1 text-foreground [&_[data-command-group-heading]]:px-2 [&_[data-command-group-heading]]:py-1.5 [&_[data-command-group-heading]]:text-xs [&_[data-command-group-heading]]:font-medium [&_[data-command-group-heading]]:text-muted-foreground",e),...o,children:[t?ar("div",{"data-command-group-heading":"",children:t}):null,n]}));xl.displayName="CommandGroup";var wl=Rt.forwardRef(({className:e,value:t,keywords:n,onSelect:o,disabled:r,onClick:s,...a},i)=>{let{search:d,activeValue:l,setActiveValue:u,registerVisible:h}=Qd(),c=Array.isArray(n)?n.join(" "):n,m=c?`${t} ${c}`:t,p=$N(m,d),x=l===t;return Rt.useLayoutEffect(()=>{if(p)return h()},[p,h]),Rt.useEffect(()=>{p&&l===null&&!r&&u(t)},[p,l,r,u,t]),p?ar("div",{ref:i,role:"option","aria-selected":x,"data-selected":x,"data-disabled":r,className:C("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50",e),onMouseEnter:()=>!r&&u(t),onClick:f=>{s?.(f),r||o?.(t)},...a}):null});wl.displayName="CommandItem";import{buildOllamaApiUrl as JN,normalizeOllamaBaseUrl as GN,OllamaCorsError as YN}from"@mcp-use/agent";import{Fragment as lk,jsx as G,jsxs as _e}from"react/jsx-runtime";var Zd="mcp-inspector-models-cache",QN=1440*60*1e3;function zg(){try{let e=localStorage.getItem(Zd);if(e)return JSON.parse(e)}catch(e){console.error("Failed to load models cache:",e)}return{}}function XN(e,t){try{let n=zg();n[e]={models:t,timestamp:Date.now()},localStorage.setItem(Zd,JSON.stringify(n))}catch(n){console.error("Failed to save models cache:",n)}}function ZN(e){try{let t=zg(),n=t[e];if(n){if(Date.now()-n.timestamp<QN)return n.models;delete t[e],localStorage.setItem(Zd,JSON.stringify(t))}}catch(t){console.error("Failed to get cached models:",t)}return null}function ek(e,t){if(!So(e)||!t?.trim())return e;let n=e==="ollama"?GN(t):t.trim().toLowerCase();return`${e}:${n}`}var tk="chat-config-source";function Sa(e){return e==="openai"||e==="anthropic"||e==="google"?e:"openrouter"}async function nk(e,t){let n={};t&&(n.Authorization=`Bearer ${t}`);let o;try{o=await fetch(`${e}/models`,{headers:n})}catch{throw new Error("Failed to reach the server. Check the URL is correct and that CORS is enabled on the server.")}if(!o.ok)throw new Error(`Failed to fetch models: ${o.statusText}`);if(!(o.headers.get("content-type")??"").includes("application/json"))throw new Error("Invalid URL \u2014 response was not JSON");let s=await o.json();if(!Array.isArray(s?.data))throw new Error("Unexpected response format \u2014 expected { data: [...] } from the OpenAI-compatible endpoint");return s.data.map(a=>({id:a.id}))}async function ok(e){let t=await fetch("https://api.openai.com/v1/models",{headers:{Authorization:`Bearer ${e}`}});if(!t.ok)throw new Error(`Failed to fetch OpenAI models: ${t.statusText}`);return(await t.json()).data.map(o=>({id:o.id}))}async function rk(e){let t=await fetch("https://api.anthropic.com/v1/models",{headers:{"x-api-key":e,"anthropic-version":"2023-06-01","anthropic-dangerous-direct-browser-access":"true"}});if(!t.ok)throw new Error(`Failed to fetch Anthropic models: ${t.statusText}`);return(await t.json()).data.map(o=>({id:o.id,displayName:o.display_name}))}async function sk(e){let t=await fetch(`https://generativelanguage.googleapis.com/v1beta/models?key=${e}`);if(!t.ok)throw new Error(`Failed to fetch Google models: ${t.statusText}`);return((await t.json()).models||[]).map(o=>({id:o.name,displayName:o.displayName}))}async function ak(e){let t=await fetch("https://openrouter.ai/api/v1/models",{headers:{Authorization:`Bearer ${e}`}});if(!t.ok)throw new Error(`Failed to fetch OpenRouter models: ${t.statusText}`);return(await t.json()).data.map(o=>({id:o.id,displayName:o.name}))}async function ik(e,t){let n;try{n=await fetch(JN(e,"/api/tags"),{headers:{...t.trim()?{Authorization:`Bearer ${t.trim()}`}:{}}})}catch(r){throw new YN(r)}if(!n.ok)throw new Error(`Failed to fetch Ollama models: ${n.statusText}`);return((await n.json()).models||[]).map(r=>({id:r.model||r.name||""}))}function Ta({open:e,onOpenChange:t,tempProvider:n,tempModel:o,tempApiKey:r,tempBaseUrl:s,onProviderChange:a,onModelChange:i,onApiKeyChange:d,onBaseUrlChange:l,onSave:u,onClear:h,showClearButton:c=!1,buttonLabel:m="Configure API Key",hostedInspector:p=!1,freeTierInfo:x,managedCloudInfo:f,useManagedCloud:b=!1,onSaveManagedCloud:g}){let{resolvedTheme:v}=no(),y=ll(v),w=v==="dark",[N,T]=$r([]),[L,P]=$r(!1),[R,D]=$r(null),[k,S]=$r(!1),[A,_]=$r(!1),[K,$]=$r(!1),[oe,ae]=$r(b?0:1),ie=ek(n,s),ne=!!(p||x||f),z=!!(f&&oe===0);Xd(()=>{e&&ae(b?0:1)},[e,b]),Xd(()=>{let Y=Lr(n),q=So(n);if(z||!e||!n||Y&&!r.trim()||q&&!s.trim()){T([]),D(null);return}let Ne=setTimeout(async()=>{let gt=ZN(ie);if(gt){T(gt),D(null);return}P(!0),D(null);try{let qe=[];n==="openai-compatible"?qe=await nk(s,r):n==="openai"?qe=await ok(r):n==="anthropic"?qe=await rk(r):n==="google"?qe=await sk(r):n==="openrouter"?qe=await ak(r):n==="ollama"&&(qe=await ik(s,r)),XN(ie,qe),T(qe)}catch(qe){D(qe instanceof Error?qe.message:"Failed to fetch models. Please check your API key."),T([])}finally{P(!1)}},500);return()=>clearTimeout(Ne)},[r,s,n,e,ie,z]);let O=KN(null);Xd(()=>{if(!e||z){e||(O.current=null);return}let Y=O.current;Y!==null&&Y!==n&&i(""),O.current=n},[n,e,i,z]);let W=So(n),j=!Lr(n),U=e&&(!Lr(n)||!!r.trim())&&(!W||!!s.trim()),H=j?"API Key (optional)":"API Key",Te=j?n==="ollama"?"Leave empty for local Ollama":"Enter your API key (optional)":"Enter your API key",Pe=n==="openai-compatible"?"http://localhost:11434/v1":er(n),le=n==="openai-compatible"?"Base URL of your OpenAI-compatible API. Local servers must have CORS enabled.":null,de=n==="ollama"?"Optional for local Ollama. Stored locally and never sent to our servers.":"Your API key is stored locally and never sent to our servers.",De=f?f.models.reduce((Y,q)=>(Y[q.provider]||(Y[q.provider]=[]),Y[q.provider].push(q),Y),{}):{},Re=f?.models.find(Y=>Y.id===f.selectedModelId),Oe=Object.keys(De),Be=Re?.provider??Oe[0]??"",tt=Be?De[Be]??[]:[],V=!!h&&c&&(!f||oe===1),ce=()=>{if(z&&g){g();return}u()},Fe=z?!!(f?.isLoading||!f?.selectedModelId||f?.models.length===0):Lr(n)&&!r.trim()||W&&!s.trim()||!o.trim();return G(fn,{open:e,onOpenChange:t,children:_e(on,{className:"max-w-md","data-testid":"chat-config-dialog",children:[_e(Qt,{children:[G(qt,{children:ne?"Configure Chat":"LLM Provider Configuration"}),G(ho,{children:f?"Pick a Manufact cloud model or bring your own API key.":x?"Chat requires an LLM. You can chat for free if you have a Manufact account, or you can use your own API key (not sent to Manufact).":"Configure your LLM provider and API key to start chatting with the MCP server"})]}),_e("div",{className:"space-y-4",children:[x&&_e("button",{type:"button",onClick:x.onLoginClick,"data-testid":"chat-config-sign-in-card",className:"relative w-full cursor-pointer overflow-hidden rounded-2xl border-0 text-left transition-opacity hover:opacity-95 active:opacity-90",children:[G("div",{className:"absolute inset-0 bg-[#edf2ff] dark:bg-background","aria-hidden":!0}),G("div",{className:"absolute inset-0 dark:opacity-90",children:G(il,{className:"absolute inset-0 h-full w-full",colors:[...y],grainOverlay:w?.1:.15})}),_e("div",{className:"relative flex items-center justify-between gap-4 px-4 py-3.5",children:[_e("div",{className:"text-sm font-medium text-foreground",children:[G("p",{children:"Chat for free with a"}),_e("p",{className:"mt-1 flex items-center gap-1.5",children:[G(gg,{symbolSize:14,textClassName:"text-sm"}),"account"]})]}),G(E,{size:"sm",render:G("span",{"aria-hidden":"true"}),nativeButton:!1,tabIndex:-1,className:"pointer-events-none shrink-0",children:"Sign in"})]})]}),f&&G("div",{className:"flex justify-center",children:_e(ka,{selectedIndex:oe,onSelect:ae,idPrefix:tk,className:"w-fit",children:[G(Fr,{index:0,label:"Manufact cloud"}),G(Fr,{index:1,label:"API key"})]})}),_e("div",{className:C("space-y-2",f&&"!mt-2"),children:[G(nt,{children:"Provider"}),z?_e(kn,{value:Be,onValueChange:Y=>{let q=f?.models.find(M=>M.provider===Y);q&&f?.onModelChange(q.id)},children:[G($n,{className:"rounded-md",leading:Be?G(Kn,{provider:Sa(Be),className:"shrink-0"}):void 0,children:G(Un,{})}),G(Fn,{children:Oe.map(Y=>G(Wt,{value:Y,label:Ot(Sa(Y)),children:_e("div",{className:"flex items-center gap-2",children:[G(Kn,{provider:Sa(Y)}),G("span",{children:Ot(Sa(Y))})]})},Y))})]}):_e(kn,{value:n,onValueChange:Y=>a(Y),children:[G($n,{className:"rounded-md",leading:G(Kn,{provider:n,className:"shrink-0"}),children:G(Un,{})}),_e(Fn,{children:[G(Wt,{value:"openai",label:Ot("openai"),children:_e("div",{className:"flex items-center gap-2",children:[G(Kn,{provider:"openai"}),G("span",{children:Ot("openai")})]})}),G(Wt,{value:"anthropic",label:Ot("anthropic"),children:_e("div",{className:"flex items-center gap-2",children:[G(Kn,{provider:"anthropic"}),G("span",{children:Ot("anthropic")})]})}),G(Wt,{value:"google",label:Ot("google"),children:_e("div",{className:"flex items-center gap-2",children:[G(Kn,{provider:"google"}),G("span",{children:Ot("google")})]})}),G(Wt,{value:"ollama",label:Ot("ollama"),children:_e("div",{className:"flex items-center gap-2",children:[G(Kn,{provider:"ollama"}),G("span",{children:Ot("ollama")})]})}),G(Wt,{value:"openrouter",label:Ot("openrouter"),children:_e("div",{className:"flex items-center gap-2",children:[G(Kn,{provider:"openrouter"}),G("span",{children:Ot("openrouter")})]})}),G(Wt,{value:"openai-compatible",label:Ot("openai-compatible"),children:G("div",{className:"flex items-center gap-2",children:G("span",{children:Ot("openai-compatible")})})})]})]})]}),!z&&W&&_e("div",{className:"space-y-2",children:[G(nt,{children:"Base URL"}),G(Ge,{value:s,onChange:Y=>l(Y.target.value),placeholder:Pe,"data-testid":"chat-config-base-url-input"}),le&&G("p",{className:"text-xs text-muted-foreground",children:le})]}),!z&&_e("div",{className:"space-y-2",children:[G(nt,{children:H}),_e("div",{className:"relative",children:[G(Ge,{type:K?"text":"password",value:r,onChange:Y=>d(Y.target.value),placeholder:Te,className:"pr-10","data-testid":"chat-config-api-key-input"}),G(E,{type:"button",variant:"ghost",size:"sm",className:"absolute right-0 top-0 h-full px-3 py-2 hover:bg-transparent",onClick:()=>$(!K),children:K?G(qN,{className:"h-4 w-4 text-muted-foreground"}):G(jN,{className:"h-4 w-4 text-muted-foreground"})})]}),G("p",{className:"text-xs text-muted-foreground",children:de})]}),z?_e("div",{className:"space-y-2",children:[G(nt,{children:"Model"}),f?.isLoading?_e("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[G(Og,{className:"h-4 w-4 animate-spin"}),G("span",{children:"Loading models\u2026"})]}):tt.length>0?_e(Jo,{open:A,modal:!0,onOpenChange:_,children:[G(Go,{render:_e(E,{variant:"outline",role:"combobox","aria-expanded":A,className:"w-full justify-between rounded-md","data-testid":"chat-config-cloud-model-select",children:[G("span",{className:"inline-flex min-w-0 items-center gap-2 truncate",children:Re?_e(lk,{children:[G(Kn,{provider:Sa(Re.provider),className:"shrink-0"}),G("span",{className:"truncate",children:Ca(Re.name,Re.provider)})]}):"Select a model\u2026"}),G(_g,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]}),nativeButton:!0}),G(Yo,{className:"w-full p-0",align:"start",children:_e(hl,{children:[G(vl,{placeholder:"Search models\u2026",className:"h-9"}),_e(bl,{children:[G(yl,{children:"No model found."}),G(xl,{children:tt.map(Y=>_e(wl,{value:Y.id,keywords:[Y.name,Y.id,Y.provider],onSelect:q=>{f?.onModelChange(q),_(!1)},children:[Ca(Y.name,Y.provider),G(Lg,{className:C("ml-auto h-4 w-4",f?.selectedModelId===Y.id?"opacity-100":"opacity-0")})]},Y.id))})]})]})})]}):G("p",{className:"text-sm text-muted-foreground",children:"Cloud models unavailable \u2014 try again or use your own key."})]}):U&&_e("div",{className:"space-y-2",children:[G(nt,{children:"Model"}),L?_e("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[G(Og,{className:"h-4 w-4 animate-spin"}),G("span",{children:"Loading models..."})]}):R?G("div",{className:"text-sm text-destructive",children:R}):N.length>0?_e(Jo,{open:k,modal:!0,onOpenChange:S,children:[G(Go,{render:_e(E,{variant:"outline",role:"combobox","aria-expanded":k,className:"w-full justify-between rounded-md","data-testid":"chat-config-model-select",children:[G("span",{className:"truncate",children:o&&(N.find(Y=>Y.id===o)?.displayName||N.find(Y=>Y.id===o)?.id)||"Select a model..."}),G(_g,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]}),nativeButton:!0}),G(Yo,{className:"w-full p-0",align:"start",children:_e(hl,{children:[G(vl,{placeholder:"Search models...",className:"h-9"}),_e(bl,{children:[G(yl,{children:"No model found."}),G(xl,{children:N.map(Y=>_e(wl,{value:Y.id,keywords:Y.displayName,onSelect:q=>{i(q===o?"":q),S(!1)},children:[Y.displayName||Y.id,G(Lg,{className:C("ml-auto h-4 w-4",o===Y.id?"opacity-100":"opacity-0")})]},Y.id))})]})]})})]}):G(Ge,{value:o,onChange:Y=>i(Y.target.value),placeholder:"Enter model name manually","data-testid":"chat-config-model-input"})]}),_e("div",{className:"flex justify-between",children:[V&&G(E,{variant:"outline",onClick:h,children:"Clear Config"}),_e(E,{onClick:ce,disabled:Fe,className:V?"ml-auto":"","data-testid":"chat-config-save-button",children:[G(WN,{className:"h-4 w-4 mr-2"}),"Save Configuration"]})]})]})]})})}var eu="rounded-full bg-background/80 backdrop-blur-md supports-[backdrop-filter]:bg-background/60 dark:bg-zinc-950/75 dark:supports-[backdrop-filter]:bg-zinc-950/55",tu=C(eu,"w-fit"),Cl=C(eu,"h-9 gap-1.5 px-3");import{jsx as Mt,jsxs as lo}from"react/jsx-runtime";var mk="chat-view";function nu({llmConfig:e,hasMessages:t,configDialogOpen:n,onConfigDialogOpenChange:o,onClearChat:r,tempProvider:s,tempModel:a,tempApiKey:i,tempBaseUrl:d,onProviderChange:l,onModelChange:u,onApiKeyChange:h,onBaseUrlChange:c,onSaveConfig:m,onClearConfig:p,hideConfigButton:x,hostedInspector:f,freeTierInfo:b,managedCloudInfo:g,useManagedCloud:v,onSaveManagedCloud:y,showClearButton:w,clearButtonLabel:N,hideTitle:T,clearButtonHideIcon:L,clearButtonHideShortcut:P,clearButtonVariant:R,hideClearButton:D,onCopyChat:k,onExportChat:S,activeChatId:A,chatTitle:_,showViewToggle:K,viewIndex:$=0,onViewIndexChange:oe,elevatedHeader:ae}){return lo("div",{className:C("relative flex w-full items-center gap-2 overflow-visible",Lo,ae?"pointer-events-none absolute top-0 right-0 z-50":"absolute top-0 right-0 z-10"),children:[Mt("div",{className:C("flex min-w-0 flex-1 items-center",ae&&"pointer-events-auto"),children:!T&&Mt("h2",{className:C(_o,tu),children:A?Mt(va,{chatId:A,title:_??rr},A):rr})}),K&&oe&&Mt("div",{className:C("absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 overflow-visible px-1",ae&&"pointer-events-auto"),children:lo(ka,{selectedIndex:$,onSelect:oe,idPrefix:mk,className:"shrink-0 overflow-visible","data-testid":"chat-view-tabs",children:[Mt(Fr,{label:"Conv",index:0}),Mt(Fr,{label:"Raw",index:1})]})}),lo("div",{className:C("ml-auto flex shrink-0 items-center gap-2",ae&&"pointer-events-auto"),children:[!D&&t&&lo("div",{className:"flex items-center gap-1",children:[k&&lo(E,{"data-testid":"chat-copy-button",variant:"ghost",size:"sm",className:Cl,onClick:k,children:[Mt(ck,{className:"h-4 w-4"}),Mt("span",{className:"hidden sm:inline",children:"Copy"})]}),S&&lo(Cr,{children:[Mt(Ho,{render:lo(E,{"data-testid":"chat-export-button",variant:"ghost",size:"sm",className:Cl,children:[Mt(dk,{className:"h-4 w-4"}),Mt("span",{className:"hidden sm:inline",children:"Export"})]}),nativeButton:!0}),lo(Nr,{align:"end",children:[Mt(Nn,{"data-testid":"chat-export-json",onClick:()=>S("json"),children:"Export as JSON"}),Mt(Nn,{"data-testid":"chat-export-markdown",onClick:()=>S("markdown"),children:"Export as Markdown"})]})]}),Mt("div",{className:"w-px h-4 bg-border mx-1"}),lo(ke,{children:[Mt(we,{render:lo(E,{variant:R??"default",size:"default",className:`p-2 cursor-pointer ${P?"sm:px-3":"sm:pr-1 sm:pl-3"}`,onClick:r,children:[!L&&Mt(uk,{className:"h-4 w-4 sm:mr-2"}),Mt("span",{className:"hidden sm:inline",children:N??"New Chat"}),!P&&Mt("span",{className:"hidden sm:inline text-[12px] border text-zinc-300 p-1 rounded-full border-zinc-300 dark:text-zinc-600 dark:border-zinc-500 ml-2",children:"\u2318O"})]}),nativeButton:!0}),Mt(Ce,{children:Mt("p",{children:N??"New Chat"})})]})]}),(!x||f||b||g)&&Mt(Ta,{open:n,onOpenChange:o,tempProvider:s,tempModel:a,tempApiKey:i,tempBaseUrl:d,onProviderChange:l,onModelChange:u,onApiKeyChange:h,onBaseUrlChange:c,onSave:m,onClear:p,showClearButton:w??(!!e&&!b&&!g),buttonLabel:e?"Change API Key":"Configure API Key",hostedInspector:f,freeTierInfo:b,managedCloudInfo:g,useManagedCloud:v,onSaveManagedCloud:y})]})]})}import{ArrowUp as Gk,Loader2 as Yk}from"lucide-react";import{Image as hk,Paperclip as vk,X as bk}from"lucide-react";import{useRef as yk}from"react";import{Wrench as pk}from"lucide-react";import{useCallback as Bg,useMemo as fk,useState as gk}from"react";import{jsx as Mo,jsxs as ir}from"react/jsx-runtime";function Hg({tools:e,disabledTools:t,onDisabledToolsChange:n,disabled:o}){let[r,s]=gk(!1),a=e.length-t.size,i=t.size===0,d=t.size>0&&t.size<e.length,l=Bg(c=>{let m=new Set(t);m.has(c)?m.delete(c):m.add(c),n(m)},[t,n]),u=Bg(()=>{n(i?new Set(e.map(c=>c.name)):new Set)},[i,e,n]),h=fk(()=>[...e].sort((c,m)=>c.name.localeCompare(m.name)),[e]);return e.length===0?null:ir(Jo,{open:r,onOpenChange:s,children:[ir(ke,{children:[Mo(we,{render:Mo(Go,{render:ir(E,{variant:"ghost",size:"sm",disabled:o,className:C("h-auto gap-1 rounded-full px-2 py-2",d?"text-amber-500 dark:text-amber-400":"text-muted-foreground hover:text-foreground"),type:"button","data-testid":"chat-tool-selector",children:[Mo(pk,{className:"h-4 w-4 shrink-0"}),d&&Mo("span",{className:"flex h-3.5 min-w-3.5 items-center justify-center rounded-full bg-amber-500 px-1 text-[9px] font-bold leading-none text-white",children:a})]}),nativeButton:!0}),nativeButton:!0}),Mo(Ce,{side:"top",children:ir("p",{children:["Tools (",a,"/",e.length,")"]})})]}),ir(Yo,{className:"w-72 gap-0 p-0",align:"start",side:"top",sideOffset:8,children:[ir("div",{className:"flex items-center justify-between px-3 py-2 border-b",children:[ir("span",{className:"text-xs font-medium text-muted-foreground",children:["Allowed Tools (",a,"/",e.length,")"]}),Mo(E,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:u,type:"button",children:i?"Disable All":"Enable All"})]}),Mo("div",{className:"max-h-64 overflow-y-auto",children:h.map(c=>{let m=!t.has(c.name);return ir("button",{type:"button",className:"flex items-center gap-2.5 w-full px-3 py-1.5 text-left hover:bg-accent/50 transition-colors cursor-pointer",onClick:()=>l(c.name),children:[Mo(ma,{checked:m,className:"pointer-events-none",tabIndex:-1}),Mo("span",{className:"min-w-0 flex-1 truncate text-sm font-mono",children:c.name})]},c.name)})})]})]})}import{jsx as _n,jsxs as Pa}from"react/jsx-runtime";function Ug({inputValue:e,isConnected:t,isLoading:n,textareaRef:o,attachments:r,placeholder:s="Ask a question",className:a,showAttachButton:i=!0,tools:d,disabledTools:l,onDisabledToolsChange:u,onInputChange:h,onKeyDown:c,onKeyUp:m,onClick:p,onAttachmentAdd:x,onAttachmentRemove:f,inlineControls:b,trailingControls:g}){let v=pt(),y=yk(null),w=T=>{let L=T.target.files;if(L&&L.length>0)for(let P=0;P<L.length;P++)x(L[P]);y.current&&(y.current.value="")},N=r.length>0;return Pa("div",{className:"relative w-full",children:[N&&_n("div",{className:"absolute top-0 left-0 right-0 z-20 p-3 flex gap-2 flex-wrap",children:r.map((T,L)=>Pa("div",{className:"relative group bg-zinc-100/90 dark:bg-zinc-900/90 backdrop-blur-sm rounded-lg p-2 flex items-center gap-2 border border-zinc-200 dark:border-zinc-700","data-testid":`chat-attachment-${L}`,children:[_n(hk,{className:"h-4 w-4 text-muted-foreground shrink-0"}),Pa("div",{className:"flex flex-col min-w-0",children:[_n("span",{className:"text-xs font-medium truncate max-w-[150px]",children:T.name||"Image"}),T.size&&_n("span",{className:"text-xs text-muted-foreground",children:Hp(T.size)})]}),_n("button",{onClick:()=>f(L),className:"shrink-0 p-1 rounded-full hover:bg-zinc-200 dark:hover:bg-zinc-800 transition-colors",title:"Remove attachment",type:"button","data-testid":`chat-attachment-remove-${L}`,children:_n(bk,{className:"h-3 w-3"})})]},L))}),_n(to,{ref:o,value:e,onChange:T=>h(T.target.value),onKeyDown:c,onKeyUp:m,onClick:p,placeholder:t?s:"Server not connected",className:C("p-4 min-h-[150px] max-h-[300px]",v.container,N&&"pt-20",a),disabled:!t||n,"data-testid":"chat-input"}),_n("input",{ref:y,type:"file",accept:"image/*",multiple:!0,onChange:w,className:"hidden","aria-label":"Upload images"}),Pa("div",{className:"absolute inset-x-0 bottom-0 flex items-center justify-between gap-2 p-3",children:[Pa("div",{className:"flex min-w-0 flex-1 items-center gap-1",children:[i&&_n(E,{variant:"ghost",size:"sm",onClick:()=>y.current?.click(),disabled:!t||n,className:"h-auto w-auto aspect-square rounded-full p-2 text-muted-foreground hover:text-foreground",title:"Attach images",type:"button","data-testid":"chat-attach-button",children:_n(vk,{className:"h-4 w-4"})}),d&&d.length>0&&l&&u&&_n(Hg,{tools:d,disabledTools:l,onDisabledToolsChange:u,disabled:!t||n}),b]}),g?_n("div",{className:"flex shrink-0 items-center gap-1.5",children:g}):null]})]})}import{MessageSquare as xk,X as wk}from"lucide-react";import{jsx as Ra,jsxs as Ck}from"react/jsx-runtime";function Fg({promptResults:e,onDeletePromptResult:t}){return Ra("div",{className:"absolute top-4 left-4 right-4 flex gap-2 overflow-x-auto z-20 flex-nowrap",style:{scrollbarWidth:"none",msOverflowStyle:"none"},children:e.map(({promptName:n},o)=>Ck(E,{type:"button",className:"flex items-center gap-2 bg-zinc-200 text-zinc-700 dark:text-zinc-300 text-[10px] px-1.5 py-0.5 dark:bg-zinc-700 rounded-lg border border-zinc-200 dark:border-zinc-300 font-medium hover:bg-zinc-300 dark:hover:bg-zinc-600",children:[Ra(xk,{className:"h-3.5 w-3.5 shrink-0"}),Ra("span",{className:"truncate",title:n,children:n}),Ra("span",{className:"ml-1 h-4 w-4 rounded-full bg-zinc-400 dark:bg-zinc-600 hover:bg-zinc-500 dark:hover:bg-zinc-500 flex items-center justify-center cursor-pointer shrink-0 transition-colors",onClick:r=>{r.stopPropagation(),t(o)},title:"Remove prompt",role:"button",tabIndex:0,children:Ra(wk,{className:"h-2.5 w-2.5 text-white"})})]},o))})}import{MessageSquare as Nk}from"lucide-react";import{useEffect as kk}from"react";import{jsx as lr,jsxs as Nl}from"react/jsx-runtime";function $g({isOpen:e,focusedIndex:t,prompts:n,selectedPrompt:o,onPromptSelect:r}){return e?(kk(()=>{if(t>=0){let s=document.getElementById(`prompt-${t}`);s&&s.scrollIntoView({behavior:"smooth",block:"nearest"})}},[t]),lr("div",{className:"absolute bottom-full left-0 right-0 max-w-3xl w-full max-h-[300px] overflow-y-auto rounded-lg border border-zinc-200 dark:border-zinc-800 bg-white dark:bg-zinc-900 shadow-lg z-30 flex flex-col gap-2 mb-1","data-testid":"chat-prompts-dropdown",children:Nl("div",{className:"p-2",children:[lr("div",{className:"text-xs font-medium text-zinc-900 dark:text-zinc-100 mb-2",children:"Prompts"}),n.map((s,a)=>Nl(ke,{children:[lr(we,{render:Nl(E,{id:`prompt-${a}`,type:"button",variant:"ghost",className:C("w-full flex items-center px-3 py-2 rounded-md hover:bg-zinc-200 dark:hover:bg-zinc-700 transition-colors text-left justify-start",t===a&&"bg-zinc-200 dark:bg-zinc-700"),onClick:()=>r(s),"data-testid":`chat-prompt-option-${a}`,children:[lr("div",{className:"flex items-center justify-center shrink-0",children:lr(Nk,{className:"h-4 w-4 text-zinc-600 dark:text-zinc-400"})}),lr("div",{className:"flex-1 min-w-0",children:Nl("div",{className:"text-sm font-medium text-zinc-900 dark:text-zinc-100 flex items-center gap-2",children:[s.name,o?.name===s.name&&lr(Kt,{className:"size-3 text-zinc-600 dark:text-zinc-400"})]})})]}),nativeButton:!0}),lr(Ce,{children:s.description})]},a))]})})):null}import{motion as $k}from"motion/react";import{useMemo as nh,useState as oh}from"react";import{ExternalLink as Fk}from"lucide-react";import{toast as rh}from"sonner";import{forwardRef as Dk,useCallback as un,useEffect as Jn,useId as Lk,useMemo as Ia,useRef as Io,useState as Vr}from"react";import{AnimatePresence as Rs,motion as co}from"motion/react";import{RadioGroup as _k}from"@base-ui/react/radio-group";import{Radio as Ok}from"@base-ui/react/radio";import{CheckboxGroup as zk}from"@base-ui/react/checkbox-group";import{Checkbox as Bk}from"@base-ui/react/checkbox";import{Field as iu}from"@base-ui/react/field";import{useEffect as au,useLayoutEffect as Sk,useRef as ou,useState as Tk}from"react";import{AnimatePresence as Pk,motion as Rk}from"motion/react";import{jsx as jg}from"react/jsx-runtime";var Mk=typeof window<"u"?Sk:au,Ts=se.moderate,Ma=.07,Ik=(Ts.duration+Ma)*1e3+80,Ek=Ts.duration*1e3+80;function ru(e,t){let n=t.filter(s=>s.start>=e.start&&s.end<=e.end).sort((s,a)=>s.start-a.start);if(n.length!==2)return null;let[o,r]=n;return r.start===o.end+2?{up:o,lo:r,gap:o.end+1}:null}function Ak(e,t,n,o){let r=n[e],s=n[t];if(!r||!s)return null;if(o==="y")return{top:r.top,left:Math.min(r.left,s.left),width:Math.max(r.width,s.width),height:s.top+s.height-r.top};let a=Math.min(r.left,s.left),i=Math.max(r.left+r.width,s.left+s.width);return{top:Math.min(r.top,s.top),left:a,width:i-a,height:Math.max(r.height,s.height)}}function qg(e,t){return t==="y"?e.top+e.height/2:e.left+e.width/2}function kl(e,t){return t==="y"?[e,e,0,0]:[e,0,0,e]}function cr(e,t){return t==="y"?[0,0,e,e]:[0,e,e,0]}function su(e){return[e,e,e,e]}function Vg(e,t,n,o,r){let s=qg(n,o);if(o==="y"){let i=t.top+t.height;e.height=s-e.top,e.radii=kl(r,o),e.instant=!0,t.top=s,t.height=i-s,t.radii=cr(r,o),t.instant=!0,t.enterFrom={top:s,left:t.left,width:t.width,height:i-s,radii:cr(r,o)};return}let a=t.left+t.width;e.width=s-e.left,e.radii=kl(r,o),e.instant=!0,t.left=s,t.width=a-s,t.radii=cr(r,o),t.instant=!0,t.enterFrom={top:t.top,left:s,width:a-s,height:t.height,radii:cr(r,o)}}function Wg(e,t,n,o="y"){let[r,s]=Tk([]),a=ou([]),i=ou(0),d=ou(new Map),l=e.map(c=>`${c.id}:${c.start}-${c.end}`).join("|");Mk(()=>{let c=a.current,m=e,p=[];for(let f of m){let b=ru(f,c);b&&(f.id===b.up.id||f.id===b.lo.id)&&p.push({tid:++i.current,kind:"merge",survivorId:f.id,otherId:f.id===b.up.id?b.lo.id:b.up.id,gapIndex:b.gap,phase:"converge"})}for(let f of c){let b=ru(f,m);b&&p.push({tid:++i.current,kind:"split",survivorId:b.up.id,otherId:b.lo.id,gapIndex:b.gap,phase:"splitIn"})}a.current=m.map(f=>({...f}));for(let f of p)d.current.set(f.tid,setTimeout(()=>{d.current.delete(f.tid),s(b=>b.some(g=>g.tid===f.tid)?b.flatMap(g=>g.tid!==f.tid?[g]:g.kind==="merge"?[{...g,phase:"commit"}]:[]):b)},f.kind==="merge"?Ik:Ek));let x=f=>f.kind==="merge"?m.some(b=>b.id===f.survivorId&&f.gapIndex>b.start&&f.gapIndex<b.end):m.some(b=>b.id===f.survivorId&&b.end===f.gapIndex-1)&&m.some(b=>b.id===f.otherId&&b.start===f.gapIndex+1);s(f=>{for(let b of f){if(x(b))continue;let g=d.current.get(b.tid);g!==void 0&&(clearTimeout(g),d.current.delete(b.tid))}return[...f.filter(x),...p]})},[l]),au(()=>{let c=d.current;return()=>c.forEach(clearTimeout)},[]),au(()=>{r.some(c=>c.phase==="splitIn"||c.phase==="commit")&&s(c=>c.flatMap(m=>m.phase==="commit"?[]:[{...m,phase:m.phase==="splitIn"?"diverge":m.phase}]))},[r]);let u=[];for(let c of e){let m=Ak(c.start,c.end,t,o);m&&u.push({key:`sel-${c.id}`,...m,radii:su(n),instant:!1,exitInstant:!1,delayCorners:!1})}let h=new Map(u.map(c=>[c.key,c]));for(let c of r){let m=t[c.gapIndex],p=h.get(`sel-${c.survivorId}`);if(!m||!p)continue;let x=qg(m,o);if(c.kind==="merge"){if(c.phase==="commit"){p.instant=!0,o==="y"?u.push({key:`sel-${c.otherId}`,top:x,left:p.left,width:p.width,height:p.top+p.height-x,radii:cr(n,o),instant:!0,exitInstant:!0,delayCorners:!1,opacity:0}):u.push({key:`sel-${c.otherId}`,top:p.top,left:x,width:p.left+p.width-x,height:p.height,radii:cr(n,o),instant:!0,exitInstant:!0,delayCorners:!1,opacity:0});continue}let f=Math.min(Ma+.03,Math.max(Ma,Ma+x/Math.max(o==="y"?m.height:m.width,1)*.002));if(o==="y"){let b=p.top+p.height;p.height=x-p.top,p.radii=kl(n,o),p.delayCorners=!0,p.cornerDelay=f,u.push({key:`sel-${c.otherId}`,top:x,left:p.left,width:p.width,height:b-x,radii:cr(n,o),enterFrom:{top:x,left:p.left,width:p.width,height:b-x,radii:su(n)},instant:!1,exitInstant:!0,delayCorners:!0,cornerDelay:f})}else{let b=p.left+p.width;p.width=x-p.left,p.radii=kl(n,o),p.delayCorners=!0,p.cornerDelay=f,u.push({key:`sel-${c.otherId}`,top:p.top,left:x,width:b-x,height:p.height,radii:cr(n,o),enterFrom:{top:p.top,left:x,width:b-x,height:p.height,radii:su(n)},instant:!1,exitInstant:!0,delayCorners:!0,cornerDelay:f})}}else if(c.phase==="splitIn"){let f=h.get(`sel-${c.otherId}`);if(!f)continue;Vg(p,f,m,o,n)}}for(let c of a.current){let m=ru(c,e),p=m&&t[m.gap];if(!m||!p)continue;let x=h.get(`sel-${m.up.id}`),f=h.get(`sel-${m.lo.id}`);!x||!f||Vg(x,f,p,o,n)}return u}function Kg({blocks:e,dimmed:t}){return jg(Pk,{children:e.map(n=>{let o=n.delayCorners?{...Ts,delay:n.cornerDelay??Ma}:Ts,r=n.opacity??(t?.8:1);return jg(Rk.div,{"aria-hidden":!0,className:"absolute bg-active pointer-events-none",initial:n.enterFrom?{opacity:r,top:n.enterFrom.top,left:n.enterFrom.left,width:n.enterFrom.width,height:n.enterFrom.height,borderTopLeftRadius:n.enterFrom.radii[0],borderTopRightRadius:n.enterFrom.radii[1],borderBottomRightRadius:n.enterFrom.radii[2],borderBottomLeftRadius:n.enterFrom.radii[3]}:!1,animate:{top:n.top,left:n.left,width:n.width,height:n.height,borderTopLeftRadius:n.radii[0],borderTopRightRadius:n.radii[1],borderBottomRightRadius:n.radii[2],borderBottomLeftRadius:n.radii[3],opacity:r},exit:{opacity:0,transition:n.exitInstant?{duration:0}:Ts.exit},transition:n.instant?{duration:0}:{...Ts,borderTopLeftRadius:o,borderTopRightRadius:o,borderBottomRightRadius:o,borderBottomLeftRadius:o,opacity:{duration:.08}}},n.key)})})}import{Fragment as Gg,jsx as fe,jsxs as Vt}from"react/jsx-runtime";function Hk(e,t){return e.id??`q-${t}`}function Sl(e,t){return e.id??`o-${t}`}var Ps=[],lu=Dk(function({questions:t,currentIndex:n,defaultCurrentIndex:o=0,onCurrentIndexChange:r,answers:s,defaultAnswers:a,onAnswersChange:i,onComplete:d,onSkip:l,skipLabel:u="Skip",intro:h,onCancel:c,cancelLabel:m="Cancel",footerLeading:p,className:x,...f},b){let[g,v]=Vr(o),y=n!==void 0,w=y?n:g,N=un(I=>{y||v(I),r?.(I)},[y,r]),[T,L]=Vr(a??{}),P=s!==void 0,R=P?s:T,D=Io(R);Jn(()=>{D.current=R},[R]);let k=un(I=>{let Z=I(D.current);return D.current=Z,P||L(Z),i?.(Z),Z},[P,i]),S=pt(),A=br("arrow-left"),_=br("arrow-right"),K=Ia(()=>function(Z){return fe(A,{...Z,className:C(Z.className,"hidden sm:block")})},[A]),$=Ia(()=>function(Z){return fe(_,{...Z,className:C(Z.className,"hidden sm:block")})},[_]),[oe]=Vr(()=>{if(typeof navigator>"u")return!1;let I=navigator,Z=I.userAgentData?.platform||I.platform||"";return/mac/i.test(Z)}),ae=Lk(),ie=t.length,ne=Math.max(0,Math.min(w,Math.max(0,ie-1))),z=t[ne],O=z?Hk(z,ne):"",W=R[O],j=!!z?.multiSelect,U=z?.skippable!==!1,H=!!z?.freeText,Te=z?.freeTextMultiline!==!1,Pe=!H&&!!z?.allowOther,le=Ia(()=>W?.selectedIds??[],[W]),de=W?.otherText??"",De=z?.options??[],Re=Pe?De.length:-1,Oe=De.length+(Pe?1:0),Be=Io(null),tt=!!z;Jn(()=>{if(!tt)return;let I=Be.current;if(I)return Ps.push(I),()=>{let Z=Ps.indexOf(I);Z!==-1&&Ps.splice(Z,1)}},[tt]);let V=Io(null),ce=Io(null),Fe=Io(0),Y=Io(new Map),{activeIndex:q,setActiveIndex:M,itemRects:Ne,sessionRef:gt,handlers:qe,registerItem:ut,measureItems:Bt}=xr(V);Jn(()=>{Bt()},[Bt,O,Oe,S]);let[It,wn]=Vr(!1);Jn(()=>{wn(!1)},[O]),Jn(()=>{let I=ce.current;if(!I)return;I.style.height="0px",I.style.height=`${I.scrollHeight}px`;let Z=parseFloat(window.getComputedStyle(I).lineHeight)||18;wn(I.scrollHeight>Z*1.5),Bt()},[de,Bt,O]),Jn(()=>{H&&ce.current?.focus({preventScroll:!0})},[H,O]);let mn=Io(null),[mo,On]=Vr("auto");Jn(()=>{let I=mn.current;if(!I)return;let Z=()=>On(I.offsetHeight);Z();let Se=new ResizeObserver(Z);return Se.observe(I),()=>Se.disconnect()},[]);let[Nt,at]=Vr(null),[re,pe]=Vr(null);Jn(()=>{M(null),at(null),pe(null)},[ne,M]);let Ze=Io(!1),We=un(()=>{V.current?.contains(document.activeElement)&&(Ze.current=!0)},[]);Jn(()=>{if(!Ze.current)return;Ze.current=!1,V.current?.querySelector('[data-proximity-index="0"]')?.focus()},[ne]);let J=un(I=>{ne>=ie-1?d?.(I):(We(),N(ne+1))},[ne,ie,d,N,We]),$e=un(I=>{if(!z)return;let Z=D.current[O]?.otherText,Se=k(ct=>({...ct,[O]:{questionId:O,selectedIds:[I],otherText:Z||void 0,skipped:!1}}));J(Se)},[z,O,k,J]),Q=un(I=>{z&&k(Z=>{let Se=Z[O],ct=new Set(Se?.selectedIds??[]);return ct.has(I)?ct.delete(I):ct.add(I),{...Z,[O]:{questionId:O,selectedIds:Array.from(ct),otherText:Se?.otherText,skipped:!1}}})},[z,O,k]),ee=un(I=>{z&&k(Z=>({...Z,[O]:{questionId:O,selectedIds:I,otherText:Z[O]?.otherText,skipped:!1}}))},[z,O,k]),me=un(I=>{z&&(pe(null),k(Z=>({...Z,[O]:{questionId:O,selectedIds:Z[O]?.selectedIds??[],otherText:I,skipped:!1}})))},[z,O,k]),xe=un(()=>{if(!z)return;let I=(D.current[O]?.otherText??"").trim();if(!I)return;if(z.freeText&&z.freeTextValidate){let Se=z.freeTextValidate(I);if(Se){pe(Se);return}}pe(null);let Z=k(Se=>({...Se,[O]:{questionId:O,selectedIds:Se[O]?.selectedIds??[],otherText:I,skipped:!1}}));J(Z)},[z,O,k,J]),he=un(()=>{if(!z)return;let I=k(Z=>({...Z,[O]:{questionId:O,selectedIds:Z[O]?.selectedIds??[],otherText:Z[O]?.otherText,skipped:!0}}));l?.(O,ne),J(I)},[z,O,k,l,ne,J]),et=un(()=>{c?.()},[c]),ht=un(()=>{J(R)},[J,R]),Yt=un(()=>{ne>0&&(We(),N(ne-1))},[ne,N,We]);Jn(()=>{if(!z)return;let I=Z=>{if(Z.metaKey||Z.ctrlKey||Z.altKey)return;let Se=Z.target;if(!Se)return;let ct=Se.tagName;if(ct==="INPUT"||ct==="TEXTAREA"||Se.isContentEditable)return;let St=Be.current;if(!St||!St.contains(Se)&&(Ps.some(Bn=>Bn!==St&&Bn.contains(Se))||Ps[Ps.length-1]!==St))return;let dt=Z.key;if(dt<"1"||dt>"9")return;let bt=parseInt(dt,10)-1;if(bt>=0&&bt<De.length){Z.preventDefault();let Bn=Sl(De[bt],bt);j?Q(Bn):$e(Bn)}else bt===De.length&&Pe&&(Z.preventDefault(),ce.current?.focus())};return document.addEventListener("keydown",I),()=>document.removeEventListener("keydown",I)},[z,De,j,Pe,$e,Q]);let Dt=I=>{V.current?.querySelector(`[data-proximity-index="${I}"]`)?.focus()},vt=un(I=>{M(I),Pe&&I===Re?ce.current?.focus():Dt(I)},[Pe,Re,M]),Kr=I=>{let Z=I.target,Se=Z.tagName==="INPUT"||Z.tagName==="TEXTAREA"||Z.isContentEditable;if(Se&&I.key!=="ArrowDown"&&I.key!=="ArrowUp")return;if(Se&&(I.key==="ArrowUp"||I.key==="ArrowDown")&&Z.tagName==="TEXTAREA"){let St=Z;if(I.key==="ArrowUp"&&St.selectionStart>0||I.key==="ArrowDown"&&St.selectionEnd<St.value.length)return}let ct=I.preventBaseUIHandler;if(I.key==="ArrowLeft"||I.key==="ArrowRight"){I.preventDefault(),I.stopPropagation(),ct?.(),I.key==="ArrowLeft"?ne>0&&Yt():U&&ie>1&&he();return}if(Oe!==0&&(I.key==="ArrowDown"||I.key==="ArrowUp"||I.key==="Home"||I.key==="End")){I.preventDefault(),I.stopPropagation(),ct?.();let St;if(I.key==="Home")St=0;else if(I.key==="End")St=Oe-1;else{let dt=Se?Re:q??-1;St=I.key==="ArrowDown"?dt+1:dt-1,St=(St+Oe)%Oe}vt(St)}},po=I=>{if(I.key!=="Enter"||!(oe?I.metaKey:I.ctrlKey)||!(j||H))return;if(I.preventDefault(),H){de.trim().length>0&&xe();return}(le.length>0||de.trim().length>0)&&ht()};if(!z)return fe("div",{ref:b,className:C("w-full max-w-[520px] p-5 bg-card border border-border",S.container,x),...f,children:fe("p",{className:"text-[13px] text-muted-foreground",children:"No questions."})});let kt=q!==null?Ne[q]:null,He=Nt!==null&&!(Pe&&Nt===Re)?Ne[Nt]:null,fo=Ia(()=>{let I=new Set;return De.forEach((Z,Se)=>{le.includes(Sl(Z,Se))&&I.add(Se)}),Pe&&de.length>0&&I.add(Re),I},[De,le,Pe,de,Re]),Ul=Ia(()=>{let I=[],Z=[...fo].sort((dt,bt)=>dt-bt);for(let dt of Z){let bt=I[I.length-1];bt&&dt===bt.end+1?bt.end=dt:I.push({start:dt,end:dt})}let Se=new Set,ct=new Map,St=I.map(dt=>{let bt=null;for(let pn=dt.start;pn<=dt.end;pn++){let Xn=Y.current.get(pn);if(Xn!==void 0&&!Se.has(Xn)){bt=Xn;break}}let Bn=bt??++Fe.current;Se.add(Bn);for(let pn=dt.start;pn<=dt.end;pn++)ct.set(pn,Bn);return{...dt,id:Bn}});return Y.current=ct,St},[fo]),$a=q!==null&&!fo.has(q),Fl=Wg(Ul,Ne,S.bgRadius),zn=ie>1&&ne>0,Qn=c!=null,Ye=!Qn&&ie>1&&U,nn=j||H,fr=zn||Ye||nn||Qn||p!=null,Cn=De.findIndex((I,Z)=>le.includes(Sl(I,Z))),gr=Vt("div",{ref:V,role:j?"group":"radiogroup","aria-labelledby":`${ae}-${O}-title`,onMouseEnter:qe.onMouseEnter,onMouseMove:qe.onMouseMove,onMouseLeave:qe.onMouseLeave,onFocus:I=>{let Z=I.target.closest("[data-proximity-index]")?.getAttribute("data-proximity-index");if(Z!=null){let Se=Number(Z);M(Se),at(I.target.matches(":focus-visible")?Se:null)}},onBlur:I=>{V.current?.contains(I.relatedTarget)||(at(null),M(null))},onKeyDown:Kr,className:"relative flex flex-col gap-0.5 -mx-3",children:[fe(Rs,{children:(()=>{if(!Pe)return null;let I=Ne[Re],Z=Nt===Re&&de.length===0;return!I||!Z?null:fe(co.div,{"aria-hidden":!0,className:C("absolute pointer-events-none bg-card ring-1 ring-inset ring-border",S.bg),initial:{opacity:0,top:I.top,left:I.left,width:I.width,height:I.height},animate:{opacity:1,top:I.top,left:I.left,width:I.width,height:I.height},exit:{opacity:0,transition:se.fast.exit},transition:{...se.fast,opacity:{duration:.08}}},"other-input")})()}),fe(Rs,{children:kt&&fe(co.div,{"aria-hidden":!0,className:C("absolute pointer-events-none bg-hover",S.bg),initial:{opacity:0,top:kt.top,left:kt.left,width:kt.width,height:kt.height},animate:{opacity:1,top:kt.top,left:kt.left,width:kt.width,height:kt.height},exit:{opacity:0,transition:se.fast.exit},transition:{...se.fast,opacity:{duration:.08}}},`hover-${gt.current}`)}),fe(Kg,{blocks:Fl,dimmed:$a}),fe(Rs,{children:He&&fe(co.div,{"aria-hidden":!0,className:C("absolute pointer-events-none border border-[color:var(--focus-ring,#6B97FF)] z-20",S.focusRing),initial:{opacity:0,top:He.top-2,left:He.left-2,width:He.width+4,height:He.height+4},animate:{opacity:1,top:He.top-2,left:He.left-2,width:He.width+4,height:He.height+4},exit:{opacity:0,transition:se.fast.exit},transition:{...se.fast,opacity:{duration:.08}}})}),De.map((I,Z)=>{let Se=Sl(I,Z),ct=le.includes(Se),dt=!j&&q===Z;return fe(Jg,{index:Z,registerItem:ut,role:j?"checkbox":"radio",isSelected:ct,tabIndex:Z===Cn||Cn===-1&&Z===0?0:-1,onClick:()=>j?Q(Se):$e(Se),onKeyDown:bt=>{(bt.key===" "||bt.key==="Enter")&&!bt.metaKey&&!bt.ctrlKey&&(bt.preventDefault(),j?Q(Se):$e(Se))},shape:S,"aria-checked":ct,chipContent:Z+1,chipFilled:ct,isMulti:j,showArrow:dt,bodyLayout:z.layout==="stacked"?"stacked":"inline",topAlign:z.layout==="stacked",chipPosition:z.chipPosition??"right",arrowIcon:fe(_,{size:14,strokeWidth:2,className:"h-3.5 w-3.5"}),hiddenControl:j?fe(Bk.Root,{name:Se,className:"sr-only",tabIndex:-1,"aria-hidden":!0}):fe(Ok.Root,{value:Se,className:"sr-only",tabIndex:-1,"aria-hidden":!0}),children:z.layout==="stacked"?Vt(Gg,{children:[Vt("span",{className:"inline-grid",children:[fe("span",{className:"col-start-1 row-start-1 invisible",style:{fontVariationSettings:yt.semibold},"aria-hidden":"true",children:I.title}),fe("span",{className:"col-start-1 row-start-1 text-foreground transition-[color,font-variation-settings] duration-80",style:{fontVariationSettings:ct?yt.semibold:yt.medium},children:I.title})]}),I.description&&fe("span",{className:"text-[12px] text-muted-foreground leading-snug",children:I.description})]}):Vt("span",{children:[Vt("span",{className:"inline-grid",children:[fe("span",{className:"col-start-1 row-start-1 invisible",style:{fontVariationSettings:yt.semibold},"aria-hidden":"true",children:I.title}),fe("span",{className:"col-start-1 row-start-1 text-foreground transition-[color,font-variation-settings] duration-80",style:{fontVariationSettings:ct?yt.semibold:yt.medium},children:I.title})]}),I.description&&Vt(Gg,{children:[" ",fe("span",{className:"text-muted-foreground",children:I.description})]})]})},Se)}),Pe&&fe(Jg,{index:Re,registerItem:ut,role:null,isSelected:de.length>0,tabIndex:-1,onClick:()=>ce.current?.focus(),shape:S,chipContent:Re+1,chipFilled:de.length>0,isMulti:j,topAlign:It,chipPosition:z.chipPosition??"right",ariaLabel:z.otherPlaceholder??"Describe in your own words",showArrow:!j&&(Nt===Re||q===Re)&&de.trim().length>0,arrowIcon:fe(_,{size:14,strokeWidth:2,className:"h-3.5 w-3.5"}),onArrowClick:!j&&de.trim().length>0?xe:void 0,children:fe("span",{className:"inline-grid w-full",children:fe("textarea",{ref:ce,rows:1,value:de,placeholder:z.otherPlaceholder??"Describe in your own words\u2026","aria-label":z.otherPlaceholder??"Describe in your own words",onChange:I=>me(I.target.value),onKeyDown:I=>{I.key==="Enter"&&(I.shiftKey||j||(I.preventDefault(),xe()))},onClick:I=>I.stopPropagation(),className:C("col-start-1 row-start-1 block w-full bg-transparent border-0 p-0 m-0 outline-none resize-none overflow-hidden text-[13px] leading-snug text-foreground placeholder:text-muted-foreground"),style:{fontVariationSettings:yt.medium}})})})]});return Vt("div",{ref:I=>{Be.current=I,typeof b=="function"?b(I):b&&(b.current=I)},className:C("relative w-full max-w-[520px] overflow-hidden bg-card border border-border",S.container,x),...f,onKeyDown:I=>{f.onKeyDown?.(I),po(I)},children:[fe("div",{className:"flex items-center px-4 sm:px-5 pt-4 sm:pt-5 pb-2 text-[12px] text-muted-foreground",children:Vt("span",{children:["Question ",ne+1," of ",ie]})}),h!=null&&fe("div",{className:"px-4 sm:px-5 pb-3 text-[13px] leading-snug text-muted-foreground",children:h}),Vt(iu.Root,{invalid:re!==null,className:"contents",children:[fe(co.div,{animate:{height:mo},initial:!1,transition:se.slow,className:"overflow-hidden",children:fe("div",{ref:mn,className:C("px-4 sm:px-5",fr?"pb-1":"pb-2.5 sm:pb-3"),children:Vt("div",{className:"flex flex-col gap-2",children:[fe("h3",{id:`${ae}-${O}-title`,className:"text-[16px] text-foreground leading-snug",style:{fontVariationSettings:yt.semibold},children:z.title}),H?fe("div",{onClick:()=>ce.current?.focus(),className:C("relative mt-1 -mx-3 px-3 py-2.5 cursor-text transition-colors",Te?"min-h-[76px]":"min-h-10",S.bg,de.length>0?"bg-active":"hover:bg-hover focus-within:bg-card focus-within:ring-1 focus-within:ring-inset focus-within:ring-border"),children:fe(iu.Control,{value:de,onValueChange:me,render:fe("textarea",{ref:ce,rows:1,placeholder:z.freeTextPlaceholder??"Type your answer\u2026","aria-labelledby":`${ae}-${O}-title`,onKeyDown:I=>{I.key==="Enter"&&(I.shiftKey||I.metaKey||I.ctrlKey||Te||(I.preventDefault(),xe()))},className:"block w-full bg-transparent border-0 p-0 m-0 outline-none resize-none overflow-hidden text-[13px] leading-snug text-foreground placeholder:text-muted-foreground",style:{fontVariationSettings:yt.medium}})})}):j?fe(zk,{value:le,onValueChange:ee,render:gr}):fe(_k,{value:le[0]??null,onValueChange:I=>{typeof I=="string"&&$e(I)},render:gr})]},O)})}),fr&&fe("div",{className:"px-4 sm:px-5 pt-1 pb-2",children:Vt("div",{className:"flex items-center justify-between gap-2 -mx-2 sm:-mx-3",children:[Vt("div",{className:"relative flex flex-1 min-w-0 items-center gap-2",children:[p!=null&&fe("div",{className:"shrink-0 px-2 sm:px-3",children:p}),fe(Rs,{mode:"popLayout",initial:!1,children:zn&&fe(co.div,{layout:"position",initial:{opacity:0,scale:.85},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.85},transition:{...se.fast,opacity:{duration:.1}},children:fe(E,{variant:"ghost",size:"sm",leadingIcon:K,onClick:Yt,className:"pl-3 sm:pl-[6px]",children:"Back"})},"back")}),re&&fe(iu.Error,{match:!0,render:fe(co.p,{role:"alert",initial:{opacity:0,y:-2},animate:{opacity:1,y:0},transition:{...se.fast,opacity:{duration:.12}},className:"min-w-0 px-2 sm:px-3 text-left text-[12px] leading-snug text-destructive"}),children:re},"ft-error")]}),fe("div",{className:"relative flex items-center gap-2",children:Vt(Rs,{mode:"popLayout",initial:!1,children:[Qn&&fe(co.div,{layout:"position",initial:{opacity:0,scale:.85},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.85},transition:{...se.fast,opacity:{duration:.1}},children:fe(E,{variant:"ghost",size:"sm",trailingIcon:$,onClick:et,className:"pr-3 sm:pr-[6px]",children:m})},"cancel"),Ye&&fe(co.div,{layout:"position",initial:{opacity:0,scale:.85},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.85},transition:{...se.fast,opacity:{duration:.1}},children:fe(E,{variant:"ghost",size:"sm",trailingIcon:$,onClick:he,className:"pr-3 sm:pr-[6px]",children:u})},"skip"),nn&&fe(co.div,{layout:"position",initial:{opacity:0,scale:.85},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.85},transition:{...se.fast,opacity:{duration:.1}},children:fe(E,{variant:"primary",size:"sm",onClick:H?xe:ht,disabled:(H||le.length===0)&&de.trim().length===0,className:"pr-3 sm:pr-[6px]",children:Vt("span",{className:"inline-flex items-center gap-1.5",children:[z.nextLabel??(ne>=ie-1?"Finish":"Continue"),fe("span",{className:"hidden sm:contents",children:Vt(Uk,{shape:S,tone:"inverted",children:[oe?"\u2318":"\u2303","\u21B5"]})})]})})},"continue")]})})]})})]})]})});lu.displayName="AskUserQuestions";function Uk({children:e,tone:t="muted",shape:n}){return fe("kbd",{"aria-hidden":!0,suppressHydrationWarning:!0,className:C("inline-flex items-center justify-center gap-0.5 px-1 min-w-[18px] h-[18px] text-[11px] leading-none font-sans tracking-wide",t==="inverted"?"bg-background/15 text-background":"bg-foreground/10 text-muted-foreground",n.bg),children:e})}function Jg({index:e,registerItem:t,role:n,isSelected:o,tabIndex:r,onClick:s,onKeyDown:a,shape:i,chipContent:d,chipFilled:l,isMulti:u,ariaLabel:h,showArrow:c,arrowIcon:m,onArrowClick:p,bodyLayout:x="inline",topAlign:f=!1,chipPosition:b="right",hiddenControl:g,children:v,...y}){let w=Io(null);Jn(()=>(t(e,w.current),()=>t(e,null)),[e,t]);let N=fe(Rs,{children:c&&fe(co.span,{"aria-hidden":!p,role:p?"button":void 0,onClick:p?P=>{P.stopPropagation(),p()}:void 0,className:C("absolute inset-0 inline-flex items-center justify-center bg-foreground text-background",i.bg,p&&"cursor-pointer"),initial:{opacity:0,scale:.6},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.6,transition:se.fast.exit},transition:{...se.fast,opacity:{duration:.08}},children:m})}),T=Vt("span",{className:C("shrink-0 w-7 h-7 relative inline-flex items-center justify-center",f&&(x==="stacked"?"-mt-[1px]":"-mt-[5px]")),children:[fe("span",{"aria-hidden":!0,className:C("absolute inline-flex items-center justify-center w-5 h-5 text-[11px] transition-[opacity,font-variation-settings] duration-80",u&&i.bg,u?l?"bg-foreground text-background":"border border-border text-muted-foreground":l?"text-foreground":"text-muted-foreground",b==="right"&&c&&"opacity-0"),style:{fontVariationSettings:l?yt.semibold:yt.medium},children:d}),b==="right"&&N]}),L=b==="left"&&!u&&fe("span",{className:C("shrink-0 w-7 h-7 relative inline-flex items-center justify-center",f&&(x==="stacked"?"-mt-[1px]":"-mt-[5px]")),children:N});return Vt("div",{ref:w,"data-proximity-index":e,"data-state":o?"checked":"unchecked",role:n??void 0,"aria-checked":n==="radio"||n==="checkbox"?!!y["aria-checked"]:void 0,"aria-label":h,tabIndex:r,onMouseDown:P=>{let R=P.target.closest('button:not([tabindex="-1"]), a[href], input, select, textarea, [tabindex]:not([tabindex="-1"])');R&&R!==P.currentTarget||(P.preventDefault(),P.currentTarget.focus())},onClick:s,onKeyDown:a,className:C("relative z-10 flex cursor-pointer select-none outline-none",b==="left"?"gap-2":"gap-3",f?"items-start":"items-center",x==="stacked"?"min-h-14 py-2":"min-h-10 py-1.5",b==="left"?u?"pl-1.5 pr-3":"pl-1.5 pr-1.5":"pl-3 pr-1.5",i.item),children:[b==="left"&&T,fe("span",{className:C("min-w-0 flex-1 text-[13px] leading-snug",x==="stacked"?"flex flex-col gap-0.5":"inline-flex items-center gap-0"),children:v}),b==="right"?T:L,g]})}function Tl(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.const=="string"&&(t.title===void 0||typeof t.title=="string")}function Yg(e){let t=Array.isArray(e.oneOf)?e.oneOf.filter(Tl):[],n=Array.isArray(e.anyOf)?e.anyOf.filter(Tl):[];return t.length>0?t:n}function Qg(e){let t=e.items&&typeof e.items=="object"?e.items:{},n=Array.isArray(t.anyOf)?t.anyOf.filter(Tl):[],o=Array.isArray(t.oneOf)?t.oneOf.filter(Tl):[];return n.length>0?n:o}function Xg(e){if(e.mode==="url"&&"url"in e)return[{id:"__url_confirm__",title:"Confirm completion",layout:"stacked",options:[{id:"confirmed",title:"I've completed the required action",description:e.url}],skippable:!1,nextLabel:"Confirm"}];let t="requestedSchema"in e?e.requestedSchema:void 0;if(!t||t.type!=="object"||!t.properties)return[{id:"__freeform__",title:"Your response",freeText:!0,freeTextPlaceholder:"Type your response\u2026",skippable:!1}];let n=t.properties,o=t.required??[];return Object.entries(n).map(([r,s])=>{let a=s,i=o.includes(r),d=a.title||r,l=a.description,u=a.type||"string",h=Yg(a),c=Qg(a),m=Array.isArray(a.enum),p=u==="array"&&Array.isArray(a.items?.enum),x=u==="array"&&c.length>0,f={id:r,title:d,skippable:!i,layout:l&&l.length>60?"stacked":"inline"};if(u==="boolean")return{...f,options:[{id:"true",title:"Yes"},{id:"false",title:"No"}]};if(x||p){let b=x?c:a.items.enum.map(g=>({const:g,title:g}))??[];return{...f,multiSelect:!0,options:b.map(g=>({id:g.const,title:g.title||g.const}))}}if(h.length>0)return{...f,layout:"stacked",options:h.map(b=>({id:b.const,title:b.title||b.const}))};if(m){let b=a.enum,g=a.enumNames;return{...f,options:b.map((v,y)=>({id:v,title:g?.[y]||v}))}}return u==="number"||u==="integer"?{...f,freeText:!0,freeTextMultiline:!1,freeTextPlaceholder:a.default!==void 0?String(a.default):"Enter a number\u2026",freeTextValidate:b=>{let g=b.trim();if(!g)return i?"Required":null;let v=u==="integer"?parseInt(g,10):parseFloat(g);return Number.isNaN(v)?"Enter a valid number":null}}:u==="string"&&(a.format==="textarea"||(a.maxLength??0)>100)?{...f,freeText:!0,freeTextPlaceholder:a.default||"Type your answer\u2026"}:{...f,freeText:!0,freeTextMultiline:!1,freeTextPlaceholder:a.default!==void 0?String(a.default):"Type your answer\u2026",freeTextValidate:b=>!b.trim()&&i?"Required":null}})}function Zg(e,t,n){if(n.mode==="url")return{};let o="requestedSchema"in n?n.requestedSchema:void 0,r=o?.type==="object"&&o.properties?o.properties:{},s={};for(let a of e){let i=a.id??"";if(i==="__freeform__"){let h=t[i]?.otherText?.trim();h&&(s.response=h);continue}let d=t[i];if(!d||d.skipped)continue;let u=r[i]?.type||"string";if(a.freeText){let h=d.otherText?.trim()??"";if(!h)continue;s[i]=u==="number"||u==="integer"?u==="integer"?parseInt(h,10):parseFloat(h):h;continue}if(a.multiSelect){s[i]=d.selectedIds;continue}if(u==="boolean"){s[i]=d.selectedIds[0]==="true";continue}d.selectedIds[0]!==void 0&&(s[i]=d.selectedIds[0])}return s}function eh(e,t,n){if(n.mode==="url")return[];let o="requestedSchema"in n?n.requestedSchema:void 0;return(o?.type==="object"?o.required??[]:[]).filter(s=>{let a=t[s];if(!a||a.skipped)return!0;let i=e.find(d=>d.id===s);return i?i.freeText?!a.otherText?.trim():(i.multiSelect,a.selectedIds.length===0):!0})}function th(e,t){if(t.mode==="url")return{};let n="requestedSchema"in t?t.requestedSchema:void 0,o=n?.type==="object"&&n.properties?n.properties:{},r={};for(let s of e){let a=s.id;if(!a||a.startsWith("__"))continue;let i=o[a];if(!(!i||i.default===void 0)){if(s.freeText){r[a]={questionId:a,selectedIds:[],otherText:String(i.default),skipped:!1};continue}if(s.multiSelect&&Array.isArray(i.default)){r[a]={questionId:a,selectedIds:i.default.map(String),skipped:!1};continue}if(i.type==="boolean"){r[a]={questionId:a,selectedIds:[String(i.default)],skipped:!1};continue}r[a]={questionId:a,selectedIds:[String(i.default)],skipped:!1}}}return r}import{jsx as Ea,jsxs as Pl}from"react/jsx-runtime";function sh({request:e,onApprove:t,onReject:n,testId:o="inline-elicitation",actionTestIdPrefix:r="inline-elicitation"}){let[s,a]=oh(!1),[i,d]=oh(""),l=nh(()=>Xg(e.request),[e.request]),u=nh(()=>th(l,e.request),[l,e.request]),c=(e.request.mode||"form")==="url",m=c&&"url"in e.request?e.request.url:void 0,p=(b,g)=>{a(!0),d(b),t(e.id,g)},x=b=>{if(s)return;if(c){if(!b.__url_confirm__?.selectedIds.includes("confirmed")){rh.error("Confirm you've completed the external action");return}p("accepted",{action:"accept"});return}let g=eh(l,b,e.request);if(g.length>0){rh.error("Missing required fields",{description:`Please fill in: ${g.join(", ")}`});return}p("accepted",{action:"accept",content:Zg(l,b,e.request)})};if(s)return Pl("p",{className:"text-sm text-muted-foreground","data-testid":`${o}-responded`,children:["Elicitation ",i," \u2014 the tool will continue executing."]});let f=Pl("div",{className:"space-y-2",children:[Ea("p",{className:"text-foreground/90",children:e.request.message}),c&&m&&Pl("div",{className:"flex items-center gap-2 rounded-md border bg-muted/40 p-2",children:[Ea("code",{className:"flex-1 text-xs font-mono break-all",children:m}),Pl(E,{size:"sm",variant:"outline",onClick:()=>window.open(m,"_blank"),"data-testid":`${r}-open-url`,children:[Ea(Fk,{className:"h-3 w-3 mr-1"}),"Open"]})]})]});return Ea(lu,{questions:l,defaultAnswers:u,onComplete:x,intro:f,onCancel:()=>n(e.id,"User cancelled elicitation request"),cancelLabel:"Cancel",footerLeading:Ea("button",{type:"button",className:"shrink-0 cursor-pointer text-[12px] text-muted-foreground underline-offset-2 hover:text-foreground hover:underline",onClick:()=>p("declined",{action:"decline"}),"data-testid":`${r}-decline-button`,children:"Decline"}),className:"w-full max-w-none shadow-lg","data-testid":o})}import{jsx as cu}from"react/jsx-runtime";function ah({requests:e,onApprove:t,onReject:n}){return e.length===0?null:cu("div",{className:"mb-3 space-y-3 pointer-events-auto","data-testid":"floating-elicitation-stack",children:e.map(o=>cu($k.div,{initial:{opacity:0,y:12,scale:.98},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:8,scale:.98},transition:se.moderate,children:cu(sh,{request:o,onApprove:t,onReject:n})},o.id))})}import{Check as Vk,Loader2 as jk,Settings2 as qk}from"lucide-react";import{useCallback as Wk,useEffect as Kk,useState as du}from"react";var jr="You are a helpful assistant with access to MCP tools. Help users interact with the MCP server.";import{jsx as Gn,jsxs as Aa}from"react/jsx-runtime";function Jk(e){let t=e?.trim();return t?t!==jr:!1}function ih({value:e,onSave:t,disabled:n,isSaving:o=!1,compact:r=!1}){let[s,a]=du(!1),[i,d]=du(e??""),[l,u]=du(!1);Kk(()=>{d(e??"")},[e]);let h=Wk(async()=>{u(!0);try{await t(i),a(!1)}finally{u(!1)}},[i,t]),c=o||l,m=Jk(e),p=Aa("button",{type:"button","data-testid":"chat-system-prompt-button",onClick:()=>a(!0),disabled:n,className:r?C("inline-flex h-auto w-auto aspect-square items-center justify-center rounded-full p-2 transition-colors disabled:pointer-events-none disabled:opacity-50",m?"text-amber-500 dark:text-amber-400":"text-muted-foreground hover:text-foreground"):C("inline-flex h-9 items-center justify-center gap-1.5 rounded-full border border-input bg-secondary px-3 text-sm font-medium shadow-xs transition-colors hover:bg-secondary/80 disabled:pointer-events-none disabled:opacity-50",m?"text-amber-600 dark:text-amber-400":"text-secondary-foreground"),children:[Gn(qk,{className:"h-4 w-4"}),!r&&Gn("span",{className:"hidden sm:inline",children:"System Prompt"})]});return Aa(fn,{open:s,onOpenChange:a,children:[r?Aa(ke,{children:[Gn(we,{render:p,nativeButton:!0}),Gn(Ce,{side:"top",children:Gn("p",{children:m?"Custom system prompt":"System Prompt"})})]}):p,Aa(on,{className:"sm:max-w-xl",children:[Gn(Qt,{children:Gn(qt,{children:"System Prompt"})}),Gn(to,{value:i,onChange:x=>d(x.target.value),placeholder:"Describe the assistant's behavior...",className:"min-h-[160px] text-sm"}),Gn(li,{children:Aa(E,{size:"sm",onClick:h,disabled:c||i===(e??""),className:"gap-1.5",children:[c?Gn(jk,{className:"h-3.5 w-3.5 animate-spin"}):Gn(Vk,{className:"h-3.5 w-3.5"}),"Save"]})})]})]})}import{Fragment as Qk,jsx as tn,jsxs as uu}from"react/jsx-runtime";function Da({inputValue:e,isConnected:t,isLoading:n,textareaRef:o,llmConfig:r,promptsDropdownOpen:s,promptFocusedIndex:a,prompts:i,selectedPrompt:d,promptResults:l,attachments:u,tools:h,disabledTools:c,onDisabledToolsChange:m,onInputChange:p,onKeyDown:x,onKeyUp:f,onClick:b,onSendMessage:g,onStopStreaming:v,onConfigDialogOpenChange:y,onPromptSelect:w,onDeletePromptResult:N,onAttachmentAdd:T,onAttachmentRemove:L,hideModelBadge:P,freeTierInfo:R,managedCloudInfo:D,modelBadgeMode:k="byok",modelDisplayName:S,followups:A=[],onFollowupSelect:_,pendingElicitationRequests:K,onApproveElicitation:$,onRejectElicitation:oe,systemPromptProvider:ae}){let ie=e.trim()||l.length>0||u.length>0,ne=(K?.length??0)>0,z=r&&(!P||R||D)?uu(ke,{children:[tn(we,{render:tn(hg,{provider:r.provider,model:r.model,displayName:S,mode:k,className:"shrink-0",onClick:()=>y(!0)}),nativeButton:!0}),tn(Ce,{children:tn("p",{children:D||R?"Change model":"Change API Key"})})]}):null;return tn("div",{className:"w-full flex shrink-0 flex-col items-center px-2 pb-2 pt-0 sm:px-4 sm:pb-2 text-foreground",children:uu("div",{className:"relative w-full max-w-3xl backdrop-blur-xl",children:[ne&&$&&oe&&tn(ah,{requests:K,onApprove:$,onReject:oe}),A.length>0&&tn("div",{className:"mb-2 flex flex-wrap gap-2",children:A.map(O=>tn(E,{type:"button",variant:"outline",size:"sm",className:"rounded-full",onClick:()=>_?.(O),disabled:n||!t,children:O},O))}),tn($g,{isOpen:s,prompts:i,selectedPrompt:d,focusedIndex:a,onPromptSelect:w}),tn(Fg,{promptResults:l,onDeletePromptResult:N}),tn(Ug,{inputValue:e,isConnected:t,isLoading:n,textareaRef:o,attachments:u,placeholder:"Ask a question or request an action...",className:C("bg-white/80 dark:text-white dark:bg-black backdrop-blur-sm border-gray-200 dark:border-zinc-800",l.length>0&&"pt-16"),tools:h,disabledTools:c,onDisabledToolsChange:m,onInputChange:p,onKeyDown:x,onKeyUp:f,onClick:b,onAttachmentAdd:T,onAttachmentRemove:L,inlineControls:r&&ae?tn(ih,{compact:!0,value:ae.prompt,onSave:ae.savePrompt,disabled:!t||n||ae.disabled,isSaving:ae.isSaving}):null,trailingControls:uu(Qk,{children:[z,tn(E,{type:"button",size:"sm",className:C("h-8 w-8 rounded-full p-0",n&&"animate-spin",!ie&&!n&&"bg-zinc-400"),disabled:!n&&(!ie||!t||ne),title:n?"Stop streaming":"Send",onClick:n?v:g,"data-testid":"chat-send-button",children:n?tn(Yk,{className:"h-3.5 w-3.5 animate-spin"}):tn(Gk,{className:"h-3.5 w-3.5"})})]})})]})})}import{AnimatePresence as Xk,motion as Zk,useInView as eS}from"motion/react";import{useRef as tS}from"react";import{jsx as lh}from"react/jsx-runtime";function ch({children:e,className:t,variant:n,duration:o=.4,delay:r=0,offset:s=6,direction:a="down",inView:i=!1,inViewMargin:d="-50px",blur:l="6px",...u}){let h=tS(null),c=eS(h,{once:!0,margin:d}),m=!i||c,p={hidden:{[a==="left"||a==="right"?"x":"y"]:a==="right"||a==="down"?-s:s,opacity:0,filter:`blur(${l})`},visible:{[a==="left"||a==="right"?"x":"y"]:0,opacity:1,filter:"blur(0px)"}},x=n||p;return lh(Xk,{children:lh(Zk.div,{ref:h,initial:"hidden",animate:m?"visible":"hidden",exit:"hidden",variants:x,transition:{delay:.04+r,duration:o,ease:"easeOut"},className:t,...u,children:e})})}import{jsx as La,jsxs as Rl}from"react/jsx-runtime";function mu({serverDisplayName:e,composerNotice:t,quickQuestions:n=[],onQuickQuestionSelect:o,...r}){return La("div",{className:"flex h-full flex-col items-center justify-center",children:Rl(ch,{className:"w-full max-w-4xl mx-auto px-2 sm:px-4",children:[Rl("div",{className:"text-center mb-6 sm:mb-8",children:[Rl("h1",{className:"text-2xl sm:text-4xl font-light mb-2 dark:text-white","data-testid":"chat-landing-header",children:["Chat with ",e]}),La("p",{className:"mx-auto max-w-xl text-sm text-muted-foreground sm:text-base","data-testid":"chat-landing-description",children:"Chat, inspect traces, preview widgets, and more."})]}),Rl("div",{className:"space-y-6",children:[t,La(Da,{...r}),n.length>0&&La("div",{className:"flex flex-wrap items-center justify-center gap-2 px-2",children:n.map(s=>La(E,{type:"button",variant:"outline",size:"sm",className:"rounded-full bg-white/70 dark:bg-black/50 text-gray-900 dark:text-white",onClick:()=>o?.(s),disabled:r.isLoading||!r.isConnected,children:s},s))})]})]})})}import{Key as nS,Settings as oS}from"lucide-react";import{jsx as Ml,jsxs as dh}from"react/jsx-runtime";function pu({onConfigureClick:e}){return dh("div",{className:"flex flex-col items-center justify-center h-full text-center",children:[Ml(nS,{className:"h-12 w-12 text-muted-foreground mb-4"}),Ml("h3",{className:"text-lg font-semibold mb-2",children:"Configure Your LLM Provider"}),Ml("p",{className:"text-sm text-muted-foreground mb-4 max-w-md",children:"To start chatting with the MCP server, you need to configure your LLM provider and API key. Your credentials are stored locally and used only for this chat."}),dh(E,{onClick:e,"data-testid":"chat-configure-api-key-button",children:[Ml(oS,{className:"h-4 w-4 mr-2"}),"Configure API Key"]})]})}import{motion as rS}from"motion/react";import{useMemo as sS}from"react";import{jsx as aS}from"react/jsx-runtime";function uh({children:e,as:t="p",className:n,duration:o=2,spread:r=2}){let s=rS.create(t),a=sS(()=>e.length*r,[e,r]);return aS(s,{className:C("relative inline-block bg-[length:250%_100%,auto] bg-clip-text","text-transparent [--base-color:#a1a1aa] [--base-gradient-color:#000]","[--bg:linear-gradient(90deg,#0000_calc(50%-var(--spread)),var(--base-gradient-color),#0000_calc(50%+var(--spread)))] [background-repeat:no-repeat,padding-box]","dark:[--base-color:#71717a] dark:[--base-gradient-color:#ffffff] dark:[--bg:linear-gradient(90deg,#0000_calc(50%-var(--spread)),var(--base-gradient-color),#0000_calc(50%+var(--spread)))]",n),initial:{backgroundPosition:"100% center"},animate:{backgroundPosition:"0% center"},transition:{repeat:1/0,duration:o,ease:"linear"},style:{"--spread":`${a}px`,backgroundImage:"var(--bg), linear-gradient(var(--base-color), var(--base-color))"},children:e})}import{memo as MS,useCallback as IS,useMemo as ES}from"react";import{memo as iS,useMemo as lS}from"react";import{jsx as mh,jsxs as dS}from"react/jsx-runtime";function cS(e){let t=e.match(/```/g);return t&&t.length%2===1?`${e}
|
|
198
|
+
\`\`\``:e}var ph=iS(function({content:t,isStreaming:n=!1}){let o=lS(()=>n?cS(t):t,[t,n]);return dS("div",{children:[mh(bs,{className:C("text-[14px] leading-relaxed text-foreground","[&_p]:mb-2 [&_p:last-child]:mb-0","[&_pre]:my-3 [&_ul]:mb-2 [&_ol]:mb-2"),content:o}),n?mh("span",{className:"inline-block w-0.5 h-[1em] ml-0.5 -mt-1 align-middle bg-foreground/60 animate-pulse","aria-hidden":!0}):null]})});import{forwardRef as vS}from"react";import{motion as bS}from"motion/react";import{useEffect as uS,useState as mS}from"react";function fh(){let[e,t]=mS(!1);return uS(()=>{if(typeof window>"u")return;let n=new AbortController,{signal:o}=n,r=()=>{let a="ontouchstart"in window||navigator.maxTouchPoints>0,i=window.matchMedia("(pointer: coarse)").matches;t(a&&i)};return window.matchMedia("(pointer: coarse)").addEventListener("change",r,{signal:o}),window.addEventListener("pointerdown",r,{signal:o}),r(),()=>n.abort()},[]),e}import{useEffect as pS,useState as fS}from"react";import{jsx as dr,jsxs as hS}from"react/jsx-runtime";function gS({size:e}){return hS("svg",{width:Math.max(16,e*.35),height:Math.max(16,e*.35),viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[dr("path",{d:"M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z"}),dr("path",{d:"M14 3v5h5"})]})}function gh({file:e,size:t,className:n}){let o=pt(),r=e.type.startsWith("image/"),[s,a]=fS(null);pS(()=>{if(!r){a(null);return}let d=URL.createObjectURL(e);return a(d),()=>URL.revokeObjectURL(d)},[r,e]);let i=r&&!s;return dr("div",{className:C("relative shrink-0 overflow-hidden bg-accent border border-border",o.bg,n),style:{width:t,height:t},children:s?dr("img",{src:s,alt:e.name,className:"absolute inset-0 w-full h-full object-cover"}):i?dr("div",{className:"absolute inset-0 flex items-center justify-center",children:dr("div",{className:"w-6 h-6 rounded-full border-2 border-border border-t-muted-foreground animate-spin","aria-label":"Loading preview",role:"status"})}):dr("div",{className:"absolute inset-0 flex items-center justify-center text-muted-foreground",role:"img","aria-label":e.name,children:dr(gS,{size:t})})})}import{jsx as _a,jsxs as hh}from"react/jsx-runtime";var Oa=vS(({from:e,files:t,thumbnailSize:n=64,time:o,actions:r,children:s,className:a,...i},d)=>{let l=pt(),u=e==="user",h=fh(),c=u&&o!=null;return hh(bS.div,{ref:d,layout:"position",initial:{opacity:0,y:8,scale:.96},animate:{opacity:1,y:0,scale:1},transition:se.moderate,style:{transformOrigin:u?"bottom right":"bottom left"},className:C("group flex max-w-[80%] flex-col gap-1.5",u?"items-end self-end":"items-start self-start",a),...i,children:[t&&t.length>0&&_a("div",{className:C("flex flex-wrap gap-1.5",u?"justify-end":"justify-start"),children:t.map((m,p)=>_a(gh,{file:m,size:n},`${m.name}-${m.size}-${m.lastModified}-${p}`))}),s!=null&&s!==""&&_a("div",{className:C("py-2 text-[14px] whitespace-pre-wrap break-words",u?C(l.bg,"px-3.5 text-pretty bg-[color-mix(in_oklab,var(--accent),var(--background)_45%)] text-accent-foreground"):"text-foreground"),children:s}),(c||r!=null)&&hh("div",{className:C("flex items-center gap-2 px-1 text-[12px] leading-none text-muted-foreground select-none",!h&&["opacity-0 pointer-events-none transition-opacity duration-150","group-hover:opacity-100 group-hover:pointer-events-auto","group-focus-within:opacity-100 group-focus-within:pointer-events-auto"]),children:[c&&_a("span",{className:"tabular-nums",children:o}),r!=null&&_a("span",{className:"flex items-center gap-0.5",children:r})]})]})});Oa.displayName="ChatMessage";import{Check as yS,Copy as xS}from"lucide-react";import{useState as wS}from"react";import{jsx as fu}from"react/jsx-runtime";function vh({text:e}){let[t,n]=wS(!1);return fu("button",{type:"button",className:"text-muted-foreground hover:text-foreground flex items-center rounded p-0.5",onClick:async()=>{await Xe(e),n(!0),setTimeout(()=>n(!1),2e3)},title:"Copy message content","data-testid":"copy-button",children:t?fu(yS,{className:"h-3.5 w-3.5"}):fu(xS,{className:"h-3.5 w-3.5"})})}import{Fragment as xh,jsx as yh,jsxs as wh}from"react/jsx-runtime";function bh(e,t){let n=e===1?"token":"tokens";return`${e.toLocaleString()} ${n} ${t}`}function Il({variant:e,copyText:t,inputTokens:n,outputTokens:o}){let r=!!t,s=e==="user"&&n!=null?bh(n,"in"):e==="assistant"&&o!=null?bh(o,"out"):null;if(!r&&!s)return null;let a=r?yh(vh,{text:t}):null,i=s?yh("span",{className:"tabular-nums",title:e==="user"?"Input tokens":"Output tokens","data-testid":e==="user"?"message-input-tokens":"message-output-tokens",children:s}):null;return e==="user"?wh(xh,{children:[i,a]}):wh(xh,{children:[a,i]})}import{jsx as El,jsxs as CS}from"react/jsx-runtime";function gu({content:e,timestamp:t,_isStreaming:n,outputTokens:o}){return!e||e.length===0?null:CS("div",{"data-testid":"chat-message-assistant",children:[El(Oa,{from:"assistant",actions:El(Il,{variant:"assistant",copyText:e,outputTokens:o}),"data-testid":"chat-message-content",children:El(ph,{content:e,isStreaming:n})}),t!=null&&El("span",{className:"sr-only",children:new Date(t).toLocaleTimeString()})]})}import{Check as Ch,Copy as hu,Loader2 as Nh,Wrench as kh,X as NS}from"lucide-react";import{jsx as st,jsxs as Gt}from"react/jsx-runtime";function vu({toolName:e,args:t,result:n,state:o="result",partialArgs:r}){let s=o==="call"&&r?r:t,a=()=>{switch(o){case"call":return st(Nh,{className:"h-4 w-4 animate-spin text-blue-500 dark:text-blue-400"});case"result":return st(Ch,{className:"h-4 w-4 text-emerald-800 dark:text-emerald-400"});case"error":return st(NS,{className:"h-4 w-4 text-red-500 dark:text-red-400"});default:return st(Ch,{className:"h-4 w-4 text-emerald-800 dark:text-emerald-400"})}},i=()=>{switch(o){case"call":return" bg-blue-500/20 dark:bg-blue-500/20";case"result":return" bg-emerald-500/20 dark:bg-emerald-500/20";case"error":return" bg-red-500/20 dark:bg-red-500/20";default:return" bg-emerald-500/20 dark:bg-emerald-500/20"}},d=l=>typeof l=="object"?_i(l).preview:String(l);return Gt(is,{children:[st(Mi,{render:Gt("div",{className:"flex max-w-min items-center gap-3 p-1 rounded-full border bg-card hover:bg-accent/50 transition-colors cursor-pointer my-4","data-testid":`chat-tool-call-${e}`,children:[st("div",{className:"w-8 h-8 rounded-full bg-zinc-100 dark:bg-zinc-900 border border-zinc-200 dark:border-zinc-800 flex items-center justify-center shrink-0",children:st(kh,{className:"size-4 text-muted-foreground"})}),st("div",{className:"flex-1 min-w-0",children:st("div",{className:"flex items-center gap-2",children:Gt("span",{className:"text-sm font-medium truncate",children:[e,"(",Object.keys(s).length>0?Gt("span",{className:"bg-muted-foreground/20 rounded-full px-1.5 mx-1 py-0.5 text-xs",children:[Object.keys(s).length," args"]}):"",")"]})})}),st("div",{className:C("w-8 h-8 rounded-full flex items-center justify-center",i()),"data-testid":`chat-tool-call-status-${o}`,children:a()})]}),nativeButton:!1}),Gt(ls,{side:"right",className:"w-[400px] sm:w-[540px] p-4 overflow-y-auto","data-testid":"chat-tool-drawer",children:[Gt(Ii,{children:[Gt(Ei,{className:"flex items-center gap-2",children:[st(kh,{className:"h-5 w-5"}),"Tool Call Details"]}),Gt(wp,{className:"flex items-center gap-2",children:[e," \u2014 ",o,o==="call"&&Gt("span",{className:"flex items-center gap-1 text-blue-500 dark:text-blue-400",children:[st(Nh,{className:"h-3 w-3 animate-spin"}),"streaming\u2026"]})]})]}),Gt("div",{className:"flex flex-col gap-6 py-4",children:[Gt("div",{children:[st("h3",{className:"text-sm font-medium mb-2",children:"Arguments"}),Gt("div",{className:"relative","data-testid":"chat-tool-drawer-args",children:[st("pre",{className:"text-xs bg-muted/50 rounded-lg p-3 overflow-x-auto border font-mono leading-relaxed max-h-48 whitespace-pre-wrap break-words",children:d(s)}),st(E,{variant:"ghost",size:"sm",onClick:()=>Xe(d(s)),className:"absolute top-2 right-2 h-6 w-6 p-0 opacity-70 hover:opacity-100",title:"Copy arguments",children:st(hu,{className:"h-3 w-3"})})]})]}),n&&Gt("div",{children:[st("h3",{className:"text-sm font-medium mb-2",children:"Result"}),st("div",{className:"relative","data-testid":"chat-tool-drawer-result",children:typeof n=="string"?Gt("div",{className:C("p-3 rounded-lg border text-sm leading-relaxed max-h-48 overflow-x-auto whitespace-pre-wrap break-words max-w-full",o==="error"?"bg-destructive/10 border-destructive/20 text-destructive-foreground":"bg-muted/30 border-border"),children:[n.startsWith("Error")?Gt("div",{className:"font-mono",children:[st("div",{className:"font-semibold text-destructive mb-1",children:"Error:"}),st("div",{className:"whitespace-pre-wrap break-words",children:n.replace(/^Error:\s*/,"")})]}):st("div",{className:"whitespace-pre-wrap font-mono break-words",children:n}),st(E,{variant:"ghost",size:"sm",onClick:()=>Xe(n),className:"absolute top-2 right-2 h-6 w-6 p-0 opacity-70 hover:opacity-100",title:"Copy result",children:st(hu,{className:"h-3 w-3"})})]}):Gt("div",{className:C("p-3 rounded-lg border text-sm leading-relaxed max-h-96 overflow-y-auto max-w-full",o==="error"?"bg-destructive/10 border-destructive/20 text-destructive-foreground":"bg-muted/30 border-border"),children:[st(wt,{data:n,filename:`tool-call-${e}-result-${Date.now()}.json`}),st(E,{variant:"ghost",size:"sm",onClick:()=>Xe(JSON.stringify(n,null,2)),className:"absolute top-2 right-2 h-6 w-6 p-0 opacity-70 hover:opacity-100",title:"Copy result",children:st(hu,{className:"h-3 w-3"})})]})})]})]})]})]})}import{useMemo as kS}from"react";import{jsx as bu}from"react/jsx-runtime";function SS(e){let t=atob(e.data),n=new Uint8Array(t.length);for(let o=0;o<t.length;o++)n[o]=t.charCodeAt(o);return new File([n],e.name||"attachment",{type:e.mimeType})}function Sh({content:e,timestamp:t,attachments:n,inputTokens:o}){let r=kS(()=>n?.map(SS),[n]);return(!e||e.length===0)&&(!n||n.length===0)?null:bu("div",{"data-testid":"chat-message-user",className:"flex flex-col items-end",children:bu(Oa,{from:"user",files:r,time:t?new Date(t).toLocaleTimeString():void 0,actions:e||o!=null?bu(Il,{variant:"user",copyText:e||void 0,inputTokens:o}):void 0,"data-testid":"chat-message-content",children:e&&e.length>0?e:void 0})})}import{isViewTool as AS}from"@mcp-use/client/react";var ur={events:[],spans:[]};function Dl(e){if(!e||typeof e!="object")return;let t=e,n=(...a)=>{for(let i of a)if(typeof t[i]=="number")return t[i]},o=n("inputTokens","input_tokens","promptTokens"),r=n("outputTokens","output_tokens","completionTokens"),s=n("totalTokens","total_tokens")??(o!==void 0&&r!==void 0?o+r:void 0);if(!(o===void 0&&r===void 0&&s===void 0))return{inputTokens:o,outputTokens:r,totalTokens:s}}var TS=new Set(["apikey","authorization","accesstoken","refreshtoken","password","cookie","secret"]);function Al(e){return Array.isArray(e)?e.map(Al):!e||typeof e!="object"?e:Object.fromEntries(Object.entries(e).map(([t,n])=>[t,TS.has(t.toLowerCase().replace(/[_-]/g,""))?"[REDACTED]":Al(n)]))}function Th(e,t=120){let n;try{n=JSON.stringify(e)}catch{n=String(e)}return n.length>t?`${n.slice(0,t)}\u2026`:n}function qr(e){switch(e.type){case"request":return"LLM request";case"text-delta":return e.delta.trim()||"Text delta";case"tool-call-start":return e.toolName;case"tool-call-args":return Th(e.args);case"tool-result":return Th(e.result);case"usage":return`${e.usage.totalTokens??"?"} tokens`;case"error":return e.message;case"done":return"Completed";default:return e}}function yu(e,t){let n=(o,r)=>o===void 0&&r===void 0?void 0:(o??0)+(r??0);return{inputTokens:n(e?.inputTokens,t.inputTokens),outputTokens:n(e?.outputTokens,t.outputTokens),totalTokens:n(e?.totalTokens,t.totalTokens),cachedInputTokens:n(e?.cachedInputTokens,t.cachedInputTokens),reasoningTokens:n(e?.reasoningTokens,t.reasoningTokens)}}function Ll(e,t){let n=e.spans.map(s=>({...s})),o=e.usage,r=[...n].reverse().find(s=>s.kind==="llm"&&s.status==="running");if(t.type==="request")n.push({id:`llm-${t.id}`,kind:"llm",name:"LLM",status:"running",startedAt:t.timestamp,preview:qr(t)});else if((t.type==="text-delta"||t.type==="tool-call-start")&&!r)r={id:`llm-${t.id}`,kind:"llm",name:"LLM",status:"running",startedAt:t.timestamp,preview:t.type==="text-delta"?qr(t):"LLM response"},n.push(r),t.type==="tool-call-start"&&n.push({id:t.toolCallId,kind:"tool",name:t.toolName,status:"running",startedAt:t.timestamp,preview:qr(t)});else if(t.type==="tool-call-start")n.push({id:t.toolCallId,kind:"tool",name:t.toolName,status:"running",startedAt:t.timestamp,preview:qr(t)});else if(t.type==="tool-call-args"){let s=n.find(a=>a.id===t.toolCallId);s&&(s.preview=qr(t))}else if(t.type==="tool-result"){let s=t.toolCallId?n.find(a=>a.id===t.toolCallId):[...n].reverse().find(a=>a.kind==="tool"&&a.name===t.toolName&&a.status==="running");s&&(s.status=t.isError?"error":"success",s.endedAt=t.timestamp,s.preview=qr(t))}else t.type==="usage"?(o=yu(o,t.usage),r&&(r.usage=yu(r.usage,t.usage))):(t.type==="error"||t.type==="done")&&r&&(r.status=t.type==="error"?"error":"success",r.endedAt=t.timestamp,r.preview=qr(t));return{events:[...e.events,t],spans:n,usage:o}}function xu(e,t){let n=[],o=null;for(let r of e)r.type==="request"?(o&&n.push(o),o={request:r,response:[]}):o&&o.response.push(r);return o&&n.push(o),{turns:n,tokenUsage:t??null}}function PS(e){let t;for(let n of e)n.type==="usage"&&(t=yu(t,n.usage));return t}function RS(e){let t=[],n=0;for(;n<e.length;){if(e[n]?.role!=="user"){n++;continue}let o=e[n].id;n++;let r=null;for(;n<e.length&&e[n]?.role==="assistant";)r=e[n].id,n++;t.push({userId:o,assistantId:r})}return t}function Ph(e,t){let{turns:n}=xu(t),o=RS(e),r=new Map,s=Math.min(n.length,o.length);for(let a=0;a<s;a++){let i=PS(n[a].response);if(!i)continue;let{userId:d,assistantId:l}=o[a];i.inputTokens!=null&&r.set(d,{...r.get(d),inputTokens:i.inputTokens}),l!=null&&i.outputTokens!=null&&r.set(l,{...r.get(l),outputTokens:i.outputTokens})}return r}import{Fragment as DS,jsx as zt,jsxs as _l}from"react/jsx-runtime";var wu=MS(({messages:e,isLoading:t,serverId:n,readResource:o,tools:r,sendMessage:s,messagesEndRef:a,traceEvents:i=[]})=>{let d=ES(()=>Ph(e,i),[e,i]),l=g=>{let v=N=>N.replace(/-/g,"_"),y=v(g);return r?.find(N=>v(N.name)===y)?._meta},u=g=>{let v=l(g);return AS(v)},h=IS(g=>{let v=g.filter(w=>w.type==="text"&&"text"in w).map(w=>w.text).join(`
|
|
199
|
+
`),y=g.filter(w=>w.type==="image"&&"data"in w&&"mimeType"in w).map(w=>({type:"image",data:w.data,mimeType:w.mimeType}));s?.(v,y.length>0?y:void 0)},[s]),c=t&&(()=>{if(e.length===0)return!0;let g=e[e.length-1];if(g.role==="user")return!0;if(g.role==="assistant"){if(g.parts&&g.parts.length>0)return!1;let v=typeof g.content=="string"?g.content:Array.isArray(g.content)?g.content.map(w=>typeof w=="string"?w:w.text||JSON.stringify(w)).join(""):JSON.stringify(g.content);return!(v&&v.trim().length>0)}return!1})(),m=e[e.length-1],p=t&&m?.role==="assistant",x=g=>{for(let v=g.length-1;v>=0;v--)if(g[v]?.type==="text")return v;return-1},f=(g,v,y)=>p&&g.id===m?.id&&v===x(y),b=g=>p&&g.id===m?.id;return _l("div",{className:"space-y-6 max-w-3xl mx-auto px-2",children:[e.map(g=>{let v=typeof g.content=="string"?g.content:Array.isArray(g.content)?g.content.map(y=>typeof y=="string"?y:y.text||JSON.stringify(y)).join(""):JSON.stringify(g.content);if(g.role==="user")return zt(Sh,{content:v,timestamp:g.timestamp,attachments:g.attachments,inputTokens:d.get(g.id)?.inputTokens},g.id);if(g.role==="assistant"){let y=d.get(g.id)?.outputTokens,w=g.parts&&g.parts.length>0?x(g.parts):-1;return zt("div",{className:"space-y-4",children:g.parts&&g.parts.length>0?g.parts.map((N,T)=>{let L=N.type==="text"?`${g.id}-text-${T}`:`${g.id}-tool-${N.toolInvocation?.toolCallId??`${N.toolInvocation?.toolName}-${T}`}`;return N.type==="text"?zt(gu,{content:N.text||"",timestamp:T===g.parts.length-1?g.timestamp:void 0,_isStreaming:f(g,T,g.parts),outputTokens:T===w?y:void 0},L):N.type==="tool-invocation"&&N.toolInvocation?_l("div",{children:[zt(vu,{toolName:N.toolInvocation.toolName,args:N.toolInvocation.args,result:N.toolInvocation.result,state:N.toolInvocation.state==="error"?"error":N.toolInvocation.state==="streaming"||N.toolInvocation.state==="pending"?"call":"result",partialArgs:N.toolInvocation.partialArgs}),(N.toolInvocation.result||N.toolInvocation.state==="streaming"||u(N.toolInvocation.toolName))&&zt("div",{"data-tool-call-id":`${g.id}-${N.toolInvocation.toolName}-${T}`,children:zt(Vi,{toolName:N.toolInvocation.toolName,toolArgs:N.toolInvocation.args,result:N.toolInvocation.result||null,serverId:n,readResource:o,toolMeta:l(N.toolInvocation.toolName),onSendFollowUp:h,partialToolArgs:N.toolInvocation.partialArgs,cancelled:N.toolInvocation.state==="error"&&N.toolInvocation.result==="Cancelled by user"})})]},L):null}):_l(DS,{children:[zt(gu,{content:v,timestamp:g.timestamp,_isStreaming:b(g),outputTokens:y}),g.toolCalls&&g.toolCalls.length>0&&zt("div",{className:"space-y-2",children:g.toolCalls.map(N=>{let T=`${g.id}-${N.toolName}-${JSON.stringify(N.args).slice(0,50)}`;return _l("div",{children:[zt(vu,{toolName:N.toolName,args:N.args,result:N.result,state:N.result?"result":"call"}),(N.result||u(N.toolName))&&zt("div",{"data-tool-call-id":T,children:zt(Vi,{toolName:N.toolName,toolArgs:N.args,result:N.result||null,serverId:n,readResource:o,toolMeta:l(N.toolName),onSendFollowUp:h})})]},T)})})]})},g.id)}return null}),c&&zt("div",{className:"flex items-start gap-3",children:zt("div",{className:"flex-1",children:zt("div",{className:"rounded-lg p-4 max-w-fit",children:zt("div",{className:"flex items-center gap-2",children:zt("span",{className:"text-sm",children:zt(uh,{duration:2,spread:1,children:"Thinking..."})})})})})}),zt("div",{ref:a})]})});import{ArrowDown as LS}from"lucide-react";import{AnimatePresence as _S,motion as OS}from"motion/react";import{jsx as za}from"react/jsx-runtime";function Rh({visible:e,onClick:t}){return za("div",{className:"pointer-events-none absolute bottom-2 left-0 right-0 z-30 flex justify-center",children:za(_S,{children:e&&za(OS.div,{initial:{opacity:0,y:8,scale:.96},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:8,scale:.96},transition:{duration:.18,ease:"easeOut"},children:za(E,{type:"button",variant:"secondary",className:"pointer-events-auto size-9 rounded-full border bg-background/95 p-0 shadow-lg backdrop-blur supports-[backdrop-filter]:bg-background/80",onClick:t,"aria-label":"Scroll to bottom",title:"Scroll to bottom","data-testid":"chat-scroll-to-bottom",children:za(LS,{className:"size-4"})})})})})}import{jsx as zS}from"react/jsx-runtime";function Mh({visible:e}){return zS("div",{"aria-hidden":!0,className:C("pointer-events-none absolute inset-x-0 top-0 z-[5] h-32 bg-[linear-gradient(to_bottom,var(--background)_0%,var(--background)_24%,transparent_46%)] transition-opacity duration-200 sm:h-36",e?"opacity-100":"opacity-0")})}import{useCallback as Ih,useEffect as Eh,useRef as Cu,useState as Ah}from"react";function Dh(e,{messageCount:t,isLoading:n,enabled:o=!0}){let r=Cu(null),[s,a]=Ah(!0),[i,d]=Ah(!1),l=Cu(!0),u=Cu({length:0,loading:!1}),h=64,c=8,m=t>0,p=o&&m&&!s,x=Ih(()=>{let b=e.current;if(!b)return;let v=b.scrollHeight-(b.scrollTop+b.clientHeight)<=h;l.current=v,a(v),d(b.scrollTop>c)},[e]),f=Ih(b=>{let g=e.current;g&&(g.scrollTo({top:g.scrollHeight,behavior:b}),l.current=!0,a(!0))},[e]);return Eh(()=>{if(!o)return;let b=e.current;if(!b)return;x();let g=()=>x();b.addEventListener("scroll",g,{passive:!0});let v=typeof ResizeObserver<"u"?new ResizeObserver(()=>x()):null;return v?.observe(b),()=>{b.removeEventListener("scroll",g),v?.disconnect()}},[o,x,t,e]),Eh(()=>{if(!o||!m||!l.current)return;let b=u.current,g=t!==b.length,v=n!==b.loading;u.current={length:t,loading:n},!(!g&&!v)&&f(n?"auto":"smooth")},[o,m,n,t,f]),{messagesEndRef:r,showScrollToBottom:p,showTopFade:i,scrollToBottom:f}}import{useCallback as Yn,useRef as _h,useState as Ms}from"react";import{convertMessagesToProvider as BS}from"@mcp-use/agent";function Ol(e){return BS(e)}var zl=e=>{let t=[];for(let n of e){if(n.error||n.result?.isError){let r={id:`prompt-error-${n.promptName}-${n.timestamp}`,role:"assistant",content:n.error||"Prompt execution failed",timestamp:n.timestamp};t.push(r);continue}let o=n.result;if(o&&"messages"in o&&Array.isArray(o.messages))for(let r of o.messages){let s="",a=[];if(typeof r.content=="string")s=r.content;else if(Array.isArray(r.content)){let d=[];for(let l of r.content)l.type==="text"&&l.text?d.push(l.text):l.type==="image"&&l.data?a.push({type:"image",data:l.data,mimeType:l.mimeType||"image/png"}):l.type==="resource"&&d.push(`[Resource: ${l.resource?.uri||"embedded"}]`);s=d.join(`
|
|
200
|
+
`)}else r.content&&typeof r.content=="object"&&(r.content.type==="text"&&r.content.text?s=r.content.text:r.content.type==="image"&&r.content.data?a.push({type:"image",data:r.content.data,mimeType:r.content.mimeType||"image/png"}):s=JSON.stringify(r.content));!s&&a.length===0&&(s="[no content]");let i={id:`prompt-${n.promptName}-${n.timestamp}-${t.length}`,role:r.role,content:s||"",timestamp:n.timestamp,attachments:a.length>0?a:void 0};t.push(i)}}return t};function Bl(e){if(!e)return;let t=Lh(e);if(t)return t;let n=[],o=!1,r=!1;for(let a of e){if(o){r?r=!1:a==="\\"?r=!0:a==='"'&&(o=!1);continue}a==='"'?o=!0:a==="{"?n.push("}"):a==="["?n.push("]"):(a==="}"||a==="]")&&n[n.length-1]===a&&n.pop()}let s=e;return o&&r&&(s=s.slice(0,-1)),o&&(s+='"'),s+=[...n].reverse().join(""),Lh(s)}function Lh(e){try{let t=JSON.parse(e);return t!==null&&!Array.isArray(t)&&typeof t=="object"?t:void 0}catch{return}}function Nu({mcpServerUrl:e,llmConfig:t,authConfig:n,mcpAuthTokens:o,isConnected:r,chatApiUrl:s,waitForChatApiUrl:a,widgetModelContexts:i,initialMessages:d,disabledTools:l,streamProtocol:u="sse",credentials:h,extraHeaders:c,body:m}){let[p,x]=Ms(d??[]),[f,b]=Ms(!1),[g,v]=Ms([]),[y,w]=Ms(ur),[N,T]=Ms(null),[L,P]=Ms(null),R=_h(null),D=_h(0),k=Yn(O=>{let W={...O,id:`trace-${++D.current}`,timestamp:Date.now()};w(j=>Ll(j,W))},[]),S=Yn(async(O,W,j)=>{let U=[...g,...j??[]];if(!(O.trim()||W.length>0||U.length>0)||!t||!r)return;let Pe=[...zl(W)];if(O.trim()||U.length>0){let le={id:`user-${Date.now()}`,role:"user",content:O.trim(),timestamp:Date.now(),attachments:U.length>0?U:void 0};Pe.push(le)}x(le=>[...le,...Pe]),b(!0),v([]),R.current=new AbortController;try{let le=n,de=n?.type==="bearer"&&!!n.token,De=n?.type==="basic"&&!!(n.username||n.password);if(!de&&!De)if(o?.access_token)le={type:"oauth",oauthTokens:o};else try{let re="mcp:auth",pe=Yi(e),Ze=`${re}_${pe}_tokens`,We=localStorage.getItem(Ze);if(We){let J=JSON.parse(We);J?.access_token&&(le={type:"oauth",oauthTokens:J})}}catch(re){console.warn("Failed to retrieve OAuth tokens:",re)}let Re=[];if(i&&i.size>0){let re=[];for(let[,pe]of i)pe&&(pe.content?.length?re.push(pe.content.map(Ze=>Ze.text).join(`
|
|
201
201
|
`)):pe.structuredContent&&re.push(JSON.stringify(pe.structuredContent)));re.length>0&&Re.push({id:`widget-context-${Date.now()}`,role:"user",content:`[Current Widget State]
|
|
202
202
|
${re.join(`
|
|
203
|
-
`)}`,timestamp:Date.now()})}let Oe=[...p,...Pe,...Re],Be=[...Oe.map(re=>({role:re.role,content:re.content||(re.parts?.filter(pe=>pe.type==="text").map(pe=>pe.text).join("")??""),attachments:re.attachments}))],tt=s??(a?await a():void 0)??
|
|
204
|
-
`);at=Ze.pop()||"";for(let We of Ze)if(We.trim())try{if(u==="data-stream"){let J=We.indexOf(":");if(J===-1)continue;let $e=We.slice(0,J),Q=We.slice(J+1),ee;try{ee=JSON.parse(Q)}catch{continue}switch($e){case"0":{let me=typeof ee=="string"?ee:String(ee);k({type:"text-delta",delta:me,raw:ee}),Bt(me);break}case"b":{let me=ee,xe=String(me.toolCallId??`tool-${M.length}`),he=String(me.toolName??"");k({type:"tool-call-start",toolCallId:xe,toolName:he,raw:ee}),mn(xe,he);break}case"c":{let me=ee,xe=String(me.toolCallId??""),he=String(me.argsTextDelta??me.argsDelta??"");mo(xe,he);break}case"9":{let me=ee,xe=me.args??{};if(typeof xe.input=="string"&&Object.keys(xe).length===1)try{let ht=JSON.parse(xe.input);typeof ht=="object"&&ht!==null&&(xe=ht)}catch{}let he=String(me.toolCallId??`tool-${M.length}`),et=String(me.toolName??"");It.has(he)||k({type:"tool-call-start",toolCallId:he,toolName:et,raw:ee}),k({type:"tool-call-args",toolCallId:he,toolName:et,args:xe,raw:ee}),
|
|
203
|
+
`)}`,timestamp:Date.now()})}let Oe=[...p,...Pe,...Re],Be=[...Oe.map(re=>({role:re.role,content:re.content||(re.parts?.filter(pe=>pe.type==="text").map(pe=>pe.text).join("")??""),attachments:re.attachments}))],tt=s??(a?await a():void 0)??Mm("chat/stream"),V=m?m(Be):{mcpServerUrl:e,llmConfig:t,authConfig:le,messages:Be,...l&&l.size>0?{disabledTools:[...l]}:{}},ce=m?Al(V):{mcpServerUrl:e,llmConfig:{provider:t.provider,model:t.model,temperature:t.temperature,baseUrl:t.baseUrl},messages:Be,...l&&l.size>0?{disabledTools:[...l]}:{}};k({type:"request",request:{url:tt,protocol:u,envelope:ce,providerMessages:Ol(Oe)}});let Fe=await fetch(tt,{method:"POST",headers:{"Content-Type":"application/json",...c},signal:R.current.signal,...h?{credentials:h}:{},body:JSON.stringify(V)});if(!Fe.ok){let re=await Fe.json().catch(()=>null);if(s){let pe=fg(Fe.status,re);if(pe){T(pe);return}}if(Fe.status===401&&re?.error==="mcp_auth_required"){P({mcpServerUrl:re.mcpServerUrl??e,message:re.message});return}throw new Error(`HTTP error! status: ${Fe.status}`)}let Y=`assistant-${Date.now()}`,q="",M=[];x(re=>[...re,{id:Y,role:"assistant",content:"",timestamp:Date.now(),parts:[]}]);let Ne=Fe.body?.getReader(),gt=new TextDecoder;if(!Ne)throw new Error("No response body");let qe=()=>{x(re=>re.map(pe=>pe.id===Y?{...pe,parts:[...M]}:pe))},ut=()=>{x(re=>re.map(pe=>pe.id===Y?{...pe,parts:[...M],content:""}:pe))},Bt=re=>{q+=re;let pe=M[M.length-1];pe&&pe.type==="text"?pe.text=q:M.push({type:"text",text:q}),qe()},It=new Map,wn=new Map,mn=(re,pe)=>{q&&(q=""),!It.has(re)&&(M.push({type:"tool-invocation",toolInvocation:{toolCallId:re,toolName:pe,args:{},state:"streaming",partialArgs:{}}}),It.set(re,M.length-1),wn.set(re,""),qe())},mo=(re,pe)=>{let Ze=It.get(re);if(Ze===void 0||!pe)return;let We=(wn.get(re)??"")+pe;wn.set(re,We);let J=Bl(We),$e=M[Ze]?.toolInvocation;!J||!$e||($e.partialArgs=J,qe())},On=(re,pe,Ze)=>{q&&(q="");let We=It.get(re),J=We===void 0?void 0:M[We]?.toolInvocation;J?(J.toolName=pe,J.args=Ze,J.state="pending",J.partialArgs=void 0):(M.push({type:"tool-invocation",toolInvocation:{toolCallId:re,toolName:pe,args:Ze,state:"pending"}}),It.set(re,M.length-1)),wn.delete(re),qe()},Nt=(re,pe)=>{let Ze;re.by==="toolName"?Ze=M.find(We=>We.type==="tool-invocation"&&We.toolInvocation?.toolName===re.toolName&&!We.toolInvocation?.result):Ze=M[re.index],Ze?.toolInvocation&&(Ze.toolInvocation.result=pe,Ze.toolInvocation.state=pe?.isError?"error":"result",qe())},at="";for(;;){if(R.current?.signal.aborted){await Ne.cancel();break}let{done:re,value:pe}=await Ne.read();if(re)break;at+=gt.decode(pe,{stream:!0});let Ze=at.split(`
|
|
204
|
+
`);at=Ze.pop()||"";for(let We of Ze)if(We.trim())try{if(u==="data-stream"){let J=We.indexOf(":");if(J===-1)continue;let $e=We.slice(0,J),Q=We.slice(J+1),ee;try{ee=JSON.parse(Q)}catch{continue}switch($e){case"0":{let me=typeof ee=="string"?ee:String(ee);k({type:"text-delta",delta:me,raw:ee}),Bt(me);break}case"b":{let me=ee,xe=String(me.toolCallId??`tool-${M.length}`),he=String(me.toolName??"");k({type:"tool-call-start",toolCallId:xe,toolName:he,raw:ee}),mn(xe,he);break}case"c":{let me=ee,xe=String(me.toolCallId??""),he=String(me.argsTextDelta??me.argsDelta??"");mo(xe,he);break}case"9":{let me=ee,xe=me.args??{};if(typeof xe.input=="string"&&Object.keys(xe).length===1)try{let ht=JSON.parse(xe.input);typeof ht=="object"&&ht!==null&&(xe=ht)}catch{}let he=String(me.toolCallId??`tool-${M.length}`),et=String(me.toolName??"");It.has(he)||k({type:"tool-call-start",toolCallId:he,toolName:et,raw:ee}),k({type:"tool-call-args",toolCallId:he,toolName:et,args:xe,raw:ee}),On(he,et,xe);break}case"a":{let me=ee,xe=It.get(me.toolCallId),he=me.result,et=he;if(et?.lc===1&&et?.type==="constructor"&&et?.kwargs?.content){let ht=et.kwargs.content;if(typeof ht=="string")try{he=JSON.parse(ht)}catch{he=ht}}xe!==void 0&&(k({type:"tool-result",toolCallId:String(me.toolCallId??""),toolName:M[xe]?.toolInvocation?.toolName??"Tool",result:he,isError:!!(he&&typeof he=="object"&&he.isError),raw:ee}),Nt({by:"index",index:xe},he));break}case"d":{let xe=Dl((ee&&typeof ee=="object"?ee:void 0)?.usage);xe&&k({type:"usage",usage:xe,raw:ee}),k({type:"done",raw:ee}),ut();break}case"3":throw k({type:"error",message:typeof ee=="string"?ee:JSON.stringify(ee),raw:ee}),new Error(typeof ee=="string"?ee:JSON.stringify(ee));default:break}}else{if(!We.startsWith("data: "))continue;let J=JSON.parse(We.slice(6));if(J.type!=="message"){if(J.type==="text")k({type:"text-delta",delta:J.content,raw:J}),Bt(J.content);else if(J.type==="tool-call-start"){let $e=J.toolCallId??`tool-${M.length}`;k({type:"tool-call-start",toolCallId:$e,toolName:J.toolName,raw:J}),mn($e,J.toolName)}else if(J.type==="tool-call-delta"||J.type==="tool-call-args-delta")mo(J.toolCallId,J.argsDelta??J.argsTextDelta??"");else if(J.type==="tool-call"){let $e=J.toolCallId??`tool-${M.length}`;It.has($e)||k({type:"tool-call-start",toolCallId:$e,toolName:J.toolName,raw:J}),k({type:"tool-call-args",toolCallId:$e,toolName:J.toolName,args:J.args,raw:J}),On($e,J.toolName,J.args)}else if(J.type==="tool-result"){k({type:"tool-result",toolCallId:J.toolCallId,toolName:J.toolName,result:J.result,isError:J.isError??J.result?.isError,raw:J});let $e=It.get(J.toolCallId);Nt($e===void 0?{by:"toolName",toolName:J.toolName}:{by:"index",index:$e},J.result)}else if(J.type==="done"){let $e=Dl(J.usage);$e&&k({type:"usage",usage:$e,raw:J}),k({type:"done",raw:J}),ut()}else if(J.type==="usage"){let $e=Dl(J.usage??J);$e&&k({type:"usage",usage:$e,raw:J})}else if(J.type==="error")throw k({type:"error",message:J.message||"Streaming error",raw:J}),new Error(J.message||"Streaming error")}}}catch(J){if(J instanceof Error&&J.message!=="Streaming error")console.error("Failed to parse streaming event:",J,We);else throw J}}if(R.current?.signal.aborted){for(let re of M)re.type==="tool-invocation"&&(re.toolInvocation?.state==="pending"||re.toolInvocation?.state==="streaming")&&(re.toolInvocation.state="error",re.toolInvocation.result="Cancelled by user");x(re=>re.map(pe=>pe.id===Y?{...pe,parts:[...M],content:""}:pe))}}catch(le){if(le instanceof DOMException&&le.name==="AbortError")return;if(s&&wa(le)){T({kind:"cloud_unavailable"});return}let de="Unknown error occurred";if(le instanceof Error){de=le.message;let Re=le;Re.status&&(de=`HTTP ${Re.status}: ${de}`),(Re.code===401||de.includes("401")||de.includes("Unauthorized"))&&(de="Authentication failed (401). Check your Authorization header in the connection settings.")}let De={id:`error-${Date.now()}`,role:"assistant",content:`Error: ${de}`,timestamp:Date.now()};x(Re=>[...Re,De])}finally{b(!1),R.current=null}},[t,r,e,p,n,o,g,s,a,i,l,u,h,c,m,k]),A=Yn(()=>{x([]),T(null),P(null),w(ur)},[]),_=Yn(()=>{T(null)},[]),K=Yn(O=>{T(O)},[]),$=Yn(()=>w(ur),[]),oe=Yn(()=>{P(null)},[]),ae=Yn(()=>{R.current&&R.current.abort()},[]),ie=Yn(async O=>{try{let W=await Xi(O);v(j=>{let U=[...j,W];return Qi(U)?U:(alert("Total attachment size exceeds 20MB limit"),j)})}catch(W){W instanceof Error?alert(W.message):alert("Failed to add attachment")}},[]),ne=Yn(O=>{v(W=>W.filter((j,U)=>U!==O))},[]),z=Yn(()=>{v([])},[]);return{messages:p,isLoading:f,attachments:g,managedChatNotice:N,mcpServerAuthRequired:L,sendMessage:S,clearMessages:A,clearManagedChatNotice:_,showManagedChatNotice:K,clearMcpServerAuthRequired:oe,setMessages:x,stop:ae,addAttachment:ie,removeAttachment:ne,clearAttachments:z,clearTrace:$,traceEvents:y.events,tokenUsage:y.usage}}import{MCPAgent as HS,providerConfigFromOptions as US}from"@mcp-use/agent";import{useCallback as uo,useEffect as FS,useRef as Oh,useState as Ba}from"react";function ku({connection:e,llmConfig:t,isConnected:n,readResource:o,widgetModelContexts:r,disabledTools:s,initialMessages:a,systemPrompt:i=jr}){let[d,l]=Ba(a??[]),[u,h]=Ba(!1),[c,m]=Ba([]),[p,x]=Ba(ur),[f,b]=Ba(null),g=Oh(null),v=Oh(0),y=uo(A=>{let _={...A,id:`trace-${++v.current}`,timestamp:Date.now()};x(K=>Ll(K,_))},[]);FS(()=>{a!==void 0&&l(a)},[a]);let w=uo(async(A,_,K)=>{let $=[...c,...K??[]];if(!(A.trim()||_.length>0||$.length>0)||!t||!n)return;let ae=zl(_),ie={id:`user-${Date.now()}`,role:"user",content:A.trim(),timestamp:Date.now(),attachments:$.length>0?$:void 0},ne=[...ae];(A.trim()||$.length>0)&&ne.push(ie),l(j=>[...j,...ne]),h(!0),m([]),g.current=new AbortController;let z=Date.now(),O=0,W=`assistant-${Date.now()}`;try{let j="",U=[],H=new Map,Te=0,Pe=80,le=async()=>{let V=Date.now();V-Te>=Pe&&(Te=V,await new Promise(ce=>setTimeout(ce,0)))};l(V=>[...V,{id:W,role:"assistant",content:"",timestamp:Date.now(),parts:[]}]);let de=[];if(r&&r.size>0){let V=[];for(let[,ce]of r)ce&&(ce.content?.length?V.push(ce.content.map(Fe=>Fe.text).join(`
|
|
205
205
|
`)):ce.structuredContent&&V.push(JSON.stringify(ce.structuredContent)));V.length>0&&de.push({id:`widget-context-${Date.now()}`,role:"user",content:`[Current Widget State]
|
|
206
206
|
${V.join(`
|
|
207
|
-
`)}`,timestamp:Date.now()})}let De=(ie.attachments?.length??0)>0,Re=[...d,...ae,...de,...A.trim()||De?[ie]:[]],Oe=Ol(Re);y({type:"request",request:{provider:t.provider,model:t.model,messages:Oe}});let Be=new US({llm:FS(t.provider,t.model,{apiKey:t.apiKey,temperature:t.temperature,baseUrl:t.baseUrl,credentials:t.credentials}),mcpServers:[e],systemPrompt:i,disallowedTools:s?[...s]:void 0,maxSteps:10,autoInitialize:!0}),tt=()=>{l(V=>V.map(ce=>ce.id===W?{...ce,parts:[...U]}:ce))};for await(let V of Be.streamEvents({messages:Oe,signal:g.current?.signal})){if(g.current?.signal.aborted)break;if(V.type==="usage"){let ce=V;y({type:"usage",usage:ce.usage,raw:ce});continue}if(V.type==="text-delta"){y({type:"text-delta",delta:V.delta,raw:V}),j+=V.delta;let ce=U[U.length-1];ce&&ce.type==="text"?ce.text=j:U.push({type:"text",text:j}),tt()}else if(V.type==="tool-call-start")y({type:"tool-call-start",toolCallId:V.toolCallId,toolName:V.toolName,raw:V}),j&&(j=""),H.set(V.toolCallId,{accumulatedJson:""}),U.push({type:"tool-invocation",toolInvocation:{toolCallId:V.toolCallId,toolName:V.toolName,args:{},state:"streaming",partialArgs:{}}}),tt();else if(V.type==="tool-call-args-delta"){let ce=H.get(V.toolCallId);if(ce){ce.accumulatedJson+=V.argsDelta;let Fe=Bl(ce.accumulatedJson);if(Fe){let Y=U.find(q=>q.type==="tool-invocation"&&q.toolInvocation?.state==="streaming"&&q.toolInvocation?.toolCallId===V.toolCallId);Y&&Y.toolInvocation&&(Y.toolInvocation.partialArgs=Fe,tt(),await le())}}}else if(V.type==="tool-call-ready"){y({type:"tool-call-args",toolCallId:V.toolCallId,toolName:V.toolName,args:V.args,raw:V}),O++,j&&(j="");let ce=U.find(Fe=>Fe.type==="tool-invocation"&&Fe.toolInvocation?.state==="streaming"&&Fe.toolInvocation?.toolCallId===V.toolCallId);ce&&ce.toolInvocation?(ce.toolInvocation.args=V.args,ce.toolInvocation.state="pending",ce.toolInvocation.partialArgs=void 0):U.push({type:"tool-invocation",toolInvocation:{toolCallId:V.toolCallId,toolName:V.toolName,args:V.args,state:"pending"}}),tt()}else if(V.type==="tool-result"){y({type:"tool-result",toolCallId:V.toolCallId,toolName:V.toolName,result:V.result,isError:V.isError,raw:V});let ce=U.find(Fe=>Fe.type==="tool-invocation"&&Fe.toolInvocation?.toolCallId===V.toolCallId&&!Fe.toolInvocation?.result);ce&&ce.toolInvocation&&(ce.toolInvocation.result=V.result,ce.toolInvocation.state=V.isError||V.result?.isError?"error":"result",tt())}else if(V.type==="done")y({type:"done",raw:V});else if(V.type==="error")throw y({type:"error",message:V.message,raw:V}),new Error(V.message)}if(g.current?.signal.aborted)for(let V of U)V.type==="tool-invocation"&&(V.toolInvocation?.state==="pending"||V.toolInvocation?.state==="streaming")&&(V.toolInvocation.state="error",V.toolInvocation.result="Cancelled by user");l(V=>V.map(ce=>ce.id===W?{...ce,parts:[...U],content:""}:ce)),t&&Lt(new $s({serverId:e.url,provider:t.provider,model:t.model,messageCount:d.length+1,toolCallsCount:O,success:!0,executionMode:"client-side",duration:Date.now()-z})).catch(()=>{})}catch(j){if(j instanceof DOMException&&j.name==="AbortError")return;let U=fg(t)?gg(j):null;if(U){b(U),l(Pe=>Pe.filter(le=>le.id!==W));return}console.error("Client-side agent error:",j);let H="Unknown error occurred";if(j instanceof Error){H=j.message;let Pe=j;Pe.status&&(H=`HTTP ${Pe.status}: ${H}`),(Pe.code===401||H.includes("401")||H.includes("Unauthorized"))&&(H="Authentication failed (401). Check your Authorization header in the connection settings.")}t&&Lt(new $s({serverId:e.url,provider:t.provider,model:t.model,messageCount:d.length+1,toolCallsCount:O,success:!1,executionMode:"client-side",duration:Date.now()-z,error:H})).catch(()=>{});let Te={id:`error-${Date.now()}`,role:"assistant",content:`Error: ${H}`,timestamp:Date.now()};l(Pe=>[...Pe,Te])}finally{h(!1),g.current=null}},[e,t,n,d,o,c,s,r,y,i]),N=uo(()=>{l([]),x(ur),b(null)},[]),T=uo(()=>x(ur),[]),L=uo(()=>{g.current&&g.current.abort()},[]),P=uo(async A=>{try{let _=await Xi(A);m(K=>{let $=[...K,_];return Qi($)?$:(alert("Total attachment size exceeds 20MB limit"),K)})}catch(_){_ instanceof Error?alert(_.message):alert("Failed to add attachment")}},[]),R=uo(A=>{m(_=>_.filter((K,$)=>$!==A))},[]),D=uo(()=>{m([])},[]),k=uo(()=>{b(null)},[]),S=uo(A=>{b(A)},[]);return{messages:d,isLoading:u,attachments:c,managedChatNotice:f,sendMessage:w,clearMessages:N,clearManagedChatNotice:k,showManagedChatNotice:S,setMessages:l,stop:L,addAttachment:P,removeAttachment:R,clearAttachments:D,clearTrace:T,traceEvents:p.events,tokenUsage:p.usage}}import{useCallback as VS,useState as jS}from"react";function Bh({useClientSide:e,managedLlmConfig:t,localLlmConfig:n}){let o=!e&&t!=null,[r,s]=jS(()=>Df(o,n)),a=VS(u=>{Zi(u?"byok":"managed"),s(u)},[]),i=o?r:e||r||!!n,d=!!t&&!r;return{forceClientSide:r,setForceClientSide:a,effectiveClientSide:i,llmConfig:d?t??null:n??t??null,isManaged:d,hostUsesServerManagedStream:o}}import{AlertCircle as qS,RefreshCw as WS}from"lucide-react";import{useCallback as KS,useState as JS}from"react";import{jsx as Is,jsxs as Ha}from"react/jsx-runtime";function Hh({serverName:e,serverUrl:t,message:n,onReconnect:o,onDismiss:r}){let[s,a]=JS(!1),i=KS(async()=>{a(!0);try{await o()}finally{a(!1)}},[o]),d=e;if(!d)try{d=new URL(t).host}catch{d=t}return Is("div",{className:"w-full flex justify-center items-center px-2 sm:px-4 mb-2",children:Ha("div",{role:"alert",className:"w-full max-w-3xl flex items-start gap-3 rounded-md border border-amber-300/60 bg-amber-50 px-3 py-2 text-sm text-amber-900 dark:border-amber-500/40 dark:bg-amber-950/40 dark:text-amber-100",children:[Is(qS,{className:"mt-0.5 size-4 shrink-0","aria-hidden":!0}),Ha("div",{className:"flex-1 min-w-0",children:[Ha("div",{className:"font-medium",children:["Reconnect to ",Is("span",{className:"font-semibold",children:d})]}),Is("div",{className:"text-xs opacity-90",children:n??"The MCP server rejected your credentials. Reconnect to refresh them."})]}),Ha("div",{className:"flex items-center gap-1",children:[Ha(E,{size:"sm",variant:"default",onClick:i,disabled:s,children:[Is(WS,{className:`size-3.5 ${s?"animate-spin":""}`,"aria-hidden":!0}),s?"Reconnecting\u2026":"Reconnect"]}),r&&Is(E,{size:"sm",variant:"ghost",onClick:r,"aria-label":"Dismiss",children:"Dismiss"})]})]})})}import{Fragment as Ua,jsx as Wr,jsxs as Es}from"react/jsx-runtime";function Uh({notice:e,onConfigureApiKey:t,onSignIn:n,authorizing:o=!1}){return Wr("div",{className:"mb-2 flex w-full justify-center px-2 sm:px-4",children:Es("p",{role:"status","data-testid":"chat-managed-notice",className:"max-w-3xl rounded-md border border-amber-300/60 bg-amber-50 px-3 py-2 text-center text-sm text-amber-900 dark:border-amber-500/40 dark:bg-amber-950/40 dark:text-amber-100",children:[e.kind==="cloud_unavailable"&&Es(Ua,{children:["Cloud chat is currently not available."," ",Wr(Pu,{onClick:t})]}),e.kind==="login_required"&&Es(Ua,{children:["Sign in through Manufact Cloud to continue with managed chat."," ",n&&Es(Ua,{children:[Wr(E,{type:"button",variant:"link",size:"sm",className:"h-auto px-0 align-baseline text-sm text-amber-900 hover:text-amber-700 dark:text-amber-100 dark:hover:text-amber-200",disabled:o,onClick:n,children:o?"Authorizing\u2026":"Sign in"})," \xB7 "]}),Wr(Pu,{onClick:t})]}),e.kind==="credits_exhausted"&&Es(Ua,{children:[e.message??"You've used your included free plan credits for managed chat."," ",e.billingUrl&&Es(Ua,{children:[Wr("a",{href:e.billingUrl,target:"_blank",rel:"noopener noreferrer",className:"underline underline-offset-2 hover:text-amber-700 dark:hover:text-amber-200",children:"Upgrade your plan"})," \xB7 "]}),Wr(Pu,{onClick:t})]})]})})}function Pu({onClick:e}){return Wr("button",{type:"button",onClick:e,className:"underline underline-offset-2 hover:text-amber-700 dark:hover:text-amber-200","data-testid":"chat-managed-notice-configure-link",children:"Configure your own API key"})}import{jsx as Ru}from"react/jsx-runtime";function Fh({events:e,usage:t}){if(e.length===0)return Ru("p",{className:"py-12 text-center text-sm text-muted-foreground",children:"Raw request/response data will appear after the next message."});let n=Cu(e,t);return Ru("div",{className:"mx-auto max-w-4xl","data-testid":"chat-raw-view",children:Ru(wt,{data:n,filename:"chat-raw.json",collapsible:!0,defaultExpanded:!1})})}import{useCallback as GS,useEffect as YS,useState as $h}from"react";function Fa(e){return`mcp-inspector-system-prompt:${e}`}function Mu(e){return typeof localStorage>"u"?null:localStorage.getItem(Fa(e))}function Iu(e,t){localStorage.setItem(Fa(e),t)}function Eu(e){return e?.trim()||jr}function Vh(e){let[t,n]=$h(null),[o,r]=$h(!1),s=Fa(e);YS(()=>{let i=()=>{n(Mu(e))};i();let d=l=>{l.key===s&&i()};return window.addEventListener("storage",d),()=>window.removeEventListener("storage",d)},[e,s]);let a=GS(async i=>{r(!0);try{Iu(e,i),n(i)}finally{r(!1)}},[e]);return{prompt:t,savePrompt:a,isSaving:o}}import{jsx as ft,jsxs as pr}from"react/jsx-runtime";var XS=/(?:^\/$|\s+\/$)/,ZS=["ArrowDown","ArrowUp","Escape","Enter"];function eT({connection:e,isConnected:t,useClientSide:n=!0,enableKeyboardShortcuts:o=!0,prompts:r,serverId:s,callPrompt:a,readResource:i,chatApiUrl:d,waitForChatApiUrl:l,initialMessages:u,managedLlmConfig:h,managedCloudModel:c,enableFreeTierUpgrade:m=!1,clearButtonLabel:p,hideTitle:x,hideModelBadge:f,clearButtonHideIcon:b,clearButtonHideShortcut:g,clearButtonVariant:v,hideClearButton:y,hideToolSelector:w,chatQuickQuestions:N=[],chatFollowups:T=[],streamProtocol:L,credentials:P,extraHeaders:R,body:D,chatStorageProvider:k,enableChatHistory:S,activeChatId:A,onActiveChatIdChange:_,titleGenerationReady:K,activeChatTitle:$,onChatTitleGenerated:oe,defaultView:ae="conv",systemPromptProvider:ie,elevatedHeader:ne}){let{isEmbedded:z}=wo(),O=Vh(s),W=ie??O,j=jh(()=>Eu(W.prompt),[W.prompt]),U=Hl(new ya),H=k??(!z&&S!==!1?U.current:null),[Te,Pe]=xn(null),le=A??Te,de=je(B=>{_?_(B):Pe(B)},[_]),[De,Re]=xn(!1),[Oe,Be]=xn(0),[tt,V]=xn(),[ce,Fe]=xn(void 0),[Y,q]=xn(""),[M,Ne]=xn(!1),[gt,qe]=xn(-1),[ut,Bt]=xn(N),[It,wn]=xn(T),[mn,mo]=xn(ae),[zn,Nt]=xn(new Set),at=Hl(null),re=Hl(null),pe=Hl(null),Ze=jh(()=>(e.tools??[]).map(B=>({name:B.name,description:B.description})),[e.tools]),{llmConfig:We,authConfig:J,configDialogOpen:$e,setConfigDialogOpen:Q,tempProvider:ee,setTempProvider:me,tempApiKey:xe,setTempApiKey:he,tempModel:et,setTempModel:ht,tempBaseUrl:Yt,setTempBaseUrl:Dt,saveLLMConfig:vt,clearConfig:Kr}=ua({mcpServerUrl:e.url??""}),{setForceClientSide:po,effectiveClientSide:kt,llmConfig:He,isManaged:fo}=Bh({useClientSide:n,managedLlmConfig:h,localLlmConfig:We}),{getAllModelContexts:Ul}=Vo(),$a=Ul(),Fl={connection:e,llmConfig:He,isConnected:t,readResource:i,widgetModelContexts:$a,disabledTools:zn},Bn=Su({mcpServerUrl:e.url??"",llmConfig:He,authConfig:J,mcpAuthTokens:e.authTokens,isConnected:t,chatApiUrl:d,waitForChatApiUrl:l,widgetModelContexts:$a,initialMessages:ce??u,disabledTools:zn,streamProtocol:L,credentials:P,extraHeaders:R,body:D}),Xn=Tu({...Fl,initialMessages:ce??u,systemPrompt:j}),{messages:Ye,isLoading:nn,attachments:fr,sendMessage:Cn,clearMessages:gr,setMessages:I,stop:Z,addAttachment:Se,removeAttachment:ct,clearTrace:St,traceEvents:dt,tokenUsage:bt}=kt?Xn:Bn,[Hn,pn]=xn(()=>Ye.length===0?"visible":"hidden"),Zn=je(()=>{pn(B=>B==="visible"?"fading":B)},[]),Va=je(()=>{gr(),pn("visible")},[gr]),{messagesEndRef:qh,showScrollToBottom:Wh,showTopFade:Kh,scrollToBottom:Jh}=Lh(re,{messageCount:Ye.length,isLoading:nn,enabled:!!He}),Gh=je(async B=>{if(!H)return;let[ue,ge]=await Promise.all([H.getMessages(B),H.listChats({agentId:s})]);Fe(ue),St(),I(ue),pn(ue.length===0?"visible":"hidden"),de(B),V(ge.items.find(mt=>mt.id===B)?.title)},[H,St,I,de,s]),Ds=je(async()=>{if(gr(),Fe([]),pn("visible"),V(zr),de(null),H){let B=await H.createChat({agentId:s,agentName:e.displayName||e.name||"MCP Server"});de(B.id),Be(ue=>ue+1)}else V(void 0)},[gr,H,s,e.displayName,e.name,de]),Au=je(async()=>{if(!H||le)return le;let B=await H.createChat({agentId:s,agentName:e.displayName||e.name||"MCP Server"});return de(B.id),V(zr),Be(ue=>ue+1),B.id},[H,le,s,e.displayName,e.name,de]);mr(()=>{!H?.saveMessages||!le||H.saveMessages(le,Ye)},[H,le,Ye]);let Yh=je(()=>{Be(B=>B+1)},[]),Qh=je((B,ue)=>{V(ue),oe?.(B,ue)},[oe]),ja=$??tt,Xh=ja&&!sr(ja)?ja:rr;Dd({activeChatId:le,storage:H,messages:Ye,isLoading:nn,effectiveClientSide:kt,llmConfig:He,activeChatTitle:ja,titleGenerationReady:K,onTitleGenerated:Qh,onHistoryRefetch:Yh});let Eo=Xn.managedChatNotice??Bn.managedChatNotice??null,Jr=je(()=>{Xn.clearManagedChatNotice(),Bn.clearManagedChatNotice()},[Xn.clearManagedChatNotice,Bn.clearManagedChatNotice]),Du=je(B=>{Xn.showManagedChatNotice(B),Bn.showManagedChatNotice(B)},[Xn.showManagedChatNotice,Bn.showManagedChatNotice]),Lu=je(()=>{vt()&&(po(!0),Jr())},[vt,po,Jr]),Ls=kt?null:Bn.mcpServerAuthRequired??null,$l=kt?void 0:Bn.clearMcpServerAuthRequired,Zh=je(async()=>{try{await e.authenticate()}catch(B){console.error("[ChatTab] MCP reconnect failed:",B),As.error(B instanceof Error?`Reconnect failed: ${B.message}`:"Reconnect failed");return}$l?.()},[e,$l]),_u=Ls?ft(Hh,{serverName:e.name,serverUrl:Ls.mcpServerUrl,message:Ls.message,onReconnect:Zh,onDismiss:$l}):null,ev=je(()=>{Q(!0)},[Q]),{user:tv,authorizing:nv,authorize:Ou}=Rg(m?d:void 0),zu=je(()=>{Q(!1),Ou().catch(B=>{if(d&&wa(B)){Du({kind:"cloud_unavailable"});return}As.error(B instanceof Error?B.message:"Authorization failed")})},[Ou,d,Q,Du]),qa=tv!=null;mr(()=>{qa&&Eo?.kind==="login_required"&&Jr()},[Jr,qa,Eo?.kind]);let Wa=m&&!qa?{onLoginClick:zu}:void 0,Bu=!!h&&!!f,Hu=Bu,Gr=m&&qa&&c?{models:c.models,selectedModelId:c.selectedModelId,onModelChange:c.setSelectedModelId,isLoading:c.isLoading}:void 0,Uu=fo?"managed":"byok",Fu=fo&&c?.selectedModel?Ca(c.selectedModel.name,c.selectedModel.provider):void 0,$u=je(()=>{po(!1),Jr(),Q(!1)},[Jr,Q,po]),{filteredPrompts:go,setSelectedPrompt:Vl,selectedPrompt:Vu,setPromptArgs:ov,executePrompt:ju,results:_s,handleDeleteResult:qu,clearPromptResults:Wu}=ha({prompts:r,callPrompt:a,serverId:s}),jl=je(B=>Array.isArray(B)?B.filter(ue=>typeof ue=="string").map(ue=>ue.trim()).filter(Boolean).slice(0,8):[],[]),Yr=je(B=>{if(typeof B.content=="string"&&B.content.trim())return B.content;if(Array.isArray(B.content)&&B.content.length>0)return B.content.map(ue=>typeof ue=="string"?ue:ue.text??"").join("");if(B.parts&&B.parts.length>0){let ue=B.parts.filter(ge=>ge.type==="text"&&ge.text).map(ge=>ge.text);if(ue.length>0)return ue.join(`
|
|
208
|
-
`)}return""},[]),
|
|
207
|
+
`)}`,timestamp:Date.now()})}let De=(ie.attachments?.length??0)>0,Re=[...d,...ae,...de,...A.trim()||De?[ie]:[]],Oe=Ol(Re);y({type:"request",request:{provider:t.provider,model:t.model,messages:Oe}});let Be=new HS({llm:US(t.provider,t.model,{apiKey:t.apiKey,temperature:t.temperature,baseUrl:t.baseUrl,credentials:t.credentials}),mcpServers:[e],systemPrompt:i,disallowedTools:s?[...s]:void 0,maxSteps:10,autoInitialize:!0}),tt=()=>{l(V=>V.map(ce=>ce.id===W?{...ce,parts:[...U]}:ce))};for await(let V of Be.streamEvents({messages:Oe,signal:g.current?.signal})){if(g.current?.signal.aborted)break;if(V.type==="usage"){let ce=V;y({type:"usage",usage:ce.usage,raw:ce});continue}if(V.type==="text-delta"){y({type:"text-delta",delta:V.delta,raw:V}),j+=V.delta;let ce=U[U.length-1];ce&&ce.type==="text"?ce.text=j:U.push({type:"text",text:j}),tt()}else if(V.type==="tool-call-start")y({type:"tool-call-start",toolCallId:V.toolCallId,toolName:V.toolName,raw:V}),j&&(j=""),H.set(V.toolCallId,{accumulatedJson:""}),U.push({type:"tool-invocation",toolInvocation:{toolCallId:V.toolCallId,toolName:V.toolName,args:{},state:"streaming",partialArgs:{}}}),tt();else if(V.type==="tool-call-args-delta"){let ce=H.get(V.toolCallId);if(ce){ce.accumulatedJson+=V.argsDelta;let Fe=Bl(ce.accumulatedJson);if(Fe){let Y=U.find(q=>q.type==="tool-invocation"&&q.toolInvocation?.state==="streaming"&&q.toolInvocation?.toolCallId===V.toolCallId);Y&&Y.toolInvocation&&(Y.toolInvocation.partialArgs=Fe,tt(),await le())}}}else if(V.type==="tool-call-ready"){y({type:"tool-call-args",toolCallId:V.toolCallId,toolName:V.toolName,args:V.args,raw:V}),O++,j&&(j="");let ce=U.find(Fe=>Fe.type==="tool-invocation"&&Fe.toolInvocation?.state==="streaming"&&Fe.toolInvocation?.toolCallId===V.toolCallId);ce&&ce.toolInvocation?(ce.toolInvocation.args=V.args,ce.toolInvocation.state="pending",ce.toolInvocation.partialArgs=void 0):U.push({type:"tool-invocation",toolInvocation:{toolCallId:V.toolCallId,toolName:V.toolName,args:V.args,state:"pending"}}),tt()}else if(V.type==="tool-result"){y({type:"tool-result",toolCallId:V.toolCallId,toolName:V.toolName,result:V.result,isError:V.isError,raw:V});let ce=U.find(Fe=>Fe.type==="tool-invocation"&&Fe.toolInvocation?.toolCallId===V.toolCallId&&!Fe.toolInvocation?.result);ce&&ce.toolInvocation&&(ce.toolInvocation.result=V.result,ce.toolInvocation.state=V.isError||V.result?.isError?"error":"result",tt())}else if(V.type==="done")y({type:"done",raw:V});else if(V.type==="error")throw y({type:"error",message:V.message,raw:V}),new Error(V.message)}if(g.current?.signal.aborted)for(let V of U)V.type==="tool-invocation"&&(V.toolInvocation?.state==="pending"||V.toolInvocation?.state==="streaming")&&(V.toolInvocation.state="error",V.toolInvocation.result="Cancelled by user");l(V=>V.map(ce=>ce.id===W?{...ce,parts:[...U],content:""}:ce)),t&&Lt(new $s({serverId:e.url,provider:t.provider,model:t.model,messageCount:d.length+1,toolCallsCount:O,success:!0,executionMode:"client-side",duration:Date.now()-z})).catch(()=>{})}catch(j){if(j instanceof DOMException&&j.name==="AbortError")return;let U=mg(t)?pg(j):null;if(U){b(U),l(Pe=>Pe.filter(le=>le.id!==W));return}console.error("Client-side agent error:",j);let H="Unknown error occurred";if(j instanceof Error){H=j.message;let Pe=j;Pe.status&&(H=`HTTP ${Pe.status}: ${H}`),(Pe.code===401||H.includes("401")||H.includes("Unauthorized"))&&(H="Authentication failed (401). Check your Authorization header in the connection settings.")}t&&Lt(new $s({serverId:e.url,provider:t.provider,model:t.model,messageCount:d.length+1,toolCallsCount:O,success:!1,executionMode:"client-side",duration:Date.now()-z,error:H})).catch(()=>{});let Te={id:`error-${Date.now()}`,role:"assistant",content:`Error: ${H}`,timestamp:Date.now()};l(Pe=>[...Pe,Te])}finally{h(!1),g.current=null}},[e,t,n,d,o,c,s,r,y,i]),N=uo(()=>{l([]),x(ur),b(null)},[]),T=uo(()=>x(ur),[]),L=uo(()=>{g.current&&g.current.abort()},[]),P=uo(async A=>{try{let _=await Xi(A);m(K=>{let $=[...K,_];return Qi($)?$:(alert("Total attachment size exceeds 20MB limit"),K)})}catch(_){_ instanceof Error?alert(_.message):alert("Failed to add attachment")}},[]),R=uo(A=>{m(_=>_.filter((K,$)=>$!==A))},[]),D=uo(()=>{m([])},[]),k=uo(()=>{b(null)},[]),S=uo(A=>{b(A)},[]);return{messages:d,isLoading:u,attachments:c,managedChatNotice:f,sendMessage:w,clearMessages:N,clearManagedChatNotice:k,showManagedChatNotice:S,setMessages:l,stop:L,addAttachment:P,removeAttachment:R,clearAttachments:D,clearTrace:T,traceEvents:p.events,tokenUsage:p.usage}}import{useCallback as $S,useState as VS}from"react";function zh({useClientSide:e,managedLlmConfig:t,localLlmConfig:n}){let o=!e&&t!=null,[r,s]=VS(()=>Ef(o,n)),a=$S(u=>{Zi(u?"byok":"managed"),s(u)},[]),i=o?r:e||r||!!n,d=!!t&&!r;return{forceClientSide:r,setForceClientSide:a,effectiveClientSide:i,llmConfig:d?t??null:n??t??null,isManaged:d,hostUsesServerManagedStream:o}}import{AlertCircle as jS,RefreshCw as qS}from"lucide-react";import{useCallback as WS,useState as KS}from"react";import{jsx as Is,jsxs as Ha}from"react/jsx-runtime";function Bh({serverName:e,serverUrl:t,message:n,onReconnect:o,onDismiss:r}){let[s,a]=KS(!1),i=WS(async()=>{a(!0);try{await o()}finally{a(!1)}},[o]),d=e;if(!d)try{d=new URL(t).host}catch{d=t}return Is("div",{className:"w-full flex justify-center items-center px-2 sm:px-4 mb-2",children:Ha("div",{role:"alert",className:"w-full max-w-3xl flex items-start gap-3 rounded-md border border-amber-300/60 bg-amber-50 px-3 py-2 text-sm text-amber-900 dark:border-amber-500/40 dark:bg-amber-950/40 dark:text-amber-100",children:[Is(jS,{className:"mt-0.5 size-4 shrink-0","aria-hidden":!0}),Ha("div",{className:"flex-1 min-w-0",children:[Ha("div",{className:"font-medium",children:["Reconnect to ",Is("span",{className:"font-semibold",children:d})]}),Is("div",{className:"text-xs opacity-90",children:n??"The MCP server rejected your credentials. Reconnect to refresh them."})]}),Ha("div",{className:"flex items-center gap-1",children:[Ha(E,{size:"sm",variant:"default",onClick:i,disabled:s,children:[Is(qS,{className:`size-3.5 ${s?"animate-spin":""}`,"aria-hidden":!0}),s?"Reconnecting\u2026":"Reconnect"]}),r&&Is(E,{size:"sm",variant:"ghost",onClick:r,"aria-label":"Dismiss",children:"Dismiss"})]})]})})}import{Fragment as Ua,jsx as Wr,jsxs as Es}from"react/jsx-runtime";function Hh({notice:e,onConfigureApiKey:t,onSignIn:n,authorizing:o=!1}){return Wr("div",{className:"mb-2 flex w-full justify-center px-2 sm:px-4",children:Es("p",{role:"status","data-testid":"chat-managed-notice",className:"max-w-3xl rounded-md border border-amber-300/60 bg-amber-50 px-3 py-2 text-center text-sm text-amber-900 dark:border-amber-500/40 dark:bg-amber-950/40 dark:text-amber-100",children:[e.kind==="cloud_unavailable"&&Es(Ua,{children:["Cloud chat is currently not available."," ",Wr(Su,{onClick:t})]}),e.kind==="login_required"&&Es(Ua,{children:["Sign in through Manufact Cloud to continue with managed chat."," ",n&&Es(Ua,{children:[Wr(E,{type:"button",variant:"link",size:"sm",className:"h-auto px-0 align-baseline text-sm text-amber-900 hover:text-amber-700 dark:text-amber-100 dark:hover:text-amber-200",disabled:o,onClick:n,children:o?"Authorizing\u2026":"Sign in"})," \xB7 "]}),Wr(Su,{onClick:t})]}),e.kind==="credits_exhausted"&&Es(Ua,{children:[e.message??"You've used your included free plan credits for managed chat."," ",e.billingUrl&&Es(Ua,{children:[Wr("a",{href:e.billingUrl,target:"_blank",rel:"noopener noreferrer",className:"underline underline-offset-2 hover:text-amber-700 dark:hover:text-amber-200",children:"Upgrade your plan"})," \xB7 "]}),Wr(Su,{onClick:t})]})]})})}function Su({onClick:e}){return Wr("button",{type:"button",onClick:e,className:"underline underline-offset-2 hover:text-amber-700 dark:hover:text-amber-200","data-testid":"chat-managed-notice-configure-link",children:"Configure your own API key"})}import{jsx as Tu}from"react/jsx-runtime";function Uh({events:e,usage:t}){if(e.length===0)return Tu("p",{className:"py-12 text-center text-sm text-muted-foreground",children:"Raw request/response data will appear after the next message."});let n=xu(e,t);return Tu("div",{className:"mx-auto max-w-4xl","data-testid":"chat-raw-view",children:Tu(wt,{data:n,filename:"chat-raw.json",collapsible:!0,defaultExpanded:!1})})}import{useCallback as JS,useEffect as GS,useState as Fh}from"react";function Fa(e){return`mcp-inspector-system-prompt:${e}`}function Pu(e){return typeof localStorage>"u"?null:localStorage.getItem(Fa(e))}function Ru(e,t){localStorage.setItem(Fa(e),t)}function Mu(e){return e?.trim()||jr}function $h(e){let[t,n]=Fh(null),[o,r]=Fh(!1),s=Fa(e);GS(()=>{let i=()=>{n(Pu(e))};i();let d=l=>{l.key===s&&i()};return window.addEventListener("storage",d),()=>window.removeEventListener("storage",d)},[e,s]);let a=JS(async i=>{r(!0);try{Ru(e,i),n(i)}finally{r(!1)}},[e]);return{prompt:t,savePrompt:a,isSaving:o}}import{jsx as ft,jsxs as pr}from"react/jsx-runtime";var QS=/(?:^\/$|\s+\/$)/,XS=["ArrowDown","ArrowUp","Escape","Enter"];function ZS({connection:e,isConnected:t,useClientSide:n=!0,enableKeyboardShortcuts:o=!0,prompts:r,serverId:s,callPrompt:a,readResource:i,chatApiUrl:d,waitForChatApiUrl:l,initialMessages:u,managedLlmConfig:h,managedCloudModel:c,enableFreeTierUpgrade:m=!1,clearButtonLabel:p,hideTitle:x,hideModelBadge:f,clearButtonHideIcon:b,clearButtonHideShortcut:g,clearButtonVariant:v,hideClearButton:y,hideToolSelector:w,chatQuickQuestions:N=[],chatFollowups:T=[],streamProtocol:L,credentials:P,extraHeaders:R,body:D,chatStorageProvider:k,enableChatHistory:S,activeChatId:A,onActiveChatIdChange:_,titleGenerationReady:K,activeChatTitle:$,onChatTitleGenerated:oe,defaultView:ae="conv",systemPromptProvider:ie,elevatedHeader:ne}){let{isEmbedded:z}=wo(),O=$h(s),W=ie??O,j=Vh(()=>Mu(W.prompt),[W.prompt]),U=Hl(new ya),H=k??(!z&&S!==!1?U.current:null),[Te,Pe]=xn(null),le=A??Te,de=je(B=>{_?_(B):Pe(B)},[_]),[De,Re]=xn(!1),[Oe,Be]=xn(0),[tt,V]=xn(),[ce,Fe]=xn(void 0),[Y,q]=xn(""),[M,Ne]=xn(!1),[gt,qe]=xn(-1),[ut,Bt]=xn(N),[It,wn]=xn(T),[mn,mo]=xn(ae),[On,Nt]=xn(new Set),at=Hl(null),re=Hl(null),pe=Hl(null),Ze=Vh(()=>(e.tools??[]).map(B=>({name:B.name,description:B.description})),[e.tools]),{llmConfig:We,authConfig:J,configDialogOpen:$e,setConfigDialogOpen:Q,tempProvider:ee,setTempProvider:me,tempApiKey:xe,setTempApiKey:he,tempModel:et,setTempModel:ht,tempBaseUrl:Yt,setTempBaseUrl:Dt,saveLLMConfig:vt,clearConfig:Kr}=ua({mcpServerUrl:e.url??""}),{setForceClientSide:po,effectiveClientSide:kt,llmConfig:He,isManaged:fo}=zh({useClientSide:n,managedLlmConfig:h,localLlmConfig:We}),{getAllModelContexts:Ul}=Vo(),$a=Ul(),Fl={connection:e,llmConfig:He,isConnected:t,readResource:i,widgetModelContexts:$a,disabledTools:On},zn=Nu({mcpServerUrl:e.url??"",llmConfig:He,authConfig:J,mcpAuthTokens:e.authTokens,isConnected:t,chatApiUrl:d,waitForChatApiUrl:l,widgetModelContexts:$a,initialMessages:ce??u,disabledTools:On,streamProtocol:L,credentials:P,extraHeaders:R,body:D}),Qn=ku({...Fl,initialMessages:ce??u,systemPrompt:j}),{messages:Ye,isLoading:nn,attachments:fr,sendMessage:Cn,clearMessages:gr,setMessages:I,stop:Z,addAttachment:Se,removeAttachment:ct,clearTrace:St,traceEvents:dt,tokenUsage:bt}=kt?Qn:zn,[Bn,pn]=xn(()=>Ye.length===0?"visible":"hidden"),Xn=je(()=>{pn(B=>B==="visible"?"fading":B)},[]),Va=je(()=>{gr(),pn("visible")},[gr]),{messagesEndRef:jh,showScrollToBottom:qh,showTopFade:Wh,scrollToBottom:Kh}=Dh(re,{messageCount:Ye.length,isLoading:nn,enabled:!!He}),Jh=je(async B=>{if(!H)return;let[ue,ge]=await Promise.all([H.getMessages(B),H.listChats({agentId:s})]);Fe(ue),St(),I(ue),pn(ue.length===0?"visible":"hidden"),de(B),V(ge.items.find(mt=>mt.id===B)?.title)},[H,St,I,de,s]),Ds=je(async()=>{if(gr(),Fe([]),pn("visible"),V(zr),de(null),H){let B=await H.createChat({agentId:s,agentName:e.displayName||e.name||"MCP Server"});de(B.id),Be(ue=>ue+1)}else V(void 0)},[gr,H,s,e.displayName,e.name,de]),Iu=je(async()=>{if(!H||le)return le;let B=await H.createChat({agentId:s,agentName:e.displayName||e.name||"MCP Server"});return de(B.id),V(zr),Be(ue=>ue+1),B.id},[H,le,s,e.displayName,e.name,de]);mr(()=>{!H?.saveMessages||!le||H.saveMessages(le,Ye)},[H,le,Ye]);let Gh=je(()=>{Be(B=>B+1)},[]),Yh=je((B,ue)=>{V(ue),oe?.(B,ue)},[oe]),ja=$??tt,Qh=ja&&!sr(ja)?ja:rr;Dd({activeChatId:le,storage:H,messages:Ye,isLoading:nn,effectiveClientSide:kt,llmConfig:He,activeChatTitle:ja,titleGenerationReady:K,onTitleGenerated:Yh,onHistoryRefetch:Gh});let Eo=Qn.managedChatNotice??zn.managedChatNotice??null,Jr=je(()=>{Qn.clearManagedChatNotice(),zn.clearManagedChatNotice()},[Qn.clearManagedChatNotice,zn.clearManagedChatNotice]),Eu=je(B=>{Qn.showManagedChatNotice(B),zn.showManagedChatNotice(B)},[Qn.showManagedChatNotice,zn.showManagedChatNotice]),Au=je(()=>{vt()&&(po(!0),Jr())},[vt,po,Jr]),Ls=kt?null:zn.mcpServerAuthRequired??null,$l=kt?void 0:zn.clearMcpServerAuthRequired,Xh=je(async()=>{try{await e.authenticate()}catch(B){console.error("[ChatTab] MCP reconnect failed:",B),As.error(B instanceof Error?`Reconnect failed: ${B.message}`:"Reconnect failed");return}$l?.()},[e,$l]),Du=Ls?ft(Bh,{serverName:e.name,serverUrl:Ls.mcpServerUrl,message:Ls.message,onReconnect:Xh,onDismiss:$l}):null,Zh=je(()=>{Q(!0)},[Q]),{user:ev,authorizing:tv,authorize:Lu}=Pg(m?d:void 0),_u=je(()=>{Q(!1),Lu().catch(B=>{if(d&&wa(B)){Eu({kind:"cloud_unavailable"});return}As.error(B instanceof Error?B.message:"Authorization failed")})},[Lu,d,Q,Eu]),qa=ev!=null;mr(()=>{qa&&Eo?.kind==="login_required"&&Jr()},[Jr,qa,Eo?.kind]);let Wa=m&&!qa?{onLoginClick:_u}:void 0,Ou=!!h&&!!f,zu=Ou,Gr=m&&qa&&c?{models:c.models,selectedModelId:c.selectedModelId,onModelChange:c.setSelectedModelId,isLoading:c.isLoading}:void 0,Bu=fo?"managed":"byok",Hu=fo&&c?.selectedModel?Ca(c.selectedModel.name,c.selectedModel.provider):void 0,Uu=je(()=>{po(!1),Jr(),Q(!1)},[Jr,Q,po]),{filteredPrompts:go,setSelectedPrompt:Vl,selectedPrompt:Fu,setPromptArgs:nv,executePrompt:$u,results:_s,handleDeleteResult:Vu,clearPromptResults:ju}=ha({prompts:r,callPrompt:a,serverId:s}),jl=je(B=>Array.isArray(B)?B.filter(ue=>typeof ue=="string").map(ue=>ue.trim()).filter(Boolean).slice(0,8):[],[]),Yr=je(B=>{if(typeof B.content=="string"&&B.content.trim())return B.content;if(Array.isArray(B.content)&&B.content.length>0)return B.content.map(ue=>typeof ue=="string"?ue:ue.text??"").join("");if(B.parts&&B.parts.length>0){let ue=B.parts.filter(ge=>ge.type==="text"&&ge.text).map(ge=>ge.text);if(ue.length>0)return ue.join(`
|
|
208
|
+
`)}return""},[]),qu=je(B=>{if(B==null)return"No result";if(typeof B=="string")try{let ue=JSON.parse(B);return JSON.stringify(ue,null,2)}catch{return B}if(typeof B=="object"&&Array.isArray(B.content)){let ue=B.content;return ue.length===0?"Empty result":ue.map(ge=>{if(ge.type==="text"){let mt=ge.text||"";try{return JSON.stringify(JSON.parse(mt),null,2)}catch{return mt}}return ge.type==="image"?`[Image: ${ge.mimeType}]`:ge.type==="resource"?`[Resource: ${ge.resource?.uri||"unknown"}]`:JSON.stringify(ge,null,2)}).join(`
|
|
209
209
|
|
|
210
|
-
`)}return JSON.stringify(B,null,2)},[]),Ka=je(()=>Ye.map(B=>{let ue=Yr(B),ge=B.parts?.filter(Ie=>Ie.type==="tool-invocation"&&Ie.toolInvocation).map(Ie=>({toolName:Ie.toolInvocation.toolName,args:Ie.toolInvocation.args,state:Ie.toolInvocation.state,result:typeof Ie.toolInvocation.result=="string"?Ie.toolInvocation.result.slice(0,2e3):Ie.toolInvocation.result!=null?JSON.stringify(Ie.toolInvocation.result).slice(0,2e3):void 0})),mt=ue||(ge?.length?`[Tool calls: ${ge.map(Ie=>`${Ie.toolName}(${Ie.state})`).join(", ")}]`:"");return{id:B.id,role:B.role,content:mt,timestamp:B.timestamp,toolInvocations:ge?.length?ge:void 0}}),[Ye,Yr]),jt=je((B,ue={})=>{typeof window>"u"||window.parent===window||window.parent.postMessage({type:B,serverId:s,...ue},"*")},[s]);mr(()=>{jt("mcp-inspector:chat:ready",{capabilities:{send:!0,clear:!0,getState:!0,setQuickQuestions:!0,setFollowups:!0,loadMessages:!0}})},[jt]),mr(()=>{jt("mcp-inspector:chat:state_changed",{isLoading:nn,messageCount:Ye.length,messages:Ka(),quickQuestions:ut,followups:It})},[It,Ka,nn,Ye.length,jt,ut]),mr(()=>{let B=ue=>{if(!ue.data||typeof ue.data!="object")return;let ge=ue.data;if(!ge.type?.startsWith("mcp-inspector:chat:")||ge.serverId&&ge.serverId!==s)return;let mt=ge.requestId,Ie=(Ee,Qe={})=>{jt("mcp-inspector:chat:command_result",{requestId:mt,ok:Ee,...Qe})};if(ge.type==="mcp-inspector:chat:send"){let Ee=(ge.message??ge.prompt??"").trim();if(!Ee){Ie(!1,{error:"Missing message"});return}if(!He||!t){Ie(!1,{error:"Chat is not ready to send messages"});return}Ye.length===0&&
|
|
210
|
+
`)}return JSON.stringify(B,null,2)},[]),Ka=je(()=>Ye.map(B=>{let ue=Yr(B),ge=B.parts?.filter(Ie=>Ie.type==="tool-invocation"&&Ie.toolInvocation).map(Ie=>({toolName:Ie.toolInvocation.toolName,args:Ie.toolInvocation.args,state:Ie.toolInvocation.state,result:typeof Ie.toolInvocation.result=="string"?Ie.toolInvocation.result.slice(0,2e3):Ie.toolInvocation.result!=null?JSON.stringify(Ie.toolInvocation.result).slice(0,2e3):void 0})),mt=ue||(ge?.length?`[Tool calls: ${ge.map(Ie=>`${Ie.toolName}(${Ie.state})`).join(", ")}]`:"");return{id:B.id,role:B.role,content:mt,timestamp:B.timestamp,toolInvocations:ge?.length?ge:void 0}}),[Ye,Yr]),jt=je((B,ue={})=>{typeof window>"u"||window.parent===window||window.parent.postMessage({type:B,serverId:s,...ue},"*")},[s]);mr(()=>{jt("mcp-inspector:chat:ready",{capabilities:{send:!0,clear:!0,getState:!0,setQuickQuestions:!0,setFollowups:!0,loadMessages:!0}})},[jt]),mr(()=>{jt("mcp-inspector:chat:state_changed",{isLoading:nn,messageCount:Ye.length,messages:Ka(),quickQuestions:ut,followups:It})},[It,Ka,nn,Ye.length,jt,ut]),mr(()=>{let B=ue=>{if(!ue.data||typeof ue.data!="object")return;let ge=ue.data;if(!ge.type?.startsWith("mcp-inspector:chat:")||ge.serverId&&ge.serverId!==s)return;let mt=ge.requestId,Ie=(Ee,Qe={})=>{jt("mcp-inspector:chat:command_result",{requestId:mt,ok:Ee,...Qe})};if(ge.type==="mcp-inspector:chat:send"){let Ee=(ge.message??ge.prompt??"").trim();if(!Ee){Ie(!1,{error:"Missing message"});return}if(!He||!t){Ie(!1,{error:"Chat is not ready to send messages"});return}Ye.length===0&&Xn(),Cn(Ee,[]).then(()=>{jt("mcp-inspector:chat:message_sent",{requestId:mt,message:Ee,source:"bridge"}),Ie(!0)}).catch(Qe=>{Ie(!1,{error:Qe instanceof Error?Qe.message:String(Qe)})});return}if(ge.type==="mcp-inspector:chat:clear"){Va(),jt("mcp-inspector:chat:cleared",{requestId:mt}),Ie(!0);return}if(ge.type==="mcp-inspector:chat:get_state"){jt("mcp-inspector:chat:state",{requestId:mt,isLoading:nn,messageCount:Ye.length,messages:Ka(),quickQuestions:ut,followups:It}),Ie(!0);return}if(ge.type==="mcp-inspector:chat:set_quick_questions"){let Ee=jl(ge.questions);Bt(Ee),Ie(!0,{quickQuestions:Ee});return}if(ge.type==="mcp-inspector:chat:set_followups"){let Ee=jl(ge.followups);wn(Ee),Ie(!0,{followups:Ee});return}if(ge.type==="mcp-inspector:chat:load_messages"){let Ee=ge.messages;if(!Array.isArray(Ee)){Ie(!1,{error:"messages must be an array"});return}I(Ee),Ie(!0,{count:Ee.length});return}if(ge.type==="mcp-inspector:chat:screenshot"){let Ee=ge.toolCallId;(async()=>{try{let Qe=null;if(Ee&&(Qe=document.querySelector(`[data-tool-call-id="${Ee}"]`)),!Qe){let Ht=document.querySelectorAll("[data-tool-call-id]");Ht.length>0&&(Qe=Ht[Ht.length-1])}if(!Qe&&re.current&&(Qe=re.current),!Qe){Ie(!1,{error:"No screenshot target found"});return}let Os=1e4,hr=null,Qa="",ql="";try{let zs=await import("https://esm.sh/html-to-image@1.11.13");zs?.toPng?hr=await Promise.race([zs.toPng(Qe,{pixelRatio:1,backgroundColor:"#ffffff",includeQueryParams:!0}),new Promise((Ao,Bs)=>setTimeout(()=>Bs(new Error("html-to-image timed out")),Os))]):Qa="toPng not found on module"}catch(Ht){Qa=Ht instanceof Error?Ht.message:String(Ht)}if(!hr)try{if(!window.html2canvas){let Ao=document.createElement("script");Ao.src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/1.4.1/html2canvas.min.js",document.head.appendChild(Ao),await new Promise((Bs,iv)=>{Ao.onload=()=>Bs(),Ao.onerror=()=>iv(new Error("Failed to load html2canvas"))})}let Ht=window.html2canvas;hr=(await Promise.race([Ht(Qe,{useCORS:!0,allowTaint:!0,backgroundColor:"#ffffff",scale:1,logging:!1,foreignObjectRendering:!1}),new Promise((Ao,Bs)=>setTimeout(()=>Bs(new Error("html2canvas timed out")),Os))])).toDataURL("image/png")}catch(Ht){ql=Ht instanceof Error?Ht.message:String(Ht)}if(hr)jt("mcp-inspector:chat:screenshot_result",{requestId:mt,toolCallId:Ee||null,image:hr,timestamp:Date.now()}),Ie(!0);else{let Ht=re.current||document.body,zs=Ht.innerText?.substring(0,5e3)||"",Ao=Ht.innerHTML?.substring(0,1e4)||"";jt("mcp-inspector:chat:screenshot_result",{requestId:mt,toolCallId:Ee||null,image:"",domText:zs,domHtml:Ao,error:`html-to-image: ${Qa||"ok"}; html2canvas: ${ql||"ok"}`,timestamp:Date.now()}),Ie(!1,{error:`html-to-image: ${Qa}; html2canvas: ${ql}`})}}catch(Qe){let hr=(re.current||document.body).innerText?.substring(0,5e3)||"";jt("mcp-inspector:chat:screenshot_result",{requestId:mt,toolCallId:Ee||null,image:"",domText:hr,error:Qe instanceof Error?Qe.message:"Screenshot capture failed",timestamp:Date.now()}),Ie(!1,{error:Qe instanceof Error?Qe.message:"Screenshot failed"})}})();return}};return window.addEventListener("message",B),()=>window.removeEventListener("message",B)},[Va,Xn,I,It,Ka,nn,Ye.length,jt,ut,jl,Cn,s,He,t]),Rg(o?{onNewChat:H?Ds:Va}:{});let Wu=B=>{let ue=ft(ug,{className:"h-full w-full",shaderPhase:Bn,meshAnimationPaused:$e,onShaderFadeComplete:()=>pn("hidden"),children:B});return H?pr("div",{className:"flex h-full flex-row overflow-hidden",children:[pr("div",{className:"group/chat-history relative hidden shrink-0 flex-col overflow-visible transition-[width] duration-200 lg:flex",style:{width:De?320:0},children:[De&&ft("div",{className:"flex h-full w-full flex-col overflow-hidden border-r border-zinc-200 bg-background dark:border-zinc-700",children:ft(Id,{provider:H,open:!0,onOpenChange:Re,currentChatId:le??void 0,agentId:s,agentDisplayNameFallback:e.displayName||e.name||"MCP Server",onSelectChat:Jh,variant:"inline",containerClassName:"h-full border-0",refetchKey:Oe,onCurrentChatDeleted:()=>{Ds()}})}),De&&ft(Ed,{onCollapse:()=>Re(!1)})]}),pr("div",{className:"relative min-w-0 flex-1 overflow-hidden",children:[!De&&ft("div",{"data-chat-history-toggle":!0,className:"absolute top-1/2 left-4 z-50 hidden -translate-y-1/2 lg:block [[data-mcp-widget-fullscreen]_&]:pointer-events-none [[data-mcp-widget-fullscreen]_&]:invisible",children:pr(ke,{children:[ft(we,{render:ft(E,{size:"icon",variant:"outline",className:"size-10 aspect-square rounded-full",onClick:()=>Re(!0),children:ft(YS,{size:16})}),nativeButton:!0}),ft(Ce,{side:"right",children:ft("p",{children:"Chat History"})})]})}),ue]})]}):ue},Qr=je(()=>{qe(-1),Ne(!1),pe.current=null},[]),Xr=je(()=>{if(!at.current)return;let B=at.current.selectionStart,ue=Y.slice(0,B),ge=QS.test(ue);Ne(ge),ge?(pe.current={start:B-1,end:B},qe(0)):Qr()},[Y,Qr]);mr(()=>{He&&Ye.length===0&&at.current&&at.current.focus()},[He,Ye.length]),mr(()=>{!nn&&Ye.length>0&&at.current&&at.current.focus()},[nn,Ye.length]),mr(()=>{at.current&&Xr()},[Y,Xr]);let Ku=je(()=>{Vl(null),nv({}),Qr()},[Qr]),Ja=je(async B=>{if(Vl(B),B.arguments&&B.arguments.length>0){Vl(null),As.error("Prompts with arguments are not supported",{description:"This prompt requires arguments which are not yet supported in chat mode."});return}try{await $u(B,{})}catch(ue){console.error("Error executing prompt",ue)}finally{if(at.current&&pe.current){let{start:ue,end:ge}=pe.current,mt=Y.slice(0,ue)+Y.slice(ge);q(mt),requestAnimationFrame(()=>{at.current?.focus(),at.current?.setSelectionRange(ue,ue)})}Ku()}},[$u,Ku,Y]),Ga=je(()=>{(Y.trim()||_s.length>0||fr.length>0)&&(Ye.length===0&&Xn(),Iu().then(()=>{Cn(Y,_s),q(""),ju()}))},[Y,_s,Cn,ju,fr,Iu,Ye.length,Xn]),Ju=je(B=>{if(B.key==="ArrowDown")qe(ue=>go.length===0?-1:(ue+1)%go.length);else if(B.key==="ArrowUp")qe(ue=>go.length===0?-1:(ue-1+go.length)%go.length);else if(B.key==="Escape")B.stopPropagation(),Qr();else if(B.key==="Enter"&>>=0){let ue=go[gt];ue&&Ja(ue)}},[go,gt,Ja,Qr]),Gu=je(B=>{XS.includes(B.key)&&M?(B.preventDefault(),Ju(B)):B.key==="Enter"&&!B.shiftKey&&(B.preventDefault(),Ga())},[Ga,Ju,M]),Yu=je(B=>{(B.key==="ArrowLeft"||B.key==="ArrowRight")&&Xr()},[Xr]),Ya=je(B=>{let ue=`# Chat Export - ${new Date().toLocaleString()}
|
|
211
211
|
|
|
212
212
|
`;return ue+=B.map(ge=>{let mt=ge.role.charAt(0).toUpperCase()+ge.role.slice(1);if(!ge.parts||ge.parts.length===0){let Ee=Yr(ge).trim();return Ee?`## ${mt}
|
|
213
|
-
${Ee}`:""}let Ie=[];for(let Ee of ge.parts)if(Ee.type==="text"&&Ee.text?.trim())Ie.push(Ee.text.trim());else if(Ee.type==="tool-invocation"&&Ee.toolInvocation){let Qe=Ee.toolInvocation,Os=
|
|
213
|
+
${Ee}`:""}let Ie=[];for(let Ee of ge.parts)if(Ee.type==="text"&&Ee.text?.trim())Ie.push(Ee.text.trim());else if(Ee.type==="tool-invocation"&&Ee.toolInvocation){let Qe=Ee.toolInvocation,Os=qu(Qe.result);Ie.push(`#### ${Qe.toolName}
|
|
214
214
|
**Arguments:**
|
|
215
215
|
\`\`\`json
|
|
216
216
|
${JSON.stringify(Qe.args,null,2)}
|
|
@@ -225,4 +225,4 @@ ${Ie.join(`
|
|
|
225
225
|
|
|
226
226
|
---
|
|
227
227
|
|
|
228
|
-
`),ue},[Yr,
|
|
228
|
+
`),ue},[Yr,qu]),ov=je(()=>{let B=Ya(Ye);Xe(B).then(()=>As.success("Chat copied to clipboard"),()=>As.error("Failed to copy chat"))},[Ye,Ya]),rv=je(B=>{let ge=`chat-export-${new Date().toISOString().split("T")[0]}`;if(B==="json"){let mt=Ye.map(Ie=>({id:Ie.id,role:Ie.role,content:Yr(Ie),timestamp:Ie.timestamp,toolInvocations:Ie.parts?.filter(Ee=>Ee.type==="tool-invocation"&&Ee.toolInvocation).map(Ee=>({toolName:Ee.toolInvocation.toolName,args:Ee.toolInvocation.args,result:Ee.toolInvocation.result}))}));Oi(mt,ge+".json")}else{let mt=Ya(Ye),Ie=new Blob([mt],{type:"text/markdown"}),Ee=URL.createObjectURL(Ie),Qe=document.createElement("a");Qe.href=Ee,Qe.download=ge+".md",document.body.appendChild(Qe),Qe.click(),document.body.removeChild(Qe),setTimeout(()=>URL.revokeObjectURL(Ee),100)}As.success(`Chat exported as ${B.toUpperCase()}`)},[Ye,Ya,Yr]),Qu=je(()=>{Kr(),Ds()},[Kr,Ds]),sv=je(B=>{B.trim()&&(!He||!t||(Xn(),Cn(B,[]).then(()=>{jt("mcp-inspector:chat:message_sent",{message:B,source:"quick_question"})})))},[jt,Cn,He,t,Xn]),av=je(B=>{B.trim()&&(!He||!t||Cn(B,[]).then(()=>{jt("mcp-inspector:chat:message_sent",{message:B,source:"followup"})}))},[jt,Cn,He,t]),Xu=Eo?ft(Hh,{notice:Eo,onConfigureApiKey:Zh,onSignIn:Eo.kind==="login_required"?d?_u:()=>{window.location.href=Eo.loginUrl}:void 0,authorizing:tv}):null;return He&&Ye.length===0?Wu(pr("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:[ft("div",{className:"absolute top-4 right-4 z-10",children:ft(Ta,{open:$e,onOpenChange:Q,tempProvider:ee,tempModel:et,tempApiKey:xe,tempBaseUrl:Yt,onProviderChange:me,onModelChange:ht,onApiKeyChange:he,onBaseUrlChange:Dt,onSave:Au,onClear:Qu,showClearButton:!!We,buttonLabel:"Change API Key",hostedInspector:m,freeTierInfo:Wa,managedCloudInfo:Gr,useManagedCloud:fo,onSaveManagedCloud:Gr?Uu:void 0})}),ft(mu,{serverDisplayName:Si(e),composerNotice:Xu,inputValue:Y,isConnected:t&&!Eo&&!Ls,isLoading:nn,textareaRef:at,llmConfig:He,promptsDropdownOpen:M,promptFocusedIndex:gt,prompts:go,selectedPrompt:Fu,promptResults:_s,attachments:fr,tools:w?void 0:Ze,disabledTools:w?void 0:On,onDisabledToolsChange:w?void 0:Nt,onDeletePromptResult:Vu,onPromptSelect:Ja,onInputChange:q,onKeyDown:Gu,onKeyUp:Yu,onClick:Xr,onSendMessage:Ga,onStopStreaming:Z,onConfigDialogOpenChange:Q,onAttachmentAdd:Se,onAttachmentRemove:ct,hideModelBadge:zu,freeTierInfo:Wa,managedCloudInfo:Gr,modelBadgeMode:Bu,modelDisplayName:Hu,quickQuestions:ut,onQuickQuestionSelect:sv,pendingElicitationRequests:e.pendingElicitationRequests,onApproveElicitation:e.approveElicitation,onRejectElicitation:e.rejectElicitation,systemPromptProvider:W}),Du]})):Wu(pr("div",{className:"relative flex min-h-0 flex-1 flex-col overflow-hidden",children:[ft(nu,{llmConfig:He,hasMessages:Ye.length>0,configDialogOpen:$e,onConfigDialogOpenChange:Q,onClearChat:H?Ds:Va,tempProvider:ee,tempModel:et,tempApiKey:xe,tempBaseUrl:Yt,onProviderChange:me,onModelChange:ht,onApiKeyChange:he,onBaseUrlChange:Dt,onSaveConfig:Au,onClearConfig:Qu,showClearButton:!!We,hideConfigButton:Ou,hostedInspector:m,freeTierInfo:Wa,managedCloudInfo:Gr,useManagedCloud:fo,onSaveManagedCloud:Gr?Uu:void 0,onCopyChat:ov,onExportChat:rv,clearButtonLabel:p,hideTitle:x,clearButtonHideIcon:b,clearButtonHideShortcut:g,clearButtonVariant:v,hideClearButton:y,activeChatId:le,chatTitle:Qh,showViewToggle:!!He,viewIndex:mn==="raw"?1:0,onViewIndexChange:B=>mo(B===1?"raw":"conv"),elevatedHeader:ne}),pr("div",{className:"relative flex min-h-0 flex-1 flex-col overflow-hidden",children:[ft(Mh,{visible:Wh&&!!He}),ft("div",{ref:re,"data-testid":"chat-messages-scroll-container",className:"min-h-0 flex-1 overflow-y-auto overscroll-contain p-2 sm:p-4 pt-[80px] sm:pt-[100px]",children:He?mn==="conv"?ft(wu,{messages:Ye,isLoading:nn,serverId:e.url,readResource:i,tools:e.tools,sendMessage:(B,ue)=>Cn(B,[],ue),serverBaseUrl:e.url,messagesEndRef:jh,traceEvents:dt}):ft(Uh,{events:dt,usage:bt}):ft(pu,{onConfigureClick:()=>Q(!0)})}),He&&ft(Rh,{visible:qh,onClick:()=>Kh("smooth")})]}),He&&pr("div",{className:"relative shrink-0",children:[Xu,ft(Da,{inputValue:Y,isConnected:t&&!Eo&&!Ls,isLoading:nn,textareaRef:at,llmConfig:He,promptsDropdownOpen:M,promptFocusedIndex:gt,prompts:go,promptResults:_s,selectedPrompt:Fu,attachments:fr,tools:w?void 0:Ze,disabledTools:w?void 0:On,onDisabledToolsChange:w?void 0:Nt,onDeletePromptResult:Vu,onPromptSelect:Ja,onInputChange:q,onKeyDown:Gu,onKeyUp:Yu,onClick:Xr,onSendMessage:Ga,onStopStreaming:Z,onConfigDialogOpenChange:Q,onAttachmentAdd:Se,onAttachmentRemove:ct,hideModelBadge:zu,freeTierInfo:Wa,managedCloudInfo:Gr,modelBadgeMode:Bu,modelDisplayName:Hu,followups:It,onFollowupSelect:av,pendingElicitationRequests:e.pendingElicitationRequests,onApproveElicitation:e.approveElicitation,onRejectElicitation:e.rejectElicitation,systemPromptProvider:W})]}),Du]}))}function eT(e){if(!e.length)return[];let t=[...e].sort((a,i)=>new Date(a.createdAt).getTime()-new Date(i.createdAt).getTime()),n=[],o=null,r=new Map,s=()=>{if(!o)return;let a=(o.parts?.length??0)>0,i=typeof o.content=="string"&&o.content.trim()!=="";(a||i)&&n.push(o),o=null,r.clear()};for(let a of t){let i=new Date(a.createdAt).getTime();if(a.type==="user_message"){s();let l=a.eventData?.content?.text||"";n.push({id:a.id,role:"user",content:l,timestamp:i});continue}if(a.type==="tool_call"){let l=a.eventData?.content??{},u=typeof l.toolCallId=="string"?l.toolCallId:a.id;o||(o={id:`assistant-${a.id}`,role:"assistant",content:"",timestamp:i,parts:[]});let h=o.parts.length;o.parts.push({type:"tool-invocation",toolInvocation:{toolName:String(l.toolName??"unknown"),args:l.args??{},state:"pending"}}),r.set(u,h);continue}if(a.type==="tool_result"){let l=a.eventData?.content??{},u=typeof l.toolCallId=="string"?l.toolCallId:void 0;if(o&&u!==void 0&&o.parts){let h=r.get(u);if(h!==void 0){let c=o.parts[h];c?.type==="tool-invocation"&&c.toolInvocation&&(c.toolInvocation.result=l.result,c.toolInvocation.state="result")}}continue}if(a.type==="assistant_message"){let l=a.eventData?.content?.text||"";o?(o.id=a.id,o.timestamp=i,o.content=l,l&&(o.parts=o.parts??[],o.parts.push({type:"text",text:l})),s()):n.push({id:a.id,role:"assistant",content:l,timestamp:i,parts:l?[{type:"text",text:l}]:[]});continue}}return s(),n}export{ny as AddToClientDropdown,zr as CHAT_TITLE_PLACEHOLDER,rr as CHAT_TITLE_SIMPLE,nu as ChatHeader,yd as ChatHistoryHeader,Id as ChatHistoryPanel,Ed as ChatHistoryRail,Da as ChatInputArea,mu as ChatLandingForm,Pd as ChatList,ZS as ChatTab,va as ChatTitleReveal,Ta as ConfigurationDialog,pu as ConfigureEmptyState,jr as DEFAULT_CHAT_SYSTEM_PROMPT,C0 as InspectorProvider,ya as LocalChatStorageProvider,wu as MessageList,Wf as PromptsTab,_f as ResourcesTab,Py as ThemeProvider,xc as ToolInputForm,Fi as ToolResultDisplay,Vi as ToolResultRenderer,Tf as ToolsTab,J3 as ViewRenderer,_y as WidgetDebugProvider,Cl as chatBarActionButtonClass,eu as chatBarFrostedPill,tu as chatBarTitleFrostedClass,eT as chatEventsToInspectorMessages,km as downloadMcpbFile,wd as firstUserMessageFromMessages,Cd as generateChatTitleWithLlm,Sm as generateClaudeCodeCommand,Pm as generateCodexConfig,wm as generateCursorDeepLink,Tm as generateGeminiCLICommand,Gb as generateMcpbConfig,qP as generatePythonSDKCode,jP as generateTypeScriptSDKCode,Cm as generateVSCodeDeepLink,Nm as generateVSCodeInsidersDeepLink,ac as getEnvVarInstructions,Fa as getSystemPromptStorageKey,Y3 as getViewResourceUri,sr as isPlaceholderTitle,G3 as isViewTool,Pu as readStoredSystemPrompt,Mu as resolveSystemPrompt,Rd as useChatHistory,Nu as useChatMessages,ku as useChatMessagesClientSide,Dd as useChatTitleGeneration,ua as useConfig,wo as useInspector,ha as useMCPPrompts,Ru as writeStoredSystemPrompt};
|