@mcp-use/inspector 0.11.0-canary.2 → 0.11.0

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-CEX29aLI.js","assets/util-t-trnxQI.js","assets/__vite-browser-external-DFygW7-s.js","assets/index-DRz5BQNA.js","assets/path-C9FudP8b.js","assets/index-mPE5nU31.js","assets/index-C2TkayVJ.js","assets/index-4MGGBPsA.js","assets/index-BsKT3Pod.js","assets/embeddings-fjp_vwal.js","assets/index-BpS0GDKB.js","assets/index-BL2BGw9b.js","assets/browser-DjEv9HBk.js"])))=>i.map(i=>d[i]);
2
- var dq=Object.defineProperty;var fq=(e,t,n)=>t in e?dq(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Nh=(e,t,n)=>fq(e,typeof t!="symbol"?t+"":t,n);function pq(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 Tp(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function oke(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 K0={exports:{}},lf={};var m$;function mq(){if(m$)return lf;m$=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 lf.Fragment=t,lf.jsx=n,lf.jsxs=n,lf}var h$;function hq(){return h$||(h$=1,K0.exports=mq()),K0.exports}var f=hq();const gq="modulepreload",bq=function(e){return"/inspector/"+e},g$={},dr=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=bq(d),d in g$)return;g$[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":gq,m||(g.as="script"),g.crossOrigin="",g.href=d,c&&g.setAttribute("nonce",c),document.head.appendChild(g),m)return new Promise((v,S)=>{g.addEventListener("load",v),g.addEventListener("error",()=>S(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 vq=Object.defineProperty,Ge=(e,t)=>vq(e,"name",{value:t,configurable:!0}),b$=(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')}),Fc={};async function p2(){if(typeof process<"u")try{const e=await dr(()=>import("./__vite-browser-external-DFygW7-s.js").then(n=>n.o),[]),t=await dr(()=>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(p2,"getNodeModules");var Aa=null;function m2(){if(typeof b$<"u")try{Aa=b$("winston")}catch{}}Ge(m2,"loadWinstonSync");async function h2(){return Aa||(Aa=await dr(()=>import("./winston-CEX29aLI.js").then(e=>e.w),__vite__mapDeps([0,1,2,3,4]))),Aa}Ge(h2,"getWinston");var mS="mcp-use";function db(){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(db,"isNodeJSEnvironment");var vu,yq=(vu=class{_level;name;constructor(t=mS,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(vu,"SimpleConsoleLogger"),vu);function Fg(e){switch((typeof process<"u"&&Fc?e:void 0)?.trim()){case"2":return"debug";case"1":return"info";default:return"info"}}Ge(Fg,"resolveLevel");var yo,g2=(yo=class{static get(t=mS){if(!db()){if(!this.simpleInstances[t]){const n=typeof process<"u"&&Fc?.DEBUG||void 0;this.simpleInstances[t]=new yq(t,Fg(n))}return this.simpleInstances[t]}if(!this.instances[t]){if(!Aa)throw new Error("Winston not loaded - call Logger.configure() first");const{createLogger:n,format:a}=Aa,{combine:r,timestamp:i,label:s,colorize:c,splat:u}=a;this.instances[t]=n({level:Fg(Fc.DEBUG),format:r(c(),u(),s({label:t}),i({format:"HH:mm:ss"}),this.getFormatter()),transports:[]})}return this.instances[t]}static getFormatter(){if(!Aa)throw new Error("Winston not loaded");const{format:t}=Aa,{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"&&Fc?.DEBUG||void 0,c=n??Fg(s);if(this.currentFormat=i,!db()){Object.values(this.simpleInstances).forEach(y=>{y.level=c});return}if(await h2(),!Aa)throw new Error("Failed to load winston");const u=this.get();u.level=c;const d=u;if(d.clear(),a&&d.add(new Aa.transports.Console),r){const{fs:y,path:_}=await p2();if(y&&_){const E=_.dirname(_.resolve(r));y.existsSync(E)||y.mkdirSync(E,{recursive:!0}),d.add(new Aa.transports.File({filename:r}))}}const{format:m}=Aa,{combine:h,timestamp:g,label:v,colorize:S,splat:w}=m;Object.values(this.instances).forEach(y=>{y&&"format"in y&&(y.level=c,y.format=h(S(),w(),v({label:mS}),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"&&Fc&&(Fc.DEBUG=t?t===!0?"2":String(t):"0")}static setFormat(t){this.currentFormat=t,this.configure({format:t})}},Ge(yo,"Logger"),Nh(yo,"instances",{}),Nh(yo,"simpleInstances",{}),Nh(yo,"currentFormat","minimal"),yo);db()&&(m2(),Aa&&g2.configure());var Re=g2.get();const b2=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 v2=Symbol("zod_brand");class kl extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class gv extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const fb={};function Qr(e){return e&&Object.assign(fb,e),fb}function wq(e){return e}function xq(e){return e}function Sq(e){}function Eq(e){throw new Error}function _q(e){}function v_(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 Pe(e,t="|"){return e.map(n=>ct(n)).join(t)}function pb(e,t){return typeof t=="bigint"?t.toString():t}function Np(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function Hl(e){return e==null}function bv(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function y2(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 v$=Symbol("evaluating");function Ht(e,t,n){let a;Object.defineProperty(e,t,{get(){if(a!==v$)return a===void 0&&(a=v$,a=n()),a},set(r){Object.defineProperty(e,t,{value:r})},configurable:!0})}function kq(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 Mo(...e){const t={};for(const n of e){const a=Object.getOwnPropertyDescriptors(n);Object.assign(t,a)}return Object.defineProperties({},t)}function Tq(e){return Mo(e._zod.def)}function Nq(e,t){return t?t.reduce((n,a)=>n?.[a],e):e}function Cq(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 Rq(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 hS(e){return JSON.stringify(e)}function w2(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const y_="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Ru(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const x2=Np(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function Al(e){if(Ru(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(Ru(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function vv(e){return Al(e)?{...e}:Array.isArray(e)?[...e]:e}function Aq(e){let t=0;for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&t++;return t}const Iq=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}`)}},mb=new Set(["string","number","symbol"]),S2=new Set(["string","number","bigint","boolean","symbol","undefined"]);function Ro(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 Ae(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 Oq(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 ct(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function E2(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const _2={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]},k2={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function T2(e,t){const n=e._zod.def,a=Mo(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 N2(e,t){const n=e._zod.def,a=Mo(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 C2(e,t){if(!Al(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=Mo(e._zod.def,{get shape(){const i={...e._zod.def.shape,...t};return $s(this,"shape",i),i},checks:[]});return ei(e,r)}function R2(e,t){if(!Al(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 A2(e,t){const n=Mo(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 I2(e,t,n){const a=Mo(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 O2(e,t,n){const a=Mo(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 yl(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 vf(e){return typeof e=="string"?e:e?.message}function vi(e,t,n){const a={...e,path:e.path??[]};if(!e.message){const r=vf(e.inst?._zod.def?.error?.(e))??vf(t?.error?.(e))??vf(n.customError?.(e))??vf(n.localeError?.(e))??"Invalid input";a.message=r}return delete a.inst,delete a.continue,t?.reportInput||delete a.input,a}function yv(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}function wv(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Au(...e){const[t,n,a]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:a}:{...t}}function Dq(e){return Object.entries(e).filter(([t,n])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function D2(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 j2(e){let t="";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}function jq(e){const t=e.replace(/-/g,"+").replace(/_/g,"/"),n="=".repeat((4-t.length%4)%4);return D2(t+n)}function Lq(e){return j2(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function $q(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 Mq(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}class Pq{constructor(...t){}}const L2=Object.freeze(Object.defineProperty({__proto__:null,BIGINT_FORMAT_RANGES:k2,Class:Pq,NUMBER_FORMAT_RANGES:_2,aborted:yl,allowsEval:x2,assert:_q,assertEqual:wq,assertIs:Sq,assertNever:Eq,assertNotEqual:xq,assignProp:$s,base64ToUint8Array:D2,base64urlToUint8Array:jq,cached:Np,captureStackTrace:y_,cleanEnum:Dq,cleanRegex:bv,clone:ei,cloneDef:Tq,createTransparentProxy:Oq,defineLazy:Ht,esc:hS,escapeRegex:Ro,extend:C2,finalizeIssue:vi,floatSafeRemainder:y2,getElementAtPath:Nq,getEnumValues:v_,getLengthableOrigin:wv,getParsedType:Iq,getSizableOrigin:yv,hexToUint8Array:$q,isObject:Ru,isPlainObject:Al,issue:Au,joinValues:Pe,jsonStringifyReplacer:pb,merge:A2,mergeDefs:Mo,normalizeParams:Ae,nullish:Hl,numKeys:Aq,objectClone:kq,omit:N2,optionalKeys:E2,partial:I2,pick:T2,prefixIssues:pi,primitiveTypes:S2,promiseAllObject:Cq,propertyKeyTypes:mb,randomString:Rq,required:O2,safeExtend:R2,shallowClone:vv,slugify:w2,stringifyPrimitive:ct,uint8ArrayToBase64:j2,uint8ArrayToBase64url:Lq,uint8ArrayToHex:Mq,unwrapMessage:vf},Symbol.toStringTag,{value:"Module"})),$2=(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,pb,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},w_=me("$ZodError",$2),La=me("$ZodError",$2,{Parent:Error});function x_(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 S_(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 M2(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 P2(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 U2(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 ${P2(a.path)}`);return t.join(`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/winston-FbqTpCXc.js","assets/util-t-trnxQI.js","assets/__vite-browser-external-DFygW7-s.js","assets/index-DRz5BQNA.js","assets/path-C9FudP8b.js","assets/index-zbgLDNGN.js","assets/index-B17id_Fn.js","assets/index-C4rXRq-z.js","assets/index-Dy6z3o7k.js","assets/embeddings-6IYwOFQO.js","assets/index-BepdOzrL.js","assets/index-CUJpXvgh.js","assets/browser-DIA2gDt8.js"])))=>i.map(i=>d[i]);
2
+ var dq=Object.defineProperty;var fq=(e,t,n)=>t in e?dq(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Nh=(e,t,n)=>fq(e,typeof t!="symbol"?t+"":t,n);function pq(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 Tp(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function oke(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 K0={exports:{}},lf={};var m$;function mq(){if(m$)return lf;m$=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 lf.Fragment=t,lf.jsx=n,lf.jsxs=n,lf}var h$;function hq(){return h$||(h$=1,K0.exports=mq()),K0.exports}var f=hq();const gq="modulepreload",bq=function(e){return"/inspector/"+e},g$={},dr=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=bq(d),d in g$)return;g$[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":gq,m||(g.as="script"),g.crossOrigin="",g.href=d,c&&g.setAttribute("nonce",c),document.head.appendChild(g),m)return new Promise((v,S)=>{g.addEventListener("load",v),g.addEventListener("error",()=>S(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 vq=Object.defineProperty,Ge=(e,t)=>vq(e,"name",{value:t,configurable:!0}),b$=(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')}),Fc={};async function p2(){if(typeof process<"u")try{const e=await dr(()=>import("./__vite-browser-external-DFygW7-s.js").then(n=>n.o),[]),t=await dr(()=>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(p2,"getNodeModules");var Aa=null;function m2(){if(typeof b$<"u")try{Aa=b$("winston")}catch{}}Ge(m2,"loadWinstonSync");async function h2(){return Aa||(Aa=await dr(()=>import("./winston-FbqTpCXc.js").then(e=>e.w),__vite__mapDeps([0,1,2,3,4]))),Aa}Ge(h2,"getWinston");var mS="mcp-use";function db(){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(db,"isNodeJSEnvironment");var vu,yq=(vu=class{_level;name;constructor(t=mS,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(vu,"SimpleConsoleLogger"),vu);function Fg(e){switch((typeof process<"u"&&Fc?e:void 0)?.trim()){case"2":return"debug";case"1":return"info";default:return"info"}}Ge(Fg,"resolveLevel");var yo,g2=(yo=class{static get(t=mS){if(!db()){if(!this.simpleInstances[t]){const n=typeof process<"u"&&Fc?.DEBUG||void 0;this.simpleInstances[t]=new yq(t,Fg(n))}return this.simpleInstances[t]}if(!this.instances[t]){if(!Aa)throw new Error("Winston not loaded - call Logger.configure() first");const{createLogger:n,format:a}=Aa,{combine:r,timestamp:i,label:s,colorize:c,splat:u}=a;this.instances[t]=n({level:Fg(Fc.DEBUG),format:r(c(),u(),s({label:t}),i({format:"HH:mm:ss"}),this.getFormatter()),transports:[]})}return this.instances[t]}static getFormatter(){if(!Aa)throw new Error("Winston not loaded");const{format:t}=Aa,{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"&&Fc?.DEBUG||void 0,c=n??Fg(s);if(this.currentFormat=i,!db()){Object.values(this.simpleInstances).forEach(y=>{y.level=c});return}if(await h2(),!Aa)throw new Error("Failed to load winston");const u=this.get();u.level=c;const d=u;if(d.clear(),a&&d.add(new Aa.transports.Console),r){const{fs:y,path:_}=await p2();if(y&&_){const E=_.dirname(_.resolve(r));y.existsSync(E)||y.mkdirSync(E,{recursive:!0}),d.add(new Aa.transports.File({filename:r}))}}const{format:m}=Aa,{combine:h,timestamp:g,label:v,colorize:S,splat:w}=m;Object.values(this.instances).forEach(y=>{y&&"format"in y&&(y.level=c,y.format=h(S(),w(),v({label:mS}),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"&&Fc&&(Fc.DEBUG=t?t===!0?"2":String(t):"0")}static setFormat(t){this.currentFormat=t,this.configure({format:t})}},Ge(yo,"Logger"),Nh(yo,"instances",{}),Nh(yo,"simpleInstances",{}),Nh(yo,"currentFormat","minimal"),yo);db()&&(m2(),Aa&&g2.configure());var Re=g2.get();const b2=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 v2=Symbol("zod_brand");class kl extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class gv extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const fb={};function Qr(e){return e&&Object.assign(fb,e),fb}function wq(e){return e}function xq(e){return e}function Sq(e){}function Eq(e){throw new Error}function _q(e){}function v_(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 Pe(e,t="|"){return e.map(n=>ct(n)).join(t)}function pb(e,t){return typeof t=="bigint"?t.toString():t}function Np(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function Hl(e){return e==null}function bv(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function y2(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 v$=Symbol("evaluating");function Ht(e,t,n){let a;Object.defineProperty(e,t,{get(){if(a!==v$)return a===void 0&&(a=v$,a=n()),a},set(r){Object.defineProperty(e,t,{value:r})},configurable:!0})}function kq(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 Mo(...e){const t={};for(const n of e){const a=Object.getOwnPropertyDescriptors(n);Object.assign(t,a)}return Object.defineProperties({},t)}function Tq(e){return Mo(e._zod.def)}function Nq(e,t){return t?t.reduce((n,a)=>n?.[a],e):e}function Cq(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 Rq(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 hS(e){return JSON.stringify(e)}function w2(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const y_="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Ru(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const x2=Np(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function Al(e){if(Ru(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(Ru(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function vv(e){return Al(e)?{...e}:Array.isArray(e)?[...e]:e}function Aq(e){let t=0;for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&t++;return t}const Iq=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}`)}},mb=new Set(["string","number","symbol"]),S2=new Set(["string","number","bigint","boolean","symbol","undefined"]);function Ro(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 Ae(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 Oq(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 ct(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function E2(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const _2={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]},k2={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function T2(e,t){const n=e._zod.def,a=Mo(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 N2(e,t){const n=e._zod.def,a=Mo(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 C2(e,t){if(!Al(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=Mo(e._zod.def,{get shape(){const i={...e._zod.def.shape,...t};return $s(this,"shape",i),i},checks:[]});return ei(e,r)}function R2(e,t){if(!Al(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 A2(e,t){const n=Mo(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 I2(e,t,n){const a=Mo(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 O2(e,t,n){const a=Mo(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 yl(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 vf(e){return typeof e=="string"?e:e?.message}function vi(e,t,n){const a={...e,path:e.path??[]};if(!e.message){const r=vf(e.inst?._zod.def?.error?.(e))??vf(t?.error?.(e))??vf(n.customError?.(e))??vf(n.localeError?.(e))??"Invalid input";a.message=r}return delete a.inst,delete a.continue,t?.reportInput||delete a.input,a}function yv(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}function wv(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Au(...e){const[t,n,a]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:a}:{...t}}function Dq(e){return Object.entries(e).filter(([t,n])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function D2(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 j2(e){let t="";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}function jq(e){const t=e.replace(/-/g,"+").replace(/_/g,"/"),n="=".repeat((4-t.length%4)%4);return D2(t+n)}function Lq(e){return j2(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function $q(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 Mq(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}class Pq{constructor(...t){}}const L2=Object.freeze(Object.defineProperty({__proto__:null,BIGINT_FORMAT_RANGES:k2,Class:Pq,NUMBER_FORMAT_RANGES:_2,aborted:yl,allowsEval:x2,assert:_q,assertEqual:wq,assertIs:Sq,assertNever:Eq,assertNotEqual:xq,assignProp:$s,base64ToUint8Array:D2,base64urlToUint8Array:jq,cached:Np,captureStackTrace:y_,cleanEnum:Dq,cleanRegex:bv,clone:ei,cloneDef:Tq,createTransparentProxy:Oq,defineLazy:Ht,esc:hS,escapeRegex:Ro,extend:C2,finalizeIssue:vi,floatSafeRemainder:y2,getElementAtPath:Nq,getEnumValues:v_,getLengthableOrigin:wv,getParsedType:Iq,getSizableOrigin:yv,hexToUint8Array:$q,isObject:Ru,isPlainObject:Al,issue:Au,joinValues:Pe,jsonStringifyReplacer:pb,merge:A2,mergeDefs:Mo,normalizeParams:Ae,nullish:Hl,numKeys:Aq,objectClone:kq,omit:N2,optionalKeys:E2,partial:I2,pick:T2,prefixIssues:pi,primitiveTypes:S2,promiseAllObject:Cq,propertyKeyTypes:mb,randomString:Rq,required:O2,safeExtend:R2,shallowClone:vv,slugify:w2,stringifyPrimitive:ct,uint8ArrayToBase64:j2,uint8ArrayToBase64url:Lq,uint8ArrayToHex:Mq,unwrapMessage:vf},Symbol.toStringTag,{value:"Module"})),$2=(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,pb,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},w_=me("$ZodError",$2),La=me("$ZodError",$2,{Parent:Error});function x_(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 S_(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 M2(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 P2(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 U2(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 ${P2(a.path)}`);return t.join(`
3
3
  `)}const Cp=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 kl;if(s.issues.length){const c=new(r?.Err??e)(s.issues.map(u=>vi(u,i,Qr())));throw y_(c,r?.callee),c}return s.value},gS=Cp(La),Rp=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=>vi(u,i,Qr())));throw y_(c,r?.callee),c}return s.value},bS=Rp(La),Ap=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 kl;return i.issues.length?{success:!1,error:new(e??w_)(i.issues.map(s=>vi(s,r,Qr())))}:{success:!0,data:i.value}},E_=Ap(La),Ip=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=>vi(s,r,Qr())))}:{success:!0,data:i.value}},z2=Ip(La),__=e=>(t,n,a)=>{const r=a?Object.assign(a,{direction:"backward"}):{direction:"backward"};return Cp(e)(t,n,r)},Uq=__(La),k_=e=>(t,n,a)=>Cp(e)(t,n,a),zq=k_(La),T_=e=>async(t,n,a)=>{const r=a?Object.assign(a,{direction:"backward"}):{direction:"backward"};return Rp(e)(t,n,r)},Fq=T_(La),N_=e=>async(t,n,a)=>Rp(e)(t,n,a),Bq=N_(La),C_=e=>(t,n,a)=>{const r=a?Object.assign(a,{direction:"backward"}):{direction:"backward"};return Ap(e)(t,n,r)},Hq=C_(La),R_=e=>(t,n,a)=>Ap(e)(t,n,a),Vq=R_(La),A_=e=>async(t,n,a)=>{const r=a?Object.assign(a,{direction:"backward"}):{direction:"backward"};return Ip(e)(t,n,r)},Gq=A_(La),I_=e=>async(t,n,a)=>Ip(e)(t,n,a),Wq=I_(La),F2=/^[cC][^\s-]{8,}$/,B2=/^[0-9a-z]+$/,H2=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,V2=/^[0-9a-vA-V]{20}$/,G2=/^[A-Za-z0-9]{27}$/,W2=/^[a-zA-Z0-9_-]{21}$/,K2=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Kq=/^[-+]?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)?)??$/,Z2=/^([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})$/,Iu=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)$/,Zq=Iu(4),Yq=Iu(6),qq=Iu(7),Y2=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Xq=/^[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])?)*$/,Jq=/^(([^<>()\[\]\\.,;:\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,}))$/,q2=/^[^\s@"]{1,64}@[^\s@]{1,255}$/u,Qq=q2,eX=/^[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])?)*$/,tX="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function X2(){return new RegExp(tX,"u")}const J2=/^(?:(?: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])$/,Q2=/^(([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}|:))$/,eF=e=>{const t=Ro(e??":");return new RegExp(`^(?:[0-9A-F]{2}${t}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${t}){5}[0-9a-f]{2}$`)},tF=/^((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])$/,nF=/^(([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])$/,rF=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,O_=/^[A-Za-z0-9_-]*$/,aF=/^(?=.{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])?)*\.?$/,iF=/^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/,oF=/^\+(?:[0-9]){6,14}[0-9]$/,sF="(?:(?:\\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])))",lF=new RegExp(`^${sF}$`);function cF(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 uF(e){return new RegExp(`^${cF(e)}$`)}function dF(e){const t=cF({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(`^${sF}T(?:${a})$`)}const fF=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},pF=/^-?\d+n?$/,mF=/^-?\d+$/,hF=/^-?\d+(?:\.\d+)?/,gF=/^(?:true|false)$/i,bF=/^null$/i,vF=/^undefined$/i,yF=/^[^A-Z]*$/,wF=/^[^a-z]*$/,xF=/^[0-9a-fA-F]*$/;function Op(e,t){return new RegExp(`^[A-Za-z0-9+/]{${e}}${t}$`)}function Dp(e){return new RegExp(`^[A-Za-z0-9_-]{${e}}$`)}const nX=/^[0-9a-fA-F]{32}$/,rX=Op(22,"=="),aX=Dp(22),iX=/^[0-9a-fA-F]{40}$/,oX=Op(27,"="),sX=Dp(27),lX=/^[0-9a-fA-F]{64}$/,cX=Op(43,"="),uX=Dp(43),dX=/^[0-9a-fA-F]{96}$/,fX=Op(64,""),pX=Dp(64),mX=/^[0-9a-fA-F]{128}$/,hX=Op(86,"=="),gX=Dp(86),D_=Object.freeze(Object.defineProperty({__proto__:null,base64:rF,base64url:O_,bigint:pF,boolean:gF,browserEmail:eX,cidrv4:tF,cidrv6:nF,cuid:F2,cuid2:B2,date:lF,datetime:dF,domain:iF,duration:K2,e164:oF,email:Y2,emoji:X2,extendedDuration:Kq,guid:Z2,hex:xF,hostname:aF,html5Email:Xq,idnEmail:Qq,integer:mF,ipv4:J2,ipv6:Q2,ksuid:G2,lowercase:yF,mac:eF,md5_base64:rX,md5_base64url:aX,md5_hex:nX,nanoid:W2,null:bF,number:hF,rfc5322Email:Jq,sha1_base64:oX,sha1_base64url:sX,sha1_hex:iX,sha256_base64:cX,sha256_base64url:uX,sha256_hex:lX,sha384_base64:fX,sha384_base64url:pX,sha384_hex:dX,sha512_base64:hX,sha512_base64url:gX,sha512_hex:mX,string:fF,time:uF,ulid:H2,undefined:vF,unicodeEmail:q2,uppercase:wF,uuid:Iu,uuid4:Zq,uuid6:Yq,uuid7:qq,xid:V2},Symbol.toStringTag,{value:"Module"})),Un=me("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),SF={number:"number",bigint:"bigint",object:"date"},j_=me("$ZodCheckLessThan",(e,t)=>{Un.init(e,t);const n=SF[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})}}),L_=me("$ZodCheckGreaterThan",(e,t)=>{Un.init(e,t);const n=SF[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})}}),EF=me("$ZodCheckMultipleOf",(e,t)=>{Un.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):y2(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})}}),_F=me("$ZodCheckNumberFormat",(e,t)=>{Un.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),a=n?"int":"number",[r,i]=_2[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=mF)}),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})}}),kF=me("$ZodCheckBigIntFormat",(e,t)=>{Un.init(e,t);const[n,a]=k2[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})}}),TF=me("$ZodCheckMaxSize",(e,t)=>{var n;Un.init(e,t),(n=e._zod.def).when??(n.when=a=>{const r=a.value;return!Hl(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:yv(r),code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),NF=me("$ZodCheckMinSize",(e,t)=>{var n;Un.init(e,t),(n=e._zod.def).when??(n.when=a=>{const r=a.value;return!Hl(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:yv(r),code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),CF=me("$ZodCheckSizeEquals",(e,t)=>{var n;Un.init(e,t),(n=e._zod.def).when??(n.when=a=>{const r=a.value;return!Hl(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:yv(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})}}),RF=me("$ZodCheckMaxLength",(e,t)=>{var n;Un.init(e,t),(n=e._zod.def).when??(n.when=a=>{const r=a.value;return!Hl(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=wv(r);a.issues.push({origin:s,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),AF=me("$ZodCheckMinLength",(e,t)=>{var n;Un.init(e,t),(n=e._zod.def).when??(n.when=a=>{const r=a.value;return!Hl(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=wv(r);a.issues.push({origin:s,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),IF=me("$ZodCheckLengthEquals",(e,t)=>{var n;Un.init(e,t),(n=e._zod.def).when??(n.when=a=>{const r=a.value;return!Hl(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=wv(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})}}),jp=me("$ZodCheckStringFormat",(e,t)=>{var n,a;Un.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=()=>{})}),OF=me("$ZodCheckRegex",(e,t)=>{jp.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})}}),DF=me("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=yF),jp.init(e,t)}),jF=me("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=wF),jp.init(e,t)}),LF=me("$ZodCheckIncludes",(e,t)=>{Un.init(e,t);const n=Ro(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})}}),$F=me("$ZodCheckStartsWith",(e,t)=>{Un.init(e,t);const n=new RegExp(`^${Ro(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})}}),MF=me("$ZodCheckEndsWith",(e,t)=>{Un.init(e,t);const n=new RegExp(`.*${Ro(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 y$(e,t,n){e.issues.length&&t.issues.push(...pi(n,e.issues))}const PF=me("$ZodCheckProperty",(e,t)=>{Un.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=>y$(r,n,t.property));y$(a,n,t.property)}}),UF=me("$ZodCheckMimeType",(e,t)=>{Un.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})}}),zF=me("$ZodCheckOverwrite",(e,t)=>{Un.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class FF{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 BF={major:4,minor:1,patch:13},bt=me("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=BF;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=yl(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 kl;if(m||v instanceof Promise)m=(m??Promise.resolve()).then(async()=>{await v,s.issues.length!==g&&(d||(d=yl(s,g)))});else{if(s.issues.length===g)continue;d||(d=yl(s,g))}}return m?m.then(()=>s):s},i=(s,c,u)=>{if(yl(s))return s.aborted=!0,s;const d=r(c,a,u);if(d instanceof Promise){if(u.async===!1)throw new kl;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 kl;return u.then(d=>r(d,a,c))}return r(u,a,c)}}e["~standard"]={validate:r=>{try{const i=E_(e,r);return i.success?{value:i.data}:{issues:i.error?.issues}}catch{return z2(e,r).then(s=>s.success?{value:s.data}:{issues:s.error?.issues})}},vendor:"zod",version:1}}),Lp=me("$ZodString",(e,t)=>{bt.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??fF(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}}),Tn=me("$ZodStringFormat",(e,t)=>{jp.init(e,t),Lp.init(e,t)}),HF=me("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Z2),Tn.init(e,t)}),VF=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=Iu(a))}else t.pattern??(t.pattern=Iu());Tn.init(e,t)}),GF=me("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Y2),Tn.init(e,t)}),WF=me("$ZodURL",(e,t)=>{Tn.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})}}}),KF=me("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=X2()),Tn.init(e,t)}),ZF=me("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=W2),Tn.init(e,t)}),YF=me("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=F2),Tn.init(e,t)}),qF=me("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=B2),Tn.init(e,t)}),XF=me("$ZodULID",(e,t)=>{t.pattern??(t.pattern=H2),Tn.init(e,t)}),JF=me("$ZodXID",(e,t)=>{t.pattern??(t.pattern=V2),Tn.init(e,t)}),QF=me("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=G2),Tn.init(e,t)}),e3=me("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=dF(t)),Tn.init(e,t)}),t3=me("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=lF),Tn.init(e,t)}),n3=me("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=uF(t)),Tn.init(e,t)}),r3=me("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=K2),Tn.init(e,t)}),a3=me("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=J2),Tn.init(e,t),e._zod.bag.format="ipv4"}),i3=me("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Q2),Tn.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})}}}),o3=me("$ZodMAC",(e,t)=>{t.pattern??(t.pattern=eF(t.delimiter)),Tn.init(e,t),e._zod.bag.format="mac"}),s3=me("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=tF),Tn.init(e,t)}),l3=me("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=nF),Tn.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 $_(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const c3=me("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=rF),Tn.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{$_(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function u3(e){if(!O_.test(e))return!1;const t=e.replace(/[-_]/g,a=>a==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return $_(n)}const d3=me("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=O_),Tn.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{u3(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),f3=me("$ZodE164",(e,t)=>{t.pattern??(t.pattern=oF),Tn.init(e,t)});function p3(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 m3=me("$ZodJWT",(e,t)=>{Tn.init(e,t),e._zod.check=n=>{p3(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),h3=me("$ZodCustomStringFormat",(e,t)=>{Tn.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})}}),M_=me("$ZodNumber",(e,t)=>{bt.init(e,t),e._zod.pattern=e._zod.bag.pattern??hF,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}}),g3=me("$ZodNumberFormat",(e,t)=>{_F.init(e,t),M_.init(e,t)}),P_=me("$ZodBoolean",(e,t)=>{bt.init(e,t),e._zod.pattern=gF,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}}),U_=me("$ZodBigInt",(e,t)=>{bt.init(e,t),e._zod.pattern=pF,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}}),b3=me("$ZodBigIntFormat",(e,t)=>{kF.init(e,t),U_.init(e,t)}),v3=me("$ZodSymbol",(e,t)=>{bt.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}}),y3=me("$ZodUndefined",(e,t)=>{bt.init(e,t),e._zod.pattern=vF,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}}),w3=me("$ZodNull",(e,t)=>{bt.init(e,t),e._zod.pattern=bF,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}}),x3=me("$ZodAny",(e,t)=>{bt.init(e,t),e._zod.parse=n=>n}),S3=me("$ZodUnknown",(e,t)=>{bt.init(e,t),e._zod.parse=n=>n}),E3=me("$ZodNever",(e,t)=>{bt.init(e,t),e._zod.parse=(n,a)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)}),_3=me("$ZodVoid",(e,t)=>{bt.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}}),k3=me("$ZodDate",(e,t)=>{bt.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 w$(e,t,n){e.issues.length&&t.issues.push(...pi(n,e.issues)),t.value[n]=e.value}const T3=me("$ZodArray",(e,t)=>{bt.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=>w$(d,n,s))):w$(u,n,s)}return i.length?Promise.all(i).then(()=>n):n}});function hb(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 N3(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=E2(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function C3(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=>hb(g,n,m,t))):hb(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 R3=me("$ZodObject",(e,t)=>{if(bt.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=Np(()=>N3(t));Ht(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=Ru,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 S=h[g]._zod.run({value:d[g],issues:[]},u);S instanceof Promise?m.push(S.then(w=>hb(w,c,g,d))):hb(S,c,g,d)}return i?C3(m,d,c,u,a.value,e):m.length?Promise.all(m).then(()=>c):c}}),A3=me("$ZodObjectJIT",(e,t)=>{R3.init(e,t);const n=e._zod.parse,a=Np(()=>N3(t)),r=g=>{const v=new FF(["shape","payload","ctx"]),S=a.value,w=k=>{const R=hS(k);return`shape[${R}]._zod.run({ value: input[${R}], issues: [] }, ctx)`};v.write("const input = payload.value;");const y=Object.create(null);let _=0;for(const k of S.keys)y[k]=`key_${_++}`;v.write("const newResult = {};");for(const k of S.keys){const R=y[k],C=hS(k);v.write(`const ${R} = ${w(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(kT,"onMcpAuthorization");var fx={exports:{}},gt={};var dP;function Mae(){if(dP)return gt;dP=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(j){return j===null||typeof j!="object"?null:(j=g&&j[g]||j["@@iterator"],typeof j=="function"?j:null)}var S={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},w=Object.assign,y={};function _(j,V,z){this.props=j,this.context=V,this.refs=y,this.updater=z||S}_.prototype.isReactComponent={},_.prototype.setState=function(j,V){if(typeof j!="object"&&typeof j!="function"&&j!=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,j,V,"setState")},_.prototype.forceUpdate=function(j){this.updater.enqueueForceUpdate(this,j,"forceUpdate")};function E(){}E.prototype=_.prototype;function k(j,V,z){this.props=j,this.context=V,this.refs=y,this.updater=z||S}var R=k.prototype=new E;R.constructor=k,w(R,_.prototype),R.isPureReactComponent=!0;var C=Array.isArray;function I(){}var A={H:null,A:null,T:null,S:null},O=Object.prototype.hasOwnProperty;function M(j,V,z){var L=z.ref;return{$$typeof:e,type:j,key:V,ref:L!==void 0?L:null,props:z}}function U(j,V){return M(j.type,V,j.props)}function H(j){return typeof j=="object"&&j!==null&&j.$$typeof===e}function K(j){var V={"=":"=0",":":"=2"};return"$"+j.replace(/[=:]/g,function(z){return V[z]})}var ee=/\/+/g;function J(j,V){return typeof j=="object"&&j!==null&&j.key!=null?K(""+j.key):V.toString(36)}function ie(j){switch(j.status){case"fulfilled":return j.value;case"rejected":throw j.reason;default:switch(typeof j.status=="string"?j.then(I,I):(j.status="pending",j.then(function(V){j.status==="pending"&&(j.status="fulfilled",j.value=V)},function(V){j.status==="pending"&&(j.status="rejected",j.reason=V)})),j.status){case"fulfilled":return j.value;case"rejected":throw j.reason}}throw j}function B(j,V,z,L,$){var F=typeof j;(F==="undefined"||F==="boolean")&&(j=null);var W=!1;if(j===null)W=!0;else switch(F){case"bigint":case"string":case"number":W=!0;break;case"object":switch(j.$$typeof){case e:case t:W=!0;break;case m:return W=j._init,B(W(j._payload),V,z,L,$)}}if(W)return $=$(j),W=L===""?"."+J(j,0):L,C($)?(z="",W!=null&&(z=W.replace(ee,"$&/")+"/"),B($,V,z,"",function(le){return le})):$!=null&&(H($)&&($=U($,z+($.key==null||j&&j.key===$.key?"":(""+$.key).replace(ee,"$&/")+"/")+W)),V.push($)),1;W=0;var X=L===""?".":L+":";if(C(j))for(var ae=0;ae<j.length;ae++)L=j[ae],F=X+J(L,ae),W+=B(L,V,z,F,$);else if(ae=v(j),typeof ae=="function")for(j=ae.call(j),ae=0;!(L=j.next()).done;)L=L.value,F=X+J(L,ae++),W+=B(L,V,z,F,$);else if(F==="object"){if(typeof j.then=="function")return B(ie(j),V,z,L,$);throw V=String(j),Error("Objects are not valid as a React child (found: "+(V==="[object Object]"?"object with keys {"+Object.keys(j).join(", ")+"}":V)+"). If you meant to render a collection of children, use an array instead.")}return W}function Z(j,V,z){if(j==null)return j;var L=[],$=0;return B(j,L,"","",function(F){return V.call(z,F,$++)}),L}function G(j){if(j._status===-1){var V=j._result;V=V(),V.then(function(z){(j._status===0||j._status===-1)&&(j._status=1,j._result=z)},function(z){(j._status===0||j._status===-1)&&(j._status=2,j._result=z)}),j._status===-1&&(j._status=0,j._result=V)}if(j._status===1)return j._result.default;throw j._result}var re=typeof reportError=="function"?reportError:function(j){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var V=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof j=="object"&&j!==null&&typeof j.message=="string"?String(j.message):String(j),error:j});if(!window.dispatchEvent(V))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",j);return}console.error(j)},ne={map:Z,forEach:function(j,V,z){Z(j,function(){V.apply(this,arguments)},z)},count:function(j){var V=0;return Z(j,function(){V++}),V},toArray:function(j){return Z(j,function(V){return V})||[]},only:function(j){if(!H(j))throw Error("React.Children.only expected to receive a single React element child.");return j}};return gt.Activity=h,gt.Children=ne,gt.Component=_,gt.Fragment=n,gt.Profiler=r,gt.PureComponent=k,gt.StrictMode=a,gt.Suspense=u,gt.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=A,gt.__COMPILER_RUNTIME={__proto__:null,c:function(j){return A.H.useMemoCache(j)}},gt.cache=function(j){return function(){return j.apply(null,arguments)}},gt.cacheSignal=function(){return null},gt.cloneElement=function(j,V,z){if(j==null)throw Error("The argument must be a React element, but you passed "+j+".");var L=w({},j.props),$=j.key;if(V!=null)for(F in V.key!==void 0&&($=""+V.key),V)!O.call(V,F)||F==="key"||F==="__self"||F==="__source"||F==="ref"&&V.ref===void 0||(L[F]=V[F]);var F=arguments.length-2;if(F===1)L.children=z;else if(1<F){for(var W=Array(F),X=0;X<F;X++)W[X]=arguments[X+2];L.children=W}return M(j.type,$,L)},gt.createContext=function(j){return j={$$typeof:s,_currentValue:j,_currentValue2:j,_threadCount:0,Provider:null,Consumer:null},j.Provider=j,j.Consumer={$$typeof:i,_context:j},j},gt.createElement=function(j,V,z){var L,$={},F=null;if(V!=null)for(L in V.key!==void 0&&(F=""+V.key),V)O.call(V,L)&&L!=="key"&&L!=="__self"&&L!=="__source"&&($[L]=V[L]);var W=arguments.length-2;if(W===1)$.children=z;else if(1<W){for(var X=Array(W),ae=0;ae<W;ae++)X[ae]=arguments[ae+2];$.children=X}if(j&&j.defaultProps)for(L in W=j.defaultProps,W)$[L]===void 0&&($[L]=W[L]);return M(j,F,$)},gt.createRef=function(){return{current:null}},gt.forwardRef=function(j){return{$$typeof:c,render:j}},gt.isValidElement=H,gt.lazy=function(j){return{$$typeof:m,_payload:{_status:-1,_result:j},_init:G}},gt.memo=function(j,V){return{$$typeof:d,type:j,compare:V===void 0?null:V}},gt.startTransition=function(j){var V=A.T,z={};A.T=z;try{var L=j(),$=A.S;$!==null&&$(z,L),typeof L=="object"&&L!==null&&typeof L.then=="function"&&L.then(I,re)}catch(F){re(F)}finally{V!==null&&z.types!==null&&(V.types=z.types),A.T=V}},gt.unstable_useCacheRefresh=function(){return A.H.useCacheRefresh()},gt.use=function(j){return A.H.use(j)},gt.useActionState=function(j,V,z){return A.H.useActionState(j,V,z)},gt.useCallback=function(j,V){return A.H.useCallback(j,V)},gt.useContext=function(j){return A.H.useContext(j)},gt.useDebugValue=function(){},gt.useDeferredValue=function(j,V){return A.H.useDeferredValue(j,V)},gt.useEffect=function(j,V){return A.H.useEffect(j,V)},gt.useEffectEvent=function(j){return A.H.useEffectEvent(j)},gt.useId=function(){return A.H.useId()},gt.useImperativeHandle=function(j,V,z){return A.H.useImperativeHandle(j,V,z)},gt.useInsertionEffect=function(j,V){return A.H.useInsertionEffect(j,V)},gt.useLayoutEffect=function(j,V){return A.H.useLayoutEffect(j,V)},gt.useMemo=function(j,V){return A.H.useMemo(j,V)},gt.useOptimistic=function(j,V){return A.H.useOptimistic(j,V)},gt.useReducer=function(j,V,z){return A.H.useReducer(j,V,z)},gt.useRef=function(j){return A.H.useRef(j)},gt.useState=function(j){return A.H.useState(j)},gt.useSyncExternalStore=function(j,V,z){return A.H.useSyncExternalStore(j,V,z)},gt.useTransition=function(){return A.H.useTransition()},gt.version="19.2.0",gt}var fP;function TT(){return fP||(fP=1,fx.exports=Mae()),fx.exports}var x=TT();const ue=Tp(x),Zu=pq({__proto__:null,default:ue},[x]);function GS(e,t){if(!e)throw new Error(t)}Ge(GS,"assert");var Pae=3e3,Uae=5e3;function NT(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=Pae,transportType:g="auto",preventAutoAuth:v=!1,useRedirectFlow:S=!1,onPopupWindow:w,timeout:y=3e4,sseReadTimeout:_=3e5,wrapTransport:E,onNotification:k,samplingCallback:R,onElicitation:C}=e,[I,A]=x.useState("discovering"),[O,M]=x.useState([]),[U,H]=x.useState([]),[K,ee]=x.useState([]),[J,ie]=x.useState([]),[B,Z]=x.useState(),[G,re]=x.useState(),[ne,j]=x.useState(void 0),[V,z]=x.useState([]),[L,$]=x.useState(void 0),F=x.useRef(null),W=x.useRef(null),X=x.useRef(!1),ae=x.useRef(!0),le=x.useRef(0),Q=x.useRef(null),q=x.useRef(I),se=x.useRef(h),he=x.useRef(null);x.useEffect(()=>{q.current=I,se.current=h},[I,h]);const ce=x.useCallback((Le,ze,...ht)=>{const Qe=ht.length>0?`${ze} ${ht.map(Rt=>JSON.stringify(Rt)).join(" ")}`:ze;console[Le](`[useMcp] ${Qe}`),ae.current&&z(Rt=>[...Rt.slice(-100),{level:Le,message:Qe,timestamp:Date.now()}])},[]),ke=x.useCallback(async(Le=!1)=>{if(Le||ce("info","Disconnecting..."),X.current=!1,Q.current&&clearTimeout(Q.current),Q.current=null,F.current)try{await F.current.closeSession("inspector-server")}catch(ze){Le||ce("warn","Error closing session:",ze)}F.current=null,ae.current&&!Le&&(A("discovering"),M([]),H([]),ee([]),ie([]),j(void 0),$(void 0))},[ce]),He=x.useCallback((Le,ze)=>{if(ce("error",Le,ze??""),ae.current){A("failed"),j(Le);const ht=W.current?.getLastAttemptedAuthUrl();ht&&($(ht),ce("info","Manual authentication URL may be available.",ht))}X.current=!1},[ce]),Se=x.useCallback(async()=>{if(!n||!t){ce("debug",n?"No server URL provided, skipping connection.":"Connection disabled via enabled flag.");return}if(X.current){ce("debug","Connection attempt already in progress.");return}if(!ae.current){ce("debug","Connect called after unmount, aborting.");return}X.current=!0,le.current+=1,j(void 0),$(void 0),he.current=null,A("discovering"),ce("info",`Connecting attempt #${le.current} to ${t}...`),W.current||(W.current=new Wg(t,{storageKeyPrefix:s,clientName:a,clientUri:r,callbackUrl:i,preventAutoAuth:v,useRedirectFlow:S,onPopupWindow:w}),ce("debug","BrowserOAuthClientProvider initialized in connect.")),F.current||(F.current=new $ae,ce("debug","BrowserMCPClient initialized in connect."));const Le=Ge(async(ht,Qe=!1)=>{ce("info",`Attempting connection with transport: ${ht}`);try{const Rt="inspector-server",rt={url:t,transport:ht==="sse"?"http":ht};if(u&&Object.keys(u).length>0&&(rt.headers=u),W.current){const wt=await W.current.tokens();wt?.access_token&&(rt.headers={...rt.headers,Authorization:`Bearer ${wt.access_token}`})}F.current.addServer(Rt,{...rt,authProvider:W.current,clientOptions:c,samplingCallback:R,elicitationCallback:C,wrapTransport:E?wt=>(console.log("[useMcp] Applying transport wrapper for server:",Rt,"url:",t),E(wt,t)):void 0});const Oe=await F.current.createSession(Rt,!1);k&&Oe.on("notification",k),await Oe.initialize(),ce("info","✅ Successfully connected to MCP server"),ce("info","Server info:",Oe.connector.serverInfo),ce("info","Server capabilities:",Oe.connector.serverCapabilities),console.log("[useMcp] Server info:",Oe.connector.serverInfo),console.log("[useMcp] Server capabilities:",Oe.connector.serverCapabilities),A("ready"),he.current=ht,M(Oe.connector.tools||[]);const $e=await Oe.connector.listAllResources();H($e.resources||[]);const Be=await Oe.connector.listPrompts();ie(Be.prompts||[]);const ut=Oe.connector.serverInfo,dt=Oe.connector.serverCapabilities;return ut&&(console.log("[useMcp] Server info:",ut),Z(ut)),dt&&(console.log("[useMcp] Server capabilities:",dt),re(dt)),"success"}catch(Rt){const rt=Rt?.message||String(Rt);if(Rt.code===401||rt.includes("401")||rt.includes("Unauthorized")){if(W.current){ce("info","Authentication required. OAuth provider available.");try{const{auth:Oe}=await dr(async()=>{const{auth:Be}=await Promise.resolve().then(()=>rP);return{auth:Be}},void 0),$e=new URL(t).origin;Oe(W.current,{serverUrl:$e}).catch(()=>{}),setTimeout(()=>{if(ae.current){const Be=W.current?.getLastAttemptedAuthUrl();Be?($(Be),ce("info","Manual authentication URL available:",Be)):ce("warn","Could not generate authentication URL")}},100)}catch(Oe){ce("warn","Error generating auth URL:",Oe)}return ae.current&&A("pending_auth"),X.current=!1,"auth_redirect"}return u&&Object.keys(u).length>0?(He("Authentication failed: Server returned 401 Unauthorized. Check your Authorization header value is correct."),"failed"):(He("Authentication required: Server returned 401 Unauthorized. Add an Authorization header in the Custom Headers section (e.g., Authorization: Bearer YOUR_API_KEY)."),"failed")}return He(rt,Rt),"failed"}},"tryConnectWithTransport");let ze="failed";if(g==="sse")ce("debug","Using SSE-only transport mode"),ze=await Le("sse");else if(g==="http")ce("debug","Using HTTP-only transport mode"),ze=await Le("http");else{ce("debug","Using auto transport mode (HTTP with SSE fallback)");const ht=await Le("http");ht==="fallback"&&ae.current&&q.current!=="authenticating"?(ce("info","HTTP failed, attempting SSE fallback..."),ze=await Le("sse")):ze=ht}(ze==="success"||ze==="failed"||ze==="auth_redirect")&&(X.current=!1),ce("debug",`Connection sequence finished with status: ${ze}`)},[ce,He,ke,t,s,a,r,i,c.name,c.version,u,g,v,S,w,n,y,_]),_e=x.useCallback(async(Le,ze,ht)=>{if(q.current!=="ready"||!F.current)throw new Error(`MCP client is not ready (current state: ${I}). Cannot call tool "${Le}".`);ce("info",`Calling tool: ${Le}`,ze);try{const Rt=F.current.getSession("inspector-server");if(!Rt)throw new Error("No active session found");const rt=await Rt.connector.callTool(Le,ze||{},ht);return ce("info",`Tool "${Le}" call successful:`,rt),rt}catch(Qe){throw ce("error",`Tool "${Le}" call failed:`,Qe),Qe}},[I]),Ue=x.useCallback(()=>{q.current==="failed"?(ce("info","Retry requested..."),Se()):ce("warn",`Retry called but state is not 'failed' (state: ${q.current}). Ignoring.`)},[ce,Se]),fe=x.useCallback(async()=>{ce("info","Manual authentication requested...");const Le=q.current;if(Le==="failed")ce("info","Attempting to reconnect and authenticate via retry..."),Ue();else if(Le==="pending_auth"){ce("info","Proceeding with authentication from pending state...");try{GS(W.current,"Auth Provider not available for manual auth"),GS(t,"Server URL is required for authentication"),ce("info","Clearing all OAuth state and initiating fresh flow...");const ze=`${s}:${W.current.serverUrlHash}`;Object.keys(localStorage).forEach(rt=>{rt.startsWith(ze)&&(ce("debug",`Removing stale OAuth key: ${rt}`),localStorage.removeItem(rt)),rt.startsWith(`${s}:state_`)&&(ce("debug",`Removing orphaned state: ${rt}`),localStorage.removeItem(rt))}),A("authenticating");const ht=new Wg(t,{storageKeyPrefix:s,clientName:a,clientUri:r,callbackUrl:i,preventAutoAuth:!1,useRedirectFlow:S,onPopupWindow:w});W.current=ht,ce("info","Triggering fresh OAuth authorization...");const{auth:Qe}=await dr(async()=>{const{auth:rt}=await Promise.resolve().then(()=>rP);return{auth:rt}},void 0),Rt=new URL(t).origin;Qe(ht,{serverUrl:Rt}).catch(rt=>{ce("info","OAuth flow initiated:",rt?.message||"Redirecting...")})}catch(ze){if(!ae.current)return;A("pending_auth"),ce("error",`Manual authentication failed: ${ze instanceof Error?ze.message:String(ze)}`)}}else if(Le==="authenticating"){ce("warn","Already attempting authentication. Check for blocked popups or wait for timeout.");const ze=W.current?.getLastAttemptedAuthUrl();ze&&!L&&($(ze),ce("info","Manual authentication URL retrieved:",ze))}else ce("info",`Client not in a state requiring manual authentication trigger (state: ${Le}). If needed, try disconnecting and reconnecting.`)},[ce,Ue,L,t,S,w,s,a,r,i]),Ie=x.useCallback(()=>{if(W.current){const Le=W.current.clearStorage();ce("info",`Cleared ${Le} item(s) from localStorage for ${t}.`),$(void 0),ke()}else ce("warn","Auth provider not initialized, cannot clear storage.")},[t,ce,ke]),Fe=x.useCallback(async()=>{if(q.current!=="ready"||!F.current)throw new Error(`MCP client is not ready (current state: ${I}). Cannot list resources.`);ce("info","Listing resources");try{const ze=F.current.getSession("inspector-server");if(!ze)throw new Error("No active session found");const ht=await ze.connector.listAllResources();H(ht.resources||[]),ce("info","Resources listed successfully")}catch(Le){throw ce("error","List resources failed:",Le),Le}},[I]),xe=x.useCallback(async Le=>{if(q.current!=="ready"||!F.current)throw new Error(`MCP client is not ready (current state: ${I}). Cannot read resource.`);ce("info",`Reading resource: ${Le}`);try{const ht=F.current.getSession("inspector-server");if(!ht)throw new Error("No active session found");const Qe=await ht.connector.readResource(Le);return ce("info","Resource read successful:",Qe),Qe}catch(ze){throw ce("error","Resource read failed:",ze),ze}},[I]),it=x.useCallback(async()=>{if(q.current!=="ready"||!F.current)throw new Error(`MCP client is not ready (current state: ${I}). Cannot list prompts.`);ce("info","Listing prompts");try{const ze=F.current.getSession("inspector-server");if(!ze)throw new Error("No active session found");const ht=await ze.connector.listPrompts();ie(ht.prompts||[]),ce("info","Prompts listed successfully")}catch(Le){throw ce("error","List prompts failed:",Le),Le}},[I]),nt=x.useCallback(async(Le,ze)=>{if(q.current!=="ready"||!F.current)throw new Error(`MCP client is not ready (current state: ${I}). Cannot get prompt.`);ce("info",`Getting prompt: ${Le}`,ze);try{const Qe=F.current.getSession("inspector-server");if(!Qe)throw new Error("No active session found");const Rt=await Qe.connector.getPrompt(Le,ze||{});return ce("info",`Prompt "${Le}" retrieved successfully:`,Rt),Rt}catch(ht){throw ce("error",`Prompt "${Le}" retrieval failed:`,ht),ht}},[I]),mt=x.useRef(Se),Ct=x.useRef(He);return x.useEffect(()=>{mt.current=Se,Ct.current=He}),x.useEffect(()=>{const Le=Ge(ze=>{ze.origin===window.location.origin&&ze.data?.type==="mcp_auth_callback"&&(ce("info","Received auth callback message.",ze.data),Q.current&&clearTimeout(Q.current),Q.current=null,ze.data.success?(ce("info","Authentication successful via popup. Reconnecting client..."),X.current&&ce("debug","Connection attempt already in progress, resetting flag to allow reconnection."),X.current=!1,setTimeout(()=>{ae.current&&(ce("debug","Initiating reconnection after successful auth callback."),mt.current())},100)):Ct.current(`Authentication failed in callback: ${ze.data.error||"Unknown reason."}`))},"messageHandler");return window.addEventListener("message",Le),ce("debug","Auth callback message listener added."),()=>{window.removeEventListener("message",Le),ce("debug","Auth callback message listener removed."),Q.current&&clearTimeout(Q.current)}},[ce]),x.useEffect(()=>(ae.current=!0,!n||!t?(ce("debug",n?"No server URL provided, skipping connection.":"Connection disabled via enabled flag."),A("discovering"),()=>{ae.current=!1}):(ce("debug","useMcp mounted, initiating connection."),le.current=0,(!W.current||W.current.serverUrl!==t)&&(W.current=new Wg(t,{storageKeyPrefix:s,clientName:a,clientUri:r,callbackUrl:i,preventAutoAuth:v,useRedirectFlow:S,onPopupWindow:w}),ce("debug","BrowserOAuthClientProvider initialized/updated on mount/option change.")),Se(),()=>{ae.current=!1,ce("debug","useMcp unmounting, disconnecting."),ke(!0)})),[t,n,s,i,a,r,c.name,c.version,S]),x.useEffect(()=>{let Le=null;if(I==="failed"&&m&&le.current>0){const ze=typeof m=="number"?m:Uae;ce("info",`Connection failed, auto-retrying in ${ze}ms...`),Le=setTimeout(()=>{ae.current&&q.current==="failed"&&Ue()},ze)}return()=>{Le&&clearTimeout(Le)}},[I,m,Ue,ce]),{state:I,tools:O,resources:U,resourceTemplates:K,prompts:J,serverInfo:B,capabilities:G,error:ne,log:V,authUrl:L,client:F.current,callTool:_e,readResource:xe,listResources:Fe,listPrompts:it,getPrompt:nt,retry:Ue,disconnect:ke,authenticate:fe,clearStorage:Ie}}Ge(NT,"useMcp");var Cu,zae=(Cu=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(Cu,"ErrorBoundary"),Cu),jf="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(jf,n),()=>{typeof window<"u"&&window.removeEventListener(jf,n)}},()=>typeof window<"u"&&window.openai?window.openai[e]:void 0)}Ge(li,"useOpenAiGlobal");function Yu(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),M=Ge(()=>{typeof window<"u"&&window.openai&&(n(!0),clearInterval(O))},"handleSetGlobals");typeof window<"u"&&window.addEventListener(jf,M);const U=setTimeout(()=>{clearInterval(O),typeof window<"u"&&window.removeEventListener(jf,M)},5e3);return()=>{clearInterval(O),clearTimeout(U),typeof window<"u"&&window.removeEventListener(jf,M)}},[]);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"),S=li("userAgent"),w=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,M)=>{if(!window.openai?.callTool)throw new Error("window.openai.callTool is not available");return window.openai.callTool(O,M)},[]),R=x.useCallback(async O=>{if(!window.openai?.sendFollowUpMessage)throw new Error("window.openai.sendFollowUpMessage is not available");return window.openai.sendFollowUpMessage({prompt:O})},[]),C=x.useCallback(O=>{if(!window.openai?.openExternal)throw new Error("window.openai.openExternal is not available");window.openai.openExternal({href:O})},[]),I=x.useCallback(async O=>{if(!window.openai?.requestDisplayMode)throw new Error("window.openai.requestDisplayMode is not available");return window.openai.requestDisplayMode({mode:O})},[]),A=x.useCallback(async O=>{if(!window.openai?.setWidgetState)throw new Error("window.openai.setWidgetState is not available");const U=typeof O=="function"?O(d!==void 0?d:_):O;return E(U),window.openai.setWidgetState(U)},[d,_]);return{props:s||e||{},output:c??null,metadata:u??null,state:_,setState:A,theme:m||"light",displayMode:h||"inline",safeArea:g||{insets:{top:0,bottom:0,left:0,right:0}},maxHeight:v||600,userAgent:S||{device:{type:"desktop"},capabilities:{hover:!0,touch:!1}},locale:w||"en",mcp_url:y,callTool:k,sendFollowUpMessage:R,openExternal:C,requestDisplayMode:I,isAvailable:t}}Ge(Yu,"useWidget");function Fae(e){const{props:t}=Yu(e);return t}Ge(Fae,"useWidgetProps");function Bae(){const{theme:e}=Yu();return e}Ge(Bae,"useWidgetTheme");function Hae(e){const{state:t,setState:n}=Yu();return x.useEffect(()=>{t===null&&e!==void 0&&window.openai?.setWidgetState&&n(e)},[]),[t,n]}Ge(Hae,"useWidgetState");var pP=Ge(({children:e})=>{const{theme:t,isAvailable:n}=Yu();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 sH({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:S,userAgent:w,locale:y,isAvailable:_,callTool:E,sendFollowUpMessage:k,openExternal:R,requestDisplayMode:C,setState:I}=Yu(),[A,O]=x.useState(!1),[M,U]=x.useState(!1),H=x.useRef(null),K=x.useRef(null),[ee,J]=x.useState([]),[ie,B]=x.useState(""),[Z,G]=x.useState("get-my-city"),[re,ne]=x.useState("{}"),[j,V]=x.useState("Test follow-up message"),[z,L]=x.useState("https://docs.mcp-use.com"),$=g==="fullscreen"&&_,F=g==="pip"&&_,W=typeof window<"u"&&window.location.pathname.includes("/inspector/api/dev-widget/");x.useEffect(()=>{const xe=setTimeout(()=>{if(typeof window<"u"&&window.openai)try{const it=Object.keys(window.openai);J(it)}catch{J([])}else J([])},100);return()=>{clearTimeout(xe)}},[]);const X=h==="dark",ae=Ge(()=>{const xe=["absolute","z-[1000]","flex","gap-2","transition-opacity","duration-200","ease-in-out",A?"opacity-100":"opacity-0",A?"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 it=v?.insets?.top?Math.max(16,v.insets.top+8):16,nt=v?.insets?.right?Math.max(16,v.insets.right+8):16,mt=v?.insets?.bottom?Math.max(16,v.insets.bottom+8):16,Ct=v?.insets?.left?Math.max(16,v.insets.left+8):16,Le={};switch(n){case"top-left":Le.top=`${it}px`,Le.left=`${Ct}px`;break;case"top-center":Le.top=`${it}px`;break;case"top-right":Le.top=`${it}px`,Le.right=`${nt}px`;break;case"center-left":Le.left=`${Ct}px`;break;case"center-right":Le.right=`${nt}px`;break;case"bottom-left":Le.bottom=`${mt}px`,Le.left=`${Ct}px`;break;case"bottom-center":Le.bottom=`${mt}px`;break;case"bottom-right":Le.bottom=`${mt}px`,Le.right=`${nt}px`;break;default:Le.top=`${it}px`,Le.right=`${nt}px`;break}return Le},"getPositionOffsetStyles");x.useEffect(()=>{if(!a)return;const xe=Ge(()=>O(!0),"handleMouseEnter"),it=Ge(()=>O(!1),"handleMouseLeave");return a.addEventListener("mouseenter",xe),a.addEventListener("mouseleave",it),()=>{a.removeEventListener("mouseenter",xe),a.removeEventListener("mouseleave",it)}},[a]),x.useEffect(()=>{if(!M)return;const xe=Ge(it=>{K.current&&!K.current.contains(it.target)&&U(!1)},"handleClickOutside");return document.addEventListener("mousedown",xe),()=>{document.removeEventListener("mousedown",xe)}},[M]),x.useEffect(()=>(M?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[M]);const Q=Ge(()=>{U(!M)},"handleToggleOverlay"),q=Ge(async()=>{try{B("Calling tool...");const xe=re.trim()?JSON.parse(re):{},it=await E(Z,xe);B(`Success: ${JSON.stringify(it,null,2)}`)}catch(xe){B(`Error: ${xe.message}`)}},"handleCallTool"),se=Ge(async()=>{try{B("Sending follow-up message..."),await k(j),B("Follow-up message sent successfully")}catch(xe){B(`Error: ${xe.message}`)}},"handleSendFollowUpMessage"),he=Ge(()=>{try{R(z),B(`Opened external link: ${z}`)}catch(xe){B(`Error: ${xe.message}`)}},"handleOpenExternal"),ce=Ge(async xe=>{try{B(`Requesting display mode: ${xe}...`);const it=await C(xe);B(`Display mode granted: ${it.mode}`)}catch(it){B(`Error: ${it.message}`)}},"handleRequestDisplayMode"),ke=Ge(async()=>{try{const xe=m?{...m,debugTimestamp:new Date().toISOString()}:{debugTimestamp:new Date().toISOString()};B("Setting state..."),await I(xe),B(`State updated: ${JSON.stringify(xe,null,2)}`)}catch(xe){B(`Error: ${xe.message}`)}},"handleSetState"),He=Ge(async()=>{try{await C("fullscreen")}catch(xe){console.error("Failed to go fullscreen:",xe)}},"handleFullscreen"),Se=Ge(async()=>{try{await C("pip")}catch(xe){console.error("Failed to go pip:",xe)}},"handlePip"),_e=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"),Ue=Ge(({onClick:xe,label:it,children:nt})=>{const[mt,Ct]=x.useState(!1),Le=_e();return ue.createElement("button",{className:`p-2 ${X?"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 ${X?"shadow-[0_2px_8px_rgba(0,0,0,0.3)]":"shadow-[0_2px_8px_rgba(0,0,0,0.2)]"} relative`,onMouseEnter:()=>Ct(!0),onMouseLeave:()=>Ct(!1),onClick:xe,"aria-label":it},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"},nt),r&&ue.createElement("span",{className:`${Le.join(" ")} ${mt?"opacity-100":"opacity-0"}`},it))},"IconButton"),fe=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"),Ie=Ge(xe=>xe?`${xe.device?.type||"unknown"}`:"N/A","formatUserAgent"),Fe=Ge(xe=>{if(!xe?.insets)return"N/A";const{top:it,bottom:nt,left:mt,right:Ct}=xe.insets;return`T:${it} B:${nt} L:${mt} R:${Ct}`},"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:ae().join(" "),style:le()},!W&&ue.createElement(ue.Fragment,null,!$&&!F&&ue.createElement(ue.Fragment,null,(s===!0||s==="fullscreen")&&ue.createElement(Ue,{onClick:He,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(Ue,{onClick:Se,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(Ue,{onClick:Q,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),M&&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&&U(!1)}},ue.createElement("button",{onClick:()=>U(!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"},fe(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"},fe(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"},fe(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"},fe(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"},S,"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"},Ie(w))),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"},ee.length>0?ee.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:Z,onChange:xe=>G(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:re,onChange:xe=>ne(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:q,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:j,onChange:xe=>V(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:se,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:z,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:he,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:()=>ce("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:()=>ce("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:()=>ce("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:()=>B(""),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(sH,"WidgetControls");function lH(){if(typeof window>"u")return"/";const t=window.location.pathname.match(/^(\/inspector\/api\/dev-widget\/[^/]+)/);return t?t[1]:"/"}Ge(lH,"getBasename");var Vae=150,Gae=5;function Wae({children:e,debugger:t=!1,viewControls:n=!1,autoSize:a=!1}){const r=lH(),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,S]=x.useState(!0);x.useEffect(()=>{let E=!0;return(async()=>{try{const k=await dr(()=>import("./index-BEtxggmu.js"),[]);E&&(m(()=>k.BrowserRouter),S(!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(kT,"onMcpAuthorization");var fx={exports:{}},gt={};var dP;function Mae(){if(dP)return gt;dP=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(j){return j===null||typeof j!="object"?null:(j=g&&j[g]||j["@@iterator"],typeof j=="function"?j:null)}var S={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},w=Object.assign,y={};function _(j,V,z){this.props=j,this.context=V,this.refs=y,this.updater=z||S}_.prototype.isReactComponent={},_.prototype.setState=function(j,V){if(typeof j!="object"&&typeof j!="function"&&j!=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,j,V,"setState")},_.prototype.forceUpdate=function(j){this.updater.enqueueForceUpdate(this,j,"forceUpdate")};function E(){}E.prototype=_.prototype;function k(j,V,z){this.props=j,this.context=V,this.refs=y,this.updater=z||S}var R=k.prototype=new E;R.constructor=k,w(R,_.prototype),R.isPureReactComponent=!0;var C=Array.isArray;function I(){}var A={H:null,A:null,T:null,S:null},O=Object.prototype.hasOwnProperty;function M(j,V,z){var L=z.ref;return{$$typeof:e,type:j,key:V,ref:L!==void 0?L:null,props:z}}function U(j,V){return M(j.type,V,j.props)}function H(j){return typeof j=="object"&&j!==null&&j.$$typeof===e}function K(j){var V={"=":"=0",":":"=2"};return"$"+j.replace(/[=:]/g,function(z){return V[z]})}var ee=/\/+/g;function J(j,V){return typeof j=="object"&&j!==null&&j.key!=null?K(""+j.key):V.toString(36)}function ie(j){switch(j.status){case"fulfilled":return j.value;case"rejected":throw j.reason;default:switch(typeof j.status=="string"?j.then(I,I):(j.status="pending",j.then(function(V){j.status==="pending"&&(j.status="fulfilled",j.value=V)},function(V){j.status==="pending"&&(j.status="rejected",j.reason=V)})),j.status){case"fulfilled":return j.value;case"rejected":throw j.reason}}throw j}function B(j,V,z,L,$){var F=typeof j;(F==="undefined"||F==="boolean")&&(j=null);var W=!1;if(j===null)W=!0;else switch(F){case"bigint":case"string":case"number":W=!0;break;case"object":switch(j.$$typeof){case e:case t:W=!0;break;case m:return W=j._init,B(W(j._payload),V,z,L,$)}}if(W)return $=$(j),W=L===""?"."+J(j,0):L,C($)?(z="",W!=null&&(z=W.replace(ee,"$&/")+"/"),B($,V,z,"",function(le){return le})):$!=null&&(H($)&&($=U($,z+($.key==null||j&&j.key===$.key?"":(""+$.key).replace(ee,"$&/")+"/")+W)),V.push($)),1;W=0;var X=L===""?".":L+":";if(C(j))for(var ae=0;ae<j.length;ae++)L=j[ae],F=X+J(L,ae),W+=B(L,V,z,F,$);else if(ae=v(j),typeof ae=="function")for(j=ae.call(j),ae=0;!(L=j.next()).done;)L=L.value,F=X+J(L,ae++),W+=B(L,V,z,F,$);else if(F==="object"){if(typeof j.then=="function")return B(ie(j),V,z,L,$);throw V=String(j),Error("Objects are not valid as a React child (found: "+(V==="[object Object]"?"object with keys {"+Object.keys(j).join(", ")+"}":V)+"). If you meant to render a collection of children, use an array instead.")}return W}function Z(j,V,z){if(j==null)return j;var L=[],$=0;return B(j,L,"","",function(F){return V.call(z,F,$++)}),L}function G(j){if(j._status===-1){var V=j._result;V=V(),V.then(function(z){(j._status===0||j._status===-1)&&(j._status=1,j._result=z)},function(z){(j._status===0||j._status===-1)&&(j._status=2,j._result=z)}),j._status===-1&&(j._status=0,j._result=V)}if(j._status===1)return j._result.default;throw j._result}var re=typeof reportError=="function"?reportError:function(j){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var V=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof j=="object"&&j!==null&&typeof j.message=="string"?String(j.message):String(j),error:j});if(!window.dispatchEvent(V))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",j);return}console.error(j)},ne={map:Z,forEach:function(j,V,z){Z(j,function(){V.apply(this,arguments)},z)},count:function(j){var V=0;return Z(j,function(){V++}),V},toArray:function(j){return Z(j,function(V){return V})||[]},only:function(j){if(!H(j))throw Error("React.Children.only expected to receive a single React element child.");return j}};return gt.Activity=h,gt.Children=ne,gt.Component=_,gt.Fragment=n,gt.Profiler=r,gt.PureComponent=k,gt.StrictMode=a,gt.Suspense=u,gt.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=A,gt.__COMPILER_RUNTIME={__proto__:null,c:function(j){return A.H.useMemoCache(j)}},gt.cache=function(j){return function(){return j.apply(null,arguments)}},gt.cacheSignal=function(){return null},gt.cloneElement=function(j,V,z){if(j==null)throw Error("The argument must be a React element, but you passed "+j+".");var L=w({},j.props),$=j.key;if(V!=null)for(F in V.key!==void 0&&($=""+V.key),V)!O.call(V,F)||F==="key"||F==="__self"||F==="__source"||F==="ref"&&V.ref===void 0||(L[F]=V[F]);var F=arguments.length-2;if(F===1)L.children=z;else if(1<F){for(var W=Array(F),X=0;X<F;X++)W[X]=arguments[X+2];L.children=W}return M(j.type,$,L)},gt.createContext=function(j){return j={$$typeof:s,_currentValue:j,_currentValue2:j,_threadCount:0,Provider:null,Consumer:null},j.Provider=j,j.Consumer={$$typeof:i,_context:j},j},gt.createElement=function(j,V,z){var L,$={},F=null;if(V!=null)for(L in V.key!==void 0&&(F=""+V.key),V)O.call(V,L)&&L!=="key"&&L!=="__self"&&L!=="__source"&&($[L]=V[L]);var W=arguments.length-2;if(W===1)$.children=z;else if(1<W){for(var X=Array(W),ae=0;ae<W;ae++)X[ae]=arguments[ae+2];$.children=X}if(j&&j.defaultProps)for(L in W=j.defaultProps,W)$[L]===void 0&&($[L]=W[L]);return M(j,F,$)},gt.createRef=function(){return{current:null}},gt.forwardRef=function(j){return{$$typeof:c,render:j}},gt.isValidElement=H,gt.lazy=function(j){return{$$typeof:m,_payload:{_status:-1,_result:j},_init:G}},gt.memo=function(j,V){return{$$typeof:d,type:j,compare:V===void 0?null:V}},gt.startTransition=function(j){var V=A.T,z={};A.T=z;try{var L=j(),$=A.S;$!==null&&$(z,L),typeof L=="object"&&L!==null&&typeof L.then=="function"&&L.then(I,re)}catch(F){re(F)}finally{V!==null&&z.types!==null&&(V.types=z.types),A.T=V}},gt.unstable_useCacheRefresh=function(){return A.H.useCacheRefresh()},gt.use=function(j){return A.H.use(j)},gt.useActionState=function(j,V,z){return A.H.useActionState(j,V,z)},gt.useCallback=function(j,V){return A.H.useCallback(j,V)},gt.useContext=function(j){return A.H.useContext(j)},gt.useDebugValue=function(){},gt.useDeferredValue=function(j,V){return A.H.useDeferredValue(j,V)},gt.useEffect=function(j,V){return A.H.useEffect(j,V)},gt.useEffectEvent=function(j){return A.H.useEffectEvent(j)},gt.useId=function(){return A.H.useId()},gt.useImperativeHandle=function(j,V,z){return A.H.useImperativeHandle(j,V,z)},gt.useInsertionEffect=function(j,V){return A.H.useInsertionEffect(j,V)},gt.useLayoutEffect=function(j,V){return A.H.useLayoutEffect(j,V)},gt.useMemo=function(j,V){return A.H.useMemo(j,V)},gt.useOptimistic=function(j,V){return A.H.useOptimistic(j,V)},gt.useReducer=function(j,V,z){return A.H.useReducer(j,V,z)},gt.useRef=function(j){return A.H.useRef(j)},gt.useState=function(j){return A.H.useState(j)},gt.useSyncExternalStore=function(j,V,z){return A.H.useSyncExternalStore(j,V,z)},gt.useTransition=function(){return A.H.useTransition()},gt.version="19.2.0",gt}var fP;function TT(){return fP||(fP=1,fx.exports=Mae()),fx.exports}var x=TT();const ue=Tp(x),Zu=pq({__proto__:null,default:ue},[x]);function GS(e,t){if(!e)throw new Error(t)}Ge(GS,"assert");var Pae=3e3,Uae=5e3;function NT(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=Pae,transportType:g="auto",preventAutoAuth:v=!1,useRedirectFlow:S=!1,onPopupWindow:w,timeout:y=3e4,sseReadTimeout:_=3e5,wrapTransport:E,onNotification:k,samplingCallback:R,onElicitation:C}=e,[I,A]=x.useState("discovering"),[O,M]=x.useState([]),[U,H]=x.useState([]),[K,ee]=x.useState([]),[J,ie]=x.useState([]),[B,Z]=x.useState(),[G,re]=x.useState(),[ne,j]=x.useState(void 0),[V,z]=x.useState([]),[L,$]=x.useState(void 0),F=x.useRef(null),W=x.useRef(null),X=x.useRef(!1),ae=x.useRef(!0),le=x.useRef(0),Q=x.useRef(null),q=x.useRef(I),se=x.useRef(h),he=x.useRef(null);x.useEffect(()=>{q.current=I,se.current=h},[I,h]);const ce=x.useCallback((Le,ze,...ht)=>{const Qe=ht.length>0?`${ze} ${ht.map(Rt=>JSON.stringify(Rt)).join(" ")}`:ze;console[Le](`[useMcp] ${Qe}`),ae.current&&z(Rt=>[...Rt.slice(-100),{level:Le,message:Qe,timestamp:Date.now()}])},[]),ke=x.useCallback(async(Le=!1)=>{if(Le||ce("info","Disconnecting..."),X.current=!1,Q.current&&clearTimeout(Q.current),Q.current=null,F.current)try{await F.current.closeSession("inspector-server")}catch(ze){Le||ce("warn","Error closing session:",ze)}F.current=null,ae.current&&!Le&&(A("discovering"),M([]),H([]),ee([]),ie([]),j(void 0),$(void 0))},[ce]),He=x.useCallback((Le,ze)=>{if(ce("error",Le,ze??""),ae.current){A("failed"),j(Le);const ht=W.current?.getLastAttemptedAuthUrl();ht&&($(ht),ce("info","Manual authentication URL may be available.",ht))}X.current=!1},[ce]),Se=x.useCallback(async()=>{if(!n||!t){ce("debug",n?"No server URL provided, skipping connection.":"Connection disabled via enabled flag.");return}if(X.current){ce("debug","Connection attempt already in progress.");return}if(!ae.current){ce("debug","Connect called after unmount, aborting.");return}X.current=!0,le.current+=1,j(void 0),$(void 0),he.current=null,A("discovering"),ce("info",`Connecting attempt #${le.current} to ${t}...`),W.current||(W.current=new Wg(t,{storageKeyPrefix:s,clientName:a,clientUri:r,callbackUrl:i,preventAutoAuth:v,useRedirectFlow:S,onPopupWindow:w}),ce("debug","BrowserOAuthClientProvider initialized in connect.")),F.current||(F.current=new $ae,ce("debug","BrowserMCPClient initialized in connect."));const Le=Ge(async(ht,Qe=!1)=>{ce("info",`Attempting connection with transport: ${ht}`);try{const Rt="inspector-server",rt={url:t,transport:ht==="sse"?"http":ht};if(u&&Object.keys(u).length>0&&(rt.headers=u),W.current){const wt=await W.current.tokens();wt?.access_token&&(rt.headers={...rt.headers,Authorization:`Bearer ${wt.access_token}`})}F.current.addServer(Rt,{...rt,authProvider:W.current,clientOptions:c,samplingCallback:R,elicitationCallback:C,wrapTransport:E?wt=>(console.log("[useMcp] Applying transport wrapper for server:",Rt,"url:",t),E(wt,t)):void 0});const Oe=await F.current.createSession(Rt,!1);k&&Oe.on("notification",k),await Oe.initialize(),ce("info","✅ Successfully connected to MCP server"),ce("info","Server info:",Oe.connector.serverInfo),ce("info","Server capabilities:",Oe.connector.serverCapabilities),console.log("[useMcp] Server info:",Oe.connector.serverInfo),console.log("[useMcp] Server capabilities:",Oe.connector.serverCapabilities),A("ready"),he.current=ht,M(Oe.connector.tools||[]);const $e=await Oe.connector.listAllResources();H($e.resources||[]);const Be=await Oe.connector.listPrompts();ie(Be.prompts||[]);const ut=Oe.connector.serverInfo,dt=Oe.connector.serverCapabilities;return ut&&(console.log("[useMcp] Server info:",ut),Z(ut)),dt&&(console.log("[useMcp] Server capabilities:",dt),re(dt)),"success"}catch(Rt){const rt=Rt?.message||String(Rt);if(Rt.code===401||rt.includes("401")||rt.includes("Unauthorized")){if(W.current){ce("info","Authentication required. OAuth provider available.");try{const{auth:Oe}=await dr(async()=>{const{auth:Be}=await Promise.resolve().then(()=>rP);return{auth:Be}},void 0),$e=new URL(t).origin;Oe(W.current,{serverUrl:$e}).catch(()=>{}),setTimeout(()=>{if(ae.current){const Be=W.current?.getLastAttemptedAuthUrl();Be?($(Be),ce("info","Manual authentication URL available:",Be)):ce("warn","Could not generate authentication URL")}},100)}catch(Oe){ce("warn","Error generating auth URL:",Oe)}return ae.current&&A("pending_auth"),X.current=!1,"auth_redirect"}return u&&Object.keys(u).length>0?(He("Authentication failed: Server returned 401 Unauthorized. Check your Authorization header value is correct."),"failed"):(He("Authentication required: Server returned 401 Unauthorized. Add an Authorization header in the Custom Headers section (e.g., Authorization: Bearer YOUR_API_KEY)."),"failed")}return He(rt,Rt),"failed"}},"tryConnectWithTransport");let ze="failed";if(g==="sse")ce("debug","Using SSE-only transport mode"),ze=await Le("sse");else if(g==="http")ce("debug","Using HTTP-only transport mode"),ze=await Le("http");else{ce("debug","Using auto transport mode (HTTP with SSE fallback)");const ht=await Le("http");ht==="fallback"&&ae.current&&q.current!=="authenticating"?(ce("info","HTTP failed, attempting SSE fallback..."),ze=await Le("sse")):ze=ht}(ze==="success"||ze==="failed"||ze==="auth_redirect")&&(X.current=!1),ce("debug",`Connection sequence finished with status: ${ze}`)},[ce,He,ke,t,s,a,r,i,c.name,c.version,u,g,v,S,w,n,y,_]),_e=x.useCallback(async(Le,ze,ht)=>{if(q.current!=="ready"||!F.current)throw new Error(`MCP client is not ready (current state: ${I}). Cannot call tool "${Le}".`);ce("info",`Calling tool: ${Le}`,ze);try{const Rt=F.current.getSession("inspector-server");if(!Rt)throw new Error("No active session found");const rt=await Rt.connector.callTool(Le,ze||{},ht);return ce("info",`Tool "${Le}" call successful:`,rt),rt}catch(Qe){throw ce("error",`Tool "${Le}" call failed:`,Qe),Qe}},[I]),Ue=x.useCallback(()=>{q.current==="failed"?(ce("info","Retry requested..."),Se()):ce("warn",`Retry called but state is not 'failed' (state: ${q.current}). Ignoring.`)},[ce,Se]),fe=x.useCallback(async()=>{ce("info","Manual authentication requested...");const Le=q.current;if(Le==="failed")ce("info","Attempting to reconnect and authenticate via retry..."),Ue();else if(Le==="pending_auth"){ce("info","Proceeding with authentication from pending state...");try{GS(W.current,"Auth Provider not available for manual auth"),GS(t,"Server URL is required for authentication"),ce("info","Clearing all OAuth state and initiating fresh flow...");const ze=`${s}:${W.current.serverUrlHash}`;Object.keys(localStorage).forEach(rt=>{rt.startsWith(ze)&&(ce("debug",`Removing stale OAuth key: ${rt}`),localStorage.removeItem(rt)),rt.startsWith(`${s}:state_`)&&(ce("debug",`Removing orphaned state: ${rt}`),localStorage.removeItem(rt))}),A("authenticating");const ht=new Wg(t,{storageKeyPrefix:s,clientName:a,clientUri:r,callbackUrl:i,preventAutoAuth:!1,useRedirectFlow:S,onPopupWindow:w});W.current=ht,ce("info","Triggering fresh OAuth authorization...");const{auth:Qe}=await dr(async()=>{const{auth:rt}=await Promise.resolve().then(()=>rP);return{auth:rt}},void 0),Rt=new URL(t).origin;Qe(ht,{serverUrl:Rt}).catch(rt=>{ce("info","OAuth flow initiated:",rt?.message||"Redirecting...")})}catch(ze){if(!ae.current)return;A("pending_auth"),ce("error",`Manual authentication failed: ${ze instanceof Error?ze.message:String(ze)}`)}}else if(Le==="authenticating"){ce("warn","Already attempting authentication. Check for blocked popups or wait for timeout.");const ze=W.current?.getLastAttemptedAuthUrl();ze&&!L&&($(ze),ce("info","Manual authentication URL retrieved:",ze))}else ce("info",`Client not in a state requiring manual authentication trigger (state: ${Le}). If needed, try disconnecting and reconnecting.`)},[ce,Ue,L,t,S,w,s,a,r,i]),Ie=x.useCallback(()=>{if(W.current){const Le=W.current.clearStorage();ce("info",`Cleared ${Le} item(s) from localStorage for ${t}.`),$(void 0),ke()}else ce("warn","Auth provider not initialized, cannot clear storage.")},[t,ce,ke]),Fe=x.useCallback(async()=>{if(q.current!=="ready"||!F.current)throw new Error(`MCP client is not ready (current state: ${I}). Cannot list resources.`);ce("info","Listing resources");try{const ze=F.current.getSession("inspector-server");if(!ze)throw new Error("No active session found");const ht=await ze.connector.listAllResources();H(ht.resources||[]),ce("info","Resources listed successfully")}catch(Le){throw ce("error","List resources failed:",Le),Le}},[I]),xe=x.useCallback(async Le=>{if(q.current!=="ready"||!F.current)throw new Error(`MCP client is not ready (current state: ${I}). Cannot read resource.`);ce("info",`Reading resource: ${Le}`);try{const ht=F.current.getSession("inspector-server");if(!ht)throw new Error("No active session found");const Qe=await ht.connector.readResource(Le);return ce("info","Resource read successful:",Qe),Qe}catch(ze){throw ce("error","Resource read failed:",ze),ze}},[I]),it=x.useCallback(async()=>{if(q.current!=="ready"||!F.current)throw new Error(`MCP client is not ready (current state: ${I}). Cannot list prompts.`);ce("info","Listing prompts");try{const ze=F.current.getSession("inspector-server");if(!ze)throw new Error("No active session found");const ht=await ze.connector.listPrompts();ie(ht.prompts||[]),ce("info","Prompts listed successfully")}catch(Le){throw ce("error","List prompts failed:",Le),Le}},[I]),nt=x.useCallback(async(Le,ze)=>{if(q.current!=="ready"||!F.current)throw new Error(`MCP client is not ready (current state: ${I}). Cannot get prompt.`);ce("info",`Getting prompt: ${Le}`,ze);try{const Qe=F.current.getSession("inspector-server");if(!Qe)throw new Error("No active session found");const Rt=await Qe.connector.getPrompt(Le,ze||{});return ce("info",`Prompt "${Le}" retrieved successfully:`,Rt),Rt}catch(ht){throw ce("error",`Prompt "${Le}" retrieval failed:`,ht),ht}},[I]),mt=x.useRef(Se),Ct=x.useRef(He);return x.useEffect(()=>{mt.current=Se,Ct.current=He}),x.useEffect(()=>{const Le=Ge(ze=>{ze.origin===window.location.origin&&ze.data?.type==="mcp_auth_callback"&&(ce("info","Received auth callback message.",ze.data),Q.current&&clearTimeout(Q.current),Q.current=null,ze.data.success?(ce("info","Authentication successful via popup. Reconnecting client..."),X.current&&ce("debug","Connection attempt already in progress, resetting flag to allow reconnection."),X.current=!1,setTimeout(()=>{ae.current&&(ce("debug","Initiating reconnection after successful auth callback."),mt.current())},100)):Ct.current(`Authentication failed in callback: ${ze.data.error||"Unknown reason."}`))},"messageHandler");return window.addEventListener("message",Le),ce("debug","Auth callback message listener added."),()=>{window.removeEventListener("message",Le),ce("debug","Auth callback message listener removed."),Q.current&&clearTimeout(Q.current)}},[ce]),x.useEffect(()=>(ae.current=!0,!n||!t?(ce("debug",n?"No server URL provided, skipping connection.":"Connection disabled via enabled flag."),A("discovering"),()=>{ae.current=!1}):(ce("debug","useMcp mounted, initiating connection."),le.current=0,(!W.current||W.current.serverUrl!==t)&&(W.current=new Wg(t,{storageKeyPrefix:s,clientName:a,clientUri:r,callbackUrl:i,preventAutoAuth:v,useRedirectFlow:S,onPopupWindow:w}),ce("debug","BrowserOAuthClientProvider initialized/updated on mount/option change.")),Se(),()=>{ae.current=!1,ce("debug","useMcp unmounting, disconnecting."),ke(!0)})),[t,n,s,i,a,r,c.name,c.version,S]),x.useEffect(()=>{let Le=null;if(I==="failed"&&m&&le.current>0){const ze=typeof m=="number"?m:Uae;ce("info",`Connection failed, auto-retrying in ${ze}ms...`),Le=setTimeout(()=>{ae.current&&q.current==="failed"&&Ue()},ze)}return()=>{Le&&clearTimeout(Le)}},[I,m,Ue,ce]),{state:I,tools:O,resources:U,resourceTemplates:K,prompts:J,serverInfo:B,capabilities:G,error:ne,log:V,authUrl:L,client:F.current,callTool:_e,readResource:xe,listResources:Fe,listPrompts:it,getPrompt:nt,retry:Ue,disconnect:ke,authenticate:fe,clearStorage:Ie}}Ge(NT,"useMcp");var Cu,zae=(Cu=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(Cu,"ErrorBoundary"),Cu),jf="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(jf,n),()=>{typeof window<"u"&&window.removeEventListener(jf,n)}},()=>typeof window<"u"&&window.openai?window.openai[e]:void 0)}Ge(li,"useOpenAiGlobal");function Yu(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),M=Ge(()=>{typeof window<"u"&&window.openai&&(n(!0),clearInterval(O))},"handleSetGlobals");typeof window<"u"&&window.addEventListener(jf,M);const U=setTimeout(()=>{clearInterval(O),typeof window<"u"&&window.removeEventListener(jf,M)},5e3);return()=>{clearInterval(O),clearTimeout(U),typeof window<"u"&&window.removeEventListener(jf,M)}},[]);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"),S=li("userAgent"),w=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,M)=>{if(!window.openai?.callTool)throw new Error("window.openai.callTool is not available");return window.openai.callTool(O,M)},[]),R=x.useCallback(async O=>{if(!window.openai?.sendFollowUpMessage)throw new Error("window.openai.sendFollowUpMessage is not available");return window.openai.sendFollowUpMessage({prompt:O})},[]),C=x.useCallback(O=>{if(!window.openai?.openExternal)throw new Error("window.openai.openExternal is not available");window.openai.openExternal({href:O})},[]),I=x.useCallback(async O=>{if(!window.openai?.requestDisplayMode)throw new Error("window.openai.requestDisplayMode is not available");return window.openai.requestDisplayMode({mode:O})},[]),A=x.useCallback(async O=>{if(!window.openai?.setWidgetState)throw new Error("window.openai.setWidgetState is not available");const U=typeof O=="function"?O(d!==void 0?d:_):O;return E(U),window.openai.setWidgetState(U)},[d,_]);return{props:s||e||{},output:c??null,metadata:u??null,state:_,setState:A,theme:m||"light",displayMode:h||"inline",safeArea:g||{insets:{top:0,bottom:0,left:0,right:0}},maxHeight:v||600,userAgent:S||{device:{type:"desktop"},capabilities:{hover:!0,touch:!1}},locale:w||"en",mcp_url:y,callTool:k,sendFollowUpMessage:R,openExternal:C,requestDisplayMode:I,isAvailable:t}}Ge(Yu,"useWidget");function Fae(e){const{props:t}=Yu(e);return t}Ge(Fae,"useWidgetProps");function Bae(){const{theme:e}=Yu();return e}Ge(Bae,"useWidgetTheme");function Hae(e){const{state:t,setState:n}=Yu();return x.useEffect(()=>{t===null&&e!==void 0&&window.openai?.setWidgetState&&n(e)},[]),[t,n]}Ge(Hae,"useWidgetState");var pP=Ge(({children:e})=>{const{theme:t,isAvailable:n}=Yu();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 sH({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:S,userAgent:w,locale:y,isAvailable:_,callTool:E,sendFollowUpMessage:k,openExternal:R,requestDisplayMode:C,setState:I}=Yu(),[A,O]=x.useState(!1),[M,U]=x.useState(!1),H=x.useRef(null),K=x.useRef(null),[ee,J]=x.useState([]),[ie,B]=x.useState(""),[Z,G]=x.useState("get-my-city"),[re,ne]=x.useState("{}"),[j,V]=x.useState("Test follow-up message"),[z,L]=x.useState("https://docs.mcp-use.com"),$=g==="fullscreen"&&_,F=g==="pip"&&_,W=typeof window<"u"&&window.location.pathname.includes("/inspector/api/dev-widget/");x.useEffect(()=>{const xe=setTimeout(()=>{if(typeof window<"u"&&window.openai)try{const it=Object.keys(window.openai);J(it)}catch{J([])}else J([])},100);return()=>{clearTimeout(xe)}},[]);const X=h==="dark",ae=Ge(()=>{const xe=["absolute","z-[1000]","flex","gap-2","transition-opacity","duration-200","ease-in-out",A?"opacity-100":"opacity-0",A?"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 it=v?.insets?.top?Math.max(16,v.insets.top+8):16,nt=v?.insets?.right?Math.max(16,v.insets.right+8):16,mt=v?.insets?.bottom?Math.max(16,v.insets.bottom+8):16,Ct=v?.insets?.left?Math.max(16,v.insets.left+8):16,Le={};switch(n){case"top-left":Le.top=`${it}px`,Le.left=`${Ct}px`;break;case"top-center":Le.top=`${it}px`;break;case"top-right":Le.top=`${it}px`,Le.right=`${nt}px`;break;case"center-left":Le.left=`${Ct}px`;break;case"center-right":Le.right=`${nt}px`;break;case"bottom-left":Le.bottom=`${mt}px`,Le.left=`${Ct}px`;break;case"bottom-center":Le.bottom=`${mt}px`;break;case"bottom-right":Le.bottom=`${mt}px`,Le.right=`${nt}px`;break;default:Le.top=`${it}px`,Le.right=`${nt}px`;break}return Le},"getPositionOffsetStyles");x.useEffect(()=>{if(!a)return;const xe=Ge(()=>O(!0),"handleMouseEnter"),it=Ge(()=>O(!1),"handleMouseLeave");return a.addEventListener("mouseenter",xe),a.addEventListener("mouseleave",it),()=>{a.removeEventListener("mouseenter",xe),a.removeEventListener("mouseleave",it)}},[a]),x.useEffect(()=>{if(!M)return;const xe=Ge(it=>{K.current&&!K.current.contains(it.target)&&U(!1)},"handleClickOutside");return document.addEventListener("mousedown",xe),()=>{document.removeEventListener("mousedown",xe)}},[M]),x.useEffect(()=>(M?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[M]);const Q=Ge(()=>{U(!M)},"handleToggleOverlay"),q=Ge(async()=>{try{B("Calling tool...");const xe=re.trim()?JSON.parse(re):{},it=await E(Z,xe);B(`Success: ${JSON.stringify(it,null,2)}`)}catch(xe){B(`Error: ${xe.message}`)}},"handleCallTool"),se=Ge(async()=>{try{B("Sending follow-up message..."),await k(j),B("Follow-up message sent successfully")}catch(xe){B(`Error: ${xe.message}`)}},"handleSendFollowUpMessage"),he=Ge(()=>{try{R(z),B(`Opened external link: ${z}`)}catch(xe){B(`Error: ${xe.message}`)}},"handleOpenExternal"),ce=Ge(async xe=>{try{B(`Requesting display mode: ${xe}...`);const it=await C(xe);B(`Display mode granted: ${it.mode}`)}catch(it){B(`Error: ${it.message}`)}},"handleRequestDisplayMode"),ke=Ge(async()=>{try{const xe=m?{...m,debugTimestamp:new Date().toISOString()}:{debugTimestamp:new Date().toISOString()};B("Setting state..."),await I(xe),B(`State updated: ${JSON.stringify(xe,null,2)}`)}catch(xe){B(`Error: ${xe.message}`)}},"handleSetState"),He=Ge(async()=>{try{await C("fullscreen")}catch(xe){console.error("Failed to go fullscreen:",xe)}},"handleFullscreen"),Se=Ge(async()=>{try{await C("pip")}catch(xe){console.error("Failed to go pip:",xe)}},"handlePip"),_e=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"),Ue=Ge(({onClick:xe,label:it,children:nt})=>{const[mt,Ct]=x.useState(!1),Le=_e();return ue.createElement("button",{className:`p-2 ${X?"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 ${X?"shadow-[0_2px_8px_rgba(0,0,0,0.3)]":"shadow-[0_2px_8px_rgba(0,0,0,0.2)]"} relative`,onMouseEnter:()=>Ct(!0),onMouseLeave:()=>Ct(!1),onClick:xe,"aria-label":it},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"},nt),r&&ue.createElement("span",{className:`${Le.join(" ")} ${mt?"opacity-100":"opacity-0"}`},it))},"IconButton"),fe=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"),Ie=Ge(xe=>xe?`${xe.device?.type||"unknown"}`:"N/A","formatUserAgent"),Fe=Ge(xe=>{if(!xe?.insets)return"N/A";const{top:it,bottom:nt,left:mt,right:Ct}=xe.insets;return`T:${it} B:${nt} L:${mt} R:${Ct}`},"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:ae().join(" "),style:le()},!W&&ue.createElement(ue.Fragment,null,!$&&!F&&ue.createElement(ue.Fragment,null,(s===!0||s==="fullscreen")&&ue.createElement(Ue,{onClick:He,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(Ue,{onClick:Se,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(Ue,{onClick:Q,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),M&&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&&U(!1)}},ue.createElement("button",{onClick:()=>U(!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"},fe(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"},fe(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"},fe(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"},fe(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"},S,"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"},Ie(w))),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"},ee.length>0?ee.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:Z,onChange:xe=>G(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:re,onChange:xe=>ne(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:q,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:j,onChange:xe=>V(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:se,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:z,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:he,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:()=>ce("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:()=>ce("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:()=>ce("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:()=>B(""),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(sH,"WidgetControls");function lH(){if(typeof window>"u")return"/";const t=window.location.pathname.match(/^(\/inspector\/api\/dev-widget\/[^/]+)/);return t?t[1]:"/"}Ge(lH,"getBasename");var Vae=150,Gae=5;function Wae({children:e,debugger:t=!1,viewControls:n=!1,autoSize:a=!1}){const r=lH(),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,S]=x.useState(!0);x.useEffect(()=>{let E=!0;return(async()=>{try{const k=await dr(()=>import("./index-DRLEjnG1.js"),[]);E&&(m(()=>k.BrowserRouter),S(!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
  `)},QP=function(){var e=parseInt(document.body.getAttribute(du)||"0",10);return isFinite(e)?e:0},Qce=function(){x.useEffect(function(){return document.body.setAttribute(du,(QP()+1).toString()),function(){var e=QP()-1;e<=0?document.body.removeAttribute(du):document.body.setAttribute(du,e.toString())}},[])},eue=function(e){var t=e.noRelative,n=e.noImportant,a=e.gapMode,r=a===void 0?"margin":a;Qce();var i=x.useMemo(function(){return qce(r)},[r]);return x.createElement(Xce,{styles:Jce(i,!t,r,n?"":"!important")})},tE=!1;if(typeof window<"u")try{var _g=Object.defineProperty({},"passive",{get:function(){return tE=!0,!0}});window.addEventListener("test",_g,_g),window.removeEventListener("test",_g,_g)}catch{tE=!1}var Mc=tE?{passive:!1}:!1,tue=function(e){return e.tagName==="TEXTAREA"},RV=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!tue(e)&&n[t]==="visible")},nue=function(e){return RV(e,"overflowY")},rue=function(e){return RV(e,"overflowX")},eU=function(e,t){var n=t.ownerDocument,a=t;do{typeof ShadowRoot<"u"&&a instanceof ShadowRoot&&(a=a.host);var r=AV(e,a);if(r){var i=IV(e,a),s=i[1],c=i[2];if(s>c)return!0}a=a.parentNode}while(a&&a!==n.body);return!1},aue=function(e){var t=e.scrollTop,n=e.scrollHeight,a=e.clientHeight;return[t,n,a]},iue=function(e){var t=e.scrollLeft,n=e.scrollWidth,a=e.clientWidth;return[t,n,a]},AV=function(e,t){return e==="v"?nue(t):rue(t)},IV=function(e,t){return e==="v"?aue(t):iue(t)},oue=function(e,t){return e==="h"&&t==="rtl"?-1:1},sue=function(e,t,n,a,r){var i=oue(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=IV(e,c),S=v[0],w=v[1],y=v[2],_=w-y-i*S;(S||_)&&AV(e,c)&&(h+=_,g+=S);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},kg=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},tU=function(e){return[e.deltaX,e.deltaY]},nU=function(e){return e&&"current"in e?e.current:e},lue=function(e,t){return e[0]===t[0]&&e[1]===t[1]},cue=function(e){return`
100
100
  .block-interactivity-`.concat(e,` {pointer-events: none;}
101
101
  .allow-interactivity-`).concat(e,` {pointer-events: all;}
102
- `)},uue=0,Pc=[];function due(e){var t=x.useRef([]),n=x.useRef([0,0]),a=x.useRef(),r=x.useState(uue++)[0],i=x.useState(CV)[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 w=Oce([e.lockRef.current],(e.shards||[]).map(nU),!0).filter(Boolean);return w.forEach(function(y){return y.classList.add("allow-interactivity-".concat(r))}),function(){document.body.classList.remove("block-interactivity-".concat(r)),w.forEach(function(y){return y.classList.remove("allow-interactivity-".concat(r))})}}},[e.inert,e.lockRef.current,e.shards]);var c=x.useCallback(function(w,y){if("touches"in w&&w.touches.length===2||w.type==="wheel"&&w.ctrlKey)return!s.current.allowPinchZoom;var _=kg(w),E=n.current,k="deltaX"in w?w.deltaX:E[0]-_[0],R="deltaY"in w?w.deltaY:E[1]-_[1],C,I=w.target,A=Math.abs(k)>Math.abs(R)?"h":"v";if("touches"in w&&A==="h"&&I.type==="range")return!1;var O=eU(A,I);if(!O)return!0;if(O?C=A:(C=A==="v"?"h":"v",O=eU(A,I)),!O)return!1;if(!a.current&&"changedTouches"in w&&(k||R)&&(a.current=C),!C)return!0;var M=a.current||C;return sue(M,y,w,M==="h"?k:R)},[]),u=x.useCallback(function(w){var y=w;if(!(!Pc.length||Pc[Pc.length-1]!==i)){var _="deltaY"in y?tU(y):kg(y),E=t.current.filter(function(C){return C.name===y.type&&(C.target===y.target||y.target===C.shadowParent)&&lue(C.delta,_)})[0];if(E&&E.should){y.cancelable&&y.preventDefault();return}if(!E){var k=(s.current.shards||[]).map(nU).filter(Boolean).filter(function(C){return C.contains(y.target)}),R=k.length>0?c(y,k[0]):!s.current.noIsolation;R&&y.cancelable&&y.preventDefault()}}},[]),d=x.useCallback(function(w,y,_,E){var k={name:w,delta:y,target:_,should:E,shadowParent:fue(_)};t.current.push(k),setTimeout(function(){t.current=t.current.filter(function(R){return R!==k})},1)},[]),m=x.useCallback(function(w){n.current=kg(w),a.current=void 0},[]),h=x.useCallback(function(w){d(w.type,tU(w),w.target,c(w,e.lockRef.current))},[]),g=x.useCallback(function(w){d(w.type,kg(w),w.target,c(w,e.lockRef.current))},[]);x.useEffect(function(){return Pc.push(i),e.setCallbacks({onScrollCapture:h,onWheelCapture:h,onTouchMoveCapture:g}),document.addEventListener("wheel",u,Mc),document.addEventListener("touchmove",u,Mc),document.addEventListener("touchstart",m,Mc),function(){Pc=Pc.filter(function(w){return w!==i}),document.removeEventListener("wheel",u,Mc),document.removeEventListener("touchmove",u,Mc),document.removeEventListener("touchstart",m,Mc)}},[]);var v=e.removeScrollBar,S=e.inert;return x.createElement(x.Fragment,null,S?x.createElement(i,{styles:cue(r)}):null,v?x.createElement(eue,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function fue(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const pue=Fce(NV,due);var Yp=x.forwardRef(function(e,t){return x.createElement(Qv,ji({},e,{ref:t,sideCar:pue}))});Yp.classNames=Qv.classNames;var nE=["Enter"," "],mue=["ArrowDown","PageUp","Home"],OV=["ArrowUp","PageDown","End"],hue=[...mue,...OV],gue={ltr:[...nE,"ArrowRight"],rtl:[...nE,"ArrowLeft"]},bue={ltr:["ArrowLeft"],rtl:["ArrowRight"]},qp="Menu",[ip,vue,yue]=jT(qp),[Gl,DV]=ki(qp,[yue,Us,yV]),ey=Us(),jV=yV(),[wue,Wl]=Gl(qp),[xue,Xp]=Gl(qp),LV=e=>{const{__scopeMenu:t,open:n=!1,children:a,dir:r,onOpenChange:i,modal:s=!0}=e,c=ey(t),[u,d]=x.useState(null),m=x.useRef(!1),h=Fi(i),g=LT(r);return x.useEffect(()=>{const v=()=>{m.current=!0,document.addEventListener("pointerdown",S,{capture:!0,once:!0}),document.addEventListener("pointermove",S,{capture:!0,once:!0})},S=()=>m.current=!1;return document.addEventListener("keydown",v,{capture:!0}),()=>{document.removeEventListener("keydown",v,{capture:!0}),document.removeEventListener("pointerdown",S,{capture:!0}),document.removeEventListener("pointermove",S,{capture:!0})}},[]),f.jsx(Yv,{...c,children:f.jsx(wue,{scope:t,open:n,onOpenChange:h,content:u,onContentChange:d,children:f.jsx(xue,{scope:t,onClose:x.useCallback(()=>h(!1),[h]),isUsingKeyboardRef:m,dir:g,modal:s,children:a})})})};LV.displayName=qp;var Sue="MenuAnchor",GT=x.forwardRef((e,t)=>{const{__scopeMenu:n,...a}=e,r=ey(n);return f.jsx(Kp,{...r,...a,ref:t})});GT.displayName=Sue;var WT="MenuPortal",[Eue,$V]=Gl(WT,{forceMount:void 0}),MV=e=>{const{__scopeMenu:t,forceMount:n,children:a,container:r}=e,i=Wl(WT,t);return f.jsx(Eue,{scope:t,forceMount:n,children:f.jsx(Ma,{present:n||i.open,children:f.jsx(id,{asChild:!0,container:r,children:a})})})};MV.displayName=WT;var Ja="MenuContent",[_ue,KT]=Gl(Ja),PV=x.forwardRef((e,t)=>{const n=$V(Ja,e.__scopeMenu),{forceMount:a=n.forceMount,...r}=e,i=Wl(Ja,e.__scopeMenu),s=Xp(Ja,e.__scopeMenu);return f.jsx(ip.Provider,{scope:e.__scopeMenu,children:f.jsx(Ma,{present:a||i.open,children:f.jsx(ip.Slot,{scope:e.__scopeMenu,children:s.modal?f.jsx(kue,{...r,ref:t}):f.jsx(Tue,{...r,ref:t})})})})}),kue=x.forwardRef((e,t)=>{const n=Wl(Ja,e.__scopeMenu),a=x.useRef(null),r=Qt(t,a);return x.useEffect(()=>{const i=a.current;if(i)return Jv(i)},[]),f.jsx(ZT,{...e,ref:r,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:Ve(e.onFocusOutside,i=>i.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),Tue=x.forwardRef((e,t)=>{const n=Wl(Ja,e.__scopeMenu);return f.jsx(ZT,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),Nue=Dl("MenuContent.ScrollLock"),ZT=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:S,...w}=e,y=Wl(Ja,n),_=Xp(Ja,n),E=ey(n),k=jV(n),R=vue(n),[C,I]=x.useState(null),A=x.useRef(null),O=Qt(t,A,y.onContentChange),M=x.useRef(0),U=x.useRef(""),H=x.useRef(0),K=x.useRef(null),ee=x.useRef("right"),J=x.useRef(0),ie=S?Yp:x.Fragment,B=S?{as:Nue,allowPinchZoom:!0}:void 0,Z=re=>{const ne=U.current+re,j=R().filter(W=>!W.disabled),V=document.activeElement,z=j.find(W=>W.ref.current===V)?.textValue,L=j.map(W=>W.textValue),$=Uue(L,ne,z),F=j.find(W=>W.textValue===$)?.ref.current;(function W(X){U.current=X,window.clearTimeout(M.current),X!==""&&(M.current=window.setTimeout(()=>W(""),1e3))})(ne),F&&setTimeout(()=>F.focus())};x.useEffect(()=>()=>window.clearTimeout(M.current),[]),Vv();const G=x.useCallback(re=>ee.current===K.current?.side&&Fue(re,K.current?.area),[]);return f.jsx(_ue,{scope:n,searchRef:U,onItemEnter:x.useCallback(re=>{G(re)&&re.preventDefault()},[G]),onItemLeave:x.useCallback(re=>{G(re)||(A.current?.focus(),I(null))},[G]),onTriggerLeave:x.useCallback(re=>{G(re)&&re.preventDefault()},[G]),pointerGraceTimerRef:H,onPointerGraceIntentChange:x.useCallback(re=>{K.current=re},[]),children:f.jsx(ie,{...B,children:f.jsx(Gp,{asChild:!0,trapped:r,onMountAutoFocus:Ve(i,re=>{re.preventDefault(),A.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:s,children:f.jsx(nd,{asChild:!0,disableOutsidePointerEvents:c,onEscapeKeyDown:d,onPointerDownOutside:m,onFocusOutside:h,onInteractOutside:g,onDismiss:v,children:f.jsx(Nce,{asChild:!0,...k,dir:_.dir,orientation:"vertical",loop:a,currentTabStopId:C,onCurrentTabStopIdChange:I,onEntryFocus:Ve(u,re=>{_.isUsingKeyboardRef.current||re.preventDefault()}),preventScrollOnEntryFocus:!0,children:f.jsx(qv,{role:"menu","aria-orientation":"vertical","data-state":e9(y.open),"data-radix-menu-content":"",dir:_.dir,...E,...w,ref:O,style:{outline:"none",...w.style},onKeyDown:Ve(w.onKeyDown,re=>{const j=re.target.closest("[data-radix-menu-content]")===re.currentTarget,V=re.ctrlKey||re.altKey||re.metaKey,z=re.key.length===1;j&&(re.key==="Tab"&&re.preventDefault(),!V&&z&&Z(re.key));const L=A.current;if(re.target!==L||!hue.includes(re.key))return;re.preventDefault();const F=R().filter(W=>!W.disabled).map(W=>W.ref.current);OV.includes(re.key)&&F.reverse(),Mue(F)}),onBlur:Ve(e.onBlur,re=>{re.currentTarget.contains(re.target)||(window.clearTimeout(M.current),U.current="")}),onPointerMove:Ve(e.onPointerMove,op(re=>{const ne=re.target,j=J.current!==re.clientX;if(re.currentTarget.contains(ne)&&j){const V=re.clientX>J.current?"right":"left";ee.current=V,J.current=re.clientX}}))})})})})})})});PV.displayName=Ja;var Cue="MenuGroup",YT=x.forwardRef((e,t)=>{const{__scopeMenu:n,...a}=e;return f.jsx(Et.div,{role:"group",...a,ref:t})});YT.displayName=Cue;var Rue="MenuLabel",UV=x.forwardRef((e,t)=>{const{__scopeMenu:n,...a}=e;return f.jsx(Et.div,{...a,ref:t})});UV.displayName=Rue;var Mb="MenuItem",rU="menu.itemSelect",ty=x.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:a,...r}=e,i=x.useRef(null),s=Xp(Mb,e.__scopeMenu),c=KT(Mb,e.__scopeMenu),u=Qt(t,i),d=x.useRef(!1),m=()=>{const h=i.current;if(!n&&h){const g=new CustomEvent(rU,{bubbles:!0,cancelable:!0});h.addEventListener(rU,v=>a?.(v),{once:!0}),KH(h,g),g.defaultPrevented?d.current=!1:s.onClose()}};return f.jsx(zV,{...r,ref:u,disabled:n,onClick:Ve(e.onClick,m),onPointerDown:h=>{e.onPointerDown?.(h),d.current=!0},onPointerUp:Ve(e.onPointerUp,h=>{d.current||h.currentTarget?.click()}),onKeyDown:Ve(e.onKeyDown,h=>{const g=c.searchRef.current!=="";n||g&&h.key===" "||nE.includes(h.key)&&(h.currentTarget.click(),h.preventDefault())})})});ty.displayName=Mb;var zV=x.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:a=!1,textValue:r,...i}=e,s=KT(Mb,n),c=jV(n),u=x.useRef(null),d=Qt(t,u),[m,h]=x.useState(!1),[g,v]=x.useState("");return x.useEffect(()=>{const S=u.current;S&&v((S.textContent??"").trim())},[i.children]),f.jsx(ip.ItemSlot,{scope:n,disabled:a,textValue:r??g,children:f.jsx(Cce,{asChild:!0,...c,focusable:!a,children:f.jsx(Et.div,{role:"menuitem","data-highlighted":m?"":void 0,"aria-disabled":a||void 0,"data-disabled":a?"":void 0,...i,ref:d,onPointerMove:Ve(e.onPointerMove,op(S=>{a?s.onItemLeave(S):(s.onItemEnter(S),S.defaultPrevented||S.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Ve(e.onPointerLeave,op(S=>s.onItemLeave(S))),onFocus:Ve(e.onFocus,()=>h(!0)),onBlur:Ve(e.onBlur,()=>h(!1))})})})}),Aue="MenuCheckboxItem",FV=x.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:a,...r}=e;return f.jsx(WV,{scope:e.__scopeMenu,checked:n,children:f.jsx(ty,{role:"menuitemcheckbox","aria-checked":Pb(n)?"mixed":n,...r,ref:t,"data-state":XT(n),onSelect:Ve(r.onSelect,()=>a?.(Pb(n)?!0:!n),{checkForDefaultPrevented:!1})})})});FV.displayName=Aue;var BV="MenuRadioGroup",[Iue,Oue]=Gl(BV,{value:void 0,onValueChange:()=>{}}),HV=x.forwardRef((e,t)=>{const{value:n,onValueChange:a,...r}=e,i=Fi(a);return f.jsx(Iue,{scope:e.__scopeMenu,value:n,onValueChange:i,children:f.jsx(YT,{...r,ref:t})})});HV.displayName=BV;var VV="MenuRadioItem",GV=x.forwardRef((e,t)=>{const{value:n,...a}=e,r=Oue(VV,e.__scopeMenu),i=n===r.value;return f.jsx(WV,{scope:e.__scopeMenu,checked:i,children:f.jsx(ty,{role:"menuitemradio","aria-checked":i,...a,ref:t,"data-state":XT(i),onSelect:Ve(a.onSelect,()=>r.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});GV.displayName=VV;var qT="MenuItemIndicator",[WV,Due]=Gl(qT,{checked:!1}),KV=x.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:a,...r}=e,i=Due(qT,n);return f.jsx(Ma,{present:a||Pb(i.checked)||i.checked===!0,children:f.jsx(Et.span,{...r,ref:t,"data-state":XT(i.checked)})})});KV.displayName=qT;var jue="MenuSeparator",ZV=x.forwardRef((e,t)=>{const{__scopeMenu:n,...a}=e;return f.jsx(Et.div,{role:"separator","aria-orientation":"horizontal",...a,ref:t})});ZV.displayName=jue;var Lue="MenuArrow",YV=x.forwardRef((e,t)=>{const{__scopeMenu:n,...a}=e,r=ey(n);return f.jsx(Xv,{...r,...a,ref:t})});YV.displayName=Lue;var $ue="MenuSub",[ske,qV]=Gl($ue),Ef="MenuSubTrigger",XV=x.forwardRef((e,t)=>{const n=Wl(Ef,e.__scopeMenu),a=Xp(Ef,e.__scopeMenu),r=qV(Ef,e.__scopeMenu),i=KT(Ef,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]),f.jsx(GT,{asChild:!0,...d,children:f.jsx(zV,{id:r.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":r.contentId,"data-state":e9(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:Ve(e.onPointerMove,op(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:Ve(e.onPointerLeave,op(h=>{m();const g=n.content?.getBoundingClientRect();if(g){const v=n.content?.dataset.side,S=v==="right",w=S?-5:5,y=g[S?"left":"right"],_=g[S?"right":"left"];i.onPointerGraceIntentChange({area:[{x:h.clientX+w,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:Ve(e.onKeyDown,h=>{const g=i.searchRef.current!=="";e.disabled||g&&h.key===" "||gue[a.dir].includes(h.key)&&(n.onOpenChange(!0),n.content?.focus(),h.preventDefault())})})})});XV.displayName=Ef;var JV="MenuSubContent",QV=x.forwardRef((e,t)=>{const n=$V(Ja,e.__scopeMenu),{forceMount:a=n.forceMount,...r}=e,i=Wl(Ja,e.__scopeMenu),s=Xp(Ja,e.__scopeMenu),c=qV(JV,e.__scopeMenu),u=x.useRef(null),d=Qt(t,u);return f.jsx(ip.Provider,{scope:e.__scopeMenu,children:f.jsx(Ma,{present:a||i.open,children:f.jsx(ip.Slot,{scope:e.__scopeMenu,children:f.jsx(ZT,{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:Ve(e.onFocusOutside,m=>{m.target!==c.trigger&&i.onOpenChange(!1)}),onEscapeKeyDown:Ve(e.onEscapeKeyDown,m=>{s.onClose(),m.preventDefault()}),onKeyDown:Ve(e.onKeyDown,m=>{const h=m.currentTarget.contains(m.target),g=bue[s.dir].includes(m.key);h&&g&&(i.onOpenChange(!1),c.trigger?.focus(),m.preventDefault())})})})})})});QV.displayName=JV;function e9(e){return e?"open":"closed"}function Pb(e){return e==="indeterminate"}function XT(e){return Pb(e)?"indeterminate":e?"checked":"unchecked"}function Mue(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function Pue(e,t){return e.map((n,a)=>e[(t+a)%e.length])}function Uue(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=Pue(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 zue(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 Fue(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return zue(n,t)}function op(e){return t=>t.pointerType==="mouse"?e(t):void 0}var Bue=LV,Hue=GT,Vue=MV,Gue=PV,Wue=YT,Kue=UV,Zue=ty,Yue=FV,que=HV,Xue=GV,Jue=KV,Que=ZV,ede=YV,tde=XV,nde=QV,ny="DropdownMenu",[rde]=ki(ny,[DV]),na=DV(),[ade,t9]=rde(ny),n9=e=>{const{__scopeDropdownMenu:t,children:n,dir:a,open:r,defaultOpen:i,onOpenChange:s,modal:c=!0}=e,u=na(t),d=x.useRef(null),[m,h]=Io({prop:r,defaultProp:i??!1,onChange:s,caller:ny});return f.jsx(ade,{scope:t,triggerId:Dr(),triggerRef:d,contentId:Dr(),open:m,onOpenChange:h,onOpenToggle:x.useCallback(()=>h(g=>!g),[h]),modal:c,children:f.jsx(Bue,{...u,open:m,onOpenChange:h,dir:a,modal:c,children:n})})};n9.displayName=ny;var r9="DropdownMenuTrigger",a9=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:a=!1,...r}=e,i=t9(r9,n),s=na(n);return f.jsx(Hue,{asChild:!0,...s,children:f.jsx(Et.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:Ve(e.onPointerDown,c=>{!a&&c.button===0&&c.ctrlKey===!1&&(i.onOpenToggle(),i.open||c.preventDefault())}),onKeyDown:Ve(e.onKeyDown,c=>{a||(["Enter"," "].includes(c.key)&&i.onOpenToggle(),c.key==="ArrowDown"&&i.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(c.key)&&c.preventDefault())})})})});a9.displayName=r9;var ide="DropdownMenuPortal",i9=e=>{const{__scopeDropdownMenu:t,...n}=e,a=na(t);return f.jsx(Vue,{...a,...n})};i9.displayName=ide;var o9="DropdownMenuContent",s9=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=t9(o9,n),i=na(n),s=x.useRef(!1);return f.jsx(Gue,{id:r.contentId,"aria-labelledby":r.triggerId,...i,...a,ref:t,onCloseAutoFocus:Ve(e.onCloseAutoFocus,c=>{s.current||r.triggerRef.current?.focus(),s.current=!1,c.preventDefault()}),onInteractOutside:Ve(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)"}})});s9.displayName=o9;var ode="DropdownMenuGroup",sde=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=na(n);return f.jsx(Wue,{...r,...a,ref:t})});sde.displayName=ode;var lde="DropdownMenuLabel",l9=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=na(n);return f.jsx(Kue,{...r,...a,ref:t})});l9.displayName=lde;var cde="DropdownMenuItem",c9=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=na(n);return f.jsx(Zue,{...r,...a,ref:t})});c9.displayName=cde;var ude="DropdownMenuCheckboxItem",u9=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=na(n);return f.jsx(Yue,{...r,...a,ref:t})});u9.displayName=ude;var dde="DropdownMenuRadioGroup",fde=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=na(n);return f.jsx(que,{...r,...a,ref:t})});fde.displayName=dde;var pde="DropdownMenuRadioItem",d9=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=na(n);return f.jsx(Xue,{...r,...a,ref:t})});d9.displayName=pde;var mde="DropdownMenuItemIndicator",hde=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=na(n);return f.jsx(Jue,{...r,...a,ref:t})});hde.displayName=mde;var gde="DropdownMenuSeparator",f9=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=na(n);return f.jsx(Que,{...r,...a,ref:t})});f9.displayName=gde;var bde="DropdownMenuArrow",vde=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=na(n);return f.jsx(ede,{...r,...a,ref:t})});vde.displayName=bde;var yde="DropdownMenuSubTrigger",p9=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=na(n);return f.jsx(tde,{...r,...a,ref:t})});p9.displayName=yde;var wde="DropdownMenuSubContent",m9=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=na(n);return f.jsx(nde,{...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)"}})});m9.displayName=wde;var xde=n9,Sde=a9,Ede=i9,h9=s9,g9=l9,b9=c9,_de=u9,kde=d9,v9=f9,Tde=p9,Nde=m9;const rE=xde,aE=Sde;Tde.displayName;Nde.displayName;function Ub({ref:e,className:t,sideOffset:n=4,...a}){return f.jsx(Ede,{children:f.jsx(h9,{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})})}Ub.displayName=h9.displayName;function Eo({ref:e,className:t,inset:n,...a}){return f.jsx(b9,{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})}Eo.displayName=b9.displayName;_de.displayName;kde.displayName;function iE({ref:e,className:t,inset:n,...a}){return f.jsx(g9,{ref:e,className:De("px-2 py-1.5 text-sm font-semibold",n&&"pl-8",t),...a})}iE.displayName=g9.displayName;function _f({ref:e,className:t,...n}){return f.jsx(v9,{ref:e,className:De("-mx-1 my-1 h-px bg-muted",t),...n})}_f.displayName=v9.displayName;var Cde=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],zo=Cde.reduce((e,t)=>{const n=RH(`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),f.jsx(u,{...c,ref:i})});return a.displayName=`Primitive.${t}`,{...e,[t]:a}},{}),Rde="Label",y9=x.forwardRef((e,t)=>f.jsx(zo.label,{...e,ref:t,onMouseDown:n=>{n.target.closest("button, input, select, textarea")||(e.onMouseDown?.(n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));y9.displayName=Rde;var Ade=y9;function Kt({className:e,...t}){return f.jsx(Ade,{"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 od({message:e,className:t="",vertical:n,noBorder:a}){return f.jsx("div",{className:De(`mt-2 rounded-md p-6 ${t}`,!a&&"border"),children:f.jsxs("p",{className:De("text-sm text-muted-foreground flex items-center gap-4",n&&"flex-col"),children:[f.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:f.jsx("g",{stroke:"none",strokeWidth:"1",fill:"none",fillRule:"evenodd",children:f.jsxs("g",{transform:"translate(5.320900, 5.320900)",fillRule:"nonzero",className:"stroke-black dark:stroke-white",strokeWidth:"4",children:[f.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"}),f.jsx("circle",{cx:"50",cy:"212.0001",r:"52.5"}),f.jsx("circle",{cx:"212.0001",cy:"50",r:"52.5"})]})})}),e]})})}function w9({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 f.jsx("section",{className:De("relative w-full h-full overflow-hidden",e),style:{background:`${u}`},children:f.jsxs("div",{className:"isolate relative w-full h-full",children:[f.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&&f.jsx("div",{className:"relative z-10 w-full h-full",children:n})]})})}function JT(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 ry="Switch",[Ide]=ki(ry),[Ode,Dde]=Ide(ry),x9=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),S=Qt(t,k=>v(k)),w=x.useRef(!1),y=g?m||!!g.closest("form"):!0,[_,E]=Io({prop:r,defaultProp:i??!1,onChange:d,caller:ry});return f.jsxs(Ode,{scope:n,checked:_,disabled:c,children:[f.jsx(Et.button,{type:"button",role:"switch","aria-checked":_,"aria-required":s,"data-state":k9(_),"data-disabled":c?"":void 0,disabled:c,value:u,...h,ref:S,onClick:Ve(e.onClick,k=>{E(R=>!R),y&&(w.current=k.isPropagationStopped(),w.current||k.stopPropagation())})}),y&&f.jsx(_9,{control:g,bubbles:!w.current,name:a,value:u,checked:_,required:s,disabled:c,form:m,style:{transform:"translateX(-100%)"}})]})});x9.displayName=ry;var S9="SwitchThumb",E9=x.forwardRef((e,t)=>{const{__scopeSwitch:n,...a}=e,r=Dde(S9,n);return f.jsx(Et.span,{"data-state":k9(r.checked),"data-disabled":r.disabled?"":void 0,...a,ref:t})});E9.displayName=S9;var jde="SwitchBubbleInput",_9=x.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:a=!0,...r},i)=>{const s=x.useRef(null),c=Qt(s,i),u=JT(n),d=BT(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 S=new Event("click",{bubbles:a});v.call(m,n),m.dispatchEvent(S)}},[u,n,a]),f.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}})});_9.displayName=jde;function k9(e){return e?"checked":"unchecked"}var T9=x9,Lde=E9;function ay({ref:e,className:t,...n}){return f.jsx(T9,{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:f.jsx(Lde,{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")})})}ay.displayName=T9.displayName;var N9=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"}),$de="VisuallyHidden",C9=x.forwardRef((e,t)=>f.jsx(Et.span,{...e,ref:t,style:{...N9,...e.style}}));C9.displayName=$de;var Mde=C9,[iy]=ki("Tooltip",[Us]),oy=Us(),R9="TooltipProvider",Pde=700,oE="tooltip.open",[Ude,QT]=iy(R9),A9=e=>{const{__scopeTooltip:t,delayDuration:n=Pde,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)},[]),f.jsx(Ude,{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})};A9.displayName=R9;var sp="Tooltip",[zde,Jp]=iy(sp),I9=e=>{const{__scopeTooltip:t,children:n,open:a,defaultOpen:r,onOpenChange:i,disableHoverableContent:s,delayDuration:c}=e,u=QT(sp,e.__scopeTooltip),d=oy(t),[m,h]=x.useState(null),g=Dr(),v=x.useRef(0),S=s??u.disableHoverableContent,w=c??u.delayDuration,y=x.useRef(!1),[_,E]=Io({prop:a,defaultProp:r??!1,onChange:A=>{A?(u.onOpen(),document.dispatchEvent(new CustomEvent(oE))):u.onClose(),i?.(A)},caller:sp}),k=x.useMemo(()=>_?y.current?"delayed-open":"instant-open":"closed",[_]),R=x.useCallback(()=>{window.clearTimeout(v.current),v.current=0,y.current=!1,E(!0)},[E]),C=x.useCallback(()=>{window.clearTimeout(v.current),v.current=0,E(!1)},[E]),I=x.useCallback(()=>{window.clearTimeout(v.current),v.current=window.setTimeout(()=>{y.current=!0,E(!0),v.current=0},w)},[w,E]);return x.useEffect(()=>()=>{v.current&&(window.clearTimeout(v.current),v.current=0)},[]),f.jsx(Yv,{...d,children:f.jsx(zde,{scope:t,contentId:g,open:_,stateAttribute:k,trigger:m,onTriggerChange:h,onTriggerEnter:x.useCallback(()=>{u.isOpenDelayedRef.current?I():R()},[u.isOpenDelayedRef,I,R]),onTriggerLeave:x.useCallback(()=>{S?C():(window.clearTimeout(v.current),v.current=0)},[C,S]),onOpen:R,onClose:C,disableHoverableContent:S,children:n})})};I9.displayName=sp;var sE="TooltipTrigger",O9=x.forwardRef((e,t)=>{const{__scopeTooltip:n,...a}=e,r=Jp(sE,n),i=QT(sE,n),s=oy(n),c=x.useRef(null),u=Qt(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]),f.jsx(Kp,{asChild:!0,...s,children:f.jsx(Et.button,{"aria-describedby":r.open?r.contentId:void 0,"data-state":r.stateAttribute,...a,ref:u,onPointerMove:Ve(e.onPointerMove,g=>{g.pointerType!=="touch"&&!m.current&&!i.isPointerInTransitRef.current&&(r.onTriggerEnter(),m.current=!0)}),onPointerLeave:Ve(e.onPointerLeave,()=>{r.onTriggerLeave(),m.current=!1}),onPointerDown:Ve(e.onPointerDown,()=>{r.open&&r.onClose(),d.current=!0,document.addEventListener("pointerup",h,{once:!0})}),onFocus:Ve(e.onFocus,()=>{d.current||r.onOpen()}),onBlur:Ve(e.onBlur,r.onClose),onClick:Ve(e.onClick,r.onClose)})})});O9.displayName=sE;var eN="TooltipPortal",[Fde,Bde]=iy(eN,{forceMount:void 0}),D9=e=>{const{__scopeTooltip:t,forceMount:n,children:a,container:r}=e,i=Jp(eN,t);return f.jsx(Fde,{scope:t,forceMount:n,children:f.jsx(Ma,{present:n||i.open,children:f.jsx(id,{asChild:!0,container:r,children:a})})})};D9.displayName=eN;var Mu="TooltipContent",j9=x.forwardRef((e,t)=>{const n=Bde(Mu,e.__scopeTooltip),{forceMount:a=n.forceMount,side:r="top",...i}=e,s=Jp(Mu,e.__scopeTooltip);return f.jsx(Ma,{present:a||s.open,children:s.disableHoverableContent?f.jsx(L9,{side:r,...i,ref:t}):f.jsx(Hde,{side:r,...i,ref:t})})}),Hde=x.forwardRef((e,t)=>{const n=Jp(Mu,e.__scopeTooltip),a=QT(Mu,e.__scopeTooltip),r=x.useRef(null),i=Qt(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((S,w)=>{const y=S.currentTarget,_={x:S.clientX,y:S.clientY},E=Kde(_,y.getBoundingClientRect()),k=Zde(_,E),R=Yde(w.getBoundingClientRect()),C=Xde([...k,...R]);c(C),h(!0)},[h]);return x.useEffect(()=>()=>g(),[g]),x.useEffect(()=>{if(u&&m){const S=y=>v(y,m),w=y=>v(y,u);return u.addEventListener("pointerleave",S),m.addEventListener("pointerleave",w),()=>{u.removeEventListener("pointerleave",S),m.removeEventListener("pointerleave",w)}}},[u,m,v,g]),x.useEffect(()=>{if(s){const S=w=>{const y=w.target,_={x:w.clientX,y:w.clientY},E=u?.contains(y)||m?.contains(y),k=!qde(_,s);E?g():k&&(g(),d())};return document.addEventListener("pointermove",S),()=>document.removeEventListener("pointermove",S)}},[u,m,s,d,g]),f.jsx(L9,{...e,ref:i})}),[Vde,Gde]=iy(sp,{isInside:!1}),Wde=Tse("TooltipContent"),L9=x.forwardRef((e,t)=>{const{__scopeTooltip:n,children:a,"aria-label":r,onEscapeKeyDown:i,onPointerDownOutside:s,...c}=e,u=Jp(Mu,n),d=oy(n),{onClose:m}=u;return x.useEffect(()=>(document.addEventListener(oE,m),()=>document.removeEventListener(oE,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]),f.jsx(nd,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:i,onPointerDownOutside:s,onFocusOutside:h=>h.preventDefault(),onDismiss:m,children:f.jsxs(qv,{"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:[f.jsx(Wde,{children:a}),f.jsx(Vde,{scope:n,isInside:!0,children:f.jsx(Mde,{id:u.contentId,role:"tooltip",children:r||a})})]})})});j9.displayName=Mu;var $9="TooltipArrow",M9=x.forwardRef((e,t)=>{const{__scopeTooltip:n,...a}=e,r=oy(n);return Gde($9,n).isInside?null:f.jsx(Xv,{...r,...a,ref:t})});M9.displayName=$9;function Kde(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 Zde(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 Yde(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 qde(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 Xde(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),Jde(t)}function Jde(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 Qde=A9,efe=I9,tfe=O9,nfe=D9,rfe=j9,afe=M9;function P9({delayDuration:e=0,...t}){return f.jsx(Qde,{"data-slot":"tooltip-provider",delayDuration:e,...t})}function $t({...e}){return f.jsx(P9,{children:f.jsx(efe,{"data-slot":"tooltip",...e})})}function Mt({...e}){return f.jsx(tfe,{"data-slot":"tooltip-trigger",...e})}function Pt({className:e,sideOffset:t=0,children:n,...a}){return f.jsx(nfe,{children:f.jsxs(rfe,{"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,f.jsx(afe,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}class ife{name="mcp_inspector_open";properties;constructor(t){this.properties={server_url:t.serverUrl,connection_count:t.connectionCount}}}class aU{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 iU{name="mcp_resource_read";properties;constructor(t){this.properties={resource_uri:t.resourceUri,server_id:t.serverId,success:t.success,error:t.error}}}class oU{name="mcp_prompt_call";properties;constructor(t){this.properties={prompt_name:t.promptName,server_id:t.serverId,success:t.success,error:t.error}}}class sU{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 ofe{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 sfe{name="mcp_server_removed";properties;constructor(t){this.properties={server_id:t.serverId}}}class lfe{name="mcp_command_palette_open";properties;constructor(t){this.properties={trigger:t.trigger}}}class cfe{name="mcp_tool_saved";properties;constructor(t){this.properties={tool_name:t.toolName,server_id:t.serverId}}}function Ix(){try{return"0.11.0-canary.2"}catch{return"0.0.0"}}var ufe={};function Ox(){try{return typeof window<"u"&&typeof document<"u"}catch{return!1}}class lU{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 ms(e){return`mcp_inspector_telemetry_${e}`}class yr{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=Ox(),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 lU(this.POSTHOG_PROXY_URL,3e3)}catch{this._posthogClient=null}try{this._scarfClient=new lU(this.SCARF_PROXY_URL,3e3)}catch{this._scarfClient=null}}}isTelemetryDisabled(){return typeof localStorage<"u"&&localStorage.getItem(ms("disabled"))==="true"||typeof process<"u"&&ufe?.MCP_USE_ANONYMIZED_TELEMETRY==="false"}getStoredSource(){return typeof localStorage<"u"?localStorage.getItem(ms("source")):null}static getInstance(){return yr.instance||(yr.instance=new yr),yr.instance}setSource(t){this._source=t,typeof localStorage<"u"&&localStorage.setItem(ms("source"),t)}getSource(){return this._source}get userId(){if(this._currUserId)return this._currUserId;if(!Ox())return this._currUserId=this.UNKNOWN_USER_ID,this._currUserId;try{const t=localStorage.getItem(ms("user_id"));if(t)this._currUserId=t;else{const n=this.generateUserId();localStorage.setItem(ms("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:Ix(),language:"typescript",source:this._source,package:"inspector"}};await this._posthogClient.logEvent(n)}catch{}if(this._scarfClient)try{const n={};n.mcp_use_version=Ix(),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&&Ox())try{const n=Ix();let a=!1,r=!1;const i=localStorage.getItem(ms("download_version"));if(i?n>i&&(a=!0,r=!1,localStorage.setItem(ms("download_version"),n)):(a=!0,r=!0,localStorage.setItem(ms("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 ife(t);await this.capture(n)}}const dfe={model:"stub-model",stopReason:"endTurn",role:"assistant",content:{type:"text",text:"positive"}};function ffe({requestId:e,serverName:t,onViewDetails:n,onApprove:a,onDeny:r}){return f.jsxs("div",{className:"space-y-3",children:[f.jsxs("div",{children:[f.jsx("strong",{children:"Sampling Request Received"}),f.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:["New request from ",t]})]}),f.jsxs("div",{className:"flex gap-2",children:[f.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"}),f.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(dfe)},children:"Approve"}),f.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"})]})]})}function pfe({requestId:e,serverName:t,mode:n,message:a,url:r,onViewDetails:i,onOpenUrl:s,onCancel:c}){return f.jsxs("div",{className:"space-y-3",children:[f.jsxs("div",{children:[f.jsx("strong",{children:"Elicitation Request Received"}),f.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:["From ",t,": ",a]}),n==="url"&&r&&f.jsx("p",{className:"text-xs text-muted-foreground mt-1 font-mono",children:r})]}),f.jsxs("div",{className:"flex gap-2 flex-wrap",children:[f.jsx("button",{className:"px-3 py-1.5 text-xs font-medium rounded-md hover:bg-accent hover:text-accent-foreground",onClick:u=>{u.stopPropagation(),i()},children:"View Details"}),n==="url"&&s&&f.jsx("button",{className:"px-3 py-1.5 text-xs font-medium rounded-md hover:bg-accent hover:text-accent-foreground",onClick:u=>{u.stopPropagation(),s()},children:"Open URL"}),f.jsx("button",{className:"px-3 py-1.5 text-xs font-medium rounded-md hover:bg-accent hover:text-accent-foreground",onClick:u=>{u.stopPropagation(),c()},children:"Cancel"})]})]})}const Tg=()=>{},Ng=()=>{},Cg=()=>{},Rg=()=>{},U9=x.createContext(null);function tN(){const e=x.use(U9);if(!e)throw new Error("useMcpContext must be used within a McpProvider");return e}function mfe({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 L=new URL(n.proxyAddress),$=new URL(e);u=`${L.origin}${L.pathname}${$.pathname}${$.search}`,d["X-Target-URL"]=e}n?.customHeaders&&(d={...d,...n.customHeaders});const[m,h]=x.useState([]),g=x.useRef(0),[v,S]=x.useState([]),w=x.useRef(0),y=x.useMemo(()=>m.map(L=>({id:L.id,request:L.request,timestamp:L.timestamp,serverName:L.serverName})),[m]),_=x.useMemo(()=>v.map(L=>({id:L.id,request:L.request,timestamp:L.timestamp,serverName:L.serverName})),[v]),E=x.useRef(null),[k,R]=x.useState(!1),C=x.useRef(!1);x.useEffect(()=>{typeof window<"u"&&!C.current&&(C.current=!0,dr(()=>import("./transport-wrapper-browser-BI4dDu3b.js"),[]).then(L=>{E.current=L.wrapTransportForLogging,R(!0),console.log("[McpContext] Transport wrapper loaded")}).catch(L=>{console.error("[McpContext] Failed to load transport wrapper:",L)}))},[]);const I=x.useMemo(()=>{if(!(!k||!E.current))return(L,$)=>{const F=r;return console.log("[McpContext] Applying transport wrapper, serverId:",F,"from connector:",$),E.current(L,F)}},[k,r]),A=`mcp-inspector-notifications-${r}`,O=500,[M,U]=x.useState([]);x.useEffect(()=>{try{const L=localStorage.getItem(A);if(L){const $=JSON.parse(L);Array.isArray($)&&U($)}}catch(L){console.error("Failed to load notifications from localStorage:",L)}},[A]),x.useEffect(()=>{try{localStorage.setItem(A,JSON.stringify(M))}catch(L){console.error("Failed to save notifications to localStorage:",L)}},[M,A]);const H=x.useCallback(L=>{U($=>$.map(F=>F.id===L?{...F,read:!0}:F))},[]),K=x.useCallback(()=>{U(L=>L.map($=>({...$,read:!0})))},[]),ee=x.useCallback(()=>{U([])},[]),J=x.useCallback(L=>{U($=>{const F=[L,...$];return F.length>O?F.slice(0,O):F})},[]),ie=x.useCallback((L,$)=>{h(F=>{const W=F.find(X=>X.id===L);return W?(W.resolve($),F.filter(X=>X.id!==L)):F})},[]),B=x.useCallback((L,$)=>{h(F=>{const W=F.find(X=>X.id===L);return W?(W.reject(new Error($||"User rejected sampling request")),F.filter(X=>X.id!==L)):F})},[]),Z=x.useCallback((L,$)=>{S(F=>{const W=F.find(X=>X.id===L);return W?(W.resolve($),F.filter(X=>X.id!==L)):F})},[]),G=x.useCallback((L,$)=>{S(F=>{const W=F.find(X=>X.id===L);return W?(W.reject(new Error($||"User rejected elicitation request")),F.filter(X=>X.id!==L)):F})},[]),re=x.useCallback(async L=>new Promise(($,F)=>{const W=`sampling-${g.current++}`,X={id:W,request:{params:L},timestamp:Date.now(),serverName:t,resolve:$,reject:F};h(ae=>[...ae,X]),typeof window<"u"&&dr(async()=>{const{toast:ae}=await Promise.resolve().then(()=>hU);return{toast:ae}},void 0).then(({toast:ae})=>{const le=ae(f.jsx(ffe,{requestId:W,serverName:t,onViewDetails:()=>{const Q=new globalThis.CustomEvent("navigate-to-sampling",{detail:{requestId:W}});window.dispatchEvent(Q),ae.dismiss(le)},onApprove:Q=>{h(q=>{const se=q.find(he=>he.id===W);return se?(se.resolve(Q),ae.success("Sampling request approved"),q.filter(he=>he.id!==W)):q}),ae.dismiss(le)},onDeny:()=>{h(Q=>{const q=Q.find(se=>se.id===W);return q?(q.reject(new Error("User denied sampling request from toast")),ae.error("Sampling request denied"),Q.filter(se=>se.id!==W)):Q}),ae.dismiss(le)}}),{duration:5e3})})}),[t]),ne=x.useCallback(async L=>new Promise(($,F)=>{const W=`elicitation-${w.current++}`,X={id:W,request:L,timestamp:Date.now(),serverName:t,resolve:$,reject:F};S(ae=>[...ae,X]),typeof window<"u"&&dr(async()=>{const{toast:ae}=await Promise.resolve().then(()=>hU);return{toast:ae}},void 0).then(({toast:ae})=>{const le=ae(f.jsx(pfe,{requestId:W,serverName:t,mode:L.mode||"form",message:L.message,url:L.mode==="url"?L.url:void 0,onViewDetails:()=>{const Q=new globalThis.CustomEvent("navigate-to-elicitation",{detail:{requestId:W}});window.dispatchEvent(Q),ae.dismiss(le)},onOpenUrl:L.mode==="url"?()=>{window.open(L.url,"_blank"),ae.dismiss(le)}:void 0,onCancel:()=>{S(Q=>{const q=Q.find(se=>se.id===W);return q?(q.reject(new Error("User cancelled elicitation request from toast")),ae.error("Elicitation request cancelled"),Q.filter(se=>se.id!==W)):Q}),ae.dismiss(le)}}),{duration:5e3})})}),[t]),j=NT({url:u,callbackUrl:c,customHeaders:Object.keys(d).length>0?d:void 0,transportType:a||"http",preventAutoAuth:!0,useRedirectFlow:!0,enabled:k,wrapTransport:I,onNotification:L=>{J({id:globalThis.crypto.randomUUID(),method:L.method,params:L.params,timestamp:Date.now(),read:!1})},samplingCallback:re,onElicitation:ne}),V=x.useRef(i),z=x.useRef(null);return x.useEffect(()=>{V.current=i},[i]),x.useEffect(()=>{if(typeof queueMicrotask<"u")queueMicrotask(()=>{j.state==="ready"&&j.serverInfo&&console.log("[McpContext] Server info available:",j.serverInfo);const L=M.filter(W=>!W.read).length,$={id:r,url:e,name:j.serverInfo?.name||t,state:j.state,tools:j.tools,resources:j.resources,prompts:j.prompts,error:j.error??null,authUrl:j.authUrl??null,customHeaders:d,transportType:a,proxyConfig:n,serverInfo:j.serverInfo,capabilities:j.capabilities,notifications:M,unreadNotificationCount:L,markNotificationRead:H,markAllNotificationsRead:K,clearNotifications:ee,pendingSamplingRequests:y,approveSampling:ie,rejectSampling:B,pendingElicitationRequests:_,approveElicitation:Z,rejectElicitation:G,callTool:j.callTool,readResource:j.readResource,listPrompts:j.listPrompts,getPrompt:j.getPrompt,authenticate:j.authenticate,retry:j.retry,clearStorage:j.clearStorage,disconnect:j.disconnect,client:j.client},F=z.current;(!F||F.state!==$.state||F.error!==$.error||F.authUrl!==$.authUrl||F.name!==$.name||F.tools.length!==$.tools.length||F.resources.length!==$.resources.length||F.prompts.length!==$.prompts.length||F.serverInfo!==$.serverInfo||F.capabilities!==$.capabilities||F.notifications.length!==$.notifications.length||F.unreadNotificationCount!==$.unreadNotificationCount||F.pendingSamplingRequests.length!==$.pendingSamplingRequests.length||F.pendingElicitationRequests.length!==$.pendingElicitationRequests.length||!F.client)&&(z.current=$,V.current($))});else{const L=M.filter(W=>!W.read).length,$={id:r,url:e,name:j.serverInfo?.name||t,state:j.state,tools:j.tools,resources:j.resources,prompts:j.prompts,error:j.error??null,authUrl:j.authUrl??null,customHeaders:d,transportType:a,proxyConfig:n,serverInfo:j.serverInfo,capabilities:j.capabilities,notifications:M,unreadNotificationCount:L,markNotificationRead:H,markAllNotificationsRead:K,clearNotifications:ee,pendingSamplingRequests:y,approveSampling:ie,rejectSampling:B,pendingElicitationRequests:_,approveElicitation:Z,rejectElicitation:G,callTool:j.callTool,readResource:j.readResource,listPrompts:j.listPrompts,getPrompt:j.getPrompt,authenticate:j.authenticate,retry:j.retry,clearStorage:j.clearStorage,disconnect:j.disconnect,client:j.client},F=z.current;(!F||F.state!==$.state||F.error!==$.error||F.authUrl!==$.authUrl||F.name!==$.name||F.tools.length!==$.tools.length||F.resources.length!==$.resources.length||F.prompts.length!==$.prompts.length||F.serverInfo!==$.serverInfo||F.capabilities!==$.capabilities||F.notifications.length!==$.notifications.length||F.unreadNotificationCount!==$.unreadNotificationCount||F.pendingSamplingRequests.length!==$.pendingSamplingRequests.length||F.pendingElicitationRequests.length!==$.pendingElicitationRequests.length||!F.client)&&(z.current=$,V.current($))}},[e,t,a,n,d,r,j.state,j.tools,j.resources,j.prompts,j.error,j.authUrl,j.serverInfo,j.capabilities,j.client,M,H,K,ee,j.callTool,j.readResource,j.listPrompts,j.getPrompt,j.authenticate,j.retry,j.clearStorage,m,ie,B,_,Z,G]),null}function hfe({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:Tg,rejectSampling:Ng,pendingElicitationRequests:[],approveElicitation:Cg,rejectElicitation:Rg,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 R=c.find(A=>A.url===y),C=t.find(A=>A.url===y);if(R&&C){if(JSON.stringify(R.proxyConfig)!==JSON.stringify(E)&&E){u(O=>O.filter(M=>M.url!==y)),n(O=>O.filter(M=>M.url!==y)),setTimeout(()=>{const O={id:y,url:y,name:_||R.name||"MCP Server",proxyConfig:E,transportType:k||R.transportType};u(M=>[...M,O]),n(M=>[...M,{id:y,url:y,name:_||R.name||"MCP Server",state:"connecting",tools:[],resources:[],prompts:[],error:null,authUrl:null,customHeaders:E?.customHeaders,transportType:k||R.transportType,proxyConfig:E,notifications:[],unreadNotificationCount:0,markNotificationRead:()=>{},markAllNotificationsRead:()=>{},clearNotifications:()=>{},pendingSamplingRequests:[],approveSampling:Tg,rejectSampling:Ng,pendingElicitationRequests:[],approveElicitation:Cg,rejectElicitation:Rg,callTool:async()=>{},readResource:async()=>{},listPrompts:async()=>{},getPrompt:async()=>{},authenticate:()=>{},retry:()=>{},clearStorage:()=>{},disconnect:()=>{},client:null}])},10);return}return}if(R&&!C){(E||k)&&u(A=>A.map(O=>O.url===y?{...O,proxyConfig:E||O.proxyConfig,transportType:k||O.transportType,name:_||O.name}:O)),n(A=>[...A,{id:R.id||y,url:y,name:_||R.name||"MCP Server",state:"connecting",tools:[],resources:[],prompts:[],error:null,authUrl:null,customHeaders:E?.customHeaders||R.proxyConfig?.customHeaders,transportType:k||R.transportType,proxyConfig:E||R.proxyConfig,notifications:[],unreadNotificationCount:0,markNotificationRead:()=>{},markAllNotificationsRead:()=>{},clearNotifications:()=>{},pendingSamplingRequests:[],approveSampling:Tg,rejectSampling:Ng,pendingElicitationRequests:[],approveElicitation:Cg,rejectElicitation:Rg,callTool:async()=>{},readResource:async()=>{},listPrompts:async()=>{},getPrompt:async()=>{},authenticate:()=>{},retry:()=>{},clearStorage:()=>{},disconnect:()=>{},client:null}]);return}const I={id:y,url:y,name:_||"MCP Server",proxyConfig:E,transportType:k};u(A=>[...A,I]),n(A=>[...A,{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:Tg,rejectSampling:Ng,pendingElicitationRequests:[],approveElicitation:Cg,rejectElicitation:Rg,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(R=>R.id!==y)),n(k=>k.filter(R=>R.id!==y));const E=localStorage.getItem("mcp-inspector-connections");if(E)try{const R=JSON.parse(E).filter(C=>(C.id||C.url)!==y);localStorage.setItem("mcp-inspector-connections",JSON.stringify(R))}catch(k){console.error("Failed to update localStorage on remove:",k)}yr.getInstance().capture(new sfe({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(C=>C.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&&k.pendingElicitationRequests.length===y.pendingElicitationRequests.length)return _;const R=[..._];return R[E]=y,R})},[]),v=x.useCallback(y=>{console.log("Connect requested for:",y)},[]),S=x.useCallback(y=>{console.log("Disconnect requested for:",y)},[]),w=x.useMemo(()=>({connections:t,addConnection:d,removeConnection:m,updateConnectionConfig:h,autoConnect:i,setAutoConnect:s,connectServer:v,disconnectServer:S,configLoaded:a}),[t,d,m,h,i,v,S,a]);return f.jsxs(U9.Provider,{value:w,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),f.jsx(mfe,{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 gfe=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),bfe=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,a)=>a?a.toUpperCase():n.toLowerCase()),cU=e=>{const t=bfe(e);return t.charAt(0).toUpperCase()+t.slice(1)},z9=(...e)=>e.filter((t,n,a)=>!!t&&t.trim()!==""&&a.indexOf(t)===n).join(" ").trim(),vfe=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};var yfe={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 wfe=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,...yfe,width:t,height:t,stroke:e,strokeWidth:a?Number(n)*24/Number(t):n,className:z9("lucide",r),...!i&&!vfe(c)&&{"aria-hidden":"true"},...c},[...s.map(([d,m])=>x.createElement(d,m)),...Array.isArray(i)?i:[i]]));const Xe=(e,t)=>{const n=x.forwardRef(({className:a,...r},i)=>x.createElement(wfe,{ref:i,iconNode:t,className:z9(`lucide-${gfe(cU(e))}`,`lucide-${e}`,a),...r}));return n.displayName=cU(e),n};const xfe=[["path",{d:"M12 17V3",key:"1cwfxf"}],["path",{d:"m6 11 6 6 6-6",key:"12ii2o"}],["path",{d:"M19 21H5",key:"150jfl"}]],Sfe=Xe("arrow-down-to-line",xfe);const Efe=[["path",{d:"m18 9-6-6-6 6",key:"kcunyi"}],["path",{d:"M12 3v14",key:"7cf3v8"}],["path",{d:"M5 21h14",key:"11awu3"}]],_fe=Xe("arrow-up-from-line",Efe);const kfe=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Tfe=Xe("arrow-up",kfe);const Nfe=[["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"}]],nN=Xe("bell",Nfe);const Cfe=[["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"}]],F9=Xe("brush",Cfe);const Rfe=[["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"}]],Afe=Xe("bug",Rfe);const Ife=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],ga=Xe("check",Ife);const Ofe=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Kl=Xe("chevron-down",Ofe);const Dfe=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],jfe=Xe("chevron-right",Dfe);const Lfe=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],rN=Xe("chevron-left",Lfe);const $fe=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],Mfe=Xe("chevron-up",$fe);const Pfe=[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]],Ufe=Xe("chevrons-up-down",Pfe);const zfe=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}]],uU=Xe("circle-minus",zfe);const Ffe=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Pu=Xe("clock",Ffe);const Bfe=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],B9=Xe("code",Bfe);const Hfe=[["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"}]],Vfe=Xe("cog",Hfe);const Gfe=[["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"}]],Wfe=Xe("command",Gfe);const Kfe=[["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"}]],Br=Xe("copy",Kfe);const Zfe=[["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"}]],sy=Xe("database",Zfe);const Yfe=[["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"}]],Qp=Xe("download",Yfe);const qfe=[["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"}]],Xfe=Xe("ellipsis-vertical",qfe);const Jfe=[["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"}]],lE=Xe("external-link",Jfe);const Qfe=[["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"}]],H9=Xe("eye-off",Qfe);const epe=[["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"}]],cE=Xe("eye",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"}],["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}]],npe=Xe("file-code",tpe);const rpe=[["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"}]],ape=Xe("file-image",rpe);const ipe=[["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"}]],aN=Xe("file-text",ipe);const ope=[["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"}]],spe=Xe("file",ope);const lpe=[["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"}]],cpe=Xe("folder-open",lpe);const upe=[["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"}]],dpe=Xe("globe",upe);const fpe=[["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"}]],ppe=Xe("grip-vertical",fpe);const mpe=[["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"}]],V9=Xe("hash",mpe);const hpe=[["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"}]],zb=Xe("history",hpe);const gpe=[["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"}]],G9=Xe("key",gpe);const bpe=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Is=Xe("loader-circle",bpe);const vpe=[["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"}]],iN=Xe("maximize-2",vpe);const ype=[["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"}]],oN=Xe("maximize",ype);const wpe=[["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"}]],xpe=Xe("message-circle",wpe);const Spe=[["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"}]],lp=Xe("message-square",Spe);const Epe=[["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"}]],_pe=Xe("minimize",Epe);const kpe=[["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"}]],dU=Xe("monitor",kpe);const Tpe=[["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"}]],Npe=Xe("moon",Tpe);const Cpe=[["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"}]],Rpe=Xe("picture-in-picture",Cpe);const Ape=[["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"}]],W9=Xe("play",Ape);const Ipe=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],K9=Xe("plus",Ipe);const Ope=[["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"}]],fU=Xe("rotate-ccw",Ope);const Dpe=[["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"}]],sN=Xe("save",Dpe);const jpe=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],sd=Xe("search",jpe);const Lpe=[["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"}]],$pe=Xe("send",Lpe);const Mpe=[["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"}]],Ppe=Xe("server",Mpe);const Upe=[["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"}]],fu=Xe("settings",Upe);const zpe=[["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"}]],Fpe=Xe("shield",zpe);const Bpe=[["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"}]],Hpe=Xe("sparkles",Bpe);const Vpe=[["path",{d:"M21 10.656V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.344",key:"2acyp4"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],Z9=Xe("square-check-big",Vpe);const Gpe=[["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"}]],Wpe=Xe("square-pen",Gpe);const Kpe=[["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"}]],Zpe=Xe("sun-dim",Kpe);const Ype=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],Dx=Xe("terminal",Ype);const qpe=[["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"}]],Os=Xe("trash-2",qpe);const Xpe=[["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"}]],Jpe=Xe("trash",Xpe);const Qpe=[["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"}]],Ll=Xe("wrench",Qpe);const eme=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Wi=Xe("x",eme);const tme=[["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"}]],cp=Xe("zap",tme);function nme(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 rme=e=>{switch(e){case"success":return ome;case"info":return lme;case"warning":return sme;case"error":return cme;default:return null}},ame=Array(12).fill(0),ime=({visible:e,className:t})=>ue.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},ue.createElement("div",{className:"sonner-spinner"},ame.map((n,a)=>ue.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${a}`})))),ome=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"})),sme=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"})),lme=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"})),cme=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"})),ume=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"})),dme=()=>{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 uE=1;class fme{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:uE++,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(mme(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,S=typeof h=="object"&&!ue.isValidElement(h)?h:{message:h};this.create({id:a,type:"error",description:g,...S})}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,S=typeof h=="object"&&!ue.isValidElement(h)?h:{message:h};this.create({id:a,type:"error",description:g,...S})}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,S=typeof h=="object"&&!ue.isValidElement(h)?h:{message:h};this.create({id:a,type:"success",description:g,...S})}}).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||uE++;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 fa=new fme,pme=(e,t)=>{const n=t?.id||uE++;return fa.addToast({title:e,...t,id:n}),n},mme=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",hme=pme,gme=()=>fa.toasts,bme=()=>fa.getActiveToasts(),Jt=Object.assign(hme,{success:fa.success,info:fa.info,warning:fa.warning,error:fa.error,custom:fa.custom,message:fa.message,promise:fa.promise,dismiss:fa.dismiss,loading:fa.loading},{getHistory:gme,getToasts:bme});nme("[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 Ag(e){return e.label!==void 0}const vme=3,yme="24px",wme="16px",pU=4e3,xme=356,Sme=14,Eme=45,_me=200;function Di(...e){return e.filter(Boolean).join(" ")}function kme(e){const[t,n]=e.split("-"),a=[];return t&&a.push(t),n&&a.push(n),a}const Tme=e=>{var t,n,a,r,i,s,c,u,d;const{invert:m,toast:h,unstyled:g,interacting:v,setHeights:S,visibleToasts:w,heights:y,index:_,toasts:E,expanded:k,removeToast:R,defaultRichColors:C,closeButton:I,style:A,cancelButtonStyle:O,actionButtonStyle:M,className:U="",descriptionClassName:H="",duration:K,position:ee,gap:J,expandByDefault:ie,classNames:B,icons:Z,closeButtonAriaLabel:G="Close toast"}=e,[re,ne]=ue.useState(null),[j,V]=ue.useState(null),[z,L]=ue.useState(!1),[$,F]=ue.useState(!1),[W,X]=ue.useState(!1),[ae,le]=ue.useState(!1),[Q,q]=ue.useState(!1),[se,he]=ue.useState(0),[ce,ke]=ue.useState(0),He=ue.useRef(h.duration||K||pU),Se=ue.useRef(null),_e=ue.useRef(null),Ue=_===0,fe=_+1<=w,Ie=h.type,Fe=h.dismissible!==!1,xe=h.className||"",it=h.descriptionClassName||"",nt=ue.useMemo(()=>y.findIndex(Ye=>Ye.toastId===h.id)||0,[y,h.id]),mt=ue.useMemo(()=>{var Ye;return(Ye=h.closeButton)!=null?Ye:I},[h.closeButton,I]),Ct=ue.useMemo(()=>h.duration||K||pU,[h.duration,K]),Le=ue.useRef(0),ze=ue.useRef(0),ht=ue.useRef(0),Qe=ue.useRef(null),[Rt,rt]=ee.split("-"),Oe=ue.useMemo(()=>y.reduce((Ye,vt,jt)=>jt>=nt?Ye:Ye+vt.height,0),[y,nt]),$e=dme(),Be=h.invert||m,ut=Ie==="loading";ze.current=ue.useMemo(()=>nt*J+Oe,[nt,Oe]),ue.useEffect(()=>{He.current=Ct},[Ct]),ue.useEffect(()=>{L(!0)},[]),ue.useEffect(()=>{const Ye=_e.current;if(Ye){const vt=Ye.getBoundingClientRect().height;return ke(vt),S(jt=>[{toastId:h.id,height:vt,position:h.position},...jt]),()=>S(jt=>jt.filter(Lt=>Lt.toastId!==h.id))}},[S,h.id]),ue.useLayoutEffect(()=>{if(!z)return;const Ye=_e.current,vt=Ye.style.height;Ye.style.height="auto";const jt=Ye.getBoundingClientRect().height;Ye.style.height=vt,ke(jt),S(Lt=>Lt.find(fn=>fn.toastId===h.id)?Lt.map(fn=>fn.toastId===h.id?{...fn,height:jt}:fn):[{toastId:h.id,height:jt,position:h.position},...Lt])},[z,h.title,h.description,S,h.id,h.jsx,h.action,h.cancel]);const dt=ue.useCallback(()=>{F(!0),he(ze.current),S(Ye=>Ye.filter(vt=>vt.toastId!==h.id)),setTimeout(()=>{R(h)},_me)},[h,R,S,ze]);ue.useEffect(()=>{if(h.promise&&Ie==="loading"||h.duration===1/0||h.type==="loading")return;let Ye;return k||v||$e?(()=>{if(ht.current<Le.current){const Lt=new Date().getTime()-Le.current;He.current=He.current-Lt}ht.current=new Date().getTime()})():(()=>{He.current!==1/0&&(Le.current=new Date().getTime(),Ye=setTimeout(()=>{h.onAutoClose==null||h.onAutoClose.call(h,h),dt()},He.current))})(),()=>clearTimeout(Ye)},[k,v,h,Ie,$e,dt]),ue.useEffect(()=>{h.delete&&(dt(),h.onDismiss==null||h.onDismiss.call(h,h))},[dt,h.delete]);function wt(){var Ye;if(Z?.loading){var vt;return ue.createElement("div",{className:Di(B?.loader,h==null||(vt=h.classNames)==null?void 0:vt.loader,"sonner-loader"),"data-visible":Ie==="loading"},Z.loading)}return ue.createElement(ime,{className:Di(B?.loader,h==null||(Ye=h.classNames)==null?void 0:Ye.loader),visible:Ie==="loading"})}const xt=h.icon||Z?.[Ie]||rme(Ie);var dn,hn;return ue.createElement("li",{tabIndex:0,ref:_e,className:Di(U,xe,B?.toast,h==null||(t=h.classNames)==null?void 0:t.toast,B?.default,B?.[Ie],h==null||(n=h.classNames)==null?void 0:n[Ie]),"data-sonner-toast":"","data-rich-colors":(dn=h.richColors)!=null?dn:C,"data-styled":!(h.jsx||h.unstyled||g),"data-mounted":z,"data-promise":!!h.promise,"data-swiped":Q,"data-removed":$,"data-visible":fe,"data-y-position":Rt,"data-x-position":rt,"data-index":_,"data-front":Ue,"data-swiping":W,"data-dismissible":Fe,"data-type":Ie,"data-invert":Be,"data-swipe-out":ae,"data-swipe-direction":j,"data-expanded":!!(k||ie&&z),"data-testid":h.testId,style:{"--index":_,"--toasts-before":_,"--z-index":E.length-_,"--offset":`${$?se:ze.current}px`,"--initial-height":ie?"auto":`${ce}px`,...A,...h.style},onDragEnd:()=>{X(!1),ne(null),Qe.current=null},onPointerDown:Ye=>{Ye.button!==2&&(ut||!Fe||(Se.current=new Date,he(ze.current),Ye.target.setPointerCapture(Ye.pointerId),Ye.target.tagName!=="BUTTON"&&(X(!0),Qe.current={x:Ye.clientX,y:Ye.clientY})))},onPointerUp:()=>{var Ye,vt,jt;if(ae||!Fe)return;Qe.current=null;const Lt=Number(((Ye=_e.current)==null?void 0:Ye.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),fr=Number(((vt=_e.current)==null?void 0:vt.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),fn=new Date().getTime()-((jt=Se.current)==null?void 0:jt.getTime()),Kn=re==="x"?Lt:fr,Zn=Math.abs(Kn)/fn;if(Math.abs(Kn)>=Eme||Zn>.11){he(ze.current),h.onDismiss==null||h.onDismiss.call(h,h),V(re==="x"?Lt>0?"right":"left":fr>0?"down":"up"),dt(),le(!0);return}else{var wn,pn;(wn=_e.current)==null||wn.style.setProperty("--swipe-amount-x","0px"),(pn=_e.current)==null||pn.style.setProperty("--swipe-amount-y","0px")}q(!1),X(!1),ne(null)},onPointerMove:Ye=>{var vt,jt,Lt;if(!Qe.current||!Fe||((vt=window.getSelection())==null?void 0:vt.toString().length)>0)return;const fn=Ye.clientY-Qe.current.y,Kn=Ye.clientX-Qe.current.x;var Zn;const wn=(Zn=e.swipeDirections)!=null?Zn:kme(ee);!re&&(Math.abs(Kn)>1||Math.abs(fn)>1)&&ne(Math.abs(Kn)>Math.abs(fn)?"x":"y");let pn={x:0,y:0};const ra=en=>1/(1.5+Math.abs(en)/20);if(re==="y"){if(wn.includes("top")||wn.includes("bottom"))if(wn.includes("top")&&fn<0||wn.includes("bottom")&&fn>0)pn.y=fn;else{const en=fn*ra(fn);pn.y=Math.abs(en)<Math.abs(fn)?en:fn}}else if(re==="x"&&(wn.includes("left")||wn.includes("right")))if(wn.includes("left")&&Kn<0||wn.includes("right")&&Kn>0)pn.x=Kn;else{const en=Kn*ra(Kn);pn.x=Math.abs(en)<Math.abs(Kn)?en:Kn}(Math.abs(pn.x)>0||Math.abs(pn.y)>0)&&q(!0),(jt=_e.current)==null||jt.style.setProperty("--swipe-amount-x",`${pn.x}px`),(Lt=_e.current)==null||Lt.style.setProperty("--swipe-amount-y",`${pn.y}px`)}},mt&&!h.jsx&&Ie!=="loading"?ue.createElement("button",{"aria-label":G,"data-disabled":ut,"data-close-button":!0,onClick:ut||!Fe?()=>{}:()=>{dt(),h.onDismiss==null||h.onDismiss.call(h,h)},className:Di(B?.closeButton,h==null||(a=h.classNames)==null?void 0:a.closeButton)},(hn=Z?.close)!=null?hn:ume):null,(Ie||h.icon||h.promise)&&h.icon!==null&&(Z?.[Ie]!==null||h.icon)?ue.createElement("div",{"data-icon":"",className:Di(B?.icon,h==null||(r=h.classNames)==null?void 0:r.icon)},h.promise||h.type==="loading"&&!h.icon?h.icon||wt():null,h.type!=="loading"?xt:null):null,ue.createElement("div",{"data-content":"",className:Di(B?.content,h==null||(i=h.classNames)==null?void 0:i.content)},ue.createElement("div",{"data-title":"",className:Di(B?.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:Di(H,it,B?.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&&Ag(h.cancel)?ue.createElement("button",{"data-button":!0,"data-cancel":!0,style:h.cancelButtonStyle||O,onClick:Ye=>{Ag(h.cancel)&&Fe&&(h.cancel.onClick==null||h.cancel.onClick.call(h.cancel,Ye),dt())},className:Di(B?.cancelButton,h==null||(u=h.classNames)==null?void 0:u.cancelButton)},h.cancel.label):null,ue.isValidElement(h.action)?h.action:h.action&&Ag(h.action)?ue.createElement("button",{"data-button":!0,"data-action":!0,style:h.actionButtonStyle||M,onClick:Ye=>{Ag(h.action)&&(h.action.onClick==null||h.action.onClick.call(h.action,Ye),!Ye.defaultPrevented&&dt())},className:Di(B?.actionButton,h==null||(d=h.classNames)==null?void 0:d.actionButton)},h.action.label):null)};function mU(){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 Nme(e,t){const n={};return[e,t].forEach((a,r)=>{const i=r===1,s=i?"--mobile-offset":"--offset",c=i?wme:yme;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 Y9=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:S,style:w,visibleToasts:y=vme,toastOptions:_,dir:E=mU(),gap:k=Sme,icons:R,containerAriaLabel:C="Notifications"}=t,[I,A]=ue.useState([]),O=ue.useMemo(()=>a?I.filter(z=>z.toasterId===a):I.filter(z=>!z.toasterId),[I,a]),M=ue.useMemo(()=>Array.from(new Set([i].concat(O.filter(z=>z.position).map(z=>z.position)))),[O,i]),[U,H]=ue.useState([]),[K,ee]=ue.useState(!1),[J,ie]=ue.useState(!1),[B,Z]=ue.useState(g!=="system"?g:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),G=ue.useRef(null),re=s.join("+").replace(/Key/g,"").replace(/Digit/g,""),ne=ue.useRef(null),j=ue.useRef(!1),V=ue.useCallback(z=>{A(L=>{var $;return($=L.find(F=>F.id===z.id))!=null&&$.delete||fa.dismiss(z.id),L.filter(({id:F})=>F!==z.id)})},[]);return ue.useEffect(()=>fa.subscribe(z=>{if(z.dismiss){requestAnimationFrame(()=>{A(L=>L.map($=>$.id===z.id?{...$,delete:!0}:$))});return}setTimeout(()=>{NH.flushSync(()=>{A(L=>{const $=L.findIndex(F=>F.id===z.id);return $!==-1?[...L.slice(0,$),{...L[$],...z},...L.slice($+1)]:[z,...L]})})})}),[I]),ue.useEffect(()=>{if(g!=="system"){Z(g);return}if(g==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?Z("dark"):Z("light")),typeof window>"u")return;const z=window.matchMedia("(prefers-color-scheme: dark)");try{z.addEventListener("change",({matches:L})=>{Z(L?"dark":"light")})}catch{z.addListener(({matches:$})=>{try{Z($?"dark":"light")}catch(F){console.error(F)}})}},[g]),ue.useEffect(()=>{I.length<=1&&ee(!1)},[I]),ue.useEffect(()=>{const z=L=>{var $;if(s.every(X=>L[X]||L.code===X)){var W;ee(!0),(W=G.current)==null||W.focus()}L.code==="Escape"&&(document.activeElement===G.current||($=G.current)!=null&&$.contains(document.activeElement))&&ee(!1)};return document.addEventListener("keydown",z),()=>document.removeEventListener("keydown",z)},[s]),ue.useEffect(()=>{if(G.current)return()=>{ne.current&&(ne.current.focus({preventScroll:!0}),ne.current=null,j.current=!1)}},[G.current]),ue.createElement("section",{ref:n,"aria-label":`${C} ${re}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},M.map((z,L)=>{var $;const[F,W]=z.split("-");return O.length?ue.createElement("ol",{key:z,dir:E==="auto"?mU():E,tabIndex:-1,ref:G,className:d,"data-sonner-toaster":!0,"data-sonner-theme":B,"data-y-position":F,"data-x-position":W,style:{"--front-toast-height":`${(($=U[0])==null?void 0:$.height)||0}px`,"--width":`${xme}px`,"--gap":`${k}px`,...w,...Nme(m,h)},onBlur:X=>{j.current&&!X.currentTarget.contains(X.relatedTarget)&&(j.current=!1,ne.current&&(ne.current.focus({preventScroll:!0}),ne.current=null))},onFocus:X=>{X.target instanceof HTMLElement&&X.target.dataset.dismissible==="false"||j.current||(j.current=!0,ne.current=X.relatedTarget)},onMouseEnter:()=>ee(!0),onMouseMove:()=>ee(!0),onMouseLeave:()=>{J||ee(!1)},onDragEnd:()=>ee(!1),onPointerDown:X=>{X.target instanceof HTMLElement&&X.target.dataset.dismissible==="false"||ie(!0)},onPointerUp:()=>ie(!1)},O.filter(X=>!X.position&&L===0||X.position===z).map((X,ae)=>{var le,Q;return ue.createElement(Tme,{key:X.id,icons:R,index:ae,toast:X,defaultRichColors:v,duration:(le=_?.duration)!=null?le:S,className:_?.className,descriptionClassName:_?.descriptionClassName,invert:r,visibleToasts:y,closeButton:(Q=_?.closeButton)!=null?Q:u,interacting:J,position:z,style:_?.style,unstyled:_?.unstyled,classNames:_?.classNames,cancelButtonStyle:_?.cancelButtonStyle,actionButtonStyle:_?.actionButtonStyle,closeButtonAriaLabel:_?.closeButtonAriaLabel,removeToast:V,toasts:O.filter(q=>q.position==X.position),heights:U.filter(q=>q.position==X.position),setHeights:H,expandByDefault:c,gap:k,expanded:K,swipeDirections:t.swipeDirections})})):null}))}),hU=Object.freeze(Object.defineProperty({__proto__:null,Toaster:Y9,toast:Jt},Symbol.toStringTag,{value:"Module"}));var ly="Dialog",[q9]=ki(ly),[Cme,Ti]=q9(ly),X9=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]=Io({prop:a,defaultProp:r??!1,onChange:i,caller:ly});return f.jsx(Cme,{scope:t,triggerRef:c,contentRef:u,contentId:Dr(),titleId:Dr(),descriptionId:Dr(),open:d,onOpenChange:m,onOpenToggle:x.useCallback(()=>m(h=>!h),[m]),modal:s,children:n})};X9.displayName=ly;var J9="DialogTrigger",Q9=x.forwardRef((e,t)=>{const{__scopeDialog:n,...a}=e,r=Ti(J9,n),i=Qt(t,r.triggerRef);return f.jsx(Et.button,{type:"button","aria-haspopup":"dialog","aria-expanded":r.open,"aria-controls":r.contentId,"data-state":uN(r.open),...a,ref:i,onClick:Ve(e.onClick,r.onOpenToggle)})});Q9.displayName=J9;var lN="DialogPortal",[Rme,e8]=q9(lN,{forceMount:void 0}),t8=e=>{const{__scopeDialog:t,forceMount:n,children:a,container:r}=e,i=Ti(lN,t);return f.jsx(Rme,{scope:t,forceMount:n,children:x.Children.map(a,s=>f.jsx(Ma,{present:n||i.open,children:f.jsx(id,{asChild:!0,container:r,children:s})}))})};t8.displayName=lN;var Fb="DialogOverlay",n8=x.forwardRef((e,t)=>{const n=e8(Fb,e.__scopeDialog),{forceMount:a=n.forceMount,...r}=e,i=Ti(Fb,e.__scopeDialog);return i.modal?f.jsx(Ma,{present:a||i.open,children:f.jsx(Ime,{...r,ref:t})}):null});n8.displayName=Fb;var Ame=Dl("DialogOverlay.RemoveScroll"),Ime=x.forwardRef((e,t)=>{const{__scopeDialog:n,...a}=e,r=Ti(Fb,n);return f.jsx(Yp,{as:Ame,allowPinchZoom:!0,shards:[r.contentRef],children:f.jsx(Et.div,{"data-state":uN(r.open),...a,ref:t,style:{pointerEvents:"auto",...a.style}})})}),$l="DialogContent",r8=x.forwardRef((e,t)=>{const n=e8($l,e.__scopeDialog),{forceMount:a=n.forceMount,...r}=e,i=Ti($l,e.__scopeDialog);return f.jsx(Ma,{present:a||i.open,children:i.modal?f.jsx(Ome,{...r,ref:t}):f.jsx(Dme,{...r,ref:t})})});r8.displayName=$l;var Ome=x.forwardRef((e,t)=>{const n=Ti($l,e.__scopeDialog),a=x.useRef(null),r=Qt(t,n.contentRef,a);return x.useEffect(()=>{const i=a.current;if(i)return Jv(i)},[]),f.jsx(a8,{...e,ref:r,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Ve(e.onCloseAutoFocus,i=>{i.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:Ve(e.onPointerDownOutside,i=>{const s=i.detail.originalEvent,c=s.button===0&&s.ctrlKey===!0;(s.button===2||c)&&i.preventDefault()}),onFocusOutside:Ve(e.onFocusOutside,i=>i.preventDefault())})}),Dme=x.forwardRef((e,t)=>{const n=Ti($l,e.__scopeDialog),a=x.useRef(!1),r=x.useRef(!1);return f.jsx(a8,{...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()}})}),a8=x.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:a,onOpenAutoFocus:r,onCloseAutoFocus:i,...s}=e,c=Ti($l,n),u=x.useRef(null),d=Qt(t,u);return Vv(),f.jsxs(f.Fragment,{children:[f.jsx(Gp,{asChild:!0,loop:!0,trapped:a,onMountAutoFocus:r,onUnmountAutoFocus:i,children:f.jsx(nd,{role:"dialog",id:c.contentId,"aria-describedby":c.descriptionId,"aria-labelledby":c.titleId,"data-state":uN(c.open),...s,ref:d,onDismiss:()=>c.onOpenChange(!1)})}),f.jsxs(f.Fragment,{children:[f.jsx(jme,{titleId:c.titleId}),f.jsx($me,{contentRef:u,descriptionId:c.descriptionId})]})]})}),cN="DialogTitle",i8=x.forwardRef((e,t)=>{const{__scopeDialog:n,...a}=e,r=Ti(cN,n);return f.jsx(Et.h2,{id:r.titleId,...a,ref:t})});i8.displayName=cN;var o8="DialogDescription",s8=x.forwardRef((e,t)=>{const{__scopeDialog:n,...a}=e,r=Ti(o8,n);return f.jsx(Et.p,{id:r.descriptionId,...a,ref:t})});s8.displayName=o8;var l8="DialogClose",c8=x.forwardRef((e,t)=>{const{__scopeDialog:n,...a}=e,r=Ti(l8,n);return f.jsx(Et.button,{type:"button",...a,ref:t,onClick:Ve(e.onClick,()=>r.onOpenChange(!1))})});c8.displayName=l8;function uN(e){return e?"open":"closed"}var u8="DialogTitleWarning",[lke,d8]=wse(u8,{contentName:$l,titleName:cN,docsSlug:"dialog"}),jme=({titleId:e})=>{const t=d8(u8),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
102
+ `)},uue=0,Pc=[];function due(e){var t=x.useRef([]),n=x.useRef([0,0]),a=x.useRef(),r=x.useState(uue++)[0],i=x.useState(CV)[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 w=Oce([e.lockRef.current],(e.shards||[]).map(nU),!0).filter(Boolean);return w.forEach(function(y){return y.classList.add("allow-interactivity-".concat(r))}),function(){document.body.classList.remove("block-interactivity-".concat(r)),w.forEach(function(y){return y.classList.remove("allow-interactivity-".concat(r))})}}},[e.inert,e.lockRef.current,e.shards]);var c=x.useCallback(function(w,y){if("touches"in w&&w.touches.length===2||w.type==="wheel"&&w.ctrlKey)return!s.current.allowPinchZoom;var _=kg(w),E=n.current,k="deltaX"in w?w.deltaX:E[0]-_[0],R="deltaY"in w?w.deltaY:E[1]-_[1],C,I=w.target,A=Math.abs(k)>Math.abs(R)?"h":"v";if("touches"in w&&A==="h"&&I.type==="range")return!1;var O=eU(A,I);if(!O)return!0;if(O?C=A:(C=A==="v"?"h":"v",O=eU(A,I)),!O)return!1;if(!a.current&&"changedTouches"in w&&(k||R)&&(a.current=C),!C)return!0;var M=a.current||C;return sue(M,y,w,M==="h"?k:R)},[]),u=x.useCallback(function(w){var y=w;if(!(!Pc.length||Pc[Pc.length-1]!==i)){var _="deltaY"in y?tU(y):kg(y),E=t.current.filter(function(C){return C.name===y.type&&(C.target===y.target||y.target===C.shadowParent)&&lue(C.delta,_)})[0];if(E&&E.should){y.cancelable&&y.preventDefault();return}if(!E){var k=(s.current.shards||[]).map(nU).filter(Boolean).filter(function(C){return C.contains(y.target)}),R=k.length>0?c(y,k[0]):!s.current.noIsolation;R&&y.cancelable&&y.preventDefault()}}},[]),d=x.useCallback(function(w,y,_,E){var k={name:w,delta:y,target:_,should:E,shadowParent:fue(_)};t.current.push(k),setTimeout(function(){t.current=t.current.filter(function(R){return R!==k})},1)},[]),m=x.useCallback(function(w){n.current=kg(w),a.current=void 0},[]),h=x.useCallback(function(w){d(w.type,tU(w),w.target,c(w,e.lockRef.current))},[]),g=x.useCallback(function(w){d(w.type,kg(w),w.target,c(w,e.lockRef.current))},[]);x.useEffect(function(){return Pc.push(i),e.setCallbacks({onScrollCapture:h,onWheelCapture:h,onTouchMoveCapture:g}),document.addEventListener("wheel",u,Mc),document.addEventListener("touchmove",u,Mc),document.addEventListener("touchstart",m,Mc),function(){Pc=Pc.filter(function(w){return w!==i}),document.removeEventListener("wheel",u,Mc),document.removeEventListener("touchmove",u,Mc),document.removeEventListener("touchstart",m,Mc)}},[]);var v=e.removeScrollBar,S=e.inert;return x.createElement(x.Fragment,null,S?x.createElement(i,{styles:cue(r)}):null,v?x.createElement(eue,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function fue(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const pue=Fce(NV,due);var Yp=x.forwardRef(function(e,t){return x.createElement(Qv,ji({},e,{ref:t,sideCar:pue}))});Yp.classNames=Qv.classNames;var nE=["Enter"," "],mue=["ArrowDown","PageUp","Home"],OV=["ArrowUp","PageDown","End"],hue=[...mue,...OV],gue={ltr:[...nE,"ArrowRight"],rtl:[...nE,"ArrowLeft"]},bue={ltr:["ArrowLeft"],rtl:["ArrowRight"]},qp="Menu",[ip,vue,yue]=jT(qp),[Gl,DV]=ki(qp,[yue,Us,yV]),ey=Us(),jV=yV(),[wue,Wl]=Gl(qp),[xue,Xp]=Gl(qp),LV=e=>{const{__scopeMenu:t,open:n=!1,children:a,dir:r,onOpenChange:i,modal:s=!0}=e,c=ey(t),[u,d]=x.useState(null),m=x.useRef(!1),h=Fi(i),g=LT(r);return x.useEffect(()=>{const v=()=>{m.current=!0,document.addEventListener("pointerdown",S,{capture:!0,once:!0}),document.addEventListener("pointermove",S,{capture:!0,once:!0})},S=()=>m.current=!1;return document.addEventListener("keydown",v,{capture:!0}),()=>{document.removeEventListener("keydown",v,{capture:!0}),document.removeEventListener("pointerdown",S,{capture:!0}),document.removeEventListener("pointermove",S,{capture:!0})}},[]),f.jsx(Yv,{...c,children:f.jsx(wue,{scope:t,open:n,onOpenChange:h,content:u,onContentChange:d,children:f.jsx(xue,{scope:t,onClose:x.useCallback(()=>h(!1),[h]),isUsingKeyboardRef:m,dir:g,modal:s,children:a})})})};LV.displayName=qp;var Sue="MenuAnchor",GT=x.forwardRef((e,t)=>{const{__scopeMenu:n,...a}=e,r=ey(n);return f.jsx(Kp,{...r,...a,ref:t})});GT.displayName=Sue;var WT="MenuPortal",[Eue,$V]=Gl(WT,{forceMount:void 0}),MV=e=>{const{__scopeMenu:t,forceMount:n,children:a,container:r}=e,i=Wl(WT,t);return f.jsx(Eue,{scope:t,forceMount:n,children:f.jsx(Ma,{present:n||i.open,children:f.jsx(id,{asChild:!0,container:r,children:a})})})};MV.displayName=WT;var Ja="MenuContent",[_ue,KT]=Gl(Ja),PV=x.forwardRef((e,t)=>{const n=$V(Ja,e.__scopeMenu),{forceMount:a=n.forceMount,...r}=e,i=Wl(Ja,e.__scopeMenu),s=Xp(Ja,e.__scopeMenu);return f.jsx(ip.Provider,{scope:e.__scopeMenu,children:f.jsx(Ma,{present:a||i.open,children:f.jsx(ip.Slot,{scope:e.__scopeMenu,children:s.modal?f.jsx(kue,{...r,ref:t}):f.jsx(Tue,{...r,ref:t})})})})}),kue=x.forwardRef((e,t)=>{const n=Wl(Ja,e.__scopeMenu),a=x.useRef(null),r=Qt(t,a);return x.useEffect(()=>{const i=a.current;if(i)return Jv(i)},[]),f.jsx(ZT,{...e,ref:r,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:Ve(e.onFocusOutside,i=>i.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),Tue=x.forwardRef((e,t)=>{const n=Wl(Ja,e.__scopeMenu);return f.jsx(ZT,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),Nue=Dl("MenuContent.ScrollLock"),ZT=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:S,...w}=e,y=Wl(Ja,n),_=Xp(Ja,n),E=ey(n),k=jV(n),R=vue(n),[C,I]=x.useState(null),A=x.useRef(null),O=Qt(t,A,y.onContentChange),M=x.useRef(0),U=x.useRef(""),H=x.useRef(0),K=x.useRef(null),ee=x.useRef("right"),J=x.useRef(0),ie=S?Yp:x.Fragment,B=S?{as:Nue,allowPinchZoom:!0}:void 0,Z=re=>{const ne=U.current+re,j=R().filter(W=>!W.disabled),V=document.activeElement,z=j.find(W=>W.ref.current===V)?.textValue,L=j.map(W=>W.textValue),$=Uue(L,ne,z),F=j.find(W=>W.textValue===$)?.ref.current;(function W(X){U.current=X,window.clearTimeout(M.current),X!==""&&(M.current=window.setTimeout(()=>W(""),1e3))})(ne),F&&setTimeout(()=>F.focus())};x.useEffect(()=>()=>window.clearTimeout(M.current),[]),Vv();const G=x.useCallback(re=>ee.current===K.current?.side&&Fue(re,K.current?.area),[]);return f.jsx(_ue,{scope:n,searchRef:U,onItemEnter:x.useCallback(re=>{G(re)&&re.preventDefault()},[G]),onItemLeave:x.useCallback(re=>{G(re)||(A.current?.focus(),I(null))},[G]),onTriggerLeave:x.useCallback(re=>{G(re)&&re.preventDefault()},[G]),pointerGraceTimerRef:H,onPointerGraceIntentChange:x.useCallback(re=>{K.current=re},[]),children:f.jsx(ie,{...B,children:f.jsx(Gp,{asChild:!0,trapped:r,onMountAutoFocus:Ve(i,re=>{re.preventDefault(),A.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:s,children:f.jsx(nd,{asChild:!0,disableOutsidePointerEvents:c,onEscapeKeyDown:d,onPointerDownOutside:m,onFocusOutside:h,onInteractOutside:g,onDismiss:v,children:f.jsx(Nce,{asChild:!0,...k,dir:_.dir,orientation:"vertical",loop:a,currentTabStopId:C,onCurrentTabStopIdChange:I,onEntryFocus:Ve(u,re=>{_.isUsingKeyboardRef.current||re.preventDefault()}),preventScrollOnEntryFocus:!0,children:f.jsx(qv,{role:"menu","aria-orientation":"vertical","data-state":e9(y.open),"data-radix-menu-content":"",dir:_.dir,...E,...w,ref:O,style:{outline:"none",...w.style},onKeyDown:Ve(w.onKeyDown,re=>{const j=re.target.closest("[data-radix-menu-content]")===re.currentTarget,V=re.ctrlKey||re.altKey||re.metaKey,z=re.key.length===1;j&&(re.key==="Tab"&&re.preventDefault(),!V&&z&&Z(re.key));const L=A.current;if(re.target!==L||!hue.includes(re.key))return;re.preventDefault();const F=R().filter(W=>!W.disabled).map(W=>W.ref.current);OV.includes(re.key)&&F.reverse(),Mue(F)}),onBlur:Ve(e.onBlur,re=>{re.currentTarget.contains(re.target)||(window.clearTimeout(M.current),U.current="")}),onPointerMove:Ve(e.onPointerMove,op(re=>{const ne=re.target,j=J.current!==re.clientX;if(re.currentTarget.contains(ne)&&j){const V=re.clientX>J.current?"right":"left";ee.current=V,J.current=re.clientX}}))})})})})})})});PV.displayName=Ja;var Cue="MenuGroup",YT=x.forwardRef((e,t)=>{const{__scopeMenu:n,...a}=e;return f.jsx(Et.div,{role:"group",...a,ref:t})});YT.displayName=Cue;var Rue="MenuLabel",UV=x.forwardRef((e,t)=>{const{__scopeMenu:n,...a}=e;return f.jsx(Et.div,{...a,ref:t})});UV.displayName=Rue;var Mb="MenuItem",rU="menu.itemSelect",ty=x.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:a,...r}=e,i=x.useRef(null),s=Xp(Mb,e.__scopeMenu),c=KT(Mb,e.__scopeMenu),u=Qt(t,i),d=x.useRef(!1),m=()=>{const h=i.current;if(!n&&h){const g=new CustomEvent(rU,{bubbles:!0,cancelable:!0});h.addEventListener(rU,v=>a?.(v),{once:!0}),KH(h,g),g.defaultPrevented?d.current=!1:s.onClose()}};return f.jsx(zV,{...r,ref:u,disabled:n,onClick:Ve(e.onClick,m),onPointerDown:h=>{e.onPointerDown?.(h),d.current=!0},onPointerUp:Ve(e.onPointerUp,h=>{d.current||h.currentTarget?.click()}),onKeyDown:Ve(e.onKeyDown,h=>{const g=c.searchRef.current!=="";n||g&&h.key===" "||nE.includes(h.key)&&(h.currentTarget.click(),h.preventDefault())})})});ty.displayName=Mb;var zV=x.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:a=!1,textValue:r,...i}=e,s=KT(Mb,n),c=jV(n),u=x.useRef(null),d=Qt(t,u),[m,h]=x.useState(!1),[g,v]=x.useState("");return x.useEffect(()=>{const S=u.current;S&&v((S.textContent??"").trim())},[i.children]),f.jsx(ip.ItemSlot,{scope:n,disabled:a,textValue:r??g,children:f.jsx(Cce,{asChild:!0,...c,focusable:!a,children:f.jsx(Et.div,{role:"menuitem","data-highlighted":m?"":void 0,"aria-disabled":a||void 0,"data-disabled":a?"":void 0,...i,ref:d,onPointerMove:Ve(e.onPointerMove,op(S=>{a?s.onItemLeave(S):(s.onItemEnter(S),S.defaultPrevented||S.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Ve(e.onPointerLeave,op(S=>s.onItemLeave(S))),onFocus:Ve(e.onFocus,()=>h(!0)),onBlur:Ve(e.onBlur,()=>h(!1))})})})}),Aue="MenuCheckboxItem",FV=x.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:a,...r}=e;return f.jsx(WV,{scope:e.__scopeMenu,checked:n,children:f.jsx(ty,{role:"menuitemcheckbox","aria-checked":Pb(n)?"mixed":n,...r,ref:t,"data-state":XT(n),onSelect:Ve(r.onSelect,()=>a?.(Pb(n)?!0:!n),{checkForDefaultPrevented:!1})})})});FV.displayName=Aue;var BV="MenuRadioGroup",[Iue,Oue]=Gl(BV,{value:void 0,onValueChange:()=>{}}),HV=x.forwardRef((e,t)=>{const{value:n,onValueChange:a,...r}=e,i=Fi(a);return f.jsx(Iue,{scope:e.__scopeMenu,value:n,onValueChange:i,children:f.jsx(YT,{...r,ref:t})})});HV.displayName=BV;var VV="MenuRadioItem",GV=x.forwardRef((e,t)=>{const{value:n,...a}=e,r=Oue(VV,e.__scopeMenu),i=n===r.value;return f.jsx(WV,{scope:e.__scopeMenu,checked:i,children:f.jsx(ty,{role:"menuitemradio","aria-checked":i,...a,ref:t,"data-state":XT(i),onSelect:Ve(a.onSelect,()=>r.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});GV.displayName=VV;var qT="MenuItemIndicator",[WV,Due]=Gl(qT,{checked:!1}),KV=x.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:a,...r}=e,i=Due(qT,n);return f.jsx(Ma,{present:a||Pb(i.checked)||i.checked===!0,children:f.jsx(Et.span,{...r,ref:t,"data-state":XT(i.checked)})})});KV.displayName=qT;var jue="MenuSeparator",ZV=x.forwardRef((e,t)=>{const{__scopeMenu:n,...a}=e;return f.jsx(Et.div,{role:"separator","aria-orientation":"horizontal",...a,ref:t})});ZV.displayName=jue;var Lue="MenuArrow",YV=x.forwardRef((e,t)=>{const{__scopeMenu:n,...a}=e,r=ey(n);return f.jsx(Xv,{...r,...a,ref:t})});YV.displayName=Lue;var $ue="MenuSub",[ske,qV]=Gl($ue),Ef="MenuSubTrigger",XV=x.forwardRef((e,t)=>{const n=Wl(Ef,e.__scopeMenu),a=Xp(Ef,e.__scopeMenu),r=qV(Ef,e.__scopeMenu),i=KT(Ef,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]),f.jsx(GT,{asChild:!0,...d,children:f.jsx(zV,{id:r.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":r.contentId,"data-state":e9(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:Ve(e.onPointerMove,op(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:Ve(e.onPointerLeave,op(h=>{m();const g=n.content?.getBoundingClientRect();if(g){const v=n.content?.dataset.side,S=v==="right",w=S?-5:5,y=g[S?"left":"right"],_=g[S?"right":"left"];i.onPointerGraceIntentChange({area:[{x:h.clientX+w,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:Ve(e.onKeyDown,h=>{const g=i.searchRef.current!=="";e.disabled||g&&h.key===" "||gue[a.dir].includes(h.key)&&(n.onOpenChange(!0),n.content?.focus(),h.preventDefault())})})})});XV.displayName=Ef;var JV="MenuSubContent",QV=x.forwardRef((e,t)=>{const n=$V(Ja,e.__scopeMenu),{forceMount:a=n.forceMount,...r}=e,i=Wl(Ja,e.__scopeMenu),s=Xp(Ja,e.__scopeMenu),c=qV(JV,e.__scopeMenu),u=x.useRef(null),d=Qt(t,u);return f.jsx(ip.Provider,{scope:e.__scopeMenu,children:f.jsx(Ma,{present:a||i.open,children:f.jsx(ip.Slot,{scope:e.__scopeMenu,children:f.jsx(ZT,{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:Ve(e.onFocusOutside,m=>{m.target!==c.trigger&&i.onOpenChange(!1)}),onEscapeKeyDown:Ve(e.onEscapeKeyDown,m=>{s.onClose(),m.preventDefault()}),onKeyDown:Ve(e.onKeyDown,m=>{const h=m.currentTarget.contains(m.target),g=bue[s.dir].includes(m.key);h&&g&&(i.onOpenChange(!1),c.trigger?.focus(),m.preventDefault())})})})})})});QV.displayName=JV;function e9(e){return e?"open":"closed"}function Pb(e){return e==="indeterminate"}function XT(e){return Pb(e)?"indeterminate":e?"checked":"unchecked"}function Mue(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function Pue(e,t){return e.map((n,a)=>e[(t+a)%e.length])}function Uue(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=Pue(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 zue(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 Fue(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return zue(n,t)}function op(e){return t=>t.pointerType==="mouse"?e(t):void 0}var Bue=LV,Hue=GT,Vue=MV,Gue=PV,Wue=YT,Kue=UV,Zue=ty,Yue=FV,que=HV,Xue=GV,Jue=KV,Que=ZV,ede=YV,tde=XV,nde=QV,ny="DropdownMenu",[rde]=ki(ny,[DV]),na=DV(),[ade,t9]=rde(ny),n9=e=>{const{__scopeDropdownMenu:t,children:n,dir:a,open:r,defaultOpen:i,onOpenChange:s,modal:c=!0}=e,u=na(t),d=x.useRef(null),[m,h]=Io({prop:r,defaultProp:i??!1,onChange:s,caller:ny});return f.jsx(ade,{scope:t,triggerId:Dr(),triggerRef:d,contentId:Dr(),open:m,onOpenChange:h,onOpenToggle:x.useCallback(()=>h(g=>!g),[h]),modal:c,children:f.jsx(Bue,{...u,open:m,onOpenChange:h,dir:a,modal:c,children:n})})};n9.displayName=ny;var r9="DropdownMenuTrigger",a9=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:a=!1,...r}=e,i=t9(r9,n),s=na(n);return f.jsx(Hue,{asChild:!0,...s,children:f.jsx(Et.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:Ve(e.onPointerDown,c=>{!a&&c.button===0&&c.ctrlKey===!1&&(i.onOpenToggle(),i.open||c.preventDefault())}),onKeyDown:Ve(e.onKeyDown,c=>{a||(["Enter"," "].includes(c.key)&&i.onOpenToggle(),c.key==="ArrowDown"&&i.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(c.key)&&c.preventDefault())})})})});a9.displayName=r9;var ide="DropdownMenuPortal",i9=e=>{const{__scopeDropdownMenu:t,...n}=e,a=na(t);return f.jsx(Vue,{...a,...n})};i9.displayName=ide;var o9="DropdownMenuContent",s9=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=t9(o9,n),i=na(n),s=x.useRef(!1);return f.jsx(Gue,{id:r.contentId,"aria-labelledby":r.triggerId,...i,...a,ref:t,onCloseAutoFocus:Ve(e.onCloseAutoFocus,c=>{s.current||r.triggerRef.current?.focus(),s.current=!1,c.preventDefault()}),onInteractOutside:Ve(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)"}})});s9.displayName=o9;var ode="DropdownMenuGroup",sde=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=na(n);return f.jsx(Wue,{...r,...a,ref:t})});sde.displayName=ode;var lde="DropdownMenuLabel",l9=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=na(n);return f.jsx(Kue,{...r,...a,ref:t})});l9.displayName=lde;var cde="DropdownMenuItem",c9=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=na(n);return f.jsx(Zue,{...r,...a,ref:t})});c9.displayName=cde;var ude="DropdownMenuCheckboxItem",u9=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=na(n);return f.jsx(Yue,{...r,...a,ref:t})});u9.displayName=ude;var dde="DropdownMenuRadioGroup",fde=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=na(n);return f.jsx(que,{...r,...a,ref:t})});fde.displayName=dde;var pde="DropdownMenuRadioItem",d9=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=na(n);return f.jsx(Xue,{...r,...a,ref:t})});d9.displayName=pde;var mde="DropdownMenuItemIndicator",hde=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=na(n);return f.jsx(Jue,{...r,...a,ref:t})});hde.displayName=mde;var gde="DropdownMenuSeparator",f9=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=na(n);return f.jsx(Que,{...r,...a,ref:t})});f9.displayName=gde;var bde="DropdownMenuArrow",vde=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=na(n);return f.jsx(ede,{...r,...a,ref:t})});vde.displayName=bde;var yde="DropdownMenuSubTrigger",p9=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=na(n);return f.jsx(tde,{...r,...a,ref:t})});p9.displayName=yde;var wde="DropdownMenuSubContent",m9=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=na(n);return f.jsx(nde,{...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)"}})});m9.displayName=wde;var xde=n9,Sde=a9,Ede=i9,h9=s9,g9=l9,b9=c9,_de=u9,kde=d9,v9=f9,Tde=p9,Nde=m9;const rE=xde,aE=Sde;Tde.displayName;Nde.displayName;function Ub({ref:e,className:t,sideOffset:n=4,...a}){return f.jsx(Ede,{children:f.jsx(h9,{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})})}Ub.displayName=h9.displayName;function Eo({ref:e,className:t,inset:n,...a}){return f.jsx(b9,{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})}Eo.displayName=b9.displayName;_de.displayName;kde.displayName;function iE({ref:e,className:t,inset:n,...a}){return f.jsx(g9,{ref:e,className:De("px-2 py-1.5 text-sm font-semibold",n&&"pl-8",t),...a})}iE.displayName=g9.displayName;function _f({ref:e,className:t,...n}){return f.jsx(v9,{ref:e,className:De("-mx-1 my-1 h-px bg-muted",t),...n})}_f.displayName=v9.displayName;var Cde=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],zo=Cde.reduce((e,t)=>{const n=RH(`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),f.jsx(u,{...c,ref:i})});return a.displayName=`Primitive.${t}`,{...e,[t]:a}},{}),Rde="Label",y9=x.forwardRef((e,t)=>f.jsx(zo.label,{...e,ref:t,onMouseDown:n=>{n.target.closest("button, input, select, textarea")||(e.onMouseDown?.(n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));y9.displayName=Rde;var Ade=y9;function Kt({className:e,...t}){return f.jsx(Ade,{"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 od({message:e,className:t="",vertical:n,noBorder:a}){return f.jsx("div",{className:De(`mt-2 rounded-md p-6 ${t}`,!a&&"border"),children:f.jsxs("p",{className:De("text-sm text-muted-foreground flex items-center gap-4",n&&"flex-col"),children:[f.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:f.jsx("g",{stroke:"none",strokeWidth:"1",fill:"none",fillRule:"evenodd",children:f.jsxs("g",{transform:"translate(5.320900, 5.320900)",fillRule:"nonzero",className:"stroke-black dark:stroke-white",strokeWidth:"4",children:[f.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"}),f.jsx("circle",{cx:"50",cy:"212.0001",r:"52.5"}),f.jsx("circle",{cx:"212.0001",cy:"50",r:"52.5"})]})})}),e]})})}function w9({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 f.jsx("section",{className:De("relative w-full h-full overflow-hidden",e),style:{background:`${u}`},children:f.jsxs("div",{className:"isolate relative w-full h-full",children:[f.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&&f.jsx("div",{className:"relative z-10 w-full h-full",children:n})]})})}function JT(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 ry="Switch",[Ide]=ki(ry),[Ode,Dde]=Ide(ry),x9=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),S=Qt(t,k=>v(k)),w=x.useRef(!1),y=g?m||!!g.closest("form"):!0,[_,E]=Io({prop:r,defaultProp:i??!1,onChange:d,caller:ry});return f.jsxs(Ode,{scope:n,checked:_,disabled:c,children:[f.jsx(Et.button,{type:"button",role:"switch","aria-checked":_,"aria-required":s,"data-state":k9(_),"data-disabled":c?"":void 0,disabled:c,value:u,...h,ref:S,onClick:Ve(e.onClick,k=>{E(R=>!R),y&&(w.current=k.isPropagationStopped(),w.current||k.stopPropagation())})}),y&&f.jsx(_9,{control:g,bubbles:!w.current,name:a,value:u,checked:_,required:s,disabled:c,form:m,style:{transform:"translateX(-100%)"}})]})});x9.displayName=ry;var S9="SwitchThumb",E9=x.forwardRef((e,t)=>{const{__scopeSwitch:n,...a}=e,r=Dde(S9,n);return f.jsx(Et.span,{"data-state":k9(r.checked),"data-disabled":r.disabled?"":void 0,...a,ref:t})});E9.displayName=S9;var jde="SwitchBubbleInput",_9=x.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:a=!0,...r},i)=>{const s=x.useRef(null),c=Qt(s,i),u=JT(n),d=BT(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 S=new Event("click",{bubbles:a});v.call(m,n),m.dispatchEvent(S)}},[u,n,a]),f.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}})});_9.displayName=jde;function k9(e){return e?"checked":"unchecked"}var T9=x9,Lde=E9;function ay({ref:e,className:t,...n}){return f.jsx(T9,{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:f.jsx(Lde,{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")})})}ay.displayName=T9.displayName;var N9=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"}),$de="VisuallyHidden",C9=x.forwardRef((e,t)=>f.jsx(Et.span,{...e,ref:t,style:{...N9,...e.style}}));C9.displayName=$de;var Mde=C9,[iy]=ki("Tooltip",[Us]),oy=Us(),R9="TooltipProvider",Pde=700,oE="tooltip.open",[Ude,QT]=iy(R9),A9=e=>{const{__scopeTooltip:t,delayDuration:n=Pde,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)},[]),f.jsx(Ude,{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})};A9.displayName=R9;var sp="Tooltip",[zde,Jp]=iy(sp),I9=e=>{const{__scopeTooltip:t,children:n,open:a,defaultOpen:r,onOpenChange:i,disableHoverableContent:s,delayDuration:c}=e,u=QT(sp,e.__scopeTooltip),d=oy(t),[m,h]=x.useState(null),g=Dr(),v=x.useRef(0),S=s??u.disableHoverableContent,w=c??u.delayDuration,y=x.useRef(!1),[_,E]=Io({prop:a,defaultProp:r??!1,onChange:A=>{A?(u.onOpen(),document.dispatchEvent(new CustomEvent(oE))):u.onClose(),i?.(A)},caller:sp}),k=x.useMemo(()=>_?y.current?"delayed-open":"instant-open":"closed",[_]),R=x.useCallback(()=>{window.clearTimeout(v.current),v.current=0,y.current=!1,E(!0)},[E]),C=x.useCallback(()=>{window.clearTimeout(v.current),v.current=0,E(!1)},[E]),I=x.useCallback(()=>{window.clearTimeout(v.current),v.current=window.setTimeout(()=>{y.current=!0,E(!0),v.current=0},w)},[w,E]);return x.useEffect(()=>()=>{v.current&&(window.clearTimeout(v.current),v.current=0)},[]),f.jsx(Yv,{...d,children:f.jsx(zde,{scope:t,contentId:g,open:_,stateAttribute:k,trigger:m,onTriggerChange:h,onTriggerEnter:x.useCallback(()=>{u.isOpenDelayedRef.current?I():R()},[u.isOpenDelayedRef,I,R]),onTriggerLeave:x.useCallback(()=>{S?C():(window.clearTimeout(v.current),v.current=0)},[C,S]),onOpen:R,onClose:C,disableHoverableContent:S,children:n})})};I9.displayName=sp;var sE="TooltipTrigger",O9=x.forwardRef((e,t)=>{const{__scopeTooltip:n,...a}=e,r=Jp(sE,n),i=QT(sE,n),s=oy(n),c=x.useRef(null),u=Qt(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]),f.jsx(Kp,{asChild:!0,...s,children:f.jsx(Et.button,{"aria-describedby":r.open?r.contentId:void 0,"data-state":r.stateAttribute,...a,ref:u,onPointerMove:Ve(e.onPointerMove,g=>{g.pointerType!=="touch"&&!m.current&&!i.isPointerInTransitRef.current&&(r.onTriggerEnter(),m.current=!0)}),onPointerLeave:Ve(e.onPointerLeave,()=>{r.onTriggerLeave(),m.current=!1}),onPointerDown:Ve(e.onPointerDown,()=>{r.open&&r.onClose(),d.current=!0,document.addEventListener("pointerup",h,{once:!0})}),onFocus:Ve(e.onFocus,()=>{d.current||r.onOpen()}),onBlur:Ve(e.onBlur,r.onClose),onClick:Ve(e.onClick,r.onClose)})})});O9.displayName=sE;var eN="TooltipPortal",[Fde,Bde]=iy(eN,{forceMount:void 0}),D9=e=>{const{__scopeTooltip:t,forceMount:n,children:a,container:r}=e,i=Jp(eN,t);return f.jsx(Fde,{scope:t,forceMount:n,children:f.jsx(Ma,{present:n||i.open,children:f.jsx(id,{asChild:!0,container:r,children:a})})})};D9.displayName=eN;var Mu="TooltipContent",j9=x.forwardRef((e,t)=>{const n=Bde(Mu,e.__scopeTooltip),{forceMount:a=n.forceMount,side:r="top",...i}=e,s=Jp(Mu,e.__scopeTooltip);return f.jsx(Ma,{present:a||s.open,children:s.disableHoverableContent?f.jsx(L9,{side:r,...i,ref:t}):f.jsx(Hde,{side:r,...i,ref:t})})}),Hde=x.forwardRef((e,t)=>{const n=Jp(Mu,e.__scopeTooltip),a=QT(Mu,e.__scopeTooltip),r=x.useRef(null),i=Qt(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((S,w)=>{const y=S.currentTarget,_={x:S.clientX,y:S.clientY},E=Kde(_,y.getBoundingClientRect()),k=Zde(_,E),R=Yde(w.getBoundingClientRect()),C=Xde([...k,...R]);c(C),h(!0)},[h]);return x.useEffect(()=>()=>g(),[g]),x.useEffect(()=>{if(u&&m){const S=y=>v(y,m),w=y=>v(y,u);return u.addEventListener("pointerleave",S),m.addEventListener("pointerleave",w),()=>{u.removeEventListener("pointerleave",S),m.removeEventListener("pointerleave",w)}}},[u,m,v,g]),x.useEffect(()=>{if(s){const S=w=>{const y=w.target,_={x:w.clientX,y:w.clientY},E=u?.contains(y)||m?.contains(y),k=!qde(_,s);E?g():k&&(g(),d())};return document.addEventListener("pointermove",S),()=>document.removeEventListener("pointermove",S)}},[u,m,s,d,g]),f.jsx(L9,{...e,ref:i})}),[Vde,Gde]=iy(sp,{isInside:!1}),Wde=Tse("TooltipContent"),L9=x.forwardRef((e,t)=>{const{__scopeTooltip:n,children:a,"aria-label":r,onEscapeKeyDown:i,onPointerDownOutside:s,...c}=e,u=Jp(Mu,n),d=oy(n),{onClose:m}=u;return x.useEffect(()=>(document.addEventListener(oE,m),()=>document.removeEventListener(oE,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]),f.jsx(nd,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:i,onPointerDownOutside:s,onFocusOutside:h=>h.preventDefault(),onDismiss:m,children:f.jsxs(qv,{"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:[f.jsx(Wde,{children:a}),f.jsx(Vde,{scope:n,isInside:!0,children:f.jsx(Mde,{id:u.contentId,role:"tooltip",children:r||a})})]})})});j9.displayName=Mu;var $9="TooltipArrow",M9=x.forwardRef((e,t)=>{const{__scopeTooltip:n,...a}=e,r=oy(n);return Gde($9,n).isInside?null:f.jsx(Xv,{...r,...a,ref:t})});M9.displayName=$9;function Kde(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 Zde(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 Yde(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 qde(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 Xde(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),Jde(t)}function Jde(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 Qde=A9,efe=I9,tfe=O9,nfe=D9,rfe=j9,afe=M9;function P9({delayDuration:e=0,...t}){return f.jsx(Qde,{"data-slot":"tooltip-provider",delayDuration:e,...t})}function $t({...e}){return f.jsx(P9,{children:f.jsx(efe,{"data-slot":"tooltip",...e})})}function Mt({...e}){return f.jsx(tfe,{"data-slot":"tooltip-trigger",...e})}function Pt({className:e,sideOffset:t=0,children:n,...a}){return f.jsx(nfe,{children:f.jsxs(rfe,{"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,f.jsx(afe,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}class ife{name="mcp_inspector_open";properties;constructor(t){this.properties={server_url:t.serverUrl,connection_count:t.connectionCount}}}class aU{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 iU{name="mcp_resource_read";properties;constructor(t){this.properties={resource_uri:t.resourceUri,server_id:t.serverId,success:t.success,error:t.error}}}class oU{name="mcp_prompt_call";properties;constructor(t){this.properties={prompt_name:t.promptName,server_id:t.serverId,success:t.success,error:t.error}}}class sU{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 ofe{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 sfe{name="mcp_server_removed";properties;constructor(t){this.properties={server_id:t.serverId}}}class lfe{name="mcp_command_palette_open";properties;constructor(t){this.properties={trigger:t.trigger}}}class cfe{name="mcp_tool_saved";properties;constructor(t){this.properties={tool_name:t.toolName,server_id:t.serverId}}}function Ix(){try{return"0.11.0"}catch{return"0.0.0"}}var ufe={};function Ox(){try{return typeof window<"u"&&typeof document<"u"}catch{return!1}}class lU{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 ms(e){return`mcp_inspector_telemetry_${e}`}class yr{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=Ox(),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 lU(this.POSTHOG_PROXY_URL,3e3)}catch{this._posthogClient=null}try{this._scarfClient=new lU(this.SCARF_PROXY_URL,3e3)}catch{this._scarfClient=null}}}isTelemetryDisabled(){return typeof localStorage<"u"&&localStorage.getItem(ms("disabled"))==="true"||typeof process<"u"&&ufe?.MCP_USE_ANONYMIZED_TELEMETRY==="false"}getStoredSource(){return typeof localStorage<"u"?localStorage.getItem(ms("source")):null}static getInstance(){return yr.instance||(yr.instance=new yr),yr.instance}setSource(t){this._source=t,typeof localStorage<"u"&&localStorage.setItem(ms("source"),t)}getSource(){return this._source}get userId(){if(this._currUserId)return this._currUserId;if(!Ox())return this._currUserId=this.UNKNOWN_USER_ID,this._currUserId;try{const t=localStorage.getItem(ms("user_id"));if(t)this._currUserId=t;else{const n=this.generateUserId();localStorage.setItem(ms("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:Ix(),language:"typescript",source:this._source,package:"inspector"}};await this._posthogClient.logEvent(n)}catch{}if(this._scarfClient)try{const n={};n.mcp_use_version=Ix(),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&&Ox())try{const n=Ix();let a=!1,r=!1;const i=localStorage.getItem(ms("download_version"));if(i?n>i&&(a=!0,r=!1,localStorage.setItem(ms("download_version"),n)):(a=!0,r=!0,localStorage.setItem(ms("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 ife(t);await this.capture(n)}}const dfe={model:"stub-model",stopReason:"endTurn",role:"assistant",content:{type:"text",text:"positive"}};function ffe({requestId:e,serverName:t,onViewDetails:n,onApprove:a,onDeny:r}){return f.jsxs("div",{className:"space-y-3",children:[f.jsxs("div",{children:[f.jsx("strong",{children:"Sampling Request Received"}),f.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:["New request from ",t]})]}),f.jsxs("div",{className:"flex gap-2",children:[f.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"}),f.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(dfe)},children:"Approve"}),f.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"})]})]})}function pfe({requestId:e,serverName:t,mode:n,message:a,url:r,onViewDetails:i,onOpenUrl:s,onCancel:c}){return f.jsxs("div",{className:"space-y-3",children:[f.jsxs("div",{children:[f.jsx("strong",{children:"Elicitation Request Received"}),f.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:["From ",t,": ",a]}),n==="url"&&r&&f.jsx("p",{className:"text-xs text-muted-foreground mt-1 font-mono",children:r})]}),f.jsxs("div",{className:"flex gap-2 flex-wrap",children:[f.jsx("button",{className:"px-3 py-1.5 text-xs font-medium rounded-md hover:bg-accent hover:text-accent-foreground",onClick:u=>{u.stopPropagation(),i()},children:"View Details"}),n==="url"&&s&&f.jsx("button",{className:"px-3 py-1.5 text-xs font-medium rounded-md hover:bg-accent hover:text-accent-foreground",onClick:u=>{u.stopPropagation(),s()},children:"Open URL"}),f.jsx("button",{className:"px-3 py-1.5 text-xs font-medium rounded-md hover:bg-accent hover:text-accent-foreground",onClick:u=>{u.stopPropagation(),c()},children:"Cancel"})]})]})}const Tg=()=>{},Ng=()=>{},Cg=()=>{},Rg=()=>{},U9=x.createContext(null);function tN(){const e=x.use(U9);if(!e)throw new Error("useMcpContext must be used within a McpProvider");return e}function mfe({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 L=new URL(n.proxyAddress),$=new URL(e);u=`${L.origin}${L.pathname}${$.pathname}${$.search}`,d["X-Target-URL"]=e}n?.customHeaders&&(d={...d,...n.customHeaders});const[m,h]=x.useState([]),g=x.useRef(0),[v,S]=x.useState([]),w=x.useRef(0),y=x.useMemo(()=>m.map(L=>({id:L.id,request:L.request,timestamp:L.timestamp,serverName:L.serverName})),[m]),_=x.useMemo(()=>v.map(L=>({id:L.id,request:L.request,timestamp:L.timestamp,serverName:L.serverName})),[v]),E=x.useRef(null),[k,R]=x.useState(!1),C=x.useRef(!1);x.useEffect(()=>{typeof window<"u"&&!C.current&&(C.current=!0,dr(()=>import("./transport-wrapper-browser-BI4dDu3b.js"),[]).then(L=>{E.current=L.wrapTransportForLogging,R(!0),console.log("[McpContext] Transport wrapper loaded")}).catch(L=>{console.error("[McpContext] Failed to load transport wrapper:",L)}))},[]);const I=x.useMemo(()=>{if(!(!k||!E.current))return(L,$)=>{const F=r;return console.log("[McpContext] Applying transport wrapper, serverId:",F,"from connector:",$),E.current(L,F)}},[k,r]),A=`mcp-inspector-notifications-${r}`,O=500,[M,U]=x.useState([]);x.useEffect(()=>{try{const L=localStorage.getItem(A);if(L){const $=JSON.parse(L);Array.isArray($)&&U($)}}catch(L){console.error("Failed to load notifications from localStorage:",L)}},[A]),x.useEffect(()=>{try{localStorage.setItem(A,JSON.stringify(M))}catch(L){console.error("Failed to save notifications to localStorage:",L)}},[M,A]);const H=x.useCallback(L=>{U($=>$.map(F=>F.id===L?{...F,read:!0}:F))},[]),K=x.useCallback(()=>{U(L=>L.map($=>({...$,read:!0})))},[]),ee=x.useCallback(()=>{U([])},[]),J=x.useCallback(L=>{U($=>{const F=[L,...$];return F.length>O?F.slice(0,O):F})},[]),ie=x.useCallback((L,$)=>{h(F=>{const W=F.find(X=>X.id===L);return W?(W.resolve($),F.filter(X=>X.id!==L)):F})},[]),B=x.useCallback((L,$)=>{h(F=>{const W=F.find(X=>X.id===L);return W?(W.reject(new Error($||"User rejected sampling request")),F.filter(X=>X.id!==L)):F})},[]),Z=x.useCallback((L,$)=>{S(F=>{const W=F.find(X=>X.id===L);return W?(W.resolve($),F.filter(X=>X.id!==L)):F})},[]),G=x.useCallback((L,$)=>{S(F=>{const W=F.find(X=>X.id===L);return W?(W.reject(new Error($||"User rejected elicitation request")),F.filter(X=>X.id!==L)):F})},[]),re=x.useCallback(async L=>new Promise(($,F)=>{const W=`sampling-${g.current++}`,X={id:W,request:{params:L},timestamp:Date.now(),serverName:t,resolve:$,reject:F};h(ae=>[...ae,X]),typeof window<"u"&&dr(async()=>{const{toast:ae}=await Promise.resolve().then(()=>hU);return{toast:ae}},void 0).then(({toast:ae})=>{const le=ae(f.jsx(ffe,{requestId:W,serverName:t,onViewDetails:()=>{const Q=new globalThis.CustomEvent("navigate-to-sampling",{detail:{requestId:W}});window.dispatchEvent(Q),ae.dismiss(le)},onApprove:Q=>{h(q=>{const se=q.find(he=>he.id===W);return se?(se.resolve(Q),ae.success("Sampling request approved"),q.filter(he=>he.id!==W)):q}),ae.dismiss(le)},onDeny:()=>{h(Q=>{const q=Q.find(se=>se.id===W);return q?(q.reject(new Error("User denied sampling request from toast")),ae.error("Sampling request denied"),Q.filter(se=>se.id!==W)):Q}),ae.dismiss(le)}}),{duration:5e3})})}),[t]),ne=x.useCallback(async L=>new Promise(($,F)=>{const W=`elicitation-${w.current++}`,X={id:W,request:L,timestamp:Date.now(),serverName:t,resolve:$,reject:F};S(ae=>[...ae,X]),typeof window<"u"&&dr(async()=>{const{toast:ae}=await Promise.resolve().then(()=>hU);return{toast:ae}},void 0).then(({toast:ae})=>{const le=ae(f.jsx(pfe,{requestId:W,serverName:t,mode:L.mode||"form",message:L.message,url:L.mode==="url"?L.url:void 0,onViewDetails:()=>{const Q=new globalThis.CustomEvent("navigate-to-elicitation",{detail:{requestId:W}});window.dispatchEvent(Q),ae.dismiss(le)},onOpenUrl:L.mode==="url"?()=>{window.open(L.url,"_blank"),ae.dismiss(le)}:void 0,onCancel:()=>{S(Q=>{const q=Q.find(se=>se.id===W);return q?(q.reject(new Error("User cancelled elicitation request from toast")),ae.error("Elicitation request cancelled"),Q.filter(se=>se.id!==W)):Q}),ae.dismiss(le)}}),{duration:5e3})})}),[t]),j=NT({url:u,callbackUrl:c,customHeaders:Object.keys(d).length>0?d:void 0,transportType:a||"http",preventAutoAuth:!0,useRedirectFlow:!0,enabled:k,wrapTransport:I,onNotification:L=>{J({id:globalThis.crypto.randomUUID(),method:L.method,params:L.params,timestamp:Date.now(),read:!1})},samplingCallback:re,onElicitation:ne}),V=x.useRef(i),z=x.useRef(null);return x.useEffect(()=>{V.current=i},[i]),x.useEffect(()=>{if(typeof queueMicrotask<"u")queueMicrotask(()=>{j.state==="ready"&&j.serverInfo&&console.log("[McpContext] Server info available:",j.serverInfo);const L=M.filter(W=>!W.read).length,$={id:r,url:e,name:j.serverInfo?.name||t,state:j.state,tools:j.tools,resources:j.resources,prompts:j.prompts,error:j.error??null,authUrl:j.authUrl??null,customHeaders:d,transportType:a,proxyConfig:n,serverInfo:j.serverInfo,capabilities:j.capabilities,notifications:M,unreadNotificationCount:L,markNotificationRead:H,markAllNotificationsRead:K,clearNotifications:ee,pendingSamplingRequests:y,approveSampling:ie,rejectSampling:B,pendingElicitationRequests:_,approveElicitation:Z,rejectElicitation:G,callTool:j.callTool,readResource:j.readResource,listPrompts:j.listPrompts,getPrompt:j.getPrompt,authenticate:j.authenticate,retry:j.retry,clearStorage:j.clearStorage,disconnect:j.disconnect,client:j.client},F=z.current;(!F||F.state!==$.state||F.error!==$.error||F.authUrl!==$.authUrl||F.name!==$.name||F.tools.length!==$.tools.length||F.resources.length!==$.resources.length||F.prompts.length!==$.prompts.length||F.serverInfo!==$.serverInfo||F.capabilities!==$.capabilities||F.notifications.length!==$.notifications.length||F.unreadNotificationCount!==$.unreadNotificationCount||F.pendingSamplingRequests.length!==$.pendingSamplingRequests.length||F.pendingElicitationRequests.length!==$.pendingElicitationRequests.length||!F.client)&&(z.current=$,V.current($))});else{const L=M.filter(W=>!W.read).length,$={id:r,url:e,name:j.serverInfo?.name||t,state:j.state,tools:j.tools,resources:j.resources,prompts:j.prompts,error:j.error??null,authUrl:j.authUrl??null,customHeaders:d,transportType:a,proxyConfig:n,serverInfo:j.serverInfo,capabilities:j.capabilities,notifications:M,unreadNotificationCount:L,markNotificationRead:H,markAllNotificationsRead:K,clearNotifications:ee,pendingSamplingRequests:y,approveSampling:ie,rejectSampling:B,pendingElicitationRequests:_,approveElicitation:Z,rejectElicitation:G,callTool:j.callTool,readResource:j.readResource,listPrompts:j.listPrompts,getPrompt:j.getPrompt,authenticate:j.authenticate,retry:j.retry,clearStorage:j.clearStorage,disconnect:j.disconnect,client:j.client},F=z.current;(!F||F.state!==$.state||F.error!==$.error||F.authUrl!==$.authUrl||F.name!==$.name||F.tools.length!==$.tools.length||F.resources.length!==$.resources.length||F.prompts.length!==$.prompts.length||F.serverInfo!==$.serverInfo||F.capabilities!==$.capabilities||F.notifications.length!==$.notifications.length||F.unreadNotificationCount!==$.unreadNotificationCount||F.pendingSamplingRequests.length!==$.pendingSamplingRequests.length||F.pendingElicitationRequests.length!==$.pendingElicitationRequests.length||!F.client)&&(z.current=$,V.current($))}},[e,t,a,n,d,r,j.state,j.tools,j.resources,j.prompts,j.error,j.authUrl,j.serverInfo,j.capabilities,j.client,M,H,K,ee,j.callTool,j.readResource,j.listPrompts,j.getPrompt,j.authenticate,j.retry,j.clearStorage,m,ie,B,_,Z,G]),null}function hfe({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:Tg,rejectSampling:Ng,pendingElicitationRequests:[],approveElicitation:Cg,rejectElicitation:Rg,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 R=c.find(A=>A.url===y),C=t.find(A=>A.url===y);if(R&&C){if(JSON.stringify(R.proxyConfig)!==JSON.stringify(E)&&E){u(O=>O.filter(M=>M.url!==y)),n(O=>O.filter(M=>M.url!==y)),setTimeout(()=>{const O={id:y,url:y,name:_||R.name||"MCP Server",proxyConfig:E,transportType:k||R.transportType};u(M=>[...M,O]),n(M=>[...M,{id:y,url:y,name:_||R.name||"MCP Server",state:"connecting",tools:[],resources:[],prompts:[],error:null,authUrl:null,customHeaders:E?.customHeaders,transportType:k||R.transportType,proxyConfig:E,notifications:[],unreadNotificationCount:0,markNotificationRead:()=>{},markAllNotificationsRead:()=>{},clearNotifications:()=>{},pendingSamplingRequests:[],approveSampling:Tg,rejectSampling:Ng,pendingElicitationRequests:[],approveElicitation:Cg,rejectElicitation:Rg,callTool:async()=>{},readResource:async()=>{},listPrompts:async()=>{},getPrompt:async()=>{},authenticate:()=>{},retry:()=>{},clearStorage:()=>{},disconnect:()=>{},client:null}])},10);return}return}if(R&&!C){(E||k)&&u(A=>A.map(O=>O.url===y?{...O,proxyConfig:E||O.proxyConfig,transportType:k||O.transportType,name:_||O.name}:O)),n(A=>[...A,{id:R.id||y,url:y,name:_||R.name||"MCP Server",state:"connecting",tools:[],resources:[],prompts:[],error:null,authUrl:null,customHeaders:E?.customHeaders||R.proxyConfig?.customHeaders,transportType:k||R.transportType,proxyConfig:E||R.proxyConfig,notifications:[],unreadNotificationCount:0,markNotificationRead:()=>{},markAllNotificationsRead:()=>{},clearNotifications:()=>{},pendingSamplingRequests:[],approveSampling:Tg,rejectSampling:Ng,pendingElicitationRequests:[],approveElicitation:Cg,rejectElicitation:Rg,callTool:async()=>{},readResource:async()=>{},listPrompts:async()=>{},getPrompt:async()=>{},authenticate:()=>{},retry:()=>{},clearStorage:()=>{},disconnect:()=>{},client:null}]);return}const I={id:y,url:y,name:_||"MCP Server",proxyConfig:E,transportType:k};u(A=>[...A,I]),n(A=>[...A,{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:Tg,rejectSampling:Ng,pendingElicitationRequests:[],approveElicitation:Cg,rejectElicitation:Rg,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(R=>R.id!==y)),n(k=>k.filter(R=>R.id!==y));const E=localStorage.getItem("mcp-inspector-connections");if(E)try{const R=JSON.parse(E).filter(C=>(C.id||C.url)!==y);localStorage.setItem("mcp-inspector-connections",JSON.stringify(R))}catch(k){console.error("Failed to update localStorage on remove:",k)}yr.getInstance().capture(new sfe({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(C=>C.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&&k.pendingElicitationRequests.length===y.pendingElicitationRequests.length)return _;const R=[..._];return R[E]=y,R})},[]),v=x.useCallback(y=>{console.log("Connect requested for:",y)},[]),S=x.useCallback(y=>{console.log("Disconnect requested for:",y)},[]),w=x.useMemo(()=>({connections:t,addConnection:d,removeConnection:m,updateConnectionConfig:h,autoConnect:i,setAutoConnect:s,connectServer:v,disconnectServer:S,configLoaded:a}),[t,d,m,h,i,v,S,a]);return f.jsxs(U9.Provider,{value:w,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),f.jsx(mfe,{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 gfe=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),bfe=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,a)=>a?a.toUpperCase():n.toLowerCase()),cU=e=>{const t=bfe(e);return t.charAt(0).toUpperCase()+t.slice(1)},z9=(...e)=>e.filter((t,n,a)=>!!t&&t.trim()!==""&&a.indexOf(t)===n).join(" ").trim(),vfe=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};var yfe={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 wfe=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,...yfe,width:t,height:t,stroke:e,strokeWidth:a?Number(n)*24/Number(t):n,className:z9("lucide",r),...!i&&!vfe(c)&&{"aria-hidden":"true"},...c},[...s.map(([d,m])=>x.createElement(d,m)),...Array.isArray(i)?i:[i]]));const Xe=(e,t)=>{const n=x.forwardRef(({className:a,...r},i)=>x.createElement(wfe,{ref:i,iconNode:t,className:z9(`lucide-${gfe(cU(e))}`,`lucide-${e}`,a),...r}));return n.displayName=cU(e),n};const xfe=[["path",{d:"M12 17V3",key:"1cwfxf"}],["path",{d:"m6 11 6 6 6-6",key:"12ii2o"}],["path",{d:"M19 21H5",key:"150jfl"}]],Sfe=Xe("arrow-down-to-line",xfe);const Efe=[["path",{d:"m18 9-6-6-6 6",key:"kcunyi"}],["path",{d:"M12 3v14",key:"7cf3v8"}],["path",{d:"M5 21h14",key:"11awu3"}]],_fe=Xe("arrow-up-from-line",Efe);const kfe=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Tfe=Xe("arrow-up",kfe);const Nfe=[["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"}]],nN=Xe("bell",Nfe);const Cfe=[["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"}]],F9=Xe("brush",Cfe);const Rfe=[["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"}]],Afe=Xe("bug",Rfe);const Ife=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],ga=Xe("check",Ife);const Ofe=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Kl=Xe("chevron-down",Ofe);const Dfe=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],jfe=Xe("chevron-right",Dfe);const Lfe=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],rN=Xe("chevron-left",Lfe);const $fe=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],Mfe=Xe("chevron-up",$fe);const Pfe=[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]],Ufe=Xe("chevrons-up-down",Pfe);const zfe=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}]],uU=Xe("circle-minus",zfe);const Ffe=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Pu=Xe("clock",Ffe);const Bfe=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],B9=Xe("code",Bfe);const Hfe=[["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"}]],Vfe=Xe("cog",Hfe);const Gfe=[["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"}]],Wfe=Xe("command",Gfe);const Kfe=[["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"}]],Br=Xe("copy",Kfe);const Zfe=[["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"}]],sy=Xe("database",Zfe);const Yfe=[["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"}]],Qp=Xe("download",Yfe);const qfe=[["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"}]],Xfe=Xe("ellipsis-vertical",qfe);const Jfe=[["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"}]],lE=Xe("external-link",Jfe);const Qfe=[["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"}]],H9=Xe("eye-off",Qfe);const epe=[["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"}]],cE=Xe("eye",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"}],["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}]],npe=Xe("file-code",tpe);const rpe=[["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"}]],ape=Xe("file-image",rpe);const ipe=[["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"}]],aN=Xe("file-text",ipe);const ope=[["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"}]],spe=Xe("file",ope);const lpe=[["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"}]],cpe=Xe("folder-open",lpe);const upe=[["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"}]],dpe=Xe("globe",upe);const fpe=[["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"}]],ppe=Xe("grip-vertical",fpe);const mpe=[["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"}]],V9=Xe("hash",mpe);const hpe=[["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"}]],zb=Xe("history",hpe);const gpe=[["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"}]],G9=Xe("key",gpe);const bpe=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Is=Xe("loader-circle",bpe);const vpe=[["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"}]],iN=Xe("maximize-2",vpe);const ype=[["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"}]],oN=Xe("maximize",ype);const wpe=[["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"}]],xpe=Xe("message-circle",wpe);const Spe=[["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"}]],lp=Xe("message-square",Spe);const Epe=[["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"}]],_pe=Xe("minimize",Epe);const kpe=[["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"}]],dU=Xe("monitor",kpe);const Tpe=[["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"}]],Npe=Xe("moon",Tpe);const Cpe=[["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"}]],Rpe=Xe("picture-in-picture",Cpe);const Ape=[["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"}]],W9=Xe("play",Ape);const Ipe=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],K9=Xe("plus",Ipe);const Ope=[["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"}]],fU=Xe("rotate-ccw",Ope);const Dpe=[["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"}]],sN=Xe("save",Dpe);const jpe=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],sd=Xe("search",jpe);const Lpe=[["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"}]],$pe=Xe("send",Lpe);const Mpe=[["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"}]],Ppe=Xe("server",Mpe);const Upe=[["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"}]],fu=Xe("settings",Upe);const zpe=[["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"}]],Fpe=Xe("shield",zpe);const Bpe=[["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"}]],Hpe=Xe("sparkles",Bpe);const Vpe=[["path",{d:"M21 10.656V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.344",key:"2acyp4"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],Z9=Xe("square-check-big",Vpe);const Gpe=[["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"}]],Wpe=Xe("square-pen",Gpe);const Kpe=[["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"}]],Zpe=Xe("sun-dim",Kpe);const Ype=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],Dx=Xe("terminal",Ype);const qpe=[["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"}]],Os=Xe("trash-2",qpe);const Xpe=[["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"}]],Jpe=Xe("trash",Xpe);const Qpe=[["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"}]],Ll=Xe("wrench",Qpe);const eme=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Wi=Xe("x",eme);const tme=[["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"}]],cp=Xe("zap",tme);function nme(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 rme=e=>{switch(e){case"success":return ome;case"info":return lme;case"warning":return sme;case"error":return cme;default:return null}},ame=Array(12).fill(0),ime=({visible:e,className:t})=>ue.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},ue.createElement("div",{className:"sonner-spinner"},ame.map((n,a)=>ue.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${a}`})))),ome=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"})),sme=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"})),lme=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"})),cme=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"})),ume=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"})),dme=()=>{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 uE=1;class fme{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:uE++,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(mme(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,S=typeof h=="object"&&!ue.isValidElement(h)?h:{message:h};this.create({id:a,type:"error",description:g,...S})}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,S=typeof h=="object"&&!ue.isValidElement(h)?h:{message:h};this.create({id:a,type:"error",description:g,...S})}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,S=typeof h=="object"&&!ue.isValidElement(h)?h:{message:h};this.create({id:a,type:"success",description:g,...S})}}).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||uE++;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 fa=new fme,pme=(e,t)=>{const n=t?.id||uE++;return fa.addToast({title:e,...t,id:n}),n},mme=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",hme=pme,gme=()=>fa.toasts,bme=()=>fa.getActiveToasts(),Jt=Object.assign(hme,{success:fa.success,info:fa.info,warning:fa.warning,error:fa.error,custom:fa.custom,message:fa.message,promise:fa.promise,dismiss:fa.dismiss,loading:fa.loading},{getHistory:gme,getToasts:bme});nme("[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 Ag(e){return e.label!==void 0}const vme=3,yme="24px",wme="16px",pU=4e3,xme=356,Sme=14,Eme=45,_me=200;function Di(...e){return e.filter(Boolean).join(" ")}function kme(e){const[t,n]=e.split("-"),a=[];return t&&a.push(t),n&&a.push(n),a}const Tme=e=>{var t,n,a,r,i,s,c,u,d;const{invert:m,toast:h,unstyled:g,interacting:v,setHeights:S,visibleToasts:w,heights:y,index:_,toasts:E,expanded:k,removeToast:R,defaultRichColors:C,closeButton:I,style:A,cancelButtonStyle:O,actionButtonStyle:M,className:U="",descriptionClassName:H="",duration:K,position:ee,gap:J,expandByDefault:ie,classNames:B,icons:Z,closeButtonAriaLabel:G="Close toast"}=e,[re,ne]=ue.useState(null),[j,V]=ue.useState(null),[z,L]=ue.useState(!1),[$,F]=ue.useState(!1),[W,X]=ue.useState(!1),[ae,le]=ue.useState(!1),[Q,q]=ue.useState(!1),[se,he]=ue.useState(0),[ce,ke]=ue.useState(0),He=ue.useRef(h.duration||K||pU),Se=ue.useRef(null),_e=ue.useRef(null),Ue=_===0,fe=_+1<=w,Ie=h.type,Fe=h.dismissible!==!1,xe=h.className||"",it=h.descriptionClassName||"",nt=ue.useMemo(()=>y.findIndex(Ye=>Ye.toastId===h.id)||0,[y,h.id]),mt=ue.useMemo(()=>{var Ye;return(Ye=h.closeButton)!=null?Ye:I},[h.closeButton,I]),Ct=ue.useMemo(()=>h.duration||K||pU,[h.duration,K]),Le=ue.useRef(0),ze=ue.useRef(0),ht=ue.useRef(0),Qe=ue.useRef(null),[Rt,rt]=ee.split("-"),Oe=ue.useMemo(()=>y.reduce((Ye,vt,jt)=>jt>=nt?Ye:Ye+vt.height,0),[y,nt]),$e=dme(),Be=h.invert||m,ut=Ie==="loading";ze.current=ue.useMemo(()=>nt*J+Oe,[nt,Oe]),ue.useEffect(()=>{He.current=Ct},[Ct]),ue.useEffect(()=>{L(!0)},[]),ue.useEffect(()=>{const Ye=_e.current;if(Ye){const vt=Ye.getBoundingClientRect().height;return ke(vt),S(jt=>[{toastId:h.id,height:vt,position:h.position},...jt]),()=>S(jt=>jt.filter(Lt=>Lt.toastId!==h.id))}},[S,h.id]),ue.useLayoutEffect(()=>{if(!z)return;const Ye=_e.current,vt=Ye.style.height;Ye.style.height="auto";const jt=Ye.getBoundingClientRect().height;Ye.style.height=vt,ke(jt),S(Lt=>Lt.find(fn=>fn.toastId===h.id)?Lt.map(fn=>fn.toastId===h.id?{...fn,height:jt}:fn):[{toastId:h.id,height:jt,position:h.position},...Lt])},[z,h.title,h.description,S,h.id,h.jsx,h.action,h.cancel]);const dt=ue.useCallback(()=>{F(!0),he(ze.current),S(Ye=>Ye.filter(vt=>vt.toastId!==h.id)),setTimeout(()=>{R(h)},_me)},[h,R,S,ze]);ue.useEffect(()=>{if(h.promise&&Ie==="loading"||h.duration===1/0||h.type==="loading")return;let Ye;return k||v||$e?(()=>{if(ht.current<Le.current){const Lt=new Date().getTime()-Le.current;He.current=He.current-Lt}ht.current=new Date().getTime()})():(()=>{He.current!==1/0&&(Le.current=new Date().getTime(),Ye=setTimeout(()=>{h.onAutoClose==null||h.onAutoClose.call(h,h),dt()},He.current))})(),()=>clearTimeout(Ye)},[k,v,h,Ie,$e,dt]),ue.useEffect(()=>{h.delete&&(dt(),h.onDismiss==null||h.onDismiss.call(h,h))},[dt,h.delete]);function wt(){var Ye;if(Z?.loading){var vt;return ue.createElement("div",{className:Di(B?.loader,h==null||(vt=h.classNames)==null?void 0:vt.loader,"sonner-loader"),"data-visible":Ie==="loading"},Z.loading)}return ue.createElement(ime,{className:Di(B?.loader,h==null||(Ye=h.classNames)==null?void 0:Ye.loader),visible:Ie==="loading"})}const xt=h.icon||Z?.[Ie]||rme(Ie);var dn,hn;return ue.createElement("li",{tabIndex:0,ref:_e,className:Di(U,xe,B?.toast,h==null||(t=h.classNames)==null?void 0:t.toast,B?.default,B?.[Ie],h==null||(n=h.classNames)==null?void 0:n[Ie]),"data-sonner-toast":"","data-rich-colors":(dn=h.richColors)!=null?dn:C,"data-styled":!(h.jsx||h.unstyled||g),"data-mounted":z,"data-promise":!!h.promise,"data-swiped":Q,"data-removed":$,"data-visible":fe,"data-y-position":Rt,"data-x-position":rt,"data-index":_,"data-front":Ue,"data-swiping":W,"data-dismissible":Fe,"data-type":Ie,"data-invert":Be,"data-swipe-out":ae,"data-swipe-direction":j,"data-expanded":!!(k||ie&&z),"data-testid":h.testId,style:{"--index":_,"--toasts-before":_,"--z-index":E.length-_,"--offset":`${$?se:ze.current}px`,"--initial-height":ie?"auto":`${ce}px`,...A,...h.style},onDragEnd:()=>{X(!1),ne(null),Qe.current=null},onPointerDown:Ye=>{Ye.button!==2&&(ut||!Fe||(Se.current=new Date,he(ze.current),Ye.target.setPointerCapture(Ye.pointerId),Ye.target.tagName!=="BUTTON"&&(X(!0),Qe.current={x:Ye.clientX,y:Ye.clientY})))},onPointerUp:()=>{var Ye,vt,jt;if(ae||!Fe)return;Qe.current=null;const Lt=Number(((Ye=_e.current)==null?void 0:Ye.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),fr=Number(((vt=_e.current)==null?void 0:vt.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),fn=new Date().getTime()-((jt=Se.current)==null?void 0:jt.getTime()),Kn=re==="x"?Lt:fr,Zn=Math.abs(Kn)/fn;if(Math.abs(Kn)>=Eme||Zn>.11){he(ze.current),h.onDismiss==null||h.onDismiss.call(h,h),V(re==="x"?Lt>0?"right":"left":fr>0?"down":"up"),dt(),le(!0);return}else{var wn,pn;(wn=_e.current)==null||wn.style.setProperty("--swipe-amount-x","0px"),(pn=_e.current)==null||pn.style.setProperty("--swipe-amount-y","0px")}q(!1),X(!1),ne(null)},onPointerMove:Ye=>{var vt,jt,Lt;if(!Qe.current||!Fe||((vt=window.getSelection())==null?void 0:vt.toString().length)>0)return;const fn=Ye.clientY-Qe.current.y,Kn=Ye.clientX-Qe.current.x;var Zn;const wn=(Zn=e.swipeDirections)!=null?Zn:kme(ee);!re&&(Math.abs(Kn)>1||Math.abs(fn)>1)&&ne(Math.abs(Kn)>Math.abs(fn)?"x":"y");let pn={x:0,y:0};const ra=en=>1/(1.5+Math.abs(en)/20);if(re==="y"){if(wn.includes("top")||wn.includes("bottom"))if(wn.includes("top")&&fn<0||wn.includes("bottom")&&fn>0)pn.y=fn;else{const en=fn*ra(fn);pn.y=Math.abs(en)<Math.abs(fn)?en:fn}}else if(re==="x"&&(wn.includes("left")||wn.includes("right")))if(wn.includes("left")&&Kn<0||wn.includes("right")&&Kn>0)pn.x=Kn;else{const en=Kn*ra(Kn);pn.x=Math.abs(en)<Math.abs(Kn)?en:Kn}(Math.abs(pn.x)>0||Math.abs(pn.y)>0)&&q(!0),(jt=_e.current)==null||jt.style.setProperty("--swipe-amount-x",`${pn.x}px`),(Lt=_e.current)==null||Lt.style.setProperty("--swipe-amount-y",`${pn.y}px`)}},mt&&!h.jsx&&Ie!=="loading"?ue.createElement("button",{"aria-label":G,"data-disabled":ut,"data-close-button":!0,onClick:ut||!Fe?()=>{}:()=>{dt(),h.onDismiss==null||h.onDismiss.call(h,h)},className:Di(B?.closeButton,h==null||(a=h.classNames)==null?void 0:a.closeButton)},(hn=Z?.close)!=null?hn:ume):null,(Ie||h.icon||h.promise)&&h.icon!==null&&(Z?.[Ie]!==null||h.icon)?ue.createElement("div",{"data-icon":"",className:Di(B?.icon,h==null||(r=h.classNames)==null?void 0:r.icon)},h.promise||h.type==="loading"&&!h.icon?h.icon||wt():null,h.type!=="loading"?xt:null):null,ue.createElement("div",{"data-content":"",className:Di(B?.content,h==null||(i=h.classNames)==null?void 0:i.content)},ue.createElement("div",{"data-title":"",className:Di(B?.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:Di(H,it,B?.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&&Ag(h.cancel)?ue.createElement("button",{"data-button":!0,"data-cancel":!0,style:h.cancelButtonStyle||O,onClick:Ye=>{Ag(h.cancel)&&Fe&&(h.cancel.onClick==null||h.cancel.onClick.call(h.cancel,Ye),dt())},className:Di(B?.cancelButton,h==null||(u=h.classNames)==null?void 0:u.cancelButton)},h.cancel.label):null,ue.isValidElement(h.action)?h.action:h.action&&Ag(h.action)?ue.createElement("button",{"data-button":!0,"data-action":!0,style:h.actionButtonStyle||M,onClick:Ye=>{Ag(h.action)&&(h.action.onClick==null||h.action.onClick.call(h.action,Ye),!Ye.defaultPrevented&&dt())},className:Di(B?.actionButton,h==null||(d=h.classNames)==null?void 0:d.actionButton)},h.action.label):null)};function mU(){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 Nme(e,t){const n={};return[e,t].forEach((a,r)=>{const i=r===1,s=i?"--mobile-offset":"--offset",c=i?wme:yme;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 Y9=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:S,style:w,visibleToasts:y=vme,toastOptions:_,dir:E=mU(),gap:k=Sme,icons:R,containerAriaLabel:C="Notifications"}=t,[I,A]=ue.useState([]),O=ue.useMemo(()=>a?I.filter(z=>z.toasterId===a):I.filter(z=>!z.toasterId),[I,a]),M=ue.useMemo(()=>Array.from(new Set([i].concat(O.filter(z=>z.position).map(z=>z.position)))),[O,i]),[U,H]=ue.useState([]),[K,ee]=ue.useState(!1),[J,ie]=ue.useState(!1),[B,Z]=ue.useState(g!=="system"?g:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),G=ue.useRef(null),re=s.join("+").replace(/Key/g,"").replace(/Digit/g,""),ne=ue.useRef(null),j=ue.useRef(!1),V=ue.useCallback(z=>{A(L=>{var $;return($=L.find(F=>F.id===z.id))!=null&&$.delete||fa.dismiss(z.id),L.filter(({id:F})=>F!==z.id)})},[]);return ue.useEffect(()=>fa.subscribe(z=>{if(z.dismiss){requestAnimationFrame(()=>{A(L=>L.map($=>$.id===z.id?{...$,delete:!0}:$))});return}setTimeout(()=>{NH.flushSync(()=>{A(L=>{const $=L.findIndex(F=>F.id===z.id);return $!==-1?[...L.slice(0,$),{...L[$],...z},...L.slice($+1)]:[z,...L]})})})}),[I]),ue.useEffect(()=>{if(g!=="system"){Z(g);return}if(g==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?Z("dark"):Z("light")),typeof window>"u")return;const z=window.matchMedia("(prefers-color-scheme: dark)");try{z.addEventListener("change",({matches:L})=>{Z(L?"dark":"light")})}catch{z.addListener(({matches:$})=>{try{Z($?"dark":"light")}catch(F){console.error(F)}})}},[g]),ue.useEffect(()=>{I.length<=1&&ee(!1)},[I]),ue.useEffect(()=>{const z=L=>{var $;if(s.every(X=>L[X]||L.code===X)){var W;ee(!0),(W=G.current)==null||W.focus()}L.code==="Escape"&&(document.activeElement===G.current||($=G.current)!=null&&$.contains(document.activeElement))&&ee(!1)};return document.addEventListener("keydown",z),()=>document.removeEventListener("keydown",z)},[s]),ue.useEffect(()=>{if(G.current)return()=>{ne.current&&(ne.current.focus({preventScroll:!0}),ne.current=null,j.current=!1)}},[G.current]),ue.createElement("section",{ref:n,"aria-label":`${C} ${re}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},M.map((z,L)=>{var $;const[F,W]=z.split("-");return O.length?ue.createElement("ol",{key:z,dir:E==="auto"?mU():E,tabIndex:-1,ref:G,className:d,"data-sonner-toaster":!0,"data-sonner-theme":B,"data-y-position":F,"data-x-position":W,style:{"--front-toast-height":`${(($=U[0])==null?void 0:$.height)||0}px`,"--width":`${xme}px`,"--gap":`${k}px`,...w,...Nme(m,h)},onBlur:X=>{j.current&&!X.currentTarget.contains(X.relatedTarget)&&(j.current=!1,ne.current&&(ne.current.focus({preventScroll:!0}),ne.current=null))},onFocus:X=>{X.target instanceof HTMLElement&&X.target.dataset.dismissible==="false"||j.current||(j.current=!0,ne.current=X.relatedTarget)},onMouseEnter:()=>ee(!0),onMouseMove:()=>ee(!0),onMouseLeave:()=>{J||ee(!1)},onDragEnd:()=>ee(!1),onPointerDown:X=>{X.target instanceof HTMLElement&&X.target.dataset.dismissible==="false"||ie(!0)},onPointerUp:()=>ie(!1)},O.filter(X=>!X.position&&L===0||X.position===z).map((X,ae)=>{var le,Q;return ue.createElement(Tme,{key:X.id,icons:R,index:ae,toast:X,defaultRichColors:v,duration:(le=_?.duration)!=null?le:S,className:_?.className,descriptionClassName:_?.descriptionClassName,invert:r,visibleToasts:y,closeButton:(Q=_?.closeButton)!=null?Q:u,interacting:J,position:z,style:_?.style,unstyled:_?.unstyled,classNames:_?.classNames,cancelButtonStyle:_?.cancelButtonStyle,actionButtonStyle:_?.actionButtonStyle,closeButtonAriaLabel:_?.closeButtonAriaLabel,removeToast:V,toasts:O.filter(q=>q.position==X.position),heights:U.filter(q=>q.position==X.position),setHeights:H,expandByDefault:c,gap:k,expanded:K,swipeDirections:t.swipeDirections})})):null}))}),hU=Object.freeze(Object.defineProperty({__proto__:null,Toaster:Y9,toast:Jt},Symbol.toStringTag,{value:"Module"}));var ly="Dialog",[q9]=ki(ly),[Cme,Ti]=q9(ly),X9=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]=Io({prop:a,defaultProp:r??!1,onChange:i,caller:ly});return f.jsx(Cme,{scope:t,triggerRef:c,contentRef:u,contentId:Dr(),titleId:Dr(),descriptionId:Dr(),open:d,onOpenChange:m,onOpenToggle:x.useCallback(()=>m(h=>!h),[m]),modal:s,children:n})};X9.displayName=ly;var J9="DialogTrigger",Q9=x.forwardRef((e,t)=>{const{__scopeDialog:n,...a}=e,r=Ti(J9,n),i=Qt(t,r.triggerRef);return f.jsx(Et.button,{type:"button","aria-haspopup":"dialog","aria-expanded":r.open,"aria-controls":r.contentId,"data-state":uN(r.open),...a,ref:i,onClick:Ve(e.onClick,r.onOpenToggle)})});Q9.displayName=J9;var lN="DialogPortal",[Rme,e8]=q9(lN,{forceMount:void 0}),t8=e=>{const{__scopeDialog:t,forceMount:n,children:a,container:r}=e,i=Ti(lN,t);return f.jsx(Rme,{scope:t,forceMount:n,children:x.Children.map(a,s=>f.jsx(Ma,{present:n||i.open,children:f.jsx(id,{asChild:!0,container:r,children:s})}))})};t8.displayName=lN;var Fb="DialogOverlay",n8=x.forwardRef((e,t)=>{const n=e8(Fb,e.__scopeDialog),{forceMount:a=n.forceMount,...r}=e,i=Ti(Fb,e.__scopeDialog);return i.modal?f.jsx(Ma,{present:a||i.open,children:f.jsx(Ime,{...r,ref:t})}):null});n8.displayName=Fb;var Ame=Dl("DialogOverlay.RemoveScroll"),Ime=x.forwardRef((e,t)=>{const{__scopeDialog:n,...a}=e,r=Ti(Fb,n);return f.jsx(Yp,{as:Ame,allowPinchZoom:!0,shards:[r.contentRef],children:f.jsx(Et.div,{"data-state":uN(r.open),...a,ref:t,style:{pointerEvents:"auto",...a.style}})})}),$l="DialogContent",r8=x.forwardRef((e,t)=>{const n=e8($l,e.__scopeDialog),{forceMount:a=n.forceMount,...r}=e,i=Ti($l,e.__scopeDialog);return f.jsx(Ma,{present:a||i.open,children:i.modal?f.jsx(Ome,{...r,ref:t}):f.jsx(Dme,{...r,ref:t})})});r8.displayName=$l;var Ome=x.forwardRef((e,t)=>{const n=Ti($l,e.__scopeDialog),a=x.useRef(null),r=Qt(t,n.contentRef,a);return x.useEffect(()=>{const i=a.current;if(i)return Jv(i)},[]),f.jsx(a8,{...e,ref:r,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Ve(e.onCloseAutoFocus,i=>{i.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:Ve(e.onPointerDownOutside,i=>{const s=i.detail.originalEvent,c=s.button===0&&s.ctrlKey===!0;(s.button===2||c)&&i.preventDefault()}),onFocusOutside:Ve(e.onFocusOutside,i=>i.preventDefault())})}),Dme=x.forwardRef((e,t)=>{const n=Ti($l,e.__scopeDialog),a=x.useRef(!1),r=x.useRef(!1);return f.jsx(a8,{...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()}})}),a8=x.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:a,onOpenAutoFocus:r,onCloseAutoFocus:i,...s}=e,c=Ti($l,n),u=x.useRef(null),d=Qt(t,u);return Vv(),f.jsxs(f.Fragment,{children:[f.jsx(Gp,{asChild:!0,loop:!0,trapped:a,onMountAutoFocus:r,onUnmountAutoFocus:i,children:f.jsx(nd,{role:"dialog",id:c.contentId,"aria-describedby":c.descriptionId,"aria-labelledby":c.titleId,"data-state":uN(c.open),...s,ref:d,onDismiss:()=>c.onOpenChange(!1)})}),f.jsxs(f.Fragment,{children:[f.jsx(jme,{titleId:c.titleId}),f.jsx($me,{contentRef:u,descriptionId:c.descriptionId})]})]})}),cN="DialogTitle",i8=x.forwardRef((e,t)=>{const{__scopeDialog:n,...a}=e,r=Ti(cN,n);return f.jsx(Et.h2,{id:r.titleId,...a,ref:t})});i8.displayName=cN;var o8="DialogDescription",s8=x.forwardRef((e,t)=>{const{__scopeDialog:n,...a}=e,r=Ti(o8,n);return f.jsx(Et.p,{id:r.descriptionId,...a,ref:t})});s8.displayName=o8;var l8="DialogClose",c8=x.forwardRef((e,t)=>{const{__scopeDialog:n,...a}=e,r=Ti(l8,n);return f.jsx(Et.button,{type:"button",...a,ref:t,onClick:Ve(e.onClick,()=>r.onOpenChange(!1))})});c8.displayName=l8;function uN(e){return e?"open":"closed"}var u8="DialogTitleWarning",[lke,d8]=wse(u8,{contentName:$l,titleName:cN,docsSlug:"dialog"}),jme=({titleId:e})=>{const t=d8(u8),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>`,gK=1,E4=2,bK=3,_4=4,vK=5,k4=Symbol.for("quilt.threads.serialize"),NEe=Symbol.for("quilt.threads.transferable");class CEe 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 T4 extends Error{constructor(){super("You attempted to call a function on a closed thread.")}}let REe="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";function yK(e=21){let t="",n=crypto.getRandomValues(new Uint8Array(e));for(let a=0;a<e;a++)t+=REe[63&n[a]];return t}var Cf,Zc,Rf,lb,d_,wK;class AEe{constructor(){fi(this,d_),fi(this,Cf,new Map),fi(this,Zc,new Map),fi(this,Rf,new Map),fi(this,lb,new WeakMap)}get(t){return Mn(this,Zc).get(t)}release(t){const n=Mn(this,Zc).get(t);return n&&(Mn(this,Zc).delete(t),Mn(this,Cf).delete(n)),!!n}serialize(t){let n=Mn(this,Cf).get(t);return n==null&&(n=yK(),Mn(this,Cf).set(t,n),Mn(this,Zc).set(n,t)),n}deserialize(t,n){var a,r;let i=(a=Mn(this,Rf).get(t))==null?void 0:a.deref();return i||(i=(...s)=>{if(!Mn(this,Rf).has(t))throw new Error("You attempted to call a function that was already revoked.");return n.call((c,u,d)=>{n.messages.send([bK,c,t,u],d)},s)},(r=Rr(this,d_,wK).call(this,n))==null||r.register(i,t),Mn(this,Rf).set(t,new WeakRef(i)),i)}}Cf=new WeakMap,Zc=new WeakMap,Rf=new WeakMap,lb=new WeakMap,d_=new WeakSet,wK=function(e){let t=Mn(this,lb).get(e);if(!(typeof FinalizationRegistry>"u"))return t||(t=new FinalizationRegistry(n=>{e.messages.send([vK,n])}),Mn(this,lb).set(e,t)),t};function IEe(e){return e!=null&&(Symbol.asyncIterator in e||Symbol.iterator in e)&&typeof e.next=="function"}function N4(e){if(e==null||typeof e!="object")return!1;const t=Object.getPrototypeOf(e);return t==null||t===Object.prototype}const lS="_@f",C4="_@i";var Yf,qf,Za,cb,vs;class OEe{constructor(t){fi(this,Za),fi(this,Yf),fi(this,qf),c_(this,Yf,t?.serialize),c_(this,qf,t?.deserialize)}serialize(t,n,a){return Rr(this,Za,cb).call(this,t,n,a)}deserialize(t,n){return Rr(this,Za,vs).call(this,t,n)}}Yf=new WeakMap,qf=new WeakMap,Za=new WeakSet,cb=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(Mn(this,Yf)&&!r){const c=Mn(this,Yf).call(this,e,u=>Rr(this,Za,cb).call(this,u,t,n,a,!0),t,n);if(c!==void 0)return a.set(e,c),c}if(e[NEe])return n?.push(e),a.set(e,e),e;const i=c=>Rr(this,Za,cb).call(this,c,t,n,a);if(typeof e[k4]=="function"){const c=e[k4]({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=IEe(e);if(N4(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[C4]=!0),a.set(e,c),c}}if(typeof e=="function"){const i=t.functions.serialize(e,t,n),s={[lS]:i};return a.set(e,s),s}return a.set(e,e),e},vs=function(e,t,n=!1){if(e==null)return e;if(typeof e=="object"){if(Mn(this,qf)&&!n){const r=Mn(this,qf).call(this,e,i=>Rr(this,Za,vs).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=>Rr(this,Za,vs).call(this,r,t));if(e instanceof Map)return new Map([...e].map(([r,i])=>[Rr(this,Za,vs).call(this,r,t),Rr(this,Za,vs).call(this,i,t)]));if(e instanceof Set)return new Set([...e].map(r=>Rr(this,Za,vs).call(this,r,t)));if(lS in e)return t.functions.deserialize(e[lS],t);if(!N4(e))return e;const a={};for(const r of Object.keys(e))r===C4?a[Symbol.asyncIterator]=()=>a:a[r]=Rr(this,Za,vs).call(this,e[r],t);return a}return e};var Yc,_l,ys,f_,xK,p_,SK;class DEe{constructor(t,{imports:n,exports:a,functions:r=new AEe,serialization:i=new OEe,signal:s}={}){fi(this,ys),fi(this,Yc),fi(this,_l,new Map);var c,u,d,m;this.messages=t,c_(this,Yc,s?new CEe(s):new AbortController),this.exports=a??{},this.imports=jEe(Rr(this,ys,xK).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 Mn(this,_l).keys())Rr(this,ys,p_).call(this,h,void 0,new T4);Mn(this,_l).clear()},{once:!0}),t.listen(async h=>{if(!(Array.isArray(h)&&typeof h[0]=="number"))return;const g=h;switch(g[0]){case gK:{const[,v,S,w]=g,y=this.exports[S]??(()=>{throw new Error(`No '${S}' method is exported from this thread`)});await Rr(this,ys,f_).call(this,y,w,(_,E,k)=>{this.messages.send([E4,v,_,E],k)});break}case bK:{const[,v,S,w]=g,y=this.functions.get(S,this)??LEe;await Rr(this,ys,f_).call(this,y,w,(_,E,k)=>{this.messages.send([_4,v,_,E],k)});break}case E4:case _4:{Rr(this,ys,p_).call(this,...g.slice(1));break}case vK:{const v=g[1];this.functions.release(v,this);break}}},{signal:this.signal})}get signal(){return Mn(this,Yc).signal}get closed(){return Mn(this,Yc).signal.aborted}close(){Mn(this,Yc).abort()}call(t,n){if(this.closed)return Promise.reject(new T4);const a=[],r=this.serialization.serialize(n,this,a),i=yK(),s=Rr(this,ys,SK).call(this,i);return t(i,r,a),s}}Yc=new WeakMap,_l=new WeakMap,ys=new WeakSet,f_=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))}},xK=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([gK,n,e,a],r)},t)}catch(n){return Promise.reject(n)}}},p_=function(...e){const t=e[0],n=Mn(this,_l).get(t);n&&(n(...e),Mn(this,_l).delete(t))},SK=function(e){const t=new Promise((n,a)=>{Mn(this,_l).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 jEe(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 LEe(){throw new Error("You attempted to call a function that is not stored. It may have already been released.")}const $Ee="quilt.threads.ping",R4="quilt.threads.pong";function MEe(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===R4&&(n=!0,s.abort(),i())},{signal:s.signal}),s.signal.addEventListener("abort",()=>i(),{once:!0}),a($Ee)});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!==R4&&i(c.data)},{signal:s})}}}class PEe extends DEe{constructor(t,{targetOrigin:n="*",...a}={}){super(MEe(t.contentWindow,{targetOrigin:n}),a),this.iframe=t}}const EK=ue.forwardRef(({content:e,children:t,...n},a)=>f.jsx("span",{ref:a,...n,children:e||t}));EK.displayName="UIText";const _K=ue.forwardRef(({label:e,onPress:t,onClick:n,children:a,...r},i)=>f.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}));_K.displayName="UIButton";const kK=ue.forwardRef(({direction:e="vertical",spacing:t="8",align:n="stretch",justify:a="flex-start",children:r,...i},s)=>f.jsx("div",{ref:s,style:{display:"flex",flexDirection:e==="horizontal"?"row":"column",gap:`${t}px`,alignItems:n,justifyContent:a},...i,children:r}));kK.displayName="UIStack";const TK=ue.forwardRef(({src:e,alt:t,width:n,height:a,children:r,...i},s)=>f.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}));TK.displayName="UIImage";const TO={name:"basic",elements:[{tagName:"ui-text",component:EK,propMapping:{content:"content"},eventMapping:{}},{tagName:"ui-button",component:_K,propMapping:{label:"label"},eventMapping:{press:"onPress"}},{tagName:"ui-stack",component:kK,propMapping:{direction:"direction",spacing:"spacing",align:"align",justify:"justify"},eventMapping:{}},{tagName:"ui-image",component:TK,propMapping:{src:"src",alt:"alt",width:"width",height:"height"},eventMapping:{}}]},UEe=({receiver:e})=>{const t=x.useRef(null);return x.useEffect(()=>{if(t.current)return e.connect(t.current),()=>{e.disconnect()}},[e]),f.jsx("div",{ref:t,"data-testid":"standard-dom-renderer-container"})},zEe=({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 bEe,S=t||TO,w=new Map;return S&&S.elements.forEach(y=>{const _=EEe(y.component);w.set(y.tagName,_)}),{receiver:v,components:w}}case"webcomponents":default:return{receiver:new vEe,components:null}}},[e,t,n]);x.useEffect(()=>{function v(S){var w;if(r.current&&S.source===r.current.contentWindow){const y=S.data;if(!y)return;(w=a?.(y))==null||w.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 S=new PEe(v);i.current=S;const{code:w,error:y}=lEe(e);if(y){c(y);return}if(w&&m!=null&&m.connection){const _={code:w,remoteElements:n,useReactRenderer:u==="react",componentLibrary:t?.name};S.imports.render(_,m.connection).catch(E=>console.error("Error calling remote render:",E))}};return s?f.jsx("p",{className:"text-red-500",children:s}):f.jsxs(f.Fragment,{children:[f.jsx("iframe",{ref:r,srcDoc:TEe,sandbox:"allow-scripts",style:{display:"none"},title:"Remote DOM Sandbox",onLoad:g},d),u==="react"&&h?f.jsx(kEe,{receiver:m,components:h}):f.jsx(UEe,{receiver:m})]})};function FEe(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 NO=e=>{const{resource:t,onUIAction:n,supportedContentTypes:a,htmlProps:r,remoteDomProps:i}=e,s=FEe(t);if(a&&s&&!a.includes(s))return f.jsxs("p",{className:"text-red-500",children:["Unsupported content type: ",s,"."]});switch(s){case"rawHtml":case"externalUrl":return f.jsx(uK,{resource:t,onUIAction:n,...r});case"remoteDom":return f.jsx(zEe,{resource:t,onUIAction:n,library:i?.library||TO,...i});default:return f.jsx("p",{className:"text-red-500",children:"Unsupported resource type."})}};NO.displayName="UIResourceRenderer";const BEe={tagName:"ui-button",remoteAttributes:["label"],remoteEvents:["click","press"]},HEe={tagName:"ui-text",remoteAttributes:["content"]},VEe={tagName:"ui-stack",remoteAttributes:["direction","spacing","align","justify"]},GEe={tagName:"ui-image",remoteAttributes:["src","alt","width","height"]},WEe=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://")?f.jsx("div",{className:"my-4 p-0 border h-[350px] rounded-2xl border-zinc-200 overflow-hidden bg-card",children:f.jsx(NO,{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 A4({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 f.jsx(xO,{componentUrl:i.uri,toolName:e,toolArgs:t,toolResult:c,serverId:a,readResource:r,noWrapper:!0,className:"my-4",showConsole:!1});if(u&&!i)return f.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:f.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?f.jsx(f.Fragment,{children:m.map(h=>f.jsx(WEe,{resource:h},`${e}-mcp-ui-${h.uri}`))}):null}function KEe({content:e,timestamp:t}){return!e||e.length===0?null:f.jsx("div",{className:"flex items-start gap-3 justify-end group/user-message",children:f.jsxs("div",{className:"flex-1 min-w-0 flex flex-col items-end",children:[f.jsx("div",{className:"bg-zinc-200 dark:bg-zinc-800 text-primary rounded-3xl px-4 py-2 max-w-[80%] break-words",children:f.jsx("p",{className:"text-base leading-7 font-sans text-start break-words",children:e})}),t&&f.jsx("span",{className:"text-xs text-muted-foreground mt-1",children:new Date(t).toLocaleTimeString()})]})})}const ZEe=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 f.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"?f.jsx(KEe,{content:u,timestamp:c.timestamp},c.id):c.role==="assistant"?f.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"?f.jsx(p4,{content:d.text||"",timestamp:m===c.parts.length-1?c.timestamp:void 0,_isStreaming:s(c)},h):d.type==="tool-invocation"&&d.toolInvocation?f.jsxs("div",{children:[f.jsx(m4,{toolName:d.toolInvocation.toolName,args:d.toolInvocation.args,result:d.toolInvocation.result,state:d.toolInvocation.result?"result":"call"}),d.toolInvocation.result&&f.jsx(A4,{toolName:d.toolInvocation.toolName,toolArgs:d.toolInvocation.args,result:d.toolInvocation.result,serverId:n,readResource:a})]},h):null}):f.jsxs(f.Fragment,{children:[f.jsx(p4,{content:u,timestamp:c.timestamp,_isStreaming:s(c)}),c.toolCalls&&c.toolCalls.length>0&&f.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 f.jsxs("div",{children:[f.jsx(m4,{toolName:d.toolName,args:d.args,result:d.result,state:d.result?"result":"call"}),d.result&&f.jsx(A4,{toolName:d.toolName,toolArgs:d.args,result:d.result,serverId:n,readResource:a})]},m)})})]})},c.id):null}),i&&f.jsx("div",{className:"flex items-start gap-3",children:f.jsx("div",{className:"flex-1",children:f.jsx("div",{className:"rounded-lg p-4 max-w-fit",children:f.jsx("div",{className:"flex items-center gap-2",children:f.jsx("span",{className:"text-sm",children:f.jsx(f0e,{duration:2,spread:1,children:"Thinking..."})})})})})}),f.jsx("div",{ref:r})]})});function NK(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 YEe({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 R="mcp:auth",C=NK(e),I=`${R}_${C}_tokens`,A=localStorage.getItem(I);if(A){const O=JSON.parse(A);g={...n,oauthTokens:O}}else console.warn("No OAuth tokens found in localStorage for key:",I)}catch(R){console.warn("Failed to retrieve OAuth tokens:",R)}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(R=>({role:R.role,content:R.content}))})});if(!v.ok)throw new Error(`HTTP error! status: ${v.status}`);const S=`assistant-${Date.now()}`;let w="";const y=[];i(R=>[...R,{id:S,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:R,value:C}=await _.read();if(R)break;k+=E.decode(C,{stream:!0});const I=k.split(`
1669
- `);k=I.pop()||"";for(const A of I)if(A.trim()&&A.startsWith("data: "))try{const O=JSON.parse(A.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"){w+=O.content;const M=y[y.length-1];M&&M.type==="text"?M.text=w:y.push({type:"text",text:w}),console.log("[Parts after text]",y.length,"parts, text length:",w.length),i(U=>U.map(H=>H.id===S?{...H,parts:[...y]}:H))}else if(O.type==="tool-call")w&&(w=""),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(M=>M.map(U=>U.id===S?{...U,parts:[...y]}:U));else if(O.type==="tool-result"){const M=y.find(U=>U.type==="tool-invocation"&&U.toolInvocation?.toolName===O.toolName&&!U.toolInvocation?.result);M&&M.toolInvocation?(M.toolInvocation.result=O.result,M.toolInvocation.state="result",console.log("[Parts after tool-result]",y.length,"parts, updated:",O.toolName),i(U=>U.map(H=>H.id===S?{...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(M=>M.map(U=>U.id===S?{...U,parts:[...y],content:""}:U));else if(O.type==="error")throw new Error(O.message||"Streaming error")}catch(O){console.error("Failed to parse streaming event:",O,A)}}}catch(g){let v="Unknown error occurred";if(g instanceof Error){v=g.message;const w=g;w.status&&(v=`HTTP ${w.status}: ${v}`),(w.code===401||v.includes("401")||v.includes("Unauthorized"))&&(v="Authentication failed (401). Check your Authorization header in the connection settings.")}const S={id:`error-${Date.now()}`,role:"assistant",content:`Error: ${v}`,timestamp:Date.now()};i(w=>[...w,S])}finally{c(!1)}},[t,a,e,r,n]),d=x.useCallback(()=>{i([])},[]);return{messages:r,isLoading:s,sendMessage:u,clearMessages:d}}function qEe({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 S={id:`user-${Date.now()}`,role:"user",content:v.trim(),timestamp:Date.now()};i(_=>[..._,S]),c(!0),u.current=new AbortController;const w=Date.now();let y=0;try{const _=`assistant-${Date.now()}`;let E="";const k=[];if(i(R=>[...R,{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 R;if(t.provider==="openai"){const{ChatOpenAI:C}=await dr(async()=>{const{ChatOpenAI:I}=await import("./index-mPE5nU31.js");return{ChatOpenAI:I}},__vite__mapDeps([5,6,7,3,8,9]));R=new C({model:t.model,apiKey:t.apiKey})}else if(t.provider==="anthropic"){const{ChatAnthropic:C}=await dr(async()=>{const{ChatAnthropic:I}=await import("./index-BpS0GDKB.js");return{ChatAnthropic:I}},__vite__mapDeps([10,7,6,3]));R=new C({model:t.model,apiKey:t.apiKey})}else if(t.provider==="google"){const{ChatGoogleGenerativeAI:C}=await dr(async()=>{const{ChatGoogleGenerativeAI:I}=await import("./index-BL2BGw9b.js");return{ChatGoogleGenerativeAI:I}},__vite__mapDeps([11,7,6,3,9]));R=new C({model:t.model,apiKey:t.apiKey})}else throw new Error(`Unsupported LLM provider: ${t.provider}`);m.current={instance:R,provider:t.provider,model:t.model,apiKey:t.apiKey}}if(!d.current||d.current.llm!==m.current.instance){const{MCPAgent:R}=await dr(async()=>{const{MCPAgent:C}=await import("./browser-DjEv9HBk.js");return{MCPAgent:C}},__vite__mapDeps([12,8,6,7,3,2,4,9]));d.current=new R({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 R of d.current.streamEvents(v,10,!1,void 0)){if(u.current?.signal.aborted)break;if(R.event==="on_chat_model_stream"&&R.data?.chunk?.text){const C=R.data.chunk.text;if(typeof C=="string"&&C.length>0){E+=C;const I=k[k.length-1];I&&I.type==="text"?I.text=E:k.push({type:"text",text:E}),i(A=>A.map(O=>O.id===_?{...O,parts:[...k]}:O))}}else if(R.event==="on_tool_start"){E&&(E="");let C={};R.data?.input?C=R.data.input:R.data?.tool_input?C=R.data.tool_input:R.data&&(C=R.data),console.log("[useChatMessagesClientSide] on_tool_start:",{toolName:R.name,eventData:R.data,extractedArgs:C}),y++,k.push({type:"tool-invocation",toolInvocation:{toolName:R.name||"unknown",args:C,state:"pending"}}),i(I=>I.map(A=>A.id===_?{...A,parts:[...k]}:A))}else if(R.event==="on_tool_end"){const C=k.find(I=>I.type==="tool-invocation"&&I.toolInvocation?.toolName===R.name&&!I.toolInvocation?.result);if(console.log("[useChatMessagesClientSide] on_tool_end event:",{toolName:R.name,hasToolPart:!!C,output:R.data?.output}),C&&C.toolInvocation){let I=R.data?.output;if(I?.kwargs?.content&&typeof I.kwargs.content=="string")try{I=JSON.parse(I.kwargs.content)}catch(O){console.warn("[useChatMessagesClientSide] Failed to parse kwargs.content:",O),I=I.kwargs.content}else if(I?.content&&typeof I.content=="string")try{I=JSON.parse(I.content)}catch{I=I.content}C.toolInvocation.result=I,C.toolInvocation.state="result";const A=I?._meta?.["openai/outputTemplate"];if(console.log("[useChatMessagesClientSide] Tool result:",{toolName:R.name,hasMeta:!!I?._meta,hasStructuredContent:!!I?.structuredContent,appsSdkUri:A}),A&&typeof A=="string"&&a){console.log("[useChatMessagesClientSide] Detected Apps SDK component, fetching resource:",A);try{const O=await a(A);console.log("[useChatMessagesClientSide] Resource fetched:",O);const M=I?.structuredContent||null;if(O?.contents&&Array.isArray(O.contents)){const U=O.contents.map(K=>({type:"resource",resource:K}));console.log("[useChatMessagesClientSide] Created MCP resources:",U);const H={...I,content:[...I.content||[],...U],structuredContent:M};C.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(M=>M.id===_?{...M,parts:[...k]}:M))}}}i(R=>R.map(C=>C.id===_?{...C,parts:[...k],content:""}:C)),t&&yr.getInstance().capture(new sU({serverId:e.url,provider:t.provider,model:t.model,messageCount:r.length+1,toolCallsCount:y,success:!0,executionMode:"client-side",duration:Date.now()-w})).catch(()=>{})}catch(_){console.error("Client-side agent error:",_);let E="Unknown error occurred";if(_ instanceof Error){E=_.message;const R=_;R.status&&(E=`HTTP ${R.status}: ${E}`),(R.code===401||E.includes("401")||E.includes("Unauthorized"))&&(E="Authentication failed (401). Check your Authorization header in the connection settings.")}t&&yr.getInstance().capture(new sU({serverId:e.url,provider:t.provider,model:t.model,messageCount:r.length+1,toolCallsCount:y,success:!1,executionMode:"client-side",duration:Date.now()-w,error:E})).catch(()=>{});const k={id:`error-${Date.now()}`,role:"assistant",content:`Error: ${E}`,timestamp:Date.now()};i(R=>[...R,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 I4={openai:"gpt-4o",anthropic:"claude-haiku-4-5-20251001",google:"gemini-2.5-flash"};function CK({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(I4.openai),v=x.useCallback(()=>{const M=localStorage.getItem("mcp-inspector-api-keys");if(M)try{return JSON.parse(M)}catch(U){return console.error("Failed to load API keys:",U),{}}return{}},[]),S=x.useCallback(M=>{localStorage.setItem("mcp-inspector-api-keys",JSON.stringify(M))},[]),[w,y]=x.useState("none"),[_,E]=x.useState(""),[k,R]=x.useState(""),[C,I]=x.useState("");x.useEffect(()=>{const M=localStorage.getItem("mcp-inspector-llm-config"),U=v();if(M)try{const H=JSON.parse(M);n(H),u(H.provider),m(U[H.provider]||H.apiKey||""),g(H.model)}catch(H){console.error("Failed to load LLM config:",H)}},[v]),x.useEffect(()=>{const M=localStorage.getItem("mcp-inspector-auth-config");if(M)try{const U=JSON.parse(M);r(U),y(U.type),U.username&&E(U.username),U.password&&R(U.password),U.token&&I(U.token)}catch(U){console.error("Failed to load auth config:",U)}else try{const U="mcp:auth",H=NK(e),K=`${U}_${H}_tokens`;localStorage.getItem(K)&&(r({type:"oauth"}),y("oauth"))}catch(U){console.error("Failed to check for OAuth tokens:",U)}},[e]),x.useEffect(()=>{g(I4[c]);const M=v();m(M[c]||"")},[c,v]);const A=x.useCallback(()=>{if(!d.trim())return;const M=v();M[c]=d,S(M);const U={provider:c,apiKey:d,model:h},H={type:w,...w==="basic"&&{username:_.trim(),password:k.trim()},...w==="bearer"&&{token:C.trim()}};n(U),r(H),localStorage.setItem("mcp-inspector-llm-config",JSON.stringify(U)),localStorage.setItem("mcp-inspector-auth-config",JSON.stringify(H)),s(!1)},[c,d,h,w,_,k,C,v,S]),O=x.useCallback(()=>{n(null),r(null);const M=v();delete M[c],S(M),m(""),E(""),R(""),I(""),y("none"),localStorage.removeItem("mcp-inspector-llm-config"),localStorage.removeItem("mcp-inspector-auth-config")},[c,v,S]);return{llmConfig:t,authConfig:a,configDialogOpen:i,setConfigDialogOpen:s,tempProvider:c,setTempProvider:u,tempApiKey:d,setTempApiKey:m,tempModel:h,setTempModel:g,tempAuthType:w,saveLLMConfig:A,clearConfig:O}}function XEe({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:S,tempModel:w,setTempModel:y,saveLLMConfig:_,clearConfig:E}=CK({mcpServerUrl:e.url}),k={connection:e,llmConfig:c,isConnected:t,readResource:a},R=YEe({mcpServerUrl:e.url,llmConfig:c,authConfig:u,isConnected:t}),C=qEe(k),{messages:I,isLoading:A,sendMessage:O,clearMessages:M}=n?C:R;TW({onNewChat:M}),x.useEffect(()=>{c&&I.length===0&&s.current&&s.current.focus()},[c,I.length]),x.useEffect(()=>{!A&&I.length>0&&s.current&&s.current.focus()},[A,I.length]);const U=x.useCallback(()=>{r.trim()&&(O(r),i(""))},[r,O]),H=x.useCallback(ee=>{ee.key==="Enter"&&!ee.shiftKey&&(ee.preventDefault(),U())},[U]),K=x.useCallback(()=>{E(),M()},[E,M]);return c&&I.length===0?f.jsxs("div",{className:"flex flex-col h-full",children:[f.jsx("div",{className:"absolute top-4 right-4 z-10",children:f.jsx(UE,{open:d,onOpenChange:m,tempProvider:h,tempModel:w,tempApiKey:v,onProviderChange:g,onModelChange:y,onApiKeyChange:S,onSave:_,onClear:K,showClearButton:!0,buttonLabel:"Change API Key"})}),f.jsx(u0e,{mcpServerUrl:e.url,inputValue:r,isConnected:t,isLoading:A,textareaRef:s,llmConfig:c,onInputChange:i,onKeyDown:H,onSubmit:ee=>{ee.preventDefault(),U()},onConfigDialogOpenChange:m})]}):f.jsxs("div",{className:"flex flex-col h-full relative",children:[f.jsx(s0e,{llmConfig:c,hasMessages:I.length>0,configDialogOpen:d,onConfigDialogOpenChange:m,onClearChat:M,tempProvider:h,tempModel:w,tempApiKey:v,onProviderChange:g,onModelChange:y,onApiKeyChange:S,onSaveConfig:_,onClearConfig:K}),f.jsx("div",{className:"flex-1 overflow-y-auto p-2 sm:p-4 pt-[80px] sm:pt-[100px]",children:c?f.jsx(ZEe,{messages:I,isLoading:A,serverId:e.url,readResource:a}):f.jsx(d0e,{onConfigureClick:()=>m(!0)})}),c&&f.jsx(l0e,{inputValue:r,isConnected:t,isLoading:A,textareaRef:s,onInputChange:i,onKeyDown:H,onSendMessage:U})]})}const Ly=x.createContext(null);Ly.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"},CO=10,Cl=x.useLayoutEffect,O4=Zu.useId,JEe=typeof O4=="function"?O4:()=>null;let QEe=0;function RO(e=null){const t=JEe(),n=x.useRef(e||t||null);return n.current===null&&(n.current=""+QEe++),e??n.current}function RK({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:S="div",...w}){const y=x.useContext(Ly);if(y===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:_,expandPanel:E,getPanelSize:k,getPanelStyle:R,groupId:C,isPanelCollapsed:I,reevaluatePanelConstraints:A,registerPanel:O,resizePanel:M,unregisterPanel:U}=y,H=RO(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}),Cl(()=>{const{callbacks:J,constraints:ie}=K.current,B={...ie};K.current.id=H,K.current.idIsFromProps=s!==void 0,K.current.order=g,J.onCollapse=d,J.onExpand=m,J.onResize=h,ie.collapsedSize=n,ie.collapsible=a,ie.defaultSize=r,ie.maxSize=c,ie.minSize=u,(B.collapsedSize!==ie.collapsedSize||B.collapsible!==ie.collapsible||B.maxSize!==ie.maxSize||B.minSize!==ie.minSize)&&A(K.current,B)}),Cl(()=>{const J=K.current;return O(J),()=>{U(J)}},[g,H,O,U]),x.useImperativeHandle(i,()=>({collapse:()=>{_(K.current)},expand:J=>{E(K.current,J)},getId(){return H},getSize(){return k(K.current)},isCollapsed(){return I(K.current)},isExpanded(){return!I(K.current)},resize:J=>{M(K.current,J)}}),[_,E,k,I,H,M]);const ee=R(K.current,r);return x.createElement(S,{...w,children:e,className:t,id:H,style:{...ee,...v},[Wn.groupId]:C,[Wn.panel]:"",[Wn.panelCollapsible]:a||void 0,[Wn.panelId]:H,[Wn.panelSize]:parseFloat(""+ee.flexGrow).toFixed(1)})}const AK=x.forwardRef((e,t)=>x.createElement(RK,{...e,forwardedRef:t}));RK.displayName="Panel";AK.displayName="forwardRef(Panel)";let m_=null,ub=-1,Es=null;function e_e(e,t,n){const a=(t&LK)!==0,r=(t&$K)!==0,i=(t&MK)!==0,s=(t&PK)!==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 t_e(){Es!==null&&(document.head.removeChild(Es),m_=null,Es=null,ub=-1)}function cS(e,t,n){var a,r;const i=e_e(e,t);if(m_!==i){if(m_=i,Es===null&&(Es=document.createElement("style"),document.head.appendChild(Es)),ub>=0){var s;(s=Es.sheet)===null||s===void 0||s.removeRule(ub)}ub=(a=(r=Es.sheet)===null||r===void 0?void 0:r.insertRule(`*{cursor: ${i} !important;}`))!==null&&a!==void 0?a:-1}}function IK(e){return e.type==="keydown"}function OK(e){return e.type.startsWith("pointer")}function DK(e){return e.type.startsWith("mouse")}function $y(e){if(OK(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(DK(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}function n_e(){if(typeof matchMedia=="function")return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}function r_e(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 a_e(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:L4(e),b:L4(t)};let a;for(;n.a.at(-1)===n.b.at(-1);)e=n.a.pop(),t=n.b.pop(),a=e;Tt(a,"Stacking order can only be calculated for elements with a common ancestor");const r={a:j4(D4(n.a)),b:j4(D4(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 i_e=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function o_e(e){var t;const n=getComputedStyle((t=jK(e))!==null&&t!==void 0?t:e).display;return n==="flex"||n==="inline-flex"}function s_e(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||o_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"||i_e.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function D4(e){let t=e.length;for(;t--;){const n=e[t];if(Tt(n,"Missing node"),s_e(n))return n}return null}function j4(e){return e&&Number(getComputedStyle(e).zIndex)||0}function L4(e){const t=[];for(;e;)t.push(e),e=jK(e);return t}function jK(e){const{parentNode:t}=e;return t&&t instanceof ShadowRoot?t.host:t}const LK=1,$K=2,MK=4,PK=8,l_e=n_e()==="coarse";let gi=[],gu=!1,_s=new Map,My=new Map;const _p=new Set;function c_e(e,t,n,a,r){var i;const{ownerDocument:s}=t,c={direction:n,element:t,hitAreaMargins:a,setResizeHandlerState:r},u=(i=_s.get(s))!==null&&i!==void 0?i:0;return _s.set(s,u+1),_p.add(c),pv(),function(){var m;My.delete(e),_p.delete(c);const h=(m=_s.get(s))!==null&&m!==void 0?m:1;if(_s.set(s,h-1),pv(),h===1&&_s.delete(s),gi.includes(c)){const g=gi.indexOf(c);g>=0&&gi.splice(g,1),Py(),r("up",!0,null)}}}function u_e(e){const{target:t}=e,{x:n,y:a}=$y(e);gu=!0,AO({target:t,x:n,y:a}),pv(),gi.length>0&&(mv("down",e),Py(),e.preventDefault(),UK(t)||e.stopImmediatePropagation())}function uS(e){const{x:t,y:n}=$y(e);if(gu&&e.type!=="pointerleave"&&e.buttons===0&&(gu=!1,mv("up",e)),!gu){const{target:a}=e;AO({target:a,x:t,y:n})}mv("move",e),Py(),gi.length>0&&e.preventDefault()}function dS(e){const{target:t}=e,{x:n,y:a}=$y(e);My.clear(),gu=!1,gi.length>0&&(e.preventDefault(),UK(t)||e.stopImmediatePropagation()),mv("up",e),AO({target:t,x:n,y:a}),Py(),pv()}function UK(e){let t=e;for(;t;){if(t.hasAttribute(Wn.resizeHandle))return!0;t=t.parentElement}return!1}function AO({target:e,x:t,y:n}){gi.splice(0);let a=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(a=e),_p.forEach(r=>{const{element:i,hitAreaMargins:s}=r,c=i.getBoundingClientRect(),{bottom:u,left:d,right:m,top:h}=c,g=l_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)&&a_e(a,i)>0){let S=a,w=!1;for(;S&&!S.contains(i);){if(r_e(S.getBoundingClientRect(),c)){w=!0;break}S=S.parentElement}if(w)return}gi.push(r)}})}function fS(e,t){My.set(e,t)}function Py(){let e=!1,t=!1;gi.forEach(a=>{const{direction:r}=a;r==="horizontal"?e=!0:t=!0});let n=0;My.forEach(a=>{n|=a}),e&&t?cS("intersection",n):e?cS("horizontal",n):t?cS("vertical",n):t_e()}let pS;function pv(){var e;(e=pS)===null||e===void 0||e.abort(),pS=new AbortController;const t={capture:!0,signal:pS.signal};_p.size&&(gu?(gi.length>0&&_s.forEach((n,a)=>{const{body:r}=a;n>0&&(r.addEventListener("contextmenu",dS,t),r.addEventListener("pointerleave",uS,t),r.addEventListener("pointermove",uS,t))}),_s.forEach((n,a)=>{const{body:r}=a;r.addEventListener("pointerup",dS,t),r.addEventListener("pointercancel",dS,t)})):_s.forEach((n,a)=>{const{body:r}=a;n>0&&(r.addEventListener("pointerdown",u_e,t),r.addEventListener("pointermove",uS,t))}))}function mv(e,t){_p.forEach(n=>{const{setResizeHandlerState:a}=n,r=gi.includes(n);a(e,r,t)})}function d_e(){const[e,t]=x.useState(0);return x.useCallback(()=>t(n=>n+1),[])}function Tt(e,t){if(!e)throw console.error(t),Error(t)}function Bl(e,t,n=CO){return e.toFixed(n)===t.toFixed(n)?0:e>t?1:-1}function wo(e,t,n=CO){return Bl(e,t,n)===0}function Ia(e,t,n){return Bl(e,t,n)===0}function f_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(!Ia(r,i,n))return!1}return!0}function lu({panelConstraints:e,panelIndex:t,size:n}){const a=e[t];Tt(a!=null,`Panel constraints not found for index ${t}`);let{collapsedSize:r=0,collapsible:i,maxSize:s=100,minSize:c=0}=a;if(Bl(n,c)<0)if(i){const u=(r+c)/2;Bl(n,u)<0?n=r:n=c}else n=c;return n=Math.min(s,n),n=parseFloat(n.toFixed(CO)),n}function Af({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:a,prevLayout:r,trigger:i}){if(Ia(e,0))return t;const s=[...t],[c,u]=a;Tt(c!=null,"Invalid first pivot index"),Tt(u!=null,"Invalid second pivot index");let d=0;if(i==="keyboard"){{const h=e<0?u:c,g=n[h];Tt(g,`Panel constraints not found for index ${h}`);const{collapsedSize:v=0,collapsible:S,minSize:w=0}=g;if(S){const y=t[h];if(Tt(y!=null,`Previous layout not found for panel index ${h}`),Ia(y,v)){const _=w-y;Bl(_,Math.abs(e))>0&&(e=e<0?0-_:_)}}}{const h=e<0?c:u,g=n[h];Tt(g,`No panel constraints found for index ${h}`);const{collapsedSize:v=0,collapsible:S,minSize:w=0}=g;if(S){const y=t[h];if(Tt(y!=null,`Previous layout not found for panel index ${h}`),Ia(y,w)){const _=y-v;Bl(_,Math.abs(e))>0&&(e=e<0?0-_:_)}}}}{const h=e<0?1:-1;let g=e<0?u:c,v=0;for(;;){const w=t[g];Tt(w!=null,`Previous layout not found for panel index ${g}`);const _=lu({panelConstraints:n,panelIndex:g,size:100})-w;if(v+=_,g+=h,g<0||g>=n.length)break}const S=Math.min(Math.abs(e),Math.abs(v));e=e<0?0-S:S}{let g=e<0?c:u;for(;g>=0&&g<n.length;){const v=Math.abs(e)-Math.abs(d),S=t[g];Tt(S!=null,`Previous layout not found for panel index ${g}`);const w=S-v,y=lu({panelConstraints:n,panelIndex:g,size:w});if(!Ia(S,y)&&(d+=S-y,s[g]=y,d.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?g--:g++}}if(f_e(r,s))return r;{const h=e<0?u:c,g=t[h];Tt(g!=null,`Previous layout not found for panel index ${h}`);const v=g+d,S=lu({panelConstraints:n,panelIndex:h,size:v});if(s[h]=S,!Ia(S,v)){let w=v-S,_=e<0?u:c;for(;_>=0&&_<n.length;){const E=s[_];Tt(E!=null,`Previous layout not found for panel index ${_}`);const k=E+w,R=lu({panelConstraints:n,panelIndex:_,size:k});if(Ia(E,R)||(w-=R-E,s[_]=R),Ia(w,0))break;e>0?_--:_++}}}const m=s.reduce((h,g)=>g+h,0);return Ia(m,100)?s:r}function p_e({layout:e,panelsArray:t,pivotIndices:n}){let a=0,r=100,i=0,s=0;const c=n[0];Tt(c!=null,"No pivot index found"),t.forEach((h,g)=>{const{constraints:v}=h,{maxSize:S=100,minSize:w=0}=v;g===c?(a=w,r=S):(i+=w,s+=S)});const u=Math.min(r,100-i),d=Math.max(a,100-s),m=e[c];return{valueMax:u,valueMin:d,valueNow:m}}function kp(e,t=document){return Array.from(t.querySelectorAll(`[${Wn.resizeHandleId}][data-panel-group-id="${e}"]`))}function zK(e,t,n=document){const r=kp(e,n).findIndex(i=>i.getAttribute(Wn.resizeHandleId)===t);return r??null}function FK(e,t,n){const a=zK(e,t,n);return a!=null?[a,a+1]:[-1,-1]}function m_e(e){return e instanceof HTMLElement?!0:typeof e=="object"&&e!==null&&"tagName"in e&&"getAttribute"in e}function BK(e,t=document){if(m_e(t)&&t.dataset.panelGroupId==e)return t;const n=t.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return n||null}function Uy(e,t=document){const n=t.querySelector(`[${Wn.resizeHandleId}="${e}"]`);return n||null}function h_e(e,t,n,a=document){var r,i,s,c;const u=Uy(t,a),d=kp(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 g_e({committedValuesRef:e,eagerValuesRef:t,groupId:n,layout:a,panelDataArray:r,panelGroupElement:i,setLayout:s}){x.useRef({didWarnAboutMissingResizeHandle:!1}),Cl(()=>{if(!i)return;const c=kp(n,i);for(let u=0;u<r.length-1;u++){const{valueMax:d,valueMin:m,valueNow:h}=p_e({layout:a,panelsArray:r,pivotIndices:[u,u+1]}),g=c[u];if(g!=null){const v=r[u];Tt(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;Tt(c,"Eager values not found");const{panelDataArray:u}=c,d=BK(n,i);Tt(d!=null,`No group found for id "${n}"`);const m=kp(n,i);Tt(m,`No resize handles found for group id "${n}"`);const h=m.map(g=>{const v=g.getAttribute(Wn.resizeHandleId);Tt(v,"Resize handle element has no handle id attribute");const[S,w]=h_e(n,v,u,i);if(S==null||w==null)return()=>{};const y=_=>{if(!_.defaultPrevented)switch(_.key){case"Enter":{_.preventDefault();const E=u.findIndex(k=>k.id===S);if(E>=0){const k=u[E];Tt(k,`No panel data found for index ${E}`);const R=a[E],{collapsedSize:C=0,collapsible:I,minSize:A=0}=k.constraints;if(R!=null&&I){const O=Af({delta:Ia(R,C)?A-C:C-R,initialLayout:a,panelConstraints:u.map(M=>M.constraints),pivotIndices:FK(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 $4(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 HK(e,t){const n=e==="horizontal",{x:a,y:r}=$y(t);return n?a:r}function b_e(e,t,n,a,r){const i=n==="horizontal",s=Uy(t,r);Tt(s,`No resize handle element found for id "${t}"`);const c=s.getAttribute(Wn.groupId);Tt(c,"Resize handle element has no group id attribute");let{initialCursorPosition:u}=a;const d=HK(n,e),m=BK(c,r);Tt(m,`No group element found for id "${c}"`);const h=m.getBoundingClientRect(),g=i?h.width:h.height;return(d-u)/g*100}function v_e(e,t,n,a,r,i){if(IK(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:b_e(e,t,n,a,i)}function y_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];Tt(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];Tt(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 zc(e,t,n){t.forEach((a,r)=>{const i=e[r];Tt(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:S}=s;S&&S(a,h),m&&(g||v)&&(v&&(h==null||wo(h,d))&&!wo(a,d)&&v(),g&&(h==null||!wo(h,d))&&wo(a,d)&&g())}})}function zg(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 w_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 x_e(e,t=10){let n=null;return(...r)=>{n!==null&&clearTimeout(n),n=setTimeout(()=>{e(...r)},t)}}function M4(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 VK(e){return`react-resizable-panels:${e}`}function GK(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 WK(e,t){try{const n=VK(e),a=t.getItem(n);if(a){const r=JSON.parse(a);if(typeof r=="object"&&r!=null)return r}}catch{}return null}function S_e(e,t,n){var a,r;const i=(a=WK(e,n))!==null&&a!==void 0?a:{},s=GK(t);return(r=i[s])!==null&&r!==void 0?r:null}function E_e(e,t,n,a,r){var i;const s=VK(e),c=GK(t),u=(i=WK(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 P4({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(!Ia(a,100)&&n.length>0)for(let i=0;i<t.length;i++){const s=n[i];Tt(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];Tt(s!=null,`No layout data found for index ${i}`);const c=lu({panelConstraints:t,panelIndex:i,size:s});s!=c&&(r+=s-c,n[i]=c)}if(!Ia(r,0))for(let i=0;i<t.length;i++){const s=n[i];Tt(s!=null,`No layout data found for index ${i}`);const c=s+r,u=lu({panelConstraints:t,panelIndex:i,size:c});if(s!==u&&(r-=u-s,n[i]=u,Ia(r,0)))break}return n}const __e=100,If={getItem:e=>(M4(If),If.getItem(e)),setItem:(e,t)=>{M4(If),If.setItem(e,t)}},U4={};function KK({autoSaveId:e=null,children:t,className:n="",direction:a,forwardedRef:r,id:i=null,onLayout:s=null,keyboardResizeBy:c=null,storage:u=If,style:d,tagName:m="div",...h}){const g=RO(i),v=x.useRef(null),[S,w]=x.useState(null),[y,_]=x.useState([]),E=d_e(),k=x.useRef({}),R=x.useRef(new Map),C=x.useRef(0),I=x.useRef({autoSaveId:e,direction:a,dragState:S,id:g,keyboardResizeBy:c,onLayout:s,storage:u}),A=x.useRef({layout:y,panelDataArray:[],panelDataArrayChanged:!1});x.useRef({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),x.useImperativeHandle(r,()=>({getId:()=>I.current.id,getLayout:()=>{const{layout:z}=A.current;return z},setLayout:z=>{const{onLayout:L}=I.current,{layout:$,panelDataArray:F}=A.current,W=P4({layout:z,panelConstraints:F.map(X=>X.constraints)});$4($,W)||(_(W),A.current.layout=W,L&&L(W),zc(F,W,k.current))}}),[]),Cl(()=>{I.current.autoSaveId=e,I.current.direction=a,I.current.dragState=S,I.current.id=g,I.current.onLayout=s,I.current.storage=u}),g_e({committedValuesRef:I,eagerValuesRef:A,groupId:g,layout:y,panelDataArray:A.current.panelDataArray,setLayout:_,panelGroupElement:v.current}),x.useEffect(()=>{const{panelDataArray:z}=A.current;if(e){if(y.length===0||y.length!==z.length)return;let L=U4[e];L==null&&(L=x_e(E_e,__e),U4[e]=L);const $=[...z],F=new Map(R.current);L(e,$,F,y,u)}},[e,y,u]),x.useEffect(()=>{});const O=x.useCallback(z=>{const{onLayout:L}=I.current,{layout:$,panelDataArray:F}=A.current;if(z.constraints.collapsible){const W=F.map(Q=>Q.constraints),{collapsedSize:X=0,panelSize:ae,pivotIndices:le}=ml(F,z,$);if(Tt(ae!=null,`Panel size not found for panel "${z.id}"`),!wo(ae,X)){R.current.set(z.id,ae);const q=qc(F,z)===F.length-1?ae-X:X-ae,se=Af({delta:q,initialLayout:$,panelConstraints:W,pivotIndices:le,prevLayout:$,trigger:"imperative-api"});zg($,se)||(_(se),A.current.layout=se,L&&L(se),zc(F,se,k.current))}}},[]),M=x.useCallback((z,L)=>{const{onLayout:$}=I.current,{layout:F,panelDataArray:W}=A.current;if(z.constraints.collapsible){const X=W.map(he=>he.constraints),{collapsedSize:ae=0,panelSize:le=0,minSize:Q=0,pivotIndices:q}=ml(W,z,F),se=L??Q;if(wo(le,ae)){const he=R.current.get(z.id),ce=he!=null&&he>=se?he:se,He=qc(W,z)===W.length-1?le-ce:ce-le,Se=Af({delta:He,initialLayout:F,panelConstraints:X,pivotIndices:q,prevLayout:F,trigger:"imperative-api"});zg(F,Se)||(_(Se),A.current.layout=Se,$&&$(Se),zc(W,Se,k.current))}}},[]),U=x.useCallback(z=>{const{layout:L,panelDataArray:$}=A.current,{panelSize:F}=ml($,z,L);return Tt(F!=null,`Panel size not found for panel "${z.id}"`),F},[]),H=x.useCallback((z,L)=>{const{panelDataArray:$}=A.current,F=qc($,z);return w_e({defaultSize:L,dragState:S,layout:y,panelData:$,panelIndex:F})},[S,y]),K=x.useCallback(z=>{const{layout:L,panelDataArray:$}=A.current,{collapsedSize:F=0,collapsible:W,panelSize:X}=ml($,z,L);return Tt(X!=null,`Panel size not found for panel "${z.id}"`),W===!0&&wo(X,F)},[]),ee=x.useCallback(z=>{const{layout:L,panelDataArray:$}=A.current,{collapsedSize:F=0,collapsible:W,panelSize:X}=ml($,z,L);return Tt(X!=null,`Panel size not found for panel "${z.id}"`),!W||Bl(X,F)>0},[]),J=x.useCallback(z=>{const{panelDataArray:L}=A.current;L.push(z),L.sort(($,F)=>{const W=$.order,X=F.order;return W==null&&X==null?0:W==null?-1:X==null?1:W-X}),A.current.panelDataArrayChanged=!0,E()},[E]);Cl(()=>{if(A.current.panelDataArrayChanged){A.current.panelDataArrayChanged=!1;const{autoSaveId:z,onLayout:L,storage:$}=I.current,{layout:F,panelDataArray:W}=A.current;let X=null;if(z){const le=S_e(z,W,$);le&&(R.current=new Map(Object.entries(le.expandToSizes)),X=le.layout)}X==null&&(X=y_e({panelDataArray:W}));const ae=P4({layout:X,panelConstraints:W.map(le=>le.constraints)});$4(F,ae)||(_(ae),A.current.layout=ae,L&&L(ae),zc(W,ae,k.current))}}),Cl(()=>{const z=A.current;return()=>{z.layout=[]}},[]);const ie=x.useCallback(z=>{let L=!1;const $=v.current;return $&&window.getComputedStyle($,null).getPropertyValue("direction")==="rtl"&&(L=!0),function(W){W.preventDefault();const X=v.current;if(!X)return()=>null;const{direction:ae,dragState:le,id:Q,keyboardResizeBy:q,onLayout:se}=I.current,{layout:he,panelDataArray:ce}=A.current,{initialLayout:ke}=le??{},He=FK(Q,z,X);let Se=v_e(W,z,ae,le,q,X);const _e=ae==="horizontal";_e&&L&&(Se=-Se);const Ue=ce.map(Fe=>Fe.constraints),fe=Af({delta:Se,initialLayout:ke??he,panelConstraints:Ue,pivotIndices:He,prevLayout:he,trigger:IK(W)?"keyboard":"mouse-or-touch"}),Ie=!zg(he,fe);(OK(W)||DK(W))&&C.current!=Se&&(C.current=Se,!Ie&&Se!==0?_e?fS(z,Se<0?LK:$K):fS(z,Se<0?MK:PK):fS(z,0)),Ie&&(_(fe),A.current.layout=fe,se&&se(fe),zc(ce,fe,k.current))}},[]),B=x.useCallback((z,L)=>{const{onLayout:$}=I.current,{layout:F,panelDataArray:W}=A.current,X=W.map(he=>he.constraints),{panelSize:ae,pivotIndices:le}=ml(W,z,F);Tt(ae!=null,`Panel size not found for panel "${z.id}"`);const q=qc(W,z)===W.length-1?ae-L:L-ae,se=Af({delta:q,initialLayout:F,panelConstraints:X,pivotIndices:le,prevLayout:F,trigger:"imperative-api"});zg(F,se)||(_(se),A.current.layout=se,$&&$(se),zc(W,se,k.current))},[]),Z=x.useCallback((z,L)=>{const{layout:$,panelDataArray:F}=A.current,{collapsedSize:W=0,collapsible:X}=L,{collapsedSize:ae=0,collapsible:le,maxSize:Q=100,minSize:q=0}=z.constraints,{panelSize:se}=ml(F,z,$);se!=null&&(X&&le&&wo(se,W)?wo(W,ae)||B(z,ae):se<q?B(z,q):se>Q&&B(z,Q))},[B]),G=x.useCallback((z,L)=>{const{direction:$}=I.current,{layout:F}=A.current;if(!v.current)return;const W=Uy(z,v.current);Tt(W,`Drag handle element not found for id "${z}"`);const X=HK($,L);w({dragHandleId:z,dragHandleRect:W.getBoundingClientRect(),initialCursorPosition:X,initialLayout:F})},[]),re=x.useCallback(()=>{w(null)},[]),ne=x.useCallback(z=>{const{panelDataArray:L}=A.current,$=qc(L,z);$>=0&&(L.splice($,1),delete k.current[z.id],A.current.panelDataArrayChanged=!0,E())},[E]),j=x.useMemo(()=>({collapsePanel:O,direction:a,dragState:S,expandPanel:M,getPanelSize:U,getPanelStyle:H,groupId:g,isPanelCollapsed:K,isPanelExpanded:ee,reevaluatePanelConstraints:Z,registerPanel:J,registerResizeHandle:ie,resizePanel:B,startDragging:G,stopDragging:re,unregisterPanel:ne,panelGroupElement:v.current}),[O,S,a,M,U,H,g,K,ee,Z,J,ie,B,G,re,ne]),V={display:"flex",flexDirection:a==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return x.createElement(Ly.Provider,{value:j},x.createElement(m,{...h,children:t,className:n,id:i,ref:v,style:{...V,...d},[Wn.group]:"",[Wn.groupDirection]:a,[Wn.groupId]:g}))}const ZK=x.forwardRef((e,t)=>x.createElement(KK,{...e,forwardedRef:t}));KK.displayName="PanelGroup";ZK.displayName="forwardRef(PanelGroup)";function qc(e,t){return e.findIndex(n=>n===t||n.id===t.id)}function ml(e,t,n){const a=qc(e,t),i=a===e.length-1?[a-1,a]:[a,a+1],s=n[a];return{...t.constraints,panelSize:s,pivotIndices:i}}function k_e({disabled:e,handleId:t,resizeHandler:n,panelGroupElement:a}){x.useEffect(()=>{if(e||n==null||a==null)return;const r=Uy(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);Tt(c,`No group element found for id "${c}"`);const u=kp(c,a),d=zK(c,t,a);Tt(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 YK({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",...S}){var w,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(Ly);if(k===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:R,groupId:C,registerResizeHandle:I,startDragging:A,stopDragging:O,panelGroupElement:M}=k,U=RO(r),[H,K]=x.useState("inactive"),[ee,J]=x.useState(!1),[ie,B]=x.useState(null),Z=x.useRef({state:H});Cl(()=>{Z.current.state=H}),x.useEffect(()=>{if(n)B(null);else{const j=I(U);B(()=>j)}},[n,U,I]);const G=(w=a?.coarse)!==null&&w!==void 0?w:15,re=(y=a?.fine)!==null&&y!==void 0?y:5;x.useEffect(()=>{if(n||ie==null)return;const j=_.current;Tt(j,"Element ref not attached");let V=!1;return c_e(U,j,R,{coarse:G,fine:re},(L,$,F)=>{if(!$){K("inactive");return}switch(L){case"down":{K("drag"),V=!1,Tt(F,'Expected event to be defined for "down" action'),A(U,F);const{onDragging:W,onPointerDown:X}=E.current;W?.(!0),X?.();break}case"move":{const{state:W}=Z.current;V=!0,W!=="drag"&&K("hover"),Tt(F,'Expected event to be defined for "move" action'),ie(F);break}case"up":{K("hover"),O();const{onClick:W,onDragging:X,onPointerUp:ae}=E.current;X?.(!1),ae?.(),V||W?.();break}}})},[G,R,n,re,I,U,ie,A,O]),k_e({disabled:n,handleId:U,resizeHandler:ie,panelGroupElement:M});const ne={touchAction:"none",userSelect:"none"};return x.createElement(v,{...S,children:e,className:t,id:r,onBlur:()=>{J(!1),i?.()},onFocus:()=>{J(!0),u?.()},ref:_,role:"separator",style:{...ne,...h},tabIndex:g,[Wn.groupDirection]:R,[Wn.groupId]:C,[Wn.resizeHandle]:"",[Wn.resizeHandleActive]:H==="drag"?"pointer":ee?"keyboard":void 0,[Wn.resizeHandleEnabled]:!n,[Wn.resizeHandleId]:U,[Wn.resizeHandleState]:H})}YK.displayName="PanelResizeHandle";function Jr({className:e,...t}){return f.jsx(ZK,{"data-slot":"resizable-panel-group",className:De("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...t})}function Rn({...e}){return f.jsx(AK,{"data-slot":"resizable-panel",...e})}function bi({withHandle:e,className:t,...n}){return f.jsx(YK,{"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&&f.jsx("div",{className:"bg-border z-10 flex h-4 w-3 items-center justify-center rounded-xs border",children:f.jsx(ppe,{className:"size-2.5"})})})}function gm({className:e,...t}){return f.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 T_e({isSearchExpanded:e,searchQuery:t,filteredNotificationsCount:n,notificationsCount:a,onSearchExpand:r,onSearchChange:i,onSearchBlur:s,onClearAll:c,searchInputRef:u}){return f.jsxs("div",{className:"flex flex-row items-center justify-between p-4 sm:p-4 py-3 gap-2",children:[f.jsx("div",{className:"flex items-center gap-2 flex-1",children:e?f.jsx(kn,{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"}):f.jsxs(f.Fragment,{children:[f.jsx("h2",{className:"text-lg font-medium text-gray-900 dark:text-gray-100",children:"Notifications"}),f.jsx(xr,{className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",variant:"outline",children:n}),f.jsxs($t,{children:[f.jsx(Mt,{asChild:!0,children:f.jsx(je,{variant:"ghost",size:"sm",onClick:r,className:"h-8 w-8 p-0",children:f.jsx(sd,{className:"h-4 w-4"})})}),f.jsxs(Pt,{side:"bottom",className:"flex gap-2",children:["Search",f.jsx(gm,{children:"F"})]})]})]})}),f.jsx("div",{className:"flex items-center gap-2",children:f.jsxs($t,{children:[f.jsx(Mt,{asChild:!0,children:f.jsx(je,{variant:"ghost",size:"sm",onClick:c,disabled:a===0,className:"h-8 w-8 p-0",children:f.jsx(Os,{className:"h-4 w-4"})})}),f.jsx(Pt,{side:"bottom",children:"Clear all"})]})})]})}function Vs({id:e,isSelected:t,isFocused:n,icon:a,title:r,description:i,metadata:s,onClick:c,className:u}){return f.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:f.jsxs("div",{className:"flex items-start gap-2 sm:gap-3",children:[a&&f.jsx("div",{className:"flex-shrink-0 mt-1",children:f.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})}),f.jsxs("div",{className:"flex-1 min-w-0",children:[f.jsx("div",{className:"flex items-center gap-2 mb-1",children:f.jsx("h3",{className:De("font-medium truncate font-mono text-sm"),children:r})}),i&&f.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 line-clamp-2",children:i})]})]})})}function N_e({notifications:e,selectedNotification:t,onNotificationSelect:n,focusedIndex:a,formatRelativeTime:r,listRef:i}){return e.length===0?f.jsx("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:f.jsx(od,{vertical:!0,noBorder:!0,message:"No notifications yet"})}):f.jsx("div",{ref:i,className:"overflow-y-auto flex-1 overscroll-contain",children:e.map((s,c)=>f.jsx(Vs,{id:`notification-${s.id}`,isSelected:t?.id===s.id,isFocused:a===c,title:f.jsxs("span",{className:"flex items-center gap-3",children:[s.method,!s.read&&f.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 C_e({notification:e,previewMode:t,onTogglePreview:n,onCopy:a,onDownload:r,onFullscreen:i,isCopied:s=!1,onClose:c}){return e?f.jsxs("div",{className:"flex flex-col h-full",children:[f.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:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx(Pu,{className:"h-3 w-3 text-gray-400"}),f.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:new Date(e.timestamp).toLocaleTimeString()})]}),f.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:e.formatRelativeTime(e.timestamp)})]}),f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsxs(je,{variant:"ghost",size:"sm",onClick:n,className:t?"":"text-purple-600 dark:text-purple-400",children:[t?f.jsx(B9,{className:"h-4 w-4 mr-1"}):f.jsx(F9,{className:"h-4 w-4 mr-1"}),t?"JSON":"Formatted"]}),f.jsx(je,{variant:"ghost",size:"sm",onClick:a,children:s?f.jsx(ga,{className:"h-4 w-4"}):f.jsx(Br,{className:"h-4 w-4"})}),f.jsx(je,{variant:"ghost",size:"sm",onClick:r,children:f.jsx(Qp,{className:"h-4 w-4"})}),f.jsx(je,{variant:"ghost",size:"sm",onClick:i,children:f.jsx(oN,{className:"h-4 w-4"})}),c&&f.jsx(je,{variant:"ghost",size:"sm",onClick:c,children:f.jsx(Wi,{className:"h-4 w-4"})})]})]}),f.jsx("div",{className:"flex-1 overflow-y-auto",children:f.jsx("div",{className:"px-4 pt-4",children:f.jsx(Jn,{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`})})})]}):f.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[f.jsx(nN,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),f.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"Select a notification to view details"})]})}function hv(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 R_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,S]=x.useState(!0),[w,y]=x.useState(!1),[_,E]=x.useState(!0),[k,R]=x.useState(!1),C=x.useRef(null),I=x.useRef(null),A=x.useRef(null),O=x.useRef(!1);x.useEffect(()=>{v&&e.length>0&&C.current&&!O.current&&(C.current.scrollTop=0)},[e.length,v]),x.useEffect(()=>{const Z=C.current;if(!Z)return;const G=()=>{Z.scrollTop>0&&(O.current=!0,S(!1))};return Z.addEventListener("scroll",G),()=>Z.removeEventListener("scroll",G)},[]),x.useEffect(()=>{e.length===0&&(O.current=!1,S(!0))},[e.length]),x.useEffect(()=>{c&&!c.read&&n(c.id)},[c,n]),x.useEffect(()=>{w&&A.current&&A.current.focus()},[w]);const M=x.useCallback(()=>{d.trim()||y(!1)},[d]),U=x.useMemo(()=>{if(!d.trim())return e;const Z=d.toLowerCase();return e.filter(G=>G.method.toLowerCase().includes(Z)||JSON.stringify(G.params||{}).toLowerCase().includes(Z))},[e,d]);x.useEffect(()=>{g(-1)},[d]),x.useEffect(()=>{const Z=G=>{const re=G.target;if(re.tagName==="INPUT"||re.tagName==="TEXTAREA"||re.contentEditable==="true"||G.metaKey||G.ctrlKey||G.altKey)return;const j=U;if(G.key==="ArrowDown")G.preventDefault(),g(V=>{const z=V+1;return z>=j.length?0:z});else if(G.key==="ArrowUp")G.preventDefault(),g(V=>{const z=V-1;return z<0?j.length-1:z});else if(G.key==="Enter"&&h>=0){G.preventDefault();const V=U[h];V&&H(V)}};return document.addEventListener("keydown",Z),()=>document.removeEventListener("keydown",Z)},[h,U]),x.useEffect(()=>{if(h>=0){const Z=`notification-${U[h]?.id}`,G=document.getElementById(Z);G&&G.scrollIntoView({behavior:"smooth",block:"nearest"})}},[h,U]);const H=x.useCallback(Z=>{u(Z)},[]),K=x.useCallback(()=>{window.confirm("Are you sure you want to clear all notifications? This cannot be undone.")&&(r(),u(null))},[r]),ee=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)),R(!0),setTimeout(()=>R(!1),2e3)}catch(Z){console.error("[NotificationsTab] Failed to copy notification:",Z)}},[c]),J=x.useCallback(()=>{if(c)try{const Z=new globalThis.Blob([JSON.stringify({method:c.method,timestamp:c.timestamp,read:c.read,params:c.params},null,2)],{type:"application/json"}),G=URL.createObjectURL(Z),re=document.createElement("a");re.href=G,re.download=`notification-${Date.now()}.json`,document.body.appendChild(re),re.click(),document.body.removeChild(re),URL.revokeObjectURL(G)}catch(Z){console.error("[NotificationsTab] Failed to download notification:",Z)}},[c]),ie=x.useCallback(async()=>{if(I.current)try{document.fullscreenElement?await document.exitFullscreen():await I.current.requestFullscreen()}catch(Z){console.error("[NotificationsTab] Failed to toggle fullscreen:",Z)}},[]),B=c?{method:c.method,params:c.params,timestamp:c.timestamp,read:c.read,formatRelativeTime:hv}:null;return s?f.jsxs(Jr,{direction:"horizontal",className:"h-full",children:[f.jsx(Rn,{defaultSize:40,minSize:30,children:f.jsx(Jr,{direction:"vertical",className:"h-full border-r dark:border-zinc-700",children:f.jsxs(Rn,{defaultSize:75,minSize:30,children:[f.jsx(T_e,{isSearchExpanded:w,searchQuery:d,filteredNotificationsCount:U.length,notificationsCount:e.length,onSearchExpand:()=>y(!0),onSearchChange:m,onSearchBlur:M,onClearAll:K,searchInputRef:A}),f.jsx("div",{className:"flex flex-col h-full",children:f.jsx(N_e,{notifications:U,selectedNotification:c,onNotificationSelect:H,focusedIndex:h,formatRelativeTime:hv,listRef:C})})]})})}),f.jsx(bi,{}),f.jsx(Rn,{defaultSize:60,minSize:40,children:f.jsx("div",{ref:I,className:"h-full bg-white dark:bg-zinc-900",children:f.jsx(C_e,{notification:B,previewMode:_,onTogglePreview:()=>E(!_),onCopy:ee,onDownload:J,onFullscreen:ie,onClose:()=>u(null),isCopied:k})})})]}):f.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[f.jsx(nN,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),f.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"Not connected to server"})]})}function qK({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:S,primaryTabName:w}){const y=e===w;return f.jsxs("div",{className:"flex flex-row items-center justify-between p-4 sm:p-4 py-3 gap-2",children:[f.jsx("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:t?f.jsx(kn,{ref:S,placeholder:d,value:n,onChange:_=>h(_.target.value),onBlur:g,className:"h-8 border-gray-300 dark:border-zinc-600"}):f.jsxs(f.Fragment,{children:[f.jsx("h2",{className:"text-lg font-medium text-gray-900 dark:text-gray-100",children:y?a:r}),y&&f.jsxs(f.Fragment,{children:[f.jsx(xr,{className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",variant:"outline",children:i}),f.jsxs($t,{children:[f.jsx(Mt,{asChild:!0,children:f.jsx(je,{variant:"ghost",size:"sm",onClick:m,className:"h-8 w-8 p-0",children:f.jsx(sd,{className:"h-4 w-4"})})}),f.jsxs(Pt,{side:"bottom",className:"flex gap-2",children:["Search",f.jsx(gm,{children:"F"})]})]})]})]})}),f.jsxs(je,{variant:"ghost",size:"sm",onClick:v,className:"gap-2 flex-shrink-0",children:[y?f.jsx(c,{}):f.jsx(u,{}),f.jsx("span",{className:"hidden sm:inline",children:y?r:a}),y&&s>0&&f.jsx(xr,{className:"bg-purple-500/20 text-purple-600 dark:text-purple-400 border-transparent",variant:"outline",children:s})]})]})}function z4({prompts:e,selectedPrompt:t,onPromptSelect:n,focusedIndex:a}){return e.length===0?f.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[f.jsx(lp,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),f.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"No prompts available"})]}):f.jsx("div",{className:"overflow-y-auto flex-1 border-r dark:border-zinc-700 overscroll-contain",children:e.map((r,i)=>f.jsx(Vs,{id:`prompt-${r.name}`,isSelected:t?.name===r.name,isFocused:a===i,icon:f.jsx(lp,{className:"h-4 w-4"}),title:r.name,description:r.description,metadata:r.arguments&&r.arguments.length>0&&f.jsxs(xr,{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 F4({activeTab:e,isSearchExpanded:t,searchQuery:n,filteredPromptsCount:a,savedPromptsCount:r,onSearchExpand:i,onSearchChange:s,onSearchBlur:c,onTabSwitch:u,searchInputRef:d}){return f.jsx(qK,{activeTab:e,isSearchExpanded:t,searchQuery:n,primaryTabName:"prompts",secondaryTabName:"saved",primaryTabTitle:"Prompts",secondaryTabTitle:"History",primaryCount:a,secondaryCount:r,primaryIcon:lp,secondaryIcon:Pu,searchPlaceholder:"Search prompts...",onSearchExpand:i,onSearchChange:s,onSearchBlur:c,onTabSwitch:u,searchInputRef:d})}function B4({savedPrompts:e,selectedPrompt:t,onLoadPrompt:n,onDeletePrompt:a,focusedIndex:r}){return e.length===0?f.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[f.jsx(Pu,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),f.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"No history"}),f.jsx("p",{className:"text-sm text-gray-400 dark:text-gray-500 mt-1",children:"Prompts you execute will appear here"})]}):f.jsx("div",{className:"overflow-y-auto flex-1 border-r dark:border-zinc-700 overscroll-contain",children:e.map((i,s)=>f.jsx(Vs,{id:`saved-prompt-${i.id}`,isSelected:t?.id===i.id,isFocused:r===s,icon:f.jsx(Pu,{className:"h-4 w-4"}),title:i.name,description:`${i.promptName} - ${new Date(i.savedAt).toLocaleString()}`,onClick:()=>n(i)},i.id))})}function A_e({selectedPrompt:e,promptArgs:t,onArgChange:n}){const a=e?.arguments||[];if(!(a.length>0))return f.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"?f.jsxs("div",{className:"space-y-2",children:[f.jsxs(Kt,{htmlFor:c,className:"text-sm font-medium",children:[c,s.required&&f.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),f.jsxs("div",{className:"flex items-center space-x-2",children:[f.jsx("input",{id:c,type:"checkbox",checked:!!u,onChange:m=>n(c,m.target.checked),className:"rounded","aria-label":`Toggle ${c}`}),f.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:s.description})]})]},c):s.type==="number"?f.jsxs("div",{className:"space-y-2",children:[f.jsxs(Kt,{htmlFor:c,className:"text-sm font-medium",children:[c,s.required&&f.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),f.jsx(kn,{id:c,type:"number",value:Number(u)||0,onChange:m=>n(c,Number(m.target.value)),placeholder:s.description||`Enter ${c}`}),s.description&&f.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:s.description})]},c):s.type==="array"||s.type==="object"?f.jsxs("div",{className:"space-y-2",children:[f.jsxs(Kt,{htmlFor:c,className:"text-sm font-medium",children:[c,s.required&&f.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),f.jsx(zl,{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&&f.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:s.description})]},c):f.jsxs("div",{className:"space-y-2",children:[f.jsxs(Kt,{htmlFor:c,className:"text-sm font-medium",children:[c,s.required&&f.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),f.jsx(kn,{id:c,value:d,onChange:m=>n(c,m.target.value),placeholder:s.description||`Enter ${c}`}),s.description&&f.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:s.description})]},c)};return f.jsx("div",{className:"space-y-4",children:a.map(s=>i(s))})}function H4({selectedPrompt:e,promptArgs:t,isExecuting:n,isConnected:a,onArgChange:r,onExecute:i,onSave:s}){return e?f.jsxs("div",{className:"flex flex-col h-full",children:[f.jsx("div",{className:"flex-shrink-0 p-3 sm:p-6 pt-3 pb-4 pr-3",children:f.jsxs("div",{children:[f.jsxs("div",{className:"flex flex-row items-center justify-between mb-0 gap-2",children:[f.jsx("h3",{className:"text-base sm:text-lg font-semibold",children:e.name}),f.jsxs("div",{className:"flex gap-2 flex-shrink-0",children:[f.jsx(je,{onClick:i,disabled:n||!a,size:"sm",className:"lg:size-default",children:n?f.jsxs(f.Fragment,{children:[f.jsx(Hi,{className:"mr-2"}),f.jsx("span",{className:"hidden sm:inline",children:"Executing..."})]}):f.jsxs(f.Fragment,{children:[f.jsx(W9,{className:"h-4 w-4 sm:mr-2"}),f.jsx("span",{className:"hidden sm:inline",children:"Execute"})]})}),f.jsxs(je,{variant:"outline",onClick:s,disabled:n,size:"sm",className:"lg:size-default gap-2",children:[f.jsx(sN,{className:"h-4 w-4"}),f.jsx("span",{className:"hidden sm:inline",children:"Save"})]})]})]}),e.description&&f.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 leading-relaxed mt-2",children:e.description})]})}),f.jsx("div",{className:"flex-1 overflow-y-auto px-3 sm:px-6 pb-4 pr-3",children:f.jsx(A_e,{selectedPrompt:e,promptArgs:t,onArgChange:r})})]}):f.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[f.jsx("p",{className:"text-gray-500 dark:text-gray-400 mb-2",children:"Select a prompt to get started"}),f.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 V4({results:e,copiedResult:t,onCopy:n}){return f.jsx("div",{className:"flex flex-col h-full bg-white dark:bg-black border-t dark:border-zinc-700",children:f.jsx("div",{className:"flex-1 overflow-y-auto h-full",children:e.length>0?f.jsx("div",{className:"space-y-4 flex-1 h-full",children:e.map((a,r)=>f.jsxs("div",{className:"space-y-0 flex-1 h-full flex flex-col",children:[f.jsxs("div",{className:"flex items-center gap-2 px-4 pt-2 border-b border-gray-200 dark:border-zinc-600 pb-2",children:[f.jsx("h3",{className:"text-sm font-medium",children:"Response"}),f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx(Pu,{className:"h-3 w-3 text-gray-400"}),f.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:new Date(a.timestamp).toLocaleTimeString()})]}),a.duration!==void 0&&f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx(cp,{className:"h-3 w-3 text-gray-400"}),f.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:[a.duration,"ms"]})]}),f.jsx("div",{className:"flex gap-2 ml-auto",children:f.jsx(je,{variant:"ghost",size:"sm",onClick:()=>n(r,a.result),className:"h-6 px-2",children:t===r?f.jsx(ga,{className:"h-4 w-4"}):f.jsx(Br,{className:"h-4 w-4"})})})]}),a.error?f.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:[f.jsx("p",{className:"text-red-800 dark:text-red-300 font-medium",children:"Error:"}),f.jsx("p",{className:"text-red-700 dark:text-red-400 text-sm",children:a.error})]}):f.jsx("div",{className:"px-4 pt-4",children:f.jsx(Jn,{data:a.result,filename:`prompt-result-${a.promptName}-${Date.now()}.json`})})]},r))}):f.jsx("div",{className:"flex items-center justify-center h-full",children:f.jsx("div",{className:"text-center",children:f.jsx(od,{vertical:!0,noBorder:!0,message:"No Results yet"})})})})})}function IO({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(S=>{const w=new Set(S);return w.has(v)?w.delete(v):w.add(v),w})},m=async()=>{r([]),c(new Set),t?.(0);try{const v=new URLSearchParams;e&&e.length>0&&v.set("serverIds",e.join(","));const S=await fetch(`/inspector/api/rpc/log?${v.toString()}`,{method:"DELETE"});S.ok||console.warn("[RPC Logger] Failed to clear server buffer:",S.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 S=new URLSearchParams;S.set("replay","3"),S.set("_t",Date.now().toString()),e&&e.length>0&&S.set("serverIds",e.join(","));const w=`/inspector/api/rpc/stream?${S.toString()}`;console.log("[RPC Logger] Connecting to SSE stream:",w),v=new globalThis.EventSource(w),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:R,timestamp:C}=_,I=R,A=typeof I?.method=="string"?I.method:I?.result!==void 0?"result":I?.error!==void 0?"error":"unknown",O={id:`${C??Date.now()}-${Math.random().toString(36).slice(2)}`,serverId:typeof E=="string"?E:"unknown",direction:typeof k=="string"?k.toUpperCase():"",method:A,timestamp:C??new Date().toISOString(),payload:R};console.log("[RPC Logger] Received RPC event:",{method:A,direction:k,serverId:E}),r(M=>{const U=[O,...M].slice(0,1e3);return t?.(U.length),U})}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(S){console.error("[RPC Logger] Failed to create SSE connection:",S)}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 S=new Set(e);v=v.filter(w=>S.has(w.serverId))}if(u.trim()){const S=u.toLowerCase();v=v.filter(w=>w.serverId.toLowerCase().includes(S)||w.method.toLowerCase().includes(S)||w.direction.toLowerCase().includes(S)||JSON.stringify(w.payload).toLowerCase().includes(S))}return v},[a,u,e]);return f.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:f.jsx("div",{ref:i,className:"flex-1 min-h-0 overflow-y-auto",children:g.length===0?f.jsxs("div",{className:"text-center py-8",children:[f.jsx("div",{className:"text-xs text-muted-foreground",children:"No messages yet"}),f.jsx("div",{className:"text-[10px] text-muted-foreground mt-1",children:"JSON-RPC messages will appear here"})]}):g.map(v=>{const S=s.has(v.id);return f.jsxs("div",{className:"group hover:bg-muted/50 transition-all duration-200 overflow-hidden",children:[f.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:[f.jsx("div",{className:"flex-shrink-0",children:S?f.jsx(Kl,{className:"h-3 w-3 text-muted-foreground transition-transform"}):f.jsx(jfe,{className:"h-3 w-3 text-muted-foreground transition-transform"})}),f.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[f.jsx("span",{className:"text-muted-foreground font-mono text-xs",children:new Date(v.timestamp).toLocaleTimeString()}),f.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"?f.jsx(Sfe,{className:"h-3 w-3"}):f.jsx(_fe,{className:"h-3 w-3"})}),f.jsx("span",{className:"text-xs font-mono text-foreground truncate",children:v.method})]})]}),S&&f.jsx("div",{className:"border-t bg-muted/20",children:f.jsx("div",{className:"p-3",children:f.jsx("div",{className:"max-h-[40vh] overflow-auto rounded-sm bg-background/60 p-2",children:f.jsx(Jn,{data:v.payload})})})})]},v.id)})})})}const G4="mcp-inspector-saved-prompts";function XK({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}=Zl(),[h,g]=x.useState({}),[v,S]=x.useState([]),[w,y]=x.useState(!1),[_,E]=x.useState(null),[k,R]=x.useState(""),[C,I]=x.useState("prompts"),[A,O]=x.useState([]),[M,U]=x.useState(!1),[H,K]=x.useState(""),[ee,J]=x.useState(!1),[ie,B]=x.useState(-1),Z=x.useRef(null),[G,re]=x.useState(!1),[ne,j]=x.useState("list"),[V,z]=x.useState(0),[L,$]=x.useState(!0),F=x.useRef(null),W=x.useRef(null);x.useEffect(()=>{const Se=()=>{re(window.innerWidth<1024)};return Se(),window.addEventListener("resize",Se),()=>window.removeEventListener("resize",Se)},[]),x.useEffect(()=>{j(i?"detail":"list")},[i]),x.useEffect(()=>{G&&v.length>0&&!w&&j("response")},[v,w,G]),x.useImperativeHandle(e,()=>({focusSearch:()=>{J(!0),setTimeout(()=>{Z.current&&Z.current.focus()},0)},blurSearch:()=>{R(""),J(!1),Z.current&&Z.current.blur()}})),x.useEffect(()=>{try{const Se=localStorage.getItem(G4);if(Se){const _e=JSON.parse(Se);O(_e)}}catch(Se){console.error("[PromptsTab] Failed to load saved prompts:",Se)}},[]);const X=x.useCallback(Se=>{try{localStorage.setItem(G4,JSON.stringify(Se))}catch(_e){console.error("[PromptsTab] Failed to save prompts:",_e)}},[]);x.useEffect(()=>{ee&&Z.current&&Z.current.focus()},[ee]);const ae=x.useCallback(()=>{k.trim()||J(!1)},[k]),le=x.useMemo(()=>{if(!k.trim())return t;const Se=k.toLowerCase();return t.filter(_e=>_e.name.toLowerCase().includes(Se)||_e.description?.toLowerCase().includes(Se))},[t,k]),Q=x.useCallback(Se=>{s(Se);const _e={};Se.arguments&&Se.arguments.forEach(Ue=>{Ue.default!==void 0?_e[Ue.name]=Ue.default:Ue.type==="string"?_e[Ue.name]="":Ue.type==="number"?_e[Ue.name]=0:Ue.type==="boolean"?_e[Ue.name]=!1:Ue.type==="array"?_e[Ue.name]=[]:Ue.type==="object"&&(_e[Ue.name]={})}),g(_e)},[]),q=x.useCallback(Se=>{const _e=t.find(Ue=>Ue.name===Se.promptName);_e&&(s(_e),g(Se.args),u(Se))},[t]);x.useEffect(()=>{B(-1)},[k,C]),x.useEffect(()=>{const Se=_e=>{const Ue=_e.target;if(Ue.tagName==="INPUT"||Ue.tagName==="TEXTAREA"||Ue.contentEditable==="true"||_e.metaKey||_e.ctrlKey||_e.altKey)return;const Ie=C==="prompts"?le:A;if(_e.key==="ArrowDown")_e.preventDefault(),B(Fe=>{const xe=Fe+1;return xe>=Ie.length?0:xe});else if(_e.key==="ArrowUp")_e.preventDefault(),B(Fe=>{const xe=Fe-1;return xe<0?Ie.length-1:xe});else if(_e.key==="Enter"&&ie>=0)if(_e.preventDefault(),C==="prompts"){const Fe=le[ie];Fe&&Q(Fe)}else{const Fe=A[ie];Fe&&q(Fe)}};return document.addEventListener("keydown",Se),()=>document.removeEventListener("keydown",Se)},[ie,le,A,C,Q,q]),x.useEffect(()=>{if(ie>=0){const Se=C==="prompts"?`prompt-${le[ie]?.name}`:`saved-prompt-${A[ie]?.id}`,_e=document.getElementById(Se);_e&&_e.scrollIntoView({behavior:"smooth",block:"nearest"})}},[ie,le,A,C]),x.useEffect(()=>{if(console.warn("[PromptsTab] Auto-selection effect triggered:",{selectedPromptName:d,promptsCount:t.length,currentSelectedPrompt:i?.name}),d&&t.length>0){const Se=t.find(_e=>_e.name===d);if(console.warn("[PromptsTab] Prompt lookup result:",{selectedPromptName:d,promptFound:!!Se,promptName:Se?.name,shouldSelect:Se&&i?.name!==Se.name}),Se&&i?.name!==Se.name){console.warn("[PromptsTab] Selecting prompt:",Se.name),m(null);const _e=setTimeout(()=>{Q(Se);const Ue=document.getElementById(`prompt-${Se.name}`);Ue&&(console.warn("[PromptsTab] Scrolling to prompt element"),Ue.scrollIntoView({behavior:"smooth",block:"nearest"}))},100);return()=>clearTimeout(_e)}}},[d,t,i,Q,m]);const se=x.useCallback((Se,_e)=>{g(Ue=>({...Ue,[Se]:_e}))},[]),he=x.useCallback(async()=>{if(!i||w)return;y(!0);const Se=Date.now();try{const _e=await n(i.name,h),Ue=Date.now()-Se;yr.getInstance().capture(new oU({promptName:i.name,serverId:a,success:!0})).catch(()=>{}),S(Ie=>[{promptName:i.name,args:h,result:_e,timestamp:Se,duration:Ue},...Ie])}catch(_e){yr.getInstance().capture(new oU({promptName:i.name,serverId:a,success:!1,error:_e instanceof Error?_e.message:"Unknown error"})).catch(()=>{});const fe={promptName:i.name,args:h,result:null,error:_e instanceof Error?_e.message:String(_e),timestamp:Se,duration:Date.now()-Se};S(Ie=>[fe,...Ie])}finally{y(!1)}},[i,h,w,n,a]),ce=x.useCallback(async(Se,_e)=>{try{await navigator.clipboard.writeText(JSON.stringify(_e,null,2)),E(Se),setTimeout(()=>E(null),2e3)}catch(Ue){console.error("[PromptsTab] Failed to copy result:",Ue)}},[]),ke=x.useCallback(()=>{i&&(K(""),U(!0))},[i]),He=x.useCallback(Se=>{X(A.filter(_e=>_e.id!==Se)),c?.id===Se&&u(null)},[A,X,c]);return G?f.jsxs("div",{className:"h-full flex flex-col overflow-hidden relative bg-background",children:[ne!=="list"&&f.jsxs("div",{className:"flex items-center gap-2 p-2 border-b shrink-0 bg-background z-10",children:[f.jsx(je,{variant:"ghost",size:"sm",onClick:()=>{ne==="response"?j("detail"):(s(null),j("list"))},className:"p-0 h-8 w-8",children:f.jsx(rN,{className:"h-4 w-4"})}),f.jsxs("div",{className:"flex items-center text-sm font-medium",children:[f.jsx("button",{onClick:()=>{s(null),j("list")},className:"text-muted-foreground hover:text-foreground hover:underline cursor-pointer",children:"Prompts"}),ne!=="list"&&f.jsxs(f.Fragment,{children:[f.jsx("span",{className:"mx-2 text-muted-foreground",children:"/"}),f.jsx("button",{onClick:()=>{ne==="response"&&j("detail")},className:ne==="detail"?"text-foreground hover:underline":ne==="response"?"text-muted-foreground hover:text-foreground hover:underline cursor-pointer":"text-muted-foreground",children:"Execute"})]}),ne==="response"&&f.jsxs(f.Fragment,{children:[f.jsx("span",{className:"mx-2 text-muted-foreground",children:"/"}),f.jsx("span",{className:"text-foreground",children:"Response"})]})]})]}),f.jsx("div",{className:"flex-1 relative overflow-hidden",children:f.jsxs(py,{initial:!1,mode:"popLayout",children:[ne==="list"&&f.jsxs(ha.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:[f.jsx(F4,{activeTab:C,isSearchExpanded:ee,searchQuery:k,filteredPromptsCount:le.length,savedPromptsCount:A.length,onSearchExpand:()=>J(!0),onSearchChange:R,onSearchBlur:ae,onTabSwitch:()=>I(C==="prompts"?"saved":"prompts"),searchInputRef:Z}),C==="prompts"?f.jsx(z4,{prompts:le,selectedPrompt:i,onPromptSelect:Q,focusedIndex:ie}):f.jsx(B4,{savedPrompts:A,selectedPrompt:c,onLoadPrompt:q,onDeletePrompt:He,focusedIndex:ie})]},"list"),ne==="detail"&&f.jsx(ha.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:f.jsx(H4,{selectedPrompt:i,promptArgs:h,isExecuting:w,isConnected:r,onArgChange:se,onExecute:he,onSave:ke})},"detail"),ne==="response"&&f.jsx(ha.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:f.jsx(V4,{results:v,copiedResult:_,onCopy:ce})},"response")]})})]}):f.jsxs(Jr,{direction:"horizontal",className:"h-full",children:[f.jsx(Rn,{defaultSize:33,className:"flex flex-col h-full relative",children:f.jsxs(Jr,{direction:"vertical",className:"h-full border-r dark:border-zinc-700",children:[f.jsx(Rn,{defaultSize:75,minSize:30,children:f.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[f.jsx(F4,{activeTab:C,isSearchExpanded:ee,searchQuery:k,filteredPromptsCount:le.length,savedPromptsCount:A.length,onSearchExpand:()=>J(!0),onSearchChange:R,onSearchBlur:ae,onTabSwitch:()=>I(C==="prompts"?"saved":"prompts"),searchInputRef:Z}),C==="prompts"?f.jsx(z4,{prompts:le,selectedPrompt:i,onPromptSelect:Q,focusedIndex:ie}):f.jsx(B4,{savedPrompts:A,selectedPrompt:c,onLoadPrompt:q,onDeletePrompt:He,focusedIndex:ie})]})}),f.jsx(bi,{withHandle:!0}),f.jsxs(Rn,{ref:F,defaultSize:0,collapsible:!0,minSize:5,collapsedSize:5,onCollapse:()=>$(!0),onExpand:()=>$(!1),className:"flex flex-col border-t dark:border-zinc-700",children:[f.jsxs("div",{className:"group flex items-center justify-between p-3 shrink-0 cursor-pointer hover:bg-muted/50 transition-colors",onClick:Se=>{Se.preventDefault(),Se.stopPropagation(),L?(F.current?.resize(25),$(!1)):(F.current?.resize(5),$(!0))},children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("h3",{className:"text-sm font-medium",children:"RPC Messages"}),V>0&&f.jsx(xr,{variant:"secondary",className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",children:V}),V>0&&!L&&f.jsx(je,{variant:"ghost",size:"sm",onClick:Se=>{Se.preventDefault(),Se.stopPropagation(),W.current?.()},className:"h-6 w-6 p-0",title:"Clear all messages",children:f.jsx(Os,{className:"h-3.5 w-3.5"})})]}),f.jsx(Kl,{className:`h-4 w-4 text-muted-foreground transition-transform ${L?"rotate-180":""}`})]}),!L&&f.jsx("div",{className:"flex-1 overflow-hidden min-h-0",children:f.jsx(IO,{serverIds:[a],onCountChange:z,onClearRef:W})})]})]})}),f.jsx(bi,{withHandle:!0}),f.jsx(Rn,{defaultSize:67,children:f.jsxs(Jr,{direction:"vertical",children:[f.jsx(Rn,{defaultSize:40,children:f.jsx(H4,{selectedPrompt:i,promptArgs:h,isExecuting:w,isConnected:r,onArgChange:se,onExecute:he,onSave:ke})}),f.jsx(bi,{withHandle:!0}),f.jsx(Rn,{defaultSize:50,children:f.jsx("div",{className:"flex flex-col h-full",children:f.jsx(V4,{results:v,copiedResult:_,onCopy:ce})})})]})})]})}XK.displayName="PromptsTab";function bu(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 I_e(e){return{uri:e.uri,mimeType:e.mimeType,text:e.text,blob:e.blob}}function JK({resource:e,onUIAction:t,className:n}){const a=async i=>t?.(i),r=I_e(e);return f.jsx("div",{className:n,children:f.jsx(NO,{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:[HEe,BEe,VEe,GEe],library:TO}})})}function W4({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(w=>w.startsWith("openai/")),h=e.resourceAnnotations["openai/outputTemplate"]),e?.result?.contents?.[0]?._meta){const w=e.result.contents[0]._meta,y=Object.keys(w).filter(_=>_.startsWith("openai/"));y.length>0&&(m=[...m,...y]),!h&&w["openai/outputTemplate"]&&(h=w["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 f.jsx("div",{className:"flex absolute left-0 top-0 items-center justify-center w-full h-full",children:f.jsx(Hi,{className:"size-5"})});if(!e)return f.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[f.jsx("p",{className:"text-gray-500 dark:text-gray-400 mb-2",children:"Select a resource to view its contents"}),f.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 f.jsx("div",{className:"p-4",children:f.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded p-3",children:[f.jsx("p",{className:"text-red-800 dark:text-red-300 font-medium",children:"Error:"}),f.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(w=>w.mimeType&&bu(w)),S=v?e.result.contents.filter(w=>w.mimeType&&bu(w)):[];return f.jsxs("div",{className:"flex flex-col h-full",children:[f.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:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx(Pu,{className:"h-3 w-3 text-gray-400"}),f.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:new Date(e.timestamp).toLocaleTimeString()})]}),(()=>{const w=e?.duration??e.result?.duration??e.result?.metrics?.durationMs;return w!==void 0?f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx(cp,{className:"h-3 w-3 text-gray-400"}),f.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:[w,"ms"]})]}):null})(),v&&f.jsx(xr,{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&&f.jsx(xr,{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"})]}),f.jsxs("div",{className:"flex items-center gap-1",children:[(v||g)&&f.jsxs(je,{variant:"ghost",size:"sm",onClick:i,className:n?"":"text-purple-600 dark:text-purple-400",children:[n?f.jsx(B9,{className:"h-4 w-4 mr-1"}):f.jsx(F9,{className:"h-4 w-4 mr-1"}),n?"JSON":g?"Component":"Preview"]}),f.jsx(je,{variant:"ghost",size:"sm",onClick:s,children:d?f.jsx(ga,{className:"h-4 w-4"}):f.jsx(Br,{className:"h-4 w-4"})}),f.jsx(je,{variant:"ghost",size:"sm",onClick:c,children:f.jsx(Qp,{className:"h-4 w-4"})}),f.jsx(je,{variant:"ghost",size:"sm",onClick:u,children:f.jsx(oN,{className:"h-4 w-4"})})]})]}),f.jsx("div",{className:"flex-1 overflow-y-auto",children:g&&a&&r&&h?n?f.jsx("div",{className:"flex-1 h-full",children:f.jsx(xO,{componentUrl:h,toolName:e.uri,toolArgs:{},toolResult:e.result,serverId:a,readResource:r,className:"w-full h-full relative flex p-4"})}):f.jsx("div",{className:"px-4 pt-4",children:f.jsx(Jn,{data:e.result,filename:`resource-${e.uri.replace(/[^a-zA-Z0-9]/g,"-")}-${Date.now()}.json`})}):v?n?f.jsxs("div",{className:"space-y-0 h-full",children:[S.map((w,y)=>f.jsx("div",{className:"mx-0 size-full",children:f.jsx("div",{className:"w-full h-full",children:f.jsx(JK,{resource:w,className:"w-full h-full"})})},`mcp-ui-${w.uri||`resource-${Date.now()}-${Math.random()}`}`)),(()=>{if(e.result.contents&&Array.isArray(e.result.contents)){const w=e.result.contents.filter(y=>!(y.mimeType&&bu(y)));if(w.length>0)return f.jsx("div",{className:"px-4",children:f.jsx(Jn,{data:w,filename:`resource-${e.uri.replace(/[^a-zA-Z0-9]/g,"-")}-non-ui-${Date.now()}.json`})})}return null})()]}):f.jsx("div",{className:"px-4 pt-4",children:f.jsx(Jn,{data:e.result,filename:`resource-${e.uri.replace(/[^a-zA-Z0-9]/g,"-")}-mcp-ui-${Date.now()}.json`})}):f.jsx("div",{className:"px-4 pt-4",children:f.jsx(Jn,{data:e.result,filename:`resource-${e.uri.replace(/[^a-zA-Z0-9]/g,"-")}-${Date.now()}.json`})})})]})}function O_e(e,t){if(!e&&!t)return f.jsx(spe,{className:"h-5 w-5"});const n=(e||t||"").toLowerCase();return n.includes("image")?f.jsx(ape,{className:"h-5 w-5"}):n.includes("json")||n.includes("javascript")||n.includes("typescript")?f.jsx(npe,{className:"h-5 w-5"}):n.includes("html")||n.includes("xml")?f.jsx(dpe,{className:"h-5 w-5"}):n.includes("database")||n.includes("sql")?f.jsx(sy,{className:"h-5 w-5"}):f.jsx(aN,{className:"h-5 w-5"})}function K4({resources:e,selectedResource:t,onResourceSelect:n,focusedIndex:a}){return e.length===0?f.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[f.jsx(sy,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),f.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"No resources available"})]}):f.jsx("div",{className:"overflow-y-auto flex-1 overscroll-contain",children:e.map((r,i)=>{const s=O_e(r.mimeType,r.uri),c=[r.description,r.mimeType&&f.jsx("span",{className:"font-mono",children:r.mimeType},"mime")].filter(Boolean);return f.jsx(Vs,{id:`resource-${r.uri}`,isSelected:t?.uri===r.uri,isFocused:a===i,icon:s,title:r.name,description:c.length>0?f.jsxs("span",{className:"flex flex-col gap-1",children:[r.description&&f.jsx("span",{children:r.description}),r.mimeType&&f.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 Z4({isSearchExpanded:e,searchQuery:t,filteredResourcesCount:n,onSearchExpand:a,onSearchChange:r,onSearchBlur:i,searchInputRef:s}){return f.jsx("div",{className:"flex flex-row items-center justify-between p-4 sm:p-4 py-3 gap-2",children:f.jsx("div",{className:"flex items-center gap-2 flex-1",children:e?f.jsx(kn,{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"}):f.jsxs(f.Fragment,{children:[f.jsx("h2",{className:"text-lg font-medium text-gray-900 dark:text-gray-100",children:"Resources"}),f.jsx(xr,{className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",variant:"outline",children:n}),f.jsxs($t,{children:[f.jsx(Mt,{asChild:!0,children:f.jsx(je,{variant:"ghost",size:"sm",onClick:a,className:"h-8 w-8 p-0",children:f.jsx(sd,{className:"h-4 w-4"})})}),f.jsxs(Pt,{side:"bottom",className:"flex gap-2",children:["Search",f.jsx(gm,{children:"F"})]})]})]})})})}function QK({ref:e,resources:t,readResource:n,serverId:a,isConnected:r}){const[i,s]=x.useState(null),{selectedResourceUri:c,setSelectedResourceUri:u}=Zl(),[d,m]=x.useState(null),[h,g]=x.useState(!1),[v,S]=x.useState(""),[w]=x.useState("resources"),[y,_]=x.useState(!0),[E,k]=x.useState(!1),[R,C]=x.useState(-1),[I,A]=x.useState(!1),O=x.useRef(null),M=x.useRef(null),[U,H]=x.useState(!1),[K,ee]=x.useState("list"),[J,ie]=x.useState(0),[B,Z]=x.useState(!0),G=x.useRef(null),re=x.useRef(null);x.useEffect(()=>{const F=()=>{H(window.innerWidth<1024)};return F(),window.addEventListener("resize",F),()=>window.removeEventListener("resize",F)},[]),x.useEffect(()=>{ee(i?"detail":"list")},[i]),x.useImperativeHandle(e,()=>({focusSearch:()=>{k(!0),setTimeout(()=>{O.current&&O.current.focus()},0)},blurSearch:()=>{S(""),k(!1),O.current&&O.current.blur()}})),x.useEffect(()=>{E&&O.current&&O.current.focus()},[E]);const ne=x.useCallback(()=>{v.trim()||k(!1)},[v]),j=x.useMemo(()=>{if(!v)return t;const F=v.toLowerCase();return t.filter(W=>W.name.toLowerCase().includes(F)||W.description?.toLowerCase().includes(F)||W.uri.toLowerCase().includes(F))},[t,v]),V=x.useCallback(async F=>{if(s(F),r){g(!0);const W=Date.now();try{const X=await n(F.uri);yr.getInstance().capture(new iU({resourceUri:F.uri,serverId:a,success:!0})).catch(()=>{}),m({uri:F.uri,result:X,timestamp:W,resourceAnnotations:F.annotations})}catch(X){yr.getInstance().capture(new iU({resourceUri:F.uri,serverId:a,success:!1,error:X instanceof Error?X.message:"Unknown error"})).catch(()=>{}),m({uri:F.uri,result:null,error:X instanceof Error?X.message:"Unknown error",timestamp:W,resourceAnnotations:F.annotations})}finally{g(!1)}}},[n,a,r]);x.useEffect(()=>{C(-1)},[v,w]),x.useEffect(()=>{const F=W=>{const X=W.target;if(X.tagName==="INPUT"||X.tagName==="TEXTAREA"||X.contentEditable==="true"||W.metaKey||W.ctrlKey||W.altKey)return;const le=j;if(W.key==="ArrowDown")W.preventDefault(),C(Q=>{const q=Q+1;return q>=le.length?0:q});else if(W.key==="ArrowUp")W.preventDefault(),C(Q=>{const q=Q-1;return q<0?le.length-1:q});else if(W.key==="Enter"&&R>=0){W.preventDefault();const Q=j[R];Q&&V(Q)}};return document.addEventListener("keydown",F),()=>document.removeEventListener("keydown",F)},[R,j,V]),x.useEffect(()=>{if(R>=0){const F=`resource-${j[R]?.uri}`,W=document.getElementById(F);W&&W.scrollIntoView({behavior:"smooth",block:"nearest"})}},[R,j]),x.useEffect(()=>{if(c&&t.length>0){const F=t.find(W=>W.uri===c);F&&i?.uri!==F.uri&&(u(null),setTimeout(()=>{V(F);const W=document.getElementById(`resource-${F.uri}`);W&&W.scrollIntoView({behavior:"smooth",block:"nearest"})},100))}},[c,t,i,V,u]);const z=x.useCallback(async()=>{if(d)try{await navigator.clipboard.writeText(JSON.stringify(d.result,null,2)),A(!0),setTimeout(()=>A(!1),2e3)}catch(F){console.error("[ResourcesTab] Failed to copy result:",F)}},[d]),L=x.useCallback(()=>{if(d)try{const F=new globalThis.Blob([JSON.stringify(d.result,null,2)],{type:"application/json"}),W=URL.createObjectURL(F),X=document.createElement("a");X.href=W,X.download=`resource-${Date.now()}.json`,document.body.appendChild(X),X.click(),document.body.removeChild(X),URL.revokeObjectURL(W)}catch(F){console.error("[ResourcesTab] Failed to download result:",F)}},[d]),$=x.useCallback(async()=>{if(M.current)try{document.fullscreenElement?await document.exitFullscreen():await M.current.requestFullscreen()}catch(F){console.error("[ResourcesTab] Failed to toggle fullscreen:",F)}},[]);return U?f.jsxs("div",{className:"h-full flex flex-col overflow-hidden relative bg-background",children:[K!=="list"&&f.jsxs("div",{className:"flex items-center gap-2 p-2 border-b shrink-0 bg-background z-10",children:[f.jsx(je,{variant:"ghost",size:"sm",onClick:()=>{s(null),ee("list")},className:"p-0 h-8 w-8",children:f.jsx(rN,{className:"h-4 w-4"})}),f.jsxs("div",{className:"flex items-center text-sm font-medium",children:[f.jsx("button",{onClick:()=>{s(null),ee("list")},className:"text-muted-foreground hover:text-foreground hover:underline cursor-pointer",children:"Resources"}),K==="detail"&&f.jsxs(f.Fragment,{children:[f.jsx("span",{className:"mx-2 text-muted-foreground",children:"/"}),f.jsx("span",{className:"text-foreground",children:"Content"})]})]})]}),f.jsx("div",{className:"flex-1 relative overflow-hidden",children:f.jsxs(py,{initial:!1,mode:"popLayout",children:[K==="list"&&f.jsxs(ha.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:[f.jsx(Z4,{activeTab:w,isSearchExpanded:E,searchQuery:v,filteredResourcesCount:j.length,onSearchExpand:()=>k(!0),onSearchChange:S,onSearchBlur:ne,onTabSwitch:()=>{},searchInputRef:O}),f.jsx("div",{className:"flex flex-col h-full",children:f.jsx(K4,{resources:j,selectedResource:i,onResourceSelect:V,focusedIndex:R})})]},"list"),K==="detail"&&f.jsx(ha.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:f.jsx("div",{ref:M,className:"h-full",children:f.jsx(W4,{result:d,isLoading:h,previewMode:y,serverId:a,readResource:n,onTogglePreview:()=>_(!y),onCopy:z,onDownload:L,onFullscreen:$,isCopied:I})})},"detail")]})})]}):f.jsxs(Jr,{direction:"horizontal",className:"h-full",children:[f.jsx(Rn,{defaultSize:25,children:f.jsxs(Jr,{direction:"vertical",className:"h-full border-r dark:border-zinc-700",children:[f.jsx(Rn,{defaultSize:75,minSize:30,children:f.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[f.jsx(Z4,{activeTab:w,isSearchExpanded:E,searchQuery:v,filteredResourcesCount:j.length,onSearchExpand:()=>k(!0),onSearchChange:S,onSearchBlur:ne,onTabSwitch:()=>{},searchInputRef:O}),f.jsx(K4,{resources:j,selectedResource:i,onResourceSelect:V,focusedIndex:R})]})}),f.jsx(bi,{withHandle:!0}),f.jsxs(Rn,{ref:G,defaultSize:0,collapsible:!0,minSize:5,collapsedSize:5,onCollapse:()=>Z(!0),onExpand:()=>Z(!1),className:"flex flex-col border-t dark:border-zinc-700",children:[f.jsxs("div",{className:"group flex items-center justify-between p-3 shrink-0 cursor-pointer hover:bg-muted/50 transition-colors",onClick:F=>{F.preventDefault(),F.stopPropagation(),B?(G.current?.resize(25),Z(!1)):(G.current?.resize(5),Z(!0))},children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("h3",{className:"text-sm font-medium",children:"RPC Messages"}),J>0&&f.jsx(xr,{variant:"secondary",className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",children:J}),J>0&&!B&&f.jsx(je,{variant:"ghost",size:"sm",onClick:F=>{F.preventDefault(),F.stopPropagation(),re.current?.()},className:"h-6 w-6 p-0",title:"Clear all messages",children:f.jsx(Os,{className:"h-3.5 w-3.5"})})]}),f.jsx(Kl,{className:`h-4 w-4 text-muted-foreground transition-transform ${B?"":"rotate-180"}`})]}),!B&&f.jsx("div",{className:"flex-1 overflow-hidden min-h-0",children:f.jsx(IO,{serverIds:[a],onCountChange:ie,onClearRef:re})})]})]})}),f.jsx(bi,{}),f.jsx(Rn,{defaultSize:50,children:f.jsx(Jr,{direction:"vertical",children:f.jsx(Rn,{defaultSize:70,children:f.jsx("div",{ref:M,className:"h-full bg-white dark:bg-zinc-900",children:f.jsx(W4,{result:d,isLoading:h,previewMode:y,serverId:a,readResource:n,onTogglePreview:()=>_(!y),onCopy:z,onDownload:L,onFullscreen:$,isCopied:I})})})})})]})}QK.displayName="ResourcesTab";function Y4({savedRequests:e,selectedRequest:t,onLoadRequest:n,onDeleteRequest:a,focusedIndex:r}){if(e.length===0)return f.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[f.jsx(sy,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),f.jsx("p",{className:"text-gray-500 dark:text-gray-400 mb-2",children:"No saved requests yet"}),f.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 f.jsx("div",{className:"overflow-y-auto flex-1 border-r dark:border-zinc-700 overscroll-contain",children:e.map((s,c)=>f.jsxs("div",{className:"relative group",children:[f.jsx(Vs,{id:`saved-${s.id}`,isSelected:t?.id===s.id,isFocused:r===c,icon:f.jsx(zb,{className:"h-4 w-4"}),title:s.name,description:s.toolName,metadata:f.jsx("div",{className:"flex flex-col gap-1",children:f.jsx("span",{className:"text-xs text-gray-400 dark:text-gray-500",children:new Date(s.savedAt).toLocaleString()})}),onClick:()=>n(s)}),f.jsx("div",{className:"absolute top-1/2 right-2 -translate-y-1/2 opacity-0 group-hover:opacity-100 transition-opacity z-10",children:f.jsxs($t,{children:[f.jsx(Mt,{asChild:!0,children:f.jsx(je,{variant:"secondary",size:"sm",onClick:u=>i(u,()=>a(s.id)),className:"h-8 w-8 p-0",children:f.jsx(Os,{className:"h-4 w-4"})})}),f.jsx(Pt,{children:f.jsx("p",{children:"Delete saved request"})})]})})]},s.id))})}function q4({isOpen:e,requestName:t,defaultPlaceholder:n,onRequestNameChange:a,onSave:r,onCancel:i}){return e?f.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:i,children:f.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:[f.jsx("h3",{className:"text-lg font-semibold mb-4 text-gray-900 dark:text-gray-100",children:"Save Request"}),f.jsxs("div",{className:"space-y-4",children:[f.jsxs("div",{children:[f.jsx(Kt,{htmlFor:"request-name",children:"Request Name (optional)"}),f.jsx(kn,{id:"request-name",value:t,onChange:s=>a(s.target.value),placeholder:n,className:"mt-2",onKeyDown:s=>{s.key==="Enter"&&r()},autoFocus:!0})]}),f.jsxs("div",{className:"flex justify-end gap-2",children:[f.jsx(je,{variant:"outline",onClick:i,children:"Cancel"}),f.jsxs(je,{onClick:r,children:[f.jsx(sN,{className:"h-4 w-4 mr-2"}),"Save"]})]})]})]})}):null}function eZ(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 D_e(e,t){if(e.anyOf&&Array.isArray(e.anyOf)){const n=e.anyOf.find(a=>a.type!=="null");if(n)return{...eZ(n,t),nullable:!0}}return e}function j_e(e){return Array.isArray(e.enum)?e.enum:null}function L_e({selectedTool:e,toolArgs:t,onArgChange:n}){const a=e?.inputSchema?.properties||{},r=e?.inputSchema?.required||[];return Object.keys(a).length>0?f.jsx("div",{className:"space-y-4",children:Object.entries(a).map(([s,c])=>{const u=e?.inputSchema||{};let d=D_e(c,u);d=eZ(d,u);const m=j_e(d),h=d.type==="string"&&m!==null,g=d;g.required=r.includes(s);const v=t[s];let S="";return v!=null&&(typeof v=="string"?S=v:typeof v=="object"&&v!==null?S=JSON.stringify(v,null,2):S=String(v)),g.type==="object"||g.type==="array"?f.jsxs("div",{className:"space-y-2",children:[f.jsxs(Kt,{htmlFor:s,className:"text-sm font-medium",children:[s,g?.required&&f.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),f.jsx(zl,{id:s,value:S,onChange:y=>n(s,y.target.value),placeholder:g?.description||`Enter ${s}`,className:"min-h-[100px]"}),g?.description&&f.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:g.description})]},s):h&&m?f.jsxs("div",{className:"space-y-2",children:[f.jsxs(Kt,{htmlFor:s,className:"text-sm font-medium",children:[s,g.required&&f.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),f.jsxs(ko,{value:String(t[s]||""),onValueChange:y=>n(s,y),children:[f.jsx(No,{id:s,className:"w-full",children:f.jsx(To,{placeholder:g.description||"Select an option"})}),f.jsx(Co,{children:m.map((y,_)=>f.jsx(Ir,{value:y,children:g.enumNames?.[_]||y},y))})]}),g.description&&f.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:g.description})]},s):f.jsxs("div",{className:"space-y-2",children:[f.jsxs(Kt,{htmlFor:s,className:"text-sm font-medium",children:[s,g?.required&&f.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),f.jsx(kn,{id:s,value:S,onChange:y=>n(s,y.target.value),placeholder:g?.description||`Enter ${s}`}),g?.description&&f.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:g.description})]},s)})}):f.jsx("div",{className:"flex items-center justify-center h-32 text-gray-500 dark:text-gray-400 text-sm",children:"No parameters required"})}function X4({selectedTool:e,toolArgs:t,isExecuting:n,isConnected:a,onArgChange:r,onExecute:i,onSave:s,onCancel:c}){const[u,d]=x.useState(!1);return x.useEffect(()=>{const m=h=>{(h.metaKey||h.ctrlKey)&&h.key==="Enter"&&e&&!n&&a&&(h.preventDefault(),i()),h.key==="Escape"&&n&&c&&(h.preventDefault(),c())};return document.addEventListener("keydown",m),()=>document.removeEventListener("keydown",m)},[e,n,a,i,c]),e?f.jsxs("div",{className:"flex flex-col h-full",children:[f.jsx("div",{className:"flex-shrink-0 p-3 sm:p-5 pt-3 sm:pt-4 pb-4 sm:pr-4",children:f.jsxs("div",{children:[f.jsxs("div",{className:"flex flex-row items-center justify-between mb-0 gap-2",children:[f.jsx("h3",{className:"text-base sm:text-lg font-semibold",children:e.name}),f.jsxs("div",{className:"flex gap-2 flex-shrink-0",children:[f.jsxs(je,{variant:"outline",onClick:s,disabled:n,size:"sm",className:"lg:size-default gap-2",children:[f.jsx(sN,{className:"h-4 w-4"}),f.jsx("span",{className:"hidden sm:inline",children:"Save"})]}),n&&c?f.jsxs($t,{open:u?void 0:!1,children:[f.jsx(Mt,{asChild:!0,children:f.jsx("div",{onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),className:"relative",children:f.jsx(je,{onClick:c,variant:u?"destructive":"default",size:"sm",className:"lg:size-default gap-2 transition-all",children:u?f.jsxs(f.Fragment,{children:[f.jsx(Wi,{className:"h-4 w-4"}),f.jsx("span",{className:"hidden sm:inline",children:"Cancel"}),f.jsx("span",{className:"hidden sm:inline text-[12px] border border-current p-1 rounded-full ml-2",children:"Esc"})]}):f.jsxs(f.Fragment,{children:[f.jsx(Hi,{className:"mr-2"}),f.jsx("span",{className:"hidden sm:inline",children:"Executing..."})]})})})}),f.jsx(Pt,{children:f.jsx("p",{children:"Hover to cancel (or press Esc)"})})]}):f.jsx(je,{onClick:i,disabled:n||!a,size:"sm",className:"lg:size-default pr-1! gap-0",children:n?f.jsxs(f.Fragment,{children:[f.jsx(Hi,{className:"mr-2"}),f.jsx("span",{className:"hidden sm:inline",children:"Executing..."})]}):f.jsxs(f.Fragment,{children:[f.jsx(W9,{className:"h-4 w-4 sm:mr-2"}),f.jsx("span",{className:"hidden sm:inline",children:"Execute"}),f.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&&f.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 leading-relaxed mt-2",children:e.description})]})}),f.jsx("div",{className:"flex-1 overflow-y-auto px-3 sm:px-6 pb-4 pr-3",children:f.jsx(L_e,{selectedTool:e,toolArgs:t,onArgChange:r})})]}):f.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[f.jsx("p",{className:"text-gray-500 dark:text-gray-400 mb-2",children:"Select a tool to get started"}),f.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 J4(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 $_e(e){try{return JSON.parse(e),!0}catch{return!1}}function M_e({content:e}){return!Array.isArray(e)||e.length===0?f.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:"No content"}):f.jsx("div",{className:"space-y-4",children:e.map((t,n)=>{if(t.type==="text"){const a=t.text||"";if($_e(a))try{const r=JSON.parse(a);return f.jsxs("div",{className:"space-y-2",children:[f.jsx("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"Text Content (JSON)"}),f.jsx(Jn,{data:r,filename:`content-${n}.json`})]},n)}catch{}return f.jsxs("div",{className:"space-y-2",children:[f.jsx("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"Text Content"}),f.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 f.jsxs("div",{className:"space-y-2",children:[f.jsx("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"Image Content"}),f.jsxs("div",{className:"bg-gray-50 dark:bg-zinc-900 rounded-lg p-3",children:[f.jsx("img",{src:`data:${t.mimeType||"image/png"};base64,${t.data}`,alt:"Result",className:"max-w-full rounded"}),t.annotations&&f.jsx("div",{className:"mt-2 text-xs text-gray-500 dark:text-gray-400",children:f.jsx(Jn,{data:t.annotations,filename:`image-annotations-${n}.json`})})]})]},n);if(t.type==="audio")return f.jsxs("div",{className:"space-y-2",children:[f.jsx("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"Audio Content"}),f.jsxs("div",{className:"bg-gray-50 dark:bg-zinc-900 rounded-lg p-3",children:[f.jsx("audio",{controls:!0,src:`data:${t.mimeType||"audio/wav"};base64,${t.data}`,className:"w-full"}),t.annotations&&f.jsx("div",{className:"mt-2 text-xs text-gray-500 dark:text-gray-400",children:f.jsx(Jn,{data:t.annotations,filename:`audio-annotations-${n}.json`})})]})]},n);if(t.type==="resource_link")return f.jsxs("div",{className:"space-y-2",children:[f.jsx("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"Resource Link"}),f.jsxs("div",{className:"bg-gray-50 dark:bg-zinc-900 rounded-lg p-3 space-y-2",children:[f.jsxs("div",{className:"font-mono text-sm break-all",children:[f.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"URI:"})," ",t.uri]}),t.name&&f.jsxs("div",{className:"text-sm",children:[f.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"Name:"})," ",t.name]}),t.description&&f.jsxs("div",{className:"text-sm",children:[f.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"Description:"})," ",t.description]}),t.mimeType&&f.jsxs("div",{className:"text-sm",children:[f.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"MIME Type:"})," ",t.mimeType]}),t.annotations&&f.jsxs("div",{className:"mt-2",children:[f.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"Annotations:"}),f.jsx(Jn,{data:t.annotations,filename:`resource-link-annotations-${n}.json`})]})]})]},n);if(t.type==="resource"){const a=t.resource||{};return f.jsxs("div",{className:"space-y-2",children:[f.jsx("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"Embedded Resource"}),f.jsxs("div",{className:"bg-gray-50 dark:bg-zinc-900 rounded-lg p-3 space-y-2",children:[f.jsxs("div",{className:"font-mono text-sm break-all",children:[f.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"URI:"})," ",a.uri]}),a.mimeType&&f.jsxs("div",{className:"text-sm",children:[f.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"MIME Type:"})," ",a.mimeType]}),a.text&&f.jsxs("div",{children:[f.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"Content:"}),f.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&&f.jsxs("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:["[Binary content: ",a.blob.length||0," bytes]"]}),a.annotations&&f.jsxs("div",{className:"mt-2",children:[f.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"Annotations:"}),f.jsx(Jn,{data:a.annotations,filename:`resource-annotations-${n}.json`})]})]})]},n)}return f.jsxs("div",{className:"space-y-2",children:[f.jsxs("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:["Unknown Content Type: ",t.type||"N/A"]}),f.jsx(Jn,{data:t,filename:`content-${n}.json`})]},n)})})}function Q4({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,S]=x.useState(!0),w=e[0],y=w?e.filter(J=>J.toolName===w.toolName):[],_=y[d]||y[0],E=e.findIndex(J=>J===_);x.useEffect(()=>{y.length>0&&d>=y.length&&m(0)},[y.length,d]),x.useEffect(()=>{const J=()=>{_&&g(J4(_.timestamp))};J();const ie=setInterval(J,1e3);return()=>clearInterval(ie)},[_]);const k=x.useMemo(()=>_?.args,[_?.timestamp,d]),R=x.useMemo(()=>_?.result,[_?.timestamp,d]),C=x.useCallback(J=>r(J),[r]);if(e.length===0)return f.jsx("div",{className:"flex flex-col h-full bg-white dark:bg-black border-t dark:border-zinc-700",children:f.jsx("div",{className:"flex-1 overflow-y-auto h-full",children:f.jsx("div",{className:"flex items-center justify-center h-full",children:f.jsx("div",{className:"text-center",children:f.jsx(od,{vertical:!0,noBorder:!0,message:"No Results yet"})})})})});const I=_.toolMeta?.["openai/outputTemplate"],A=!!(I&&typeof I=="string"&&_.appsSdkResource),O=I,M=_.result?.content||[],U=M.filter(J=>J.type==="resource"&&bu(J.resource)),H=U.length>0,K=!!(M&&M.length>0||_.result?.structuredContent),ee=!H&&!A&&K;return f.jsx("div",{className:"flex flex-col h-full bg-white dark:bg-black border-t dark:border-zinc-700",children:f.jsx("div",{className:"flex-1 overflow-y-auto h-full",children:f.jsxs("div",{className:"space-y-0 flex-1 h-full flex flex-col",children:[f.jsxs("div",{className:`flex items-center gap-2 px-4 pt-2 ${H||A||ee?"border-b border-gray-200 dark:border-zinc-600 pb-2":""}`,children:[f.jsx("h3",{className:"text-sm font-medium hidden sm:block",children:"Response"}),_.duration!==void 0&&f.jsxs("div",{className:"hidden sm:flex items-center gap-1",children:[f.jsx(cp,{className:"h-3 w-3 text-gray-400"}),f.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:[_.duration,"ms"]})]}),A&&f.jsxs("div",{className:"flex items-center gap-4 sm:ml-4",children:[f.jsxs("span",{className:"hidden sm:inline text-xs text-gray-500 dark:text-gray-400",children:["URI: ",O||"No URI"]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("button",{onClick:()=>s(),className:`text-xs font-medium ${n?"text-black dark:text-white":"text-zinc-500 dark:text-zinc-400"}`,children:"Component"}),f.jsx("span",{className:"text-xs text-zinc-400",children:"|"}),f.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&&!A&&f.jsxs("div",{className:"flex items-center gap-4 sm:ml-4",children:[f.jsxs("span",{className:"hidden sm:inline text-xs text-gray-500 dark:text-gray-400",children:["URI: ",U[0]?.resource?.uri||"No URI"]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("button",{onClick:()=>s(),className:`text-xs font-medium ${n?"text-black dark:text-white":"text-zinc-500 dark:text-zinc-400"}`,children:"Preview"}),f.jsx("span",{className:"text-xs text-zinc-400",children:"|"}),f.jsx("button",{onClick:()=>s(),className:`text-xs font-medium ${n?"text-zinc-500 dark:text-zinc-400":"text-black dark:text-white"}`,children:"JSON"})]})]}),ee&&f.jsxs("div",{className:"flex items-center gap-2 sm:ml-4",children:[f.jsx("button",{onClick:()=>S(!0),className:`text-xs font-medium ${v?"text-black dark:text-white":"text-zinc-500 dark:text-zinc-400"}`,children:"Formatted"}),f.jsx("span",{className:"text-xs text-zinc-400",children:"|"}),f.jsx("button",{onClick:()=>S(!1),className:`text-xs font-medium ${v?"text-zinc-500 dark:text-zinc-400":"text-black dark:text-white"}`,children:"Raw"})]}),f.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[(A||H)&&c&&f.jsx(je,{variant:"ghost",size:"sm",onClick:c,title:u?"Restore":"Maximize",children:u?f.jsx(_pe,{className:"h-4 w-4"}):f.jsx(oN,{className:"h-4 w-4"})}),y.length>1&&f.jsxs(ko,{value:d.toString(),onValueChange:J=>m(parseInt(J)),children:[f.jsx(No,{size:"sm",className:"w-[140px] h-8 text-xs",children:f.jsx(To,{children:f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx(zb,{className:"h-3 w-3"}),f.jsx("span",{children:h})]})})}),f.jsx(Co,{children:y.map((J,ie)=>f.jsx(Ir,{value:ie.toString(),children:f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(zb,{className:"h-3 w-3"}),f.jsx("span",{children:J4(J.timestamp)}),f.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",new Date(J.timestamp).toLocaleTimeString(),")"]})]})},ie))})]}),f.jsx(je,{variant:"ghost",size:"sm",onClick:()=>i(E,_.result),children:t===E?f.jsx(ga,{className:"h-4 w-4"}):f.jsx(Br,{className:"h-4 w-4"})})]})]}),_.error?f.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:[f.jsx("p",{className:"text-red-800 dark:text-red-300 font-medium",children:"Error:"}),f.jsx("p",{className:"text-red-700 dark:text-red-400 text-sm",children:_.error})]}):(()=>{if(A){const J=_.appsSdkResource;return J.isLoading?f.jsx(f.Fragment,{}):J.error?f.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:[f.jsx("p",{className:"text-red-800 dark:text-red-300 font-medium",children:"Resource Error:"}),f.jsx("p",{className:"text-red-700 dark:text-red-400 text-sm",children:J.error})]}):n?f.jsx("div",{className:"flex-1",children:f.jsx(xO,{componentUrl:O,toolName:_.toolName,toolArgs:k,toolResult:R,serverId:a,readResource:C,className:"w-full h-full relative p-4"})}):f.jsx("div",{className:"px-4 pt-4",children:f.jsx(Jn,{data:_.result,filename:`tool-result-${_.toolName}-${Date.now()}.json`})})}if(H)return n?f.jsxs("div",{className:"space-y-0 h-full",children:[U.map((J,ie)=>f.jsx("div",{className:"mx-0 size-full",children:f.jsx(JK,{resource:J.resource,onUIAction:B=>{},className:"w-full h-full relative"})},ie)),M.filter(J=>!(J.type==="resource"&&bu(J.resource))).length>0&&f.jsx("div",{className:"px-4",children:f.jsx(Jn,{data:M.filter(J=>!(J.type==="resource"&&bu(J.resource))),filename:`tool-result-${_.toolName}-non-ui-${Date.now()}.json`})})]}):f.jsx("div",{className:"px-4 pt-4",children:f.jsx(Jn,{data:_.result,filename:`tool-result-${_.toolName}-mcp-ui-${Date.now()}.json`})});if(ee&&v){const J=_.result?.structuredContent;return f.jsxs("div",{className:"px-4 pt-4 space-y-4",children:[J&&f.jsxs("div",{className:"space-y-2",children:[f.jsx("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"Structured Content"}),f.jsx(Jn,{data:J,filename:`structured-content-${_.toolName}-${Date.now()}.json`})]}),M&&M.length>0&&f.jsx(M_e,{content:M}),!J&&(!M||M.length===0)&&f.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:"No content to display"})]})}return f.jsx("div",{className:"px-4 pt-4",children:f.jsx(Jn,{data:_.result,filename:`tool-result-${_.toolName}-${Date.now()}.json`})})})()]})})})}function e2({tools:e,selectedTool:t,onToolSelect:n,focusedIndex:a}){return e.length===0?f.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[f.jsx(Ll,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),f.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"No tools available"})]}):f.jsx("div",{className:"overflow-y-auto flex-1 overscroll-contain",children:e.map((r,i)=>f.jsx(Vs,{id:`tool-${r.name}`,isSelected:t?.name===r.name,isFocused:a===i,icon:f.jsx(Ll,{className:"h-4 w-4"}),title:r.name,description:r.description,metadata:r.inputSchema?.properties&&f.jsxs(xr,{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 t2({activeTab:e,isSearchExpanded:t,searchQuery:n,filteredToolsCount:a,savedRequestsCount:r,onSearchExpand:i,onSearchChange:s,onSearchBlur:c,onTabSwitch:u,searchInputRef:d}){return f.jsx(qK,{activeTab:e,isSearchExpanded:t,searchQuery:n,primaryTabName:"tools",secondaryTabName:"saved",primaryTabTitle:"Tools",secondaryTabTitle:"Saved",primaryCount:a,secondaryCount:r,primaryIcon:Ll,secondaryIcon:sy,searchPlaceholder:"Search tools...",onSearchExpand:i,onSearchChange:s,onSearchBlur:c,onTabSwitch:u,searchInputRef:d})}const n2="mcp-inspector-saved-requests";function tZ({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}=Zl(),[g,v]=x.useState({}),[S,w]=x.useState([]),[y,_]=x.useState(!1),[E,k]=x.useState(null),[R,C]=x.useState(null),[I,A]=x.useState(""),[O,M]=x.useState("tools"),[U,H]=x.useState([]),[K,ee]=x.useState(!1),[J,ie]=x.useState(""),[B,Z]=x.useState(!0),[G,re]=x.useState(!1),[ne,j]=x.useState(-1),V=x.useRef(null),[z,L]=x.useState(!1),[$,F]=x.useState("list"),[W,X]=x.useState(!1),[ae,le]=x.useState(0),[Q,q]=x.useState(!0),[se,he]=x.useState(void 0),ce=x.useRef(null),ke=x.useRef(null),He=x.useRef(null),Se=x.useRef(null),_e=x.useRef(null);x.useEffect(()=>{const Oe=()=>{L(window.innerWidth<1024)};return Oe(),window.addEventListener("resize",Oe),()=>window.removeEventListener("resize",Oe)},[]),x.useEffect(()=>{F(s?"detail":"list")},[s]),x.useEffect(()=>{z&&S.length>0&&!y&&F("response")},[S,y,z]),x.useImperativeHandle(e,()=>({focusSearch:()=>{re(!0),setTimeout(()=>{V.current&&V.current.focus()},0)},blurSearch:()=>{A(""),re(!1),V.current&&V.current.blur()}})),x.useEffect(()=>{try{const Oe=localStorage.getItem(n2);Oe&&H(JSON.parse(Oe))}catch(Oe){console.error("[ToolsTab] Failed to load saved requests:",Oe)}},[]);const Ue=x.useCallback(Oe=>{try{localStorage.setItem(n2,JSON.stringify(Oe)),H(Oe)}catch($e){console.error("[ToolsTab] Failed to save requests:",$e)}},[]),fe=x.useMemo(()=>{if(!I.trim())return t;const Oe=I.toLowerCase();return t.filter($e=>$e.name.toLowerCase().includes(Oe)||$e.description?.toLowerCase().includes(Oe))},[t,I]),Ie=x.useCallback(Oe=>{c(Oe);const $e={};Oe.inputSchema?.properties&&Object.entries(Oe.inputSchema.properties).forEach(([Be,ut])=>{const dt=ut;dt.default!==void 0?$e[Be]=dt.default:dt.type==="string"?$e[Be]="":dt.type==="number"?$e[Be]=0:dt.type==="boolean"?$e[Be]=!1:dt.type==="array"?$e[Be]="[]":dt.type==="object"&&($e[Be]="{}")}),v($e)},[]),Fe=x.useCallback(Oe=>{const $e=t.find(Be=>Be.name===Oe.toolName);$e&&(c($e),v(Oe.args),d(Oe))},[t]);x.useEffect(()=>{G&&V.current&&V.current.focus()},[G]);const xe=x.useCallback(()=>{I.trim()||re(!1)},[I]);x.useEffect(()=>{O!=="tools"&&re(!1)},[O]),x.useEffect(()=>{j(-1)},[I,O]),x.useEffect(()=>{const Oe=$e=>{const Be=$e.target;if(Be.tagName==="INPUT"||Be.tagName==="TEXTAREA"||Be.contentEditable==="true"||$e.metaKey||$e.ctrlKey||$e.altKey)return;const dt=O==="tools"?fe:U;if($e.key==="ArrowDown")$e.preventDefault(),j(wt=>{const xt=wt+1;return xt>=dt.length?0:xt});else if($e.key==="ArrowUp")$e.preventDefault(),j(wt=>{const xt=wt-1;return xt<0?dt.length-1:xt});else if($e.key==="Enter"&&ne>=0)if($e.preventDefault(),O==="tools"){const wt=fe[ne];wt&&Ie(wt)}else{const wt=U[ne];wt&&Fe(wt)}};return document.addEventListener("keydown",Oe),()=>document.removeEventListener("keydown",Oe)},[ne,fe,U,O,Ie,Fe]),x.useEffect(()=>{if(ne>=0){const Oe=O==="tools"?`tool-${fe[ne]?.name}`:`saved-${U[ne]?.id}`,$e=document.getElementById(Oe);$e&&$e.scrollIntoView({behavior:"smooth",block:"nearest"})}},[ne,fe,U,O]),x.useEffect(()=>{if(m&&t.length>0){const Oe=t.find($e=>$e.name===m);if(Oe&&s?.name!==Oe.name){h(null);const $e=setTimeout(()=>{Ie(Oe);const Be=document.getElementById(`tool-${Oe.name}`);Be&&Be.scrollIntoView({behavior:"smooth",block:"nearest"})},100);return()=>clearTimeout($e)}}},[m,t,s,Ie,h]);const it=x.useCallback((Oe,$e)=>{v(Be=>{const ut={...Be};if(s?.inputSchema?.properties?.[Oe]){const wt=s.inputSchema.properties[Oe].type;if(wt==="object"||wt==="array")ut[Oe]=$e;else if(wt==="string")ut[Oe]=$e;else try{ut[Oe]=JSON.parse($e)}catch{ut[Oe]=$e}}else ut[Oe]=$e;return ut})},[s]),nt=x.useCallback(async()=>{if(!s||y)return;const Oe=new AbortController;C(Oe),_(!0);const $e=Date.now();try{const Be={...g};s.inputSchema?.properties&&Object.entries(s.inputSchema.properties).forEach(([Ye,vt])=>{const Lt=vt.type,fr=Be[Ye];if((Lt==="object"||Lt==="array")&&typeof fr=="string")try{Be[Ye]=JSON.parse(fr)}catch{}});const ut=await n(s.name,Be,{timeout:6e5,resetTimeoutOnProgress:!0,signal:Oe.signal}),dt=Date.now()-$e;yr.getInstance().capture(new aU({toolName:s.name,serverId:r,success:!0,duration:dt})).catch(()=>{});const xt=s?._meta||s?.metadata,dn=xt?.["openai/outputTemplate"];let hn;if(dn&&typeof dn=="string"){const Ye={toolName:s.name,args:g,result:ut,timestamp:$e,duration:dt,toolMeta:xt,appsSdkResource:{uri:dn,resourceData:null,isLoading:!0}};w([Ye]);try{const vt=await a(dn);let jt=null;if(ut?.structuredContent)jt=ut.structuredContent;else if(Array.isArray(ut)&&ut[0]){const Lt=ut[0];Lt.output?.value?.structuredContent?jt=Lt.output.value.structuredContent:Lt.structuredContent?jt=Lt.structuredContent:Lt.output?.value&&(jt=Lt.output.value)}jt||(jt=ut),hn={uri:dn,resourceData:{...vt,structuredContent:jt},isLoading:!1}}catch(vt){hn={uri:dn,resourceData:null,isLoading:!1,error:vt instanceof Error?vt.message:String(vt)}}w(vt=>vt.map((jt,Lt)=>Lt===0?{...jt,appsSdkResource:hn}:jt))}else w(Ye=>[{toolName:s.name,args:g,result:ut,timestamp:$e,duration:dt,toolMeta:xt},...Ye])}catch(Be){const ut=Date.now()-$e;yr.getInstance().capture(new aU({toolName:s.name,serverId:r,success:!1,duration:ut,error:Be instanceof Error?Be.message:String(Be)})).catch(()=>{});const wt=s?._meta||s?.metadata,xt={toolName:s.name,args:g,result:null,error:Be instanceof Error?Be.message:String(Be),timestamp:$e,duration:ut,toolMeta:wt},dn=wt?.["openai/outputTemplate"];w(dn?[xt]:hn=>[xt,...hn])}finally{_(!1)}},[s,g,y,n,a,r]),mt=x.useCallback(async(Oe,$e)=>{try{await navigator.clipboard.writeText(JSON.stringify($e,null,2)),k(Oe),setTimeout(()=>k(null),2e3)}catch(Be){console.error("[ToolsTab] Failed to copy result:",Be)}},[]),Ct=x.useCallback(Oe=>{w($e=>$e.filter((Be,ut)=>ut!==Oe))},[]),Le=x.useMemo(()=>s?S.filter(Oe=>Oe.toolName===s.name):[],[S,s]),ze=x.useCallback(Oe=>{const $e=Le[Oe];if($e){const Be=window.open("","_blank","width=800,height=600");Be&&(Be.document.write(`
1669
+ `);k=I.pop()||"";for(const A of I)if(A.trim()&&A.startsWith("data: "))try{const O=JSON.parse(A.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"){w+=O.content;const M=y[y.length-1];M&&M.type==="text"?M.text=w:y.push({type:"text",text:w}),console.log("[Parts after text]",y.length,"parts, text length:",w.length),i(U=>U.map(H=>H.id===S?{...H,parts:[...y]}:H))}else if(O.type==="tool-call")w&&(w=""),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(M=>M.map(U=>U.id===S?{...U,parts:[...y]}:U));else if(O.type==="tool-result"){const M=y.find(U=>U.type==="tool-invocation"&&U.toolInvocation?.toolName===O.toolName&&!U.toolInvocation?.result);M&&M.toolInvocation?(M.toolInvocation.result=O.result,M.toolInvocation.state="result",console.log("[Parts after tool-result]",y.length,"parts, updated:",O.toolName),i(U=>U.map(H=>H.id===S?{...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(M=>M.map(U=>U.id===S?{...U,parts:[...y],content:""}:U));else if(O.type==="error")throw new Error(O.message||"Streaming error")}catch(O){console.error("Failed to parse streaming event:",O,A)}}}catch(g){let v="Unknown error occurred";if(g instanceof Error){v=g.message;const w=g;w.status&&(v=`HTTP ${w.status}: ${v}`),(w.code===401||v.includes("401")||v.includes("Unauthorized"))&&(v="Authentication failed (401). Check your Authorization header in the connection settings.")}const S={id:`error-${Date.now()}`,role:"assistant",content:`Error: ${v}`,timestamp:Date.now()};i(w=>[...w,S])}finally{c(!1)}},[t,a,e,r,n]),d=x.useCallback(()=>{i([])},[]);return{messages:r,isLoading:s,sendMessage:u,clearMessages:d}}function qEe({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 S={id:`user-${Date.now()}`,role:"user",content:v.trim(),timestamp:Date.now()};i(_=>[..._,S]),c(!0),u.current=new AbortController;const w=Date.now();let y=0;try{const _=`assistant-${Date.now()}`;let E="";const k=[];if(i(R=>[...R,{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 R;if(t.provider==="openai"){const{ChatOpenAI:C}=await dr(async()=>{const{ChatOpenAI:I}=await import("./index-zbgLDNGN.js");return{ChatOpenAI:I}},__vite__mapDeps([5,6,7,3,8,9]));R=new C({model:t.model,apiKey:t.apiKey})}else if(t.provider==="anthropic"){const{ChatAnthropic:C}=await dr(async()=>{const{ChatAnthropic:I}=await import("./index-BepdOzrL.js");return{ChatAnthropic:I}},__vite__mapDeps([10,7,6,3]));R=new C({model:t.model,apiKey:t.apiKey})}else if(t.provider==="google"){const{ChatGoogleGenerativeAI:C}=await dr(async()=>{const{ChatGoogleGenerativeAI:I}=await import("./index-CUJpXvgh.js");return{ChatGoogleGenerativeAI:I}},__vite__mapDeps([11,7,6,3,9]));R=new C({model:t.model,apiKey:t.apiKey})}else throw new Error(`Unsupported LLM provider: ${t.provider}`);m.current={instance:R,provider:t.provider,model:t.model,apiKey:t.apiKey}}if(!d.current||d.current.llm!==m.current.instance){const{MCPAgent:R}=await dr(async()=>{const{MCPAgent:C}=await import("./browser-DIA2gDt8.js");return{MCPAgent:C}},__vite__mapDeps([12,8,6,7,3,2,4,9]));d.current=new R({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 R of d.current.streamEvents(v,10,!1,void 0)){if(u.current?.signal.aborted)break;if(R.event==="on_chat_model_stream"&&R.data?.chunk?.text){const C=R.data.chunk.text;if(typeof C=="string"&&C.length>0){E+=C;const I=k[k.length-1];I&&I.type==="text"?I.text=E:k.push({type:"text",text:E}),i(A=>A.map(O=>O.id===_?{...O,parts:[...k]}:O))}}else if(R.event==="on_tool_start"){E&&(E="");let C={};R.data?.input?C=R.data.input:R.data?.tool_input?C=R.data.tool_input:R.data&&(C=R.data),console.log("[useChatMessagesClientSide] on_tool_start:",{toolName:R.name,eventData:R.data,extractedArgs:C}),y++,k.push({type:"tool-invocation",toolInvocation:{toolName:R.name||"unknown",args:C,state:"pending"}}),i(I=>I.map(A=>A.id===_?{...A,parts:[...k]}:A))}else if(R.event==="on_tool_end"){const C=k.find(I=>I.type==="tool-invocation"&&I.toolInvocation?.toolName===R.name&&!I.toolInvocation?.result);if(console.log("[useChatMessagesClientSide] on_tool_end event:",{toolName:R.name,hasToolPart:!!C,output:R.data?.output}),C&&C.toolInvocation){let I=R.data?.output;if(I?.kwargs?.content&&typeof I.kwargs.content=="string")try{I=JSON.parse(I.kwargs.content)}catch(O){console.warn("[useChatMessagesClientSide] Failed to parse kwargs.content:",O),I=I.kwargs.content}else if(I?.content&&typeof I.content=="string")try{I=JSON.parse(I.content)}catch{I=I.content}C.toolInvocation.result=I,C.toolInvocation.state="result";const A=I?._meta?.["openai/outputTemplate"];if(console.log("[useChatMessagesClientSide] Tool result:",{toolName:R.name,hasMeta:!!I?._meta,hasStructuredContent:!!I?.structuredContent,appsSdkUri:A}),A&&typeof A=="string"&&a){console.log("[useChatMessagesClientSide] Detected Apps SDK component, fetching resource:",A);try{const O=await a(A);console.log("[useChatMessagesClientSide] Resource fetched:",O);const M=I?.structuredContent||null;if(O?.contents&&Array.isArray(O.contents)){const U=O.contents.map(K=>({type:"resource",resource:K}));console.log("[useChatMessagesClientSide] Created MCP resources:",U);const H={...I,content:[...I.content||[],...U],structuredContent:M};C.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(M=>M.id===_?{...M,parts:[...k]}:M))}}}i(R=>R.map(C=>C.id===_?{...C,parts:[...k],content:""}:C)),t&&yr.getInstance().capture(new sU({serverId:e.url,provider:t.provider,model:t.model,messageCount:r.length+1,toolCallsCount:y,success:!0,executionMode:"client-side",duration:Date.now()-w})).catch(()=>{})}catch(_){console.error("Client-side agent error:",_);let E="Unknown error occurred";if(_ instanceof Error){E=_.message;const R=_;R.status&&(E=`HTTP ${R.status}: ${E}`),(R.code===401||E.includes("401")||E.includes("Unauthorized"))&&(E="Authentication failed (401). Check your Authorization header in the connection settings.")}t&&yr.getInstance().capture(new sU({serverId:e.url,provider:t.provider,model:t.model,messageCount:r.length+1,toolCallsCount:y,success:!1,executionMode:"client-side",duration:Date.now()-w,error:E})).catch(()=>{});const k={id:`error-${Date.now()}`,role:"assistant",content:`Error: ${E}`,timestamp:Date.now()};i(R=>[...R,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 I4={openai:"gpt-4o",anthropic:"claude-haiku-4-5-20251001",google:"gemini-2.5-flash"};function CK({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(I4.openai),v=x.useCallback(()=>{const M=localStorage.getItem("mcp-inspector-api-keys");if(M)try{return JSON.parse(M)}catch(U){return console.error("Failed to load API keys:",U),{}}return{}},[]),S=x.useCallback(M=>{localStorage.setItem("mcp-inspector-api-keys",JSON.stringify(M))},[]),[w,y]=x.useState("none"),[_,E]=x.useState(""),[k,R]=x.useState(""),[C,I]=x.useState("");x.useEffect(()=>{const M=localStorage.getItem("mcp-inspector-llm-config"),U=v();if(M)try{const H=JSON.parse(M);n(H),u(H.provider),m(U[H.provider]||H.apiKey||""),g(H.model)}catch(H){console.error("Failed to load LLM config:",H)}},[v]),x.useEffect(()=>{const M=localStorage.getItem("mcp-inspector-auth-config");if(M)try{const U=JSON.parse(M);r(U),y(U.type),U.username&&E(U.username),U.password&&R(U.password),U.token&&I(U.token)}catch(U){console.error("Failed to load auth config:",U)}else try{const U="mcp:auth",H=NK(e),K=`${U}_${H}_tokens`;localStorage.getItem(K)&&(r({type:"oauth"}),y("oauth"))}catch(U){console.error("Failed to check for OAuth tokens:",U)}},[e]),x.useEffect(()=>{g(I4[c]);const M=v();m(M[c]||"")},[c,v]);const A=x.useCallback(()=>{if(!d.trim())return;const M=v();M[c]=d,S(M);const U={provider:c,apiKey:d,model:h},H={type:w,...w==="basic"&&{username:_.trim(),password:k.trim()},...w==="bearer"&&{token:C.trim()}};n(U),r(H),localStorage.setItem("mcp-inspector-llm-config",JSON.stringify(U)),localStorage.setItem("mcp-inspector-auth-config",JSON.stringify(H)),s(!1)},[c,d,h,w,_,k,C,v,S]),O=x.useCallback(()=>{n(null),r(null);const M=v();delete M[c],S(M),m(""),E(""),R(""),I(""),y("none"),localStorage.removeItem("mcp-inspector-llm-config"),localStorage.removeItem("mcp-inspector-auth-config")},[c,v,S]);return{llmConfig:t,authConfig:a,configDialogOpen:i,setConfigDialogOpen:s,tempProvider:c,setTempProvider:u,tempApiKey:d,setTempApiKey:m,tempModel:h,setTempModel:g,tempAuthType:w,saveLLMConfig:A,clearConfig:O}}function XEe({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:S,tempModel:w,setTempModel:y,saveLLMConfig:_,clearConfig:E}=CK({mcpServerUrl:e.url}),k={connection:e,llmConfig:c,isConnected:t,readResource:a},R=YEe({mcpServerUrl:e.url,llmConfig:c,authConfig:u,isConnected:t}),C=qEe(k),{messages:I,isLoading:A,sendMessage:O,clearMessages:M}=n?C:R;TW({onNewChat:M}),x.useEffect(()=>{c&&I.length===0&&s.current&&s.current.focus()},[c,I.length]),x.useEffect(()=>{!A&&I.length>0&&s.current&&s.current.focus()},[A,I.length]);const U=x.useCallback(()=>{r.trim()&&(O(r),i(""))},[r,O]),H=x.useCallback(ee=>{ee.key==="Enter"&&!ee.shiftKey&&(ee.preventDefault(),U())},[U]),K=x.useCallback(()=>{E(),M()},[E,M]);return c&&I.length===0?f.jsxs("div",{className:"flex flex-col h-full",children:[f.jsx("div",{className:"absolute top-4 right-4 z-10",children:f.jsx(UE,{open:d,onOpenChange:m,tempProvider:h,tempModel:w,tempApiKey:v,onProviderChange:g,onModelChange:y,onApiKeyChange:S,onSave:_,onClear:K,showClearButton:!0,buttonLabel:"Change API Key"})}),f.jsx(u0e,{mcpServerUrl:e.url,inputValue:r,isConnected:t,isLoading:A,textareaRef:s,llmConfig:c,onInputChange:i,onKeyDown:H,onSubmit:ee=>{ee.preventDefault(),U()},onConfigDialogOpenChange:m})]}):f.jsxs("div",{className:"flex flex-col h-full relative",children:[f.jsx(s0e,{llmConfig:c,hasMessages:I.length>0,configDialogOpen:d,onConfigDialogOpenChange:m,onClearChat:M,tempProvider:h,tempModel:w,tempApiKey:v,onProviderChange:g,onModelChange:y,onApiKeyChange:S,onSaveConfig:_,onClearConfig:K}),f.jsx("div",{className:"flex-1 overflow-y-auto p-2 sm:p-4 pt-[80px] sm:pt-[100px]",children:c?f.jsx(ZEe,{messages:I,isLoading:A,serverId:e.url,readResource:a}):f.jsx(d0e,{onConfigureClick:()=>m(!0)})}),c&&f.jsx(l0e,{inputValue:r,isConnected:t,isLoading:A,textareaRef:s,onInputChange:i,onKeyDown:H,onSendMessage:U})]})}const Ly=x.createContext(null);Ly.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"},CO=10,Cl=x.useLayoutEffect,O4=Zu.useId,JEe=typeof O4=="function"?O4:()=>null;let QEe=0;function RO(e=null){const t=JEe(),n=x.useRef(e||t||null);return n.current===null&&(n.current=""+QEe++),e??n.current}function RK({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:S="div",...w}){const y=x.useContext(Ly);if(y===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:_,expandPanel:E,getPanelSize:k,getPanelStyle:R,groupId:C,isPanelCollapsed:I,reevaluatePanelConstraints:A,registerPanel:O,resizePanel:M,unregisterPanel:U}=y,H=RO(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}),Cl(()=>{const{callbacks:J,constraints:ie}=K.current,B={...ie};K.current.id=H,K.current.idIsFromProps=s!==void 0,K.current.order=g,J.onCollapse=d,J.onExpand=m,J.onResize=h,ie.collapsedSize=n,ie.collapsible=a,ie.defaultSize=r,ie.maxSize=c,ie.minSize=u,(B.collapsedSize!==ie.collapsedSize||B.collapsible!==ie.collapsible||B.maxSize!==ie.maxSize||B.minSize!==ie.minSize)&&A(K.current,B)}),Cl(()=>{const J=K.current;return O(J),()=>{U(J)}},[g,H,O,U]),x.useImperativeHandle(i,()=>({collapse:()=>{_(K.current)},expand:J=>{E(K.current,J)},getId(){return H},getSize(){return k(K.current)},isCollapsed(){return I(K.current)},isExpanded(){return!I(K.current)},resize:J=>{M(K.current,J)}}),[_,E,k,I,H,M]);const ee=R(K.current,r);return x.createElement(S,{...w,children:e,className:t,id:H,style:{...ee,...v},[Wn.groupId]:C,[Wn.panel]:"",[Wn.panelCollapsible]:a||void 0,[Wn.panelId]:H,[Wn.panelSize]:parseFloat(""+ee.flexGrow).toFixed(1)})}const AK=x.forwardRef((e,t)=>x.createElement(RK,{...e,forwardedRef:t}));RK.displayName="Panel";AK.displayName="forwardRef(Panel)";let m_=null,ub=-1,Es=null;function e_e(e,t,n){const a=(t&LK)!==0,r=(t&$K)!==0,i=(t&MK)!==0,s=(t&PK)!==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 t_e(){Es!==null&&(document.head.removeChild(Es),m_=null,Es=null,ub=-1)}function cS(e,t,n){var a,r;const i=e_e(e,t);if(m_!==i){if(m_=i,Es===null&&(Es=document.createElement("style"),document.head.appendChild(Es)),ub>=0){var s;(s=Es.sheet)===null||s===void 0||s.removeRule(ub)}ub=(a=(r=Es.sheet)===null||r===void 0?void 0:r.insertRule(`*{cursor: ${i} !important;}`))!==null&&a!==void 0?a:-1}}function IK(e){return e.type==="keydown"}function OK(e){return e.type.startsWith("pointer")}function DK(e){return e.type.startsWith("mouse")}function $y(e){if(OK(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(DK(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}function n_e(){if(typeof matchMedia=="function")return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}function r_e(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 a_e(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:L4(e),b:L4(t)};let a;for(;n.a.at(-1)===n.b.at(-1);)e=n.a.pop(),t=n.b.pop(),a=e;Tt(a,"Stacking order can only be calculated for elements with a common ancestor");const r={a:j4(D4(n.a)),b:j4(D4(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 i_e=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function o_e(e){var t;const n=getComputedStyle((t=jK(e))!==null&&t!==void 0?t:e).display;return n==="flex"||n==="inline-flex"}function s_e(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||o_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"||i_e.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function D4(e){let t=e.length;for(;t--;){const n=e[t];if(Tt(n,"Missing node"),s_e(n))return n}return null}function j4(e){return e&&Number(getComputedStyle(e).zIndex)||0}function L4(e){const t=[];for(;e;)t.push(e),e=jK(e);return t}function jK(e){const{parentNode:t}=e;return t&&t instanceof ShadowRoot?t.host:t}const LK=1,$K=2,MK=4,PK=8,l_e=n_e()==="coarse";let gi=[],gu=!1,_s=new Map,My=new Map;const _p=new Set;function c_e(e,t,n,a,r){var i;const{ownerDocument:s}=t,c={direction:n,element:t,hitAreaMargins:a,setResizeHandlerState:r},u=(i=_s.get(s))!==null&&i!==void 0?i:0;return _s.set(s,u+1),_p.add(c),pv(),function(){var m;My.delete(e),_p.delete(c);const h=(m=_s.get(s))!==null&&m!==void 0?m:1;if(_s.set(s,h-1),pv(),h===1&&_s.delete(s),gi.includes(c)){const g=gi.indexOf(c);g>=0&&gi.splice(g,1),Py(),r("up",!0,null)}}}function u_e(e){const{target:t}=e,{x:n,y:a}=$y(e);gu=!0,AO({target:t,x:n,y:a}),pv(),gi.length>0&&(mv("down",e),Py(),e.preventDefault(),UK(t)||e.stopImmediatePropagation())}function uS(e){const{x:t,y:n}=$y(e);if(gu&&e.type!=="pointerleave"&&e.buttons===0&&(gu=!1,mv("up",e)),!gu){const{target:a}=e;AO({target:a,x:t,y:n})}mv("move",e),Py(),gi.length>0&&e.preventDefault()}function dS(e){const{target:t}=e,{x:n,y:a}=$y(e);My.clear(),gu=!1,gi.length>0&&(e.preventDefault(),UK(t)||e.stopImmediatePropagation()),mv("up",e),AO({target:t,x:n,y:a}),Py(),pv()}function UK(e){let t=e;for(;t;){if(t.hasAttribute(Wn.resizeHandle))return!0;t=t.parentElement}return!1}function AO({target:e,x:t,y:n}){gi.splice(0);let a=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(a=e),_p.forEach(r=>{const{element:i,hitAreaMargins:s}=r,c=i.getBoundingClientRect(),{bottom:u,left:d,right:m,top:h}=c,g=l_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)&&a_e(a,i)>0){let S=a,w=!1;for(;S&&!S.contains(i);){if(r_e(S.getBoundingClientRect(),c)){w=!0;break}S=S.parentElement}if(w)return}gi.push(r)}})}function fS(e,t){My.set(e,t)}function Py(){let e=!1,t=!1;gi.forEach(a=>{const{direction:r}=a;r==="horizontal"?e=!0:t=!0});let n=0;My.forEach(a=>{n|=a}),e&&t?cS("intersection",n):e?cS("horizontal",n):t?cS("vertical",n):t_e()}let pS;function pv(){var e;(e=pS)===null||e===void 0||e.abort(),pS=new AbortController;const t={capture:!0,signal:pS.signal};_p.size&&(gu?(gi.length>0&&_s.forEach((n,a)=>{const{body:r}=a;n>0&&(r.addEventListener("contextmenu",dS,t),r.addEventListener("pointerleave",uS,t),r.addEventListener("pointermove",uS,t))}),_s.forEach((n,a)=>{const{body:r}=a;r.addEventListener("pointerup",dS,t),r.addEventListener("pointercancel",dS,t)})):_s.forEach((n,a)=>{const{body:r}=a;n>0&&(r.addEventListener("pointerdown",u_e,t),r.addEventListener("pointermove",uS,t))}))}function mv(e,t){_p.forEach(n=>{const{setResizeHandlerState:a}=n,r=gi.includes(n);a(e,r,t)})}function d_e(){const[e,t]=x.useState(0);return x.useCallback(()=>t(n=>n+1),[])}function Tt(e,t){if(!e)throw console.error(t),Error(t)}function Bl(e,t,n=CO){return e.toFixed(n)===t.toFixed(n)?0:e>t?1:-1}function wo(e,t,n=CO){return Bl(e,t,n)===0}function Ia(e,t,n){return Bl(e,t,n)===0}function f_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(!Ia(r,i,n))return!1}return!0}function lu({panelConstraints:e,panelIndex:t,size:n}){const a=e[t];Tt(a!=null,`Panel constraints not found for index ${t}`);let{collapsedSize:r=0,collapsible:i,maxSize:s=100,minSize:c=0}=a;if(Bl(n,c)<0)if(i){const u=(r+c)/2;Bl(n,u)<0?n=r:n=c}else n=c;return n=Math.min(s,n),n=parseFloat(n.toFixed(CO)),n}function Af({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:a,prevLayout:r,trigger:i}){if(Ia(e,0))return t;const s=[...t],[c,u]=a;Tt(c!=null,"Invalid first pivot index"),Tt(u!=null,"Invalid second pivot index");let d=0;if(i==="keyboard"){{const h=e<0?u:c,g=n[h];Tt(g,`Panel constraints not found for index ${h}`);const{collapsedSize:v=0,collapsible:S,minSize:w=0}=g;if(S){const y=t[h];if(Tt(y!=null,`Previous layout not found for panel index ${h}`),Ia(y,v)){const _=w-y;Bl(_,Math.abs(e))>0&&(e=e<0?0-_:_)}}}{const h=e<0?c:u,g=n[h];Tt(g,`No panel constraints found for index ${h}`);const{collapsedSize:v=0,collapsible:S,minSize:w=0}=g;if(S){const y=t[h];if(Tt(y!=null,`Previous layout not found for panel index ${h}`),Ia(y,w)){const _=y-v;Bl(_,Math.abs(e))>0&&(e=e<0?0-_:_)}}}}{const h=e<0?1:-1;let g=e<0?u:c,v=0;for(;;){const w=t[g];Tt(w!=null,`Previous layout not found for panel index ${g}`);const _=lu({panelConstraints:n,panelIndex:g,size:100})-w;if(v+=_,g+=h,g<0||g>=n.length)break}const S=Math.min(Math.abs(e),Math.abs(v));e=e<0?0-S:S}{let g=e<0?c:u;for(;g>=0&&g<n.length;){const v=Math.abs(e)-Math.abs(d),S=t[g];Tt(S!=null,`Previous layout not found for panel index ${g}`);const w=S-v,y=lu({panelConstraints:n,panelIndex:g,size:w});if(!Ia(S,y)&&(d+=S-y,s[g]=y,d.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?g--:g++}}if(f_e(r,s))return r;{const h=e<0?u:c,g=t[h];Tt(g!=null,`Previous layout not found for panel index ${h}`);const v=g+d,S=lu({panelConstraints:n,panelIndex:h,size:v});if(s[h]=S,!Ia(S,v)){let w=v-S,_=e<0?u:c;for(;_>=0&&_<n.length;){const E=s[_];Tt(E!=null,`Previous layout not found for panel index ${_}`);const k=E+w,R=lu({panelConstraints:n,panelIndex:_,size:k});if(Ia(E,R)||(w-=R-E,s[_]=R),Ia(w,0))break;e>0?_--:_++}}}const m=s.reduce((h,g)=>g+h,0);return Ia(m,100)?s:r}function p_e({layout:e,panelsArray:t,pivotIndices:n}){let a=0,r=100,i=0,s=0;const c=n[0];Tt(c!=null,"No pivot index found"),t.forEach((h,g)=>{const{constraints:v}=h,{maxSize:S=100,minSize:w=0}=v;g===c?(a=w,r=S):(i+=w,s+=S)});const u=Math.min(r,100-i),d=Math.max(a,100-s),m=e[c];return{valueMax:u,valueMin:d,valueNow:m}}function kp(e,t=document){return Array.from(t.querySelectorAll(`[${Wn.resizeHandleId}][data-panel-group-id="${e}"]`))}function zK(e,t,n=document){const r=kp(e,n).findIndex(i=>i.getAttribute(Wn.resizeHandleId)===t);return r??null}function FK(e,t,n){const a=zK(e,t,n);return a!=null?[a,a+1]:[-1,-1]}function m_e(e){return e instanceof HTMLElement?!0:typeof e=="object"&&e!==null&&"tagName"in e&&"getAttribute"in e}function BK(e,t=document){if(m_e(t)&&t.dataset.panelGroupId==e)return t;const n=t.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return n||null}function Uy(e,t=document){const n=t.querySelector(`[${Wn.resizeHandleId}="${e}"]`);return n||null}function h_e(e,t,n,a=document){var r,i,s,c;const u=Uy(t,a),d=kp(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 g_e({committedValuesRef:e,eagerValuesRef:t,groupId:n,layout:a,panelDataArray:r,panelGroupElement:i,setLayout:s}){x.useRef({didWarnAboutMissingResizeHandle:!1}),Cl(()=>{if(!i)return;const c=kp(n,i);for(let u=0;u<r.length-1;u++){const{valueMax:d,valueMin:m,valueNow:h}=p_e({layout:a,panelsArray:r,pivotIndices:[u,u+1]}),g=c[u];if(g!=null){const v=r[u];Tt(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;Tt(c,"Eager values not found");const{panelDataArray:u}=c,d=BK(n,i);Tt(d!=null,`No group found for id "${n}"`);const m=kp(n,i);Tt(m,`No resize handles found for group id "${n}"`);const h=m.map(g=>{const v=g.getAttribute(Wn.resizeHandleId);Tt(v,"Resize handle element has no handle id attribute");const[S,w]=h_e(n,v,u,i);if(S==null||w==null)return()=>{};const y=_=>{if(!_.defaultPrevented)switch(_.key){case"Enter":{_.preventDefault();const E=u.findIndex(k=>k.id===S);if(E>=0){const k=u[E];Tt(k,`No panel data found for index ${E}`);const R=a[E],{collapsedSize:C=0,collapsible:I,minSize:A=0}=k.constraints;if(R!=null&&I){const O=Af({delta:Ia(R,C)?A-C:C-R,initialLayout:a,panelConstraints:u.map(M=>M.constraints),pivotIndices:FK(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 $4(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 HK(e,t){const n=e==="horizontal",{x:a,y:r}=$y(t);return n?a:r}function b_e(e,t,n,a,r){const i=n==="horizontal",s=Uy(t,r);Tt(s,`No resize handle element found for id "${t}"`);const c=s.getAttribute(Wn.groupId);Tt(c,"Resize handle element has no group id attribute");let{initialCursorPosition:u}=a;const d=HK(n,e),m=BK(c,r);Tt(m,`No group element found for id "${c}"`);const h=m.getBoundingClientRect(),g=i?h.width:h.height;return(d-u)/g*100}function v_e(e,t,n,a,r,i){if(IK(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:b_e(e,t,n,a,i)}function y_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];Tt(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];Tt(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 zc(e,t,n){t.forEach((a,r)=>{const i=e[r];Tt(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:S}=s;S&&S(a,h),m&&(g||v)&&(v&&(h==null||wo(h,d))&&!wo(a,d)&&v(),g&&(h==null||!wo(h,d))&&wo(a,d)&&g())}})}function zg(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 w_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 x_e(e,t=10){let n=null;return(...r)=>{n!==null&&clearTimeout(n),n=setTimeout(()=>{e(...r)},t)}}function M4(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 VK(e){return`react-resizable-panels:${e}`}function GK(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 WK(e,t){try{const n=VK(e),a=t.getItem(n);if(a){const r=JSON.parse(a);if(typeof r=="object"&&r!=null)return r}}catch{}return null}function S_e(e,t,n){var a,r;const i=(a=WK(e,n))!==null&&a!==void 0?a:{},s=GK(t);return(r=i[s])!==null&&r!==void 0?r:null}function E_e(e,t,n,a,r){var i;const s=VK(e),c=GK(t),u=(i=WK(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 P4({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(!Ia(a,100)&&n.length>0)for(let i=0;i<t.length;i++){const s=n[i];Tt(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];Tt(s!=null,`No layout data found for index ${i}`);const c=lu({panelConstraints:t,panelIndex:i,size:s});s!=c&&(r+=s-c,n[i]=c)}if(!Ia(r,0))for(let i=0;i<t.length;i++){const s=n[i];Tt(s!=null,`No layout data found for index ${i}`);const c=s+r,u=lu({panelConstraints:t,panelIndex:i,size:c});if(s!==u&&(r-=u-s,n[i]=u,Ia(r,0)))break}return n}const __e=100,If={getItem:e=>(M4(If),If.getItem(e)),setItem:(e,t)=>{M4(If),If.setItem(e,t)}},U4={};function KK({autoSaveId:e=null,children:t,className:n="",direction:a,forwardedRef:r,id:i=null,onLayout:s=null,keyboardResizeBy:c=null,storage:u=If,style:d,tagName:m="div",...h}){const g=RO(i),v=x.useRef(null),[S,w]=x.useState(null),[y,_]=x.useState([]),E=d_e(),k=x.useRef({}),R=x.useRef(new Map),C=x.useRef(0),I=x.useRef({autoSaveId:e,direction:a,dragState:S,id:g,keyboardResizeBy:c,onLayout:s,storage:u}),A=x.useRef({layout:y,panelDataArray:[],panelDataArrayChanged:!1});x.useRef({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),x.useImperativeHandle(r,()=>({getId:()=>I.current.id,getLayout:()=>{const{layout:z}=A.current;return z},setLayout:z=>{const{onLayout:L}=I.current,{layout:$,panelDataArray:F}=A.current,W=P4({layout:z,panelConstraints:F.map(X=>X.constraints)});$4($,W)||(_(W),A.current.layout=W,L&&L(W),zc(F,W,k.current))}}),[]),Cl(()=>{I.current.autoSaveId=e,I.current.direction=a,I.current.dragState=S,I.current.id=g,I.current.onLayout=s,I.current.storage=u}),g_e({committedValuesRef:I,eagerValuesRef:A,groupId:g,layout:y,panelDataArray:A.current.panelDataArray,setLayout:_,panelGroupElement:v.current}),x.useEffect(()=>{const{panelDataArray:z}=A.current;if(e){if(y.length===0||y.length!==z.length)return;let L=U4[e];L==null&&(L=x_e(E_e,__e),U4[e]=L);const $=[...z],F=new Map(R.current);L(e,$,F,y,u)}},[e,y,u]),x.useEffect(()=>{});const O=x.useCallback(z=>{const{onLayout:L}=I.current,{layout:$,panelDataArray:F}=A.current;if(z.constraints.collapsible){const W=F.map(Q=>Q.constraints),{collapsedSize:X=0,panelSize:ae,pivotIndices:le}=ml(F,z,$);if(Tt(ae!=null,`Panel size not found for panel "${z.id}"`),!wo(ae,X)){R.current.set(z.id,ae);const q=qc(F,z)===F.length-1?ae-X:X-ae,se=Af({delta:q,initialLayout:$,panelConstraints:W,pivotIndices:le,prevLayout:$,trigger:"imperative-api"});zg($,se)||(_(se),A.current.layout=se,L&&L(se),zc(F,se,k.current))}}},[]),M=x.useCallback((z,L)=>{const{onLayout:$}=I.current,{layout:F,panelDataArray:W}=A.current;if(z.constraints.collapsible){const X=W.map(he=>he.constraints),{collapsedSize:ae=0,panelSize:le=0,minSize:Q=0,pivotIndices:q}=ml(W,z,F),se=L??Q;if(wo(le,ae)){const he=R.current.get(z.id),ce=he!=null&&he>=se?he:se,He=qc(W,z)===W.length-1?le-ce:ce-le,Se=Af({delta:He,initialLayout:F,panelConstraints:X,pivotIndices:q,prevLayout:F,trigger:"imperative-api"});zg(F,Se)||(_(Se),A.current.layout=Se,$&&$(Se),zc(W,Se,k.current))}}},[]),U=x.useCallback(z=>{const{layout:L,panelDataArray:$}=A.current,{panelSize:F}=ml($,z,L);return Tt(F!=null,`Panel size not found for panel "${z.id}"`),F},[]),H=x.useCallback((z,L)=>{const{panelDataArray:$}=A.current,F=qc($,z);return w_e({defaultSize:L,dragState:S,layout:y,panelData:$,panelIndex:F})},[S,y]),K=x.useCallback(z=>{const{layout:L,panelDataArray:$}=A.current,{collapsedSize:F=0,collapsible:W,panelSize:X}=ml($,z,L);return Tt(X!=null,`Panel size not found for panel "${z.id}"`),W===!0&&wo(X,F)},[]),ee=x.useCallback(z=>{const{layout:L,panelDataArray:$}=A.current,{collapsedSize:F=0,collapsible:W,panelSize:X}=ml($,z,L);return Tt(X!=null,`Panel size not found for panel "${z.id}"`),!W||Bl(X,F)>0},[]),J=x.useCallback(z=>{const{panelDataArray:L}=A.current;L.push(z),L.sort(($,F)=>{const W=$.order,X=F.order;return W==null&&X==null?0:W==null?-1:X==null?1:W-X}),A.current.panelDataArrayChanged=!0,E()},[E]);Cl(()=>{if(A.current.panelDataArrayChanged){A.current.panelDataArrayChanged=!1;const{autoSaveId:z,onLayout:L,storage:$}=I.current,{layout:F,panelDataArray:W}=A.current;let X=null;if(z){const le=S_e(z,W,$);le&&(R.current=new Map(Object.entries(le.expandToSizes)),X=le.layout)}X==null&&(X=y_e({panelDataArray:W}));const ae=P4({layout:X,panelConstraints:W.map(le=>le.constraints)});$4(F,ae)||(_(ae),A.current.layout=ae,L&&L(ae),zc(W,ae,k.current))}}),Cl(()=>{const z=A.current;return()=>{z.layout=[]}},[]);const ie=x.useCallback(z=>{let L=!1;const $=v.current;return $&&window.getComputedStyle($,null).getPropertyValue("direction")==="rtl"&&(L=!0),function(W){W.preventDefault();const X=v.current;if(!X)return()=>null;const{direction:ae,dragState:le,id:Q,keyboardResizeBy:q,onLayout:se}=I.current,{layout:he,panelDataArray:ce}=A.current,{initialLayout:ke}=le??{},He=FK(Q,z,X);let Se=v_e(W,z,ae,le,q,X);const _e=ae==="horizontal";_e&&L&&(Se=-Se);const Ue=ce.map(Fe=>Fe.constraints),fe=Af({delta:Se,initialLayout:ke??he,panelConstraints:Ue,pivotIndices:He,prevLayout:he,trigger:IK(W)?"keyboard":"mouse-or-touch"}),Ie=!zg(he,fe);(OK(W)||DK(W))&&C.current!=Se&&(C.current=Se,!Ie&&Se!==0?_e?fS(z,Se<0?LK:$K):fS(z,Se<0?MK:PK):fS(z,0)),Ie&&(_(fe),A.current.layout=fe,se&&se(fe),zc(ce,fe,k.current))}},[]),B=x.useCallback((z,L)=>{const{onLayout:$}=I.current,{layout:F,panelDataArray:W}=A.current,X=W.map(he=>he.constraints),{panelSize:ae,pivotIndices:le}=ml(W,z,F);Tt(ae!=null,`Panel size not found for panel "${z.id}"`);const q=qc(W,z)===W.length-1?ae-L:L-ae,se=Af({delta:q,initialLayout:F,panelConstraints:X,pivotIndices:le,prevLayout:F,trigger:"imperative-api"});zg(F,se)||(_(se),A.current.layout=se,$&&$(se),zc(W,se,k.current))},[]),Z=x.useCallback((z,L)=>{const{layout:$,panelDataArray:F}=A.current,{collapsedSize:W=0,collapsible:X}=L,{collapsedSize:ae=0,collapsible:le,maxSize:Q=100,minSize:q=0}=z.constraints,{panelSize:se}=ml(F,z,$);se!=null&&(X&&le&&wo(se,W)?wo(W,ae)||B(z,ae):se<q?B(z,q):se>Q&&B(z,Q))},[B]),G=x.useCallback((z,L)=>{const{direction:$}=I.current,{layout:F}=A.current;if(!v.current)return;const W=Uy(z,v.current);Tt(W,`Drag handle element not found for id "${z}"`);const X=HK($,L);w({dragHandleId:z,dragHandleRect:W.getBoundingClientRect(),initialCursorPosition:X,initialLayout:F})},[]),re=x.useCallback(()=>{w(null)},[]),ne=x.useCallback(z=>{const{panelDataArray:L}=A.current,$=qc(L,z);$>=0&&(L.splice($,1),delete k.current[z.id],A.current.panelDataArrayChanged=!0,E())},[E]),j=x.useMemo(()=>({collapsePanel:O,direction:a,dragState:S,expandPanel:M,getPanelSize:U,getPanelStyle:H,groupId:g,isPanelCollapsed:K,isPanelExpanded:ee,reevaluatePanelConstraints:Z,registerPanel:J,registerResizeHandle:ie,resizePanel:B,startDragging:G,stopDragging:re,unregisterPanel:ne,panelGroupElement:v.current}),[O,S,a,M,U,H,g,K,ee,Z,J,ie,B,G,re,ne]),V={display:"flex",flexDirection:a==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return x.createElement(Ly.Provider,{value:j},x.createElement(m,{...h,children:t,className:n,id:i,ref:v,style:{...V,...d},[Wn.group]:"",[Wn.groupDirection]:a,[Wn.groupId]:g}))}const ZK=x.forwardRef((e,t)=>x.createElement(KK,{...e,forwardedRef:t}));KK.displayName="PanelGroup";ZK.displayName="forwardRef(PanelGroup)";function qc(e,t){return e.findIndex(n=>n===t||n.id===t.id)}function ml(e,t,n){const a=qc(e,t),i=a===e.length-1?[a-1,a]:[a,a+1],s=n[a];return{...t.constraints,panelSize:s,pivotIndices:i}}function k_e({disabled:e,handleId:t,resizeHandler:n,panelGroupElement:a}){x.useEffect(()=>{if(e||n==null||a==null)return;const r=Uy(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);Tt(c,`No group element found for id "${c}"`);const u=kp(c,a),d=zK(c,t,a);Tt(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 YK({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",...S}){var w,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(Ly);if(k===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:R,groupId:C,registerResizeHandle:I,startDragging:A,stopDragging:O,panelGroupElement:M}=k,U=RO(r),[H,K]=x.useState("inactive"),[ee,J]=x.useState(!1),[ie,B]=x.useState(null),Z=x.useRef({state:H});Cl(()=>{Z.current.state=H}),x.useEffect(()=>{if(n)B(null);else{const j=I(U);B(()=>j)}},[n,U,I]);const G=(w=a?.coarse)!==null&&w!==void 0?w:15,re=(y=a?.fine)!==null&&y!==void 0?y:5;x.useEffect(()=>{if(n||ie==null)return;const j=_.current;Tt(j,"Element ref not attached");let V=!1;return c_e(U,j,R,{coarse:G,fine:re},(L,$,F)=>{if(!$){K("inactive");return}switch(L){case"down":{K("drag"),V=!1,Tt(F,'Expected event to be defined for "down" action'),A(U,F);const{onDragging:W,onPointerDown:X}=E.current;W?.(!0),X?.();break}case"move":{const{state:W}=Z.current;V=!0,W!=="drag"&&K("hover"),Tt(F,'Expected event to be defined for "move" action'),ie(F);break}case"up":{K("hover"),O();const{onClick:W,onDragging:X,onPointerUp:ae}=E.current;X?.(!1),ae?.(),V||W?.();break}}})},[G,R,n,re,I,U,ie,A,O]),k_e({disabled:n,handleId:U,resizeHandler:ie,panelGroupElement:M});const ne={touchAction:"none",userSelect:"none"};return x.createElement(v,{...S,children:e,className:t,id:r,onBlur:()=>{J(!1),i?.()},onFocus:()=>{J(!0),u?.()},ref:_,role:"separator",style:{...ne,...h},tabIndex:g,[Wn.groupDirection]:R,[Wn.groupId]:C,[Wn.resizeHandle]:"",[Wn.resizeHandleActive]:H==="drag"?"pointer":ee?"keyboard":void 0,[Wn.resizeHandleEnabled]:!n,[Wn.resizeHandleId]:U,[Wn.resizeHandleState]:H})}YK.displayName="PanelResizeHandle";function Jr({className:e,...t}){return f.jsx(ZK,{"data-slot":"resizable-panel-group",className:De("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...t})}function Rn({...e}){return f.jsx(AK,{"data-slot":"resizable-panel",...e})}function bi({withHandle:e,className:t,...n}){return f.jsx(YK,{"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&&f.jsx("div",{className:"bg-border z-10 flex h-4 w-3 items-center justify-center rounded-xs border",children:f.jsx(ppe,{className:"size-2.5"})})})}function gm({className:e,...t}){return f.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 T_e({isSearchExpanded:e,searchQuery:t,filteredNotificationsCount:n,notificationsCount:a,onSearchExpand:r,onSearchChange:i,onSearchBlur:s,onClearAll:c,searchInputRef:u}){return f.jsxs("div",{className:"flex flex-row items-center justify-between p-4 sm:p-4 py-3 gap-2",children:[f.jsx("div",{className:"flex items-center gap-2 flex-1",children:e?f.jsx(kn,{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"}):f.jsxs(f.Fragment,{children:[f.jsx("h2",{className:"text-lg font-medium text-gray-900 dark:text-gray-100",children:"Notifications"}),f.jsx(xr,{className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",variant:"outline",children:n}),f.jsxs($t,{children:[f.jsx(Mt,{asChild:!0,children:f.jsx(je,{variant:"ghost",size:"sm",onClick:r,className:"h-8 w-8 p-0",children:f.jsx(sd,{className:"h-4 w-4"})})}),f.jsxs(Pt,{side:"bottom",className:"flex gap-2",children:["Search",f.jsx(gm,{children:"F"})]})]})]})}),f.jsx("div",{className:"flex items-center gap-2",children:f.jsxs($t,{children:[f.jsx(Mt,{asChild:!0,children:f.jsx(je,{variant:"ghost",size:"sm",onClick:c,disabled:a===0,className:"h-8 w-8 p-0",children:f.jsx(Os,{className:"h-4 w-4"})})}),f.jsx(Pt,{side:"bottom",children:"Clear all"})]})})]})}function Vs({id:e,isSelected:t,isFocused:n,icon:a,title:r,description:i,metadata:s,onClick:c,className:u}){return f.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:f.jsxs("div",{className:"flex items-start gap-2 sm:gap-3",children:[a&&f.jsx("div",{className:"flex-shrink-0 mt-1",children:f.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})}),f.jsxs("div",{className:"flex-1 min-w-0",children:[f.jsx("div",{className:"flex items-center gap-2 mb-1",children:f.jsx("h3",{className:De("font-medium truncate font-mono text-sm"),children:r})}),i&&f.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 line-clamp-2",children:i})]})]})})}function N_e({notifications:e,selectedNotification:t,onNotificationSelect:n,focusedIndex:a,formatRelativeTime:r,listRef:i}){return e.length===0?f.jsx("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:f.jsx(od,{vertical:!0,noBorder:!0,message:"No notifications yet"})}):f.jsx("div",{ref:i,className:"overflow-y-auto flex-1 overscroll-contain",children:e.map((s,c)=>f.jsx(Vs,{id:`notification-${s.id}`,isSelected:t?.id===s.id,isFocused:a===c,title:f.jsxs("span",{className:"flex items-center gap-3",children:[s.method,!s.read&&f.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 C_e({notification:e,previewMode:t,onTogglePreview:n,onCopy:a,onDownload:r,onFullscreen:i,isCopied:s=!1,onClose:c}){return e?f.jsxs("div",{className:"flex flex-col h-full",children:[f.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:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx(Pu,{className:"h-3 w-3 text-gray-400"}),f.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:new Date(e.timestamp).toLocaleTimeString()})]}),f.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:e.formatRelativeTime(e.timestamp)})]}),f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsxs(je,{variant:"ghost",size:"sm",onClick:n,className:t?"":"text-purple-600 dark:text-purple-400",children:[t?f.jsx(B9,{className:"h-4 w-4 mr-1"}):f.jsx(F9,{className:"h-4 w-4 mr-1"}),t?"JSON":"Formatted"]}),f.jsx(je,{variant:"ghost",size:"sm",onClick:a,children:s?f.jsx(ga,{className:"h-4 w-4"}):f.jsx(Br,{className:"h-4 w-4"})}),f.jsx(je,{variant:"ghost",size:"sm",onClick:r,children:f.jsx(Qp,{className:"h-4 w-4"})}),f.jsx(je,{variant:"ghost",size:"sm",onClick:i,children:f.jsx(oN,{className:"h-4 w-4"})}),c&&f.jsx(je,{variant:"ghost",size:"sm",onClick:c,children:f.jsx(Wi,{className:"h-4 w-4"})})]})]}),f.jsx("div",{className:"flex-1 overflow-y-auto",children:f.jsx("div",{className:"px-4 pt-4",children:f.jsx(Jn,{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`})})})]}):f.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[f.jsx(nN,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),f.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"Select a notification to view details"})]})}function hv(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 R_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,S]=x.useState(!0),[w,y]=x.useState(!1),[_,E]=x.useState(!0),[k,R]=x.useState(!1),C=x.useRef(null),I=x.useRef(null),A=x.useRef(null),O=x.useRef(!1);x.useEffect(()=>{v&&e.length>0&&C.current&&!O.current&&(C.current.scrollTop=0)},[e.length,v]),x.useEffect(()=>{const Z=C.current;if(!Z)return;const G=()=>{Z.scrollTop>0&&(O.current=!0,S(!1))};return Z.addEventListener("scroll",G),()=>Z.removeEventListener("scroll",G)},[]),x.useEffect(()=>{e.length===0&&(O.current=!1,S(!0))},[e.length]),x.useEffect(()=>{c&&!c.read&&n(c.id)},[c,n]),x.useEffect(()=>{w&&A.current&&A.current.focus()},[w]);const M=x.useCallback(()=>{d.trim()||y(!1)},[d]),U=x.useMemo(()=>{if(!d.trim())return e;const Z=d.toLowerCase();return e.filter(G=>G.method.toLowerCase().includes(Z)||JSON.stringify(G.params||{}).toLowerCase().includes(Z))},[e,d]);x.useEffect(()=>{g(-1)},[d]),x.useEffect(()=>{const Z=G=>{const re=G.target;if(re.tagName==="INPUT"||re.tagName==="TEXTAREA"||re.contentEditable==="true"||G.metaKey||G.ctrlKey||G.altKey)return;const j=U;if(G.key==="ArrowDown")G.preventDefault(),g(V=>{const z=V+1;return z>=j.length?0:z});else if(G.key==="ArrowUp")G.preventDefault(),g(V=>{const z=V-1;return z<0?j.length-1:z});else if(G.key==="Enter"&&h>=0){G.preventDefault();const V=U[h];V&&H(V)}};return document.addEventListener("keydown",Z),()=>document.removeEventListener("keydown",Z)},[h,U]),x.useEffect(()=>{if(h>=0){const Z=`notification-${U[h]?.id}`,G=document.getElementById(Z);G&&G.scrollIntoView({behavior:"smooth",block:"nearest"})}},[h,U]);const H=x.useCallback(Z=>{u(Z)},[]),K=x.useCallback(()=>{window.confirm("Are you sure you want to clear all notifications? This cannot be undone.")&&(r(),u(null))},[r]),ee=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)),R(!0),setTimeout(()=>R(!1),2e3)}catch(Z){console.error("[NotificationsTab] Failed to copy notification:",Z)}},[c]),J=x.useCallback(()=>{if(c)try{const Z=new globalThis.Blob([JSON.stringify({method:c.method,timestamp:c.timestamp,read:c.read,params:c.params},null,2)],{type:"application/json"}),G=URL.createObjectURL(Z),re=document.createElement("a");re.href=G,re.download=`notification-${Date.now()}.json`,document.body.appendChild(re),re.click(),document.body.removeChild(re),URL.revokeObjectURL(G)}catch(Z){console.error("[NotificationsTab] Failed to download notification:",Z)}},[c]),ie=x.useCallback(async()=>{if(I.current)try{document.fullscreenElement?await document.exitFullscreen():await I.current.requestFullscreen()}catch(Z){console.error("[NotificationsTab] Failed to toggle fullscreen:",Z)}},[]),B=c?{method:c.method,params:c.params,timestamp:c.timestamp,read:c.read,formatRelativeTime:hv}:null;return s?f.jsxs(Jr,{direction:"horizontal",className:"h-full",children:[f.jsx(Rn,{defaultSize:40,minSize:30,children:f.jsx(Jr,{direction:"vertical",className:"h-full border-r dark:border-zinc-700",children:f.jsxs(Rn,{defaultSize:75,minSize:30,children:[f.jsx(T_e,{isSearchExpanded:w,searchQuery:d,filteredNotificationsCount:U.length,notificationsCount:e.length,onSearchExpand:()=>y(!0),onSearchChange:m,onSearchBlur:M,onClearAll:K,searchInputRef:A}),f.jsx("div",{className:"flex flex-col h-full",children:f.jsx(N_e,{notifications:U,selectedNotification:c,onNotificationSelect:H,focusedIndex:h,formatRelativeTime:hv,listRef:C})})]})})}),f.jsx(bi,{}),f.jsx(Rn,{defaultSize:60,minSize:40,children:f.jsx("div",{ref:I,className:"h-full bg-white dark:bg-zinc-900",children:f.jsx(C_e,{notification:B,previewMode:_,onTogglePreview:()=>E(!_),onCopy:ee,onDownload:J,onFullscreen:ie,onClose:()=>u(null),isCopied:k})})})]}):f.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[f.jsx(nN,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),f.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"Not connected to server"})]})}function qK({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:S,primaryTabName:w}){const y=e===w;return f.jsxs("div",{className:"flex flex-row items-center justify-between p-4 sm:p-4 py-3 gap-2",children:[f.jsx("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:t?f.jsx(kn,{ref:S,placeholder:d,value:n,onChange:_=>h(_.target.value),onBlur:g,className:"h-8 border-gray-300 dark:border-zinc-600"}):f.jsxs(f.Fragment,{children:[f.jsx("h2",{className:"text-lg font-medium text-gray-900 dark:text-gray-100",children:y?a:r}),y&&f.jsxs(f.Fragment,{children:[f.jsx(xr,{className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",variant:"outline",children:i}),f.jsxs($t,{children:[f.jsx(Mt,{asChild:!0,children:f.jsx(je,{variant:"ghost",size:"sm",onClick:m,className:"h-8 w-8 p-0",children:f.jsx(sd,{className:"h-4 w-4"})})}),f.jsxs(Pt,{side:"bottom",className:"flex gap-2",children:["Search",f.jsx(gm,{children:"F"})]})]})]})]})}),f.jsxs(je,{variant:"ghost",size:"sm",onClick:v,className:"gap-2 flex-shrink-0",children:[y?f.jsx(c,{}):f.jsx(u,{}),f.jsx("span",{className:"hidden sm:inline",children:y?r:a}),y&&s>0&&f.jsx(xr,{className:"bg-purple-500/20 text-purple-600 dark:text-purple-400 border-transparent",variant:"outline",children:s})]})]})}function z4({prompts:e,selectedPrompt:t,onPromptSelect:n,focusedIndex:a}){return e.length===0?f.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[f.jsx(lp,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),f.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"No prompts available"})]}):f.jsx("div",{className:"overflow-y-auto flex-1 border-r dark:border-zinc-700 overscroll-contain",children:e.map((r,i)=>f.jsx(Vs,{id:`prompt-${r.name}`,isSelected:t?.name===r.name,isFocused:a===i,icon:f.jsx(lp,{className:"h-4 w-4"}),title:r.name,description:r.description,metadata:r.arguments&&r.arguments.length>0&&f.jsxs(xr,{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 F4({activeTab:e,isSearchExpanded:t,searchQuery:n,filteredPromptsCount:a,savedPromptsCount:r,onSearchExpand:i,onSearchChange:s,onSearchBlur:c,onTabSwitch:u,searchInputRef:d}){return f.jsx(qK,{activeTab:e,isSearchExpanded:t,searchQuery:n,primaryTabName:"prompts",secondaryTabName:"saved",primaryTabTitle:"Prompts",secondaryTabTitle:"History",primaryCount:a,secondaryCount:r,primaryIcon:lp,secondaryIcon:Pu,searchPlaceholder:"Search prompts...",onSearchExpand:i,onSearchChange:s,onSearchBlur:c,onTabSwitch:u,searchInputRef:d})}function B4({savedPrompts:e,selectedPrompt:t,onLoadPrompt:n,onDeletePrompt:a,focusedIndex:r}){return e.length===0?f.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[f.jsx(Pu,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),f.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"No history"}),f.jsx("p",{className:"text-sm text-gray-400 dark:text-gray-500 mt-1",children:"Prompts you execute will appear here"})]}):f.jsx("div",{className:"overflow-y-auto flex-1 border-r dark:border-zinc-700 overscroll-contain",children:e.map((i,s)=>f.jsx(Vs,{id:`saved-prompt-${i.id}`,isSelected:t?.id===i.id,isFocused:r===s,icon:f.jsx(Pu,{className:"h-4 w-4"}),title:i.name,description:`${i.promptName} - ${new Date(i.savedAt).toLocaleString()}`,onClick:()=>n(i)},i.id))})}function A_e({selectedPrompt:e,promptArgs:t,onArgChange:n}){const a=e?.arguments||[];if(!(a.length>0))return f.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"?f.jsxs("div",{className:"space-y-2",children:[f.jsxs(Kt,{htmlFor:c,className:"text-sm font-medium",children:[c,s.required&&f.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),f.jsxs("div",{className:"flex items-center space-x-2",children:[f.jsx("input",{id:c,type:"checkbox",checked:!!u,onChange:m=>n(c,m.target.checked),className:"rounded","aria-label":`Toggle ${c}`}),f.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:s.description})]})]},c):s.type==="number"?f.jsxs("div",{className:"space-y-2",children:[f.jsxs(Kt,{htmlFor:c,className:"text-sm font-medium",children:[c,s.required&&f.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),f.jsx(kn,{id:c,type:"number",value:Number(u)||0,onChange:m=>n(c,Number(m.target.value)),placeholder:s.description||`Enter ${c}`}),s.description&&f.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:s.description})]},c):s.type==="array"||s.type==="object"?f.jsxs("div",{className:"space-y-2",children:[f.jsxs(Kt,{htmlFor:c,className:"text-sm font-medium",children:[c,s.required&&f.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),f.jsx(zl,{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&&f.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:s.description})]},c):f.jsxs("div",{className:"space-y-2",children:[f.jsxs(Kt,{htmlFor:c,className:"text-sm font-medium",children:[c,s.required&&f.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),f.jsx(kn,{id:c,value:d,onChange:m=>n(c,m.target.value),placeholder:s.description||`Enter ${c}`}),s.description&&f.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:s.description})]},c)};return f.jsx("div",{className:"space-y-4",children:a.map(s=>i(s))})}function H4({selectedPrompt:e,promptArgs:t,isExecuting:n,isConnected:a,onArgChange:r,onExecute:i,onSave:s}){return e?f.jsxs("div",{className:"flex flex-col h-full",children:[f.jsx("div",{className:"flex-shrink-0 p-3 sm:p-6 pt-3 pb-4 pr-3",children:f.jsxs("div",{children:[f.jsxs("div",{className:"flex flex-row items-center justify-between mb-0 gap-2",children:[f.jsx("h3",{className:"text-base sm:text-lg font-semibold",children:e.name}),f.jsxs("div",{className:"flex gap-2 flex-shrink-0",children:[f.jsx(je,{onClick:i,disabled:n||!a,size:"sm",className:"lg:size-default",children:n?f.jsxs(f.Fragment,{children:[f.jsx(Hi,{className:"mr-2"}),f.jsx("span",{className:"hidden sm:inline",children:"Executing..."})]}):f.jsxs(f.Fragment,{children:[f.jsx(W9,{className:"h-4 w-4 sm:mr-2"}),f.jsx("span",{className:"hidden sm:inline",children:"Execute"})]})}),f.jsxs(je,{variant:"outline",onClick:s,disabled:n,size:"sm",className:"lg:size-default gap-2",children:[f.jsx(sN,{className:"h-4 w-4"}),f.jsx("span",{className:"hidden sm:inline",children:"Save"})]})]})]}),e.description&&f.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 leading-relaxed mt-2",children:e.description})]})}),f.jsx("div",{className:"flex-1 overflow-y-auto px-3 sm:px-6 pb-4 pr-3",children:f.jsx(A_e,{selectedPrompt:e,promptArgs:t,onArgChange:r})})]}):f.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[f.jsx("p",{className:"text-gray-500 dark:text-gray-400 mb-2",children:"Select a prompt to get started"}),f.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 V4({results:e,copiedResult:t,onCopy:n}){return f.jsx("div",{className:"flex flex-col h-full bg-white dark:bg-black border-t dark:border-zinc-700",children:f.jsx("div",{className:"flex-1 overflow-y-auto h-full",children:e.length>0?f.jsx("div",{className:"space-y-4 flex-1 h-full",children:e.map((a,r)=>f.jsxs("div",{className:"space-y-0 flex-1 h-full flex flex-col",children:[f.jsxs("div",{className:"flex items-center gap-2 px-4 pt-2 border-b border-gray-200 dark:border-zinc-600 pb-2",children:[f.jsx("h3",{className:"text-sm font-medium",children:"Response"}),f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx(Pu,{className:"h-3 w-3 text-gray-400"}),f.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:new Date(a.timestamp).toLocaleTimeString()})]}),a.duration!==void 0&&f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx(cp,{className:"h-3 w-3 text-gray-400"}),f.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:[a.duration,"ms"]})]}),f.jsx("div",{className:"flex gap-2 ml-auto",children:f.jsx(je,{variant:"ghost",size:"sm",onClick:()=>n(r,a.result),className:"h-6 px-2",children:t===r?f.jsx(ga,{className:"h-4 w-4"}):f.jsx(Br,{className:"h-4 w-4"})})})]}),a.error?f.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:[f.jsx("p",{className:"text-red-800 dark:text-red-300 font-medium",children:"Error:"}),f.jsx("p",{className:"text-red-700 dark:text-red-400 text-sm",children:a.error})]}):f.jsx("div",{className:"px-4 pt-4",children:f.jsx(Jn,{data:a.result,filename:`prompt-result-${a.promptName}-${Date.now()}.json`})})]},r))}):f.jsx("div",{className:"flex items-center justify-center h-full",children:f.jsx("div",{className:"text-center",children:f.jsx(od,{vertical:!0,noBorder:!0,message:"No Results yet"})})})})})}function IO({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(S=>{const w=new Set(S);return w.has(v)?w.delete(v):w.add(v),w})},m=async()=>{r([]),c(new Set),t?.(0);try{const v=new URLSearchParams;e&&e.length>0&&v.set("serverIds",e.join(","));const S=await fetch(`/inspector/api/rpc/log?${v.toString()}`,{method:"DELETE"});S.ok||console.warn("[RPC Logger] Failed to clear server buffer:",S.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 S=new URLSearchParams;S.set("replay","3"),S.set("_t",Date.now().toString()),e&&e.length>0&&S.set("serverIds",e.join(","));const w=`/inspector/api/rpc/stream?${S.toString()}`;console.log("[RPC Logger] Connecting to SSE stream:",w),v=new globalThis.EventSource(w),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:R,timestamp:C}=_,I=R,A=typeof I?.method=="string"?I.method:I?.result!==void 0?"result":I?.error!==void 0?"error":"unknown",O={id:`${C??Date.now()}-${Math.random().toString(36).slice(2)}`,serverId:typeof E=="string"?E:"unknown",direction:typeof k=="string"?k.toUpperCase():"",method:A,timestamp:C??new Date().toISOString(),payload:R};console.log("[RPC Logger] Received RPC event:",{method:A,direction:k,serverId:E}),r(M=>{const U=[O,...M].slice(0,1e3);return t?.(U.length),U})}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(S){console.error("[RPC Logger] Failed to create SSE connection:",S)}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 S=new Set(e);v=v.filter(w=>S.has(w.serverId))}if(u.trim()){const S=u.toLowerCase();v=v.filter(w=>w.serverId.toLowerCase().includes(S)||w.method.toLowerCase().includes(S)||w.direction.toLowerCase().includes(S)||JSON.stringify(w.payload).toLowerCase().includes(S))}return v},[a,u,e]);return f.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:f.jsx("div",{ref:i,className:"flex-1 min-h-0 overflow-y-auto",children:g.length===0?f.jsxs("div",{className:"text-center py-8",children:[f.jsx("div",{className:"text-xs text-muted-foreground",children:"No messages yet"}),f.jsx("div",{className:"text-[10px] text-muted-foreground mt-1",children:"JSON-RPC messages will appear here"})]}):g.map(v=>{const S=s.has(v.id);return f.jsxs("div",{className:"group hover:bg-muted/50 transition-all duration-200 overflow-hidden",children:[f.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:[f.jsx("div",{className:"flex-shrink-0",children:S?f.jsx(Kl,{className:"h-3 w-3 text-muted-foreground transition-transform"}):f.jsx(jfe,{className:"h-3 w-3 text-muted-foreground transition-transform"})}),f.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[f.jsx("span",{className:"text-muted-foreground font-mono text-xs",children:new Date(v.timestamp).toLocaleTimeString()}),f.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"?f.jsx(Sfe,{className:"h-3 w-3"}):f.jsx(_fe,{className:"h-3 w-3"})}),f.jsx("span",{className:"text-xs font-mono text-foreground truncate",children:v.method})]})]}),S&&f.jsx("div",{className:"border-t bg-muted/20",children:f.jsx("div",{className:"p-3",children:f.jsx("div",{className:"max-h-[40vh] overflow-auto rounded-sm bg-background/60 p-2",children:f.jsx(Jn,{data:v.payload})})})})]},v.id)})})})}const G4="mcp-inspector-saved-prompts";function XK({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}=Zl(),[h,g]=x.useState({}),[v,S]=x.useState([]),[w,y]=x.useState(!1),[_,E]=x.useState(null),[k,R]=x.useState(""),[C,I]=x.useState("prompts"),[A,O]=x.useState([]),[M,U]=x.useState(!1),[H,K]=x.useState(""),[ee,J]=x.useState(!1),[ie,B]=x.useState(-1),Z=x.useRef(null),[G,re]=x.useState(!1),[ne,j]=x.useState("list"),[V,z]=x.useState(0),[L,$]=x.useState(!0),F=x.useRef(null),W=x.useRef(null);x.useEffect(()=>{const Se=()=>{re(window.innerWidth<1024)};return Se(),window.addEventListener("resize",Se),()=>window.removeEventListener("resize",Se)},[]),x.useEffect(()=>{j(i?"detail":"list")},[i]),x.useEffect(()=>{G&&v.length>0&&!w&&j("response")},[v,w,G]),x.useImperativeHandle(e,()=>({focusSearch:()=>{J(!0),setTimeout(()=>{Z.current&&Z.current.focus()},0)},blurSearch:()=>{R(""),J(!1),Z.current&&Z.current.blur()}})),x.useEffect(()=>{try{const Se=localStorage.getItem(G4);if(Se){const _e=JSON.parse(Se);O(_e)}}catch(Se){console.error("[PromptsTab] Failed to load saved prompts:",Se)}},[]);const X=x.useCallback(Se=>{try{localStorage.setItem(G4,JSON.stringify(Se))}catch(_e){console.error("[PromptsTab] Failed to save prompts:",_e)}},[]);x.useEffect(()=>{ee&&Z.current&&Z.current.focus()},[ee]);const ae=x.useCallback(()=>{k.trim()||J(!1)},[k]),le=x.useMemo(()=>{if(!k.trim())return t;const Se=k.toLowerCase();return t.filter(_e=>_e.name.toLowerCase().includes(Se)||_e.description?.toLowerCase().includes(Se))},[t,k]),Q=x.useCallback(Se=>{s(Se);const _e={};Se.arguments&&Se.arguments.forEach(Ue=>{Ue.default!==void 0?_e[Ue.name]=Ue.default:Ue.type==="string"?_e[Ue.name]="":Ue.type==="number"?_e[Ue.name]=0:Ue.type==="boolean"?_e[Ue.name]=!1:Ue.type==="array"?_e[Ue.name]=[]:Ue.type==="object"&&(_e[Ue.name]={})}),g(_e)},[]),q=x.useCallback(Se=>{const _e=t.find(Ue=>Ue.name===Se.promptName);_e&&(s(_e),g(Se.args),u(Se))},[t]);x.useEffect(()=>{B(-1)},[k,C]),x.useEffect(()=>{const Se=_e=>{const Ue=_e.target;if(Ue.tagName==="INPUT"||Ue.tagName==="TEXTAREA"||Ue.contentEditable==="true"||_e.metaKey||_e.ctrlKey||_e.altKey)return;const Ie=C==="prompts"?le:A;if(_e.key==="ArrowDown")_e.preventDefault(),B(Fe=>{const xe=Fe+1;return xe>=Ie.length?0:xe});else if(_e.key==="ArrowUp")_e.preventDefault(),B(Fe=>{const xe=Fe-1;return xe<0?Ie.length-1:xe});else if(_e.key==="Enter"&&ie>=0)if(_e.preventDefault(),C==="prompts"){const Fe=le[ie];Fe&&Q(Fe)}else{const Fe=A[ie];Fe&&q(Fe)}};return document.addEventListener("keydown",Se),()=>document.removeEventListener("keydown",Se)},[ie,le,A,C,Q,q]),x.useEffect(()=>{if(ie>=0){const Se=C==="prompts"?`prompt-${le[ie]?.name}`:`saved-prompt-${A[ie]?.id}`,_e=document.getElementById(Se);_e&&_e.scrollIntoView({behavior:"smooth",block:"nearest"})}},[ie,le,A,C]),x.useEffect(()=>{if(console.warn("[PromptsTab] Auto-selection effect triggered:",{selectedPromptName:d,promptsCount:t.length,currentSelectedPrompt:i?.name}),d&&t.length>0){const Se=t.find(_e=>_e.name===d);if(console.warn("[PromptsTab] Prompt lookup result:",{selectedPromptName:d,promptFound:!!Se,promptName:Se?.name,shouldSelect:Se&&i?.name!==Se.name}),Se&&i?.name!==Se.name){console.warn("[PromptsTab] Selecting prompt:",Se.name),m(null);const _e=setTimeout(()=>{Q(Se);const Ue=document.getElementById(`prompt-${Se.name}`);Ue&&(console.warn("[PromptsTab] Scrolling to prompt element"),Ue.scrollIntoView({behavior:"smooth",block:"nearest"}))},100);return()=>clearTimeout(_e)}}},[d,t,i,Q,m]);const se=x.useCallback((Se,_e)=>{g(Ue=>({...Ue,[Se]:_e}))},[]),he=x.useCallback(async()=>{if(!i||w)return;y(!0);const Se=Date.now();try{const _e=await n(i.name,h),Ue=Date.now()-Se;yr.getInstance().capture(new oU({promptName:i.name,serverId:a,success:!0})).catch(()=>{}),S(Ie=>[{promptName:i.name,args:h,result:_e,timestamp:Se,duration:Ue},...Ie])}catch(_e){yr.getInstance().capture(new oU({promptName:i.name,serverId:a,success:!1,error:_e instanceof Error?_e.message:"Unknown error"})).catch(()=>{});const fe={promptName:i.name,args:h,result:null,error:_e instanceof Error?_e.message:String(_e),timestamp:Se,duration:Date.now()-Se};S(Ie=>[fe,...Ie])}finally{y(!1)}},[i,h,w,n,a]),ce=x.useCallback(async(Se,_e)=>{try{await navigator.clipboard.writeText(JSON.stringify(_e,null,2)),E(Se),setTimeout(()=>E(null),2e3)}catch(Ue){console.error("[PromptsTab] Failed to copy result:",Ue)}},[]),ke=x.useCallback(()=>{i&&(K(""),U(!0))},[i]),He=x.useCallback(Se=>{X(A.filter(_e=>_e.id!==Se)),c?.id===Se&&u(null)},[A,X,c]);return G?f.jsxs("div",{className:"h-full flex flex-col overflow-hidden relative bg-background",children:[ne!=="list"&&f.jsxs("div",{className:"flex items-center gap-2 p-2 border-b shrink-0 bg-background z-10",children:[f.jsx(je,{variant:"ghost",size:"sm",onClick:()=>{ne==="response"?j("detail"):(s(null),j("list"))},className:"p-0 h-8 w-8",children:f.jsx(rN,{className:"h-4 w-4"})}),f.jsxs("div",{className:"flex items-center text-sm font-medium",children:[f.jsx("button",{onClick:()=>{s(null),j("list")},className:"text-muted-foreground hover:text-foreground hover:underline cursor-pointer",children:"Prompts"}),ne!=="list"&&f.jsxs(f.Fragment,{children:[f.jsx("span",{className:"mx-2 text-muted-foreground",children:"/"}),f.jsx("button",{onClick:()=>{ne==="response"&&j("detail")},className:ne==="detail"?"text-foreground hover:underline":ne==="response"?"text-muted-foreground hover:text-foreground hover:underline cursor-pointer":"text-muted-foreground",children:"Execute"})]}),ne==="response"&&f.jsxs(f.Fragment,{children:[f.jsx("span",{className:"mx-2 text-muted-foreground",children:"/"}),f.jsx("span",{className:"text-foreground",children:"Response"})]})]})]}),f.jsx("div",{className:"flex-1 relative overflow-hidden",children:f.jsxs(py,{initial:!1,mode:"popLayout",children:[ne==="list"&&f.jsxs(ha.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:[f.jsx(F4,{activeTab:C,isSearchExpanded:ee,searchQuery:k,filteredPromptsCount:le.length,savedPromptsCount:A.length,onSearchExpand:()=>J(!0),onSearchChange:R,onSearchBlur:ae,onTabSwitch:()=>I(C==="prompts"?"saved":"prompts"),searchInputRef:Z}),C==="prompts"?f.jsx(z4,{prompts:le,selectedPrompt:i,onPromptSelect:Q,focusedIndex:ie}):f.jsx(B4,{savedPrompts:A,selectedPrompt:c,onLoadPrompt:q,onDeletePrompt:He,focusedIndex:ie})]},"list"),ne==="detail"&&f.jsx(ha.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:f.jsx(H4,{selectedPrompt:i,promptArgs:h,isExecuting:w,isConnected:r,onArgChange:se,onExecute:he,onSave:ke})},"detail"),ne==="response"&&f.jsx(ha.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:f.jsx(V4,{results:v,copiedResult:_,onCopy:ce})},"response")]})})]}):f.jsxs(Jr,{direction:"horizontal",className:"h-full",children:[f.jsx(Rn,{defaultSize:33,className:"flex flex-col h-full relative",children:f.jsxs(Jr,{direction:"vertical",className:"h-full border-r dark:border-zinc-700",children:[f.jsx(Rn,{defaultSize:75,minSize:30,children:f.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[f.jsx(F4,{activeTab:C,isSearchExpanded:ee,searchQuery:k,filteredPromptsCount:le.length,savedPromptsCount:A.length,onSearchExpand:()=>J(!0),onSearchChange:R,onSearchBlur:ae,onTabSwitch:()=>I(C==="prompts"?"saved":"prompts"),searchInputRef:Z}),C==="prompts"?f.jsx(z4,{prompts:le,selectedPrompt:i,onPromptSelect:Q,focusedIndex:ie}):f.jsx(B4,{savedPrompts:A,selectedPrompt:c,onLoadPrompt:q,onDeletePrompt:He,focusedIndex:ie})]})}),f.jsx(bi,{withHandle:!0}),f.jsxs(Rn,{ref:F,defaultSize:0,collapsible:!0,minSize:5,collapsedSize:5,onCollapse:()=>$(!0),onExpand:()=>$(!1),className:"flex flex-col border-t dark:border-zinc-700",children:[f.jsxs("div",{className:"group flex items-center justify-between p-3 shrink-0 cursor-pointer hover:bg-muted/50 transition-colors",onClick:Se=>{Se.preventDefault(),Se.stopPropagation(),L?(F.current?.resize(25),$(!1)):(F.current?.resize(5),$(!0))},children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("h3",{className:"text-sm font-medium",children:"RPC Messages"}),V>0&&f.jsx(xr,{variant:"secondary",className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",children:V}),V>0&&!L&&f.jsx(je,{variant:"ghost",size:"sm",onClick:Se=>{Se.preventDefault(),Se.stopPropagation(),W.current?.()},className:"h-6 w-6 p-0",title:"Clear all messages",children:f.jsx(Os,{className:"h-3.5 w-3.5"})})]}),f.jsx(Kl,{className:`h-4 w-4 text-muted-foreground transition-transform ${L?"rotate-180":""}`})]}),!L&&f.jsx("div",{className:"flex-1 overflow-hidden min-h-0",children:f.jsx(IO,{serverIds:[a],onCountChange:z,onClearRef:W})})]})]})}),f.jsx(bi,{withHandle:!0}),f.jsx(Rn,{defaultSize:67,children:f.jsxs(Jr,{direction:"vertical",children:[f.jsx(Rn,{defaultSize:40,children:f.jsx(H4,{selectedPrompt:i,promptArgs:h,isExecuting:w,isConnected:r,onArgChange:se,onExecute:he,onSave:ke})}),f.jsx(bi,{withHandle:!0}),f.jsx(Rn,{defaultSize:50,children:f.jsx("div",{className:"flex flex-col h-full",children:f.jsx(V4,{results:v,copiedResult:_,onCopy:ce})})})]})})]})}XK.displayName="PromptsTab";function bu(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 I_e(e){return{uri:e.uri,mimeType:e.mimeType,text:e.text,blob:e.blob}}function JK({resource:e,onUIAction:t,className:n}){const a=async i=>t?.(i),r=I_e(e);return f.jsx("div",{className:n,children:f.jsx(NO,{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:[HEe,BEe,VEe,GEe],library:TO}})})}function W4({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(w=>w.startsWith("openai/")),h=e.resourceAnnotations["openai/outputTemplate"]),e?.result?.contents?.[0]?._meta){const w=e.result.contents[0]._meta,y=Object.keys(w).filter(_=>_.startsWith("openai/"));y.length>0&&(m=[...m,...y]),!h&&w["openai/outputTemplate"]&&(h=w["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 f.jsx("div",{className:"flex absolute left-0 top-0 items-center justify-center w-full h-full",children:f.jsx(Hi,{className:"size-5"})});if(!e)return f.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[f.jsx("p",{className:"text-gray-500 dark:text-gray-400 mb-2",children:"Select a resource to view its contents"}),f.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 f.jsx("div",{className:"p-4",children:f.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded p-3",children:[f.jsx("p",{className:"text-red-800 dark:text-red-300 font-medium",children:"Error:"}),f.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(w=>w.mimeType&&bu(w)),S=v?e.result.contents.filter(w=>w.mimeType&&bu(w)):[];return f.jsxs("div",{className:"flex flex-col h-full",children:[f.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:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx(Pu,{className:"h-3 w-3 text-gray-400"}),f.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:new Date(e.timestamp).toLocaleTimeString()})]}),(()=>{const w=e?.duration??e.result?.duration??e.result?.metrics?.durationMs;return w!==void 0?f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx(cp,{className:"h-3 w-3 text-gray-400"}),f.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:[w,"ms"]})]}):null})(),v&&f.jsx(xr,{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&&f.jsx(xr,{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"})]}),f.jsxs("div",{className:"flex items-center gap-1",children:[(v||g)&&f.jsxs(je,{variant:"ghost",size:"sm",onClick:i,className:n?"":"text-purple-600 dark:text-purple-400",children:[n?f.jsx(B9,{className:"h-4 w-4 mr-1"}):f.jsx(F9,{className:"h-4 w-4 mr-1"}),n?"JSON":g?"Component":"Preview"]}),f.jsx(je,{variant:"ghost",size:"sm",onClick:s,children:d?f.jsx(ga,{className:"h-4 w-4"}):f.jsx(Br,{className:"h-4 w-4"})}),f.jsx(je,{variant:"ghost",size:"sm",onClick:c,children:f.jsx(Qp,{className:"h-4 w-4"})}),f.jsx(je,{variant:"ghost",size:"sm",onClick:u,children:f.jsx(oN,{className:"h-4 w-4"})})]})]}),f.jsx("div",{className:"flex-1 overflow-y-auto",children:g&&a&&r&&h?n?f.jsx("div",{className:"flex-1 h-full",children:f.jsx(xO,{componentUrl:h,toolName:e.uri,toolArgs:{},toolResult:e.result,serverId:a,readResource:r,className:"w-full h-full relative flex p-4"})}):f.jsx("div",{className:"px-4 pt-4",children:f.jsx(Jn,{data:e.result,filename:`resource-${e.uri.replace(/[^a-zA-Z0-9]/g,"-")}-${Date.now()}.json`})}):v?n?f.jsxs("div",{className:"space-y-0 h-full",children:[S.map((w,y)=>f.jsx("div",{className:"mx-0 size-full",children:f.jsx("div",{className:"w-full h-full",children:f.jsx(JK,{resource:w,className:"w-full h-full"})})},`mcp-ui-${w.uri||`resource-${Date.now()}-${Math.random()}`}`)),(()=>{if(e.result.contents&&Array.isArray(e.result.contents)){const w=e.result.contents.filter(y=>!(y.mimeType&&bu(y)));if(w.length>0)return f.jsx("div",{className:"px-4",children:f.jsx(Jn,{data:w,filename:`resource-${e.uri.replace(/[^a-zA-Z0-9]/g,"-")}-non-ui-${Date.now()}.json`})})}return null})()]}):f.jsx("div",{className:"px-4 pt-4",children:f.jsx(Jn,{data:e.result,filename:`resource-${e.uri.replace(/[^a-zA-Z0-9]/g,"-")}-mcp-ui-${Date.now()}.json`})}):f.jsx("div",{className:"px-4 pt-4",children:f.jsx(Jn,{data:e.result,filename:`resource-${e.uri.replace(/[^a-zA-Z0-9]/g,"-")}-${Date.now()}.json`})})})]})}function O_e(e,t){if(!e&&!t)return f.jsx(spe,{className:"h-5 w-5"});const n=(e||t||"").toLowerCase();return n.includes("image")?f.jsx(ape,{className:"h-5 w-5"}):n.includes("json")||n.includes("javascript")||n.includes("typescript")?f.jsx(npe,{className:"h-5 w-5"}):n.includes("html")||n.includes("xml")?f.jsx(dpe,{className:"h-5 w-5"}):n.includes("database")||n.includes("sql")?f.jsx(sy,{className:"h-5 w-5"}):f.jsx(aN,{className:"h-5 w-5"})}function K4({resources:e,selectedResource:t,onResourceSelect:n,focusedIndex:a}){return e.length===0?f.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[f.jsx(sy,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),f.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"No resources available"})]}):f.jsx("div",{className:"overflow-y-auto flex-1 overscroll-contain",children:e.map((r,i)=>{const s=O_e(r.mimeType,r.uri),c=[r.description,r.mimeType&&f.jsx("span",{className:"font-mono",children:r.mimeType},"mime")].filter(Boolean);return f.jsx(Vs,{id:`resource-${r.uri}`,isSelected:t?.uri===r.uri,isFocused:a===i,icon:s,title:r.name,description:c.length>0?f.jsxs("span",{className:"flex flex-col gap-1",children:[r.description&&f.jsx("span",{children:r.description}),r.mimeType&&f.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 Z4({isSearchExpanded:e,searchQuery:t,filteredResourcesCount:n,onSearchExpand:a,onSearchChange:r,onSearchBlur:i,searchInputRef:s}){return f.jsx("div",{className:"flex flex-row items-center justify-between p-4 sm:p-4 py-3 gap-2",children:f.jsx("div",{className:"flex items-center gap-2 flex-1",children:e?f.jsx(kn,{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"}):f.jsxs(f.Fragment,{children:[f.jsx("h2",{className:"text-lg font-medium text-gray-900 dark:text-gray-100",children:"Resources"}),f.jsx(xr,{className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",variant:"outline",children:n}),f.jsxs($t,{children:[f.jsx(Mt,{asChild:!0,children:f.jsx(je,{variant:"ghost",size:"sm",onClick:a,className:"h-8 w-8 p-0",children:f.jsx(sd,{className:"h-4 w-4"})})}),f.jsxs(Pt,{side:"bottom",className:"flex gap-2",children:["Search",f.jsx(gm,{children:"F"})]})]})]})})})}function QK({ref:e,resources:t,readResource:n,serverId:a,isConnected:r}){const[i,s]=x.useState(null),{selectedResourceUri:c,setSelectedResourceUri:u}=Zl(),[d,m]=x.useState(null),[h,g]=x.useState(!1),[v,S]=x.useState(""),[w]=x.useState("resources"),[y,_]=x.useState(!0),[E,k]=x.useState(!1),[R,C]=x.useState(-1),[I,A]=x.useState(!1),O=x.useRef(null),M=x.useRef(null),[U,H]=x.useState(!1),[K,ee]=x.useState("list"),[J,ie]=x.useState(0),[B,Z]=x.useState(!0),G=x.useRef(null),re=x.useRef(null);x.useEffect(()=>{const F=()=>{H(window.innerWidth<1024)};return F(),window.addEventListener("resize",F),()=>window.removeEventListener("resize",F)},[]),x.useEffect(()=>{ee(i?"detail":"list")},[i]),x.useImperativeHandle(e,()=>({focusSearch:()=>{k(!0),setTimeout(()=>{O.current&&O.current.focus()},0)},blurSearch:()=>{S(""),k(!1),O.current&&O.current.blur()}})),x.useEffect(()=>{E&&O.current&&O.current.focus()},[E]);const ne=x.useCallback(()=>{v.trim()||k(!1)},[v]),j=x.useMemo(()=>{if(!v)return t;const F=v.toLowerCase();return t.filter(W=>W.name.toLowerCase().includes(F)||W.description?.toLowerCase().includes(F)||W.uri.toLowerCase().includes(F))},[t,v]),V=x.useCallback(async F=>{if(s(F),r){g(!0);const W=Date.now();try{const X=await n(F.uri);yr.getInstance().capture(new iU({resourceUri:F.uri,serverId:a,success:!0})).catch(()=>{}),m({uri:F.uri,result:X,timestamp:W,resourceAnnotations:F.annotations})}catch(X){yr.getInstance().capture(new iU({resourceUri:F.uri,serverId:a,success:!1,error:X instanceof Error?X.message:"Unknown error"})).catch(()=>{}),m({uri:F.uri,result:null,error:X instanceof Error?X.message:"Unknown error",timestamp:W,resourceAnnotations:F.annotations})}finally{g(!1)}}},[n,a,r]);x.useEffect(()=>{C(-1)},[v,w]),x.useEffect(()=>{const F=W=>{const X=W.target;if(X.tagName==="INPUT"||X.tagName==="TEXTAREA"||X.contentEditable==="true"||W.metaKey||W.ctrlKey||W.altKey)return;const le=j;if(W.key==="ArrowDown")W.preventDefault(),C(Q=>{const q=Q+1;return q>=le.length?0:q});else if(W.key==="ArrowUp")W.preventDefault(),C(Q=>{const q=Q-1;return q<0?le.length-1:q});else if(W.key==="Enter"&&R>=0){W.preventDefault();const Q=j[R];Q&&V(Q)}};return document.addEventListener("keydown",F),()=>document.removeEventListener("keydown",F)},[R,j,V]),x.useEffect(()=>{if(R>=0){const F=`resource-${j[R]?.uri}`,W=document.getElementById(F);W&&W.scrollIntoView({behavior:"smooth",block:"nearest"})}},[R,j]),x.useEffect(()=>{if(c&&t.length>0){const F=t.find(W=>W.uri===c);F&&i?.uri!==F.uri&&(u(null),setTimeout(()=>{V(F);const W=document.getElementById(`resource-${F.uri}`);W&&W.scrollIntoView({behavior:"smooth",block:"nearest"})},100))}},[c,t,i,V,u]);const z=x.useCallback(async()=>{if(d)try{await navigator.clipboard.writeText(JSON.stringify(d.result,null,2)),A(!0),setTimeout(()=>A(!1),2e3)}catch(F){console.error("[ResourcesTab] Failed to copy result:",F)}},[d]),L=x.useCallback(()=>{if(d)try{const F=new globalThis.Blob([JSON.stringify(d.result,null,2)],{type:"application/json"}),W=URL.createObjectURL(F),X=document.createElement("a");X.href=W,X.download=`resource-${Date.now()}.json`,document.body.appendChild(X),X.click(),document.body.removeChild(X),URL.revokeObjectURL(W)}catch(F){console.error("[ResourcesTab] Failed to download result:",F)}},[d]),$=x.useCallback(async()=>{if(M.current)try{document.fullscreenElement?await document.exitFullscreen():await M.current.requestFullscreen()}catch(F){console.error("[ResourcesTab] Failed to toggle fullscreen:",F)}},[]);return U?f.jsxs("div",{className:"h-full flex flex-col overflow-hidden relative bg-background",children:[K!=="list"&&f.jsxs("div",{className:"flex items-center gap-2 p-2 border-b shrink-0 bg-background z-10",children:[f.jsx(je,{variant:"ghost",size:"sm",onClick:()=>{s(null),ee("list")},className:"p-0 h-8 w-8",children:f.jsx(rN,{className:"h-4 w-4"})}),f.jsxs("div",{className:"flex items-center text-sm font-medium",children:[f.jsx("button",{onClick:()=>{s(null),ee("list")},className:"text-muted-foreground hover:text-foreground hover:underline cursor-pointer",children:"Resources"}),K==="detail"&&f.jsxs(f.Fragment,{children:[f.jsx("span",{className:"mx-2 text-muted-foreground",children:"/"}),f.jsx("span",{className:"text-foreground",children:"Content"})]})]})]}),f.jsx("div",{className:"flex-1 relative overflow-hidden",children:f.jsxs(py,{initial:!1,mode:"popLayout",children:[K==="list"&&f.jsxs(ha.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:[f.jsx(Z4,{activeTab:w,isSearchExpanded:E,searchQuery:v,filteredResourcesCount:j.length,onSearchExpand:()=>k(!0),onSearchChange:S,onSearchBlur:ne,onTabSwitch:()=>{},searchInputRef:O}),f.jsx("div",{className:"flex flex-col h-full",children:f.jsx(K4,{resources:j,selectedResource:i,onResourceSelect:V,focusedIndex:R})})]},"list"),K==="detail"&&f.jsx(ha.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:f.jsx("div",{ref:M,className:"h-full",children:f.jsx(W4,{result:d,isLoading:h,previewMode:y,serverId:a,readResource:n,onTogglePreview:()=>_(!y),onCopy:z,onDownload:L,onFullscreen:$,isCopied:I})})},"detail")]})})]}):f.jsxs(Jr,{direction:"horizontal",className:"h-full",children:[f.jsx(Rn,{defaultSize:25,children:f.jsxs(Jr,{direction:"vertical",className:"h-full border-r dark:border-zinc-700",children:[f.jsx(Rn,{defaultSize:75,minSize:30,children:f.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[f.jsx(Z4,{activeTab:w,isSearchExpanded:E,searchQuery:v,filteredResourcesCount:j.length,onSearchExpand:()=>k(!0),onSearchChange:S,onSearchBlur:ne,onTabSwitch:()=>{},searchInputRef:O}),f.jsx(K4,{resources:j,selectedResource:i,onResourceSelect:V,focusedIndex:R})]})}),f.jsx(bi,{withHandle:!0}),f.jsxs(Rn,{ref:G,defaultSize:0,collapsible:!0,minSize:5,collapsedSize:5,onCollapse:()=>Z(!0),onExpand:()=>Z(!1),className:"flex flex-col border-t dark:border-zinc-700",children:[f.jsxs("div",{className:"group flex items-center justify-between p-3 shrink-0 cursor-pointer hover:bg-muted/50 transition-colors",onClick:F=>{F.preventDefault(),F.stopPropagation(),B?(G.current?.resize(25),Z(!1)):(G.current?.resize(5),Z(!0))},children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("h3",{className:"text-sm font-medium",children:"RPC Messages"}),J>0&&f.jsx(xr,{variant:"secondary",className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",children:J}),J>0&&!B&&f.jsx(je,{variant:"ghost",size:"sm",onClick:F=>{F.preventDefault(),F.stopPropagation(),re.current?.()},className:"h-6 w-6 p-0",title:"Clear all messages",children:f.jsx(Os,{className:"h-3.5 w-3.5"})})]}),f.jsx(Kl,{className:`h-4 w-4 text-muted-foreground transition-transform ${B?"":"rotate-180"}`})]}),!B&&f.jsx("div",{className:"flex-1 overflow-hidden min-h-0",children:f.jsx(IO,{serverIds:[a],onCountChange:ie,onClearRef:re})})]})]})}),f.jsx(bi,{}),f.jsx(Rn,{defaultSize:50,children:f.jsx(Jr,{direction:"vertical",children:f.jsx(Rn,{defaultSize:70,children:f.jsx("div",{ref:M,className:"h-full bg-white dark:bg-zinc-900",children:f.jsx(W4,{result:d,isLoading:h,previewMode:y,serverId:a,readResource:n,onTogglePreview:()=>_(!y),onCopy:z,onDownload:L,onFullscreen:$,isCopied:I})})})})})]})}QK.displayName="ResourcesTab";function Y4({savedRequests:e,selectedRequest:t,onLoadRequest:n,onDeleteRequest:a,focusedIndex:r}){if(e.length===0)return f.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[f.jsx(sy,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),f.jsx("p",{className:"text-gray-500 dark:text-gray-400 mb-2",children:"No saved requests yet"}),f.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 f.jsx("div",{className:"overflow-y-auto flex-1 border-r dark:border-zinc-700 overscroll-contain",children:e.map((s,c)=>f.jsxs("div",{className:"relative group",children:[f.jsx(Vs,{id:`saved-${s.id}`,isSelected:t?.id===s.id,isFocused:r===c,icon:f.jsx(zb,{className:"h-4 w-4"}),title:s.name,description:s.toolName,metadata:f.jsx("div",{className:"flex flex-col gap-1",children:f.jsx("span",{className:"text-xs text-gray-400 dark:text-gray-500",children:new Date(s.savedAt).toLocaleString()})}),onClick:()=>n(s)}),f.jsx("div",{className:"absolute top-1/2 right-2 -translate-y-1/2 opacity-0 group-hover:opacity-100 transition-opacity z-10",children:f.jsxs($t,{children:[f.jsx(Mt,{asChild:!0,children:f.jsx(je,{variant:"secondary",size:"sm",onClick:u=>i(u,()=>a(s.id)),className:"h-8 w-8 p-0",children:f.jsx(Os,{className:"h-4 w-4"})})}),f.jsx(Pt,{children:f.jsx("p",{children:"Delete saved request"})})]})})]},s.id))})}function q4({isOpen:e,requestName:t,defaultPlaceholder:n,onRequestNameChange:a,onSave:r,onCancel:i}){return e?f.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:i,children:f.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:[f.jsx("h3",{className:"text-lg font-semibold mb-4 text-gray-900 dark:text-gray-100",children:"Save Request"}),f.jsxs("div",{className:"space-y-4",children:[f.jsxs("div",{children:[f.jsx(Kt,{htmlFor:"request-name",children:"Request Name (optional)"}),f.jsx(kn,{id:"request-name",value:t,onChange:s=>a(s.target.value),placeholder:n,className:"mt-2",onKeyDown:s=>{s.key==="Enter"&&r()},autoFocus:!0})]}),f.jsxs("div",{className:"flex justify-end gap-2",children:[f.jsx(je,{variant:"outline",onClick:i,children:"Cancel"}),f.jsxs(je,{onClick:r,children:[f.jsx(sN,{className:"h-4 w-4 mr-2"}),"Save"]})]})]})]})}):null}function eZ(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 D_e(e,t){if(e.anyOf&&Array.isArray(e.anyOf)){const n=e.anyOf.find(a=>a.type!=="null");if(n)return{...eZ(n,t),nullable:!0}}return e}function j_e(e){return Array.isArray(e.enum)?e.enum:null}function L_e({selectedTool:e,toolArgs:t,onArgChange:n}){const a=e?.inputSchema?.properties||{},r=e?.inputSchema?.required||[];return Object.keys(a).length>0?f.jsx("div",{className:"space-y-4",children:Object.entries(a).map(([s,c])=>{const u=e?.inputSchema||{};let d=D_e(c,u);d=eZ(d,u);const m=j_e(d),h=d.type==="string"&&m!==null,g=d;g.required=r.includes(s);const v=t[s];let S="";return v!=null&&(typeof v=="string"?S=v:typeof v=="object"&&v!==null?S=JSON.stringify(v,null,2):S=String(v)),g.type==="object"||g.type==="array"?f.jsxs("div",{className:"space-y-2",children:[f.jsxs(Kt,{htmlFor:s,className:"text-sm font-medium",children:[s,g?.required&&f.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),f.jsx(zl,{id:s,value:S,onChange:y=>n(s,y.target.value),placeholder:g?.description||`Enter ${s}`,className:"min-h-[100px]"}),g?.description&&f.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:g.description})]},s):h&&m?f.jsxs("div",{className:"space-y-2",children:[f.jsxs(Kt,{htmlFor:s,className:"text-sm font-medium",children:[s,g.required&&f.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),f.jsxs(ko,{value:String(t[s]||""),onValueChange:y=>n(s,y),children:[f.jsx(No,{id:s,className:"w-full",children:f.jsx(To,{placeholder:g.description||"Select an option"})}),f.jsx(Co,{children:m.map((y,_)=>f.jsx(Ir,{value:y,children:g.enumNames?.[_]||y},y))})]}),g.description&&f.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:g.description})]},s):f.jsxs("div",{className:"space-y-2",children:[f.jsxs(Kt,{htmlFor:s,className:"text-sm font-medium",children:[s,g?.required&&f.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),f.jsx(kn,{id:s,value:S,onChange:y=>n(s,y.target.value),placeholder:g?.description||`Enter ${s}`}),g?.description&&f.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:g.description})]},s)})}):f.jsx("div",{className:"flex items-center justify-center h-32 text-gray-500 dark:text-gray-400 text-sm",children:"No parameters required"})}function X4({selectedTool:e,toolArgs:t,isExecuting:n,isConnected:a,onArgChange:r,onExecute:i,onSave:s,onCancel:c}){const[u,d]=x.useState(!1);return x.useEffect(()=>{const m=h=>{(h.metaKey||h.ctrlKey)&&h.key==="Enter"&&e&&!n&&a&&(h.preventDefault(),i()),h.key==="Escape"&&n&&c&&(h.preventDefault(),c())};return document.addEventListener("keydown",m),()=>document.removeEventListener("keydown",m)},[e,n,a,i,c]),e?f.jsxs("div",{className:"flex flex-col h-full",children:[f.jsx("div",{className:"flex-shrink-0 p-3 sm:p-5 pt-3 sm:pt-4 pb-4 sm:pr-4",children:f.jsxs("div",{children:[f.jsxs("div",{className:"flex flex-row items-center justify-between mb-0 gap-2",children:[f.jsx("h3",{className:"text-base sm:text-lg font-semibold",children:e.name}),f.jsxs("div",{className:"flex gap-2 flex-shrink-0",children:[f.jsxs(je,{variant:"outline",onClick:s,disabled:n,size:"sm",className:"lg:size-default gap-2",children:[f.jsx(sN,{className:"h-4 w-4"}),f.jsx("span",{className:"hidden sm:inline",children:"Save"})]}),n&&c?f.jsxs($t,{open:u?void 0:!1,children:[f.jsx(Mt,{asChild:!0,children:f.jsx("div",{onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),className:"relative",children:f.jsx(je,{onClick:c,variant:u?"destructive":"default",size:"sm",className:"lg:size-default gap-2 transition-all",children:u?f.jsxs(f.Fragment,{children:[f.jsx(Wi,{className:"h-4 w-4"}),f.jsx("span",{className:"hidden sm:inline",children:"Cancel"}),f.jsx("span",{className:"hidden sm:inline text-[12px] border border-current p-1 rounded-full ml-2",children:"Esc"})]}):f.jsxs(f.Fragment,{children:[f.jsx(Hi,{className:"mr-2"}),f.jsx("span",{className:"hidden sm:inline",children:"Executing..."})]})})})}),f.jsx(Pt,{children:f.jsx("p",{children:"Hover to cancel (or press Esc)"})})]}):f.jsx(je,{onClick:i,disabled:n||!a,size:"sm",className:"lg:size-default pr-1! gap-0",children:n?f.jsxs(f.Fragment,{children:[f.jsx(Hi,{className:"mr-2"}),f.jsx("span",{className:"hidden sm:inline",children:"Executing..."})]}):f.jsxs(f.Fragment,{children:[f.jsx(W9,{className:"h-4 w-4 sm:mr-2"}),f.jsx("span",{className:"hidden sm:inline",children:"Execute"}),f.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&&f.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 leading-relaxed mt-2",children:e.description})]})}),f.jsx("div",{className:"flex-1 overflow-y-auto px-3 sm:px-6 pb-4 pr-3",children:f.jsx(L_e,{selectedTool:e,toolArgs:t,onArgChange:r})})]}):f.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[f.jsx("p",{className:"text-gray-500 dark:text-gray-400 mb-2",children:"Select a tool to get started"}),f.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 J4(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 $_e(e){try{return JSON.parse(e),!0}catch{return!1}}function M_e({content:e}){return!Array.isArray(e)||e.length===0?f.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:"No content"}):f.jsx("div",{className:"space-y-4",children:e.map((t,n)=>{if(t.type==="text"){const a=t.text||"";if($_e(a))try{const r=JSON.parse(a);return f.jsxs("div",{className:"space-y-2",children:[f.jsx("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"Text Content (JSON)"}),f.jsx(Jn,{data:r,filename:`content-${n}.json`})]},n)}catch{}return f.jsxs("div",{className:"space-y-2",children:[f.jsx("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"Text Content"}),f.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 f.jsxs("div",{className:"space-y-2",children:[f.jsx("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"Image Content"}),f.jsxs("div",{className:"bg-gray-50 dark:bg-zinc-900 rounded-lg p-3",children:[f.jsx("img",{src:`data:${t.mimeType||"image/png"};base64,${t.data}`,alt:"Result",className:"max-w-full rounded"}),t.annotations&&f.jsx("div",{className:"mt-2 text-xs text-gray-500 dark:text-gray-400",children:f.jsx(Jn,{data:t.annotations,filename:`image-annotations-${n}.json`})})]})]},n);if(t.type==="audio")return f.jsxs("div",{className:"space-y-2",children:[f.jsx("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"Audio Content"}),f.jsxs("div",{className:"bg-gray-50 dark:bg-zinc-900 rounded-lg p-3",children:[f.jsx("audio",{controls:!0,src:`data:${t.mimeType||"audio/wav"};base64,${t.data}`,className:"w-full"}),t.annotations&&f.jsx("div",{className:"mt-2 text-xs text-gray-500 dark:text-gray-400",children:f.jsx(Jn,{data:t.annotations,filename:`audio-annotations-${n}.json`})})]})]},n);if(t.type==="resource_link")return f.jsxs("div",{className:"space-y-2",children:[f.jsx("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"Resource Link"}),f.jsxs("div",{className:"bg-gray-50 dark:bg-zinc-900 rounded-lg p-3 space-y-2",children:[f.jsxs("div",{className:"font-mono text-sm break-all",children:[f.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"URI:"})," ",t.uri]}),t.name&&f.jsxs("div",{className:"text-sm",children:[f.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"Name:"})," ",t.name]}),t.description&&f.jsxs("div",{className:"text-sm",children:[f.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"Description:"})," ",t.description]}),t.mimeType&&f.jsxs("div",{className:"text-sm",children:[f.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"MIME Type:"})," ",t.mimeType]}),t.annotations&&f.jsxs("div",{className:"mt-2",children:[f.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"Annotations:"}),f.jsx(Jn,{data:t.annotations,filename:`resource-link-annotations-${n}.json`})]})]})]},n);if(t.type==="resource"){const a=t.resource||{};return f.jsxs("div",{className:"space-y-2",children:[f.jsx("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"Embedded Resource"}),f.jsxs("div",{className:"bg-gray-50 dark:bg-zinc-900 rounded-lg p-3 space-y-2",children:[f.jsxs("div",{className:"font-mono text-sm break-all",children:[f.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"URI:"})," ",a.uri]}),a.mimeType&&f.jsxs("div",{className:"text-sm",children:[f.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"MIME Type:"})," ",a.mimeType]}),a.text&&f.jsxs("div",{children:[f.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"Content:"}),f.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&&f.jsxs("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:["[Binary content: ",a.blob.length||0," bytes]"]}),a.annotations&&f.jsxs("div",{className:"mt-2",children:[f.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"Annotations:"}),f.jsx(Jn,{data:a.annotations,filename:`resource-annotations-${n}.json`})]})]})]},n)}return f.jsxs("div",{className:"space-y-2",children:[f.jsxs("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:["Unknown Content Type: ",t.type||"N/A"]}),f.jsx(Jn,{data:t,filename:`content-${n}.json`})]},n)})})}function Q4({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,S]=x.useState(!0),w=e[0],y=w?e.filter(J=>J.toolName===w.toolName):[],_=y[d]||y[0],E=e.findIndex(J=>J===_);x.useEffect(()=>{y.length>0&&d>=y.length&&m(0)},[y.length,d]),x.useEffect(()=>{const J=()=>{_&&g(J4(_.timestamp))};J();const ie=setInterval(J,1e3);return()=>clearInterval(ie)},[_]);const k=x.useMemo(()=>_?.args,[_?.timestamp,d]),R=x.useMemo(()=>_?.result,[_?.timestamp,d]),C=x.useCallback(J=>r(J),[r]);if(e.length===0)return f.jsx("div",{className:"flex flex-col h-full bg-white dark:bg-black border-t dark:border-zinc-700",children:f.jsx("div",{className:"flex-1 overflow-y-auto h-full",children:f.jsx("div",{className:"flex items-center justify-center h-full",children:f.jsx("div",{className:"text-center",children:f.jsx(od,{vertical:!0,noBorder:!0,message:"No Results yet"})})})})});const I=_.toolMeta?.["openai/outputTemplate"],A=!!(I&&typeof I=="string"&&_.appsSdkResource),O=I,M=_.result?.content||[],U=M.filter(J=>J.type==="resource"&&bu(J.resource)),H=U.length>0,K=!!(M&&M.length>0||_.result?.structuredContent),ee=!H&&!A&&K;return f.jsx("div",{className:"flex flex-col h-full bg-white dark:bg-black border-t dark:border-zinc-700",children:f.jsx("div",{className:"flex-1 overflow-y-auto h-full",children:f.jsxs("div",{className:"space-y-0 flex-1 h-full flex flex-col",children:[f.jsxs("div",{className:`flex items-center gap-2 px-4 pt-2 ${H||A||ee?"border-b border-gray-200 dark:border-zinc-600 pb-2":""}`,children:[f.jsx("h3",{className:"text-sm font-medium hidden sm:block",children:"Response"}),_.duration!==void 0&&f.jsxs("div",{className:"hidden sm:flex items-center gap-1",children:[f.jsx(cp,{className:"h-3 w-3 text-gray-400"}),f.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:[_.duration,"ms"]})]}),A&&f.jsxs("div",{className:"flex items-center gap-4 sm:ml-4",children:[f.jsxs("span",{className:"hidden sm:inline text-xs text-gray-500 dark:text-gray-400",children:["URI: ",O||"No URI"]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("button",{onClick:()=>s(),className:`text-xs font-medium ${n?"text-black dark:text-white":"text-zinc-500 dark:text-zinc-400"}`,children:"Component"}),f.jsx("span",{className:"text-xs text-zinc-400",children:"|"}),f.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&&!A&&f.jsxs("div",{className:"flex items-center gap-4 sm:ml-4",children:[f.jsxs("span",{className:"hidden sm:inline text-xs text-gray-500 dark:text-gray-400",children:["URI: ",U[0]?.resource?.uri||"No URI"]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("button",{onClick:()=>s(),className:`text-xs font-medium ${n?"text-black dark:text-white":"text-zinc-500 dark:text-zinc-400"}`,children:"Preview"}),f.jsx("span",{className:"text-xs text-zinc-400",children:"|"}),f.jsx("button",{onClick:()=>s(),className:`text-xs font-medium ${n?"text-zinc-500 dark:text-zinc-400":"text-black dark:text-white"}`,children:"JSON"})]})]}),ee&&f.jsxs("div",{className:"flex items-center gap-2 sm:ml-4",children:[f.jsx("button",{onClick:()=>S(!0),className:`text-xs font-medium ${v?"text-black dark:text-white":"text-zinc-500 dark:text-zinc-400"}`,children:"Formatted"}),f.jsx("span",{className:"text-xs text-zinc-400",children:"|"}),f.jsx("button",{onClick:()=>S(!1),className:`text-xs font-medium ${v?"text-zinc-500 dark:text-zinc-400":"text-black dark:text-white"}`,children:"Raw"})]}),f.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[(A||H)&&c&&f.jsx(je,{variant:"ghost",size:"sm",onClick:c,title:u?"Restore":"Maximize",children:u?f.jsx(_pe,{className:"h-4 w-4"}):f.jsx(oN,{className:"h-4 w-4"})}),y.length>1&&f.jsxs(ko,{value:d.toString(),onValueChange:J=>m(parseInt(J)),children:[f.jsx(No,{size:"sm",className:"w-[140px] h-8 text-xs",children:f.jsx(To,{children:f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx(zb,{className:"h-3 w-3"}),f.jsx("span",{children:h})]})})}),f.jsx(Co,{children:y.map((J,ie)=>f.jsx(Ir,{value:ie.toString(),children:f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(zb,{className:"h-3 w-3"}),f.jsx("span",{children:J4(J.timestamp)}),f.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",new Date(J.timestamp).toLocaleTimeString(),")"]})]})},ie))})]}),f.jsx(je,{variant:"ghost",size:"sm",onClick:()=>i(E,_.result),children:t===E?f.jsx(ga,{className:"h-4 w-4"}):f.jsx(Br,{className:"h-4 w-4"})})]})]}),_.error?f.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:[f.jsx("p",{className:"text-red-800 dark:text-red-300 font-medium",children:"Error:"}),f.jsx("p",{className:"text-red-700 dark:text-red-400 text-sm",children:_.error})]}):(()=>{if(A){const J=_.appsSdkResource;return J.isLoading?f.jsx(f.Fragment,{}):J.error?f.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:[f.jsx("p",{className:"text-red-800 dark:text-red-300 font-medium",children:"Resource Error:"}),f.jsx("p",{className:"text-red-700 dark:text-red-400 text-sm",children:J.error})]}):n?f.jsx("div",{className:"flex-1",children:f.jsx(xO,{componentUrl:O,toolName:_.toolName,toolArgs:k,toolResult:R,serverId:a,readResource:C,className:"w-full h-full relative p-4"})}):f.jsx("div",{className:"px-4 pt-4",children:f.jsx(Jn,{data:_.result,filename:`tool-result-${_.toolName}-${Date.now()}.json`})})}if(H)return n?f.jsxs("div",{className:"space-y-0 h-full",children:[U.map((J,ie)=>f.jsx("div",{className:"mx-0 size-full",children:f.jsx(JK,{resource:J.resource,onUIAction:B=>{},className:"w-full h-full relative"})},ie)),M.filter(J=>!(J.type==="resource"&&bu(J.resource))).length>0&&f.jsx("div",{className:"px-4",children:f.jsx(Jn,{data:M.filter(J=>!(J.type==="resource"&&bu(J.resource))),filename:`tool-result-${_.toolName}-non-ui-${Date.now()}.json`})})]}):f.jsx("div",{className:"px-4 pt-4",children:f.jsx(Jn,{data:_.result,filename:`tool-result-${_.toolName}-mcp-ui-${Date.now()}.json`})});if(ee&&v){const J=_.result?.structuredContent;return f.jsxs("div",{className:"px-4 pt-4 space-y-4",children:[J&&f.jsxs("div",{className:"space-y-2",children:[f.jsx("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"Structured Content"}),f.jsx(Jn,{data:J,filename:`structured-content-${_.toolName}-${Date.now()}.json`})]}),M&&M.length>0&&f.jsx(M_e,{content:M}),!J&&(!M||M.length===0)&&f.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:"No content to display"})]})}return f.jsx("div",{className:"px-4 pt-4",children:f.jsx(Jn,{data:_.result,filename:`tool-result-${_.toolName}-${Date.now()}.json`})})})()]})})})}function e2({tools:e,selectedTool:t,onToolSelect:n,focusedIndex:a}){return e.length===0?f.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[f.jsx(Ll,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),f.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"No tools available"})]}):f.jsx("div",{className:"overflow-y-auto flex-1 overscroll-contain",children:e.map((r,i)=>f.jsx(Vs,{id:`tool-${r.name}`,isSelected:t?.name===r.name,isFocused:a===i,icon:f.jsx(Ll,{className:"h-4 w-4"}),title:r.name,description:r.description,metadata:r.inputSchema?.properties&&f.jsxs(xr,{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 t2({activeTab:e,isSearchExpanded:t,searchQuery:n,filteredToolsCount:a,savedRequestsCount:r,onSearchExpand:i,onSearchChange:s,onSearchBlur:c,onTabSwitch:u,searchInputRef:d}){return f.jsx(qK,{activeTab:e,isSearchExpanded:t,searchQuery:n,primaryTabName:"tools",secondaryTabName:"saved",primaryTabTitle:"Tools",secondaryTabTitle:"Saved",primaryCount:a,secondaryCount:r,primaryIcon:Ll,secondaryIcon:sy,searchPlaceholder:"Search tools...",onSearchExpand:i,onSearchChange:s,onSearchBlur:c,onTabSwitch:u,searchInputRef:d})}const n2="mcp-inspector-saved-requests";function tZ({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}=Zl(),[g,v]=x.useState({}),[S,w]=x.useState([]),[y,_]=x.useState(!1),[E,k]=x.useState(null),[R,C]=x.useState(null),[I,A]=x.useState(""),[O,M]=x.useState("tools"),[U,H]=x.useState([]),[K,ee]=x.useState(!1),[J,ie]=x.useState(""),[B,Z]=x.useState(!0),[G,re]=x.useState(!1),[ne,j]=x.useState(-1),V=x.useRef(null),[z,L]=x.useState(!1),[$,F]=x.useState("list"),[W,X]=x.useState(!1),[ae,le]=x.useState(0),[Q,q]=x.useState(!0),[se,he]=x.useState(void 0),ce=x.useRef(null),ke=x.useRef(null),He=x.useRef(null),Se=x.useRef(null),_e=x.useRef(null);x.useEffect(()=>{const Oe=()=>{L(window.innerWidth<1024)};return Oe(),window.addEventListener("resize",Oe),()=>window.removeEventListener("resize",Oe)},[]),x.useEffect(()=>{F(s?"detail":"list")},[s]),x.useEffect(()=>{z&&S.length>0&&!y&&F("response")},[S,y,z]),x.useImperativeHandle(e,()=>({focusSearch:()=>{re(!0),setTimeout(()=>{V.current&&V.current.focus()},0)},blurSearch:()=>{A(""),re(!1),V.current&&V.current.blur()}})),x.useEffect(()=>{try{const Oe=localStorage.getItem(n2);Oe&&H(JSON.parse(Oe))}catch(Oe){console.error("[ToolsTab] Failed to load saved requests:",Oe)}},[]);const Ue=x.useCallback(Oe=>{try{localStorage.setItem(n2,JSON.stringify(Oe)),H(Oe)}catch($e){console.error("[ToolsTab] Failed to save requests:",$e)}},[]),fe=x.useMemo(()=>{if(!I.trim())return t;const Oe=I.toLowerCase();return t.filter($e=>$e.name.toLowerCase().includes(Oe)||$e.description?.toLowerCase().includes(Oe))},[t,I]),Ie=x.useCallback(Oe=>{c(Oe);const $e={};Oe.inputSchema?.properties&&Object.entries(Oe.inputSchema.properties).forEach(([Be,ut])=>{const dt=ut;dt.default!==void 0?$e[Be]=dt.default:dt.type==="string"?$e[Be]="":dt.type==="number"?$e[Be]=0:dt.type==="boolean"?$e[Be]=!1:dt.type==="array"?$e[Be]="[]":dt.type==="object"&&($e[Be]="{}")}),v($e)},[]),Fe=x.useCallback(Oe=>{const $e=t.find(Be=>Be.name===Oe.toolName);$e&&(c($e),v(Oe.args),d(Oe))},[t]);x.useEffect(()=>{G&&V.current&&V.current.focus()},[G]);const xe=x.useCallback(()=>{I.trim()||re(!1)},[I]);x.useEffect(()=>{O!=="tools"&&re(!1)},[O]),x.useEffect(()=>{j(-1)},[I,O]),x.useEffect(()=>{const Oe=$e=>{const Be=$e.target;if(Be.tagName==="INPUT"||Be.tagName==="TEXTAREA"||Be.contentEditable==="true"||$e.metaKey||$e.ctrlKey||$e.altKey)return;const dt=O==="tools"?fe:U;if($e.key==="ArrowDown")$e.preventDefault(),j(wt=>{const xt=wt+1;return xt>=dt.length?0:xt});else if($e.key==="ArrowUp")$e.preventDefault(),j(wt=>{const xt=wt-1;return xt<0?dt.length-1:xt});else if($e.key==="Enter"&&ne>=0)if($e.preventDefault(),O==="tools"){const wt=fe[ne];wt&&Ie(wt)}else{const wt=U[ne];wt&&Fe(wt)}};return document.addEventListener("keydown",Oe),()=>document.removeEventListener("keydown",Oe)},[ne,fe,U,O,Ie,Fe]),x.useEffect(()=>{if(ne>=0){const Oe=O==="tools"?`tool-${fe[ne]?.name}`:`saved-${U[ne]?.id}`,$e=document.getElementById(Oe);$e&&$e.scrollIntoView({behavior:"smooth",block:"nearest"})}},[ne,fe,U,O]),x.useEffect(()=>{if(m&&t.length>0){const Oe=t.find($e=>$e.name===m);if(Oe&&s?.name!==Oe.name){h(null);const $e=setTimeout(()=>{Ie(Oe);const Be=document.getElementById(`tool-${Oe.name}`);Be&&Be.scrollIntoView({behavior:"smooth",block:"nearest"})},100);return()=>clearTimeout($e)}}},[m,t,s,Ie,h]);const it=x.useCallback((Oe,$e)=>{v(Be=>{const ut={...Be};if(s?.inputSchema?.properties?.[Oe]){const wt=s.inputSchema.properties[Oe].type;if(wt==="object"||wt==="array")ut[Oe]=$e;else if(wt==="string")ut[Oe]=$e;else try{ut[Oe]=JSON.parse($e)}catch{ut[Oe]=$e}}else ut[Oe]=$e;return ut})},[s]),nt=x.useCallback(async()=>{if(!s||y)return;const Oe=new AbortController;C(Oe),_(!0);const $e=Date.now();try{const Be={...g};s.inputSchema?.properties&&Object.entries(s.inputSchema.properties).forEach(([Ye,vt])=>{const Lt=vt.type,fr=Be[Ye];if((Lt==="object"||Lt==="array")&&typeof fr=="string")try{Be[Ye]=JSON.parse(fr)}catch{}});const ut=await n(s.name,Be,{timeout:6e5,resetTimeoutOnProgress:!0,signal:Oe.signal}),dt=Date.now()-$e;yr.getInstance().capture(new aU({toolName:s.name,serverId:r,success:!0,duration:dt})).catch(()=>{});const xt=s?._meta||s?.metadata,dn=xt?.["openai/outputTemplate"];let hn;if(dn&&typeof dn=="string"){const Ye={toolName:s.name,args:g,result:ut,timestamp:$e,duration:dt,toolMeta:xt,appsSdkResource:{uri:dn,resourceData:null,isLoading:!0}};w([Ye]);try{const vt=await a(dn);let jt=null;if(ut?.structuredContent)jt=ut.structuredContent;else if(Array.isArray(ut)&&ut[0]){const Lt=ut[0];Lt.output?.value?.structuredContent?jt=Lt.output.value.structuredContent:Lt.structuredContent?jt=Lt.structuredContent:Lt.output?.value&&(jt=Lt.output.value)}jt||(jt=ut),hn={uri:dn,resourceData:{...vt,structuredContent:jt},isLoading:!1}}catch(vt){hn={uri:dn,resourceData:null,isLoading:!1,error:vt instanceof Error?vt.message:String(vt)}}w(vt=>vt.map((jt,Lt)=>Lt===0?{...jt,appsSdkResource:hn}:jt))}else w(Ye=>[{toolName:s.name,args:g,result:ut,timestamp:$e,duration:dt,toolMeta:xt},...Ye])}catch(Be){const ut=Date.now()-$e;yr.getInstance().capture(new aU({toolName:s.name,serverId:r,success:!1,duration:ut,error:Be instanceof Error?Be.message:String(Be)})).catch(()=>{});const wt=s?._meta||s?.metadata,xt={toolName:s.name,args:g,result:null,error:Be instanceof Error?Be.message:String(Be),timestamp:$e,duration:ut,toolMeta:wt},dn=wt?.["openai/outputTemplate"];w(dn?[xt]:hn=>[xt,...hn])}finally{_(!1)}},[s,g,y,n,a,r]),mt=x.useCallback(async(Oe,$e)=>{try{await navigator.clipboard.writeText(JSON.stringify($e,null,2)),k(Oe),setTimeout(()=>k(null),2e3)}catch(Be){console.error("[ToolsTab] Failed to copy result:",Be)}},[]),Ct=x.useCallback(Oe=>{w($e=>$e.filter((Be,ut)=>ut!==Oe))},[]),Le=x.useMemo(()=>s?S.filter(Oe=>Oe.toolName===s.name):[],[S,s]),ze=x.useCallback(Oe=>{const $e=Le[Oe];if($e){const Be=window.open("","_blank","width=800,height=600");Be&&(Be.document.write(`
1670
1670
  <html>
1671
1671
  <head>
1672
1672
  <title>${$e.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($e.result,null,2)}</pre>
1681
1681
  </body>
1682
1682
  </html>
1683
- `),Be.document.close())}},[S]),ht=x.useCallback(()=>{W?(ce.current&&ce.current.expand(),ke.current&&ke.current.expand(),X(!1)):(ce.current&&ce.current.collapse(),ke.current&&ke.current.collapse(),X(!0))},[W]),Qe=x.useCallback(()=>{s&&(ie(""),ee(!0))},[s]),Rt=x.useCallback(()=>{if(!s)return;const Oe={id:`${Date.now()}-${Math.random()}`,name:J.trim()||`${s.name} - ${new Date().toLocaleString()}`,toolName:s.name,args:g,savedAt:Date.now(),serverId:s._serverId,serverName:s._serverName};Ue([...U,Oe]),yr.getInstance().capture(new cfe({toolName:s.name,serverId:r})).catch(()=>{}),ee(!1),ie("")},[s,J,g,U,Ue,r]),rt=x.useCallback(Oe=>{Ue(U.filter($e=>$e.id!==Oe)),u?.id===Oe&&d(null)},[U,Ue,u]);return z?f.jsxs("div",{className:"h-full flex flex-col overflow-hidden relative bg-background",children:[$!=="list"&&f.jsxs("div",{className:"flex items-center gap-2 p-2 border-b shrink-0 bg-background z-10",children:[f.jsx(je,{variant:"ghost",size:"sm",onClick:()=>{$==="response"?F("detail"):(c(null),F("list"))},className:"p-0 h-8 w-8",children:f.jsx(rN,{className:"h-4 w-4"})}),f.jsxs("div",{className:"flex items-center text-sm font-medium",children:[f.jsx("button",{onClick:()=>{c(null),F("list")},className:"text-muted-foreground hover:text-foreground hover:underline cursor-pointer",children:"Tools"}),$==="detail"&&f.jsxs(f.Fragment,{children:[f.jsx("span",{className:"mx-2 text-muted-foreground",children:"/"}),f.jsx("button",{onClick:()=>{F("response")},className:$==="detail"?"text-foreground hover:underline":$==="response"?"text-muted-foreground hover:text-foreground hover:underline cursor-pointer":"text-muted-foreground",children:"Execute"})]}),$==="response"&&f.jsxs(f.Fragment,{children:[f.jsx("span",{className:"mx-2 text-muted-foreground",children:"/"}),f.jsx("span",{className:"text-foreground",children:"Response"})]})]})]}),f.jsx("div",{className:"flex-1 relative overflow-hidden",children:f.jsxs(py,{initial:!1,mode:"popLayout",children:[$==="list"&&f.jsxs(ha.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:[f.jsx(t2,{activeTab:O,isSearchExpanded:G,searchQuery:I,filteredToolsCount:fe.length,savedRequestsCount:U.length,onSearchExpand:()=>re(!0),onSearchChange:A,onSearchBlur:xe,onTabSwitch:()=>M(O==="tools"?"saved":"tools"),searchInputRef:V}),O==="tools"?f.jsx(e2,{tools:fe,selectedTool:s,onToolSelect:Ie,focusedIndex:ne}):f.jsx(Y4,{savedRequests:U,selectedRequest:u,onLoadRequest:Fe,onDeleteRequest:rt,focusedIndex:ne})]},"list"),$==="detail"&&f.jsx(ha.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:f.jsx(X4,{selectedTool:s,toolArgs:g,isExecuting:y,isConnected:i,onArgChange:it,onExecute:nt,onSave:Qe})},"detail"),$==="response"&&f.jsx(ha.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:f.jsx(Q4,{results:Le,copiedResult:E,previewMode:B,serverId:r,readResource:a,onCopy:mt,onDelete:Ct,onFullscreen:ze,onTogglePreview:()=>Z(!B)})},"response")]})}),f.jsx(q4,{isOpen:K,requestName:J,defaultPlaceholder:`${s?.name} - ${new Date().toLocaleString()}`,onRequestNameChange:ie,onSave:Rt,onCancel:()=>ee(!1)})]}):f.jsxs(Jr,{direction:"horizontal",className:"h-full",children:[f.jsx(Rn,{ref:ce,defaultSize:33,collapsible:!0,className:"flex flex-col h-full relative",children:f.jsxs(Jr,{direction:"vertical",className:"h-full border-r dark:border-zinc-700",children:[f.jsx(Rn,{defaultSize:75,minSize:30,children:f.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[f.jsx(t2,{activeTab:O,isSearchExpanded:G,searchQuery:I,filteredToolsCount:fe.length,savedRequestsCount:U.length,onSearchExpand:()=>re(!0),onSearchChange:A,onSearchBlur:xe,onTabSwitch:()=>M(O==="tools"?"saved":"tools"),searchInputRef:V}),O==="tools"?f.jsx(e2,{tools:fe,selectedTool:s,onToolSelect:Ie,focusedIndex:ne}):f.jsx(Y4,{savedRequests:U,selectedRequest:u,onLoadRequest:Fe,onDeleteRequest:rt,focusedIndex:ne})]})}),f.jsx(bi,{withHandle:!0}),f.jsxs(Rn,{ref:Se,defaultSize:0,collapsible:!0,minSize:5,collapsedSize:5,onCollapse:()=>{q(!0)},onExpand:()=>{q(!1)},className:"flex flex-col border-t dark:border-zinc-700",children:[f.jsxs("div",{className:"group flex items-center justify-between p-3 shrink-0 cursor-pointer hover:bg-muted/50 transition-colors",onClick:Oe=>{Oe.preventDefault(),Oe.stopPropagation(),Q?(Se.current?.resize(25),q(!1)):(Se.current?.resize(5),q(!0))},children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("h3",{className:"text-sm font-medium",children:"RPC Messages"}),ae>0&&f.jsx(xr,{variant:"secondary",className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",children:ae}),ae>0&&!Q&&f.jsx(je,{variant:"ghost",size:"sm",onClick:Oe=>{Oe.preventDefault(),Oe.stopPropagation(),_e.current?.()},className:"h-6 w-6 p-0",title:"Clear all messages",children:f.jsx(Os,{className:"h-3.5 w-3.5"})})]}),f.jsx(Kl,{className:`h-4 w-4 text-muted-foreground transition-transform ${Q?"":"rotate-180"}`})]}),!Q&&f.jsx("div",{className:"flex-1 overflow-hidden min-h-0",children:f.jsx(IO,{serverIds:[r],onCountChange:le,onClearRef:_e})})]})]})}),f.jsx(bi,{withHandle:!0}),f.jsx(Rn,{defaultSize:67,children:f.jsxs(Jr,{direction:"vertical",children:[f.jsx(Rn,{ref:ke,defaultSize:40,collapsible:!0,children:f.jsx(X4,{selectedTool:s,toolArgs:g,isExecuting:y,isConnected:i,onArgChange:it,onExecute:nt,onSave:Qe,onCancel:()=>{R&&R.abort()}})}),f.jsx(bi,{withHandle:!0}),f.jsx(Rn,{ref:He,defaultSize:60,children:f.jsx("div",{className:"flex flex-col h-full",children:f.jsx(Q4,{results:Le,copiedResult:E,previewMode:B,serverId:r,readResource:a,onCopy:mt,onDelete:Ct,onFullscreen:ze,onTogglePreview:()=>Z(!B),onMaximize:ht,isMaximized:W})})})]})}),f.jsx(q4,{isOpen:K,requestName:J,defaultPlaceholder:`${s?.name} - ${new Date().toLocaleString()}`,onRequestNameChange:ie,onSave:Rt,onCancel:()=>ee(!1)})]})}tZ.displayName="ToolsTab";function P_e({isSearchExpanded:e,searchQuery:t,filteredRequestsCount:n,requestsCount:a,onSearchExpand:r,onSearchChange:i,onSearchBlur:s,onRejectAll:c,searchInputRef:u}){return f.jsxs("div",{className:"flex flex-row items-center justify-between p-4 sm:p-4 py-3 gap-2",children:[f.jsx("div",{className:"flex items-center gap-2 flex-1",children:e?f.jsx(kn,{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"}):f.jsxs(f.Fragment,{children:[f.jsx("h2",{className:"text-lg font-medium text-gray-900 dark:text-gray-100",children:"Sampling"}),f.jsx(xr,{className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",variant:"outline",children:n}),f.jsxs($t,{children:[f.jsx(Mt,{asChild:!0,children:f.jsx(je,{variant:"ghost",size:"sm",onClick:r,className:"h-8 w-8 p-0",children:f.jsx(sd,{className:"h-4 w-4"})})}),f.jsxs(Pt,{side:"bottom",className:"flex gap-2",children:["Search",f.jsx(gm,{children:"F"})]})]})]})}),f.jsx("div",{className:"flex items-center gap-2",children:f.jsxs($t,{children:[f.jsx(Mt,{asChild:!0,children:f.jsx(je,{variant:"ghost",size:"sm",onClick:c,disabled:a===0,className:"h-8 w-8 p-0",children:f.jsx(Os,{className:"h-4 w-4"})})}),f.jsx(Pt,{side:"bottom",children:"Reject all"})]})})]})}function U_e({requests:e,selectedRequest:t,onRequestSelect:n,focusedIndex:a,formatRelativeTime:r,listRef:i}){return e.length===0?f.jsx("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:f.jsx(od,{vertical:!0,noBorder:!0,message:"No sampling requests"})}):f.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 f.jsx(Vs,{id:`sampling-request-${s.id}`,isSelected:t?.id===s.id,isFocused:a===c,title:f.jsxs("span",{className:"flex items-center gap-3",children:[s.serverName,f.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 z_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 dr(async()=>{const{HumanMessage:S,AIMessage:w}=await import("./index-C2TkayVJ.js").then(y=>y.bD);return{HumanMessage:S,AIMessage:w}},[]);for(const S of c){if(!S||!S.role){console.warn("Skipping invalid message:",S);continue}const w=Array.isArray(S.content)?S.content[0]:S.content;if(!w){console.warn("Skipping message with no content:",S);continue}w.type==="text"&&w.text?S.role==="user"?u.push(new d(w.text)):S.role==="assistant"&&u.push(new m(w.text)):console.warn("Skipping message with unsupported content type:",w)}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 S;const w={model:e.model,apiKey:e.apiKey};if(i!==void 0&&(w.maxTokens=i),s!==void 0?w.temperature=s:e.temperature!==void 0&&(w.temperature=e.temperature),e.provider==="openai"){const{ChatOpenAI:y}=await dr(async()=>{const{ChatOpenAI:_}=await import("./index-mPE5nU31.js");return{ChatOpenAI:_}},__vite__mapDeps([5,6,7,3,8,9]));S=new y(w)}else if(e.provider==="anthropic"){const{ChatAnthropic:y}=await dr(async()=>{const{ChatAnthropic:_}=await import("./index-BpS0GDKB.js");return{ChatAnthropic:_}},__vite__mapDeps([10,7,6,3]));S=new y(w)}else if(e.provider==="google"){const{ChatGoogleGenerativeAI:y}=await dr(async()=>{const{ChatGoogleGenerativeAI:_}=await import("./index-BL2BGw9b.js");return{ChatGoogleGenerativeAI:_}},__vite__mapDeps([11,7,6,3,9]));S=new y(w)}else throw new Error(`Unsupported LLM provider: ${e.provider}`);t.current={instance:S,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 F_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,S]=x.useState("stub-model"),[w,y]=x.useState("endTurn"),[_,E]=x.useState("assistant"),[k,R]=x.useState("text"),[C,I]=x.useState("positive"),[A,O]=x.useState(""),[M,U]=x.useState("image/png"),[H,K]=x.useState(!1),[ee,J]=x.useState(null),{generateResponse:ie,isAvailable:B}=z_e({llmConfig:m});x.useEffect(()=>{e&&(S("stub-model"),y("endTurn"),E("assistant"),R("text"),I("positive"),O(""),U("image/png"),J(null))},[e?.id]);const Z=async()=>{if(!(!e||!B)){K(!0),J(null);try{const j=await ie({request:e.request});S(j.model||m?.model||"stub-model"),y(j.stopReason||"endTurn"),E(j.role||"assistant");const V=Array.isArray(j.content)?j.content[0]:j.content;V.type==="text"?(R("text"),I(V.text||"")):V.type==="image"&&(R("image"),O(V.data||""),U(V.mimeType||"image/png"))}catch(j){const V=j instanceof Error?j.message:"Failed to generate response";J(V),Jt.error("LLM Generation Failed",{description:V})}finally{K(!1)}}},G=x.useMemo(()=>{const j={model:v,stopReason:w,role:_,content:{type:k}};return k==="text"?j.content.text=C:k==="image"&&(j.content.data=A,j.content.mimeType=M),j},[v,w,_,k,C,A,M]),re=()=>{if(!e)return;const j=gT.safeParse(G);if(!j.success){Jt.error("Invalid response",{description:`Validation failed: ${j.error.message}`});return}t(e.id,j.data),a(),dr(()=>Promise.resolve().then(()=>Zu),void 0).then(V=>{const z=Jt(V.createElement("div",{className:"space-y-3"},V.createElement("div",null,V.createElement("strong",null,"Sampling Response Sent"),V.createElement("p",{className:"text-sm text-muted-foreground mt-1"},"The tool will continue executing.")),V.createElement("div",{className:"flex gap-2"},V.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),Jt.dismiss(z)}},"View Tool Result"))),{duration:5e3})})},ne=()=>{e&&(n(e.id,"User rejected sampling request"),a())};return e?f.jsxs("div",{className:"flex flex-col h-full",children:[f.jsxs("div",{className:"flex items-center justify-between p-4 border-b dark:border-zinc-700",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("h3",{className:"font-medium text-gray-900 dark:text-gray-100",children:e.serverName}),f.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:new Date(e.timestamp).toLocaleString()})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsxs($t,{children:[f.jsx(Mt,{asChild:!0,children:f.jsx(je,{variant:"ghost",size:"sm",onClick:c,className:"h-8 w-8 p-0",children:s?f.jsx(ga,{className:"h-4 w-4 text-green-600"}):f.jsx(Br,{className:"h-4 w-4"})})}),f.jsx(Pt,{children:"Copy request"})]}),f.jsxs($t,{children:[f.jsx(Mt,{asChild:!0,children:f.jsx(je,{variant:"ghost",size:"sm",onClick:u,className:"h-8 w-8 p-0",children:f.jsx(Qp,{className:"h-4 w-4"})})}),f.jsx(Pt,{children:"Download request"})]}),f.jsxs($t,{children:[f.jsx(Mt,{asChild:!0,children:f.jsx(je,{variant:"ghost",size:"sm",onClick:d,className:"h-8 w-8 p-0",children:f.jsx(iN,{className:"h-4 w-4"})})}),f.jsx(Pt,{children:"Fullscreen"})]}),f.jsx(je,{variant:"ghost",size:"sm",onClick:a,className:"h-8 w-8 p-0",children:f.jsx(Wi,{className:"h-4 w-4"})})]})]}),f.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-6",children:[f.jsxs("div",{className:"space-y-2",children:[f.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:"Request"}),f.jsx("div",{className:"bg-muted rounded-lg p-3 max-h-64 overflow-auto",children:f.jsx(Jn,{data:e.request})})]}),f.jsxs("div",{className:"space-y-4",children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:"Response"}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(Kt,{htmlFor:`responseMode-${e.id}`,className:"text-xs text-gray-500 dark:text-gray-400",children:"Mode:"}),f.jsxs(ko,{value:h,onValueChange:j=>g(j),children:[f.jsx(No,{id:`responseMode-${e.id}`,className:"w-32 h-8 text-xs",children:f.jsx(To,{})}),f.jsxs(Co,{children:[f.jsx(Ir,{value:"manual",children:"Manual"}),f.jsx(Ir,{value:"llm",children:"LLM"})]})]})]})]}),h==="llm"&&f.jsxs("div",{className:"space-y-2 p-3 bg-muted rounded-lg",children:[B?f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(je,{onClick:Z,disabled:H,size:"sm",className:"flex items-center gap-2",children:H?f.jsxs(f.Fragment,{children:[f.jsx(Is,{className:"h-4 w-4 animate-spin"}),"Generating..."]}):f.jsxs(f.Fragment,{children:[f.jsx(Hpe,{className:"h-4 w-4"}),"Generate with LLM"]})}),f.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:["Using ",m?.provider," (",m?.model,")"]})]}):f.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:"LLM not configured. Please configure LLM in the Chat tab."}),ee&&f.jsx("div",{className:"text-xs text-red-600 dark:text-red-400",children:ee})]}),f.jsxs("div",{className:"space-y-2",children:[f.jsx(Kt,{htmlFor:`model-${e.id}`,children:"Model"}),f.jsx(kn,{id:`model-${e.id}`,value:v,onChange:j=>S(j.target.value),placeholder:"stub-model",disabled:h==="llm"&&H})]}),f.jsxs("div",{className:"space-y-2",children:[f.jsx(Kt,{htmlFor:`stopReason-${e.id}`,children:"Stop Reason"}),f.jsx(kn,{id:`stopReason-${e.id}`,value:w,onChange:j=>y(j.target.value),placeholder:"endTurn",disabled:h==="llm"&&H})]}),f.jsxs("div",{className:"space-y-2",children:[f.jsx(Kt,{htmlFor:`role-${e.id}`,children:"Role"}),f.jsxs(ko,{value:_,onValueChange:j=>E(j),disabled:h==="llm"&&H,children:[f.jsx(No,{id:`role-${e.id}`,children:f.jsx(To,{})}),f.jsxs(Co,{children:[f.jsx(Ir,{value:"assistant",children:"assistant"}),f.jsx(Ir,{value:"user",children:"user"})]})]})]}),f.jsxs("div",{className:"space-y-2",children:[f.jsx(Kt,{htmlFor:`contentType-${e.id}`,children:"Content Type"}),f.jsxs(ko,{value:k,onValueChange:j=>R(j),disabled:h==="llm"&&H,children:[f.jsx(No,{id:`contentType-${e.id}`,children:f.jsx(To,{})}),f.jsxs(Co,{children:[f.jsx(Ir,{value:"text",children:"text"}),f.jsx(Ir,{value:"image",children:"image"})]})]})]}),k==="text"&&f.jsxs("div",{className:"space-y-2",children:[f.jsx(Kt,{htmlFor:`text-${e.id}`,children:"Text Content"}),f.jsx(zl,{id:`text-${e.id}`,value:C,onChange:j=>I(j.target.value),placeholder:"Enter response text...",rows:6,disabled:h==="llm"&&H})]}),k==="image"&&f.jsxs(f.Fragment,{children:[f.jsxs("div",{className:"space-y-2",children:[f.jsx(Kt,{htmlFor:`imageData-${e.id}`,children:"Base64 Image Data"}),f.jsx(zl,{id:`imageData-${e.id}`,value:A,onChange:j=>O(j.target.value),placeholder:"Base64 encoded image data...",rows:4,disabled:h==="llm"&&H})]}),f.jsxs("div",{className:"space-y-2",children:[f.jsx(Kt,{htmlFor:`mimeType-${e.id}`,children:"MIME Type"}),f.jsx(kn,{id:`mimeType-${e.id}`,value:M,onChange:j=>U(j.target.value),placeholder:"image/png",disabled:h==="llm"&&H})]})]})]})]}),f.jsxs("div",{className:"flex gap-2 p-4 border-t dark:border-zinc-700",children:[f.jsx(je,{onClick:re,className:"flex-1",disabled:h==="llm"&&H,children:"Approve"}),f.jsx(je,{onClick:ne,variant:"outline",className:"flex-1",disabled:h==="llm"&&H,children:"Reject"})]})]}):f.jsx("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:f.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"Select a sampling request to view details"})})}function B_e({pendingRequests:e,onApprove:t,onReject:n,serverId:a,isConnected:r,mcpServerUrl:i}){const{selectedSamplingRequestId:s,setSelectedSamplingRequestId:c}=Zl(),{llmConfig:u}=CK({mcpServerUrl:i}),[d,m]=x.useState(null),[h,g]=x.useState(""),[v,S]=x.useState(-1),[w,y]=x.useState(!0),[_,E]=x.useState(!1),[k,R]=x.useState(!0),[C,I]=x.useState(!1),A=x.useRef(null),O=x.useRef(null),M=x.useRef(null),U=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 G=e.find(re=>re.id===s);console.log("[SamplingTab] Found request for auto-selection:",!!G,G?.id),G&&(console.log("[SamplingTab] Auto-selecting request:",G.id),c(null),m(G),setTimeout(()=>{const re=document.getElementById(`sampling-request-${G.id}`);console.log("[SamplingTab] Scrolling to element:",!!re),re&&re.scrollIntoView({behavior:"smooth",block:"nearest"})},100))}},[s,e,c]),x.useEffect(()=>{const G=re=>{const j=re.detail.requestId;console.log("[SamplingTab] Custom navigate event received:",j);const V=e.find(z=>z.id===j);V&&(console.log("[SamplingTab] Selecting request from event:",j),m(V),setTimeout(()=>{const z=document.getElementById(`sampling-request-${j}`);z&&z.scrollIntoView({behavior:"smooth",block:"nearest"})},200))};return window.addEventListener("navigate-to-sampling",G),()=>window.removeEventListener("navigate-to-sampling",G)},[e]),x.useEffect(()=>{w&&e.length>0&&A.current&&!U.current&&(A.current.scrollTop=0)},[e.length,w]),x.useEffect(()=>{const G=A.current;if(!G)return;const re=()=>{G.scrollTop>0&&(U.current=!0,y(!1))};return G.addEventListener("scroll",re),()=>G.removeEventListener("scroll",re)},[]),x.useEffect(()=>{e.length===0&&(U.current=!1,y(!0))},[e.length]),x.useEffect(()=>{_&&M.current&&M.current.focus()},[_]);const H=x.useCallback(()=>{h.trim()||E(!1)},[h]),K=x.useMemo(()=>{if(!h.trim())return e;const G=h.toLowerCase();return e.filter(re=>re.serverName.toLowerCase().includes(G)||JSON.stringify(re.request||{}).toLowerCase().includes(G))},[e,h]);x.useEffect(()=>{S(-1)},[h]),x.useEffect(()=>{const G=re=>{const ne=re.target;if(ne.tagName==="INPUT"||ne.tagName==="TEXTAREA"||ne.contentEditable==="true"||re.metaKey||re.ctrlKey||re.altKey)return;const V=K;if(re.key==="ArrowDown")re.preventDefault(),S(z=>{const L=z+1;return L>=V.length?0:L});else if(re.key==="ArrowUp")re.preventDefault(),S(z=>{const L=z-1;return L<0?V.length-1:L});else if(re.key==="Enter"&&v>=0){re.preventDefault();const z=K[v];z&&ee(z)}};return document.addEventListener("keydown",G),()=>document.removeEventListener("keydown",G)},[v,K]),x.useEffect(()=>{if(v>=0){const G=`sampling-request-${K[v]?.id}`,re=document.getElementById(G);re&&re.scrollIntoView({behavior:"smooth",block:"nearest"})}},[v,K]);const ee=x.useCallback(G=>{m(G)},[]),J=x.useCallback(()=>{window.confirm("Are you sure you want to reject all sampling requests? This cannot be undone.")&&(e.forEach(G=>{n(G.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)),I(!0),setTimeout(()=>I(!1),2e3)}catch(G){console.error("[SamplingTab] Failed to copy request:",G)}},[d]),B=x.useCallback(()=>{if(d)try{const G=new globalThis.Blob([JSON.stringify({id:d.id,serverName:d.serverName,timestamp:d.timestamp,request:d.request},null,2)],{type:"application/json"}),re=URL.createObjectURL(G),ne=document.createElement("a");ne.href=re,ne.download=`sampling-request-${Date.now()}.json`,document.body.appendChild(ne),ne.click(),document.body.removeChild(ne),URL.revokeObjectURL(re)}catch(G){console.error("[SamplingTab] Failed to download request:",G)}},[d]),Z=x.useCallback(async()=>{if(O.current)try{document.fullscreenElement?await document.exitFullscreen():await O.current.requestFullscreen()}catch(G){console.error("[SamplingTab] Failed to toggle fullscreen:",G)}},[]);return r?f.jsxs(Jr,{direction:"horizontal",className:"h-full",children:[f.jsx(Rn,{defaultSize:40,minSize:30,children:f.jsx(Jr,{direction:"vertical",className:"h-full border-r dark:border-zinc-700",children:f.jsxs(Rn,{defaultSize:75,minSize:30,children:[f.jsx(P_e,{isSearchExpanded:_,searchQuery:h,filteredRequestsCount:K.length,requestsCount:e.length,onSearchExpand:()=>E(!0),onSearchChange:g,onSearchBlur:H,onRejectAll:J,searchInputRef:M}),f.jsx("div",{className:"flex flex-col h-full",children:f.jsx(U_e,{requests:K,selectedRequest:d,onRequestSelect:ee,focusedIndex:v,formatRelativeTime:hv,listRef:A})})]})})}),f.jsx(bi,{}),f.jsx(Rn,{defaultSize:60,minSize:40,children:f.jsx("div",{ref:O,className:"h-full bg-white dark:bg-zinc-900",children:f.jsx(F_e,{request:d,onApprove:t,onReject:n,onClose:()=>m(null),previewMode:k,onTogglePreview:()=>R(!k),isCopied:C,onCopy:ie,onDownload:B,onFullscreen:Z,llmConfig:u})})})]}):f.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[f.jsx(V9,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),f.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"Not connected to server"})]})}function H_e({isSearchExpanded:e,searchQuery:t,filteredRequestsCount:n,requestsCount:a,onSearchExpand:r,onSearchChange:i,onSearchBlur:s,onCancelAll:c,searchInputRef:u}){return f.jsxs("div",{className:"flex flex-row items-center justify-between p-4 sm:p-4 py-3 gap-2",children:[f.jsx("div",{className:"flex items-center gap-2 flex-1",children:e?f.jsx(kn,{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"}):f.jsxs(f.Fragment,{children:[f.jsx("h2",{className:"text-lg font-medium text-gray-900 dark:text-gray-100",children:"Elicitation"}),f.jsx(xr,{className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",variant:"outline",children:n}),f.jsxs($t,{children:[f.jsx(Mt,{asChild:!0,children:f.jsx(je,{variant:"ghost",size:"sm",onClick:r,className:"h-8 w-8 p-0",children:f.jsx(sd,{className:"h-4 w-4"})})}),f.jsxs(Pt,{side:"bottom",className:"flex gap-2",children:["Search",f.jsx(gm,{children:"F"})]})]})]})}),f.jsx("div",{className:"flex items-center gap-2",children:f.jsxs($t,{children:[f.jsx(Mt,{asChild:!0,children:f.jsx(je,{variant:"ghost",size:"sm",onClick:c,disabled:a===0,className:"h-8 w-8 p-0",children:f.jsx(Wi,{className:"h-4 w-4"})})}),f.jsx(Pt,{side:"bottom",children:"Cancel all"})]})})]})}function V_e({requests:e,selectedRequest:t,onRequestSelect:n,focusedIndex:a,formatRelativeTime:r,listRef:i}){return e.length===0?f.jsx("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:f.jsx(od,{vertical:!0,noBorder:!0,message:"No elicitation requests"})}):f.jsx("div",{ref:i,className:"overflow-y-auto flex-1 overscroll-contain",children:e.map((s,c)=>{const u=s.request.mode||"form",d=u==="form"&&"requestedSchema"in s.request&&s.request.requestedSchema;return f.jsx(Vs,{id:`elicitation-request-${s.id}`,isSelected:t?.id===s.id,isFocused:a===c,title:f.jsxs("span",{className:"flex items-center gap-3",children:[s.serverName,f.jsx(xr,{variant:"outline",className:u==="url"?"bg-blue-500/20 text-blue-600 dark:text-blue-400 border-blue-500/50":"bg-green-500/20 text-green-600 dark:text-green-400 border-green-500/50",children:u})]}),description:(()=>{const m=r(s.timestamp),h=[];d&&h.push("with schema"),u==="url"&&h.push("external action");const g=h.length>0?` | ${h.join(", ")}`:"";return m+g})(),onClick:()=>n(s)},s.id)})})}function G_e({request:e,onApprove:t,onReject:n,onClose:a,previewMode:r,onTogglePreview:i,isCopied:s,onCopy:c,onDownload:u,onFullscreen:d}){const[m,h]=x.useState({}),[g,v]=x.useState(!1),S=e?.request.mode||"form",w=S==="form",y=S==="url";x.useEffect(()=>{if(e&&w&&"requestedSchema"in e.request){const A=e.request.requestedSchema,O={};if(A?.type==="object"&&A.properties)for(const[M,U]of Object.entries(A.properties)){const H=U;H.default!==void 0?O[M]=H.default:H.type==="boolean"?O[M]=!1:H.type==="number"||H.type==="integer"?O[M]=0:O[M]=""}h(O)}v(!1)},[e?.id,w]);const _=(A,O)=>{h(M=>({...M,[A]:O}))},E=()=>{if(e){if(w){if("requestedSchema"in e.request){const A=e.request.requestedSchema;if(A?.required){const O=A.required.filter(M=>m[M]===void 0||m[M]===""||m[M]===null);if(O.length>0){Jt.error("Missing required fields",{description:`Please fill in: ${O.join(", ")}`});return}}}t(e.id,{action:"accept",data:m})}else y&&t(e.id,{action:"accept"});a(),dr(()=>Promise.resolve().then(()=>Zu),void 0).then(A=>{const O=Jt(A.createElement("div",{className:"space-y-3"},A.createElement("div",null,A.createElement("strong",null,"Elicitation Response Sent"),A.createElement("p",{className:"text-sm text-muted-foreground mt-1"},"The tool will continue executing.")),A.createElement("div",{className:"flex gap-2"},A.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 M=new globalThis.CustomEvent("navigate-to-tool-result",{detail:{toolName:null}});window.dispatchEvent(M),Jt.dismiss(O)}},"View Tool Result"))),{duration:5e3})})}},k=()=>{e&&(t(e.id,{action:"decline"}),a())},R=()=>{e&&(n(e.id,"User cancelled elicitation request"),a())},C=()=>{e&&y&&"url"in e.request&&(window.open(e.request.url,"_blank"),v(!0))},I=x.useMemo(()=>{if(!e||!w||!("requestedSchema"in e.request))return null;const A=e.request.requestedSchema;if(!A||A.type!=="object"||!A.properties)return f.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:"No form schema available"});const O=A.properties,M=A.required||[];return f.jsx("div",{className:"space-y-4",children:Object.entries(O).map(([U,H])=>{const K=H,ee=M.includes(U),J=K.type||"string",ie=K.title||U,B=K.description;return f.jsxs("div",{className:"space-y-2",children:[f.jsxs(Kt,{htmlFor:`field-${U}`,children:[ie,ee&&f.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),B&&f.jsx("p",{className:"text-xs text-muted-foreground",children:B}),J==="boolean"?f.jsxs("div",{className:"flex items-center space-x-2",children:[f.jsx(Sp,{id:`field-${U}`,checked:m[U]||!1,onCheckedChange:Z=>_(U,Z)}),f.jsx(Kt,{htmlFor:`field-${U}`,className:"text-sm font-normal cursor-pointer",children:K.title||U})]}):J==="number"||J==="integer"?f.jsx(kn,{id:`field-${U}`,type:"number",value:m[U]||"",onChange:Z=>_(U,J==="integer"?parseInt(Z.target.value,10):parseFloat(Z.target.value)),placeholder:K.default?.toString()||""}):K.enum?f.jsxs("select",{id:`field-${U}`,value:m[U]||"",onChange:Z=>_(U,Z.target.value),className:"flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",children:[f.jsx("option",{value:"",children:"Select..."}),K.enum.map(Z=>f.jsx("option",{value:Z,children:Z},Z))]}):J==="string"&&(K.format==="textarea"||K.maxLength>100)?f.jsx(zl,{id:`field-${U}`,value:m[U]||"",onChange:Z=>_(U,Z.target.value),placeholder:K.default||"",rows:4}):f.jsx(kn,{id:`field-${U}`,type:"text",value:m[U]||"",onChange:Z=>_(U,Z.target.value),placeholder:K.default||""})]},U)})})},[e,m,w]);return e?f.jsxs("div",{className:"flex flex-col h-full",children:[f.jsxs("div",{className:"flex items-center justify-between p-4 border-b dark:border-zinc-700",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("h3",{className:"font-medium text-gray-900 dark:text-gray-100",children:e.serverName}),f.jsx(xr,{variant:"outline",className:y?"bg-blue-500/20 text-blue-600 dark:text-blue-400 border-blue-500/50":"bg-green-500/20 text-green-600 dark:text-green-400 border-green-500/50",children:S}),f.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:new Date(e.timestamp).toLocaleString()})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsxs($t,{children:[f.jsx(Mt,{asChild:!0,children:f.jsx(je,{variant:"ghost",size:"sm",onClick:c,className:"h-8 w-8 p-0",children:s?f.jsx(ga,{className:"h-4 w-4 text-green-600"}):f.jsx(Br,{className:"h-4 w-4"})})}),f.jsx(Pt,{children:"Copy request"})]}),f.jsxs($t,{children:[f.jsx(Mt,{asChild:!0,children:f.jsx(je,{variant:"ghost",size:"sm",onClick:u,className:"h-8 w-8 p-0",children:f.jsx(Qp,{className:"h-4 w-4"})})}),f.jsx(Pt,{children:"Download request"})]}),f.jsxs($t,{children:[f.jsx(Mt,{asChild:!0,children:f.jsx(je,{variant:"ghost",size:"sm",onClick:d,className:"h-8 w-8 p-0",children:f.jsx(iN,{className:"h-4 w-4"})})}),f.jsx(Pt,{children:"Fullscreen"})]}),f.jsx(je,{variant:"ghost",size:"sm",onClick:a,className:"h-8 w-8 p-0",children:f.jsx(Wi,{className:"h-4 w-4"})})]})]}),f.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-6",children:[f.jsxs("div",{className:"space-y-2",children:[f.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:"Message"}),f.jsx("p",{className:"text-sm text-gray-700 dark:text-gray-300",children:e.request.message})]}),y&&"url"in e.request&&f.jsxs("div",{className:"space-y-2",children:[f.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:"External Action Required"}),f.jsxs("div",{className:"bg-muted rounded-lg p-4 space-y-3",children:[f.jsx("p",{className:"text-sm text-muted-foreground",children:"This request requires you to complete an action at an external URL:"}),f.jsxs("div",{className:"flex items-center gap-2 p-2 bg-background rounded border",children:[f.jsx("code",{className:"flex-1 text-xs font-mono break-all",children:e.request.url}),f.jsxs(je,{size:"sm",variant:"outline",onClick:C,className:"flex items-center gap-2",children:[f.jsx(lE,{className:"h-4 w-4"}),"Open URL"]})]}),f.jsxs("div",{className:"flex items-center space-x-2 pt-2",children:[f.jsx(Sp,{id:"url-completed",checked:g,onCheckedChange:A=>v(!!A)}),f.jsx(Kt,{htmlFor:"url-completed",className:"text-sm font-normal cursor-pointer",children:"I have completed the required action"})]})]})]}),w&&f.jsxs("div",{className:"space-y-2",children:[f.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:"Form Data"}),I]}),w&&"requestedSchema"in e.request&&e.request.requestedSchema&&f.jsxs("details",{className:"space-y-2",children:[f.jsx("summary",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100 cursor-pointer",children:"Schema (for reference)"}),f.jsx("div",{className:"bg-muted rounded-lg p-3 max-h-64 overflow-auto",children:f.jsx(Jn,{data:e.request.requestedSchema})})]})]}),f.jsxs("div",{className:"flex gap-2 p-4 border-t dark:border-zinc-700",children:[f.jsx(je,{onClick:E,className:"flex-1",children:"Accept"}),f.jsx(je,{onClick:k,variant:"outline",className:"flex-1",children:"Decline"}),f.jsx(je,{onClick:R,variant:"outline",className:"flex-1",children:"Cancel"})]})]}):f.jsx("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:f.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"Select an elicitation request to view details"})})}function W_e({pendingRequests:e=[],onApprove:t,onReject:n,serverId:a,isConnected:r}){const{selectedElicitationRequestId:i,setSelectedElicitationRequestId:s}=Zl(),[c,u]=x.useState(null),[d,m]=x.useState(""),[h,g]=x.useState(-1),[v,S]=x.useState(!0),[w,y]=x.useState(!1),[_,E]=x.useState(!0),[k,R]=x.useState(!1),C=x.useRef(null),I=x.useRef(null),A=x.useRef(null),O=x.useRef(!1);x.useEffect(()=>{if(console.log("[ElicitationTab] Auto-selection check:",{selectedElicitationRequestId:i,pendingRequestsCount:e.length,currentSelectedId:c?.id}),i&&e.length>0){const B=e.find(Z=>Z.id===i);console.log("[ElicitationTab] Found request for auto-selection:",!!B,B?.id),B&&(console.log("[ElicitationTab] Auto-selecting request:",B.id),s(null),u(B),setTimeout(()=>{const Z=document.getElementById(`elicitation-request-${B.id}`);console.log("[ElicitationTab] Scrolling to element:",!!Z),Z&&Z.scrollIntoView({behavior:"smooth",block:"nearest"})},100))}},[i,e,s]),x.useEffect(()=>{const B=Z=>{const re=Z.detail.requestId;console.log("[ElicitationTab] Custom navigate event received:",re);const ne=e.find(j=>j.id===re);ne&&(console.log("[ElicitationTab] Selecting request from event:",re),u(ne),setTimeout(()=>{const j=document.getElementById(`elicitation-request-${re}`);j&&j.scrollIntoView({behavior:"smooth",block:"nearest"})},200))};return window.addEventListener("navigate-to-elicitation",B),()=>window.removeEventListener("navigate-to-elicitation",B)},[e]),x.useEffect(()=>{v&&e.length>0&&C.current&&!O.current&&(C.current.scrollTop=0)},[e.length,v]),x.useEffect(()=>{const B=C.current;if(!B)return;const Z=()=>{B.scrollTop>0&&(O.current=!0,S(!1))};return B.addEventListener("scroll",Z),()=>B.removeEventListener("scroll",Z)},[]),x.useEffect(()=>{e.length===0&&(O.current=!1,S(!0))},[e.length]),x.useEffect(()=>{w&&A.current&&A.current.focus()},[w]);const M=x.useCallback(()=>{d.trim()||y(!1)},[d]),U=x.useMemo(()=>{if(!d.trim())return e;const B=d.toLowerCase();return e.filter(Z=>Z.serverName.toLowerCase().includes(B)||Z.request.message.toLowerCase().includes(B)||JSON.stringify(Z.request||{}).toLowerCase().includes(B))},[e,d]);x.useEffect(()=>{g(-1)},[d]),x.useEffect(()=>{const B=Z=>{const G=Z.target;if(G.tagName==="INPUT"||G.tagName==="TEXTAREA"||G.contentEditable==="true"||Z.metaKey||Z.ctrlKey||Z.altKey)return;const ne=U;if(Z.key==="ArrowDown")Z.preventDefault(),g(j=>{const V=j+1;return V>=ne.length?0:V});else if(Z.key==="ArrowUp")Z.preventDefault(),g(j=>{const V=j-1;return V<0?ne.length-1:V});else if(Z.key==="Enter"&&h>=0){Z.preventDefault();const j=U[h];j&&H(j)}};return document.addEventListener("keydown",B),()=>document.removeEventListener("keydown",B)},[h,U]),x.useEffect(()=>{if(h>=0){const B=`elicitation-request-${U[h]?.id}`,Z=document.getElementById(B);Z&&Z.scrollIntoView({behavior:"smooth",block:"nearest"})}},[h,U]);const H=x.useCallback(B=>{u(B)},[]),K=x.useCallback(()=>{window.confirm("Are you sure you want to cancel all elicitation requests? This cannot be undone.")&&(e.forEach(B=>{n(B.id,"User cancelled all requests")}),u(null))},[e,n]),ee=x.useCallback(async()=>{if(c)try{await navigator.clipboard.writeText(JSON.stringify({id:c.id,serverName:c.serverName,timestamp:c.timestamp,request:c.request},null,2)),R(!0),setTimeout(()=>R(!1),2e3)}catch(B){console.error("[ElicitationTab] Failed to copy request:",B)}},[c]),J=x.useCallback(()=>{if(c)try{const B=new globalThis.Blob([JSON.stringify({id:c.id,serverName:c.serverName,timestamp:c.timestamp,request:c.request},null,2)],{type:"application/json"}),Z=URL.createObjectURL(B),G=document.createElement("a");G.href=Z,G.download=`elicitation-request-${Date.now()}.json`,document.body.appendChild(G),G.click(),document.body.removeChild(G),URL.revokeObjectURL(Z)}catch(B){console.error("[ElicitationTab] Failed to download request:",B)}},[c]),ie=x.useCallback(async()=>{if(I.current)try{document.fullscreenElement?await document.exitFullscreen():await I.current.requestFullscreen()}catch(B){console.error("[ElicitationTab] Failed to toggle fullscreen:",B)}},[]);return r?f.jsxs(Jr,{direction:"horizontal",className:"h-full",children:[f.jsx(Rn,{defaultSize:40,minSize:30,children:f.jsx(Jr,{direction:"vertical",className:"h-full border-r dark:border-zinc-700",children:f.jsxs(Rn,{defaultSize:75,minSize:30,children:[f.jsx(H_e,{isSearchExpanded:w,searchQuery:d,filteredRequestsCount:U.length,requestsCount:e.length,onSearchExpand:()=>y(!0),onSearchChange:m,onSearchBlur:M,onCancelAll:K,searchInputRef:A}),f.jsx("div",{className:"flex flex-col h-full",children:f.jsx(V_e,{requests:U,selectedRequest:c,onRequestSelect:H,focusedIndex:h,formatRelativeTime:hv,listRef:C})})]})})}),f.jsx(bi,{}),f.jsx(Rn,{defaultSize:60,minSize:40,children:f.jsx("div",{ref:I,className:"h-full bg-white dark:bg-zinc-900",children:f.jsx(G_e,{request:c,onApprove:t,onReject:n,onClose:()=>u(null),previewMode:_,onTogglePreview:()=>E(!_),isCopied:k,onCopy:ee,onDownload:J,onFullscreen:ie})})})]}):f.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[f.jsx(Z9,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),f.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"Not connected to server"})]})}function K_e({selectedServer:e,activeTab:t,toolsSearchRef:n,promptsSearchRef:a,resourcesSearchRef:r,children:i}){return e?f.jsxs(f.Fragment,{children:[f.jsx("div",{style:{display:t==="tools"?"block":"none"},className:"h-full",children:f.jsx(tZ,{ref:n,tools:e.tools,callTool:e.callTool,readResource:e.readResource,serverId:e.id,isConnected:e.state==="ready"})}),f.jsx("div",{style:{display:t==="prompts"?"block":"none"},className:"h-full",children:f.jsx(XK,{ref:a,prompts:e.prompts,callPrompt:e.getPrompt,serverId:e.id,isConnected:e.state==="ready"})}),f.jsx("div",{style:{display:t==="resources"?"block":"none"},className:"h-full",children:f.jsx(QK,{ref:r,resources:e.resources,readResource:e.readResource,serverId:e.id,isConnected:e.state==="ready"})}),f.jsx("div",{style:{display:t==="chat"?"block":"none"},className:"h-full",children:f.jsx(XEe,{connection:e,isConnected:e.state==="ready",readResource:e.readResource},e.id)}),f.jsx("div",{style:{display:t==="sampling"?"block":"none"},className:"h-full",children:f.jsx(B_e,{pendingRequests:e.pendingSamplingRequests,onApprove:e.approveSampling,onReject:e.rejectSampling,serverId:e.id,isConnected:e.state==="ready",mcpServerUrl:e.url})}),f.jsx("div",{style:{display:t==="elicitation"?"block":"none"},className:"h-full",children:f.jsx(W_e,{pendingRequests:e.pendingElicitationRequests,onApprove:e.approveElicitation,onReject:e.rejectElicitation,serverId:e.id,isConnected:e.state==="ready"})}),f.jsx("div",{style:{display:t==="notifications"?"block":"none"},className:"h-full",children:f.jsx(R_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!=="elicitation"&&t!=="notifications"&&f.jsx(f.Fragment,{children:i})]}):f.jsx(f.Fragment,{children:i})}function r2({className:e}){return f.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:[f.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"}),f.jsx("path",{d:"M9 18c-4.51 2-5-2-7-2"})]})}const nZ=x.createContext(void 0);function rZ(){const e=x.use(nZ);if(!e)throw new Error("useTabs must be used within a TabsProvider");return e}const aZ=x.createContext(void 0);function Z_e(){return x.use(aZ)}function h_({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 f.jsx(nZ,{value:{activeValue:h,handleValueChange:m},children:f.jsx("div",{ref:e,className:De("flex flex-col gap-2",i),...s,children:t})})}h_.displayName="Tabs";function g_({ref:e,children:t,className:n,variant:a="default",...r}){const{activeValue:i}=rZ(),[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(w=>x.isValidElement(w)&&w.props.value===i),v=x.useCallback(()=>{const w=u.current;if(!w)return;const _=w.querySelectorAll("button")[g];if(_){const E=w.getBoundingClientRect(),k=_.getBoundingClientRect();c({width:k.width,left:k.left-E.left})}},[g]),S=x.useCallback(()=>{m.current&&clearTimeout(m.current),m.current=setTimeout(v,16)},[v]);return x.useEffect(()=>{const w=setTimeout(v,10);return()=>clearTimeout(w)},[v]),x.useEffect(()=>{const w=u.current;return w?(d.current=new ResizeObserver(()=>{S()}),d.current.observe(w),w.querySelectorAll("button").forEach(_=>{d.current&&d.current.observe(_)}),()=>{d.current&&d.current.disconnect(),m.current&&clearTimeout(m.current)}):void 0},[S]),x.useEffect(()=>{const w=()=>{S()};return window.addEventListener("resize",w),()=>window.removeEventListener("resize",w)},[S]),x.useEffect(()=>{const w=u.current;if(!w)return;const y=w.querySelector("[data-width]");y&&(y.style.width=`${s.width}px`,y.style.left=`${s.left}px`)},[s]),f.jsx(aZ,{value:{variant:a},children:f.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,f.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})]})})}g_.displayName="TabsList";function b_({ref:e,children:t,value:n,className:a,disabled:r,icon:i,...s}){const{activeValue:c,handleValueChange:u}=rZ(),m=Z_e()?.variant||"default",h=c===n;return f.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&&f.jsx(i,{className:"mr-2 h-4 w-4"}),t]})}b_.displayName="TabsTrigger";function a2({className:e}){const{theme:t,setTheme:n}=Dy(),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"?f.jsx(dU,{className:"size-4"}):t==="light"?f.jsx(Zpe,{className:"size-5"}):f.jsx(Npe,{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:S}=a.current.getBoundingClientRect(),w=h+S/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 ${w}px)`,`circle(${k}px at ${y}px ${w}px)`]},{duration:700,easing:"ease-in-out",pseudoElement:"::view-transition-new(root)"})}else n(m)};return r?f.jsx("button",{ref:a,onClick:d,className:De(e),"aria-label":u(),title:`Current: ${t==="system"?"Auto":t==="light"?"Light":"Dark"}`,children:c()}):f.jsx("button",{ref:a,className:De(e),"aria-label":"Toggle theme",children:f.jsx(dU,{className:"size-4"})})}function i2({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 f.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:[f.jsx("div",{className:"relative",children:f.jsxs(ha.svg,{viewBox:"0 0 303 303",initial:"rest",animate:a?"hover":"rest",className:De("text-foreground",t==="expanded"?"size-[40px]":"size-[20px]"),children:[f.jsxs(ha.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:[f.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"}),f.jsx("circle",{cx:"70.3",cy:"232.3",r:"50"}),f.jsx("circle",{cx:"232.3",cy:"70.3",r:"50"})]}),f.jsxs("g",{fill:"none",stroke:"currentColor",strokeWidth:u,strokeLinecap:"round",strokeLinejoin:"round",children:[f.jsx(Y_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}),f.jsx(o2,{cx:70.3,cy:232.3,r:50,times:{T0:m,T1:h,T2:g,T3:v},total:d}),f.jsx(o2,{cx:232.3,cy:70.3,r:50,times:{T0:m,T1:h,T2:g,T3:v},total:d})]})]})}),t==="expanded"&&f.jsxs("div",{className:"font-ubuntu flex flex-col items-start -space-y-1 mr-3",children:[f.jsx("h1",{className:"text-xl font-medium",children:"mcp-use"}),f.jsx("span",{className:"text-lg text-muted-foreground tracking-wide font-sans font-light",children:"Inspector"})]})]})}function Y_e({d:e,times:t,total:n}){const{T0:a,T1:r,T2:i,T3:s}=t;return f.jsx(ha.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 o2({cx:e,cy:t,r:n,times:a,total:r}){const{T0:i,T1:s,T2:c,T3:u}=a;return f.jsx(ha.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 iZ({ref:e,shimmerColor:t,shimmerSize:n="0.05em",shimmerDuration:a="3s",borderRadius:r="100px",background:i,className:s,children:c,...u}){const{resolvedTheme:d}=Dy(),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 f.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:[f.jsx("div",{className:De("-z-30 blur-[2px]","[container-type:size] absolute inset-0 overflow-visible"),children:f.jsx("div",{className:"animate-shimmer-slide absolute inset-0 [aspect-ratio:1] h-[100cqh] [border-radius:0] [mask:none]",children:f.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,f.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]")}),f.jsx("div",{className:De("absolute [inset:var(--cut)] -z-20 [border-radius:var(--radius)] [background:var(--bg)]")})]})}iZ.displayName="ShimmerButton";function s2({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 f.jsxs($t,{children:[f.jsx(Mt,{asChild:!0,children:f.jsxs("div",{className:"relative",children:[f.jsx("div",{className:`absolute w-2 h-2 rounded-full ${a} animate-ping`}),f.jsx("div",{className:`relative w-2 h-2 rounded-full ${n}`})]})}),f.jsx(Pt,{children:f.jsx("p",{children:r})})]})}function l2({connections:e,selectedServer:t,onServerSelect:n,onOpenConnectionOptions:a,mobileMode:r=!1}){const i=Ju(),s=c=>{const u=e.find(d=>d.id===c);if(!u||u.state!=="ready"){Jt.error("Server is not connected and cannot be inspected");return}n(c)};return r?f.jsx("div",{className:"flex items-center gap-2",children:f.jsx("div",{className:"relative",children:f.jsxs(rE,{children:[f.jsx(aE,{asChild:!0,children:f.jsxs(je,{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?f.jsx(Sl,{serverUrl:t.url,serverName:t.name,size:"md"}):f.jsx(Ppe,{className:"h-5 w-5"}),f.jsx(Kl,{className:"h-4 w-4"})]})}),f.jsxs(Ub,{className:"w-[calc(100vw-2rem)] sm:w-[300px]",align:"start",children:[f.jsx(iE,{className:"cursor-pointer hover:bg-zinc-100 dark:hover:bg-zinc-800",onClick:()=>i("/"),children:"MCP Servers"}),f.jsx(_f,{}),e.length===0?f.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=>f.jsxs(Eo,{onClick:()=>s(c.id),className:"flex items-center gap-3",children:[f.jsx(Sl,{serverUrl:c.url,serverName:c.name,size:"sm"}),f.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[f.jsx("div",{className:"font-medium",children:c.name}),f.jsx(s2,{status:c.state})]}),f.jsx(je,{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:f.jsx(fu,{className:"h-3 w-3"})})]},c.id)),f.jsx(_f,{}),f.jsx(Eo,{onClick:()=>i("/"),children:f.jsx("span",{className:"text-blue-600 dark:text-blue-400",children:"+ Add new server"})})]})]})})}):f.jsx("div",{className:"flex items-center gap-2",children:f.jsx("div",{className:"relative",children:f.jsxs(rE,{children:[f.jsx(aE,{asChild:!0,children:f.jsxs(iZ,{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&&f.jsx(Sl,{serverUrl:t.url,serverName:t.name,size:"md",className:"mr-2"}),f.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[f.jsx("span",{className:"truncate",children:t?t.name:"Select server to inspect"}),t&&f.jsx("div",{className:"flex items-center gap-2",children:t.error&&t.state!=="ready"?f.jsxs($t,{children:[f.jsx(Mt,{asChild:!0,children:f.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"})}),f.jsx(Pt,{children:f.jsx("p",{className:"max-w-xs",children:t.error})})]}):f.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&&f.jsxs($t,{children:[f.jsx(Mt,{asChild:!0,children:f.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:f.jsx(fu,{className:"h-4 w-4"})})}),f.jsx(Pt,{children:f.jsx("p",{children:"Edit connection settings"})})]}),f.jsxs(Ub,{className:"w-[calc(100vw-2rem)] sm:w-[300px]",align:"start",children:[f.jsx(iE,{className:"cursor-pointer hover:bg-zinc-100 dark:hover:bg-zinc-800",onClick:()=>i("/"),children:"MCP Servers"}),f.jsx(_f,{}),e.length===0?f.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=>f.jsxs(Eo,{onClick:()=>s(c.id),className:"flex items-center gap-3",children:[f.jsx(Sl,{serverUrl:c.url,serverName:c.name,size:"sm"}),f.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[f.jsx("div",{className:"font-medium",children:c.name}),f.jsx(s2,{status:c.state})]}),f.jsx(je,{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:f.jsx(fu,{className:"h-3 w-3"})})]},c.id)),f.jsx(_f,{}),f.jsx(Eo,{onClick:()=>i("/"),children:f.jsx("span",{className:"text-blue-600 dark:text-blue-400",children:"+ Add new server"})})]})]})})})}const c2=[{id:"tools",label:"Tools",icon:Ll},{id:"prompts",label:"Prompts",icon:lp},{id:"resources",label:"Resources",icon:cpe},{id:"chat",label:"Chat",icon:xpe},{id:"sampling",label:"Sampling",icon:V9},{id:"elicitation",label:"Elicitation",icon:Z9},{id:"notifications",label:"Notifications",icon:nN}];function u2(e,t){return e==="tools"?t.tools.length:e==="prompts"?t.prompts.length:e==="resources"?t.resources.length:e==="sampling"?t.pendingSamplingRequests?.length||0:e==="elicitation"?t.pendingElicitationRequests?.length||0:e==="notifications"?t.unreadNotificationCount:0}function q_e({connections:e,selectedServer:t,activeTab:n,onServerSelect:a,onTabChange:r,onCommandPaletteOpen:i,onOpenConnectionOptions:s}){const{tunnelUrl:c}=Zl(),u=t&&c,[d,m]=x.useState(!1),h=async()=>{if(c)try{await navigator.clipboard.writeText(`${c}/mcp`),m(!0),Jt.success("Tunnel URL copied to clipboard"),setTimeout(()=>m(!1),2e3)}catch{Jt.error("Failed to copy URL")}};return f.jsxs("header",{className:"w-full mx-auto",children:[f.jsxs("div",{className:"flex lg:hidden flex-col gap-3",children:[f.jsxs("div",{className:"flex items-center justify-between w-full",children:[f.jsx("div",{className:"flex-1 flex justify-start",children:f.jsx(l2,{connections:e,selectedServer:t,onServerSelect:a,onOpenConnectionOptions:s,mobileMode:!0})}),f.jsx("div",{className:"flex-shrink-0 flex justify-center",children:f.jsx("div",{className:"scale-150",children:f.jsx(i2,{state:"collapsed"})})}),f.jsxs("div",{className:"flex-1 flex justify-end items-center gap-2",children:[f.jsxs($t,{children:[f.jsx(Mt,{asChild:!0,children:f.jsx(je,{variant:"ghost",size:"sm",asChild:!0,children:f.jsx("a",{href:"https://github.com/mcp-use/mcp-use",target:"_blank",rel:"noopener noreferrer",className:"p-2","aria-label":"GitHub",children:f.jsx(r2,{className:"h-4 w-4"})})})}),f.jsx(Pt,{children:f.jsx("p",{children:"Give us a star ⭐"})})]}),f.jsx(a2,{className:"p-2 hover:bg-zinc-200 dark:hover:bg-zinc-800 rounded-full transition-colors cursor-pointer"})]})]}),t&&f.jsx("div",{className:"w-full",children:f.jsx(h_,{value:n,onValueChange:g=>r(g),children:f.jsx(g_,{className:"w-full justify-center",children:c2.map(g=>{const v=u2(g.id,t);return f.jsxs(b_,{value:g.id,icon:g.icon,className:"[&>svg]:mr-0 flex-1 flex-row gap-2 relative",children:[v>0&&f.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}),f.jsx("span",{className:"sr-only",children:g.label})]},g.id)})})})})]}),f.jsxs("div",{className:"hidden lg:flex items-center justify-between gap-3",children:[f.jsxs("div",{className:"flex items-center flex-wrap gap-2 md:space-x-6 space-x-2",children:[f.jsx(l2,{connections:e,selectedServer:t,onServerSelect:a,onOpenConnectionOptions:s}),t&&f.jsx(h_,{value:n,onValueChange:g=>r(g),children:f.jsx(g_,{className:"overflow-x-auto",children:c2.map(g=>{const v=u2(g.id,t);return f.jsx(b_,{value:g.id,icon:g.icon,className:"[&>svg]:mr-0 lg:[&>svg]:mr-2 relative",children:f.jsxs("div",{className:"items-center gap-2 hidden lg:flex",children:[g.label,v>0&&f.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&&f.jsxs(JW,{children:[f.jsx(QW,{asChild:!0,children:f.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:[f.jsx(cp,{className:"size-4 text-purple-600 dark:text-purple-400 animate-pulse"}),f.jsx("span",{className:"text-xs font-medium text-purple-700 dark:text-purple-300 hidden lg:inline",children:"Tunnel"})]})}),f.jsx(QN,{className:"w-[calc(100vw-2rem)] sm:w-96",align:"start",children:f.jsxs("div",{className:"space-y-4",children:[f.jsxs("div",{children:[f.jsxs("h4",{className:"font-semibold text-sm mb-2 flex items-center gap-2",children:[f.jsx(cp,{className:"size-4 text-purple-600 dark:text-purple-400"}),"Tunnel URL"]}),f.jsxs("div",{className:"flex items-center gap-2 p-2 py-0 bg-muted rounded-full",children:[f.jsxs("code",{className:"flex-1 text-[10px] font-mono",children:[c,"/mcp"]}),f.jsx(je,{variant:"ghost",size:"sm",className:"h-7 px-2",onClick:h,children:d?f.jsx(ga,{className:"size-3.5 text-green-600"}):f.jsx(Br,{className:"size-3.5"})})]})]}),f.jsxs("div",{children:[f.jsx("h5",{className:"font-semibold text-sm mb-2",children:"Use in ChatGPT"}),f.jsxs("ol",{className:"space-y-2 text-xs text-muted-foreground",children:[f.jsxs("li",{className:"flex gap-2",children:[f.jsx("span",{className:"font-semibold text-foreground",children:"1."}),f.jsxs("span",{children:["Enable"," ",f.jsx("span",{className:"font-medium text-foreground",children:"dev mode"})," ","from settings"]})]}),f.jsxs("li",{className:"flex gap-2",children:[f.jsx("span",{className:"font-semibold text-foreground",children:"2."}),f.jsxs("span",{children:["In"," ",f.jsx("span",{className:"font-medium text-foreground",children:"App & Connectors"})," ","click on"," ",f.jsx("span",{className:"font-medium text-foreground",children:"create"})]})]}),f.jsxs("li",{className:"flex gap-2",children:[f.jsx("span",{className:"font-semibold text-foreground",children:"3."}),f.jsx("span",{children:"Use the tunnel URL in the input"})]})]})]})]})})]})]}),f.jsxs("div",{className:"flex items-center gap-2 sm:gap-4 flex-shrink-0",children:[f.jsxs($t,{children:[f.jsx(Mt,{children:f.jsx(a2,{className:"p-2 hover:bg-zinc-200 dark:hover:bg-zinc-800 rounded-full transition-colors cursor-pointer"})}),f.jsx(Pt,{children:f.jsx("p",{children:"Toggle theme"})})]}),f.jsxs($t,{children:[f.jsx(Mt,{asChild:!0,children:f.jsxs(je,{variant:"ghost",className:"hover:bg-zinc-200 dark:hover:bg-zinc-800 rounded-full px-1 -mx-3 flex gap-1",onClick:i,children:[f.jsx(Wfe,{className:"size-4"}),f.jsx("span",{className:"text-base font-mono hidden sm:inline",children:"K"})]})}),f.jsx(Pt,{children:f.jsx("p",{children:"Command Palette"})})]}),f.jsxs($t,{children:[f.jsx(Mt,{asChild:!0,children:f.jsx(je,{variant:"ghost",size:"sm",asChild:!0,children:f.jsxs("a",{href:"https://github.com/mcp-use/mcp-use",className:"flex items-center gap-2",target:"_blank",rel:"noopener noreferrer",children:[f.jsx(r2,{className:"h-4 w-4"}),f.jsx("span",{className:"hidden sm:inline",children:"Github"})]})})}),f.jsx(Pt,{children:f.jsx("p",{children:"Give us a star ⭐"})})]}),f.jsx(i2,{state:"expanded"})]})]})]})}function X_e({children:e}){const t=Ju(),n=Uo(),{connections:a,addConnection:r,removeConnection:i,updateConnectionConfig:s,configLoaded:c}=tN(),{selectedServerId:u,setSelectedServerId:d,activeTab:m,setActiveTab:h,navigateToItem:g,setTunnelUrl:v}=Zl(),[S,w]=x.useState(!1),[y,_]=x.useState(null),E=mwe();x.useEffect(()=>{const Z=new URLSearchParams(n.search).get("tunnelUrl");v(Z)},[n.search,v]),x.useEffect(()=>{const B=re=>{const j=re.detail.requestId;u&&g(u,"sampling",j)},Z=re=>{const j=re.detail.requestId;u&&g(u,"elicitation",j)},G=re=>{const j=re.detail.toolName;u&&j?g(u,"tools",j):u&&h("tools")};return window.addEventListener("navigate-to-sampling",B),window.addEventListener("navigate-to-elicitation",Z),window.addEventListener("navigate-to-tool-result",G),()=>{window.removeEventListener("navigate-to-sampling",B),window.removeEventListener("navigate-to-elicitation",Z),window.removeEventListener("navigate-to-tool-result",G)}},[u,h,g]);const k=x.useRef(null),R=x.useRef(null),C=x.useRef(null),{isAutoConnecting:I}=pwe({connections:a,addConnection:r,removeConnection:i,configLoaded:c}),A=x.useCallback(B=>{yr.getInstance().capture(new lfe({trigger:B})).catch(()=>{}),w(!0)},[]),O=B=>{const Z=a.find(j=>j.id===B);if(!Z||Z.state!=="ready"){Jt.error("Server is not connected and cannot be inspected");return}d(B);const re=new URLSearchParams(n.search).get("tunnelUrl"),ne=re?`/?server=${encodeURIComponent(B)}&tunnelUrl=${encodeURIComponent(re)}`:`/?server=${encodeURIComponent(B)}`;t(ne)},M=x.useCallback(B=>{_(B)},[]),U=x.useCallback(B=>{y&&(B.url!==y?(i(y),r(B.url,B.name,B.proxyConfig,B.transportType)):s(y,{name:B.name,proxyConfig:B.proxyConfig,transportType:B.transportType}),_(null),Jt.success("Connection settings updated"))},[y,i,r,s]),H=(B,Z,G)=>{if(console.warn("[Layout] handleCommandPaletteNavigate called:",{tab:B,itemName:Z,serverId:G}),G){const re=a.find(z=>z.id===G);if(console.warn("[Layout] Server lookup:",{serverId:G,serverFound:!!re,serverState:re?.state}),!re||re.state!=="ready"){console.warn("[Layout] Server not ready, showing error"),Jt.error("Server is not connected and cannot be inspected");return}console.warn("[Layout] Calling navigateToItem:",{serverId:G,tab:B,itemName:Z}),g(G,B,Z);const j=new URLSearchParams(n.search).get("tunnelUrl"),V=j?`/?server=${encodeURIComponent(G)}&tunnelUrl=${encodeURIComponent(j)}`:`/?server=${encodeURIComponent(G)}`;console.warn("[Layout] Navigating to:",V),t(V)}else console.warn("[Layout] No serverId, just updating tab to:",B),h(B)},K=a.find(B=>B.id===u),ee=K?K.tools.map(B=>({...B,_serverId:K.id})):a.flatMap(B=>B.state==="ready"?B.tools.map(Z=>({...Z,_serverId:B.id,_serverName:B.name})):[]),J=K?K.prompts.map(B=>({...B,_serverId:K.id})):a.flatMap(B=>B.state==="ready"?B.prompts.map(Z=>({...Z,_serverId:B.id,_serverName:B.name})):[]),ie=K?K.resources.map(B=>({...B,_serverId:K.id})):a.flatMap(B=>B.state==="ready"?B.resources.map(Z=>({...Z,_serverId:B.id,_serverName:B.name})):[]);return x.useEffect(()=>{const Z=new URLSearchParams(n.search).get("server"),G=Z?decodeURIComponent(Z):null;G!==u&&d(G)},[n.search,u,d]),x.useEffect(()=>{const Z=new URLSearchParams(n.search).get("server");if(!Z)return;const G=decodeURIComponent(Z),re=a.find(ne=>ne.id===G);if(!re){const ne=setTimeout(()=>t("/"),3e3);return()=>clearTimeout(ne)}if(re.state==="failed"){const ne=setTimeout(()=>t("/"),2e3);return()=>clearTimeout(ne)}},[n.search,t,a]),TW({onCommandPalette:()=>A("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"&&R.current?R.current.focusSearch():m==="resources"&&C.current&&C.current.focusSearch()},onBlurSearch:()=>{m==="tools"&&k.current?k.current.blurSearch():m==="prompts"&&R.current?R.current.blurSearch():m==="resources"&&C.current&&C.current.blurSearch()}}),I?f.jsx("div",{className:"h-screen bg-white dark:bg-zinc-900 flex items-center justify-center",children:f.jsxs("div",{className:"flex flex-col items-center gap-4",children:[f.jsx(Hi,{className:"h-8 w-8 text-zinc-600 dark:text-zinc-400"}),f.jsx("p",{className:"text-sm text-zinc-600 dark:text-zinc-400",children:"Connecting to MCP server..."})]})}):f.jsx(P9,{children:f.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:[f.jsx(q_e,{connections:a,selectedServer:K,activeTab:m,onServerSelect:O,onTabChange:h,onCommandPaletteOpen:()=>A("button"),onOpenConnectionOptions:M}),f.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:f.jsx(K_e,{selectedServer:K,activeTab:m,toolsSearchRef:k,promptsSearchRef:R,resourcesSearchRef:C,children:e})}),f.jsx(Fwe,{isOpen:S,onOpenChange:w,tools:ee,prompts:J,resources:ie,savedRequests:E,connections:a,onNavigate:H,onServerSelect:O}),f.jsx(H8,{connection:y&&a.find(B=>B.id===y)||null,open:y!==null,onOpenChange:B=>{B||_(null)},onConnect:U})]})})}function J_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),kT().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"?f.jsx("div",{className:"h-screen w-full flex items-center justify-center bg-white dark:bg-zinc-900",children:f.jsxs("div",{className:"flex flex-col items-center gap-4",children:[f.jsx(Is,{className:"h-8 w-8 animate-spin text-zinc-600 dark:text-zinc-400"}),f.jsx("p",{className:"text-sm text-zinc-600 dark:text-zinc-400",children:"Completing authentication..."})]})}):e==="error"?f.jsx("div",{className:"h-screen w-full flex items-center justify-center bg-white dark:bg-zinc-900",children:f.jsxs("div",{className:"max-w-md p-6",children:[f.jsx("h1",{className:"text-xl font-semibold text-red-600 dark:text-red-400 mb-2",children:"Authentication Error"}),f.jsx("p",{className:"text-sm text-zinc-600 dark:text-zinc-400 mb-4",children:n}),f.jsx("p",{className:"text-xs text-zinc-500 dark:text-zinc-500",children:"You can close this window and try again."})]})}):f.jsx("div",{className:"h-screen w-full flex items-center justify-center bg-white dark:bg-zinc-900",children:f.jsxs("div",{className:"max-w-md p-6",children:[f.jsx("h1",{className:"text-xl font-semibold text-green-600 dark:text-green-400 mb-2",children:"Authentication Successful!"}),f.jsx("p",{className:"text-sm text-zinc-600 dark:text-zinc-400",children:"Redirecting you back..."})]})})}var Q_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(S=>{let w=S==="class",y=w&&i?r.map(_=>i[_]||_):r;w?(u.classList.remove(...y),u.classList.add(i&&i[v]?i[v]:v)):u.setAttribute(S,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,S=s&&v==="system"?g():v;m(S)}catch{}},eke=x.createContext(void 0),tke={setTheme:e=>{},themes:[]},nke=()=>{var e;return(e=x.useContext(eke))!=null?e:tke};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:`(${Q_e.toString()})(${m})`}})});function rke({...e}){const{theme:t="system"}=nke();return f.jsx(Y9,{theme:t,className:"toaster group",style:{"--normal-bg":"var(--popover)","--normal-text":"var(--popover-foreground)","--normal-border":"var(--border)"},...e})}function ake(){return f.jsx(ASe,{children:f.jsx(hfe,{children:f.jsxs(fwe,{children:[f.jsx(poe,{basename:"/inspector",children:f.jsxs(Vie,{children:[f.jsx(KS,{path:"/oauth/callback",element:f.jsx(J_e,{})}),f.jsx(KS,{path:"/",element:f.jsx(X_e,{children:f.jsx(dwe,{})})})]})}),f.jsx(rke,{position:"top-center"})]})})})}const d2=new URLSearchParams(window.location.search);if(d2.has("code")||d2.has("error"))try{kT()}catch(e){console.error("[inspector] OAuth callback error:",e)}const f2=document.getElementById("root");f2?Qae.createRoot(f2).render(f.jsx(ake,{})):console.error("[inspector] Root element not found");export{E3 as $,v6 as A,b6 as B,Av as C,S6 as D,I5 as E,Wg as F,$ae as G,uP as H,kT as I,g2 as L,Iae as M,ue as R,jae as W,Nt as Z,Ge as _,dr as a,Zu as b,Qu as c,gS as d,oke as e,mi as f,Tp as g,bS as h,ei as i,DB as j,z3 as k,C2 as l,I2 as m,OB as n,S3 as o,U2 as p,mee as q,x as r,H_ as s,JB as t,Re as u,vee as v,D5 as w,wS as x,Bee as y,Yk as z};
1683
+ `),Be.document.close())}},[S]),ht=x.useCallback(()=>{W?(ce.current&&ce.current.expand(),ke.current&&ke.current.expand(),X(!1)):(ce.current&&ce.current.collapse(),ke.current&&ke.current.collapse(),X(!0))},[W]),Qe=x.useCallback(()=>{s&&(ie(""),ee(!0))},[s]),Rt=x.useCallback(()=>{if(!s)return;const Oe={id:`${Date.now()}-${Math.random()}`,name:J.trim()||`${s.name} - ${new Date().toLocaleString()}`,toolName:s.name,args:g,savedAt:Date.now(),serverId:s._serverId,serverName:s._serverName};Ue([...U,Oe]),yr.getInstance().capture(new cfe({toolName:s.name,serverId:r})).catch(()=>{}),ee(!1),ie("")},[s,J,g,U,Ue,r]),rt=x.useCallback(Oe=>{Ue(U.filter($e=>$e.id!==Oe)),u?.id===Oe&&d(null)},[U,Ue,u]);return z?f.jsxs("div",{className:"h-full flex flex-col overflow-hidden relative bg-background",children:[$!=="list"&&f.jsxs("div",{className:"flex items-center gap-2 p-2 border-b shrink-0 bg-background z-10",children:[f.jsx(je,{variant:"ghost",size:"sm",onClick:()=>{$==="response"?F("detail"):(c(null),F("list"))},className:"p-0 h-8 w-8",children:f.jsx(rN,{className:"h-4 w-4"})}),f.jsxs("div",{className:"flex items-center text-sm font-medium",children:[f.jsx("button",{onClick:()=>{c(null),F("list")},className:"text-muted-foreground hover:text-foreground hover:underline cursor-pointer",children:"Tools"}),$==="detail"&&f.jsxs(f.Fragment,{children:[f.jsx("span",{className:"mx-2 text-muted-foreground",children:"/"}),f.jsx("button",{onClick:()=>{F("response")},className:$==="detail"?"text-foreground hover:underline":$==="response"?"text-muted-foreground hover:text-foreground hover:underline cursor-pointer":"text-muted-foreground",children:"Execute"})]}),$==="response"&&f.jsxs(f.Fragment,{children:[f.jsx("span",{className:"mx-2 text-muted-foreground",children:"/"}),f.jsx("span",{className:"text-foreground",children:"Response"})]})]})]}),f.jsx("div",{className:"flex-1 relative overflow-hidden",children:f.jsxs(py,{initial:!1,mode:"popLayout",children:[$==="list"&&f.jsxs(ha.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:[f.jsx(t2,{activeTab:O,isSearchExpanded:G,searchQuery:I,filteredToolsCount:fe.length,savedRequestsCount:U.length,onSearchExpand:()=>re(!0),onSearchChange:A,onSearchBlur:xe,onTabSwitch:()=>M(O==="tools"?"saved":"tools"),searchInputRef:V}),O==="tools"?f.jsx(e2,{tools:fe,selectedTool:s,onToolSelect:Ie,focusedIndex:ne}):f.jsx(Y4,{savedRequests:U,selectedRequest:u,onLoadRequest:Fe,onDeleteRequest:rt,focusedIndex:ne})]},"list"),$==="detail"&&f.jsx(ha.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:f.jsx(X4,{selectedTool:s,toolArgs:g,isExecuting:y,isConnected:i,onArgChange:it,onExecute:nt,onSave:Qe})},"detail"),$==="response"&&f.jsx(ha.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:f.jsx(Q4,{results:Le,copiedResult:E,previewMode:B,serverId:r,readResource:a,onCopy:mt,onDelete:Ct,onFullscreen:ze,onTogglePreview:()=>Z(!B)})},"response")]})}),f.jsx(q4,{isOpen:K,requestName:J,defaultPlaceholder:`${s?.name} - ${new Date().toLocaleString()}`,onRequestNameChange:ie,onSave:Rt,onCancel:()=>ee(!1)})]}):f.jsxs(Jr,{direction:"horizontal",className:"h-full",children:[f.jsx(Rn,{ref:ce,defaultSize:33,collapsible:!0,className:"flex flex-col h-full relative",children:f.jsxs(Jr,{direction:"vertical",className:"h-full border-r dark:border-zinc-700",children:[f.jsx(Rn,{defaultSize:75,minSize:30,children:f.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[f.jsx(t2,{activeTab:O,isSearchExpanded:G,searchQuery:I,filteredToolsCount:fe.length,savedRequestsCount:U.length,onSearchExpand:()=>re(!0),onSearchChange:A,onSearchBlur:xe,onTabSwitch:()=>M(O==="tools"?"saved":"tools"),searchInputRef:V}),O==="tools"?f.jsx(e2,{tools:fe,selectedTool:s,onToolSelect:Ie,focusedIndex:ne}):f.jsx(Y4,{savedRequests:U,selectedRequest:u,onLoadRequest:Fe,onDeleteRequest:rt,focusedIndex:ne})]})}),f.jsx(bi,{withHandle:!0}),f.jsxs(Rn,{ref:Se,defaultSize:0,collapsible:!0,minSize:5,collapsedSize:5,onCollapse:()=>{q(!0)},onExpand:()=>{q(!1)},className:"flex flex-col border-t dark:border-zinc-700",children:[f.jsxs("div",{className:"group flex items-center justify-between p-3 shrink-0 cursor-pointer hover:bg-muted/50 transition-colors",onClick:Oe=>{Oe.preventDefault(),Oe.stopPropagation(),Q?(Se.current?.resize(25),q(!1)):(Se.current?.resize(5),q(!0))},children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("h3",{className:"text-sm font-medium",children:"RPC Messages"}),ae>0&&f.jsx(xr,{variant:"secondary",className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",children:ae}),ae>0&&!Q&&f.jsx(je,{variant:"ghost",size:"sm",onClick:Oe=>{Oe.preventDefault(),Oe.stopPropagation(),_e.current?.()},className:"h-6 w-6 p-0",title:"Clear all messages",children:f.jsx(Os,{className:"h-3.5 w-3.5"})})]}),f.jsx(Kl,{className:`h-4 w-4 text-muted-foreground transition-transform ${Q?"":"rotate-180"}`})]}),!Q&&f.jsx("div",{className:"flex-1 overflow-hidden min-h-0",children:f.jsx(IO,{serverIds:[r],onCountChange:le,onClearRef:_e})})]})]})}),f.jsx(bi,{withHandle:!0}),f.jsx(Rn,{defaultSize:67,children:f.jsxs(Jr,{direction:"vertical",children:[f.jsx(Rn,{ref:ke,defaultSize:40,collapsible:!0,children:f.jsx(X4,{selectedTool:s,toolArgs:g,isExecuting:y,isConnected:i,onArgChange:it,onExecute:nt,onSave:Qe,onCancel:()=>{R&&R.abort()}})}),f.jsx(bi,{withHandle:!0}),f.jsx(Rn,{ref:He,defaultSize:60,children:f.jsx("div",{className:"flex flex-col h-full",children:f.jsx(Q4,{results:Le,copiedResult:E,previewMode:B,serverId:r,readResource:a,onCopy:mt,onDelete:Ct,onFullscreen:ze,onTogglePreview:()=>Z(!B),onMaximize:ht,isMaximized:W})})})]})}),f.jsx(q4,{isOpen:K,requestName:J,defaultPlaceholder:`${s?.name} - ${new Date().toLocaleString()}`,onRequestNameChange:ie,onSave:Rt,onCancel:()=>ee(!1)})]})}tZ.displayName="ToolsTab";function P_e({isSearchExpanded:e,searchQuery:t,filteredRequestsCount:n,requestsCount:a,onSearchExpand:r,onSearchChange:i,onSearchBlur:s,onRejectAll:c,searchInputRef:u}){return f.jsxs("div",{className:"flex flex-row items-center justify-between p-4 sm:p-4 py-3 gap-2",children:[f.jsx("div",{className:"flex items-center gap-2 flex-1",children:e?f.jsx(kn,{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"}):f.jsxs(f.Fragment,{children:[f.jsx("h2",{className:"text-lg font-medium text-gray-900 dark:text-gray-100",children:"Sampling"}),f.jsx(xr,{className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",variant:"outline",children:n}),f.jsxs($t,{children:[f.jsx(Mt,{asChild:!0,children:f.jsx(je,{variant:"ghost",size:"sm",onClick:r,className:"h-8 w-8 p-0",children:f.jsx(sd,{className:"h-4 w-4"})})}),f.jsxs(Pt,{side:"bottom",className:"flex gap-2",children:["Search",f.jsx(gm,{children:"F"})]})]})]})}),f.jsx("div",{className:"flex items-center gap-2",children:f.jsxs($t,{children:[f.jsx(Mt,{asChild:!0,children:f.jsx(je,{variant:"ghost",size:"sm",onClick:c,disabled:a===0,className:"h-8 w-8 p-0",children:f.jsx(Os,{className:"h-4 w-4"})})}),f.jsx(Pt,{side:"bottom",children:"Reject all"})]})})]})}function U_e({requests:e,selectedRequest:t,onRequestSelect:n,focusedIndex:a,formatRelativeTime:r,listRef:i}){return e.length===0?f.jsx("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:f.jsx(od,{vertical:!0,noBorder:!0,message:"No sampling requests"})}):f.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 f.jsx(Vs,{id:`sampling-request-${s.id}`,isSelected:t?.id===s.id,isFocused:a===c,title:f.jsxs("span",{className:"flex items-center gap-3",children:[s.serverName,f.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 z_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 dr(async()=>{const{HumanMessage:S,AIMessage:w}=await import("./index-B17id_Fn.js").then(y=>y.bD);return{HumanMessage:S,AIMessage:w}},[]);for(const S of c){if(!S||!S.role){console.warn("Skipping invalid message:",S);continue}const w=Array.isArray(S.content)?S.content[0]:S.content;if(!w){console.warn("Skipping message with no content:",S);continue}w.type==="text"&&w.text?S.role==="user"?u.push(new d(w.text)):S.role==="assistant"&&u.push(new m(w.text)):console.warn("Skipping message with unsupported content type:",w)}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 S;const w={model:e.model,apiKey:e.apiKey};if(i!==void 0&&(w.maxTokens=i),s!==void 0?w.temperature=s:e.temperature!==void 0&&(w.temperature=e.temperature),e.provider==="openai"){const{ChatOpenAI:y}=await dr(async()=>{const{ChatOpenAI:_}=await import("./index-zbgLDNGN.js");return{ChatOpenAI:_}},__vite__mapDeps([5,6,7,3,8,9]));S=new y(w)}else if(e.provider==="anthropic"){const{ChatAnthropic:y}=await dr(async()=>{const{ChatAnthropic:_}=await import("./index-BepdOzrL.js");return{ChatAnthropic:_}},__vite__mapDeps([10,7,6,3]));S=new y(w)}else if(e.provider==="google"){const{ChatGoogleGenerativeAI:y}=await dr(async()=>{const{ChatGoogleGenerativeAI:_}=await import("./index-CUJpXvgh.js");return{ChatGoogleGenerativeAI:_}},__vite__mapDeps([11,7,6,3,9]));S=new y(w)}else throw new Error(`Unsupported LLM provider: ${e.provider}`);t.current={instance:S,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 F_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,S]=x.useState("stub-model"),[w,y]=x.useState("endTurn"),[_,E]=x.useState("assistant"),[k,R]=x.useState("text"),[C,I]=x.useState("positive"),[A,O]=x.useState(""),[M,U]=x.useState("image/png"),[H,K]=x.useState(!1),[ee,J]=x.useState(null),{generateResponse:ie,isAvailable:B}=z_e({llmConfig:m});x.useEffect(()=>{e&&(S("stub-model"),y("endTurn"),E("assistant"),R("text"),I("positive"),O(""),U("image/png"),J(null))},[e?.id]);const Z=async()=>{if(!(!e||!B)){K(!0),J(null);try{const j=await ie({request:e.request});S(j.model||m?.model||"stub-model"),y(j.stopReason||"endTurn"),E(j.role||"assistant");const V=Array.isArray(j.content)?j.content[0]:j.content;V.type==="text"?(R("text"),I(V.text||"")):V.type==="image"&&(R("image"),O(V.data||""),U(V.mimeType||"image/png"))}catch(j){const V=j instanceof Error?j.message:"Failed to generate response";J(V),Jt.error("LLM Generation Failed",{description:V})}finally{K(!1)}}},G=x.useMemo(()=>{const j={model:v,stopReason:w,role:_,content:{type:k}};return k==="text"?j.content.text=C:k==="image"&&(j.content.data=A,j.content.mimeType=M),j},[v,w,_,k,C,A,M]),re=()=>{if(!e)return;const j=gT.safeParse(G);if(!j.success){Jt.error("Invalid response",{description:`Validation failed: ${j.error.message}`});return}t(e.id,j.data),a(),dr(()=>Promise.resolve().then(()=>Zu),void 0).then(V=>{const z=Jt(V.createElement("div",{className:"space-y-3"},V.createElement("div",null,V.createElement("strong",null,"Sampling Response Sent"),V.createElement("p",{className:"text-sm text-muted-foreground mt-1"},"The tool will continue executing.")),V.createElement("div",{className:"flex gap-2"},V.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),Jt.dismiss(z)}},"View Tool Result"))),{duration:5e3})})},ne=()=>{e&&(n(e.id,"User rejected sampling request"),a())};return e?f.jsxs("div",{className:"flex flex-col h-full",children:[f.jsxs("div",{className:"flex items-center justify-between p-4 border-b dark:border-zinc-700",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("h3",{className:"font-medium text-gray-900 dark:text-gray-100",children:e.serverName}),f.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:new Date(e.timestamp).toLocaleString()})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsxs($t,{children:[f.jsx(Mt,{asChild:!0,children:f.jsx(je,{variant:"ghost",size:"sm",onClick:c,className:"h-8 w-8 p-0",children:s?f.jsx(ga,{className:"h-4 w-4 text-green-600"}):f.jsx(Br,{className:"h-4 w-4"})})}),f.jsx(Pt,{children:"Copy request"})]}),f.jsxs($t,{children:[f.jsx(Mt,{asChild:!0,children:f.jsx(je,{variant:"ghost",size:"sm",onClick:u,className:"h-8 w-8 p-0",children:f.jsx(Qp,{className:"h-4 w-4"})})}),f.jsx(Pt,{children:"Download request"})]}),f.jsxs($t,{children:[f.jsx(Mt,{asChild:!0,children:f.jsx(je,{variant:"ghost",size:"sm",onClick:d,className:"h-8 w-8 p-0",children:f.jsx(iN,{className:"h-4 w-4"})})}),f.jsx(Pt,{children:"Fullscreen"})]}),f.jsx(je,{variant:"ghost",size:"sm",onClick:a,className:"h-8 w-8 p-0",children:f.jsx(Wi,{className:"h-4 w-4"})})]})]}),f.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-6",children:[f.jsxs("div",{className:"space-y-2",children:[f.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:"Request"}),f.jsx("div",{className:"bg-muted rounded-lg p-3 max-h-64 overflow-auto",children:f.jsx(Jn,{data:e.request})})]}),f.jsxs("div",{className:"space-y-4",children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:"Response"}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(Kt,{htmlFor:`responseMode-${e.id}`,className:"text-xs text-gray-500 dark:text-gray-400",children:"Mode:"}),f.jsxs(ko,{value:h,onValueChange:j=>g(j),children:[f.jsx(No,{id:`responseMode-${e.id}`,className:"w-32 h-8 text-xs",children:f.jsx(To,{})}),f.jsxs(Co,{children:[f.jsx(Ir,{value:"manual",children:"Manual"}),f.jsx(Ir,{value:"llm",children:"LLM"})]})]})]})]}),h==="llm"&&f.jsxs("div",{className:"space-y-2 p-3 bg-muted rounded-lg",children:[B?f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(je,{onClick:Z,disabled:H,size:"sm",className:"flex items-center gap-2",children:H?f.jsxs(f.Fragment,{children:[f.jsx(Is,{className:"h-4 w-4 animate-spin"}),"Generating..."]}):f.jsxs(f.Fragment,{children:[f.jsx(Hpe,{className:"h-4 w-4"}),"Generate with LLM"]})}),f.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:["Using ",m?.provider," (",m?.model,")"]})]}):f.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:"LLM not configured. Please configure LLM in the Chat tab."}),ee&&f.jsx("div",{className:"text-xs text-red-600 dark:text-red-400",children:ee})]}),f.jsxs("div",{className:"space-y-2",children:[f.jsx(Kt,{htmlFor:`model-${e.id}`,children:"Model"}),f.jsx(kn,{id:`model-${e.id}`,value:v,onChange:j=>S(j.target.value),placeholder:"stub-model",disabled:h==="llm"&&H})]}),f.jsxs("div",{className:"space-y-2",children:[f.jsx(Kt,{htmlFor:`stopReason-${e.id}`,children:"Stop Reason"}),f.jsx(kn,{id:`stopReason-${e.id}`,value:w,onChange:j=>y(j.target.value),placeholder:"endTurn",disabled:h==="llm"&&H})]}),f.jsxs("div",{className:"space-y-2",children:[f.jsx(Kt,{htmlFor:`role-${e.id}`,children:"Role"}),f.jsxs(ko,{value:_,onValueChange:j=>E(j),disabled:h==="llm"&&H,children:[f.jsx(No,{id:`role-${e.id}`,children:f.jsx(To,{})}),f.jsxs(Co,{children:[f.jsx(Ir,{value:"assistant",children:"assistant"}),f.jsx(Ir,{value:"user",children:"user"})]})]})]}),f.jsxs("div",{className:"space-y-2",children:[f.jsx(Kt,{htmlFor:`contentType-${e.id}`,children:"Content Type"}),f.jsxs(ko,{value:k,onValueChange:j=>R(j),disabled:h==="llm"&&H,children:[f.jsx(No,{id:`contentType-${e.id}`,children:f.jsx(To,{})}),f.jsxs(Co,{children:[f.jsx(Ir,{value:"text",children:"text"}),f.jsx(Ir,{value:"image",children:"image"})]})]})]}),k==="text"&&f.jsxs("div",{className:"space-y-2",children:[f.jsx(Kt,{htmlFor:`text-${e.id}`,children:"Text Content"}),f.jsx(zl,{id:`text-${e.id}`,value:C,onChange:j=>I(j.target.value),placeholder:"Enter response text...",rows:6,disabled:h==="llm"&&H})]}),k==="image"&&f.jsxs(f.Fragment,{children:[f.jsxs("div",{className:"space-y-2",children:[f.jsx(Kt,{htmlFor:`imageData-${e.id}`,children:"Base64 Image Data"}),f.jsx(zl,{id:`imageData-${e.id}`,value:A,onChange:j=>O(j.target.value),placeholder:"Base64 encoded image data...",rows:4,disabled:h==="llm"&&H})]}),f.jsxs("div",{className:"space-y-2",children:[f.jsx(Kt,{htmlFor:`mimeType-${e.id}`,children:"MIME Type"}),f.jsx(kn,{id:`mimeType-${e.id}`,value:M,onChange:j=>U(j.target.value),placeholder:"image/png",disabled:h==="llm"&&H})]})]})]})]}),f.jsxs("div",{className:"flex gap-2 p-4 border-t dark:border-zinc-700",children:[f.jsx(je,{onClick:re,className:"flex-1",disabled:h==="llm"&&H,children:"Approve"}),f.jsx(je,{onClick:ne,variant:"outline",className:"flex-1",disabled:h==="llm"&&H,children:"Reject"})]})]}):f.jsx("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:f.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"Select a sampling request to view details"})})}function B_e({pendingRequests:e,onApprove:t,onReject:n,serverId:a,isConnected:r,mcpServerUrl:i}){const{selectedSamplingRequestId:s,setSelectedSamplingRequestId:c}=Zl(),{llmConfig:u}=CK({mcpServerUrl:i}),[d,m]=x.useState(null),[h,g]=x.useState(""),[v,S]=x.useState(-1),[w,y]=x.useState(!0),[_,E]=x.useState(!1),[k,R]=x.useState(!0),[C,I]=x.useState(!1),A=x.useRef(null),O=x.useRef(null),M=x.useRef(null),U=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 G=e.find(re=>re.id===s);console.log("[SamplingTab] Found request for auto-selection:",!!G,G?.id),G&&(console.log("[SamplingTab] Auto-selecting request:",G.id),c(null),m(G),setTimeout(()=>{const re=document.getElementById(`sampling-request-${G.id}`);console.log("[SamplingTab] Scrolling to element:",!!re),re&&re.scrollIntoView({behavior:"smooth",block:"nearest"})},100))}},[s,e,c]),x.useEffect(()=>{const G=re=>{const j=re.detail.requestId;console.log("[SamplingTab] Custom navigate event received:",j);const V=e.find(z=>z.id===j);V&&(console.log("[SamplingTab] Selecting request from event:",j),m(V),setTimeout(()=>{const z=document.getElementById(`sampling-request-${j}`);z&&z.scrollIntoView({behavior:"smooth",block:"nearest"})},200))};return window.addEventListener("navigate-to-sampling",G),()=>window.removeEventListener("navigate-to-sampling",G)},[e]),x.useEffect(()=>{w&&e.length>0&&A.current&&!U.current&&(A.current.scrollTop=0)},[e.length,w]),x.useEffect(()=>{const G=A.current;if(!G)return;const re=()=>{G.scrollTop>0&&(U.current=!0,y(!1))};return G.addEventListener("scroll",re),()=>G.removeEventListener("scroll",re)},[]),x.useEffect(()=>{e.length===0&&(U.current=!1,y(!0))},[e.length]),x.useEffect(()=>{_&&M.current&&M.current.focus()},[_]);const H=x.useCallback(()=>{h.trim()||E(!1)},[h]),K=x.useMemo(()=>{if(!h.trim())return e;const G=h.toLowerCase();return e.filter(re=>re.serverName.toLowerCase().includes(G)||JSON.stringify(re.request||{}).toLowerCase().includes(G))},[e,h]);x.useEffect(()=>{S(-1)},[h]),x.useEffect(()=>{const G=re=>{const ne=re.target;if(ne.tagName==="INPUT"||ne.tagName==="TEXTAREA"||ne.contentEditable==="true"||re.metaKey||re.ctrlKey||re.altKey)return;const V=K;if(re.key==="ArrowDown")re.preventDefault(),S(z=>{const L=z+1;return L>=V.length?0:L});else if(re.key==="ArrowUp")re.preventDefault(),S(z=>{const L=z-1;return L<0?V.length-1:L});else if(re.key==="Enter"&&v>=0){re.preventDefault();const z=K[v];z&&ee(z)}};return document.addEventListener("keydown",G),()=>document.removeEventListener("keydown",G)},[v,K]),x.useEffect(()=>{if(v>=0){const G=`sampling-request-${K[v]?.id}`,re=document.getElementById(G);re&&re.scrollIntoView({behavior:"smooth",block:"nearest"})}},[v,K]);const ee=x.useCallback(G=>{m(G)},[]),J=x.useCallback(()=>{window.confirm("Are you sure you want to reject all sampling requests? This cannot be undone.")&&(e.forEach(G=>{n(G.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)),I(!0),setTimeout(()=>I(!1),2e3)}catch(G){console.error("[SamplingTab] Failed to copy request:",G)}},[d]),B=x.useCallback(()=>{if(d)try{const G=new globalThis.Blob([JSON.stringify({id:d.id,serverName:d.serverName,timestamp:d.timestamp,request:d.request},null,2)],{type:"application/json"}),re=URL.createObjectURL(G),ne=document.createElement("a");ne.href=re,ne.download=`sampling-request-${Date.now()}.json`,document.body.appendChild(ne),ne.click(),document.body.removeChild(ne),URL.revokeObjectURL(re)}catch(G){console.error("[SamplingTab] Failed to download request:",G)}},[d]),Z=x.useCallback(async()=>{if(O.current)try{document.fullscreenElement?await document.exitFullscreen():await O.current.requestFullscreen()}catch(G){console.error("[SamplingTab] Failed to toggle fullscreen:",G)}},[]);return r?f.jsxs(Jr,{direction:"horizontal",className:"h-full",children:[f.jsx(Rn,{defaultSize:40,minSize:30,children:f.jsx(Jr,{direction:"vertical",className:"h-full border-r dark:border-zinc-700",children:f.jsxs(Rn,{defaultSize:75,minSize:30,children:[f.jsx(P_e,{isSearchExpanded:_,searchQuery:h,filteredRequestsCount:K.length,requestsCount:e.length,onSearchExpand:()=>E(!0),onSearchChange:g,onSearchBlur:H,onRejectAll:J,searchInputRef:M}),f.jsx("div",{className:"flex flex-col h-full",children:f.jsx(U_e,{requests:K,selectedRequest:d,onRequestSelect:ee,focusedIndex:v,formatRelativeTime:hv,listRef:A})})]})})}),f.jsx(bi,{}),f.jsx(Rn,{defaultSize:60,minSize:40,children:f.jsx("div",{ref:O,className:"h-full bg-white dark:bg-zinc-900",children:f.jsx(F_e,{request:d,onApprove:t,onReject:n,onClose:()=>m(null),previewMode:k,onTogglePreview:()=>R(!k),isCopied:C,onCopy:ie,onDownload:B,onFullscreen:Z,llmConfig:u})})})]}):f.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[f.jsx(V9,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),f.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"Not connected to server"})]})}function H_e({isSearchExpanded:e,searchQuery:t,filteredRequestsCount:n,requestsCount:a,onSearchExpand:r,onSearchChange:i,onSearchBlur:s,onCancelAll:c,searchInputRef:u}){return f.jsxs("div",{className:"flex flex-row items-center justify-between p-4 sm:p-4 py-3 gap-2",children:[f.jsx("div",{className:"flex items-center gap-2 flex-1",children:e?f.jsx(kn,{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"}):f.jsxs(f.Fragment,{children:[f.jsx("h2",{className:"text-lg font-medium text-gray-900 dark:text-gray-100",children:"Elicitation"}),f.jsx(xr,{className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",variant:"outline",children:n}),f.jsxs($t,{children:[f.jsx(Mt,{asChild:!0,children:f.jsx(je,{variant:"ghost",size:"sm",onClick:r,className:"h-8 w-8 p-0",children:f.jsx(sd,{className:"h-4 w-4"})})}),f.jsxs(Pt,{side:"bottom",className:"flex gap-2",children:["Search",f.jsx(gm,{children:"F"})]})]})]})}),f.jsx("div",{className:"flex items-center gap-2",children:f.jsxs($t,{children:[f.jsx(Mt,{asChild:!0,children:f.jsx(je,{variant:"ghost",size:"sm",onClick:c,disabled:a===0,className:"h-8 w-8 p-0",children:f.jsx(Wi,{className:"h-4 w-4"})})}),f.jsx(Pt,{side:"bottom",children:"Cancel all"})]})})]})}function V_e({requests:e,selectedRequest:t,onRequestSelect:n,focusedIndex:a,formatRelativeTime:r,listRef:i}){return e.length===0?f.jsx("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:f.jsx(od,{vertical:!0,noBorder:!0,message:"No elicitation requests"})}):f.jsx("div",{ref:i,className:"overflow-y-auto flex-1 overscroll-contain",children:e.map((s,c)=>{const u=s.request.mode||"form",d=u==="form"&&"requestedSchema"in s.request&&s.request.requestedSchema;return f.jsx(Vs,{id:`elicitation-request-${s.id}`,isSelected:t?.id===s.id,isFocused:a===c,title:f.jsxs("span",{className:"flex items-center gap-3",children:[s.serverName,f.jsx(xr,{variant:"outline",className:u==="url"?"bg-blue-500/20 text-blue-600 dark:text-blue-400 border-blue-500/50":"bg-green-500/20 text-green-600 dark:text-green-400 border-green-500/50",children:u})]}),description:(()=>{const m=r(s.timestamp),h=[];d&&h.push("with schema"),u==="url"&&h.push("external action");const g=h.length>0?` | ${h.join(", ")}`:"";return m+g})(),onClick:()=>n(s)},s.id)})})}function G_e({request:e,onApprove:t,onReject:n,onClose:a,previewMode:r,onTogglePreview:i,isCopied:s,onCopy:c,onDownload:u,onFullscreen:d}){const[m,h]=x.useState({}),[g,v]=x.useState(!1),S=e?.request.mode||"form",w=S==="form",y=S==="url";x.useEffect(()=>{if(e&&w&&"requestedSchema"in e.request){const A=e.request.requestedSchema,O={};if(A?.type==="object"&&A.properties)for(const[M,U]of Object.entries(A.properties)){const H=U;H.default!==void 0?O[M]=H.default:H.type==="boolean"?O[M]=!1:H.type==="number"||H.type==="integer"?O[M]=0:O[M]=""}h(O)}v(!1)},[e?.id,w]);const _=(A,O)=>{h(M=>({...M,[A]:O}))},E=()=>{if(e){if(w){if("requestedSchema"in e.request){const A=e.request.requestedSchema;if(A?.required){const O=A.required.filter(M=>m[M]===void 0||m[M]===""||m[M]===null);if(O.length>0){Jt.error("Missing required fields",{description:`Please fill in: ${O.join(", ")}`});return}}}t(e.id,{action:"accept",data:m})}else y&&t(e.id,{action:"accept"});a(),dr(()=>Promise.resolve().then(()=>Zu),void 0).then(A=>{const O=Jt(A.createElement("div",{className:"space-y-3"},A.createElement("div",null,A.createElement("strong",null,"Elicitation Response Sent"),A.createElement("p",{className:"text-sm text-muted-foreground mt-1"},"The tool will continue executing.")),A.createElement("div",{className:"flex gap-2"},A.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 M=new globalThis.CustomEvent("navigate-to-tool-result",{detail:{toolName:null}});window.dispatchEvent(M),Jt.dismiss(O)}},"View Tool Result"))),{duration:5e3})})}},k=()=>{e&&(t(e.id,{action:"decline"}),a())},R=()=>{e&&(n(e.id,"User cancelled elicitation request"),a())},C=()=>{e&&y&&"url"in e.request&&(window.open(e.request.url,"_blank"),v(!0))},I=x.useMemo(()=>{if(!e||!w||!("requestedSchema"in e.request))return null;const A=e.request.requestedSchema;if(!A||A.type!=="object"||!A.properties)return f.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:"No form schema available"});const O=A.properties,M=A.required||[];return f.jsx("div",{className:"space-y-4",children:Object.entries(O).map(([U,H])=>{const K=H,ee=M.includes(U),J=K.type||"string",ie=K.title||U,B=K.description;return f.jsxs("div",{className:"space-y-2",children:[f.jsxs(Kt,{htmlFor:`field-${U}`,children:[ie,ee&&f.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),B&&f.jsx("p",{className:"text-xs text-muted-foreground",children:B}),J==="boolean"?f.jsxs("div",{className:"flex items-center space-x-2",children:[f.jsx(Sp,{id:`field-${U}`,checked:m[U]||!1,onCheckedChange:Z=>_(U,Z)}),f.jsx(Kt,{htmlFor:`field-${U}`,className:"text-sm font-normal cursor-pointer",children:K.title||U})]}):J==="number"||J==="integer"?f.jsx(kn,{id:`field-${U}`,type:"number",value:m[U]||"",onChange:Z=>_(U,J==="integer"?parseInt(Z.target.value,10):parseFloat(Z.target.value)),placeholder:K.default?.toString()||""}):K.enum?f.jsxs("select",{id:`field-${U}`,value:m[U]||"",onChange:Z=>_(U,Z.target.value),className:"flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",children:[f.jsx("option",{value:"",children:"Select..."}),K.enum.map(Z=>f.jsx("option",{value:Z,children:Z},Z))]}):J==="string"&&(K.format==="textarea"||K.maxLength>100)?f.jsx(zl,{id:`field-${U}`,value:m[U]||"",onChange:Z=>_(U,Z.target.value),placeholder:K.default||"",rows:4}):f.jsx(kn,{id:`field-${U}`,type:"text",value:m[U]||"",onChange:Z=>_(U,Z.target.value),placeholder:K.default||""})]},U)})})},[e,m,w]);return e?f.jsxs("div",{className:"flex flex-col h-full",children:[f.jsxs("div",{className:"flex items-center justify-between p-4 border-b dark:border-zinc-700",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("h3",{className:"font-medium text-gray-900 dark:text-gray-100",children:e.serverName}),f.jsx(xr,{variant:"outline",className:y?"bg-blue-500/20 text-blue-600 dark:text-blue-400 border-blue-500/50":"bg-green-500/20 text-green-600 dark:text-green-400 border-green-500/50",children:S}),f.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:new Date(e.timestamp).toLocaleString()})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsxs($t,{children:[f.jsx(Mt,{asChild:!0,children:f.jsx(je,{variant:"ghost",size:"sm",onClick:c,className:"h-8 w-8 p-0",children:s?f.jsx(ga,{className:"h-4 w-4 text-green-600"}):f.jsx(Br,{className:"h-4 w-4"})})}),f.jsx(Pt,{children:"Copy request"})]}),f.jsxs($t,{children:[f.jsx(Mt,{asChild:!0,children:f.jsx(je,{variant:"ghost",size:"sm",onClick:u,className:"h-8 w-8 p-0",children:f.jsx(Qp,{className:"h-4 w-4"})})}),f.jsx(Pt,{children:"Download request"})]}),f.jsxs($t,{children:[f.jsx(Mt,{asChild:!0,children:f.jsx(je,{variant:"ghost",size:"sm",onClick:d,className:"h-8 w-8 p-0",children:f.jsx(iN,{className:"h-4 w-4"})})}),f.jsx(Pt,{children:"Fullscreen"})]}),f.jsx(je,{variant:"ghost",size:"sm",onClick:a,className:"h-8 w-8 p-0",children:f.jsx(Wi,{className:"h-4 w-4"})})]})]}),f.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-6",children:[f.jsxs("div",{className:"space-y-2",children:[f.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:"Message"}),f.jsx("p",{className:"text-sm text-gray-700 dark:text-gray-300",children:e.request.message})]}),y&&"url"in e.request&&f.jsxs("div",{className:"space-y-2",children:[f.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:"External Action Required"}),f.jsxs("div",{className:"bg-muted rounded-lg p-4 space-y-3",children:[f.jsx("p",{className:"text-sm text-muted-foreground",children:"This request requires you to complete an action at an external URL:"}),f.jsxs("div",{className:"flex items-center gap-2 p-2 bg-background rounded border",children:[f.jsx("code",{className:"flex-1 text-xs font-mono break-all",children:e.request.url}),f.jsxs(je,{size:"sm",variant:"outline",onClick:C,className:"flex items-center gap-2",children:[f.jsx(lE,{className:"h-4 w-4"}),"Open URL"]})]}),f.jsxs("div",{className:"flex items-center space-x-2 pt-2",children:[f.jsx(Sp,{id:"url-completed",checked:g,onCheckedChange:A=>v(!!A)}),f.jsx(Kt,{htmlFor:"url-completed",className:"text-sm font-normal cursor-pointer",children:"I have completed the required action"})]})]})]}),w&&f.jsxs("div",{className:"space-y-2",children:[f.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:"Form Data"}),I]}),w&&"requestedSchema"in e.request&&e.request.requestedSchema&&f.jsxs("details",{className:"space-y-2",children:[f.jsx("summary",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100 cursor-pointer",children:"Schema (for reference)"}),f.jsx("div",{className:"bg-muted rounded-lg p-3 max-h-64 overflow-auto",children:f.jsx(Jn,{data:e.request.requestedSchema})})]})]}),f.jsxs("div",{className:"flex gap-2 p-4 border-t dark:border-zinc-700",children:[f.jsx(je,{onClick:E,className:"flex-1",children:"Accept"}),f.jsx(je,{onClick:k,variant:"outline",className:"flex-1",children:"Decline"}),f.jsx(je,{onClick:R,variant:"outline",className:"flex-1",children:"Cancel"})]})]}):f.jsx("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:f.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"Select an elicitation request to view details"})})}function W_e({pendingRequests:e=[],onApprove:t,onReject:n,serverId:a,isConnected:r}){const{selectedElicitationRequestId:i,setSelectedElicitationRequestId:s}=Zl(),[c,u]=x.useState(null),[d,m]=x.useState(""),[h,g]=x.useState(-1),[v,S]=x.useState(!0),[w,y]=x.useState(!1),[_,E]=x.useState(!0),[k,R]=x.useState(!1),C=x.useRef(null),I=x.useRef(null),A=x.useRef(null),O=x.useRef(!1);x.useEffect(()=>{if(console.log("[ElicitationTab] Auto-selection check:",{selectedElicitationRequestId:i,pendingRequestsCount:e.length,currentSelectedId:c?.id}),i&&e.length>0){const B=e.find(Z=>Z.id===i);console.log("[ElicitationTab] Found request for auto-selection:",!!B,B?.id),B&&(console.log("[ElicitationTab] Auto-selecting request:",B.id),s(null),u(B),setTimeout(()=>{const Z=document.getElementById(`elicitation-request-${B.id}`);console.log("[ElicitationTab] Scrolling to element:",!!Z),Z&&Z.scrollIntoView({behavior:"smooth",block:"nearest"})},100))}},[i,e,s]),x.useEffect(()=>{const B=Z=>{const re=Z.detail.requestId;console.log("[ElicitationTab] Custom navigate event received:",re);const ne=e.find(j=>j.id===re);ne&&(console.log("[ElicitationTab] Selecting request from event:",re),u(ne),setTimeout(()=>{const j=document.getElementById(`elicitation-request-${re}`);j&&j.scrollIntoView({behavior:"smooth",block:"nearest"})},200))};return window.addEventListener("navigate-to-elicitation",B),()=>window.removeEventListener("navigate-to-elicitation",B)},[e]),x.useEffect(()=>{v&&e.length>0&&C.current&&!O.current&&(C.current.scrollTop=0)},[e.length,v]),x.useEffect(()=>{const B=C.current;if(!B)return;const Z=()=>{B.scrollTop>0&&(O.current=!0,S(!1))};return B.addEventListener("scroll",Z),()=>B.removeEventListener("scroll",Z)},[]),x.useEffect(()=>{e.length===0&&(O.current=!1,S(!0))},[e.length]),x.useEffect(()=>{w&&A.current&&A.current.focus()},[w]);const M=x.useCallback(()=>{d.trim()||y(!1)},[d]),U=x.useMemo(()=>{if(!d.trim())return e;const B=d.toLowerCase();return e.filter(Z=>Z.serverName.toLowerCase().includes(B)||Z.request.message.toLowerCase().includes(B)||JSON.stringify(Z.request||{}).toLowerCase().includes(B))},[e,d]);x.useEffect(()=>{g(-1)},[d]),x.useEffect(()=>{const B=Z=>{const G=Z.target;if(G.tagName==="INPUT"||G.tagName==="TEXTAREA"||G.contentEditable==="true"||Z.metaKey||Z.ctrlKey||Z.altKey)return;const ne=U;if(Z.key==="ArrowDown")Z.preventDefault(),g(j=>{const V=j+1;return V>=ne.length?0:V});else if(Z.key==="ArrowUp")Z.preventDefault(),g(j=>{const V=j-1;return V<0?ne.length-1:V});else if(Z.key==="Enter"&&h>=0){Z.preventDefault();const j=U[h];j&&H(j)}};return document.addEventListener("keydown",B),()=>document.removeEventListener("keydown",B)},[h,U]),x.useEffect(()=>{if(h>=0){const B=`elicitation-request-${U[h]?.id}`,Z=document.getElementById(B);Z&&Z.scrollIntoView({behavior:"smooth",block:"nearest"})}},[h,U]);const H=x.useCallback(B=>{u(B)},[]),K=x.useCallback(()=>{window.confirm("Are you sure you want to cancel all elicitation requests? This cannot be undone.")&&(e.forEach(B=>{n(B.id,"User cancelled all requests")}),u(null))},[e,n]),ee=x.useCallback(async()=>{if(c)try{await navigator.clipboard.writeText(JSON.stringify({id:c.id,serverName:c.serverName,timestamp:c.timestamp,request:c.request},null,2)),R(!0),setTimeout(()=>R(!1),2e3)}catch(B){console.error("[ElicitationTab] Failed to copy request:",B)}},[c]),J=x.useCallback(()=>{if(c)try{const B=new globalThis.Blob([JSON.stringify({id:c.id,serverName:c.serverName,timestamp:c.timestamp,request:c.request},null,2)],{type:"application/json"}),Z=URL.createObjectURL(B),G=document.createElement("a");G.href=Z,G.download=`elicitation-request-${Date.now()}.json`,document.body.appendChild(G),G.click(),document.body.removeChild(G),URL.revokeObjectURL(Z)}catch(B){console.error("[ElicitationTab] Failed to download request:",B)}},[c]),ie=x.useCallback(async()=>{if(I.current)try{document.fullscreenElement?await document.exitFullscreen():await I.current.requestFullscreen()}catch(B){console.error("[ElicitationTab] Failed to toggle fullscreen:",B)}},[]);return r?f.jsxs(Jr,{direction:"horizontal",className:"h-full",children:[f.jsx(Rn,{defaultSize:40,minSize:30,children:f.jsx(Jr,{direction:"vertical",className:"h-full border-r dark:border-zinc-700",children:f.jsxs(Rn,{defaultSize:75,minSize:30,children:[f.jsx(H_e,{isSearchExpanded:w,searchQuery:d,filteredRequestsCount:U.length,requestsCount:e.length,onSearchExpand:()=>y(!0),onSearchChange:m,onSearchBlur:M,onCancelAll:K,searchInputRef:A}),f.jsx("div",{className:"flex flex-col h-full",children:f.jsx(V_e,{requests:U,selectedRequest:c,onRequestSelect:H,focusedIndex:h,formatRelativeTime:hv,listRef:C})})]})})}),f.jsx(bi,{}),f.jsx(Rn,{defaultSize:60,minSize:40,children:f.jsx("div",{ref:I,className:"h-full bg-white dark:bg-zinc-900",children:f.jsx(G_e,{request:c,onApprove:t,onReject:n,onClose:()=>u(null),previewMode:_,onTogglePreview:()=>E(!_),isCopied:k,onCopy:ee,onDownload:J,onFullscreen:ie})})})]}):f.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[f.jsx(Z9,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),f.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"Not connected to server"})]})}function K_e({selectedServer:e,activeTab:t,toolsSearchRef:n,promptsSearchRef:a,resourcesSearchRef:r,children:i}){return e?f.jsxs(f.Fragment,{children:[f.jsx("div",{style:{display:t==="tools"?"block":"none"},className:"h-full",children:f.jsx(tZ,{ref:n,tools:e.tools,callTool:e.callTool,readResource:e.readResource,serverId:e.id,isConnected:e.state==="ready"})}),f.jsx("div",{style:{display:t==="prompts"?"block":"none"},className:"h-full",children:f.jsx(XK,{ref:a,prompts:e.prompts,callPrompt:e.getPrompt,serverId:e.id,isConnected:e.state==="ready"})}),f.jsx("div",{style:{display:t==="resources"?"block":"none"},className:"h-full",children:f.jsx(QK,{ref:r,resources:e.resources,readResource:e.readResource,serverId:e.id,isConnected:e.state==="ready"})}),f.jsx("div",{style:{display:t==="chat"?"block":"none"},className:"h-full",children:f.jsx(XEe,{connection:e,isConnected:e.state==="ready",readResource:e.readResource},e.id)}),f.jsx("div",{style:{display:t==="sampling"?"block":"none"},className:"h-full",children:f.jsx(B_e,{pendingRequests:e.pendingSamplingRequests,onApprove:e.approveSampling,onReject:e.rejectSampling,serverId:e.id,isConnected:e.state==="ready",mcpServerUrl:e.url})}),f.jsx("div",{style:{display:t==="elicitation"?"block":"none"},className:"h-full",children:f.jsx(W_e,{pendingRequests:e.pendingElicitationRequests,onApprove:e.approveElicitation,onReject:e.rejectElicitation,serverId:e.id,isConnected:e.state==="ready"})}),f.jsx("div",{style:{display:t==="notifications"?"block":"none"},className:"h-full",children:f.jsx(R_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!=="elicitation"&&t!=="notifications"&&f.jsx(f.Fragment,{children:i})]}):f.jsx(f.Fragment,{children:i})}function r2({className:e}){return f.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:[f.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"}),f.jsx("path",{d:"M9 18c-4.51 2-5-2-7-2"})]})}const nZ=x.createContext(void 0);function rZ(){const e=x.use(nZ);if(!e)throw new Error("useTabs must be used within a TabsProvider");return e}const aZ=x.createContext(void 0);function Z_e(){return x.use(aZ)}function h_({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 f.jsx(nZ,{value:{activeValue:h,handleValueChange:m},children:f.jsx("div",{ref:e,className:De("flex flex-col gap-2",i),...s,children:t})})}h_.displayName="Tabs";function g_({ref:e,children:t,className:n,variant:a="default",...r}){const{activeValue:i}=rZ(),[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(w=>x.isValidElement(w)&&w.props.value===i),v=x.useCallback(()=>{const w=u.current;if(!w)return;const _=w.querySelectorAll("button")[g];if(_){const E=w.getBoundingClientRect(),k=_.getBoundingClientRect();c({width:k.width,left:k.left-E.left})}},[g]),S=x.useCallback(()=>{m.current&&clearTimeout(m.current),m.current=setTimeout(v,16)},[v]);return x.useEffect(()=>{const w=setTimeout(v,10);return()=>clearTimeout(w)},[v]),x.useEffect(()=>{const w=u.current;return w?(d.current=new ResizeObserver(()=>{S()}),d.current.observe(w),w.querySelectorAll("button").forEach(_=>{d.current&&d.current.observe(_)}),()=>{d.current&&d.current.disconnect(),m.current&&clearTimeout(m.current)}):void 0},[S]),x.useEffect(()=>{const w=()=>{S()};return window.addEventListener("resize",w),()=>window.removeEventListener("resize",w)},[S]),x.useEffect(()=>{const w=u.current;if(!w)return;const y=w.querySelector("[data-width]");y&&(y.style.width=`${s.width}px`,y.style.left=`${s.left}px`)},[s]),f.jsx(aZ,{value:{variant:a},children:f.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,f.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})]})})}g_.displayName="TabsList";function b_({ref:e,children:t,value:n,className:a,disabled:r,icon:i,...s}){const{activeValue:c,handleValueChange:u}=rZ(),m=Z_e()?.variant||"default",h=c===n;return f.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&&f.jsx(i,{className:"mr-2 h-4 w-4"}),t]})}b_.displayName="TabsTrigger";function a2({className:e}){const{theme:t,setTheme:n}=Dy(),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"?f.jsx(dU,{className:"size-4"}):t==="light"?f.jsx(Zpe,{className:"size-5"}):f.jsx(Npe,{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:S}=a.current.getBoundingClientRect(),w=h+S/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 ${w}px)`,`circle(${k}px at ${y}px ${w}px)`]},{duration:700,easing:"ease-in-out",pseudoElement:"::view-transition-new(root)"})}else n(m)};return r?f.jsx("button",{ref:a,onClick:d,className:De(e),"aria-label":u(),title:`Current: ${t==="system"?"Auto":t==="light"?"Light":"Dark"}`,children:c()}):f.jsx("button",{ref:a,className:De(e),"aria-label":"Toggle theme",children:f.jsx(dU,{className:"size-4"})})}function i2({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 f.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:[f.jsx("div",{className:"relative",children:f.jsxs(ha.svg,{viewBox:"0 0 303 303",initial:"rest",animate:a?"hover":"rest",className:De("text-foreground",t==="expanded"?"size-[40px]":"size-[20px]"),children:[f.jsxs(ha.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:[f.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"}),f.jsx("circle",{cx:"70.3",cy:"232.3",r:"50"}),f.jsx("circle",{cx:"232.3",cy:"70.3",r:"50"})]}),f.jsxs("g",{fill:"none",stroke:"currentColor",strokeWidth:u,strokeLinecap:"round",strokeLinejoin:"round",children:[f.jsx(Y_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}),f.jsx(o2,{cx:70.3,cy:232.3,r:50,times:{T0:m,T1:h,T2:g,T3:v},total:d}),f.jsx(o2,{cx:232.3,cy:70.3,r:50,times:{T0:m,T1:h,T2:g,T3:v},total:d})]})]})}),t==="expanded"&&f.jsxs("div",{className:"font-ubuntu flex flex-col items-start -space-y-1 mr-3",children:[f.jsx("h1",{className:"text-xl font-medium",children:"mcp-use"}),f.jsx("span",{className:"text-lg text-muted-foreground tracking-wide font-sans font-light",children:"Inspector"})]})]})}function Y_e({d:e,times:t,total:n}){const{T0:a,T1:r,T2:i,T3:s}=t;return f.jsx(ha.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 o2({cx:e,cy:t,r:n,times:a,total:r}){const{T0:i,T1:s,T2:c,T3:u}=a;return f.jsx(ha.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 iZ({ref:e,shimmerColor:t,shimmerSize:n="0.05em",shimmerDuration:a="3s",borderRadius:r="100px",background:i,className:s,children:c,...u}){const{resolvedTheme:d}=Dy(),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 f.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:[f.jsx("div",{className:De("-z-30 blur-[2px]","[container-type:size] absolute inset-0 overflow-visible"),children:f.jsx("div",{className:"animate-shimmer-slide absolute inset-0 [aspect-ratio:1] h-[100cqh] [border-radius:0] [mask:none]",children:f.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,f.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]")}),f.jsx("div",{className:De("absolute [inset:var(--cut)] -z-20 [border-radius:var(--radius)] [background:var(--bg)]")})]})}iZ.displayName="ShimmerButton";function s2({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 f.jsxs($t,{children:[f.jsx(Mt,{asChild:!0,children:f.jsxs("div",{className:"relative",children:[f.jsx("div",{className:`absolute w-2 h-2 rounded-full ${a} animate-ping`}),f.jsx("div",{className:`relative w-2 h-2 rounded-full ${n}`})]})}),f.jsx(Pt,{children:f.jsx("p",{children:r})})]})}function l2({connections:e,selectedServer:t,onServerSelect:n,onOpenConnectionOptions:a,mobileMode:r=!1}){const i=Ju(),s=c=>{const u=e.find(d=>d.id===c);if(!u||u.state!=="ready"){Jt.error("Server is not connected and cannot be inspected");return}n(c)};return r?f.jsx("div",{className:"flex items-center gap-2",children:f.jsx("div",{className:"relative",children:f.jsxs(rE,{children:[f.jsx(aE,{asChild:!0,children:f.jsxs(je,{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?f.jsx(Sl,{serverUrl:t.url,serverName:t.name,size:"md"}):f.jsx(Ppe,{className:"h-5 w-5"}),f.jsx(Kl,{className:"h-4 w-4"})]})}),f.jsxs(Ub,{className:"w-[calc(100vw-2rem)] sm:w-[300px]",align:"start",children:[f.jsx(iE,{className:"cursor-pointer hover:bg-zinc-100 dark:hover:bg-zinc-800",onClick:()=>i("/"),children:"MCP Servers"}),f.jsx(_f,{}),e.length===0?f.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=>f.jsxs(Eo,{onClick:()=>s(c.id),className:"flex items-center gap-3",children:[f.jsx(Sl,{serverUrl:c.url,serverName:c.name,size:"sm"}),f.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[f.jsx("div",{className:"font-medium",children:c.name}),f.jsx(s2,{status:c.state})]}),f.jsx(je,{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:f.jsx(fu,{className:"h-3 w-3"})})]},c.id)),f.jsx(_f,{}),f.jsx(Eo,{onClick:()=>i("/"),children:f.jsx("span",{className:"text-blue-600 dark:text-blue-400",children:"+ Add new server"})})]})]})})}):f.jsx("div",{className:"flex items-center gap-2",children:f.jsx("div",{className:"relative",children:f.jsxs(rE,{children:[f.jsx(aE,{asChild:!0,children:f.jsxs(iZ,{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&&f.jsx(Sl,{serverUrl:t.url,serverName:t.name,size:"md",className:"mr-2"}),f.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[f.jsx("span",{className:"truncate",children:t?t.name:"Select server to inspect"}),t&&f.jsx("div",{className:"flex items-center gap-2",children:t.error&&t.state!=="ready"?f.jsxs($t,{children:[f.jsx(Mt,{asChild:!0,children:f.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"})}),f.jsx(Pt,{children:f.jsx("p",{className:"max-w-xs",children:t.error})})]}):f.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&&f.jsxs($t,{children:[f.jsx(Mt,{asChild:!0,children:f.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:f.jsx(fu,{className:"h-4 w-4"})})}),f.jsx(Pt,{children:f.jsx("p",{children:"Edit connection settings"})})]}),f.jsxs(Ub,{className:"w-[calc(100vw-2rem)] sm:w-[300px]",align:"start",children:[f.jsx(iE,{className:"cursor-pointer hover:bg-zinc-100 dark:hover:bg-zinc-800",onClick:()=>i("/"),children:"MCP Servers"}),f.jsx(_f,{}),e.length===0?f.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=>f.jsxs(Eo,{onClick:()=>s(c.id),className:"flex items-center gap-3",children:[f.jsx(Sl,{serverUrl:c.url,serverName:c.name,size:"sm"}),f.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[f.jsx("div",{className:"font-medium",children:c.name}),f.jsx(s2,{status:c.state})]}),f.jsx(je,{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:f.jsx(fu,{className:"h-3 w-3"})})]},c.id)),f.jsx(_f,{}),f.jsx(Eo,{onClick:()=>i("/"),children:f.jsx("span",{className:"text-blue-600 dark:text-blue-400",children:"+ Add new server"})})]})]})})})}const c2=[{id:"tools",label:"Tools",icon:Ll},{id:"prompts",label:"Prompts",icon:lp},{id:"resources",label:"Resources",icon:cpe},{id:"chat",label:"Chat",icon:xpe},{id:"sampling",label:"Sampling",icon:V9},{id:"elicitation",label:"Elicitation",icon:Z9},{id:"notifications",label:"Notifications",icon:nN}];function u2(e,t){return e==="tools"?t.tools.length:e==="prompts"?t.prompts.length:e==="resources"?t.resources.length:e==="sampling"?t.pendingSamplingRequests?.length||0:e==="elicitation"?t.pendingElicitationRequests?.length||0:e==="notifications"?t.unreadNotificationCount:0}function q_e({connections:e,selectedServer:t,activeTab:n,onServerSelect:a,onTabChange:r,onCommandPaletteOpen:i,onOpenConnectionOptions:s}){const{tunnelUrl:c}=Zl(),u=t&&c,[d,m]=x.useState(!1),h=async()=>{if(c)try{await navigator.clipboard.writeText(`${c}/mcp`),m(!0),Jt.success("Tunnel URL copied to clipboard"),setTimeout(()=>m(!1),2e3)}catch{Jt.error("Failed to copy URL")}};return f.jsxs("header",{className:"w-full mx-auto",children:[f.jsxs("div",{className:"flex lg:hidden flex-col gap-3",children:[f.jsxs("div",{className:"flex items-center justify-between w-full",children:[f.jsx("div",{className:"flex-1 flex justify-start",children:f.jsx(l2,{connections:e,selectedServer:t,onServerSelect:a,onOpenConnectionOptions:s,mobileMode:!0})}),f.jsx("div",{className:"flex-shrink-0 flex justify-center",children:f.jsx("div",{className:"scale-150",children:f.jsx(i2,{state:"collapsed"})})}),f.jsxs("div",{className:"flex-1 flex justify-end items-center gap-2",children:[f.jsxs($t,{children:[f.jsx(Mt,{asChild:!0,children:f.jsx(je,{variant:"ghost",size:"sm",asChild:!0,children:f.jsx("a",{href:"https://github.com/mcp-use/mcp-use",target:"_blank",rel:"noopener noreferrer",className:"p-2","aria-label":"GitHub",children:f.jsx(r2,{className:"h-4 w-4"})})})}),f.jsx(Pt,{children:f.jsx("p",{children:"Give us a star ⭐"})})]}),f.jsx(a2,{className:"p-2 hover:bg-zinc-200 dark:hover:bg-zinc-800 rounded-full transition-colors cursor-pointer"})]})]}),t&&f.jsx("div",{className:"w-full",children:f.jsx(h_,{value:n,onValueChange:g=>r(g),children:f.jsx(g_,{className:"w-full justify-center",children:c2.map(g=>{const v=u2(g.id,t);return f.jsxs(b_,{value:g.id,icon:g.icon,className:"[&>svg]:mr-0 flex-1 flex-row gap-2 relative",children:[v>0&&f.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}),f.jsx("span",{className:"sr-only",children:g.label})]},g.id)})})})})]}),f.jsxs("div",{className:"hidden lg:flex items-center justify-between gap-3",children:[f.jsxs("div",{className:"flex items-center flex-wrap gap-2 md:space-x-6 space-x-2",children:[f.jsx(l2,{connections:e,selectedServer:t,onServerSelect:a,onOpenConnectionOptions:s}),t&&f.jsx(h_,{value:n,onValueChange:g=>r(g),children:f.jsx(g_,{className:"overflow-x-auto",children:c2.map(g=>{const v=u2(g.id,t);return f.jsx(b_,{value:g.id,icon:g.icon,className:"[&>svg]:mr-0 lg:[&>svg]:mr-2 relative",children:f.jsxs("div",{className:"items-center gap-2 hidden lg:flex",children:[g.label,v>0&&f.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&&f.jsxs(JW,{children:[f.jsx(QW,{asChild:!0,children:f.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:[f.jsx(cp,{className:"size-4 text-purple-600 dark:text-purple-400 animate-pulse"}),f.jsx("span",{className:"text-xs font-medium text-purple-700 dark:text-purple-300 hidden lg:inline",children:"Tunnel"})]})}),f.jsx(QN,{className:"w-[calc(100vw-2rem)] sm:w-96",align:"start",children:f.jsxs("div",{className:"space-y-4",children:[f.jsxs("div",{children:[f.jsxs("h4",{className:"font-semibold text-sm mb-2 flex items-center gap-2",children:[f.jsx(cp,{className:"size-4 text-purple-600 dark:text-purple-400"}),"Tunnel URL"]}),f.jsxs("div",{className:"flex items-center gap-2 p-2 py-0 bg-muted rounded-full",children:[f.jsxs("code",{className:"flex-1 text-[10px] font-mono",children:[c,"/mcp"]}),f.jsx(je,{variant:"ghost",size:"sm",className:"h-7 px-2",onClick:h,children:d?f.jsx(ga,{className:"size-3.5 text-green-600"}):f.jsx(Br,{className:"size-3.5"})})]})]}),f.jsxs("div",{children:[f.jsx("h5",{className:"font-semibold text-sm mb-2",children:"Use in ChatGPT"}),f.jsxs("ol",{className:"space-y-2 text-xs text-muted-foreground",children:[f.jsxs("li",{className:"flex gap-2",children:[f.jsx("span",{className:"font-semibold text-foreground",children:"1."}),f.jsxs("span",{children:["Enable"," ",f.jsx("span",{className:"font-medium text-foreground",children:"dev mode"})," ","from settings"]})]}),f.jsxs("li",{className:"flex gap-2",children:[f.jsx("span",{className:"font-semibold text-foreground",children:"2."}),f.jsxs("span",{children:["In"," ",f.jsx("span",{className:"font-medium text-foreground",children:"App & Connectors"})," ","click on"," ",f.jsx("span",{className:"font-medium text-foreground",children:"create"})]})]}),f.jsxs("li",{className:"flex gap-2",children:[f.jsx("span",{className:"font-semibold text-foreground",children:"3."}),f.jsx("span",{children:"Use the tunnel URL in the input"})]})]})]})]})})]})]}),f.jsxs("div",{className:"flex items-center gap-2 sm:gap-4 flex-shrink-0",children:[f.jsxs($t,{children:[f.jsx(Mt,{children:f.jsx(a2,{className:"p-2 hover:bg-zinc-200 dark:hover:bg-zinc-800 rounded-full transition-colors cursor-pointer"})}),f.jsx(Pt,{children:f.jsx("p",{children:"Toggle theme"})})]}),f.jsxs($t,{children:[f.jsx(Mt,{asChild:!0,children:f.jsxs(je,{variant:"ghost",className:"hover:bg-zinc-200 dark:hover:bg-zinc-800 rounded-full px-1 -mx-3 flex gap-1",onClick:i,children:[f.jsx(Wfe,{className:"size-4"}),f.jsx("span",{className:"text-base font-mono hidden sm:inline",children:"K"})]})}),f.jsx(Pt,{children:f.jsx("p",{children:"Command Palette"})})]}),f.jsxs($t,{children:[f.jsx(Mt,{asChild:!0,children:f.jsx(je,{variant:"ghost",size:"sm",asChild:!0,children:f.jsxs("a",{href:"https://github.com/mcp-use/mcp-use",className:"flex items-center gap-2",target:"_blank",rel:"noopener noreferrer",children:[f.jsx(r2,{className:"h-4 w-4"}),f.jsx("span",{className:"hidden sm:inline",children:"Github"})]})})}),f.jsx(Pt,{children:f.jsx("p",{children:"Give us a star ⭐"})})]}),f.jsx(i2,{state:"expanded"})]})]})]})}function X_e({children:e}){const t=Ju(),n=Uo(),{connections:a,addConnection:r,removeConnection:i,updateConnectionConfig:s,configLoaded:c}=tN(),{selectedServerId:u,setSelectedServerId:d,activeTab:m,setActiveTab:h,navigateToItem:g,setTunnelUrl:v}=Zl(),[S,w]=x.useState(!1),[y,_]=x.useState(null),E=mwe();x.useEffect(()=>{const Z=new URLSearchParams(n.search).get("tunnelUrl");v(Z)},[n.search,v]),x.useEffect(()=>{const B=re=>{const j=re.detail.requestId;u&&g(u,"sampling",j)},Z=re=>{const j=re.detail.requestId;u&&g(u,"elicitation",j)},G=re=>{const j=re.detail.toolName;u&&j?g(u,"tools",j):u&&h("tools")};return window.addEventListener("navigate-to-sampling",B),window.addEventListener("navigate-to-elicitation",Z),window.addEventListener("navigate-to-tool-result",G),()=>{window.removeEventListener("navigate-to-sampling",B),window.removeEventListener("navigate-to-elicitation",Z),window.removeEventListener("navigate-to-tool-result",G)}},[u,h,g]);const k=x.useRef(null),R=x.useRef(null),C=x.useRef(null),{isAutoConnecting:I}=pwe({connections:a,addConnection:r,removeConnection:i,configLoaded:c}),A=x.useCallback(B=>{yr.getInstance().capture(new lfe({trigger:B})).catch(()=>{}),w(!0)},[]),O=B=>{const Z=a.find(j=>j.id===B);if(!Z||Z.state!=="ready"){Jt.error("Server is not connected and cannot be inspected");return}d(B);const re=new URLSearchParams(n.search).get("tunnelUrl"),ne=re?`/?server=${encodeURIComponent(B)}&tunnelUrl=${encodeURIComponent(re)}`:`/?server=${encodeURIComponent(B)}`;t(ne)},M=x.useCallback(B=>{_(B)},[]),U=x.useCallback(B=>{y&&(B.url!==y?(i(y),r(B.url,B.name,B.proxyConfig,B.transportType)):s(y,{name:B.name,proxyConfig:B.proxyConfig,transportType:B.transportType}),_(null),Jt.success("Connection settings updated"))},[y,i,r,s]),H=(B,Z,G)=>{if(console.warn("[Layout] handleCommandPaletteNavigate called:",{tab:B,itemName:Z,serverId:G}),G){const re=a.find(z=>z.id===G);if(console.warn("[Layout] Server lookup:",{serverId:G,serverFound:!!re,serverState:re?.state}),!re||re.state!=="ready"){console.warn("[Layout] Server not ready, showing error"),Jt.error("Server is not connected and cannot be inspected");return}console.warn("[Layout] Calling navigateToItem:",{serverId:G,tab:B,itemName:Z}),g(G,B,Z);const j=new URLSearchParams(n.search).get("tunnelUrl"),V=j?`/?server=${encodeURIComponent(G)}&tunnelUrl=${encodeURIComponent(j)}`:`/?server=${encodeURIComponent(G)}`;console.warn("[Layout] Navigating to:",V),t(V)}else console.warn("[Layout] No serverId, just updating tab to:",B),h(B)},K=a.find(B=>B.id===u),ee=K?K.tools.map(B=>({...B,_serverId:K.id})):a.flatMap(B=>B.state==="ready"?B.tools.map(Z=>({...Z,_serverId:B.id,_serverName:B.name})):[]),J=K?K.prompts.map(B=>({...B,_serverId:K.id})):a.flatMap(B=>B.state==="ready"?B.prompts.map(Z=>({...Z,_serverId:B.id,_serverName:B.name})):[]),ie=K?K.resources.map(B=>({...B,_serverId:K.id})):a.flatMap(B=>B.state==="ready"?B.resources.map(Z=>({...Z,_serverId:B.id,_serverName:B.name})):[]);return x.useEffect(()=>{const Z=new URLSearchParams(n.search).get("server"),G=Z?decodeURIComponent(Z):null;G!==u&&d(G)},[n.search,u,d]),x.useEffect(()=>{const Z=new URLSearchParams(n.search).get("server");if(!Z)return;const G=decodeURIComponent(Z),re=a.find(ne=>ne.id===G);if(!re){const ne=setTimeout(()=>t("/"),3e3);return()=>clearTimeout(ne)}if(re.state==="failed"){const ne=setTimeout(()=>t("/"),2e3);return()=>clearTimeout(ne)}},[n.search,t,a]),TW({onCommandPalette:()=>A("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"&&R.current?R.current.focusSearch():m==="resources"&&C.current&&C.current.focusSearch()},onBlurSearch:()=>{m==="tools"&&k.current?k.current.blurSearch():m==="prompts"&&R.current?R.current.blurSearch():m==="resources"&&C.current&&C.current.blurSearch()}}),I?f.jsx("div",{className:"h-screen bg-white dark:bg-zinc-900 flex items-center justify-center",children:f.jsxs("div",{className:"flex flex-col items-center gap-4",children:[f.jsx(Hi,{className:"h-8 w-8 text-zinc-600 dark:text-zinc-400"}),f.jsx("p",{className:"text-sm text-zinc-600 dark:text-zinc-400",children:"Connecting to MCP server..."})]})}):f.jsx(P9,{children:f.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:[f.jsx(q_e,{connections:a,selectedServer:K,activeTab:m,onServerSelect:O,onTabChange:h,onCommandPaletteOpen:()=>A("button"),onOpenConnectionOptions:M}),f.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:f.jsx(K_e,{selectedServer:K,activeTab:m,toolsSearchRef:k,promptsSearchRef:R,resourcesSearchRef:C,children:e})}),f.jsx(Fwe,{isOpen:S,onOpenChange:w,tools:ee,prompts:J,resources:ie,savedRequests:E,connections:a,onNavigate:H,onServerSelect:O}),f.jsx(H8,{connection:y&&a.find(B=>B.id===y)||null,open:y!==null,onOpenChange:B=>{B||_(null)},onConnect:U})]})})}function J_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),kT().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"?f.jsx("div",{className:"h-screen w-full flex items-center justify-center bg-white dark:bg-zinc-900",children:f.jsxs("div",{className:"flex flex-col items-center gap-4",children:[f.jsx(Is,{className:"h-8 w-8 animate-spin text-zinc-600 dark:text-zinc-400"}),f.jsx("p",{className:"text-sm text-zinc-600 dark:text-zinc-400",children:"Completing authentication..."})]})}):e==="error"?f.jsx("div",{className:"h-screen w-full flex items-center justify-center bg-white dark:bg-zinc-900",children:f.jsxs("div",{className:"max-w-md p-6",children:[f.jsx("h1",{className:"text-xl font-semibold text-red-600 dark:text-red-400 mb-2",children:"Authentication Error"}),f.jsx("p",{className:"text-sm text-zinc-600 dark:text-zinc-400 mb-4",children:n}),f.jsx("p",{className:"text-xs text-zinc-500 dark:text-zinc-500",children:"You can close this window and try again."})]})}):f.jsx("div",{className:"h-screen w-full flex items-center justify-center bg-white dark:bg-zinc-900",children:f.jsxs("div",{className:"max-w-md p-6",children:[f.jsx("h1",{className:"text-xl font-semibold text-green-600 dark:text-green-400 mb-2",children:"Authentication Successful!"}),f.jsx("p",{className:"text-sm text-zinc-600 dark:text-zinc-400",children:"Redirecting you back..."})]})})}var Q_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(S=>{let w=S==="class",y=w&&i?r.map(_=>i[_]||_):r;w?(u.classList.remove(...y),u.classList.add(i&&i[v]?i[v]:v)):u.setAttribute(S,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,S=s&&v==="system"?g():v;m(S)}catch{}},eke=x.createContext(void 0),tke={setTheme:e=>{},themes:[]},nke=()=>{var e;return(e=x.useContext(eke))!=null?e:tke};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:`(${Q_e.toString()})(${m})`}})});function rke({...e}){const{theme:t="system"}=nke();return f.jsx(Y9,{theme:t,className:"toaster group",style:{"--normal-bg":"var(--popover)","--normal-text":"var(--popover-foreground)","--normal-border":"var(--border)"},...e})}function ake(){return f.jsx(ASe,{children:f.jsx(hfe,{children:f.jsxs(fwe,{children:[f.jsx(poe,{basename:"/inspector",children:f.jsxs(Vie,{children:[f.jsx(KS,{path:"/oauth/callback",element:f.jsx(J_e,{})}),f.jsx(KS,{path:"/",element:f.jsx(X_e,{children:f.jsx(dwe,{})})})]})}),f.jsx(rke,{position:"top-center"})]})})})}const d2=new URLSearchParams(window.location.search);if(d2.has("code")||d2.has("error"))try{kT()}catch(e){console.error("[inspector] OAuth callback error:",e)}const f2=document.getElementById("root");f2?Qae.createRoot(f2).render(f.jsx(ake,{})):console.error("[inspector] Root element not found");export{E3 as $,v6 as A,b6 as B,Av as C,S6 as D,I5 as E,Wg as F,$ae as G,uP as H,kT as I,g2 as L,Iae as M,ue as R,jae as W,Nt as Z,Ge as _,dr as a,Zu as b,Qu as c,gS as d,oke as e,mi as f,Tp as g,bS as h,ei as i,DB as j,z3 as k,C2 as l,I2 as m,OB as n,S3 as o,U2 as p,mee as q,x as r,H_ as s,JB as t,Re as u,vee as v,D5 as w,wS as x,Bee as y,Yk as z};