@mcp-use/inspector 0.10.0 → 0.10.1

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.
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/winston-BG6TqujU.js","assets/util-t-trnxQI.js","assets/__vite-browser-external-DFygW7-s.js","assets/index-DRz5BQNA.js","assets/path-C9FudP8b.js","assets/index-dcwAFu32.js","assets/index-DLvycrCn.js","assets/index-uLaqVHqx.js","assets/index-C1fAPMt_.js","assets/embeddings-DSYSWoMY.js","assets/index-jXEm6Yfx.js","assets/index-DMpSV0MO.js","assets/browser-B0j7NxIO.js"])))=>i.map(i=>d[i]);
2
- var sX=Object.defineProperty;var lX=(e,t,n)=>t in e?sX(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var _h=(e,t,n)=>lX(e,typeof t!="symbol"?t+"":t,n);function cX(e,t){for(var n=0;n<t.length;n++){const a=t[n];if(typeof a!="string"&&!Array.isArray(a)){for(const r in a)if(r!=="default"&&!(r in e)){const i=Object.getOwnPropertyDescriptor(a,r);i&&Object.defineProperty(e,r,i.get?i:{enumerable:!0,get:()=>a[r]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))a(r);new MutationObserver(r=>{for(const i of r)if(i.type==="childList")for(const s of i.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&a(s)}).observe(document,{childList:!0,subtree:!0});function n(r){const i={};return r.integrity&&(i.integrity=r.integrity),r.referrerPolicy&&(i.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?i.credentials="include":r.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function a(r){if(r.ep)return;r.ep=!0;const i=n(r);fetch(r.href,i)}})();function xp(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function q_e(e){if(Object.prototype.hasOwnProperty.call(e,"__esModule"))return e;var t=e.default;if(typeof t=="function"){var n=function a(){var r=!1;try{r=this instanceof a}catch{}return r?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach(function(a){var r=Object.getOwnPropertyDescriptor(e,a);Object.defineProperty(n,a,r.get?r:{enumerable:!0,get:function(){return e[a]}})}),n}var H0={exports:{}},af={};var cj;function uX(){if(cj)return af;cj=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(a,r,i){var s=null;if(i!==void 0&&(s=""+i),r.key!==void 0&&(s=""+r.key),"key"in r){i={};for(var c in r)c!=="key"&&(i[c]=r[c])}else i=r;return r=i.ref,{$$typeof:e,type:a,key:s,ref:r!==void 0?r:null,props:i}}return af.Fragment=t,af.jsx=n,af.jsxs=n,af}var uj;function dX(){return uj||(uj=1,H0.exports=uX()),H0.exports}var p=dX();const fX="modulepreload",pX=function(e){return"/inspector/"+e},dj={},Ar=function(t,n,a){let r=Promise.resolve();if(n&&n.length>0){let u=function(d){return Promise.all(d.map(m=>Promise.resolve(m).then(h=>({status:"fulfilled",value:h}),h=>({status:"rejected",reason:h}))))};document.getElementsByTagName("link");const s=document.querySelector("meta[property=csp-nonce]"),c=s?.nonce||s?.getAttribute("nonce");r=u(n.map(d=>{if(d=pX(d),d in dj)return;dj[d]=!0;const m=d.endsWith(".css"),h=m?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${d}"]${h}`))return;const g=document.createElement("link");if(g.rel=m?"stylesheet":fX,m||(g.as="script"),g.crossOrigin="",g.href=d,c&&g.setAttribute("nonce",c),document.head.appendChild(g),m)return new Promise((v,w)=>{g.addEventListener("load",v),g.addEventListener("error",()=>w(new Error(`Unable to preload CSS for ${d}`)))})}))}function i(s){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=s,window.dispatchEvent(c),!c.defaultPrevented)throw s}return r.then(s=>{for(const c of s||[])c.status==="rejected"&&i(c.reason);return t().catch(i)})};var mX=Object.defineProperty,Ge=(e,t)=>mX(e,"name",{value:t,configurable:!0}),fj=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,n)=>(typeof require<"u"?require:t)[n]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')}),Uc={};async function l2(){if(typeof process<"u")try{const e=await Ar(()=>import("./__vite-browser-external-DFygW7-s.js").then(n=>n.o),[]),t=await Ar(()=>import("./path-C9FudP8b.js").then(n=>n.p),[]);return{fs:e.default,path:t.default}}catch{return{fs:null,path:null}}return{fs:null,path:null}}Ge(l2,"getNodeModules");var Ra=null;function c2(){if(typeof fj<"u")try{Ra=fj("winston")}catch{}}Ge(c2,"loadWinstonSync");async function u2(){return Ra||(Ra=await Ar(()=>import("./winston-BG6TqujU.js").then(e=>e.w),__vite__mapDeps([0,1,2,3,4]))),Ra}Ge(u2,"getWinston");var ux="mcp-use";function ob(){try{return typeof navigator<"u"&&navigator.userAgent?.includes("Cloudflare-Workers")||typeof globalThis.EdgeRuntime<"u"||typeof globalThis.Deno<"u"?!1:typeof process<"u"&&!0&&typeof __dirname<"u"}catch{return!1}}Ge(ob,"isNodeJSEnvironment");var gu,hX=(gu=class{_level;name;constructor(t=ux,n="info"){this.name=t,this._level=n}shouldLog(t){const n=["error","warn","info","http","verbose","debug","silly"],a=n.indexOf(this._level);return n.indexOf(t)<=a}formatMessage(t,n){return`${new Date().toLocaleTimeString("en-US",{hour12:!1})} [${this.name}] ${t}: ${n}`}error(t){this.shouldLog("error")&&console.error(this.formatMessage("error",t))}warn(t){this.shouldLog("warn")&&console.warn(this.formatMessage("warn",t))}info(t){this.shouldLog("info")&&console.info(this.formatMessage("info",t))}debug(t){this.shouldLog("debug")&&console.debug(this.formatMessage("debug",t))}http(t){this.shouldLog("http")&&console.log(this.formatMessage("http",t))}verbose(t){this.shouldLog("verbose")&&console.log(this.formatMessage("verbose",t))}silly(t){this.shouldLog("silly")&&console.log(this.formatMessage("silly",t))}get level(){return this._level}set level(t){this._level=t}},Ge(gu,"SimpleConsoleLogger"),gu);function jg(e){switch((typeof process<"u"&&Uc?e:void 0)?.trim()){case"2":return"debug";case"1":return"info";default:return"info"}}Ge(jg,"resolveLevel");var bo,d2=(bo=class{static get(t=ux){if(!ob()){if(!this.simpleInstances[t]){const n=typeof process<"u"&&Uc?.DEBUG||void 0;this.simpleInstances[t]=new hX(t,jg(n))}return this.simpleInstances[t]}if(!this.instances[t]){if(!Ra)throw new Error("Winston not loaded - call Logger.configure() first");const{createLogger:n,format:a}=Ra,{combine:r,timestamp:i,label:s,colorize:c,splat:u}=a;this.instances[t]=n({level:jg(Uc.DEBUG),format:r(c(),u(),s({label:t}),i({format:"HH:mm:ss"}),this.getFormatter()),transports:[]})}return this.instances[t]}static getFormatter(){if(!Ra)throw new Error("Winston not loaded");const{format:t}=Ra,{printf:n}=t,a=n(({level:s,message:c,label:u,timestamp:d})=>`${d} [${u}] ${s}: ${c}`),r=n(({level:s,message:c,label:u,timestamp:d})=>`${d} [${u}] ${s.toUpperCase()}: ${c}`),i=n(({level:s,message:c,label:u,timestamp:d})=>`${d} [${u}] ${s.toUpperCase()}: ${c}`);switch(this.currentFormat){case"minimal":return a;case"detailed":return r;case"emoji":return i;default:return a}}static async configure(t={}){const{level:n,console:a=!0,file:r,format:i="minimal"}=t,s=typeof process<"u"&&Uc?.DEBUG||void 0,c=n??jg(s);if(this.currentFormat=i,!ob()){Object.values(this.simpleInstances).forEach(y=>{y.level=c});return}if(await u2(),!Ra)throw new Error("Failed to load winston");const u=this.get();u.level=c;const d=u;if(d.clear(),a&&d.add(new Ra.transports.Console),r){const{fs:y,path:_}=await l2();if(y&&_){const E=_.dirname(_.resolve(r));y.existsSync(E)||y.mkdirSync(E,{recursive:!0}),d.add(new Ra.transports.File({filename:r}))}}const{format:m}=Ra,{combine:h,timestamp:g,label:v,colorize:w,splat:S}=m;Object.values(this.instances).forEach(y=>{y&&"format"in y&&(y.level=c,y.format=h(w(),S(),v({label:ux}),g({format:"HH:mm:ss"}),this.getFormatter()))})}static setDebug(t){let n;t===2||t===!0?n="debug":n="info",Object.values(this.simpleInstances).forEach(a=>{a.level=n}),Object.values(this.instances).forEach(a=>{a&&(a.level=n)}),typeof process<"u"&&Uc&&(Uc.DEBUG=t?t===!0?"2":String(t):"0")}static setFormat(t){this.currentFormat=t,this.configure({format:t})}},Ge(bo,"Logger"),_h(bo,"instances",{}),_h(bo,"simpleInstances",{}),_h(bo,"currentFormat","minimal"),bo);ob()&&(c2(),Ra&&d2.configure());var Oe=d2.get();const f2=Object.freeze({status:"aborted"});function me(e,t,n){function a(c,u){if(c._zod||Object.defineProperty(c,"_zod",{value:{def:u,constr:s,traits:new Set},enumerable:!1}),c._zod.traits.has(e))return;c._zod.traits.add(e),t(c,u);const d=s.prototype,m=Object.keys(d);for(let h=0;h<m.length;h++){const g=m[h];g in c||(c[g]=d[g].bind(c))}}const r=n?.Parent??Object;class i extends r{}Object.defineProperty(i,"name",{value:e});function s(c){var u;const d=n?.Parent?new i:this;a(d,c),(u=d._zod).deferred??(u.deferred=[]);for(const m of d._zod.deferred)m();return d}return Object.defineProperty(s,"init",{value:a}),Object.defineProperty(s,Symbol.hasInstance,{value:c=>n?.Parent&&c instanceof n.Parent?!0:c?._zod?.traits?.has(e)}),Object.defineProperty(s,"name",{value:e}),s}const p2=Symbol("zod_brand");class El extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class uv extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const sb={};function qr(e){return e&&Object.assign(sb,e),sb}function gX(e){return e}function bX(e){return e}function vX(e){}function yX(e){throw new Error}function wX(e){}function h_(e){const t=Object.values(e).filter(a=>typeof a=="number");return Object.entries(e).filter(([a,r])=>t.indexOf(+a)===-1).map(([a,r])=>r)}function Me(e,t="|"){return e.map(n=>dt(n)).join(t)}function lb(e,t){return typeof t=="bigint"?t.toString():t}function Ep(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function zl(e){return e==null}function dv(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function m2(e,t){const n=(e.toString().split(".")[1]||"").length,a=t.toString();let r=(a.split(".")[1]||"").length;if(r===0&&/\d?e-\d?/.test(a)){const u=a.match(/\d?e-(\d?)/);u?.[1]&&(r=Number.parseInt(u[1]))}const i=n>r?n:r,s=Number.parseInt(e.toFixed(i).replace(".","")),c=Number.parseInt(t.toFixed(i).replace(".",""));return s%c/10**i}const pj=Symbol("evaluating");function Lt(e,t,n){let a;Object.defineProperty(e,t,{get(){if(a!==pj)return a===void 0&&(a=pj,a=n()),a},set(r){Object.defineProperty(e,t,{value:r})},configurable:!0})}function SX(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function $s(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function jo(...e){const t={};for(const n of e){const a=Object.getOwnPropertyDescriptors(n);Object.assign(t,a)}return Object.defineProperties({},t)}function xX(e){return jo(e._zod.def)}function EX(e,t){return t?t.reduce((n,a)=>n?.[a],e):e}function _X(e){const t=Object.keys(e),n=t.map(a=>e[a]);return Promise.all(n).then(a=>{const r={};for(let i=0;i<t.length;i++)r[t[i]]=a[i];return r})}function kX(e=10){const t="abcdefghijklmnopqrstuvwxyz";let n="";for(let a=0;a<e;a++)n+=t[Math.floor(Math.random()*t.length)];return n}function dx(e){return JSON.stringify(e)}function h2(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const g_="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Nu(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const g2=Ep(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function Rl(e){if(Nu(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(Nu(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function fv(e){return Rl(e)?{...e}:Array.isArray(e)?[...e]:e}function TX(e){let t=0;for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&t++;return t}const NX=e=>{const t=typeof e;switch(t){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(e)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(e)?"array":e===null?"null":e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?"promise":typeof Map<"u"&&e instanceof Map?"map":typeof Set<"u"&&e instanceof Set?"set":typeof Date<"u"&&e instanceof Date?"date":typeof File<"u"&&e instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${t}`)}},cb=new Set(["string","number","symbol"]),b2=new Set(["string","number","bigint","boolean","symbol","undefined"]);function No(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ei(e,t,n){const a=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(a._zod.parent=e),a}function Ce(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function RX(e){let t;return new Proxy({},{get(n,a,r){return t??(t=e()),Reflect.get(t,a,r)},set(n,a,r,i){return t??(t=e()),Reflect.set(t,a,r,i)},has(n,a){return t??(t=e()),Reflect.has(t,a)},deleteProperty(n,a){return t??(t=e()),Reflect.deleteProperty(t,a)},ownKeys(n){return t??(t=e()),Reflect.ownKeys(t)},getOwnPropertyDescriptor(n,a){return t??(t=e()),Reflect.getOwnPropertyDescriptor(t,a)},defineProperty(n,a,r){return t??(t=e()),Reflect.defineProperty(t,a,r)}})}function dt(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function v2(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const y2={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},w2={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function S2(e,t){const n=e._zod.def,a=jo(e._zod.def,{get shape(){const r={};for(const i in t){if(!(i in n.shape))throw new Error(`Unrecognized key: "${i}"`);t[i]&&(r[i]=n.shape[i])}return $s(this,"shape",r),r},checks:[]});return ei(e,a)}function x2(e,t){const n=e._zod.def,a=jo(e._zod.def,{get shape(){const r={...e._zod.def.shape};for(const i in t){if(!(i in n.shape))throw new Error(`Unrecognized key: "${i}"`);t[i]&&delete r[i]}return $s(this,"shape",r),r},checks:[]});return ei(e,a)}function E2(e,t){if(!Rl(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0)throw new Error("Object schemas containing refinements cannot be extended. Use `.safeExtend()` instead.");const r=jo(e._zod.def,{get shape(){const i={...e._zod.def.shape,...t};return $s(this,"shape",i),i},checks:[]});return ei(e,r)}function _2(e,t){if(!Rl(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n={...e._zod.def,get shape(){const a={...e._zod.def.shape,...t};return $s(this,"shape",a),a},checks:e._zod.def.checks};return ei(e,n)}function k2(e,t){const n=jo(e._zod.def,{get shape(){const a={...e._zod.def.shape,...t._zod.def.shape};return $s(this,"shape",a),a},get catchall(){return t._zod.def.catchall},checks:[]});return ei(e,n)}function T2(e,t,n){const a=jo(t._zod.def,{get shape(){const r=t._zod.def.shape,i={...r};if(n)for(const s in n){if(!(s in r))throw new Error(`Unrecognized key: "${s}"`);n[s]&&(i[s]=e?new e({type:"optional",innerType:r[s]}):r[s])}else for(const s in r)i[s]=e?new e({type:"optional",innerType:r[s]}):r[s];return $s(this,"shape",i),i},checks:[]});return ei(t,a)}function N2(e,t,n){const a=jo(t._zod.def,{get shape(){const r=t._zod.def.shape,i={...r};if(n)for(const s in n){if(!(s in i))throw new Error(`Unrecognized key: "${s}"`);n[s]&&(i[s]=new e({type:"nonoptional",innerType:r[s]}))}else for(const s in r)i[s]=new e({type:"nonoptional",innerType:r[s]});return $s(this,"shape",i),i},checks:[]});return ei(t,a)}function bl(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function pi(e,t){return t.map(n=>{var a;return(a=n).path??(a.path=[]),n.path.unshift(e),n})}function hf(e){return typeof e=="string"?e:e?.message}function bi(e,t,n){const a={...e,path:e.path??[]};if(!e.message){const r=hf(e.inst?._zod.def?.error?.(e))??hf(t?.error?.(e))??hf(n.customError?.(e))??hf(n.localeError?.(e))??"Invalid input";a.message=r}return delete a.inst,delete a.continue,t?.reportInput||delete a.input,a}function pv(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}function mv(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Ru(...e){const[t,n,a]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:a}:{...t}}function CX(e){return Object.entries(e).filter(([t,n])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function R2(e){const t=atob(e),n=new Uint8Array(t.length);for(let a=0;a<t.length;a++)n[a]=t.charCodeAt(a);return n}function C2(e){let t="";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}function AX(e){const t=e.replace(/-/g,"+").replace(/_/g,"/"),n="=".repeat((4-t.length%4)%4);return R2(t+n)}function IX(e){return C2(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function OX(e){const t=e.replace(/^0x/,"");if(t.length%2!==0)throw new Error("Invalid hex string length");const n=new Uint8Array(t.length/2);for(let a=0;a<t.length;a+=2)n[a/2]=Number.parseInt(t.slice(a,a+2),16);return n}function DX(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}class LX{constructor(...t){}}const A2=Object.freeze(Object.defineProperty({__proto__:null,BIGINT_FORMAT_RANGES:w2,Class:LX,NUMBER_FORMAT_RANGES:y2,aborted:bl,allowsEval:g2,assert:wX,assertEqual:gX,assertIs:vX,assertNever:yX,assertNotEqual:bX,assignProp:$s,base64ToUint8Array:R2,base64urlToUint8Array:AX,cached:Ep,captureStackTrace:g_,cleanEnum:CX,cleanRegex:dv,clone:ei,cloneDef:xX,createTransparentProxy:RX,defineLazy:Lt,esc:dx,escapeRegex:No,extend:E2,finalizeIssue:bi,floatSafeRemainder:m2,getElementAtPath:EX,getEnumValues:h_,getLengthableOrigin:mv,getParsedType:NX,getSizableOrigin:pv,hexToUint8Array:OX,isObject:Nu,isPlainObject:Rl,issue:Ru,joinValues:Me,jsonStringifyReplacer:lb,merge:k2,mergeDefs:jo,normalizeParams:Ce,nullish:zl,numKeys:TX,objectClone:SX,omit:x2,optionalKeys:v2,partial:T2,pick:S2,prefixIssues:pi,primitiveTypes:b2,promiseAllObject:_X,propertyKeyTypes:cb,randomString:kX,required:N2,safeExtend:_2,shallowClone:fv,slugify:h2,stringifyPrimitive:dt,uint8ArrayToBase64:C2,uint8ArrayToBase64url:IX,uint8ArrayToHex:DX,unwrapMessage:hf},Symbol.toStringTag,{value:"Module"})),I2=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,lb,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},b_=me("$ZodError",I2),$a=me("$ZodError",I2,{Parent:Error});function v_(e,t=n=>n.message){const n={},a=[];for(const r of e.issues)r.path.length>0?(n[r.path[0]]=n[r.path[0]]||[],n[r.path[0]].push(t(r))):a.push(t(r));return{formErrors:a,fieldErrors:n}}function y_(e,t=n=>n.message){const n={_errors:[]},a=r=>{for(const i of r.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(s=>a({issues:s}));else if(i.code==="invalid_key")a({issues:i.issues});else if(i.code==="invalid_element")a({issues:i.issues});else if(i.path.length===0)n._errors.push(t(i));else{let s=n,c=0;for(;c<i.path.length;){const u=i.path[c];c===i.path.length-1?(s[u]=s[u]||{_errors:[]},s[u]._errors.push(t(i))):s[u]=s[u]||{_errors:[]},s=s[u],c++}}};return a(e),n}function O2(e,t=n=>n.message){const n={errors:[]},a=(r,i=[])=>{var s,c;for(const u of r.issues)if(u.code==="invalid_union"&&u.errors.length)u.errors.map(d=>a({issues:d},u.path));else if(u.code==="invalid_key")a({issues:u.issues},u.path);else if(u.code==="invalid_element")a({issues:u.issues},u.path);else{const d=[...i,...u.path];if(d.length===0){n.errors.push(t(u));continue}let m=n,h=0;for(;h<d.length;){const g=d[h],v=h===d.length-1;typeof g=="string"?(m.properties??(m.properties={}),(s=m.properties)[g]??(s[g]={errors:[]}),m=m.properties[g]):(m.items??(m.items=[]),(c=m.items)[g]??(c[g]={errors:[]}),m=m.items[g]),v&&m.errors.push(t(u)),h++}}};return a(e),n}function D2(e){const t=[],n=e.map(a=>typeof a=="object"?a.key:a);for(const a of n)typeof a=="number"?t.push(`[${a}]`):typeof a=="symbol"?t.push(`[${JSON.stringify(String(a))}]`):/[^\w$]/.test(a)?t.push(`[${JSON.stringify(a)}]`):(t.length&&t.push("."),t.push(a));return t.join("")}function L2(e){const t=[],n=[...e.issues].sort((a,r)=>(a.path??[]).length-(r.path??[]).length);for(const a of n)t.push(`✖ ${a.message}`),a.path?.length&&t.push(` → at ${D2(a.path)}`);return t.join(`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/winston-DR7cYlm9.js","assets/util-t-trnxQI.js","assets/__vite-browser-external-DFygW7-s.js","assets/index-DRz5BQNA.js","assets/path-C9FudP8b.js","assets/index-eSg28oTZ.js","assets/index-Ce878vOP.js","assets/index-BYhzDU5C.js","assets/index-DhgLWhgI.js","assets/embeddings-2-V6Dm5C.js","assets/index-BWh1LT8v.js","assets/index-C0sILan8.js","assets/browser-DhbomOzS.js"])))=>i.map(i=>d[i]);
2
+ var sX=Object.defineProperty;var lX=(e,t,n)=>t in e?sX(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var _h=(e,t,n)=>lX(e,typeof t!="symbol"?t+"":t,n);function cX(e,t){for(var n=0;n<t.length;n++){const a=t[n];if(typeof a!="string"&&!Array.isArray(a)){for(const r in a)if(r!=="default"&&!(r in e)){const i=Object.getOwnPropertyDescriptor(a,r);i&&Object.defineProperty(e,r,i.get?i:{enumerable:!0,get:()=>a[r]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))a(r);new MutationObserver(r=>{for(const i of r)if(i.type==="childList")for(const s of i.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&a(s)}).observe(document,{childList:!0,subtree:!0});function n(r){const i={};return r.integrity&&(i.integrity=r.integrity),r.referrerPolicy&&(i.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?i.credentials="include":r.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function a(r){if(r.ep)return;r.ep=!0;const i=n(r);fetch(r.href,i)}})();function xp(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function q_e(e){if(Object.prototype.hasOwnProperty.call(e,"__esModule"))return e;var t=e.default;if(typeof t=="function"){var n=function a(){var r=!1;try{r=this instanceof a}catch{}return r?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach(function(a){var r=Object.getOwnPropertyDescriptor(e,a);Object.defineProperty(n,a,r.get?r:{enumerable:!0,get:function(){return e[a]}})}),n}var H0={exports:{}},af={};var cj;function uX(){if(cj)return af;cj=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(a,r,i){var s=null;if(i!==void 0&&(s=""+i),r.key!==void 0&&(s=""+r.key),"key"in r){i={};for(var c in r)c!=="key"&&(i[c]=r[c])}else i=r;return r=i.ref,{$$typeof:e,type:a,key:s,ref:r!==void 0?r:null,props:i}}return af.Fragment=t,af.jsx=n,af.jsxs=n,af}var uj;function dX(){return uj||(uj=1,H0.exports=uX()),H0.exports}var p=dX();const fX="modulepreload",pX=function(e){return"/inspector/"+e},dj={},Ar=function(t,n,a){let r=Promise.resolve();if(n&&n.length>0){let u=function(d){return Promise.all(d.map(m=>Promise.resolve(m).then(h=>({status:"fulfilled",value:h}),h=>({status:"rejected",reason:h}))))};document.getElementsByTagName("link");const s=document.querySelector("meta[property=csp-nonce]"),c=s?.nonce||s?.getAttribute("nonce");r=u(n.map(d=>{if(d=pX(d),d in dj)return;dj[d]=!0;const m=d.endsWith(".css"),h=m?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${d}"]${h}`))return;const g=document.createElement("link");if(g.rel=m?"stylesheet":fX,m||(g.as="script"),g.crossOrigin="",g.href=d,c&&g.setAttribute("nonce",c),document.head.appendChild(g),m)return new Promise((v,w)=>{g.addEventListener("load",v),g.addEventListener("error",()=>w(new Error(`Unable to preload CSS for ${d}`)))})}))}function i(s){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=s,window.dispatchEvent(c),!c.defaultPrevented)throw s}return r.then(s=>{for(const c of s||[])c.status==="rejected"&&i(c.reason);return t().catch(i)})};var mX=Object.defineProperty,Ge=(e,t)=>mX(e,"name",{value:t,configurable:!0}),fj=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,n)=>(typeof require<"u"?require:t)[n]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')}),Uc={};async function l2(){if(typeof process<"u")try{const e=await Ar(()=>import("./__vite-browser-external-DFygW7-s.js").then(n=>n.o),[]),t=await Ar(()=>import("./path-C9FudP8b.js").then(n=>n.p),[]);return{fs:e.default,path:t.default}}catch{return{fs:null,path:null}}return{fs:null,path:null}}Ge(l2,"getNodeModules");var Ra=null;function c2(){if(typeof fj<"u")try{Ra=fj("winston")}catch{}}Ge(c2,"loadWinstonSync");async function u2(){return Ra||(Ra=await Ar(()=>import("./winston-DR7cYlm9.js").then(e=>e.w),__vite__mapDeps([0,1,2,3,4]))),Ra}Ge(u2,"getWinston");var ux="mcp-use";function ob(){try{return typeof navigator<"u"&&navigator.userAgent?.includes("Cloudflare-Workers")||typeof globalThis.EdgeRuntime<"u"||typeof globalThis.Deno<"u"?!1:typeof process<"u"&&!0&&typeof __dirname<"u"}catch{return!1}}Ge(ob,"isNodeJSEnvironment");var gu,hX=(gu=class{_level;name;constructor(t=ux,n="info"){this.name=t,this._level=n}shouldLog(t){const n=["error","warn","info","http","verbose","debug","silly"],a=n.indexOf(this._level);return n.indexOf(t)<=a}formatMessage(t,n){return`${new Date().toLocaleTimeString("en-US",{hour12:!1})} [${this.name}] ${t}: ${n}`}error(t){this.shouldLog("error")&&console.error(this.formatMessage("error",t))}warn(t){this.shouldLog("warn")&&console.warn(this.formatMessage("warn",t))}info(t){this.shouldLog("info")&&console.info(this.formatMessage("info",t))}debug(t){this.shouldLog("debug")&&console.debug(this.formatMessage("debug",t))}http(t){this.shouldLog("http")&&console.log(this.formatMessage("http",t))}verbose(t){this.shouldLog("verbose")&&console.log(this.formatMessage("verbose",t))}silly(t){this.shouldLog("silly")&&console.log(this.formatMessage("silly",t))}get level(){return this._level}set level(t){this._level=t}},Ge(gu,"SimpleConsoleLogger"),gu);function jg(e){switch((typeof process<"u"&&Uc?e:void 0)?.trim()){case"2":return"debug";case"1":return"info";default:return"info"}}Ge(jg,"resolveLevel");var bo,d2=(bo=class{static get(t=ux){if(!ob()){if(!this.simpleInstances[t]){const n=typeof process<"u"&&Uc?.DEBUG||void 0;this.simpleInstances[t]=new hX(t,jg(n))}return this.simpleInstances[t]}if(!this.instances[t]){if(!Ra)throw new Error("Winston not loaded - call Logger.configure() first");const{createLogger:n,format:a}=Ra,{combine:r,timestamp:i,label:s,colorize:c,splat:u}=a;this.instances[t]=n({level:jg(Uc.DEBUG),format:r(c(),u(),s({label:t}),i({format:"HH:mm:ss"}),this.getFormatter()),transports:[]})}return this.instances[t]}static getFormatter(){if(!Ra)throw new Error("Winston not loaded");const{format:t}=Ra,{printf:n}=t,a=n(({level:s,message:c,label:u,timestamp:d})=>`${d} [${u}] ${s}: ${c}`),r=n(({level:s,message:c,label:u,timestamp:d})=>`${d} [${u}] ${s.toUpperCase()}: ${c}`),i=n(({level:s,message:c,label:u,timestamp:d})=>`${d} [${u}] ${s.toUpperCase()}: ${c}`);switch(this.currentFormat){case"minimal":return a;case"detailed":return r;case"emoji":return i;default:return a}}static async configure(t={}){const{level:n,console:a=!0,file:r,format:i="minimal"}=t,s=typeof process<"u"&&Uc?.DEBUG||void 0,c=n??jg(s);if(this.currentFormat=i,!ob()){Object.values(this.simpleInstances).forEach(y=>{y.level=c});return}if(await u2(),!Ra)throw new Error("Failed to load winston");const u=this.get();u.level=c;const d=u;if(d.clear(),a&&d.add(new Ra.transports.Console),r){const{fs:y,path:_}=await l2();if(y&&_){const E=_.dirname(_.resolve(r));y.existsSync(E)||y.mkdirSync(E,{recursive:!0}),d.add(new Ra.transports.File({filename:r}))}}const{format:m}=Ra,{combine:h,timestamp:g,label:v,colorize:w,splat:S}=m;Object.values(this.instances).forEach(y=>{y&&"format"in y&&(y.level=c,y.format=h(w(),S(),v({label:ux}),g({format:"HH:mm:ss"}),this.getFormatter()))})}static setDebug(t){let n;t===2||t===!0?n="debug":n="info",Object.values(this.simpleInstances).forEach(a=>{a.level=n}),Object.values(this.instances).forEach(a=>{a&&(a.level=n)}),typeof process<"u"&&Uc&&(Uc.DEBUG=t?t===!0?"2":String(t):"0")}static setFormat(t){this.currentFormat=t,this.configure({format:t})}},Ge(bo,"Logger"),_h(bo,"instances",{}),_h(bo,"simpleInstances",{}),_h(bo,"currentFormat","minimal"),bo);ob()&&(c2(),Ra&&d2.configure());var Oe=d2.get();const f2=Object.freeze({status:"aborted"});function me(e,t,n){function a(c,u){if(c._zod||Object.defineProperty(c,"_zod",{value:{def:u,constr:s,traits:new Set},enumerable:!1}),c._zod.traits.has(e))return;c._zod.traits.add(e),t(c,u);const d=s.prototype,m=Object.keys(d);for(let h=0;h<m.length;h++){const g=m[h];g in c||(c[g]=d[g].bind(c))}}const r=n?.Parent??Object;class i extends r{}Object.defineProperty(i,"name",{value:e});function s(c){var u;const d=n?.Parent?new i:this;a(d,c),(u=d._zod).deferred??(u.deferred=[]);for(const m of d._zod.deferred)m();return d}return Object.defineProperty(s,"init",{value:a}),Object.defineProperty(s,Symbol.hasInstance,{value:c=>n?.Parent&&c instanceof n.Parent?!0:c?._zod?.traits?.has(e)}),Object.defineProperty(s,"name",{value:e}),s}const p2=Symbol("zod_brand");class El extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class uv extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const sb={};function qr(e){return e&&Object.assign(sb,e),sb}function gX(e){return e}function bX(e){return e}function vX(e){}function yX(e){throw new Error}function wX(e){}function h_(e){const t=Object.values(e).filter(a=>typeof a=="number");return Object.entries(e).filter(([a,r])=>t.indexOf(+a)===-1).map(([a,r])=>r)}function Me(e,t="|"){return e.map(n=>dt(n)).join(t)}function lb(e,t){return typeof t=="bigint"?t.toString():t}function Ep(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function zl(e){return e==null}function dv(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function m2(e,t){const n=(e.toString().split(".")[1]||"").length,a=t.toString();let r=(a.split(".")[1]||"").length;if(r===0&&/\d?e-\d?/.test(a)){const u=a.match(/\d?e-(\d?)/);u?.[1]&&(r=Number.parseInt(u[1]))}const i=n>r?n:r,s=Number.parseInt(e.toFixed(i).replace(".","")),c=Number.parseInt(t.toFixed(i).replace(".",""));return s%c/10**i}const pj=Symbol("evaluating");function Lt(e,t,n){let a;Object.defineProperty(e,t,{get(){if(a!==pj)return a===void 0&&(a=pj,a=n()),a},set(r){Object.defineProperty(e,t,{value:r})},configurable:!0})}function SX(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function $s(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function jo(...e){const t={};for(const n of e){const a=Object.getOwnPropertyDescriptors(n);Object.assign(t,a)}return Object.defineProperties({},t)}function xX(e){return jo(e._zod.def)}function EX(e,t){return t?t.reduce((n,a)=>n?.[a],e):e}function _X(e){const t=Object.keys(e),n=t.map(a=>e[a]);return Promise.all(n).then(a=>{const r={};for(let i=0;i<t.length;i++)r[t[i]]=a[i];return r})}function kX(e=10){const t="abcdefghijklmnopqrstuvwxyz";let n="";for(let a=0;a<e;a++)n+=t[Math.floor(Math.random()*t.length)];return n}function dx(e){return JSON.stringify(e)}function h2(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const g_="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Nu(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const g2=Ep(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function Rl(e){if(Nu(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(Nu(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function fv(e){return Rl(e)?{...e}:Array.isArray(e)?[...e]:e}function TX(e){let t=0;for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&t++;return t}const NX=e=>{const t=typeof e;switch(t){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(e)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(e)?"array":e===null?"null":e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?"promise":typeof Map<"u"&&e instanceof Map?"map":typeof Set<"u"&&e instanceof Set?"set":typeof Date<"u"&&e instanceof Date?"date":typeof File<"u"&&e instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${t}`)}},cb=new Set(["string","number","symbol"]),b2=new Set(["string","number","bigint","boolean","symbol","undefined"]);function No(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ei(e,t,n){const a=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(a._zod.parent=e),a}function Ce(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function RX(e){let t;return new Proxy({},{get(n,a,r){return t??(t=e()),Reflect.get(t,a,r)},set(n,a,r,i){return t??(t=e()),Reflect.set(t,a,r,i)},has(n,a){return t??(t=e()),Reflect.has(t,a)},deleteProperty(n,a){return t??(t=e()),Reflect.deleteProperty(t,a)},ownKeys(n){return t??(t=e()),Reflect.ownKeys(t)},getOwnPropertyDescriptor(n,a){return t??(t=e()),Reflect.getOwnPropertyDescriptor(t,a)},defineProperty(n,a,r){return t??(t=e()),Reflect.defineProperty(t,a,r)}})}function dt(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function v2(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const y2={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},w2={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function S2(e,t){const n=e._zod.def,a=jo(e._zod.def,{get shape(){const r={};for(const i in t){if(!(i in n.shape))throw new Error(`Unrecognized key: "${i}"`);t[i]&&(r[i]=n.shape[i])}return $s(this,"shape",r),r},checks:[]});return ei(e,a)}function x2(e,t){const n=e._zod.def,a=jo(e._zod.def,{get shape(){const r={...e._zod.def.shape};for(const i in t){if(!(i in n.shape))throw new Error(`Unrecognized key: "${i}"`);t[i]&&delete r[i]}return $s(this,"shape",r),r},checks:[]});return ei(e,a)}function E2(e,t){if(!Rl(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0)throw new Error("Object schemas containing refinements cannot be extended. Use `.safeExtend()` instead.");const r=jo(e._zod.def,{get shape(){const i={...e._zod.def.shape,...t};return $s(this,"shape",i),i},checks:[]});return ei(e,r)}function _2(e,t){if(!Rl(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n={...e._zod.def,get shape(){const a={...e._zod.def.shape,...t};return $s(this,"shape",a),a},checks:e._zod.def.checks};return ei(e,n)}function k2(e,t){const n=jo(e._zod.def,{get shape(){const a={...e._zod.def.shape,...t._zod.def.shape};return $s(this,"shape",a),a},get catchall(){return t._zod.def.catchall},checks:[]});return ei(e,n)}function T2(e,t,n){const a=jo(t._zod.def,{get shape(){const r=t._zod.def.shape,i={...r};if(n)for(const s in n){if(!(s in r))throw new Error(`Unrecognized key: "${s}"`);n[s]&&(i[s]=e?new e({type:"optional",innerType:r[s]}):r[s])}else for(const s in r)i[s]=e?new e({type:"optional",innerType:r[s]}):r[s];return $s(this,"shape",i),i},checks:[]});return ei(t,a)}function N2(e,t,n){const a=jo(t._zod.def,{get shape(){const r=t._zod.def.shape,i={...r};if(n)for(const s in n){if(!(s in i))throw new Error(`Unrecognized key: "${s}"`);n[s]&&(i[s]=new e({type:"nonoptional",innerType:r[s]}))}else for(const s in r)i[s]=new e({type:"nonoptional",innerType:r[s]});return $s(this,"shape",i),i},checks:[]});return ei(t,a)}function bl(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function pi(e,t){return t.map(n=>{var a;return(a=n).path??(a.path=[]),n.path.unshift(e),n})}function hf(e){return typeof e=="string"?e:e?.message}function bi(e,t,n){const a={...e,path:e.path??[]};if(!e.message){const r=hf(e.inst?._zod.def?.error?.(e))??hf(t?.error?.(e))??hf(n.customError?.(e))??hf(n.localeError?.(e))??"Invalid input";a.message=r}return delete a.inst,delete a.continue,t?.reportInput||delete a.input,a}function pv(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}function mv(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Ru(...e){const[t,n,a]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:a}:{...t}}function CX(e){return Object.entries(e).filter(([t,n])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function R2(e){const t=atob(e),n=new Uint8Array(t.length);for(let a=0;a<t.length;a++)n[a]=t.charCodeAt(a);return n}function C2(e){let t="";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}function AX(e){const t=e.replace(/-/g,"+").replace(/_/g,"/"),n="=".repeat((4-t.length%4)%4);return R2(t+n)}function IX(e){return C2(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function OX(e){const t=e.replace(/^0x/,"");if(t.length%2!==0)throw new Error("Invalid hex string length");const n=new Uint8Array(t.length/2);for(let a=0;a<t.length;a+=2)n[a/2]=Number.parseInt(t.slice(a,a+2),16);return n}function DX(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}class LX{constructor(...t){}}const A2=Object.freeze(Object.defineProperty({__proto__:null,BIGINT_FORMAT_RANGES:w2,Class:LX,NUMBER_FORMAT_RANGES:y2,aborted:bl,allowsEval:g2,assert:wX,assertEqual:gX,assertIs:vX,assertNever:yX,assertNotEqual:bX,assignProp:$s,base64ToUint8Array:R2,base64urlToUint8Array:AX,cached:Ep,captureStackTrace:g_,cleanEnum:CX,cleanRegex:dv,clone:ei,cloneDef:xX,createTransparentProxy:RX,defineLazy:Lt,esc:dx,escapeRegex:No,extend:E2,finalizeIssue:bi,floatSafeRemainder:m2,getElementAtPath:EX,getEnumValues:h_,getLengthableOrigin:mv,getParsedType:NX,getSizableOrigin:pv,hexToUint8Array:OX,isObject:Nu,isPlainObject:Rl,issue:Ru,joinValues:Me,jsonStringifyReplacer:lb,merge:k2,mergeDefs:jo,normalizeParams:Ce,nullish:zl,numKeys:TX,objectClone:SX,omit:x2,optionalKeys:v2,partial:T2,pick:S2,prefixIssues:pi,primitiveTypes:b2,promiseAllObject:_X,propertyKeyTypes:cb,randomString:kX,required:N2,safeExtend:_2,shallowClone:fv,slugify:h2,stringifyPrimitive:dt,uint8ArrayToBase64:C2,uint8ArrayToBase64url:IX,uint8ArrayToHex:DX,unwrapMessage:hf},Symbol.toStringTag,{value:"Module"})),I2=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,lb,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},b_=me("$ZodError",I2),$a=me("$ZodError",I2,{Parent:Error});function v_(e,t=n=>n.message){const n={},a=[];for(const r of e.issues)r.path.length>0?(n[r.path[0]]=n[r.path[0]]||[],n[r.path[0]].push(t(r))):a.push(t(r));return{formErrors:a,fieldErrors:n}}function y_(e,t=n=>n.message){const n={_errors:[]},a=r=>{for(const i of r.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(s=>a({issues:s}));else if(i.code==="invalid_key")a({issues:i.issues});else if(i.code==="invalid_element")a({issues:i.issues});else if(i.path.length===0)n._errors.push(t(i));else{let s=n,c=0;for(;c<i.path.length;){const u=i.path[c];c===i.path.length-1?(s[u]=s[u]||{_errors:[]},s[u]._errors.push(t(i))):s[u]=s[u]||{_errors:[]},s=s[u],c++}}};return a(e),n}function O2(e,t=n=>n.message){const n={errors:[]},a=(r,i=[])=>{var s,c;for(const u of r.issues)if(u.code==="invalid_union"&&u.errors.length)u.errors.map(d=>a({issues:d},u.path));else if(u.code==="invalid_key")a({issues:u.issues},u.path);else if(u.code==="invalid_element")a({issues:u.issues},u.path);else{const d=[...i,...u.path];if(d.length===0){n.errors.push(t(u));continue}let m=n,h=0;for(;h<d.length;){const g=d[h],v=h===d.length-1;typeof g=="string"?(m.properties??(m.properties={}),(s=m.properties)[g]??(s[g]={errors:[]}),m=m.properties[g]):(m.items??(m.items=[]),(c=m.items)[g]??(c[g]={errors:[]}),m=m.items[g]),v&&m.errors.push(t(u)),h++}}};return a(e),n}function D2(e){const t=[],n=e.map(a=>typeof a=="object"?a.key:a);for(const a of n)typeof a=="number"?t.push(`[${a}]`):typeof a=="symbol"?t.push(`[${JSON.stringify(String(a))}]`):/[^\w$]/.test(a)?t.push(`[${JSON.stringify(a)}]`):(t.length&&t.push("."),t.push(a));return t.join("")}function L2(e){const t=[],n=[...e.issues].sort((a,r)=>(a.path??[]).length-(r.path??[]).length);for(const a of n)t.push(`✖ ${a.message}`),a.path?.length&&t.push(` → at ${D2(a.path)}`);return t.join(`
3
3
  `)}const _p=e=>(t,n,a,r)=>{const i=a?Object.assign(a,{async:!1}):{async:!1},s=t._zod.run({value:n,issues:[]},i);if(s instanceof Promise)throw new El;if(s.issues.length){const c=new(r?.Err??e)(s.issues.map(u=>bi(u,i,qr())));throw g_(c,r?.callee),c}return s.value},fx=_p($a),kp=e=>async(t,n,a,r)=>{const i=a?Object.assign(a,{async:!0}):{async:!0};let s=t._zod.run({value:n,issues:[]},i);if(s instanceof Promise&&(s=await s),s.issues.length){const c=new(r?.Err??e)(s.issues.map(u=>bi(u,i,qr())));throw g_(c,r?.callee),c}return s.value},px=kp($a),Tp=e=>(t,n,a)=>{const r=a?{...a,async:!1}:{async:!1},i=t._zod.run({value:n,issues:[]},r);if(i instanceof Promise)throw new El;return i.issues.length?{success:!1,error:new(e??b_)(i.issues.map(s=>bi(s,r,qr())))}:{success:!0,data:i.value}},w_=Tp($a),Np=e=>async(t,n,a)=>{const r=a?Object.assign(a,{async:!0}):{async:!0};let i=t._zod.run({value:n,issues:[]},r);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new e(i.issues.map(s=>bi(s,r,qr())))}:{success:!0,data:i.value}},$2=Np($a),S_=e=>(t,n,a)=>{const r=a?Object.assign(a,{direction:"backward"}):{direction:"backward"};return _p(e)(t,n,r)},$X=S_($a),x_=e=>(t,n,a)=>_p(e)(t,n,a),jX=x_($a),E_=e=>async(t,n,a)=>{const r=a?Object.assign(a,{direction:"backward"}):{direction:"backward"};return kp(e)(t,n,r)},MX=E_($a),__=e=>async(t,n,a)=>kp(e)(t,n,a),PX=__($a),k_=e=>(t,n,a)=>{const r=a?Object.assign(a,{direction:"backward"}):{direction:"backward"};return Tp(e)(t,n,r)},UX=k_($a),T_=e=>(t,n,a)=>Tp(e)(t,n,a),zX=T_($a),N_=e=>async(t,n,a)=>{const r=a?Object.assign(a,{direction:"backward"}):{direction:"backward"};return Np(e)(t,n,r)},FX=N_($a),R_=e=>async(t,n,a)=>Np(e)(t,n,a),BX=R_($a),j2=/^[cC][^\s-]{8,}$/,M2=/^[0-9a-z]+$/,P2=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,U2=/^[0-9a-vA-V]{20}$/,z2=/^[A-Za-z0-9]{27}$/,F2=/^[a-zA-Z0-9_-]{21}$/,B2=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,HX=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,H2=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Cu=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,VX=Cu(4),GX=Cu(6),WX=Cu(7),V2=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,KX=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,ZX=/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,G2=/^[^\s@"]{1,64}@[^\s@]{1,255}$/u,YX=G2,XX=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,qX="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function W2(){return new RegExp(qX,"u")}const K2=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Z2=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,Y2=e=>{const t=No(e??":");return new RegExp(`^(?:[0-9A-F]{2}${t}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${t}){5}[0-9a-f]{2}$`)},X2=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,q2=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,J2=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,C_=/^[A-Za-z0-9_-]*$/,Q2=/^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/,eF=/^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/,tF=/^\+(?:[0-9]){6,14}[0-9]$/,nF="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",rF=new RegExp(`^${nF}$`);function aF(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function iF(e){return new RegExp(`^${aF(e)}$`)}function oF(e){const t=aF({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const a=`${t}(?:${n.join("|")})`;return new RegExp(`^${nF}T(?:${a})$`)}const sF=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},lF=/^-?\d+n?$/,cF=/^-?\d+$/,uF=/^-?\d+(?:\.\d+)?/,dF=/^(?:true|false)$/i,fF=/^null$/i,pF=/^undefined$/i,mF=/^[^A-Z]*$/,hF=/^[^a-z]*$/,gF=/^[0-9a-fA-F]*$/;function Rp(e,t){return new RegExp(`^[A-Za-z0-9+/]{${e}}${t}$`)}function Cp(e){return new RegExp(`^[A-Za-z0-9_-]{${e}}$`)}const JX=/^[0-9a-fA-F]{32}$/,QX=Rp(22,"=="),eq=Cp(22),tq=/^[0-9a-fA-F]{40}$/,nq=Rp(27,"="),rq=Cp(27),aq=/^[0-9a-fA-F]{64}$/,iq=Rp(43,"="),oq=Cp(43),sq=/^[0-9a-fA-F]{96}$/,lq=Rp(64,""),cq=Cp(64),uq=/^[0-9a-fA-F]{128}$/,dq=Rp(86,"=="),fq=Cp(86),A_=Object.freeze(Object.defineProperty({__proto__:null,base64:J2,base64url:C_,bigint:lF,boolean:dF,browserEmail:XX,cidrv4:X2,cidrv6:q2,cuid:j2,cuid2:M2,date:rF,datetime:oF,domain:eF,duration:B2,e164:tF,email:V2,emoji:W2,extendedDuration:HX,guid:H2,hex:gF,hostname:Q2,html5Email:KX,idnEmail:YX,integer:cF,ipv4:K2,ipv6:Z2,ksuid:z2,lowercase:mF,mac:Y2,md5_base64:QX,md5_base64url:eq,md5_hex:JX,nanoid:F2,null:fF,number:uF,rfc5322Email:ZX,sha1_base64:nq,sha1_base64url:rq,sha1_hex:tq,sha256_base64:iq,sha256_base64url:oq,sha256_hex:aq,sha384_base64:lq,sha384_base64url:cq,sha384_hex:sq,sha512_base64:dq,sha512_base64url:fq,sha512_hex:uq,string:sF,time:iF,ulid:P2,undefined:pF,unicodeEmail:G2,uppercase:hF,uuid:Cu,uuid4:VX,uuid6:GX,uuid7:WX,xid:U2},Symbol.toStringTag,{value:"Module"})),Pn=me("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),bF={number:"number",bigint:"bigint",object:"date"},I_=me("$ZodCheckLessThan",(e,t)=>{Pn.init(e,t);const n=bF[typeof t.value];e._zod.onattach.push(a=>{const r=a._zod.bag,i=(t.inclusive?r.maximum:r.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<i&&(t.inclusive?r.maximum=t.value:r.exclusiveMaximum=t.value)}),e._zod.check=a=>{(t.inclusive?a.value<=t.value:a.value<t.value)||a.issues.push({origin:n,code:"too_big",maximum:t.value,input:a.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),O_=me("$ZodCheckGreaterThan",(e,t)=>{Pn.init(e,t);const n=bF[typeof t.value];e._zod.onattach.push(a=>{const r=a._zod.bag,i=(t.inclusive?r.minimum:r.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>i&&(t.inclusive?r.minimum=t.value:r.exclusiveMinimum=t.value)}),e._zod.check=a=>{(t.inclusive?a.value>=t.value:a.value>t.value)||a.issues.push({origin:n,code:"too_small",minimum:t.value,input:a.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),vF=me("$ZodCheckMultipleOf",(e,t)=>{Pn.init(e,t),e._zod.onattach.push(n=>{var a;(a=n._zod.bag).multipleOf??(a.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?n.value%t.value===BigInt(0):m2(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),yF=me("$ZodCheckNumberFormat",(e,t)=>{Pn.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),a=n?"int":"number",[r,i]=y2[t.format];e._zod.onattach.push(s=>{const c=s._zod.bag;c.format=t.format,c.minimum=r,c.maximum=i,n&&(c.pattern=cF)}),e._zod.check=s=>{const c=s.value;if(n){if(!Number.isInteger(c)){s.issues.push({expected:a,format:t.format,code:"invalid_type",continue:!1,input:c,inst:e});return}if(!Number.isSafeInteger(c)){c>0?s.issues.push({input:c,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:a,continue:!t.abort}):s.issues.push({input:c,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:a,continue:!t.abort});return}}c<r&&s.issues.push({origin:"number",input:c,code:"too_small",minimum:r,inclusive:!0,inst:e,continue:!t.abort}),c>i&&s.issues.push({origin:"number",input:c,code:"too_big",maximum:i,inst:e})}}),wF=me("$ZodCheckBigIntFormat",(e,t)=>{Pn.init(e,t);const[n,a]=w2[t.format];e._zod.onattach.push(r=>{const i=r._zod.bag;i.format=t.format,i.minimum=n,i.maximum=a}),e._zod.check=r=>{const i=r.value;i<n&&r.issues.push({origin:"bigint",input:i,code:"too_small",minimum:n,inclusive:!0,inst:e,continue:!t.abort}),i>a&&r.issues.push({origin:"bigint",input:i,code:"too_big",maximum:a,inst:e})}}),SF=me("$ZodCheckMaxSize",(e,t)=>{var n;Pn.init(e,t),(n=e._zod.def).when??(n.when=a=>{const r=a.value;return!zl(r)&&r.size!==void 0}),e._zod.onattach.push(a=>{const r=a._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<r&&(a._zod.bag.maximum=t.maximum)}),e._zod.check=a=>{const r=a.value;r.size<=t.maximum||a.issues.push({origin:pv(r),code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),xF=me("$ZodCheckMinSize",(e,t)=>{var n;Pn.init(e,t),(n=e._zod.def).when??(n.when=a=>{const r=a.value;return!zl(r)&&r.size!==void 0}),e._zod.onattach.push(a=>{const r=a._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>r&&(a._zod.bag.minimum=t.minimum)}),e._zod.check=a=>{const r=a.value;r.size>=t.minimum||a.issues.push({origin:pv(r),code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),EF=me("$ZodCheckSizeEquals",(e,t)=>{var n;Pn.init(e,t),(n=e._zod.def).when??(n.when=a=>{const r=a.value;return!zl(r)&&r.size!==void 0}),e._zod.onattach.push(a=>{const r=a._zod.bag;r.minimum=t.size,r.maximum=t.size,r.size=t.size}),e._zod.check=a=>{const r=a.value,i=r.size;if(i===t.size)return;const s=i>t.size;a.issues.push({origin:pv(r),...s?{code:"too_big",maximum:t.size}:{code:"too_small",minimum:t.size},inclusive:!0,exact:!0,input:a.value,inst:e,continue:!t.abort})}}),_F=me("$ZodCheckMaxLength",(e,t)=>{var n;Pn.init(e,t),(n=e._zod.def).when??(n.when=a=>{const r=a.value;return!zl(r)&&r.length!==void 0}),e._zod.onattach.push(a=>{const r=a._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<r&&(a._zod.bag.maximum=t.maximum)}),e._zod.check=a=>{const r=a.value;if(r.length<=t.maximum)return;const s=mv(r);a.issues.push({origin:s,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),kF=me("$ZodCheckMinLength",(e,t)=>{var n;Pn.init(e,t),(n=e._zod.def).when??(n.when=a=>{const r=a.value;return!zl(r)&&r.length!==void 0}),e._zod.onattach.push(a=>{const r=a._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>r&&(a._zod.bag.minimum=t.minimum)}),e._zod.check=a=>{const r=a.value;if(r.length>=t.minimum)return;const s=mv(r);a.issues.push({origin:s,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),TF=me("$ZodCheckLengthEquals",(e,t)=>{var n;Pn.init(e,t),(n=e._zod.def).when??(n.when=a=>{const r=a.value;return!zl(r)&&r.length!==void 0}),e._zod.onattach.push(a=>{const r=a._zod.bag;r.minimum=t.length,r.maximum=t.length,r.length=t.length}),e._zod.check=a=>{const r=a.value,i=r.length;if(i===t.length)return;const s=mv(r),c=i>t.length;a.issues.push({origin:s,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:a.value,inst:e,continue:!t.abort})}}),Ap=me("$ZodCheckStringFormat",(e,t)=>{var n,a;Pn.init(e,t),e._zod.onattach.push(r=>{const i=r._zod.bag;i.format=t.format,t.pattern&&(i.patterns??(i.patterns=new Set),i.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:t.format,input:r.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(a=e._zod).check??(a.check=()=>{})}),NF=me("$ZodCheckRegex",(e,t)=>{Ap.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),RF=me("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=mF),Ap.init(e,t)}),CF=me("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=hF),Ap.init(e,t)}),AF=me("$ZodCheckIncludes",(e,t)=>{Pn.init(e,t);const n=No(t.includes),a=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=a,e._zod.onattach.push(r=>{const i=r._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(a)}),e._zod.check=r=>{r.value.includes(t.includes,t.position)||r.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:r.value,inst:e,continue:!t.abort})}}),IF=me("$ZodCheckStartsWith",(e,t)=>{Pn.init(e,t);const n=new RegExp(`^${No(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(a=>{const r=a._zod.bag;r.patterns??(r.patterns=new Set),r.patterns.add(n)}),e._zod.check=a=>{a.value.startsWith(t.prefix)||a.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:a.value,inst:e,continue:!t.abort})}}),OF=me("$ZodCheckEndsWith",(e,t)=>{Pn.init(e,t);const n=new RegExp(`.*${No(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(a=>{const r=a._zod.bag;r.patterns??(r.patterns=new Set),r.patterns.add(n)}),e._zod.check=a=>{a.value.endsWith(t.suffix)||a.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:a.value,inst:e,continue:!t.abort})}});function mj(e,t,n){e.issues.length&&t.issues.push(...pi(n,e.issues))}const DF=me("$ZodCheckProperty",(e,t)=>{Pn.init(e,t),e._zod.check=n=>{const a=t.schema._zod.run({value:n.value[t.property],issues:[]},{});if(a instanceof Promise)return a.then(r=>mj(r,n,t.property));mj(a,n,t.property)}}),LF=me("$ZodCheckMimeType",(e,t)=>{Pn.init(e,t);const n=new Set(t.mime);e._zod.onattach.push(a=>{a._zod.bag.mime=t.mime}),e._zod.check=a=>{n.has(a.value.type)||a.issues.push({code:"invalid_value",values:t.mime,input:a.value.type,inst:e,continue:!t.abort})}}),$F=me("$ZodCheckOverwrite",(e,t)=>{Pn.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class jF{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const a=t.split(`
4
4
  `).filter(s=>s),r=Math.min(...a.map(s=>s.length-s.trimStart().length)),i=a.map(s=>s.slice(r)).map(s=>" ".repeat(this.indent*2)+s);for(const s of i)this.content.push(s)}compile(){const t=Function,n=this?.args,r=[...(this?.content??[""]).map(i=>` ${i}`)];return new t(...n,r.join(`
5
5
  `))}}const MF={major:4,minor:1,patch:13},vt=me("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=MF;const a=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&a.unshift(e);for(const r of a)for(const i of r._zod.onattach)i(e);if(a.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const r=(s,c,u)=>{let d=bl(s),m;for(const h of c){if(h._zod.def.when){if(!h._zod.def.when(s))continue}else if(d)continue;const g=s.issues.length,v=h._zod.check(s);if(v instanceof Promise&&u?.async===!1)throw new El;if(m||v instanceof Promise)m=(m??Promise.resolve()).then(async()=>{await v,s.issues.length!==g&&(d||(d=bl(s,g)))});else{if(s.issues.length===g)continue;d||(d=bl(s,g))}}return m?m.then(()=>s):s},i=(s,c,u)=>{if(bl(s))return s.aborted=!0,s;const d=r(c,a,u);if(d instanceof Promise){if(u.async===!1)throw new El;return d.then(m=>e._zod.parse(m,u))}return e._zod.parse(d,u)};e._zod.run=(s,c)=>{if(c.skipChecks)return e._zod.parse(s,c);if(c.direction==="backward"){const d=e._zod.parse({value:s.value,issues:[]},{...c,skipChecks:!0});return d instanceof Promise?d.then(m=>i(m,s,c)):i(d,s,c)}const u=e._zod.parse(s,c);if(u instanceof Promise){if(c.async===!1)throw new El;return u.then(d=>r(d,a,c))}return r(u,a,c)}}e["~standard"]={validate:r=>{try{const i=w_(e,r);return i.success?{value:i.data}:{issues:i.error?.issues}}catch{return $2(e,r).then(s=>s.success?{value:s.data}:{issues:s.error?.issues})}},vendor:"zod",version:1}}),Ip=me("$ZodString",(e,t)=>{vt.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??sF(e._zod.bag),e._zod.parse=(n,a)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value=="string"||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),xn=me("$ZodStringFormat",(e,t)=>{Ap.init(e,t),Ip.init(e,t)}),PF=me("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=H2),xn.init(e,t)}),UF=me("$ZodUUID",(e,t)=>{if(t.version){const a={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(a===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Cu(a))}else t.pattern??(t.pattern=Cu());xn.init(e,t)}),zF=me("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=V2),xn.init(e,t)}),FF=me("$ZodURL",(e,t)=>{xn.init(e,t),e._zod.check=n=>{try{const a=n.value.trim(),r=new URL(a);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(r.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(r.protocol.endsWith(":")?r.protocol.slice(0,-1):r.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=r.href:n.value=a;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),BF=me("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=W2()),xn.init(e,t)}),HF=me("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=F2),xn.init(e,t)}),VF=me("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=j2),xn.init(e,t)}),GF=me("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=M2),xn.init(e,t)}),WF=me("$ZodULID",(e,t)=>{t.pattern??(t.pattern=P2),xn.init(e,t)}),KF=me("$ZodXID",(e,t)=>{t.pattern??(t.pattern=U2),xn.init(e,t)}),ZF=me("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=z2),xn.init(e,t)}),YF=me("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=oF(t)),xn.init(e,t)}),XF=me("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=rF),xn.init(e,t)}),qF=me("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=iF(t)),xn.init(e,t)}),JF=me("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=B2),xn.init(e,t)}),QF=me("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=K2),xn.init(e,t),e._zod.bag.format="ipv4"}),e3=me("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Z2),xn.init(e,t),e._zod.bag.format="ipv6",e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}}),t3=me("$ZodMAC",(e,t)=>{t.pattern??(t.pattern=Y2(t.delimiter)),xn.init(e,t),e._zod.bag.format="mac"}),n3=me("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=X2),xn.init(e,t)}),r3=me("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=q2),xn.init(e,t),e._zod.check=n=>{const a=n.value.split("/");try{if(a.length!==2)throw new Error;const[r,i]=a;if(!i)throw new Error;const s=Number(i);if(`${s}`!==i)throw new Error;if(s<0||s>128)throw new Error;new URL(`http://[${r}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function D_(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const a3=me("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=J2),xn.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{D_(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function i3(e){if(!C_.test(e))return!1;const t=e.replace(/[-_]/g,a=>a==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return D_(n)}const o3=me("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=C_),xn.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{i3(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),s3=me("$ZodE164",(e,t)=>{t.pattern??(t.pattern=tF),xn.init(e,t)});function l3(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[a]=n;if(!a)return!1;const r=JSON.parse(atob(a));return!("typ"in r&&r?.typ!=="JWT"||!r.alg||t&&(!("alg"in r)||r.alg!==t))}catch{return!1}}const c3=me("$ZodJWT",(e,t)=>{xn.init(e,t),e._zod.check=n=>{l3(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),u3=me("$ZodCustomStringFormat",(e,t)=>{xn.init(e,t),e._zod.check=n=>{t.fn(n.value)||n.issues.push({code:"invalid_format",format:t.format,input:n.value,inst:e,continue:!t.abort})}}),L_=me("$ZodNumber",(e,t)=>{vt.init(e,t),e._zod.pattern=e._zod.bag.pattern??uF,e._zod.parse=(n,a)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}const r=n.value;if(typeof r=="number"&&!Number.isNaN(r)&&Number.isFinite(r))return n;const i=typeof r=="number"?Number.isNaN(r)?"NaN":Number.isFinite(r)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:r,inst:e,...i?{received:i}:{}}),n}}),d3=me("$ZodNumberFormat",(e,t)=>{yF.init(e,t),L_.init(e,t)}),$_=me("$ZodBoolean",(e,t)=>{vt.init(e,t),e._zod.pattern=dF,e._zod.parse=(n,a)=>{if(t.coerce)try{n.value=!!n.value}catch{}const r=n.value;return typeof r=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:r,inst:e}),n}}),j_=me("$ZodBigInt",(e,t)=>{vt.init(e,t),e._zod.pattern=lF,e._zod.parse=(n,a)=>{if(t.coerce)try{n.value=BigInt(n.value)}catch{}return typeof n.value=="bigint"||n.issues.push({expected:"bigint",code:"invalid_type",input:n.value,inst:e}),n}}),f3=me("$ZodBigIntFormat",(e,t)=>{wF.init(e,t),j_.init(e,t)}),p3=me("$ZodSymbol",(e,t)=>{vt.init(e,t),e._zod.parse=(n,a)=>{const r=n.value;return typeof r=="symbol"||n.issues.push({expected:"symbol",code:"invalid_type",input:r,inst:e}),n}}),m3=me("$ZodUndefined",(e,t)=>{vt.init(e,t),e._zod.pattern=pF,e._zod.values=new Set([void 0]),e._zod.optin="optional",e._zod.optout="optional",e._zod.parse=(n,a)=>{const r=n.value;return typeof r>"u"||n.issues.push({expected:"undefined",code:"invalid_type",input:r,inst:e}),n}}),h3=me("$ZodNull",(e,t)=>{vt.init(e,t),e._zod.pattern=fF,e._zod.values=new Set([null]),e._zod.parse=(n,a)=>{const r=n.value;return r===null||n.issues.push({expected:"null",code:"invalid_type",input:r,inst:e}),n}}),g3=me("$ZodAny",(e,t)=>{vt.init(e,t),e._zod.parse=n=>n}),b3=me("$ZodUnknown",(e,t)=>{vt.init(e,t),e._zod.parse=n=>n}),v3=me("$ZodNever",(e,t)=>{vt.init(e,t),e._zod.parse=(n,a)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)}),y3=me("$ZodVoid",(e,t)=>{vt.init(e,t),e._zod.parse=(n,a)=>{const r=n.value;return typeof r>"u"||n.issues.push({expected:"void",code:"invalid_type",input:r,inst:e}),n}}),w3=me("$ZodDate",(e,t)=>{vt.init(e,t),e._zod.parse=(n,a)=>{if(t.coerce)try{n.value=new Date(n.value)}catch{}const r=n.value,i=r instanceof Date;return i&&!Number.isNaN(r.getTime())||n.issues.push({expected:"date",code:"invalid_type",input:r,...i?{received:"Invalid Date"}:{},inst:e}),n}});function hj(e,t,n){e.issues.length&&t.issues.push(...pi(n,e.issues)),t.value[n]=e.value}const S3=me("$ZodArray",(e,t)=>{vt.init(e,t),e._zod.parse=(n,a)=>{const r=n.value;if(!Array.isArray(r))return n.issues.push({expected:"array",code:"invalid_type",input:r,inst:e}),n;n.value=Array(r.length);const i=[];for(let s=0;s<r.length;s++){const c=r[s],u=t.element._zod.run({value:c,issues:[]},a);u instanceof Promise?i.push(u.then(d=>hj(d,n,s))):hj(u,n,s)}return i.length?Promise.all(i).then(()=>n):n}});function ub(e,t,n,a){e.issues.length&&t.issues.push(...pi(n,e.issues)),e.value===void 0?n in a&&(t.value[n]=void 0):t.value[n]=e.value}function x3(e){const t=Object.keys(e.shape);for(const a of t)if(!e.shape?.[a]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${a}": expected a Zod schema`);const n=v2(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function E3(e,t,n,a,r,i){const s=[],c=r.keySet,u=r.catchall._zod,d=u.def.type;for(const m in t){if(c.has(m))continue;if(d==="never"){s.push(m);continue}const h=u.run({value:t[m],issues:[]},a);h instanceof Promise?e.push(h.then(g=>ub(g,n,m,t))):ub(h,n,m,t)}return s.length&&n.issues.push({code:"unrecognized_keys",keys:s,input:t,inst:i}),e.length?Promise.all(e).then(()=>n):n}const _3=me("$ZodObject",(e,t)=>{if(vt.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){const c=t.shape;Object.defineProperty(t,"shape",{get:()=>{const u={...c};return Object.defineProperty(t,"shape",{value:u}),u}})}const a=Ep(()=>x3(t));Lt(e._zod,"propValues",()=>{const c=t.shape,u={};for(const d in c){const m=c[d]._zod;if(m.values){u[d]??(u[d]=new Set);for(const h of m.values)u[d].add(h)}}return u});const r=Nu,i=t.catchall;let s;e._zod.parse=(c,u)=>{s??(s=a.value);const d=c.value;if(!r(d))return c.issues.push({expected:"object",code:"invalid_type",input:d,inst:e}),c;c.value={};const m=[],h=s.shape;for(const g of s.keys){const w=h[g]._zod.run({value:d[g],issues:[]},u);w instanceof Promise?m.push(w.then(S=>ub(S,c,g,d))):ub(w,c,g,d)}return i?E3(m,d,c,u,a.value,e):m.length?Promise.all(m).then(()=>c):c}}),k3=me("$ZodObjectJIT",(e,t)=>{_3.init(e,t);const n=e._zod.parse,a=Ep(()=>x3(t)),r=g=>{const v=new jF(["shape","payload","ctx"]),w=a.value,S=k=>{const C=dx(k);return`shape[${C}]._zod.run({ value: input[${C}], issues: [] }, ctx)`};v.write("const input = payload.value;");const y=Object.create(null);let _=0;for(const k of w.keys)y[k]=`key_${_++}`;v.write("const newResult = {};");for(const k of w.keys){const C=y[k],R=dx(k);v.write(`const ${C} = ${S(k)};`),v.write(`
@@ -41,7 +41,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
41
41
  <p>You can close this window or <a href="#" onclick="window.close(); return false;">click here to close</a>.</p>
42
42
  <pre style="font-size: 0.8em; color: #555; margin-top: 20px; white-space: pre-wrap;">${d instanceof Error?d.stack:""}</pre>
43
43
  </div>
44
- `}catch(h){console.error(`${i} Could not display error in callback window:`,h)}u&&localStorage.removeItem(u),s&&(localStorage.removeItem(s.getKey("code_verifier")),localStorage.removeItem(s.getKey("last_auth_url")))}}Ge(ST,"onMcpAuthorization");var lS={exports:{}},bt={};var oP;function Dae(){if(oP)return bt;oP=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),a=Symbol.for("react.strict_mode"),r=Symbol.for("react.profiler"),i=Symbol.for("react.consumer"),s=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),d=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),h=Symbol.for("react.activity"),g=Symbol.iterator;function v($){return $===null||typeof $!="object"?null:($=g&&$[g]||$["@@iterator"],typeof $=="function"?$:null)}var w={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},S=Object.assign,y={};function _($,B,U){this.props=$,this.context=B,this.refs=y,this.updater=U||w}_.prototype.isReactComponent={},_.prototype.setState=function($,B){if(typeof $!="object"&&typeof $!="function"&&$!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,$,B,"setState")},_.prototype.forceUpdate=function($){this.updater.enqueueForceUpdate(this,$,"forceUpdate")};function E(){}E.prototype=_.prototype;function k($,B,U){this.props=$,this.context=B,this.refs=y,this.updater=U||w}var C=k.prototype=new E;C.constructor=k,S(C,_.prototype),C.isPureReactComponent=!0;var R=Array.isArray;function A(){}var I={H:null,A:null,T:null,S:null},O=Object.prototype.hasOwnProperty;function j($,B,U){var L=U.ref;return{$$typeof:e,type:$,key:B,ref:L!==void 0?L:null,props:U}}function F($,B){return j($.type,B,$.props)}function H($){return typeof $=="object"&&$!==null&&$.$$typeof===e}function K($){var B={"=":"=0",":":"=2"};return"$"+$.replace(/[=:]/g,function(U){return B[U]})}var Q=/\/+/g;function W($,B){return typeof $=="object"&&$!==null&&$.key!=null?K(""+$.key):B.toString(36)}function ie($){switch($.status){case"fulfilled":return $.value;case"rejected":throw $.reason;default:switch(typeof $.status=="string"?$.then(A,A):($.status="pending",$.then(function(B){$.status==="pending"&&($.status="fulfilled",$.value=B)},function(B){$.status==="pending"&&($.status="rejected",$.reason=B)})),$.status){case"fulfilled":return $.value;case"rejected":throw $.reason}}throw $}function V($,B,U,L,P){var G=typeof $;(G==="undefined"||G==="boolean")&&($=null);var Z=!1;if($===null)Z=!0;else switch(G){case"bigint":case"string":case"number":Z=!0;break;case"object":switch($.$$typeof){case e:case t:Z=!0;break;case m:return Z=$._init,V(Z($._payload),B,U,L,P)}}if(Z)return P=P($),Z=L===""?"."+W($,0):L,R(P)?(U="",Z!=null&&(U=Z.replace(Q,"$&/")+"/"),V(P,B,U,"",function(le){return le})):P!=null&&(H(P)&&(P=F(P,U+(P.key==null||$&&$.key===P.key?"":(""+P.key).replace(Q,"$&/")+"/")+Z)),B.push(P)),1;Z=0;var J=L===""?".":L+":";if(R($))for(var se=0;se<$.length;se++)L=$[se],G=J+W(L,se),Z+=V(L,B,U,G,P);else if(se=v($),typeof se=="function")for($=se.call($),se=0;!(L=$.next()).done;)L=L.value,G=J+W(L,se++),Z+=V(L,B,U,G,P);else if(G==="object"){if(typeof $.then=="function")return V(ie($),B,U,L,P);throw B=String($),Error("Objects are not valid as a React child (found: "+(B==="[object Object]"?"object with keys {"+Object.keys($).join(", ")+"}":B)+"). If you meant to render a collection of children, use an array instead.")}return Z}function Y($,B,U){if($==null)return $;var L=[],P=0;return V($,L,"","",function(G){return B.call(U,G,P++)}),L}function z($){if($._status===-1){var B=$._result;B=B(),B.then(function(U){($._status===0||$._status===-1)&&($._status=1,$._result=U)},function(U){($._status===0||$._status===-1)&&($._status=2,$._result=U)}),$._status===-1&&($._status=0,$._result=B)}if($._status===1)return $._result.default;throw $._result}var te=typeof reportError=="function"?reportError:function($){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var B=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof $=="object"&&$!==null&&typeof $.message=="string"?String($.message):String($),error:$});if(!window.dispatchEvent(B))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",$);return}console.error($)},re={map:Y,forEach:function($,B,U){Y($,function(){B.apply(this,arguments)},U)},count:function($){var B=0;return Y($,function(){B++}),B},toArray:function($){return Y($,function(B){return B})||[]},only:function($){if(!H($))throw Error("React.Children.only expected to receive a single React element child.");return $}};return bt.Activity=h,bt.Children=re,bt.Component=_,bt.Fragment=n,bt.Profiler=r,bt.PureComponent=k,bt.StrictMode=a,bt.Suspense=u,bt.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=I,bt.__COMPILER_RUNTIME={__proto__:null,c:function($){return I.H.useMemoCache($)}},bt.cache=function($){return function(){return $.apply(null,arguments)}},bt.cacheSignal=function(){return null},bt.cloneElement=function($,B,U){if($==null)throw Error("The argument must be a React element, but you passed "+$+".");var L=S({},$.props),P=$.key;if(B!=null)for(G in B.key!==void 0&&(P=""+B.key),B)!O.call(B,G)||G==="key"||G==="__self"||G==="__source"||G==="ref"&&B.ref===void 0||(L[G]=B[G]);var G=arguments.length-2;if(G===1)L.children=U;else if(1<G){for(var Z=Array(G),J=0;J<G;J++)Z[J]=arguments[J+2];L.children=Z}return j($.type,P,L)},bt.createContext=function($){return $={$$typeof:s,_currentValue:$,_currentValue2:$,_threadCount:0,Provider:null,Consumer:null},$.Provider=$,$.Consumer={$$typeof:i,_context:$},$},bt.createElement=function($,B,U){var L,P={},G=null;if(B!=null)for(L in B.key!==void 0&&(G=""+B.key),B)O.call(B,L)&&L!=="key"&&L!=="__self"&&L!=="__source"&&(P[L]=B[L]);var Z=arguments.length-2;if(Z===1)P.children=U;else if(1<Z){for(var J=Array(Z),se=0;se<Z;se++)J[se]=arguments[se+2];P.children=J}if($&&$.defaultProps)for(L in Z=$.defaultProps,Z)P[L]===void 0&&(P[L]=Z[L]);return j($,G,P)},bt.createRef=function(){return{current:null}},bt.forwardRef=function($){return{$$typeof:c,render:$}},bt.isValidElement=H,bt.lazy=function($){return{$$typeof:m,_payload:{_status:-1,_result:$},_init:z}},bt.memo=function($,B){return{$$typeof:d,type:$,compare:B===void 0?null:B}},bt.startTransition=function($){var B=I.T,U={};I.T=U;try{var L=$(),P=I.S;P!==null&&P(U,L),typeof L=="object"&&L!==null&&typeof L.then=="function"&&L.then(A,te)}catch(G){te(G)}finally{B!==null&&U.types!==null&&(B.types=U.types),I.T=B}},bt.unstable_useCacheRefresh=function(){return I.H.useCacheRefresh()},bt.use=function($){return I.H.use($)},bt.useActionState=function($,B,U){return I.H.useActionState($,B,U)},bt.useCallback=function($,B){return I.H.useCallback($,B)},bt.useContext=function($){return I.H.useContext($)},bt.useDebugValue=function(){},bt.useDeferredValue=function($,B){return I.H.useDeferredValue($,B)},bt.useEffect=function($,B){return I.H.useEffect($,B)},bt.useEffectEvent=function($){return I.H.useEffectEvent($)},bt.useId=function(){return I.H.useId()},bt.useImperativeHandle=function($,B,U){return I.H.useImperativeHandle($,B,U)},bt.useInsertionEffect=function($,B){return I.H.useInsertionEffect($,B)},bt.useLayoutEffect=function($,B){return I.H.useLayoutEffect($,B)},bt.useMemo=function($,B){return I.H.useMemo($,B)},bt.useOptimistic=function($,B){return I.H.useOptimistic($,B)},bt.useReducer=function($,B,U){return I.H.useReducer($,B,U)},bt.useRef=function($){return I.H.useRef($)},bt.useState=function($){return I.H.useState($)},bt.useSyncExternalStore=function($,B,U){return I.H.useSyncExternalStore($,B,U)},bt.useTransition=function(){return I.H.useTransition()},bt.version="19.2.0",bt}var sP;function xT(){return sP||(sP=1,lS.exports=Dae()),lS.exports}var x=xT();const ue=xp(x),Pp=cX({__proto__:null,default:ue},[x]);function Fx(e,t){if(!e)throw new Error(t)}Ge(Fx,"assert");var Lae=3e3,$ae=5e3;function ET(e){const{url:t,enabled:n=!0,clientName:a,clientUri:r,callbackUrl:i=typeof window<"u"?qc(new URL("/oauth/callback",window.location.origin).toString()):"/oauth/callback",storageKeyPrefix:s="mcp:auth",clientConfig:c={},customHeaders:u={},debug:d=!1,autoRetry:m=!1,autoReconnect:h=Lae,transportType:g="auto",preventAutoAuth:v=!1,useRedirectFlow:w=!1,onPopupWindow:S,timeout:y=3e4,sseReadTimeout:_=3e5,wrapTransport:E,onNotification:k,samplingCallback:C}=e,[R,A]=x.useState("discovering"),[I,O]=x.useState([]),[j,F]=x.useState([]),[H,K]=x.useState([]),[Q,W]=x.useState([]),[ie,V]=x.useState(),[Y,z]=x.useState(),[te,re]=x.useState(void 0),[$,B]=x.useState([]),[U,L]=x.useState(void 0),P=x.useRef(null),G=x.useRef(null),Z=x.useRef(!1),J=x.useRef(!0),se=x.useRef(0),le=x.useRef(null),ee=x.useRef(R),ne=x.useRef(h),ce=x.useRef(null);x.useEffect(()=>{ee.current=R,ne.current=h},[R,h]);const ae=x.useCallback((Pe,$e,...et)=>{const an=et.length>0?`${$e} ${et.map(Qe=>JSON.stringify(Qe)).join(" ")}`:$e;console[Pe](`[useMcp] ${an}`),J.current&&B(Qe=>[...Qe.slice(-100),{level:Pe,message:an,timestamp:Date.now()}])},[]),ye=x.useCallback(async(Pe=!1)=>{if(Pe||ae("info","Disconnecting..."),Z.current=!1,le.current&&clearTimeout(le.current),le.current=null,P.current)try{await P.current.closeSession("inspector-server")}catch($e){Pe||ae("warn","Error closing session:",$e)}P.current=null,J.current&&!Pe&&(A("discovering"),O([]),F([]),K([]),W([]),re(void 0),L(void 0))},[ae]),ke=x.useCallback((Pe,$e)=>{if(ae("error",Pe,$e??""),J.current){A("failed"),re(Pe);const et=G.current?.getLastAttemptedAuthUrl();et&&(L(et),ae("info","Manual authentication URL may be available.",et))}Z.current=!1},[ae]),Be=x.useCallback(async()=>{if(!n||!t){ae("debug",n?"No server URL provided, skipping connection.":"Connection disabled via enabled flag.");return}if(Z.current){ae("debug","Connection attempt already in progress.");return}if(!J.current){ae("debug","Connect called after unmount, aborting.");return}Z.current=!0,se.current+=1,re(void 0),L(void 0),ce.current=null,A("discovering"),ae("info",`Connecting attempt #${se.current} to ${t}...`),G.current||(G.current=new Fg(t,{storageKeyPrefix:s,clientName:a,clientUri:r,callbackUrl:i,preventAutoAuth:v,useRedirectFlow:w,onPopupWindow:S}),ae("debug","BrowserOAuthClientProvider initialized in connect.")),P.current||(P.current=new Oae,ae("debug","BrowserMCPClient initialized in connect."));const Pe=Ge(async(et,an=!1)=>{ae("info",`Attempting connection with transport: ${et}`);try{const Qe="inspector-server",Ae={url:t,transport:et==="sse"?"http":et};if(u&&Object.keys(u).length>0&&(Ae.headers=u),G.current){const mt=await G.current.tokens();mt?.access_token&&(Ae.headers={...Ae.headers,Authorization:`Bearer ${mt.access_token}`})}P.current.addServer(Qe,{...Ae,authProvider:G.current,clientOptions:c,samplingCallback:C,wrapTransport:E?mt=>(console.log("[useMcp] Applying transport wrapper for server:",Qe,"url:",t),E(mt,t)):void 0});const Ie=await P.current.createSession(Qe,!1);k&&Ie.on("notification",k),await Ie.initialize(),ae("info","✅ Successfully connected to MCP server"),ae("info","Server info:",Ie.connector.serverInfo),ae("info","Server capabilities:",Ie.connector.serverCapabilities),console.log("[useMcp] Server info:",Ie.connector.serverInfo),console.log("[useMcp] Server capabilities:",Ie.connector.serverCapabilities),A("ready"),ce.current=et,O(Ie.connector.tools||[]);const Ye=await Ie.connector.listAllResources();F(Ye.resources||[]);const tt=await Ie.connector.listPrompts();W(tt.prompts||[]);const it=Ie.connector.serverInfo,gt=Ie.connector.serverCapabilities;return it&&(console.log("[useMcp] Server info:",it),V(it)),gt&&(console.log("[useMcp] Server capabilities:",gt),z(gt)),"success"}catch(Qe){const Ae=Qe?.message||String(Qe);if(Qe.code===401||Ae.includes("401")||Ae.includes("Unauthorized")){if(G.current){ae("info","Authentication required. OAuth provider available.");try{const{auth:Ie}=await Ar(async()=>{const{auth:tt}=await Promise.resolve().then(()=>JM);return{auth:tt}},void 0),Ye=new URL(t).origin;Ie(G.current,{serverUrl:Ye}).catch(()=>{}),setTimeout(()=>{if(J.current){const tt=G.current?.getLastAttemptedAuthUrl();tt?(L(tt),ae("info","Manual authentication URL available:",tt)):ae("warn","Could not generate authentication URL")}},100)}catch(Ie){ae("warn","Error generating auth URL:",Ie)}return J.current&&A("pending_auth"),Z.current=!1,"auth_redirect"}return u&&Object.keys(u).length>0?(ke("Authentication failed: Server returned 401 Unauthorized. Check your Authorization header value is correct."),"failed"):(ke("Authentication required: Server returned 401 Unauthorized. Add an Authorization header in the Custom Headers section (e.g., Authorization: Bearer YOUR_API_KEY)."),"failed")}return ke(Ae,Qe),"failed"}},"tryConnectWithTransport");let $e="failed";if(g==="sse")ae("debug","Using SSE-only transport mode"),$e=await Pe("sse");else if(g==="http")ae("debug","Using HTTP-only transport mode"),$e=await Pe("http");else{ae("debug","Using auto transport mode (HTTP with SSE fallback)");const et=await Pe("http");et==="fallback"&&J.current&&ee.current!=="authenticating"?(ae("info","HTTP failed, attempting SSE fallback..."),$e=await Pe("sse")):$e=et}($e==="success"||$e==="failed"||$e==="auth_redirect")&&(Z.current=!1),ae("debug",`Connection sequence finished with status: ${$e}`)},[ae,ke,ye,t,s,a,r,i,c.name,c.version,u,g,v,w,S,n,y,_]),_e=x.useCallback(async(Pe,$e,et)=>{if(ee.current!=="ready"||!P.current)throw new Error(`MCP client is not ready (current state: ${R}). Cannot call tool "${Pe}".`);ae("info",`Calling tool: ${Pe}`,$e);try{const Qe=P.current.getSession("inspector-server");if(!Qe)throw new Error("No active session found");const Ae=await Qe.connector.callTool(Pe,$e||{},et);return ae("info",`Tool "${Pe}" call successful:`,Ae),Ae}catch(an){throw ae("error",`Tool "${Pe}" call failed:`,an),an}},[R]),Se=x.useCallback(()=>{ee.current==="failed"?(ae("info","Retry requested..."),Be()):ae("warn",`Retry called but state is not 'failed' (state: ${ee.current}). Ignoring.`)},[ae,Be]),ze=x.useCallback(async()=>{ae("info","Manual authentication requested...");const Pe=ee.current;if(Pe==="failed")ae("info","Attempting to reconnect and authenticate via retry..."),Se();else if(Pe==="pending_auth"){ae("info","Proceeding with authentication from pending state...");try{Fx(G.current,"Auth Provider not available for manual auth"),Fx(t,"Server URL is required for authentication"),ae("info","Clearing all OAuth state and initiating fresh flow...");const $e=`${s}:${G.current.serverUrlHash}`;Object.keys(localStorage).forEach(Ae=>{Ae.startsWith($e)&&(ae("debug",`Removing stale OAuth key: ${Ae}`),localStorage.removeItem(Ae)),Ae.startsWith(`${s}:state_`)&&(ae("debug",`Removing orphaned state: ${Ae}`),localStorage.removeItem(Ae))}),A("authenticating");const et=new Fg(t,{storageKeyPrefix:s,clientName:a,clientUri:r,callbackUrl:i,preventAutoAuth:!1,useRedirectFlow:w,onPopupWindow:S});G.current=et,ae("info","Triggering fresh OAuth authorization...");const{auth:an}=await Ar(async()=>{const{auth:Ae}=await Promise.resolve().then(()=>JM);return{auth:Ae}},void 0),Qe=new URL(t).origin;an(et,{serverUrl:Qe}).catch(Ae=>{ae("info","OAuth flow initiated:",Ae?.message||"Redirecting...")})}catch($e){if(!J.current)return;A("pending_auth"),ae("error",`Manual authentication failed: ${$e instanceof Error?$e.message:String($e)}`)}}else if(Pe==="authenticating"){ae("warn","Already attempting authentication. Check for blocked popups or wait for timeout.");const $e=G.current?.getLastAttemptedAuthUrl();$e&&!U&&(L($e),ae("info","Manual authentication URL retrieved:",$e))}else ae("info",`Client not in a state requiring manual authentication trigger (state: ${Pe}). If needed, try disconnecting and reconnecting.`)},[ae,Se,U,t,w,S,s,a,r,i]),pe=x.useCallback(()=>{if(G.current){const Pe=G.current.clearStorage();ae("info",`Cleared ${Pe} item(s) from localStorage for ${t}.`),L(void 0),ye()}else ae("warn","Auth provider not initialized, cannot clear storage.")},[t,ae,ye]),Le=x.useCallback(async()=>{if(ee.current!=="ready"||!P.current)throw new Error(`MCP client is not ready (current state: ${R}). Cannot list resources.`);ae("info","Listing resources");try{const $e=P.current.getSession("inspector-server");if(!$e)throw new Error("No active session found");const et=await $e.connector.listAllResources();F(et.resources||[]),ae("info","Resources listed successfully")}catch(Pe){throw ae("error","List resources failed:",Pe),Pe}},[R]),Fe=x.useCallback(async Pe=>{if(ee.current!=="ready"||!P.current)throw new Error(`MCP client is not ready (current state: ${R}). Cannot read resource.`);ae("info",`Reading resource: ${Pe}`);try{const et=P.current.getSession("inspector-server");if(!et)throw new Error("No active session found");const an=await et.connector.readResource(Pe);return ae("info","Resource read successful:",an),an}catch($e){throw ae("error","Resource read failed:",$e),$e}},[R]),xe=x.useCallback(async()=>{if(ee.current!=="ready"||!P.current)throw new Error(`MCP client is not ready (current state: ${R}). Cannot list prompts.`);ae("info","Listing prompts");try{const $e=P.current.getSession("inspector-server");if(!$e)throw new Error("No active session found");const et=await $e.connector.listPrompts();W(et.prompts||[]),ae("info","Prompts listed successfully")}catch(Pe){throw ae("error","List prompts failed:",Pe),Pe}},[R]),st=x.useCallback(async(Pe,$e)=>{if(ee.current!=="ready"||!P.current)throw new Error(`MCP client is not ready (current state: ${R}). Cannot get prompt.`);ae("info",`Getting prompt: ${Pe}`,$e);try{const an=P.current.getSession("inspector-server");if(!an)throw new Error("No active session found");const Qe=await an.connector.getPrompt(Pe,$e||{});return ae("info",`Prompt "${Pe}" retrieved successfully:`,Qe),Qe}catch(et){throw ae("error",`Prompt "${Pe}" retrieval failed:`,et),et}},[R]),at=x.useRef(Be),pt=x.useRef(ke);return x.useEffect(()=>{at.current=Be,pt.current=ke}),x.useEffect(()=>{const Pe=Ge($e=>{$e.origin===window.location.origin&&$e.data?.type==="mcp_auth_callback"&&(ae("info","Received auth callback message.",$e.data),le.current&&clearTimeout(le.current),le.current=null,$e.data.success?(ae("info","Authentication successful via popup. Reconnecting client..."),Z.current&&ae("debug","Connection attempt already in progress, resetting flag to allow reconnection."),Z.current=!1,setTimeout(()=>{J.current&&(ae("debug","Initiating reconnection after successful auth callback."),at.current())},100)):pt.current(`Authentication failed in callback: ${$e.data.error||"Unknown reason."}`))},"messageHandler");return window.addEventListener("message",Pe),ae("debug","Auth callback message listener added."),()=>{window.removeEventListener("message",Pe),ae("debug","Auth callback message listener removed."),le.current&&clearTimeout(le.current)}},[ae]),x.useEffect(()=>(J.current=!0,!n||!t?(ae("debug",n?"No server URL provided, skipping connection.":"Connection disabled via enabled flag."),A("discovering"),()=>{J.current=!1}):(ae("debug","useMcp mounted, initiating connection."),se.current=0,(!G.current||G.current.serverUrl!==t)&&(G.current=new Fg(t,{storageKeyPrefix:s,clientName:a,clientUri:r,callbackUrl:i,preventAutoAuth:v,useRedirectFlow:w,onPopupWindow:S}),ae("debug","BrowserOAuthClientProvider initialized/updated on mount/option change.")),Be(),()=>{J.current=!1,ae("debug","useMcp unmounting, disconnecting."),ye(!0)})),[t,n,s,i,a,r,c.name,c.version,w]),x.useEffect(()=>{let Pe=null;if(R==="failed"&&m&&se.current>0){const $e=typeof m=="number"?m:$ae;ae("info",`Connection failed, auto-retrying in ${$e}ms...`),Pe=setTimeout(()=>{J.current&&ee.current==="failed"&&Se()},$e)}return()=>{Pe&&clearTimeout(Pe)}},[R,m,Se,ae]),{state:R,tools:I,resources:j,resourceTemplates:H,prompts:Q,serverInfo:ie,capabilities:Y,error:te,log:$,authUrl:U,client:P.current,callTool:_e,readResource:Fe,listResources:Le,listPrompts:xe,getPrompt:st,retry:Se,disconnect:ye,authenticate:ze,clearStorage:pe}}Ge(ET,"useMcp");var Tu,jae=(Tu=class extends ue.Component{constructor(t){super(t),this.state={hasError:!1,error:null}}static getDerivedStateFromError(t){return{hasError:!0,error:t}}componentDidCatch(t,n){console.error("Widget Error:",t,n)}render(){return this.state.hasError?ue.createElement("div",{className:"p-4 border border-red-500 bg-red-50 text-red-900 rounded-md dark:bg-red-900/20 dark:text-red-100"},ue.createElement("h3",{className:"font-bold mb-2"},"Widget Error"),ue.createElement("pre",{className:"text-sm whitespace-pre-wrap"},this.state.error?.message)):this.props.children}},Ge(Tu,"ErrorBoundary"),Tu),If="openai:set_globals";function li(e){return x.useSyncExternalStore(t=>{const n=Ge(a=>{a.detail.globals[e]!==void 0&&t()},"handleSetGlobal");return typeof window<"u"&&window.addEventListener(If,n),()=>{typeof window<"u"&&window.removeEventListener(If,n)}},()=>typeof window<"u"&&window.openai?window.openai[e]:void 0)}Ge(li,"useOpenAiGlobal");function Ku(e){const[t,n]=x.useState(()=>typeof window<"u"&&!!window.openai);x.useEffect(()=>{if(typeof window<"u"&&window.openai){n(!0);return}const O=setInterval(()=>{typeof window<"u"&&window.openai&&(n(!0),clearInterval(O))},100),j=Ge(()=>{typeof window<"u"&&window.openai&&(n(!0),clearInterval(O))},"handleSetGlobals");typeof window<"u"&&window.addEventListener(If,j);const F=setTimeout(()=>{clearInterval(O),typeof window<"u"&&window.removeEventListener(If,j)},5e3);return()=>{clearInterval(O),clearTimeout(F),typeof window<"u"&&window.removeEventListener(If,j)}},[]);const a=x.useMemo(()=>t?"openai":"mcp-ui",[t]),r=typeof window<"u"?window.location.search:"",i=x.useMemo(()=>{const O=new URLSearchParams(r);return O.has("mcpUseParams")?JSON.parse(O.get("mcpUseParams")):{toolInput:{},toolOutput:{},toolId:""}},[r]),s=a==="openai"?li("toolInput"):i.toolInput,c=a==="openai"?li("toolOutput"):i.toolOutput,u=li("toolResponseMetadata"),d=li("widgetState"),m=li("theme"),h=li("displayMode"),g=li("safeArea"),v=li("maxHeight"),w=li("userAgent"),S=li("locale"),y=x.useMemo(()=>typeof window<"u"&&window.__mcpPublicUrl?window.__mcpPublicUrl.replace(/\/mcp-use\/public$/,""):"",[]),[_,E]=x.useState(null);x.useEffect(()=>{d!==void 0&&E(d)},[d]);const k=x.useCallback(async(O,j)=>{if(!window.openai?.callTool)throw new Error("window.openai.callTool is not available");return window.openai.callTool(O,j)},[]),C=x.useCallback(async O=>{if(!window.openai?.sendFollowUpMessage)throw new Error("window.openai.sendFollowUpMessage is not available");return window.openai.sendFollowUpMessage({prompt:O})},[]),R=x.useCallback(O=>{if(!window.openai?.openExternal)throw new Error("window.openai.openExternal is not available");window.openai.openExternal({href:O})},[]),A=x.useCallback(async O=>{if(!window.openai?.requestDisplayMode)throw new Error("window.openai.requestDisplayMode is not available");return window.openai.requestDisplayMode({mode:O})},[]),I=x.useCallback(async O=>{if(!window.openai?.setWidgetState)throw new Error("window.openai.setWidgetState is not available");const F=typeof O=="function"?O(d!==void 0?d:_):O;return E(F),window.openai.setWidgetState(F)},[d,_]);return{props:s||e||{},output:c??null,metadata:u??null,state:_,setState:I,theme:m||"light",displayMode:h||"inline",safeArea:g||{insets:{top:0,bottom:0,left:0,right:0}},maxHeight:v||600,userAgent:w||{device:{type:"desktop"},capabilities:{hover:!0,touch:!1}},locale:S||"en",mcp_url:y,callTool:k,sendFollowUpMessage:C,openExternal:R,requestDisplayMode:A,isAvailable:t}}Ge(Ku,"useWidget");function Mae(e){const{props:t}=Ku(e);return t}Ge(Mae,"useWidgetProps");function Pae(){const{theme:e}=Ku();return e}Ge(Pae,"useWidgetTheme");function Uae(e){const{state:t,setState:n}=Ku();return x.useEffect(()=>{t===null&&e!==void 0&&window.openai?.setWidgetState&&n(e)},[]),[t,n]}Ge(Uae,"useWidgetState");var lP=Ge(({children:e})=>{const{theme:t,isAvailable:n}=Ku();console.log("theme",t);const[a,r]=x.useState(()=>typeof window>"u"?"light":window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light");x.useEffect(()=>{if(typeof window>"u")return;const s=window.matchMedia("(prefers-color-scheme: dark)"),c=Ge(u=>{r(u.matches?"dark":"light")},"handleChange");return s.addEventListener("change",c),()=>s.removeEventListener("change",c)},[]);const i=n?t:a;return x.useLayoutEffect(()=>{typeof document>"u"||(i==="dark"?document.documentElement.classList.add("dark"):document.documentElement.classList.remove("dark"))},[i]),ue.createElement(ue.Fragment,null,e)},"ThemeProvider");function rH({children:e,className:t="",position:n="top-right",attachTo:a,showLabels:r=!0,debugger:i=!1,viewControls:s=!1}){const{props:c,output:u,metadata:d,state:m,theme:h,displayMode:g,safeArea:v,maxHeight:w,userAgent:S,locale:y,isAvailable:_,callTool:E,sendFollowUpMessage:k,openExternal:C,requestDisplayMode:R,setState:A}=Ku(),[I,O]=x.useState(!1),[j,F]=x.useState(!1),H=x.useRef(null),K=x.useRef(null),[Q,W]=x.useState([]),[ie,V]=x.useState(""),[Y,z]=x.useState("get-my-city"),[te,re]=x.useState("{}"),[$,B]=x.useState("Test follow-up message"),[U,L]=x.useState("https://docs.mcp-use.com"),P=g==="fullscreen"&&_,G=g==="pip"&&_,Z=typeof window<"u"&&window.location.pathname.includes("/inspector/api/dev-widget/");x.useEffect(()=>{const xe=setTimeout(()=>{if(typeof window<"u"&&window.openai)try{const st=Object.keys(window.openai);W(st)}catch{W([])}else W([])},100);return()=>{clearTimeout(xe)}},[]);const J=h==="dark",se=Ge(()=>{const xe=["absolute","z-[1000]","flex","gap-2","transition-opacity","duration-200","ease-in-out",I?"opacity-100":"opacity-0",I?"pointer-events-auto":"pointer-events-none"];switch(n){case"top-left":return[...xe,"top-4","left-4"];case"top-center":return[...xe,"top-4","left-1/2","-translate-x-1/2"];case"top-right":return[...xe,"top-4","right-4"];case"center-left":return[...xe,"top-1/2","left-4","-translate-y-1/2"];case"center-right":return[...xe,"top-1/2","right-4","-translate-y-1/2"];case"bottom-left":return[...xe,"bottom-4","left-4"];case"bottom-center":return[...xe,"bottom-4","left-1/2","-translate-x-1/2"];case"bottom-right":return[...xe,"bottom-4","right-4"];default:return[...xe,"top-4","right-4"]}},"getPositionClasses"),le=Ge(()=>{const st=v?.insets?.top?Math.max(16,v.insets.top+8):16,at=v?.insets?.right?Math.max(16,v.insets.right+8):16,pt=v?.insets?.bottom?Math.max(16,v.insets.bottom+8):16,Pe=v?.insets?.left?Math.max(16,v.insets.left+8):16,$e={};switch(n){case"top-left":$e.top=`${st}px`,$e.left=`${Pe}px`;break;case"top-center":$e.top=`${st}px`;break;case"top-right":$e.top=`${st}px`,$e.right=`${at}px`;break;case"center-left":$e.left=`${Pe}px`;break;case"center-right":$e.right=`${at}px`;break;case"bottom-left":$e.bottom=`${pt}px`,$e.left=`${Pe}px`;break;case"bottom-center":$e.bottom=`${pt}px`;break;case"bottom-right":$e.bottom=`${pt}px`,$e.right=`${at}px`;break;default:$e.top=`${st}px`,$e.right=`${at}px`;break}return $e},"getPositionOffsetStyles");x.useEffect(()=>{if(!a)return;const xe=Ge(()=>O(!0),"handleMouseEnter"),st=Ge(()=>O(!1),"handleMouseLeave");return a.addEventListener("mouseenter",xe),a.addEventListener("mouseleave",st),()=>{a.removeEventListener("mouseenter",xe),a.removeEventListener("mouseleave",st)}},[a]),x.useEffect(()=>{if(!j)return;const xe=Ge(st=>{K.current&&!K.current.contains(st.target)&&F(!1)},"handleClickOutside");return document.addEventListener("mousedown",xe),()=>{document.removeEventListener("mousedown",xe)}},[j]),x.useEffect(()=>(j?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[j]);const ee=Ge(()=>{F(!j)},"handleToggleOverlay"),ne=Ge(async()=>{try{V("Calling tool...");const xe=te.trim()?JSON.parse(te):{},st=await E(Y,xe);V(`Success: ${JSON.stringify(st,null,2)}`)}catch(xe){V(`Error: ${xe.message}`)}},"handleCallTool"),ce=Ge(async()=>{try{V("Sending follow-up message..."),await k($),V("Follow-up message sent successfully")}catch(xe){V(`Error: ${xe.message}`)}},"handleSendFollowUpMessage"),ae=Ge(()=>{try{C(U),V(`Opened external link: ${U}`)}catch(xe){V(`Error: ${xe.message}`)}},"handleOpenExternal"),ye=Ge(async xe=>{try{V(`Requesting display mode: ${xe}...`);const st=await R(xe);V(`Display mode granted: ${st.mode}`)}catch(st){V(`Error: ${st.message}`)}},"handleRequestDisplayMode"),ke=Ge(async()=>{try{const xe=m?{...m,debugTimestamp:new Date().toISOString()}:{debugTimestamp:new Date().toISOString()};V("Setting state..."),await A(xe),V(`State updated: ${JSON.stringify(xe,null,2)}`)}catch(xe){V(`Error: ${xe.message}`)}},"handleSetState"),Be=Ge(async()=>{try{await R("fullscreen")}catch(xe){console.error("Failed to go fullscreen:",xe)}},"handleFullscreen"),_e=Ge(async()=>{try{await R("pip")}catch(xe){console.error("Failed to go pip:",xe)}},"handlePip"),Se=Ge(()=>{const xe=["absolute","px-2","py-1","bg-black/90","text-white","rounded","text-xs","whitespace-nowrap","pointer-events-none","transition-opacity","duration-200","ease-in-out"];switch(n){case"top-right":return[...xe,"top-full","right-0","mt-2"];case"top-left":return[...xe,"top-full","left-0","mt-2"];case"top-center":return[...xe,"top-full","left-1/2","-translate-x-1/2","mt-2"];case"bottom-right":return[...xe,"bottom-full","right-0","mb-2"];case"bottom-left":return[...xe,"bottom-full","left-0","mb-2"];case"bottom-center":return[...xe,"bottom-full","left-1/2","-translate-x-1/2","mb-2"];case"center-left":return[...xe,"left-full","top-1/2","-translate-y-1/2","ml-2"];case"center-right":return[...xe,"right-full","top-1/2","-translate-y-1/2","mr-2"];default:return[...xe,"top-full","right-0","mt-2"]}},"getTooltipClasses"),ze=Ge(({onClick:xe,label:st,children:at})=>{const[pt,Pe]=x.useState(!1),$e=Se();return ue.createElement("button",{className:`p-2 ${J?"bg-white/10 hover:bg-white/20":"bg-black/70 hover:bg-black/90"} text-white border-none rounded-lg cursor-pointer flex items-center justify-center w-8 h-8 transition-colors duration-200 backdrop-blur-md ${J?"shadow-[0_2px_8px_rgba(0,0,0,0.3)]":"shadow-[0_2px_8px_rgba(0,0,0,0.2)]"} relative`,onMouseEnter:()=>Pe(!0),onMouseLeave:()=>Pe(!1),onClick:xe,"aria-label":st},ue.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"block"},at),r&&ue.createElement("span",{className:`${$e.join(" ")} ${pt?"opacity-100":"opacity-0"}`},st))},"IconButton"),pe=Ge(xe=>{if(xe===null)return"null";if(xe===void 0)return"undefined";if(typeof xe=="object")try{return JSON.stringify(xe,null,2)}catch{return String(xe)}return String(xe)},"formatValue"),Le=Ge(xe=>xe?`${xe.device?.type||"unknown"}`:"N/A","formatUserAgent"),Fe=Ge(xe=>{if(!xe?.insets)return"N/A";const{top:st,bottom:at,left:pt,right:Pe}=xe.insets;return`T:${st} B:${at} L:${pt} R:${Pe}`},"formatSafeArea");return ue.createElement(ue.Fragment,null,ue.createElement("div",{ref:H,className:`${t} relative h-fit`,onMouseEnter:()=>!a&&O(!0),onMouseLeave:()=>!a&&O(!1)},ue.createElement("div",{className:se().join(" "),style:le()},!Z&&ue.createElement(ue.Fragment,null,!P&&!G&&ue.createElement(ue.Fragment,null,(s===!0||s==="fullscreen")&&ue.createElement(ze,{onClick:Be,label:"Fullscreen"},ue.createElement("path",{d:"M15 3h6v6"}),ue.createElement("path",{d:"m21 3-7 7"}),ue.createElement("path",{d:"m3 21 7-7"}),ue.createElement("path",{d:"M9 21H3v-6"})),(s===!0||s==="pip")&&ue.createElement(ze,{onClick:_e,label:"Picture in Picture"},ue.createElement("path",{d:"M21 9V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v10c0 1.1.9 2 2 2h4"}),ue.createElement("rect",{width:"10",height:"7",x:"12",y:"13",rx:"2"}))),i&&ue.createElement(ze,{onClick:ee,label:"Debug Info"},ue.createElement("path",{d:"M12 20v-9"}),ue.createElement("path",{d:"M14 7a4 4 0 0 1 4 4v3a6 6 0 0 1-12 0v-3a4 4 0 0 1 4-4z"}),ue.createElement("path",{d:"M14.12 3.88 16 2"}),ue.createElement("path",{d:"M21 21a4 4 0 0 0-3.81-4"}),ue.createElement("path",{d:"M21 5a4 4 0 0 1-3.55 3.97"}),ue.createElement("path",{d:"M22 13h-4"}),ue.createElement("path",{d:"M3 21a4 4 0 0 1 3.81-4"}),ue.createElement("path",{d:"M3 5a4 4 0 0 0 3.55 3.97"}),ue.createElement("path",{d:"M6 13H2"}),ue.createElement("path",{d:"m8 2 1.88 1.88"}),ue.createElement("path",{d:"M9 7.13V6a3 3 0 1 1 6 0v1.13"})))),e),j&&i&&ue.createElement("div",{ref:K,className:"fixed inset-0 bg-black text-white font-mono text-xs z-[10000] overflow-auto p-4",onClick:xe=>{xe.target===K.current&&F(!1)}},ue.createElement("button",{onClick:()=>F(!1),className:"absolute top-4 right-4 bg-white/10 text-white border-none rounded w-8 h-8 cursor-pointer flex items-center justify-center text-lg leading-none","aria-label":"Close"},"×"),ue.createElement("div",{className:"max-w-[1200px] mx-auto pt-10"},ue.createElement("h1",{className:"text-lg font-bold mb-4 border-b border-gray-700 pb-2"},"Debug Info"),ue.createElement("table",{className:"w-full border-collapse border-spacing-0"},ue.createElement("tbody",null,ue.createElement("tr",{className:"border-b border-gray-700"},ue.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Props"),ue.createElement("td",{className:"p-2 whitespace-pre-wrap break-all"},pe(c))),ue.createElement("tr",{className:"border-b border-gray-700"},ue.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Output"),ue.createElement("td",{className:"p-2 whitespace-pre-wrap break-all"},pe(u))),ue.createElement("tr",{className:"border-b border-gray-700"},ue.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Metadata"),ue.createElement("td",{className:"p-2 whitespace-pre-wrap break-all"},pe(d))),ue.createElement("tr",{className:"border-b border-gray-700"},ue.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"State"),ue.createElement("td",{className:"p-2 whitespace-pre-wrap break-all"},pe(m))),ue.createElement("tr",{className:"border-b border-gray-700"},ue.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Theme"),ue.createElement("td",{className:"p-2"},h)),ue.createElement("tr",{className:"border-b border-gray-700"},ue.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Display Mode"),ue.createElement("td",{className:"p-2"},g)),ue.createElement("tr",{className:"border-b border-gray-700"},ue.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Locale"),ue.createElement("td",{className:"p-2"},y)),ue.createElement("tr",{className:"border-b border-gray-700"},ue.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Max Height"),ue.createElement("td",{className:"p-2"},w,"px")),ue.createElement("tr",{className:"border-b border-gray-700"},ue.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"User Agent"),ue.createElement("td",{className:"p-2"},Le(S))),ue.createElement("tr",{className:"border-b border-gray-700"},ue.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Safe Area"),ue.createElement("td",{className:"p-2"},Fe(v))),ue.createElement("tr",{className:"border-b border-gray-700"},ue.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"API Available"),ue.createElement("td",{className:"p-2"},_?"Yes":"No")),ue.createElement("tr",{className:"border-b border-gray-700"},ue.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"window.openai Keys"),ue.createElement("td",{className:"p-2"},Q.length>0?Q.join(", "):"N/A")))),ue.createElement("h2",{className:"text-base font-bold mt-8 mb-4 border-b border-gray-700 pb-2"},"Actions"),ue.createElement("div",{className:"flex flex-col gap-3"},ue.createElement("div",{className:"flex gap-2 items-center"},ue.createElement("input",{type:"text",value:Y,onChange:xe=>z(xe.target.value),placeholder:"Tool name",className:"py-1.5 px-2 bg-[#1a1a1a] text-white border border-gray-700 rounded font-mono text-xs w-[150px]"}),ue.createElement("input",{type:"text",value:te,onChange:xe=>re(xe.target.value),placeholder:'{"key": "value"}',className:"py-1.5 px-2 bg-[#1a1a1a] text-white border border-gray-700 rounded font-mono text-xs flex-1"}),ue.createElement("button",{onClick:ne,className:"py-1.5 px-3 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-xs"},"Call Tool")),ue.createElement("div",{className:"flex gap-2 items-center"},ue.createElement("input",{type:"text",value:$,onChange:xe=>B(xe.target.value),placeholder:"Follow-up message",className:"py-1.5 px-2 bg-[#1a1a1a] text-white border border-gray-700 rounded font-mono text-xs flex-1"}),ue.createElement("button",{onClick:ce,className:"py-1.5 px-3 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-xs"},"Send Follow-Up")),ue.createElement("div",{className:"flex gap-2 items-center"},ue.createElement("input",{type:"text",value:U,onChange:xe=>L(xe.target.value),placeholder:"External URL",className:"py-1.5 px-2 bg-[#1a1a1a] text-white border border-gray-700 rounded font-mono text-xs flex-1"}),ue.createElement("button",{onClick:ae,className:"py-1.5 px-3 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-xs"},"Open Link")),ue.createElement("div",{className:"flex gap-2 items-center"},ue.createElement("span",{className:"w-[150px] text-xs"},"Display Mode:"),ue.createElement("button",{onClick:()=>ye("inline"),className:"py-1.5 px-3 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-xs flex-1"},"Inline"),ue.createElement("button",{onClick:()=>ye("pip"),className:"py-1.5 px-3 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-xs flex-1"},"PiP"),ue.createElement("button",{onClick:()=>ye("fullscreen"),className:"py-1.5 px-3 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-xs flex-1"},"Fullscreen")),ue.createElement("div",{className:"flex gap-2 items-center"},ue.createElement("button",{onClick:ke,className:"py-1.5 px-3 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-xs"},"Set State (Add Timestamp)")),ie&&ue.createElement("div",{className:"mt-2 p-2 bg-[#1a1a1a] border border-gray-700 rounded whitespace-pre-wrap break-all text-[11px] max-h-[200px] overflow-auto"},ue.createElement("div",{className:"font-bold mb-1 text-gray-400"},"Result:"),ie,ue.createElement("button",{onClick:()=>V(""),className:"mt-2 py-1 px-2 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-[11px]"},"Clear"))))))}Ge(rH,"WidgetControls");function aH(){if(typeof window>"u")return"/";const t=window.location.pathname.match(/^(\/inspector\/api\/dev-widget\/[^/]+)/);return t?t[1]:"/"}Ge(aH,"getBasename");var zae=150,Fae=5;function Bae({children:e,debugger:t=!1,viewControls:n=!1,autoSize:a=!1}){const r=aH(),i=x.useRef(null),s=x.useRef(0),c=x.useRef(null),u=x.useRef(!1),[d,m]=x.useState(null),[h,g]=x.useState(null),[v,w]=x.useState(!0);x.useEffect(()=>{let E=!0;return(async()=>{try{const k=await Ar(()=>import("./index-CmrpwsvF.js"),[]);E&&(m(()=>k.BrowserRouter),w(!1))}catch{E&&(g(new Error(`❌ react-router-dom not installed!
44
+ `}catch(h){console.error(`${i} Could not display error in callback window:`,h)}u&&localStorage.removeItem(u),s&&(localStorage.removeItem(s.getKey("code_verifier")),localStorage.removeItem(s.getKey("last_auth_url")))}}Ge(ST,"onMcpAuthorization");var lS={exports:{}},bt={};var oP;function Dae(){if(oP)return bt;oP=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),a=Symbol.for("react.strict_mode"),r=Symbol.for("react.profiler"),i=Symbol.for("react.consumer"),s=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),d=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),h=Symbol.for("react.activity"),g=Symbol.iterator;function v($){return $===null||typeof $!="object"?null:($=g&&$[g]||$["@@iterator"],typeof $=="function"?$:null)}var w={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},S=Object.assign,y={};function _($,B,U){this.props=$,this.context=B,this.refs=y,this.updater=U||w}_.prototype.isReactComponent={},_.prototype.setState=function($,B){if(typeof $!="object"&&typeof $!="function"&&$!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,$,B,"setState")},_.prototype.forceUpdate=function($){this.updater.enqueueForceUpdate(this,$,"forceUpdate")};function E(){}E.prototype=_.prototype;function k($,B,U){this.props=$,this.context=B,this.refs=y,this.updater=U||w}var C=k.prototype=new E;C.constructor=k,S(C,_.prototype),C.isPureReactComponent=!0;var R=Array.isArray;function A(){}var I={H:null,A:null,T:null,S:null},O=Object.prototype.hasOwnProperty;function j($,B,U){var L=U.ref;return{$$typeof:e,type:$,key:B,ref:L!==void 0?L:null,props:U}}function F($,B){return j($.type,B,$.props)}function H($){return typeof $=="object"&&$!==null&&$.$$typeof===e}function K($){var B={"=":"=0",":":"=2"};return"$"+$.replace(/[=:]/g,function(U){return B[U]})}var Q=/\/+/g;function W($,B){return typeof $=="object"&&$!==null&&$.key!=null?K(""+$.key):B.toString(36)}function ie($){switch($.status){case"fulfilled":return $.value;case"rejected":throw $.reason;default:switch(typeof $.status=="string"?$.then(A,A):($.status="pending",$.then(function(B){$.status==="pending"&&($.status="fulfilled",$.value=B)},function(B){$.status==="pending"&&($.status="rejected",$.reason=B)})),$.status){case"fulfilled":return $.value;case"rejected":throw $.reason}}throw $}function V($,B,U,L,P){var G=typeof $;(G==="undefined"||G==="boolean")&&($=null);var Z=!1;if($===null)Z=!0;else switch(G){case"bigint":case"string":case"number":Z=!0;break;case"object":switch($.$$typeof){case e:case t:Z=!0;break;case m:return Z=$._init,V(Z($._payload),B,U,L,P)}}if(Z)return P=P($),Z=L===""?"."+W($,0):L,R(P)?(U="",Z!=null&&(U=Z.replace(Q,"$&/")+"/"),V(P,B,U,"",function(le){return le})):P!=null&&(H(P)&&(P=F(P,U+(P.key==null||$&&$.key===P.key?"":(""+P.key).replace(Q,"$&/")+"/")+Z)),B.push(P)),1;Z=0;var J=L===""?".":L+":";if(R($))for(var se=0;se<$.length;se++)L=$[se],G=J+W(L,se),Z+=V(L,B,U,G,P);else if(se=v($),typeof se=="function")for($=se.call($),se=0;!(L=$.next()).done;)L=L.value,G=J+W(L,se++),Z+=V(L,B,U,G,P);else if(G==="object"){if(typeof $.then=="function")return V(ie($),B,U,L,P);throw B=String($),Error("Objects are not valid as a React child (found: "+(B==="[object Object]"?"object with keys {"+Object.keys($).join(", ")+"}":B)+"). If you meant to render a collection of children, use an array instead.")}return Z}function Y($,B,U){if($==null)return $;var L=[],P=0;return V($,L,"","",function(G){return B.call(U,G,P++)}),L}function z($){if($._status===-1){var B=$._result;B=B(),B.then(function(U){($._status===0||$._status===-1)&&($._status=1,$._result=U)},function(U){($._status===0||$._status===-1)&&($._status=2,$._result=U)}),$._status===-1&&($._status=0,$._result=B)}if($._status===1)return $._result.default;throw $._result}var te=typeof reportError=="function"?reportError:function($){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var B=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof $=="object"&&$!==null&&typeof $.message=="string"?String($.message):String($),error:$});if(!window.dispatchEvent(B))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",$);return}console.error($)},re={map:Y,forEach:function($,B,U){Y($,function(){B.apply(this,arguments)},U)},count:function($){var B=0;return Y($,function(){B++}),B},toArray:function($){return Y($,function(B){return B})||[]},only:function($){if(!H($))throw Error("React.Children.only expected to receive a single React element child.");return $}};return bt.Activity=h,bt.Children=re,bt.Component=_,bt.Fragment=n,bt.Profiler=r,bt.PureComponent=k,bt.StrictMode=a,bt.Suspense=u,bt.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=I,bt.__COMPILER_RUNTIME={__proto__:null,c:function($){return I.H.useMemoCache($)}},bt.cache=function($){return function(){return $.apply(null,arguments)}},bt.cacheSignal=function(){return null},bt.cloneElement=function($,B,U){if($==null)throw Error("The argument must be a React element, but you passed "+$+".");var L=S({},$.props),P=$.key;if(B!=null)for(G in B.key!==void 0&&(P=""+B.key),B)!O.call(B,G)||G==="key"||G==="__self"||G==="__source"||G==="ref"&&B.ref===void 0||(L[G]=B[G]);var G=arguments.length-2;if(G===1)L.children=U;else if(1<G){for(var Z=Array(G),J=0;J<G;J++)Z[J]=arguments[J+2];L.children=Z}return j($.type,P,L)},bt.createContext=function($){return $={$$typeof:s,_currentValue:$,_currentValue2:$,_threadCount:0,Provider:null,Consumer:null},$.Provider=$,$.Consumer={$$typeof:i,_context:$},$},bt.createElement=function($,B,U){var L,P={},G=null;if(B!=null)for(L in B.key!==void 0&&(G=""+B.key),B)O.call(B,L)&&L!=="key"&&L!=="__self"&&L!=="__source"&&(P[L]=B[L]);var Z=arguments.length-2;if(Z===1)P.children=U;else if(1<Z){for(var J=Array(Z),se=0;se<Z;se++)J[se]=arguments[se+2];P.children=J}if($&&$.defaultProps)for(L in Z=$.defaultProps,Z)P[L]===void 0&&(P[L]=Z[L]);return j($,G,P)},bt.createRef=function(){return{current:null}},bt.forwardRef=function($){return{$$typeof:c,render:$}},bt.isValidElement=H,bt.lazy=function($){return{$$typeof:m,_payload:{_status:-1,_result:$},_init:z}},bt.memo=function($,B){return{$$typeof:d,type:$,compare:B===void 0?null:B}},bt.startTransition=function($){var B=I.T,U={};I.T=U;try{var L=$(),P=I.S;P!==null&&P(U,L),typeof L=="object"&&L!==null&&typeof L.then=="function"&&L.then(A,te)}catch(G){te(G)}finally{B!==null&&U.types!==null&&(B.types=U.types),I.T=B}},bt.unstable_useCacheRefresh=function(){return I.H.useCacheRefresh()},bt.use=function($){return I.H.use($)},bt.useActionState=function($,B,U){return I.H.useActionState($,B,U)},bt.useCallback=function($,B){return I.H.useCallback($,B)},bt.useContext=function($){return I.H.useContext($)},bt.useDebugValue=function(){},bt.useDeferredValue=function($,B){return I.H.useDeferredValue($,B)},bt.useEffect=function($,B){return I.H.useEffect($,B)},bt.useEffectEvent=function($){return I.H.useEffectEvent($)},bt.useId=function(){return I.H.useId()},bt.useImperativeHandle=function($,B,U){return I.H.useImperativeHandle($,B,U)},bt.useInsertionEffect=function($,B){return I.H.useInsertionEffect($,B)},bt.useLayoutEffect=function($,B){return I.H.useLayoutEffect($,B)},bt.useMemo=function($,B){return I.H.useMemo($,B)},bt.useOptimistic=function($,B){return I.H.useOptimistic($,B)},bt.useReducer=function($,B,U){return I.H.useReducer($,B,U)},bt.useRef=function($){return I.H.useRef($)},bt.useState=function($){return I.H.useState($)},bt.useSyncExternalStore=function($,B,U){return I.H.useSyncExternalStore($,B,U)},bt.useTransition=function(){return I.H.useTransition()},bt.version="19.2.0",bt}var sP;function xT(){return sP||(sP=1,lS.exports=Dae()),lS.exports}var x=xT();const ue=xp(x),Pp=cX({__proto__:null,default:ue},[x]);function Fx(e,t){if(!e)throw new Error(t)}Ge(Fx,"assert");var Lae=3e3,$ae=5e3;function ET(e){const{url:t,enabled:n=!0,clientName:a,clientUri:r,callbackUrl:i=typeof window<"u"?qc(new URL("/oauth/callback",window.location.origin).toString()):"/oauth/callback",storageKeyPrefix:s="mcp:auth",clientConfig:c={},customHeaders:u={},debug:d=!1,autoRetry:m=!1,autoReconnect:h=Lae,transportType:g="auto",preventAutoAuth:v=!1,useRedirectFlow:w=!1,onPopupWindow:S,timeout:y=3e4,sseReadTimeout:_=3e5,wrapTransport:E,onNotification:k,samplingCallback:C}=e,[R,A]=x.useState("discovering"),[I,O]=x.useState([]),[j,F]=x.useState([]),[H,K]=x.useState([]),[Q,W]=x.useState([]),[ie,V]=x.useState(),[Y,z]=x.useState(),[te,re]=x.useState(void 0),[$,B]=x.useState([]),[U,L]=x.useState(void 0),P=x.useRef(null),G=x.useRef(null),Z=x.useRef(!1),J=x.useRef(!0),se=x.useRef(0),le=x.useRef(null),ee=x.useRef(R),ne=x.useRef(h),ce=x.useRef(null);x.useEffect(()=>{ee.current=R,ne.current=h},[R,h]);const ae=x.useCallback((Pe,$e,...et)=>{const an=et.length>0?`${$e} ${et.map(Qe=>JSON.stringify(Qe)).join(" ")}`:$e;console[Pe](`[useMcp] ${an}`),J.current&&B(Qe=>[...Qe.slice(-100),{level:Pe,message:an,timestamp:Date.now()}])},[]),ye=x.useCallback(async(Pe=!1)=>{if(Pe||ae("info","Disconnecting..."),Z.current=!1,le.current&&clearTimeout(le.current),le.current=null,P.current)try{await P.current.closeSession("inspector-server")}catch($e){Pe||ae("warn","Error closing session:",$e)}P.current=null,J.current&&!Pe&&(A("discovering"),O([]),F([]),K([]),W([]),re(void 0),L(void 0))},[ae]),ke=x.useCallback((Pe,$e)=>{if(ae("error",Pe,$e??""),J.current){A("failed"),re(Pe);const et=G.current?.getLastAttemptedAuthUrl();et&&(L(et),ae("info","Manual authentication URL may be available.",et))}Z.current=!1},[ae]),Be=x.useCallback(async()=>{if(!n||!t){ae("debug",n?"No server URL provided, skipping connection.":"Connection disabled via enabled flag.");return}if(Z.current){ae("debug","Connection attempt already in progress.");return}if(!J.current){ae("debug","Connect called after unmount, aborting.");return}Z.current=!0,se.current+=1,re(void 0),L(void 0),ce.current=null,A("discovering"),ae("info",`Connecting attempt #${se.current} to ${t}...`),G.current||(G.current=new Fg(t,{storageKeyPrefix:s,clientName:a,clientUri:r,callbackUrl:i,preventAutoAuth:v,useRedirectFlow:w,onPopupWindow:S}),ae("debug","BrowserOAuthClientProvider initialized in connect.")),P.current||(P.current=new Oae,ae("debug","BrowserMCPClient initialized in connect."));const Pe=Ge(async(et,an=!1)=>{ae("info",`Attempting connection with transport: ${et}`);try{const Qe="inspector-server",Ae={url:t,transport:et==="sse"?"http":et};if(u&&Object.keys(u).length>0&&(Ae.headers=u),G.current){const mt=await G.current.tokens();mt?.access_token&&(Ae.headers={...Ae.headers,Authorization:`Bearer ${mt.access_token}`})}P.current.addServer(Qe,{...Ae,authProvider:G.current,clientOptions:c,samplingCallback:C,wrapTransport:E?mt=>(console.log("[useMcp] Applying transport wrapper for server:",Qe,"url:",t),E(mt,t)):void 0});const Ie=await P.current.createSession(Qe,!1);k&&Ie.on("notification",k),await Ie.initialize(),ae("info","✅ Successfully connected to MCP server"),ae("info","Server info:",Ie.connector.serverInfo),ae("info","Server capabilities:",Ie.connector.serverCapabilities),console.log("[useMcp] Server info:",Ie.connector.serverInfo),console.log("[useMcp] Server capabilities:",Ie.connector.serverCapabilities),A("ready"),ce.current=et,O(Ie.connector.tools||[]);const Ye=await Ie.connector.listAllResources();F(Ye.resources||[]);const tt=await Ie.connector.listPrompts();W(tt.prompts||[]);const it=Ie.connector.serverInfo,gt=Ie.connector.serverCapabilities;return it&&(console.log("[useMcp] Server info:",it),V(it)),gt&&(console.log("[useMcp] Server capabilities:",gt),z(gt)),"success"}catch(Qe){const Ae=Qe?.message||String(Qe);if(Qe.code===401||Ae.includes("401")||Ae.includes("Unauthorized")){if(G.current){ae("info","Authentication required. OAuth provider available.");try{const{auth:Ie}=await Ar(async()=>{const{auth:tt}=await Promise.resolve().then(()=>JM);return{auth:tt}},void 0),Ye=new URL(t).origin;Ie(G.current,{serverUrl:Ye}).catch(()=>{}),setTimeout(()=>{if(J.current){const tt=G.current?.getLastAttemptedAuthUrl();tt?(L(tt),ae("info","Manual authentication URL available:",tt)):ae("warn","Could not generate authentication URL")}},100)}catch(Ie){ae("warn","Error generating auth URL:",Ie)}return J.current&&A("pending_auth"),Z.current=!1,"auth_redirect"}return u&&Object.keys(u).length>0?(ke("Authentication failed: Server returned 401 Unauthorized. Check your Authorization header value is correct."),"failed"):(ke("Authentication required: Server returned 401 Unauthorized. Add an Authorization header in the Custom Headers section (e.g., Authorization: Bearer YOUR_API_KEY)."),"failed")}return ke(Ae,Qe),"failed"}},"tryConnectWithTransport");let $e="failed";if(g==="sse")ae("debug","Using SSE-only transport mode"),$e=await Pe("sse");else if(g==="http")ae("debug","Using HTTP-only transport mode"),$e=await Pe("http");else{ae("debug","Using auto transport mode (HTTP with SSE fallback)");const et=await Pe("http");et==="fallback"&&J.current&&ee.current!=="authenticating"?(ae("info","HTTP failed, attempting SSE fallback..."),$e=await Pe("sse")):$e=et}($e==="success"||$e==="failed"||$e==="auth_redirect")&&(Z.current=!1),ae("debug",`Connection sequence finished with status: ${$e}`)},[ae,ke,ye,t,s,a,r,i,c.name,c.version,u,g,v,w,S,n,y,_]),_e=x.useCallback(async(Pe,$e,et)=>{if(ee.current!=="ready"||!P.current)throw new Error(`MCP client is not ready (current state: ${R}). Cannot call tool "${Pe}".`);ae("info",`Calling tool: ${Pe}`,$e);try{const Qe=P.current.getSession("inspector-server");if(!Qe)throw new Error("No active session found");const Ae=await Qe.connector.callTool(Pe,$e||{},et);return ae("info",`Tool "${Pe}" call successful:`,Ae),Ae}catch(an){throw ae("error",`Tool "${Pe}" call failed:`,an),an}},[R]),Se=x.useCallback(()=>{ee.current==="failed"?(ae("info","Retry requested..."),Be()):ae("warn",`Retry called but state is not 'failed' (state: ${ee.current}). Ignoring.`)},[ae,Be]),ze=x.useCallback(async()=>{ae("info","Manual authentication requested...");const Pe=ee.current;if(Pe==="failed")ae("info","Attempting to reconnect and authenticate via retry..."),Se();else if(Pe==="pending_auth"){ae("info","Proceeding with authentication from pending state...");try{Fx(G.current,"Auth Provider not available for manual auth"),Fx(t,"Server URL is required for authentication"),ae("info","Clearing all OAuth state and initiating fresh flow...");const $e=`${s}:${G.current.serverUrlHash}`;Object.keys(localStorage).forEach(Ae=>{Ae.startsWith($e)&&(ae("debug",`Removing stale OAuth key: ${Ae}`),localStorage.removeItem(Ae)),Ae.startsWith(`${s}:state_`)&&(ae("debug",`Removing orphaned state: ${Ae}`),localStorage.removeItem(Ae))}),A("authenticating");const et=new Fg(t,{storageKeyPrefix:s,clientName:a,clientUri:r,callbackUrl:i,preventAutoAuth:!1,useRedirectFlow:w,onPopupWindow:S});G.current=et,ae("info","Triggering fresh OAuth authorization...");const{auth:an}=await Ar(async()=>{const{auth:Ae}=await Promise.resolve().then(()=>JM);return{auth:Ae}},void 0),Qe=new URL(t).origin;an(et,{serverUrl:Qe}).catch(Ae=>{ae("info","OAuth flow initiated:",Ae?.message||"Redirecting...")})}catch($e){if(!J.current)return;A("pending_auth"),ae("error",`Manual authentication failed: ${$e instanceof Error?$e.message:String($e)}`)}}else if(Pe==="authenticating"){ae("warn","Already attempting authentication. Check for blocked popups or wait for timeout.");const $e=G.current?.getLastAttemptedAuthUrl();$e&&!U&&(L($e),ae("info","Manual authentication URL retrieved:",$e))}else ae("info",`Client not in a state requiring manual authentication trigger (state: ${Pe}). If needed, try disconnecting and reconnecting.`)},[ae,Se,U,t,w,S,s,a,r,i]),pe=x.useCallback(()=>{if(G.current){const Pe=G.current.clearStorage();ae("info",`Cleared ${Pe} item(s) from localStorage for ${t}.`),L(void 0),ye()}else ae("warn","Auth provider not initialized, cannot clear storage.")},[t,ae,ye]),Le=x.useCallback(async()=>{if(ee.current!=="ready"||!P.current)throw new Error(`MCP client is not ready (current state: ${R}). Cannot list resources.`);ae("info","Listing resources");try{const $e=P.current.getSession("inspector-server");if(!$e)throw new Error("No active session found");const et=await $e.connector.listAllResources();F(et.resources||[]),ae("info","Resources listed successfully")}catch(Pe){throw ae("error","List resources failed:",Pe),Pe}},[R]),Fe=x.useCallback(async Pe=>{if(ee.current!=="ready"||!P.current)throw new Error(`MCP client is not ready (current state: ${R}). Cannot read resource.`);ae("info",`Reading resource: ${Pe}`);try{const et=P.current.getSession("inspector-server");if(!et)throw new Error("No active session found");const an=await et.connector.readResource(Pe);return ae("info","Resource read successful:",an),an}catch($e){throw ae("error","Resource read failed:",$e),$e}},[R]),xe=x.useCallback(async()=>{if(ee.current!=="ready"||!P.current)throw new Error(`MCP client is not ready (current state: ${R}). Cannot list prompts.`);ae("info","Listing prompts");try{const $e=P.current.getSession("inspector-server");if(!$e)throw new Error("No active session found");const et=await $e.connector.listPrompts();W(et.prompts||[]),ae("info","Prompts listed successfully")}catch(Pe){throw ae("error","List prompts failed:",Pe),Pe}},[R]),st=x.useCallback(async(Pe,$e)=>{if(ee.current!=="ready"||!P.current)throw new Error(`MCP client is not ready (current state: ${R}). Cannot get prompt.`);ae("info",`Getting prompt: ${Pe}`,$e);try{const an=P.current.getSession("inspector-server");if(!an)throw new Error("No active session found");const Qe=await an.connector.getPrompt(Pe,$e||{});return ae("info",`Prompt "${Pe}" retrieved successfully:`,Qe),Qe}catch(et){throw ae("error",`Prompt "${Pe}" retrieval failed:`,et),et}},[R]),at=x.useRef(Be),pt=x.useRef(ke);return x.useEffect(()=>{at.current=Be,pt.current=ke}),x.useEffect(()=>{const Pe=Ge($e=>{$e.origin===window.location.origin&&$e.data?.type==="mcp_auth_callback"&&(ae("info","Received auth callback message.",$e.data),le.current&&clearTimeout(le.current),le.current=null,$e.data.success?(ae("info","Authentication successful via popup. Reconnecting client..."),Z.current&&ae("debug","Connection attempt already in progress, resetting flag to allow reconnection."),Z.current=!1,setTimeout(()=>{J.current&&(ae("debug","Initiating reconnection after successful auth callback."),at.current())},100)):pt.current(`Authentication failed in callback: ${$e.data.error||"Unknown reason."}`))},"messageHandler");return window.addEventListener("message",Pe),ae("debug","Auth callback message listener added."),()=>{window.removeEventListener("message",Pe),ae("debug","Auth callback message listener removed."),le.current&&clearTimeout(le.current)}},[ae]),x.useEffect(()=>(J.current=!0,!n||!t?(ae("debug",n?"No server URL provided, skipping connection.":"Connection disabled via enabled flag."),A("discovering"),()=>{J.current=!1}):(ae("debug","useMcp mounted, initiating connection."),se.current=0,(!G.current||G.current.serverUrl!==t)&&(G.current=new Fg(t,{storageKeyPrefix:s,clientName:a,clientUri:r,callbackUrl:i,preventAutoAuth:v,useRedirectFlow:w,onPopupWindow:S}),ae("debug","BrowserOAuthClientProvider initialized/updated on mount/option change.")),Be(),()=>{J.current=!1,ae("debug","useMcp unmounting, disconnecting."),ye(!0)})),[t,n,s,i,a,r,c.name,c.version,w]),x.useEffect(()=>{let Pe=null;if(R==="failed"&&m&&se.current>0){const $e=typeof m=="number"?m:$ae;ae("info",`Connection failed, auto-retrying in ${$e}ms...`),Pe=setTimeout(()=>{J.current&&ee.current==="failed"&&Se()},$e)}return()=>{Pe&&clearTimeout(Pe)}},[R,m,Se,ae]),{state:R,tools:I,resources:j,resourceTemplates:H,prompts:Q,serverInfo:ie,capabilities:Y,error:te,log:$,authUrl:U,client:P.current,callTool:_e,readResource:Fe,listResources:Le,listPrompts:xe,getPrompt:st,retry:Se,disconnect:ye,authenticate:ze,clearStorage:pe}}Ge(ET,"useMcp");var Tu,jae=(Tu=class extends ue.Component{constructor(t){super(t),this.state={hasError:!1,error:null}}static getDerivedStateFromError(t){return{hasError:!0,error:t}}componentDidCatch(t,n){console.error("Widget Error:",t,n)}render(){return this.state.hasError?ue.createElement("div",{className:"p-4 border border-red-500 bg-red-50 text-red-900 rounded-md dark:bg-red-900/20 dark:text-red-100"},ue.createElement("h3",{className:"font-bold mb-2"},"Widget Error"),ue.createElement("pre",{className:"text-sm whitespace-pre-wrap"},this.state.error?.message)):this.props.children}},Ge(Tu,"ErrorBoundary"),Tu),If="openai:set_globals";function li(e){return x.useSyncExternalStore(t=>{const n=Ge(a=>{a.detail.globals[e]!==void 0&&t()},"handleSetGlobal");return typeof window<"u"&&window.addEventListener(If,n),()=>{typeof window<"u"&&window.removeEventListener(If,n)}},()=>typeof window<"u"&&window.openai?window.openai[e]:void 0)}Ge(li,"useOpenAiGlobal");function Ku(e){const[t,n]=x.useState(()=>typeof window<"u"&&!!window.openai);x.useEffect(()=>{if(typeof window<"u"&&window.openai){n(!0);return}const O=setInterval(()=>{typeof window<"u"&&window.openai&&(n(!0),clearInterval(O))},100),j=Ge(()=>{typeof window<"u"&&window.openai&&(n(!0),clearInterval(O))},"handleSetGlobals");typeof window<"u"&&window.addEventListener(If,j);const F=setTimeout(()=>{clearInterval(O),typeof window<"u"&&window.removeEventListener(If,j)},5e3);return()=>{clearInterval(O),clearTimeout(F),typeof window<"u"&&window.removeEventListener(If,j)}},[]);const a=x.useMemo(()=>t?"openai":"mcp-ui",[t]),r=typeof window<"u"?window.location.search:"",i=x.useMemo(()=>{const O=new URLSearchParams(r);return O.has("mcpUseParams")?JSON.parse(O.get("mcpUseParams")):{toolInput:{},toolOutput:{},toolId:""}},[r]),s=a==="openai"?li("toolInput"):i.toolInput,c=a==="openai"?li("toolOutput"):i.toolOutput,u=li("toolResponseMetadata"),d=li("widgetState"),m=li("theme"),h=li("displayMode"),g=li("safeArea"),v=li("maxHeight"),w=li("userAgent"),S=li("locale"),y=x.useMemo(()=>typeof window<"u"&&window.__mcpPublicUrl?window.__mcpPublicUrl.replace(/\/mcp-use\/public$/,""):"",[]),[_,E]=x.useState(null);x.useEffect(()=>{d!==void 0&&E(d)},[d]);const k=x.useCallback(async(O,j)=>{if(!window.openai?.callTool)throw new Error("window.openai.callTool is not available");return window.openai.callTool(O,j)},[]),C=x.useCallback(async O=>{if(!window.openai?.sendFollowUpMessage)throw new Error("window.openai.sendFollowUpMessage is not available");return window.openai.sendFollowUpMessage({prompt:O})},[]),R=x.useCallback(O=>{if(!window.openai?.openExternal)throw new Error("window.openai.openExternal is not available");window.openai.openExternal({href:O})},[]),A=x.useCallback(async O=>{if(!window.openai?.requestDisplayMode)throw new Error("window.openai.requestDisplayMode is not available");return window.openai.requestDisplayMode({mode:O})},[]),I=x.useCallback(async O=>{if(!window.openai?.setWidgetState)throw new Error("window.openai.setWidgetState is not available");const F=typeof O=="function"?O(d!==void 0?d:_):O;return E(F),window.openai.setWidgetState(F)},[d,_]);return{props:s||e||{},output:c??null,metadata:u??null,state:_,setState:I,theme:m||"light",displayMode:h||"inline",safeArea:g||{insets:{top:0,bottom:0,left:0,right:0}},maxHeight:v||600,userAgent:w||{device:{type:"desktop"},capabilities:{hover:!0,touch:!1}},locale:S||"en",mcp_url:y,callTool:k,sendFollowUpMessage:C,openExternal:R,requestDisplayMode:A,isAvailable:t}}Ge(Ku,"useWidget");function Mae(e){const{props:t}=Ku(e);return t}Ge(Mae,"useWidgetProps");function Pae(){const{theme:e}=Ku();return e}Ge(Pae,"useWidgetTheme");function Uae(e){const{state:t,setState:n}=Ku();return x.useEffect(()=>{t===null&&e!==void 0&&window.openai?.setWidgetState&&n(e)},[]),[t,n]}Ge(Uae,"useWidgetState");var lP=Ge(({children:e})=>{const{theme:t,isAvailable:n}=Ku();console.log("theme",t);const[a,r]=x.useState(()=>typeof window>"u"?"light":window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light");x.useEffect(()=>{if(typeof window>"u")return;const s=window.matchMedia("(prefers-color-scheme: dark)"),c=Ge(u=>{r(u.matches?"dark":"light")},"handleChange");return s.addEventListener("change",c),()=>s.removeEventListener("change",c)},[]);const i=n?t:a;return x.useLayoutEffect(()=>{typeof document>"u"||(i==="dark"?document.documentElement.classList.add("dark"):document.documentElement.classList.remove("dark"))},[i]),ue.createElement(ue.Fragment,null,e)},"ThemeProvider");function rH({children:e,className:t="",position:n="top-right",attachTo:a,showLabels:r=!0,debugger:i=!1,viewControls:s=!1}){const{props:c,output:u,metadata:d,state:m,theme:h,displayMode:g,safeArea:v,maxHeight:w,userAgent:S,locale:y,isAvailable:_,callTool:E,sendFollowUpMessage:k,openExternal:C,requestDisplayMode:R,setState:A}=Ku(),[I,O]=x.useState(!1),[j,F]=x.useState(!1),H=x.useRef(null),K=x.useRef(null),[Q,W]=x.useState([]),[ie,V]=x.useState(""),[Y,z]=x.useState("get-my-city"),[te,re]=x.useState("{}"),[$,B]=x.useState("Test follow-up message"),[U,L]=x.useState("https://docs.mcp-use.com"),P=g==="fullscreen"&&_,G=g==="pip"&&_,Z=typeof window<"u"&&window.location.pathname.includes("/inspector/api/dev-widget/");x.useEffect(()=>{const xe=setTimeout(()=>{if(typeof window<"u"&&window.openai)try{const st=Object.keys(window.openai);W(st)}catch{W([])}else W([])},100);return()=>{clearTimeout(xe)}},[]);const J=h==="dark",se=Ge(()=>{const xe=["absolute","z-[1000]","flex","gap-2","transition-opacity","duration-200","ease-in-out",I?"opacity-100":"opacity-0",I?"pointer-events-auto":"pointer-events-none"];switch(n){case"top-left":return[...xe,"top-4","left-4"];case"top-center":return[...xe,"top-4","left-1/2","-translate-x-1/2"];case"top-right":return[...xe,"top-4","right-4"];case"center-left":return[...xe,"top-1/2","left-4","-translate-y-1/2"];case"center-right":return[...xe,"top-1/2","right-4","-translate-y-1/2"];case"bottom-left":return[...xe,"bottom-4","left-4"];case"bottom-center":return[...xe,"bottom-4","left-1/2","-translate-x-1/2"];case"bottom-right":return[...xe,"bottom-4","right-4"];default:return[...xe,"top-4","right-4"]}},"getPositionClasses"),le=Ge(()=>{const st=v?.insets?.top?Math.max(16,v.insets.top+8):16,at=v?.insets?.right?Math.max(16,v.insets.right+8):16,pt=v?.insets?.bottom?Math.max(16,v.insets.bottom+8):16,Pe=v?.insets?.left?Math.max(16,v.insets.left+8):16,$e={};switch(n){case"top-left":$e.top=`${st}px`,$e.left=`${Pe}px`;break;case"top-center":$e.top=`${st}px`;break;case"top-right":$e.top=`${st}px`,$e.right=`${at}px`;break;case"center-left":$e.left=`${Pe}px`;break;case"center-right":$e.right=`${at}px`;break;case"bottom-left":$e.bottom=`${pt}px`,$e.left=`${Pe}px`;break;case"bottom-center":$e.bottom=`${pt}px`;break;case"bottom-right":$e.bottom=`${pt}px`,$e.right=`${at}px`;break;default:$e.top=`${st}px`,$e.right=`${at}px`;break}return $e},"getPositionOffsetStyles");x.useEffect(()=>{if(!a)return;const xe=Ge(()=>O(!0),"handleMouseEnter"),st=Ge(()=>O(!1),"handleMouseLeave");return a.addEventListener("mouseenter",xe),a.addEventListener("mouseleave",st),()=>{a.removeEventListener("mouseenter",xe),a.removeEventListener("mouseleave",st)}},[a]),x.useEffect(()=>{if(!j)return;const xe=Ge(st=>{K.current&&!K.current.contains(st.target)&&F(!1)},"handleClickOutside");return document.addEventListener("mousedown",xe),()=>{document.removeEventListener("mousedown",xe)}},[j]),x.useEffect(()=>(j?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[j]);const ee=Ge(()=>{F(!j)},"handleToggleOverlay"),ne=Ge(async()=>{try{V("Calling tool...");const xe=te.trim()?JSON.parse(te):{},st=await E(Y,xe);V(`Success: ${JSON.stringify(st,null,2)}`)}catch(xe){V(`Error: ${xe.message}`)}},"handleCallTool"),ce=Ge(async()=>{try{V("Sending follow-up message..."),await k($),V("Follow-up message sent successfully")}catch(xe){V(`Error: ${xe.message}`)}},"handleSendFollowUpMessage"),ae=Ge(()=>{try{C(U),V(`Opened external link: ${U}`)}catch(xe){V(`Error: ${xe.message}`)}},"handleOpenExternal"),ye=Ge(async xe=>{try{V(`Requesting display mode: ${xe}...`);const st=await R(xe);V(`Display mode granted: ${st.mode}`)}catch(st){V(`Error: ${st.message}`)}},"handleRequestDisplayMode"),ke=Ge(async()=>{try{const xe=m?{...m,debugTimestamp:new Date().toISOString()}:{debugTimestamp:new Date().toISOString()};V("Setting state..."),await A(xe),V(`State updated: ${JSON.stringify(xe,null,2)}`)}catch(xe){V(`Error: ${xe.message}`)}},"handleSetState"),Be=Ge(async()=>{try{await R("fullscreen")}catch(xe){console.error("Failed to go fullscreen:",xe)}},"handleFullscreen"),_e=Ge(async()=>{try{await R("pip")}catch(xe){console.error("Failed to go pip:",xe)}},"handlePip"),Se=Ge(()=>{const xe=["absolute","px-2","py-1","bg-black/90","text-white","rounded","text-xs","whitespace-nowrap","pointer-events-none","transition-opacity","duration-200","ease-in-out"];switch(n){case"top-right":return[...xe,"top-full","right-0","mt-2"];case"top-left":return[...xe,"top-full","left-0","mt-2"];case"top-center":return[...xe,"top-full","left-1/2","-translate-x-1/2","mt-2"];case"bottom-right":return[...xe,"bottom-full","right-0","mb-2"];case"bottom-left":return[...xe,"bottom-full","left-0","mb-2"];case"bottom-center":return[...xe,"bottom-full","left-1/2","-translate-x-1/2","mb-2"];case"center-left":return[...xe,"left-full","top-1/2","-translate-y-1/2","ml-2"];case"center-right":return[...xe,"right-full","top-1/2","-translate-y-1/2","mr-2"];default:return[...xe,"top-full","right-0","mt-2"]}},"getTooltipClasses"),ze=Ge(({onClick:xe,label:st,children:at})=>{const[pt,Pe]=x.useState(!1),$e=Se();return ue.createElement("button",{className:`p-2 ${J?"bg-white/10 hover:bg-white/20":"bg-black/70 hover:bg-black/90"} text-white border-none rounded-lg cursor-pointer flex items-center justify-center w-8 h-8 transition-colors duration-200 backdrop-blur-md ${J?"shadow-[0_2px_8px_rgba(0,0,0,0.3)]":"shadow-[0_2px_8px_rgba(0,0,0,0.2)]"} relative`,onMouseEnter:()=>Pe(!0),onMouseLeave:()=>Pe(!1),onClick:xe,"aria-label":st},ue.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"block"},at),r&&ue.createElement("span",{className:`${$e.join(" ")} ${pt?"opacity-100":"opacity-0"}`},st))},"IconButton"),pe=Ge(xe=>{if(xe===null)return"null";if(xe===void 0)return"undefined";if(typeof xe=="object")try{return JSON.stringify(xe,null,2)}catch{return String(xe)}return String(xe)},"formatValue"),Le=Ge(xe=>xe?`${xe.device?.type||"unknown"}`:"N/A","formatUserAgent"),Fe=Ge(xe=>{if(!xe?.insets)return"N/A";const{top:st,bottom:at,left:pt,right:Pe}=xe.insets;return`T:${st} B:${at} L:${pt} R:${Pe}`},"formatSafeArea");return ue.createElement(ue.Fragment,null,ue.createElement("div",{ref:H,className:`${t} relative h-fit`,onMouseEnter:()=>!a&&O(!0),onMouseLeave:()=>!a&&O(!1)},ue.createElement("div",{className:se().join(" "),style:le()},!Z&&ue.createElement(ue.Fragment,null,!P&&!G&&ue.createElement(ue.Fragment,null,(s===!0||s==="fullscreen")&&ue.createElement(ze,{onClick:Be,label:"Fullscreen"},ue.createElement("path",{d:"M15 3h6v6"}),ue.createElement("path",{d:"m21 3-7 7"}),ue.createElement("path",{d:"m3 21 7-7"}),ue.createElement("path",{d:"M9 21H3v-6"})),(s===!0||s==="pip")&&ue.createElement(ze,{onClick:_e,label:"Picture in Picture"},ue.createElement("path",{d:"M21 9V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v10c0 1.1.9 2 2 2h4"}),ue.createElement("rect",{width:"10",height:"7",x:"12",y:"13",rx:"2"}))),i&&ue.createElement(ze,{onClick:ee,label:"Debug Info"},ue.createElement("path",{d:"M12 20v-9"}),ue.createElement("path",{d:"M14 7a4 4 0 0 1 4 4v3a6 6 0 0 1-12 0v-3a4 4 0 0 1 4-4z"}),ue.createElement("path",{d:"M14.12 3.88 16 2"}),ue.createElement("path",{d:"M21 21a4 4 0 0 0-3.81-4"}),ue.createElement("path",{d:"M21 5a4 4 0 0 1-3.55 3.97"}),ue.createElement("path",{d:"M22 13h-4"}),ue.createElement("path",{d:"M3 21a4 4 0 0 1 3.81-4"}),ue.createElement("path",{d:"M3 5a4 4 0 0 0 3.55 3.97"}),ue.createElement("path",{d:"M6 13H2"}),ue.createElement("path",{d:"m8 2 1.88 1.88"}),ue.createElement("path",{d:"M9 7.13V6a3 3 0 1 1 6 0v1.13"})))),e),j&&i&&ue.createElement("div",{ref:K,className:"fixed inset-0 bg-black text-white font-mono text-xs z-[10000] overflow-auto p-4",onClick:xe=>{xe.target===K.current&&F(!1)}},ue.createElement("button",{onClick:()=>F(!1),className:"absolute top-4 right-4 bg-white/10 text-white border-none rounded w-8 h-8 cursor-pointer flex items-center justify-center text-lg leading-none","aria-label":"Close"},"×"),ue.createElement("div",{className:"max-w-[1200px] mx-auto pt-10"},ue.createElement("h1",{className:"text-lg font-bold mb-4 border-b border-gray-700 pb-2"},"Debug Info"),ue.createElement("table",{className:"w-full border-collapse border-spacing-0"},ue.createElement("tbody",null,ue.createElement("tr",{className:"border-b border-gray-700"},ue.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Props"),ue.createElement("td",{className:"p-2 whitespace-pre-wrap break-all"},pe(c))),ue.createElement("tr",{className:"border-b border-gray-700"},ue.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Output"),ue.createElement("td",{className:"p-2 whitespace-pre-wrap break-all"},pe(u))),ue.createElement("tr",{className:"border-b border-gray-700"},ue.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Metadata"),ue.createElement("td",{className:"p-2 whitespace-pre-wrap break-all"},pe(d))),ue.createElement("tr",{className:"border-b border-gray-700"},ue.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"State"),ue.createElement("td",{className:"p-2 whitespace-pre-wrap break-all"},pe(m))),ue.createElement("tr",{className:"border-b border-gray-700"},ue.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Theme"),ue.createElement("td",{className:"p-2"},h)),ue.createElement("tr",{className:"border-b border-gray-700"},ue.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Display Mode"),ue.createElement("td",{className:"p-2"},g)),ue.createElement("tr",{className:"border-b border-gray-700"},ue.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Locale"),ue.createElement("td",{className:"p-2"},y)),ue.createElement("tr",{className:"border-b border-gray-700"},ue.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Max Height"),ue.createElement("td",{className:"p-2"},w,"px")),ue.createElement("tr",{className:"border-b border-gray-700"},ue.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"User Agent"),ue.createElement("td",{className:"p-2"},Le(S))),ue.createElement("tr",{className:"border-b border-gray-700"},ue.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Safe Area"),ue.createElement("td",{className:"p-2"},Fe(v))),ue.createElement("tr",{className:"border-b border-gray-700"},ue.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"API Available"),ue.createElement("td",{className:"p-2"},_?"Yes":"No")),ue.createElement("tr",{className:"border-b border-gray-700"},ue.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"window.openai Keys"),ue.createElement("td",{className:"p-2"},Q.length>0?Q.join(", "):"N/A")))),ue.createElement("h2",{className:"text-base font-bold mt-8 mb-4 border-b border-gray-700 pb-2"},"Actions"),ue.createElement("div",{className:"flex flex-col gap-3"},ue.createElement("div",{className:"flex gap-2 items-center"},ue.createElement("input",{type:"text",value:Y,onChange:xe=>z(xe.target.value),placeholder:"Tool name",className:"py-1.5 px-2 bg-[#1a1a1a] text-white border border-gray-700 rounded font-mono text-xs w-[150px]"}),ue.createElement("input",{type:"text",value:te,onChange:xe=>re(xe.target.value),placeholder:'{"key": "value"}',className:"py-1.5 px-2 bg-[#1a1a1a] text-white border border-gray-700 rounded font-mono text-xs flex-1"}),ue.createElement("button",{onClick:ne,className:"py-1.5 px-3 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-xs"},"Call Tool")),ue.createElement("div",{className:"flex gap-2 items-center"},ue.createElement("input",{type:"text",value:$,onChange:xe=>B(xe.target.value),placeholder:"Follow-up message",className:"py-1.5 px-2 bg-[#1a1a1a] text-white border border-gray-700 rounded font-mono text-xs flex-1"}),ue.createElement("button",{onClick:ce,className:"py-1.5 px-3 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-xs"},"Send Follow-Up")),ue.createElement("div",{className:"flex gap-2 items-center"},ue.createElement("input",{type:"text",value:U,onChange:xe=>L(xe.target.value),placeholder:"External URL",className:"py-1.5 px-2 bg-[#1a1a1a] text-white border border-gray-700 rounded font-mono text-xs flex-1"}),ue.createElement("button",{onClick:ae,className:"py-1.5 px-3 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-xs"},"Open Link")),ue.createElement("div",{className:"flex gap-2 items-center"},ue.createElement("span",{className:"w-[150px] text-xs"},"Display Mode:"),ue.createElement("button",{onClick:()=>ye("inline"),className:"py-1.5 px-3 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-xs flex-1"},"Inline"),ue.createElement("button",{onClick:()=>ye("pip"),className:"py-1.5 px-3 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-xs flex-1"},"PiP"),ue.createElement("button",{onClick:()=>ye("fullscreen"),className:"py-1.5 px-3 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-xs flex-1"},"Fullscreen")),ue.createElement("div",{className:"flex gap-2 items-center"},ue.createElement("button",{onClick:ke,className:"py-1.5 px-3 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-xs"},"Set State (Add Timestamp)")),ie&&ue.createElement("div",{className:"mt-2 p-2 bg-[#1a1a1a] border border-gray-700 rounded whitespace-pre-wrap break-all text-[11px] max-h-[200px] overflow-auto"},ue.createElement("div",{className:"font-bold mb-1 text-gray-400"},"Result:"),ie,ue.createElement("button",{onClick:()=>V(""),className:"mt-2 py-1 px-2 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-[11px]"},"Clear"))))))}Ge(rH,"WidgetControls");function aH(){if(typeof window>"u")return"/";const t=window.location.pathname.match(/^(\/inspector\/api\/dev-widget\/[^/]+)/);return t?t[1]:"/"}Ge(aH,"getBasename");var zae=150,Fae=5;function Bae({children:e,debugger:t=!1,viewControls:n=!1,autoSize:a=!1}){const r=aH(),i=x.useRef(null),s=x.useRef(0),c=x.useRef(null),u=x.useRef(!1),[d,m]=x.useState(null),[h,g]=x.useState(null),[v,w]=x.useState(!0);x.useEffect(()=>{let E=!0;return(async()=>{try{const k=await Ar(()=>import("./index-BP3EqGmh.js"),[]);E&&(m(()=>k.BrowserRouter),w(!1))}catch{E&&(g(new Error(`❌ react-router-dom not installed!
45
45
 
46
46
  To use MCP widgets with McpUseProvider, you need to install:
47
47
 
@@ -99,7 +99,7 @@ Please change the parent <Route path="${E}"> to <Route path="${E==="/"?"*":`${E}
99
99
  `)},ZP=function(){var e=parseInt(document.body.getAttribute(cu)||"0",10);return isFinite(e)?e:0},Yce=function(){x.useEffect(function(){return document.body.setAttribute(cu,(ZP()+1).toString()),function(){var e=ZP()-1;e<=0?document.body.removeAttribute(cu):document.body.setAttribute(cu,e.toString())}},[])},Xce=function(e){var t=e.noRelative,n=e.noImportant,a=e.gapMode,r=a===void 0?"margin":a;Yce();var i=x.useMemo(function(){return Wce(r)},[r]);return x.createElement(Kce,{styles:Zce(i,!t,r,n?"":"!important")})},qx=!1;if(typeof window<"u")try{var Sg=Object.defineProperty({},"passive",{get:function(){return qx=!0,!0}});window.addEventListener("test",Sg,Sg),window.removeEventListener("test",Sg,Sg)}catch{qx=!1}var $c=qx?{passive:!1}:!1,qce=function(e){return e.tagName==="TEXTAREA"},kV=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!qce(e)&&n[t]==="visible")},Jce=function(e){return kV(e,"overflowY")},Qce=function(e){return kV(e,"overflowX")},YP=function(e,t){var n=t.ownerDocument,a=t;do{typeof ShadowRoot<"u"&&a instanceof ShadowRoot&&(a=a.host);var r=TV(e,a);if(r){var i=NV(e,a),s=i[1],c=i[2];if(s>c)return!0}a=a.parentNode}while(a&&a!==n.body);return!1},eue=function(e){var t=e.scrollTop,n=e.scrollHeight,a=e.clientHeight;return[t,n,a]},tue=function(e){var t=e.scrollLeft,n=e.scrollWidth,a=e.clientWidth;return[t,n,a]},TV=function(e,t){return e==="v"?Jce(t):Qce(t)},NV=function(e,t){return e==="v"?eue(t):tue(t)},nue=function(e,t){return e==="h"&&t==="rtl"?-1:1},rue=function(e,t,n,a,r){var i=nue(e,window.getComputedStyle(t).direction),s=i*a,c=n.target,u=t.contains(c),d=!1,m=s>0,h=0,g=0;do{if(!c)break;var v=NV(e,c),w=v[0],S=v[1],y=v[2],_=S-y-i*w;(w||_)&&TV(e,c)&&(h+=_,g+=w);var E=c.parentNode;c=E&&E.nodeType===Node.DOCUMENT_FRAGMENT_NODE?E.host:E}while(!u&&c!==document.body||u&&(t.contains(c)||t===c));return(m&&Math.abs(h)<1||!m&&Math.abs(g)<1)&&(d=!0),d},xg=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},XP=function(e){return[e.deltaX,e.deltaY]},qP=function(e){return e&&"current"in e?e.current:e},aue=function(e,t){return e[0]===t[0]&&e[1]===t[1]},iue=function(e){return`
100
100
  .block-interactivity-`.concat(e,` {pointer-events: none;}
101
101
  .allow-interactivity-`).concat(e,` {pointer-events: all;}
102
- `)},oue=0,jc=[];function sue(e){var t=x.useRef([]),n=x.useRef([0,0]),a=x.useRef(),r=x.useState(oue++)[0],i=x.useState(_V)[0],s=x.useRef(e);x.useEffect(function(){s.current=e},[e]),x.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(r));var S=Rce([e.lockRef.current],(e.shards||[]).map(qP),!0).filter(Boolean);return S.forEach(function(y){return y.classList.add("allow-interactivity-".concat(r))}),function(){document.body.classList.remove("block-interactivity-".concat(r)),S.forEach(function(y){return y.classList.remove("allow-interactivity-".concat(r))})}}},[e.inert,e.lockRef.current,e.shards]);var c=x.useCallback(function(S,y){if("touches"in S&&S.touches.length===2||S.type==="wheel"&&S.ctrlKey)return!s.current.allowPinchZoom;var _=xg(S),E=n.current,k="deltaX"in S?S.deltaX:E[0]-_[0],C="deltaY"in S?S.deltaY:E[1]-_[1],R,A=S.target,I=Math.abs(k)>Math.abs(C)?"h":"v";if("touches"in S&&I==="h"&&A.type==="range")return!1;var O=YP(I,A);if(!O)return!0;if(O?R=I:(R=I==="v"?"h":"v",O=YP(I,A)),!O)return!1;if(!a.current&&"changedTouches"in S&&(k||C)&&(a.current=R),!R)return!0;var j=a.current||R;return rue(j,y,S,j==="h"?k:C)},[]),u=x.useCallback(function(S){var y=S;if(!(!jc.length||jc[jc.length-1]!==i)){var _="deltaY"in y?XP(y):xg(y),E=t.current.filter(function(R){return R.name===y.type&&(R.target===y.target||y.target===R.shadowParent)&&aue(R.delta,_)})[0];if(E&&E.should){y.cancelable&&y.preventDefault();return}if(!E){var k=(s.current.shards||[]).map(qP).filter(Boolean).filter(function(R){return R.contains(y.target)}),C=k.length>0?c(y,k[0]):!s.current.noIsolation;C&&y.cancelable&&y.preventDefault()}}},[]),d=x.useCallback(function(S,y,_,E){var k={name:S,delta:y,target:_,should:E,shadowParent:lue(_)};t.current.push(k),setTimeout(function(){t.current=t.current.filter(function(C){return C!==k})},1)},[]),m=x.useCallback(function(S){n.current=xg(S),a.current=void 0},[]),h=x.useCallback(function(S){d(S.type,XP(S),S.target,c(S,e.lockRef.current))},[]),g=x.useCallback(function(S){d(S.type,xg(S),S.target,c(S,e.lockRef.current))},[]);x.useEffect(function(){return jc.push(i),e.setCallbacks({onScrollCapture:h,onWheelCapture:h,onTouchMoveCapture:g}),document.addEventListener("wheel",u,$c),document.addEventListener("touchmove",u,$c),document.addEventListener("touchstart",m,$c),function(){jc=jc.filter(function(S){return S!==i}),document.removeEventListener("wheel",u,$c),document.removeEventListener("touchmove",u,$c),document.removeEventListener("touchstart",m,$c)}},[]);var v=e.removeScrollBar,w=e.inert;return x.createElement(x.Fragment,null,w?x.createElement(i,{styles:iue(r)}):null,v?x.createElement(Xce,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function lue(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const cue=Mce(EV,sue);var Wp=x.forwardRef(function(e,t){return x.createElement(Kv,Di({},e,{ref:t,sideCar:cue}))});Wp.classNames=Kv.classNames;var Jx=["Enter"," "],uue=["ArrowDown","PageUp","Home"],RV=["ArrowUp","PageDown","End"],due=[...uue,...RV],fue={ltr:[...Jx,"ArrowRight"],rtl:[...Jx,"ArrowLeft"]},pue={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Kp="Menu",[np,mue,hue]=AT(Kp),[Bl,CV]=_i(Kp,[hue,Ps,hV]),Zv=Ps(),AV=hV(),[gue,Hl]=Bl(Kp),[bue,Zp]=Bl(Kp),IV=e=>{const{__scopeMenu:t,open:n=!1,children:a,dir:r,onOpenChange:i,modal:s=!0}=e,c=Zv(t),[u,d]=x.useState(null),m=x.useRef(!1),h=Fi(i),g=IT(r);return x.useEffect(()=>{const v=()=>{m.current=!0,document.addEventListener("pointerdown",w,{capture:!0,once:!0}),document.addEventListener("pointermove",w,{capture:!0,once:!0})},w=()=>m.current=!1;return document.addEventListener("keydown",v,{capture:!0}),()=>{document.removeEventListener("keydown",v,{capture:!0}),document.removeEventListener("pointerdown",w,{capture:!0}),document.removeEventListener("pointermove",w,{capture:!0})}},[]),p.jsx(Hv,{...c,children:p.jsx(gue,{scope:t,open:n,onOpenChange:h,content:u,onContentChange:d,children:p.jsx(bue,{scope:t,onClose:x.useCallback(()=>h(!1),[h]),isUsingKeyboardRef:m,dir:g,modal:s,children:a})})})};IV.displayName=Kp;var vue="MenuAnchor",FT=x.forwardRef((e,t)=>{const{__scopeMenu:n,...a}=e,r=Zv(n);return p.jsx(Vp,{...r,...a,ref:t})});FT.displayName=vue;var BT="MenuPortal",[yue,OV]=Bl(BT,{forceMount:void 0}),DV=e=>{const{__scopeMenu:t,forceMount:n,children:a,container:r}=e,i=Hl(BT,t);return p.jsx(yue,{scope:t,forceMount:n,children:p.jsx(Ma,{present:n||i.open,children:p.jsx(rd,{asChild:!0,container:r,children:a})})})};DV.displayName=BT;var Ja="MenuContent",[wue,HT]=Bl(Ja),LV=x.forwardRef((e,t)=>{const n=OV(Ja,e.__scopeMenu),{forceMount:a=n.forceMount,...r}=e,i=Hl(Ja,e.__scopeMenu),s=Zp(Ja,e.__scopeMenu);return p.jsx(np.Provider,{scope:e.__scopeMenu,children:p.jsx(Ma,{present:a||i.open,children:p.jsx(np.Slot,{scope:e.__scopeMenu,children:s.modal?p.jsx(Sue,{...r,ref:t}):p.jsx(xue,{...r,ref:t})})})})}),Sue=x.forwardRef((e,t)=>{const n=Hl(Ja,e.__scopeMenu),a=x.useRef(null),r=Gt(t,a);return x.useEffect(()=>{const i=a.current;if(i)return Wv(i)},[]),p.jsx(VT,{...e,ref:r,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:He(e.onFocusOutside,i=>i.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),xue=x.forwardRef((e,t)=>{const n=Hl(Ja,e.__scopeMenu);return p.jsx(VT,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),Eue=Il("MenuContent.ScrollLock"),VT=x.forwardRef((e,t)=>{const{__scopeMenu:n,loop:a=!1,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:s,disableOutsidePointerEvents:c,onEntryFocus:u,onEscapeKeyDown:d,onPointerDownOutside:m,onFocusOutside:h,onInteractOutside:g,onDismiss:v,disableOutsideScroll:w,...S}=e,y=Hl(Ja,n),_=Zp(Ja,n),E=Zv(n),k=AV(n),C=mue(n),[R,A]=x.useState(null),I=x.useRef(null),O=Gt(t,I,y.onContentChange),j=x.useRef(0),F=x.useRef(""),H=x.useRef(0),K=x.useRef(null),Q=x.useRef("right"),W=x.useRef(0),ie=w?Wp:x.Fragment,V=w?{as:Eue,allowPinchZoom:!0}:void 0,Y=te=>{const re=F.current+te,$=C().filter(Z=>!Z.disabled),B=document.activeElement,U=$.find(Z=>Z.ref.current===B)?.textValue,L=$.map(Z=>Z.textValue),P=$ue(L,re,U),G=$.find(Z=>Z.textValue===P)?.ref.current;(function Z(J){F.current=J,window.clearTimeout(j.current),J!==""&&(j.current=window.setTimeout(()=>Z(""),1e3))})(re),G&&setTimeout(()=>G.focus())};x.useEffect(()=>()=>window.clearTimeout(j.current),[]),Pv();const z=x.useCallback(te=>Q.current===K.current?.side&&Mue(te,K.current?.area),[]);return p.jsx(wue,{scope:n,searchRef:F,onItemEnter:x.useCallback(te=>{z(te)&&te.preventDefault()},[z]),onItemLeave:x.useCallback(te=>{z(te)||(I.current?.focus(),A(null))},[z]),onTriggerLeave:x.useCallback(te=>{z(te)&&te.preventDefault()},[z]),pointerGraceTimerRef:H,onPointerGraceIntentChange:x.useCallback(te=>{K.current=te},[]),children:p.jsx(ie,{...V,children:p.jsx(Bp,{asChild:!0,trapped:r,onMountAutoFocus:He(i,te=>{te.preventDefault(),I.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:s,children:p.jsx(ed,{asChild:!0,disableOutsidePointerEvents:c,onEscapeKeyDown:d,onPointerDownOutside:m,onFocusOutside:h,onInteractOutside:g,onDismiss:v,children:p.jsx(Ece,{asChild:!0,...k,dir:_.dir,orientation:"vertical",loop:a,currentTabStopId:R,onCurrentTabStopIdChange:A,onEntryFocus:He(u,te=>{_.isUsingKeyboardRef.current||te.preventDefault()}),preventScrollOnEntryFocus:!0,children:p.jsx(Vv,{role:"menu","aria-orientation":"vertical","data-state":XV(y.open),"data-radix-menu-content":"",dir:_.dir,...E,...S,ref:O,style:{outline:"none",...S.style},onKeyDown:He(S.onKeyDown,te=>{const $=te.target.closest("[data-radix-menu-content]")===te.currentTarget,B=te.ctrlKey||te.altKey||te.metaKey,U=te.key.length===1;$&&(te.key==="Tab"&&te.preventDefault(),!B&&U&&Y(te.key));const L=I.current;if(te.target!==L||!due.includes(te.key))return;te.preventDefault();const G=C().filter(Z=>!Z.disabled).map(Z=>Z.ref.current);RV.includes(te.key)&&G.reverse(),Due(G)}),onBlur:He(e.onBlur,te=>{te.currentTarget.contains(te.target)||(window.clearTimeout(j.current),F.current="")}),onPointerMove:He(e.onPointerMove,rp(te=>{const re=te.target,$=W.current!==te.clientX;if(te.currentTarget.contains(re)&&$){const B=te.clientX>W.current?"right":"left";Q.current=B,W.current=te.clientX}}))})})})})})})});LV.displayName=Ja;var _ue="MenuGroup",GT=x.forwardRef((e,t)=>{const{__scopeMenu:n,...a}=e;return p.jsx(St.div,{role:"group",...a,ref:t})});GT.displayName=_ue;var kue="MenuLabel",$V=x.forwardRef((e,t)=>{const{__scopeMenu:n,...a}=e;return p.jsx(St.div,{...a,ref:t})});$V.displayName=kue;var Ob="MenuItem",JP="menu.itemSelect",Yv=x.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:a,...r}=e,i=x.useRef(null),s=Zp(Ob,e.__scopeMenu),c=HT(Ob,e.__scopeMenu),u=Gt(t,i),d=x.useRef(!1),m=()=>{const h=i.current;if(!n&&h){const g=new CustomEvent(JP,{bubbles:!0,cancelable:!0});h.addEventListener(JP,v=>a?.(v),{once:!0}),HH(h,g),g.defaultPrevented?d.current=!1:s.onClose()}};return p.jsx(jV,{...r,ref:u,disabled:n,onClick:He(e.onClick,m),onPointerDown:h=>{e.onPointerDown?.(h),d.current=!0},onPointerUp:He(e.onPointerUp,h=>{d.current||h.currentTarget?.click()}),onKeyDown:He(e.onKeyDown,h=>{const g=c.searchRef.current!=="";n||g&&h.key===" "||Jx.includes(h.key)&&(h.currentTarget.click(),h.preventDefault())})})});Yv.displayName=Ob;var jV=x.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:a=!1,textValue:r,...i}=e,s=HT(Ob,n),c=AV(n),u=x.useRef(null),d=Gt(t,u),[m,h]=x.useState(!1),[g,v]=x.useState("");return x.useEffect(()=>{const w=u.current;w&&v((w.textContent??"").trim())},[i.children]),p.jsx(np.ItemSlot,{scope:n,disabled:a,textValue:r??g,children:p.jsx(_ce,{asChild:!0,...c,focusable:!a,children:p.jsx(St.div,{role:"menuitem","data-highlighted":m?"":void 0,"aria-disabled":a||void 0,"data-disabled":a?"":void 0,...i,ref:d,onPointerMove:He(e.onPointerMove,rp(w=>{a?s.onItemLeave(w):(s.onItemEnter(w),w.defaultPrevented||w.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:He(e.onPointerLeave,rp(w=>s.onItemLeave(w))),onFocus:He(e.onFocus,()=>h(!0)),onBlur:He(e.onBlur,()=>h(!1))})})})}),Tue="MenuCheckboxItem",MV=x.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:a,...r}=e;return p.jsx(BV,{scope:e.__scopeMenu,checked:n,children:p.jsx(Yv,{role:"menuitemcheckbox","aria-checked":Db(n)?"mixed":n,...r,ref:t,"data-state":KT(n),onSelect:He(r.onSelect,()=>a?.(Db(n)?!0:!n),{checkForDefaultPrevented:!1})})})});MV.displayName=Tue;var PV="MenuRadioGroup",[Nue,Rue]=Bl(PV,{value:void 0,onValueChange:()=>{}}),UV=x.forwardRef((e,t)=>{const{value:n,onValueChange:a,...r}=e,i=Fi(a);return p.jsx(Nue,{scope:e.__scopeMenu,value:n,onValueChange:i,children:p.jsx(GT,{...r,ref:t})})});UV.displayName=PV;var zV="MenuRadioItem",FV=x.forwardRef((e,t)=>{const{value:n,...a}=e,r=Rue(zV,e.__scopeMenu),i=n===r.value;return p.jsx(BV,{scope:e.__scopeMenu,checked:i,children:p.jsx(Yv,{role:"menuitemradio","aria-checked":i,...a,ref:t,"data-state":KT(i),onSelect:He(a.onSelect,()=>r.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});FV.displayName=zV;var WT="MenuItemIndicator",[BV,Cue]=Bl(WT,{checked:!1}),HV=x.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:a,...r}=e,i=Cue(WT,n);return p.jsx(Ma,{present:a||Db(i.checked)||i.checked===!0,children:p.jsx(St.span,{...r,ref:t,"data-state":KT(i.checked)})})});HV.displayName=WT;var Aue="MenuSeparator",VV=x.forwardRef((e,t)=>{const{__scopeMenu:n,...a}=e;return p.jsx(St.div,{role:"separator","aria-orientation":"horizontal",...a,ref:t})});VV.displayName=Aue;var Iue="MenuArrow",GV=x.forwardRef((e,t)=>{const{__scopeMenu:n,...a}=e,r=Zv(n);return p.jsx(Gv,{...r,...a,ref:t})});GV.displayName=Iue;var Oue="MenuSub",[J_e,WV]=Bl(Oue),wf="MenuSubTrigger",KV=x.forwardRef((e,t)=>{const n=Hl(wf,e.__scopeMenu),a=Zp(wf,e.__scopeMenu),r=WV(wf,e.__scopeMenu),i=HT(wf,e.__scopeMenu),s=x.useRef(null),{pointerGraceTimerRef:c,onPointerGraceIntentChange:u}=i,d={__scopeMenu:e.__scopeMenu},m=x.useCallback(()=>{s.current&&window.clearTimeout(s.current),s.current=null},[]);return x.useEffect(()=>m,[m]),x.useEffect(()=>{const h=c.current;return()=>{window.clearTimeout(h),u(null)}},[c,u]),p.jsx(FT,{asChild:!0,...d,children:p.jsx(jV,{id:r.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":r.contentId,"data-state":XV(n.open),...e,ref:zi(t,r.onTriggerChange),onClick:h=>{e.onClick?.(h),!(e.disabled||h.defaultPrevented)&&(h.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:He(e.onPointerMove,rp(h=>{i.onItemEnter(h),!h.defaultPrevented&&!e.disabled&&!n.open&&!s.current&&(i.onPointerGraceIntentChange(null),s.current=window.setTimeout(()=>{n.onOpenChange(!0),m()},100))})),onPointerLeave:He(e.onPointerLeave,rp(h=>{m();const g=n.content?.getBoundingClientRect();if(g){const v=n.content?.dataset.side,w=v==="right",S=w?-5:5,y=g[w?"left":"right"],_=g[w?"right":"left"];i.onPointerGraceIntentChange({area:[{x:h.clientX+S,y:h.clientY},{x:y,y:g.top},{x:_,y:g.top},{x:_,y:g.bottom},{x:y,y:g.bottom}],side:v}),window.clearTimeout(c.current),c.current=window.setTimeout(()=>i.onPointerGraceIntentChange(null),300)}else{if(i.onTriggerLeave(h),h.defaultPrevented)return;i.onPointerGraceIntentChange(null)}})),onKeyDown:He(e.onKeyDown,h=>{const g=i.searchRef.current!=="";e.disabled||g&&h.key===" "||fue[a.dir].includes(h.key)&&(n.onOpenChange(!0),n.content?.focus(),h.preventDefault())})})})});KV.displayName=wf;var ZV="MenuSubContent",YV=x.forwardRef((e,t)=>{const n=OV(Ja,e.__scopeMenu),{forceMount:a=n.forceMount,...r}=e,i=Hl(Ja,e.__scopeMenu),s=Zp(Ja,e.__scopeMenu),c=WV(ZV,e.__scopeMenu),u=x.useRef(null),d=Gt(t,u);return p.jsx(np.Provider,{scope:e.__scopeMenu,children:p.jsx(Ma,{present:a||i.open,children:p.jsx(np.Slot,{scope:e.__scopeMenu,children:p.jsx(VT,{id:c.contentId,"aria-labelledby":c.triggerId,...r,ref:d,align:"start",side:s.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:m=>{s.isUsingKeyboardRef.current&&u.current?.focus(),m.preventDefault()},onCloseAutoFocus:m=>m.preventDefault(),onFocusOutside:He(e.onFocusOutside,m=>{m.target!==c.trigger&&i.onOpenChange(!1)}),onEscapeKeyDown:He(e.onEscapeKeyDown,m=>{s.onClose(),m.preventDefault()}),onKeyDown:He(e.onKeyDown,m=>{const h=m.currentTarget.contains(m.target),g=pue[s.dir].includes(m.key);h&&g&&(i.onOpenChange(!1),c.trigger?.focus(),m.preventDefault())})})})})})});YV.displayName=ZV;function XV(e){return e?"open":"closed"}function Db(e){return e==="indeterminate"}function KT(e){return Db(e)?"indeterminate":e?"checked":"unchecked"}function Due(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function Lue(e,t){return e.map((n,a)=>e[(t+a)%e.length])}function $ue(e,t,n){const r=t.length>1&&Array.from(t).every(d=>d===t[0])?t[0]:t,i=n?e.indexOf(n):-1;let s=Lue(e,Math.max(i,0));r.length===1&&(s=s.filter(d=>d!==n));const u=s.find(d=>d.toLowerCase().startsWith(r.toLowerCase()));return u!==n?u:void 0}function jue(e,t){const{x:n,y:a}=e;let r=!1;for(let i=0,s=t.length-1;i<t.length;s=i++){const c=t[i],u=t[s],d=c.x,m=c.y,h=u.x,g=u.y;m>a!=g>a&&n<(h-d)*(a-m)/(g-m)+d&&(r=!r)}return r}function Mue(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return jue(n,t)}function rp(e){return t=>t.pointerType==="mouse"?e(t):void 0}var Pue=IV,Uue=FT,zue=DV,Fue=LV,Bue=GT,Hue=$V,Vue=Yv,Gue=MV,Wue=UV,Kue=FV,Zue=HV,Yue=VV,Xue=GV,que=KV,Jue=YV,Xv="DropdownMenu",[Que]=_i(Xv,[CV]),ta=CV(),[ede,qV]=Que(Xv),JV=e=>{const{__scopeDropdownMenu:t,children:n,dir:a,open:r,defaultOpen:i,onOpenChange:s,modal:c=!0}=e,u=ta(t),d=x.useRef(null),[m,h]=Co({prop:r,defaultProp:i??!1,onChange:s,caller:Xv});return p.jsx(ede,{scope:t,triggerId:Ir(),triggerRef:d,contentId:Ir(),open:m,onOpenChange:h,onOpenToggle:x.useCallback(()=>h(g=>!g),[h]),modal:c,children:p.jsx(Pue,{...u,open:m,onOpenChange:h,dir:a,modal:c,children:n})})};JV.displayName=Xv;var QV="DropdownMenuTrigger",e9=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:a=!1,...r}=e,i=qV(QV,n),s=ta(n);return p.jsx(Uue,{asChild:!0,...s,children:p.jsx(St.button,{type:"button",id:i.triggerId,"aria-haspopup":"menu","aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":i.open?"open":"closed","data-disabled":a?"":void 0,disabled:a,...r,ref:zi(t,i.triggerRef),onPointerDown:He(e.onPointerDown,c=>{!a&&c.button===0&&c.ctrlKey===!1&&(i.onOpenToggle(),i.open||c.preventDefault())}),onKeyDown:He(e.onKeyDown,c=>{a||(["Enter"," "].includes(c.key)&&i.onOpenToggle(),c.key==="ArrowDown"&&i.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(c.key)&&c.preventDefault())})})})});e9.displayName=QV;var tde="DropdownMenuPortal",t9=e=>{const{__scopeDropdownMenu:t,...n}=e,a=ta(t);return p.jsx(zue,{...a,...n})};t9.displayName=tde;var n9="DropdownMenuContent",r9=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=qV(n9,n),i=ta(n),s=x.useRef(!1);return p.jsx(Fue,{id:r.contentId,"aria-labelledby":r.triggerId,...i,...a,ref:t,onCloseAutoFocus:He(e.onCloseAutoFocus,c=>{s.current||r.triggerRef.current?.focus(),s.current=!1,c.preventDefault()}),onInteractOutside:He(e.onInteractOutside,c=>{const u=c.detail.originalEvent,d=u.button===0&&u.ctrlKey===!0,m=u.button===2||d;(!r.modal||m)&&(s.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});r9.displayName=n9;var nde="DropdownMenuGroup",rde=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ta(n);return p.jsx(Bue,{...r,...a,ref:t})});rde.displayName=nde;var ade="DropdownMenuLabel",a9=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ta(n);return p.jsx(Hue,{...r,...a,ref:t})});a9.displayName=ade;var ide="DropdownMenuItem",i9=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ta(n);return p.jsx(Vue,{...r,...a,ref:t})});i9.displayName=ide;var ode="DropdownMenuCheckboxItem",o9=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ta(n);return p.jsx(Gue,{...r,...a,ref:t})});o9.displayName=ode;var sde="DropdownMenuRadioGroup",lde=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ta(n);return p.jsx(Wue,{...r,...a,ref:t})});lde.displayName=sde;var cde="DropdownMenuRadioItem",s9=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ta(n);return p.jsx(Kue,{...r,...a,ref:t})});s9.displayName=cde;var ude="DropdownMenuItemIndicator",dde=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ta(n);return p.jsx(Zue,{...r,...a,ref:t})});dde.displayName=ude;var fde="DropdownMenuSeparator",l9=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ta(n);return p.jsx(Yue,{...r,...a,ref:t})});l9.displayName=fde;var pde="DropdownMenuArrow",mde=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ta(n);return p.jsx(Xue,{...r,...a,ref:t})});mde.displayName=pde;var hde="DropdownMenuSubTrigger",c9=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ta(n);return p.jsx(que,{...r,...a,ref:t})});c9.displayName=hde;var gde="DropdownMenuSubContent",u9=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ta(n);return p.jsx(Jue,{...r,...a,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});u9.displayName=gde;var bde=JV,vde=e9,yde=t9,d9=r9,f9=a9,p9=i9,wde=o9,Sde=s9,m9=l9,xde=c9,Ede=u9;const Qx=bde,eE=vde;xde.displayName;Ede.displayName;function Lb({ref:e,className:t,sideOffset:n=4,...a}){return p.jsx(yde,{children:p.jsx(d9,{ref:e,sideOffset:n,className:De("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md","data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-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",t),...a})})}Lb.displayName=d9.displayName;function So({ref:e,className:t,inset:n,...a}){return p.jsx(p9,{ref:e,className:De("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",n&&"pl-8",t),...a})}So.displayName=p9.displayName;wde.displayName;Sde.displayName;function tE({ref:e,className:t,inset:n,...a}){return p.jsx(f9,{ref:e,className:De("px-2 py-1.5 text-sm font-semibold",n&&"pl-8",t),...a})}tE.displayName=f9.displayName;function Sf({ref:e,className:t,...n}){return p.jsx(m9,{ref:e,className:De("-mx-1 my-1 h-px bg-muted",t),...n})}Sf.displayName=m9.displayName;var _de=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Uo=_de.reduce((e,t)=>{const n=kH(`Primitive.${t}`),a=x.forwardRef((r,i)=>{const{asChild:s,...c}=r,u=s?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),p.jsx(u,{...c,ref:i})});return a.displayName=`Primitive.${t}`,{...e,[t]:a}},{}),kde="Label",h9=x.forwardRef((e,t)=>p.jsx(Uo.label,{...e,ref:t,onMouseDown:n=>{n.target.closest("button, input, select, textarea")||(e.onMouseDown?.(n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));h9.displayName=kde;var Tde=h9;function Yt({className:e,...t}){return p.jsx(Tde,{"data-slot":"label",className:De("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",e),...t})}function Yp({message:e,className:t="",vertical:n,noBorder:a}){return p.jsx("div",{className:De(`mt-2 rounded-md p-6 ${t}`,!a&&"border"),children:p.jsxs("p",{className:De("text-sm text-muted-foreground flex items-center gap-4",n&&"flex-col"),children:[p.jsx("svg",{width:"40",height:"40",viewBox:"0 0 273 273",version:"1.1",xmlns:"http://www.w3.org/2000/svg",className:"flex-shrink-0",children:p.jsx("g",{stroke:"none",strokeWidth:"1",fill:"none",fillRule:"evenodd",children:p.jsxs("g",{transform:"translate(5.320900, 5.320900)",fillRule:"nonzero",className:"stroke-black dark:stroke-white",strokeWidth:"4",children:[p.jsx("path",{d:"M49.953025,-2.10854389 C63.26892,-2.21867124 76.6185256,2.70621155 86.9019463,12.6653164 L86.9019463,12.6653164 L87.505627,13.2592944 C97.5154947,23.2654892 102.640454,36.3074513 102.880738,49.4222247 C103.08932,77.4533067 113.877287,105.391753 135.242867,126.757333 C156.613383,148.127849 184.559216,158.914875 212.568138,159.119313 L212.568138,159.119313 L213.212264,159.134159 C225.843948,159.517566 238.363557,164.434972 248.121998,173.886137 L248.121998,173.886137 L248.725621,174.480088 C258.982114,184.732164 264.11035,198.171134 264.11035,211.6101 C264.11035,225.04592 258.984514,238.481745 248.732867,248.732867 C238.592792,258.872942 225.336706,263.997882 212.046872,264.107794 C198.731075,264.21792 185.381569,259.293085 175.098248,249.334078 L175.098248,249.334078 L174.494602,248.740134 C163.75802,238.008189 158.640853,223.784027 159.143413,209.719372 C158.258245,182.640933 147.489786,155.83332 126.828333,135.171867 C106.351297,114.694831 79.8363505,103.934873 53.0237258,102.891841 L53.0237258,102.891841 L52.2811438,102.865674 C38.4791718,103.347421 24.5325234,98.4328111 13.8776628,88.1140866 L13.8776628,88.1140866 L13.2739843,87.5201168 C3.12895117,77.3789607 -1.9984796,64.1195994 -2.10841888,50.8264755 C-2.21854669,37.5105567 2.70635908,24.1609269 12.6655135,13.8774565 L12.6655135,13.8774565 L13.2594878,13.2737797 C23.4005926,3.12880025 36.659927,-1.99860507 49.953025,-2.10854389 Z"}),p.jsx("circle",{cx:"50",cy:"212.0001",r:"52.5"}),p.jsx("circle",{cx:"212.0001",cy:"50",r:"52.5"})]})})}),e]})})}function g9({className:e,color:t,children:n,grayscaled:a=!1}){const r=x.useMemo(()=>{if(t){const h=t.split("(")[1].split(")")[0].trim().split(/\s+/);return Number.parseFloat(h[1]||"0")}return a?0:.2},[t,a]),i=x.useMemo(()=>{if(t){const h=t.split("(")[1].split(")")[0].trim().split(/\s+/);return Number.parseFloat(h[0]||"0.5")}return a?.3:.4},[t,a]),s=x.useMemo(()=>{if(t){const h=t.split("(")[1].split(")")[0].trim().split(/\s+/);return Number.parseFloat(h[2]||"0")}return Math.floor(Math.random()*360)},[t]),c=x.useMemo(()=>t||`oklch(${Math.min(i,1)} ${r} ${s})`,[s,r,i]),u=x.useMemo(()=>`oklch(${Math.min(i*2,1)} ${r} ${s})`,[s,r,i,t]),d=x.useMemo(()=>Math.floor(Math.random()*360),[s]),m=x.useMemo(()=>"1000%",[]);return p.jsx("section",{className:De("relative w-full h-full overflow-hidden",e),style:{background:`${u}`},children:p.jsxs("div",{className:"isolate relative w-full h-full",children:[p.jsx("div",{className:"noise w-full h-full",style:{background:`linear-gradient(${d}deg, ${c}, transparent), url(https://grainy-gradients.vercel.app/noise.svg)`,filter:`contrast(120%) brightness(${m})`}}),n&&p.jsx("div",{className:"relative z-10 w-full h-full",children:n})]})})}function ZT(e){const t=x.useRef({value:e,previous:e});return x.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var qv="Switch",[Nde]=_i(qv),[Rde,Cde]=Nde(qv),b9=x.forwardRef((e,t)=>{const{__scopeSwitch:n,name:a,checked:r,defaultChecked:i,required:s,disabled:c,value:u="on",onCheckedChange:d,form:m,...h}=e,[g,v]=x.useState(null),w=Gt(t,k=>v(k)),S=x.useRef(!1),y=g?m||!!g.closest("form"):!0,[_,E]=Co({prop:r,defaultProp:i??!1,onChange:d,caller:qv});return p.jsxs(Rde,{scope:n,checked:_,disabled:c,children:[p.jsx(St.button,{type:"button",role:"switch","aria-checked":_,"aria-required":s,"data-state":S9(_),"data-disabled":c?"":void 0,disabled:c,value:u,...h,ref:w,onClick:He(e.onClick,k=>{E(C=>!C),y&&(S.current=k.isPropagationStopped(),S.current||k.stopPropagation())})}),y&&p.jsx(w9,{control:g,bubbles:!S.current,name:a,value:u,checked:_,required:s,disabled:c,form:m,style:{transform:"translateX(-100%)"}})]})});b9.displayName=qv;var v9="SwitchThumb",y9=x.forwardRef((e,t)=>{const{__scopeSwitch:n,...a}=e,r=Cde(v9,n);return p.jsx(St.span,{"data-state":S9(r.checked),"data-disabled":r.disabled?"":void 0,...a,ref:t})});y9.displayName=v9;var Ade="SwitchBubbleInput",w9=x.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:a=!0,...r},i)=>{const s=x.useRef(null),c=Gt(s,i),u=ZT(n),d=PT(t);return x.useEffect(()=>{const m=s.current;if(!m)return;const h=window.HTMLInputElement.prototype,v=Object.getOwnPropertyDescriptor(h,"checked").set;if(u!==n&&v){const w=new Event("click",{bubbles:a});v.call(m,n),m.dispatchEvent(w)}},[u,n,a]),p.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...r,tabIndex:-1,ref:c,style:{...r.style,...d,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});w9.displayName=Ade;function S9(e){return e?"checked":"unchecked"}var x9=b9,Ide=y9;function Jv({ref:e,className:t,...n}){return p.jsx(x9,{className:De("peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",t),...n,ref:e,children:p.jsx(Ide,{className:De("pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0")})})}Jv.displayName=x9.displayName;var E9=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),Ode="VisuallyHidden",_9=x.forwardRef((e,t)=>p.jsx(St.span,{...e,ref:t,style:{...E9,...e.style}}));_9.displayName=Ode;var Dde=_9,[Qv]=_i("Tooltip",[Ps]),ey=Ps(),k9="TooltipProvider",Lde=700,nE="tooltip.open",[$de,YT]=Qv(k9),T9=e=>{const{__scopeTooltip:t,delayDuration:n=Lde,skipDelayDuration:a=300,disableHoverableContent:r=!1,children:i}=e,s=x.useRef(!0),c=x.useRef(!1),u=x.useRef(0);return x.useEffect(()=>{const d=u.current;return()=>window.clearTimeout(d)},[]),p.jsx($de,{scope:t,isOpenDelayedRef:s,delayDuration:n,onOpen:x.useCallback(()=>{window.clearTimeout(u.current),s.current=!1},[]),onClose:x.useCallback(()=>{window.clearTimeout(u.current),u.current=window.setTimeout(()=>s.current=!0,a)},[a]),isPointerInTransitRef:c,onPointerInTransitChange:x.useCallback(d=>{c.current=d},[]),disableHoverableContent:r,children:i})};T9.displayName=k9;var ap="Tooltip",[jde,Xp]=Qv(ap),N9=e=>{const{__scopeTooltip:t,children:n,open:a,defaultOpen:r,onOpenChange:i,disableHoverableContent:s,delayDuration:c}=e,u=YT(ap,e.__scopeTooltip),d=ey(t),[m,h]=x.useState(null),g=Ir(),v=x.useRef(0),w=s??u.disableHoverableContent,S=c??u.delayDuration,y=x.useRef(!1),[_,E]=Co({prop:a,defaultProp:r??!1,onChange:I=>{I?(u.onOpen(),document.dispatchEvent(new CustomEvent(nE))):u.onClose(),i?.(I)},caller:ap}),k=x.useMemo(()=>_?y.current?"delayed-open":"instant-open":"closed",[_]),C=x.useCallback(()=>{window.clearTimeout(v.current),v.current=0,y.current=!1,E(!0)},[E]),R=x.useCallback(()=>{window.clearTimeout(v.current),v.current=0,E(!1)},[E]),A=x.useCallback(()=>{window.clearTimeout(v.current),v.current=window.setTimeout(()=>{y.current=!0,E(!0),v.current=0},S)},[S,E]);return x.useEffect(()=>()=>{v.current&&(window.clearTimeout(v.current),v.current=0)},[]),p.jsx(Hv,{...d,children:p.jsx(jde,{scope:t,contentId:g,open:_,stateAttribute:k,trigger:m,onTriggerChange:h,onTriggerEnter:x.useCallback(()=>{u.isOpenDelayedRef.current?A():C()},[u.isOpenDelayedRef,A,C]),onTriggerLeave:x.useCallback(()=>{w?R():(window.clearTimeout(v.current),v.current=0)},[R,w]),onOpen:C,onClose:R,disableHoverableContent:w,children:n})})};N9.displayName=ap;var rE="TooltipTrigger",R9=x.forwardRef((e,t)=>{const{__scopeTooltip:n,...a}=e,r=Xp(rE,n),i=YT(rE,n),s=ey(n),c=x.useRef(null),u=Gt(t,c,r.onTriggerChange),d=x.useRef(!1),m=x.useRef(!1),h=x.useCallback(()=>d.current=!1,[]);return x.useEffect(()=>()=>document.removeEventListener("pointerup",h),[h]),p.jsx(Vp,{asChild:!0,...s,children:p.jsx(St.button,{"aria-describedby":r.open?r.contentId:void 0,"data-state":r.stateAttribute,...a,ref:u,onPointerMove:He(e.onPointerMove,g=>{g.pointerType!=="touch"&&!m.current&&!i.isPointerInTransitRef.current&&(r.onTriggerEnter(),m.current=!0)}),onPointerLeave:He(e.onPointerLeave,()=>{r.onTriggerLeave(),m.current=!1}),onPointerDown:He(e.onPointerDown,()=>{r.open&&r.onClose(),d.current=!0,document.addEventListener("pointerup",h,{once:!0})}),onFocus:He(e.onFocus,()=>{d.current||r.onOpen()}),onBlur:He(e.onBlur,r.onClose),onClick:He(e.onClick,r.onClose)})})});R9.displayName=rE;var XT="TooltipPortal",[Mde,Pde]=Qv(XT,{forceMount:void 0}),C9=e=>{const{__scopeTooltip:t,forceMount:n,children:a,container:r}=e,i=Xp(XT,t);return p.jsx(Mde,{scope:t,forceMount:n,children:p.jsx(Ma,{present:n||i.open,children:p.jsx(rd,{asChild:!0,container:r,children:a})})})};C9.displayName=XT;var $u="TooltipContent",A9=x.forwardRef((e,t)=>{const n=Pde($u,e.__scopeTooltip),{forceMount:a=n.forceMount,side:r="top",...i}=e,s=Xp($u,e.__scopeTooltip);return p.jsx(Ma,{present:a||s.open,children:s.disableHoverableContent?p.jsx(I9,{side:r,...i,ref:t}):p.jsx(Ude,{side:r,...i,ref:t})})}),Ude=x.forwardRef((e,t)=>{const n=Xp($u,e.__scopeTooltip),a=YT($u,e.__scopeTooltip),r=x.useRef(null),i=Gt(t,r),[s,c]=x.useState(null),{trigger:u,onClose:d}=n,m=r.current,{onPointerInTransitChange:h}=a,g=x.useCallback(()=>{c(null),h(!1)},[h]),v=x.useCallback((w,S)=>{const y=w.currentTarget,_={x:w.clientX,y:w.clientY},E=Hde(_,y.getBoundingClientRect()),k=Vde(_,E),C=Gde(S.getBoundingClientRect()),R=Kde([...k,...C]);c(R),h(!0)},[h]);return x.useEffect(()=>()=>g(),[g]),x.useEffect(()=>{if(u&&m){const w=y=>v(y,m),S=y=>v(y,u);return u.addEventListener("pointerleave",w),m.addEventListener("pointerleave",S),()=>{u.removeEventListener("pointerleave",w),m.removeEventListener("pointerleave",S)}}},[u,m,v,g]),x.useEffect(()=>{if(s){const w=S=>{const y=S.target,_={x:S.clientX,y:S.clientY},E=u?.contains(y)||m?.contains(y),k=!Wde(_,s);E?g():k&&(g(),d())};return document.addEventListener("pointermove",w),()=>document.removeEventListener("pointermove",w)}},[u,m,s,d,g]),p.jsx(I9,{...e,ref:i})}),[zde,Fde]=Qv(ap,{isInside:!1}),Bde=xse("TooltipContent"),I9=x.forwardRef((e,t)=>{const{__scopeTooltip:n,children:a,"aria-label":r,onEscapeKeyDown:i,onPointerDownOutside:s,...c}=e,u=Xp($u,n),d=ey(n),{onClose:m}=u;return x.useEffect(()=>(document.addEventListener(nE,m),()=>document.removeEventListener(nE,m)),[m]),x.useEffect(()=>{if(u.trigger){const h=g=>{g.target?.contains(u.trigger)&&m()};return window.addEventListener("scroll",h,{capture:!0}),()=>window.removeEventListener("scroll",h,{capture:!0})}},[u.trigger,m]),p.jsx(ed,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:i,onPointerDownOutside:s,onFocusOutside:h=>h.preventDefault(),onDismiss:m,children:p.jsxs(Vv,{"data-state":u.stateAttribute,...d,...c,ref:t,style:{...c.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[p.jsx(Bde,{children:a}),p.jsx(zde,{scope:n,isInside:!0,children:p.jsx(Dde,{id:u.contentId,role:"tooltip",children:r||a})})]})})});A9.displayName=$u;var O9="TooltipArrow",D9=x.forwardRef((e,t)=>{const{__scopeTooltip:n,...a}=e,r=ey(n);return Fde(O9,n).isInside?null:p.jsx(Gv,{...r,...a,ref:t})});D9.displayName=O9;function Hde(e,t){const n=Math.abs(t.top-e.y),a=Math.abs(t.bottom-e.y),r=Math.abs(t.right-e.x),i=Math.abs(t.left-e.x);switch(Math.min(n,a,r,i)){case i:return"left";case r:return"right";case n:return"top";case a:return"bottom";default:throw new Error("unreachable")}}function Vde(e,t,n=5){const a=[];switch(t){case"top":a.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":a.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":a.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":a.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return a}function Gde(e){const{top:t,right:n,bottom:a,left:r}=e;return[{x:r,y:t},{x:n,y:t},{x:n,y:a},{x:r,y:a}]}function Wde(e,t){const{x:n,y:a}=e;let r=!1;for(let i=0,s=t.length-1;i<t.length;s=i++){const c=t[i],u=t[s],d=c.x,m=c.y,h=u.x,g=u.y;m>a!=g>a&&n<(h-d)*(a-m)/(g-m)+d&&(r=!r)}return r}function Kde(e){const t=e.slice();return t.sort((n,a)=>n.x<a.x?-1:n.x>a.x?1:n.y<a.y?-1:n.y>a.y?1:0),Zde(t)}function Zde(e){if(e.length<=1)return e.slice();const t=[];for(let a=0;a<e.length;a++){const r=e[a];for(;t.length>=2;){const i=t[t.length-1],s=t[t.length-2];if((i.x-s.x)*(r.y-s.y)>=(i.y-s.y)*(r.x-s.x))t.pop();else break}t.push(r)}t.pop();const n=[];for(let a=e.length-1;a>=0;a--){const r=e[a];for(;n.length>=2;){const i=n[n.length-1],s=n[n.length-2];if((i.x-s.x)*(r.y-s.y)>=(i.y-s.y)*(r.x-s.x))n.pop();else break}n.push(r)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var Yde=T9,Xde=N9,qde=R9,Jde=C9,Qde=A9,efe=D9;function L9({delayDuration:e=0,...t}){return p.jsx(Yde,{"data-slot":"tooltip-provider",delayDuration:e,...t})}function en({...e}){return p.jsx(L9,{children:p.jsx(Xde,{"data-slot":"tooltip",...e})})}function tn({...e}){return p.jsx(qde,{"data-slot":"tooltip-trigger",...e})}function nn({className:e,sideOffset:t=0,children:n,...a}){return p.jsx(Jde,{children:p.jsxs(Qde,{"data-slot":"tooltip-content",sideOffset:t,className:De("bg-foreground text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-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 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",e),...a,children:[n,p.jsx(efe,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}class tfe{name="mcp_inspector_open";properties;constructor(t){this.properties={server_url:t.serverUrl,connection_count:t.connectionCount}}}class QP{name="mcp_tool_execution";properties;constructor(t){this.properties={tool_name:t.toolName,server_id:t.serverId,success:t.success,duration:t.duration,error:t.error}}}class eU{name="mcp_resource_read";properties;constructor(t){this.properties={resource_uri:t.resourceUri,server_id:t.serverId,success:t.success,error:t.error}}}class tU{name="mcp_prompt_call";properties;constructor(t){this.properties={prompt_name:t.promptName,server_id:t.serverId,success:t.success,error:t.error}}}class nU{name="mcp_chat_message";properties;constructor(t){this.properties={server_id:t.serverId,provider:t.provider,model:t.model,message_count:t.messageCount,tool_calls_count:t.toolCallsCount,success:t.success,execution_mode:t.executionMode,duration:t.duration,error:t.error}}}class nfe{name="mcp_server_added";properties;constructor(t){this.properties={server_id:t.serverId,server_url:t.serverUrl,connection_type:t.connectionType,via_proxy:t.viaProxy}}}class rfe{name="mcp_server_removed";properties;constructor(t){this.properties={server_id:t.serverId}}}class afe{name="mcp_command_palette_open";properties;constructor(t){this.properties={trigger:t.trigger}}}class ife{name="mcp_tool_saved";properties;constructor(t){this.properties={tool_name:t.toolName,server_id:t.serverId}}}function NS(){try{return"0.10.0"}catch{return"0.0.0"}}var ofe={};function RS(){try{return typeof window<"u"&&typeof document<"u"}catch{return!1}}class rU{endpoint;timeout;constructor(t,n=3e3){this.endpoint=t,this.timeout=n}async logEvent(t){try{const n=new AbortController,a=setTimeout(()=>n.abort(),this.timeout),r=await fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t),signal:n.signal});if(clearTimeout(a),!r.ok)throw new Error(`HTTP error! status: ${r.status}`)}catch{}}}function ps(e){return`mcp_inspector_telemetry_${e}`}class br{static instance=null;POSTHOG_PROXY_URL="/inspector/api/tel/posthog";SCARF_PROXY_URL="/inspector/api/tel/scarf";UNKNOWN_USER_ID="UNKNOWN_USER_ID";_currUserId=null;_posthogClient=null;_scarfClient=null;_source="inspector";constructor(){const t=RS(),n=this.isTelemetryDisabled();if(this._source=this.getStoredSource()||"inspector",n)this._posthogClient=null,this._scarfClient=null;else if(!t)this._posthogClient=null,this._scarfClient=null;else{try{this._posthogClient=new rU(this.POSTHOG_PROXY_URL,3e3)}catch{this._posthogClient=null}try{this._scarfClient=new rU(this.SCARF_PROXY_URL,3e3)}catch{this._scarfClient=null}}}isTelemetryDisabled(){return typeof localStorage<"u"&&localStorage.getItem(ps("disabled"))==="true"||typeof process<"u"&&ofe?.MCP_USE_ANONYMIZED_TELEMETRY==="false"}getStoredSource(){return typeof localStorage<"u"?localStorage.getItem(ps("source")):null}static getInstance(){return br.instance||(br.instance=new br),br.instance}setSource(t){this._source=t,typeof localStorage<"u"&&localStorage.setItem(ps("source"),t)}getSource(){return this._source}get userId(){if(this._currUserId)return this._currUserId;if(!RS())return this._currUserId=this.UNKNOWN_USER_ID,this._currUserId;try{const t=localStorage.getItem(ps("user_id"));if(t)this._currUserId=t;else{const n=this.generateUserId();localStorage.setItem(ps("user_id"),n),this._currUserId=n}this.trackPackageDownload({triggered_by:"user_id_property"}).catch(()=>{})}catch{this._currUserId=this.UNKNOWN_USER_ID}return this._currUserId}generateUserId(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{const n=Math.random()*16|0;return(t==="x"?n:n&3|8).toString(16)})}async capture(t){if(!(!this._posthogClient&&!this._scarfClient)){if(this._posthogClient)try{const n={event:t.name,user_id:this.userId,properties:{...t.properties,mcp_use_version:NS(),language:"typescript",source:this._source,package:"inspector"}};await this._posthogClient.logEvent(n)}catch{}if(this._scarfClient)try{const n={};n.mcp_use_version=NS(),n.user_id=this.userId,n.event=t.name,n.language="typescript",n.source=this._source,n.package="inspector",await this._scarfClient.logEvent(n)}catch{}}}async trackPackageDownload(t){if(this._scarfClient&&RS())try{const n=NS();let a=!1,r=!1;const i=localStorage.getItem(ps("download_version"));if(i?n>i&&(a=!0,r=!1,localStorage.setItem(ps("download_version"),n)):(a=!0,r=!0,localStorage.setItem(ps("download_version"),n)),a){const s={...t||{}};s.mcp_use_version=n,s.user_id=this.userId,s.event="package_download",s.first_download=r,s.language="typescript",s.source=this._source,s.package="inspector",await this._scarfClient.logEvent(s)}}catch{}}async trackInspectorOpen(t){const n=new tfe(t);await this.capture(n)}}const sfe={model:"stub-model",stopReason:"endTurn",role:"assistant",content:{type:"text",text:"positive"}};function lfe({requestId:e,serverName:t,onViewDetails:n,onApprove:a,onDeny:r}){return p.jsxs("div",{className:"space-y-3",children:[p.jsxs("div",{children:[p.jsx("strong",{children:"Sampling Request Received"}),p.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:["New request from ",t]})]}),p.jsxs("div",{className:"flex gap-2",children:[p.jsx("button",{className:"px-3 py-1.5 text-xs font-medium rounded-md hover:bg-accent hover:text-accent-foreground",onClick:i=>{i.stopPropagation(),n()},children:"View Details"}),p.jsx("button",{className:"px-3 py-1.5 text-xs font-medium rounded-md hover:bg-accent hover:text-accent-foreground",onClick:i=>{i.stopPropagation(),a(sfe)},children:"Approve"}),p.jsx("button",{className:"px-3 py-1.5 text-xs font-medium rounded-md hover:bg-accent hover:text-accent-foreground",onClick:i=>{i.stopPropagation(),r()},children:"Deny"})]})]})}const Eg=()=>{},_g=()=>{},$9=x.createContext(null);function qT(){const e=x.use($9);if(!e)throw new Error("useMcpContext must be used within a McpProvider");return e}function cfe({url:e,name:t,proxyConfig:n,transportType:a,connectionId:r,onUpdate:i,onRemove:s}){const c=typeof window<"u"?new URL("/inspector/oauth/callback",window.location.origin).toString():"/inspector/oauth/callback";let u=e,d={};if(n?.proxyAddress){const Y=new URL(n.proxyAddress),z=new URL(e);u=`${Y.origin}${Y.pathname}${z.pathname}${z.search}`,d["X-Target-URL"]=e}n?.customHeaders&&(d={...d,...n.customHeaders});const[m,h]=x.useState([]),g=x.useRef(0),v=x.useMemo(()=>m.map(Y=>({id:Y.id,request:Y.request,timestamp:Y.timestamp,serverName:Y.serverName})),[m]),w=x.useRef(null),[S,y]=x.useState(!1),_=x.useRef(!1);x.useEffect(()=>{typeof window<"u"&&!_.current&&(_.current=!0,Ar(()=>import("./transport-wrapper-browser-BI4dDu3b.js"),[]).then(Y=>{w.current=Y.wrapTransportForLogging,y(!0),console.log("[McpContext] Transport wrapper loaded")}).catch(Y=>{console.error("[McpContext] Failed to load transport wrapper:",Y)}))},[]);const E=x.useMemo(()=>{if(!(!S||!w.current))return(Y,z)=>{const te=r;return console.log("[McpContext] Applying transport wrapper, serverId:",te,"from connector:",z),w.current(Y,te)}},[S,r]),k=`mcp-inspector-notifications-${r}`,C=500,[R,A]=x.useState([]);x.useEffect(()=>{try{const Y=localStorage.getItem(k);if(Y){const z=JSON.parse(Y);Array.isArray(z)&&A(z)}}catch(Y){console.error("Failed to load notifications from localStorage:",Y)}},[k]),x.useEffect(()=>{try{localStorage.setItem(k,JSON.stringify(R))}catch(Y){console.error("Failed to save notifications to localStorage:",Y)}},[R,k]);const I=x.useCallback(Y=>{A(z=>z.map(te=>te.id===Y?{...te,read:!0}:te))},[]),O=x.useCallback(()=>{A(Y=>Y.map(z=>({...z,read:!0})))},[]),j=x.useCallback(()=>{A([])},[]),F=x.useCallback(Y=>{A(z=>{const te=[Y,...z];return te.length>C?te.slice(0,C):te})},[]),H=x.useCallback((Y,z)=>{h(te=>{const re=te.find($=>$.id===Y);return re?(re.resolve(z),te.filter($=>$.id!==Y)):te})},[]),K=x.useCallback((Y,z)=>{h(te=>{const re=te.find($=>$.id===Y);return re?(re.reject(new Error(z||"User rejected sampling request")),te.filter($=>$.id!==Y)):te})},[]),Q=x.useCallback(async Y=>new Promise((z,te)=>{const re=`sampling-${g.current++}`,$={id:re,request:{params:Y},timestamp:Date.now(),serverName:t,resolve:z,reject:te};h(B=>[...B,$]),typeof window<"u"&&Ar(async()=>{const{toast:B}=await Promise.resolve().then(()=>xme);return{toast:B}},void 0).then(({toast:B})=>{const U=B(p.jsx(lfe,{requestId:re,serverName:t,onViewDetails:()=>{const L=new globalThis.CustomEvent("navigate-to-sampling",{detail:{requestId:re}});window.dispatchEvent(L),B.dismiss(U)},onApprove:L=>{h(P=>{const G=P.find(Z=>Z.id===re);return G?(G.resolve(L),B.success("Sampling request approved"),P.filter(Z=>Z.id!==re)):P}),B.dismiss(U)},onDeny:()=>{h(L=>{const P=L.find(G=>G.id===re);return P?(P.reject(new Error("User denied sampling request from toast")),B.error("Sampling request denied"),L.filter(G=>G.id!==re)):L}),B.dismiss(U)}}),{duration:5e3})})}),[t]),W=ET({url:u,callbackUrl:c,customHeaders:Object.keys(d).length>0?d:void 0,transportType:a||"http",preventAutoAuth:!0,useRedirectFlow:!0,enabled:S,wrapTransport:E,onNotification:Y=>{F({id:globalThis.crypto.randomUUID(),method:Y.method,params:Y.params,timestamp:Date.now(),read:!1})},samplingCallback:Q}),ie=x.useRef(i),V=x.useRef(null);return x.useEffect(()=>{ie.current=i},[i]),x.useEffect(()=>{if(typeof queueMicrotask<"u")queueMicrotask(()=>{W.state==="ready"&&W.serverInfo&&console.log("[McpContext] Server info available:",W.serverInfo);const Y=R.filter(re=>!re.read).length,z={id:r,url:e,name:W.serverInfo?.name||t,state:W.state,tools:W.tools,resources:W.resources,prompts:W.prompts,error:W.error??null,authUrl:W.authUrl??null,customHeaders:d,transportType:a,proxyConfig:n,serverInfo:W.serverInfo,capabilities:W.capabilities,notifications:R,unreadNotificationCount:Y,markNotificationRead:I,markAllNotificationsRead:O,clearNotifications:j,pendingSamplingRequests:v,approveSampling:H,rejectSampling:K,callTool:W.callTool,readResource:W.readResource,listPrompts:W.listPrompts,getPrompt:W.getPrompt,authenticate:W.authenticate,retry:W.retry,clearStorage:W.clearStorage,disconnect:W.disconnect,client:W.client},te=V.current;(!te||te.state!==z.state||te.error!==z.error||te.authUrl!==z.authUrl||te.name!==z.name||te.tools.length!==z.tools.length||te.resources.length!==z.resources.length||te.prompts.length!==z.prompts.length||te.serverInfo!==z.serverInfo||te.capabilities!==z.capabilities||te.notifications.length!==z.notifications.length||te.unreadNotificationCount!==z.unreadNotificationCount||te.pendingSamplingRequests.length!==z.pendingSamplingRequests.length||!te.client)&&(V.current=z,ie.current(z))});else{const Y=R.filter(re=>!re.read).length,z={id:r,url:e,name:W.serverInfo?.name||t,state:W.state,tools:W.tools,resources:W.resources,prompts:W.prompts,error:W.error??null,authUrl:W.authUrl??null,customHeaders:d,transportType:a,proxyConfig:n,serverInfo:W.serverInfo,capabilities:W.capabilities,notifications:R,unreadNotificationCount:Y,markNotificationRead:I,markAllNotificationsRead:O,clearNotifications:j,pendingSamplingRequests:v,approveSampling:H,rejectSampling:K,callTool:W.callTool,readResource:W.readResource,listPrompts:W.listPrompts,getPrompt:W.getPrompt,authenticate:W.authenticate,retry:W.retry,clearStorage:W.clearStorage,disconnect:W.disconnect,client:W.client},te=V.current;(!te||te.state!==z.state||te.error!==z.error||te.authUrl!==z.authUrl||te.name!==z.name||te.tools.length!==z.tools.length||te.resources.length!==z.resources.length||te.prompts.length!==z.prompts.length||te.serverInfo!==z.serverInfo||te.capabilities!==z.capabilities||te.notifications.length!==z.notifications.length||te.unreadNotificationCount!==z.unreadNotificationCount||te.pendingSamplingRequests.length!==z.pendingSamplingRequests.length||!te.client)&&(V.current=z,ie.current(z))}},[e,t,a,n,d,r,W.state,W.tools,W.resources,W.prompts,W.error,W.authUrl,W.serverInfo,W.capabilities,W.client,R,I,O,j,W.callTool,W.readResource,W.listPrompts,W.getPrompt,W.authenticate,W.retry,W.clearStorage,m,H,K]),null}function ufe({children:e}){const[t,n]=x.useState([]),[a,r]=x.useState(!1),[i,s]=x.useState(!0),[c,u]=x.useState([]);x.useEffect(()=>{try{const y=localStorage.getItem("mcp-inspector-connections");if(y){const E=JSON.parse(y);Array.isArray(E)&&(u(E),n(E.map(k=>({id:k.id||k.url,url:k.url,name:k.name||"MCP Server",state:"discovering",tools:[],resources:[],prompts:[],error:null,authUrl:null,customHeaders:k.proxyConfig?.customHeaders,transportType:k.transportType,proxyConfig:k.proxyConfig,notifications:[],unreadNotificationCount:0,markNotificationRead:()=>{},markAllNotificationsRead:()=>{},clearNotifications:()=>{},pendingSamplingRequests:[],approveSampling:Eg,rejectSampling:_g,callTool:async()=>{},readResource:async()=>{},listPrompts:async()=>{},getPrompt:async()=>{},authenticate:()=>{},retry:()=>{},clearStorage:()=>{},disconnect:()=>{},client:null}))))}const _=localStorage.getItem("mcp-inspector-auto-connect");_!==null&&s(_==="true")}catch(y){console.error("Failed to load connections from localStorage:",y)}finally{r(!0)}},[]),x.useEffect(()=>{a&&localStorage.setItem("mcp-inspector-connections",JSON.stringify(c))},[c,a]),x.useEffect(()=>{a&&localStorage.setItem("mcp-inspector-auto-connect",String(i))},[i,a]);const d=x.useCallback((y,_,E,k)=>{const C=c.find(I=>I.url===y),R=t.find(I=>I.url===y);if(C&&R){if(JSON.stringify(C.proxyConfig)!==JSON.stringify(E)&&E){u(O=>O.filter(j=>j.url!==y)),n(O=>O.filter(j=>j.url!==y)),setTimeout(()=>{const O={id:y,url:y,name:_||C.name||"MCP Server",proxyConfig:E,transportType:k||C.transportType};u(j=>[...j,O]),n(j=>[...j,{id:y,url:y,name:_||C.name||"MCP Server",state:"connecting",tools:[],resources:[],prompts:[],error:null,authUrl:null,customHeaders:E?.customHeaders,transportType:k||C.transportType,proxyConfig:E,notifications:[],unreadNotificationCount:0,markNotificationRead:()=>{},markAllNotificationsRead:()=>{},clearNotifications:()=>{},pendingSamplingRequests:[],approveSampling:Eg,rejectSampling:_g,callTool:async()=>{},readResource:async()=>{},listPrompts:async()=>{},getPrompt:async()=>{},authenticate:()=>{},retry:()=>{},clearStorage:()=>{},disconnect:()=>{},client:null}])},10);return}return}if(C&&!R){(E||k)&&u(I=>I.map(O=>O.url===y?{...O,proxyConfig:E||O.proxyConfig,transportType:k||O.transportType,name:_||O.name}:O)),n(I=>[...I,{id:C.id||y,url:y,name:_||C.name||"MCP Server",state:"connecting",tools:[],resources:[],prompts:[],error:null,authUrl:null,customHeaders:E?.customHeaders||C.proxyConfig?.customHeaders,transportType:k||C.transportType,proxyConfig:E||C.proxyConfig,notifications:[],unreadNotificationCount:0,markNotificationRead:()=>{},markAllNotificationsRead:()=>{},clearNotifications:()=>{},pendingSamplingRequests:[],approveSampling:Eg,rejectSampling:_g,callTool:async()=>{},readResource:async()=>{},listPrompts:async()=>{},getPrompt:async()=>{},authenticate:()=>{},retry:()=>{},clearStorage:()=>{},disconnect:()=>{},client:null}]);return}const A={id:y,url:y,name:_||"MCP Server",proxyConfig:E,transportType:k};u(I=>[...I,A]),n(I=>[...I,{id:y,url:y,name:_||"MCP Server",state:"connecting",tools:[],resources:[],prompts:[],error:null,authUrl:null,customHeaders:E?.customHeaders,transportType:k,proxyConfig:E,notifications:[],unreadNotificationCount:0,markNotificationRead:()=>{},markAllNotificationsRead:()=>{},clearNotifications:()=>{},pendingSamplingRequests:[],approveSampling:Eg,rejectSampling:_g,callTool:async()=>{},readResource:async()=>{},listPrompts:async()=>{},getPrompt:async()=>{},authenticate:()=>{},retry:()=>{},clearStorage:()=>{},disconnect:()=>{},client:null}])},[c,t]),m=x.useCallback(y=>{const _=t.find(k=>k.id===y);_&&(console.log(`[McpContext] Cleaning up connection: ${y}`),_.disconnect&&(console.log(`[McpContext] Disconnecting from server: ${y}`),_.disconnect()),_.clearStorage&&(console.log(`[McpContext] Clearing OAuth storage for connection: ${y}`),_.clearStorage())),u(k=>k.filter(C=>C.id!==y)),n(k=>k.filter(C=>C.id!==y));const E=localStorage.getItem("mcp-inspector-connections");if(E)try{const C=JSON.parse(E).filter(R=>(R.id||R.url)!==y);localStorage.setItem("mcp-inspector-connections",JSON.stringify(C))}catch(k){console.error("Failed to update localStorage on remove:",k)}br.getInstance().capture(new rfe({serverId:y}))},[t]),h=x.useCallback((y,_)=>{u(E=>E.map(k=>k.id===y||k.url===y?{...k,..._}:k)),n(E=>E.map(k=>k.id===y?{...k,..._}:k))},[]),g=x.useCallback(y=>{n(_=>{const E=_.findIndex(R=>R.id===y.id);if(E===-1)return _;const k=_[E];if(k.state===y.state&&k.tools===y.tools&&k.resources===y.resources&&k.prompts===y.prompts&&k.error===y.error&&k.serverInfo===y.serverInfo&&k.client===y.client&&k.notifications===y.notifications&&k.unreadNotificationCount===y.unreadNotificationCount&&k.pendingSamplingRequests.length===y.pendingSamplingRequests.length)return _;const C=[..._];return C[E]=y,C})},[]),v=x.useCallback(y=>{console.log("Connect requested for:",y)},[]),w=x.useCallback(y=>{console.log("Disconnect requested for:",y)},[]),S=x.useMemo(()=>({connections:t,addConnection:d,removeConnection:m,updateConnectionConfig:h,autoConnect:i,setAutoConnect:s,connectServer:v,disconnectServer:w,configLoaded:a}),[t,d,m,h,i,v,w,a]);return p.jsxs($9.Provider,{value:S,children:[e,a&&i&&c.map(y=>{const _=`${y.id||y.url}-${y.proxyConfig?.proxyAddress?"proxy":"direct"}`;return console.warn("[McpContext] Rendering McpConnectionWrapper with key:",_,"proxyConfig:",y.proxyConfig),p.jsx(cfe,{url:y.url,name:y.name,proxyConfig:y.proxyConfig,transportType:y.transportType,connectionId:y.id||y.url,onUpdate:g,onRemove:()=>m(y.id||y.url)},_)})]})}const dfe=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),ffe=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,a)=>a?a.toUpperCase():n.toLowerCase()),aU=e=>{const t=ffe(e);return t.charAt(0).toUpperCase()+t.slice(1)},j9=(...e)=>e.filter((t,n,a)=>!!t&&t.trim()!==""&&a.indexOf(t)===n).join(" ").trim(),pfe=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};var mfe={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const hfe=x.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:a,className:r="",children:i,iconNode:s,...c},u)=>x.createElement("svg",{ref:u,...mfe,width:t,height:t,stroke:e,strokeWidth:a?Number(n)*24/Number(t):n,className:j9("lucide",r),...!i&&!pfe(c)&&{"aria-hidden":"true"},...c},[...s.map(([d,m])=>x.createElement(d,m)),...Array.isArray(i)?i:[i]]));const Je=(e,t)=>{const n=x.forwardRef(({className:a,...r},i)=>x.createElement(hfe,{ref:i,iconNode:t,className:j9(`lucide-${dfe(aU(e))}`,`lucide-${e}`,a),...r}));return n.displayName=aU(e),n};const gfe=[["path",{d:"M12 17V3",key:"1cwfxf"}],["path",{d:"m6 11 6 6 6-6",key:"12ii2o"}],["path",{d:"M19 21H5",key:"150jfl"}]],bfe=Je("arrow-down-to-line",gfe);const vfe=[["path",{d:"m18 9-6-6-6 6",key:"kcunyi"}],["path",{d:"M12 3v14",key:"7cf3v8"}],["path",{d:"M5 21h14",key:"11awu3"}]],yfe=Je("arrow-up-from-line",vfe);const wfe=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Sfe=Je("arrow-up",wfe);const xfe=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}]],JT=Je("bell",xfe);const Efe=[["path",{d:"m11 10 3 3",key:"fzmg1i"}],["path",{d:"M6.5 21A3.5 3.5 0 1 0 3 17.5a2.62 2.62 0 0 1-.708 1.792A1 1 0 0 0 3 21z",key:"p4q2r7"}],["path",{d:"M9.969 17.031 21.378 5.624a1 1 0 0 0-3.002-3.002L6.967 14.031",key:"wy6l02"}]],M9=Je("brush",Efe);const _fe=[["path",{d:"M12 20v-9",key:"1qisl0"}],["path",{d:"M14 7a4 4 0 0 1 4 4v3a6 6 0 0 1-12 0v-3a4 4 0 0 1 4-4z",key:"uouzyp"}],["path",{d:"M14.12 3.88 16 2",key:"qol33r"}],["path",{d:"M21 21a4 4 0 0 0-3.81-4",key:"1b0z45"}],["path",{d:"M21 5a4 4 0 0 1-3.55 3.97",key:"5cxbf6"}],["path",{d:"M22 13h-4",key:"1jl80f"}],["path",{d:"M3 21a4 4 0 0 1 3.81-4",key:"1fjd4g"}],["path",{d:"M3 5a4 4 0 0 0 3.55 3.97",key:"1d7oge"}],["path",{d:"M6 13H2",key:"82j7cp"}],["path",{d:"m8 2 1.88 1.88",key:"fmnt4t"}],["path",{d:"M9 7.13V6a3 3 0 1 1 6 0v1.13",key:"1vgav8"}]],kfe=Je("bug",_fe);const Tfe=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],La=Je("check",Tfe);const Nfe=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Vl=Je("chevron-down",Nfe);const Rfe=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Cfe=Je("chevron-right",Rfe);const Afe=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],QT=Je("chevron-left",Afe);const Ife=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],Ofe=Je("chevron-up",Ife);const Dfe=[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]],Lfe=Je("chevrons-up-down",Dfe);const $fe=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}]],iU=Je("circle-minus",$fe);const jfe=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],ju=Je("clock",jfe);const Mfe=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],P9=Je("code",Mfe);const Pfe=[["path",{d:"M11 10.27 7 3.34",key:"16pf9h"}],["path",{d:"m11 13.73-4 6.93",key:"794ttg"}],["path",{d:"M12 22v-2",key:"1osdcq"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M14 12h8",key:"4f43i9"}],["path",{d:"m17 20.66-1-1.73",key:"eq3orb"}],["path",{d:"m17 3.34-1 1.73",key:"2wel8s"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"m20.66 17-1.73-1",key:"sg0v6f"}],["path",{d:"m20.66 7-1.73 1",key:"1ow05n"}],["path",{d:"m3.34 17 1.73-1",key:"nuk764"}],["path",{d:"m3.34 7 1.73 1",key:"1ulond"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["circle",{cx:"12",cy:"12",r:"8",key:"46899m"}]],Ufe=Je("cog",Pfe);const zfe=[["path",{d:"M15 6v12a3 3 0 1 0 3-3H6a3 3 0 1 0 3 3V6a3 3 0 1 0-3 3h12a3 3 0 1 0-3-3",key:"11bfej"}]],Ffe=Je("command",zfe);const Bfe=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],Xr=Je("copy",Bfe);const Hfe=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]],ty=Je("database",Hfe);const Vfe=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],ny=Je("download",Vfe);const Gfe=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]],Wfe=Je("ellipsis-vertical",Gfe);const Kfe=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],oU=Je("external-link",Kfe);const Zfe=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],U9=Je("eye-off",Zfe);const Yfe=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],aE=Je("eye",Yfe);const Xfe=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}]],qfe=Je("file-code",Xfe);const Jfe=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["circle",{cx:"10",cy:"12",r:"2",key:"737tya"}],["path",{d:"m20 17-1.296-1.296a2.41 2.41 0 0 0-3.408 0L9 22",key:"wt3hpn"}]],Qfe=Je("file-image",Jfe);const epe=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],eN=Je("file-text",epe);const tpe=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}]],npe=Je("file",tpe);const rpe=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],ape=Je("folder-open",rpe);const ipe=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],ope=Je("globe",ipe);const spe=[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]],lpe=Je("grip-vertical",spe);const cpe=[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]],z9=Je("hash",cpe);const upe=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]],$b=Je("history",upe);const dpe=[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]],F9=Je("key",dpe);const fpe=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],As=Je("loader-circle",fpe);const ppe=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]],B9=Je("maximize-2",ppe);const mpe=[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]],tN=Je("maximize",mpe);const hpe=[["path",{d:"M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719",key:"1sd12s"}]],gpe=Je("message-circle",hpe);const bpe=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]],ip=Je("message-square",bpe);const vpe=[["path",{d:"M8 3v3a2 2 0 0 1-2 2H3",key:"hohbtr"}],["path",{d:"M21 8h-3a2 2 0 0 1-2-2V3",key:"5jw1f3"}],["path",{d:"M3 16h3a2 2 0 0 1 2 2v3",key:"198tvr"}],["path",{d:"M16 21v-3a2 2 0 0 1 2-2h3",key:"ph8mxp"}]],ype=Je("minimize",vpe);const wpe=[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]],sU=Je("monitor",wpe);const Spe=[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]],xpe=Je("moon",Spe);const Epe=[["path",{d:"M2 10h6V4",key:"zwrco"}],["path",{d:"m2 4 6 6",key:"ug085t"}],["path",{d:"M21 10V7a2 2 0 0 0-2-2h-7",key:"git5jr"}],["path",{d:"M3 14v2a2 2 0 0 0 2 2h3",key:"1f7fh3"}],["rect",{x:"12",y:"14",width:"10",height:"7",rx:"1",key:"1wjs3o"}]],_pe=Je("picture-in-picture",Epe);const kpe=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],H9=Je("play",kpe);const Tpe=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],V9=Je("plus",Tpe);const Npe=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],lU=Je("rotate-ccw",Npe);const Rpe=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]],nN=Je("save",Rpe);const Cpe=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],qp=Je("search",Cpe);const Ape=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],Ipe=Je("send",Ape);const Ope=[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]],Dpe=Je("server",Ope);const Lpe=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],uu=Je("settings",Lpe);const $pe=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]],jpe=Je("shield",$pe);const Mpe=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],Ppe=Je("sparkles",Mpe);const Upe=[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]],zpe=Je("square-pen",Upe);const Fpe=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 4h.01",key:"1ujb9j"}],["path",{d:"M20 12h.01",key:"1ykeid"}],["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M4 12h.01",key:"158zrr"}],["path",{d:"M17.657 6.343h.01",key:"31pqzk"}],["path",{d:"M17.657 17.657h.01",key:"jehnf4"}],["path",{d:"M6.343 17.657h.01",key:"gdk6ow"}],["path",{d:"M6.343 6.343h.01",key:"1uurf0"}]],Bpe=Je("sun-dim",Fpe);const Hpe=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],CS=Je("terminal",Hpe);const Vpe=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],Is=Je("trash-2",Vpe);const Gpe=[["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],Wpe=Je("trash",Gpe);const Kpe=[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]],Dl=Je("wrench",Kpe);const Zpe=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Gl=Je("x",Zpe);const Ype=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],op=Je("zap",Ype);function Xpe(e){if(typeof document>"u")return;let t=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css",t.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}const qpe=e=>{switch(e){case"success":return eme;case"info":return nme;case"warning":return tme;case"error":return rme;default:return null}},Jpe=Array(12).fill(0),Qpe=({visible:e,className:t})=>ue.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},ue.createElement("div",{className:"sonner-spinner"},Jpe.map((n,a)=>ue.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${a}`})))),eme=ue.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},ue.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),tme=ue.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},ue.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),nme=ue.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},ue.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),rme=ue.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},ue.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),ame=ue.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},ue.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),ue.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),ime=()=>{const[e,t]=ue.useState(document.hidden);return ue.useEffect(()=>{const n=()=>{t(document.hidden)};return document.addEventListener("visibilitychange",n),()=>window.removeEventListener("visibilitychange",n)},[]),e};let iE=1;class ome{constructor(){this.subscribe=t=>(this.subscribers.push(t),()=>{const n=this.subscribers.indexOf(t);this.subscribers.splice(n,1)}),this.publish=t=>{this.subscribers.forEach(n=>n(t))},this.addToast=t=>{this.publish(t),this.toasts=[...this.toasts,t]},this.create=t=>{var n;const{message:a,...r}=t,i=typeof t?.id=="number"||((n=t.id)==null?void 0:n.length)>0?t.id:iE++,s=this.toasts.find(u=>u.id===i),c=t.dismissible===void 0?!0:t.dismissible;return this.dismissedToasts.has(i)&&this.dismissedToasts.delete(i),s?this.toasts=this.toasts.map(u=>u.id===i?(this.publish({...u,...t,id:i,title:a}),{...u,...t,id:i,dismissible:c,title:a}):u):this.addToast({title:a,...r,dismissible:c,id:i}),i},this.dismiss=t=>(t?(this.dismissedToasts.add(t),requestAnimationFrame(()=>this.subscribers.forEach(n=>n({id:t,dismiss:!0})))):this.toasts.forEach(n=>{this.subscribers.forEach(a=>a({id:n.id,dismiss:!0}))}),t),this.message=(t,n)=>this.create({...n,message:t}),this.error=(t,n)=>this.create({...n,message:t,type:"error"}),this.success=(t,n)=>this.create({...n,type:"success",message:t}),this.info=(t,n)=>this.create({...n,type:"info",message:t}),this.warning=(t,n)=>this.create({...n,type:"warning",message:t}),this.loading=(t,n)=>this.create({...n,type:"loading",message:t}),this.promise=(t,n)=>{if(!n)return;let a;n.loading!==void 0&&(a=this.create({...n,promise:t,type:"loading",message:n.loading,description:typeof n.description!="function"?n.description:void 0}));const r=Promise.resolve(t instanceof Function?t():t);let i=a!==void 0,s;const c=r.then(async d=>{if(s=["resolve",d],ue.isValidElement(d))i=!1,this.create({id:a,type:"default",message:d});else if(lme(d)&&!d.ok){i=!1;const h=typeof n.error=="function"?await n.error(`HTTP error! status: ${d.status}`):n.error,g=typeof n.description=="function"?await n.description(`HTTP error! status: ${d.status}`):n.description,w=typeof h=="object"&&!ue.isValidElement(h)?h:{message:h};this.create({id:a,type:"error",description:g,...w})}else if(d instanceof Error){i=!1;const h=typeof n.error=="function"?await n.error(d):n.error,g=typeof n.description=="function"?await n.description(d):n.description,w=typeof h=="object"&&!ue.isValidElement(h)?h:{message:h};this.create({id:a,type:"error",description:g,...w})}else if(n.success!==void 0){i=!1;const h=typeof n.success=="function"?await n.success(d):n.success,g=typeof n.description=="function"?await n.description(d):n.description,w=typeof h=="object"&&!ue.isValidElement(h)?h:{message:h};this.create({id:a,type:"success",description:g,...w})}}).catch(async d=>{if(s=["reject",d],n.error!==void 0){i=!1;const m=typeof n.error=="function"?await n.error(d):n.error,h=typeof n.description=="function"?await n.description(d):n.description,v=typeof m=="object"&&!ue.isValidElement(m)?m:{message:m};this.create({id:a,type:"error",description:h,...v})}}).finally(()=>{i&&(this.dismiss(a),a=void 0),n.finally==null||n.finally.call(n)}),u=()=>new Promise((d,m)=>c.then(()=>s[0]==="reject"?m(s[1]):d(s[1])).catch(m));return typeof a!="string"&&typeof a!="number"?{unwrap:u}:Object.assign(a,{unwrap:u})},this.custom=(t,n)=>{const a=n?.id||iE++;return this.create({jsx:t(a),id:a,...n}),a},this.getActiveToasts=()=>this.toasts.filter(t=>!this.dismissedToasts.has(t.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}}const da=new ome,sme=(e,t)=>{const n=t?.id||iE++;return da.addToast({title:e,...t,id:n}),n},lme=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",cme=sme,ume=()=>da.toasts,dme=()=>da.getActiveToasts(),Qt=Object.assign(cme,{success:da.success,info:da.info,warning:da.warning,error:da.error,custom:da.custom,message:da.message,promise:da.promise,dismiss:da.dismiss,loading:da.loading},{getHistory:ume,getToasts:dme});Xpe("[data-sonner-toaster][dir=ltr],html[dir=ltr]{--toast-icon-margin-start:-3px;--toast-icon-margin-end:4px;--toast-svg-margin-start:-1px;--toast-svg-margin-end:0px;--toast-button-margin-start:auto;--toast-button-margin-end:0;--toast-close-button-start:0;--toast-close-button-end:unset;--toast-close-button-transform:translate(-35%, -35%)}[data-sonner-toaster][dir=rtl],html[dir=rtl]{--toast-icon-margin-start:4px;--toast-icon-margin-end:-3px;--toast-svg-margin-start:0px;--toast-svg-margin-end:-1px;--toast-button-margin-start:0;--toast-button-margin-end:auto;--toast-close-button-start:unset;--toast-close-button-end:0;--toast-close-button-transform:translate(35%, -35%)}[data-sonner-toaster]{position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1:hsl(0, 0%, 99%);--gray2:hsl(0, 0%, 97.3%);--gray3:hsl(0, 0%, 95.1%);--gray4:hsl(0, 0%, 93%);--gray5:hsl(0, 0%, 90.9%);--gray6:hsl(0, 0%, 88.7%);--gray7:hsl(0, 0%, 85.8%);--gray8:hsl(0, 0%, 78%);--gray9:hsl(0, 0%, 56.1%);--gray10:hsl(0, 0%, 52.3%);--gray11:hsl(0, 0%, 43.5%);--gray12:hsl(0, 0%, 9%);--border-radius:8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:0;z-index:999999999;transition:transform .4s ease}@media (hover:none) and (pointer:coarse){[data-sonner-toaster][data-lifted=true]{transform:none}}[data-sonner-toaster][data-x-position=right]{right:var(--offset-right)}[data-sonner-toaster][data-x-position=left]{left:var(--offset-left)}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translateX(-50%)}[data-sonner-toaster][data-y-position=top]{top:var(--offset-top)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--offset-bottom)}[data-sonner-toast]{--y:translateY(100%);--lift-amount:calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:0;overflow-wrap:anywhere}[data-sonner-toast][data-styled=true]{padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-y-position=top]{top:0;--y:translateY(-100%);--lift:1;--lift-amount:calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y:translateY(100%);--lift:-1;--lift-amount:calc(var(--lift) * var(--gap))}[data-sonner-toast][data-styled=true] [data-description]{font-weight:400;line-height:1.4;color:#3f3f3f}[data-rich-colors=true][data-sonner-toast][data-styled=true] [data-description]{color:inherit}[data-sonner-toaster][data-sonner-theme=dark] [data-description]{color:#e8e8e8}[data-sonner-toast][data-styled=true] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast][data-styled=true] [data-icon]{display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast][data-styled=true] [data-icon]>*{flex-shrink:0}[data-sonner-toast][data-styled=true] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast][data-styled=true] [data-content]{display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;font-weight:500;cursor:pointer;outline:0;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}[data-sonner-toast][data-styled=true] [data-button]:focus-visible{box-shadow:0 0 0 2px rgba(0,0,0,.4)}[data-sonner-toast][data-styled=true] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast][data-styled=true] [data-cancel]{color:var(--normal-text);background:rgba(0,0,0,.08)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-styled=true] [data-cancel]{background:rgba(255,255,255,.3)}[data-sonner-toast][data-styled=true] [data-close-button]{position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);background:var(--normal-bg);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast][data-styled=true] [data-close-button]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-styled=true] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast][data-styled=true]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]::before{content:'';position:absolute;left:-100%;right:-100%;height:100%;z-index:-1}[data-sonner-toast][data-y-position=top][data-swiping=true]::before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]::before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]::before{content:'';position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast][data-expanded=true]::after{content:'';position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y:translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale:var(--toasts-before) * 0.05 + 1;--y:translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-x-position=right]{right:0}[data-sonner-toast][data-x-position=left]{left:0}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y:translateY(calc(var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=false]{--y:translateY(40%);opacity:0;transition:transform .5s,opacity .2s}[data-sonner-toast][data-removed=true][data-front=false]::before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y,0)) translateX(var(--swipe-amount-x,0));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width:600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-sonner-theme=light]{--normal-bg:#fff;--normal-border:var(--gray4);--normal-text:var(--gray12);--success-bg:hsl(143, 85%, 96%);--success-border:hsl(145, 92%, 87%);--success-text:hsl(140, 100%, 27%);--info-bg:hsl(208, 100%, 97%);--info-border:hsl(221, 91%, 93%);--info-text:hsl(210, 92%, 45%);--warning-bg:hsl(49, 100%, 97%);--warning-border:hsl(49, 91%, 84%);--warning-text:hsl(31, 92%, 45%);--error-bg:hsl(359, 100%, 97%);--error-border:hsl(359, 100%, 94%);--error-text:hsl(360, 100%, 45%)}[data-sonner-toaster][data-sonner-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg:#000;--normal-border:hsl(0, 0%, 20%);--normal-text:var(--gray1)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg:#fff;--normal-border:var(--gray3);--normal-text:var(--gray12)}[data-sonner-toaster][data-sonner-theme=dark]{--normal-bg:#000;--normal-bg-hover:hsl(0, 0%, 12%);--normal-border:hsl(0, 0%, 20%);--normal-border-hover:hsl(0, 0%, 25%);--normal-text:var(--gray1);--success-bg:hsl(150, 100%, 6%);--success-border:hsl(147, 100%, 12%);--success-text:hsl(150, 86%, 65%);--info-bg:hsl(215, 100%, 6%);--info-border:hsl(223, 43%, 17%);--info-text:hsl(216, 87%, 65%);--warning-bg:hsl(64, 100%, 6%);--warning-border:hsl(60, 100%, 9%);--warning-text:hsl(46, 87%, 65%);--error-bg:hsl(358, 76%, 10%);--error-border:hsl(357, 89%, 16%);--error-text:hsl(358, 100%, 81%)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size:16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:first-child{animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}100%{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}100%{opacity:.15}}@media (prefers-reduced-motion){.sonner-loading-bar,[data-sonner-toast],[data-sonner-toast]>*{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}");function kg(e){return e.label!==void 0}const fme=3,pme="24px",mme="16px",cU=4e3,hme=356,gme=14,bme=45,vme=200;function Oi(...e){return e.filter(Boolean).join(" ")}function yme(e){const[t,n]=e.split("-"),a=[];return t&&a.push(t),n&&a.push(n),a}const wme=e=>{var t,n,a,r,i,s,c,u,d;const{invert:m,toast:h,unstyled:g,interacting:v,setHeights:w,visibleToasts:S,heights:y,index:_,toasts:E,expanded:k,removeToast:C,defaultRichColors:R,closeButton:A,style:I,cancelButtonStyle:O,actionButtonStyle:j,className:F="",descriptionClassName:H="",duration:K,position:Q,gap:W,expandByDefault:ie,classNames:V,icons:Y,closeButtonAriaLabel:z="Close toast"}=e,[te,re]=ue.useState(null),[$,B]=ue.useState(null),[U,L]=ue.useState(!1),[P,G]=ue.useState(!1),[Z,J]=ue.useState(!1),[se,le]=ue.useState(!1),[ee,ne]=ue.useState(!1),[ce,ae]=ue.useState(0),[ye,ke]=ue.useState(0),Be=ue.useRef(h.duration||K||cU),_e=ue.useRef(null),Se=ue.useRef(null),ze=_===0,pe=_+1<=S,Le=h.type,Fe=h.dismissible!==!1,xe=h.className||"",st=h.descriptionClassName||"",at=ue.useMemo(()=>y.findIndex(Ve=>Ve.toastId===h.id)||0,[y,h.id]),pt=ue.useMemo(()=>{var Ve;return(Ve=h.closeButton)!=null?Ve:A},[h.closeButton,A]),Pe=ue.useMemo(()=>h.duration||K||cU,[h.duration,K]),$e=ue.useRef(0),et=ue.useRef(0),an=ue.useRef(0),Qe=ue.useRef(null),[Ae,Ie]=Q.split("-"),Ye=ue.useMemo(()=>y.reduce((Ve,jt,En)=>En>=at?Ve:Ve+jt.height,0),[y,at]),tt=ime(),it=h.invert||m,gt=Le==="loading";et.current=ue.useMemo(()=>at*W+Ye,[at,Ye]),ue.useEffect(()=>{Be.current=Pe},[Pe]),ue.useEffect(()=>{L(!0)},[]),ue.useEffect(()=>{const Ve=Se.current;if(Ve){const jt=Ve.getBoundingClientRect().height;return ke(jt),w(En=>[{toastId:h.id,height:jt,position:h.position},...En]),()=>w(En=>En.filter(_n=>_n.toastId!==h.id))}},[w,h.id]),ue.useLayoutEffect(()=>{if(!U)return;const Ve=Se.current,jt=Ve.style.height;Ve.style.height="auto";const En=Ve.getBoundingClientRect().height;Ve.style.height=jt,ke(En),w(_n=>_n.find(un=>un.toastId===h.id)?_n.map(un=>un.toastId===h.id?{...un,height:En}:un):[{toastId:h.id,height:En,position:h.position},..._n])},[U,h.title,h.description,w,h.id,h.jsx,h.action,h.cancel]);const mt=ue.useCallback(()=>{G(!0),ae(et.current),w(Ve=>Ve.filter(jt=>jt.toastId!==h.id)),setTimeout(()=>{C(h)},vme)},[h,C,w,et]);ue.useEffect(()=>{if(h.promise&&Le==="loading"||h.duration===1/0||h.type==="loading")return;let Ve;return k||v||tt?(()=>{if(an.current<$e.current){const _n=new Date().getTime()-$e.current;Be.current=Be.current-_n}an.current=new Date().getTime()})():(()=>{Be.current!==1/0&&($e.current=new Date().getTime(),Ve=setTimeout(()=>{h.onAutoClose==null||h.onAutoClose.call(h,h),mt()},Be.current))})(),()=>clearTimeout(Ve)},[k,v,h,Le,tt,mt]),ue.useEffect(()=>{h.delete&&(mt(),h.onDismiss==null||h.onDismiss.call(h,h))},[mt,h.delete]);function Rn(){var Ve;if(Y?.loading){var jt;return ue.createElement("div",{className:Oi(V?.loader,h==null||(jt=h.classNames)==null?void 0:jt.loader,"sonner-loader"),"data-visible":Le==="loading"},Y.loading)}return ue.createElement(Qpe,{className:Oi(V?.loader,h==null||(Ve=h.classNames)==null?void 0:Ve.loader),visible:Le==="loading"})}const $t=h.icon||Y?.[Le]||qpe(Le);var on,Bt;return ue.createElement("li",{tabIndex:0,ref:Se,className:Oi(F,xe,V?.toast,h==null||(t=h.classNames)==null?void 0:t.toast,V?.default,V?.[Le],h==null||(n=h.classNames)==null?void 0:n[Le]),"data-sonner-toast":"","data-rich-colors":(on=h.richColors)!=null?on:R,"data-styled":!(h.jsx||h.unstyled||g),"data-mounted":U,"data-promise":!!h.promise,"data-swiped":ee,"data-removed":P,"data-visible":pe,"data-y-position":Ae,"data-x-position":Ie,"data-index":_,"data-front":ze,"data-swiping":Z,"data-dismissible":Fe,"data-type":Le,"data-invert":it,"data-swipe-out":se,"data-swipe-direction":$,"data-expanded":!!(k||ie&&U),"data-testid":h.testId,style:{"--index":_,"--toasts-before":_,"--z-index":E.length-_,"--offset":`${P?ce:et.current}px`,"--initial-height":ie?"auto":`${ye}px`,...I,...h.style},onDragEnd:()=>{J(!1),re(null),Qe.current=null},onPointerDown:Ve=>{Ve.button!==2&&(gt||!Fe||(_e.current=new Date,ae(et.current),Ve.target.setPointerCapture(Ve.pointerId),Ve.target.tagName!=="BUTTON"&&(J(!0),Qe.current={x:Ve.clientX,y:Ve.clientY})))},onPointerUp:()=>{var Ve,jt,En;if(se||!Fe)return;Qe.current=null;const _n=Number(((Ve=Se.current)==null?void 0:Ve.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),Hr=Number(((jt=Se.current)==null?void 0:jt.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),un=new Date().getTime()-((En=_e.current)==null?void 0:En.getTime()),Kn=te==="x"?_n:Hr,Zn=Math.abs(Kn)/un;if(Math.abs(Kn)>=bme||Zn>.11){ae(et.current),h.onDismiss==null||h.onDismiss.call(h,h),B(te==="x"?_n>0?"right":"left":Hr>0?"down":"up"),mt(),le(!0);return}else{var bn,dn;(bn=Se.current)==null||bn.style.setProperty("--swipe-amount-x","0px"),(dn=Se.current)==null||dn.style.setProperty("--swipe-amount-y","0px")}ne(!1),J(!1),re(null)},onPointerMove:Ve=>{var jt,En,_n;if(!Qe.current||!Fe||((jt=window.getSelection())==null?void 0:jt.toString().length)>0)return;const un=Ve.clientY-Qe.current.y,Kn=Ve.clientX-Qe.current.x;var Zn;const bn=(Zn=e.swipeDirections)!=null?Zn:yme(Q);!te&&(Math.abs(Kn)>1||Math.abs(un)>1)&&re(Math.abs(Kn)>Math.abs(un)?"x":"y");let dn={x:0,y:0};const na=Wt=>1/(1.5+Math.abs(Wt)/20);if(te==="y"){if(bn.includes("top")||bn.includes("bottom"))if(bn.includes("top")&&un<0||bn.includes("bottom")&&un>0)dn.y=un;else{const Wt=un*na(un);dn.y=Math.abs(Wt)<Math.abs(un)?Wt:un}}else if(te==="x"&&(bn.includes("left")||bn.includes("right")))if(bn.includes("left")&&Kn<0||bn.includes("right")&&Kn>0)dn.x=Kn;else{const Wt=Kn*na(Kn);dn.x=Math.abs(Wt)<Math.abs(Kn)?Wt:Kn}(Math.abs(dn.x)>0||Math.abs(dn.y)>0)&&ne(!0),(En=Se.current)==null||En.style.setProperty("--swipe-amount-x",`${dn.x}px`),(_n=Se.current)==null||_n.style.setProperty("--swipe-amount-y",`${dn.y}px`)}},pt&&!h.jsx&&Le!=="loading"?ue.createElement("button",{"aria-label":z,"data-disabled":gt,"data-close-button":!0,onClick:gt||!Fe?()=>{}:()=>{mt(),h.onDismiss==null||h.onDismiss.call(h,h)},className:Oi(V?.closeButton,h==null||(a=h.classNames)==null?void 0:a.closeButton)},(Bt=Y?.close)!=null?Bt:ame):null,(Le||h.icon||h.promise)&&h.icon!==null&&(Y?.[Le]!==null||h.icon)?ue.createElement("div",{"data-icon":"",className:Oi(V?.icon,h==null||(r=h.classNames)==null?void 0:r.icon)},h.promise||h.type==="loading"&&!h.icon?h.icon||Rn():null,h.type!=="loading"?$t:null):null,ue.createElement("div",{"data-content":"",className:Oi(V?.content,h==null||(i=h.classNames)==null?void 0:i.content)},ue.createElement("div",{"data-title":"",className:Oi(V?.title,h==null||(s=h.classNames)==null?void 0:s.title)},h.jsx?h.jsx:typeof h.title=="function"?h.title():h.title),h.description?ue.createElement("div",{"data-description":"",className:Oi(H,st,V?.description,h==null||(c=h.classNames)==null?void 0:c.description)},typeof h.description=="function"?h.description():h.description):null),ue.isValidElement(h.cancel)?h.cancel:h.cancel&&kg(h.cancel)?ue.createElement("button",{"data-button":!0,"data-cancel":!0,style:h.cancelButtonStyle||O,onClick:Ve=>{kg(h.cancel)&&Fe&&(h.cancel.onClick==null||h.cancel.onClick.call(h.cancel,Ve),mt())},className:Oi(V?.cancelButton,h==null||(u=h.classNames)==null?void 0:u.cancelButton)},h.cancel.label):null,ue.isValidElement(h.action)?h.action:h.action&&kg(h.action)?ue.createElement("button",{"data-button":!0,"data-action":!0,style:h.actionButtonStyle||j,onClick:Ve=>{kg(h.action)&&(h.action.onClick==null||h.action.onClick.call(h.action,Ve),!Ve.defaultPrevented&&mt())},className:Oi(V?.actionButton,h==null||(d=h.classNames)==null?void 0:d.actionButton)},h.action.label):null)};function uU(){if(typeof window>"u"||typeof document>"u")return"ltr";const e=document.documentElement.getAttribute("dir");return e==="auto"||!e?window.getComputedStyle(document.documentElement).direction:e}function Sme(e,t){const n={};return[e,t].forEach((a,r)=>{const i=r===1,s=i?"--mobile-offset":"--offset",c=i?mme:pme;function u(d){["top","right","bottom","left"].forEach(m=>{n[`${s}-${m}`]=typeof d=="number"?`${d}px`:d})}typeof a=="number"||typeof a=="string"?u(a):typeof a=="object"?["top","right","bottom","left"].forEach(d=>{a[d]===void 0?n[`${s}-${d}`]=c:n[`${s}-${d}`]=typeof a[d]=="number"?`${a[d]}px`:a[d]}):u(c)}),n}const G9=ue.forwardRef(function(t,n){const{id:a,invert:r,position:i="bottom-right",hotkey:s=["altKey","KeyT"],expand:c,closeButton:u,className:d,offset:m,mobileOffset:h,theme:g="light",richColors:v,duration:w,style:S,visibleToasts:y=fme,toastOptions:_,dir:E=uU(),gap:k=gme,icons:C,containerAriaLabel:R="Notifications"}=t,[A,I]=ue.useState([]),O=ue.useMemo(()=>a?A.filter(U=>U.toasterId===a):A.filter(U=>!U.toasterId),[A,a]),j=ue.useMemo(()=>Array.from(new Set([i].concat(O.filter(U=>U.position).map(U=>U.position)))),[O,i]),[F,H]=ue.useState([]),[K,Q]=ue.useState(!1),[W,ie]=ue.useState(!1),[V,Y]=ue.useState(g!=="system"?g:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),z=ue.useRef(null),te=s.join("+").replace(/Key/g,"").replace(/Digit/g,""),re=ue.useRef(null),$=ue.useRef(!1),B=ue.useCallback(U=>{I(L=>{var P;return(P=L.find(G=>G.id===U.id))!=null&&P.delete||da.dismiss(U.id),L.filter(({id:G})=>G!==U.id)})},[]);return ue.useEffect(()=>da.subscribe(U=>{if(U.dismiss){requestAnimationFrame(()=>{I(L=>L.map(P=>P.id===U.id?{...P,delete:!0}:P))});return}setTimeout(()=>{EH.flushSync(()=>{I(L=>{const P=L.findIndex(G=>G.id===U.id);return P!==-1?[...L.slice(0,P),{...L[P],...U},...L.slice(P+1)]:[U,...L]})})})}),[A]),ue.useEffect(()=>{if(g!=="system"){Y(g);return}if(g==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?Y("dark"):Y("light")),typeof window>"u")return;const U=window.matchMedia("(prefers-color-scheme: dark)");try{U.addEventListener("change",({matches:L})=>{Y(L?"dark":"light")})}catch{U.addListener(({matches:P})=>{try{Y(P?"dark":"light")}catch(G){console.error(G)}})}},[g]),ue.useEffect(()=>{A.length<=1&&Q(!1)},[A]),ue.useEffect(()=>{const U=L=>{var P;if(s.every(J=>L[J]||L.code===J)){var Z;Q(!0),(Z=z.current)==null||Z.focus()}L.code==="Escape"&&(document.activeElement===z.current||(P=z.current)!=null&&P.contains(document.activeElement))&&Q(!1)};return document.addEventListener("keydown",U),()=>document.removeEventListener("keydown",U)},[s]),ue.useEffect(()=>{if(z.current)return()=>{re.current&&(re.current.focus({preventScroll:!0}),re.current=null,$.current=!1)}},[z.current]),ue.createElement("section",{ref:n,"aria-label":`${R} ${te}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},j.map((U,L)=>{var P;const[G,Z]=U.split("-");return O.length?ue.createElement("ol",{key:U,dir:E==="auto"?uU():E,tabIndex:-1,ref:z,className:d,"data-sonner-toaster":!0,"data-sonner-theme":V,"data-y-position":G,"data-x-position":Z,style:{"--front-toast-height":`${((P=F[0])==null?void 0:P.height)||0}px`,"--width":`${hme}px`,"--gap":`${k}px`,...S,...Sme(m,h)},onBlur:J=>{$.current&&!J.currentTarget.contains(J.relatedTarget)&&($.current=!1,re.current&&(re.current.focus({preventScroll:!0}),re.current=null))},onFocus:J=>{J.target instanceof HTMLElement&&J.target.dataset.dismissible==="false"||$.current||($.current=!0,re.current=J.relatedTarget)},onMouseEnter:()=>Q(!0),onMouseMove:()=>Q(!0),onMouseLeave:()=>{W||Q(!1)},onDragEnd:()=>Q(!1),onPointerDown:J=>{J.target instanceof HTMLElement&&J.target.dataset.dismissible==="false"||ie(!0)},onPointerUp:()=>ie(!1)},O.filter(J=>!J.position&&L===0||J.position===U).map((J,se)=>{var le,ee;return ue.createElement(wme,{key:J.id,icons:C,index:se,toast:J,defaultRichColors:v,duration:(le=_?.duration)!=null?le:w,className:_?.className,descriptionClassName:_?.descriptionClassName,invert:r,visibleToasts:y,closeButton:(ee=_?.closeButton)!=null?ee:u,interacting:W,position:U,style:_?.style,unstyled:_?.unstyled,classNames:_?.classNames,cancelButtonStyle:_?.cancelButtonStyle,actionButtonStyle:_?.actionButtonStyle,closeButtonAriaLabel:_?.closeButtonAriaLabel,removeToast:B,toasts:O.filter(ne=>ne.position==J.position),heights:F.filter(ne=>ne.position==J.position),setHeights:H,expandByDefault:c,gap:k,expanded:K,swipeDirections:t.swipeDirections})})):null}))}),xme=Object.freeze(Object.defineProperty({__proto__:null,Toaster:G9,toast:Qt},Symbol.toStringTag,{value:"Module"}));var ry="Dialog",[W9]=_i(ry),[Eme,ki]=W9(ry),K9=e=>{const{__scopeDialog:t,children:n,open:a,defaultOpen:r,onOpenChange:i,modal:s=!0}=e,c=x.useRef(null),u=x.useRef(null),[d,m]=Co({prop:a,defaultProp:r??!1,onChange:i,caller:ry});return p.jsx(Eme,{scope:t,triggerRef:c,contentRef:u,contentId:Ir(),titleId:Ir(),descriptionId:Ir(),open:d,onOpenChange:m,onOpenToggle:x.useCallback(()=>m(h=>!h),[m]),modal:s,children:n})};K9.displayName=ry;var Z9="DialogTrigger",Y9=x.forwardRef((e,t)=>{const{__scopeDialog:n,...a}=e,r=ki(Z9,n),i=Gt(t,r.triggerRef);return p.jsx(St.button,{type:"button","aria-haspopup":"dialog","aria-expanded":r.open,"aria-controls":r.contentId,"data-state":iN(r.open),...a,ref:i,onClick:He(e.onClick,r.onOpenToggle)})});Y9.displayName=Z9;var rN="DialogPortal",[_me,X9]=W9(rN,{forceMount:void 0}),q9=e=>{const{__scopeDialog:t,forceMount:n,children:a,container:r}=e,i=ki(rN,t);return p.jsx(_me,{scope:t,forceMount:n,children:x.Children.map(a,s=>p.jsx(Ma,{present:n||i.open,children:p.jsx(rd,{asChild:!0,container:r,children:s})}))})};q9.displayName=rN;var jb="DialogOverlay",J9=x.forwardRef((e,t)=>{const n=X9(jb,e.__scopeDialog),{forceMount:a=n.forceMount,...r}=e,i=ki(jb,e.__scopeDialog);return i.modal?p.jsx(Ma,{present:a||i.open,children:p.jsx(Tme,{...r,ref:t})}):null});J9.displayName=jb;var kme=Il("DialogOverlay.RemoveScroll"),Tme=x.forwardRef((e,t)=>{const{__scopeDialog:n,...a}=e,r=ki(jb,n);return p.jsx(Wp,{as:kme,allowPinchZoom:!0,shards:[r.contentRef],children:p.jsx(St.div,{"data-state":iN(r.open),...a,ref:t,style:{pointerEvents:"auto",...a.style}})})}),Ll="DialogContent",Q9=x.forwardRef((e,t)=>{const n=X9(Ll,e.__scopeDialog),{forceMount:a=n.forceMount,...r}=e,i=ki(Ll,e.__scopeDialog);return p.jsx(Ma,{present:a||i.open,children:i.modal?p.jsx(Nme,{...r,ref:t}):p.jsx(Rme,{...r,ref:t})})});Q9.displayName=Ll;var Nme=x.forwardRef((e,t)=>{const n=ki(Ll,e.__scopeDialog),a=x.useRef(null),r=Gt(t,n.contentRef,a);return x.useEffect(()=>{const i=a.current;if(i)return Wv(i)},[]),p.jsx(eG,{...e,ref:r,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:He(e.onCloseAutoFocus,i=>{i.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:He(e.onPointerDownOutside,i=>{const s=i.detail.originalEvent,c=s.button===0&&s.ctrlKey===!0;(s.button===2||c)&&i.preventDefault()}),onFocusOutside:He(e.onFocusOutside,i=>i.preventDefault())})}),Rme=x.forwardRef((e,t)=>{const n=ki(Ll,e.__scopeDialog),a=x.useRef(!1),r=x.useRef(!1);return p.jsx(eG,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{e.onCloseAutoFocus?.(i),i.defaultPrevented||(a.current||n.triggerRef.current?.focus(),i.preventDefault()),a.current=!1,r.current=!1},onInteractOutside:i=>{e.onInteractOutside?.(i),i.defaultPrevented||(a.current=!0,i.detail.originalEvent.type==="pointerdown"&&(r.current=!0));const s=i.target;n.triggerRef.current?.contains(s)&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&r.current&&i.preventDefault()}})}),eG=x.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:a,onOpenAutoFocus:r,onCloseAutoFocus:i,...s}=e,c=ki(Ll,n),u=x.useRef(null),d=Gt(t,u);return Pv(),p.jsxs(p.Fragment,{children:[p.jsx(Bp,{asChild:!0,loop:!0,trapped:a,onMountAutoFocus:r,onUnmountAutoFocus:i,children:p.jsx(ed,{role:"dialog",id:c.contentId,"aria-describedby":c.descriptionId,"aria-labelledby":c.titleId,"data-state":iN(c.open),...s,ref:d,onDismiss:()=>c.onOpenChange(!1)})}),p.jsxs(p.Fragment,{children:[p.jsx(Cme,{titleId:c.titleId}),p.jsx(Ime,{contentRef:u,descriptionId:c.descriptionId})]})]})}),aN="DialogTitle",tG=x.forwardRef((e,t)=>{const{__scopeDialog:n,...a}=e,r=ki(aN,n);return p.jsx(St.h2,{id:r.titleId,...a,ref:t})});tG.displayName=aN;var nG="DialogDescription",rG=x.forwardRef((e,t)=>{const{__scopeDialog:n,...a}=e,r=ki(nG,n);return p.jsx(St.p,{id:r.descriptionId,...a,ref:t})});rG.displayName=nG;var aG="DialogClose",iG=x.forwardRef((e,t)=>{const{__scopeDialog:n,...a}=e,r=ki(aG,n);return p.jsx(St.button,{type:"button",...a,ref:t,onClick:He(e.onClick,()=>r.onOpenChange(!1))})});iG.displayName=aG;function iN(e){return e?"open":"closed"}var oG="DialogTitleWarning",[Q_e,sG]=gse(oG,{contentName:Ll,titleName:aN,docsSlug:"dialog"}),Cme=({titleId:e})=>{const t=sG(oG),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
102
+ `)},oue=0,jc=[];function sue(e){var t=x.useRef([]),n=x.useRef([0,0]),a=x.useRef(),r=x.useState(oue++)[0],i=x.useState(_V)[0],s=x.useRef(e);x.useEffect(function(){s.current=e},[e]),x.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(r));var S=Rce([e.lockRef.current],(e.shards||[]).map(qP),!0).filter(Boolean);return S.forEach(function(y){return y.classList.add("allow-interactivity-".concat(r))}),function(){document.body.classList.remove("block-interactivity-".concat(r)),S.forEach(function(y){return y.classList.remove("allow-interactivity-".concat(r))})}}},[e.inert,e.lockRef.current,e.shards]);var c=x.useCallback(function(S,y){if("touches"in S&&S.touches.length===2||S.type==="wheel"&&S.ctrlKey)return!s.current.allowPinchZoom;var _=xg(S),E=n.current,k="deltaX"in S?S.deltaX:E[0]-_[0],C="deltaY"in S?S.deltaY:E[1]-_[1],R,A=S.target,I=Math.abs(k)>Math.abs(C)?"h":"v";if("touches"in S&&I==="h"&&A.type==="range")return!1;var O=YP(I,A);if(!O)return!0;if(O?R=I:(R=I==="v"?"h":"v",O=YP(I,A)),!O)return!1;if(!a.current&&"changedTouches"in S&&(k||C)&&(a.current=R),!R)return!0;var j=a.current||R;return rue(j,y,S,j==="h"?k:C)},[]),u=x.useCallback(function(S){var y=S;if(!(!jc.length||jc[jc.length-1]!==i)){var _="deltaY"in y?XP(y):xg(y),E=t.current.filter(function(R){return R.name===y.type&&(R.target===y.target||y.target===R.shadowParent)&&aue(R.delta,_)})[0];if(E&&E.should){y.cancelable&&y.preventDefault();return}if(!E){var k=(s.current.shards||[]).map(qP).filter(Boolean).filter(function(R){return R.contains(y.target)}),C=k.length>0?c(y,k[0]):!s.current.noIsolation;C&&y.cancelable&&y.preventDefault()}}},[]),d=x.useCallback(function(S,y,_,E){var k={name:S,delta:y,target:_,should:E,shadowParent:lue(_)};t.current.push(k),setTimeout(function(){t.current=t.current.filter(function(C){return C!==k})},1)},[]),m=x.useCallback(function(S){n.current=xg(S),a.current=void 0},[]),h=x.useCallback(function(S){d(S.type,XP(S),S.target,c(S,e.lockRef.current))},[]),g=x.useCallback(function(S){d(S.type,xg(S),S.target,c(S,e.lockRef.current))},[]);x.useEffect(function(){return jc.push(i),e.setCallbacks({onScrollCapture:h,onWheelCapture:h,onTouchMoveCapture:g}),document.addEventListener("wheel",u,$c),document.addEventListener("touchmove",u,$c),document.addEventListener("touchstart",m,$c),function(){jc=jc.filter(function(S){return S!==i}),document.removeEventListener("wheel",u,$c),document.removeEventListener("touchmove",u,$c),document.removeEventListener("touchstart",m,$c)}},[]);var v=e.removeScrollBar,w=e.inert;return x.createElement(x.Fragment,null,w?x.createElement(i,{styles:iue(r)}):null,v?x.createElement(Xce,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function lue(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const cue=Mce(EV,sue);var Wp=x.forwardRef(function(e,t){return x.createElement(Kv,Di({},e,{ref:t,sideCar:cue}))});Wp.classNames=Kv.classNames;var Jx=["Enter"," "],uue=["ArrowDown","PageUp","Home"],RV=["ArrowUp","PageDown","End"],due=[...uue,...RV],fue={ltr:[...Jx,"ArrowRight"],rtl:[...Jx,"ArrowLeft"]},pue={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Kp="Menu",[np,mue,hue]=AT(Kp),[Bl,CV]=_i(Kp,[hue,Ps,hV]),Zv=Ps(),AV=hV(),[gue,Hl]=Bl(Kp),[bue,Zp]=Bl(Kp),IV=e=>{const{__scopeMenu:t,open:n=!1,children:a,dir:r,onOpenChange:i,modal:s=!0}=e,c=Zv(t),[u,d]=x.useState(null),m=x.useRef(!1),h=Fi(i),g=IT(r);return x.useEffect(()=>{const v=()=>{m.current=!0,document.addEventListener("pointerdown",w,{capture:!0,once:!0}),document.addEventListener("pointermove",w,{capture:!0,once:!0})},w=()=>m.current=!1;return document.addEventListener("keydown",v,{capture:!0}),()=>{document.removeEventListener("keydown",v,{capture:!0}),document.removeEventListener("pointerdown",w,{capture:!0}),document.removeEventListener("pointermove",w,{capture:!0})}},[]),p.jsx(Hv,{...c,children:p.jsx(gue,{scope:t,open:n,onOpenChange:h,content:u,onContentChange:d,children:p.jsx(bue,{scope:t,onClose:x.useCallback(()=>h(!1),[h]),isUsingKeyboardRef:m,dir:g,modal:s,children:a})})})};IV.displayName=Kp;var vue="MenuAnchor",FT=x.forwardRef((e,t)=>{const{__scopeMenu:n,...a}=e,r=Zv(n);return p.jsx(Vp,{...r,...a,ref:t})});FT.displayName=vue;var BT="MenuPortal",[yue,OV]=Bl(BT,{forceMount:void 0}),DV=e=>{const{__scopeMenu:t,forceMount:n,children:a,container:r}=e,i=Hl(BT,t);return p.jsx(yue,{scope:t,forceMount:n,children:p.jsx(Ma,{present:n||i.open,children:p.jsx(rd,{asChild:!0,container:r,children:a})})})};DV.displayName=BT;var Ja="MenuContent",[wue,HT]=Bl(Ja),LV=x.forwardRef((e,t)=>{const n=OV(Ja,e.__scopeMenu),{forceMount:a=n.forceMount,...r}=e,i=Hl(Ja,e.__scopeMenu),s=Zp(Ja,e.__scopeMenu);return p.jsx(np.Provider,{scope:e.__scopeMenu,children:p.jsx(Ma,{present:a||i.open,children:p.jsx(np.Slot,{scope:e.__scopeMenu,children:s.modal?p.jsx(Sue,{...r,ref:t}):p.jsx(xue,{...r,ref:t})})})})}),Sue=x.forwardRef((e,t)=>{const n=Hl(Ja,e.__scopeMenu),a=x.useRef(null),r=Gt(t,a);return x.useEffect(()=>{const i=a.current;if(i)return Wv(i)},[]),p.jsx(VT,{...e,ref:r,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:He(e.onFocusOutside,i=>i.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),xue=x.forwardRef((e,t)=>{const n=Hl(Ja,e.__scopeMenu);return p.jsx(VT,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),Eue=Il("MenuContent.ScrollLock"),VT=x.forwardRef((e,t)=>{const{__scopeMenu:n,loop:a=!1,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:s,disableOutsidePointerEvents:c,onEntryFocus:u,onEscapeKeyDown:d,onPointerDownOutside:m,onFocusOutside:h,onInteractOutside:g,onDismiss:v,disableOutsideScroll:w,...S}=e,y=Hl(Ja,n),_=Zp(Ja,n),E=Zv(n),k=AV(n),C=mue(n),[R,A]=x.useState(null),I=x.useRef(null),O=Gt(t,I,y.onContentChange),j=x.useRef(0),F=x.useRef(""),H=x.useRef(0),K=x.useRef(null),Q=x.useRef("right"),W=x.useRef(0),ie=w?Wp:x.Fragment,V=w?{as:Eue,allowPinchZoom:!0}:void 0,Y=te=>{const re=F.current+te,$=C().filter(Z=>!Z.disabled),B=document.activeElement,U=$.find(Z=>Z.ref.current===B)?.textValue,L=$.map(Z=>Z.textValue),P=$ue(L,re,U),G=$.find(Z=>Z.textValue===P)?.ref.current;(function Z(J){F.current=J,window.clearTimeout(j.current),J!==""&&(j.current=window.setTimeout(()=>Z(""),1e3))})(re),G&&setTimeout(()=>G.focus())};x.useEffect(()=>()=>window.clearTimeout(j.current),[]),Pv();const z=x.useCallback(te=>Q.current===K.current?.side&&Mue(te,K.current?.area),[]);return p.jsx(wue,{scope:n,searchRef:F,onItemEnter:x.useCallback(te=>{z(te)&&te.preventDefault()},[z]),onItemLeave:x.useCallback(te=>{z(te)||(I.current?.focus(),A(null))},[z]),onTriggerLeave:x.useCallback(te=>{z(te)&&te.preventDefault()},[z]),pointerGraceTimerRef:H,onPointerGraceIntentChange:x.useCallback(te=>{K.current=te},[]),children:p.jsx(ie,{...V,children:p.jsx(Bp,{asChild:!0,trapped:r,onMountAutoFocus:He(i,te=>{te.preventDefault(),I.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:s,children:p.jsx(ed,{asChild:!0,disableOutsidePointerEvents:c,onEscapeKeyDown:d,onPointerDownOutside:m,onFocusOutside:h,onInteractOutside:g,onDismiss:v,children:p.jsx(Ece,{asChild:!0,...k,dir:_.dir,orientation:"vertical",loop:a,currentTabStopId:R,onCurrentTabStopIdChange:A,onEntryFocus:He(u,te=>{_.isUsingKeyboardRef.current||te.preventDefault()}),preventScrollOnEntryFocus:!0,children:p.jsx(Vv,{role:"menu","aria-orientation":"vertical","data-state":XV(y.open),"data-radix-menu-content":"",dir:_.dir,...E,...S,ref:O,style:{outline:"none",...S.style},onKeyDown:He(S.onKeyDown,te=>{const $=te.target.closest("[data-radix-menu-content]")===te.currentTarget,B=te.ctrlKey||te.altKey||te.metaKey,U=te.key.length===1;$&&(te.key==="Tab"&&te.preventDefault(),!B&&U&&Y(te.key));const L=I.current;if(te.target!==L||!due.includes(te.key))return;te.preventDefault();const G=C().filter(Z=>!Z.disabled).map(Z=>Z.ref.current);RV.includes(te.key)&&G.reverse(),Due(G)}),onBlur:He(e.onBlur,te=>{te.currentTarget.contains(te.target)||(window.clearTimeout(j.current),F.current="")}),onPointerMove:He(e.onPointerMove,rp(te=>{const re=te.target,$=W.current!==te.clientX;if(te.currentTarget.contains(re)&&$){const B=te.clientX>W.current?"right":"left";Q.current=B,W.current=te.clientX}}))})})})})})})});LV.displayName=Ja;var _ue="MenuGroup",GT=x.forwardRef((e,t)=>{const{__scopeMenu:n,...a}=e;return p.jsx(St.div,{role:"group",...a,ref:t})});GT.displayName=_ue;var kue="MenuLabel",$V=x.forwardRef((e,t)=>{const{__scopeMenu:n,...a}=e;return p.jsx(St.div,{...a,ref:t})});$V.displayName=kue;var Ob="MenuItem",JP="menu.itemSelect",Yv=x.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:a,...r}=e,i=x.useRef(null),s=Zp(Ob,e.__scopeMenu),c=HT(Ob,e.__scopeMenu),u=Gt(t,i),d=x.useRef(!1),m=()=>{const h=i.current;if(!n&&h){const g=new CustomEvent(JP,{bubbles:!0,cancelable:!0});h.addEventListener(JP,v=>a?.(v),{once:!0}),HH(h,g),g.defaultPrevented?d.current=!1:s.onClose()}};return p.jsx(jV,{...r,ref:u,disabled:n,onClick:He(e.onClick,m),onPointerDown:h=>{e.onPointerDown?.(h),d.current=!0},onPointerUp:He(e.onPointerUp,h=>{d.current||h.currentTarget?.click()}),onKeyDown:He(e.onKeyDown,h=>{const g=c.searchRef.current!=="";n||g&&h.key===" "||Jx.includes(h.key)&&(h.currentTarget.click(),h.preventDefault())})})});Yv.displayName=Ob;var jV=x.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:a=!1,textValue:r,...i}=e,s=HT(Ob,n),c=AV(n),u=x.useRef(null),d=Gt(t,u),[m,h]=x.useState(!1),[g,v]=x.useState("");return x.useEffect(()=>{const w=u.current;w&&v((w.textContent??"").trim())},[i.children]),p.jsx(np.ItemSlot,{scope:n,disabled:a,textValue:r??g,children:p.jsx(_ce,{asChild:!0,...c,focusable:!a,children:p.jsx(St.div,{role:"menuitem","data-highlighted":m?"":void 0,"aria-disabled":a||void 0,"data-disabled":a?"":void 0,...i,ref:d,onPointerMove:He(e.onPointerMove,rp(w=>{a?s.onItemLeave(w):(s.onItemEnter(w),w.defaultPrevented||w.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:He(e.onPointerLeave,rp(w=>s.onItemLeave(w))),onFocus:He(e.onFocus,()=>h(!0)),onBlur:He(e.onBlur,()=>h(!1))})})})}),Tue="MenuCheckboxItem",MV=x.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:a,...r}=e;return p.jsx(BV,{scope:e.__scopeMenu,checked:n,children:p.jsx(Yv,{role:"menuitemcheckbox","aria-checked":Db(n)?"mixed":n,...r,ref:t,"data-state":KT(n),onSelect:He(r.onSelect,()=>a?.(Db(n)?!0:!n),{checkForDefaultPrevented:!1})})})});MV.displayName=Tue;var PV="MenuRadioGroup",[Nue,Rue]=Bl(PV,{value:void 0,onValueChange:()=>{}}),UV=x.forwardRef((e,t)=>{const{value:n,onValueChange:a,...r}=e,i=Fi(a);return p.jsx(Nue,{scope:e.__scopeMenu,value:n,onValueChange:i,children:p.jsx(GT,{...r,ref:t})})});UV.displayName=PV;var zV="MenuRadioItem",FV=x.forwardRef((e,t)=>{const{value:n,...a}=e,r=Rue(zV,e.__scopeMenu),i=n===r.value;return p.jsx(BV,{scope:e.__scopeMenu,checked:i,children:p.jsx(Yv,{role:"menuitemradio","aria-checked":i,...a,ref:t,"data-state":KT(i),onSelect:He(a.onSelect,()=>r.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});FV.displayName=zV;var WT="MenuItemIndicator",[BV,Cue]=Bl(WT,{checked:!1}),HV=x.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:a,...r}=e,i=Cue(WT,n);return p.jsx(Ma,{present:a||Db(i.checked)||i.checked===!0,children:p.jsx(St.span,{...r,ref:t,"data-state":KT(i.checked)})})});HV.displayName=WT;var Aue="MenuSeparator",VV=x.forwardRef((e,t)=>{const{__scopeMenu:n,...a}=e;return p.jsx(St.div,{role:"separator","aria-orientation":"horizontal",...a,ref:t})});VV.displayName=Aue;var Iue="MenuArrow",GV=x.forwardRef((e,t)=>{const{__scopeMenu:n,...a}=e,r=Zv(n);return p.jsx(Gv,{...r,...a,ref:t})});GV.displayName=Iue;var Oue="MenuSub",[J_e,WV]=Bl(Oue),wf="MenuSubTrigger",KV=x.forwardRef((e,t)=>{const n=Hl(wf,e.__scopeMenu),a=Zp(wf,e.__scopeMenu),r=WV(wf,e.__scopeMenu),i=HT(wf,e.__scopeMenu),s=x.useRef(null),{pointerGraceTimerRef:c,onPointerGraceIntentChange:u}=i,d={__scopeMenu:e.__scopeMenu},m=x.useCallback(()=>{s.current&&window.clearTimeout(s.current),s.current=null},[]);return x.useEffect(()=>m,[m]),x.useEffect(()=>{const h=c.current;return()=>{window.clearTimeout(h),u(null)}},[c,u]),p.jsx(FT,{asChild:!0,...d,children:p.jsx(jV,{id:r.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":r.contentId,"data-state":XV(n.open),...e,ref:zi(t,r.onTriggerChange),onClick:h=>{e.onClick?.(h),!(e.disabled||h.defaultPrevented)&&(h.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:He(e.onPointerMove,rp(h=>{i.onItemEnter(h),!h.defaultPrevented&&!e.disabled&&!n.open&&!s.current&&(i.onPointerGraceIntentChange(null),s.current=window.setTimeout(()=>{n.onOpenChange(!0),m()},100))})),onPointerLeave:He(e.onPointerLeave,rp(h=>{m();const g=n.content?.getBoundingClientRect();if(g){const v=n.content?.dataset.side,w=v==="right",S=w?-5:5,y=g[w?"left":"right"],_=g[w?"right":"left"];i.onPointerGraceIntentChange({area:[{x:h.clientX+S,y:h.clientY},{x:y,y:g.top},{x:_,y:g.top},{x:_,y:g.bottom},{x:y,y:g.bottom}],side:v}),window.clearTimeout(c.current),c.current=window.setTimeout(()=>i.onPointerGraceIntentChange(null),300)}else{if(i.onTriggerLeave(h),h.defaultPrevented)return;i.onPointerGraceIntentChange(null)}})),onKeyDown:He(e.onKeyDown,h=>{const g=i.searchRef.current!=="";e.disabled||g&&h.key===" "||fue[a.dir].includes(h.key)&&(n.onOpenChange(!0),n.content?.focus(),h.preventDefault())})})})});KV.displayName=wf;var ZV="MenuSubContent",YV=x.forwardRef((e,t)=>{const n=OV(Ja,e.__scopeMenu),{forceMount:a=n.forceMount,...r}=e,i=Hl(Ja,e.__scopeMenu),s=Zp(Ja,e.__scopeMenu),c=WV(ZV,e.__scopeMenu),u=x.useRef(null),d=Gt(t,u);return p.jsx(np.Provider,{scope:e.__scopeMenu,children:p.jsx(Ma,{present:a||i.open,children:p.jsx(np.Slot,{scope:e.__scopeMenu,children:p.jsx(VT,{id:c.contentId,"aria-labelledby":c.triggerId,...r,ref:d,align:"start",side:s.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:m=>{s.isUsingKeyboardRef.current&&u.current?.focus(),m.preventDefault()},onCloseAutoFocus:m=>m.preventDefault(),onFocusOutside:He(e.onFocusOutside,m=>{m.target!==c.trigger&&i.onOpenChange(!1)}),onEscapeKeyDown:He(e.onEscapeKeyDown,m=>{s.onClose(),m.preventDefault()}),onKeyDown:He(e.onKeyDown,m=>{const h=m.currentTarget.contains(m.target),g=pue[s.dir].includes(m.key);h&&g&&(i.onOpenChange(!1),c.trigger?.focus(),m.preventDefault())})})})})})});YV.displayName=ZV;function XV(e){return e?"open":"closed"}function Db(e){return e==="indeterminate"}function KT(e){return Db(e)?"indeterminate":e?"checked":"unchecked"}function Due(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function Lue(e,t){return e.map((n,a)=>e[(t+a)%e.length])}function $ue(e,t,n){const r=t.length>1&&Array.from(t).every(d=>d===t[0])?t[0]:t,i=n?e.indexOf(n):-1;let s=Lue(e,Math.max(i,0));r.length===1&&(s=s.filter(d=>d!==n));const u=s.find(d=>d.toLowerCase().startsWith(r.toLowerCase()));return u!==n?u:void 0}function jue(e,t){const{x:n,y:a}=e;let r=!1;for(let i=0,s=t.length-1;i<t.length;s=i++){const c=t[i],u=t[s],d=c.x,m=c.y,h=u.x,g=u.y;m>a!=g>a&&n<(h-d)*(a-m)/(g-m)+d&&(r=!r)}return r}function Mue(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return jue(n,t)}function rp(e){return t=>t.pointerType==="mouse"?e(t):void 0}var Pue=IV,Uue=FT,zue=DV,Fue=LV,Bue=GT,Hue=$V,Vue=Yv,Gue=MV,Wue=UV,Kue=FV,Zue=HV,Yue=VV,Xue=GV,que=KV,Jue=YV,Xv="DropdownMenu",[Que]=_i(Xv,[CV]),ta=CV(),[ede,qV]=Que(Xv),JV=e=>{const{__scopeDropdownMenu:t,children:n,dir:a,open:r,defaultOpen:i,onOpenChange:s,modal:c=!0}=e,u=ta(t),d=x.useRef(null),[m,h]=Co({prop:r,defaultProp:i??!1,onChange:s,caller:Xv});return p.jsx(ede,{scope:t,triggerId:Ir(),triggerRef:d,contentId:Ir(),open:m,onOpenChange:h,onOpenToggle:x.useCallback(()=>h(g=>!g),[h]),modal:c,children:p.jsx(Pue,{...u,open:m,onOpenChange:h,dir:a,modal:c,children:n})})};JV.displayName=Xv;var QV="DropdownMenuTrigger",e9=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:a=!1,...r}=e,i=qV(QV,n),s=ta(n);return p.jsx(Uue,{asChild:!0,...s,children:p.jsx(St.button,{type:"button",id:i.triggerId,"aria-haspopup":"menu","aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":i.open?"open":"closed","data-disabled":a?"":void 0,disabled:a,...r,ref:zi(t,i.triggerRef),onPointerDown:He(e.onPointerDown,c=>{!a&&c.button===0&&c.ctrlKey===!1&&(i.onOpenToggle(),i.open||c.preventDefault())}),onKeyDown:He(e.onKeyDown,c=>{a||(["Enter"," "].includes(c.key)&&i.onOpenToggle(),c.key==="ArrowDown"&&i.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(c.key)&&c.preventDefault())})})})});e9.displayName=QV;var tde="DropdownMenuPortal",t9=e=>{const{__scopeDropdownMenu:t,...n}=e,a=ta(t);return p.jsx(zue,{...a,...n})};t9.displayName=tde;var n9="DropdownMenuContent",r9=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=qV(n9,n),i=ta(n),s=x.useRef(!1);return p.jsx(Fue,{id:r.contentId,"aria-labelledby":r.triggerId,...i,...a,ref:t,onCloseAutoFocus:He(e.onCloseAutoFocus,c=>{s.current||r.triggerRef.current?.focus(),s.current=!1,c.preventDefault()}),onInteractOutside:He(e.onInteractOutside,c=>{const u=c.detail.originalEvent,d=u.button===0&&u.ctrlKey===!0,m=u.button===2||d;(!r.modal||m)&&(s.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});r9.displayName=n9;var nde="DropdownMenuGroup",rde=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ta(n);return p.jsx(Bue,{...r,...a,ref:t})});rde.displayName=nde;var ade="DropdownMenuLabel",a9=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ta(n);return p.jsx(Hue,{...r,...a,ref:t})});a9.displayName=ade;var ide="DropdownMenuItem",i9=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ta(n);return p.jsx(Vue,{...r,...a,ref:t})});i9.displayName=ide;var ode="DropdownMenuCheckboxItem",o9=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ta(n);return p.jsx(Gue,{...r,...a,ref:t})});o9.displayName=ode;var sde="DropdownMenuRadioGroup",lde=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ta(n);return p.jsx(Wue,{...r,...a,ref:t})});lde.displayName=sde;var cde="DropdownMenuRadioItem",s9=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ta(n);return p.jsx(Kue,{...r,...a,ref:t})});s9.displayName=cde;var ude="DropdownMenuItemIndicator",dde=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ta(n);return p.jsx(Zue,{...r,...a,ref:t})});dde.displayName=ude;var fde="DropdownMenuSeparator",l9=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ta(n);return p.jsx(Yue,{...r,...a,ref:t})});l9.displayName=fde;var pde="DropdownMenuArrow",mde=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ta(n);return p.jsx(Xue,{...r,...a,ref:t})});mde.displayName=pde;var hde="DropdownMenuSubTrigger",c9=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ta(n);return p.jsx(que,{...r,...a,ref:t})});c9.displayName=hde;var gde="DropdownMenuSubContent",u9=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ta(n);return p.jsx(Jue,{...r,...a,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});u9.displayName=gde;var bde=JV,vde=e9,yde=t9,d9=r9,f9=a9,p9=i9,wde=o9,Sde=s9,m9=l9,xde=c9,Ede=u9;const Qx=bde,eE=vde;xde.displayName;Ede.displayName;function Lb({ref:e,className:t,sideOffset:n=4,...a}){return p.jsx(yde,{children:p.jsx(d9,{ref:e,sideOffset:n,className:De("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md","data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-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",t),...a})})}Lb.displayName=d9.displayName;function So({ref:e,className:t,inset:n,...a}){return p.jsx(p9,{ref:e,className:De("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",n&&"pl-8",t),...a})}So.displayName=p9.displayName;wde.displayName;Sde.displayName;function tE({ref:e,className:t,inset:n,...a}){return p.jsx(f9,{ref:e,className:De("px-2 py-1.5 text-sm font-semibold",n&&"pl-8",t),...a})}tE.displayName=f9.displayName;function Sf({ref:e,className:t,...n}){return p.jsx(m9,{ref:e,className:De("-mx-1 my-1 h-px bg-muted",t),...n})}Sf.displayName=m9.displayName;var _de=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Uo=_de.reduce((e,t)=>{const n=kH(`Primitive.${t}`),a=x.forwardRef((r,i)=>{const{asChild:s,...c}=r,u=s?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),p.jsx(u,{...c,ref:i})});return a.displayName=`Primitive.${t}`,{...e,[t]:a}},{}),kde="Label",h9=x.forwardRef((e,t)=>p.jsx(Uo.label,{...e,ref:t,onMouseDown:n=>{n.target.closest("button, input, select, textarea")||(e.onMouseDown?.(n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));h9.displayName=kde;var Tde=h9;function Yt({className:e,...t}){return p.jsx(Tde,{"data-slot":"label",className:De("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",e),...t})}function Yp({message:e,className:t="",vertical:n,noBorder:a}){return p.jsx("div",{className:De(`mt-2 rounded-md p-6 ${t}`,!a&&"border"),children:p.jsxs("p",{className:De("text-sm text-muted-foreground flex items-center gap-4",n&&"flex-col"),children:[p.jsx("svg",{width:"40",height:"40",viewBox:"0 0 273 273",version:"1.1",xmlns:"http://www.w3.org/2000/svg",className:"flex-shrink-0",children:p.jsx("g",{stroke:"none",strokeWidth:"1",fill:"none",fillRule:"evenodd",children:p.jsxs("g",{transform:"translate(5.320900, 5.320900)",fillRule:"nonzero",className:"stroke-black dark:stroke-white",strokeWidth:"4",children:[p.jsx("path",{d:"M49.953025,-2.10854389 C63.26892,-2.21867124 76.6185256,2.70621155 86.9019463,12.6653164 L86.9019463,12.6653164 L87.505627,13.2592944 C97.5154947,23.2654892 102.640454,36.3074513 102.880738,49.4222247 C103.08932,77.4533067 113.877287,105.391753 135.242867,126.757333 C156.613383,148.127849 184.559216,158.914875 212.568138,159.119313 L212.568138,159.119313 L213.212264,159.134159 C225.843948,159.517566 238.363557,164.434972 248.121998,173.886137 L248.121998,173.886137 L248.725621,174.480088 C258.982114,184.732164 264.11035,198.171134 264.11035,211.6101 C264.11035,225.04592 258.984514,238.481745 248.732867,248.732867 C238.592792,258.872942 225.336706,263.997882 212.046872,264.107794 C198.731075,264.21792 185.381569,259.293085 175.098248,249.334078 L175.098248,249.334078 L174.494602,248.740134 C163.75802,238.008189 158.640853,223.784027 159.143413,209.719372 C158.258245,182.640933 147.489786,155.83332 126.828333,135.171867 C106.351297,114.694831 79.8363505,103.934873 53.0237258,102.891841 L53.0237258,102.891841 L52.2811438,102.865674 C38.4791718,103.347421 24.5325234,98.4328111 13.8776628,88.1140866 L13.8776628,88.1140866 L13.2739843,87.5201168 C3.12895117,77.3789607 -1.9984796,64.1195994 -2.10841888,50.8264755 C-2.21854669,37.5105567 2.70635908,24.1609269 12.6655135,13.8774565 L12.6655135,13.8774565 L13.2594878,13.2737797 C23.4005926,3.12880025 36.659927,-1.99860507 49.953025,-2.10854389 Z"}),p.jsx("circle",{cx:"50",cy:"212.0001",r:"52.5"}),p.jsx("circle",{cx:"212.0001",cy:"50",r:"52.5"})]})})}),e]})})}function g9({className:e,color:t,children:n,grayscaled:a=!1}){const r=x.useMemo(()=>{if(t){const h=t.split("(")[1].split(")")[0].trim().split(/\s+/);return Number.parseFloat(h[1]||"0")}return a?0:.2},[t,a]),i=x.useMemo(()=>{if(t){const h=t.split("(")[1].split(")")[0].trim().split(/\s+/);return Number.parseFloat(h[0]||"0.5")}return a?.3:.4},[t,a]),s=x.useMemo(()=>{if(t){const h=t.split("(")[1].split(")")[0].trim().split(/\s+/);return Number.parseFloat(h[2]||"0")}return Math.floor(Math.random()*360)},[t]),c=x.useMemo(()=>t||`oklch(${Math.min(i,1)} ${r} ${s})`,[s,r,i]),u=x.useMemo(()=>`oklch(${Math.min(i*2,1)} ${r} ${s})`,[s,r,i,t]),d=x.useMemo(()=>Math.floor(Math.random()*360),[s]),m=x.useMemo(()=>"1000%",[]);return p.jsx("section",{className:De("relative w-full h-full overflow-hidden",e),style:{background:`${u}`},children:p.jsxs("div",{className:"isolate relative w-full h-full",children:[p.jsx("div",{className:"noise w-full h-full",style:{background:`linear-gradient(${d}deg, ${c}, transparent), url(https://grainy-gradients.vercel.app/noise.svg)`,filter:`contrast(120%) brightness(${m})`}}),n&&p.jsx("div",{className:"relative z-10 w-full h-full",children:n})]})})}function ZT(e){const t=x.useRef({value:e,previous:e});return x.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var qv="Switch",[Nde]=_i(qv),[Rde,Cde]=Nde(qv),b9=x.forwardRef((e,t)=>{const{__scopeSwitch:n,name:a,checked:r,defaultChecked:i,required:s,disabled:c,value:u="on",onCheckedChange:d,form:m,...h}=e,[g,v]=x.useState(null),w=Gt(t,k=>v(k)),S=x.useRef(!1),y=g?m||!!g.closest("form"):!0,[_,E]=Co({prop:r,defaultProp:i??!1,onChange:d,caller:qv});return p.jsxs(Rde,{scope:n,checked:_,disabled:c,children:[p.jsx(St.button,{type:"button",role:"switch","aria-checked":_,"aria-required":s,"data-state":S9(_),"data-disabled":c?"":void 0,disabled:c,value:u,...h,ref:w,onClick:He(e.onClick,k=>{E(C=>!C),y&&(S.current=k.isPropagationStopped(),S.current||k.stopPropagation())})}),y&&p.jsx(w9,{control:g,bubbles:!S.current,name:a,value:u,checked:_,required:s,disabled:c,form:m,style:{transform:"translateX(-100%)"}})]})});b9.displayName=qv;var v9="SwitchThumb",y9=x.forwardRef((e,t)=>{const{__scopeSwitch:n,...a}=e,r=Cde(v9,n);return p.jsx(St.span,{"data-state":S9(r.checked),"data-disabled":r.disabled?"":void 0,...a,ref:t})});y9.displayName=v9;var Ade="SwitchBubbleInput",w9=x.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:a=!0,...r},i)=>{const s=x.useRef(null),c=Gt(s,i),u=ZT(n),d=PT(t);return x.useEffect(()=>{const m=s.current;if(!m)return;const h=window.HTMLInputElement.prototype,v=Object.getOwnPropertyDescriptor(h,"checked").set;if(u!==n&&v){const w=new Event("click",{bubbles:a});v.call(m,n),m.dispatchEvent(w)}},[u,n,a]),p.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...r,tabIndex:-1,ref:c,style:{...r.style,...d,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});w9.displayName=Ade;function S9(e){return e?"checked":"unchecked"}var x9=b9,Ide=y9;function Jv({ref:e,className:t,...n}){return p.jsx(x9,{className:De("peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",t),...n,ref:e,children:p.jsx(Ide,{className:De("pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0")})})}Jv.displayName=x9.displayName;var E9=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),Ode="VisuallyHidden",_9=x.forwardRef((e,t)=>p.jsx(St.span,{...e,ref:t,style:{...E9,...e.style}}));_9.displayName=Ode;var Dde=_9,[Qv]=_i("Tooltip",[Ps]),ey=Ps(),k9="TooltipProvider",Lde=700,nE="tooltip.open",[$de,YT]=Qv(k9),T9=e=>{const{__scopeTooltip:t,delayDuration:n=Lde,skipDelayDuration:a=300,disableHoverableContent:r=!1,children:i}=e,s=x.useRef(!0),c=x.useRef(!1),u=x.useRef(0);return x.useEffect(()=>{const d=u.current;return()=>window.clearTimeout(d)},[]),p.jsx($de,{scope:t,isOpenDelayedRef:s,delayDuration:n,onOpen:x.useCallback(()=>{window.clearTimeout(u.current),s.current=!1},[]),onClose:x.useCallback(()=>{window.clearTimeout(u.current),u.current=window.setTimeout(()=>s.current=!0,a)},[a]),isPointerInTransitRef:c,onPointerInTransitChange:x.useCallback(d=>{c.current=d},[]),disableHoverableContent:r,children:i})};T9.displayName=k9;var ap="Tooltip",[jde,Xp]=Qv(ap),N9=e=>{const{__scopeTooltip:t,children:n,open:a,defaultOpen:r,onOpenChange:i,disableHoverableContent:s,delayDuration:c}=e,u=YT(ap,e.__scopeTooltip),d=ey(t),[m,h]=x.useState(null),g=Ir(),v=x.useRef(0),w=s??u.disableHoverableContent,S=c??u.delayDuration,y=x.useRef(!1),[_,E]=Co({prop:a,defaultProp:r??!1,onChange:I=>{I?(u.onOpen(),document.dispatchEvent(new CustomEvent(nE))):u.onClose(),i?.(I)},caller:ap}),k=x.useMemo(()=>_?y.current?"delayed-open":"instant-open":"closed",[_]),C=x.useCallback(()=>{window.clearTimeout(v.current),v.current=0,y.current=!1,E(!0)},[E]),R=x.useCallback(()=>{window.clearTimeout(v.current),v.current=0,E(!1)},[E]),A=x.useCallback(()=>{window.clearTimeout(v.current),v.current=window.setTimeout(()=>{y.current=!0,E(!0),v.current=0},S)},[S,E]);return x.useEffect(()=>()=>{v.current&&(window.clearTimeout(v.current),v.current=0)},[]),p.jsx(Hv,{...d,children:p.jsx(jde,{scope:t,contentId:g,open:_,stateAttribute:k,trigger:m,onTriggerChange:h,onTriggerEnter:x.useCallback(()=>{u.isOpenDelayedRef.current?A():C()},[u.isOpenDelayedRef,A,C]),onTriggerLeave:x.useCallback(()=>{w?R():(window.clearTimeout(v.current),v.current=0)},[R,w]),onOpen:C,onClose:R,disableHoverableContent:w,children:n})})};N9.displayName=ap;var rE="TooltipTrigger",R9=x.forwardRef((e,t)=>{const{__scopeTooltip:n,...a}=e,r=Xp(rE,n),i=YT(rE,n),s=ey(n),c=x.useRef(null),u=Gt(t,c,r.onTriggerChange),d=x.useRef(!1),m=x.useRef(!1),h=x.useCallback(()=>d.current=!1,[]);return x.useEffect(()=>()=>document.removeEventListener("pointerup",h),[h]),p.jsx(Vp,{asChild:!0,...s,children:p.jsx(St.button,{"aria-describedby":r.open?r.contentId:void 0,"data-state":r.stateAttribute,...a,ref:u,onPointerMove:He(e.onPointerMove,g=>{g.pointerType!=="touch"&&!m.current&&!i.isPointerInTransitRef.current&&(r.onTriggerEnter(),m.current=!0)}),onPointerLeave:He(e.onPointerLeave,()=>{r.onTriggerLeave(),m.current=!1}),onPointerDown:He(e.onPointerDown,()=>{r.open&&r.onClose(),d.current=!0,document.addEventListener("pointerup",h,{once:!0})}),onFocus:He(e.onFocus,()=>{d.current||r.onOpen()}),onBlur:He(e.onBlur,r.onClose),onClick:He(e.onClick,r.onClose)})})});R9.displayName=rE;var XT="TooltipPortal",[Mde,Pde]=Qv(XT,{forceMount:void 0}),C9=e=>{const{__scopeTooltip:t,forceMount:n,children:a,container:r}=e,i=Xp(XT,t);return p.jsx(Mde,{scope:t,forceMount:n,children:p.jsx(Ma,{present:n||i.open,children:p.jsx(rd,{asChild:!0,container:r,children:a})})})};C9.displayName=XT;var $u="TooltipContent",A9=x.forwardRef((e,t)=>{const n=Pde($u,e.__scopeTooltip),{forceMount:a=n.forceMount,side:r="top",...i}=e,s=Xp($u,e.__scopeTooltip);return p.jsx(Ma,{present:a||s.open,children:s.disableHoverableContent?p.jsx(I9,{side:r,...i,ref:t}):p.jsx(Ude,{side:r,...i,ref:t})})}),Ude=x.forwardRef((e,t)=>{const n=Xp($u,e.__scopeTooltip),a=YT($u,e.__scopeTooltip),r=x.useRef(null),i=Gt(t,r),[s,c]=x.useState(null),{trigger:u,onClose:d}=n,m=r.current,{onPointerInTransitChange:h}=a,g=x.useCallback(()=>{c(null),h(!1)},[h]),v=x.useCallback((w,S)=>{const y=w.currentTarget,_={x:w.clientX,y:w.clientY},E=Hde(_,y.getBoundingClientRect()),k=Vde(_,E),C=Gde(S.getBoundingClientRect()),R=Kde([...k,...C]);c(R),h(!0)},[h]);return x.useEffect(()=>()=>g(),[g]),x.useEffect(()=>{if(u&&m){const w=y=>v(y,m),S=y=>v(y,u);return u.addEventListener("pointerleave",w),m.addEventListener("pointerleave",S),()=>{u.removeEventListener("pointerleave",w),m.removeEventListener("pointerleave",S)}}},[u,m,v,g]),x.useEffect(()=>{if(s){const w=S=>{const y=S.target,_={x:S.clientX,y:S.clientY},E=u?.contains(y)||m?.contains(y),k=!Wde(_,s);E?g():k&&(g(),d())};return document.addEventListener("pointermove",w),()=>document.removeEventListener("pointermove",w)}},[u,m,s,d,g]),p.jsx(I9,{...e,ref:i})}),[zde,Fde]=Qv(ap,{isInside:!1}),Bde=xse("TooltipContent"),I9=x.forwardRef((e,t)=>{const{__scopeTooltip:n,children:a,"aria-label":r,onEscapeKeyDown:i,onPointerDownOutside:s,...c}=e,u=Xp($u,n),d=ey(n),{onClose:m}=u;return x.useEffect(()=>(document.addEventListener(nE,m),()=>document.removeEventListener(nE,m)),[m]),x.useEffect(()=>{if(u.trigger){const h=g=>{g.target?.contains(u.trigger)&&m()};return window.addEventListener("scroll",h,{capture:!0}),()=>window.removeEventListener("scroll",h,{capture:!0})}},[u.trigger,m]),p.jsx(ed,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:i,onPointerDownOutside:s,onFocusOutside:h=>h.preventDefault(),onDismiss:m,children:p.jsxs(Vv,{"data-state":u.stateAttribute,...d,...c,ref:t,style:{...c.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[p.jsx(Bde,{children:a}),p.jsx(zde,{scope:n,isInside:!0,children:p.jsx(Dde,{id:u.contentId,role:"tooltip",children:r||a})})]})})});A9.displayName=$u;var O9="TooltipArrow",D9=x.forwardRef((e,t)=>{const{__scopeTooltip:n,...a}=e,r=ey(n);return Fde(O9,n).isInside?null:p.jsx(Gv,{...r,...a,ref:t})});D9.displayName=O9;function Hde(e,t){const n=Math.abs(t.top-e.y),a=Math.abs(t.bottom-e.y),r=Math.abs(t.right-e.x),i=Math.abs(t.left-e.x);switch(Math.min(n,a,r,i)){case i:return"left";case r:return"right";case n:return"top";case a:return"bottom";default:throw new Error("unreachable")}}function Vde(e,t,n=5){const a=[];switch(t){case"top":a.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":a.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":a.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":a.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return a}function Gde(e){const{top:t,right:n,bottom:a,left:r}=e;return[{x:r,y:t},{x:n,y:t},{x:n,y:a},{x:r,y:a}]}function Wde(e,t){const{x:n,y:a}=e;let r=!1;for(let i=0,s=t.length-1;i<t.length;s=i++){const c=t[i],u=t[s],d=c.x,m=c.y,h=u.x,g=u.y;m>a!=g>a&&n<(h-d)*(a-m)/(g-m)+d&&(r=!r)}return r}function Kde(e){const t=e.slice();return t.sort((n,a)=>n.x<a.x?-1:n.x>a.x?1:n.y<a.y?-1:n.y>a.y?1:0),Zde(t)}function Zde(e){if(e.length<=1)return e.slice();const t=[];for(let a=0;a<e.length;a++){const r=e[a];for(;t.length>=2;){const i=t[t.length-1],s=t[t.length-2];if((i.x-s.x)*(r.y-s.y)>=(i.y-s.y)*(r.x-s.x))t.pop();else break}t.push(r)}t.pop();const n=[];for(let a=e.length-1;a>=0;a--){const r=e[a];for(;n.length>=2;){const i=n[n.length-1],s=n[n.length-2];if((i.x-s.x)*(r.y-s.y)>=(i.y-s.y)*(r.x-s.x))n.pop();else break}n.push(r)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var Yde=T9,Xde=N9,qde=R9,Jde=C9,Qde=A9,efe=D9;function L9({delayDuration:e=0,...t}){return p.jsx(Yde,{"data-slot":"tooltip-provider",delayDuration:e,...t})}function en({...e}){return p.jsx(L9,{children:p.jsx(Xde,{"data-slot":"tooltip",...e})})}function tn({...e}){return p.jsx(qde,{"data-slot":"tooltip-trigger",...e})}function nn({className:e,sideOffset:t=0,children:n,...a}){return p.jsx(Jde,{children:p.jsxs(Qde,{"data-slot":"tooltip-content",sideOffset:t,className:De("bg-foreground text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-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 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",e),...a,children:[n,p.jsx(efe,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}class tfe{name="mcp_inspector_open";properties;constructor(t){this.properties={server_url:t.serverUrl,connection_count:t.connectionCount}}}class QP{name="mcp_tool_execution";properties;constructor(t){this.properties={tool_name:t.toolName,server_id:t.serverId,success:t.success,duration:t.duration,error:t.error}}}class eU{name="mcp_resource_read";properties;constructor(t){this.properties={resource_uri:t.resourceUri,server_id:t.serverId,success:t.success,error:t.error}}}class tU{name="mcp_prompt_call";properties;constructor(t){this.properties={prompt_name:t.promptName,server_id:t.serverId,success:t.success,error:t.error}}}class nU{name="mcp_chat_message";properties;constructor(t){this.properties={server_id:t.serverId,provider:t.provider,model:t.model,message_count:t.messageCount,tool_calls_count:t.toolCallsCount,success:t.success,execution_mode:t.executionMode,duration:t.duration,error:t.error}}}class nfe{name="mcp_server_added";properties;constructor(t){this.properties={server_id:t.serverId,server_url:t.serverUrl,connection_type:t.connectionType,via_proxy:t.viaProxy}}}class rfe{name="mcp_server_removed";properties;constructor(t){this.properties={server_id:t.serverId}}}class afe{name="mcp_command_palette_open";properties;constructor(t){this.properties={trigger:t.trigger}}}class ife{name="mcp_tool_saved";properties;constructor(t){this.properties={tool_name:t.toolName,server_id:t.serverId}}}function NS(){try{return"0.10.1"}catch{return"0.0.0"}}var ofe={};function RS(){try{return typeof window<"u"&&typeof document<"u"}catch{return!1}}class rU{endpoint;timeout;constructor(t,n=3e3){this.endpoint=t,this.timeout=n}async logEvent(t){try{const n=new AbortController,a=setTimeout(()=>n.abort(),this.timeout),r=await fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t),signal:n.signal});if(clearTimeout(a),!r.ok)throw new Error(`HTTP error! status: ${r.status}`)}catch{}}}function ps(e){return`mcp_inspector_telemetry_${e}`}class br{static instance=null;POSTHOG_PROXY_URL="/inspector/api/tel/posthog";SCARF_PROXY_URL="/inspector/api/tel/scarf";UNKNOWN_USER_ID="UNKNOWN_USER_ID";_currUserId=null;_posthogClient=null;_scarfClient=null;_source="inspector";constructor(){const t=RS(),n=this.isTelemetryDisabled();if(this._source=this.getStoredSource()||"inspector",n)this._posthogClient=null,this._scarfClient=null;else if(!t)this._posthogClient=null,this._scarfClient=null;else{try{this._posthogClient=new rU(this.POSTHOG_PROXY_URL,3e3)}catch{this._posthogClient=null}try{this._scarfClient=new rU(this.SCARF_PROXY_URL,3e3)}catch{this._scarfClient=null}}}isTelemetryDisabled(){return typeof localStorage<"u"&&localStorage.getItem(ps("disabled"))==="true"||typeof process<"u"&&ofe?.MCP_USE_ANONYMIZED_TELEMETRY==="false"}getStoredSource(){return typeof localStorage<"u"?localStorage.getItem(ps("source")):null}static getInstance(){return br.instance||(br.instance=new br),br.instance}setSource(t){this._source=t,typeof localStorage<"u"&&localStorage.setItem(ps("source"),t)}getSource(){return this._source}get userId(){if(this._currUserId)return this._currUserId;if(!RS())return this._currUserId=this.UNKNOWN_USER_ID,this._currUserId;try{const t=localStorage.getItem(ps("user_id"));if(t)this._currUserId=t;else{const n=this.generateUserId();localStorage.setItem(ps("user_id"),n),this._currUserId=n}this.trackPackageDownload({triggered_by:"user_id_property"}).catch(()=>{})}catch{this._currUserId=this.UNKNOWN_USER_ID}return this._currUserId}generateUserId(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{const n=Math.random()*16|0;return(t==="x"?n:n&3|8).toString(16)})}async capture(t){if(!(!this._posthogClient&&!this._scarfClient)){if(this._posthogClient)try{const n={event:t.name,user_id:this.userId,properties:{...t.properties,mcp_use_version:NS(),language:"typescript",source:this._source,package:"inspector"}};await this._posthogClient.logEvent(n)}catch{}if(this._scarfClient)try{const n={};n.mcp_use_version=NS(),n.user_id=this.userId,n.event=t.name,n.language="typescript",n.source=this._source,n.package="inspector",await this._scarfClient.logEvent(n)}catch{}}}async trackPackageDownload(t){if(this._scarfClient&&RS())try{const n=NS();let a=!1,r=!1;const i=localStorage.getItem(ps("download_version"));if(i?n>i&&(a=!0,r=!1,localStorage.setItem(ps("download_version"),n)):(a=!0,r=!0,localStorage.setItem(ps("download_version"),n)),a){const s={...t||{}};s.mcp_use_version=n,s.user_id=this.userId,s.event="package_download",s.first_download=r,s.language="typescript",s.source=this._source,s.package="inspector",await this._scarfClient.logEvent(s)}}catch{}}async trackInspectorOpen(t){const n=new tfe(t);await this.capture(n)}}const sfe={model:"stub-model",stopReason:"endTurn",role:"assistant",content:{type:"text",text:"positive"}};function lfe({requestId:e,serverName:t,onViewDetails:n,onApprove:a,onDeny:r}){return p.jsxs("div",{className:"space-y-3",children:[p.jsxs("div",{children:[p.jsx("strong",{children:"Sampling Request Received"}),p.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:["New request from ",t]})]}),p.jsxs("div",{className:"flex gap-2",children:[p.jsx("button",{className:"px-3 py-1.5 text-xs font-medium rounded-md hover:bg-accent hover:text-accent-foreground",onClick:i=>{i.stopPropagation(),n()},children:"View Details"}),p.jsx("button",{className:"px-3 py-1.5 text-xs font-medium rounded-md hover:bg-accent hover:text-accent-foreground",onClick:i=>{i.stopPropagation(),a(sfe)},children:"Approve"}),p.jsx("button",{className:"px-3 py-1.5 text-xs font-medium rounded-md hover:bg-accent hover:text-accent-foreground",onClick:i=>{i.stopPropagation(),r()},children:"Deny"})]})]})}const Eg=()=>{},_g=()=>{},$9=x.createContext(null);function qT(){const e=x.use($9);if(!e)throw new Error("useMcpContext must be used within a McpProvider");return e}function cfe({url:e,name:t,proxyConfig:n,transportType:a,connectionId:r,onUpdate:i,onRemove:s}){const c=typeof window<"u"?new URL("/inspector/oauth/callback",window.location.origin).toString():"/inspector/oauth/callback";let u=e,d={};if(n?.proxyAddress){const Y=new URL(n.proxyAddress),z=new URL(e);u=`${Y.origin}${Y.pathname}${z.pathname}${z.search}`,d["X-Target-URL"]=e}n?.customHeaders&&(d={...d,...n.customHeaders});const[m,h]=x.useState([]),g=x.useRef(0),v=x.useMemo(()=>m.map(Y=>({id:Y.id,request:Y.request,timestamp:Y.timestamp,serverName:Y.serverName})),[m]),w=x.useRef(null),[S,y]=x.useState(!1),_=x.useRef(!1);x.useEffect(()=>{typeof window<"u"&&!_.current&&(_.current=!0,Ar(()=>import("./transport-wrapper-browser-BI4dDu3b.js"),[]).then(Y=>{w.current=Y.wrapTransportForLogging,y(!0),console.log("[McpContext] Transport wrapper loaded")}).catch(Y=>{console.error("[McpContext] Failed to load transport wrapper:",Y)}))},[]);const E=x.useMemo(()=>{if(!(!S||!w.current))return(Y,z)=>{const te=r;return console.log("[McpContext] Applying transport wrapper, serverId:",te,"from connector:",z),w.current(Y,te)}},[S,r]),k=`mcp-inspector-notifications-${r}`,C=500,[R,A]=x.useState([]);x.useEffect(()=>{try{const Y=localStorage.getItem(k);if(Y){const z=JSON.parse(Y);Array.isArray(z)&&A(z)}}catch(Y){console.error("Failed to load notifications from localStorage:",Y)}},[k]),x.useEffect(()=>{try{localStorage.setItem(k,JSON.stringify(R))}catch(Y){console.error("Failed to save notifications to localStorage:",Y)}},[R,k]);const I=x.useCallback(Y=>{A(z=>z.map(te=>te.id===Y?{...te,read:!0}:te))},[]),O=x.useCallback(()=>{A(Y=>Y.map(z=>({...z,read:!0})))},[]),j=x.useCallback(()=>{A([])},[]),F=x.useCallback(Y=>{A(z=>{const te=[Y,...z];return te.length>C?te.slice(0,C):te})},[]),H=x.useCallback((Y,z)=>{h(te=>{const re=te.find($=>$.id===Y);return re?(re.resolve(z),te.filter($=>$.id!==Y)):te})},[]),K=x.useCallback((Y,z)=>{h(te=>{const re=te.find($=>$.id===Y);return re?(re.reject(new Error(z||"User rejected sampling request")),te.filter($=>$.id!==Y)):te})},[]),Q=x.useCallback(async Y=>new Promise((z,te)=>{const re=`sampling-${g.current++}`,$={id:re,request:{params:Y},timestamp:Date.now(),serverName:t,resolve:z,reject:te};h(B=>[...B,$]),typeof window<"u"&&Ar(async()=>{const{toast:B}=await Promise.resolve().then(()=>xme);return{toast:B}},void 0).then(({toast:B})=>{const U=B(p.jsx(lfe,{requestId:re,serverName:t,onViewDetails:()=>{const L=new globalThis.CustomEvent("navigate-to-sampling",{detail:{requestId:re}});window.dispatchEvent(L),B.dismiss(U)},onApprove:L=>{h(P=>{const G=P.find(Z=>Z.id===re);return G?(G.resolve(L),B.success("Sampling request approved"),P.filter(Z=>Z.id!==re)):P}),B.dismiss(U)},onDeny:()=>{h(L=>{const P=L.find(G=>G.id===re);return P?(P.reject(new Error("User denied sampling request from toast")),B.error("Sampling request denied"),L.filter(G=>G.id!==re)):L}),B.dismiss(U)}}),{duration:5e3})})}),[t]),W=ET({url:u,callbackUrl:c,customHeaders:Object.keys(d).length>0?d:void 0,transportType:a||"http",preventAutoAuth:!0,useRedirectFlow:!0,enabled:S,wrapTransport:E,onNotification:Y=>{F({id:globalThis.crypto.randomUUID(),method:Y.method,params:Y.params,timestamp:Date.now(),read:!1})},samplingCallback:Q}),ie=x.useRef(i),V=x.useRef(null);return x.useEffect(()=>{ie.current=i},[i]),x.useEffect(()=>{if(typeof queueMicrotask<"u")queueMicrotask(()=>{W.state==="ready"&&W.serverInfo&&console.log("[McpContext] Server info available:",W.serverInfo);const Y=R.filter(re=>!re.read).length,z={id:r,url:e,name:W.serverInfo?.name||t,state:W.state,tools:W.tools,resources:W.resources,prompts:W.prompts,error:W.error??null,authUrl:W.authUrl??null,customHeaders:d,transportType:a,proxyConfig:n,serverInfo:W.serverInfo,capabilities:W.capabilities,notifications:R,unreadNotificationCount:Y,markNotificationRead:I,markAllNotificationsRead:O,clearNotifications:j,pendingSamplingRequests:v,approveSampling:H,rejectSampling:K,callTool:W.callTool,readResource:W.readResource,listPrompts:W.listPrompts,getPrompt:W.getPrompt,authenticate:W.authenticate,retry:W.retry,clearStorage:W.clearStorage,disconnect:W.disconnect,client:W.client},te=V.current;(!te||te.state!==z.state||te.error!==z.error||te.authUrl!==z.authUrl||te.name!==z.name||te.tools.length!==z.tools.length||te.resources.length!==z.resources.length||te.prompts.length!==z.prompts.length||te.serverInfo!==z.serverInfo||te.capabilities!==z.capabilities||te.notifications.length!==z.notifications.length||te.unreadNotificationCount!==z.unreadNotificationCount||te.pendingSamplingRequests.length!==z.pendingSamplingRequests.length||!te.client)&&(V.current=z,ie.current(z))});else{const Y=R.filter(re=>!re.read).length,z={id:r,url:e,name:W.serverInfo?.name||t,state:W.state,tools:W.tools,resources:W.resources,prompts:W.prompts,error:W.error??null,authUrl:W.authUrl??null,customHeaders:d,transportType:a,proxyConfig:n,serverInfo:W.serverInfo,capabilities:W.capabilities,notifications:R,unreadNotificationCount:Y,markNotificationRead:I,markAllNotificationsRead:O,clearNotifications:j,pendingSamplingRequests:v,approveSampling:H,rejectSampling:K,callTool:W.callTool,readResource:W.readResource,listPrompts:W.listPrompts,getPrompt:W.getPrompt,authenticate:W.authenticate,retry:W.retry,clearStorage:W.clearStorage,disconnect:W.disconnect,client:W.client},te=V.current;(!te||te.state!==z.state||te.error!==z.error||te.authUrl!==z.authUrl||te.name!==z.name||te.tools.length!==z.tools.length||te.resources.length!==z.resources.length||te.prompts.length!==z.prompts.length||te.serverInfo!==z.serverInfo||te.capabilities!==z.capabilities||te.notifications.length!==z.notifications.length||te.unreadNotificationCount!==z.unreadNotificationCount||te.pendingSamplingRequests.length!==z.pendingSamplingRequests.length||!te.client)&&(V.current=z,ie.current(z))}},[e,t,a,n,d,r,W.state,W.tools,W.resources,W.prompts,W.error,W.authUrl,W.serverInfo,W.capabilities,W.client,R,I,O,j,W.callTool,W.readResource,W.listPrompts,W.getPrompt,W.authenticate,W.retry,W.clearStorage,m,H,K]),null}function ufe({children:e}){const[t,n]=x.useState([]),[a,r]=x.useState(!1),[i,s]=x.useState(!0),[c,u]=x.useState([]);x.useEffect(()=>{try{const y=localStorage.getItem("mcp-inspector-connections");if(y){const E=JSON.parse(y);Array.isArray(E)&&(u(E),n(E.map(k=>({id:k.id||k.url,url:k.url,name:k.name||"MCP Server",state:"discovering",tools:[],resources:[],prompts:[],error:null,authUrl:null,customHeaders:k.proxyConfig?.customHeaders,transportType:k.transportType,proxyConfig:k.proxyConfig,notifications:[],unreadNotificationCount:0,markNotificationRead:()=>{},markAllNotificationsRead:()=>{},clearNotifications:()=>{},pendingSamplingRequests:[],approveSampling:Eg,rejectSampling:_g,callTool:async()=>{},readResource:async()=>{},listPrompts:async()=>{},getPrompt:async()=>{},authenticate:()=>{},retry:()=>{},clearStorage:()=>{},disconnect:()=>{},client:null}))))}const _=localStorage.getItem("mcp-inspector-auto-connect");_!==null&&s(_==="true")}catch(y){console.error("Failed to load connections from localStorage:",y)}finally{r(!0)}},[]),x.useEffect(()=>{a&&localStorage.setItem("mcp-inspector-connections",JSON.stringify(c))},[c,a]),x.useEffect(()=>{a&&localStorage.setItem("mcp-inspector-auto-connect",String(i))},[i,a]);const d=x.useCallback((y,_,E,k)=>{const C=c.find(I=>I.url===y),R=t.find(I=>I.url===y);if(C&&R){if(JSON.stringify(C.proxyConfig)!==JSON.stringify(E)&&E){u(O=>O.filter(j=>j.url!==y)),n(O=>O.filter(j=>j.url!==y)),setTimeout(()=>{const O={id:y,url:y,name:_||C.name||"MCP Server",proxyConfig:E,transportType:k||C.transportType};u(j=>[...j,O]),n(j=>[...j,{id:y,url:y,name:_||C.name||"MCP Server",state:"connecting",tools:[],resources:[],prompts:[],error:null,authUrl:null,customHeaders:E?.customHeaders,transportType:k||C.transportType,proxyConfig:E,notifications:[],unreadNotificationCount:0,markNotificationRead:()=>{},markAllNotificationsRead:()=>{},clearNotifications:()=>{},pendingSamplingRequests:[],approveSampling:Eg,rejectSampling:_g,callTool:async()=>{},readResource:async()=>{},listPrompts:async()=>{},getPrompt:async()=>{},authenticate:()=>{},retry:()=>{},clearStorage:()=>{},disconnect:()=>{},client:null}])},10);return}return}if(C&&!R){(E||k)&&u(I=>I.map(O=>O.url===y?{...O,proxyConfig:E||O.proxyConfig,transportType:k||O.transportType,name:_||O.name}:O)),n(I=>[...I,{id:C.id||y,url:y,name:_||C.name||"MCP Server",state:"connecting",tools:[],resources:[],prompts:[],error:null,authUrl:null,customHeaders:E?.customHeaders||C.proxyConfig?.customHeaders,transportType:k||C.transportType,proxyConfig:E||C.proxyConfig,notifications:[],unreadNotificationCount:0,markNotificationRead:()=>{},markAllNotificationsRead:()=>{},clearNotifications:()=>{},pendingSamplingRequests:[],approveSampling:Eg,rejectSampling:_g,callTool:async()=>{},readResource:async()=>{},listPrompts:async()=>{},getPrompt:async()=>{},authenticate:()=>{},retry:()=>{},clearStorage:()=>{},disconnect:()=>{},client:null}]);return}const A={id:y,url:y,name:_||"MCP Server",proxyConfig:E,transportType:k};u(I=>[...I,A]),n(I=>[...I,{id:y,url:y,name:_||"MCP Server",state:"connecting",tools:[],resources:[],prompts:[],error:null,authUrl:null,customHeaders:E?.customHeaders,transportType:k,proxyConfig:E,notifications:[],unreadNotificationCount:0,markNotificationRead:()=>{},markAllNotificationsRead:()=>{},clearNotifications:()=>{},pendingSamplingRequests:[],approveSampling:Eg,rejectSampling:_g,callTool:async()=>{},readResource:async()=>{},listPrompts:async()=>{},getPrompt:async()=>{},authenticate:()=>{},retry:()=>{},clearStorage:()=>{},disconnect:()=>{},client:null}])},[c,t]),m=x.useCallback(y=>{const _=t.find(k=>k.id===y);_&&(console.log(`[McpContext] Cleaning up connection: ${y}`),_.disconnect&&(console.log(`[McpContext] Disconnecting from server: ${y}`),_.disconnect()),_.clearStorage&&(console.log(`[McpContext] Clearing OAuth storage for connection: ${y}`),_.clearStorage())),u(k=>k.filter(C=>C.id!==y)),n(k=>k.filter(C=>C.id!==y));const E=localStorage.getItem("mcp-inspector-connections");if(E)try{const C=JSON.parse(E).filter(R=>(R.id||R.url)!==y);localStorage.setItem("mcp-inspector-connections",JSON.stringify(C))}catch(k){console.error("Failed to update localStorage on remove:",k)}br.getInstance().capture(new rfe({serverId:y}))},[t]),h=x.useCallback((y,_)=>{u(E=>E.map(k=>k.id===y||k.url===y?{...k,..._}:k)),n(E=>E.map(k=>k.id===y?{...k,..._}:k))},[]),g=x.useCallback(y=>{n(_=>{const E=_.findIndex(R=>R.id===y.id);if(E===-1)return _;const k=_[E];if(k.state===y.state&&k.tools===y.tools&&k.resources===y.resources&&k.prompts===y.prompts&&k.error===y.error&&k.serverInfo===y.serverInfo&&k.client===y.client&&k.notifications===y.notifications&&k.unreadNotificationCount===y.unreadNotificationCount&&k.pendingSamplingRequests.length===y.pendingSamplingRequests.length)return _;const C=[..._];return C[E]=y,C})},[]),v=x.useCallback(y=>{console.log("Connect requested for:",y)},[]),w=x.useCallback(y=>{console.log("Disconnect requested for:",y)},[]),S=x.useMemo(()=>({connections:t,addConnection:d,removeConnection:m,updateConnectionConfig:h,autoConnect:i,setAutoConnect:s,connectServer:v,disconnectServer:w,configLoaded:a}),[t,d,m,h,i,v,w,a]);return p.jsxs($9.Provider,{value:S,children:[e,a&&i&&c.map(y=>{const _=`${y.id||y.url}-${y.proxyConfig?.proxyAddress?"proxy":"direct"}`;return console.warn("[McpContext] Rendering McpConnectionWrapper with key:",_,"proxyConfig:",y.proxyConfig),p.jsx(cfe,{url:y.url,name:y.name,proxyConfig:y.proxyConfig,transportType:y.transportType,connectionId:y.id||y.url,onUpdate:g,onRemove:()=>m(y.id||y.url)},_)})]})}const dfe=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),ffe=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,a)=>a?a.toUpperCase():n.toLowerCase()),aU=e=>{const t=ffe(e);return t.charAt(0).toUpperCase()+t.slice(1)},j9=(...e)=>e.filter((t,n,a)=>!!t&&t.trim()!==""&&a.indexOf(t)===n).join(" ").trim(),pfe=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};var mfe={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const hfe=x.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:a,className:r="",children:i,iconNode:s,...c},u)=>x.createElement("svg",{ref:u,...mfe,width:t,height:t,stroke:e,strokeWidth:a?Number(n)*24/Number(t):n,className:j9("lucide",r),...!i&&!pfe(c)&&{"aria-hidden":"true"},...c},[...s.map(([d,m])=>x.createElement(d,m)),...Array.isArray(i)?i:[i]]));const Je=(e,t)=>{const n=x.forwardRef(({className:a,...r},i)=>x.createElement(hfe,{ref:i,iconNode:t,className:j9(`lucide-${dfe(aU(e))}`,`lucide-${e}`,a),...r}));return n.displayName=aU(e),n};const gfe=[["path",{d:"M12 17V3",key:"1cwfxf"}],["path",{d:"m6 11 6 6 6-6",key:"12ii2o"}],["path",{d:"M19 21H5",key:"150jfl"}]],bfe=Je("arrow-down-to-line",gfe);const vfe=[["path",{d:"m18 9-6-6-6 6",key:"kcunyi"}],["path",{d:"M12 3v14",key:"7cf3v8"}],["path",{d:"M5 21h14",key:"11awu3"}]],yfe=Je("arrow-up-from-line",vfe);const wfe=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Sfe=Je("arrow-up",wfe);const xfe=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}]],JT=Je("bell",xfe);const Efe=[["path",{d:"m11 10 3 3",key:"fzmg1i"}],["path",{d:"M6.5 21A3.5 3.5 0 1 0 3 17.5a2.62 2.62 0 0 1-.708 1.792A1 1 0 0 0 3 21z",key:"p4q2r7"}],["path",{d:"M9.969 17.031 21.378 5.624a1 1 0 0 0-3.002-3.002L6.967 14.031",key:"wy6l02"}]],M9=Je("brush",Efe);const _fe=[["path",{d:"M12 20v-9",key:"1qisl0"}],["path",{d:"M14 7a4 4 0 0 1 4 4v3a6 6 0 0 1-12 0v-3a4 4 0 0 1 4-4z",key:"uouzyp"}],["path",{d:"M14.12 3.88 16 2",key:"qol33r"}],["path",{d:"M21 21a4 4 0 0 0-3.81-4",key:"1b0z45"}],["path",{d:"M21 5a4 4 0 0 1-3.55 3.97",key:"5cxbf6"}],["path",{d:"M22 13h-4",key:"1jl80f"}],["path",{d:"M3 21a4 4 0 0 1 3.81-4",key:"1fjd4g"}],["path",{d:"M3 5a4 4 0 0 0 3.55 3.97",key:"1d7oge"}],["path",{d:"M6 13H2",key:"82j7cp"}],["path",{d:"m8 2 1.88 1.88",key:"fmnt4t"}],["path",{d:"M9 7.13V6a3 3 0 1 1 6 0v1.13",key:"1vgav8"}]],kfe=Je("bug",_fe);const Tfe=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],La=Je("check",Tfe);const Nfe=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Vl=Je("chevron-down",Nfe);const Rfe=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Cfe=Je("chevron-right",Rfe);const Afe=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],QT=Je("chevron-left",Afe);const Ife=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],Ofe=Je("chevron-up",Ife);const Dfe=[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]],Lfe=Je("chevrons-up-down",Dfe);const $fe=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}]],iU=Je("circle-minus",$fe);const jfe=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],ju=Je("clock",jfe);const Mfe=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],P9=Je("code",Mfe);const Pfe=[["path",{d:"M11 10.27 7 3.34",key:"16pf9h"}],["path",{d:"m11 13.73-4 6.93",key:"794ttg"}],["path",{d:"M12 22v-2",key:"1osdcq"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M14 12h8",key:"4f43i9"}],["path",{d:"m17 20.66-1-1.73",key:"eq3orb"}],["path",{d:"m17 3.34-1 1.73",key:"2wel8s"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"m20.66 17-1.73-1",key:"sg0v6f"}],["path",{d:"m20.66 7-1.73 1",key:"1ow05n"}],["path",{d:"m3.34 17 1.73-1",key:"nuk764"}],["path",{d:"m3.34 7 1.73 1",key:"1ulond"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["circle",{cx:"12",cy:"12",r:"8",key:"46899m"}]],Ufe=Je("cog",Pfe);const zfe=[["path",{d:"M15 6v12a3 3 0 1 0 3-3H6a3 3 0 1 0 3 3V6a3 3 0 1 0-3 3h12a3 3 0 1 0-3-3",key:"11bfej"}]],Ffe=Je("command",zfe);const Bfe=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],Xr=Je("copy",Bfe);const Hfe=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]],ty=Je("database",Hfe);const Vfe=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],ny=Je("download",Vfe);const Gfe=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]],Wfe=Je("ellipsis-vertical",Gfe);const Kfe=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],oU=Je("external-link",Kfe);const Zfe=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],U9=Je("eye-off",Zfe);const Yfe=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],aE=Je("eye",Yfe);const Xfe=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}]],qfe=Je("file-code",Xfe);const Jfe=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["circle",{cx:"10",cy:"12",r:"2",key:"737tya"}],["path",{d:"m20 17-1.296-1.296a2.41 2.41 0 0 0-3.408 0L9 22",key:"wt3hpn"}]],Qfe=Je("file-image",Jfe);const epe=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],eN=Je("file-text",epe);const tpe=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}]],npe=Je("file",tpe);const rpe=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],ape=Je("folder-open",rpe);const ipe=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],ope=Je("globe",ipe);const spe=[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]],lpe=Je("grip-vertical",spe);const cpe=[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]],z9=Je("hash",cpe);const upe=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]],$b=Je("history",upe);const dpe=[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]],F9=Je("key",dpe);const fpe=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],As=Je("loader-circle",fpe);const ppe=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]],B9=Je("maximize-2",ppe);const mpe=[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]],tN=Je("maximize",mpe);const hpe=[["path",{d:"M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719",key:"1sd12s"}]],gpe=Je("message-circle",hpe);const bpe=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]],ip=Je("message-square",bpe);const vpe=[["path",{d:"M8 3v3a2 2 0 0 1-2 2H3",key:"hohbtr"}],["path",{d:"M21 8h-3a2 2 0 0 1-2-2V3",key:"5jw1f3"}],["path",{d:"M3 16h3a2 2 0 0 1 2 2v3",key:"198tvr"}],["path",{d:"M16 21v-3a2 2 0 0 1 2-2h3",key:"ph8mxp"}]],ype=Je("minimize",vpe);const wpe=[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]],sU=Je("monitor",wpe);const Spe=[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]],xpe=Je("moon",Spe);const Epe=[["path",{d:"M2 10h6V4",key:"zwrco"}],["path",{d:"m2 4 6 6",key:"ug085t"}],["path",{d:"M21 10V7a2 2 0 0 0-2-2h-7",key:"git5jr"}],["path",{d:"M3 14v2a2 2 0 0 0 2 2h3",key:"1f7fh3"}],["rect",{x:"12",y:"14",width:"10",height:"7",rx:"1",key:"1wjs3o"}]],_pe=Je("picture-in-picture",Epe);const kpe=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],H9=Je("play",kpe);const Tpe=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],V9=Je("plus",Tpe);const Npe=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],lU=Je("rotate-ccw",Npe);const Rpe=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]],nN=Je("save",Rpe);const Cpe=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],qp=Je("search",Cpe);const Ape=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],Ipe=Je("send",Ape);const Ope=[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]],Dpe=Je("server",Ope);const Lpe=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],uu=Je("settings",Lpe);const $pe=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]],jpe=Je("shield",$pe);const Mpe=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],Ppe=Je("sparkles",Mpe);const Upe=[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]],zpe=Je("square-pen",Upe);const Fpe=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 4h.01",key:"1ujb9j"}],["path",{d:"M20 12h.01",key:"1ykeid"}],["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M4 12h.01",key:"158zrr"}],["path",{d:"M17.657 6.343h.01",key:"31pqzk"}],["path",{d:"M17.657 17.657h.01",key:"jehnf4"}],["path",{d:"M6.343 17.657h.01",key:"gdk6ow"}],["path",{d:"M6.343 6.343h.01",key:"1uurf0"}]],Bpe=Je("sun-dim",Fpe);const Hpe=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],CS=Je("terminal",Hpe);const Vpe=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],Is=Je("trash-2",Vpe);const Gpe=[["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],Wpe=Je("trash",Gpe);const Kpe=[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]],Dl=Je("wrench",Kpe);const Zpe=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Gl=Je("x",Zpe);const Ype=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],op=Je("zap",Ype);function Xpe(e){if(typeof document>"u")return;let t=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css",t.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}const qpe=e=>{switch(e){case"success":return eme;case"info":return nme;case"warning":return tme;case"error":return rme;default:return null}},Jpe=Array(12).fill(0),Qpe=({visible:e,className:t})=>ue.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},ue.createElement("div",{className:"sonner-spinner"},Jpe.map((n,a)=>ue.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${a}`})))),eme=ue.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},ue.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),tme=ue.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},ue.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),nme=ue.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},ue.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),rme=ue.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},ue.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),ame=ue.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},ue.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),ue.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),ime=()=>{const[e,t]=ue.useState(document.hidden);return ue.useEffect(()=>{const n=()=>{t(document.hidden)};return document.addEventListener("visibilitychange",n),()=>window.removeEventListener("visibilitychange",n)},[]),e};let iE=1;class ome{constructor(){this.subscribe=t=>(this.subscribers.push(t),()=>{const n=this.subscribers.indexOf(t);this.subscribers.splice(n,1)}),this.publish=t=>{this.subscribers.forEach(n=>n(t))},this.addToast=t=>{this.publish(t),this.toasts=[...this.toasts,t]},this.create=t=>{var n;const{message:a,...r}=t,i=typeof t?.id=="number"||((n=t.id)==null?void 0:n.length)>0?t.id:iE++,s=this.toasts.find(u=>u.id===i),c=t.dismissible===void 0?!0:t.dismissible;return this.dismissedToasts.has(i)&&this.dismissedToasts.delete(i),s?this.toasts=this.toasts.map(u=>u.id===i?(this.publish({...u,...t,id:i,title:a}),{...u,...t,id:i,dismissible:c,title:a}):u):this.addToast({title:a,...r,dismissible:c,id:i}),i},this.dismiss=t=>(t?(this.dismissedToasts.add(t),requestAnimationFrame(()=>this.subscribers.forEach(n=>n({id:t,dismiss:!0})))):this.toasts.forEach(n=>{this.subscribers.forEach(a=>a({id:n.id,dismiss:!0}))}),t),this.message=(t,n)=>this.create({...n,message:t}),this.error=(t,n)=>this.create({...n,message:t,type:"error"}),this.success=(t,n)=>this.create({...n,type:"success",message:t}),this.info=(t,n)=>this.create({...n,type:"info",message:t}),this.warning=(t,n)=>this.create({...n,type:"warning",message:t}),this.loading=(t,n)=>this.create({...n,type:"loading",message:t}),this.promise=(t,n)=>{if(!n)return;let a;n.loading!==void 0&&(a=this.create({...n,promise:t,type:"loading",message:n.loading,description:typeof n.description!="function"?n.description:void 0}));const r=Promise.resolve(t instanceof Function?t():t);let i=a!==void 0,s;const c=r.then(async d=>{if(s=["resolve",d],ue.isValidElement(d))i=!1,this.create({id:a,type:"default",message:d});else if(lme(d)&&!d.ok){i=!1;const h=typeof n.error=="function"?await n.error(`HTTP error! status: ${d.status}`):n.error,g=typeof n.description=="function"?await n.description(`HTTP error! status: ${d.status}`):n.description,w=typeof h=="object"&&!ue.isValidElement(h)?h:{message:h};this.create({id:a,type:"error",description:g,...w})}else if(d instanceof Error){i=!1;const h=typeof n.error=="function"?await n.error(d):n.error,g=typeof n.description=="function"?await n.description(d):n.description,w=typeof h=="object"&&!ue.isValidElement(h)?h:{message:h};this.create({id:a,type:"error",description:g,...w})}else if(n.success!==void 0){i=!1;const h=typeof n.success=="function"?await n.success(d):n.success,g=typeof n.description=="function"?await n.description(d):n.description,w=typeof h=="object"&&!ue.isValidElement(h)?h:{message:h};this.create({id:a,type:"success",description:g,...w})}}).catch(async d=>{if(s=["reject",d],n.error!==void 0){i=!1;const m=typeof n.error=="function"?await n.error(d):n.error,h=typeof n.description=="function"?await n.description(d):n.description,v=typeof m=="object"&&!ue.isValidElement(m)?m:{message:m};this.create({id:a,type:"error",description:h,...v})}}).finally(()=>{i&&(this.dismiss(a),a=void 0),n.finally==null||n.finally.call(n)}),u=()=>new Promise((d,m)=>c.then(()=>s[0]==="reject"?m(s[1]):d(s[1])).catch(m));return typeof a!="string"&&typeof a!="number"?{unwrap:u}:Object.assign(a,{unwrap:u})},this.custom=(t,n)=>{const a=n?.id||iE++;return this.create({jsx:t(a),id:a,...n}),a},this.getActiveToasts=()=>this.toasts.filter(t=>!this.dismissedToasts.has(t.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}}const da=new ome,sme=(e,t)=>{const n=t?.id||iE++;return da.addToast({title:e,...t,id:n}),n},lme=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",cme=sme,ume=()=>da.toasts,dme=()=>da.getActiveToasts(),Qt=Object.assign(cme,{success:da.success,info:da.info,warning:da.warning,error:da.error,custom:da.custom,message:da.message,promise:da.promise,dismiss:da.dismiss,loading:da.loading},{getHistory:ume,getToasts:dme});Xpe("[data-sonner-toaster][dir=ltr],html[dir=ltr]{--toast-icon-margin-start:-3px;--toast-icon-margin-end:4px;--toast-svg-margin-start:-1px;--toast-svg-margin-end:0px;--toast-button-margin-start:auto;--toast-button-margin-end:0;--toast-close-button-start:0;--toast-close-button-end:unset;--toast-close-button-transform:translate(-35%, -35%)}[data-sonner-toaster][dir=rtl],html[dir=rtl]{--toast-icon-margin-start:4px;--toast-icon-margin-end:-3px;--toast-svg-margin-start:0px;--toast-svg-margin-end:-1px;--toast-button-margin-start:0;--toast-button-margin-end:auto;--toast-close-button-start:unset;--toast-close-button-end:0;--toast-close-button-transform:translate(35%, -35%)}[data-sonner-toaster]{position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1:hsl(0, 0%, 99%);--gray2:hsl(0, 0%, 97.3%);--gray3:hsl(0, 0%, 95.1%);--gray4:hsl(0, 0%, 93%);--gray5:hsl(0, 0%, 90.9%);--gray6:hsl(0, 0%, 88.7%);--gray7:hsl(0, 0%, 85.8%);--gray8:hsl(0, 0%, 78%);--gray9:hsl(0, 0%, 56.1%);--gray10:hsl(0, 0%, 52.3%);--gray11:hsl(0, 0%, 43.5%);--gray12:hsl(0, 0%, 9%);--border-radius:8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:0;z-index:999999999;transition:transform .4s ease}@media (hover:none) and (pointer:coarse){[data-sonner-toaster][data-lifted=true]{transform:none}}[data-sonner-toaster][data-x-position=right]{right:var(--offset-right)}[data-sonner-toaster][data-x-position=left]{left:var(--offset-left)}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translateX(-50%)}[data-sonner-toaster][data-y-position=top]{top:var(--offset-top)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--offset-bottom)}[data-sonner-toast]{--y:translateY(100%);--lift-amount:calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:0;overflow-wrap:anywhere}[data-sonner-toast][data-styled=true]{padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-y-position=top]{top:0;--y:translateY(-100%);--lift:1;--lift-amount:calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y:translateY(100%);--lift:-1;--lift-amount:calc(var(--lift) * var(--gap))}[data-sonner-toast][data-styled=true] [data-description]{font-weight:400;line-height:1.4;color:#3f3f3f}[data-rich-colors=true][data-sonner-toast][data-styled=true] [data-description]{color:inherit}[data-sonner-toaster][data-sonner-theme=dark] [data-description]{color:#e8e8e8}[data-sonner-toast][data-styled=true] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast][data-styled=true] [data-icon]{display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast][data-styled=true] [data-icon]>*{flex-shrink:0}[data-sonner-toast][data-styled=true] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast][data-styled=true] [data-content]{display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;font-weight:500;cursor:pointer;outline:0;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}[data-sonner-toast][data-styled=true] [data-button]:focus-visible{box-shadow:0 0 0 2px rgba(0,0,0,.4)}[data-sonner-toast][data-styled=true] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast][data-styled=true] [data-cancel]{color:var(--normal-text);background:rgba(0,0,0,.08)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-styled=true] [data-cancel]{background:rgba(255,255,255,.3)}[data-sonner-toast][data-styled=true] [data-close-button]{position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);background:var(--normal-bg);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast][data-styled=true] [data-close-button]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-styled=true] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast][data-styled=true]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]::before{content:'';position:absolute;left:-100%;right:-100%;height:100%;z-index:-1}[data-sonner-toast][data-y-position=top][data-swiping=true]::before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]::before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]::before{content:'';position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast][data-expanded=true]::after{content:'';position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y:translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale:var(--toasts-before) * 0.05 + 1;--y:translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-x-position=right]{right:0}[data-sonner-toast][data-x-position=left]{left:0}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y:translateY(calc(var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=false]{--y:translateY(40%);opacity:0;transition:transform .5s,opacity .2s}[data-sonner-toast][data-removed=true][data-front=false]::before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y,0)) translateX(var(--swipe-amount-x,0));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width:600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-sonner-theme=light]{--normal-bg:#fff;--normal-border:var(--gray4);--normal-text:var(--gray12);--success-bg:hsl(143, 85%, 96%);--success-border:hsl(145, 92%, 87%);--success-text:hsl(140, 100%, 27%);--info-bg:hsl(208, 100%, 97%);--info-border:hsl(221, 91%, 93%);--info-text:hsl(210, 92%, 45%);--warning-bg:hsl(49, 100%, 97%);--warning-border:hsl(49, 91%, 84%);--warning-text:hsl(31, 92%, 45%);--error-bg:hsl(359, 100%, 97%);--error-border:hsl(359, 100%, 94%);--error-text:hsl(360, 100%, 45%)}[data-sonner-toaster][data-sonner-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg:#000;--normal-border:hsl(0, 0%, 20%);--normal-text:var(--gray1)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg:#fff;--normal-border:var(--gray3);--normal-text:var(--gray12)}[data-sonner-toaster][data-sonner-theme=dark]{--normal-bg:#000;--normal-bg-hover:hsl(0, 0%, 12%);--normal-border:hsl(0, 0%, 20%);--normal-border-hover:hsl(0, 0%, 25%);--normal-text:var(--gray1);--success-bg:hsl(150, 100%, 6%);--success-border:hsl(147, 100%, 12%);--success-text:hsl(150, 86%, 65%);--info-bg:hsl(215, 100%, 6%);--info-border:hsl(223, 43%, 17%);--info-text:hsl(216, 87%, 65%);--warning-bg:hsl(64, 100%, 6%);--warning-border:hsl(60, 100%, 9%);--warning-text:hsl(46, 87%, 65%);--error-bg:hsl(358, 76%, 10%);--error-border:hsl(357, 89%, 16%);--error-text:hsl(358, 100%, 81%)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size:16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:first-child{animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}100%{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}100%{opacity:.15}}@media (prefers-reduced-motion){.sonner-loading-bar,[data-sonner-toast],[data-sonner-toast]>*{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}");function kg(e){return e.label!==void 0}const fme=3,pme="24px",mme="16px",cU=4e3,hme=356,gme=14,bme=45,vme=200;function Oi(...e){return e.filter(Boolean).join(" ")}function yme(e){const[t,n]=e.split("-"),a=[];return t&&a.push(t),n&&a.push(n),a}const wme=e=>{var t,n,a,r,i,s,c,u,d;const{invert:m,toast:h,unstyled:g,interacting:v,setHeights:w,visibleToasts:S,heights:y,index:_,toasts:E,expanded:k,removeToast:C,defaultRichColors:R,closeButton:A,style:I,cancelButtonStyle:O,actionButtonStyle:j,className:F="",descriptionClassName:H="",duration:K,position:Q,gap:W,expandByDefault:ie,classNames:V,icons:Y,closeButtonAriaLabel:z="Close toast"}=e,[te,re]=ue.useState(null),[$,B]=ue.useState(null),[U,L]=ue.useState(!1),[P,G]=ue.useState(!1),[Z,J]=ue.useState(!1),[se,le]=ue.useState(!1),[ee,ne]=ue.useState(!1),[ce,ae]=ue.useState(0),[ye,ke]=ue.useState(0),Be=ue.useRef(h.duration||K||cU),_e=ue.useRef(null),Se=ue.useRef(null),ze=_===0,pe=_+1<=S,Le=h.type,Fe=h.dismissible!==!1,xe=h.className||"",st=h.descriptionClassName||"",at=ue.useMemo(()=>y.findIndex(Ve=>Ve.toastId===h.id)||0,[y,h.id]),pt=ue.useMemo(()=>{var Ve;return(Ve=h.closeButton)!=null?Ve:A},[h.closeButton,A]),Pe=ue.useMemo(()=>h.duration||K||cU,[h.duration,K]),$e=ue.useRef(0),et=ue.useRef(0),an=ue.useRef(0),Qe=ue.useRef(null),[Ae,Ie]=Q.split("-"),Ye=ue.useMemo(()=>y.reduce((Ve,jt,En)=>En>=at?Ve:Ve+jt.height,0),[y,at]),tt=ime(),it=h.invert||m,gt=Le==="loading";et.current=ue.useMemo(()=>at*W+Ye,[at,Ye]),ue.useEffect(()=>{Be.current=Pe},[Pe]),ue.useEffect(()=>{L(!0)},[]),ue.useEffect(()=>{const Ve=Se.current;if(Ve){const jt=Ve.getBoundingClientRect().height;return ke(jt),w(En=>[{toastId:h.id,height:jt,position:h.position},...En]),()=>w(En=>En.filter(_n=>_n.toastId!==h.id))}},[w,h.id]),ue.useLayoutEffect(()=>{if(!U)return;const Ve=Se.current,jt=Ve.style.height;Ve.style.height="auto";const En=Ve.getBoundingClientRect().height;Ve.style.height=jt,ke(En),w(_n=>_n.find(un=>un.toastId===h.id)?_n.map(un=>un.toastId===h.id?{...un,height:En}:un):[{toastId:h.id,height:En,position:h.position},..._n])},[U,h.title,h.description,w,h.id,h.jsx,h.action,h.cancel]);const mt=ue.useCallback(()=>{G(!0),ae(et.current),w(Ve=>Ve.filter(jt=>jt.toastId!==h.id)),setTimeout(()=>{C(h)},vme)},[h,C,w,et]);ue.useEffect(()=>{if(h.promise&&Le==="loading"||h.duration===1/0||h.type==="loading")return;let Ve;return k||v||tt?(()=>{if(an.current<$e.current){const _n=new Date().getTime()-$e.current;Be.current=Be.current-_n}an.current=new Date().getTime()})():(()=>{Be.current!==1/0&&($e.current=new Date().getTime(),Ve=setTimeout(()=>{h.onAutoClose==null||h.onAutoClose.call(h,h),mt()},Be.current))})(),()=>clearTimeout(Ve)},[k,v,h,Le,tt,mt]),ue.useEffect(()=>{h.delete&&(mt(),h.onDismiss==null||h.onDismiss.call(h,h))},[mt,h.delete]);function Rn(){var Ve;if(Y?.loading){var jt;return ue.createElement("div",{className:Oi(V?.loader,h==null||(jt=h.classNames)==null?void 0:jt.loader,"sonner-loader"),"data-visible":Le==="loading"},Y.loading)}return ue.createElement(Qpe,{className:Oi(V?.loader,h==null||(Ve=h.classNames)==null?void 0:Ve.loader),visible:Le==="loading"})}const $t=h.icon||Y?.[Le]||qpe(Le);var on,Bt;return ue.createElement("li",{tabIndex:0,ref:Se,className:Oi(F,xe,V?.toast,h==null||(t=h.classNames)==null?void 0:t.toast,V?.default,V?.[Le],h==null||(n=h.classNames)==null?void 0:n[Le]),"data-sonner-toast":"","data-rich-colors":(on=h.richColors)!=null?on:R,"data-styled":!(h.jsx||h.unstyled||g),"data-mounted":U,"data-promise":!!h.promise,"data-swiped":ee,"data-removed":P,"data-visible":pe,"data-y-position":Ae,"data-x-position":Ie,"data-index":_,"data-front":ze,"data-swiping":Z,"data-dismissible":Fe,"data-type":Le,"data-invert":it,"data-swipe-out":se,"data-swipe-direction":$,"data-expanded":!!(k||ie&&U),"data-testid":h.testId,style:{"--index":_,"--toasts-before":_,"--z-index":E.length-_,"--offset":`${P?ce:et.current}px`,"--initial-height":ie?"auto":`${ye}px`,...I,...h.style},onDragEnd:()=>{J(!1),re(null),Qe.current=null},onPointerDown:Ve=>{Ve.button!==2&&(gt||!Fe||(_e.current=new Date,ae(et.current),Ve.target.setPointerCapture(Ve.pointerId),Ve.target.tagName!=="BUTTON"&&(J(!0),Qe.current={x:Ve.clientX,y:Ve.clientY})))},onPointerUp:()=>{var Ve,jt,En;if(se||!Fe)return;Qe.current=null;const _n=Number(((Ve=Se.current)==null?void 0:Ve.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),Hr=Number(((jt=Se.current)==null?void 0:jt.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),un=new Date().getTime()-((En=_e.current)==null?void 0:En.getTime()),Kn=te==="x"?_n:Hr,Zn=Math.abs(Kn)/un;if(Math.abs(Kn)>=bme||Zn>.11){ae(et.current),h.onDismiss==null||h.onDismiss.call(h,h),B(te==="x"?_n>0?"right":"left":Hr>0?"down":"up"),mt(),le(!0);return}else{var bn,dn;(bn=Se.current)==null||bn.style.setProperty("--swipe-amount-x","0px"),(dn=Se.current)==null||dn.style.setProperty("--swipe-amount-y","0px")}ne(!1),J(!1),re(null)},onPointerMove:Ve=>{var jt,En,_n;if(!Qe.current||!Fe||((jt=window.getSelection())==null?void 0:jt.toString().length)>0)return;const un=Ve.clientY-Qe.current.y,Kn=Ve.clientX-Qe.current.x;var Zn;const bn=(Zn=e.swipeDirections)!=null?Zn:yme(Q);!te&&(Math.abs(Kn)>1||Math.abs(un)>1)&&re(Math.abs(Kn)>Math.abs(un)?"x":"y");let dn={x:0,y:0};const na=Wt=>1/(1.5+Math.abs(Wt)/20);if(te==="y"){if(bn.includes("top")||bn.includes("bottom"))if(bn.includes("top")&&un<0||bn.includes("bottom")&&un>0)dn.y=un;else{const Wt=un*na(un);dn.y=Math.abs(Wt)<Math.abs(un)?Wt:un}}else if(te==="x"&&(bn.includes("left")||bn.includes("right")))if(bn.includes("left")&&Kn<0||bn.includes("right")&&Kn>0)dn.x=Kn;else{const Wt=Kn*na(Kn);dn.x=Math.abs(Wt)<Math.abs(Kn)?Wt:Kn}(Math.abs(dn.x)>0||Math.abs(dn.y)>0)&&ne(!0),(En=Se.current)==null||En.style.setProperty("--swipe-amount-x",`${dn.x}px`),(_n=Se.current)==null||_n.style.setProperty("--swipe-amount-y",`${dn.y}px`)}},pt&&!h.jsx&&Le!=="loading"?ue.createElement("button",{"aria-label":z,"data-disabled":gt,"data-close-button":!0,onClick:gt||!Fe?()=>{}:()=>{mt(),h.onDismiss==null||h.onDismiss.call(h,h)},className:Oi(V?.closeButton,h==null||(a=h.classNames)==null?void 0:a.closeButton)},(Bt=Y?.close)!=null?Bt:ame):null,(Le||h.icon||h.promise)&&h.icon!==null&&(Y?.[Le]!==null||h.icon)?ue.createElement("div",{"data-icon":"",className:Oi(V?.icon,h==null||(r=h.classNames)==null?void 0:r.icon)},h.promise||h.type==="loading"&&!h.icon?h.icon||Rn():null,h.type!=="loading"?$t:null):null,ue.createElement("div",{"data-content":"",className:Oi(V?.content,h==null||(i=h.classNames)==null?void 0:i.content)},ue.createElement("div",{"data-title":"",className:Oi(V?.title,h==null||(s=h.classNames)==null?void 0:s.title)},h.jsx?h.jsx:typeof h.title=="function"?h.title():h.title),h.description?ue.createElement("div",{"data-description":"",className:Oi(H,st,V?.description,h==null||(c=h.classNames)==null?void 0:c.description)},typeof h.description=="function"?h.description():h.description):null),ue.isValidElement(h.cancel)?h.cancel:h.cancel&&kg(h.cancel)?ue.createElement("button",{"data-button":!0,"data-cancel":!0,style:h.cancelButtonStyle||O,onClick:Ve=>{kg(h.cancel)&&Fe&&(h.cancel.onClick==null||h.cancel.onClick.call(h.cancel,Ve),mt())},className:Oi(V?.cancelButton,h==null||(u=h.classNames)==null?void 0:u.cancelButton)},h.cancel.label):null,ue.isValidElement(h.action)?h.action:h.action&&kg(h.action)?ue.createElement("button",{"data-button":!0,"data-action":!0,style:h.actionButtonStyle||j,onClick:Ve=>{kg(h.action)&&(h.action.onClick==null||h.action.onClick.call(h.action,Ve),!Ve.defaultPrevented&&mt())},className:Oi(V?.actionButton,h==null||(d=h.classNames)==null?void 0:d.actionButton)},h.action.label):null)};function uU(){if(typeof window>"u"||typeof document>"u")return"ltr";const e=document.documentElement.getAttribute("dir");return e==="auto"||!e?window.getComputedStyle(document.documentElement).direction:e}function Sme(e,t){const n={};return[e,t].forEach((a,r)=>{const i=r===1,s=i?"--mobile-offset":"--offset",c=i?mme:pme;function u(d){["top","right","bottom","left"].forEach(m=>{n[`${s}-${m}`]=typeof d=="number"?`${d}px`:d})}typeof a=="number"||typeof a=="string"?u(a):typeof a=="object"?["top","right","bottom","left"].forEach(d=>{a[d]===void 0?n[`${s}-${d}`]=c:n[`${s}-${d}`]=typeof a[d]=="number"?`${a[d]}px`:a[d]}):u(c)}),n}const G9=ue.forwardRef(function(t,n){const{id:a,invert:r,position:i="bottom-right",hotkey:s=["altKey","KeyT"],expand:c,closeButton:u,className:d,offset:m,mobileOffset:h,theme:g="light",richColors:v,duration:w,style:S,visibleToasts:y=fme,toastOptions:_,dir:E=uU(),gap:k=gme,icons:C,containerAriaLabel:R="Notifications"}=t,[A,I]=ue.useState([]),O=ue.useMemo(()=>a?A.filter(U=>U.toasterId===a):A.filter(U=>!U.toasterId),[A,a]),j=ue.useMemo(()=>Array.from(new Set([i].concat(O.filter(U=>U.position).map(U=>U.position)))),[O,i]),[F,H]=ue.useState([]),[K,Q]=ue.useState(!1),[W,ie]=ue.useState(!1),[V,Y]=ue.useState(g!=="system"?g:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),z=ue.useRef(null),te=s.join("+").replace(/Key/g,"").replace(/Digit/g,""),re=ue.useRef(null),$=ue.useRef(!1),B=ue.useCallback(U=>{I(L=>{var P;return(P=L.find(G=>G.id===U.id))!=null&&P.delete||da.dismiss(U.id),L.filter(({id:G})=>G!==U.id)})},[]);return ue.useEffect(()=>da.subscribe(U=>{if(U.dismiss){requestAnimationFrame(()=>{I(L=>L.map(P=>P.id===U.id?{...P,delete:!0}:P))});return}setTimeout(()=>{EH.flushSync(()=>{I(L=>{const P=L.findIndex(G=>G.id===U.id);return P!==-1?[...L.slice(0,P),{...L[P],...U},...L.slice(P+1)]:[U,...L]})})})}),[A]),ue.useEffect(()=>{if(g!=="system"){Y(g);return}if(g==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?Y("dark"):Y("light")),typeof window>"u")return;const U=window.matchMedia("(prefers-color-scheme: dark)");try{U.addEventListener("change",({matches:L})=>{Y(L?"dark":"light")})}catch{U.addListener(({matches:P})=>{try{Y(P?"dark":"light")}catch(G){console.error(G)}})}},[g]),ue.useEffect(()=>{A.length<=1&&Q(!1)},[A]),ue.useEffect(()=>{const U=L=>{var P;if(s.every(J=>L[J]||L.code===J)){var Z;Q(!0),(Z=z.current)==null||Z.focus()}L.code==="Escape"&&(document.activeElement===z.current||(P=z.current)!=null&&P.contains(document.activeElement))&&Q(!1)};return document.addEventListener("keydown",U),()=>document.removeEventListener("keydown",U)},[s]),ue.useEffect(()=>{if(z.current)return()=>{re.current&&(re.current.focus({preventScroll:!0}),re.current=null,$.current=!1)}},[z.current]),ue.createElement("section",{ref:n,"aria-label":`${R} ${te}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},j.map((U,L)=>{var P;const[G,Z]=U.split("-");return O.length?ue.createElement("ol",{key:U,dir:E==="auto"?uU():E,tabIndex:-1,ref:z,className:d,"data-sonner-toaster":!0,"data-sonner-theme":V,"data-y-position":G,"data-x-position":Z,style:{"--front-toast-height":`${((P=F[0])==null?void 0:P.height)||0}px`,"--width":`${hme}px`,"--gap":`${k}px`,...S,...Sme(m,h)},onBlur:J=>{$.current&&!J.currentTarget.contains(J.relatedTarget)&&($.current=!1,re.current&&(re.current.focus({preventScroll:!0}),re.current=null))},onFocus:J=>{J.target instanceof HTMLElement&&J.target.dataset.dismissible==="false"||$.current||($.current=!0,re.current=J.relatedTarget)},onMouseEnter:()=>Q(!0),onMouseMove:()=>Q(!0),onMouseLeave:()=>{W||Q(!1)},onDragEnd:()=>Q(!1),onPointerDown:J=>{J.target instanceof HTMLElement&&J.target.dataset.dismissible==="false"||ie(!0)},onPointerUp:()=>ie(!1)},O.filter(J=>!J.position&&L===0||J.position===U).map((J,se)=>{var le,ee;return ue.createElement(wme,{key:J.id,icons:C,index:se,toast:J,defaultRichColors:v,duration:(le=_?.duration)!=null?le:w,className:_?.className,descriptionClassName:_?.descriptionClassName,invert:r,visibleToasts:y,closeButton:(ee=_?.closeButton)!=null?ee:u,interacting:W,position:U,style:_?.style,unstyled:_?.unstyled,classNames:_?.classNames,cancelButtonStyle:_?.cancelButtonStyle,actionButtonStyle:_?.actionButtonStyle,closeButtonAriaLabel:_?.closeButtonAriaLabel,removeToast:B,toasts:O.filter(ne=>ne.position==J.position),heights:F.filter(ne=>ne.position==J.position),setHeights:H,expandByDefault:c,gap:k,expanded:K,swipeDirections:t.swipeDirections})})):null}))}),xme=Object.freeze(Object.defineProperty({__proto__:null,Toaster:G9,toast:Qt},Symbol.toStringTag,{value:"Module"}));var ry="Dialog",[W9]=_i(ry),[Eme,ki]=W9(ry),K9=e=>{const{__scopeDialog:t,children:n,open:a,defaultOpen:r,onOpenChange:i,modal:s=!0}=e,c=x.useRef(null),u=x.useRef(null),[d,m]=Co({prop:a,defaultProp:r??!1,onChange:i,caller:ry});return p.jsx(Eme,{scope:t,triggerRef:c,contentRef:u,contentId:Ir(),titleId:Ir(),descriptionId:Ir(),open:d,onOpenChange:m,onOpenToggle:x.useCallback(()=>m(h=>!h),[m]),modal:s,children:n})};K9.displayName=ry;var Z9="DialogTrigger",Y9=x.forwardRef((e,t)=>{const{__scopeDialog:n,...a}=e,r=ki(Z9,n),i=Gt(t,r.triggerRef);return p.jsx(St.button,{type:"button","aria-haspopup":"dialog","aria-expanded":r.open,"aria-controls":r.contentId,"data-state":iN(r.open),...a,ref:i,onClick:He(e.onClick,r.onOpenToggle)})});Y9.displayName=Z9;var rN="DialogPortal",[_me,X9]=W9(rN,{forceMount:void 0}),q9=e=>{const{__scopeDialog:t,forceMount:n,children:a,container:r}=e,i=ki(rN,t);return p.jsx(_me,{scope:t,forceMount:n,children:x.Children.map(a,s=>p.jsx(Ma,{present:n||i.open,children:p.jsx(rd,{asChild:!0,container:r,children:s})}))})};q9.displayName=rN;var jb="DialogOverlay",J9=x.forwardRef((e,t)=>{const n=X9(jb,e.__scopeDialog),{forceMount:a=n.forceMount,...r}=e,i=ki(jb,e.__scopeDialog);return i.modal?p.jsx(Ma,{present:a||i.open,children:p.jsx(Tme,{...r,ref:t})}):null});J9.displayName=jb;var kme=Il("DialogOverlay.RemoveScroll"),Tme=x.forwardRef((e,t)=>{const{__scopeDialog:n,...a}=e,r=ki(jb,n);return p.jsx(Wp,{as:kme,allowPinchZoom:!0,shards:[r.contentRef],children:p.jsx(St.div,{"data-state":iN(r.open),...a,ref:t,style:{pointerEvents:"auto",...a.style}})})}),Ll="DialogContent",Q9=x.forwardRef((e,t)=>{const n=X9(Ll,e.__scopeDialog),{forceMount:a=n.forceMount,...r}=e,i=ki(Ll,e.__scopeDialog);return p.jsx(Ma,{present:a||i.open,children:i.modal?p.jsx(Nme,{...r,ref:t}):p.jsx(Rme,{...r,ref:t})})});Q9.displayName=Ll;var Nme=x.forwardRef((e,t)=>{const n=ki(Ll,e.__scopeDialog),a=x.useRef(null),r=Gt(t,n.contentRef,a);return x.useEffect(()=>{const i=a.current;if(i)return Wv(i)},[]),p.jsx(eG,{...e,ref:r,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:He(e.onCloseAutoFocus,i=>{i.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:He(e.onPointerDownOutside,i=>{const s=i.detail.originalEvent,c=s.button===0&&s.ctrlKey===!0;(s.button===2||c)&&i.preventDefault()}),onFocusOutside:He(e.onFocusOutside,i=>i.preventDefault())})}),Rme=x.forwardRef((e,t)=>{const n=ki(Ll,e.__scopeDialog),a=x.useRef(!1),r=x.useRef(!1);return p.jsx(eG,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{e.onCloseAutoFocus?.(i),i.defaultPrevented||(a.current||n.triggerRef.current?.focus(),i.preventDefault()),a.current=!1,r.current=!1},onInteractOutside:i=>{e.onInteractOutside?.(i),i.defaultPrevented||(a.current=!0,i.detail.originalEvent.type==="pointerdown"&&(r.current=!0));const s=i.target;n.triggerRef.current?.contains(s)&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&r.current&&i.preventDefault()}})}),eG=x.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:a,onOpenAutoFocus:r,onCloseAutoFocus:i,...s}=e,c=ki(Ll,n),u=x.useRef(null),d=Gt(t,u);return Pv(),p.jsxs(p.Fragment,{children:[p.jsx(Bp,{asChild:!0,loop:!0,trapped:a,onMountAutoFocus:r,onUnmountAutoFocus:i,children:p.jsx(ed,{role:"dialog",id:c.contentId,"aria-describedby":c.descriptionId,"aria-labelledby":c.titleId,"data-state":iN(c.open),...s,ref:d,onDismiss:()=>c.onOpenChange(!1)})}),p.jsxs(p.Fragment,{children:[p.jsx(Cme,{titleId:c.titleId}),p.jsx(Ime,{contentRef:u,descriptionId:c.descriptionId})]})]})}),aN="DialogTitle",tG=x.forwardRef((e,t)=>{const{__scopeDialog:n,...a}=e,r=ki(aN,n);return p.jsx(St.h2,{id:r.titleId,...a,ref:t})});tG.displayName=aN;var nG="DialogDescription",rG=x.forwardRef((e,t)=>{const{__scopeDialog:n,...a}=e,r=ki(nG,n);return p.jsx(St.p,{id:r.descriptionId,...a,ref:t})});rG.displayName=nG;var aG="DialogClose",iG=x.forwardRef((e,t)=>{const{__scopeDialog:n,...a}=e,r=ki(aG,n);return p.jsx(St.button,{type:"button",...a,ref:t,onClick:He(e.onClick,()=>r.onOpenChange(!1))})});iG.displayName=aG;function iN(e){return e?"open":"closed"}var oG="DialogTitleWarning",[Q_e,sG]=gse(oG,{contentName:Ll,titleName:aN,docsSlug:"dialog"}),Cme=({titleId:e})=>{const t=sG(oG),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
103
103
 
104
104
  If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
105
105
 
@@ -1666,7 +1666,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
1666
1666
  <\/script>
1667
1667
  </body>
1668
1668
  </html>`,fK=1,v4=2,pK=3,y4=4,mK=5,w4=Symbol.for("quilt.threads.serialize"),xEe=Symbol.for("quilt.threads.transferable");class EEe extends AbortController{constructor(...t){super();const n=t.find(a=>a.aborted);if(n)this.abort(n.reason);else{const a=i=>this.abort(i.target.reason),r={signal:this.signal};for(const i of t)i.addEventListener("abort",a,r)}}}class S4 extends Error{constructor(){super("You attempted to call a function on a closed thread.")}}let _Ee="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";function hK(e=21){let t="",n=crypto.getRandomValues(new Uint8Array(e));for(let a=0;a<e;a++)t+=_Ee[63&n[a]];return t}var kf,Wc,Tf,rb,s_,gK;class kEe{constructor(){fi(this,s_),fi(this,kf,new Map),fi(this,Wc,new Map),fi(this,Tf,new Map),fi(this,rb,new WeakMap)}get(t){return $n(this,Wc).get(t)}release(t){const n=$n(this,Wc).get(t);return n&&($n(this,Wc).delete(t),$n(this,kf).delete(n)),!!n}serialize(t){let n=$n(this,kf).get(t);return n==null&&(n=hK(),$n(this,kf).set(t,n),$n(this,Wc).set(n,t)),n}deserialize(t,n){var a,r;let i=(a=$n(this,Tf).get(t))==null?void 0:a.deref();return i||(i=(...s)=>{if(!$n(this,Tf).has(t))throw new Error("You attempted to call a function that was already revoked.");return n.call((c,u,d)=>{n.messages.send([pK,c,t,u],d)},s)},(r=Tr(this,s_,gK).call(this,n))==null||r.register(i,t),$n(this,Tf).set(t,new WeakRef(i)),i)}}kf=new WeakMap,Wc=new WeakMap,Tf=new WeakMap,rb=new WeakMap,s_=new WeakSet,gK=function(e){let t=$n(this,rb).get(e);if(!(typeof FinalizationRegistry>"u"))return t||(t=new FinalizationRegistry(n=>{e.messages.send([mK,n])}),$n(this,rb).set(e,t)),t};function TEe(e){return e!=null&&(Symbol.asyncIterator in e||Symbol.iterator in e)&&typeof e.next=="function"}function x4(e){if(e==null||typeof e!="object")return!1;const t=Object.getPrototypeOf(e);return t==null||t===Object.prototype}const ax="_@f",E4="_@i";var Wf,Kf,Za,ab,bs;class NEe{constructor(t){fi(this,Za),fi(this,Wf),fi(this,Kf),i_(this,Wf,t?.serialize),i_(this,Kf,t?.deserialize)}serialize(t,n,a){return Tr(this,Za,ab).call(this,t,n,a)}deserialize(t,n){return Tr(this,Za,bs).call(this,t,n)}}Wf=new WeakMap,Kf=new WeakMap,Za=new WeakSet,ab=function(e,t,n,a=new Map,r=!1){if(e==null)return e;if(a.has(e))return a.get(e);if(a.set(e,void 0),typeof e=="object"){if($n(this,Wf)&&!r){const c=$n(this,Wf).call(this,e,u=>Tr(this,Za,ab).call(this,u,t,n,a,!0),t,n);if(c!==void 0)return a.set(e,c),c}if(e[xEe])return n?.push(e),a.set(e,e),e;const i=c=>Tr(this,Za,ab).call(this,c,t,n,a);if(typeof e[w4]=="function"){const c=e[w4]({serialize:i});return a.set(e,c),c}if(Array.isArray(e)){const c=e.map(u=>i(u));return a.set(e,c),c}if(e instanceof Map){const c=[...e.entries()].map(([d,m])=>[i(d),i(m)]),u=new Map(c);return a.set(e,u),u}if(e instanceof Set){const c=[...e].map(d=>i(d)),u=new Set(c);return a.set(e,u),u}const s=TEe(e);if(x4(e)||s){const c={};for(const u of Object.keys(e))c[u]=i(e[u]);return s&&(c.next??(c.next=i(e.next.bind(e))),c.return??(c.return=i(e.return.bind(e))),c.throw??(c.throw=i(e.throw.bind(e))),c[E4]=!0),a.set(e,c),c}}if(typeof e=="function"){const i=t.functions.serialize(e,t,n),s={[ax]:i};return a.set(e,s),s}return a.set(e,e),e},bs=function(e,t,n=!1){if(e==null)return e;if(typeof e=="object"){if($n(this,Kf)&&!n){const r=$n(this,Kf).call(this,e,i=>Tr(this,Za,bs).call(this,i,t,!0),t);if(r!==void 0)return r}if(e==null)return e;if(Array.isArray(e))return e.map(r=>Tr(this,Za,bs).call(this,r,t));if(e instanceof Map)return new Map([...e].map(([r,i])=>[Tr(this,Za,bs).call(this,r,t),Tr(this,Za,bs).call(this,i,t)]));if(e instanceof Set)return new Set([...e].map(r=>Tr(this,Za,bs).call(this,r,t)));if(ax in e)return t.functions.deserialize(e[ax],t);if(!x4(e))return e;const a={};for(const r of Object.keys(e))r===E4?a[Symbol.asyncIterator]=()=>a:a[r]=Tr(this,Za,bs).call(this,e[r],t);return a}return e};var Kc,xl,vs,l_,bK,c_,vK;class REe{constructor(t,{imports:n,exports:a,functions:r=new kEe,serialization:i=new NEe,signal:s}={}){fi(this,vs),fi(this,Kc),fi(this,xl,new Map);var c,u,d,m;this.messages=t,i_(this,Kc,s?new EEe(s):new AbortController),this.exports=a??{},this.imports=CEe(Tr(this,vs,bK).bind(this),n),this.functions=r,this.serialization=i,(u=(c=this.functions).start)==null||u.call(c,this),(m=(d=this.serialization).start)==null||m.call(d,this),this.signal.addEventListener("abort",()=>{for(const h of $n(this,xl).keys())Tr(this,vs,c_).call(this,h,void 0,new S4);$n(this,xl).clear()},{once:!0}),t.listen(async h=>{if(!(Array.isArray(h)&&typeof h[0]=="number"))return;const g=h;switch(g[0]){case fK:{const[,v,w,S]=g,y=this.exports[w]??(()=>{throw new Error(`No '${w}' method is exported from this thread`)});await Tr(this,vs,l_).call(this,y,S,(_,E,k)=>{this.messages.send([v4,v,_,E],k)});break}case pK:{const[,v,w,S]=g,y=this.functions.get(w,this)??AEe;await Tr(this,vs,l_).call(this,y,S,(_,E,k)=>{this.messages.send([y4,v,_,E],k)});break}case v4:case y4:{Tr(this,vs,c_).call(this,...g.slice(1));break}case mK:{const v=g[1];this.functions.release(v,this);break}}},{signal:this.signal})}get signal(){return $n(this,Kc).signal}get closed(){return $n(this,Kc).signal.aborted}close(){$n(this,Kc).abort()}call(t,n){if(this.closed)return Promise.reject(new S4);const a=[],r=this.serialization.serialize(n,this,a),i=hK(),s=Tr(this,vs,vK).call(this,i);return t(i,r,a),s}}Kc=new WeakMap,xl=new WeakMap,vs=new WeakSet,l_=async function(e,t,n){try{const a=this.functions.call?await this.functions.call(e,t,this):await e(...this.serialization.deserialize(t,this)),r=[],i=this.serialization.serialize(a,this,r);n(i,void 0,r)}catch(a){n(void 0,this.serialization.serialize(a,this))}},bK=function(e){return(...t)=>{try{if(typeof e!="string"&&typeof e!="number")throw new Error(`Can’t call a symbol method on a thread: ${e.toString()}`);return this.call((n,a,r)=>{this.messages.send([fK,n,e,a],r)},t)}catch(n){return Promise.reject(n)}}},c_=function(...e){const t=e[0],n=$n(this,xl).get(t);n&&(n(...e),$n(this,xl).delete(t))},vK=function(e){const t=new Promise((n,a)=>{$n(this,xl).set(e,(r,i,s)=>{s==null?n(this.serialization.deserialize(i,this)):a(this.serialization.deserialize(s,this))})});return Object.defineProperty(t,Symbol.asyncIterator,{async*value(){const n=await t;Object.defineProperty(n,Symbol.asyncIterator,{value:()=>n}),yield*n}}),t};function CEe(e,t){let n;if(t==null){if(typeof Proxy!="function")throw new Error("You must pass an array of callable methods in environments without Proxies.");const a=new Map;n=new Proxy({},{get(r,i){if(a.has(i))return a.get(i);const s=e(i);return a.set(i,s),s}})}else{n={};for(const a of t)Object.defineProperty(n,a,{value:e(a),writable:!1,configurable:!0,enumerable:!0})}return n}function AEe(){throw new Error("You attempted to call a function that is not stored. It may have already been released.")}const IEe="quilt.threads.ping",_4="quilt.threads.pong";function OEe(e,{targetOrigin:t="*"}={}){let n=!1;const a=function(i,s){e.postMessage(i,t,s)},r=new Promise(i=>{const s=new AbortController;globalThis.window.addEventListener("message",c=>{c.source===e&&c.data===_4&&(n=!0,s.abort(),i())},{signal:s.signal}),s.signal.addEventListener("abort",()=>i(),{once:!0}),a(IEe)});return{send(i,s){return n?a(i,s):r.then(()=>{if(n)return a(i,s)})},listen(i,{signal:s}){self.addEventListener("message",c=>{c.source===e&&c.data!==_4&&i(c.data)},{signal:s})}}}class DEe extends REe{constructor(t,{targetOrigin:n="*",...a}={}){super(OEe(t.contentWindow,{targetOrigin:n}),a),this.iframe=t}}const yK=ue.forwardRef(({content:e,children:t,...n},a)=>p.jsx("span",{ref:a,...n,children:e||t}));yK.displayName="UIText";const wK=ue.forwardRef(({label:e,onPress:t,onClick:n,children:a,...r},i)=>p.jsx("button",{ref:i,onClick:s=>{t&&t(),n&&n(s)},style:{padding:"8px 16px",backgroundColor:"#007bff",color:"white",border:"none",borderRadius:"4px",cursor:"pointer"},...r,children:e||a}));wK.displayName="UIButton";const SK=ue.forwardRef(({direction:e="vertical",spacing:t="8",align:n="stretch",justify:a="flex-start",children:r,...i},s)=>p.jsx("div",{ref:s,style:{display:"flex",flexDirection:e==="horizontal"?"row":"column",gap:`${t}px`,alignItems:n,justifyContent:a},...i,children:r}));SK.displayName="UIStack";const xK=ue.forwardRef(({src:e,alt:t,width:n,height:a,children:r,...i},s)=>p.jsx("img",{ref:s,src:e,alt:t,width:n,height:a,style:{maxWidth:"100%",height:"auto",borderRadius:"8px",boxShadow:"0 2px 8px rgba(0, 0, 0, 0.1)"},...i}));xK.displayName="UIImage";const SO={name:"basic",elements:[{tagName:"ui-text",component:yK,propMapping:{content:"content"},eventMapping:{}},{tagName:"ui-button",component:wK,propMapping:{label:"label"},eventMapping:{press:"onPress"}},{tagName:"ui-stack",component:SK,propMapping:{direction:"direction",spacing:"spacing",align:"align",justify:"justify"},eventMapping:{}},{tagName:"ui-image",component:xK,propMapping:{src:"src",alt:"alt",width:"width",height:"height"},eventMapping:{}}]},LEe=({receiver:e})=>{const t=x.useRef(null);return x.useEffect(()=>{if(t.current)return e.connect(t.current),()=>{e.disconnect()}},[e]),p.jsx("div",{ref:t,"data-testid":"standard-dom-renderer-container"})},$Ee=({resource:e,library:t,remoteElements:n=[],onUIAction:a})=>{const r=x.useRef(null),i=x.useRef(null),[s,c]=x.useState(null),u=x.useMemo(()=>(e.mimeType||"").includes("framework=react")?"react":"webcomponents",[e.mimeType]),d=`${t?.name}-${u}`,{receiver:m,components:h}=x.useMemo(()=>{switch(u){case"react":{const v=new fEe,w=t||SO,S=new Map;return w&&w.elements.forEach(y=>{const _=vEe(y.component);S.set(y.tagName,_)}),{receiver:v,components:S}}case"webcomponents":default:return{receiver:new pEe,components:null}}},[e,t,n]);x.useEffect(()=>{function v(w){var S;if(r.current&&w.source===r.current.contentWindow){const y=w.data;if(!y)return;(S=a?.(y))==null||S.catch(_=>{console.error("Error handling UI action result in RemoteDOMResourceRenderer:",_)})}}return window.addEventListener("message",v),()=>window.removeEventListener("message",v)},[a]),x.useEffect(()=>{const v=i.current;return i.current=null,()=>{v?.close()}},[d]);const g=()=>{const v=r.current;if(!v||i.current)return;const w=new DEe(v);i.current=w;const{code:S,error:y}=rEe(e);if(y){c(y);return}if(S&&m!=null&&m.connection){const _={code:S,remoteElements:n,useReactRenderer:u==="react",componentLibrary:t?.name};w.imports.render(_,m.connection).catch(E=>console.error("Error calling remote render:",E))}};return s?p.jsx("p",{className:"text-red-500",children:s}):p.jsxs(p.Fragment,{children:[p.jsx("iframe",{ref:r,srcDoc:SEe,sandbox:"allow-scripts",style:{display:"none"},title:"Remote DOM Sandbox",onLoad:g},d),u==="react"&&h?p.jsx(wEe,{receiver:m,components:h}):p.jsx(LEe,{receiver:m})]})};function jEe(e){var t;if(e.contentType)return e.contentType;if(e.mimeType==="text/html")return"rawHtml";if(e.mimeType==="text/uri-list")return"externalUrl";if((t=e.mimeType)!=null&&t.startsWith("application/vnd.mcp-ui.remote-dom"))return"remoteDom"}const xO=e=>{const{resource:t,onUIAction:n,supportedContentTypes:a,htmlProps:r,remoteDomProps:i}=e,s=jEe(t);if(a&&s&&!a.includes(s))return p.jsxs("p",{className:"text-red-500",children:["Unsupported content type: ",s,"."]});switch(s){case"rawHtml":case"externalUrl":return p.jsx(oK,{resource:t,onUIAction:n,...r});case"remoteDom":return p.jsx($Ee,{resource:t,onUIAction:n,library:i?.library||SO,...i});default:return p.jsx("p",{className:"text-red-500",children:"Unsupported resource type."})}};xO.displayName="UIResourceRenderer";const MEe={tagName:"ui-button",remoteAttributes:["label"],remoteEvents:["click","press"]},PEe={tagName:"ui-text",remoteAttributes:["content"]},UEe={tagName:"ui-stack",remoteAttributes:["direction","spacing","align","justify"]},zEe={tagName:"ui-image",remoteAttributes:["src","alt","width","height"]},FEe=x.memo(({resource:e})=>{const t=async n=>(n.type==="tool"||n.type==="prompt"||(n.type==="link"?n.payload.url&&window.open(n.payload.url,"_blank"):n.type==="intent"||n.type),{status:"Action received"});return e.uri?.startsWith("ui://")?p.jsx("div",{className:"my-4 p-0 border h-[350px] rounded-2xl border-zinc-200 overflow-hidden bg-card",children:p.jsx(xO,{resource:e,onUIAction:t,htmlProps:{style:{maxWidth:"100%",height:"100%",overflow:"auto"},autoResizeIframe:!0,sandboxPermissions:"allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox"}})}):null});function k4({toolName:e,toolArgs:t,result:n,serverId:a,readResource:r}){const[i,s]=x.useState(null),c=x.useMemo(()=>{if(typeof n=="string")try{return JSON.parse(n)}catch(h){return console.error("[ToolResultRenderer] Failed to parse result:",h),n}return n},[n]),u=x.useMemo(()=>!!(c?.content&&Array.isArray(c.content)&&c.content.some(h=>h.type==="resource"&&h.resource?.uri?.startsWith("ui://")&&h.resource?.mimeType==="text/html+skybridge")),[c]),d=x.useMemo(()=>u&&c.content.find(g=>g.type==="resource"&&g.resource?.uri?.startsWith("ui://")&&g.resource?.mimeType==="text/html+skybridge")?.resource||null,[u,c]);if(x.useEffect(()=>{(()=>{d&&s(d)})()},[d]),u&&i&&a&&r)return p.jsx(gO,{componentUrl:i.uri,toolName:e,toolArgs:t,toolResult:c,serverId:a,readResource:r,noWrapper:!0,className:"my-4",showConsole:!1});if(u&&!i)return p.jsx("div",{className:"my-4 p-4 bg-blue-50/30 dark:bg-blue-950/20 border border-blue-200/50 dark:border-blue-800/50 rounded-lg",children:p.jsx("p",{className:"text-sm text-blue-600 dark:text-blue-400",children:"Loading component..."})});const m=[];if(c?.content&&Array.isArray(c.content))for(const h of c.content)h.type==="resource"&&h.resource?.uri?.startsWith("ui://")&&h.resource?.mimeType!=="text/html+skybridge"&&m.push(h.resource);return m.length>0?p.jsx(p.Fragment,{children:m.map(h=>p.jsx(FEe,{resource:h},`${e}-mcp-ui-${h.uri}`))}):null}function BEe({content:e,timestamp:t}){return!e||e.length===0?null:p.jsx("div",{className:"flex items-start gap-3 justify-end group/user-message",children:p.jsxs("div",{className:"flex-1 min-w-0 flex flex-col items-end",children:[p.jsx("div",{className:"bg-zinc-200 dark:bg-zinc-800 text-primary rounded-3xl px-4 py-2 max-w-[80%] break-words",children:p.jsx("p",{className:"text-base leading-7 font-sans text-start break-words",children:e})}),t&&p.jsx("span",{className:"text-xs text-muted-foreground mt-1",children:new Date(t).toLocaleTimeString()})]})})}const HEe=x.memo(({messages:e,isLoading:t,serverId:n,readResource:a})=>{const r=x.useRef(null);x.useEffect(()=>{e.length>0&&r.current&&r.current.scrollIntoView({behavior:t?"auto":"smooth",block:"start"})},[e.length,t]);const i=t&&(()=>{if(e.length===0)return!0;const c=e[e.length-1];if(c.role==="user")return!0;if(c.role==="assistant"){const u=typeof c.content=="string"?c.content:Array.isArray(c.content)?c.content.map(m=>typeof m=="string"?m:m.text||JSON.stringify(m)).join(""):JSON.stringify(c.content);return!(u&&u.trim().length>0)}return!1})(),s=c=>{if(!t)return!1;const u=e[e.length-1];return c.id===u.id&&u.role==="assistant"};return p.jsxs("div",{className:"space-y-6 max-w-3xl mx-auto px-2",children:[e.map(c=>{const u=typeof c.content=="string"?c.content:Array.isArray(c.content)?c.content.map(d=>typeof d=="string"?d:d.text||JSON.stringify(d)).join(""):JSON.stringify(c.content);return c.role==="user"?p.jsx(BEe,{content:u,timestamp:c.timestamp},c.id):c.role==="assistant"?p.jsx("div",{className:"space-y-4",children:c.parts&&c.parts.length>0?c.parts.map((d,m)=>{const h=d.type==="text"?`${c.id}-text-${m}-${d.text?.slice(0,20)}`:`${c.id}-tool-${d.toolInvocation?.toolName}-${m}`;return d.type==="text"?p.jsx(l4,{content:d.text||"",timestamp:m===c.parts.length-1?c.timestamp:void 0,_isStreaming:s(c)},h):d.type==="tool-invocation"&&d.toolInvocation?p.jsxs("div",{children:[p.jsx(c4,{toolName:d.toolInvocation.toolName,args:d.toolInvocation.args,result:d.toolInvocation.result,state:d.toolInvocation.result?"result":"call"}),d.toolInvocation.result&&p.jsx(k4,{toolName:d.toolInvocation.toolName,toolArgs:d.toolInvocation.args,result:d.toolInvocation.result,serverId:n,readResource:a})]},h):null}):p.jsxs(p.Fragment,{children:[p.jsx(l4,{content:u,timestamp:c.timestamp,_isStreaming:s(c)}),c.toolCalls&&c.toolCalls.length>0&&p.jsx("div",{className:"space-y-2",children:c.toolCalls.map(d=>{const m=`${c.id}-${d.toolName}-${JSON.stringify(d.args).slice(0,50)}`;return p.jsxs("div",{children:[p.jsx(c4,{toolName:d.toolName,args:d.args,result:d.result,state:d.result?"result":"call"}),d.result&&p.jsx(k4,{toolName:d.toolName,toolArgs:d.args,result:d.result,serverId:n,readResource:a})]},m)})})]})},c.id):null}),i&&p.jsx("div",{className:"flex items-start gap-3",children:p.jsx("div",{className:"flex-1",children:p.jsx("div",{className:"rounded-lg p-4 max-w-fit",children:p.jsx("div",{className:"flex items-center gap-2",children:p.jsx("span",{className:"text-sm",children:p.jsx(s0e,{duration:2,spread:1,children:"Thinking..."})})})})})}),p.jsx("div",{ref:r})]})});function EK(e){let t=0;for(let n=0;n<e.length;n++){const a=e.charCodeAt(n);t=(t<<5)-t+a,t=t&t}return Math.abs(t).toString(16)}function VEe({mcpServerUrl:e,llmConfig:t,authConfig:n,isConnected:a}){const[r,i]=x.useState([]),[s,c]=x.useState(!1),u=x.useCallback(async m=>{if(!m.trim()||!t||!a)return;const h={id:`user-${Date.now()}`,role:"user",content:m.trim(),timestamp:Date.now()};i(g=>[...g,h]),c(!0);try{let g=n;if(n?.type==="oauth")try{const C="mcp:auth",R=EK(e),A=`${C}_${R}_tokens`,I=localStorage.getItem(A);if(I){const O=JSON.parse(I);g={...n,oauthTokens:O}}else console.warn("No OAuth tokens found in localStorage for key:",A)}catch(C){console.warn("Failed to retrieve OAuth tokens:",C)}const v=await fetch("/inspector/api/chat/stream",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mcpServerUrl:e,llmConfig:t,authConfig:g,messages:[...r,h].map(C=>({role:C.role,content:C.content}))})});if(!v.ok)throw new Error(`HTTP error! status: ${v.status}`);const w=`assistant-${Date.now()}`;let S="";const y=[];i(C=>[...C,{id:w,role:"assistant",content:"",timestamp:Date.now(),parts:[]}]);const _=v.body?.getReader(),E=new TextDecoder;if(!_)throw new Error("No response body");let k="";for(;;){const{done:C,value:R}=await _.read();if(C)break;k+=E.decode(R,{stream:!0});const A=k.split(`
1669
- `);k=A.pop()||"";for(const I of A)if(I.trim()&&I.startsWith("data: "))try{const O=JSON.parse(I.slice(6));if(console.log("[Client received event]",O.type,O.toolName||O.content?.slice?.(0,30)),O.type==="message")console.log("[Message started]",O.id);else if(O.type==="text"){S+=O.content;const j=y[y.length-1];j&&j.type==="text"?j.text=S:y.push({type:"text",text:S}),console.log("[Parts after text]",y.length,"parts, text length:",S.length),i(F=>F.map(H=>H.id===w?{...H,parts:[...y]}:H))}else if(O.type==="tool-call")S&&(S=""),y.push({type:"tool-invocation",toolInvocation:{toolName:O.toolName,args:O.args,state:"pending"}}),console.log("[Parts after tool-call]",y.length,"parts, tool:",O.toolName),i(j=>j.map(F=>F.id===w?{...F,parts:[...y]}:F));else if(O.type==="tool-result"){const j=y.find(F=>F.type==="tool-invocation"&&F.toolInvocation?.toolName===O.toolName&&!F.toolInvocation?.result);j&&j.toolInvocation?(j.toolInvocation.result=O.result,j.toolInvocation.state="result",console.log("[Parts after tool-result]",y.length,"parts, updated:",O.toolName),i(F=>F.map(H=>H.id===w?{...H,parts:[...y]}:H))):console.warn("[tool-result] Could not find matching tool part for",O.toolName)}else if(O.type==="done")console.log("[Done] Final parts:",y.length),i(j=>j.map(F=>F.id===w?{...F,parts:[...y],content:""}:F));else if(O.type==="error")throw new Error(O.message||"Streaming error")}catch(O){console.error("Failed to parse streaming event:",O,I)}}}catch(g){let v="Unknown error occurred";if(g instanceof Error){v=g.message;const S=g;S.status&&(v=`HTTP ${S.status}: ${v}`),(S.code===401||v.includes("401")||v.includes("Unauthorized"))&&(v="Authentication failed (401). Check your Authorization header in the connection settings.")}const w={id:`error-${Date.now()}`,role:"assistant",content:`Error: ${v}`,timestamp:Date.now()};i(S=>[...S,w])}finally{c(!1)}},[t,a,e,r,n]),d=x.useCallback(()=>{i([])},[]);return{messages:r,isLoading:s,sendMessage:u,clearMessages:d}}function GEe({connection:e,llmConfig:t,isConnected:n,readResource:a}){const[r,i]=x.useState([]),[s,c]=x.useState(!1),u=x.useRef(null),d=x.useRef(null),m=x.useRef(null),h=x.useCallback(async v=>{if(!v.trim()||!t||!n)return;const w={id:`user-${Date.now()}`,role:"user",content:v.trim(),timestamp:Date.now()};i(_=>[..._,w]),c(!0),u.current=new AbortController;const S=Date.now();let y=0;try{const _=`assistant-${Date.now()}`;let E="";const k=[];if(i(C=>[...C,{id:_,role:"assistant",content:"",timestamp:Date.now(),parts:[]}]),!m.current||m.current.provider!==t.provider||m.current.model!==t.model||m.current.apiKey!==t.apiKey){let C;if(t.provider==="openai"){const{ChatOpenAI:R}=await Ar(async()=>{const{ChatOpenAI:A}=await import("./index-dcwAFu32.js");return{ChatOpenAI:A}},__vite__mapDeps([5,6,7,3,8,9]));C=new R({model:t.model,apiKey:t.apiKey})}else if(t.provider==="anthropic"){const{ChatAnthropic:R}=await Ar(async()=>{const{ChatAnthropic:A}=await import("./index-jXEm6Yfx.js");return{ChatAnthropic:A}},__vite__mapDeps([10,7,6,3]));C=new R({model:t.model,apiKey:t.apiKey})}else if(t.provider==="google"){const{ChatGoogleGenerativeAI:R}=await Ar(async()=>{const{ChatGoogleGenerativeAI:A}=await import("./index-DMpSV0MO.js");return{ChatGoogleGenerativeAI:A}},__vite__mapDeps([11,7,6,3,9]));C=new R({model:t.model,apiKey:t.apiKey})}else throw new Error(`Unsupported LLM provider: ${t.provider}`);m.current={instance:C,provider:t.provider,model:t.model,apiKey:t.apiKey}}if(!d.current||d.current.llm!==m.current.instance){const{MCPAgent:C}=await Ar(async()=>{const{MCPAgent:R}=await import("./browser-B0j7NxIO.js");return{MCPAgent:R}},__vite__mapDeps([12,8,6,7,3,2,4,9]));d.current=new C({llm:m.current.instance,client:e.client,memoryEnabled:!0,systemPrompt:"You are a helpful assistant with access to MCP tools, prompts, and resources. Help users interact with the MCP server."}),await d.current.initialize()}else console.log("[useChatMessagesClientSide] Reusing existing agent. History length:",d.current.conversationHistory?.length);for await(const C of d.current.streamEvents(v,10,!1,void 0)){if(u.current?.signal.aborted)break;if(C.event==="on_chat_model_stream"&&C.data?.chunk?.text){const R=C.data.chunk.text;if(typeof R=="string"&&R.length>0){E+=R;const A=k[k.length-1];A&&A.type==="text"?A.text=E:k.push({type:"text",text:E}),i(I=>I.map(O=>O.id===_?{...O,parts:[...k]}:O))}}else if(C.event==="on_tool_start"){E&&(E="");let R={};C.data?.input?R=C.data.input:C.data?.tool_input?R=C.data.tool_input:C.data&&(R=C.data),console.log("[useChatMessagesClientSide] on_tool_start:",{toolName:C.name,eventData:C.data,extractedArgs:R}),y++,k.push({type:"tool-invocation",toolInvocation:{toolName:C.name||"unknown",args:R,state:"pending"}}),i(A=>A.map(I=>I.id===_?{...I,parts:[...k]}:I))}else if(C.event==="on_tool_end"){const R=k.find(A=>A.type==="tool-invocation"&&A.toolInvocation?.toolName===C.name&&!A.toolInvocation?.result);if(console.log("[useChatMessagesClientSide] on_tool_end event:",{toolName:C.name,hasToolPart:!!R,output:C.data?.output}),R&&R.toolInvocation){let A=C.data?.output;if(A?.kwargs?.content&&typeof A.kwargs.content=="string")try{A=JSON.parse(A.kwargs.content)}catch(O){console.warn("[useChatMessagesClientSide] Failed to parse kwargs.content:",O),A=A.kwargs.content}else if(A?.content&&typeof A.content=="string")try{A=JSON.parse(A.content)}catch{A=A.content}R.toolInvocation.result=A,R.toolInvocation.state="result";const I=A?._meta?.["openai/outputTemplate"];if(console.log("[useChatMessagesClientSide] Tool result:",{toolName:C.name,hasMeta:!!A?._meta,hasStructuredContent:!!A?.structuredContent,appsSdkUri:I}),I&&typeof I=="string"&&a){console.log("[useChatMessagesClientSide] Detected Apps SDK component, fetching resource:",I);try{const O=await a(I);console.log("[useChatMessagesClientSide] Resource fetched:",O);const j=A?.structuredContent||null;if(O?.contents&&Array.isArray(O.contents)){const F=O.contents.map(K=>({type:"resource",resource:K}));console.log("[useChatMessagesClientSide] Created MCP resources:",F);const H={...A,content:[...A.content||[],...F],structuredContent:j};R.toolInvocation.result=H,console.log("[useChatMessagesClientSide] Updated result with resources")}else console.warn("[useChatMessagesClientSide] No contents in resourceData:",O)}catch(O){console.error("Failed to fetch Apps SDK resource:",O)}}i(O=>O.map(j=>j.id===_?{...j,parts:[...k]}:j))}}}i(C=>C.map(R=>R.id===_?{...R,parts:[...k],content:""}:R)),t&&br.getInstance().capture(new nU({serverId:e.url,provider:t.provider,model:t.model,messageCount:r.length+1,toolCallsCount:y,success:!0,executionMode:"client-side",duration:Date.now()-S})).catch(()=>{})}catch(_){console.error("Client-side agent error:",_);let E="Unknown error occurred";if(_ instanceof Error){E=_.message;const C=_;C.status&&(E=`HTTP ${C.status}: ${E}`),(C.code===401||E.includes("401")||E.includes("Unauthorized"))&&(E="Authentication failed (401). Check your Authorization header in the connection settings.")}t&&br.getInstance().capture(new nU({serverId:e.url,provider:t.provider,model:t.model,messageCount:r.length+1,toolCallsCount:y,success:!1,executionMode:"client-side",duration:Date.now()-S,error:E})).catch(()=>{});const k={id:`error-${Date.now()}`,role:"assistant",content:`Error: ${E}`,timestamp:Date.now()};i(C=>[...C,k])}finally{c(!1),u.current=null}},[e,t,n,r,a]),g=x.useCallback(()=>{i([]),d.current&&d.current.clearConversationHistory()},[]);return{messages:r,isLoading:s,sendMessage:h,clearMessages:g}}const T4={openai:"gpt-4o",anthropic:"claude-haiku-4-5-20251001",google:"gemini-2.5-flash"};function _K({mcpServerUrl:e}){const[t,n]=x.useState(null),[a,r]=x.useState(null),[i,s]=x.useState(!1),[c,u]=x.useState("openai"),[d,m]=x.useState(""),[h,g]=x.useState(T4.openai),v=x.useCallback(()=>{const j=localStorage.getItem("mcp-inspector-api-keys");if(j)try{return JSON.parse(j)}catch(F){return console.error("Failed to load API keys:",F),{}}return{}},[]),w=x.useCallback(j=>{localStorage.setItem("mcp-inspector-api-keys",JSON.stringify(j))},[]),[S,y]=x.useState("none"),[_,E]=x.useState(""),[k,C]=x.useState(""),[R,A]=x.useState("");x.useEffect(()=>{const j=localStorage.getItem("mcp-inspector-llm-config"),F=v();if(j)try{const H=JSON.parse(j);n(H),u(H.provider),m(F[H.provider]||H.apiKey||""),g(H.model)}catch(H){console.error("Failed to load LLM config:",H)}},[v]),x.useEffect(()=>{const j=localStorage.getItem("mcp-inspector-auth-config");if(j)try{const F=JSON.parse(j);r(F),y(F.type),F.username&&E(F.username),F.password&&C(F.password),F.token&&A(F.token)}catch(F){console.error("Failed to load auth config:",F)}else try{const F="mcp:auth",H=EK(e),K=`${F}_${H}_tokens`;localStorage.getItem(K)&&(r({type:"oauth"}),y("oauth"))}catch(F){console.error("Failed to check for OAuth tokens:",F)}},[e]),x.useEffect(()=>{g(T4[c]);const j=v();m(j[c]||"")},[c,v]);const I=x.useCallback(()=>{if(!d.trim())return;const j=v();j[c]=d,w(j);const F={provider:c,apiKey:d,model:h},H={type:S,...S==="basic"&&{username:_.trim(),password:k.trim()},...S==="bearer"&&{token:R.trim()}};n(F),r(H),localStorage.setItem("mcp-inspector-llm-config",JSON.stringify(F)),localStorage.setItem("mcp-inspector-auth-config",JSON.stringify(H)),s(!1)},[c,d,h,S,_,k,R,v,w]),O=x.useCallback(()=>{n(null),r(null);const j=v();delete j[c],w(j),m(""),E(""),C(""),A(""),y("none"),localStorage.removeItem("mcp-inspector-llm-config"),localStorage.removeItem("mcp-inspector-auth-config")},[c,v,w]);return{llmConfig:t,authConfig:a,configDialogOpen:i,setConfigDialogOpen:s,tempProvider:c,setTempProvider:u,tempApiKey:d,setTempApiKey:m,tempModel:h,setTempModel:g,tempAuthType:S,saveLLMConfig:I,clearConfig:O}}function WEe({connection:e,isConnected:t,useClientSide:n=!0,readResource:a}){const[r,i]=x.useState(""),s=x.useRef(null),{llmConfig:c,authConfig:u,configDialogOpen:d,setConfigDialogOpen:m,tempProvider:h,setTempProvider:g,tempApiKey:v,setTempApiKey:w,tempModel:S,setTempModel:y,saveLLMConfig:_,clearConfig:E}=_K({mcpServerUrl:e.url}),k={connection:e,llmConfig:c,isConnected:t,readResource:a},C=VEe({mcpServerUrl:e.url,llmConfig:c,authConfig:u,isConnected:t}),R=GEe(k),{messages:A,isLoading:I,sendMessage:O,clearMessages:j}=n?R:C;xW({onNewChat:j}),x.useEffect(()=>{c&&A.length===0&&s.current&&s.current.focus()},[c,A.length]),x.useEffect(()=>{!I&&A.length>0&&s.current&&s.current.focus()},[I,A.length]);const F=x.useCallback(()=>{r.trim()&&(O(r),i(""))},[r,O]),H=x.useCallback(Q=>{Q.key==="Enter"&&!Q.shiftKey&&(Q.preventDefault(),F())},[F]),K=x.useCallback(()=>{E(),j()},[E,j]);return c&&A.length===0?p.jsxs("div",{className:"flex flex-col h-full",children:[p.jsx("div",{className:"absolute top-4 right-4 z-10",children:p.jsx(LE,{open:d,onOpenChange:m,tempProvider:h,tempModel:S,tempApiKey:v,onProviderChange:g,onModelChange:y,onApiKeyChange:w,onSave:_,onClear:K,showClearButton:!0,buttonLabel:"Change API Key"})}),p.jsx(i0e,{mcpServerUrl:e.url,inputValue:r,isConnected:t,isLoading:I,textareaRef:s,llmConfig:c,onInputChange:i,onKeyDown:H,onSubmit:Q=>{Q.preventDefault(),F()},onConfigDialogOpenChange:m})]}):p.jsxs("div",{className:"flex flex-col h-full relative",children:[p.jsx(n0e,{llmConfig:c,hasMessages:A.length>0,configDialogOpen:d,onConfigDialogOpenChange:m,onClearChat:j,tempProvider:h,tempModel:S,tempApiKey:v,onProviderChange:g,onModelChange:y,onApiKeyChange:w,onSaveConfig:_,onClearConfig:K}),p.jsx("div",{className:"flex-1 overflow-y-auto p-2 sm:p-4 pt-[80px] sm:pt-[100px]",children:c?p.jsx(HEe,{messages:A,isLoading:I,serverId:e.url,readResource:a}):p.jsx(o0e,{onConfigureClick:()=>m(!0)})}),c&&p.jsx(r0e,{inputValue:r,isConnected:t,isLoading:I,textareaRef:s,onInputChange:i,onKeyDown:H,onSendMessage:F})]})}const Ay=x.createContext(null);Ay.displayName="PanelGroupContext";const Wn={group:"data-panel-group",groupDirection:"data-panel-group-direction",groupId:"data-panel-group-id",panel:"data-panel",panelCollapsible:"data-panel-collapsible",panelId:"data-panel-id",panelSize:"data-panel-size",resizeHandle:"data-resize-handle",resizeHandleActive:"data-resize-handle-active",resizeHandleEnabled:"data-panel-resize-handle-enabled",resizeHandleId:"data-panel-resize-handle-id",resizeHandleState:"data-resize-handle-state"},EO=10,Tl=x.useLayoutEffect,N4=Pp.useId,KEe=typeof N4=="function"?N4:()=>null;let ZEe=0;function _O(e=null){const t=KEe(),n=x.useRef(e||t||null);return n.current===null&&(n.current=""+ZEe++),e??n.current}function kK({children:e,className:t="",collapsedSize:n,collapsible:a,defaultSize:r,forwardedRef:i,id:s,maxSize:c,minSize:u,onCollapse:d,onExpand:m,onResize:h,order:g,style:v,tagName:w="div",...S}){const y=x.useContext(Ay);if(y===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:_,expandPanel:E,getPanelSize:k,getPanelStyle:C,groupId:R,isPanelCollapsed:A,reevaluatePanelConstraints:I,registerPanel:O,resizePanel:j,unregisterPanel:F}=y,H=_O(s),K=x.useRef({callbacks:{onCollapse:d,onExpand:m,onResize:h},constraints:{collapsedSize:n,collapsible:a,defaultSize:r,maxSize:c,minSize:u},id:H,idIsFromProps:s!==void 0,order:g});x.useRef({didLogMissingDefaultSizeWarning:!1}),Tl(()=>{const{callbacks:W,constraints:ie}=K.current,V={...ie};K.current.id=H,K.current.idIsFromProps=s!==void 0,K.current.order=g,W.onCollapse=d,W.onExpand=m,W.onResize=h,ie.collapsedSize=n,ie.collapsible=a,ie.defaultSize=r,ie.maxSize=c,ie.minSize=u,(V.collapsedSize!==ie.collapsedSize||V.collapsible!==ie.collapsible||V.maxSize!==ie.maxSize||V.minSize!==ie.minSize)&&I(K.current,V)}),Tl(()=>{const W=K.current;return O(W),()=>{F(W)}},[g,H,O,F]),x.useImperativeHandle(i,()=>({collapse:()=>{_(K.current)},expand:W=>{E(K.current,W)},getId(){return H},getSize(){return k(K.current)},isCollapsed(){return A(K.current)},isExpanded(){return!A(K.current)},resize:W=>{j(K.current,W)}}),[_,E,k,A,H,j]);const Q=C(K.current,r);return x.createElement(w,{...S,children:e,className:t,id:H,style:{...Q,...v},[Wn.groupId]:R,[Wn.panel]:"",[Wn.panelCollapsible]:a||void 0,[Wn.panelId]:H,[Wn.panelSize]:parseFloat(""+Q.flexGrow).toFixed(1)})}const TK=x.forwardRef((e,t)=>x.createElement(kK,{...e,forwardedRef:t}));kK.displayName="Panel";TK.displayName="forwardRef(Panel)";let u_=null,ib=-1,xs=null;function YEe(e,t,n){const a=(t&IK)!==0,r=(t&OK)!==0,i=(t&DK)!==0,s=(t&LK)!==0;if(t){if(a)return i?"se-resize":s?"ne-resize":"e-resize";if(r)return i?"sw-resize":s?"nw-resize":"w-resize";if(i)return"s-resize";if(s)return"n-resize"}switch(e){case"horizontal":return"ew-resize";case"intersection":return"move";case"vertical":return"ns-resize"}}function XEe(){xs!==null&&(document.head.removeChild(xs),u_=null,xs=null,ib=-1)}function ix(e,t,n){var a,r;const i=YEe(e,t);if(u_!==i){if(u_=i,xs===null&&(xs=document.createElement("style"),document.head.appendChild(xs)),ib>=0){var s;(s=xs.sheet)===null||s===void 0||s.removeRule(ib)}ib=(a=(r=xs.sheet)===null||r===void 0?void 0:r.insertRule(`*{cursor: ${i} !important;}`))!==null&&a!==void 0?a:-1}}function NK(e){return e.type==="keydown"}function RK(e){return e.type.startsWith("pointer")}function CK(e){return e.type.startsWith("mouse")}function Iy(e){if(RK(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(CK(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}function qEe(){if(typeof matchMedia=="function")return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}function JEe(e,t,n){return e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y}function QEe(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:A4(e),b:A4(t)};let a;for(;n.a.at(-1)===n.b.at(-1);)e=n.a.pop(),t=n.b.pop(),a=e;_t(a,"Stacking order can only be calculated for elements with a common ancestor");const r={a:C4(R4(n.a)),b:C4(R4(n.b))};if(r.a===r.b){const i=a.childNodes,s={a:n.a.at(-1),b:n.b.at(-1)};let c=i.length;for(;c--;){const u=i[c];if(u===s.a)return 1;if(u===s.b)return-1}}return Math.sign(r.a-r.b)}const e_e=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function t_e(e){var t;const n=getComputedStyle((t=AK(e))!==null&&t!==void 0?t:e).display;return n==="flex"||n==="inline-flex"}function n_e(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||t_e(e))||+t.opacity<1||"transform"in t&&t.transform!=="none"||"webkitTransform"in t&&t.webkitTransform!=="none"||"mixBlendMode"in t&&t.mixBlendMode!=="normal"||"filter"in t&&t.filter!=="none"||"webkitFilter"in t&&t.webkitFilter!=="none"||"isolation"in t&&t.isolation==="isolate"||e_e.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function R4(e){let t=e.length;for(;t--;){const n=e[t];if(_t(n,"Missing node"),n_e(n))return n}return null}function C4(e){return e&&Number(getComputedStyle(e).zIndex)||0}function A4(e){const t=[];for(;e;)t.push(e),e=AK(e);return t}function AK(e){const{parentNode:t}=e;return t&&t instanceof ShadowRoot?t.host:t}const IK=1,OK=2,DK=4,LK=8,r_e=qEe()==="coarse";let gi=[],mu=!1,Es=new Map,Oy=new Map;const wp=new Set;function a_e(e,t,n,a,r){var i;const{ownerDocument:s}=t,c={direction:n,element:t,hitAreaMargins:a,setResizeHandlerState:r},u=(i=Es.get(s))!==null&&i!==void 0?i:0;return Es.set(s,u+1),wp.add(c),lv(),function(){var m;Oy.delete(e),wp.delete(c);const h=(m=Es.get(s))!==null&&m!==void 0?m:1;if(Es.set(s,h-1),lv(),h===1&&Es.delete(s),gi.includes(c)){const g=gi.indexOf(c);g>=0&&gi.splice(g,1),Dy(),r("up",!0,null)}}}function i_e(e){const{target:t}=e,{x:n,y:a}=Iy(e);mu=!0,kO({target:t,x:n,y:a}),lv(),gi.length>0&&(cv("down",e),Dy(),e.preventDefault(),$K(t)||e.stopImmediatePropagation())}function ox(e){const{x:t,y:n}=Iy(e);if(mu&&e.type!=="pointerleave"&&e.buttons===0&&(mu=!1,cv("up",e)),!mu){const{target:a}=e;kO({target:a,x:t,y:n})}cv("move",e),Dy(),gi.length>0&&e.preventDefault()}function sx(e){const{target:t}=e,{x:n,y:a}=Iy(e);Oy.clear(),mu=!1,gi.length>0&&(e.preventDefault(),$K(t)||e.stopImmediatePropagation()),cv("up",e),kO({target:t,x:n,y:a}),Dy(),lv()}function $K(e){let t=e;for(;t;){if(t.hasAttribute(Wn.resizeHandle))return!0;t=t.parentElement}return!1}function kO({target:e,x:t,y:n}){gi.splice(0);let a=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(a=e),wp.forEach(r=>{const{element:i,hitAreaMargins:s}=r,c=i.getBoundingClientRect(),{bottom:u,left:d,right:m,top:h}=c,g=r_e?s.coarse:s.fine;if(t>=d-g&&t<=m+g&&n>=h-g&&n<=u+g){if(a!==null&&document.contains(a)&&i!==a&&!i.contains(a)&&!a.contains(i)&&QEe(a,i)>0){let w=a,S=!1;for(;w&&!w.contains(i);){if(JEe(w.getBoundingClientRect(),c)){S=!0;break}w=w.parentElement}if(S)return}gi.push(r)}})}function lx(e,t){Oy.set(e,t)}function Dy(){let e=!1,t=!1;gi.forEach(a=>{const{direction:r}=a;r==="horizontal"?e=!0:t=!0});let n=0;Oy.forEach(a=>{n|=a}),e&&t?ix("intersection",n):e?ix("horizontal",n):t?ix("vertical",n):XEe()}let cx;function lv(){var e;(e=cx)===null||e===void 0||e.abort(),cx=new AbortController;const t={capture:!0,signal:cx.signal};wp.size&&(mu?(gi.length>0&&Es.forEach((n,a)=>{const{body:r}=a;n>0&&(r.addEventListener("contextmenu",sx,t),r.addEventListener("pointerleave",ox,t),r.addEventListener("pointermove",ox,t))}),Es.forEach((n,a)=>{const{body:r}=a;r.addEventListener("pointerup",sx,t),r.addEventListener("pointercancel",sx,t)})):Es.forEach((n,a)=>{const{body:r}=a;n>0&&(r.addEventListener("pointerdown",i_e,t),r.addEventListener("pointermove",ox,t))}))}function cv(e,t){wp.forEach(n=>{const{setResizeHandlerState:a}=n,r=gi.includes(n);a(e,r,t)})}function o_e(){const[e,t]=x.useState(0);return x.useCallback(()=>t(n=>n+1),[])}function _t(e,t){if(!e)throw console.error(t),Error(t)}function Ul(e,t,n=EO){return e.toFixed(n)===t.toFixed(n)?0:e>t?1:-1}function vo(e,t,n=EO){return Ul(e,t,n)===0}function Ca(e,t,n){return Ul(e,t,n)===0}function s_e(e,t,n){if(e.length!==t.length)return!1;for(let a=0;a<e.length;a++){const r=e[a],i=t[a];if(!Ca(r,i,n))return!1}return!0}function ou({panelConstraints:e,panelIndex:t,size:n}){const a=e[t];_t(a!=null,`Panel constraints not found for index ${t}`);let{collapsedSize:r=0,collapsible:i,maxSize:s=100,minSize:c=0}=a;if(Ul(n,c)<0)if(i){const u=(r+c)/2;Ul(n,u)<0?n=r:n=c}else n=c;return n=Math.min(s,n),n=parseFloat(n.toFixed(EO)),n}function Nf({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:a,prevLayout:r,trigger:i}){if(Ca(e,0))return t;const s=[...t],[c,u]=a;_t(c!=null,"Invalid first pivot index"),_t(u!=null,"Invalid second pivot index");let d=0;if(i==="keyboard"){{const h=e<0?u:c,g=n[h];_t(g,`Panel constraints not found for index ${h}`);const{collapsedSize:v=0,collapsible:w,minSize:S=0}=g;if(w){const y=t[h];if(_t(y!=null,`Previous layout not found for panel index ${h}`),Ca(y,v)){const _=S-y;Ul(_,Math.abs(e))>0&&(e=e<0?0-_:_)}}}{const h=e<0?c:u,g=n[h];_t(g,`No panel constraints found for index ${h}`);const{collapsedSize:v=0,collapsible:w,minSize:S=0}=g;if(w){const y=t[h];if(_t(y!=null,`Previous layout not found for panel index ${h}`),Ca(y,S)){const _=y-v;Ul(_,Math.abs(e))>0&&(e=e<0?0-_:_)}}}}{const h=e<0?1:-1;let g=e<0?u:c,v=0;for(;;){const S=t[g];_t(S!=null,`Previous layout not found for panel index ${g}`);const _=ou({panelConstraints:n,panelIndex:g,size:100})-S;if(v+=_,g+=h,g<0||g>=n.length)break}const w=Math.min(Math.abs(e),Math.abs(v));e=e<0?0-w:w}{let g=e<0?c:u;for(;g>=0&&g<n.length;){const v=Math.abs(e)-Math.abs(d),w=t[g];_t(w!=null,`Previous layout not found for panel index ${g}`);const S=w-v,y=ou({panelConstraints:n,panelIndex:g,size:S});if(!Ca(w,y)&&(d+=w-y,s[g]=y,d.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?g--:g++}}if(s_e(r,s))return r;{const h=e<0?u:c,g=t[h];_t(g!=null,`Previous layout not found for panel index ${h}`);const v=g+d,w=ou({panelConstraints:n,panelIndex:h,size:v});if(s[h]=w,!Ca(w,v)){let S=v-w,_=e<0?u:c;for(;_>=0&&_<n.length;){const E=s[_];_t(E!=null,`Previous layout not found for panel index ${_}`);const k=E+S,C=ou({panelConstraints:n,panelIndex:_,size:k});if(Ca(E,C)||(S-=C-E,s[_]=C),Ca(S,0))break;e>0?_--:_++}}}const m=s.reduce((h,g)=>g+h,0);return Ca(m,100)?s:r}function l_e({layout:e,panelsArray:t,pivotIndices:n}){let a=0,r=100,i=0,s=0;const c=n[0];_t(c!=null,"No pivot index found"),t.forEach((h,g)=>{const{constraints:v}=h,{maxSize:w=100,minSize:S=0}=v;g===c?(a=S,r=w):(i+=S,s+=w)});const u=Math.min(r,100-i),d=Math.max(a,100-s),m=e[c];return{valueMax:u,valueMin:d,valueNow:m}}function Sp(e,t=document){return Array.from(t.querySelectorAll(`[${Wn.resizeHandleId}][data-panel-group-id="${e}"]`))}function jK(e,t,n=document){const r=Sp(e,n).findIndex(i=>i.getAttribute(Wn.resizeHandleId)===t);return r??null}function MK(e,t,n){const a=jK(e,t,n);return a!=null?[a,a+1]:[-1,-1]}function c_e(e){return e instanceof HTMLElement?!0:typeof e=="object"&&e!==null&&"tagName"in e&&"getAttribute"in e}function PK(e,t=document){if(c_e(t)&&t.dataset.panelGroupId==e)return t;const n=t.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return n||null}function Ly(e,t=document){const n=t.querySelector(`[${Wn.resizeHandleId}="${e}"]`);return n||null}function u_e(e,t,n,a=document){var r,i,s,c;const u=Ly(t,a),d=Sp(e,a),m=u?d.indexOf(u):-1,h=(r=(i=n[m])===null||i===void 0?void 0:i.id)!==null&&r!==void 0?r:null,g=(s=(c=n[m+1])===null||c===void 0?void 0:c.id)!==null&&s!==void 0?s:null;return[h,g]}function d_e({committedValuesRef:e,eagerValuesRef:t,groupId:n,layout:a,panelDataArray:r,panelGroupElement:i,setLayout:s}){x.useRef({didWarnAboutMissingResizeHandle:!1}),Tl(()=>{if(!i)return;const c=Sp(n,i);for(let u=0;u<r.length-1;u++){const{valueMax:d,valueMin:m,valueNow:h}=l_e({layout:a,panelsArray:r,pivotIndices:[u,u+1]}),g=c[u];if(g!=null){const v=r[u];_t(v,`No panel data found for index "${u}"`),g.setAttribute("aria-controls",v.id),g.setAttribute("aria-valuemax",""+Math.round(d)),g.setAttribute("aria-valuemin",""+Math.round(m)),g.setAttribute("aria-valuenow",h!=null?""+Math.round(h):"")}}return()=>{c.forEach((u,d)=>{u.removeAttribute("aria-controls"),u.removeAttribute("aria-valuemax"),u.removeAttribute("aria-valuemin"),u.removeAttribute("aria-valuenow")})}},[n,a,r,i]),x.useEffect(()=>{if(!i)return;const c=t.current;_t(c,"Eager values not found");const{panelDataArray:u}=c,d=PK(n,i);_t(d!=null,`No group found for id "${n}"`);const m=Sp(n,i);_t(m,`No resize handles found for group id "${n}"`);const h=m.map(g=>{const v=g.getAttribute(Wn.resizeHandleId);_t(v,"Resize handle element has no handle id attribute");const[w,S]=u_e(n,v,u,i);if(w==null||S==null)return()=>{};const y=_=>{if(!_.defaultPrevented)switch(_.key){case"Enter":{_.preventDefault();const E=u.findIndex(k=>k.id===w);if(E>=0){const k=u[E];_t(k,`No panel data found for index ${E}`);const C=a[E],{collapsedSize:R=0,collapsible:A,minSize:I=0}=k.constraints;if(C!=null&&A){const O=Nf({delta:Ca(C,R)?I-R:R-C,initialLayout:a,panelConstraints:u.map(j=>j.constraints),pivotIndices:MK(n,v,i),prevLayout:a,trigger:"keyboard"});a!==O&&s(O)}}break}}};return g.addEventListener("keydown",y),()=>{g.removeEventListener("keydown",y)}});return()=>{h.forEach(g=>g())}},[i,e,t,n,a,r,s])}function I4(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function UK(e,t){const n=e==="horizontal",{x:a,y:r}=Iy(t);return n?a:r}function f_e(e,t,n,a,r){const i=n==="horizontal",s=Ly(t,r);_t(s,`No resize handle element found for id "${t}"`);const c=s.getAttribute(Wn.groupId);_t(c,"Resize handle element has no group id attribute");let{initialCursorPosition:u}=a;const d=UK(n,e),m=PK(c,r);_t(m,`No group element found for id "${c}"`);const h=m.getBoundingClientRect(),g=i?h.width:h.height;return(d-u)/g*100}function p_e(e,t,n,a,r,i){if(NK(e)){const s=n==="horizontal";let c=0;e.shiftKey?c=100:r!=null?c=r:c=10;let u=0;switch(e.key){case"ArrowDown":u=s?0:c;break;case"ArrowLeft":u=s?-c:0;break;case"ArrowRight":u=s?c:0;break;case"ArrowUp":u=s?0:-c;break;case"End":u=100;break;case"Home":u=-100;break}return u}else return a==null?0:f_e(e,t,n,a,i)}function m_e({panelDataArray:e}){const t=Array(e.length),n=e.map(i=>i.constraints);let a=0,r=100;for(let i=0;i<e.length;i++){const s=n[i];_t(s,`Panel constraints not found for index ${i}`);const{defaultSize:c}=s;c!=null&&(a++,t[i]=c,r-=c)}for(let i=0;i<e.length;i++){const s=n[i];_t(s,`Panel constraints not found for index ${i}`);const{defaultSize:c}=s;if(c!=null)continue;const u=e.length-a,d=r/u;a++,t[i]=d,r-=d}return t}function Pc(e,t,n){t.forEach((a,r)=>{const i=e[r];_t(i,`Panel data not found for index ${r}`);const{callbacks:s,constraints:c,id:u}=i,{collapsedSize:d=0,collapsible:m}=c,h=n[u];if(h==null||a!==h){n[u]=a;const{onCollapse:g,onExpand:v,onResize:w}=s;w&&w(a,h),m&&(g||v)&&(v&&(h==null||vo(h,d))&&!vo(a,d)&&v(),g&&(h==null||!vo(h,d))&&vo(a,d)&&g())}})}function $g(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n])return!1;return!0}function h_e({defaultSize:e,dragState:t,layout:n,panelData:a,panelIndex:r,precision:i=3}){const s=n[r];let c;return s==null?c=e!=null?e.toFixed(i):"1":a.length===1?c="1":c=s.toFixed(i),{flexBasis:0,flexGrow:c,flexShrink:1,overflow:"hidden",pointerEvents:t!==null?"none":void 0}}function g_e(e,t=10){let n=null;return(...r)=>{n!==null&&clearTimeout(n),n=setTimeout(()=>{e(...r)},t)}}function O4(e){try{if(typeof localStorage<"u")e.getItem=t=>localStorage.getItem(t),e.setItem=(t,n)=>{localStorage.setItem(t,n)};else throw new Error("localStorage not supported in this environment")}catch(t){console.error(t),e.getItem=()=>null,e.setItem=()=>{}}}function zK(e){return`react-resizable-panels:${e}`}function FK(e){return e.map(t=>{const{constraints:n,id:a,idIsFromProps:r,order:i}=t;return r?a:i?`${i}:${JSON.stringify(n)}`:JSON.stringify(n)}).sort((t,n)=>t.localeCompare(n)).join(",")}function BK(e,t){try{const n=zK(e),a=t.getItem(n);if(a){const r=JSON.parse(a);if(typeof r=="object"&&r!=null)return r}}catch{}return null}function b_e(e,t,n){var a,r;const i=(a=BK(e,n))!==null&&a!==void 0?a:{},s=FK(t);return(r=i[s])!==null&&r!==void 0?r:null}function v_e(e,t,n,a,r){var i;const s=zK(e),c=FK(t),u=(i=BK(e,r))!==null&&i!==void 0?i:{};u[c]={expandToSizes:Object.fromEntries(n.entries()),layout:a};try{r.setItem(s,JSON.stringify(u))}catch(d){console.error(d)}}function D4({layout:e,panelConstraints:t}){const n=[...e],a=n.reduce((i,s)=>i+s,0);if(n.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${n.map(i=>`${i}%`).join(", ")}`);if(!Ca(a,100)&&n.length>0)for(let i=0;i<t.length;i++){const s=n[i];_t(s!=null,`No layout data found for index ${i}`);const c=100/a*s;n[i]=c}let r=0;for(let i=0;i<t.length;i++){const s=n[i];_t(s!=null,`No layout data found for index ${i}`);const c=ou({panelConstraints:t,panelIndex:i,size:s});s!=c&&(r+=s-c,n[i]=c)}if(!Ca(r,0))for(let i=0;i<t.length;i++){const s=n[i];_t(s!=null,`No layout data found for index ${i}`);const c=s+r,u=ou({panelConstraints:t,panelIndex:i,size:c});if(s!==u&&(r-=u-s,n[i]=u,Ca(r,0)))break}return n}const y_e=100,Rf={getItem:e=>(O4(Rf),Rf.getItem(e)),setItem:(e,t)=>{O4(Rf),Rf.setItem(e,t)}},L4={};function HK({autoSaveId:e=null,children:t,className:n="",direction:a,forwardedRef:r,id:i=null,onLayout:s=null,keyboardResizeBy:c=null,storage:u=Rf,style:d,tagName:m="div",...h}){const g=_O(i),v=x.useRef(null),[w,S]=x.useState(null),[y,_]=x.useState([]),E=o_e(),k=x.useRef({}),C=x.useRef(new Map),R=x.useRef(0),A=x.useRef({autoSaveId:e,direction:a,dragState:w,id:g,keyboardResizeBy:c,onLayout:s,storage:u}),I=x.useRef({layout:y,panelDataArray:[],panelDataArrayChanged:!1});x.useRef({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),x.useImperativeHandle(r,()=>({getId:()=>A.current.id,getLayout:()=>{const{layout:U}=I.current;return U},setLayout:U=>{const{onLayout:L}=A.current,{layout:P,panelDataArray:G}=I.current,Z=D4({layout:U,panelConstraints:G.map(J=>J.constraints)});I4(P,Z)||(_(Z),I.current.layout=Z,L&&L(Z),Pc(G,Z,k.current))}}),[]),Tl(()=>{A.current.autoSaveId=e,A.current.direction=a,A.current.dragState=w,A.current.id=g,A.current.onLayout=s,A.current.storage=u}),d_e({committedValuesRef:A,eagerValuesRef:I,groupId:g,layout:y,panelDataArray:I.current.panelDataArray,setLayout:_,panelGroupElement:v.current}),x.useEffect(()=>{const{panelDataArray:U}=I.current;if(e){if(y.length===0||y.length!==U.length)return;let L=L4[e];L==null&&(L=g_e(v_e,y_e),L4[e]=L);const P=[...U],G=new Map(C.current);L(e,P,G,y,u)}},[e,y,u]),x.useEffect(()=>{});const O=x.useCallback(U=>{const{onLayout:L}=A.current,{layout:P,panelDataArray:G}=I.current;if(U.constraints.collapsible){const Z=G.map(ee=>ee.constraints),{collapsedSize:J=0,panelSize:se,pivotIndices:le}=fl(G,U,P);if(_t(se!=null,`Panel size not found for panel "${U.id}"`),!vo(se,J)){C.current.set(U.id,se);const ne=Zc(G,U)===G.length-1?se-J:J-se,ce=Nf({delta:ne,initialLayout:P,panelConstraints:Z,pivotIndices:le,prevLayout:P,trigger:"imperative-api"});$g(P,ce)||(_(ce),I.current.layout=ce,L&&L(ce),Pc(G,ce,k.current))}}},[]),j=x.useCallback((U,L)=>{const{onLayout:P}=A.current,{layout:G,panelDataArray:Z}=I.current;if(U.constraints.collapsible){const J=Z.map(ae=>ae.constraints),{collapsedSize:se=0,panelSize:le=0,minSize:ee=0,pivotIndices:ne}=fl(Z,U,G),ce=L??ee;if(vo(le,se)){const ae=C.current.get(U.id),ye=ae!=null&&ae>=ce?ae:ce,Be=Zc(Z,U)===Z.length-1?le-ye:ye-le,_e=Nf({delta:Be,initialLayout:G,panelConstraints:J,pivotIndices:ne,prevLayout:G,trigger:"imperative-api"});$g(G,_e)||(_(_e),I.current.layout=_e,P&&P(_e),Pc(Z,_e,k.current))}}},[]),F=x.useCallback(U=>{const{layout:L,panelDataArray:P}=I.current,{panelSize:G}=fl(P,U,L);return _t(G!=null,`Panel size not found for panel "${U.id}"`),G},[]),H=x.useCallback((U,L)=>{const{panelDataArray:P}=I.current,G=Zc(P,U);return h_e({defaultSize:L,dragState:w,layout:y,panelData:P,panelIndex:G})},[w,y]),K=x.useCallback(U=>{const{layout:L,panelDataArray:P}=I.current,{collapsedSize:G=0,collapsible:Z,panelSize:J}=fl(P,U,L);return _t(J!=null,`Panel size not found for panel "${U.id}"`),Z===!0&&vo(J,G)},[]),Q=x.useCallback(U=>{const{layout:L,panelDataArray:P}=I.current,{collapsedSize:G=0,collapsible:Z,panelSize:J}=fl(P,U,L);return _t(J!=null,`Panel size not found for panel "${U.id}"`),!Z||Ul(J,G)>0},[]),W=x.useCallback(U=>{const{panelDataArray:L}=I.current;L.push(U),L.sort((P,G)=>{const Z=P.order,J=G.order;return Z==null&&J==null?0:Z==null?-1:J==null?1:Z-J}),I.current.panelDataArrayChanged=!0,E()},[E]);Tl(()=>{if(I.current.panelDataArrayChanged){I.current.panelDataArrayChanged=!1;const{autoSaveId:U,onLayout:L,storage:P}=A.current,{layout:G,panelDataArray:Z}=I.current;let J=null;if(U){const le=b_e(U,Z,P);le&&(C.current=new Map(Object.entries(le.expandToSizes)),J=le.layout)}J==null&&(J=m_e({panelDataArray:Z}));const se=D4({layout:J,panelConstraints:Z.map(le=>le.constraints)});I4(G,se)||(_(se),I.current.layout=se,L&&L(se),Pc(Z,se,k.current))}}),Tl(()=>{const U=I.current;return()=>{U.layout=[]}},[]);const ie=x.useCallback(U=>{let L=!1;const P=v.current;return P&&window.getComputedStyle(P,null).getPropertyValue("direction")==="rtl"&&(L=!0),function(Z){Z.preventDefault();const J=v.current;if(!J)return()=>null;const{direction:se,dragState:le,id:ee,keyboardResizeBy:ne,onLayout:ce}=A.current,{layout:ae,panelDataArray:ye}=I.current,{initialLayout:ke}=le??{},Be=MK(ee,U,J);let _e=p_e(Z,U,se,le,ne,J);const Se=se==="horizontal";Se&&L&&(_e=-_e);const ze=ye.map(Fe=>Fe.constraints),pe=Nf({delta:_e,initialLayout:ke??ae,panelConstraints:ze,pivotIndices:Be,prevLayout:ae,trigger:NK(Z)?"keyboard":"mouse-or-touch"}),Le=!$g(ae,pe);(RK(Z)||CK(Z))&&R.current!=_e&&(R.current=_e,!Le&&_e!==0?Se?lx(U,_e<0?IK:OK):lx(U,_e<0?DK:LK):lx(U,0)),Le&&(_(pe),I.current.layout=pe,ce&&ce(pe),Pc(ye,pe,k.current))}},[]),V=x.useCallback((U,L)=>{const{onLayout:P}=A.current,{layout:G,panelDataArray:Z}=I.current,J=Z.map(ae=>ae.constraints),{panelSize:se,pivotIndices:le}=fl(Z,U,G);_t(se!=null,`Panel size not found for panel "${U.id}"`);const ne=Zc(Z,U)===Z.length-1?se-L:L-se,ce=Nf({delta:ne,initialLayout:G,panelConstraints:J,pivotIndices:le,prevLayout:G,trigger:"imperative-api"});$g(G,ce)||(_(ce),I.current.layout=ce,P&&P(ce),Pc(Z,ce,k.current))},[]),Y=x.useCallback((U,L)=>{const{layout:P,panelDataArray:G}=I.current,{collapsedSize:Z=0,collapsible:J}=L,{collapsedSize:se=0,collapsible:le,maxSize:ee=100,minSize:ne=0}=U.constraints,{panelSize:ce}=fl(G,U,P);ce!=null&&(J&&le&&vo(ce,Z)?vo(Z,se)||V(U,se):ce<ne?V(U,ne):ce>ee&&V(U,ee))},[V]),z=x.useCallback((U,L)=>{const{direction:P}=A.current,{layout:G}=I.current;if(!v.current)return;const Z=Ly(U,v.current);_t(Z,`Drag handle element not found for id "${U}"`);const J=UK(P,L);S({dragHandleId:U,dragHandleRect:Z.getBoundingClientRect(),initialCursorPosition:J,initialLayout:G})},[]),te=x.useCallback(()=>{S(null)},[]),re=x.useCallback(U=>{const{panelDataArray:L}=I.current,P=Zc(L,U);P>=0&&(L.splice(P,1),delete k.current[U.id],I.current.panelDataArrayChanged=!0,E())},[E]),$=x.useMemo(()=>({collapsePanel:O,direction:a,dragState:w,expandPanel:j,getPanelSize:F,getPanelStyle:H,groupId:g,isPanelCollapsed:K,isPanelExpanded:Q,reevaluatePanelConstraints:Y,registerPanel:W,registerResizeHandle:ie,resizePanel:V,startDragging:z,stopDragging:te,unregisterPanel:re,panelGroupElement:v.current}),[O,w,a,j,F,H,g,K,Q,Y,W,ie,V,z,te,re]),B={display:"flex",flexDirection:a==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return x.createElement(Ay.Provider,{value:$},x.createElement(m,{...h,children:t,className:n,id:i,ref:v,style:{...B,...d},[Wn.group]:"",[Wn.groupDirection]:a,[Wn.groupId]:g}))}const VK=x.forwardRef((e,t)=>x.createElement(HK,{...e,forwardedRef:t}));HK.displayName="PanelGroup";VK.displayName="forwardRef(PanelGroup)";function Zc(e,t){return e.findIndex(n=>n===t||n.id===t.id)}function fl(e,t,n){const a=Zc(e,t),i=a===e.length-1?[a-1,a]:[a,a+1],s=n[a];return{...t.constraints,panelSize:s,pivotIndices:i}}function w_e({disabled:e,handleId:t,resizeHandler:n,panelGroupElement:a}){x.useEffect(()=>{if(e||n==null||a==null)return;const r=Ly(t,a);if(r==null)return;const i=s=>{if(!s.defaultPrevented)switch(s.key){case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"End":case"Home":{s.preventDefault(),n(s);break}case"F6":{s.preventDefault();const c=r.getAttribute(Wn.groupId);_t(c,`No group element found for id "${c}"`);const u=Sp(c,a),d=jK(c,t,a);_t(d!==null,`No resize element found for id "${t}"`);const m=s.shiftKey?d>0?d-1:u.length-1:d+1<u.length?d+1:0;u[m].focus();break}}};return r.addEventListener("keydown",i),()=>{r.removeEventListener("keydown",i)}},[a,e,t,n])}function GK({children:e=null,className:t="",disabled:n=!1,hitAreaMargins:a,id:r,onBlur:i,onClick:s,onDragging:c,onFocus:u,onPointerDown:d,onPointerUp:m,style:h={},tabIndex:g=0,tagName:v="div",...w}){var S,y;const _=x.useRef(null),E=x.useRef({onClick:s,onDragging:c,onPointerDown:d,onPointerUp:m});x.useEffect(()=>{E.current.onClick=s,E.current.onDragging=c,E.current.onPointerDown=d,E.current.onPointerUp=m});const k=x.useContext(Ay);if(k===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:C,groupId:R,registerResizeHandle:A,startDragging:I,stopDragging:O,panelGroupElement:j}=k,F=_O(r),[H,K]=x.useState("inactive"),[Q,W]=x.useState(!1),[ie,V]=x.useState(null),Y=x.useRef({state:H});Tl(()=>{Y.current.state=H}),x.useEffect(()=>{if(n)V(null);else{const $=A(F);V(()=>$)}},[n,F,A]);const z=(S=a?.coarse)!==null&&S!==void 0?S:15,te=(y=a?.fine)!==null&&y!==void 0?y:5;x.useEffect(()=>{if(n||ie==null)return;const $=_.current;_t($,"Element ref not attached");let B=!1;return a_e(F,$,C,{coarse:z,fine:te},(L,P,G)=>{if(!P){K("inactive");return}switch(L){case"down":{K("drag"),B=!1,_t(G,'Expected event to be defined for "down" action'),I(F,G);const{onDragging:Z,onPointerDown:J}=E.current;Z?.(!0),J?.();break}case"move":{const{state:Z}=Y.current;B=!0,Z!=="drag"&&K("hover"),_t(G,'Expected event to be defined for "move" action'),ie(G);break}case"up":{K("hover"),O();const{onClick:Z,onDragging:J,onPointerUp:se}=E.current;J?.(!1),se?.(),B||Z?.();break}}})},[z,C,n,te,A,F,ie,I,O]),w_e({disabled:n,handleId:F,resizeHandler:ie,panelGroupElement:j});const re={touchAction:"none",userSelect:"none"};return x.createElement(v,{...w,children:e,className:t,id:r,onBlur:()=>{W(!1),i?.()},onFocus:()=>{W(!0),u?.()},ref:_,role:"separator",style:{...re,...h},tabIndex:g,[Wn.groupDirection]:C,[Wn.groupId]:R,[Wn.resizeHandle]:"",[Wn.resizeHandleActive]:H==="drag"?"pointer":Q?"keyboard":void 0,[Wn.resizeHandleEnabled]:!n,[Wn.resizeHandleId]:F,[Wn.resizeHandleState]:H})}GK.displayName="PanelResizeHandle";function Da({className:e,...t}){return p.jsx(VK,{"data-slot":"resizable-panel-group",className:De("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...t})}function zn({...e}){return p.jsx(TK,{"data-slot":"resizable-panel",...e})}function Ui({withHandle:e,className:t,...n}){return p.jsx(GK,{"data-slot":"resizable-handle",className:De("bg-border focus-visible:ring-ring relative flex w-px items-center justify-center after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:ring-1 focus-visible:ring-offset-1 focus-visible:outline-hidden data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:h-1 data-[panel-group-direction=vertical]:after:w-full data-[panel-group-direction=vertical]:after:translate-x-0 data-[panel-group-direction=vertical]:after:-translate-y-1/2 [&[data-panel-group-direction=vertical]>div]:rotate-90",t),...n,children:e&&p.jsx("div",{className:"bg-border z-10 flex h-4 w-3 items-center justify-center rounded-xs border",children:p.jsx(lpe,{className:"size-2.5"})})})}function $y({className:e,...t}){return p.jsx("kbd",{"data-slot":"kbd",className:De("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})}function S_e({isSearchExpanded:e,searchQuery:t,filteredNotificationsCount:n,notificationsCount:a,onSearchExpand:r,onSearchChange:i,onSearchBlur:s,onClearAll:c,searchInputRef:u}){return p.jsxs("div",{className:"flex flex-row items-center justify-between p-4 sm:p-4 py-3 gap-2",children:[p.jsx("div",{className:"flex items-center gap-2 flex-1",children:e?p.jsx(jn,{ref:u,placeholder:"Search notifications...",value:t,onChange:d=>i(d.target.value),onBlur:s,className:"h-8 border-gray-300 dark:border-zinc-600"}):p.jsxs(p.Fragment,{children:[p.jsx("h2",{className:"text-lg font-medium text-gray-900 dark:text-gray-100",children:"Notifications"}),p.jsx(Jr,{className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",variant:"outline",children:n}),p.jsxs(en,{children:[p.jsx(tn,{asChild:!0,children:p.jsx(Ue,{variant:"ghost",size:"sm",onClick:r,className:"h-8 w-8 p-0",children:p.jsx(qp,{className:"h-4 w-4"})})}),p.jsxs(nn,{side:"bottom",className:"flex gap-2",children:["Search",p.jsx($y,{children:"F"})]})]})]})}),p.jsx("div",{className:"flex items-center gap-2",children:p.jsxs(en,{children:[p.jsx(tn,{asChild:!0,children:p.jsx(Ue,{variant:"ghost",size:"sm",onClick:c,disabled:a===0,className:"h-8 w-8 p-0",children:p.jsx(Is,{className:"h-4 w-4"})})}),p.jsx(nn,{side:"bottom",children:"Clear all"})]})})]})}function Xl({id:e,isSelected:t,isFocused:n,icon:a,title:r,description:i,metadata:s,onClick:c,className:u}){return p.jsx("button",{id:e,type:"button",onClick:c,className:De("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",u),children:p.jsxs("div",{className:"flex items-start gap-2 sm:gap-3",children:[a&&p.jsx("div",{className:"flex-shrink-0 mt-1",children:p.jsx("div",{className:De("p-2.5 rounded-full transition-colors",t?"bg-zinc-500 dark:bg-zinc-100/80 text-zinc-100 dark:text-zinc-900":"bg-gray-100 dark:bg-zinc-700 text-gray-600 dark:text-gray-400 group-hover:bg-gray-200 dark:group-hover:bg-zinc-600"),children:a})}),p.jsxs("div",{className:"flex-1 min-w-0",children:[p.jsx("div",{className:"flex items-center gap-2 mb-1",children:p.jsx("h3",{className:De("font-medium truncate font-mono text-sm"),children:r})}),i&&p.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 line-clamp-2",children:i})]})]})})}function x_e({notifications:e,selectedNotification:t,onNotificationSelect:n,focusedIndex:a,formatRelativeTime:r,listRef:i}){return e.length===0?p.jsx("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:p.jsx(Yp,{vertical:!0,noBorder:!0,message:"No notifications yet"})}):p.jsx("div",{ref:i,className:"overflow-y-auto flex-1 overscroll-contain",children:e.map((s,c)=>p.jsx(Xl,{id:`notification-${s.id}`,isSelected:t?.id===s.id,isFocused:a===c,title:p.jsxs("span",{className:"flex items-center gap-3",children:[s.method,!s.read&&p.jsx("span",{className:"size-1.5 block rounded-full bg-orange-500"})]}),description:(()=>{const u=r(s.timestamp),d=s.params&&Object.keys(s.params).length>0?Object.keys(s.params).length:0,m=d>0?` | ${d} param${d>1?"s":""}`:"";return u+m})(),onClick:()=>n(s)},s.id))})}function E_e({notification:e,previewMode:t,onTogglePreview:n,onCopy:a,onDownload:r,onFullscreen:i,isCopied:s=!1,onClose:c}){return e?p.jsxs("div",{className:"flex flex-col h-full",children:[p.jsxs("div",{className:"flex-shrink-0 px-4 py-3 border-b border-gray-200 dark:border-zinc-700 flex items-center justify-between",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsxs("div",{className:"flex items-center gap-1",children:[p.jsx(ju,{className:"h-3 w-3 text-gray-400"}),p.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:new Date(e.timestamp).toLocaleTimeString()})]}),p.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:e.formatRelativeTime(e.timestamp)})]}),p.jsxs("div",{className:"flex items-center gap-1",children:[p.jsxs(Ue,{variant:"ghost",size:"sm",onClick:n,className:t?"":"text-purple-600 dark:text-purple-400",children:[t?p.jsx(P9,{className:"h-4 w-4 mr-1"}):p.jsx(M9,{className:"h-4 w-4 mr-1"}),t?"JSON":"Formatted"]}),p.jsx(Ue,{variant:"ghost",size:"sm",onClick:a,children:s?p.jsx(La,{className:"h-4 w-4"}):p.jsx(Xr,{className:"h-4 w-4"})}),p.jsx(Ue,{variant:"ghost",size:"sm",onClick:r,children:p.jsx(ny,{className:"h-4 w-4"})}),p.jsx(Ue,{variant:"ghost",size:"sm",onClick:i,children:p.jsx(tN,{className:"h-4 w-4"})}),c&&p.jsx(Ue,{variant:"ghost",size:"sm",onClick:c,children:p.jsx(Gl,{className:"h-4 w-4"})})]})]}),p.jsx("div",{className:"flex-1 overflow-y-auto",children:p.jsx("div",{className:"px-4 pt-4",children:p.jsx(ir,{data:{method:e.method,timestamp:e.timestamp,read:e.read,params:e.params},filename:`notification-${e.method.replace(/[^a-zA-Z0-9]/g,"-")}-${Date.now()}.json`})})})]}):p.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[p.jsx(JT,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),p.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"Select a notification to view details"})]})}function d_(e){const n=Date.now()-e,a=Math.floor(n/1e3),r=Math.floor(a/60),i=Math.floor(r/60),s=Math.floor(i/24);return a<60?"just now":r<60?`${r}m ago`:i<24?`${i}h ago`:s<7?`${s}d ago`:new Date(e).toLocaleDateString()}function __e({notifications:e,unreadCount:t,markNotificationRead:n,markAllNotificationsRead:a,clearNotifications:r,serverId:i,isConnected:s}){const[c,u]=x.useState(null),[d,m]=x.useState(""),[h,g]=x.useState(-1),[v,w]=x.useState(!0),[S,y]=x.useState(!1),[_,E]=x.useState(!0),[k,C]=x.useState(!1),R=x.useRef(null),A=x.useRef(null),I=x.useRef(null),O=x.useRef(!1);x.useEffect(()=>{v&&e.length>0&&R.current&&!O.current&&(R.current.scrollTop=0)},[e.length,v]),x.useEffect(()=>{const Y=R.current;if(!Y)return;const z=()=>{Y.scrollTop>0&&(O.current=!0,w(!1))};return Y.addEventListener("scroll",z),()=>Y.removeEventListener("scroll",z)},[]),x.useEffect(()=>{e.length===0&&(O.current=!1,w(!0))},[e.length]),x.useEffect(()=>{c&&!c.read&&n(c.id)},[c,n]),x.useEffect(()=>{S&&I.current&&I.current.focus()},[S]);const j=x.useCallback(()=>{d.trim()||y(!1)},[d]),F=x.useMemo(()=>{if(!d.trim())return e;const Y=d.toLowerCase();return e.filter(z=>z.method.toLowerCase().includes(Y)||JSON.stringify(z.params||{}).toLowerCase().includes(Y))},[e,d]);x.useEffect(()=>{g(-1)},[d]),x.useEffect(()=>{const Y=z=>{const te=z.target;if(te.tagName==="INPUT"||te.tagName==="TEXTAREA"||te.contentEditable==="true"||z.metaKey||z.ctrlKey||z.altKey)return;const $=F;if(z.key==="ArrowDown")z.preventDefault(),g(B=>{const U=B+1;return U>=$.length?0:U});else if(z.key==="ArrowUp")z.preventDefault(),g(B=>{const U=B-1;return U<0?$.length-1:U});else if(z.key==="Enter"&&h>=0){z.preventDefault();const B=F[h];B&&H(B)}};return document.addEventListener("keydown",Y),()=>document.removeEventListener("keydown",Y)},[h,F]),x.useEffect(()=>{if(h>=0){const Y=`notification-${F[h]?.id}`,z=document.getElementById(Y);z&&z.scrollIntoView({behavior:"smooth",block:"nearest"})}},[h,F]);const H=x.useCallback(Y=>{u(Y)},[]),K=x.useCallback(()=>{window.confirm("Are you sure you want to clear all notifications? This cannot be undone.")&&(r(),u(null))},[r]),Q=x.useCallback(async()=>{if(c)try{await navigator.clipboard.writeText(JSON.stringify({method:c.method,timestamp:c.timestamp,read:c.read,params:c.params},null,2)),C(!0),setTimeout(()=>C(!1),2e3)}catch(Y){console.error("[NotificationsTab] Failed to copy notification:",Y)}},[c]),W=x.useCallback(()=>{if(c)try{const Y=new globalThis.Blob([JSON.stringify({method:c.method,timestamp:c.timestamp,read:c.read,params:c.params},null,2)],{type:"application/json"}),z=URL.createObjectURL(Y),te=document.createElement("a");te.href=z,te.download=`notification-${Date.now()}.json`,document.body.appendChild(te),te.click(),document.body.removeChild(te),URL.revokeObjectURL(z)}catch(Y){console.error("[NotificationsTab] Failed to download notification:",Y)}},[c]),ie=x.useCallback(async()=>{if(A.current)try{document.fullscreenElement?await document.exitFullscreen():await A.current.requestFullscreen()}catch(Y){console.error("[NotificationsTab] Failed to toggle fullscreen:",Y)}},[]),V=c?{method:c.method,params:c.params,timestamp:c.timestamp,read:c.read,formatRelativeTime:d_}:null;return s?p.jsxs(Da,{direction:"horizontal",className:"h-full",children:[p.jsx(zn,{defaultSize:40,minSize:30,children:p.jsx(Da,{direction:"vertical",className:"h-full border-r dark:border-zinc-700",children:p.jsxs(zn,{defaultSize:75,minSize:30,children:[p.jsx(S_e,{isSearchExpanded:S,searchQuery:d,filteredNotificationsCount:F.length,notificationsCount:e.length,onSearchExpand:()=>y(!0),onSearchChange:m,onSearchBlur:j,onClearAll:K,searchInputRef:I}),p.jsx("div",{className:"flex flex-col h-full",children:p.jsx(x_e,{notifications:F,selectedNotification:c,onNotificationSelect:H,focusedIndex:h,formatRelativeTime:d_,listRef:R})})]})})}),p.jsx(Ui,{}),p.jsx(zn,{defaultSize:60,minSize:40,children:p.jsx("div",{ref:A,className:"h-full bg-white dark:bg-zinc-900",children:p.jsx(E_e,{notification:V,previewMode:_,onTogglePreview:()=>E(!_),onCopy:Q,onDownload:W,onFullscreen:ie,onClose:()=>u(null),isCopied:k})})})]}):p.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[p.jsx(JT,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),p.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"Not connected to server"})]})}function WK({activeTab:e,isSearchExpanded:t,searchQuery:n,primaryTabTitle:a,secondaryTabTitle:r,primaryCount:i,secondaryCount:s,secondaryIcon:c,primaryIcon:u,searchPlaceholder:d="Search...",onSearchExpand:m,onSearchChange:h,onSearchBlur:g,onTabSwitch:v,searchInputRef:w,primaryTabName:S}){const y=e===S;return p.jsxs("div",{className:"flex flex-row items-center justify-between p-4 sm:p-4 py-3 gap-2",children:[p.jsx("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:t?p.jsx(jn,{ref:w,placeholder:d,value:n,onChange:_=>h(_.target.value),onBlur:g,className:"h-8 border-gray-300 dark:border-zinc-600"}):p.jsxs(p.Fragment,{children:[p.jsx("h2",{className:"text-lg font-medium text-gray-900 dark:text-gray-100",children:y?a:r}),y&&p.jsxs(p.Fragment,{children:[p.jsx(Jr,{className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",variant:"outline",children:i}),p.jsxs(en,{children:[p.jsx(tn,{asChild:!0,children:p.jsx(Ue,{variant:"ghost",size:"sm",onClick:m,className:"h-8 w-8 p-0",children:p.jsx(qp,{className:"h-4 w-4"})})}),p.jsxs(nn,{side:"bottom",className:"flex gap-2",children:["Search",p.jsx($y,{children:"F"})]})]})]})]})}),p.jsxs(Ue,{variant:"ghost",size:"sm",onClick:v,className:"gap-2 flex-shrink-0",children:[y?p.jsx(c,{}):p.jsx(u,{}),p.jsx("span",{className:"hidden sm:inline",children:y?r:a}),y&&s>0&&p.jsx(Jr,{className:"bg-purple-500/20 text-purple-600 dark:text-purple-400 border-transparent",variant:"outline",children:s})]})]})}function $4({prompts:e,selectedPrompt:t,onPromptSelect:n,focusedIndex:a}){return e.length===0?p.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[p.jsx(ip,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),p.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"No prompts available"})]}):p.jsx("div",{className:"overflow-y-auto flex-1 border-r dark:border-zinc-700 overscroll-contain",children:e.map((r,i)=>p.jsx(Xl,{id:`prompt-${r.name}`,isSelected:t?.name===r.name,isFocused:a===i,icon:p.jsx(ip,{className:"h-4 w-4"}),title:r.name,description:r.description,metadata:r.arguments&&r.arguments.length>0&&p.jsxs(Jr,{variant:"outline",className:"text-xs border-gray-300 dark:border-zinc-600 text-gray-600 dark:text-gray-400",children:[r.arguments.length," args"]}),onClick:()=>n(r)},r.name))})}function j4({activeTab:e,isSearchExpanded:t,searchQuery:n,filteredPromptsCount:a,savedPromptsCount:r,onSearchExpand:i,onSearchChange:s,onSearchBlur:c,onTabSwitch:u,searchInputRef:d}){return p.jsx(WK,{activeTab:e,isSearchExpanded:t,searchQuery:n,primaryTabName:"prompts",secondaryTabName:"saved",primaryTabTitle:"Prompts",secondaryTabTitle:"History",primaryCount:a,secondaryCount:r,primaryIcon:ip,secondaryIcon:ju,searchPlaceholder:"Search prompts...",onSearchExpand:i,onSearchChange:s,onSearchBlur:c,onTabSwitch:u,searchInputRef:d})}function M4({savedPrompts:e,selectedPrompt:t,onLoadPrompt:n,onDeletePrompt:a,focusedIndex:r}){return e.length===0?p.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[p.jsx(ju,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),p.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"No history"}),p.jsx("p",{className:"text-sm text-gray-400 dark:text-gray-500 mt-1",children:"Prompts you execute will appear here"})]}):p.jsx("div",{className:"overflow-y-auto flex-1 border-r dark:border-zinc-700 overscroll-contain",children:e.map((i,s)=>p.jsx(Xl,{id:`saved-prompt-${i.id}`,isSelected:t?.id===i.id,isFocused:r===s,icon:p.jsx(ju,{className:"h-4 w-4"}),title:i.name,description:`${i.promptName} - ${new Date(i.savedAt).toLocaleString()}`,onClick:()=>n(i)},i.id))})}function k_e({selectedPrompt:e,promptArgs:t,onArgChange:n}){const a=e?.arguments||[];if(!(a.length>0))return p.jsx("div",{className:"flex items-center justify-center h-32 text-gray-500 dark:text-gray-400 text-sm",children:"No arguments required"});const i=s=>{const c=s.name,u=t[c],d=typeof u=="string"?u:JSON.stringify(u);return s.type==="boolean"?p.jsxs("div",{className:"space-y-2",children:[p.jsxs(Yt,{htmlFor:c,className:"text-sm font-medium",children:[c,s.required&&p.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),p.jsxs("div",{className:"flex items-center space-x-2",children:[p.jsx("input",{id:c,type:"checkbox",checked:!!u,onChange:m=>n(c,m.target.checked),className:"rounded","aria-label":`Toggle ${c}`}),p.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:s.description})]})]},c):s.type==="number"?p.jsxs("div",{className:"space-y-2",children:[p.jsxs(Yt,{htmlFor:c,className:"text-sm font-medium",children:[c,s.required&&p.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),p.jsx(jn,{id:c,type:"number",value:Number(u)||0,onChange:m=>n(c,Number(m.target.value)),placeholder:s.description||`Enter ${c}`}),s.description&&p.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:s.description})]},c):s.type==="array"||s.type==="object"?p.jsxs("div",{className:"space-y-2",children:[p.jsxs(Yt,{htmlFor:c,className:"text-sm font-medium",children:[c,s.required&&p.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),p.jsx(zu,{id:c,value:d,onChange:m=>{try{const h=JSON.parse(m.target.value);n(c,h)}catch{n(c,m.target.value)}},placeholder:s.description||`Enter ${c} as JSON`,className:"font-mono text-sm min-h-[100px]"}),s.description&&p.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:s.description})]},c):p.jsxs("div",{className:"space-y-2",children:[p.jsxs(Yt,{htmlFor:c,className:"text-sm font-medium",children:[c,s.required&&p.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),p.jsx(jn,{id:c,value:d,onChange:m=>n(c,m.target.value),placeholder:s.description||`Enter ${c}`}),s.description&&p.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:s.description})]},c)};return p.jsx("div",{className:"space-y-4",children:a.map(s=>i(s))})}function P4({selectedPrompt:e,promptArgs:t,isExecuting:n,isConnected:a,onArgChange:r,onExecute:i,onSave:s}){return e?p.jsxs("div",{className:"flex flex-col h-full",children:[p.jsx("div",{className:"flex-shrink-0 p-3 sm:p-6 pt-3 pb-4 pr-3",children:p.jsxs("div",{children:[p.jsxs("div",{className:"flex flex-row items-center justify-between mb-0 gap-2",children:[p.jsx("h3",{className:"text-base sm:text-lg font-semibold",children:e.name}),p.jsxs("div",{className:"flex gap-2 flex-shrink-0",children:[p.jsx(Ue,{onClick:i,disabled:n||!a,size:"sm",className:"lg:size-default",children:n?p.jsxs(p.Fragment,{children:[p.jsx(Lo,{className:"mr-2"}),p.jsx("span",{className:"hidden sm:inline",children:"Executing..."})]}):p.jsxs(p.Fragment,{children:[p.jsx(H9,{className:"h-4 w-4 sm:mr-2"}),p.jsx("span",{className:"hidden sm:inline",children:"Execute"})]})}),p.jsxs(Ue,{variant:"outline",onClick:s,disabled:n,size:"sm",className:"lg:size-default gap-2",children:[p.jsx(nN,{className:"h-4 w-4"}),p.jsx("span",{className:"hidden sm:inline",children:"Save"})]})]})]}),e.description&&p.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 leading-relaxed mt-2",children:e.description})]})}),p.jsx("div",{className:"flex-1 overflow-y-auto px-3 sm:px-6 pb-4 pr-3",children:p.jsx(k_e,{selectedPrompt:e,promptArgs:t,onArgChange:r})})]}):p.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[p.jsx("p",{className:"text-gray-500 dark:text-gray-400 mb-2",children:"Select a prompt to get started"}),p.jsx("p",{className:"text-xs text-gray-400 dark:text-gray-500",children:"Choose a prompt from the list to view its details and execute it"})]})}function U4({results:e,copiedResult:t,onCopy:n}){return p.jsx("div",{className:"flex flex-col h-full bg-white dark:bg-black border-t dark:border-zinc-700",children:p.jsx("div",{className:"flex-1 overflow-y-auto h-full",children:e.length>0?p.jsx("div",{className:"space-y-4 flex-1 h-full",children:e.map((a,r)=>p.jsxs("div",{className:"space-y-0 flex-1 h-full flex flex-col",children:[p.jsxs("div",{className:"flex items-center gap-2 px-4 pt-2 border-b border-gray-200 dark:border-zinc-600 pb-2",children:[p.jsx("h3",{className:"text-sm font-medium",children:"Response"}),p.jsxs("div",{className:"flex items-center gap-1",children:[p.jsx(ju,{className:"h-3 w-3 text-gray-400"}),p.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:new Date(a.timestamp).toLocaleTimeString()})]}),a.duration!==void 0&&p.jsxs("div",{className:"flex items-center gap-1",children:[p.jsx(op,{className:"h-3 w-3 text-gray-400"}),p.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:[a.duration,"ms"]})]}),p.jsx("div",{className:"flex gap-2 ml-auto",children:p.jsx(Ue,{variant:"ghost",size:"sm",onClick:()=>n(r,a.result),className:"h-6 px-2",children:t===r?p.jsx(La,{className:"h-4 w-4"}):p.jsx(Xr,{className:"h-4 w-4"})})})]}),a.error?p.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded p-3 mx-4",children:[p.jsx("p",{className:"text-red-800 dark:text-red-300 font-medium",children:"Error:"}),p.jsx("p",{className:"text-red-700 dark:text-red-400 text-sm",children:a.error})]}):p.jsx("div",{className:"px-4 pt-4",children:p.jsx(ir,{data:a.result,filename:`prompt-result-${a.promptName}-${Date.now()}.json`})})]},r))}):p.jsx("div",{className:"flex items-center justify-center h-full",children:p.jsx("div",{className:"text-center",children:p.jsx(Yp,{vertical:!0,noBorder:!0,message:"No Results yet"})})})})})}function TO({serverIds:e,onCountChange:t,onClearRef:n}={}){const[a,r]=x.useState([]),i=x.useRef(null),[s,c]=x.useState(new Set),[u]=x.useState(""),d=v=>{c(w=>{const S=new Set(w);return S.has(v)?S.delete(v):S.add(v),S})},m=async()=>{r([]),c(new Set),t?.(0);try{const v=new URLSearchParams;e&&e.length>0&&v.set("serverIds",e.join(","));const w=await fetch(`/inspector/api/rpc/log?${v.toString()}`,{method:"DELETE"});w.ok||console.warn("[RPC Logger] Failed to clear server buffer:",w.status)}catch(v){console.warn("[RPC Logger] Error clearing server buffer:",v)}},h=x.useMemo(()=>!e||e.length===0?"":[...e].sort().join(","),[e]);x.useEffect(()=>(n&&(n.current=m),()=>{n&&(n.current=null)}),[n,m]),x.useEffect(()=>{t?.(a.length)},[a.length,t]),x.useEffect(()=>{let v=null;try{const w=new URLSearchParams;w.set("replay","3"),w.set("_t",Date.now().toString()),e&&e.length>0&&w.set("serverIds",e.join(","));const S=`/inspector/api/rpc/stream?${w.toString()}`;console.log("[RPC Logger] Connecting to SSE stream:",S),v=new globalThis.EventSource(S),v.onopen=()=>{console.log("[RPC Logger] SSE connection opened")},v.onmessage=y=>{try{const _=JSON.parse(y.data);if(!_||_.type!=="rpc")return;const{serverId:E,direction:k,message:C,timestamp:R}=_,A=C,I=typeof A?.method=="string"?A.method:A?.result!==void 0?"result":A?.error!==void 0?"error":"unknown",O={id:`${R??Date.now()}-${Math.random().toString(36).slice(2)}`,serverId:typeof E=="string"?E:"unknown",direction:typeof k=="string"?k.toUpperCase():"",method:I,timestamp:R??new Date().toISOString(),payload:C};console.log("[RPC Logger] Received RPC event:",{method:I,direction:k,serverId:E}),r(j=>{const F=[O,...j].slice(0,1e3);return t?.(F.length),F})}catch(_){console.error("[RPC Logger] Error parsing SSE message:",_)}},v.onerror=y=>{console.error("[RPC Logger] SSE connection error:",y);try{v?.close()}catch{}}}catch(w){console.error("[RPC Logger] Failed to create SSE connection:",w)}return()=>{try{v?.close(),console.log("[RPC Logger] SSE connection closed")}catch{}}},[h]);const g=x.useMemo(()=>{let v=a;if(e&&e.length>0){const w=new Set(e);v=v.filter(S=>w.has(S.serverId))}if(u.trim()){const w=u.toLowerCase();v=v.filter(S=>S.serverId.toLowerCase().includes(w)||S.method.toLowerCase().includes(w)||S.direction.toLowerCase().includes(w)||JSON.stringify(S.payload).toLowerCase().includes(w))}return v},[a,u,e]);return p.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:p.jsx("div",{ref:i,className:"flex-1 min-h-0 overflow-y-auto",children:g.length===0?p.jsxs("div",{className:"text-center py-8",children:[p.jsx("div",{className:"text-xs text-muted-foreground",children:"No messages yet"}),p.jsx("div",{className:"text-[10px] text-muted-foreground mt-1",children:"JSON-RPC messages will appear here"})]}):g.map(v=>{const w=s.has(v.id);return p.jsxs("div",{className:"group hover:bg-muted/50 transition-all duration-200 overflow-hidden",children:[p.jsxs("div",{className:"px-3 py-2 flex items-center gap-2 cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>d(v.id),children:[p.jsx("div",{className:"flex-shrink-0",children:w?p.jsx(Vl,{className:"h-3 w-3 text-muted-foreground transition-transform"}):p.jsx(Cfe,{className:"h-3 w-3 text-muted-foreground transition-transform"})}),p.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[p.jsx("span",{className:"text-muted-foreground font-mono text-xs",children:new Date(v.timestamp).toLocaleTimeString()}),p.jsx("span",{className:`flex items-center justify-center px-1 py-0.5 rounded ${v.direction==="RECEIVE"?"bg-blue-500/10 text-blue-600 dark:text-blue-400":"bg-green-500/10 text-green-600 dark:text-green-400"}`,title:v.direction==="RECEIVE"?"Incoming":"Outgoing",children:v.direction==="RECEIVE"?p.jsx(bfe,{className:"h-3 w-3"}):p.jsx(yfe,{className:"h-3 w-3"})}),p.jsx("span",{className:"text-xs font-mono text-foreground truncate",children:v.method})]})]}),w&&p.jsx("div",{className:"border-t bg-muted/20",children:p.jsx("div",{className:"p-3",children:p.jsx("div",{className:"max-h-[40vh] overflow-auto rounded-sm bg-background/60 p-2",children:p.jsx(ir,{data:v.payload})})})})]},v.id)})})})}const z4="mcp-inspector-saved-prompts";function KK({ref:e,prompts:t,callPrompt:n,serverId:a,isConnected:r}){const[i,s]=x.useState(null),[c,u]=x.useState(null),{selectedPromptName:d,setSelectedPromptName:m}=ld(),[h,g]=x.useState({}),[v,w]=x.useState([]),[S,y]=x.useState(!1),[_,E]=x.useState(null),[k,C]=x.useState(""),[R,A]=x.useState("prompts"),[I,O]=x.useState([]),[j,F]=x.useState(!1),[H,K]=x.useState(""),[Q,W]=x.useState(!1),[ie,V]=x.useState(-1),Y=x.useRef(null),[z,te]=x.useState(!1),[re,$]=x.useState("list"),[B,U]=x.useState(0),[L,P]=x.useState(!0),G=x.useRef(null),Z=x.useRef(null);x.useEffect(()=>{const _e=()=>{te(window.innerWidth<1024)};return _e(),window.addEventListener("resize",_e),()=>window.removeEventListener("resize",_e)},[]),x.useEffect(()=>{$(i?"detail":"list")},[i]),x.useEffect(()=>{z&&v.length>0&&!S&&$("response")},[v,S,z]),x.useImperativeHandle(e,()=>({focusSearch:()=>{W(!0),setTimeout(()=>{Y.current&&Y.current.focus()},0)},blurSearch:()=>{C(""),W(!1),Y.current&&Y.current.blur()}})),x.useEffect(()=>{try{const _e=localStorage.getItem(z4);if(_e){const Se=JSON.parse(_e);O(Se)}}catch(_e){console.error("[PromptsTab] Failed to load saved prompts:",_e)}},[]);const J=x.useCallback(_e=>{try{localStorage.setItem(z4,JSON.stringify(_e))}catch(Se){console.error("[PromptsTab] Failed to save prompts:",Se)}},[]);x.useEffect(()=>{Q&&Y.current&&Y.current.focus()},[Q]);const se=x.useCallback(()=>{k.trim()||W(!1)},[k]),le=x.useMemo(()=>{if(!k.trim())return t;const _e=k.toLowerCase();return t.filter(Se=>Se.name.toLowerCase().includes(_e)||Se.description?.toLowerCase().includes(_e))},[t,k]),ee=x.useCallback(_e=>{s(_e);const Se={};_e.arguments&&_e.arguments.forEach(ze=>{ze.default!==void 0?Se[ze.name]=ze.default:ze.type==="string"?Se[ze.name]="":ze.type==="number"?Se[ze.name]=0:ze.type==="boolean"?Se[ze.name]=!1:ze.type==="array"?Se[ze.name]=[]:ze.type==="object"&&(Se[ze.name]={})}),g(Se)},[]),ne=x.useCallback(_e=>{const Se=t.find(ze=>ze.name===_e.promptName);Se&&(s(Se),g(_e.args),u(_e))},[t]);x.useEffect(()=>{V(-1)},[k,R]),x.useEffect(()=>{const _e=Se=>{const ze=Se.target;if(ze.tagName==="INPUT"||ze.tagName==="TEXTAREA"||ze.contentEditable==="true"||Se.metaKey||Se.ctrlKey||Se.altKey)return;const Le=R==="prompts"?le:I;if(Se.key==="ArrowDown")Se.preventDefault(),V(Fe=>{const xe=Fe+1;return xe>=Le.length?0:xe});else if(Se.key==="ArrowUp")Se.preventDefault(),V(Fe=>{const xe=Fe-1;return xe<0?Le.length-1:xe});else if(Se.key==="Enter"&&ie>=0)if(Se.preventDefault(),R==="prompts"){const Fe=le[ie];Fe&&ee(Fe)}else{const Fe=I[ie];Fe&&ne(Fe)}};return document.addEventListener("keydown",_e),()=>document.removeEventListener("keydown",_e)},[ie,le,I,R,ee,ne]),x.useEffect(()=>{if(ie>=0){const _e=R==="prompts"?`prompt-${le[ie]?.name}`:`saved-prompt-${I[ie]?.id}`,Se=document.getElementById(_e);Se&&Se.scrollIntoView({behavior:"smooth",block:"nearest"})}},[ie,le,I,R]),x.useEffect(()=>{if(console.warn("[PromptsTab] Auto-selection effect triggered:",{selectedPromptName:d,promptsCount:t.length,currentSelectedPrompt:i?.name}),d&&t.length>0){const _e=t.find(Se=>Se.name===d);if(console.warn("[PromptsTab] Prompt lookup result:",{selectedPromptName:d,promptFound:!!_e,promptName:_e?.name,shouldSelect:_e&&i?.name!==_e.name}),_e&&i?.name!==_e.name){console.warn("[PromptsTab] Selecting prompt:",_e.name),m(null);const Se=setTimeout(()=>{ee(_e);const ze=document.getElementById(`prompt-${_e.name}`);ze&&(console.warn("[PromptsTab] Scrolling to prompt element"),ze.scrollIntoView({behavior:"smooth",block:"nearest"}))},100);return()=>clearTimeout(Se)}}},[d,t,i,ee,m]);const ce=x.useCallback((_e,Se)=>{g(ze=>({...ze,[_e]:Se}))},[]),ae=x.useCallback(async()=>{if(!i||S)return;y(!0);const _e=Date.now();try{const Se=await n(i.name,h),ze=Date.now()-_e;br.getInstance().capture(new tU({promptName:i.name,serverId:a,success:!0})).catch(()=>{}),w(Le=>[{promptName:i.name,args:h,result:Se,timestamp:_e,duration:ze},...Le])}catch(Se){br.getInstance().capture(new tU({promptName:i.name,serverId:a,success:!1,error:Se instanceof Error?Se.message:"Unknown error"})).catch(()=>{});const pe={promptName:i.name,args:h,result:null,error:Se instanceof Error?Se.message:String(Se),timestamp:_e,duration:Date.now()-_e};w(Le=>[pe,...Le])}finally{y(!1)}},[i,h,S,n,a]),ye=x.useCallback(async(_e,Se)=>{try{await navigator.clipboard.writeText(JSON.stringify(Se,null,2)),E(_e),setTimeout(()=>E(null),2e3)}catch(ze){console.error("[PromptsTab] Failed to copy result:",ze)}},[]),ke=x.useCallback(()=>{i&&(K(""),F(!0))},[i]),Be=x.useCallback(_e=>{J(I.filter(Se=>Se.id!==_e)),c?.id===_e&&u(null)},[I,J,c]);return z?p.jsxs("div",{className:"h-full flex flex-col overflow-hidden relative bg-background",children:[re!=="list"&&p.jsxs("div",{className:"flex items-center gap-2 p-2 border-b shrink-0 bg-background z-10",children:[p.jsx(Ue,{variant:"ghost",size:"sm",onClick:()=>{re==="response"?$("detail"):(s(null),$("list"))},className:"p-0 h-8 w-8",children:p.jsx(QT,{className:"h-4 w-4"})}),p.jsxs("div",{className:"flex items-center text-sm font-medium",children:[p.jsx("button",{onClick:()=>{s(null),$("list")},className:"text-muted-foreground hover:text-foreground hover:underline cursor-pointer",children:"Prompts"}),re!=="list"&&p.jsxs(p.Fragment,{children:[p.jsx("span",{className:"mx-2 text-muted-foreground",children:"/"}),p.jsx("button",{onClick:()=>{re==="response"&&$("detail")},className:re==="detail"?"text-foreground hover:underline":re==="response"?"text-muted-foreground hover:text-foreground hover:underline cursor-pointer":"text-muted-foreground",children:"Execute"})]}),re==="response"&&p.jsxs(p.Fragment,{children:[p.jsx("span",{className:"mx-2 text-muted-foreground",children:"/"}),p.jsx("span",{className:"text-foreground",children:"Response"})]})]})]}),p.jsx("div",{className:"flex-1 relative overflow-hidden",children:p.jsxs(ly,{initial:!1,mode:"popLayout",children:[re==="list"&&p.jsxs(ma.div,{initial:{x:"-100%"},animate:{x:0},exit:{x:"-100%"},transition:{type:"spring",stiffness:300,damping:30},className:"absolute inset-0 flex flex-col bg-background z-0",children:[p.jsx(j4,{activeTab:R,isSearchExpanded:Q,searchQuery:k,filteredPromptsCount:le.length,savedPromptsCount:I.length,onSearchExpand:()=>W(!0),onSearchChange:C,onSearchBlur:se,onTabSwitch:()=>A(R==="prompts"?"saved":"prompts"),searchInputRef:Y}),R==="prompts"?p.jsx($4,{prompts:le,selectedPrompt:i,onPromptSelect:ee,focusedIndex:ie}):p.jsx(M4,{savedPrompts:I,selectedPrompt:c,onLoadPrompt:ne,onDeletePrompt:Be,focusedIndex:ie})]},"list"),re==="detail"&&p.jsx(ma.div,{initial:{x:"100%"},animate:{x:0},exit:{x:"-100%"},transition:{type:"spring",stiffness:300,damping:30},className:"absolute inset-0 bg-background z-10",children:p.jsx(P4,{selectedPrompt:i,promptArgs:h,isExecuting:S,isConnected:r,onArgChange:ce,onExecute:ae,onSave:ke})},"detail"),re==="response"&&p.jsx(ma.div,{initial:{x:"100%"},animate:{x:0},exit:{x:"100%"},transition:{type:"spring",stiffness:300,damping:30},className:"absolute inset-0 bg-background z-20",children:p.jsx(U4,{results:v,copiedResult:_,onCopy:ye})},"response")]})})]}):p.jsxs(Da,{direction:"horizontal",className:"h-full",children:[p.jsx(zn,{defaultSize:33,className:"flex flex-col h-full relative",children:p.jsxs(Da,{direction:"vertical",className:"h-full border-r dark:border-zinc-700",children:[p.jsx(zn,{defaultSize:75,minSize:30,children:p.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[p.jsx(j4,{activeTab:R,isSearchExpanded:Q,searchQuery:k,filteredPromptsCount:le.length,savedPromptsCount:I.length,onSearchExpand:()=>W(!0),onSearchChange:C,onSearchBlur:se,onTabSwitch:()=>A(R==="prompts"?"saved":"prompts"),searchInputRef:Y}),R==="prompts"?p.jsx($4,{prompts:le,selectedPrompt:i,onPromptSelect:ee,focusedIndex:ie}):p.jsx(M4,{savedPrompts:I,selectedPrompt:c,onLoadPrompt:ne,onDeletePrompt:Be,focusedIndex:ie})]})}),p.jsx(Ui,{withHandle:!0}),p.jsxs(zn,{ref:G,defaultSize:0,collapsible:!0,minSize:5,collapsedSize:5,onCollapse:()=>P(!0),onExpand:()=>P(!1),className:"flex flex-col border-t dark:border-zinc-700",children:[p.jsxs("div",{className:"group flex items-center justify-between p-3 shrink-0 cursor-pointer hover:bg-muted/50 transition-colors",onClick:_e=>{_e.preventDefault(),_e.stopPropagation(),L?(G.current?.resize(25),P(!1)):(G.current?.resize(5),P(!0))},children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx("h3",{className:"text-sm font-medium",children:"RPC Messages"}),B>0&&p.jsx(Jr,{variant:"secondary",className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",children:B}),B>0&&!L&&p.jsx(Ue,{variant:"ghost",size:"sm",onClick:_e=>{_e.preventDefault(),_e.stopPropagation(),Z.current?.()},className:"h-6 w-6 p-0",title:"Clear all messages",children:p.jsx(Is,{className:"h-3.5 w-3.5"})})]}),p.jsx(Vl,{className:`h-4 w-4 text-muted-foreground transition-transform ${L?"rotate-180":""}`})]}),!L&&p.jsx("div",{className:"flex-1 overflow-hidden min-h-0",children:p.jsx(TO,{serverIds:[a],onCountChange:U,onClearRef:Z})})]})]})}),p.jsx(Ui,{withHandle:!0}),p.jsx(zn,{defaultSize:67,children:p.jsxs(Da,{direction:"vertical",children:[p.jsx(zn,{defaultSize:40,children:p.jsx(P4,{selectedPrompt:i,promptArgs:h,isExecuting:S,isConnected:r,onArgChange:ce,onExecute:ae,onSave:ke})}),p.jsx(Ui,{withHandle:!0}),p.jsx(zn,{defaultSize:50,children:p.jsx("div",{className:"flex flex-col h-full",children:p.jsx(U4,{results:v,copiedResult:_,onCopy:ye})})})]})})]})}KK.displayName="PromptsTab";function hu(e){if(!e?.mimeType)return!1;const t=e.mimeType.toLowerCase();return t==="text/html"||t==="text/html+skybridge"||t==="text/uri-list"||t.startsWith("application/vnd.mcp-ui.remote-dom")}function T_e(e){return{uri:e.uri,mimeType:e.mimeType,text:e.text,blob:e.blob}}function ZK({resource:e,onUIAction:t,className:n}){const a=async i=>t?.(i),r=T_e(e);return p.jsx("div",{className:n,children:p.jsx(xO,{resource:r,onUIAction:a,htmlProps:{autoResizeIframe:{width:!0,height:!0},style:{width:"100%",minHeight:"200px"},sandboxPermissions:"allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox"},remoteDomProps:{remoteElements:[PEe,MEe,UEe,zEe],library:SO}})})}function F4({result:e,isLoading:t,previewMode:n,serverId:a,readResource:r,onTogglePreview:i,onCopy:s,onDownload:c,onFullscreen:u,isCopied:d=!1}){let m=[],h;if(e?.resourceAnnotations&&(m=Object.keys(e.resourceAnnotations).filter(S=>S.startsWith("openai/")),h=e.resourceAnnotations["openai/outputTemplate"]),e?.result?.contents?.[0]?._meta){const S=e.result.contents[0]._meta,y=Object.keys(S).filter(_=>_.startsWith("openai/"));y.length>0&&(m=[...m,...y]),!h&&S["openai/outputTemplate"]&&(h=S["openai/outputTemplate"]),!h&&e.uri&&e.uri.startsWith("ui://widget/")&&(h=e.uri)}const g=!!(m.length>0&&h&&typeof h=="string"&&a&&r);if(t)return p.jsx("div",{className:"flex absolute left-0 top-0 items-center justify-center w-full h-full",children:p.jsx(Lo,{className:"size-5"})});if(!e)return p.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[p.jsx("p",{className:"text-gray-500 dark:text-gray-400 mb-2",children:"Select a resource to view its contents"}),p.jsx("p",{className:"text-xs text-gray-400 dark:text-gray-500",children:"Choose a resource from the list to see its data"})]});if(e.error)return p.jsx("div",{className:"p-4",children:p.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded p-3",children:[p.jsx("p",{className:"text-red-800 dark:text-red-300 font-medium",children:"Error:"}),p.jsx("p",{className:"text-red-700 dark:text-red-400 text-sm",children:e.error})]})});const v=e?.result?.contents&&Array.isArray(e.result.contents)&&e.result.contents.some(S=>S.mimeType&&hu(S)),w=v?e.result.contents.filter(S=>S.mimeType&&hu(S)):[];return p.jsxs("div",{className:"flex flex-col h-full",children:[p.jsxs("div",{className:"flex-shrink-0 px-4 py-3 border-b border-gray-200 dark:border-zinc-700 flex items-center justify-between",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsxs("div",{className:"flex items-center gap-1",children:[p.jsx(ju,{className:"h-3 w-3 text-gray-400"}),p.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:new Date(e.timestamp).toLocaleTimeString()})]}),(()=>{const S=e?.duration??e.result?.duration??e.result?.metrics?.durationMs;return S!==void 0?p.jsxs("div",{className:"flex items-center gap-1",children:[p.jsx(op,{className:"h-3 w-3 text-gray-400"}),p.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:[S,"ms"]})]}):null})(),v&&p.jsx(Jr,{variant:"outline",className:"text-xs bg-purple-50 dark:bg-purple-900/20 border-none border-purple-200 dark:border-purple-800/50 text-purple-600 dark:text-purple-400",children:"MCP UI"}),g&&p.jsx(Jr,{variant:"outline",className:"text-xs bg-blue-50 dark:bg-blue-900/20 border-none border-blue-200 dark:border-blue-800/50 text-blue-600 dark:text-blue-400",children:"OpenAI Widget"})]}),p.jsxs("div",{className:"flex items-center gap-1",children:[(v||g)&&p.jsxs(Ue,{variant:"ghost",size:"sm",onClick:i,className:n?"":"text-purple-600 dark:text-purple-400",children:[n?p.jsx(P9,{className:"h-4 w-4 mr-1"}):p.jsx(M9,{className:"h-4 w-4 mr-1"}),n?"JSON":g?"Component":"Preview"]}),p.jsx(Ue,{variant:"ghost",size:"sm",onClick:s,children:d?p.jsx(La,{className:"h-4 w-4"}):p.jsx(Xr,{className:"h-4 w-4"})}),p.jsx(Ue,{variant:"ghost",size:"sm",onClick:c,children:p.jsx(ny,{className:"h-4 w-4"})}),p.jsx(Ue,{variant:"ghost",size:"sm",onClick:u,children:p.jsx(tN,{className:"h-4 w-4"})})]})]}),p.jsx("div",{className:"flex-1 overflow-y-auto",children:g&&a&&r&&h?n?p.jsx("div",{className:"flex-1 h-full",children:p.jsx(gO,{componentUrl:h,toolName:e.uri,toolArgs:{},toolResult:e.result,serverId:a,readResource:r,className:"w-full h-full relative flex p-4"})}):p.jsx("div",{className:"px-4 pt-4",children:p.jsx(ir,{data:e.result,filename:`resource-${e.uri.replace(/[^a-zA-Z0-9]/g,"-")}-${Date.now()}.json`})}):v?n?p.jsxs("div",{className:"space-y-0 h-full",children:[w.map((S,y)=>p.jsx("div",{className:"mx-0 size-full",children:p.jsx("div",{className:"w-full h-full",children:p.jsx(ZK,{resource:S,className:"w-full h-full"})})},`mcp-ui-${S.uri||`resource-${Date.now()}-${Math.random()}`}`)),(()=>{if(e.result.contents&&Array.isArray(e.result.contents)){const S=e.result.contents.filter(y=>!(y.mimeType&&hu(y)));if(S.length>0)return p.jsx("div",{className:"px-4",children:p.jsx(ir,{data:S,filename:`resource-${e.uri.replace(/[^a-zA-Z0-9]/g,"-")}-non-ui-${Date.now()}.json`})})}return null})()]}):p.jsx("div",{className:"px-4 pt-4",children:p.jsx(ir,{data:e.result,filename:`resource-${e.uri.replace(/[^a-zA-Z0-9]/g,"-")}-mcp-ui-${Date.now()}.json`})}):p.jsx("div",{className:"px-4 pt-4",children:p.jsx(ir,{data:e.result,filename:`resource-${e.uri.replace(/[^a-zA-Z0-9]/g,"-")}-${Date.now()}.json`})})})]})}function N_e(e,t){if(!e&&!t)return p.jsx(npe,{className:"h-5 w-5"});const n=(e||t||"").toLowerCase();return n.includes("image")?p.jsx(Qfe,{className:"h-5 w-5"}):n.includes("json")||n.includes("javascript")||n.includes("typescript")?p.jsx(qfe,{className:"h-5 w-5"}):n.includes("html")||n.includes("xml")?p.jsx(ope,{className:"h-5 w-5"}):n.includes("database")||n.includes("sql")?p.jsx(ty,{className:"h-5 w-5"}):p.jsx(eN,{className:"h-5 w-5"})}function B4({resources:e,selectedResource:t,onResourceSelect:n,focusedIndex:a}){return e.length===0?p.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[p.jsx(ty,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),p.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"No resources available"})]}):p.jsx("div",{className:"overflow-y-auto flex-1 overscroll-contain",children:e.map((r,i)=>{const s=N_e(r.mimeType,r.uri),c=[r.description,r.mimeType&&p.jsx("span",{className:"font-mono",children:r.mimeType},"mime")].filter(Boolean);return p.jsx(Xl,{id:`resource-${r.uri}`,isSelected:t?.uri===r.uri,isFocused:a===i,icon:s,title:r.name,description:c.length>0?p.jsxs("span",{className:"flex flex-col gap-1",children:[r.description&&p.jsx("span",{children:r.description}),r.mimeType&&p.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-500 font-mono",children:r.mimeType})]}):void 0,onClick:()=>n(r)},r.uri)})})}function H4({isSearchExpanded:e,searchQuery:t,filteredResourcesCount:n,onSearchExpand:a,onSearchChange:r,onSearchBlur:i,searchInputRef:s}){return p.jsx("div",{className:"flex flex-row items-center justify-between p-4 sm:p-4 py-3 gap-2",children:p.jsx("div",{className:"flex items-center gap-2 flex-1",children:e?p.jsx(jn,{ref:s,placeholder:"Search resources...",value:t,onChange:c=>r(c.target.value),onBlur:i,className:"h-8 border-gray-300 dark:border-zinc-600"}):p.jsxs(p.Fragment,{children:[p.jsx("h2",{className:"text-lg font-medium text-gray-900 dark:text-gray-100",children:"Resources"}),p.jsx(Jr,{className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",variant:"outline",children:n}),p.jsxs(en,{children:[p.jsx(tn,{asChild:!0,children:p.jsx(Ue,{variant:"ghost",size:"sm",onClick:a,className:"h-8 w-8 p-0",children:p.jsx(qp,{className:"h-4 w-4"})})}),p.jsxs(nn,{side:"bottom",className:"flex gap-2",children:["Search",p.jsx($y,{children:"F"})]})]})]})})})}function YK({ref:e,resources:t,readResource:n,serverId:a,isConnected:r}){const[i,s]=x.useState(null),{selectedResourceUri:c,setSelectedResourceUri:u}=ld(),[d,m]=x.useState(null),[h,g]=x.useState(!1),[v,w]=x.useState(""),[S]=x.useState("resources"),[y,_]=x.useState(!0),[E,k]=x.useState(!1),[C,R]=x.useState(-1),[A,I]=x.useState(!1),O=x.useRef(null),j=x.useRef(null),[F,H]=x.useState(!1),[K,Q]=x.useState("list"),[W,ie]=x.useState(0),[V,Y]=x.useState(!0),z=x.useRef(null),te=x.useRef(null);x.useEffect(()=>{const G=()=>{H(window.innerWidth<1024)};return G(),window.addEventListener("resize",G),()=>window.removeEventListener("resize",G)},[]),x.useEffect(()=>{Q(i?"detail":"list")},[i]),x.useImperativeHandle(e,()=>({focusSearch:()=>{k(!0),setTimeout(()=>{O.current&&O.current.focus()},0)},blurSearch:()=>{w(""),k(!1),O.current&&O.current.blur()}})),x.useEffect(()=>{E&&O.current&&O.current.focus()},[E]);const re=x.useCallback(()=>{v.trim()||k(!1)},[v]),$=x.useMemo(()=>{if(!v)return t;const G=v.toLowerCase();return t.filter(Z=>Z.name.toLowerCase().includes(G)||Z.description?.toLowerCase().includes(G)||Z.uri.toLowerCase().includes(G))},[t,v]),B=x.useCallback(async G=>{if(s(G),r){g(!0);const Z=Date.now();try{const J=await n(G.uri);br.getInstance().capture(new eU({resourceUri:G.uri,serverId:a,success:!0})).catch(()=>{}),m({uri:G.uri,result:J,timestamp:Z,resourceAnnotations:G.annotations})}catch(J){br.getInstance().capture(new eU({resourceUri:G.uri,serverId:a,success:!1,error:J instanceof Error?J.message:"Unknown error"})).catch(()=>{}),m({uri:G.uri,result:null,error:J instanceof Error?J.message:"Unknown error",timestamp:Z,resourceAnnotations:G.annotations})}finally{g(!1)}}},[n,a,r]);x.useEffect(()=>{R(-1)},[v,S]),x.useEffect(()=>{const G=Z=>{const J=Z.target;if(J.tagName==="INPUT"||J.tagName==="TEXTAREA"||J.contentEditable==="true"||Z.metaKey||Z.ctrlKey||Z.altKey)return;const le=$;if(Z.key==="ArrowDown")Z.preventDefault(),R(ee=>{const ne=ee+1;return ne>=le.length?0:ne});else if(Z.key==="ArrowUp")Z.preventDefault(),R(ee=>{const ne=ee-1;return ne<0?le.length-1:ne});else if(Z.key==="Enter"&&C>=0){Z.preventDefault();const ee=$[C];ee&&B(ee)}};return document.addEventListener("keydown",G),()=>document.removeEventListener("keydown",G)},[C,$,B]),x.useEffect(()=>{if(C>=0){const G=`resource-${$[C]?.uri}`,Z=document.getElementById(G);Z&&Z.scrollIntoView({behavior:"smooth",block:"nearest"})}},[C,$]),x.useEffect(()=>{if(c&&t.length>0){const G=t.find(Z=>Z.uri===c);G&&i?.uri!==G.uri&&(u(null),setTimeout(()=>{B(G);const Z=document.getElementById(`resource-${G.uri}`);Z&&Z.scrollIntoView({behavior:"smooth",block:"nearest"})},100))}},[c,t,i,B,u]);const U=x.useCallback(async()=>{if(d)try{await navigator.clipboard.writeText(JSON.stringify(d.result,null,2)),I(!0),setTimeout(()=>I(!1),2e3)}catch(G){console.error("[ResourcesTab] Failed to copy result:",G)}},[d]),L=x.useCallback(()=>{if(d)try{const G=new globalThis.Blob([JSON.stringify(d.result,null,2)],{type:"application/json"}),Z=URL.createObjectURL(G),J=document.createElement("a");J.href=Z,J.download=`resource-${Date.now()}.json`,document.body.appendChild(J),J.click(),document.body.removeChild(J),URL.revokeObjectURL(Z)}catch(G){console.error("[ResourcesTab] Failed to download result:",G)}},[d]),P=x.useCallback(async()=>{if(j.current)try{document.fullscreenElement?await document.exitFullscreen():await j.current.requestFullscreen()}catch(G){console.error("[ResourcesTab] Failed to toggle fullscreen:",G)}},[]);return F?p.jsxs("div",{className:"h-full flex flex-col overflow-hidden relative bg-background",children:[K!=="list"&&p.jsxs("div",{className:"flex items-center gap-2 p-2 border-b shrink-0 bg-background z-10",children:[p.jsx(Ue,{variant:"ghost",size:"sm",onClick:()=>{s(null),Q("list")},className:"p-0 h-8 w-8",children:p.jsx(QT,{className:"h-4 w-4"})}),p.jsxs("div",{className:"flex items-center text-sm font-medium",children:[p.jsx("button",{onClick:()=>{s(null),Q("list")},className:"text-muted-foreground hover:text-foreground hover:underline cursor-pointer",children:"Resources"}),K==="detail"&&p.jsxs(p.Fragment,{children:[p.jsx("span",{className:"mx-2 text-muted-foreground",children:"/"}),p.jsx("span",{className:"text-foreground",children:"Content"})]})]})]}),p.jsx("div",{className:"flex-1 relative overflow-hidden",children:p.jsxs(ly,{initial:!1,mode:"popLayout",children:[K==="list"&&p.jsxs(ma.div,{initial:{x:"-100%"},animate:{x:0},exit:{x:"-100%"},transition:{type:"spring",stiffness:300,damping:30},className:"absolute inset-0 flex flex-col bg-background z-0",children:[p.jsx(H4,{activeTab:S,isSearchExpanded:E,searchQuery:v,filteredResourcesCount:$.length,onSearchExpand:()=>k(!0),onSearchChange:w,onSearchBlur:re,onTabSwitch:()=>{},searchInputRef:O}),p.jsx("div",{className:"flex flex-col h-full",children:p.jsx(B4,{resources:$,selectedResource:i,onResourceSelect:B,focusedIndex:C})})]},"list"),K==="detail"&&p.jsx(ma.div,{initial:{x:"100%"},animate:{x:0},exit:{x:"100%"},transition:{type:"spring",stiffness:300,damping:30},className:"absolute inset-0 bg-white dark:bg-zinc-900 z-10",children:p.jsx("div",{ref:j,className:"h-full",children:p.jsx(F4,{result:d,isLoading:h,previewMode:y,serverId:a,readResource:n,onTogglePreview:()=>_(!y),onCopy:U,onDownload:L,onFullscreen:P,isCopied:A})})},"detail")]})})]}):p.jsxs(Da,{direction:"horizontal",className:"h-full",children:[p.jsx(zn,{defaultSize:25,children:p.jsxs(Da,{direction:"vertical",className:"h-full border-r dark:border-zinc-700",children:[p.jsx(zn,{defaultSize:75,minSize:30,children:p.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[p.jsx(H4,{activeTab:S,isSearchExpanded:E,searchQuery:v,filteredResourcesCount:$.length,onSearchExpand:()=>k(!0),onSearchChange:w,onSearchBlur:re,onTabSwitch:()=>{},searchInputRef:O}),p.jsx(B4,{resources:$,selectedResource:i,onResourceSelect:B,focusedIndex:C})]})}),p.jsx(Ui,{withHandle:!0}),p.jsxs(zn,{ref:z,defaultSize:0,collapsible:!0,minSize:5,collapsedSize:5,onCollapse:()=>Y(!0),onExpand:()=>Y(!1),className:"flex flex-col border-t dark:border-zinc-700",children:[p.jsxs("div",{className:"group flex items-center justify-between p-3 shrink-0 cursor-pointer hover:bg-muted/50 transition-colors",onClick:G=>{G.preventDefault(),G.stopPropagation(),V?(z.current?.resize(25),Y(!1)):(z.current?.resize(5),Y(!0))},children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx("h3",{className:"text-sm font-medium",children:"RPC Messages"}),W>0&&p.jsx(Jr,{variant:"secondary",className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",children:W}),W>0&&!V&&p.jsx(Ue,{variant:"ghost",size:"sm",onClick:G=>{G.preventDefault(),G.stopPropagation(),te.current?.()},className:"h-6 w-6 p-0",title:"Clear all messages",children:p.jsx(Is,{className:"h-3.5 w-3.5"})})]}),p.jsx(Vl,{className:`h-4 w-4 text-muted-foreground transition-transform ${V?"":"rotate-180"}`})]}),!V&&p.jsx("div",{className:"flex-1 overflow-hidden min-h-0",children:p.jsx(TO,{serverIds:[a],onCountChange:ie,onClearRef:te})})]})]})}),p.jsx(Ui,{}),p.jsx(zn,{defaultSize:50,children:p.jsx(Da,{direction:"vertical",children:p.jsx(zn,{defaultSize:70,children:p.jsx("div",{ref:j,className:"h-full bg-white dark:bg-zinc-900",children:p.jsx(F4,{result:d,isLoading:h,previewMode:y,serverId:a,readResource:n,onTogglePreview:()=>_(!y),onCopy:U,onDownload:L,onFullscreen:P,isCopied:A})})})})})]})}YK.displayName="ResourcesTab";function V4({savedRequests:e,selectedRequest:t,onLoadRequest:n,onDeleteRequest:a,focusedIndex:r}){if(e.length===0)return p.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[p.jsx(ty,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),p.jsx("p",{className:"text-gray-500 dark:text-gray-400 mb-2",children:"No saved requests yet"}),p.jsx("p",{className:"text-xs text-gray-400 dark:text-gray-500",children:"Execute a tool and click Save to store requests"})]});const i=(s,c)=>{s.stopPropagation(),c()};return p.jsx("div",{className:"overflow-y-auto flex-1 border-r dark:border-zinc-700 overscroll-contain",children:e.map((s,c)=>p.jsxs("div",{className:"relative group",children:[p.jsx(Xl,{id:`saved-${s.id}`,isSelected:t?.id===s.id,isFocused:r===c,icon:p.jsx($b,{className:"h-4 w-4"}),title:s.name,description:s.toolName,metadata:p.jsx("div",{className:"flex flex-col gap-1",children:p.jsx("span",{className:"text-xs text-gray-400 dark:text-gray-500",children:new Date(s.savedAt).toLocaleString()})}),onClick:()=>n(s)}),p.jsx("div",{className:"absolute top-1/2 right-2 -translate-y-1/2 opacity-0 group-hover:opacity-100 transition-opacity z-10",children:p.jsxs(en,{children:[p.jsx(tn,{asChild:!0,children:p.jsx(Ue,{variant:"secondary",size:"sm",onClick:u=>i(u,()=>a(s.id)),className:"h-8 w-8 p-0",children:p.jsx(Is,{className:"h-4 w-4"})})}),p.jsx(nn,{children:p.jsx("p",{children:"Delete saved request"})})]})})]},s.id))})}function G4({isOpen:e,requestName:t,defaultPlaceholder:n,onRequestNameChange:a,onSave:r,onCancel:i}){return e?p.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:i,children:p.jsxs("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:s=>s.stopPropagation(),children:[p.jsx("h3",{className:"text-lg font-semibold mb-4 text-gray-900 dark:text-gray-100",children:"Save Request"}),p.jsxs("div",{className:"space-y-4",children:[p.jsxs("div",{children:[p.jsx(Yt,{htmlFor:"request-name",children:"Request Name (optional)"}),p.jsx(jn,{id:"request-name",value:t,onChange:s=>a(s.target.value),placeholder:n,className:"mt-2",onKeyDown:s=>{s.key==="Enter"&&r()},autoFocus:!0})]}),p.jsxs("div",{className:"flex justify-end gap-2",children:[p.jsx(Ue,{variant:"outline",onClick:i,children:"Cancel"}),p.jsxs(Ue,{onClick:r,children:[p.jsx(nN,{className:"h-4 w-4 mr-2"}),"Save"]})]})]})]})}):null}function XK(e,t){if(!e?.$ref)return e;const n=e.$ref;if(n.startsWith("#/")){const a=n.substring(2).split("/");let r=t;for(const i of a)if(r&&typeof r=="object"&&i in r)r=r[i];else return console.warn(`Could not resolve $ref: ${n}`),e;return r}return e}function R_e(e,t){if(e.anyOf&&Array.isArray(e.anyOf)){const n=e.anyOf.find(a=>a.type!=="null");if(n)return{...XK(n,t),nullable:!0}}return e}function C_e(e){return Array.isArray(e.enum)?e.enum:null}function A_e({selectedTool:e,toolArgs:t,onArgChange:n}){const a=e?.inputSchema?.properties||{},r=e?.inputSchema?.required||[];return Object.keys(a).length>0?p.jsx("div",{className:"space-y-4",children:Object.entries(a).map(([s,c])=>{const u=e?.inputSchema||{};let d=R_e(c,u);d=XK(d,u);const m=C_e(d),h=d.type==="string"&&m!==null,g=d;g.required=r.includes(s);const v=t[s];let w="";return v!=null&&(typeof v=="string"?w=v:typeof v=="object"&&v!==null?w=JSON.stringify(v,null,2):w=String(v)),g.type==="object"||g.type==="array"?p.jsxs("div",{className:"space-y-2",children:[p.jsxs(Yt,{htmlFor:s,className:"text-sm font-medium",children:[s,g?.required&&p.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),p.jsx(zu,{id:s,value:w,onChange:y=>n(s,y.target.value),placeholder:g?.description||`Enter ${s}`,className:"min-h-[100px]"}),g?.description&&p.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:g.description})]},s):h&&m?p.jsxs("div",{className:"space-y-2",children:[p.jsxs(Yt,{htmlFor:s,className:"text-sm font-medium",children:[s,g.required&&p.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),p.jsxs(Eo,{value:String(t[s]||""),onValueChange:y=>n(s,y),children:[p.jsx(ko,{id:s,className:"w-full",children:p.jsx(_o,{placeholder:g.description||"Select an option"})}),p.jsx(To,{children:m.map((y,_)=>p.jsx(Rr,{value:y,children:g.enumNames?.[_]||y},y))})]}),g.description&&p.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:g.description})]},s):p.jsxs("div",{className:"space-y-2",children:[p.jsxs(Yt,{htmlFor:s,className:"text-sm font-medium",children:[s,g?.required&&p.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),p.jsx(jn,{id:s,value:w,onChange:y=>n(s,y.target.value),placeholder:g?.description||`Enter ${s}`}),g?.description&&p.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:g.description})]},s)})}):p.jsx("div",{className:"flex items-center justify-center h-32 text-gray-500 dark:text-gray-400 text-sm",children:"No parameters required"})}function W4({selectedTool:e,toolArgs:t,isExecuting:n,isConnected:a,onArgChange:r,onExecute:i,onSave:s}){return x.useEffect(()=>{const c=u=>{(u.metaKey||u.ctrlKey)&&u.key==="Enter"&&e&&!n&&a&&(u.preventDefault(),i())};return document.addEventListener("keydown",c),()=>document.removeEventListener("keydown",c)},[e,n,a,i]),e?p.jsxs("div",{className:"flex flex-col h-full",children:[p.jsx("div",{className:"flex-shrink-0 p-3 sm:p-5 pt-3 sm:pt-4 pb-4 sm:pr-4",children:p.jsxs("div",{children:[p.jsxs("div",{className:"flex flex-row items-center justify-between mb-0 gap-2",children:[p.jsx("h3",{className:"text-base sm:text-lg font-semibold",children:e.name}),p.jsxs("div",{className:"flex gap-2 flex-shrink-0",children:[p.jsxs(Ue,{variant:"outline",onClick:s,disabled:n,size:"sm",className:"lg:size-default gap-2",children:[p.jsx(nN,{className:"h-4 w-4"}),p.jsx("span",{className:"hidden sm:inline",children:"Save"})]}),p.jsx(Ue,{onClick:i,disabled:n||!a,size:"sm",className:"lg:size-default pr-1! gap-0",children:n?p.jsxs(p.Fragment,{children:[p.jsx(Lo,{className:"mr-2"}),p.jsx("span",{className:"hidden sm:inline",children:"Executing..."})]}):p.jsxs(p.Fragment,{children:[p.jsx(H9,{className:"h-4 w-4 sm:mr-2"}),p.jsx("span",{className:"hidden sm:inline",children:"Execute"}),p.jsx("span",{className:"hidden sm:inline text-[12px] border text-zinc-300 p-1 rounded-full border-zinc-300 dark:text-zinc-600 dark:border-zinc-500 ml-2",children:"⌘↵"})]})})]})]}),e.description&&p.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 leading-relaxed mt-2",children:e.description})]})}),p.jsx("div",{className:"flex-1 overflow-y-auto px-3 sm:px-6 pb-4 pr-3",children:p.jsx(A_e,{selectedTool:e,toolArgs:t,onArgChange:r})})]}):p.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[p.jsx("p",{className:"text-gray-500 dark:text-gray-400 mb-2",children:"Select a tool to get started"}),p.jsx("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"})]})}function K4(e){const n=Date.now()-e,a=Math.floor(n/1e3),r=Math.floor(a/60),i=Math.floor(r/60),s=Math.floor(i/24);return a<10?"now":a<60?`${a}s ago`:r<60?`${r}m ago`:i<24?`${i}h ago`:`${s}d ago`}function I_e(e){try{return JSON.parse(e),!0}catch{return!1}}function O_e({content:e}){return!Array.isArray(e)||e.length===0?p.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:"No content"}):p.jsx("div",{className:"space-y-4",children:e.map((t,n)=>{if(t.type==="text"){const a=t.text||"";if(I_e(a))try{const r=JSON.parse(a);return p.jsxs("div",{className:"space-y-2",children:[p.jsx("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"Text Content (JSON)"}),p.jsx(ir,{data:r,filename:`content-${n}.json`})]},n)}catch{}return p.jsxs("div",{className:"space-y-2",children:[p.jsx("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"Text Content"}),p.jsx("div",{className:"bg-gray-50 dark:bg-zinc-900 rounded-lg p-3 font-mono text-sm whitespace-pre-wrap break-words",children:a})]},n)}if(t.type==="image")return p.jsxs("div",{className:"space-y-2",children:[p.jsx("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"Image Content"}),p.jsxs("div",{className:"bg-gray-50 dark:bg-zinc-900 rounded-lg p-3",children:[p.jsx("img",{src:`data:${t.mimeType||"image/png"};base64,${t.data}`,alt:"Result",className:"max-w-full rounded"}),t.annotations&&p.jsx("div",{className:"mt-2 text-xs text-gray-500 dark:text-gray-400",children:p.jsx(ir,{data:t.annotations,filename:`image-annotations-${n}.json`})})]})]},n);if(t.type==="audio")return p.jsxs("div",{className:"space-y-2",children:[p.jsx("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"Audio Content"}),p.jsxs("div",{className:"bg-gray-50 dark:bg-zinc-900 rounded-lg p-3",children:[p.jsx("audio",{controls:!0,src:`data:${t.mimeType||"audio/wav"};base64,${t.data}`,className:"w-full"}),t.annotations&&p.jsx("div",{className:"mt-2 text-xs text-gray-500 dark:text-gray-400",children:p.jsx(ir,{data:t.annotations,filename:`audio-annotations-${n}.json`})})]})]},n);if(t.type==="resource_link")return p.jsxs("div",{className:"space-y-2",children:[p.jsx("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"Resource Link"}),p.jsxs("div",{className:"bg-gray-50 dark:bg-zinc-900 rounded-lg p-3 space-y-2",children:[p.jsxs("div",{className:"font-mono text-sm break-all",children:[p.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"URI:"})," ",t.uri]}),t.name&&p.jsxs("div",{className:"text-sm",children:[p.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"Name:"})," ",t.name]}),t.description&&p.jsxs("div",{className:"text-sm",children:[p.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"Description:"})," ",t.description]}),t.mimeType&&p.jsxs("div",{className:"text-sm",children:[p.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"MIME Type:"})," ",t.mimeType]}),t.annotations&&p.jsxs("div",{className:"mt-2",children:[p.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"Annotations:"}),p.jsx(ir,{data:t.annotations,filename:`resource-link-annotations-${n}.json`})]})]})]},n);if(t.type==="resource"){const a=t.resource||{};return p.jsxs("div",{className:"space-y-2",children:[p.jsx("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"Embedded Resource"}),p.jsxs("div",{className:"bg-gray-50 dark:bg-zinc-900 rounded-lg p-3 space-y-2",children:[p.jsxs("div",{className:"font-mono text-sm break-all",children:[p.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"URI:"})," ",a.uri]}),a.mimeType&&p.jsxs("div",{className:"text-sm",children:[p.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"MIME Type:"})," ",a.mimeType]}),a.text&&p.jsxs("div",{children:[p.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"Content:"}),p.jsx("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&&p.jsxs("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:["[Binary content: ",a.blob.length||0," bytes]"]}),a.annotations&&p.jsxs("div",{className:"mt-2",children:[p.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"Annotations:"}),p.jsx(ir,{data:a.annotations,filename:`resource-annotations-${n}.json`})]})]})]},n)}return p.jsxs("div",{className:"space-y-2",children:[p.jsxs("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:["Unknown Content Type: ",t.type||"N/A"]}),p.jsx(ir,{data:t,filename:`content-${n}.json`})]},n)})})}function Z4({results:e,copiedResult:t,previewMode:n,serverId:a,readResource:r,onCopy:i,onTogglePreview:s,onMaximize:c,isMaximized:u=!1}){const[d,m]=x.useState(0),[h,g]=x.useState(""),[v,w]=x.useState(!0),S=e[0],y=S?e.filter(W=>W.toolName===S.toolName):[],_=y[d]||y[0],E=e.findIndex(W=>W===_);x.useEffect(()=>{y.length>0&&d>=y.length&&m(0)},[y.length,d]),x.useEffect(()=>{const W=()=>{_&&g(K4(_.timestamp))};W();const ie=setInterval(W,1e3);return()=>clearInterval(ie)},[_]);const k=x.useMemo(()=>_?.args,[_?.timestamp,d]),C=x.useMemo(()=>_?.result,[_?.timestamp,d]),R=x.useCallback(W=>r(W),[r]);if(e.length===0)return p.jsx("div",{className:"flex flex-col h-full bg-white dark:bg-black border-t dark:border-zinc-700",children:p.jsx("div",{className:"flex-1 overflow-y-auto h-full",children:p.jsx("div",{className:"flex items-center justify-center h-full",children:p.jsx("div",{className:"text-center",children:p.jsx(Yp,{vertical:!0,noBorder:!0,message:"No Results yet"})})})})});const A=_.toolMeta?.["openai/outputTemplate"],I=!!(A&&typeof A=="string"&&_.appsSdkResource),O=A,j=_.result?.content||[],F=j.filter(W=>W.type==="resource"&&hu(W.resource)),H=F.length>0,K=!!(j&&j.length>0||_.result?.structuredContent),Q=!H&&!I&&K;return p.jsx("div",{className:"flex flex-col h-full bg-white dark:bg-black border-t dark:border-zinc-700",children:p.jsx("div",{className:"flex-1 overflow-y-auto h-full",children:p.jsxs("div",{className:"space-y-0 flex-1 h-full flex flex-col",children:[p.jsxs("div",{className:`flex items-center gap-2 px-4 pt-2 ${H||I||Q?"border-b border-gray-200 dark:border-zinc-600 pb-2":""}`,children:[p.jsx("h3",{className:"text-sm font-medium hidden sm:block",children:"Response"}),_.duration!==void 0&&p.jsxs("div",{className:"hidden sm:flex items-center gap-1",children:[p.jsx(op,{className:"h-3 w-3 text-gray-400"}),p.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:[_.duration,"ms"]})]}),I&&p.jsxs("div",{className:"flex items-center gap-4 sm:ml-4",children:[p.jsxs("span",{className:"hidden sm:inline text-xs text-gray-500 dark:text-gray-400",children:["URI: ",O||"No URI"]}),p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx("button",{onClick:()=>s(),className:`text-xs font-medium ${n?"text-black dark:text-white":"text-zinc-500 dark:text-zinc-400"}`,children:"Component"}),p.jsx("span",{className:"text-xs text-zinc-400",children:"|"}),p.jsx("button",{onClick:()=>s(),className:`text-xs font-medium ${n?"text-zinc-500 dark:text-zinc-400":"text-black dark:text-white"}`,children:"Raw JSON"})]})]}),H&&!I&&p.jsxs("div",{className:"flex items-center gap-4 sm:ml-4",children:[p.jsxs("span",{className:"hidden sm:inline text-xs text-gray-500 dark:text-gray-400",children:["URI: ",F[0]?.resource?.uri||"No URI"]}),p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx("button",{onClick:()=>s(),className:`text-xs font-medium ${n?"text-black dark:text-white":"text-zinc-500 dark:text-zinc-400"}`,children:"Preview"}),p.jsx("span",{className:"text-xs text-zinc-400",children:"|"}),p.jsx("button",{onClick:()=>s(),className:`text-xs font-medium ${n?"text-zinc-500 dark:text-zinc-400":"text-black dark:text-white"}`,children:"JSON"})]})]}),Q&&p.jsxs("div",{className:"flex items-center gap-2 sm:ml-4",children:[p.jsx("button",{onClick:()=>w(!0),className:`text-xs font-medium ${v?"text-black dark:text-white":"text-zinc-500 dark:text-zinc-400"}`,children:"Formatted"}),p.jsx("span",{className:"text-xs text-zinc-400",children:"|"}),p.jsx("button",{onClick:()=>w(!1),className:`text-xs font-medium ${v?"text-zinc-500 dark:text-zinc-400":"text-black dark:text-white"}`,children:"Raw"})]}),p.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[(I||H)&&c&&p.jsx(Ue,{variant:"ghost",size:"sm",onClick:c,title:u?"Restore":"Maximize",children:u?p.jsx(ype,{className:"h-4 w-4"}):p.jsx(tN,{className:"h-4 w-4"})}),y.length>1&&p.jsxs(Eo,{value:d.toString(),onValueChange:W=>m(parseInt(W)),children:[p.jsx(ko,{size:"sm",className:"w-[140px] h-8 text-xs",children:p.jsx(_o,{children:p.jsxs("div",{className:"flex items-center gap-1",children:[p.jsx($b,{className:"h-3 w-3"}),p.jsx("span",{children:h})]})})}),p.jsx(To,{children:y.map((W,ie)=>p.jsx(Rr,{value:ie.toString(),children:p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx($b,{className:"h-3 w-3"}),p.jsx("span",{children:K4(W.timestamp)}),p.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",new Date(W.timestamp).toLocaleTimeString(),")"]})]})},ie))})]}),p.jsx(Ue,{variant:"ghost",size:"sm",onClick:()=>i(E,_.result),children:t===E?p.jsx(La,{className:"h-4 w-4"}):p.jsx(Xr,{className:"h-4 w-4"})})]})]}),_.error?p.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded p-3 mx-4",children:[p.jsx("p",{className:"text-red-800 dark:text-red-300 font-medium",children:"Error:"}),p.jsx("p",{className:"text-red-700 dark:text-red-400 text-sm",children:_.error})]}):(()=>{if(I){const W=_.appsSdkResource;return W.isLoading?p.jsx(p.Fragment,{}):W.error?p.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded p-3 mx-4",children:[p.jsx("p",{className:"text-red-800 dark:text-red-300 font-medium",children:"Resource Error:"}),p.jsx("p",{className:"text-red-700 dark:text-red-400 text-sm",children:W.error})]}):n?p.jsx("div",{className:"flex-1",children:p.jsx(gO,{componentUrl:O,toolName:_.toolName,toolArgs:k,toolResult:C,serverId:a,readResource:R,className:"w-full h-full relative p-4"})}):p.jsx("div",{className:"px-4 pt-4",children:p.jsx(ir,{data:_.result,filename:`tool-result-${_.toolName}-${Date.now()}.json`})})}if(H)return n?p.jsxs("div",{className:"space-y-0 h-full",children:[F.map((W,ie)=>p.jsx("div",{className:"mx-0 size-full",children:p.jsx(ZK,{resource:W.resource,onUIAction:V=>{},className:"w-full h-full relative"})},ie)),j.filter(W=>!(W.type==="resource"&&hu(W.resource))).length>0&&p.jsx("div",{className:"px-4",children:p.jsx(ir,{data:j.filter(W=>!(W.type==="resource"&&hu(W.resource))),filename:`tool-result-${_.toolName}-non-ui-${Date.now()}.json`})})]}):p.jsx("div",{className:"px-4 pt-4",children:p.jsx(ir,{data:_.result,filename:`tool-result-${_.toolName}-mcp-ui-${Date.now()}.json`})});if(Q&&v){const W=_.result?.structuredContent;return p.jsxs("div",{className:"px-4 pt-4 space-y-4",children:[W&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"Structured Content"}),p.jsx(ir,{data:W,filename:`structured-content-${_.toolName}-${Date.now()}.json`})]}),j&&j.length>0&&p.jsx(O_e,{content:j}),!W&&(!j||j.length===0)&&p.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:"No content to display"})]})}return p.jsx("div",{className:"px-4 pt-4",children:p.jsx(ir,{data:_.result,filename:`tool-result-${_.toolName}-${Date.now()}.json`})})})()]})})})}function Y4({tools:e,selectedTool:t,onToolSelect:n,focusedIndex:a}){return e.length===0?p.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[p.jsx(Dl,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),p.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"No tools available"})]}):p.jsx("div",{className:"overflow-y-auto flex-1 overscroll-contain",children:e.map((r,i)=>p.jsx(Xl,{id:`tool-${r.name}`,isSelected:t?.name===r.name,isFocused:a===i,icon:p.jsx(Dl,{className:"h-4 w-4"}),title:r.name,description:r.description,metadata:r.inputSchema?.properties&&p.jsxs(Jr,{variant:"outline",className:"text-xs border-gray-300 dark:border-zinc-600 text-gray-600 dark:text-gray-400",children:[Object.keys(r.inputSchema.properties).length," params"]}),onClick:()=>n(r)},r.name))})}function X4({activeTab:e,isSearchExpanded:t,searchQuery:n,filteredToolsCount:a,savedRequestsCount:r,onSearchExpand:i,onSearchChange:s,onSearchBlur:c,onTabSwitch:u,searchInputRef:d}){return p.jsx(WK,{activeTab:e,isSearchExpanded:t,searchQuery:n,primaryTabName:"tools",secondaryTabName:"saved",primaryTabTitle:"Tools",secondaryTabTitle:"Saved",primaryCount:a,secondaryCount:r,primaryIcon:Dl,secondaryIcon:ty,searchPlaceholder:"Search tools...",onSearchExpand:i,onSearchChange:s,onSearchBlur:c,onTabSwitch:u,searchInputRef:d})}const q4="mcp-inspector-saved-requests";function qK({ref:e,tools:t,callTool:n,readResource:a,serverId:r,isConnected:i}){const[s,c]=x.useState(null),[u,d]=x.useState(null),{selectedToolName:m,setSelectedToolName:h}=ld(),[g,v]=x.useState({}),[w,S]=x.useState([]),[y,_]=x.useState(!1),[E,k]=x.useState(null),[C,R]=x.useState(""),[A,I]=x.useState("tools"),[O,j]=x.useState([]),[F,H]=x.useState(!1),[K,Q]=x.useState(""),[W,ie]=x.useState(!0),[V,Y]=x.useState(!1),[z,te]=x.useState(-1),re=x.useRef(null),[$,B]=x.useState(!1),[U,L]=x.useState("list"),[P,G]=x.useState(!1),[Z,J]=x.useState(0),[se,le]=x.useState(!0),[ee,ne]=x.useState(void 0),ce=x.useRef(null),ae=x.useRef(null),ye=x.useRef(null),ke=x.useRef(null),Be=x.useRef(null);x.useEffect(()=>{const Ae=()=>{B(window.innerWidth<1024)};return Ae(),window.addEventListener("resize",Ae),()=>window.removeEventListener("resize",Ae)},[]),x.useEffect(()=>{L(s?"detail":"list")},[s]),x.useEffect(()=>{$&&w.length>0&&!y&&L("response")},[w,y,$]),x.useImperativeHandle(e,()=>({focusSearch:()=>{Y(!0),setTimeout(()=>{re.current&&re.current.focus()},0)},blurSearch:()=>{R(""),Y(!1),re.current&&re.current.blur()}})),x.useEffect(()=>{try{const Ae=localStorage.getItem(q4);Ae&&j(JSON.parse(Ae))}catch(Ae){console.error("[ToolsTab] Failed to load saved requests:",Ae)}},[]);const _e=x.useCallback(Ae=>{try{localStorage.setItem(q4,JSON.stringify(Ae)),j(Ae)}catch(Ie){console.error("[ToolsTab] Failed to save requests:",Ie)}},[]),Se=x.useMemo(()=>{if(!C.trim())return t;const Ae=C.toLowerCase();return t.filter(Ie=>Ie.name.toLowerCase().includes(Ae)||Ie.description?.toLowerCase().includes(Ae))},[t,C]),ze=x.useCallback(Ae=>{c(Ae);const Ie={};Ae.inputSchema?.properties&&Object.entries(Ae.inputSchema.properties).forEach(([Ye,tt])=>{const it=tt;it.default!==void 0?Ie[Ye]=it.default:it.type==="string"?Ie[Ye]="":it.type==="number"?Ie[Ye]=0:it.type==="boolean"?Ie[Ye]=!1:it.type==="array"?Ie[Ye]="[]":it.type==="object"&&(Ie[Ye]="{}")}),v(Ie)},[]),pe=x.useCallback(Ae=>{const Ie=t.find(Ye=>Ye.name===Ae.toolName);Ie&&(c(Ie),v(Ae.args),d(Ae))},[t]);x.useEffect(()=>{V&&re.current&&re.current.focus()},[V]);const Le=x.useCallback(()=>{C.trim()||Y(!1)},[C]);x.useEffect(()=>{A!=="tools"&&Y(!1)},[A]),x.useEffect(()=>{te(-1)},[C,A]),x.useEffect(()=>{const Ae=Ie=>{const Ye=Ie.target;if(Ye.tagName==="INPUT"||Ye.tagName==="TEXTAREA"||Ye.contentEditable==="true"||Ie.metaKey||Ie.ctrlKey||Ie.altKey)return;const it=A==="tools"?Se:O;if(Ie.key==="ArrowDown")Ie.preventDefault(),te(gt=>{const mt=gt+1;return mt>=it.length?0:mt});else if(Ie.key==="ArrowUp")Ie.preventDefault(),te(gt=>{const mt=gt-1;return mt<0?it.length-1:mt});else if(Ie.key==="Enter"&&z>=0)if(Ie.preventDefault(),A==="tools"){const gt=Se[z];gt&&ze(gt)}else{const gt=O[z];gt&&pe(gt)}};return document.addEventListener("keydown",Ae),()=>document.removeEventListener("keydown",Ae)},[z,Se,O,A,ze,pe]),x.useEffect(()=>{if(z>=0){const Ae=A==="tools"?`tool-${Se[z]?.name}`:`saved-${O[z]?.id}`,Ie=document.getElementById(Ae);Ie&&Ie.scrollIntoView({behavior:"smooth",block:"nearest"})}},[z,Se,O,A]),x.useEffect(()=>{if(m&&t.length>0){const Ae=t.find(Ie=>Ie.name===m);if(Ae&&s?.name!==Ae.name){h(null);const Ie=setTimeout(()=>{ze(Ae);const Ye=document.getElementById(`tool-${Ae.name}`);Ye&&Ye.scrollIntoView({behavior:"smooth",block:"nearest"})},100);return()=>clearTimeout(Ie)}}},[m,t,s,ze,h]);const Fe=x.useCallback((Ae,Ie)=>{v(Ye=>{const tt={...Ye};if(s?.inputSchema?.properties?.[Ae]){const gt=s.inputSchema.properties[Ae].type;if(gt==="object"||gt==="array")tt[Ae]=Ie;else if(gt==="string")tt[Ae]=Ie;else try{tt[Ae]=JSON.parse(Ie)}catch{tt[Ae]=Ie}}else tt[Ae]=Ie;return tt})},[s]),xe=x.useCallback(async()=>{if(!s||y)return;_(!0);const Ae=Date.now();try{const Ie={...g};s.inputSchema?.properties&&Object.entries(s.inputSchema.properties).forEach(([$t,on])=>{const Ve=on.type,jt=Ie[$t];if((Ve==="object"||Ve==="array")&&typeof jt=="string")try{Ie[$t]=JSON.parse(jt)}catch{}});const Ye=await n(s.name,Ie,{timeout:6e5,resetTimeoutOnProgress:!0}),tt=Date.now()-Ae;br.getInstance().capture(new QP({toolName:s.name,serverId:r,success:!0,duration:tt})).catch(()=>{});const gt=s?._meta||s?.metadata,mt=gt?.["openai/outputTemplate"];let Rn;if(mt&&typeof mt=="string"){const $t={toolName:s.name,args:g,result:Ye,timestamp:Ae,duration:tt,toolMeta:gt,appsSdkResource:{uri:mt,resourceData:null,isLoading:!0}};S([$t]);try{const on=await a(mt);let Bt=null;if(Ye?.structuredContent)Bt=Ye.structuredContent;else if(Array.isArray(Ye)&&Ye[0]){const Ve=Ye[0];Ve.output?.value?.structuredContent?Bt=Ve.output.value.structuredContent:Ve.structuredContent?Bt=Ve.structuredContent:Ve.output?.value&&(Bt=Ve.output.value)}Bt||(Bt=Ye),Rn={uri:mt,resourceData:{...on,structuredContent:Bt},isLoading:!1}}catch(on){Rn={uri:mt,resourceData:null,isLoading:!1,error:on instanceof Error?on.message:String(on)}}S(on=>on.map((Bt,Ve)=>Ve===0?{...Bt,appsSdkResource:Rn}:Bt))}else S($t=>[{toolName:s.name,args:g,result:Ye,timestamp:Ae,duration:tt,toolMeta:gt},...$t])}catch(Ie){const Ye=Date.now()-Ae;br.getInstance().capture(new QP({toolName:s.name,serverId:r,success:!1,duration:Ye,error:Ie instanceof Error?Ie.message:String(Ie)})).catch(()=>{});const it=s?._meta||s?.metadata,gt={toolName:s.name,args:g,result:null,error:Ie instanceof Error?Ie.message:String(Ie),timestamp:Ae,duration:Ye,toolMeta:it},mt=it?.["openai/outputTemplate"];S(mt?[gt]:Rn=>[gt,...Rn])}finally{_(!1)}},[s,g,y,n,a,r]),st=x.useCallback(async(Ae,Ie)=>{try{await navigator.clipboard.writeText(JSON.stringify(Ie,null,2)),k(Ae),setTimeout(()=>k(null),2e3)}catch(Ye){console.error("[ToolsTab] Failed to copy result:",Ye)}},[]),at=x.useCallback(Ae=>{S(Ie=>Ie.filter((Ye,tt)=>tt!==Ae))},[]),pt=x.useMemo(()=>s?w.filter(Ae=>Ae.toolName===s.name):[],[w,s]),Pe=x.useCallback(Ae=>{const Ie=pt[Ae];if(Ie){const Ye=window.open("","_blank","width=800,height=600");Ye&&(Ye.document.write(`
1669
+ `);k=A.pop()||"";for(const I of A)if(I.trim()&&I.startsWith("data: "))try{const O=JSON.parse(I.slice(6));if(console.log("[Client received event]",O.type,O.toolName||O.content?.slice?.(0,30)),O.type==="message")console.log("[Message started]",O.id);else if(O.type==="text"){S+=O.content;const j=y[y.length-1];j&&j.type==="text"?j.text=S:y.push({type:"text",text:S}),console.log("[Parts after text]",y.length,"parts, text length:",S.length),i(F=>F.map(H=>H.id===w?{...H,parts:[...y]}:H))}else if(O.type==="tool-call")S&&(S=""),y.push({type:"tool-invocation",toolInvocation:{toolName:O.toolName,args:O.args,state:"pending"}}),console.log("[Parts after tool-call]",y.length,"parts, tool:",O.toolName),i(j=>j.map(F=>F.id===w?{...F,parts:[...y]}:F));else if(O.type==="tool-result"){const j=y.find(F=>F.type==="tool-invocation"&&F.toolInvocation?.toolName===O.toolName&&!F.toolInvocation?.result);j&&j.toolInvocation?(j.toolInvocation.result=O.result,j.toolInvocation.state="result",console.log("[Parts after tool-result]",y.length,"parts, updated:",O.toolName),i(F=>F.map(H=>H.id===w?{...H,parts:[...y]}:H))):console.warn("[tool-result] Could not find matching tool part for",O.toolName)}else if(O.type==="done")console.log("[Done] Final parts:",y.length),i(j=>j.map(F=>F.id===w?{...F,parts:[...y],content:""}:F));else if(O.type==="error")throw new Error(O.message||"Streaming error")}catch(O){console.error("Failed to parse streaming event:",O,I)}}}catch(g){let v="Unknown error occurred";if(g instanceof Error){v=g.message;const S=g;S.status&&(v=`HTTP ${S.status}: ${v}`),(S.code===401||v.includes("401")||v.includes("Unauthorized"))&&(v="Authentication failed (401). Check your Authorization header in the connection settings.")}const w={id:`error-${Date.now()}`,role:"assistant",content:`Error: ${v}`,timestamp:Date.now()};i(S=>[...S,w])}finally{c(!1)}},[t,a,e,r,n]),d=x.useCallback(()=>{i([])},[]);return{messages:r,isLoading:s,sendMessage:u,clearMessages:d}}function GEe({connection:e,llmConfig:t,isConnected:n,readResource:a}){const[r,i]=x.useState([]),[s,c]=x.useState(!1),u=x.useRef(null),d=x.useRef(null),m=x.useRef(null),h=x.useCallback(async v=>{if(!v.trim()||!t||!n)return;const w={id:`user-${Date.now()}`,role:"user",content:v.trim(),timestamp:Date.now()};i(_=>[..._,w]),c(!0),u.current=new AbortController;const S=Date.now();let y=0;try{const _=`assistant-${Date.now()}`;let E="";const k=[];if(i(C=>[...C,{id:_,role:"assistant",content:"",timestamp:Date.now(),parts:[]}]),!m.current||m.current.provider!==t.provider||m.current.model!==t.model||m.current.apiKey!==t.apiKey){let C;if(t.provider==="openai"){const{ChatOpenAI:R}=await Ar(async()=>{const{ChatOpenAI:A}=await import("./index-eSg28oTZ.js");return{ChatOpenAI:A}},__vite__mapDeps([5,6,7,3,8,9]));C=new R({model:t.model,apiKey:t.apiKey})}else if(t.provider==="anthropic"){const{ChatAnthropic:R}=await Ar(async()=>{const{ChatAnthropic:A}=await import("./index-BWh1LT8v.js");return{ChatAnthropic:A}},__vite__mapDeps([10,7,6,3]));C=new R({model:t.model,apiKey:t.apiKey})}else if(t.provider==="google"){const{ChatGoogleGenerativeAI:R}=await Ar(async()=>{const{ChatGoogleGenerativeAI:A}=await import("./index-C0sILan8.js");return{ChatGoogleGenerativeAI:A}},__vite__mapDeps([11,7,6,3,9]));C=new R({model:t.model,apiKey:t.apiKey})}else throw new Error(`Unsupported LLM provider: ${t.provider}`);m.current={instance:C,provider:t.provider,model:t.model,apiKey:t.apiKey}}if(!d.current||d.current.llm!==m.current.instance){const{MCPAgent:C}=await Ar(async()=>{const{MCPAgent:R}=await import("./browser-DhbomOzS.js");return{MCPAgent:R}},__vite__mapDeps([12,8,6,7,3,2,4,9]));d.current=new C({llm:m.current.instance,client:e.client,memoryEnabled:!0,systemPrompt:"You are a helpful assistant with access to MCP tools, prompts, and resources. Help users interact with the MCP server."}),await d.current.initialize()}else console.log("[useChatMessagesClientSide] Reusing existing agent. History length:",d.current.conversationHistory?.length);for await(const C of d.current.streamEvents(v,10,!1,void 0)){if(u.current?.signal.aborted)break;if(C.event==="on_chat_model_stream"&&C.data?.chunk?.text){const R=C.data.chunk.text;if(typeof R=="string"&&R.length>0){E+=R;const A=k[k.length-1];A&&A.type==="text"?A.text=E:k.push({type:"text",text:E}),i(I=>I.map(O=>O.id===_?{...O,parts:[...k]}:O))}}else if(C.event==="on_tool_start"){E&&(E="");let R={};C.data?.input?R=C.data.input:C.data?.tool_input?R=C.data.tool_input:C.data&&(R=C.data),console.log("[useChatMessagesClientSide] on_tool_start:",{toolName:C.name,eventData:C.data,extractedArgs:R}),y++,k.push({type:"tool-invocation",toolInvocation:{toolName:C.name||"unknown",args:R,state:"pending"}}),i(A=>A.map(I=>I.id===_?{...I,parts:[...k]}:I))}else if(C.event==="on_tool_end"){const R=k.find(A=>A.type==="tool-invocation"&&A.toolInvocation?.toolName===C.name&&!A.toolInvocation?.result);if(console.log("[useChatMessagesClientSide] on_tool_end event:",{toolName:C.name,hasToolPart:!!R,output:C.data?.output}),R&&R.toolInvocation){let A=C.data?.output;if(A?.kwargs?.content&&typeof A.kwargs.content=="string")try{A=JSON.parse(A.kwargs.content)}catch(O){console.warn("[useChatMessagesClientSide] Failed to parse kwargs.content:",O),A=A.kwargs.content}else if(A?.content&&typeof A.content=="string")try{A=JSON.parse(A.content)}catch{A=A.content}R.toolInvocation.result=A,R.toolInvocation.state="result";const I=A?._meta?.["openai/outputTemplate"];if(console.log("[useChatMessagesClientSide] Tool result:",{toolName:C.name,hasMeta:!!A?._meta,hasStructuredContent:!!A?.structuredContent,appsSdkUri:I}),I&&typeof I=="string"&&a){console.log("[useChatMessagesClientSide] Detected Apps SDK component, fetching resource:",I);try{const O=await a(I);console.log("[useChatMessagesClientSide] Resource fetched:",O);const j=A?.structuredContent||null;if(O?.contents&&Array.isArray(O.contents)){const F=O.contents.map(K=>({type:"resource",resource:K}));console.log("[useChatMessagesClientSide] Created MCP resources:",F);const H={...A,content:[...A.content||[],...F],structuredContent:j};R.toolInvocation.result=H,console.log("[useChatMessagesClientSide] Updated result with resources")}else console.warn("[useChatMessagesClientSide] No contents in resourceData:",O)}catch(O){console.error("Failed to fetch Apps SDK resource:",O)}}i(O=>O.map(j=>j.id===_?{...j,parts:[...k]}:j))}}}i(C=>C.map(R=>R.id===_?{...R,parts:[...k],content:""}:R)),t&&br.getInstance().capture(new nU({serverId:e.url,provider:t.provider,model:t.model,messageCount:r.length+1,toolCallsCount:y,success:!0,executionMode:"client-side",duration:Date.now()-S})).catch(()=>{})}catch(_){console.error("Client-side agent error:",_);let E="Unknown error occurred";if(_ instanceof Error){E=_.message;const C=_;C.status&&(E=`HTTP ${C.status}: ${E}`),(C.code===401||E.includes("401")||E.includes("Unauthorized"))&&(E="Authentication failed (401). Check your Authorization header in the connection settings.")}t&&br.getInstance().capture(new nU({serverId:e.url,provider:t.provider,model:t.model,messageCount:r.length+1,toolCallsCount:y,success:!1,executionMode:"client-side",duration:Date.now()-S,error:E})).catch(()=>{});const k={id:`error-${Date.now()}`,role:"assistant",content:`Error: ${E}`,timestamp:Date.now()};i(C=>[...C,k])}finally{c(!1),u.current=null}},[e,t,n,r,a]),g=x.useCallback(()=>{i([]),d.current&&d.current.clearConversationHistory()},[]);return{messages:r,isLoading:s,sendMessage:h,clearMessages:g}}const T4={openai:"gpt-4o",anthropic:"claude-haiku-4-5-20251001",google:"gemini-2.5-flash"};function _K({mcpServerUrl:e}){const[t,n]=x.useState(null),[a,r]=x.useState(null),[i,s]=x.useState(!1),[c,u]=x.useState("openai"),[d,m]=x.useState(""),[h,g]=x.useState(T4.openai),v=x.useCallback(()=>{const j=localStorage.getItem("mcp-inspector-api-keys");if(j)try{return JSON.parse(j)}catch(F){return console.error("Failed to load API keys:",F),{}}return{}},[]),w=x.useCallback(j=>{localStorage.setItem("mcp-inspector-api-keys",JSON.stringify(j))},[]),[S,y]=x.useState("none"),[_,E]=x.useState(""),[k,C]=x.useState(""),[R,A]=x.useState("");x.useEffect(()=>{const j=localStorage.getItem("mcp-inspector-llm-config"),F=v();if(j)try{const H=JSON.parse(j);n(H),u(H.provider),m(F[H.provider]||H.apiKey||""),g(H.model)}catch(H){console.error("Failed to load LLM config:",H)}},[v]),x.useEffect(()=>{const j=localStorage.getItem("mcp-inspector-auth-config");if(j)try{const F=JSON.parse(j);r(F),y(F.type),F.username&&E(F.username),F.password&&C(F.password),F.token&&A(F.token)}catch(F){console.error("Failed to load auth config:",F)}else try{const F="mcp:auth",H=EK(e),K=`${F}_${H}_tokens`;localStorage.getItem(K)&&(r({type:"oauth"}),y("oauth"))}catch(F){console.error("Failed to check for OAuth tokens:",F)}},[e]),x.useEffect(()=>{g(T4[c]);const j=v();m(j[c]||"")},[c,v]);const I=x.useCallback(()=>{if(!d.trim())return;const j=v();j[c]=d,w(j);const F={provider:c,apiKey:d,model:h},H={type:S,...S==="basic"&&{username:_.trim(),password:k.trim()},...S==="bearer"&&{token:R.trim()}};n(F),r(H),localStorage.setItem("mcp-inspector-llm-config",JSON.stringify(F)),localStorage.setItem("mcp-inspector-auth-config",JSON.stringify(H)),s(!1)},[c,d,h,S,_,k,R,v,w]),O=x.useCallback(()=>{n(null),r(null);const j=v();delete j[c],w(j),m(""),E(""),C(""),A(""),y("none"),localStorage.removeItem("mcp-inspector-llm-config"),localStorage.removeItem("mcp-inspector-auth-config")},[c,v,w]);return{llmConfig:t,authConfig:a,configDialogOpen:i,setConfigDialogOpen:s,tempProvider:c,setTempProvider:u,tempApiKey:d,setTempApiKey:m,tempModel:h,setTempModel:g,tempAuthType:S,saveLLMConfig:I,clearConfig:O}}function WEe({connection:e,isConnected:t,useClientSide:n=!0,readResource:a}){const[r,i]=x.useState(""),s=x.useRef(null),{llmConfig:c,authConfig:u,configDialogOpen:d,setConfigDialogOpen:m,tempProvider:h,setTempProvider:g,tempApiKey:v,setTempApiKey:w,tempModel:S,setTempModel:y,saveLLMConfig:_,clearConfig:E}=_K({mcpServerUrl:e.url}),k={connection:e,llmConfig:c,isConnected:t,readResource:a},C=VEe({mcpServerUrl:e.url,llmConfig:c,authConfig:u,isConnected:t}),R=GEe(k),{messages:A,isLoading:I,sendMessage:O,clearMessages:j}=n?R:C;xW({onNewChat:j}),x.useEffect(()=>{c&&A.length===0&&s.current&&s.current.focus()},[c,A.length]),x.useEffect(()=>{!I&&A.length>0&&s.current&&s.current.focus()},[I,A.length]);const F=x.useCallback(()=>{r.trim()&&(O(r),i(""))},[r,O]),H=x.useCallback(Q=>{Q.key==="Enter"&&!Q.shiftKey&&(Q.preventDefault(),F())},[F]),K=x.useCallback(()=>{E(),j()},[E,j]);return c&&A.length===0?p.jsxs("div",{className:"flex flex-col h-full",children:[p.jsx("div",{className:"absolute top-4 right-4 z-10",children:p.jsx(LE,{open:d,onOpenChange:m,tempProvider:h,tempModel:S,tempApiKey:v,onProviderChange:g,onModelChange:y,onApiKeyChange:w,onSave:_,onClear:K,showClearButton:!0,buttonLabel:"Change API Key"})}),p.jsx(i0e,{mcpServerUrl:e.url,inputValue:r,isConnected:t,isLoading:I,textareaRef:s,llmConfig:c,onInputChange:i,onKeyDown:H,onSubmit:Q=>{Q.preventDefault(),F()},onConfigDialogOpenChange:m})]}):p.jsxs("div",{className:"flex flex-col h-full relative",children:[p.jsx(n0e,{llmConfig:c,hasMessages:A.length>0,configDialogOpen:d,onConfigDialogOpenChange:m,onClearChat:j,tempProvider:h,tempModel:S,tempApiKey:v,onProviderChange:g,onModelChange:y,onApiKeyChange:w,onSaveConfig:_,onClearConfig:K}),p.jsx("div",{className:"flex-1 overflow-y-auto p-2 sm:p-4 pt-[80px] sm:pt-[100px]",children:c?p.jsx(HEe,{messages:A,isLoading:I,serverId:e.url,readResource:a}):p.jsx(o0e,{onConfigureClick:()=>m(!0)})}),c&&p.jsx(r0e,{inputValue:r,isConnected:t,isLoading:I,textareaRef:s,onInputChange:i,onKeyDown:H,onSendMessage:F})]})}const Ay=x.createContext(null);Ay.displayName="PanelGroupContext";const Wn={group:"data-panel-group",groupDirection:"data-panel-group-direction",groupId:"data-panel-group-id",panel:"data-panel",panelCollapsible:"data-panel-collapsible",panelId:"data-panel-id",panelSize:"data-panel-size",resizeHandle:"data-resize-handle",resizeHandleActive:"data-resize-handle-active",resizeHandleEnabled:"data-panel-resize-handle-enabled",resizeHandleId:"data-panel-resize-handle-id",resizeHandleState:"data-resize-handle-state"},EO=10,Tl=x.useLayoutEffect,N4=Pp.useId,KEe=typeof N4=="function"?N4:()=>null;let ZEe=0;function _O(e=null){const t=KEe(),n=x.useRef(e||t||null);return n.current===null&&(n.current=""+ZEe++),e??n.current}function kK({children:e,className:t="",collapsedSize:n,collapsible:a,defaultSize:r,forwardedRef:i,id:s,maxSize:c,minSize:u,onCollapse:d,onExpand:m,onResize:h,order:g,style:v,tagName:w="div",...S}){const y=x.useContext(Ay);if(y===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:_,expandPanel:E,getPanelSize:k,getPanelStyle:C,groupId:R,isPanelCollapsed:A,reevaluatePanelConstraints:I,registerPanel:O,resizePanel:j,unregisterPanel:F}=y,H=_O(s),K=x.useRef({callbacks:{onCollapse:d,onExpand:m,onResize:h},constraints:{collapsedSize:n,collapsible:a,defaultSize:r,maxSize:c,minSize:u},id:H,idIsFromProps:s!==void 0,order:g});x.useRef({didLogMissingDefaultSizeWarning:!1}),Tl(()=>{const{callbacks:W,constraints:ie}=K.current,V={...ie};K.current.id=H,K.current.idIsFromProps=s!==void 0,K.current.order=g,W.onCollapse=d,W.onExpand=m,W.onResize=h,ie.collapsedSize=n,ie.collapsible=a,ie.defaultSize=r,ie.maxSize=c,ie.minSize=u,(V.collapsedSize!==ie.collapsedSize||V.collapsible!==ie.collapsible||V.maxSize!==ie.maxSize||V.minSize!==ie.minSize)&&I(K.current,V)}),Tl(()=>{const W=K.current;return O(W),()=>{F(W)}},[g,H,O,F]),x.useImperativeHandle(i,()=>({collapse:()=>{_(K.current)},expand:W=>{E(K.current,W)},getId(){return H},getSize(){return k(K.current)},isCollapsed(){return A(K.current)},isExpanded(){return!A(K.current)},resize:W=>{j(K.current,W)}}),[_,E,k,A,H,j]);const Q=C(K.current,r);return x.createElement(w,{...S,children:e,className:t,id:H,style:{...Q,...v},[Wn.groupId]:R,[Wn.panel]:"",[Wn.panelCollapsible]:a||void 0,[Wn.panelId]:H,[Wn.panelSize]:parseFloat(""+Q.flexGrow).toFixed(1)})}const TK=x.forwardRef((e,t)=>x.createElement(kK,{...e,forwardedRef:t}));kK.displayName="Panel";TK.displayName="forwardRef(Panel)";let u_=null,ib=-1,xs=null;function YEe(e,t,n){const a=(t&IK)!==0,r=(t&OK)!==0,i=(t&DK)!==0,s=(t&LK)!==0;if(t){if(a)return i?"se-resize":s?"ne-resize":"e-resize";if(r)return i?"sw-resize":s?"nw-resize":"w-resize";if(i)return"s-resize";if(s)return"n-resize"}switch(e){case"horizontal":return"ew-resize";case"intersection":return"move";case"vertical":return"ns-resize"}}function XEe(){xs!==null&&(document.head.removeChild(xs),u_=null,xs=null,ib=-1)}function ix(e,t,n){var a,r;const i=YEe(e,t);if(u_!==i){if(u_=i,xs===null&&(xs=document.createElement("style"),document.head.appendChild(xs)),ib>=0){var s;(s=xs.sheet)===null||s===void 0||s.removeRule(ib)}ib=(a=(r=xs.sheet)===null||r===void 0?void 0:r.insertRule(`*{cursor: ${i} !important;}`))!==null&&a!==void 0?a:-1}}function NK(e){return e.type==="keydown"}function RK(e){return e.type.startsWith("pointer")}function CK(e){return e.type.startsWith("mouse")}function Iy(e){if(RK(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(CK(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}function qEe(){if(typeof matchMedia=="function")return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}function JEe(e,t,n){return e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y}function QEe(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:A4(e),b:A4(t)};let a;for(;n.a.at(-1)===n.b.at(-1);)e=n.a.pop(),t=n.b.pop(),a=e;_t(a,"Stacking order can only be calculated for elements with a common ancestor");const r={a:C4(R4(n.a)),b:C4(R4(n.b))};if(r.a===r.b){const i=a.childNodes,s={a:n.a.at(-1),b:n.b.at(-1)};let c=i.length;for(;c--;){const u=i[c];if(u===s.a)return 1;if(u===s.b)return-1}}return Math.sign(r.a-r.b)}const e_e=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function t_e(e){var t;const n=getComputedStyle((t=AK(e))!==null&&t!==void 0?t:e).display;return n==="flex"||n==="inline-flex"}function n_e(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||t_e(e))||+t.opacity<1||"transform"in t&&t.transform!=="none"||"webkitTransform"in t&&t.webkitTransform!=="none"||"mixBlendMode"in t&&t.mixBlendMode!=="normal"||"filter"in t&&t.filter!=="none"||"webkitFilter"in t&&t.webkitFilter!=="none"||"isolation"in t&&t.isolation==="isolate"||e_e.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function R4(e){let t=e.length;for(;t--;){const n=e[t];if(_t(n,"Missing node"),n_e(n))return n}return null}function C4(e){return e&&Number(getComputedStyle(e).zIndex)||0}function A4(e){const t=[];for(;e;)t.push(e),e=AK(e);return t}function AK(e){const{parentNode:t}=e;return t&&t instanceof ShadowRoot?t.host:t}const IK=1,OK=2,DK=4,LK=8,r_e=qEe()==="coarse";let gi=[],mu=!1,Es=new Map,Oy=new Map;const wp=new Set;function a_e(e,t,n,a,r){var i;const{ownerDocument:s}=t,c={direction:n,element:t,hitAreaMargins:a,setResizeHandlerState:r},u=(i=Es.get(s))!==null&&i!==void 0?i:0;return Es.set(s,u+1),wp.add(c),lv(),function(){var m;Oy.delete(e),wp.delete(c);const h=(m=Es.get(s))!==null&&m!==void 0?m:1;if(Es.set(s,h-1),lv(),h===1&&Es.delete(s),gi.includes(c)){const g=gi.indexOf(c);g>=0&&gi.splice(g,1),Dy(),r("up",!0,null)}}}function i_e(e){const{target:t}=e,{x:n,y:a}=Iy(e);mu=!0,kO({target:t,x:n,y:a}),lv(),gi.length>0&&(cv("down",e),Dy(),e.preventDefault(),$K(t)||e.stopImmediatePropagation())}function ox(e){const{x:t,y:n}=Iy(e);if(mu&&e.type!=="pointerleave"&&e.buttons===0&&(mu=!1,cv("up",e)),!mu){const{target:a}=e;kO({target:a,x:t,y:n})}cv("move",e),Dy(),gi.length>0&&e.preventDefault()}function sx(e){const{target:t}=e,{x:n,y:a}=Iy(e);Oy.clear(),mu=!1,gi.length>0&&(e.preventDefault(),$K(t)||e.stopImmediatePropagation()),cv("up",e),kO({target:t,x:n,y:a}),Dy(),lv()}function $K(e){let t=e;for(;t;){if(t.hasAttribute(Wn.resizeHandle))return!0;t=t.parentElement}return!1}function kO({target:e,x:t,y:n}){gi.splice(0);let a=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(a=e),wp.forEach(r=>{const{element:i,hitAreaMargins:s}=r,c=i.getBoundingClientRect(),{bottom:u,left:d,right:m,top:h}=c,g=r_e?s.coarse:s.fine;if(t>=d-g&&t<=m+g&&n>=h-g&&n<=u+g){if(a!==null&&document.contains(a)&&i!==a&&!i.contains(a)&&!a.contains(i)&&QEe(a,i)>0){let w=a,S=!1;for(;w&&!w.contains(i);){if(JEe(w.getBoundingClientRect(),c)){S=!0;break}w=w.parentElement}if(S)return}gi.push(r)}})}function lx(e,t){Oy.set(e,t)}function Dy(){let e=!1,t=!1;gi.forEach(a=>{const{direction:r}=a;r==="horizontal"?e=!0:t=!0});let n=0;Oy.forEach(a=>{n|=a}),e&&t?ix("intersection",n):e?ix("horizontal",n):t?ix("vertical",n):XEe()}let cx;function lv(){var e;(e=cx)===null||e===void 0||e.abort(),cx=new AbortController;const t={capture:!0,signal:cx.signal};wp.size&&(mu?(gi.length>0&&Es.forEach((n,a)=>{const{body:r}=a;n>0&&(r.addEventListener("contextmenu",sx,t),r.addEventListener("pointerleave",ox,t),r.addEventListener("pointermove",ox,t))}),Es.forEach((n,a)=>{const{body:r}=a;r.addEventListener("pointerup",sx,t),r.addEventListener("pointercancel",sx,t)})):Es.forEach((n,a)=>{const{body:r}=a;n>0&&(r.addEventListener("pointerdown",i_e,t),r.addEventListener("pointermove",ox,t))}))}function cv(e,t){wp.forEach(n=>{const{setResizeHandlerState:a}=n,r=gi.includes(n);a(e,r,t)})}function o_e(){const[e,t]=x.useState(0);return x.useCallback(()=>t(n=>n+1),[])}function _t(e,t){if(!e)throw console.error(t),Error(t)}function Ul(e,t,n=EO){return e.toFixed(n)===t.toFixed(n)?0:e>t?1:-1}function vo(e,t,n=EO){return Ul(e,t,n)===0}function Ca(e,t,n){return Ul(e,t,n)===0}function s_e(e,t,n){if(e.length!==t.length)return!1;for(let a=0;a<e.length;a++){const r=e[a],i=t[a];if(!Ca(r,i,n))return!1}return!0}function ou({panelConstraints:e,panelIndex:t,size:n}){const a=e[t];_t(a!=null,`Panel constraints not found for index ${t}`);let{collapsedSize:r=0,collapsible:i,maxSize:s=100,minSize:c=0}=a;if(Ul(n,c)<0)if(i){const u=(r+c)/2;Ul(n,u)<0?n=r:n=c}else n=c;return n=Math.min(s,n),n=parseFloat(n.toFixed(EO)),n}function Nf({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:a,prevLayout:r,trigger:i}){if(Ca(e,0))return t;const s=[...t],[c,u]=a;_t(c!=null,"Invalid first pivot index"),_t(u!=null,"Invalid second pivot index");let d=0;if(i==="keyboard"){{const h=e<0?u:c,g=n[h];_t(g,`Panel constraints not found for index ${h}`);const{collapsedSize:v=0,collapsible:w,minSize:S=0}=g;if(w){const y=t[h];if(_t(y!=null,`Previous layout not found for panel index ${h}`),Ca(y,v)){const _=S-y;Ul(_,Math.abs(e))>0&&(e=e<0?0-_:_)}}}{const h=e<0?c:u,g=n[h];_t(g,`No panel constraints found for index ${h}`);const{collapsedSize:v=0,collapsible:w,minSize:S=0}=g;if(w){const y=t[h];if(_t(y!=null,`Previous layout not found for panel index ${h}`),Ca(y,S)){const _=y-v;Ul(_,Math.abs(e))>0&&(e=e<0?0-_:_)}}}}{const h=e<0?1:-1;let g=e<0?u:c,v=0;for(;;){const S=t[g];_t(S!=null,`Previous layout not found for panel index ${g}`);const _=ou({panelConstraints:n,panelIndex:g,size:100})-S;if(v+=_,g+=h,g<0||g>=n.length)break}const w=Math.min(Math.abs(e),Math.abs(v));e=e<0?0-w:w}{let g=e<0?c:u;for(;g>=0&&g<n.length;){const v=Math.abs(e)-Math.abs(d),w=t[g];_t(w!=null,`Previous layout not found for panel index ${g}`);const S=w-v,y=ou({panelConstraints:n,panelIndex:g,size:S});if(!Ca(w,y)&&(d+=w-y,s[g]=y,d.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?g--:g++}}if(s_e(r,s))return r;{const h=e<0?u:c,g=t[h];_t(g!=null,`Previous layout not found for panel index ${h}`);const v=g+d,w=ou({panelConstraints:n,panelIndex:h,size:v});if(s[h]=w,!Ca(w,v)){let S=v-w,_=e<0?u:c;for(;_>=0&&_<n.length;){const E=s[_];_t(E!=null,`Previous layout not found for panel index ${_}`);const k=E+S,C=ou({panelConstraints:n,panelIndex:_,size:k});if(Ca(E,C)||(S-=C-E,s[_]=C),Ca(S,0))break;e>0?_--:_++}}}const m=s.reduce((h,g)=>g+h,0);return Ca(m,100)?s:r}function l_e({layout:e,panelsArray:t,pivotIndices:n}){let a=0,r=100,i=0,s=0;const c=n[0];_t(c!=null,"No pivot index found"),t.forEach((h,g)=>{const{constraints:v}=h,{maxSize:w=100,minSize:S=0}=v;g===c?(a=S,r=w):(i+=S,s+=w)});const u=Math.min(r,100-i),d=Math.max(a,100-s),m=e[c];return{valueMax:u,valueMin:d,valueNow:m}}function Sp(e,t=document){return Array.from(t.querySelectorAll(`[${Wn.resizeHandleId}][data-panel-group-id="${e}"]`))}function jK(e,t,n=document){const r=Sp(e,n).findIndex(i=>i.getAttribute(Wn.resizeHandleId)===t);return r??null}function MK(e,t,n){const a=jK(e,t,n);return a!=null?[a,a+1]:[-1,-1]}function c_e(e){return e instanceof HTMLElement?!0:typeof e=="object"&&e!==null&&"tagName"in e&&"getAttribute"in e}function PK(e,t=document){if(c_e(t)&&t.dataset.panelGroupId==e)return t;const n=t.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return n||null}function Ly(e,t=document){const n=t.querySelector(`[${Wn.resizeHandleId}="${e}"]`);return n||null}function u_e(e,t,n,a=document){var r,i,s,c;const u=Ly(t,a),d=Sp(e,a),m=u?d.indexOf(u):-1,h=(r=(i=n[m])===null||i===void 0?void 0:i.id)!==null&&r!==void 0?r:null,g=(s=(c=n[m+1])===null||c===void 0?void 0:c.id)!==null&&s!==void 0?s:null;return[h,g]}function d_e({committedValuesRef:e,eagerValuesRef:t,groupId:n,layout:a,panelDataArray:r,panelGroupElement:i,setLayout:s}){x.useRef({didWarnAboutMissingResizeHandle:!1}),Tl(()=>{if(!i)return;const c=Sp(n,i);for(let u=0;u<r.length-1;u++){const{valueMax:d,valueMin:m,valueNow:h}=l_e({layout:a,panelsArray:r,pivotIndices:[u,u+1]}),g=c[u];if(g!=null){const v=r[u];_t(v,`No panel data found for index "${u}"`),g.setAttribute("aria-controls",v.id),g.setAttribute("aria-valuemax",""+Math.round(d)),g.setAttribute("aria-valuemin",""+Math.round(m)),g.setAttribute("aria-valuenow",h!=null?""+Math.round(h):"")}}return()=>{c.forEach((u,d)=>{u.removeAttribute("aria-controls"),u.removeAttribute("aria-valuemax"),u.removeAttribute("aria-valuemin"),u.removeAttribute("aria-valuenow")})}},[n,a,r,i]),x.useEffect(()=>{if(!i)return;const c=t.current;_t(c,"Eager values not found");const{panelDataArray:u}=c,d=PK(n,i);_t(d!=null,`No group found for id "${n}"`);const m=Sp(n,i);_t(m,`No resize handles found for group id "${n}"`);const h=m.map(g=>{const v=g.getAttribute(Wn.resizeHandleId);_t(v,"Resize handle element has no handle id attribute");const[w,S]=u_e(n,v,u,i);if(w==null||S==null)return()=>{};const y=_=>{if(!_.defaultPrevented)switch(_.key){case"Enter":{_.preventDefault();const E=u.findIndex(k=>k.id===w);if(E>=0){const k=u[E];_t(k,`No panel data found for index ${E}`);const C=a[E],{collapsedSize:R=0,collapsible:A,minSize:I=0}=k.constraints;if(C!=null&&A){const O=Nf({delta:Ca(C,R)?I-R:R-C,initialLayout:a,panelConstraints:u.map(j=>j.constraints),pivotIndices:MK(n,v,i),prevLayout:a,trigger:"keyboard"});a!==O&&s(O)}}break}}};return g.addEventListener("keydown",y),()=>{g.removeEventListener("keydown",y)}});return()=>{h.forEach(g=>g())}},[i,e,t,n,a,r,s])}function I4(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function UK(e,t){const n=e==="horizontal",{x:a,y:r}=Iy(t);return n?a:r}function f_e(e,t,n,a,r){const i=n==="horizontal",s=Ly(t,r);_t(s,`No resize handle element found for id "${t}"`);const c=s.getAttribute(Wn.groupId);_t(c,"Resize handle element has no group id attribute");let{initialCursorPosition:u}=a;const d=UK(n,e),m=PK(c,r);_t(m,`No group element found for id "${c}"`);const h=m.getBoundingClientRect(),g=i?h.width:h.height;return(d-u)/g*100}function p_e(e,t,n,a,r,i){if(NK(e)){const s=n==="horizontal";let c=0;e.shiftKey?c=100:r!=null?c=r:c=10;let u=0;switch(e.key){case"ArrowDown":u=s?0:c;break;case"ArrowLeft":u=s?-c:0;break;case"ArrowRight":u=s?c:0;break;case"ArrowUp":u=s?0:-c;break;case"End":u=100;break;case"Home":u=-100;break}return u}else return a==null?0:f_e(e,t,n,a,i)}function m_e({panelDataArray:e}){const t=Array(e.length),n=e.map(i=>i.constraints);let a=0,r=100;for(let i=0;i<e.length;i++){const s=n[i];_t(s,`Panel constraints not found for index ${i}`);const{defaultSize:c}=s;c!=null&&(a++,t[i]=c,r-=c)}for(let i=0;i<e.length;i++){const s=n[i];_t(s,`Panel constraints not found for index ${i}`);const{defaultSize:c}=s;if(c!=null)continue;const u=e.length-a,d=r/u;a++,t[i]=d,r-=d}return t}function Pc(e,t,n){t.forEach((a,r)=>{const i=e[r];_t(i,`Panel data not found for index ${r}`);const{callbacks:s,constraints:c,id:u}=i,{collapsedSize:d=0,collapsible:m}=c,h=n[u];if(h==null||a!==h){n[u]=a;const{onCollapse:g,onExpand:v,onResize:w}=s;w&&w(a,h),m&&(g||v)&&(v&&(h==null||vo(h,d))&&!vo(a,d)&&v(),g&&(h==null||!vo(h,d))&&vo(a,d)&&g())}})}function $g(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n])return!1;return!0}function h_e({defaultSize:e,dragState:t,layout:n,panelData:a,panelIndex:r,precision:i=3}){const s=n[r];let c;return s==null?c=e!=null?e.toFixed(i):"1":a.length===1?c="1":c=s.toFixed(i),{flexBasis:0,flexGrow:c,flexShrink:1,overflow:"hidden",pointerEvents:t!==null?"none":void 0}}function g_e(e,t=10){let n=null;return(...r)=>{n!==null&&clearTimeout(n),n=setTimeout(()=>{e(...r)},t)}}function O4(e){try{if(typeof localStorage<"u")e.getItem=t=>localStorage.getItem(t),e.setItem=(t,n)=>{localStorage.setItem(t,n)};else throw new Error("localStorage not supported in this environment")}catch(t){console.error(t),e.getItem=()=>null,e.setItem=()=>{}}}function zK(e){return`react-resizable-panels:${e}`}function FK(e){return e.map(t=>{const{constraints:n,id:a,idIsFromProps:r,order:i}=t;return r?a:i?`${i}:${JSON.stringify(n)}`:JSON.stringify(n)}).sort((t,n)=>t.localeCompare(n)).join(",")}function BK(e,t){try{const n=zK(e),a=t.getItem(n);if(a){const r=JSON.parse(a);if(typeof r=="object"&&r!=null)return r}}catch{}return null}function b_e(e,t,n){var a,r;const i=(a=BK(e,n))!==null&&a!==void 0?a:{},s=FK(t);return(r=i[s])!==null&&r!==void 0?r:null}function v_e(e,t,n,a,r){var i;const s=zK(e),c=FK(t),u=(i=BK(e,r))!==null&&i!==void 0?i:{};u[c]={expandToSizes:Object.fromEntries(n.entries()),layout:a};try{r.setItem(s,JSON.stringify(u))}catch(d){console.error(d)}}function D4({layout:e,panelConstraints:t}){const n=[...e],a=n.reduce((i,s)=>i+s,0);if(n.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${n.map(i=>`${i}%`).join(", ")}`);if(!Ca(a,100)&&n.length>0)for(let i=0;i<t.length;i++){const s=n[i];_t(s!=null,`No layout data found for index ${i}`);const c=100/a*s;n[i]=c}let r=0;for(let i=0;i<t.length;i++){const s=n[i];_t(s!=null,`No layout data found for index ${i}`);const c=ou({panelConstraints:t,panelIndex:i,size:s});s!=c&&(r+=s-c,n[i]=c)}if(!Ca(r,0))for(let i=0;i<t.length;i++){const s=n[i];_t(s!=null,`No layout data found for index ${i}`);const c=s+r,u=ou({panelConstraints:t,panelIndex:i,size:c});if(s!==u&&(r-=u-s,n[i]=u,Ca(r,0)))break}return n}const y_e=100,Rf={getItem:e=>(O4(Rf),Rf.getItem(e)),setItem:(e,t)=>{O4(Rf),Rf.setItem(e,t)}},L4={};function HK({autoSaveId:e=null,children:t,className:n="",direction:a,forwardedRef:r,id:i=null,onLayout:s=null,keyboardResizeBy:c=null,storage:u=Rf,style:d,tagName:m="div",...h}){const g=_O(i),v=x.useRef(null),[w,S]=x.useState(null),[y,_]=x.useState([]),E=o_e(),k=x.useRef({}),C=x.useRef(new Map),R=x.useRef(0),A=x.useRef({autoSaveId:e,direction:a,dragState:w,id:g,keyboardResizeBy:c,onLayout:s,storage:u}),I=x.useRef({layout:y,panelDataArray:[],panelDataArrayChanged:!1});x.useRef({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),x.useImperativeHandle(r,()=>({getId:()=>A.current.id,getLayout:()=>{const{layout:U}=I.current;return U},setLayout:U=>{const{onLayout:L}=A.current,{layout:P,panelDataArray:G}=I.current,Z=D4({layout:U,panelConstraints:G.map(J=>J.constraints)});I4(P,Z)||(_(Z),I.current.layout=Z,L&&L(Z),Pc(G,Z,k.current))}}),[]),Tl(()=>{A.current.autoSaveId=e,A.current.direction=a,A.current.dragState=w,A.current.id=g,A.current.onLayout=s,A.current.storage=u}),d_e({committedValuesRef:A,eagerValuesRef:I,groupId:g,layout:y,panelDataArray:I.current.panelDataArray,setLayout:_,panelGroupElement:v.current}),x.useEffect(()=>{const{panelDataArray:U}=I.current;if(e){if(y.length===0||y.length!==U.length)return;let L=L4[e];L==null&&(L=g_e(v_e,y_e),L4[e]=L);const P=[...U],G=new Map(C.current);L(e,P,G,y,u)}},[e,y,u]),x.useEffect(()=>{});const O=x.useCallback(U=>{const{onLayout:L}=A.current,{layout:P,panelDataArray:G}=I.current;if(U.constraints.collapsible){const Z=G.map(ee=>ee.constraints),{collapsedSize:J=0,panelSize:se,pivotIndices:le}=fl(G,U,P);if(_t(se!=null,`Panel size not found for panel "${U.id}"`),!vo(se,J)){C.current.set(U.id,se);const ne=Zc(G,U)===G.length-1?se-J:J-se,ce=Nf({delta:ne,initialLayout:P,panelConstraints:Z,pivotIndices:le,prevLayout:P,trigger:"imperative-api"});$g(P,ce)||(_(ce),I.current.layout=ce,L&&L(ce),Pc(G,ce,k.current))}}},[]),j=x.useCallback((U,L)=>{const{onLayout:P}=A.current,{layout:G,panelDataArray:Z}=I.current;if(U.constraints.collapsible){const J=Z.map(ae=>ae.constraints),{collapsedSize:se=0,panelSize:le=0,minSize:ee=0,pivotIndices:ne}=fl(Z,U,G),ce=L??ee;if(vo(le,se)){const ae=C.current.get(U.id),ye=ae!=null&&ae>=ce?ae:ce,Be=Zc(Z,U)===Z.length-1?le-ye:ye-le,_e=Nf({delta:Be,initialLayout:G,panelConstraints:J,pivotIndices:ne,prevLayout:G,trigger:"imperative-api"});$g(G,_e)||(_(_e),I.current.layout=_e,P&&P(_e),Pc(Z,_e,k.current))}}},[]),F=x.useCallback(U=>{const{layout:L,panelDataArray:P}=I.current,{panelSize:G}=fl(P,U,L);return _t(G!=null,`Panel size not found for panel "${U.id}"`),G},[]),H=x.useCallback((U,L)=>{const{panelDataArray:P}=I.current,G=Zc(P,U);return h_e({defaultSize:L,dragState:w,layout:y,panelData:P,panelIndex:G})},[w,y]),K=x.useCallback(U=>{const{layout:L,panelDataArray:P}=I.current,{collapsedSize:G=0,collapsible:Z,panelSize:J}=fl(P,U,L);return _t(J!=null,`Panel size not found for panel "${U.id}"`),Z===!0&&vo(J,G)},[]),Q=x.useCallback(U=>{const{layout:L,panelDataArray:P}=I.current,{collapsedSize:G=0,collapsible:Z,panelSize:J}=fl(P,U,L);return _t(J!=null,`Panel size not found for panel "${U.id}"`),!Z||Ul(J,G)>0},[]),W=x.useCallback(U=>{const{panelDataArray:L}=I.current;L.push(U),L.sort((P,G)=>{const Z=P.order,J=G.order;return Z==null&&J==null?0:Z==null?-1:J==null?1:Z-J}),I.current.panelDataArrayChanged=!0,E()},[E]);Tl(()=>{if(I.current.panelDataArrayChanged){I.current.panelDataArrayChanged=!1;const{autoSaveId:U,onLayout:L,storage:P}=A.current,{layout:G,panelDataArray:Z}=I.current;let J=null;if(U){const le=b_e(U,Z,P);le&&(C.current=new Map(Object.entries(le.expandToSizes)),J=le.layout)}J==null&&(J=m_e({panelDataArray:Z}));const se=D4({layout:J,panelConstraints:Z.map(le=>le.constraints)});I4(G,se)||(_(se),I.current.layout=se,L&&L(se),Pc(Z,se,k.current))}}),Tl(()=>{const U=I.current;return()=>{U.layout=[]}},[]);const ie=x.useCallback(U=>{let L=!1;const P=v.current;return P&&window.getComputedStyle(P,null).getPropertyValue("direction")==="rtl"&&(L=!0),function(Z){Z.preventDefault();const J=v.current;if(!J)return()=>null;const{direction:se,dragState:le,id:ee,keyboardResizeBy:ne,onLayout:ce}=A.current,{layout:ae,panelDataArray:ye}=I.current,{initialLayout:ke}=le??{},Be=MK(ee,U,J);let _e=p_e(Z,U,se,le,ne,J);const Se=se==="horizontal";Se&&L&&(_e=-_e);const ze=ye.map(Fe=>Fe.constraints),pe=Nf({delta:_e,initialLayout:ke??ae,panelConstraints:ze,pivotIndices:Be,prevLayout:ae,trigger:NK(Z)?"keyboard":"mouse-or-touch"}),Le=!$g(ae,pe);(RK(Z)||CK(Z))&&R.current!=_e&&(R.current=_e,!Le&&_e!==0?Se?lx(U,_e<0?IK:OK):lx(U,_e<0?DK:LK):lx(U,0)),Le&&(_(pe),I.current.layout=pe,ce&&ce(pe),Pc(ye,pe,k.current))}},[]),V=x.useCallback((U,L)=>{const{onLayout:P}=A.current,{layout:G,panelDataArray:Z}=I.current,J=Z.map(ae=>ae.constraints),{panelSize:se,pivotIndices:le}=fl(Z,U,G);_t(se!=null,`Panel size not found for panel "${U.id}"`);const ne=Zc(Z,U)===Z.length-1?se-L:L-se,ce=Nf({delta:ne,initialLayout:G,panelConstraints:J,pivotIndices:le,prevLayout:G,trigger:"imperative-api"});$g(G,ce)||(_(ce),I.current.layout=ce,P&&P(ce),Pc(Z,ce,k.current))},[]),Y=x.useCallback((U,L)=>{const{layout:P,panelDataArray:G}=I.current,{collapsedSize:Z=0,collapsible:J}=L,{collapsedSize:se=0,collapsible:le,maxSize:ee=100,minSize:ne=0}=U.constraints,{panelSize:ce}=fl(G,U,P);ce!=null&&(J&&le&&vo(ce,Z)?vo(Z,se)||V(U,se):ce<ne?V(U,ne):ce>ee&&V(U,ee))},[V]),z=x.useCallback((U,L)=>{const{direction:P}=A.current,{layout:G}=I.current;if(!v.current)return;const Z=Ly(U,v.current);_t(Z,`Drag handle element not found for id "${U}"`);const J=UK(P,L);S({dragHandleId:U,dragHandleRect:Z.getBoundingClientRect(),initialCursorPosition:J,initialLayout:G})},[]),te=x.useCallback(()=>{S(null)},[]),re=x.useCallback(U=>{const{panelDataArray:L}=I.current,P=Zc(L,U);P>=0&&(L.splice(P,1),delete k.current[U.id],I.current.panelDataArrayChanged=!0,E())},[E]),$=x.useMemo(()=>({collapsePanel:O,direction:a,dragState:w,expandPanel:j,getPanelSize:F,getPanelStyle:H,groupId:g,isPanelCollapsed:K,isPanelExpanded:Q,reevaluatePanelConstraints:Y,registerPanel:W,registerResizeHandle:ie,resizePanel:V,startDragging:z,stopDragging:te,unregisterPanel:re,panelGroupElement:v.current}),[O,w,a,j,F,H,g,K,Q,Y,W,ie,V,z,te,re]),B={display:"flex",flexDirection:a==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return x.createElement(Ay.Provider,{value:$},x.createElement(m,{...h,children:t,className:n,id:i,ref:v,style:{...B,...d},[Wn.group]:"",[Wn.groupDirection]:a,[Wn.groupId]:g}))}const VK=x.forwardRef((e,t)=>x.createElement(HK,{...e,forwardedRef:t}));HK.displayName="PanelGroup";VK.displayName="forwardRef(PanelGroup)";function Zc(e,t){return e.findIndex(n=>n===t||n.id===t.id)}function fl(e,t,n){const a=Zc(e,t),i=a===e.length-1?[a-1,a]:[a,a+1],s=n[a];return{...t.constraints,panelSize:s,pivotIndices:i}}function w_e({disabled:e,handleId:t,resizeHandler:n,panelGroupElement:a}){x.useEffect(()=>{if(e||n==null||a==null)return;const r=Ly(t,a);if(r==null)return;const i=s=>{if(!s.defaultPrevented)switch(s.key){case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"End":case"Home":{s.preventDefault(),n(s);break}case"F6":{s.preventDefault();const c=r.getAttribute(Wn.groupId);_t(c,`No group element found for id "${c}"`);const u=Sp(c,a),d=jK(c,t,a);_t(d!==null,`No resize element found for id "${t}"`);const m=s.shiftKey?d>0?d-1:u.length-1:d+1<u.length?d+1:0;u[m].focus();break}}};return r.addEventListener("keydown",i),()=>{r.removeEventListener("keydown",i)}},[a,e,t,n])}function GK({children:e=null,className:t="",disabled:n=!1,hitAreaMargins:a,id:r,onBlur:i,onClick:s,onDragging:c,onFocus:u,onPointerDown:d,onPointerUp:m,style:h={},tabIndex:g=0,tagName:v="div",...w}){var S,y;const _=x.useRef(null),E=x.useRef({onClick:s,onDragging:c,onPointerDown:d,onPointerUp:m});x.useEffect(()=>{E.current.onClick=s,E.current.onDragging=c,E.current.onPointerDown=d,E.current.onPointerUp=m});const k=x.useContext(Ay);if(k===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:C,groupId:R,registerResizeHandle:A,startDragging:I,stopDragging:O,panelGroupElement:j}=k,F=_O(r),[H,K]=x.useState("inactive"),[Q,W]=x.useState(!1),[ie,V]=x.useState(null),Y=x.useRef({state:H});Tl(()=>{Y.current.state=H}),x.useEffect(()=>{if(n)V(null);else{const $=A(F);V(()=>$)}},[n,F,A]);const z=(S=a?.coarse)!==null&&S!==void 0?S:15,te=(y=a?.fine)!==null&&y!==void 0?y:5;x.useEffect(()=>{if(n||ie==null)return;const $=_.current;_t($,"Element ref not attached");let B=!1;return a_e(F,$,C,{coarse:z,fine:te},(L,P,G)=>{if(!P){K("inactive");return}switch(L){case"down":{K("drag"),B=!1,_t(G,'Expected event to be defined for "down" action'),I(F,G);const{onDragging:Z,onPointerDown:J}=E.current;Z?.(!0),J?.();break}case"move":{const{state:Z}=Y.current;B=!0,Z!=="drag"&&K("hover"),_t(G,'Expected event to be defined for "move" action'),ie(G);break}case"up":{K("hover"),O();const{onClick:Z,onDragging:J,onPointerUp:se}=E.current;J?.(!1),se?.(),B||Z?.();break}}})},[z,C,n,te,A,F,ie,I,O]),w_e({disabled:n,handleId:F,resizeHandler:ie,panelGroupElement:j});const re={touchAction:"none",userSelect:"none"};return x.createElement(v,{...w,children:e,className:t,id:r,onBlur:()=>{W(!1),i?.()},onFocus:()=>{W(!0),u?.()},ref:_,role:"separator",style:{...re,...h},tabIndex:g,[Wn.groupDirection]:C,[Wn.groupId]:R,[Wn.resizeHandle]:"",[Wn.resizeHandleActive]:H==="drag"?"pointer":Q?"keyboard":void 0,[Wn.resizeHandleEnabled]:!n,[Wn.resizeHandleId]:F,[Wn.resizeHandleState]:H})}GK.displayName="PanelResizeHandle";function Da({className:e,...t}){return p.jsx(VK,{"data-slot":"resizable-panel-group",className:De("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...t})}function zn({...e}){return p.jsx(TK,{"data-slot":"resizable-panel",...e})}function Ui({withHandle:e,className:t,...n}){return p.jsx(GK,{"data-slot":"resizable-handle",className:De("bg-border focus-visible:ring-ring relative flex w-px items-center justify-center after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:ring-1 focus-visible:ring-offset-1 focus-visible:outline-hidden data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:h-1 data-[panel-group-direction=vertical]:after:w-full data-[panel-group-direction=vertical]:after:translate-x-0 data-[panel-group-direction=vertical]:after:-translate-y-1/2 [&[data-panel-group-direction=vertical]>div]:rotate-90",t),...n,children:e&&p.jsx("div",{className:"bg-border z-10 flex h-4 w-3 items-center justify-center rounded-xs border",children:p.jsx(lpe,{className:"size-2.5"})})})}function $y({className:e,...t}){return p.jsx("kbd",{"data-slot":"kbd",className:De("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})}function S_e({isSearchExpanded:e,searchQuery:t,filteredNotificationsCount:n,notificationsCount:a,onSearchExpand:r,onSearchChange:i,onSearchBlur:s,onClearAll:c,searchInputRef:u}){return p.jsxs("div",{className:"flex flex-row items-center justify-between p-4 sm:p-4 py-3 gap-2",children:[p.jsx("div",{className:"flex items-center gap-2 flex-1",children:e?p.jsx(jn,{ref:u,placeholder:"Search notifications...",value:t,onChange:d=>i(d.target.value),onBlur:s,className:"h-8 border-gray-300 dark:border-zinc-600"}):p.jsxs(p.Fragment,{children:[p.jsx("h2",{className:"text-lg font-medium text-gray-900 dark:text-gray-100",children:"Notifications"}),p.jsx(Jr,{className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",variant:"outline",children:n}),p.jsxs(en,{children:[p.jsx(tn,{asChild:!0,children:p.jsx(Ue,{variant:"ghost",size:"sm",onClick:r,className:"h-8 w-8 p-0",children:p.jsx(qp,{className:"h-4 w-4"})})}),p.jsxs(nn,{side:"bottom",className:"flex gap-2",children:["Search",p.jsx($y,{children:"F"})]})]})]})}),p.jsx("div",{className:"flex items-center gap-2",children:p.jsxs(en,{children:[p.jsx(tn,{asChild:!0,children:p.jsx(Ue,{variant:"ghost",size:"sm",onClick:c,disabled:a===0,className:"h-8 w-8 p-0",children:p.jsx(Is,{className:"h-4 w-4"})})}),p.jsx(nn,{side:"bottom",children:"Clear all"})]})})]})}function Xl({id:e,isSelected:t,isFocused:n,icon:a,title:r,description:i,metadata:s,onClick:c,className:u}){return p.jsx("button",{id:e,type:"button",onClick:c,className:De("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",u),children:p.jsxs("div",{className:"flex items-start gap-2 sm:gap-3",children:[a&&p.jsx("div",{className:"flex-shrink-0 mt-1",children:p.jsx("div",{className:De("p-2.5 rounded-full transition-colors",t?"bg-zinc-500 dark:bg-zinc-100/80 text-zinc-100 dark:text-zinc-900":"bg-gray-100 dark:bg-zinc-700 text-gray-600 dark:text-gray-400 group-hover:bg-gray-200 dark:group-hover:bg-zinc-600"),children:a})}),p.jsxs("div",{className:"flex-1 min-w-0",children:[p.jsx("div",{className:"flex items-center gap-2 mb-1",children:p.jsx("h3",{className:De("font-medium truncate font-mono text-sm"),children:r})}),i&&p.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 line-clamp-2",children:i})]})]})})}function x_e({notifications:e,selectedNotification:t,onNotificationSelect:n,focusedIndex:a,formatRelativeTime:r,listRef:i}){return e.length===0?p.jsx("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:p.jsx(Yp,{vertical:!0,noBorder:!0,message:"No notifications yet"})}):p.jsx("div",{ref:i,className:"overflow-y-auto flex-1 overscroll-contain",children:e.map((s,c)=>p.jsx(Xl,{id:`notification-${s.id}`,isSelected:t?.id===s.id,isFocused:a===c,title:p.jsxs("span",{className:"flex items-center gap-3",children:[s.method,!s.read&&p.jsx("span",{className:"size-1.5 block rounded-full bg-orange-500"})]}),description:(()=>{const u=r(s.timestamp),d=s.params&&Object.keys(s.params).length>0?Object.keys(s.params).length:0,m=d>0?` | ${d} param${d>1?"s":""}`:"";return u+m})(),onClick:()=>n(s)},s.id))})}function E_e({notification:e,previewMode:t,onTogglePreview:n,onCopy:a,onDownload:r,onFullscreen:i,isCopied:s=!1,onClose:c}){return e?p.jsxs("div",{className:"flex flex-col h-full",children:[p.jsxs("div",{className:"flex-shrink-0 px-4 py-3 border-b border-gray-200 dark:border-zinc-700 flex items-center justify-between",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsxs("div",{className:"flex items-center gap-1",children:[p.jsx(ju,{className:"h-3 w-3 text-gray-400"}),p.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:new Date(e.timestamp).toLocaleTimeString()})]}),p.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:e.formatRelativeTime(e.timestamp)})]}),p.jsxs("div",{className:"flex items-center gap-1",children:[p.jsxs(Ue,{variant:"ghost",size:"sm",onClick:n,className:t?"":"text-purple-600 dark:text-purple-400",children:[t?p.jsx(P9,{className:"h-4 w-4 mr-1"}):p.jsx(M9,{className:"h-4 w-4 mr-1"}),t?"JSON":"Formatted"]}),p.jsx(Ue,{variant:"ghost",size:"sm",onClick:a,children:s?p.jsx(La,{className:"h-4 w-4"}):p.jsx(Xr,{className:"h-4 w-4"})}),p.jsx(Ue,{variant:"ghost",size:"sm",onClick:r,children:p.jsx(ny,{className:"h-4 w-4"})}),p.jsx(Ue,{variant:"ghost",size:"sm",onClick:i,children:p.jsx(tN,{className:"h-4 w-4"})}),c&&p.jsx(Ue,{variant:"ghost",size:"sm",onClick:c,children:p.jsx(Gl,{className:"h-4 w-4"})})]})]}),p.jsx("div",{className:"flex-1 overflow-y-auto",children:p.jsx("div",{className:"px-4 pt-4",children:p.jsx(ir,{data:{method:e.method,timestamp:e.timestamp,read:e.read,params:e.params},filename:`notification-${e.method.replace(/[^a-zA-Z0-9]/g,"-")}-${Date.now()}.json`})})})]}):p.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[p.jsx(JT,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),p.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"Select a notification to view details"})]})}function d_(e){const n=Date.now()-e,a=Math.floor(n/1e3),r=Math.floor(a/60),i=Math.floor(r/60),s=Math.floor(i/24);return a<60?"just now":r<60?`${r}m ago`:i<24?`${i}h ago`:s<7?`${s}d ago`:new Date(e).toLocaleDateString()}function __e({notifications:e,unreadCount:t,markNotificationRead:n,markAllNotificationsRead:a,clearNotifications:r,serverId:i,isConnected:s}){const[c,u]=x.useState(null),[d,m]=x.useState(""),[h,g]=x.useState(-1),[v,w]=x.useState(!0),[S,y]=x.useState(!1),[_,E]=x.useState(!0),[k,C]=x.useState(!1),R=x.useRef(null),A=x.useRef(null),I=x.useRef(null),O=x.useRef(!1);x.useEffect(()=>{v&&e.length>0&&R.current&&!O.current&&(R.current.scrollTop=0)},[e.length,v]),x.useEffect(()=>{const Y=R.current;if(!Y)return;const z=()=>{Y.scrollTop>0&&(O.current=!0,w(!1))};return Y.addEventListener("scroll",z),()=>Y.removeEventListener("scroll",z)},[]),x.useEffect(()=>{e.length===0&&(O.current=!1,w(!0))},[e.length]),x.useEffect(()=>{c&&!c.read&&n(c.id)},[c,n]),x.useEffect(()=>{S&&I.current&&I.current.focus()},[S]);const j=x.useCallback(()=>{d.trim()||y(!1)},[d]),F=x.useMemo(()=>{if(!d.trim())return e;const Y=d.toLowerCase();return e.filter(z=>z.method.toLowerCase().includes(Y)||JSON.stringify(z.params||{}).toLowerCase().includes(Y))},[e,d]);x.useEffect(()=>{g(-1)},[d]),x.useEffect(()=>{const Y=z=>{const te=z.target;if(te.tagName==="INPUT"||te.tagName==="TEXTAREA"||te.contentEditable==="true"||z.metaKey||z.ctrlKey||z.altKey)return;const $=F;if(z.key==="ArrowDown")z.preventDefault(),g(B=>{const U=B+1;return U>=$.length?0:U});else if(z.key==="ArrowUp")z.preventDefault(),g(B=>{const U=B-1;return U<0?$.length-1:U});else if(z.key==="Enter"&&h>=0){z.preventDefault();const B=F[h];B&&H(B)}};return document.addEventListener("keydown",Y),()=>document.removeEventListener("keydown",Y)},[h,F]),x.useEffect(()=>{if(h>=0){const Y=`notification-${F[h]?.id}`,z=document.getElementById(Y);z&&z.scrollIntoView({behavior:"smooth",block:"nearest"})}},[h,F]);const H=x.useCallback(Y=>{u(Y)},[]),K=x.useCallback(()=>{window.confirm("Are you sure you want to clear all notifications? This cannot be undone.")&&(r(),u(null))},[r]),Q=x.useCallback(async()=>{if(c)try{await navigator.clipboard.writeText(JSON.stringify({method:c.method,timestamp:c.timestamp,read:c.read,params:c.params},null,2)),C(!0),setTimeout(()=>C(!1),2e3)}catch(Y){console.error("[NotificationsTab] Failed to copy notification:",Y)}},[c]),W=x.useCallback(()=>{if(c)try{const Y=new globalThis.Blob([JSON.stringify({method:c.method,timestamp:c.timestamp,read:c.read,params:c.params},null,2)],{type:"application/json"}),z=URL.createObjectURL(Y),te=document.createElement("a");te.href=z,te.download=`notification-${Date.now()}.json`,document.body.appendChild(te),te.click(),document.body.removeChild(te),URL.revokeObjectURL(z)}catch(Y){console.error("[NotificationsTab] Failed to download notification:",Y)}},[c]),ie=x.useCallback(async()=>{if(A.current)try{document.fullscreenElement?await document.exitFullscreen():await A.current.requestFullscreen()}catch(Y){console.error("[NotificationsTab] Failed to toggle fullscreen:",Y)}},[]),V=c?{method:c.method,params:c.params,timestamp:c.timestamp,read:c.read,formatRelativeTime:d_}:null;return s?p.jsxs(Da,{direction:"horizontal",className:"h-full",children:[p.jsx(zn,{defaultSize:40,minSize:30,children:p.jsx(Da,{direction:"vertical",className:"h-full border-r dark:border-zinc-700",children:p.jsxs(zn,{defaultSize:75,minSize:30,children:[p.jsx(S_e,{isSearchExpanded:S,searchQuery:d,filteredNotificationsCount:F.length,notificationsCount:e.length,onSearchExpand:()=>y(!0),onSearchChange:m,onSearchBlur:j,onClearAll:K,searchInputRef:I}),p.jsx("div",{className:"flex flex-col h-full",children:p.jsx(x_e,{notifications:F,selectedNotification:c,onNotificationSelect:H,focusedIndex:h,formatRelativeTime:d_,listRef:R})})]})})}),p.jsx(Ui,{}),p.jsx(zn,{defaultSize:60,minSize:40,children:p.jsx("div",{ref:A,className:"h-full bg-white dark:bg-zinc-900",children:p.jsx(E_e,{notification:V,previewMode:_,onTogglePreview:()=>E(!_),onCopy:Q,onDownload:W,onFullscreen:ie,onClose:()=>u(null),isCopied:k})})})]}):p.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[p.jsx(JT,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),p.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"Not connected to server"})]})}function WK({activeTab:e,isSearchExpanded:t,searchQuery:n,primaryTabTitle:a,secondaryTabTitle:r,primaryCount:i,secondaryCount:s,secondaryIcon:c,primaryIcon:u,searchPlaceholder:d="Search...",onSearchExpand:m,onSearchChange:h,onSearchBlur:g,onTabSwitch:v,searchInputRef:w,primaryTabName:S}){const y=e===S;return p.jsxs("div",{className:"flex flex-row items-center justify-between p-4 sm:p-4 py-3 gap-2",children:[p.jsx("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:t?p.jsx(jn,{ref:w,placeholder:d,value:n,onChange:_=>h(_.target.value),onBlur:g,className:"h-8 border-gray-300 dark:border-zinc-600"}):p.jsxs(p.Fragment,{children:[p.jsx("h2",{className:"text-lg font-medium text-gray-900 dark:text-gray-100",children:y?a:r}),y&&p.jsxs(p.Fragment,{children:[p.jsx(Jr,{className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",variant:"outline",children:i}),p.jsxs(en,{children:[p.jsx(tn,{asChild:!0,children:p.jsx(Ue,{variant:"ghost",size:"sm",onClick:m,className:"h-8 w-8 p-0",children:p.jsx(qp,{className:"h-4 w-4"})})}),p.jsxs(nn,{side:"bottom",className:"flex gap-2",children:["Search",p.jsx($y,{children:"F"})]})]})]})]})}),p.jsxs(Ue,{variant:"ghost",size:"sm",onClick:v,className:"gap-2 flex-shrink-0",children:[y?p.jsx(c,{}):p.jsx(u,{}),p.jsx("span",{className:"hidden sm:inline",children:y?r:a}),y&&s>0&&p.jsx(Jr,{className:"bg-purple-500/20 text-purple-600 dark:text-purple-400 border-transparent",variant:"outline",children:s})]})]})}function $4({prompts:e,selectedPrompt:t,onPromptSelect:n,focusedIndex:a}){return e.length===0?p.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[p.jsx(ip,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),p.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"No prompts available"})]}):p.jsx("div",{className:"overflow-y-auto flex-1 border-r dark:border-zinc-700 overscroll-contain",children:e.map((r,i)=>p.jsx(Xl,{id:`prompt-${r.name}`,isSelected:t?.name===r.name,isFocused:a===i,icon:p.jsx(ip,{className:"h-4 w-4"}),title:r.name,description:r.description,metadata:r.arguments&&r.arguments.length>0&&p.jsxs(Jr,{variant:"outline",className:"text-xs border-gray-300 dark:border-zinc-600 text-gray-600 dark:text-gray-400",children:[r.arguments.length," args"]}),onClick:()=>n(r)},r.name))})}function j4({activeTab:e,isSearchExpanded:t,searchQuery:n,filteredPromptsCount:a,savedPromptsCount:r,onSearchExpand:i,onSearchChange:s,onSearchBlur:c,onTabSwitch:u,searchInputRef:d}){return p.jsx(WK,{activeTab:e,isSearchExpanded:t,searchQuery:n,primaryTabName:"prompts",secondaryTabName:"saved",primaryTabTitle:"Prompts",secondaryTabTitle:"History",primaryCount:a,secondaryCount:r,primaryIcon:ip,secondaryIcon:ju,searchPlaceholder:"Search prompts...",onSearchExpand:i,onSearchChange:s,onSearchBlur:c,onTabSwitch:u,searchInputRef:d})}function M4({savedPrompts:e,selectedPrompt:t,onLoadPrompt:n,onDeletePrompt:a,focusedIndex:r}){return e.length===0?p.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[p.jsx(ju,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),p.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"No history"}),p.jsx("p",{className:"text-sm text-gray-400 dark:text-gray-500 mt-1",children:"Prompts you execute will appear here"})]}):p.jsx("div",{className:"overflow-y-auto flex-1 border-r dark:border-zinc-700 overscroll-contain",children:e.map((i,s)=>p.jsx(Xl,{id:`saved-prompt-${i.id}`,isSelected:t?.id===i.id,isFocused:r===s,icon:p.jsx(ju,{className:"h-4 w-4"}),title:i.name,description:`${i.promptName} - ${new Date(i.savedAt).toLocaleString()}`,onClick:()=>n(i)},i.id))})}function k_e({selectedPrompt:e,promptArgs:t,onArgChange:n}){const a=e?.arguments||[];if(!(a.length>0))return p.jsx("div",{className:"flex items-center justify-center h-32 text-gray-500 dark:text-gray-400 text-sm",children:"No arguments required"});const i=s=>{const c=s.name,u=t[c],d=typeof u=="string"?u:JSON.stringify(u);return s.type==="boolean"?p.jsxs("div",{className:"space-y-2",children:[p.jsxs(Yt,{htmlFor:c,className:"text-sm font-medium",children:[c,s.required&&p.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),p.jsxs("div",{className:"flex items-center space-x-2",children:[p.jsx("input",{id:c,type:"checkbox",checked:!!u,onChange:m=>n(c,m.target.checked),className:"rounded","aria-label":`Toggle ${c}`}),p.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:s.description})]})]},c):s.type==="number"?p.jsxs("div",{className:"space-y-2",children:[p.jsxs(Yt,{htmlFor:c,className:"text-sm font-medium",children:[c,s.required&&p.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),p.jsx(jn,{id:c,type:"number",value:Number(u)||0,onChange:m=>n(c,Number(m.target.value)),placeholder:s.description||`Enter ${c}`}),s.description&&p.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:s.description})]},c):s.type==="array"||s.type==="object"?p.jsxs("div",{className:"space-y-2",children:[p.jsxs(Yt,{htmlFor:c,className:"text-sm font-medium",children:[c,s.required&&p.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),p.jsx(zu,{id:c,value:d,onChange:m=>{try{const h=JSON.parse(m.target.value);n(c,h)}catch{n(c,m.target.value)}},placeholder:s.description||`Enter ${c} as JSON`,className:"font-mono text-sm min-h-[100px]"}),s.description&&p.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:s.description})]},c):p.jsxs("div",{className:"space-y-2",children:[p.jsxs(Yt,{htmlFor:c,className:"text-sm font-medium",children:[c,s.required&&p.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),p.jsx(jn,{id:c,value:d,onChange:m=>n(c,m.target.value),placeholder:s.description||`Enter ${c}`}),s.description&&p.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:s.description})]},c)};return p.jsx("div",{className:"space-y-4",children:a.map(s=>i(s))})}function P4({selectedPrompt:e,promptArgs:t,isExecuting:n,isConnected:a,onArgChange:r,onExecute:i,onSave:s}){return e?p.jsxs("div",{className:"flex flex-col h-full",children:[p.jsx("div",{className:"flex-shrink-0 p-3 sm:p-6 pt-3 pb-4 pr-3",children:p.jsxs("div",{children:[p.jsxs("div",{className:"flex flex-row items-center justify-between mb-0 gap-2",children:[p.jsx("h3",{className:"text-base sm:text-lg font-semibold",children:e.name}),p.jsxs("div",{className:"flex gap-2 flex-shrink-0",children:[p.jsx(Ue,{onClick:i,disabled:n||!a,size:"sm",className:"lg:size-default",children:n?p.jsxs(p.Fragment,{children:[p.jsx(Lo,{className:"mr-2"}),p.jsx("span",{className:"hidden sm:inline",children:"Executing..."})]}):p.jsxs(p.Fragment,{children:[p.jsx(H9,{className:"h-4 w-4 sm:mr-2"}),p.jsx("span",{className:"hidden sm:inline",children:"Execute"})]})}),p.jsxs(Ue,{variant:"outline",onClick:s,disabled:n,size:"sm",className:"lg:size-default gap-2",children:[p.jsx(nN,{className:"h-4 w-4"}),p.jsx("span",{className:"hidden sm:inline",children:"Save"})]})]})]}),e.description&&p.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 leading-relaxed mt-2",children:e.description})]})}),p.jsx("div",{className:"flex-1 overflow-y-auto px-3 sm:px-6 pb-4 pr-3",children:p.jsx(k_e,{selectedPrompt:e,promptArgs:t,onArgChange:r})})]}):p.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[p.jsx("p",{className:"text-gray-500 dark:text-gray-400 mb-2",children:"Select a prompt to get started"}),p.jsx("p",{className:"text-xs text-gray-400 dark:text-gray-500",children:"Choose a prompt from the list to view its details and execute it"})]})}function U4({results:e,copiedResult:t,onCopy:n}){return p.jsx("div",{className:"flex flex-col h-full bg-white dark:bg-black border-t dark:border-zinc-700",children:p.jsx("div",{className:"flex-1 overflow-y-auto h-full",children:e.length>0?p.jsx("div",{className:"space-y-4 flex-1 h-full",children:e.map((a,r)=>p.jsxs("div",{className:"space-y-0 flex-1 h-full flex flex-col",children:[p.jsxs("div",{className:"flex items-center gap-2 px-4 pt-2 border-b border-gray-200 dark:border-zinc-600 pb-2",children:[p.jsx("h3",{className:"text-sm font-medium",children:"Response"}),p.jsxs("div",{className:"flex items-center gap-1",children:[p.jsx(ju,{className:"h-3 w-3 text-gray-400"}),p.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:new Date(a.timestamp).toLocaleTimeString()})]}),a.duration!==void 0&&p.jsxs("div",{className:"flex items-center gap-1",children:[p.jsx(op,{className:"h-3 w-3 text-gray-400"}),p.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:[a.duration,"ms"]})]}),p.jsx("div",{className:"flex gap-2 ml-auto",children:p.jsx(Ue,{variant:"ghost",size:"sm",onClick:()=>n(r,a.result),className:"h-6 px-2",children:t===r?p.jsx(La,{className:"h-4 w-4"}):p.jsx(Xr,{className:"h-4 w-4"})})})]}),a.error?p.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded p-3 mx-4",children:[p.jsx("p",{className:"text-red-800 dark:text-red-300 font-medium",children:"Error:"}),p.jsx("p",{className:"text-red-700 dark:text-red-400 text-sm",children:a.error})]}):p.jsx("div",{className:"px-4 pt-4",children:p.jsx(ir,{data:a.result,filename:`prompt-result-${a.promptName}-${Date.now()}.json`})})]},r))}):p.jsx("div",{className:"flex items-center justify-center h-full",children:p.jsx("div",{className:"text-center",children:p.jsx(Yp,{vertical:!0,noBorder:!0,message:"No Results yet"})})})})})}function TO({serverIds:e,onCountChange:t,onClearRef:n}={}){const[a,r]=x.useState([]),i=x.useRef(null),[s,c]=x.useState(new Set),[u]=x.useState(""),d=v=>{c(w=>{const S=new Set(w);return S.has(v)?S.delete(v):S.add(v),S})},m=async()=>{r([]),c(new Set),t?.(0);try{const v=new URLSearchParams;e&&e.length>0&&v.set("serverIds",e.join(","));const w=await fetch(`/inspector/api/rpc/log?${v.toString()}`,{method:"DELETE"});w.ok||console.warn("[RPC Logger] Failed to clear server buffer:",w.status)}catch(v){console.warn("[RPC Logger] Error clearing server buffer:",v)}},h=x.useMemo(()=>!e||e.length===0?"":[...e].sort().join(","),[e]);x.useEffect(()=>(n&&(n.current=m),()=>{n&&(n.current=null)}),[n,m]),x.useEffect(()=>{t?.(a.length)},[a.length,t]),x.useEffect(()=>{let v=null;try{const w=new URLSearchParams;w.set("replay","3"),w.set("_t",Date.now().toString()),e&&e.length>0&&w.set("serverIds",e.join(","));const S=`/inspector/api/rpc/stream?${w.toString()}`;console.log("[RPC Logger] Connecting to SSE stream:",S),v=new globalThis.EventSource(S),v.onopen=()=>{console.log("[RPC Logger] SSE connection opened")},v.onmessage=y=>{try{const _=JSON.parse(y.data);if(!_||_.type!=="rpc")return;const{serverId:E,direction:k,message:C,timestamp:R}=_,A=C,I=typeof A?.method=="string"?A.method:A?.result!==void 0?"result":A?.error!==void 0?"error":"unknown",O={id:`${R??Date.now()}-${Math.random().toString(36).slice(2)}`,serverId:typeof E=="string"?E:"unknown",direction:typeof k=="string"?k.toUpperCase():"",method:I,timestamp:R??new Date().toISOString(),payload:C};console.log("[RPC Logger] Received RPC event:",{method:I,direction:k,serverId:E}),r(j=>{const F=[O,...j].slice(0,1e3);return t?.(F.length),F})}catch(_){console.error("[RPC Logger] Error parsing SSE message:",_)}},v.onerror=y=>{console.error("[RPC Logger] SSE connection error:",y);try{v?.close()}catch{}}}catch(w){console.error("[RPC Logger] Failed to create SSE connection:",w)}return()=>{try{v?.close(),console.log("[RPC Logger] SSE connection closed")}catch{}}},[h]);const g=x.useMemo(()=>{let v=a;if(e&&e.length>0){const w=new Set(e);v=v.filter(S=>w.has(S.serverId))}if(u.trim()){const w=u.toLowerCase();v=v.filter(S=>S.serverId.toLowerCase().includes(w)||S.method.toLowerCase().includes(w)||S.direction.toLowerCase().includes(w)||JSON.stringify(S.payload).toLowerCase().includes(w))}return v},[a,u,e]);return p.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:p.jsx("div",{ref:i,className:"flex-1 min-h-0 overflow-y-auto",children:g.length===0?p.jsxs("div",{className:"text-center py-8",children:[p.jsx("div",{className:"text-xs text-muted-foreground",children:"No messages yet"}),p.jsx("div",{className:"text-[10px] text-muted-foreground mt-1",children:"JSON-RPC messages will appear here"})]}):g.map(v=>{const w=s.has(v.id);return p.jsxs("div",{className:"group hover:bg-muted/50 transition-all duration-200 overflow-hidden",children:[p.jsxs("div",{className:"px-3 py-2 flex items-center gap-2 cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>d(v.id),children:[p.jsx("div",{className:"flex-shrink-0",children:w?p.jsx(Vl,{className:"h-3 w-3 text-muted-foreground transition-transform"}):p.jsx(Cfe,{className:"h-3 w-3 text-muted-foreground transition-transform"})}),p.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[p.jsx("span",{className:"text-muted-foreground font-mono text-xs",children:new Date(v.timestamp).toLocaleTimeString()}),p.jsx("span",{className:`flex items-center justify-center px-1 py-0.5 rounded ${v.direction==="RECEIVE"?"bg-blue-500/10 text-blue-600 dark:text-blue-400":"bg-green-500/10 text-green-600 dark:text-green-400"}`,title:v.direction==="RECEIVE"?"Incoming":"Outgoing",children:v.direction==="RECEIVE"?p.jsx(bfe,{className:"h-3 w-3"}):p.jsx(yfe,{className:"h-3 w-3"})}),p.jsx("span",{className:"text-xs font-mono text-foreground truncate",children:v.method})]})]}),w&&p.jsx("div",{className:"border-t bg-muted/20",children:p.jsx("div",{className:"p-3",children:p.jsx("div",{className:"max-h-[40vh] overflow-auto rounded-sm bg-background/60 p-2",children:p.jsx(ir,{data:v.payload})})})})]},v.id)})})})}const z4="mcp-inspector-saved-prompts";function KK({ref:e,prompts:t,callPrompt:n,serverId:a,isConnected:r}){const[i,s]=x.useState(null),[c,u]=x.useState(null),{selectedPromptName:d,setSelectedPromptName:m}=ld(),[h,g]=x.useState({}),[v,w]=x.useState([]),[S,y]=x.useState(!1),[_,E]=x.useState(null),[k,C]=x.useState(""),[R,A]=x.useState("prompts"),[I,O]=x.useState([]),[j,F]=x.useState(!1),[H,K]=x.useState(""),[Q,W]=x.useState(!1),[ie,V]=x.useState(-1),Y=x.useRef(null),[z,te]=x.useState(!1),[re,$]=x.useState("list"),[B,U]=x.useState(0),[L,P]=x.useState(!0),G=x.useRef(null),Z=x.useRef(null);x.useEffect(()=>{const _e=()=>{te(window.innerWidth<1024)};return _e(),window.addEventListener("resize",_e),()=>window.removeEventListener("resize",_e)},[]),x.useEffect(()=>{$(i?"detail":"list")},[i]),x.useEffect(()=>{z&&v.length>0&&!S&&$("response")},[v,S,z]),x.useImperativeHandle(e,()=>({focusSearch:()=>{W(!0),setTimeout(()=>{Y.current&&Y.current.focus()},0)},blurSearch:()=>{C(""),W(!1),Y.current&&Y.current.blur()}})),x.useEffect(()=>{try{const _e=localStorage.getItem(z4);if(_e){const Se=JSON.parse(_e);O(Se)}}catch(_e){console.error("[PromptsTab] Failed to load saved prompts:",_e)}},[]);const J=x.useCallback(_e=>{try{localStorage.setItem(z4,JSON.stringify(_e))}catch(Se){console.error("[PromptsTab] Failed to save prompts:",Se)}},[]);x.useEffect(()=>{Q&&Y.current&&Y.current.focus()},[Q]);const se=x.useCallback(()=>{k.trim()||W(!1)},[k]),le=x.useMemo(()=>{if(!k.trim())return t;const _e=k.toLowerCase();return t.filter(Se=>Se.name.toLowerCase().includes(_e)||Se.description?.toLowerCase().includes(_e))},[t,k]),ee=x.useCallback(_e=>{s(_e);const Se={};_e.arguments&&_e.arguments.forEach(ze=>{ze.default!==void 0?Se[ze.name]=ze.default:ze.type==="string"?Se[ze.name]="":ze.type==="number"?Se[ze.name]=0:ze.type==="boolean"?Se[ze.name]=!1:ze.type==="array"?Se[ze.name]=[]:ze.type==="object"&&(Se[ze.name]={})}),g(Se)},[]),ne=x.useCallback(_e=>{const Se=t.find(ze=>ze.name===_e.promptName);Se&&(s(Se),g(_e.args),u(_e))},[t]);x.useEffect(()=>{V(-1)},[k,R]),x.useEffect(()=>{const _e=Se=>{const ze=Se.target;if(ze.tagName==="INPUT"||ze.tagName==="TEXTAREA"||ze.contentEditable==="true"||Se.metaKey||Se.ctrlKey||Se.altKey)return;const Le=R==="prompts"?le:I;if(Se.key==="ArrowDown")Se.preventDefault(),V(Fe=>{const xe=Fe+1;return xe>=Le.length?0:xe});else if(Se.key==="ArrowUp")Se.preventDefault(),V(Fe=>{const xe=Fe-1;return xe<0?Le.length-1:xe});else if(Se.key==="Enter"&&ie>=0)if(Se.preventDefault(),R==="prompts"){const Fe=le[ie];Fe&&ee(Fe)}else{const Fe=I[ie];Fe&&ne(Fe)}};return document.addEventListener("keydown",_e),()=>document.removeEventListener("keydown",_e)},[ie,le,I,R,ee,ne]),x.useEffect(()=>{if(ie>=0){const _e=R==="prompts"?`prompt-${le[ie]?.name}`:`saved-prompt-${I[ie]?.id}`,Se=document.getElementById(_e);Se&&Se.scrollIntoView({behavior:"smooth",block:"nearest"})}},[ie,le,I,R]),x.useEffect(()=>{if(console.warn("[PromptsTab] Auto-selection effect triggered:",{selectedPromptName:d,promptsCount:t.length,currentSelectedPrompt:i?.name}),d&&t.length>0){const _e=t.find(Se=>Se.name===d);if(console.warn("[PromptsTab] Prompt lookup result:",{selectedPromptName:d,promptFound:!!_e,promptName:_e?.name,shouldSelect:_e&&i?.name!==_e.name}),_e&&i?.name!==_e.name){console.warn("[PromptsTab] Selecting prompt:",_e.name),m(null);const Se=setTimeout(()=>{ee(_e);const ze=document.getElementById(`prompt-${_e.name}`);ze&&(console.warn("[PromptsTab] Scrolling to prompt element"),ze.scrollIntoView({behavior:"smooth",block:"nearest"}))},100);return()=>clearTimeout(Se)}}},[d,t,i,ee,m]);const ce=x.useCallback((_e,Se)=>{g(ze=>({...ze,[_e]:Se}))},[]),ae=x.useCallback(async()=>{if(!i||S)return;y(!0);const _e=Date.now();try{const Se=await n(i.name,h),ze=Date.now()-_e;br.getInstance().capture(new tU({promptName:i.name,serverId:a,success:!0})).catch(()=>{}),w(Le=>[{promptName:i.name,args:h,result:Se,timestamp:_e,duration:ze},...Le])}catch(Se){br.getInstance().capture(new tU({promptName:i.name,serverId:a,success:!1,error:Se instanceof Error?Se.message:"Unknown error"})).catch(()=>{});const pe={promptName:i.name,args:h,result:null,error:Se instanceof Error?Se.message:String(Se),timestamp:_e,duration:Date.now()-_e};w(Le=>[pe,...Le])}finally{y(!1)}},[i,h,S,n,a]),ye=x.useCallback(async(_e,Se)=>{try{await navigator.clipboard.writeText(JSON.stringify(Se,null,2)),E(_e),setTimeout(()=>E(null),2e3)}catch(ze){console.error("[PromptsTab] Failed to copy result:",ze)}},[]),ke=x.useCallback(()=>{i&&(K(""),F(!0))},[i]),Be=x.useCallback(_e=>{J(I.filter(Se=>Se.id!==_e)),c?.id===_e&&u(null)},[I,J,c]);return z?p.jsxs("div",{className:"h-full flex flex-col overflow-hidden relative bg-background",children:[re!=="list"&&p.jsxs("div",{className:"flex items-center gap-2 p-2 border-b shrink-0 bg-background z-10",children:[p.jsx(Ue,{variant:"ghost",size:"sm",onClick:()=>{re==="response"?$("detail"):(s(null),$("list"))},className:"p-0 h-8 w-8",children:p.jsx(QT,{className:"h-4 w-4"})}),p.jsxs("div",{className:"flex items-center text-sm font-medium",children:[p.jsx("button",{onClick:()=>{s(null),$("list")},className:"text-muted-foreground hover:text-foreground hover:underline cursor-pointer",children:"Prompts"}),re!=="list"&&p.jsxs(p.Fragment,{children:[p.jsx("span",{className:"mx-2 text-muted-foreground",children:"/"}),p.jsx("button",{onClick:()=>{re==="response"&&$("detail")},className:re==="detail"?"text-foreground hover:underline":re==="response"?"text-muted-foreground hover:text-foreground hover:underline cursor-pointer":"text-muted-foreground",children:"Execute"})]}),re==="response"&&p.jsxs(p.Fragment,{children:[p.jsx("span",{className:"mx-2 text-muted-foreground",children:"/"}),p.jsx("span",{className:"text-foreground",children:"Response"})]})]})]}),p.jsx("div",{className:"flex-1 relative overflow-hidden",children:p.jsxs(ly,{initial:!1,mode:"popLayout",children:[re==="list"&&p.jsxs(ma.div,{initial:{x:"-100%"},animate:{x:0},exit:{x:"-100%"},transition:{type:"spring",stiffness:300,damping:30},className:"absolute inset-0 flex flex-col bg-background z-0",children:[p.jsx(j4,{activeTab:R,isSearchExpanded:Q,searchQuery:k,filteredPromptsCount:le.length,savedPromptsCount:I.length,onSearchExpand:()=>W(!0),onSearchChange:C,onSearchBlur:se,onTabSwitch:()=>A(R==="prompts"?"saved":"prompts"),searchInputRef:Y}),R==="prompts"?p.jsx($4,{prompts:le,selectedPrompt:i,onPromptSelect:ee,focusedIndex:ie}):p.jsx(M4,{savedPrompts:I,selectedPrompt:c,onLoadPrompt:ne,onDeletePrompt:Be,focusedIndex:ie})]},"list"),re==="detail"&&p.jsx(ma.div,{initial:{x:"100%"},animate:{x:0},exit:{x:"-100%"},transition:{type:"spring",stiffness:300,damping:30},className:"absolute inset-0 bg-background z-10",children:p.jsx(P4,{selectedPrompt:i,promptArgs:h,isExecuting:S,isConnected:r,onArgChange:ce,onExecute:ae,onSave:ke})},"detail"),re==="response"&&p.jsx(ma.div,{initial:{x:"100%"},animate:{x:0},exit:{x:"100%"},transition:{type:"spring",stiffness:300,damping:30},className:"absolute inset-0 bg-background z-20",children:p.jsx(U4,{results:v,copiedResult:_,onCopy:ye})},"response")]})})]}):p.jsxs(Da,{direction:"horizontal",className:"h-full",children:[p.jsx(zn,{defaultSize:33,className:"flex flex-col h-full relative",children:p.jsxs(Da,{direction:"vertical",className:"h-full border-r dark:border-zinc-700",children:[p.jsx(zn,{defaultSize:75,minSize:30,children:p.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[p.jsx(j4,{activeTab:R,isSearchExpanded:Q,searchQuery:k,filteredPromptsCount:le.length,savedPromptsCount:I.length,onSearchExpand:()=>W(!0),onSearchChange:C,onSearchBlur:se,onTabSwitch:()=>A(R==="prompts"?"saved":"prompts"),searchInputRef:Y}),R==="prompts"?p.jsx($4,{prompts:le,selectedPrompt:i,onPromptSelect:ee,focusedIndex:ie}):p.jsx(M4,{savedPrompts:I,selectedPrompt:c,onLoadPrompt:ne,onDeletePrompt:Be,focusedIndex:ie})]})}),p.jsx(Ui,{withHandle:!0}),p.jsxs(zn,{ref:G,defaultSize:0,collapsible:!0,minSize:5,collapsedSize:5,onCollapse:()=>P(!0),onExpand:()=>P(!1),className:"flex flex-col border-t dark:border-zinc-700",children:[p.jsxs("div",{className:"group flex items-center justify-between p-3 shrink-0 cursor-pointer hover:bg-muted/50 transition-colors",onClick:_e=>{_e.preventDefault(),_e.stopPropagation(),L?(G.current?.resize(25),P(!1)):(G.current?.resize(5),P(!0))},children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx("h3",{className:"text-sm font-medium",children:"RPC Messages"}),B>0&&p.jsx(Jr,{variant:"secondary",className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",children:B}),B>0&&!L&&p.jsx(Ue,{variant:"ghost",size:"sm",onClick:_e=>{_e.preventDefault(),_e.stopPropagation(),Z.current?.()},className:"h-6 w-6 p-0",title:"Clear all messages",children:p.jsx(Is,{className:"h-3.5 w-3.5"})})]}),p.jsx(Vl,{className:`h-4 w-4 text-muted-foreground transition-transform ${L?"rotate-180":""}`})]}),!L&&p.jsx("div",{className:"flex-1 overflow-hidden min-h-0",children:p.jsx(TO,{serverIds:[a],onCountChange:U,onClearRef:Z})})]})]})}),p.jsx(Ui,{withHandle:!0}),p.jsx(zn,{defaultSize:67,children:p.jsxs(Da,{direction:"vertical",children:[p.jsx(zn,{defaultSize:40,children:p.jsx(P4,{selectedPrompt:i,promptArgs:h,isExecuting:S,isConnected:r,onArgChange:ce,onExecute:ae,onSave:ke})}),p.jsx(Ui,{withHandle:!0}),p.jsx(zn,{defaultSize:50,children:p.jsx("div",{className:"flex flex-col h-full",children:p.jsx(U4,{results:v,copiedResult:_,onCopy:ye})})})]})})]})}KK.displayName="PromptsTab";function hu(e){if(!e?.mimeType)return!1;const t=e.mimeType.toLowerCase();return t==="text/html"||t==="text/html+skybridge"||t==="text/uri-list"||t.startsWith("application/vnd.mcp-ui.remote-dom")}function T_e(e){return{uri:e.uri,mimeType:e.mimeType,text:e.text,blob:e.blob}}function ZK({resource:e,onUIAction:t,className:n}){const a=async i=>t?.(i),r=T_e(e);return p.jsx("div",{className:n,children:p.jsx(xO,{resource:r,onUIAction:a,htmlProps:{autoResizeIframe:{width:!0,height:!0},style:{width:"100%",minHeight:"200px"},sandboxPermissions:"allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox"},remoteDomProps:{remoteElements:[PEe,MEe,UEe,zEe],library:SO}})})}function F4({result:e,isLoading:t,previewMode:n,serverId:a,readResource:r,onTogglePreview:i,onCopy:s,onDownload:c,onFullscreen:u,isCopied:d=!1}){let m=[],h;if(e?.resourceAnnotations&&(m=Object.keys(e.resourceAnnotations).filter(S=>S.startsWith("openai/")),h=e.resourceAnnotations["openai/outputTemplate"]),e?.result?.contents?.[0]?._meta){const S=e.result.contents[0]._meta,y=Object.keys(S).filter(_=>_.startsWith("openai/"));y.length>0&&(m=[...m,...y]),!h&&S["openai/outputTemplate"]&&(h=S["openai/outputTemplate"]),!h&&e.uri&&e.uri.startsWith("ui://widget/")&&(h=e.uri)}const g=!!(m.length>0&&h&&typeof h=="string"&&a&&r);if(t)return p.jsx("div",{className:"flex absolute left-0 top-0 items-center justify-center w-full h-full",children:p.jsx(Lo,{className:"size-5"})});if(!e)return p.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[p.jsx("p",{className:"text-gray-500 dark:text-gray-400 mb-2",children:"Select a resource to view its contents"}),p.jsx("p",{className:"text-xs text-gray-400 dark:text-gray-500",children:"Choose a resource from the list to see its data"})]});if(e.error)return p.jsx("div",{className:"p-4",children:p.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded p-3",children:[p.jsx("p",{className:"text-red-800 dark:text-red-300 font-medium",children:"Error:"}),p.jsx("p",{className:"text-red-700 dark:text-red-400 text-sm",children:e.error})]})});const v=e?.result?.contents&&Array.isArray(e.result.contents)&&e.result.contents.some(S=>S.mimeType&&hu(S)),w=v?e.result.contents.filter(S=>S.mimeType&&hu(S)):[];return p.jsxs("div",{className:"flex flex-col h-full",children:[p.jsxs("div",{className:"flex-shrink-0 px-4 py-3 border-b border-gray-200 dark:border-zinc-700 flex items-center justify-between",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsxs("div",{className:"flex items-center gap-1",children:[p.jsx(ju,{className:"h-3 w-3 text-gray-400"}),p.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:new Date(e.timestamp).toLocaleTimeString()})]}),(()=>{const S=e?.duration??e.result?.duration??e.result?.metrics?.durationMs;return S!==void 0?p.jsxs("div",{className:"flex items-center gap-1",children:[p.jsx(op,{className:"h-3 w-3 text-gray-400"}),p.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:[S,"ms"]})]}):null})(),v&&p.jsx(Jr,{variant:"outline",className:"text-xs bg-purple-50 dark:bg-purple-900/20 border-none border-purple-200 dark:border-purple-800/50 text-purple-600 dark:text-purple-400",children:"MCP UI"}),g&&p.jsx(Jr,{variant:"outline",className:"text-xs bg-blue-50 dark:bg-blue-900/20 border-none border-blue-200 dark:border-blue-800/50 text-blue-600 dark:text-blue-400",children:"OpenAI Widget"})]}),p.jsxs("div",{className:"flex items-center gap-1",children:[(v||g)&&p.jsxs(Ue,{variant:"ghost",size:"sm",onClick:i,className:n?"":"text-purple-600 dark:text-purple-400",children:[n?p.jsx(P9,{className:"h-4 w-4 mr-1"}):p.jsx(M9,{className:"h-4 w-4 mr-1"}),n?"JSON":g?"Component":"Preview"]}),p.jsx(Ue,{variant:"ghost",size:"sm",onClick:s,children:d?p.jsx(La,{className:"h-4 w-4"}):p.jsx(Xr,{className:"h-4 w-4"})}),p.jsx(Ue,{variant:"ghost",size:"sm",onClick:c,children:p.jsx(ny,{className:"h-4 w-4"})}),p.jsx(Ue,{variant:"ghost",size:"sm",onClick:u,children:p.jsx(tN,{className:"h-4 w-4"})})]})]}),p.jsx("div",{className:"flex-1 overflow-y-auto",children:g&&a&&r&&h?n?p.jsx("div",{className:"flex-1 h-full",children:p.jsx(gO,{componentUrl:h,toolName:e.uri,toolArgs:{},toolResult:e.result,serverId:a,readResource:r,className:"w-full h-full relative flex p-4"})}):p.jsx("div",{className:"px-4 pt-4",children:p.jsx(ir,{data:e.result,filename:`resource-${e.uri.replace(/[^a-zA-Z0-9]/g,"-")}-${Date.now()}.json`})}):v?n?p.jsxs("div",{className:"space-y-0 h-full",children:[w.map((S,y)=>p.jsx("div",{className:"mx-0 size-full",children:p.jsx("div",{className:"w-full h-full",children:p.jsx(ZK,{resource:S,className:"w-full h-full"})})},`mcp-ui-${S.uri||`resource-${Date.now()}-${Math.random()}`}`)),(()=>{if(e.result.contents&&Array.isArray(e.result.contents)){const S=e.result.contents.filter(y=>!(y.mimeType&&hu(y)));if(S.length>0)return p.jsx("div",{className:"px-4",children:p.jsx(ir,{data:S,filename:`resource-${e.uri.replace(/[^a-zA-Z0-9]/g,"-")}-non-ui-${Date.now()}.json`})})}return null})()]}):p.jsx("div",{className:"px-4 pt-4",children:p.jsx(ir,{data:e.result,filename:`resource-${e.uri.replace(/[^a-zA-Z0-9]/g,"-")}-mcp-ui-${Date.now()}.json`})}):p.jsx("div",{className:"px-4 pt-4",children:p.jsx(ir,{data:e.result,filename:`resource-${e.uri.replace(/[^a-zA-Z0-9]/g,"-")}-${Date.now()}.json`})})})]})}function N_e(e,t){if(!e&&!t)return p.jsx(npe,{className:"h-5 w-5"});const n=(e||t||"").toLowerCase();return n.includes("image")?p.jsx(Qfe,{className:"h-5 w-5"}):n.includes("json")||n.includes("javascript")||n.includes("typescript")?p.jsx(qfe,{className:"h-5 w-5"}):n.includes("html")||n.includes("xml")?p.jsx(ope,{className:"h-5 w-5"}):n.includes("database")||n.includes("sql")?p.jsx(ty,{className:"h-5 w-5"}):p.jsx(eN,{className:"h-5 w-5"})}function B4({resources:e,selectedResource:t,onResourceSelect:n,focusedIndex:a}){return e.length===0?p.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[p.jsx(ty,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),p.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"No resources available"})]}):p.jsx("div",{className:"overflow-y-auto flex-1 overscroll-contain",children:e.map((r,i)=>{const s=N_e(r.mimeType,r.uri),c=[r.description,r.mimeType&&p.jsx("span",{className:"font-mono",children:r.mimeType},"mime")].filter(Boolean);return p.jsx(Xl,{id:`resource-${r.uri}`,isSelected:t?.uri===r.uri,isFocused:a===i,icon:s,title:r.name,description:c.length>0?p.jsxs("span",{className:"flex flex-col gap-1",children:[r.description&&p.jsx("span",{children:r.description}),r.mimeType&&p.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-500 font-mono",children:r.mimeType})]}):void 0,onClick:()=>n(r)},r.uri)})})}function H4({isSearchExpanded:e,searchQuery:t,filteredResourcesCount:n,onSearchExpand:a,onSearchChange:r,onSearchBlur:i,searchInputRef:s}){return p.jsx("div",{className:"flex flex-row items-center justify-between p-4 sm:p-4 py-3 gap-2",children:p.jsx("div",{className:"flex items-center gap-2 flex-1",children:e?p.jsx(jn,{ref:s,placeholder:"Search resources...",value:t,onChange:c=>r(c.target.value),onBlur:i,className:"h-8 border-gray-300 dark:border-zinc-600"}):p.jsxs(p.Fragment,{children:[p.jsx("h2",{className:"text-lg font-medium text-gray-900 dark:text-gray-100",children:"Resources"}),p.jsx(Jr,{className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",variant:"outline",children:n}),p.jsxs(en,{children:[p.jsx(tn,{asChild:!0,children:p.jsx(Ue,{variant:"ghost",size:"sm",onClick:a,className:"h-8 w-8 p-0",children:p.jsx(qp,{className:"h-4 w-4"})})}),p.jsxs(nn,{side:"bottom",className:"flex gap-2",children:["Search",p.jsx($y,{children:"F"})]})]})]})})})}function YK({ref:e,resources:t,readResource:n,serverId:a,isConnected:r}){const[i,s]=x.useState(null),{selectedResourceUri:c,setSelectedResourceUri:u}=ld(),[d,m]=x.useState(null),[h,g]=x.useState(!1),[v,w]=x.useState(""),[S]=x.useState("resources"),[y,_]=x.useState(!0),[E,k]=x.useState(!1),[C,R]=x.useState(-1),[A,I]=x.useState(!1),O=x.useRef(null),j=x.useRef(null),[F,H]=x.useState(!1),[K,Q]=x.useState("list"),[W,ie]=x.useState(0),[V,Y]=x.useState(!0),z=x.useRef(null),te=x.useRef(null);x.useEffect(()=>{const G=()=>{H(window.innerWidth<1024)};return G(),window.addEventListener("resize",G),()=>window.removeEventListener("resize",G)},[]),x.useEffect(()=>{Q(i?"detail":"list")},[i]),x.useImperativeHandle(e,()=>({focusSearch:()=>{k(!0),setTimeout(()=>{O.current&&O.current.focus()},0)},blurSearch:()=>{w(""),k(!1),O.current&&O.current.blur()}})),x.useEffect(()=>{E&&O.current&&O.current.focus()},[E]);const re=x.useCallback(()=>{v.trim()||k(!1)},[v]),$=x.useMemo(()=>{if(!v)return t;const G=v.toLowerCase();return t.filter(Z=>Z.name.toLowerCase().includes(G)||Z.description?.toLowerCase().includes(G)||Z.uri.toLowerCase().includes(G))},[t,v]),B=x.useCallback(async G=>{if(s(G),r){g(!0);const Z=Date.now();try{const J=await n(G.uri);br.getInstance().capture(new eU({resourceUri:G.uri,serverId:a,success:!0})).catch(()=>{}),m({uri:G.uri,result:J,timestamp:Z,resourceAnnotations:G.annotations})}catch(J){br.getInstance().capture(new eU({resourceUri:G.uri,serverId:a,success:!1,error:J instanceof Error?J.message:"Unknown error"})).catch(()=>{}),m({uri:G.uri,result:null,error:J instanceof Error?J.message:"Unknown error",timestamp:Z,resourceAnnotations:G.annotations})}finally{g(!1)}}},[n,a,r]);x.useEffect(()=>{R(-1)},[v,S]),x.useEffect(()=>{const G=Z=>{const J=Z.target;if(J.tagName==="INPUT"||J.tagName==="TEXTAREA"||J.contentEditable==="true"||Z.metaKey||Z.ctrlKey||Z.altKey)return;const le=$;if(Z.key==="ArrowDown")Z.preventDefault(),R(ee=>{const ne=ee+1;return ne>=le.length?0:ne});else if(Z.key==="ArrowUp")Z.preventDefault(),R(ee=>{const ne=ee-1;return ne<0?le.length-1:ne});else if(Z.key==="Enter"&&C>=0){Z.preventDefault();const ee=$[C];ee&&B(ee)}};return document.addEventListener("keydown",G),()=>document.removeEventListener("keydown",G)},[C,$,B]),x.useEffect(()=>{if(C>=0){const G=`resource-${$[C]?.uri}`,Z=document.getElementById(G);Z&&Z.scrollIntoView({behavior:"smooth",block:"nearest"})}},[C,$]),x.useEffect(()=>{if(c&&t.length>0){const G=t.find(Z=>Z.uri===c);G&&i?.uri!==G.uri&&(u(null),setTimeout(()=>{B(G);const Z=document.getElementById(`resource-${G.uri}`);Z&&Z.scrollIntoView({behavior:"smooth",block:"nearest"})},100))}},[c,t,i,B,u]);const U=x.useCallback(async()=>{if(d)try{await navigator.clipboard.writeText(JSON.stringify(d.result,null,2)),I(!0),setTimeout(()=>I(!1),2e3)}catch(G){console.error("[ResourcesTab] Failed to copy result:",G)}},[d]),L=x.useCallback(()=>{if(d)try{const G=new globalThis.Blob([JSON.stringify(d.result,null,2)],{type:"application/json"}),Z=URL.createObjectURL(G),J=document.createElement("a");J.href=Z,J.download=`resource-${Date.now()}.json`,document.body.appendChild(J),J.click(),document.body.removeChild(J),URL.revokeObjectURL(Z)}catch(G){console.error("[ResourcesTab] Failed to download result:",G)}},[d]),P=x.useCallback(async()=>{if(j.current)try{document.fullscreenElement?await document.exitFullscreen():await j.current.requestFullscreen()}catch(G){console.error("[ResourcesTab] Failed to toggle fullscreen:",G)}},[]);return F?p.jsxs("div",{className:"h-full flex flex-col overflow-hidden relative bg-background",children:[K!=="list"&&p.jsxs("div",{className:"flex items-center gap-2 p-2 border-b shrink-0 bg-background z-10",children:[p.jsx(Ue,{variant:"ghost",size:"sm",onClick:()=>{s(null),Q("list")},className:"p-0 h-8 w-8",children:p.jsx(QT,{className:"h-4 w-4"})}),p.jsxs("div",{className:"flex items-center text-sm font-medium",children:[p.jsx("button",{onClick:()=>{s(null),Q("list")},className:"text-muted-foreground hover:text-foreground hover:underline cursor-pointer",children:"Resources"}),K==="detail"&&p.jsxs(p.Fragment,{children:[p.jsx("span",{className:"mx-2 text-muted-foreground",children:"/"}),p.jsx("span",{className:"text-foreground",children:"Content"})]})]})]}),p.jsx("div",{className:"flex-1 relative overflow-hidden",children:p.jsxs(ly,{initial:!1,mode:"popLayout",children:[K==="list"&&p.jsxs(ma.div,{initial:{x:"-100%"},animate:{x:0},exit:{x:"-100%"},transition:{type:"spring",stiffness:300,damping:30},className:"absolute inset-0 flex flex-col bg-background z-0",children:[p.jsx(H4,{activeTab:S,isSearchExpanded:E,searchQuery:v,filteredResourcesCount:$.length,onSearchExpand:()=>k(!0),onSearchChange:w,onSearchBlur:re,onTabSwitch:()=>{},searchInputRef:O}),p.jsx("div",{className:"flex flex-col h-full",children:p.jsx(B4,{resources:$,selectedResource:i,onResourceSelect:B,focusedIndex:C})})]},"list"),K==="detail"&&p.jsx(ma.div,{initial:{x:"100%"},animate:{x:0},exit:{x:"100%"},transition:{type:"spring",stiffness:300,damping:30},className:"absolute inset-0 bg-white dark:bg-zinc-900 z-10",children:p.jsx("div",{ref:j,className:"h-full",children:p.jsx(F4,{result:d,isLoading:h,previewMode:y,serverId:a,readResource:n,onTogglePreview:()=>_(!y),onCopy:U,onDownload:L,onFullscreen:P,isCopied:A})})},"detail")]})})]}):p.jsxs(Da,{direction:"horizontal",className:"h-full",children:[p.jsx(zn,{defaultSize:25,children:p.jsxs(Da,{direction:"vertical",className:"h-full border-r dark:border-zinc-700",children:[p.jsx(zn,{defaultSize:75,minSize:30,children:p.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[p.jsx(H4,{activeTab:S,isSearchExpanded:E,searchQuery:v,filteredResourcesCount:$.length,onSearchExpand:()=>k(!0),onSearchChange:w,onSearchBlur:re,onTabSwitch:()=>{},searchInputRef:O}),p.jsx(B4,{resources:$,selectedResource:i,onResourceSelect:B,focusedIndex:C})]})}),p.jsx(Ui,{withHandle:!0}),p.jsxs(zn,{ref:z,defaultSize:0,collapsible:!0,minSize:5,collapsedSize:5,onCollapse:()=>Y(!0),onExpand:()=>Y(!1),className:"flex flex-col border-t dark:border-zinc-700",children:[p.jsxs("div",{className:"group flex items-center justify-between p-3 shrink-0 cursor-pointer hover:bg-muted/50 transition-colors",onClick:G=>{G.preventDefault(),G.stopPropagation(),V?(z.current?.resize(25),Y(!1)):(z.current?.resize(5),Y(!0))},children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx("h3",{className:"text-sm font-medium",children:"RPC Messages"}),W>0&&p.jsx(Jr,{variant:"secondary",className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",children:W}),W>0&&!V&&p.jsx(Ue,{variant:"ghost",size:"sm",onClick:G=>{G.preventDefault(),G.stopPropagation(),te.current?.()},className:"h-6 w-6 p-0",title:"Clear all messages",children:p.jsx(Is,{className:"h-3.5 w-3.5"})})]}),p.jsx(Vl,{className:`h-4 w-4 text-muted-foreground transition-transform ${V?"":"rotate-180"}`})]}),!V&&p.jsx("div",{className:"flex-1 overflow-hidden min-h-0",children:p.jsx(TO,{serverIds:[a],onCountChange:ie,onClearRef:te})})]})]})}),p.jsx(Ui,{}),p.jsx(zn,{defaultSize:50,children:p.jsx(Da,{direction:"vertical",children:p.jsx(zn,{defaultSize:70,children:p.jsx("div",{ref:j,className:"h-full bg-white dark:bg-zinc-900",children:p.jsx(F4,{result:d,isLoading:h,previewMode:y,serverId:a,readResource:n,onTogglePreview:()=>_(!y),onCopy:U,onDownload:L,onFullscreen:P,isCopied:A})})})})})]})}YK.displayName="ResourcesTab";function V4({savedRequests:e,selectedRequest:t,onLoadRequest:n,onDeleteRequest:a,focusedIndex:r}){if(e.length===0)return p.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[p.jsx(ty,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),p.jsx("p",{className:"text-gray-500 dark:text-gray-400 mb-2",children:"No saved requests yet"}),p.jsx("p",{className:"text-xs text-gray-400 dark:text-gray-500",children:"Execute a tool and click Save to store requests"})]});const i=(s,c)=>{s.stopPropagation(),c()};return p.jsx("div",{className:"overflow-y-auto flex-1 border-r dark:border-zinc-700 overscroll-contain",children:e.map((s,c)=>p.jsxs("div",{className:"relative group",children:[p.jsx(Xl,{id:`saved-${s.id}`,isSelected:t?.id===s.id,isFocused:r===c,icon:p.jsx($b,{className:"h-4 w-4"}),title:s.name,description:s.toolName,metadata:p.jsx("div",{className:"flex flex-col gap-1",children:p.jsx("span",{className:"text-xs text-gray-400 dark:text-gray-500",children:new Date(s.savedAt).toLocaleString()})}),onClick:()=>n(s)}),p.jsx("div",{className:"absolute top-1/2 right-2 -translate-y-1/2 opacity-0 group-hover:opacity-100 transition-opacity z-10",children:p.jsxs(en,{children:[p.jsx(tn,{asChild:!0,children:p.jsx(Ue,{variant:"secondary",size:"sm",onClick:u=>i(u,()=>a(s.id)),className:"h-8 w-8 p-0",children:p.jsx(Is,{className:"h-4 w-4"})})}),p.jsx(nn,{children:p.jsx("p",{children:"Delete saved request"})})]})})]},s.id))})}function G4({isOpen:e,requestName:t,defaultPlaceholder:n,onRequestNameChange:a,onSave:r,onCancel:i}){return e?p.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:i,children:p.jsxs("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:s=>s.stopPropagation(),children:[p.jsx("h3",{className:"text-lg font-semibold mb-4 text-gray-900 dark:text-gray-100",children:"Save Request"}),p.jsxs("div",{className:"space-y-4",children:[p.jsxs("div",{children:[p.jsx(Yt,{htmlFor:"request-name",children:"Request Name (optional)"}),p.jsx(jn,{id:"request-name",value:t,onChange:s=>a(s.target.value),placeholder:n,className:"mt-2",onKeyDown:s=>{s.key==="Enter"&&r()},autoFocus:!0})]}),p.jsxs("div",{className:"flex justify-end gap-2",children:[p.jsx(Ue,{variant:"outline",onClick:i,children:"Cancel"}),p.jsxs(Ue,{onClick:r,children:[p.jsx(nN,{className:"h-4 w-4 mr-2"}),"Save"]})]})]})]})}):null}function XK(e,t){if(!e?.$ref)return e;const n=e.$ref;if(n.startsWith("#/")){const a=n.substring(2).split("/");let r=t;for(const i of a)if(r&&typeof r=="object"&&i in r)r=r[i];else return console.warn(`Could not resolve $ref: ${n}`),e;return r}return e}function R_e(e,t){if(e.anyOf&&Array.isArray(e.anyOf)){const n=e.anyOf.find(a=>a.type!=="null");if(n)return{...XK(n,t),nullable:!0}}return e}function C_e(e){return Array.isArray(e.enum)?e.enum:null}function A_e({selectedTool:e,toolArgs:t,onArgChange:n}){const a=e?.inputSchema?.properties||{},r=e?.inputSchema?.required||[];return Object.keys(a).length>0?p.jsx("div",{className:"space-y-4",children:Object.entries(a).map(([s,c])=>{const u=e?.inputSchema||{};let d=R_e(c,u);d=XK(d,u);const m=C_e(d),h=d.type==="string"&&m!==null,g=d;g.required=r.includes(s);const v=t[s];let w="";return v!=null&&(typeof v=="string"?w=v:typeof v=="object"&&v!==null?w=JSON.stringify(v,null,2):w=String(v)),g.type==="object"||g.type==="array"?p.jsxs("div",{className:"space-y-2",children:[p.jsxs(Yt,{htmlFor:s,className:"text-sm font-medium",children:[s,g?.required&&p.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),p.jsx(zu,{id:s,value:w,onChange:y=>n(s,y.target.value),placeholder:g?.description||`Enter ${s}`,className:"min-h-[100px]"}),g?.description&&p.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:g.description})]},s):h&&m?p.jsxs("div",{className:"space-y-2",children:[p.jsxs(Yt,{htmlFor:s,className:"text-sm font-medium",children:[s,g.required&&p.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),p.jsxs(Eo,{value:String(t[s]||""),onValueChange:y=>n(s,y),children:[p.jsx(ko,{id:s,className:"w-full",children:p.jsx(_o,{placeholder:g.description||"Select an option"})}),p.jsx(To,{children:m.map((y,_)=>p.jsx(Rr,{value:y,children:g.enumNames?.[_]||y},y))})]}),g.description&&p.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:g.description})]},s):p.jsxs("div",{className:"space-y-2",children:[p.jsxs(Yt,{htmlFor:s,className:"text-sm font-medium",children:[s,g?.required&&p.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),p.jsx(jn,{id:s,value:w,onChange:y=>n(s,y.target.value),placeholder:g?.description||`Enter ${s}`}),g?.description&&p.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:g.description})]},s)})}):p.jsx("div",{className:"flex items-center justify-center h-32 text-gray-500 dark:text-gray-400 text-sm",children:"No parameters required"})}function W4({selectedTool:e,toolArgs:t,isExecuting:n,isConnected:a,onArgChange:r,onExecute:i,onSave:s}){return x.useEffect(()=>{const c=u=>{(u.metaKey||u.ctrlKey)&&u.key==="Enter"&&e&&!n&&a&&(u.preventDefault(),i())};return document.addEventListener("keydown",c),()=>document.removeEventListener("keydown",c)},[e,n,a,i]),e?p.jsxs("div",{className:"flex flex-col h-full",children:[p.jsx("div",{className:"flex-shrink-0 p-3 sm:p-5 pt-3 sm:pt-4 pb-4 sm:pr-4",children:p.jsxs("div",{children:[p.jsxs("div",{className:"flex flex-row items-center justify-between mb-0 gap-2",children:[p.jsx("h3",{className:"text-base sm:text-lg font-semibold",children:e.name}),p.jsxs("div",{className:"flex gap-2 flex-shrink-0",children:[p.jsxs(Ue,{variant:"outline",onClick:s,disabled:n,size:"sm",className:"lg:size-default gap-2",children:[p.jsx(nN,{className:"h-4 w-4"}),p.jsx("span",{className:"hidden sm:inline",children:"Save"})]}),p.jsx(Ue,{onClick:i,disabled:n||!a,size:"sm",className:"lg:size-default pr-1! gap-0",children:n?p.jsxs(p.Fragment,{children:[p.jsx(Lo,{className:"mr-2"}),p.jsx("span",{className:"hidden sm:inline",children:"Executing..."})]}):p.jsxs(p.Fragment,{children:[p.jsx(H9,{className:"h-4 w-4 sm:mr-2"}),p.jsx("span",{className:"hidden sm:inline",children:"Execute"}),p.jsx("span",{className:"hidden sm:inline text-[12px] border text-zinc-300 p-1 rounded-full border-zinc-300 dark:text-zinc-600 dark:border-zinc-500 ml-2",children:"⌘↵"})]})})]})]}),e.description&&p.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 leading-relaxed mt-2",children:e.description})]})}),p.jsx("div",{className:"flex-1 overflow-y-auto px-3 sm:px-6 pb-4 pr-3",children:p.jsx(A_e,{selectedTool:e,toolArgs:t,onArgChange:r})})]}):p.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[p.jsx("p",{className:"text-gray-500 dark:text-gray-400 mb-2",children:"Select a tool to get started"}),p.jsx("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"})]})}function K4(e){const n=Date.now()-e,a=Math.floor(n/1e3),r=Math.floor(a/60),i=Math.floor(r/60),s=Math.floor(i/24);return a<10?"now":a<60?`${a}s ago`:r<60?`${r}m ago`:i<24?`${i}h ago`:`${s}d ago`}function I_e(e){try{return JSON.parse(e),!0}catch{return!1}}function O_e({content:e}){return!Array.isArray(e)||e.length===0?p.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:"No content"}):p.jsx("div",{className:"space-y-4",children:e.map((t,n)=>{if(t.type==="text"){const a=t.text||"";if(I_e(a))try{const r=JSON.parse(a);return p.jsxs("div",{className:"space-y-2",children:[p.jsx("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"Text Content (JSON)"}),p.jsx(ir,{data:r,filename:`content-${n}.json`})]},n)}catch{}return p.jsxs("div",{className:"space-y-2",children:[p.jsx("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"Text Content"}),p.jsx("div",{className:"bg-gray-50 dark:bg-zinc-900 rounded-lg p-3 font-mono text-sm whitespace-pre-wrap break-words",children:a})]},n)}if(t.type==="image")return p.jsxs("div",{className:"space-y-2",children:[p.jsx("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"Image Content"}),p.jsxs("div",{className:"bg-gray-50 dark:bg-zinc-900 rounded-lg p-3",children:[p.jsx("img",{src:`data:${t.mimeType||"image/png"};base64,${t.data}`,alt:"Result",className:"max-w-full rounded"}),t.annotations&&p.jsx("div",{className:"mt-2 text-xs text-gray-500 dark:text-gray-400",children:p.jsx(ir,{data:t.annotations,filename:`image-annotations-${n}.json`})})]})]},n);if(t.type==="audio")return p.jsxs("div",{className:"space-y-2",children:[p.jsx("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"Audio Content"}),p.jsxs("div",{className:"bg-gray-50 dark:bg-zinc-900 rounded-lg p-3",children:[p.jsx("audio",{controls:!0,src:`data:${t.mimeType||"audio/wav"};base64,${t.data}`,className:"w-full"}),t.annotations&&p.jsx("div",{className:"mt-2 text-xs text-gray-500 dark:text-gray-400",children:p.jsx(ir,{data:t.annotations,filename:`audio-annotations-${n}.json`})})]})]},n);if(t.type==="resource_link")return p.jsxs("div",{className:"space-y-2",children:[p.jsx("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"Resource Link"}),p.jsxs("div",{className:"bg-gray-50 dark:bg-zinc-900 rounded-lg p-3 space-y-2",children:[p.jsxs("div",{className:"font-mono text-sm break-all",children:[p.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"URI:"})," ",t.uri]}),t.name&&p.jsxs("div",{className:"text-sm",children:[p.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"Name:"})," ",t.name]}),t.description&&p.jsxs("div",{className:"text-sm",children:[p.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"Description:"})," ",t.description]}),t.mimeType&&p.jsxs("div",{className:"text-sm",children:[p.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"MIME Type:"})," ",t.mimeType]}),t.annotations&&p.jsxs("div",{className:"mt-2",children:[p.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"Annotations:"}),p.jsx(ir,{data:t.annotations,filename:`resource-link-annotations-${n}.json`})]})]})]},n);if(t.type==="resource"){const a=t.resource||{};return p.jsxs("div",{className:"space-y-2",children:[p.jsx("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"Embedded Resource"}),p.jsxs("div",{className:"bg-gray-50 dark:bg-zinc-900 rounded-lg p-3 space-y-2",children:[p.jsxs("div",{className:"font-mono text-sm break-all",children:[p.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"URI:"})," ",a.uri]}),a.mimeType&&p.jsxs("div",{className:"text-sm",children:[p.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"MIME Type:"})," ",a.mimeType]}),a.text&&p.jsxs("div",{children:[p.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"Content:"}),p.jsx("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&&p.jsxs("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:["[Binary content: ",a.blob.length||0," bytes]"]}),a.annotations&&p.jsxs("div",{className:"mt-2",children:[p.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"Annotations:"}),p.jsx(ir,{data:a.annotations,filename:`resource-annotations-${n}.json`})]})]})]},n)}return p.jsxs("div",{className:"space-y-2",children:[p.jsxs("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:["Unknown Content Type: ",t.type||"N/A"]}),p.jsx(ir,{data:t,filename:`content-${n}.json`})]},n)})})}function Z4({results:e,copiedResult:t,previewMode:n,serverId:a,readResource:r,onCopy:i,onTogglePreview:s,onMaximize:c,isMaximized:u=!1}){const[d,m]=x.useState(0),[h,g]=x.useState(""),[v,w]=x.useState(!0),S=e[0],y=S?e.filter(W=>W.toolName===S.toolName):[],_=y[d]||y[0],E=e.findIndex(W=>W===_);x.useEffect(()=>{y.length>0&&d>=y.length&&m(0)},[y.length,d]),x.useEffect(()=>{const W=()=>{_&&g(K4(_.timestamp))};W();const ie=setInterval(W,1e3);return()=>clearInterval(ie)},[_]);const k=x.useMemo(()=>_?.args,[_?.timestamp,d]),C=x.useMemo(()=>_?.result,[_?.timestamp,d]),R=x.useCallback(W=>r(W),[r]);if(e.length===0)return p.jsx("div",{className:"flex flex-col h-full bg-white dark:bg-black border-t dark:border-zinc-700",children:p.jsx("div",{className:"flex-1 overflow-y-auto h-full",children:p.jsx("div",{className:"flex items-center justify-center h-full",children:p.jsx("div",{className:"text-center",children:p.jsx(Yp,{vertical:!0,noBorder:!0,message:"No Results yet"})})})})});const A=_.toolMeta?.["openai/outputTemplate"],I=!!(A&&typeof A=="string"&&_.appsSdkResource),O=A,j=_.result?.content||[],F=j.filter(W=>W.type==="resource"&&hu(W.resource)),H=F.length>0,K=!!(j&&j.length>0||_.result?.structuredContent),Q=!H&&!I&&K;return p.jsx("div",{className:"flex flex-col h-full bg-white dark:bg-black border-t dark:border-zinc-700",children:p.jsx("div",{className:"flex-1 overflow-y-auto h-full",children:p.jsxs("div",{className:"space-y-0 flex-1 h-full flex flex-col",children:[p.jsxs("div",{className:`flex items-center gap-2 px-4 pt-2 ${H||I||Q?"border-b border-gray-200 dark:border-zinc-600 pb-2":""}`,children:[p.jsx("h3",{className:"text-sm font-medium hidden sm:block",children:"Response"}),_.duration!==void 0&&p.jsxs("div",{className:"hidden sm:flex items-center gap-1",children:[p.jsx(op,{className:"h-3 w-3 text-gray-400"}),p.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:[_.duration,"ms"]})]}),I&&p.jsxs("div",{className:"flex items-center gap-4 sm:ml-4",children:[p.jsxs("span",{className:"hidden sm:inline text-xs text-gray-500 dark:text-gray-400",children:["URI: ",O||"No URI"]}),p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx("button",{onClick:()=>s(),className:`text-xs font-medium ${n?"text-black dark:text-white":"text-zinc-500 dark:text-zinc-400"}`,children:"Component"}),p.jsx("span",{className:"text-xs text-zinc-400",children:"|"}),p.jsx("button",{onClick:()=>s(),className:`text-xs font-medium ${n?"text-zinc-500 dark:text-zinc-400":"text-black dark:text-white"}`,children:"Raw JSON"})]})]}),H&&!I&&p.jsxs("div",{className:"flex items-center gap-4 sm:ml-4",children:[p.jsxs("span",{className:"hidden sm:inline text-xs text-gray-500 dark:text-gray-400",children:["URI: ",F[0]?.resource?.uri||"No URI"]}),p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx("button",{onClick:()=>s(),className:`text-xs font-medium ${n?"text-black dark:text-white":"text-zinc-500 dark:text-zinc-400"}`,children:"Preview"}),p.jsx("span",{className:"text-xs text-zinc-400",children:"|"}),p.jsx("button",{onClick:()=>s(),className:`text-xs font-medium ${n?"text-zinc-500 dark:text-zinc-400":"text-black dark:text-white"}`,children:"JSON"})]})]}),Q&&p.jsxs("div",{className:"flex items-center gap-2 sm:ml-4",children:[p.jsx("button",{onClick:()=>w(!0),className:`text-xs font-medium ${v?"text-black dark:text-white":"text-zinc-500 dark:text-zinc-400"}`,children:"Formatted"}),p.jsx("span",{className:"text-xs text-zinc-400",children:"|"}),p.jsx("button",{onClick:()=>w(!1),className:`text-xs font-medium ${v?"text-zinc-500 dark:text-zinc-400":"text-black dark:text-white"}`,children:"Raw"})]}),p.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[(I||H)&&c&&p.jsx(Ue,{variant:"ghost",size:"sm",onClick:c,title:u?"Restore":"Maximize",children:u?p.jsx(ype,{className:"h-4 w-4"}):p.jsx(tN,{className:"h-4 w-4"})}),y.length>1&&p.jsxs(Eo,{value:d.toString(),onValueChange:W=>m(parseInt(W)),children:[p.jsx(ko,{size:"sm",className:"w-[140px] h-8 text-xs",children:p.jsx(_o,{children:p.jsxs("div",{className:"flex items-center gap-1",children:[p.jsx($b,{className:"h-3 w-3"}),p.jsx("span",{children:h})]})})}),p.jsx(To,{children:y.map((W,ie)=>p.jsx(Rr,{value:ie.toString(),children:p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx($b,{className:"h-3 w-3"}),p.jsx("span",{children:K4(W.timestamp)}),p.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",new Date(W.timestamp).toLocaleTimeString(),")"]})]})},ie))})]}),p.jsx(Ue,{variant:"ghost",size:"sm",onClick:()=>i(E,_.result),children:t===E?p.jsx(La,{className:"h-4 w-4"}):p.jsx(Xr,{className:"h-4 w-4"})})]})]}),_.error?p.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded p-3 mx-4",children:[p.jsx("p",{className:"text-red-800 dark:text-red-300 font-medium",children:"Error:"}),p.jsx("p",{className:"text-red-700 dark:text-red-400 text-sm",children:_.error})]}):(()=>{if(I){const W=_.appsSdkResource;return W.isLoading?p.jsx(p.Fragment,{}):W.error?p.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded p-3 mx-4",children:[p.jsx("p",{className:"text-red-800 dark:text-red-300 font-medium",children:"Resource Error:"}),p.jsx("p",{className:"text-red-700 dark:text-red-400 text-sm",children:W.error})]}):n?p.jsx("div",{className:"flex-1",children:p.jsx(gO,{componentUrl:O,toolName:_.toolName,toolArgs:k,toolResult:C,serverId:a,readResource:R,className:"w-full h-full relative p-4"})}):p.jsx("div",{className:"px-4 pt-4",children:p.jsx(ir,{data:_.result,filename:`tool-result-${_.toolName}-${Date.now()}.json`})})}if(H)return n?p.jsxs("div",{className:"space-y-0 h-full",children:[F.map((W,ie)=>p.jsx("div",{className:"mx-0 size-full",children:p.jsx(ZK,{resource:W.resource,onUIAction:V=>{},className:"w-full h-full relative"})},ie)),j.filter(W=>!(W.type==="resource"&&hu(W.resource))).length>0&&p.jsx("div",{className:"px-4",children:p.jsx(ir,{data:j.filter(W=>!(W.type==="resource"&&hu(W.resource))),filename:`tool-result-${_.toolName}-non-ui-${Date.now()}.json`})})]}):p.jsx("div",{className:"px-4 pt-4",children:p.jsx(ir,{data:_.result,filename:`tool-result-${_.toolName}-mcp-ui-${Date.now()}.json`})});if(Q&&v){const W=_.result?.structuredContent;return p.jsxs("div",{className:"px-4 pt-4 space-y-4",children:[W&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"Structured Content"}),p.jsx(ir,{data:W,filename:`structured-content-${_.toolName}-${Date.now()}.json`})]}),j&&j.length>0&&p.jsx(O_e,{content:j}),!W&&(!j||j.length===0)&&p.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:"No content to display"})]})}return p.jsx("div",{className:"px-4 pt-4",children:p.jsx(ir,{data:_.result,filename:`tool-result-${_.toolName}-${Date.now()}.json`})})})()]})})})}function Y4({tools:e,selectedTool:t,onToolSelect:n,focusedIndex:a}){return e.length===0?p.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[p.jsx(Dl,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),p.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"No tools available"})]}):p.jsx("div",{className:"overflow-y-auto flex-1 overscroll-contain",children:e.map((r,i)=>p.jsx(Xl,{id:`tool-${r.name}`,isSelected:t?.name===r.name,isFocused:a===i,icon:p.jsx(Dl,{className:"h-4 w-4"}),title:r.name,description:r.description,metadata:r.inputSchema?.properties&&p.jsxs(Jr,{variant:"outline",className:"text-xs border-gray-300 dark:border-zinc-600 text-gray-600 dark:text-gray-400",children:[Object.keys(r.inputSchema.properties).length," params"]}),onClick:()=>n(r)},r.name))})}function X4({activeTab:e,isSearchExpanded:t,searchQuery:n,filteredToolsCount:a,savedRequestsCount:r,onSearchExpand:i,onSearchChange:s,onSearchBlur:c,onTabSwitch:u,searchInputRef:d}){return p.jsx(WK,{activeTab:e,isSearchExpanded:t,searchQuery:n,primaryTabName:"tools",secondaryTabName:"saved",primaryTabTitle:"Tools",secondaryTabTitle:"Saved",primaryCount:a,secondaryCount:r,primaryIcon:Dl,secondaryIcon:ty,searchPlaceholder:"Search tools...",onSearchExpand:i,onSearchChange:s,onSearchBlur:c,onTabSwitch:u,searchInputRef:d})}const q4="mcp-inspector-saved-requests";function qK({ref:e,tools:t,callTool:n,readResource:a,serverId:r,isConnected:i}){const[s,c]=x.useState(null),[u,d]=x.useState(null),{selectedToolName:m,setSelectedToolName:h}=ld(),[g,v]=x.useState({}),[w,S]=x.useState([]),[y,_]=x.useState(!1),[E,k]=x.useState(null),[C,R]=x.useState(""),[A,I]=x.useState("tools"),[O,j]=x.useState([]),[F,H]=x.useState(!1),[K,Q]=x.useState(""),[W,ie]=x.useState(!0),[V,Y]=x.useState(!1),[z,te]=x.useState(-1),re=x.useRef(null),[$,B]=x.useState(!1),[U,L]=x.useState("list"),[P,G]=x.useState(!1),[Z,J]=x.useState(0),[se,le]=x.useState(!0),[ee,ne]=x.useState(void 0),ce=x.useRef(null),ae=x.useRef(null),ye=x.useRef(null),ke=x.useRef(null),Be=x.useRef(null);x.useEffect(()=>{const Ae=()=>{B(window.innerWidth<1024)};return Ae(),window.addEventListener("resize",Ae),()=>window.removeEventListener("resize",Ae)},[]),x.useEffect(()=>{L(s?"detail":"list")},[s]),x.useEffect(()=>{$&&w.length>0&&!y&&L("response")},[w,y,$]),x.useImperativeHandle(e,()=>({focusSearch:()=>{Y(!0),setTimeout(()=>{re.current&&re.current.focus()},0)},blurSearch:()=>{R(""),Y(!1),re.current&&re.current.blur()}})),x.useEffect(()=>{try{const Ae=localStorage.getItem(q4);Ae&&j(JSON.parse(Ae))}catch(Ae){console.error("[ToolsTab] Failed to load saved requests:",Ae)}},[]);const _e=x.useCallback(Ae=>{try{localStorage.setItem(q4,JSON.stringify(Ae)),j(Ae)}catch(Ie){console.error("[ToolsTab] Failed to save requests:",Ie)}},[]),Se=x.useMemo(()=>{if(!C.trim())return t;const Ae=C.toLowerCase();return t.filter(Ie=>Ie.name.toLowerCase().includes(Ae)||Ie.description?.toLowerCase().includes(Ae))},[t,C]),ze=x.useCallback(Ae=>{c(Ae);const Ie={};Ae.inputSchema?.properties&&Object.entries(Ae.inputSchema.properties).forEach(([Ye,tt])=>{const it=tt;it.default!==void 0?Ie[Ye]=it.default:it.type==="string"?Ie[Ye]="":it.type==="number"?Ie[Ye]=0:it.type==="boolean"?Ie[Ye]=!1:it.type==="array"?Ie[Ye]="[]":it.type==="object"&&(Ie[Ye]="{}")}),v(Ie)},[]),pe=x.useCallback(Ae=>{const Ie=t.find(Ye=>Ye.name===Ae.toolName);Ie&&(c(Ie),v(Ae.args),d(Ae))},[t]);x.useEffect(()=>{V&&re.current&&re.current.focus()},[V]);const Le=x.useCallback(()=>{C.trim()||Y(!1)},[C]);x.useEffect(()=>{A!=="tools"&&Y(!1)},[A]),x.useEffect(()=>{te(-1)},[C,A]),x.useEffect(()=>{const Ae=Ie=>{const Ye=Ie.target;if(Ye.tagName==="INPUT"||Ye.tagName==="TEXTAREA"||Ye.contentEditable==="true"||Ie.metaKey||Ie.ctrlKey||Ie.altKey)return;const it=A==="tools"?Se:O;if(Ie.key==="ArrowDown")Ie.preventDefault(),te(gt=>{const mt=gt+1;return mt>=it.length?0:mt});else if(Ie.key==="ArrowUp")Ie.preventDefault(),te(gt=>{const mt=gt-1;return mt<0?it.length-1:mt});else if(Ie.key==="Enter"&&z>=0)if(Ie.preventDefault(),A==="tools"){const gt=Se[z];gt&&ze(gt)}else{const gt=O[z];gt&&pe(gt)}};return document.addEventListener("keydown",Ae),()=>document.removeEventListener("keydown",Ae)},[z,Se,O,A,ze,pe]),x.useEffect(()=>{if(z>=0){const Ae=A==="tools"?`tool-${Se[z]?.name}`:`saved-${O[z]?.id}`,Ie=document.getElementById(Ae);Ie&&Ie.scrollIntoView({behavior:"smooth",block:"nearest"})}},[z,Se,O,A]),x.useEffect(()=>{if(m&&t.length>0){const Ae=t.find(Ie=>Ie.name===m);if(Ae&&s?.name!==Ae.name){h(null);const Ie=setTimeout(()=>{ze(Ae);const Ye=document.getElementById(`tool-${Ae.name}`);Ye&&Ye.scrollIntoView({behavior:"smooth",block:"nearest"})},100);return()=>clearTimeout(Ie)}}},[m,t,s,ze,h]);const Fe=x.useCallback((Ae,Ie)=>{v(Ye=>{const tt={...Ye};if(s?.inputSchema?.properties?.[Ae]){const gt=s.inputSchema.properties[Ae].type;if(gt==="object"||gt==="array")tt[Ae]=Ie;else if(gt==="string")tt[Ae]=Ie;else try{tt[Ae]=JSON.parse(Ie)}catch{tt[Ae]=Ie}}else tt[Ae]=Ie;return tt})},[s]),xe=x.useCallback(async()=>{if(!s||y)return;_(!0);const Ae=Date.now();try{const Ie={...g};s.inputSchema?.properties&&Object.entries(s.inputSchema.properties).forEach(([$t,on])=>{const Ve=on.type,jt=Ie[$t];if((Ve==="object"||Ve==="array")&&typeof jt=="string")try{Ie[$t]=JSON.parse(jt)}catch{}});const Ye=await n(s.name,Ie,{timeout:6e5,resetTimeoutOnProgress:!0}),tt=Date.now()-Ae;br.getInstance().capture(new QP({toolName:s.name,serverId:r,success:!0,duration:tt})).catch(()=>{});const gt=s?._meta||s?.metadata,mt=gt?.["openai/outputTemplate"];let Rn;if(mt&&typeof mt=="string"){const $t={toolName:s.name,args:g,result:Ye,timestamp:Ae,duration:tt,toolMeta:gt,appsSdkResource:{uri:mt,resourceData:null,isLoading:!0}};S([$t]);try{const on=await a(mt);let Bt=null;if(Ye?.structuredContent)Bt=Ye.structuredContent;else if(Array.isArray(Ye)&&Ye[0]){const Ve=Ye[0];Ve.output?.value?.structuredContent?Bt=Ve.output.value.structuredContent:Ve.structuredContent?Bt=Ve.structuredContent:Ve.output?.value&&(Bt=Ve.output.value)}Bt||(Bt=Ye),Rn={uri:mt,resourceData:{...on,structuredContent:Bt},isLoading:!1}}catch(on){Rn={uri:mt,resourceData:null,isLoading:!1,error:on instanceof Error?on.message:String(on)}}S(on=>on.map((Bt,Ve)=>Ve===0?{...Bt,appsSdkResource:Rn}:Bt))}else S($t=>[{toolName:s.name,args:g,result:Ye,timestamp:Ae,duration:tt,toolMeta:gt},...$t])}catch(Ie){const Ye=Date.now()-Ae;br.getInstance().capture(new QP({toolName:s.name,serverId:r,success:!1,duration:Ye,error:Ie instanceof Error?Ie.message:String(Ie)})).catch(()=>{});const it=s?._meta||s?.metadata,gt={toolName:s.name,args:g,result:null,error:Ie instanceof Error?Ie.message:String(Ie),timestamp:Ae,duration:Ye,toolMeta:it},mt=it?.["openai/outputTemplate"];S(mt?[gt]:Rn=>[gt,...Rn])}finally{_(!1)}},[s,g,y,n,a,r]),st=x.useCallback(async(Ae,Ie)=>{try{await navigator.clipboard.writeText(JSON.stringify(Ie,null,2)),k(Ae),setTimeout(()=>k(null),2e3)}catch(Ye){console.error("[ToolsTab] Failed to copy result:",Ye)}},[]),at=x.useCallback(Ae=>{S(Ie=>Ie.filter((Ye,tt)=>tt!==Ae))},[]),pt=x.useMemo(()=>s?w.filter(Ae=>Ae.toolName===s.name):[],[w,s]),Pe=x.useCallback(Ae=>{const Ie=pt[Ae];if(Ie){const Ye=window.open("","_blank","width=800,height=600");Ye&&(Ye.document.write(`
1670
1670
  <html>
1671
1671
  <head>
1672
1672
  <title>${Ie.toolName} Result</title>
@@ -1680,4 +1680,4 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
1680
1680
  <pre>${JSON.stringify(Ie.result,null,2)}</pre>
1681
1681
  </body>
1682
1682
  </html>
1683
- `),Ye.document.close())}},[w]),$e=x.useCallback(()=>{P?(ce.current&&ce.current.expand(),ae.current&&ae.current.expand(),G(!1)):(ce.current&&ce.current.collapse(),ae.current&&ae.current.collapse(),G(!0))},[P]),et=x.useCallback(()=>{s&&(Q(""),H(!0))},[s]),an=x.useCallback(()=>{if(!s)return;const Ae={id:`${Date.now()}-${Math.random()}`,name:K.trim()||`${s.name} - ${new Date().toLocaleString()}`,toolName:s.name,args:g,savedAt:Date.now(),serverId:s._serverId,serverName:s._serverName};_e([...O,Ae]),br.getInstance().capture(new ife({toolName:s.name,serverId:r})).catch(()=>{}),H(!1),Q("")},[s,K,g,O,_e,r]),Qe=x.useCallback(Ae=>{_e(O.filter(Ie=>Ie.id!==Ae)),u?.id===Ae&&d(null)},[O,_e,u]);return $?p.jsxs("div",{className:"h-full flex flex-col overflow-hidden relative bg-background",children:[U!=="list"&&p.jsxs("div",{className:"flex items-center gap-2 p-2 border-b shrink-0 bg-background z-10",children:[p.jsx(Ue,{variant:"ghost",size:"sm",onClick:()=>{U==="response"?L("detail"):(c(null),L("list"))},className:"p-0 h-8 w-8",children:p.jsx(QT,{className:"h-4 w-4"})}),p.jsxs("div",{className:"flex items-center text-sm font-medium",children:[p.jsx("button",{onClick:()=>{c(null),L("list")},className:"text-muted-foreground hover:text-foreground hover:underline cursor-pointer",children:"Tools"}),U==="detail"&&p.jsxs(p.Fragment,{children:[p.jsx("span",{className:"mx-2 text-muted-foreground",children:"/"}),p.jsx("button",{onClick:()=>{L("response")},className:U==="detail"?"text-foreground hover:underline":U==="response"?"text-muted-foreground hover:text-foreground hover:underline cursor-pointer":"text-muted-foreground",children:"Execute"})]}),U==="response"&&p.jsxs(p.Fragment,{children:[p.jsx("span",{className:"mx-2 text-muted-foreground",children:"/"}),p.jsx("span",{className:"text-foreground",children:"Response"})]})]})]}),p.jsx("div",{className:"flex-1 relative overflow-hidden",children:p.jsxs(ly,{initial:!1,mode:"popLayout",children:[U==="list"&&p.jsxs(ma.div,{initial:{x:"-100%"},animate:{x:0},exit:{x:"-100%"},transition:{type:"spring",stiffness:300,damping:30},className:"absolute inset-0 flex flex-col bg-background z-0",children:[p.jsx(X4,{activeTab:A,isSearchExpanded:V,searchQuery:C,filteredToolsCount:Se.length,savedRequestsCount:O.length,onSearchExpand:()=>Y(!0),onSearchChange:R,onSearchBlur:Le,onTabSwitch:()=>I(A==="tools"?"saved":"tools"),searchInputRef:re}),A==="tools"?p.jsx(Y4,{tools:Se,selectedTool:s,onToolSelect:ze,focusedIndex:z}):p.jsx(V4,{savedRequests:O,selectedRequest:u,onLoadRequest:pe,onDeleteRequest:Qe,focusedIndex:z})]},"list"),U==="detail"&&p.jsx(ma.div,{initial:{x:"100%"},animate:{x:0},exit:{x:"-100%"},transition:{type:"spring",stiffness:300,damping:30},className:"absolute inset-0 bg-background z-10",children:p.jsx(W4,{selectedTool:s,toolArgs:g,isExecuting:y,isConnected:i,onArgChange:Fe,onExecute:xe,onSave:et})},"detail"),U==="response"&&p.jsx(ma.div,{initial:{x:"100%"},animate:{x:0},exit:{x:"100%"},transition:{type:"spring",stiffness:300,damping:30},className:"absolute inset-0 bg-background z-20",children:p.jsx(Z4,{results:pt,copiedResult:E,previewMode:W,serverId:r,readResource:a,onCopy:st,onDelete:at,onFullscreen:Pe,onTogglePreview:()=>ie(!W)})},"response")]})}),p.jsx(G4,{isOpen:F,requestName:K,defaultPlaceholder:`${s?.name} - ${new Date().toLocaleString()}`,onRequestNameChange:Q,onSave:an,onCancel:()=>H(!1)})]}):p.jsxs(Da,{direction:"horizontal",className:"h-full",children:[p.jsx(zn,{ref:ce,defaultSize:33,collapsible:!0,className:"flex flex-col h-full relative",children:p.jsxs(Da,{direction:"vertical",className:"h-full border-r dark:border-zinc-700",children:[p.jsx(zn,{defaultSize:75,minSize:30,children:p.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[p.jsx(X4,{activeTab:A,isSearchExpanded:V,searchQuery:C,filteredToolsCount:Se.length,savedRequestsCount:O.length,onSearchExpand:()=>Y(!0),onSearchChange:R,onSearchBlur:Le,onTabSwitch:()=>I(A==="tools"?"saved":"tools"),searchInputRef:re}),A==="tools"?p.jsx(Y4,{tools:Se,selectedTool:s,onToolSelect:ze,focusedIndex:z}):p.jsx(V4,{savedRequests:O,selectedRequest:u,onLoadRequest:pe,onDeleteRequest:Qe,focusedIndex:z})]})}),p.jsx(Ui,{withHandle:!0}),p.jsxs(zn,{ref:ke,defaultSize:0,collapsible:!0,minSize:5,collapsedSize:5,onCollapse:()=>{le(!0)},onExpand:()=>{le(!1)},className:"flex flex-col border-t dark:border-zinc-700",children:[p.jsxs("div",{className:"group flex items-center justify-between p-3 shrink-0 cursor-pointer hover:bg-muted/50 transition-colors",onClick:Ae=>{Ae.preventDefault(),Ae.stopPropagation(),se?(ke.current?.resize(25),le(!1)):(ke.current?.resize(5),le(!0))},children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx("h3",{className:"text-sm font-medium",children:"RPC Messages"}),Z>0&&p.jsx(Jr,{variant:"secondary",className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",children:Z}),Z>0&&!se&&p.jsx(Ue,{variant:"ghost",size:"sm",onClick:Ae=>{Ae.preventDefault(),Ae.stopPropagation(),Be.current?.()},className:"h-6 w-6 p-0",title:"Clear all messages",children:p.jsx(Is,{className:"h-3.5 w-3.5"})})]}),p.jsx(Vl,{className:`h-4 w-4 text-muted-foreground transition-transform ${se?"":"rotate-180"}`})]}),!se&&p.jsx("div",{className:"flex-1 overflow-hidden min-h-0",children:p.jsx(TO,{serverIds:[r],onCountChange:J,onClearRef:Be})})]})]})}),p.jsx(Ui,{withHandle:!0}),p.jsx(zn,{defaultSize:67,children:p.jsxs(Da,{direction:"vertical",children:[p.jsx(zn,{ref:ae,defaultSize:40,collapsible:!0,children:p.jsx(W4,{selectedTool:s,toolArgs:g,isExecuting:y,isConnected:i,onArgChange:Fe,onExecute:xe,onSave:et})}),p.jsx(Ui,{withHandle:!0}),p.jsx(zn,{ref:ye,defaultSize:60,children:p.jsx("div",{className:"flex flex-col h-full",children:p.jsx(Z4,{results:pt,copiedResult:E,previewMode:W,serverId:r,readResource:a,onCopy:st,onDelete:at,onFullscreen:Pe,onTogglePreview:()=>ie(!W),onMaximize:$e,isMaximized:P})})})]})}),p.jsx(G4,{isOpen:F,requestName:K,defaultPlaceholder:`${s?.name} - ${new Date().toLocaleString()}`,onRequestNameChange:Q,onSave:an,onCancel:()=>H(!1)})]})}qK.displayName="ToolsTab";function D_e({isSearchExpanded:e,searchQuery:t,filteredRequestsCount:n,requestsCount:a,onSearchExpand:r,onSearchChange:i,onSearchBlur:s,onRejectAll:c,searchInputRef:u}){return p.jsxs("div",{className:"flex flex-row items-center justify-between p-4 sm:p-4 py-3 gap-2",children:[p.jsx("div",{className:"flex items-center gap-2 flex-1",children:e?p.jsx(jn,{ref:u,placeholder:"Search requests...",value:t,onChange:d=>i(d.target.value),onBlur:s,className:"h-8 border-gray-300 dark:border-zinc-600"}):p.jsxs(p.Fragment,{children:[p.jsx("h2",{className:"text-lg font-medium text-gray-900 dark:text-gray-100",children:"Sampling"}),p.jsx(Jr,{className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",variant:"outline",children:n}),p.jsxs(en,{children:[p.jsx(tn,{asChild:!0,children:p.jsx(Ue,{variant:"ghost",size:"sm",onClick:r,className:"h-8 w-8 p-0",children:p.jsx(qp,{className:"h-4 w-4"})})}),p.jsxs(nn,{side:"bottom",className:"flex gap-2",children:["Search",p.jsx($y,{children:"F"})]})]})]})}),p.jsx("div",{className:"flex items-center gap-2",children:p.jsxs(en,{children:[p.jsx(tn,{asChild:!0,children:p.jsx(Ue,{variant:"ghost",size:"sm",onClick:c,disabled:a===0,className:"h-8 w-8 p-0",children:p.jsx(Is,{className:"h-4 w-4"})})}),p.jsx(nn,{side:"bottom",children:"Reject all"})]})})]})}function L_e({requests:e,selectedRequest:t,onRequestSelect:n,focusedIndex:a,formatRelativeTime:r,listRef:i}){return e.length===0?p.jsx("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:p.jsx(Yp,{vertical:!0,noBorder:!0,message:"No sampling requests"})}):p.jsx("div",{ref:i,className:"overflow-y-auto flex-1 overscroll-contain",children:e.map((s,c)=>{const u=s.request.params?.messages?.length||0,d=s.request.params?.maxTokens;return p.jsx(Xl,{id:`sampling-request-${s.id}`,isSelected:t?.id===s.id,isFocused:a===c,title:p.jsxs("span",{className:"flex items-center gap-3",children:[s.serverName,p.jsx("span",{className:"size-1.5 block rounded-full bg-orange-500"})]}),description:(()=>{const m=r(s.timestamp),h=[];u>0&&h.push(`${u} message${u>1?"s":""}`),d&&h.push(`max ${d} tokens`);const g=h.length>0?` | ${h.join(", ")}`:"";return m+g})(),onClick:()=>n(s)},s.id)})})}function $_e({llmConfig:e}){const t=x.useRef(null);return{generateResponse:x.useCallback(async({request:a})=>{if(!e)throw new Error("LLM config is not available");const r=a.params||{},i=r.maxTokens,s=r.temperature;r.modelPreferences;const c=r.messages||[];if(console.log("[useSamplingLLM] Request structure:",{hasParams:!!r,messagesCount:c.length,messages:c,params:r}),c.length===0)throw new Error("No messages found in sampling request");const u=[],{HumanMessage:d,AIMessage:m}=await Ar(async()=>{const{HumanMessage:w,AIMessage:S}=await import("./index-DLvycrCn.js").then(y=>y.bD);return{HumanMessage:w,AIMessage:S}},[]);for(const w of c){if(!w||!w.role){console.warn("Skipping invalid message:",w);continue}const S=Array.isArray(w.content)?w.content[0]:w.content;if(!S){console.warn("Skipping message with no content:",w);continue}S.type==="text"&&S.text?w.role==="user"?u.push(new d(S.text)):w.role==="assistant"&&u.push(new m(S.text)):console.warn("Skipping message with unsupported content type:",S)}if(u.length===0)throw new Error("No valid messages could be converted. Please ensure messages have 'text' content type.");if(!t.current||t.current.provider!==e.provider||t.current.model!==e.model||t.current.apiKey!==e.apiKey){let w;const S={model:e.model,apiKey:e.apiKey};if(i!==void 0&&(S.maxTokens=i),s!==void 0?S.temperature=s:e.temperature!==void 0&&(S.temperature=e.temperature),e.provider==="openai"){const{ChatOpenAI:y}=await Ar(async()=>{const{ChatOpenAI:_}=await import("./index-dcwAFu32.js");return{ChatOpenAI:_}},__vite__mapDeps([5,6,7,3,8,9]));w=new y(S)}else if(e.provider==="anthropic"){const{ChatAnthropic:y}=await Ar(async()=>{const{ChatAnthropic:_}=await import("./index-jXEm6Yfx.js");return{ChatAnthropic:_}},__vite__mapDeps([10,7,6,3]));w=new y(S)}else if(e.provider==="google"){const{ChatGoogleGenerativeAI:y}=await Ar(async()=>{const{ChatGoogleGenerativeAI:_}=await import("./index-DMpSV0MO.js");return{ChatGoogleGenerativeAI:_}},__vite__mapDeps([11,7,6,3,9]));w=new y(S)}else throw new Error(`Unsupported LLM provider: ${e.provider}`);t.current={instance:w,provider:e.provider,model:e.model,apiKey:e.apiKey}}const h=await t.current.instance.invoke(u);return{role:"assistant",content:{type:"text",text:h.content||h.text||""},model:e.model,stopReason:"endTurn"}},[e]),isAvailable:e!==null}}function j_e({request:e,onApprove:t,onReject:n,onClose:a,previewMode:r,onTogglePreview:i,isCopied:s,onCopy:c,onDownload:u,onFullscreen:d,llmConfig:m}){const[h,g]=x.useState("manual"),[v,w]=x.useState("stub-model"),[S,y]=x.useState("endTurn"),[_,E]=x.useState("assistant"),[k,C]=x.useState("text"),[R,A]=x.useState("positive"),[I,O]=x.useState(""),[j,F]=x.useState("image/png"),[H,K]=x.useState(!1),[Q,W]=x.useState(null),{generateResponse:ie,isAvailable:V}=$_e({llmConfig:m});x.useEffect(()=>{e&&(w("stub-model"),y("endTurn"),E("assistant"),C("text"),A("positive"),O(""),F("image/png"),W(null))},[e?.id]);const Y=async()=>{if(!(!e||!V)){K(!0),W(null);try{const $=await ie({request:e.request});w($.model||m?.model||"stub-model"),y($.stopReason||"endTurn"),E($.role||"assistant");const B=Array.isArray($.content)?$.content[0]:$.content;B.type==="text"?(C("text"),A(B.text||"")):B.type==="image"&&(C("image"),O(B.data||""),F(B.mimeType||"image/png"))}catch($){const B=$ instanceof Error?$.message:"Failed to generate response";W(B),Qt.error("LLM Generation Failed",{description:B})}finally{K(!1)}}},z=x.useMemo(()=>{const $={model:v,stopReason:S,role:_,content:{type:k}};return k==="text"?$.content.text=R:k==="image"&&($.content.data=I,$.content.mimeType=j),$},[v,S,_,k,R,I,j]),te=()=>{if(!e)return;const $=pT.safeParse(z);if(!$.success){Qt.error("Invalid response",{description:`Validation failed: ${$.error.message}`});return}t(e.id,$.data),a(),Ar(()=>Promise.resolve().then(()=>Pp),void 0).then(B=>{const U=Qt(B.createElement("div",{className:"space-y-3"},B.createElement("div",null,B.createElement("strong",null,"Sampling Response Sent"),B.createElement("p",{className:"text-sm text-muted-foreground mt-1"},"The tool will continue executing.")),B.createElement("div",{className:"flex gap-2"},B.createElement("button",{className:"px-3 py-1.5 text-xs font-medium rounded-md bg-primary text-primary-foreground hover:bg-primary/90",onClick:()=>{const L=new globalThis.CustomEvent("navigate-to-tool-result",{detail:{toolName:e.toolName}});window.dispatchEvent(L),Qt.dismiss(U)}},"View Tool Result"))),{duration:5e3})})},re=()=>{e&&(n(e.id,"User rejected sampling request"),a())};return e?p.jsxs("div",{className:"flex flex-col h-full",children:[p.jsxs("div",{className:"flex items-center justify-between p-4 border-b dark:border-zinc-700",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx("h3",{className:"font-medium text-gray-900 dark:text-gray-100",children:e.serverName}),p.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:new Date(e.timestamp).toLocaleString()})]}),p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsxs(en,{children:[p.jsx(tn,{asChild:!0,children:p.jsx(Ue,{variant:"ghost",size:"sm",onClick:c,className:"h-8 w-8 p-0",children:s?p.jsx(La,{className:"h-4 w-4 text-green-600"}):p.jsx(Xr,{className:"h-4 w-4"})})}),p.jsx(nn,{children:"Copy request"})]}),p.jsxs(en,{children:[p.jsx(tn,{asChild:!0,children:p.jsx(Ue,{variant:"ghost",size:"sm",onClick:u,className:"h-8 w-8 p-0",children:p.jsx(ny,{className:"h-4 w-4"})})}),p.jsx(nn,{children:"Download request"})]}),p.jsxs(en,{children:[p.jsx(tn,{asChild:!0,children:p.jsx(Ue,{variant:"ghost",size:"sm",onClick:d,className:"h-8 w-8 p-0",children:p.jsx(B9,{className:"h-4 w-4"})})}),p.jsx(nn,{children:"Fullscreen"})]}),p.jsx(Ue,{variant:"ghost",size:"sm",onClick:a,className:"h-8 w-8 p-0",children:p.jsx(Gl,{className:"h-4 w-4"})})]})]}),p.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-6",children:[p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:"Request"}),p.jsx("div",{className:"bg-muted rounded-lg p-3 max-h-64 overflow-auto",children:p.jsx(ir,{data:e.request})})]}),p.jsxs("div",{className:"space-y-4",children:[p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:"Response"}),p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(Yt,{htmlFor:`responseMode-${e.id}`,className:"text-xs text-gray-500 dark:text-gray-400",children:"Mode:"}),p.jsxs(Eo,{value:h,onValueChange:$=>g($),children:[p.jsx(ko,{id:`responseMode-${e.id}`,className:"w-32 h-8 text-xs",children:p.jsx(_o,{})}),p.jsxs(To,{children:[p.jsx(Rr,{value:"manual",children:"Manual"}),p.jsx(Rr,{value:"llm",children:"LLM"})]})]})]})]}),h==="llm"&&p.jsxs("div",{className:"space-y-2 p-3 bg-muted rounded-lg",children:[V?p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(Ue,{onClick:Y,disabled:H,size:"sm",className:"flex items-center gap-2",children:H?p.jsxs(p.Fragment,{children:[p.jsx(As,{className:"h-4 w-4 animate-spin"}),"Generating..."]}):p.jsxs(p.Fragment,{children:[p.jsx(Ppe,{className:"h-4 w-4"}),"Generate with LLM"]})}),p.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:["Using ",m?.provider," (",m?.model,")"]})]}):p.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:"LLM not configured. Please configure LLM in the Chat tab."}),Q&&p.jsx("div",{className:"text-xs text-red-600 dark:text-red-400",children:Q})]}),p.jsxs("div",{className:"space-y-2",children:[p.jsx(Yt,{htmlFor:`model-${e.id}`,children:"Model"}),p.jsx(jn,{id:`model-${e.id}`,value:v,onChange:$=>w($.target.value),placeholder:"stub-model",disabled:h==="llm"&&H})]}),p.jsxs("div",{className:"space-y-2",children:[p.jsx(Yt,{htmlFor:`stopReason-${e.id}`,children:"Stop Reason"}),p.jsx(jn,{id:`stopReason-${e.id}`,value:S,onChange:$=>y($.target.value),placeholder:"endTurn",disabled:h==="llm"&&H})]}),p.jsxs("div",{className:"space-y-2",children:[p.jsx(Yt,{htmlFor:`role-${e.id}`,children:"Role"}),p.jsxs(Eo,{value:_,onValueChange:$=>E($),disabled:h==="llm"&&H,children:[p.jsx(ko,{id:`role-${e.id}`,children:p.jsx(_o,{})}),p.jsxs(To,{children:[p.jsx(Rr,{value:"assistant",children:"assistant"}),p.jsx(Rr,{value:"user",children:"user"})]})]})]}),p.jsxs("div",{className:"space-y-2",children:[p.jsx(Yt,{htmlFor:`contentType-${e.id}`,children:"Content Type"}),p.jsxs(Eo,{value:k,onValueChange:$=>C($),disabled:h==="llm"&&H,children:[p.jsx(ko,{id:`contentType-${e.id}`,children:p.jsx(_o,{})}),p.jsxs(To,{children:[p.jsx(Rr,{value:"text",children:"text"}),p.jsx(Rr,{value:"image",children:"image"})]})]})]}),k==="text"&&p.jsxs("div",{className:"space-y-2",children:[p.jsx(Yt,{htmlFor:`text-${e.id}`,children:"Text Content"}),p.jsx(zu,{id:`text-${e.id}`,value:R,onChange:$=>A($.target.value),placeholder:"Enter response text...",rows:6,disabled:h==="llm"&&H})]}),k==="image"&&p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"space-y-2",children:[p.jsx(Yt,{htmlFor:`imageData-${e.id}`,children:"Base64 Image Data"}),p.jsx(zu,{id:`imageData-${e.id}`,value:I,onChange:$=>O($.target.value),placeholder:"Base64 encoded image data...",rows:4,disabled:h==="llm"&&H})]}),p.jsxs("div",{className:"space-y-2",children:[p.jsx(Yt,{htmlFor:`mimeType-${e.id}`,children:"MIME Type"}),p.jsx(jn,{id:`mimeType-${e.id}`,value:j,onChange:$=>F($.target.value),placeholder:"image/png",disabled:h==="llm"&&H})]})]})]})]}),p.jsxs("div",{className:"flex gap-2 p-4 border-t dark:border-zinc-700",children:[p.jsx(Ue,{onClick:te,className:"flex-1",disabled:h==="llm"&&H,children:"Approve"}),p.jsx(Ue,{onClick:re,variant:"outline",className:"flex-1",disabled:h==="llm"&&H,children:"Reject"})]})]}):p.jsx("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:p.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"Select a sampling request to view details"})})}function M_e({pendingRequests:e,onApprove:t,onReject:n,serverId:a,isConnected:r,mcpServerUrl:i}){const{selectedSamplingRequestId:s,setSelectedSamplingRequestId:c}=ld(),{llmConfig:u}=_K({mcpServerUrl:i}),[d,m]=x.useState(null),[h,g]=x.useState(""),[v,w]=x.useState(-1),[S,y]=x.useState(!0),[_,E]=x.useState(!1),[k,C]=x.useState(!0),[R,A]=x.useState(!1),I=x.useRef(null),O=x.useRef(null),j=x.useRef(null),F=x.useRef(!1);x.useEffect(()=>{if(console.log("[SamplingTab] Auto-selection check:",{selectedSamplingRequestId:s,pendingRequestsCount:e.length,currentSelectedId:d?.id}),s&&e.length>0){const z=e.find(te=>te.id===s);console.log("[SamplingTab] Found request for auto-selection:",!!z,z?.id),z&&(console.log("[SamplingTab] Auto-selecting request:",z.id),c(null),m(z),setTimeout(()=>{const te=document.getElementById(`sampling-request-${z.id}`);console.log("[SamplingTab] Scrolling to element:",!!te),te&&te.scrollIntoView({behavior:"smooth",block:"nearest"})},100))}},[s,e,c]),x.useEffect(()=>{const z=te=>{const $=te.detail.requestId;console.log("[SamplingTab] Custom navigate event received:",$);const B=e.find(U=>U.id===$);B&&(console.log("[SamplingTab] Selecting request from event:",$),m(B),setTimeout(()=>{const U=document.getElementById(`sampling-request-${$}`);U&&U.scrollIntoView({behavior:"smooth",block:"nearest"})},200))};return window.addEventListener("navigate-to-sampling",z),()=>window.removeEventListener("navigate-to-sampling",z)},[e]),x.useEffect(()=>{S&&e.length>0&&I.current&&!F.current&&(I.current.scrollTop=0)},[e.length,S]),x.useEffect(()=>{const z=I.current;if(!z)return;const te=()=>{z.scrollTop>0&&(F.current=!0,y(!1))};return z.addEventListener("scroll",te),()=>z.removeEventListener("scroll",te)},[]),x.useEffect(()=>{e.length===0&&(F.current=!1,y(!0))},[e.length]),x.useEffect(()=>{_&&j.current&&j.current.focus()},[_]);const H=x.useCallback(()=>{h.trim()||E(!1)},[h]),K=x.useMemo(()=>{if(!h.trim())return e;const z=h.toLowerCase();return e.filter(te=>te.serverName.toLowerCase().includes(z)||JSON.stringify(te.request||{}).toLowerCase().includes(z))},[e,h]);x.useEffect(()=>{w(-1)},[h]),x.useEffect(()=>{const z=te=>{const re=te.target;if(re.tagName==="INPUT"||re.tagName==="TEXTAREA"||re.contentEditable==="true"||te.metaKey||te.ctrlKey||te.altKey)return;const B=K;if(te.key==="ArrowDown")te.preventDefault(),w(U=>{const L=U+1;return L>=B.length?0:L});else if(te.key==="ArrowUp")te.preventDefault(),w(U=>{const L=U-1;return L<0?B.length-1:L});else if(te.key==="Enter"&&v>=0){te.preventDefault();const U=K[v];U&&Q(U)}};return document.addEventListener("keydown",z),()=>document.removeEventListener("keydown",z)},[v,K]),x.useEffect(()=>{if(v>=0){const z=`sampling-request-${K[v]?.id}`,te=document.getElementById(z);te&&te.scrollIntoView({behavior:"smooth",block:"nearest"})}},[v,K]);const Q=x.useCallback(z=>{m(z)},[]),W=x.useCallback(()=>{window.confirm("Are you sure you want to reject all sampling requests? This cannot be undone.")&&(e.forEach(z=>{n(z.id,"User rejected all requests")}),m(null))},[e,n]),ie=x.useCallback(async()=>{if(d)try{await navigator.clipboard.writeText(JSON.stringify({id:d.id,serverName:d.serverName,timestamp:d.timestamp,request:d.request},null,2)),A(!0),setTimeout(()=>A(!1),2e3)}catch(z){console.error("[SamplingTab] Failed to copy request:",z)}},[d]),V=x.useCallback(()=>{if(d)try{const z=new globalThis.Blob([JSON.stringify({id:d.id,serverName:d.serverName,timestamp:d.timestamp,request:d.request},null,2)],{type:"application/json"}),te=URL.createObjectURL(z),re=document.createElement("a");re.href=te,re.download=`sampling-request-${Date.now()}.json`,document.body.appendChild(re),re.click(),document.body.removeChild(re),URL.revokeObjectURL(te)}catch(z){console.error("[SamplingTab] Failed to download request:",z)}},[d]),Y=x.useCallback(async()=>{if(O.current)try{document.fullscreenElement?await document.exitFullscreen():await O.current.requestFullscreen()}catch(z){console.error("[SamplingTab] Failed to toggle fullscreen:",z)}},[]);return r?p.jsxs(Da,{direction:"horizontal",className:"h-full",children:[p.jsx(zn,{defaultSize:40,minSize:30,children:p.jsx(Da,{direction:"vertical",className:"h-full border-r dark:border-zinc-700",children:p.jsxs(zn,{defaultSize:75,minSize:30,children:[p.jsx(D_e,{isSearchExpanded:_,searchQuery:h,filteredRequestsCount:K.length,requestsCount:e.length,onSearchExpand:()=>E(!0),onSearchChange:g,onSearchBlur:H,onRejectAll:W,searchInputRef:j}),p.jsx("div",{className:"flex flex-col h-full",children:p.jsx(L_e,{requests:K,selectedRequest:d,onRequestSelect:Q,focusedIndex:v,formatRelativeTime:d_,listRef:I})})]})})}),p.jsx(Ui,{}),p.jsx(zn,{defaultSize:60,minSize:40,children:p.jsx("div",{ref:O,className:"h-full bg-white dark:bg-zinc-900",children:p.jsx(j_e,{request:d,onApprove:t,onReject:n,onClose:()=>m(null),previewMode:k,onTogglePreview:()=>C(!k),isCopied:R,onCopy:ie,onDownload:V,onFullscreen:Y,llmConfig:u})})})]}):p.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[p.jsx(z9,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),p.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"Not connected to server"})]})}function P_e({selectedServer:e,activeTab:t,toolsSearchRef:n,promptsSearchRef:a,resourcesSearchRef:r,children:i}){return e?p.jsxs(p.Fragment,{children:[p.jsx("div",{style:{display:t==="tools"?"block":"none"},className:"h-full",children:p.jsx(qK,{ref:n,tools:e.tools,callTool:e.callTool,readResource:e.readResource,serverId:e.id,isConnected:e.state==="ready"})}),p.jsx("div",{style:{display:t==="prompts"?"block":"none"},className:"h-full",children:p.jsx(KK,{ref:a,prompts:e.prompts,callPrompt:e.getPrompt,serverId:e.id,isConnected:e.state==="ready"})}),p.jsx("div",{style:{display:t==="resources"?"block":"none"},className:"h-full",children:p.jsx(YK,{ref:r,resources:e.resources,readResource:e.readResource,serverId:e.id,isConnected:e.state==="ready"})}),p.jsx("div",{style:{display:t==="chat"?"block":"none"},className:"h-full",children:p.jsx(WEe,{connection:e,isConnected:e.state==="ready",readResource:e.readResource},e.id)}),p.jsx("div",{style:{display:t==="sampling"?"block":"none"},className:"h-full",children:p.jsx(M_e,{pendingRequests:e.pendingSamplingRequests,onApprove:e.approveSampling,onReject:e.rejectSampling,serverId:e.id,isConnected:e.state==="ready",mcpServerUrl:e.url})}),p.jsx("div",{style:{display:t==="notifications"?"block":"none"},className:"h-full",children:p.jsx(__e,{notifications:e.notifications,unreadCount:e.unreadNotificationCount,markNotificationRead:e.markNotificationRead,markAllNotificationsRead:e.markAllNotificationsRead,clearNotifications:e.clearNotifications,serverId:e.id,isConnected:e.state==="ready"})}),t!=="tools"&&t!=="prompts"&&t!=="resources"&&t!=="chat"&&t!=="sampling"&&t!=="notifications"&&p.jsx(p.Fragment,{children:i})]}):p.jsx(p.Fragment,{children:i})}function J4({className:e}){return p.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentcolor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:e,children:[p.jsx("path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4"}),p.jsx("path",{d:"M9 18c-4.51 2-5-2-7-2"})]})}const JK=x.createContext(void 0);function QK(){const e=x.use(JK);if(!e)throw new Error("useTabs must be used within a TabsProvider");return e}const eZ=x.createContext(void 0);function U_e(){return x.use(eZ)}function f_({ref:e,children:t,defaultValue:n,value:a,onValueChange:r,className:i,...s}){const[c,u]=x.useState(n||""),d=a!==void 0,m=x.useCallback(g=>{d||u(g),r?.(g)},[d,r]),h=d?a:c;return p.jsx(JK,{value:{activeValue:h,handleValueChange:m},children:p.jsx("div",{ref:e,className:De("flex flex-col gap-2",i),...s,children:t})})}f_.displayName="Tabs";function p_({ref:e,children:t,className:n,variant:a="default",...r}){const{activeValue:i}=QK(),[s,c]=x.useState({width:0,left:0}),u=x.useRef(null),d=x.useRef(null),m=x.useRef(null),g=x.Children.toArray(t).findIndex(S=>x.isValidElement(S)&&S.props.value===i),v=x.useCallback(()=>{const S=u.current;if(!S)return;const _=S.querySelectorAll("button")[g];if(_){const E=S.getBoundingClientRect(),k=_.getBoundingClientRect();c({width:k.width,left:k.left-E.left})}},[g]),w=x.useCallback(()=>{m.current&&clearTimeout(m.current),m.current=setTimeout(v,16)},[v]);return x.useEffect(()=>{const S=setTimeout(v,10);return()=>clearTimeout(S)},[v]),x.useEffect(()=>{const S=u.current;return S?(d.current=new ResizeObserver(()=>{w()}),d.current.observe(S),S.querySelectorAll("button").forEach(_=>{d.current&&d.current.observe(_)}),()=>{d.current&&d.current.disconnect(),m.current&&clearTimeout(m.current)}):void 0},[w]),x.useEffect(()=>{const S=()=>{w()};return window.addEventListener("resize",S),()=>window.removeEventListener("resize",S)},[w]),x.useEffect(()=>{const S=u.current;if(!S)return;const y=S.querySelector("[data-width]");y&&(y.style.width=`${s.width}px`,y.style.left=`${s.left}px`)},[s]),p.jsx(eZ,{value:{variant:a},children:p.jsxs("div",{ref:u,className:De("relative flex bg-none",a==="default"&&"p-1 rounded-full border border-zinc-300 dark:border-zinc-600",a==="underline"&&"border-b border-zinc-200 dark:border-zinc-700",n),...r,children:[t,p.jsx("span",{className:De("absolute transition-all duration-200 ease-out z-0",a==="default"&&"bg-white dark:bg-zinc-700 rounded-full h-[calc(100%-8px)] top-1 border border-zinc-300 dark:border-zinc-600",a==="underline"&&"bottom-0 h-0.5 bg-black dark:bg-white"),"data-width":s.width,"data-left":s.left})]})})}p_.displayName="TabsList";function m_({ref:e,children:t,value:n,className:a,disabled:r,icon:i,...s}){const{activeValue:c,handleValueChange:u}=QK(),m=U_e()?.variant||"default",h=c===n;return p.jsxs("button",{ref:e,disabled:r,onClick:()=>u(n),className:De("relative z-10 flex-1 inline-flex items-center justify-center whitespace-nowrap text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 cursor-pointer",m==="default"&&"rounded-md px-4 py-2.5",m==="underline"&&"px-6 py-3 border-b-2 border-transparent",h&&"text-foreground",!h&&"text-muted-foreground hover:text-foreground",a),...s,children:[i&&p.jsx(i,{className:"mr-2 h-4 w-4"}),t]})}m_.displayName="TabsTrigger";function Q4({className:e}){const{theme:t,setTheme:n}=Ry(),a=x.useRef(null),[r,i]=x.useState(!1);x.useEffect(()=>{i(!0)},[]);const s=()=>t==="system"?"light":t==="light"?"dark":"system",c=()=>t==="system"?p.jsx(sU,{className:"size-4"}):t==="light"?p.jsx(Bpe,{className:"size-5"}):p.jsx(xpe,{className:"size-4"}),u=()=>t==="system"?"Switch to light mode":t==="light"?"Switch to dark mode":"Switch to system mode",d=async()=>{if(!a.current)return;const m=s();if(typeof document<"u"&&"startViewTransition"in document){await document.startViewTransition(()=>{qu.flushSync(()=>{n(m)})}).ready;const{top:h,left:g,width:v,height:w}=a.current.getBoundingClientRect(),S=h+w/2,y=g+v/2,_=window.innerWidth-g,E=window.innerHeight-h,k=Math.hypot(Math.max(g,_),Math.max(h,E));document.documentElement.animate({clipPath:[`circle(0px at ${y}px ${S}px)`,`circle(${k}px at ${y}px ${S}px)`]},{duration:700,easing:"ease-in-out",pseudoElement:"::view-transition-new(root)"})}else n(m)};return r?p.jsx("button",{ref:a,onClick:d,className:De(e),"aria-label":u(),title:`Current: ${t==="system"?"Auto":t==="light"?"Light":"Dark"}`,children:c()}):p.jsx("button",{ref:a,className:De(e),"aria-label":"Toggle theme",children:p.jsx(sU,{className:"size-4"})})}function e2({className:e,state:t="collapsed",href:n="https://mcp-use.com"}){const[a,r]=x.useState(!1),i=.2,s=.7,c=.6,u=4,d=i+s+c,m=0,h=i/d,g=(i+s)/d,v=1;return p.jsxs("a",{href:n,target:"_blank",rel:"noopener noreferrer",className:De("flex items-center transition-opacity -my-3",t==="expanded"?"space-x-2":"",e),onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),children:[p.jsx("div",{className:"relative",children:p.jsxs(ma.svg,{viewBox:"0 0 303 303",initial:"rest",animate:a?"hover":"rest",className:De("text-foreground",t==="expanded"?"size-[40px]":"size-[20px]"),children:[p.jsxs(ma.g,{variants:{rest:{opacity:1},hover:{opacity:[1,0,0,1],transition:{duration:d,times:[m,h,g,v],ease:"easeInOut"}}},fill:"currentColor",fillRule:"nonzero",stroke:"currentColor",strokeWidth:u,strokeLinecap:"round",strokeLinejoin:"round",children:[p.jsx("path",{d:"m105.5 34.8.6.6c9.5 9.5 14.4 21.9 14.6 34.4a112.6 112.6 0 0 0 112.2 112.1h.6c12 .4 24 5.1 33.2 14.1l.6.6a50 50 0 0 1-70.1 71.3l-.6-.6A49.9 49.9 0 0 1 182 230 112.6 112.6 0 0 0 73.4 120.7h-.8a49.9 49.9 0 0 1-36.7-14l-.5-.6a50 50 0 0 1-.6-70.2l.6-.5a50 50 0 0 1 69.5-1.2l.6.6Z"}),p.jsx("circle",{cx:"70.3",cy:"232.3",r:"50"}),p.jsx("circle",{cx:"232.3",cy:"70.3",r:"50"})]}),p.jsxs("g",{fill:"none",stroke:"currentColor",strokeWidth:u,strokeLinecap:"round",strokeLinejoin:"round",children:[p.jsx(z_e,{d:"m105.5 34.8.6.6c9.5 9.5 14.4 21.9 14.6 34.4a112.6 112.6 0 0 0 112.2 112.1h.6c12 .4 24 5.1 33.2 14.1l.6.6a50 50 0 0 1-70.1 71.3l-.6-.6A49.9 49.9 0 0 1 182 230 112.6 112.6 0 0 0 73.4 120.7h-.8a49.9 49.9 0 0 1-36.7-14l-.5-.6a50 50 0 0 1-.6-70.2l.6-.5a50 50 0 0 1 69.5-1.2l.6.6Z",times:{T0:m,T1:h,T2:g,T3:v},total:d}),p.jsx(t2,{cx:70.3,cy:232.3,r:50,times:{T0:m,T1:h,T2:g,T3:v},total:d}),p.jsx(t2,{cx:232.3,cy:70.3,r:50,times:{T0:m,T1:h,T2:g,T3:v},total:d})]})]})}),t==="expanded"&&p.jsxs("div",{className:"font-ubuntu flex flex-col items-start -space-y-1 mr-3",children:[p.jsx("h1",{className:"text-xl font-medium",children:"mcp-use"}),p.jsx("span",{className:"text-lg text-muted-foreground tracking-wide font-sans font-light",children:"Inspector"})]})]})}function z_e({d:e,times:t,total:n}){const{T0:a,T1:r,T2:i,T3:s}=t;return p.jsx(ma.path,{d:e,variants:{rest:{pathLength:0,opacity:0},hover:{pathLength:[0,0,1,1],opacity:[0,0,1,1],transition:{duration:n,times:[a,r,i,s],ease:"easeInOut"}}}})}function t2({cx:e,cy:t,r:n,times:a,total:r}){const{T0:i,T1:s,T2:c,T3:u}=a;return p.jsx(ma.circle,{cx:e,cy:t,r:n,variants:{rest:{pathLength:0,opacity:0},hover:{pathLength:[0,0,1,1],opacity:[0,0,1,1],transition:{duration:r,times:[i,s,c,u],ease:"easeInOut"}}}})}function tZ({ref:e,shimmerColor:t,shimmerSize:n="0.05em",shimmerDuration:a="3s",borderRadius:r="100px",background:i,className:s,children:c,...u}){const{resolvedTheme:d}=Ry(),m=d==="dark"?"#000000":"#ffffff",h=d==="dark"?"rgba(255, 255, 255, 1)":"rgba(0, 0, 0, 1)",g=t||m,v=i||h;return p.jsxs("button",{style:{"--spread":"90deg","--shimmer-color":g,"--radius":r,"--speed":a,"--cut":n,"--bg":v},className:De("group relative z-0 flex cursor-pointer items-center justify-center overflow-hidden [border-radius:var(--radius)] border px-6 py-3 whitespace-nowrap [background:var(--bg)]","transform-gpu transition-transform duration-300 ease-in-out active:translate-y-px",d==="dark"?"border-black/10 text-black":"border-white/10 text-white",s),ref:e,...u,children:[p.jsx("div",{className:De("-z-30 blur-[2px]","[container-type:size] absolute inset-0 overflow-visible"),children:p.jsx("div",{className:"animate-shimmer-slide absolute inset-0 [aspect-ratio:1] h-[100cqh] [border-radius:0] [mask:none]",children:p.jsx("div",{className:"animate-spin-around absolute -inset-full w-auto [translate:0_0] rotate-0 [background:conic-gradient(from_calc(270deg-(var(--spread)*0.5)),transparent_0,var(--shimmer-color)_var(--spread),transparent_var(--spread))]"})})}),c,p.jsx("div",{className:De("absolute inset-0 size-full","rounded-2xl px-4 py-1.5 text-sm font-medium","transform-gpu transition-all duration-300 ease-in-out",d==="dark"?"shadow-[inset_0_-8px_10px_#0000001f] group-hover:shadow-[inset_0_-6px_10px_#0000003f] group-active:shadow-[inset_0_-10px_10px_#0000003f]":"shadow-[inset_0_-8px_10px_#ffffff1f] group-hover:shadow-[inset_0_-6px_10px_#ffffff3f] group-active:shadow-[inset_0_-10px_10px_#ffffff3f]")}),p.jsx("div",{className:De("absolute [inset:var(--cut)] -z-20 [border-radius:var(--radius)] [background:var(--bg)]")})]})}tZ.displayName="ShimmerButton";function n2({status:e}){const t=i=>{switch(i){case"ready":return{color:"bg-emerald-500",ringColor:"ring-emerald-500",tooltip:"Connected"};case"failed":return{color:"bg-red-500",ringColor:"ring-red-500",tooltip:"Failed"};default:return{color:"bg-yellow-500",ringColor:"ring-yellow-500",tooltip:i}}},{color:n,ringColor:a,tooltip:r}=t(e);return p.jsxs(en,{children:[p.jsx(tn,{asChild:!0,children:p.jsxs("div",{className:"relative",children:[p.jsx("div",{className:`absolute w-2 h-2 rounded-full ${a} animate-ping`}),p.jsx("div",{className:`relative w-2 h-2 rounded-full ${n}`})]})}),p.jsx(nn,{children:p.jsx("p",{children:r})})]})}function r2({connections:e,selectedServer:t,onServerSelect:n,onOpenConnectionOptions:a,mobileMode:r=!1}){const i=Xu(),s=c=>{const u=e.find(d=>d.id===c);if(!u||u.state!=="ready"){Qt.error("Server is not connected and cannot be inspected");return}n(c)};return r?p.jsx("div",{className:"flex items-center gap-2",children:p.jsx("div",{className:"relative",children:p.jsxs(Qx,{children:[p.jsx(eE,{asChild:!0,children:p.jsxs(Ue,{variant:"ghost",className:"h-11 px-2 bg-black dark:bg-white text-white dark:text-black border-black dark:border-white hover:bg-gray-800 dark:hover:bg-zinc-100 hover:border-gray-800 dark:hover:border-zinc-200 flex items-center gap-1.5",children:[t?p.jsx(wl,{serverUrl:t.url,serverName:t.name,size:"md"}):p.jsx(Dpe,{className:"h-5 w-5"}),p.jsx(Vl,{className:"h-4 w-4"})]})}),p.jsxs(Lb,{className:"w-[calc(100vw-2rem)] sm:w-[300px]",align:"start",children:[p.jsx(tE,{className:"cursor-pointer hover:bg-zinc-100 dark:hover:bg-zinc-800",onClick:()=>i("/"),children:"MCP Servers"}),p.jsx(Sf,{}),e.length===0?p.jsx("div",{className:"px-2 py-4 text-sm text-muted-foreground dark:text-zinc-400 text-center",children:"No servers connected. Go to the dashboard to add one."}):e.map(c=>p.jsxs(So,{onClick:()=>s(c.id),className:"flex items-center gap-3",children:[p.jsx(wl,{serverUrl:c.url,serverName:c.name,size:"sm"}),p.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[p.jsx("div",{className:"font-medium",children:c.name}),p.jsx(n2,{status:c.state})]}),p.jsx(Ue,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 hover:bg-zinc-100 dark:hover:bg-zinc-800",onClick:u=>{u.stopPropagation(),a(c.id)},children:p.jsx(uu,{className:"h-3 w-3"})})]},c.id)),p.jsx(Sf,{}),p.jsx(So,{onClick:()=>i("/"),children:p.jsx("span",{className:"text-blue-600 dark:text-blue-400",children:"+ Add new server"})})]})]})})}):p.jsx("div",{className:"flex items-center gap-2",children:p.jsx("div",{className:"relative",children:p.jsxs(Qx,{children:[p.jsx(eE,{asChild:!0,children:p.jsxs(tZ,{className:De("min-w-0 sm:min-w-[200px] p-0 px-1 text-sm h-11 justify-start bg-black dark:bg-white text-white dark:text-black border-black dark:border-white hover:bg-gray-800 dark:hover:bg-zinc-100 hover:border-gray-800 dark:hover:border-zinc-200",!t&&"pl-4",t&&"pr-10"),children:[t&&p.jsx(wl,{serverUrl:t.url,serverName:t.name,size:"md",className:"mr-2"}),p.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[p.jsx("span",{className:"truncate",children:t?t.name:"Select server to inspect"}),t&&p.jsx("div",{className:"flex items-center gap-2",children:t.error&&t.state!=="ready"?p.jsxs(en,{children:[p.jsx(tn,{asChild:!0,children:p.jsx("button",{onClick:c=>{c.stopPropagation()},className:"w-2 h-2 rounded-full bg-rose-500 animate-status-pulse-red hover:bg-rose-600 transition-colors",title:"Click to copy error message","aria-label":"Copy error message to clipboard"})}),p.jsx(nn,{children:p.jsx("p",{className:"max-w-xs",children:t.error})})]}):p.jsx("div",{className:`w-2 h-2 rounded-full ${t.state==="ready"?"bg-emerald-600 animate-status-pulse":t.state==="failed"?"bg-rose-600 animate-status-pulse-red":"bg-yellow-500 animate-status-pulse-yellow"}`})})]})]})}),t&&p.jsxs(en,{children:[p.jsx(tn,{asChild:!0,children:p.jsx("button",{type:"button",onClick:()=>{a(t.id)},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1.5 hover:bg-white/10 dark:hover:bg-black/10 rounded-full transition-colors text-white dark:text-black","aria-label":"Edit connection settings",children:p.jsx(uu,{className:"h-4 w-4"})})}),p.jsx(nn,{children:p.jsx("p",{children:"Edit connection settings"})})]}),p.jsxs(Lb,{className:"w-[calc(100vw-2rem)] sm:w-[300px]",align:"start",children:[p.jsx(tE,{className:"cursor-pointer hover:bg-zinc-100 dark:hover:bg-zinc-800",onClick:()=>i("/"),children:"MCP Servers"}),p.jsx(Sf,{}),e.length===0?p.jsx("div",{className:"px-2 py-4 text-sm text-muted-foreground dark:text-zinc-400 text-center",children:"No servers connected. Go to the dashboard to add one."}):e.map(c=>p.jsxs(So,{onClick:()=>s(c.id),className:"flex items-center gap-3",children:[p.jsx(wl,{serverUrl:c.url,serverName:c.name,size:"sm"}),p.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[p.jsx("div",{className:"font-medium",children:c.name}),p.jsx(n2,{status:c.state})]}),p.jsx(Ue,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 hover:bg-zinc-100 dark:hover:bg-zinc-800",onClick:u=>{u.stopPropagation(),a(c.id)},children:p.jsx(uu,{className:"h-3 w-3"})})]},c.id)),p.jsx(Sf,{}),p.jsx(So,{onClick:()=>i("/"),children:p.jsx("span",{className:"text-blue-600 dark:text-blue-400",children:"+ Add new server"})})]})]})})})}const a2=[{id:"tools",label:"Tools",icon:Dl},{id:"prompts",label:"Prompts",icon:ip},{id:"resources",label:"Resources",icon:ape},{id:"chat",label:"Chat",icon:gpe},{id:"sampling",label:"Sampling",icon:z9},{id:"notifications",label:"Notifications",icon:JT}];function i2(e,t){return e==="tools"?t.tools.length:e==="prompts"?t.prompts.length:e==="resources"?t.resources.length:e==="sampling"?t.pendingSamplingRequests.length:e==="notifications"?t.unreadNotificationCount:0}function F_e({connections:e,selectedServer:t,activeTab:n,onServerSelect:a,onTabChange:r,onCommandPaletteOpen:i,onOpenConnectionOptions:s}){const{tunnelUrl:c}=ld(),u=t&&c,[d,m]=x.useState(!1),h=async()=>{if(c)try{await navigator.clipboard.writeText(`${c}/mcp`),m(!0),Qt.success("Tunnel URL copied to clipboard"),setTimeout(()=>m(!1),2e3)}catch{Qt.error("Failed to copy URL")}};return p.jsxs("header",{className:"w-full mx-auto",children:[p.jsxs("div",{className:"flex lg:hidden flex-col gap-3",children:[p.jsxs("div",{className:"flex items-center justify-between w-full",children:[p.jsx("div",{className:"flex-1 flex justify-start",children:p.jsx(r2,{connections:e,selectedServer:t,onServerSelect:a,onOpenConnectionOptions:s,mobileMode:!0})}),p.jsx("div",{className:"flex-shrink-0 flex justify-center",children:p.jsx("div",{className:"scale-150",children:p.jsx(e2,{state:"collapsed"})})}),p.jsxs("div",{className:"flex-1 flex justify-end items-center gap-2",children:[p.jsxs(en,{children:[p.jsx(tn,{asChild:!0,children:p.jsx(Ue,{variant:"ghost",size:"sm",asChild:!0,children:p.jsx("a",{href:"https://github.com/mcp-use/mcp-use",target:"_blank",rel:"noopener noreferrer",className:"p-2","aria-label":"GitHub",children:p.jsx(J4,{className:"h-4 w-4"})})})}),p.jsx(nn,{children:p.jsx("p",{children:"Give us a star ⭐"})})]}),p.jsx(Q4,{className:"p-2 hover:bg-zinc-200 dark:hover:bg-zinc-800 rounded-full transition-colors cursor-pointer"})]})]}),t&&p.jsx("div",{className:"w-full",children:p.jsx(f_,{value:n,onValueChange:g=>r(g),children:p.jsx(p_,{className:"w-full justify-center",children:a2.map(g=>{const v=i2(g.id,t);return p.jsxs(m_,{value:g.id,icon:g.icon,className:"[&>svg]:mr-0 flex-1 flex-row gap-2 relative",children:[v>0&&p.jsx("span",{className:De(n===g.id?"dark:bg-black":"dark:bg-zinc-700","bg-zinc-200 text-zinc-700 dark:text-zinc-300 text-[10px] px-1.5 py-0.5 rounded-full font-medium"),children:v}),p.jsx("span",{className:"sr-only",children:g.label})]},g.id)})})})})]}),p.jsxs("div",{className:"hidden lg:flex items-center justify-between gap-3",children:[p.jsxs("div",{className:"flex items-center flex-wrap gap-2 md:space-x-6 space-x-2",children:[p.jsx(r2,{connections:e,selectedServer:t,onServerSelect:a,onOpenConnectionOptions:s}),t&&p.jsx(f_,{value:n,onValueChange:g=>r(g),children:p.jsx(p_,{className:"overflow-x-auto",children:a2.map(g=>{const v=i2(g.id,t);return p.jsx(m_,{value:g.id,icon:g.icon,className:"[&>svg]:mr-0 lg:[&>svg]:mr-2 relative",children:p.jsxs("div",{className:"items-center gap-2 hidden lg:flex",children:[g.label,v>0&&p.jsx("span",{className:De(n===g.id?" dark:bg-black ":"dark:bg-zinc-700","bg-zinc-200 text-zinc-700 dark:text-zinc-300 text-xs px-2 py-0.5 rounded-full font-medium"),children:v})]})},g.id)})})}),u&&p.jsxs(ZW,{children:[p.jsx(YW,{asChild:!0,children:p.jsxs("button",{className:"flex items-center gap-2 px-3 py-1.5 bg-gradient-to-r from-purple-500/10 to-pink-500/10 dark:from-purple-500/20 dark:to-pink-500/20 border border-purple-500/30 dark:border-purple-500/40 rounded-full hover:from-purple-500/20 hover:to-pink-500/20 dark:hover:from-purple-500/30 dark:hover:to-pink-500/30 transition-colors cursor-pointer",children:[p.jsx(op,{className:"size-4 text-purple-600 dark:text-purple-400 animate-pulse"}),p.jsx("span",{className:"text-xs font-medium text-purple-700 dark:text-purple-300 hidden lg:inline",children:"Tunnel"})]})}),p.jsx(ZN,{className:"w-[calc(100vw-2rem)] sm:w-96",align:"start",children:p.jsxs("div",{className:"space-y-4",children:[p.jsxs("div",{children:[p.jsxs("h4",{className:"font-semibold text-sm mb-2 flex items-center gap-2",children:[p.jsx(op,{className:"size-4 text-purple-600 dark:text-purple-400"}),"Tunnel URL"]}),p.jsxs("div",{className:"flex items-center gap-2 p-2 py-0 bg-muted rounded-full",children:[p.jsxs("code",{className:"flex-1 text-[10px] font-mono",children:[c,"/mcp"]}),p.jsx(Ue,{variant:"ghost",size:"sm",className:"h-7 px-2",onClick:h,children:d?p.jsx(La,{className:"size-3.5 text-green-600"}):p.jsx(Xr,{className:"size-3.5"})})]})]}),p.jsxs("div",{children:[p.jsx("h5",{className:"font-semibold text-sm mb-2",children:"Use in ChatGPT"}),p.jsxs("ol",{className:"space-y-2 text-xs text-muted-foreground",children:[p.jsxs("li",{className:"flex gap-2",children:[p.jsx("span",{className:"font-semibold text-foreground",children:"1."}),p.jsxs("span",{children:["Enable"," ",p.jsx("span",{className:"font-medium text-foreground",children:"dev mode"})," ","from settings"]})]}),p.jsxs("li",{className:"flex gap-2",children:[p.jsx("span",{className:"font-semibold text-foreground",children:"2."}),p.jsxs("span",{children:["In"," ",p.jsx("span",{className:"font-medium text-foreground",children:"App & Connectors"})," ","click on"," ",p.jsx("span",{className:"font-medium text-foreground",children:"create"})]})]}),p.jsxs("li",{className:"flex gap-2",children:[p.jsx("span",{className:"font-semibold text-foreground",children:"3."}),p.jsx("span",{children:"Use the tunnel URL in the input"})]})]})]})]})})]})]}),p.jsxs("div",{className:"flex items-center gap-2 sm:gap-4 flex-shrink-0",children:[p.jsxs(en,{children:[p.jsx(tn,{children:p.jsx(Q4,{className:"p-2 hover:bg-zinc-200 dark:hover:bg-zinc-800 rounded-full transition-colors cursor-pointer"})}),p.jsx(nn,{children:p.jsx("p",{children:"Toggle theme"})})]}),p.jsxs(en,{children:[p.jsx(tn,{asChild:!0,children:p.jsxs(Ue,{variant:"ghost",className:"hover:bg-zinc-200 dark:hover:bg-zinc-800 rounded-full px-1 -mx-3 flex gap-1",onClick:i,children:[p.jsx(Ffe,{className:"size-4"}),p.jsx("span",{className:"text-base font-mono hidden sm:inline",children:"K"})]})}),p.jsx(nn,{children:p.jsx("p",{children:"Command Palette"})})]}),p.jsxs(en,{children:[p.jsx(tn,{asChild:!0,children:p.jsx(Ue,{variant:"ghost",size:"sm",asChild:!0,children:p.jsxs("a",{href:"https://github.com/mcp-use/mcp-use",className:"flex items-center gap-2",target:"_blank",rel:"noopener noreferrer",children:[p.jsx(J4,{className:"h-4 w-4"}),p.jsx("span",{className:"hidden sm:inline",children:"Github"})]})})}),p.jsx(nn,{children:p.jsx("p",{children:"Give us a star ⭐"})})]}),p.jsx(e2,{state:"expanded"})]})]})]})}function B_e({children:e}){const t=Xu(),n=Po(),{connections:a,addConnection:r,removeConnection:i,updateConnectionConfig:s,configLoaded:c}=qT(),{selectedServerId:u,setSelectedServerId:d,activeTab:m,setActiveTab:h,navigateToItem:g,setTunnelUrl:v}=ld(),[w,S]=x.useState(!1),[y,_]=x.useState(null),E=cwe();x.useEffect(()=>{const Y=new URLSearchParams(n.search).get("tunnelUrl");v(Y)},[n.search,v]),x.useEffect(()=>{const V=z=>{const re=z.detail.requestId;u&&g(u,"sampling",re)},Y=z=>{const re=z.detail.toolName;u&&re?g(u,"tools",re):u&&h("tools")};return window.addEventListener("navigate-to-sampling",V),window.addEventListener("navigate-to-tool-result",Y),()=>{window.removeEventListener("navigate-to-sampling",V),window.removeEventListener("navigate-to-tool-result",Y)}},[u,h,g]);const k=x.useRef(null),C=x.useRef(null),R=x.useRef(null),{isAutoConnecting:A}=lwe({connections:a,addConnection:r,removeConnection:i,configLoaded:c}),I=x.useCallback(V=>{br.getInstance().capture(new afe({trigger:V})).catch(()=>{}),S(!0)},[]),O=V=>{const Y=a.find($=>$.id===V);if(!Y||Y.state!=="ready"){Qt.error("Server is not connected and cannot be inspected");return}d(V);const te=new URLSearchParams(n.search).get("tunnelUrl"),re=te?`/?server=${encodeURIComponent(V)}&tunnelUrl=${encodeURIComponent(te)}`:`/?server=${encodeURIComponent(V)}`;t(re)},j=x.useCallback(V=>{_(V)},[]),F=x.useCallback(V=>{y&&(V.url!==y?(i(y),r(V.url,V.name,V.proxyConfig,V.transportType)):s(y,{name:V.name,proxyConfig:V.proxyConfig,transportType:V.transportType}),_(null),Qt.success("Connection settings updated"))},[y,i,r,s]),H=(V,Y,z)=>{if(console.warn("[Layout] handleCommandPaletteNavigate called:",{tab:V,itemName:Y,serverId:z}),z){const te=a.find(U=>U.id===z);if(console.warn("[Layout] Server lookup:",{serverId:z,serverFound:!!te,serverState:te?.state}),!te||te.state!=="ready"){console.warn("[Layout] Server not ready, showing error"),Qt.error("Server is not connected and cannot be inspected");return}console.warn("[Layout] Calling navigateToItem:",{serverId:z,tab:V,itemName:Y}),g(z,V,Y);const $=new URLSearchParams(n.search).get("tunnelUrl"),B=$?`/?server=${encodeURIComponent(z)}&tunnelUrl=${encodeURIComponent($)}`:`/?server=${encodeURIComponent(z)}`;console.warn("[Layout] Navigating to:",B),t(B)}else console.warn("[Layout] No serverId, just updating tab to:",V),h(V)},K=a.find(V=>V.id===u),Q=K?K.tools.map(V=>({...V,_serverId:K.id})):a.flatMap(V=>V.state==="ready"?V.tools.map(Y=>({...Y,_serverId:V.id,_serverName:V.name})):[]),W=K?K.prompts.map(V=>({...V,_serverId:K.id})):a.flatMap(V=>V.state==="ready"?V.prompts.map(Y=>({...Y,_serverId:V.id,_serverName:V.name})):[]),ie=K?K.resources.map(V=>({...V,_serverId:K.id})):a.flatMap(V=>V.state==="ready"?V.resources.map(Y=>({...Y,_serverId:V.id,_serverName:V.name})):[]);return x.useEffect(()=>{const Y=new URLSearchParams(n.search).get("server"),z=Y?decodeURIComponent(Y):null;z!==u&&d(z)},[n.search,u,d]),x.useEffect(()=>{const Y=new URLSearchParams(n.search).get("server");if(!Y)return;const z=decodeURIComponent(Y),te=a.find(re=>re.id===z);if(!te){const re=setTimeout(()=>t("/"),3e3);return()=>clearTimeout(re)}if(te.state==="failed"){const re=setTimeout(()=>t("/"),2e3);return()=>clearTimeout(re)}},[n.search,t,a]),xW({onCommandPalette:()=>I("keyboard"),onToolsTab:()=>{K&&h("tools")},onPromptsTab:()=>{K&&h("prompts")},onResourcesTab:()=>{K&&h("resources")},onChatTab:()=>{K&&h("chat")},onHome:()=>{t("/")},onFocusSearch:()=>{m==="tools"&&k.current?k.current.focusSearch():m==="prompts"&&C.current?C.current.focusSearch():m==="resources"&&R.current&&R.current.focusSearch()},onBlurSearch:()=>{m==="tools"&&k.current?k.current.blurSearch():m==="prompts"&&C.current?C.current.blurSearch():m==="resources"&&R.current&&R.current.blurSearch()}}),A?p.jsx("div",{className:"h-screen bg-white dark:bg-zinc-900 flex items-center justify-center",children:p.jsxs("div",{className:"flex flex-col items-center gap-4",children:[p.jsx(Lo,{className:"h-8 w-8 text-zinc-600 dark:text-zinc-400"}),p.jsx("p",{className:"text-sm text-zinc-600 dark:text-zinc-400",children:"Connecting to MCP server..."})]})}):p.jsx(L9,{children:p.jsxs("div",{className:"h-screen bg-[#f3f3f3] dark:bg-black flex flex-col px-2 py-2 sm:px-4 sm:py-4 gap-2 sm:gap-4",children:[p.jsx(F_e,{connections:a,selectedServer:K,activeTab:m,onServerSelect:O,onTabChange:h,onCommandPaletteOpen:()=>I("button"),onOpenConnectionOptions:j}),p.jsx("main",{className:"flex-1 w-full mx-auto bg-white dark:bg-black rounded-2xl border border-zinc-200 dark:border-zinc-700 p-0 overflow-auto",children:p.jsx(P_e,{selectedServer:K,activeTab:m,toolsSearchRef:k,promptsSearchRef:C,resourcesSearchRef:R,children:e})}),p.jsx(jwe,{isOpen:w,onOpenChange:S,tools:Q,prompts:W,resources:ie,savedRequests:E,connections:a,onNavigate:H,onServerSelect:O}),p.jsx(UG,{connection:y&&a.find(V=>V.id===y)||null,open:y!==null,onOpenChange:V=>{V||_(null)},onConnect:F})]})})}function H_e(){const[e,t]=x.useState("processing"),[n,a]=x.useState("");return x.useEffect(()=>{console.log("[OAuthCallback] Component mounted, handling authorization..."),console.log("[OAuthCallback] Current URL:",window.location.href),ST().then(()=>{console.log("[OAuthCallback] Authorization successful"),t("success")}).catch(r=>{console.error("[OAuthCallback] Authorization failed:",r),t("error"),a(r instanceof Error?r.message:String(r))})},[]),e==="processing"?p.jsx("div",{className:"h-screen w-full flex items-center justify-center bg-white dark:bg-zinc-900",children:p.jsxs("div",{className:"flex flex-col items-center gap-4",children:[p.jsx(As,{className:"h-8 w-8 animate-spin text-zinc-600 dark:text-zinc-400"}),p.jsx("p",{className:"text-sm text-zinc-600 dark:text-zinc-400",children:"Completing authentication..."})]})}):e==="error"?p.jsx("div",{className:"h-screen w-full flex items-center justify-center bg-white dark:bg-zinc-900",children:p.jsxs("div",{className:"max-w-md p-6",children:[p.jsx("h1",{className:"text-xl font-semibold text-red-600 dark:text-red-400 mb-2",children:"Authentication Error"}),p.jsx("p",{className:"text-sm text-zinc-600 dark:text-zinc-400 mb-4",children:n}),p.jsx("p",{className:"text-xs text-zinc-500 dark:text-zinc-500",children:"You can close this window and try again."})]})}):p.jsx("div",{className:"h-screen w-full flex items-center justify-center bg-white dark:bg-zinc-900",children:p.jsxs("div",{className:"max-w-md p-6",children:[p.jsx("h1",{className:"text-xl font-semibold text-green-600 dark:text-green-400 mb-2",children:"Authentication Successful!"}),p.jsx("p",{className:"text-sm text-zinc-600 dark:text-zinc-400",children:"Redirecting you back..."})]})})}var V_e=(e,t,n,a,r,i,s,c)=>{let u=document.documentElement,d=["light","dark"];function m(v){(Array.isArray(e)?e:[e]).forEach(w=>{let S=w==="class",y=S&&i?r.map(_=>i[_]||_):r;S?(u.classList.remove(...y),u.classList.add(i&&i[v]?i[v]:v)):u.setAttribute(w,v)}),h(v)}function h(v){c&&d.includes(v)&&(u.style.colorScheme=v)}function g(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}if(a)m(a);else try{let v=localStorage.getItem(t)||n,w=s&&v==="system"?g():v;m(w)}catch{}},G_e=x.createContext(void 0),W_e={setTheme:e=>{},themes:[]},K_e=()=>{var e;return(e=x.useContext(G_e))!=null?e:W_e};x.memo(({forcedTheme:e,storageKey:t,attribute:n,enableSystem:a,enableColorScheme:r,defaultTheme:i,value:s,themes:c,nonce:u,scriptProps:d})=>{let m=JSON.stringify([n,t,i,e,c,s,a,r]).slice(1,-1);return x.createElement("script",{...d,suppressHydrationWarning:!0,nonce:typeof window>"u"?u:"",dangerouslySetInnerHTML:{__html:`(${V_e.toString()})(${m})`}})});function Z_e({...e}){const{theme:t="system"}=K_e();return p.jsx(G9,{theme:t,className:"toaster group",style:{"--normal-bg":"var(--popover)","--normal-text":"var(--popover-foreground)","--normal-border":"var(--border)"},...e})}function Y_e(){return p.jsx(kxe,{children:p.jsx(ufe,{children:p.jsxs(swe,{children:[p.jsx(coe,{basename:"/inspector",children:p.jsxs(zie,{children:[p.jsx(Hx,{path:"/oauth/callback",element:p.jsx(H_e,{})}),p.jsx(Hx,{path:"/",element:p.jsx(B_e,{children:p.jsx(owe,{})})})]})}),p.jsx(Z_e,{position:"top-center"})]})})})}const o2=new URLSearchParams(window.location.search);if(o2.has("code")||o2.has("error"))try{ST()}catch(e){console.error("[inspector] OAuth callback error:",e)}const s2=document.getElementById("root");s2?Yae.createRoot(s2).render(p.jsx(Y_e,{})):console.error("[inspector] Root element not found");export{v3 as $,p6 as A,f6 as B,_v as C,b6 as D,N5 as E,Fg as F,Oae as G,iP as H,ST as I,d2 as L,Nae as M,ue as R,Aae as W,kt as Z,Ge as _,Ar as a,Pp as b,qu as c,fx as d,q_e as e,mi as f,xp as g,px as h,ei as i,RB as j,$3 as k,E2 as l,T2 as m,NB as n,b3 as o,L2 as p,uee as q,x as r,z_ as s,KB as t,Oe as u,mee as v,C5 as w,gx as x,Pee as y,Wk as z};
1683
+ `),Ye.document.close())}},[w]),$e=x.useCallback(()=>{P?(ce.current&&ce.current.expand(),ae.current&&ae.current.expand(),G(!1)):(ce.current&&ce.current.collapse(),ae.current&&ae.current.collapse(),G(!0))},[P]),et=x.useCallback(()=>{s&&(Q(""),H(!0))},[s]),an=x.useCallback(()=>{if(!s)return;const Ae={id:`${Date.now()}-${Math.random()}`,name:K.trim()||`${s.name} - ${new Date().toLocaleString()}`,toolName:s.name,args:g,savedAt:Date.now(),serverId:s._serverId,serverName:s._serverName};_e([...O,Ae]),br.getInstance().capture(new ife({toolName:s.name,serverId:r})).catch(()=>{}),H(!1),Q("")},[s,K,g,O,_e,r]),Qe=x.useCallback(Ae=>{_e(O.filter(Ie=>Ie.id!==Ae)),u?.id===Ae&&d(null)},[O,_e,u]);return $?p.jsxs("div",{className:"h-full flex flex-col overflow-hidden relative bg-background",children:[U!=="list"&&p.jsxs("div",{className:"flex items-center gap-2 p-2 border-b shrink-0 bg-background z-10",children:[p.jsx(Ue,{variant:"ghost",size:"sm",onClick:()=>{U==="response"?L("detail"):(c(null),L("list"))},className:"p-0 h-8 w-8",children:p.jsx(QT,{className:"h-4 w-4"})}),p.jsxs("div",{className:"flex items-center text-sm font-medium",children:[p.jsx("button",{onClick:()=>{c(null),L("list")},className:"text-muted-foreground hover:text-foreground hover:underline cursor-pointer",children:"Tools"}),U==="detail"&&p.jsxs(p.Fragment,{children:[p.jsx("span",{className:"mx-2 text-muted-foreground",children:"/"}),p.jsx("button",{onClick:()=>{L("response")},className:U==="detail"?"text-foreground hover:underline":U==="response"?"text-muted-foreground hover:text-foreground hover:underline cursor-pointer":"text-muted-foreground",children:"Execute"})]}),U==="response"&&p.jsxs(p.Fragment,{children:[p.jsx("span",{className:"mx-2 text-muted-foreground",children:"/"}),p.jsx("span",{className:"text-foreground",children:"Response"})]})]})]}),p.jsx("div",{className:"flex-1 relative overflow-hidden",children:p.jsxs(ly,{initial:!1,mode:"popLayout",children:[U==="list"&&p.jsxs(ma.div,{initial:{x:"-100%"},animate:{x:0},exit:{x:"-100%"},transition:{type:"spring",stiffness:300,damping:30},className:"absolute inset-0 flex flex-col bg-background z-0",children:[p.jsx(X4,{activeTab:A,isSearchExpanded:V,searchQuery:C,filteredToolsCount:Se.length,savedRequestsCount:O.length,onSearchExpand:()=>Y(!0),onSearchChange:R,onSearchBlur:Le,onTabSwitch:()=>I(A==="tools"?"saved":"tools"),searchInputRef:re}),A==="tools"?p.jsx(Y4,{tools:Se,selectedTool:s,onToolSelect:ze,focusedIndex:z}):p.jsx(V4,{savedRequests:O,selectedRequest:u,onLoadRequest:pe,onDeleteRequest:Qe,focusedIndex:z})]},"list"),U==="detail"&&p.jsx(ma.div,{initial:{x:"100%"},animate:{x:0},exit:{x:"-100%"},transition:{type:"spring",stiffness:300,damping:30},className:"absolute inset-0 bg-background z-10",children:p.jsx(W4,{selectedTool:s,toolArgs:g,isExecuting:y,isConnected:i,onArgChange:Fe,onExecute:xe,onSave:et})},"detail"),U==="response"&&p.jsx(ma.div,{initial:{x:"100%"},animate:{x:0},exit:{x:"100%"},transition:{type:"spring",stiffness:300,damping:30},className:"absolute inset-0 bg-background z-20",children:p.jsx(Z4,{results:pt,copiedResult:E,previewMode:W,serverId:r,readResource:a,onCopy:st,onDelete:at,onFullscreen:Pe,onTogglePreview:()=>ie(!W)})},"response")]})}),p.jsx(G4,{isOpen:F,requestName:K,defaultPlaceholder:`${s?.name} - ${new Date().toLocaleString()}`,onRequestNameChange:Q,onSave:an,onCancel:()=>H(!1)})]}):p.jsxs(Da,{direction:"horizontal",className:"h-full",children:[p.jsx(zn,{ref:ce,defaultSize:33,collapsible:!0,className:"flex flex-col h-full relative",children:p.jsxs(Da,{direction:"vertical",className:"h-full border-r dark:border-zinc-700",children:[p.jsx(zn,{defaultSize:75,minSize:30,children:p.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[p.jsx(X4,{activeTab:A,isSearchExpanded:V,searchQuery:C,filteredToolsCount:Se.length,savedRequestsCount:O.length,onSearchExpand:()=>Y(!0),onSearchChange:R,onSearchBlur:Le,onTabSwitch:()=>I(A==="tools"?"saved":"tools"),searchInputRef:re}),A==="tools"?p.jsx(Y4,{tools:Se,selectedTool:s,onToolSelect:ze,focusedIndex:z}):p.jsx(V4,{savedRequests:O,selectedRequest:u,onLoadRequest:pe,onDeleteRequest:Qe,focusedIndex:z})]})}),p.jsx(Ui,{withHandle:!0}),p.jsxs(zn,{ref:ke,defaultSize:0,collapsible:!0,minSize:5,collapsedSize:5,onCollapse:()=>{le(!0)},onExpand:()=>{le(!1)},className:"flex flex-col border-t dark:border-zinc-700",children:[p.jsxs("div",{className:"group flex items-center justify-between p-3 shrink-0 cursor-pointer hover:bg-muted/50 transition-colors",onClick:Ae=>{Ae.preventDefault(),Ae.stopPropagation(),se?(ke.current?.resize(25),le(!1)):(ke.current?.resize(5),le(!0))},children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx("h3",{className:"text-sm font-medium",children:"RPC Messages"}),Z>0&&p.jsx(Jr,{variant:"secondary",className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",children:Z}),Z>0&&!se&&p.jsx(Ue,{variant:"ghost",size:"sm",onClick:Ae=>{Ae.preventDefault(),Ae.stopPropagation(),Be.current?.()},className:"h-6 w-6 p-0",title:"Clear all messages",children:p.jsx(Is,{className:"h-3.5 w-3.5"})})]}),p.jsx(Vl,{className:`h-4 w-4 text-muted-foreground transition-transform ${se?"":"rotate-180"}`})]}),!se&&p.jsx("div",{className:"flex-1 overflow-hidden min-h-0",children:p.jsx(TO,{serverIds:[r],onCountChange:J,onClearRef:Be})})]})]})}),p.jsx(Ui,{withHandle:!0}),p.jsx(zn,{defaultSize:67,children:p.jsxs(Da,{direction:"vertical",children:[p.jsx(zn,{ref:ae,defaultSize:40,collapsible:!0,children:p.jsx(W4,{selectedTool:s,toolArgs:g,isExecuting:y,isConnected:i,onArgChange:Fe,onExecute:xe,onSave:et})}),p.jsx(Ui,{withHandle:!0}),p.jsx(zn,{ref:ye,defaultSize:60,children:p.jsx("div",{className:"flex flex-col h-full",children:p.jsx(Z4,{results:pt,copiedResult:E,previewMode:W,serverId:r,readResource:a,onCopy:st,onDelete:at,onFullscreen:Pe,onTogglePreview:()=>ie(!W),onMaximize:$e,isMaximized:P})})})]})}),p.jsx(G4,{isOpen:F,requestName:K,defaultPlaceholder:`${s?.name} - ${new Date().toLocaleString()}`,onRequestNameChange:Q,onSave:an,onCancel:()=>H(!1)})]})}qK.displayName="ToolsTab";function D_e({isSearchExpanded:e,searchQuery:t,filteredRequestsCount:n,requestsCount:a,onSearchExpand:r,onSearchChange:i,onSearchBlur:s,onRejectAll:c,searchInputRef:u}){return p.jsxs("div",{className:"flex flex-row items-center justify-between p-4 sm:p-4 py-3 gap-2",children:[p.jsx("div",{className:"flex items-center gap-2 flex-1",children:e?p.jsx(jn,{ref:u,placeholder:"Search requests...",value:t,onChange:d=>i(d.target.value),onBlur:s,className:"h-8 border-gray-300 dark:border-zinc-600"}):p.jsxs(p.Fragment,{children:[p.jsx("h2",{className:"text-lg font-medium text-gray-900 dark:text-gray-100",children:"Sampling"}),p.jsx(Jr,{className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",variant:"outline",children:n}),p.jsxs(en,{children:[p.jsx(tn,{asChild:!0,children:p.jsx(Ue,{variant:"ghost",size:"sm",onClick:r,className:"h-8 w-8 p-0",children:p.jsx(qp,{className:"h-4 w-4"})})}),p.jsxs(nn,{side:"bottom",className:"flex gap-2",children:["Search",p.jsx($y,{children:"F"})]})]})]})}),p.jsx("div",{className:"flex items-center gap-2",children:p.jsxs(en,{children:[p.jsx(tn,{asChild:!0,children:p.jsx(Ue,{variant:"ghost",size:"sm",onClick:c,disabled:a===0,className:"h-8 w-8 p-0",children:p.jsx(Is,{className:"h-4 w-4"})})}),p.jsx(nn,{side:"bottom",children:"Reject all"})]})})]})}function L_e({requests:e,selectedRequest:t,onRequestSelect:n,focusedIndex:a,formatRelativeTime:r,listRef:i}){return e.length===0?p.jsx("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:p.jsx(Yp,{vertical:!0,noBorder:!0,message:"No sampling requests"})}):p.jsx("div",{ref:i,className:"overflow-y-auto flex-1 overscroll-contain",children:e.map((s,c)=>{const u=s.request.params?.messages?.length||0,d=s.request.params?.maxTokens;return p.jsx(Xl,{id:`sampling-request-${s.id}`,isSelected:t?.id===s.id,isFocused:a===c,title:p.jsxs("span",{className:"flex items-center gap-3",children:[s.serverName,p.jsx("span",{className:"size-1.5 block rounded-full bg-orange-500"})]}),description:(()=>{const m=r(s.timestamp),h=[];u>0&&h.push(`${u} message${u>1?"s":""}`),d&&h.push(`max ${d} tokens`);const g=h.length>0?` | ${h.join(", ")}`:"";return m+g})(),onClick:()=>n(s)},s.id)})})}function $_e({llmConfig:e}){const t=x.useRef(null);return{generateResponse:x.useCallback(async({request:a})=>{if(!e)throw new Error("LLM config is not available");const r=a.params||{},i=r.maxTokens,s=r.temperature;r.modelPreferences;const c=r.messages||[];if(console.log("[useSamplingLLM] Request structure:",{hasParams:!!r,messagesCount:c.length,messages:c,params:r}),c.length===0)throw new Error("No messages found in sampling request");const u=[],{HumanMessage:d,AIMessage:m}=await Ar(async()=>{const{HumanMessage:w,AIMessage:S}=await import("./index-Ce878vOP.js").then(y=>y.bD);return{HumanMessage:w,AIMessage:S}},[]);for(const w of c){if(!w||!w.role){console.warn("Skipping invalid message:",w);continue}const S=Array.isArray(w.content)?w.content[0]:w.content;if(!S){console.warn("Skipping message with no content:",w);continue}S.type==="text"&&S.text?w.role==="user"?u.push(new d(S.text)):w.role==="assistant"&&u.push(new m(S.text)):console.warn("Skipping message with unsupported content type:",S)}if(u.length===0)throw new Error("No valid messages could be converted. Please ensure messages have 'text' content type.");if(!t.current||t.current.provider!==e.provider||t.current.model!==e.model||t.current.apiKey!==e.apiKey){let w;const S={model:e.model,apiKey:e.apiKey};if(i!==void 0&&(S.maxTokens=i),s!==void 0?S.temperature=s:e.temperature!==void 0&&(S.temperature=e.temperature),e.provider==="openai"){const{ChatOpenAI:y}=await Ar(async()=>{const{ChatOpenAI:_}=await import("./index-eSg28oTZ.js");return{ChatOpenAI:_}},__vite__mapDeps([5,6,7,3,8,9]));w=new y(S)}else if(e.provider==="anthropic"){const{ChatAnthropic:y}=await Ar(async()=>{const{ChatAnthropic:_}=await import("./index-BWh1LT8v.js");return{ChatAnthropic:_}},__vite__mapDeps([10,7,6,3]));w=new y(S)}else if(e.provider==="google"){const{ChatGoogleGenerativeAI:y}=await Ar(async()=>{const{ChatGoogleGenerativeAI:_}=await import("./index-C0sILan8.js");return{ChatGoogleGenerativeAI:_}},__vite__mapDeps([11,7,6,3,9]));w=new y(S)}else throw new Error(`Unsupported LLM provider: ${e.provider}`);t.current={instance:w,provider:e.provider,model:e.model,apiKey:e.apiKey}}const h=await t.current.instance.invoke(u);return{role:"assistant",content:{type:"text",text:h.content||h.text||""},model:e.model,stopReason:"endTurn"}},[e]),isAvailable:e!==null}}function j_e({request:e,onApprove:t,onReject:n,onClose:a,previewMode:r,onTogglePreview:i,isCopied:s,onCopy:c,onDownload:u,onFullscreen:d,llmConfig:m}){const[h,g]=x.useState("manual"),[v,w]=x.useState("stub-model"),[S,y]=x.useState("endTurn"),[_,E]=x.useState("assistant"),[k,C]=x.useState("text"),[R,A]=x.useState("positive"),[I,O]=x.useState(""),[j,F]=x.useState("image/png"),[H,K]=x.useState(!1),[Q,W]=x.useState(null),{generateResponse:ie,isAvailable:V}=$_e({llmConfig:m});x.useEffect(()=>{e&&(w("stub-model"),y("endTurn"),E("assistant"),C("text"),A("positive"),O(""),F("image/png"),W(null))},[e?.id]);const Y=async()=>{if(!(!e||!V)){K(!0),W(null);try{const $=await ie({request:e.request});w($.model||m?.model||"stub-model"),y($.stopReason||"endTurn"),E($.role||"assistant");const B=Array.isArray($.content)?$.content[0]:$.content;B.type==="text"?(C("text"),A(B.text||"")):B.type==="image"&&(C("image"),O(B.data||""),F(B.mimeType||"image/png"))}catch($){const B=$ instanceof Error?$.message:"Failed to generate response";W(B),Qt.error("LLM Generation Failed",{description:B})}finally{K(!1)}}},z=x.useMemo(()=>{const $={model:v,stopReason:S,role:_,content:{type:k}};return k==="text"?$.content.text=R:k==="image"&&($.content.data=I,$.content.mimeType=j),$},[v,S,_,k,R,I,j]),te=()=>{if(!e)return;const $=pT.safeParse(z);if(!$.success){Qt.error("Invalid response",{description:`Validation failed: ${$.error.message}`});return}t(e.id,$.data),a(),Ar(()=>Promise.resolve().then(()=>Pp),void 0).then(B=>{const U=Qt(B.createElement("div",{className:"space-y-3"},B.createElement("div",null,B.createElement("strong",null,"Sampling Response Sent"),B.createElement("p",{className:"text-sm text-muted-foreground mt-1"},"The tool will continue executing.")),B.createElement("div",{className:"flex gap-2"},B.createElement("button",{className:"px-3 py-1.5 text-xs font-medium rounded-md bg-primary text-primary-foreground hover:bg-primary/90",onClick:()=>{const L=new globalThis.CustomEvent("navigate-to-tool-result",{detail:{toolName:e.toolName}});window.dispatchEvent(L),Qt.dismiss(U)}},"View Tool Result"))),{duration:5e3})})},re=()=>{e&&(n(e.id,"User rejected sampling request"),a())};return e?p.jsxs("div",{className:"flex flex-col h-full",children:[p.jsxs("div",{className:"flex items-center justify-between p-4 border-b dark:border-zinc-700",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx("h3",{className:"font-medium text-gray-900 dark:text-gray-100",children:e.serverName}),p.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:new Date(e.timestamp).toLocaleString()})]}),p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsxs(en,{children:[p.jsx(tn,{asChild:!0,children:p.jsx(Ue,{variant:"ghost",size:"sm",onClick:c,className:"h-8 w-8 p-0",children:s?p.jsx(La,{className:"h-4 w-4 text-green-600"}):p.jsx(Xr,{className:"h-4 w-4"})})}),p.jsx(nn,{children:"Copy request"})]}),p.jsxs(en,{children:[p.jsx(tn,{asChild:!0,children:p.jsx(Ue,{variant:"ghost",size:"sm",onClick:u,className:"h-8 w-8 p-0",children:p.jsx(ny,{className:"h-4 w-4"})})}),p.jsx(nn,{children:"Download request"})]}),p.jsxs(en,{children:[p.jsx(tn,{asChild:!0,children:p.jsx(Ue,{variant:"ghost",size:"sm",onClick:d,className:"h-8 w-8 p-0",children:p.jsx(B9,{className:"h-4 w-4"})})}),p.jsx(nn,{children:"Fullscreen"})]}),p.jsx(Ue,{variant:"ghost",size:"sm",onClick:a,className:"h-8 w-8 p-0",children:p.jsx(Gl,{className:"h-4 w-4"})})]})]}),p.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-6",children:[p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:"Request"}),p.jsx("div",{className:"bg-muted rounded-lg p-3 max-h-64 overflow-auto",children:p.jsx(ir,{data:e.request})})]}),p.jsxs("div",{className:"space-y-4",children:[p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:"Response"}),p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(Yt,{htmlFor:`responseMode-${e.id}`,className:"text-xs text-gray-500 dark:text-gray-400",children:"Mode:"}),p.jsxs(Eo,{value:h,onValueChange:$=>g($),children:[p.jsx(ko,{id:`responseMode-${e.id}`,className:"w-32 h-8 text-xs",children:p.jsx(_o,{})}),p.jsxs(To,{children:[p.jsx(Rr,{value:"manual",children:"Manual"}),p.jsx(Rr,{value:"llm",children:"LLM"})]})]})]})]}),h==="llm"&&p.jsxs("div",{className:"space-y-2 p-3 bg-muted rounded-lg",children:[V?p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(Ue,{onClick:Y,disabled:H,size:"sm",className:"flex items-center gap-2",children:H?p.jsxs(p.Fragment,{children:[p.jsx(As,{className:"h-4 w-4 animate-spin"}),"Generating..."]}):p.jsxs(p.Fragment,{children:[p.jsx(Ppe,{className:"h-4 w-4"}),"Generate with LLM"]})}),p.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:["Using ",m?.provider," (",m?.model,")"]})]}):p.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:"LLM not configured. Please configure LLM in the Chat tab."}),Q&&p.jsx("div",{className:"text-xs text-red-600 dark:text-red-400",children:Q})]}),p.jsxs("div",{className:"space-y-2",children:[p.jsx(Yt,{htmlFor:`model-${e.id}`,children:"Model"}),p.jsx(jn,{id:`model-${e.id}`,value:v,onChange:$=>w($.target.value),placeholder:"stub-model",disabled:h==="llm"&&H})]}),p.jsxs("div",{className:"space-y-2",children:[p.jsx(Yt,{htmlFor:`stopReason-${e.id}`,children:"Stop Reason"}),p.jsx(jn,{id:`stopReason-${e.id}`,value:S,onChange:$=>y($.target.value),placeholder:"endTurn",disabled:h==="llm"&&H})]}),p.jsxs("div",{className:"space-y-2",children:[p.jsx(Yt,{htmlFor:`role-${e.id}`,children:"Role"}),p.jsxs(Eo,{value:_,onValueChange:$=>E($),disabled:h==="llm"&&H,children:[p.jsx(ko,{id:`role-${e.id}`,children:p.jsx(_o,{})}),p.jsxs(To,{children:[p.jsx(Rr,{value:"assistant",children:"assistant"}),p.jsx(Rr,{value:"user",children:"user"})]})]})]}),p.jsxs("div",{className:"space-y-2",children:[p.jsx(Yt,{htmlFor:`contentType-${e.id}`,children:"Content Type"}),p.jsxs(Eo,{value:k,onValueChange:$=>C($),disabled:h==="llm"&&H,children:[p.jsx(ko,{id:`contentType-${e.id}`,children:p.jsx(_o,{})}),p.jsxs(To,{children:[p.jsx(Rr,{value:"text",children:"text"}),p.jsx(Rr,{value:"image",children:"image"})]})]})]}),k==="text"&&p.jsxs("div",{className:"space-y-2",children:[p.jsx(Yt,{htmlFor:`text-${e.id}`,children:"Text Content"}),p.jsx(zu,{id:`text-${e.id}`,value:R,onChange:$=>A($.target.value),placeholder:"Enter response text...",rows:6,disabled:h==="llm"&&H})]}),k==="image"&&p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"space-y-2",children:[p.jsx(Yt,{htmlFor:`imageData-${e.id}`,children:"Base64 Image Data"}),p.jsx(zu,{id:`imageData-${e.id}`,value:I,onChange:$=>O($.target.value),placeholder:"Base64 encoded image data...",rows:4,disabled:h==="llm"&&H})]}),p.jsxs("div",{className:"space-y-2",children:[p.jsx(Yt,{htmlFor:`mimeType-${e.id}`,children:"MIME Type"}),p.jsx(jn,{id:`mimeType-${e.id}`,value:j,onChange:$=>F($.target.value),placeholder:"image/png",disabled:h==="llm"&&H})]})]})]})]}),p.jsxs("div",{className:"flex gap-2 p-4 border-t dark:border-zinc-700",children:[p.jsx(Ue,{onClick:te,className:"flex-1",disabled:h==="llm"&&H,children:"Approve"}),p.jsx(Ue,{onClick:re,variant:"outline",className:"flex-1",disabled:h==="llm"&&H,children:"Reject"})]})]}):p.jsx("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:p.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"Select a sampling request to view details"})})}function M_e({pendingRequests:e,onApprove:t,onReject:n,serverId:a,isConnected:r,mcpServerUrl:i}){const{selectedSamplingRequestId:s,setSelectedSamplingRequestId:c}=ld(),{llmConfig:u}=_K({mcpServerUrl:i}),[d,m]=x.useState(null),[h,g]=x.useState(""),[v,w]=x.useState(-1),[S,y]=x.useState(!0),[_,E]=x.useState(!1),[k,C]=x.useState(!0),[R,A]=x.useState(!1),I=x.useRef(null),O=x.useRef(null),j=x.useRef(null),F=x.useRef(!1);x.useEffect(()=>{if(console.log("[SamplingTab] Auto-selection check:",{selectedSamplingRequestId:s,pendingRequestsCount:e.length,currentSelectedId:d?.id}),s&&e.length>0){const z=e.find(te=>te.id===s);console.log("[SamplingTab] Found request for auto-selection:",!!z,z?.id),z&&(console.log("[SamplingTab] Auto-selecting request:",z.id),c(null),m(z),setTimeout(()=>{const te=document.getElementById(`sampling-request-${z.id}`);console.log("[SamplingTab] Scrolling to element:",!!te),te&&te.scrollIntoView({behavior:"smooth",block:"nearest"})},100))}},[s,e,c]),x.useEffect(()=>{const z=te=>{const $=te.detail.requestId;console.log("[SamplingTab] Custom navigate event received:",$);const B=e.find(U=>U.id===$);B&&(console.log("[SamplingTab] Selecting request from event:",$),m(B),setTimeout(()=>{const U=document.getElementById(`sampling-request-${$}`);U&&U.scrollIntoView({behavior:"smooth",block:"nearest"})},200))};return window.addEventListener("navigate-to-sampling",z),()=>window.removeEventListener("navigate-to-sampling",z)},[e]),x.useEffect(()=>{S&&e.length>0&&I.current&&!F.current&&(I.current.scrollTop=0)},[e.length,S]),x.useEffect(()=>{const z=I.current;if(!z)return;const te=()=>{z.scrollTop>0&&(F.current=!0,y(!1))};return z.addEventListener("scroll",te),()=>z.removeEventListener("scroll",te)},[]),x.useEffect(()=>{e.length===0&&(F.current=!1,y(!0))},[e.length]),x.useEffect(()=>{_&&j.current&&j.current.focus()},[_]);const H=x.useCallback(()=>{h.trim()||E(!1)},[h]),K=x.useMemo(()=>{if(!h.trim())return e;const z=h.toLowerCase();return e.filter(te=>te.serverName.toLowerCase().includes(z)||JSON.stringify(te.request||{}).toLowerCase().includes(z))},[e,h]);x.useEffect(()=>{w(-1)},[h]),x.useEffect(()=>{const z=te=>{const re=te.target;if(re.tagName==="INPUT"||re.tagName==="TEXTAREA"||re.contentEditable==="true"||te.metaKey||te.ctrlKey||te.altKey)return;const B=K;if(te.key==="ArrowDown")te.preventDefault(),w(U=>{const L=U+1;return L>=B.length?0:L});else if(te.key==="ArrowUp")te.preventDefault(),w(U=>{const L=U-1;return L<0?B.length-1:L});else if(te.key==="Enter"&&v>=0){te.preventDefault();const U=K[v];U&&Q(U)}};return document.addEventListener("keydown",z),()=>document.removeEventListener("keydown",z)},[v,K]),x.useEffect(()=>{if(v>=0){const z=`sampling-request-${K[v]?.id}`,te=document.getElementById(z);te&&te.scrollIntoView({behavior:"smooth",block:"nearest"})}},[v,K]);const Q=x.useCallback(z=>{m(z)},[]),W=x.useCallback(()=>{window.confirm("Are you sure you want to reject all sampling requests? This cannot be undone.")&&(e.forEach(z=>{n(z.id,"User rejected all requests")}),m(null))},[e,n]),ie=x.useCallback(async()=>{if(d)try{await navigator.clipboard.writeText(JSON.stringify({id:d.id,serverName:d.serverName,timestamp:d.timestamp,request:d.request},null,2)),A(!0),setTimeout(()=>A(!1),2e3)}catch(z){console.error("[SamplingTab] Failed to copy request:",z)}},[d]),V=x.useCallback(()=>{if(d)try{const z=new globalThis.Blob([JSON.stringify({id:d.id,serverName:d.serverName,timestamp:d.timestamp,request:d.request},null,2)],{type:"application/json"}),te=URL.createObjectURL(z),re=document.createElement("a");re.href=te,re.download=`sampling-request-${Date.now()}.json`,document.body.appendChild(re),re.click(),document.body.removeChild(re),URL.revokeObjectURL(te)}catch(z){console.error("[SamplingTab] Failed to download request:",z)}},[d]),Y=x.useCallback(async()=>{if(O.current)try{document.fullscreenElement?await document.exitFullscreen():await O.current.requestFullscreen()}catch(z){console.error("[SamplingTab] Failed to toggle fullscreen:",z)}},[]);return r?p.jsxs(Da,{direction:"horizontal",className:"h-full",children:[p.jsx(zn,{defaultSize:40,minSize:30,children:p.jsx(Da,{direction:"vertical",className:"h-full border-r dark:border-zinc-700",children:p.jsxs(zn,{defaultSize:75,minSize:30,children:[p.jsx(D_e,{isSearchExpanded:_,searchQuery:h,filteredRequestsCount:K.length,requestsCount:e.length,onSearchExpand:()=>E(!0),onSearchChange:g,onSearchBlur:H,onRejectAll:W,searchInputRef:j}),p.jsx("div",{className:"flex flex-col h-full",children:p.jsx(L_e,{requests:K,selectedRequest:d,onRequestSelect:Q,focusedIndex:v,formatRelativeTime:d_,listRef:I})})]})})}),p.jsx(Ui,{}),p.jsx(zn,{defaultSize:60,minSize:40,children:p.jsx("div",{ref:O,className:"h-full bg-white dark:bg-zinc-900",children:p.jsx(j_e,{request:d,onApprove:t,onReject:n,onClose:()=>m(null),previewMode:k,onTogglePreview:()=>C(!k),isCopied:R,onCopy:ie,onDownload:V,onFullscreen:Y,llmConfig:u})})})]}):p.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[p.jsx(z9,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),p.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"Not connected to server"})]})}function P_e({selectedServer:e,activeTab:t,toolsSearchRef:n,promptsSearchRef:a,resourcesSearchRef:r,children:i}){return e?p.jsxs(p.Fragment,{children:[p.jsx("div",{style:{display:t==="tools"?"block":"none"},className:"h-full",children:p.jsx(qK,{ref:n,tools:e.tools,callTool:e.callTool,readResource:e.readResource,serverId:e.id,isConnected:e.state==="ready"})}),p.jsx("div",{style:{display:t==="prompts"?"block":"none"},className:"h-full",children:p.jsx(KK,{ref:a,prompts:e.prompts,callPrompt:e.getPrompt,serverId:e.id,isConnected:e.state==="ready"})}),p.jsx("div",{style:{display:t==="resources"?"block":"none"},className:"h-full",children:p.jsx(YK,{ref:r,resources:e.resources,readResource:e.readResource,serverId:e.id,isConnected:e.state==="ready"})}),p.jsx("div",{style:{display:t==="chat"?"block":"none"},className:"h-full",children:p.jsx(WEe,{connection:e,isConnected:e.state==="ready",readResource:e.readResource},e.id)}),p.jsx("div",{style:{display:t==="sampling"?"block":"none"},className:"h-full",children:p.jsx(M_e,{pendingRequests:e.pendingSamplingRequests,onApprove:e.approveSampling,onReject:e.rejectSampling,serverId:e.id,isConnected:e.state==="ready",mcpServerUrl:e.url})}),p.jsx("div",{style:{display:t==="notifications"?"block":"none"},className:"h-full",children:p.jsx(__e,{notifications:e.notifications,unreadCount:e.unreadNotificationCount,markNotificationRead:e.markNotificationRead,markAllNotificationsRead:e.markAllNotificationsRead,clearNotifications:e.clearNotifications,serverId:e.id,isConnected:e.state==="ready"})}),t!=="tools"&&t!=="prompts"&&t!=="resources"&&t!=="chat"&&t!=="sampling"&&t!=="notifications"&&p.jsx(p.Fragment,{children:i})]}):p.jsx(p.Fragment,{children:i})}function J4({className:e}){return p.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentcolor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:e,children:[p.jsx("path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4"}),p.jsx("path",{d:"M9 18c-4.51 2-5-2-7-2"})]})}const JK=x.createContext(void 0);function QK(){const e=x.use(JK);if(!e)throw new Error("useTabs must be used within a TabsProvider");return e}const eZ=x.createContext(void 0);function U_e(){return x.use(eZ)}function f_({ref:e,children:t,defaultValue:n,value:a,onValueChange:r,className:i,...s}){const[c,u]=x.useState(n||""),d=a!==void 0,m=x.useCallback(g=>{d||u(g),r?.(g)},[d,r]),h=d?a:c;return p.jsx(JK,{value:{activeValue:h,handleValueChange:m},children:p.jsx("div",{ref:e,className:De("flex flex-col gap-2",i),...s,children:t})})}f_.displayName="Tabs";function p_({ref:e,children:t,className:n,variant:a="default",...r}){const{activeValue:i}=QK(),[s,c]=x.useState({width:0,left:0}),u=x.useRef(null),d=x.useRef(null),m=x.useRef(null),g=x.Children.toArray(t).findIndex(S=>x.isValidElement(S)&&S.props.value===i),v=x.useCallback(()=>{const S=u.current;if(!S)return;const _=S.querySelectorAll("button")[g];if(_){const E=S.getBoundingClientRect(),k=_.getBoundingClientRect();c({width:k.width,left:k.left-E.left})}},[g]),w=x.useCallback(()=>{m.current&&clearTimeout(m.current),m.current=setTimeout(v,16)},[v]);return x.useEffect(()=>{const S=setTimeout(v,10);return()=>clearTimeout(S)},[v]),x.useEffect(()=>{const S=u.current;return S?(d.current=new ResizeObserver(()=>{w()}),d.current.observe(S),S.querySelectorAll("button").forEach(_=>{d.current&&d.current.observe(_)}),()=>{d.current&&d.current.disconnect(),m.current&&clearTimeout(m.current)}):void 0},[w]),x.useEffect(()=>{const S=()=>{w()};return window.addEventListener("resize",S),()=>window.removeEventListener("resize",S)},[w]),x.useEffect(()=>{const S=u.current;if(!S)return;const y=S.querySelector("[data-width]");y&&(y.style.width=`${s.width}px`,y.style.left=`${s.left}px`)},[s]),p.jsx(eZ,{value:{variant:a},children:p.jsxs("div",{ref:u,className:De("relative flex bg-none",a==="default"&&"p-1 rounded-full border border-zinc-300 dark:border-zinc-600",a==="underline"&&"border-b border-zinc-200 dark:border-zinc-700",n),...r,children:[t,p.jsx("span",{className:De("absolute transition-all duration-200 ease-out z-0",a==="default"&&"bg-white dark:bg-zinc-700 rounded-full h-[calc(100%-8px)] top-1 border border-zinc-300 dark:border-zinc-600",a==="underline"&&"bottom-0 h-0.5 bg-black dark:bg-white"),"data-width":s.width,"data-left":s.left})]})})}p_.displayName="TabsList";function m_({ref:e,children:t,value:n,className:a,disabled:r,icon:i,...s}){const{activeValue:c,handleValueChange:u}=QK(),m=U_e()?.variant||"default",h=c===n;return p.jsxs("button",{ref:e,disabled:r,onClick:()=>u(n),className:De("relative z-10 flex-1 inline-flex items-center justify-center whitespace-nowrap text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 cursor-pointer",m==="default"&&"rounded-md px-4 py-2.5",m==="underline"&&"px-6 py-3 border-b-2 border-transparent",h&&"text-foreground",!h&&"text-muted-foreground hover:text-foreground",a),...s,children:[i&&p.jsx(i,{className:"mr-2 h-4 w-4"}),t]})}m_.displayName="TabsTrigger";function Q4({className:e}){const{theme:t,setTheme:n}=Ry(),a=x.useRef(null),[r,i]=x.useState(!1);x.useEffect(()=>{i(!0)},[]);const s=()=>t==="system"?"light":t==="light"?"dark":"system",c=()=>t==="system"?p.jsx(sU,{className:"size-4"}):t==="light"?p.jsx(Bpe,{className:"size-5"}):p.jsx(xpe,{className:"size-4"}),u=()=>t==="system"?"Switch to light mode":t==="light"?"Switch to dark mode":"Switch to system mode",d=async()=>{if(!a.current)return;const m=s();if(typeof document<"u"&&"startViewTransition"in document){await document.startViewTransition(()=>{qu.flushSync(()=>{n(m)})}).ready;const{top:h,left:g,width:v,height:w}=a.current.getBoundingClientRect(),S=h+w/2,y=g+v/2,_=window.innerWidth-g,E=window.innerHeight-h,k=Math.hypot(Math.max(g,_),Math.max(h,E));document.documentElement.animate({clipPath:[`circle(0px at ${y}px ${S}px)`,`circle(${k}px at ${y}px ${S}px)`]},{duration:700,easing:"ease-in-out",pseudoElement:"::view-transition-new(root)"})}else n(m)};return r?p.jsx("button",{ref:a,onClick:d,className:De(e),"aria-label":u(),title:`Current: ${t==="system"?"Auto":t==="light"?"Light":"Dark"}`,children:c()}):p.jsx("button",{ref:a,className:De(e),"aria-label":"Toggle theme",children:p.jsx(sU,{className:"size-4"})})}function e2({className:e,state:t="collapsed",href:n="https://mcp-use.com"}){const[a,r]=x.useState(!1),i=.2,s=.7,c=.6,u=4,d=i+s+c,m=0,h=i/d,g=(i+s)/d,v=1;return p.jsxs("a",{href:n,target:"_blank",rel:"noopener noreferrer",className:De("flex items-center transition-opacity -my-3",t==="expanded"?"space-x-2":"",e),onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),children:[p.jsx("div",{className:"relative",children:p.jsxs(ma.svg,{viewBox:"0 0 303 303",initial:"rest",animate:a?"hover":"rest",className:De("text-foreground",t==="expanded"?"size-[40px]":"size-[20px]"),children:[p.jsxs(ma.g,{variants:{rest:{opacity:1},hover:{opacity:[1,0,0,1],transition:{duration:d,times:[m,h,g,v],ease:"easeInOut"}}},fill:"currentColor",fillRule:"nonzero",stroke:"currentColor",strokeWidth:u,strokeLinecap:"round",strokeLinejoin:"round",children:[p.jsx("path",{d:"m105.5 34.8.6.6c9.5 9.5 14.4 21.9 14.6 34.4a112.6 112.6 0 0 0 112.2 112.1h.6c12 .4 24 5.1 33.2 14.1l.6.6a50 50 0 0 1-70.1 71.3l-.6-.6A49.9 49.9 0 0 1 182 230 112.6 112.6 0 0 0 73.4 120.7h-.8a49.9 49.9 0 0 1-36.7-14l-.5-.6a50 50 0 0 1-.6-70.2l.6-.5a50 50 0 0 1 69.5-1.2l.6.6Z"}),p.jsx("circle",{cx:"70.3",cy:"232.3",r:"50"}),p.jsx("circle",{cx:"232.3",cy:"70.3",r:"50"})]}),p.jsxs("g",{fill:"none",stroke:"currentColor",strokeWidth:u,strokeLinecap:"round",strokeLinejoin:"round",children:[p.jsx(z_e,{d:"m105.5 34.8.6.6c9.5 9.5 14.4 21.9 14.6 34.4a112.6 112.6 0 0 0 112.2 112.1h.6c12 .4 24 5.1 33.2 14.1l.6.6a50 50 0 0 1-70.1 71.3l-.6-.6A49.9 49.9 0 0 1 182 230 112.6 112.6 0 0 0 73.4 120.7h-.8a49.9 49.9 0 0 1-36.7-14l-.5-.6a50 50 0 0 1-.6-70.2l.6-.5a50 50 0 0 1 69.5-1.2l.6.6Z",times:{T0:m,T1:h,T2:g,T3:v},total:d}),p.jsx(t2,{cx:70.3,cy:232.3,r:50,times:{T0:m,T1:h,T2:g,T3:v},total:d}),p.jsx(t2,{cx:232.3,cy:70.3,r:50,times:{T0:m,T1:h,T2:g,T3:v},total:d})]})]})}),t==="expanded"&&p.jsxs("div",{className:"font-ubuntu flex flex-col items-start -space-y-1 mr-3",children:[p.jsx("h1",{className:"text-xl font-medium",children:"mcp-use"}),p.jsx("span",{className:"text-lg text-muted-foreground tracking-wide font-sans font-light",children:"Inspector"})]})]})}function z_e({d:e,times:t,total:n}){const{T0:a,T1:r,T2:i,T3:s}=t;return p.jsx(ma.path,{d:e,variants:{rest:{pathLength:0,opacity:0},hover:{pathLength:[0,0,1,1],opacity:[0,0,1,1],transition:{duration:n,times:[a,r,i,s],ease:"easeInOut"}}}})}function t2({cx:e,cy:t,r:n,times:a,total:r}){const{T0:i,T1:s,T2:c,T3:u}=a;return p.jsx(ma.circle,{cx:e,cy:t,r:n,variants:{rest:{pathLength:0,opacity:0},hover:{pathLength:[0,0,1,1],opacity:[0,0,1,1],transition:{duration:r,times:[i,s,c,u],ease:"easeInOut"}}}})}function tZ({ref:e,shimmerColor:t,shimmerSize:n="0.05em",shimmerDuration:a="3s",borderRadius:r="100px",background:i,className:s,children:c,...u}){const{resolvedTheme:d}=Ry(),m=d==="dark"?"#000000":"#ffffff",h=d==="dark"?"rgba(255, 255, 255, 1)":"rgba(0, 0, 0, 1)",g=t||m,v=i||h;return p.jsxs("button",{style:{"--spread":"90deg","--shimmer-color":g,"--radius":r,"--speed":a,"--cut":n,"--bg":v},className:De("group relative z-0 flex cursor-pointer items-center justify-center overflow-hidden [border-radius:var(--radius)] border px-6 py-3 whitespace-nowrap [background:var(--bg)]","transform-gpu transition-transform duration-300 ease-in-out active:translate-y-px",d==="dark"?"border-black/10 text-black":"border-white/10 text-white",s),ref:e,...u,children:[p.jsx("div",{className:De("-z-30 blur-[2px]","[container-type:size] absolute inset-0 overflow-visible"),children:p.jsx("div",{className:"animate-shimmer-slide absolute inset-0 [aspect-ratio:1] h-[100cqh] [border-radius:0] [mask:none]",children:p.jsx("div",{className:"animate-spin-around absolute -inset-full w-auto [translate:0_0] rotate-0 [background:conic-gradient(from_calc(270deg-(var(--spread)*0.5)),transparent_0,var(--shimmer-color)_var(--spread),transparent_var(--spread))]"})})}),c,p.jsx("div",{className:De("absolute inset-0 size-full","rounded-2xl px-4 py-1.5 text-sm font-medium","transform-gpu transition-all duration-300 ease-in-out",d==="dark"?"shadow-[inset_0_-8px_10px_#0000001f] group-hover:shadow-[inset_0_-6px_10px_#0000003f] group-active:shadow-[inset_0_-10px_10px_#0000003f]":"shadow-[inset_0_-8px_10px_#ffffff1f] group-hover:shadow-[inset_0_-6px_10px_#ffffff3f] group-active:shadow-[inset_0_-10px_10px_#ffffff3f]")}),p.jsx("div",{className:De("absolute [inset:var(--cut)] -z-20 [border-radius:var(--radius)] [background:var(--bg)]")})]})}tZ.displayName="ShimmerButton";function n2({status:e}){const t=i=>{switch(i){case"ready":return{color:"bg-emerald-500",ringColor:"ring-emerald-500",tooltip:"Connected"};case"failed":return{color:"bg-red-500",ringColor:"ring-red-500",tooltip:"Failed"};default:return{color:"bg-yellow-500",ringColor:"ring-yellow-500",tooltip:i}}},{color:n,ringColor:a,tooltip:r}=t(e);return p.jsxs(en,{children:[p.jsx(tn,{asChild:!0,children:p.jsxs("div",{className:"relative",children:[p.jsx("div",{className:`absolute w-2 h-2 rounded-full ${a} animate-ping`}),p.jsx("div",{className:`relative w-2 h-2 rounded-full ${n}`})]})}),p.jsx(nn,{children:p.jsx("p",{children:r})})]})}function r2({connections:e,selectedServer:t,onServerSelect:n,onOpenConnectionOptions:a,mobileMode:r=!1}){const i=Xu(),s=c=>{const u=e.find(d=>d.id===c);if(!u||u.state!=="ready"){Qt.error("Server is not connected and cannot be inspected");return}n(c)};return r?p.jsx("div",{className:"flex items-center gap-2",children:p.jsx("div",{className:"relative",children:p.jsxs(Qx,{children:[p.jsx(eE,{asChild:!0,children:p.jsxs(Ue,{variant:"ghost",className:"h-11 px-2 bg-black dark:bg-white text-white dark:text-black border-black dark:border-white hover:bg-gray-800 dark:hover:bg-zinc-100 hover:border-gray-800 dark:hover:border-zinc-200 flex items-center gap-1.5",children:[t?p.jsx(wl,{serverUrl:t.url,serverName:t.name,size:"md"}):p.jsx(Dpe,{className:"h-5 w-5"}),p.jsx(Vl,{className:"h-4 w-4"})]})}),p.jsxs(Lb,{className:"w-[calc(100vw-2rem)] sm:w-[300px]",align:"start",children:[p.jsx(tE,{className:"cursor-pointer hover:bg-zinc-100 dark:hover:bg-zinc-800",onClick:()=>i("/"),children:"MCP Servers"}),p.jsx(Sf,{}),e.length===0?p.jsx("div",{className:"px-2 py-4 text-sm text-muted-foreground dark:text-zinc-400 text-center",children:"No servers connected. Go to the dashboard to add one."}):e.map(c=>p.jsxs(So,{onClick:()=>s(c.id),className:"flex items-center gap-3",children:[p.jsx(wl,{serverUrl:c.url,serverName:c.name,size:"sm"}),p.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[p.jsx("div",{className:"font-medium",children:c.name}),p.jsx(n2,{status:c.state})]}),p.jsx(Ue,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 hover:bg-zinc-100 dark:hover:bg-zinc-800",onClick:u=>{u.stopPropagation(),a(c.id)},children:p.jsx(uu,{className:"h-3 w-3"})})]},c.id)),p.jsx(Sf,{}),p.jsx(So,{onClick:()=>i("/"),children:p.jsx("span",{className:"text-blue-600 dark:text-blue-400",children:"+ Add new server"})})]})]})})}):p.jsx("div",{className:"flex items-center gap-2",children:p.jsx("div",{className:"relative",children:p.jsxs(Qx,{children:[p.jsx(eE,{asChild:!0,children:p.jsxs(tZ,{className:De("min-w-0 sm:min-w-[200px] p-0 px-1 text-sm h-11 justify-start bg-black dark:bg-white text-white dark:text-black border-black dark:border-white hover:bg-gray-800 dark:hover:bg-zinc-100 hover:border-gray-800 dark:hover:border-zinc-200",!t&&"pl-4",t&&"pr-10"),children:[t&&p.jsx(wl,{serverUrl:t.url,serverName:t.name,size:"md",className:"mr-2"}),p.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[p.jsx("span",{className:"truncate",children:t?t.name:"Select server to inspect"}),t&&p.jsx("div",{className:"flex items-center gap-2",children:t.error&&t.state!=="ready"?p.jsxs(en,{children:[p.jsx(tn,{asChild:!0,children:p.jsx("button",{onClick:c=>{c.stopPropagation()},className:"w-2 h-2 rounded-full bg-rose-500 animate-status-pulse-red hover:bg-rose-600 transition-colors",title:"Click to copy error message","aria-label":"Copy error message to clipboard"})}),p.jsx(nn,{children:p.jsx("p",{className:"max-w-xs",children:t.error})})]}):p.jsx("div",{className:`w-2 h-2 rounded-full ${t.state==="ready"?"bg-emerald-600 animate-status-pulse":t.state==="failed"?"bg-rose-600 animate-status-pulse-red":"bg-yellow-500 animate-status-pulse-yellow"}`})})]})]})}),t&&p.jsxs(en,{children:[p.jsx(tn,{asChild:!0,children:p.jsx("button",{type:"button",onClick:()=>{a(t.id)},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1.5 hover:bg-white/10 dark:hover:bg-black/10 rounded-full transition-colors text-white dark:text-black","aria-label":"Edit connection settings",children:p.jsx(uu,{className:"h-4 w-4"})})}),p.jsx(nn,{children:p.jsx("p",{children:"Edit connection settings"})})]}),p.jsxs(Lb,{className:"w-[calc(100vw-2rem)] sm:w-[300px]",align:"start",children:[p.jsx(tE,{className:"cursor-pointer hover:bg-zinc-100 dark:hover:bg-zinc-800",onClick:()=>i("/"),children:"MCP Servers"}),p.jsx(Sf,{}),e.length===0?p.jsx("div",{className:"px-2 py-4 text-sm text-muted-foreground dark:text-zinc-400 text-center",children:"No servers connected. Go to the dashboard to add one."}):e.map(c=>p.jsxs(So,{onClick:()=>s(c.id),className:"flex items-center gap-3",children:[p.jsx(wl,{serverUrl:c.url,serverName:c.name,size:"sm"}),p.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[p.jsx("div",{className:"font-medium",children:c.name}),p.jsx(n2,{status:c.state})]}),p.jsx(Ue,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 hover:bg-zinc-100 dark:hover:bg-zinc-800",onClick:u=>{u.stopPropagation(),a(c.id)},children:p.jsx(uu,{className:"h-3 w-3"})})]},c.id)),p.jsx(Sf,{}),p.jsx(So,{onClick:()=>i("/"),children:p.jsx("span",{className:"text-blue-600 dark:text-blue-400",children:"+ Add new server"})})]})]})})})}const a2=[{id:"tools",label:"Tools",icon:Dl},{id:"prompts",label:"Prompts",icon:ip},{id:"resources",label:"Resources",icon:ape},{id:"chat",label:"Chat",icon:gpe},{id:"sampling",label:"Sampling",icon:z9},{id:"notifications",label:"Notifications",icon:JT}];function i2(e,t){return e==="tools"?t.tools.length:e==="prompts"?t.prompts.length:e==="resources"?t.resources.length:e==="sampling"?t.pendingSamplingRequests.length:e==="notifications"?t.unreadNotificationCount:0}function F_e({connections:e,selectedServer:t,activeTab:n,onServerSelect:a,onTabChange:r,onCommandPaletteOpen:i,onOpenConnectionOptions:s}){const{tunnelUrl:c}=ld(),u=t&&c,[d,m]=x.useState(!1),h=async()=>{if(c)try{await navigator.clipboard.writeText(`${c}/mcp`),m(!0),Qt.success("Tunnel URL copied to clipboard"),setTimeout(()=>m(!1),2e3)}catch{Qt.error("Failed to copy URL")}};return p.jsxs("header",{className:"w-full mx-auto",children:[p.jsxs("div",{className:"flex lg:hidden flex-col gap-3",children:[p.jsxs("div",{className:"flex items-center justify-between w-full",children:[p.jsx("div",{className:"flex-1 flex justify-start",children:p.jsx(r2,{connections:e,selectedServer:t,onServerSelect:a,onOpenConnectionOptions:s,mobileMode:!0})}),p.jsx("div",{className:"flex-shrink-0 flex justify-center",children:p.jsx("div",{className:"scale-150",children:p.jsx(e2,{state:"collapsed"})})}),p.jsxs("div",{className:"flex-1 flex justify-end items-center gap-2",children:[p.jsxs(en,{children:[p.jsx(tn,{asChild:!0,children:p.jsx(Ue,{variant:"ghost",size:"sm",asChild:!0,children:p.jsx("a",{href:"https://github.com/mcp-use/mcp-use",target:"_blank",rel:"noopener noreferrer",className:"p-2","aria-label":"GitHub",children:p.jsx(J4,{className:"h-4 w-4"})})})}),p.jsx(nn,{children:p.jsx("p",{children:"Give us a star ⭐"})})]}),p.jsx(Q4,{className:"p-2 hover:bg-zinc-200 dark:hover:bg-zinc-800 rounded-full transition-colors cursor-pointer"})]})]}),t&&p.jsx("div",{className:"w-full",children:p.jsx(f_,{value:n,onValueChange:g=>r(g),children:p.jsx(p_,{className:"w-full justify-center",children:a2.map(g=>{const v=i2(g.id,t);return p.jsxs(m_,{value:g.id,icon:g.icon,className:"[&>svg]:mr-0 flex-1 flex-row gap-2 relative",children:[v>0&&p.jsx("span",{className:De(n===g.id?"dark:bg-black":"dark:bg-zinc-700","bg-zinc-200 text-zinc-700 dark:text-zinc-300 text-[10px] px-1.5 py-0.5 rounded-full font-medium"),children:v}),p.jsx("span",{className:"sr-only",children:g.label})]},g.id)})})})})]}),p.jsxs("div",{className:"hidden lg:flex items-center justify-between gap-3",children:[p.jsxs("div",{className:"flex items-center flex-wrap gap-2 md:space-x-6 space-x-2",children:[p.jsx(r2,{connections:e,selectedServer:t,onServerSelect:a,onOpenConnectionOptions:s}),t&&p.jsx(f_,{value:n,onValueChange:g=>r(g),children:p.jsx(p_,{className:"overflow-x-auto",children:a2.map(g=>{const v=i2(g.id,t);return p.jsx(m_,{value:g.id,icon:g.icon,className:"[&>svg]:mr-0 lg:[&>svg]:mr-2 relative",children:p.jsxs("div",{className:"items-center gap-2 hidden lg:flex",children:[g.label,v>0&&p.jsx("span",{className:De(n===g.id?" dark:bg-black ":"dark:bg-zinc-700","bg-zinc-200 text-zinc-700 dark:text-zinc-300 text-xs px-2 py-0.5 rounded-full font-medium"),children:v})]})},g.id)})})}),u&&p.jsxs(ZW,{children:[p.jsx(YW,{asChild:!0,children:p.jsxs("button",{className:"flex items-center gap-2 px-3 py-1.5 bg-gradient-to-r from-purple-500/10 to-pink-500/10 dark:from-purple-500/20 dark:to-pink-500/20 border border-purple-500/30 dark:border-purple-500/40 rounded-full hover:from-purple-500/20 hover:to-pink-500/20 dark:hover:from-purple-500/30 dark:hover:to-pink-500/30 transition-colors cursor-pointer",children:[p.jsx(op,{className:"size-4 text-purple-600 dark:text-purple-400 animate-pulse"}),p.jsx("span",{className:"text-xs font-medium text-purple-700 dark:text-purple-300 hidden lg:inline",children:"Tunnel"})]})}),p.jsx(ZN,{className:"w-[calc(100vw-2rem)] sm:w-96",align:"start",children:p.jsxs("div",{className:"space-y-4",children:[p.jsxs("div",{children:[p.jsxs("h4",{className:"font-semibold text-sm mb-2 flex items-center gap-2",children:[p.jsx(op,{className:"size-4 text-purple-600 dark:text-purple-400"}),"Tunnel URL"]}),p.jsxs("div",{className:"flex items-center gap-2 p-2 py-0 bg-muted rounded-full",children:[p.jsxs("code",{className:"flex-1 text-[10px] font-mono",children:[c,"/mcp"]}),p.jsx(Ue,{variant:"ghost",size:"sm",className:"h-7 px-2",onClick:h,children:d?p.jsx(La,{className:"size-3.5 text-green-600"}):p.jsx(Xr,{className:"size-3.5"})})]})]}),p.jsxs("div",{children:[p.jsx("h5",{className:"font-semibold text-sm mb-2",children:"Use in ChatGPT"}),p.jsxs("ol",{className:"space-y-2 text-xs text-muted-foreground",children:[p.jsxs("li",{className:"flex gap-2",children:[p.jsx("span",{className:"font-semibold text-foreground",children:"1."}),p.jsxs("span",{children:["Enable"," ",p.jsx("span",{className:"font-medium text-foreground",children:"dev mode"})," ","from settings"]})]}),p.jsxs("li",{className:"flex gap-2",children:[p.jsx("span",{className:"font-semibold text-foreground",children:"2."}),p.jsxs("span",{children:["In"," ",p.jsx("span",{className:"font-medium text-foreground",children:"App & Connectors"})," ","click on"," ",p.jsx("span",{className:"font-medium text-foreground",children:"create"})]})]}),p.jsxs("li",{className:"flex gap-2",children:[p.jsx("span",{className:"font-semibold text-foreground",children:"3."}),p.jsx("span",{children:"Use the tunnel URL in the input"})]})]})]})]})})]})]}),p.jsxs("div",{className:"flex items-center gap-2 sm:gap-4 flex-shrink-0",children:[p.jsxs(en,{children:[p.jsx(tn,{children:p.jsx(Q4,{className:"p-2 hover:bg-zinc-200 dark:hover:bg-zinc-800 rounded-full transition-colors cursor-pointer"})}),p.jsx(nn,{children:p.jsx("p",{children:"Toggle theme"})})]}),p.jsxs(en,{children:[p.jsx(tn,{asChild:!0,children:p.jsxs(Ue,{variant:"ghost",className:"hover:bg-zinc-200 dark:hover:bg-zinc-800 rounded-full px-1 -mx-3 flex gap-1",onClick:i,children:[p.jsx(Ffe,{className:"size-4"}),p.jsx("span",{className:"text-base font-mono hidden sm:inline",children:"K"})]})}),p.jsx(nn,{children:p.jsx("p",{children:"Command Palette"})})]}),p.jsxs(en,{children:[p.jsx(tn,{asChild:!0,children:p.jsx(Ue,{variant:"ghost",size:"sm",asChild:!0,children:p.jsxs("a",{href:"https://github.com/mcp-use/mcp-use",className:"flex items-center gap-2",target:"_blank",rel:"noopener noreferrer",children:[p.jsx(J4,{className:"h-4 w-4"}),p.jsx("span",{className:"hidden sm:inline",children:"Github"})]})})}),p.jsx(nn,{children:p.jsx("p",{children:"Give us a star ⭐"})})]}),p.jsx(e2,{state:"expanded"})]})]})]})}function B_e({children:e}){const t=Xu(),n=Po(),{connections:a,addConnection:r,removeConnection:i,updateConnectionConfig:s,configLoaded:c}=qT(),{selectedServerId:u,setSelectedServerId:d,activeTab:m,setActiveTab:h,navigateToItem:g,setTunnelUrl:v}=ld(),[w,S]=x.useState(!1),[y,_]=x.useState(null),E=cwe();x.useEffect(()=>{const Y=new URLSearchParams(n.search).get("tunnelUrl");v(Y)},[n.search,v]),x.useEffect(()=>{const V=z=>{const re=z.detail.requestId;u&&g(u,"sampling",re)},Y=z=>{const re=z.detail.toolName;u&&re?g(u,"tools",re):u&&h("tools")};return window.addEventListener("navigate-to-sampling",V),window.addEventListener("navigate-to-tool-result",Y),()=>{window.removeEventListener("navigate-to-sampling",V),window.removeEventListener("navigate-to-tool-result",Y)}},[u,h,g]);const k=x.useRef(null),C=x.useRef(null),R=x.useRef(null),{isAutoConnecting:A}=lwe({connections:a,addConnection:r,removeConnection:i,configLoaded:c}),I=x.useCallback(V=>{br.getInstance().capture(new afe({trigger:V})).catch(()=>{}),S(!0)},[]),O=V=>{const Y=a.find($=>$.id===V);if(!Y||Y.state!=="ready"){Qt.error("Server is not connected and cannot be inspected");return}d(V);const te=new URLSearchParams(n.search).get("tunnelUrl"),re=te?`/?server=${encodeURIComponent(V)}&tunnelUrl=${encodeURIComponent(te)}`:`/?server=${encodeURIComponent(V)}`;t(re)},j=x.useCallback(V=>{_(V)},[]),F=x.useCallback(V=>{y&&(V.url!==y?(i(y),r(V.url,V.name,V.proxyConfig,V.transportType)):s(y,{name:V.name,proxyConfig:V.proxyConfig,transportType:V.transportType}),_(null),Qt.success("Connection settings updated"))},[y,i,r,s]),H=(V,Y,z)=>{if(console.warn("[Layout] handleCommandPaletteNavigate called:",{tab:V,itemName:Y,serverId:z}),z){const te=a.find(U=>U.id===z);if(console.warn("[Layout] Server lookup:",{serverId:z,serverFound:!!te,serverState:te?.state}),!te||te.state!=="ready"){console.warn("[Layout] Server not ready, showing error"),Qt.error("Server is not connected and cannot be inspected");return}console.warn("[Layout] Calling navigateToItem:",{serverId:z,tab:V,itemName:Y}),g(z,V,Y);const $=new URLSearchParams(n.search).get("tunnelUrl"),B=$?`/?server=${encodeURIComponent(z)}&tunnelUrl=${encodeURIComponent($)}`:`/?server=${encodeURIComponent(z)}`;console.warn("[Layout] Navigating to:",B),t(B)}else console.warn("[Layout] No serverId, just updating tab to:",V),h(V)},K=a.find(V=>V.id===u),Q=K?K.tools.map(V=>({...V,_serverId:K.id})):a.flatMap(V=>V.state==="ready"?V.tools.map(Y=>({...Y,_serverId:V.id,_serverName:V.name})):[]),W=K?K.prompts.map(V=>({...V,_serverId:K.id})):a.flatMap(V=>V.state==="ready"?V.prompts.map(Y=>({...Y,_serverId:V.id,_serverName:V.name})):[]),ie=K?K.resources.map(V=>({...V,_serverId:K.id})):a.flatMap(V=>V.state==="ready"?V.resources.map(Y=>({...Y,_serverId:V.id,_serverName:V.name})):[]);return x.useEffect(()=>{const Y=new URLSearchParams(n.search).get("server"),z=Y?decodeURIComponent(Y):null;z!==u&&d(z)},[n.search,u,d]),x.useEffect(()=>{const Y=new URLSearchParams(n.search).get("server");if(!Y)return;const z=decodeURIComponent(Y),te=a.find(re=>re.id===z);if(!te){const re=setTimeout(()=>t("/"),3e3);return()=>clearTimeout(re)}if(te.state==="failed"){const re=setTimeout(()=>t("/"),2e3);return()=>clearTimeout(re)}},[n.search,t,a]),xW({onCommandPalette:()=>I("keyboard"),onToolsTab:()=>{K&&h("tools")},onPromptsTab:()=>{K&&h("prompts")},onResourcesTab:()=>{K&&h("resources")},onChatTab:()=>{K&&h("chat")},onHome:()=>{t("/")},onFocusSearch:()=>{m==="tools"&&k.current?k.current.focusSearch():m==="prompts"&&C.current?C.current.focusSearch():m==="resources"&&R.current&&R.current.focusSearch()},onBlurSearch:()=>{m==="tools"&&k.current?k.current.blurSearch():m==="prompts"&&C.current?C.current.blurSearch():m==="resources"&&R.current&&R.current.blurSearch()}}),A?p.jsx("div",{className:"h-screen bg-white dark:bg-zinc-900 flex items-center justify-center",children:p.jsxs("div",{className:"flex flex-col items-center gap-4",children:[p.jsx(Lo,{className:"h-8 w-8 text-zinc-600 dark:text-zinc-400"}),p.jsx("p",{className:"text-sm text-zinc-600 dark:text-zinc-400",children:"Connecting to MCP server..."})]})}):p.jsx(L9,{children:p.jsxs("div",{className:"h-screen bg-[#f3f3f3] dark:bg-black flex flex-col px-2 py-2 sm:px-4 sm:py-4 gap-2 sm:gap-4",children:[p.jsx(F_e,{connections:a,selectedServer:K,activeTab:m,onServerSelect:O,onTabChange:h,onCommandPaletteOpen:()=>I("button"),onOpenConnectionOptions:j}),p.jsx("main",{className:"flex-1 w-full mx-auto bg-white dark:bg-black rounded-2xl border border-zinc-200 dark:border-zinc-700 p-0 overflow-auto",children:p.jsx(P_e,{selectedServer:K,activeTab:m,toolsSearchRef:k,promptsSearchRef:C,resourcesSearchRef:R,children:e})}),p.jsx(jwe,{isOpen:w,onOpenChange:S,tools:Q,prompts:W,resources:ie,savedRequests:E,connections:a,onNavigate:H,onServerSelect:O}),p.jsx(UG,{connection:y&&a.find(V=>V.id===y)||null,open:y!==null,onOpenChange:V=>{V||_(null)},onConnect:F})]})})}function H_e(){const[e,t]=x.useState("processing"),[n,a]=x.useState("");return x.useEffect(()=>{console.log("[OAuthCallback] Component mounted, handling authorization..."),console.log("[OAuthCallback] Current URL:",window.location.href),ST().then(()=>{console.log("[OAuthCallback] Authorization successful"),t("success")}).catch(r=>{console.error("[OAuthCallback] Authorization failed:",r),t("error"),a(r instanceof Error?r.message:String(r))})},[]),e==="processing"?p.jsx("div",{className:"h-screen w-full flex items-center justify-center bg-white dark:bg-zinc-900",children:p.jsxs("div",{className:"flex flex-col items-center gap-4",children:[p.jsx(As,{className:"h-8 w-8 animate-spin text-zinc-600 dark:text-zinc-400"}),p.jsx("p",{className:"text-sm text-zinc-600 dark:text-zinc-400",children:"Completing authentication..."})]})}):e==="error"?p.jsx("div",{className:"h-screen w-full flex items-center justify-center bg-white dark:bg-zinc-900",children:p.jsxs("div",{className:"max-w-md p-6",children:[p.jsx("h1",{className:"text-xl font-semibold text-red-600 dark:text-red-400 mb-2",children:"Authentication Error"}),p.jsx("p",{className:"text-sm text-zinc-600 dark:text-zinc-400 mb-4",children:n}),p.jsx("p",{className:"text-xs text-zinc-500 dark:text-zinc-500",children:"You can close this window and try again."})]})}):p.jsx("div",{className:"h-screen w-full flex items-center justify-center bg-white dark:bg-zinc-900",children:p.jsxs("div",{className:"max-w-md p-6",children:[p.jsx("h1",{className:"text-xl font-semibold text-green-600 dark:text-green-400 mb-2",children:"Authentication Successful!"}),p.jsx("p",{className:"text-sm text-zinc-600 dark:text-zinc-400",children:"Redirecting you back..."})]})})}var V_e=(e,t,n,a,r,i,s,c)=>{let u=document.documentElement,d=["light","dark"];function m(v){(Array.isArray(e)?e:[e]).forEach(w=>{let S=w==="class",y=S&&i?r.map(_=>i[_]||_):r;S?(u.classList.remove(...y),u.classList.add(i&&i[v]?i[v]:v)):u.setAttribute(w,v)}),h(v)}function h(v){c&&d.includes(v)&&(u.style.colorScheme=v)}function g(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}if(a)m(a);else try{let v=localStorage.getItem(t)||n,w=s&&v==="system"?g():v;m(w)}catch{}},G_e=x.createContext(void 0),W_e={setTheme:e=>{},themes:[]},K_e=()=>{var e;return(e=x.useContext(G_e))!=null?e:W_e};x.memo(({forcedTheme:e,storageKey:t,attribute:n,enableSystem:a,enableColorScheme:r,defaultTheme:i,value:s,themes:c,nonce:u,scriptProps:d})=>{let m=JSON.stringify([n,t,i,e,c,s,a,r]).slice(1,-1);return x.createElement("script",{...d,suppressHydrationWarning:!0,nonce:typeof window>"u"?u:"",dangerouslySetInnerHTML:{__html:`(${V_e.toString()})(${m})`}})});function Z_e({...e}){const{theme:t="system"}=K_e();return p.jsx(G9,{theme:t,className:"toaster group",style:{"--normal-bg":"var(--popover)","--normal-text":"var(--popover-foreground)","--normal-border":"var(--border)"},...e})}function Y_e(){return p.jsx(kxe,{children:p.jsx(ufe,{children:p.jsxs(swe,{children:[p.jsx(coe,{basename:"/inspector",children:p.jsxs(zie,{children:[p.jsx(Hx,{path:"/oauth/callback",element:p.jsx(H_e,{})}),p.jsx(Hx,{path:"/",element:p.jsx(B_e,{children:p.jsx(owe,{})})})]})}),p.jsx(Z_e,{position:"top-center"})]})})})}const o2=new URLSearchParams(window.location.search);if(o2.has("code")||o2.has("error"))try{ST()}catch(e){console.error("[inspector] OAuth callback error:",e)}const s2=document.getElementById("root");s2?Yae.createRoot(s2).render(p.jsx(Y_e,{})):console.error("[inspector] Root element not found");export{v3 as $,p6 as A,f6 as B,_v as C,b6 as D,N5 as E,Fg as F,Oae as G,iP as H,ST as I,d2 as L,Nae as M,ue as R,Aae as W,kt as Z,Ge as _,Ar as a,Pp as b,qu as c,fx as d,q_e as e,mi as f,xp as g,px as h,ei as i,RB as j,$3 as k,E2 as l,T2 as m,NB as n,b3 as o,L2 as p,uee as q,x as r,z_ as s,KB as t,Oe as u,mee as v,C5 as w,gx as x,Pee as y,Wk as z};