@mcp-use/inspector 20.0.5-canary.0 → 20.0.5-canary.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Binary file
package/dist/cli.js CHANGED
@@ -5,7 +5,7 @@ ${n.join(`\r
5
5
  \r
6
6
  `)},jo=e=>{let t=e.socket.encrypted?"https":"http",r=new URL(e.url??"/",`${t}://${e.headers.host??"localhost"}`),n=new Headers;for(let o in e.headers){let s=e.headers[o];s&&n.append(o,Array.isArray(s)?s[0]:s)}return new Request(r,{headers:n})},Bo=e=>{let{server:t,fetchCallback:r,wss:n}=e,o=new Map;n.on("connection",(a,c)=>{let l=o.get(c);l&&(l.resolve(a),o.delete(c))});let s=a=>{let c=o.get(a);c&&(o.delete(a),c.reject(new Error("WebSocket handshake aborted")))},i=(a,c)=>new Promise((l,u)=>{o.set(a,{resolve:l,reject:u,connectionSymbol:c})});t.on("upgrade",async(a,c,l)=>{if(a.headers.upgrade?.toLowerCase()!=="websocket")return;let u={incoming:a,outgoing:void 0,wss:n,[ur]:i},d=400,p;try{let y=await r(jo(a),u);y instanceof Response&&(d=y.status,p=y.headers)}catch{t.listenerCount("upgrade")===1&&Jt(c,500);return}let m=o.get(a);if(!m||m.connectionSymbol!==u[lr]){s(a),t.listenerCount("upgrade")===1&&Jt(c,d,p);return}let g=y=>{dr(y,p)},h=()=>s(a);c.once("close",h),n.on("headers",g);try{n.handleUpgrade(a,c,l,y=>{c.off("close",h),n.emit("connection",y,a)})}finally{n.off("headers",g)}}),t.on("close",()=>{n.close()})},ji=Wt(async(e,t,r)=>{if(e.req.header("upgrade")?.toLowerCase()!=="websocket")return;let n=e.env,o=n[ur];if(!o||!n.incoming)return new Response(null,{status:500});let s=No();return n[lr]=s,(async()=>{let i;try{i=await o(n.incoming,s)}catch{return}let a=[],c=(d,p)=>{a.push([d,p])};i.on("message",c);let l={binaryType:"arraybuffer",close(d,p){i.close(d,p)},protocol:i.protocol,raw:i,get readyState(){return i.readyState},send(d,p){i.send(d,{compress:p?.compress})},url:new URL(e.req.url)};try{t?.onOpen?.(new Event("open"),l)}catch(d){(r?.onError??console.error)(d)}let u=(d,p)=>{let m=Array.isArray(d)?d:[d];for(let g of m)try{t?.onMessage?.(new MessageEvent("message",{data:p?g instanceof ArrayBuffer?g:g.buffer.slice(g.byteOffset,g.byteOffset+g.byteLength):typeof g=="string"?g:Buffer.from(g).toString("utf-8")}),l)}catch(h){(r?.onError??console.error)(h)}};i.off("message",c);for(let d of a)u(...d);i.on("message",(d,p)=>{u(d,p)}),i.on("close",(d,p)=>{try{t?.onClose?.(new Io("close",{code:d,reason:p.toString()}),l)}catch(m){(r?.onError??console.error)(m)}}),i.on("error",d=>{try{t?.onError?.(new Do("error",{error:d}),l)}catch(p){(r?.onError??console.error)(p)}})})(),new Response}),Ho=e=>{let t=e.fetch,r=Mo(t,{hostname:e.hostname,overrideGlobalObjects:e.overrideGlobalObjects,autoCleanupIncoming:e.autoCleanupIncoming}),n=(e.createServer||to)(e.serverOptions||{},r);if(e.websocket&&e.websocket.server){if(e.websocket.server.options.noServer!==!0)throw new Error("WebSocket server must be created with { noServer: true } option");Bo({server:n,fetchCallback:t,wss:e.websocket.server})}return n},fr=(e,t)=>{let r=Ho(e);return r.listen(e?.port??3e3,e.hostname,()=>{let n=r.address();t&&t(n)}),r};var nt=(e,t,r)=>(n,o)=>{let s=-1;return i(0);async function i(a){if(a<=s)throw new Error("next() called multiple times");s=a;let c,l=!1,u;if(e[a]?(u=e[a][0][0],n.req.routeIndex=a):u=a===e.length&&o||void 0,u)try{c=await u(n,()=>i(a+1))}catch(d){if(d instanceof Error&&t)n.error=d,c=await t(d,n),l=!0;else throw d}else n.finalized===!1&&r&&(c=await r(n));return c&&(n.finalized===!1||l)&&(n.res=c),n}};var pr=Symbol();var hr=(e,t)=>new Response(e,{headers:{"Content-Type":t.replace(/^[^;]+/,n=>n.toLowerCase())}}).formData();var Oe=e=>"headers"in e,gr=async(e,t=Object.create(null))=>{let{all:r=!1,dot:n=!1}=t,i=(Oe(e)?e.headers:e.raw.headers).get("Content-Type")?.split(";")[0].trim().toLowerCase();return i==="multipart/form-data"||i==="application/x-www-form-urlencoded"?$o(e,{all:r,dot:n}):{}};async function $o(e,t){if(!Oe(e)&&e.bodyCache.formData)return mr(await e.bodyCache.formData,t);let r=Oe(e)?e.headers:e.raw.headers,n=await e.arrayBuffer(),o=hr(n,r.get("Content-Type")||"");Oe(e)||(e.bodyCache.formData=o);let s=await o;return s?mr(s,t):{}}function mr(e,t){let r=Object.create(null);return e.forEach((n,o)=>{t.all||o.endsWith("[]")?Fo(r,o,n):r[o]=n}),t.dot&&Object.entries(r).forEach(([n,o])=>{n.includes(".")&&(Wo(r,n,o),delete r[n])}),r}var Fo=(e,t,r)=>{e[t]!==void 0?Array.isArray(e[t])?e[t].push(r):e[t]=[e[t],r]:t.endsWith("[]")?e[t]=[r]:e[t]=r},Wo=(e,t,r)=>{if(/(?:^|\.)__proto__\./.test(t))return;let n=e,o=t.split(".");o.forEach((s,i)=>{i===o.length-1?n[s]=r:((!n[s]||typeof n[s]!="object"||Array.isArray(n[s])||n[s]instanceof File)&&(n[s]=Object.create(null)),n=n[s])})};var st=e=>{let t=e.split("/");return t[0]===""&&t.shift(),t},yr=e=>{let{groups:t,path:r}=zo(e),n=st(r);return qo(n,t)},zo=e=>{let t=[];return e=e.replace(/\{[^}]+\}/g,(r,n)=>{let o=`@${n}`;return t.push([o,r]),o}),{groups:t,path:e}},qo=(e,t)=>{for(let r=t.length-1;r>=0;r--){let[n]=t[r];for(let o=e.length-1;o>=0;o--)if(e[o].includes(n)){e[o]=e[o].replace(n,t[r][1]);break}}return e},Te={},wr=(e,t)=>{if(e==="*")return"*";let r=e.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);if(r){let n=`${e}#${t}`;return Te[n]||(r[2]?Te[n]=t&&t[0]!==":"&&t[0]!=="*"?[n,r[1],new RegExp(`^${r[2]}(?=/${t})`)]:[e,r[1],new RegExp(`^${r[2]}$`)]:Te[n]=[e,r[1],!0]),Te[n]}return null},Le=(e,t)=>{try{return t(e)}catch{return e.replace(/(?:%[0-9A-Fa-f]{2})+/g,r=>{try{return t(r)}catch{return r}})}},Ko=e=>Le(e,decodeURI),it=e=>{let t=e.url,r=t.indexOf("/",t.indexOf(":")+4),n=r;for(;n<t.length;n++){let o=t.charCodeAt(n);if(o===37){let s=t.indexOf("?",n),i=t.indexOf("#",n),a=s===-1?i===-1?void 0:i:i===-1?s:Math.min(s,i),c=t.slice(r,a);return Ko(c.includes("%25")?c.replace(/%25/g,"%2525"):c)}else if(o===63||o===35)break}return t.slice(r,n)};var br=e=>{let t=it(e);return t.length>1&&t.at(-1)==="/"?t.slice(0,-1):t},K=(e,t,...r)=>(r.length&&(t=K(t,...r)),`${e?.[0]==="/"?"":"/"}${e}${t==="/"?"":`${e?.at(-1)==="/"?"":"/"}${t?.[0]==="/"?t.slice(1):t}`}`),ke=e=>{if(e.charCodeAt(e.length-1)!==63||!e.includes(":"))return null;let t=e.split("/"),r=[],n="";return t.forEach(o=>{if(o!==""&&!/\:/.test(o))n+="/"+o;else if(/\:/.test(o))if(/\?/.test(o)){r.length===0&&n===""?r.push("/"):r.push(n);let s=o.replace("?","");n+="/"+s,r.push(n)}else n+="/"+o}),r.filter((o,s,i)=>i.indexOf(o)===s)},ot=e=>/[%+]/.test(e)?(e.indexOf("+")!==-1&&(e=e.replace(/\+/g," ")),e.indexOf("%")!==-1?Le(e,at):e):e,vr=(e,t,r)=>{let n;if(!r&&t&&!/[%+]/.test(t)){let i=e.indexOf("?",8);if(i===-1)return;for(e.startsWith(t,i+1)||(i=e.indexOf(`&${t}`,i+1));i!==-1;){let a=e.charCodeAt(i+t.length+1);if(a===61){let c=i+t.length+2,l=e.indexOf("&",c);return ot(e.slice(c,l===-1?void 0:l))}else if(a==38||isNaN(a))return"";i=e.indexOf(`&${t}`,i+1)}if(n=/[%+]/.test(e),!n)return}let o=Object.create(null);n??=/[%+]/.test(e);let s=e.indexOf("?",8);for(;s!==-1;){let i=e.indexOf("&",s+1),a=e.indexOf("=",s);a>i&&i!==-1&&(a=-1);let c=e.slice(s+1,a===-1?i===-1?void 0:i:a);if(n&&(c=ot(c)),s=i,c==="")continue;let l;a===-1?l="":(l=e.slice(a+1,i===-1?void 0:i),n&&(l=ot(l))),r?(o[c]&&Array.isArray(o[c])||(o[c]=[]),o[c].push(l)):o[c]??=l}return t?o[t]:o},xr=vr,Er=(e,t)=>vr(e,t,!0),at=decodeURIComponent;var Sr=e=>Le(e,at),Rr=class{raw;#e;#t;routeIndex=0;path;bodyCache={};constructor(e,t="/",r=[[]]){this.raw=e,this.path=t,this.#t=r,this.#e={}}param(e){return e?this.#r(e):this.#s()}#r(e){let t=this.#t[0][this.routeIndex][1][e],r=this.#o(t);return r&&/\%/.test(r)?Sr(r):r}#s(){let e={},t=Object.keys(this.#t[0][this.routeIndex][1]);for(let r of t){let n=this.#o(this.#t[0][this.routeIndex][1][r]);n!==void 0&&(e[r]=/\%/.test(n)?Sr(n):n)}return e}#o(e){return this.#t[1]?this.#t[1][e]:e}query(e){return xr(this.url,e)}queries(e){return Er(this.url,e)}header(e){if(e)return this.raw.headers.get(e)??void 0;let t=Object.create(null);return this.raw.headers.forEach((r,n)=>{t[n]=r}),t}async parseBody(e){return gr(this,e)}#n=e=>{let{bodyCache:t,raw:r}=this,n=t[e];if(n)return n;let o=Object.keys(t)[0];return o?t[o].then(s=>(o==="json"&&(s=JSON.stringify(s)),new Response(s)[e]())):t[e]=r[e]()};json(){return this.#n("text").then(e=>JSON.parse(e))}text(){return this.#n("text")}arrayBuffer(){return this.#n("arrayBuffer")}bytes(){return this.#n("arrayBuffer").then(e=>new Uint8Array(e))}blob(){return this.#n("blob")}formData(){return this.#n("formData")}addValidatedData(e,t){this.#e[e]=t}valid(e){return this.#e[e]}get url(){return this.raw.url}get method(){return this.raw.method}get[pr](){return this.#t}get matchedRoutes(){return this.#t[0].map(([[,e]])=>e)}get routePath(){return this.#t[0].map(([[,e]])=>e)[this.routeIndex].path}};var Pr={Stringify:1,BeforeStream:2,Stream:3},Vo=(e,t)=>{let r=new String(e);return r.isEscaped=!0,r.callbacks=t,r};var ct=async(e,t,r,n,o)=>{typeof e=="object"&&!(e instanceof String)&&(e instanceof Promise||(e=e.toString()),e instanceof Promise&&(e=await e));let s=e.callbacks;if(!s?.length)return Promise.resolve(e);o?o[0]+=e:o=[e];let i=Promise.all(s.map(a=>a({phase:t,buffer:o,context:n}))).then(a=>Promise.all(a.filter(Boolean).map(c=>ct(c,t,!1,n,o))).then(()=>o[0]));return r?Vo(await i,s):i};var Go="text/plain; charset=UTF-8",lt=(e,t)=>({"Content-Type":e,...t}),me=(e,t)=>new Response(e,t),ut=class{#e;#t;env={};#r;finalized=!1;error;#s;#o;#n;#u;#c;#l;#a;#d;#f;constructor(e,t){this.#e=e,t&&(this.#o=t.executionCtx,this.env=t.env,this.#l=t.notFoundHandler,this.#f=t.path,this.#d=t.matchResult)}get req(){return this.#t??=new Rr(this.#e,this.#f,this.#d),this.#t}get event(){if(this.#o&&"respondWith"in this.#o)return this.#o;throw Error("This context has no FetchEvent")}get executionCtx(){if(this.#o)return this.#o;throw Error("This context has no ExecutionContext")}get res(){return this.#n||=me(null,{headers:this.#a??=new Headers})}set res(e){if(this.#n&&e){e=me(e.body,e);for(let[t,r]of this.#n.headers.entries())if(t!=="content-type")if(t==="set-cookie"){let n=this.#n.headers.getSetCookie();e.headers.delete("set-cookie");for(let o of n)e.headers.append("set-cookie",o)}else e.headers.set(t,r)}this.#n=e,this.finalized=!0}render=(...e)=>(this.#c??=t=>this.html(t),this.#c(...e));setLayout=e=>this.#u=e;getLayout=()=>this.#u;setRenderer=e=>{this.#c=e};header=(e,t,r)=>{this.finalized&&(this.#n=me(this.#n.body,this.#n));let n=this.#n?this.#n.headers:this.#a??=new Headers;t===void 0?n.delete(e):r?.append?n.append(e,t):n.set(e,t)};status=e=>{this.#s=e};set=(e,t)=>{this.#r??=new Map,this.#r.set(e,t)};get=e=>this.#r?this.#r.get(e):void 0;get var(){return this.#r?Object.fromEntries(this.#r):{}}#i(e,t,r){let n=this.#n?new Headers(this.#n.headers):this.#a??new Headers;if(typeof t=="object"&&"headers"in t){let s=t.headers instanceof Headers?t.headers:new Headers(t.headers);for(let[i,a]of s)i.toLowerCase()==="set-cookie"?n.append(i,a):n.set(i,a)}if(r)for(let[s,i]of Object.entries(r))if(typeof i=="string")n.set(s,i);else{n.delete(s);for(let a of i)n.append(s,a)}let o=typeof t=="number"?t:t?.status??this.#s;return me(e,{status:o,headers:n})}newResponse=(...e)=>this.#i(...e);body=(e,t,r)=>this.#i(e,t,r);text=(e,t,r)=>!this.#a&&!this.#s&&!t&&!r&&!this.finalized?new Response(e):this.#i(e,t,lt(Go,r));json=(e,t,r)=>this.#i(JSON.stringify(e),t,lt("application/json",r));html=(e,t,r)=>{let n=o=>this.#i(o,t,lt("text/html; charset=UTF-8",r));return typeof e=="object"?ct(e,Pr.Stringify,!1,{}).then(n):n(e)};redirect=(e,t)=>{let r=String(e);return this.header("Location",/[^\x00-\xFF]/.test(r)?encodeURI(r):r),this.newResponse(null,t??302)};notFound=()=>(this.#l??=()=>me(),this.#l(this))};var x="ALL",Ar="all",Cr=["get","post","put","delete","options","patch"],Me="Can not add a route since the matcher is already built.",Ie=class extends Error{};var _r="__COMPOSED_HANDLER";var Yo=e=>e.text("404 Not Found",404),Or=(e,t)=>{if("getResponse"in e){let r=e.getResponse();return t.newResponse(r.body,r)}return console.error(e),t.text("Internal Server Error",500)},Tr=class Lr{get;post;put;delete;options;patch;all;on;use;router;getPath;_basePath="/";#e="/";routes=[];constructor(t={}){[...Cr,Ar].forEach(s=>{this[s]=(i,...a)=>(typeof i=="string"?this.#e=i:this.#s(s,this.#e,i),a.forEach(c=>{this.#s(s,this.#e,c)}),this)}),this.on=(s,i,...a)=>{for(let c of[i].flat()){this.#e=c;for(let l of[s].flat())a.map(u=>{this.#s(l.toUpperCase(),this.#e,u)})}return this},this.use=(s,...i)=>(typeof s=="string"?this.#e=s:(this.#e="*",i.unshift(s)),i.forEach(a=>{this.#s(x,this.#e,a)}),this);let{strict:n,...o}=t;Object.assign(this,o),this.getPath=n??!0?t.getPath??it:br}#t(){let t=new Lr({router:this.router,getPath:this.getPath});return t.errorHandler=this.errorHandler,t.#r=this.#r,t.routes=this.routes,t}#r=Yo;errorHandler=Or;route(t,r){let n=this.basePath(t);return r.routes.map(o=>{let s;r.errorHandler===Or?s=o.handler:(s=async(i,a)=>(await nt([],r.errorHandler)(i,()=>o.handler(i,a))).res,s[_r]=o.handler),n.#s(o.method,o.path,s,o.basePath)}),this}basePath(t){let r=this.#t();return r._basePath=K(this._basePath,t),r}onError=t=>(this.errorHandler=t,this);notFound=t=>(this.#r=t,this);mount(t,r,n){let o,s;n&&(typeof n=="function"?s=n:(s=n.optionHandler,n.replaceRequest===!1?o=c=>c:o=n.replaceRequest));let i=s?c=>{let l=s(c);return Array.isArray(l)?l:[l]}:c=>{let l;try{l=c.executionCtx}catch{}return[c.env,l]};o||=(()=>{let c=K(this._basePath,t),l=c==="/"?0:c.length;return u=>{let d=new URL(u.url);return d.pathname=this.getPath(u).slice(l)||"/",new Request(d,u)}})();let a=async(c,l)=>{let u=await r(o(c.req.raw),...i(c));if(u)return u;await l()};return this.#s(x,K(t,"*"),a),this}#s(t,r,n,o){t=t.toUpperCase(),r=K(this._basePath,r);let s={basePath:o!==void 0?K(this._basePath,o):this._basePath,path:r,method:t,handler:n};this.router.add(t,r,[n,s]),this.routes.push(s)}#o(t,r){if(t instanceof Error)return this.errorHandler(t,r);throw t}#n(t,r,n,o){if(o==="HEAD")return(async()=>new Response(null,await this.#n(t,r,n,"GET")))();let s=this.getPath(t,{env:n}),i=this.router.match(o,s),a=new ut(t,{path:s,matchResult:i,env:n,executionCtx:r,notFoundHandler:this.#r});if(i[0].length===1){let l;try{l=i[0][0][0][0](a,async()=>{a.res=await this.#r(a)})}catch(u){return this.#o(u,a)}return l instanceof Promise?l.then(u=>u||(a.finalized?a.res:this.#r(a))).catch(u=>this.#o(u,a)):l??this.#r(a)}let c=nt(i[0],this.errorHandler,this.#r);return(async()=>{try{let l=await c(a);if(!l.finalized)throw new Error("Context is not finalized. Did you forget to return a Response object or `await next()`?");return l.res}catch(l){return this.#o(l,a)}})()}fetch=(t,...r)=>this.#n(t,r[1],r[0],t.method);request=(t,r,n,o)=>t instanceof Request?this.fetch(r?new Request(t,r):t,n,o):(t=t.toString(),this.fetch(new Request(/^https?:\/\//.test(t)?t:`http://localhost${K("/",t)}`,r),n,o));fire=()=>{addEventListener("fetch",t=>{t.respondWith(this.#n(t.request,t,void 0,t.request.method))})}};var De=[];function dt(e,t){let r=this.buildAllMatchers(),n=((o,s)=>{let i=r[o]||r[x],a=i[2][s];if(a)return a;let c=s.match(i[0]);if(!c)return[[],De];let l=c.indexOf("",1);return[i[1][l],c]});return this.match=n,n(e,t)}var Ne="[^/]+",ge=".*",ye="(?:|/.*)",J=Symbol(),Xo=new Set(".\\+*[^]$()");function Jo(e,t){return e.length===1?t.length===1?e<t?-1:1:-1:t.length===1||e===ge||e===ye?1:t===ge||t===ye?-1:e===Ne?1:t===Ne?-1:e.length===t.length?e<t?-1:1:t.length-e.length}var kr=class ft{#e;#t;#r=Object.create(null);insert(t,r,n,o,s){if(t.length===0){if(this.#e!==void 0)throw J;if(s)return;this.#e=r;return}let[i,...a]=t,c=i==="*"?a.length===0?["","",ge]:["","",Ne]:i==="/*"?["","",ye]:i.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/),l;if(c){let u=c[1],d=c[2]||Ne;if(u&&c[2]&&(d===".*"||(d=d.replace(/^\((?!\?:)(?=[^)]+\)$)/,"(?:"),/\((?!\?:)/.test(d))))throw J;if(l=this.#r[d],!l){if(Object.keys(this.#r).some(p=>p!==ge&&p!==ye))throw J;if(s)return;l=this.#r[d]=new ft,u!==""&&(l.#t=o.varIndex++)}!s&&u!==""&&n.push([u,l.#t])}else if(l=this.#r[i],!l){if(Object.keys(this.#r).some(u=>u.length>1&&u!==ge&&u!==ye))throw J;if(s)return;l=this.#r[i]=new ft}l.insert(a,r,n,o,s)}buildRegExpStr(){let r=Object.keys(this.#r).sort(Jo).map(n=>{let o=this.#r[n];return(typeof o.#t=="number"?`(${n})@${o.#t}`:Xo.has(n)?`\\${n}`:n)+o.buildRegExpStr()});return typeof this.#e=="number"&&r.unshift(`#${this.#e}`),r.length===0?"":r.length===1?r[0]:"(?:"+r.join("|")+")"}};var Mr=class{#e={varIndex:0};#t=new kr;insert(e,t,r){let n=[],o=[];for(let i=0;;){let a=!1;if(e=e.replace(/\{[^}]+\}/g,c=>{let l=`@\\${i}`;return o[i]=[l,c],i++,a=!0,l}),!a)break}let s=e.match(/(?::[^\/]+)|(?:\/\*$)|./g)||[];for(let i=o.length-1;i>=0;i--){let[a]=o[i];for(let c=s.length-1;c>=0;c--)if(s[c].indexOf(a)!==-1){s[c]=s[c].replace(a,o[i][1]);break}}return this.#t.insert(s,t,n,this.#e,r),n}buildRegExp(){let e=this.#t.buildRegExpStr();if(e==="")return[/^$/,[],[]];let t=0,r=[],n=[];return e=e.replace(/#(\d+)|@(\d+)|\.\*\$/g,(o,s,i)=>s!==void 0?(r[++t]=Number(s),"$()"):(i!==void 0&&(n[Number(i)]=++t),"")),[new RegExp(`^${e}`),r,n]}};var Qo=[/^$/,[],Object.create(null)],Ir=Object.create(null);function Dr(e){return Ir[e]??=new RegExp(e==="*"?"":`^${e.replace(/\/\*$|([.\\+*[^\]$()])/g,(t,r)=>r?`\\${r}`:"(?:|/.*)")}$`)}function Zo(){Ir=Object.create(null)}function es(e){let t=new Mr,r=[];if(e.length===0)return Qo;let n=e.map(l=>[!/\*|\/:/.test(l[0]),...l]).sort(([l,u],[d,p])=>l?1:d?-1:u.length-p.length),o=Object.create(null);for(let l=0,u=-1,d=n.length;l<d;l++){let[p,m,g]=n[l];p?o[m]=[g.map(([y])=>[y,Object.create(null)]),De]:u++;let h;try{h=t.insert(m,u,p)}catch(y){throw y===J?new Ie(m):y}p||(r[u]=g.map(([y,f])=>{let w=Object.create(null);for(f-=1;f>=0;f--){let[v,L]=h[f];w[v]=L}return[y,w]}))}let[s,i,a]=t.buildRegExp();for(let l=0,u=r.length;l<u;l++)for(let d=0,p=r[l].length;d<p;d++){let m=r[l][d]?.[1];if(!m)continue;let g=Object.keys(m);for(let h=0,y=g.length;h<y;h++)m[g[h]]=a[m[g[h]]]}let c=[];for(let l in i)c[l]=r[i[l]];return[s,c,o]}function se(e,t){if(e){for(let r of Object.keys(e).sort((n,o)=>o.length-n.length))if(Dr(r).test(t))return[...e[r]]}}var Ue=class{name="RegExpRouter";#e;#t;constructor(){this.#e={[x]:Object.create(null)},this.#t={[x]:Object.create(null)}}add(e,t,r){let n=this.#e,o=this.#t;if(!n||!o)throw new Error(Me);n[e]||[n,o].forEach(a=>{a[e]=Object.create(null),Object.keys(a[x]).forEach(c=>{a[e][c]=[...a[x][c]]})}),t==="/*"&&(t="*");let s=(t.match(/\/:/g)||[]).length;if(/\*$/.test(t)){let a=Dr(t);e===x?Object.keys(n).forEach(c=>{n[c][t]||=se(n[c],t)||se(n[x],t)||[]}):n[e][t]||=se(n[e],t)||se(n[x],t)||[],Object.keys(n).forEach(c=>{(e===x||e===c)&&Object.keys(n[c]).forEach(l=>{a.test(l)&&n[c][l].push([r,s])})}),Object.keys(o).forEach(c=>{(e===x||e===c)&&Object.keys(o[c]).forEach(l=>a.test(l)&&o[c][l].push([r,s]))});return}let i=ke(t)||[t];for(let a=0,c=i.length;a<c;a++){let l=i[a];Object.keys(o).forEach(u=>{(e===x||e===u)&&(o[u][l]||=[...se(n[u],l)||se(n[x],l)||[]],o[u][l].push([r,s-c+a+1]))})}}match=dt;buildAllMatchers(){let e=Object.create(null);return Object.keys(this.#t).concat(Object.keys(this.#e)).forEach(t=>{e[t]||=this.#r(t)}),this.#e=this.#t=void 0,Zo(),e}#r(e){let t=[],r=e===x;return[this.#e,this.#t].forEach(n=>{let o=n[e]?Object.keys(n[e]).map(s=>[s,n[e][s]]):[];o.length!==0?(r||=!0,t.push(...o)):e!==x&&t.push(...Object.keys(n[x]).map(s=>[s,n[x][s]]))}),r?es(t):null}};var pt=class{name="SmartRouter";#e=[];#t=[];constructor(e){this.#e=e.routers}add(e,t,r){if(!this.#t)throw new Error(Me);this.#t.push([e,t,r])}match(e,t){if(!this.#t)throw new Error("Fatal error");let r=this.#e,n=this.#t,o=r.length,s=0,i;for(;s<o;s++){let a=r[s];try{for(let c=0,l=n.length;c<l;c++)a.add(...n[c]);i=a.match(e,t)}catch(c){if(c instanceof Ie)continue;throw c}this.match=a.match.bind(a),this.#e=[a],this.#t=void 0;break}if(s===o)throw new Error("Fatal error");return this.name=`SmartRouter + ${this.activeRouter.name}`,i}get activeRouter(){if(this.#t||this.#e.length!==1)throw new Error("No active router has been determined yet.");return this.#e[0]}};var we=Object.create(null),ts=e=>{for(let t in e)return!0;return!1},Nr=class Ur{#e;#t;#r;#s=0;#o=we;constructor(t,r,n){if(this.#t=n||Object.create(null),this.#e=[],t&&r){let o=Object.create(null);o[t]={handler:r,possibleKeys:[],score:0},this.#e=[o]}this.#r=[]}insert(t,r,n){this.#s=++this.#s;let o=this,s=yr(r),i=[];for(let a=0,c=s.length;a<c;a++){let l=s[a],u=s[a+1],d=wr(l,u),p=Array.isArray(d)?d[0]:l;if(p in o.#t){o=o.#t[p],d&&i.push(d[1]);continue}o.#t[p]=new Ur,d&&(o.#r.push(d),i.push(d[1])),o=o.#t[p]}return o.#e.push({[t]:{handler:n,possibleKeys:i.filter((a,c,l)=>l.indexOf(a)===c),score:this.#s}}),o}#n(t,r,n,o,s){for(let i=0,a=r.#e.length;i<a;i++){let c=r.#e[i],l=c[n]||c[x],u={};if(l!==void 0&&(l.params=Object.create(null),t.push(l),o!==we||s&&s!==we))for(let d=0,p=l.possibleKeys.length;d<p;d++){let m=l.possibleKeys[d],g=u[l.score];l.params[m]=s?.[m]&&!g?s[m]:o[m]??s?.[m],u[l.score]=!0}}}search(t,r){let n=[];this.#o=we;let s=[this],i=st(r),a=[],c=i.length,l=null;for(let u=0;u<c;u++){let d=i[u],p=u===c-1,m=[];for(let h=0,y=s.length;h<y;h++){let f=s[h],w=f.#t[d];w&&(w.#o=f.#o,p?(w.#t["*"]&&this.#n(n,w.#t["*"],t,f.#o),this.#n(n,w,t,f.#o)):m.push(w));for(let v=0,L=f.#r.length;v<L;v++){let k=f.#r[v],S=f.#o===we?{}:{...f.#o};if(k==="*"){let R=f.#t["*"];R&&(this.#n(n,R,t,f.#o),R.#o=S,m.push(R));continue}let[P,A,E]=k;if(!d&&!(E instanceof RegExp))continue;let b=f.#t[P];if(E instanceof RegExp){if(l===null){l=new Array(c);let G=r[0]==="/"?1:0;for(let Y=0;Y<c;Y++)l[Y]=G,G+=i[Y].length+1}let R=r.substring(l[u]),T=E.exec(R);if(T){if(S[A]=T[0],this.#n(n,b,t,f.#o,S),T[0].length===R.length&&b.#t["*"]&&this.#n(n,b.#t["*"],t,f.#o,S),ts(b.#t)){b.#o=S;let G=T[0].match(/\//)?.length??0;(a[G]||=[]).push(b)}continue}}(E===!0||E.test(d))&&(S[A]=d,p?(this.#n(n,b,t,S,f.#o),b.#t["*"]&&this.#n(n,b.#t["*"],t,S,f.#o)):(b.#o=S,m.push(b)))}}let g=a.shift();s=g?m.concat(g):m}return n.length>1&&n.sort((u,d)=>u.score-d.score),[n.map(({handler:u,params:d})=>[u,d])]}};var ht=class{name="TrieRouter";#e;constructor(){this.#e=new Nr}add(e,t,r){let n=ke(t);if(n){for(let o=0,s=n.length;o<s;o++)this.#e.insert(e,n[o],r);return}this.#e.insert(e,t,r)}match(e,t){return this.#e.search(e,t)}};var mt=class extends Tr{constructor(e={}){super(e),this.router=e.router??new pt({routers:[new Ue,new ht]})}};var je=e=>{let t={origin:"*",allowMethods:["GET","HEAD","PUT","POST","DELETE","PATCH"],allowHeaders:[],exposeHeaders:[],...e},r=(o=>typeof o=="string"?o==="*"?()=>o:s=>o===s?s:null:typeof o=="function"?o:s=>o.includes(s)?s:null)(t.origin),n=(o=>typeof o=="function"?o:Array.isArray(o)?()=>o:()=>[])(t.allowMethods);return async function(s,i){function a(l,u){s.res.headers.set(l,u)}let c=await r(s.req.header("origin")||"",s);if(c&&a("Access-Control-Allow-Origin",c),t.credentials&&a("Access-Control-Allow-Credentials","true"),t.exposeHeaders?.length&&a("Access-Control-Expose-Headers",t.exposeHeaders.join(",")),s.req.method==="OPTIONS"){t.origin!=="*"&&a("Vary","Origin"),t.maxAge!=null&&a("Access-Control-Max-Age",t.maxAge.toString());let l=await n(s.req.header("origin")||"",s);l.length&&a("Access-Control-Allow-Methods",l.join(","));let u=t.allowHeaders;if(!u?.length){let d=s.req.header("Access-Control-Request-Headers");d&&(u=d.split(",").map(p=>p.trim()))}return u?.length&&(a("Access-Control-Allow-Headers",u.join(",")),s.res.headers.append("Vary","Access-Control-Request-Headers")),s.res.headers.delete("Content-Length"),s.res.headers.delete("Content-Type"),new Response(null,{headers:s.res.headers,status:204,statusText:"No Content"})}await i(),t.origin!=="*"&&s.header("Vary","Origin",{append:!0})}};import en from"process";import tn from"path";import{fileURLToPath as Ms}from"url";import Is from"child_process";import Ds,{constants as Ns}from"fs/promises";import{promisify as fs}from"util";import ps from"child_process";import vt,{constants as zr}from"fs/promises";import Hr from"process";import is from"os";import as from"fs";import os from"fs";import jr from"fs";var gt;function rs(){try{return jr.statSync("/.dockerenv"),!0}catch{return!1}}function ns(){try{return jr.readFileSync("/proc/self/cgroup","utf8").includes("docker")}catch{return!1}}function yt(){return gt===void 0&&(gt=rs()||ns()),gt}var wt,ss=()=>{try{return os.statSync("/run/.containerenv"),!0}catch{return!1}};function ie(){return wt===void 0&&(wt=ss()||yt()),wt}var Br=()=>{if(Hr.platform!=="linux")return!1;if(is.release().toLowerCase().includes("microsoft"))return!ie();try{return as.readFileSync("/proc/version","utf8").toLowerCase().includes("microsoft")?!ie():!1}catch{return!1}},H=Hr.env.__IS_WSL_TEST__?Br:Br();import $r from"process";import{Buffer as cs}from"buffer";import{promisify as ls}from"util";import us from"child_process";import Oc,{constants as Tc}from"fs/promises";var ds=ls(us.execFile),bt=()=>`${$r.env.SYSTEMROOT||$r.env.windir||String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`;var O=async(e,t={})=>{let{powerShellPath:r,...n}=t,o=O.encodeCommand(e);return ds(r??bt(),[...O.argumentsPrefix,o],{encoding:"utf8",...n})};O.argumentsPrefix=["-NoProfile","-NonInteractive","-ExecutionPolicy","Bypass","-EncodedCommand"];O.encodeCommand=e=>cs.from(e,"utf16le").toString("base64");O.escapeArgument=e=>`'${String(e).replaceAll("'","''")}'`;function Fr(e){for(let t of e.split(`
7
7
  `)){if(/^\s*#/.test(t))continue;let r=/^\s*root\s*=\s*(?<mountPoint>"[^"]*"|'[^']*'|[^#]*)/.exec(t);if(r)return r.groups.mountPoint.trim().replaceAll(/^["']|["']$/g,"")}}var hs=fs(ps.execFile),ms=(()=>{let e="/mnt/",t;return async function(){if(t)return t;let r="/etc/wsl.conf",n=!1;try{await vt.access(r,zr.F_OK),n=!0}catch{}if(!n)return e;let o=await vt.readFile(r,{encoding:"utf8"}),s=Fr(o);return s===void 0?e:(t=s,t=t.endsWith("/")?t:`${t}/`,t)}})(),gs=async()=>`${await ms()}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`,Be=H?gs:bt,Wr,qr=async()=>(Wr??=(async()=>{try{let e=await Be();return await vt.access(e,zr.X_OK),!0}catch{return!1}})(),Wr),Kr=async()=>{let e=await Be(),t=String.raw`(Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice").ProgId`,{stdout:r}=await O(t,{powerShellPath:e});return r.trim()},Vr=async e=>{if(/^[a-z]+:\/\//i.test(e))return e;try{let{stdout:t}=await hs("wslpath",["-aw",e],{encoding:"utf8"});return t.trim()}catch{return e}};function Q(e,t,r){let n=o=>Object.defineProperty(e,t,{value:o,enumerable:!0,writable:!0});return Object.defineProperty(e,t,{configurable:!0,enumerable:!0,get(){let o=r();return n(o),o},set(o){n(o)}}),e}import{promisify as _s}from"util";import At from"process";import{execFile as Os}from"child_process";import{promisify as ys}from"util";import ws from"process";import{execFile as bs}from"child_process";var vs=ys(bs);async function xt(){if(ws.platform!=="darwin")throw new Error("macOS only");let{stdout:e}=await vs("defaults",["read","com.apple.LaunchServices/com.apple.launchservices.secure","LSHandlers"]),r=/LSHandlerRoleAll = "(?!-)(?<id>[^"]+?)";\s+?LSHandlerURLScheme = (?:http|https);/.exec(e)?.groups.id??"com.apple.Safari";return r==="com.apple.safari"?"com.apple.Safari":r}import xs from"process";import{promisify as Es}from"util";import{execFile as Ss,execFileSync as Yc}from"child_process";var Rs=Es(Ss);async function Gr(e,{humanReadableOutput:t=!0,signal:r}={}){if(xs.platform!=="darwin")throw new Error("macOS only");let n=t?[]:["-ss"],o={};r&&(o.signal=r);let{stdout:s}=await Rs("osascript",["-e",e,n],o);return s.trim()}async function Et(e){return Gr(`tell application "Finder" to set app_path to application file id "${e}" as string
8
- tell application "System Events" to get value of property list item "CFBundleName" of property list file (app_path & ":Contents:Info.plist")`)}import{promisify as Ps}from"util";import{execFile as As}from"child_process";var Cs=Ps(As),He={MSEdgeHTM:{name:"Edge",id:"com.microsoft.edge"},MSEdgeBHTML:{name:"Edge Beta",id:"com.microsoft.edge.beta"},MSEdgeDHTML:{name:"Edge Dev",id:"com.microsoft.edge.dev"},AppXq0fevzme2pys62n3e0fbqa7peapykr8v:{name:"Edge",id:"com.microsoft.edge.old"},ChromeHTML:{name:"Chrome",id:"com.google.chrome"},ChromeBHTML:{name:"Chrome Beta",id:"com.google.chrome.beta"},ChromeDHTML:{name:"Chrome Dev",id:"com.google.chrome.dev"},ChromiumHTM:{name:"Chromium",id:"org.chromium.Chromium"},BraveHTML:{name:"Brave",id:"com.brave.Browser"},BraveBHTML:{name:"Brave Beta",id:"com.brave.Browser.beta"},BraveDHTML:{name:"Brave Dev",id:"com.brave.Browser.dev"},BraveSSHTM:{name:"Brave Nightly",id:"com.brave.Browser.nightly"},FirefoxURL:{name:"Firefox",id:"org.mozilla.firefox"},OperaStable:{name:"Opera",id:"com.operasoftware.Opera"},VivaldiHTM:{name:"Vivaldi",id:"com.vivaldi.Vivaldi"},"IE.HTTP":{name:"Internet Explorer",id:"com.microsoft.ie"}},Rt=new Map(Object.entries(He)),St=class extends Error{};async function Pt(e=Cs){let{stdout:t}=await e("reg",["QUERY"," HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice","/v","ProgId"]),r=/ProgId\s*REG_SZ\s*(?<id>\S+)/.exec(t);if(!r)throw new St(`Cannot find Windows browser in stdout: ${JSON.stringify(t)}`);let{id:n}=r.groups,o=n.lastIndexOf("."),s=n.lastIndexOf("-"),i=o===-1?void 0:n.slice(0,o),a=s===-1?void 0:n.slice(0,s);return He[n]??He[i]??He[a]??{name:n,id:n}}var Ts=_s(Os),Ls=e=>e.toLowerCase().replaceAll(/(?:^|\s|-)\S/g,t=>t.toUpperCase());async function Ct(){if(At.platform==="darwin"){let e=await xt();return{name:await Et(e),id:e}}if(At.platform==="linux"){let{stdout:e}=await Ts("xdg-mime",["query","default","x-scheme-handler/http"]),t=e.trim();return{name:Ls(t.replace(/.desktop$/,"").replace("-"," ")),id:t}}if(At.platform==="win32")return Pt();throw new Error("Only macOS, Linux, and Windows are supported")}import _t from"process";var ks=!!(_t.env.SSH_CONNECTION||_t.env.SSH_CLIENT||_t.env.SSH_TTY),Yr=ks;var $e=Symbol("fallbackAttempt"),Ot=import.meta.url?tn.dirname(Ms(import.meta.url)):"",Xr=tn.join(Ot,"xdg-open"),{platform:ae,arch:Jr}=en,Qr=async(e,t)=>{if(e.length===0)return;let r=[];for(let n of e)try{return await t(n)}catch(o){r.push(o)}throw new AggregateError(r,"Failed to open in all supported apps")},Fe=async e=>{e={wait:!1,background:!1,newInstance:!1,allowNonzeroExitCode:!1,...e};let t=e[$e]===!0;if(delete e[$e],Array.isArray(e.app))return Qr(e.app,l=>Fe({...e,app:l,[$e]:!0}));let{name:r,arguments:n=[]}=e.app??{};if(n=[...n],Array.isArray(r))return Qr(r,l=>Fe({...e,app:{name:l,arguments:n},[$e]:!0}));if(r==="browser"||r==="browserPrivate"){let l={"com.google.chrome":"chrome","google-chrome.desktop":"chrome","com.brave.browser":"brave","org.mozilla.firefox":"firefox","firefox.desktop":"firefox","com.microsoft.msedge":"edge","com.microsoft.edge":"edge","com.microsoft.edgemac":"edge","microsoft-edge.desktop":"edge","com.apple.safari":"safari"},u={chrome:"--incognito",brave:"--incognito",firefox:"--private-window",edge:"--inPrivate"},d;if(H){let p=await Kr();d=Rt.get(p)??{}}else d=await Ct();if(d.id in l){let p=l[d.id.toLowerCase()];if(r==="browserPrivate"){if(p==="safari")throw new Error("Safari doesn't support opening in private mode via command line");n.push(u[p])}return Fe({...e,app:{name:ce[p],arguments:n}})}throw new Error(`${d.name} is not supported as a default browser`)}let o,s=[],i={},a=!1;if(H&&!ie()&&!Yr&&!r&&(a=await qr()),ae==="darwin")o="open",e.wait&&s.push("--wait-apps"),e.background&&s.push("--background"),e.newInstance&&s.push("--new"),r&&s.push("-a",r);else if(ae==="win32"||a){o=await Be(),s.push(...O.argumentsPrefix),H||(i.windowsVerbatimArguments=!0),H&&e.target&&(e.target=await Vr(e.target));let l=["$ProgressPreference = 'SilentlyContinue';","Start"];e.wait&&l.push("-Wait"),r?(l.push(O.escapeArgument(r)),e.target&&n.push(e.target)):e.target&&l.push(O.escapeArgument(e.target)),n.length>0&&(n=n.map(u=>O.escapeArgument(u)),l.push("-ArgumentList",n.join(","))),e.target=O.encodeCommand(l.join(" ")),e.wait||(i.stdio="ignore")}else{if(r)o=r;else{let l=!Ot||Ot==="/",u=!1;try{await Ds.access(Xr,Ns.X_OK),u=!0}catch{}o=en.versions.electron??(ae==="android"||l||!u)?"xdg-open":Xr}n.length>0&&s.push(...n),e.wait||(i.stdio="ignore",i.detached=!0)}ae==="darwin"&&n.length>0&&s.push("--args",...n),e.target&&s.push(e.target);let c=Is.spawn(o,s,i);return e.wait?new Promise((l,u)=>{c.once("error",u),c.once("close",d=>{if(!e.allowNonzeroExitCode&&d!==0){u(new Error(`Exited with code ${d}`));return}l(c)})}):t?new Promise((l,u)=>{c.once("error",u),c.once("spawn",()=>{c.once("close",d=>{if(c.off("error",u),d!==0){u(new Error(`Exited with code ${d}`));return}c.unref(),l(c)})})}):(c.unref(),new Promise((l,u)=>{c.once("error",u),c.once("spawn",()=>{c.off("error",u),l(c)})}))},Us=(e,t)=>{if(typeof e!="string")throw new TypeError("Expected a `target`");return Fe({...t,target:e})};function Zr(e){if(typeof e=="string"||Array.isArray(e))return e;let{[Jr]:t}=e;if(!t)throw new Error(`${Jr} is not supported`);return t}function be({[ae]:e},{wsl:t}={}){if(t&&H)return Zr(t);if(!e)throw new Error(`${ae} is not supported`);return Zr(e)}var ce={browser:"browser",browserPrivate:"browserPrivate"};Q(ce,"chrome",()=>be({darwin:"google chrome",win32:"chrome",linux:["google-chrome","google-chrome-stable","chromium","chromium-browser"]},{wsl:{ia32:"/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe",x64:["/mnt/c/Program Files/Google/Chrome/Application/chrome.exe","/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe"]}}));Q(ce,"brave",()=>be({darwin:"brave browser",win32:"brave",linux:["brave-browser","brave"]},{wsl:{ia32:"/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe",x64:["/mnt/c/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe","/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe"]}}));Q(ce,"firefox",()=>be({darwin:"firefox",win32:String.raw`C:\Program Files\Mozilla Firefox\firefox.exe`,linux:"firefox"},{wsl:"/mnt/c/Program Files/Mozilla Firefox/firefox.exe"}));Q(ce,"edge",()=>be({darwin:"microsoft edge",win32:"msedge",linux:["microsoft-edge","microsoft-edge-dev"]},{wsl:"/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"}));Q(ce,"safari",()=>be({darwin:"Safari"}));var rn=Us;function nn(e=""){return`<link rel="icon" type="image/svg+xml" href="${`${e.replace(/\/$/,"")}/favicon-black.svg?v=4`}" />`}import{existsSync as gn,readFileSync as Fs}from"fs";import F from"path";import{fileURLToPath as Ws}from"url";import{gunzipSync as zs}from"zlib";var $=Zn(mn(),1);function le(e,t){return e.header("Retry-After",String(Hs(t))),e.json({error:"Too Many Requests"},429)}function Hs(e){return e&&typeof e=="object"&&"msBeforeNext"in e&&typeof e.msBeforeNext=="number"&&Number.isFinite(e.msBeforeNext)?Math.max(1,Math.ceil(e.msBeforeNext/1e3)):60}var qs={".js":"application/javascript",".css":"text/css",".svg":"image/svg+xml",".png":"image/png",".ico":"image/x-icon",".webmanifest":"application/manifest+json"};function Ks(){let e=F.dirname(Ws(import.meta.url));for(let t of[F.resolve(e,"app"),F.resolve(e,"../app"),F.resolve(e,"../../dist/app")])if(gn(F.join(t,"inspector.js.gz")))return t;throw new Error("Inspector bundle not found (expected dist/app/inspector.js.gz)")}function yn(e,t="/inspector/assets"){let r=Ks(),n=new Map,o=new $.default({points:600,duration:60}),s=async(i,a)=>{try{await o.consume(i.req)}catch(c){return le(i,c)}return a()};e.use(`${t}/*`,s),e.get(`${t}/*`,async i=>{let a=i.req.path.slice(t.length),c=a.startsWith("/")?a.slice(1):a;if(!c||c.includes(".."))return i.notFound();let l=c==="inspector.js"||c==="inspector.css"?`${c}.gz`:c,u=F.resolve(r,l),d=r.endsWith(F.sep)?r:`${r}${F.sep}`;if(!u.startsWith(d)||!gn(u))return i.notFound();let p=F.extname(c),m=l.endsWith(".gz"),g=/(?:^|,)\s*gzip\s*(?:,|$)/i.test(i.req.header("accept-encoding")??""),h=Fs(u),y=m&&!g?n.get(u)??Vs(n,u,h):h,f=y.buffer.slice(y.byteOffset,y.byteOffset+y.byteLength);return i.body(f,200,{"Content-Type":qs[p]??"application/octet-stream",...m&&g?{"Content-Encoding":"gzip"}:{},...m?{Vary:"Accept-Encoding"}:{},"Cache-Control":"no-cache"})})}function Vs(e,t,r){let n=zs(r);return e.set(t,n),n}var wn={name:"@mcp-use/inspector",type:"module",version:"20.0.5-canary.0",description:"MCP Inspector - A tool for inspecting and debugging MCP servers",author:"",license:"MIT",homepage:"https://github.com/mcp-use/mcp-use#readme",repository:{type:"git",url:"git+https://github.com/mcp-use/mcp-use.git",directory:"libraries/typescript/packages/inspector"},bugs:{url:"https://github.com/mcp-use/mcp-use/issues"},keywords:["mcp","inspector","debug","tools"],exports:{".":{types:"./dist/server/index.d.ts",import:"./dist/server/index.js"},"./client":{types:"./dist/client/index.d.ts",import:"./dist/client/index.js"}},main:"./dist/server/index.js",types:"./dist/server/index.d.ts",bin:{"mcp-inspect":"./dist/cli.js"},files:["dist"],scripts:{dev:"rimraf node_modules/.vite && vite --strictPort","dev:client":"pnpm run dev","dev:server":"VITE_DEV=true tsx watch src/server/server.ts","dev:standalone":"tsx watch src/server/server.ts",clean:"rimraf dist",build:"npm run clean && npm run build:client-exports && npm run build:server && npm run build:app && npm run verify:package","build:app":"vite build --config vite.app.config.ts && node scripts/compress-app.mjs","watch:app":"vite build --watch --config vite.app.config.ts","preview:app":"vite preview --config vite.app.config.ts --host 127.0.0.1","serve:app":"pnpm build:app && pnpm preview:app","analyze:app":"ANALYZE=true vite build --config vite.app.config.ts","build:client-exports":"tsup --config tsup.client.ts","build:server":"tsup --config tsup.server.ts","verify:package":"node scripts/verify-package.mjs",prepublishOnly:"pnpm --filter @mcp-use/client build && pnpm build",start:"node dist/cli.js --port 3000",preview:"vite preview","type-check":"tsc --noEmit",lint:"eslint .","lint:fix":"eslint . --fix","test:e2e":"playwright test","test:e2e:ui":"playwright test --ui","test:e2e:debug":"playwright test --debug","test:e2e:builtin":"node tests/e2e/scripts/run-test-matrix.mjs builtin","test:e2e:prod":"node tests/e2e/scripts/run-test-matrix.mjs prod","test:e2e:mix":"node tests/e2e/scripts/run-test-matrix.mjs mix","test:e2e:prod:ui":"TEST_MODE=production playwright test --ui","test:e2e:codegen":"playwright codegen http://localhost:3000/inspector","test:e2e:report":"playwright show-report","test:e2e:python":"node tests/e2e/scripts/run-python-e2e.mjs","test:unit":"vitest run","test:unit:watch":"vitest","test:e2e:tunnel":"node tests/e2e/scripts/run-tunnel-test.mjs","install:pnpm":"pnpm install","install:npm":"npm install","lint:npm":"npm run lint:fix","lint:pnpm":"pnpm lint:fix"},engines:{node:">=22.22.2"},peerDependencies:{"@base-ui/react":"^1.6.0","@mcp-use/agent":"^2.0.2-canary.0","@mcp-use/client":"^2.0.2-canary.0","class-variance-authority":"^0.7.1",clsx:"^2.1.1",express:"^4.21.2 || ^5.0.0","lucide-react":"^0.562.0","markdown-to-jsx":"^9.7.4","mcp-use":"workspace:*",motion:"^12.34.2",react:"^18.0.0 || ^19.0.0","react-dom":"^18.0.0 || ^19.0.0","react-resizable-panels":"^4.6.4",sonner:"^2.0.7","tailwind-merge":"^3.5.0"},peerDependenciesMeta:{"@base-ui/react":{optional:!0},"@mcp-use/agent":{optional:!0},"@mcp-use/client":{optional:!0},"class-variance-authority":{optional:!0},clsx:{optional:!0},express:{optional:!0},"lucide-react":{optional:!0},"markdown-to-jsx":{optional:!0},"mcp-use":{optional:!0},motion:{optional:!0},react:{optional:!0},"react-dom":{optional:!0},"react-resizable-panels":{optional:!0},sonner:{optional:!0},"tailwind-merge":{optional:!0}},dependencies:{},publishConfig:{access:"public"},devDependencies:{"@base-ui/react":"^1.6.0","@hono/node-server":"^2.0.5","@mcp-use/agent":"workspace:*","@mcp-use/client":"workspace:*","@playwright/test":"^1.58.2","@tailwindcss/vite":"^4.2.0","@types/express":"^5.0.6","@vitejs/plugin-react":"^6.0.0","class-variance-authority":"^0.7.1",clsx:"^2.1.1",emulate:"0.5.0",eslint:"^9.39.2",express:"^5.2.1",hono:"^4.12.34","lucide-react":"^0.562.0","markdown-to-jsx":"^9.7.4",motion:"^12.34.2","oauth2-mock-server":"^8.2.2",open:"^11.0.0",react:"^19.2.3","react-dom":"^19.2.3","react-router":"^8.3.0","react-resizable-panels":"^4.6.4","rate-limiter-flexible":"^11.2.0","rollup-plugin-visualizer":"^6.0.3",sonner:"^2.0.7","tailwind-merge":"^3.5.0",tailwindcss:"^4.2.0",tsup:"^8.5.1",tsx:"^4.21.0","tw-animate-css":"^1.4.0",typescript:"^5.9.3",vite:"^8.0.16",vitest:"^4.1.0","wait-on":"^9.0.4",zod:"^4.2.0"}};var Ys=wn.version;function We(){return Ys}var Xs=`<!doctype html>
8
+ tell application "System Events" to get value of property list item "CFBundleName" of property list file (app_path & ":Contents:Info.plist")`)}import{promisify as Ps}from"util";import{execFile as As}from"child_process";var Cs=Ps(As),He={MSEdgeHTM:{name:"Edge",id:"com.microsoft.edge"},MSEdgeBHTML:{name:"Edge Beta",id:"com.microsoft.edge.beta"},MSEdgeDHTML:{name:"Edge Dev",id:"com.microsoft.edge.dev"},AppXq0fevzme2pys62n3e0fbqa7peapykr8v:{name:"Edge",id:"com.microsoft.edge.old"},ChromeHTML:{name:"Chrome",id:"com.google.chrome"},ChromeBHTML:{name:"Chrome Beta",id:"com.google.chrome.beta"},ChromeDHTML:{name:"Chrome Dev",id:"com.google.chrome.dev"},ChromiumHTM:{name:"Chromium",id:"org.chromium.Chromium"},BraveHTML:{name:"Brave",id:"com.brave.Browser"},BraveBHTML:{name:"Brave Beta",id:"com.brave.Browser.beta"},BraveDHTML:{name:"Brave Dev",id:"com.brave.Browser.dev"},BraveSSHTM:{name:"Brave Nightly",id:"com.brave.Browser.nightly"},FirefoxURL:{name:"Firefox",id:"org.mozilla.firefox"},OperaStable:{name:"Opera",id:"com.operasoftware.Opera"},VivaldiHTM:{name:"Vivaldi",id:"com.vivaldi.Vivaldi"},"IE.HTTP":{name:"Internet Explorer",id:"com.microsoft.ie"}},Rt=new Map(Object.entries(He)),St=class extends Error{};async function Pt(e=Cs){let{stdout:t}=await e("reg",["QUERY"," HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice","/v","ProgId"]),r=/ProgId\s*REG_SZ\s*(?<id>\S+)/.exec(t);if(!r)throw new St(`Cannot find Windows browser in stdout: ${JSON.stringify(t)}`);let{id:n}=r.groups,o=n.lastIndexOf("."),s=n.lastIndexOf("-"),i=o===-1?void 0:n.slice(0,o),a=s===-1?void 0:n.slice(0,s);return He[n]??He[i]??He[a]??{name:n,id:n}}var Ts=_s(Os),Ls=e=>e.toLowerCase().replaceAll(/(?:^|\s|-)\S/g,t=>t.toUpperCase());async function Ct(){if(At.platform==="darwin"){let e=await xt();return{name:await Et(e),id:e}}if(At.platform==="linux"){let{stdout:e}=await Ts("xdg-mime",["query","default","x-scheme-handler/http"]),t=e.trim();return{name:Ls(t.replace(/.desktop$/,"").replace("-"," ")),id:t}}if(At.platform==="win32")return Pt();throw new Error("Only macOS, Linux, and Windows are supported")}import _t from"process";var ks=!!(_t.env.SSH_CONNECTION||_t.env.SSH_CLIENT||_t.env.SSH_TTY),Yr=ks;var $e=Symbol("fallbackAttempt"),Ot=import.meta.url?tn.dirname(Ms(import.meta.url)):"",Xr=tn.join(Ot,"xdg-open"),{platform:ae,arch:Jr}=en,Qr=async(e,t)=>{if(e.length===0)return;let r=[];for(let n of e)try{return await t(n)}catch(o){r.push(o)}throw new AggregateError(r,"Failed to open in all supported apps")},Fe=async e=>{e={wait:!1,background:!1,newInstance:!1,allowNonzeroExitCode:!1,...e};let t=e[$e]===!0;if(delete e[$e],Array.isArray(e.app))return Qr(e.app,l=>Fe({...e,app:l,[$e]:!0}));let{name:r,arguments:n=[]}=e.app??{};if(n=[...n],Array.isArray(r))return Qr(r,l=>Fe({...e,app:{name:l,arguments:n},[$e]:!0}));if(r==="browser"||r==="browserPrivate"){let l={"com.google.chrome":"chrome","google-chrome.desktop":"chrome","com.brave.browser":"brave","org.mozilla.firefox":"firefox","firefox.desktop":"firefox","com.microsoft.msedge":"edge","com.microsoft.edge":"edge","com.microsoft.edgemac":"edge","microsoft-edge.desktop":"edge","com.apple.safari":"safari"},u={chrome:"--incognito",brave:"--incognito",firefox:"--private-window",edge:"--inPrivate"},d;if(H){let p=await Kr();d=Rt.get(p)??{}}else d=await Ct();if(d.id in l){let p=l[d.id.toLowerCase()];if(r==="browserPrivate"){if(p==="safari")throw new Error("Safari doesn't support opening in private mode via command line");n.push(u[p])}return Fe({...e,app:{name:ce[p],arguments:n}})}throw new Error(`${d.name} is not supported as a default browser`)}let o,s=[],i={},a=!1;if(H&&!ie()&&!Yr&&!r&&(a=await qr()),ae==="darwin")o="open",e.wait&&s.push("--wait-apps"),e.background&&s.push("--background"),e.newInstance&&s.push("--new"),r&&s.push("-a",r);else if(ae==="win32"||a){o=await Be(),s.push(...O.argumentsPrefix),H||(i.windowsVerbatimArguments=!0),H&&e.target&&(e.target=await Vr(e.target));let l=["$ProgressPreference = 'SilentlyContinue';","Start"];e.wait&&l.push("-Wait"),r?(l.push(O.escapeArgument(r)),e.target&&n.push(e.target)):e.target&&l.push(O.escapeArgument(e.target)),n.length>0&&(n=n.map(u=>O.escapeArgument(u)),l.push("-ArgumentList",n.join(","))),e.target=O.encodeCommand(l.join(" ")),e.wait||(i.stdio="ignore")}else{if(r)o=r;else{let l=!Ot||Ot==="/",u=!1;try{await Ds.access(Xr,Ns.X_OK),u=!0}catch{}o=en.versions.electron??(ae==="android"||l||!u)?"xdg-open":Xr}n.length>0&&s.push(...n),e.wait||(i.stdio="ignore",i.detached=!0)}ae==="darwin"&&n.length>0&&s.push("--args",...n),e.target&&s.push(e.target);let c=Is.spawn(o,s,i);return e.wait?new Promise((l,u)=>{c.once("error",u),c.once("close",d=>{if(!e.allowNonzeroExitCode&&d!==0){u(new Error(`Exited with code ${d}`));return}l(c)})}):t?new Promise((l,u)=>{c.once("error",u),c.once("spawn",()=>{c.once("close",d=>{if(c.off("error",u),d!==0){u(new Error(`Exited with code ${d}`));return}c.unref(),l(c)})})}):(c.unref(),new Promise((l,u)=>{c.once("error",u),c.once("spawn",()=>{c.off("error",u),l(c)})}))},Us=(e,t)=>{if(typeof e!="string")throw new TypeError("Expected a `target`");return Fe({...t,target:e})};function Zr(e){if(typeof e=="string"||Array.isArray(e))return e;let{[Jr]:t}=e;if(!t)throw new Error(`${Jr} is not supported`);return t}function be({[ae]:e},{wsl:t}={}){if(t&&H)return Zr(t);if(!e)throw new Error(`${ae} is not supported`);return Zr(e)}var ce={browser:"browser",browserPrivate:"browserPrivate"};Q(ce,"chrome",()=>be({darwin:"google chrome",win32:"chrome",linux:["google-chrome","google-chrome-stable","chromium","chromium-browser"]},{wsl:{ia32:"/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe",x64:["/mnt/c/Program Files/Google/Chrome/Application/chrome.exe","/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe"]}}));Q(ce,"brave",()=>be({darwin:"brave browser",win32:"brave",linux:["brave-browser","brave"]},{wsl:{ia32:"/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe",x64:["/mnt/c/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe","/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe"]}}));Q(ce,"firefox",()=>be({darwin:"firefox",win32:String.raw`C:\Program Files\Mozilla Firefox\firefox.exe`,linux:"firefox"},{wsl:"/mnt/c/Program Files/Mozilla Firefox/firefox.exe"}));Q(ce,"edge",()=>be({darwin:"microsoft edge",win32:"msedge",linux:["microsoft-edge","microsoft-edge-dev"]},{wsl:"/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"}));Q(ce,"safari",()=>be({darwin:"Safari"}));var rn=Us;function nn(e=""){return`<link rel="icon" type="image/svg+xml" href="${`${e.replace(/\/$/,"")}/favicon-black.svg?v=4`}" />`}import{existsSync as gn,readFileSync as Fs}from"fs";import F from"path";import{fileURLToPath as Ws}from"url";import{gunzipSync as zs}from"zlib";var $=Zn(mn(),1);function le(e,t){return e.header("Retry-After",String(Hs(t))),e.json({error:"Too Many Requests"},429)}function Hs(e){return e&&typeof e=="object"&&"msBeforeNext"in e&&typeof e.msBeforeNext=="number"&&Number.isFinite(e.msBeforeNext)?Math.max(1,Math.ceil(e.msBeforeNext/1e3)):60}var qs={".js":"application/javascript",".css":"text/css",".svg":"image/svg+xml",".png":"image/png",".ico":"image/x-icon",".webmanifest":"application/manifest+json"};function Ks(){let e=F.dirname(Ws(import.meta.url));for(let t of[F.resolve(e,"app"),F.resolve(e,"../app"),F.resolve(e,"../../dist/app")])if(gn(F.join(t,"inspector.js.gz")))return t;throw new Error("Inspector bundle not found (expected dist/app/inspector.js.gz)")}function yn(e,t="/inspector/assets"){let r=Ks(),n=new Map,o=new $.default({points:600,duration:60}),s=async(i,a)=>{try{await o.consume(i.req)}catch(c){return le(i,c)}return a()};e.use(`${t}/*`,s),e.get(`${t}/*`,async i=>{let a=i.req.path.slice(t.length),c=a.startsWith("/")?a.slice(1):a;if(!c||c.includes(".."))return i.notFound();let l=c==="inspector.js"||c==="inspector.css"?`${c}.gz`:c,u=F.resolve(r,l),d=r.endsWith(F.sep)?r:`${r}${F.sep}`;if(!u.startsWith(d)||!gn(u))return i.notFound();let p=F.extname(c),m=l.endsWith(".gz"),g=/(?:^|,)\s*gzip\s*(?:,|$)/i.test(i.req.header("accept-encoding")??""),h=Fs(u),y=m&&!g?n.get(u)??Vs(n,u,h):h,f=y.buffer.slice(y.byteOffset,y.byteOffset+y.byteLength);return i.body(f,200,{"Content-Type":qs[p]??"application/octet-stream",...m&&g?{"Content-Encoding":"gzip"}:{},...m?{Vary:"Accept-Encoding"}:{},"Cache-Control":"no-cache"})})}function Vs(e,t,r){let n=zs(r);return e.set(t,n),n}var wn={name:"@mcp-use/inspector",type:"module",version:"20.0.5-canary.2",description:"MCP Inspector - A tool for inspecting and debugging MCP servers",author:"",license:"MIT",homepage:"https://github.com/mcp-use/mcp-use#readme",repository:{type:"git",url:"git+https://github.com/mcp-use/mcp-use.git",directory:"libraries/typescript/packages/inspector"},bugs:{url:"https://github.com/mcp-use/mcp-use/issues"},keywords:["mcp","inspector","debug","tools"],exports:{".":{types:"./dist/server/index.d.ts",import:"./dist/server/index.js"},"./client":{types:"./dist/client/index.d.ts",import:"./dist/client/index.js"}},main:"./dist/server/index.js",types:"./dist/server/index.d.ts",bin:{"mcp-inspect":"./dist/cli.js"},files:["dist"],scripts:{dev:"rimraf node_modules/.vite && vite --strictPort","dev:client":"pnpm run dev","dev:server":"VITE_DEV=true tsx watch src/server/server.ts","dev:standalone":"tsx watch src/server/server.ts",clean:"rimraf dist",build:"npm run clean && npm run build:client-exports && npm run build:server && npm run build:app && npm run verify:package","build:app":"vite build --config vite.app.config.ts && node scripts/compress-app.mjs","watch:app":"vite build --watch --config vite.app.config.ts","preview:app":"vite preview --config vite.app.config.ts --host 127.0.0.1","serve:app":"pnpm build:app && pnpm preview:app","analyze:app":"ANALYZE=true vite build --config vite.app.config.ts","build:client-exports":"tsup --config tsup.client.ts","build:server":"tsup --config tsup.server.ts","verify:package":"node scripts/verify-package.mjs",prepublishOnly:"pnpm --filter @mcp-use/client build && pnpm build",start:"node dist/cli.js --port 3000",preview:"vite preview","type-check":"tsc --noEmit",lint:"eslint .","lint:fix":"eslint . --fix","test:e2e":"playwright test","test:e2e:ui":"playwright test --ui","test:e2e:debug":"playwright test --debug","test:e2e:builtin":"node tests/e2e/scripts/run-test-matrix.mjs builtin","test:e2e:prod":"node tests/e2e/scripts/run-test-matrix.mjs prod","test:e2e:mix":"node tests/e2e/scripts/run-test-matrix.mjs mix","test:e2e:prod:ui":"TEST_MODE=production playwright test --ui","test:e2e:codegen":"playwright codegen http://localhost:3000/inspector","test:e2e:report":"playwright show-report","test:e2e:python":"node tests/e2e/scripts/run-python-e2e.mjs","test:unit":"vitest run","test:unit:watch":"vitest","test:e2e:tunnel":"node tests/e2e/scripts/run-tunnel-test.mjs","install:pnpm":"pnpm install","install:npm":"npm install","lint:npm":"npm run lint:fix","lint:pnpm":"pnpm lint:fix"},engines:{node:">=22.22.2"},peerDependencies:{"@base-ui/react":"^1.6.0","@mcp-use/agent":"^2.0.2-canary.0","@mcp-use/client":"^2.0.2-canary.0","class-variance-authority":"^0.7.1",clsx:"^2.1.1",express:"^4.21.2 || ^5.0.0","lucide-react":"^0.562.0","markdown-to-jsx":"^9.7.4","mcp-use":"workspace:*",motion:"^12.34.2",react:"^18.0.0 || ^19.0.0","react-dom":"^18.0.0 || ^19.0.0","react-resizable-panels":"^4.6.4",sonner:"^2.0.7","tailwind-merge":"^3.5.0"},peerDependenciesMeta:{"@base-ui/react":{optional:!0},"@mcp-use/agent":{optional:!0},"@mcp-use/client":{optional:!0},"class-variance-authority":{optional:!0},clsx:{optional:!0},express:{optional:!0},"lucide-react":{optional:!0},"markdown-to-jsx":{optional:!0},"mcp-use":{optional:!0},motion:{optional:!0},react:{optional:!0},"react-dom":{optional:!0},"react-resizable-panels":{optional:!0},sonner:{optional:!0},"tailwind-merge":{optional:!0}},dependencies:{},publishConfig:{access:"public"},devDependencies:{"@base-ui/react":"^1.6.0","@hono/node-server":"^2.0.5","@mcp-use/agent":"workspace:*","@mcp-use/client":"workspace:*","@playwright/test":"^1.58.2","@tailwindcss/vite":"^4.2.0","@types/express":"^5.0.6","@vitejs/plugin-react":"^6.0.0","class-variance-authority":"^0.7.1",clsx:"^2.1.1",emulate:"0.5.0",eslint:"^9.39.2",express:"^5.2.1",hono:"^4.12.34","lucide-react":"^0.562.0","markdown-to-jsx":"^9.7.4",motion:"^12.34.2","oauth2-mock-server":"^8.2.2",open:"^11.0.0",react:"^19.2.3","react-dom":"^19.2.3","react-router":"^8.3.0","react-resizable-panels":"^4.6.4","rate-limiter-flexible":"^11.2.0","rollup-plugin-visualizer":"^6.0.3",sonner:"^2.0.7","tailwind-merge":"^3.5.0",tailwindcss:"^4.2.0",tsup:"^8.5.1",tsx:"^4.21.0","tw-animate-css":"^1.4.0",typescript:"^5.9.3",vite:"^8.0.16",vitest:"^4.1.0","wait-on":"^9.0.4",zod:"^4.2.0"}};var Ys=wn.version;function We(){return Ys}var Xs=`<!doctype html>
9
9
  <html>
10
10
  <head>
11
11
  <meta charset="utf-8" />
@@ -99,7 +99,7 @@ Return ONLY JSON.`:`Resource Information:
99
99
  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:c},{role:"user",content:l}],f=await cf({config:{provider:e.provider,model:e.model,apiKey:e.apiKey,temperature:e.temperature,baseUrl:e.baseUrl},messages:u});try{let d=df(f);if(d)return Object.entries(d).map(([v,p])=>({key:v,value:typeof p=="object"&&p!==null?JSON.stringify(p):String(p)}));let g=f.split(`
100
100
  `),m=[];for(let v of g){let p=v.match(/^\s*["']?(\w+)["']?\s*[:=]\s*["']?(.+?)["']?\s*,?\s*$/);p&&m.push({key:p[1].trim(),value:p[2].trim().replace(/^["']|["']$/g,"")})}if(m.length>0)return m;throw new Error("Could not parse props from LLM response")}catch(d){throw console.error("[usePropsLLM] Failed to parse LLM response:",d),new Error(`Failed to parse props from LLM response: ${f.slice(0,100)}...`)}},[e]),isAvailable:e!==null}}import{Loader2 as N0,Plus as k0,Sparkles as S0,Trash2 as T0}from"lucide-react";import{useEffect as R0,useMemo as P0,useState as ra}from"react";import{toast as kr}from"sonner";import{jsx as Tn,jsxs as Nr}from"react/jsx-runtime";function mf(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 w0(e,t){if(e.anyOf&&Array.isArray(e.anyOf)){let n=e.anyOf.find(o=>o.type!=="null");if(n)return{...mf(n,t),nullable:!0}}return e}function C0(e){return Array.isArray(e.enum)?e.enum:null}function pf({name:e,schema:t,value:n,onChange:o,required:r=!1,disabled:s=!1,rootSchema:a}){let i=a||t,c=w0(t,i);c=mf(c,i);let l=C0(c),u=c.type==="string"&&l!==null,f=c;return f.type==="object"||f.type==="array"?Nr("div",{className:"space-y-2",children:[Nr(tt,{htmlFor:e,className:"text-sm font-medium",children:[e,r&&Tn("span",{className:"text-red-500 ml-1",children:"*"})]}),Tn(Qn,{id:e,value:n,onChange:g=>o(g.target.value),placeholder:f?.description||f?.default?JSON.stringify(f.default,null,2):`Enter ${e}`,className:"min-h-[100px]",disabled:s}),f?.description&&Tn("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:f.description})]}):u&&l?Nr("div",{className:"space-y-2",children:[Nr(tt,{htmlFor:e,className:"text-sm font-medium",children:[e,r&&Tn("span",{className:"text-red-500 ml-1",children:"*"})]}),Nr(Sn,{value:n||"",onValueChange:o,disabled:s,children:[Tn(Un,{id:e,className:"w-full",children:Tn(Bn,{placeholder:f.description||"Select an option"})}),Tn(Hn,{children:l.map((g,m)=>Tn(Wt,{value:g,children:f.enumNames?.[m]||g},g))})]}),f.description&&Tn("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:f.description})]}):Nr("div",{className:"space-y-2",children:[Nr(tt,{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:g=>o(g.target.value),placeholder:f?.description||(f?.default!==void 0?String(f.default):`Enter ${e}`),type:f.type==="number"?"number":"text",disabled:s}),f?.description&&Tn("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:f.description})]})}import{Fragment as ff,jsx as Pt,jsxs as Ht}from"react/jsx-runtime";function gf({open:e,onOpenChange:t,onSave:n,existingPresets:o,resource:r,resourceAnnotations:s,llmConfig:a,editingPreset:i}){let c=P0(()=>{let I=L=>{if(!L)return null;if(L.type==="object"&&L.properties)return L;let _=L?.def?.shape??L?._def?.shape;if(_&&typeof _=="object"){let K={},F=[],Y=Q=>({ZodString:"string",string:"string",ZodNumber:"number",number:"number",ZodBoolean:"boolean",boolean:"boolean",ZodArray:"array",array:"array",ZodObject:"object",object:"object"})[Q]||"string",ee=Q=>Q?.typeName??Q?.type??"",$=Q=>{let V=Q?._def??Q?.def??{},Z=Q,be=ee(V);for(;be==="ZodOptional"||be==="ZodDefault"||be==="ZodNullable";){Z=V.innerType??Z;let q=Z?._def??Z?.def??{};be=ee(q)}let re=Y(be);if(re==="array"){let q=Z?._def?.type??Z?.def?.element??Z?.element;if(q){let W=q._def??q.def??{};if(Y(ee(W))==="object"){let de=W.shape??q._def?.shape??q.def?.shape??{};return{type:"array",items:{type:"object",properties:Object.fromEntries(Object.entries(de).map(([ke,Ne])=>{let ae=Ne?._def??Ne?.def??{};return[ke,{type:Y(ee(ae))}]}))}}}}return{type:"array"}}return{type:re}};for(let[Q,V]of Object.entries(_)){let Z=V,be=Z?._def??Z?.def??{},re=ee(be),q=re==="ZodOptional"||re==="ZodDefault"||re==="ZodNullable",W=$(Z);K[Q]={type:W.type,...W.items&&{items:W.items},description:Z?.description??be.description},q||F.push(Q)}if(Object.keys(K).length>0)return{type:"object",properties:K,required:F.length>0?F:void 0}}return null},k=s;if(k?.["mcp-use/propsSchema"])return I(k["mcp-use/propsSchema"]);let N=r.annotations;return N?.["mcp-use/propsSchema"]?I(N["mcp-use/propsSchema"]):null},[s,r.annotations,r.uri,r.name]),l=!!c,[u,f]=ra(""),[d,g]=ra({}),[m,v]=ra([{id:crypto.randomUUID(),key:"",value:""}]),[p,x]=ra(!1),[C,b]=ra(null),{generateProps:h,isAvailable:y}=uf({llmConfig:a});R0(()=>{if(e){if(i)if(f(i.name),l)g(i.props);else{let I=Object.entries(i.props).map(([k,N])=>({id:crypto.randomUUID(),key:k,value:N}));v(I.length>0?I:[{id:crypto.randomUUID(),key:"",value:""}])}else f(""),l?g({}):v([{id:crypto.randomUUID(),key:"",value:""}]);b(null)}},[e,i,l]);let R=()=>{v([...m,{id:crypto.randomUUID(),key:"",value:""}])},P=I=>{m.length>1&&v(m.filter(k=>k.id!==I))},S=(I,k,N)=>{v(m.map(L=>L.id===I?{...L,[k]:N}:L))},T=async()=>{if(!y){kr.error("LLM not configured",{description:"Please configure LLM in the Chat tab first."});return}x(!0),b(null);try{let I=await h({resource:r,resourceAnnotations:s,propsSchema:l?c:void 0});if(l){let k={};for(let N of I)c.properties?.[N.key]&&(k[N.key]=N.value);g(k)}else v(I.map(k=>({id:crypto.randomUUID(),key:k.key,value:k.value})));kr.success("Props generated successfully",{description:`Generated ${I.length} prop(s) using ${a?.provider}`})}catch(I){let k=I instanceof Error?I.message:"Failed to generate props";b(k),kr.error("LLM Generation Failed",{description:k})}finally{x(!1)}},M=()=>{if(!u.trim()){kr.error("Preset name required",{description:"Please enter a name for this preset."});return}if(o.find(L=>L.name.toLowerCase()===u.toLowerCase()&&L.id!==i?.id)){kr.error("Duplicate preset name",{description:"A preset with this name already exists."});return}let k;if(l)k={...d};else{k={};for(let L of m)L.key.trim()&&(k[L.key.trim()]=L.value)}if(Object.keys(k).length===0){kr.error("No props defined",{description:"Please add at least one prop with a key."});return}let N={id:i?.id||crypto.randomUUID(),name:u.trim(),props:k};n(N),t(!1),kr.success(i?"Preset updated":"Preset created",{description:`Preset "${N.name}" saved successfully.`})};return Pt(fn,{open:e,onOpenChange:t,children:Ht(rn,{scrollable:!0,className:"sm:max-w-[600px] max-h-[80vh]","data-testid":"props-config-dialog",children:[Ht(Xt,{children:[Pt(qt,{children:i?"Edit Preset":"Create Props Preset"}),Ht(mo,{children:["Configure props for ",r.name||r.uri,". You can manually add key-value pairs or generate them with AI."]})]}),Ht(zn,{className:"space-y-4 py-4",children:[Ht("div",{className:"space-y-2",children:[Pt(tt,{htmlFor:"preset-name",children:"Preset Name"}),Pt(Ge,{id:"preset-name","data-testid":"props-config-preset-name",value:u,onChange:I=>f(I.target.value),placeholder:"e.g., Dark Theme, Production Config",disabled:p})]}),Ht("div",{className:"space-y-2 p-3 bg-muted rounded-lg",children:[Ht("div",{className:"flex items-center justify-between",children:[Pt(tt,{className:"text-sm font-medium",children:"Generate with AI"}),y&&Ht("span",{className:"text-xs text-muted-foreground",children:["Using ",a?.provider," (",a?.model,")"]})]}),y?Pt(A,{onClick:T,disabled:p,size:"sm",variant:"outline",className:"w-full","data-testid":"props-config-generate-llm-button",children:p?Ht("span",{"data-testid":"props-config-generating",className:"flex items-center gap-2",children:[Pt(N0,{className:"h-4 w-4 mr-2 animate-spin"}),"Generating..."]}):Ht(ff,{children:[Pt(S0,{className:"h-4 w-4 mr-2"}),"Generate Props with LLM"]})}):Pt("p",{className:"text-xs text-muted-foreground",children:"LLM not configured. Please configure LLM in the Chat tab to use this feature."}),C&&Pt("p",{className:"text-xs text-destructive","data-testid":"props-config-error",children:C})]}),Ht("div",{className:"space-y-3",children:[Pt(tt,{className:"text-sm font-medium",children:"Props"}),l?Pt("div",{className:"space-y-4",children:Object.entries(c.properties||{}).map(([I,k])=>Pt(pf,{name:I,schema:k,value:d[I]||"",onChange:N=>g(L=>({...L,[I]:N})),required:c.required?.includes(I),disabled:p,rootSchema:c},I))}):Ht(ff,{children:[Pt("div",{className:"flex items-center justify-between",children:Ht(A,{onClick:R,size:"sm",variant:"ghost",disabled:p,"data-testid":"props-config-add-prop",children:[Pt(k0,{className:"h-4 w-4 mr-1"}),"Add Prop"]})}),m.map((I,k)=>Ht("div",{className:"flex items-center gap-2",children:[Ht("div",{className:"flex-1 grid grid-cols-2 gap-2",children:[Pt(Ge,{placeholder:"Key",value:I.key,onChange:N=>S(I.id,"key",N.target.value),disabled:p,"data-testid":`props-config-key-${k}`}),Pt(Ge,{placeholder:"Value",value:I.value,onChange:N=>S(I.id,"value",N.target.value),disabled:p,"data-testid":`props-config-value-${k}`})]}),Pt(A,{variant:"ghost",size:"sm",onClick:()=>P(I.id),disabled:m.length===1||p,className:"h-9 w-9 p-0","data-testid":`props-config-remove-${k}`,children:Pt(T0,{className:"h-4 w-4 text-muted-foreground"})})]},I.id))]})]})]}),Ht(bi,{children:[Pt(A,{variant:"outline",onClick:()=>t(!1),disabled:p,"data-testid":"props-config-cancel-button",children:"Cancel"}),Ht(A,{onClick:M,disabled:p,"data-testid":"props-config-save-button",children:[i?"Update":"Create"," Preset"]})]})]})})}function hf(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 vf(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 bf=100*1024,yf=1024*20;function qi(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=>qi(n,t));if(typeof e=="object"){let n={};for(let o in e)Object.prototype.hasOwnProperty.call(e,o)&&(n[o]=qi(e[o],t));return n}return e}function xf(e){let t=JSON.stringify(e,null,2);return new TextEncoder().encode(t).length>bf?qi(e,yf):e}function Wi(e){let t=JSON.stringify(e,null,2),n=new TextEncoder().encode(t).length,o=n>bf,r;if(o){let a=qi(e,yf);r=JSON.stringify(a,null,2)}else r=t;let s=hf(n);return{isLarge:o,size:n,sizeFormatted:s,preview:r,full:t}}function Ki(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 E0}from"react/jsx-runtime";var M0={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 I0(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 c=e[i]===":";o(c?"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 Kc(e){return I0(e).map((t,n)=>E0("span",{className:M0[t.kind],children:t.text},n))}import{Download as O0}from"lucide-react";import{ChevronRight as A0}from"lucide-react";import{useState as L0}from"react";import{Fragment as Ji,jsx as yt,jsxs as eo}from"react/jsx-runtime";var en={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 D0(e){return e===null?yt("span",{className:en.null,children:"null"}):typeof e=="string"?yt("span",{className:en.string,children:JSON.stringify(e)}):typeof e=="number"?yt("span",{className:en.number,children:String(e)}):typeof e=="boolean"?yt("span",{className:en.boolean,children:String(e)}):yt("span",{className:en.string,children:JSON.stringify(e)})}function _0(e){return Array.isArray(e)?`[${e.length}]`:`{${Object.keys(e).length}}`}function wf({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]=L0(r&&(o||n===0));if(!r){let d=Array.isArray(t)?"[]":"{}";return t!==null&&typeof t=="object"?eo("div",{className:"font-mono text-[0.8rem] leading-relaxed",style:{paddingLeft:n*12},children:[e!=null&&eo(Ji,{children:[yt("span",{className:en.key,children:JSON.stringify(e)}),yt("span",{className:en.punctuation,children:": "})]}),yt("span",{className:en.punctuation,children:d})]}):eo("div",{className:"font-mono text-[0.8rem] leading-relaxed",style:{paddingLeft:n*12},children:[e!=null&&eo(Ji,{children:[yt("span",{className:en.key,children:JSON.stringify(e)}),yt("span",{className:en.punctuation,children:": "})]}),D0(t)]})}let i=Array.isArray(t)?t.map((f,d)=>[String(d),f]):Object.entries(t),c=Array.isArray(t),l=c?"[":"{",u=c?"]":"}";return eo("div",{className:"font-mono text-[0.8rem] leading-relaxed",children:[eo("div",{className:"flex items-start gap-0.5",style:{paddingLeft:n*12},children:[yt("button",{type:"button","aria-expanded":s,onClick:()=>a(f=>!f),className:"mt-0.5 inline-flex shrink-0 items-center justify-center rounded-sm text-muted-foreground hover:text-foreground",children:yt(A0,{className:w("h-3.5 w-3.5 transition-transform",s&&"rotate-90")})}),eo("div",{className:"min-w-0 flex-1",children:[e!=null&&eo(Ji,{children:[yt("span",{className:en.key,children:JSON.stringify(e)}),yt("span",{className:en.punctuation,children:": "})]}),yt("span",{className:en.punctuation,children:l}),!s&&eo(Ji,{children:[yt("button",{type:"button",onClick:()=>a(!0),className:"mx-1 text-xs text-muted-foreground hover:text-foreground",children:_0(t)}),yt("span",{className:en.punctuation,children:u})]})]})]}),s&&eo("div",{children:[i.map(([f,d])=>yt(wf,{label:f,value:d,depth:n+1,defaultExpanded:o},`${n}-${f}`)),yt("div",{style:{paddingLeft:n*12},children:yt("span",{className:en.punctuation,children:u})})]})]})}function Cf({data:e,defaultExpanded:t=!0,className:n}){return yt("div",{className:w("text-gray-900 dark:text-gray-100 [overflow-wrap:anywhere]",n),"data-testid":"collapsible-json",children:yt(wf,{value:e,depth:0,defaultExpanded:t})})}import{jsx as fo,jsxs as ms}from"react/jsx-runtime";var Nf="font-mono text-[0.8rem] text-gray-900 dark:text-gray-100 whitespace-pre-wrap break-words [overflow-wrap:anywhere]";function xt({data:e,filename:t,className:n,collapsible:o=!1,defaultExpanded:r=!0,...s}){let a=Wi(e),i=xf(e),c=()=>{Ki(e,t)},l=a.isLarge?fo("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:ms("div",{className:"flex items-center justify-between gap-2",children:[ms("div",{className:"flex-1",children:[ms("p",{className:"text-sm font-medium text-yellow-800 dark:text-yellow-300 mb-1",children:["JSON is too large (",a.sizeFormatted,")"]}),fo("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."})]}),ms(A,{variant:"outline",size:"sm",onClick:c,className:"shrink-0",children:[fo(O0,{className:"h-4 w-4 mr-1"}),"Download"]})]})}):null;return o?ms("div",{className:n,...s,children:[l,fo(Cf,{data:i,defaultExpanded:r})]}):a.isLarge?ms("div",{className:n,...s,children:[l,fo("pre",{className:Nf,children:fo("code",{children:Kc(a.preview)})})]}):fo("div",{className:n,...s,children:fo("pre",{className:Nf,children:fo("code",{children:Kc(a.preview)})})})}import{jsx as $o,jsxs as sa}from"react/jsx-runtime";function kf({value:e,onChange:t}){let n=(o,r)=>{let s=parseInt(r,10);isNaN(s)||t({...e,[o]:s})};return sa("div",{className:"grid grid-cols-2 gap-2",children:[sa("div",{className:"space-y-1",children:[$o("label",{className:"text-xs text-muted-foreground",children:"Top"}),$o(Ge,{type:"number",min:"0",value:e.top,onChange:o=>n("top",o.target.value),className:"h-8","data-testid":"debugger-safe-area-top"})]}),sa("div",{className:"space-y-1",children:[$o("label",{className:"text-xs text-muted-foreground",children:"Right"}),$o(Ge,{type:"number",min:"0",value:e.right,onChange:o=>n("right",o.target.value),className:"h-8","data-testid":"debugger-safe-area-right"})]}),sa("div",{className:"space-y-1",children:[$o("label",{className:"text-xs text-muted-foreground",children:"Bottom"}),$o(Ge,{type:"number",min:"0",value:e.bottom,onChange:o=>n("bottom",o.target.value),className:"h-8","data-testid":"debugger-safe-area-bottom"})]}),sa("div",{className:"space-y-1",children:[$o("label",{className:"text-xs text-muted-foreground",children:"Left"}),$o(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 Sf(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 f=null;try{f=new URL(u).origin}catch{continue}if(!f)continue;let d=(l.effectiveDirective||l.directive||"").toLowerCase();d===a?(n.add(f),f.startsWith("http://")?n.add(f.replace("http://","ws://")):f.startsWith("https://")&&n.add(f.replace("https://","wss://"))):s.has(d)?o.add(f):d===i&&r.add(f)}let c={connectDomains:Array.from(n).sort(),resourceDomains:Array.from(o).sort()};return r.size>0&&(c.frameDomains=Array.from(r).sort()),c}var z0="https://raw.githubusercontent.com/modelcontextprotocol/ext-apps/bcfffb6585ea4fb1e3a9da39fb8911b83399fa71/specification/2026-01-26/apps.mdx",B0="https://mcp-use.com/docs/typescript/server/csp";function Tf(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: ${z0}`,`- mcp-use CSP docs: ${B0}`,""];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(`
101
101
  `)}import{Popover as aa}from"@base-ui/react/popover";import{jsx as ia}from"react/jsx-runtime";function Vo({...e}){return ia(aa.Root,{"data-slot":"popover",...e})}function jo(e){return ia(aa.Trigger,{"data-slot":"popover-trigger",...e})}function qo({className:e,align:t="center",alignOffset:n=0,side:o="bottom",sideOffset:r=4,...s}){return ia(aa.Portal,{children:ia(aa.Positioner,{align:t,alignOffset:n,side:o,sideOffset:r,className:"isolate z-50",children:ia(aa.Popup,{"data-slot":"popover-content",className:w("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 Df,jsx as H,jsxs as xe}from"react/jsx-runtime";var Sr="__no_props__",la="__tool_props__",Ef="__create_preset__",Af=[{value:"desktop",label:"Desktop",icon:_f},{value:"mobile",label:"Mobile",icon:Of}];function Lf({options:e,value:t,onValueChange:n,placeholder:o,contentTestId:r,searchTestId:s,optionTestId:a,trigger:i}){let[c,l]=go(!1),[u,f]=go(""),d=Q0(null);Gi(()=>{if(!c){f("");return}let v=requestAnimationFrame(()=>d.current?.focus());return()=>cancelAnimationFrame(v)},[c]);let g=ca(()=>{let v=u.trim().toLowerCase();return v?e.filter(p=>p.label.toLowerCase().includes(v)||p.value.toLowerCase().includes(v)):[...e]},[e,u]),m=g.findIndex(v=>v.value===t);return xe(hr,{open:c,onOpenChange:l,children:[i,xe(vr,{"data-testid":r,checkedIndex:m>=0?m:void 0,className:"w-80 overflow-hidden",children:[H("div",{className:"border-b border-border p-2",onKeyDown:v=>v.stopPropagation(),children:H(Ge,{ref:d,value:u,onChange:v=>f(v.target.value),placeholder:o,"data-testid":s,className:"h-8"})}),H("div",{className:"max-h-64 overflow-y-auto",children:g.length===0?H("p",{className:"px-3 py-4 text-xs text-muted-foreground",children:"No results found."}):g.map((v,p)=>H(pr,{index:p,label:v.label,checked:t===v.value,"data-testid":a(v.value),onSelect:()=>{n(v.value),l(!1)}},v.value))})]})]})}function Yi({displayMode:e,onDisplayModeChange:t,toolCallId:n,propsContext:o,resourceUri:r,toolInput:s,resourceAnnotations:a,llmConfig:i,resource:c,onPropsChange:l,requiredProps:u}){let{resolvedTheme:f,setTheme:d}=Zn(),{playground:g,updatePlaygroundSettings:m,widgets:v,clearCspViolations:p}=Ho(),x=v.get(n),C=x?.cspViolations??[],b=x?.declaredCsp,h=x?.effectivePolicy,y=C.length>0?Sf(C,b):null,R=C.length>0?Tf(b,h,C,y):"",P=e==="fullscreen",S=e==="pip",{presets:T,activePresetId:M,savePreset:I,deletePreset:k,setActivePreset:N,getActiveProps:L}=Kp(r),[_,K]=go(!1),Y=!!u?.length&&!M,[ee,$]=go(()=>Y);Gi(()=>{Y&&$(!0)},[Y]);let[Q,V]=go(null),[Z,be]=go(!1),[re,q]=go("mode"),[W,de]=go(!0),ke=ca(()=>fp(b),[b]),Ne=ca(()=>gp(h),[h]),ae=ca(()=>hp(ke,Ne),[ke,Ne]),G=ca(()=>vp({mode:g.cspMode,declared:b,effectivePolicy:h,violations:C}),[g.cspMode,b,h,C]),ne=X0(()=>o==="tool"&&s?la:Sr,[o,s]),[ue,Pe]=go(ne());Gi(()=>{M&&o!=="tool"?Pe(M):ue!==Sr&&ue!==la&&Pe(ne())},[M,ue,ne,o]),Gi(()=>{if(l){if(ue===Sr||ue===la)l(null);else if(M&&ue===M){let D=L();D&&l(D)}}},[ue,M,s,L,l,T]);let qe=D=>{if(D===Ef){V(null),K(!0);return}if(D===Sr||D===la)N(null),Pe(D),l?.(null);else{N(D),Pe(D);let ye=T.find(te=>te.id===D);l?.(ye?.props??null)}},it=D=>{I(D),N(D.id),Pe(D.id),l?.(D.props)},Ve=(D,ye)=>{ye.stopPropagation();let te=T.find(ie=>ie.id===D);te&&(k(D),Jc.success("Preset deleted",{description:`Preset "${te.name}" has been deleted.`}))},Rt=(D,ye)=>{ye.stopPropagation(),V(D),K(!0)},ce=()=>g.deviceType==="mobile"?H(Of,{className:"size-3"}):H(_f,{className:"size-3"}),j=Af.findIndex(D=>D.value===g.deviceType);return xe("div",{className:"flex items-center gap-2",children:[!P&&!S&&xe(Df,{children:[xe(Re,{children:[H(Se,{render:H(A,{"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:H($0,{className:"size-4"})}),nativeButton:!0}),H(Te,{children:"Enter fullscreen mode"})]}),xe(Re,{children:[H(Se,{render:H(A,{"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:H(q0,{className:"size-4"})}),nativeButton:!0}),H(Te,{children:"Picture-in-picture"})]})]}),xe(hr,{children:[xe(Re,{children:[H(Se,{render:H(_o,{render:H(A,{"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:ce()}),nativeButton:!0}),nativeButton:!0}),xe(Te,{children:["Device: ",g.deviceType]})]}),H(vr,{"data-testid":"debugger-device-dialog",checkedIndex:j>=0?j:void 0,className:"w-56",children:Af.map((D,ye)=>H(pr,{index:ye,icon:D.icon,label:D.label,checked:g.deviceType===D.value,"data-testid":`debugger-device-option-${D.value}`,onSelect:()=>m({deviceType:D.value})},D.value))})]}),xe(Re,{children:[H(Se,{render:H(A,{"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:()=>{d(f==="dark"?"light":"dark")},children:f==="dark"?H(V0,{className:"size-3.5"}):H(G0,{className:"size-3.5"})}),nativeButton:!0}),xe(Te,{children:["Theme: ",f==="dark"?"Dark":"Light"]})]}),H(Lf,{options:$p,value:g.locale,onValueChange:D=>m({locale:D}),placeholder:"Search locales...",contentTestId:"debugger-locale-dialog",searchTestId:"debugger-locale-search",optionTestId:D=>`debugger-locale-option-${D}`,trigger:xe(Re,{children:[H(Se,{render:H(_o,{render:H(A,{"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:H("span",{className:"text-xs font-mono",children:g.locale})}),nativeButton:!0}),nativeButton:!0}),H(Te,{children:"Locale"})]})}),H(Lf,{options:Vp,value:g.timeZone,onValueChange:D=>m({timeZone:D}),placeholder:"Search timezones...",contentTestId:"debugger-timezone-dialog",searchTestId:"debugger-timezone-search",optionTestId:D=>`debugger-timezone-option-${D.replace(/\//g,"-")}`,trigger:xe(Re,{children:[H(Se,{render:H(_o,{render:H(A,{"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:H(F0,{className:"size-3.5"})}),nativeButton:!0}),nativeButton:!0}),xe(Te,{children:["Timezone: ",g.timeZone]})]})}),xe(fn,{open:Z,onOpenChange:be,children:[xe(Re,{children:[H(Se,{render:H(ic,{render:xe(A,{"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:[g.cspMode==="permissive"?H(If,{className:"size-3.5"}):H(Mf,{className:"size-3.5"}),C.length>0&&H("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 ${g.cspMode==="permissive"?"bg-yellow-500":"bg-red-500"}`,children:C.length>99?"99+":C.length})]}),nativeButton:!0}),nativeButton:!0}),xe(Te,{children:["CSP:"," ",g.cspMode==="permissive"?"Permissive":"Declared",C.length>0&&` \xB7 ${C.length} ${g.cspMode==="permissive"?"would be blocked":"blocked"}`]})]}),xe(rn,{scrollable:!0,className:"sm:max-w-[520px] max-h-[85vh]","data-testid":"debugger-csp-dialog",children:[H(Xt,{children:H(qt,{children:"CSP Mode"})}),xe(zn,{className:"space-y-3",children:[H("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(([D,ye])=>H("button",{type:"button",role:"tab","aria-selected":re===D,onClick:()=>q(D),className:`rounded px-2 py-1.5 text-xs font-medium ${re===D?"bg-zinc-100 dark:bg-zinc-800":"text-muted-foreground"}`,children:ye},D))}),re==="mode"&&xe("div",{role:"tabpanel",className:"space-y-2",children:[xe(A,{"data-testid":"debugger-csp-option-permissive",variant:g.cspMode==="permissive"?"default":"outline",className:"w-full justify-start",onClick:()=>m({cspMode:"permissive"}),children:[H(If,{className:"size-4 mr-2"}),"Permissive"]}),xe(A,{"data-testid":"debugger-csp-option-widget-declared",variant:g.cspMode==="widget-declared"?"default":"outline",className:"w-full justify-start",onClick:()=>m({cspMode:"widget-declared"}),children:[H(Mf,{className:"size-4 mr-2"}),"Widget-Declared"]}),H("p",{className:"text-xs text-muted-foreground",children:"Permissive records would-be blocks; Widget-Declared enforces the resource metadata policy."})]}),re==="diff"&&xe("div",{role:"tabpanel",className:"space-y-2",children:[ae.length?H("div",{className:"max-h-64 overflow-y-auto rounded border border-zinc-200 dark:border-zinc-700",children:ae.map(D=>xe("div",{className:"border-b border-zinc-100 dark:border-zinc-800 p-2 text-xs last:border-0",children:[xe("div",{className:"flex items-center justify-between",children:[H("code",{children:D.directive}),H("span",{className:"text-[10px] uppercase text-muted-foreground",children:D.status})]}),xe("div",{className:"mt-1 font-mono text-[10px] text-muted-foreground break-all",children:["requested: ",D.requested.join(" ")||"\u2014",H("br",{}),"effective: ",D.effective.join(" ")||"\u2014"]})]},D.directive))}):H("p",{className:"text-xs text-muted-foreground",children:"No requested or effective policy data yet."}),h&&xe(A,{variant:"outline",size:"sm",onClick:async()=>{try{await Ze(h),Jc.success("Policy copied to clipboard")}catch{Jc.error("Failed to copy")}},children:[H(Pf,{className:"size-3.5 mr-2"}),"Copy effective policy"]})]}),re==="findings"&&xe("div",{role:"tabpanel",className:"space-y-2",children:[H("div",{className:"space-y-1.5",children:G.map((D,ye)=>xe("div",{className:"rounded border border-zinc-200 dark:border-zinc-700 p-2",children:[H("div",{className:"text-xs font-medium",children:D.title}),H("div",{className:"text-[11px] text-muted-foreground break-all",children:D.detail})]},`${D.title}-${ye}`))}),C.length>0&&xe(Df,{children:[xe("div",{className:"flex items-center justify-between",children:[xe("span",{className:"text-xs font-medium",children:[C.length," observed request",C.length===1?"":"s"]}),H("button",{className:"text-xs text-muted-foreground underline",onClick:()=>p(n),children:"Clear"})]}),xe("div",{className:"border border-amber-200 dark:border-amber-800 rounded-md overflow-hidden",children:[xe("div",{className:"flex items-center justify-between bg-amber-50 dark:bg-amber-950/30 px-3 py-2",children:[xe("button",{type:"button",className:"flex items-center gap-2 text-xs font-medium text-amber-800 dark:text-amber-200",onClick:()=>de(D=>!D),children:[W?H(H0,{className:"size-3.5"}):H(U0,{className:"size-3.5"}),"Prompt for Agents"]}),H(A,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>{Ze(R)},"aria-label":"Copy prompt for agents",children:H(Pf,{className:"size-3.5"})})]}),W&&H("pre",{className:"max-h-48 overflow-auto whitespace-pre-wrap p-2 text-[11px]","data-testid":"debugger-csp-prompt-for-agents",children:R})]})]})]})]})]})]}),xe(Re,{children:[H(Se,{render:H(A,{"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 ${g.capabilities.touch?"border-blue-500 dark:border-blue-400":""}`,onClick:()=>{let D={...g.capabilities,touch:!g.capabilities.touch};m({capabilities:D})},children:H(W0,{className:`size-3.5 ${g.capabilities.touch?"text-blue-600 dark:text-blue-400":""}`})}),nativeButton:!0}),xe(Te,{children:["Touch: ",g.capabilities.touch?"Enabled":"Disabled"]})]}),xe(Re,{children:[H(Se,{render:H(A,{"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 ${g.capabilities.hover?"border-blue-500 dark:border-blue-400":""}`,onClick:()=>{let D={...g.capabilities,hover:!g.capabilities.hover};m({capabilities:D})},children:H(j0,{className:`size-3.5 ${g.capabilities.hover?"text-blue-600 dark:text-blue-400":""}`})}),nativeButton:!0}),xe(Te,{children:["Hover: ",g.capabilities.hover?"Enabled":"Disabled"]})]}),xe(Vo,{children:[H(jo,{render:H(A,{"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:H(J0,{className:"size-3.5"})}),nativeButton:!0}),H(qo,{className:"w-64 p-3","data-testid":"debugger-safe-area-dialog",children:xe("div",{className:"space-y-2",children:[H("label",{className:"text-xs font-medium",children:"Safe Area Insets"}),H(kf,{value:g.safeAreaInsets,onChange:D=>{m({safeAreaInsets:D})}})]})})]}),o==="tool"?xe(fn,{children:[xe(Re,{children:[H(Se,{render:H(ic,{render:H(A,{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:H(Rf,{className:"size-3.5"})}),nativeButton:!0}),nativeButton:!0}),H(Te,{children:"View Tool Props"})]}),xe(rn,{scrollable:!0,className:"sm:max-w-[600px] max-h-[85vh]","data-testid":"debugger-props-dialog",children:[H(Xt,{children:H(qt,{children:"Tool Props"})}),H(zn,{children:H(vi,{children:H(xt,{data:s??{},filename:"tool-props.json"})})})]})]}):xe(Vo,{open:ee,onOpenChange:$,children:[xe(Re,{children:[H(Se,{render:H(jo,{render:H(A,{variant:"outline",size:"sm",className:`h-8 w-8 p-0 backdrop-blur-sm shadow-sm ${Y?"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:H(Rf,{className:`size-3.5 ${Y?"text-amber-500":""}`})}),nativeButton:!0}),nativeButton:!0}),xe(Te,{children:["Props:"," ",ue===Sr?"No Props":ue===la?"Tool Props":T.find(D=>D.id===ue)?.name||"Custom"]})]}),xe(qo,{className:"w-64 p-2","data-testid":"debugger-props-popover",children:[Y&&xe("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:[H("p",{className:"text-xs font-medium text-amber-700 dark:text-amber-300 mb-0.5",children:"Props required to render this widget:"}),H("p",{className:"text-xs font-mono text-amber-600 dark:text-amber-400",children:u.join(", ")}),H("p",{className:"text-xs text-amber-500 dark:text-amber-400 mt-1",children:"Create a preset below to set them."})]}),xe("div",{className:"space-y-1",children:[H(A,{variant:ue===Sr?"secondary":"ghost",size:"sm",className:"w-full justify-start",onClick:()=>qe(Sr),"data-testid":"debugger-props-no-props",children:"No Props"}),T.map(D=>xe("div",{className:"relative group flex items-center",children:[H(A,{variant:ue===D.id?"secondary":"ghost",size:"sm",className:"w-full justify-start pr-14",onClick:()=>qe(D.id),"data-testid":`debugger-props-preset-${D.id}`,children:D.name}),xe("div",{className:"absolute right-2 flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[H(A,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:ye=>Rt(D,ye),"data-testid":`debugger-props-edit-${D.id}`,children:H(K0,{className:"h-3 w-3"})}),H(A,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:ye=>Ve(D.id,ye),"data-testid":`debugger-props-delete-${D.id}`,children:H(Y0,{className:"h-3 w-3 text-destructive"})})]})]},D.id)),H(A,{variant:"ghost",size:"sm",className:"w-full justify-start text-primary",onClick:()=>qe(Ef),"data-testid":"debugger-props-create-preset",children:"+ Create Preset..."})]})]})]}),H(lf,{iframeId:n,enabled:!0}),c&&H(gf,{open:_,onOpenChange:K,onSave:it,existingPresets:T,resource:c,resourceAnnotations:a,llmConfig:i||null,editingPreset:Q})]})}import{jsx as Xi,jsxs as zf}from"react/jsx-runtime";function ps({message:e,className:t="",vertical:n,noBorder:o}){return Xi("div",{className:w(`mt-2 rounded-md p-6 ${t}`,!o&&"border"),children:zf("p",{className:w("text-sm text-muted-foreground flex items-center gap-4",n&&"flex-col"),children:[zf("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:[Xi("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"}),Xi("circle",{cx:"100.426",cy:"399.575",r:"100.426"}),Xi("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 oe,jsxs as _e}from"react/jsx-runtime";function lw({timestamp:e}){let[t,n]=Tr(()=>Gc(e));return da(()=>{let o=()=>n(Gc(e));o();let r=setInterval(o,1e3);return()=>clearInterval(r)},[e]),oe("span",{children:t})}function Gc(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 Hf(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(`
102
- `)}return"An error occurred"}function cw(e){try{return JSON.parse(e),!0}catch{return!1}}function dw({content:e}){let[t,n]=Tr(new Set),o=Uf(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?oe("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:"No content"}):oe("div",{className:"space-y-4",children:e.map((r,s)=>{if(r.type==="text"){let a=r.text||"",i=t.has(s),c=cw(a),l=c?(()=>{try{return JSON.parse(a)}catch{return null}})():null;return _e("div",{className:"space-y-2",children:[_e("div",{className:"flex items-center justify-between gap-2",children:[_e("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:["Text Content",i?" (formatted)":""]}),c&&oe("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?oe(xt,{data:l,filename:`content-${s}.json`}):oe("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 _e("div",{className:"space-y-2",children:[oe("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"Image Content"}),_e("div",{className:"bg-gray-50 dark:bg-zinc-900 rounded-lg p-3",children:[oe("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&&oe("div",{className:"mt-2 text-xs text-gray-500 dark:text-gray-400",children:oe(xt,{data:r.annotations,filename:`image-annotations-${s}.json`,"data-testid":"tool-execution-results-image-annotations"})})]})]},s);if(r.type==="audio")return _e("div",{className:"space-y-2",children:[oe("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"Audio Content"}),_e("div",{className:"bg-gray-50 dark:bg-zinc-900 rounded-lg p-3",children:[oe("audio",{controls:!0,src:`data:${r.mimeType||"audio/wav"};base64,${r.data}`,className:"w-full","data-testid":"tool-execution-results-audio-content"}),r.annotations&&oe("div",{className:"mt-2 text-xs text-gray-500 dark:text-gray-400",children:oe(xt,{data:r.annotations,filename:`audio-annotations-${s}.json`,"data-testid":"tool-execution-results-audio-annotations"})})]})]},s);if(r.type==="resource_link")return _e("div",{className:"space-y-2",children:[oe("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"Resource Link"}),_e("div",{className:"bg-gray-50 dark:bg-zinc-900 rounded-lg p-3 space-y-2",children:[_e("div",{className:"font-mono text-sm break-all",children:[oe("span",{className:"text-gray-600 dark:text-gray-400",children:"URI:"})," ",r.uri]}),r.name&&_e("div",{className:"text-sm",children:[oe("span",{className:"text-gray-600 dark:text-gray-400",children:"Name:"})," ",r.name]}),r.description&&_e("div",{className:"text-sm",children:[oe("span",{className:"text-gray-600 dark:text-gray-400",children:"Description:"})," ",r.description]}),r.mimeType&&_e("div",{className:"text-sm",children:[oe("span",{className:"text-gray-600 dark:text-gray-400",children:"MIME Type:"})," ",r.mimeType]}),r.annotations&&_e("div",{className:"mt-2",children:[oe("div",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"Annotations:"}),oe(xt,{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 _e("div",{className:"space-y-2",children:[oe("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"Embedded Resource"}),_e("div",{className:"bg-gray-50 dark:bg-zinc-900 rounded-lg p-3 space-y-2",children:[_e("div",{className:"font-mono text-sm break-all","data-testid":"tool-execution-results-resource-uri",children:[oe("span",{className:"text-gray-600 dark:text-gray-400",children:"URI:"})," ",a.uri]}),a.mimeType&&_e("div",{className:"text-sm",children:[oe("span",{className:"text-gray-600 dark:text-gray-400","data-testid":"tool-execution-results-mime-type",children:"MIME Type:"})," ",a.mimeType]}),a.text&&_e("div",{"data-testid":"tool-execution-results-resource-text-content",children:[oe("div",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"Content:"}),oe("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&&_e("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:["[Binary content: ",a.blob.length||0," bytes]"]}),a.annotations&&_e("div",{className:"mt-2",children:[oe("div",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"Annotations:"}),oe(xt,{data:a.annotations,filename:`resource-annotations-${s}.json`,"data-testid":"tool-execution-results-resource-annotations"})]})]})]},s)}return _e("div",{className:"space-y-2",children:[_e("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:["Unknown Content Type: ",r.type||"N/A"]}),oe(xt,{data:r,filename:`content-${s}.json`,"data-testid":"tool-execution-results-unknown-content"})]},s)})})}function Qi({results:e,copiedResult:t,serverId:n,readResource:o,onCopy:r,onMaximize:s,isMaximized:a=!1,onRerunTool:i,onWidgetHeightChange:c}){let[l,u]=Tr(0),[f,d]=Tr(!0),[g,m]=Tr("json"),[v,p]=Tr("inline"),[x,C]=Tr(null),b=e[0],h=b?e.filter($=>$.toolName===b.toolName):[],y=h[l]||h[0],R=e.findIndex($=>$===y),P=y?y.error||Hf(y.result):null,S=P??(y!=null?JSON.stringify(y.result,null,2):"");da(()=>{h.length>0&&l>=h.length&&u(0)},[h.length,l]);let T=to(()=>y?.args,[y?.timestamp,l]),M=to(()=>y?.result,[y?.timestamp,y?.duration,l]),I=Uf($=>o($),[o]),k=to(()=>y&&iw(y.toolMeta)?"mcp-apps":null,[y]),N=to(()=>y?.toolMeta?aw(y.toolMeta):null,[y?.toolMeta]),L=to(()=>k==="mcp-apps"&&!!N,[k,N]);da(()=>{m(L?"mcp-apps":"json")},[b?.toolName,L]);let _=to(()=>y?.result?.content||[],[y]),K=to(()=>N||null,[N]),F=to(()=>!!(_&&_.length>0||y?.result?.structuredContent),[_,y]),Y=to(()=>!L&&F,[L,F]),ee=to(()=>{let $=[];return L&&N&&$.push({mode:"mcp-apps",label:"Component (MCP Apps)"}),$.push({mode:"json",label:"Raw JSON"}),$},[L,N]);return da(()=>{ee.length!==0&&(ee.some($=>$.mode===g)||m(L?"mcp-apps":"json"))},[ee,L,g]),da(()=>{c&&(e.length===0||g!=="mcp-apps"||v!=="inline"||!L)&&c(null)},[c,e.length,g,v,L]),e.length===0?oe("div",{className:"flex flex-col h-full bg-white dark:bg-black",children:oe("div",{className:"flex-1 overflow-y-auto h-full",children:oe("div",{className:"flex items-center justify-center h-full",children:oe("div",{className:"text-center",children:oe(ps,{vertical:!0,noBorder:!0,message:"No Results yet"})})})})}):_e("div",{className:"relative flex flex-col h-full bg-white dark:bg-black",children:[oe("div",{className:"flex-1 overflow-y-auto h-full",children:_e("div",{className:"space-y-0 flex flex-col flex-1 h-full",children:[_e("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 ${L||Y?"border-b border-gray-200 dark:border-zinc-600 pb-2":""}`,children:[oe("h3",{className:"text-sm font-medium hidden sm:block",children:"Response"}),y.duration!==void 0&&_e("div",{className:"hidden sm:flex items-center gap-1",children:[oe(rw,{className:"h-3 w-3 text-gray-400"}),_e("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:[y.duration,"ms"]})]}),L&&oe("div",{className:"flex items-center gap-4 sm:ml-4",children:oe("div",{className:"flex items-center gap-2",children:ee.map(($,Q)=>_e(sw.Fragment,{children:[Q>0&&oe("span",{className:"text-xs text-zinc-400",children:"|"}),oe("button",{"data-testid":`tool-result-view-${$.mode}`,onClick:()=>m($.mode),className:`text-xs font-medium ${g===$.mode?"text-black dark:text-white":"text-zinc-500 dark:text-zinc-400"}`,children:$.label})]},$.mode))})}),Y&&_e("div",{className:"flex items-center gap-2 sm:ml-4",children:[oe("button",{onClick:()=>d(!0),className:`text-xs font-medium ${f?"text-black dark:text-white":"text-zinc-500 dark:text-zinc-400"}`,children:"Formatted"}),oe("span",{className:"text-xs text-zinc-400",children:"|"}),oe("button",{onClick:()=>d(!1),className:`text-xs font-medium ${f?"text-zinc-500 dark:text-zinc-400":"text-black dark:text-white"}`,children:"Raw"})]}),_e("div",{className:"ml-auto flex items-center gap-1",children:[a&&i&&_e(A,{"data-testid":"tool-result-rerun",variant:"ghost",size:"sm",onClick:i,title:"Re-run with same arguments",children:[oe(ow,{className:"h-4 w-4"}),oe("span",{className:"hidden sm:inline ml-1",children:"Re-run"})]}),L&&s&&oe(A,{"data-testid":"tool-result-maximize",variant:"ghost",size:"sm",onClick:s,title:a?"Restore":"Maximize",children:a?oe(nw,{className:"h-4 w-4"}):oe(tw,{className:"h-4 w-4"})}),h.length>1&&_e(Sn,{value:l.toString(),onValueChange:$=>u(parseInt($)),children:[oe(Un,{className:"w-[140px] h-8 text-xs",leading:_e("div",{className:"flex items-center gap-1",children:[oe(Bf,{className:"h-3 w-3"}),oe(lw,{timestamp:y.timestamp})]})}),oe(Hn,{children:h.map(($,Q)=>oe(Wt,{value:Q.toString(),children:_e("div",{className:"flex items-center gap-2",children:[oe(Bf,{className:"h-3 w-3"}),oe("span",{children:Gc($.timestamp)}),_e("span",{className:"text-xs text-muted-foreground",children:["(",new Date($.timestamp).toLocaleTimeString(),")"]})]})},Q))})]}),oe(A,{"data-testid":`tool-result-copy-${R}`,variant:"ghost",size:"sm",onClick:()=>r(R,S),children:t===R?oe(Z0,{className:"h-4 w-4"}):oe(ew,{className:"h-4 w-4"})})]})]}),(()=>{let $=y.error||Hf(y.result);return $?_e("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:[oe("p",{className:"text-red-800 dark:text-red-300 font-medium",children:"Error:"}),oe("p",{className:"text-red-700 dark:text-red-400 text-sm",children:$})]}):(()=>{switch(g){case"mcp-apps":return!L||!N?oe("div",{className:"px-4 pt-4",children:oe("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded p-3",children:oe("p",{className:"text-sm text-red-600 dark:text-red-400",children:"MCP Apps resource not available"})})}):_e(na,{className:"relative flex flex-1 w-full min-h-[240px] items-stretch",children:[oe("div",{className:"absolute top-2 right-2 z-30 flex items-center gap-2",children:oe(Yi,{toolCallId:`tool-${y.timestamp}`,displayMode:v,onDisplayModeChange:p,propsContext:"tool",resourceUri:N,toolInput:y.args,resourceAnnotations:y.toolMeta,llmConfig:null,resource:null,onPropsChange:C})}),oe("div",{className:"flex min-h-0 flex-1 flex-col pt-11",children:oe(is,{serverId:n,viewId:`tool-${y.timestamp}`,toolName:y.toolName,toolInput:T,toolOutput:M,toolMetadata:y.toolMeta,resourceUri:N,readResource:I,customProps:x||void 0,displayMode:v,onDisplayModeChange:p,onWidgetHeightChange:c?V=>c(V):void 0,noWrapper:!0},`mcp-apps-${y.timestamp}`)})]});case"json":{if(Y&&f){let V=y.result?.structuredContent;return _e("div",{className:"px-4 pt-4 space-y-4","data-testid":"tool-execution-results-content",children:[V&&_e("div",{className:"space-y-2","data-testid":"tool-execution-results-structured-content",children:[oe("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"Structured Content"}),oe(xt,{data:V,filename:`structured-content-${y.toolName}-${Date.now()}.json`})]}),_&&_.length>0&&oe(dw,{content:_}),!V&&(!_||_.length===0)&&oe("div",{className:"text-sm text-gray-500 dark:text-gray-400","data-testid":"tool-execution-results-no-content",children:"No content to display"})]})}return oe("div",{className:"px-4 pt-4",children:oe(xt,{data:y.result,filename:`tool-result-${y.toolName}-${Date.now()}.json`})})}default:return null}})()})()]})}),K&&g==="mcp-apps"&&oe("div",{className:"absolute bottom-0 left-1/2 -translate-x-1/2 z-40 pointer-events-none",children:oe("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:K})})]})}import{isViewTool as uw}from"@mcp-use/client/react";import{useMemo as Zi,useState as mw}from"react";import{Fragment as fw,jsx as ho,jsxs as Ff}from"react/jsx-runtime";function pw({widgetId:e}){let{getWidget:t}=Ho(),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 Ff("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:[ho("span",{className:"inline-block w-1.5 h-1.5 rounded-full bg-blue-400 shrink-0"}),ho("span",{className:"font-medium",children:"State synced to model"}),ho("span",{className:"truncate opacity-60 max-w-[300px]",children:r})]})}function el({toolName:e,toolArgs:t,result:n,serverId:o,readResource:r,toolMeta:s,onSendFollowUp:a,modelContextScope:i,llmConfig:c,partialToolArgs:l,cancelled:u}){let f=Zi(()=>`chat-tool-${e}-${Date.now()}-${Math.random().toString(36).substring(2,11)}`,[e]),[d,g]=mw("inline"),m=Zi(()=>{if(!n)return null;if(typeof n=="string")try{return JSON.parse(n)}catch{return n}return n},[n]),v=uw(s),p=v?s?.ui?.resourceUri??null:null,x=Zi(()=>t,[e,m]),C=Zi(()=>m,[e,m]);return v&&p&&o&&r?Ff(fw,{children:[ho(is,{serverId:o,viewId:f,toolName:e,resourceUri:p,toolInput:x,toolOutput:C,toolMetadata:s,readResource:r,displayMode:d,onDisplayModeChange:g,onSendFollowUp:a,modelContextScope:i,llmConfig:c,partialToolInput:l,cancelled:u,noWrapper:!0,className:"my-4"}),ho(pw,{widgetId:f})]}):v&&!p?ho("div",{className:"flex items-center justify-center w-full h-[200px] rounded border",children:ho(hn,{className:"size-5"})}):v&&(!o||!r)?ho("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:ho("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 SU,isViewTool as TU,getViewResourceUri as RU}from"@mcp-use/client/react";import{createContext as gw,use as hw,useCallback as Rn,useState as vw}from"react";import{jsx as yw}from"react/jsx-runtime";var $f=gw(void 0);function bw({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]=vw({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=Rn(b=>{s(h=>({...h,selectedServerId:b}))},[]),i=Rn(b=>{s(h=>({...h,activeTab:b}))},[]),c=Rn(b=>{s(h=>({...h,selectedToolName:b}))},[]),l=Rn(b=>{s(h=>({...h,selectedPromptName:b}))},[]),u=Rn(b=>{s(h=>({...h,selectedResourceUri:b}))},[]),f=Rn(b=>{s(h=>({...h,selectedSamplingRequestId:b}))},[]),d=Rn(b=>{s(h=>({...h,selectedElicitationRequestId:b}))},[]),g=Rn(b=>{s(h=>({...h,tunnelUrl:b}))},[]),m=Rn(b=>{s(h=>({...h,isTunnelStarting:b}))},[]),v=Rn((b,h={})=>{s(y=>({...y,isEmbedded:b,embeddedConfig:{...h,chatApiUrl:h.chatApiUrl?.trim()||o,chatStreamProtocol:h.chatStreamProtocol??"data-stream",chatEnableFreeTierUpgrade:h.chatEnableFreeTierUpgrade??!0}}))},[o]),p=Rn((b,h,y)=>{console.warn("[InspectorContext] navigateToItem called:",{serverId:b,tab:h,itemIdentifier:y}),s(R=>({...R,selectedServerId:b,activeTab:h,selectedToolName:h==="tools"&&y||null,selectedPromptName:h==="prompts"&&y||null,selectedResourceUri:h==="resources"&&y||null,selectedSamplingRequestId:h==="sampling"&&y||null,selectedElicitationRequestId:h==="elicitation"&&y||null}))},[]),x=Rn(()=>{s(b=>({...b,selectedToolName:null,selectedPromptName:null,selectedResourceUri:null,selectedSamplingRequestId:null,selectedElicitationRequestId:null}))},[]),C={...r,setSelectedServerId:a,setActiveTab:i,setSelectedToolName:c,setSelectedPromptName:l,setSelectedResourceUri:u,setSelectedSamplingRequestId:f,setSelectedElicitationRequestId:d,setTunnelUrl:g,setIsTunnelStarting:m,setEmbeddedMode:v,navigateToItem:p,clearSelection:x};return yw($f,{value:C,children:e})}function vo(){let e=hw($f);if(!e)throw new Error("useInspector must be used within InspectorProvider");return e}import{GripVerticalIcon as xw}from"lucide-react";import*as Rr from"react-resizable-panels";import{jsx as ua}from"react/jsx-runtime";var{usePanelRef:Pr}=Rr;function Wo({className:e,...t}){return ua(Rr.Group,{"data-slot":"resizable-panel-group",className:w("flex h-full w-full aria-[orientation=vertical]:flex-col",e),...t})}function vn({...e}){return ua(Rr.Panel,{"data-slot":"resizable-panel",...e})}function Ko({withHandle:e,className:t,...n}){return ua(Rr.Separator,{"data-slot":"resizable-handle",className:w("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&&ua("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:ua(xw,{className:"size-2.5 text-muted-foreground"})})})}import{AnimatePresence as rC,motion as dd}from"motion/react";import{ChevronLeft as sC,Database as eg,Wrench as tg}from"lucide-react";import{useCallback as yn,useEffect as ng,useMemo as og,useRef as sl,useState as Mn}from"react";import{useState as ww}from"react";import{jsx as Vf}from"react/jsx-runtime";function no({className:e,scrollRef:t,children:n}){let[o,r]=ww(!1);return Vf("div",{ref:t,className:w("h-full overflow-y-auto overscroll-none",e),onScroll:s=>r(s.currentTarget.scrollTop>0),children:Vf("div",{className:"flex min-h-full flex-col",children:n(o)})})}import{jsx as ma,jsxs as jf}from"react/jsx-runtime";function $n({id:e,isSelected:t,isFocused:n,title:o,description:r,metadata:s,onClick:a,className:i,"data-testid":c}){return ma("button",{id:e,"data-testid":c,type:"button",onClick:a,className:w("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:jf("div",{className:"flex items-start gap-2 sm:gap-3",children:[jf("div",{className:"flex-1 min-w-0",children:[ma("div",{className:"flex items-center gap-2 mb-1",children:ma("h3",{className:w("font-medium truncate font-mono text-sm"),children:o})}),r&&ma("p",{className:"text-sm text-gray-600 dark:text-gray-400 line-clamp-2",children:r})]}),s&&ma("div",{className:"flex-shrink-0 flex items-center self-center",children:s})]})})}import{forwardRef as Cw}from"react";import{cva as Nw}from"class-variance-authority";import{jsx as tl}from"react/jsx-runtime";var kw={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"},Sw=Nw("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"}}),qf={default:{variant:"solid",color:"blue"},secondary:{variant:"solid",color:"green"},destructive:{variant:"solid",color:"red"},outline:{variant:"outline",color:"gray"}};function Tw(e){return typeof e=="string"||typeof e=="number"}function Rw({children:e}){return Tw(e)?tl("span",{className:"[text-box:trim-both_cap_alphabetic]",children:e}):tl("span",{className:"inline-flex items-center gap-1",children:e})}var Kt=Cw(({className:e,variant:t="solid",size:n="md",color:o,children:r,style:s,...a},i)=>{let c=t&&t in qf?qf[t]:null,l=c?.variant??t,u=o??c?.color??"gray",f=vt(),d=kw[u],m=l==="solid"?u==="gray"?{backgroundColor:"var(--accent)",color:"var(--foreground)"}:{color:"var(--foreground)",backgroundColor:`color-mix(in srgb, ${d} 15%, var(--background))`}:{};return tl("span",{ref:i,className:w(Sw({variant:l,size:n}),f.item,e),style:{...m,...s},...a,children:tl(Rw,{children:r})})});Kt.displayName="Badge";import{RefreshCw as Mw,Search as Iw}from"lucide-react";import{jsx as Pw}from"react/jsx-runtime";function fs({className:e,...t}){return Pw("kbd",{"data-slot":"kbd",className:w("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 Wf,jsx as an,jsxs as bo}from"react/jsx-runtime";var Ew="h-3.5 w-3.5 shrink-0 text-muted-foreground";function Mr({activeTab:e,isSearchExpanded:t,searchQuery:n,primaryTabTitle:o,secondaryTabTitle:r,primaryCount:s,secondaryCount:a,secondaryIcon:i,primaryIcon:c,searchPlaceholder:l="Search...",onSearchExpand:u,onSearchChange:f,onSearchBlur:d,onTabSwitch:g,searchInputRef:m,primaryTabName:v,onRefresh:p,isRefreshing:x=!1,isScrolled:C=!1}){let b=e===v,h=b?c:i,y=b?o:r;return bo("div",{className:`flex flex-row items-center justify-between gap-2 ${yi(C)} ${Io}`,children:[an("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:t?an(Ge,{ref:m,placeholder:l,value:n,onChange:R=>f(R.target.value),onBlur:d,className:"h-8 border-gray-300 dark:border-zinc-600"}):bo(Wf,{children:[bo("h2",{className:`${Eo} flex items-center gap-1.5`,children:[an(h,{className:Ew,"aria-hidden":!0}),y]}),b&&bo(Wf,{children:[an(Kt,{className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",variant:"outline",children:s}),bo(Re,{children:[an(Se,{render:an(A,{variant:"ghost",size:"sm",onClick:u,className:"h-8 w-8 p-0",children:an(Iw,{className:"h-4 w-4"})}),nativeButton:!0}),bo(Te,{side:"bottom",className:"flex gap-2",children:["Search",an(fs,{children:"F"})]})]}),p&&bo(Re,{children:[an(Se,{render:an(A,{variant:"ghost",size:"sm",onClick:p,disabled:x,className:"h-8 w-8 p-0",children:an(Mw,{className:`h-4 w-4 ${x?"animate-spin":""}`})}),nativeButton:!0}),bo(Te,{side:"bottom",className:"flex gap-2",children:["Refresh list",an(fs,{children:"R"})]})]})]})]})}),bo(A,{variant:"ghost",size:"sm",onClick:g,className:"gap-2 flex-shrink-0",children:[an("span",{className:"hidden sm:inline",children:b?r:o}),b&&a>0&&an(Kt,{className:"bg-purple-500/20 text-purple-600 dark:text-purple-400 border-transparent",variant:"outline",children:a})]})]})}import{RefreshCw as Aw,Search as Lw}from"lucide-react";import{Fragment as Dw,jsx as Ut,jsxs as Jo}from"react/jsx-runtime";function nl({title:e,count:t,icon:n,isSearchExpanded:o,searchQuery:r,searchPlaceholder:s,onSearchExpand:a,onSearchChange:i,onSearchBlur:c,searchInputRef:l,titleTestId:u,bulkAction:f,onRefresh:d,isRefreshing:g=!1,isScrolled:m=!1}){let v=f?.icon;return Jo("div",{className:`flex flex-row items-center justify-between gap-2 ${yi(m)} ${Io}`,children:[Ut("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:o?Ut(Ge,{ref:l,placeholder:s,value:r,onChange:x=>i(x.target.value),onBlur:c,className:"h-8 border-gray-300 dark:border-zinc-600"}):Jo(Dw,{children:[Jo("h2",{className:`${Eo} flex items-center gap-1.5`,"data-testid":u,children:[n?Ut(n,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground","aria-hidden":!0}):null,e]}),Ut(Kt,{className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",variant:"outline",children:t}),Jo(Re,{children:[Ut(Se,{render:Ut(A,{variant:"ghost",size:"sm",onClick:a,className:"h-8 w-8 p-0",children:Ut(Lw,{className:"h-4 w-4"})}),nativeButton:!0}),Jo(Te,{side:"bottom",className:"flex gap-2",children:["Search",Ut(fs,{children:"F"})]})]}),d&&Jo(Re,{children:[Ut(Se,{render:Ut(A,{variant:"ghost",size:"sm",onClick:d,disabled:g,className:"h-8 w-8 p-0",children:Ut(Aw,{className:`h-4 w-4 ${g?"animate-spin":""}`})}),nativeButton:!0}),Jo(Te,{side:"bottom",className:"flex gap-2",children:["Refresh list",Ut(fs,{children:"R"})]})]})]})}),f&&v&&Ut("div",{className:"flex items-center gap-2",children:Jo(Re,{children:[Ut(Se,{render:Ut(A,{variant:"ghost",size:"sm",onClick:f.onClick,disabled:f.disabled,className:"h-8 w-8 p-0",children:Ut(v,{className:"h-4 w-4"})}),nativeButton:!0}),Ut(Te,{side:"bottom",children:f.label})]})})]})}import{AlertTriangle as pL,Check as fL,Loader2 as gL,XCircle as hL}from"lucide-react";import{jsx as bL}from"react/jsx-runtime";import{Database as _w,Trash2 as Ow}from"lucide-react";import{jsx as bn,jsxs as Yc}from"react/jsx-runtime";function Xc({savedRequests:e,selectedRequest:t,onLoadRequest:n,onDeleteRequest:o,focusedIndex:r}){if(e.length===0)return Yc("div",{className:"flex flex-1 flex-col items-center justify-center p-4 text-center",children:[bn(_w,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),bn("p",{className:"text-gray-500 dark:text-gray-400 mb-2",children:"No saved requests yet"}),bn("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 bn("div",{children:e.map((a,i)=>Yc("div",{className:"relative group",children:[bn($n,{id:`saved-${a.id}`,isSelected:t?.id===a.id,isFocused:r===i,title:a.name,description:a.toolName,metadata:bn("div",{className:"flex flex-col gap-1",children:bn("span",{className:"text-xs text-gray-400 dark:text-gray-500",children:new Date(a.savedAt).toLocaleString()})}),onClick:()=>n(a)}),bn("div",{className:"absolute top-1/2 right-2 -translate-y-1/2 opacity-0 group-hover:opacity-100 transition-opacity z-10",children:Yc(Re,{children:[bn(Se,{render:bn(A,{variant:"secondary",size:"sm",onClick:c=>s(c,()=>o(a.id)),className:"h-8 w-8 p-0",children:bn(Ow,{className:"h-4 w-4"})}),nativeButton:!0}),bn(Te,{children:bn("p",{children:"Delete saved request"})})]})})]},a.id))})}import{Save as zw}from"lucide-react";import{jsx as gs,jsxs as pa}from"react/jsx-runtime";function Qc({isOpen:e,requestName:t,defaultPlaceholder:n,onRequestNameChange:o,onSave:r,onCancel:s}){return e?gs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:s,children:pa("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:[gs("h3",{className:"text-lg font-semibold mb-4 text-gray-900 dark:text-gray-100",children:"Save Request"}),pa("div",{className:"space-y-4",children:[pa("div",{children:[gs(tt,{htmlFor:"request-name",children:"Request Name (optional)"}),gs(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})]}),pa("div",{className:"flex justify-end gap-2",children:[gs(A,{variant:"outline",onClick:s,children:"Cancel"}),pa(A,{onClick:r,children:[gs(zw,{className:"h-4 w-4 mr-2"}),"Save"]})]})]})]})}):null}import{Check as Bw,ChevronDown as Hw,ChevronUp as Uw,Code as Fw,Copy as $w,Play as Vw,Save as jw,X as qw}from"lucide-react";import{useEffect as Kf,useRef as Ww,useState as fa}from"react";import{Fragment as hs,jsx as Ce,jsxs as kt}from"react/jsx-runtime";function Zc({selectedTool:e,toolArgs:t,payloadToSend:n,isExecuting:o,isConnected:r,onArgChange:s,onExecute:a,onSave:i,onCancel:c,onBulkPaste:l,autoFilledFields:u,setFields:f,sendEmptyFields:d,onToggleEmpty:g}){let m="hidden @[700px]/tool-exec:inline",v="hidden @[700px]/tool-exec:inline shrink-0 text-[10px] leading-none border border-current/30 p-1 rounded-full",p="@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",x="@max-[699px]/tool-exec:!pr-0",[C,b]=fa(!1),[h,y]=fa(!1),[R,P]=fa(!1),[S,T]=fa(!1),[M,I]=fa(!1),k=Ww(null);Kf(()=>{if(k.current&&e?.description){let _=k.current,K=parseFloat(getComputedStyle(_).lineHeight),F=_.scrollHeight,Y=Math.round(F/K);I(Y>3),T(!1)}},[e?.description]);let N=async()=>{e&&await Ze(JSON.stringify(e,null,2))},L=async()=>{if(e)try{await Ze(JSON.stringify(n??t,null,2)),P(!0),setTimeout(()=>P(!1),2e3)}catch{}};return Kf(()=>{let _=K=>{if(K.key==="Escape"&&o&&c){K.preventDefault(),c();return}if(K.key!=="Enter")return;let F=K.metaKey||K.ctrlKey,Y=!K.metaKey&&!K.ctrlKey&&!K.altKey&&!K.shiftKey,ee=K.target,$=ee instanceof HTMLInputElement&&ee.dataset.toolArgumentInput==="true";(F||Y&&$)&&e&&!o&&r&&(K.preventDefault(),a())};return document.addEventListener("keydown",_),()=>document.removeEventListener("keydown",_)},[e,o,r,a,c]),e?kt("div",{className:"flex flex-col h-full @container/tool-exec",children:[Ce("div",{className:"shrink-0 p-3 sm:p-5 pt-3 sm:pt-4 pb-2 sm:pb-2 sm:pr-4",children:Ce("div",{children:kt("div",{className:"flex flex-row items-center justify-between mb-0 gap-2",children:[Ce("h3",{className:"text-base sm:text-lg font-semibold","data-testid":"tool-execution-title",children:e.name}),kt("div",{className:"flex gap-2 shrink-0",children:[kt(Re,{children:[Ce(Se,{render:kt(A,{"data-testid":"tool-execution-metadata-button",variant:h?"default":"outline",onClick:()=>y(!h),disabled:o,size:"sm",className:w(ur,p),title:"View tool metadata",children:[Ce(Fw,{}),Ce("span",{className:m,children:"Metadata"})]}),nativeButton:!0}),Ce(Te,{children:Ce("p",{children:"View tool definition metadata"})})]}),kt(Re,{children:[Ce(Se,{render:kt(A,{"data-testid":"tool-execution-copy-payload-button",variant:"outline",onClick:L,disabled:o,size:"sm",className:w(ur,p),title:"Copy payload as JSON",children:[R?Ce(Bw,{className:"text-green-600"}):Ce($w,{}),Ce("span",{className:m,children:R?"Copied!":"Payload"})]}),nativeButton:!0}),Ce(Te,{children:Ce("p",{children:"Copy payload as JSON"})})]}),kt(Re,{children:[Ce(Se,{render:kt(A,{"data-testid":"tool-execution-save-button",variant:"outline",onClick:i,disabled:o,size:"sm",className:w(ur,p),title:"Save request",children:[Ce(jw,{}),Ce("span",{className:m,children:"Save"})]}),nativeButton:!0}),Ce(Te,{children:Ce("p",{children:"Save request"})})]}),o&&c?kt(Re,{open:C?void 0:!1,children:[Ce(Se,{render:Ce("div",{onMouseEnter:()=>b(!0),onMouseLeave:()=>b(!1),className:"relative",children:Ce(A,{"data-testid":"tool-execution-cancel-button",onClick:c,variant:C?"destructive":"default",size:"sm",className:w(Gs,p,x,"transition-all"),children:C?kt(hs,{children:[Ce(qw,{}),Ce("span",{className:m,children:"Cancel"}),Ce("span",{className:v,children:"Esc"})]}):kt(hs,{children:[Ce(hn,{}),Ce("span",{className:m,children:"Executing..."})]})})}),nativeButton:!1}),Ce(Te,{children:Ce("p",{children:"Hover to cancel (or press Esc)"})})]}):Ce(A,{"data-testid":"tool-execution-execute-button",onClick:a,disabled:o||!r,size:"sm",className:w(Gs,p,x),children:o?kt(hs,{children:[Ce(hn,{}),Ce("span",{className:m,children:"Executing..."})]}):kt(hs,{children:[Ce(Vw,{}),Ce("span",{className:m,children:"Execute"}),Ce("span",{className:v,children:"\u2318\u21B5"})]})})]})]})})}),kt("div",{className:"flex-1 overflow-y-auto px-3 sm:px-5 pb-4 pr-3",children:[e.description&&kt("div",{className:"relative mb-6",children:[kt("div",{className:"relative",children:[Ce("p",{ref:k,"data-testid":"tool-execution-description",className:`text-sm text-gray-600 dark:text-gray-400 leading-relaxed transition-all duration-300 ${!S&&M?"line-clamp-3":""}`,children:e.description}),M&&!S&&Ce("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"})]}),M&&Ce("div",{className:"flex justify-end",children:Ce("button",{onClick:()=>T(!S),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:S?kt(hs,{children:["Show less",Ce(Uw,{className:"h-3 w-3"})]}):kt(hs,{children:["Show more",Ce(Hw,{className:"h-3 w-3"})]})})})]}),Ce(Ec,{selectedTool:e,toolArgs:t,onArgChange:s,onBulkPaste:l,autoFilledFields:u,setFields:f,sendEmptyFields:d,onToggleEmpty:g})]}),Ce(fn,{open:h,onOpenChange:y,children:kt(rn,{scrollable:!0,className:"max-w-3xl max-h-[80vh]",children:[Ce(Xt,{sticky:!0,children:Ce(qt,{children:"Tool Definition"})}),Ce(zn,{children:Ce(vi,{onCopy:N,children:Ce(xt,{data:e,filename:`tool-definition-${e.name}-${Date.now()}.json`})})})]})})]}):kt("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[Ce("p",{className:"text-gray-500 dark:text-gray-400 mb-2",children:"Select a tool to get started"}),Ce("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 Kw,Wrench as Jw}from"lucide-react";import{isViewTool as Gw}from"@mcp-use/client/react";import{jsx as yo,jsxs as ol}from"react/jsx-runtime";function ed({tools:e,selectedTool:t,onToolSelect:n,focusedIndex:o}){if(e.length===0)return ol("div",{className:"flex flex-1 flex-col items-center justify-center p-4 text-center",children:[yo(Jw,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),yo("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 yo("div",{children:e.map((s,a)=>{let i=s._meta,c=Gw(i)?"mcp-apps":null,l=s.inputSchema?.properties,u=l?Object.keys(l).length:0,f=r&&u>0&&ol(Kt,{variant:"outline",className:"text-xs border-gray-300 dark:border-zinc-600 text-gray-600 dark:text-gray-400",children:[u," params"]}),g=c==="mcp-apps"||f?ol("div",{className:"flex items-center gap-1.5",children:[c==="mcp-apps"&&ol(Re,{children:[yo(Se,{render:yo("span",{className:"inline-flex",children:yo(Kw,{className:"h-3.5 w-3.5"})}),nativeButton:!1}),yo(Te,{children:yo("p",{children:"UI widget"})})]}),f]}):void 0;return yo($n,{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:g,onClick:()=>n(s)},s.name)})})}import{AlertDialog as Ir}from"@base-ui/react/alert-dialog";import{jsx as Pn,jsxs as Qw}from"react/jsx-runtime";function td({...e}){return Pn(Ir.Root,{"data-slot":"alert-dialog",...e})}function Yw({...e}){return Pn(Ir.Portal,{"data-slot":"alert-dialog-portal",...e})}function Xw({className:e,...t}){return Pn(Ir.Backdrop,{"data-slot":"alert-dialog-overlay",className:w("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 nd({className:e,size:t="default",...n}){return Qw(Yw,{children:[Pn(Xw,{}),Pn(Ir.Popup,{"data-slot":"alert-dialog-content","data-size":t,className:w("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 od({className:e,...t}){return Pn("div",{"data-slot":"alert-dialog-header",className:w("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 rd({className:e,...t}){return Pn("div",{"data-slot":"alert-dialog-footer",className:w("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 sd({className:e,...t}){return Pn(Ir.Title,{"data-slot":"alert-dialog-title",className:w("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 ad({className:e,...t}){return Pn(Ir.Description,{"data-slot":"alert-dialog-description",className:w("text-sm text-balance text-muted-foreground md:text-pretty *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground",e),...t})}function id({className:e,...t}){return Pn(A,{"data-slot":"alert-dialog-action",className:w(e),...t})}function ld({className:e,variant:t="outline",size:n="default",...o}){return Pn(Ir.Close,{"data-slot":"alert-dialog-cancel",className:w(e),render:Pn(A,{variant:t,size:n}),...o})}import{useCallback as Zw,useEffect as Jf,useState as eC}from"react";var cd="mcp-inspector-saved-requests";function Gf(){let[e,t]=eC([]);Jf(()=>{try{let o=localStorage.getItem(cd);o&&t(JSON.parse(o))}catch(o){console.error("[useSavedRequests] Failed to load saved requests:",o)}},[]),Jf(()=>{let o=r=>{if(r.key===cd&&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=Zw(o=>{try{localStorage.setItem(cd,JSON.stringify(o)),t(o)}catch(r){console.error("[useSavedRequests] Failed to save requests:",r)}},[]);return{savedRequests:e,saveSavedRequests:n}}import{useCallback as ga,useMemo as tC,useState as rl}from"react";function Yf(e,t){if(!e)return t;if(!t)return e;let n=e.ui&&typeof e.ui=="object"&&!Array.isArray(e.ui)?e.ui:void 0,o=t.ui&&typeof t.ui=="object"&&!Array.isArray(t.ui)?t.ui:void 0;return{...e,...t,...n||o?{ui:{...n,...o}}:{}}}function Xf({selectedTool:e,payloadToSend:t,toolArgs:n,callTool:o,readResource:r,serverId:s}){let[a,i]=rl([]),[c,l]=rl(!1),[u,f]=rl(null),[d,g]=rl(null),m=ga(async()=>{if(!e||c)return;let h=new AbortController;g(h),l(!0);let y=Date.now();try{let R=t,P=e?._meta||e?.metadata,T=P?.ui?.resourceUri;if(T&&typeof T=="string"){try{await r(T)}catch{}i([{toolName:e.name,args:R,result:null,timestamp:y,duration:0,toolMeta:P}])}let M=await o(e.name,R,{timeout:6e5,resetTimeoutOnProgress:!0,signal:h.signal}),I=Date.now()-y,k=Yf(P,M?._meta);It(new Vs({toolName:e.name,serverId:s,success:!0,duration:I})).catch(()=>{}),window.dispatchEvent(new Event("mcp-tool-executed")),i(T&&typeof T=="string"?N=>N.map((L,_)=>_===0?{...L,result:M,duration:I,toolMeta:k}:L):N=>[{toolName:e.name,args:n,result:M,timestamp:y,duration:I,toolMeta:k},...N])}catch(R){let P=Date.now()-y;It(new Vs({toolName:e.name,serverId:s,success:!1,duration:P,error:R instanceof Error?R.message:String(R)})).catch(()=>{}),window.dispatchEvent(new Event("mcp-tool-executed"));let S=e?._meta||e?.metadata,T={toolName:e.name,args:n,result:null,error:R instanceof Error?R.message:String(R),timestamp:y,duration:P,toolMeta:S},M=S?.ui?.resourceUri;i(M?[T]:I=>[T,...I])}finally{l(!1)}},[e,t,n,c,o,r,s]),v=ga(async(h,y)=>{try{await Ze(y),f(h),setTimeout(()=>f(null),2e3)}catch(R){console.error("[ToolsTab] Failed to copy result:",R)}},[]),p=ga(h=>{i(y=>y.filter((R,P)=>P!==h))},[]),x=tC(()=>e?a.filter(h=>h.toolName===e.name):[],[a,e]),C=ga(h=>{let y=x[h];if(!y)return;let R=window.open("","_blank","width=800,height=600");R&&(R.document.write(`
102
+ `)}return"An error occurred"}function cw(e){try{return JSON.parse(e),!0}catch{return!1}}function dw({content:e}){let[t,n]=Tr(new Set),o=Uf(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?oe("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:"No content"}):oe("div",{className:"space-y-4",children:e.map((r,s)=>{if(r.type==="text"){let a=r.text||"",i=t.has(s),c=cw(a),l=c?(()=>{try{return JSON.parse(a)}catch{return null}})():null;return _e("div",{className:"space-y-2",children:[_e("div",{className:"flex items-center justify-between gap-2",children:[_e("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:["Text Content",i?" (formatted)":""]}),c&&oe("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?oe(xt,{data:l,filename:`content-${s}.json`}):oe("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 _e("div",{className:"space-y-2",children:[oe("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"Image Content"}),_e("div",{className:"bg-gray-50 dark:bg-zinc-900 rounded-lg p-3",children:[oe("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&&oe("div",{className:"mt-2 text-xs text-gray-500 dark:text-gray-400",children:oe(xt,{data:r.annotations,filename:`image-annotations-${s}.json`,"data-testid":"tool-execution-results-image-annotations"})})]})]},s);if(r.type==="audio")return _e("div",{className:"space-y-2",children:[oe("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"Audio Content"}),_e("div",{className:"bg-gray-50 dark:bg-zinc-900 rounded-lg p-3",children:[oe("audio",{controls:!0,src:`data:${r.mimeType||"audio/wav"};base64,${r.data}`,className:"w-full","data-testid":"tool-execution-results-audio-content"}),r.annotations&&oe("div",{className:"mt-2 text-xs text-gray-500 dark:text-gray-400",children:oe(xt,{data:r.annotations,filename:`audio-annotations-${s}.json`,"data-testid":"tool-execution-results-audio-annotations"})})]})]},s);if(r.type==="resource_link")return _e("div",{className:"space-y-2",children:[oe("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"Resource Link"}),_e("div",{className:"bg-gray-50 dark:bg-zinc-900 rounded-lg p-3 space-y-2",children:[_e("div",{className:"font-mono text-sm break-all",children:[oe("span",{className:"text-gray-600 dark:text-gray-400",children:"URI:"})," ",r.uri]}),r.name&&_e("div",{className:"text-sm",children:[oe("span",{className:"text-gray-600 dark:text-gray-400",children:"Name:"})," ",r.name]}),r.description&&_e("div",{className:"text-sm",children:[oe("span",{className:"text-gray-600 dark:text-gray-400",children:"Description:"})," ",r.description]}),r.mimeType&&_e("div",{className:"text-sm",children:[oe("span",{className:"text-gray-600 dark:text-gray-400",children:"MIME Type:"})," ",r.mimeType]}),r.annotations&&_e("div",{className:"mt-2",children:[oe("div",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"Annotations:"}),oe(xt,{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 _e("div",{className:"space-y-2",children:[oe("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"Embedded Resource"}),_e("div",{className:"bg-gray-50 dark:bg-zinc-900 rounded-lg p-3 space-y-2",children:[_e("div",{className:"font-mono text-sm break-all","data-testid":"tool-execution-results-resource-uri",children:[oe("span",{className:"text-gray-600 dark:text-gray-400",children:"URI:"})," ",a.uri]}),a.mimeType&&_e("div",{className:"text-sm",children:[oe("span",{className:"text-gray-600 dark:text-gray-400","data-testid":"tool-execution-results-mime-type",children:"MIME Type:"})," ",a.mimeType]}),a.text&&_e("div",{"data-testid":"tool-execution-results-resource-text-content",children:[oe("div",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"Content:"}),oe("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&&_e("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:["[Binary content: ",a.blob.length||0," bytes]"]}),a.annotations&&_e("div",{className:"mt-2",children:[oe("div",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"Annotations:"}),oe(xt,{data:a.annotations,filename:`resource-annotations-${s}.json`,"data-testid":"tool-execution-results-resource-annotations"})]})]})]},s)}return _e("div",{className:"space-y-2",children:[_e("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:["Unknown Content Type: ",r.type||"N/A"]}),oe(xt,{data:r,filename:`content-${s}.json`,"data-testid":"tool-execution-results-unknown-content"})]},s)})})}function Qi({results:e,copiedResult:t,serverId:n,readResource:o,onCopy:r,onMaximize:s,isMaximized:a=!1,onRerunTool:i,onWidgetHeightChange:c}){let[l,u]=Tr(0),[f,d]=Tr(!0),[g,m]=Tr("json"),[v,p]=Tr("inline"),[x,C]=Tr(null),b=e[0],h=b?e.filter($=>$.toolName===b.toolName):[],y=h[l]||h[0],R=e.findIndex($=>$===y),P=y?y.error||Hf(y.result):null,S=P??(y!=null?JSON.stringify(y.result,null,2):"");da(()=>{h.length>0&&l>=h.length&&u(0)},[h.length,l]);let T=to(()=>y?.args,[y?.timestamp,l]),M=to(()=>y?.result,[y?.timestamp,y?.duration,l]),I=Uf($=>o($),[o]),k=to(()=>y&&iw(y.toolMeta)?"mcp-apps":null,[y]),N=to(()=>y?.toolMeta?aw(y.toolMeta):null,[y?.toolMeta]),L=to(()=>k==="mcp-apps"&&!!N,[k,N]);da(()=>{m(L?"mcp-apps":"json")},[b?.toolName,L]);let _=to(()=>y?.result?.content||[],[y]),K=to(()=>N||null,[N]),F=to(()=>!!(_&&_.length>0||y?.result?.structuredContent),[_,y]),Y=to(()=>!L&&F,[L,F]),ee=to(()=>{let $=[];return L&&N&&$.push({mode:"mcp-apps",label:"Component (MCP Apps)"}),$.push({mode:"json",label:"Raw JSON"}),$},[L,N]);return da(()=>{ee.length!==0&&(ee.some($=>$.mode===g)||m(L?"mcp-apps":"json"))},[ee,L,g]),da(()=>{c&&(e.length===0||g!=="mcp-apps"||v!=="inline"||!L)&&c(null)},[c,e.length,g,v,L]),e.length===0?oe("div",{className:"flex flex-col h-full bg-white dark:bg-black",children:oe("div",{className:"flex-1 overflow-y-auto h-full",children:oe("div",{className:"flex items-center justify-center h-full",children:oe("div",{className:"text-center",children:oe(ps,{vertical:!0,noBorder:!0,message:"No Results yet"})})})})}):_e("div",{className:"relative flex flex-col h-full bg-white dark:bg-black",children:[oe("div",{className:"flex-1 overflow-y-auto h-full",children:_e("div",{className:"space-y-0 flex flex-col flex-1 h-full",children:[_e("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 ${L||Y?"border-b border-gray-200 dark:border-zinc-600 pb-2":""}`,children:[oe("h3",{className:"text-sm font-medium hidden sm:block",children:"Response"}),y.duration!==void 0&&_e("div",{className:"hidden sm:flex items-center gap-1",children:[oe(rw,{className:"h-3 w-3 text-gray-400"}),_e("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:[y.duration,"ms"]})]}),L&&oe("div",{className:"flex items-center gap-4 sm:ml-4",children:oe("div",{className:"flex items-center gap-2",children:ee.map(($,Q)=>_e(sw.Fragment,{children:[Q>0&&oe("span",{className:"text-xs text-zinc-400",children:"|"}),oe("button",{"data-testid":`tool-result-view-${$.mode}`,onClick:()=>m($.mode),className:`text-xs font-medium ${g===$.mode?"text-black dark:text-white":"text-zinc-500 dark:text-zinc-400"}`,children:$.label})]},$.mode))})}),Y&&_e("div",{className:"flex items-center gap-2 sm:ml-4",children:[oe("button",{onClick:()=>d(!0),className:`text-xs font-medium ${f?"text-black dark:text-white":"text-zinc-500 dark:text-zinc-400"}`,children:"Formatted"}),oe("span",{className:"text-xs text-zinc-400",children:"|"}),oe("button",{onClick:()=>d(!1),className:`text-xs font-medium ${f?"text-zinc-500 dark:text-zinc-400":"text-black dark:text-white"}`,children:"Raw"})]}),_e("div",{className:"ml-auto flex items-center gap-1",children:[a&&i&&_e(A,{"data-testid":"tool-result-rerun",variant:"ghost",size:"sm",onClick:i,title:"Re-run with same arguments",children:[oe(ow,{className:"h-4 w-4"}),oe("span",{className:"hidden sm:inline ml-1",children:"Re-run"})]}),L&&s&&oe(A,{"data-testid":"tool-result-maximize",variant:"ghost",size:"sm",onClick:s,title:a?"Restore":"Maximize",children:a?oe(nw,{className:"h-4 w-4"}):oe(tw,{className:"h-4 w-4"})}),h.length>1&&_e(Sn,{value:l.toString(),onValueChange:$=>u(parseInt($)),children:[oe(Un,{className:"w-[140px] h-8 text-xs",leading:_e("div",{className:"flex items-center gap-1",children:[oe(Bf,{className:"h-3 w-3"}),oe(lw,{timestamp:y.timestamp})]})}),oe(Hn,{children:h.map(($,Q)=>oe(Wt,{value:Q.toString(),children:_e("div",{className:"flex items-center gap-2",children:[oe(Bf,{className:"h-3 w-3"}),oe("span",{children:Gc($.timestamp)}),_e("span",{className:"text-xs text-muted-foreground",children:["(",new Date($.timestamp).toLocaleTimeString(),")"]})]})},Q))})]}),oe(A,{"data-testid":`tool-result-copy-${R}`,variant:"ghost",size:"sm",onClick:()=>r(R,S),children:t===R?oe(Z0,{className:"h-4 w-4"}):oe(ew,{className:"h-4 w-4"})})]})]}),(()=>{let $=y.error||Hf(y.result);return $?_e("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:[oe("p",{className:"text-red-800 dark:text-red-300 font-medium",children:"Error:"}),oe("p",{className:"text-red-700 dark:text-red-400 text-sm",children:$})]}):(()=>{switch(g){case"mcp-apps":return!L||!N?oe("div",{className:"px-4 pt-4",children:oe("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded p-3",children:oe("p",{className:"text-sm text-red-600 dark:text-red-400",children:"MCP Apps resource not available"})})}):_e(na,{className:"relative flex flex-1 w-full min-h-[240px] items-stretch",children:[oe("div",{className:"absolute top-2 right-2 z-30 flex items-center gap-2",children:oe(Yi,{toolCallId:`tool-${y.timestamp}`,displayMode:v,onDisplayModeChange:p,propsContext:"tool",resourceUri:N,toolInput:y.args,resourceAnnotations:y.toolMeta,llmConfig:null,resource:null,onPropsChange:C})}),oe("div",{className:"flex min-h-0 flex-1 flex-col pt-11",children:oe(is,{serverId:n,viewId:`tool-${y.timestamp}`,toolName:y.toolName,toolInput:T,toolOutput:M,toolMetadata:y.toolMeta,resourceUri:N,readResource:I,customProps:x||void 0,displayMode:v,onDisplayModeChange:p,onWidgetHeightChange:c?V=>c(V):void 0,noWrapper:!0},`mcp-apps-${y.timestamp}`)})]});case"json":{if(Y&&f){let V=y.result?.structuredContent;return _e("div",{className:"px-4 pt-4 space-y-4","data-testid":"tool-execution-results-content",children:[V&&_e("div",{className:"space-y-2","data-testid":"tool-execution-results-structured-content",children:[oe("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"Structured Content"}),oe(xt,{data:V,filename:`structured-content-${y.toolName}-${Date.now()}.json`})]}),_&&_.length>0&&oe(dw,{content:_}),!V&&(!_||_.length===0)&&oe("div",{className:"text-sm text-gray-500 dark:text-gray-400","data-testid":"tool-execution-results-no-content",children:"No content to display"})]})}return oe("div",{className:"px-4 pt-4",children:oe(xt,{data:y.result,filename:`tool-result-${y.toolName}-${Date.now()}.json`})})}default:return null}})()})()]})}),K&&g==="mcp-apps"&&oe("div",{className:"absolute bottom-0 left-1/2 -translate-x-1/2 z-40 pointer-events-none",children:oe("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:K})})]})}import{isViewTool as uw}from"@mcp-use/client/react";import{useMemo as Zi,useState as mw}from"react";import{Fragment as fw,jsx as ho,jsxs as Ff}from"react/jsx-runtime";function pw({widgetId:e}){let{getWidget:t}=Ho(),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 Ff("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:[ho("span",{className:"inline-block w-1.5 h-1.5 rounded-full bg-blue-400 shrink-0"}),ho("span",{className:"font-medium",children:"State synced to model"}),ho("span",{className:"truncate opacity-60 max-w-[300px]",children:r})]})}function el({toolName:e,toolArgs:t,result:n,serverId:o,readResource:r,toolMeta:s,onSendFollowUp:a,modelContextScope:i,llmConfig:c,partialToolArgs:l,cancelled:u}){let f=Zi(()=>`chat-tool-${e}-${Date.now()}-${Math.random().toString(36).substring(2,11)}`,[e]),[d,g]=mw("inline"),m=Zi(()=>{if(!n)return null;if(typeof n=="string")try{return JSON.parse(n)}catch{return n}return n},[n]),v=uw(s),p=v?s?.ui?.resourceUri??null:null,x=Zi(()=>t,[e,m]),C=Zi(()=>m,[e,m]);return v&&p&&o&&r?Ff(fw,{children:[ho(is,{serverId:o,viewId:f,toolName:e,resourceUri:p,toolInput:x,toolOutput:C,toolMetadata:s,readResource:r,displayMode:d,onDisplayModeChange:g,onSendFollowUp:a,modelContextScope:i,llmConfig:c,partialToolInput:l,cancelled:u,noWrapper:!0,className:"my-4"}),ho(pw,{widgetId:f})]}):v&&!p?ho("div",{className:"flex items-center justify-center w-full h-[200px] rounded border",children:ho(hn,{className:"size-5"})}):v&&(!o||!r)?ho("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:ho("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 pU,isViewTool as fU,getViewResourceUri as gU}from"@mcp-use/client/react";import{createContext as gw,use as hw,useCallback as Rn,useState as vw}from"react";import{jsx as yw}from"react/jsx-runtime";var $f=gw(void 0);function bw({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]=vw({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=Rn(b=>{s(h=>({...h,selectedServerId:b}))},[]),i=Rn(b=>{s(h=>({...h,activeTab:b}))},[]),c=Rn(b=>{s(h=>({...h,selectedToolName:b}))},[]),l=Rn(b=>{s(h=>({...h,selectedPromptName:b}))},[]),u=Rn(b=>{s(h=>({...h,selectedResourceUri:b}))},[]),f=Rn(b=>{s(h=>({...h,selectedSamplingRequestId:b}))},[]),d=Rn(b=>{s(h=>({...h,selectedElicitationRequestId:b}))},[]),g=Rn(b=>{s(h=>({...h,tunnelUrl:b}))},[]),m=Rn(b=>{s(h=>({...h,isTunnelStarting:b}))},[]),v=Rn((b,h={})=>{s(y=>({...y,isEmbedded:b,embeddedConfig:{...h,chatApiUrl:h.chatApiUrl?.trim()||o,chatStreamProtocol:h.chatStreamProtocol??"data-stream",chatEnableFreeTierUpgrade:h.chatEnableFreeTierUpgrade??!0}}))},[o]),p=Rn((b,h,y)=>{console.warn("[InspectorContext] navigateToItem called:",{serverId:b,tab:h,itemIdentifier:y}),s(R=>({...R,selectedServerId:b,activeTab:h,selectedToolName:h==="tools"&&y||null,selectedPromptName:h==="prompts"&&y||null,selectedResourceUri:h==="resources"&&y||null,selectedSamplingRequestId:h==="sampling"&&y||null,selectedElicitationRequestId:h==="elicitation"&&y||null}))},[]),x=Rn(()=>{s(b=>({...b,selectedToolName:null,selectedPromptName:null,selectedResourceUri:null,selectedSamplingRequestId:null,selectedElicitationRequestId:null}))},[]),C={...r,setSelectedServerId:a,setActiveTab:i,setSelectedToolName:c,setSelectedPromptName:l,setSelectedResourceUri:u,setSelectedSamplingRequestId:f,setSelectedElicitationRequestId:d,setTunnelUrl:g,setIsTunnelStarting:m,setEmbeddedMode:v,navigateToItem:p,clearSelection:x};return yw($f,{value:C,children:e})}function vo(){let e=hw($f);if(!e)throw new Error("useInspector must be used within InspectorProvider");return e}import{GripVerticalIcon as xw}from"lucide-react";import*as Rr from"react-resizable-panels";import{jsx as ua}from"react/jsx-runtime";var{usePanelRef:Pr}=Rr;function Wo({className:e,...t}){return ua(Rr.Group,{"data-slot":"resizable-panel-group",className:w("flex h-full w-full aria-[orientation=vertical]:flex-col",e),...t})}function vn({...e}){return ua(Rr.Panel,{"data-slot":"resizable-panel",...e})}function Ko({withHandle:e,className:t,...n}){return ua(Rr.Separator,{"data-slot":"resizable-handle",className:w("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&&ua("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:ua(xw,{className:"size-2.5 text-muted-foreground"})})})}import{AnimatePresence as rC,motion as dd}from"motion/react";import{ChevronLeft as sC,Database as eg,Wrench as tg}from"lucide-react";import{useCallback as yn,useEffect as ng,useMemo as og,useRef as sl,useState as Mn}from"react";import{useState as ww}from"react";import{jsx as Vf}from"react/jsx-runtime";function no({className:e,scrollRef:t,children:n}){let[o,r]=ww(!1);return Vf("div",{ref:t,className:w("h-full overflow-y-auto overscroll-none",e),onScroll:s=>r(s.currentTarget.scrollTop>0),children:Vf("div",{className:"flex min-h-full flex-col",children:n(o)})})}import{jsx as ma,jsxs as jf}from"react/jsx-runtime";function $n({id:e,isSelected:t,isFocused:n,title:o,description:r,metadata:s,onClick:a,className:i,"data-testid":c}){return ma("button",{id:e,"data-testid":c,type:"button",onClick:a,className:w("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:jf("div",{className:"flex items-start gap-2 sm:gap-3",children:[jf("div",{className:"flex-1 min-w-0",children:[ma("div",{className:"flex items-center gap-2 mb-1",children:ma("h3",{className:w("font-medium truncate font-mono text-sm"),children:o})}),r&&ma("p",{className:"text-sm text-gray-600 dark:text-gray-400 line-clamp-2",children:r})]}),s&&ma("div",{className:"flex-shrink-0 flex items-center self-center",children:s})]})})}import{forwardRef as Cw}from"react";import{cva as Nw}from"class-variance-authority";import{jsx as tl}from"react/jsx-runtime";var kw={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"},Sw=Nw("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"}}),qf={default:{variant:"solid",color:"blue"},secondary:{variant:"solid",color:"green"},destructive:{variant:"solid",color:"red"},outline:{variant:"outline",color:"gray"}};function Tw(e){return typeof e=="string"||typeof e=="number"}function Rw({children:e}){return Tw(e)?tl("span",{className:"[text-box:trim-both_cap_alphabetic]",children:e}):tl("span",{className:"inline-flex items-center gap-1",children:e})}var Kt=Cw(({className:e,variant:t="solid",size:n="md",color:o,children:r,style:s,...a},i)=>{let c=t&&t in qf?qf[t]:null,l=c?.variant??t,u=o??c?.color??"gray",f=vt(),d=kw[u],m=l==="solid"?u==="gray"?{backgroundColor:"var(--accent)",color:"var(--foreground)"}:{color:"var(--foreground)",backgroundColor:`color-mix(in srgb, ${d} 15%, var(--background))`}:{};return tl("span",{ref:i,className:w(Sw({variant:l,size:n}),f.item,e),style:{...m,...s},...a,children:tl(Rw,{children:r})})});Kt.displayName="Badge";import{RefreshCw as Mw,Search as Iw}from"lucide-react";import{jsx as Pw}from"react/jsx-runtime";function fs({className:e,...t}){return Pw("kbd",{"data-slot":"kbd",className:w("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 Wf,jsx as an,jsxs as bo}from"react/jsx-runtime";var Ew="h-3.5 w-3.5 shrink-0 text-muted-foreground";function Mr({activeTab:e,isSearchExpanded:t,searchQuery:n,primaryTabTitle:o,secondaryTabTitle:r,primaryCount:s,secondaryCount:a,secondaryIcon:i,primaryIcon:c,searchPlaceholder:l="Search...",onSearchExpand:u,onSearchChange:f,onSearchBlur:d,onTabSwitch:g,searchInputRef:m,primaryTabName:v,onRefresh:p,isRefreshing:x=!1,isScrolled:C=!1}){let b=e===v,h=b?c:i,y=b?o:r;return bo("div",{className:`flex flex-row items-center justify-between gap-2 ${yi(C)} ${Io}`,children:[an("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:t?an(Ge,{ref:m,placeholder:l,value:n,onChange:R=>f(R.target.value),onBlur:d,className:"h-8 border-gray-300 dark:border-zinc-600"}):bo(Wf,{children:[bo("h2",{className:`${Eo} flex items-center gap-1.5`,children:[an(h,{className:Ew,"aria-hidden":!0}),y]}),b&&bo(Wf,{children:[an(Kt,{className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",variant:"outline",children:s}),bo(Re,{children:[an(Se,{render:an(A,{variant:"ghost",size:"sm",onClick:u,className:"h-8 w-8 p-0",children:an(Iw,{className:"h-4 w-4"})}),nativeButton:!0}),bo(Te,{side:"bottom",className:"flex gap-2",children:["Search",an(fs,{children:"F"})]})]}),p&&bo(Re,{children:[an(Se,{render:an(A,{variant:"ghost",size:"sm",onClick:p,disabled:x,className:"h-8 w-8 p-0",children:an(Mw,{className:`h-4 w-4 ${x?"animate-spin":""}`})}),nativeButton:!0}),bo(Te,{side:"bottom",className:"flex gap-2",children:["Refresh list",an(fs,{children:"R"})]})]})]})]})}),bo(A,{variant:"ghost",size:"sm",onClick:g,className:"gap-2 flex-shrink-0",children:[an("span",{className:"hidden sm:inline",children:b?r:o}),b&&a>0&&an(Kt,{className:"bg-purple-500/20 text-purple-600 dark:text-purple-400 border-transparent",variant:"outline",children:a})]})]})}import{RefreshCw as Aw,Search as Lw}from"lucide-react";import{Fragment as Dw,jsx as Ut,jsxs as Jo}from"react/jsx-runtime";function nl({title:e,count:t,icon:n,isSearchExpanded:o,searchQuery:r,searchPlaceholder:s,onSearchExpand:a,onSearchChange:i,onSearchBlur:c,searchInputRef:l,titleTestId:u,bulkAction:f,onRefresh:d,isRefreshing:g=!1,isScrolled:m=!1}){let v=f?.icon;return Jo("div",{className:`flex flex-row items-center justify-between gap-2 ${yi(m)} ${Io}`,children:[Ut("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:o?Ut(Ge,{ref:l,placeholder:s,value:r,onChange:x=>i(x.target.value),onBlur:c,className:"h-8 border-gray-300 dark:border-zinc-600"}):Jo(Dw,{children:[Jo("h2",{className:`${Eo} flex items-center gap-1.5`,"data-testid":u,children:[n?Ut(n,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground","aria-hidden":!0}):null,e]}),Ut(Kt,{className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",variant:"outline",children:t}),Jo(Re,{children:[Ut(Se,{render:Ut(A,{variant:"ghost",size:"sm",onClick:a,className:"h-8 w-8 p-0",children:Ut(Lw,{className:"h-4 w-4"})}),nativeButton:!0}),Jo(Te,{side:"bottom",className:"flex gap-2",children:["Search",Ut(fs,{children:"F"})]})]}),d&&Jo(Re,{children:[Ut(Se,{render:Ut(A,{variant:"ghost",size:"sm",onClick:d,disabled:g,className:"h-8 w-8 p-0",children:Ut(Aw,{className:`h-4 w-4 ${g?"animate-spin":""}`})}),nativeButton:!0}),Jo(Te,{side:"bottom",className:"flex gap-2",children:["Refresh list",Ut(fs,{children:"R"})]})]})]})}),f&&v&&Ut("div",{className:"flex items-center gap-2",children:Jo(Re,{children:[Ut(Se,{render:Ut(A,{variant:"ghost",size:"sm",onClick:f.onClick,disabled:f.disabled,className:"h-8 w-8 p-0",children:Ut(v,{className:"h-4 w-4"})}),nativeButton:!0}),Ut(Te,{side:"bottom",children:f.label})]})})]})}import{Database as _w,Trash2 as Ow}from"lucide-react";import{jsx as bn,jsxs as Yc}from"react/jsx-runtime";function Xc({savedRequests:e,selectedRequest:t,onLoadRequest:n,onDeleteRequest:o,focusedIndex:r}){if(e.length===0)return Yc("div",{className:"flex flex-1 flex-col items-center justify-center p-4 text-center",children:[bn(_w,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),bn("p",{className:"text-gray-500 dark:text-gray-400 mb-2",children:"No saved requests yet"}),bn("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 bn("div",{children:e.map((a,i)=>Yc("div",{className:"relative group",children:[bn($n,{id:`saved-${a.id}`,isSelected:t?.id===a.id,isFocused:r===i,title:a.name,description:a.toolName,metadata:bn("div",{className:"flex flex-col gap-1",children:bn("span",{className:"text-xs text-gray-400 dark:text-gray-500",children:new Date(a.savedAt).toLocaleString()})}),onClick:()=>n(a)}),bn("div",{className:"absolute top-1/2 right-2 -translate-y-1/2 opacity-0 group-hover:opacity-100 transition-opacity z-10",children:Yc(Re,{children:[bn(Se,{render:bn(A,{variant:"secondary",size:"sm",onClick:c=>s(c,()=>o(a.id)),className:"h-8 w-8 p-0",children:bn(Ow,{className:"h-4 w-4"})}),nativeButton:!0}),bn(Te,{children:bn("p",{children:"Delete saved request"})})]})})]},a.id))})}import{Save as zw}from"lucide-react";import{jsx as gs,jsxs as pa}from"react/jsx-runtime";function Qc({isOpen:e,requestName:t,defaultPlaceholder:n,onRequestNameChange:o,onSave:r,onCancel:s}){return e?gs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:s,children:pa("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:[gs("h3",{className:"text-lg font-semibold mb-4 text-gray-900 dark:text-gray-100",children:"Save Request"}),pa("div",{className:"space-y-4",children:[pa("div",{children:[gs(tt,{htmlFor:"request-name",children:"Request Name (optional)"}),gs(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})]}),pa("div",{className:"flex justify-end gap-2",children:[gs(A,{variant:"outline",onClick:s,children:"Cancel"}),pa(A,{onClick:r,children:[gs(zw,{className:"h-4 w-4 mr-2"}),"Save"]})]})]})]})}):null}import{Check as Bw,ChevronDown as Hw,ChevronUp as Uw,Code as Fw,Copy as $w,Play as Vw,Save as jw,X as qw}from"lucide-react";import{useEffect as Kf,useRef as Ww,useState as fa}from"react";import{Fragment as hs,jsx as Ce,jsxs as kt}from"react/jsx-runtime";function Zc({selectedTool:e,toolArgs:t,payloadToSend:n,isExecuting:o,isConnected:r,onArgChange:s,onExecute:a,onSave:i,onCancel:c,onBulkPaste:l,autoFilledFields:u,setFields:f,sendEmptyFields:d,onToggleEmpty:g}){let m="hidden @[700px]/tool-exec:inline",v="hidden @[700px]/tool-exec:inline shrink-0 text-[10px] leading-none border border-current/30 p-1 rounded-full",p="@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",x="@max-[699px]/tool-exec:!pr-0",[C,b]=fa(!1),[h,y]=fa(!1),[R,P]=fa(!1),[S,T]=fa(!1),[M,I]=fa(!1),k=Ww(null);Kf(()=>{if(k.current&&e?.description){let _=k.current,K=parseFloat(getComputedStyle(_).lineHeight),F=_.scrollHeight,Y=Math.round(F/K);I(Y>3),T(!1)}},[e?.description]);let N=async()=>{e&&await Ze(JSON.stringify(e,null,2))},L=async()=>{if(e)try{await Ze(JSON.stringify(n??t,null,2)),P(!0),setTimeout(()=>P(!1),2e3)}catch{}};return Kf(()=>{let _=K=>{if(K.key==="Escape"&&o&&c){K.preventDefault(),c();return}if(K.key!=="Enter")return;let F=K.metaKey||K.ctrlKey,Y=!K.metaKey&&!K.ctrlKey&&!K.altKey&&!K.shiftKey,ee=K.target,$=ee instanceof HTMLInputElement&&ee.dataset.toolArgumentInput==="true";(F||Y&&$)&&e&&!o&&r&&(K.preventDefault(),a())};return document.addEventListener("keydown",_),()=>document.removeEventListener("keydown",_)},[e,o,r,a,c]),e?kt("div",{className:"flex flex-col h-full @container/tool-exec",children:[Ce("div",{className:"shrink-0 p-3 sm:p-5 pt-3 sm:pt-4 pb-2 sm:pb-2 sm:pr-4",children:Ce("div",{children:kt("div",{className:"flex flex-row items-center justify-between mb-0 gap-2",children:[Ce("h3",{className:"text-base sm:text-lg font-semibold","data-testid":"tool-execution-title",children:e.name}),kt("div",{className:"flex gap-2 shrink-0",children:[kt(Re,{children:[Ce(Se,{render:kt(A,{"data-testid":"tool-execution-metadata-button",variant:h?"default":"outline",onClick:()=>y(!h),disabled:o,size:"sm",className:w(ur,p),title:"View tool metadata",children:[Ce(Fw,{}),Ce("span",{className:m,children:"Metadata"})]}),nativeButton:!0}),Ce(Te,{children:Ce("p",{children:"View tool definition metadata"})})]}),kt(Re,{children:[Ce(Se,{render:kt(A,{"data-testid":"tool-execution-copy-payload-button",variant:"outline",onClick:L,disabled:o,size:"sm",className:w(ur,p),title:"Copy payload as JSON",children:[R?Ce(Bw,{className:"text-green-600"}):Ce($w,{}),Ce("span",{className:m,children:R?"Copied!":"Payload"})]}),nativeButton:!0}),Ce(Te,{children:Ce("p",{children:"Copy payload as JSON"})})]}),kt(Re,{children:[Ce(Se,{render:kt(A,{"data-testid":"tool-execution-save-button",variant:"outline",onClick:i,disabled:o,size:"sm",className:w(ur,p),title:"Save request",children:[Ce(jw,{}),Ce("span",{className:m,children:"Save"})]}),nativeButton:!0}),Ce(Te,{children:Ce("p",{children:"Save request"})})]}),o&&c?kt(Re,{open:C?void 0:!1,children:[Ce(Se,{render:Ce("div",{onMouseEnter:()=>b(!0),onMouseLeave:()=>b(!1),className:"relative",children:Ce(A,{"data-testid":"tool-execution-cancel-button",onClick:c,variant:C?"destructive":"default",size:"sm",className:w(Gs,p,x,"transition-all"),children:C?kt(hs,{children:[Ce(qw,{}),Ce("span",{className:m,children:"Cancel"}),Ce("span",{className:v,children:"Esc"})]}):kt(hs,{children:[Ce(hn,{}),Ce("span",{className:m,children:"Executing..."})]})})}),nativeButton:!1}),Ce(Te,{children:Ce("p",{children:"Hover to cancel (or press Esc)"})})]}):Ce(A,{"data-testid":"tool-execution-execute-button",onClick:a,disabled:o||!r,size:"sm",className:w(Gs,p,x),children:o?kt(hs,{children:[Ce(hn,{}),Ce("span",{className:m,children:"Executing..."})]}):kt(hs,{children:[Ce(Vw,{}),Ce("span",{className:m,children:"Execute"}),Ce("span",{className:v,children:"\u2318\u21B5"})]})})]})]})})}),kt("div",{className:"flex-1 overflow-y-auto px-3 sm:px-5 pb-4 pr-3",children:[e.description&&kt("div",{className:"relative mb-6",children:[kt("div",{className:"relative",children:[Ce("p",{ref:k,"data-testid":"tool-execution-description",className:`text-sm text-gray-600 dark:text-gray-400 leading-relaxed transition-all duration-300 ${!S&&M?"line-clamp-3":""}`,children:e.description}),M&&!S&&Ce("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"})]}),M&&Ce("div",{className:"flex justify-end",children:Ce("button",{onClick:()=>T(!S),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:S?kt(hs,{children:["Show less",Ce(Uw,{className:"h-3 w-3"})]}):kt(hs,{children:["Show more",Ce(Hw,{className:"h-3 w-3"})]})})})]}),Ce(Ec,{selectedTool:e,toolArgs:t,onArgChange:s,onBulkPaste:l,autoFilledFields:u,setFields:f,sendEmptyFields:d,onToggleEmpty:g})]}),Ce(fn,{open:h,onOpenChange:y,children:kt(rn,{scrollable:!0,className:"max-w-3xl max-h-[80vh]",children:[Ce(Xt,{sticky:!0,children:Ce(qt,{children:"Tool Definition"})}),Ce(zn,{children:Ce(vi,{onCopy:N,children:Ce(xt,{data:e,filename:`tool-definition-${e.name}-${Date.now()}.json`})})})]})})]}):kt("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[Ce("p",{className:"text-gray-500 dark:text-gray-400 mb-2",children:"Select a tool to get started"}),Ce("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 Kw,Wrench as Jw}from"lucide-react";import{isViewTool as Gw}from"@mcp-use/client/react";import{jsx as yo,jsxs as ol}from"react/jsx-runtime";function ed({tools:e,selectedTool:t,onToolSelect:n,focusedIndex:o}){if(e.length===0)return ol("div",{className:"flex flex-1 flex-col items-center justify-center p-4 text-center",children:[yo(Jw,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),yo("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 yo("div",{children:e.map((s,a)=>{let i=s._meta,c=Gw(i)?"mcp-apps":null,l=s.inputSchema?.properties,u=l?Object.keys(l).length:0,f=r&&u>0&&ol(Kt,{variant:"outline",className:"text-xs border-gray-300 dark:border-zinc-600 text-gray-600 dark:text-gray-400",children:[u," params"]}),g=c==="mcp-apps"||f?ol("div",{className:"flex items-center gap-1.5",children:[c==="mcp-apps"&&ol(Re,{children:[yo(Se,{render:yo("span",{className:"inline-flex",children:yo(Kw,{className:"h-3.5 w-3.5"})}),nativeButton:!1}),yo(Te,{children:yo("p",{children:"UI widget"})})]}),f]}):void 0;return yo($n,{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:g,onClick:()=>n(s)},s.name)})})}import{AlertDialog as Ir}from"@base-ui/react/alert-dialog";import{jsx as Pn,jsxs as Qw}from"react/jsx-runtime";function td({...e}){return Pn(Ir.Root,{"data-slot":"alert-dialog",...e})}function Yw({...e}){return Pn(Ir.Portal,{"data-slot":"alert-dialog-portal",...e})}function Xw({className:e,...t}){return Pn(Ir.Backdrop,{"data-slot":"alert-dialog-overlay",className:w("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 nd({className:e,size:t="default",...n}){return Qw(Yw,{children:[Pn(Xw,{}),Pn(Ir.Popup,{"data-slot":"alert-dialog-content","data-size":t,className:w("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 od({className:e,...t}){return Pn("div",{"data-slot":"alert-dialog-header",className:w("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 rd({className:e,...t}){return Pn("div",{"data-slot":"alert-dialog-footer",className:w("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 sd({className:e,...t}){return Pn(Ir.Title,{"data-slot":"alert-dialog-title",className:w("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 ad({className:e,...t}){return Pn(Ir.Description,{"data-slot":"alert-dialog-description",className:w("text-sm text-balance text-muted-foreground md:text-pretty *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground",e),...t})}function id({className:e,...t}){return Pn(A,{"data-slot":"alert-dialog-action",className:w(e),...t})}function ld({className:e,variant:t="outline",size:n="default",...o}){return Pn(Ir.Close,{"data-slot":"alert-dialog-cancel",className:w(e),render:Pn(A,{variant:t,size:n}),...o})}import{useCallback as Zw,useEffect as Jf,useState as eC}from"react";var cd="mcp-inspector-saved-requests";function Gf(){let[e,t]=eC([]);Jf(()=>{try{let o=localStorage.getItem(cd);o&&t(JSON.parse(o))}catch(o){console.error("[useSavedRequests] Failed to load saved requests:",o)}},[]),Jf(()=>{let o=r=>{if(r.key===cd&&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=Zw(o=>{try{localStorage.setItem(cd,JSON.stringify(o)),t(o)}catch(r){console.error("[useSavedRequests] Failed to save requests:",r)}},[]);return{savedRequests:e,saveSavedRequests:n}}import{useCallback as ga,useMemo as tC,useState as rl}from"react";function Yf(e,t){if(!e)return t;if(!t)return e;let n=e.ui&&typeof e.ui=="object"&&!Array.isArray(e.ui)?e.ui:void 0,o=t.ui&&typeof t.ui=="object"&&!Array.isArray(t.ui)?t.ui:void 0;return{...e,...t,...n||o?{ui:{...n,...o}}:{}}}function Xf({selectedTool:e,payloadToSend:t,toolArgs:n,callTool:o,readResource:r,serverId:s}){let[a,i]=rl([]),[c,l]=rl(!1),[u,f]=rl(null),[d,g]=rl(null),m=ga(async()=>{if(!e||c)return;let h=new AbortController;g(h),l(!0);let y=Date.now();try{let R=t,P=e?._meta||e?.metadata,T=P?.ui?.resourceUri;if(T&&typeof T=="string"){try{await r(T)}catch{}i([{toolName:e.name,args:R,result:null,timestamp:y,duration:0,toolMeta:P}])}let M=await o(e.name,R,{timeout:6e5,resetTimeoutOnProgress:!0,signal:h.signal}),I=Date.now()-y,k=Yf(P,M?._meta);It(new Vs({toolName:e.name,serverId:s,success:!0,duration:I})).catch(()=>{}),window.dispatchEvent(new Event("mcp-tool-executed")),i(T&&typeof T=="string"?N=>N.map((L,_)=>_===0?{...L,result:M,duration:I,toolMeta:k}:L):N=>[{toolName:e.name,args:n,result:M,timestamp:y,duration:I,toolMeta:k},...N])}catch(R){let P=Date.now()-y;It(new Vs({toolName:e.name,serverId:s,success:!1,duration:P,error:R instanceof Error?R.message:String(R)})).catch(()=>{}),window.dispatchEvent(new Event("mcp-tool-executed"));let S=e?._meta||e?.metadata,T={toolName:e.name,args:n,result:null,error:R instanceof Error?R.message:String(R),timestamp:y,duration:P,toolMeta:S},M=S?.ui?.resourceUri;i(M?[T]:I=>[T,...I])}finally{l(!1)}},[e,t,n,c,o,r,s]),v=ga(async(h,y)=>{try{await Ze(y),f(h),setTimeout(()=>f(null),2e3)}catch(R){console.error("[ToolsTab] Failed to copy result:",R)}},[]),p=ga(h=>{i(y=>y.filter((R,P)=>P!==h))},[]),x=tC(()=>e?a.filter(h=>h.toolName===e.name):[],[a,e]),C=ga(h=>{let y=x[h];if(!y)return;let R=window.open("","_blank","width=800,height=600");R&&(R.document.write(`
103
103
  <html>
104
104
  <head><title>${y.toolName} Result</title></head>
105
105
  <body><pre>${JSON.stringify(y.result,null,2)}</pre></body>
@@ -223,4 +223,4 @@ ${Le.join(`
223
223
 
224
224
  ---
225
225
 
226
- `),pe},[Xr,lm]),$v=$e(()=>{let z=ai(U);Ze(z).then(()=>Ls.success("Chat copied to clipboard"),()=>Ls.error("Failed to copy chat"))},[U,ai]),Vv=$e(z=>{let fe=`chat-export-${new Date().toISOString().split("T")[0]}`;if(z==="json"){let dt=U.map(Le=>({id:Le.id,role:Le.role,content:Xr(Le),timestamp:Le.timestamp,toolInvocations:Le.parts?.filter(De=>De.type==="tool-invocation"&&De.toolInvocation).map(De=>({toolName:De.toolInvocation.toolName,args:De.toolInvocation.args,result:De.toolInvocation.result}))}));Ki(dt,fe+".json")}else{let dt=ai(U),Le=new Blob([dt],{type:"text/markdown"}),De=URL.createObjectURL(Le),Qe=document.createElement("a");Qe.href=De,Qe.download=fe+".md",document.body.appendChild(Qe),Qe.click(),document.body.removeChild(Qe),setTimeout(()=>URL.revokeObjectURL(De),100)}Ls.success(`Chat exported as ${z.toUpperCase()}`)},[U,ai,Xr]),fm=$e(()=>{Ot(),zs()},[Ot,zs]),jv=$e(z=>{z.trim()&&(!ft||!t||(Gr(),Xe(z,[]).then(()=>{jt("mcp-inspector:chat:message_sent",{message:z,source:"quick_question"})})))},[jt,Xe,ft,t,Gr]),qv=$e(z=>{z.trim()&&(!ft||!t||Xe(z,[]).then(()=>{jt("mcp-inspector:chat:message_sent",{message:z,source:"followup"})}))},[jt,Xe,ft,t]),gm=co&&!(g&&co.kind==="login_required")?gt(wv,{notice:co,onConfigureApiKey:Bv,onSignIn:co.kind==="login_required"?c?Qu:()=>{window.location.href=co.loginUrl}:void 0,authorizing:Uv}):null;return ft&&U.length===0?cm(lr("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:[gt("div",{className:"absolute top-4 right-4 z-10",children:gt(Aa,{open:ge,onOpenChange:me,tempProvider:B,tempModel:Oe,tempApiKey:$t,tempBaseUrl:lt,onProviderChange:Ie,onModelChange:Ae,onApiKeyChange:Ee,onBaseUrlChange:Vt,onSave:Gu,onClear:fm,showClearButton:!!O,buttonLabel:"Change API Key",hostedInspector:g,freeTierInfo:ni,managedCloudInfo:Yr,useManagedCloud:Wr,onSaveManagedCloud:Yr?om:void 0})}),gt(Nu,{serverDisplayName:Oi(e),composerNotice:gm,inputValue:j,isConnected:t&&!co&&!Bs,isLoading:ve,textareaRef:pt,llmConfig:ft,promptsDropdownOpen:ye,promptFocusedIndex:ie,prompts:uo,selectedPrompt:rm,promptResults:Hs,attachments:nt,tools:y?void 0:Yt,disabledTools:y?void 0:ht,onDisabledToolsChange:y?void 0:Ct,onDeletePromptResult:am,onPromptSelect:ri,onInputChange:D,onKeyDown:mm,onKeyUp:pm,onClick:Zr,onSendMessage:si,onStopStreaming:Nn,onConfigDialogOpenChange:me,onAttachmentAdd:Gn,onAttachmentRemove:Jr,hideModelBadge:em,freeTierInfo:ni,managedCloudInfo:Yr,modelBadgeMode:tm,modelDisplayName:nm,quickQuestions:Je,onQuickQuestionSelect:jv,pendingElicitationRequests:e.pendingElicitationRequests,onApproveElicitation:e.approveElicitation,onRejectElicitation:e.rejectElicitation,systemPromptProvider:re}),Yu]})):cm(lr("div",{className:"relative flex min-h-0 flex-1 flex-col overflow-hidden",children:[gt(fu,{llmConfig:ft,hasMessages:U.length>0,configDialogOpen:ge,onConfigDialogOpenChange:me,onClearChat:de?zs:Za,tempProvider:B,tempModel:Oe,tempApiKey:$t,tempBaseUrl:lt,onProviderChange:Ie,onModelChange:Ae,onApiKeyChange:Ee,onBaseUrlChange:Vt,onSaveConfig:Gu,onClearConfig:fm,showClearButton:!!O,hideConfigButton:Zu,hostedInspector:g,freeTierInfo:ni,managedCloudInfo:Yr,useManagedCloud:Wr,onSaveManagedCloud:Yr?om:void 0,onCopyChat:$v,onExportChat:Vv,clearButtonLabel:m,hideTitle:v,clearButtonHideIcon:x,clearButtonHideShortcut:C,clearButtonVariant:b,hideClearButton:h,activeChatId:ae,chatTitle:Ov,showViewToggle:!!ft,viewIndex:mn==="raw"?1:0,onViewIndexChange:z=>Ro(z===1?"raw":"conv"),elevatedHeader:Q}),lr("div",{className:"relative flex min-h-0 flex-1 flex-col overflow-hidden",children:[gt(dv,{visible:Ev&&!!ft}),gt("div",{ref:Dt,"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:ft?mn==="conv"?gt(Va,{messages:U,isLoading:ve,serverId:e.url,readResource:i,tools:e.tools,sendMessage:Rv,modelContextScope:Kr,llmConfig:ft,serverBaseUrl:e.url,messagesEndRef:Mv,traceEvents:Wu}):gt(Cv,{events:Wu,usage:Tv}):gt(ku,{onConfigureClick:()=>me(!0)})}),ft&&gt(cv,{visible:Iv,onClick:()=>Av("smooth")})]}),ft&&lr("div",{className:"relative shrink-0","data-chat-composer":!0,children:[gt(vv,{messages:U,isLoading:ve}),gm,gt(Ha,{variant:V?"fullscreen":"default",inputValue:j,isConnected:t&&!co&&!Bs,isLoading:ve,textareaRef:pt,llmConfig:ft,promptsDropdownOpen:ye,promptFocusedIndex:ie,prompts:uo,promptResults:Hs,selectedPrompt:rm,attachments:nt,tools:y?void 0:Yt,disabledTools:y?void 0:ht,onDisabledToolsChange:y?void 0:Ct,onDeletePromptResult:am,onPromptSelect:ri,onInputChange:D,onKeyDown:mm,onKeyUp:pm,onClick:Zr,onSendMessage:si,onStopStreaming:Nn,onConfigDialogOpenChange:me,onAttachmentAdd:Gn,onAttachmentRemove:Jr,hideModelBadge:em,freeTierInfo:ni,managedCloudInfo:Yr,modelBadgeMode:tm,modelDisplayName:nm,followups:Gt,onFollowupSelect:qv,pendingElicitationRequests:e.pendingElicitationRequests,onApproveElicitation:e.approveElicitation,onRejectElicitation:e.rejectElicitation,systemPromptProvider:re})]}),Yu]}))}function eR(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 f=o.parts.length;o.parts.push({type:"tool-invocation",toolInvocation:{toolName:String(l.toolName??"unknown"),args:l.args??{},state:"pending"}}),r.set(u,f);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 f=r.get(u);if(f!==void 0){let d=o.parts[f];d?.type==="tool-invocation"&&d.toolInvocation&&(d.toolInvocation.result=l.result,d.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{Fy as AddToClientDropdown,_r as CHAT_TITLE_PLACEHOLDER,Zo as CHAT_TITLE_SIMPLE,fu as ChatHeader,Ed as ChatHistoryHeader,$d as ChatHistoryPanel,Vd as ChatHistoryRail,Ha as ChatInputArea,Nu as ChatLandingForm,Hd as ChatList,ZT as ChatTab,Na as ChatTitleReveal,Aa as ConfigurationDialog,ku as ConfigureEmptyState,$r as DEFAULT_CHAT_SYSTEM_PROMPT,bw as InspectorProvider,Sa as LocalChatStorageProvider,Va as MessageList,Sg as PromptsTab,fg as ResourcesTab,mx as ThemeProvider,Ec as ToolInputForm,Qi as ToolResultDisplay,el as ToolResultRenderer,sg as ToolsTab,SU as ViewRenderer,wx as WidgetDebugProvider,Ll as chatBarActionButtonClass,mu as chatBarFrostedPill,pu as chatBarTitleFrostedClass,eR as chatEventsToInspectorMessages,Fm as downloadMcpbFile,Ld as firstUserMessageFromMessages,Dd as generateChatTitleWithLlm,$m as generateClaudeCodeCommand,jm as generateCodexConfig,Bm as generateCursorDeepLink,Vm as generateGeminiCLICommand,Dy as generateMcpbConfig,jP as generatePythonSDKCode,VP as generateTypeScriptSDKCode,Hm as generateVSCodeDeepLink,Um as generateVSCodeInsidersDeepLink,vc as getEnvVarInstructions,Ga as getSystemPromptStorageKey,RU as getViewResourceUri,er as isPlaceholderTitle,TU as isViewTool,Fu as readStoredSystemPrompt,Vu as resolveSystemPrompt,Ud as useChatHistory,Ou as useChatMessages,Bu as useChatMessagesClientSide,qd as useChatTitleGeneration,va as useConfig,vo as useInspector,Ca as useMCPPrompts,$u as writeStoredSystemPrompt};
226
+ `),pe},[Xr,lm]),$v=$e(()=>{let z=ai(U);Ze(z).then(()=>Ls.success("Chat copied to clipboard"),()=>Ls.error("Failed to copy chat"))},[U,ai]),Vv=$e(z=>{let fe=`chat-export-${new Date().toISOString().split("T")[0]}`;if(z==="json"){let dt=U.map(Le=>({id:Le.id,role:Le.role,content:Xr(Le),timestamp:Le.timestamp,toolInvocations:Le.parts?.filter(De=>De.type==="tool-invocation"&&De.toolInvocation).map(De=>({toolName:De.toolInvocation.toolName,args:De.toolInvocation.args,result:De.toolInvocation.result}))}));Ki(dt,fe+".json")}else{let dt=ai(U),Le=new Blob([dt],{type:"text/markdown"}),De=URL.createObjectURL(Le),Qe=document.createElement("a");Qe.href=De,Qe.download=fe+".md",document.body.appendChild(Qe),Qe.click(),document.body.removeChild(Qe),setTimeout(()=>URL.revokeObjectURL(De),100)}Ls.success(`Chat exported as ${z.toUpperCase()}`)},[U,ai,Xr]),fm=$e(()=>{Ot(),zs()},[Ot,zs]),jv=$e(z=>{z.trim()&&(!ft||!t||(Gr(),Xe(z,[]).then(()=>{jt("mcp-inspector:chat:message_sent",{message:z,source:"quick_question"})})))},[jt,Xe,ft,t,Gr]),qv=$e(z=>{z.trim()&&(!ft||!t||Xe(z,[]).then(()=>{jt("mcp-inspector:chat:message_sent",{message:z,source:"followup"})}))},[jt,Xe,ft,t]),gm=co&&!(g&&co.kind==="login_required")?gt(wv,{notice:co,onConfigureApiKey:Bv,onSignIn:co.kind==="login_required"?c?Qu:()=>{window.location.href=co.loginUrl}:void 0,authorizing:Uv}):null;return ft&&U.length===0?cm(lr("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:[gt("div",{className:"absolute top-4 right-4 z-10",children:gt(Aa,{open:ge,onOpenChange:me,tempProvider:B,tempModel:Oe,tempApiKey:$t,tempBaseUrl:lt,onProviderChange:Ie,onModelChange:Ae,onApiKeyChange:Ee,onBaseUrlChange:Vt,onSave:Gu,onClear:fm,showClearButton:!!O,buttonLabel:"Change API Key",hostedInspector:g,freeTierInfo:ni,managedCloudInfo:Yr,useManagedCloud:Wr,onSaveManagedCloud:Yr?om:void 0})}),gt(Nu,{serverDisplayName:Oi(e),composerNotice:gm,inputValue:j,isConnected:t&&!co&&!Bs,isLoading:ve,textareaRef:pt,llmConfig:ft,promptsDropdownOpen:ye,promptFocusedIndex:ie,prompts:uo,selectedPrompt:rm,promptResults:Hs,attachments:nt,tools:y?void 0:Yt,disabledTools:y?void 0:ht,onDisabledToolsChange:y?void 0:Ct,onDeletePromptResult:am,onPromptSelect:ri,onInputChange:D,onKeyDown:mm,onKeyUp:pm,onClick:Zr,onSendMessage:si,onStopStreaming:Nn,onConfigDialogOpenChange:me,onAttachmentAdd:Gn,onAttachmentRemove:Jr,hideModelBadge:em,freeTierInfo:ni,managedCloudInfo:Yr,modelBadgeMode:tm,modelDisplayName:nm,quickQuestions:Je,onQuickQuestionSelect:jv,pendingElicitationRequests:e.pendingElicitationRequests,onApproveElicitation:e.approveElicitation,onRejectElicitation:e.rejectElicitation,systemPromptProvider:re}),Yu]})):cm(lr("div",{className:"relative flex min-h-0 flex-1 flex-col overflow-hidden",children:[gt(fu,{llmConfig:ft,hasMessages:U.length>0,configDialogOpen:ge,onConfigDialogOpenChange:me,onClearChat:de?zs:Za,tempProvider:B,tempModel:Oe,tempApiKey:$t,tempBaseUrl:lt,onProviderChange:Ie,onModelChange:Ae,onApiKeyChange:Ee,onBaseUrlChange:Vt,onSaveConfig:Gu,onClearConfig:fm,showClearButton:!!O,hideConfigButton:Zu,hostedInspector:g,freeTierInfo:ni,managedCloudInfo:Yr,useManagedCloud:Wr,onSaveManagedCloud:Yr?om:void 0,onCopyChat:$v,onExportChat:Vv,clearButtonLabel:m,hideTitle:v,clearButtonHideIcon:x,clearButtonHideShortcut:C,clearButtonVariant:b,hideClearButton:h,activeChatId:ae,chatTitle:Ov,showViewToggle:!!ft,viewIndex:mn==="raw"?1:0,onViewIndexChange:z=>Ro(z===1?"raw":"conv"),elevatedHeader:Q}),lr("div",{className:"relative flex min-h-0 flex-1 flex-col overflow-hidden",children:[gt(dv,{visible:Ev&&!!ft}),gt("div",{ref:Dt,"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:ft?mn==="conv"?gt(Va,{messages:U,isLoading:ve,serverId:e.url,readResource:i,tools:e.tools,sendMessage:Rv,modelContextScope:Kr,llmConfig:ft,serverBaseUrl:e.url,messagesEndRef:Mv,traceEvents:Wu}):gt(Cv,{events:Wu,usage:Tv}):gt(ku,{onConfigureClick:()=>me(!0)})}),ft&&gt(cv,{visible:Iv,onClick:()=>Av("smooth")})]}),ft&&lr("div",{className:"relative shrink-0","data-chat-composer":!0,children:[gt(vv,{messages:U,isLoading:ve}),gm,gt(Ha,{variant:V?"fullscreen":"default",inputValue:j,isConnected:t&&!co&&!Bs,isLoading:ve,textareaRef:pt,llmConfig:ft,promptsDropdownOpen:ye,promptFocusedIndex:ie,prompts:uo,promptResults:Hs,selectedPrompt:rm,attachments:nt,tools:y?void 0:Yt,disabledTools:y?void 0:ht,onDisabledToolsChange:y?void 0:Ct,onDeletePromptResult:am,onPromptSelect:ri,onInputChange:D,onKeyDown:mm,onKeyUp:pm,onClick:Zr,onSendMessage:si,onStopStreaming:Nn,onConfigDialogOpenChange:me,onAttachmentAdd:Gn,onAttachmentRemove:Jr,hideModelBadge:em,freeTierInfo:ni,managedCloudInfo:Yr,modelBadgeMode:tm,modelDisplayName:nm,followups:Gt,onFollowupSelect:qv,pendingElicitationRequests:e.pendingElicitationRequests,onApproveElicitation:e.approveElicitation,onRejectElicitation:e.rejectElicitation,systemPromptProvider:re})]}),Yu]}))}function eR(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 f=o.parts.length;o.parts.push({type:"tool-invocation",toolInvocation:{toolName:String(l.toolName??"unknown"),args:l.args??{},state:"pending"}}),r.set(u,f);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 f=r.get(u);if(f!==void 0){let d=o.parts[f];d?.type==="tool-invocation"&&d.toolInvocation&&(d.toolInvocation.result=l.result,d.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{Fy as AddToClientDropdown,_r as CHAT_TITLE_PLACEHOLDER,Zo as CHAT_TITLE_SIMPLE,fu as ChatHeader,Ed as ChatHistoryHeader,$d as ChatHistoryPanel,Vd as ChatHistoryRail,Ha as ChatInputArea,Nu as ChatLandingForm,Hd as ChatList,ZT as ChatTab,Na as ChatTitleReveal,Aa as ConfigurationDialog,ku as ConfigureEmptyState,$r as DEFAULT_CHAT_SYSTEM_PROMPT,bw as InspectorProvider,Sa as LocalChatStorageProvider,Va as MessageList,Sg as PromptsTab,fg as ResourcesTab,mx as ThemeProvider,Ec as ToolInputForm,Qi as ToolResultDisplay,el as ToolResultRenderer,sg as ToolsTab,pU as ViewRenderer,wx as WidgetDebugProvider,Ll as chatBarActionButtonClass,mu as chatBarFrostedPill,pu as chatBarTitleFrostedClass,eR as chatEventsToInspectorMessages,Fm as downloadMcpbFile,Ld as firstUserMessageFromMessages,Dd as generateChatTitleWithLlm,$m as generateClaudeCodeCommand,jm as generateCodexConfig,Bm as generateCursorDeepLink,Vm as generateGeminiCLICommand,Dy as generateMcpbConfig,jP as generatePythonSDKCode,VP as generateTypeScriptSDKCode,Hm as generateVSCodeDeepLink,Um as generateVSCodeInsidersDeepLink,vc as getEnvVarInstructions,Ga as getSystemPromptStorageKey,gU as getViewResourceUri,er as isPlaceholderTitle,fU as isViewTool,Fu as readStoredSystemPrompt,Vu as resolveSystemPrompt,Ud as useChatHistory,Ou as useChatMessages,Bu as useChatMessagesClientSide,qd as useChatTitleGeneration,va as useConfig,vo as useInspector,Ca as useMCPPrompts,$u as writeStoredSystemPrompt};
@@ -1,4 +1,4 @@
1
- var Xt=Object.create;var ke=Object.defineProperty;var Qt=Object.getOwnPropertyDescriptor;var Zt=Object.getOwnPropertyNames;var er=Object.getPrototypeOf,tr=Object.prototype.hasOwnProperty;var F=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var rr=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Zt(e))!tr.call(t,o)&&o!==r&&ke(t,o,{get:()=>e[o],enumerable:!(n=Qt(e,o))||n.enumerable});return t};var nr=(t,e,r)=>(r=t!=null?Xt(er(t)):{},rr(e||!t||!t.__esModule?ke(r,"default",{value:t,enumerable:!0}):r,t));var ct=F((Wo,at)=>{"use strict";at.exports=class{constructor(e={}){this.points=e.points,this.duration=e.duration,this.blockDuration=e.blockDuration,this.execEvenly=e.execEvenly,this.execEvenlyMinDelayMs=e.execEvenlyMinDelayMs,this.keyPrefix=e.keyPrefix}get points(){return this._points}set points(e){if(Number.isFinite(e))this._points=e;else throw new Error("points must be set and must be a finite number")}get duration(){return this._duration}set duration(e){if(typeof e=="number"&&Number.isFinite(e)&&e>=0)this._duration=e;else throw new Error("duration must be set and must be a finite, non-negative number")}get msDuration(){return this.duration*1e3}get blockDuration(){return this._blockDuration}set blockDuration(e){this._blockDuration=typeof e>"u"?0:e}get msBlockDuration(){return this.blockDuration*1e3}get execEvenly(){return this._execEvenly}set execEvenly(e){this._execEvenly=typeof e>"u"?!1:!!e}get execEvenlyMinDelayMs(){return this._execEvenlyMinDelayMs===void 0?this._getExecEvenlyMinDelayMsDefault():this._execEvenlyMinDelayMs}set execEvenlyMinDelayMs(e){this._execEvenlyMinDelayMs=e}_getExecEvenlyMinDelayMsDefault(){return this.points>0?Math.ceil(this.msDuration/this.points):0}get keyPrefix(){return this._keyPrefix}set keyPrefix(e){if(typeof e>"u"&&(e="rlflx"),typeof e!="string")throw new Error("keyPrefix must be string");this._keyPrefix=e}_getKeySecDuration(e={}){return e&&e.customDuration>=0?e.customDuration:this.duration}getKey(e){return this.keyPrefix.length>0?`${this.keyPrefix}:${e}`:e}parseKey(e){return this.keyPrefix.length>0?e.substring(this.keyPrefix.length+1):e}consume(){throw new Error("You have to implement the method 'consume'!")}penalty(){throw new Error("You have to implement the method 'penalty'!")}reward(){throw new Error("You have to implement the method 'reward'!")}get(){throw new Error("You have to implement the method 'get'!")}set(){throw new Error("You have to implement the method 'set'!")}block(){throw new Error("You have to implement the method 'block'!")}delete(){throw new Error("You have to implement the method 'delete'!")}}});var ut=F((Ko,lt)=>{"use strict";lt.exports=class{constructor(e,r,n=null){this.value=e,this.expiresAt=r,this.timeoutId=n}get value(){return this._value}set value(e){this._value=parseInt(e,10)}get expiresAt(){return this._expiresAt}set expiresAt(e){e instanceof Date?this._expiresAt=e.getTime():this._expiresAt=e}get timeoutId(){return this._timeoutId}set timeoutId(e){this._timeoutId=e}}});var Re=F((Go,dt)=>{"use strict";dt.exports=class{constructor(e,r,n,o){this.remainingPoints=typeof e>"u"?0:e,this.msBeforeNext=typeof r>"u"?0:r,this.consumedPoints=typeof n>"u"?0:n,this.isFirstInDuration=typeof o>"u"?!1:o}get msBeforeNext(){return this._msBeforeNext}set msBeforeNext(e){return this._msBeforeNext=e,this}get remainingPoints(){return this._remainingPoints}set remainingPoints(e){return this._remainingPoints=e,this}get consumedPoints(){return this._consumedPoints}set consumedPoints(e){return this._consumedPoints=e,this}get isFirstInDuration(){return this._isFirstInDuration}set isFirstInDuration(e){this._isFirstInDuration=!!e}_getDecoratedProperties(){return{remainingPoints:this.remainingPoints,msBeforeNext:this.msBeforeNext,consumedPoints:this.consumedPoints,isFirstInDuration:this.isFirstInDuration}}[Symbol.for("nodejs.util.inspect.custom")](){return this._getDecoratedProperties()}toString(){return JSON.stringify(this._getDecoratedProperties())}toJSON(){return this._getDecoratedProperties()}}});var ft=F((Xo,ht)=>{"use strict";var pt=ut(),Ee=Re();ht.exports=class{constructor(){this._storage=new Map}incrby(e,r,n){let o=this._storage.get(e);if(o){let s=o.expiresAt?o.expiresAt-Date.now():-1;return!o.expiresAt||s>0?(o.value=o.value+r,new Ee(0,s,o.value,!1)):this.set(e,r,n)}return this.set(e,r,n)}set(e,r,n){let o=n*1e3,s=this._storage.get(e);s&&s.timeoutId&&clearTimeout(s.timeoutId);let i=new pt(r,o>0?Date.now()+o:null);return this._storage.set(e,i),o>0&&(i.timeoutId=setTimeout(()=>{this._storage.delete(e)},o),i.timeoutId.unref&&i.timeoutId.unref()),new Ee(0,o===0?-1:o,i.value,!0)}get(e){let r=this._storage.get(e);if(r){let n=r.expiresAt?r.expiresAt-Date.now():-1;return new Ee(0,n,r.value,!1)}return null}delete(e){let r=this._storage.get(e);return r?(r.timeoutId&&clearTimeout(r.timeoutId),this._storage.delete(e),!0):!1}_restoreRecord(e,r,n){let o=Date.now(),s=n!==null;if(s&&!Number.isFinite(n)||s&&n<=o)return;let i=s?n-o:0,a=this._storage.get(e);a&&a.timeoutId&&clearTimeout(a.timeoutId);let c=new pt(r,n);this._storage.set(e,c),i>0&&(c.timeoutId=setTimeout(()=>{this._storage.delete(e)},i),c.timeoutId.unref&&c.timeoutId.unref())}}});var yt=F((Qo,gt)=>{"use strict";var br=ct(),xr=ft(),mt=Re(),_e=class extends br{constructor(e={}){super(e),this._memoryStorage=new xr}consume(e,r=1,n={}){return new Promise((o,s)=>{let i=this.getKey(e),a=this._getKeySecDuration(n),c=this._memoryStorage.incrby(i,r,a);if(c.remainingPoints=Math.max(this.points-c.consumedPoints,0),c.consumedPoints>this.points)this.blockDuration>0&&c.consumedPoints<=this.points+r&&(c=this._memoryStorage.set(i,c.consumedPoints,this.blockDuration)),s(c);else if(this.execEvenly&&this.points>0&&c.msBeforeNext>0&&!c.isFirstInDuration){let l=Math.ceil(c.msBeforeNext/(c.remainingPoints+2));l<this.execEvenlyMinDelayMs&&(l=c.consumedPoints*this.execEvenlyMinDelayMs),c.msBeforeNext=Math.max(c.msBeforeNext-l,0),setTimeout(o,l,c)}else o(c)})}penalty(e,r=1,n={}){let o=this.getKey(e);return new Promise(s=>{let i=this._getKeySecDuration(n),a=this._memoryStorage.incrby(o,r,i);a.remainingPoints=Math.max(this.points-a.consumedPoints,0),s(a)})}reward(e,r=1,n={}){let o=this.getKey(e);return new Promise(s=>{let i=this._getKeySecDuration(n),a=this._memoryStorage.incrby(o,-r,i);a.remainingPoints=Math.max(this.points-a.consumedPoints,0),s(a)})}block(e,r){let n=r*1e3,o=this.points+1;return this._memoryStorage.set(this.getKey(e),o,r),Promise.resolve(new mt(0,n===0?-1:n,o))}set(e,r,n){let o=(n>=0?n:this.duration)*1e3;return this._memoryStorage.set(this.getKey(e),r,n),Promise.resolve(new mt(0,o===0?-1:o,r))}get(e){let r=this._memoryStorage.get(this.getKey(e));return r!==null&&(r.remainingPoints=Math.max(this.points-r.consumedPoints,0)),Promise.resolve(r)}delete(e){return Promise.resolve(this._memoryStorage.delete(this.getKey(e)))}dump(){let e=[];for(let[r,n]of this._memoryStorage._storage)e.push({key:this.parseKey(r),value:n.value,expiresAt:n.expiresAt});return{version:1,dumpedAt:Date.now(),storage:e}}restore(e,r=!1){if(!e||typeof e!="object"||e.version!==1)return;let n=r?{invalid:{count:0,keys:[]},expired:{count:0,keys:[]},restored:{count:0,keys:[]}}:{invalid:0,expired:0,restored:0},o=(s,i)=>{r?(n[s].count+=1,n[s].keys.push(i)):n[s]+=1};if(!Array.isArray(e.storage))return n;for(let s of e.storage){if(!s||typeof s!="object"){o("invalid","N/A");continue}let i=typeof s.key=="string"||typeof s.key=="number",a=Number.isFinite(s.value),c=s.expiresAt===null||Number.isFinite(s.expiresAt);if(!i||!a||!c){o("invalid",s.key);continue}if(s.expiresAt!==null&&s.expiresAt<=Date.now()){o("expired",s.key);continue}this._memoryStorage._restoreRecord(this.getKey(s.key),s.value,s.expiresAt),o("restored",s.key)}return n}};gt.exports=_e});var le=(t,e,r)=>(n,o)=>{let s=-1;return i(0);async function i(a){if(a<=s)throw new Error("next() called multiple times");s=a;let c,l=!1,u;if(t[a]?(u=t[a][0][0],n.req.routeIndex=a):u=a===t.length&&o||void 0,u)try{c=await u(n,()=>i(a+1))}catch(p){if(p instanceof Error&&e)n.error=p,c=await e(p,n),l=!0;else throw p}else n.finalized===!1&&r&&(c=await r(n));return c&&(n.finalized===!1||l)&&(n.res=c),n}};var De=Symbol();var je=(t,e)=>new Response(t,{headers:{"Content-Type":e.replace(/^[^;]+/,n=>n.toLowerCase())}}).formData();var Y=t=>"headers"in t,Ne=async(t,e=Object.create(null))=>{let{all:r=!1,dot:n=!1}=e,i=(Y(t)?t.headers:t.raw.headers).get("Content-Type")?.split(";")[0].trim().toLowerCase();return i==="multipart/form-data"||i==="application/x-www-form-urlencoded"?or(t,{all:r,dot:n}):{}};async function or(t,e){if(!Y(t)&&t.bodyCache.formData)return Ue(await t.bodyCache.formData,e);let r=Y(t)?t.headers:t.raw.headers,n=await t.arrayBuffer(),o=je(n,r.get("Content-Type")||"");Y(t)||(t.bodyCache.formData=o);let s=await o;return s?Ue(s,e):{}}function Ue(t,e){let r=Object.create(null);return t.forEach((n,o)=>{e.all||o.endsWith("[]")?sr(r,o,n):r[o]=n}),e.dot&&Object.entries(r).forEach(([n,o])=>{n.includes(".")&&(ir(r,n,o),delete r[n])}),r}var sr=(t,e,r)=>{t[e]!==void 0?Array.isArray(t[e])?t[e].push(r):t[e]=[t[e],r]:e.endsWith("[]")?t[e]=[r]:t[e]=r},ir=(t,e,r)=>{if(/(?:^|\.)__proto__\./.test(e))return;let n=t,o=e.split(".");o.forEach((s,i)=>{i===o.length-1?n[s]=r:((!n[s]||typeof n[s]!="object"||Array.isArray(n[s])||n[s]instanceof File)&&(n[s]=Object.create(null)),n=n[s])})};var de=t=>{let e=t.split("/");return e[0]===""&&e.shift(),e},He=t=>{let{groups:e,path:r}=ar(t),n=de(r);return cr(n,e)},ar=t=>{let e=[];return t=t.replace(/\{[^}]+\}/g,(r,n)=>{let o=`@${n}`;return e.push([o,r]),o}),{groups:e,path:t}},cr=(t,e)=>{for(let r=e.length-1;r>=0;r--){let[n]=e[r];for(let o=t.length-1;o>=0;o--)if(t[o].includes(n)){t[o]=t[o].replace(n,e[r][1]);break}}return t},X={},$e=(t,e)=>{if(t==="*")return"*";let r=t.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);if(r){let n=`${t}#${e}`;return X[n]||(r[2]?X[n]=e&&e[0]!==":"&&e[0]!=="*"?[n,r[1],new RegExp(`^${r[2]}(?=/${e})`)]:[t,r[1],new RegExp(`^${r[2]}$`)]:X[n]=[t,r[1],!0]),X[n]}return null},Q=(t,e)=>{try{return e(t)}catch{return t.replace(/(?:%[0-9A-Fa-f]{2})+/g,r=>{try{return e(r)}catch{return r}})}},lr=t=>Q(t,decodeURI),pe=t=>{let e=t.url,r=e.indexOf("/",e.indexOf(":")+4),n=r;for(;n<e.length;n++){let o=e.charCodeAt(n);if(o===37){let s=e.indexOf("?",n),i=e.indexOf("#",n),a=s===-1?i===-1?void 0:i:i===-1?s:Math.min(s,i),c=e.slice(r,a);return lr(c.includes("%25")?c.replace(/%25/g,"%2525"):c)}else if(o===63||o===35)break}return e.slice(r,n)};var Be=t=>{let e=pe(t);return e.length>1&&e.at(-1)==="/"?e.slice(0,-1):e},k=(t,e,...r)=>(r.length&&(e=k(e,...r)),`${t?.[0]==="/"?"":"/"}${t}${e==="/"?"":`${t?.at(-1)==="/"?"":"/"}${e?.[0]==="/"?e.slice(1):e}`}`),Z=t=>{if(t.charCodeAt(t.length-1)!==63||!t.includes(":"))return null;let e=t.split("/"),r=[],n="";return e.forEach(o=>{if(o!==""&&!/\:/.test(o))n+="/"+o;else if(/\:/.test(o))if(/\?/.test(o)){r.length===0&&n===""?r.push("/"):r.push(n);let s=o.replace("?","");n+="/"+s,r.push(n)}else n+="/"+o}),r.filter((o,s,i)=>i.indexOf(o)===s)},ue=t=>/[%+]/.test(t)?(t.indexOf("+")!==-1&&(t=t.replace(/\+/g," ")),t.indexOf("%")!==-1?Q(t,he):t):t,qe=(t,e,r)=>{let n;if(!r&&e&&!/[%+]/.test(e)){let i=t.indexOf("?",8);if(i===-1)return;for(t.startsWith(e,i+1)||(i=t.indexOf(`&${e}`,i+1));i!==-1;){let a=t.charCodeAt(i+e.length+1);if(a===61){let c=i+e.length+2,l=t.indexOf("&",c);return ue(t.slice(c,l===-1?void 0:l))}else if(a==38||isNaN(a))return"";i=t.indexOf(`&${e}`,i+1)}if(n=/[%+]/.test(t),!n)return}let o=Object.create(null);n??=/[%+]/.test(t);let s=t.indexOf("?",8);for(;s!==-1;){let i=t.indexOf("&",s+1),a=t.indexOf("=",s);a>i&&i!==-1&&(a=-1);let c=t.slice(s+1,a===-1?i===-1?void 0:i:a);if(n&&(c=ue(c)),s=i,c==="")continue;let l;a===-1?l="":(l=t.slice(a+1,i===-1?void 0:i),n&&(l=ue(l))),r?(o[c]&&Array.isArray(o[c])||(o[c]=[]),o[c].push(l)):o[c]??=l}return e?o[e]:o},ze=qe,Fe=(t,e)=>qe(t,e,!0),he=decodeURIComponent;var We=t=>Q(t,he),Ve=class{raw;#t;#e;routeIndex=0;path;bodyCache={};constructor(t,e="/",r=[[]]){this.raw=t,this.path=e,this.#e=r,this.#t={}}param(t){return t?this.#r(t):this.#s()}#r(t){let e=this.#e[0][this.routeIndex][1][t],r=this.#o(e);return r&&/\%/.test(r)?We(r):r}#s(){let t={},e=Object.keys(this.#e[0][this.routeIndex][1]);for(let r of e){let n=this.#o(this.#e[0][this.routeIndex][1][r]);n!==void 0&&(t[r]=/\%/.test(n)?We(n):n)}return t}#o(t){return this.#e[1]?this.#e[1][t]:t}query(t){return ze(this.url,t)}queries(t){return Fe(this.url,t)}header(t){if(t)return this.raw.headers.get(t)??void 0;let e=Object.create(null);return this.raw.headers.forEach((r,n)=>{e[n]=r}),e}async parseBody(t){return Ne(this,t)}#n=t=>{let{bodyCache:e,raw:r}=this,n=e[t];if(n)return n;let o=Object.keys(e)[0];return o?e[o].then(s=>(o==="json"&&(s=JSON.stringify(s)),new Response(s)[t]())):e[t]=r[t]()};json(){return this.#n("text").then(t=>JSON.parse(t))}text(){return this.#n("text")}arrayBuffer(){return this.#n("arrayBuffer")}bytes(){return this.#n("arrayBuffer").then(t=>new Uint8Array(t))}blob(){return this.#n("blob")}formData(){return this.#n("formData")}addValidatedData(t,e){this.#t[t]=e}valid(t){return this.#t[t]}get url(){return this.raw.url}get method(){return this.raw.method}get[De](){return this.#e}get matchedRoutes(){return this.#e[0].map(([[,t]])=>t)}get routePath(){return this.#e[0].map(([[,t]])=>t)[this.routeIndex].path}};var Ke={Stringify:1,BeforeStream:2,Stream:3},ur=(t,e)=>{let r=new String(t);return r.isEscaped=!0,r.callbacks=e,r};var fe=async(t,e,r,n,o)=>{typeof t=="object"&&!(t instanceof String)&&(t instanceof Promise||(t=t.toString()),t instanceof Promise&&(t=await t));let s=t.callbacks;if(!s?.length)return Promise.resolve(t);o?o[0]+=t:o=[t];let i=Promise.all(s.map(a=>a({phase:e,buffer:o,context:n}))).then(a=>Promise.all(a.filter(Boolean).map(c=>fe(c,e,!1,n,o))).then(()=>o[0]));return r?ur(await i,s):i};var dr="text/plain; charset=UTF-8",me=(t,e)=>({"Content-Type":t,...e}),W=(t,e)=>new Response(t,e),ge=class{#t;#e;env={};#r;finalized=!1;error;#s;#o;#n;#u;#c;#l;#a;#d;#p;constructor(t,e){this.#t=t,e&&(this.#o=e.executionCtx,this.env=e.env,this.#l=e.notFoundHandler,this.#p=e.path,this.#d=e.matchResult)}get req(){return this.#e??=new Ve(this.#t,this.#p,this.#d),this.#e}get event(){if(this.#o&&"respondWith"in this.#o)return this.#o;throw Error("This context has no FetchEvent")}get executionCtx(){if(this.#o)return this.#o;throw Error("This context has no ExecutionContext")}get res(){return this.#n||=W(null,{headers:this.#a??=new Headers})}set res(t){if(this.#n&&t){t=W(t.body,t);for(let[e,r]of this.#n.headers.entries())if(e!=="content-type")if(e==="set-cookie"){let n=this.#n.headers.getSetCookie();t.headers.delete("set-cookie");for(let o of n)t.headers.append("set-cookie",o)}else t.headers.set(e,r)}this.#n=t,this.finalized=!0}render=(...t)=>(this.#c??=e=>this.html(e),this.#c(...t));setLayout=t=>this.#u=t;getLayout=()=>this.#u;setRenderer=t=>{this.#c=t};header=(t,e,r)=>{this.finalized&&(this.#n=W(this.#n.body,this.#n));let n=this.#n?this.#n.headers:this.#a??=new Headers;e===void 0?n.delete(t):r?.append?n.append(t,e):n.set(t,e)};status=t=>{this.#s=t};set=(t,e)=>{this.#r??=new Map,this.#r.set(t,e)};get=t=>this.#r?this.#r.get(t):void 0;get var(){return this.#r?Object.fromEntries(this.#r):{}}#i(t,e,r){let n=this.#n?new Headers(this.#n.headers):this.#a??new Headers;if(typeof e=="object"&&"headers"in e){let s=e.headers instanceof Headers?e.headers:new Headers(e.headers);for(let[i,a]of s)i.toLowerCase()==="set-cookie"?n.append(i,a):n.set(i,a)}if(r)for(let[s,i]of Object.entries(r))if(typeof i=="string")n.set(s,i);else{n.delete(s);for(let a of i)n.append(s,a)}let o=typeof e=="number"?e:e?.status??this.#s;return W(t,{status:o,headers:n})}newResponse=(...t)=>this.#i(...t);body=(t,e,r)=>this.#i(t,e,r);text=(t,e,r)=>!this.#a&&!this.#s&&!e&&!r&&!this.finalized?new Response(t):this.#i(t,e,me(dr,r));json=(t,e,r)=>this.#i(JSON.stringify(t),e,me("application/json",r));html=(t,e,r)=>{let n=o=>this.#i(o,e,me("text/html; charset=UTF-8",r));return typeof t=="object"?fe(t,Ke.Stringify,!1,{}).then(n):n(t)};redirect=(t,e)=>{let r=String(t);return this.header("Location",/[^\x00-\xFF]/.test(r)?encodeURI(r):r),this.newResponse(null,e??302)};notFound=()=>(this.#l??=()=>W(),this.#l(this))};var v="ALL",Je="all",Ge=["get","post","put","delete","options","patch"],ee="Can not add a route since the matcher is already built.",te=class extends Error{};var Ye="__COMPOSED_HANDLER";var pr=t=>t.text("404 Not Found",404),Xe=(t,e)=>{if("getResponse"in t){let r=t.getResponse();return e.newResponse(r.body,r)}return console.error(t),e.text("Internal Server Error",500)},Qe=class Ze{get;post;put;delete;options;patch;all;on;use;router;getPath;_basePath="/";#t="/";routes=[];constructor(e={}){[...Ge,Je].forEach(s=>{this[s]=(i,...a)=>(typeof i=="string"?this.#t=i:this.#s(s,this.#t,i),a.forEach(c=>{this.#s(s,this.#t,c)}),this)}),this.on=(s,i,...a)=>{for(let c of[i].flat()){this.#t=c;for(let l of[s].flat())a.map(u=>{this.#s(l.toUpperCase(),this.#t,u)})}return this},this.use=(s,...i)=>(typeof s=="string"?this.#t=s:(this.#t="*",i.unshift(s)),i.forEach(a=>{this.#s(v,this.#t,a)}),this);let{strict:n,...o}=e;Object.assign(this,o),this.getPath=n??!0?e.getPath??pe:Be}#e(){let e=new Ze({router:this.router,getPath:this.getPath});return e.errorHandler=this.errorHandler,e.#r=this.#r,e.routes=this.routes,e}#r=pr;errorHandler=Xe;route(e,r){let n=this.basePath(e);return r.routes.map(o=>{let s;r.errorHandler===Xe?s=o.handler:(s=async(i,a)=>(await le([],r.errorHandler)(i,()=>o.handler(i,a))).res,s[Ye]=o.handler),n.#s(o.method,o.path,s,o.basePath)}),this}basePath(e){let r=this.#e();return r._basePath=k(this._basePath,e),r}onError=e=>(this.errorHandler=e,this);notFound=e=>(this.#r=e,this);mount(e,r,n){let o,s;n&&(typeof n=="function"?s=n:(s=n.optionHandler,n.replaceRequest===!1?o=c=>c:o=n.replaceRequest));let i=s?c=>{let l=s(c);return Array.isArray(l)?l:[l]}:c=>{let l;try{l=c.executionCtx}catch{}return[c.env,l]};o||=(()=>{let c=k(this._basePath,e),l=c==="/"?0:c.length;return u=>{let p=new URL(u.url);return p.pathname=this.getPath(u).slice(l)||"/",new Request(p,u)}})();let a=async(c,l)=>{let u=await r(o(c.req.raw),...i(c));if(u)return u;await l()};return this.#s(v,k(e,"*"),a),this}#s(e,r,n,o){e=e.toUpperCase(),r=k(this._basePath,r);let s={basePath:o!==void 0?k(this._basePath,o):this._basePath,path:r,method:e,handler:n};this.router.add(e,r,[n,s]),this.routes.push(s)}#o(e,r){if(e instanceof Error)return this.errorHandler(e,r);throw e}#n(e,r,n,o){if(o==="HEAD")return(async()=>new Response(null,await this.#n(e,r,n,"GET")))();let s=this.getPath(e,{env:n}),i=this.router.match(o,s),a=new ge(e,{path:s,matchResult:i,env:n,executionCtx:r,notFoundHandler:this.#r});if(i[0].length===1){let l;try{l=i[0][0][0][0](a,async()=>{a.res=await this.#r(a)})}catch(u){return this.#o(u,a)}return l instanceof Promise?l.then(u=>u||(a.finalized?a.res:this.#r(a))).catch(u=>this.#o(u,a)):l??this.#r(a)}let c=le(i[0],this.errorHandler,this.#r);return(async()=>{try{let l=await c(a);if(!l.finalized)throw new Error("Context is not finalized. Did you forget to return a Response object or `await next()`?");return l.res}catch(l){return this.#o(l,a)}})()}fetch=(e,...r)=>this.#n(e,r[1],r[0],e.method);request=(e,r,n,o)=>e instanceof Request?this.fetch(r?new Request(e,r):e,n,o):(e=e.toString(),this.fetch(new Request(/^https?:\/\//.test(e)?e:`http://localhost${k("/",e)}`,r),n,o));fire=()=>{addEventListener("fetch",e=>{e.respondWith(this.#n(e.request,e,void 0,e.request.method))})}};var re=[];function ye(t,e){let r=this.buildAllMatchers(),n=((o,s)=>{let i=r[o]||r[v],a=i[2][s];if(a)return a;let c=s.match(i[0]);if(!c)return[[],re];let l=c.indexOf("",1);return[i[1][l],c]});return this.match=n,n(t,e)}var ne="[^/]+",V=".*",K="(?:|/.*)",H=Symbol(),hr=new Set(".\\+*[^]$()");function fr(t,e){return t.length===1?e.length===1?t<e?-1:1:-1:e.length===1||t===V||t===K?1:e===V||e===K?-1:t===ne?1:e===ne?-1:t.length===e.length?t<e?-1:1:e.length-t.length}var et=class we{#t;#e;#r=Object.create(null);insert(e,r,n,o,s){if(e.length===0){if(this.#t!==void 0)throw H;if(s)return;this.#t=r;return}let[i,...a]=e,c=i==="*"?a.length===0?["","",V]:["","",ne]:i==="/*"?["","",K]:i.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/),l;if(c){let u=c[1],p=c[2]||ne;if(u&&c[2]&&(p===".*"||(p=p.replace(/^\((?!\?:)(?=[^)]+\)$)/,"(?:"),/\((?!\?:)/.test(p))))throw H;if(l=this.#r[p],!l){if(Object.keys(this.#r).some(h=>h!==V&&h!==K))throw H;if(s)return;l=this.#r[p]=new we,u!==""&&(l.#e=o.varIndex++)}!s&&u!==""&&n.push([u,l.#e])}else if(l=this.#r[i],!l){if(Object.keys(this.#r).some(u=>u.length>1&&u!==V&&u!==K))throw H;if(s)return;l=this.#r[i]=new we}l.insert(a,r,n,o,s)}buildRegExpStr(){let r=Object.keys(this.#r).sort(fr).map(n=>{let o=this.#r[n];return(typeof o.#e=="number"?`(${n})@${o.#e}`:hr.has(n)?`\\${n}`:n)+o.buildRegExpStr()});return typeof this.#t=="number"&&r.unshift(`#${this.#t}`),r.length===0?"":r.length===1?r[0]:"(?:"+r.join("|")+")"}};var tt=class{#t={varIndex:0};#e=new et;insert(t,e,r){let n=[],o=[];for(let i=0;;){let a=!1;if(t=t.replace(/\{[^}]+\}/g,c=>{let l=`@\\${i}`;return o[i]=[l,c],i++,a=!0,l}),!a)break}let s=t.match(/(?::[^\/]+)|(?:\/\*$)|./g)||[];for(let i=o.length-1;i>=0;i--){let[a]=o[i];for(let c=s.length-1;c>=0;c--)if(s[c].indexOf(a)!==-1){s[c]=s[c].replace(a,o[i][1]);break}}return this.#e.insert(s,e,n,this.#t,r),n}buildRegExp(){let t=this.#e.buildRegExpStr();if(t==="")return[/^$/,[],[]];let e=0,r=[],n=[];return t=t.replace(/#(\d+)|@(\d+)|\.\*\$/g,(o,s,i)=>s!==void 0?(r[++e]=Number(s),"$()"):(i!==void 0&&(n[Number(i)]=++e),"")),[new RegExp(`^${t}`),r,n]}};var mr=[/^$/,[],Object.create(null)],rt=Object.create(null);function nt(t){return rt[t]??=new RegExp(t==="*"?"":`^${t.replace(/\/\*$|([.\\+*[^\]$()])/g,(e,r)=>r?`\\${r}`:"(?:|/.*)")}$`)}function gr(){rt=Object.create(null)}function yr(t){let e=new tt,r=[];if(t.length===0)return mr;let n=t.map(l=>[!/\*|\/:/.test(l[0]),...l]).sort(([l,u],[p,h])=>l?1:p?-1:u.length-h.length),o=Object.create(null);for(let l=0,u=-1,p=n.length;l<p;l++){let[h,f,w]=n[l];h?o[f]=[w.map(([g])=>[g,Object.create(null)]),re]:u++;let b;try{b=e.insert(f,u,h)}catch(g){throw g===H?new te(f):g}h||(r[u]=w.map(([g,d])=>{let m=Object.create(null);for(d-=1;d>=0;d--){let[x,O]=b[d];m[x]=O}return[g,m]}))}let[s,i,a]=e.buildRegExp();for(let l=0,u=r.length;l<u;l++)for(let p=0,h=r[l].length;p<h;p++){let f=r[l][p]?.[1];if(!f)continue;let w=Object.keys(f);for(let b=0,g=w.length;b<g;b++)f[w[b]]=a[f[w[b]]]}let c=[];for(let l in i)c[l]=r[i[l]];return[s,c,o]}function q(t,e){if(t){for(let r of Object.keys(t).sort((n,o)=>o.length-n.length))if(nt(r).test(e))return[...t[r]]}}var oe=class{name="RegExpRouter";#t;#e;constructor(){this.#t={[v]:Object.create(null)},this.#e={[v]:Object.create(null)}}add(t,e,r){let n=this.#t,o=this.#e;if(!n||!o)throw new Error(ee);n[t]||[n,o].forEach(a=>{a[t]=Object.create(null),Object.keys(a[v]).forEach(c=>{a[t][c]=[...a[v][c]]})}),e==="/*"&&(e="*");let s=(e.match(/\/:/g)||[]).length;if(/\*$/.test(e)){let a=nt(e);t===v?Object.keys(n).forEach(c=>{n[c][e]||=q(n[c],e)||q(n[v],e)||[]}):n[t][e]||=q(n[t],e)||q(n[v],e)||[],Object.keys(n).forEach(c=>{(t===v||t===c)&&Object.keys(n[c]).forEach(l=>{a.test(l)&&n[c][l].push([r,s])})}),Object.keys(o).forEach(c=>{(t===v||t===c)&&Object.keys(o[c]).forEach(l=>a.test(l)&&o[c][l].push([r,s]))});return}let i=Z(e)||[e];for(let a=0,c=i.length;a<c;a++){let l=i[a];Object.keys(o).forEach(u=>{(t===v||t===u)&&(o[u][l]||=[...q(n[u],l)||q(n[v],l)||[]],o[u][l].push([r,s-c+a+1]))})}}match=ye;buildAllMatchers(){let t=Object.create(null);return Object.keys(this.#e).concat(Object.keys(this.#t)).forEach(e=>{t[e]||=this.#r(e)}),this.#t=this.#e=void 0,gr(),t}#r(t){let e=[],r=t===v;return[this.#t,this.#e].forEach(n=>{let o=n[t]?Object.keys(n[t]).map(s=>[s,n[t][s]]):[];o.length!==0?(r||=!0,e.push(...o)):t!==v&&e.push(...Object.keys(n[v]).map(s=>[s,n[v][s]]))}),r?yr(e):null}};var be=class{name="SmartRouter";#t=[];#e=[];constructor(t){this.#t=t.routers}add(t,e,r){if(!this.#e)throw new Error(ee);this.#e.push([t,e,r])}match(t,e){if(!this.#e)throw new Error("Fatal error");let r=this.#t,n=this.#e,o=r.length,s=0,i;for(;s<o;s++){let a=r[s];try{for(let c=0,l=n.length;c<l;c++)a.add(...n[c]);i=a.match(t,e)}catch(c){if(c instanceof te)continue;throw c}this.match=a.match.bind(a),this.#t=[a],this.#e=void 0;break}if(s===o)throw new Error("Fatal error");return this.name=`SmartRouter + ${this.activeRouter.name}`,i}get activeRouter(){if(this.#e||this.#t.length!==1)throw new Error("No active router has been determined yet.");return this.#t[0]}};var J=Object.create(null),wr=t=>{for(let e in t)return!0;return!1},ot=class st{#t;#e;#r;#s=0;#o=J;constructor(e,r,n){if(this.#e=n||Object.create(null),this.#t=[],e&&r){let o=Object.create(null);o[e]={handler:r,possibleKeys:[],score:0},this.#t=[o]}this.#r=[]}insert(e,r,n){this.#s=++this.#s;let o=this,s=He(r),i=[];for(let a=0,c=s.length;a<c;a++){let l=s[a],u=s[a+1],p=$e(l,u),h=Array.isArray(p)?p[0]:l;if(h in o.#e){o=o.#e[h],p&&i.push(p[1]);continue}o.#e[h]=new st,p&&(o.#r.push(p),i.push(p[1])),o=o.#e[h]}return o.#t.push({[e]:{handler:n,possibleKeys:i.filter((a,c,l)=>l.indexOf(a)===c),score:this.#s}}),o}#n(e,r,n,o,s){for(let i=0,a=r.#t.length;i<a;i++){let c=r.#t[i],l=c[n]||c[v],u={};if(l!==void 0&&(l.params=Object.create(null),e.push(l),o!==J||s&&s!==J))for(let p=0,h=l.possibleKeys.length;p<h;p++){let f=l.possibleKeys[p],w=u[l.score];l.params[f]=s?.[f]&&!w?s[f]:o[f]??s?.[f],u[l.score]=!0}}}search(e,r){let n=[];this.#o=J;let s=[this],i=de(r),a=[],c=i.length,l=null;for(let u=0;u<c;u++){let p=i[u],h=u===c-1,f=[];for(let b=0,g=s.length;b<g;b++){let d=s[b],m=d.#e[p];m&&(m.#o=d.#o,h?(m.#e["*"]&&this.#n(n,m.#e["*"],e,d.#o),this.#n(n,m,e,d.#o)):f.push(m));for(let x=0,O=d.#r.length;x<O;x++){let L=d.#r[x],E=d.#o===J?{}:{...d.#o};if(L==="*"){let _=d.#e["*"];_&&(this.#n(n,_,e,d.#o),_.#o=E,f.push(_));continue}let[P,S,R]=L;if(!p&&!(R instanceof RegExp))continue;let y=d.#e[P];if(R instanceof RegExp){if(l===null){l=new Array(c);let j=r[0]==="/"?1:0;for(let U=0;U<c;U++)l[U]=j,j+=i[U].length+1}let _=r.substring(l[u]),C=R.exec(_);if(C){if(E[S]=C[0],this.#n(n,y,e,d.#o,E),C[0].length===_.length&&y.#e["*"]&&this.#n(n,y.#e["*"],e,d.#o,E),wr(y.#e)){y.#o=E;let j=C[0].match(/\//)?.length??0;(a[j]||=[]).push(y)}continue}}(R===!0||R.test(p))&&(E[S]=p,h?(this.#n(n,y,e,E,d.#o),y.#e["*"]&&this.#n(n,y.#e["*"],e,E,d.#o)):(y.#o=E,f.push(y)))}}let w=a.shift();s=w?f.concat(w):f}return n.length>1&&n.sort((u,p)=>u.score-p.score),[n.map(({handler:u,params:p})=>[u,p])]}};var xe=class{name="TrieRouter";#t;constructor(){this.#t=new ot}add(t,e,r){let n=Z(e);if(n){for(let o=0,s=n.length;o<s;o++)this.#t.insert(t,n[o],r);return}this.#t.insert(t,e,r)}match(t,e){return this.#t.search(t,e)}};var ve=class extends Qe{constructor(t={}){super(t),this.router=t.router??new be({routers:[new oe,new xe]})}};import{Readable as un}from"stream";function it(t=""){return`<link rel="icon" type="image/svg+xml" href="${`${t.replace(/\/$/,"")}/favicon-black.svg?v=4`}" />`}import{existsSync as wt,readFileSync as Er}from"fs";import I from"path";import{fileURLToPath as _r}from"url";import{gunzipSync as Pr}from"zlib";var M=nr(yt(),1);function z(t,e){return t.header("Retry-After",String(vr(e))),t.json({error:"Too Many Requests"},429)}function vr(t){return t&&typeof t=="object"&&"msBeforeNext"in t&&typeof t.msBeforeNext=="number"&&Number.isFinite(t.msBeforeNext)?Math.max(1,Math.ceil(t.msBeforeNext/1e3)):60}var Sr={".js":"application/javascript",".css":"text/css",".svg":"image/svg+xml",".png":"image/png",".ico":"image/x-icon",".webmanifest":"application/manifest+json"};function Ar(){let t=I.dirname(_r(import.meta.url));for(let e of[I.resolve(t,"app"),I.resolve(t,"../app"),I.resolve(t,"../../dist/app")])if(wt(I.join(e,"inspector.js.gz")))return e;throw new Error("Inspector bundle not found (expected dist/app/inspector.js.gz)")}function bt(t,e="/inspector/assets"){let r=Ar(),n=new Map,o=new M.default({points:600,duration:60}),s=async(i,a)=>{try{await o.consume(i.req)}catch(c){return z(i,c)}return a()};t.use(`${e}/*`,s),t.get(`${e}/*`,async i=>{let a=i.req.path.slice(e.length),c=a.startsWith("/")?a.slice(1):a;if(!c||c.includes(".."))return i.notFound();let l=c==="inspector.js"||c==="inspector.css"?`${c}.gz`:c,u=I.resolve(r,l),p=r.endsWith(I.sep)?r:`${r}${I.sep}`;if(!u.startsWith(p)||!wt(u))return i.notFound();let h=I.extname(c),f=l.endsWith(".gz"),w=/(?:^|,)\s*gzip\s*(?:,|$)/i.test(i.req.header("accept-encoding")??""),b=Er(u),g=f&&!w?n.get(u)??Cr(n,u,b):b,d=g.buffer.slice(g.byteOffset,g.byteOffset+g.byteLength);return i.body(d,200,{"Content-Type":Sr[h]??"application/octet-stream",...f&&w?{"Content-Encoding":"gzip"}:{},...f?{Vary:"Accept-Encoding"}:{},"Cache-Control":"no-cache"})})}function Cr(t,e,r){let n=Pr(r);return t.set(e,n),n}var xt={name:"@mcp-use/inspector",type:"module",version:"20.0.5-canary.0",description:"MCP Inspector - A tool for inspecting and debugging MCP servers",author:"",license:"MIT",homepage:"https://github.com/mcp-use/mcp-use#readme",repository:{type:"git",url:"git+https://github.com/mcp-use/mcp-use.git",directory:"libraries/typescript/packages/inspector"},bugs:{url:"https://github.com/mcp-use/mcp-use/issues"},keywords:["mcp","inspector","debug","tools"],exports:{".":{types:"./dist/server/index.d.ts",import:"./dist/server/index.js"},"./client":{types:"./dist/client/index.d.ts",import:"./dist/client/index.js"}},main:"./dist/server/index.js",types:"./dist/server/index.d.ts",bin:{"mcp-inspect":"./dist/cli.js"},files:["dist"],scripts:{dev:"rimraf node_modules/.vite && vite --strictPort","dev:client":"pnpm run dev","dev:server":"VITE_DEV=true tsx watch src/server/server.ts","dev:standalone":"tsx watch src/server/server.ts",clean:"rimraf dist",build:"npm run clean && npm run build:client-exports && npm run build:server && npm run build:app && npm run verify:package","build:app":"vite build --config vite.app.config.ts && node scripts/compress-app.mjs","watch:app":"vite build --watch --config vite.app.config.ts","preview:app":"vite preview --config vite.app.config.ts --host 127.0.0.1","serve:app":"pnpm build:app && pnpm preview:app","analyze:app":"ANALYZE=true vite build --config vite.app.config.ts","build:client-exports":"tsup --config tsup.client.ts","build:server":"tsup --config tsup.server.ts","verify:package":"node scripts/verify-package.mjs",prepublishOnly:"pnpm --filter @mcp-use/client build && pnpm build",start:"node dist/cli.js --port 3000",preview:"vite preview","type-check":"tsc --noEmit",lint:"eslint .","lint:fix":"eslint . --fix","test:e2e":"playwright test","test:e2e:ui":"playwright test --ui","test:e2e:debug":"playwright test --debug","test:e2e:builtin":"node tests/e2e/scripts/run-test-matrix.mjs builtin","test:e2e:prod":"node tests/e2e/scripts/run-test-matrix.mjs prod","test:e2e:mix":"node tests/e2e/scripts/run-test-matrix.mjs mix","test:e2e:prod:ui":"TEST_MODE=production playwright test --ui","test:e2e:codegen":"playwright codegen http://localhost:3000/inspector","test:e2e:report":"playwright show-report","test:e2e:python":"node tests/e2e/scripts/run-python-e2e.mjs","test:unit":"vitest run","test:unit:watch":"vitest","test:e2e:tunnel":"node tests/e2e/scripts/run-tunnel-test.mjs","install:pnpm":"pnpm install","install:npm":"npm install","lint:npm":"npm run lint:fix","lint:pnpm":"pnpm lint:fix"},engines:{node:">=22.22.2"},peerDependencies:{"@base-ui/react":"^1.6.0","@mcp-use/agent":"^2.0.2-canary.0","@mcp-use/client":"^2.0.2-canary.0","class-variance-authority":"^0.7.1",clsx:"^2.1.1",express:"^4.21.2 || ^5.0.0","lucide-react":"^0.562.0","markdown-to-jsx":"^9.7.4","mcp-use":"workspace:*",motion:"^12.34.2",react:"^18.0.0 || ^19.0.0","react-dom":"^18.0.0 || ^19.0.0","react-resizable-panels":"^4.6.4",sonner:"^2.0.7","tailwind-merge":"^3.5.0"},peerDependenciesMeta:{"@base-ui/react":{optional:!0},"@mcp-use/agent":{optional:!0},"@mcp-use/client":{optional:!0},"class-variance-authority":{optional:!0},clsx:{optional:!0},express:{optional:!0},"lucide-react":{optional:!0},"markdown-to-jsx":{optional:!0},"mcp-use":{optional:!0},motion:{optional:!0},react:{optional:!0},"react-dom":{optional:!0},"react-resizable-panels":{optional:!0},sonner:{optional:!0},"tailwind-merge":{optional:!0}},dependencies:{},publishConfig:{access:"public"},devDependencies:{"@base-ui/react":"^1.6.0","@hono/node-server":"^2.0.5","@mcp-use/agent":"workspace:*","@mcp-use/client":"workspace:*","@playwright/test":"^1.58.2","@tailwindcss/vite":"^4.2.0","@types/express":"^5.0.6","@vitejs/plugin-react":"^6.0.0","class-variance-authority":"^0.7.1",clsx:"^2.1.1",emulate:"0.5.0",eslint:"^9.39.2",express:"^5.2.1",hono:"^4.12.34","lucide-react":"^0.562.0","markdown-to-jsx":"^9.7.4",motion:"^12.34.2","oauth2-mock-server":"^8.2.2",open:"^11.0.0",react:"^19.2.3","react-dom":"^19.2.3","react-router":"^8.3.0","react-resizable-panels":"^4.6.4","rate-limiter-flexible":"^11.2.0","rollup-plugin-visualizer":"^6.0.3",sonner:"^2.0.7","tailwind-merge":"^3.5.0",tailwindcss:"^4.2.0",tsup:"^8.5.1",tsx:"^4.21.0","tw-animate-css":"^1.4.0",typescript:"^5.9.3",vite:"^8.0.16",vitest:"^4.1.0","wait-on":"^9.0.4",zod:"^4.2.0"}};var Lr=xt.version;function vt(){return Lr}var Tr=`<!doctype html>
1
+ var Xt=Object.create;var ke=Object.defineProperty;var Qt=Object.getOwnPropertyDescriptor;var Zt=Object.getOwnPropertyNames;var er=Object.getPrototypeOf,tr=Object.prototype.hasOwnProperty;var F=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var rr=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Zt(e))!tr.call(t,o)&&o!==r&&ke(t,o,{get:()=>e[o],enumerable:!(n=Qt(e,o))||n.enumerable});return t};var nr=(t,e,r)=>(r=t!=null?Xt(er(t)):{},rr(e||!t||!t.__esModule?ke(r,"default",{value:t,enumerable:!0}):r,t));var ct=F((Wo,at)=>{"use strict";at.exports=class{constructor(e={}){this.points=e.points,this.duration=e.duration,this.blockDuration=e.blockDuration,this.execEvenly=e.execEvenly,this.execEvenlyMinDelayMs=e.execEvenlyMinDelayMs,this.keyPrefix=e.keyPrefix}get points(){return this._points}set points(e){if(Number.isFinite(e))this._points=e;else throw new Error("points must be set and must be a finite number")}get duration(){return this._duration}set duration(e){if(typeof e=="number"&&Number.isFinite(e)&&e>=0)this._duration=e;else throw new Error("duration must be set and must be a finite, non-negative number")}get msDuration(){return this.duration*1e3}get blockDuration(){return this._blockDuration}set blockDuration(e){this._blockDuration=typeof e>"u"?0:e}get msBlockDuration(){return this.blockDuration*1e3}get execEvenly(){return this._execEvenly}set execEvenly(e){this._execEvenly=typeof e>"u"?!1:!!e}get execEvenlyMinDelayMs(){return this._execEvenlyMinDelayMs===void 0?this._getExecEvenlyMinDelayMsDefault():this._execEvenlyMinDelayMs}set execEvenlyMinDelayMs(e){this._execEvenlyMinDelayMs=e}_getExecEvenlyMinDelayMsDefault(){return this.points>0?Math.ceil(this.msDuration/this.points):0}get keyPrefix(){return this._keyPrefix}set keyPrefix(e){if(typeof e>"u"&&(e="rlflx"),typeof e!="string")throw new Error("keyPrefix must be string");this._keyPrefix=e}_getKeySecDuration(e={}){return e&&e.customDuration>=0?e.customDuration:this.duration}getKey(e){return this.keyPrefix.length>0?`${this.keyPrefix}:${e}`:e}parseKey(e){return this.keyPrefix.length>0?e.substring(this.keyPrefix.length+1):e}consume(){throw new Error("You have to implement the method 'consume'!")}penalty(){throw new Error("You have to implement the method 'penalty'!")}reward(){throw new Error("You have to implement the method 'reward'!")}get(){throw new Error("You have to implement the method 'get'!")}set(){throw new Error("You have to implement the method 'set'!")}block(){throw new Error("You have to implement the method 'block'!")}delete(){throw new Error("You have to implement the method 'delete'!")}}});var ut=F((Ko,lt)=>{"use strict";lt.exports=class{constructor(e,r,n=null){this.value=e,this.expiresAt=r,this.timeoutId=n}get value(){return this._value}set value(e){this._value=parseInt(e,10)}get expiresAt(){return this._expiresAt}set expiresAt(e){e instanceof Date?this._expiresAt=e.getTime():this._expiresAt=e}get timeoutId(){return this._timeoutId}set timeoutId(e){this._timeoutId=e}}});var Re=F((Go,dt)=>{"use strict";dt.exports=class{constructor(e,r,n,o){this.remainingPoints=typeof e>"u"?0:e,this.msBeforeNext=typeof r>"u"?0:r,this.consumedPoints=typeof n>"u"?0:n,this.isFirstInDuration=typeof o>"u"?!1:o}get msBeforeNext(){return this._msBeforeNext}set msBeforeNext(e){return this._msBeforeNext=e,this}get remainingPoints(){return this._remainingPoints}set remainingPoints(e){return this._remainingPoints=e,this}get consumedPoints(){return this._consumedPoints}set consumedPoints(e){return this._consumedPoints=e,this}get isFirstInDuration(){return this._isFirstInDuration}set isFirstInDuration(e){this._isFirstInDuration=!!e}_getDecoratedProperties(){return{remainingPoints:this.remainingPoints,msBeforeNext:this.msBeforeNext,consumedPoints:this.consumedPoints,isFirstInDuration:this.isFirstInDuration}}[Symbol.for("nodejs.util.inspect.custom")](){return this._getDecoratedProperties()}toString(){return JSON.stringify(this._getDecoratedProperties())}toJSON(){return this._getDecoratedProperties()}}});var ft=F((Xo,ht)=>{"use strict";var pt=ut(),Ee=Re();ht.exports=class{constructor(){this._storage=new Map}incrby(e,r,n){let o=this._storage.get(e);if(o){let s=o.expiresAt?o.expiresAt-Date.now():-1;return!o.expiresAt||s>0?(o.value=o.value+r,new Ee(0,s,o.value,!1)):this.set(e,r,n)}return this.set(e,r,n)}set(e,r,n){let o=n*1e3,s=this._storage.get(e);s&&s.timeoutId&&clearTimeout(s.timeoutId);let i=new pt(r,o>0?Date.now()+o:null);return this._storage.set(e,i),o>0&&(i.timeoutId=setTimeout(()=>{this._storage.delete(e)},o),i.timeoutId.unref&&i.timeoutId.unref()),new Ee(0,o===0?-1:o,i.value,!0)}get(e){let r=this._storage.get(e);if(r){let n=r.expiresAt?r.expiresAt-Date.now():-1;return new Ee(0,n,r.value,!1)}return null}delete(e){let r=this._storage.get(e);return r?(r.timeoutId&&clearTimeout(r.timeoutId),this._storage.delete(e),!0):!1}_restoreRecord(e,r,n){let o=Date.now(),s=n!==null;if(s&&!Number.isFinite(n)||s&&n<=o)return;let i=s?n-o:0,a=this._storage.get(e);a&&a.timeoutId&&clearTimeout(a.timeoutId);let c=new pt(r,n);this._storage.set(e,c),i>0&&(c.timeoutId=setTimeout(()=>{this._storage.delete(e)},i),c.timeoutId.unref&&c.timeoutId.unref())}}});var yt=F((Qo,gt)=>{"use strict";var br=ct(),xr=ft(),mt=Re(),_e=class extends br{constructor(e={}){super(e),this._memoryStorage=new xr}consume(e,r=1,n={}){return new Promise((o,s)=>{let i=this.getKey(e),a=this._getKeySecDuration(n),c=this._memoryStorage.incrby(i,r,a);if(c.remainingPoints=Math.max(this.points-c.consumedPoints,0),c.consumedPoints>this.points)this.blockDuration>0&&c.consumedPoints<=this.points+r&&(c=this._memoryStorage.set(i,c.consumedPoints,this.blockDuration)),s(c);else if(this.execEvenly&&this.points>0&&c.msBeforeNext>0&&!c.isFirstInDuration){let l=Math.ceil(c.msBeforeNext/(c.remainingPoints+2));l<this.execEvenlyMinDelayMs&&(l=c.consumedPoints*this.execEvenlyMinDelayMs),c.msBeforeNext=Math.max(c.msBeforeNext-l,0),setTimeout(o,l,c)}else o(c)})}penalty(e,r=1,n={}){let o=this.getKey(e);return new Promise(s=>{let i=this._getKeySecDuration(n),a=this._memoryStorage.incrby(o,r,i);a.remainingPoints=Math.max(this.points-a.consumedPoints,0),s(a)})}reward(e,r=1,n={}){let o=this.getKey(e);return new Promise(s=>{let i=this._getKeySecDuration(n),a=this._memoryStorage.incrby(o,-r,i);a.remainingPoints=Math.max(this.points-a.consumedPoints,0),s(a)})}block(e,r){let n=r*1e3,o=this.points+1;return this._memoryStorage.set(this.getKey(e),o,r),Promise.resolve(new mt(0,n===0?-1:n,o))}set(e,r,n){let o=(n>=0?n:this.duration)*1e3;return this._memoryStorage.set(this.getKey(e),r,n),Promise.resolve(new mt(0,o===0?-1:o,r))}get(e){let r=this._memoryStorage.get(this.getKey(e));return r!==null&&(r.remainingPoints=Math.max(this.points-r.consumedPoints,0)),Promise.resolve(r)}delete(e){return Promise.resolve(this._memoryStorage.delete(this.getKey(e)))}dump(){let e=[];for(let[r,n]of this._memoryStorage._storage)e.push({key:this.parseKey(r),value:n.value,expiresAt:n.expiresAt});return{version:1,dumpedAt:Date.now(),storage:e}}restore(e,r=!1){if(!e||typeof e!="object"||e.version!==1)return;let n=r?{invalid:{count:0,keys:[]},expired:{count:0,keys:[]},restored:{count:0,keys:[]}}:{invalid:0,expired:0,restored:0},o=(s,i)=>{r?(n[s].count+=1,n[s].keys.push(i)):n[s]+=1};if(!Array.isArray(e.storage))return n;for(let s of e.storage){if(!s||typeof s!="object"){o("invalid","N/A");continue}let i=typeof s.key=="string"||typeof s.key=="number",a=Number.isFinite(s.value),c=s.expiresAt===null||Number.isFinite(s.expiresAt);if(!i||!a||!c){o("invalid",s.key);continue}if(s.expiresAt!==null&&s.expiresAt<=Date.now()){o("expired",s.key);continue}this._memoryStorage._restoreRecord(this.getKey(s.key),s.value,s.expiresAt),o("restored",s.key)}return n}};gt.exports=_e});var le=(t,e,r)=>(n,o)=>{let s=-1;return i(0);async function i(a){if(a<=s)throw new Error("next() called multiple times");s=a;let c,l=!1,u;if(t[a]?(u=t[a][0][0],n.req.routeIndex=a):u=a===t.length&&o||void 0,u)try{c=await u(n,()=>i(a+1))}catch(p){if(p instanceof Error&&e)n.error=p,c=await e(p,n),l=!0;else throw p}else n.finalized===!1&&r&&(c=await r(n));return c&&(n.finalized===!1||l)&&(n.res=c),n}};var De=Symbol();var je=(t,e)=>new Response(t,{headers:{"Content-Type":e.replace(/^[^;]+/,n=>n.toLowerCase())}}).formData();var Y=t=>"headers"in t,Ne=async(t,e=Object.create(null))=>{let{all:r=!1,dot:n=!1}=e,i=(Y(t)?t.headers:t.raw.headers).get("Content-Type")?.split(";")[0].trim().toLowerCase();return i==="multipart/form-data"||i==="application/x-www-form-urlencoded"?or(t,{all:r,dot:n}):{}};async function or(t,e){if(!Y(t)&&t.bodyCache.formData)return Ue(await t.bodyCache.formData,e);let r=Y(t)?t.headers:t.raw.headers,n=await t.arrayBuffer(),o=je(n,r.get("Content-Type")||"");Y(t)||(t.bodyCache.formData=o);let s=await o;return s?Ue(s,e):{}}function Ue(t,e){let r=Object.create(null);return t.forEach((n,o)=>{e.all||o.endsWith("[]")?sr(r,o,n):r[o]=n}),e.dot&&Object.entries(r).forEach(([n,o])=>{n.includes(".")&&(ir(r,n,o),delete r[n])}),r}var sr=(t,e,r)=>{t[e]!==void 0?Array.isArray(t[e])?t[e].push(r):t[e]=[t[e],r]:e.endsWith("[]")?t[e]=[r]:t[e]=r},ir=(t,e,r)=>{if(/(?:^|\.)__proto__\./.test(e))return;let n=t,o=e.split(".");o.forEach((s,i)=>{i===o.length-1?n[s]=r:((!n[s]||typeof n[s]!="object"||Array.isArray(n[s])||n[s]instanceof File)&&(n[s]=Object.create(null)),n=n[s])})};var de=t=>{let e=t.split("/");return e[0]===""&&e.shift(),e},He=t=>{let{groups:e,path:r}=ar(t),n=de(r);return cr(n,e)},ar=t=>{let e=[];return t=t.replace(/\{[^}]+\}/g,(r,n)=>{let o=`@${n}`;return e.push([o,r]),o}),{groups:e,path:t}},cr=(t,e)=>{for(let r=e.length-1;r>=0;r--){let[n]=e[r];for(let o=t.length-1;o>=0;o--)if(t[o].includes(n)){t[o]=t[o].replace(n,e[r][1]);break}}return t},X={},$e=(t,e)=>{if(t==="*")return"*";let r=t.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);if(r){let n=`${t}#${e}`;return X[n]||(r[2]?X[n]=e&&e[0]!==":"&&e[0]!=="*"?[n,r[1],new RegExp(`^${r[2]}(?=/${e})`)]:[t,r[1],new RegExp(`^${r[2]}$`)]:X[n]=[t,r[1],!0]),X[n]}return null},Q=(t,e)=>{try{return e(t)}catch{return t.replace(/(?:%[0-9A-Fa-f]{2})+/g,r=>{try{return e(r)}catch{return r}})}},lr=t=>Q(t,decodeURI),pe=t=>{let e=t.url,r=e.indexOf("/",e.indexOf(":")+4),n=r;for(;n<e.length;n++){let o=e.charCodeAt(n);if(o===37){let s=e.indexOf("?",n),i=e.indexOf("#",n),a=s===-1?i===-1?void 0:i:i===-1?s:Math.min(s,i),c=e.slice(r,a);return lr(c.includes("%25")?c.replace(/%25/g,"%2525"):c)}else if(o===63||o===35)break}return e.slice(r,n)};var Be=t=>{let e=pe(t);return e.length>1&&e.at(-1)==="/"?e.slice(0,-1):e},k=(t,e,...r)=>(r.length&&(e=k(e,...r)),`${t?.[0]==="/"?"":"/"}${t}${e==="/"?"":`${t?.at(-1)==="/"?"":"/"}${e?.[0]==="/"?e.slice(1):e}`}`),Z=t=>{if(t.charCodeAt(t.length-1)!==63||!t.includes(":"))return null;let e=t.split("/"),r=[],n="";return e.forEach(o=>{if(o!==""&&!/\:/.test(o))n+="/"+o;else if(/\:/.test(o))if(/\?/.test(o)){r.length===0&&n===""?r.push("/"):r.push(n);let s=o.replace("?","");n+="/"+s,r.push(n)}else n+="/"+o}),r.filter((o,s,i)=>i.indexOf(o)===s)},ue=t=>/[%+]/.test(t)?(t.indexOf("+")!==-1&&(t=t.replace(/\+/g," ")),t.indexOf("%")!==-1?Q(t,he):t):t,qe=(t,e,r)=>{let n;if(!r&&e&&!/[%+]/.test(e)){let i=t.indexOf("?",8);if(i===-1)return;for(t.startsWith(e,i+1)||(i=t.indexOf(`&${e}`,i+1));i!==-1;){let a=t.charCodeAt(i+e.length+1);if(a===61){let c=i+e.length+2,l=t.indexOf("&",c);return ue(t.slice(c,l===-1?void 0:l))}else if(a==38||isNaN(a))return"";i=t.indexOf(`&${e}`,i+1)}if(n=/[%+]/.test(t),!n)return}let o=Object.create(null);n??=/[%+]/.test(t);let s=t.indexOf("?",8);for(;s!==-1;){let i=t.indexOf("&",s+1),a=t.indexOf("=",s);a>i&&i!==-1&&(a=-1);let c=t.slice(s+1,a===-1?i===-1?void 0:i:a);if(n&&(c=ue(c)),s=i,c==="")continue;let l;a===-1?l="":(l=t.slice(a+1,i===-1?void 0:i),n&&(l=ue(l))),r?(o[c]&&Array.isArray(o[c])||(o[c]=[]),o[c].push(l)):o[c]??=l}return e?o[e]:o},ze=qe,Fe=(t,e)=>qe(t,e,!0),he=decodeURIComponent;var We=t=>Q(t,he),Ve=class{raw;#t;#e;routeIndex=0;path;bodyCache={};constructor(t,e="/",r=[[]]){this.raw=t,this.path=e,this.#e=r,this.#t={}}param(t){return t?this.#r(t):this.#s()}#r(t){let e=this.#e[0][this.routeIndex][1][t],r=this.#o(e);return r&&/\%/.test(r)?We(r):r}#s(){let t={},e=Object.keys(this.#e[0][this.routeIndex][1]);for(let r of e){let n=this.#o(this.#e[0][this.routeIndex][1][r]);n!==void 0&&(t[r]=/\%/.test(n)?We(n):n)}return t}#o(t){return this.#e[1]?this.#e[1][t]:t}query(t){return ze(this.url,t)}queries(t){return Fe(this.url,t)}header(t){if(t)return this.raw.headers.get(t)??void 0;let e=Object.create(null);return this.raw.headers.forEach((r,n)=>{e[n]=r}),e}async parseBody(t){return Ne(this,t)}#n=t=>{let{bodyCache:e,raw:r}=this,n=e[t];if(n)return n;let o=Object.keys(e)[0];return o?e[o].then(s=>(o==="json"&&(s=JSON.stringify(s)),new Response(s)[t]())):e[t]=r[t]()};json(){return this.#n("text").then(t=>JSON.parse(t))}text(){return this.#n("text")}arrayBuffer(){return this.#n("arrayBuffer")}bytes(){return this.#n("arrayBuffer").then(t=>new Uint8Array(t))}blob(){return this.#n("blob")}formData(){return this.#n("formData")}addValidatedData(t,e){this.#t[t]=e}valid(t){return this.#t[t]}get url(){return this.raw.url}get method(){return this.raw.method}get[De](){return this.#e}get matchedRoutes(){return this.#e[0].map(([[,t]])=>t)}get routePath(){return this.#e[0].map(([[,t]])=>t)[this.routeIndex].path}};var Ke={Stringify:1,BeforeStream:2,Stream:3},ur=(t,e)=>{let r=new String(t);return r.isEscaped=!0,r.callbacks=e,r};var fe=async(t,e,r,n,o)=>{typeof t=="object"&&!(t instanceof String)&&(t instanceof Promise||(t=t.toString()),t instanceof Promise&&(t=await t));let s=t.callbacks;if(!s?.length)return Promise.resolve(t);o?o[0]+=t:o=[t];let i=Promise.all(s.map(a=>a({phase:e,buffer:o,context:n}))).then(a=>Promise.all(a.filter(Boolean).map(c=>fe(c,e,!1,n,o))).then(()=>o[0]));return r?ur(await i,s):i};var dr="text/plain; charset=UTF-8",me=(t,e)=>({"Content-Type":t,...e}),W=(t,e)=>new Response(t,e),ge=class{#t;#e;env={};#r;finalized=!1;error;#s;#o;#n;#u;#c;#l;#a;#d;#p;constructor(t,e){this.#t=t,e&&(this.#o=e.executionCtx,this.env=e.env,this.#l=e.notFoundHandler,this.#p=e.path,this.#d=e.matchResult)}get req(){return this.#e??=new Ve(this.#t,this.#p,this.#d),this.#e}get event(){if(this.#o&&"respondWith"in this.#o)return this.#o;throw Error("This context has no FetchEvent")}get executionCtx(){if(this.#o)return this.#o;throw Error("This context has no ExecutionContext")}get res(){return this.#n||=W(null,{headers:this.#a??=new Headers})}set res(t){if(this.#n&&t){t=W(t.body,t);for(let[e,r]of this.#n.headers.entries())if(e!=="content-type")if(e==="set-cookie"){let n=this.#n.headers.getSetCookie();t.headers.delete("set-cookie");for(let o of n)t.headers.append("set-cookie",o)}else t.headers.set(e,r)}this.#n=t,this.finalized=!0}render=(...t)=>(this.#c??=e=>this.html(e),this.#c(...t));setLayout=t=>this.#u=t;getLayout=()=>this.#u;setRenderer=t=>{this.#c=t};header=(t,e,r)=>{this.finalized&&(this.#n=W(this.#n.body,this.#n));let n=this.#n?this.#n.headers:this.#a??=new Headers;e===void 0?n.delete(t):r?.append?n.append(t,e):n.set(t,e)};status=t=>{this.#s=t};set=(t,e)=>{this.#r??=new Map,this.#r.set(t,e)};get=t=>this.#r?this.#r.get(t):void 0;get var(){return this.#r?Object.fromEntries(this.#r):{}}#i(t,e,r){let n=this.#n?new Headers(this.#n.headers):this.#a??new Headers;if(typeof e=="object"&&"headers"in e){let s=e.headers instanceof Headers?e.headers:new Headers(e.headers);for(let[i,a]of s)i.toLowerCase()==="set-cookie"?n.append(i,a):n.set(i,a)}if(r)for(let[s,i]of Object.entries(r))if(typeof i=="string")n.set(s,i);else{n.delete(s);for(let a of i)n.append(s,a)}let o=typeof e=="number"?e:e?.status??this.#s;return W(t,{status:o,headers:n})}newResponse=(...t)=>this.#i(...t);body=(t,e,r)=>this.#i(t,e,r);text=(t,e,r)=>!this.#a&&!this.#s&&!e&&!r&&!this.finalized?new Response(t):this.#i(t,e,me(dr,r));json=(t,e,r)=>this.#i(JSON.stringify(t),e,me("application/json",r));html=(t,e,r)=>{let n=o=>this.#i(o,e,me("text/html; charset=UTF-8",r));return typeof t=="object"?fe(t,Ke.Stringify,!1,{}).then(n):n(t)};redirect=(t,e)=>{let r=String(t);return this.header("Location",/[^\x00-\xFF]/.test(r)?encodeURI(r):r),this.newResponse(null,e??302)};notFound=()=>(this.#l??=()=>W(),this.#l(this))};var v="ALL",Je="all",Ge=["get","post","put","delete","options","patch"],ee="Can not add a route since the matcher is already built.",te=class extends Error{};var Ye="__COMPOSED_HANDLER";var pr=t=>t.text("404 Not Found",404),Xe=(t,e)=>{if("getResponse"in t){let r=t.getResponse();return e.newResponse(r.body,r)}return console.error(t),e.text("Internal Server Error",500)},Qe=class Ze{get;post;put;delete;options;patch;all;on;use;router;getPath;_basePath="/";#t="/";routes=[];constructor(e={}){[...Ge,Je].forEach(s=>{this[s]=(i,...a)=>(typeof i=="string"?this.#t=i:this.#s(s,this.#t,i),a.forEach(c=>{this.#s(s,this.#t,c)}),this)}),this.on=(s,i,...a)=>{for(let c of[i].flat()){this.#t=c;for(let l of[s].flat())a.map(u=>{this.#s(l.toUpperCase(),this.#t,u)})}return this},this.use=(s,...i)=>(typeof s=="string"?this.#t=s:(this.#t="*",i.unshift(s)),i.forEach(a=>{this.#s(v,this.#t,a)}),this);let{strict:n,...o}=e;Object.assign(this,o),this.getPath=n??!0?e.getPath??pe:Be}#e(){let e=new Ze({router:this.router,getPath:this.getPath});return e.errorHandler=this.errorHandler,e.#r=this.#r,e.routes=this.routes,e}#r=pr;errorHandler=Xe;route(e,r){let n=this.basePath(e);return r.routes.map(o=>{let s;r.errorHandler===Xe?s=o.handler:(s=async(i,a)=>(await le([],r.errorHandler)(i,()=>o.handler(i,a))).res,s[Ye]=o.handler),n.#s(o.method,o.path,s,o.basePath)}),this}basePath(e){let r=this.#e();return r._basePath=k(this._basePath,e),r}onError=e=>(this.errorHandler=e,this);notFound=e=>(this.#r=e,this);mount(e,r,n){let o,s;n&&(typeof n=="function"?s=n:(s=n.optionHandler,n.replaceRequest===!1?o=c=>c:o=n.replaceRequest));let i=s?c=>{let l=s(c);return Array.isArray(l)?l:[l]}:c=>{let l;try{l=c.executionCtx}catch{}return[c.env,l]};o||=(()=>{let c=k(this._basePath,e),l=c==="/"?0:c.length;return u=>{let p=new URL(u.url);return p.pathname=this.getPath(u).slice(l)||"/",new Request(p,u)}})();let a=async(c,l)=>{let u=await r(o(c.req.raw),...i(c));if(u)return u;await l()};return this.#s(v,k(e,"*"),a),this}#s(e,r,n,o){e=e.toUpperCase(),r=k(this._basePath,r);let s={basePath:o!==void 0?k(this._basePath,o):this._basePath,path:r,method:e,handler:n};this.router.add(e,r,[n,s]),this.routes.push(s)}#o(e,r){if(e instanceof Error)return this.errorHandler(e,r);throw e}#n(e,r,n,o){if(o==="HEAD")return(async()=>new Response(null,await this.#n(e,r,n,"GET")))();let s=this.getPath(e,{env:n}),i=this.router.match(o,s),a=new ge(e,{path:s,matchResult:i,env:n,executionCtx:r,notFoundHandler:this.#r});if(i[0].length===1){let l;try{l=i[0][0][0][0](a,async()=>{a.res=await this.#r(a)})}catch(u){return this.#o(u,a)}return l instanceof Promise?l.then(u=>u||(a.finalized?a.res:this.#r(a))).catch(u=>this.#o(u,a)):l??this.#r(a)}let c=le(i[0],this.errorHandler,this.#r);return(async()=>{try{let l=await c(a);if(!l.finalized)throw new Error("Context is not finalized. Did you forget to return a Response object or `await next()`?");return l.res}catch(l){return this.#o(l,a)}})()}fetch=(e,...r)=>this.#n(e,r[1],r[0],e.method);request=(e,r,n,o)=>e instanceof Request?this.fetch(r?new Request(e,r):e,n,o):(e=e.toString(),this.fetch(new Request(/^https?:\/\//.test(e)?e:`http://localhost${k("/",e)}`,r),n,o));fire=()=>{addEventListener("fetch",e=>{e.respondWith(this.#n(e.request,e,void 0,e.request.method))})}};var re=[];function ye(t,e){let r=this.buildAllMatchers(),n=((o,s)=>{let i=r[o]||r[v],a=i[2][s];if(a)return a;let c=s.match(i[0]);if(!c)return[[],re];let l=c.indexOf("",1);return[i[1][l],c]});return this.match=n,n(t,e)}var ne="[^/]+",V=".*",K="(?:|/.*)",H=Symbol(),hr=new Set(".\\+*[^]$()");function fr(t,e){return t.length===1?e.length===1?t<e?-1:1:-1:e.length===1||t===V||t===K?1:e===V||e===K?-1:t===ne?1:e===ne?-1:t.length===e.length?t<e?-1:1:e.length-t.length}var et=class we{#t;#e;#r=Object.create(null);insert(e,r,n,o,s){if(e.length===0){if(this.#t!==void 0)throw H;if(s)return;this.#t=r;return}let[i,...a]=e,c=i==="*"?a.length===0?["","",V]:["","",ne]:i==="/*"?["","",K]:i.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/),l;if(c){let u=c[1],p=c[2]||ne;if(u&&c[2]&&(p===".*"||(p=p.replace(/^\((?!\?:)(?=[^)]+\)$)/,"(?:"),/\((?!\?:)/.test(p))))throw H;if(l=this.#r[p],!l){if(Object.keys(this.#r).some(h=>h!==V&&h!==K))throw H;if(s)return;l=this.#r[p]=new we,u!==""&&(l.#e=o.varIndex++)}!s&&u!==""&&n.push([u,l.#e])}else if(l=this.#r[i],!l){if(Object.keys(this.#r).some(u=>u.length>1&&u!==V&&u!==K))throw H;if(s)return;l=this.#r[i]=new we}l.insert(a,r,n,o,s)}buildRegExpStr(){let r=Object.keys(this.#r).sort(fr).map(n=>{let o=this.#r[n];return(typeof o.#e=="number"?`(${n})@${o.#e}`:hr.has(n)?`\\${n}`:n)+o.buildRegExpStr()});return typeof this.#t=="number"&&r.unshift(`#${this.#t}`),r.length===0?"":r.length===1?r[0]:"(?:"+r.join("|")+")"}};var tt=class{#t={varIndex:0};#e=new et;insert(t,e,r){let n=[],o=[];for(let i=0;;){let a=!1;if(t=t.replace(/\{[^}]+\}/g,c=>{let l=`@\\${i}`;return o[i]=[l,c],i++,a=!0,l}),!a)break}let s=t.match(/(?::[^\/]+)|(?:\/\*$)|./g)||[];for(let i=o.length-1;i>=0;i--){let[a]=o[i];for(let c=s.length-1;c>=0;c--)if(s[c].indexOf(a)!==-1){s[c]=s[c].replace(a,o[i][1]);break}}return this.#e.insert(s,e,n,this.#t,r),n}buildRegExp(){let t=this.#e.buildRegExpStr();if(t==="")return[/^$/,[],[]];let e=0,r=[],n=[];return t=t.replace(/#(\d+)|@(\d+)|\.\*\$/g,(o,s,i)=>s!==void 0?(r[++e]=Number(s),"$()"):(i!==void 0&&(n[Number(i)]=++e),"")),[new RegExp(`^${t}`),r,n]}};var mr=[/^$/,[],Object.create(null)],rt=Object.create(null);function nt(t){return rt[t]??=new RegExp(t==="*"?"":`^${t.replace(/\/\*$|([.\\+*[^\]$()])/g,(e,r)=>r?`\\${r}`:"(?:|/.*)")}$`)}function gr(){rt=Object.create(null)}function yr(t){let e=new tt,r=[];if(t.length===0)return mr;let n=t.map(l=>[!/\*|\/:/.test(l[0]),...l]).sort(([l,u],[p,h])=>l?1:p?-1:u.length-h.length),o=Object.create(null);for(let l=0,u=-1,p=n.length;l<p;l++){let[h,f,w]=n[l];h?o[f]=[w.map(([g])=>[g,Object.create(null)]),re]:u++;let b;try{b=e.insert(f,u,h)}catch(g){throw g===H?new te(f):g}h||(r[u]=w.map(([g,d])=>{let m=Object.create(null);for(d-=1;d>=0;d--){let[x,O]=b[d];m[x]=O}return[g,m]}))}let[s,i,a]=e.buildRegExp();for(let l=0,u=r.length;l<u;l++)for(let p=0,h=r[l].length;p<h;p++){let f=r[l][p]?.[1];if(!f)continue;let w=Object.keys(f);for(let b=0,g=w.length;b<g;b++)f[w[b]]=a[f[w[b]]]}let c=[];for(let l in i)c[l]=r[i[l]];return[s,c,o]}function q(t,e){if(t){for(let r of Object.keys(t).sort((n,o)=>o.length-n.length))if(nt(r).test(e))return[...t[r]]}}var oe=class{name="RegExpRouter";#t;#e;constructor(){this.#t={[v]:Object.create(null)},this.#e={[v]:Object.create(null)}}add(t,e,r){let n=this.#t,o=this.#e;if(!n||!o)throw new Error(ee);n[t]||[n,o].forEach(a=>{a[t]=Object.create(null),Object.keys(a[v]).forEach(c=>{a[t][c]=[...a[v][c]]})}),e==="/*"&&(e="*");let s=(e.match(/\/:/g)||[]).length;if(/\*$/.test(e)){let a=nt(e);t===v?Object.keys(n).forEach(c=>{n[c][e]||=q(n[c],e)||q(n[v],e)||[]}):n[t][e]||=q(n[t],e)||q(n[v],e)||[],Object.keys(n).forEach(c=>{(t===v||t===c)&&Object.keys(n[c]).forEach(l=>{a.test(l)&&n[c][l].push([r,s])})}),Object.keys(o).forEach(c=>{(t===v||t===c)&&Object.keys(o[c]).forEach(l=>a.test(l)&&o[c][l].push([r,s]))});return}let i=Z(e)||[e];for(let a=0,c=i.length;a<c;a++){let l=i[a];Object.keys(o).forEach(u=>{(t===v||t===u)&&(o[u][l]||=[...q(n[u],l)||q(n[v],l)||[]],o[u][l].push([r,s-c+a+1]))})}}match=ye;buildAllMatchers(){let t=Object.create(null);return Object.keys(this.#e).concat(Object.keys(this.#t)).forEach(e=>{t[e]||=this.#r(e)}),this.#t=this.#e=void 0,gr(),t}#r(t){let e=[],r=t===v;return[this.#t,this.#e].forEach(n=>{let o=n[t]?Object.keys(n[t]).map(s=>[s,n[t][s]]):[];o.length!==0?(r||=!0,e.push(...o)):t!==v&&e.push(...Object.keys(n[v]).map(s=>[s,n[v][s]]))}),r?yr(e):null}};var be=class{name="SmartRouter";#t=[];#e=[];constructor(t){this.#t=t.routers}add(t,e,r){if(!this.#e)throw new Error(ee);this.#e.push([t,e,r])}match(t,e){if(!this.#e)throw new Error("Fatal error");let r=this.#t,n=this.#e,o=r.length,s=0,i;for(;s<o;s++){let a=r[s];try{for(let c=0,l=n.length;c<l;c++)a.add(...n[c]);i=a.match(t,e)}catch(c){if(c instanceof te)continue;throw c}this.match=a.match.bind(a),this.#t=[a],this.#e=void 0;break}if(s===o)throw new Error("Fatal error");return this.name=`SmartRouter + ${this.activeRouter.name}`,i}get activeRouter(){if(this.#e||this.#t.length!==1)throw new Error("No active router has been determined yet.");return this.#t[0]}};var J=Object.create(null),wr=t=>{for(let e in t)return!0;return!1},ot=class st{#t;#e;#r;#s=0;#o=J;constructor(e,r,n){if(this.#e=n||Object.create(null),this.#t=[],e&&r){let o=Object.create(null);o[e]={handler:r,possibleKeys:[],score:0},this.#t=[o]}this.#r=[]}insert(e,r,n){this.#s=++this.#s;let o=this,s=He(r),i=[];for(let a=0,c=s.length;a<c;a++){let l=s[a],u=s[a+1],p=$e(l,u),h=Array.isArray(p)?p[0]:l;if(h in o.#e){o=o.#e[h],p&&i.push(p[1]);continue}o.#e[h]=new st,p&&(o.#r.push(p),i.push(p[1])),o=o.#e[h]}return o.#t.push({[e]:{handler:n,possibleKeys:i.filter((a,c,l)=>l.indexOf(a)===c),score:this.#s}}),o}#n(e,r,n,o,s){for(let i=0,a=r.#t.length;i<a;i++){let c=r.#t[i],l=c[n]||c[v],u={};if(l!==void 0&&(l.params=Object.create(null),e.push(l),o!==J||s&&s!==J))for(let p=0,h=l.possibleKeys.length;p<h;p++){let f=l.possibleKeys[p],w=u[l.score];l.params[f]=s?.[f]&&!w?s[f]:o[f]??s?.[f],u[l.score]=!0}}}search(e,r){let n=[];this.#o=J;let s=[this],i=de(r),a=[],c=i.length,l=null;for(let u=0;u<c;u++){let p=i[u],h=u===c-1,f=[];for(let b=0,g=s.length;b<g;b++){let d=s[b],m=d.#e[p];m&&(m.#o=d.#o,h?(m.#e["*"]&&this.#n(n,m.#e["*"],e,d.#o),this.#n(n,m,e,d.#o)):f.push(m));for(let x=0,O=d.#r.length;x<O;x++){let L=d.#r[x],E=d.#o===J?{}:{...d.#o};if(L==="*"){let _=d.#e["*"];_&&(this.#n(n,_,e,d.#o),_.#o=E,f.push(_));continue}let[P,S,R]=L;if(!p&&!(R instanceof RegExp))continue;let y=d.#e[P];if(R instanceof RegExp){if(l===null){l=new Array(c);let j=r[0]==="/"?1:0;for(let U=0;U<c;U++)l[U]=j,j+=i[U].length+1}let _=r.substring(l[u]),C=R.exec(_);if(C){if(E[S]=C[0],this.#n(n,y,e,d.#o,E),C[0].length===_.length&&y.#e["*"]&&this.#n(n,y.#e["*"],e,d.#o,E),wr(y.#e)){y.#o=E;let j=C[0].match(/\//)?.length??0;(a[j]||=[]).push(y)}continue}}(R===!0||R.test(p))&&(E[S]=p,h?(this.#n(n,y,e,E,d.#o),y.#e["*"]&&this.#n(n,y.#e["*"],e,E,d.#o)):(y.#o=E,f.push(y)))}}let w=a.shift();s=w?f.concat(w):f}return n.length>1&&n.sort((u,p)=>u.score-p.score),[n.map(({handler:u,params:p})=>[u,p])]}};var xe=class{name="TrieRouter";#t;constructor(){this.#t=new ot}add(t,e,r){let n=Z(e);if(n){for(let o=0,s=n.length;o<s;o++)this.#t.insert(t,n[o],r);return}this.#t.insert(t,e,r)}match(t,e){return this.#t.search(t,e)}};var ve=class extends Qe{constructor(t={}){super(t),this.router=t.router??new be({routers:[new oe,new xe]})}};import{Readable as un}from"stream";function it(t=""){return`<link rel="icon" type="image/svg+xml" href="${`${t.replace(/\/$/,"")}/favicon-black.svg?v=4`}" />`}import{existsSync as wt,readFileSync as Er}from"fs";import I from"path";import{fileURLToPath as _r}from"url";import{gunzipSync as Pr}from"zlib";var M=nr(yt(),1);function z(t,e){return t.header("Retry-After",String(vr(e))),t.json({error:"Too Many Requests"},429)}function vr(t){return t&&typeof t=="object"&&"msBeforeNext"in t&&typeof t.msBeforeNext=="number"&&Number.isFinite(t.msBeforeNext)?Math.max(1,Math.ceil(t.msBeforeNext/1e3)):60}var Sr={".js":"application/javascript",".css":"text/css",".svg":"image/svg+xml",".png":"image/png",".ico":"image/x-icon",".webmanifest":"application/manifest+json"};function Ar(){let t=I.dirname(_r(import.meta.url));for(let e of[I.resolve(t,"app"),I.resolve(t,"../app"),I.resolve(t,"../../dist/app")])if(wt(I.join(e,"inspector.js.gz")))return e;throw new Error("Inspector bundle not found (expected dist/app/inspector.js.gz)")}function bt(t,e="/inspector/assets"){let r=Ar(),n=new Map,o=new M.default({points:600,duration:60}),s=async(i,a)=>{try{await o.consume(i.req)}catch(c){return z(i,c)}return a()};t.use(`${e}/*`,s),t.get(`${e}/*`,async i=>{let a=i.req.path.slice(e.length),c=a.startsWith("/")?a.slice(1):a;if(!c||c.includes(".."))return i.notFound();let l=c==="inspector.js"||c==="inspector.css"?`${c}.gz`:c,u=I.resolve(r,l),p=r.endsWith(I.sep)?r:`${r}${I.sep}`;if(!u.startsWith(p)||!wt(u))return i.notFound();let h=I.extname(c),f=l.endsWith(".gz"),w=/(?:^|,)\s*gzip\s*(?:,|$)/i.test(i.req.header("accept-encoding")??""),b=Er(u),g=f&&!w?n.get(u)??Cr(n,u,b):b,d=g.buffer.slice(g.byteOffset,g.byteOffset+g.byteLength);return i.body(d,200,{"Content-Type":Sr[h]??"application/octet-stream",...f&&w?{"Content-Encoding":"gzip"}:{},...f?{Vary:"Accept-Encoding"}:{},"Cache-Control":"no-cache"})})}function Cr(t,e,r){let n=Pr(r);return t.set(e,n),n}var xt={name:"@mcp-use/inspector",type:"module",version:"20.0.5-canary.2",description:"MCP Inspector - A tool for inspecting and debugging MCP servers",author:"",license:"MIT",homepage:"https://github.com/mcp-use/mcp-use#readme",repository:{type:"git",url:"git+https://github.com/mcp-use/mcp-use.git",directory:"libraries/typescript/packages/inspector"},bugs:{url:"https://github.com/mcp-use/mcp-use/issues"},keywords:["mcp","inspector","debug","tools"],exports:{".":{types:"./dist/server/index.d.ts",import:"./dist/server/index.js"},"./client":{types:"./dist/client/index.d.ts",import:"./dist/client/index.js"}},main:"./dist/server/index.js",types:"./dist/server/index.d.ts",bin:{"mcp-inspect":"./dist/cli.js"},files:["dist"],scripts:{dev:"rimraf node_modules/.vite && vite --strictPort","dev:client":"pnpm run dev","dev:server":"VITE_DEV=true tsx watch src/server/server.ts","dev:standalone":"tsx watch src/server/server.ts",clean:"rimraf dist",build:"npm run clean && npm run build:client-exports && npm run build:server && npm run build:app && npm run verify:package","build:app":"vite build --config vite.app.config.ts && node scripts/compress-app.mjs","watch:app":"vite build --watch --config vite.app.config.ts","preview:app":"vite preview --config vite.app.config.ts --host 127.0.0.1","serve:app":"pnpm build:app && pnpm preview:app","analyze:app":"ANALYZE=true vite build --config vite.app.config.ts","build:client-exports":"tsup --config tsup.client.ts","build:server":"tsup --config tsup.server.ts","verify:package":"node scripts/verify-package.mjs",prepublishOnly:"pnpm --filter @mcp-use/client build && pnpm build",start:"node dist/cli.js --port 3000",preview:"vite preview","type-check":"tsc --noEmit",lint:"eslint .","lint:fix":"eslint . --fix","test:e2e":"playwright test","test:e2e:ui":"playwright test --ui","test:e2e:debug":"playwright test --debug","test:e2e:builtin":"node tests/e2e/scripts/run-test-matrix.mjs builtin","test:e2e:prod":"node tests/e2e/scripts/run-test-matrix.mjs prod","test:e2e:mix":"node tests/e2e/scripts/run-test-matrix.mjs mix","test:e2e:prod:ui":"TEST_MODE=production playwright test --ui","test:e2e:codegen":"playwright codegen http://localhost:3000/inspector","test:e2e:report":"playwright show-report","test:e2e:python":"node tests/e2e/scripts/run-python-e2e.mjs","test:unit":"vitest run","test:unit:watch":"vitest","test:e2e:tunnel":"node tests/e2e/scripts/run-tunnel-test.mjs","install:pnpm":"pnpm install","install:npm":"npm install","lint:npm":"npm run lint:fix","lint:pnpm":"pnpm lint:fix"},engines:{node:">=22.22.2"},peerDependencies:{"@base-ui/react":"^1.6.0","@mcp-use/agent":"^2.0.2-canary.0","@mcp-use/client":"^2.0.2-canary.0","class-variance-authority":"^0.7.1",clsx:"^2.1.1",express:"^4.21.2 || ^5.0.0","lucide-react":"^0.562.0","markdown-to-jsx":"^9.7.4","mcp-use":"workspace:*",motion:"^12.34.2",react:"^18.0.0 || ^19.0.0","react-dom":"^18.0.0 || ^19.0.0","react-resizable-panels":"^4.6.4",sonner:"^2.0.7","tailwind-merge":"^3.5.0"},peerDependenciesMeta:{"@base-ui/react":{optional:!0},"@mcp-use/agent":{optional:!0},"@mcp-use/client":{optional:!0},"class-variance-authority":{optional:!0},clsx:{optional:!0},express:{optional:!0},"lucide-react":{optional:!0},"markdown-to-jsx":{optional:!0},"mcp-use":{optional:!0},motion:{optional:!0},react:{optional:!0},"react-dom":{optional:!0},"react-resizable-panels":{optional:!0},sonner:{optional:!0},"tailwind-merge":{optional:!0}},dependencies:{},publishConfig:{access:"public"},devDependencies:{"@base-ui/react":"^1.6.0","@hono/node-server":"^2.0.5","@mcp-use/agent":"workspace:*","@mcp-use/client":"workspace:*","@playwright/test":"^1.58.2","@tailwindcss/vite":"^4.2.0","@types/express":"^5.0.6","@vitejs/plugin-react":"^6.0.0","class-variance-authority":"^0.7.1",clsx:"^2.1.1",emulate:"0.5.0",eslint:"^9.39.2",express:"^5.2.1",hono:"^4.12.34","lucide-react":"^0.562.0","markdown-to-jsx":"^9.7.4",motion:"^12.34.2","oauth2-mock-server":"^8.2.2",open:"^11.0.0",react:"^19.2.3","react-dom":"^19.2.3","react-router":"^8.3.0","react-resizable-panels":"^4.6.4","rate-limiter-flexible":"^11.2.0","rollup-plugin-visualizer":"^6.0.3",sonner:"^2.0.7","tailwind-merge":"^3.5.0",tailwindcss:"^4.2.0",tsup:"^8.5.1",tsx:"^4.21.0","tw-animate-css":"^1.4.0",typescript:"^5.9.3",vite:"^8.0.16",vitest:"^4.1.0","wait-on":"^9.0.4",zod:"^4.2.0"}};var Lr=xt.version;function vt(){return Lr}var Tr=`<!doctype html>
2
2
  <html>
3
3
  <head>
4
4
  <meta charset="utf-8" />
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mcp-use/inspector",
3
3
  "type": "module",
4
- "version": "20.0.5-canary.0",
4
+ "version": "20.0.5-canary.2",
5
5
  "description": "MCP Inspector - A tool for inspecting and debugging MCP servers",
6
6
  "author": "",
7
7
  "license": "MIT",
@@ -56,7 +56,7 @@
56
56
  "react-resizable-panels": "^4.6.4",
57
57
  "sonner": "^2.0.7",
58
58
  "tailwind-merge": "^3.5.0",
59
- "mcp-use": "2.0.5-canary.0"
59
+ "mcp-use": "2.0.5-canary.2"
60
60
  },
61
61
  "peerDependenciesMeta": {
62
62
  "@base-ui/react": {
@@ -144,8 +144,8 @@
144
144
  "vitest": "^4.1.0",
145
145
  "wait-on": "^9.0.4",
146
146
  "zod": "^4.2.0",
147
- "@mcp-use/agent": "2.0.2-canary.0",
148
- "@mcp-use/client": "2.0.2-canary.0"
147
+ "@mcp-use/agent": "2.0.2-canary.2",
148
+ "@mcp-use/client": "2.0.2-canary.2"
149
149
  },
150
150
  "scripts": {
151
151
  "dev": "rimraf node_modules/.vite && vite --strictPort",