@mcp-use/inspector 0.13.0-canary.5 → 0.13.0-canary.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/assets/{browser-BdMDtIlv.js → browser-BoLKWpwz.js} +4 -4
- package/dist/client/assets/{display-A5IEINAP-dqxgrgbQ.js → display-A5IEINAP-BY84EJZk.js} +2 -2
- package/dist/client/assets/{embeddings-CSf4uSmN.js → embeddings-8blUtIbt.js} +1 -1
- package/dist/client/assets/{index-BzDHD_Cr.js → index-BAK37pc4.js} +1 -1
- package/dist/client/assets/{index-CdRFVlLS.js → index-BAxAv6UE.js} +7 -7
- package/dist/client/assets/{index-CTlKvTfg.js → index-CSlqw8-V.js} +1 -1
- package/dist/client/assets/{index-Bsd6iYVu.js → index-CsvzhAm-.js} +1 -1
- package/dist/client/assets/{index-DY_o0BMd.js → index-DOp47eHE.js} +1 -1
- package/dist/client/assets/{index-ifgbqaNd.js → index-DPD9iyF6.js} +1 -1
- package/dist/client/assets/{index-CEMsS_qT.js → index-DwpYRN9f.js} +1 -1
- package/dist/client/assets/{index-DbyrwQxd.js → index-jb1lbUp7.js} +1 -1
- package/dist/client/assets/{index-DzgEpj4m.js → index-olcjmwjt.js} +1 -1
- package/dist/client/assets/langfuse-74RGPTAH-YjoHS_KH.js +1 -0
- package/dist/client/assets/{path-BcSHKymO.js → path-B4GZD74M.js} +1 -1
- package/dist/client/assets/{winston-DS4dbLAZ.js → winston-BtMmKlI5.js} +1 -1
- package/dist/client/index.html +2 -2
- package/package.json +2 -2
- package/dist/client/assets/langfuse-74RGPTAH-CSnfC9fN.js +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/winston-
|
|
2
|
-
var Mq=Object.defineProperty;var Pq=(e,t,n)=>t in e?Mq(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var _f=(e,t,n)=>Pq(e,typeof t!="symbol"?t+"":t,n);function Uq(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 $v(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function Kke(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 mx={exports:{}},kf={};var P$;function zq(){if(P$)return kf;P$=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 kf.Fragment=t,kf.jsx=n,kf.jsxs=n,kf}var U$;function Fq(){return U$||(U$=1,mx.exports=zq()),mx.exports}var f=Fq();const Bq="modulepreload",Hq=function(e){return"/inspector/"+e},z$={},Qn=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=Hq(d),d in z$)return;z$[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":Bq,m||(g.as="script"),g.crossOrigin="",g.href=d,c&&g.setAttribute("nonce",c),document.head.appendChild(g),m)return new Promise((v,w)=>{g.addEventListener("load",v),g.addEventListener("error",()=>w(new Error(`Unable to preload CSS for ${d}`)))})}))}function i(s){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=s,window.dispatchEvent(c),!c.defaultPrevented)throw s}return r.then(s=>{for(const c of s||[])c.status==="rejected"&&i(c.reason);return t().catch(i)})};var Vq=Object.defineProperty,ze=(e,t)=>Vq(e,"name",{value:t,configurable:!0}),Es=(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')}),Gc={};async function $2(){if(typeof process<"u")try{const e=await Qn(()=>import("fs"),[]),t=await Qn(()=>import("./path-MNZaYwxc.js").then(n=>n.p),[]);return{fs:e.default,path:t.default}}catch{return{fs:null,path:null}}return{fs:null,path:null}}ze($2,"getNodeModules");var pa=null;function M2(){if(typeof Es<"u")try{pa=Es("winston")}catch{}}ze(M2,"loadWinstonSync");async function P2(){return pa||(pa=await Qn(()=>import("./winston-DS4dbLAZ.js").then(e=>e.w),__vite__mapDeps([0,1,2,3,4]))),pa}ze(P2,"getWinston");var LS="mcp-use";function Rb(){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}}ze(Rb,"isNodeJSEnvironment");var Su,Gq=(Su=class{_level;name;constructor(t=LS,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}},ze(Su,"SimpleConsoleLogger"),Su);function ab(e){switch((typeof process<"u"&&Gc?e:void 0)?.trim()){case"2":return"debug";case"1":return"info";default:return"info"}}ze(ab,"resolveLevel");var So,U2=(So=class{static get(t=LS){if(!Rb()){if(!this.simpleInstances[t]){const n=typeof process<"u"&&Gc?.DEBUG||void 0;this.simpleInstances[t]=new Gq(t,ab(n))}return this.simpleInstances[t]}if(!this.instances[t]){if(!pa)throw new Error("Winston not loaded - call Logger.configure() first");const{createLogger:n,format:a}=pa,{combine:r,timestamp:i,label:s,colorize:c,splat:u}=a;this.instances[t]=n({level:ab(Gc.DEBUG),format:r(c(),u(),s({label:t}),i({format:"HH:mm:ss"}),this.getFormatter()),transports:[new pa.transports.Console]})}return this.instances[t]}static getFormatter(){if(!pa)throw new Error("Winston not loaded");const{format:t}=pa,{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"&&Gc?.DEBUG||void 0,c=n??ab(s);if(this.currentFormat=i,!Rb()){Object.values(this.simpleInstances).forEach(y=>{y.level=c});return}if(await P2(),!pa)throw new Error("Failed to load winston");const u=this.get();u.level=c;const d=u;if(d.clear(),a&&d.add(new pa.transports.Console),r){const{fs:y,path:_}=await $2();if(y&&_){const E=_.dirname(_.resolve(r));y.existsSync(E)||y.mkdirSync(E,{recursive:!0}),d.add(new pa.transports.File({filename:r}))}}const{format:m}=pa,{combine:h,timestamp:g,label:v,colorize:w,splat:S}=m;Object.values(this.instances).forEach(y=>{y&&"format"in y&&(y.level=c,y.format=h(w(),S(),v({label:LS}),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"&&Gc&&(Gc.DEBUG=t?t===!0?"2":String(t):"0")}static setFormat(t){this.currentFormat=t,this.configure({format:t})}},ze(So,"Logger"),_f(So,"instances",{}),_f(So,"simpleInstances",{}),_f(So,"currentFormat","minimal"),So);Rb()&&(M2(),pa&&U2.configure());var ke=U2.get(),ib={},z2=typeof globalThis.Deno<"u";function Wq(e){return z2?globalThis.Deno.env.get(e):ib[e]}ze(Wq,"getEnv");function Kq(){return z2?globalThis.Deno.cwd():process.cwd()}ze(Kq,"getCwd");function Lf(){return globalThis.crypto.randomUUID()}ze(Lf,"generateUUID");var Zq="1.11.0-canary.5";function Ab(){return Zq}ze(Ab,"getPackageVersion");var Eu,Ti=(Eu=class{},ze(Eu,"BaseTelemetryEvent"),Eu),_u,Yq=(_u=class extends Ti{constructor(t){super(),this.data=t}get name(){return"mcp_agent_execution"}get properties(){return{execution_method:this.data.executionMethod,query:this.data.query,query_length:this.data.query.length,success:this.data.success,model_provider:this.data.modelProvider,model_name:this.data.modelName,server_count:this.data.serverCount,server_identifiers:this.data.serverIdentifiers,total_tools_available:this.data.totalToolsAvailable,tools_available_names:this.data.toolsAvailableNames,max_steps_configured:this.data.maxStepsConfigured,memory_enabled:this.data.memoryEnabled,use_server_manager:this.data.useServerManager,max_steps_used:this.data.maxStepsUsed,manage_connector:this.data.manageConnector,external_history_used:this.data.externalHistoryUsed,steps_taken:this.data.stepsTaken??null,tools_used_count:this.data.toolsUsedCount??null,tools_used_names:this.data.toolsUsedNames??null,response:this.data.response??null,response_length:this.data.response?this.data.response.length:null,execution_time_ms:this.data.executionTimeMs??null,error_type:this.data.errorType??null,conversation_history_length:this.data.conversationHistoryLength??null}}},ze(_u,"MCPAgentExecutionEvent"),_u);function F2(e,t){const n=Array.from(e.registrations.tools.values()),a=Array.from(e.registrations.prompts.values()),r=Array.from(e.registrations.resources.values()),i=Array.from(e.registrations.resourceTemplates.values()),s=r.map(m=>({name:m.config.name,title:m.config.title??null,description:m.config.description??null,uri:m.config.uri??null,mime_type:m.config.mimeType??null})),c=s.filter(m=>m.mime_type==="text/html+skybridge"),u=s.filter(m=>m.mime_type==="text/uri-list"||m.mime_type==="text/html"),d=s.filter(m=>m.mime_type==="text/html+mcp");return{transport:t,toolsNumber:e.registeredTools.length,resourcesNumber:e.registeredResources.length,promptsNumber:e.registeredPrompts.length,auth:!!e.oauthProvider,name:e.config.name,description:e.config.description??null,baseUrl:e.serverBaseUrl??null,toolNames:e.registeredTools.length>0?e.registeredTools:null,resourceNames:e.registeredResources.length>0?e.registeredResources:null,promptNames:e.registeredPrompts.length>0?e.registeredPrompts:null,tools:n.length>0?n.map(m=>({name:m.config.name,title:m.config.title??null,description:m.config.description??null,input_schema:m.config.schema?JSON.stringify(m.config.schema):null,output_schema:m.config.outputSchema?JSON.stringify(m.config.outputSchema):null})):null,resources:s.length>0?s:null,prompts:a.length>0?a.map(m=>({name:m.config.name,title:m.config.title??null,description:m.config.description??null,args:m.config.args?JSON.stringify(m.config.args):null})):null,templates:i.length>0?i.map(m=>({name:m.config.name,title:m.config.title??null,description:m.config.description??null})):null,capabilities:{logging:!0,resources:{subscribe:!0,listChanged:!0}},appsSdkResources:c.length>0?c:null,appsSdkResourcesNumber:c.length,mcpUiResources:u.length>0?u:null,mcpUiResourcesNumber:u.length,mcpAppsResources:d.length>0?d:null,mcpAppsResourcesNumber:d.length}}ze(F2,"createServerRunEventData");var ku,qq=(ku=class extends Ti{constructor(t){super(),this.data=t}get name(){return"server_run"}get properties(){return{transport:this.data.transport,tools_number:this.data.toolsNumber,resources_number:this.data.resourcesNumber,prompts_number:this.data.promptsNumber,auth:this.data.auth,name:this.data.name,description:this.data.description??null,base_url:this.data.baseUrl??null,tool_names:this.data.toolNames??null,resource_names:this.data.resourceNames??null,prompt_names:this.data.promptNames??null,tools:this.data.tools??null,resources:this.data.resources??null,prompts:this.data.prompts??null,templates:this.data.templates??null,capabilities:this.data.capabilities?JSON.stringify(this.data.capabilities):null,apps_sdk_resources:this.data.appsSdkResources?JSON.stringify(this.data.appsSdkResources):null,apps_sdk_resources_number:this.data.appsSdkResourcesNumber??0,mcp_ui_resources:this.data.mcpUiResources?JSON.stringify(this.data.mcpUiResources):null,mcp_ui_resources_number:this.data.mcpUiResourcesNumber??0,mcp_apps_resources:this.data.mcpAppsResources?JSON.stringify(this.data.mcpAppsResources):null,mcp_apps_resources_number:this.data.mcpAppsResourcesNumber??0}}},ze(ku,"ServerRunEvent"),ku),Tu,Xq=(Tu=class extends Ti{constructor(t){super(),this.data=t}get name(){return"server_initialize_call"}get properties(){return{protocol_version:this.data.protocolVersion,client_info:JSON.stringify(this.data.clientInfo),client_capabilities:JSON.stringify(this.data.clientCapabilities),session_id:this.data.sessionId??null}}},ze(Tu,"ServerInitializeEvent"),Tu),Nu,Jq=(Nu=class extends Ti{constructor(t){super(),this.data=t}get name(){return"server_tool_call"}get properties(){return{tool_name:this.data.toolName,length_input_argument:this.data.lengthInputArgument,success:this.data.success,error_type:this.data.errorType??null,execution_time_ms:this.data.executionTimeMs??null}}},ze(Nu,"ServerToolCallEvent"),Nu),Cu,Qq=(Cu=class extends Ti{constructor(t){super(),this.data=t}get name(){return"server_resource_call"}get properties(){return{name:this.data.name,description:this.data.description,contents:this.data.contents,success:this.data.success,error_type:this.data.errorType??null}}},ze(Cu,"ServerResourceCallEvent"),Cu),Ru,eX=(Ru=class extends Ti{constructor(t){super(),this.data=t}get name(){return"server_prompt_call"}get properties(){return{name:this.data.name,description:this.data.description,success:this.data.success,error_type:this.data.errorType??null}}},ze(Ru,"ServerPromptCallEvent"),Ru),Au,tX=(Au=class extends Ti{constructor(t){super(),this.data=t}get name(){return`server_context_${this.data.contextType}`}get properties(){return{context_type:this.data.contextType,notification_type:this.data.notificationType??null}}},ze(Au,"ServerContextEvent"),Au),Iu,nX=(Iu=class extends Ti{constructor(t){super(),this.data=t}get name(){return"mcpclient_init"}get properties(){return{code_mode:this.data.codeMode,sandbox:this.data.sandbox,all_callbacks:this.data.allCallbacks,verify:this.data.verify,servers:this.data.servers,num_servers:this.data.numServers,is_browser:this.data.isBrowser}}},ze(Iu,"MCPClientInitEvent"),Iu),Ou,rX=(Ou=class extends Ti{constructor(t){super(),this.data=t}get name(){return"connector_init"}get properties(){return{connector_type:this.data.connectorType,server_command:this.data.serverCommand??null,server_args:this.data.serverArgs??null,server_url:this.data.serverUrl??null,public_identifier:this.data.publicIdentifier??null}}},ze(Ou,"ConnectorInitEvent"),Ou),Du,aX=(Du=class extends Ti{constructor(t){super(),this.data=t}get name(){return"client_add_server"}get properties(){const{serverName:t,serverConfig:n}=this.data,a=n.url;return{server_name:t,server_url_domain:a?this._extractHostname(a):null,transport:n.transport??null,has_auth:!!(n.authToken||n.authProvider)}}_extractHostname(t){try{return new URL(t).hostname}catch{return null}}},ze(Du,"ClientAddServerEvent"),Du),ju,iX=(ju=class extends Ti{constructor(t){super(),this.data=t}get name(){return"client_remove_server"}get properties(){return{server_name:this.data.serverName}}},ze(ju,"ClientRemoveServerEvent"),ju);function B2(e){return e._llm_type||e.constructor.name.toLowerCase()}ze(B2,"getModelProvider");function H2(e){if("_identifyingParams"in e){const t=e._identifyingParams;if(typeof t=="object"&&t!==null){for(const n of["model","modelName","model_name","modelId","model_id","deploymentName","deployment_name"])if(n in t)return String(t[n])}}return e.model||e.modelName||e.constructor.name}ze(H2,"getModelName");function oX(e){return[B2(e),H2(e)]}ze(oX,"extractModelInfo");var F$="mcp_use_user_id";function V2(){try{return typeof globalThis.Bun<"u"?"bun":typeof globalThis.Deno<"u"?"deno":typeof navigator<"u"&&navigator.userAgent?.includes("Cloudflare-Workers")?"cloudflare-workers":typeof globalThis.EdgeRuntime<"u"?"edge":typeof window<"u"&&typeof document<"u"?"browser":typeof process<"u"&&typeof process.versions?.node<"u"?"node":"unknown"}catch{return"unknown"}}ze(V2,"detectRuntimeEnvironment");function G2(e){switch(e){case"node":case"bun":return"filesystem";case"browser":try{if(typeof localStorage<"u")return localStorage.setItem("__mcp_use_test__","1"),localStorage.removeItem("__mcp_use_test__"),"localStorage"}catch{}return"session-only";case"deno":return"session-only";default:return"session-only"}}ze(G2,"getStorageCapability");var hx=null;function W2(){return hx===null&&(hx=V2()),hx}ze(W2,"getRuntimeEnvironment");var Lu,sX=(Lu=class{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(n){ke.debug(`Failed to send Scarf event: ${n}`)}}},ze(Lu,"ScarfEventLogger"),Lu),pi,K2=(pi=class{PROJECT_API_KEY="phc_lyTtbYwvkdSbrcMQNPiKiiRWrrM1seyKIMjycSvItEI";HOST="https://eu.i.posthog.com";SCARF_GATEWAY_URL="https://mcpuse.gateway.scarf.sh/events-ts";UNKNOWN_USER_ID="UNKNOWN_USER_ID";_currUserId=null;_posthogNodeClient=null;_posthogBrowserClient=null;_posthogLoading=null;_scarfClient=null;_runtimeEnvironment;_storageCapability;_source;_userIdPath=null;_versionDownloadPath=null;constructor(){this._runtimeEnvironment=W2(),this._storageCapability=G2(this._runtimeEnvironment),this._source=typeof process<"u"&&ib?.MCP_USE_TELEMETRY_SOURCE||this._runtimeEnvironment;const t=this._checkTelemetryDisabled(),n=this._runtimeEnvironment!=="unknown";if(t)this._posthogNodeClient=null,this._posthogBrowserClient=null,this._scarfClient=null,ke.debug("Telemetry disabled via environment/localStorage");else if(!n)this._posthogNodeClient=null,this._posthogBrowserClient=null,this._scarfClient=null,ke.debug(`Telemetry disabled - unknown environment: ${this._runtimeEnvironment}`);else{ke.info("Anonymized telemetry enabled. Set MCP_USE_ANONYMIZED_TELEMETRY=false to disable."),this._posthogLoading=this._initPostHog();try{this._scarfClient=new sX(this.SCARF_GATEWAY_URL,3e3)}catch(a){ke.warn(`Failed to initialize Scarf telemetry: ${a}`),this._scarfClient=null}}}_checkTelemetryDisabled(){return typeof process<"u"&&ib?.MCP_USE_ANONYMIZED_TELEMETRY?.toLowerCase()==="false"||typeof localStorage<"u"&&localStorage.getItem("MCP_USE_ANONYMIZED_TELEMETRY")==="false"}async _initPostHog(){this._runtimeEnvironment==="browser"?await this._initPostHogBrowser():await this._initPostHogNode()}async _initPostHogBrowser(){try{const t=await Qn(()=>import("./module-DXhXtM9n.js"),[]),n=t.default||t.posthog;if(!n||typeof n.init!="function")throw new Error("posthog-js module did not export expected interface");n.init(this.PROJECT_API_KEY,{api_host:this.HOST,persistence:"localStorage",autocapture:!1,capture_pageview:!1,disable_session_recording:!0,loaded:ze(()=>{ke.debug("PostHog browser client initialized")},"loaded")}),this._posthogBrowserClient=n}catch(t){ke.warn(`Failed to initialize PostHog browser telemetry: ${t}`),this._posthogBrowserClient=null}}async _initPostHogNode(){try{const{PostHog:t}=await Qn(async()=>{const{PostHog:r}=await import("./posthog-node-CuYhrq1Q.js");return{PostHog:r}},[]),n=["cloudflare-workers","edge","deno"].includes(this._runtimeEnvironment),a={host:this.HOST,disableGeoip:!1};n&&(a.flushAt=1,a.flushInterval=0),this._posthogNodeClient=new t(this.PROJECT_API_KEY,a),ke.debug("PostHog Node.js client initialized")}catch(t){ke.warn(`Failed to initialize PostHog Node.js telemetry: ${t}`),this._posthogNodeClient=null}}get runtimeEnvironment(){return this._runtimeEnvironment}get storageCapability(){return this._storageCapability}static getInstance(){return pi.instance||(pi.instance=new pi),pi.instance}setSource(t){this._source=t,ke.debug(`Telemetry source set to: ${t}`)}getSource(){return this._source}get isEnabled(){return this._posthogNodeClient!==null||this._posthogBrowserClient!==null||this._scarfClient!==null}get userId(){if(this._currUserId)return this._currUserId;try{switch(this._storageCapability){case"filesystem":this._currUserId=this._getUserIdFromFilesystem();break;case"localStorage":this._currUserId=this._getUserIdFromLocalStorage();break;case"session-only":default:this._currUserId=`session-${Lf()}`,ke.debug(`Using session-based user ID (${this._runtimeEnvironment} environment)`);break}this._storageCapability==="filesystem"&&this._currUserId&&this._trackPackageDownloadInternal(this._currUserId,{triggered_by:"user_id_property"}).catch(t=>ke.debug(`Failed to track package download: ${t}`))}catch(t){ke.debug(`Failed to get/create user ID: ${t}`),this._currUserId=this.UNKNOWN_USER_ID}return this._currUserId}_getUserIdFromFilesystem(){const t=Es("fs"),n=Es("os"),a=Es("path");if(this._userIdPath||(this._userIdPath=a.join(this._getCacheHome(n,a),"mcp_use_3","telemetry_user_id")),!t.existsSync(this._userIdPath)){ke.debug(`Creating user ID path: ${this._userIdPath}`),t.mkdirSync(a.dirname(this._userIdPath),{recursive:!0});const i=Lf();return t.writeFileSync(this._userIdPath,i),ke.debug(`User ID path created: ${this._userIdPath}`),i}return t.readFileSync(this._userIdPath,"utf-8").trim()}_getUserIdFromLocalStorage(){try{let t=localStorage.getItem(F$);return t||(t=Lf(),localStorage.setItem(F$,t),ke.debug("Created new browser user ID")),t}catch(t){return ke.debug(`localStorage access failed: ${t}`),`session-${Lf()}`}}_getCacheHome(t,n){const a=ib.XDG_CACHE_HOME;if(a&&n.isAbsolute(a))return a;const r=t.homedir();return n.join(r,".cache")}async capture(t){if(this._posthogLoading&&await this._posthogLoading,!this._posthogNodeClient&&!this._posthogBrowserClient&&!this._scarfClient)return;const n={...t.properties};if(n.mcp_use_version=Ab(),n.language="typescript",n.source=this._source,n.runtime=this._runtimeEnvironment,this._posthogNodeClient)try{ke.debug(`CAPTURE: PostHog Node Event ${t.name}`),this._posthogNodeClient.capture({distinctId:this.userId,event:t.name,properties:n})}catch(a){ke.debug(`Failed to track PostHog Node event ${t.name}: ${a}`)}if(this._posthogBrowserClient)try{ke.debug(`CAPTURE: PostHog Browser Event ${t.name}`),this._posthogBrowserClient.capture(t.name,{...n,distinct_id:this.userId})}catch(a){ke.debug(`Failed to track PostHog Browser event ${t.name}: ${a}`)}if(this._scarfClient)try{const a={...n,user_id:this.userId,event:t.name};await this._scarfClient.logEvent(a)}catch(a){ke.debug(`Failed to track Scarf event ${t.name}: ${a}`)}}async trackPackageDownload(t){return this._trackPackageDownloadInternal(this.userId,t)}async _trackPackageDownloadInternal(t,n){if(this._scarfClient&&this._storageCapability==="filesystem")try{const a=Es("fs"),r=Es("path"),i=Es("os");this._versionDownloadPath||(this._versionDownloadPath=r.join(this._getCacheHome(i,r),"mcp_use","download_version"));const s=Ab();let c=!1,u=!1;if(!a.existsSync(this._versionDownloadPath))c=!0,u=!0,a.mkdirSync(r.dirname(this._versionDownloadPath),{recursive:!0}),a.writeFileSync(this._versionDownloadPath,s);else{const d=a.readFileSync(this._versionDownloadPath,"utf-8").trim();s>d&&(c=!0,u=!1,a.writeFileSync(this._versionDownloadPath,s))}if(c){ke.debug(`Tracking package download event with properties: ${JSON.stringify(n)}`);const d={...n||{}};d.mcp_use_version=s,d.user_id=t,d.event="package_download",d.first_download=u,d.language="typescript",d.source=this._source,d.runtime=this._runtimeEnvironment,await this._scarfClient.logEvent(d)}}catch(a){ke.debug(`Failed to track Scarf package_download event: ${a}`)}}async trackAgentExecution(t){if(!this.isEnabled)return;const n=new Yq(t);await this.capture(n)}async trackServerRunFromServer(t,n){if(!this.isEnabled)return;const a=F2(t,n),r=new qq(a);await this.capture(r)}async trackServerInitialize(t){if(!this.isEnabled)return;const n=new Xq(t);await this.capture(n)}async trackServerToolCall(t){if(!this.isEnabled)return;const n=new Jq(t);await this.capture(n)}async trackServerResourceCall(t){if(!this.isEnabled)return;const n=new Qq(t);await this.capture(n)}async trackServerPromptCall(t){if(!this.isEnabled)return;const n=new eX(t);await this.capture(n)}async trackServerContext(t){if(!this.isEnabled)return;const n=new tX(t);await this.capture(n)}async trackMCPClientInit(t){if(!this.isEnabled)return;const n=new nX(t);await this.capture(n)}async trackConnectorInit(t){if(!this.isEnabled)return;const n=new rX(t);await this.capture(n)}async trackClientAddServer(t,n){if(!this.isEnabled)return;const a=new aX({serverName:t,serverConfig:n});await this.capture(a)}async trackClientRemoveServer(t){if(!this.isEnabled)return;const n=new iX({serverName:t});await this.capture(n)}async trackUseMcpConnection(t){this.isEnabled&&await this.capture({name:"usemcp_connection",properties:{url_domain:new URL(t.url).hostname,transport_type:t.transportType,success:t.success,error_type:t.errorType??null,connection_time_ms:t.connectionTimeMs??null,has_oauth:t.hasOAuth,has_sampling:t.hasSampling,has_elicitation:t.hasElicitation}})}async trackUseMcpToolCall(t){this.isEnabled&&await this.capture({name:"usemcp_tool_call",properties:{tool_name:t.toolName,success:t.success,error_type:t.errorType??null,execution_time_ms:t.executionTimeMs??null}})}async trackUseMcpResourceRead(t){this.isEnabled&&await this.capture({name:"usemcp_resource_read",properties:{resource_uri_scheme:t.resourceUri.split(":")[0],success:t.success,error_type:t.errorType??null}})}identify(t,n){if(this._posthogBrowserClient)try{this._posthogBrowserClient.identify(t,n)}catch(a){ke.debug(`Failed to identify user: ${a}`)}}reset(){if(this._posthogBrowserClient)try{this._posthogBrowserClient.reset()}catch(t){ke.debug(`Failed to reset user: ${t}`)}this._currUserId=null}flush(){if(this._posthogNodeClient)try{this._posthogNodeClient.flush(),ke.debug("PostHog client telemetry queue flushed")}catch(t){ke.debug(`Failed to flush PostHog client: ${t}`)}}shutdown(){if(this._posthogNodeClient)try{this._posthogNodeClient.shutdown(),ke.debug("PostHog client shutdown successfully")}catch(t){ke.debug(`Error shutting down PostHog client: ${t}`)}}},ze(pi,"Telemetry"),_f(pi,"instance",null),pi),Mi=K2;function lX(e){Mi.getInstance().setSource(e)}ze(lX,"setTelemetrySource");const Z2=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 Y2=Symbol("zod_brand");class Rl extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Mv extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const Ib={};function ea(e){return e&&Object.assign(Ib,e),Ib}function cX(e){return e}function uX(e){return e}function dX(e){}function fX(e){throw new Error}function pX(e){}function P_(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=>ut(n)).join(t)}function Ob(e,t){return typeof t=="bigint"?t.toString():t}function Vp(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function Kl(e){return e==null}function Pv(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function q2(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 B$=Symbol("evaluating");function Ht(e,t,n){let a;Object.defineProperty(e,t,{get(){if(a!==B$)return a===void 0&&(a=B$,a=n()),a},set(r){Object.defineProperty(e,t,{value:r})},configurable:!0})}function mX(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function zs(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function zo(...e){const t={};for(const n of e){const a=Object.getOwnPropertyDescriptors(n);Object.assign(t,a)}return Object.defineProperties({},t)}function hX(e){return zo(e._zod.def)}function gX(e,t){return t?t.reduce((n,a)=>n?.[a],e):e}function bX(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 vX(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 $S(e){return JSON.stringify(e)}function X2(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const U_="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Vu(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const J2=Vp(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function jl(e){if(Vu(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(Vu(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function Uv(e){return jl(e)?{...e}:Array.isArray(e)?[...e]:e}function yX(e){let t=0;for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&t++;return t}const wX=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}`)}},Db=new Set(["string","number","symbol"]),Q2=new Set(["string","number","bigint","boolean","symbol","undefined"]);function Oo(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 xX(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 ut(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function eF(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const tF={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]},nF={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function rF(e,t){const n=e._zod.def,a=zo(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 zs(this,"shape",r),r},checks:[]});return ei(e,a)}function aF(e,t){const n=e._zod.def,a=zo(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 zs(this,"shape",r),r},checks:[]});return ei(e,a)}function iF(e,t){if(!jl(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=zo(e._zod.def,{get shape(){const i={...e._zod.def.shape,...t};return zs(this,"shape",i),i},checks:[]});return ei(e,r)}function oF(e,t){if(!jl(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 zs(this,"shape",a),a},checks:e._zod.def.checks};return ei(e,n)}function sF(e,t){const n=zo(e._zod.def,{get shape(){const a={...e._zod.def.shape,...t._zod.def.shape};return zs(this,"shape",a),a},get catchall(){return t._zod.def.catchall},checks:[]});return ei(e,n)}function lF(e,t,n){const a=zo(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 zs(this,"shape",i),i},checks:[]});return ei(t,a)}function cF(e,t,n){const a=zo(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 zs(this,"shape",i),i},checks:[]});return ei(t,a)}function El(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 mi(e,t){return t.map(n=>{var a;return(a=n).path??(a.path=[]),n.path.unshift(e),n})}function $f(e){return typeof e=="string"?e:e?.message}function yi(e,t,n){const a={...e,path:e.path??[]};if(!e.message){const r=$f(e.inst?._zod.def?.error?.(e))??$f(t?.error?.(e))??$f(n.customError?.(e))??$f(n.localeError?.(e))??"Invalid input";a.message=r}return delete a.inst,delete a.continue,t?.reportInput||delete a.input,a}function zv(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}function Fv(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Gu(...e){const[t,n,a]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:a}:{...t}}function SX(e){return Object.entries(e).filter(([t,n])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function uF(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 dF(e){let t="";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}function EX(e){const t=e.replace(/-/g,"+").replace(/_/g,"/"),n="=".repeat((4-t.length%4)%4);return uF(t+n)}function _X(e){return dF(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function kX(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 TX(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}class NX{constructor(...t){}}const fF=Object.freeze(Object.defineProperty({__proto__:null,BIGINT_FORMAT_RANGES:nF,Class:NX,NUMBER_FORMAT_RANGES:tF,aborted:El,allowsEval:J2,assert:pX,assertEqual:cX,assertIs:dX,assertNever:fX,assertNotEqual:uX,assignProp:zs,base64ToUint8Array:uF,base64urlToUint8Array:EX,cached:Vp,captureStackTrace:U_,cleanEnum:SX,cleanRegex:Pv,clone:ei,cloneDef:hX,createTransparentProxy:xX,defineLazy:Ht,esc:$S,escapeRegex:Oo,extend:iF,finalizeIssue:yi,floatSafeRemainder:q2,getElementAtPath:gX,getEnumValues:P_,getLengthableOrigin:Fv,getParsedType:wX,getSizableOrigin:zv,hexToUint8Array:kX,isObject:Vu,isPlainObject:jl,issue:Gu,joinValues:Pe,jsonStringifyReplacer:Ob,merge:sF,mergeDefs:zo,normalizeParams:Ae,nullish:Kl,numKeys:yX,objectClone:mX,omit:aF,optionalKeys:eF,partial:lF,pick:rF,prefixIssues:mi,primitiveTypes:Q2,promiseAllObject:bX,propertyKeyTypes:Db,randomString:vX,required:cF,safeExtend:oF,shallowClone:Uv,slugify:X2,stringifyPrimitive:ut,uint8ArrayToBase64:dF,uint8ArrayToBase64url:_X,uint8ArrayToHex:TX,unwrapMessage:$f},Symbol.toStringTag,{value:"Module"})),pF=(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,Ob,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},z_=me("$ZodError",pF),La=me("$ZodError",pF,{Parent:Error});function F_(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 B_(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 mF(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 hF(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 gF(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 ${hF(a.path)}`);return t.join(`
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/winston-BtMmKlI5.js","assets/util-t-trnxQI.js","assets/index-DRz5BQNA.js","assets/path-B4GZD74M.js","assets/path-MNZaYwxc.js","assets/index-DPD9iyF6.js","assets/index-DOp47eHE.js","assets/index-olcjmwjt.js","assets/index-DwpYRN9f.js","assets/embeddings-8blUtIbt.js","assets/index-CsvzhAm-.js","assets/index-CSlqw8-V.js","assets/browser-BoLKWpwz.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
var Mq=Object.defineProperty;var Pq=(e,t,n)=>t in e?Mq(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var _f=(e,t,n)=>Pq(e,typeof t!="symbol"?t+"":t,n);function Uq(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 $v(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function Kke(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 mx={exports:{}},kf={};var P$;function zq(){if(P$)return kf;P$=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 kf.Fragment=t,kf.jsx=n,kf.jsxs=n,kf}var U$;function Fq(){return U$||(U$=1,mx.exports=zq()),mx.exports}var f=Fq();const Bq="modulepreload",Hq=function(e){return"/inspector/"+e},z$={},Qn=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=Hq(d),d in z$)return;z$[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":Bq,m||(g.as="script"),g.crossOrigin="",g.href=d,c&&g.setAttribute("nonce",c),document.head.appendChild(g),m)return new Promise((v,w)=>{g.addEventListener("load",v),g.addEventListener("error",()=>w(new Error(`Unable to preload CSS for ${d}`)))})}))}function i(s){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=s,window.dispatchEvent(c),!c.defaultPrevented)throw s}return r.then(s=>{for(const c of s||[])c.status==="rejected"&&i(c.reason);return t().catch(i)})};var Vq=Object.defineProperty,ze=(e,t)=>Vq(e,"name",{value:t,configurable:!0}),Es=(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')}),Gc={};async function $2(){if(typeof process<"u")try{const e=await Qn(()=>import("fs"),[]),t=await Qn(()=>import("./path-MNZaYwxc.js").then(n=>n.p),[]);return{fs:e.default,path:t.default}}catch{return{fs:null,path:null}}return{fs:null,path:null}}ze($2,"getNodeModules");var pa=null;function M2(){if(typeof Es<"u")try{pa=Es("winston")}catch{}}ze(M2,"loadWinstonSync");async function P2(){return pa||(pa=await Qn(()=>import("./winston-BtMmKlI5.js").then(e=>e.w),__vite__mapDeps([0,1,2,3,4]))),pa}ze(P2,"getWinston");var LS="mcp-use";function Rb(){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}}ze(Rb,"isNodeJSEnvironment");var Su,Gq=(Su=class{_level;name;constructor(t=LS,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}},ze(Su,"SimpleConsoleLogger"),Su);function ab(e){switch((typeof process<"u"&&Gc?e:void 0)?.trim()){case"2":return"debug";case"1":return"info";default:return"info"}}ze(ab,"resolveLevel");var So,U2=(So=class{static get(t=LS){if(!Rb()){if(!this.simpleInstances[t]){const n=typeof process<"u"&&Gc?.DEBUG||void 0;this.simpleInstances[t]=new Gq(t,ab(n))}return this.simpleInstances[t]}if(!this.instances[t]){if(!pa)throw new Error("Winston not loaded - call Logger.configure() first");const{createLogger:n,format:a}=pa,{combine:r,timestamp:i,label:s,colorize:c,splat:u}=a;this.instances[t]=n({level:ab(Gc.DEBUG),format:r(c(),u(),s({label:t}),i({format:"HH:mm:ss"}),this.getFormatter()),transports:[new pa.transports.Console]})}return this.instances[t]}static getFormatter(){if(!pa)throw new Error("Winston not loaded");const{format:t}=pa,{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"&&Gc?.DEBUG||void 0,c=n??ab(s);if(this.currentFormat=i,!Rb()){Object.values(this.simpleInstances).forEach(y=>{y.level=c});return}if(await P2(),!pa)throw new Error("Failed to load winston");const u=this.get();u.level=c;const d=u;if(d.clear(),a&&d.add(new pa.transports.Console),r){const{fs:y,path:_}=await $2();if(y&&_){const E=_.dirname(_.resolve(r));y.existsSync(E)||y.mkdirSync(E,{recursive:!0}),d.add(new pa.transports.File({filename:r}))}}const{format:m}=pa,{combine:h,timestamp:g,label:v,colorize:w,splat:S}=m;Object.values(this.instances).forEach(y=>{y&&"format"in y&&(y.level=c,y.format=h(w(),S(),v({label:LS}),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"&&Gc&&(Gc.DEBUG=t?t===!0?"2":String(t):"0")}static setFormat(t){this.currentFormat=t,this.configure({format:t})}},ze(So,"Logger"),_f(So,"instances",{}),_f(So,"simpleInstances",{}),_f(So,"currentFormat","minimal"),So);Rb()&&(M2(),pa&&U2.configure());var ke=U2.get(),ib={},z2=typeof globalThis.Deno<"u";function Wq(e){return z2?globalThis.Deno.env.get(e):ib[e]}ze(Wq,"getEnv");function Kq(){return z2?globalThis.Deno.cwd():process.cwd()}ze(Kq,"getCwd");function Lf(){return globalThis.crypto.randomUUID()}ze(Lf,"generateUUID");var Zq="1.11.0-canary.6";function Ab(){return Zq}ze(Ab,"getPackageVersion");var Eu,Ti=(Eu=class{},ze(Eu,"BaseTelemetryEvent"),Eu),_u,Yq=(_u=class extends Ti{constructor(t){super(),this.data=t}get name(){return"mcp_agent_execution"}get properties(){return{execution_method:this.data.executionMethod,query:this.data.query,query_length:this.data.query.length,success:this.data.success,model_provider:this.data.modelProvider,model_name:this.data.modelName,server_count:this.data.serverCount,server_identifiers:this.data.serverIdentifiers,total_tools_available:this.data.totalToolsAvailable,tools_available_names:this.data.toolsAvailableNames,max_steps_configured:this.data.maxStepsConfigured,memory_enabled:this.data.memoryEnabled,use_server_manager:this.data.useServerManager,max_steps_used:this.data.maxStepsUsed,manage_connector:this.data.manageConnector,external_history_used:this.data.externalHistoryUsed,steps_taken:this.data.stepsTaken??null,tools_used_count:this.data.toolsUsedCount??null,tools_used_names:this.data.toolsUsedNames??null,response:this.data.response??null,response_length:this.data.response?this.data.response.length:null,execution_time_ms:this.data.executionTimeMs??null,error_type:this.data.errorType??null,conversation_history_length:this.data.conversationHistoryLength??null}}},ze(_u,"MCPAgentExecutionEvent"),_u);function F2(e,t){const n=Array.from(e.registrations.tools.values()),a=Array.from(e.registrations.prompts.values()),r=Array.from(e.registrations.resources.values()),i=Array.from(e.registrations.resourceTemplates.values()),s=r.map(m=>({name:m.config.name,title:m.config.title??null,description:m.config.description??null,uri:m.config.uri??null,mime_type:m.config.mimeType??null})),c=s.filter(m=>m.mime_type==="text/html+skybridge"),u=s.filter(m=>m.mime_type==="text/uri-list"||m.mime_type==="text/html"),d=s.filter(m=>m.mime_type==="text/html+mcp");return{transport:t,toolsNumber:e.registeredTools.length,resourcesNumber:e.registeredResources.length,promptsNumber:e.registeredPrompts.length,auth:!!e.oauthProvider,name:e.config.name,description:e.config.description??null,baseUrl:e.serverBaseUrl??null,toolNames:e.registeredTools.length>0?e.registeredTools:null,resourceNames:e.registeredResources.length>0?e.registeredResources:null,promptNames:e.registeredPrompts.length>0?e.registeredPrompts:null,tools:n.length>0?n.map(m=>({name:m.config.name,title:m.config.title??null,description:m.config.description??null,input_schema:m.config.schema?JSON.stringify(m.config.schema):null,output_schema:m.config.outputSchema?JSON.stringify(m.config.outputSchema):null})):null,resources:s.length>0?s:null,prompts:a.length>0?a.map(m=>({name:m.config.name,title:m.config.title??null,description:m.config.description??null,args:m.config.args?JSON.stringify(m.config.args):null})):null,templates:i.length>0?i.map(m=>({name:m.config.name,title:m.config.title??null,description:m.config.description??null})):null,capabilities:{logging:!0,resources:{subscribe:!0,listChanged:!0}},appsSdkResources:c.length>0?c:null,appsSdkResourcesNumber:c.length,mcpUiResources:u.length>0?u:null,mcpUiResourcesNumber:u.length,mcpAppsResources:d.length>0?d:null,mcpAppsResourcesNumber:d.length}}ze(F2,"createServerRunEventData");var ku,qq=(ku=class extends Ti{constructor(t){super(),this.data=t}get name(){return"server_run"}get properties(){return{transport:this.data.transport,tools_number:this.data.toolsNumber,resources_number:this.data.resourcesNumber,prompts_number:this.data.promptsNumber,auth:this.data.auth,name:this.data.name,description:this.data.description??null,base_url:this.data.baseUrl??null,tool_names:this.data.toolNames??null,resource_names:this.data.resourceNames??null,prompt_names:this.data.promptNames??null,tools:this.data.tools??null,resources:this.data.resources??null,prompts:this.data.prompts??null,templates:this.data.templates??null,capabilities:this.data.capabilities?JSON.stringify(this.data.capabilities):null,apps_sdk_resources:this.data.appsSdkResources?JSON.stringify(this.data.appsSdkResources):null,apps_sdk_resources_number:this.data.appsSdkResourcesNumber??0,mcp_ui_resources:this.data.mcpUiResources?JSON.stringify(this.data.mcpUiResources):null,mcp_ui_resources_number:this.data.mcpUiResourcesNumber??0,mcp_apps_resources:this.data.mcpAppsResources?JSON.stringify(this.data.mcpAppsResources):null,mcp_apps_resources_number:this.data.mcpAppsResourcesNumber??0}}},ze(ku,"ServerRunEvent"),ku),Tu,Xq=(Tu=class extends Ti{constructor(t){super(),this.data=t}get name(){return"server_initialize_call"}get properties(){return{protocol_version:this.data.protocolVersion,client_info:JSON.stringify(this.data.clientInfo),client_capabilities:JSON.stringify(this.data.clientCapabilities),session_id:this.data.sessionId??null}}},ze(Tu,"ServerInitializeEvent"),Tu),Nu,Jq=(Nu=class extends Ti{constructor(t){super(),this.data=t}get name(){return"server_tool_call"}get properties(){return{tool_name:this.data.toolName,length_input_argument:this.data.lengthInputArgument,success:this.data.success,error_type:this.data.errorType??null,execution_time_ms:this.data.executionTimeMs??null}}},ze(Nu,"ServerToolCallEvent"),Nu),Cu,Qq=(Cu=class extends Ti{constructor(t){super(),this.data=t}get name(){return"server_resource_call"}get properties(){return{name:this.data.name,description:this.data.description,contents:this.data.contents,success:this.data.success,error_type:this.data.errorType??null}}},ze(Cu,"ServerResourceCallEvent"),Cu),Ru,eX=(Ru=class extends Ti{constructor(t){super(),this.data=t}get name(){return"server_prompt_call"}get properties(){return{name:this.data.name,description:this.data.description,success:this.data.success,error_type:this.data.errorType??null}}},ze(Ru,"ServerPromptCallEvent"),Ru),Au,tX=(Au=class extends Ti{constructor(t){super(),this.data=t}get name(){return`server_context_${this.data.contextType}`}get properties(){return{context_type:this.data.contextType,notification_type:this.data.notificationType??null}}},ze(Au,"ServerContextEvent"),Au),Iu,nX=(Iu=class extends Ti{constructor(t){super(),this.data=t}get name(){return"mcpclient_init"}get properties(){return{code_mode:this.data.codeMode,sandbox:this.data.sandbox,all_callbacks:this.data.allCallbacks,verify:this.data.verify,servers:this.data.servers,num_servers:this.data.numServers,is_browser:this.data.isBrowser}}},ze(Iu,"MCPClientInitEvent"),Iu),Ou,rX=(Ou=class extends Ti{constructor(t){super(),this.data=t}get name(){return"connector_init"}get properties(){return{connector_type:this.data.connectorType,server_command:this.data.serverCommand??null,server_args:this.data.serverArgs??null,server_url:this.data.serverUrl??null,public_identifier:this.data.publicIdentifier??null}}},ze(Ou,"ConnectorInitEvent"),Ou),Du,aX=(Du=class extends Ti{constructor(t){super(),this.data=t}get name(){return"client_add_server"}get properties(){const{serverName:t,serverConfig:n}=this.data,a=n.url;return{server_name:t,server_url_domain:a?this._extractHostname(a):null,transport:n.transport??null,has_auth:!!(n.authToken||n.authProvider)}}_extractHostname(t){try{return new URL(t).hostname}catch{return null}}},ze(Du,"ClientAddServerEvent"),Du),ju,iX=(ju=class extends Ti{constructor(t){super(),this.data=t}get name(){return"client_remove_server"}get properties(){return{server_name:this.data.serverName}}},ze(ju,"ClientRemoveServerEvent"),ju);function B2(e){return e._llm_type||e.constructor.name.toLowerCase()}ze(B2,"getModelProvider");function H2(e){if("_identifyingParams"in e){const t=e._identifyingParams;if(typeof t=="object"&&t!==null){for(const n of["model","modelName","model_name","modelId","model_id","deploymentName","deployment_name"])if(n in t)return String(t[n])}}return e.model||e.modelName||e.constructor.name}ze(H2,"getModelName");function oX(e){return[B2(e),H2(e)]}ze(oX,"extractModelInfo");var F$="mcp_use_user_id";function V2(){try{return typeof globalThis.Bun<"u"?"bun":typeof globalThis.Deno<"u"?"deno":typeof navigator<"u"&&navigator.userAgent?.includes("Cloudflare-Workers")?"cloudflare-workers":typeof globalThis.EdgeRuntime<"u"?"edge":typeof window<"u"&&typeof document<"u"?"browser":typeof process<"u"&&typeof process.versions?.node<"u"?"node":"unknown"}catch{return"unknown"}}ze(V2,"detectRuntimeEnvironment");function G2(e){switch(e){case"node":case"bun":return"filesystem";case"browser":try{if(typeof localStorage<"u")return localStorage.setItem("__mcp_use_test__","1"),localStorage.removeItem("__mcp_use_test__"),"localStorage"}catch{}return"session-only";case"deno":return"session-only";default:return"session-only"}}ze(G2,"getStorageCapability");var hx=null;function W2(){return hx===null&&(hx=V2()),hx}ze(W2,"getRuntimeEnvironment");var Lu,sX=(Lu=class{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(n){ke.debug(`Failed to send Scarf event: ${n}`)}}},ze(Lu,"ScarfEventLogger"),Lu),pi,K2=(pi=class{PROJECT_API_KEY="phc_lyTtbYwvkdSbrcMQNPiKiiRWrrM1seyKIMjycSvItEI";HOST="https://eu.i.posthog.com";SCARF_GATEWAY_URL="https://mcpuse.gateway.scarf.sh/events-ts";UNKNOWN_USER_ID="UNKNOWN_USER_ID";_currUserId=null;_posthogNodeClient=null;_posthogBrowserClient=null;_posthogLoading=null;_scarfClient=null;_runtimeEnvironment;_storageCapability;_source;_userIdPath=null;_versionDownloadPath=null;constructor(){this._runtimeEnvironment=W2(),this._storageCapability=G2(this._runtimeEnvironment),this._source=typeof process<"u"&&ib?.MCP_USE_TELEMETRY_SOURCE||this._runtimeEnvironment;const t=this._checkTelemetryDisabled(),n=this._runtimeEnvironment!=="unknown";if(t)this._posthogNodeClient=null,this._posthogBrowserClient=null,this._scarfClient=null,ke.debug("Telemetry disabled via environment/localStorage");else if(!n)this._posthogNodeClient=null,this._posthogBrowserClient=null,this._scarfClient=null,ke.debug(`Telemetry disabled - unknown environment: ${this._runtimeEnvironment}`);else{ke.info("Anonymized telemetry enabled. Set MCP_USE_ANONYMIZED_TELEMETRY=false to disable."),this._posthogLoading=this._initPostHog();try{this._scarfClient=new sX(this.SCARF_GATEWAY_URL,3e3)}catch(a){ke.warn(`Failed to initialize Scarf telemetry: ${a}`),this._scarfClient=null}}}_checkTelemetryDisabled(){return typeof process<"u"&&ib?.MCP_USE_ANONYMIZED_TELEMETRY?.toLowerCase()==="false"||typeof localStorage<"u"&&localStorage.getItem("MCP_USE_ANONYMIZED_TELEMETRY")==="false"}async _initPostHog(){this._runtimeEnvironment==="browser"?await this._initPostHogBrowser():await this._initPostHogNode()}async _initPostHogBrowser(){try{const t=await Qn(()=>import("./module-DXhXtM9n.js"),[]),n=t.default||t.posthog;if(!n||typeof n.init!="function")throw new Error("posthog-js module did not export expected interface");n.init(this.PROJECT_API_KEY,{api_host:this.HOST,persistence:"localStorage",autocapture:!1,capture_pageview:!1,disable_session_recording:!0,loaded:ze(()=>{ke.debug("PostHog browser client initialized")},"loaded")}),this._posthogBrowserClient=n}catch(t){ke.warn(`Failed to initialize PostHog browser telemetry: ${t}`),this._posthogBrowserClient=null}}async _initPostHogNode(){try{const{PostHog:t}=await Qn(async()=>{const{PostHog:r}=await import("./posthog-node-CuYhrq1Q.js");return{PostHog:r}},[]),n=["cloudflare-workers","edge","deno"].includes(this._runtimeEnvironment),a={host:this.HOST,disableGeoip:!1};n&&(a.flushAt=1,a.flushInterval=0),this._posthogNodeClient=new t(this.PROJECT_API_KEY,a),ke.debug("PostHog Node.js client initialized")}catch(t){ke.warn(`Failed to initialize PostHog Node.js telemetry: ${t}`),this._posthogNodeClient=null}}get runtimeEnvironment(){return this._runtimeEnvironment}get storageCapability(){return this._storageCapability}static getInstance(){return pi.instance||(pi.instance=new pi),pi.instance}setSource(t){this._source=t,ke.debug(`Telemetry source set to: ${t}`)}getSource(){return this._source}get isEnabled(){return this._posthogNodeClient!==null||this._posthogBrowserClient!==null||this._scarfClient!==null}get userId(){if(this._currUserId)return this._currUserId;try{switch(this._storageCapability){case"filesystem":this._currUserId=this._getUserIdFromFilesystem();break;case"localStorage":this._currUserId=this._getUserIdFromLocalStorage();break;case"session-only":default:this._currUserId=`session-${Lf()}`,ke.debug(`Using session-based user ID (${this._runtimeEnvironment} environment)`);break}this._storageCapability==="filesystem"&&this._currUserId&&this._trackPackageDownloadInternal(this._currUserId,{triggered_by:"user_id_property"}).catch(t=>ke.debug(`Failed to track package download: ${t}`))}catch(t){ke.debug(`Failed to get/create user ID: ${t}`),this._currUserId=this.UNKNOWN_USER_ID}return this._currUserId}_getUserIdFromFilesystem(){const t=Es("fs"),n=Es("os"),a=Es("path");if(this._userIdPath||(this._userIdPath=a.join(this._getCacheHome(n,a),"mcp_use_3","telemetry_user_id")),!t.existsSync(this._userIdPath)){ke.debug(`Creating user ID path: ${this._userIdPath}`),t.mkdirSync(a.dirname(this._userIdPath),{recursive:!0});const i=Lf();return t.writeFileSync(this._userIdPath,i),ke.debug(`User ID path created: ${this._userIdPath}`),i}return t.readFileSync(this._userIdPath,"utf-8").trim()}_getUserIdFromLocalStorage(){try{let t=localStorage.getItem(F$);return t||(t=Lf(),localStorage.setItem(F$,t),ke.debug("Created new browser user ID")),t}catch(t){return ke.debug(`localStorage access failed: ${t}`),`session-${Lf()}`}}_getCacheHome(t,n){const a=ib.XDG_CACHE_HOME;if(a&&n.isAbsolute(a))return a;const r=t.homedir();return n.join(r,".cache")}async capture(t){if(this._posthogLoading&&await this._posthogLoading,!this._posthogNodeClient&&!this._posthogBrowserClient&&!this._scarfClient)return;const n={...t.properties};if(n.mcp_use_version=Ab(),n.language="typescript",n.source=this._source,n.runtime=this._runtimeEnvironment,this._posthogNodeClient)try{ke.debug(`CAPTURE: PostHog Node Event ${t.name}`),this._posthogNodeClient.capture({distinctId:this.userId,event:t.name,properties:n})}catch(a){ke.debug(`Failed to track PostHog Node event ${t.name}: ${a}`)}if(this._posthogBrowserClient)try{ke.debug(`CAPTURE: PostHog Browser Event ${t.name}`),this._posthogBrowserClient.capture(t.name,{...n,distinct_id:this.userId})}catch(a){ke.debug(`Failed to track PostHog Browser event ${t.name}: ${a}`)}if(this._scarfClient)try{const a={...n,user_id:this.userId,event:t.name};await this._scarfClient.logEvent(a)}catch(a){ke.debug(`Failed to track Scarf event ${t.name}: ${a}`)}}async trackPackageDownload(t){return this._trackPackageDownloadInternal(this.userId,t)}async _trackPackageDownloadInternal(t,n){if(this._scarfClient&&this._storageCapability==="filesystem")try{const a=Es("fs"),r=Es("path"),i=Es("os");this._versionDownloadPath||(this._versionDownloadPath=r.join(this._getCacheHome(i,r),"mcp_use","download_version"));const s=Ab();let c=!1,u=!1;if(!a.existsSync(this._versionDownloadPath))c=!0,u=!0,a.mkdirSync(r.dirname(this._versionDownloadPath),{recursive:!0}),a.writeFileSync(this._versionDownloadPath,s);else{const d=a.readFileSync(this._versionDownloadPath,"utf-8").trim();s>d&&(c=!0,u=!1,a.writeFileSync(this._versionDownloadPath,s))}if(c){ke.debug(`Tracking package download event with properties: ${JSON.stringify(n)}`);const d={...n||{}};d.mcp_use_version=s,d.user_id=t,d.event="package_download",d.first_download=u,d.language="typescript",d.source=this._source,d.runtime=this._runtimeEnvironment,await this._scarfClient.logEvent(d)}}catch(a){ke.debug(`Failed to track Scarf package_download event: ${a}`)}}async trackAgentExecution(t){if(!this.isEnabled)return;const n=new Yq(t);await this.capture(n)}async trackServerRunFromServer(t,n){if(!this.isEnabled)return;const a=F2(t,n),r=new qq(a);await this.capture(r)}async trackServerInitialize(t){if(!this.isEnabled)return;const n=new Xq(t);await this.capture(n)}async trackServerToolCall(t){if(!this.isEnabled)return;const n=new Jq(t);await this.capture(n)}async trackServerResourceCall(t){if(!this.isEnabled)return;const n=new Qq(t);await this.capture(n)}async trackServerPromptCall(t){if(!this.isEnabled)return;const n=new eX(t);await this.capture(n)}async trackServerContext(t){if(!this.isEnabled)return;const n=new tX(t);await this.capture(n)}async trackMCPClientInit(t){if(!this.isEnabled)return;const n=new nX(t);await this.capture(n)}async trackConnectorInit(t){if(!this.isEnabled)return;const n=new rX(t);await this.capture(n)}async trackClientAddServer(t,n){if(!this.isEnabled)return;const a=new aX({serverName:t,serverConfig:n});await this.capture(a)}async trackClientRemoveServer(t){if(!this.isEnabled)return;const n=new iX({serverName:t});await this.capture(n)}async trackUseMcpConnection(t){this.isEnabled&&await this.capture({name:"usemcp_connection",properties:{url_domain:new URL(t.url).hostname,transport_type:t.transportType,success:t.success,error_type:t.errorType??null,connection_time_ms:t.connectionTimeMs??null,has_oauth:t.hasOAuth,has_sampling:t.hasSampling,has_elicitation:t.hasElicitation}})}async trackUseMcpToolCall(t){this.isEnabled&&await this.capture({name:"usemcp_tool_call",properties:{tool_name:t.toolName,success:t.success,error_type:t.errorType??null,execution_time_ms:t.executionTimeMs??null}})}async trackUseMcpResourceRead(t){this.isEnabled&&await this.capture({name:"usemcp_resource_read",properties:{resource_uri_scheme:t.resourceUri.split(":")[0],success:t.success,error_type:t.errorType??null}})}identify(t,n){if(this._posthogBrowserClient)try{this._posthogBrowserClient.identify(t,n)}catch(a){ke.debug(`Failed to identify user: ${a}`)}}reset(){if(this._posthogBrowserClient)try{this._posthogBrowserClient.reset()}catch(t){ke.debug(`Failed to reset user: ${t}`)}this._currUserId=null}flush(){if(this._posthogNodeClient)try{this._posthogNodeClient.flush(),ke.debug("PostHog client telemetry queue flushed")}catch(t){ke.debug(`Failed to flush PostHog client: ${t}`)}}shutdown(){if(this._posthogNodeClient)try{this._posthogNodeClient.shutdown(),ke.debug("PostHog client shutdown successfully")}catch(t){ke.debug(`Error shutting down PostHog client: ${t}`)}}},ze(pi,"Telemetry"),_f(pi,"instance",null),pi),Mi=K2;function lX(e){Mi.getInstance().setSource(e)}ze(lX,"setTelemetrySource");const Z2=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 Y2=Symbol("zod_brand");class Rl extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Mv extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const Ib={};function ea(e){return e&&Object.assign(Ib,e),Ib}function cX(e){return e}function uX(e){return e}function dX(e){}function fX(e){throw new Error}function pX(e){}function P_(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=>ut(n)).join(t)}function Ob(e,t){return typeof t=="bigint"?t.toString():t}function Vp(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function Kl(e){return e==null}function Pv(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function q2(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 B$=Symbol("evaluating");function Ht(e,t,n){let a;Object.defineProperty(e,t,{get(){if(a!==B$)return a===void 0&&(a=B$,a=n()),a},set(r){Object.defineProperty(e,t,{value:r})},configurable:!0})}function mX(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function zs(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function zo(...e){const t={};for(const n of e){const a=Object.getOwnPropertyDescriptors(n);Object.assign(t,a)}return Object.defineProperties({},t)}function hX(e){return zo(e._zod.def)}function gX(e,t){return t?t.reduce((n,a)=>n?.[a],e):e}function bX(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 vX(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 $S(e){return JSON.stringify(e)}function X2(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const U_="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Vu(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const J2=Vp(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function jl(e){if(Vu(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(Vu(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function Uv(e){return jl(e)?{...e}:Array.isArray(e)?[...e]:e}function yX(e){let t=0;for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&t++;return t}const wX=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}`)}},Db=new Set(["string","number","symbol"]),Q2=new Set(["string","number","bigint","boolean","symbol","undefined"]);function Oo(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 xX(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 ut(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function eF(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const tF={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]},nF={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function rF(e,t){const n=e._zod.def,a=zo(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 zs(this,"shape",r),r},checks:[]});return ei(e,a)}function aF(e,t){const n=e._zod.def,a=zo(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 zs(this,"shape",r),r},checks:[]});return ei(e,a)}function iF(e,t){if(!jl(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=zo(e._zod.def,{get shape(){const i={...e._zod.def.shape,...t};return zs(this,"shape",i),i},checks:[]});return ei(e,r)}function oF(e,t){if(!jl(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 zs(this,"shape",a),a},checks:e._zod.def.checks};return ei(e,n)}function sF(e,t){const n=zo(e._zod.def,{get shape(){const a={...e._zod.def.shape,...t._zod.def.shape};return zs(this,"shape",a),a},get catchall(){return t._zod.def.catchall},checks:[]});return ei(e,n)}function lF(e,t,n){const a=zo(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 zs(this,"shape",i),i},checks:[]});return ei(t,a)}function cF(e,t,n){const a=zo(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 zs(this,"shape",i),i},checks:[]});return ei(t,a)}function El(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 mi(e,t){return t.map(n=>{var a;return(a=n).path??(a.path=[]),n.path.unshift(e),n})}function $f(e){return typeof e=="string"?e:e?.message}function yi(e,t,n){const a={...e,path:e.path??[]};if(!e.message){const r=$f(e.inst?._zod.def?.error?.(e))??$f(t?.error?.(e))??$f(n.customError?.(e))??$f(n.localeError?.(e))??"Invalid input";a.message=r}return delete a.inst,delete a.continue,t?.reportInput||delete a.input,a}function zv(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}function Fv(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Gu(...e){const[t,n,a]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:a}:{...t}}function SX(e){return Object.entries(e).filter(([t,n])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function uF(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 dF(e){let t="";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}function EX(e){const t=e.replace(/-/g,"+").replace(/_/g,"/"),n="=".repeat((4-t.length%4)%4);return uF(t+n)}function _X(e){return dF(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function kX(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 TX(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}class NX{constructor(...t){}}const fF=Object.freeze(Object.defineProperty({__proto__:null,BIGINT_FORMAT_RANGES:nF,Class:NX,NUMBER_FORMAT_RANGES:tF,aborted:El,allowsEval:J2,assert:pX,assertEqual:cX,assertIs:dX,assertNever:fX,assertNotEqual:uX,assignProp:zs,base64ToUint8Array:uF,base64urlToUint8Array:EX,cached:Vp,captureStackTrace:U_,cleanEnum:SX,cleanRegex:Pv,clone:ei,cloneDef:hX,createTransparentProxy:xX,defineLazy:Ht,esc:$S,escapeRegex:Oo,extend:iF,finalizeIssue:yi,floatSafeRemainder:q2,getElementAtPath:gX,getEnumValues:P_,getLengthableOrigin:Fv,getParsedType:wX,getSizableOrigin:zv,hexToUint8Array:kX,isObject:Vu,isPlainObject:jl,issue:Gu,joinValues:Pe,jsonStringifyReplacer:Ob,merge:sF,mergeDefs:zo,normalizeParams:Ae,nullish:Kl,numKeys:yX,objectClone:mX,omit:aF,optionalKeys:eF,partial:lF,pick:rF,prefixIssues:mi,primitiveTypes:Q2,promiseAllObject:bX,propertyKeyTypes:Db,randomString:vX,required:cF,safeExtend:oF,shallowClone:Uv,slugify:X2,stringifyPrimitive:ut,uint8ArrayToBase64:dF,uint8ArrayToBase64url:_X,uint8ArrayToHex:TX,unwrapMessage:$f},Symbol.toStringTag,{value:"Module"})),pF=(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,Ob,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},z_=me("$ZodError",pF),La=me("$ZodError",pF,{Parent:Error});function F_(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 B_(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 mF(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 hF(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 gF(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 ${hF(a.path)}`);return t.join(`
|
|
3
3
|
`)}const Gp=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 Rl;if(s.issues.length){const c=new(r?.Err??e)(s.issues.map(u=>yi(u,i,ea())));throw U_(c,r?.callee),c}return s.value},MS=Gp(La),Wp=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=>yi(u,i,ea())));throw U_(c,r?.callee),c}return s.value},PS=Wp(La),Kp=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 Rl;return i.issues.length?{success:!1,error:new(e??z_)(i.issues.map(s=>yi(s,r,ea())))}:{success:!0,data:i.value}},H_=Kp(La),Zp=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=>yi(s,r,ea())))}:{success:!0,data:i.value}},bF=Zp(La),V_=e=>(t,n,a)=>{const r=a?Object.assign(a,{direction:"backward"}):{direction:"backward"};return Gp(e)(t,n,r)},CX=V_(La),G_=e=>(t,n,a)=>Gp(e)(t,n,a),RX=G_(La),W_=e=>async(t,n,a)=>{const r=a?Object.assign(a,{direction:"backward"}):{direction:"backward"};return Wp(e)(t,n,r)},AX=W_(La),K_=e=>async(t,n,a)=>Wp(e)(t,n,a),IX=K_(La),Z_=e=>(t,n,a)=>{const r=a?Object.assign(a,{direction:"backward"}):{direction:"backward"};return Kp(e)(t,n,r)},OX=Z_(La),Y_=e=>(t,n,a)=>Kp(e)(t,n,a),DX=Y_(La),q_=e=>async(t,n,a)=>{const r=a?Object.assign(a,{direction:"backward"}):{direction:"backward"};return Zp(e)(t,n,r)},jX=q_(La),X_=e=>async(t,n,a)=>Zp(e)(t,n,a),LX=X_(La),vF=/^[cC][^\s-]{8,}$/,yF=/^[0-9a-z]+$/,wF=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,xF=/^[0-9a-vA-V]{20}$/,SF=/^[A-Za-z0-9]{27}$/,EF=/^[a-zA-Z0-9_-]{21}$/,_F=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,$X=/^[-+]?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)?)??$/,kF=/^([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})$/,Wu=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)$/,MX=Wu(4),PX=Wu(6),UX=Wu(7),TF=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,zX=/^[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])?)*$/,FX=/^(([^<>()\[\]\\.,;:\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,}))$/,NF=/^[^\s@"]{1,64}@[^\s@]{1,255}$/u,BX=NF,HX=/^[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])?)*$/,VX="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function CF(){return new RegExp(VX,"u")}const RF=/^(?:(?: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])$/,AF=/^(([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}|:))$/,IF=e=>{const t=Oo(e??":");return new RegExp(`^(?:[0-9A-F]{2}${t}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${t}){5}[0-9a-f]{2}$`)},OF=/^((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])$/,DF=/^(([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])$/,jF=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,J_=/^[A-Za-z0-9_-]*$/,LF=/^(?=.{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])?)*\.?$/,$F=/^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/,MF=/^\+(?:[0-9]){6,14}[0-9]$/,PF="(?:(?:\\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])))",UF=new RegExp(`^${PF}$`);function zF(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 FF(e){return new RegExp(`^${zF(e)}$`)}function BF(e){const t=zF({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(`^${PF}T(?:${a})$`)}const HF=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},VF=/^-?\d+n?$/,GF=/^-?\d+$/,WF=/^-?\d+(?:\.\d+)?/,KF=/^(?:true|false)$/i,ZF=/^null$/i,YF=/^undefined$/i,qF=/^[^A-Z]*$/,XF=/^[^a-z]*$/,JF=/^[0-9a-fA-F]*$/;function Yp(e,t){return new RegExp(`^[A-Za-z0-9+/]{${e}}${t}$`)}function qp(e){return new RegExp(`^[A-Za-z0-9_-]{${e}}$`)}const GX=/^[0-9a-fA-F]{32}$/,WX=Yp(22,"=="),KX=qp(22),ZX=/^[0-9a-fA-F]{40}$/,YX=Yp(27,"="),qX=qp(27),XX=/^[0-9a-fA-F]{64}$/,JX=Yp(43,"="),QX=qp(43),eJ=/^[0-9a-fA-F]{96}$/,tJ=Yp(64,""),nJ=qp(64),rJ=/^[0-9a-fA-F]{128}$/,aJ=Yp(86,"=="),iJ=qp(86),Q_=Object.freeze(Object.defineProperty({__proto__:null,base64:jF,base64url:J_,bigint:VF,boolean:KF,browserEmail:HX,cidrv4:OF,cidrv6:DF,cuid:vF,cuid2:yF,date:UF,datetime:BF,domain:$F,duration:_F,e164:MF,email:TF,emoji:CF,extendedDuration:$X,guid:kF,hex:JF,hostname:LF,html5Email:zX,idnEmail:BX,integer:GF,ipv4:RF,ipv6:AF,ksuid:SF,lowercase:qF,mac:IF,md5_base64:WX,md5_base64url:KX,md5_hex:GX,nanoid:EF,null:ZF,number:WF,rfc5322Email:FX,sha1_base64:YX,sha1_base64url:qX,sha1_hex:ZX,sha256_base64:JX,sha256_base64url:QX,sha256_hex:XX,sha384_base64:tJ,sha384_base64url:nJ,sha384_hex:eJ,sha512_base64:aJ,sha512_base64url:iJ,sha512_hex:rJ,string:HF,time:FF,ulid:wF,undefined:YF,unicodeEmail:NF,uppercase:XF,uuid:Wu,uuid4:MX,uuid6:PX,uuid7:UX,xid:xF},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=[])}),QF={number:"number",bigint:"bigint",object:"date"},ek=me("$ZodCheckLessThan",(e,t)=>{Un.init(e,t);const n=QF[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})}}),tk=me("$ZodCheckGreaterThan",(e,t)=>{Un.init(e,t);const n=QF[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})}}),e3=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):q2(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})}}),t3=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]=tF[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=GF)}),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})}}),n3=me("$ZodCheckBigIntFormat",(e,t)=>{Un.init(e,t);const[n,a]=nF[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})}}),r3=me("$ZodCheckMaxSize",(e,t)=>{var n;Un.init(e,t),(n=e._zod.def).when??(n.when=a=>{const r=a.value;return!Kl(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:zv(r),code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),a3=me("$ZodCheckMinSize",(e,t)=>{var n;Un.init(e,t),(n=e._zod.def).when??(n.when=a=>{const r=a.value;return!Kl(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:zv(r),code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),i3=me("$ZodCheckSizeEquals",(e,t)=>{var n;Un.init(e,t),(n=e._zod.def).when??(n.when=a=>{const r=a.value;return!Kl(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:zv(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})}}),o3=me("$ZodCheckMaxLength",(e,t)=>{var n;Un.init(e,t),(n=e._zod.def).when??(n.when=a=>{const r=a.value;return!Kl(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=Fv(r);a.issues.push({origin:s,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),s3=me("$ZodCheckMinLength",(e,t)=>{var n;Un.init(e,t),(n=e._zod.def).when??(n.when=a=>{const r=a.value;return!Kl(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=Fv(r);a.issues.push({origin:s,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),l3=me("$ZodCheckLengthEquals",(e,t)=>{var n;Un.init(e,t),(n=e._zod.def).when??(n.when=a=>{const r=a.value;return!Kl(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=Fv(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})}}),Xp=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=()=>{})}),c3=me("$ZodCheckRegex",(e,t)=>{Xp.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})}}),u3=me("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=qF),Xp.init(e,t)}),d3=me("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=XF),Xp.init(e,t)}),f3=me("$ZodCheckIncludes",(e,t)=>{Un.init(e,t);const n=Oo(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})}}),p3=me("$ZodCheckStartsWith",(e,t)=>{Un.init(e,t);const n=new RegExp(`^${Oo(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})}}),m3=me("$ZodCheckEndsWith",(e,t)=>{Un.init(e,t);const n=new RegExp(`.*${Oo(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 H$(e,t,n){e.issues.length&&t.issues.push(...mi(n,e.issues))}const h3=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=>H$(r,n,t.property));H$(a,n,t.property)}}),g3=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})}}),b3=me("$ZodCheckOverwrite",(e,t)=>{Un.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class v3{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 y3={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=y3;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=El(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 Rl;if(m||v instanceof Promise)m=(m??Promise.resolve()).then(async()=>{await v,s.issues.length!==g&&(d||(d=El(s,g)))});else{if(s.issues.length===g)continue;d||(d=El(s,g))}}return m?m.then(()=>s):s},i=(s,c,u)=>{if(El(s))return s.aborted=!0,s;const d=r(c,a,u);if(d instanceof Promise){if(u.async===!1)throw new Rl;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 Rl;return u.then(d=>r(d,a,c))}return r(u,a,c)}}e["~standard"]={validate:r=>{try{const i=H_(e,r);return i.success?{value:i.data}:{issues:i.error?.issues}}catch{return bF(e,r).then(s=>s.success?{value:s.data}:{issues:s.error?.issues})}},vendor:"zod",version:1}}),Jp=me("$ZodString",(e,t)=>{bt.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??HF(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)=>{Xp.init(e,t),Jp.init(e,t)}),w3=me("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=kF),Tn.init(e,t)}),x3=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=Wu(a))}else t.pattern??(t.pattern=Wu());Tn.init(e,t)}),S3=me("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=TF),Tn.init(e,t)}),E3=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})}}}),_3=me("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=CF()),Tn.init(e,t)}),k3=me("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=EF),Tn.init(e,t)}),T3=me("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=vF),Tn.init(e,t)}),N3=me("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=yF),Tn.init(e,t)}),C3=me("$ZodULID",(e,t)=>{t.pattern??(t.pattern=wF),Tn.init(e,t)}),R3=me("$ZodXID",(e,t)=>{t.pattern??(t.pattern=xF),Tn.init(e,t)}),A3=me("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=SF),Tn.init(e,t)}),I3=me("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=BF(t)),Tn.init(e,t)}),O3=me("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=UF),Tn.init(e,t)}),D3=me("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=FF(t)),Tn.init(e,t)}),j3=me("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=_F),Tn.init(e,t)}),L3=me("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=RF),Tn.init(e,t),e._zod.bag.format="ipv4"}),$3=me("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=AF),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})}}}),M3=me("$ZodMAC",(e,t)=>{t.pattern??(t.pattern=IF(t.delimiter)),Tn.init(e,t),e._zod.bag.format="mac"}),P3=me("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=OF),Tn.init(e,t)}),U3=me("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=DF),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 nk(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const z3=me("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=jF),Tn.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{nk(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function F3(e){if(!J_.test(e))return!1;const t=e.replace(/[-_]/g,a=>a==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return nk(n)}const B3=me("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=J_),Tn.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{F3(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),H3=me("$ZodE164",(e,t)=>{t.pattern??(t.pattern=MF),Tn.init(e,t)});function V3(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 G3=me("$ZodJWT",(e,t)=>{Tn.init(e,t),e._zod.check=n=>{V3(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),W3=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})}}),rk=me("$ZodNumber",(e,t)=>{bt.init(e,t),e._zod.pattern=e._zod.bag.pattern??WF,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}}),K3=me("$ZodNumberFormat",(e,t)=>{t3.init(e,t),rk.init(e,t)}),ak=me("$ZodBoolean",(e,t)=>{bt.init(e,t),e._zod.pattern=KF,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}}),ik=me("$ZodBigInt",(e,t)=>{bt.init(e,t),e._zod.pattern=VF,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}}),Z3=me("$ZodBigIntFormat",(e,t)=>{n3.init(e,t),ik.init(e,t)}),Y3=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}}),q3=me("$ZodUndefined",(e,t)=>{bt.init(e,t),e._zod.pattern=YF,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}}),X3=me("$ZodNull",(e,t)=>{bt.init(e,t),e._zod.pattern=ZF,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}}),J3=me("$ZodAny",(e,t)=>{bt.init(e,t),e._zod.parse=n=>n}),Q3=me("$ZodUnknown",(e,t)=>{bt.init(e,t),e._zod.parse=n=>n}),eB=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)}),tB=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}}),nB=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 V$(e,t,n){e.issues.length&&t.issues.push(...mi(n,e.issues)),t.value[n]=e.value}const rB=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=>V$(d,n,s))):V$(u,n,s)}return i.length?Promise.all(i).then(()=>n):n}});function jb(e,t,n,a){e.issues.length&&t.issues.push(...mi(n,e.issues)),e.value===void 0?n in a&&(t.value[n]=void 0):t.value[n]=e.value}function aB(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=eF(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function iB(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=>jb(g,n,m,t))):jb(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 oB=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=Vp(()=>aB(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=Vu,i=t.catchall;let s;e._zod.parse=(c,u)=>{s??(s=a.value);const d=c.value;if(!r(d))return c.issues.push({expected:"object",code:"invalid_type",input:d,inst:e}),c;c.value={};const m=[],h=s.shape;for(const g of s.keys){const w=h[g]._zod.run({value:d[g],issues:[]},u);w instanceof Promise?m.push(w.then(S=>jb(S,c,g,d))):jb(w,c,g,d)}return i?iB(m,d,c,u,a.value,e):m.length?Promise.all(m).then(()=>c):c}}),sB=me("$ZodObjectJIT",(e,t)=>{oB.init(e,t);const n=e._zod.parse,a=Vp(()=>aB(t)),r=g=>{const v=new v3(["shape","payload","ctx"]),w=a.value,S=k=>{const C=$S(k);return`shape[${C}]._zod.run({ value: input[${C}], issues: [] }, ctx)`};v.write("const input = payload.value;");const y=Object.create(null);let _=0;for(const k of w.keys)y[k]=`key_${_++}`;v.write("const newResult = {};");for(const k of w.keys){const C=y[k],R=$S(k);v.write(`const ${C} = ${S(k)};`),v.write(`
|
|
@@ -32,7 +32,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
32
32
|
`;break;case"id":c=y.includes("\0")?void 0:y;break;case"retry":/^\d+$/.test(y)?a(parseInt(y,10)):n(new CP(`Invalid \`retry\` value: "${y}"`,{type:"invalid-retry",value:y,line:_}));break;default:n(new CP(`Unknown field "${S.length>20?`${S.slice(0,20)}…`:S}"`,{type:"unknown-field",field:S,value:y,line:_}));break}}function v(){u.length>0&&t({id:c,event:d||void 0,data:u.endsWith(`
|
|
33
33
|
`)?u.slice(0,-1):u}),c=void 0,u="",d=""}function w(S={}){i&&S.consume&&h(i),s=!0,c=void 0,u="",d="",i=""}return{feed:m,reset:w}}function lie(e){const t=[];let n="",a=0;for(;a<e.length;){const r=e.indexOf("\r",a),i=e.indexOf(`
|
|
34
34
|
`,a);let s=-1;if(r!==-1&&i!==-1?s=Math.min(r,i):r!==-1?r===e.length-1?s=-1:s=r:i!==-1&&(s=i),s===-1){n=e.slice(a);break}else{const c=e.slice(a,s);t.push(c),a=s+1,e[a-1]==="\r"&&e[a]===`
|
|
35
|
-
`&&a++}}return[t,n]}class cie extends TransformStream{constructor({onError:t,onRetry:n,onComment:a}={}){let r;super({start(i){r=IH({onEvent:s=>{i.enqueue(s)},onError(s){t==="terminate"?i.error(s):typeof t=="function"&&t(s)},onRetry:n,onComment:a})},transform(i){r.feed(i)}})}}const uie={initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:2};class yl extends Error{constructor(t,n){super(`Streamable HTTP error: ${n}`),this.code=t}}class die{constructor(t,n){var a;this._hasCompletedAuthFlow=!1,this._url=t,this._resourceMetadataUrl=void 0,this._scope=void 0,this._requestInit=n?.requestInit,this._authProvider=n?.authProvider,this._fetch=n?.fetch,this._fetchWithInit=bH(n?.fetch,n?.requestInit),this._sessionId=n?.sessionId,this._reconnectionOptions=(a=n?.reconnectionOptions)!==null&&a!==void 0?a:uie}async _authThenStart(){var t;if(!this._authProvider)throw new Ya("No auth provider");let n;try{n=await ko(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(a){throw(t=this.onerror)===null||t===void 0||t.call(this,a),a}if(n!=="AUTHORIZED")throw new Ya;return await this._startOrAuthSse({resumptionToken:void 0})}async _commonHeaders(){var t;const n={};if(this._authProvider){const r=await this._authProvider.tokens();r&&(n.Authorization=`Bearer ${r.access_token}`)}this._sessionId&&(n["mcp-session-id"]=this._sessionId),this._protocolVersion&&(n["mcp-protocol-version"]=this._protocolVersion);const a=Vb((t=this._requestInit)===null||t===void 0?void 0:t.headers);return new Headers({...n,...a})}async _startOrAuthSse(t){var n,a,r,i;const{resumptionToken:s}=t;try{const c=await this._commonHeaders();c.set("Accept","text/event-stream"),s&&c.set("last-event-id",s);const u=await((n=this._fetch)!==null&&n!==void 0?n:fetch)(this._url,{method:"GET",headers:c,signal:(a=this._abortController)===null||a===void 0?void 0:a.signal});if(!u.ok){if(await((r=u.body)===null||r===void 0?void 0:r.cancel()),u.status===401&&this._authProvider)return await this._authThenStart();if(u.status===405)return;throw new yl(u.status,`Failed to open SSE stream: ${u.statusText}`)}this._handleSseStream(u.body,t,!0)}catch(c){throw(i=this.onerror)===null||i===void 0||i.call(this,c),c}}_getNextReconnectionDelay(t){if(this._serverRetryMs!==void 0)return this._serverRetryMs;const n=this._reconnectionOptions.initialReconnectionDelay,a=this._reconnectionOptions.reconnectionDelayGrowFactor,r=this._reconnectionOptions.maxReconnectionDelay;return Math.min(n*Math.pow(a,t),r)}_scheduleReconnection(t,n=0){var a;const r=this._reconnectionOptions.maxRetries;if(n>=r){(a=this.onerror)===null||a===void 0||a.call(this,new Error(`Maximum reconnection attempts (${r}) exceeded.`));return}const i=this._getNextReconnectionDelay(n);this._reconnectionTimeout=setTimeout(()=>{this._startOrAuthSse(t).catch(s=>{var c;(c=this.onerror)===null||c===void 0||c.call(this,new Error(`Failed to reconnect SSE stream: ${s instanceof Error?s.message:String(s)}`)),this._scheduleReconnection(t,n+1)})},i)}_handleSseStream(t,n,a){if(!t)return;const{onresumptiontoken:r,replayMessageId:i}=n;let s,c=!1,u=!1;(async()=>{var m,h,g,v;try{const w=t.pipeThrough(new TextDecoderStream).pipeThrough(new cie({onRetry:_=>{this._serverRetryMs=_}})).getReader();for(;;){const{value:_,done:E}=await w.read();if(E)break;if(_.id&&(s=_.id,c=!0,r?.(_.id)),!!_.data&&(!_.event||_.event==="message"))try{const k=ob.parse(JSON.parse(_.data));Pf(k)&&(u=!0,i!==void 0&&(k.id=i)),(m=this.onmessage)===null||m===void 0||m.call(this,k)}catch(k){(h=this.onerror)===null||h===void 0||h.call(this,k)}}(a||c)&&!u&&this._abortController&&!this._abortController.signal.aborted&&this._scheduleReconnection({resumptionToken:s,onresumptiontoken:r,replayMessageId:i},0)}catch(w){if((g=this.onerror)===null||g===void 0||g.call(this,new Error(`SSE stream disconnected: ${w}`)),(a||c)&&!u&&this._abortController&&!this._abortController.signal.aborted)try{this._scheduleReconnection({resumptionToken:s,onresumptiontoken:r,replayMessageId:i},0)}catch(_){(v=this.onerror)===null||v===void 0||v.call(this,new Error(`Failed to reconnect: ${_ instanceof Error?_.message:String(_)}`))}}})()}async start(){if(this._abortController)throw new Error("StreamableHTTPClientTransport already started! If using Client class, note that connect() calls start() automatically.");this._abortController=new AbortController}async finishAuth(t){if(!this._authProvider)throw new Ya("No auth provider");if(await ko(this._authProvider,{serverUrl:this._url,authorizationCode:t,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new Ya("Failed to authorize")}async close(){var t,n;this._reconnectionTimeout&&(clearTimeout(this._reconnectionTimeout),this._reconnectionTimeout=void 0),(t=this._abortController)===null||t===void 0||t.abort(),(n=this.onclose)===null||n===void 0||n.call(this)}async send(t,n){var a,r,i,s,c,u,d;try{const{resumptionToken:m,onresumptiontoken:h}=n||{};if(m){this._startOrAuthSse({resumptionToken:m,replayMessageId:VS(t)?t.id:void 0}).catch(k=>{var C;return(C=this.onerror)===null||C===void 0?void 0:C.call(this,k)});return}const g=await this._commonHeaders();g.set("content-type","application/json"),g.set("accept","application/json, text/event-stream");const v={...this._requestInit,method:"POST",headers:g,body:JSON.stringify(t),signal:(a=this._abortController)===null||a===void 0?void 0:a.signal},w=await((r=this._fetch)!==null&&r!==void 0?r:fetch)(this._url,v),S=w.headers.get("mcp-session-id");if(S&&(this._sessionId=S),!w.ok){const k=await w.text().catch(()=>null);if(w.status===401&&this._authProvider){if(this._hasCompletedAuthFlow)throw new yl(401,"Server returned 401 after successful authentication");const{resourceMetadataUrl:C,scope:R}=yp(w);if(this._resourceMetadataUrl=C,this._scope=R,await ko(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new Ya;return this._hasCompletedAuthFlow=!0,this.send(t)}if(w.status===403&&this._authProvider){const{resourceMetadataUrl:C,scope:R,error:I}=yp(w);if(I==="insufficient_scope"){const A=w.headers.get("WWW-Authenticate");if(this._lastUpscopingHeader===A)throw new yl(403,"Server returned 403 after trying upscoping");if(R&&(this._scope=R),C&&(this._resourceMetadataUrl=C),this._lastUpscopingHeader=A??void 0,await ko(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetch})!=="AUTHORIZED")throw new Ya;return this.send(t)}}throw new yl(w.status,`Error POSTing to endpoint: ${k}`)}if(this._hasCompletedAuthFlow=!1,this._lastUpscopingHeader=void 0,w.status===202){await((i=w.body)===null||i===void 0?void 0:i.cancel()),tne(t)&&this._startOrAuthSse({resumptionToken:void 0}).catch(k=>{var C;return(C=this.onerror)===null||C===void 0?void 0:C.call(this,k)});return}const _=(Array.isArray(t)?t:[t]).filter(k=>"method"in k&&"id"in k&&k.id!==void 0).length>0,E=w.headers.get("content-type");if(_)if(E?.includes("text/event-stream"))this._handleSseStream(w.body,{onresumptiontoken:h},!1);else if(E?.includes("application/json")){const k=await w.json(),C=Array.isArray(k)?k.map(R=>ob.parse(R)):[ob.parse(k)];for(const R of C)(s=this.onmessage)===null||s===void 0||s.call(this,R)}else throw await((c=w.body)===null||c===void 0?void 0:c.cancel()),new yl(-1,`Unexpected content type: ${E}`);else await((u=w.body)===null||u===void 0?void 0:u.cancel())}catch(m){throw(d=this.onerror)===null||d===void 0||d.call(this,m),m}}get sessionId(){return this._sessionId}async terminateSession(){var t,n,a,r;if(this._sessionId)try{const i=await this._commonHeaders(),s={...this._requestInit,method:"DELETE",headers:i,signal:(t=this._abortController)===null||t===void 0?void 0:t.signal},c=await((n=this._fetch)!==null&&n!==void 0?n:fetch)(this._url,s);if(await((a=c.body)===null||a===void 0?void 0:a.cancel()),!c.ok&&c.status!==405)throw new yl(c.status,`Failed to terminate session: ${c.statusText}`);this._sessionId=void 0}catch(i){throw(r=this.onerror)===null||r===void 0||r.call(this,i),i}}setProtocolVersion(t){this._protocolVersion=t}get protocolVersion(){return this._protocolVersion}async resumeStream(t,n){await this._startOrAuthSse({resumptionToken:t,onresumptiontoken:n?.onresumptiontoken})}}class RP extends Event{constructor(t,n){var a,r;super(t),this.code=(a=n?.code)!=null?a:void 0,this.message=(r=n?.message)!=null?r:void 0}[Symbol.for("nodejs.util.inspect.custom")](t,n,a){return a(AP(this),n)}[Symbol.for("Deno.customInspect")](t,n){return t(AP(this),n)}}function fie(e){const t=globalThis.DOMException;return typeof t=="function"?new t(e,"SyntaxError"):new SyntaxError(e)}function rE(e){return e instanceof Error?"errors"in e&&Array.isArray(e.errors)?e.errors.map(rE).join(", "):"cause"in e&&e.cause instanceof Error?`${e}: ${rE(e.cause)}`:e.message:`${e}`}function AP(e){return{type:e.type,message:e.message,code:e.code,defaultPrevented:e.defaultPrevented,cancelable:e.cancelable,timeStamp:e.timeStamp}}var OH=e=>{throw TypeError(e)},KT=(e,t,n)=>t.has(e)||OH("Cannot "+n),Bt=(e,t,n)=>(KT(e,t,"read from private field"),n?n.call(e):t.get(e)),ur=(e,t,n)=>t.has(e)?OH("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),$n=(e,t,n,a)=>(KT(e,t,"write to private field"),t.set(e,n),n),wo=(e,t,n)=>(KT(e,t,"access private method"),n),ha,xl,Wc,lb,Yb,qf,nu,Xf,Ts,Kc,pu,Zc,Uf,ci,aE,iE,oE,IP,sE,lE,zf,cE,uE;class cb extends EventTarget{constructor(t,n){var a,r;super(),ur(this,ci),this.CONNECTING=0,this.OPEN=1,this.CLOSED=2,ur(this,ha),ur(this,xl),ur(this,Wc),ur(this,lb),ur(this,Yb),ur(this,qf),ur(this,nu),ur(this,Xf,null),ur(this,Ts),ur(this,Kc),ur(this,pu,null),ur(this,Zc,null),ur(this,Uf,null),ur(this,iE,async i=>{var s;Bt(this,Kc).reset();const{body:c,redirected:u,status:d,headers:m}=i;if(d===204){wo(this,ci,zf).call(this,"Server sent HTTP 204, not reconnecting",204),this.close();return}if(u?$n(this,Wc,new URL(i.url)):$n(this,Wc,void 0),d!==200){wo(this,ci,zf).call(this,`Non-200 status code (${d})`,d);return}if(!(m.get("content-type")||"").startsWith("text/event-stream")){wo(this,ci,zf).call(this,'Invalid content type, expected "text/event-stream"',d);return}if(Bt(this,ha)===this.CLOSED)return;$n(this,ha,this.OPEN);const h=new Event("open");if((s=Bt(this,Uf))==null||s.call(this,h),this.dispatchEvent(h),typeof c!="object"||!c||!("getReader"in c)){wo(this,ci,zf).call(this,"Invalid response body, expected a web ReadableStream",d),this.close();return}const g=new TextDecoder,v=c.getReader();let w=!0;do{const{done:S,value:y}=await v.read();y&&Bt(this,Kc).feed(g.decode(y,{stream:!S})),S&&(w=!1,Bt(this,Kc).reset(),wo(this,ci,cE).call(this))}while(w)}),ur(this,oE,i=>{$n(this,Ts,void 0),!(i.name==="AbortError"||i.type==="aborted")&&wo(this,ci,cE).call(this,rE(i))}),ur(this,sE,i=>{typeof i.id=="string"&&$n(this,Xf,i.id);const s=new MessageEvent(i.event||"message",{data:i.data,origin:Bt(this,Wc)?Bt(this,Wc).origin:Bt(this,xl).origin,lastEventId:i.id||""});Bt(this,Zc)&&(!i.event||i.event==="message")&&Bt(this,Zc).call(this,s),this.dispatchEvent(s)}),ur(this,lE,i=>{$n(this,qf,i)}),ur(this,uE,()=>{$n(this,nu,void 0),Bt(this,ha)===this.CONNECTING&&wo(this,ci,aE).call(this)});try{if(t instanceof URL)$n(this,xl,t);else if(typeof t=="string")$n(this,xl,new URL(t,pie()));else throw new Error("Invalid URL")}catch{throw fie("An invalid or illegal string was specified")}$n(this,Kc,IH({onEvent:Bt(this,sE),onRetry:Bt(this,lE)})),$n(this,ha,this.CONNECTING),$n(this,qf,3e3),$n(this,Yb,(a=n?.fetch)!=null?a:globalThis.fetch),$n(this,lb,(r=n?.withCredentials)!=null?r:!1),wo(this,ci,aE).call(this)}get readyState(){return Bt(this,ha)}get url(){return Bt(this,xl).href}get withCredentials(){return Bt(this,lb)}get onerror(){return Bt(this,pu)}set onerror(t){$n(this,pu,t)}get onmessage(){return Bt(this,Zc)}set onmessage(t){$n(this,Zc,t)}get onopen(){return Bt(this,Uf)}set onopen(t){$n(this,Uf,t)}addEventListener(t,n,a){const r=n;super.addEventListener(t,r,a)}removeEventListener(t,n,a){const r=n;super.removeEventListener(t,r,a)}close(){Bt(this,nu)&&clearTimeout(Bt(this,nu)),Bt(this,ha)!==this.CLOSED&&(Bt(this,Ts)&&Bt(this,Ts).abort(),$n(this,ha,this.CLOSED),$n(this,Ts,void 0))}}ha=new WeakMap,xl=new WeakMap,Wc=new WeakMap,lb=new WeakMap,Yb=new WeakMap,qf=new WeakMap,nu=new WeakMap,Xf=new WeakMap,Ts=new WeakMap,Kc=new WeakMap,pu=new WeakMap,Zc=new WeakMap,Uf=new WeakMap,ci=new WeakSet,aE=function(){$n(this,ha,this.CONNECTING),$n(this,Ts,new AbortController),Bt(this,Yb)(Bt(this,xl),wo(this,ci,IP).call(this)).then(Bt(this,iE)).catch(Bt(this,oE))},iE=new WeakMap,oE=new WeakMap,IP=function(){var e;const t={mode:"cors",redirect:"follow",headers:{Accept:"text/event-stream",...Bt(this,Xf)?{"Last-Event-ID":Bt(this,Xf)}:void 0},cache:"no-store",signal:(e=Bt(this,Ts))==null?void 0:e.signal};return"window"in globalThis&&(t.credentials=this.withCredentials?"include":"same-origin"),t},sE=new WeakMap,lE=new WeakMap,zf=function(e,t){var n;Bt(this,ha)!==this.CLOSED&&$n(this,ha,this.CLOSED);const a=new RP("error",{code:t,message:e});(n=Bt(this,pu))==null||n.call(this,a),this.dispatchEvent(a)},cE=function(e,t){var n;if(Bt(this,ha)===this.CLOSED)return;$n(this,ha,this.CONNECTING);const a=new RP("error",{code:t,message:e});(n=Bt(this,pu))==null||n.call(this,a),this.dispatchEvent(a),$n(this,nu,setTimeout(Bt(this,uE),Bt(this,qf)))},uE=new WeakMap,cb.CONNECTING=0,cb.OPEN=1,cb.CLOSED=2;function pie(){const e="document"in globalThis?globalThis.document:void 0;return e&&typeof e=="object"&&"baseURI"in e&&typeof e.baseURI=="string"?e.baseURI:void 0}class mie extends Error{constructor(t,n,a){super(`SSE error: ${n}`),this.code=t,this.event=a}}class hie{constructor(t,n){this._url=t,this._resourceMetadataUrl=void 0,this._scope=void 0,this._eventSourceInit=n?.eventSourceInit,this._requestInit=n?.requestInit,this._authProvider=n?.authProvider,this._fetch=n?.fetch,this._fetchWithInit=bH(n?.fetch,n?.requestInit)}async _authThenStart(){var t;if(!this._authProvider)throw new Ya("No auth provider");let n;try{n=await ko(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(a){throw(t=this.onerror)===null||t===void 0||t.call(this,a),a}if(n!=="AUTHORIZED")throw new Ya;return await this._startOrAuth()}async _commonHeaders(){var t;const n={};if(this._authProvider){const r=await this._authProvider.tokens();r&&(n.Authorization=`Bearer ${r.access_token}`)}this._protocolVersion&&(n["mcp-protocol-version"]=this._protocolVersion);const a=Vb((t=this._requestInit)===null||t===void 0?void 0:t.headers);return new Headers({...n,...a})}_startOrAuth(){var t,n,a;const r=(a=(n=(t=this===null||this===void 0?void 0:this._eventSourceInit)===null||t===void 0?void 0:t.fetch)!==null&&n!==void 0?n:this._fetch)!==null&&a!==void 0?a:fetch;return new Promise((i,s)=>{this._eventSource=new cb(this._url.href,{...this._eventSourceInit,fetch:async(c,u)=>{const d=await this._commonHeaders();d.set("Accept","text/event-stream");const m=await r(c,{...u,headers:d});if(m.status===401&&m.headers.has("www-authenticate")){const{resourceMetadataUrl:h,scope:g}=yp(m);this._resourceMetadataUrl=h,this._scope=g}return m}}),this._abortController=new AbortController,this._eventSource.onerror=c=>{var u;if(c.code===401&&this._authProvider){this._authThenStart().then(i,s);return}const d=new mie(c.code,c.message,c);s(d),(u=this.onerror)===null||u===void 0||u.call(this,d)},this._eventSource.onopen=()=>{},this._eventSource.addEventListener("endpoint",c=>{var u;const d=c;try{if(this._endpoint=new URL(d.data,this._url),this._endpoint.origin!==this._url.origin)throw new Error(`Endpoint origin does not match connection origin: ${this._endpoint.origin}`)}catch(m){s(m),(u=this.onerror)===null||u===void 0||u.call(this,m),this.close();return}i()}),this._eventSource.onmessage=c=>{var u,d;const m=c;let h;try{h=ob.parse(JSON.parse(m.data))}catch(g){(u=this.onerror)===null||u===void 0||u.call(this,g);return}(d=this.onmessage)===null||d===void 0||d.call(this,h)}})}async start(){if(this._eventSource)throw new Error("SSEClientTransport already started! If using Client class, note that connect() calls start() automatically.");return await this._startOrAuth()}async finishAuth(t){if(!this._authProvider)throw new Ya("No auth provider");if(await ko(this._authProvider,{serverUrl:this._url,authorizationCode:t,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new Ya("Failed to authorize")}async close(){var t,n,a;(t=this._abortController)===null||t===void 0||t.abort(),(n=this._eventSource)===null||n===void 0||n.close(),(a=this.onclose)===null||a===void 0||a.call(this)}async send(t){var n,a,r,i;if(!this._endpoint)throw new Error("Not connected");try{const s=await this._commonHeaders();s.set("content-type","application/json");const c={...this._requestInit,method:"POST",headers:s,body:JSON.stringify(t),signal:(n=this._abortController)===null||n===void 0?void 0:n.signal},u=await((a=this._fetch)!==null&&a!==void 0?a:fetch)(this._endpoint,c);if(!u.ok){const d=await u.text().catch(()=>null);if(u.status===401&&this._authProvider){const{resourceMetadataUrl:m,scope:h}=yp(u);if(this._resourceMetadataUrl=m,this._scope=h,await ko(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new Ya;return this.send(t)}throw new Error(`Error POSTing to endpoint (HTTP ${u.status}): ${d}`)}await((r=u.body)===null||r===void 0?void 0:r.cancel())}catch(s){throw(i=this.onerror)===null||i===void 0||i.call(this,s),s}}setProtocolVersion(t){this._protocolVersion=t}}var Mu,gie=(Mu=class{connector;autoConnect;constructor(t,n=!0){this.connector=t,this.autoConnect=n}async connect(){await this.connector.connect()}async disconnect(){await this.connector.disconnect()}async initialize(){!this.isConnected&&this.autoConnect&&await this.connect(),await this.connector.initialize()}get isConnected(){return this.connector&&this.connector.isClientConnected}on(t,n){t==="notification"&&this.connector.onNotification(n)}async setRoots(t){return this.connector.setRoots(t)}getRoots(){return this.connector.getRoots()}get tools(){return this.connector.tools}async listTools(t){return this.connector.listTools(t)}get serverCapabilities(){return this.connector.serverCapabilities}get serverInfo(){return this.connector.serverInfo}async callTool(t,n={},a){return this.connector.callTool(t,n,a)}async listResources(t,n){return this.connector.listResources(t,n)}async listAllResources(t){return this.connector.listAllResources(t)}async listResourceTemplates(t){return this.connector.listResourceTemplates(t)}async readResource(t,n){return this.connector.readResource(t,n)}async subscribeToResource(t,n){return this.connector.subscribeToResource(t,n)}async unsubscribeFromResource(t,n){return this.connector.unsubscribeFromResource(t,n)}async listPrompts(){return this.connector.listPrompts()}async getPrompt(t,n){return this.connector.getPrompt(t,n)}async request(t,n=null,a){return this.connector.request(t,n,a)}},ze(Mu,"MCPSession"),Mu),Pu,bie=(Pu=class{_readyPromise;_readyResolver;_donePromise;_doneResolver;_exception=null;_connection=null;_task=null;_abortController=null;constructor(){this.reset()}async start(){if(this.reset(),ke.debug(`Starting ${this.constructor.name}`),this._task=this.connectionTask(),await this._readyPromise,this._exception)throw this._exception;if(this._connection===null)throw new Error("Connection was not established");return this._connection}async stop(){if(this._task&&this._abortController){ke.debug(`Cancelling ${this.constructor.name} task`),this._abortController.abort();try{await this._task}catch(t){t instanceof Error&&t.name==="AbortError"?ke.debug(`${this.constructor.name} task aborted successfully`):ke.warn(`Error stopping ${this.constructor.name} task: ${t}`)}}await this._donePromise,ke.debug(`${this.constructor.name} task completed`)}reset(){this._readyPromise=new Promise(t=>this._readyResolver=t),this._donePromise=new Promise(t=>this._doneResolver=t),this._exception=null,this._connection=null,this._task=null,this._abortController=new AbortController}async connectionTask(){ke.debug(`Running ${this.constructor.name} task`);try{this._connection=await this.establishConnection(),ke.debug(`${this.constructor.name} connected successfully`),this._readyResolver(),await this.waitForAbort()}catch(t){this._exception=t,ke.error(`Error in ${this.constructor.name} task: ${t}`),this._readyResolver()}finally{if(this._connection!==null){try{await this.closeConnection(this._connection)}catch(t){ke.warn(`Error closing connection in ${this.constructor.name}: ${t}`)}this._connection=null}this._doneResolver()}}async waitForAbort(){return new Promise((t,n)=>{if(!this._abortController)return;const a=this._abortController.signal;if(a.aborted){t();return}const r=ze(()=>{a.removeEventListener("abort",r),t()},"onAbort");a.addEventListener("abort",r)})}},ze(Pu,"ConnectionManager"),Pu),Uu,vie=(Uu=class extends bie{url;opts;_transport=null;constructor(t,n){super(),this.url=typeof t=="string"?new URL(t):t,this.opts=n}async establishConnection(){return this._transport=new hie(this.url,this.opts),ke.debug(`${this.constructor.name} connected successfully`),this._transport}async closeConnection(t){if(this._transport)try{await this._transport.close()}catch(n){ke.warn(`Error closing SSE transport: ${n}`)}finally{this._transport=null}}},ze(Uu,"SseConnectionManager"),Uu),zu,yie=(zu=class extends bre{baseUrl;headers;timeout;sseReadTimeout;clientInfo;preferSse;transportType=null;streamableTransport=null;constructor(t,n={}){super(n),this.baseUrl=t.replace(/\/$/,""),this.headers={...n.headers??{}},n.authToken&&(this.headers.Authorization=`Bearer ${n.authToken}`),this.timeout=n.timeout??3e4,this.sseReadTimeout=n.sseReadTimeout??3e5,this.clientInfo=n.clientInfo??{name:"http-connector",version:"1.0.0"},this.preferSse=n.preferSse??!1}async connect(){if(this.connected){ke.debug("Already connected to MCP implementation");return}const t=this.baseUrl;if(this.preferSse){ke.debug(`Connecting to MCP implementation via HTTP/SSE: ${t}`),await this.connectWithSse(t);return}ke.debug(`Connecting to MCP implementation via HTTP: ${t}`);try{ke.info("🔄 Attempting streamable HTTP transport..."),await this.connectWithStreamableHttp(t),ke.info("✅ Successfully connected via streamable HTTP")}catch(n){let a="Unknown error",r=!1;if(n instanceof yl){const i=n;r=i.code===401,i.code===400&&i.message.includes("Missing session ID")?(a="Server requires session ID (FastMCP compatibility) - using SSE transport",ke.warn(`⚠️ ${a}`)):i.code===404||i.code===405?(a=`Server returned ${i.code} - server likely doesn't support streamable HTTP`,ke.debug(a)):(a=`Server returned ${i.code}: ${i.message}`,ke.debug(a))}else if(n instanceof Error){const i=n.toString(),s=n.message||"";r=i.includes("401")||s.includes("Unauthorized"),i.includes("Missing session ID")||i.includes("Bad Request: Missing session ID")||s.includes("FastMCP session ID error")?(a="Server requires session ID (FastMCP compatibility) - using SSE transport",ke.warn(`⚠️ ${a}`)):i.includes("405 Method Not Allowed")||i.includes("404 Not Found")?(a="Server doesn't support streamable HTTP (405/404)",ke.debug(a)):(a=`Streamable HTTP failed: ${n.message}`,ke.debug(a))}if(r){ke.info("Authentication required - skipping SSE fallback"),await this.cleanupResources();const i=new Error("Authentication required");throw i.code=401,i}ke.info("🔄 Falling back to SSE transport...");try{await this.connectWithSse(t)}catch(i){if(ke.error("Failed to connect with both transports:"),ke.error(` Streamable HTTP: ${a}`),ke.error(` SSE: ${i}`),await this.cleanupResources(),i?.message?.includes("401")||i?.message?.includes("Unauthorized")){const c=new Error("Authentication required");throw c.code=401,c}throw new Error("Could not connect to server with any available transport")}}}async connectWithStreamableHttp(t){try{const n=new die(new URL(t),{authProvider:this.opts.authProvider,requestInit:{headers:this.headers},reconnectionOptions:{maxReconnectionDelay:3e4,initialReconnectionDelay:1e3,reconnectionDelayGrowFactor:1.5,maxRetries:2}});let a=n;if(this.opts.wrapTransport){const i=this.baseUrl;a=this.opts.wrapTransport(a,i)}const r={...this.opts.clientOptions||{},capabilities:{...this.opts.clientOptions?.capabilities||{},roots:{listChanged:!0},...this.opts.samplingCallback?{sampling:{}}:{},...this.opts.elicitationCallback?{elicitation:{form:{},url:{}}}:{}}};ke.debug("Creating Client with capabilities:",JSON.stringify(r.capabilities,null,2)),this.client=new _P(this.clientInfo,r),this.setupRootsHandler(),ke.debug("Roots handler registered before connect");try{await this.client.connect(a,{timeout:Math.min(this.timeout,3e3)});const i=n.sessionId;i?ke.debug(`Session ID obtained: ${i}`):ke.warn("Session ID not available after connect - this may cause issues with SSE stream")}catch(i){if(i instanceof Error){const s=i.message||i.toString();if(s.includes("Missing session ID")||s.includes("Bad Request: Missing session ID")||s.includes("Mcp-Session-Id header is required")){const c=new Error(`Session ID error: ${s}. The SDK should automatically extract session ID from initialize response.`);throw c.cause=i,c}}throw i}this.streamableTransport=n,this.connectionManager={stop:ze(async()=>{if(this.streamableTransport)try{await this.streamableTransport.terminateSession(),await this.streamableTransport.close()}catch(i){ke.warn(`Error closing Streamable HTTP transport: ${i}`)}finally{this.streamableTransport=null}},"stop")},this.connected=!0,this.transportType="streamable-http",this.setupNotificationHandler(),this.setupSamplingHandler(),this.setupElicitationHandler(),ke.debug(`Successfully connected to MCP implementation via streamable HTTP: ${t}`),this.trackConnectorInit({serverUrl:this.baseUrl,publicIdentifier:`${this.baseUrl} (streamable-http)`})}catch(n){throw await this.cleanupResources(),n}}async connectWithSse(t){try{this.connectionManager=new vie(t,{authProvider:this.opts.authProvider,requestInit:{headers:this.headers}});let n=await this.connectionManager.start();if(this.opts.wrapTransport){const r=this.baseUrl;n=this.opts.wrapTransport(n,r)}const a={...this.opts.clientOptions||{},capabilities:{...this.opts.clientOptions?.capabilities||{},roots:{listChanged:!0},...this.opts.samplingCallback?{sampling:{}}:{},...this.opts.elicitationCallback?{elicitation:{form:{},url:{}}}:{}}};ke.debug("Creating Client with capabilities (SSE):",JSON.stringify(a.capabilities,null,2)),this.client=new _P(this.clientInfo,a),this.setupRootsHandler(),ke.debug("Roots handler registered before connect (SSE)"),await this.client.connect(n),this.connected=!0,this.transportType="sse",this.setupNotificationHandler(),this.setupSamplingHandler(),this.setupElicitationHandler(),ke.debug(`Successfully connected to MCP implementation via HTTP/SSE: ${t}`),this.trackConnectorInit({serverUrl:this.baseUrl,publicIdentifier:`${this.baseUrl} (sse)`})}catch(n){throw await this.cleanupResources(),n}}get publicIdentifier(){return{type:"http",url:this.baseUrl,transport:this.transportType||"unknown"}}getTransportType(){return this.transportType}},ze(zu,"HttpConnector"),zu),Fu,wie=(Fu=class{config={};sessions={};activeSessions=[];constructor(t){t&&(this.config=t)}static fromDict(t){throw new Error("fromDict must be implemented by concrete class")}addServer(t,n){this.config.mcpServers=this.config.mcpServers||{},this.config.mcpServers[t]=n,Mi.getInstance().trackClientAddServer(t,n)}removeServer(t){this.config.mcpServers?.[t]&&(delete this.config.mcpServers[t],this.activeSessions=this.activeSessions.filter(n=>n!==t),Mi.getInstance().trackClientRemoveServer(t))}getServerNames(){return Object.keys(this.config.mcpServers??{})}getServerConfig(t){return this.config.mcpServers?.[t]}getConfig(){return this.config??{}}async createSession(t,n=!0){const a=this.config.mcpServers??{};if(Object.keys(a).length===0&&ke.warn("No MCP servers defined in config"),!a[t])throw new Error(`Server '${t}' not found in config`);const r=this.createConnectorFromConfig(a[t]),i=new gie(r);return n&&await i.initialize(),this.sessions[t]=i,this.activeSessions.includes(t)||this.activeSessions.push(t),i}async createAllSessions(t=!0){const n=this.config.mcpServers??{};Object.keys(n).length===0&&ke.warn("No MCP servers defined in config");for(const a of Object.keys(n))await this.createSession(a,t);return this.sessions}getSession(t){const n=this.sessions[t];return n||null}requireSession(t){const n=this.sessions[t];if(!n)throw new Error(`Session '${t}' not found. Available sessions: ${this.activeSessions.join(", ")||"none"}`);return n}getAllActiveSessions(){return Object.fromEntries(this.activeSessions.map(t=>[t,this.sessions[t]]))}async closeSession(t){const n=this.sessions[t];if(!n){ke.warn(`No session exists for server ${t}, nothing to close`);return}try{ke.debug(`Closing session for server ${t}`),await n.disconnect()}catch(a){ke.error(`Error closing session for server '${t}': ${a}`)}finally{delete this.sessions[t],this.activeSessions=this.activeSessions.filter(a=>a!==t)}}async closeAllSessions(){const t=Object.keys(this.sessions),n=[];for(const a of t)try{ke.debug(`Closing session for server ${a}`),await this.closeSession(a)}catch(r){const i=`Failed to close session for server '${a}': ${r}`;ke.error(i),n.push(i)}n.length?ke.error(`Encountered ${n.length} errors while closing sessions`):ke.debug("All sessions closed successfully")}},ze(Fu,"BaseMCPClient"),Fu),Dl,xie=(Dl=class extends wie{static getPackageVersion(){return Ab()}constructor(t){super(t),this._trackClientInit()}_trackClientInit(){const t=Object.keys(this.config.mcpServers??{});Mi.getInstance().trackMCPClientInit({codeMode:!1,sandbox:!1,allCallbacks:!1,verify:!1,servers:t,numServers:t.length,isBrowser:!0}).catch(n=>ke.debug(`Failed to track BrowserMCPClient init: ${n}`))}static fromDict(t){return new Dl(t)}createConnectorFromConfig(t){const{url:n,headers:a,authToken:r,authProvider:i,wrapTransport:s,clientOptions:c,samplingCallback:u,elicitationCallback:d}=t;if(!n)throw new Error("Server URL is required");const m={headers:a,authToken:r,authProvider:i,wrapTransport:s,clientOptions:c,samplingCallback:u,elicitationCallback:d};return c?console.log("[BrowserMCPClient] Passing clientOptions to connector:",JSON.stringify(c,null,2)):console.warn("[BrowserMCPClient] No clientOptions provided to connector!"),new yie(n,m)}},ze(Dl,"BrowserMCPClient"),Dl);function ru(e){const t=ze(()=>{throw new Error(`Invalid url to pass to open(): ${e}`)},"abort");let n;try{n=new URL(e)}catch{t()}return n.protocol!=="https:"&&n.protocol!=="http:"&&t(),n.hostname!==encodeURIComponent(n.hostname)&&t(),n.username&&(n.username=encodeURIComponent(n.username)),n.password&&(n.password=encodeURIComponent(n.password)),n.pathname=n.pathname.slice(0,1)+encodeURIComponent(n.pathname.slice(1)).replace(/%2f/gi,"/"),n.search=n.search.slice(0,1)+Array.from(n.searchParams.entries()).map(DH).join("&"),n.hash=n.hash.slice(0,1)+encodeURIComponent(n.hash.slice(1)),n.href}ze(ru,"sanitizeUrl");function DH([e,t]){return`${encodeURIComponent(e)}${t.length>0?`=${encodeURIComponent(t)}`:""}`}ze(DH,"sanitizeParam");var Bu,ub=(Bu=class{serverUrl;storageKeyPrefix;serverUrlHash;clientName;clientUri;callbackUrl;preventAutoAuth;useRedirectFlow;onPopupWindow;constructor(t,n={}){this.serverUrl=t,this.storageKeyPrefix=n.storageKeyPrefix||"mcp:auth",this.serverUrlHash=this.hashString(t),this.clientName=n.clientName||"mcp-use",this.clientUri=n.clientUri||(typeof window<"u"?window.location.origin:""),this.callbackUrl=ru(n.callbackUrl||(typeof window<"u"?new URL("/oauth/callback",window.location.origin).toString():"/oauth/callback")),this.preventAutoAuth=n.preventAutoAuth,this.useRedirectFlow=n.useRedirectFlow,this.onPopupWindow=n.onPopupWindow}get redirectUrl(){return ru(this.callbackUrl)}get clientMetadata(){return{redirect_uris:[this.redirectUrl],token_endpoint_auth_method:"none",grant_types:["authorization_code","refresh_token"],response_types:["code"],client_name:this.clientName,client_uri:this.clientUri}}async clientInformation(){const t=this.getKey("client_info"),n=localStorage.getItem(t);if(n)try{return JSON.parse(n)}catch(a){console.warn(`[${this.storageKeyPrefix}] Failed to parse client information:`,a),localStorage.removeItem(t);return}}async saveClientInformation(t){const n=this.getKey("client_info");localStorage.setItem(n,JSON.stringify(t))}async tokens(){const t=this.getKey("tokens"),n=localStorage.getItem(t);if(n)try{return JSON.parse(n)}catch(a){console.warn(`[${this.storageKeyPrefix}] Failed to parse tokens:`,a),localStorage.removeItem(t);return}}async saveTokens(t){const n=this.getKey("tokens");localStorage.setItem(n,JSON.stringify(t)),localStorage.removeItem(this.getKey("code_verifier")),localStorage.removeItem(this.getKey("last_auth_url"))}async saveCodeVerifier(t){const n=this.getKey("code_verifier");localStorage.setItem(n,t)}async codeVerifier(){const t=this.getKey("code_verifier"),n=localStorage.getItem(t);if(!n)throw new Error(`[${this.storageKeyPrefix}] Code verifier not found in storage for key ${t}. Auth flow likely corrupted or timed out.`);return n}async prepareAuthorizationUrl(t){const n=globalThis.crypto.randomUUID(),a=`${this.storageKeyPrefix}:state_${n}`,r={serverUrlHash:this.serverUrlHash,expiry:Date.now()+1e3*60*10,providerOptions:{serverUrl:this.serverUrl,storageKeyPrefix:this.storageKeyPrefix,clientName:this.clientName,clientUri:this.clientUri,callbackUrl:this.callbackUrl},flowType:this.useRedirectFlow?"redirect":"popup",returnUrl:this.useRedirectFlow&&typeof window<"u"?window.location.href:void 0};localStorage.setItem(a,JSON.stringify(r)),t.searchParams.set("state",n);const i=t.toString(),s=ru(i);return localStorage.setItem(this.getKey("last_auth_url"),s),s}async redirectToAuthorization(t){const n=await this.prepareAuthorizationUrl(t);if(this.preventAutoAuth){console.info(`[${this.storageKeyPrefix}] Auto-auth prevented. Authorization URL stored for manual trigger.`);return}if(this.useRedirectFlow){console.info(`[${this.storageKeyPrefix}] Redirecting to authorization URL (full-page redirect).`),window.location.href=n;return}const a="width=600,height=700,resizable=yes,scrollbars=yes,status=yes";try{const r=window.open(n,`mcp_auth_${this.serverUrlHash}`,a);this.onPopupWindow&&this.onPopupWindow(n,a,r),!r||r.closed||typeof r.closed>"u"?console.warn(`[${this.storageKeyPrefix}] Popup likely blocked by browser. Manual navigation might be required using the stored URL.`):(r.focus(),console.info(`[${this.storageKeyPrefix}] Redirecting to authorization URL in popup.`))}catch(r){console.error(`[${this.storageKeyPrefix}] Error opening popup window:`,r)}}getLastAttemptedAuthUrl(){const t=localStorage.getItem(this.getKey("last_auth_url"));return t?ru(t):null}clearStorage(){const t=`${this.storageKeyPrefix}_${this.serverUrlHash}_`,n=`${this.storageKeyPrefix}:state_`,a=[];let r=0;for(let s=0;s<localStorage.length;s++){const c=localStorage.key(s);if(c){if(c.startsWith(t))a.push(c);else if(c.startsWith(n))try{const u=localStorage.getItem(c);u&&JSON.parse(u).serverUrlHash===this.serverUrlHash&&a.push(c)}catch(u){console.warn(`[${this.storageKeyPrefix}] Error parsing state key ${c} during clearStorage:`,u)}}}return[...new Set(a)].forEach(s=>{localStorage.removeItem(s),r++}),r}hashString(t){let n=0;for(let a=0;a<t.length;a++){const r=t.charCodeAt(a);n=(n<<5)-n+r,n=n&n}return Math.abs(n).toString(16)}getKey(t){return`${this.storageKeyPrefix}_${this.serverUrlHash}_${t}`}},ze(Bu,"BrowserOAuthClientProvider"),Bu);async function ZT(){const e=new URLSearchParams(window.location.search),t=e.get("code"),n=e.get("state"),a=e.get("error"),r=e.get("error_description"),i="[mcp-callback]";console.log(`${i} Handling callback...`,{code:t,state:n,error:a,errorDescription:r});let s=null,c=null;const u=n?`mcp:auth:state_${n}`:null;try{if(a)throw new Error(`OAuth error: ${a} - ${r||"No description provided."}`);if(!t)throw new Error("Authorization code not found in callback query parameters.");if(!n||!u)throw new Error("State parameter not found or invalid in callback query parameters.");const d=localStorage.getItem(u);if(!d)throw new Error(`Invalid or expired state parameter "${n}". No matching state found in storage.`);try{c=JSON.parse(d)}catch{throw new Error("Failed to parse stored OAuth state.")}if(!c.expiry||c.expiry<Date.now())throw localStorage.removeItem(u),new Error("OAuth state has expired. Please try initiating authentication again.");if(!c.providerOptions)throw new Error("Stored state is missing required provider options.");const{serverUrl:m,...h}=c.providerOptions;console.log(`${i} Re-instantiating provider for server: ${m}`),s=new ub(m,h),console.log(`${i} Calling SDK auth() to exchange code...`);const g=new URL(m).origin,v=await ko(s,{serverUrl:g,authorizationCode:t});if(v==="AUTHORIZED")if(console.log(`${i} Authorization successful via SDK auth().`),c.flowType==="redirect"&&c.returnUrl)console.log(`${i} Redirect flow complete. Returning to: ${c.returnUrl}`),localStorage.removeItem(u),window.location.href=c.returnUrl;else if(window.opener&&!window.opener.closed)console.log(`${i} Popup flow complete. Notifying opener...`),window.opener.postMessage({type:"mcp_auth_callback",success:!0},window.location.origin),localStorage.removeItem(u),window.close();else{console.warn(`${i} No opener window or return URL detected. Redirecting to root.`),localStorage.removeItem(u);const S=window.location.pathname.split("/").filter(Boolean),y=S.length>0&&S[S.length-1]==="callback"?"/"+S.slice(0,-2).join("/"):"/";window.location.href=y||"/"}else throw console.warn(`${i} SDK auth() returned unexpected status: ${v}`),new Error(`Unexpected result from authentication library: ${v}`)}catch(d){console.error(`${i} Error during OAuth callback handling:`,d);const m=d instanceof Error?d.message:String(d);window.opener&&!window.opener.closed&&window.opener.postMessage({type:"mcp_auth_callback",success:!1,error:m},window.location.origin);try{document.body.innerHTML="";const h=document.createElement("div");h.style.fontFamily="sans-serif",h.style.padding="20px";const g=document.createElement("h1");g.textContent="Authentication Error",h.appendChild(g);const v=document.createElement("p");v.style.color="red",v.style.backgroundColor="#ffebeb",v.style.border="1px solid red",v.style.padding="10px",v.style.borderRadius="4px",v.textContent=m,h.appendChild(v);const w=document.createElement("p");w.textContent="You can close this window or ";const S=document.createElement("a");if(S.href="#",S.textContent="click here to close",S.onclick=y=>(y.preventDefault(),window.close(),!1),w.appendChild(S),w.appendChild(document.createTextNode(".")),h.appendChild(w),d instanceof Error&&d.stack){const y=document.createElement("pre");y.style.fontSize="0.8em",y.style.color="#555",y.style.marginTop="20px",y.style.whiteSpace="pre-wrap",y.textContent=d.stack,h.appendChild(y)}document.body.appendChild(h)}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")))}}ze(ZT,"onMcpAuthorization");var Dx={exports:{}},gt={};var OP;function Sie(){if(OP)return gt;OP=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),a=Symbol.for("react.strict_mode"),r=Symbol.for("react.profiler"),i=Symbol.for("react.consumer"),s=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),d=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),h=Symbol.for("react.activity"),g=Symbol.iterator;function v(j){return j===null||typeof j!="object"?null:(j=g&&j[g]||j["@@iterator"],typeof j=="function"?j:null)}var w={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},S=Object.assign,y={};function _(j,V,z){this.props=j,this.context=V,this.refs=y,this.updater=z||w}_.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||w}var C=k.prototype=new E;C.constructor=k,S(C,_.prototype),C.isPureReactComponent=!0;var R=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 te(j,V){return typeof j=="object"&&j!==null&&j.key!=null?K(""+j.key):V.toString(36)}function ae(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===""?"."+te(j,0):L,R($)?(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(R(j))for(var ie=0;ie<j.length;ie++)L=j[ie],F=X+te(L,ie),W+=B(L,V,z,F,$);else if(ie=v(j),typeof ie=="function")for(j=ie.call(j),ie=0;!(L=j.next()).done;)L=L.value,F=X+te(L,ie++),W+=B(L,V,z,F,$);else if(F==="object"){if(typeof j.then=="function")return B(ae(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=S({},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),ie=0;ie<W;ie++)X[ie]=arguments[ie+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 DP;function YT(){return DP||(DP=1,Dx.exports=Sie()),Dx.exports}var x=YT();const ue=$v(x),ud=Uq({__proto__:null,default:ue},[x]);function dE(e,t){if(!e)throw new Error(t)}ze(dE,"assert");var Eie=3e3,_ie=5e3;function qT(e){const{url:t,enabled:n=!0,clientName:a,clientUri:r,callbackUrl:i=typeof window<"u"?ru(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=Eie,transportType:g="auto",preventAutoAuth:v=!1,useRedirectFlow:w=!1,onPopupWindow:S,timeout:y=3e4,sseReadTimeout:_=3e5,wrapTransport:E,onNotification:k,samplingCallback:C,onElicitation:R}=e,[I,A]=x.useState("discovering"),[O,M]=x.useState([]),[U,H]=x.useState([]),[K,ee]=x.useState([]),[te,ae]=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),ie=x.useRef(!0),le=x.useRef(0),J=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((je,Fe,...pt)=>{const Qe=pt.length>0?`${Fe} ${pt.map(Tt=>JSON.stringify(Tt)).join(" ")}`:Fe;console[je](`[useMcp] ${Qe}`),ie.current&&z(Tt=>[...Tt.slice(-100),{level:je,message:Qe,timestamp:Date.now()}])},[]),Te=x.useCallback(async(je=!1)=>{if(je||ce("info","Disconnecting..."),X.current=!1,J.current&&clearTimeout(J.current),J.current=null,F.current)try{await F.current.closeSession("inspector-server")}catch(Fe){je||ce("warn","Error closing session:",Fe)}F.current=null,ie.current&&!je&&(A("discovering"),M([]),H([]),ee([]),ae([]),j(void 0),$(void 0))},[ce]),He=x.useCallback((je,Fe)=>{if(ce("error",je,Fe??""),ie.current){A("failed"),j(je);const pt=W.current?.getLastAttemptedAuthUrl();pt&&($(pt),ce("info","Manual authentication URL may be available.",pt))}X.current=!1,t&&Mi.getInstance().trackUseMcpConnection({url:t,transportType:g,success:!1,errorType:Fe?.name||"UnknownError",hasOAuth:!!W.current,hasSampling:!!C,hasElicitation:!!R}).catch(()=>{})},[ce,t,g,C,R]),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(!ie.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 ub(t,{storageKeyPrefix:s,clientName:a,clientUri:r,callbackUrl:i,preventAutoAuth:v,useRedirectFlow:w,onPopupWindow:S}),ce("debug","BrowserOAuthClientProvider initialized in connect.")),F.current||(F.current=new xie,ce("debug","BrowserMCPClient initialized in connect."));const je=ze(async(pt,Qe=!1)=>{ce("info",`Attempting connection with transport: ${pt}`);try{const Tt="inspector-server",nt={url:t,transport:pt==="sse"?"http":pt};if(u&&Object.keys(u).length>0&&(nt.headers=u),W.current){const wt=await W.current.tokens();wt?.access_token&&(nt.headers={...nt.headers,Authorization:`Bearer ${wt.access_token}`})}F.current.addServer(Tt,{...nt,authProvider:W.current,clientOptions:c,samplingCallback:C,elicitationCallback:R,wrapTransport:E?wt=>(console.log("[useMcp] Applying transport wrapper for server:",Tt,"url:",t),E(wt,t)):void 0});const Ie=await F.current.createSession(Tt,!1);k&&Ie.on("notification",k),await Ie.initialize(),ce("info","✅ Successfully connected to MCP server"),ce("info","Server info:",Ie.connector.serverInfo),ce("info","Server capabilities:",Ie.connector.serverCapabilities),console.log("[useMcp] Server info:",Ie.connector.serverInfo),console.log("[useMcp] Server capabilities:",Ie.connector.serverCapabilities),A("ready"),he.current=pt,Mi.getInstance().trackUseMcpConnection({url:t,transportType:pt,success:!0,hasOAuth:!!W.current,hasSampling:!!C,hasElicitation:!!R}).catch(()=>{}),M(Ie.connector.tools||[]);const $e=await Ie.connector.listAllResources();H($e.resources||[]);const Ve=await Ie.connector.listPrompts();ae(Ve.prompts||[]);const at=Ie.connector.serverInfo,dt=Ie.connector.serverCapabilities;return at&&(console.log("[useMcp] Server info:",at),Z(at)),dt&&(console.log("[useMcp] Server capabilities:",dt),re(dt)),"success"}catch(Tt){const nt=Tt,Ie=nt?.message||String(Tt);if(nt.code===401||Ie.includes("401")||Ie.includes("Unauthorized")){if(W.current){ce("info","Authentication required. OAuth provider available.");try{const{auth:$e}=await Qn(async()=>{const{auth:at}=await Promise.resolve().then(()=>NP);return{auth:at}},void 0),Ve=new URL(t).origin;$e(W.current,{serverUrl:Ve}).catch(()=>{}),setTimeout(()=>{if(ie.current){const at=W.current?.getLastAttemptedAuthUrl();at?($(at),ce("info","Manual authentication URL available:",at)):ce("warn","Could not generate authentication URL")}},100)}catch($e){ce("warn","Error generating auth URL:",$e)}return ie.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(Ie,nt instanceof Error?nt:new Error(String(nt))),"failed"}},"tryConnectWithTransport");let Fe="failed";if(g==="sse")ce("debug","Using SSE-only transport mode"),Fe=await je("sse");else if(g==="http")ce("debug","Using HTTP-only transport mode"),Fe=await je("http");else{ce("debug","Using auto transport mode (HTTP with SSE fallback)");const pt=await je("http");pt==="fallback"&&ie.current&&q.current!=="authenticating"?(ce("info","HTTP failed, attempting SSE fallback..."),Fe=await je("sse")):Fe=pt}(Fe==="success"||Fe==="failed"||Fe==="auth_redirect")&&(X.current=!1),ce("debug",`Connection sequence finished with status: ${Fe}`)},[ce,He,Te,t,s,a,r,i,c.name,c.version,u,g,v,w,S,n,y,_]),_e=x.useCallback(async(je,Fe,pt)=>{if(q.current!=="ready"||!F.current)throw new Error(`MCP client is not ready (current state: ${I}). Cannot call tool "${je}".`);ce("info",`Calling tool: ${je}`,Fe);const Qe=Date.now();try{const nt=F.current.getSession("inspector-server");if(!nt)throw new Error("No active session found");const Ie=await nt.connector.callTool(je,Fe||{},pt);return ce("info",`Tool "${je}" call successful:`,Ie),Mi.getInstance().trackUseMcpToolCall({toolName:je,success:!0,executionTimeMs:Date.now()-Qe}).catch(()=>{}),Ie}catch(Tt){throw ce("error",`Tool "${je}" call failed:`,Tt),Mi.getInstance().trackUseMcpToolCall({toolName:je,success:!1,errorType:Tt instanceof Error?Tt.name:"UnknownError",executionTimeMs:Date.now()-Qe}).catch(()=>{}),Tt}},[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 je=q.current;if(je==="failed")ce("info","Attempting to reconnect and authenticate via retry..."),Ue();else if(je==="pending_auth"){ce("info","Proceeding with authentication from pending state...");try{dE(W.current,"Auth Provider not available for manual auth"),dE(t,"Server URL is required for authentication"),ce("info","Clearing all OAuth state and initiating fresh flow...");const Fe=`${s}:${W.current.serverUrlHash}`;Object.keys(localStorage).forEach(nt=>{nt.startsWith(Fe)&&(ce("debug",`Removing stale OAuth key: ${nt}`),localStorage.removeItem(nt)),nt.startsWith(`${s}:state_`)&&(ce("debug",`Removing orphaned state: ${nt}`),localStorage.removeItem(nt))}),A("authenticating");const pt=new ub(t,{storageKeyPrefix:s,clientName:a,clientUri:r,callbackUrl:i,preventAutoAuth:!1,useRedirectFlow:w,onPopupWindow:S});W.current=pt,ce("info","Triggering fresh OAuth authorization...");const{auth:Qe}=await Qn(async()=>{const{auth:nt}=await Promise.resolve().then(()=>NP);return{auth:nt}},void 0),Tt=new URL(t).origin;Qe(pt,{serverUrl:Tt}).catch(nt=>{ce("info","OAuth flow initiated:",nt instanceof Error?nt.message:"Redirecting...")})}catch(Fe){if(!ie.current)return;A("pending_auth"),ce("error",`Manual authentication failed: ${Fe instanceof Error?Fe.message:String(Fe)}`)}}else if(je==="authenticating"){ce("warn","Already attempting authentication. Check for blocked popups or wait for timeout.");const Fe=W.current?.getLastAttemptedAuthUrl();Fe&&!L&&($(Fe),ce("info","Manual authentication URL retrieved:",Fe))}else ce("info",`Client not in a state requiring manual authentication trigger (state: ${je}). If needed, try disconnecting and reconnecting.`)},[ce,Ue,L,t,w,S,s,a,r,i]),Oe=x.useCallback(()=>{if(W.current){const je=W.current.clearStorage();ce("info",`Cleared ${je} item(s) from localStorage for ${t}.`),$(void 0),Te()}else ce("warn","Auth provider not initialized, cannot clear storage.")},[t,ce,Te]),Be=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 Fe=F.current.getSession("inspector-server");if(!Fe)throw new Error("No active session found");const pt=await Fe.connector.listAllResources();H(pt.resources||[]),ce("info","Resources listed successfully")}catch(je){throw ce("error","List resources failed:",je),je}},[I]),xe=x.useCallback(async je=>{if(q.current!=="ready"||!F.current)throw new Error(`MCP client is not ready (current state: ${I}). Cannot read resource.`);ce("info",`Reading resource: ${je}`);try{const pt=F.current.getSession("inspector-server");if(!pt)throw new Error("No active session found");const Qe=await pt.connector.readResource(je);return ce("info","Resource read successful:",Qe),Mi.getInstance().trackUseMcpResourceRead({resourceUri:je,success:!0}).catch(()=>{}),Qe}catch(Fe){throw ce("error","Resource read failed:",Fe),Mi.getInstance().trackUseMcpResourceRead({resourceUri:je,success:!1,errorType:Fe instanceof Error?Fe.name:"UnknownError"}).catch(()=>{}),Fe}},[I]),tt=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 Fe=F.current.getSession("inspector-server");if(!Fe)throw new Error("No active session found");const pt=await Fe.connector.listPrompts();ae(pt.prompts||[]),ce("info","Prompts listed successfully")}catch(je){throw ce("error","List prompts failed:",je),je}},[I]),it=x.useCallback(async(je,Fe)=>{if(q.current!=="ready"||!F.current)throw new Error(`MCP client is not ready (current state: ${I}). Cannot get prompt.`);ce("info",`Getting prompt: ${je}`,Fe);try{const Qe=F.current.getSession("inspector-server");if(!Qe)throw new Error("No active session found");const Tt=await Qe.connector.getPrompt(je,Fe||{});return ce("info",`Prompt "${je}" retrieved successfully:`,Tt),Tt}catch(pt){throw ce("error",`Prompt "${je}" retrieval failed:`,pt),pt}},[I]),ht=x.useRef(Se),Rt=x.useRef(He);return x.useEffect(()=>{ht.current=Se,Rt.current=He}),x.useEffect(()=>{const je=ze(Fe=>{Fe.origin===window.location.origin&&Fe.data?.type==="mcp_auth_callback"&&(ce("info","Received auth callback message.",Fe.data),J.current&&clearTimeout(J.current),J.current=null,Fe.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(()=>{ie.current&&(ce("debug","Initiating reconnection after successful auth callback."),ht.current())},100)):Rt.current(`Authentication failed in callback: ${Fe.data.error||"Unknown reason."}`))},"messageHandler");return window.addEventListener("message",je),ce("debug","Auth callback message listener added."),()=>{window.removeEventListener("message",je),ce("debug","Auth callback message listener removed."),J.current&&clearTimeout(J.current)}},[ce]),x.useEffect(()=>(ie.current=!0,!n||!t?(ce("debug",n?"No server URL provided, skipping connection.":"Connection disabled via enabled flag."),A("discovering"),()=>{ie.current=!1}):(ce("debug","useMcp mounted, initiating connection."),le.current=0,(!W.current||W.current.serverUrl!==t)&&(W.current=new ub(t,{storageKeyPrefix:s,clientName:a,clientUri:r,callbackUrl:i,preventAutoAuth:v,useRedirectFlow:w,onPopupWindow:S}),ce("debug","BrowserOAuthClientProvider initialized/updated on mount/option change.")),Se(),()=>{ie.current=!1,ce("debug","useMcp unmounting, disconnecting."),Te(!0)})),[t,n,s,i,a,r,c.name,c.version,w]),x.useEffect(()=>{let je=null;if(I==="failed"&&m&&le.current>0){const Fe=typeof m=="number"?m:_ie;ce("info",`Connection failed, auto-retrying in ${Fe}ms...`),je=setTimeout(()=>{ie.current&&q.current==="failed"&&Ue()},Fe)}return()=>{je&&clearTimeout(je)}},[I,m,Ue,ce]),{state:I,tools:O,resources:U,resourceTemplates:K,prompts:te,serverInfo:B,capabilities:G,error:ne,log:V,authUrl:L,client:F.current,callTool:_e,readResource:xe,listResources:Be,listPrompts:tt,getPrompt:it,retry:Ue,disconnect:Te,authenticate:fe,clearStorage:Oe}}ze(qT,"useMcp");var Hu,kie=(Hu=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}},ze(Hu,"ErrorBoundary"),Hu),Jf="openai:set_globals";function li(e){return x.useSyncExternalStore(t=>{const n=ze(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)}ze(li,"useOpenAiGlobal");function dd(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=ze(()=>{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"),w=li("userAgent"),S=li("locale"),y=x.useMemo(()=>typeof window<"u"&&window.__mcpPublicUrl?window.__mcpPublicUrl.replace(/\/mcp-use\/public$/,""):"",[]),[_,E]=x.useState(null);x.useEffect(()=>{d!==void 0&&E(d)},[d]);const k=x.useCallback(async(O,M)=>{if(!window.openai?.callTool)throw new Error("window.openai.callTool is not available");return window.openai.callTool(O,M)},[]),C=x.useCallback(async O=>{if(!window.openai?.sendFollowUpMessage)throw new Error("window.openai.sendFollowUpMessage is not available");return window.openai.sendFollowUpMessage({prompt:O})},[]),R=x.useCallback(O=>{if(!window.openai?.openExternal)throw new Error("window.openai.openExternal is not available");window.openai.openExternal({href:O})},[]),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:w||{device:{type:"desktop"},capabilities:{hover:!0,touch:!1}},locale:S||"en",mcp_url:y,callTool:k,sendFollowUpMessage:C,openExternal:R,requestDisplayMode:I,isAvailable:t}}ze(dd,"useWidget");function Tie(e){const{props:t}=dd(e);return t}ze(Tie,"useWidgetProps");function Nie(){const{theme:e}=dd();return e}ze(Nie,"useWidgetTheme");function Cie(e){const{state:t,setState:n}=dd();return x.useEffect(()=>{t===null&&e!==void 0&&window.openai?.setWidgetState&&n(e)},[]),[t,n]}ze(Cie,"useWidgetState");var jP=ze(({children:e})=>{const{theme:t,isAvailable:n}=dd();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=ze(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 jH({children:e,className:t="",position:n="top-right",attachTo:a,showLabels:r=!0,debugger:i=!1,viewControls:s=!1}){const{props:c,output:u,metadata:d,state:m,theme:h,displayMode:g,safeArea:v,maxHeight:w,userAgent:S,locale:y,isAvailable:_,callTool:E,sendFollowUpMessage:k,openExternal:C,requestDisplayMode:R,setState:I}=dd(),[A,O]=x.useState(!1),[M,U]=x.useState(!1),H=x.useRef(null),K=x.useRef(null),[ee,te]=x.useState([]),[ae,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 tt=Object.keys(window.openai);te(tt)}catch{te([])}else te([])},100);return()=>{clearTimeout(xe)}},[]);const X=h==="dark",ie=ze(()=>{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=ze(()=>{const tt=v?.insets?.top?Math.max(16,v.insets.top+8):16,it=v?.insets?.right?Math.max(16,v.insets.right+8):16,ht=v?.insets?.bottom?Math.max(16,v.insets.bottom+8):16,Rt=v?.insets?.left?Math.max(16,v.insets.left+8):16,je={};switch(n){case"top-left":je.top=`${tt}px`,je.left=`${Rt}px`;break;case"top-center":je.top=`${tt}px`;break;case"top-right":je.top=`${tt}px`,je.right=`${it}px`;break;case"center-left":je.left=`${Rt}px`;break;case"center-right":je.right=`${it}px`;break;case"bottom-left":je.bottom=`${ht}px`,je.left=`${Rt}px`;break;case"bottom-center":je.bottom=`${ht}px`;break;case"bottom-right":je.bottom=`${ht}px`,je.right=`${it}px`;break;default:je.top=`${tt}px`,je.right=`${it}px`;break}return je},"getPositionOffsetStyles");x.useEffect(()=>{if(!a)return;const xe=ze(()=>O(!0),"handleMouseEnter"),tt=ze(()=>O(!1),"handleMouseLeave");return a.addEventListener("mouseenter",xe),a.addEventListener("mouseleave",tt),()=>{a.removeEventListener("mouseenter",xe),a.removeEventListener("mouseleave",tt)}},[a]),x.useEffect(()=>{if(!M)return;const xe=ze(tt=>{K.current&&!K.current.contains(tt.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 J=ze(()=>{U(!M)},"handleToggleOverlay"),q=ze(async()=>{try{B("Calling tool...");const xe=re.trim()?JSON.parse(re):{},tt=await E(Z,xe);B(`Success: ${JSON.stringify(tt,null,2)}`)}catch(xe){B(`Error: ${xe.message}`)}},"handleCallTool"),se=ze(async()=>{try{B("Sending follow-up message..."),await k(j),B("Follow-up message sent successfully")}catch(xe){B(`Error: ${xe.message}`)}},"handleSendFollowUpMessage"),he=ze(()=>{try{C(z),B(`Opened external link: ${z}`)}catch(xe){B(`Error: ${xe.message}`)}},"handleOpenExternal"),ce=ze(async xe=>{try{B(`Requesting display mode: ${xe}...`);const tt=await R(xe);B(`Display mode granted: ${tt.mode}`)}catch(tt){B(`Error: ${tt.message}`)}},"handleRequestDisplayMode"),Te=ze(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=ze(async()=>{try{await R("fullscreen")}catch(xe){console.error("Failed to go fullscreen:",xe)}},"handleFullscreen"),Se=ze(async()=>{try{await R("pip")}catch(xe){console.error("Failed to go pip:",xe)}},"handlePip"),_e=ze(()=>{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=ze(({onClick:xe,label:tt,children:it})=>{const[ht,Rt]=x.useState(!1),je=_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:()=>Rt(!0),onMouseLeave:()=>Rt(!1),onClick:xe,"aria-label":tt},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"},it),r&&ue.createElement("span",{className:`${je.join(" ")} ${ht?"opacity-100":"opacity-0"}`},tt))},"IconButton"),fe=ze(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"),Oe=ze(xe=>xe?`${xe.device?.type||"unknown"}`:"N/A","formatUserAgent"),Be=ze(xe=>{if(!xe?.insets)return"N/A";const{top:tt,bottom:it,left:ht,right:Rt}=xe.insets;return`T:${tt} B:${it} L:${ht} R:${Rt}`},"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:ie().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:J,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"},w,"px")),ue.createElement("tr",{className:"border-b border-gray-700"},ue.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"User Agent"),ue.createElement("td",{className:"p-2"},Oe(S))),ue.createElement("tr",{className:"border-b border-gray-700"},ue.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Safe Area"),ue.createElement("td",{className:"p-2"},Be(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:Te,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)")),ae&&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:"),ae,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"))))))}ze(jH,"WidgetControls");function LH(){if(typeof window>"u")return"/";const t=window.location.pathname.match(/^(\/inspector\/api\/dev-widget\/[^/]+)/);return t?t[1]:"/"}ze(LH,"getBasename");var Rie=150,Aie=5;function Iie({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,w]=x.useState(!0);x.useEffect(()=>{let E=!0;return(async()=>{try{const k=await Qn(()=>import("./index-DbyrwQxd.js"),[]);E&&(m(()=>k.BrowserRouter),w(!1))}catch{E&&(g(new Error(`❌ react-router-dom not installed!
|
|
35
|
+
`&&a++}}return[t,n]}class cie extends TransformStream{constructor({onError:t,onRetry:n,onComment:a}={}){let r;super({start(i){r=IH({onEvent:s=>{i.enqueue(s)},onError(s){t==="terminate"?i.error(s):typeof t=="function"&&t(s)},onRetry:n,onComment:a})},transform(i){r.feed(i)}})}}const uie={initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:2};class yl extends Error{constructor(t,n){super(`Streamable HTTP error: ${n}`),this.code=t}}class die{constructor(t,n){var a;this._hasCompletedAuthFlow=!1,this._url=t,this._resourceMetadataUrl=void 0,this._scope=void 0,this._requestInit=n?.requestInit,this._authProvider=n?.authProvider,this._fetch=n?.fetch,this._fetchWithInit=bH(n?.fetch,n?.requestInit),this._sessionId=n?.sessionId,this._reconnectionOptions=(a=n?.reconnectionOptions)!==null&&a!==void 0?a:uie}async _authThenStart(){var t;if(!this._authProvider)throw new Ya("No auth provider");let n;try{n=await ko(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(a){throw(t=this.onerror)===null||t===void 0||t.call(this,a),a}if(n!=="AUTHORIZED")throw new Ya;return await this._startOrAuthSse({resumptionToken:void 0})}async _commonHeaders(){var t;const n={};if(this._authProvider){const r=await this._authProvider.tokens();r&&(n.Authorization=`Bearer ${r.access_token}`)}this._sessionId&&(n["mcp-session-id"]=this._sessionId),this._protocolVersion&&(n["mcp-protocol-version"]=this._protocolVersion);const a=Vb((t=this._requestInit)===null||t===void 0?void 0:t.headers);return new Headers({...n,...a})}async _startOrAuthSse(t){var n,a,r,i;const{resumptionToken:s}=t;try{const c=await this._commonHeaders();c.set("Accept","text/event-stream"),s&&c.set("last-event-id",s);const u=await((n=this._fetch)!==null&&n!==void 0?n:fetch)(this._url,{method:"GET",headers:c,signal:(a=this._abortController)===null||a===void 0?void 0:a.signal});if(!u.ok){if(await((r=u.body)===null||r===void 0?void 0:r.cancel()),u.status===401&&this._authProvider)return await this._authThenStart();if(u.status===405)return;throw new yl(u.status,`Failed to open SSE stream: ${u.statusText}`)}this._handleSseStream(u.body,t,!0)}catch(c){throw(i=this.onerror)===null||i===void 0||i.call(this,c),c}}_getNextReconnectionDelay(t){if(this._serverRetryMs!==void 0)return this._serverRetryMs;const n=this._reconnectionOptions.initialReconnectionDelay,a=this._reconnectionOptions.reconnectionDelayGrowFactor,r=this._reconnectionOptions.maxReconnectionDelay;return Math.min(n*Math.pow(a,t),r)}_scheduleReconnection(t,n=0){var a;const r=this._reconnectionOptions.maxRetries;if(n>=r){(a=this.onerror)===null||a===void 0||a.call(this,new Error(`Maximum reconnection attempts (${r}) exceeded.`));return}const i=this._getNextReconnectionDelay(n);this._reconnectionTimeout=setTimeout(()=>{this._startOrAuthSse(t).catch(s=>{var c;(c=this.onerror)===null||c===void 0||c.call(this,new Error(`Failed to reconnect SSE stream: ${s instanceof Error?s.message:String(s)}`)),this._scheduleReconnection(t,n+1)})},i)}_handleSseStream(t,n,a){if(!t)return;const{onresumptiontoken:r,replayMessageId:i}=n;let s,c=!1,u=!1;(async()=>{var m,h,g,v;try{const w=t.pipeThrough(new TextDecoderStream).pipeThrough(new cie({onRetry:_=>{this._serverRetryMs=_}})).getReader();for(;;){const{value:_,done:E}=await w.read();if(E)break;if(_.id&&(s=_.id,c=!0,r?.(_.id)),!!_.data&&(!_.event||_.event==="message"))try{const k=ob.parse(JSON.parse(_.data));Pf(k)&&(u=!0,i!==void 0&&(k.id=i)),(m=this.onmessage)===null||m===void 0||m.call(this,k)}catch(k){(h=this.onerror)===null||h===void 0||h.call(this,k)}}(a||c)&&!u&&this._abortController&&!this._abortController.signal.aborted&&this._scheduleReconnection({resumptionToken:s,onresumptiontoken:r,replayMessageId:i},0)}catch(w){if((g=this.onerror)===null||g===void 0||g.call(this,new Error(`SSE stream disconnected: ${w}`)),(a||c)&&!u&&this._abortController&&!this._abortController.signal.aborted)try{this._scheduleReconnection({resumptionToken:s,onresumptiontoken:r,replayMessageId:i},0)}catch(_){(v=this.onerror)===null||v===void 0||v.call(this,new Error(`Failed to reconnect: ${_ instanceof Error?_.message:String(_)}`))}}})()}async start(){if(this._abortController)throw new Error("StreamableHTTPClientTransport already started! If using Client class, note that connect() calls start() automatically.");this._abortController=new AbortController}async finishAuth(t){if(!this._authProvider)throw new Ya("No auth provider");if(await ko(this._authProvider,{serverUrl:this._url,authorizationCode:t,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new Ya("Failed to authorize")}async close(){var t,n;this._reconnectionTimeout&&(clearTimeout(this._reconnectionTimeout),this._reconnectionTimeout=void 0),(t=this._abortController)===null||t===void 0||t.abort(),(n=this.onclose)===null||n===void 0||n.call(this)}async send(t,n){var a,r,i,s,c,u,d;try{const{resumptionToken:m,onresumptiontoken:h}=n||{};if(m){this._startOrAuthSse({resumptionToken:m,replayMessageId:VS(t)?t.id:void 0}).catch(k=>{var C;return(C=this.onerror)===null||C===void 0?void 0:C.call(this,k)});return}const g=await this._commonHeaders();g.set("content-type","application/json"),g.set("accept","application/json, text/event-stream");const v={...this._requestInit,method:"POST",headers:g,body:JSON.stringify(t),signal:(a=this._abortController)===null||a===void 0?void 0:a.signal},w=await((r=this._fetch)!==null&&r!==void 0?r:fetch)(this._url,v),S=w.headers.get("mcp-session-id");if(S&&(this._sessionId=S),!w.ok){const k=await w.text().catch(()=>null);if(w.status===401&&this._authProvider){if(this._hasCompletedAuthFlow)throw new yl(401,"Server returned 401 after successful authentication");const{resourceMetadataUrl:C,scope:R}=yp(w);if(this._resourceMetadataUrl=C,this._scope=R,await ko(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new Ya;return this._hasCompletedAuthFlow=!0,this.send(t)}if(w.status===403&&this._authProvider){const{resourceMetadataUrl:C,scope:R,error:I}=yp(w);if(I==="insufficient_scope"){const A=w.headers.get("WWW-Authenticate");if(this._lastUpscopingHeader===A)throw new yl(403,"Server returned 403 after trying upscoping");if(R&&(this._scope=R),C&&(this._resourceMetadataUrl=C),this._lastUpscopingHeader=A??void 0,await ko(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetch})!=="AUTHORIZED")throw new Ya;return this.send(t)}}throw new yl(w.status,`Error POSTing to endpoint: ${k}`)}if(this._hasCompletedAuthFlow=!1,this._lastUpscopingHeader=void 0,w.status===202){await((i=w.body)===null||i===void 0?void 0:i.cancel()),tne(t)&&this._startOrAuthSse({resumptionToken:void 0}).catch(k=>{var C;return(C=this.onerror)===null||C===void 0?void 0:C.call(this,k)});return}const _=(Array.isArray(t)?t:[t]).filter(k=>"method"in k&&"id"in k&&k.id!==void 0).length>0,E=w.headers.get("content-type");if(_)if(E?.includes("text/event-stream"))this._handleSseStream(w.body,{onresumptiontoken:h},!1);else if(E?.includes("application/json")){const k=await w.json(),C=Array.isArray(k)?k.map(R=>ob.parse(R)):[ob.parse(k)];for(const R of C)(s=this.onmessage)===null||s===void 0||s.call(this,R)}else throw await((c=w.body)===null||c===void 0?void 0:c.cancel()),new yl(-1,`Unexpected content type: ${E}`);else await((u=w.body)===null||u===void 0?void 0:u.cancel())}catch(m){throw(d=this.onerror)===null||d===void 0||d.call(this,m),m}}get sessionId(){return this._sessionId}async terminateSession(){var t,n,a,r;if(this._sessionId)try{const i=await this._commonHeaders(),s={...this._requestInit,method:"DELETE",headers:i,signal:(t=this._abortController)===null||t===void 0?void 0:t.signal},c=await((n=this._fetch)!==null&&n!==void 0?n:fetch)(this._url,s);if(await((a=c.body)===null||a===void 0?void 0:a.cancel()),!c.ok&&c.status!==405)throw new yl(c.status,`Failed to terminate session: ${c.statusText}`);this._sessionId=void 0}catch(i){throw(r=this.onerror)===null||r===void 0||r.call(this,i),i}}setProtocolVersion(t){this._protocolVersion=t}get protocolVersion(){return this._protocolVersion}async resumeStream(t,n){await this._startOrAuthSse({resumptionToken:t,onresumptiontoken:n?.onresumptiontoken})}}class RP extends Event{constructor(t,n){var a,r;super(t),this.code=(a=n?.code)!=null?a:void 0,this.message=(r=n?.message)!=null?r:void 0}[Symbol.for("nodejs.util.inspect.custom")](t,n,a){return a(AP(this),n)}[Symbol.for("Deno.customInspect")](t,n){return t(AP(this),n)}}function fie(e){const t=globalThis.DOMException;return typeof t=="function"?new t(e,"SyntaxError"):new SyntaxError(e)}function rE(e){return e instanceof Error?"errors"in e&&Array.isArray(e.errors)?e.errors.map(rE).join(", "):"cause"in e&&e.cause instanceof Error?`${e}: ${rE(e.cause)}`:e.message:`${e}`}function AP(e){return{type:e.type,message:e.message,code:e.code,defaultPrevented:e.defaultPrevented,cancelable:e.cancelable,timeStamp:e.timeStamp}}var OH=e=>{throw TypeError(e)},KT=(e,t,n)=>t.has(e)||OH("Cannot "+n),Bt=(e,t,n)=>(KT(e,t,"read from private field"),n?n.call(e):t.get(e)),ur=(e,t,n)=>t.has(e)?OH("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),$n=(e,t,n,a)=>(KT(e,t,"write to private field"),t.set(e,n),n),wo=(e,t,n)=>(KT(e,t,"access private method"),n),ha,xl,Wc,lb,Yb,qf,nu,Xf,Ts,Kc,pu,Zc,Uf,ci,aE,iE,oE,IP,sE,lE,zf,cE,uE;class cb extends EventTarget{constructor(t,n){var a,r;super(),ur(this,ci),this.CONNECTING=0,this.OPEN=1,this.CLOSED=2,ur(this,ha),ur(this,xl),ur(this,Wc),ur(this,lb),ur(this,Yb),ur(this,qf),ur(this,nu),ur(this,Xf,null),ur(this,Ts),ur(this,Kc),ur(this,pu,null),ur(this,Zc,null),ur(this,Uf,null),ur(this,iE,async i=>{var s;Bt(this,Kc).reset();const{body:c,redirected:u,status:d,headers:m}=i;if(d===204){wo(this,ci,zf).call(this,"Server sent HTTP 204, not reconnecting",204),this.close();return}if(u?$n(this,Wc,new URL(i.url)):$n(this,Wc,void 0),d!==200){wo(this,ci,zf).call(this,`Non-200 status code (${d})`,d);return}if(!(m.get("content-type")||"").startsWith("text/event-stream")){wo(this,ci,zf).call(this,'Invalid content type, expected "text/event-stream"',d);return}if(Bt(this,ha)===this.CLOSED)return;$n(this,ha,this.OPEN);const h=new Event("open");if((s=Bt(this,Uf))==null||s.call(this,h),this.dispatchEvent(h),typeof c!="object"||!c||!("getReader"in c)){wo(this,ci,zf).call(this,"Invalid response body, expected a web ReadableStream",d),this.close();return}const g=new TextDecoder,v=c.getReader();let w=!0;do{const{done:S,value:y}=await v.read();y&&Bt(this,Kc).feed(g.decode(y,{stream:!S})),S&&(w=!1,Bt(this,Kc).reset(),wo(this,ci,cE).call(this))}while(w)}),ur(this,oE,i=>{$n(this,Ts,void 0),!(i.name==="AbortError"||i.type==="aborted")&&wo(this,ci,cE).call(this,rE(i))}),ur(this,sE,i=>{typeof i.id=="string"&&$n(this,Xf,i.id);const s=new MessageEvent(i.event||"message",{data:i.data,origin:Bt(this,Wc)?Bt(this,Wc).origin:Bt(this,xl).origin,lastEventId:i.id||""});Bt(this,Zc)&&(!i.event||i.event==="message")&&Bt(this,Zc).call(this,s),this.dispatchEvent(s)}),ur(this,lE,i=>{$n(this,qf,i)}),ur(this,uE,()=>{$n(this,nu,void 0),Bt(this,ha)===this.CONNECTING&&wo(this,ci,aE).call(this)});try{if(t instanceof URL)$n(this,xl,t);else if(typeof t=="string")$n(this,xl,new URL(t,pie()));else throw new Error("Invalid URL")}catch{throw fie("An invalid or illegal string was specified")}$n(this,Kc,IH({onEvent:Bt(this,sE),onRetry:Bt(this,lE)})),$n(this,ha,this.CONNECTING),$n(this,qf,3e3),$n(this,Yb,(a=n?.fetch)!=null?a:globalThis.fetch),$n(this,lb,(r=n?.withCredentials)!=null?r:!1),wo(this,ci,aE).call(this)}get readyState(){return Bt(this,ha)}get url(){return Bt(this,xl).href}get withCredentials(){return Bt(this,lb)}get onerror(){return Bt(this,pu)}set onerror(t){$n(this,pu,t)}get onmessage(){return Bt(this,Zc)}set onmessage(t){$n(this,Zc,t)}get onopen(){return Bt(this,Uf)}set onopen(t){$n(this,Uf,t)}addEventListener(t,n,a){const r=n;super.addEventListener(t,r,a)}removeEventListener(t,n,a){const r=n;super.removeEventListener(t,r,a)}close(){Bt(this,nu)&&clearTimeout(Bt(this,nu)),Bt(this,ha)!==this.CLOSED&&(Bt(this,Ts)&&Bt(this,Ts).abort(),$n(this,ha,this.CLOSED),$n(this,Ts,void 0))}}ha=new WeakMap,xl=new WeakMap,Wc=new WeakMap,lb=new WeakMap,Yb=new WeakMap,qf=new WeakMap,nu=new WeakMap,Xf=new WeakMap,Ts=new WeakMap,Kc=new WeakMap,pu=new WeakMap,Zc=new WeakMap,Uf=new WeakMap,ci=new WeakSet,aE=function(){$n(this,ha,this.CONNECTING),$n(this,Ts,new AbortController),Bt(this,Yb)(Bt(this,xl),wo(this,ci,IP).call(this)).then(Bt(this,iE)).catch(Bt(this,oE))},iE=new WeakMap,oE=new WeakMap,IP=function(){var e;const t={mode:"cors",redirect:"follow",headers:{Accept:"text/event-stream",...Bt(this,Xf)?{"Last-Event-ID":Bt(this,Xf)}:void 0},cache:"no-store",signal:(e=Bt(this,Ts))==null?void 0:e.signal};return"window"in globalThis&&(t.credentials=this.withCredentials?"include":"same-origin"),t},sE=new WeakMap,lE=new WeakMap,zf=function(e,t){var n;Bt(this,ha)!==this.CLOSED&&$n(this,ha,this.CLOSED);const a=new RP("error",{code:t,message:e});(n=Bt(this,pu))==null||n.call(this,a),this.dispatchEvent(a)},cE=function(e,t){var n;if(Bt(this,ha)===this.CLOSED)return;$n(this,ha,this.CONNECTING);const a=new RP("error",{code:t,message:e});(n=Bt(this,pu))==null||n.call(this,a),this.dispatchEvent(a),$n(this,nu,setTimeout(Bt(this,uE),Bt(this,qf)))},uE=new WeakMap,cb.CONNECTING=0,cb.OPEN=1,cb.CLOSED=2;function pie(){const e="document"in globalThis?globalThis.document:void 0;return e&&typeof e=="object"&&"baseURI"in e&&typeof e.baseURI=="string"?e.baseURI:void 0}class mie extends Error{constructor(t,n,a){super(`SSE error: ${n}`),this.code=t,this.event=a}}class hie{constructor(t,n){this._url=t,this._resourceMetadataUrl=void 0,this._scope=void 0,this._eventSourceInit=n?.eventSourceInit,this._requestInit=n?.requestInit,this._authProvider=n?.authProvider,this._fetch=n?.fetch,this._fetchWithInit=bH(n?.fetch,n?.requestInit)}async _authThenStart(){var t;if(!this._authProvider)throw new Ya("No auth provider");let n;try{n=await ko(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(a){throw(t=this.onerror)===null||t===void 0||t.call(this,a),a}if(n!=="AUTHORIZED")throw new Ya;return await this._startOrAuth()}async _commonHeaders(){var t;const n={};if(this._authProvider){const r=await this._authProvider.tokens();r&&(n.Authorization=`Bearer ${r.access_token}`)}this._protocolVersion&&(n["mcp-protocol-version"]=this._protocolVersion);const a=Vb((t=this._requestInit)===null||t===void 0?void 0:t.headers);return new Headers({...n,...a})}_startOrAuth(){var t,n,a;const r=(a=(n=(t=this===null||this===void 0?void 0:this._eventSourceInit)===null||t===void 0?void 0:t.fetch)!==null&&n!==void 0?n:this._fetch)!==null&&a!==void 0?a:fetch;return new Promise((i,s)=>{this._eventSource=new cb(this._url.href,{...this._eventSourceInit,fetch:async(c,u)=>{const d=await this._commonHeaders();d.set("Accept","text/event-stream");const m=await r(c,{...u,headers:d});if(m.status===401&&m.headers.has("www-authenticate")){const{resourceMetadataUrl:h,scope:g}=yp(m);this._resourceMetadataUrl=h,this._scope=g}return m}}),this._abortController=new AbortController,this._eventSource.onerror=c=>{var u;if(c.code===401&&this._authProvider){this._authThenStart().then(i,s);return}const d=new mie(c.code,c.message,c);s(d),(u=this.onerror)===null||u===void 0||u.call(this,d)},this._eventSource.onopen=()=>{},this._eventSource.addEventListener("endpoint",c=>{var u;const d=c;try{if(this._endpoint=new URL(d.data,this._url),this._endpoint.origin!==this._url.origin)throw new Error(`Endpoint origin does not match connection origin: ${this._endpoint.origin}`)}catch(m){s(m),(u=this.onerror)===null||u===void 0||u.call(this,m),this.close();return}i()}),this._eventSource.onmessage=c=>{var u,d;const m=c;let h;try{h=ob.parse(JSON.parse(m.data))}catch(g){(u=this.onerror)===null||u===void 0||u.call(this,g);return}(d=this.onmessage)===null||d===void 0||d.call(this,h)}})}async start(){if(this._eventSource)throw new Error("SSEClientTransport already started! If using Client class, note that connect() calls start() automatically.");return await this._startOrAuth()}async finishAuth(t){if(!this._authProvider)throw new Ya("No auth provider");if(await ko(this._authProvider,{serverUrl:this._url,authorizationCode:t,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new Ya("Failed to authorize")}async close(){var t,n,a;(t=this._abortController)===null||t===void 0||t.abort(),(n=this._eventSource)===null||n===void 0||n.close(),(a=this.onclose)===null||a===void 0||a.call(this)}async send(t){var n,a,r,i;if(!this._endpoint)throw new Error("Not connected");try{const s=await this._commonHeaders();s.set("content-type","application/json");const c={...this._requestInit,method:"POST",headers:s,body:JSON.stringify(t),signal:(n=this._abortController)===null||n===void 0?void 0:n.signal},u=await((a=this._fetch)!==null&&a!==void 0?a:fetch)(this._endpoint,c);if(!u.ok){const d=await u.text().catch(()=>null);if(u.status===401&&this._authProvider){const{resourceMetadataUrl:m,scope:h}=yp(u);if(this._resourceMetadataUrl=m,this._scope=h,await ko(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new Ya;return this.send(t)}throw new Error(`Error POSTing to endpoint (HTTP ${u.status}): ${d}`)}await((r=u.body)===null||r===void 0?void 0:r.cancel())}catch(s){throw(i=this.onerror)===null||i===void 0||i.call(this,s),s}}setProtocolVersion(t){this._protocolVersion=t}}var Mu,gie=(Mu=class{connector;autoConnect;constructor(t,n=!0){this.connector=t,this.autoConnect=n}async connect(){await this.connector.connect()}async disconnect(){await this.connector.disconnect()}async initialize(){!this.isConnected&&this.autoConnect&&await this.connect(),await this.connector.initialize()}get isConnected(){return this.connector&&this.connector.isClientConnected}on(t,n){t==="notification"&&this.connector.onNotification(n)}async setRoots(t){return this.connector.setRoots(t)}getRoots(){return this.connector.getRoots()}get tools(){return this.connector.tools}async listTools(t){return this.connector.listTools(t)}get serverCapabilities(){return this.connector.serverCapabilities}get serverInfo(){return this.connector.serverInfo}async callTool(t,n={},a){return this.connector.callTool(t,n,a)}async listResources(t,n){return this.connector.listResources(t,n)}async listAllResources(t){return this.connector.listAllResources(t)}async listResourceTemplates(t){return this.connector.listResourceTemplates(t)}async readResource(t,n){return this.connector.readResource(t,n)}async subscribeToResource(t,n){return this.connector.subscribeToResource(t,n)}async unsubscribeFromResource(t,n){return this.connector.unsubscribeFromResource(t,n)}async listPrompts(){return this.connector.listPrompts()}async getPrompt(t,n){return this.connector.getPrompt(t,n)}async request(t,n=null,a){return this.connector.request(t,n,a)}},ze(Mu,"MCPSession"),Mu),Pu,bie=(Pu=class{_readyPromise;_readyResolver;_donePromise;_doneResolver;_exception=null;_connection=null;_task=null;_abortController=null;constructor(){this.reset()}async start(){if(this.reset(),ke.debug(`Starting ${this.constructor.name}`),this._task=this.connectionTask(),await this._readyPromise,this._exception)throw this._exception;if(this._connection===null)throw new Error("Connection was not established");return this._connection}async stop(){if(this._task&&this._abortController){ke.debug(`Cancelling ${this.constructor.name} task`),this._abortController.abort();try{await this._task}catch(t){t instanceof Error&&t.name==="AbortError"?ke.debug(`${this.constructor.name} task aborted successfully`):ke.warn(`Error stopping ${this.constructor.name} task: ${t}`)}}await this._donePromise,ke.debug(`${this.constructor.name} task completed`)}reset(){this._readyPromise=new Promise(t=>this._readyResolver=t),this._donePromise=new Promise(t=>this._doneResolver=t),this._exception=null,this._connection=null,this._task=null,this._abortController=new AbortController}async connectionTask(){ke.debug(`Running ${this.constructor.name} task`);try{this._connection=await this.establishConnection(),ke.debug(`${this.constructor.name} connected successfully`),this._readyResolver(),await this.waitForAbort()}catch(t){this._exception=t,ke.error(`Error in ${this.constructor.name} task: ${t}`),this._readyResolver()}finally{if(this._connection!==null){try{await this.closeConnection(this._connection)}catch(t){ke.warn(`Error closing connection in ${this.constructor.name}: ${t}`)}this._connection=null}this._doneResolver()}}async waitForAbort(){return new Promise((t,n)=>{if(!this._abortController)return;const a=this._abortController.signal;if(a.aborted){t();return}const r=ze(()=>{a.removeEventListener("abort",r),t()},"onAbort");a.addEventListener("abort",r)})}},ze(Pu,"ConnectionManager"),Pu),Uu,vie=(Uu=class extends bie{url;opts;_transport=null;constructor(t,n){super(),this.url=typeof t=="string"?new URL(t):t,this.opts=n}async establishConnection(){return this._transport=new hie(this.url,this.opts),ke.debug(`${this.constructor.name} connected successfully`),this._transport}async closeConnection(t){if(this._transport)try{await this._transport.close()}catch(n){ke.warn(`Error closing SSE transport: ${n}`)}finally{this._transport=null}}},ze(Uu,"SseConnectionManager"),Uu),zu,yie=(zu=class extends bre{baseUrl;headers;timeout;sseReadTimeout;clientInfo;preferSse;transportType=null;streamableTransport=null;constructor(t,n={}){super(n),this.baseUrl=t.replace(/\/$/,""),this.headers={...n.headers??{}},n.authToken&&(this.headers.Authorization=`Bearer ${n.authToken}`),this.timeout=n.timeout??3e4,this.sseReadTimeout=n.sseReadTimeout??3e5,this.clientInfo=n.clientInfo??{name:"http-connector",version:"1.0.0"},this.preferSse=n.preferSse??!1}async connect(){if(this.connected){ke.debug("Already connected to MCP implementation");return}const t=this.baseUrl;if(this.preferSse){ke.debug(`Connecting to MCP implementation via HTTP/SSE: ${t}`),await this.connectWithSse(t);return}ke.debug(`Connecting to MCP implementation via HTTP: ${t}`);try{ke.info("🔄 Attempting streamable HTTP transport..."),await this.connectWithStreamableHttp(t),ke.info("✅ Successfully connected via streamable HTTP")}catch(n){let a="Unknown error",r=!1;if(n instanceof yl){const i=n;r=i.code===401,i.code===400&&i.message.includes("Missing session ID")?(a="Server requires session ID (FastMCP compatibility) - using SSE transport",ke.warn(`⚠️ ${a}`)):i.code===404||i.code===405?(a=`Server returned ${i.code} - server likely doesn't support streamable HTTP`,ke.debug(a)):(a=`Server returned ${i.code}: ${i.message}`,ke.debug(a))}else if(n instanceof Error){const i=n.toString(),s=n.message||"";r=i.includes("401")||s.includes("Unauthorized"),i.includes("Missing session ID")||i.includes("Bad Request: Missing session ID")||s.includes("FastMCP session ID error")?(a="Server requires session ID (FastMCP compatibility) - using SSE transport",ke.warn(`⚠️ ${a}`)):i.includes("405 Method Not Allowed")||i.includes("404 Not Found")?(a="Server doesn't support streamable HTTP (405/404)",ke.debug(a)):(a=`Streamable HTTP failed: ${n.message}`,ke.debug(a))}if(r){ke.info("Authentication required - skipping SSE fallback"),await this.cleanupResources();const i=new Error("Authentication required");throw i.code=401,i}ke.info("🔄 Falling back to SSE transport...");try{await this.connectWithSse(t)}catch(i){if(ke.error("Failed to connect with both transports:"),ke.error(` Streamable HTTP: ${a}`),ke.error(` SSE: ${i}`),await this.cleanupResources(),i?.message?.includes("401")||i?.message?.includes("Unauthorized")){const c=new Error("Authentication required");throw c.code=401,c}throw new Error("Could not connect to server with any available transport")}}}async connectWithStreamableHttp(t){try{const n=new die(new URL(t),{authProvider:this.opts.authProvider,requestInit:{headers:this.headers},reconnectionOptions:{maxReconnectionDelay:3e4,initialReconnectionDelay:1e3,reconnectionDelayGrowFactor:1.5,maxRetries:2}});let a=n;if(this.opts.wrapTransport){const i=this.baseUrl;a=this.opts.wrapTransport(a,i)}const r={...this.opts.clientOptions||{},capabilities:{...this.opts.clientOptions?.capabilities||{},roots:{listChanged:!0},...this.opts.samplingCallback?{sampling:{}}:{},...this.opts.elicitationCallback?{elicitation:{form:{},url:{}}}:{}}};ke.debug("Creating Client with capabilities:",JSON.stringify(r.capabilities,null,2)),this.client=new _P(this.clientInfo,r),this.setupRootsHandler(),ke.debug("Roots handler registered before connect");try{await this.client.connect(a,{timeout:Math.min(this.timeout,3e3)});const i=n.sessionId;i?ke.debug(`Session ID obtained: ${i}`):ke.warn("Session ID not available after connect - this may cause issues with SSE stream")}catch(i){if(i instanceof Error){const s=i.message||i.toString();if(s.includes("Missing session ID")||s.includes("Bad Request: Missing session ID")||s.includes("Mcp-Session-Id header is required")){const c=new Error(`Session ID error: ${s}. The SDK should automatically extract session ID from initialize response.`);throw c.cause=i,c}}throw i}this.streamableTransport=n,this.connectionManager={stop:ze(async()=>{if(this.streamableTransport)try{await this.streamableTransport.terminateSession(),await this.streamableTransport.close()}catch(i){ke.warn(`Error closing Streamable HTTP transport: ${i}`)}finally{this.streamableTransport=null}},"stop")},this.connected=!0,this.transportType="streamable-http",this.setupNotificationHandler(),this.setupSamplingHandler(),this.setupElicitationHandler(),ke.debug(`Successfully connected to MCP implementation via streamable HTTP: ${t}`),this.trackConnectorInit({serverUrl:this.baseUrl,publicIdentifier:`${this.baseUrl} (streamable-http)`})}catch(n){throw await this.cleanupResources(),n}}async connectWithSse(t){try{this.connectionManager=new vie(t,{authProvider:this.opts.authProvider,requestInit:{headers:this.headers}});let n=await this.connectionManager.start();if(this.opts.wrapTransport){const r=this.baseUrl;n=this.opts.wrapTransport(n,r)}const a={...this.opts.clientOptions||{},capabilities:{...this.opts.clientOptions?.capabilities||{},roots:{listChanged:!0},...this.opts.samplingCallback?{sampling:{}}:{},...this.opts.elicitationCallback?{elicitation:{form:{},url:{}}}:{}}};ke.debug("Creating Client with capabilities (SSE):",JSON.stringify(a.capabilities,null,2)),this.client=new _P(this.clientInfo,a),this.setupRootsHandler(),ke.debug("Roots handler registered before connect (SSE)"),await this.client.connect(n),this.connected=!0,this.transportType="sse",this.setupNotificationHandler(),this.setupSamplingHandler(),this.setupElicitationHandler(),ke.debug(`Successfully connected to MCP implementation via HTTP/SSE: ${t}`),this.trackConnectorInit({serverUrl:this.baseUrl,publicIdentifier:`${this.baseUrl} (sse)`})}catch(n){throw await this.cleanupResources(),n}}get publicIdentifier(){return{type:"http",url:this.baseUrl,transport:this.transportType||"unknown"}}getTransportType(){return this.transportType}},ze(zu,"HttpConnector"),zu),Fu,wie=(Fu=class{config={};sessions={};activeSessions=[];constructor(t){t&&(this.config=t)}static fromDict(t){throw new Error("fromDict must be implemented by concrete class")}addServer(t,n){this.config.mcpServers=this.config.mcpServers||{},this.config.mcpServers[t]=n,Mi.getInstance().trackClientAddServer(t,n)}removeServer(t){this.config.mcpServers?.[t]&&(delete this.config.mcpServers[t],this.activeSessions=this.activeSessions.filter(n=>n!==t),Mi.getInstance().trackClientRemoveServer(t))}getServerNames(){return Object.keys(this.config.mcpServers??{})}getServerConfig(t){return this.config.mcpServers?.[t]}getConfig(){return this.config??{}}async createSession(t,n=!0){const a=this.config.mcpServers??{};if(Object.keys(a).length===0&&ke.warn("No MCP servers defined in config"),!a[t])throw new Error(`Server '${t}' not found in config`);const r=this.createConnectorFromConfig(a[t]),i=new gie(r);return n&&await i.initialize(),this.sessions[t]=i,this.activeSessions.includes(t)||this.activeSessions.push(t),i}async createAllSessions(t=!0){const n=this.config.mcpServers??{};Object.keys(n).length===0&&ke.warn("No MCP servers defined in config");for(const a of Object.keys(n))await this.createSession(a,t);return this.sessions}getSession(t){const n=this.sessions[t];return n||null}requireSession(t){const n=this.sessions[t];if(!n)throw new Error(`Session '${t}' not found. Available sessions: ${this.activeSessions.join(", ")||"none"}`);return n}getAllActiveSessions(){return Object.fromEntries(this.activeSessions.map(t=>[t,this.sessions[t]]))}async closeSession(t){const n=this.sessions[t];if(!n){ke.warn(`No session exists for server ${t}, nothing to close`);return}try{ke.debug(`Closing session for server ${t}`),await n.disconnect()}catch(a){ke.error(`Error closing session for server '${t}': ${a}`)}finally{delete this.sessions[t],this.activeSessions=this.activeSessions.filter(a=>a!==t)}}async closeAllSessions(){const t=Object.keys(this.sessions),n=[];for(const a of t)try{ke.debug(`Closing session for server ${a}`),await this.closeSession(a)}catch(r){const i=`Failed to close session for server '${a}': ${r}`;ke.error(i),n.push(i)}n.length?ke.error(`Encountered ${n.length} errors while closing sessions`):ke.debug("All sessions closed successfully")}},ze(Fu,"BaseMCPClient"),Fu),Dl,xie=(Dl=class extends wie{static getPackageVersion(){return Ab()}constructor(t){super(t),this._trackClientInit()}_trackClientInit(){const t=Object.keys(this.config.mcpServers??{});Mi.getInstance().trackMCPClientInit({codeMode:!1,sandbox:!1,allCallbacks:!1,verify:!1,servers:t,numServers:t.length,isBrowser:!0}).catch(n=>ke.debug(`Failed to track BrowserMCPClient init: ${n}`))}static fromDict(t){return new Dl(t)}createConnectorFromConfig(t){const{url:n,headers:a,authToken:r,authProvider:i,wrapTransport:s,clientOptions:c,samplingCallback:u,elicitationCallback:d}=t;if(!n)throw new Error("Server URL is required");const m={headers:a,authToken:r,authProvider:i,wrapTransport:s,clientOptions:c,samplingCallback:u,elicitationCallback:d};return c?console.log("[BrowserMCPClient] Passing clientOptions to connector:",JSON.stringify(c,null,2)):console.warn("[BrowserMCPClient] No clientOptions provided to connector!"),new yie(n,m)}},ze(Dl,"BrowserMCPClient"),Dl);function ru(e){const t=ze(()=>{throw new Error(`Invalid url to pass to open(): ${e}`)},"abort");let n;try{n=new URL(e)}catch{t()}return n.protocol!=="https:"&&n.protocol!=="http:"&&t(),n.hostname!==encodeURIComponent(n.hostname)&&t(),n.username&&(n.username=encodeURIComponent(n.username)),n.password&&(n.password=encodeURIComponent(n.password)),n.pathname=n.pathname.slice(0,1)+encodeURIComponent(n.pathname.slice(1)).replace(/%2f/gi,"/"),n.search=n.search.slice(0,1)+Array.from(n.searchParams.entries()).map(DH).join("&"),n.hash=n.hash.slice(0,1)+encodeURIComponent(n.hash.slice(1)),n.href}ze(ru,"sanitizeUrl");function DH([e,t]){return`${encodeURIComponent(e)}${t.length>0?`=${encodeURIComponent(t)}`:""}`}ze(DH,"sanitizeParam");var Bu,ub=(Bu=class{serverUrl;storageKeyPrefix;serverUrlHash;clientName;clientUri;callbackUrl;preventAutoAuth;useRedirectFlow;onPopupWindow;constructor(t,n={}){this.serverUrl=t,this.storageKeyPrefix=n.storageKeyPrefix||"mcp:auth",this.serverUrlHash=this.hashString(t),this.clientName=n.clientName||"mcp-use",this.clientUri=n.clientUri||(typeof window<"u"?window.location.origin:""),this.callbackUrl=ru(n.callbackUrl||(typeof window<"u"?new URL("/oauth/callback",window.location.origin).toString():"/oauth/callback")),this.preventAutoAuth=n.preventAutoAuth,this.useRedirectFlow=n.useRedirectFlow,this.onPopupWindow=n.onPopupWindow}get redirectUrl(){return ru(this.callbackUrl)}get clientMetadata(){return{redirect_uris:[this.redirectUrl],token_endpoint_auth_method:"none",grant_types:["authorization_code","refresh_token"],response_types:["code"],client_name:this.clientName,client_uri:this.clientUri}}async clientInformation(){const t=this.getKey("client_info"),n=localStorage.getItem(t);if(n)try{return JSON.parse(n)}catch(a){console.warn(`[${this.storageKeyPrefix}] Failed to parse client information:`,a),localStorage.removeItem(t);return}}async saveClientInformation(t){const n=this.getKey("client_info");localStorage.setItem(n,JSON.stringify(t))}async tokens(){const t=this.getKey("tokens"),n=localStorage.getItem(t);if(n)try{return JSON.parse(n)}catch(a){console.warn(`[${this.storageKeyPrefix}] Failed to parse tokens:`,a),localStorage.removeItem(t);return}}async saveTokens(t){const n=this.getKey("tokens");localStorage.setItem(n,JSON.stringify(t)),localStorage.removeItem(this.getKey("code_verifier")),localStorage.removeItem(this.getKey("last_auth_url"))}async saveCodeVerifier(t){const n=this.getKey("code_verifier");localStorage.setItem(n,t)}async codeVerifier(){const t=this.getKey("code_verifier"),n=localStorage.getItem(t);if(!n)throw new Error(`[${this.storageKeyPrefix}] Code verifier not found in storage for key ${t}. Auth flow likely corrupted or timed out.`);return n}async prepareAuthorizationUrl(t){const n=globalThis.crypto.randomUUID(),a=`${this.storageKeyPrefix}:state_${n}`,r={serverUrlHash:this.serverUrlHash,expiry:Date.now()+1e3*60*10,providerOptions:{serverUrl:this.serverUrl,storageKeyPrefix:this.storageKeyPrefix,clientName:this.clientName,clientUri:this.clientUri,callbackUrl:this.callbackUrl},flowType:this.useRedirectFlow?"redirect":"popup",returnUrl:this.useRedirectFlow&&typeof window<"u"?window.location.href:void 0};localStorage.setItem(a,JSON.stringify(r)),t.searchParams.set("state",n);const i=t.toString(),s=ru(i);return localStorage.setItem(this.getKey("last_auth_url"),s),s}async redirectToAuthorization(t){const n=await this.prepareAuthorizationUrl(t);if(this.preventAutoAuth){console.info(`[${this.storageKeyPrefix}] Auto-auth prevented. Authorization URL stored for manual trigger.`);return}if(this.useRedirectFlow){console.info(`[${this.storageKeyPrefix}] Redirecting to authorization URL (full-page redirect).`),window.location.href=n;return}const a="width=600,height=700,resizable=yes,scrollbars=yes,status=yes";try{const r=window.open(n,`mcp_auth_${this.serverUrlHash}`,a);this.onPopupWindow&&this.onPopupWindow(n,a,r),!r||r.closed||typeof r.closed>"u"?console.warn(`[${this.storageKeyPrefix}] Popup likely blocked by browser. Manual navigation might be required using the stored URL.`):(r.focus(),console.info(`[${this.storageKeyPrefix}] Redirecting to authorization URL in popup.`))}catch(r){console.error(`[${this.storageKeyPrefix}] Error opening popup window:`,r)}}getLastAttemptedAuthUrl(){const t=localStorage.getItem(this.getKey("last_auth_url"));return t?ru(t):null}clearStorage(){const t=`${this.storageKeyPrefix}_${this.serverUrlHash}_`,n=`${this.storageKeyPrefix}:state_`,a=[];let r=0;for(let s=0;s<localStorage.length;s++){const c=localStorage.key(s);if(c){if(c.startsWith(t))a.push(c);else if(c.startsWith(n))try{const u=localStorage.getItem(c);u&&JSON.parse(u).serverUrlHash===this.serverUrlHash&&a.push(c)}catch(u){console.warn(`[${this.storageKeyPrefix}] Error parsing state key ${c} during clearStorage:`,u)}}}return[...new Set(a)].forEach(s=>{localStorage.removeItem(s),r++}),r}hashString(t){let n=0;for(let a=0;a<t.length;a++){const r=t.charCodeAt(a);n=(n<<5)-n+r,n=n&n}return Math.abs(n).toString(16)}getKey(t){return`${this.storageKeyPrefix}_${this.serverUrlHash}_${t}`}},ze(Bu,"BrowserOAuthClientProvider"),Bu);async function ZT(){const e=new URLSearchParams(window.location.search),t=e.get("code"),n=e.get("state"),a=e.get("error"),r=e.get("error_description"),i="[mcp-callback]";console.log(`${i} Handling callback...`,{code:t,state:n,error:a,errorDescription:r});let s=null,c=null;const u=n?`mcp:auth:state_${n}`:null;try{if(a)throw new Error(`OAuth error: ${a} - ${r||"No description provided."}`);if(!t)throw new Error("Authorization code not found in callback query parameters.");if(!n||!u)throw new Error("State parameter not found or invalid in callback query parameters.");const d=localStorage.getItem(u);if(!d)throw new Error(`Invalid or expired state parameter "${n}". No matching state found in storage.`);try{c=JSON.parse(d)}catch{throw new Error("Failed to parse stored OAuth state.")}if(!c.expiry||c.expiry<Date.now())throw localStorage.removeItem(u),new Error("OAuth state has expired. Please try initiating authentication again.");if(!c.providerOptions)throw new Error("Stored state is missing required provider options.");const{serverUrl:m,...h}=c.providerOptions;console.log(`${i} Re-instantiating provider for server: ${m}`),s=new ub(m,h),console.log(`${i} Calling SDK auth() to exchange code...`);const g=new URL(m).origin,v=await ko(s,{serverUrl:g,authorizationCode:t});if(v==="AUTHORIZED")if(console.log(`${i} Authorization successful via SDK auth().`),c.flowType==="redirect"&&c.returnUrl)console.log(`${i} Redirect flow complete. Returning to: ${c.returnUrl}`),localStorage.removeItem(u),window.location.href=c.returnUrl;else if(window.opener&&!window.opener.closed)console.log(`${i} Popup flow complete. Notifying opener...`),window.opener.postMessage({type:"mcp_auth_callback",success:!0},window.location.origin),localStorage.removeItem(u),window.close();else{console.warn(`${i} No opener window or return URL detected. Redirecting to root.`),localStorage.removeItem(u);const S=window.location.pathname.split("/").filter(Boolean),y=S.length>0&&S[S.length-1]==="callback"?"/"+S.slice(0,-2).join("/"):"/";window.location.href=y||"/"}else throw console.warn(`${i} SDK auth() returned unexpected status: ${v}`),new Error(`Unexpected result from authentication library: ${v}`)}catch(d){console.error(`${i} Error during OAuth callback handling:`,d);const m=d instanceof Error?d.message:String(d);window.opener&&!window.opener.closed&&window.opener.postMessage({type:"mcp_auth_callback",success:!1,error:m},window.location.origin);try{document.body.innerHTML="";const h=document.createElement("div");h.style.fontFamily="sans-serif",h.style.padding="20px";const g=document.createElement("h1");g.textContent="Authentication Error",h.appendChild(g);const v=document.createElement("p");v.style.color="red",v.style.backgroundColor="#ffebeb",v.style.border="1px solid red",v.style.padding="10px",v.style.borderRadius="4px",v.textContent=m,h.appendChild(v);const w=document.createElement("p");w.textContent="You can close this window or ";const S=document.createElement("a");if(S.href="#",S.textContent="click here to close",S.onclick=y=>(y.preventDefault(),window.close(),!1),w.appendChild(S),w.appendChild(document.createTextNode(".")),h.appendChild(w),d instanceof Error&&d.stack){const y=document.createElement("pre");y.style.fontSize="0.8em",y.style.color="#555",y.style.marginTop="20px",y.style.whiteSpace="pre-wrap",y.textContent=d.stack,h.appendChild(y)}document.body.appendChild(h)}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")))}}ze(ZT,"onMcpAuthorization");var Dx={exports:{}},gt={};var OP;function Sie(){if(OP)return gt;OP=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),a=Symbol.for("react.strict_mode"),r=Symbol.for("react.profiler"),i=Symbol.for("react.consumer"),s=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),d=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),h=Symbol.for("react.activity"),g=Symbol.iterator;function v(j){return j===null||typeof j!="object"?null:(j=g&&j[g]||j["@@iterator"],typeof j=="function"?j:null)}var w={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},S=Object.assign,y={};function _(j,V,z){this.props=j,this.context=V,this.refs=y,this.updater=z||w}_.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||w}var C=k.prototype=new E;C.constructor=k,S(C,_.prototype),C.isPureReactComponent=!0;var R=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 te(j,V){return typeof j=="object"&&j!==null&&j.key!=null?K(""+j.key):V.toString(36)}function ae(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===""?"."+te(j,0):L,R($)?(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(R(j))for(var ie=0;ie<j.length;ie++)L=j[ie],F=X+te(L,ie),W+=B(L,V,z,F,$);else if(ie=v(j),typeof ie=="function")for(j=ie.call(j),ie=0;!(L=j.next()).done;)L=L.value,F=X+te(L,ie++),W+=B(L,V,z,F,$);else if(F==="object"){if(typeof j.then=="function")return B(ae(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=S({},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),ie=0;ie<W;ie++)X[ie]=arguments[ie+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 DP;function YT(){return DP||(DP=1,Dx.exports=Sie()),Dx.exports}var x=YT();const ue=$v(x),ud=Uq({__proto__:null,default:ue},[x]);function dE(e,t){if(!e)throw new Error(t)}ze(dE,"assert");var Eie=3e3,_ie=5e3;function qT(e){const{url:t,enabled:n=!0,clientName:a,clientUri:r,callbackUrl:i=typeof window<"u"?ru(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=Eie,transportType:g="auto",preventAutoAuth:v=!1,useRedirectFlow:w=!1,onPopupWindow:S,timeout:y=3e4,sseReadTimeout:_=3e5,wrapTransport:E,onNotification:k,samplingCallback:C,onElicitation:R}=e,[I,A]=x.useState("discovering"),[O,M]=x.useState([]),[U,H]=x.useState([]),[K,ee]=x.useState([]),[te,ae]=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),ie=x.useRef(!0),le=x.useRef(0),J=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((je,Fe,...pt)=>{const Qe=pt.length>0?`${Fe} ${pt.map(Tt=>JSON.stringify(Tt)).join(" ")}`:Fe;console[je](`[useMcp] ${Qe}`),ie.current&&z(Tt=>[...Tt.slice(-100),{level:je,message:Qe,timestamp:Date.now()}])},[]),Te=x.useCallback(async(je=!1)=>{if(je||ce("info","Disconnecting..."),X.current=!1,J.current&&clearTimeout(J.current),J.current=null,F.current)try{await F.current.closeSession("inspector-server")}catch(Fe){je||ce("warn","Error closing session:",Fe)}F.current=null,ie.current&&!je&&(A("discovering"),M([]),H([]),ee([]),ae([]),j(void 0),$(void 0))},[ce]),He=x.useCallback((je,Fe)=>{if(ce("error",je,Fe??""),ie.current){A("failed"),j(je);const pt=W.current?.getLastAttemptedAuthUrl();pt&&($(pt),ce("info","Manual authentication URL may be available.",pt))}X.current=!1,t&&Mi.getInstance().trackUseMcpConnection({url:t,transportType:g,success:!1,errorType:Fe?.name||"UnknownError",hasOAuth:!!W.current,hasSampling:!!C,hasElicitation:!!R}).catch(()=>{})},[ce,t,g,C,R]),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(!ie.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 ub(t,{storageKeyPrefix:s,clientName:a,clientUri:r,callbackUrl:i,preventAutoAuth:v,useRedirectFlow:w,onPopupWindow:S}),ce("debug","BrowserOAuthClientProvider initialized in connect.")),F.current||(F.current=new xie,ce("debug","BrowserMCPClient initialized in connect."));const je=ze(async(pt,Qe=!1)=>{ce("info",`Attempting connection with transport: ${pt}`);try{const Tt="inspector-server",nt={url:t,transport:pt==="sse"?"http":pt};if(u&&Object.keys(u).length>0&&(nt.headers=u),W.current){const wt=await W.current.tokens();wt?.access_token&&(nt.headers={...nt.headers,Authorization:`Bearer ${wt.access_token}`})}F.current.addServer(Tt,{...nt,authProvider:W.current,clientOptions:c,samplingCallback:C,elicitationCallback:R,wrapTransport:E?wt=>(console.log("[useMcp] Applying transport wrapper for server:",Tt,"url:",t),E(wt,t)):void 0});const Ie=await F.current.createSession(Tt,!1);k&&Ie.on("notification",k),await Ie.initialize(),ce("info","✅ Successfully connected to MCP server"),ce("info","Server info:",Ie.connector.serverInfo),ce("info","Server capabilities:",Ie.connector.serverCapabilities),console.log("[useMcp] Server info:",Ie.connector.serverInfo),console.log("[useMcp] Server capabilities:",Ie.connector.serverCapabilities),A("ready"),he.current=pt,Mi.getInstance().trackUseMcpConnection({url:t,transportType:pt,success:!0,hasOAuth:!!W.current,hasSampling:!!C,hasElicitation:!!R}).catch(()=>{}),M(Ie.connector.tools||[]);const $e=await Ie.connector.listAllResources();H($e.resources||[]);const Ve=await Ie.connector.listPrompts();ae(Ve.prompts||[]);const at=Ie.connector.serverInfo,dt=Ie.connector.serverCapabilities;return at&&(console.log("[useMcp] Server info:",at),Z(at)),dt&&(console.log("[useMcp] Server capabilities:",dt),re(dt)),"success"}catch(Tt){const nt=Tt,Ie=nt?.message||String(Tt);if(nt.code===401||Ie.includes("401")||Ie.includes("Unauthorized")){if(W.current){ce("info","Authentication required. OAuth provider available.");try{const{auth:$e}=await Qn(async()=>{const{auth:at}=await Promise.resolve().then(()=>NP);return{auth:at}},void 0),Ve=new URL(t).origin;$e(W.current,{serverUrl:Ve}).catch(()=>{}),setTimeout(()=>{if(ie.current){const at=W.current?.getLastAttemptedAuthUrl();at?($(at),ce("info","Manual authentication URL available:",at)):ce("warn","Could not generate authentication URL")}},100)}catch($e){ce("warn","Error generating auth URL:",$e)}return ie.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(Ie,nt instanceof Error?nt:new Error(String(nt))),"failed"}},"tryConnectWithTransport");let Fe="failed";if(g==="sse")ce("debug","Using SSE-only transport mode"),Fe=await je("sse");else if(g==="http")ce("debug","Using HTTP-only transport mode"),Fe=await je("http");else{ce("debug","Using auto transport mode (HTTP with SSE fallback)");const pt=await je("http");pt==="fallback"&&ie.current&&q.current!=="authenticating"?(ce("info","HTTP failed, attempting SSE fallback..."),Fe=await je("sse")):Fe=pt}(Fe==="success"||Fe==="failed"||Fe==="auth_redirect")&&(X.current=!1),ce("debug",`Connection sequence finished with status: ${Fe}`)},[ce,He,Te,t,s,a,r,i,c.name,c.version,u,g,v,w,S,n,y,_]),_e=x.useCallback(async(je,Fe,pt)=>{if(q.current!=="ready"||!F.current)throw new Error(`MCP client is not ready (current state: ${I}). Cannot call tool "${je}".`);ce("info",`Calling tool: ${je}`,Fe);const Qe=Date.now();try{const nt=F.current.getSession("inspector-server");if(!nt)throw new Error("No active session found");const Ie=await nt.connector.callTool(je,Fe||{},pt);return ce("info",`Tool "${je}" call successful:`,Ie),Mi.getInstance().trackUseMcpToolCall({toolName:je,success:!0,executionTimeMs:Date.now()-Qe}).catch(()=>{}),Ie}catch(Tt){throw ce("error",`Tool "${je}" call failed:`,Tt),Mi.getInstance().trackUseMcpToolCall({toolName:je,success:!1,errorType:Tt instanceof Error?Tt.name:"UnknownError",executionTimeMs:Date.now()-Qe}).catch(()=>{}),Tt}},[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 je=q.current;if(je==="failed")ce("info","Attempting to reconnect and authenticate via retry..."),Ue();else if(je==="pending_auth"){ce("info","Proceeding with authentication from pending state...");try{dE(W.current,"Auth Provider not available for manual auth"),dE(t,"Server URL is required for authentication"),ce("info","Clearing all OAuth state and initiating fresh flow...");const Fe=`${s}:${W.current.serverUrlHash}`;Object.keys(localStorage).forEach(nt=>{nt.startsWith(Fe)&&(ce("debug",`Removing stale OAuth key: ${nt}`),localStorage.removeItem(nt)),nt.startsWith(`${s}:state_`)&&(ce("debug",`Removing orphaned state: ${nt}`),localStorage.removeItem(nt))}),A("authenticating");const pt=new ub(t,{storageKeyPrefix:s,clientName:a,clientUri:r,callbackUrl:i,preventAutoAuth:!1,useRedirectFlow:w,onPopupWindow:S});W.current=pt,ce("info","Triggering fresh OAuth authorization...");const{auth:Qe}=await Qn(async()=>{const{auth:nt}=await Promise.resolve().then(()=>NP);return{auth:nt}},void 0),Tt=new URL(t).origin;Qe(pt,{serverUrl:Tt}).catch(nt=>{ce("info","OAuth flow initiated:",nt instanceof Error?nt.message:"Redirecting...")})}catch(Fe){if(!ie.current)return;A("pending_auth"),ce("error",`Manual authentication failed: ${Fe instanceof Error?Fe.message:String(Fe)}`)}}else if(je==="authenticating"){ce("warn","Already attempting authentication. Check for blocked popups or wait for timeout.");const Fe=W.current?.getLastAttemptedAuthUrl();Fe&&!L&&($(Fe),ce("info","Manual authentication URL retrieved:",Fe))}else ce("info",`Client not in a state requiring manual authentication trigger (state: ${je}). If needed, try disconnecting and reconnecting.`)},[ce,Ue,L,t,w,S,s,a,r,i]),Oe=x.useCallback(()=>{if(W.current){const je=W.current.clearStorage();ce("info",`Cleared ${je} item(s) from localStorage for ${t}.`),$(void 0),Te()}else ce("warn","Auth provider not initialized, cannot clear storage.")},[t,ce,Te]),Be=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 Fe=F.current.getSession("inspector-server");if(!Fe)throw new Error("No active session found");const pt=await Fe.connector.listAllResources();H(pt.resources||[]),ce("info","Resources listed successfully")}catch(je){throw ce("error","List resources failed:",je),je}},[I]),xe=x.useCallback(async je=>{if(q.current!=="ready"||!F.current)throw new Error(`MCP client is not ready (current state: ${I}). Cannot read resource.`);ce("info",`Reading resource: ${je}`);try{const pt=F.current.getSession("inspector-server");if(!pt)throw new Error("No active session found");const Qe=await pt.connector.readResource(je);return ce("info","Resource read successful:",Qe),Mi.getInstance().trackUseMcpResourceRead({resourceUri:je,success:!0}).catch(()=>{}),Qe}catch(Fe){throw ce("error","Resource read failed:",Fe),Mi.getInstance().trackUseMcpResourceRead({resourceUri:je,success:!1,errorType:Fe instanceof Error?Fe.name:"UnknownError"}).catch(()=>{}),Fe}},[I]),tt=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 Fe=F.current.getSession("inspector-server");if(!Fe)throw new Error("No active session found");const pt=await Fe.connector.listPrompts();ae(pt.prompts||[]),ce("info","Prompts listed successfully")}catch(je){throw ce("error","List prompts failed:",je),je}},[I]),it=x.useCallback(async(je,Fe)=>{if(q.current!=="ready"||!F.current)throw new Error(`MCP client is not ready (current state: ${I}). Cannot get prompt.`);ce("info",`Getting prompt: ${je}`,Fe);try{const Qe=F.current.getSession("inspector-server");if(!Qe)throw new Error("No active session found");const Tt=await Qe.connector.getPrompt(je,Fe||{});return ce("info",`Prompt "${je}" retrieved successfully:`,Tt),Tt}catch(pt){throw ce("error",`Prompt "${je}" retrieval failed:`,pt),pt}},[I]),ht=x.useRef(Se),Rt=x.useRef(He);return x.useEffect(()=>{ht.current=Se,Rt.current=He}),x.useEffect(()=>{const je=ze(Fe=>{Fe.origin===window.location.origin&&Fe.data?.type==="mcp_auth_callback"&&(ce("info","Received auth callback message.",Fe.data),J.current&&clearTimeout(J.current),J.current=null,Fe.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(()=>{ie.current&&(ce("debug","Initiating reconnection after successful auth callback."),ht.current())},100)):Rt.current(`Authentication failed in callback: ${Fe.data.error||"Unknown reason."}`))},"messageHandler");return window.addEventListener("message",je),ce("debug","Auth callback message listener added."),()=>{window.removeEventListener("message",je),ce("debug","Auth callback message listener removed."),J.current&&clearTimeout(J.current)}},[ce]),x.useEffect(()=>(ie.current=!0,!n||!t?(ce("debug",n?"No server URL provided, skipping connection.":"Connection disabled via enabled flag."),A("discovering"),()=>{ie.current=!1}):(ce("debug","useMcp mounted, initiating connection."),le.current=0,(!W.current||W.current.serverUrl!==t)&&(W.current=new ub(t,{storageKeyPrefix:s,clientName:a,clientUri:r,callbackUrl:i,preventAutoAuth:v,useRedirectFlow:w,onPopupWindow:S}),ce("debug","BrowserOAuthClientProvider initialized/updated on mount/option change.")),Se(),()=>{ie.current=!1,ce("debug","useMcp unmounting, disconnecting."),Te(!0)})),[t,n,s,i,a,r,c.name,c.version,w]),x.useEffect(()=>{let je=null;if(I==="failed"&&m&&le.current>0){const Fe=typeof m=="number"?m:_ie;ce("info",`Connection failed, auto-retrying in ${Fe}ms...`),je=setTimeout(()=>{ie.current&&q.current==="failed"&&Ue()},Fe)}return()=>{je&&clearTimeout(je)}},[I,m,Ue,ce]),{state:I,tools:O,resources:U,resourceTemplates:K,prompts:te,serverInfo:B,capabilities:G,error:ne,log:V,authUrl:L,client:F.current,callTool:_e,readResource:xe,listResources:Be,listPrompts:tt,getPrompt:it,retry:Ue,disconnect:Te,authenticate:fe,clearStorage:Oe}}ze(qT,"useMcp");var Hu,kie=(Hu=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}},ze(Hu,"ErrorBoundary"),Hu),Jf="openai:set_globals";function li(e){return x.useSyncExternalStore(t=>{const n=ze(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)}ze(li,"useOpenAiGlobal");function dd(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=ze(()=>{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"),w=li("userAgent"),S=li("locale"),y=x.useMemo(()=>typeof window<"u"&&window.__mcpPublicUrl?window.__mcpPublicUrl.replace(/\/mcp-use\/public$/,""):"",[]),[_,E]=x.useState(null);x.useEffect(()=>{d!==void 0&&E(d)},[d]);const k=x.useCallback(async(O,M)=>{if(!window.openai?.callTool)throw new Error("window.openai.callTool is not available");return window.openai.callTool(O,M)},[]),C=x.useCallback(async O=>{if(!window.openai?.sendFollowUpMessage)throw new Error("window.openai.sendFollowUpMessage is not available");return window.openai.sendFollowUpMessage({prompt:O})},[]),R=x.useCallback(O=>{if(!window.openai?.openExternal)throw new Error("window.openai.openExternal is not available");window.openai.openExternal({href:O})},[]),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:w||{device:{type:"desktop"},capabilities:{hover:!0,touch:!1}},locale:S||"en",mcp_url:y,callTool:k,sendFollowUpMessage:C,openExternal:R,requestDisplayMode:I,isAvailable:t}}ze(dd,"useWidget");function Tie(e){const{props:t}=dd(e);return t}ze(Tie,"useWidgetProps");function Nie(){const{theme:e}=dd();return e}ze(Nie,"useWidgetTheme");function Cie(e){const{state:t,setState:n}=dd();return x.useEffect(()=>{t===null&&e!==void 0&&window.openai?.setWidgetState&&n(e)},[]),[t,n]}ze(Cie,"useWidgetState");var jP=ze(({children:e})=>{const{theme:t,isAvailable:n}=dd();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=ze(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 jH({children:e,className:t="",position:n="top-right",attachTo:a,showLabels:r=!0,debugger:i=!1,viewControls:s=!1}){const{props:c,output:u,metadata:d,state:m,theme:h,displayMode:g,safeArea:v,maxHeight:w,userAgent:S,locale:y,isAvailable:_,callTool:E,sendFollowUpMessage:k,openExternal:C,requestDisplayMode:R,setState:I}=dd(),[A,O]=x.useState(!1),[M,U]=x.useState(!1),H=x.useRef(null),K=x.useRef(null),[ee,te]=x.useState([]),[ae,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/");x.useEffect(()=>{const xe=setTimeout(()=>{if(typeof window<"u"&&window.openai)try{const tt=Object.keys(window.openai);te(tt)}catch{te([])}else te([])},100);return()=>{clearTimeout(xe)}},[]);const X=h==="dark",ie=ze(()=>{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=ze(()=>{const tt=v?.insets?.top?Math.max(16,v.insets.top+8):16,it=v?.insets?.right?Math.max(16,v.insets.right+8):16,ht=v?.insets?.bottom?Math.max(16,v.insets.bottom+8):16,Rt=v?.insets?.left?Math.max(16,v.insets.left+8):16,je={};switch(n){case"top-left":je.top=`${tt}px`,je.left=`${Rt}px`;break;case"top-center":je.top=`${tt}px`;break;case"top-right":je.top=`${tt}px`,je.right=`${it}px`;break;case"center-left":je.left=`${Rt}px`;break;case"center-right":je.right=`${it}px`;break;case"bottom-left":je.bottom=`${ht}px`,je.left=`${Rt}px`;break;case"bottom-center":je.bottom=`${ht}px`;break;case"bottom-right":je.bottom=`${ht}px`,je.right=`${it}px`;break;default:je.top=`${tt}px`,je.right=`${it}px`;break}return je},"getPositionOffsetStyles");x.useEffect(()=>{if(!a)return;const xe=ze(()=>O(!0),"handleMouseEnter"),tt=ze(()=>O(!1),"handleMouseLeave");return a.addEventListener("mouseenter",xe),a.addEventListener("mouseleave",tt),()=>{a.removeEventListener("mouseenter",xe),a.removeEventListener("mouseleave",tt)}},[a]),x.useEffect(()=>{if(!M)return;const xe=ze(tt=>{K.current&&!K.current.contains(tt.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 J=ze(()=>{U(!M)},"handleToggleOverlay"),q=ze(async()=>{try{B("Calling tool...");const xe=re.trim()?JSON.parse(re):{},tt=await E(Z,xe);B(`Success: ${JSON.stringify(tt,null,2)}`)}catch(xe){B(`Error: ${xe.message}`)}},"handleCallTool"),se=ze(async()=>{try{B("Sending follow-up message..."),await k(j),B("Follow-up message sent successfully")}catch(xe){B(`Error: ${xe.message}`)}},"handleSendFollowUpMessage"),he=ze(()=>{try{C(z),B(`Opened external link: ${z}`)}catch(xe){B(`Error: ${xe.message}`)}},"handleOpenExternal"),ce=ze(async xe=>{try{B(`Requesting display mode: ${xe}...`);const tt=await R(xe);B(`Display mode granted: ${tt.mode}`)}catch(tt){B(`Error: ${tt.message}`)}},"handleRequestDisplayMode"),Te=ze(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=ze(async()=>{try{await R("fullscreen")}catch(xe){console.error("Failed to go fullscreen:",xe)}},"handleFullscreen"),Se=ze(async()=>{try{await R("pip")}catch(xe){console.error("Failed to go pip:",xe)}},"handlePip"),_e=ze(()=>{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=ze(({onClick:xe,label:tt,children:it})=>{const[ht,Rt]=x.useState(!1),je=_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:()=>Rt(!0),onMouseLeave:()=>Rt(!1),onClick:xe,"aria-label":tt},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"},it),r&&ue.createElement("span",{className:`${je.join(" ")} ${ht?"opacity-100":"opacity-0"}`},tt))},"IconButton"),fe=ze(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"),Oe=ze(xe=>xe?`${xe.device?.type||"unknown"}`:"N/A","formatUserAgent"),Be=ze(xe=>{if(!xe?.insets)return"N/A";const{top:tt,bottom:it,left:ht,right:Rt}=xe.insets;return`T:${tt} B:${it} L:${ht} R:${Rt}`},"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:ie().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:J,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"},w,"px")),ue.createElement("tr",{className:"border-b border-gray-700"},ue.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"User Agent"),ue.createElement("td",{className:"p-2"},Oe(S))),ue.createElement("tr",{className:"border-b border-gray-700"},ue.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Safe Area"),ue.createElement("td",{className:"p-2"},Be(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:Te,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)")),ae&&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:"),ae,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"))))))}ze(jH,"WidgetControls");function LH(){if(typeof window>"u")return"/";const t=window.location.pathname.match(/^(\/inspector\/api\/dev-widget\/[^/]+)/);return t?t[1]:"/"}ze(LH,"getBasename");var Rie=150,Aie=5;function Iie({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,w]=x.useState(!0);x.useEffect(()=>{let E=!0;return(async()=>{try{const k=await Qn(()=>import("./index-jb1lbUp7.js"),[]);E&&(m(()=>k.BrowserRouter),w(!1))}catch{E&&(g(new Error(`❌ react-router-dom not installed!
|
|
36
36
|
|
|
37
37
|
To use MCP widgets with McpUseProvider, you need to install:
|
|
38
38
|
|
|
@@ -90,7 +90,7 @@ Please change the parent <Route path="${E}"> to <Route path="${E==="/"?"*":`${E}
|
|
|
90
90
|
`)},wU=function(){var e=parseInt(document.body.getAttribute(hu)||"0",10);return isFinite(e)?e:0},Pue=function(){x.useEffect(function(){return document.body.setAttribute(hu,(wU()+1).toString()),function(){var e=wU()-1;e<=0?document.body.removeAttribute(hu):document.body.setAttribute(hu,e.toString())}},[])},Uue=function(e){var t=e.noRelative,n=e.noImportant,a=e.gapMode,r=a===void 0?"margin":a;Pue();var i=x.useMemo(function(){return Lue(r)},[r]);return x.createElement($ue,{styles:Mue(i,!t,r,n?"":"!important")})},xE=!1;if(typeof window<"u")try{var Fg=Object.defineProperty({},"passive",{get:function(){return xE=!0,!0}});window.addEventListener("test",Fg,Fg),window.removeEventListener("test",Fg,Fg)}catch{xE=!1}var Fc=xE?{passive:!1}:!1,zue=function(e){return e.tagName==="TEXTAREA"},n9=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!zue(e)&&n[t]==="visible")},Fue=function(e){return n9(e,"overflowY")},Bue=function(e){return n9(e,"overflowX")},xU=function(e,t){var n=t.ownerDocument,a=t;do{typeof ShadowRoot<"u"&&a instanceof ShadowRoot&&(a=a.host);var r=r9(e,a);if(r){var i=a9(e,a),s=i[1],c=i[2];if(s>c)return!0}a=a.parentNode}while(a&&a!==n.body);return!1},Hue=function(e){var t=e.scrollTop,n=e.scrollHeight,a=e.clientHeight;return[t,n,a]},Vue=function(e){var t=e.scrollLeft,n=e.scrollWidth,a=e.clientWidth;return[t,n,a]},r9=function(e,t){return e==="v"?Fue(t):Bue(t)},a9=function(e,t){return e==="v"?Hue(t):Vue(t)},Gue=function(e,t){return e==="h"&&t==="rtl"?-1:1},Wue=function(e,t,n,a,r){var i=Gue(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=a9(e,c),w=v[0],S=v[1],y=v[2],_=S-y-i*w;(w||_)&&r9(e,c)&&(h+=_,g+=w);var E=c.parentNode;c=E&&E.nodeType===Node.DOCUMENT_FRAGMENT_NODE?E.host:E}while(!u&&c!==document.body||u&&(t.contains(c)||t===c));return(m&&Math.abs(h)<1||!m&&Math.abs(g)<1)&&(d=!0),d},Bg=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},SU=function(e){return[e.deltaX,e.deltaY]},EU=function(e){return e&&"current"in e?e.current:e},Kue=function(e,t){return e[0]===t[0]&&e[1]===t[1]},Zue=function(e){return`
|
|
91
91
|
.block-interactivity-`.concat(e,` {pointer-events: none;}
|
|
92
92
|
.allow-interactivity-`).concat(e,` {pointer-events: all;}
|
|
93
|
-
`)},Yue=0,Bc=[];function que(e){var t=x.useRef([]),n=x.useRef([0,0]),a=x.useRef(),r=x.useState(Yue++)[0],i=x.useState(t9)[0],s=x.useRef(e);x.useEffect(function(){s.current=e},[e]),x.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(r));var S=bue([e.lockRef.current],(e.shards||[]).map(EU),!0).filter(Boolean);return S.forEach(function(y){return y.classList.add("allow-interactivity-".concat(r))}),function(){document.body.classList.remove("block-interactivity-".concat(r)),S.forEach(function(y){return y.classList.remove("allow-interactivity-".concat(r))})}}},[e.inert,e.lockRef.current,e.shards]);var c=x.useCallback(function(S,y){if("touches"in S&&S.touches.length===2||S.type==="wheel"&&S.ctrlKey)return!s.current.allowPinchZoom;var _=Bg(S),E=n.current,k="deltaX"in S?S.deltaX:E[0]-_[0],C="deltaY"in S?S.deltaY:E[1]-_[1],R,I=S.target,A=Math.abs(k)>Math.abs(C)?"h":"v";if("touches"in S&&A==="h"&&I.type==="range")return!1;var O=xU(A,I);if(!O)return!0;if(O?R=A:(R=A==="v"?"h":"v",O=xU(A,I)),!O)return!1;if(!a.current&&"changedTouches"in S&&(k||C)&&(a.current=R),!R)return!0;var M=a.current||R;return Wue(M,y,S,M==="h"?k:C)},[]),u=x.useCallback(function(S){var y=S;if(!(!Bc.length||Bc[Bc.length-1]!==i)){var _="deltaY"in y?SU(y):Bg(y),E=t.current.filter(function(R){return R.name===y.type&&(R.target===y.target||y.target===R.shadowParent)&&Kue(R.delta,_)})[0];if(E&&E.should){y.cancelable&&y.preventDefault();return}if(!E){var k=(s.current.shards||[]).map(EU).filter(Boolean).filter(function(R){return R.contains(y.target)}),C=k.length>0?c(y,k[0]):!s.current.noIsolation;C&&y.cancelable&&y.preventDefault()}}},[]),d=x.useCallback(function(S,y,_,E){var k={name:S,delta:y,target:_,should:E,shadowParent:Xue(_)};t.current.push(k),setTimeout(function(){t.current=t.current.filter(function(C){return C!==k})},1)},[]),m=x.useCallback(function(S){n.current=Bg(S),a.current=void 0},[]),h=x.useCallback(function(S){d(S.type,SU(S),S.target,c(S,e.lockRef.current))},[]),g=x.useCallback(function(S){d(S.type,Bg(S),S.target,c(S,e.lockRef.current))},[]);x.useEffect(function(){return Bc.push(i),e.setCallbacks({onScrollCapture:h,onWheelCapture:h,onTouchMoveCapture:g}),document.addEventListener("wheel",u,Fc),document.addEventListener("touchmove",u,Fc),document.addEventListener("touchstart",m,Fc),function(){Bc=Bc.filter(function(S){return S!==i}),document.removeEventListener("wheel",u,Fc),document.removeEventListener("touchmove",u,Fc),document.removeEventListener("touchstart",m,Fc)}},[]);var v=e.removeScrollBar,w=e.inert;return x.createElement(x.Fragment,null,w?x.createElement(i,{styles:Zue(r)}):null,v?x.createElement(Uue,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Xue(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const Jue=Tue(e9,que);var pm=x.forwardRef(function(e,t){return x.createElement(wy,Pi({},e,{ref:t,sideCar:Jue}))});pm.classNames=wy.classNames;var SE=["Enter"," "],Que=["ArrowDown","PageUp","Home"],i9=["ArrowUp","PageDown","End"],ede=[...Que,...i9],tde={ltr:[...SE,"ArrowRight"],rtl:[...SE,"ArrowLeft"]},nde={ltr:["ArrowLeft"],rtl:["ArrowRight"]},mm="Menu",[Ep,rde,ade]=rN(mm),[Yl,o9]=Ci(mm,[ade,Hs,WV]),xy=Hs(),s9=WV(),[ide,ql]=Yl(mm),[ode,hm]=Yl(mm),l9=e=>{const{__scopeMenu:t,open:n=!1,children:a,dir:r,onOpenChange:i,modal:s=!0}=e,c=xy(t),[u,d]=x.useState(null),m=x.useRef(!1),h=Gi(i),g=aN(r);return x.useEffect(()=>{const v=()=>{m.current=!0,document.addEventListener("pointerdown",w,{capture:!0,once:!0}),document.addEventListener("pointermove",w,{capture:!0,once:!0})},w=()=>m.current=!1;return document.addEventListener("keydown",v,{capture:!0}),()=>{document.removeEventListener("keydown",v,{capture:!0}),document.removeEventListener("pointerdown",w,{capture:!0}),document.removeEventListener("pointermove",w,{capture:!0})}},[]),f.jsx(gy,{...c,children:f.jsx(ide,{scope:t,open:n,onOpenChange:h,content:u,onContentChange:d,children:f.jsx(ode,{scope:t,onClose:x.useCallback(()=>h(!1),[h]),isUsingKeyboardRef:m,dir:g,modal:s,children:a})})})};l9.displayName=mm;var sde="MenuAnchor",mN=x.forwardRef((e,t)=>{const{__scopeMenu:n,...a}=e,r=xy(n);return f.jsx(dm,{...r,...a,ref:t})});mN.displayName=sde;var hN="MenuPortal",[lde,c9]=Yl(hN,{forceMount:void 0}),u9=e=>{const{__scopeMenu:t,forceMount:n,children:a,container:r}=e,i=ql(hN,t);return f.jsx(lde,{scope:t,forceMount:n,children:f.jsx(Ma,{present:n||i.open,children:f.jsx(xd,{asChild:!0,container:r,children:a})})})};u9.displayName=hN;var Ja="MenuContent",[cde,gN]=Yl(Ja),d9=x.forwardRef((e,t)=>{const n=c9(Ja,e.__scopeMenu),{forceMount:a=n.forceMount,...r}=e,i=ql(Ja,e.__scopeMenu),s=hm(Ja,e.__scopeMenu);return f.jsx(Ep.Provider,{scope:e.__scopeMenu,children:f.jsx(Ma,{present:a||i.open,children:f.jsx(Ep.Slot,{scope:e.__scopeMenu,children:s.modal?f.jsx(ude,{...r,ref:t}):f.jsx(dde,{...r,ref:t})})})})}),ude=x.forwardRef((e,t)=>{const n=ql(Ja,e.__scopeMenu),a=x.useRef(null),r=Qt(t,a);return x.useEffect(()=>{const i=a.current;if(i)return yy(i)},[]),f.jsx(bN,{...e,ref:r,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:Ge(e.onFocusOutside,i=>i.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),dde=x.forwardRef((e,t)=>{const n=ql(Ja,e.__scopeMenu);return f.jsx(bN,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),fde=Ml("MenuContent.ScrollLock"),bN=x.forwardRef((e,t)=>{const{__scopeMenu:n,loop:a=!1,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:s,disableOutsidePointerEvents:c,onEntryFocus:u,onEscapeKeyDown:d,onPointerDownOutside:m,onFocusOutside:h,onInteractOutside:g,onDismiss:v,disableOutsideScroll:w,...S}=e,y=ql(Ja,n),_=hm(Ja,n),E=xy(n),k=s9(n),C=rde(n),[R,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"),te=x.useRef(0),ae=w?pm:x.Fragment,B=w?{as:fde,allowPinchZoom:!0}:void 0,Z=re=>{const ne=U.current+re,j=C().filter(W=>!W.disabled),V=document.activeElement,z=j.find(W=>W.ref.current===V)?.textValue,L=j.map(W=>W.textValue),$=_de(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),[]),dy();const G=x.useCallback(re=>ee.current===K.current?.side&&Tde(re,K.current?.area),[]);return f.jsx(cde,{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(ae,{...B,children:f.jsx(cm,{asChild:!0,trapped:r,onMountAutoFocus:Ge(i,re=>{re.preventDefault(),A.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:s,children:f.jsx(vd,{asChild:!0,disableOutsidePointerEvents:c,onEscapeKeyDown:d,onPointerDownOutside:m,onFocusOutside:h,onInteractOutside:g,onDismiss:v,children:f.jsx(fue,{asChild:!0,...k,dir:_.dir,orientation:"vertical",loop:a,currentTabStopId:R,onCurrentTabStopIdChange:I,onEntryFocus:Ge(u,re=>{_.isUsingKeyboardRef.current||re.preventDefault()}),preventScrollOnEntryFocus:!0,children:f.jsx(by,{role:"menu","aria-orientation":"vertical","data-state":N9(y.open),"data-radix-menu-content":"",dir:_.dir,...E,...S,ref:O,style:{outline:"none",...S.style},onKeyDown:Ge(S.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||!ede.includes(re.key))return;re.preventDefault();const F=C().filter(W=>!W.disabled).map(W=>W.ref.current);i9.includes(re.key)&&F.reverse(),Sde(F)}),onBlur:Ge(e.onBlur,re=>{re.currentTarget.contains(re.target)||(window.clearTimeout(M.current),U.current="")}),onPointerMove:Ge(e.onPointerMove,_p(re=>{const ne=re.target,j=te.current!==re.clientX;if(re.currentTarget.contains(ne)&&j){const V=re.clientX>te.current?"right":"left";ee.current=V,te.current=re.clientX}}))})})})})})})});d9.displayName=Ja;var pde="MenuGroup",vN=x.forwardRef((e,t)=>{const{__scopeMenu:n,...a}=e;return f.jsx(Et.div,{role:"group",...a,ref:t})});vN.displayName=pde;var mde="MenuLabel",f9=x.forwardRef((e,t)=>{const{__scopeMenu:n,...a}=e;return f.jsx(Et.div,{...a,ref:t})});f9.displayName=mde;var rv="MenuItem",_U="menu.itemSelect",Sy=x.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:a,...r}=e,i=x.useRef(null),s=hm(rv,e.__scopeMenu),c=gN(rv,e.__scopeMenu),u=Qt(t,i),d=x.useRef(!1),m=()=>{const h=i.current;if(!n&&h){const g=new CustomEvent(_U,{bubbles:!0,cancelable:!0});h.addEventListener(_U,v=>a?.(v),{once:!0}),wV(h,g),g.defaultPrevented?d.current=!1:s.onClose()}};return f.jsx(p9,{...r,ref:u,disabled:n,onClick:Ge(e.onClick,m),onPointerDown:h=>{e.onPointerDown?.(h),d.current=!0},onPointerUp:Ge(e.onPointerUp,h=>{d.current||h.currentTarget?.click()}),onKeyDown:Ge(e.onKeyDown,h=>{const g=c.searchRef.current!=="";n||g&&h.key===" "||SE.includes(h.key)&&(h.currentTarget.click(),h.preventDefault())})})});Sy.displayName=rv;var p9=x.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:a=!1,textValue:r,...i}=e,s=gN(rv,n),c=s9(n),u=x.useRef(null),d=Qt(t,u),[m,h]=x.useState(!1),[g,v]=x.useState("");return x.useEffect(()=>{const w=u.current;w&&v((w.textContent??"").trim())},[i.children]),f.jsx(Ep.ItemSlot,{scope:n,disabled:a,textValue:r??g,children:f.jsx(pue,{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:Ge(e.onPointerMove,_p(w=>{a?s.onItemLeave(w):(s.onItemEnter(w),w.defaultPrevented||w.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Ge(e.onPointerLeave,_p(w=>s.onItemLeave(w))),onFocus:Ge(e.onFocus,()=>h(!0)),onBlur:Ge(e.onBlur,()=>h(!1))})})})}),hde="MenuCheckboxItem",m9=x.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:a,...r}=e;return f.jsx(y9,{scope:e.__scopeMenu,checked:n,children:f.jsx(Sy,{role:"menuitemcheckbox","aria-checked":av(n)?"mixed":n,...r,ref:t,"data-state":wN(n),onSelect:Ge(r.onSelect,()=>a?.(av(n)?!0:!n),{checkForDefaultPrevented:!1})})})});m9.displayName=hde;var h9="MenuRadioGroup",[gde,bde]=Yl(h9,{value:void 0,onValueChange:()=>{}}),g9=x.forwardRef((e,t)=>{const{value:n,onValueChange:a,...r}=e,i=Gi(a);return f.jsx(gde,{scope:e.__scopeMenu,value:n,onValueChange:i,children:f.jsx(vN,{...r,ref:t})})});g9.displayName=h9;var b9="MenuRadioItem",v9=x.forwardRef((e,t)=>{const{value:n,...a}=e,r=bde(b9,e.__scopeMenu),i=n===r.value;return f.jsx(y9,{scope:e.__scopeMenu,checked:i,children:f.jsx(Sy,{role:"menuitemradio","aria-checked":i,...a,ref:t,"data-state":wN(i),onSelect:Ge(a.onSelect,()=>r.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});v9.displayName=b9;var yN="MenuItemIndicator",[y9,vde]=Yl(yN,{checked:!1}),w9=x.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:a,...r}=e,i=vde(yN,n);return f.jsx(Ma,{present:a||av(i.checked)||i.checked===!0,children:f.jsx(Et.span,{...r,ref:t,"data-state":wN(i.checked)})})});w9.displayName=yN;var yde="MenuSeparator",x9=x.forwardRef((e,t)=>{const{__scopeMenu:n,...a}=e;return f.jsx(Et.div,{role:"separator","aria-orientation":"horizontal",...a,ref:t})});x9.displayName=yde;var wde="MenuArrow",S9=x.forwardRef((e,t)=>{const{__scopeMenu:n,...a}=e,r=xy(n);return f.jsx(vy,{...r,...a,ref:t})});S9.displayName=wde;var xde="MenuSub",[Zke,E9]=Yl(xde),Ff="MenuSubTrigger",_9=x.forwardRef((e,t)=>{const n=ql(Ff,e.__scopeMenu),a=hm(Ff,e.__scopeMenu),r=E9(Ff,e.__scopeMenu),i=gN(Ff,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(mN,{asChild:!0,...d,children:f.jsx(p9,{id:r.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":r.contentId,"data-state":N9(n.open),...e,ref:Vi(t,r.onTriggerChange),onClick:h=>{e.onClick?.(h),!(e.disabled||h.defaultPrevented)&&(h.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:Ge(e.onPointerMove,_p(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:Ge(e.onPointerLeave,_p(h=>{m();const g=n.content?.getBoundingClientRect();if(g){const v=n.content?.dataset.side,w=v==="right",S=w?-5:5,y=g[w?"left":"right"],_=g[w?"right":"left"];i.onPointerGraceIntentChange({area:[{x:h.clientX+S,y:h.clientY},{x:y,y:g.top},{x:_,y:g.top},{x:_,y:g.bottom},{x:y,y:g.bottom}],side:v}),window.clearTimeout(c.current),c.current=window.setTimeout(()=>i.onPointerGraceIntentChange(null),300)}else{if(i.onTriggerLeave(h),h.defaultPrevented)return;i.onPointerGraceIntentChange(null)}})),onKeyDown:Ge(e.onKeyDown,h=>{const g=i.searchRef.current!=="";e.disabled||g&&h.key===" "||tde[a.dir].includes(h.key)&&(n.onOpenChange(!0),n.content?.focus(),h.preventDefault())})})})});_9.displayName=Ff;var k9="MenuSubContent",T9=x.forwardRef((e,t)=>{const n=c9(Ja,e.__scopeMenu),{forceMount:a=n.forceMount,...r}=e,i=ql(Ja,e.__scopeMenu),s=hm(Ja,e.__scopeMenu),c=E9(k9,e.__scopeMenu),u=x.useRef(null),d=Qt(t,u);return f.jsx(Ep.Provider,{scope:e.__scopeMenu,children:f.jsx(Ma,{present:a||i.open,children:f.jsx(Ep.Slot,{scope:e.__scopeMenu,children:f.jsx(bN,{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:Ge(e.onFocusOutside,m=>{m.target!==c.trigger&&i.onOpenChange(!1)}),onEscapeKeyDown:Ge(e.onEscapeKeyDown,m=>{s.onClose(),m.preventDefault()}),onKeyDown:Ge(e.onKeyDown,m=>{const h=m.currentTarget.contains(m.target),g=nde[s.dir].includes(m.key);h&&g&&(i.onOpenChange(!1),c.trigger?.focus(),m.preventDefault())})})})})})});T9.displayName=k9;function N9(e){return e?"open":"closed"}function av(e){return e==="indeterminate"}function wN(e){return av(e)?"indeterminate":e?"checked":"unchecked"}function Sde(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function Ede(e,t){return e.map((n,a)=>e[(t+a)%e.length])}function _de(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=Ede(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 kde(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 Tde(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return kde(n,t)}function _p(e){return t=>t.pointerType==="mouse"?e(t):void 0}var Nde=l9,Cde=mN,Rde=u9,Ade=d9,Ide=vN,Ode=f9,Dde=Sy,jde=m9,Lde=g9,$de=v9,Mde=w9,Pde=x9,Ude=S9,zde=_9,Fde=T9,Ey="DropdownMenu",[Bde]=Ci(Ey,[o9]),ra=o9(),[Hde,C9]=Bde(Ey),R9=e=>{const{__scopeDropdownMenu:t,children:n,dir:a,open:r,defaultOpen:i,onOpenChange:s,modal:c=!0}=e,u=ra(t),d=x.useRef(null),[m,h]=jo({prop:r,defaultProp:i??!1,onChange:s,caller:Ey});return f.jsx(Hde,{scope:t,triggerId:Dr(),triggerRef:d,contentId:Dr(),open:m,onOpenChange:h,onOpenToggle:x.useCallback(()=>h(g=>!g),[h]),modal:c,children:f.jsx(Nde,{...u,open:m,onOpenChange:h,dir:a,modal:c,children:n})})};R9.displayName=Ey;var A9="DropdownMenuTrigger",I9=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:a=!1,...r}=e,i=C9(A9,n),s=ra(n);return f.jsx(Cde,{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:Vi(t,i.triggerRef),onPointerDown:Ge(e.onPointerDown,c=>{!a&&c.button===0&&c.ctrlKey===!1&&(i.onOpenToggle(),i.open||c.preventDefault())}),onKeyDown:Ge(e.onKeyDown,c=>{a||(["Enter"," "].includes(c.key)&&i.onOpenToggle(),c.key==="ArrowDown"&&i.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(c.key)&&c.preventDefault())})})})});I9.displayName=A9;var Vde="DropdownMenuPortal",O9=e=>{const{__scopeDropdownMenu:t,...n}=e,a=ra(t);return f.jsx(Rde,{...a,...n})};O9.displayName=Vde;var D9="DropdownMenuContent",j9=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=C9(D9,n),i=ra(n),s=x.useRef(!1);return f.jsx(Ade,{id:r.contentId,"aria-labelledby":r.triggerId,...i,...a,ref:t,onCloseAutoFocus:Ge(e.onCloseAutoFocus,c=>{s.current||r.triggerRef.current?.focus(),s.current=!1,c.preventDefault()}),onInteractOutside:Ge(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)"}})});j9.displayName=D9;var Gde="DropdownMenuGroup",Wde=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ra(n);return f.jsx(Ide,{...r,...a,ref:t})});Wde.displayName=Gde;var Kde="DropdownMenuLabel",L9=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ra(n);return f.jsx(Ode,{...r,...a,ref:t})});L9.displayName=Kde;var Zde="DropdownMenuItem",$9=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ra(n);return f.jsx(Dde,{...r,...a,ref:t})});$9.displayName=Zde;var Yde="DropdownMenuCheckboxItem",M9=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ra(n);return f.jsx(jde,{...r,...a,ref:t})});M9.displayName=Yde;var qde="DropdownMenuRadioGroup",Xde=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ra(n);return f.jsx(Lde,{...r,...a,ref:t})});Xde.displayName=qde;var Jde="DropdownMenuRadioItem",P9=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ra(n);return f.jsx($de,{...r,...a,ref:t})});P9.displayName=Jde;var Qde="DropdownMenuItemIndicator",efe=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ra(n);return f.jsx(Mde,{...r,...a,ref:t})});efe.displayName=Qde;var tfe="DropdownMenuSeparator",U9=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ra(n);return f.jsx(Pde,{...r,...a,ref:t})});U9.displayName=tfe;var nfe="DropdownMenuArrow",rfe=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ra(n);return f.jsx(Ude,{...r,...a,ref:t})});rfe.displayName=nfe;var afe="DropdownMenuSubTrigger",z9=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ra(n);return f.jsx(zde,{...r,...a,ref:t})});z9.displayName=afe;var ife="DropdownMenuSubContent",F9=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ra(n);return f.jsx(Fde,{...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)"}})});F9.displayName=ife;var ofe=R9,sfe=I9,lfe=O9,B9=j9,H9=L9,V9=$9,cfe=M9,ufe=P9,G9=U9,dfe=z9,ffe=F9;const EE=ofe,_E=sfe;dfe.displayName;ffe.displayName;function iv({ref:e,className:t,sideOffset:n=4,...a}){return f.jsx(lfe,{children:f.jsx(B9,{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})})}iv.displayName=B9.displayName;function To({ref:e,className:t,inset:n,...a}){return f.jsx(V9,{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})}To.displayName=V9.displayName;cfe.displayName;ufe.displayName;function kE({ref:e,className:t,inset:n,...a}){return f.jsx(H9,{ref:e,className:De("px-2 py-1.5 text-sm font-semibold",n&&"pl-8",t),...a})}kE.displayName=H9.displayName;function Bf({ref:e,className:t,...n}){return f.jsx(G9,{ref:e,className:De("-mx-1 my-1 h-px bg-muted",t),...n})}Bf.displayName=G9.displayName;var pfe=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Ho=pfe.reduce((e,t)=>{const n=nV(`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}},{}),mfe="Label",W9=x.forwardRef((e,t)=>f.jsx(Ho.label,{...e,ref:t,onMouseDown:n=>{n.target.closest("button, input, select, textarea")||(e.onMouseDown?.(n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));W9.displayName=mfe;var hfe=W9;function Kt({className:e,...t}){return f.jsx(hfe,{"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 Sd({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 K9({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 xN(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 _y="Switch",[gfe]=Ci(_y),[bfe,vfe]=gfe(_y),Z9=x.forwardRef((e,t)=>{const{__scopeSwitch:n,name:a,checked:r,defaultChecked:i,required:s,disabled:c,value:u="on",onCheckedChange:d,form:m,...h}=e,[g,v]=x.useState(null),w=Qt(t,k=>v(k)),S=x.useRef(!1),y=g?m||!!g.closest("form"):!0,[_,E]=jo({prop:r,defaultProp:i??!1,onChange:d,caller:_y});return f.jsxs(bfe,{scope:n,checked:_,disabled:c,children:[f.jsx(Et.button,{type:"button",role:"switch","aria-checked":_,"aria-required":s,"data-state":J9(_),"data-disabled":c?"":void 0,disabled:c,value:u,...h,ref:w,onClick:Ge(e.onClick,k=>{E(C=>!C),y&&(S.current=k.isPropagationStopped(),S.current||k.stopPropagation())})}),y&&f.jsx(X9,{control:g,bubbles:!S.current,name:a,value:u,checked:_,required:s,disabled:c,form:m,style:{transform:"translateX(-100%)"}})]})});Z9.displayName=_y;var Y9="SwitchThumb",q9=x.forwardRef((e,t)=>{const{__scopeSwitch:n,...a}=e,r=vfe(Y9,n);return f.jsx(Et.span,{"data-state":J9(r.checked),"data-disabled":r.disabled?"":void 0,...a,ref:t})});q9.displayName=Y9;var yfe="SwitchBubbleInput",X9=x.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:a=!0,...r},i)=>{const s=x.useRef(null),c=Qt(s,i),u=xN(n),d=dN(t);return x.useEffect(()=>{const m=s.current;if(!m)return;const h=window.HTMLInputElement.prototype,v=Object.getOwnPropertyDescriptor(h,"checked").set;if(u!==n&&v){const w=new Event("click",{bubbles:a});v.call(m,n),m.dispatchEvent(w)}},[u,n,a]),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}})});X9.displayName=yfe;function J9(e){return e?"checked":"unchecked"}var Q9=Z9,wfe=q9;function ky({ref:e,className:t,...n}){return f.jsx(Q9,{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(wfe,{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")})})}ky.displayName=Q9.displayName;var e8=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"}),xfe="VisuallyHidden",t8=x.forwardRef((e,t)=>f.jsx(Et.span,{...e,ref:t,style:{...e8,...e.style}}));t8.displayName=xfe;var Sfe=t8,[Ty]=Ci("Tooltip",[Hs]),Ny=Hs(),n8="TooltipProvider",Efe=700,TE="tooltip.open",[_fe,SN]=Ty(n8),r8=e=>{const{__scopeTooltip:t,delayDuration:n=Efe,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(_fe,{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})};r8.displayName=n8;var kp="Tooltip",[kfe,gm]=Ty(kp),a8=e=>{const{__scopeTooltip:t,children:n,open:a,defaultOpen:r,onOpenChange:i,disableHoverableContent:s,delayDuration:c}=e,u=SN(kp,e.__scopeTooltip),d=Ny(t),[m,h]=x.useState(null),g=Dr(),v=x.useRef(0),w=s??u.disableHoverableContent,S=c??u.delayDuration,y=x.useRef(!1),[_,E]=jo({prop:a,defaultProp:r??!1,onChange:A=>{A?(u.onOpen(),document.dispatchEvent(new CustomEvent(TE))):u.onClose(),i?.(A)},caller:kp}),k=x.useMemo(()=>_?y.current?"delayed-open":"instant-open":"closed",[_]),C=x.useCallback(()=>{window.clearTimeout(v.current),v.current=0,y.current=!1,E(!0)},[E]),R=x.useCallback(()=>{window.clearTimeout(v.current),v.current=0,E(!1)},[E]),I=x.useCallback(()=>{window.clearTimeout(v.current),v.current=window.setTimeout(()=>{y.current=!0,E(!0),v.current=0},S)},[S,E]);return x.useEffect(()=>()=>{v.current&&(window.clearTimeout(v.current),v.current=0)},[]),f.jsx(gy,{...d,children:f.jsx(kfe,{scope:t,contentId:g,open:_,stateAttribute:k,trigger:m,onTriggerChange:h,onTriggerEnter:x.useCallback(()=>{u.isOpenDelayedRef.current?I():C()},[u.isOpenDelayedRef,I,C]),onTriggerLeave:x.useCallback(()=>{w?R():(window.clearTimeout(v.current),v.current=0)},[R,w]),onOpen:C,onClose:R,disableHoverableContent:w,children:n})})};a8.displayName=kp;var NE="TooltipTrigger",i8=x.forwardRef((e,t)=>{const{__scopeTooltip:n,...a}=e,r=gm(NE,n),i=SN(NE,n),s=Ny(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(dm,{asChild:!0,...s,children:f.jsx(Et.button,{"aria-describedby":r.open?r.contentId:void 0,"data-state":r.stateAttribute,...a,ref:u,onPointerMove:Ge(e.onPointerMove,g=>{g.pointerType!=="touch"&&!m.current&&!i.isPointerInTransitRef.current&&(r.onTriggerEnter(),m.current=!0)}),onPointerLeave:Ge(e.onPointerLeave,()=>{r.onTriggerLeave(),m.current=!1}),onPointerDown:Ge(e.onPointerDown,()=>{r.open&&r.onClose(),d.current=!0,document.addEventListener("pointerup",h,{once:!0})}),onFocus:Ge(e.onFocus,()=>{d.current||r.onOpen()}),onBlur:Ge(e.onBlur,r.onClose),onClick:Ge(e.onClick,r.onClose)})})});i8.displayName=NE;var EN="TooltipPortal",[Tfe,Nfe]=Ty(EN,{forceMount:void 0}),o8=e=>{const{__scopeTooltip:t,forceMount:n,children:a,container:r}=e,i=gm(EN,t);return f.jsx(Tfe,{scope:t,forceMount:n,children:f.jsx(Ma,{present:n||i.open,children:f.jsx(xd,{asChild:!0,container:r,children:a})})})};o8.displayName=EN;var Ju="TooltipContent",s8=x.forwardRef((e,t)=>{const n=Nfe(Ju,e.__scopeTooltip),{forceMount:a=n.forceMount,side:r="top",...i}=e,s=gm(Ju,e.__scopeTooltip);return f.jsx(Ma,{present:a||s.open,children:s.disableHoverableContent?f.jsx(l8,{side:r,...i,ref:t}):f.jsx(Cfe,{side:r,...i,ref:t})})}),Cfe=x.forwardRef((e,t)=>{const n=gm(Ju,e.__scopeTooltip),a=SN(Ju,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((w,S)=>{const y=w.currentTarget,_={x:w.clientX,y:w.clientY},E=Ofe(_,y.getBoundingClientRect()),k=Dfe(_,E),C=jfe(S.getBoundingClientRect()),R=$fe([...k,...C]);c(R),h(!0)},[h]);return x.useEffect(()=>()=>g(),[g]),x.useEffect(()=>{if(u&&m){const w=y=>v(y,m),S=y=>v(y,u);return u.addEventListener("pointerleave",w),m.addEventListener("pointerleave",S),()=>{u.removeEventListener("pointerleave",w),m.removeEventListener("pointerleave",S)}}},[u,m,v,g]),x.useEffect(()=>{if(s){const w=S=>{const y=S.target,_={x:S.clientX,y:S.clientY},E=u?.contains(y)||m?.contains(y),k=!Lfe(_,s);E?g():k&&(g(),d())};return document.addEventListener("pointermove",w),()=>document.removeEventListener("pointermove",w)}},[u,m,s,d,g]),f.jsx(l8,{...e,ref:i})}),[Rfe,Afe]=Ty(kp,{isInside:!1}),Ife=dle("TooltipContent"),l8=x.forwardRef((e,t)=>{const{__scopeTooltip:n,children:a,"aria-label":r,onEscapeKeyDown:i,onPointerDownOutside:s,...c}=e,u=gm(Ju,n),d=Ny(n),{onClose:m}=u;return x.useEffect(()=>(document.addEventListener(TE,m),()=>document.removeEventListener(TE,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(vd,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:i,onPointerDownOutside:s,onFocusOutside:h=>h.preventDefault(),onDismiss:m,children:f.jsxs(by,{"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(Ife,{children:a}),f.jsx(Rfe,{scope:n,isInside:!0,children:f.jsx(Sfe,{id:u.contentId,role:"tooltip",children:r||a})})]})})});s8.displayName=Ju;var c8="TooltipArrow",u8=x.forwardRef((e,t)=>{const{__scopeTooltip:n,...a}=e,r=Ny(n);return Afe(c8,n).isInside?null:f.jsx(vy,{...r,...a,ref:t})});u8.displayName=c8;function Ofe(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 Dfe(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 jfe(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 Lfe(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 $fe(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),Mfe(t)}function Mfe(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 Pfe=r8,Ufe=a8,zfe=i8,Ffe=o8,Bfe=s8,Hfe=u8;function d8({delayDuration:e=0,...t}){return f.jsx(Pfe,{"data-slot":"tooltip-provider",delayDuration:e,...t})}function Dt({...e}){return f.jsx(d8,{children:f.jsx(Ufe,{"data-slot":"tooltip",...e})})}function jt({...e}){return f.jsx(zfe,{"data-slot":"tooltip-trigger",...e})}function Lt({className:e,sideOffset:t=0,children:n,...a}){return f.jsx(Ffe,{children:f.jsxs(Bfe,{"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(Hfe,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}class Vfe{name="mcp_inspector_open";properties;constructor(t){this.properties={server_url:t.serverUrl,connection_count:t.connectionCount}}}class kU{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 TU{name="mcp_resource_read";properties;constructor(t){this.properties={resource_uri:t.resourceUri,server_id:t.serverId,success:t.success,error:t.error}}}class NU{name="mcp_prompt_call";properties;constructor(t){this.properties={prompt_name:t.promptName,server_id:t.serverId,success:t.success,error:t.error}}}class CU{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 Gfe{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 Wfe{name="mcp_server_removed";properties;constructor(t){this.properties={server_id:t.serverId}}}class Kfe{name="mcp_command_palette_open";properties;constructor(t){this.properties={trigger:t.trigger}}}class Zfe{name="mcp_tool_saved";properties;constructor(t){this.properties={tool_name:t.toolName,server_id:t.serverId}}}function Jx(){try{return"0.13.0-canary.5"}catch{return"0.0.0"}}var Yfe={};function Qx(){try{return typeof window<"u"&&typeof document<"u"}catch{return!1}}class RU{endpoint;timeout;constructor(t,n=3e3){this.endpoint=t,this.timeout=n}async logEvent(t){try{const n=new AbortController,a=setTimeout(()=>n.abort(),this.timeout),r=await fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t),signal:n.signal});if(clearTimeout(a),!r.ok)throw new Error(`HTTP error! status: ${r.status}`)}catch{}}}function bs(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=Qx(),n=this.isTelemetryDisabled();if(this._source=this.getStoredSource()||"inspector",n)this._posthogClient=null,this._scarfClient=null;else if(!t)this._posthogClient=null,this._scarfClient=null;else{try{this._posthogClient=new RU(this.POSTHOG_PROXY_URL,3e3)}catch{this._posthogClient=null}try{this._scarfClient=new RU(this.SCARF_PROXY_URL,3e3)}catch{this._scarfClient=null}}}isTelemetryDisabled(){return typeof localStorage<"u"&&localStorage.getItem(bs("disabled"))==="true"||typeof process<"u"&&Yfe?.MCP_USE_ANONYMIZED_TELEMETRY==="false"}getStoredSource(){return typeof localStorage<"u"?localStorage.getItem(bs("source")):null}static getInstance(){return yr.instance||(yr.instance=new yr),yr.instance}setSource(t){this._source=t,typeof localStorage<"u"&&localStorage.setItem(bs("source"),t)}getSource(){return this._source}get userId(){if(this._currUserId)return this._currUserId;if(!Qx())return this._currUserId=this.UNKNOWN_USER_ID,this._currUserId;try{const t=localStorage.getItem(bs("user_id"));if(t)this._currUserId=t;else{const n=this.generateUserId();localStorage.setItem(bs("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:Jx(),language:"typescript",source:this._source,package:"inspector"}};await this._posthogClient.logEvent(n)}catch{}if(this._scarfClient)try{const n={};n.mcp_use_version=Jx(),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&&Qx())try{const n=Jx();let a=!1,r=!1;const i=localStorage.getItem(bs("download_version"));if(i?n>i&&(a=!0,r=!1,localStorage.setItem(bs("download_version"),n)):(a=!0,r=!0,localStorage.setItem(bs("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 Vfe(t);await this.capture(n)}}const qfe={model:"stub-model",stopReason:"endTurn",role:"assistant",content:{type:"text",text:"positive"}};function Xfe({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(qfe)},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 Jfe({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 Hg=()=>{},Vg=()=>{},Gg=()=>{},Wg=()=>{},f8=x.createContext(null);function _N(){const e=x.use(f8);if(!e)throw new Error("useMcpContext must be used within a McpProvider");return e}function Qfe({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,w]=x.useState([]),S=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,C]=x.useState(!1),R=x.useRef(!1);x.useEffect(()=>{typeof window<"u"&&!R.current&&(R.current=!0,Qn(()=>import("./transport-wrapper-browser-BI4dDu3b.js"),[]).then(L=>{E.current=L.wrapTransportForLogging,C(!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([])},[]),te=x.useCallback(L=>{U($=>{const F=[L,...$];return F.length>O?F.slice(0,O):F})},[]),ae=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,$)=>{w(F=>{const W=F.find(X=>X.id===L);return W?(W.resolve($),F.filter(X=>X.id!==L)):F})},[]),G=x.useCallback((L,$)=>{w(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(ie=>[...ie,X]),typeof window<"u"&&Qn(async()=>{const{toast:ie}=await Promise.resolve().then(()=>$U);return{toast:ie}},void 0).then(({toast:ie})=>{const le=ie(f.jsx(Xfe,{requestId:W,serverName:t,onViewDetails:()=>{const J=new globalThis.CustomEvent("navigate-to-sampling",{detail:{requestId:W}});window.dispatchEvent(J),ie.dismiss(le)},onApprove:J=>{h(q=>{const se=q.find(he=>he.id===W);return se?(se.resolve(J),ie.success("Sampling request approved"),q.filter(he=>he.id!==W)):q}),ie.dismiss(le)},onDeny:()=>{h(J=>{const q=J.find(se=>se.id===W);return q?(q.reject(new Error("User denied sampling request from toast")),ie.error("Sampling request denied"),J.filter(se=>se.id!==W)):J}),ie.dismiss(le)}}),{duration:5e3})})}),[t]),ne=x.useCallback(async L=>new Promise(($,F)=>{const W=`elicitation-${S.current++}`,X={id:W,request:L,timestamp:Date.now(),serverName:t,resolve:$,reject:F};w(ie=>[...ie,X]),typeof window<"u"&&Qn(async()=>{const{toast:ie}=await Promise.resolve().then(()=>$U);return{toast:ie}},void 0).then(({toast:ie})=>{const le=ie(f.jsx(Jfe,{requestId:W,serverName:t,mode:L.mode||"form",message:L.message,url:L.mode==="url"?L.url:void 0,onViewDetails:()=>{const J=new globalThis.CustomEvent("navigate-to-elicitation",{detail:{requestId:W}});window.dispatchEvent(J),ie.dismiss(le)},onOpenUrl:L.mode==="url"?()=>{window.open(L.url,"_blank"),ie.dismiss(le)}:void 0,onCancel:()=>{w(J=>{const q=J.find(se=>se.id===W);return q?(q.reject(new Error("User cancelled elicitation request from toast")),ie.error("Elicitation request cancelled"),J.filter(se=>se.id!==W)):J}),ie.dismiss(le)}}),{duration:5e3})})}),[t]),j=qT({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=>{te({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:ae,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:ae,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,ae,B,_,Z,G]),null}function epe({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:Hg,rejectSampling:Vg,pendingElicitationRequests:[],approveElicitation:Gg,rejectElicitation:Wg,callTool:async()=>{},readResource:async()=>{},listPrompts:async()=>{},getPrompt:async()=>{},authenticate:()=>{},retry:()=>{},clearStorage:()=>{},disconnect:()=>{},client:null}))))}const _=localStorage.getItem("mcp-inspector-auto-connect");_!==null&&s(_==="true")}catch(y){console.error("Failed to load connections from localStorage:",y)}finally{r(!0)}},[]),x.useEffect(()=>{a&&localStorage.setItem("mcp-inspector-connections",JSON.stringify(c))},[c,a]),x.useEffect(()=>{a&&localStorage.setItem("mcp-inspector-auto-connect",String(i))},[i,a]);const d=x.useCallback((y,_,E,k)=>{const C=c.find(A=>A.url===y),R=t.find(A=>A.url===y);if(C&&R){if(JSON.stringify(C.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:_||C.name||"MCP Server",proxyConfig:E,transportType:k||C.transportType};u(M=>[...M,O]),n(M=>[...M,{id:y,url:y,name:_||C.name||"MCP Server",state:"connecting",tools:[],resources:[],prompts:[],error:null,authUrl:null,customHeaders:E?.customHeaders,transportType:k||C.transportType,proxyConfig:E,notifications:[],unreadNotificationCount:0,markNotificationRead:()=>{},markAllNotificationsRead:()=>{},clearNotifications:()=>{},pendingSamplingRequests:[],approveSampling:Hg,rejectSampling:Vg,pendingElicitationRequests:[],approveElicitation:Gg,rejectElicitation:Wg,callTool:async()=>{},readResource:async()=>{},listPrompts:async()=>{},getPrompt:async()=>{},authenticate:()=>{},retry:()=>{},clearStorage:()=>{},disconnect:()=>{},client:null}])},10);return}return}if(C&&!R){(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:C.id||y,url:y,name:_||C.name||"MCP Server",state:"connecting",tools:[],resources:[],prompts:[],error:null,authUrl:null,customHeaders:E?.customHeaders||C.proxyConfig?.customHeaders,transportType:k||C.transportType,proxyConfig:E||C.proxyConfig,notifications:[],unreadNotificationCount:0,markNotificationRead:()=>{},markAllNotificationsRead:()=>{},clearNotifications:()=>{},pendingSamplingRequests:[],approveSampling:Hg,rejectSampling:Vg,pendingElicitationRequests:[],approveElicitation:Gg,rejectElicitation:Wg,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:Hg,rejectSampling:Vg,pendingElicitationRequests:[],approveElicitation:Gg,rejectElicitation:Wg,callTool:async()=>{},readResource:async()=>{},listPrompts:async()=>{},getPrompt:async()=>{},authenticate:()=>{},retry:()=>{},clearStorage:()=>{},disconnect:()=>{},client:null}])},[c,t]),m=x.useCallback(y=>{const _=t.find(k=>k.id===y);_&&(console.log(`[McpContext] Cleaning up connection: ${y}`),_.disconnect&&(console.log(`[McpContext] Disconnecting from server: ${y}`),_.disconnect()),_.clearStorage&&(console.log(`[McpContext] Clearing OAuth storage for connection: ${y}`),_.clearStorage())),u(k=>k.filter(C=>C.id!==y)),n(k=>k.filter(C=>C.id!==y));const E=localStorage.getItem("mcp-inspector-connections");if(E)try{const C=JSON.parse(E).filter(R=>(R.id||R.url)!==y);localStorage.setItem("mcp-inspector-connections",JSON.stringify(C))}catch(k){console.error("Failed to update localStorage on remove:",k)}yr.getInstance().capture(new Wfe({serverId:y}))},[t]),h=x.useCallback((y,_)=>{u(E=>E.map(k=>k.id===y||k.url===y?{...k,..._}:k)),n(E=>E.map(k=>k.id===y?{...k,..._}:k))},[]),g=x.useCallback(y=>{n(_=>{const E=_.findIndex(R=>R.id===y.id);if(E===-1)return _;const k=_[E];if(k.state===y.state&&k.tools===y.tools&&k.resources===y.resources&&k.prompts===y.prompts&&k.error===y.error&&k.serverInfo===y.serverInfo&&k.client===y.client&&k.notifications===y.notifications&&k.unreadNotificationCount===y.unreadNotificationCount&&k.pendingSamplingRequests.length===y.pendingSamplingRequests.length&&k.pendingElicitationRequests.length===y.pendingElicitationRequests.length)return _;const C=[..._];return C[E]=y,C})},[]),v=x.useCallback(y=>{console.log("Connect requested for:",y)},[]),w=x.useCallback(y=>{console.log("Disconnect requested for:",y)},[]),S=x.useMemo(()=>({connections:t,addConnection:d,removeConnection:m,updateConnectionConfig:h,autoConnect:i,setAutoConnect:s,connectServer:v,disconnectServer:w,configLoaded:a}),[t,d,m,h,i,v,w,a]);return f.jsxs(f8.Provider,{value:S,children:[e,a&&i&&c.map(y=>{const _=`${y.id||y.url}-${y.proxyConfig?.proxyAddress?"proxy":"direct"}`;return console.warn("[McpContext] Rendering McpConnectionWrapper with key:",_,"proxyConfig:",y.proxyConfig),f.jsx(Qfe,{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 tpe=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),npe=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,a)=>a?a.toUpperCase():n.toLowerCase()),AU=e=>{const t=npe(e);return t.charAt(0).toUpperCase()+t.slice(1)},p8=(...e)=>e.filter((t,n,a)=>!!t&&t.trim()!==""&&a.indexOf(t)===n).join(" ").trim(),rpe=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};var ape={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 ipe=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,...ape,width:t,height:t,stroke:e,strokeWidth:a?Number(n)*24/Number(t):n,className:p8("lucide",r),...!i&&!rpe(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(ipe,{ref:i,iconNode:t,className:p8(`lucide-${tpe(AU(e))}`,`lucide-${e}`,a),...r}));return n.displayName=AU(e),n};const ope=[["path",{d:"M12 17V3",key:"1cwfxf"}],["path",{d:"m6 11 6 6 6-6",key:"12ii2o"}],["path",{d:"M19 21H5",key:"150jfl"}]],spe=Xe("arrow-down-to-line",ope);const lpe=[["path",{d:"m18 9-6-6-6 6",key:"kcunyi"}],["path",{d:"M12 3v14",key:"7cf3v8"}],["path",{d:"M5 21h14",key:"11awu3"}]],cpe=Xe("arrow-up-from-line",lpe);const upe=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],dpe=Xe("arrow-up",upe);const fpe=[["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"}]],kN=Xe("bell",fpe);const ppe=[["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"}]],m8=Xe("brush",ppe);const mpe=[["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"}]],hpe=Xe("bug",mpe);const gpe=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],ta=Xe("check",gpe);const bpe=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Xl=Xe("chevron-down",bpe);const vpe=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],ype=Xe("chevron-right",vpe);const wpe=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],TN=Xe("chevron-left",wpe);const xpe=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],Spe=Xe("chevron-up",xpe);const Epe=[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]],_pe=Xe("chevrons-up-down",Epe);const kpe=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}]],IU=Xe("circle-minus",kpe);const Tpe=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Qu=Xe("clock",Tpe);const Npe=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],NN=Xe("code",Npe);const Cpe=[["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"}]],Rpe=Xe("cog",Cpe);const Ape=[["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"}]],Ipe=Xe("command",Ape);const Ope=[["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"}]],jr=Xe("copy",Ope);const Dpe=[["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"}]],Cy=Xe("database",Dpe);const jpe=[["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"}]],bm=Xe("download",jpe);const Lpe=[["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"}]],$pe=Xe("ellipsis-vertical",Lpe);const Mpe=[["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"}]],CE=Xe("external-link",Mpe);const Ppe=[["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"}]],h8=Xe("eye-off",Ppe);const Upe=[["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"}]],RE=Xe("eye",Upe);const zpe=[["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"}]],Fpe=Xe("file-code",zpe);const Bpe=[["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"}]],Hpe=Xe("file-image",Bpe);const Vpe=[["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"}]],CN=Xe("file-text",Vpe);const Gpe=[["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"}]],Wpe=Xe("file",Gpe);const Kpe=[["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"}]],Zpe=Xe("folder-open",Kpe);const Ype=[["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"}]],qpe=Xe("globe",Ype);const Xpe=[["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"}]],Jpe=Xe("grip-vertical",Xpe);const Qpe=[["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"}]],g8=Xe("hash",Qpe);const eme=[["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"}]],ov=Xe("history",eme);const tme=[["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"}]],b8=Xe("key",tme);const nme=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Ls=Xe("loader-circle",nme);const rme=[["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"}]],RN=Xe("maximize-2",rme);const ame=[["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"}]],AN=Xe("maximize",ame);const ime=[["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"}]],ome=Xe("message-circle",ime);const sme=[["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"}]],Tp=Xe("message-square",sme);const lme=[["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"}]],cme=Xe("minimize",lme);const ume=[["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"}]],OU=Xe("monitor",ume);const dme=[["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"}]],fme=Xe("moon",dme);const pme=[["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"}]],mme=Xe("picture-in-picture",pme);const hme=[["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"}]],v8=Xe("play",hme);const gme=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],y8=Xe("plus",gme);const bme=[["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"}]],DU=Xe("rotate-ccw",bme);const vme=[["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"}]],IN=Xe("save",vme);const yme=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],Ed=Xe("search",yme);const wme=[["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"}]],xme=Xe("send",wme);const Sme=[["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"}]],Eme=Xe("server",Sme);const _me=[["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"}]],gu=Xe("settings",_me);const kme=[["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"}]],Tme=Xe("shield",kme);const Nme=[["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"}]],Cme=Xe("sparkles",Nme);const Rme=[["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"}]],w8=Xe("square-check-big",Rme);const Ame=[["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"}]],Ime=Xe("square-pen",Ame);const Ome=[["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"}]],Dme=Xe("sun-dim",Ome);const jme=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],eS=Xe("terminal",jme);const Lme=[["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"}]],$s=Xe("trash-2",Lme);const $me=[["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"}]],Mme=Xe("trash",$me);const Pme=[["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"}]],Ul=Xe("wrench",Pme);const Ume=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Yi=Xe("x",Ume);const zme=[["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"}]],Np=Xe("zap",zme);function Fme(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 Bme=e=>{switch(e){case"success":return Gme;case"info":return Kme;case"warning":return Wme;case"error":return Zme;default:return null}},Hme=Array(12).fill(0),Vme=({visible:e,className:t})=>ue.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},ue.createElement("div",{className:"sonner-spinner"},Hme.map((n,a)=>ue.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${a}`})))),Gme=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"})),Wme=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"})),Kme=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"})),Zme=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"})),Yme=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"})),qme=()=>{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 AE=1;class Xme{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:AE++,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(Qme(d)&&!d.ok){i=!1;const h=typeof n.error=="function"?await n.error(`HTTP error! status: ${d.status}`):n.error,g=typeof n.description=="function"?await n.description(`HTTP error! status: ${d.status}`):n.description,w=typeof h=="object"&&!ue.isValidElement(h)?h:{message:h};this.create({id:a,type:"error",description:g,...w})}else if(d instanceof Error){i=!1;const h=typeof n.error=="function"?await n.error(d):n.error,g=typeof n.description=="function"?await n.description(d):n.description,w=typeof h=="object"&&!ue.isValidElement(h)?h:{message:h};this.create({id:a,type:"error",description:g,...w})}else if(n.success!==void 0){i=!1;const h=typeof n.success=="function"?await n.success(d):n.success,g=typeof n.description=="function"?await n.description(d):n.description,w=typeof h=="object"&&!ue.isValidElement(h)?h:{message:h};this.create({id:a,type:"success",description:g,...w})}}).catch(async d=>{if(s=["reject",d],n.error!==void 0){i=!1;const m=typeof n.error=="function"?await n.error(d):n.error,h=typeof n.description=="function"?await n.description(d):n.description,v=typeof m=="object"&&!ue.isValidElement(m)?m:{message:m};this.create({id:a,type:"error",description:h,...v})}}).finally(()=>{i&&(this.dismiss(a),a=void 0),n.finally==null||n.finally.call(n)}),u=()=>new Promise((d,m)=>c.then(()=>s[0]==="reject"?m(s[1]):d(s[1])).catch(m));return typeof a!="string"&&typeof a!="number"?{unwrap:u}:Object.assign(a,{unwrap:u})},this.custom=(t,n)=>{const a=n?.id||AE++;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 ma=new Xme,Jme=(e,t)=>{const n=t?.id||AE++;return ma.addToast({title:e,...t,id:n}),n},Qme=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",ehe=Jme,the=()=>ma.toasts,nhe=()=>ma.getActiveToasts(),Jt=Object.assign(ehe,{success:ma.success,info:ma.info,warning:ma.warning,error:ma.error,custom:ma.custom,message:ma.message,promise:ma.promise,dismiss:ma.dismiss,loading:ma.loading},{getHistory:the,getToasts:nhe});Fme("[data-sonner-toaster][dir=ltr],html[dir=ltr]{--toast-icon-margin-start:-3px;--toast-icon-margin-end:4px;--toast-svg-margin-start:-1px;--toast-svg-margin-end:0px;--toast-button-margin-start:auto;--toast-button-margin-end:0;--toast-close-button-start:0;--toast-close-button-end:unset;--toast-close-button-transform:translate(-35%, -35%)}[data-sonner-toaster][dir=rtl],html[dir=rtl]{--toast-icon-margin-start:4px;--toast-icon-margin-end:-3px;--toast-svg-margin-start:0px;--toast-svg-margin-end:-1px;--toast-button-margin-start:0;--toast-button-margin-end:auto;--toast-close-button-start:unset;--toast-close-button-end:0;--toast-close-button-transform:translate(35%, -35%)}[data-sonner-toaster]{position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1:hsl(0, 0%, 99%);--gray2:hsl(0, 0%, 97.3%);--gray3:hsl(0, 0%, 95.1%);--gray4:hsl(0, 0%, 93%);--gray5:hsl(0, 0%, 90.9%);--gray6:hsl(0, 0%, 88.7%);--gray7:hsl(0, 0%, 85.8%);--gray8:hsl(0, 0%, 78%);--gray9:hsl(0, 0%, 56.1%);--gray10:hsl(0, 0%, 52.3%);--gray11:hsl(0, 0%, 43.5%);--gray12:hsl(0, 0%, 9%);--border-radius:8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:0;z-index:999999999;transition:transform .4s ease}@media (hover:none) and (pointer:coarse){[data-sonner-toaster][data-lifted=true]{transform:none}}[data-sonner-toaster][data-x-position=right]{right:var(--offset-right)}[data-sonner-toaster][data-x-position=left]{left:var(--offset-left)}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translateX(-50%)}[data-sonner-toaster][data-y-position=top]{top:var(--offset-top)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--offset-bottom)}[data-sonner-toast]{--y:translateY(100%);--lift-amount:calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:0;overflow-wrap:anywhere}[data-sonner-toast][data-styled=true]{padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-y-position=top]{top:0;--y:translateY(-100%);--lift:1;--lift-amount:calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y:translateY(100%);--lift:-1;--lift-amount:calc(var(--lift) * var(--gap))}[data-sonner-toast][data-styled=true] [data-description]{font-weight:400;line-height:1.4;color:#3f3f3f}[data-rich-colors=true][data-sonner-toast][data-styled=true] [data-description]{color:inherit}[data-sonner-toaster][data-sonner-theme=dark] [data-description]{color:#e8e8e8}[data-sonner-toast][data-styled=true] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast][data-styled=true] [data-icon]{display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast][data-styled=true] [data-icon]>*{flex-shrink:0}[data-sonner-toast][data-styled=true] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast][data-styled=true] [data-content]{display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;font-weight:500;cursor:pointer;outline:0;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}[data-sonner-toast][data-styled=true] [data-button]:focus-visible{box-shadow:0 0 0 2px rgba(0,0,0,.4)}[data-sonner-toast][data-styled=true] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast][data-styled=true] [data-cancel]{color:var(--normal-text);background:rgba(0,0,0,.08)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-styled=true] [data-cancel]{background:rgba(255,255,255,.3)}[data-sonner-toast][data-styled=true] [data-close-button]{position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);background:var(--normal-bg);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast][data-styled=true] [data-close-button]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-styled=true] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast][data-styled=true]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]::before{content:'';position:absolute;left:-100%;right:-100%;height:100%;z-index:-1}[data-sonner-toast][data-y-position=top][data-swiping=true]::before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]::before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]::before{content:'';position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast][data-expanded=true]::after{content:'';position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y:translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale:var(--toasts-before) * 0.05 + 1;--y:translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-x-position=right]{right:0}[data-sonner-toast][data-x-position=left]{left:0}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y:translateY(calc(var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=false]{--y:translateY(40%);opacity:0;transition:transform .5s,opacity .2s}[data-sonner-toast][data-removed=true][data-front=false]::before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y,0)) translateX(var(--swipe-amount-x,0));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width:600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-sonner-theme=light]{--normal-bg:#fff;--normal-border:var(--gray4);--normal-text:var(--gray12);--success-bg:hsl(143, 85%, 96%);--success-border:hsl(145, 92%, 87%);--success-text:hsl(140, 100%, 27%);--info-bg:hsl(208, 100%, 97%);--info-border:hsl(221, 91%, 93%);--info-text:hsl(210, 92%, 45%);--warning-bg:hsl(49, 100%, 97%);--warning-border:hsl(49, 91%, 84%);--warning-text:hsl(31, 92%, 45%);--error-bg:hsl(359, 100%, 97%);--error-border:hsl(359, 100%, 94%);--error-text:hsl(360, 100%, 45%)}[data-sonner-toaster][data-sonner-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg:#000;--normal-border:hsl(0, 0%, 20%);--normal-text:var(--gray1)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg:#fff;--normal-border:var(--gray3);--normal-text:var(--gray12)}[data-sonner-toaster][data-sonner-theme=dark]{--normal-bg:#000;--normal-bg-hover:hsl(0, 0%, 12%);--normal-border:hsl(0, 0%, 20%);--normal-border-hover:hsl(0, 0%, 25%);--normal-text:var(--gray1);--success-bg:hsl(150, 100%, 6%);--success-border:hsl(147, 100%, 12%);--success-text:hsl(150, 86%, 65%);--info-bg:hsl(215, 100%, 6%);--info-border:hsl(223, 43%, 17%);--info-text:hsl(216, 87%, 65%);--warning-bg:hsl(64, 100%, 6%);--warning-border:hsl(60, 100%, 9%);--warning-text:hsl(46, 87%, 65%);--error-bg:hsl(358, 76%, 10%);--error-border:hsl(357, 89%, 16%);--error-text:hsl(358, 100%, 81%)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size:16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:first-child{animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}100%{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}100%{opacity:.15}}@media (prefers-reduced-motion){.sonner-loading-bar,[data-sonner-toast],[data-sonner-toast]>*{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}");function Kg(e){return e.label!==void 0}const rhe=3,ahe="24px",ihe="16px",jU=4e3,ohe=356,she=14,lhe=45,che=200;function $i(...e){return e.filter(Boolean).join(" ")}function uhe(e){const[t,n]=e.split("-"),a=[];return t&&a.push(t),n&&a.push(n),a}const dhe=e=>{var t,n,a,r,i,s,c,u,d;const{invert:m,toast:h,unstyled:g,interacting:v,setHeights:w,visibleToasts:S,heights:y,index:_,toasts:E,expanded:k,removeToast:C,defaultRichColors:R,closeButton:I,style:A,cancelButtonStyle:O,actionButtonStyle:M,className:U="",descriptionClassName:H="",duration:K,position:ee,gap:te,expandByDefault:ae,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),[ie,le]=ue.useState(!1),[J,q]=ue.useState(!1),[se,he]=ue.useState(0),[ce,Te]=ue.useState(0),He=ue.useRef(h.duration||K||jU),Se=ue.useRef(null),_e=ue.useRef(null),Ue=_===0,fe=_+1<=S,Oe=h.type,Be=h.dismissible!==!1,xe=h.className||"",tt=h.descriptionClassName||"",it=ue.useMemo(()=>y.findIndex(Ye=>Ye.toastId===h.id)||0,[y,h.id]),ht=ue.useMemo(()=>{var Ye;return(Ye=h.closeButton)!=null?Ye:I},[h.closeButton,I]),Rt=ue.useMemo(()=>h.duration||K||jU,[h.duration,K]),je=ue.useRef(0),Fe=ue.useRef(0),pt=ue.useRef(0),Qe=ue.useRef(null),[Tt,nt]=ee.split("-"),Ie=ue.useMemo(()=>y.reduce((Ye,vt,Mt)=>Mt>=it?Ye:Ye+vt.height,0),[y,it]),$e=qme(),Ve=h.invert||m,at=Oe==="loading";Fe.current=ue.useMemo(()=>it*te+Ie,[it,Ie]),ue.useEffect(()=>{He.current=Rt},[Rt]),ue.useEffect(()=>{L(!0)},[]),ue.useEffect(()=>{const Ye=_e.current;if(Ye){const vt=Ye.getBoundingClientRect().height;return Te(vt),w(Mt=>[{toastId:h.id,height:vt,position:h.position},...Mt]),()=>w(Mt=>Mt.filter(Pt=>Pt.toastId!==h.id))}},[w,h.id]),ue.useLayoutEffect(()=>{if(!z)return;const Ye=_e.current,vt=Ye.style.height;Ye.style.height="auto";const Mt=Ye.getBoundingClientRect().height;Ye.style.height=vt,Te(Mt),w(Pt=>Pt.find(fn=>fn.toastId===h.id)?Pt.map(fn=>fn.toastId===h.id?{...fn,height:Mt}:fn):[{toastId:h.id,height:Mt,position:h.position},...Pt])},[z,h.title,h.description,w,h.id,h.jsx,h.action,h.cancel]);const dt=ue.useCallback(()=>{F(!0),he(Fe.current),w(Ye=>Ye.filter(vt=>vt.toastId!==h.id)),setTimeout(()=>{C(h)},che)},[h,C,w,Fe]);ue.useEffect(()=>{if(h.promise&&Oe==="loading"||h.duration===1/0||h.type==="loading")return;let Ye;return k||v||$e?(()=>{if(pt.current<je.current){const Pt=new Date().getTime()-je.current;He.current=He.current-Pt}pt.current=new Date().getTime()})():(()=>{He.current!==1/0&&(je.current=new Date().getTime(),Ye=setTimeout(()=>{h.onAutoClose==null||h.onAutoClose.call(h,h),dt()},He.current))})(),()=>clearTimeout(Ye)},[k,v,h,Oe,$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:$i(B?.loader,h==null||(vt=h.classNames)==null?void 0:vt.loader,"sonner-loader"),"data-visible":Oe==="loading"},Z.loading)}return ue.createElement(Vme,{className:$i(B?.loader,h==null||(Ye=h.classNames)==null?void 0:Ye.loader),visible:Oe==="loading"})}const xt=h.icon||Z?.[Oe]||Bme(Oe);var dn,hn;return ue.createElement("li",{tabIndex:0,ref:_e,className:$i(U,xe,B?.toast,h==null||(t=h.classNames)==null?void 0:t.toast,B?.default,B?.[Oe],h==null||(n=h.classNames)==null?void 0:n[Oe]),"data-sonner-toast":"","data-rich-colors":(dn=h.richColors)!=null?dn:R,"data-styled":!(h.jsx||h.unstyled||g),"data-mounted":z,"data-promise":!!h.promise,"data-swiped":J,"data-removed":$,"data-visible":fe,"data-y-position":Tt,"data-x-position":nt,"data-index":_,"data-front":Ue,"data-swiping":W,"data-dismissible":Be,"data-type":Oe,"data-invert":Ve,"data-swipe-out":ie,"data-swipe-direction":j,"data-expanded":!!(k||ae&&z),"data-testid":h.testId,style:{"--index":_,"--toasts-before":_,"--z-index":E.length-_,"--offset":`${$?se:Fe.current}px`,"--initial-height":ae?"auto":`${ce}px`,...A,...h.style},onDragEnd:()=>{X(!1),ne(null),Qe.current=null},onPointerDown:Ye=>{Ye.button!==2&&(at||!Be||(Se.current=new Date,he(Fe.current),Ye.target.setPointerCapture(Ye.pointerId),Ye.target.tagName!=="BUTTON"&&(X(!0),Qe.current={x:Ye.clientX,y:Ye.clientY})))},onPointerUp:()=>{var Ye,vt,Mt;if(ie||!Be)return;Qe.current=null;const Pt=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()-((Mt=Se.current)==null?void 0:Mt.getTime()),Kn=re==="x"?Pt:fr,Zn=Math.abs(Kn)/fn;if(Math.abs(Kn)>=lhe||Zn>.11){he(Fe.current),h.onDismiss==null||h.onDismiss.call(h,h),V(re==="x"?Pt>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,Mt,Pt;if(!Qe.current||!Be||((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:uhe(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 aa=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*aa(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*aa(Kn);pn.x=Math.abs(en)<Math.abs(Kn)?en:Kn}(Math.abs(pn.x)>0||Math.abs(pn.y)>0)&&q(!0),(Mt=_e.current)==null||Mt.style.setProperty("--swipe-amount-x",`${pn.x}px`),(Pt=_e.current)==null||Pt.style.setProperty("--swipe-amount-y",`${pn.y}px`)}},ht&&!h.jsx&&Oe!=="loading"?ue.createElement("button",{"aria-label":G,"data-disabled":at,"data-close-button":!0,onClick:at||!Be?()=>{}:()=>{dt(),h.onDismiss==null||h.onDismiss.call(h,h)},className:$i(B?.closeButton,h==null||(a=h.classNames)==null?void 0:a.closeButton)},(hn=Z?.close)!=null?hn:Yme):null,(Oe||h.icon||h.promise)&&h.icon!==null&&(Z?.[Oe]!==null||h.icon)?ue.createElement("div",{"data-icon":"",className:$i(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:$i(B?.content,h==null||(i=h.classNames)==null?void 0:i.content)},ue.createElement("div",{"data-title":"",className:$i(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:$i(H,tt,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&&Kg(h.cancel)?ue.createElement("button",{"data-button":!0,"data-cancel":!0,style:h.cancelButtonStyle||O,onClick:Ye=>{Kg(h.cancel)&&Be&&(h.cancel.onClick==null||h.cancel.onClick.call(h.cancel,Ye),dt())},className:$i(B?.cancelButton,h==null||(u=h.classNames)==null?void 0:u.cancelButton)},h.cancel.label):null,ue.isValidElement(h.action)?h.action:h.action&&Kg(h.action)?ue.createElement("button",{"data-button":!0,"data-action":!0,style:h.actionButtonStyle||M,onClick:Ye=>{Kg(h.action)&&(h.action.onClick==null||h.action.onClick.call(h.action,Ye),!Ye.defaultPrevented&&dt())},className:$i(B?.actionButton,h==null||(d=h.classNames)==null?void 0:d.actionButton)},h.action.label):null)};function LU(){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 fhe(e,t){const n={};return[e,t].forEach((a,r)=>{const i=r===1,s=i?"--mobile-offset":"--offset",c=i?ihe:ahe;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 x8=ue.forwardRef(function(t,n){const{id:a,invert:r,position:i="bottom-right",hotkey:s=["altKey","KeyT"],expand:c,closeButton:u,className:d,offset:m,mobileOffset:h,theme:g="light",richColors:v,duration:w,style:S,visibleToasts:y=rhe,toastOptions:_,dir:E=LU(),gap:k=she,icons:C,containerAriaLabel:R="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),[te,ae]=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||ma.dismiss(z.id),L.filter(({id:F})=>F!==z.id)})},[]);return ue.useEffect(()=>ma.subscribe(z=>{if(z.dismiss){requestAnimationFrame(()=>{A(L=>L.map($=>$.id===z.id?{...$,delete:!0}:$))});return}setTimeout(()=>{eV.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":`${R} ${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"?LU():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":`${ohe}px`,"--gap":`${k}px`,...S,...fhe(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:()=>{te||ee(!1)},onDragEnd:()=>ee(!1),onPointerDown:X=>{X.target instanceof HTMLElement&&X.target.dataset.dismissible==="false"||ae(!0)},onPointerUp:()=>ae(!1)},O.filter(X=>!X.position&&L===0||X.position===z).map((X,ie)=>{var le,J;return ue.createElement(dhe,{key:X.id,icons:C,index:ie,toast:X,defaultRichColors:v,duration:(le=_?.duration)!=null?le:w,className:_?.className,descriptionClassName:_?.descriptionClassName,invert:r,visibleToasts:y,closeButton:(J=_?.closeButton)!=null?J:u,interacting:te,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}))}),$U=Object.freeze(Object.defineProperty({__proto__:null,Toaster:x8,toast:Jt},Symbol.toStringTag,{value:"Module"}));var Ry="Dialog",[S8]=Ci(Ry),[phe,Ri]=S8(Ry),E8=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]=jo({prop:a,defaultProp:r??!1,onChange:i,caller:Ry});return f.jsx(phe,{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})};E8.displayName=Ry;var _8="DialogTrigger",k8=x.forwardRef((e,t)=>{const{__scopeDialog:n,...a}=e,r=Ri(_8,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":jN(r.open),...a,ref:i,onClick:Ge(e.onClick,r.onOpenToggle)})});k8.displayName=_8;var ON="DialogPortal",[mhe,T8]=S8(ON,{forceMount:void 0}),N8=e=>{const{__scopeDialog:t,forceMount:n,children:a,container:r}=e,i=Ri(ON,t);return f.jsx(mhe,{scope:t,forceMount:n,children:x.Children.map(a,s=>f.jsx(Ma,{present:n||i.open,children:f.jsx(xd,{asChild:!0,container:r,children:s})}))})};N8.displayName=ON;var sv="DialogOverlay",C8=x.forwardRef((e,t)=>{const n=T8(sv,e.__scopeDialog),{forceMount:a=n.forceMount,...r}=e,i=Ri(sv,e.__scopeDialog);return i.modal?f.jsx(Ma,{present:a||i.open,children:f.jsx(ghe,{...r,ref:t})}):null});C8.displayName=sv;var hhe=Ml("DialogOverlay.RemoveScroll"),ghe=x.forwardRef((e,t)=>{const{__scopeDialog:n,...a}=e,r=Ri(sv,n);return f.jsx(pm,{as:hhe,allowPinchZoom:!0,shards:[r.contentRef],children:f.jsx(Et.div,{"data-state":jN(r.open),...a,ref:t,style:{pointerEvents:"auto",...a.style}})})}),zl="DialogContent",R8=x.forwardRef((e,t)=>{const n=T8(zl,e.__scopeDialog),{forceMount:a=n.forceMount,...r}=e,i=Ri(zl,e.__scopeDialog);return f.jsx(Ma,{present:a||i.open,children:i.modal?f.jsx(bhe,{...r,ref:t}):f.jsx(vhe,{...r,ref:t})})});R8.displayName=zl;var bhe=x.forwardRef((e,t)=>{const n=Ri(zl,e.__scopeDialog),a=x.useRef(null),r=Qt(t,n.contentRef,a);return x.useEffect(()=>{const i=a.current;if(i)return yy(i)},[]),f.jsx(A8,{...e,ref:r,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Ge(e.onCloseAutoFocus,i=>{i.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:Ge(e.onPointerDownOutside,i=>{const s=i.detail.originalEvent,c=s.button===0&&s.ctrlKey===!0;(s.button===2||c)&&i.preventDefault()}),onFocusOutside:Ge(e.onFocusOutside,i=>i.preventDefault())})}),vhe=x.forwardRef((e,t)=>{const n=Ri(zl,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=Ri(zl,n),u=x.useRef(null),d=Qt(t,u);return dy(),f.jsxs(f.Fragment,{children:[f.jsx(cm,{asChild:!0,loop:!0,trapped:a,onMountAutoFocus:r,onUnmountAutoFocus:i,children:f.jsx(vd,{role:"dialog",id:c.contentId,"aria-describedby":c.descriptionId,"aria-labelledby":c.titleId,"data-state":jN(c.open),...s,ref:d,onDismiss:()=>c.onOpenChange(!1)})}),f.jsxs(f.Fragment,{children:[f.jsx(yhe,{titleId:c.titleId}),f.jsx(xhe,{contentRef:u,descriptionId:c.descriptionId})]})]})}),DN="DialogTitle",I8=x.forwardRef((e,t)=>{const{__scopeDialog:n,...a}=e,r=Ri(DN,n);return f.jsx(Et.h2,{id:r.titleId,...a,ref:t})});I8.displayName=DN;var O8="DialogDescription",D8=x.forwardRef((e,t)=>{const{__scopeDialog:n,...a}=e,r=Ri(O8,n);return f.jsx(Et.p,{id:r.descriptionId,...a,ref:t})});D8.displayName=O8;var j8="DialogClose",L8=x.forwardRef((e,t)=>{const{__scopeDialog:n,...a}=e,r=Ri(j8,n);return f.jsx(Et.button,{type:"button",...a,ref:t,onClick:Ge(e.onClick,()=>r.onOpenChange(!1))})});L8.displayName=j8;function jN(e){return e?"open":"closed"}var $8="DialogTitleWarning",[Yke,M8]=ile($8,{contentName:zl,titleName:DN,docsSlug:"dialog"}),yhe=({titleId:e})=>{const t=M8($8),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
93
|
+
`)},Yue=0,Bc=[];function que(e){var t=x.useRef([]),n=x.useRef([0,0]),a=x.useRef(),r=x.useState(Yue++)[0],i=x.useState(t9)[0],s=x.useRef(e);x.useEffect(function(){s.current=e},[e]),x.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(r));var S=bue([e.lockRef.current],(e.shards||[]).map(EU),!0).filter(Boolean);return S.forEach(function(y){return y.classList.add("allow-interactivity-".concat(r))}),function(){document.body.classList.remove("block-interactivity-".concat(r)),S.forEach(function(y){return y.classList.remove("allow-interactivity-".concat(r))})}}},[e.inert,e.lockRef.current,e.shards]);var c=x.useCallback(function(S,y){if("touches"in S&&S.touches.length===2||S.type==="wheel"&&S.ctrlKey)return!s.current.allowPinchZoom;var _=Bg(S),E=n.current,k="deltaX"in S?S.deltaX:E[0]-_[0],C="deltaY"in S?S.deltaY:E[1]-_[1],R,I=S.target,A=Math.abs(k)>Math.abs(C)?"h":"v";if("touches"in S&&A==="h"&&I.type==="range")return!1;var O=xU(A,I);if(!O)return!0;if(O?R=A:(R=A==="v"?"h":"v",O=xU(A,I)),!O)return!1;if(!a.current&&"changedTouches"in S&&(k||C)&&(a.current=R),!R)return!0;var M=a.current||R;return Wue(M,y,S,M==="h"?k:C)},[]),u=x.useCallback(function(S){var y=S;if(!(!Bc.length||Bc[Bc.length-1]!==i)){var _="deltaY"in y?SU(y):Bg(y),E=t.current.filter(function(R){return R.name===y.type&&(R.target===y.target||y.target===R.shadowParent)&&Kue(R.delta,_)})[0];if(E&&E.should){y.cancelable&&y.preventDefault();return}if(!E){var k=(s.current.shards||[]).map(EU).filter(Boolean).filter(function(R){return R.contains(y.target)}),C=k.length>0?c(y,k[0]):!s.current.noIsolation;C&&y.cancelable&&y.preventDefault()}}},[]),d=x.useCallback(function(S,y,_,E){var k={name:S,delta:y,target:_,should:E,shadowParent:Xue(_)};t.current.push(k),setTimeout(function(){t.current=t.current.filter(function(C){return C!==k})},1)},[]),m=x.useCallback(function(S){n.current=Bg(S),a.current=void 0},[]),h=x.useCallback(function(S){d(S.type,SU(S),S.target,c(S,e.lockRef.current))},[]),g=x.useCallback(function(S){d(S.type,Bg(S),S.target,c(S,e.lockRef.current))},[]);x.useEffect(function(){return Bc.push(i),e.setCallbacks({onScrollCapture:h,onWheelCapture:h,onTouchMoveCapture:g}),document.addEventListener("wheel",u,Fc),document.addEventListener("touchmove",u,Fc),document.addEventListener("touchstart",m,Fc),function(){Bc=Bc.filter(function(S){return S!==i}),document.removeEventListener("wheel",u,Fc),document.removeEventListener("touchmove",u,Fc),document.removeEventListener("touchstart",m,Fc)}},[]);var v=e.removeScrollBar,w=e.inert;return x.createElement(x.Fragment,null,w?x.createElement(i,{styles:Zue(r)}):null,v?x.createElement(Uue,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Xue(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const Jue=Tue(e9,que);var pm=x.forwardRef(function(e,t){return x.createElement(wy,Pi({},e,{ref:t,sideCar:Jue}))});pm.classNames=wy.classNames;var SE=["Enter"," "],Que=["ArrowDown","PageUp","Home"],i9=["ArrowUp","PageDown","End"],ede=[...Que,...i9],tde={ltr:[...SE,"ArrowRight"],rtl:[...SE,"ArrowLeft"]},nde={ltr:["ArrowLeft"],rtl:["ArrowRight"]},mm="Menu",[Ep,rde,ade]=rN(mm),[Yl,o9]=Ci(mm,[ade,Hs,WV]),xy=Hs(),s9=WV(),[ide,ql]=Yl(mm),[ode,hm]=Yl(mm),l9=e=>{const{__scopeMenu:t,open:n=!1,children:a,dir:r,onOpenChange:i,modal:s=!0}=e,c=xy(t),[u,d]=x.useState(null),m=x.useRef(!1),h=Gi(i),g=aN(r);return x.useEffect(()=>{const v=()=>{m.current=!0,document.addEventListener("pointerdown",w,{capture:!0,once:!0}),document.addEventListener("pointermove",w,{capture:!0,once:!0})},w=()=>m.current=!1;return document.addEventListener("keydown",v,{capture:!0}),()=>{document.removeEventListener("keydown",v,{capture:!0}),document.removeEventListener("pointerdown",w,{capture:!0}),document.removeEventListener("pointermove",w,{capture:!0})}},[]),f.jsx(gy,{...c,children:f.jsx(ide,{scope:t,open:n,onOpenChange:h,content:u,onContentChange:d,children:f.jsx(ode,{scope:t,onClose:x.useCallback(()=>h(!1),[h]),isUsingKeyboardRef:m,dir:g,modal:s,children:a})})})};l9.displayName=mm;var sde="MenuAnchor",mN=x.forwardRef((e,t)=>{const{__scopeMenu:n,...a}=e,r=xy(n);return f.jsx(dm,{...r,...a,ref:t})});mN.displayName=sde;var hN="MenuPortal",[lde,c9]=Yl(hN,{forceMount:void 0}),u9=e=>{const{__scopeMenu:t,forceMount:n,children:a,container:r}=e,i=ql(hN,t);return f.jsx(lde,{scope:t,forceMount:n,children:f.jsx(Ma,{present:n||i.open,children:f.jsx(xd,{asChild:!0,container:r,children:a})})})};u9.displayName=hN;var Ja="MenuContent",[cde,gN]=Yl(Ja),d9=x.forwardRef((e,t)=>{const n=c9(Ja,e.__scopeMenu),{forceMount:a=n.forceMount,...r}=e,i=ql(Ja,e.__scopeMenu),s=hm(Ja,e.__scopeMenu);return f.jsx(Ep.Provider,{scope:e.__scopeMenu,children:f.jsx(Ma,{present:a||i.open,children:f.jsx(Ep.Slot,{scope:e.__scopeMenu,children:s.modal?f.jsx(ude,{...r,ref:t}):f.jsx(dde,{...r,ref:t})})})})}),ude=x.forwardRef((e,t)=>{const n=ql(Ja,e.__scopeMenu),a=x.useRef(null),r=Qt(t,a);return x.useEffect(()=>{const i=a.current;if(i)return yy(i)},[]),f.jsx(bN,{...e,ref:r,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:Ge(e.onFocusOutside,i=>i.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),dde=x.forwardRef((e,t)=>{const n=ql(Ja,e.__scopeMenu);return f.jsx(bN,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),fde=Ml("MenuContent.ScrollLock"),bN=x.forwardRef((e,t)=>{const{__scopeMenu:n,loop:a=!1,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:s,disableOutsidePointerEvents:c,onEntryFocus:u,onEscapeKeyDown:d,onPointerDownOutside:m,onFocusOutside:h,onInteractOutside:g,onDismiss:v,disableOutsideScroll:w,...S}=e,y=ql(Ja,n),_=hm(Ja,n),E=xy(n),k=s9(n),C=rde(n),[R,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"),te=x.useRef(0),ae=w?pm:x.Fragment,B=w?{as:fde,allowPinchZoom:!0}:void 0,Z=re=>{const ne=U.current+re,j=C().filter(W=>!W.disabled),V=document.activeElement,z=j.find(W=>W.ref.current===V)?.textValue,L=j.map(W=>W.textValue),$=_de(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),[]),dy();const G=x.useCallback(re=>ee.current===K.current?.side&&Tde(re,K.current?.area),[]);return f.jsx(cde,{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(ae,{...B,children:f.jsx(cm,{asChild:!0,trapped:r,onMountAutoFocus:Ge(i,re=>{re.preventDefault(),A.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:s,children:f.jsx(vd,{asChild:!0,disableOutsidePointerEvents:c,onEscapeKeyDown:d,onPointerDownOutside:m,onFocusOutside:h,onInteractOutside:g,onDismiss:v,children:f.jsx(fue,{asChild:!0,...k,dir:_.dir,orientation:"vertical",loop:a,currentTabStopId:R,onCurrentTabStopIdChange:I,onEntryFocus:Ge(u,re=>{_.isUsingKeyboardRef.current||re.preventDefault()}),preventScrollOnEntryFocus:!0,children:f.jsx(by,{role:"menu","aria-orientation":"vertical","data-state":N9(y.open),"data-radix-menu-content":"",dir:_.dir,...E,...S,ref:O,style:{outline:"none",...S.style},onKeyDown:Ge(S.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||!ede.includes(re.key))return;re.preventDefault();const F=C().filter(W=>!W.disabled).map(W=>W.ref.current);i9.includes(re.key)&&F.reverse(),Sde(F)}),onBlur:Ge(e.onBlur,re=>{re.currentTarget.contains(re.target)||(window.clearTimeout(M.current),U.current="")}),onPointerMove:Ge(e.onPointerMove,_p(re=>{const ne=re.target,j=te.current!==re.clientX;if(re.currentTarget.contains(ne)&&j){const V=re.clientX>te.current?"right":"left";ee.current=V,te.current=re.clientX}}))})})})})})})});d9.displayName=Ja;var pde="MenuGroup",vN=x.forwardRef((e,t)=>{const{__scopeMenu:n,...a}=e;return f.jsx(Et.div,{role:"group",...a,ref:t})});vN.displayName=pde;var mde="MenuLabel",f9=x.forwardRef((e,t)=>{const{__scopeMenu:n,...a}=e;return f.jsx(Et.div,{...a,ref:t})});f9.displayName=mde;var rv="MenuItem",_U="menu.itemSelect",Sy=x.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:a,...r}=e,i=x.useRef(null),s=hm(rv,e.__scopeMenu),c=gN(rv,e.__scopeMenu),u=Qt(t,i),d=x.useRef(!1),m=()=>{const h=i.current;if(!n&&h){const g=new CustomEvent(_U,{bubbles:!0,cancelable:!0});h.addEventListener(_U,v=>a?.(v),{once:!0}),wV(h,g),g.defaultPrevented?d.current=!1:s.onClose()}};return f.jsx(p9,{...r,ref:u,disabled:n,onClick:Ge(e.onClick,m),onPointerDown:h=>{e.onPointerDown?.(h),d.current=!0},onPointerUp:Ge(e.onPointerUp,h=>{d.current||h.currentTarget?.click()}),onKeyDown:Ge(e.onKeyDown,h=>{const g=c.searchRef.current!=="";n||g&&h.key===" "||SE.includes(h.key)&&(h.currentTarget.click(),h.preventDefault())})})});Sy.displayName=rv;var p9=x.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:a=!1,textValue:r,...i}=e,s=gN(rv,n),c=s9(n),u=x.useRef(null),d=Qt(t,u),[m,h]=x.useState(!1),[g,v]=x.useState("");return x.useEffect(()=>{const w=u.current;w&&v((w.textContent??"").trim())},[i.children]),f.jsx(Ep.ItemSlot,{scope:n,disabled:a,textValue:r??g,children:f.jsx(pue,{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:Ge(e.onPointerMove,_p(w=>{a?s.onItemLeave(w):(s.onItemEnter(w),w.defaultPrevented||w.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Ge(e.onPointerLeave,_p(w=>s.onItemLeave(w))),onFocus:Ge(e.onFocus,()=>h(!0)),onBlur:Ge(e.onBlur,()=>h(!1))})})})}),hde="MenuCheckboxItem",m9=x.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:a,...r}=e;return f.jsx(y9,{scope:e.__scopeMenu,checked:n,children:f.jsx(Sy,{role:"menuitemcheckbox","aria-checked":av(n)?"mixed":n,...r,ref:t,"data-state":wN(n),onSelect:Ge(r.onSelect,()=>a?.(av(n)?!0:!n),{checkForDefaultPrevented:!1})})})});m9.displayName=hde;var h9="MenuRadioGroup",[gde,bde]=Yl(h9,{value:void 0,onValueChange:()=>{}}),g9=x.forwardRef((e,t)=>{const{value:n,onValueChange:a,...r}=e,i=Gi(a);return f.jsx(gde,{scope:e.__scopeMenu,value:n,onValueChange:i,children:f.jsx(vN,{...r,ref:t})})});g9.displayName=h9;var b9="MenuRadioItem",v9=x.forwardRef((e,t)=>{const{value:n,...a}=e,r=bde(b9,e.__scopeMenu),i=n===r.value;return f.jsx(y9,{scope:e.__scopeMenu,checked:i,children:f.jsx(Sy,{role:"menuitemradio","aria-checked":i,...a,ref:t,"data-state":wN(i),onSelect:Ge(a.onSelect,()=>r.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});v9.displayName=b9;var yN="MenuItemIndicator",[y9,vde]=Yl(yN,{checked:!1}),w9=x.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:a,...r}=e,i=vde(yN,n);return f.jsx(Ma,{present:a||av(i.checked)||i.checked===!0,children:f.jsx(Et.span,{...r,ref:t,"data-state":wN(i.checked)})})});w9.displayName=yN;var yde="MenuSeparator",x9=x.forwardRef((e,t)=>{const{__scopeMenu:n,...a}=e;return f.jsx(Et.div,{role:"separator","aria-orientation":"horizontal",...a,ref:t})});x9.displayName=yde;var wde="MenuArrow",S9=x.forwardRef((e,t)=>{const{__scopeMenu:n,...a}=e,r=xy(n);return f.jsx(vy,{...r,...a,ref:t})});S9.displayName=wde;var xde="MenuSub",[Zke,E9]=Yl(xde),Ff="MenuSubTrigger",_9=x.forwardRef((e,t)=>{const n=ql(Ff,e.__scopeMenu),a=hm(Ff,e.__scopeMenu),r=E9(Ff,e.__scopeMenu),i=gN(Ff,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(mN,{asChild:!0,...d,children:f.jsx(p9,{id:r.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":r.contentId,"data-state":N9(n.open),...e,ref:Vi(t,r.onTriggerChange),onClick:h=>{e.onClick?.(h),!(e.disabled||h.defaultPrevented)&&(h.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:Ge(e.onPointerMove,_p(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:Ge(e.onPointerLeave,_p(h=>{m();const g=n.content?.getBoundingClientRect();if(g){const v=n.content?.dataset.side,w=v==="right",S=w?-5:5,y=g[w?"left":"right"],_=g[w?"right":"left"];i.onPointerGraceIntentChange({area:[{x:h.clientX+S,y:h.clientY},{x:y,y:g.top},{x:_,y:g.top},{x:_,y:g.bottom},{x:y,y:g.bottom}],side:v}),window.clearTimeout(c.current),c.current=window.setTimeout(()=>i.onPointerGraceIntentChange(null),300)}else{if(i.onTriggerLeave(h),h.defaultPrevented)return;i.onPointerGraceIntentChange(null)}})),onKeyDown:Ge(e.onKeyDown,h=>{const g=i.searchRef.current!=="";e.disabled||g&&h.key===" "||tde[a.dir].includes(h.key)&&(n.onOpenChange(!0),n.content?.focus(),h.preventDefault())})})})});_9.displayName=Ff;var k9="MenuSubContent",T9=x.forwardRef((e,t)=>{const n=c9(Ja,e.__scopeMenu),{forceMount:a=n.forceMount,...r}=e,i=ql(Ja,e.__scopeMenu),s=hm(Ja,e.__scopeMenu),c=E9(k9,e.__scopeMenu),u=x.useRef(null),d=Qt(t,u);return f.jsx(Ep.Provider,{scope:e.__scopeMenu,children:f.jsx(Ma,{present:a||i.open,children:f.jsx(Ep.Slot,{scope:e.__scopeMenu,children:f.jsx(bN,{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:Ge(e.onFocusOutside,m=>{m.target!==c.trigger&&i.onOpenChange(!1)}),onEscapeKeyDown:Ge(e.onEscapeKeyDown,m=>{s.onClose(),m.preventDefault()}),onKeyDown:Ge(e.onKeyDown,m=>{const h=m.currentTarget.contains(m.target),g=nde[s.dir].includes(m.key);h&&g&&(i.onOpenChange(!1),c.trigger?.focus(),m.preventDefault())})})})})})});T9.displayName=k9;function N9(e){return e?"open":"closed"}function av(e){return e==="indeterminate"}function wN(e){return av(e)?"indeterminate":e?"checked":"unchecked"}function Sde(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function Ede(e,t){return e.map((n,a)=>e[(t+a)%e.length])}function _de(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=Ede(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 kde(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 Tde(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return kde(n,t)}function _p(e){return t=>t.pointerType==="mouse"?e(t):void 0}var Nde=l9,Cde=mN,Rde=u9,Ade=d9,Ide=vN,Ode=f9,Dde=Sy,jde=m9,Lde=g9,$de=v9,Mde=w9,Pde=x9,Ude=S9,zde=_9,Fde=T9,Ey="DropdownMenu",[Bde]=Ci(Ey,[o9]),ra=o9(),[Hde,C9]=Bde(Ey),R9=e=>{const{__scopeDropdownMenu:t,children:n,dir:a,open:r,defaultOpen:i,onOpenChange:s,modal:c=!0}=e,u=ra(t),d=x.useRef(null),[m,h]=jo({prop:r,defaultProp:i??!1,onChange:s,caller:Ey});return f.jsx(Hde,{scope:t,triggerId:Dr(),triggerRef:d,contentId:Dr(),open:m,onOpenChange:h,onOpenToggle:x.useCallback(()=>h(g=>!g),[h]),modal:c,children:f.jsx(Nde,{...u,open:m,onOpenChange:h,dir:a,modal:c,children:n})})};R9.displayName=Ey;var A9="DropdownMenuTrigger",I9=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:a=!1,...r}=e,i=C9(A9,n),s=ra(n);return f.jsx(Cde,{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:Vi(t,i.triggerRef),onPointerDown:Ge(e.onPointerDown,c=>{!a&&c.button===0&&c.ctrlKey===!1&&(i.onOpenToggle(),i.open||c.preventDefault())}),onKeyDown:Ge(e.onKeyDown,c=>{a||(["Enter"," "].includes(c.key)&&i.onOpenToggle(),c.key==="ArrowDown"&&i.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(c.key)&&c.preventDefault())})})})});I9.displayName=A9;var Vde="DropdownMenuPortal",O9=e=>{const{__scopeDropdownMenu:t,...n}=e,a=ra(t);return f.jsx(Rde,{...a,...n})};O9.displayName=Vde;var D9="DropdownMenuContent",j9=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=C9(D9,n),i=ra(n),s=x.useRef(!1);return f.jsx(Ade,{id:r.contentId,"aria-labelledby":r.triggerId,...i,...a,ref:t,onCloseAutoFocus:Ge(e.onCloseAutoFocus,c=>{s.current||r.triggerRef.current?.focus(),s.current=!1,c.preventDefault()}),onInteractOutside:Ge(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)"}})});j9.displayName=D9;var Gde="DropdownMenuGroup",Wde=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ra(n);return f.jsx(Ide,{...r,...a,ref:t})});Wde.displayName=Gde;var Kde="DropdownMenuLabel",L9=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ra(n);return f.jsx(Ode,{...r,...a,ref:t})});L9.displayName=Kde;var Zde="DropdownMenuItem",$9=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ra(n);return f.jsx(Dde,{...r,...a,ref:t})});$9.displayName=Zde;var Yde="DropdownMenuCheckboxItem",M9=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ra(n);return f.jsx(jde,{...r,...a,ref:t})});M9.displayName=Yde;var qde="DropdownMenuRadioGroup",Xde=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ra(n);return f.jsx(Lde,{...r,...a,ref:t})});Xde.displayName=qde;var Jde="DropdownMenuRadioItem",P9=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ra(n);return f.jsx($de,{...r,...a,ref:t})});P9.displayName=Jde;var Qde="DropdownMenuItemIndicator",efe=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ra(n);return f.jsx(Mde,{...r,...a,ref:t})});efe.displayName=Qde;var tfe="DropdownMenuSeparator",U9=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ra(n);return f.jsx(Pde,{...r,...a,ref:t})});U9.displayName=tfe;var nfe="DropdownMenuArrow",rfe=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ra(n);return f.jsx(Ude,{...r,...a,ref:t})});rfe.displayName=nfe;var afe="DropdownMenuSubTrigger",z9=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ra(n);return f.jsx(zde,{...r,...a,ref:t})});z9.displayName=afe;var ife="DropdownMenuSubContent",F9=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ra(n);return f.jsx(Fde,{...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)"}})});F9.displayName=ife;var ofe=R9,sfe=I9,lfe=O9,B9=j9,H9=L9,V9=$9,cfe=M9,ufe=P9,G9=U9,dfe=z9,ffe=F9;const EE=ofe,_E=sfe;dfe.displayName;ffe.displayName;function iv({ref:e,className:t,sideOffset:n=4,...a}){return f.jsx(lfe,{children:f.jsx(B9,{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})})}iv.displayName=B9.displayName;function To({ref:e,className:t,inset:n,...a}){return f.jsx(V9,{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})}To.displayName=V9.displayName;cfe.displayName;ufe.displayName;function kE({ref:e,className:t,inset:n,...a}){return f.jsx(H9,{ref:e,className:De("px-2 py-1.5 text-sm font-semibold",n&&"pl-8",t),...a})}kE.displayName=H9.displayName;function Bf({ref:e,className:t,...n}){return f.jsx(G9,{ref:e,className:De("-mx-1 my-1 h-px bg-muted",t),...n})}Bf.displayName=G9.displayName;var pfe=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Ho=pfe.reduce((e,t)=>{const n=nV(`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}},{}),mfe="Label",W9=x.forwardRef((e,t)=>f.jsx(Ho.label,{...e,ref:t,onMouseDown:n=>{n.target.closest("button, input, select, textarea")||(e.onMouseDown?.(n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));W9.displayName=mfe;var hfe=W9;function Kt({className:e,...t}){return f.jsx(hfe,{"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 Sd({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 K9({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 xN(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 _y="Switch",[gfe]=Ci(_y),[bfe,vfe]=gfe(_y),Z9=x.forwardRef((e,t)=>{const{__scopeSwitch:n,name:a,checked:r,defaultChecked:i,required:s,disabled:c,value:u="on",onCheckedChange:d,form:m,...h}=e,[g,v]=x.useState(null),w=Qt(t,k=>v(k)),S=x.useRef(!1),y=g?m||!!g.closest("form"):!0,[_,E]=jo({prop:r,defaultProp:i??!1,onChange:d,caller:_y});return f.jsxs(bfe,{scope:n,checked:_,disabled:c,children:[f.jsx(Et.button,{type:"button",role:"switch","aria-checked":_,"aria-required":s,"data-state":J9(_),"data-disabled":c?"":void 0,disabled:c,value:u,...h,ref:w,onClick:Ge(e.onClick,k=>{E(C=>!C),y&&(S.current=k.isPropagationStopped(),S.current||k.stopPropagation())})}),y&&f.jsx(X9,{control:g,bubbles:!S.current,name:a,value:u,checked:_,required:s,disabled:c,form:m,style:{transform:"translateX(-100%)"}})]})});Z9.displayName=_y;var Y9="SwitchThumb",q9=x.forwardRef((e,t)=>{const{__scopeSwitch:n,...a}=e,r=vfe(Y9,n);return f.jsx(Et.span,{"data-state":J9(r.checked),"data-disabled":r.disabled?"":void 0,...a,ref:t})});q9.displayName=Y9;var yfe="SwitchBubbleInput",X9=x.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:a=!0,...r},i)=>{const s=x.useRef(null),c=Qt(s,i),u=xN(n),d=dN(t);return x.useEffect(()=>{const m=s.current;if(!m)return;const h=window.HTMLInputElement.prototype,v=Object.getOwnPropertyDescriptor(h,"checked").set;if(u!==n&&v){const w=new Event("click",{bubbles:a});v.call(m,n),m.dispatchEvent(w)}},[u,n,a]),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}})});X9.displayName=yfe;function J9(e){return e?"checked":"unchecked"}var Q9=Z9,wfe=q9;function ky({ref:e,className:t,...n}){return f.jsx(Q9,{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(wfe,{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")})})}ky.displayName=Q9.displayName;var e8=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"}),xfe="VisuallyHidden",t8=x.forwardRef((e,t)=>f.jsx(Et.span,{...e,ref:t,style:{...e8,...e.style}}));t8.displayName=xfe;var Sfe=t8,[Ty]=Ci("Tooltip",[Hs]),Ny=Hs(),n8="TooltipProvider",Efe=700,TE="tooltip.open",[_fe,SN]=Ty(n8),r8=e=>{const{__scopeTooltip:t,delayDuration:n=Efe,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(_fe,{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})};r8.displayName=n8;var kp="Tooltip",[kfe,gm]=Ty(kp),a8=e=>{const{__scopeTooltip:t,children:n,open:a,defaultOpen:r,onOpenChange:i,disableHoverableContent:s,delayDuration:c}=e,u=SN(kp,e.__scopeTooltip),d=Ny(t),[m,h]=x.useState(null),g=Dr(),v=x.useRef(0),w=s??u.disableHoverableContent,S=c??u.delayDuration,y=x.useRef(!1),[_,E]=jo({prop:a,defaultProp:r??!1,onChange:A=>{A?(u.onOpen(),document.dispatchEvent(new CustomEvent(TE))):u.onClose(),i?.(A)},caller:kp}),k=x.useMemo(()=>_?y.current?"delayed-open":"instant-open":"closed",[_]),C=x.useCallback(()=>{window.clearTimeout(v.current),v.current=0,y.current=!1,E(!0)},[E]),R=x.useCallback(()=>{window.clearTimeout(v.current),v.current=0,E(!1)},[E]),I=x.useCallback(()=>{window.clearTimeout(v.current),v.current=window.setTimeout(()=>{y.current=!0,E(!0),v.current=0},S)},[S,E]);return x.useEffect(()=>()=>{v.current&&(window.clearTimeout(v.current),v.current=0)},[]),f.jsx(gy,{...d,children:f.jsx(kfe,{scope:t,contentId:g,open:_,stateAttribute:k,trigger:m,onTriggerChange:h,onTriggerEnter:x.useCallback(()=>{u.isOpenDelayedRef.current?I():C()},[u.isOpenDelayedRef,I,C]),onTriggerLeave:x.useCallback(()=>{w?R():(window.clearTimeout(v.current),v.current=0)},[R,w]),onOpen:C,onClose:R,disableHoverableContent:w,children:n})})};a8.displayName=kp;var NE="TooltipTrigger",i8=x.forwardRef((e,t)=>{const{__scopeTooltip:n,...a}=e,r=gm(NE,n),i=SN(NE,n),s=Ny(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(dm,{asChild:!0,...s,children:f.jsx(Et.button,{"aria-describedby":r.open?r.contentId:void 0,"data-state":r.stateAttribute,...a,ref:u,onPointerMove:Ge(e.onPointerMove,g=>{g.pointerType!=="touch"&&!m.current&&!i.isPointerInTransitRef.current&&(r.onTriggerEnter(),m.current=!0)}),onPointerLeave:Ge(e.onPointerLeave,()=>{r.onTriggerLeave(),m.current=!1}),onPointerDown:Ge(e.onPointerDown,()=>{r.open&&r.onClose(),d.current=!0,document.addEventListener("pointerup",h,{once:!0})}),onFocus:Ge(e.onFocus,()=>{d.current||r.onOpen()}),onBlur:Ge(e.onBlur,r.onClose),onClick:Ge(e.onClick,r.onClose)})})});i8.displayName=NE;var EN="TooltipPortal",[Tfe,Nfe]=Ty(EN,{forceMount:void 0}),o8=e=>{const{__scopeTooltip:t,forceMount:n,children:a,container:r}=e,i=gm(EN,t);return f.jsx(Tfe,{scope:t,forceMount:n,children:f.jsx(Ma,{present:n||i.open,children:f.jsx(xd,{asChild:!0,container:r,children:a})})})};o8.displayName=EN;var Ju="TooltipContent",s8=x.forwardRef((e,t)=>{const n=Nfe(Ju,e.__scopeTooltip),{forceMount:a=n.forceMount,side:r="top",...i}=e,s=gm(Ju,e.__scopeTooltip);return f.jsx(Ma,{present:a||s.open,children:s.disableHoverableContent?f.jsx(l8,{side:r,...i,ref:t}):f.jsx(Cfe,{side:r,...i,ref:t})})}),Cfe=x.forwardRef((e,t)=>{const n=gm(Ju,e.__scopeTooltip),a=SN(Ju,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((w,S)=>{const y=w.currentTarget,_={x:w.clientX,y:w.clientY},E=Ofe(_,y.getBoundingClientRect()),k=Dfe(_,E),C=jfe(S.getBoundingClientRect()),R=$fe([...k,...C]);c(R),h(!0)},[h]);return x.useEffect(()=>()=>g(),[g]),x.useEffect(()=>{if(u&&m){const w=y=>v(y,m),S=y=>v(y,u);return u.addEventListener("pointerleave",w),m.addEventListener("pointerleave",S),()=>{u.removeEventListener("pointerleave",w),m.removeEventListener("pointerleave",S)}}},[u,m,v,g]),x.useEffect(()=>{if(s){const w=S=>{const y=S.target,_={x:S.clientX,y:S.clientY},E=u?.contains(y)||m?.contains(y),k=!Lfe(_,s);E?g():k&&(g(),d())};return document.addEventListener("pointermove",w),()=>document.removeEventListener("pointermove",w)}},[u,m,s,d,g]),f.jsx(l8,{...e,ref:i})}),[Rfe,Afe]=Ty(kp,{isInside:!1}),Ife=dle("TooltipContent"),l8=x.forwardRef((e,t)=>{const{__scopeTooltip:n,children:a,"aria-label":r,onEscapeKeyDown:i,onPointerDownOutside:s,...c}=e,u=gm(Ju,n),d=Ny(n),{onClose:m}=u;return x.useEffect(()=>(document.addEventListener(TE,m),()=>document.removeEventListener(TE,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(vd,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:i,onPointerDownOutside:s,onFocusOutside:h=>h.preventDefault(),onDismiss:m,children:f.jsxs(by,{"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(Ife,{children:a}),f.jsx(Rfe,{scope:n,isInside:!0,children:f.jsx(Sfe,{id:u.contentId,role:"tooltip",children:r||a})})]})})});s8.displayName=Ju;var c8="TooltipArrow",u8=x.forwardRef((e,t)=>{const{__scopeTooltip:n,...a}=e,r=Ny(n);return Afe(c8,n).isInside?null:f.jsx(vy,{...r,...a,ref:t})});u8.displayName=c8;function Ofe(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 Dfe(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 jfe(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 Lfe(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 $fe(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),Mfe(t)}function Mfe(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 Pfe=r8,Ufe=a8,zfe=i8,Ffe=o8,Bfe=s8,Hfe=u8;function d8({delayDuration:e=0,...t}){return f.jsx(Pfe,{"data-slot":"tooltip-provider",delayDuration:e,...t})}function Dt({...e}){return f.jsx(d8,{children:f.jsx(Ufe,{"data-slot":"tooltip",...e})})}function jt({...e}){return f.jsx(zfe,{"data-slot":"tooltip-trigger",...e})}function Lt({className:e,sideOffset:t=0,children:n,...a}){return f.jsx(Ffe,{children:f.jsxs(Bfe,{"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(Hfe,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}class Vfe{name="mcp_inspector_open";properties;constructor(t){this.properties={server_url:t.serverUrl,connection_count:t.connectionCount}}}class kU{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 TU{name="mcp_resource_read";properties;constructor(t){this.properties={resource_uri:t.resourceUri,server_id:t.serverId,success:t.success,error:t.error}}}class NU{name="mcp_prompt_call";properties;constructor(t){this.properties={prompt_name:t.promptName,server_id:t.serverId,success:t.success,error:t.error}}}class CU{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 Gfe{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 Wfe{name="mcp_server_removed";properties;constructor(t){this.properties={server_id:t.serverId}}}class Kfe{name="mcp_command_palette_open";properties;constructor(t){this.properties={trigger:t.trigger}}}class Zfe{name="mcp_tool_saved";properties;constructor(t){this.properties={tool_name:t.toolName,server_id:t.serverId}}}function Jx(){try{return"0.13.0-canary.6"}catch{return"0.0.0"}}var Yfe={};function Qx(){try{return typeof window<"u"&&typeof document<"u"}catch{return!1}}class RU{endpoint;timeout;constructor(t,n=3e3){this.endpoint=t,this.timeout=n}async logEvent(t){try{const n=new AbortController,a=setTimeout(()=>n.abort(),this.timeout),r=await fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t),signal:n.signal});if(clearTimeout(a),!r.ok)throw new Error(`HTTP error! status: ${r.status}`)}catch{}}}function bs(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=Qx(),n=this.isTelemetryDisabled();if(this._source=this.getStoredSource()||"inspector",n)this._posthogClient=null,this._scarfClient=null;else if(!t)this._posthogClient=null,this._scarfClient=null;else{try{this._posthogClient=new RU(this.POSTHOG_PROXY_URL,3e3)}catch{this._posthogClient=null}try{this._scarfClient=new RU(this.SCARF_PROXY_URL,3e3)}catch{this._scarfClient=null}}}isTelemetryDisabled(){return typeof localStorage<"u"&&localStorage.getItem(bs("disabled"))==="true"||typeof process<"u"&&Yfe?.MCP_USE_ANONYMIZED_TELEMETRY==="false"}getStoredSource(){return typeof localStorage<"u"?localStorage.getItem(bs("source")):null}static getInstance(){return yr.instance||(yr.instance=new yr),yr.instance}setSource(t){this._source=t,typeof localStorage<"u"&&localStorage.setItem(bs("source"),t)}getSource(){return this._source}get userId(){if(this._currUserId)return this._currUserId;if(!Qx())return this._currUserId=this.UNKNOWN_USER_ID,this._currUserId;try{const t=localStorage.getItem(bs("user_id"));if(t)this._currUserId=t;else{const n=this.generateUserId();localStorage.setItem(bs("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:Jx(),language:"typescript",source:this._source,package:"inspector"}};await this._posthogClient.logEvent(n)}catch{}if(this._scarfClient)try{const n={};n.mcp_use_version=Jx(),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&&Qx())try{const n=Jx();let a=!1,r=!1;const i=localStorage.getItem(bs("download_version"));if(i?n>i&&(a=!0,r=!1,localStorage.setItem(bs("download_version"),n)):(a=!0,r=!0,localStorage.setItem(bs("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 Vfe(t);await this.capture(n)}}const qfe={model:"stub-model",stopReason:"endTurn",role:"assistant",content:{type:"text",text:"positive"}};function Xfe({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(qfe)},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 Jfe({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 Hg=()=>{},Vg=()=>{},Gg=()=>{},Wg=()=>{},f8=x.createContext(null);function _N(){const e=x.use(f8);if(!e)throw new Error("useMcpContext must be used within a McpProvider");return e}function Qfe({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,w]=x.useState([]),S=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,C]=x.useState(!1),R=x.useRef(!1);x.useEffect(()=>{typeof window<"u"&&!R.current&&(R.current=!0,Qn(()=>import("./transport-wrapper-browser-BI4dDu3b.js"),[]).then(L=>{E.current=L.wrapTransportForLogging,C(!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([])},[]),te=x.useCallback(L=>{U($=>{const F=[L,...$];return F.length>O?F.slice(0,O):F})},[]),ae=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,$)=>{w(F=>{const W=F.find(X=>X.id===L);return W?(W.resolve($),F.filter(X=>X.id!==L)):F})},[]),G=x.useCallback((L,$)=>{w(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(ie=>[...ie,X]),typeof window<"u"&&Qn(async()=>{const{toast:ie}=await Promise.resolve().then(()=>$U);return{toast:ie}},void 0).then(({toast:ie})=>{const le=ie(f.jsx(Xfe,{requestId:W,serverName:t,onViewDetails:()=>{const J=new globalThis.CustomEvent("navigate-to-sampling",{detail:{requestId:W}});window.dispatchEvent(J),ie.dismiss(le)},onApprove:J=>{h(q=>{const se=q.find(he=>he.id===W);return se?(se.resolve(J),ie.success("Sampling request approved"),q.filter(he=>he.id!==W)):q}),ie.dismiss(le)},onDeny:()=>{h(J=>{const q=J.find(se=>se.id===W);return q?(q.reject(new Error("User denied sampling request from toast")),ie.error("Sampling request denied"),J.filter(se=>se.id!==W)):J}),ie.dismiss(le)}}),{duration:5e3})})}),[t]),ne=x.useCallback(async L=>new Promise(($,F)=>{const W=`elicitation-${S.current++}`,X={id:W,request:L,timestamp:Date.now(),serverName:t,resolve:$,reject:F};w(ie=>[...ie,X]),typeof window<"u"&&Qn(async()=>{const{toast:ie}=await Promise.resolve().then(()=>$U);return{toast:ie}},void 0).then(({toast:ie})=>{const le=ie(f.jsx(Jfe,{requestId:W,serverName:t,mode:L.mode||"form",message:L.message,url:L.mode==="url"?L.url:void 0,onViewDetails:()=>{const J=new globalThis.CustomEvent("navigate-to-elicitation",{detail:{requestId:W}});window.dispatchEvent(J),ie.dismiss(le)},onOpenUrl:L.mode==="url"?()=>{window.open(L.url,"_blank"),ie.dismiss(le)}:void 0,onCancel:()=>{w(J=>{const q=J.find(se=>se.id===W);return q?(q.reject(new Error("User cancelled elicitation request from toast")),ie.error("Elicitation request cancelled"),J.filter(se=>se.id!==W)):J}),ie.dismiss(le)}}),{duration:5e3})})}),[t]),j=qT({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=>{te({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:ae,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:ae,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,ae,B,_,Z,G]),null}function epe({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:Hg,rejectSampling:Vg,pendingElicitationRequests:[],approveElicitation:Gg,rejectElicitation:Wg,callTool:async()=>{},readResource:async()=>{},listPrompts:async()=>{},getPrompt:async()=>{},authenticate:()=>{},retry:()=>{},clearStorage:()=>{},disconnect:()=>{},client:null}))))}const _=localStorage.getItem("mcp-inspector-auto-connect");_!==null&&s(_==="true")}catch(y){console.error("Failed to load connections from localStorage:",y)}finally{r(!0)}},[]),x.useEffect(()=>{a&&localStorage.setItem("mcp-inspector-connections",JSON.stringify(c))},[c,a]),x.useEffect(()=>{a&&localStorage.setItem("mcp-inspector-auto-connect",String(i))},[i,a]);const d=x.useCallback((y,_,E,k)=>{const C=c.find(A=>A.url===y),R=t.find(A=>A.url===y);if(C&&R){if(JSON.stringify(C.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:_||C.name||"MCP Server",proxyConfig:E,transportType:k||C.transportType};u(M=>[...M,O]),n(M=>[...M,{id:y,url:y,name:_||C.name||"MCP Server",state:"connecting",tools:[],resources:[],prompts:[],error:null,authUrl:null,customHeaders:E?.customHeaders,transportType:k||C.transportType,proxyConfig:E,notifications:[],unreadNotificationCount:0,markNotificationRead:()=>{},markAllNotificationsRead:()=>{},clearNotifications:()=>{},pendingSamplingRequests:[],approveSampling:Hg,rejectSampling:Vg,pendingElicitationRequests:[],approveElicitation:Gg,rejectElicitation:Wg,callTool:async()=>{},readResource:async()=>{},listPrompts:async()=>{},getPrompt:async()=>{},authenticate:()=>{},retry:()=>{},clearStorage:()=>{},disconnect:()=>{},client:null}])},10);return}return}if(C&&!R){(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:C.id||y,url:y,name:_||C.name||"MCP Server",state:"connecting",tools:[],resources:[],prompts:[],error:null,authUrl:null,customHeaders:E?.customHeaders||C.proxyConfig?.customHeaders,transportType:k||C.transportType,proxyConfig:E||C.proxyConfig,notifications:[],unreadNotificationCount:0,markNotificationRead:()=>{},markAllNotificationsRead:()=>{},clearNotifications:()=>{},pendingSamplingRequests:[],approveSampling:Hg,rejectSampling:Vg,pendingElicitationRequests:[],approveElicitation:Gg,rejectElicitation:Wg,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:Hg,rejectSampling:Vg,pendingElicitationRequests:[],approveElicitation:Gg,rejectElicitation:Wg,callTool:async()=>{},readResource:async()=>{},listPrompts:async()=>{},getPrompt:async()=>{},authenticate:()=>{},retry:()=>{},clearStorage:()=>{},disconnect:()=>{},client:null}])},[c,t]),m=x.useCallback(y=>{const _=t.find(k=>k.id===y);_&&(console.log(`[McpContext] Cleaning up connection: ${y}`),_.disconnect&&(console.log(`[McpContext] Disconnecting from server: ${y}`),_.disconnect()),_.clearStorage&&(console.log(`[McpContext] Clearing OAuth storage for connection: ${y}`),_.clearStorage())),u(k=>k.filter(C=>C.id!==y)),n(k=>k.filter(C=>C.id!==y));const E=localStorage.getItem("mcp-inspector-connections");if(E)try{const C=JSON.parse(E).filter(R=>(R.id||R.url)!==y);localStorage.setItem("mcp-inspector-connections",JSON.stringify(C))}catch(k){console.error("Failed to update localStorage on remove:",k)}yr.getInstance().capture(new Wfe({serverId:y}))},[t]),h=x.useCallback((y,_)=>{u(E=>E.map(k=>k.id===y||k.url===y?{...k,..._}:k)),n(E=>E.map(k=>k.id===y?{...k,..._}:k))},[]),g=x.useCallback(y=>{n(_=>{const E=_.findIndex(R=>R.id===y.id);if(E===-1)return _;const k=_[E];if(k.state===y.state&&k.tools===y.tools&&k.resources===y.resources&&k.prompts===y.prompts&&k.error===y.error&&k.serverInfo===y.serverInfo&&k.client===y.client&&k.notifications===y.notifications&&k.unreadNotificationCount===y.unreadNotificationCount&&k.pendingSamplingRequests.length===y.pendingSamplingRequests.length&&k.pendingElicitationRequests.length===y.pendingElicitationRequests.length)return _;const C=[..._];return C[E]=y,C})},[]),v=x.useCallback(y=>{console.log("Connect requested for:",y)},[]),w=x.useCallback(y=>{console.log("Disconnect requested for:",y)},[]),S=x.useMemo(()=>({connections:t,addConnection:d,removeConnection:m,updateConnectionConfig:h,autoConnect:i,setAutoConnect:s,connectServer:v,disconnectServer:w,configLoaded:a}),[t,d,m,h,i,v,w,a]);return f.jsxs(f8.Provider,{value:S,children:[e,a&&i&&c.map(y=>{const _=`${y.id||y.url}-${y.proxyConfig?.proxyAddress?"proxy":"direct"}`;return console.warn("[McpContext] Rendering McpConnectionWrapper with key:",_,"proxyConfig:",y.proxyConfig),f.jsx(Qfe,{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 tpe=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),npe=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,a)=>a?a.toUpperCase():n.toLowerCase()),AU=e=>{const t=npe(e);return t.charAt(0).toUpperCase()+t.slice(1)},p8=(...e)=>e.filter((t,n,a)=>!!t&&t.trim()!==""&&a.indexOf(t)===n).join(" ").trim(),rpe=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};var ape={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 ipe=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,...ape,width:t,height:t,stroke:e,strokeWidth:a?Number(n)*24/Number(t):n,className:p8("lucide",r),...!i&&!rpe(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(ipe,{ref:i,iconNode:t,className:p8(`lucide-${tpe(AU(e))}`,`lucide-${e}`,a),...r}));return n.displayName=AU(e),n};const ope=[["path",{d:"M12 17V3",key:"1cwfxf"}],["path",{d:"m6 11 6 6 6-6",key:"12ii2o"}],["path",{d:"M19 21H5",key:"150jfl"}]],spe=Xe("arrow-down-to-line",ope);const lpe=[["path",{d:"m18 9-6-6-6 6",key:"kcunyi"}],["path",{d:"M12 3v14",key:"7cf3v8"}],["path",{d:"M5 21h14",key:"11awu3"}]],cpe=Xe("arrow-up-from-line",lpe);const upe=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],dpe=Xe("arrow-up",upe);const fpe=[["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"}]],kN=Xe("bell",fpe);const ppe=[["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"}]],m8=Xe("brush",ppe);const mpe=[["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"}]],hpe=Xe("bug",mpe);const gpe=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],ta=Xe("check",gpe);const bpe=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Xl=Xe("chevron-down",bpe);const vpe=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],ype=Xe("chevron-right",vpe);const wpe=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],TN=Xe("chevron-left",wpe);const xpe=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],Spe=Xe("chevron-up",xpe);const Epe=[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]],_pe=Xe("chevrons-up-down",Epe);const kpe=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}]],IU=Xe("circle-minus",kpe);const Tpe=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Qu=Xe("clock",Tpe);const Npe=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],NN=Xe("code",Npe);const Cpe=[["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"}]],Rpe=Xe("cog",Cpe);const Ape=[["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"}]],Ipe=Xe("command",Ape);const Ope=[["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"}]],jr=Xe("copy",Ope);const Dpe=[["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"}]],Cy=Xe("database",Dpe);const jpe=[["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"}]],bm=Xe("download",jpe);const Lpe=[["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"}]],$pe=Xe("ellipsis-vertical",Lpe);const Mpe=[["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"}]],CE=Xe("external-link",Mpe);const Ppe=[["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"}]],h8=Xe("eye-off",Ppe);const Upe=[["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"}]],RE=Xe("eye",Upe);const zpe=[["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"}]],Fpe=Xe("file-code",zpe);const Bpe=[["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"}]],Hpe=Xe("file-image",Bpe);const Vpe=[["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"}]],CN=Xe("file-text",Vpe);const Gpe=[["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"}]],Wpe=Xe("file",Gpe);const Kpe=[["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"}]],Zpe=Xe("folder-open",Kpe);const Ype=[["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"}]],qpe=Xe("globe",Ype);const Xpe=[["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"}]],Jpe=Xe("grip-vertical",Xpe);const Qpe=[["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"}]],g8=Xe("hash",Qpe);const eme=[["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"}]],ov=Xe("history",eme);const tme=[["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"}]],b8=Xe("key",tme);const nme=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Ls=Xe("loader-circle",nme);const rme=[["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"}]],RN=Xe("maximize-2",rme);const ame=[["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"}]],AN=Xe("maximize",ame);const ime=[["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"}]],ome=Xe("message-circle",ime);const sme=[["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"}]],Tp=Xe("message-square",sme);const lme=[["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"}]],cme=Xe("minimize",lme);const ume=[["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"}]],OU=Xe("monitor",ume);const dme=[["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"}]],fme=Xe("moon",dme);const pme=[["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"}]],mme=Xe("picture-in-picture",pme);const hme=[["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"}]],v8=Xe("play",hme);const gme=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],y8=Xe("plus",gme);const bme=[["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"}]],DU=Xe("rotate-ccw",bme);const vme=[["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"}]],IN=Xe("save",vme);const yme=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],Ed=Xe("search",yme);const wme=[["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"}]],xme=Xe("send",wme);const Sme=[["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"}]],Eme=Xe("server",Sme);const _me=[["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"}]],gu=Xe("settings",_me);const kme=[["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"}]],Tme=Xe("shield",kme);const Nme=[["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"}]],Cme=Xe("sparkles",Nme);const Rme=[["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"}]],w8=Xe("square-check-big",Rme);const Ame=[["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"}]],Ime=Xe("square-pen",Ame);const Ome=[["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"}]],Dme=Xe("sun-dim",Ome);const jme=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],eS=Xe("terminal",jme);const Lme=[["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"}]],$s=Xe("trash-2",Lme);const $me=[["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"}]],Mme=Xe("trash",$me);const Pme=[["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"}]],Ul=Xe("wrench",Pme);const Ume=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Yi=Xe("x",Ume);const zme=[["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"}]],Np=Xe("zap",zme);function Fme(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 Bme=e=>{switch(e){case"success":return Gme;case"info":return Kme;case"warning":return Wme;case"error":return Zme;default:return null}},Hme=Array(12).fill(0),Vme=({visible:e,className:t})=>ue.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},ue.createElement("div",{className:"sonner-spinner"},Hme.map((n,a)=>ue.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${a}`})))),Gme=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"})),Wme=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"})),Kme=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"})),Zme=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"})),Yme=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"})),qme=()=>{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 AE=1;class Xme{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:AE++,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(Qme(d)&&!d.ok){i=!1;const h=typeof n.error=="function"?await n.error(`HTTP error! status: ${d.status}`):n.error,g=typeof n.description=="function"?await n.description(`HTTP error! status: ${d.status}`):n.description,w=typeof h=="object"&&!ue.isValidElement(h)?h:{message:h};this.create({id:a,type:"error",description:g,...w})}else if(d instanceof Error){i=!1;const h=typeof n.error=="function"?await n.error(d):n.error,g=typeof n.description=="function"?await n.description(d):n.description,w=typeof h=="object"&&!ue.isValidElement(h)?h:{message:h};this.create({id:a,type:"error",description:g,...w})}else if(n.success!==void 0){i=!1;const h=typeof n.success=="function"?await n.success(d):n.success,g=typeof n.description=="function"?await n.description(d):n.description,w=typeof h=="object"&&!ue.isValidElement(h)?h:{message:h};this.create({id:a,type:"success",description:g,...w})}}).catch(async d=>{if(s=["reject",d],n.error!==void 0){i=!1;const m=typeof n.error=="function"?await n.error(d):n.error,h=typeof n.description=="function"?await n.description(d):n.description,v=typeof m=="object"&&!ue.isValidElement(m)?m:{message:m};this.create({id:a,type:"error",description:h,...v})}}).finally(()=>{i&&(this.dismiss(a),a=void 0),n.finally==null||n.finally.call(n)}),u=()=>new Promise((d,m)=>c.then(()=>s[0]==="reject"?m(s[1]):d(s[1])).catch(m));return typeof a!="string"&&typeof a!="number"?{unwrap:u}:Object.assign(a,{unwrap:u})},this.custom=(t,n)=>{const a=n?.id||AE++;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 ma=new Xme,Jme=(e,t)=>{const n=t?.id||AE++;return ma.addToast({title:e,...t,id:n}),n},Qme=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",ehe=Jme,the=()=>ma.toasts,nhe=()=>ma.getActiveToasts(),Jt=Object.assign(ehe,{success:ma.success,info:ma.info,warning:ma.warning,error:ma.error,custom:ma.custom,message:ma.message,promise:ma.promise,dismiss:ma.dismiss,loading:ma.loading},{getHistory:the,getToasts:nhe});Fme("[data-sonner-toaster][dir=ltr],html[dir=ltr]{--toast-icon-margin-start:-3px;--toast-icon-margin-end:4px;--toast-svg-margin-start:-1px;--toast-svg-margin-end:0px;--toast-button-margin-start:auto;--toast-button-margin-end:0;--toast-close-button-start:0;--toast-close-button-end:unset;--toast-close-button-transform:translate(-35%, -35%)}[data-sonner-toaster][dir=rtl],html[dir=rtl]{--toast-icon-margin-start:4px;--toast-icon-margin-end:-3px;--toast-svg-margin-start:0px;--toast-svg-margin-end:-1px;--toast-button-margin-start:0;--toast-button-margin-end:auto;--toast-close-button-start:unset;--toast-close-button-end:0;--toast-close-button-transform:translate(35%, -35%)}[data-sonner-toaster]{position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1:hsl(0, 0%, 99%);--gray2:hsl(0, 0%, 97.3%);--gray3:hsl(0, 0%, 95.1%);--gray4:hsl(0, 0%, 93%);--gray5:hsl(0, 0%, 90.9%);--gray6:hsl(0, 0%, 88.7%);--gray7:hsl(0, 0%, 85.8%);--gray8:hsl(0, 0%, 78%);--gray9:hsl(0, 0%, 56.1%);--gray10:hsl(0, 0%, 52.3%);--gray11:hsl(0, 0%, 43.5%);--gray12:hsl(0, 0%, 9%);--border-radius:8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:0;z-index:999999999;transition:transform .4s ease}@media (hover:none) and (pointer:coarse){[data-sonner-toaster][data-lifted=true]{transform:none}}[data-sonner-toaster][data-x-position=right]{right:var(--offset-right)}[data-sonner-toaster][data-x-position=left]{left:var(--offset-left)}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translateX(-50%)}[data-sonner-toaster][data-y-position=top]{top:var(--offset-top)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--offset-bottom)}[data-sonner-toast]{--y:translateY(100%);--lift-amount:calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:0;overflow-wrap:anywhere}[data-sonner-toast][data-styled=true]{padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-y-position=top]{top:0;--y:translateY(-100%);--lift:1;--lift-amount:calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y:translateY(100%);--lift:-1;--lift-amount:calc(var(--lift) * var(--gap))}[data-sonner-toast][data-styled=true] [data-description]{font-weight:400;line-height:1.4;color:#3f3f3f}[data-rich-colors=true][data-sonner-toast][data-styled=true] [data-description]{color:inherit}[data-sonner-toaster][data-sonner-theme=dark] [data-description]{color:#e8e8e8}[data-sonner-toast][data-styled=true] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast][data-styled=true] [data-icon]{display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast][data-styled=true] [data-icon]>*{flex-shrink:0}[data-sonner-toast][data-styled=true] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast][data-styled=true] [data-content]{display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;font-weight:500;cursor:pointer;outline:0;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}[data-sonner-toast][data-styled=true] [data-button]:focus-visible{box-shadow:0 0 0 2px rgba(0,0,0,.4)}[data-sonner-toast][data-styled=true] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast][data-styled=true] [data-cancel]{color:var(--normal-text);background:rgba(0,0,0,.08)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-styled=true] [data-cancel]{background:rgba(255,255,255,.3)}[data-sonner-toast][data-styled=true] [data-close-button]{position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);background:var(--normal-bg);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast][data-styled=true] [data-close-button]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-styled=true] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast][data-styled=true]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]::before{content:'';position:absolute;left:-100%;right:-100%;height:100%;z-index:-1}[data-sonner-toast][data-y-position=top][data-swiping=true]::before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]::before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]::before{content:'';position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast][data-expanded=true]::after{content:'';position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y:translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale:var(--toasts-before) * 0.05 + 1;--y:translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-x-position=right]{right:0}[data-sonner-toast][data-x-position=left]{left:0}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y:translateY(calc(var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=false]{--y:translateY(40%);opacity:0;transition:transform .5s,opacity .2s}[data-sonner-toast][data-removed=true][data-front=false]::before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y,0)) translateX(var(--swipe-amount-x,0));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width:600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-sonner-theme=light]{--normal-bg:#fff;--normal-border:var(--gray4);--normal-text:var(--gray12);--success-bg:hsl(143, 85%, 96%);--success-border:hsl(145, 92%, 87%);--success-text:hsl(140, 100%, 27%);--info-bg:hsl(208, 100%, 97%);--info-border:hsl(221, 91%, 93%);--info-text:hsl(210, 92%, 45%);--warning-bg:hsl(49, 100%, 97%);--warning-border:hsl(49, 91%, 84%);--warning-text:hsl(31, 92%, 45%);--error-bg:hsl(359, 100%, 97%);--error-border:hsl(359, 100%, 94%);--error-text:hsl(360, 100%, 45%)}[data-sonner-toaster][data-sonner-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg:#000;--normal-border:hsl(0, 0%, 20%);--normal-text:var(--gray1)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg:#fff;--normal-border:var(--gray3);--normal-text:var(--gray12)}[data-sonner-toaster][data-sonner-theme=dark]{--normal-bg:#000;--normal-bg-hover:hsl(0, 0%, 12%);--normal-border:hsl(0, 0%, 20%);--normal-border-hover:hsl(0, 0%, 25%);--normal-text:var(--gray1);--success-bg:hsl(150, 100%, 6%);--success-border:hsl(147, 100%, 12%);--success-text:hsl(150, 86%, 65%);--info-bg:hsl(215, 100%, 6%);--info-border:hsl(223, 43%, 17%);--info-text:hsl(216, 87%, 65%);--warning-bg:hsl(64, 100%, 6%);--warning-border:hsl(60, 100%, 9%);--warning-text:hsl(46, 87%, 65%);--error-bg:hsl(358, 76%, 10%);--error-border:hsl(357, 89%, 16%);--error-text:hsl(358, 100%, 81%)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size:16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:first-child{animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}100%{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}100%{opacity:.15}}@media (prefers-reduced-motion){.sonner-loading-bar,[data-sonner-toast],[data-sonner-toast]>*{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}");function Kg(e){return e.label!==void 0}const rhe=3,ahe="24px",ihe="16px",jU=4e3,ohe=356,she=14,lhe=45,che=200;function $i(...e){return e.filter(Boolean).join(" ")}function uhe(e){const[t,n]=e.split("-"),a=[];return t&&a.push(t),n&&a.push(n),a}const dhe=e=>{var t,n,a,r,i,s,c,u,d;const{invert:m,toast:h,unstyled:g,interacting:v,setHeights:w,visibleToasts:S,heights:y,index:_,toasts:E,expanded:k,removeToast:C,defaultRichColors:R,closeButton:I,style:A,cancelButtonStyle:O,actionButtonStyle:M,className:U="",descriptionClassName:H="",duration:K,position:ee,gap:te,expandByDefault:ae,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),[ie,le]=ue.useState(!1),[J,q]=ue.useState(!1),[se,he]=ue.useState(0),[ce,Te]=ue.useState(0),He=ue.useRef(h.duration||K||jU),Se=ue.useRef(null),_e=ue.useRef(null),Ue=_===0,fe=_+1<=S,Oe=h.type,Be=h.dismissible!==!1,xe=h.className||"",tt=h.descriptionClassName||"",it=ue.useMemo(()=>y.findIndex(Ye=>Ye.toastId===h.id)||0,[y,h.id]),ht=ue.useMemo(()=>{var Ye;return(Ye=h.closeButton)!=null?Ye:I},[h.closeButton,I]),Rt=ue.useMemo(()=>h.duration||K||jU,[h.duration,K]),je=ue.useRef(0),Fe=ue.useRef(0),pt=ue.useRef(0),Qe=ue.useRef(null),[Tt,nt]=ee.split("-"),Ie=ue.useMemo(()=>y.reduce((Ye,vt,Mt)=>Mt>=it?Ye:Ye+vt.height,0),[y,it]),$e=qme(),Ve=h.invert||m,at=Oe==="loading";Fe.current=ue.useMemo(()=>it*te+Ie,[it,Ie]),ue.useEffect(()=>{He.current=Rt},[Rt]),ue.useEffect(()=>{L(!0)},[]),ue.useEffect(()=>{const Ye=_e.current;if(Ye){const vt=Ye.getBoundingClientRect().height;return Te(vt),w(Mt=>[{toastId:h.id,height:vt,position:h.position},...Mt]),()=>w(Mt=>Mt.filter(Pt=>Pt.toastId!==h.id))}},[w,h.id]),ue.useLayoutEffect(()=>{if(!z)return;const Ye=_e.current,vt=Ye.style.height;Ye.style.height="auto";const Mt=Ye.getBoundingClientRect().height;Ye.style.height=vt,Te(Mt),w(Pt=>Pt.find(fn=>fn.toastId===h.id)?Pt.map(fn=>fn.toastId===h.id?{...fn,height:Mt}:fn):[{toastId:h.id,height:Mt,position:h.position},...Pt])},[z,h.title,h.description,w,h.id,h.jsx,h.action,h.cancel]);const dt=ue.useCallback(()=>{F(!0),he(Fe.current),w(Ye=>Ye.filter(vt=>vt.toastId!==h.id)),setTimeout(()=>{C(h)},che)},[h,C,w,Fe]);ue.useEffect(()=>{if(h.promise&&Oe==="loading"||h.duration===1/0||h.type==="loading")return;let Ye;return k||v||$e?(()=>{if(pt.current<je.current){const Pt=new Date().getTime()-je.current;He.current=He.current-Pt}pt.current=new Date().getTime()})():(()=>{He.current!==1/0&&(je.current=new Date().getTime(),Ye=setTimeout(()=>{h.onAutoClose==null||h.onAutoClose.call(h,h),dt()},He.current))})(),()=>clearTimeout(Ye)},[k,v,h,Oe,$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:$i(B?.loader,h==null||(vt=h.classNames)==null?void 0:vt.loader,"sonner-loader"),"data-visible":Oe==="loading"},Z.loading)}return ue.createElement(Vme,{className:$i(B?.loader,h==null||(Ye=h.classNames)==null?void 0:Ye.loader),visible:Oe==="loading"})}const xt=h.icon||Z?.[Oe]||Bme(Oe);var dn,hn;return ue.createElement("li",{tabIndex:0,ref:_e,className:$i(U,xe,B?.toast,h==null||(t=h.classNames)==null?void 0:t.toast,B?.default,B?.[Oe],h==null||(n=h.classNames)==null?void 0:n[Oe]),"data-sonner-toast":"","data-rich-colors":(dn=h.richColors)!=null?dn:R,"data-styled":!(h.jsx||h.unstyled||g),"data-mounted":z,"data-promise":!!h.promise,"data-swiped":J,"data-removed":$,"data-visible":fe,"data-y-position":Tt,"data-x-position":nt,"data-index":_,"data-front":Ue,"data-swiping":W,"data-dismissible":Be,"data-type":Oe,"data-invert":Ve,"data-swipe-out":ie,"data-swipe-direction":j,"data-expanded":!!(k||ae&&z),"data-testid":h.testId,style:{"--index":_,"--toasts-before":_,"--z-index":E.length-_,"--offset":`${$?se:Fe.current}px`,"--initial-height":ae?"auto":`${ce}px`,...A,...h.style},onDragEnd:()=>{X(!1),ne(null),Qe.current=null},onPointerDown:Ye=>{Ye.button!==2&&(at||!Be||(Se.current=new Date,he(Fe.current),Ye.target.setPointerCapture(Ye.pointerId),Ye.target.tagName!=="BUTTON"&&(X(!0),Qe.current={x:Ye.clientX,y:Ye.clientY})))},onPointerUp:()=>{var Ye,vt,Mt;if(ie||!Be)return;Qe.current=null;const Pt=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()-((Mt=Se.current)==null?void 0:Mt.getTime()),Kn=re==="x"?Pt:fr,Zn=Math.abs(Kn)/fn;if(Math.abs(Kn)>=lhe||Zn>.11){he(Fe.current),h.onDismiss==null||h.onDismiss.call(h,h),V(re==="x"?Pt>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,Mt,Pt;if(!Qe.current||!Be||((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:uhe(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 aa=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*aa(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*aa(Kn);pn.x=Math.abs(en)<Math.abs(Kn)?en:Kn}(Math.abs(pn.x)>0||Math.abs(pn.y)>0)&&q(!0),(Mt=_e.current)==null||Mt.style.setProperty("--swipe-amount-x",`${pn.x}px`),(Pt=_e.current)==null||Pt.style.setProperty("--swipe-amount-y",`${pn.y}px`)}},ht&&!h.jsx&&Oe!=="loading"?ue.createElement("button",{"aria-label":G,"data-disabled":at,"data-close-button":!0,onClick:at||!Be?()=>{}:()=>{dt(),h.onDismiss==null||h.onDismiss.call(h,h)},className:$i(B?.closeButton,h==null||(a=h.classNames)==null?void 0:a.closeButton)},(hn=Z?.close)!=null?hn:Yme):null,(Oe||h.icon||h.promise)&&h.icon!==null&&(Z?.[Oe]!==null||h.icon)?ue.createElement("div",{"data-icon":"",className:$i(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:$i(B?.content,h==null||(i=h.classNames)==null?void 0:i.content)},ue.createElement("div",{"data-title":"",className:$i(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:$i(H,tt,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&&Kg(h.cancel)?ue.createElement("button",{"data-button":!0,"data-cancel":!0,style:h.cancelButtonStyle||O,onClick:Ye=>{Kg(h.cancel)&&Be&&(h.cancel.onClick==null||h.cancel.onClick.call(h.cancel,Ye),dt())},className:$i(B?.cancelButton,h==null||(u=h.classNames)==null?void 0:u.cancelButton)},h.cancel.label):null,ue.isValidElement(h.action)?h.action:h.action&&Kg(h.action)?ue.createElement("button",{"data-button":!0,"data-action":!0,style:h.actionButtonStyle||M,onClick:Ye=>{Kg(h.action)&&(h.action.onClick==null||h.action.onClick.call(h.action,Ye),!Ye.defaultPrevented&&dt())},className:$i(B?.actionButton,h==null||(d=h.classNames)==null?void 0:d.actionButton)},h.action.label):null)};function LU(){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 fhe(e,t){const n={};return[e,t].forEach((a,r)=>{const i=r===1,s=i?"--mobile-offset":"--offset",c=i?ihe:ahe;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 x8=ue.forwardRef(function(t,n){const{id:a,invert:r,position:i="bottom-right",hotkey:s=["altKey","KeyT"],expand:c,closeButton:u,className:d,offset:m,mobileOffset:h,theme:g="light",richColors:v,duration:w,style:S,visibleToasts:y=rhe,toastOptions:_,dir:E=LU(),gap:k=she,icons:C,containerAriaLabel:R="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),[te,ae]=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||ma.dismiss(z.id),L.filter(({id:F})=>F!==z.id)})},[]);return ue.useEffect(()=>ma.subscribe(z=>{if(z.dismiss){requestAnimationFrame(()=>{A(L=>L.map($=>$.id===z.id?{...$,delete:!0}:$))});return}setTimeout(()=>{eV.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":`${R} ${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"?LU():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":`${ohe}px`,"--gap":`${k}px`,...S,...fhe(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:()=>{te||ee(!1)},onDragEnd:()=>ee(!1),onPointerDown:X=>{X.target instanceof HTMLElement&&X.target.dataset.dismissible==="false"||ae(!0)},onPointerUp:()=>ae(!1)},O.filter(X=>!X.position&&L===0||X.position===z).map((X,ie)=>{var le,J;return ue.createElement(dhe,{key:X.id,icons:C,index:ie,toast:X,defaultRichColors:v,duration:(le=_?.duration)!=null?le:w,className:_?.className,descriptionClassName:_?.descriptionClassName,invert:r,visibleToasts:y,closeButton:(J=_?.closeButton)!=null?J:u,interacting:te,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}))}),$U=Object.freeze(Object.defineProperty({__proto__:null,Toaster:x8,toast:Jt},Symbol.toStringTag,{value:"Module"}));var Ry="Dialog",[S8]=Ci(Ry),[phe,Ri]=S8(Ry),E8=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]=jo({prop:a,defaultProp:r??!1,onChange:i,caller:Ry});return f.jsx(phe,{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})};E8.displayName=Ry;var _8="DialogTrigger",k8=x.forwardRef((e,t)=>{const{__scopeDialog:n,...a}=e,r=Ri(_8,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":jN(r.open),...a,ref:i,onClick:Ge(e.onClick,r.onOpenToggle)})});k8.displayName=_8;var ON="DialogPortal",[mhe,T8]=S8(ON,{forceMount:void 0}),N8=e=>{const{__scopeDialog:t,forceMount:n,children:a,container:r}=e,i=Ri(ON,t);return f.jsx(mhe,{scope:t,forceMount:n,children:x.Children.map(a,s=>f.jsx(Ma,{present:n||i.open,children:f.jsx(xd,{asChild:!0,container:r,children:s})}))})};N8.displayName=ON;var sv="DialogOverlay",C8=x.forwardRef((e,t)=>{const n=T8(sv,e.__scopeDialog),{forceMount:a=n.forceMount,...r}=e,i=Ri(sv,e.__scopeDialog);return i.modal?f.jsx(Ma,{present:a||i.open,children:f.jsx(ghe,{...r,ref:t})}):null});C8.displayName=sv;var hhe=Ml("DialogOverlay.RemoveScroll"),ghe=x.forwardRef((e,t)=>{const{__scopeDialog:n,...a}=e,r=Ri(sv,n);return f.jsx(pm,{as:hhe,allowPinchZoom:!0,shards:[r.contentRef],children:f.jsx(Et.div,{"data-state":jN(r.open),...a,ref:t,style:{pointerEvents:"auto",...a.style}})})}),zl="DialogContent",R8=x.forwardRef((e,t)=>{const n=T8(zl,e.__scopeDialog),{forceMount:a=n.forceMount,...r}=e,i=Ri(zl,e.__scopeDialog);return f.jsx(Ma,{present:a||i.open,children:i.modal?f.jsx(bhe,{...r,ref:t}):f.jsx(vhe,{...r,ref:t})})});R8.displayName=zl;var bhe=x.forwardRef((e,t)=>{const n=Ri(zl,e.__scopeDialog),a=x.useRef(null),r=Qt(t,n.contentRef,a);return x.useEffect(()=>{const i=a.current;if(i)return yy(i)},[]),f.jsx(A8,{...e,ref:r,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Ge(e.onCloseAutoFocus,i=>{i.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:Ge(e.onPointerDownOutside,i=>{const s=i.detail.originalEvent,c=s.button===0&&s.ctrlKey===!0;(s.button===2||c)&&i.preventDefault()}),onFocusOutside:Ge(e.onFocusOutside,i=>i.preventDefault())})}),vhe=x.forwardRef((e,t)=>{const n=Ri(zl,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=Ri(zl,n),u=x.useRef(null),d=Qt(t,u);return dy(),f.jsxs(f.Fragment,{children:[f.jsx(cm,{asChild:!0,loop:!0,trapped:a,onMountAutoFocus:r,onUnmountAutoFocus:i,children:f.jsx(vd,{role:"dialog",id:c.contentId,"aria-describedby":c.descriptionId,"aria-labelledby":c.titleId,"data-state":jN(c.open),...s,ref:d,onDismiss:()=>c.onOpenChange(!1)})}),f.jsxs(f.Fragment,{children:[f.jsx(yhe,{titleId:c.titleId}),f.jsx(xhe,{contentRef:u,descriptionId:c.descriptionId})]})]})}),DN="DialogTitle",I8=x.forwardRef((e,t)=>{const{__scopeDialog:n,...a}=e,r=Ri(DN,n);return f.jsx(Et.h2,{id:r.titleId,...a,ref:t})});I8.displayName=DN;var O8="DialogDescription",D8=x.forwardRef((e,t)=>{const{__scopeDialog:n,...a}=e,r=Ri(O8,n);return f.jsx(Et.p,{id:r.descriptionId,...a,ref:t})});D8.displayName=O8;var j8="DialogClose",L8=x.forwardRef((e,t)=>{const{__scopeDialog:n,...a}=e,r=Ri(j8,n);return f.jsx(Et.button,{type:"button",...a,ref:t,onClick:Ge(e.onClick,()=>r.onOpenChange(!1))})});L8.displayName=j8;function jN(e){return e?"open":"closed"}var $8="DialogTitleWarning",[Yke,M8]=ile($8,{contentName:zl,titleName:DN,docsSlug:"dialog"}),yhe=({titleId:e})=>{const t=M8($8),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
94
94
|
|
|
95
95
|
If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
96
96
|
|
|
@@ -335,7 +335,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
335
335
|
}]);
|
|
336
336
|
});
|
|
337
337
|
})();
|
|
338
|
-
`;function M4(e){if(!e.contentWindow)return;const t=()=>{try{const n=e.contentWindow?.document;if(!n||n.querySelector("script[data-console-interceptor]"))return;const a=n.createElement("script");a.setAttribute("data-console-interceptor","true"),a.textContent=LEe;const r=n.head||n.body||n.documentElement;r&&r.insertBefore(a,r.firstChild)}catch(n){n instanceof Error&&n.name!=="SecurityError"&&console.warn("[IframeConsole] Failed to inject console interceptor:",n)}};try{const n=e.contentDocument;if(n?.readyState==="complete"||n?.readyState==="interactive")t();else{const a=()=>{t(),e.removeEventListener("load",a)};e.addEventListener("load",a,{once:!0}),setTimeout(()=>{try{(e.contentDocument?.readyState==="complete"||e.contentDocument?.readyState==="interactive")&&t()}catch{}},100)}}catch{}}function $Ee({title:e,onClose:t,className:n}){return f.jsxs("div",{className:De("fixed top-0 left-0 right-0 z-50 flex items-center justify-between px-4 py-3","bg-background/80 backdrop-blur-md border-b border-border","supports-[backdrop-filter]:bg-background/60",n),children:[f.jsx("div",{className:"flex items-center gap-2",children:f.jsx("span",{className:"text-sm font-semibold text-foreground/80",children:"MCP Inspector"})}),f.jsx("div",{className:"flex-1 text-center",children:f.jsx("h2",{className:"text-sm font-medium text-foreground truncate max-w-md mx-auto",children:e})}),f.jsx("div",{className:"flex items-center",children:f.jsxs("button",{onClick:t,className:De("flex items-center gap-2 px-3 py-1.5 rounded-md","text-sm font-medium","bg-background/50 hover:bg-background/80","border border-border hover:border-border/80","transition-colors","focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2"),"aria-label":"Exit Fullscreen",children:[f.jsx(Yi,{className:"w-4 h-4"}),f.jsx("span",{className:"hidden sm:inline",children:"Exit Fullscreen"})]})})]})}function MEe(e={}){const{enabled:t=!0,maxLogs:n=1e3,proxyToPageConsole:a=!1}=e,[r,i]=x.useState([]),[s,c]=x.useState(!1),u=x.useRef(0),d=x.useCallback(h=>{if(!t)return;const g={...h,id:`log-${++u.current}-${Date.now()}`};if(i(v=>[...v,g].slice(-n)),a){const v="[WIDGET CONSOLE]",w=h.args.map(S=>{if(typeof S=="object"&&S!==null)try{return JSON.stringify(S,null,2)}catch{return String(S)}return S});switch(h.level){case"error":console.error(v,...w);break;case"warn":console.warn(v,...w);break;case"info":console.info(v,...w);break;case"debug":console.debug(v,...w);break;case"trace":console.trace(v,...w);break;default:console.log(v,...w)}}},[t,n,a]),m=x.useCallback(()=>{i([]),u.current=0},[]);return x.useEffect(()=>{if(!t)return;const h=g=>{g.data&&g.data.type==="iframe-console-log"&&g.data.level&&Array.isArray(g.data.args)&&d({level:g.data.level,args:g.data.args,timestamp:g.data.timestamp||new Date().toISOString(),url:g.data.url})};return window.addEventListener("message",h),()=>{window.removeEventListener("message",h)}},[t,d]),{logs:r,addLog:d,clearLogs:m,isOpen:s,setIsOpen:c}}function PEe({level:e}){const t={log:"bg-zinc-500",info:"bg-blue-500",warn:"bg-yellow-500",error:"bg-red-500",debug:"bg-purple-500",trace:"bg-gray-500"};return f.jsx("span",{className:De("px-1.5 py-0.5 text-[11px] font-mono font-semibold rounded-full text-white",t[e]),children:e.toUpperCase()})}function UEe({log:e}){const t=x.useMemo(()=>{try{return new Date(e.timestamp).toLocaleTimeString()}catch{return""}},[e.timestamp]),n=a=>{if(a===null)return"null";if(a===void 0)return"undefined";if(typeof a=="string")return a;if(typeof a=="object")try{return JSON.stringify(a,null,2)}catch{return String(a)}return String(a)};return f.jsxs("div",{className:De("font-mono text-xs p-2 border-b border-zinc-200 dark:border-zinc-800",e.level==="error"&&"bg-red-50/30 dark:bg-red-950/10",e.level==="warn"&&"bg-yellow-50/30 dark:bg-yellow-950/10"),children:[f.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[f.jsx(PEe,{level:e.level}),f.jsx("span",{className:"text-zinc-500 dark:text-zinc-400 text-[10px]",children:t}),e.url&&f.jsx("span",{className:"text-zinc-400 dark:text-zinc-500 text-[10px] truncate flex-1",children:(()=>{try{return new URL(e.url).pathname}catch{return e.url}})()})]}),f.jsx("div",{className:"pl-1",children:e.args.map((a,r)=>f.jsx("pre",{className:De("whitespace-pre-wrap break-words",e.level==="error"&&"text-red-700 dark:text-red-400",e.level==="warn"&&"text-yellow-700 dark:text-yellow-400"),children:n(a)},r))})]})}const P4="mcp-inspector-console-proxy-enabled";function zEe({iframeId:e,enabled:t=!0}){const[n,a]=x.useState(()=>{if(typeof window>"u")return!1;try{return localStorage.getItem(P4)==="true"}catch{return!1}}),{logs:r,clearLogs:i,isOpen:s,setIsOpen:c}=MEe({enabled:t,proxyToPageConsole:n}),u=x.useRef(null);x.useEffect(()=>{try{localStorage.setItem(P4,String(n))}catch{}},[n]);const d=x.useMemo(()=>r.filter(h=>h.level==="error").length,[r]),m=x.useMemo(()=>r.filter(h=>h.level==="warn").length,[r]);return x.useEffect(()=>{s&&u.current&&(u.current.scrollTop=u.current.scrollHeight)},[r,s]),f.jsxs(RK,{open:s,onOpenChange:c,children:[f.jsx(AK,{asChild:!0,children:f.jsxs(Dt,{children:[f.jsx(jt,{asChild:!0,children:f.jsxs(Le,{variant:"outline",size:"sm",className:"relative bg-white/90 dark:bg-zinc-900/90 backdrop-blur-sm shadow-sm hover:bg-white dark:hover:bg-zinc-900",onClick:()=>c(!0),children:[f.jsx(eS,{className:"size-4"}),(d>0||m>0)&&f.jsx("span",{className:De("ml-2 px-1.5 py-0.5 text-xs rounded-full text-white font-semibold",d>0?"bg-red-500":"bg-yellow-500"),children:d+m})]})}),f.jsx(Lt,{children:f.jsxs("p",{children:[d+m," console logs from the iframe"]})})]})}),f.jsxs(IK,{side:"bottom",className:"h-[400px] flex flex-col p-0",children:[f.jsx(OK,{className:"px-4 py-3 border-b border-zinc-200 dark:border-zinc-800",children:f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsxs(DK,{className:"flex items-center gap-2",children:[f.jsx(eS,{className:"size-4"}),"Widget Console Logs",r.length>0&&f.jsxs("span",{className:"text-sm font-normal text-zinc-500 dark:text-zinc-400",children:["(",r.length," ",r.length===1?"log":"logs",")"]})]}),f.jsxs("div",{className:"flex items-center gap-4 pr-4",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(ky,{id:"proxy-console-toggle",checked:n,onCheckedChange:a}),f.jsx(Kt,{htmlFor:"proxy-console-toggle",className:"text-sm font-normal cursor-pointer",children:"Proxy logs to page console"})]}),r.length>0&&f.jsxs(Le,{variant:"ghost",size:"sm",onClick:i,className:"-my-2",children:[f.jsx(Mme,{className:"size-4 mr-1"}),"Clear"]})]})]})}),f.jsx("div",{ref:u,className:"flex-1 overflow-auto bg-zinc-50 dark:bg-zinc-950",children:r.length===0?f.jsx("div",{className:"flex items-center justify-center h-full text-zinc-500 dark:text-zinc-400",children:f.jsxs("div",{className:"text-center",children:[f.jsx(eS,{className:"size-8 mx-auto mb-2 opacity-50"}),f.jsx("p",{className:"text-sm",children:"No console logs yet"}),f.jsx("p",{className:"text-xs mt-1",children:"Logs from iframes will appear here"})]})}):f.jsx("div",{children:r.map(h=>f.jsx(UEe,{log:h},h.id))})})]})]})}function FEe({displayMode:e,onDisplayModeChange:t,toolInput:n,toolOutput:a,toolResult:r,iframeRef:i,toolId:s}){const[c,u]=x.useState(!1),[d,m]=x.useState(null),h=x.useRef(null);x.useEffect(()=>{if(!c||!i.current)return;(()=>{try{const _=i.current?.contentWindow;_?.openai?.widgetState!==void 0&&m(_.openai.widgetState)}catch{}})(),i.current?.contentWindow&&i.current.contentWindow.postMessage({type:"mcp-inspector:getWidgetState",toolId:s},"*");const y=_=>{(_.data?.type==="mcp-inspector:widgetStateResponse"&&_.data.toolId===s||_.data?.type==="openai:setWidgetState"&&_.data.toolId===s)&&m(_.data.state)};return window.addEventListener("message",y),()=>{window.removeEventListener("message",y)}},[c,i,s]),x.useEffect(()=>{if(!c)return;const S=y=>{h.current&&!h.current.contains(y.target)&&u(!1)};return document.addEventListener("mousedown",S),()=>{document.removeEventListener("mousedown",S)}},[c]),x.useEffect(()=>(c?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[c]);const g=S=>{if(S===null)return"null";if(S===void 0)return"undefined";if(typeof S=="object")try{return JSON.stringify(S,null,2)}catch{return String(S)}return String(S)},v=e==="fullscreen",w=e==="pip";return f.jsxs(f.Fragment,{children:[f.jsxs("div",{className:"flex items-center gap-2",children:[!v&&!w&&f.jsxs(f.Fragment,{children:[f.jsxs(Dt,{children:[f.jsx(jt,{asChild:!0,children:f.jsx(Le,{variant:"outline",size:"sm",className:"bg-white/90 dark:bg-zinc-900/90 backdrop-blur-sm shadow-sm hover:bg-white dark:hover:bg-zinc-900",onClick:()=>t("fullscreen"),children:f.jsx(RN,{className:"size-4"})})}),f.jsx(Lt,{children:f.jsx("p",{children:"Enter fullscreen mode"})})]}),f.jsxs(Dt,{children:[f.jsx(jt,{asChild:!0,children:f.jsx(Le,{variant:"outline",size:"sm",className:"bg-white/90 dark:bg-zinc-900/90 backdrop-blur-sm shadow-sm hover:bg-white dark:hover:bg-zinc-900",onClick:()=>t("pip"),children:f.jsx(mme,{className:"size-4"})})}),f.jsx(Lt,{children:f.jsx("p",{children:"Enter picture-in-picture mode"})})]})]}),f.jsxs(Dt,{children:[f.jsx(jt,{asChild:!0,children:f.jsx(Le,{variant:"outline",size:"sm",className:"bg-white/90 dark:bg-zinc-900/90 backdrop-blur-sm shadow-sm hover:bg-white dark:hover:bg-zinc-900",onClick:()=>u(!0),children:f.jsx(hpe,{className:"size-4"})})}),f.jsx(Lt,{children:f.jsx("p",{children:"Open debug overlay"})})]})]}),c&&f.jsxs("div",{ref:h,style:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"#000000",color:"#ffffff",fontFamily:"monospace",fontSize:"12px",zIndex:1e4,overflow:"auto",padding:"16px"},onClick:S=>{S.target===h.current&&u(!1)},children:[f.jsx("button",{onClick:()=>u(!1),style:{position:"absolute",top:"16px",right:"16px",backgroundColor:"rgba(255, 255, 255, 0.1)",color:"#ffffff",border:"none",borderRadius:"4px",width:"32px",height:"32px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"18px",lineHeight:1},"aria-label":"Close",children:"×"}),f.jsxs("div",{style:{maxWidth:"1200px",margin:"0 auto",paddingTop:"40px"},children:[f.jsx("h1",{style:{fontSize:"18px",fontWeight:"bold",marginBottom:"16px",borderBottom:"1px solid #333",paddingBottom:"8px"},children:"Debug Info"}),f.jsx("table",{style:{width:"100%",borderCollapse:"collapse",borderSpacing:0},children:f.jsxs("tbody",{children:[f.jsxs("tr",{style:{borderBottom:"1px solid #333"},children:[f.jsx("td",{style:{padding:"8px",fontWeight:"bold",width:"200px",verticalAlign:"top"},children:"Props (Tool Input)"}),f.jsx("td",{style:{padding:"8px",whiteSpace:"pre-wrap",wordBreak:"break-all"},children:g(n)})]}),f.jsxs("tr",{style:{borderBottom:"1px solid #333"},children:[f.jsx("td",{style:{padding:"8px",fontWeight:"bold",width:"200px",verticalAlign:"top"},children:"Output (Tool Output)"}),f.jsx("td",{style:{padding:"8px",whiteSpace:"pre-wrap",wordBreak:"break-all"},children:g(a)})]}),f.jsxs("tr",{style:{borderBottom:"1px solid #333"},children:[f.jsx("td",{style:{padding:"8px",fontWeight:"bold",width:"200px",verticalAlign:"top"},children:"Metadata"}),f.jsx("td",{style:{padding:"8px",whiteSpace:"pre-wrap",wordBreak:"break-all"},children:g(r?._meta||r?.contents?.[0]?._meta||null)})]}),f.jsxs("tr",{style:{borderBottom:"1px solid #333"},children:[f.jsx("td",{style:{padding:"8px",fontWeight:"bold",width:"200px",verticalAlign:"top"},children:"Widget State"}),f.jsx("td",{style:{padding:"8px",whiteSpace:"pre-wrap",wordBreak:"break-all"},children:g(d)})]}),f.jsxs("tr",{style:{borderBottom:"1px solid #333"},children:[f.jsx("td",{style:{padding:"8px",fontWeight:"bold",width:"200px",verticalAlign:"top"},children:"Display Mode"}),f.jsx("td",{style:{padding:"8px"},children:e})]})]})})]})]})]})}function U4({children:e,className:t,noWrapper:n}){return n?e:f.jsx("div",{className:De("bg-zinc-100 dark:bg-zinc-900 bg-[radial-gradient(circle,_rgba(0,0,0,0.2)_1px,_transparent_1px)] dark:bg-[radial-gradient(circle,_rgba(255,255,255,0.2)_1px,_transparent_1px)] bg-[length:32px_32px]",t),children:e})}function BEe({componentUrl:e,toolName:t,toolArgs:n,toolResult:a,serverId:r,readResource:i,className:s,noWrapper:c=!1,showConsole:u=!0}){const d=x.useRef(null),m=x.useRef(null),[h,g]=x.useState(!1),[v,w]=x.useState(null),[S,y]=x.useState(null),[_,E]=x.useState(400),k=x.useRef(0),C=x.useRef(0),R=x.useRef(!1),[I,A]=x.useState(!1),[O,M]=x.useState("inline"),[U,H]=x.useState(!1),[K,ee]=x.useState(!1),[te,ae]=x.useState(!1),[B,Z]=x.useState(null),[G,re]=x.useState(null),j=x.useRef(`tool-${Date.now()}-${Math.random().toString(36).substring(7)}`).current,z=_N().connections.find(X=>X.id===r),L=z?.url,{resolvedTheme:$}=ew();x.useEffect(()=>{(async()=>{try{const ie=a?.structuredContent||null,le=await i(e),J=ie||n;Z(J),re(ie);let q=null;const se=a?._meta||a?.contents?.[0]?._meta;se?.["openai/widgetCSP"]&&(q=se["openai/widgetCSP"]);const he=new URLSearchParams,ce={toolInput:B,toolOutput:ie,toolId:j};he.set("mcpUseParams",JSON.stringify(ce));const Te=a?._meta||a?.contents?.[0]?._meta,He=Te?.["mcp-use/widget"]?.html&&Te?.["mcp-use/widget"]?.dev;ae(He||!1);const Se=Te?.["mcp-use/widget"]?.name,_e={serverId:r,uri:e,toolInput:J,toolOutput:ie,resourceData:le,toolId:j,widgetCSP:q,theme:$};if(He&&Se&&L){const fe=new URL(L).origin,Oe=`${fe}/mcp-use/widgets/${Se}`;_e.devWidgetUrl=Oe,_e.devServerBaseUrl=fe}const Ue=await fetch("/inspector/api/resources/widget/store",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(_e)});if(!Ue.ok){const fe=await Ue.json().catch(()=>({error:"Unknown error"}));throw new Error(`Failed to store widget data: ${fe.error||Ue.statusText}`)}if(He&&Se&&L){const fe=`/inspector/api/dev-widget/${j}`;y(fe),H(!0)}else{const fe=`/inspector/api/resources/widget/${j}`;y(fe),H(!0)}}catch(ie){console.error("Error storing widget data:",ie),w(ie instanceof Error?ie.message:"Failed to prepare widget")}})()},[e,r,n,a,j,i,L,$]);const F=x.useCallback(X=>{if(d.current?.contentWindow)try{const ie=d.current.contentWindow,le=d.current.contentDocument;if(X.theme!==void 0&&le){const J=le.documentElement;J.setAttribute("data-theme",X.theme),J.style.colorScheme=X.theme}if(ie.openai){X.displayMode!==void 0&&(ie.openai.displayMode=X.displayMode),X.theme!==void 0&&(ie.openai.theme=X.theme),X.maxHeight!==void 0&&(ie.openai.maxHeight=X.maxHeight),X.locale!==void 0&&(ie.openai.locale=X.locale),X.safeArea!==void 0&&(ie.openai.safeArea=X.safeArea),X.userAgent!==void 0&&(ie.openai.userAgent=X.userAgent);try{const J=ie.CustomEvent,q=new J("openai:set_globals",{detail:{globals:{...ie.openai}}});ie.dispatchEvent(q)}catch{ie.postMessage({type:"openai:globalsChanged",updates:X},"*")}}}catch{d.current.contentWindow.postMessage({type:"openai:globalsChanged",updates:X},"*")}},[]),W=x.useCallback(async X=>{try{if(X==="fullscreen"){if(document.fullscreenElement){M(X),F({displayMode:X});return}m.current&&(await m.current.requestFullscreen(),M(X),F({displayMode:X}),console.log("[OpenAIComponentRenderer] Entered fullscreen"))}else document.fullscreenElement&&await document.exitFullscreen(),M(X),F({displayMode:X}),console.log("[OpenAIComponentRenderer] Exited fullscreen")}catch(ie){console.error("[OpenAIComponentRenderer] Fullscreen error:",ie),M(X),F({displayMode:X})}},[F]);return x.useEffect(()=>{if(!S)return;const X=async q=>{if(!(!d.current||q.source!==d.current.contentWindow)&&q.data?.type!=="iframe-console-log"){if(q.data?.type==="mcp-inspector:getWidgetState"){try{const se=d.current?.contentWindow;se?.openai?.widgetState!==void 0&&d.current?.contentWindow?.postMessage({type:"mcp-inspector:widgetStateResponse",toolId:q.data.toolId,state:se.openai.widgetState},"*")}catch{}return}switch(q.data.type){case"openai:setWidgetState":break;case"openai:callTool":try{if(!z)throw new Error("Server connection not available");const{toolName:se,params:he,requestId:ce}=q.data,Te=await z.callTool(se,he||{},{timeout:6e5,resetTimeoutOnProgress:!0});let He;Te&&typeof Te=="object"?Array.isArray(Te.contents)?He={content:Te.contents.map(Se=>typeof Se=="string"?{type:"text",text:Se}:Se.type==="text"&&Se.text?{type:"text",text:Se.text}:Se.type==="image"&&Se.data?{type:"image",image_url:{url:Se.data}}:{type:"text",text:JSON.stringify(Se)})}:He={content:[{type:"text",text:typeof Te=="string"?Te:JSON.stringify(Te)}]}:He={content:[{type:"text",text:String(Te)}]},d.current?.contentWindow?.postMessage({type:"openai:callTool:response",requestId:ce,result:He},"*")}catch(se){console.error("[OpenAIComponentRenderer] Tool call error:",se),d.current?.contentWindow?.postMessage({type:"openai:callTool:response",requestId:q.data.requestId,error:se instanceof Error?se.message:String(se)},"*")}break;case"openai:sendFollowup":try{const{message:se}=q.data,he=typeof se=="string"?se:se?.prompt||se;if(!he){console.warn("[OpenAIComponentRenderer] No prompt in followup message");return}const ce=new window.CustomEvent("mcp-inspector:widget-followup",{detail:{prompt:he,serverId:r}});window.dispatchEvent(ce);try{const Te=JSON.parse(localStorage.getItem("mcp-inspector-pending-followups")||"[]");Te.push({prompt:he,serverId:r,timestamp:Date.now()}),localStorage.setItem("mcp-inspector-pending-followups",JSON.stringify(Te.slice(-10)))}catch{}}catch(se){console.error("[OpenAIComponentRenderer] Failed to send followup:",se)}break;case"openai:requestDisplayMode":try{const{mode:se}=q.data;se&&["inline","pip","fullscreen"].includes(se)&&await W(se)}catch(se){console.error("[OpenAIComponentRenderer] Failed to change display mode:",se)}break;case"openai:notifyIntrinsicHeight":try{const{height:se}=q.data;if(typeof se=="number"&&se>0){let he=se;if(O==="fullscreen"||O==="pip"){const ce=typeof window<"u"?window.innerHeight:se;he=Math.min(se,ce)}(se!==C.current||he!==_)&&(C.current=se,k.current=he,R.current=!0,E(he))}}catch(se){console.error("[OpenAIComponentRenderer] Failed to handle intrinsic height notification:",se)}break}}};window.addEventListener("message",X);const ie=()=>{if(g(!0),w(null),d.current)try{const q=!!d.current.contentDocument;q&&U?M4(d.current):q||H(!1)}catch{H(!1)}$&&setTimeout(()=>{F({theme:$})},50)},le=()=>{w("Failed to load component")},J=d.current;return J?.addEventListener("load",ie),J?.addEventListener("error",le),J&&U&&J.contentDocument?.readyState==="complete"&&M4(J),()=>{window.removeEventListener("message",X),J?.removeEventListener("load",ie),J?.removeEventListener("error",le)}},[S,U,W,z,r,$,F,te]),x.useEffect(()=>{if(!d.current?.contentDocument||!h)return;const ie=d.current.contentDocument.documentElement;ie.setAttribute("data-theme",$),ie.style.colorScheme=$,F({theme:$})},[$,h,F]),x.useEffect(()=>{if(!S)return;const X=()=>{if(R.current)return;const J=d.current,se=J?.contentWindow?.document?.body;if(!J||!se)return;const he=se.scrollHeight||0,ce=typeof window<"u"?window.innerHeight:he,Te=Math.min(he,ce);Te>0&&Te!==k.current&&(k.current=Te,E(Te))};let ie;const le=()=>{X(),ie=window.requestAnimationFrame(le)};return le(),window.addEventListener("resize",X),()=>{window.cancelAnimationFrame(ie),window.removeEventListener("resize",X)}},[S]),x.useEffect(()=>{const X=()=>{const ie=m.current;if(!ie)return;const le=ie.clientHeight;A(le>_)};return X(),window.addEventListener("resize",X),()=>{window.removeEventListener("resize",X)}},[_]),x.useEffect(()=>{const X=()=>{!document.fullscreenElement&&O==="fullscreen"?(M("inline"),F({displayMode:"inline"}),console.log("[OpenAIComponentRenderer] Fullscreen exited by user")):document.fullscreenElement&&O!=="fullscreen"&&(M("fullscreen"),F({displayMode:"fullscreen"}))};return document.addEventListener("fullscreenchange",X),document.addEventListener("fullscreenerror",ie=>{console.error("[OpenAIComponentRenderer] Fullscreen error:",ie)}),()=>{document.removeEventListener("fullscreenchange",X)}},[O,F]),x.useEffect(()=>{if(S&&$&&h){const X=setTimeout(()=>{F({theme:$})},0);return()=>clearTimeout(X)}},[$,S,h,F]),v?f.jsx("div",{className:s,children:f.jsx("div",{className:"bg-red-50/30 dark:bg-red-950/20 border border-red-200/50 dark:border-red-800/50 rounded-lg p-4",children:f.jsxs("p",{className:"text-sm text-red-600 dark:text-red-400",children:["Failed to load component: ",v]})})}):S?f.jsxs(U4,{className:s,noWrapper:c,children:[!h&&f.jsx("div",{className:"flex absolute left-0 top-0 items-center justify-center w-full h-full",children:f.jsx(Ei,{className:"size-5"})}),u&&U&&O!=="fullscreen"&&O!=="pip"&&f.jsxs("div",{className:"absolute top-2 right-2 z-10 flex items-center gap-2",children:[f.jsx(zEe,{iframeId:j,enabled:!0}),te&&f.jsx(FEe,{displayMode:O,onDisplayModeChange:W,toolInput:B,toolOutput:G,toolResult:a,iframeRef:d,toolId:j})]}),f.jsxs("div",{ref:m,className:De("w-full h-full flex flex-col justify-center items-center",I&&"items-center",O==="fullscreen"&&"bg-background",O==="pip"&&"fixed bottom-6 right-6 z-50 rounded-3xl w-[768px] h-96 shadow-2xl border overflow-hidden"),onMouseEnter:()=>O==="pip"&&ee(!0),onMouseLeave:()=>O==="pip"&&ee(!1),children:[O==="fullscreen"&&document.fullscreenElement&&f.jsx($Ee,{title:t,onClose:()=>W("inline")}),O==="pip"&&f.jsx("button",{onClick:()=>W("inline"),className:De("absolute top-2 right-2 z-50","flex items-center justify-center","w-8 h-8 rounded-full","bg-background/90 hover:bg-background","border border-border","shadow-lg","transition-opacity duration-200","focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",K?"opacity-100":"opacity-0"),"aria-label":"Exit Picture in Picture",children:f.jsx(Yi,{className:"w-4 h-4 text-foreground"})}),f.jsx("div",{className:De("flex-1 w-full flex justify-center items-center",O==="fullscreen"&&"pt-14",I&&"items-center"),children:f.jsx("iframe",{ref:d,src:S,className:De(O==="inline"&&" w-full max-w-[768px]",O==="fullscreen"&&"w-full h-full rounded-none",O==="pip"&&"w-full h-full rounded-lg"),style:{height:O==="fullscreen"||O==="pip"?"100%":`${_}px`},sandbox:"allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox",title:`OpenAI Component: ${t}`,allow:"web-share"})})]})]}):f.jsx(U4,{className:s,noWrapper:c,children:f.jsx("div",{className:"flex absolute left-0 top-0 items-center justify-center w-full h-full",children:f.jsx(Ei,{className:"size-5"})})})}const GO=x.memo(BEe);var HEe=Object.defineProperty,LK=e=>{throw TypeError(e)},VEe=(e,t,n)=>t in e?HEe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Xc=(e,t,n)=>VEe(e,typeof t!="symbol"?t+"":t,n),WO=(e,t,n)=>t.has(e)||LK("Cannot "+n),Mn=(e,t,n)=>(WO(e,t,"read from private field"),n?n.call(e):t.get(e)),fi=(e,t,n)=>t.has(e)?LK("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),R_=(e,t,n,a)=>(WO(e,t,"write to private field"),t.set(e,n),n),Rr=(e,t,n)=>(WO(e,t,"access private method"),n);const z4={PREFERRED_FRAME_SIZE:"preferred-frame-size",INITIAL_RENDER_DATA:"initial-render-data"},F4="mcpui.dev/ui-";function GEe(e){let t;try{t=new URL(e)}catch(n){return console.error("Error parsing URL:",n),!1}return t.protocol==="http:"||t.protocol==="https:"}function WEe(e,t){if(e.mimeType!=="text/html"&&e.mimeType!=="text/uri-list")return{error:"Resource must be of type text/html (for HTML content) or text/uri-list (for URL content)."};if(e.mimeType==="text/uri-list"){let n="";if("text"in e&&typeof e.text=="string"&&e.text.trim()!=="")n=e.text;else if("blob"in e&&typeof e.blob=="string")try{n=new TextDecoder().decode(Uint8Array.from(atob(e.blob),i=>i.charCodeAt(0)))}catch(i){return console.error("Error decoding base64 blob for URL content:",i),{error:"Error decoding URL from blob."}}else return{error:"URL resource expects a non-empty text or blob field containing the URL."};if(n.trim()==="")return{error:"URL content is empty."};const a=n.split(`
|
|
338
|
+
`;function M4(e){if(!e.contentWindow)return;const t=()=>{try{const n=e.contentWindow?.document;if(!n||n.querySelector("script[data-console-interceptor]"))return;const a=n.createElement("script");a.setAttribute("data-console-interceptor","true"),a.textContent=LEe;const r=n.head||n.body||n.documentElement;r&&r.insertBefore(a,r.firstChild)}catch(n){n instanceof Error&&n.name!=="SecurityError"&&console.warn("[IframeConsole] Failed to inject console interceptor:",n)}};try{const n=e.contentDocument;if(n?.readyState==="complete"||n?.readyState==="interactive")t();else{const a=()=>{t(),e.removeEventListener("load",a)};e.addEventListener("load",a,{once:!0}),setTimeout(()=>{try{(e.contentDocument?.readyState==="complete"||e.contentDocument?.readyState==="interactive")&&t()}catch{}},100)}}catch{}}function $Ee({title:e,onClose:t,className:n}){return f.jsxs("div",{className:De("fixed top-0 left-0 right-0 z-50 flex items-center justify-between px-4 py-3","bg-background/80 backdrop-blur-md border-b border-border","supports-[backdrop-filter]:bg-background/60",n),children:[f.jsx("div",{className:"flex items-center gap-2",children:f.jsx("span",{className:"text-sm font-semibold text-foreground/80",children:"MCP Inspector"})}),f.jsx("div",{className:"flex-1 text-center",children:f.jsx("h2",{className:"text-sm font-medium text-foreground truncate max-w-md mx-auto",children:e})}),f.jsx("div",{className:"flex items-center",children:f.jsxs("button",{onClick:t,className:De("flex items-center gap-2 px-3 py-1.5 rounded-md","text-sm font-medium","bg-background/50 hover:bg-background/80","border border-border hover:border-border/80","transition-colors","focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2"),"aria-label":"Exit Fullscreen",children:[f.jsx(Yi,{className:"w-4 h-4"}),f.jsx("span",{className:"hidden sm:inline",children:"Exit Fullscreen"})]})})]})}function MEe(e={}){const{enabled:t=!0,maxLogs:n=1e3,proxyToPageConsole:a=!1}=e,[r,i]=x.useState([]),[s,c]=x.useState(!1),u=x.useRef(0),d=x.useCallback(h=>{if(!t)return;const g={...h,id:`log-${++u.current}-${Date.now()}`};if(i(v=>[...v,g].slice(-n)),a){const v="[WIDGET CONSOLE]",w=h.args.map(S=>{if(typeof S=="object"&&S!==null)try{return JSON.stringify(S,null,2)}catch{return String(S)}return S});switch(h.level){case"error":console.error(v,...w);break;case"warn":console.warn(v,...w);break;case"info":console.info(v,...w);break;case"debug":console.debug(v,...w);break;case"trace":console.trace(v,...w);break;default:console.log(v,...w)}}},[t,n,a]),m=x.useCallback(()=>{i([]),u.current=0},[]);return x.useEffect(()=>{if(!t)return;const h=g=>{g.data&&g.data.type==="iframe-console-log"&&g.data.level&&Array.isArray(g.data.args)&&d({level:g.data.level,args:g.data.args,timestamp:g.data.timestamp||new Date().toISOString(),url:g.data.url})};return window.addEventListener("message",h),()=>{window.removeEventListener("message",h)}},[t,d]),{logs:r,addLog:d,clearLogs:m,isOpen:s,setIsOpen:c}}function PEe({level:e}){const t={log:"bg-zinc-500",info:"bg-blue-500",warn:"bg-yellow-500",error:"bg-red-500",debug:"bg-purple-500",trace:"bg-gray-500"};return f.jsx("span",{className:De("px-1.5 py-0.5 text-[11px] font-mono font-semibold rounded-full text-white",t[e]),children:e.toUpperCase()})}function UEe({log:e}){const t=x.useMemo(()=>{try{return new Date(e.timestamp).toLocaleTimeString()}catch{return""}},[e.timestamp]),n=a=>{if(a===null)return"null";if(a===void 0)return"undefined";if(typeof a=="string")return a;if(typeof a=="object")try{return JSON.stringify(a,null,2)}catch{return String(a)}return String(a)};return f.jsxs("div",{className:De("font-mono text-xs p-2 border-b border-zinc-200 dark:border-zinc-800",e.level==="error"&&"bg-red-50/30 dark:bg-red-950/10",e.level==="warn"&&"bg-yellow-50/30 dark:bg-yellow-950/10"),children:[f.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[f.jsx(PEe,{level:e.level}),f.jsx("span",{className:"text-zinc-500 dark:text-zinc-400 text-[10px]",children:t}),e.url&&f.jsx("span",{className:"text-zinc-400 dark:text-zinc-500 text-[10px] truncate flex-1",children:(()=>{try{return new URL(e.url).pathname}catch{return e.url}})()})]}),f.jsx("div",{className:"pl-1",children:e.args.map((a,r)=>f.jsx("pre",{className:De("whitespace-pre-wrap break-words",e.level==="error"&&"text-red-700 dark:text-red-400",e.level==="warn"&&"text-yellow-700 dark:text-yellow-400"),children:n(a)},r))})]})}const P4="mcp-inspector-console-proxy-enabled";function zEe({iframeId:e,enabled:t=!0}){const[n,a]=x.useState(()=>{if(typeof window>"u")return!1;try{return localStorage.getItem(P4)==="true"}catch{return!1}}),{logs:r,clearLogs:i,isOpen:s,setIsOpen:c}=MEe({enabled:t,proxyToPageConsole:n}),u=x.useRef(null);x.useEffect(()=>{try{localStorage.setItem(P4,String(n))}catch{}},[n]);const d=x.useMemo(()=>r.filter(h=>h.level==="error").length,[r]),m=x.useMemo(()=>r.filter(h=>h.level==="warn").length,[r]);return x.useEffect(()=>{s&&u.current&&(u.current.scrollTop=u.current.scrollHeight)},[r,s]),f.jsxs(RK,{open:s,onOpenChange:c,children:[f.jsx(AK,{asChild:!0,children:f.jsxs(Dt,{children:[f.jsx(jt,{asChild:!0,children:f.jsxs(Le,{variant:"outline",size:"sm",className:"relative bg-white/90 dark:bg-zinc-900/90 backdrop-blur-sm shadow-sm hover:bg-white dark:hover:bg-zinc-900",onClick:()=>c(!0),children:[f.jsx(eS,{className:"size-4"}),(d>0||m>0)&&f.jsx("span",{className:De("ml-2 px-1.5 py-0.5 text-xs rounded-full text-white font-semibold",d>0?"bg-red-500":"bg-yellow-500"),children:d+m})]})}),f.jsx(Lt,{children:f.jsxs("p",{children:[d+m," console logs from the iframe"]})})]})}),f.jsxs(IK,{side:"bottom",className:"h-[400px] flex flex-col p-0",children:[f.jsx(OK,{className:"px-4 py-3 border-b border-zinc-200 dark:border-zinc-800",children:f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsxs(DK,{className:"flex items-center gap-2",children:[f.jsx(eS,{className:"size-4"}),"Widget Console Logs",r.length>0&&f.jsxs("span",{className:"text-sm font-normal text-zinc-500 dark:text-zinc-400",children:["(",r.length," ",r.length===1?"log":"logs",")"]})]}),f.jsxs("div",{className:"flex items-center gap-4 pr-4",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(ky,{id:"proxy-console-toggle",checked:n,onCheckedChange:a}),f.jsx(Kt,{htmlFor:"proxy-console-toggle",className:"text-sm font-normal cursor-pointer",children:"Proxy logs to page console"})]}),r.length>0&&f.jsxs(Le,{variant:"ghost",size:"sm",onClick:i,className:"-my-2",children:[f.jsx(Mme,{className:"size-4 mr-1"}),"Clear"]})]})]})}),f.jsx("div",{ref:u,className:"flex-1 overflow-auto bg-zinc-50 dark:bg-zinc-950",children:r.length===0?f.jsx("div",{className:"flex items-center justify-center h-full text-zinc-500 dark:text-zinc-400",children:f.jsxs("div",{className:"text-center",children:[f.jsx(eS,{className:"size-8 mx-auto mb-2 opacity-50"}),f.jsx("p",{className:"text-sm",children:"No console logs yet"}),f.jsx("p",{className:"text-xs mt-1",children:"Logs from iframes will appear here"})]})}):f.jsx("div",{children:r.map(h=>f.jsx(UEe,{log:h},h.id))})})]})]})}function FEe({displayMode:e,onDisplayModeChange:t,toolInput:n,toolOutput:a,toolResult:r,iframeRef:i,toolId:s}){const[c,u]=x.useState(!1),[d,m]=x.useState(null),h=x.useRef(null);x.useEffect(()=>{if(!c||!i.current)return;(()=>{try{const _=i.current?.contentWindow;_?.openai?.widgetState!==void 0&&m(_.openai.widgetState)}catch{}})(),i.current?.contentWindow&&i.current.contentWindow.postMessage({type:"mcp-inspector:getWidgetState",toolId:s},"*");const y=_=>{(_.data?.type==="mcp-inspector:widgetStateResponse"&&_.data.toolId===s||_.data?.type==="openai:setWidgetState"&&_.data.toolId===s)&&m(_.data.state)};return window.addEventListener("message",y),()=>{window.removeEventListener("message",y)}},[c,i,s]),x.useEffect(()=>{if(!c)return;const S=y=>{h.current&&!h.current.contains(y.target)&&u(!1)};return document.addEventListener("mousedown",S),()=>{document.removeEventListener("mousedown",S)}},[c]),x.useEffect(()=>(c?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[c]);const g=S=>{if(S===null)return"null";if(S===void 0)return"undefined";if(typeof S=="object")try{return JSON.stringify(S,null,2)}catch{return String(S)}return String(S)},v=e==="fullscreen",w=e==="pip";return f.jsxs(f.Fragment,{children:[f.jsxs("div",{className:"flex items-center gap-2",children:[!v&&!w&&f.jsxs(f.Fragment,{children:[f.jsxs(Dt,{children:[f.jsx(jt,{asChild:!0,children:f.jsx(Le,{variant:"outline",size:"sm",className:"bg-white/90 dark:bg-zinc-900/90 backdrop-blur-sm shadow-sm hover:bg-white dark:hover:bg-zinc-900",onClick:()=>t("fullscreen"),children:f.jsx(RN,{className:"size-4"})})}),f.jsx(Lt,{children:f.jsx("p",{children:"Enter fullscreen mode"})})]}),f.jsxs(Dt,{children:[f.jsx(jt,{asChild:!0,children:f.jsx(Le,{variant:"outline",size:"sm",className:"bg-white/90 dark:bg-zinc-900/90 backdrop-blur-sm shadow-sm hover:bg-white dark:hover:bg-zinc-900",onClick:()=>t("pip"),children:f.jsx(mme,{className:"size-4"})})}),f.jsx(Lt,{children:f.jsx("p",{children:"Enter picture-in-picture mode"})})]})]}),f.jsxs(Dt,{children:[f.jsx(jt,{asChild:!0,children:f.jsx(Le,{variant:"outline",size:"sm",className:"bg-white/90 dark:bg-zinc-900/90 backdrop-blur-sm shadow-sm hover:bg-white dark:hover:bg-zinc-900",onClick:()=>u(!0),children:f.jsx(hpe,{className:"size-4"})})}),f.jsx(Lt,{children:f.jsx("p",{children:"Open debug overlay"})})]})]}),c&&f.jsxs("div",{ref:h,style:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"#000000",color:"#ffffff",fontFamily:"monospace",fontSize:"12px",zIndex:1e4,overflow:"auto",padding:"16px"},onClick:S=>{S.target===h.current&&u(!1)},children:[f.jsx("button",{onClick:()=>u(!1),style:{position:"absolute",top:"16px",right:"16px",backgroundColor:"rgba(255, 255, 255, 0.1)",color:"#ffffff",border:"none",borderRadius:"4px",width:"32px",height:"32px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"18px",lineHeight:1},"aria-label":"Close",children:"×"}),f.jsxs("div",{style:{maxWidth:"1200px",margin:"0 auto",paddingTop:"40px"},children:[f.jsx("h1",{style:{fontSize:"18px",fontWeight:"bold",marginBottom:"16px",borderBottom:"1px solid #333",paddingBottom:"8px"},children:"Debug Info"}),f.jsx("table",{style:{width:"100%",borderCollapse:"collapse",borderSpacing:0},children:f.jsxs("tbody",{children:[f.jsxs("tr",{style:{borderBottom:"1px solid #333"},children:[f.jsx("td",{style:{padding:"8px",fontWeight:"bold",width:"200px",verticalAlign:"top"},children:"Props (Tool Input)"}),f.jsx("td",{style:{padding:"8px",whiteSpace:"pre-wrap",wordBreak:"break-all"},children:g(n)})]}),f.jsxs("tr",{style:{borderBottom:"1px solid #333"},children:[f.jsx("td",{style:{padding:"8px",fontWeight:"bold",width:"200px",verticalAlign:"top"},children:"Output (Tool Output)"}),f.jsx("td",{style:{padding:"8px",whiteSpace:"pre-wrap",wordBreak:"break-all"},children:g(a)})]}),f.jsxs("tr",{style:{borderBottom:"1px solid #333"},children:[f.jsx("td",{style:{padding:"8px",fontWeight:"bold",width:"200px",verticalAlign:"top"},children:"Metadata"}),f.jsx("td",{style:{padding:"8px",whiteSpace:"pre-wrap",wordBreak:"break-all"},children:g(r?._meta||r?.contents?.[0]?._meta||null)})]}),f.jsxs("tr",{style:{borderBottom:"1px solid #333"},children:[f.jsx("td",{style:{padding:"8px",fontWeight:"bold",width:"200px",verticalAlign:"top"},children:"Widget State"}),f.jsx("td",{style:{padding:"8px",whiteSpace:"pre-wrap",wordBreak:"break-all"},children:g(d)})]}),f.jsxs("tr",{style:{borderBottom:"1px solid #333"},children:[f.jsx("td",{style:{padding:"8px",fontWeight:"bold",width:"200px",verticalAlign:"top"},children:"Display Mode"}),f.jsx("td",{style:{padding:"8px"},children:e})]})]})})]})]})]})}function U4({children:e,className:t,noWrapper:n}){return n?e:f.jsx("div",{className:De("bg-zinc-100 dark:bg-zinc-900 bg-[radial-gradient(circle,_rgba(0,0,0,0.2)_1px,_transparent_1px)] dark:bg-[radial-gradient(circle,_rgba(255,255,255,0.2)_1px,_transparent_1px)] bg-[length:32px_32px]",t),children:e})}function BEe({componentUrl:e,toolName:t,toolArgs:n,toolResult:a,serverId:r,readResource:i,className:s,noWrapper:c=!1,showConsole:u=!0}){const d=x.useRef(null),m=x.useRef(null),[h,g]=x.useState(!1),[v,w]=x.useState(null),[S,y]=x.useState(null),[_,E]=x.useState(400),k=x.useRef(0),C=x.useRef(0),R=x.useRef(!1),[I,A]=x.useState(!1),[O,M]=x.useState("inline"),[U,H]=x.useState(!1),[K,ee]=x.useState(!1),[te,ae]=x.useState(!1),[B,Z]=x.useState(null),[G,re]=x.useState(null),j=x.useRef(`tool-${Date.now()}-${Math.random().toString(36).substring(7)}`).current,z=_N().connections.find(X=>X.id===r),L=z?.url,{resolvedTheme:$}=ew();x.useEffect(()=>{(async()=>{try{const ie=a?.structuredContent||null,le=await i(e),J=ie||n;Z(J),re(ie);let q=null;const se=a?._meta||a?.contents?.[0]?._meta;se?.["openai/widgetCSP"]&&(q=se["openai/widgetCSP"]);const he=new URLSearchParams,ce={toolInput:B,toolOutput:ie,toolId:j};he.set("mcpUseParams",JSON.stringify(ce));const Te=a?._meta||a?.contents?.[0]?._meta,He=Te?.["mcp-use/widget"]?.html&&Te?.["mcp-use/widget"]?.dev;ae(He||!1);const Se=Te?.["mcp-use/widget"]?.name,_e={serverId:r,uri:e,toolInput:J,toolOutput:ie,resourceData:le,toolId:j,widgetCSP:q,theme:$};if(He&&Se&&L){const fe=new URL(L).origin,Oe=`${fe}/mcp-use/widgets/${Se}`;_e.devWidgetUrl=Oe,_e.devServerBaseUrl=fe}const Ue=await fetch("/inspector/api/resources/widget/store",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(_e)});if(!Ue.ok){const fe=await Ue.json().catch(()=>({error:"Unknown error"}));throw new Error(`Failed to store widget data: ${fe.error||Ue.statusText}`)}if(He&&Se&&L){const fe=`/inspector/api/dev-widget/${j}`;y(fe),H(!0)}else{const fe=`/inspector/api/resources/widget/${j}`;y(fe),H(!0)}}catch(ie){console.error("Error storing widget data:",ie),w(ie instanceof Error?ie.message:"Failed to prepare widget")}})()},[e,r,n,a,j,i,L,$]);const F=x.useCallback(X=>{if(d.current?.contentWindow)try{const ie=d.current.contentWindow,le=d.current.contentDocument;if(X.theme!==void 0&&le){const J=le.documentElement;J.setAttribute("data-theme",X.theme),J.style.colorScheme=X.theme}if(ie.openai){X.displayMode!==void 0&&(ie.openai.displayMode=X.displayMode),X.theme!==void 0&&(ie.openai.theme=X.theme),X.maxHeight!==void 0&&(ie.openai.maxHeight=X.maxHeight),X.locale!==void 0&&(ie.openai.locale=X.locale),X.safeArea!==void 0&&(ie.openai.safeArea=X.safeArea),X.userAgent!==void 0&&(ie.openai.userAgent=X.userAgent);try{const J=ie.CustomEvent,q=new J("openai:set_globals",{detail:{globals:{...ie.openai}}});ie.dispatchEvent(q)}catch{ie.postMessage({type:"openai:globalsChanged",updates:X},"*")}}}catch{d.current.contentWindow.postMessage({type:"openai:globalsChanged",updates:X},"*")}},[]),W=x.useCallback(async X=>{try{if(X==="fullscreen"){if(document.fullscreenElement){M(X),F({displayMode:X});return}m.current&&(await m.current.requestFullscreen(),M(X),F({displayMode:X}),console.log("[OpenAIComponentRenderer] Entered fullscreen"))}else document.fullscreenElement&&await document.exitFullscreen(),M(X),F({displayMode:X}),console.log("[OpenAIComponentRenderer] Exited fullscreen")}catch(ie){console.error("[OpenAIComponentRenderer] Fullscreen error:",ie),M(X),F({displayMode:X})}},[F]);return x.useEffect(()=>{if(!S)return;const X=async q=>{if(!(!d.current||q.source!==d.current.contentWindow)&&q.data?.type!=="iframe-console-log"){if(q.data?.type==="mcp-inspector:getWidgetState"){try{const se=d.current?.contentWindow;se?.openai?.widgetState!==void 0&&d.current?.contentWindow?.postMessage({type:"mcp-inspector:widgetStateResponse",toolId:q.data.toolId,state:se.openai.widgetState},"*")}catch{}return}switch(q.data.type){case"openai:setWidgetState":break;case"openai:callTool":try{if(!z)throw new Error("Server connection not available");const{toolName:se,params:he,requestId:ce}=q.data,Te=await z.callTool(se,he||{},{timeout:6e5,resetTimeoutOnProgress:!0});let He;Te&&typeof Te=="object"?Array.isArray(Te.contents)?He={content:Te.contents.map(Se=>typeof Se=="string"?{type:"text",text:Se}:Se.type==="text"&&Se.text?{type:"text",text:Se.text}:Se.type==="image"&&Se.data?{type:"image",image_url:{url:Se.data}}:{type:"text",text:JSON.stringify(Se)})}:He={content:[{type:"text",text:typeof Te=="string"?Te:JSON.stringify(Te)}]}:He={content:[{type:"text",text:String(Te)}]},d.current?.contentWindow?.postMessage({type:"openai:callTool:response",requestId:ce,result:He},"*")}catch(se){console.error("[OpenAIComponentRenderer] Tool call error:",se),d.current?.contentWindow?.postMessage({type:"openai:callTool:response",requestId:q.data.requestId,error:se instanceof Error?se.message:String(se)},"*")}break;case"openai:sendFollowup":try{const{message:se}=q.data,he=typeof se=="string"?se:se?.prompt||se;if(!he){console.warn("[OpenAIComponentRenderer] No prompt in followup message");return}const ce=new window.CustomEvent("mcp-inspector:widget-followup",{detail:{prompt:he,serverId:r}});window.dispatchEvent(ce);try{const Te=JSON.parse(localStorage.getItem("mcp-inspector-pending-followups")||"[]");Te.push({prompt:he,serverId:r,timestamp:Date.now()}),localStorage.setItem("mcp-inspector-pending-followups",JSON.stringify(Te.slice(-10)))}catch{}}catch(se){console.error("[OpenAIComponentRenderer] Failed to send followup:",se)}break;case"openai:requestDisplayMode":try{const{mode:se}=q.data;se&&["inline","pip","fullscreen"].includes(se)&&await W(se)}catch(se){console.error("[OpenAIComponentRenderer] Failed to change display mode:",se)}break;case"openai:notifyIntrinsicHeight":try{const{height:se}=q.data;if(typeof se=="number"&&se>0){let he=se;if(O==="fullscreen"||O==="pip"){const ce=typeof window<"u"?window.innerHeight:se;he=Math.min(se,ce)}(se!==C.current||he!==_)&&(C.current=se,k.current=he,R.current=!0,E(he))}}catch(se){console.error("[OpenAIComponentRenderer] Failed to handle intrinsic height notification:",se)}break}}};window.addEventListener("message",X);const ie=()=>{if(g(!0),w(null),d.current)try{const q=!!d.current.contentDocument;q&&U?M4(d.current):q||H(!1)}catch{H(!1)}$&&setTimeout(()=>{F({theme:$})},50)},le=()=>{w("Failed to load component")},J=d.current;return J?.addEventListener("load",ie),J?.addEventListener("error",le),J&&U&&J.contentDocument?.readyState==="complete"&&M4(J),()=>{window.removeEventListener("message",X),J?.removeEventListener("load",ie),J?.removeEventListener("error",le)}},[S,U,W,z,r,$,F,te]),x.useEffect(()=>{if(!d.current?.contentDocument||!h)return;const ie=d.current.contentDocument.documentElement;ie.setAttribute("data-theme",$),ie.style.colorScheme=$,F({theme:$})},[$,h,F]),x.useEffect(()=>{if(!S)return;const X=()=>{if(R.current)return;const J=d.current,se=J?.contentWindow?.document?.body;if(!J||!se)return;const he=se.scrollHeight||0,ce=typeof window<"u"?window.innerHeight:he,Te=Math.min(he,ce);Te>0&&Te!==k.current&&(k.current=Te,E(Te))};let ie;const le=()=>{X(),ie=window.requestAnimationFrame(le)};return le(),window.addEventListener("resize",X),()=>{window.cancelAnimationFrame(ie),window.removeEventListener("resize",X)}},[S]),x.useEffect(()=>{const X=()=>{const ie=m.current;if(!ie)return;const le=ie.clientHeight;A(le>_)};return X(),window.addEventListener("resize",X),()=>{window.removeEventListener("resize",X)}},[_]),x.useEffect(()=>{const X=()=>{!document.fullscreenElement&&O==="fullscreen"?(M("inline"),F({displayMode:"inline"}),console.log("[OpenAIComponentRenderer] Fullscreen exited by user")):document.fullscreenElement&&O!=="fullscreen"&&(M("fullscreen"),F({displayMode:"fullscreen"}))};return document.addEventListener("fullscreenchange",X),document.addEventListener("fullscreenerror",ie=>{console.error("[OpenAIComponentRenderer] Fullscreen error:",ie)}),()=>{document.removeEventListener("fullscreenchange",X)}},[O,F]),x.useEffect(()=>{if(S&&$&&h){const X=setTimeout(()=>{F({theme:$})},0);return()=>clearTimeout(X)}},[$,S,h,F]),v?f.jsx("div",{className:s,children:f.jsx("div",{className:"bg-red-50/30 dark:bg-red-950/20 border border-red-200/50 dark:border-red-800/50 rounded-lg p-4",children:f.jsxs("p",{className:"text-sm text-red-600 dark:text-red-400",children:["Failed to load component: ",v]})})}):S?f.jsxs(U4,{className:s,noWrapper:c,children:[!h&&f.jsx("div",{className:"flex absolute left-0 top-0 items-center justify-center w-full h-full",children:f.jsx(Ei,{className:"size-5"})}),u&&U&&O!=="fullscreen"&&O!=="pip"&&f.jsxs("div",{className:"absolute top-2 right-2 z-10 flex items-center gap-2",children:[f.jsx(zEe,{iframeId:j,enabled:!0}),f.jsx(FEe,{displayMode:O,onDisplayModeChange:W,toolInput:B,toolOutput:G,toolResult:a,iframeRef:d,toolId:j})]}),f.jsxs("div",{ref:m,className:De("w-full h-full flex flex-col justify-center items-center",I&&"items-center",O==="fullscreen"&&"bg-background",O==="pip"&&"fixed bottom-6 right-6 z-50 rounded-3xl w-[768px] h-96 shadow-2xl border overflow-hidden"),onMouseEnter:()=>O==="pip"&&ee(!0),onMouseLeave:()=>O==="pip"&&ee(!1),children:[O==="fullscreen"&&document.fullscreenElement&&f.jsx($Ee,{title:t,onClose:()=>W("inline")}),O==="pip"&&f.jsx("button",{onClick:()=>W("inline"),className:De("absolute top-2 right-2 z-50","flex items-center justify-center","w-8 h-8 rounded-full","bg-background/90 hover:bg-background","border border-border","shadow-lg","transition-opacity duration-200","focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",K?"opacity-100":"opacity-0"),"aria-label":"Exit Picture in Picture",children:f.jsx(Yi,{className:"w-4 h-4 text-foreground"})}),f.jsx("div",{className:De("flex-1 w-full flex justify-center items-center",O==="fullscreen"&&"pt-14",I&&"items-center"),children:f.jsx("iframe",{ref:d,src:S,className:De(O==="inline"&&" w-full max-w-[768px]",O==="fullscreen"&&"w-full h-full rounded-none",O==="pip"&&"w-full h-full rounded-lg"),style:{height:O==="fullscreen"||O==="pip"?"100%":`${_}px`},sandbox:"allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox",title:`OpenAI Component: ${t}`,allow:"web-share"})})]})]}):f.jsx(U4,{className:s,noWrapper:c,children:f.jsx("div",{className:"flex absolute left-0 top-0 items-center justify-center w-full h-full",children:f.jsx(Ei,{className:"size-5"})})})}const GO=x.memo(BEe);var HEe=Object.defineProperty,LK=e=>{throw TypeError(e)},VEe=(e,t,n)=>t in e?HEe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Xc=(e,t,n)=>VEe(e,typeof t!="symbol"?t+"":t,n),WO=(e,t,n)=>t.has(e)||LK("Cannot "+n),Mn=(e,t,n)=>(WO(e,t,"read from private field"),n?n.call(e):t.get(e)),fi=(e,t,n)=>t.has(e)?LK("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),R_=(e,t,n,a)=>(WO(e,t,"write to private field"),t.set(e,n),n),Rr=(e,t,n)=>(WO(e,t,"access private method"),n);const z4={PREFERRED_FRAME_SIZE:"preferred-frame-size",INITIAL_RENDER_DATA:"initial-render-data"},F4="mcpui.dev/ui-";function GEe(e){let t;try{t=new URL(e)}catch(n){return console.error("Error parsing URL:",n),!1}return t.protocol==="http:"||t.protocol==="https:"}function WEe(e,t){if(e.mimeType!=="text/html"&&e.mimeType!=="text/uri-list")return{error:"Resource must be of type text/html (for HTML content) or text/uri-list (for URL content)."};if(e.mimeType==="text/uri-list"){let n="";if("text"in e&&typeof e.text=="string"&&e.text.trim()!=="")n=e.text;else if("blob"in e&&typeof e.blob=="string")try{n=new TextDecoder().decode(Uint8Array.from(atob(e.blob),i=>i.charCodeAt(0)))}catch(i){return console.error("Error decoding base64 blob for URL content:",i),{error:"Error decoding URL from blob."}}else return{error:"URL resource expects a non-empty text or blob field containing the URL."};if(n.trim()==="")return{error:"URL content is empty."};const a=n.split(`
|
|
339
339
|
`).map(i=>i.trim()).filter(i=>i&&!i.startsWith("#")&&GEe(i));if(a.length===0)return{error:"No valid URLs found in uri-list content."};a.length>1&&console.warn(`Multiple URLs found in uri-list content. Using the first URL: "${a[0]}". Other URLs ignored:`,a.slice(1));const r=a[0];if(t&&t.trim()!=="")try{const i=new URL(t);if(typeof window<"u"&&i.host===window.location.host)console.error("For security, the proxy origin must not be the same as the host origin. Using original URL instead.");else return i.searchParams.set("url",r),{iframeSrc:i.toString(),iframeRenderMode:"src"}}catch(i){console.error(`Invalid proxy URL provided: "${t}". Falling back to direct URL.`,i instanceof Error?i.message:String(i))}return{iframeSrc:r,iframeRenderMode:"src"}}else if(e.mimeType==="text/html"){let n="";if("text"in e&&typeof e.text=="string")n=e.text;else if("blob"in e&&typeof e.blob=="string")try{n=new TextDecoder().decode(Uint8Array.from(atob(e.blob),a=>a.charCodeAt(0)))}catch(a){return console.error("Error decoding base64 blob for HTML content:",a),{error:"Error decoding HTML content from blob."}}else return{error:"HTML resource requires text or blob content."};if(t&&t.trim()!=="")try{const a=new URL(t);if(typeof window<"u"&&a.host===window.location.host)console.error("For security, the proxy origin must not be the same as the host origin. Using srcDoc rendering instead.");else return a.searchParams.set("contentType","rawhtml"),{iframeSrc:a.toString(),iframeRenderMode:"src",htmlString:n}}catch(a){console.error(`Invalid proxy URL provided: "${t}". Falling back to srcDoc rendering.`,a instanceof Error?a.message:String(a))}return{htmlString:n,iframeRenderMode:"srcDoc"}}else return{error:"Unsupported mimeType. Expected text/html or text/uri-list."}}function KEe(e){if("text"in e&&typeof e.text=="string"&&e.text.trim()!=="")return{code:e.text};if("blob"in e&&typeof e.blob=="string")try{return{code:new TextDecoder().decode(Uint8Array.from(atob(e.blob),t=>t.charCodeAt(0)))}}catch(t){return console.error("Error decoding base64 blob for remote DOM content:",t),{error:"Error decoding remote DOM content from blob."}}return{error:"Remote DOM resource requires non-empty text or blob content."}}function ZEe(e){return e._meta??{}}function YEe(e){const t=ZEe(e),n={};return Object.entries(t).forEach(([a,r])=>{a.startsWith(F4)&&(n[a.slice(F4.length)]=r)}),n}const si={UI_MESSAGE_RECEIVED:"ui-message-received",UI_MESSAGE_RESPONSE:"ui-message-response",UI_SIZE_CHANGE:"ui-size-change",UI_LIFECYCLE_IFRAME_READY:"ui-lifecycle-iframe-ready",UI_LIFECYCLE_IFRAME_RENDER_DATA:"ui-lifecycle-iframe-render-data",UI_REQUEST_RENDER_DATA:"ui-request-render-data",UI_PROXY_IFRAME_READY:"ui-proxy-iframe-ready",UI_HTML_CONTENT:"ui-html-content"},qEe={WAIT_FOR_RENDER_DATA:"waitForRenderData"},$K=({resource:e,onUIAction:t,style:n,proxy:a,iframeRenderData:r,autoResizeIframe:i,sandboxPermissions:s,iframeProps:c})=>{const u=x.useRef(null);x.useImperativeHandle(c?.ref,()=>u.current);const{error:d,iframeSrc:m,iframeRenderMode:h,htmlString:g}=x.useMemo(()=>WEe(e,a),[e,a]),v=x.useMemo(()=>YEe(e),[e]),w=v[z4.PREFERRED_FRAME_SIZE]??["100%","100%"],S=v[z4.INITIAL_RENDER_DATA]??void 0,y=x.useMemo(()=>{if(!(!r&&!S))return{...S,...r}},[r,S]),_=x.useMemo(()=>{if(m&&y){const C=new URL(m);return C.searchParams.set(qEe.WAIT_FOR_RENDER_DATA,"true"),C.toString()}return m},[m,y]),E=x.useCallback(C=>{var R;if(y){const I=C.currentTarget.contentWindow,A=_?new URL(_).origin:"*";bl(si.UI_LIFECYCLE_IFRAME_RENDER_DATA,I,A,void 0,{renderData:y})}(R=c?.onLoad)==null||R.call(c,C)},[y,_,c?.onLoad]),k=x.useMemo(()=>h==="srcDoc"?B4(s??"","allow-scripts"):B4(s??"","allow-scripts allow-same-origin"),[s,h]);return x.useEffect(()=>{async function C(R){const{source:I,origin:A,data:O}=R;if(u.current&&I===u.current.contentWindow){if(O?.type===si.UI_PROXY_IFRAME_READY){h==="src"&&g&&_!=null&&_.includes("contentType=rawhtml")&&bl(si.UI_HTML_CONTENT,I,A,void 0,{html:g});return}if(O?.type===si.UI_LIFECYCLE_IFRAME_READY){y&&bl(si.UI_LIFECYCLE_IFRAME_RENDER_DATA,I,A,void 0,{renderData:y});return}if(O?.type===si.UI_REQUEST_RENDER_DATA){bl(si.UI_LIFECYCLE_IFRAME_RENDER_DATA,I,A,O.messageId,{renderData:y});return}if(O?.type===si.UI_SIZE_CHANGE){const{width:U,height:H}=O.payload;if(i&&u.current){const K=(typeof i=="boolean"||i.height)&&H,ee=(typeof i=="boolean"||i.width)&&U;K&&(u.current.style.height=`${H}px`),ee&&(u.current.style.width=`${U}px`)}return}const M=O;if(!M)return;if(t){const U=M.messageId;bl(si.UI_MESSAGE_RECEIVED,I,A,U);try{const H=await t(M);bl(si.UI_MESSAGE_RESPONSE,I,A,U,{response:H})}catch(H){console.error("Error handling UI action result in HTMLResourceRenderer:",H),bl(si.UI_MESSAGE_RESPONSE,I,A,U,{error:H})}}}}return window.addEventListener("message",C),()=>window.removeEventListener("message",C)},[t,y,h,g,_]),d?f.jsx("p",{className:"text-red-500",children:d}):h==="srcDoc"?g==null?d?null:f.jsx("p",{className:"text-orange-500",children:"No HTML content to display."}):f.jsx("iframe",{srcDoc:g,sandbox:k,style:{width:w[0],height:w[1],...n},title:"MCP HTML Resource (Embedded Content)",...c,ref:u,onLoad:E}):h==="src"?_==null?d?null:f.jsx("p",{className:"text-orange-500",children:"No URL provided for HTML resource."}):f.jsx("iframe",{src:_,sandbox:k,style:{width:w[0],height:w[1],...n},title:"MCP HTML Resource (URL)",...c,ref:u,onLoad:E}):f.jsx("p",{className:"text-gray-500",children:"Initializing HTML resource display..."})};$K.displayName="HTMLResourceRenderer";function bl(e,t,n,a,r){const i=n&&n!=="null"?n:"*";t?.postMessage({type:e,messageId:a??void 0,payload:r},i)}function B4(e,t){return[...new Set([...e.split(" "),...t.split(" ")])].filter(Boolean).map(n=>n.trim()).join(" ")}const MK=1,PK=3,UK=8,XEe=9,JEe=0,QEe=1,e_e=2,t_e=3,Fp=1,KO=2,ZO=3,fp="~";function zK({call:e,insertChild:t,removeChild:n,updateText:a,updateProperty:r}){const i={[JEe]:t,[QEe]:n,[e_e]:a,[t_e]:r};return{call:e,mutate(s){for(const[c,...u]of s)i[c](...u)}}}class n_e{constructor({retain:t,release:n,methods:a}={}){Xc(this,"root",{id:fp,type:XEe,children:[],version:0,properties:{},attributes:{},eventListeners:{}}),Xc(this,"attached",new Map([[fp,this.root]])),Xc(this,"subscribers",new Map),Xc(this,"parents",new Map),Xc(this,"implementations",new Map);const{attached:r,parents:i,subscribers:s}=this;this.connection=zK({call:(m,h,...g)=>{const v=this.implementations.get(m),w=v?.[h];if(typeof w!="function")throw new Error(`Node ${m} does not implement the ${h}() method`);return w(...g)},insertChild:(m,h,g)=>{const v=r.get(m),{children:w}=v,S=u(h,v);g===w.length?w.push(S):w.splice(g,0,S),v.version+=1,this.parents.set(h.id,v.id),c(v)},removeChild:(m,h)=>{const g=r.get(m),{children:v}=g,[w]=v.splice(h,1);w&&(g.version+=1,c(g),d(w))},updateProperty:(m,h,g,v=Fp)=>{const w=r.get(m);t?.(g);let S;switch(v){case Fp:S=w.properties;break;case KO:S=w.attributes;break;case ZO:S=w.eventListeners;break}const y=S[h];S[h]=g,w.version+=1;let _;if(h==="slot"){const E=this.parents.get(m);_=E==null?E:r.get(E),_&&(_.version+=1)}c(w),_&&c(_),n?.(y)},updateText:(m,h)=>{const g=r.get(m);g.data=h,g.version+=1,c(g)}}),a&&this.implement(this.root,a);function c(m){const h=s.get(m.id);if(h)for(const g of h)g(m)}function u(m,h){let g;switch(m.type){case PK:case UK:{const{id:v,type:w,data:S}=m;g={id:v,type:w,data:S,version:0};break}case MK:{const{id:v,type:w,element:S,children:y,properties:_,attributes:E,eventListeners:k}=m;t?.(_),t?.(k);const C=[];g={id:v,type:w,element:S,version:0,children:C,properties:{..._},attributes:{...E},eventListeners:{...k}};for(const R of y)C.push(u(R,g));break}default:throw new Error(`Unknown node type: ${JSON.stringify(m)}`)}return r.set(g.id,g),i.set(g.id,h.id),g}function d(m){if(r.delete(m.id),i.delete(m.id),n&&("properties"in m&&n(m.properties),"eventListeners"in m&&n(m.eventListeners)),"children"in m)for(const h of m.children)d(h)}}get({id:t}){return this.attached.get(t)}implement({id:t},n){n==null?this.implementations.delete(t):this.implementations.set(t,n)}subscribe({id:t},n,{signal:a}={}){let r=this.subscribers.get(t);r==null&&(r=new Set,this.subscribers.set(t,r)),r.add(n),a?.addEventListener("abort",()=>{r.delete(n),r.size===0&&this.subscribers.delete(t)})}}const H4=new WeakMap,tb=new WeakMap,FK=new WeakMap;class r_e{constructor({root:t,retain:n,release:a,call:r,cache:i}={}){Xc(this,"attached",new Map),this.root=t??document.createDocumentFragment();const{attached:s}=this,c=new Map;this.connection=zK({call:(m,h,...g)=>{const v=m===fp&&this.root.nodeType!==11?this.root:s.get(m);return r?r(v,h,...g):v[h](...g)},insertChild:(m,h,g)=>{const v=m===fp?this.root:s.get(m),w=c.get(m);w&&clearTimeout(w),v.insertBefore(u(h),v.childNodes[g]||null)},removeChild:(m,h)=>{const g=(m===fp?this.root:s.get(m)).childNodes[h];if(g.remove(),i!=null&&i.maxAge){const v=c.get(m);v&&clearTimeout(v);const w=setTimeout(()=>{d(g)},i.maxAge);c.set(m,w)}else d(g)},updateProperty:(m,h,g,v=Fp)=>{const w=s.get(m);n?.(g);const S=tb.get(w),y=S[h];S[h]=g,nb(w,h,g,v),a?.(y)},updateText:(m,h)=>{const g=s.get(m);g.data=h}});function u(m){const h=s.get(m.id);if(h)return h;let g;switch(m.type){case MK:{if(g=document.createElement(m.element),m.properties){tb.set(g,m.properties);for(const v of Object.keys(m.properties)){const w=m.properties[v];n?.(w),nb(g,v,w,Fp)}}else tb.set(g,{});if(m.attributes)for(const v of Object.keys(m.attributes)){const w=m.attributes[v];n?.(w),nb(g,v,w,KO)}if(FK.set(g,{}),m.eventListeners)for(const v of Object.keys(m.eventListeners)){const w=m.eventListeners[v];n?.(w),nb(g,v,w,ZO)}for(const v of m.children)g.appendChild(u(v));break}case PK:{g=document.createTextNode(m.data);break}case UK:{g=document.createComment(m.data);break}default:throw new Error(`Unknown node type: ${JSON.stringify(m)}`)}return H4.set(g,m.id),s.set(m.id,g),g}function d(m){const h=H4.get(m);h&&s.delete(h);const g=tb.get(m);if(g&&a&&a(g),m instanceof Element)for(const v of m.childNodes)d(v)}}connect(t){const n=this.root;this.root=t,n.childNodes.forEach(a=>{t.appendChild(a)})}disconnect(){if(this.root.nodeType===11)return this.root;const t=this.root,n=new DocumentFragment;return this.root=n,t.childNodes.forEach(a=>{n.appendChild(a)}),n}}function nb(e,t,n,a){switch(a){case Fp:{e[t]=n;break}case KO:{n==null?e.removeAttribute(t):e.setAttribute(t,n);break}case ZO:{const r=FK.get(e),i=r?.[t];if(i&&e.removeEventListener(t,i),n!=null){const s=c=>{var u;if(c.target!==e)return;const d=n(c.detail);(u=c.resolve)==null||u.call(c,d)};r&&(r[t]=s),e.addEventListener(t,s)}break}}}function YO(e,t){const[n,a]=x.useState(()=>{const i=t.get(e);return{id:e.id,version:i?.version,value:i,receiver:t}});let r=n.value;if(n.receiver!==t||n.id!==e.id){const i=t.get(e);r=i,a({receiver:t,id:e.id,version:i?.version,value:r})}return x.useDebugValue(r),x.useEffect(()=>{const i=new AbortController,s=()=>{i.signal.aborted||a(c=>{const{id:u,version:d,receiver:m}=c,{id:h}=e;if(m!==t||u!==h)return c;const g=t.get(e),v=g?.version;return d===v?c:{receiver:t,value:g,id:h,version:v}})};return t.subscribe(e,s,{signal:i.signal}),s(),()=>{i.abort()}},[t,e.id]),r}function a_e({remote:e,receiver:t}){const n=YO(e,t);return n?f.jsx(f.Fragment,{children:n.data}):null}function A_(e,{receiver:t,components:n}){switch(e.type){case 1:{const a=n.get(e.element);if(a==null)throw new Error(`No component found for remote element: ${e.element}`);return f.jsx(a,{element:e,receiver:t,components:n},e.id)}case 3:return f.jsx(a_e,{remote:e,receiver:t},e.id);case 8:return null;default:throw new Error(`Unknown remote node type: ${String(e)}`)}}function i_e(e,t){if(!e)return;const{children:n,properties:a,attributes:r,eventListeners:i}=e,s=[],c={...a,...r,children:s};if(t.eventProps)for(const[u,d]of Object.entries(t.eventProps)){const m=d?.event;if(m==null)continue;const h=i[m];h&&(c[u]=V4(h))}else for(const[u,d]of Object.entries(i))c[`on${u[0].toUpperCase()}${u.slice(1)}`]=V4(d);for(const u of n)if(u.type===1&&typeof u.attributes.slot=="string"){const d=u.attributes.slot,m=A_(u,t);c[d]=c[d]?f.jsxs(f.Fragment,{children:[c[d],m]}):m}else s.push(A_(u,t));return c}function V4(e){return function(...t){if(t.length===1&&t[0]instanceof Event){const n=t[0];return n.target!==n.currentTarget?void 0:"detail"in n?e(n.detail):e()}return e(...t)}}const o_e=Symbol.for("remote-dom.element"),s_e=Symbol.for("remote-dom.element.attached");function l_e(e,{name:t,eventProps:n}={}){const a=x.memo(function({element:r,receiver:i,components:s}){const c=x.useRef(),u=YO(r,i),d=u??r,m=d.id,h=i_e(d,{receiver:i,components:s,eventProps:n});if(h[o_e]=d,h[s_e]=u!=null,c.current==null){const g={id:m,receiver:i};g.instanceRef=c_e(g),c.current=g}return c.current.id=m,c.current.receiver=i,x.useEffect(()=>{var g;const v={id:m};return i.implement(v,(g=c.current)==null?void 0:g.instanceRef.current),()=>{i.implement(v,null)}},[m,i]),f.jsx(e,{ref:c.current.instanceRef,...h})});return a.displayName=t??`RemoteComponentRenderer(${e.displayName??e.name??"Component"})`,a}function c_e(e){let t=null;return{get current(){return t},set current(n){t=n,e.receiver.implement(e,n)}}}function u_e(e){const{receiver:t}=e,{children:n}=YO(t.root,t);return f.jsx(f.Fragment,{children:n.map(a=>A_(a,e))})}const d_e=`<!DOCTYPE html>
|
|
340
340
|
<html>
|
|
341
341
|
<head>
|
|
@@ -1657,7 +1657,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1657
1657
|
<\/script>
|
|
1658
1658
|
</body>
|
|
1659
1659
|
</html>`,BK=1,G4=2,HK=3,W4=4,VK=5,K4=Symbol.for("quilt.threads.serialize"),f_e=Symbol.for("quilt.threads.transferable");class p_e 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 Z4 extends Error{constructor(){super("You attempted to call a function on a closed thread.")}}let m_e="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";function GK(e=21){let t="",n=crypto.getRandomValues(new Uint8Array(e));for(let a=0;a<e;a++)t+=m_e[63&n[a]];return t}var Wf,Jc,Kf,Tb,I_,WK;class h_e{constructor(){fi(this,I_),fi(this,Wf,new Map),fi(this,Jc,new Map),fi(this,Kf,new Map),fi(this,Tb,new WeakMap)}get(t){return Mn(this,Jc).get(t)}release(t){const n=Mn(this,Jc).get(t);return n&&(Mn(this,Jc).delete(t),Mn(this,Wf).delete(n)),!!n}serialize(t){let n=Mn(this,Wf).get(t);return n==null&&(n=GK(),Mn(this,Wf).set(t,n),Mn(this,Jc).set(n,t)),n}deserialize(t,n){var a,r;let i=(a=Mn(this,Kf).get(t))==null?void 0:a.deref();return i||(i=(...s)=>{if(!Mn(this,Kf).has(t))throw new Error("You attempted to call a function that was already revoked.");return n.call((c,u,d)=>{n.messages.send([HK,c,t,u],d)},s)},(r=Rr(this,I_,WK).call(this,n))==null||r.register(i,t),Mn(this,Kf).set(t,new WeakRef(i)),i)}}Wf=new WeakMap,Jc=new WeakMap,Kf=new WeakMap,Tb=new WeakMap,I_=new WeakSet,WK=function(e){let t=Mn(this,Tb).get(e);if(!(typeof FinalizationRegistry>"u"))return t||(t=new FinalizationRegistry(n=>{e.messages.send([VK,n])}),Mn(this,Tb).set(e,t)),t};function g_e(e){return e!=null&&(Symbol.asyncIterator in e||Symbol.iterator in e)&&typeof e.next=="function"}function Y4(e){if(e==null||typeof e!="object")return!1;const t=Object.getPrototypeOf(e);return t==null||t===Object.prototype}const RS="_@f",q4="_@i";var pp,mp,Za,Nb,xs;class b_e{constructor(t){fi(this,Za),fi(this,pp),fi(this,mp),R_(this,pp,t?.serialize),R_(this,mp,t?.deserialize)}serialize(t,n,a){return Rr(this,Za,Nb).call(this,t,n,a)}deserialize(t,n){return Rr(this,Za,xs).call(this,t,n)}}pp=new WeakMap,mp=new WeakMap,Za=new WeakSet,Nb=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,pp)&&!r){const c=Mn(this,pp).call(this,e,u=>Rr(this,Za,Nb).call(this,u,t,n,a,!0),t,n);if(c!==void 0)return a.set(e,c),c}if(e[f_e])return n?.push(e),a.set(e,e),e;const i=c=>Rr(this,Za,Nb).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=g_e(e);if(Y4(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[q4]=!0),a.set(e,c),c}}if(typeof e=="function"){const i=t.functions.serialize(e,t,n),s={[RS]:i};return a.set(e,s),s}return a.set(e,e),e},xs=function(e,t,n=!1){if(e==null)return e;if(typeof e=="object"){if(Mn(this,mp)&&!n){const r=Mn(this,mp).call(this,e,i=>Rr(this,Za,xs).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,xs).call(this,r,t));if(e instanceof Map)return new Map([...e].map(([r,i])=>[Rr(this,Za,xs).call(this,r,t),Rr(this,Za,xs).call(this,i,t)]));if(e instanceof Set)return new Set([...e].map(r=>Rr(this,Za,xs).call(this,r,t)));if(RS in e)return t.functions.deserialize(e[RS],t);if(!Y4(e))return e;const a={};for(const r of Object.keys(e))r===q4?a[Symbol.asyncIterator]=()=>a:a[r]=Rr(this,Za,xs).call(this,e[r],t);return a}return e};var Qc,Cl,Ss,O_,KK,D_,ZK;class v_e{constructor(t,{imports:n,exports:a,functions:r=new h_e,serialization:i=new b_e,signal:s}={}){fi(this,Ss),fi(this,Qc),fi(this,Cl,new Map);var c,u,d,m;this.messages=t,R_(this,Qc,s?new p_e(s):new AbortController),this.exports=a??{},this.imports=y_e(Rr(this,Ss,KK).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,Cl).keys())Rr(this,Ss,D_).call(this,h,void 0,new Z4);Mn(this,Cl).clear()},{once:!0}),t.listen(async h=>{if(!(Array.isArray(h)&&typeof h[0]=="number"))return;const g=h;switch(g[0]){case BK:{const[,v,w,S]=g,y=this.exports[w]??(()=>{throw new Error(`No '${w}' method is exported from this thread`)});await Rr(this,Ss,O_).call(this,y,S,(_,E,k)=>{this.messages.send([G4,v,_,E],k)});break}case HK:{const[,v,w,S]=g,y=this.functions.get(w,this)??w_e;await Rr(this,Ss,O_).call(this,y,S,(_,E,k)=>{this.messages.send([W4,v,_,E],k)});break}case G4:case W4:{Rr(this,Ss,D_).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,Qc).signal}get closed(){return Mn(this,Qc).signal.aborted}close(){Mn(this,Qc).abort()}call(t,n){if(this.closed)return Promise.reject(new Z4);const a=[],r=this.serialization.serialize(n,this,a),i=GK(),s=Rr(this,Ss,ZK).call(this,i);return t(i,r,a),s}}Qc=new WeakMap,Cl=new WeakMap,Ss=new WeakSet,O_=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))}},KK=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([BK,n,e,a],r)},t)}catch(n){return Promise.reject(n)}}},D_=function(...e){const t=e[0],n=Mn(this,Cl).get(t);n&&(n(...e),Mn(this,Cl).delete(t))},ZK=function(e){const t=new Promise((n,a)=>{Mn(this,Cl).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 y_e(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 w_e(){throw new Error("You attempted to call a function that is not stored. It may have already been released.")}const x_e="quilt.threads.ping",X4="quilt.threads.pong";function S_e(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===X4&&(n=!0,s.abort(),i())},{signal:s.signal}),s.signal.addEventListener("abort",()=>i(),{once:!0}),a(x_e)});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!==X4&&i(c.data)},{signal:s})}}}class E_e extends v_e{constructor(t,{targetOrigin:n="*",...a}={}){super(S_e(t.contentWindow,{targetOrigin:n}),a),this.iframe=t}}const YK=ue.forwardRef(({content:e,children:t,...n},a)=>f.jsx("span",{ref:a,...n,children:e||t}));YK.displayName="UIText";const qK=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}));qK.displayName="UIButton";const XK=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}));XK.displayName="UIStack";const JK=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}));JK.displayName="UIImage";const qO={name:"basic",elements:[{tagName:"ui-text",component:YK,propMapping:{content:"content"},eventMapping:{}},{tagName:"ui-button",component:qK,propMapping:{label:"label"},eventMapping:{press:"onPress"}},{tagName:"ui-stack",component:XK,propMapping:{direction:"direction",spacing:"spacing",align:"align",justify:"justify"},eventMapping:{}},{tagName:"ui-image",component:JK,propMapping:{src:"src",alt:"alt",width:"width",height:"height"},eventMapping:{}}]},__e=({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"})},k_e=({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 n_e,w=t||qO,S=new Map;return w&&w.elements.forEach(y=>{const _=l_e(y.component);S.set(y.tagName,_)}),{receiver:v,components:S}}case"webcomponents":default:return{receiver:new r_e,components:null}}},[e,t,n]);x.useEffect(()=>{function v(w){var S;if(r.current&&w.source===r.current.contentWindow){const y=w.data;if(!y)return;(S=a?.(y))==null||S.catch(_=>{console.error("Error handling UI action result in RemoteDOMResourceRenderer:",_)})}}return window.addEventListener("message",v),()=>window.removeEventListener("message",v)},[a]),x.useEffect(()=>{const v=i.current;return i.current=null,()=>{v?.close()}},[d]);const g=()=>{const v=r.current;if(!v||i.current)return;const w=new E_e(v);i.current=w;const{code:S,error:y}=KEe(e);if(y){c(y);return}if(S&&m!=null&&m.connection){const _={code:S,remoteElements:n,useReactRenderer:u==="react",componentLibrary:t?.name};w.imports.render(_,m.connection).catch(E=>console.error("Error calling remote render:",E))}};return s?f.jsx("p",{className:"text-red-500",children:s}):f.jsxs(f.Fragment,{children:[f.jsx("iframe",{ref:r,srcDoc:d_e,sandbox:"allow-scripts",style:{display:"none"},title:"Remote DOM Sandbox",onLoad:g},d),u==="react"&&h?f.jsx(u_e,{receiver:m,components:h}):f.jsx(__e,{receiver:m})]})};function T_e(e){var t;if(e.contentType)return e.contentType;if(e.mimeType==="text/html")return"rawHtml";if(e.mimeType==="text/uri-list")return"externalUrl";if((t=e.mimeType)!=null&&t.startsWith("application/vnd.mcp-ui.remote-dom"))return"remoteDom"}const XO=e=>{const{resource:t,onUIAction:n,supportedContentTypes:a,htmlProps:r,remoteDomProps:i}=e,s=T_e(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($K,{resource:t,onUIAction:n,...r});case"remoteDom":return f.jsx(k_e,{resource:t,onUIAction:n,library:i?.library||qO,...i});default:return f.jsx("p",{className:"text-red-500",children:"Unsupported resource type."})}};XO.displayName="UIResourceRenderer";const N_e={tagName:"ui-button",remoteAttributes:["label"],remoteEvents:["click","press"]},C_e={tagName:"ui-text",remoteAttributes:["content"]},R_e={tagName:"ui-stack",remoteAttributes:["direction","spacing","align","justify"]},A_e={tagName:"ui-image",remoteAttributes:["src","alt","width","height"]},I_e=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(XO,{resource:e,onUIAction:t,htmlProps:{style:{maxWidth:"100%",height:"100%",overflow:"auto"},autoResizeIframe:!0,sandboxPermissions:"allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox"}})}):null});function J4({toolName:e,toolArgs:t,result:n,serverId:a,readResource:r,toolMeta:i}){const[s,c]=x.useState(null);x.useEffect(()=>{console.log("[ToolResultRenderer] Rendering:",{toolName:e,hasToolMeta:!!i,outputTemplate:i?.["openai/outputTemplate"],hasResult:!!n,hasServerId:!!a,hasReadResource:!!r})},[e,i,n,a,r]);const u=x.useMemo(()=>{if(typeof n=="string")try{return JSON.parse(n)}catch(v){return console.error("[ToolResultRenderer] Failed to parse result:",v),n}return n},[n]),d=x.useMemo(()=>!!i?.["openai/outputTemplate"],[i]),m=x.useMemo(()=>!!(u?.content&&Array.isArray(u.content)&&u.content.some(v=>v.type==="resource"&&v.resource?.uri?.startsWith("ui://")&&v.resource?.mimeType==="text/html+skybridge")),[u]),h=x.useMemo(()=>m&&u.content.find(w=>w.type==="resource"&&w.resource?.uri?.startsWith("ui://")&&w.resource?.mimeType==="text/html+skybridge")?.resource||null,[m,u]);if(x.useEffect(()=>{if(h){c(h);return}if(d&&i&&r){const v=i["openai/outputTemplate"];console.log("[ToolResultRenderer] Fetching resource for Apps SDK tool:",v),r(v).then(w=>{console.log("[ToolResultRenderer] Resource fetched:",w),w?.contents&&Array.isArray(w.contents)&&w.contents.length>0?c(w.contents[0]):console.warn("[ToolResultRenderer] No contents in fetched resource:",w)}).catch(w=>{console.error("[ToolResultRenderer] Failed to fetch resource:",w)})}},[h,d,i,r]),(d||m)&&s&&a&&r)return f.jsx(GO,{componentUrl:s.uri,toolName:e,toolArgs:t,toolResult:u,serverId:a,readResource:r,noWrapper:!0,className:"my-4",showConsole:!1});if((d||m)&&!s)return f.jsx("div",{className:"flex items-center justify-center w-full h-[200px] rounded border",children:f.jsx(Ei,{className:"size-5"})});if(d&&(!a||!r))return console.error("[ToolResultRenderer] Apps SDK tool but missing serverId or readResource:",{toolName:e,hasServerId:!!a,hasReadResource:!!r}),f.jsx("div",{className:"my-4 p-4 bg-red-50/30 dark:bg-red-950/20 border border-red-200/50 dark:border-red-800/50 rounded-lg",children:f.jsx("p",{className:"text-sm text-red-600 dark:text-red-400",children:"Cannot render widget: Missing required props (serverId or readResource)"})});const g=[];if(u?.content&&Array.isArray(u.content))for(const v of u.content)v.type==="resource"&&v.resource?.uri?.startsWith("ui://")&&v.resource?.mimeType!=="text/html+skybridge"&&g.push(v.resource);return g.length>0?f.jsx(f.Fragment,{children:g.map(v=>f.jsx(I_e,{resource:v},`${e}-mcp-ui-${v.uri}`))}):(console.log("[ToolResultRenderer] Not rendering (no UI resources found):",{toolName:e,isAppsSdkTool:d,hasAppsSdkComponent:m,hasResourceData:!!s,contentLength:u?.content?.length}),null)}function O_e({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 D_e=x.memo(({messages:e,isLoading:t,serverId:n,readResource:a,tools:r})=>{const i=x.useRef(null),s=d=>r?.find(h=>h.name===d)?._meta;x.useEffect(()=>{e.length>0&&i.current&&i.current.scrollIntoView({behavior:t?"auto":"smooth",block:"start"})},[e.length,t]);const c=t&&(()=>{if(e.length===0)return!0;const d=e[e.length-1];if(d.role==="user")return!0;if(d.role==="assistant"){const m=typeof d.content=="string"?d.content:Array.isArray(d.content)?d.content.map(g=>typeof g=="string"?g:g.text||JSON.stringify(g)).join(""):JSON.stringify(d.content);return!(m&&m.trim().length>0)}return!1})(),u=d=>{if(!t)return!1;const m=e[e.length-1];return d.id===m.id&&m.role==="assistant"};return f.jsxs("div",{className:"space-y-6 max-w-3xl mx-auto px-2",children:[e.map(d=>{const m=typeof d.content=="string"?d.content:Array.isArray(d.content)?d.content.map(h=>typeof h=="string"?h:h.text||JSON.stringify(h)).join(""):JSON.stringify(d.content);return d.role==="user"?f.jsx(O_e,{content:m,timestamp:d.timestamp},d.id):d.role==="assistant"?f.jsx("div",{className:"space-y-4",children:d.parts&&d.parts.length>0?d.parts.map((h,g)=>{const v=h.type==="text"?`${d.id}-text-${g}-${h.text?.slice(0,20)}`:`${d.id}-tool-${h.toolInvocation?.toolName}-${g}`;return h.type==="text"?f.jsx(L4,{content:h.text||"",timestamp:g===d.parts.length-1?d.timestamp:void 0,_isStreaming:u(d)},v):h.type==="tool-invocation"&&h.toolInvocation?f.jsxs("div",{children:[f.jsx($4,{toolName:h.toolInvocation.toolName,args:h.toolInvocation.args,result:h.toolInvocation.result,state:h.toolInvocation.result?"result":"call"}),h.toolInvocation.result&&f.jsx(J4,{toolName:h.toolInvocation.toolName,toolArgs:h.toolInvocation.args,result:h.toolInvocation.result,serverId:n,readResource:a,toolMeta:s(h.toolInvocation.toolName)})]},v):null}):f.jsxs(f.Fragment,{children:[f.jsx(L4,{content:m,timestamp:d.timestamp,_isStreaming:u(d)}),d.toolCalls&&d.toolCalls.length>0&&f.jsx("div",{className:"space-y-2",children:d.toolCalls.map(h=>{const g=`${d.id}-${h.toolName}-${JSON.stringify(h.args).slice(0,50)}`;return f.jsxs("div",{children:[f.jsx($4,{toolName:h.toolName,args:h.args,result:h.result,state:h.result?"result":"call"}),h.result&&f.jsx(J4,{toolName:h.toolName,toolArgs:h.args,result:h.result,serverId:n,readResource:a,toolMeta:s(h.toolName)})]},g)})})]})},d.id):null}),c&&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(X0e,{duration:2,spread:1,children:"Thinking..."})})})})})}),f.jsx("div",{ref:i})]})});function QK(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 j_e({mcpServerUrl:e,llmConfig:t,authConfig:n,isConnected:a}){const[r,i]=x.useState([]),[s,c]=x.useState(!1),u=x.useCallback(async m=>{if(!m.trim()||!t||!a)return;const h={id:`user-${Date.now()}`,role:"user",content:m.trim(),timestamp:Date.now()};i(g=>[...g,h]),c(!0);try{let g=n;if(n?.type==="oauth")try{const C="mcp:auth",R=QK(e),I=`${C}_${R}_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(C){console.warn("Failed to retrieve OAuth tokens:",C)}const v=await fetch("/inspector/api/chat/stream",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mcpServerUrl:e,llmConfig:t,authConfig:g,messages:[...r,h].map(C=>({role:C.role,content:C.content}))})});if(!v.ok)throw new Error(`HTTP error! status: ${v.status}`);const w=`assistant-${Date.now()}`;let S="";const y=[];i(C=>[...C,{id:w,role:"assistant",content:"",timestamp:Date.now(),parts:[]}]);const _=v.body?.getReader(),E=new TextDecoder;if(!_)throw new Error("No response body");let k="";for(;;){const{done:C,value:R}=await _.read();if(C)break;k+=E.decode(R,{stream:!0});const I=k.split(`
|
|
1660
|
-
`);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"){S+=O.content;const M=y[y.length-1];M&&M.type==="text"?M.text=S:y.push({type:"text",text:S}),console.log("[Parts after text]",y.length,"parts, text length:",S.length),i(U=>U.map(H=>H.id===w?{...H,parts:[...y]}:H))}else if(O.type==="tool-call")S&&(S=""),y.push({type:"tool-invocation",toolInvocation:{toolName:O.toolName,args:O.args,state:"pending"}}),console.log("[Parts after tool-call]",y.length,"parts, tool:",O.toolName),i(M=>M.map(U=>U.id===w?{...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===w?{...H,parts:[...y]}:H))):console.warn("[tool-result] Could not find matching tool part for",O.toolName)}else if(O.type==="done")console.log("[Done] Final parts:",y.length),i(M=>M.map(U=>U.id===w?{...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 S=g;S.status&&(v=`HTTP ${S.status}: ${v}`),(S.code===401||v.includes("401")||v.includes("Unauthorized"))&&(v="Authentication failed (401). Check your Authorization header in the connection settings.")}const w={id:`error-${Date.now()}`,role:"assistant",content:`Error: ${v}`,timestamp:Date.now()};i(S=>[...S,w])}finally{c(!1)}},[t,a,e,r,n]),d=x.useCallback(()=>{i([])},[]);return{messages:r,isLoading:s,sendMessage:u,clearMessages:d}}function L_e({connection:e,llmConfig:t,isConnected:n,readResource:a}){const[r,i]=x.useState([]),[s,c]=x.useState(!1),u=x.useRef(null),d=x.useRef(null),m=x.useRef(null),h=x.useCallback(async v=>{if(!v.trim()||!t||!n)return;const w={id:`user-${Date.now()}`,role:"user",content:v.trim(),timestamp:Date.now()};i(_=>[..._,w]),c(!0),u.current=new AbortController;const S=Date.now();let y=0;try{const _=`assistant-${Date.now()}`;let E="";const k=[];if(i(C=>[...C,{id:_,role:"assistant",content:"",timestamp:Date.now(),parts:[]}]),!m.current||m.current.provider!==t.provider||m.current.model!==t.model||m.current.apiKey!==t.apiKey){let C;if(t.provider==="openai"){const{ChatOpenAI:R}=await Qn(async()=>{const{ChatOpenAI:I}=await import("./index-ifgbqaNd.js");return{ChatOpenAI:I}},__vite__mapDeps([5,6,7,2,8,9]));C=new R({model:t.model,apiKey:t.apiKey})}else if(t.provider==="anthropic"){const{ChatAnthropic:R}=await Qn(async()=>{const{ChatAnthropic:I}=await import("./index-Bsd6iYVu.js");return{ChatAnthropic:I}},__vite__mapDeps([10,7,6,2]));C=new R({model:t.model,apiKey:t.apiKey})}else if(t.provider==="google"){const{ChatGoogleGenerativeAI:R}=await Qn(async()=>{const{ChatGoogleGenerativeAI:I}=await import("./index-CTlKvTfg.js");return{ChatGoogleGenerativeAI:I}},__vite__mapDeps([11,7,6,2,9]));C=new R({model:t.model,apiKey:t.apiKey})}else throw new Error(`Unsupported LLM provider: ${t.provider}`);m.current={instance:C,provider:t.provider,model:t.model,apiKey:t.apiKey}}if(!d.current||d.current.llm!==m.current.instance){const{MCPAgent:C}=await Qn(async()=>{const{MCPAgent:R}=await import("./browser-BdMDtIlv.js").then(I=>I.b);return{MCPAgent:R}},__vite__mapDeps([12,8,6,7,2,3,4,9]));d.current=new C({llm:m.current.instance,client:e.client,memoryEnabled:!0,systemPrompt:"You are a helpful assistant with access to MCP tools, prompts, and resources. Help users interact with the MCP server."}),await d.current.initialize()}else console.log("[useChatMessagesClientSide] Reusing existing agent. History length:",d.current.conversationHistory?.length);for await(const C of d.current.streamEvents(v,10,!1,void 0)){if(u.current?.signal.aborted)break;if(C.event==="on_chat_model_stream"&&C.data?.chunk?.text){const R=C.data.chunk.text;if(typeof R=="string"&&R.length>0){E+=R;const 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(C.event==="on_tool_start"){E&&(E="");let R={};C.data?.input?R=C.data.input:C.data?.tool_input?R=C.data.tool_input:C.data&&(R=C.data),console.log("[useChatMessagesClientSide] on_tool_start:",{toolName:C.name,eventData:C.data,extractedArgs:R}),y++,k.push({type:"tool-invocation",toolInvocation:{toolName:C.name||"unknown",args:R,state:"pending"}}),i(I=>I.map(A=>A.id===_?{...A,parts:[...k]}:A))}else if(C.event==="on_tool_end"){const R=k.find(I=>I.type==="tool-invocation"&&I.toolInvocation?.toolName===C.name&&!I.toolInvocation?.result);if(console.log("[useChatMessagesClientSide] on_tool_end event:",{toolName:C.name,hasToolPart:!!R,output:C.data?.output}),R&&R.toolInvocation){let I=C.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}R.toolInvocation.result=I,R.toolInvocation.state="result";const A=I?._meta?.["openai/outputTemplate"];if(console.log("[useChatMessagesClientSide] Tool result:",{toolName:C.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};R.toolInvocation.result=H,console.log("[useChatMessagesClientSide] Updated result with resources")}else console.warn("[useChatMessagesClientSide] No contents in resourceData:",O)}catch(O){console.error("Failed to fetch Apps SDK resource:",O)}}i(O=>O.map(M=>M.id===_?{...M,parts:[...k]}:M))}}}i(C=>C.map(R=>R.id===_?{...R,parts:[...k],content:""}:R)),t&&yr.getInstance().capture(new CU({serverId:e.url,provider:t.provider,model:t.model,messageCount:r.length+1,toolCallsCount:y,success:!0,executionMode:"client-side",duration:Date.now()-S})).catch(()=>{})}catch(_){console.error("Client-side agent error:",_);let E="Unknown error occurred";if(_ instanceof Error){E=_.message;const C=_;C.status&&(E=`HTTP ${C.status}: ${E}`),(C.code===401||E.includes("401")||E.includes("Unauthorized"))&&(E="Authentication failed (401). Check your Authorization header in the connection settings.")}t&&yr.getInstance().capture(new CU({serverId:e.url,provider:t.provider,model:t.model,messageCount:r.length+1,toolCallsCount:y,success:!1,executionMode:"client-side",duration:Date.now()-S,error:E})).catch(()=>{});const k={id:`error-${Date.now()}`,role:"assistant",content:`Error: ${E}`,timestamp:Date.now()};i(C=>[...C,k])}finally{c(!1),u.current=null}},[e,t,n,r,a]),g=x.useCallback(()=>{i([]),d.current&&d.current.clearConversationHistory()},[]);return{messages:r,isLoading:s,sendMessage:h,clearMessages:g}}const Q4={openai:"gpt-4o",anthropic:"claude-haiku-4-5-20251001",google:"gemini-2.5-flash"};function eZ({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(Q4.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{}},[]),w=x.useCallback(M=>{localStorage.setItem("mcp-inspector-api-keys",JSON.stringify(M))},[]),[S,y]=x.useState("none"),[_,E]=x.useState(""),[k,C]=x.useState(""),[R,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&&C(U.password),U.token&&I(U.token)}catch(U){console.error("Failed to load auth config:",U)}else try{const U="mcp:auth",H=QK(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(Q4[c]);const M=v();m(M[c]||"")},[c,v]);const A=x.useCallback(()=>{if(!d.trim())return;const M=v();M[c]=d,w(M);const U={provider:c,apiKey:d,model:h},H={type:S,...S==="basic"&&{username:_.trim(),password:k.trim()},...S==="bearer"&&{token:R.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,S,_,k,R,v,w]),O=x.useCallback(()=>{n(null),r(null);const M=v();delete M[c],w(M),m(""),E(""),C(""),I(""),y("none"),localStorage.removeItem("mcp-inspector-llm-config"),localStorage.removeItem("mcp-inspector-auth-config")},[c,v,w]);return{llmConfig:t,authConfig:a,configDialogOpen:i,setConfigDialogOpen:s,tempProvider:c,setTempProvider:u,tempApiKey:d,setTempApiKey:m,tempModel:h,setTempModel:g,tempAuthType:S,saveLLMConfig:A,clearConfig:O}}function $_e({connection:e,isConnected:t,useClientSide:n=!0,readResource:a}){const[r,i]=x.useState(""),s=x.useRef(null),{llmConfig:c,authConfig:u,configDialogOpen:d,setConfigDialogOpen:m,tempProvider:h,setTempProvider:g,tempApiKey:v,setTempApiKey:w,tempModel:S,setTempModel:y,saveLLMConfig:_,clearConfig:E}=eZ({mcpServerUrl:e.url}),k={connection:e,llmConfig:c,isConnected:t,readResource:a},C=j_e({mcpServerUrl:e.url,llmConfig:c,authConfig:u,isConnected:t}),R=L_e(k),{messages:I,isLoading:A,sendMessage:O,clearMessages:M}=n?R:C;JW({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(i_,{open:d,onOpenChange:m,tempProvider:h,tempModel:S,tempApiKey:v,onProviderChange:g,onModelChange:y,onApiKeyChange:w,onSave:_,onClear:K,showClearButton:!0,buttonLabel:"Change API Key"})}),f.jsx(Y0e,{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(W0e,{llmConfig:c,hasMessages:I.length>0,configDialogOpen:d,onConfigDialogOpenChange:m,onClearChat:M,tempProvider:h,tempModel:S,tempApiKey:v,onProviderChange:g,onModelChange:y,onApiKeyChange:w,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(D_e,{messages:I,isLoading:A,serverId:e.url,readResource:a,tools:e.tools}):f.jsx(q0e,{onConfigureClick:()=>m(!0)})}),c&&f.jsx(K0e,{inputValue:r,isConnected:t,isLoading:A,textareaRef:s,onInputChange:i,onKeyDown:H,onSendMessage:U})]})}const nw=x.createContext(null);nw.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"},JO=10,Ol=x.useLayoutEffect,e2=ud.useId,M_e=typeof e2=="function"?e2:()=>null;let P_e=0;function QO(e=null){const t=M_e(),n=x.useRef(e||t||null);return n.current===null&&(n.current=""+P_e++),e??n.current}function tZ({children:e,className:t="",collapsedSize:n,collapsible:a,defaultSize:r,forwardedRef:i,id:s,maxSize:c,minSize:u,onCollapse:d,onExpand:m,onResize:h,order:g,style:v,tagName:w="div",...S}){const y=x.useContext(nw);if(y===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:_,expandPanel:E,getPanelSize:k,getPanelStyle:C,groupId:R,isPanelCollapsed:I,reevaluatePanelConstraints:A,registerPanel:O,resizePanel:M,unregisterPanel:U}=y,H=QO(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}),Ol(()=>{const{callbacks:te,constraints:ae}=K.current,B={...ae};K.current.id=H,K.current.idIsFromProps=s!==void 0,K.current.order=g,te.onCollapse=d,te.onExpand=m,te.onResize=h,ae.collapsedSize=n,ae.collapsible=a,ae.defaultSize=r,ae.maxSize=c,ae.minSize=u,(B.collapsedSize!==ae.collapsedSize||B.collapsible!==ae.collapsible||B.maxSize!==ae.maxSize||B.minSize!==ae.minSize)&&A(K.current,B)}),Ol(()=>{const te=K.current;return O(te),()=>{U(te)}},[g,H,O,U]),x.useImperativeHandle(i,()=>({collapse:()=>{_(K.current)},expand:te=>{E(K.current,te)},getId(){return H},getSize(){return k(K.current)},isCollapsed(){return I(K.current)},isExpanded(){return!I(K.current)},resize:te=>{M(K.current,te)}}),[_,E,k,I,H,M]);const ee=C(K.current,r);return x.createElement(w,{...S,children:e,className:t,id:H,style:{...ee,...v},[Wn.groupId]:R,[Wn.panel]:"",[Wn.panelCollapsible]:a||void 0,[Wn.panelId]:H,[Wn.panelSize]:parseFloat(""+ee.flexGrow).toFixed(1)})}const nZ=x.forwardRef((e,t)=>x.createElement(tZ,{...e,forwardedRef:t}));tZ.displayName="Panel";nZ.displayName="forwardRef(Panel)";let j_=null,Cb=-1,Ns=null;function U_e(e,t,n){const a=(t&sZ)!==0,r=(t&lZ)!==0,i=(t&cZ)!==0,s=(t&uZ)!==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 z_e(){Ns!==null&&(document.head.removeChild(Ns),j_=null,Ns=null,Cb=-1)}function AS(e,t,n){var a,r;const i=U_e(e,t);if(j_!==i){if(j_=i,Ns===null&&(Ns=document.createElement("style"),document.head.appendChild(Ns)),Cb>=0){var s;(s=Ns.sheet)===null||s===void 0||s.removeRule(Cb)}Cb=(a=(r=Ns.sheet)===null||r===void 0?void 0:r.insertRule(`*{cursor: ${i} !important;}`))!==null&&a!==void 0?a:-1}}function rZ(e){return e.type==="keydown"}function aZ(e){return e.type.startsWith("pointer")}function iZ(e){return e.type.startsWith("mouse")}function rw(e){if(aZ(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(iZ(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}function F_e(){if(typeof matchMedia=="function")return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}function B_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 H_e(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:r2(e),b:r2(t)};let a;for(;n.a.at(-1)===n.b.at(-1);)e=n.a.pop(),t=n.b.pop(),a=e;Nt(a,"Stacking order can only be calculated for elements with a common ancestor");const r={a:n2(t2(n.a)),b:n2(t2(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 V_e=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function G_e(e){var t;const n=getComputedStyle((t=oZ(e))!==null&&t!==void 0?t:e).display;return n==="flex"||n==="inline-flex"}function W_e(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||G_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"||V_e.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function t2(e){let t=e.length;for(;t--;){const n=e[t];if(Nt(n,"Missing node"),W_e(n))return n}return null}function n2(e){return e&&Number(getComputedStyle(e).zIndex)||0}function r2(e){const t=[];for(;e;)t.push(e),e=oZ(e);return t}function oZ(e){const{parentNode:t}=e;return t&&t instanceof ShadowRoot?t.host:t}const sZ=1,lZ=2,cZ=4,uZ=8,K_e=F_e()==="coarse";let bi=[],wu=!1,Cs=new Map,aw=new Map;const Bp=new Set;function Z_e(e,t,n,a,r){var i;const{ownerDocument:s}=t,c={direction:n,element:t,hitAreaMargins:a,setResizeHandlerState:r},u=(i=Cs.get(s))!==null&&i!==void 0?i:0;return Cs.set(s,u+1),Bp.add(c),Dv(),function(){var m;aw.delete(e),Bp.delete(c);const h=(m=Cs.get(s))!==null&&m!==void 0?m:1;if(Cs.set(s,h-1),Dv(),h===1&&Cs.delete(s),bi.includes(c)){const g=bi.indexOf(c);g>=0&&bi.splice(g,1),iw(),r("up",!0,null)}}}function Y_e(e){const{target:t}=e,{x:n,y:a}=rw(e);wu=!0,eD({target:t,x:n,y:a}),Dv(),bi.length>0&&(jv("down",e),iw(),e.preventDefault(),dZ(t)||e.stopImmediatePropagation())}function IS(e){const{x:t,y:n}=rw(e);if(wu&&e.type!=="pointerleave"&&e.buttons===0&&(wu=!1,jv("up",e)),!wu){const{target:a}=e;eD({target:a,x:t,y:n})}jv("move",e),iw(),bi.length>0&&e.preventDefault()}function OS(e){const{target:t}=e,{x:n,y:a}=rw(e);aw.clear(),wu=!1,bi.length>0&&(e.preventDefault(),dZ(t)||e.stopImmediatePropagation()),jv("up",e),eD({target:t,x:n,y:a}),iw(),Dv()}function dZ(e){let t=e;for(;t;){if(t.hasAttribute(Wn.resizeHandle))return!0;t=t.parentElement}return!1}function eD({target:e,x:t,y:n}){bi.splice(0);let a=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(a=e),Bp.forEach(r=>{const{element:i,hitAreaMargins:s}=r,c=i.getBoundingClientRect(),{bottom:u,left:d,right:m,top:h}=c,g=K_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)&&H_e(a,i)>0){let w=a,S=!1;for(;w&&!w.contains(i);){if(B_e(w.getBoundingClientRect(),c)){S=!0;break}w=w.parentElement}if(S)return}bi.push(r)}})}function DS(e,t){aw.set(e,t)}function iw(){let e=!1,t=!1;bi.forEach(a=>{const{direction:r}=a;r==="horizontal"?e=!0:t=!0});let n=0;aw.forEach(a=>{n|=a}),e&&t?AS("intersection",n):e?AS("horizontal",n):t?AS("vertical",n):z_e()}let jS;function Dv(){var e;(e=jS)===null||e===void 0||e.abort(),jS=new AbortController;const t={capture:!0,signal:jS.signal};Bp.size&&(wu?(bi.length>0&&Cs.forEach((n,a)=>{const{body:r}=a;n>0&&(r.addEventListener("contextmenu",OS,t),r.addEventListener("pointerleave",IS,t),r.addEventListener("pointermove",IS,t))}),Cs.forEach((n,a)=>{const{body:r}=a;r.addEventListener("pointerup",OS,t),r.addEventListener("pointercancel",OS,t)})):Cs.forEach((n,a)=>{const{body:r}=a;n>0&&(r.addEventListener("pointerdown",Y_e,t),r.addEventListener("pointermove",IS,t))}))}function jv(e,t){Bp.forEach(n=>{const{setResizeHandlerState:a}=n,r=bi.includes(n);a(e,r,t)})}function q_e(){const[e,t]=x.useState(0);return x.useCallback(()=>t(n=>n+1),[])}function Nt(e,t){if(!e)throw console.error(t),Error(t)}function Wl(e,t,n=JO){return e.toFixed(n)===t.toFixed(n)?0:e>t?1:-1}function Eo(e,t,n=JO){return Wl(e,t,n)===0}function Ia(e,t,n){return Wl(e,t,n)===0}function X_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 fu({panelConstraints:e,panelIndex:t,size:n}){const a=e[t];Nt(a!=null,`Panel constraints not found for index ${t}`);let{collapsedSize:r=0,collapsible:i,maxSize:s=100,minSize:c=0}=a;if(Wl(n,c)<0)if(i){const u=(r+c)/2;Wl(n,u)<0?n=r:n=c}else n=c;return n=Math.min(s,n),n=parseFloat(n.toFixed(JO)),n}function Zf({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:a,prevLayout:r,trigger:i}){if(Ia(e,0))return t;const s=[...t],[c,u]=a;Nt(c!=null,"Invalid first pivot index"),Nt(u!=null,"Invalid second pivot index");let d=0;if(i==="keyboard"){{const h=e<0?u:c,g=n[h];Nt(g,`Panel constraints not found for index ${h}`);const{collapsedSize:v=0,collapsible:w,minSize:S=0}=g;if(w){const y=t[h];if(Nt(y!=null,`Previous layout not found for panel index ${h}`),Ia(y,v)){const _=S-y;Wl(_,Math.abs(e))>0&&(e=e<0?0-_:_)}}}{const h=e<0?c:u,g=n[h];Nt(g,`No panel constraints found for index ${h}`);const{collapsedSize:v=0,collapsible:w,minSize:S=0}=g;if(w){const y=t[h];if(Nt(y!=null,`Previous layout not found for panel index ${h}`),Ia(y,S)){const _=y-v;Wl(_,Math.abs(e))>0&&(e=e<0?0-_:_)}}}}{const h=e<0?1:-1;let g=e<0?u:c,v=0;for(;;){const S=t[g];Nt(S!=null,`Previous layout not found for panel index ${g}`);const _=fu({panelConstraints:n,panelIndex:g,size:100})-S;if(v+=_,g+=h,g<0||g>=n.length)break}const w=Math.min(Math.abs(e),Math.abs(v));e=e<0?0-w:w}{let g=e<0?c:u;for(;g>=0&&g<n.length;){const v=Math.abs(e)-Math.abs(d),w=t[g];Nt(w!=null,`Previous layout not found for panel index ${g}`);const S=w-v,y=fu({panelConstraints:n,panelIndex:g,size:S});if(!Ia(w,y)&&(d+=w-y,s[g]=y,d.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?g--:g++}}if(X_e(r,s))return r;{const h=e<0?u:c,g=t[h];Nt(g!=null,`Previous layout not found for panel index ${h}`);const v=g+d,w=fu({panelConstraints:n,panelIndex:h,size:v});if(s[h]=w,!Ia(w,v)){let S=v-w,_=e<0?u:c;for(;_>=0&&_<n.length;){const E=s[_];Nt(E!=null,`Previous layout not found for panel index ${_}`);const k=E+S,C=fu({panelConstraints:n,panelIndex:_,size:k});if(Ia(E,C)||(S-=C-E,s[_]=C),Ia(S,0))break;e>0?_--:_++}}}const m=s.reduce((h,g)=>g+h,0);return Ia(m,100)?s:r}function J_e({layout:e,panelsArray:t,pivotIndices:n}){let a=0,r=100,i=0,s=0;const c=n[0];Nt(c!=null,"No pivot index found"),t.forEach((h,g)=>{const{constraints:v}=h,{maxSize:w=100,minSize:S=0}=v;g===c?(a=S,r=w):(i+=S,s+=w)});const u=Math.min(r,100-i),d=Math.max(a,100-s),m=e[c];return{valueMax:u,valueMin:d,valueNow:m}}function Hp(e,t=document){return Array.from(t.querySelectorAll(`[${Wn.resizeHandleId}][data-panel-group-id="${e}"]`))}function fZ(e,t,n=document){const r=Hp(e,n).findIndex(i=>i.getAttribute(Wn.resizeHandleId)===t);return r??null}function pZ(e,t,n){const a=fZ(e,t,n);return a!=null?[a,a+1]:[-1,-1]}function Q_e(e){return e instanceof HTMLElement?!0:typeof e=="object"&&e!==null&&"tagName"in e&&"getAttribute"in e}function mZ(e,t=document){if(Q_e(t)&&t.dataset.panelGroupId==e)return t;const n=t.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return n||null}function ow(e,t=document){const n=t.querySelector(`[${Wn.resizeHandleId}="${e}"]`);return n||null}function eke(e,t,n,a=document){var r,i,s,c;const u=ow(t,a),d=Hp(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 tke({committedValuesRef:e,eagerValuesRef:t,groupId:n,layout:a,panelDataArray:r,panelGroupElement:i,setLayout:s}){x.useRef({didWarnAboutMissingResizeHandle:!1}),Ol(()=>{if(!i)return;const c=Hp(n,i);for(let u=0;u<r.length-1;u++){const{valueMax:d,valueMin:m,valueNow:h}=J_e({layout:a,panelsArray:r,pivotIndices:[u,u+1]}),g=c[u];if(g!=null){const v=r[u];Nt(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;Nt(c,"Eager values not found");const{panelDataArray:u}=c,d=mZ(n,i);Nt(d!=null,`No group found for id "${n}"`);const m=Hp(n,i);Nt(m,`No resize handles found for group id "${n}"`);const h=m.map(g=>{const v=g.getAttribute(Wn.resizeHandleId);Nt(v,"Resize handle element has no handle id attribute");const[w,S]=eke(n,v,u,i);if(w==null||S==null)return()=>{};const y=_=>{if(!_.defaultPrevented)switch(_.key){case"Enter":{_.preventDefault();const E=u.findIndex(k=>k.id===w);if(E>=0){const k=u[E];Nt(k,`No panel data found for index ${E}`);const C=a[E],{collapsedSize:R=0,collapsible:I,minSize:A=0}=k.constraints;if(C!=null&&I){const O=Zf({delta:Ia(C,R)?A-R:R-C,initialLayout:a,panelConstraints:u.map(M=>M.constraints),pivotIndices:pZ(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 a2(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 hZ(e,t){const n=e==="horizontal",{x:a,y:r}=rw(t);return n?a:r}function nke(e,t,n,a,r){const i=n==="horizontal",s=ow(t,r);Nt(s,`No resize handle element found for id "${t}"`);const c=s.getAttribute(Wn.groupId);Nt(c,"Resize handle element has no group id attribute");let{initialCursorPosition:u}=a;const d=hZ(n,e),m=mZ(c,r);Nt(m,`No group element found for id "${c}"`);const h=m.getBoundingClientRect(),g=i?h.width:h.height;return(d-u)/g*100}function rke(e,t,n,a,r,i){if(rZ(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:nke(e,t,n,a,i)}function ake({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];Nt(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];Nt(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 Vc(e,t,n){t.forEach((a,r)=>{const i=e[r];Nt(i,`Panel data not found for index ${r}`);const{callbacks:s,constraints:c,id:u}=i,{collapsedSize:d=0,collapsible:m}=c,h=n[u];if(h==null||a!==h){n[u]=a;const{onCollapse:g,onExpand:v,onResize:w}=s;w&&w(a,h),m&&(g||v)&&(v&&(h==null||Eo(h,d))&&!Eo(a,d)&&v(),g&&(h==null||!Eo(h,d))&&Eo(a,d)&&g())}})}function rb(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 ike({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 oke(e,t=10){let n=null;return(...r)=>{n!==null&&clearTimeout(n),n=setTimeout(()=>{e(...r)},t)}}function i2(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 gZ(e){return`react-resizable-panels:${e}`}function bZ(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 vZ(e,t){try{const n=gZ(e),a=t.getItem(n);if(a){const r=JSON.parse(a);if(typeof r=="object"&&r!=null)return r}}catch{}return null}function ske(e,t,n){var a,r;const i=(a=vZ(e,n))!==null&&a!==void 0?a:{},s=bZ(t);return(r=i[s])!==null&&r!==void 0?r:null}function lke(e,t,n,a,r){var i;const s=gZ(e),c=bZ(t),u=(i=vZ(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 o2({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];Nt(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];Nt(s!=null,`No layout data found for index ${i}`);const c=fu({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];Nt(s!=null,`No layout data found for index ${i}`);const c=s+r,u=fu({panelConstraints:t,panelIndex:i,size:c});if(s!==u&&(r-=u-s,n[i]=u,Ia(r,0)))break}return n}const cke=100,Yf={getItem:e=>(i2(Yf),Yf.getItem(e)),setItem:(e,t)=>{i2(Yf),Yf.setItem(e,t)}},s2={};function yZ({autoSaveId:e=null,children:t,className:n="",direction:a,forwardedRef:r,id:i=null,onLayout:s=null,keyboardResizeBy:c=null,storage:u=Yf,style:d,tagName:m="div",...h}){const g=QO(i),v=x.useRef(null),[w,S]=x.useState(null),[y,_]=x.useState([]),E=q_e(),k=x.useRef({}),C=x.useRef(new Map),R=x.useRef(0),I=x.useRef({autoSaveId:e,direction:a,dragState:w,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=o2({layout:z,panelConstraints:F.map(X=>X.constraints)});a2($,W)||(_(W),A.current.layout=W,L&&L(W),Vc(F,W,k.current))}}),[]),Ol(()=>{I.current.autoSaveId=e,I.current.direction=a,I.current.dragState=w,I.current.id=g,I.current.onLayout=s,I.current.storage=u}),tke({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=s2[e];L==null&&(L=oke(lke,cke),s2[e]=L);const $=[...z],F=new Map(C.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(J=>J.constraints),{collapsedSize:X=0,panelSize:ie,pivotIndices:le}=vl(F,z,$);if(Nt(ie!=null,`Panel size not found for panel "${z.id}"`),!Eo(ie,X)){C.current.set(z.id,ie);const q=eu(F,z)===F.length-1?ie-X:X-ie,se=Zf({delta:q,initialLayout:$,panelConstraints:W,pivotIndices:le,prevLayout:$,trigger:"imperative-api"});rb($,se)||(_(se),A.current.layout=se,L&&L(se),Vc(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:ie=0,panelSize:le=0,minSize:J=0,pivotIndices:q}=vl(W,z,F),se=L??J;if(Eo(le,ie)){const he=C.current.get(z.id),ce=he!=null&&he>=se?he:se,He=eu(W,z)===W.length-1?le-ce:ce-le,Se=Zf({delta:He,initialLayout:F,panelConstraints:X,pivotIndices:q,prevLayout:F,trigger:"imperative-api"});rb(F,Se)||(_(Se),A.current.layout=Se,$&&$(Se),Vc(W,Se,k.current))}}},[]),U=x.useCallback(z=>{const{layout:L,panelDataArray:$}=A.current,{panelSize:F}=vl($,z,L);return Nt(F!=null,`Panel size not found for panel "${z.id}"`),F},[]),H=x.useCallback((z,L)=>{const{panelDataArray:$}=A.current,F=eu($,z);return ike({defaultSize:L,dragState:w,layout:y,panelData:$,panelIndex:F})},[w,y]),K=x.useCallback(z=>{const{layout:L,panelDataArray:$}=A.current,{collapsedSize:F=0,collapsible:W,panelSize:X}=vl($,z,L);return Nt(X!=null,`Panel size not found for panel "${z.id}"`),W===!0&&Eo(X,F)},[]),ee=x.useCallback(z=>{const{layout:L,panelDataArray:$}=A.current,{collapsedSize:F=0,collapsible:W,panelSize:X}=vl($,z,L);return Nt(X!=null,`Panel size not found for panel "${z.id}"`),!W||Wl(X,F)>0},[]),te=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]);Ol(()=>{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=ske(z,W,$);le&&(C.current=new Map(Object.entries(le.expandToSizes)),X=le.layout)}X==null&&(X=ake({panelDataArray:W}));const ie=o2({layout:X,panelConstraints:W.map(le=>le.constraints)});a2(F,ie)||(_(ie),A.current.layout=ie,L&&L(ie),Vc(W,ie,k.current))}}),Ol(()=>{const z=A.current;return()=>{z.layout=[]}},[]);const ae=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:ie,dragState:le,id:J,keyboardResizeBy:q,onLayout:se}=I.current,{layout:he,panelDataArray:ce}=A.current,{initialLayout:Te}=le??{},He=pZ(J,z,X);let Se=rke(W,z,ie,le,q,X);const _e=ie==="horizontal";_e&&L&&(Se=-Se);const Ue=ce.map(Be=>Be.constraints),fe=Zf({delta:Se,initialLayout:Te??he,panelConstraints:Ue,pivotIndices:He,prevLayout:he,trigger:rZ(W)?"keyboard":"mouse-or-touch"}),Oe=!rb(he,fe);(aZ(W)||iZ(W))&&R.current!=Se&&(R.current=Se,!Oe&&Se!==0?_e?DS(z,Se<0?sZ:lZ):DS(z,Se<0?cZ:uZ):DS(z,0)),Oe&&(_(fe),A.current.layout=fe,se&&se(fe),Vc(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:ie,pivotIndices:le}=vl(W,z,F);Nt(ie!=null,`Panel size not found for panel "${z.id}"`);const q=eu(W,z)===W.length-1?ie-L:L-ie,se=Zf({delta:q,initialLayout:F,panelConstraints:X,pivotIndices:le,prevLayout:F,trigger:"imperative-api"});rb(F,se)||(_(se),A.current.layout=se,$&&$(se),Vc(W,se,k.current))},[]),Z=x.useCallback((z,L)=>{const{layout:$,panelDataArray:F}=A.current,{collapsedSize:W=0,collapsible:X}=L,{collapsedSize:ie=0,collapsible:le,maxSize:J=100,minSize:q=0}=z.constraints,{panelSize:se}=vl(F,z,$);se!=null&&(X&&le&&Eo(se,W)?Eo(W,ie)||B(z,ie):se<q?B(z,q):se>J&&B(z,J))},[B]),G=x.useCallback((z,L)=>{const{direction:$}=I.current,{layout:F}=A.current;if(!v.current)return;const W=ow(z,v.current);Nt(W,`Drag handle element not found for id "${z}"`);const X=hZ($,L);S({dragHandleId:z,dragHandleRect:W.getBoundingClientRect(),initialCursorPosition:X,initialLayout:F})},[]),re=x.useCallback(()=>{S(null)},[]),ne=x.useCallback(z=>{const{panelDataArray:L}=A.current,$=eu(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:w,expandPanel:M,getPanelSize:U,getPanelStyle:H,groupId:g,isPanelCollapsed:K,isPanelExpanded:ee,reevaluatePanelConstraints:Z,registerPanel:te,registerResizeHandle:ae,resizePanel:B,startDragging:G,stopDragging:re,unregisterPanel:ne,panelGroupElement:v.current}),[O,w,a,M,U,H,g,K,ee,Z,te,ae,B,G,re,ne]),V={display:"flex",flexDirection:a==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return x.createElement(nw.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 wZ=x.forwardRef((e,t)=>x.createElement(yZ,{...e,forwardedRef:t}));yZ.displayName="PanelGroup";wZ.displayName="forwardRef(PanelGroup)";function eu(e,t){return e.findIndex(n=>n===t||n.id===t.id)}function vl(e,t,n){const a=eu(e,t),i=a===e.length-1?[a-1,a]:[a,a+1],s=n[a];return{...t.constraints,panelSize:s,pivotIndices:i}}function uke({disabled:e,handleId:t,resizeHandler:n,panelGroupElement:a}){x.useEffect(()=>{if(e||n==null||a==null)return;const r=ow(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);Nt(c,`No group element found for id "${c}"`);const u=Hp(c,a),d=fZ(c,t,a);Nt(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 xZ({children:e=null,className:t="",disabled:n=!1,hitAreaMargins:a,id:r,onBlur:i,onClick:s,onDragging:c,onFocus:u,onPointerDown:d,onPointerUp:m,style:h={},tabIndex:g=0,tagName:v="div",...w}){var S,y;const _=x.useRef(null),E=x.useRef({onClick:s,onDragging:c,onPointerDown:d,onPointerUp:m});x.useEffect(()=>{E.current.onClick=s,E.current.onDragging=c,E.current.onPointerDown=d,E.current.onPointerUp=m});const k=x.useContext(nw);if(k===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:C,groupId:R,registerResizeHandle:I,startDragging:A,stopDragging:O,panelGroupElement:M}=k,U=QO(r),[H,K]=x.useState("inactive"),[ee,te]=x.useState(!1),[ae,B]=x.useState(null),Z=x.useRef({state:H});Ol(()=>{Z.current.state=H}),x.useEffect(()=>{if(n)B(null);else{const j=I(U);B(()=>j)}},[n,U,I]);const G=(S=a?.coarse)!==null&&S!==void 0?S:15,re=(y=a?.fine)!==null&&y!==void 0?y:5;x.useEffect(()=>{if(n||ae==null)return;const j=_.current;Nt(j,"Element ref not attached");let V=!1;return Z_e(U,j,C,{coarse:G,fine:re},(L,$,F)=>{if(!$){K("inactive");return}switch(L){case"down":{K("drag"),V=!1,Nt(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"),Nt(F,'Expected event to be defined for "move" action'),ae(F);break}case"up":{K("hover"),O();const{onClick:W,onDragging:X,onPointerUp:ie}=E.current;X?.(!1),ie?.(),V||W?.();break}}})},[G,C,n,re,I,U,ae,A,O]),uke({disabled:n,handleId:U,resizeHandler:ae,panelGroupElement:M});const ne={touchAction:"none",userSelect:"none"};return x.createElement(v,{...w,children:e,className:t,id:r,onBlur:()=>{te(!1),i?.()},onFocus:()=>{te(!0),u?.()},ref:_,role:"separator",style:{...ne,...h},tabIndex:g,[Wn.groupDirection]:C,[Wn.groupId]:R,[Wn.resizeHandle]:"",[Wn.resizeHandleActive]:H==="drag"?"pointer":ee?"keyboard":void 0,[Wn.resizeHandleEnabled]:!n,[Wn.resizeHandleId]:U,[Wn.resizeHandleState]:H})}xZ.displayName="PanelResizeHandle";function Qr({className:e,...t}){return f.jsx(wZ,{"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(nZ,{"data-slot":"resizable-panel",...e})}function vi({withHandle:e,className:t,...n}){return f.jsx(xZ,{"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(Jpe,{className:"size-2.5"})})})}function jm({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 dke({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(Dt,{children:[f.jsx(jt,{asChild:!0,children:f.jsx(Le,{variant:"ghost",size:"sm",onClick:r,className:"h-8 w-8 p-0",children:f.jsx(Ed,{className:"h-4 w-4"})})}),f.jsxs(Lt,{side:"bottom",className:"flex gap-2",children:["Search",f.jsx(jm,{children:"F"})]})]})]})}),f.jsx("div",{className:"flex items-center gap-2",children:f.jsxs(Dt,{children:[f.jsx(jt,{asChild:!0,children:f.jsx(Le,{variant:"ghost",size:"sm",onClick:c,disabled:a===0,className:"h-8 w-8 p-0",children:f.jsx($s,{className:"h-4 w-4"})})}),f.jsx(Lt,{side:"bottom",children:"Clear all"})]})})]})}function Zs({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 fke({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(Sd,{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(Zs,{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 pke({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(Qu,{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(Le,{variant:"ghost",size:"sm",onClick:n,className:t?"":"text-purple-600 dark:text-purple-400",children:[t?f.jsx(NN,{className:"h-4 w-4 mr-1"}):f.jsx(m8,{className:"h-4 w-4 mr-1"}),t?"JSON":"Formatted"]}),f.jsx(Le,{variant:"ghost",size:"sm",onClick:a,children:s?f.jsx(ta,{className:"h-4 w-4"}):f.jsx(jr,{className:"h-4 w-4"})}),f.jsx(Le,{variant:"ghost",size:"sm",onClick:r,children:f.jsx(bm,{className:"h-4 w-4"})}),f.jsx(Le,{variant:"ghost",size:"sm",onClick:i,children:f.jsx(AN,{className:"h-4 w-4"})}),c&&f.jsx(Le,{variant:"ghost",size:"sm",onClick:c,children:f.jsx(Yi,{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(kN,{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 Lv(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 mke({notifications:e,unreadCount:t,markNotificationRead:n,markAllNotificationsRead:a,clearNotifications:r,serverId:i,isConnected:s}){const[c,u]=x.useState(null),[d,m]=x.useState(""),[h,g]=x.useState(-1),[v,w]=x.useState(!0),[S,y]=x.useState(!1),[_,E]=x.useState(!0),[k,C]=x.useState(!1),R=x.useRef(null),I=x.useRef(null),A=x.useRef(null),O=x.useRef(!1);x.useEffect(()=>{v&&e.length>0&&R.current&&!O.current&&(R.current.scrollTop=0)},[e.length,v]),x.useEffect(()=>{const Z=R.current;if(!Z)return;const G=()=>{Z.scrollTop>0&&(O.current=!0,w(!1))};return Z.addEventListener("scroll",G),()=>Z.removeEventListener("scroll",G)},[]),x.useEffect(()=>{e.length===0&&(O.current=!1,w(!0))},[e.length]),x.useEffect(()=>{c&&!c.read&&n(c.id)},[c,n]),x.useEffect(()=>{S&&A.current&&A.current.focus()},[S]);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)),C(!0),setTimeout(()=>C(!1),2e3)}catch(Z){console.error("[NotificationsTab] Failed to copy notification:",Z)}},[c]),te=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]),ae=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:Lv}:null;return s?f.jsxs(Qr,{direction:"horizontal",className:"h-full",children:[f.jsx(Rn,{defaultSize:40,minSize:30,children:f.jsx(Qr,{direction:"vertical",className:"h-full border-r dark:border-zinc-700",children:f.jsxs(Rn,{defaultSize:75,minSize:30,children:[f.jsx(dke,{isSearchExpanded:S,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(fke,{notifications:U,selectedNotification:c,onNotificationSelect:H,focusedIndex:h,formatRelativeTime:Lv,listRef:R})})]})})}),f.jsx(vi,{}),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(pke,{notification:B,previewMode:_,onTogglePreview:()=>E(!_),onCopy:ee,onDownload:te,onFullscreen:ae,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(kN,{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 SZ({activeTab:e,isSearchExpanded:t,searchQuery:n,primaryTabTitle:a,secondaryTabTitle:r,primaryCount:i,secondaryCount:s,secondaryIcon:c,primaryIcon:u,searchPlaceholder:d="Search...",onSearchExpand:m,onSearchChange:h,onSearchBlur:g,onTabSwitch:v,searchInputRef:w,primaryTabName:S}){const y=e===S;return 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:w,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(Dt,{children:[f.jsx(jt,{asChild:!0,children:f.jsx(Le,{variant:"ghost",size:"sm",onClick:m,className:"h-8 w-8 p-0",children:f.jsx(Ed,{className:"h-4 w-4"})})}),f.jsxs(Lt,{side:"bottom",className:"flex gap-2",children:["Search",f.jsx(jm,{children:"F"})]})]})]})]})}),f.jsxs(Le,{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 l2({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(Tp,{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(Zs,{id:`prompt-${r.name}`,isSelected:t?.name===r.name,isFocused:a===i,icon:f.jsx(Tp,{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 c2({activeTab:e,isSearchExpanded:t,searchQuery:n,filteredPromptsCount:a,savedPromptsCount:r,onSearchExpand:i,onSearchChange:s,onSearchBlur:c,onTabSwitch:u,searchInputRef:d}){return f.jsx(SZ,{activeTab:e,isSearchExpanded:t,searchQuery:n,primaryTabName:"prompts",secondaryTabName:"saved",primaryTabTitle:"Prompts",secondaryTabTitle:"History",primaryCount:a,secondaryCount:r,primaryIcon:Tp,secondaryIcon:Qu,searchPlaceholder:"Search prompts...",onSearchExpand:i,onSearchChange:s,onSearchBlur:c,onTabSwitch:u,searchInputRef:d})}function u2({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(Qu,{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(Zs,{id:`saved-prompt-${i.id}`,isSelected:t?.id===i.id,isFocused:r===s,icon:f.jsx(Qu,{className:"h-4 w-4"}),title:i.name,description:`${i.promptName} - ${new Date(i.savedAt).toLocaleString()}`,onClick:()=>n(i)},i.id))})}function hke({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(Vl,{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 d2({selectedPrompt:e,promptArgs:t,isExecuting:n,isConnected:a,onArgChange:r,onExecute:i,onSave:s}){return x.useEffect(()=>{const c=u=>{(u.metaKey||u.ctrlKey)&&u.key==="Enter"&&e&&!n&&a&&(u.preventDefault(),i())};return document.addEventListener("keydown",c),()=>document.removeEventListener("keydown",c)},[e,n,a,i]),e?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(Le,{onClick:i,disabled:n||!a,size:"sm",className:"lg:size-default pr-1! gap-0",children:n?f.jsxs(f.Fragment,{children:[f.jsx(Ei,{className:"mr-2"}),f.jsx("span",{className:"hidden sm:inline",children:"Executing..."})]}):f.jsxs(f.Fragment,{children:[f.jsx(v8,{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:"⌘↵"})]})}),f.jsxs(Le,{variant:"outline",onClick:s,disabled:n,size:"sm",className:"lg:size-default gap-2",children:[f.jsx(IN,{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(hke,{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 gke(e){return"isError"in e&&!e.isError?null:"error"in e&&e.error?e.error:"isError"in e&&e.isError?"An error occurred":null}function f2({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)=>{const i=a.error||gke(a.result);return 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(Qu,{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(Np,{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(Le,{variant:"ghost",size:"sm",onClick:()=>n(r,a.result),className:"h-6 px-2",children:t===r?f.jsx(ta,{className:"h-4 w-4"}):f.jsx(jr,{className:"h-4 w-4"})})})]}),i?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:i})]}):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(Sd,{vertical:!0,noBorder:!0,message:"No Results yet"})})})})})}function tD({serverIds:e,onCountChange:t,onClearRef:n}={}){const[a,r]=x.useState([]),i=x.useRef(null),[s,c]=x.useState(new Set),[u]=x.useState(""),d=v=>{c(w=>{const S=new Set(w);return S.has(v)?S.delete(v):S.add(v),S})},m=async()=>{r([]),c(new Set),t?.(0);try{const v=new URLSearchParams;e&&e.length>0&&v.set("serverIds",e.join(","));const w=await fetch(`/inspector/api/rpc/log?${v.toString()}`,{method:"DELETE"});w.ok||console.warn("[RPC Logger] Failed to clear server buffer:",w.status)}catch(v){console.warn("[RPC Logger] Error clearing server buffer:",v)}},h=x.useMemo(()=>!e||e.length===0?"":[...e].sort().join(","),[e]);x.useEffect(()=>(n&&(n.current=m),()=>{n&&(n.current=null)}),[n,m]),x.useEffect(()=>{t?.(a.length)},[a.length,t]),x.useEffect(()=>{let v=null;try{const w=new URLSearchParams;w.set("replay","3"),w.set("_t",Date.now().toString()),e&&e.length>0&&w.set("serverIds",e.join(","));const S=`/inspector/api/rpc/stream?${w.toString()}`;console.log("[RPC Logger] Connecting to SSE stream:",S),v=new globalThis.EventSource(S),v.onopen=()=>{console.log("[RPC Logger] SSE connection opened")},v.onmessage=y=>{try{const _=JSON.parse(y.data);if(!_||_.type!=="rpc")return;const{serverId:E,direction:k,message:C,timestamp:R}=_,I=C,A=typeof I?.method=="string"?I.method:I?.result!==void 0?"result":I?.error!==void 0?"error":"unknown",O={id:`${R??Date.now()}-${Math.random().toString(36).slice(2)}`,serverId:typeof E=="string"?E:"unknown",direction:typeof k=="string"?k.toUpperCase():"",method:A,timestamp:R??new Date().toISOString(),payload:C};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(w){console.error("[RPC Logger] Failed to create SSE connection:",w)}return()=>{try{v?.close(),console.log("[RPC Logger] SSE connection closed")}catch{}}},[h]);const g=x.useMemo(()=>{let v=a;if(e&&e.length>0){const w=new Set(e);v=v.filter(S=>w.has(S.serverId))}if(u.trim()){const w=u.toLowerCase();v=v.filter(S=>S.serverId.toLowerCase().includes(w)||S.method.toLowerCase().includes(w)||S.direction.toLowerCase().includes(w)||JSON.stringify(S.payload).toLowerCase().includes(w))}return v},[a,u,e]);return 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 w=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:w?f.jsx(Xl,{className:"h-3 w-3 text-muted-foreground transition-transform"}):f.jsx(ype,{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(spe,{className:"h-3 w-3"}):f.jsx(cpe,{className:"h-3 w-3"})}),f.jsx("span",{className:"text-xs font-mono text-foreground truncate",children:v.method})]})]}),w&&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 p2="mcp-inspector-saved-prompts";function EZ({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}=Jl(),[h,g]=x.useState({}),[v,w]=x.useState([]),[S,y]=x.useState(!1),[_,E]=x.useState(null),[k,C]=x.useState(""),[R,I]=x.useState("prompts"),[A,O]=x.useState([]),[M,U]=x.useState(!1),[H,K]=x.useState(""),[ee,te]=x.useState(!1),[ae,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&&!S&&j("response")},[v,S,G]),x.useImperativeHandle(e,()=>({focusSearch:()=>{te(!0),setTimeout(()=>{Z.current&&Z.current.focus()},0)},blurSearch:()=>{C(""),te(!1),Z.current&&Z.current.blur()}})),x.useEffect(()=>{try{const Se=localStorage.getItem(p2);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(p2,JSON.stringify(Se))}catch(_e){console.error("[PromptsTab] Failed to save prompts:",_e)}},[]);x.useEffect(()=>{ee&&Z.current&&Z.current.focus()},[ee]);const ie=x.useCallback(()=>{k.trim()||te(!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]),J=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,R]),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 Oe=R==="prompts"?le:A;if(_e.key==="ArrowDown")_e.preventDefault(),B(Be=>{const xe=Be+1;return xe>=Oe.length?0:xe});else if(_e.key==="ArrowUp")_e.preventDefault(),B(Be=>{const xe=Be-1;return xe<0?Oe.length-1:xe});else if(_e.key==="Enter"&&ae>=0)if(_e.preventDefault(),R==="prompts"){const Be=le[ae];Be&&J(Be)}else{const Be=A[ae];Be&&q(Be)}};return document.addEventListener("keydown",Se),()=>document.removeEventListener("keydown",Se)},[ae,le,A,R,J,q]),x.useEffect(()=>{if(ae>=0){const Se=R==="prompts"?`prompt-${le[ae]?.name}`:`saved-prompt-${A[ae]?.id}`,_e=document.getElementById(Se);_e&&_e.scrollIntoView({behavior:"smooth",block:"nearest"})}},[ae,le,A,R]),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(()=>{J(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,J,m]);const se=x.useCallback((Se,_e)=>{g(Ue=>({...Ue,[Se]:_e}))},[]),he=x.useCallback(async()=>{if(!i||S)return;y(!0);const Se=Date.now();try{const _e=await n(i.name,h),Ue=Date.now()-Se;yr.getInstance().capture(new NU({promptName:i.name,serverId:a,success:!0})).catch(()=>{}),w(Oe=>[{promptName:i.name,args:h,result:_e,timestamp:Se,duration:Ue},...Oe])}catch(_e){yr.getInstance().capture(new NU({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};w(Oe=>[fe,...Oe])}finally{y(!1)}},[i,h,S,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)}},[]),Te=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(Le,{variant:"ghost",size:"sm",onClick:()=>{ne==="response"?j("detail"):(s(null),j("list"))},className:"p-0 h-8 w-8",children:f.jsx(TN,{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(jy,{initial:!1,mode:"popLayout",children:[ne==="list"&&f.jsxs(ba.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(c2,{activeTab:R,isSearchExpanded:ee,searchQuery:k,filteredPromptsCount:le.length,savedPromptsCount:A.length,onSearchExpand:()=>te(!0),onSearchChange:C,onSearchBlur:ie,onTabSwitch:()=>I(R==="prompts"?"saved":"prompts"),searchInputRef:Z}),R==="prompts"?f.jsx(l2,{prompts:le,selectedPrompt:i,onPromptSelect:J,focusedIndex:ae}):f.jsx(u2,{savedPrompts:A,selectedPrompt:c,onLoadPrompt:q,onDeletePrompt:He,focusedIndex:ae})]},"list"),ne==="detail"&&f.jsx(ba.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(d2,{selectedPrompt:i,promptArgs:h,isExecuting:S,isConnected:r,onArgChange:se,onExecute:he,onSave:Te})},"detail"),ne==="response"&&f.jsx(ba.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(f2,{results:v,copiedResult:_,onCopy:ce})},"response")]})})]}):f.jsxs(Qr,{direction:"horizontal",className:"h-full",children:[f.jsx(Rn,{defaultSize:33,className:"flex flex-col h-full relative",children:f.jsxs(Qr,{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(c2,{activeTab:R,isSearchExpanded:ee,searchQuery:k,filteredPromptsCount:le.length,savedPromptsCount:A.length,onSearchExpand:()=>te(!0),onSearchChange:C,onSearchBlur:ie,onTabSwitch:()=>I(R==="prompts"?"saved":"prompts"),searchInputRef:Z}),R==="prompts"?f.jsx(l2,{prompts:le,selectedPrompt:i,onPromptSelect:J,focusedIndex:ae}):f.jsx(u2,{savedPrompts:A,selectedPrompt:c,onLoadPrompt:q,onDeletePrompt:He,focusedIndex:ae})]})}),f.jsx(vi,{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(Le,{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($s,{className:"h-3.5 w-3.5"})})]}),f.jsx(Xl,{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(tD,{serverIds:[a],onCountChange:z,onClearRef:W})})]})]})}),f.jsx(vi,{withHandle:!0}),f.jsx(Rn,{defaultSize:67,children:f.jsxs(Qr,{direction:"vertical",children:[f.jsx(Rn,{defaultSize:40,children:f.jsx(d2,{selectedPrompt:i,promptArgs:h,isExecuting:S,isConnected:r,onArgChange:se,onExecute:he,onSave:Te})}),f.jsx(vi,{withHandle:!0}),f.jsx(Rn,{defaultSize:50,children:f.jsx("div",{className:"flex flex-col h-full",children:f.jsx(f2,{results:v,copiedResult:_,onCopy:ce})})})]})})]})}EZ.displayName="PromptsTab";function xu(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 bke(e){return{uri:e.uri,mimeType:e.mimeType,text:e.text,blob:e.blob}}function _Z({resource:e,onUIAction:t,className:n}){const a=async i=>t?.(i),r=bke(e);return f.jsx("div",{className:n,children:f.jsx(XO,{resource:r,onUIAction:a,htmlProps:{autoResizeIframe:{width:!0,height:!0},style:{width:"100%",minHeight:"200px"},sandboxPermissions:"allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox"},remoteDomProps:{remoteElements:[C_e,N_e,R_e,A_e],library:qO}})})}function vke(e){if("error"in e&&e.error)return e.error;if(!("isError"in e&&e.isError))return null;if("contents"in e&&Array.isArray(e.contents)){const t=e.contents.filter(n=>"text"in n).map(n=>n.text).filter(Boolean);if(t.length>0)return t.join(`
|
|
1660
|
+
`);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"){S+=O.content;const M=y[y.length-1];M&&M.type==="text"?M.text=S:y.push({type:"text",text:S}),console.log("[Parts after text]",y.length,"parts, text length:",S.length),i(U=>U.map(H=>H.id===w?{...H,parts:[...y]}:H))}else if(O.type==="tool-call")S&&(S=""),y.push({type:"tool-invocation",toolInvocation:{toolName:O.toolName,args:O.args,state:"pending"}}),console.log("[Parts after tool-call]",y.length,"parts, tool:",O.toolName),i(M=>M.map(U=>U.id===w?{...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===w?{...H,parts:[...y]}:H))):console.warn("[tool-result] Could not find matching tool part for",O.toolName)}else if(O.type==="done")console.log("[Done] Final parts:",y.length),i(M=>M.map(U=>U.id===w?{...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 S=g;S.status&&(v=`HTTP ${S.status}: ${v}`),(S.code===401||v.includes("401")||v.includes("Unauthorized"))&&(v="Authentication failed (401). Check your Authorization header in the connection settings.")}const w={id:`error-${Date.now()}`,role:"assistant",content:`Error: ${v}`,timestamp:Date.now()};i(S=>[...S,w])}finally{c(!1)}},[t,a,e,r,n]),d=x.useCallback(()=>{i([])},[]);return{messages:r,isLoading:s,sendMessage:u,clearMessages:d}}function L_e({connection:e,llmConfig:t,isConnected:n,readResource:a}){const[r,i]=x.useState([]),[s,c]=x.useState(!1),u=x.useRef(null),d=x.useRef(null),m=x.useRef(null),h=x.useCallback(async v=>{if(!v.trim()||!t||!n)return;const w={id:`user-${Date.now()}`,role:"user",content:v.trim(),timestamp:Date.now()};i(_=>[..._,w]),c(!0),u.current=new AbortController;const S=Date.now();let y=0;try{const _=`assistant-${Date.now()}`;let E="";const k=[];if(i(C=>[...C,{id:_,role:"assistant",content:"",timestamp:Date.now(),parts:[]}]),!m.current||m.current.provider!==t.provider||m.current.model!==t.model||m.current.apiKey!==t.apiKey){let C;if(t.provider==="openai"){const{ChatOpenAI:R}=await Qn(async()=>{const{ChatOpenAI:I}=await import("./index-DPD9iyF6.js");return{ChatOpenAI:I}},__vite__mapDeps([5,6,7,2,8,9]));C=new R({model:t.model,apiKey:t.apiKey})}else if(t.provider==="anthropic"){const{ChatAnthropic:R}=await Qn(async()=>{const{ChatAnthropic:I}=await import("./index-CsvzhAm-.js");return{ChatAnthropic:I}},__vite__mapDeps([10,7,6,2]));C=new R({model:t.model,apiKey:t.apiKey})}else if(t.provider==="google"){const{ChatGoogleGenerativeAI:R}=await Qn(async()=>{const{ChatGoogleGenerativeAI:I}=await import("./index-CSlqw8-V.js");return{ChatGoogleGenerativeAI:I}},__vite__mapDeps([11,7,6,2,9]));C=new R({model:t.model,apiKey:t.apiKey})}else throw new Error(`Unsupported LLM provider: ${t.provider}`);m.current={instance:C,provider:t.provider,model:t.model,apiKey:t.apiKey}}if(!d.current||d.current.llm!==m.current.instance){const{MCPAgent:C}=await Qn(async()=>{const{MCPAgent:R}=await import("./browser-BoLKWpwz.js").then(I=>I.b);return{MCPAgent:R}},__vite__mapDeps([12,8,6,7,2,3,4,9]));d.current=new C({llm:m.current.instance,client:e.client,memoryEnabled:!0,systemPrompt:"You are a helpful assistant with access to MCP tools, prompts, and resources. Help users interact with the MCP server."}),await d.current.initialize()}else console.log("[useChatMessagesClientSide] Reusing existing agent. History length:",d.current.conversationHistory?.length);for await(const C of d.current.streamEvents(v,10,!1,void 0)){if(u.current?.signal.aborted)break;if(C.event==="on_chat_model_stream"&&C.data?.chunk?.text){const R=C.data.chunk.text;if(typeof R=="string"&&R.length>0){E+=R;const 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(C.event==="on_tool_start"){E&&(E="");let R={};C.data?.input?R=C.data.input:C.data?.tool_input?R=C.data.tool_input:C.data&&(R=C.data),console.log("[useChatMessagesClientSide] on_tool_start:",{toolName:C.name,eventData:C.data,extractedArgs:R}),y++,k.push({type:"tool-invocation",toolInvocation:{toolName:C.name||"unknown",args:R,state:"pending"}}),i(I=>I.map(A=>A.id===_?{...A,parts:[...k]}:A))}else if(C.event==="on_tool_end"){const R=k.find(I=>I.type==="tool-invocation"&&I.toolInvocation?.toolName===C.name&&!I.toolInvocation?.result);if(console.log("[useChatMessagesClientSide] on_tool_end event:",{toolName:C.name,hasToolPart:!!R,output:C.data?.output}),R&&R.toolInvocation){let I=C.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}R.toolInvocation.result=I,R.toolInvocation.state="result";const A=I?._meta?.["openai/outputTemplate"];if(console.log("[useChatMessagesClientSide] Tool result:",{toolName:C.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};R.toolInvocation.result=H,console.log("[useChatMessagesClientSide] Updated result with resources")}else console.warn("[useChatMessagesClientSide] No contents in resourceData:",O)}catch(O){console.error("Failed to fetch Apps SDK resource:",O)}}i(O=>O.map(M=>M.id===_?{...M,parts:[...k]}:M))}}}i(C=>C.map(R=>R.id===_?{...R,parts:[...k],content:""}:R)),t&&yr.getInstance().capture(new CU({serverId:e.url,provider:t.provider,model:t.model,messageCount:r.length+1,toolCallsCount:y,success:!0,executionMode:"client-side",duration:Date.now()-S})).catch(()=>{})}catch(_){console.error("Client-side agent error:",_);let E="Unknown error occurred";if(_ instanceof Error){E=_.message;const C=_;C.status&&(E=`HTTP ${C.status}: ${E}`),(C.code===401||E.includes("401")||E.includes("Unauthorized"))&&(E="Authentication failed (401). Check your Authorization header in the connection settings.")}t&&yr.getInstance().capture(new CU({serverId:e.url,provider:t.provider,model:t.model,messageCount:r.length+1,toolCallsCount:y,success:!1,executionMode:"client-side",duration:Date.now()-S,error:E})).catch(()=>{});const k={id:`error-${Date.now()}`,role:"assistant",content:`Error: ${E}`,timestamp:Date.now()};i(C=>[...C,k])}finally{c(!1),u.current=null}},[e,t,n,r,a]),g=x.useCallback(()=>{i([]),d.current&&d.current.clearConversationHistory()},[]);return{messages:r,isLoading:s,sendMessage:h,clearMessages:g}}const Q4={openai:"gpt-4o",anthropic:"claude-haiku-4-5-20251001",google:"gemini-2.5-flash"};function eZ({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(Q4.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{}},[]),w=x.useCallback(M=>{localStorage.setItem("mcp-inspector-api-keys",JSON.stringify(M))},[]),[S,y]=x.useState("none"),[_,E]=x.useState(""),[k,C]=x.useState(""),[R,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&&C(U.password),U.token&&I(U.token)}catch(U){console.error("Failed to load auth config:",U)}else try{const U="mcp:auth",H=QK(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(Q4[c]);const M=v();m(M[c]||"")},[c,v]);const A=x.useCallback(()=>{if(!d.trim())return;const M=v();M[c]=d,w(M);const U={provider:c,apiKey:d,model:h},H={type:S,...S==="basic"&&{username:_.trim(),password:k.trim()},...S==="bearer"&&{token:R.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,S,_,k,R,v,w]),O=x.useCallback(()=>{n(null),r(null);const M=v();delete M[c],w(M),m(""),E(""),C(""),I(""),y("none"),localStorage.removeItem("mcp-inspector-llm-config"),localStorage.removeItem("mcp-inspector-auth-config")},[c,v,w]);return{llmConfig:t,authConfig:a,configDialogOpen:i,setConfigDialogOpen:s,tempProvider:c,setTempProvider:u,tempApiKey:d,setTempApiKey:m,tempModel:h,setTempModel:g,tempAuthType:S,saveLLMConfig:A,clearConfig:O}}function $_e({connection:e,isConnected:t,useClientSide:n=!0,readResource:a}){const[r,i]=x.useState(""),s=x.useRef(null),{llmConfig:c,authConfig:u,configDialogOpen:d,setConfigDialogOpen:m,tempProvider:h,setTempProvider:g,tempApiKey:v,setTempApiKey:w,tempModel:S,setTempModel:y,saveLLMConfig:_,clearConfig:E}=eZ({mcpServerUrl:e.url}),k={connection:e,llmConfig:c,isConnected:t,readResource:a},C=j_e({mcpServerUrl:e.url,llmConfig:c,authConfig:u,isConnected:t}),R=L_e(k),{messages:I,isLoading:A,sendMessage:O,clearMessages:M}=n?R:C;JW({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(i_,{open:d,onOpenChange:m,tempProvider:h,tempModel:S,tempApiKey:v,onProviderChange:g,onModelChange:y,onApiKeyChange:w,onSave:_,onClear:K,showClearButton:!0,buttonLabel:"Change API Key"})}),f.jsx(Y0e,{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(W0e,{llmConfig:c,hasMessages:I.length>0,configDialogOpen:d,onConfigDialogOpenChange:m,onClearChat:M,tempProvider:h,tempModel:S,tempApiKey:v,onProviderChange:g,onModelChange:y,onApiKeyChange:w,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(D_e,{messages:I,isLoading:A,serverId:e.url,readResource:a,tools:e.tools}):f.jsx(q0e,{onConfigureClick:()=>m(!0)})}),c&&f.jsx(K0e,{inputValue:r,isConnected:t,isLoading:A,textareaRef:s,onInputChange:i,onKeyDown:H,onSendMessage:U})]})}const nw=x.createContext(null);nw.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"},JO=10,Ol=x.useLayoutEffect,e2=ud.useId,M_e=typeof e2=="function"?e2:()=>null;let P_e=0;function QO(e=null){const t=M_e(),n=x.useRef(e||t||null);return n.current===null&&(n.current=""+P_e++),e??n.current}function tZ({children:e,className:t="",collapsedSize:n,collapsible:a,defaultSize:r,forwardedRef:i,id:s,maxSize:c,minSize:u,onCollapse:d,onExpand:m,onResize:h,order:g,style:v,tagName:w="div",...S}){const y=x.useContext(nw);if(y===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:_,expandPanel:E,getPanelSize:k,getPanelStyle:C,groupId:R,isPanelCollapsed:I,reevaluatePanelConstraints:A,registerPanel:O,resizePanel:M,unregisterPanel:U}=y,H=QO(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}),Ol(()=>{const{callbacks:te,constraints:ae}=K.current,B={...ae};K.current.id=H,K.current.idIsFromProps=s!==void 0,K.current.order=g,te.onCollapse=d,te.onExpand=m,te.onResize=h,ae.collapsedSize=n,ae.collapsible=a,ae.defaultSize=r,ae.maxSize=c,ae.minSize=u,(B.collapsedSize!==ae.collapsedSize||B.collapsible!==ae.collapsible||B.maxSize!==ae.maxSize||B.minSize!==ae.minSize)&&A(K.current,B)}),Ol(()=>{const te=K.current;return O(te),()=>{U(te)}},[g,H,O,U]),x.useImperativeHandle(i,()=>({collapse:()=>{_(K.current)},expand:te=>{E(K.current,te)},getId(){return H},getSize(){return k(K.current)},isCollapsed(){return I(K.current)},isExpanded(){return!I(K.current)},resize:te=>{M(K.current,te)}}),[_,E,k,I,H,M]);const ee=C(K.current,r);return x.createElement(w,{...S,children:e,className:t,id:H,style:{...ee,...v},[Wn.groupId]:R,[Wn.panel]:"",[Wn.panelCollapsible]:a||void 0,[Wn.panelId]:H,[Wn.panelSize]:parseFloat(""+ee.flexGrow).toFixed(1)})}const nZ=x.forwardRef((e,t)=>x.createElement(tZ,{...e,forwardedRef:t}));tZ.displayName="Panel";nZ.displayName="forwardRef(Panel)";let j_=null,Cb=-1,Ns=null;function U_e(e,t,n){const a=(t&sZ)!==0,r=(t&lZ)!==0,i=(t&cZ)!==0,s=(t&uZ)!==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 z_e(){Ns!==null&&(document.head.removeChild(Ns),j_=null,Ns=null,Cb=-1)}function AS(e,t,n){var a,r;const i=U_e(e,t);if(j_!==i){if(j_=i,Ns===null&&(Ns=document.createElement("style"),document.head.appendChild(Ns)),Cb>=0){var s;(s=Ns.sheet)===null||s===void 0||s.removeRule(Cb)}Cb=(a=(r=Ns.sheet)===null||r===void 0?void 0:r.insertRule(`*{cursor: ${i} !important;}`))!==null&&a!==void 0?a:-1}}function rZ(e){return e.type==="keydown"}function aZ(e){return e.type.startsWith("pointer")}function iZ(e){return e.type.startsWith("mouse")}function rw(e){if(aZ(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(iZ(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}function F_e(){if(typeof matchMedia=="function")return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}function B_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 H_e(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:r2(e),b:r2(t)};let a;for(;n.a.at(-1)===n.b.at(-1);)e=n.a.pop(),t=n.b.pop(),a=e;Nt(a,"Stacking order can only be calculated for elements with a common ancestor");const r={a:n2(t2(n.a)),b:n2(t2(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 V_e=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function G_e(e){var t;const n=getComputedStyle((t=oZ(e))!==null&&t!==void 0?t:e).display;return n==="flex"||n==="inline-flex"}function W_e(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||G_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"||V_e.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function t2(e){let t=e.length;for(;t--;){const n=e[t];if(Nt(n,"Missing node"),W_e(n))return n}return null}function n2(e){return e&&Number(getComputedStyle(e).zIndex)||0}function r2(e){const t=[];for(;e;)t.push(e),e=oZ(e);return t}function oZ(e){const{parentNode:t}=e;return t&&t instanceof ShadowRoot?t.host:t}const sZ=1,lZ=2,cZ=4,uZ=8,K_e=F_e()==="coarse";let bi=[],wu=!1,Cs=new Map,aw=new Map;const Bp=new Set;function Z_e(e,t,n,a,r){var i;const{ownerDocument:s}=t,c={direction:n,element:t,hitAreaMargins:a,setResizeHandlerState:r},u=(i=Cs.get(s))!==null&&i!==void 0?i:0;return Cs.set(s,u+1),Bp.add(c),Dv(),function(){var m;aw.delete(e),Bp.delete(c);const h=(m=Cs.get(s))!==null&&m!==void 0?m:1;if(Cs.set(s,h-1),Dv(),h===1&&Cs.delete(s),bi.includes(c)){const g=bi.indexOf(c);g>=0&&bi.splice(g,1),iw(),r("up",!0,null)}}}function Y_e(e){const{target:t}=e,{x:n,y:a}=rw(e);wu=!0,eD({target:t,x:n,y:a}),Dv(),bi.length>0&&(jv("down",e),iw(),e.preventDefault(),dZ(t)||e.stopImmediatePropagation())}function IS(e){const{x:t,y:n}=rw(e);if(wu&&e.type!=="pointerleave"&&e.buttons===0&&(wu=!1,jv("up",e)),!wu){const{target:a}=e;eD({target:a,x:t,y:n})}jv("move",e),iw(),bi.length>0&&e.preventDefault()}function OS(e){const{target:t}=e,{x:n,y:a}=rw(e);aw.clear(),wu=!1,bi.length>0&&(e.preventDefault(),dZ(t)||e.stopImmediatePropagation()),jv("up",e),eD({target:t,x:n,y:a}),iw(),Dv()}function dZ(e){let t=e;for(;t;){if(t.hasAttribute(Wn.resizeHandle))return!0;t=t.parentElement}return!1}function eD({target:e,x:t,y:n}){bi.splice(0);let a=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(a=e),Bp.forEach(r=>{const{element:i,hitAreaMargins:s}=r,c=i.getBoundingClientRect(),{bottom:u,left:d,right:m,top:h}=c,g=K_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)&&H_e(a,i)>0){let w=a,S=!1;for(;w&&!w.contains(i);){if(B_e(w.getBoundingClientRect(),c)){S=!0;break}w=w.parentElement}if(S)return}bi.push(r)}})}function DS(e,t){aw.set(e,t)}function iw(){let e=!1,t=!1;bi.forEach(a=>{const{direction:r}=a;r==="horizontal"?e=!0:t=!0});let n=0;aw.forEach(a=>{n|=a}),e&&t?AS("intersection",n):e?AS("horizontal",n):t?AS("vertical",n):z_e()}let jS;function Dv(){var e;(e=jS)===null||e===void 0||e.abort(),jS=new AbortController;const t={capture:!0,signal:jS.signal};Bp.size&&(wu?(bi.length>0&&Cs.forEach((n,a)=>{const{body:r}=a;n>0&&(r.addEventListener("contextmenu",OS,t),r.addEventListener("pointerleave",IS,t),r.addEventListener("pointermove",IS,t))}),Cs.forEach((n,a)=>{const{body:r}=a;r.addEventListener("pointerup",OS,t),r.addEventListener("pointercancel",OS,t)})):Cs.forEach((n,a)=>{const{body:r}=a;n>0&&(r.addEventListener("pointerdown",Y_e,t),r.addEventListener("pointermove",IS,t))}))}function jv(e,t){Bp.forEach(n=>{const{setResizeHandlerState:a}=n,r=bi.includes(n);a(e,r,t)})}function q_e(){const[e,t]=x.useState(0);return x.useCallback(()=>t(n=>n+1),[])}function Nt(e,t){if(!e)throw console.error(t),Error(t)}function Wl(e,t,n=JO){return e.toFixed(n)===t.toFixed(n)?0:e>t?1:-1}function Eo(e,t,n=JO){return Wl(e,t,n)===0}function Ia(e,t,n){return Wl(e,t,n)===0}function X_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 fu({panelConstraints:e,panelIndex:t,size:n}){const a=e[t];Nt(a!=null,`Panel constraints not found for index ${t}`);let{collapsedSize:r=0,collapsible:i,maxSize:s=100,minSize:c=0}=a;if(Wl(n,c)<0)if(i){const u=(r+c)/2;Wl(n,u)<0?n=r:n=c}else n=c;return n=Math.min(s,n),n=parseFloat(n.toFixed(JO)),n}function Zf({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:a,prevLayout:r,trigger:i}){if(Ia(e,0))return t;const s=[...t],[c,u]=a;Nt(c!=null,"Invalid first pivot index"),Nt(u!=null,"Invalid second pivot index");let d=0;if(i==="keyboard"){{const h=e<0?u:c,g=n[h];Nt(g,`Panel constraints not found for index ${h}`);const{collapsedSize:v=0,collapsible:w,minSize:S=0}=g;if(w){const y=t[h];if(Nt(y!=null,`Previous layout not found for panel index ${h}`),Ia(y,v)){const _=S-y;Wl(_,Math.abs(e))>0&&(e=e<0?0-_:_)}}}{const h=e<0?c:u,g=n[h];Nt(g,`No panel constraints found for index ${h}`);const{collapsedSize:v=0,collapsible:w,minSize:S=0}=g;if(w){const y=t[h];if(Nt(y!=null,`Previous layout not found for panel index ${h}`),Ia(y,S)){const _=y-v;Wl(_,Math.abs(e))>0&&(e=e<0?0-_:_)}}}}{const h=e<0?1:-1;let g=e<0?u:c,v=0;for(;;){const S=t[g];Nt(S!=null,`Previous layout not found for panel index ${g}`);const _=fu({panelConstraints:n,panelIndex:g,size:100})-S;if(v+=_,g+=h,g<0||g>=n.length)break}const w=Math.min(Math.abs(e),Math.abs(v));e=e<0?0-w:w}{let g=e<0?c:u;for(;g>=0&&g<n.length;){const v=Math.abs(e)-Math.abs(d),w=t[g];Nt(w!=null,`Previous layout not found for panel index ${g}`);const S=w-v,y=fu({panelConstraints:n,panelIndex:g,size:S});if(!Ia(w,y)&&(d+=w-y,s[g]=y,d.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?g--:g++}}if(X_e(r,s))return r;{const h=e<0?u:c,g=t[h];Nt(g!=null,`Previous layout not found for panel index ${h}`);const v=g+d,w=fu({panelConstraints:n,panelIndex:h,size:v});if(s[h]=w,!Ia(w,v)){let S=v-w,_=e<0?u:c;for(;_>=0&&_<n.length;){const E=s[_];Nt(E!=null,`Previous layout not found for panel index ${_}`);const k=E+S,C=fu({panelConstraints:n,panelIndex:_,size:k});if(Ia(E,C)||(S-=C-E,s[_]=C),Ia(S,0))break;e>0?_--:_++}}}const m=s.reduce((h,g)=>g+h,0);return Ia(m,100)?s:r}function J_e({layout:e,panelsArray:t,pivotIndices:n}){let a=0,r=100,i=0,s=0;const c=n[0];Nt(c!=null,"No pivot index found"),t.forEach((h,g)=>{const{constraints:v}=h,{maxSize:w=100,minSize:S=0}=v;g===c?(a=S,r=w):(i+=S,s+=w)});const u=Math.min(r,100-i),d=Math.max(a,100-s),m=e[c];return{valueMax:u,valueMin:d,valueNow:m}}function Hp(e,t=document){return Array.from(t.querySelectorAll(`[${Wn.resizeHandleId}][data-panel-group-id="${e}"]`))}function fZ(e,t,n=document){const r=Hp(e,n).findIndex(i=>i.getAttribute(Wn.resizeHandleId)===t);return r??null}function pZ(e,t,n){const a=fZ(e,t,n);return a!=null?[a,a+1]:[-1,-1]}function Q_e(e){return e instanceof HTMLElement?!0:typeof e=="object"&&e!==null&&"tagName"in e&&"getAttribute"in e}function mZ(e,t=document){if(Q_e(t)&&t.dataset.panelGroupId==e)return t;const n=t.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return n||null}function ow(e,t=document){const n=t.querySelector(`[${Wn.resizeHandleId}="${e}"]`);return n||null}function eke(e,t,n,a=document){var r,i,s,c;const u=ow(t,a),d=Hp(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 tke({committedValuesRef:e,eagerValuesRef:t,groupId:n,layout:a,panelDataArray:r,panelGroupElement:i,setLayout:s}){x.useRef({didWarnAboutMissingResizeHandle:!1}),Ol(()=>{if(!i)return;const c=Hp(n,i);for(let u=0;u<r.length-1;u++){const{valueMax:d,valueMin:m,valueNow:h}=J_e({layout:a,panelsArray:r,pivotIndices:[u,u+1]}),g=c[u];if(g!=null){const v=r[u];Nt(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;Nt(c,"Eager values not found");const{panelDataArray:u}=c,d=mZ(n,i);Nt(d!=null,`No group found for id "${n}"`);const m=Hp(n,i);Nt(m,`No resize handles found for group id "${n}"`);const h=m.map(g=>{const v=g.getAttribute(Wn.resizeHandleId);Nt(v,"Resize handle element has no handle id attribute");const[w,S]=eke(n,v,u,i);if(w==null||S==null)return()=>{};const y=_=>{if(!_.defaultPrevented)switch(_.key){case"Enter":{_.preventDefault();const E=u.findIndex(k=>k.id===w);if(E>=0){const k=u[E];Nt(k,`No panel data found for index ${E}`);const C=a[E],{collapsedSize:R=0,collapsible:I,minSize:A=0}=k.constraints;if(C!=null&&I){const O=Zf({delta:Ia(C,R)?A-R:R-C,initialLayout:a,panelConstraints:u.map(M=>M.constraints),pivotIndices:pZ(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 a2(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 hZ(e,t){const n=e==="horizontal",{x:a,y:r}=rw(t);return n?a:r}function nke(e,t,n,a,r){const i=n==="horizontal",s=ow(t,r);Nt(s,`No resize handle element found for id "${t}"`);const c=s.getAttribute(Wn.groupId);Nt(c,"Resize handle element has no group id attribute");let{initialCursorPosition:u}=a;const d=hZ(n,e),m=mZ(c,r);Nt(m,`No group element found for id "${c}"`);const h=m.getBoundingClientRect(),g=i?h.width:h.height;return(d-u)/g*100}function rke(e,t,n,a,r,i){if(rZ(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:nke(e,t,n,a,i)}function ake({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];Nt(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];Nt(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 Vc(e,t,n){t.forEach((a,r)=>{const i=e[r];Nt(i,`Panel data not found for index ${r}`);const{callbacks:s,constraints:c,id:u}=i,{collapsedSize:d=0,collapsible:m}=c,h=n[u];if(h==null||a!==h){n[u]=a;const{onCollapse:g,onExpand:v,onResize:w}=s;w&&w(a,h),m&&(g||v)&&(v&&(h==null||Eo(h,d))&&!Eo(a,d)&&v(),g&&(h==null||!Eo(h,d))&&Eo(a,d)&&g())}})}function rb(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 ike({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 oke(e,t=10){let n=null;return(...r)=>{n!==null&&clearTimeout(n),n=setTimeout(()=>{e(...r)},t)}}function i2(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 gZ(e){return`react-resizable-panels:${e}`}function bZ(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 vZ(e,t){try{const n=gZ(e),a=t.getItem(n);if(a){const r=JSON.parse(a);if(typeof r=="object"&&r!=null)return r}}catch{}return null}function ske(e,t,n){var a,r;const i=(a=vZ(e,n))!==null&&a!==void 0?a:{},s=bZ(t);return(r=i[s])!==null&&r!==void 0?r:null}function lke(e,t,n,a,r){var i;const s=gZ(e),c=bZ(t),u=(i=vZ(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 o2({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];Nt(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];Nt(s!=null,`No layout data found for index ${i}`);const c=fu({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];Nt(s!=null,`No layout data found for index ${i}`);const c=s+r,u=fu({panelConstraints:t,panelIndex:i,size:c});if(s!==u&&(r-=u-s,n[i]=u,Ia(r,0)))break}return n}const cke=100,Yf={getItem:e=>(i2(Yf),Yf.getItem(e)),setItem:(e,t)=>{i2(Yf),Yf.setItem(e,t)}},s2={};function yZ({autoSaveId:e=null,children:t,className:n="",direction:a,forwardedRef:r,id:i=null,onLayout:s=null,keyboardResizeBy:c=null,storage:u=Yf,style:d,tagName:m="div",...h}){const g=QO(i),v=x.useRef(null),[w,S]=x.useState(null),[y,_]=x.useState([]),E=q_e(),k=x.useRef({}),C=x.useRef(new Map),R=x.useRef(0),I=x.useRef({autoSaveId:e,direction:a,dragState:w,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=o2({layout:z,panelConstraints:F.map(X=>X.constraints)});a2($,W)||(_(W),A.current.layout=W,L&&L(W),Vc(F,W,k.current))}}),[]),Ol(()=>{I.current.autoSaveId=e,I.current.direction=a,I.current.dragState=w,I.current.id=g,I.current.onLayout=s,I.current.storage=u}),tke({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=s2[e];L==null&&(L=oke(lke,cke),s2[e]=L);const $=[...z],F=new Map(C.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(J=>J.constraints),{collapsedSize:X=0,panelSize:ie,pivotIndices:le}=vl(F,z,$);if(Nt(ie!=null,`Panel size not found for panel "${z.id}"`),!Eo(ie,X)){C.current.set(z.id,ie);const q=eu(F,z)===F.length-1?ie-X:X-ie,se=Zf({delta:q,initialLayout:$,panelConstraints:W,pivotIndices:le,prevLayout:$,trigger:"imperative-api"});rb($,se)||(_(se),A.current.layout=se,L&&L(se),Vc(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:ie=0,panelSize:le=0,minSize:J=0,pivotIndices:q}=vl(W,z,F),se=L??J;if(Eo(le,ie)){const he=C.current.get(z.id),ce=he!=null&&he>=se?he:se,He=eu(W,z)===W.length-1?le-ce:ce-le,Se=Zf({delta:He,initialLayout:F,panelConstraints:X,pivotIndices:q,prevLayout:F,trigger:"imperative-api"});rb(F,Se)||(_(Se),A.current.layout=Se,$&&$(Se),Vc(W,Se,k.current))}}},[]),U=x.useCallback(z=>{const{layout:L,panelDataArray:$}=A.current,{panelSize:F}=vl($,z,L);return Nt(F!=null,`Panel size not found for panel "${z.id}"`),F},[]),H=x.useCallback((z,L)=>{const{panelDataArray:$}=A.current,F=eu($,z);return ike({defaultSize:L,dragState:w,layout:y,panelData:$,panelIndex:F})},[w,y]),K=x.useCallback(z=>{const{layout:L,panelDataArray:$}=A.current,{collapsedSize:F=0,collapsible:W,panelSize:X}=vl($,z,L);return Nt(X!=null,`Panel size not found for panel "${z.id}"`),W===!0&&Eo(X,F)},[]),ee=x.useCallback(z=>{const{layout:L,panelDataArray:$}=A.current,{collapsedSize:F=0,collapsible:W,panelSize:X}=vl($,z,L);return Nt(X!=null,`Panel size not found for panel "${z.id}"`),!W||Wl(X,F)>0},[]),te=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]);Ol(()=>{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=ske(z,W,$);le&&(C.current=new Map(Object.entries(le.expandToSizes)),X=le.layout)}X==null&&(X=ake({panelDataArray:W}));const ie=o2({layout:X,panelConstraints:W.map(le=>le.constraints)});a2(F,ie)||(_(ie),A.current.layout=ie,L&&L(ie),Vc(W,ie,k.current))}}),Ol(()=>{const z=A.current;return()=>{z.layout=[]}},[]);const ae=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:ie,dragState:le,id:J,keyboardResizeBy:q,onLayout:se}=I.current,{layout:he,panelDataArray:ce}=A.current,{initialLayout:Te}=le??{},He=pZ(J,z,X);let Se=rke(W,z,ie,le,q,X);const _e=ie==="horizontal";_e&&L&&(Se=-Se);const Ue=ce.map(Be=>Be.constraints),fe=Zf({delta:Se,initialLayout:Te??he,panelConstraints:Ue,pivotIndices:He,prevLayout:he,trigger:rZ(W)?"keyboard":"mouse-or-touch"}),Oe=!rb(he,fe);(aZ(W)||iZ(W))&&R.current!=Se&&(R.current=Se,!Oe&&Se!==0?_e?DS(z,Se<0?sZ:lZ):DS(z,Se<0?cZ:uZ):DS(z,0)),Oe&&(_(fe),A.current.layout=fe,se&&se(fe),Vc(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:ie,pivotIndices:le}=vl(W,z,F);Nt(ie!=null,`Panel size not found for panel "${z.id}"`);const q=eu(W,z)===W.length-1?ie-L:L-ie,se=Zf({delta:q,initialLayout:F,panelConstraints:X,pivotIndices:le,prevLayout:F,trigger:"imperative-api"});rb(F,se)||(_(se),A.current.layout=se,$&&$(se),Vc(W,se,k.current))},[]),Z=x.useCallback((z,L)=>{const{layout:$,panelDataArray:F}=A.current,{collapsedSize:W=0,collapsible:X}=L,{collapsedSize:ie=0,collapsible:le,maxSize:J=100,minSize:q=0}=z.constraints,{panelSize:se}=vl(F,z,$);se!=null&&(X&&le&&Eo(se,W)?Eo(W,ie)||B(z,ie):se<q?B(z,q):se>J&&B(z,J))},[B]),G=x.useCallback((z,L)=>{const{direction:$}=I.current,{layout:F}=A.current;if(!v.current)return;const W=ow(z,v.current);Nt(W,`Drag handle element not found for id "${z}"`);const X=hZ($,L);S({dragHandleId:z,dragHandleRect:W.getBoundingClientRect(),initialCursorPosition:X,initialLayout:F})},[]),re=x.useCallback(()=>{S(null)},[]),ne=x.useCallback(z=>{const{panelDataArray:L}=A.current,$=eu(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:w,expandPanel:M,getPanelSize:U,getPanelStyle:H,groupId:g,isPanelCollapsed:K,isPanelExpanded:ee,reevaluatePanelConstraints:Z,registerPanel:te,registerResizeHandle:ae,resizePanel:B,startDragging:G,stopDragging:re,unregisterPanel:ne,panelGroupElement:v.current}),[O,w,a,M,U,H,g,K,ee,Z,te,ae,B,G,re,ne]),V={display:"flex",flexDirection:a==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return x.createElement(nw.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 wZ=x.forwardRef((e,t)=>x.createElement(yZ,{...e,forwardedRef:t}));yZ.displayName="PanelGroup";wZ.displayName="forwardRef(PanelGroup)";function eu(e,t){return e.findIndex(n=>n===t||n.id===t.id)}function vl(e,t,n){const a=eu(e,t),i=a===e.length-1?[a-1,a]:[a,a+1],s=n[a];return{...t.constraints,panelSize:s,pivotIndices:i}}function uke({disabled:e,handleId:t,resizeHandler:n,panelGroupElement:a}){x.useEffect(()=>{if(e||n==null||a==null)return;const r=ow(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);Nt(c,`No group element found for id "${c}"`);const u=Hp(c,a),d=fZ(c,t,a);Nt(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 xZ({children:e=null,className:t="",disabled:n=!1,hitAreaMargins:a,id:r,onBlur:i,onClick:s,onDragging:c,onFocus:u,onPointerDown:d,onPointerUp:m,style:h={},tabIndex:g=0,tagName:v="div",...w}){var S,y;const _=x.useRef(null),E=x.useRef({onClick:s,onDragging:c,onPointerDown:d,onPointerUp:m});x.useEffect(()=>{E.current.onClick=s,E.current.onDragging=c,E.current.onPointerDown=d,E.current.onPointerUp=m});const k=x.useContext(nw);if(k===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:C,groupId:R,registerResizeHandle:I,startDragging:A,stopDragging:O,panelGroupElement:M}=k,U=QO(r),[H,K]=x.useState("inactive"),[ee,te]=x.useState(!1),[ae,B]=x.useState(null),Z=x.useRef({state:H});Ol(()=>{Z.current.state=H}),x.useEffect(()=>{if(n)B(null);else{const j=I(U);B(()=>j)}},[n,U,I]);const G=(S=a?.coarse)!==null&&S!==void 0?S:15,re=(y=a?.fine)!==null&&y!==void 0?y:5;x.useEffect(()=>{if(n||ae==null)return;const j=_.current;Nt(j,"Element ref not attached");let V=!1;return Z_e(U,j,C,{coarse:G,fine:re},(L,$,F)=>{if(!$){K("inactive");return}switch(L){case"down":{K("drag"),V=!1,Nt(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"),Nt(F,'Expected event to be defined for "move" action'),ae(F);break}case"up":{K("hover"),O();const{onClick:W,onDragging:X,onPointerUp:ie}=E.current;X?.(!1),ie?.(),V||W?.();break}}})},[G,C,n,re,I,U,ae,A,O]),uke({disabled:n,handleId:U,resizeHandler:ae,panelGroupElement:M});const ne={touchAction:"none",userSelect:"none"};return x.createElement(v,{...w,children:e,className:t,id:r,onBlur:()=>{te(!1),i?.()},onFocus:()=>{te(!0),u?.()},ref:_,role:"separator",style:{...ne,...h},tabIndex:g,[Wn.groupDirection]:C,[Wn.groupId]:R,[Wn.resizeHandle]:"",[Wn.resizeHandleActive]:H==="drag"?"pointer":ee?"keyboard":void 0,[Wn.resizeHandleEnabled]:!n,[Wn.resizeHandleId]:U,[Wn.resizeHandleState]:H})}xZ.displayName="PanelResizeHandle";function Qr({className:e,...t}){return f.jsx(wZ,{"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(nZ,{"data-slot":"resizable-panel",...e})}function vi({withHandle:e,className:t,...n}){return f.jsx(xZ,{"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(Jpe,{className:"size-2.5"})})})}function jm({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 dke({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(Dt,{children:[f.jsx(jt,{asChild:!0,children:f.jsx(Le,{variant:"ghost",size:"sm",onClick:r,className:"h-8 w-8 p-0",children:f.jsx(Ed,{className:"h-4 w-4"})})}),f.jsxs(Lt,{side:"bottom",className:"flex gap-2",children:["Search",f.jsx(jm,{children:"F"})]})]})]})}),f.jsx("div",{className:"flex items-center gap-2",children:f.jsxs(Dt,{children:[f.jsx(jt,{asChild:!0,children:f.jsx(Le,{variant:"ghost",size:"sm",onClick:c,disabled:a===0,className:"h-8 w-8 p-0",children:f.jsx($s,{className:"h-4 w-4"})})}),f.jsx(Lt,{side:"bottom",children:"Clear all"})]})})]})}function Zs({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 fke({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(Sd,{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(Zs,{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 pke({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(Qu,{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(Le,{variant:"ghost",size:"sm",onClick:n,className:t?"":"text-purple-600 dark:text-purple-400",children:[t?f.jsx(NN,{className:"h-4 w-4 mr-1"}):f.jsx(m8,{className:"h-4 w-4 mr-1"}),t?"JSON":"Formatted"]}),f.jsx(Le,{variant:"ghost",size:"sm",onClick:a,children:s?f.jsx(ta,{className:"h-4 w-4"}):f.jsx(jr,{className:"h-4 w-4"})}),f.jsx(Le,{variant:"ghost",size:"sm",onClick:r,children:f.jsx(bm,{className:"h-4 w-4"})}),f.jsx(Le,{variant:"ghost",size:"sm",onClick:i,children:f.jsx(AN,{className:"h-4 w-4"})}),c&&f.jsx(Le,{variant:"ghost",size:"sm",onClick:c,children:f.jsx(Yi,{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(kN,{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 Lv(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 mke({notifications:e,unreadCount:t,markNotificationRead:n,markAllNotificationsRead:a,clearNotifications:r,serverId:i,isConnected:s}){const[c,u]=x.useState(null),[d,m]=x.useState(""),[h,g]=x.useState(-1),[v,w]=x.useState(!0),[S,y]=x.useState(!1),[_,E]=x.useState(!0),[k,C]=x.useState(!1),R=x.useRef(null),I=x.useRef(null),A=x.useRef(null),O=x.useRef(!1);x.useEffect(()=>{v&&e.length>0&&R.current&&!O.current&&(R.current.scrollTop=0)},[e.length,v]),x.useEffect(()=>{const Z=R.current;if(!Z)return;const G=()=>{Z.scrollTop>0&&(O.current=!0,w(!1))};return Z.addEventListener("scroll",G),()=>Z.removeEventListener("scroll",G)},[]),x.useEffect(()=>{e.length===0&&(O.current=!1,w(!0))},[e.length]),x.useEffect(()=>{c&&!c.read&&n(c.id)},[c,n]),x.useEffect(()=>{S&&A.current&&A.current.focus()},[S]);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)),C(!0),setTimeout(()=>C(!1),2e3)}catch(Z){console.error("[NotificationsTab] Failed to copy notification:",Z)}},[c]),te=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]),ae=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:Lv}:null;return s?f.jsxs(Qr,{direction:"horizontal",className:"h-full",children:[f.jsx(Rn,{defaultSize:40,minSize:30,children:f.jsx(Qr,{direction:"vertical",className:"h-full border-r dark:border-zinc-700",children:f.jsxs(Rn,{defaultSize:75,minSize:30,children:[f.jsx(dke,{isSearchExpanded:S,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(fke,{notifications:U,selectedNotification:c,onNotificationSelect:H,focusedIndex:h,formatRelativeTime:Lv,listRef:R})})]})})}),f.jsx(vi,{}),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(pke,{notification:B,previewMode:_,onTogglePreview:()=>E(!_),onCopy:ee,onDownload:te,onFullscreen:ae,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(kN,{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 SZ({activeTab:e,isSearchExpanded:t,searchQuery:n,primaryTabTitle:a,secondaryTabTitle:r,primaryCount:i,secondaryCount:s,secondaryIcon:c,primaryIcon:u,searchPlaceholder:d="Search...",onSearchExpand:m,onSearchChange:h,onSearchBlur:g,onTabSwitch:v,searchInputRef:w,primaryTabName:S}){const y=e===S;return 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:w,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(Dt,{children:[f.jsx(jt,{asChild:!0,children:f.jsx(Le,{variant:"ghost",size:"sm",onClick:m,className:"h-8 w-8 p-0",children:f.jsx(Ed,{className:"h-4 w-4"})})}),f.jsxs(Lt,{side:"bottom",className:"flex gap-2",children:["Search",f.jsx(jm,{children:"F"})]})]})]})]})}),f.jsxs(Le,{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 l2({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(Tp,{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(Zs,{id:`prompt-${r.name}`,isSelected:t?.name===r.name,isFocused:a===i,icon:f.jsx(Tp,{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 c2({activeTab:e,isSearchExpanded:t,searchQuery:n,filteredPromptsCount:a,savedPromptsCount:r,onSearchExpand:i,onSearchChange:s,onSearchBlur:c,onTabSwitch:u,searchInputRef:d}){return f.jsx(SZ,{activeTab:e,isSearchExpanded:t,searchQuery:n,primaryTabName:"prompts",secondaryTabName:"saved",primaryTabTitle:"Prompts",secondaryTabTitle:"History",primaryCount:a,secondaryCount:r,primaryIcon:Tp,secondaryIcon:Qu,searchPlaceholder:"Search prompts...",onSearchExpand:i,onSearchChange:s,onSearchBlur:c,onTabSwitch:u,searchInputRef:d})}function u2({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(Qu,{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(Zs,{id:`saved-prompt-${i.id}`,isSelected:t?.id===i.id,isFocused:r===s,icon:f.jsx(Qu,{className:"h-4 w-4"}),title:i.name,description:`${i.promptName} - ${new Date(i.savedAt).toLocaleString()}`,onClick:()=>n(i)},i.id))})}function hke({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(Vl,{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 d2({selectedPrompt:e,promptArgs:t,isExecuting:n,isConnected:a,onArgChange:r,onExecute:i,onSave:s}){return x.useEffect(()=>{const c=u=>{(u.metaKey||u.ctrlKey)&&u.key==="Enter"&&e&&!n&&a&&(u.preventDefault(),i())};return document.addEventListener("keydown",c),()=>document.removeEventListener("keydown",c)},[e,n,a,i]),e?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(Le,{onClick:i,disabled:n||!a,size:"sm",className:"lg:size-default pr-1! gap-0",children:n?f.jsxs(f.Fragment,{children:[f.jsx(Ei,{className:"mr-2"}),f.jsx("span",{className:"hidden sm:inline",children:"Executing..."})]}):f.jsxs(f.Fragment,{children:[f.jsx(v8,{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:"⌘↵"})]})}),f.jsxs(Le,{variant:"outline",onClick:s,disabled:n,size:"sm",className:"lg:size-default gap-2",children:[f.jsx(IN,{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(hke,{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 gke(e){return"isError"in e&&!e.isError?null:"error"in e&&e.error?e.error:"isError"in e&&e.isError?"An error occurred":null}function f2({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)=>{const i=a.error||gke(a.result);return 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(Qu,{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(Np,{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(Le,{variant:"ghost",size:"sm",onClick:()=>n(r,a.result),className:"h-6 px-2",children:t===r?f.jsx(ta,{className:"h-4 w-4"}):f.jsx(jr,{className:"h-4 w-4"})})})]}),i?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:i})]}):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(Sd,{vertical:!0,noBorder:!0,message:"No Results yet"})})})})})}function tD({serverIds:e,onCountChange:t,onClearRef:n}={}){const[a,r]=x.useState([]),i=x.useRef(null),[s,c]=x.useState(new Set),[u]=x.useState(""),d=v=>{c(w=>{const S=new Set(w);return S.has(v)?S.delete(v):S.add(v),S})},m=async()=>{r([]),c(new Set),t?.(0);try{const v=new URLSearchParams;e&&e.length>0&&v.set("serverIds",e.join(","));const w=await fetch(`/inspector/api/rpc/log?${v.toString()}`,{method:"DELETE"});w.ok||console.warn("[RPC Logger] Failed to clear server buffer:",w.status)}catch(v){console.warn("[RPC Logger] Error clearing server buffer:",v)}},h=x.useMemo(()=>!e||e.length===0?"":[...e].sort().join(","),[e]);x.useEffect(()=>(n&&(n.current=m),()=>{n&&(n.current=null)}),[n,m]),x.useEffect(()=>{t?.(a.length)},[a.length,t]),x.useEffect(()=>{let v=null;try{const w=new URLSearchParams;w.set("replay","3"),w.set("_t",Date.now().toString()),e&&e.length>0&&w.set("serverIds",e.join(","));const S=`/inspector/api/rpc/stream?${w.toString()}`;console.log("[RPC Logger] Connecting to SSE stream:",S),v=new globalThis.EventSource(S),v.onopen=()=>{console.log("[RPC Logger] SSE connection opened")},v.onmessage=y=>{try{const _=JSON.parse(y.data);if(!_||_.type!=="rpc")return;const{serverId:E,direction:k,message:C,timestamp:R}=_,I=C,A=typeof I?.method=="string"?I.method:I?.result!==void 0?"result":I?.error!==void 0?"error":"unknown",O={id:`${R??Date.now()}-${Math.random().toString(36).slice(2)}`,serverId:typeof E=="string"?E:"unknown",direction:typeof k=="string"?k.toUpperCase():"",method:A,timestamp:R??new Date().toISOString(),payload:C};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(w){console.error("[RPC Logger] Failed to create SSE connection:",w)}return()=>{try{v?.close(),console.log("[RPC Logger] SSE connection closed")}catch{}}},[h]);const g=x.useMemo(()=>{let v=a;if(e&&e.length>0){const w=new Set(e);v=v.filter(S=>w.has(S.serverId))}if(u.trim()){const w=u.toLowerCase();v=v.filter(S=>S.serverId.toLowerCase().includes(w)||S.method.toLowerCase().includes(w)||S.direction.toLowerCase().includes(w)||JSON.stringify(S.payload).toLowerCase().includes(w))}return v},[a,u,e]);return 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 w=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:w?f.jsx(Xl,{className:"h-3 w-3 text-muted-foreground transition-transform"}):f.jsx(ype,{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(spe,{className:"h-3 w-3"}):f.jsx(cpe,{className:"h-3 w-3"})}),f.jsx("span",{className:"text-xs font-mono text-foreground truncate",children:v.method})]})]}),w&&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 p2="mcp-inspector-saved-prompts";function EZ({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}=Jl(),[h,g]=x.useState({}),[v,w]=x.useState([]),[S,y]=x.useState(!1),[_,E]=x.useState(null),[k,C]=x.useState(""),[R,I]=x.useState("prompts"),[A,O]=x.useState([]),[M,U]=x.useState(!1),[H,K]=x.useState(""),[ee,te]=x.useState(!1),[ae,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&&!S&&j("response")},[v,S,G]),x.useImperativeHandle(e,()=>({focusSearch:()=>{te(!0),setTimeout(()=>{Z.current&&Z.current.focus()},0)},blurSearch:()=>{C(""),te(!1),Z.current&&Z.current.blur()}})),x.useEffect(()=>{try{const Se=localStorage.getItem(p2);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(p2,JSON.stringify(Se))}catch(_e){console.error("[PromptsTab] Failed to save prompts:",_e)}},[]);x.useEffect(()=>{ee&&Z.current&&Z.current.focus()},[ee]);const ie=x.useCallback(()=>{k.trim()||te(!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]),J=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,R]),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 Oe=R==="prompts"?le:A;if(_e.key==="ArrowDown")_e.preventDefault(),B(Be=>{const xe=Be+1;return xe>=Oe.length?0:xe});else if(_e.key==="ArrowUp")_e.preventDefault(),B(Be=>{const xe=Be-1;return xe<0?Oe.length-1:xe});else if(_e.key==="Enter"&&ae>=0)if(_e.preventDefault(),R==="prompts"){const Be=le[ae];Be&&J(Be)}else{const Be=A[ae];Be&&q(Be)}};return document.addEventListener("keydown",Se),()=>document.removeEventListener("keydown",Se)},[ae,le,A,R,J,q]),x.useEffect(()=>{if(ae>=0){const Se=R==="prompts"?`prompt-${le[ae]?.name}`:`saved-prompt-${A[ae]?.id}`,_e=document.getElementById(Se);_e&&_e.scrollIntoView({behavior:"smooth",block:"nearest"})}},[ae,le,A,R]),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(()=>{J(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,J,m]);const se=x.useCallback((Se,_e)=>{g(Ue=>({...Ue,[Se]:_e}))},[]),he=x.useCallback(async()=>{if(!i||S)return;y(!0);const Se=Date.now();try{const _e=await n(i.name,h),Ue=Date.now()-Se;yr.getInstance().capture(new NU({promptName:i.name,serverId:a,success:!0})).catch(()=>{}),w(Oe=>[{promptName:i.name,args:h,result:_e,timestamp:Se,duration:Ue},...Oe])}catch(_e){yr.getInstance().capture(new NU({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};w(Oe=>[fe,...Oe])}finally{y(!1)}},[i,h,S,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)}},[]),Te=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(Le,{variant:"ghost",size:"sm",onClick:()=>{ne==="response"?j("detail"):(s(null),j("list"))},className:"p-0 h-8 w-8",children:f.jsx(TN,{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(jy,{initial:!1,mode:"popLayout",children:[ne==="list"&&f.jsxs(ba.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(c2,{activeTab:R,isSearchExpanded:ee,searchQuery:k,filteredPromptsCount:le.length,savedPromptsCount:A.length,onSearchExpand:()=>te(!0),onSearchChange:C,onSearchBlur:ie,onTabSwitch:()=>I(R==="prompts"?"saved":"prompts"),searchInputRef:Z}),R==="prompts"?f.jsx(l2,{prompts:le,selectedPrompt:i,onPromptSelect:J,focusedIndex:ae}):f.jsx(u2,{savedPrompts:A,selectedPrompt:c,onLoadPrompt:q,onDeletePrompt:He,focusedIndex:ae})]},"list"),ne==="detail"&&f.jsx(ba.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(d2,{selectedPrompt:i,promptArgs:h,isExecuting:S,isConnected:r,onArgChange:se,onExecute:he,onSave:Te})},"detail"),ne==="response"&&f.jsx(ba.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(f2,{results:v,copiedResult:_,onCopy:ce})},"response")]})})]}):f.jsxs(Qr,{direction:"horizontal",className:"h-full",children:[f.jsx(Rn,{defaultSize:33,className:"flex flex-col h-full relative",children:f.jsxs(Qr,{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(c2,{activeTab:R,isSearchExpanded:ee,searchQuery:k,filteredPromptsCount:le.length,savedPromptsCount:A.length,onSearchExpand:()=>te(!0),onSearchChange:C,onSearchBlur:ie,onTabSwitch:()=>I(R==="prompts"?"saved":"prompts"),searchInputRef:Z}),R==="prompts"?f.jsx(l2,{prompts:le,selectedPrompt:i,onPromptSelect:J,focusedIndex:ae}):f.jsx(u2,{savedPrompts:A,selectedPrompt:c,onLoadPrompt:q,onDeletePrompt:He,focusedIndex:ae})]})}),f.jsx(vi,{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(Le,{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($s,{className:"h-3.5 w-3.5"})})]}),f.jsx(Xl,{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(tD,{serverIds:[a],onCountChange:z,onClearRef:W})})]})]})}),f.jsx(vi,{withHandle:!0}),f.jsx(Rn,{defaultSize:67,children:f.jsxs(Qr,{direction:"vertical",children:[f.jsx(Rn,{defaultSize:40,children:f.jsx(d2,{selectedPrompt:i,promptArgs:h,isExecuting:S,isConnected:r,onArgChange:se,onExecute:he,onSave:Te})}),f.jsx(vi,{withHandle:!0}),f.jsx(Rn,{defaultSize:50,children:f.jsx("div",{className:"flex flex-col h-full",children:f.jsx(f2,{results:v,copiedResult:_,onCopy:ce})})})]})})]})}EZ.displayName="PromptsTab";function xu(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 bke(e){return{uri:e.uri,mimeType:e.mimeType,text:e.text,blob:e.blob}}function _Z({resource:e,onUIAction:t,className:n}){const a=async i=>t?.(i),r=bke(e);return f.jsx("div",{className:n,children:f.jsx(XO,{resource:r,onUIAction:a,htmlProps:{autoResizeIframe:{width:!0,height:!0},style:{width:"100%",minHeight:"200px"},sandboxPermissions:"allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox"},remoteDomProps:{remoteElements:[C_e,N_e,R_e,A_e],library:qO}})})}function vke(e){if("error"in e&&e.error)return e.error;if(!("isError"in e&&e.isError))return null;if("contents"in e&&Array.isArray(e.contents)){const t=e.contents.filter(n=>"text"in n).map(n=>n.text).filter(Boolean);if(t.length>0)return t.join(`
|
|
1661
1661
|
`)}return"An error occurred"}function m2({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(y=>y.startsWith("openai/")),h=e.resourceAnnotations["openai/outputTemplate"]),e?.result?.contents?.[0]?._meta){const y=e.result.contents[0]._meta,_=Object.keys(y).filter(E=>E.startsWith("openai/"));_.length>0&&(m=[...m,..._]),!h&&y["openai/outputTemplate"]&&(h=y["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(Ei,{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"})]});const v=e.error||vke(e.result);if(v)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:v})]})});const w=e?.result?.contents&&Array.isArray(e.result.contents)&&e.result.contents.some(y=>y.mimeType&&xu(y)),S=w?e.result.contents.filter(y=>y.mimeType&&xu(y)):[];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(Qu,{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 y=e?.duration??e.result?.duration??e.result?.metrics?.durationMs;return y!==void 0?f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx(Np,{className:"h-3 w-3 text-gray-400"}),f.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:[y,"ms"]})]}):null})(),w&&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:[(w||g)&&f.jsxs(Le,{variant:"ghost",size:"sm",onClick:i,className:n?"":"text-purple-600 dark:text-purple-400",children:[n?f.jsx(NN,{className:"h-4 w-4 mr-1"}):f.jsx(m8,{className:"h-4 w-4 mr-1"}),n?"JSON":g?"Component":"Preview"]}),f.jsx(Le,{variant:"ghost",size:"sm",onClick:s,children:d?f.jsx(ta,{className:"h-4 w-4"}):f.jsx(jr,{className:"h-4 w-4"})}),f.jsx(Le,{variant:"ghost",size:"sm",onClick:c,children:f.jsx(bm,{className:"h-4 w-4"})}),f.jsx(Le,{variant:"ghost",size:"sm",onClick:u,children:f.jsx(AN,{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(GO,{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`})}):w?n?f.jsxs("div",{className:"space-y-0 h-full",children:[S.map((y,_)=>f.jsx("div",{className:"mx-0 size-full",children:f.jsx("div",{className:"w-full h-full",children:f.jsx(_Z,{resource:y,className:"w-full h-full"})})},`mcp-ui-${y.uri||`resource-${Date.now()}-${Math.random()}`}`)),(()=>{if(e.result.contents&&Array.isArray(e.result.contents)){const y=e.result.contents.filter(_=>!(_.mimeType&&xu(_)));if(y.length>0)return f.jsx("div",{className:"px-4",children:f.jsx(Jn,{data:y,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 yke(e,t){if(!e&&!t)return f.jsx(Wpe,{className:"h-5 w-5"});const n=(e||t||"").toLowerCase();return n.includes("image")?f.jsx(Hpe,{className:"h-5 w-5"}):n.includes("json")||n.includes("javascript")||n.includes("typescript")?f.jsx(Fpe,{className:"h-5 w-5"}):n.includes("html")||n.includes("xml")?f.jsx(qpe,{className:"h-5 w-5"}):n.includes("database")||n.includes("sql")?f.jsx(Cy,{className:"h-5 w-5"}):f.jsx(CN,{className:"h-5 w-5"})}function h2({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(Cy,{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=yke(r.mimeType,r.uri),c=[r.description,r.mimeType&&f.jsx("span",{className:"font-mono",children:r.mimeType},"mime")].filter(Boolean);return f.jsx(Zs,{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 g2({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(Dt,{children:[f.jsx(jt,{asChild:!0,children:f.jsx(Le,{variant:"ghost",size:"sm",onClick:a,className:"h-8 w-8 p-0",children:f.jsx(Ed,{className:"h-4 w-4"})})}),f.jsxs(Lt,{side:"bottom",className:"flex gap-2",children:["Search",f.jsx(jm,{children:"F"})]})]})]})})})}function kZ({ref:e,resources:t,readResource:n,serverId:a,isConnected:r}){const[i,s]=x.useState(null),{selectedResourceUri:c,setSelectedResourceUri:u}=Jl(),[d,m]=x.useState(null),[h,g]=x.useState(!1),[v,w]=x.useState(""),[S]=x.useState("resources"),[y,_]=x.useState(!0),[E,k]=x.useState(!1),[C,R]=x.useState(-1),[I,A]=x.useState(!1),O=x.useRef(null),M=x.useRef(null),[U,H]=x.useState(!1),[K,ee]=x.useState("list"),[te,ae]=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:()=>{w(""),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 TU({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 TU({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(()=>{R(-1)},[v,S]),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(),R(J=>{const q=J+1;return q>=le.length?0:q});else if(W.key==="ArrowUp")W.preventDefault(),R(J=>{const q=J-1;return q<0?le.length-1:q});else if(W.key==="Enter"&&C>=0){W.preventDefault();const J=j[C];J&&V(J)}};return document.addEventListener("keydown",F),()=>document.removeEventListener("keydown",F)},[C,j,V]),x.useEffect(()=>{if(C>=0){const F=`resource-${j[C]?.uri}`,W=document.getElementById(F);W&&W.scrollIntoView({behavior:"smooth",block:"nearest"})}},[C,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(Le,{variant:"ghost",size:"sm",onClick:()=>{s(null),ee("list")},className:"p-0 h-8 w-8",children:f.jsx(TN,{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(jy,{initial:!1,mode:"popLayout",children:[K==="list"&&f.jsxs(ba.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(g2,{activeTab:S,isSearchExpanded:E,searchQuery:v,filteredResourcesCount:j.length,onSearchExpand:()=>k(!0),onSearchChange:w,onSearchBlur:ne,onTabSwitch:()=>{},searchInputRef:O}),f.jsx("div",{className:"flex flex-col h-full",children:f.jsx(h2,{resources:j,selectedResource:i,onResourceSelect:V,focusedIndex:C})})]},"list"),K==="detail"&&f.jsx(ba.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(m2,{result:d,isLoading:h,previewMode:y,serverId:a,readResource:n,onTogglePreview:()=>_(!y),onCopy:z,onDownload:L,onFullscreen:$,isCopied:I})})},"detail")]})})]}):f.jsxs(Qr,{direction:"horizontal",className:"h-full",children:[f.jsx(Rn,{defaultSize:25,children:f.jsxs(Qr,{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(g2,{activeTab:S,isSearchExpanded:E,searchQuery:v,filteredResourcesCount:j.length,onSearchExpand:()=>k(!0),onSearchChange:w,onSearchBlur:ne,onTabSwitch:()=>{},searchInputRef:O}),f.jsx(h2,{resources:j,selectedResource:i,onResourceSelect:V,focusedIndex:C})]})}),f.jsx(vi,{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"}),te>0&&f.jsx(xr,{variant:"secondary",className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",children:te}),te>0&&!B&&f.jsx(Le,{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($s,{className:"h-3.5 w-3.5"})})]}),f.jsx(Xl,{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(tD,{serverIds:[a],onCountChange:ae,onClearRef:re})})]})]})}),f.jsx(vi,{}),f.jsx(Rn,{defaultSize:50,children:f.jsx(Qr,{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(m2,{result:d,isLoading:h,previewMode:y,serverId:a,readResource:n,onTogglePreview:()=>_(!y),onCopy:z,onDownload:L,onFullscreen:$,isCopied:I})})})})})]})}kZ.displayName="ResourcesTab";function b2({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(Cy,{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(Zs,{id:`saved-${s.id}`,isSelected:t?.id===s.id,isFocused:r===c,icon:f.jsx(ov,{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(Dt,{children:[f.jsx(jt,{asChild:!0,children:f.jsx(Le,{variant:"secondary",size:"sm",onClick:u=>i(u,()=>a(s.id)),className:"h-8 w-8 p-0",children:f.jsx($s,{className:"h-4 w-4"})})}),f.jsx(Lt,{children:f.jsx("p",{children:"Delete saved request"})})]})})]},s.id))})}function v2({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(Le,{variant:"outline",onClick:i,children:"Cancel"}),f.jsxs(Le,{onClick:r,children:[f.jsx(IN,{className:"h-4 w-4 mr-2"}),"Save"]})]})]})]})}):null}function TZ(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 wke(e,t){if(e.anyOf&&Array.isArray(e.anyOf)){const n=e.anyOf.find(a=>a.type!=="null");if(n)return{...TZ(n,t),nullable:!0}}return e}function xke(e){return Array.isArray(e.enum)?e.enum:null}function y2({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=wke(c,u);d=TZ(d,u);const m=xke(d),h=d.type==="string"&&m!==null,g=d;g.required=r.includes(s);const v=t[s];let w="";return v!=null&&(typeof v=="string"?w=v:typeof v=="object"&&v!==null?w=JSON.stringify(v,null,2):w=String(v)),g.type==="object"||g.type==="array"?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(Vl,{id:s,value:w,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(Co,{value:String(t[s]||""),onValueChange:y=>n(s,y),children:[f.jsx(Ao,{id:s,className:"w-full",children:f.jsx(Ro,{placeholder:g.description||"Select an option"})}),f.jsx(Io,{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:w,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 w2({selectedTool:e,toolArgs:t,isExecuting:n,isConnected:a,onArgChange:r,onExecute:i,onSave:s,onCancel:c}){const[u,d]=x.useState(!1),[m,h]=x.useState(()=>{if(typeof window<"u"){const S=localStorage.getItem("mcp-inspector-show-tool-metadata");return S?JSON.parse(S):!1}return!1}),[g,v]=x.useState(!1);x.useEffect(()=>{typeof window<"u"&&localStorage.setItem("mcp-inspector-show-tool-metadata",JSON.stringify(m))},[m]);const w=()=>{if(!e)return;const S={name:e.name,description:e.description||"",_meta:e._meta};navigator.clipboard.writeText(JSON.stringify(S,null,2)),v(!0),setTimeout(()=>v(!1),2e3)};return x.useEffect(()=>{const S=y=>{(y.metaKey||y.ctrlKey)&&y.key==="Enter"&&e&&!n&&a&&(y.preventDefault(),i()),y.key==="Escape"&&n&&c&&(y.preventDefault(),c())};return document.addEventListener("keydown",S),()=>document.removeEventListener("keydown",S)},[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(Dt,{children:[f.jsx(jt,{asChild:!0,children:f.jsxs(Le,{variant:m?"default":"outline",onClick:()=>h(!m),disabled:n,size:"sm",className:"lg:size-default gap-2",title:"Toggle tool metadata",children:[f.jsx(NN,{className:"h-4 w-4"}),f.jsx("span",{className:"hidden sm:inline",children:"Metadata"})]})}),f.jsx(Lt,{children:f.jsx("p",{children:"Show tool definition metadata"})})]}),f.jsxs(Le,{variant:"outline",onClick:s,disabled:n,size:"sm",className:"lg:size-default gap-2",children:[f.jsx(IN,{className:"h-4 w-4"}),f.jsx("span",{className:"hidden sm:inline",children:"Save"})]}),n&&c?f.jsxs(Dt,{open:u?void 0:!1,children:[f.jsx(jt,{asChild:!0,children:f.jsx("div",{onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),className:"relative",children:f.jsx(Le,{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(Yi,{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(Ei,{className:"mr-2"}),f.jsx("span",{className:"hidden sm:inline",children:"Executing..."})]})})})}),f.jsx(Lt,{children:f.jsx("p",{children:"Hover to cancel (or press Esc)"})})]}):f.jsx(Le,{onClick:i,disabled:n||!a,size:"sm",className:"lg:size-default pr-1! gap-0",children:n?f.jsxs(f.Fragment,{children:[f.jsx(Ei,{className:"mr-2"}),f.jsx("span",{className:"hidden sm:inline",children:"Executing..."})]}):f.jsxs(f.Fragment,{children:[f.jsx(v8,{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})]})}),m?f.jsxs("div",{className:"flex-1 overflow-hidden flex gap-4 px-3 sm:px-6 pb-4",children:[f.jsx("div",{className:"flex-1 min-w-0 overflow-y-auto",children:f.jsx(y2,{selectedTool:e,toolArgs:t,onArgChange:r})}),f.jsxs("div",{className:"w-2/5 flex flex-col bg-zinc-50 dark:bg-zinc-900/50 rounded border border-zinc-200 dark:border-zinc-800 overflow-hidden",children:[f.jsxs("div",{className:"flex items-center justify-between p-3 border-b border-zinc-200 dark:border-zinc-800 flex-shrink-0",children:[f.jsx("h4",{className:"text-sm font-medium",children:"Tool Definition"}),f.jsx(Le,{variant:"ghost",size:"sm",onClick:w,className:"h-7 w-7 p-0",title:"Copy metadata",children:g?f.jsx(ta,{className:"h-3.5 w-3.5 text-green-600"}):f.jsx(jr,{className:"h-3.5 w-3.5"})})]}),f.jsx("div",{className:"flex-1 overflow-y-auto p-3",children:f.jsx("pre",{className:"text-xs font-mono text-zinc-700 dark:text-zinc-300 whitespace-pre-wrap break-words",children:JSON.stringify({name:e.name,description:e.description||"(no description)",_meta:e._meta||null},null,2)})})]})]}):f.jsx("div",{className:"flex-1 overflow-y-auto px-3 sm:px-6 pb-4 pr-3",children:f.jsx(y2,{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 x2(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 Ske(e){if(!e?.isError)return null;if(e.content&&Array.isArray(e.content)){const t=e.content.filter(n=>n.type==="text").map(n=>n.text).filter(Boolean);if(t.length>0)return t.join(`
|
|
1662
1662
|
`)}return"An error occurred"}function Eke(e){try{return JSON.parse(e),!0}catch{return!1}}function _ke({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(Eke(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 S2({results:e,copiedResult:t,previewMode:n,serverId:a,readResource:r,onCopy:i,onTogglePreview:s,onMaximize:c,isMaximized:u=!1}){const[d,m]=x.useState(0),[h,g]=x.useState(""),[v,w]=x.useState(!0),S=e[0],y=S?e.filter(te=>te.toolName===S.toolName):[],_=y[d]||y[0],E=e.findIndex(te=>te===_);x.useEffect(()=>{y.length>0&&d>=y.length&&m(0)},[y.length,d]),x.useEffect(()=>{const te=()=>{_&&g(x2(_.timestamp))};te();const ae=setInterval(te,1e3);return()=>clearInterval(ae)},[_]);const k=x.useMemo(()=>_?.args,[_?.timestamp,d]),C=x.useMemo(()=>_?.result,[_?.timestamp,d]),R=x.useCallback(te=>r(te),[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(Sd,{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(te=>te.type==="resource"&&xu(te.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(Np,{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:()=>w(!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:()=>w(!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(Le,{variant:"ghost",size:"sm",onClick:c,title:u?"Restore":"Maximize",children:u?f.jsx(cme,{className:"h-4 w-4"}):f.jsx(AN,{className:"h-4 w-4"})}),y.length>1&&f.jsxs(Co,{value:d.toString(),onValueChange:te=>m(parseInt(te)),children:[f.jsx(Ao,{size:"sm",className:"w-[140px] h-8 text-xs",children:f.jsx(Ro,{children:f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx(ov,{className:"h-3 w-3"}),f.jsx("span",{children:h})]})})}),f.jsx(Io,{children:y.map((te,ae)=>f.jsx(Ir,{value:ae.toString(),children:f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(ov,{className:"h-3 w-3"}),f.jsx("span",{children:x2(te.timestamp)}),f.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",new Date(te.timestamp).toLocaleTimeString(),")"]})]})},ae))})]}),f.jsx(Le,{variant:"ghost",size:"sm",onClick:()=>i(E,_.result),children:t===E?f.jsx(ta,{className:"h-4 w-4"}):f.jsx(jr,{className:"h-4 w-4"})})]})]}),(()=>{const te=_.error||Ske(_.result);return te?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:te})]}):(()=>{if(A){const ae=_.appsSdkResource;return ae.isLoading?f.jsx(f.Fragment,{}):ae.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:ae.error})]}):n?f.jsx("div",{className:"flex-1",children:f.jsx(GO,{componentUrl:O,toolName:_.toolName,toolArgs:k,toolResult:C,serverId:a,readResource:R,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((ae,B)=>f.jsx("div",{className:"mx-0 size-full",children:f.jsx(_Z,{resource:ae.resource,onUIAction:Z=>{},className:"w-full h-full relative"})},B)),M.filter(ae=>!(ae.type==="resource"&&xu(ae.resource))).length>0&&f.jsx("div",{className:"px-4",children:f.jsx(Jn,{data:M.filter(ae=>!(ae.type==="resource"&&xu(ae.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 ae=_.result?.structuredContent;return f.jsxs("div",{className:"px-4 pt-4 space-y-4",children:[ae&&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:ae,filename:`structured-content-${_.toolName}-${Date.now()}.json`})]}),M&&M.length>0&&f.jsx(_ke,{content:M}),!ae&&(!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(Ul,{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(Zs,{id:`tool-${r.name}`,isSelected:t?.name===r.name,isFocused:a===i,icon:f.jsx(Ul,{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 _2({activeTab:e,isSearchExpanded:t,searchQuery:n,filteredToolsCount:a,savedRequestsCount:r,onSearchExpand:i,onSearchChange:s,onSearchBlur:c,onTabSwitch:u,searchInputRef:d}){return f.jsx(SZ,{activeTab:e,isSearchExpanded:t,searchQuery:n,primaryTabName:"tools",secondaryTabName:"saved",primaryTabTitle:"Tools",secondaryTabTitle:"Saved",primaryCount:a,secondaryCount:r,primaryIcon:Ul,secondaryIcon:Cy,searchPlaceholder:"Search tools...",onSearchExpand:i,onSearchChange:s,onSearchBlur:c,onTabSwitch:u,searchInputRef:d})}const k2="mcp-inspector-saved-requests";function NZ({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}=Jl(),[g,v]=x.useState({}),[w,S]=x.useState([]),[y,_]=x.useState(!1),[E,k]=x.useState(null),[C,R]=x.useState(null),[I,A]=x.useState(""),[O,M]=x.useState("tools"),[U,H]=x.useState([]),[K,ee]=x.useState(!1),[te,ae]=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),[ie,le]=x.useState(0),[J,q]=x.useState(!0),[se,he]=x.useState(void 0),ce=x.useRef(null),Te=x.useRef(null),He=x.useRef(null),Se=x.useRef(null),_e=x.useRef(null);x.useEffect(()=>{const Ie=()=>{L(window.innerWidth<1024)};return Ie(),window.addEventListener("resize",Ie),()=>window.removeEventListener("resize",Ie)},[]),x.useEffect(()=>{F(s?"detail":"list")},[s]),x.useEffect(()=>{z&&w.length>0&&!y&&F("response")},[w,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 Ie=localStorage.getItem(k2);Ie&&H(JSON.parse(Ie))}catch(Ie){console.error("[ToolsTab] Failed to load saved requests:",Ie)}},[]);const Ue=x.useCallback(Ie=>{try{localStorage.setItem(k2,JSON.stringify(Ie)),H(Ie)}catch($e){console.error("[ToolsTab] Failed to save requests:",$e)}},[]),fe=x.useMemo(()=>{if(!I.trim())return t;const Ie=I.toLowerCase();return t.filter($e=>$e.name.toLowerCase().includes(Ie)||$e.description?.toLowerCase().includes(Ie))},[t,I]),Oe=x.useCallback(Ie=>{c(Ie);const $e={};Ie.inputSchema?.properties&&Object.entries(Ie.inputSchema.properties).forEach(([Ve,at])=>{const dt=at;dt.default!==void 0?$e[Ve]=dt.default:dt.type==="string"?$e[Ve]="":dt.type==="number"?$e[Ve]=0:dt.type==="boolean"?$e[Ve]=!1:dt.type==="array"?$e[Ve]="[]":dt.type==="object"&&($e[Ve]="{}")}),v($e)},[]),Be=x.useCallback(Ie=>{const $e=t.find(Ve=>Ve.name===Ie.toolName);$e&&(c($e),v(Ie.args),d(Ie))},[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 Ie=$e=>{const Ve=$e.target;if(Ve.tagName==="INPUT"||Ve.tagName==="TEXTAREA"||Ve.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&&Oe(wt)}else{const wt=U[ne];wt&&Be(wt)}};return document.addEventListener("keydown",Ie),()=>document.removeEventListener("keydown",Ie)},[ne,fe,U,O,Oe,Be]),x.useEffect(()=>{if(ne>=0){const Ie=O==="tools"?`tool-${fe[ne]?.name}`:`saved-${U[ne]?.id}`,$e=document.getElementById(Ie);$e&&$e.scrollIntoView({behavior:"smooth",block:"nearest"})}},[ne,fe,U,O]),x.useEffect(()=>{if(m&&t.length>0){const Ie=t.find($e=>$e.name===m);if(Ie&&s?.name!==Ie.name){h(null);const $e=setTimeout(()=>{Oe(Ie);const Ve=document.getElementById(`tool-${Ie.name}`);Ve&&Ve.scrollIntoView({behavior:"smooth",block:"nearest"})},100);return()=>clearTimeout($e)}}},[m,t,s,Oe,h]);const tt=x.useCallback((Ie,$e)=>{v(Ve=>{const at={...Ve};if(s?.inputSchema?.properties?.[Ie]){const wt=s.inputSchema.properties[Ie].type;if(wt==="object"||wt==="array")at[Ie]=$e;else if(wt==="string")at[Ie]=$e;else try{at[Ie]=JSON.parse($e)}catch{at[Ie]=$e}}else at[Ie]=$e;return at})},[s]),it=x.useCallback(async()=>{if(!s||y)return;const Ie=new AbortController;R(Ie),_(!0);const $e=Date.now();try{const Ve={...g};s.inputSchema?.properties&&Object.entries(s.inputSchema.properties).forEach(([Ye,vt])=>{const Pt=vt.type,fr=Ve[Ye];if((Pt==="object"||Pt==="array")&&typeof fr=="string")try{Ve[Ye]=JSON.parse(fr)}catch{}});const at=await n(s.name,Ve,{timeout:6e5,resetTimeoutOnProgress:!0,signal:Ie.signal}),dt=Date.now()-$e;yr.getInstance().capture(new kU({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:at,timestamp:$e,duration:dt,toolMeta:xt,appsSdkResource:{uri:dn,resourceData:null,isLoading:!0}};S([Ye]);try{const vt=await a(dn);let Mt=null;if(at?.structuredContent)Mt=at.structuredContent;else if(Array.isArray(at)&&at[0]){const Pt=at[0];Pt.output?.value?.structuredContent?Mt=Pt.output.value.structuredContent:Pt.structuredContent?Mt=Pt.structuredContent:Pt.output?.value&&(Mt=Pt.output.value)}Mt||(Mt=at),hn={uri:dn,resourceData:{...vt,structuredContent:Mt},isLoading:!1}}catch(vt){hn={uri:dn,resourceData:null,isLoading:!1,error:vt instanceof Error?vt.message:String(vt)}}S(vt=>vt.map((Mt,Pt)=>Pt===0?{...Mt,appsSdkResource:hn}:Mt))}else S(Ye=>[{toolName:s.name,args:g,result:at,timestamp:$e,duration:dt,toolMeta:xt},...Ye])}catch(Ve){const at=Date.now()-$e;yr.getInstance().capture(new kU({toolName:s.name,serverId:r,success:!1,duration:at,error:Ve instanceof Error?Ve.message:String(Ve)})).catch(()=>{});const wt=s?._meta||s?.metadata,xt={toolName:s.name,args:g,result:null,error:Ve instanceof Error?Ve.message:String(Ve),timestamp:$e,duration:at,toolMeta:wt},dn=wt?.["openai/outputTemplate"];S(dn?[xt]:hn=>[xt,...hn])}finally{_(!1)}},[s,g,y,n,a,r]),ht=x.useCallback(async(Ie,$e)=>{try{await navigator.clipboard.writeText(JSON.stringify($e,null,2)),k(Ie),setTimeout(()=>k(null),2e3)}catch(Ve){console.error("[ToolsTab] Failed to copy result:",Ve)}},[]),Rt=x.useCallback(Ie=>{S($e=>$e.filter((Ve,at)=>at!==Ie))},[]),je=x.useMemo(()=>s?w.filter(Ie=>Ie.toolName===s.name):[],[w,s]),Fe=x.useCallback(Ie=>{const $e=je[Ie];if($e){const Ve=window.open("","_blank","width=800,height=600");Ve&&(Ve.document.write(`
|
|
1663
1663
|
<html>
|
|
@@ -1673,4 +1673,4 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1673
1673
|
<pre>${JSON.stringify($e.result,null,2)}</pre>
|
|
1674
1674
|
</body>
|
|
1675
1675
|
</html>
|
|
1676
|
-
`),Ve.document.close())}},[w]),pt=x.useCallback(()=>{W?(ce.current&&ce.current.expand(),Te.current&&Te.current.expand(),X(!1)):(ce.current&&ce.current.collapse(),Te.current&&Te.current.collapse(),X(!0))},[W]),Qe=x.useCallback(()=>{s&&(ae(""),ee(!0))},[s]),Tt=x.useCallback(()=>{if(!s)return;const Ie={id:`${Date.now()}-${Math.random()}`,name:te.trim()||`${s.name} - ${new Date().toLocaleString()}`,toolName:s.name,args:g,savedAt:Date.now(),serverId:s._serverId,serverName:s._serverName};Ue([...U,Ie]),yr.getInstance().capture(new Zfe({toolName:s.name,serverId:r})).catch(()=>{}),ee(!1),ae("")},[s,te,g,U,Ue,r]),nt=x.useCallback(Ie=>{Ue(U.filter($e=>$e.id!==Ie)),u?.id===Ie&&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(Le,{variant:"ghost",size:"sm",onClick:()=>{$==="response"?F("detail"):(c(null),F("list"))},className:"p-0 h-8 w-8",children:f.jsx(TN,{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(jy,{initial:!1,mode:"popLayout",children:[$==="list"&&f.jsxs(ba.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(_2,{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:Oe,focusedIndex:ne}):f.jsx(b2,{savedRequests:U,selectedRequest:u,onLoadRequest:Be,onDeleteRequest:nt,focusedIndex:ne})]},"list"),$==="detail"&&f.jsx(ba.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(w2,{selectedTool:s,toolArgs:g,isExecuting:y,isConnected:i,onArgChange:tt,onExecute:it,onSave:Qe})},"detail"),$==="response"&&f.jsx(ba.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(S2,{results:je,copiedResult:E,previewMode:B,serverId:r,readResource:a,onCopy:ht,onDelete:Rt,onFullscreen:Fe,onTogglePreview:()=>Z(!B)})},"response")]})}),f.jsx(v2,{isOpen:K,requestName:te,defaultPlaceholder:`${s?.name} - ${new Date().toLocaleString()}`,onRequestNameChange:ae,onSave:Tt,onCancel:()=>ee(!1)})]}):f.jsxs(Qr,{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(Qr,{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(_2,{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:Oe,focusedIndex:ne}):f.jsx(b2,{savedRequests:U,selectedRequest:u,onLoadRequest:Be,onDeleteRequest:nt,focusedIndex:ne})]})}),f.jsx(vi,{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:Ie=>{Ie.preventDefault(),Ie.stopPropagation(),J?(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"}),ie>0&&f.jsx(xr,{variant:"secondary",className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",children:ie}),ie>0&&!J&&f.jsx(Le,{variant:"ghost",size:"sm",onClick:Ie=>{Ie.preventDefault(),Ie.stopPropagation(),_e.current?.()},className:"h-6 w-6 p-0",title:"Clear all messages",children:f.jsx($s,{className:"h-3.5 w-3.5"})})]}),f.jsx(Xl,{className:`h-4 w-4 text-muted-foreground transition-transform ${J?"":"rotate-180"}`})]}),!J&&f.jsx("div",{className:"flex-1 overflow-hidden min-h-0",children:f.jsx(tD,{serverIds:[r],onCountChange:le,onClearRef:_e})})]})]})}),f.jsx(vi,{withHandle:!0}),f.jsx(Rn,{defaultSize:67,children:f.jsxs(Qr,{direction:"vertical",children:[f.jsx(Rn,{ref:Te,defaultSize:40,collapsible:!0,children:f.jsx(w2,{selectedTool:s,toolArgs:g,isExecuting:y,isConnected:i,onArgChange:tt,onExecute:it,onSave:Qe,onCancel:()=>{C&&C.abort()}})}),f.jsx(vi,{withHandle:!0}),f.jsx(Rn,{ref:He,defaultSize:60,children:f.jsx("div",{className:"flex flex-col h-full",children:f.jsx(S2,{results:je,copiedResult:E,previewMode:B,serverId:r,readResource:a,onCopy:ht,onDelete:Rt,onFullscreen:Fe,onTogglePreview:()=>Z(!B),onMaximize:pt,isMaximized:W})})})]})}),f.jsx(v2,{isOpen:K,requestName:te,defaultPlaceholder:`${s?.name} - ${new Date().toLocaleString()}`,onRequestNameChange:ae,onSave:Tt,onCancel:()=>ee(!1)})]})}NZ.displayName="ToolsTab";function kke({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(Dt,{children:[f.jsx(jt,{asChild:!0,children:f.jsx(Le,{variant:"ghost",size:"sm",onClick:r,className:"h-8 w-8 p-0",children:f.jsx(Ed,{className:"h-4 w-4"})})}),f.jsxs(Lt,{side:"bottom",className:"flex gap-2",children:["Search",f.jsx(jm,{children:"F"})]})]})]})}),f.jsx("div",{className:"flex items-center gap-2",children:f.jsxs(Dt,{children:[f.jsx(jt,{asChild:!0,children:f.jsx(Le,{variant:"ghost",size:"sm",onClick:c,disabled:a===0,className:"h-8 w-8 p-0",children:f.jsx($s,{className:"h-4 w-4"})})}),f.jsx(Lt,{side:"bottom",children:"Reject all"})]})})]})}function Tke({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(Sd,{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(Zs,{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 Nke({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 Qn(async()=>{const{HumanMessage:w,AIMessage:S}=await import("./index-DY_o0BMd.js").then(y=>y.bD);return{HumanMessage:w,AIMessage:S}},[]);for(const w of c){if(!w||!w.role){console.warn("Skipping invalid message:",w);continue}const S=Array.isArray(w.content)?w.content[0]:w.content;if(!S){console.warn("Skipping message with no content:",w);continue}S.type==="text"&&S.text?w.role==="user"?u.push(new d(S.text)):w.role==="assistant"&&u.push(new m(S.text)):console.warn("Skipping message with unsupported content type:",S)}if(u.length===0)throw new Error("No valid messages could be converted. Please ensure messages have 'text' content type.");if(!t.current||t.current.provider!==e.provider||t.current.model!==e.model||t.current.apiKey!==e.apiKey){let w;const S={model:e.model,apiKey:e.apiKey};if(i!==void 0&&(S.maxTokens=i),s!==void 0?S.temperature=s:e.temperature!==void 0&&(S.temperature=e.temperature),e.provider==="openai"){const{ChatOpenAI:y}=await Qn(async()=>{const{ChatOpenAI:_}=await import("./index-ifgbqaNd.js");return{ChatOpenAI:_}},__vite__mapDeps([5,6,7,2,8,9]));w=new y(S)}else if(e.provider==="anthropic"){const{ChatAnthropic:y}=await Qn(async()=>{const{ChatAnthropic:_}=await import("./index-Bsd6iYVu.js");return{ChatAnthropic:_}},__vite__mapDeps([10,7,6,2]));w=new y(S)}else if(e.provider==="google"){const{ChatGoogleGenerativeAI:y}=await Qn(async()=>{const{ChatGoogleGenerativeAI:_}=await import("./index-CTlKvTfg.js");return{ChatGoogleGenerativeAI:_}},__vite__mapDeps([11,7,6,2,9]));w=new y(S)}else throw new Error(`Unsupported LLM provider: ${e.provider}`);t.current={instance:w,provider:e.provider,model:e.model,apiKey:e.apiKey}}const h=await t.current.instance.invoke(u);return{role:"assistant",content:{type:"text",text:h.content||h.text||""},model:e.model,stopReason:"endTurn"}},[e]),isAvailable:e!==null}}function Cke({request:e,onApprove:t,onReject:n,onClose:a,previewMode:r,onTogglePreview:i,isCopied:s,onCopy:c,onDownload:u,onFullscreen:d,llmConfig:m}){const[h,g]=x.useState("manual"),[v,w]=x.useState("stub-model"),[S,y]=x.useState("endTurn"),[_,E]=x.useState("assistant"),[k,C]=x.useState("text"),[R,I]=x.useState("positive"),[A,O]=x.useState(""),[M,U]=x.useState("image/png"),[H,K]=x.useState(!1),[ee,te]=x.useState(null),{generateResponse:ae,isAvailable:B}=Nke({llmConfig:m});x.useEffect(()=>{e&&(w("stub-model"),y("endTurn"),E("assistant"),C("text"),I("positive"),O(""),U("image/png"),te(null))},[e?.id]);const Z=async()=>{if(!(!e||!B)){K(!0),te(null);try{const j=await ae({request:e.request});w(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"?(C("text"),I(V.text||"")):V.type==="image"&&(C("image"),O(V.data||""),U(V.mimeType||"image/png"))}catch(j){const V=j instanceof Error?j.message:"Failed to generate response";te(V),Jt.error("LLM Generation Failed",{description:V})}finally{K(!1)}}},G=x.useMemo(()=>{const j={model:v,stopReason:S,role:_,content:{type:k}};return k==="text"?j.content.text=R:k==="image"&&(j.content.data=A,j.content.mimeType=M),j},[v,S,_,k,R,A,M]),re=()=>{if(!e)return;const j=UT.safeParse(G);if(!j.success){Jt.error("Invalid response",{description:`Validation failed: ${j.error.message}`});return}t(e.id,j.data),a(),Qn(()=>Promise.resolve().then(()=>ud),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(Dt,{children:[f.jsx(jt,{asChild:!0,children:f.jsx(Le,{variant:"ghost",size:"sm",onClick:c,className:"h-8 w-8 p-0",children:s?f.jsx(ta,{className:"h-4 w-4 text-green-600"}):f.jsx(jr,{className:"h-4 w-4"})})}),f.jsx(Lt,{children:"Copy request"})]}),f.jsxs(Dt,{children:[f.jsx(jt,{asChild:!0,children:f.jsx(Le,{variant:"ghost",size:"sm",onClick:u,className:"h-8 w-8 p-0",children:f.jsx(bm,{className:"h-4 w-4"})})}),f.jsx(Lt,{children:"Download request"})]}),f.jsxs(Dt,{children:[f.jsx(jt,{asChild:!0,children:f.jsx(Le,{variant:"ghost",size:"sm",onClick:d,className:"h-8 w-8 p-0",children:f.jsx(RN,{className:"h-4 w-4"})})}),f.jsx(Lt,{children:"Fullscreen"})]}),f.jsx(Le,{variant:"ghost",size:"sm",onClick:a,className:"h-8 w-8 p-0",children:f.jsx(Yi,{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(Co,{value:h,onValueChange:j=>g(j),children:[f.jsx(Ao,{id:`responseMode-${e.id}`,className:"w-32 h-8 text-xs",children:f.jsx(Ro,{})}),f.jsxs(Io,{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(Le,{onClick:Z,disabled:H,size:"sm",className:"flex items-center gap-2",children:H?f.jsxs(f.Fragment,{children:[f.jsx(Ls,{className:"h-4 w-4 animate-spin"}),"Generating..."]}):f.jsxs(f.Fragment,{children:[f.jsx(Cme,{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=>w(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:S,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(Co,{value:_,onValueChange:j=>E(j),disabled:h==="llm"&&H,children:[f.jsx(Ao,{id:`role-${e.id}`,children:f.jsx(Ro,{})}),f.jsxs(Io,{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(Co,{value:k,onValueChange:j=>C(j),disabled:h==="llm"&&H,children:[f.jsx(Ao,{id:`contentType-${e.id}`,children:f.jsx(Ro,{})}),f.jsxs(Io,{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(Vl,{id:`text-${e.id}`,value:R,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(Vl,{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(Le,{onClick:re,className:"flex-1",disabled:h==="llm"&&H,children:"Approve"}),f.jsx(Le,{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 Rke({pendingRequests:e,onApprove:t,onReject:n,serverId:a,isConnected:r,mcpServerUrl:i}){const{selectedSamplingRequestId:s,setSelectedSamplingRequestId:c}=Jl(),{llmConfig:u}=eZ({mcpServerUrl:i}),[d,m]=x.useState(null),[h,g]=x.useState(""),[v,w]=x.useState(-1),[S,y]=x.useState(!0),[_,E]=x.useState(!1),[k,C]=x.useState(!0),[R,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(()=>{S&&e.length>0&&A.current&&!U.current&&(A.current.scrollTop=0)},[e.length,S]),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(()=>{w(-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(),w(z=>{const L=z+1;return L>=V.length?0:L});else if(re.key==="ArrowUp")re.preventDefault(),w(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)},[]),te=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]),ae=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(Qr,{direction:"horizontal",className:"h-full",children:[f.jsx(Rn,{defaultSize:40,minSize:30,children:f.jsx(Qr,{direction:"vertical",className:"h-full border-r dark:border-zinc-700",children:f.jsxs(Rn,{defaultSize:75,minSize:30,children:[f.jsx(kke,{isSearchExpanded:_,searchQuery:h,filteredRequestsCount:K.length,requestsCount:e.length,onSearchExpand:()=>E(!0),onSearchChange:g,onSearchBlur:H,onRejectAll:te,searchInputRef:M}),f.jsx("div",{className:"flex flex-col h-full",children:f.jsx(Tke,{requests:K,selectedRequest:d,onRequestSelect:ee,focusedIndex:v,formatRelativeTime:Lv,listRef:A})})]})})}),f.jsx(vi,{}),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(Cke,{request:d,onApprove:t,onReject:n,onClose:()=>m(null),previewMode:k,onTogglePreview:()=>C(!k),isCopied:R,onCopy:ae,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(g8,{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 Ake({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(Dt,{children:[f.jsx(jt,{asChild:!0,children:f.jsx(Le,{variant:"ghost",size:"sm",onClick:r,className:"h-8 w-8 p-0",children:f.jsx(Ed,{className:"h-4 w-4"})})}),f.jsxs(Lt,{side:"bottom",className:"flex gap-2",children:["Search",f.jsx(jm,{children:"F"})]})]})]})}),f.jsx("div",{className:"flex items-center gap-2",children:f.jsxs(Dt,{children:[f.jsx(jt,{asChild:!0,children:f.jsx(Le,{variant:"ghost",size:"sm",onClick:c,disabled:a===0,className:"h-8 w-8 p-0",children:f.jsx(Yi,{className:"h-4 w-4"})})}),f.jsx(Lt,{side:"bottom",children:"Cancel all"})]})})]})}function Ike({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(Sd,{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(Zs,{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 Oke({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),w=e?.request.mode||"form",S=w==="form",y=w==="url";x.useEffect(()=>{if(e&&S&&"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,S]);const _=(A,O)=>{h(M=>({...M,[A]:O}))},E=()=>{if(e){if(S){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(),Qn(()=>Promise.resolve().then(()=>ud),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())},C=()=>{e&&(n(e.id,"User cancelled elicitation request"),a())},R=()=>{e&&y&&"url"in e.request&&(window.open(e.request.url,"_blank"),v(!0))},I=x.useMemo(()=>{if(!e||!S||!("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),te=K.type||"string",ae=K.title||U,B=K.description;return f.jsxs("div",{className:"space-y-2",children:[f.jsxs(Kt,{htmlFor:`field-${U}`,children:[ae,ee&&f.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),B&&f.jsx("p",{className:"text-xs text-muted-foreground",children:B}),te==="boolean"?f.jsxs("div",{className:"flex items-center space-x-2",children:[f.jsx(zp,{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})]}):te==="number"||te==="integer"?f.jsx(kn,{id:`field-${U}`,type:"number",value:m[U]||"",onChange:Z=>_(U,te==="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))]}):te==="string"&&(K.format==="textarea"||K.maxLength>100)?f.jsx(Vl,{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,S]);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:w}),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(Dt,{children:[f.jsx(jt,{asChild:!0,children:f.jsx(Le,{variant:"ghost",size:"sm",onClick:c,className:"h-8 w-8 p-0",children:s?f.jsx(ta,{className:"h-4 w-4 text-green-600"}):f.jsx(jr,{className:"h-4 w-4"})})}),f.jsx(Lt,{children:"Copy request"})]}),f.jsxs(Dt,{children:[f.jsx(jt,{asChild:!0,children:f.jsx(Le,{variant:"ghost",size:"sm",onClick:u,className:"h-8 w-8 p-0",children:f.jsx(bm,{className:"h-4 w-4"})})}),f.jsx(Lt,{children:"Download request"})]}),f.jsxs(Dt,{children:[f.jsx(jt,{asChild:!0,children:f.jsx(Le,{variant:"ghost",size:"sm",onClick:d,className:"h-8 w-8 p-0",children:f.jsx(RN,{className:"h-4 w-4"})})}),f.jsx(Lt,{children:"Fullscreen"})]}),f.jsx(Le,{variant:"ghost",size:"sm",onClick:a,className:"h-8 w-8 p-0",children:f.jsx(Yi,{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(Le,{size:"sm",variant:"outline",onClick:R,className:"flex items-center gap-2",children:[f.jsx(CE,{className:"h-4 w-4"}),"Open URL"]})]}),f.jsxs("div",{className:"flex items-center space-x-2 pt-2",children:[f.jsx(zp,{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"})]})]})]}),S&&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]}),S&&"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(Le,{onClick:E,className:"flex-1",children:"Accept"}),f.jsx(Le,{onClick:k,variant:"outline",className:"flex-1",children:"Decline"}),f.jsx(Le,{onClick:C,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 Dke({pendingRequests:e=[],onApprove:t,onReject:n,serverId:a,isConnected:r}){const{selectedElicitationRequestId:i,setSelectedElicitationRequestId:s}=Jl(),[c,u]=x.useState(null),[d,m]=x.useState(""),[h,g]=x.useState(-1),[v,w]=x.useState(!0),[S,y]=x.useState(!1),[_,E]=x.useState(!0),[k,C]=x.useState(!1),R=x.useRef(null),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&&R.current&&!O.current&&(R.current.scrollTop=0)},[e.length,v]),x.useEffect(()=>{const B=R.current;if(!B)return;const Z=()=>{B.scrollTop>0&&(O.current=!0,w(!1))};return B.addEventListener("scroll",Z),()=>B.removeEventListener("scroll",Z)},[]),x.useEffect(()=>{e.length===0&&(O.current=!1,w(!0))},[e.length]),x.useEffect(()=>{S&&A.current&&A.current.focus()},[S]);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)),C(!0),setTimeout(()=>C(!1),2e3)}catch(B){console.error("[ElicitationTab] Failed to copy request:",B)}},[c]),te=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]),ae=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(Qr,{direction:"horizontal",className:"h-full",children:[f.jsx(Rn,{defaultSize:40,minSize:30,children:f.jsx(Qr,{direction:"vertical",className:"h-full border-r dark:border-zinc-700",children:f.jsxs(Rn,{defaultSize:75,minSize:30,children:[f.jsx(Ake,{isSearchExpanded:S,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(Ike,{requests:U,selectedRequest:c,onRequestSelect:H,focusedIndex:h,formatRelativeTime:Lv,listRef:R})})]})})}),f.jsx(vi,{}),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(Oke,{request:c,onApprove:t,onReject:n,onClose:()=>u(null),previewMode:_,onTogglePreview:()=>E(!_),isCopied:k,onCopy:ee,onDownload:te,onFullscreen:ae})})})]}):f.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[f.jsx(w8,{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 jke({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(NZ,{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(EZ,{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(kZ,{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($_e,{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(Rke,{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(Dke,{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(mke,{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 T2({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 CZ=x.createContext(void 0);function RZ(){const e=x.use(CZ);if(!e)throw new Error("useTabs must be used within a TabsProvider");return e}const AZ=x.createContext(void 0);function Lke(){return x.use(AZ)}function L_({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(CZ,{value:{activeValue:h,handleValueChange:m},children:f.jsx("div",{ref:e,className:De("flex flex-col gap-2",i),...s,children:t})})}L_.displayName="Tabs";function $_({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(S=>x.isValidElement(S)&&S.props.value===i),v=x.useCallback(()=>{const S=u.current;if(!S)return;const _=S.querySelectorAll("button")[g];if(_){const E=S.getBoundingClientRect(),k=_.getBoundingClientRect();c({width:k.width,left:k.left-E.left})}},[g]),w=x.useCallback(()=>{m.current&&clearTimeout(m.current),m.current=setTimeout(v,16)},[v]);return x.useEffect(()=>{const S=setTimeout(v,10);return()=>clearTimeout(S)},[v]),x.useEffect(()=>{const S=u.current;return S?(d.current=new ResizeObserver(()=>{w()}),d.current.observe(S),S.querySelectorAll("button").forEach(_=>{d.current&&d.current.observe(_)}),()=>{d.current&&d.current.disconnect(),m.current&&clearTimeout(m.current)}):void 0},[w]),x.useEffect(()=>{const S=()=>{w()};return window.addEventListener("resize",S),()=>window.removeEventListener("resize",S)},[w]),x.useEffect(()=>{const S=u.current;if(!S)return;const y=S.querySelector("[data-width]");y&&(y.style.width=`${s.width}px`,y.style.left=`${s.left}px`)},[s]),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})]})})}$_.displayName="TabsList";function M_({ref:e,children:t,value:n,className:a,disabled:r,icon:i,...s}){const{activeValue:c,handleValueChange:u}=RZ(),m=Lke()?.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]})}M_.displayName="TabsTrigger";function N2({className:e}){const{theme:t,setTheme:n}=ew(),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(OU,{className:"size-4"}):t==="light"?f.jsx(Dme,{className:"size-5"}):f.jsx(fme,{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(()=>{hd.flushSync(()=>{n(m)})}).ready;const{top:h,left:g,width:v,height:w}=a.current.getBoundingClientRect(),S=h+w/2,y=g+v/2,_=window.innerWidth-g,E=window.innerHeight-h,k=Math.hypot(Math.max(g,_),Math.max(h,E));document.documentElement.animate({clipPath:[`circle(0px at ${y}px ${S}px)`,`circle(${k}px at ${y}px ${S}px)`]},{duration:700,easing:"ease-in-out",pseudoElement:"::view-transition-new(root)"})}else n(m)};return r?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(OU,{className:"size-4"})})}function C2({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(ba.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(ba.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($ke,{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(R2,{cx:70.3,cy:232.3,r:50,times:{T0:m,T1:h,T2:g,T3:v},total:d}),f.jsx(R2,{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 $ke({d:e,times:t,total:n}){const{T0:a,T1:r,T2:i,T3:s}=t;return f.jsx(ba.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 R2({cx:e,cy:t,r:n,times:a,total:r}){const{T0:i,T1:s,T2:c,T3:u}=a;return f.jsx(ba.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}=ew(),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 A2({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(Dt,{children:[f.jsx(jt,{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(Lt,{children:f.jsx("p",{children:r})})]})}function I2({connections:e,selectedServer:t,onServerSelect:n,onOpenConnectionOptions:a,mobileMode:r=!1}){const i=md(),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(EE,{children:[f.jsx(_E,{asChild:!0,children:f.jsxs(Le,{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(Tl,{serverUrl:t.url,serverName:t.name,size:"md"}):f.jsx(Eme,{className:"h-5 w-5"}),f.jsx(Xl,{className:"h-4 w-4"})]})}),f.jsxs(iv,{className:"w-[calc(100vw-2rem)] sm:w-[300px]",align:"start",children:[f.jsx(kE,{className:"cursor-pointer hover:bg-zinc-100 dark:hover:bg-zinc-800",onClick:()=>i("/"),children:"MCP Servers"}),f.jsx(Bf,{}),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(To,{onClick:()=>s(c.id),className:"flex items-center gap-3",children:[f.jsx(Tl,{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(A2,{status:c.state})]}),f.jsx(Le,{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(gu,{className:"h-3 w-3"})})]},c.id)),f.jsx(Bf,{}),f.jsx(To,{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(EE,{children:[f.jsx(_E,{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(Tl,{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(Dt,{children:[f.jsx(jt,{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(Lt,{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(Dt,{children:[f.jsx(jt,{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(gu,{className:"h-4 w-4"})})}),f.jsx(Lt,{children:f.jsx("p",{children:"Edit connection settings"})})]}),f.jsxs(iv,{className:"w-[calc(100vw-2rem)] sm:w-[300px]",align:"start",children:[f.jsx(kE,{className:"cursor-pointer hover:bg-zinc-100 dark:hover:bg-zinc-800",onClick:()=>i("/"),children:"MCP Servers"}),f.jsx(Bf,{}),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(To,{onClick:()=>s(c.id),className:"flex items-center gap-3",children:[f.jsx(Tl,{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(A2,{status:c.state})]}),f.jsx(Le,{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(gu,{className:"h-3 w-3"})})]},c.id)),f.jsx(Bf,{}),f.jsx(To,{onClick:()=>i("/"),children:f.jsx("span",{className:"text-blue-600 dark:text-blue-400",children:"+ Add new server"})})]})]})})})}const O2=[{id:"tools",label:"Tools",icon:Ul},{id:"prompts",label:"Prompts",icon:Tp},{id:"resources",label:"Resources",icon:Zpe},{id:"sampling",label:"Sampling",icon:g8},{id:"elicitation",label:"Elicitation",icon:w8},{id:"notifications",label:"Notifications",icon:kN},{id:"chat",label:"Chat",icon:ome}];function D2(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 Mke({connections:e,selectedServer:t,activeTab:n,onServerSelect:a,onTabChange:r,onCommandPaletteOpen:i,onOpenConnectionOptions:s}){const{tunnelUrl:c}=Jl(),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(I2,{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(C2,{state:"collapsed"})})}),f.jsxs("div",{className:"flex-1 flex justify-end items-center gap-2",children:[f.jsxs(Dt,{children:[f.jsx(jt,{asChild:!0,children:f.jsx(Le,{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(T2,{className:"h-4 w-4"})})})}),f.jsx(Lt,{children:f.jsx("p",{children:"Give us a star ⭐"})})]}),f.jsx(N2,{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(L_,{value:n,onValueChange:g=>r(g),children:f.jsx($_,{className:"w-full justify-center",children:O2.map(g=>{const v=D2(g.id,t);return f.jsxs(M_,{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(I2,{connections:e,selectedServer:t,onServerSelect:a,onOpenConnectionOptions:s}),t&&f.jsx(L_,{value:n,onValueChange:g=>r(g),children:f.jsx($_,{className:"overflow-x-auto",children:O2.map(g=>{const v=D2(g.id,t);return f.jsx(M_,{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(_7,{children:[f.jsx(k7,{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(Np,{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(EC,{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(Np,{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(Le,{variant:"ghost",size:"sm",className:"h-7 px-2",onClick:h,children:d?f.jsx(ta,{className:"size-3.5 text-green-600"}):f.jsx(jr,{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(Dt,{children:[f.jsx(jt,{children:f.jsx(N2,{className:"p-2 hover:bg-zinc-200 dark:hover:bg-zinc-800 rounded-full transition-colors cursor-pointer"})}),f.jsx(Lt,{children:f.jsx("p",{children:"Toggle theme"})})]}),f.jsxs(Dt,{children:[f.jsx(jt,{asChild:!0,children:f.jsxs(Le,{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(Ipe,{className:"size-4"}),f.jsx("span",{className:"text-base font-mono hidden sm:inline",children:"K"})]})}),f.jsx(Lt,{children:f.jsx("p",{children:"Command Palette"})})]}),f.jsxs(Dt,{children:[f.jsx(jt,{asChild:!0,children:f.jsx(Le,{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(T2,{className:"h-4 w-4"}),f.jsx("span",{className:"hidden sm:inline",children:"Github"})]})})}),f.jsx(Lt,{children:f.jsx("p",{children:"Give us a star ⭐"})})]}),f.jsx(C2,{state:"expanded"})]})]})]})}function Pke({children:e}){const t=md(),n=Bo(),{connections:a,addConnection:r,removeConnection:i,updateConnectionConfig:s,configLoaded:c}=_N(),{selectedServerId:u,setSelectedServerId:d,activeTab:m,setActiveTab:h,navigateToItem:g,setTunnelUrl:v}=Jl(),[w,S]=x.useState(!1),[y,_]=x.useState(null),E=Qwe();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),C=x.useRef(null),R=x.useRef(null),{isAutoConnecting:I}=Jwe({connections:a,addConnection:r,removeConnection:i,configLoaded:c}),A=x.useCallback(B=>{yr.getInstance().capture(new Kfe({trigger:B})).catch(()=>{}),S(!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})):[]),te=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})):[]),ae=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]),JW({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"&&C.current?C.current.focusSearch():m==="resources"&&R.current&&R.current.focusSearch()},onBlurSearch:()=>{m==="tools"&&k.current?k.current.blurSearch():m==="prompts"&&C.current?C.current.blurSearch():m==="resources"&&R.current&&R.current.blurSearch()}}),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(Ei,{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(d8,{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(Mke,{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(jke,{selectedServer:K,activeTab:m,toolsSearchRef:k,promptsSearchRef:C,resourcesSearchRef:R,children:e})}),f.jsx(T0e,{isOpen:w,onOpenChange:S,tools:ee,prompts:te,resources:ae,savedRequests:E,connections:a,onNavigate:H,onServerSelect:O}),f.jsx(hG,{connection:y&&a.find(B=>B.id===y)||null,open:y!==null,onOpenChange:B=>{B||_(null)},onConnect:U})]})})}function Uke(){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),ZT().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(Ls,{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 zke=(e,t,n,a,r,i,s,c)=>{let u=document.documentElement,d=["light","dark"];function m(v){(Array.isArray(e)?e:[e]).forEach(w=>{let S=w==="class",y=S&&i?r.map(_=>i[_]||_):r;S?(u.classList.remove(...y),u.classList.add(i&&i[v]?i[v]:v)):u.setAttribute(w,v)}),h(v)}function h(v){c&&d.includes(v)&&(u.style.colorScheme=v)}function g(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}if(a)m(a);else try{let v=localStorage.getItem(t)||n,w=s&&v==="system"?g():v;m(w)}catch{}},Fke=x.createContext(void 0),Bke={setTheme:e=>{},themes:[]},Hke=()=>{var e;return(e=x.useContext(Fke))!=null?e:Bke};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:`(${zke.toString()})(${m})`}})});function Vke({...e}){const{theme:t="system"}=Hke();return f.jsx(x8,{theme:t,className:"toaster group",style:{"--normal-bg":"var(--popover)","--normal-text":"var(--popover-foreground)","--normal-border":"var(--border)"},...e})}function Gke(){return f.jsx(hEe,{children:f.jsx(epe,{children:f.jsxs(Xwe,{children:[f.jsx(Joe,{basename:"/inspector",children:f.jsxs(Roe,{children:[f.jsx(pE,{path:"/oauth/callback",element:f.jsx(Uke,{})}),f.jsx(pE,{path:"/",element:f.jsx(Pke,{children:f.jsx(qwe,{})})})]})}),f.jsx(Vke,{position:"top-center"})]})})})}const j2=new URLSearchParams(window.location.search);if(j2.has("code")||j2.has("error"))try{ZT()}catch(e){console.error("[inspector] OAuth callback error:",e)}const L2=document.getElementById("root");L2?Pie.createRoot(L2).render(f.jsx(Gke,{})):console.error("[inspector] Root element not found");export{ck as $,xie as A,bre as B,_P as C,ZT as D,lX as E,hi as F,PS as G,yie as H,ei as I,ob as J,u6 as K,U2 as L,gie as M,eB as N,bB as O,iF as P,lF as Q,ue as R,c6 as S,K2 as T,Q3 as U,Zq as V,Ct as Z,ze as _,Qn as a,ud as b,hd as c,$v as d,MS as e,rte as f,Kke as g,Ab as h,oX as i,wie as j,Mi as k,ke as l,Ite as m,Y6 as n,ste as o,gF as p,Z6 as q,x as r,FS as s,R6 as t,hT as u,Xv as v,Q6 as w,Es as x,bie as y,ub as z};
|
|
1676
|
+
`),Ve.document.close())}},[w]),pt=x.useCallback(()=>{W?(ce.current&&ce.current.expand(),Te.current&&Te.current.expand(),X(!1)):(ce.current&&ce.current.collapse(),Te.current&&Te.current.collapse(),X(!0))},[W]),Qe=x.useCallback(()=>{s&&(ae(""),ee(!0))},[s]),Tt=x.useCallback(()=>{if(!s)return;const Ie={id:`${Date.now()}-${Math.random()}`,name:te.trim()||`${s.name} - ${new Date().toLocaleString()}`,toolName:s.name,args:g,savedAt:Date.now(),serverId:s._serverId,serverName:s._serverName};Ue([...U,Ie]),yr.getInstance().capture(new Zfe({toolName:s.name,serverId:r})).catch(()=>{}),ee(!1),ae("")},[s,te,g,U,Ue,r]),nt=x.useCallback(Ie=>{Ue(U.filter($e=>$e.id!==Ie)),u?.id===Ie&&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(Le,{variant:"ghost",size:"sm",onClick:()=>{$==="response"?F("detail"):(c(null),F("list"))},className:"p-0 h-8 w-8",children:f.jsx(TN,{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(jy,{initial:!1,mode:"popLayout",children:[$==="list"&&f.jsxs(ba.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(_2,{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:Oe,focusedIndex:ne}):f.jsx(b2,{savedRequests:U,selectedRequest:u,onLoadRequest:Be,onDeleteRequest:nt,focusedIndex:ne})]},"list"),$==="detail"&&f.jsx(ba.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(w2,{selectedTool:s,toolArgs:g,isExecuting:y,isConnected:i,onArgChange:tt,onExecute:it,onSave:Qe})},"detail"),$==="response"&&f.jsx(ba.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(S2,{results:je,copiedResult:E,previewMode:B,serverId:r,readResource:a,onCopy:ht,onDelete:Rt,onFullscreen:Fe,onTogglePreview:()=>Z(!B)})},"response")]})}),f.jsx(v2,{isOpen:K,requestName:te,defaultPlaceholder:`${s?.name} - ${new Date().toLocaleString()}`,onRequestNameChange:ae,onSave:Tt,onCancel:()=>ee(!1)})]}):f.jsxs(Qr,{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(Qr,{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(_2,{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:Oe,focusedIndex:ne}):f.jsx(b2,{savedRequests:U,selectedRequest:u,onLoadRequest:Be,onDeleteRequest:nt,focusedIndex:ne})]})}),f.jsx(vi,{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:Ie=>{Ie.preventDefault(),Ie.stopPropagation(),J?(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"}),ie>0&&f.jsx(xr,{variant:"secondary",className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",children:ie}),ie>0&&!J&&f.jsx(Le,{variant:"ghost",size:"sm",onClick:Ie=>{Ie.preventDefault(),Ie.stopPropagation(),_e.current?.()},className:"h-6 w-6 p-0",title:"Clear all messages",children:f.jsx($s,{className:"h-3.5 w-3.5"})})]}),f.jsx(Xl,{className:`h-4 w-4 text-muted-foreground transition-transform ${J?"":"rotate-180"}`})]}),!J&&f.jsx("div",{className:"flex-1 overflow-hidden min-h-0",children:f.jsx(tD,{serverIds:[r],onCountChange:le,onClearRef:_e})})]})]})}),f.jsx(vi,{withHandle:!0}),f.jsx(Rn,{defaultSize:67,children:f.jsxs(Qr,{direction:"vertical",children:[f.jsx(Rn,{ref:Te,defaultSize:40,collapsible:!0,children:f.jsx(w2,{selectedTool:s,toolArgs:g,isExecuting:y,isConnected:i,onArgChange:tt,onExecute:it,onSave:Qe,onCancel:()=>{C&&C.abort()}})}),f.jsx(vi,{withHandle:!0}),f.jsx(Rn,{ref:He,defaultSize:60,children:f.jsx("div",{className:"flex flex-col h-full",children:f.jsx(S2,{results:je,copiedResult:E,previewMode:B,serverId:r,readResource:a,onCopy:ht,onDelete:Rt,onFullscreen:Fe,onTogglePreview:()=>Z(!B),onMaximize:pt,isMaximized:W})})})]})}),f.jsx(v2,{isOpen:K,requestName:te,defaultPlaceholder:`${s?.name} - ${new Date().toLocaleString()}`,onRequestNameChange:ae,onSave:Tt,onCancel:()=>ee(!1)})]})}NZ.displayName="ToolsTab";function kke({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(Dt,{children:[f.jsx(jt,{asChild:!0,children:f.jsx(Le,{variant:"ghost",size:"sm",onClick:r,className:"h-8 w-8 p-0",children:f.jsx(Ed,{className:"h-4 w-4"})})}),f.jsxs(Lt,{side:"bottom",className:"flex gap-2",children:["Search",f.jsx(jm,{children:"F"})]})]})]})}),f.jsx("div",{className:"flex items-center gap-2",children:f.jsxs(Dt,{children:[f.jsx(jt,{asChild:!0,children:f.jsx(Le,{variant:"ghost",size:"sm",onClick:c,disabled:a===0,className:"h-8 w-8 p-0",children:f.jsx($s,{className:"h-4 w-4"})})}),f.jsx(Lt,{side:"bottom",children:"Reject all"})]})})]})}function Tke({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(Sd,{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(Zs,{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 Nke({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 Qn(async()=>{const{HumanMessage:w,AIMessage:S}=await import("./index-DOp47eHE.js").then(y=>y.bD);return{HumanMessage:w,AIMessage:S}},[]);for(const w of c){if(!w||!w.role){console.warn("Skipping invalid message:",w);continue}const S=Array.isArray(w.content)?w.content[0]:w.content;if(!S){console.warn("Skipping message with no content:",w);continue}S.type==="text"&&S.text?w.role==="user"?u.push(new d(S.text)):w.role==="assistant"&&u.push(new m(S.text)):console.warn("Skipping message with unsupported content type:",S)}if(u.length===0)throw new Error("No valid messages could be converted. Please ensure messages have 'text' content type.");if(!t.current||t.current.provider!==e.provider||t.current.model!==e.model||t.current.apiKey!==e.apiKey){let w;const S={model:e.model,apiKey:e.apiKey};if(i!==void 0&&(S.maxTokens=i),s!==void 0?S.temperature=s:e.temperature!==void 0&&(S.temperature=e.temperature),e.provider==="openai"){const{ChatOpenAI:y}=await Qn(async()=>{const{ChatOpenAI:_}=await import("./index-DPD9iyF6.js");return{ChatOpenAI:_}},__vite__mapDeps([5,6,7,2,8,9]));w=new y(S)}else if(e.provider==="anthropic"){const{ChatAnthropic:y}=await Qn(async()=>{const{ChatAnthropic:_}=await import("./index-CsvzhAm-.js");return{ChatAnthropic:_}},__vite__mapDeps([10,7,6,2]));w=new y(S)}else if(e.provider==="google"){const{ChatGoogleGenerativeAI:y}=await Qn(async()=>{const{ChatGoogleGenerativeAI:_}=await import("./index-CSlqw8-V.js");return{ChatGoogleGenerativeAI:_}},__vite__mapDeps([11,7,6,2,9]));w=new y(S)}else throw new Error(`Unsupported LLM provider: ${e.provider}`);t.current={instance:w,provider:e.provider,model:e.model,apiKey:e.apiKey}}const h=await t.current.instance.invoke(u);return{role:"assistant",content:{type:"text",text:h.content||h.text||""},model:e.model,stopReason:"endTurn"}},[e]),isAvailable:e!==null}}function Cke({request:e,onApprove:t,onReject:n,onClose:a,previewMode:r,onTogglePreview:i,isCopied:s,onCopy:c,onDownload:u,onFullscreen:d,llmConfig:m}){const[h,g]=x.useState("manual"),[v,w]=x.useState("stub-model"),[S,y]=x.useState("endTurn"),[_,E]=x.useState("assistant"),[k,C]=x.useState("text"),[R,I]=x.useState("positive"),[A,O]=x.useState(""),[M,U]=x.useState("image/png"),[H,K]=x.useState(!1),[ee,te]=x.useState(null),{generateResponse:ae,isAvailable:B}=Nke({llmConfig:m});x.useEffect(()=>{e&&(w("stub-model"),y("endTurn"),E("assistant"),C("text"),I("positive"),O(""),U("image/png"),te(null))},[e?.id]);const Z=async()=>{if(!(!e||!B)){K(!0),te(null);try{const j=await ae({request:e.request});w(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"?(C("text"),I(V.text||"")):V.type==="image"&&(C("image"),O(V.data||""),U(V.mimeType||"image/png"))}catch(j){const V=j instanceof Error?j.message:"Failed to generate response";te(V),Jt.error("LLM Generation Failed",{description:V})}finally{K(!1)}}},G=x.useMemo(()=>{const j={model:v,stopReason:S,role:_,content:{type:k}};return k==="text"?j.content.text=R:k==="image"&&(j.content.data=A,j.content.mimeType=M),j},[v,S,_,k,R,A,M]),re=()=>{if(!e)return;const j=UT.safeParse(G);if(!j.success){Jt.error("Invalid response",{description:`Validation failed: ${j.error.message}`});return}t(e.id,j.data),a(),Qn(()=>Promise.resolve().then(()=>ud),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(Dt,{children:[f.jsx(jt,{asChild:!0,children:f.jsx(Le,{variant:"ghost",size:"sm",onClick:c,className:"h-8 w-8 p-0",children:s?f.jsx(ta,{className:"h-4 w-4 text-green-600"}):f.jsx(jr,{className:"h-4 w-4"})})}),f.jsx(Lt,{children:"Copy request"})]}),f.jsxs(Dt,{children:[f.jsx(jt,{asChild:!0,children:f.jsx(Le,{variant:"ghost",size:"sm",onClick:u,className:"h-8 w-8 p-0",children:f.jsx(bm,{className:"h-4 w-4"})})}),f.jsx(Lt,{children:"Download request"})]}),f.jsxs(Dt,{children:[f.jsx(jt,{asChild:!0,children:f.jsx(Le,{variant:"ghost",size:"sm",onClick:d,className:"h-8 w-8 p-0",children:f.jsx(RN,{className:"h-4 w-4"})})}),f.jsx(Lt,{children:"Fullscreen"})]}),f.jsx(Le,{variant:"ghost",size:"sm",onClick:a,className:"h-8 w-8 p-0",children:f.jsx(Yi,{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(Co,{value:h,onValueChange:j=>g(j),children:[f.jsx(Ao,{id:`responseMode-${e.id}`,className:"w-32 h-8 text-xs",children:f.jsx(Ro,{})}),f.jsxs(Io,{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(Le,{onClick:Z,disabled:H,size:"sm",className:"flex items-center gap-2",children:H?f.jsxs(f.Fragment,{children:[f.jsx(Ls,{className:"h-4 w-4 animate-spin"}),"Generating..."]}):f.jsxs(f.Fragment,{children:[f.jsx(Cme,{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=>w(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:S,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(Co,{value:_,onValueChange:j=>E(j),disabled:h==="llm"&&H,children:[f.jsx(Ao,{id:`role-${e.id}`,children:f.jsx(Ro,{})}),f.jsxs(Io,{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(Co,{value:k,onValueChange:j=>C(j),disabled:h==="llm"&&H,children:[f.jsx(Ao,{id:`contentType-${e.id}`,children:f.jsx(Ro,{})}),f.jsxs(Io,{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(Vl,{id:`text-${e.id}`,value:R,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(Vl,{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(Le,{onClick:re,className:"flex-1",disabled:h==="llm"&&H,children:"Approve"}),f.jsx(Le,{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 Rke({pendingRequests:e,onApprove:t,onReject:n,serverId:a,isConnected:r,mcpServerUrl:i}){const{selectedSamplingRequestId:s,setSelectedSamplingRequestId:c}=Jl(),{llmConfig:u}=eZ({mcpServerUrl:i}),[d,m]=x.useState(null),[h,g]=x.useState(""),[v,w]=x.useState(-1),[S,y]=x.useState(!0),[_,E]=x.useState(!1),[k,C]=x.useState(!0),[R,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(()=>{S&&e.length>0&&A.current&&!U.current&&(A.current.scrollTop=0)},[e.length,S]),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(()=>{w(-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(),w(z=>{const L=z+1;return L>=V.length?0:L});else if(re.key==="ArrowUp")re.preventDefault(),w(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)},[]),te=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]),ae=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(Qr,{direction:"horizontal",className:"h-full",children:[f.jsx(Rn,{defaultSize:40,minSize:30,children:f.jsx(Qr,{direction:"vertical",className:"h-full border-r dark:border-zinc-700",children:f.jsxs(Rn,{defaultSize:75,minSize:30,children:[f.jsx(kke,{isSearchExpanded:_,searchQuery:h,filteredRequestsCount:K.length,requestsCount:e.length,onSearchExpand:()=>E(!0),onSearchChange:g,onSearchBlur:H,onRejectAll:te,searchInputRef:M}),f.jsx("div",{className:"flex flex-col h-full",children:f.jsx(Tke,{requests:K,selectedRequest:d,onRequestSelect:ee,focusedIndex:v,formatRelativeTime:Lv,listRef:A})})]})})}),f.jsx(vi,{}),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(Cke,{request:d,onApprove:t,onReject:n,onClose:()=>m(null),previewMode:k,onTogglePreview:()=>C(!k),isCopied:R,onCopy:ae,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(g8,{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 Ake({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(Dt,{children:[f.jsx(jt,{asChild:!0,children:f.jsx(Le,{variant:"ghost",size:"sm",onClick:r,className:"h-8 w-8 p-0",children:f.jsx(Ed,{className:"h-4 w-4"})})}),f.jsxs(Lt,{side:"bottom",className:"flex gap-2",children:["Search",f.jsx(jm,{children:"F"})]})]})]})}),f.jsx("div",{className:"flex items-center gap-2",children:f.jsxs(Dt,{children:[f.jsx(jt,{asChild:!0,children:f.jsx(Le,{variant:"ghost",size:"sm",onClick:c,disabled:a===0,className:"h-8 w-8 p-0",children:f.jsx(Yi,{className:"h-4 w-4"})})}),f.jsx(Lt,{side:"bottom",children:"Cancel all"})]})})]})}function Ike({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(Sd,{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(Zs,{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 Oke({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),w=e?.request.mode||"form",S=w==="form",y=w==="url";x.useEffect(()=>{if(e&&S&&"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,S]);const _=(A,O)=>{h(M=>({...M,[A]:O}))},E=()=>{if(e){if(S){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(),Qn(()=>Promise.resolve().then(()=>ud),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())},C=()=>{e&&(n(e.id,"User cancelled elicitation request"),a())},R=()=>{e&&y&&"url"in e.request&&(window.open(e.request.url,"_blank"),v(!0))},I=x.useMemo(()=>{if(!e||!S||!("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),te=K.type||"string",ae=K.title||U,B=K.description;return f.jsxs("div",{className:"space-y-2",children:[f.jsxs(Kt,{htmlFor:`field-${U}`,children:[ae,ee&&f.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),B&&f.jsx("p",{className:"text-xs text-muted-foreground",children:B}),te==="boolean"?f.jsxs("div",{className:"flex items-center space-x-2",children:[f.jsx(zp,{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})]}):te==="number"||te==="integer"?f.jsx(kn,{id:`field-${U}`,type:"number",value:m[U]||"",onChange:Z=>_(U,te==="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))]}):te==="string"&&(K.format==="textarea"||K.maxLength>100)?f.jsx(Vl,{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,S]);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:w}),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(Dt,{children:[f.jsx(jt,{asChild:!0,children:f.jsx(Le,{variant:"ghost",size:"sm",onClick:c,className:"h-8 w-8 p-0",children:s?f.jsx(ta,{className:"h-4 w-4 text-green-600"}):f.jsx(jr,{className:"h-4 w-4"})})}),f.jsx(Lt,{children:"Copy request"})]}),f.jsxs(Dt,{children:[f.jsx(jt,{asChild:!0,children:f.jsx(Le,{variant:"ghost",size:"sm",onClick:u,className:"h-8 w-8 p-0",children:f.jsx(bm,{className:"h-4 w-4"})})}),f.jsx(Lt,{children:"Download request"})]}),f.jsxs(Dt,{children:[f.jsx(jt,{asChild:!0,children:f.jsx(Le,{variant:"ghost",size:"sm",onClick:d,className:"h-8 w-8 p-0",children:f.jsx(RN,{className:"h-4 w-4"})})}),f.jsx(Lt,{children:"Fullscreen"})]}),f.jsx(Le,{variant:"ghost",size:"sm",onClick:a,className:"h-8 w-8 p-0",children:f.jsx(Yi,{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(Le,{size:"sm",variant:"outline",onClick:R,className:"flex items-center gap-2",children:[f.jsx(CE,{className:"h-4 w-4"}),"Open URL"]})]}),f.jsxs("div",{className:"flex items-center space-x-2 pt-2",children:[f.jsx(zp,{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"})]})]})]}),S&&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]}),S&&"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(Le,{onClick:E,className:"flex-1",children:"Accept"}),f.jsx(Le,{onClick:k,variant:"outline",className:"flex-1",children:"Decline"}),f.jsx(Le,{onClick:C,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 Dke({pendingRequests:e=[],onApprove:t,onReject:n,serverId:a,isConnected:r}){const{selectedElicitationRequestId:i,setSelectedElicitationRequestId:s}=Jl(),[c,u]=x.useState(null),[d,m]=x.useState(""),[h,g]=x.useState(-1),[v,w]=x.useState(!0),[S,y]=x.useState(!1),[_,E]=x.useState(!0),[k,C]=x.useState(!1),R=x.useRef(null),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&&R.current&&!O.current&&(R.current.scrollTop=0)},[e.length,v]),x.useEffect(()=>{const B=R.current;if(!B)return;const Z=()=>{B.scrollTop>0&&(O.current=!0,w(!1))};return B.addEventListener("scroll",Z),()=>B.removeEventListener("scroll",Z)},[]),x.useEffect(()=>{e.length===0&&(O.current=!1,w(!0))},[e.length]),x.useEffect(()=>{S&&A.current&&A.current.focus()},[S]);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)),C(!0),setTimeout(()=>C(!1),2e3)}catch(B){console.error("[ElicitationTab] Failed to copy request:",B)}},[c]),te=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]),ae=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(Qr,{direction:"horizontal",className:"h-full",children:[f.jsx(Rn,{defaultSize:40,minSize:30,children:f.jsx(Qr,{direction:"vertical",className:"h-full border-r dark:border-zinc-700",children:f.jsxs(Rn,{defaultSize:75,minSize:30,children:[f.jsx(Ake,{isSearchExpanded:S,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(Ike,{requests:U,selectedRequest:c,onRequestSelect:H,focusedIndex:h,formatRelativeTime:Lv,listRef:R})})]})})}),f.jsx(vi,{}),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(Oke,{request:c,onApprove:t,onReject:n,onClose:()=>u(null),previewMode:_,onTogglePreview:()=>E(!_),isCopied:k,onCopy:ee,onDownload:te,onFullscreen:ae})})})]}):f.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[f.jsx(w8,{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 jke({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(NZ,{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(EZ,{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(kZ,{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($_e,{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(Rke,{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(Dke,{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(mke,{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 T2({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 CZ=x.createContext(void 0);function RZ(){const e=x.use(CZ);if(!e)throw new Error("useTabs must be used within a TabsProvider");return e}const AZ=x.createContext(void 0);function Lke(){return x.use(AZ)}function L_({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(CZ,{value:{activeValue:h,handleValueChange:m},children:f.jsx("div",{ref:e,className:De("flex flex-col gap-2",i),...s,children:t})})}L_.displayName="Tabs";function $_({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(S=>x.isValidElement(S)&&S.props.value===i),v=x.useCallback(()=>{const S=u.current;if(!S)return;const _=S.querySelectorAll("button")[g];if(_){const E=S.getBoundingClientRect(),k=_.getBoundingClientRect();c({width:k.width,left:k.left-E.left})}},[g]),w=x.useCallback(()=>{m.current&&clearTimeout(m.current),m.current=setTimeout(v,16)},[v]);return x.useEffect(()=>{const S=setTimeout(v,10);return()=>clearTimeout(S)},[v]),x.useEffect(()=>{const S=u.current;return S?(d.current=new ResizeObserver(()=>{w()}),d.current.observe(S),S.querySelectorAll("button").forEach(_=>{d.current&&d.current.observe(_)}),()=>{d.current&&d.current.disconnect(),m.current&&clearTimeout(m.current)}):void 0},[w]),x.useEffect(()=>{const S=()=>{w()};return window.addEventListener("resize",S),()=>window.removeEventListener("resize",S)},[w]),x.useEffect(()=>{const S=u.current;if(!S)return;const y=S.querySelector("[data-width]");y&&(y.style.width=`${s.width}px`,y.style.left=`${s.left}px`)},[s]),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})]})})}$_.displayName="TabsList";function M_({ref:e,children:t,value:n,className:a,disabled:r,icon:i,...s}){const{activeValue:c,handleValueChange:u}=RZ(),m=Lke()?.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]})}M_.displayName="TabsTrigger";function N2({className:e}){const{theme:t,setTheme:n}=ew(),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(OU,{className:"size-4"}):t==="light"?f.jsx(Dme,{className:"size-5"}):f.jsx(fme,{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(()=>{hd.flushSync(()=>{n(m)})}).ready;const{top:h,left:g,width:v,height:w}=a.current.getBoundingClientRect(),S=h+w/2,y=g+v/2,_=window.innerWidth-g,E=window.innerHeight-h,k=Math.hypot(Math.max(g,_),Math.max(h,E));document.documentElement.animate({clipPath:[`circle(0px at ${y}px ${S}px)`,`circle(${k}px at ${y}px ${S}px)`]},{duration:700,easing:"ease-in-out",pseudoElement:"::view-transition-new(root)"})}else n(m)};return r?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(OU,{className:"size-4"})})}function C2({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(ba.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(ba.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($ke,{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(R2,{cx:70.3,cy:232.3,r:50,times:{T0:m,T1:h,T2:g,T3:v},total:d}),f.jsx(R2,{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 $ke({d:e,times:t,total:n}){const{T0:a,T1:r,T2:i,T3:s}=t;return f.jsx(ba.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 R2({cx:e,cy:t,r:n,times:a,total:r}){const{T0:i,T1:s,T2:c,T3:u}=a;return f.jsx(ba.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}=ew(),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 A2({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(Dt,{children:[f.jsx(jt,{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(Lt,{children:f.jsx("p",{children:r})})]})}function I2({connections:e,selectedServer:t,onServerSelect:n,onOpenConnectionOptions:a,mobileMode:r=!1}){const i=md(),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(EE,{children:[f.jsx(_E,{asChild:!0,children:f.jsxs(Le,{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(Tl,{serverUrl:t.url,serverName:t.name,size:"md"}):f.jsx(Eme,{className:"h-5 w-5"}),f.jsx(Xl,{className:"h-4 w-4"})]})}),f.jsxs(iv,{className:"w-[calc(100vw-2rem)] sm:w-[300px]",align:"start",children:[f.jsx(kE,{className:"cursor-pointer hover:bg-zinc-100 dark:hover:bg-zinc-800",onClick:()=>i("/"),children:"MCP Servers"}),f.jsx(Bf,{}),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(To,{onClick:()=>s(c.id),className:"flex items-center gap-3",children:[f.jsx(Tl,{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(A2,{status:c.state})]}),f.jsx(Le,{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(gu,{className:"h-3 w-3"})})]},c.id)),f.jsx(Bf,{}),f.jsx(To,{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(EE,{children:[f.jsx(_E,{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(Tl,{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(Dt,{children:[f.jsx(jt,{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(Lt,{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(Dt,{children:[f.jsx(jt,{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(gu,{className:"h-4 w-4"})})}),f.jsx(Lt,{children:f.jsx("p",{children:"Edit connection settings"})})]}),f.jsxs(iv,{className:"w-[calc(100vw-2rem)] sm:w-[300px]",align:"start",children:[f.jsx(kE,{className:"cursor-pointer hover:bg-zinc-100 dark:hover:bg-zinc-800",onClick:()=>i("/"),children:"MCP Servers"}),f.jsx(Bf,{}),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(To,{onClick:()=>s(c.id),className:"flex items-center gap-3",children:[f.jsx(Tl,{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(A2,{status:c.state})]}),f.jsx(Le,{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(gu,{className:"h-3 w-3"})})]},c.id)),f.jsx(Bf,{}),f.jsx(To,{onClick:()=>i("/"),children:f.jsx("span",{className:"text-blue-600 dark:text-blue-400",children:"+ Add new server"})})]})]})})})}const O2=[{id:"tools",label:"Tools",icon:Ul},{id:"prompts",label:"Prompts",icon:Tp},{id:"resources",label:"Resources",icon:Zpe},{id:"sampling",label:"Sampling",icon:g8},{id:"elicitation",label:"Elicitation",icon:w8},{id:"notifications",label:"Notifications",icon:kN},{id:"chat",label:"Chat",icon:ome}];function D2(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 Mke({connections:e,selectedServer:t,activeTab:n,onServerSelect:a,onTabChange:r,onCommandPaletteOpen:i,onOpenConnectionOptions:s}){const{tunnelUrl:c}=Jl(),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(I2,{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(C2,{state:"collapsed"})})}),f.jsxs("div",{className:"flex-1 flex justify-end items-center gap-2",children:[f.jsxs(Dt,{children:[f.jsx(jt,{asChild:!0,children:f.jsx(Le,{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(T2,{className:"h-4 w-4"})})})}),f.jsx(Lt,{children:f.jsx("p",{children:"Give us a star ⭐"})})]}),f.jsx(N2,{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(L_,{value:n,onValueChange:g=>r(g),children:f.jsx($_,{className:"w-full justify-center",children:O2.map(g=>{const v=D2(g.id,t);return f.jsxs(M_,{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(I2,{connections:e,selectedServer:t,onServerSelect:a,onOpenConnectionOptions:s}),t&&f.jsx(L_,{value:n,onValueChange:g=>r(g),children:f.jsx($_,{className:"overflow-x-auto",children:O2.map(g=>{const v=D2(g.id,t);return f.jsx(M_,{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(_7,{children:[f.jsx(k7,{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(Np,{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(EC,{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(Np,{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(Le,{variant:"ghost",size:"sm",className:"h-7 px-2",onClick:h,children:d?f.jsx(ta,{className:"size-3.5 text-green-600"}):f.jsx(jr,{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(Dt,{children:[f.jsx(jt,{children:f.jsx(N2,{className:"p-2 hover:bg-zinc-200 dark:hover:bg-zinc-800 rounded-full transition-colors cursor-pointer"})}),f.jsx(Lt,{children:f.jsx("p",{children:"Toggle theme"})})]}),f.jsxs(Dt,{children:[f.jsx(jt,{asChild:!0,children:f.jsxs(Le,{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(Ipe,{className:"size-4"}),f.jsx("span",{className:"text-base font-mono hidden sm:inline",children:"K"})]})}),f.jsx(Lt,{children:f.jsx("p",{children:"Command Palette"})})]}),f.jsxs(Dt,{children:[f.jsx(jt,{asChild:!0,children:f.jsx(Le,{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(T2,{className:"h-4 w-4"}),f.jsx("span",{className:"hidden sm:inline",children:"Github"})]})})}),f.jsx(Lt,{children:f.jsx("p",{children:"Give us a star ⭐"})})]}),f.jsx(C2,{state:"expanded"})]})]})]})}function Pke({children:e}){const t=md(),n=Bo(),{connections:a,addConnection:r,removeConnection:i,updateConnectionConfig:s,configLoaded:c}=_N(),{selectedServerId:u,setSelectedServerId:d,activeTab:m,setActiveTab:h,navigateToItem:g,setTunnelUrl:v}=Jl(),[w,S]=x.useState(!1),[y,_]=x.useState(null),E=Qwe();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),C=x.useRef(null),R=x.useRef(null),{isAutoConnecting:I}=Jwe({connections:a,addConnection:r,removeConnection:i,configLoaded:c}),A=x.useCallback(B=>{yr.getInstance().capture(new Kfe({trigger:B})).catch(()=>{}),S(!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})):[]),te=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})):[]),ae=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]),JW({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"&&C.current?C.current.focusSearch():m==="resources"&&R.current&&R.current.focusSearch()},onBlurSearch:()=>{m==="tools"&&k.current?k.current.blurSearch():m==="prompts"&&C.current?C.current.blurSearch():m==="resources"&&R.current&&R.current.blurSearch()}}),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(Ei,{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(d8,{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(Mke,{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(jke,{selectedServer:K,activeTab:m,toolsSearchRef:k,promptsSearchRef:C,resourcesSearchRef:R,children:e})}),f.jsx(T0e,{isOpen:w,onOpenChange:S,tools:ee,prompts:te,resources:ae,savedRequests:E,connections:a,onNavigate:H,onServerSelect:O}),f.jsx(hG,{connection:y&&a.find(B=>B.id===y)||null,open:y!==null,onOpenChange:B=>{B||_(null)},onConnect:U})]})})}function Uke(){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),ZT().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(Ls,{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 zke=(e,t,n,a,r,i,s,c)=>{let u=document.documentElement,d=["light","dark"];function m(v){(Array.isArray(e)?e:[e]).forEach(w=>{let S=w==="class",y=S&&i?r.map(_=>i[_]||_):r;S?(u.classList.remove(...y),u.classList.add(i&&i[v]?i[v]:v)):u.setAttribute(w,v)}),h(v)}function h(v){c&&d.includes(v)&&(u.style.colorScheme=v)}function g(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}if(a)m(a);else try{let v=localStorage.getItem(t)||n,w=s&&v==="system"?g():v;m(w)}catch{}},Fke=x.createContext(void 0),Bke={setTheme:e=>{},themes:[]},Hke=()=>{var e;return(e=x.useContext(Fke))!=null?e:Bke};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:`(${zke.toString()})(${m})`}})});function Vke({...e}){const{theme:t="system"}=Hke();return f.jsx(x8,{theme:t,className:"toaster group",style:{"--normal-bg":"var(--popover)","--normal-text":"var(--popover-foreground)","--normal-border":"var(--border)"},...e})}function Gke(){return f.jsx(hEe,{children:f.jsx(epe,{children:f.jsxs(Xwe,{children:[f.jsx(Joe,{basename:"/inspector",children:f.jsxs(Roe,{children:[f.jsx(pE,{path:"/oauth/callback",element:f.jsx(Uke,{})}),f.jsx(pE,{path:"/",element:f.jsx(Pke,{children:f.jsx(qwe,{})})})]})}),f.jsx(Vke,{position:"top-center"})]})})})}const j2=new URLSearchParams(window.location.search);if(j2.has("code")||j2.has("error"))try{ZT()}catch(e){console.error("[inspector] OAuth callback error:",e)}const L2=document.getElementById("root");L2?Pie.createRoot(L2).render(f.jsx(Gke,{})):console.error("[inspector] Root element not found");export{ck as $,xie as A,bre as B,_P as C,ZT as D,lX as E,hi as F,PS as G,yie as H,ei as I,ob as J,u6 as K,U2 as L,gie as M,eB as N,bB as O,iF as P,lF as Q,ue as R,c6 as S,K2 as T,Q3 as U,Zq as V,Ct as Z,ze as _,Qn as a,ud as b,hd as c,$v as d,MS as e,rte as f,Kke as g,Ab as h,oX as i,wie as j,Mi as k,ke as l,Ite as m,Y6 as n,ste as o,gF as p,Z6 as q,x as r,FS as s,R6 as t,hT as u,Xv as v,Q6 as w,Es as x,bie as y,ub as z};
|