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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-CViqT8bM.js","assets/index-VYwK-OPz.js","assets/index-Dq7x0qqu.js","assets/llms-BUzESsFt.js","assets/embeddings-B4YvBGM4.js","assets/index-mpZL6dl2.js","assets/index-B3BSS2WR.js","assets/index-oD85ijkM.js","assets/browser-CffKCGrT.js"])))=>i.map(i=>d[i]);
2
- var QY=Object.defineProperty;var eZ=(e,t,n)=>t in e?QY(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Lg=(e,t,n)=>eZ(e,typeof t!="symbol"?t+"":t,n);function tZ(e,t){for(var n=0;n<t.length;n++){const r=t[n];if(typeof r!="string"&&!Array.isArray(r)){for(const a in r)if(a!=="default"&&!(a in e)){const o=Object.getOwnPropertyDescriptor(r,a);o&&Object.defineProperty(e,a,o.get?o:{enumerable:!0,get:()=>r[a]})}}}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 a of document.querySelectorAll('link[rel="modulepreload"]'))r(a);new MutationObserver(a=>{for(const o of a)if(o.type==="childList")for(const i of o.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&r(i)}).observe(document,{childList:!0,subtree:!0});function n(a){const o={};return a.integrity&&(o.integrity=a.integrity),a.referrerPolicy&&(o.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?o.credentials="include":a.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function r(a){if(a.ep)return;a.ep=!0;const o=n(a);fetch(a.href,o)}})();function Fm(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function MTe(e){if(Object.prototype.hasOwnProperty.call(e,"__esModule"))return e;var t=e.default;if(typeof t=="function"){var n=function r(){var a=!1;try{a=this instanceof r}catch{}return a?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(r){var a=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(n,r,a.get?a:{enumerable:!0,get:function(){return e[r]}})}),n}var Jx={exports:{}},fp={};var Oj;function nZ(){if(Oj)return fp;Oj=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(r,a,o){var i=null;if(o!==void 0&&(i=""+o),a.key!==void 0&&(i=""+a.key),"key"in a){o={};for(var l in a)l!=="key"&&(o[l]=a[l])}else o=a;return a=o.ref,{$$typeof:e,type:r,key:i,ref:a!==void 0?a:null,props:o}}return fp.Fragment=t,fp.jsx=n,fp.jsxs=n,fp}var Dj;function rZ(){return Dj||(Dj=1,Jx.exports=nZ()),Jx.exports}var d=rZ();const aZ="modulepreload",oZ=function(e){return"/inspector/"+e},Lj={},Ua=function(t,n,r){let a=Promise.resolve();if(n&&n.length>0){let u=function(f){return Promise.all(f.map(m=>Promise.resolve(m).then(h=>({status:"fulfilled",value:h}),h=>({status:"rejected",reason:h}))))};document.getElementsByTagName("link");const i=document.querySelector("meta[property=csp-nonce]"),l=i?.nonce||i?.getAttribute("nonce");a=u(n.map(f=>{if(f=oZ(f),f in Lj)return;Lj[f]=!0;const m=f.endsWith(".css"),h=m?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${f}"]${h}`))return;const g=document.createElement("link");if(g.rel=m?"stylesheet":aZ,m||(g.as="script"),g.crossOrigin="",g.href=f,l&&g.setAttribute("nonce",l),document.head.appendChild(g),m)return new Promise((y,E)=>{g.addEventListener("load",y),g.addEventListener("error",()=>E(new Error(`Unable to preload CSS for ${f}`)))})}))}function o(i){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=i,window.dispatchEvent(l),!l.defaultPrevented)throw i}return a.then(i=>{for(const l of i||[])l.status==="rejected"&&o(l.reason);return t().catch(o)})};var sZ=Object.defineProperty,ze=(e,t)=>sZ(e,"name",{value:t,configurable:!0}),jTe=(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')});function i4(e){return e==="localhost"||e==="127.0.0.1"||e.startsWith("127.")||e.startsWith("192.168.")||e.startsWith("10.")||e.startsWith("172.")}ze(i4,"isLocalServer");function l4(e){const t=e.split("."),n=[];for(let r=0;r<t.length-1;r++)n.push(t.slice(r).join("."));return n}ze(l4,"getSubdomainLevels");function c4(e){return new Promise((t,n)=>{const r=new FileReader;r.onloadend=()=>{t(r.result)},r.onerror=n,r.readAsDataURL(e)})}ze(c4,"blobToBase64");async function u4(e){console.debug("[favicon-detector] Starting favicon detection for:",e);try{let t;if(e.startsWith("http://")||e.startsWith("https://")?t=new URL(e).hostname:e.includes("://")?t=e.split("://")[1].split("/")[0]:t=e.split("/")[0],console.debug("[favicon-detector] Extracted domain:",t),i4(t))return console.debug("[favicon-detector] Skipping local server:",t),null;const n=l4(t);console.debug("[favicon-detector] Domains to try:",n);for(const r of n)try{const a=`https://favicon.tools.mcp-use.com/${r}?response=json`;console.debug("[favicon-detector] Attempting to fetch favicon metadata for:",r,"from:",a);const o=new AbortController,i=setTimeout(()=>o.abort(),2e3);try{const l=await fetch(a,{signal:o.signal});if(clearTimeout(i),!l.ok){console.debug("[favicon-detector] Fetch failed for",r,"with status:",l.status);continue}const u=await l.json();console.debug("[favicon-detector] Retrieved favicon metadata for:",r,"source:",u.source);const f=u.url.replace(/^http:\/\//,"https://"),m=await fetch(f);if(!m.ok){console.debug("[favicon-detector] Failed to fetch favicon image for",r,"status:",m.status);continue}const h=await m.blob(),g=await c4(h);if(u.source==="default"){console.debug("[favicon-detector] Found default favicon for:",r,"skipping and continuing to search for non-default");continue}return console.debug("[favicon-detector] Successfully retrieved non-default favicon for:",r,"source:",u.source,"size:",h.size,"bytes"),g}catch(l){clearTimeout(i),console.debug("[favicon-detector] Fetch error for",r,":",l instanceof Error?l.message:String(l));continue}}catch(a){console.debug("[favicon-detector] Error processing domain",r,":",a instanceof Error?a.message:String(a));continue}return console.debug("[favicon-detector] No non-default favicon found for:",e,"returning null to show gradient fallback"),null}catch(t){return console.warn("[favicon-detector] Error detecting favicon:",t),null}}ze(u4,"detectFavicon");function d4(e,t){const n=t?.headers??t?.customHeaders??{};if(t?.customHeaders&&!t?.headers&&console.warn('[applyProxyConfig] The "customHeaders" option in proxyConfig is deprecated. Use "headers" instead.'),!t?.proxyAddress)return{url:e,headers:n};const r=new URL(t.proxyAddress),a=new URL(e),o=`${r.origin}${r.pathname}${a.pathname}${a.search}`,i={"X-Target-URL":e,...n};return{url:o,headers:i}}ze(d4,"applyProxyConfig");var Sp={},f4="mcp-use";function CS(e){switch((typeof process<"u"&&Sp?e:void 0)?.trim()){case"2":return"debug";case"1":return"info";default:return"info"}}ze(CS,"resolveLevel");function p4(e){return e.length===0?"":e.map(t=>{if(typeof t=="string")return t;try{return JSON.stringify(t)}catch{return String(t)}}).join(" ")}ze(p4,"formatArgs");var id,iZ=(id=class{_level;name;format;constructor(t=f4,n="info",r="minimal"){this.name=t,this._level=n,this.format=r}shouldLog(t){const n=["error","warn","info","http","verbose","debug","silly"],r=n.indexOf(this._level);return n.indexOf(t)<=r}formatMessage(t,n,r){const a=new Date().toLocaleTimeString("en-US",{hour12:!1}),o=p4(r),i=o?`${n} ${o}`:n;switch(this.format){case"detailed":return`${a} [${this.name}] ${t.toUpperCase()}: ${i}`;case"emoji":{const l={error:"❌",warn:"⚠️",info:"ℹ️",http:"🌐",verbose:"📝",debug:"🔍",silly:"🤪"};return`${a} [${this.name}] ${l[t]||""} ${t.toUpperCase()}: ${i}`}case"minimal":default:return`${a} [${this.name}] ${t}: ${i}`}}error(t,...n){this.shouldLog("error")&&console.error(this.formatMessage("error",t,n))}warn(t,...n){this.shouldLog("warn")&&console.warn(this.formatMessage("warn",t,n))}info(t,...n){this.shouldLog("info")&&console.info(this.formatMessage("info",t,n))}debug(t,...n){this.shouldLog("debug")&&console.debug(this.formatMessage("debug",t,n))}http(t,...n){this.shouldLog("http")&&console.log(this.formatMessage("http",t,n))}verbose(t,...n){this.shouldLog("verbose")&&console.log(this.formatMessage("verbose",t,n))}silly(t,...n){this.shouldLog("silly")&&console.log(this.formatMessage("silly",t,n))}get level(){return this._level}set level(t){this._level=t}setFormat(t){this.format=t}},ze(id,"SimpleConsoleLogger"),id),Zi,lZ=(Zi=class{static get(t=f4){if(!this.instances[t]){const n=typeof process<"u"&&Sp?.DEBUG||void 0;this.instances[t]=new iZ(t,CS(n),this.currentFormat)}return this.instances[t]}static configure(t={}){const{level:n,format:r="minimal"}=t,a=typeof process<"u"&&Sp?.DEBUG||void 0,o=n??CS(a);this.currentFormat=r,Object.values(this.instances).forEach(i=>{i.level=o,i.setFormat(r)})}static setDebug(t){let n;t===2||t===!0?n="debug":n="info",Object.values(this.instances).forEach(r=>{r.level=n}),typeof process<"u"&&Sp&&(Sp.DEBUG=t?t===!0?"2":String(t):"0")}static setFormat(t){this.currentFormat=t,this.configure({format:t})}},ze(Zi,"Logger"),Lg(Zi,"instances",{}),Lg(Zi,"currentFormat","minimal"),Zi),He=lZ.get(),cZ="1.13.3-canary.2";function Tv(){return cZ}ze(Tv,"getPackageVersion");var ld,Yo=(ld=class{},ze(ld,"BaseTelemetryEvent"),ld),cd,uZ=(cd=class extends Yo{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(cd,"MCPAgentExecutionEvent"),cd);function m4(e,t){const n=Array.from(e.registrations.tools.values()),r=Array.from(e.registrations.prompts.values()),a=Array.from(e.registrations.resources.values()),o=Array.from(e.registrations.resourceTemplates.values()),i=a.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})),l=i.filter(m=>m.mime_type==="text/html+skybridge"),u=i.filter(m=>m.mime_type==="text/uri-list"||m.mime_type==="text/html"),f=i.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:i.length>0?i:null,prompts:r.length>0?r.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:o.length>0?o.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:l.length>0?l:null,appsSdkResourcesNumber:l.length,mcpUiResources:u.length>0?u:null,mcpUiResourcesNumber:u.length,mcpAppsResources:f.length>0?f:null,mcpAppsResourcesNumber:f.length}}ze(m4,"createServerRunEventData");var ud,dZ=(ud=class extends Yo{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(ud,"ServerRunEvent"),ud),dd,fZ=(dd=class extends Yo{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(dd,"ServerInitializeEvent"),dd),fd,pZ=(fd=class extends Yo{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(fd,"ServerToolCallEvent"),fd),pd,mZ=(pd=class extends Yo{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(pd,"ServerResourceCallEvent"),pd),md,hZ=(md=class extends Yo{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(md,"ServerPromptCallEvent"),md),hd,gZ=(hd=class extends Yo{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(hd,"ServerContextEvent"),hd),gd,bZ=(gd=class extends Yo{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(gd,"MCPClientInitEvent"),gd),bd,yZ=(bd=class extends Yo{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(bd,"ConnectorInitEvent"),bd),yd,vZ=(yd=class extends Yo{constructor(t){super(),this.data=t}get name(){return"client_add_server"}get properties(){const{serverName:t,serverConfig:n}=this.data,r=n.url;return{server_name:t,server_url_domain:r?this._extractHostname(r):null,transport:n.transport??null,has_auth:!!(n.authToken||n.authProvider)}}_extractHostname(t){try{return new URL(t).hostname}catch{return null}}},ze(yd,"ClientAddServerEvent"),yd),vd,wZ=(vd=class extends Yo{constructor(t){super(),this.data=t}get name(){return"client_remove_server"}get properties(){return{server_name:this.data.serverName}}},ze(vd,"ClientRemoveServerEvent"),vd);function h4(e){return e._llm_type||e.constructor.name.toLowerCase()}ze(h4,"getModelProvider");function g4(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(g4,"getModelName");function xZ(e){return[h4(e),g4(e)]}ze(xZ,"extractModelInfo");function qb(){if(typeof globalThis<"u"&&globalThis.crypto&&typeof globalThis.crypto.randomUUID=="function")return globalThis.crypto.randomUUID();if(typeof globalThis<"u"&&globalThis.crypto&&typeof globalThis.crypto.getRandomValues=="function"){const e=new Uint8Array(16);globalThis.crypto.getRandomValues(e);const t=Array.from(e,n=>n.toString(16).padStart(2,"0")).join("");return`${t.substring(0,8)}-${t.substring(8,12)}-${t.substring(12,16)}-${t.substring(16,20)}-${t.substring(20)}`}return`${Date.now()}-${Math.random().toString(36).substring(2,15)}-${Math.random().toString(36).substring(2,15)}`}ze(qb,"generateUUID");function Xb(){if(typeof window<"u"&&window.crypto&&typeof window.crypto.getRandomValues=="function"){const e=new Uint8Array(8);return window.crypto.getRandomValues(e),Array.from(e,t=>t.toString(16).padStart(2,"0")).join("")}if(typeof globalThis<"u"&&globalThis.crypto&&typeof globalThis.crypto.getRandomValues=="function"){const e=new Uint8Array(8);return globalThis.crypto.getRandomValues(e),Array.from(e,t=>t.toString(16).padStart(2,"0")).join("")}return Math.random().toString(36).substring(2,15)}ze(Xb,"secureRandomString");var Mj="mcp_use_user_id";function Au(){return typeof localStorage<"u"&&typeof localStorage.getItem=="function"&&typeof localStorage.setItem=="function"&&typeof localStorage.removeItem=="function"}ze(Au,"isLocalStorageFunctional");function b4(){try{return typeof window<"u"&&typeof document<"u"?"browser":"unknown"}catch{return"unknown"}}ze(b4,"detectRuntimeEnvironment");function y4(e){if(e==="browser")try{if(Au())return localStorage.setItem("__mcp_use_test__","1"),localStorage.removeItem("__mcp_use_test__"),"localStorage"}catch{}return"session-only"}ze(y4,"getStorageCapability");var Qx=null;function v4(){return Qx===null&&(Qx=b4()),Qx}ze(v4,"getRuntimeEnvironment");var Fo,w4=(Fo=class{PROJECT_API_KEY="phc_lyTtbYwvkdSbrcMQNPiKiiRWrrM1seyKIMjycSvItEI";HOST="https://eu.i.posthog.com";UNKNOWN_USER_ID="UNKNOWN_USER_ID";_currUserId=null;_posthogBrowserClient=null;_posthogLoading=null;_runtimeEnvironment;_storageCapability;_source;constructor(){this._runtimeEnvironment=v4(),this._storageCapability=y4(this._runtimeEnvironment),this._source=this._getSourceFromLocalStorage()||this._runtimeEnvironment;const t=this._checkTelemetryDisabled(),n=this._runtimeEnvironment!=="unknown";t?(this._posthogBrowserClient=null,He.debug("Telemetry disabled via localStorage")):n?(He.info("Anonymized telemetry enabled. Set MCP_USE_ANONYMIZED_TELEMETRY=false in localStorage to disable."),this._posthogLoading=this._initPostHogBrowser()):(this._posthogBrowserClient=null,He.debug(`Telemetry disabled - unknown environment: ${this._runtimeEnvironment}`))}_getSourceFromLocalStorage(){try{if(Au())return localStorage.getItem("MCP_USE_TELEMETRY_SOURCE")}catch{}return null}_checkTelemetryDisabled(){return!!(Au()&&localStorage.getItem("MCP_USE_ANONYMIZED_TELEMETRY")==="false")}async _initPostHogBrowser(){try{const n=await Ua(()=>import("./module-D4IOASh4.js"),[]),r=n.default||n.posthog;if(!r||typeof r.init!="function")throw new Error("posthog-js module did not export expected interface");r.init(this.PROJECT_API_KEY,{api_host:this.HOST,persistence:"localStorage",autocapture:!1,capture_pageview:!1,disable_session_recording:!0,loaded:ze(()=>{He.debug("PostHog browser client initialized")},"loaded")}),this._posthogBrowserClient=r}catch(t){He.warn(`Failed to initialize PostHog browser telemetry: ${t}`),this._posthogBrowserClient=null}}get runtimeEnvironment(){return this._runtimeEnvironment}get storageCapability(){return this._storageCapability}static getInstance(){return Fo.instance||(Fo.instance=new Fo),Fo.instance}setSource(t){this._source=t;try{Au()&&localStorage.setItem("MCP_USE_TELEMETRY_SOURCE",t)}catch{}He.debug(`Telemetry source set to: ${t}`)}getSource(){return this._source}get isEnabled(){return this._posthogBrowserClient!==null}get userId(){if(this._currUserId)return this._currUserId;try{switch(this._storageCapability){case"localStorage":this._currUserId=this._getUserIdFromLocalStorage();break;case"session-only":default:try{this._currUserId=`session-${qb()}`}catch{this._currUserId=`session-${Date.now()}-${Xb()}`}break}}catch{this._currUserId=this.UNKNOWN_USER_ID}return this._currUserId}_getUserIdFromLocalStorage(){try{if(!Au())throw new Error("localStorage is not available or not functional");localStorage.setItem("__mcp_use_test__","1"),localStorage.removeItem("__mcp_use_test__");let t=localStorage.getItem(Mj);if(!t){try{t=qb()}catch{t=`${Date.now()}-${Xb()}`}localStorage.setItem(Mj,t)}return t}catch(t){He.debug(`Failed to access localStorage for user ID: ${t}`);let n;try{n=`session-${qb()}`}catch{n=`session-${Date.now()}-${Xb()}`}return n}}async capture(t){if(this._posthogLoading&&await this._posthogLoading,!this._posthogBrowserClient)return;const n=this.userId,r={...t.properties};if(r.mcp_use_version=Tv(),r.language="typescript",r.source=this._source,r.runtime=this._runtimeEnvironment,this._posthogBrowserClient)try{this._posthogBrowserClient.capture(t.name,{...r,distinct_id:n})}catch(a){He.debug(`Failed to track PostHog Browser event ${t.name}: ${a}`)}}async trackAgentExecution(t){if(!this.isEnabled)return;const n=new uZ(t);await this.capture(n)}async trackServerRunFromServer(t,n){if(!this.isEnabled)return;const r=m4(t,n),a=new dZ(r);await this.capture(a)}async trackServerInitialize(t){if(!this.isEnabled)return;const n=new fZ(t);await this.capture(n)}async trackServerToolCall(t){if(!this.isEnabled)return;const n=new pZ(t);await this.capture(n)}async trackServerResourceCall(t){if(!this.isEnabled)return;const n=new mZ(t);await this.capture(n)}async trackServerPromptCall(t){if(!this.isEnabled)return;const n=new hZ(t);await this.capture(n)}async trackServerContext(t){if(!this.isEnabled)return;const n=new gZ(t);await this.capture(n)}async trackMCPClientInit(t){if(!this.isEnabled)return;const n=new bZ(t);await this.capture(n)}async trackConnectorInit(t){if(!this.isEnabled)return;const n=new yZ(t);await this.capture(n)}async trackClientAddServer(t,n){if(!this.isEnabled)return;const r=new vZ({serverName:t,serverConfig:n});await this.capture(r)}async trackClientRemoveServer(t){if(!this.isEnabled)return;const n=new wZ({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(r){He.debug(`Failed to identify user: ${r}`)}}reset(){if(this._posthogBrowserClient)try{this._posthogBrowserClient.reset()}catch(t){He.debug(`Failed to reset user: ${t}`)}this._currUserId=null}flush(){}shutdown(){}async trackPackageDownload(t){}},ze(Fo,"Telemetry"),Lg(Fo,"instance",null),Fo),rs=w4;function EZ(e){rs.getInstance().setSource(e)}ze(EZ,"setTelemetrySource");const SZ=Object.freeze({status:"aborted"});function Oe(e,t,n){function r(l,u){if(l._zod||Object.defineProperty(l,"_zod",{value:{def:u,constr:i,traits:new Set},enumerable:!1}),l._zod.traits.has(e))return;l._zod.traits.add(e),t(l,u);const f=i.prototype,m=Object.keys(f);for(let h=0;h<m.length;h++){const g=m[h];g in l||(l[g]=f[g].bind(l))}}const a=n?.Parent??Object;class o extends a{}Object.defineProperty(o,"name",{value:e});function i(l){var u;const f=n?.Parent?new o:this;r(f,l),(u=f._zod).deferred??(u.deferred=[]);for(const m of f._zod.deferred)m();return f}return Object.defineProperty(i,"init",{value:r}),Object.defineProperty(i,Symbol.hasInstance,{value:l=>n?.Parent&&l instanceof n.Parent?!0:l?._zod?.traits?.has(e)}),Object.defineProperty(i,"name",{value:e}),i}class Yu extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class x4 extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const RS={};function ol(e){return e&&Object.assign(RS,e),RS}function E4(e){const t=Object.values(e).filter(r=>typeof r=="number");return Object.entries(e).filter(([r,a])=>t.indexOf(+r)===-1).map(([r,a])=>a)}function PTe(e,t="|"){return e.map(n=>RZ(n)).join(t)}function kS(e,t){return typeof t=="bigint"?t.toString():t}function Nv(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function HT(e){return e==null}function VT(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function _Z(e,t){const n=(e.toString().split(".")[1]||"").length,r=t.toString();let a=(r.split(".")[1]||"").length;if(a===0&&/\d?e-\d?/.test(r)){const u=r.match(/\d?e-(\d?)/);u?.[1]&&(a=Number.parseInt(u[1]))}const o=n>a?n:a,i=Number.parseInt(e.toFixed(o).replace(".","")),l=Number.parseInt(t.toFixed(o).replace(".",""));return i%l/10**o}const jj=Symbol("evaluating");function Vn(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==jj)return r===void 0&&(r=jj,r=n()),r},set(a){Object.defineProperty(e,t,{value:a})},configurable:!0})}function wc(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function xc(...e){const t={};for(const n of e){const r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function Pj(e){return JSON.stringify(e)}function TZ(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const S4="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function tm(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const NZ=Nv(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function Id(e){if(tm(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(tm(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function _4(e){return Id(e)?{...e}:Array.isArray(e)?[...e]:e}const CZ=new Set(["string","number","symbol"]);function Od(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function pl(e,t,n){const r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function yt(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 RZ(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function kZ(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const AZ={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]};function IZ(e,t){const n=e._zod.def,r=xc(e._zod.def,{get shape(){const a={};for(const o in t){if(!(o in n.shape))throw new Error(`Unrecognized key: "${o}"`);t[o]&&(a[o]=n.shape[o])}return wc(this,"shape",a),a},checks:[]});return pl(e,r)}function OZ(e,t){const n=e._zod.def,r=xc(e._zod.def,{get shape(){const a={...e._zod.def.shape};for(const o in t){if(!(o in n.shape))throw new Error(`Unrecognized key: "${o}"`);t[o]&&delete a[o]}return wc(this,"shape",a),a},checks:[]});return pl(e,r)}function DZ(e,t){if(!Id(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 a=xc(e._zod.def,{get shape(){const o={...e._zod.def.shape,...t};return wc(this,"shape",o),o},checks:[]});return pl(e,a)}function LZ(e,t){if(!Id(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n={...e._zod.def,get shape(){const r={...e._zod.def.shape,...t};return wc(this,"shape",r),r},checks:e._zod.def.checks};return pl(e,n)}function MZ(e,t){const n=xc(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t._zod.def.shape};return wc(this,"shape",r),r},get catchall(){return t._zod.def.catchall},checks:[]});return pl(e,n)}function jZ(e,t,n){const r=xc(t._zod.def,{get shape(){const a=t._zod.def.shape,o={...a};if(n)for(const i in n){if(!(i in a))throw new Error(`Unrecognized key: "${i}"`);n[i]&&(o[i]=e?new e({type:"optional",innerType:a[i]}):a[i])}else for(const i in a)o[i]=e?new e({type:"optional",innerType:a[i]}):a[i];return wc(this,"shape",o),o},checks:[]});return pl(t,r)}function PZ(e,t,n){const r=xc(t._zod.def,{get shape(){const a=t._zod.def.shape,o={...a};if(n)for(const i in n){if(!(i in o))throw new Error(`Unrecognized key: "${i}"`);n[i]&&(o[i]=new e({type:"nonoptional",innerType:a[i]}))}else for(const i in a)o[i]=new e({type:"nonoptional",innerType:a[i]});return wc(this,"shape",o),o},checks:[]});return pl(t,r)}function Iu(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 Jl(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function Mg(e){return typeof e=="string"?e:e?.message}function sl(e,t,n){const r={...e,path:e.path??[]};if(!e.message){const a=Mg(e.inst?._zod.def?.error?.(e))??Mg(t?.error?.(e))??Mg(n.customError?.(e))??Mg(n.localeError?.(e))??"Invalid input";r.message=a}return delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}function GT(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function nm(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}const T4=(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,kS,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},N4=Oe("$ZodError",T4),Cv=Oe("$ZodError",T4,{Parent:Error});function $Z(e,t=n=>n.message){const n={},r=[];for(const a of e.issues)a.path.length>0?(n[a.path[0]]=n[a.path[0]]||[],n[a.path[0]].push(t(a))):r.push(t(a));return{formErrors:r,fieldErrors:n}}function UZ(e,t=n=>n.message){const n={_errors:[]},r=a=>{for(const o of a.issues)if(o.code==="invalid_union"&&o.errors.length)o.errors.map(i=>r({issues:i}));else if(o.code==="invalid_key")r({issues:o.issues});else if(o.code==="invalid_element")r({issues:o.issues});else if(o.path.length===0)n._errors.push(t(o));else{let i=n,l=0;for(;l<o.path.length;){const u=o.path[l];l===o.path.length-1?(i[u]=i[u]||{_errors:[]},i[u]._errors.push(t(o))):i[u]=i[u]||{_errors:[]},i=i[u],l++}}};return r(e),n}function zZ(e){const t=[],n=e.map(r=>typeof r=="object"?r.key:r);for(const r of n)typeof r=="number"?t.push(`[${r}]`):typeof r=="symbol"?t.push(`[${JSON.stringify(String(r))}]`):/[^\w$]/.test(r)?t.push(`[${JSON.stringify(r)}]`):(t.length&&t.push("."),t.push(r));return t.join("")}function $Te(e){const t=[],n=[...e.issues].sort((r,a)=>(r.path??[]).length-(a.path??[]).length);for(const r of n)t.push(`✖ ${r.message}`),r.path?.length&&t.push(` → at ${zZ(r.path)}`);return t.join(`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-DjyLCU4S.js","assets/index-D598FUk4.js","assets/index-B2NAAQwi.js","assets/llms-BgqhTakm.js","assets/embeddings-DbFJ99yc.js","assets/index-D-0Qb1W2.js","assets/index-CdkiRJxS.js","assets/index-Dqcx9Dh4.js","assets/browser-CsjID3k2.js"])))=>i.map(i=>d[i]);
2
+ var QY=Object.defineProperty;var eZ=(e,t,n)=>t in e?QY(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Lg=(e,t,n)=>eZ(e,typeof t!="symbol"?t+"":t,n);function tZ(e,t){for(var n=0;n<t.length;n++){const r=t[n];if(typeof r!="string"&&!Array.isArray(r)){for(const a in r)if(a!=="default"&&!(a in e)){const o=Object.getOwnPropertyDescriptor(r,a);o&&Object.defineProperty(e,a,o.get?o:{enumerable:!0,get:()=>r[a]})}}}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 a of document.querySelectorAll('link[rel="modulepreload"]'))r(a);new MutationObserver(a=>{for(const o of a)if(o.type==="childList")for(const i of o.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&r(i)}).observe(document,{childList:!0,subtree:!0});function n(a){const o={};return a.integrity&&(o.integrity=a.integrity),a.referrerPolicy&&(o.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?o.credentials="include":a.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function r(a){if(a.ep)return;a.ep=!0;const o=n(a);fetch(a.href,o)}})();function Fm(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function MTe(e){if(Object.prototype.hasOwnProperty.call(e,"__esModule"))return e;var t=e.default;if(typeof t=="function"){var n=function r(){var a=!1;try{a=this instanceof r}catch{}return a?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(r){var a=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(n,r,a.get?a:{enumerable:!0,get:function(){return e[r]}})}),n}var Jx={exports:{}},fp={};var Oj;function nZ(){if(Oj)return fp;Oj=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(r,a,o){var i=null;if(o!==void 0&&(i=""+o),a.key!==void 0&&(i=""+a.key),"key"in a){o={};for(var l in a)l!=="key"&&(o[l]=a[l])}else o=a;return a=o.ref,{$$typeof:e,type:r,key:i,ref:a!==void 0?a:null,props:o}}return fp.Fragment=t,fp.jsx=n,fp.jsxs=n,fp}var Dj;function rZ(){return Dj||(Dj=1,Jx.exports=nZ()),Jx.exports}var d=rZ();const aZ="modulepreload",oZ=function(e){return"/inspector/"+e},Lj={},Ua=function(t,n,r){let a=Promise.resolve();if(n&&n.length>0){let u=function(f){return Promise.all(f.map(m=>Promise.resolve(m).then(h=>({status:"fulfilled",value:h}),h=>({status:"rejected",reason:h}))))};document.getElementsByTagName("link");const i=document.querySelector("meta[property=csp-nonce]"),l=i?.nonce||i?.getAttribute("nonce");a=u(n.map(f=>{if(f=oZ(f),f in Lj)return;Lj[f]=!0;const m=f.endsWith(".css"),h=m?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${f}"]${h}`))return;const g=document.createElement("link");if(g.rel=m?"stylesheet":aZ,m||(g.as="script"),g.crossOrigin="",g.href=f,l&&g.setAttribute("nonce",l),document.head.appendChild(g),m)return new Promise((y,E)=>{g.addEventListener("load",y),g.addEventListener("error",()=>E(new Error(`Unable to preload CSS for ${f}`)))})}))}function o(i){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=i,window.dispatchEvent(l),!l.defaultPrevented)throw i}return a.then(i=>{for(const l of i||[])l.status==="rejected"&&o(l.reason);return t().catch(o)})};var sZ=Object.defineProperty,ze=(e,t)=>sZ(e,"name",{value:t,configurable:!0}),jTe=(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')});function i4(e){return e==="localhost"||e==="127.0.0.1"||e.startsWith("127.")||e.startsWith("192.168.")||e.startsWith("10.")||e.startsWith("172.")}ze(i4,"isLocalServer");function l4(e){const t=e.split("."),n=[];for(let r=0;r<t.length-1;r++)n.push(t.slice(r).join("."));return n}ze(l4,"getSubdomainLevels");function c4(e){return new Promise((t,n)=>{const r=new FileReader;r.onloadend=()=>{t(r.result)},r.onerror=n,r.readAsDataURL(e)})}ze(c4,"blobToBase64");async function u4(e){console.debug("[favicon-detector] Starting favicon detection for:",e);try{let t;if(e.startsWith("http://")||e.startsWith("https://")?t=new URL(e).hostname:e.includes("://")?t=e.split("://")[1].split("/")[0]:t=e.split("/")[0],console.debug("[favicon-detector] Extracted domain:",t),i4(t))return console.debug("[favicon-detector] Skipping local server:",t),null;const n=l4(t);console.debug("[favicon-detector] Domains to try:",n);for(const r of n)try{const a=`https://favicon.tools.mcp-use.com/${r}?response=json`;console.debug("[favicon-detector] Attempting to fetch favicon metadata for:",r,"from:",a);const o=new AbortController,i=setTimeout(()=>o.abort(),2e3);try{const l=await fetch(a,{signal:o.signal});if(clearTimeout(i),!l.ok){console.debug("[favicon-detector] Fetch failed for",r,"with status:",l.status);continue}const u=await l.json();console.debug("[favicon-detector] Retrieved favicon metadata for:",r,"source:",u.source);const f=u.url.replace(/^http:\/\//,"https://"),m=await fetch(f);if(!m.ok){console.debug("[favicon-detector] Failed to fetch favicon image for",r,"status:",m.status);continue}const h=await m.blob(),g=await c4(h);if(u.source==="default"){console.debug("[favicon-detector] Found default favicon for:",r,"skipping and continuing to search for non-default");continue}return console.debug("[favicon-detector] Successfully retrieved non-default favicon for:",r,"source:",u.source,"size:",h.size,"bytes"),g}catch(l){clearTimeout(i),console.debug("[favicon-detector] Fetch error for",r,":",l instanceof Error?l.message:String(l));continue}}catch(a){console.debug("[favicon-detector] Error processing domain",r,":",a instanceof Error?a.message:String(a));continue}return console.debug("[favicon-detector] No non-default favicon found for:",e,"returning null to show gradient fallback"),null}catch(t){return console.warn("[favicon-detector] Error detecting favicon:",t),null}}ze(u4,"detectFavicon");function d4(e,t){const n=t?.headers??t?.customHeaders??{};if(t?.customHeaders&&!t?.headers&&console.warn('[applyProxyConfig] The "customHeaders" option in proxyConfig is deprecated. Use "headers" instead.'),!t?.proxyAddress)return{url:e,headers:n};const r=new URL(t.proxyAddress),a=new URL(e),o=`${r.origin}${r.pathname}${a.pathname}${a.search}`,i={"X-Target-URL":e,...n};return{url:o,headers:i}}ze(d4,"applyProxyConfig");var Sp={},f4="mcp-use";function CS(e){switch((typeof process<"u"&&Sp?e:void 0)?.trim()){case"2":return"debug";case"1":return"info";default:return"info"}}ze(CS,"resolveLevel");function p4(e){return e.length===0?"":e.map(t=>{if(typeof t=="string")return t;try{return JSON.stringify(t)}catch{return String(t)}}).join(" ")}ze(p4,"formatArgs");var id,iZ=(id=class{_level;name;format;constructor(t=f4,n="info",r="minimal"){this.name=t,this._level=n,this.format=r}shouldLog(t){const n=["error","warn","info","http","verbose","debug","silly"],r=n.indexOf(this._level);return n.indexOf(t)<=r}formatMessage(t,n,r){const a=new Date().toLocaleTimeString("en-US",{hour12:!1}),o=p4(r),i=o?`${n} ${o}`:n;switch(this.format){case"detailed":return`${a} [${this.name}] ${t.toUpperCase()}: ${i}`;case"emoji":{const l={error:"❌",warn:"⚠️",info:"ℹ️",http:"🌐",verbose:"📝",debug:"🔍",silly:"🤪"};return`${a} [${this.name}] ${l[t]||""} ${t.toUpperCase()}: ${i}`}case"minimal":default:return`${a} [${this.name}] ${t}: ${i}`}}error(t,...n){this.shouldLog("error")&&console.error(this.formatMessage("error",t,n))}warn(t,...n){this.shouldLog("warn")&&console.warn(this.formatMessage("warn",t,n))}info(t,...n){this.shouldLog("info")&&console.info(this.formatMessage("info",t,n))}debug(t,...n){this.shouldLog("debug")&&console.debug(this.formatMessage("debug",t,n))}http(t,...n){this.shouldLog("http")&&console.log(this.formatMessage("http",t,n))}verbose(t,...n){this.shouldLog("verbose")&&console.log(this.formatMessage("verbose",t,n))}silly(t,...n){this.shouldLog("silly")&&console.log(this.formatMessage("silly",t,n))}get level(){return this._level}set level(t){this._level=t}setFormat(t){this.format=t}},ze(id,"SimpleConsoleLogger"),id),Zi,lZ=(Zi=class{static get(t=f4){if(!this.instances[t]){const n=typeof process<"u"&&Sp?.DEBUG||void 0;this.instances[t]=new iZ(t,CS(n),this.currentFormat)}return this.instances[t]}static configure(t={}){const{level:n,format:r="minimal"}=t,a=typeof process<"u"&&Sp?.DEBUG||void 0,o=n??CS(a);this.currentFormat=r,Object.values(this.instances).forEach(i=>{i.level=o,i.setFormat(r)})}static setDebug(t){let n;t===2||t===!0?n="debug":n="info",Object.values(this.instances).forEach(r=>{r.level=n}),typeof process<"u"&&Sp&&(Sp.DEBUG=t?t===!0?"2":String(t):"0")}static setFormat(t){this.currentFormat=t,this.configure({format:t})}},ze(Zi,"Logger"),Lg(Zi,"instances",{}),Lg(Zi,"currentFormat","minimal"),Zi),He=lZ.get(),cZ="1.13.3";function Tv(){return cZ}ze(Tv,"getPackageVersion");var ld,Yo=(ld=class{},ze(ld,"BaseTelemetryEvent"),ld),cd,uZ=(cd=class extends Yo{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(cd,"MCPAgentExecutionEvent"),cd);function m4(e,t){const n=Array.from(e.registrations.tools.values()),r=Array.from(e.registrations.prompts.values()),a=Array.from(e.registrations.resources.values()),o=Array.from(e.registrations.resourceTemplates.values()),i=a.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})),l=i.filter(m=>m.mime_type==="text/html+skybridge"),u=i.filter(m=>m.mime_type==="text/uri-list"||m.mime_type==="text/html"),f=i.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:i.length>0?i:null,prompts:r.length>0?r.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:o.length>0?o.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:l.length>0?l:null,appsSdkResourcesNumber:l.length,mcpUiResources:u.length>0?u:null,mcpUiResourcesNumber:u.length,mcpAppsResources:f.length>0?f:null,mcpAppsResourcesNumber:f.length}}ze(m4,"createServerRunEventData");var ud,dZ=(ud=class extends Yo{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(ud,"ServerRunEvent"),ud),dd,fZ=(dd=class extends Yo{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(dd,"ServerInitializeEvent"),dd),fd,pZ=(fd=class extends Yo{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(fd,"ServerToolCallEvent"),fd),pd,mZ=(pd=class extends Yo{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(pd,"ServerResourceCallEvent"),pd),md,hZ=(md=class extends Yo{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(md,"ServerPromptCallEvent"),md),hd,gZ=(hd=class extends Yo{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(hd,"ServerContextEvent"),hd),gd,bZ=(gd=class extends Yo{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(gd,"MCPClientInitEvent"),gd),bd,yZ=(bd=class extends Yo{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(bd,"ConnectorInitEvent"),bd),yd,vZ=(yd=class extends Yo{constructor(t){super(),this.data=t}get name(){return"client_add_server"}get properties(){const{serverName:t,serverConfig:n}=this.data,r=n.url;return{server_name:t,server_url_domain:r?this._extractHostname(r):null,transport:n.transport??null,has_auth:!!(n.authToken||n.authProvider)}}_extractHostname(t){try{return new URL(t).hostname}catch{return null}}},ze(yd,"ClientAddServerEvent"),yd),vd,wZ=(vd=class extends Yo{constructor(t){super(),this.data=t}get name(){return"client_remove_server"}get properties(){return{server_name:this.data.serverName}}},ze(vd,"ClientRemoveServerEvent"),vd);function h4(e){return e._llm_type||e.constructor.name.toLowerCase()}ze(h4,"getModelProvider");function g4(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(g4,"getModelName");function xZ(e){return[h4(e),g4(e)]}ze(xZ,"extractModelInfo");function qb(){if(typeof globalThis<"u"&&globalThis.crypto&&typeof globalThis.crypto.randomUUID=="function")return globalThis.crypto.randomUUID();if(typeof globalThis<"u"&&globalThis.crypto&&typeof globalThis.crypto.getRandomValues=="function"){const e=new Uint8Array(16);globalThis.crypto.getRandomValues(e);const t=Array.from(e,n=>n.toString(16).padStart(2,"0")).join("");return`${t.substring(0,8)}-${t.substring(8,12)}-${t.substring(12,16)}-${t.substring(16,20)}-${t.substring(20)}`}return`${Date.now()}-${Math.random().toString(36).substring(2,15)}-${Math.random().toString(36).substring(2,15)}`}ze(qb,"generateUUID");function Xb(){if(typeof window<"u"&&window.crypto&&typeof window.crypto.getRandomValues=="function"){const e=new Uint8Array(8);return window.crypto.getRandomValues(e),Array.from(e,t=>t.toString(16).padStart(2,"0")).join("")}if(typeof globalThis<"u"&&globalThis.crypto&&typeof globalThis.crypto.getRandomValues=="function"){const e=new Uint8Array(8);return globalThis.crypto.getRandomValues(e),Array.from(e,t=>t.toString(16).padStart(2,"0")).join("")}return Math.random().toString(36).substring(2,15)}ze(Xb,"secureRandomString");var Mj="mcp_use_user_id";function Au(){return typeof localStorage<"u"&&typeof localStorage.getItem=="function"&&typeof localStorage.setItem=="function"&&typeof localStorage.removeItem=="function"}ze(Au,"isLocalStorageFunctional");function b4(){try{return typeof window<"u"&&typeof document<"u"?"browser":"unknown"}catch{return"unknown"}}ze(b4,"detectRuntimeEnvironment");function y4(e){if(e==="browser")try{if(Au())return localStorage.setItem("__mcp_use_test__","1"),localStorage.removeItem("__mcp_use_test__"),"localStorage"}catch{}return"session-only"}ze(y4,"getStorageCapability");var Qx=null;function v4(){return Qx===null&&(Qx=b4()),Qx}ze(v4,"getRuntimeEnvironment");var Fo,w4=(Fo=class{PROJECT_API_KEY="phc_lyTtbYwvkdSbrcMQNPiKiiRWrrM1seyKIMjycSvItEI";HOST="https://eu.i.posthog.com";UNKNOWN_USER_ID="UNKNOWN_USER_ID";_currUserId=null;_posthogBrowserClient=null;_posthogLoading=null;_runtimeEnvironment;_storageCapability;_source;constructor(){this._runtimeEnvironment=v4(),this._storageCapability=y4(this._runtimeEnvironment),this._source=this._getSourceFromLocalStorage()||this._runtimeEnvironment;const t=this._checkTelemetryDisabled(),n=this._runtimeEnvironment!=="unknown";t?(this._posthogBrowserClient=null,He.debug("Telemetry disabled via localStorage")):n?(He.info("Anonymized telemetry enabled. Set MCP_USE_ANONYMIZED_TELEMETRY=false in localStorage to disable."),this._posthogLoading=this._initPostHogBrowser()):(this._posthogBrowserClient=null,He.debug(`Telemetry disabled - unknown environment: ${this._runtimeEnvironment}`))}_getSourceFromLocalStorage(){try{if(Au())return localStorage.getItem("MCP_USE_TELEMETRY_SOURCE")}catch{}return null}_checkTelemetryDisabled(){return!!(Au()&&localStorage.getItem("MCP_USE_ANONYMIZED_TELEMETRY")==="false")}async _initPostHogBrowser(){try{const n=await Ua(()=>import("./module-D4IOASh4.js"),[]),r=n.default||n.posthog;if(!r||typeof r.init!="function")throw new Error("posthog-js module did not export expected interface");r.init(this.PROJECT_API_KEY,{api_host:this.HOST,persistence:"localStorage",autocapture:!1,capture_pageview:!1,disable_session_recording:!0,loaded:ze(()=>{He.debug("PostHog browser client initialized")},"loaded")}),this._posthogBrowserClient=r}catch(t){He.warn(`Failed to initialize PostHog browser telemetry: ${t}`),this._posthogBrowserClient=null}}get runtimeEnvironment(){return this._runtimeEnvironment}get storageCapability(){return this._storageCapability}static getInstance(){return Fo.instance||(Fo.instance=new Fo),Fo.instance}setSource(t){this._source=t;try{Au()&&localStorage.setItem("MCP_USE_TELEMETRY_SOURCE",t)}catch{}He.debug(`Telemetry source set to: ${t}`)}getSource(){return this._source}get isEnabled(){return this._posthogBrowserClient!==null}get userId(){if(this._currUserId)return this._currUserId;try{switch(this._storageCapability){case"localStorage":this._currUserId=this._getUserIdFromLocalStorage();break;case"session-only":default:try{this._currUserId=`session-${qb()}`}catch{this._currUserId=`session-${Date.now()}-${Xb()}`}break}}catch{this._currUserId=this.UNKNOWN_USER_ID}return this._currUserId}_getUserIdFromLocalStorage(){try{if(!Au())throw new Error("localStorage is not available or not functional");localStorage.setItem("__mcp_use_test__","1"),localStorage.removeItem("__mcp_use_test__");let t=localStorage.getItem(Mj);if(!t){try{t=qb()}catch{t=`${Date.now()}-${Xb()}`}localStorage.setItem(Mj,t)}return t}catch(t){He.debug(`Failed to access localStorage for user ID: ${t}`);let n;try{n=`session-${qb()}`}catch{n=`session-${Date.now()}-${Xb()}`}return n}}async capture(t){if(this._posthogLoading&&await this._posthogLoading,!this._posthogBrowserClient)return;const n=this.userId,r={...t.properties};if(r.mcp_use_version=Tv(),r.language="typescript",r.source=this._source,r.runtime=this._runtimeEnvironment,this._posthogBrowserClient)try{this._posthogBrowserClient.capture(t.name,{...r,distinct_id:n})}catch(a){He.debug(`Failed to track PostHog Browser event ${t.name}: ${a}`)}}async trackAgentExecution(t){if(!this.isEnabled)return;const n=new uZ(t);await this.capture(n)}async trackServerRunFromServer(t,n){if(!this.isEnabled)return;const r=m4(t,n),a=new dZ(r);await this.capture(a)}async trackServerInitialize(t){if(!this.isEnabled)return;const n=new fZ(t);await this.capture(n)}async trackServerToolCall(t){if(!this.isEnabled)return;const n=new pZ(t);await this.capture(n)}async trackServerResourceCall(t){if(!this.isEnabled)return;const n=new mZ(t);await this.capture(n)}async trackServerPromptCall(t){if(!this.isEnabled)return;const n=new hZ(t);await this.capture(n)}async trackServerContext(t){if(!this.isEnabled)return;const n=new gZ(t);await this.capture(n)}async trackMCPClientInit(t){if(!this.isEnabled)return;const n=new bZ(t);await this.capture(n)}async trackConnectorInit(t){if(!this.isEnabled)return;const n=new yZ(t);await this.capture(n)}async trackClientAddServer(t,n){if(!this.isEnabled)return;const r=new vZ({serverName:t,serverConfig:n});await this.capture(r)}async trackClientRemoveServer(t){if(!this.isEnabled)return;const n=new wZ({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(r){He.debug(`Failed to identify user: ${r}`)}}reset(){if(this._posthogBrowserClient)try{this._posthogBrowserClient.reset()}catch(t){He.debug(`Failed to reset user: ${t}`)}this._currUserId=null}flush(){}shutdown(){}async trackPackageDownload(t){}},ze(Fo,"Telemetry"),Lg(Fo,"instance",null),Fo),rs=w4;function EZ(e){rs.getInstance().setSource(e)}ze(EZ,"setTelemetrySource");const SZ=Object.freeze({status:"aborted"});function Oe(e,t,n){function r(l,u){if(l._zod||Object.defineProperty(l,"_zod",{value:{def:u,constr:i,traits:new Set},enumerable:!1}),l._zod.traits.has(e))return;l._zod.traits.add(e),t(l,u);const f=i.prototype,m=Object.keys(f);for(let h=0;h<m.length;h++){const g=m[h];g in l||(l[g]=f[g].bind(l))}}const a=n?.Parent??Object;class o extends a{}Object.defineProperty(o,"name",{value:e});function i(l){var u;const f=n?.Parent?new o:this;r(f,l),(u=f._zod).deferred??(u.deferred=[]);for(const m of f._zod.deferred)m();return f}return Object.defineProperty(i,"init",{value:r}),Object.defineProperty(i,Symbol.hasInstance,{value:l=>n?.Parent&&l instanceof n.Parent?!0:l?._zod?.traits?.has(e)}),Object.defineProperty(i,"name",{value:e}),i}class Yu extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class x4 extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const RS={};function ol(e){return e&&Object.assign(RS,e),RS}function E4(e){const t=Object.values(e).filter(r=>typeof r=="number");return Object.entries(e).filter(([r,a])=>t.indexOf(+r)===-1).map(([r,a])=>a)}function PTe(e,t="|"){return e.map(n=>RZ(n)).join(t)}function kS(e,t){return typeof t=="bigint"?t.toString():t}function Nv(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function HT(e){return e==null}function VT(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function _Z(e,t){const n=(e.toString().split(".")[1]||"").length,r=t.toString();let a=(r.split(".")[1]||"").length;if(a===0&&/\d?e-\d?/.test(r)){const u=r.match(/\d?e-(\d?)/);u?.[1]&&(a=Number.parseInt(u[1]))}const o=n>a?n:a,i=Number.parseInt(e.toFixed(o).replace(".","")),l=Number.parseInt(t.toFixed(o).replace(".",""));return i%l/10**o}const jj=Symbol("evaluating");function Vn(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==jj)return r===void 0&&(r=jj,r=n()),r},set(a){Object.defineProperty(e,t,{value:a})},configurable:!0})}function wc(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function xc(...e){const t={};for(const n of e){const r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function Pj(e){return JSON.stringify(e)}function TZ(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const S4="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function tm(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const NZ=Nv(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function Id(e){if(tm(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(tm(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function _4(e){return Id(e)?{...e}:Array.isArray(e)?[...e]:e}const CZ=new Set(["string","number","symbol"]);function Od(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function pl(e,t,n){const r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function yt(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 RZ(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function kZ(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const AZ={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]};function IZ(e,t){const n=e._zod.def,r=xc(e._zod.def,{get shape(){const a={};for(const o in t){if(!(o in n.shape))throw new Error(`Unrecognized key: "${o}"`);t[o]&&(a[o]=n.shape[o])}return wc(this,"shape",a),a},checks:[]});return pl(e,r)}function OZ(e,t){const n=e._zod.def,r=xc(e._zod.def,{get shape(){const a={...e._zod.def.shape};for(const o in t){if(!(o in n.shape))throw new Error(`Unrecognized key: "${o}"`);t[o]&&delete a[o]}return wc(this,"shape",a),a},checks:[]});return pl(e,r)}function DZ(e,t){if(!Id(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 a=xc(e._zod.def,{get shape(){const o={...e._zod.def.shape,...t};return wc(this,"shape",o),o},checks:[]});return pl(e,a)}function LZ(e,t){if(!Id(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n={...e._zod.def,get shape(){const r={...e._zod.def.shape,...t};return wc(this,"shape",r),r},checks:e._zod.def.checks};return pl(e,n)}function MZ(e,t){const n=xc(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t._zod.def.shape};return wc(this,"shape",r),r},get catchall(){return t._zod.def.catchall},checks:[]});return pl(e,n)}function jZ(e,t,n){const r=xc(t._zod.def,{get shape(){const a=t._zod.def.shape,o={...a};if(n)for(const i in n){if(!(i in a))throw new Error(`Unrecognized key: "${i}"`);n[i]&&(o[i]=e?new e({type:"optional",innerType:a[i]}):a[i])}else for(const i in a)o[i]=e?new e({type:"optional",innerType:a[i]}):a[i];return wc(this,"shape",o),o},checks:[]});return pl(t,r)}function PZ(e,t,n){const r=xc(t._zod.def,{get shape(){const a=t._zod.def.shape,o={...a};if(n)for(const i in n){if(!(i in o))throw new Error(`Unrecognized key: "${i}"`);n[i]&&(o[i]=new e({type:"nonoptional",innerType:a[i]}))}else for(const i in a)o[i]=new e({type:"nonoptional",innerType:a[i]});return wc(this,"shape",o),o},checks:[]});return pl(t,r)}function Iu(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 Jl(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function Mg(e){return typeof e=="string"?e:e?.message}function sl(e,t,n){const r={...e,path:e.path??[]};if(!e.message){const a=Mg(e.inst?._zod.def?.error?.(e))??Mg(t?.error?.(e))??Mg(n.customError?.(e))??Mg(n.localeError?.(e))??"Invalid input";r.message=a}return delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}function GT(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function nm(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}const T4=(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,kS,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},N4=Oe("$ZodError",T4),Cv=Oe("$ZodError",T4,{Parent:Error});function $Z(e,t=n=>n.message){const n={},r=[];for(const a of e.issues)a.path.length>0?(n[a.path[0]]=n[a.path[0]]||[],n[a.path[0]].push(t(a))):r.push(t(a));return{formErrors:r,fieldErrors:n}}function UZ(e,t=n=>n.message){const n={_errors:[]},r=a=>{for(const o of a.issues)if(o.code==="invalid_union"&&o.errors.length)o.errors.map(i=>r({issues:i}));else if(o.code==="invalid_key")r({issues:o.issues});else if(o.code==="invalid_element")r({issues:o.issues});else if(o.path.length===0)n._errors.push(t(o));else{let i=n,l=0;for(;l<o.path.length;){const u=o.path[l];l===o.path.length-1?(i[u]=i[u]||{_errors:[]},i[u]._errors.push(t(o))):i[u]=i[u]||{_errors:[]},i=i[u],l++}}};return r(e),n}function zZ(e){const t=[],n=e.map(r=>typeof r=="object"?r.key:r);for(const r of n)typeof r=="number"?t.push(`[${r}]`):typeof r=="symbol"?t.push(`[${JSON.stringify(String(r))}]`):/[^\w$]/.test(r)?t.push(`[${JSON.stringify(r)}]`):(t.length&&t.push("."),t.push(r));return t.join("")}function $Te(e){const t=[],n=[...e.issues].sort((r,a)=>(r.path??[]).length-(a.path??[]).length);for(const r of n)t.push(`✖ ${r.message}`),r.path?.length&&t.push(` → at ${zZ(r.path)}`);return t.join(`
3
3
  `)}const Rv=e=>(t,n,r,a)=>{const o=r?Object.assign(r,{async:!1}):{async:!1},i=t._zod.run({value:n,issues:[]},o);if(i instanceof Promise)throw new Yu;if(i.issues.length){const l=new(a?.Err??e)(i.issues.map(u=>sl(u,o,ol())));throw S4(l,a?.callee),l}return i.value},UTe=Rv(Cv),kv=e=>async(t,n,r,a)=>{const o=r?Object.assign(r,{async:!0}):{async:!0};let i=t._zod.run({value:n,issues:[]},o);if(i instanceof Promise&&(i=await i),i.issues.length){const l=new(a?.Err??e)(i.issues.map(u=>sl(u,o,ol())));throw S4(l,a?.callee),l}return i.value},zTe=kv(Cv),Av=e=>(t,n,r)=>{const a=r?{...r,async:!1}:{async:!1},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise)throw new Yu;return o.issues.length?{success:!1,error:new(e??N4)(o.issues.map(i=>sl(i,a,ol())))}:{success:!0,data:o.value}},C4=Av(Cv),Iv=e=>async(t,n,r)=>{const a=r?Object.assign(r,{async:!0}):{async:!0};let o=t._zod.run({value:n,issues:[]},a);return o instanceof Promise&&(o=await o),o.issues.length?{success:!1,error:new e(o.issues.map(i=>sl(i,a,ol())))}:{success:!0,data:o.value}},FZ=Iv(Cv),BZ=e=>(t,n,r)=>{const a=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Rv(e)(t,n,a)},HZ=e=>(t,n,r)=>Rv(e)(t,n,r),VZ=e=>async(t,n,r)=>{const a=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return kv(e)(t,n,a)},GZ=e=>async(t,n,r)=>kv(e)(t,n,r),WZ=e=>(t,n,r)=>{const a=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Av(e)(t,n,a)},KZ=e=>(t,n,r)=>Av(e)(t,n,r),YZ=e=>async(t,n,r)=>{const a=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Iv(e)(t,n,a)},ZZ=e=>async(t,n,r)=>Iv(e)(t,n,r),qZ=/^[cC][^\s-]{8,}$/,XZ=/^[0-9a-z]+$/,JZ=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,QZ=/^[0-9a-vA-V]{20}$/,eq=/^[A-Za-z0-9]{27}$/,tq=/^[a-zA-Z0-9_-]{21}$/,nq=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,rq=/^([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})$/,$j=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)$/,aq=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,oq="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function sq(){return new RegExp(oq,"u")}const iq=/^(?:(?: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])$/,lq=/^(([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}|:))$/,cq=/^((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])$/,uq=/^(([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])$/,dq=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,R4=/^[A-Za-z0-9_-]*$/,fq=/^\+(?:[0-9]){6,14}[0-9]$/,k4="(?:(?:\\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])))",pq=new RegExp(`^${k4}$`);function A4(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 mq(e){return new RegExp(`^${A4(e)}$`)}function hq(e){const t=A4({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const r=`${t}(?:${n.join("|")})`;return new RegExp(`^${k4}T(?:${r})$`)}const gq=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},bq=/^-?\d+$/,yq=/^-?\d+(?:\.\d+)?/,vq=/^(?:true|false)$/i,wq=/^null$/i,xq=/^[^A-Z]*$/,Eq=/^[^a-z]*$/,Ba=Oe("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),I4={number:"number",bigint:"bigint",object:"date"},O4=Oe("$ZodCheckLessThan",(e,t)=>{Ba.init(e,t);const n=I4[typeof t.value];e._zod.onattach.push(r=>{const a=r._zod.bag,o=(t.inclusive?a.maximum:a.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<o&&(t.inclusive?a.maximum=t.value:a.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:"too_big",maximum:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),D4=Oe("$ZodCheckGreaterThan",(e,t)=>{Ba.init(e,t);const n=I4[typeof t.value];e._zod.onattach.push(r=>{const a=r._zod.bag,o=(t.inclusive?a.minimum:a.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>o&&(t.inclusive?a.minimum=t.value:a.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:"too_small",minimum:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Sq=Oe("$ZodCheckMultipleOf",(e,t)=>{Ba.init(e,t),e._zod.onattach.push(n=>{var r;(r=n._zod.bag).multipleOf??(r.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):_Z(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})}}),_q=Oe("$ZodCheckNumberFormat",(e,t)=>{Ba.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),r=n?"int":"number",[a,o]=AZ[t.format];e._zod.onattach.push(i=>{const l=i._zod.bag;l.format=t.format,l.minimum=a,l.maximum=o,n&&(l.pattern=bq)}),e._zod.check=i=>{const l=i.value;if(n){if(!Number.isInteger(l)){i.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:l,inst:e});return}if(!Number.isSafeInteger(l)){l>0?i.issues.push({input:l,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,continue:!t.abort}):i.issues.push({input:l,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,continue:!t.abort});return}}l<a&&i.issues.push({origin:"number",input:l,code:"too_small",minimum:a,inclusive:!0,inst:e,continue:!t.abort}),l>o&&i.issues.push({origin:"number",input:l,code:"too_big",maximum:o,inst:e})}}),Tq=Oe("$ZodCheckMaxLength",(e,t)=>{var n;Ba.init(e,t),(n=e._zod.def).when??(n.when=r=>{const a=r.value;return!HT(a)&&a.length!==void 0}),e._zod.onattach.push(r=>{const a=r._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<a&&(r._zod.bag.maximum=t.maximum)}),e._zod.check=r=>{const a=r.value;if(a.length<=t.maximum)return;const i=GT(a);r.issues.push({origin:i,code:"too_big",maximum:t.maximum,inclusive:!0,input:a,inst:e,continue:!t.abort})}}),Nq=Oe("$ZodCheckMinLength",(e,t)=>{var n;Ba.init(e,t),(n=e._zod.def).when??(n.when=r=>{const a=r.value;return!HT(a)&&a.length!==void 0}),e._zod.onattach.push(r=>{const a=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>a&&(r._zod.bag.minimum=t.minimum)}),e._zod.check=r=>{const a=r.value;if(a.length>=t.minimum)return;const i=GT(a);r.issues.push({origin:i,code:"too_small",minimum:t.minimum,inclusive:!0,input:a,inst:e,continue:!t.abort})}}),Cq=Oe("$ZodCheckLengthEquals",(e,t)=>{var n;Ba.init(e,t),(n=e._zod.def).when??(n.when=r=>{const a=r.value;return!HT(a)&&a.length!==void 0}),e._zod.onattach.push(r=>{const a=r._zod.bag;a.minimum=t.length,a.maximum=t.length,a.length=t.length}),e._zod.check=r=>{const a=r.value,o=a.length;if(o===t.length)return;const i=GT(a),l=o>t.length;r.issues.push({origin:i,...l?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),Ov=Oe("$ZodCheckStringFormat",(e,t)=>{var n,r;Ba.init(e,t),e._zod.onattach.push(a=>{const o=a._zod.bag;o.format=t.format,t.pattern&&(o.patterns??(o.patterns=new Set),o.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=a=>{t.pattern.lastIndex=0,!t.pattern.test(a.value)&&a.issues.push({origin:"string",code:"invalid_format",format:t.format,input:a.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),Rq=Oe("$ZodCheckRegex",(e,t)=>{Ov.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})}}),kq=Oe("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=xq),Ov.init(e,t)}),Aq=Oe("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Eq),Ov.init(e,t)}),Iq=Oe("$ZodCheckIncludes",(e,t)=>{Ba.init(e,t);const n=Od(t.includes),r=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(a=>{const o=a._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(r)}),e._zod.check=a=>{a.value.includes(t.includes,t.position)||a.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:a.value,inst:e,continue:!t.abort})}}),Oq=Oe("$ZodCheckStartsWith",(e,t)=>{Ba.init(e,t);const n=new RegExp(`^${Od(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const a=r._zod.bag;a.patterns??(a.patterns=new Set),a.patterns.add(n)}),e._zod.check=r=>{r.value.startsWith(t.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),Dq=Oe("$ZodCheckEndsWith",(e,t)=>{Ba.init(e,t);const n=new RegExp(`.*${Od(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const a=r._zod.bag;a.patterns??(a.patterns=new Set),a.patterns.add(n)}),e._zod.check=r=>{r.value.endsWith(t.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}}),Lq=Oe("$ZodCheckOverwrite",(e,t)=>{Ba.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class Mq{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 r=t.split(`
4
4
  `).filter(i=>i),a=Math.min(...r.map(i=>i.length-i.trimStart().length)),o=r.map(i=>i.slice(a)).map(i=>" ".repeat(this.indent*2)+i);for(const i of o)this.content.push(i)}compile(){const t=Function,n=this?.args,a=[...(this?.content??[""]).map(o=>` ${o}`)];return new t(...n,a.join(`
5
5
  `))}}const jq={major:4,minor:2,patch:0},Gn=Oe("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=jq;const r=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&r.unshift(e);for(const a of r)for(const o of a._zod.onattach)o(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const a=(i,l,u)=>{let f=Iu(i),m;for(const h of l){if(h._zod.def.when){if(!h._zod.def.when(i))continue}else if(f)continue;const g=i.issues.length,y=h._zod.check(i);if(y instanceof Promise&&u?.async===!1)throw new Yu;if(m||y instanceof Promise)m=(m??Promise.resolve()).then(async()=>{await y,i.issues.length!==g&&(f||(f=Iu(i,g)))});else{if(i.issues.length===g)continue;f||(f=Iu(i,g))}}return m?m.then(()=>i):i},o=(i,l,u)=>{if(Iu(i))return i.aborted=!0,i;const f=a(l,r,u);if(f instanceof Promise){if(u.async===!1)throw new Yu;return f.then(m=>e._zod.parse(m,u))}return e._zod.parse(f,u)};e._zod.run=(i,l)=>{if(l.skipChecks)return e._zod.parse(i,l);if(l.direction==="backward"){const f=e._zod.parse({value:i.value,issues:[]},{...l,skipChecks:!0});return f instanceof Promise?f.then(m=>o(m,i,l)):o(f,i,l)}const u=e._zod.parse(i,l);if(u instanceof Promise){if(l.async===!1)throw new Yu;return u.then(f=>a(f,r,l))}return a(u,r,l)}}e["~standard"]={validate:a=>{try{const o=C4(e,a);return o.success?{value:o.data}:{issues:o.error?.issues}}catch{return FZ(e,a).then(i=>i.success?{value:i.data}:{issues:i.error?.issues})}},vendor:"zod",version:1}}),WT=Oe("$ZodString",(e,t)=>{Gn.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??gq(e._zod.bag),e._zod.parse=(n,r)=>{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}}),lr=Oe("$ZodStringFormat",(e,t)=>{Ov.init(e,t),WT.init(e,t)}),Pq=Oe("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=rq),lr.init(e,t)}),$q=Oe("$ZodUUID",(e,t)=>{if(t.version){const r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(r===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=$j(r))}else t.pattern??(t.pattern=$j());lr.init(e,t)}),Uq=Oe("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=aq),lr.init(e,t)}),zq=Oe("$ZodURL",(e,t)=>{lr.init(e,t),e._zod.check=n=>{try{const r=n.value.trim(),a=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(a.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(a.protocol.endsWith(":")?a.protocol.slice(0,-1):a.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=a.href:n.value=r;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),Fq=Oe("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=sq()),lr.init(e,t)}),Bq=Oe("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=tq),lr.init(e,t)}),Hq=Oe("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=qZ),lr.init(e,t)}),Vq=Oe("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=XZ),lr.init(e,t)}),Gq=Oe("$ZodULID",(e,t)=>{t.pattern??(t.pattern=JZ),lr.init(e,t)}),Wq=Oe("$ZodXID",(e,t)=>{t.pattern??(t.pattern=QZ),lr.init(e,t)}),Kq=Oe("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=eq),lr.init(e,t)}),Yq=Oe("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=hq(t)),lr.init(e,t)}),Zq=Oe("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=pq),lr.init(e,t)}),qq=Oe("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=mq(t)),lr.init(e,t)}),Xq=Oe("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=nq),lr.init(e,t)}),Jq=Oe("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=iq),lr.init(e,t),e._zod.bag.format="ipv4"}),Qq=Oe("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=lq),lr.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})}}}),eX=Oe("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=cq),lr.init(e,t)}),tX=Oe("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=uq),lr.init(e,t),e._zod.check=n=>{const r=n.value.split("/");try{if(r.length!==2)throw new Error;const[a,o]=r;if(!o)throw new Error;const i=Number(o);if(`${i}`!==o)throw new Error;if(i<0||i>128)throw new Error;new URL(`http://[${a}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function L4(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const nX=Oe("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=dq),lr.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{L4(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function rX(e){if(!R4.test(e))return!1;const t=e.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return L4(n)}const aX=Oe("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=R4),lr.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{rX(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),oX=Oe("$ZodE164",(e,t)=>{t.pattern??(t.pattern=fq),lr.init(e,t)});function sX(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[r]=n;if(!r)return!1;const a=JSON.parse(atob(r));return!("typ"in a&&a?.typ!=="JWT"||!a.alg||t&&(!("alg"in a)||a.alg!==t))}catch{return!1}}const iX=Oe("$ZodJWT",(e,t)=>{lr.init(e,t),e._zod.check=n=>{sX(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),M4=Oe("$ZodNumber",(e,t)=>{Gn.init(e,t),e._zod.pattern=e._zod.bag.pattern??yq,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}const a=n.value;if(typeof a=="number"&&!Number.isNaN(a)&&Number.isFinite(a))return n;const o=typeof a=="number"?Number.isNaN(a)?"NaN":Number.isFinite(a)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:a,inst:e,...o?{received:o}:{}}),n}}),lX=Oe("$ZodNumberFormat",(e,t)=>{_q.init(e,t),M4.init(e,t)}),cX=Oe("$ZodBoolean",(e,t)=>{Gn.init(e,t),e._zod.pattern=vq,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}const a=n.value;return typeof a=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:a,inst:e}),n}}),uX=Oe("$ZodNull",(e,t)=>{Gn.init(e,t),e._zod.pattern=wq,e._zod.values=new Set([null]),e._zod.parse=(n,r)=>{const a=n.value;return a===null||n.issues.push({expected:"null",code:"invalid_type",input:a,inst:e}),n}}),dX=Oe("$ZodAny",(e,t)=>{Gn.init(e,t),e._zod.parse=n=>n}),fX=Oe("$ZodUnknown",(e,t)=>{Gn.init(e,t),e._zod.parse=n=>n}),pX=Oe("$ZodNever",(e,t)=>{Gn.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function Uj(e,t,n){e.issues.length&&t.issues.push(...Jl(n,e.issues)),t.value[n]=e.value}const mX=Oe("$ZodArray",(e,t)=>{Gn.init(e,t),e._zod.parse=(n,r)=>{const a=n.value;if(!Array.isArray(a))return n.issues.push({expected:"array",code:"invalid_type",input:a,inst:e}),n;n.value=Array(a.length);const o=[];for(let i=0;i<a.length;i++){const l=a[i],u=t.element._zod.run({value:l,issues:[]},r);u instanceof Promise?o.push(u.then(f=>Uj(f,n,i))):Uj(u,n,i)}return o.length?Promise.all(o).then(()=>n):n}});function Ty(e,t,n,r){e.issues.length&&t.issues.push(...Jl(n,e.issues)),e.value===void 0?n in r&&(t.value[n]=void 0):t.value[n]=e.value}function j4(e){const t=Object.keys(e.shape);for(const r of t)if(!e.shape?.[r]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${r}": expected a Zod schema`);const n=kZ(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function P4(e,t,n,r,a,o){const i=[],l=a.keySet,u=a.catchall._zod,f=u.def.type;for(const m in t){if(l.has(m))continue;if(f==="never"){i.push(m);continue}const h=u.run({value:t[m],issues:[]},r);h instanceof Promise?e.push(h.then(g=>Ty(g,n,m,t))):Ty(h,n,m,t)}return i.length&&n.issues.push({code:"unrecognized_keys",keys:i,input:t,inst:o}),e.length?Promise.all(e).then(()=>n):n}const hX=Oe("$ZodObject",(e,t)=>{if(Gn.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){const l=t.shape;Object.defineProperty(t,"shape",{get:()=>{const u={...l};return Object.defineProperty(t,"shape",{value:u}),u}})}const r=Nv(()=>j4(t));Vn(e._zod,"propValues",()=>{const l=t.shape,u={};for(const f in l){const m=l[f]._zod;if(m.values){u[f]??(u[f]=new Set);for(const h of m.values)u[f].add(h)}}return u});const a=tm,o=t.catchall;let i;e._zod.parse=(l,u)=>{i??(i=r.value);const f=l.value;if(!a(f))return l.issues.push({expected:"object",code:"invalid_type",input:f,inst:e}),l;l.value={};const m=[],h=i.shape;for(const g of i.keys){const E=h[g]._zod.run({value:f[g],issues:[]},u);E instanceof Promise?m.push(E.then(x=>Ty(x,l,g,f))):Ty(E,l,g,f)}return o?P4(m,f,l,u,r.value,e):m.length?Promise.all(m).then(()=>l):l}}),gX=Oe("$ZodObjectJIT",(e,t)=>{hX.init(e,t);const n=e._zod.parse,r=Nv(()=>j4(t)),a=g=>{const y=new Mq(["shape","payload","ctx"]),E=r.value,x=T=>{const A=Pj(T);return`shape[${A}]._zod.run({ value: input[${A}], issues: [] }, ctx)`};y.write("const input = payload.value;");const w=Object.create(null);let S=0;for(const T of E.keys)w[T]=`key_${S++}`;y.write("const newResult = {};");for(const T of E.keys){const A=w[T],R=Pj(T);y.write(`const ${A} = ${x(T)};`),y.write(`
@@ -32,7 +32,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
32
32
  `;break;case"id":l=w.includes("\0")?void 0:w;break;case"retry":/^\d+$/.test(w)?r(parseInt(w,10)):n(new _$(`Invalid \`retry\` value: "${w}"`,{type:"invalid-retry",value:w,line:S}));break;default:n(new _$(`Unknown field "${x.length>20?`${x.slice(0,20)}…`:x}"`,{type:"unknown-field",field:x,value:w,line:S}));break}}function y(){u.length>0&&t({id:l,event:f||void 0,data:u.endsWith(`
33
33
  `)?u.slice(0,-1):u}),l=void 0,u="",f=""}function E(x={}){o&&x.consume&&h(o),i=!0,l=void 0,u="",f="",o=""}return{feed:m,reset:E}}function Ore(e){const t=[];let n="",r=0;for(;r<e.length;){const a=e.indexOf("\r",r),o=e.indexOf(`
34
34
  `,r);let i=-1;if(a!==-1&&o!==-1?i=Math.min(a,o):a!==-1?a===e.length-1?i=-1:i=a:o!==-1&&(i=o),i===-1){n=e.slice(r);break}else{const l=e.slice(r,i);t.push(l),r=i+1,e[r-1]==="\r"&&e[r]===`
35
- `&&r++}}return[t,n]}class Dre extends TransformStream{constructor({onError:t,onRetry:n,onComment:r}={}){let a;super({start(o){a=vB({onEvent:i=>{o.enqueue(i)},onError(i){t==="terminate"?o.error(i):typeof t=="function"&&t(i)},onRetry:n,onComment:r})},transform(o){a.feed(o)}})}}const Lre={initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:2};class Vi extends Error{constructor(t,n){super(`Streamable HTTP error: ${n}`),this.code=t}}class Mre{constructor(t,n){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=oB(n?.fetch,n?.requestInit),this._sessionId=n?.sessionId,this._reconnectionOptions=n?.reconnectionOptions??Lre}async _authThenStart(){if(!this._authProvider)throw new yo("No auth provider");let t;try{t=await Ws(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(n){throw this.onerror?.(n),n}if(t!=="AUTHORIZED")throw new yo;return await this._startOrAuthSse({resumptionToken:void 0})}async _commonHeaders(){const t={};if(this._authProvider){const r=await this._authProvider.tokens();r&&(t.Authorization=`Bearer ${r.access_token}`)}this._sessionId&&(t["mcp-session-id"]=this._sessionId),this._protocolVersion&&(t["mcp-protocol-version"]=this._protocolVersion);const n=My(this._requestInit?.headers);return new Headers({...t,...n})}async _startOrAuthSse(t){const{resumptionToken:n}=t;try{const r=await this._commonHeaders();r.set("Accept","text/event-stream"),n&&r.set("last-event-id",n);const a=await(this._fetch??fetch)(this._url,{method:"GET",headers:r,signal:this._abortController?.signal});if(!a.ok){if(await a.body?.cancel(),a.status===401&&this._authProvider)return await this._authThenStart();if(a.status===405)return;throw new Vi(a.status,`Failed to open SSE stream: ${a.statusText}`)}this._handleSseStream(a.body,t,!0)}catch(r){throw this.onerror?.(r),r}}_getNextReconnectionDelay(t){if(this._serverRetryMs!==void 0)return this._serverRetryMs;const n=this._reconnectionOptions.initialReconnectionDelay,r=this._reconnectionOptions.reconnectionDelayGrowFactor,a=this._reconnectionOptions.maxReconnectionDelay;return Math.min(n*Math.pow(r,t),a)}_scheduleReconnection(t,n=0){const r=this._reconnectionOptions.maxRetries;if(n>=r){this.onerror?.(new Error(`Maximum reconnection attempts (${r}) exceeded.`));return}const a=this._getNextReconnectionDelay(n);this._reconnectionTimeout=setTimeout(()=>{this._startOrAuthSse(t).catch(o=>{this.onerror?.(new Error(`Failed to reconnect SSE stream: ${o instanceof Error?o.message:String(o)}`)),this._scheduleReconnection(t,n+1)})},a)}_handleSseStream(t,n,r){if(!t)return;const{onresumptiontoken:a,replayMessageId:o}=n;let i,l=!1,u=!1;(async()=>{try{const m=t.pipeThrough(new TextDecoderStream).pipeThrough(new Dre({onRetry:y=>{this._serverRetryMs=y}})).getReader();for(;;){const{value:y,done:E}=await m.read();if(E)break;if(y.id&&(i=y.id,l=!0,a?.(y.id)),!!y.data&&(!y.event||y.event==="message"))try{const x=Jb.parse(JSON.parse(y.data));Tp(x)&&(u=!0,o!==void 0&&(x.id=o)),this.onmessage?.(x)}catch(x){this.onerror?.(x)}}(r||l)&&!u&&this._abortController&&!this._abortController.signal.aborted&&this._scheduleReconnection({resumptionToken:i,onresumptiontoken:a,replayMessageId:o},0)}catch(m){if(this.onerror?.(new Error(`SSE stream disconnected: ${m}`)),(r||l)&&!u&&this._abortController&&!this._abortController.signal.aborted)try{this._scheduleReconnection({resumptionToken:i,onresumptiontoken:a,replayMessageId:o},0)}catch(y){this.onerror?.(new Error(`Failed to reconnect: ${y instanceof Error?y.message:String(y)}`))}}})()}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 yo("No auth provider");if(await Ws(this._authProvider,{serverUrl:this._url,authorizationCode:t,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new yo("Failed to authorize")}async close(){this._reconnectionTimeout&&(clearTimeout(this._reconnectionTimeout),this._reconnectionTimeout=void 0),this._abortController?.abort(),this.onclose?.()}async send(t,n){try{const{resumptionToken:r,onresumptiontoken:a}=n||{};if(r){this._startOrAuthSse({resumptionToken:r,replayMessageId:DS(t)?t.id:void 0}).catch(g=>this.onerror?.(g));return}const o=await this._commonHeaders();o.set("content-type","application/json"),o.set("accept","application/json, text/event-stream");const i={...this._requestInit,method:"POST",headers:o,body:JSON.stringify(t),signal:this._abortController?.signal},l=await(this._fetch??fetch)(this._url,i),u=l.headers.get("mcp-session-id");if(u&&(this._sessionId=u),!l.ok){const g=await l.text().catch(()=>null);if(l.status===401&&this._authProvider){if(this._hasCompletedAuthFlow)throw new Vi(401,"Server returned 401 after successful authentication");const{resourceMetadataUrl:y,scope:E}=am(l);if(this._resourceMetadataUrl=y,this._scope=E,await Ws(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new yo;return this._hasCompletedAuthFlow=!0,this.send(t)}if(l.status===403&&this._authProvider){const{resourceMetadataUrl:y,scope:E,error:x}=am(l);if(x==="insufficient_scope"){const w=l.headers.get("WWW-Authenticate");if(this._lastUpscopingHeader===w)throw new Vi(403,"Server returned 403 after trying upscoping");if(E&&(this._scope=E),y&&(this._resourceMetadataUrl=y),this._lastUpscopingHeader=w??void 0,await Ws(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetch})!=="AUTHORIZED")throw new yo;return this.send(t)}}throw new Vi(l.status,`Error POSTing to endpoint: ${g}`)}if(this._hasCompletedAuthFlow=!1,this._lastUpscopingHeader=void 0,l.status===202){await l.body?.cancel(),See(t)&&this._startOrAuthSse({resumptionToken:void 0}).catch(g=>this.onerror?.(g));return}const m=(Array.isArray(t)?t:[t]).filter(g=>"method"in g&&"id"in g&&g.id!==void 0).length>0,h=l.headers.get("content-type");if(m)if(h?.includes("text/event-stream"))this._handleSseStream(l.body,{onresumptiontoken:a},!1);else if(h?.includes("application/json")){const g=await l.json(),y=Array.isArray(g)?g.map(E=>Jb.parse(E)):[Jb.parse(g)];for(const E of y)this.onmessage?.(E)}else throw await l.body?.cancel(),new Vi(-1,`Unexpected content type: ${h}`);else await l.body?.cancel()}catch(r){throw this.onerror?.(r),r}}get sessionId(){return this._sessionId}async terminateSession(){if(this._sessionId)try{const t=await this._commonHeaders(),n={...this._requestInit,method:"DELETE",headers:t,signal:this._abortController?.signal},r=await(this._fetch??fetch)(this._url,n);if(await r.body?.cancel(),!r.ok&&r.status!==405)throw new Vi(r.status,`Failed to terminate session: ${r.statusText}`);this._sessionId=void 0}catch(t){throw this.onerror?.(t),t}}setProtocolVersion(t){this._protocolVersion=t}get protocolVersion(){return this._protocolVersion}async resumeStream(t,n){await this._startOrAuthSse({resumptionToken:t,onresumptiontoken:n?.onresumptiontoken})}}class T$ extends Event{constructor(t,n){var r,a;super(t),this.code=(r=n?.code)!=null?r:void 0,this.message=(a=n?.message)!=null?a:void 0}[Symbol.for("nodejs.util.inspect.custom")](t,n,r){return r(N$(this),n)}[Symbol.for("Deno.customInspect")](t,n){return t(N$(this),n)}}function jre(e){const t=globalThis.DOMException;return typeof t=="function"?new t(e,"SyntaxError"):new SyntaxError(e)}function WS(e){return e instanceof Error?"errors"in e&&Array.isArray(e.errors)?e.errors.map(WS).join(", "):"cause"in e&&e.cause instanceof Error?`${e}: ${WS(e.cause)}`:e.message:`${e}`}function N$(e){return{type:e.type,message:e.message,code:e.code,defaultPrevented:e.defaultPrevented,cancelable:e.cancelable,timeStamp:e.timeStamp}}var wB=e=>{throw TypeError(e)},EN=(e,t,n)=>t.has(e)||wB("Cannot "+n),un=(e,t,n)=>(EN(e,t,"read from private field"),n?n.call(e):t.get(e)),Mr=(e,t,n)=>t.has(e)?wB("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),or=(e,t,n,r)=>(EN(e,t,"write to private field"),t.set(e,n),n),Hs=(e,t,n)=>(EN(e,t,"access private method"),n),$a,Zl,wu,ey,zy,$p,Du,Up,Wi,xu,Zu,Eu,Np,jo,KS,YS,ZS,C$,qS,XS,Cp,JS,QS;class ty extends EventTarget{constructor(t,n){var r,a;super(),Mr(this,jo),this.CONNECTING=0,this.OPEN=1,this.CLOSED=2,Mr(this,$a),Mr(this,Zl),Mr(this,wu),Mr(this,ey),Mr(this,zy),Mr(this,$p),Mr(this,Du),Mr(this,Up,null),Mr(this,Wi),Mr(this,xu),Mr(this,Zu,null),Mr(this,Eu,null),Mr(this,Np,null),Mr(this,YS,async o=>{var i;un(this,xu).reset();const{body:l,redirected:u,status:f,headers:m}=o;if(f===204){Hs(this,jo,Cp).call(this,"Server sent HTTP 204, not reconnecting",204),this.close();return}if(u?or(this,wu,new URL(o.url)):or(this,wu,void 0),f!==200){Hs(this,jo,Cp).call(this,`Non-200 status code (${f})`,f);return}if(!(m.get("content-type")||"").startsWith("text/event-stream")){Hs(this,jo,Cp).call(this,'Invalid content type, expected "text/event-stream"',f);return}if(un(this,$a)===this.CLOSED)return;or(this,$a,this.OPEN);const h=new Event("open");if((i=un(this,Np))==null||i.call(this,h),this.dispatchEvent(h),typeof l!="object"||!l||!("getReader"in l)){Hs(this,jo,Cp).call(this,"Invalid response body, expected a web ReadableStream",f),this.close();return}const g=new TextDecoder,y=l.getReader();let E=!0;do{const{done:x,value:w}=await y.read();w&&un(this,xu).feed(g.decode(w,{stream:!x})),x&&(E=!1,un(this,xu).reset(),Hs(this,jo,JS).call(this))}while(E)}),Mr(this,ZS,o=>{or(this,Wi,void 0),!(o.name==="AbortError"||o.type==="aborted")&&Hs(this,jo,JS).call(this,WS(o))}),Mr(this,qS,o=>{typeof o.id=="string"&&or(this,Up,o.id);const i=new MessageEvent(o.event||"message",{data:o.data,origin:un(this,wu)?un(this,wu).origin:un(this,Zl).origin,lastEventId:o.id||""});un(this,Eu)&&(!o.event||o.event==="message")&&un(this,Eu).call(this,i),this.dispatchEvent(i)}),Mr(this,XS,o=>{or(this,$p,o)}),Mr(this,QS,()=>{or(this,Du,void 0),un(this,$a)===this.CONNECTING&&Hs(this,jo,KS).call(this)});try{if(t instanceof URL)or(this,Zl,t);else if(typeof t=="string")or(this,Zl,new URL(t,Pre()));else throw new Error("Invalid URL")}catch{throw jre("An invalid or illegal string was specified")}or(this,xu,vB({onEvent:un(this,qS),onRetry:un(this,XS)})),or(this,$a,this.CONNECTING),or(this,$p,3e3),or(this,zy,(r=n?.fetch)!=null?r:globalThis.fetch),or(this,ey,(a=n?.withCredentials)!=null?a:!1),Hs(this,jo,KS).call(this)}get readyState(){return un(this,$a)}get url(){return un(this,Zl).href}get withCredentials(){return un(this,ey)}get onerror(){return un(this,Zu)}set onerror(t){or(this,Zu,t)}get onmessage(){return un(this,Eu)}set onmessage(t){or(this,Eu,t)}get onopen(){return un(this,Np)}set onopen(t){or(this,Np,t)}addEventListener(t,n,r){const a=n;super.addEventListener(t,a,r)}removeEventListener(t,n,r){const a=n;super.removeEventListener(t,a,r)}close(){un(this,Du)&&clearTimeout(un(this,Du)),un(this,$a)!==this.CLOSED&&(un(this,Wi)&&un(this,Wi).abort(),or(this,$a,this.CLOSED),or(this,Wi,void 0))}}$a=new WeakMap,Zl=new WeakMap,wu=new WeakMap,ey=new WeakMap,zy=new WeakMap,$p=new WeakMap,Du=new WeakMap,Up=new WeakMap,Wi=new WeakMap,xu=new WeakMap,Zu=new WeakMap,Eu=new WeakMap,Np=new WeakMap,jo=new WeakSet,KS=function(){or(this,$a,this.CONNECTING),or(this,Wi,new AbortController),un(this,zy)(un(this,Zl),Hs(this,jo,C$).call(this)).then(un(this,YS)).catch(un(this,ZS))},YS=new WeakMap,ZS=new WeakMap,C$=function(){var e;const t={mode:"cors",redirect:"follow",headers:{Accept:"text/event-stream",...un(this,Up)?{"Last-Event-ID":un(this,Up)}:void 0},cache:"no-store",signal:(e=un(this,Wi))==null?void 0:e.signal};return"window"in globalThis&&(t.credentials=this.withCredentials?"include":"same-origin"),t},qS=new WeakMap,XS=new WeakMap,Cp=function(e,t){var n;un(this,$a)!==this.CLOSED&&or(this,$a,this.CLOSED);const r=new T$("error",{code:t,message:e});(n=un(this,Zu))==null||n.call(this,r),this.dispatchEvent(r)},JS=function(e,t){var n;if(un(this,$a)===this.CLOSED)return;or(this,$a,this.CONNECTING);const r=new T$("error",{code:t,message:e});(n=un(this,Zu))==null||n.call(this,r),this.dispatchEvent(r),or(this,Du,setTimeout(un(this,QS),un(this,$p)))},QS=new WeakMap,ty.CONNECTING=0,ty.OPEN=1,ty.CLOSED=2;function Pre(){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 $re extends Error{constructor(t,n,r){super(`SSE error: ${n}`),this.code=t,this.event=r}}class Ure{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=oB(n?.fetch,n?.requestInit)}async _authThenStart(){if(!this._authProvider)throw new yo("No auth provider");let t;try{t=await Ws(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(n){throw this.onerror?.(n),n}if(t!=="AUTHORIZED")throw new yo;return await this._startOrAuth()}async _commonHeaders(){const t={};if(this._authProvider){const r=await this._authProvider.tokens();r&&(t.Authorization=`Bearer ${r.access_token}`)}this._protocolVersion&&(t["mcp-protocol-version"]=this._protocolVersion);const n=My(this._requestInit?.headers);return new Headers({...t,...n})}_startOrAuth(){const t=this?._eventSourceInit?.fetch??this._fetch??fetch;return new Promise((n,r)=>{this._eventSource=new ty(this._url.href,{...this._eventSourceInit,fetch:async(a,o)=>{const i=await this._commonHeaders();i.set("Accept","text/event-stream");const l=await t(a,{...o,headers:i});if(l.status===401&&l.headers.has("www-authenticate")){const{resourceMetadataUrl:u,scope:f}=am(l);this._resourceMetadataUrl=u,this._scope=f}return l}}),this._abortController=new AbortController,this._eventSource.onerror=a=>{if(a.code===401&&this._authProvider){this._authThenStart().then(n,r);return}const o=new $re(a.code,a.message,a);r(o),this.onerror?.(o)},this._eventSource.onopen=()=>{},this._eventSource.addEventListener("endpoint",a=>{const o=a;try{if(this._endpoint=new URL(o.data,this._url),this._endpoint.origin!==this._url.origin)throw new Error(`Endpoint origin does not match connection origin: ${this._endpoint.origin}`)}catch(i){r(i),this.onerror?.(i),this.close();return}n()}),this._eventSource.onmessage=a=>{const o=a;let i;try{i=Jb.parse(JSON.parse(o.data))}catch(l){this.onerror?.(l);return}this.onmessage?.(i)}})}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 yo("No auth provider");if(await Ws(this._authProvider,{serverUrl:this._url,authorizationCode:t,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new yo("Failed to authorize")}async close(){this._abortController?.abort(),this._eventSource?.close(),this.onclose?.()}async send(t){if(!this._endpoint)throw new Error("Not connected");try{const n=await this._commonHeaders();n.set("content-type","application/json");const r={...this._requestInit,method:"POST",headers:n,body:JSON.stringify(t),signal:this._abortController?.signal},a=await(this._fetch??fetch)(this._endpoint,r);if(!a.ok){const o=await a.text().catch(()=>null);if(a.status===401&&this._authProvider){const{resourceMetadataUrl:i,scope:l}=am(a);if(this._resourceMetadataUrl=i,this._scope=l,await Ws(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new yo;return this.send(t)}throw new Error(`Error POSTing to endpoint (HTTP ${a.status}): ${o}`)}await a.body?.cancel()}catch(n){throw this.onerror?.(n),n}}setProtocolVersion(t){this._protocolVersion=t}}var xd,zre=(xd=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={},r){return this.connector.callTool(t,n,r)}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,r){return this.connector.request(t,n,r)}},ze(xd,"MCPSession"),xd),Ed,Fre=(Ed=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,rs.getInstance().trackClientAddServer(t,n)}removeServer(t){this.config.mcpServers?.[t]&&(delete this.config.mcpServers[t],this.activeSessions=this.activeSessions.filter(n=>n!==t),rs.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 r=this.config.mcpServers??{};if(Object.keys(r).length===0&&He.warn("No MCP servers defined in config"),!r[t])throw new Error(`Server '${t}' not found in config`);const a=this.createConnectorFromConfig(r[t]),o=new zre(a);return n&&await o.initialize(),this.sessions[t]=o,this.activeSessions.includes(t)||this.activeSessions.push(t),o}async createAllSessions(t=!0){const n=this.config.mcpServers??{};Object.keys(n).length===0&&He.warn("No MCP servers defined in config");for(const r of Object.keys(n))await this.createSession(r,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){He.warn(`No session exists for server ${t}, nothing to close`);return}try{He.debug(`Closing session for server ${t}`),await n.disconnect()}catch(r){He.error(`Error closing session for server '${t}': ${r}`)}finally{delete this.sessions[t],this.activeSessions=this.activeSessions.filter(r=>r!==t)}}async closeAllSessions(){const t=Object.keys(this.sessions),n=[];for(const r of t)try{He.debug(`Closing session for server ${r}`),await this.closeSession(r)}catch(a){const o=`Failed to close session for server '${r}': ${a}`;He.error(o),n.push(o)}n.length?He.error(`Encountered ${n.length} errors while closing sessions`):He.debug("All sessions closed successfully")}},ze(Ed,"BaseMCPClient"),Ed),Sd,Bre=(Sd=class{_readyPromise;_readyResolver;_donePromise;_doneResolver;_exception=null;_connection=null;_task=null;_abortController=null;constructor(){this.reset()}async start(){if(this.reset(),He.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){He.debug(`Cancelling ${this.constructor.name} task`),this._abortController.abort();try{await this._task}catch(t){t instanceof Error&&t.name==="AbortError"?He.debug(`${this.constructor.name} task aborted successfully`):He.warn(`Error stopping ${this.constructor.name} task: ${t}`)}}await this._donePromise,He.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(){He.debug(`Running ${this.constructor.name} task`);try{this._connection=await this.establishConnection(),He.debug(`${this.constructor.name} connected successfully`),this._readyResolver(),await this.waitForAbort()}catch(t){this._exception=t,He.error(`Error in ${this.constructor.name} task: ${t}`),this._readyResolver()}finally{if(this._connection!==null){try{await this.closeConnection(this._connection)}catch(t){He.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 r=this._abortController.signal;if(r.aborted){t();return}const a=ze(()=>{r.removeEventListener("abort",a),t()},"onAbort");r.addEventListener("abort",a)})}},ze(Sd,"ConnectionManager"),Sd),_d,Hre=(_d=class extends Bre{url;opts;_transport=null;reinitializing=!1;constructor(t,n){super(),this.url=typeof t=="string"?new URL(t):t,this.opts=n}async establishConnection(){const t=new Ure(this.url,this.opts),n=t.send.bind(t);return t.send=async r=>{const a=ze(async o=>{if(Array.isArray(o))for(const i of o)await n(i);else await n(o)},"sendMessage");try{await a(r)}catch(o){if(o?.code===404&&t.sessionId&&!this.reinitializing){He.warn("[SSE] Session not found (404), re-initializing per MCP spec..."),this.reinitializing=!0;try{t.sessionId=void 0,await this.reinitialize(t),He.info("[SSE] Re-initialization successful, retrying request"),await a(r)}finally{this.reinitializing=!1}}else throw o}},this._transport=t,He.debug(`${this.constructor.name} connected successfully`),t}async reinitialize(t){He.debug("[SSE] Re-initialization triggered")}async closeConnection(t){if(this._transport)try{await this._transport.close()}catch(n){He.warn(`Error closing SSE transport: ${n}`)}finally{this._transport=null}}},ze(_d,"SseConnectionManager"),_d),Td,Vre=(Td=class extends Ute{baseUrl;headers;timeout;sseReadTimeout;clientInfo;preferSse;disableSseFallback;gatewayUrl;serverId;transportType=null;streamableTransport=null;constructor(t,n={}){super(n);const r=t.replace(/\/$/,"");this.gatewayUrl=n.gatewayUrl,this.serverId=n.serverId,this.gatewayUrl?(this.baseUrl=this.gatewayUrl.replace(/\/$/,""),this.headers={...n.headers??{}},this.headers["X-Target-URL"]=r,this.serverId&&(this.headers["X-Server-Id"]=this.serverId)):(this.baseUrl=r,this.headers={...n.headers??{}}),n.authToken&&(this.headers.Authorization=`Bearer ${n.authToken}`),this.timeout=n.timeout??1e4,this.sseReadTimeout=n.sseReadTimeout??3e5,this.clientInfo=n.clientInfo??{name:"http-connector",version:"1.0.0"},this.preferSse=n.preferSse??!1,this.disableSseFallback=n.disableSseFallback??!1}async connect(){if(this.connected){He.debug("Already connected to MCP implementation");return}const t=this.baseUrl;if(this.preferSse){He.debug(`Connecting to MCP implementation via HTTP/SSE: ${t}`),await this.connectWithSse(t);return}He.debug(`Connecting to MCP implementation via HTTP: ${t}`);try{He.info("🔄 Attempting streamable HTTP transport..."),await this.connectWithStreamableHttp(t),He.info("✅ Successfully connected via streamable HTTP")}catch(n){console.log("error in http connector connect",n);let r="Unknown error",a=!1,o,i=null;if(n instanceof Vi?i=n:n instanceof Error&&n.cause instanceof Vi&&(i=n.cause),i)a=i.code===401,o=i.code,console.log("Captured HTTP status code:",o),i.code===400&&i.message.includes("Missing session ID")?(r="Server requires session ID (FastMCP compatibility) - using SSE transport",He.warn(`⚠️ ${r}`)):i.code===404||i.code===405?(r=`Server returned ${i.code} - server likely doesn't support streamable HTTP`,He.debug(r)):(r=`Server returned ${i.code}: ${i.message}`,He.debug(r));else if(n instanceof Error){const l=n.toString(),u=n.message||"";a=l.includes("401")||u.includes("Unauthorized"),l.includes("Missing session ID")||l.includes("Bad Request: Missing session ID")||u.includes("FastMCP session ID error")?(r="Server requires session ID (FastMCP compatibility) - using SSE transport",He.warn(`⚠️ ${r}`)):l.includes("405 Method Not Allowed")||l.includes("404 Not Found")?(r="Server doesn't support streamable HTTP (405/404)",He.debug(r)):(r=`Streamable HTTP failed: ${n.message}`,He.debug(r))}if(a){He.info("Authentication required - skipping SSE fallback"),await this.cleanupResources();const l=new Error("Authentication required");throw l.code=401,l}He.info("🔄 Falling back to SSE transport...");try{await this.connectWithSse(t)}catch(l){if(console.error("Failed to connect with both transports:"),console.error(` Streamable HTTP: ${r}`),console.error(` SSE: ${l}`),await this.cleanupResources(),l?.message?.includes("401")||l?.message?.includes("Unauthorized")){const m=new Error("Authentication required");throw m.code=401,m}const f=new Error(`Could not connect to server with any available transport. Streamable HTTP: ${r}`);throw o!==void 0&&(Object.defineProperty(f,"code",{value:o,writable:!1,enumerable:!0,configurable:!0}),He.debug(`Preserving HTTP status code ${o} in error for proxy fallback detection`)),f}}}async connectWithStreamableHttp(t){try{console.log("[HttpConnector] Connecting with Streamable HTTP:"),console.log(` Base URL: ${t}`),console.log(` Original URL: ${this.baseUrl}`),console.log(` Gateway URL: ${this.gatewayUrl||"none"}`),console.log(` Auth Provider URL: ${this.opts.authProvider?.serverUrl||"none"}`),console.log(` Headers: ${JSON.stringify(this.headers)}`);const n=new Mre(new URL(t),{authProvider:this.opts.authProvider,requestInit:{headers:this.headers},reconnectionOptions:{maxReconnectionDelay:3e4,initialReconnectionDelay:1e3,reconnectionDelayGrowFactor:1.5,maxRetries:2}});let r=n;if(this.opts.wrapTransport){const o=this.baseUrl;r=this.opts.wrapTransport(r,o)}const a={...this.opts.clientOptions||{},capabilities:{...this.opts.clientOptions?.capabilities||{},roots:{listChanged:!0},...this.opts.samplingCallback?{sampling:{}}:{},...this.opts.elicitationCallback?{elicitation:{form:{},url:{}}}:{}}};He.debug("Creating Client with capabilities:",JSON.stringify(a.capabilities,null,2)),this.client=new x$(this.clientInfo,a),this.setupRootsHandler(),He.debug("Roots handler registered before connect");try{await this.client.connect(r,{timeout:this.timeout});const o=n.sessionId;o?He.debug(`Session ID obtained: ${o}`):He.warn("Session ID not available after connect - this may cause issues with SSE stream")}catch(o){if(o instanceof Error){const i=o.message||o.toString();if(i.includes("Missing session ID")||i.includes("Bad Request: Missing session ID")||i.includes("Mcp-Session-Id header is required")){const l=new Error(`Session ID error: ${i}. The SDK should automatically extract session ID from initialize response.`);throw l.cause=o,l}}throw o}this.streamableTransport=n,this.connectionManager={stop:ze(async()=>{if(this.streamableTransport)try{await this.streamableTransport.terminateSession(),await this.streamableTransport.close()}catch(o){He.warn(`Error closing Streamable HTTP transport: ${o}`)}finally{this.streamableTransport=null}},"stop")},this.connected=!0,this.transportType="streamable-http",this.setupNotificationHandler(),this.setupSamplingHandler(),this.setupElicitationHandler(),He.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 Hre(t,{authProvider:this.opts.authProvider,requestInit:{headers:this.headers}});let n=await this.connectionManager.start();if(this.opts.wrapTransport){const a=this.baseUrl;n=this.opts.wrapTransport(n,a)}const r={...this.opts.clientOptions||{},capabilities:{...this.opts.clientOptions?.capabilities||{},roots:{listChanged:!0},...this.opts.samplingCallback?{sampling:{}}:{},...this.opts.elicitationCallback?{elicitation:{form:{},url:{}}}:{}}};He.debug("Creating Client with capabilities (SSE):",JSON.stringify(r.capabilities,null,2)),this.client=new x$(this.clientInfo,r),this.setupRootsHandler(),He.debug("Roots handler registered before connect (SSE)"),await this.client.connect(n),this.connected=!0,this.transportType="sse",this.setupNotificationHandler(),this.setupSamplingHandler(),this.setupElicitationHandler(),He.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(Td,"HttpConnector"),Td),lc,Gre=(lc=class extends Fre{static getPackageVersion(){return Tv()}constructor(t){super(t),this._trackClientInit()}_trackClientInit(){const t=Object.keys(this.config.mcpServers??{});rs.getInstance().trackMCPClientInit({codeMode:!1,sandbox:!1,allCallbacks:!1,verify:!1,servers:t,numServers:t.length,isBrowser:!0}).catch(n=>He.debug(`Failed to track BrowserMCPClient init: ${n}`))}static fromDict(t){return new lc(t)}createConnectorFromConfig(t){const{url:n,headers:r,authToken:a,authProvider:o,wrapTransport:i,clientOptions:l,onSampling:u,samplingCallback:f,elicitationCallback:m,disableSseFallback:h,preferSse:g,clientInfo:y,gatewayUrl:E,serverId:x}=t;if(!n)throw new Error("Server URL is required");const w=u??f,S={headers:r,authToken:a,authProvider:o,wrapTransport:i,clientOptions:l,onSampling:w,samplingCallback:w,elicitationCallback:m,disableSseFallback:h,preferSse:g,clientInfo:y,gatewayUrl:E,serverId:x};return l?console.log("[BrowserMCPClient] Passing clientOptions to connector:",JSON.stringify(l,null,2)):console.warn("[BrowserMCPClient] No clientOptions provided to connector!"),new Vre(n,S)}},ze(lc,"BrowserMCPClient"),lc);function Lu(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(xB).join("&"),n.hash=n.hash.slice(0,1)+encodeURIComponent(n.hash.slice(1)),n.href}ze(Lu,"sanitizeUrl");function xB([e,t]){return`${encodeURIComponent(e)}${t.length>0?`=${encodeURIComponent(t)}`:""}`}ze(xB,"sanitizeParam");async function EB(e){return typeof e=="string"?e:e instanceof URLSearchParams||e instanceof FormData?Object.fromEntries(e.entries()):e instanceof Blob?await e.text():e}ze(EB,"serializeBody");var Nd,ny=(Nd=class{serverUrl;storageKeyPrefix;serverUrlHash;clientName;clientUri;logoUri;callbackUrl;preventAutoAuth;useRedirectFlow;oauthProxyUrl;connectionUrl;originalFetch;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.logoUri=n.logoUri||"https://mcp-use.com/logo.png",this.callbackUrl=Lu(n.callbackUrl||(typeof window<"u"?new URL("/oauth/callback",window.location.origin).toString():"/oauth/callback")),this.preventAutoAuth=n.preventAutoAuth,this.useRedirectFlow=n.useRedirectFlow,this.oauthProxyUrl=n.oauthProxyUrl,this.connectionUrl=n.connectionUrl,this.onPopupWindow=n.onPopupWindow}installFetchInterceptor(){if(!this.oauthProxyUrl){console.warn("[BrowserOAuthProvider] No OAuth proxy URL configured, skipping fetch interceptor installation");return}if(!this.originalFetch)this.originalFetch=window.fetch;else{console.warn("[BrowserOAuthProvider] Fetch interceptor already installed");return}const t=this.oauthProxyUrl,n=this.connectionUrl,r=this.serverUrl,a=this.originalFetch;console.log(`[BrowserOAuthProvider] Installing fetch interceptor with proxy: ${t}`),window.fetch=ze(async function(i,l){const u=typeof i=="string"?i:i instanceof URL?i.toString():i.url;if(!(u.includes("/.well-known/")||u.match(/\/(register|token|authorize)$/)))return await a(i,l);try{const m=new URL(u),h=new URL(t);if(m.origin===h.origin&&(m.pathname.startsWith(h.pathname)||u.includes("/inspector/api/oauth")))return await a(i,l)}catch{}try{const m=u.includes("/.well-known/");let h=u;if(m&&r)try{const S=new URL(u),_=new URL(r);if(S.protocol==="http:"&&_.protocol==="https:"){const T=S.pathname.match(/(\/.well-known\/[^/]+)/),A=T?T[1]:S.pathname;h=`${_.origin}${A}`,console.log(`[OAuth Proxy] Rewrote gateway metadata URL ${u} to server URL ${h}`)}else if(n){const T=new URL(n);if(S.origin===T.origin&&S.origin!==_.origin){const A=S.pathname.match(/(\/.well-known\/[^/]+)/),R=A?A[1]:S.pathname;h=`${_.origin}${R}`,console.log(`[OAuth Proxy] Rewrote gateway metadata URL ${u} to server URL ${h}`)}}}catch(S){console.error("[OAuth Proxy] Error rewriting metadata URL:",S)}const g=m?`${t}/metadata?url=${encodeURIComponent(h)}`:`${t}/proxy`;if(console.log(`[OAuth Proxy] Routing ${m?"metadata":"request"} through: ${g}`),m){const S={...l?.headers?Object.fromEntries(new Headers(l.headers)):{}};n&&(S["X-Connection-URL"]=n);const _=new URL(g);return r&&_.searchParams.set("mcp_url",r),await a(_.toString(),{...l,method:"GET",headers:S})}let y=u;if(u.includes("/authorize")&&r)try{const S=new URL(u),_=S.searchParams.get("resource");if(_&&n){const T=new URL(n);(_.startsWith(T.origin)||_===n)&&(S.searchParams.set("resource",r),y=S.toString(),console.log(`[OAuth Proxy] Rewrote authorize resource parameter from ${_} to ${r}`))}}catch(S){console.error("[OAuth Proxy] Error rewriting authorize URL:",S)}let E=l?.body?await EB(l.body):void 0;if(u.includes("/token")&&r&&n&&E)try{const S=new URLSearchParams(E),_=S.get("resource");if(_){const T=new URL(n);(_.startsWith(T.origin)||_===n)&&(S.set("resource",r),E=S.toString(),console.log(`[OAuth Proxy] Rewrote token resource parameter from ${_} to ${r}`))}}catch(S){console.error("[OAuth Proxy] Error rewriting token body:",S)}const w=await(await a(g,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:y,method:l?.method||"POST",headers:l?.headers?Object.fromEntries(new Headers(l.headers)):{},body:E})})).json();return new Response(JSON.stringify(w.body),{status:w.status,statusText:w.statusText,headers:new Headers(w.headers)})}catch(m){return console.error("[OAuth Proxy] Request failed, falling back to direct fetch:",m),await a(i,l)}},"interceptedFetch")}restoreFetch(){this.originalFetch&&(console.log("[BrowserOAuthProvider] Restoring original fetch"),window.fetch=this.originalFetch,this.originalFetch=void 0)}get redirectUrl(){return Lu(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,logo_uri:this.logoUri}}async clientInformation(){const t=this.getKey("client_info"),n=localStorage.getItem(t);if(n)try{return JSON.parse(n)}catch(r){console.warn(`[${this.storageKeyPrefix}] Failed to parse client information:`,r),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(r){console.warn(`[${this.storageKeyPrefix}] Failed to parse tokens:`,r),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){if(this.connectionUrl&&this.serverUrl){const u=t.searchParams.get("resource");if(u)try{const f=new URL(this.connectionUrl);(u.startsWith(f.origin)||u===this.connectionUrl)&&(t.searchParams.set("resource",this.serverUrl),console.log(`[OAuth] Rewrote authorize resource parameter from ${u} to ${this.serverUrl}`))}catch(f){console.error("[OAuth] Error rewriting resource parameter:",f)}}const n=globalThis.crypto.randomUUID(),r=`${this.storageKeyPrefix}:state_${n}`,a={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,oauthProxyUrl:this.oauthProxyUrl,connectionUrl:this.connectionUrl},flowType:this.useRedirectFlow?"redirect":"popup",returnUrl:typeof window<"u"?window.location.href:void 0};console.log(`[OAuth] Storing state key: ${r}`),localStorage.setItem(r,JSON.stringify(a));const o=localStorage.getItem(r);console.log(`[OAuth] State stored successfully: ${!!o}`),t.searchParams.set("state",n);const i=t.toString(),l=Lu(i);return localStorage.setItem(this.getKey("last_auth_url"),l),l}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 r="width=600,height=700,resizable=yes,scrollbars=yes,status=yes";try{const a=window.open(n,`mcp_auth_${this.serverUrlHash}`,r);this.onPopupWindow&&this.onPopupWindow(n,r,a),!a||a.closed||typeof a.closed>"u"?console.warn(`[${this.storageKeyPrefix}] Popup likely blocked by browser. Manual navigation might be required using the stored URL.`):(a.focus(),console.info(`[${this.storageKeyPrefix}] Redirecting to authorization URL in popup.`))}catch(a){console.error(`[${this.storageKeyPrefix}] Error opening popup window:`,a)}}getLastAttemptedAuthUrl(){const t=localStorage.getItem(this.getKey("last_auth_url"));return t?Lu(t):null}clearStorage(){const t=`${this.storageKeyPrefix}_${this.serverUrlHash}_`,n=`${this.storageKeyPrefix}:state_`,r=[];let a=0;for(let i=0;i<localStorage.length;i++){const l=localStorage.key(i);if(l){if(l.startsWith(t))r.push(l);else if(l.startsWith(n))try{const u=localStorage.getItem(l);u&&JSON.parse(u).serverUrlHash===this.serverUrlHash&&r.push(l)}catch(u){console.warn(`[${this.storageKeyPrefix}] Error parsing state key ${l} during clearStorage:`,u)}}}return[...new Set(r)].forEach(i=>{localStorage.removeItem(i),a++}),a}hashString(t){let n=0;for(let r=0;r<t.length;r++){const a=t.charCodeAt(r);n=(n<<5)-n+a,n=n&n}return Math.abs(n).toString(16)}getKey(t){return`${this.storageKeyPrefix}_${this.serverUrlHash}_${t}`}},ze(Nd,"BrowserOAuthClientProvider"),Nd);async function SN(){const e=new URLSearchParams(window.location.search),t=e.get("code"),n=e.get("state"),r=e.get("error"),a=e.get("error_description"),o="[mcp-callback]";console.log(`${o} Handling callback...`,{code:t,state:n,error:r,errorDescription:a});let i=null,l=null,u=null;try{if(r)throw new Error(`OAuth error: ${r} - ${a||"No description provided."}`);if(!t)throw new Error("Authorization code not found in callback query parameters.");if(!n)throw new Error("State parameter not found or invalid in callback query parameters.");console.log(`[mcp-callback] Looking for state: ${n}`),console.log("[mcp-callback] All localStorage keys:",Object.keys(localStorage));const f=`mcp:auth:state_${n}`;if(localStorage.getItem(f))u=f,console.log(`[mcp-callback] Found state with default key: ${f}`);else{const S=`:state_${n}`;for(let _=0;_<localStorage.length;_++){const T=localStorage.key(_);if(T&&T.endsWith(S)){u=T,console.log(`[mcp-callback] Found state with dynamic key: ${T}`);break}}}if(!u){const S=Object.keys(localStorage).filter(_=>_.includes("state"));throw console.log("[mcp-callback] State keys in storage:",S),new Error(`Invalid or expired state parameter "${n}". No matching state found in storage.`)}const m=localStorage.getItem(u);if(!m)throw new Error(`Invalid or expired state parameter "${n}". No matching state found in storage.`);try{l=JSON.parse(m)}catch{throw new Error("Failed to parse stored OAuth state.")}if(!l.expiry||l.expiry<Date.now())throw localStorage.removeItem(u),new Error("OAuth state has expired. Please try initiating authentication again.");if(!l.providerOptions)throw new Error("Stored state is missing required provider options.");const{serverUrl:h,...g}=l.providerOptions;let y=g.oauthProxyUrl,E=g.connectionUrl;if(!y)try{const S=new URL(window.location.href);if(S.pathname.includes("/oauth/callback")){const _=S.pathname.replace(/\/oauth\/callback.*$/,"");y=`${S.origin}${_}/api/oauth`,E=`${S.origin}${_}/api/proxy`,console.log(`${o} Inferred OAuth proxy URL from callback: ${y}`)}}catch(S){console.warn(`${o} Could not infer OAuth proxy URL:`,S)}console.log(`${o} Re-instantiating provider for server: ${h}`),i=new ny(h,{...g,oauthProxyUrl:y,connectionUrl:E}),y&&(console.log(`${o} Installing fetch interceptor for token exchange (proxy: ${y})`),i.installFetchInterceptor()),console.log(`${o} Calling SDK auth() to exchange code...`);const x=E||new URL(h).origin;console.log(`${o} Using SDK serverUrl: ${x} (connectionUrl: ${E||"none"})`);const w=await Ws(i,{serverUrl:x,authorizationCode:t});if(w==="AUTHORIZED")if(console.log(`${o} Authorization successful via SDK auth().`),l.flowType==="redirect"&&l.returnUrl)console.log(`${o} Redirect flow complete. Returning to: ${l.returnUrl}`),localStorage.removeItem(u),window.location.href=l.returnUrl;else if(window.opener&&!window.opener.closed)console.log(`${o} Popup flow complete. Notifying opener...`),window.opener.postMessage({type:"mcp_auth_callback",success:!0},window.location.origin),localStorage.removeItem(u),window.close();else if(l.returnUrl)console.log(`${o} Popup flow without opener. Returning to: ${l.returnUrl}`),localStorage.removeItem(u),window.location.href=l.returnUrl;else{console.warn(`${o} No opener window or return URL detected. Redirecting to root.`),localStorage.removeItem(u);const _=window.location.pathname.split("/").filter(Boolean),T=_.length>0&&_[_.length-1]==="callback"?"/"+_.slice(0,-2).join("/"):"/";window.location.href=T||"/"}else throw console.warn(`${o} SDK auth() returned unexpected status: ${w}`),new Error(`Unexpected result from authentication library: ${w}`)}catch(f){console.error(`${o} Error during OAuth callback handling:`,f);const m=f instanceof Error?f.message:String(f);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 y=document.createElement("p");y.style.color="red",y.style.backgroundColor="#ffebeb",y.style.border="1px solid red",y.style.padding="10px",y.style.borderRadius="4px",y.textContent=m,h.appendChild(y);const E=document.createElement("p");E.textContent="You can close this window or ";const x=document.createElement("a");if(x.href="#",x.textContent="click here to close",x.onclick=w=>(w.preventDefault(),window.close(),!1),E.appendChild(x),E.appendChild(document.createTextNode(".")),h.appendChild(E),f instanceof Error&&f.stack){const w=document.createElement("pre");w.style.fontSize="0.8em",w.style.color="#555",w.style.marginTop="20px",w.style.whiteSpace="pre-wrap",w.textContent=f.stack,h.appendChild(w)}document.body.appendChild(h)}catch(h){console.error(`${o} Could not display error in callback window:`,h)}u&&localStorage.removeItem(u),i&&(localStorage.removeItem(i.getKey("code_verifier")),localStorage.removeItem(i.getKey("last_auth_url")))}}ze(SN,"onMcpAuthorization");var vE={exports:{}},Bt={};var R$;function Wre(){if(R$)return Bt;R$=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),o=Symbol.for("react.consumer"),i=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),h=Symbol.for("react.activity"),g=Symbol.iterator;function y(j){return j===null||typeof j!="object"?null:(j=g&&j[g]||j["@@iterator"],typeof j=="function"?j:null)}var E={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},x=Object.assign,w={};function S(j,B,z){this.props=j,this.context=B,this.refs=w,this.updater=z||E}S.prototype.isReactComponent={},S.prototype.setState=function(j,B){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,B,"setState")},S.prototype.forceUpdate=function(j){this.updater.enqueueForceUpdate(this,j,"forceUpdate")};function _(){}_.prototype=S.prototype;function T(j,B,z){this.props=j,this.context=B,this.refs=w,this.updater=z||E}var A=T.prototype=new _;A.constructor=T,x(A,S.prototype),A.isPureReactComponent=!0;var R=Array.isArray;function k(){}var C={H:null,A:null,T:null,S:null},O=Object.prototype.hasOwnProperty;function M(j,B,z){var D=z.ref;return{$$typeof:e,type:j,key:B,ref:D!==void 0?D:null,props:z}}function L(j,B){return M(j.type,B,j.props)}function $(j){return typeof j=="object"&&j!==null&&j.$$typeof===e}function H(j){var B={"=":"=0",":":"=2"};return"$"+j.replace(/[=:]/g,function(z){return B[z]})}var V=/\/+/g;function Z(j,B){return typeof j=="object"&&j!==null&&j.key!=null?H(""+j.key):B.toString(36)}function ne(j){switch(j.status){case"fulfilled":return j.value;case"rejected":throw j.reason;default:switch(typeof j.status=="string"?j.then(k,k):(j.status="pending",j.then(function(B){j.status==="pending"&&(j.status="fulfilled",j.value=B)},function(B){j.status==="pending"&&(j.status="rejected",j.reason=B)})),j.status){case"fulfilled":return j.value;case"rejected":throw j.reason}}throw j}function G(j,B,z,D,P){var W=typeof j;(W==="undefined"||W==="boolean")&&(j=null);var K=!1;if(j===null)K=!0;else switch(W){case"bigint":case"string":case"number":K=!0;break;case"object":switch(j.$$typeof){case e:case t:K=!0;break;case m:return K=j._init,G(K(j._payload),B,z,D,P)}}if(K)return P=P(j),K=D===""?"."+Z(j,0):D,R(P)?(z="",K!=null&&(z=K.replace(V,"$&/")+"/"),G(P,B,z,"",function(le){return le})):P!=null&&($(P)&&(P=L(P,z+(P.key==null||j&&j.key===P.key?"":(""+P.key).replace(V,"$&/")+"/")+K)),B.push(P)),1;K=0;var ae=D===""?".":D+":";if(R(j))for(var oe=0;oe<j.length;oe++)D=j[oe],W=ae+Z(D,oe),K+=G(D,B,z,W,P);else if(oe=y(j),typeof oe=="function")for(j=oe.call(j),oe=0;!(D=j.next()).done;)D=D.value,W=ae+Z(D,oe++),K+=G(D,B,z,W,P);else if(W==="object"){if(typeof j.then=="function")return G(ne(j),B,z,D,P);throw B=String(j),Error("Objects are not valid as a React child (found: "+(B==="[object Object]"?"object with keys {"+Object.keys(j).join(", ")+"}":B)+"). If you meant to render a collection of children, use an array instead.")}return K}function Y(j,B,z){if(j==null)return j;var D=[],P=0;return G(j,D,"","",function(W){return B.call(z,W,P++)}),D}function F(j){if(j._status===-1){var B=j._result;B=B(),B.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=B)}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 B=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(B))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",j);return}console.error(j)},ee={map:Y,forEach:function(j,B,z){Y(j,function(){B.apply(this,arguments)},z)},count:function(j){var B=0;return Y(j,function(){B++}),B},toArray:function(j){return Y(j,function(B){return B})||[]},only:function(j){if(!$(j))throw Error("React.Children.only expected to receive a single React element child.");return j}};return Bt.Activity=h,Bt.Children=ee,Bt.Component=S,Bt.Fragment=n,Bt.Profiler=a,Bt.PureComponent=T,Bt.StrictMode=r,Bt.Suspense=u,Bt.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=C,Bt.__COMPILER_RUNTIME={__proto__:null,c:function(j){return C.H.useMemoCache(j)}},Bt.cache=function(j){return function(){return j.apply(null,arguments)}},Bt.cacheSignal=function(){return null},Bt.cloneElement=function(j,B,z){if(j==null)throw Error("The argument must be a React element, but you passed "+j+".");var D=x({},j.props),P=j.key;if(B!=null)for(W in B.key!==void 0&&(P=""+B.key),B)!O.call(B,W)||W==="key"||W==="__self"||W==="__source"||W==="ref"&&B.ref===void 0||(D[W]=B[W]);var W=arguments.length-2;if(W===1)D.children=z;else if(1<W){for(var K=Array(W),ae=0;ae<W;ae++)K[ae]=arguments[ae+2];D.children=K}return M(j.type,P,D)},Bt.createContext=function(j){return j={$$typeof:i,_currentValue:j,_currentValue2:j,_threadCount:0,Provider:null,Consumer:null},j.Provider=j,j.Consumer={$$typeof:o,_context:j},j},Bt.createElement=function(j,B,z){var D,P={},W=null;if(B!=null)for(D in B.key!==void 0&&(W=""+B.key),B)O.call(B,D)&&D!=="key"&&D!=="__self"&&D!=="__source"&&(P[D]=B[D]);var K=arguments.length-2;if(K===1)P.children=z;else if(1<K){for(var ae=Array(K),oe=0;oe<K;oe++)ae[oe]=arguments[oe+2];P.children=ae}if(j&&j.defaultProps)for(D in K=j.defaultProps,K)P[D]===void 0&&(P[D]=K[D]);return M(j,W,P)},Bt.createRef=function(){return{current:null}},Bt.forwardRef=function(j){return{$$typeof:l,render:j}},Bt.isValidElement=$,Bt.lazy=function(j){return{$$typeof:m,_payload:{_status:-1,_result:j},_init:F}},Bt.memo=function(j,B){return{$$typeof:f,type:j,compare:B===void 0?null:B}},Bt.startTransition=function(j){var B=C.T,z={};C.T=z;try{var D=j(),P=C.S;P!==null&&P(z,D),typeof D=="object"&&D!==null&&typeof D.then=="function"&&D.then(k,re)}catch(W){re(W)}finally{B!==null&&z.types!==null&&(B.types=z.types),C.T=B}},Bt.unstable_useCacheRefresh=function(){return C.H.useCacheRefresh()},Bt.use=function(j){return C.H.use(j)},Bt.useActionState=function(j,B,z){return C.H.useActionState(j,B,z)},Bt.useCallback=function(j,B){return C.H.useCallback(j,B)},Bt.useContext=function(j){return C.H.useContext(j)},Bt.useDebugValue=function(){},Bt.useDeferredValue=function(j,B){return C.H.useDeferredValue(j,B)},Bt.useEffect=function(j,B){return C.H.useEffect(j,B)},Bt.useEffectEvent=function(j){return C.H.useEffectEvent(j)},Bt.useId=function(){return C.H.useId()},Bt.useImperativeHandle=function(j,B,z){return C.H.useImperativeHandle(j,B,z)},Bt.useInsertionEffect=function(j,B){return C.H.useInsertionEffect(j,B)},Bt.useLayoutEffect=function(j,B){return C.H.useLayoutEffect(j,B)},Bt.useMemo=function(j,B){return C.H.useMemo(j,B)},Bt.useOptimistic=function(j,B){return C.H.useOptimistic(j,B)},Bt.useReducer=function(j,B,z){return C.H.useReducer(j,B,z)},Bt.useRef=function(j){return C.H.useRef(j)},Bt.useState=function(j){return C.H.useState(j)},Bt.useSyncExternalStore=function(j,B,z){return C.H.useSyncExternalStore(j,B,z)},Bt.useTransition=function(){return C.H.useTransition()},Bt.version="19.2.3",Bt}var k$;function _N(){return k$||(k$=1,vE.exports=Wre()),vE.exports}var b=_N();const ue=Fm(b),Ec=tZ({__proto__:null,default:ue},[b]);function e_(e,t){if(!e)throw new Error(t)}ze(e_,"assert");var A$=3e3,Kre=5e3;function SB(e){return{name:e.name,version:e.version,uri:e.websiteUrl,logo_uri:e.icons?.[0]?.src}}ze(SB,"deriveClientConfigFromClientInfo");function _B(e){const n=(e instanceof Error?e.message:String(e)).toLowerCase();return n.includes("oauth discovery failed")||n.includes("oauth-authorization-server")||n.includes("not valid json")||n.includes("404")&&(n.includes("openid-configuration")||n.includes("oauth-protected-resources")||n.includes("oauth-authorization-url")||n.includes("register"))||n.includes("invalid oauth error response")&&n.includes("not found")}ze(_B,"isOAuthDiscoveryFailure");function TB(e){const{url:t,enabled:n=!0,callbackUrl:r=typeof window<"u"?Lu(new URL("/oauth/callback",window.location.origin).toString()):"/oauth/callback",storageKeyPrefix:a="mcp:auth",clientConfig:o={},headers:i,customHeaders:l,proxyConfig:u,autoProxyFallback:f=!0,debug:m=!1,autoRetry:h=!1,autoReconnect:g=A$,transportType:y="auto",preventAutoAuth:E=!0,useRedirectFlow:x=!1,onPopupWindow:w,timeout:S=3e4,sseReadTimeout:_=3e5,wrapTransport:T,onNotification:A,onSampling:R,samplingCallback:k,onElicitation:C}=e,O=i??l??{};l&&!i&&console.warn('[useMcp] The "customHeaders" option is deprecated. Use "headers" instead.');const M=R??k;k&&!R&&console.warn('[useMcp] The "samplingCallback" option is deprecated. Use "onSampling" instead.');const L=b.useMemo(()=>({name:"mcp-use",title:"mcp-use",version:Tv(),description:"mcp-use is a complete TypeScript framework for building and using MCP",icons:[{src:"https://mcp-use.com/logo.png"}],websiteUrl:"https://mcp-use.com"}),[]),$=b.useMemo(()=>e.clientInfo?{...L,...e.clientInfo}:L,[e.clientInfo,L]),H=b.useMemo(()=>SB($),[$]),V=b.useMemo(()=>o&&Object.keys(o).length>0?(console.warn("[useMcp] The 'clientConfig' option is deprecated and will be removed in a future version. Use 'clientInfo' instead. The clientConfig will be automatically derived from clientInfo."),{...H,...o}):H,[o,H]),Z=b.useMemo(()=>f?typeof f=="boolean"?{enabled:f,proxyAddress:"https://inspector.mcp-use.com/inspector/api/proxy"}:{enabled:f.enabled!==!1,proxyAddress:f.proxyAddress||"https://inspector.mcp-use.com/inspector/api/proxy"}:{enabled:!1,proxyAddress:void 0},[f]),ne=b.useRef(!1),[G,Y]=b.useState(u),{gatewayUrl:F,proxyHeaders:re}=b.useMemo(()=>{const ge=d4(t||"",G);return{gatewayUrl:G?.proxyAddress,proxyHeaders:ge.headers}},[t,G]),ee=b.useMemo(()=>t||"",[t]),j=b.useMemo(()=>({...re,...O}),[re,O]),[B,z]=b.useState("discovering"),[D,P]=b.useState([]),[W,K]=b.useState([]),[ae,oe]=b.useState([]),[le,Q]=b.useState([]),[J,q]=b.useState(e._initialServerInfo?.name?e._initialServerInfo:void 0),[ie,he]=b.useState(),[Ne,Ye]=b.useState(void 0),[Pe,Ue]=b.useState([]),[st,Ve]=b.useState(void 0),[ut,rt]=b.useState(void 0),Ee=b.useRef(null),_e=b.useRef(null),Be=b.useRef(null),it=b.useRef(!1),qe=b.useRef(!0),lt=b.useRef(0),At=b.useRef(null),Nn=b.useRef(!1),ot=b.useRef(B),zn=b.useRef(g),qt=b.useRef(null),Ge=b.useRef(null),We=b.useRef(null);b.useEffect(()=>{ot.current=B,zn.current=g},[B,g]);const fe=b.useCallback((ge,Ce,...Te)=>{const Ae=Te.length>0?`${Ce} ${Te.map($e=>JSON.stringify($e)).join(" ")}`:Ce;console[ge](`[useMcp] ${Ae}`),qe.current&&Ue($e=>[...$e.slice(-100),{level:ge,message:Ae,timestamp:Date.now()}])},[]),It=b.useCallback(async(ge=!1)=>{if(ge||fe("info","Disconnecting..."),it.current=!1,At.current&&clearTimeout(At.current),At.current=null,Ee.current)try{const Ce="inspector-server",Te=Ee.current.getSession(Ce);Te&&Te._healthCheckCleanup&&(Te._healthCheckCleanup(),Te._healthCheckCleanup=null),Te&&await Ee.current.closeSession(Ce)}catch(Ce){ge||fe("warn","Error closing session:",Ce)}Ee.current=null,qe.current&&!ge&&(z("discovering"),P([]),K([]),oe([]),Q([]),Ye(void 0),Ve(void 0))},[fe]),Ct=b.useCallback((ge,Ce)=>{fe("error",ge,Ce??"");const Te=Ce&&"code"in Ce?Ce.code:void 0,Ae=Z.enabled&&!G?.proxyAddress,$e=ge.includes("CORS")||ge.includes("blocked by CORS policy")||ge.includes("Failed to fetch"),Xe=Te===400,Je=typeof Te=="number"&&Te>=404&&Te<500;if(Ae&&($e||Xe||Je)&&!(Te===401||Te===403))return fe("info",`Direct connection failed with ${$e?"CORS error":Xe?"HTTP 400 (Bad Request)":"HTTP 4xx error"}. Trying with proxy...`),Ee.current=null,_e.current=null,fe("debug","Cleared client and auth provider for proxy fallback"),Y({proxyAddress:Z.proxyAddress}),qe.current&&z("discovering"),setTimeout(()=>{qe.current&&Ge.current?.()},1e3),!0;if(qe.current){console.log("[useMcp] Setting state to FAILED:",ge),z("failed"),Ye(ge);const tt=_e.current?.getLastAttemptedAuthUrl();tt&&(Ve(tt),fe("info","Manual authentication URL may be available.",tt))}return it.current=!1,t&&rs.getInstance().trackUseMcpConnection({url:t,transportType:y,success:!1,errorType:Ce?.name||"UnknownError",hasOAuth:!!_e.current,hasSampling:!!M,hasElicitation:!!C}).catch(()=>{}),!1},[fe,t,y,M,C,Z,G]),Pt=b.useCallback(async()=>{if(!n||!t){fe("debug",n?"No server URL provided, skipping connection.":"Connection disabled via enabled flag.");return}if(it.current){fe("debug","Connection attempt already in progress.");return}if(!qe.current){fe("debug","Connect called after unmount, aborting.");return}if(it.current=!0,lt.current+=1,Ye(void 0),Ve(void 0),qt.current=null,z("discovering"),fe("info",`Connecting attempt #${lt.current} to ${t}...`),_e.current){const Te=_e.current.clearStorage();Te>0&&fe("debug",`Cleared ${Te} stale OAuth storage item(s) before connecting`)}if(!_e.current){let Te;if(F){const Ae=new URL(F),$e=Ae.pathname.replace(/\/proxy\/?$/,"");Te=`${Ae.origin}${$e}/oauth`,fe("debug",`OAuth proxy URL derived from gateway: ${Te}`)}_e.current=new ny(ee,{storageKeyPrefix:a,clientName:V.name,clientUri:V.uri,logoUri:V.logo_uri||"https://mcp-use.com/logo.png",callbackUrl:r,preventAutoAuth:E,useRedirectFlow:x,oauthProxyUrl:Te,connectionUrl:F,onPopupWindow:w}),fe("debug",`BrowserOAuthClientProvider initialized with URL: ${ee}, proxy: ${Te?"enabled":"disabled"}, gateway: ${F?"enabled":"disabled"}`),Te&&(_e.current.installFetchInterceptor(),fe("debug","Installed OAuth fetch interceptor"))}Ee.current?fe("debug","BrowserMCPClient already exists, reusing."):(Ee.current=new Gre,fe("debug","BrowserMCPClient initialized in connect."));const ge=ze(async(Te,Ae=!1)=>{if(!qe.current)return fe("debug","Connection attempt aborted - component unmounted"),"failed";fe("info",`Attempting connection with transport: ${Te}`),fe("debug",`Client ref status at start of tryConnectWithTransport: ${Ee.current?"initialized":"NULL"}`);try{const $e="inspector-server",Xe={url:t,transport:Te==="sse"?"http":Te,disableSseFallback:y==="http",preferSse:Te==="sse",clientInfo:$};if(F&&(Xe.gatewayUrl=F,console.log(`[useMcp] Using proxy gateway: ${F} for target: ${t}`)),j&&Object.keys(j).length>0&&(Xe.headers=j),_e.current){const et=await _e.current.tokens();if(!qe.current)return fe("debug","Connection aborted after token fetch - component unmounted"),"failed";et?.access_token&&(Xe.headers={...Xe.headers,Authorization:`Bearer ${et.access_token}`})}if(!Ee.current){if(!qe.current)return fe("debug","Connection aborted - component unmounted, client cleaned up"),"failed";const et=new Error("Client not initialized - this is a bug in the connection flow");throw fe("error","Client ref is null in tryConnectWithTransport but component is still mounted"),et}Ee.current.addServer($e,{...Xe,authProvider:_e.current,clientOptions:V,onSampling:M,samplingCallback:M,elicitationCallback:C,wrapTransport:T?et=>(console.log("[useMcp] Applying transport wrapper for server:",$e,"url:",t),T(et,t)):void 0});const Je=await Ee.current.createSession($e,!1);if(!qe.current)return fe("debug","Connection aborted after session creation - component unmounted"),"failed";if(Je.on("notification",et=>{A?.(et),et.method==="notifications/tools/list_changed"?(fe("info","Tools list changed, auto-refreshing..."),Ln().catch(Ke=>fe("warn","Auto-refresh tools failed:",Ke))):et.method==="notifications/resources/list_changed"?(fe("info","Resources list changed, auto-refreshing..."),sn().catch(Ke=>fe("warn","Auto-refresh resources failed:",Ke))):et.method==="notifications/prompts/list_changed"&&(fe("info","Prompts list changed, auto-refreshing..."),Mn().catch(Ke=>fe("warn","Auto-refresh prompts failed:",Ke)))}),await Je.initialize(),!qe.current)return fe("debug","Connection completed but component unmounted, aborting"),"failed";if(fe("info","✅ Successfully connected to MCP server"),fe("info","Server info:",Je.connector.serverInfo),fe("info","Server capabilities:",Je.connector.serverCapabilities),console.log("[useMcp] Server info:",Je.connector.serverInfo),console.log("[useMcp] Server capabilities:",Je.connector.serverCapabilities),!qe.current)return fe("debug","Skipping state update - component unmounted"),"failed";z("ready"),qt.current=Te;const Qe=ze(()=>{let et=null,Ke=Date.now();const St=1e4,En=3e4;return et=setInterval(ze(async()=>{if(!qe.current||ot.current!=="ready"){et&&(clearInterval(et),et=null);return}try{await Je.connector.listTools(),Ke=Date.now()}catch{const _t=Date.now()-Ke;_t>En&&(fe("warn",`Connection appears to be broken (no response for ${Math.round(_t/1e3)}s), attempting to reconnect...`),et&&(clearInterval(et),et=null),zn.current&&qe.current&&(z("discovering"),fe("info","Auto-reconnecting to MCP server..."),setTimeout(()=>{qe.current&&ot.current==="discovering"&&Pt()},typeof zn.current=="number"?zn.current:A$)))}},"checkConnectionHealth"),St),()=>{et&&(clearInterval(et),et=null)}},"setupConnectionMonitoring");if(g){const et=Qe();Je._healthCheckCleanup=et}rs.getInstance().trackUseMcpConnection({url:t,transportType:Te,success:!0,hasOAuth:!!_e.current,hasSampling:!!M,hasElicitation:!!C}).catch(()=>{}),P(Je.connector.tools||[]);const Mt=await Je.connector.listAllResources();if(!qe.current)return fe("debug","Connection aborted after listing resources - component unmounted"),"failed";K(Mt.resources||[]);const tt=await Je.connector.listPrompts();if(!qe.current)return fe("debug","Connection aborted after listing prompts - component unmounted"),"failed";Q(tt.prompts||[]);const xt=Je.connector.serverInfo,Rt=Je.connector.serverCapabilities;if(xt){if(console.log("[useMcp] Server info:",xt),!qe.current)return fe("debug","Skipping state update - component unmounted"),"failed";q(xt);const et=(async()=>{try{const Ke=xt.icons;if(Ke&&Array.isArray(Ke)&&Ke.length>0){const St=Ke[0].src||Ke[0].url;if(St){fe("info","Server provided icon:",St);const gt=await(await fetch(St)).blob(),Fn=await new Promise((_t,Cn)=>{const en=new FileReader;en.onloadend=()=>_t(en.result),en.onerror=Cn,en.readAsDataURL(gt)});return qe.current&&(q(_t=>_t?{..._t,icon:Fn}:void 0),fe("debug","Server icon converted to base64")),Fn}}if(t){const St=await u4(t);if(!qe.current)return fe("debug","Connection aborted after favicon detection - component unmounted"),null;if(St)return q(En=>En?{...En,icon:St}:void 0),fe("debug","Favicon detected and added to serverInfo"),St}return null}catch(Ke){return fe("debug","Icon loading failed (non-critical):",Ke),null}})();Be.current=et}if(Rt){if(console.log("[useMcp] Server capabilities:",Rt),!qe.current)return fe("debug","Skipping state update - component unmounted"),"failed";he(Rt)}if(_e.current){const et=await _e.current.tokens();if(!qe.current)return fe("debug","Connection aborted after token fetch for auth tokens - component unmounted"),"failed";if(et?.access_token){const Ke=et.expires_in?Date.now()+et.expires_in*1e3:void 0;if(!qe.current)return fe("debug","Skipping state update - component unmounted"),"failed";rt({access_token:et.access_token,token_type:et.token_type||"Bearer",expires_at:Ke,refresh_token:et.refresh_token,scope:et.scope})}}return"success"}catch($e){const Xe=$e,Je=Xe?.message||String($e),Qe=_B($e),Mt=Xe.code===401||Je.includes("401")||Je.includes("Unauthorized");if(Qe&&O&&Object.keys(O).length>0)return Ct("Authentication failed (HTTP 401). Server does not support OAuth. Check your Authorization header value is correct."),"failed";if(Mt){if(Qe)return Ct("Authentication required (HTTP 401). Server does not support OAuth. Add an Authorization header in the Custom Headers section (e.g., Authorization: Bearer YOUR_API_KEY)."),"failed";if(_e.current){if(fe("info","Authentication required. OAuth provider available."),fe("info","Waiting for user to initiate authentication flow..."),qe.current){z("pending_auth");const xt=_e.current?.getLastAttemptedAuthUrl();xt&&(Ve(xt),fe("info","Retrieved stored auth URL for manual authentication"))}return it.current=!1,"auth_redirect"}return O&&Object.keys(O).length>0?(Ct("Authentication failed: Server returned 401 Unauthorized. Check your Authorization header value is correct."),"failed"):(Ct("Authentication required: Server returned 401 Unauthorized. Add an Authorization header in the Custom Headers section (e.g., Authorization: Bearer YOUR_API_KEY)."),"failed")}return Ct(Je,Xe instanceof Error?Xe:new Error(String(Xe)))?"auth_redirect":"failed"}},"tryConnectWithTransport");let Ce="failed";if(y==="sse")fe("debug","Using SSE-only transport mode"),Ce=await ge("sse");else if(y==="http")fe("debug","Using HTTP-only transport mode"),Ce=await ge("http");else{fe("debug","Using auto transport mode (HTTP with SSE fallback)");const Te=await ge("http");Te==="fallback"&&qe.current&&ot.current!=="authenticating"?(fe("info","HTTP failed, attempting SSE fallback..."),Ce=await ge("sse")):Ce=Te}(Ce==="success"||Ce==="failed"||Ce==="auth_redirect")&&(it.current=!1),fe("debug",`Connection sequence finished with status: ${Ce}`)},[fe,Ct,It,t,a,r,V.name,V.version,V.uri,V.logo_uri,O,y,E,x,w,n,S,_,$,F,j,ee]);b.useEffect(()=>{Ge.current=Pt,We.current=Ct},[Pt,Ct]);const $t=b.useCallback(async(ge,Ce,Te)=>{if(ot.current!=="ready"||!Ee.current)throw new Error(`MCP client is not ready (current state: ${B}). Cannot call tool "${ge}".`);fe("info",`Calling tool: ${ge}`,Ce);const Ae=Date.now();try{const Xe=Ee.current.getSession("inspector-server");if(!Xe)throw new Error("No active session found");const Je=await Xe.connector.callTool(ge,Ce||{},Te);return fe("info",`Tool "${ge}" call successful:`,Je),rs.getInstance().trackUseMcpToolCall({toolName:ge,success:!0,executionTimeMs:Date.now()-Ae}).catch(()=>{}),Je}catch($e){throw fe("error",`Tool "${ge}" call failed:`,$e),rs.getInstance().trackUseMcpToolCall({toolName:ge,success:!1,errorType:$e instanceof Error?$e.name:"UnknownError",executionTimeMs:Date.now()-Ae}).catch(()=>{}),$e}},[B]),Xt=b.useCallback(()=>{ot.current==="failed"?(fe("info","Retry requested..."),Ge.current?.()):fe("warn",`Retry called but state is not 'failed' (state: ${ot.current}). Ignoring.`)},[fe]),xn=b.useCallback(async()=>{fe("info","Manual authentication requested...");const ge=ot.current;if(ge==="failed")fe("info","Attempting to reconnect and authenticate via retry..."),Xt();else if(ge==="pending_auth"){fe("info","Proceeding with authentication from pending state...");try{e_(_e.current,"Auth Provider not available for manual auth"),e_(t,"Server URL is required for authentication");const Ce=_e.current.clearStorage();fe("info",`Cleared ${Ce} OAuth storage item(s) for fresh authentication`),z("authenticating");let Te;if(F){const Qe=new URL(F),Mt=Qe.pathname.replace(/\/proxy\/?$/,"");Te=`${Qe.origin}${Mt}/oauth`}const Ae=new ny(ee,{storageKeyPrefix:a,clientName:V.name,clientUri:V.uri,logoUri:V.logo_uri||"https://mcp-use.com/logo.png",callbackUrl:r,preventAutoAuth:!1,useRedirectFlow:x,oauthProxyUrl:Te,connectionUrl:F,onPopupWindow:w});Te&&!F?(Ae.installFetchInterceptor(),fe("info","Installed OAuth fetch interceptor for manual auth")):Te&&F&&fe("info","Using MCP gateway proxy for OAuth (no fetch interceptor needed)"),_e.current=Ae,fe("info","Triggering fresh OAuth authorization...");const{auth:$e}=await Ua(async()=>{const{auth:Qe}=await Promise.resolve().then(()=>Ire);return{auth:Qe}},void 0),Xe=new URL(t).origin;try{await $e(Ae,{serverUrl:Xe}),fe("info","OAuth flow completed (tokens obtained)")}catch(Qe){fe("info","OAuth flow initiated (popup/redirect):",Qe instanceof Error?Qe.message:"Redirecting...")}const Je=Ae.getLastAttemptedAuthUrl();Je&&(Ve(Je),fe("info","Updated auth URL for fallback:",Je))}catch(Ce){if(!qe.current)return;z("pending_auth"),fe("error",`Manual authentication failed: ${Ce instanceof Error?Ce.message:String(Ce)}`)}}else if(ge==="authenticating"){fe("warn","Already attempting authentication. Check for blocked popups or wait for timeout.");const Ce=_e.current?.getLastAttemptedAuthUrl();Ce&&!st&&(Ve(Ce),fe("info","Manual authentication URL retrieved:",Ce))}else fe("info",`Client not in a state requiring manual authentication trigger (state: ${ge}). If needed, try disconnecting and reconnecting.`)},[fe,Xt,st,t,x,w,a,V.name,V.uri,V.logo_uri,r,$]),dt=b.useCallback(()=>{if(_e.current){const ge=_e.current.clearStorage();fe("info",`Cleared ${ge} item(s) from localStorage for ${t}.`),Ve(void 0),It()}else fe("warn","Auth provider not initialized, cannot clear storage.")},[t,fe,It]),Ut=b.useCallback(async()=>{if(ot.current!=="ready"||!Ee.current)throw new Error(`MCP client is not ready (current state: ${B}). Cannot list resources.`);fe("info","Listing resources");try{const Ce=Ee.current.getSession("inspector-server");if(!Ce)throw new Error("No active session found");const Te=await Ce.connector.listAllResources();K(Te.resources||[]),fe("info","Resources listed successfully")}catch(ge){throw fe("error","List resources failed:",ge),ge}},[B]),Ht=b.useCallback(async ge=>{if(ot.current!=="ready"||!Ee.current)throw new Error(`MCP client is not ready (current state: ${B}). Cannot read resource.`);fe("info",`Reading resource: ${ge}`);try{const Te=Ee.current.getSession("inspector-server");if(!Te)throw new Error("No active session found");const Ae=await Te.connector.readResource(ge);return fe("info","Resource read successful:",Ae),rs.getInstance().trackUseMcpResourceRead({resourceUri:ge,success:!0}).catch(()=>{}),Ae}catch(Ce){throw fe("error","Resource read failed:",Ce),rs.getInstance().trackUseMcpResourceRead({resourceUri:ge,success:!1,errorType:Ce instanceof Error?Ce.name:"UnknownError"}).catch(()=>{}),Ce}},[B]),zt=b.useCallback(async()=>{if(ot.current!=="ready"||!Ee.current)throw new Error(`MCP client is not ready (current state: ${B}). Cannot list prompts.`);fe("info","Listing prompts");try{const Ce=Ee.current.getSession("inspector-server");if(!Ce)throw new Error("No active session found");const Te=await Ce.connector.listPrompts();Q(Te.prompts||[]),fe("info","Prompts listed successfully")}catch(ge){throw fe("error","List prompts failed:",ge),ge}},[B]),Ln=b.useCallback(async()=>{if(ot.current!=="ready"||!Ee.current){fe("debug","Cannot refresh tools - client not ready");return}fe("debug","Refreshing tools list");try{const Ce=Ee.current.getSession("inspector-server");if(!Ce){fe("warn","No active session found for tools refresh");return}const Te=await Ce.connector.listTools();P(Te||[]),fe("info","Tools list refreshed successfully")}catch(ge){fe("warn","Failed to refresh tools:",ge)}},[fe]),sn=b.useCallback(async()=>{if(ot.current!=="ready"||!Ee.current){fe("debug","Cannot refresh resources - client not ready");return}fe("debug","Refreshing resources list");try{const Ce=Ee.current.getSession("inspector-server");if(!Ce){fe("warn","No active session found for resources refresh");return}const Te=await Ce.connector.listAllResources();K(Te.resources||[]),fe("info","Resources list refreshed successfully")}catch(ge){fe("warn","Failed to refresh resources:",ge)}},[fe]),Mn=b.useCallback(async()=>{if(ot.current!=="ready"||!Ee.current){fe("debug","Cannot refresh prompts - client not ready");return}fe("debug","Refreshing prompts list");try{const Ce=Ee.current.getSession("inspector-server");if(!Ce){fe("warn","No active session found for prompts refresh");return}const Te=await Ce.connector.listPrompts();Q(Te.prompts||[]),fe("info","Prompts list refreshed successfully")}catch(ge){fe("warn","Failed to refresh prompts:",ge)}},[fe]),qn=b.useCallback(async()=>{fe("info","Refreshing all lists (tools, resources, prompts)"),await Promise.all([Ln(),sn(),Mn()])},[Ln,sn,Mn,fe]),se=b.useCallback(async(ge,Ce)=>{if(ot.current!=="ready"||!Ee.current)throw new Error(`MCP client is not ready (current state: ${B}). Cannot get prompt.`);fe("info",`Getting prompt: ${ge}`,Ce);try{const Ae=Ee.current.getSession("inspector-server");if(!Ae)throw new Error("No active session found");const $e=await Ae.connector.getPrompt(ge,Ce||{});return fe("info",`Prompt "${ge}" retrieved successfully:`,$e),$e}catch(Te){throw fe("error",`Prompt "${ge}" retrieval failed:`,Te),Te}},[B]);b.useEffect(()=>{const ge=ze(Ce=>{Ce.origin===window.location.origin&&Ce.data?.type==="mcp_auth_callback"&&(fe("info","Received auth callback message.",Ce.data),At.current&&clearTimeout(At.current),At.current=null,Ce.data.success?(fe("info","Authentication successful via popup. Reconnecting client..."),it.current&&fe("debug","Connection attempt already in progress, resetting flag to allow reconnection."),it.current=!1,setTimeout(()=>{qe.current&&(fe("debug","Initiating reconnection after successful auth callback."),Ge.current?.())},100)):We.current?.(`Authentication failed in callback: ${Ce.data.error||"Unknown reason."}`))},"messageHandler");return window.addEventListener("message",ge),fe("debug","Auth callback message listener added."),()=>{window.removeEventListener("message",ge),fe("debug","Auth callback message listener removed."),At.current&&clearTimeout(At.current)}},[fe]),b.useEffect(()=>{ne.current=!1,Y(u)},[t,u]),b.useEffect(()=>{if(qe.current=!0,!n||!t)return fe("debug",n?"No server URL provided, skipping connection.":"Connection disabled via enabled flag."),z("discovering"),()=>{qe.current=!1};if(fe("debug","useMcp mounted, initiating connection."),lt.current=0,!_e.current||_e.current.serverUrl!==ee){let ge;if(F){const Ce=new URL(F),Te=Ce.pathname.replace(/\/proxy\/?$/,"");ge=`${Ce.origin}${Te}/oauth`,fe("debug",`OAuth proxy URL derived from gateway: ${ge}`)}_e.current=new ny(ee,{storageKeyPrefix:a,clientName:V.name,clientUri:V.uri,logoUri:V.logo_uri||"https://mcp-use.com/logo.png",callbackUrl:r,preventAutoAuth:E,useRedirectFlow:x,oauthProxyUrl:ge,connectionUrl:F,onPopupWindow:w}),fe("debug",`BrowserOAuthClientProvider initialized/updated with URL: ${ee}, proxy: ${ge?"enabled":"disabled"}, gateway: ${F?"enabled":"disabled"}`),ge&&(_e.current.installFetchInterceptor(),fe("debug","Installed OAuth fetch interceptor"))}return Pt(),()=>{if(qe.current=!1,fe("debug","useMcp unmounting, disconnecting."),(ot.current==="authenticating"||ot.current==="pending_auth")&&_e.current)try{const ge=_e.current.clearStorage();ge>0&&fe("debug",`Cleared ${ge} OAuth state item(s) during unmount to prevent corruption`)}catch(ge){fe("debug","Error clearing OAuth state during unmount:",ge)}It(!0)}},[t,n,a,r,V.name,V.version,V.uri,V.logo_uri,x,$,ee]);const de=b.useRef(Xt),ye=b.useRef(fe);b.useEffect(()=>{de.current=Xt,ye.current=fe},[Xt,fe]),b.useEffect(()=>{let ge=null;if(B==="failed"&&h&&lt.current>0){if(!Nn.current){Nn.current=!0;const Ce=typeof h=="number"?h:Kre;ye.current("info",`Connection failed, auto-retrying in ${Ce}ms...`),ge=setTimeout(()=>{Nn.current=!1,qe.current&&ot.current==="failed"&&de.current()},Ce)}}else B!=="failed"&&(Nn.current=!1);return()=>{ge&&(clearTimeout(ge),Nn.current=!1)}},[B,h]);const ke=b.useCallback(async()=>ot.current!=="ready"?(fe("warn","Cannot ensure icon loaded - not connected"),null):J?.icon?J.icon:Be.current?(fe("debug","Waiting for icon to finish loading..."),await Be.current):(fe("debug","No icon available and no loading in progress"),null),[J,fe]);return{state:B,name:J?.name||t||"",tools:D,resources:W,resourceTemplates:ae,prompts:le,serverInfo:J,capabilities:ie,error:Ne,log:Pe,authUrl:st,authTokens:ut,client:Ee.current,callTool:$t,readResource:Ht,listResources:Ut,listPrompts:zt,getPrompt:se,refreshTools:Ln,refreshResources:sn,refreshPrompts:Mn,refreshAll:qn,retry:Xt,disconnect:It,authenticate:xn,clearStorage:dt,ensureIconLoaded:ke}}ze(TB,"useMcp");var Cd,Yre=(Cd=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(Cd,"ErrorBoundary"),Cd),zp="openai:set_globals";function Mo(e){return b.useSyncExternalStore(t=>{const n=ze(r=>{r.detail.globals[e]!==void 0&&t()},"handleSetGlobal");return typeof window<"u"&&window.addEventListener(zp,n),()=>{typeof window<"u"&&window.removeEventListener(zp,n)}},()=>typeof window<"u"&&window.openai?window.openai[e]:void 0)}ze(Mo,"useOpenAiGlobal");function Jd(e){const[t,n]=b.useState(()=>typeof window<"u"&&!!window.openai);b.useEffect(()=>{if(typeof window<"u"&&window.openai){n(!0);return}const L=setInterval(()=>{typeof window<"u"&&window.openai&&(n(!0),clearInterval(L))},100),$=ze(()=>{typeof window<"u"&&window.openai&&(n(!0),clearInterval(L))},"handleSetGlobals");typeof window<"u"&&window.addEventListener(zp,$);const H=setTimeout(()=>{clearInterval(L),typeof window<"u"&&window.removeEventListener(zp,$)},5e3);return()=>{clearInterval(L),clearTimeout(H),typeof window<"u"&&window.removeEventListener(zp,$)}},[]);const r=b.useMemo(()=>t?"openai":"mcp-ui",[t]),a=typeof window<"u"?window.location.search:"",o=b.useMemo(()=>{const L=new URLSearchParams(a);return L.has("mcpUseParams")?JSON.parse(L.get("mcpUseParams")):{toolInput:{},toolOutput:{},toolId:""}},[a]),i=r==="openai"?Mo("toolInput"):o.toolInput,l=r==="openai"?Mo("toolOutput"):o.toolOutput,u=Mo("toolResponseMetadata"),f=b.useMemo(()=>{if(u&&typeof u=="object"){const L=u["mcp-use/props"];if(L)return L}return e||{}},[u,e]),m=Mo("widgetState"),h=Mo("theme"),g=Mo("displayMode"),y=Mo("safeArea"),E=Mo("maxHeight"),x=Mo("userAgent"),w=Mo("locale"),S=b.useMemo(()=>typeof window<"u"&&window.__mcpPublicUrl?window.__mcpPublicUrl.replace(/\/mcp-use\/public$/,""):"",[]),[_,T]=b.useState(null);b.useEffect(()=>{m!==void 0&&T(m)},[m]);const A=b.useCallback(async(L,$)=>{if(!window.openai?.callTool)throw new Error("window.openai.callTool is not available");return window.openai.callTool(L,$)},[]),R=b.useCallback(async L=>{if(!window.openai?.sendFollowUpMessage)throw new Error("window.openai.sendFollowUpMessage is not available");return window.openai.sendFollowUpMessage({prompt:L})},[]),k=b.useCallback(L=>{if(!window.openai?.openExternal)throw new Error("window.openai.openExternal is not available");window.openai.openExternal({href:L})},[]),C=b.useCallback(async L=>{if(!window.openai?.requestDisplayMode)throw new Error("window.openai.requestDisplayMode is not available");return window.openai.requestDisplayMode({mode:L})},[]),O=b.useCallback(async L=>{if(!window.openai?.setWidgetState)throw new Error("window.openai.setWidgetState is not available");const H=typeof L=="function"?L(m!==void 0?m:_):L;return T(H),window.openai.setWidgetState(H)},[m,_]),M=b.useMemo(()=>r==="openai"&&u===null,[r,u]);return{props:f,toolInput:i||{},output:l??null,metadata:u??null,state:_,setState:O,theme:h||"light",displayMode:g||"inline",safeArea:y||{insets:{top:0,bottom:0,left:0,right:0}},maxHeight:E||600,userAgent:x||{device:{type:"desktop"},capabilities:{hover:!0,touch:!1}},locale:w||"en",mcp_url:S,callTool:A,sendFollowUpMessage:R,openExternal:k,requestDisplayMode:C,isAvailable:t,isPending:M}}ze(Jd,"useWidget");function Zre(e){const{props:t}=Jd(e);return t}ze(Zre,"useWidgetProps");function qre(){const{theme:e}=Jd();return e}ze(qre,"useWidgetTheme");function Xre(e){const{state:t,setState:n}=Jd();return b.useEffect(()=>{t===null&&e!==void 0&&window.openai?.setWidgetState&&n(e)},[]),[t,n]}ze(Xre,"useWidgetState");var I$=ze(({children:e})=>{const{theme:t,isAvailable:n}=Jd();console.log("theme",t);const[r,a]=b.useState(()=>typeof window>"u"?"light":window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light");b.useEffect(()=>{if(typeof window>"u")return;const i=window.matchMedia("(prefers-color-scheme: dark)"),l=ze(u=>{a(u.matches?"dark":"light")},"handleChange");return i.addEventListener("change",l),()=>i.removeEventListener("change",l)},[]);const o=n?t:r;return b.useLayoutEffect(()=>{typeof document>"u"||(o==="dark"?document.documentElement.classList.add("dark"):document.documentElement.classList.remove("dark"))},[o]),ue.createElement(ue.Fragment,null,e)},"ThemeProvider");function NB({children:e,className:t="",position:n="top-right",attachTo:r,showLabels:a=!0,debugger:o=!1,viewControls:i=!1}){const{props:l,output:u,metadata:f,state:m,theme:h,displayMode:g,safeArea:y,maxHeight:E,userAgent:x,locale:w,isAvailable:S,callTool:_,sendFollowUpMessage:T,openExternal:A,requestDisplayMode:R,setState:k}=Jd(),[C,O]=b.useState(!1),[M,L]=b.useState(!1),$=b.useRef(null),H=b.useRef(null),[V,Z]=b.useState([]),[ne,G]=b.useState(""),[Y,F]=b.useState("get-my-city"),[re,ee]=b.useState("{}"),[j,B]=b.useState("Test follow-up message"),[z,D]=b.useState("https://mcp-use.com/docs"),P=g==="fullscreen"&&S,W=g==="pip"&&S,K=typeof window<"u"&&window.location.pathname.includes("/inspector/api/");b.useEffect(()=>{const Ee=setTimeout(()=>{if(typeof window<"u"&&window.openai)try{const _e=Object.keys(window.openai);Z(_e)}catch{Z([])}else Z([])},100);return()=>{clearTimeout(Ee)}},[]);const ae=h==="dark",oe=ze(()=>{const Ee=["absolute","z-[1000]","flex","gap-2","transition-opacity","duration-200","ease-in-out",C?"opacity-100":"opacity-0",C?"pointer-events-auto":"pointer-events-none"];switch(n){case"top-left":return[...Ee,"top-4","left-4"];case"top-center":return[...Ee,"top-4","left-1/2","-translate-x-1/2"];case"top-right":return[...Ee,"top-4","right-4"];case"center-left":return[...Ee,"top-1/2","left-4","-translate-y-1/2"];case"center-right":return[...Ee,"top-1/2","right-4","-translate-y-1/2"];case"bottom-left":return[...Ee,"bottom-4","left-4"];case"bottom-center":return[...Ee,"bottom-4","left-1/2","-translate-x-1/2"];case"bottom-right":return[...Ee,"bottom-4","right-4"];default:return[...Ee,"top-4","right-4"]}},"getPositionClasses"),le=ze(()=>{const _e=y?.insets?.top?Math.max(16,y.insets.top+8):16,Be=y?.insets?.right?Math.max(16,y.insets.right+8):16,it=y?.insets?.bottom?Math.max(16,y.insets.bottom+8):16,qe=y?.insets?.left?Math.max(16,y.insets.left+8):16,lt={};switch(n){case"top-left":lt.top=`${_e}px`,lt.left=`${qe}px`;break;case"top-center":lt.top=`${_e}px`;break;case"top-right":lt.top=`${_e}px`,lt.right=`${Be}px`;break;case"center-left":lt.left=`${qe}px`;break;case"center-right":lt.right=`${Be}px`;break;case"bottom-left":lt.bottom=`${it}px`,lt.left=`${qe}px`;break;case"bottom-center":lt.bottom=`${it}px`;break;case"bottom-right":lt.bottom=`${it}px`,lt.right=`${Be}px`;break;default:lt.top=`${_e}px`,lt.right=`${Be}px`;break}return lt},"getPositionOffsetStyles");b.useEffect(()=>{if(!r)return;const Ee=ze(()=>O(!0),"handleMouseEnter"),_e=ze(()=>O(!1),"handleMouseLeave");return r.addEventListener("mouseenter",Ee),r.addEventListener("mouseleave",_e),()=>{r.removeEventListener("mouseenter",Ee),r.removeEventListener("mouseleave",_e)}},[r]),b.useEffect(()=>{if(!M)return;const Ee=ze(_e=>{H.current&&!H.current.contains(_e.target)&&L(!1)},"handleClickOutside");return document.addEventListener("mousedown",Ee),()=>{document.removeEventListener("mousedown",Ee)}},[M]),b.useEffect(()=>(M?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[M]);const Q=ze(()=>{L(!M)},"handleToggleOverlay"),J=ze(async()=>{try{G("Calling tool...");const Ee=re.trim()?JSON.parse(re):{},_e=await _(Y,Ee);G(`Success: ${JSON.stringify(_e,null,2)}`)}catch(Ee){G(`Error: ${Ee.message}`)}},"handleCallTool"),q=ze(async()=>{try{G("Sending follow-up message..."),await T(j),G("Follow-up message sent successfully")}catch(Ee){G(`Error: ${Ee.message}`)}},"handleSendFollowUpMessage"),ie=ze(()=>{try{A(z),G(`Opened external link: ${z}`)}catch(Ee){G(`Error: ${Ee.message}`)}},"handleOpenExternal"),he=ze(async Ee=>{try{G(`Requesting display mode: ${Ee}...`);const _e=await R(Ee);G(`Display mode granted: ${_e.mode}`)}catch(_e){G(`Error: ${_e.message}`)}},"handleRequestDisplayMode"),Ne=ze(async()=>{try{const Ee=m?{...m,debugTimestamp:new Date().toISOString()}:{debugTimestamp:new Date().toISOString()};G("Setting state..."),await k(Ee),G(`State updated: ${JSON.stringify(Ee,null,2)}`)}catch(Ee){G(`Error: ${Ee.message}`)}},"handleSetState"),Ye=ze(async()=>{try{await R("fullscreen")}catch(Ee){console.error("Failed to go fullscreen:",Ee)}},"handleFullscreen"),Pe=ze(async()=>{try{await R("pip")}catch(Ee){console.error("Failed to go pip:",Ee)}},"handlePip"),Ue=ze(()=>{const Ee=["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[...Ee,"top-full","right-0","mt-2"];case"top-left":return[...Ee,"top-full","left-0","mt-2"];case"top-center":return[...Ee,"top-full","left-1/2","-translate-x-1/2","mt-2"];case"bottom-right":return[...Ee,"bottom-full","right-0","mb-2"];case"bottom-left":return[...Ee,"bottom-full","left-0","mb-2"];case"bottom-center":return[...Ee,"bottom-full","left-1/2","-translate-x-1/2","mb-2"];case"center-left":return[...Ee,"left-full","top-1/2","-translate-y-1/2","ml-2"];case"center-right":return[...Ee,"right-full","top-1/2","-translate-y-1/2","mr-2"];default:return[...Ee,"top-full","right-0","mt-2"]}},"getTooltipClasses"),st=ze(({onClick:Ee,label:_e,children:Be})=>{const[it,qe]=b.useState(!1),lt=Ue();return ue.createElement("button",{className:`p-2 ${ae?"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 ${ae?"shadow-[0_2px_8px_rgba(0,0,0,0.3)]":"shadow-[0_2px_8px_rgba(0,0,0,0.2)]"} relative`,onMouseEnter:()=>qe(!0),onMouseLeave:()=>qe(!1),onClick:Ee,"aria-label":_e},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"},Be),a&&ue.createElement("span",{className:`${lt.join(" ")} ${it?"opacity-100":"opacity-0"}`},_e))},"IconButton"),Ve=ze(Ee=>{if(Ee===null)return"null";if(Ee===void 0)return"undefined";if(typeof Ee=="object")try{return JSON.stringify(Ee,null,2)}catch{return String(Ee)}return String(Ee)},"formatValue"),ut=ze(Ee=>Ee?`${Ee.device?.type||"unknown"}`:"N/A","formatUserAgent"),rt=ze(Ee=>{if(!Ee?.insets)return"N/A";const{top:_e,bottom:Be,left:it,right:qe}=Ee.insets;return`T:${_e} B:${Be} L:${it} R:${qe}`},"formatSafeArea");return ue.createElement(ue.Fragment,null,ue.createElement("div",{ref:$,className:`${t} relative h-fit`,onMouseEnter:()=>!r&&O(!0),onMouseLeave:()=>!r&&O(!1)},ue.createElement("div",{className:oe().join(" "),style:le()},!K&&ue.createElement(ue.Fragment,null,!P&&!W&&ue.createElement(ue.Fragment,null,(i===!0||i==="fullscreen")&&ue.createElement(st,{onClick:Ye,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"})),(i===!0||i==="pip")&&ue.createElement(st,{onClick:Pe,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"}))),o&&ue.createElement(st,{onClick:Q,label:"Debug Info"},ue.createElement("path",{d:"M12 20v-9"}),ue.createElement("path",{d:"M14 7a4 4 0 0 1 4 4v3a6 6 0 0 1-12 0v-3a4 4 0 0 1 4-4z"}),ue.createElement("path",{d:"M14.12 3.88 16 2"}),ue.createElement("path",{d:"M21 21a4 4 0 0 0-3.81-4"}),ue.createElement("path",{d:"M21 5a4 4 0 0 1-3.55 3.97"}),ue.createElement("path",{d:"M22 13h-4"}),ue.createElement("path",{d:"M3 21a4 4 0 0 1 3.81-4"}),ue.createElement("path",{d:"M3 5a4 4 0 0 0 3.55 3.97"}),ue.createElement("path",{d:"M6 13H2"}),ue.createElement("path",{d:"m8 2 1.88 1.88"}),ue.createElement("path",{d:"M9 7.13V6a3 3 0 1 1 6 0v1.13"})))),e),M&&o&&ue.createElement("div",{ref:H,className:"fixed inset-0 bg-black text-white font-mono text-xs z-[10000] overflow-auto p-4",onClick:Ee=>{Ee.target===H.current&&L(!1)}},ue.createElement("button",{onClick:()=>L(!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"},Ve(l))),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"},Ve(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"},Ve(f))),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"},Ve(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"},w)),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"},E,"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"},ut(x))),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"},rt(y))),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"},S?"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"},V.length>0?V.join(", "):"N/A")))),ue.createElement("h2",{className:"text-base font-bold mt-8 mb-4 border-b border-gray-700 pb-2"},"Actions"),ue.createElement("div",{className:"flex flex-col gap-3"},ue.createElement("div",{className:"flex gap-2 items-center"},ue.createElement("input",{type:"text",value:Y,onChange:Ee=>F(Ee.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:Ee=>ee(Ee.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:J,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:Ee=>B(Ee.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:q,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:Ee=>D(Ee.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:ie,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:()=>he("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:()=>he("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:()=>he("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:Ne,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)")),ne&&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:"),ne,ue.createElement("button",{onClick:()=>G(""),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(NB,"WidgetControls");function CB(){if(typeof window>"u")return"/";const t=window.location.pathname.match(/^(\/inspector\/api\/dev-widget\/[^/]+)/);return t?t[1]:"/"}ze(CB,"getBasename");var Jre=150,Qre=5;function eae({children:e,debugger:t=!1,viewControls:n=!1,autoSize:r=!1}){const a=CB(),o=b.useRef(null),i=b.useRef(0),l=b.useRef(null),u=b.useRef(!1),[f,m]=b.useState(null),[h,g]=b.useState(null),[y,E]=b.useState(!0);b.useEffect(()=>{let _=!0;return(async()=>{try{const T=await Ua(()=>import("./index-CwF58WkY.js"),[]);_&&(m(()=>T.BrowserRouter),E(!1))}catch{_&&(g(new Error(`❌ react-router not installed!
35
+ `&&r++}}return[t,n]}class Dre extends TransformStream{constructor({onError:t,onRetry:n,onComment:r}={}){let a;super({start(o){a=vB({onEvent:i=>{o.enqueue(i)},onError(i){t==="terminate"?o.error(i):typeof t=="function"&&t(i)},onRetry:n,onComment:r})},transform(o){a.feed(o)}})}}const Lre={initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:2};class Vi extends Error{constructor(t,n){super(`Streamable HTTP error: ${n}`),this.code=t}}class Mre{constructor(t,n){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=oB(n?.fetch,n?.requestInit),this._sessionId=n?.sessionId,this._reconnectionOptions=n?.reconnectionOptions??Lre}async _authThenStart(){if(!this._authProvider)throw new yo("No auth provider");let t;try{t=await Ws(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(n){throw this.onerror?.(n),n}if(t!=="AUTHORIZED")throw new yo;return await this._startOrAuthSse({resumptionToken:void 0})}async _commonHeaders(){const t={};if(this._authProvider){const r=await this._authProvider.tokens();r&&(t.Authorization=`Bearer ${r.access_token}`)}this._sessionId&&(t["mcp-session-id"]=this._sessionId),this._protocolVersion&&(t["mcp-protocol-version"]=this._protocolVersion);const n=My(this._requestInit?.headers);return new Headers({...t,...n})}async _startOrAuthSse(t){const{resumptionToken:n}=t;try{const r=await this._commonHeaders();r.set("Accept","text/event-stream"),n&&r.set("last-event-id",n);const a=await(this._fetch??fetch)(this._url,{method:"GET",headers:r,signal:this._abortController?.signal});if(!a.ok){if(await a.body?.cancel(),a.status===401&&this._authProvider)return await this._authThenStart();if(a.status===405)return;throw new Vi(a.status,`Failed to open SSE stream: ${a.statusText}`)}this._handleSseStream(a.body,t,!0)}catch(r){throw this.onerror?.(r),r}}_getNextReconnectionDelay(t){if(this._serverRetryMs!==void 0)return this._serverRetryMs;const n=this._reconnectionOptions.initialReconnectionDelay,r=this._reconnectionOptions.reconnectionDelayGrowFactor,a=this._reconnectionOptions.maxReconnectionDelay;return Math.min(n*Math.pow(r,t),a)}_scheduleReconnection(t,n=0){const r=this._reconnectionOptions.maxRetries;if(n>=r){this.onerror?.(new Error(`Maximum reconnection attempts (${r}) exceeded.`));return}const a=this._getNextReconnectionDelay(n);this._reconnectionTimeout=setTimeout(()=>{this._startOrAuthSse(t).catch(o=>{this.onerror?.(new Error(`Failed to reconnect SSE stream: ${o instanceof Error?o.message:String(o)}`)),this._scheduleReconnection(t,n+1)})},a)}_handleSseStream(t,n,r){if(!t)return;const{onresumptiontoken:a,replayMessageId:o}=n;let i,l=!1,u=!1;(async()=>{try{const m=t.pipeThrough(new TextDecoderStream).pipeThrough(new Dre({onRetry:y=>{this._serverRetryMs=y}})).getReader();for(;;){const{value:y,done:E}=await m.read();if(E)break;if(y.id&&(i=y.id,l=!0,a?.(y.id)),!!y.data&&(!y.event||y.event==="message"))try{const x=Jb.parse(JSON.parse(y.data));Tp(x)&&(u=!0,o!==void 0&&(x.id=o)),this.onmessage?.(x)}catch(x){this.onerror?.(x)}}(r||l)&&!u&&this._abortController&&!this._abortController.signal.aborted&&this._scheduleReconnection({resumptionToken:i,onresumptiontoken:a,replayMessageId:o},0)}catch(m){if(this.onerror?.(new Error(`SSE stream disconnected: ${m}`)),(r||l)&&!u&&this._abortController&&!this._abortController.signal.aborted)try{this._scheduleReconnection({resumptionToken:i,onresumptiontoken:a,replayMessageId:o},0)}catch(y){this.onerror?.(new Error(`Failed to reconnect: ${y instanceof Error?y.message:String(y)}`))}}})()}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 yo("No auth provider");if(await Ws(this._authProvider,{serverUrl:this._url,authorizationCode:t,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new yo("Failed to authorize")}async close(){this._reconnectionTimeout&&(clearTimeout(this._reconnectionTimeout),this._reconnectionTimeout=void 0),this._abortController?.abort(),this.onclose?.()}async send(t,n){try{const{resumptionToken:r,onresumptiontoken:a}=n||{};if(r){this._startOrAuthSse({resumptionToken:r,replayMessageId:DS(t)?t.id:void 0}).catch(g=>this.onerror?.(g));return}const o=await this._commonHeaders();o.set("content-type","application/json"),o.set("accept","application/json, text/event-stream");const i={...this._requestInit,method:"POST",headers:o,body:JSON.stringify(t),signal:this._abortController?.signal},l=await(this._fetch??fetch)(this._url,i),u=l.headers.get("mcp-session-id");if(u&&(this._sessionId=u),!l.ok){const g=await l.text().catch(()=>null);if(l.status===401&&this._authProvider){if(this._hasCompletedAuthFlow)throw new Vi(401,"Server returned 401 after successful authentication");const{resourceMetadataUrl:y,scope:E}=am(l);if(this._resourceMetadataUrl=y,this._scope=E,await Ws(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new yo;return this._hasCompletedAuthFlow=!0,this.send(t)}if(l.status===403&&this._authProvider){const{resourceMetadataUrl:y,scope:E,error:x}=am(l);if(x==="insufficient_scope"){const w=l.headers.get("WWW-Authenticate");if(this._lastUpscopingHeader===w)throw new Vi(403,"Server returned 403 after trying upscoping");if(E&&(this._scope=E),y&&(this._resourceMetadataUrl=y),this._lastUpscopingHeader=w??void 0,await Ws(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetch})!=="AUTHORIZED")throw new yo;return this.send(t)}}throw new Vi(l.status,`Error POSTing to endpoint: ${g}`)}if(this._hasCompletedAuthFlow=!1,this._lastUpscopingHeader=void 0,l.status===202){await l.body?.cancel(),See(t)&&this._startOrAuthSse({resumptionToken:void 0}).catch(g=>this.onerror?.(g));return}const m=(Array.isArray(t)?t:[t]).filter(g=>"method"in g&&"id"in g&&g.id!==void 0).length>0,h=l.headers.get("content-type");if(m)if(h?.includes("text/event-stream"))this._handleSseStream(l.body,{onresumptiontoken:a},!1);else if(h?.includes("application/json")){const g=await l.json(),y=Array.isArray(g)?g.map(E=>Jb.parse(E)):[Jb.parse(g)];for(const E of y)this.onmessage?.(E)}else throw await l.body?.cancel(),new Vi(-1,`Unexpected content type: ${h}`);else await l.body?.cancel()}catch(r){throw this.onerror?.(r),r}}get sessionId(){return this._sessionId}async terminateSession(){if(this._sessionId)try{const t=await this._commonHeaders(),n={...this._requestInit,method:"DELETE",headers:t,signal:this._abortController?.signal},r=await(this._fetch??fetch)(this._url,n);if(await r.body?.cancel(),!r.ok&&r.status!==405)throw new Vi(r.status,`Failed to terminate session: ${r.statusText}`);this._sessionId=void 0}catch(t){throw this.onerror?.(t),t}}setProtocolVersion(t){this._protocolVersion=t}get protocolVersion(){return this._protocolVersion}async resumeStream(t,n){await this._startOrAuthSse({resumptionToken:t,onresumptiontoken:n?.onresumptiontoken})}}class T$ extends Event{constructor(t,n){var r,a;super(t),this.code=(r=n?.code)!=null?r:void 0,this.message=(a=n?.message)!=null?a:void 0}[Symbol.for("nodejs.util.inspect.custom")](t,n,r){return r(N$(this),n)}[Symbol.for("Deno.customInspect")](t,n){return t(N$(this),n)}}function jre(e){const t=globalThis.DOMException;return typeof t=="function"?new t(e,"SyntaxError"):new SyntaxError(e)}function WS(e){return e instanceof Error?"errors"in e&&Array.isArray(e.errors)?e.errors.map(WS).join(", "):"cause"in e&&e.cause instanceof Error?`${e}: ${WS(e.cause)}`:e.message:`${e}`}function N$(e){return{type:e.type,message:e.message,code:e.code,defaultPrevented:e.defaultPrevented,cancelable:e.cancelable,timeStamp:e.timeStamp}}var wB=e=>{throw TypeError(e)},EN=(e,t,n)=>t.has(e)||wB("Cannot "+n),un=(e,t,n)=>(EN(e,t,"read from private field"),n?n.call(e):t.get(e)),Mr=(e,t,n)=>t.has(e)?wB("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),or=(e,t,n,r)=>(EN(e,t,"write to private field"),t.set(e,n),n),Hs=(e,t,n)=>(EN(e,t,"access private method"),n),$a,Zl,wu,ey,zy,$p,Du,Up,Wi,xu,Zu,Eu,Np,jo,KS,YS,ZS,C$,qS,XS,Cp,JS,QS;class ty extends EventTarget{constructor(t,n){var r,a;super(),Mr(this,jo),this.CONNECTING=0,this.OPEN=1,this.CLOSED=2,Mr(this,$a),Mr(this,Zl),Mr(this,wu),Mr(this,ey),Mr(this,zy),Mr(this,$p),Mr(this,Du),Mr(this,Up,null),Mr(this,Wi),Mr(this,xu),Mr(this,Zu,null),Mr(this,Eu,null),Mr(this,Np,null),Mr(this,YS,async o=>{var i;un(this,xu).reset();const{body:l,redirected:u,status:f,headers:m}=o;if(f===204){Hs(this,jo,Cp).call(this,"Server sent HTTP 204, not reconnecting",204),this.close();return}if(u?or(this,wu,new URL(o.url)):or(this,wu,void 0),f!==200){Hs(this,jo,Cp).call(this,`Non-200 status code (${f})`,f);return}if(!(m.get("content-type")||"").startsWith("text/event-stream")){Hs(this,jo,Cp).call(this,'Invalid content type, expected "text/event-stream"',f);return}if(un(this,$a)===this.CLOSED)return;or(this,$a,this.OPEN);const h=new Event("open");if((i=un(this,Np))==null||i.call(this,h),this.dispatchEvent(h),typeof l!="object"||!l||!("getReader"in l)){Hs(this,jo,Cp).call(this,"Invalid response body, expected a web ReadableStream",f),this.close();return}const g=new TextDecoder,y=l.getReader();let E=!0;do{const{done:x,value:w}=await y.read();w&&un(this,xu).feed(g.decode(w,{stream:!x})),x&&(E=!1,un(this,xu).reset(),Hs(this,jo,JS).call(this))}while(E)}),Mr(this,ZS,o=>{or(this,Wi,void 0),!(o.name==="AbortError"||o.type==="aborted")&&Hs(this,jo,JS).call(this,WS(o))}),Mr(this,qS,o=>{typeof o.id=="string"&&or(this,Up,o.id);const i=new MessageEvent(o.event||"message",{data:o.data,origin:un(this,wu)?un(this,wu).origin:un(this,Zl).origin,lastEventId:o.id||""});un(this,Eu)&&(!o.event||o.event==="message")&&un(this,Eu).call(this,i),this.dispatchEvent(i)}),Mr(this,XS,o=>{or(this,$p,o)}),Mr(this,QS,()=>{or(this,Du,void 0),un(this,$a)===this.CONNECTING&&Hs(this,jo,KS).call(this)});try{if(t instanceof URL)or(this,Zl,t);else if(typeof t=="string")or(this,Zl,new URL(t,Pre()));else throw new Error("Invalid URL")}catch{throw jre("An invalid or illegal string was specified")}or(this,xu,vB({onEvent:un(this,qS),onRetry:un(this,XS)})),or(this,$a,this.CONNECTING),or(this,$p,3e3),or(this,zy,(r=n?.fetch)!=null?r:globalThis.fetch),or(this,ey,(a=n?.withCredentials)!=null?a:!1),Hs(this,jo,KS).call(this)}get readyState(){return un(this,$a)}get url(){return un(this,Zl).href}get withCredentials(){return un(this,ey)}get onerror(){return un(this,Zu)}set onerror(t){or(this,Zu,t)}get onmessage(){return un(this,Eu)}set onmessage(t){or(this,Eu,t)}get onopen(){return un(this,Np)}set onopen(t){or(this,Np,t)}addEventListener(t,n,r){const a=n;super.addEventListener(t,a,r)}removeEventListener(t,n,r){const a=n;super.removeEventListener(t,a,r)}close(){un(this,Du)&&clearTimeout(un(this,Du)),un(this,$a)!==this.CLOSED&&(un(this,Wi)&&un(this,Wi).abort(),or(this,$a,this.CLOSED),or(this,Wi,void 0))}}$a=new WeakMap,Zl=new WeakMap,wu=new WeakMap,ey=new WeakMap,zy=new WeakMap,$p=new WeakMap,Du=new WeakMap,Up=new WeakMap,Wi=new WeakMap,xu=new WeakMap,Zu=new WeakMap,Eu=new WeakMap,Np=new WeakMap,jo=new WeakSet,KS=function(){or(this,$a,this.CONNECTING),or(this,Wi,new AbortController),un(this,zy)(un(this,Zl),Hs(this,jo,C$).call(this)).then(un(this,YS)).catch(un(this,ZS))},YS=new WeakMap,ZS=new WeakMap,C$=function(){var e;const t={mode:"cors",redirect:"follow",headers:{Accept:"text/event-stream",...un(this,Up)?{"Last-Event-ID":un(this,Up)}:void 0},cache:"no-store",signal:(e=un(this,Wi))==null?void 0:e.signal};return"window"in globalThis&&(t.credentials=this.withCredentials?"include":"same-origin"),t},qS=new WeakMap,XS=new WeakMap,Cp=function(e,t){var n;un(this,$a)!==this.CLOSED&&or(this,$a,this.CLOSED);const r=new T$("error",{code:t,message:e});(n=un(this,Zu))==null||n.call(this,r),this.dispatchEvent(r)},JS=function(e,t){var n;if(un(this,$a)===this.CLOSED)return;or(this,$a,this.CONNECTING);const r=new T$("error",{code:t,message:e});(n=un(this,Zu))==null||n.call(this,r),this.dispatchEvent(r),or(this,Du,setTimeout(un(this,QS),un(this,$p)))},QS=new WeakMap,ty.CONNECTING=0,ty.OPEN=1,ty.CLOSED=2;function Pre(){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 $re extends Error{constructor(t,n,r){super(`SSE error: ${n}`),this.code=t,this.event=r}}class Ure{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=oB(n?.fetch,n?.requestInit)}async _authThenStart(){if(!this._authProvider)throw new yo("No auth provider");let t;try{t=await Ws(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(n){throw this.onerror?.(n),n}if(t!=="AUTHORIZED")throw new yo;return await this._startOrAuth()}async _commonHeaders(){const t={};if(this._authProvider){const r=await this._authProvider.tokens();r&&(t.Authorization=`Bearer ${r.access_token}`)}this._protocolVersion&&(t["mcp-protocol-version"]=this._protocolVersion);const n=My(this._requestInit?.headers);return new Headers({...t,...n})}_startOrAuth(){const t=this?._eventSourceInit?.fetch??this._fetch??fetch;return new Promise((n,r)=>{this._eventSource=new ty(this._url.href,{...this._eventSourceInit,fetch:async(a,o)=>{const i=await this._commonHeaders();i.set("Accept","text/event-stream");const l=await t(a,{...o,headers:i});if(l.status===401&&l.headers.has("www-authenticate")){const{resourceMetadataUrl:u,scope:f}=am(l);this._resourceMetadataUrl=u,this._scope=f}return l}}),this._abortController=new AbortController,this._eventSource.onerror=a=>{if(a.code===401&&this._authProvider){this._authThenStart().then(n,r);return}const o=new $re(a.code,a.message,a);r(o),this.onerror?.(o)},this._eventSource.onopen=()=>{},this._eventSource.addEventListener("endpoint",a=>{const o=a;try{if(this._endpoint=new URL(o.data,this._url),this._endpoint.origin!==this._url.origin)throw new Error(`Endpoint origin does not match connection origin: ${this._endpoint.origin}`)}catch(i){r(i),this.onerror?.(i),this.close();return}n()}),this._eventSource.onmessage=a=>{const o=a;let i;try{i=Jb.parse(JSON.parse(o.data))}catch(l){this.onerror?.(l);return}this.onmessage?.(i)}})}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 yo("No auth provider");if(await Ws(this._authProvider,{serverUrl:this._url,authorizationCode:t,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new yo("Failed to authorize")}async close(){this._abortController?.abort(),this._eventSource?.close(),this.onclose?.()}async send(t){if(!this._endpoint)throw new Error("Not connected");try{const n=await this._commonHeaders();n.set("content-type","application/json");const r={...this._requestInit,method:"POST",headers:n,body:JSON.stringify(t),signal:this._abortController?.signal},a=await(this._fetch??fetch)(this._endpoint,r);if(!a.ok){const o=await a.text().catch(()=>null);if(a.status===401&&this._authProvider){const{resourceMetadataUrl:i,scope:l}=am(a);if(this._resourceMetadataUrl=i,this._scope=l,await Ws(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new yo;return this.send(t)}throw new Error(`Error POSTing to endpoint (HTTP ${a.status}): ${o}`)}await a.body?.cancel()}catch(n){throw this.onerror?.(n),n}}setProtocolVersion(t){this._protocolVersion=t}}var xd,zre=(xd=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={},r){return this.connector.callTool(t,n,r)}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,r){return this.connector.request(t,n,r)}},ze(xd,"MCPSession"),xd),Ed,Fre=(Ed=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,rs.getInstance().trackClientAddServer(t,n)}removeServer(t){this.config.mcpServers?.[t]&&(delete this.config.mcpServers[t],this.activeSessions=this.activeSessions.filter(n=>n!==t),rs.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 r=this.config.mcpServers??{};if(Object.keys(r).length===0&&He.warn("No MCP servers defined in config"),!r[t])throw new Error(`Server '${t}' not found in config`);const a=this.createConnectorFromConfig(r[t]),o=new zre(a);return n&&await o.initialize(),this.sessions[t]=o,this.activeSessions.includes(t)||this.activeSessions.push(t),o}async createAllSessions(t=!0){const n=this.config.mcpServers??{};Object.keys(n).length===0&&He.warn("No MCP servers defined in config");for(const r of Object.keys(n))await this.createSession(r,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){He.warn(`No session exists for server ${t}, nothing to close`);return}try{He.debug(`Closing session for server ${t}`),await n.disconnect()}catch(r){He.error(`Error closing session for server '${t}': ${r}`)}finally{delete this.sessions[t],this.activeSessions=this.activeSessions.filter(r=>r!==t)}}async closeAllSessions(){const t=Object.keys(this.sessions),n=[];for(const r of t)try{He.debug(`Closing session for server ${r}`),await this.closeSession(r)}catch(a){const o=`Failed to close session for server '${r}': ${a}`;He.error(o),n.push(o)}n.length?He.error(`Encountered ${n.length} errors while closing sessions`):He.debug("All sessions closed successfully")}},ze(Ed,"BaseMCPClient"),Ed),Sd,Bre=(Sd=class{_readyPromise;_readyResolver;_donePromise;_doneResolver;_exception=null;_connection=null;_task=null;_abortController=null;constructor(){this.reset()}async start(){if(this.reset(),He.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){He.debug(`Cancelling ${this.constructor.name} task`),this._abortController.abort();try{await this._task}catch(t){t instanceof Error&&t.name==="AbortError"?He.debug(`${this.constructor.name} task aborted successfully`):He.warn(`Error stopping ${this.constructor.name} task: ${t}`)}}await this._donePromise,He.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(){He.debug(`Running ${this.constructor.name} task`);try{this._connection=await this.establishConnection(),He.debug(`${this.constructor.name} connected successfully`),this._readyResolver(),await this.waitForAbort()}catch(t){this._exception=t,He.error(`Error in ${this.constructor.name} task: ${t}`),this._readyResolver()}finally{if(this._connection!==null){try{await this.closeConnection(this._connection)}catch(t){He.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 r=this._abortController.signal;if(r.aborted){t();return}const a=ze(()=>{r.removeEventListener("abort",a),t()},"onAbort");r.addEventListener("abort",a)})}},ze(Sd,"ConnectionManager"),Sd),_d,Hre=(_d=class extends Bre{url;opts;_transport=null;reinitializing=!1;constructor(t,n){super(),this.url=typeof t=="string"?new URL(t):t,this.opts=n}async establishConnection(){const t=new Ure(this.url,this.opts),n=t.send.bind(t);return t.send=async r=>{const a=ze(async o=>{if(Array.isArray(o))for(const i of o)await n(i);else await n(o)},"sendMessage");try{await a(r)}catch(o){if(o?.code===404&&t.sessionId&&!this.reinitializing){He.warn("[SSE] Session not found (404), re-initializing per MCP spec..."),this.reinitializing=!0;try{t.sessionId=void 0,await this.reinitialize(t),He.info("[SSE] Re-initialization successful, retrying request"),await a(r)}finally{this.reinitializing=!1}}else throw o}},this._transport=t,He.debug(`${this.constructor.name} connected successfully`),t}async reinitialize(t){He.debug("[SSE] Re-initialization triggered")}async closeConnection(t){if(this._transport)try{await this._transport.close()}catch(n){He.warn(`Error closing SSE transport: ${n}`)}finally{this._transport=null}}},ze(_d,"SseConnectionManager"),_d),Td,Vre=(Td=class extends Ute{baseUrl;headers;timeout;sseReadTimeout;clientInfo;preferSse;disableSseFallback;gatewayUrl;serverId;transportType=null;streamableTransport=null;constructor(t,n={}){super(n);const r=t.replace(/\/$/,"");this.gatewayUrl=n.gatewayUrl,this.serverId=n.serverId,this.gatewayUrl?(this.baseUrl=this.gatewayUrl.replace(/\/$/,""),this.headers={...n.headers??{}},this.headers["X-Target-URL"]=r,this.serverId&&(this.headers["X-Server-Id"]=this.serverId)):(this.baseUrl=r,this.headers={...n.headers??{}}),n.authToken&&(this.headers.Authorization=`Bearer ${n.authToken}`),this.timeout=n.timeout??1e4,this.sseReadTimeout=n.sseReadTimeout??3e5,this.clientInfo=n.clientInfo??{name:"http-connector",version:"1.0.0"},this.preferSse=n.preferSse??!1,this.disableSseFallback=n.disableSseFallback??!1}async connect(){if(this.connected){He.debug("Already connected to MCP implementation");return}const t=this.baseUrl;if(this.preferSse){He.debug(`Connecting to MCP implementation via HTTP/SSE: ${t}`),await this.connectWithSse(t);return}He.debug(`Connecting to MCP implementation via HTTP: ${t}`);try{He.info("🔄 Attempting streamable HTTP transport..."),await this.connectWithStreamableHttp(t),He.info("✅ Successfully connected via streamable HTTP")}catch(n){console.log("error in http connector connect",n);let r="Unknown error",a=!1,o,i=null;if(n instanceof Vi?i=n:n instanceof Error&&n.cause instanceof Vi&&(i=n.cause),i)a=i.code===401,o=i.code,console.log("Captured HTTP status code:",o),i.code===400&&i.message.includes("Missing session ID")?(r="Server requires session ID (FastMCP compatibility) - using SSE transport",He.warn(`⚠️ ${r}`)):i.code===404||i.code===405?(r=`Server returned ${i.code} - server likely doesn't support streamable HTTP`,He.debug(r)):(r=`Server returned ${i.code}: ${i.message}`,He.debug(r));else if(n instanceof Error){const l=n.toString(),u=n.message||"";a=l.includes("401")||u.includes("Unauthorized"),l.includes("Missing session ID")||l.includes("Bad Request: Missing session ID")||u.includes("FastMCP session ID error")?(r="Server requires session ID (FastMCP compatibility) - using SSE transport",He.warn(`⚠️ ${r}`)):l.includes("405 Method Not Allowed")||l.includes("404 Not Found")?(r="Server doesn't support streamable HTTP (405/404)",He.debug(r)):(r=`Streamable HTTP failed: ${n.message}`,He.debug(r))}if(a){He.info("Authentication required - skipping SSE fallback"),await this.cleanupResources();const l=new Error("Authentication required");throw l.code=401,l}He.info("🔄 Falling back to SSE transport...");try{await this.connectWithSse(t)}catch(l){if(console.error("Failed to connect with both transports:"),console.error(` Streamable HTTP: ${r}`),console.error(` SSE: ${l}`),await this.cleanupResources(),l?.message?.includes("401")||l?.message?.includes("Unauthorized")){const m=new Error("Authentication required");throw m.code=401,m}const f=new Error(`Could not connect to server with any available transport. Streamable HTTP: ${r}`);throw o!==void 0&&(Object.defineProperty(f,"code",{value:o,writable:!1,enumerable:!0,configurable:!0}),He.debug(`Preserving HTTP status code ${o} in error for proxy fallback detection`)),f}}}async connectWithStreamableHttp(t){try{console.log("[HttpConnector] Connecting with Streamable HTTP:"),console.log(` Base URL: ${t}`),console.log(` Original URL: ${this.baseUrl}`),console.log(` Gateway URL: ${this.gatewayUrl||"none"}`),console.log(` Auth Provider URL: ${this.opts.authProvider?.serverUrl||"none"}`),console.log(` Headers: ${JSON.stringify(this.headers)}`);const n=new Mre(new URL(t),{authProvider:this.opts.authProvider,requestInit:{headers:this.headers},reconnectionOptions:{maxReconnectionDelay:3e4,initialReconnectionDelay:1e3,reconnectionDelayGrowFactor:1.5,maxRetries:2}});let r=n;if(this.opts.wrapTransport){const o=this.baseUrl;r=this.opts.wrapTransport(r,o)}const a={...this.opts.clientOptions||{},capabilities:{...this.opts.clientOptions?.capabilities||{},roots:{listChanged:!0},...this.opts.samplingCallback?{sampling:{}}:{},...this.opts.elicitationCallback?{elicitation:{form:{},url:{}}}:{}}};He.debug("Creating Client with capabilities:",JSON.stringify(a.capabilities,null,2)),this.client=new x$(this.clientInfo,a),this.setupRootsHandler(),He.debug("Roots handler registered before connect");try{await this.client.connect(r,{timeout:this.timeout});const o=n.sessionId;o?He.debug(`Session ID obtained: ${o}`):He.warn("Session ID not available after connect - this may cause issues with SSE stream")}catch(o){if(o instanceof Error){const i=o.message||o.toString();if(i.includes("Missing session ID")||i.includes("Bad Request: Missing session ID")||i.includes("Mcp-Session-Id header is required")){const l=new Error(`Session ID error: ${i}. The SDK should automatically extract session ID from initialize response.`);throw l.cause=o,l}}throw o}this.streamableTransport=n,this.connectionManager={stop:ze(async()=>{if(this.streamableTransport)try{await this.streamableTransport.terminateSession(),await this.streamableTransport.close()}catch(o){He.warn(`Error closing Streamable HTTP transport: ${o}`)}finally{this.streamableTransport=null}},"stop")},this.connected=!0,this.transportType="streamable-http",this.setupNotificationHandler(),this.setupSamplingHandler(),this.setupElicitationHandler(),He.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 Hre(t,{authProvider:this.opts.authProvider,requestInit:{headers:this.headers}});let n=await this.connectionManager.start();if(this.opts.wrapTransport){const a=this.baseUrl;n=this.opts.wrapTransport(n,a)}const r={...this.opts.clientOptions||{},capabilities:{...this.opts.clientOptions?.capabilities||{},roots:{listChanged:!0},...this.opts.samplingCallback?{sampling:{}}:{},...this.opts.elicitationCallback?{elicitation:{form:{},url:{}}}:{}}};He.debug("Creating Client with capabilities (SSE):",JSON.stringify(r.capabilities,null,2)),this.client=new x$(this.clientInfo,r),this.setupRootsHandler(),He.debug("Roots handler registered before connect (SSE)"),await this.client.connect(n),this.connected=!0,this.transportType="sse",this.setupNotificationHandler(),this.setupSamplingHandler(),this.setupElicitationHandler(),He.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(Td,"HttpConnector"),Td),lc,Gre=(lc=class extends Fre{static getPackageVersion(){return Tv()}constructor(t){super(t),this._trackClientInit()}_trackClientInit(){const t=Object.keys(this.config.mcpServers??{});rs.getInstance().trackMCPClientInit({codeMode:!1,sandbox:!1,allCallbacks:!1,verify:!1,servers:t,numServers:t.length,isBrowser:!0}).catch(n=>He.debug(`Failed to track BrowserMCPClient init: ${n}`))}static fromDict(t){return new lc(t)}createConnectorFromConfig(t){const{url:n,headers:r,authToken:a,authProvider:o,wrapTransport:i,clientOptions:l,onSampling:u,samplingCallback:f,elicitationCallback:m,disableSseFallback:h,preferSse:g,clientInfo:y,gatewayUrl:E,serverId:x}=t;if(!n)throw new Error("Server URL is required");const w=u??f,S={headers:r,authToken:a,authProvider:o,wrapTransport:i,clientOptions:l,onSampling:w,samplingCallback:w,elicitationCallback:m,disableSseFallback:h,preferSse:g,clientInfo:y,gatewayUrl:E,serverId:x};return l?console.log("[BrowserMCPClient] Passing clientOptions to connector:",JSON.stringify(l,null,2)):console.warn("[BrowserMCPClient] No clientOptions provided to connector!"),new Vre(n,S)}},ze(lc,"BrowserMCPClient"),lc);function Lu(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(xB).join("&"),n.hash=n.hash.slice(0,1)+encodeURIComponent(n.hash.slice(1)),n.href}ze(Lu,"sanitizeUrl");function xB([e,t]){return`${encodeURIComponent(e)}${t.length>0?`=${encodeURIComponent(t)}`:""}`}ze(xB,"sanitizeParam");async function EB(e){return typeof e=="string"?e:e instanceof URLSearchParams||e instanceof FormData?Object.fromEntries(e.entries()):e instanceof Blob?await e.text():e}ze(EB,"serializeBody");var Nd,ny=(Nd=class{serverUrl;storageKeyPrefix;serverUrlHash;clientName;clientUri;logoUri;callbackUrl;preventAutoAuth;useRedirectFlow;oauthProxyUrl;connectionUrl;originalFetch;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.logoUri=n.logoUri||"https://mcp-use.com/logo.png",this.callbackUrl=Lu(n.callbackUrl||(typeof window<"u"?new URL("/oauth/callback",window.location.origin).toString():"/oauth/callback")),this.preventAutoAuth=n.preventAutoAuth,this.useRedirectFlow=n.useRedirectFlow,this.oauthProxyUrl=n.oauthProxyUrl,this.connectionUrl=n.connectionUrl,this.onPopupWindow=n.onPopupWindow}installFetchInterceptor(){if(!this.oauthProxyUrl){console.warn("[BrowserOAuthProvider] No OAuth proxy URL configured, skipping fetch interceptor installation");return}if(!this.originalFetch)this.originalFetch=window.fetch;else{console.warn("[BrowserOAuthProvider] Fetch interceptor already installed");return}const t=this.oauthProxyUrl,n=this.connectionUrl,r=this.serverUrl,a=this.originalFetch;console.log(`[BrowserOAuthProvider] Installing fetch interceptor with proxy: ${t}`),window.fetch=ze(async function(i,l){const u=typeof i=="string"?i:i instanceof URL?i.toString():i.url;if(!(u.includes("/.well-known/")||u.match(/\/(register|token|authorize)$/)))return await a(i,l);try{const m=new URL(u),h=new URL(t);if(m.origin===h.origin&&(m.pathname.startsWith(h.pathname)||u.includes("/inspector/api/oauth")))return await a(i,l)}catch{}try{const m=u.includes("/.well-known/");let h=u;if(m&&r)try{const S=new URL(u),_=new URL(r);if(S.protocol==="http:"&&_.protocol==="https:"){const T=S.pathname.match(/(\/.well-known\/[^/]+)/),A=T?T[1]:S.pathname;h=`${_.origin}${A}`,console.log(`[OAuth Proxy] Rewrote gateway metadata URL ${u} to server URL ${h}`)}else if(n){const T=new URL(n);if(S.origin===T.origin&&S.origin!==_.origin){const A=S.pathname.match(/(\/.well-known\/[^/]+)/),R=A?A[1]:S.pathname;h=`${_.origin}${R}`,console.log(`[OAuth Proxy] Rewrote gateway metadata URL ${u} to server URL ${h}`)}}}catch(S){console.error("[OAuth Proxy] Error rewriting metadata URL:",S)}const g=m?`${t}/metadata?url=${encodeURIComponent(h)}`:`${t}/proxy`;if(console.log(`[OAuth Proxy] Routing ${m?"metadata":"request"} through: ${g}`),m){const S={...l?.headers?Object.fromEntries(new Headers(l.headers)):{}};n&&(S["X-Connection-URL"]=n);const _=new URL(g);return r&&_.searchParams.set("mcp_url",r),await a(_.toString(),{...l,method:"GET",headers:S})}let y=u;if(u.includes("/authorize")&&r)try{const S=new URL(u),_=S.searchParams.get("resource");if(_&&n){const T=new URL(n);(_.startsWith(T.origin)||_===n)&&(S.searchParams.set("resource",r),y=S.toString(),console.log(`[OAuth Proxy] Rewrote authorize resource parameter from ${_} to ${r}`))}}catch(S){console.error("[OAuth Proxy] Error rewriting authorize URL:",S)}let E=l?.body?await EB(l.body):void 0;if(u.includes("/token")&&r&&n&&E)try{const S=new URLSearchParams(E),_=S.get("resource");if(_){const T=new URL(n);(_.startsWith(T.origin)||_===n)&&(S.set("resource",r),E=S.toString(),console.log(`[OAuth Proxy] Rewrote token resource parameter from ${_} to ${r}`))}}catch(S){console.error("[OAuth Proxy] Error rewriting token body:",S)}const w=await(await a(g,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:y,method:l?.method||"POST",headers:l?.headers?Object.fromEntries(new Headers(l.headers)):{},body:E})})).json();return new Response(JSON.stringify(w.body),{status:w.status,statusText:w.statusText,headers:new Headers(w.headers)})}catch(m){return console.error("[OAuth Proxy] Request failed, falling back to direct fetch:",m),await a(i,l)}},"interceptedFetch")}restoreFetch(){this.originalFetch&&(console.log("[BrowserOAuthProvider] Restoring original fetch"),window.fetch=this.originalFetch,this.originalFetch=void 0)}get redirectUrl(){return Lu(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,logo_uri:this.logoUri}}async clientInformation(){const t=this.getKey("client_info"),n=localStorage.getItem(t);if(n)try{return JSON.parse(n)}catch(r){console.warn(`[${this.storageKeyPrefix}] Failed to parse client information:`,r),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(r){console.warn(`[${this.storageKeyPrefix}] Failed to parse tokens:`,r),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){if(this.connectionUrl&&this.serverUrl){const u=t.searchParams.get("resource");if(u)try{const f=new URL(this.connectionUrl);(u.startsWith(f.origin)||u===this.connectionUrl)&&(t.searchParams.set("resource",this.serverUrl),console.log(`[OAuth] Rewrote authorize resource parameter from ${u} to ${this.serverUrl}`))}catch(f){console.error("[OAuth] Error rewriting resource parameter:",f)}}const n=globalThis.crypto.randomUUID(),r=`${this.storageKeyPrefix}:state_${n}`,a={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,oauthProxyUrl:this.oauthProxyUrl,connectionUrl:this.connectionUrl},flowType:this.useRedirectFlow?"redirect":"popup",returnUrl:typeof window<"u"?window.location.href:void 0};console.log(`[OAuth] Storing state key: ${r}`),localStorage.setItem(r,JSON.stringify(a));const o=localStorage.getItem(r);console.log(`[OAuth] State stored successfully: ${!!o}`),t.searchParams.set("state",n);const i=t.toString(),l=Lu(i);return localStorage.setItem(this.getKey("last_auth_url"),l),l}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 r="width=600,height=700,resizable=yes,scrollbars=yes,status=yes";try{const a=window.open(n,`mcp_auth_${this.serverUrlHash}`,r);this.onPopupWindow&&this.onPopupWindow(n,r,a),!a||a.closed||typeof a.closed>"u"?console.warn(`[${this.storageKeyPrefix}] Popup likely blocked by browser. Manual navigation might be required using the stored URL.`):(a.focus(),console.info(`[${this.storageKeyPrefix}] Redirecting to authorization URL in popup.`))}catch(a){console.error(`[${this.storageKeyPrefix}] Error opening popup window:`,a)}}getLastAttemptedAuthUrl(){const t=localStorage.getItem(this.getKey("last_auth_url"));return t?Lu(t):null}clearStorage(){const t=`${this.storageKeyPrefix}_${this.serverUrlHash}_`,n=`${this.storageKeyPrefix}:state_`,r=[];let a=0;for(let i=0;i<localStorage.length;i++){const l=localStorage.key(i);if(l){if(l.startsWith(t))r.push(l);else if(l.startsWith(n))try{const u=localStorage.getItem(l);u&&JSON.parse(u).serverUrlHash===this.serverUrlHash&&r.push(l)}catch(u){console.warn(`[${this.storageKeyPrefix}] Error parsing state key ${l} during clearStorage:`,u)}}}return[...new Set(r)].forEach(i=>{localStorage.removeItem(i),a++}),a}hashString(t){let n=0;for(let r=0;r<t.length;r++){const a=t.charCodeAt(r);n=(n<<5)-n+a,n=n&n}return Math.abs(n).toString(16)}getKey(t){return`${this.storageKeyPrefix}_${this.serverUrlHash}_${t}`}},ze(Nd,"BrowserOAuthClientProvider"),Nd);async function SN(){const e=new URLSearchParams(window.location.search),t=e.get("code"),n=e.get("state"),r=e.get("error"),a=e.get("error_description"),o="[mcp-callback]";console.log(`${o} Handling callback...`,{code:t,state:n,error:r,errorDescription:a});let i=null,l=null,u=null;try{if(r)throw new Error(`OAuth error: ${r} - ${a||"No description provided."}`);if(!t)throw new Error("Authorization code not found in callback query parameters.");if(!n)throw new Error("State parameter not found or invalid in callback query parameters.");console.log(`[mcp-callback] Looking for state: ${n}`),console.log("[mcp-callback] All localStorage keys:",Object.keys(localStorage));const f=`mcp:auth:state_${n}`;if(localStorage.getItem(f))u=f,console.log(`[mcp-callback] Found state with default key: ${f}`);else{const S=`:state_${n}`;for(let _=0;_<localStorage.length;_++){const T=localStorage.key(_);if(T&&T.endsWith(S)){u=T,console.log(`[mcp-callback] Found state with dynamic key: ${T}`);break}}}if(!u){const S=Object.keys(localStorage).filter(_=>_.includes("state"));throw console.log("[mcp-callback] State keys in storage:",S),new Error(`Invalid or expired state parameter "${n}". No matching state found in storage.`)}const m=localStorage.getItem(u);if(!m)throw new Error(`Invalid or expired state parameter "${n}". No matching state found in storage.`);try{l=JSON.parse(m)}catch{throw new Error("Failed to parse stored OAuth state.")}if(!l.expiry||l.expiry<Date.now())throw localStorage.removeItem(u),new Error("OAuth state has expired. Please try initiating authentication again.");if(!l.providerOptions)throw new Error("Stored state is missing required provider options.");const{serverUrl:h,...g}=l.providerOptions;let y=g.oauthProxyUrl,E=g.connectionUrl;if(!y)try{const S=new URL(window.location.href);if(S.pathname.includes("/oauth/callback")){const _=S.pathname.replace(/\/oauth\/callback.*$/,"");y=`${S.origin}${_}/api/oauth`,E=`${S.origin}${_}/api/proxy`,console.log(`${o} Inferred OAuth proxy URL from callback: ${y}`)}}catch(S){console.warn(`${o} Could not infer OAuth proxy URL:`,S)}console.log(`${o} Re-instantiating provider for server: ${h}`),i=new ny(h,{...g,oauthProxyUrl:y,connectionUrl:E}),y&&(console.log(`${o} Installing fetch interceptor for token exchange (proxy: ${y})`),i.installFetchInterceptor()),console.log(`${o} Calling SDK auth() to exchange code...`);const x=E||new URL(h).origin;console.log(`${o} Using SDK serverUrl: ${x} (connectionUrl: ${E||"none"})`);const w=await Ws(i,{serverUrl:x,authorizationCode:t});if(w==="AUTHORIZED")if(console.log(`${o} Authorization successful via SDK auth().`),l.flowType==="redirect"&&l.returnUrl)console.log(`${o} Redirect flow complete. Returning to: ${l.returnUrl}`),localStorage.removeItem(u),window.location.href=l.returnUrl;else if(window.opener&&!window.opener.closed)console.log(`${o} Popup flow complete. Notifying opener...`),window.opener.postMessage({type:"mcp_auth_callback",success:!0},window.location.origin),localStorage.removeItem(u),window.close();else if(l.returnUrl)console.log(`${o} Popup flow without opener. Returning to: ${l.returnUrl}`),localStorage.removeItem(u),window.location.href=l.returnUrl;else{console.warn(`${o} No opener window or return URL detected. Redirecting to root.`),localStorage.removeItem(u);const _=window.location.pathname.split("/").filter(Boolean),T=_.length>0&&_[_.length-1]==="callback"?"/"+_.slice(0,-2).join("/"):"/";window.location.href=T||"/"}else throw console.warn(`${o} SDK auth() returned unexpected status: ${w}`),new Error(`Unexpected result from authentication library: ${w}`)}catch(f){console.error(`${o} Error during OAuth callback handling:`,f);const m=f instanceof Error?f.message:String(f);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 y=document.createElement("p");y.style.color="red",y.style.backgroundColor="#ffebeb",y.style.border="1px solid red",y.style.padding="10px",y.style.borderRadius="4px",y.textContent=m,h.appendChild(y);const E=document.createElement("p");E.textContent="You can close this window or ";const x=document.createElement("a");if(x.href="#",x.textContent="click here to close",x.onclick=w=>(w.preventDefault(),window.close(),!1),E.appendChild(x),E.appendChild(document.createTextNode(".")),h.appendChild(E),f instanceof Error&&f.stack){const w=document.createElement("pre");w.style.fontSize="0.8em",w.style.color="#555",w.style.marginTop="20px",w.style.whiteSpace="pre-wrap",w.textContent=f.stack,h.appendChild(w)}document.body.appendChild(h)}catch(h){console.error(`${o} Could not display error in callback window:`,h)}u&&localStorage.removeItem(u),i&&(localStorage.removeItem(i.getKey("code_verifier")),localStorage.removeItem(i.getKey("last_auth_url")))}}ze(SN,"onMcpAuthorization");var vE={exports:{}},Bt={};var R$;function Wre(){if(R$)return Bt;R$=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),o=Symbol.for("react.consumer"),i=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),h=Symbol.for("react.activity"),g=Symbol.iterator;function y(j){return j===null||typeof j!="object"?null:(j=g&&j[g]||j["@@iterator"],typeof j=="function"?j:null)}var E={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},x=Object.assign,w={};function S(j,B,z){this.props=j,this.context=B,this.refs=w,this.updater=z||E}S.prototype.isReactComponent={},S.prototype.setState=function(j,B){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,B,"setState")},S.prototype.forceUpdate=function(j){this.updater.enqueueForceUpdate(this,j,"forceUpdate")};function _(){}_.prototype=S.prototype;function T(j,B,z){this.props=j,this.context=B,this.refs=w,this.updater=z||E}var A=T.prototype=new _;A.constructor=T,x(A,S.prototype),A.isPureReactComponent=!0;var R=Array.isArray;function k(){}var C={H:null,A:null,T:null,S:null},O=Object.prototype.hasOwnProperty;function M(j,B,z){var D=z.ref;return{$$typeof:e,type:j,key:B,ref:D!==void 0?D:null,props:z}}function L(j,B){return M(j.type,B,j.props)}function $(j){return typeof j=="object"&&j!==null&&j.$$typeof===e}function H(j){var B={"=":"=0",":":"=2"};return"$"+j.replace(/[=:]/g,function(z){return B[z]})}var V=/\/+/g;function Z(j,B){return typeof j=="object"&&j!==null&&j.key!=null?H(""+j.key):B.toString(36)}function ne(j){switch(j.status){case"fulfilled":return j.value;case"rejected":throw j.reason;default:switch(typeof j.status=="string"?j.then(k,k):(j.status="pending",j.then(function(B){j.status==="pending"&&(j.status="fulfilled",j.value=B)},function(B){j.status==="pending"&&(j.status="rejected",j.reason=B)})),j.status){case"fulfilled":return j.value;case"rejected":throw j.reason}}throw j}function G(j,B,z,D,P){var W=typeof j;(W==="undefined"||W==="boolean")&&(j=null);var K=!1;if(j===null)K=!0;else switch(W){case"bigint":case"string":case"number":K=!0;break;case"object":switch(j.$$typeof){case e:case t:K=!0;break;case m:return K=j._init,G(K(j._payload),B,z,D,P)}}if(K)return P=P(j),K=D===""?"."+Z(j,0):D,R(P)?(z="",K!=null&&(z=K.replace(V,"$&/")+"/"),G(P,B,z,"",function(le){return le})):P!=null&&($(P)&&(P=L(P,z+(P.key==null||j&&j.key===P.key?"":(""+P.key).replace(V,"$&/")+"/")+K)),B.push(P)),1;K=0;var ae=D===""?".":D+":";if(R(j))for(var oe=0;oe<j.length;oe++)D=j[oe],W=ae+Z(D,oe),K+=G(D,B,z,W,P);else if(oe=y(j),typeof oe=="function")for(j=oe.call(j),oe=0;!(D=j.next()).done;)D=D.value,W=ae+Z(D,oe++),K+=G(D,B,z,W,P);else if(W==="object"){if(typeof j.then=="function")return G(ne(j),B,z,D,P);throw B=String(j),Error("Objects are not valid as a React child (found: "+(B==="[object Object]"?"object with keys {"+Object.keys(j).join(", ")+"}":B)+"). If you meant to render a collection of children, use an array instead.")}return K}function Y(j,B,z){if(j==null)return j;var D=[],P=0;return G(j,D,"","",function(W){return B.call(z,W,P++)}),D}function F(j){if(j._status===-1){var B=j._result;B=B(),B.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=B)}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 B=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(B))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",j);return}console.error(j)},ee={map:Y,forEach:function(j,B,z){Y(j,function(){B.apply(this,arguments)},z)},count:function(j){var B=0;return Y(j,function(){B++}),B},toArray:function(j){return Y(j,function(B){return B})||[]},only:function(j){if(!$(j))throw Error("React.Children.only expected to receive a single React element child.");return j}};return Bt.Activity=h,Bt.Children=ee,Bt.Component=S,Bt.Fragment=n,Bt.Profiler=a,Bt.PureComponent=T,Bt.StrictMode=r,Bt.Suspense=u,Bt.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=C,Bt.__COMPILER_RUNTIME={__proto__:null,c:function(j){return C.H.useMemoCache(j)}},Bt.cache=function(j){return function(){return j.apply(null,arguments)}},Bt.cacheSignal=function(){return null},Bt.cloneElement=function(j,B,z){if(j==null)throw Error("The argument must be a React element, but you passed "+j+".");var D=x({},j.props),P=j.key;if(B!=null)for(W in B.key!==void 0&&(P=""+B.key),B)!O.call(B,W)||W==="key"||W==="__self"||W==="__source"||W==="ref"&&B.ref===void 0||(D[W]=B[W]);var W=arguments.length-2;if(W===1)D.children=z;else if(1<W){for(var K=Array(W),ae=0;ae<W;ae++)K[ae]=arguments[ae+2];D.children=K}return M(j.type,P,D)},Bt.createContext=function(j){return j={$$typeof:i,_currentValue:j,_currentValue2:j,_threadCount:0,Provider:null,Consumer:null},j.Provider=j,j.Consumer={$$typeof:o,_context:j},j},Bt.createElement=function(j,B,z){var D,P={},W=null;if(B!=null)for(D in B.key!==void 0&&(W=""+B.key),B)O.call(B,D)&&D!=="key"&&D!=="__self"&&D!=="__source"&&(P[D]=B[D]);var K=arguments.length-2;if(K===1)P.children=z;else if(1<K){for(var ae=Array(K),oe=0;oe<K;oe++)ae[oe]=arguments[oe+2];P.children=ae}if(j&&j.defaultProps)for(D in K=j.defaultProps,K)P[D]===void 0&&(P[D]=K[D]);return M(j,W,P)},Bt.createRef=function(){return{current:null}},Bt.forwardRef=function(j){return{$$typeof:l,render:j}},Bt.isValidElement=$,Bt.lazy=function(j){return{$$typeof:m,_payload:{_status:-1,_result:j},_init:F}},Bt.memo=function(j,B){return{$$typeof:f,type:j,compare:B===void 0?null:B}},Bt.startTransition=function(j){var B=C.T,z={};C.T=z;try{var D=j(),P=C.S;P!==null&&P(z,D),typeof D=="object"&&D!==null&&typeof D.then=="function"&&D.then(k,re)}catch(W){re(W)}finally{B!==null&&z.types!==null&&(B.types=z.types),C.T=B}},Bt.unstable_useCacheRefresh=function(){return C.H.useCacheRefresh()},Bt.use=function(j){return C.H.use(j)},Bt.useActionState=function(j,B,z){return C.H.useActionState(j,B,z)},Bt.useCallback=function(j,B){return C.H.useCallback(j,B)},Bt.useContext=function(j){return C.H.useContext(j)},Bt.useDebugValue=function(){},Bt.useDeferredValue=function(j,B){return C.H.useDeferredValue(j,B)},Bt.useEffect=function(j,B){return C.H.useEffect(j,B)},Bt.useEffectEvent=function(j){return C.H.useEffectEvent(j)},Bt.useId=function(){return C.H.useId()},Bt.useImperativeHandle=function(j,B,z){return C.H.useImperativeHandle(j,B,z)},Bt.useInsertionEffect=function(j,B){return C.H.useInsertionEffect(j,B)},Bt.useLayoutEffect=function(j,B){return C.H.useLayoutEffect(j,B)},Bt.useMemo=function(j,B){return C.H.useMemo(j,B)},Bt.useOptimistic=function(j,B){return C.H.useOptimistic(j,B)},Bt.useReducer=function(j,B,z){return C.H.useReducer(j,B,z)},Bt.useRef=function(j){return C.H.useRef(j)},Bt.useState=function(j){return C.H.useState(j)},Bt.useSyncExternalStore=function(j,B,z){return C.H.useSyncExternalStore(j,B,z)},Bt.useTransition=function(){return C.H.useTransition()},Bt.version="19.2.3",Bt}var k$;function _N(){return k$||(k$=1,vE.exports=Wre()),vE.exports}var b=_N();const ue=Fm(b),Ec=tZ({__proto__:null,default:ue},[b]);function e_(e,t){if(!e)throw new Error(t)}ze(e_,"assert");var A$=3e3,Kre=5e3;function SB(e){return{name:e.name,version:e.version,uri:e.websiteUrl,logo_uri:e.icons?.[0]?.src}}ze(SB,"deriveClientConfigFromClientInfo");function _B(e){const n=(e instanceof Error?e.message:String(e)).toLowerCase();return n.includes("oauth discovery failed")||n.includes("oauth-authorization-server")||n.includes("not valid json")||n.includes("404")&&(n.includes("openid-configuration")||n.includes("oauth-protected-resources")||n.includes("oauth-authorization-url")||n.includes("register"))||n.includes("invalid oauth error response")&&n.includes("not found")}ze(_B,"isOAuthDiscoveryFailure");function TB(e){const{url:t,enabled:n=!0,callbackUrl:r=typeof window<"u"?Lu(new URL("/oauth/callback",window.location.origin).toString()):"/oauth/callback",storageKeyPrefix:a="mcp:auth",clientConfig:o={},headers:i,customHeaders:l,proxyConfig:u,autoProxyFallback:f=!0,debug:m=!1,autoRetry:h=!1,autoReconnect:g=A$,transportType:y="auto",preventAutoAuth:E=!0,useRedirectFlow:x=!1,onPopupWindow:w,timeout:S=3e4,sseReadTimeout:_=3e5,wrapTransport:T,onNotification:A,onSampling:R,samplingCallback:k,onElicitation:C}=e,O=i??l??{};l&&!i&&console.warn('[useMcp] The "customHeaders" option is deprecated. Use "headers" instead.');const M=R??k;k&&!R&&console.warn('[useMcp] The "samplingCallback" option is deprecated. Use "onSampling" instead.');const L=b.useMemo(()=>({name:"mcp-use",title:"mcp-use",version:Tv(),description:"mcp-use is a complete TypeScript framework for building and using MCP",icons:[{src:"https://mcp-use.com/logo.png"}],websiteUrl:"https://mcp-use.com"}),[]),$=b.useMemo(()=>e.clientInfo?{...L,...e.clientInfo}:L,[e.clientInfo,L]),H=b.useMemo(()=>SB($),[$]),V=b.useMemo(()=>o&&Object.keys(o).length>0?(console.warn("[useMcp] The 'clientConfig' option is deprecated and will be removed in a future version. Use 'clientInfo' instead. The clientConfig will be automatically derived from clientInfo."),{...H,...o}):H,[o,H]),Z=b.useMemo(()=>f?typeof f=="boolean"?{enabled:f,proxyAddress:"https://inspector.mcp-use.com/inspector/api/proxy"}:{enabled:f.enabled!==!1,proxyAddress:f.proxyAddress||"https://inspector.mcp-use.com/inspector/api/proxy"}:{enabled:!1,proxyAddress:void 0},[f]),ne=b.useRef(!1),[G,Y]=b.useState(u),{gatewayUrl:F,proxyHeaders:re}=b.useMemo(()=>{const ge=d4(t||"",G);return{gatewayUrl:G?.proxyAddress,proxyHeaders:ge.headers}},[t,G]),ee=b.useMemo(()=>t||"",[t]),j=b.useMemo(()=>({...re,...O}),[re,O]),[B,z]=b.useState("discovering"),[D,P]=b.useState([]),[W,K]=b.useState([]),[ae,oe]=b.useState([]),[le,Q]=b.useState([]),[J,q]=b.useState(e._initialServerInfo?.name?e._initialServerInfo:void 0),[ie,he]=b.useState(),[Ne,Ye]=b.useState(void 0),[Pe,Ue]=b.useState([]),[st,Ve]=b.useState(void 0),[ut,rt]=b.useState(void 0),Ee=b.useRef(null),_e=b.useRef(null),Be=b.useRef(null),it=b.useRef(!1),qe=b.useRef(!0),lt=b.useRef(0),At=b.useRef(null),Nn=b.useRef(!1),ot=b.useRef(B),zn=b.useRef(g),qt=b.useRef(null),Ge=b.useRef(null),We=b.useRef(null);b.useEffect(()=>{ot.current=B,zn.current=g},[B,g]);const fe=b.useCallback((ge,Ce,...Te)=>{const Ae=Te.length>0?`${Ce} ${Te.map($e=>JSON.stringify($e)).join(" ")}`:Ce;console[ge](`[useMcp] ${Ae}`),qe.current&&Ue($e=>[...$e.slice(-100),{level:ge,message:Ae,timestamp:Date.now()}])},[]),It=b.useCallback(async(ge=!1)=>{if(ge||fe("info","Disconnecting..."),it.current=!1,At.current&&clearTimeout(At.current),At.current=null,Ee.current)try{const Ce="inspector-server",Te=Ee.current.getSession(Ce);Te&&Te._healthCheckCleanup&&(Te._healthCheckCleanup(),Te._healthCheckCleanup=null),Te&&await Ee.current.closeSession(Ce)}catch(Ce){ge||fe("warn","Error closing session:",Ce)}Ee.current=null,qe.current&&!ge&&(z("discovering"),P([]),K([]),oe([]),Q([]),Ye(void 0),Ve(void 0))},[fe]),Ct=b.useCallback((ge,Ce)=>{fe("error",ge,Ce??"");const Te=Ce&&"code"in Ce?Ce.code:void 0,Ae=Z.enabled&&!G?.proxyAddress,$e=ge.includes("CORS")||ge.includes("blocked by CORS policy")||ge.includes("Failed to fetch"),Xe=Te===400,Je=typeof Te=="number"&&Te>=404&&Te<500;if(Ae&&($e||Xe||Je)&&!(Te===401||Te===403))return fe("info",`Direct connection failed with ${$e?"CORS error":Xe?"HTTP 400 (Bad Request)":"HTTP 4xx error"}. Trying with proxy...`),Ee.current=null,_e.current=null,fe("debug","Cleared client and auth provider for proxy fallback"),Y({proxyAddress:Z.proxyAddress}),qe.current&&z("discovering"),setTimeout(()=>{qe.current&&Ge.current?.()},1e3),!0;if(qe.current){console.log("[useMcp] Setting state to FAILED:",ge),z("failed"),Ye(ge);const tt=_e.current?.getLastAttemptedAuthUrl();tt&&(Ve(tt),fe("info","Manual authentication URL may be available.",tt))}return it.current=!1,t&&rs.getInstance().trackUseMcpConnection({url:t,transportType:y,success:!1,errorType:Ce?.name||"UnknownError",hasOAuth:!!_e.current,hasSampling:!!M,hasElicitation:!!C}).catch(()=>{}),!1},[fe,t,y,M,C,Z,G]),Pt=b.useCallback(async()=>{if(!n||!t){fe("debug",n?"No server URL provided, skipping connection.":"Connection disabled via enabled flag.");return}if(it.current){fe("debug","Connection attempt already in progress.");return}if(!qe.current){fe("debug","Connect called after unmount, aborting.");return}if(it.current=!0,lt.current+=1,Ye(void 0),Ve(void 0),qt.current=null,z("discovering"),fe("info",`Connecting attempt #${lt.current} to ${t}...`),_e.current){const Te=_e.current.clearStorage();Te>0&&fe("debug",`Cleared ${Te} stale OAuth storage item(s) before connecting`)}if(!_e.current){let Te;if(F){const Ae=new URL(F),$e=Ae.pathname.replace(/\/proxy\/?$/,"");Te=`${Ae.origin}${$e}/oauth`,fe("debug",`OAuth proxy URL derived from gateway: ${Te}`)}_e.current=new ny(ee,{storageKeyPrefix:a,clientName:V.name,clientUri:V.uri,logoUri:V.logo_uri||"https://mcp-use.com/logo.png",callbackUrl:r,preventAutoAuth:E,useRedirectFlow:x,oauthProxyUrl:Te,connectionUrl:F,onPopupWindow:w}),fe("debug",`BrowserOAuthClientProvider initialized with URL: ${ee}, proxy: ${Te?"enabled":"disabled"}, gateway: ${F?"enabled":"disabled"}`),Te&&(_e.current.installFetchInterceptor(),fe("debug","Installed OAuth fetch interceptor"))}Ee.current?fe("debug","BrowserMCPClient already exists, reusing."):(Ee.current=new Gre,fe("debug","BrowserMCPClient initialized in connect."));const ge=ze(async(Te,Ae=!1)=>{if(!qe.current)return fe("debug","Connection attempt aborted - component unmounted"),"failed";fe("info",`Attempting connection with transport: ${Te}`),fe("debug",`Client ref status at start of tryConnectWithTransport: ${Ee.current?"initialized":"NULL"}`);try{const $e="inspector-server",Xe={url:t,transport:Te==="sse"?"http":Te,disableSseFallback:y==="http",preferSse:Te==="sse",clientInfo:$};if(F&&(Xe.gatewayUrl=F,console.log(`[useMcp] Using proxy gateway: ${F} for target: ${t}`)),j&&Object.keys(j).length>0&&(Xe.headers=j),_e.current){const et=await _e.current.tokens();if(!qe.current)return fe("debug","Connection aborted after token fetch - component unmounted"),"failed";et?.access_token&&(Xe.headers={...Xe.headers,Authorization:`Bearer ${et.access_token}`})}if(!Ee.current){if(!qe.current)return fe("debug","Connection aborted - component unmounted, client cleaned up"),"failed";const et=new Error("Client not initialized - this is a bug in the connection flow");throw fe("error","Client ref is null in tryConnectWithTransport but component is still mounted"),et}Ee.current.addServer($e,{...Xe,authProvider:_e.current,clientOptions:V,onSampling:M,samplingCallback:M,elicitationCallback:C,wrapTransport:T?et=>(console.log("[useMcp] Applying transport wrapper for server:",$e,"url:",t),T(et,t)):void 0});const Je=await Ee.current.createSession($e,!1);if(!qe.current)return fe("debug","Connection aborted after session creation - component unmounted"),"failed";if(Je.on("notification",et=>{A?.(et),et.method==="notifications/tools/list_changed"?(fe("info","Tools list changed, auto-refreshing..."),Ln().catch(Ke=>fe("warn","Auto-refresh tools failed:",Ke))):et.method==="notifications/resources/list_changed"?(fe("info","Resources list changed, auto-refreshing..."),sn().catch(Ke=>fe("warn","Auto-refresh resources failed:",Ke))):et.method==="notifications/prompts/list_changed"&&(fe("info","Prompts list changed, auto-refreshing..."),Mn().catch(Ke=>fe("warn","Auto-refresh prompts failed:",Ke)))}),await Je.initialize(),!qe.current)return fe("debug","Connection completed but component unmounted, aborting"),"failed";if(fe("info","✅ Successfully connected to MCP server"),fe("info","Server info:",Je.connector.serverInfo),fe("info","Server capabilities:",Je.connector.serverCapabilities),console.log("[useMcp] Server info:",Je.connector.serverInfo),console.log("[useMcp] Server capabilities:",Je.connector.serverCapabilities),!qe.current)return fe("debug","Skipping state update - component unmounted"),"failed";z("ready"),qt.current=Te;const Qe=ze(()=>{let et=null,Ke=Date.now();const St=1e4,En=3e4;return et=setInterval(ze(async()=>{if(!qe.current||ot.current!=="ready"){et&&(clearInterval(et),et=null);return}try{await Je.connector.listTools(),Ke=Date.now()}catch{const _t=Date.now()-Ke;_t>En&&(fe("warn",`Connection appears to be broken (no response for ${Math.round(_t/1e3)}s), attempting to reconnect...`),et&&(clearInterval(et),et=null),zn.current&&qe.current&&(z("discovering"),fe("info","Auto-reconnecting to MCP server..."),setTimeout(()=>{qe.current&&ot.current==="discovering"&&Pt()},typeof zn.current=="number"?zn.current:A$)))}},"checkConnectionHealth"),St),()=>{et&&(clearInterval(et),et=null)}},"setupConnectionMonitoring");if(g){const et=Qe();Je._healthCheckCleanup=et}rs.getInstance().trackUseMcpConnection({url:t,transportType:Te,success:!0,hasOAuth:!!_e.current,hasSampling:!!M,hasElicitation:!!C}).catch(()=>{}),P(Je.connector.tools||[]);const Mt=await Je.connector.listAllResources();if(!qe.current)return fe("debug","Connection aborted after listing resources - component unmounted"),"failed";K(Mt.resources||[]);const tt=await Je.connector.listPrompts();if(!qe.current)return fe("debug","Connection aborted after listing prompts - component unmounted"),"failed";Q(tt.prompts||[]);const xt=Je.connector.serverInfo,Rt=Je.connector.serverCapabilities;if(xt){if(console.log("[useMcp] Server info:",xt),!qe.current)return fe("debug","Skipping state update - component unmounted"),"failed";q(xt);const et=(async()=>{try{const Ke=xt.icons;if(Ke&&Array.isArray(Ke)&&Ke.length>0){const St=Ke[0].src||Ke[0].url;if(St){fe("info","Server provided icon:",St);const gt=await(await fetch(St)).blob(),Fn=await new Promise((_t,Cn)=>{const en=new FileReader;en.onloadend=()=>_t(en.result),en.onerror=Cn,en.readAsDataURL(gt)});return qe.current&&(q(_t=>_t?{..._t,icon:Fn}:void 0),fe("debug","Server icon converted to base64")),Fn}}if(t){const St=await u4(t);if(!qe.current)return fe("debug","Connection aborted after favicon detection - component unmounted"),null;if(St)return q(En=>En?{...En,icon:St}:void 0),fe("debug","Favicon detected and added to serverInfo"),St}return null}catch(Ke){return fe("debug","Icon loading failed (non-critical):",Ke),null}})();Be.current=et}if(Rt){if(console.log("[useMcp] Server capabilities:",Rt),!qe.current)return fe("debug","Skipping state update - component unmounted"),"failed";he(Rt)}if(_e.current){const et=await _e.current.tokens();if(!qe.current)return fe("debug","Connection aborted after token fetch for auth tokens - component unmounted"),"failed";if(et?.access_token){const Ke=et.expires_in?Date.now()+et.expires_in*1e3:void 0;if(!qe.current)return fe("debug","Skipping state update - component unmounted"),"failed";rt({access_token:et.access_token,token_type:et.token_type||"Bearer",expires_at:Ke,refresh_token:et.refresh_token,scope:et.scope})}}return"success"}catch($e){const Xe=$e,Je=Xe?.message||String($e),Qe=_B($e),Mt=Xe.code===401||Je.includes("401")||Je.includes("Unauthorized");if(Qe&&O&&Object.keys(O).length>0)return Ct("Authentication failed (HTTP 401). Server does not support OAuth. Check your Authorization header value is correct."),"failed";if(Mt){if(Qe)return Ct("Authentication required (HTTP 401). Server does not support OAuth. Add an Authorization header in the Custom Headers section (e.g., Authorization: Bearer YOUR_API_KEY)."),"failed";if(_e.current){if(fe("info","Authentication required. OAuth provider available."),fe("info","Waiting for user to initiate authentication flow..."),qe.current){z("pending_auth");const xt=_e.current?.getLastAttemptedAuthUrl();xt&&(Ve(xt),fe("info","Retrieved stored auth URL for manual authentication"))}return it.current=!1,"auth_redirect"}return O&&Object.keys(O).length>0?(Ct("Authentication failed: Server returned 401 Unauthorized. Check your Authorization header value is correct."),"failed"):(Ct("Authentication required: Server returned 401 Unauthorized. Add an Authorization header in the Custom Headers section (e.g., Authorization: Bearer YOUR_API_KEY)."),"failed")}return Ct(Je,Xe instanceof Error?Xe:new Error(String(Xe)))?"auth_redirect":"failed"}},"tryConnectWithTransport");let Ce="failed";if(y==="sse")fe("debug","Using SSE-only transport mode"),Ce=await ge("sse");else if(y==="http")fe("debug","Using HTTP-only transport mode"),Ce=await ge("http");else{fe("debug","Using auto transport mode (HTTP with SSE fallback)");const Te=await ge("http");Te==="fallback"&&qe.current&&ot.current!=="authenticating"?(fe("info","HTTP failed, attempting SSE fallback..."),Ce=await ge("sse")):Ce=Te}(Ce==="success"||Ce==="failed"||Ce==="auth_redirect")&&(it.current=!1),fe("debug",`Connection sequence finished with status: ${Ce}`)},[fe,Ct,It,t,a,r,V.name,V.version,V.uri,V.logo_uri,O,y,E,x,w,n,S,_,$,F,j,ee]);b.useEffect(()=>{Ge.current=Pt,We.current=Ct},[Pt,Ct]);const $t=b.useCallback(async(ge,Ce,Te)=>{if(ot.current!=="ready"||!Ee.current)throw new Error(`MCP client is not ready (current state: ${B}). Cannot call tool "${ge}".`);fe("info",`Calling tool: ${ge}`,Ce);const Ae=Date.now();try{const Xe=Ee.current.getSession("inspector-server");if(!Xe)throw new Error("No active session found");const Je=await Xe.connector.callTool(ge,Ce||{},Te);return fe("info",`Tool "${ge}" call successful:`,Je),rs.getInstance().trackUseMcpToolCall({toolName:ge,success:!0,executionTimeMs:Date.now()-Ae}).catch(()=>{}),Je}catch($e){throw fe("error",`Tool "${ge}" call failed:`,$e),rs.getInstance().trackUseMcpToolCall({toolName:ge,success:!1,errorType:$e instanceof Error?$e.name:"UnknownError",executionTimeMs:Date.now()-Ae}).catch(()=>{}),$e}},[B]),Xt=b.useCallback(()=>{ot.current==="failed"?(fe("info","Retry requested..."),Ge.current?.()):fe("warn",`Retry called but state is not 'failed' (state: ${ot.current}). Ignoring.`)},[fe]),xn=b.useCallback(async()=>{fe("info","Manual authentication requested...");const ge=ot.current;if(ge==="failed")fe("info","Attempting to reconnect and authenticate via retry..."),Xt();else if(ge==="pending_auth"){fe("info","Proceeding with authentication from pending state...");try{e_(_e.current,"Auth Provider not available for manual auth"),e_(t,"Server URL is required for authentication");const Ce=_e.current.clearStorage();fe("info",`Cleared ${Ce} OAuth storage item(s) for fresh authentication`),z("authenticating");let Te;if(F){const Qe=new URL(F),Mt=Qe.pathname.replace(/\/proxy\/?$/,"");Te=`${Qe.origin}${Mt}/oauth`}const Ae=new ny(ee,{storageKeyPrefix:a,clientName:V.name,clientUri:V.uri,logoUri:V.logo_uri||"https://mcp-use.com/logo.png",callbackUrl:r,preventAutoAuth:!1,useRedirectFlow:x,oauthProxyUrl:Te,connectionUrl:F,onPopupWindow:w});Te&&!F?(Ae.installFetchInterceptor(),fe("info","Installed OAuth fetch interceptor for manual auth")):Te&&F&&fe("info","Using MCP gateway proxy for OAuth (no fetch interceptor needed)"),_e.current=Ae,fe("info","Triggering fresh OAuth authorization...");const{auth:$e}=await Ua(async()=>{const{auth:Qe}=await Promise.resolve().then(()=>Ire);return{auth:Qe}},void 0),Xe=new URL(t).origin;try{await $e(Ae,{serverUrl:Xe}),fe("info","OAuth flow completed (tokens obtained)")}catch(Qe){fe("info","OAuth flow initiated (popup/redirect):",Qe instanceof Error?Qe.message:"Redirecting...")}const Je=Ae.getLastAttemptedAuthUrl();Je&&(Ve(Je),fe("info","Updated auth URL for fallback:",Je))}catch(Ce){if(!qe.current)return;z("pending_auth"),fe("error",`Manual authentication failed: ${Ce instanceof Error?Ce.message:String(Ce)}`)}}else if(ge==="authenticating"){fe("warn","Already attempting authentication. Check for blocked popups or wait for timeout.");const Ce=_e.current?.getLastAttemptedAuthUrl();Ce&&!st&&(Ve(Ce),fe("info","Manual authentication URL retrieved:",Ce))}else fe("info",`Client not in a state requiring manual authentication trigger (state: ${ge}). If needed, try disconnecting and reconnecting.`)},[fe,Xt,st,t,x,w,a,V.name,V.uri,V.logo_uri,r,$]),dt=b.useCallback(()=>{if(_e.current){const ge=_e.current.clearStorage();fe("info",`Cleared ${ge} item(s) from localStorage for ${t}.`),Ve(void 0),It()}else fe("warn","Auth provider not initialized, cannot clear storage.")},[t,fe,It]),Ut=b.useCallback(async()=>{if(ot.current!=="ready"||!Ee.current)throw new Error(`MCP client is not ready (current state: ${B}). Cannot list resources.`);fe("info","Listing resources");try{const Ce=Ee.current.getSession("inspector-server");if(!Ce)throw new Error("No active session found");const Te=await Ce.connector.listAllResources();K(Te.resources||[]),fe("info","Resources listed successfully")}catch(ge){throw fe("error","List resources failed:",ge),ge}},[B]),Ht=b.useCallback(async ge=>{if(ot.current!=="ready"||!Ee.current)throw new Error(`MCP client is not ready (current state: ${B}). Cannot read resource.`);fe("info",`Reading resource: ${ge}`);try{const Te=Ee.current.getSession("inspector-server");if(!Te)throw new Error("No active session found");const Ae=await Te.connector.readResource(ge);return fe("info","Resource read successful:",Ae),rs.getInstance().trackUseMcpResourceRead({resourceUri:ge,success:!0}).catch(()=>{}),Ae}catch(Ce){throw fe("error","Resource read failed:",Ce),rs.getInstance().trackUseMcpResourceRead({resourceUri:ge,success:!1,errorType:Ce instanceof Error?Ce.name:"UnknownError"}).catch(()=>{}),Ce}},[B]),zt=b.useCallback(async()=>{if(ot.current!=="ready"||!Ee.current)throw new Error(`MCP client is not ready (current state: ${B}). Cannot list prompts.`);fe("info","Listing prompts");try{const Ce=Ee.current.getSession("inspector-server");if(!Ce)throw new Error("No active session found");const Te=await Ce.connector.listPrompts();Q(Te.prompts||[]),fe("info","Prompts listed successfully")}catch(ge){throw fe("error","List prompts failed:",ge),ge}},[B]),Ln=b.useCallback(async()=>{if(ot.current!=="ready"||!Ee.current){fe("debug","Cannot refresh tools - client not ready");return}fe("debug","Refreshing tools list");try{const Ce=Ee.current.getSession("inspector-server");if(!Ce){fe("warn","No active session found for tools refresh");return}const Te=await Ce.connector.listTools();P(Te||[]),fe("info","Tools list refreshed successfully")}catch(ge){fe("warn","Failed to refresh tools:",ge)}},[fe]),sn=b.useCallback(async()=>{if(ot.current!=="ready"||!Ee.current){fe("debug","Cannot refresh resources - client not ready");return}fe("debug","Refreshing resources list");try{const Ce=Ee.current.getSession("inspector-server");if(!Ce){fe("warn","No active session found for resources refresh");return}const Te=await Ce.connector.listAllResources();K(Te.resources||[]),fe("info","Resources list refreshed successfully")}catch(ge){fe("warn","Failed to refresh resources:",ge)}},[fe]),Mn=b.useCallback(async()=>{if(ot.current!=="ready"||!Ee.current){fe("debug","Cannot refresh prompts - client not ready");return}fe("debug","Refreshing prompts list");try{const Ce=Ee.current.getSession("inspector-server");if(!Ce){fe("warn","No active session found for prompts refresh");return}const Te=await Ce.connector.listPrompts();Q(Te.prompts||[]),fe("info","Prompts list refreshed successfully")}catch(ge){fe("warn","Failed to refresh prompts:",ge)}},[fe]),qn=b.useCallback(async()=>{fe("info","Refreshing all lists (tools, resources, prompts)"),await Promise.all([Ln(),sn(),Mn()])},[Ln,sn,Mn,fe]),se=b.useCallback(async(ge,Ce)=>{if(ot.current!=="ready"||!Ee.current)throw new Error(`MCP client is not ready (current state: ${B}). Cannot get prompt.`);fe("info",`Getting prompt: ${ge}`,Ce);try{const Ae=Ee.current.getSession("inspector-server");if(!Ae)throw new Error("No active session found");const $e=await Ae.connector.getPrompt(ge,Ce||{});return fe("info",`Prompt "${ge}" retrieved successfully:`,$e),$e}catch(Te){throw fe("error",`Prompt "${ge}" retrieval failed:`,Te),Te}},[B]);b.useEffect(()=>{const ge=ze(Ce=>{Ce.origin===window.location.origin&&Ce.data?.type==="mcp_auth_callback"&&(fe("info","Received auth callback message.",Ce.data),At.current&&clearTimeout(At.current),At.current=null,Ce.data.success?(fe("info","Authentication successful via popup. Reconnecting client..."),it.current&&fe("debug","Connection attempt already in progress, resetting flag to allow reconnection."),it.current=!1,setTimeout(()=>{qe.current&&(fe("debug","Initiating reconnection after successful auth callback."),Ge.current?.())},100)):We.current?.(`Authentication failed in callback: ${Ce.data.error||"Unknown reason."}`))},"messageHandler");return window.addEventListener("message",ge),fe("debug","Auth callback message listener added."),()=>{window.removeEventListener("message",ge),fe("debug","Auth callback message listener removed."),At.current&&clearTimeout(At.current)}},[fe]),b.useEffect(()=>{ne.current=!1,Y(u)},[t,u]),b.useEffect(()=>{if(qe.current=!0,!n||!t)return fe("debug",n?"No server URL provided, skipping connection.":"Connection disabled via enabled flag."),z("discovering"),()=>{qe.current=!1};if(fe("debug","useMcp mounted, initiating connection."),lt.current=0,!_e.current||_e.current.serverUrl!==ee){let ge;if(F){const Ce=new URL(F),Te=Ce.pathname.replace(/\/proxy\/?$/,"");ge=`${Ce.origin}${Te}/oauth`,fe("debug",`OAuth proxy URL derived from gateway: ${ge}`)}_e.current=new ny(ee,{storageKeyPrefix:a,clientName:V.name,clientUri:V.uri,logoUri:V.logo_uri||"https://mcp-use.com/logo.png",callbackUrl:r,preventAutoAuth:E,useRedirectFlow:x,oauthProxyUrl:ge,connectionUrl:F,onPopupWindow:w}),fe("debug",`BrowserOAuthClientProvider initialized/updated with URL: ${ee}, proxy: ${ge?"enabled":"disabled"}, gateway: ${F?"enabled":"disabled"}`),ge&&(_e.current.installFetchInterceptor(),fe("debug","Installed OAuth fetch interceptor"))}return Pt(),()=>{if(qe.current=!1,fe("debug","useMcp unmounting, disconnecting."),(ot.current==="authenticating"||ot.current==="pending_auth")&&_e.current)try{const ge=_e.current.clearStorage();ge>0&&fe("debug",`Cleared ${ge} OAuth state item(s) during unmount to prevent corruption`)}catch(ge){fe("debug","Error clearing OAuth state during unmount:",ge)}It(!0)}},[t,n,a,r,V.name,V.version,V.uri,V.logo_uri,x,$,ee]);const de=b.useRef(Xt),ye=b.useRef(fe);b.useEffect(()=>{de.current=Xt,ye.current=fe},[Xt,fe]),b.useEffect(()=>{let ge=null;if(B==="failed"&&h&&lt.current>0){if(!Nn.current){Nn.current=!0;const Ce=typeof h=="number"?h:Kre;ye.current("info",`Connection failed, auto-retrying in ${Ce}ms...`),ge=setTimeout(()=>{Nn.current=!1,qe.current&&ot.current==="failed"&&de.current()},Ce)}}else B!=="failed"&&(Nn.current=!1);return()=>{ge&&(clearTimeout(ge),Nn.current=!1)}},[B,h]);const ke=b.useCallback(async()=>ot.current!=="ready"?(fe("warn","Cannot ensure icon loaded - not connected"),null):J?.icon?J.icon:Be.current?(fe("debug","Waiting for icon to finish loading..."),await Be.current):(fe("debug","No icon available and no loading in progress"),null),[J,fe]);return{state:B,name:J?.name||t||"",tools:D,resources:W,resourceTemplates:ae,prompts:le,serverInfo:J,capabilities:ie,error:Ne,log:Pe,authUrl:st,authTokens:ut,client:Ee.current,callTool:$t,readResource:Ht,listResources:Ut,listPrompts:zt,getPrompt:se,refreshTools:Ln,refreshResources:sn,refreshPrompts:Mn,refreshAll:qn,retry:Xt,disconnect:It,authenticate:xn,clearStorage:dt,ensureIconLoaded:ke}}ze(TB,"useMcp");var Cd,Yre=(Cd=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(Cd,"ErrorBoundary"),Cd),zp="openai:set_globals";function Mo(e){return b.useSyncExternalStore(t=>{const n=ze(r=>{r.detail.globals[e]!==void 0&&t()},"handleSetGlobal");return typeof window<"u"&&window.addEventListener(zp,n),()=>{typeof window<"u"&&window.removeEventListener(zp,n)}},()=>typeof window<"u"&&window.openai?window.openai[e]:void 0)}ze(Mo,"useOpenAiGlobal");function Jd(e){const[t,n]=b.useState(()=>typeof window<"u"&&!!window.openai);b.useEffect(()=>{if(typeof window<"u"&&window.openai){n(!0);return}const L=setInterval(()=>{typeof window<"u"&&window.openai&&(n(!0),clearInterval(L))},100),$=ze(()=>{typeof window<"u"&&window.openai&&(n(!0),clearInterval(L))},"handleSetGlobals");typeof window<"u"&&window.addEventListener(zp,$);const H=setTimeout(()=>{clearInterval(L),typeof window<"u"&&window.removeEventListener(zp,$)},5e3);return()=>{clearInterval(L),clearTimeout(H),typeof window<"u"&&window.removeEventListener(zp,$)}},[]);const r=b.useMemo(()=>t?"openai":"mcp-ui",[t]),a=typeof window<"u"?window.location.search:"",o=b.useMemo(()=>{const L=new URLSearchParams(a);return L.has("mcpUseParams")?JSON.parse(L.get("mcpUseParams")):{toolInput:{},toolOutput:{},toolId:""}},[a]),i=r==="openai"?Mo("toolInput"):o.toolInput,l=r==="openai"?Mo("toolOutput"):o.toolOutput,u=Mo("toolResponseMetadata"),f=b.useMemo(()=>{if(u&&typeof u=="object"){const L=u["mcp-use/props"];if(L)return L}return e||{}},[u,e]),m=Mo("widgetState"),h=Mo("theme"),g=Mo("displayMode"),y=Mo("safeArea"),E=Mo("maxHeight"),x=Mo("userAgent"),w=Mo("locale"),S=b.useMemo(()=>typeof window<"u"&&window.__mcpPublicUrl?window.__mcpPublicUrl.replace(/\/mcp-use\/public$/,""):"",[]),[_,T]=b.useState(null);b.useEffect(()=>{m!==void 0&&T(m)},[m]);const A=b.useCallback(async(L,$)=>{if(!window.openai?.callTool)throw new Error("window.openai.callTool is not available");return window.openai.callTool(L,$)},[]),R=b.useCallback(async L=>{if(!window.openai?.sendFollowUpMessage)throw new Error("window.openai.sendFollowUpMessage is not available");return window.openai.sendFollowUpMessage({prompt:L})},[]),k=b.useCallback(L=>{if(!window.openai?.openExternal)throw new Error("window.openai.openExternal is not available");window.openai.openExternal({href:L})},[]),C=b.useCallback(async L=>{if(!window.openai?.requestDisplayMode)throw new Error("window.openai.requestDisplayMode is not available");return window.openai.requestDisplayMode({mode:L})},[]),O=b.useCallback(async L=>{if(!window.openai?.setWidgetState)throw new Error("window.openai.setWidgetState is not available");const H=typeof L=="function"?L(m!==void 0?m:_):L;return T(H),window.openai.setWidgetState(H)},[m,_]),M=b.useMemo(()=>r==="openai"&&u===null,[r,u]);return{props:f,toolInput:i||{},output:l??null,metadata:u??null,state:_,setState:O,theme:h||"light",displayMode:g||"inline",safeArea:y||{insets:{top:0,bottom:0,left:0,right:0}},maxHeight:E||600,userAgent:x||{device:{type:"desktop"},capabilities:{hover:!0,touch:!1}},locale:w||"en",mcp_url:S,callTool:A,sendFollowUpMessage:R,openExternal:k,requestDisplayMode:C,isAvailable:t,isPending:M}}ze(Jd,"useWidget");function Zre(e){const{props:t}=Jd(e);return t}ze(Zre,"useWidgetProps");function qre(){const{theme:e}=Jd();return e}ze(qre,"useWidgetTheme");function Xre(e){const{state:t,setState:n}=Jd();return b.useEffect(()=>{t===null&&e!==void 0&&window.openai?.setWidgetState&&n(e)},[]),[t,n]}ze(Xre,"useWidgetState");var I$=ze(({children:e})=>{const{theme:t,isAvailable:n}=Jd();console.log("theme",t);const[r,a]=b.useState(()=>typeof window>"u"?"light":window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light");b.useEffect(()=>{if(typeof window>"u")return;const i=window.matchMedia("(prefers-color-scheme: dark)"),l=ze(u=>{a(u.matches?"dark":"light")},"handleChange");return i.addEventListener("change",l),()=>i.removeEventListener("change",l)},[]);const o=n?t:r;return b.useLayoutEffect(()=>{typeof document>"u"||(o==="dark"?document.documentElement.classList.add("dark"):document.documentElement.classList.remove("dark"))},[o]),ue.createElement(ue.Fragment,null,e)},"ThemeProvider");function NB({children:e,className:t="",position:n="top-right",attachTo:r,showLabels:a=!0,debugger:o=!1,viewControls:i=!1}){const{props:l,output:u,metadata:f,state:m,theme:h,displayMode:g,safeArea:y,maxHeight:E,userAgent:x,locale:w,isAvailable:S,callTool:_,sendFollowUpMessage:T,openExternal:A,requestDisplayMode:R,setState:k}=Jd(),[C,O]=b.useState(!1),[M,L]=b.useState(!1),$=b.useRef(null),H=b.useRef(null),[V,Z]=b.useState([]),[ne,G]=b.useState(""),[Y,F]=b.useState("get-my-city"),[re,ee]=b.useState("{}"),[j,B]=b.useState("Test follow-up message"),[z,D]=b.useState("https://mcp-use.com/docs"),P=g==="fullscreen"&&S,W=g==="pip"&&S,K=typeof window<"u"&&window.location.pathname.includes("/inspector/api/");b.useEffect(()=>{const Ee=setTimeout(()=>{if(typeof window<"u"&&window.openai)try{const _e=Object.keys(window.openai);Z(_e)}catch{Z([])}else Z([])},100);return()=>{clearTimeout(Ee)}},[]);const ae=h==="dark",oe=ze(()=>{const Ee=["absolute","z-[1000]","flex","gap-2","transition-opacity","duration-200","ease-in-out",C?"opacity-100":"opacity-0",C?"pointer-events-auto":"pointer-events-none"];switch(n){case"top-left":return[...Ee,"top-4","left-4"];case"top-center":return[...Ee,"top-4","left-1/2","-translate-x-1/2"];case"top-right":return[...Ee,"top-4","right-4"];case"center-left":return[...Ee,"top-1/2","left-4","-translate-y-1/2"];case"center-right":return[...Ee,"top-1/2","right-4","-translate-y-1/2"];case"bottom-left":return[...Ee,"bottom-4","left-4"];case"bottom-center":return[...Ee,"bottom-4","left-1/2","-translate-x-1/2"];case"bottom-right":return[...Ee,"bottom-4","right-4"];default:return[...Ee,"top-4","right-4"]}},"getPositionClasses"),le=ze(()=>{const _e=y?.insets?.top?Math.max(16,y.insets.top+8):16,Be=y?.insets?.right?Math.max(16,y.insets.right+8):16,it=y?.insets?.bottom?Math.max(16,y.insets.bottom+8):16,qe=y?.insets?.left?Math.max(16,y.insets.left+8):16,lt={};switch(n){case"top-left":lt.top=`${_e}px`,lt.left=`${qe}px`;break;case"top-center":lt.top=`${_e}px`;break;case"top-right":lt.top=`${_e}px`,lt.right=`${Be}px`;break;case"center-left":lt.left=`${qe}px`;break;case"center-right":lt.right=`${Be}px`;break;case"bottom-left":lt.bottom=`${it}px`,lt.left=`${qe}px`;break;case"bottom-center":lt.bottom=`${it}px`;break;case"bottom-right":lt.bottom=`${it}px`,lt.right=`${Be}px`;break;default:lt.top=`${_e}px`,lt.right=`${Be}px`;break}return lt},"getPositionOffsetStyles");b.useEffect(()=>{if(!r)return;const Ee=ze(()=>O(!0),"handleMouseEnter"),_e=ze(()=>O(!1),"handleMouseLeave");return r.addEventListener("mouseenter",Ee),r.addEventListener("mouseleave",_e),()=>{r.removeEventListener("mouseenter",Ee),r.removeEventListener("mouseleave",_e)}},[r]),b.useEffect(()=>{if(!M)return;const Ee=ze(_e=>{H.current&&!H.current.contains(_e.target)&&L(!1)},"handleClickOutside");return document.addEventListener("mousedown",Ee),()=>{document.removeEventListener("mousedown",Ee)}},[M]),b.useEffect(()=>(M?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[M]);const Q=ze(()=>{L(!M)},"handleToggleOverlay"),J=ze(async()=>{try{G("Calling tool...");const Ee=re.trim()?JSON.parse(re):{},_e=await _(Y,Ee);G(`Success: ${JSON.stringify(_e,null,2)}`)}catch(Ee){G(`Error: ${Ee.message}`)}},"handleCallTool"),q=ze(async()=>{try{G("Sending follow-up message..."),await T(j),G("Follow-up message sent successfully")}catch(Ee){G(`Error: ${Ee.message}`)}},"handleSendFollowUpMessage"),ie=ze(()=>{try{A(z),G(`Opened external link: ${z}`)}catch(Ee){G(`Error: ${Ee.message}`)}},"handleOpenExternal"),he=ze(async Ee=>{try{G(`Requesting display mode: ${Ee}...`);const _e=await R(Ee);G(`Display mode granted: ${_e.mode}`)}catch(_e){G(`Error: ${_e.message}`)}},"handleRequestDisplayMode"),Ne=ze(async()=>{try{const Ee=m?{...m,debugTimestamp:new Date().toISOString()}:{debugTimestamp:new Date().toISOString()};G("Setting state..."),await k(Ee),G(`State updated: ${JSON.stringify(Ee,null,2)}`)}catch(Ee){G(`Error: ${Ee.message}`)}},"handleSetState"),Ye=ze(async()=>{try{await R("fullscreen")}catch(Ee){console.error("Failed to go fullscreen:",Ee)}},"handleFullscreen"),Pe=ze(async()=>{try{await R("pip")}catch(Ee){console.error("Failed to go pip:",Ee)}},"handlePip"),Ue=ze(()=>{const Ee=["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[...Ee,"top-full","right-0","mt-2"];case"top-left":return[...Ee,"top-full","left-0","mt-2"];case"top-center":return[...Ee,"top-full","left-1/2","-translate-x-1/2","mt-2"];case"bottom-right":return[...Ee,"bottom-full","right-0","mb-2"];case"bottom-left":return[...Ee,"bottom-full","left-0","mb-2"];case"bottom-center":return[...Ee,"bottom-full","left-1/2","-translate-x-1/2","mb-2"];case"center-left":return[...Ee,"left-full","top-1/2","-translate-y-1/2","ml-2"];case"center-right":return[...Ee,"right-full","top-1/2","-translate-y-1/2","mr-2"];default:return[...Ee,"top-full","right-0","mt-2"]}},"getTooltipClasses"),st=ze(({onClick:Ee,label:_e,children:Be})=>{const[it,qe]=b.useState(!1),lt=Ue();return ue.createElement("button",{className:`p-2 ${ae?"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 ${ae?"shadow-[0_2px_8px_rgba(0,0,0,0.3)]":"shadow-[0_2px_8px_rgba(0,0,0,0.2)]"} relative`,onMouseEnter:()=>qe(!0),onMouseLeave:()=>qe(!1),onClick:Ee,"aria-label":_e},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"},Be),a&&ue.createElement("span",{className:`${lt.join(" ")} ${it?"opacity-100":"opacity-0"}`},_e))},"IconButton"),Ve=ze(Ee=>{if(Ee===null)return"null";if(Ee===void 0)return"undefined";if(typeof Ee=="object")try{return JSON.stringify(Ee,null,2)}catch{return String(Ee)}return String(Ee)},"formatValue"),ut=ze(Ee=>Ee?`${Ee.device?.type||"unknown"}`:"N/A","formatUserAgent"),rt=ze(Ee=>{if(!Ee?.insets)return"N/A";const{top:_e,bottom:Be,left:it,right:qe}=Ee.insets;return`T:${_e} B:${Be} L:${it} R:${qe}`},"formatSafeArea");return ue.createElement(ue.Fragment,null,ue.createElement("div",{ref:$,className:`${t} relative h-fit`,onMouseEnter:()=>!r&&O(!0),onMouseLeave:()=>!r&&O(!1)},ue.createElement("div",{className:oe().join(" "),style:le()},!K&&ue.createElement(ue.Fragment,null,!P&&!W&&ue.createElement(ue.Fragment,null,(i===!0||i==="fullscreen")&&ue.createElement(st,{onClick:Ye,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"})),(i===!0||i==="pip")&&ue.createElement(st,{onClick:Pe,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"}))),o&&ue.createElement(st,{onClick:Q,label:"Debug Info"},ue.createElement("path",{d:"M12 20v-9"}),ue.createElement("path",{d:"M14 7a4 4 0 0 1 4 4v3a6 6 0 0 1-12 0v-3a4 4 0 0 1 4-4z"}),ue.createElement("path",{d:"M14.12 3.88 16 2"}),ue.createElement("path",{d:"M21 21a4 4 0 0 0-3.81-4"}),ue.createElement("path",{d:"M21 5a4 4 0 0 1-3.55 3.97"}),ue.createElement("path",{d:"M22 13h-4"}),ue.createElement("path",{d:"M3 21a4 4 0 0 1 3.81-4"}),ue.createElement("path",{d:"M3 5a4 4 0 0 0 3.55 3.97"}),ue.createElement("path",{d:"M6 13H2"}),ue.createElement("path",{d:"m8 2 1.88 1.88"}),ue.createElement("path",{d:"M9 7.13V6a3 3 0 1 1 6 0v1.13"})))),e),M&&o&&ue.createElement("div",{ref:H,className:"fixed inset-0 bg-black text-white font-mono text-xs z-[10000] overflow-auto p-4",onClick:Ee=>{Ee.target===H.current&&L(!1)}},ue.createElement("button",{onClick:()=>L(!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"},Ve(l))),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"},Ve(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"},Ve(f))),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"},Ve(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"},w)),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"},E,"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"},ut(x))),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"},rt(y))),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"},S?"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"},V.length>0?V.join(", "):"N/A")))),ue.createElement("h2",{className:"text-base font-bold mt-8 mb-4 border-b border-gray-700 pb-2"},"Actions"),ue.createElement("div",{className:"flex flex-col gap-3"},ue.createElement("div",{className:"flex gap-2 items-center"},ue.createElement("input",{type:"text",value:Y,onChange:Ee=>F(Ee.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:Ee=>ee(Ee.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:J,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:Ee=>B(Ee.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:q,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:Ee=>D(Ee.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:ie,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:()=>he("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:()=>he("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:()=>he("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:Ne,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)")),ne&&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:"),ne,ue.createElement("button",{onClick:()=>G(""),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(NB,"WidgetControls");function CB(){if(typeof window>"u")return"/";const t=window.location.pathname.match(/^(\/inspector\/api\/dev-widget\/[^/]+)/);return t?t[1]:"/"}ze(CB,"getBasename");var Jre=150,Qre=5;function eae({children:e,debugger:t=!1,viewControls:n=!1,autoSize:r=!1}){const a=CB(),o=b.useRef(null),i=b.useRef(0),l=b.useRef(null),u=b.useRef(!1),[f,m]=b.useState(null),[h,g]=b.useState(null),[y,E]=b.useState(!0);b.useEffect(()=>{let _=!0;return(async()=>{try{const T=await Ua(()=>import("./index-B4crqmqO.js"),[]);_&&(m(()=>T.BrowserRouter),E(!1))}catch{_&&(g(new Error(`❌ react-router not installed!
36
36
 
37
37
  To use MCP widgets with McpUseProvider, you need to install:
38
38
 
@@ -88,7 +88,7 @@ Error generating stack: `+v.message+`
88
88
  `)},fU=function(){var e=parseInt(document.body.getAttribute(Xu)||"0",10);return isFinite(e)?e:0},Bie=function(){b.useEffect(function(){return document.body.setAttribute(Xu,(fU()+1).toString()),function(){var e=fU()-1;e<=0?document.body.removeAttribute(Xu):document.body.setAttribute(Xu,e.toString())}},[])},Hie=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,a=r===void 0?"margin":r;Bie();var o=b.useMemo(function(){return Uie(a)},[a]);return b.createElement(zie,{styles:Fie(o,!t,a,n?"":"!important")})},i_=!1;if(typeof window<"u")try{var Ab=Object.defineProperty({},"passive",{get:function(){return i_=!0,!0}});window.addEventListener("test",Ab,Ab),window.removeEventListener("test",Ab,Ab)}catch{i_=!1}var gu=i_?{passive:!1}:!1,Vie=function(e){return e.tagName==="TEXTAREA"},j5=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!Vie(e)&&n[t]==="visible")},Gie=function(e){return j5(e,"overflowY")},Wie=function(e){return j5(e,"overflowX")},pU=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var a=P5(e,r);if(a){var o=$5(e,r),i=o[1],l=o[2];if(i>l)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},Kie=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},Yie=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},P5=function(e,t){return e==="v"?Gie(t):Wie(t)},$5=function(e,t){return e==="v"?Kie(t):Yie(t)},Zie=function(e,t){return e==="h"&&t==="rtl"?-1:1},qie=function(e,t,n,r,a){var o=Zie(e,window.getComputedStyle(t).direction),i=o*r,l=n.target,u=t.contains(l),f=!1,m=i>0,h=0,g=0;do{if(!l)break;var y=$5(e,l),E=y[0],x=y[1],w=y[2],S=x-w-o*E;(E||S)&&P5(e,l)&&(h+=S,g+=E);var _=l.parentNode;l=_&&_.nodeType===Node.DOCUMENT_FRAGMENT_NODE?_.host:_}while(!u&&l!==document.body||u&&(t.contains(l)||t===l));return(m&&Math.abs(h)<1||!m&&Math.abs(g)<1)&&(f=!0),f},Ib=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},mU=function(e){return[e.deltaX,e.deltaY]},hU=function(e){return e&&"current"in e?e.current:e},Xie=function(e,t){return e[0]===t[0]&&e[1]===t[1]},Jie=function(e){return`
89
89
  .block-interactivity-`.concat(e,` {pointer-events: none;}
90
90
  .allow-interactivity-`).concat(e,` {pointer-events: all;}
91
- `)},Qie=0,bu=[];function ele(e){var t=b.useRef([]),n=b.useRef([0,0]),r=b.useRef(),a=b.useState(Qie++)[0],o=b.useState(M5)[0],i=b.useRef(e);b.useEffect(function(){i.current=e},[e]),b.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(a));var x=xie([e.lockRef.current],(e.shards||[]).map(hU),!0).filter(Boolean);return x.forEach(function(w){return w.classList.add("allow-interactivity-".concat(a))}),function(){document.body.classList.remove("block-interactivity-".concat(a)),x.forEach(function(w){return w.classList.remove("allow-interactivity-".concat(a))})}}},[e.inert,e.lockRef.current,e.shards]);var l=b.useCallback(function(x,w){if("touches"in x&&x.touches.length===2||x.type==="wheel"&&x.ctrlKey)return!i.current.allowPinchZoom;var S=Ib(x),_=n.current,T="deltaX"in x?x.deltaX:_[0]-S[0],A="deltaY"in x?x.deltaY:_[1]-S[1],R,k=x.target,C=Math.abs(T)>Math.abs(A)?"h":"v";if("touches"in x&&C==="h"&&k.type==="range")return!1;var O=window.getSelection(),M=O&&O.anchorNode,L=M?M===k||M.contains(k):!1;if(L)return!1;var $=pU(C,k);if(!$)return!0;if($?R=C:(R=C==="v"?"h":"v",$=pU(C,k)),!$)return!1;if(!r.current&&"changedTouches"in x&&(T||A)&&(r.current=R),!R)return!0;var H=r.current||R;return qie(H,w,x,H==="h"?T:A)},[]),u=b.useCallback(function(x){var w=x;if(!(!bu.length||bu[bu.length-1]!==o)){var S="deltaY"in w?mU(w):Ib(w),_=t.current.filter(function(R){return R.name===w.type&&(R.target===w.target||w.target===R.shadowParent)&&Xie(R.delta,S)})[0];if(_&&_.should){w.cancelable&&w.preventDefault();return}if(!_){var T=(i.current.shards||[]).map(hU).filter(Boolean).filter(function(R){return R.contains(w.target)}),A=T.length>0?l(w,T[0]):!i.current.noIsolation;A&&w.cancelable&&w.preventDefault()}}},[]),f=b.useCallback(function(x,w,S,_){var T={name:x,delta:w,target:S,should:_,shadowParent:tle(S)};t.current.push(T),setTimeout(function(){t.current=t.current.filter(function(A){return A!==T})},1)},[]),m=b.useCallback(function(x){n.current=Ib(x),r.current=void 0},[]),h=b.useCallback(function(x){f(x.type,mU(x),x.target,l(x,e.lockRef.current))},[]),g=b.useCallback(function(x){f(x.type,Ib(x),x.target,l(x,e.lockRef.current))},[]);b.useEffect(function(){return bu.push(o),e.setCallbacks({onScrollCapture:h,onWheelCapture:h,onTouchMoveCapture:g}),document.addEventListener("wheel",u,gu),document.addEventListener("touchmove",u,gu),document.addEventListener("touchstart",m,gu),function(){bu=bu.filter(function(x){return x!==o}),document.removeEventListener("wheel",u,gu),document.removeEventListener("touchmove",u,gu),document.removeEventListener("touchstart",m,gu)}},[]);var y=e.removeScrollBar,E=e.inert;return b.createElement(b.Fragment,null,E?b.createElement(o,{styles:Jie(a)}):null,y?b.createElement(Hie,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function tle(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const nle=Aie(L5,ele);var Qm=b.forwardRef(function(e,t){return b.createElement(Xv,as({},e,{ref:t,sideCar:nle}))});Qm.classNames=Xv.classNames;var l_=["Enter"," "],rle=["ArrowDown","PageUp","Home"],U5=["ArrowUp","PageDown","End"],ale=[...rle,...U5],ole={ltr:[...l_,"ArrowRight"],rtl:[...l_,"ArrowLeft"]},sle={ltr:["ArrowLeft"],rtl:["ArrowRight"]},eh="Menu",[im,ile,lle]=RN(eh),[Sc,z5]=qo(eh,[lle,hl,N5]),Jv=hl(),F5=N5(),[cle,_c]=Sc(eh),[ule,th]=Sc(eh),B5=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:a,onOpenChange:o,modal:i=!0}=e,l=Jv(t),[u,f]=b.useState(null),m=b.useRef(!1),h=ps(o),g=kN(a);return b.useEffect(()=>{const y=()=>{m.current=!0,document.addEventListener("pointerdown",E,{capture:!0,once:!0}),document.addEventListener("pointermove",E,{capture:!0,once:!0})},E=()=>m.current=!1;return document.addEventListener("keydown",y,{capture:!0}),()=>{document.removeEventListener("keydown",y,{capture:!0}),document.removeEventListener("pointerdown",E,{capture:!0}),document.removeEventListener("pointermove",E,{capture:!0})}},[]),d.jsx(Kv,{...l,children:d.jsx(cle,{scope:t,open:n,onOpenChange:h,content:u,onContentChange:f,children:d.jsx(ule,{scope:t,onClose:b.useCallback(()=>h(!1),[h]),isUsingKeyboardRef:m,dir:g,modal:i,children:r})})})};B5.displayName=eh;var dle="MenuAnchor",UN=b.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,a=Jv(n);return d.jsx(Xm,{...a,...r,ref:t})});UN.displayName=dle;var zN="MenuPortal",[fle,H5]=Sc(zN,{forceMount:void 0}),V5=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:a}=e,o=_c(zN,t);return d.jsx(fle,{scope:t,forceMount:n,children:d.jsx(ao,{present:n||o.open,children:d.jsx(of,{asChild:!0,container:a,children:r})})})};V5.displayName=zN;var Eo="MenuContent",[ple,FN]=Sc(Eo),G5=b.forwardRef((e,t)=>{const n=H5(Eo,e.__scopeMenu),{forceMount:r=n.forceMount,...a}=e,o=_c(Eo,e.__scopeMenu),i=th(Eo,e.__scopeMenu);return d.jsx(im.Provider,{scope:e.__scopeMenu,children:d.jsx(ao,{present:r||o.open,children:d.jsx(im.Slot,{scope:e.__scopeMenu,children:i.modal?d.jsx(mle,{...a,ref:t}):d.jsx(hle,{...a,ref:t})})})})}),mle=b.forwardRef((e,t)=>{const n=_c(Eo,e.__scopeMenu),r=b.useRef(null),a=gn(t,r);return b.useEffect(()=>{const o=r.current;if(o)return qv(o)},[]),d.jsx(BN,{...e,ref:a,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:ct(e.onFocusOutside,o=>o.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),hle=b.forwardRef((e,t)=>{const n=_c(Eo,e.__scopeMenu);return d.jsx(BN,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),gle=cc("MenuContent.ScrollLock"),BN=b.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:a,onOpenAutoFocus:o,onCloseAutoFocus:i,disableOutsidePointerEvents:l,onEntryFocus:u,onEscapeKeyDown:f,onPointerDownOutside:m,onFocusOutside:h,onInteractOutside:g,onDismiss:y,disableOutsideScroll:E,...x}=e,w=_c(Eo,n),S=th(Eo,n),_=Jv(n),T=F5(n),A=ile(n),[R,k]=b.useState(null),C=b.useRef(null),O=gn(t,C,w.onContentChange),M=b.useRef(0),L=b.useRef(""),$=b.useRef(0),H=b.useRef(null),V=b.useRef("right"),Z=b.useRef(0),ne=E?Qm:b.Fragment,G=E?{as:gle,allowPinchZoom:!0}:void 0,Y=re=>{const ee=L.current+re,j=A().filter(K=>!K.disabled),B=document.activeElement,z=j.find(K=>K.ref.current===B)?.textValue,D=j.map(K=>K.textValue),P=Rle(D,ee,z),W=j.find(K=>K.textValue===P)?.ref.current;(function K(ae){L.current=ae,window.clearTimeout(M.current),ae!==""&&(M.current=window.setTimeout(()=>K(""),1e3))})(ee),W&&setTimeout(()=>W.focus())};b.useEffect(()=>()=>window.clearTimeout(M.current),[]),Bv();const F=b.useCallback(re=>V.current===H.current?.side&&Ale(re,H.current?.area),[]);return d.jsx(ple,{scope:n,searchRef:L,onItemEnter:b.useCallback(re=>{F(re)&&re.preventDefault()},[F]),onItemLeave:b.useCallback(re=>{F(re)||(C.current?.focus(),k(null))},[F]),onTriggerLeave:b.useCallback(re=>{F(re)&&re.preventDefault()},[F]),pointerGraceTimerRef:$,onPointerGraceIntentChange:b.useCallback(re=>{H.current=re},[]),children:d.jsx(ne,{...G,children:d.jsx(Zm,{asChild:!0,trapped:a,onMountAutoFocus:ct(o,re=>{re.preventDefault(),C.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:d.jsx(nf,{asChild:!0,disableOutsidePointerEvents:l,onEscapeKeyDown:f,onPointerDownOutside:m,onFocusOutside:h,onInteractOutside:g,onDismiss:y,children:d.jsx(gie,{asChild:!0,...T,dir:S.dir,orientation:"vertical",loop:r,currentTabStopId:R,onCurrentTabStopIdChange:k,onEntryFocus:ct(u,re=>{S.isUsingKeyboardRef.current||re.preventDefault()}),preventScrollOnEntryFocus:!0,children:d.jsx(Yv,{role:"menu","aria-orientation":"vertical","data-state":iH(w.open),"data-radix-menu-content":"",dir:S.dir,..._,...x,ref:O,style:{outline:"none",...x.style},onKeyDown:ct(x.onKeyDown,re=>{const j=re.target.closest("[data-radix-menu-content]")===re.currentTarget,B=re.ctrlKey||re.altKey||re.metaKey,z=re.key.length===1;j&&(re.key==="Tab"&&re.preventDefault(),!B&&z&&Y(re.key));const D=C.current;if(re.target!==D||!ale.includes(re.key))return;re.preventDefault();const W=A().filter(K=>!K.disabled).map(K=>K.ref.current);U5.includes(re.key)&&W.reverse(),Nle(W)}),onBlur:ct(e.onBlur,re=>{re.currentTarget.contains(re.target)||(window.clearTimeout(M.current),L.current="")}),onPointerMove:ct(e.onPointerMove,lm(re=>{const ee=re.target,j=Z.current!==re.clientX;if(re.currentTarget.contains(ee)&&j){const B=re.clientX>Z.current?"right":"left";V.current=B,Z.current=re.clientX}}))})})})})})})});G5.displayName=Eo;var ble="MenuGroup",HN=b.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return d.jsx(Zt.div,{role:"group",...r,ref:t})});HN.displayName=ble;var yle="MenuLabel",W5=b.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return d.jsx(Zt.div,{...r,ref:t})});W5.displayName=yle;var Yy="MenuItem",gU="menu.itemSelect",Qv=b.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...a}=e,o=b.useRef(null),i=th(Yy,e.__scopeMenu),l=FN(Yy,e.__scopeMenu),u=gn(t,o),f=b.useRef(!1),m=()=>{const h=o.current;if(!n&&h){const g=new CustomEvent(gU,{bubbles:!0,cancelable:!0});h.addEventListener(gU,y=>r?.(y),{once:!0}),e5(h,g),g.defaultPrevented?f.current=!1:i.onClose()}};return d.jsx(K5,{...a,ref:u,disabled:n,onClick:ct(e.onClick,m),onPointerDown:h=>{e.onPointerDown?.(h),f.current=!0},onPointerUp:ct(e.onPointerUp,h=>{f.current||h.currentTarget?.click()}),onKeyDown:ct(e.onKeyDown,h=>{const g=l.searchRef.current!=="";n||g&&h.key===" "||l_.includes(h.key)&&(h.currentTarget.click(),h.preventDefault())})})});Qv.displayName=Yy;var K5=b.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:a,...o}=e,i=FN(Yy,n),l=F5(n),u=b.useRef(null),f=gn(t,u),[m,h]=b.useState(!1),[g,y]=b.useState("");return b.useEffect(()=>{const E=u.current;E&&y((E.textContent??"").trim())},[o.children]),d.jsx(im.ItemSlot,{scope:n,disabled:r,textValue:a??g,children:d.jsx(bie,{asChild:!0,...l,focusable:!r,children:d.jsx(Zt.div,{role:"menuitem","data-highlighted":m?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...o,ref:f,onPointerMove:ct(e.onPointerMove,lm(E=>{r?i.onItemLeave(E):(i.onItemEnter(E),E.defaultPrevented||E.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:ct(e.onPointerLeave,lm(E=>i.onItemLeave(E))),onFocus:ct(e.onFocus,()=>h(!0)),onBlur:ct(e.onBlur,()=>h(!1))})})})}),vle="MenuCheckboxItem",Y5=b.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...a}=e;return d.jsx(Q5,{scope:e.__scopeMenu,checked:n,children:d.jsx(Qv,{role:"menuitemcheckbox","aria-checked":Zy(n)?"mixed":n,...a,ref:t,"data-state":GN(n),onSelect:ct(a.onSelect,()=>r?.(Zy(n)?!0:!n),{checkForDefaultPrevented:!1})})})});Y5.displayName=vle;var Z5="MenuRadioGroup",[wle,xle]=Sc(Z5,{value:void 0,onValueChange:()=>{}}),q5=b.forwardRef((e,t)=>{const{value:n,onValueChange:r,...a}=e,o=ps(r);return d.jsx(wle,{scope:e.__scopeMenu,value:n,onValueChange:o,children:d.jsx(HN,{...a,ref:t})})});q5.displayName=Z5;var X5="MenuRadioItem",J5=b.forwardRef((e,t)=>{const{value:n,...r}=e,a=xle(X5,e.__scopeMenu),o=n===a.value;return d.jsx(Q5,{scope:e.__scopeMenu,checked:o,children:d.jsx(Qv,{role:"menuitemradio","aria-checked":o,...r,ref:t,"data-state":GN(o),onSelect:ct(r.onSelect,()=>a.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});J5.displayName=X5;var VN="MenuItemIndicator",[Q5,Ele]=Sc(VN,{checked:!1}),eH=b.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...a}=e,o=Ele(VN,n);return d.jsx(ao,{present:r||Zy(o.checked)||o.checked===!0,children:d.jsx(Zt.span,{...a,ref:t,"data-state":GN(o.checked)})})});eH.displayName=VN;var Sle="MenuSeparator",tH=b.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return d.jsx(Zt.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});tH.displayName=Sle;var _le="MenuArrow",nH=b.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,a=Jv(n);return d.jsx(Zv,{...a,...r,ref:t})});nH.displayName=_le;var Tle="MenuSub",[HTe,rH]=Sc(Tle),Rp="MenuSubTrigger",aH=b.forwardRef((e,t)=>{const n=_c(Rp,e.__scopeMenu),r=th(Rp,e.__scopeMenu),a=rH(Rp,e.__scopeMenu),o=FN(Rp,e.__scopeMenu),i=b.useRef(null),{pointerGraceTimerRef:l,onPointerGraceIntentChange:u}=o,f={__scopeMenu:e.__scopeMenu},m=b.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return b.useEffect(()=>m,[m]),b.useEffect(()=>{const h=l.current;return()=>{window.clearTimeout(h),u(null)}},[l,u]),d.jsx(UN,{asChild:!0,...f,children:d.jsx(K5,{id:a.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":a.contentId,"data-state":iH(n.open),...e,ref:fs(t,a.onTriggerChange),onClick:h=>{e.onClick?.(h),!(e.disabled||h.defaultPrevented)&&(h.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:ct(e.onPointerMove,lm(h=>{o.onItemEnter(h),!h.defaultPrevented&&!e.disabled&&!n.open&&!i.current&&(o.onPointerGraceIntentChange(null),i.current=window.setTimeout(()=>{n.onOpenChange(!0),m()},100))})),onPointerLeave:ct(e.onPointerLeave,lm(h=>{m();const g=n.content?.getBoundingClientRect();if(g){const y=n.content?.dataset.side,E=y==="right",x=E?-5:5,w=g[E?"left":"right"],S=g[E?"right":"left"];o.onPointerGraceIntentChange({area:[{x:h.clientX+x,y:h.clientY},{x:w,y:g.top},{x:S,y:g.top},{x:S,y:g.bottom},{x:w,y:g.bottom}],side:y}),window.clearTimeout(l.current),l.current=window.setTimeout(()=>o.onPointerGraceIntentChange(null),300)}else{if(o.onTriggerLeave(h),h.defaultPrevented)return;o.onPointerGraceIntentChange(null)}})),onKeyDown:ct(e.onKeyDown,h=>{const g=o.searchRef.current!=="";e.disabled||g&&h.key===" "||ole[r.dir].includes(h.key)&&(n.onOpenChange(!0),n.content?.focus(),h.preventDefault())})})})});aH.displayName=Rp;var oH="MenuSubContent",sH=b.forwardRef((e,t)=>{const n=H5(Eo,e.__scopeMenu),{forceMount:r=n.forceMount,...a}=e,o=_c(Eo,e.__scopeMenu),i=th(Eo,e.__scopeMenu),l=rH(oH,e.__scopeMenu),u=b.useRef(null),f=gn(t,u);return d.jsx(im.Provider,{scope:e.__scopeMenu,children:d.jsx(ao,{present:r||o.open,children:d.jsx(im.Slot,{scope:e.__scopeMenu,children:d.jsx(BN,{id:l.contentId,"aria-labelledby":l.triggerId,...a,ref:f,align:"start",side:i.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:m=>{i.isUsingKeyboardRef.current&&u.current?.focus(),m.preventDefault()},onCloseAutoFocus:m=>m.preventDefault(),onFocusOutside:ct(e.onFocusOutside,m=>{m.target!==l.trigger&&o.onOpenChange(!1)}),onEscapeKeyDown:ct(e.onEscapeKeyDown,m=>{i.onClose(),m.preventDefault()}),onKeyDown:ct(e.onKeyDown,m=>{const h=m.currentTarget.contains(m.target),g=sle[i.dir].includes(m.key);h&&g&&(o.onOpenChange(!1),l.trigger?.focus(),m.preventDefault())})})})})})});sH.displayName=oH;function iH(e){return e?"open":"closed"}function Zy(e){return e==="indeterminate"}function GN(e){return Zy(e)?"indeterminate":e?"checked":"unchecked"}function Nle(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function Cle(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function Rle(e,t,n){const a=t.length>1&&Array.from(t).every(f=>f===t[0])?t[0]:t,o=n?e.indexOf(n):-1;let i=Cle(e,Math.max(o,0));a.length===1&&(i=i.filter(f=>f!==n));const u=i.find(f=>f.toLowerCase().startsWith(a.toLowerCase()));return u!==n?u:void 0}function kle(e,t){const{x:n,y:r}=e;let a=!1;for(let o=0,i=t.length-1;o<t.length;i=o++){const l=t[o],u=t[i],f=l.x,m=l.y,h=u.x,g=u.y;m>r!=g>r&&n<(h-f)*(r-m)/(g-m)+f&&(a=!a)}return a}function Ale(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return kle(n,t)}function lm(e){return t=>t.pointerType==="mouse"?e(t):void 0}var Ile=B5,Ole=UN,Dle=V5,Lle=G5,Mle=HN,jle=W5,Ple=Qv,$le=Y5,Ule=q5,zle=J5,Fle=eH,Ble=tH,Hle=nH,Vle=aH,Gle=sH,ew="DropdownMenu",[Wle]=qo(ew,[z5]),Ra=z5(),[Kle,lH]=Wle(ew),cH=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:a,defaultOpen:o,onOpenChange:i,modal:l=!0}=e,u=Ra(t),f=b.useRef(null),[m,h]=Js({prop:a,defaultProp:o??!1,onChange:i,caller:ew});return d.jsx(Kle,{scope:t,triggerId:oa(),triggerRef:f,contentId:oa(),open:m,onOpenChange:h,onOpenToggle:b.useCallback(()=>h(g=>!g),[h]),modal:l,children:d.jsx(Ile,{...u,open:m,onOpenChange:h,dir:r,modal:l,children:n})})};cH.displayName=ew;var uH="DropdownMenuTrigger",dH=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...a}=e,o=lH(uH,n),i=Ra(n);return d.jsx(Ole,{asChild:!0,...i,children:d.jsx(Zt.button,{type:"button",id:o.triggerId,"aria-haspopup":"menu","aria-expanded":o.open,"aria-controls":o.open?o.contentId:void 0,"data-state":o.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...a,ref:fs(t,o.triggerRef),onPointerDown:ct(e.onPointerDown,l=>{!r&&l.button===0&&l.ctrlKey===!1&&(o.onOpenToggle(),o.open||l.preventDefault())}),onKeyDown:ct(e.onKeyDown,l=>{r||(["Enter"," "].includes(l.key)&&o.onOpenToggle(),l.key==="ArrowDown"&&o.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(l.key)&&l.preventDefault())})})})});dH.displayName=uH;var Yle="DropdownMenuPortal",fH=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Ra(t);return d.jsx(Dle,{...r,...n})};fH.displayName=Yle;var pH="DropdownMenuContent",mH=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=lH(pH,n),o=Ra(n),i=b.useRef(!1);return d.jsx(Lle,{id:a.contentId,"aria-labelledby":a.triggerId,...o,...r,ref:t,onCloseAutoFocus:ct(e.onCloseAutoFocus,l=>{i.current||a.triggerRef.current?.focus(),i.current=!1,l.preventDefault()}),onInteractOutside:ct(e.onInteractOutside,l=>{const u=l.detail.originalEvent,f=u.button===0&&u.ctrlKey===!0,m=u.button===2||f;(!a.modal||m)&&(i.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)"}})});mH.displayName=pH;var Zle="DropdownMenuGroup",qle=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=Ra(n);return d.jsx(Mle,{...a,...r,ref:t})});qle.displayName=Zle;var Xle="DropdownMenuLabel",hH=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=Ra(n);return d.jsx(jle,{...a,...r,ref:t})});hH.displayName=Xle;var Jle="DropdownMenuItem",gH=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=Ra(n);return d.jsx(Ple,{...a,...r,ref:t})});gH.displayName=Jle;var Qle="DropdownMenuCheckboxItem",bH=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=Ra(n);return d.jsx($le,{...a,...r,ref:t})});bH.displayName=Qle;var ece="DropdownMenuRadioGroup",yH=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=Ra(n);return d.jsx(Ule,{...a,...r,ref:t})});yH.displayName=ece;var tce="DropdownMenuRadioItem",vH=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=Ra(n);return d.jsx(zle,{...a,...r,ref:t})});vH.displayName=tce;var nce="DropdownMenuItemIndicator",rce=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=Ra(n);return d.jsx(Fle,{...a,...r,ref:t})});rce.displayName=nce;var ace="DropdownMenuSeparator",wH=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=Ra(n);return d.jsx(Ble,{...a,...r,ref:t})});wH.displayName=ace;var oce="DropdownMenuArrow",sce=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=Ra(n);return d.jsx(Hle,{...a,...r,ref:t})});sce.displayName=oce;var ice="DropdownMenuSubTrigger",xH=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=Ra(n);return d.jsx(Vle,{...a,...r,ref:t})});xH.displayName=ice;var lce="DropdownMenuSubContent",EH=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=Ra(n);return d.jsx(Gle,{...a,...r,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)"}})});EH.displayName=lce;var cce=cH,uce=dH,dce=fH,SH=mH,_H=hH,TH=gH,fce=bH,pce=yH,NH=vH,CH=wH,mce=xH,hce=EH;const cm=cce,um=uce,gce=pce;mce.displayName;hce.displayName;function Pd({ref:e,className:t,sideOffset:n=4,...r}){return d.jsx(dce,{children:d.jsx(SH,{ref:e,sideOffset:n,className:Fe("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),...r})})}Pd.displayName=SH.displayName;function Jr({ref:e,className:t,inset:n,...r}){return d.jsx(TH,{ref:e,className:Fe("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),...r})}Jr.displayName=TH.displayName;fce.displayName;function sy({ref:e,className:t,children:n,...r}){return d.jsx(NH,{ref:e,className:Fe("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...r,children:n})}sy.displayName=NH.displayName;function c_({ref:e,className:t,inset:n,...r}){return d.jsx(_H,{ref:e,className:Fe("px-2 py-1.5 text-sm font-semibold",n&&"pl-8",t),...r})}c_.displayName=_H.displayName;function Mu({ref:e,className:t,...n}){return d.jsx(CH,{ref:e,className:Fe("-mx-1 my-1 h-px bg-muted",t),...n})}Mu.displayName=CH.displayName;function sf({message:e,className:t="",vertical:n,noBorder:r}){return d.jsx("div",{className:Fe(`mt-2 rounded-md p-6 ${t}`,!r&&"border"),children:d.jsxs("p",{className:Fe("text-sm text-muted-foreground flex items-center gap-4",n&&"flex-col"),children:[d.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:d.jsx("g",{stroke:"none",strokeWidth:"1",fill:"none",fillRule:"evenodd",children:d.jsxs("g",{transform:"translate(5.320900, 5.320900)",fillRule:"nonzero",className:"stroke-black dark:stroke-white",strokeWidth:"4",children:[d.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"}),d.jsx("circle",{cx:"50",cy:"212.0001",r:"52.5"}),d.jsx("circle",{cx:"212.0001",cy:"50",r:"52.5"})]})})}),e]})})}function RH({className:e,color:t,children:n,grayscaled:r=!1}){const a=b.useMemo(()=>{if(t){const h=t.split("(")[1].split(")")[0].trim().split(/\s+/);return Number.parseFloat(h[1]||"0")}return r?0:.2},[t,r]),o=b.useMemo(()=>{if(t){const h=t.split("(")[1].split(")")[0].trim().split(/\s+/);return Number.parseFloat(h[0]||"0.5")}return r?.3:.4},[t,r]),i=b.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]),l=b.useMemo(()=>t||`oklch(${Math.min(o,1)} ${a} ${i})`,[i,a,o]),u=b.useMemo(()=>`oklch(${Math.min(o*2,1)} ${a} ${i})`,[i,a,o,t]),f=b.useMemo(()=>Math.floor(Math.random()*360),[i]),m=b.useMemo(()=>"1000%",[]);return d.jsx("section",{className:Fe("relative w-full h-full overflow-hidden",e),style:{background:`${u}`},children:d.jsxs("div",{className:"isolate relative w-full h-full",children:[d.jsx("div",{className:"noise w-full h-full",style:{background:`linear-gradient(${f}deg, ${l}, transparent), url(https://grainy-gradients.vercel.app/noise.svg)`,filter:`contrast(120%) brightness(${m})`}}),n&&d.jsx("div",{className:"relative z-10 w-full h-full",children:n})]})})}var kH=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"}),bce="VisuallyHidden",AH=b.forwardRef((e,t)=>d.jsx(Zt.span,{...e,ref:t,style:{...kH,...e.style}}));AH.displayName=bce;var yce=AH,[tw]=qo("Tooltip",[hl]),nw=hl(),IH="TooltipProvider",vce=700,u_="tooltip.open",[wce,WN]=tw(IH),OH=e=>{const{__scopeTooltip:t,delayDuration:n=vce,skipDelayDuration:r=300,disableHoverableContent:a=!1,children:o}=e,i=b.useRef(!0),l=b.useRef(!1),u=b.useRef(0);return b.useEffect(()=>{const f=u.current;return()=>window.clearTimeout(f)},[]),d.jsx(wce,{scope:t,isOpenDelayedRef:i,delayDuration:n,onOpen:b.useCallback(()=>{window.clearTimeout(u.current),i.current=!1},[]),onClose:b.useCallback(()=>{window.clearTimeout(u.current),u.current=window.setTimeout(()=>i.current=!0,r)},[r]),isPointerInTransitRef:l,onPointerInTransitChange:b.useCallback(f=>{l.current=f},[]),disableHoverableContent:a,children:o})};OH.displayName=IH;var dm="Tooltip",[xce,nh]=tw(dm),DH=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:a,onOpenChange:o,disableHoverableContent:i,delayDuration:l}=e,u=WN(dm,e.__scopeTooltip),f=nw(t),[m,h]=b.useState(null),g=oa(),y=b.useRef(0),E=i??u.disableHoverableContent,x=l??u.delayDuration,w=b.useRef(!1),[S,_]=Js({prop:r,defaultProp:a??!1,onChange:C=>{C?(u.onOpen(),document.dispatchEvent(new CustomEvent(u_))):u.onClose(),o?.(C)},caller:dm}),T=b.useMemo(()=>S?w.current?"delayed-open":"instant-open":"closed",[S]),A=b.useCallback(()=>{window.clearTimeout(y.current),y.current=0,w.current=!1,_(!0)},[_]),R=b.useCallback(()=>{window.clearTimeout(y.current),y.current=0,_(!1)},[_]),k=b.useCallback(()=>{window.clearTimeout(y.current),y.current=window.setTimeout(()=>{w.current=!0,_(!0),y.current=0},x)},[x,_]);return b.useEffect(()=>()=>{y.current&&(window.clearTimeout(y.current),y.current=0)},[]),d.jsx(Kv,{...f,children:d.jsx(xce,{scope:t,contentId:g,open:S,stateAttribute:T,trigger:m,onTriggerChange:h,onTriggerEnter:b.useCallback(()=>{u.isOpenDelayedRef.current?k():A()},[u.isOpenDelayedRef,k,A]),onTriggerLeave:b.useCallback(()=>{E?R():(window.clearTimeout(y.current),y.current=0)},[R,E]),onOpen:A,onClose:R,disableHoverableContent:E,children:n})})};DH.displayName=dm;var d_="TooltipTrigger",LH=b.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,a=nh(d_,n),o=WN(d_,n),i=nw(n),l=b.useRef(null),u=gn(t,l,a.onTriggerChange),f=b.useRef(!1),m=b.useRef(!1),h=b.useCallback(()=>f.current=!1,[]);return b.useEffect(()=>()=>document.removeEventListener("pointerup",h),[h]),d.jsx(Xm,{asChild:!0,...i,children:d.jsx(Zt.button,{"aria-describedby":a.open?a.contentId:void 0,"data-state":a.stateAttribute,...r,ref:u,onPointerMove:ct(e.onPointerMove,g=>{g.pointerType!=="touch"&&!m.current&&!o.isPointerInTransitRef.current&&(a.onTriggerEnter(),m.current=!0)}),onPointerLeave:ct(e.onPointerLeave,()=>{a.onTriggerLeave(),m.current=!1}),onPointerDown:ct(e.onPointerDown,()=>{a.open&&a.onClose(),f.current=!0,document.addEventListener("pointerup",h,{once:!0})}),onFocus:ct(e.onFocus,()=>{f.current||a.onOpen()}),onBlur:ct(e.onBlur,a.onClose),onClick:ct(e.onClick,a.onClose)})})});LH.displayName=d_;var KN="TooltipPortal",[Ece,Sce]=tw(KN,{forceMount:void 0}),MH=e=>{const{__scopeTooltip:t,forceMount:n,children:r,container:a}=e,o=nh(KN,t);return d.jsx(Ece,{scope:t,forceMount:n,children:d.jsx(ao,{present:n||o.open,children:d.jsx(of,{asChild:!0,container:a,children:r})})})};MH.displayName=KN;var $d="TooltipContent",jH=b.forwardRef((e,t)=>{const n=Sce($d,e.__scopeTooltip),{forceMount:r=n.forceMount,side:a="top",...o}=e,i=nh($d,e.__scopeTooltip);return d.jsx(ao,{present:r||i.open,children:i.disableHoverableContent?d.jsx(PH,{side:a,...o,ref:t}):d.jsx(_ce,{side:a,...o,ref:t})})}),_ce=b.forwardRef((e,t)=>{const n=nh($d,e.__scopeTooltip),r=WN($d,e.__scopeTooltip),a=b.useRef(null),o=gn(t,a),[i,l]=b.useState(null),{trigger:u,onClose:f}=n,m=a.current,{onPointerInTransitChange:h}=r,g=b.useCallback(()=>{l(null),h(!1)},[h]),y=b.useCallback((E,x)=>{const w=E.currentTarget,S={x:E.clientX,y:E.clientY},_=Rce(S,w.getBoundingClientRect()),T=kce(S,_),A=Ace(x.getBoundingClientRect()),R=Oce([...T,...A]);l(R),h(!0)},[h]);return b.useEffect(()=>()=>g(),[g]),b.useEffect(()=>{if(u&&m){const E=w=>y(w,m),x=w=>y(w,u);return u.addEventListener("pointerleave",E),m.addEventListener("pointerleave",x),()=>{u.removeEventListener("pointerleave",E),m.removeEventListener("pointerleave",x)}}},[u,m,y,g]),b.useEffect(()=>{if(i){const E=x=>{const w=x.target,S={x:x.clientX,y:x.clientY},_=u?.contains(w)||m?.contains(w),T=!Ice(S,i);_?g():T&&(g(),f())};return document.addEventListener("pointermove",E),()=>document.removeEventListener("pointermove",E)}},[u,m,i,f,g]),d.jsx(PH,{...e,ref:o})}),[Tce,Nce]=tw(dm,{isInside:!1}),Cce=hoe("TooltipContent"),PH=b.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":a,onEscapeKeyDown:o,onPointerDownOutside:i,...l}=e,u=nh($d,n),f=nw(n),{onClose:m}=u;return b.useEffect(()=>(document.addEventListener(u_,m),()=>document.removeEventListener(u_,m)),[m]),b.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]),d.jsx(nf,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:o,onPointerDownOutside:i,onFocusOutside:h=>h.preventDefault(),onDismiss:m,children:d.jsxs(Yv,{"data-state":u.stateAttribute,...f,...l,ref:t,style:{...l.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:[d.jsx(Cce,{children:r}),d.jsx(Tce,{scope:n,isInside:!0,children:d.jsx(yce,{id:u.contentId,role:"tooltip",children:a||r})})]})})});jH.displayName=$d;var $H="TooltipArrow",UH=b.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,a=nw(n);return Nce($H,n).isInside?null:d.jsx(Zv,{...a,...r,ref:t})});UH.displayName=$H;function Rce(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),a=Math.abs(t.right-e.x),o=Math.abs(t.left-e.x);switch(Math.min(n,r,a,o)){case o:return"left";case a:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function kce(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function Ace(e){const{top:t,right:n,bottom:r,left:a}=e;return[{x:a,y:t},{x:n,y:t},{x:n,y:r},{x:a,y:r}]}function Ice(e,t){const{x:n,y:r}=e;let a=!1;for(let o=0,i=t.length-1;o<t.length;i=o++){const l=t[o],u=t[i],f=l.x,m=l.y,h=u.x,g=u.y;m>r!=g>r&&n<(h-f)*(r-m)/(g-m)+f&&(a=!a)}return a}function Oce(e){const t=e.slice();return t.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),Dce(t)}function Dce(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const a=e[r];for(;t.length>=2;){const o=t[t.length-1],i=t[t.length-2];if((o.x-i.x)*(a.y-i.y)>=(o.y-i.y)*(a.x-i.x))t.pop();else break}t.push(a)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const a=e[r];for(;n.length>=2;){const o=n[n.length-1],i=n[n.length-2];if((o.x-i.x)*(a.y-i.y)>=(o.y-i.y)*(a.x-i.x))n.pop();else break}n.push(a)}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 Lce=OH,Mce=DH,jce=LH,Pce=MH,$ce=jH,Uce=UH;function YN({delayDuration:e=0,...t}){return d.jsx(Lce,{"data-slot":"tooltip-provider",delayDuration:e,...t})}function Wt({...e}){return d.jsx(YN,{children:d.jsx(Mce,{"data-slot":"tooltip",...e})})}function Kt({...e}){return d.jsx(jce,{"data-slot":"tooltip-trigger",...e})}function Yt({className:e,sideOffset:t=0,children:n,...r}){return d.jsx(Pce,{children:d.jsxs($ce,{"data-slot":"tooltip-content",sideOffset:t,className:Fe("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),...r,children:[n,d.jsx(Uce,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}class zce{name="mcp_inspector_open";properties;constructor(t){this.properties={server_url:t.serverUrl,connection_count:t.connectionCount}}}class bU{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 yU{name="mcp_resource_read";properties;constructor(t){this.properties={resource_uri:t.resourceUri,server_id:t.serverId,success:t.success,error:t.error}}}class vU{name="mcp_prompt_call";properties;constructor(t){this.properties={prompt_name:t.promptName,server_id:t.serverId,success:t.success,error:t.error}}}class wU{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 Fce{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 Bce{name="mcp_command_palette_open";properties;constructor(t){this.properties={trigger:t.trigger}}}class Hce{name="mcp_tool_saved";properties;constructor(t){this.properties={tool_name:t.toolName,server_id:t.serverId}}}function jE(){try{return"0.15.1-canary.2"}catch{return"0.0.0"}}var Vce={};function PE(){try{return typeof window<"u"&&typeof document<"u"}catch{return!1}}class xU{endpoint;timeout;constructor(t,n=3e3){this.endpoint=t,this.timeout=n}async logEvent(t){try{const n=new AbortController,r=setTimeout(()=>n.abort(),this.timeout),a=await fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t),signal:n.signal});if(clearTimeout(r),!a.ok)throw new Error(`HTTP error! status: ${a.status}`)}catch{}}}function Pi(e){return`mcp_inspector_telemetry_${e}`}function yp(){return typeof localStorage<"u"&&typeof localStorage.getItem=="function"&&typeof localStorage.setItem=="function"}class ra{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=PE(),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 xU(this.POSTHOG_PROXY_URL,3e3)}catch{this._posthogClient=null}try{this._scarfClient=new xU(this.SCARF_PROXY_URL,3e3)}catch{this._scarfClient=null}}}isTelemetryDisabled(){return!!(yp()&&localStorage.getItem(Pi("disabled"))==="true"||typeof process<"u"&&Vce?.MCP_USE_ANONYMIZED_TELEMETRY==="false")}getStoredSource(){return yp()?localStorage.getItem(Pi("source")):null}static getInstance(){return ra.instance||(ra.instance=new ra),ra.instance}setSource(t){this._source=t,yp()&&localStorage.setItem(Pi("source"),t)}getSource(){return this._source}get userId(){if(this._currUserId)return this._currUserId;if(!PE())return this._currUserId=this.UNKNOWN_USER_ID,this._currUserId;try{if(!yp())throw new Error("localStorage is not available or not functional");const t=localStorage.getItem(Pi("user_id"));if(t)this._currUserId=t;else{const n=this.generateUserId();localStorage.setItem(Pi("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(){const t=window.crypto;if(t){const n=new Uint8Array(16);t.getRandomValues(n),n[6]=n[6]&15|64,n[8]=n[8]&63|128;const r=Array.from(n).map(a=>a.toString(16).padStart(2,"0")).join("");return r.slice(0,8)+"-"+r.slice(8,12)+"-"+r.slice(12,16)+"-"+r.slice(16,20)+"-"+r.slice(20,32)}else return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,n=>{const r=Math.random()*16|0;return(n==="x"?r:r&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:jE(),language:"typescript",source:this._source,package:"inspector"}};await this._posthogClient.logEvent(n)}catch{}if(this._scarfClient)try{const n={};n.mcp_use_version=jE(),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&&PE())try{if(!yp())throw new Error("localStorage is not available or not functional");const n=jE();let r=!1,a=!1;const o=localStorage.getItem(Pi("download_version"));if(o?n>o&&(r=!0,a=!1,localStorage.setItem(Pi("download_version"),n)):(r=!0,a=!0,localStorage.setItem(Pi("download_version"),n)),r){const i={...t||{}};i.mcp_use_version=n,i.user_id=this.userId,i.event="package_download",i.first_download=a,i.language="typescript",i.source=this._source,i.package="inspector",await this._scarfClient.logEvent(i)}}catch{}}async trackInspectorOpen(t){const n=new zce(t);await this.capture(n)}}const Gce=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Wce=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,r)=>r?r.toUpperCase():n.toLowerCase()),EU=e=>{const t=Wce(e);return t.charAt(0).toUpperCase()+t.slice(1)},zH=(...e)=>e.filter((t,n,r)=>!!t&&t.trim()!==""&&r.indexOf(t)===n).join(" ").trim(),Kce=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};var Yce={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 Zce=b.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:a="",children:o,iconNode:i,...l},u)=>b.createElement("svg",{ref:u,...Yce,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:zH("lucide",a),...!o&&!Kce(l)&&{"aria-hidden":"true"},...l},[...i.map(([f,m])=>b.createElement(f,m)),...Array.isArray(o)?o:[o]]));const ht=(e,t)=>{const n=b.forwardRef(({className:r,...a},o)=>b.createElement(Zce,{ref:o,iconNode:t,className:zH(`lucide-${Gce(EU(e))}`,`lucide-${e}`,r),...a}));return n.displayName=EU(e),n};const qce=[["path",{d:"M12 17V3",key:"1cwfxf"}],["path",{d:"m6 11 6 6 6-6",key:"12ii2o"}],["path",{d:"M19 21H5",key:"150jfl"}]],Xce=ht("arrow-down-to-line",qce);const Jce=[["path",{d:"m18 9-6-6-6 6",key:"kcunyi"}],["path",{d:"M12 3v14",key:"7cf3v8"}],["path",{d:"M5 21h14",key:"11awu3"}]],Qce=ht("arrow-up-from-line",Jce);const eue=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],tue=ht("arrow-up",eue);const nue=[["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"}]],ZN=ht("bell",nue);const rue=[["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"}]],FH=ht("brush",rue);const aue=[["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"}]],oue=ht("bug",aue);const sue=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Or=ht("check",sue);const iue=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],hs=ht("chevron-down",iue);const lue=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],rw=ht("chevron-left",lue);const cue=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],BH=ht("chevron-right",cue);const uue=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],due=ht("chevron-up",uue);const fue=[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]],pue=ht("chevrons-up-down",fue);const mue=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}]],SU=ht("circle-minus",mue);const hue=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],fm=ht("clock",hue);const gue=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],qN=ht("code",gue);const bue=[["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"}]],yue=ht("cog",bue);const vue=[["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"}]],wue=ht("command",vue);const xue=[["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"}]],wr=ht("copy",xue);const Eue=[["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"}]],aw=ht("database",Eue);const Sue=[["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"}]],rh=ht("download",Sue);const _ue=[["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"}]],Tue=ht("ellipsis-vertical",_ue);const Nue=[["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"}]],f_=ht("external-link",Nue);const Cue=[["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"}]],HH=ht("eye-off",Cue);const Rue=[["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"}]],p_=ht("eye",Rue);const kue=[["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"}]],Aue=ht("file-code",kue);const Iue=[["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"}]],Oue=ht("file-image",Iue);const Due=[["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"}]],XN=ht("file-text",Due);const Lue=[["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"}]],Mue=ht("file",Lue);const jue=[["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"}]],Pue=ht("folder-open",jue);const $ue=[["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"}]],Uue=ht("globe",$ue);const zue=[["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"}]],Fue=ht("grip-vertical",zue);const Bue=[["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"}]],VH=ht("hash",Bue);const Hue=[["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"}]],pm=ht("history",Hue);const Vue=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],Fp=ht("info",Vue);const Gue=[["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"}]],GH=ht("key",Gue);const Wue=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],cl=ht("loader-circle",Wue);const Kue=[["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"}]],JN=ht("maximize-2",Kue);const Yue=[["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"}]],mm=ht("maximize",Yue);const Zue=[["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"}]],que=ht("message-circle",Zue);const Xue=[["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"}]],hm=ht("message-square",Xue);const Jue=[["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"}]],WH=ht("minimize",Jue);const Que=[["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"}]],_U=ht("monitor",Que);const ede=[["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"}]],TU=ht("moon",ede);const tde=[["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"}]],nde=ht("picture-in-picture",tde);const rde=[["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"}]],KH=ht("play",rde);const ade=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],gm=ht("plus",ade);const ode=[["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"}]],NU=ht("rotate-ccw",ode);const sde=[["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"}]],QN=ht("save",sde);const ide=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],lf=ht("search",ide);const lde=[["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"}]],cde=ht("send",lde);const ude=[["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"}]],YH=ht("server",ude);const dde=[["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"}]],Ju=ht("settings",dde);const fde=[["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"}]],pde=ht("shield",fde);const mde=[["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"}]],hde=ht("sparkles",mde);const gde=[["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"}]],ZH=ht("square-check-big",gde);const bde=[["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"}]],yde=ht("square-pen",bde);const vde=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],wde=ht("square",vde);const xde=[["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"}]],CU=ht("sun-dim",xde);const Ede=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],$E=ht("terminal",Ede);const Sde=[["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"}]],ti=ht("trash-2",Sde);const _de=[["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"}]],Tde=ht("trash",_de);const Nde=[["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"}]],dc=ht("wrench",Nde);const Cde=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],ys=ht("x",Cde);const Rde=[["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"}]],bm=ht("zap",Rde);var qH=e=>{throw TypeError(e)},kde=(e,t,n)=>t.has(e)||qH("Cannot "+n),UE=(e,t,n)=>(kde(e,t,"read from private field"),n?n.call(e):t.get(e)),Ade=(e,t,n)=>t.has(e)?qH("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Ide=(e=>(e.Pop="POP",e.Push="PUSH",e.Replace="REPLACE",e))(Ide||{}),RU="popstate";function XH(e={}){let{initialEntries:t=["/"],initialIndex:n,v5Compat:r=!1}=e,a;a=t.map((y,E)=>m(y,typeof y=="string"?null:y.state,E===0?"default":void 0));let o=u(n??a.length-1),i="POP",l=null;function u(y){return Math.min(Math.max(y,0),a.length-1)}function f(){return a[o]}function m(y,E=null,x){let w=ni(a?f().pathname:"/",y,E,x);return Un(w.pathname.charAt(0)==="/",`relative pathnames are not supported in memory history: ${JSON.stringify(y)}`),w}function h(y){return typeof y=="string"?y:ga(y)}return{get index(){return o},get action(){return i},get location(){return f()},createHref:h,createURL(y){return new URL(h(y),"http://localhost")},encodeLocation(y){let E=typeof y=="string"?Ro(y):y;return{pathname:E.pathname||"",search:E.search||"",hash:E.hash||""}},push(y,E){i="PUSH";let x=m(y,E);o+=1,a.splice(o,a.length,x),r&&l&&l({action:i,location:x,delta:1})},replace(y,E){i="REPLACE";let x=m(y,E);a[o]=x,r&&l&&l({action:i,location:x,delta:0})},go(y){i="POP";let E=u(o+y),x=a[E];o=E,l&&l({action:i,location:x,delta:y})},listen(y){return l=y,()=>{l=null}}}}function JH(e={}){function t(r,a){let{pathname:o,search:i,hash:l}=r.location;return ni("",{pathname:o,search:i,hash:l},a.state&&a.state.usr||null,a.state&&a.state.key||"default")}function n(r,a){return typeof a=="string"?a:ga(a)}return eV(t,n,null,e)}function QH(e={}){function t(a,o){let{pathname:i="/",search:l="",hash:u=""}=Ro(a.location.hash.substring(1));return!i.startsWith("/")&&!i.startsWith(".")&&(i="/"+i),ni("",{pathname:i,search:l,hash:u},o.state&&o.state.usr||null,o.state&&o.state.key||"default")}function n(a,o){let i=a.document.querySelector("base"),l="";if(i&&i.getAttribute("href")){let u=a.location.href,f=u.indexOf("#");l=f===-1?u:u.slice(0,f)}return l+"#"+(typeof o=="string"?o:ga(o))}function r(a,o){Un(a.pathname.charAt(0)==="/",`relative pathnames are not supported in hash history.push(${JSON.stringify(o)})`)}return eV(t,n,r,e)}function Et(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function Un(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function Ode(){return Math.random().toString(36).substring(2,10)}function kU(e,t){return{usr:e.state,key:e.key,idx:t}}function ni(e,t,n=null,r){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?Ro(t):t,state:n,key:t&&t.key||r||Ode()}}function ga({pathname:e="/",search:t="",hash:n=""}){return t&&t!=="?"&&(e+=t.charAt(0)==="?"?t:"?"+t),n&&n!=="#"&&(e+=n.charAt(0)==="#"?n:"#"+n),e}function Ro(e){let t={};if(e){let n=e.indexOf("#");n>=0&&(t.hash=e.substring(n),e=e.substring(0,n));let r=e.indexOf("?");r>=0&&(t.search=e.substring(r),e=e.substring(0,r)),e&&(t.pathname=e)}return t}function eV(e,t,n,r={}){let{window:a=document.defaultView,v5Compat:o=!1}=r,i=a.history,l="POP",u=null,f=m();f==null&&(f=0,i.replaceState({...i.state,idx:f},""));function m(){return(i.state||{idx:null}).idx}function h(){l="POP";let w=m(),S=w==null?null:w-f;f=w,u&&u({action:l,location:x.location,delta:S})}function g(w,S){l="PUSH";let _=ni(x.location,w,S);n&&n(_,w),f=m()+1;let T=kU(_,f),A=x.createHref(_);try{i.pushState(T,"",A)}catch(R){if(R instanceof DOMException&&R.name==="DataCloneError")throw R;a.location.assign(A)}o&&u&&u({action:l,location:x.location,delta:1})}function y(w,S){l="REPLACE";let _=ni(x.location,w,S);n&&n(_,w),f=m();let T=kU(_,f),A=x.createHref(_);i.replaceState(T,"",A),o&&u&&u({action:l,location:x.location,delta:0})}function E(w){return tV(w)}let x={get action(){return l},get location(){return e(a,i)},listen(w){if(u)throw new Error("A history only accepts one active listener");return a.addEventListener(RU,h),u=w,()=>{a.removeEventListener(RU,h),u=null}},createHref(w){return t(a,w)},createURL:E,encodeLocation(w){let S=E(w);return{pathname:S.pathname,search:S.search,hash:S.hash}},push:g,replace:y,go(w){return i.go(w)}};return x}function tV(e,t=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),Et(n,"No window.location.(origin|href) available to create URL");let r=typeof e=="string"?e:ga(e);return r=r.replace(/ $/,"%20"),!t&&r.startsWith("//")&&(r=n+r),new URL(r,n)}function VTe(e){return{defaultValue:e}}var kp,ju=class{constructor(e){if(Ade(this,kp,new Map),e)for(let[t,n]of e)this.set(t,n)}get(e){if(UE(this,kp).has(e))return UE(this,kp).get(e);if(e.defaultValue!==void 0)return e.defaultValue;throw new Error("No value found for context")}set(e,t){UE(this,kp).set(e,t)}};kp=new WeakMap;var Dde=new Set(["lazy","caseSensitive","path","id","index","children"]);function Lde(e){return Dde.has(e)}var Mde=new Set(["lazy","caseSensitive","path","id","index","middleware","children"]);function jde(e){return Mde.has(e)}function Pde(e){return e.index===!0}function fc(e,t,n=[],r={},a=!1){return e.map((o,i)=>{let l=[...n,String(i)],u=typeof o.id=="string"?o.id:l.join("-");if(Et(o.index!==!0||!o.children,"Cannot specify children on an index route"),Et(a||!r[u],`Found a route id collision on id "${u}". Route id's must be globally unique within Data Router usages`),Pde(o)){let f={...o,id:u};return r[u]=AU(f,t(f)),f}else{let f={...o,id:u,children:void 0};return r[u]=AU(f,t(f)),o.children&&(f.children=fc(o.children,t,l,r,a)),f}})}function AU(e,t){return Object.assign(e,{...t,...typeof t.lazy=="object"&&t.lazy!=null?{lazy:{...e.lazy,...t.lazy}}:{}})}function Uo(e,t,n="/"){return Ap(e,t,n,!1)}function Ap(e,t,n,r){let a=typeof t=="string"?Ro(t):t,o=Na(a.pathname||"/",n);if(o==null)return null;let i=rV(e);$de(i);let l=null;for(let u=0;l==null&&u<i.length;++u){let f=sV(o);l=Kde(i[u],f,r)}return l}function nV(e,t){let{route:n,pathname:r,params:a}=e;return{id:n.id,pathname:r,params:a,data:t[n.id],loaderData:t[n.id],handle:n.handle}}function rV(e,t=[],n=[],r="",a=!1){let o=(i,l,u=a,f)=>{let m={relativePath:f===void 0?i.path||"":f,caseSensitive:i.caseSensitive===!0,childrenIndex:l,route:i};if(m.relativePath.startsWith("/")){if(!m.relativePath.startsWith(r)&&u)return;Et(m.relativePath.startsWith(r),`Absolute route path "${m.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),m.relativePath=m.relativePath.slice(r.length)}let h=is([r,m.relativePath]),g=n.concat(m);i.children&&i.children.length>0&&(Et(i.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${h}".`),rV(i.children,t,g,h,u)),!(i.path==null&&!i.index)&&t.push({path:h,score:Gde(h,i.index),routesMeta:g})};return e.forEach((i,l)=>{if(i.path===""||!i.path?.includes("?"))o(i,l);else for(let u of aV(i.path))o(i,l,!0,u)}),t}function aV(e){let t=e.split("/");if(t.length===0)return[];let[n,...r]=t,a=n.endsWith("?"),o=n.replace(/\?$/,"");if(r.length===0)return a?[o,""]:[o];let i=aV(r.join("/")),l=[];return l.push(...i.map(u=>u===""?o:[o,u].join("/"))),a&&l.push(...i),l.map(u=>e.startsWith("/")&&u===""?"/":u)}function $de(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:Wde(t.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}var Ude=/^:[\w-]+$/,zde=3,Fde=2,Bde=1,Hde=10,Vde=-2,IU=e=>e==="*";function Gde(e,t){let n=e.split("/"),r=n.length;return n.some(IU)&&(r+=Vde),t&&(r+=Fde),n.filter(a=>!IU(a)).reduce((a,o)=>a+(Ude.test(o)?zde:o===""?Bde:Hde),r)}function Wde(e,t){return e.length===t.length&&e.slice(0,-1).every((r,a)=>r===t[a])?e[e.length-1]-t[t.length-1]:0}function Kde(e,t,n=!1){let{routesMeta:r}=e,a={},o="/",i=[];for(let l=0;l<r.length;++l){let u=r[l],f=l===r.length-1,m=o==="/"?t:t.slice(o.length)||"/",h=ym({path:u.relativePath,caseSensitive:u.caseSensitive,end:f},m),g=u.route;if(!h&&f&&n&&!r[r.length-1].route.index&&(h=ym({path:u.relativePath,caseSensitive:u.caseSensitive,end:!1},m)),!h)return null;Object.assign(a,h.params),i.push({params:a,pathname:is([o,h.pathname]),pathnameBase:qde(is([o,h.pathnameBase])),route:g}),h.pathnameBase!=="/"&&(o=is([o,h.pathnameBase]))}return i}function GTe(e,t={}){let n=e;n.endsWith("*")&&n!=="*"&&!n.endsWith("/*")&&(Un(!1,`Route path "${n}" will be treated as if it were "${n.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${n.replace(/\*$/,"/*")}".`),n=n.replace(/\*$/,"/*"));const r=n.startsWith("/")?"/":"",a=i=>i==null?"":typeof i=="string"?i:String(i),o=n.split(/\/+/).map((i,l,u)=>{if(l===u.length-1&&i==="*")return a(t["*"]);const m=i.match(/^:([\w-]+)(\??)(.*)/);if(m){const[,h,g,y]=m;let E=t[h];return Et(g==="?"||E!=null,`Missing ":${h}" param`),encodeURIComponent(a(E))+y}return i.replace(/\?$/g,"")}).filter(i=>!!i);return r+o.join("/")}function ym(e,t){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[n,r]=oV(e.path,e.caseSensitive,e.end),a=t.match(n);if(!a)return null;let o=a[0],i=o.replace(/(.)\/+$/,"$1"),l=a.slice(1);return{params:r.reduce((f,{paramName:m,isOptional:h},g)=>{if(m==="*"){let E=l[g]||"";i=o.slice(0,o.length-E.length).replace(/(.)\/+$/,"$1")}const y=l[g];return h&&!y?f[m]=void 0:f[m]=(y||"").replace(/%2F/g,"/"),f},{}),pathname:o,pathnameBase:i,pattern:e}}function oV(e,t=!1,n=!0){Un(e==="*"||!e.endsWith("*")||e.endsWith("/*"),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,"/*")}".`);let r=[],a="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(i,l,u)=>(r.push({paramName:l,isOptional:u!=null}),u?"/?([^\\/]+)?":"/([^\\/]+)")).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return e.endsWith("*")?(r.push({paramName:"*"}),a+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?a+="\\/*$":e!==""&&e!=="/"&&(a+="(?:(?=\\/|$))"),[new RegExp(a,t?void 0:"i"),r]}function sV(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return Un(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`),e}}function Na(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith("/")?t.length-1:t.length,r=e.charAt(n);return r&&r!=="/"?null:e.slice(n)||"/"}function Yde({basename:e,pathname:t}){return t==="/"?e:is([e,t])}var iV=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,ow=e=>iV.test(e);function Zde(e,t="/"){let{pathname:n,search:r="",hash:a=""}=typeof e=="string"?Ro(e):e,o;if(n)if(ow(n))o=n;else{if(n.includes("//")){let i=n;n=n.replace(/\/\/+/g,"/"),Un(!1,`Pathnames cannot have embedded double slashes - normalizing ${i} -> ${n}`)}n.startsWith("/")?o=OU(n.substring(1),"/"):o=OU(n,t)}else o=t;return{pathname:o,search:Xde(r),hash:Jde(a)}}function OU(e,t){let n=t.replace(/\/+$/,"").split("/");return e.split("/").forEach(a=>{a===".."?n.length>1&&n.pop():a!=="."&&n.push(a)}),n.length>1?n.join("/"):"/"}function zE(e,t,n,r){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(r)}]. Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function lV(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function sw(e){let t=lV(e);return t.map((n,r)=>r===t.length-1?n.pathname:n.pathnameBase)}function iw(e,t,n,r=!1){let a;typeof e=="string"?a=Ro(e):(a={...e},Et(!a.pathname||!a.pathname.includes("?"),zE("?","pathname","search",a)),Et(!a.pathname||!a.pathname.includes("#"),zE("#","pathname","hash",a)),Et(!a.search||!a.search.includes("#"),zE("#","search","hash",a)));let o=e===""||a.pathname==="",i=o?"/":a.pathname,l;if(i==null)l=n;else{let h=t.length-1;if(!r&&i.startsWith("..")){let g=i.split("/");for(;g[0]==="..";)g.shift(),h-=1;a.pathname=g.join("/")}l=h>=0?t[h]:"/"}let u=Zde(a,l),f=i&&i!=="/"&&i.endsWith("/"),m=(o||i===".")&&n.endsWith("/");return!u.pathname.endsWith("/")&&(f||m)&&(u.pathname+="/"),u}var is=e=>e.join("/").replace(/\/\/+/g,"/"),qde=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),Xde=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,Jde=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e,Qde=class{constructor(e,t){this.type="DataWithResponseInit",this.data=e,this.init=t||null}};function efe(e,t){return new Qde(e,typeof t=="number"?{status:t}:t)}var eC=(e,t=302)=>{let n=t;typeof n=="number"?n={status:n}:typeof n.status>"u"&&(n.status=302);let r=new Headers(n.headers);return r.set("Location",e),new Response(null,{...n,headers:r})},WTe=(e,t)=>{let n=eC(e,t);return n.headers.set("X-Remix-Reload-Document","true"),n},KTe=(e,t)=>{let n=eC(e,t);return n.headers.set("X-Remix-Replace","true"),n},vs=class{constructor(e,t,n,r=!1){this.status=e,this.statusText=t||"",this.internal=r,n instanceof Error?(this.data=n.toString(),this.error=n):this.data=n}};function So(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function Ks(e){return e.map(t=>t.route.path).filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}var cV=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function uV(e,t){let n=e;if(typeof n!="string"||!iV.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,a=!1;if(cV)try{let o=new URL(window.location.href),i=n.startsWith("//")?new URL(o.protocol+n):new URL(n),l=Na(i.pathname,t);i.origin===o.origin&&l!=null?n=l+i.search+i.hash:a=!0}catch{Un(!1,`<Link to="${n}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:r,isExternal:a,to:n}}var qi=Symbol("Uninstrumented");function dV(e,t){let n={lazy:[],"lazy.loader":[],"lazy.action":[],"lazy.middleware":[],middleware:[],loader:[],action:[]};e.forEach(a=>a({id:t.id,index:t.index,path:t.path,instrument(o){let i=Object.keys(n);for(let l of i)o[l]&&n[l].push(o[l])}}));let r={};if(typeof t.lazy=="function"&&n.lazy.length>0){let a=Ql(n.lazy,t.lazy,()=>{});a&&(r.lazy=a)}if(typeof t.lazy=="object"){let a=t.lazy;["middleware","loader","action"].forEach(o=>{let i=a[o],l=n[`lazy.${o}`];if(typeof i=="function"&&l.length>0){let u=Ql(l,i,()=>{});u&&(r.lazy=Object.assign(r.lazy||{},{[o]:u}))}})}return["loader","action"].forEach(a=>{let o=t[a];if(typeof o=="function"&&n[a].length>0){let i=o[qi]??o,l=Ql(n[a],i,(...u)=>DU(u[0]));l&&(a==="loader"&&i.hydrate===!0&&(l.hydrate=!0),l[qi]=i,r[a]=l)}}),t.middleware&&t.middleware.length>0&&n.middleware.length>0&&(r.middleware=t.middleware.map(a=>{let o=a[qi]??a,i=Ql(n.middleware,o,(...l)=>DU(l[0]));return i?(i[qi]=o,i):a})),r}function tfe(e,t){let n={navigate:[],fetch:[]};if(t.forEach(r=>r({instrument(a){let o=Object.keys(a);for(let i of o)a[i]&&n[i].push(a[i])}})),n.navigate.length>0){let r=e.navigate[qi]??e.navigate,a=Ql(n.navigate,r,(...o)=>{let[i,l]=o;return{to:typeof i=="number"||typeof i=="string"?i:i?ga(i):".",...LU(e,l??{})}});a&&(a[qi]=r,e.navigate=a)}if(n.fetch.length>0){let r=e.fetch[qi]??e.fetch,a=Ql(n.fetch,r,(...o)=>{let[i,,l,u]=o;return{href:l??".",fetcherKey:i,...LU(e,u??{})}});a&&(a[qi]=r,e.fetch=a)}return e}function YTe(e,t){let n={request:[]};t.forEach(a=>a({instrument(o){let i=Object.keys(o);for(let l of i)o[l]&&n[l].push(o[l])}}));let r=e;return n.request.length>0&&(r=Ql(n.request,e,(...a)=>{let[o,i]=a;return{request:pV(o),context:i!=null?mV(i):i}})),r}function Ql(e,t,n){return e.length===0?null:async(...r)=>{let a=await fV(e,n(...r),()=>t(...r),e.length-1);if(a.type==="error")throw a.value;return a.value}}async function fV(e,t,n,r){let a=e[r],o;if(a){let i,l=async()=>(i?console.error("You cannot call instrumented handlers more than once"):i=fV(e,t,n,r-1),o=await i,Et(o,"Expected a result"),o.type==="error"&&o.value instanceof Error?{status:"error",error:o.value}:{status:"success",error:void 0});try{await a(l,t)}catch(u){console.error("An instrumentation function threw an error:",u)}i||await l(),await i}else try{o={type:"success",value:await n()}}catch(i){o={type:"error",value:i}}return o||{type:"error",value:new Error("No result assigned in instrumentation chain.")}}function DU(e){let{request:t,context:n,params:r,unstable_pattern:a}=e;return{request:pV(t),params:{...r},unstable_pattern:a,context:mV(n)}}function LU(e,t){return{currentUrl:ga(e.state.location),..."formMethod"in t?{formMethod:t.formMethod}:{},..."formEncType"in t?{formEncType:t.formEncType}:{},..."formData"in t?{formData:t.formData}:{},..."body"in t?{body:t.body}:{}}}function pV(e){return{method:e.method,url:e.url,headers:{get:(...t)=>e.headers.get(...t)}}}function mV(e){if(rfe(e)){let t={...e};return Object.freeze(t),t}else return{get:t=>e.get(t)}}var nfe=Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function rfe(e){if(e===null||typeof e!="object")return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||t===null||Object.getOwnPropertyNames(t).sort().join("\0")===nfe}var hV=["POST","PUT","PATCH","DELETE"],afe=new Set(hV),ofe=["GET",...hV],sfe=new Set(ofe),gV=new Set([301,302,303,307,308]),ife=new Set([307,308]),iy={state:"idle",location:void 0,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0},tC={state:"idle",data:void 0,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0},ql={state:"unblocked",proceed:void 0,reset:void 0,location:void 0},bV=e=>({hasErrorBoundary:!!e.hasErrorBoundary}),yV="remix-router-transitions",vV=Symbol("ResetLoaderData");function nC(e){const t=e.window?e.window:typeof window<"u"?window:void 0,n=typeof t<"u"&&typeof t.document<"u"&&typeof t.document.createElement<"u";Et(e.routes.length>0,"You must provide a non-empty routes array to createRouter");let r=e.hydrationRouteProperties||[],a=e.mapRouteProperties||bV,o=a;if(e.unstable_instrumentations){let se=e.unstable_instrumentations;o=de=>({...a(de),...dV(se.map(ye=>ye.route).filter(Boolean),de)})}let i={},l=fc(e.routes,o,void 0,i),u,f=e.basename||"/";f.startsWith("/")||(f=`/${f}`);let m=e.dataStrategy||hfe,h={...e.future},g=null,y=new Set,E=null,x=null,w=null,S=e.hydrationData!=null,_=Uo(l,e.history.location,f),T=!1,A=null,R;if(_==null&&!e.patchRoutesOnNavigation){let se=Ar(404,{pathname:e.history.location.pathname}),{matches:de,route:ye}=Pu(l);R=!0,_=de,A={[ye.id]:se}}else if(_&&!e.hydrationData&&zt(_,l,e.history.location.pathname).active&&(_=null),_)if(_.some(se=>se.route.lazy))R=!1;else if(!_.some(se=>rC(se.route)))R=!0;else{let se=e.hydrationData?e.hydrationData.loaderData:null,de=e.hydrationData?e.hydrationData.errors:null;if(de){let ye=_.findIndex(ke=>de[ke.route.id]!==void 0);R=_.slice(0,ye+1).every(ke=>!h_(ke.route,se,de))}else R=_.every(ye=>!h_(ye.route,se,de))}else{R=!1,_=[];let se=zt(null,l,e.history.location.pathname);se.active&&se.matches&&(T=!0,_=se.matches)}let k,C={historyAction:e.history.action,location:e.history.location,matches:_,initialized:R,navigation:iy,restoreScrollPosition:e.hydrationData!=null?!1:null,preventScrollReset:!1,revalidation:"idle",loaderData:e.hydrationData&&e.hydrationData.loaderData||{},actionData:e.hydrationData&&e.hydrationData.actionData||null,errors:e.hydrationData&&e.hydrationData.errors||A,fetchers:new Map,blockers:new Map},O="POP",M=null,L=!1,$,H=!1,V=new Map,Z=null,ne=!1,G=!1,Y=new Set,F=new Map,re=0,ee=-1,j=new Map,B=new Set,z=new Map,D=new Map,P=new Set,W=new Map,K,ae=null;function oe(){if(g=e.history.listen(({action:se,location:de,delta:ye})=>{if(K){K(),K=void 0;return}Un(W.size===0||ye!=null,"You are trying to use a blocker on a POP navigation to a location that was not created by @remix-run/router. This will fail silently in production. This can happen if you are navigating outside the router via `window.history.pushState`/`window.location.hash` instead of using router navigation APIs. This can also happen if you are using createHashRouter and the user manually changes the URL.");let ke=$t({currentLocation:C.location,nextLocation:de,historyAction:se});if(ke&&ye!=null){let ge=new Promise(Ce=>{K=Ce});e.history.go(ye*-1),Pt(ke,{state:"blocked",location:de,proceed(){Pt(ke,{state:"proceeding",proceed:void 0,reset:void 0,location:de}),ge.then(()=>e.history.go(ye))},reset(){let Ce=new Map(C.blockers);Ce.set(ke,ql),J({blockers:Ce})}}),M?.resolve(),M=null;return}return Ne(se,de)}),n){Efe(t,V);let se=()=>Sfe(t,V);t.addEventListener("pagehide",se),Z=()=>t.removeEventListener("pagehide",se)}return C.initialized||Ne("POP",C.location,{initialHydration:!0}),k}function le(){g&&g(),Z&&Z(),y.clear(),$&&$.abort(),C.fetchers.forEach((se,de)=>ot(de)),C.blockers.forEach((se,de)=>Ct(de))}function Q(se){return y.add(se),()=>y.delete(se)}function J(se,de={}){se.matches&&(se.matches=se.matches.map(ge=>{let Ce=i[ge.route.id],Te=ge.route;return Te.element!==Ce.element||Te.errorElement!==Ce.errorElement||Te.hydrateFallbackElement!==Ce.hydrateFallbackElement?{...ge,route:Ce}:ge})),C={...C,...se};let ye=[],ke=[];C.fetchers.forEach((ge,Ce)=>{ge.state==="idle"&&(P.has(Ce)?ye.push(Ce):ke.push(Ce))}),P.forEach(ge=>{!C.fetchers.has(ge)&&!F.has(ge)&&ye.push(ge)}),[...y].forEach(ge=>ge(C,{deletedFetchers:ye,newErrors:se.errors??null,viewTransitionOpts:de.viewTransitionOpts,flushSync:de.flushSync===!0})),ye.forEach(ge=>ot(ge)),ke.forEach(ge=>C.fetchers.delete(ge))}function q(se,de,{flushSync:ye}={}){let ke=C.actionData!=null&&C.navigation.formMethod!=null&&Zr(C.navigation.formMethod)&&C.navigation.state==="loading"&&se.state?._isRedirect!==!0,ge;de.actionData?Object.keys(de.actionData).length>0?ge=de.actionData:ge=null:ke?ge=C.actionData:ge=null;let Ce=de.loaderData?WU(C.loaderData,de.loaderData,de.matches||[],de.errors):C.loaderData,Te=C.blockers;Te.size>0&&(Te=new Map(Te),Te.forEach((Je,Qe)=>Te.set(Qe,ql)));let Ae=ne?!1:Ht(se,de.matches||C.matches),$e=L===!0||C.navigation.formMethod!=null&&Zr(C.navigation.formMethod)&&se.state?._isRedirect!==!0;u&&(l=u,u=void 0),ne||O==="POP"||(O==="PUSH"?e.history.push(se,se.state):O==="REPLACE"&&e.history.replace(se,se.state));let Xe;if(O==="POP"){let Je=V.get(C.location.pathname);Je&&Je.has(se.pathname)?Xe={currentLocation:C.location,nextLocation:se}:V.has(se.pathname)&&(Xe={currentLocation:se,nextLocation:C.location})}else if(H){let Je=V.get(C.location.pathname);Je?Je.add(se.pathname):(Je=new Set([se.pathname]),V.set(C.location.pathname,Je)),Xe={currentLocation:C.location,nextLocation:se}}J({...de,actionData:ge,loaderData:Ce,historyAction:O,location:se,initialized:!0,navigation:iy,revalidation:"idle",restoreScrollPosition:Ae,preventScrollReset:$e,blockers:Te},{viewTransitionOpts:Xe,flushSync:ye===!0}),O="POP",L=!1,H=!1,ne=!1,G=!1,M?.resolve(),M=null,ae?.resolve(),ae=null}async function ie(se,de){if(M?.resolve(),M=null,typeof se=="number"){M||(M=ZU());let tt=M.promise;return e.history.go(se),tt}let ye=m_(C.location,C.matches,f,se,de?.fromRouteId,de?.relative),{path:ke,submission:ge,error:Ce}=jU(!1,ye,de),Te=C.location,Ae=ni(C.location,ke,de&&de.state);Ae={...Ae,...e.history.encodeLocation(Ae)};let $e=de&&de.replace!=null?de.replace:void 0,Xe="PUSH";$e===!0?Xe="REPLACE":$e===!1||ge!=null&&Zr(ge.formMethod)&&ge.formAction===C.location.pathname+C.location.search&&(Xe="REPLACE");let Je=de&&"preventScrollReset"in de?de.preventScrollReset===!0:void 0,Qe=(de&&de.flushSync)===!0,Mt=$t({currentLocation:Te,nextLocation:Ae,historyAction:Xe});if(Mt){Pt(Mt,{state:"blocked",location:Ae,proceed(){Pt(Mt,{state:"proceeding",proceed:void 0,reset:void 0,location:Ae}),ie(se,de)},reset(){let tt=new Map(C.blockers);tt.set(Mt,ql),J({blockers:tt})}});return}await Ne(Xe,Ae,{submission:ge,pendingError:Ce,preventScrollReset:Je,replace:de&&de.replace,enableViewTransition:de&&de.viewTransition,flushSync:Qe,callSiteDefaultShouldRevalidate:de&&de.unstable_defaultShouldRevalidate})}function he(){ae||(ae=ZU()),it(),J({revalidation:"loading"});let se=ae.promise;return C.navigation.state==="submitting"?se:C.navigation.state==="idle"?(Ne(C.historyAction,C.location,{startUninterruptedRevalidation:!0}),se):(Ne(O||C.historyAction,C.navigation.location,{overrideNavigation:C.navigation,enableViewTransition:H===!0}),se)}async function Ne(se,de,ye){$&&$.abort(),$=null,O=se,ne=(ye&&ye.startUninterruptedRevalidation)===!0,Ut(C.location,C.matches),L=(ye&&ye.preventScrollReset)===!0,H=(ye&&ye.enableViewTransition)===!0;let ke=u||l,ge=ye&&ye.overrideNavigation,Ce=ye?.initialHydration&&C.matches&&C.matches.length>0&&!T?C.matches:Uo(ke,de,f),Te=(ye&&ye.flushSync)===!0;if(Ce&&C.initialized&&!G&&bfe(C.location,de)&&!(ye&&ye.submission&&Zr(ye.submission.formMethod))){q(de,{matches:Ce},{flushSync:Te});return}let Ae=zt(Ce,ke,de.pathname);if(Ae.active&&Ae.matches&&(Ce=Ae.matches),!Ce){let{error:Rt,notFoundMatches:et,route:Ke}=Xt(de.pathname);q(de,{matches:et,loaderData:{},errors:{[Ke.id]:Rt}},{flushSync:Te});return}$=new AbortController;let $e=Su(e.history,de,$.signal,ye&&ye.submission),Xe=e.getContext?await e.getContext():new ju,Je;if(ye&&ye.pendingError)Je=[wo(Ce).route.id,{type:"error",error:ye.pendingError}];else if(ye&&ye.submission&&Zr(ye.submission.formMethod)){let Rt=await Ye($e,de,ye.submission,Ce,Xe,Ae.active,ye&&ye.initialHydration===!0,{replace:ye.replace,flushSync:Te});if(Rt.shortCircuited)return;if(Rt.pendingActionResult){let[et,Ke]=Rt.pendingActionResult;if(zr(Ke)&&So(Ke.error)&&Ke.error.status===404){$=null,q(de,{matches:Rt.matches,loaderData:{},errors:{[et]:Ke.error}});return}}Ce=Rt.matches||Ce,Je=Rt.pendingActionResult,ge=FE(de,ye.submission),Te=!1,Ae.active=!1,$e=Su(e.history,$e.url,$e.signal)}let{shortCircuited:Qe,matches:Mt,loaderData:tt,errors:xt}=await Pe($e,de,Ce,Xe,Ae.active,ge,ye&&ye.submission,ye&&ye.fetcherSubmission,ye&&ye.replace,ye&&ye.initialHydration===!0,Te,Je,ye&&ye.callSiteDefaultShouldRevalidate);Qe||($=null,q(de,{matches:Mt||Ce,...KU(Je),loaderData:tt,errors:xt}))}async function Ye(se,de,ye,ke,ge,Ce,Te,Ae={}){it();let $e=wfe(de,ye);if(J({navigation:$e},{flushSync:Ae.flushSync===!0}),Ce){let Qe=await Ln(ke,de.pathname,se.signal);if(Qe.type==="aborted")return{shortCircuited:!0};if(Qe.type==="error"){if(Qe.partialMatches.length===0){let{matches:tt,route:xt}=Pu(l);return{matches:tt,pendingActionResult:[xt.id,{type:"error",error:Qe.error}]}}let Mt=wo(Qe.partialMatches).route.id;return{matches:Qe.partialMatches,pendingActionResult:[Mt,{type:"error",error:Qe.error}]}}else if(Qe.matches)ke=Qe.matches;else{let{notFoundMatches:Mt,error:tt,route:xt}=Xt(de.pathname);return{matches:Mt,pendingActionResult:[xt.id,{type:"error",error:tt}]}}}let Xe,Je=Qu(ke,de);if(!Je.route.action&&!Je.route.lazy)Xe={type:"error",error:Ar(405,{method:se.method,pathname:de.pathname,routeId:Je.route.id})};else{let Qe=el(o,i,se,ke,Je,Te?[]:r,ge),Mt=await _e(se,Qe,ge,null);if(Xe=Mt[Je.route.id],!Xe){for(let tt of ke)if(Mt[tt.route.id]){Xe=Mt[tt.route.id];break}}if(se.signal.aborted)return{shortCircuited:!0}}if(Xi(Xe)){let Qe;return Ae&&Ae.replace!=null?Qe=Ae.replace:Qe=HU(Xe.response.headers.get("Location"),new URL(se.url),f,e.history)===C.location.pathname+C.location.search,await Ee(se,Xe,!0,{submission:ye,replace:Qe}),{shortCircuited:!0}}if(zr(Xe)){let Qe=wo(ke,Je.route.id);return(Ae&&Ae.replace)!==!0&&(O="PUSH"),{matches:ke,pendingActionResult:[Qe.route.id,Xe,Je.route.id]}}return{matches:ke,pendingActionResult:[Je.route.id,Xe]}}async function Pe(se,de,ye,ke,ge,Ce,Te,Ae,$e,Xe,Je,Qe,Mt){let tt=Ce||FE(de,Te),xt=Te||Ae||YU(tt),Rt=!ne&&!Xe;if(ge){if(Rt){let kt=Ue(Qe);J({navigation:tt,...kt!==void 0?{actionData:kt}:{}},{flushSync:Je})}let Ft=await Ln(ye,de.pathname,se.signal);if(Ft.type==="aborted")return{shortCircuited:!0};if(Ft.type==="error"){if(Ft.partialMatches.length===0){let{matches:xr,route:Wn}=Pu(l);return{matches:xr,loaderData:{},errors:{[Wn.id]:Ft.error}}}let kt=wo(Ft.partialMatches).route.id;return{matches:Ft.partialMatches,loaderData:{},errors:{[kt]:Ft.error}}}else if(Ft.matches)ye=Ft.matches;else{let{error:kt,notFoundMatches:xr,route:Wn}=Xt(de.pathname);return{matches:xr,loaderData:{},errors:{[Wn.id]:kt}}}}let et=u||l,{dsMatches:Ke,revalidatingFetchers:St}=PU(se,ke,o,i,e.history,C,ye,xt,de,Xe?[]:r,Xe===!0,G,Y,P,z,B,et,f,e.patchRoutesOnNavigation!=null,Qe,Mt);if(ee=++re,!e.dataStrategy&&!Ke.some(Ft=>Ft.shouldLoad)&&!Ke.some(Ft=>Ft.route.middleware&&Ft.route.middleware.length>0)&&St.length===0){let Ft=We();return q(de,{matches:ye,loaderData:{},errors:Qe&&zr(Qe[1])?{[Qe[0]]:Qe[1].error}:null,...KU(Qe),...Ft?{fetchers:new Map(C.fetchers)}:{}},{flushSync:Je}),{shortCircuited:!0}}if(Rt){let Ft={};if(!ge){Ft.navigation=tt;let kt=Ue(Qe);kt!==void 0&&(Ft.actionData=kt)}St.length>0&&(Ft.fetchers=st(St)),J(Ft,{flushSync:Je})}St.forEach(Ft=>{qt(Ft.key),Ft.controller&&F.set(Ft.key,Ft.controller)});let En=()=>St.forEach(Ft=>qt(Ft.key));$&&$.signal.addEventListener("abort",En);let{loaderResults:gt,fetcherResults:Fn}=await Be(Ke,St,se,ke);if(se.signal.aborted)return{shortCircuited:!0};$&&$.signal.removeEventListener("abort",En),St.forEach(Ft=>F.delete(Ft.key));let _t=Ob(gt);if(_t)return await Ee(se,_t.result,!0,{replace:$e}),{shortCircuited:!0};if(_t=Ob(Fn),_t)return B.add(_t.key),await Ee(se,_t.result,!0,{replace:$e}),{shortCircuited:!0};let{loaderData:Cn,errors:en}=GU(C,ye,gt,Qe,St,Fn);Xe&&C.errors&&(en={...C.errors,...en});let bn=We(),Xn=fe(ee),cr=bn||Xn||St.length>0;return{matches:ye,loaderData:Cn,errors:en,...cr?{fetchers:new Map(C.fetchers)}:{}}}function Ue(se){if(se&&!zr(se[1]))return{[se[0]]:se[1].data};if(C.actionData)return Object.keys(C.actionData).length===0?null:C.actionData}function st(se){return se.forEach(de=>{let ye=C.fetchers.get(de.key),ke=vp(void 0,ye?ye.data:void 0);C.fetchers.set(de.key,ke)}),new Map(C.fetchers)}async function Ve(se,de,ye,ke){qt(se);let ge=(ke&&ke.flushSync)===!0,Ce=u||l,Te=m_(C.location,C.matches,f,ye,de,ke?.relative),Ae=Uo(Ce,Te,f),$e=zt(Ae,Ce,Te);if($e.active&&$e.matches&&(Ae=$e.matches),!Ae){lt(se,de,Ar(404,{pathname:Te}),{flushSync:ge});return}let{path:Xe,submission:Je,error:Qe}=jU(!0,Te,ke);if(Qe){lt(se,de,Qe,{flushSync:ge});return}let Mt=e.getContext?await e.getContext():new ju,tt=(ke&&ke.preventScrollReset)===!0;if(Je&&Zr(Je.formMethod)){await ut(se,de,Xe,Ae,Mt,$e.active,ge,tt,Je,ke&&ke.unstable_defaultShouldRevalidate);return}z.set(se,{routeId:de,path:Xe}),await rt(se,de,Xe,Ae,Mt,$e.active,ge,tt,Je)}async function ut(se,de,ye,ke,ge,Ce,Te,Ae,$e,Xe){it(),z.delete(se);let Je=C.fetchers.get(se);qe(se,xfe($e,Je),{flushSync:Te});let Qe=new AbortController,Mt=Su(e.history,ye,Qe.signal,$e);if(Ce){let nn=await Ln(ke,new URL(Mt.url).pathname,Mt.signal,se);if(nn.type==="aborted")return;if(nn.type==="error"){lt(se,de,nn.error,{flushSync:Te});return}else if(nn.matches)ke=nn.matches;else{lt(se,de,Ar(404,{pathname:ye}),{flushSync:Te});return}}let tt=Qu(ke,ye);if(!tt.route.action&&!tt.route.lazy){let nn=Ar(405,{method:$e.formMethod,pathname:ye,routeId:de});lt(se,de,nn,{flushSync:Te});return}F.set(se,Qe);let xt=re,Rt=el(o,i,Mt,ke,tt,r,ge),et=await _e(Mt,Rt,ge,se),Ke=et[tt.route.id];if(!Ke){for(let nn of Rt)if(et[nn.route.id]){Ke=et[nn.route.id];break}}if(Mt.signal.aborted){F.get(se)===Qe&&F.delete(se);return}if(P.has(se)){if(Xi(Ke)||zr(Ke)){qe(se,Vs(void 0));return}}else{if(Xi(Ke))if(F.delete(se),ee>xt){qe(se,Vs(void 0));return}else return B.add(se),qe(se,vp($e)),Ee(Mt,Ke,!1,{fetcherSubmission:$e,preventScrollReset:Ae});if(zr(Ke)){lt(se,de,Ke.error);return}}let St=C.navigation.location||C.location,En=Su(e.history,St,Qe.signal),gt=u||l,Fn=C.navigation.state!=="idle"?Uo(gt,C.navigation.location,f):C.matches;Et(Fn,"Didn't find any matches after fetcher action");let _t=++re;j.set(se,_t);let Cn=vp($e,Ke.data);C.fetchers.set(se,Cn);let{dsMatches:en,revalidatingFetchers:bn}=PU(En,ge,o,i,e.history,C,Fn,$e,St,r,!1,G,Y,P,z,B,gt,f,e.patchRoutesOnNavigation!=null,[tt.route.id,Ke],Xe);bn.filter(nn=>nn.key!==se).forEach(nn=>{let va=nn.key,Oc=C.fetchers.get(va),ui=vp(void 0,Oc?Oc.data:void 0);C.fetchers.set(va,ui),qt(va),nn.controller&&F.set(va,nn.controller)}),J({fetchers:new Map(C.fetchers)});let Xn=()=>bn.forEach(nn=>qt(nn.key));Qe.signal.addEventListener("abort",Xn);let{loaderResults:cr,fetcherResults:Ft}=await Be(en,bn,En,ge);if(Qe.signal.aborted)return;if(Qe.signal.removeEventListener("abort",Xn),j.delete(se),F.delete(se),bn.forEach(nn=>F.delete(nn.key)),C.fetchers.has(se)){let nn=Vs(Ke.data);C.fetchers.set(se,nn)}let kt=Ob(cr);if(kt)return Ee(En,kt.result,!1,{preventScrollReset:Ae});if(kt=Ob(Ft),kt)return B.add(kt.key),Ee(En,kt.result,!1,{preventScrollReset:Ae});let{loaderData:xr,errors:Wn}=GU(C,Fn,cr,void 0,bn,Ft);fe(_t),C.navigation.state==="loading"&&_t>ee?(Et(O,"Expected pending action"),$&&$.abort(),q(C.navigation.location,{matches:Fn,loaderData:xr,errors:Wn,fetchers:new Map(C.fetchers)})):(J({errors:Wn,loaderData:WU(C.loaderData,xr,Fn,Wn),fetchers:new Map(C.fetchers)}),G=!1)}async function rt(se,de,ye,ke,ge,Ce,Te,Ae,$e){let Xe=C.fetchers.get(se);qe(se,vp($e,Xe?Xe.data:void 0),{flushSync:Te});let Je=new AbortController,Qe=Su(e.history,ye,Je.signal);if(Ce){let Ke=await Ln(ke,new URL(Qe.url).pathname,Qe.signal,se);if(Ke.type==="aborted")return;if(Ke.type==="error"){lt(se,de,Ke.error,{flushSync:Te});return}else if(Ke.matches)ke=Ke.matches;else{lt(se,de,Ar(404,{pathname:ye}),{flushSync:Te});return}}let Mt=Qu(ke,ye);F.set(se,Je);let tt=re,xt=el(o,i,Qe,ke,Mt,r,ge),et=(await _e(Qe,xt,ge,se))[Mt.route.id];if(F.get(se)===Je&&F.delete(se),!Qe.signal.aborted){if(P.has(se)){qe(se,Vs(void 0));return}if(Xi(et))if(ee>tt){qe(se,Vs(void 0));return}else{B.add(se),await Ee(Qe,et,!1,{preventScrollReset:Ae});return}if(zr(et)){lt(se,de,et.error);return}qe(se,Vs(et.data))}}async function Ee(se,de,ye,{submission:ke,fetcherSubmission:ge,preventScrollReset:Ce,replace:Te}={}){ye||(M?.resolve(),M=null),de.response.headers.has("X-Remix-Revalidate")&&(G=!0);let Ae=de.response.headers.get("Location");Et(Ae,"Expected a Location header on the redirect Response"),Ae=HU(Ae,new URL(se.url),f,e.history);let $e=ni(C.location,Ae,{_isRedirect:!0});if(n){let xt=!1;if(de.response.headers.has("X-Remix-Reload-Document"))xt=!0;else if(ow(Ae)){const Rt=tV(Ae,!0);xt=Rt.origin!==t.location.origin||Na(Rt.pathname,f)==null}if(xt){Te?t.location.replace(Ae):t.location.assign(Ae);return}}$=null;let Xe=Te===!0||de.response.headers.has("X-Remix-Replace")?"REPLACE":"PUSH",{formMethod:Je,formAction:Qe,formEncType:Mt}=C.navigation;!ke&&!ge&&Je&&Qe&&Mt&&(ke=YU(C.navigation));let tt=ke||ge;if(ife.has(de.response.status)&&tt&&Zr(tt.formMethod))await Ne(Xe,$e,{submission:{...tt,formAction:Ae},preventScrollReset:Ce||L,enableViewTransition:ye?H:void 0});else{let xt=FE($e,ke);await Ne(Xe,$e,{overrideNavigation:xt,fetcherSubmission:ge,preventScrollReset:Ce||L,enableViewTransition:ye?H:void 0})}}async function _e(se,de,ye,ke){let ge,Ce={};try{ge=await TV(m,se,de,ke,ye,!1)}catch(Te){return de.filter(Ae=>Ae.shouldLoad).forEach(Ae=>{Ce[Ae.route.id]={type:"error",error:Te}}),Ce}if(se.signal.aborted)return Ce;if(!Zr(se.method))for(let Te of de){if(ge[Te.route.id]?.type==="error")break;!ge.hasOwnProperty(Te.route.id)&&!C.loaderData.hasOwnProperty(Te.route.id)&&(!C.errors||!C.errors.hasOwnProperty(Te.route.id))&&Te.shouldCallHandler()&&(ge[Te.route.id]={type:"error",result:new Error(`No result returned from dataStrategy for route ${Te.route.id}`)})}for(let[Te,Ae]of Object.entries(ge))if(DV(Ae)){let $e=Ae.result;Ce[Te]={type:"redirect",response:RV($e,se,Te,de,f)}}else Ce[Te]=await CV(Ae);return Ce}async function Be(se,de,ye,ke){let ge=_e(ye,se,ke,null),Ce=Promise.all(de.map(async $e=>{if($e.matches&&$e.match&&$e.request&&$e.controller){let Je=(await _e($e.request,$e.matches,ke,$e.key))[$e.match.route.id];return{[$e.key]:Je}}else return Promise.resolve({[$e.key]:{type:"error",error:Ar(404,{pathname:$e.path})}})})),Te=await ge,Ae=(await Ce).reduce(($e,Xe)=>Object.assign($e,Xe),{});return{loaderResults:Te,fetcherResults:Ae}}function it(){G=!0,z.forEach((se,de)=>{F.has(de)&&Y.add(de),qt(de)})}function qe(se,de,ye={}){C.fetchers.set(se,de),J({fetchers:new Map(C.fetchers)},{flushSync:(ye&&ye.flushSync)===!0})}function lt(se,de,ye,ke={}){let ge=wo(C.matches,de);ot(se),J({errors:{[ge.route.id]:ye},fetchers:new Map(C.fetchers)},{flushSync:(ke&&ke.flushSync)===!0})}function At(se){return D.set(se,(D.get(se)||0)+1),P.has(se)&&P.delete(se),C.fetchers.get(se)||tC}function Nn(se,de){qt(se,de?.reason),qe(se,Vs(null))}function ot(se){let de=C.fetchers.get(se);F.has(se)&&!(de&&de.state==="loading"&&j.has(se))&&qt(se),z.delete(se),j.delete(se),B.delete(se),P.delete(se),Y.delete(se),C.fetchers.delete(se)}function zn(se){let de=(D.get(se)||0)-1;de<=0?(D.delete(se),P.add(se)):D.set(se,de),J({fetchers:new Map(C.fetchers)})}function qt(se,de){let ye=F.get(se);ye&&(ye.abort(de),F.delete(se))}function Ge(se){for(let de of se){let ye=At(de),ke=Vs(ye.data);C.fetchers.set(de,ke)}}function We(){let se=[],de=!1;for(let ye of B){let ke=C.fetchers.get(ye);Et(ke,`Expected fetcher: ${ye}`),ke.state==="loading"&&(B.delete(ye),se.push(ye),de=!0)}return Ge(se),de}function fe(se){let de=[];for(let[ye,ke]of j)if(ke<se){let ge=C.fetchers.get(ye);Et(ge,`Expected fetcher: ${ye}`),ge.state==="loading"&&(qt(ye),j.delete(ye),de.push(ye))}return Ge(de),de.length>0}function It(se,de){let ye=C.blockers.get(se)||ql;return W.get(se)!==de&&W.set(se,de),ye}function Ct(se){C.blockers.delete(se),W.delete(se)}function Pt(se,de){let ye=C.blockers.get(se)||ql;Et(ye.state==="unblocked"&&de.state==="blocked"||ye.state==="blocked"&&de.state==="blocked"||ye.state==="blocked"&&de.state==="proceeding"||ye.state==="blocked"&&de.state==="unblocked"||ye.state==="proceeding"&&de.state==="unblocked",`Invalid blocker state transition: ${ye.state} -> ${de.state}`);let ke=new Map(C.blockers);ke.set(se,de),J({blockers:ke})}function $t({currentLocation:se,nextLocation:de,historyAction:ye}){if(W.size===0)return;W.size>1&&Un(!1,"A router only supports one blocker at a time");let ke=Array.from(W.entries()),[ge,Ce]=ke[ke.length-1],Te=C.blockers.get(ge);if(!(Te&&Te.state==="proceeding")&&Ce({currentLocation:se,nextLocation:de,historyAction:ye}))return ge}function Xt(se){let de=Ar(404,{pathname:se}),ye=u||l,{matches:ke,route:ge}=Pu(ye);return{notFoundMatches:ke,route:ge,error:de}}function xn(se,de,ye){if(E=se,w=de,x=ye||null,!S&&C.navigation===iy){S=!0;let ke=Ht(C.location,C.matches);ke!=null&&J({restoreScrollPosition:ke})}return()=>{E=null,w=null,x=null}}function dt(se,de){return x&&x(se,de.map(ke=>nV(ke,C.loaderData)))||se.key}function Ut(se,de){if(E&&w){let ye=dt(se,de);E[ye]=w()}}function Ht(se,de){if(E){let ye=dt(se,de),ke=E[ye];if(typeof ke=="number")return ke}return null}function zt(se,de,ye){if(e.patchRoutesOnNavigation)if(se){if(Object.keys(se[0].params).length>0)return{active:!0,matches:Ap(de,ye,f,!0)}}else return{active:!0,matches:Ap(de,ye,f,!0)||[]};return{active:!1,matches:null}}async function Ln(se,de,ye,ke){if(!e.patchRoutesOnNavigation)return{type:"success",matches:se};let ge=se;for(;;){let Ce=u==null,Te=u||l,Ae=i;try{await e.patchRoutesOnNavigation({signal:ye,path:de,matches:ge,fetcherKey:ke,patch:(Je,Qe)=>{ye.aborted||$U(Je,Qe,Te,Ae,o,!1)}})}catch(Je){return{type:"error",error:Je,partialMatches:ge}}finally{Ce&&!ye.aborted&&(l=[...l])}if(ye.aborted)return{type:"aborted"};let $e=Uo(Te,de,f),Xe=null;if($e){if(Object.keys($e[0].params).length===0)return{type:"success",matches:$e};if(Xe=Ap(Te,de,f,!0),!(Xe&&ge.length<Xe.length&&sn(ge,Xe.slice(0,ge.length))))return{type:"success",matches:$e}}if(Xe||(Xe=Ap(Te,de,f,!0)),!Xe||sn(ge,Xe))return{type:"success",matches:null};ge=Xe}}function sn(se,de){return se.length===de.length&&se.every((ye,ke)=>ye.route.id===de[ke].route.id)}function Mn(se){i={},u=fc(se,o,void 0,i)}function qn(se,de,ye=!1){let ke=u==null;$U(se,de,u||l,i,o,ye),ke&&(l=[...l],J({}))}return k={get basename(){return f},get future(){return h},get state(){return C},get routes(){return l},get window(){return t},initialize:oe,subscribe:Q,enableScrollRestoration:xn,navigate:ie,fetch:Ve,revalidate:he,createHref:se=>e.history.createHref(se),encodeLocation:se=>e.history.encodeLocation(se),getFetcher:At,resetFetcher:Nn,deleteFetcher:zn,dispose:le,getBlocker:It,deleteBlocker:Ct,patchRoutes:qn,_internalFetchControllers:F,_internalSetRoutes:Mn,_internalSetStateDoNotUseOrYouWillBreakYourApp(se){J(se)}},e.unstable_instrumentations&&(k=tfe(k,e.unstable_instrumentations.map(se=>se.router).filter(Boolean))),k}function lfe(e,t){Et(e.length>0,"You must provide a non-empty routes array to createStaticHandler");let n={},r=(t?t.basename:null)||"/",a=t?.mapRouteProperties||bV,o=a;if(t?.unstable_instrumentations){let y=t.unstable_instrumentations;o=E=>({...a(E),...dV(y.map(x=>x.route).filter(Boolean),E)})}let i=fc(e,o,void 0,n);async function l(y,{requestContext:E,filterMatchesToLoad:x,skipLoaderErrorBubbling:w,skipRevalidation:S,dataStrategy:_,generateMiddlewareResponse:T}={}){let A=new URL(y.url),R=y.method,k=ni("",ga(A),null,"default"),C=Uo(i,k,r);if(E=E??new ju,!w_(R)&&R!=="HEAD"){let M=Ar(405,{method:R}),{matches:L,route:$}=Pu(i),H={basename:r,location:k,matches:L,loaderData:{},actionData:null,errors:{[$.id]:M},statusCode:M.status,loaderHeaders:{},actionHeaders:{}};return T?T(()=>Promise.resolve(H)):H}else if(!C){let M=Ar(404,{pathname:k.pathname}),{matches:L,route:$}=Pu(i),H={basename:r,location:k,matches:L,loaderData:{},actionData:null,errors:{[$.id]:M},statusCode:M.status,loaderHeaders:{},actionHeaders:{}};return T?T(()=>Promise.resolve(H)):H}if(T){Et(E instanceof ju,"When using middleware in `staticHandler.query()`, any provided `requestContext` must be an instance of `RouterContextProvider`");try{await FU(C,n,o);let M,L=await BU({request:y,unstable_pattern:Ks(C),matches:C,params:C[0].params,context:E},async()=>await T(async(H,V={})=>{let Z=await f(H,k,C,E,_||null,w===!0,null,"filterMatchesToLoad"in V?V.filterMatchesToLoad??null:x??null,S===!0);return ua(Z)?Z:(M={location:k,basename:r,...Z},M)}),async($,H)=>{if(v_($))return $;if(ua($))try{$=new vs($.status,$.statusText,await NV($))}catch(V){$=V}if(ac($)&&($=IV($)),M){H in M.loaderData&&(M.loaderData[H]=void 0);let V=cfe(i,M,$,w?H:wo(C,H).route.id);return T(()=>Promise.resolve(V))}else{let V=w?H:wo(C,C.find(ne=>ne.route.id===H||ne.route.loader)?.route.id||H).route.id,Z={matches:C,location:k,basename:r,loaderData:{},actionData:null,errors:{[V]:$},statusCode:So($)?$.status:500,actionHeaders:{},loaderHeaders:{}};return T(()=>Promise.resolve(Z))}});return Et(ua(L),"Expected a response in query()"),L}catch(M){if(ua(M))return M;throw M}}let O=await f(y,k,C,E,_||null,w===!0,null,x||null,S===!0);return ua(O)?O:{location:k,basename:r,...O}}async function u(y,{routeId:E,requestContext:x,dataStrategy:w,generateMiddlewareResponse:S}={}){let _=new URL(y.url),T=y.method,A=ni("",ga(_),null,"default"),R=Uo(i,A,r);if(x=x??new ju,!w_(T)&&T!=="HEAD"&&T!=="OPTIONS")throw Ar(405,{method:T});if(!R)throw Ar(404,{pathname:A.pathname});let k=E?R.find(M=>M.route.id===E):Qu(R,A);if(E&&!k)throw Ar(403,{pathname:A.pathname,routeId:E});if(!k)throw Ar(404,{pathname:A.pathname});if(S)return Et(x instanceof ju,"When using middleware in `staticHandler.queryRoute()`, any provided `requestContext` must be an instance of `RouterContextProvider`"),await FU(R,n,o),await BU({request:y,unstable_pattern:Ks(R),matches:R,params:R[0].params,context:x},async()=>await S(async $=>{let H=await f($,A,R,x,w||null,!1,k,null,!1),V=O(H);return ua(V)?V:typeof V=="string"?new Response(V):Response.json(V)}),L=>{if(ac(L))return Promise.resolve(y_(L));if(ua(L))return Promise.resolve(L);throw L});let C=await f(y,A,R,x,w||null,!1,k,null,!1);return O(C);function O(M){if(ua(M))return M;let L=M.errors?Object.values(M.errors)[0]:void 0;if(L!==void 0)throw L;if(M.actionData)return Object.values(M.actionData)[0];if(M.loaderData)return Object.values(M.loaderData)[0]}}async function f(y,E,x,w,S,_,T,A,R){Et(y.signal,"query()/queryRoute() requests must contain an AbortController signal");try{if(Zr(y.method))return await m(y,x,T||Qu(x,E),w,S,_,T!=null,A,R);let k=await h(y,x,w,S,_,T,A);return ua(k)?k:{...k,actionData:null,actionHeaders:{}}}catch(k){if(OV(k)&&ua(k.result)){if(k.type==="error")throw k.result;return k.result}if(v_(k))return k;throw k}}async function m(y,E,x,w,S,_,T,A,R){let k;if(!x.route.action&&!x.route.lazy){let M=Ar(405,{method:y.method,pathname:new URL(y.url).pathname,routeId:x.route.id});if(T)throw M;k={type:"error",error:M}}else{let M=el(o,n,y,E,x,[],w);k=(await g(y,M,T,w,S))[x.route.id],y.signal.aborted&&MU(y,T)}if(Xi(k))throw new Response(null,{status:k.response.status,headers:{Location:k.response.headers.get("Location")}});if(T){if(zr(k))throw k.error;return{matches:[x],loaderData:{},actionData:{[x.route.id]:k.data},errors:null,statusCode:200,loaderHeaders:{},actionHeaders:{}}}if(R)if(zr(k)){let M=_?x:wo(E,x.route.id);return{statusCode:So(k.error)?k.error.status:k.statusCode!=null?k.statusCode:500,actionData:null,actionHeaders:{...k.headers?{[x.route.id]:k.headers}:{}},matches:E,loaderData:{},errors:{[M.route.id]:k.error},loaderHeaders:{}}}else return{actionData:{[x.route.id]:k.data},actionHeaders:k.headers?{[x.route.id]:k.headers}:{},matches:E,loaderData:{},errors:null,statusCode:k.statusCode||200,loaderHeaders:{}};let C=new Request(y.url,{headers:y.headers,redirect:y.redirect,signal:y.signal});if(zr(k)){let M=_?x:wo(E,x.route.id);return{...await h(C,E,w,S,_,null,A,[M.route.id,k]),statusCode:So(k.error)?k.error.status:k.statusCode!=null?k.statusCode:500,actionData:null,actionHeaders:{...k.headers?{[x.route.id]:k.headers}:{}}}}return{...await h(C,E,w,S,_,null,A),actionData:{[x.route.id]:k.data},...k.statusCode?{statusCode:k.statusCode}:{},actionHeaders:k.headers?{[x.route.id]:k.headers}:{}}}async function h(y,E,x,w,S,_,T,A){let R=_!=null;if(R&&!_?.route.loader&&!_?.route.lazy)throw Ar(400,{method:y.method,pathname:new URL(y.url).pathname,routeId:_?.route.id});let k;if(_)k=el(o,n,y,E,_,[],x);else{let M=A&&zr(A[1])?E.findIndex($=>$.route.id===A[0])-1:void 0,L=Ks(E);k=E.map(($,H)=>M!=null&&H>M?vm(o,n,y,L,$,[],x,!1):vm(o,n,y,L,$,[],x,($.route.loader||$.route.lazy)!=null&&(!T||T($))))}if(!w&&!k.some(M=>M.shouldLoad))return{matches:E,loaderData:{},errors:A&&zr(A[1])?{[A[0]]:A[1].error}:null,statusCode:200,loaderHeaders:{}};let C=await g(y,k,R,x,w);return y.signal.aborted&&MU(y,R),{...kV(E,C,A,!0,S),matches:E}}async function g(y,E,x,w,S){let _=await TV(S||g_,y,E,null,w,!0),T={};return await Promise.all(E.map(async A=>{if(!(A.route.id in _))return;let R=_[A.route.id];if(DV(R)){let k=R.result;throw RV(k,y,A.route.id,E,r)}if(x){if(ua(R.result))throw R;if(ac(R.result))throw y_(R.result)}T[A.route.id]=await CV(R)})),T}return{dataRoutes:i,query:l,queryRoute:u}}function cfe(e,t,n,r){let a=r||t._deepestRenderedBoundaryId||e[0].id;return{...t,statusCode:So(n)?n.status:500,errors:{[a]:n}}}function MU(e,t){if(e.signal.reason!==void 0)throw e.signal.reason;let n=t?"queryRoute":"query";throw new Error(`${n}() call aborted without an \`AbortSignal.reason\`: ${e.method} ${e.url}`)}function ufe(e){return e!=null&&("formData"in e&&e.formData!=null||"body"in e&&e.body!==void 0)}function m_(e,t,n,r,a,o){let i,l;if(a){i=[];for(let f of t)if(i.push(f),f.route.id===a){l=f;break}}else i=t,l=t[t.length-1];let u=iw(r||".",sw(i),Na(e.pathname,n)||e.pathname,o==="path");if(r==null&&(u.search=e.search,u.hash=e.hash),(r==null||r===""||r===".")&&l){let f=oC(u.search);if(l.route.index&&!f)u.search=u.search?u.search.replace(/^\?/,"?index&"):"?index";else if(!l.route.index&&f){let m=new URLSearchParams(u.search),h=m.getAll("index");m.delete("index"),h.filter(y=>y).forEach(y=>m.append("index",y));let g=m.toString();u.search=g?`?${g}`:""}}return n!=="/"&&(u.pathname=Yde({basename:n,pathname:u.pathname})),ga(u)}function jU(e,t,n){if(!n||!ufe(n))return{path:t};if(n.formMethod&&!w_(n.formMethod))return{path:t,error:Ar(405,{method:n.formMethod})};let r=()=>({path:t,error:Ar(400,{type:"invalid-body"})}),o=(n.formMethod||"get").toUpperCase(),i=AV(t);if(n.body!==void 0){if(n.formEncType==="text/plain"){if(!Zr(o))return r();let h=typeof n.body=="string"?n.body:n.body instanceof FormData||n.body instanceof URLSearchParams?Array.from(n.body.entries()).reduce((g,[y,E])=>`${g}${y}=${E}
91
+ `)},Qie=0,bu=[];function ele(e){var t=b.useRef([]),n=b.useRef([0,0]),r=b.useRef(),a=b.useState(Qie++)[0],o=b.useState(M5)[0],i=b.useRef(e);b.useEffect(function(){i.current=e},[e]),b.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(a));var x=xie([e.lockRef.current],(e.shards||[]).map(hU),!0).filter(Boolean);return x.forEach(function(w){return w.classList.add("allow-interactivity-".concat(a))}),function(){document.body.classList.remove("block-interactivity-".concat(a)),x.forEach(function(w){return w.classList.remove("allow-interactivity-".concat(a))})}}},[e.inert,e.lockRef.current,e.shards]);var l=b.useCallback(function(x,w){if("touches"in x&&x.touches.length===2||x.type==="wheel"&&x.ctrlKey)return!i.current.allowPinchZoom;var S=Ib(x),_=n.current,T="deltaX"in x?x.deltaX:_[0]-S[0],A="deltaY"in x?x.deltaY:_[1]-S[1],R,k=x.target,C=Math.abs(T)>Math.abs(A)?"h":"v";if("touches"in x&&C==="h"&&k.type==="range")return!1;var O=window.getSelection(),M=O&&O.anchorNode,L=M?M===k||M.contains(k):!1;if(L)return!1;var $=pU(C,k);if(!$)return!0;if($?R=C:(R=C==="v"?"h":"v",$=pU(C,k)),!$)return!1;if(!r.current&&"changedTouches"in x&&(T||A)&&(r.current=R),!R)return!0;var H=r.current||R;return qie(H,w,x,H==="h"?T:A)},[]),u=b.useCallback(function(x){var w=x;if(!(!bu.length||bu[bu.length-1]!==o)){var S="deltaY"in w?mU(w):Ib(w),_=t.current.filter(function(R){return R.name===w.type&&(R.target===w.target||w.target===R.shadowParent)&&Xie(R.delta,S)})[0];if(_&&_.should){w.cancelable&&w.preventDefault();return}if(!_){var T=(i.current.shards||[]).map(hU).filter(Boolean).filter(function(R){return R.contains(w.target)}),A=T.length>0?l(w,T[0]):!i.current.noIsolation;A&&w.cancelable&&w.preventDefault()}}},[]),f=b.useCallback(function(x,w,S,_){var T={name:x,delta:w,target:S,should:_,shadowParent:tle(S)};t.current.push(T),setTimeout(function(){t.current=t.current.filter(function(A){return A!==T})},1)},[]),m=b.useCallback(function(x){n.current=Ib(x),r.current=void 0},[]),h=b.useCallback(function(x){f(x.type,mU(x),x.target,l(x,e.lockRef.current))},[]),g=b.useCallback(function(x){f(x.type,Ib(x),x.target,l(x,e.lockRef.current))},[]);b.useEffect(function(){return bu.push(o),e.setCallbacks({onScrollCapture:h,onWheelCapture:h,onTouchMoveCapture:g}),document.addEventListener("wheel",u,gu),document.addEventListener("touchmove",u,gu),document.addEventListener("touchstart",m,gu),function(){bu=bu.filter(function(x){return x!==o}),document.removeEventListener("wheel",u,gu),document.removeEventListener("touchmove",u,gu),document.removeEventListener("touchstart",m,gu)}},[]);var y=e.removeScrollBar,E=e.inert;return b.createElement(b.Fragment,null,E?b.createElement(o,{styles:Jie(a)}):null,y?b.createElement(Hie,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function tle(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const nle=Aie(L5,ele);var Qm=b.forwardRef(function(e,t){return b.createElement(Xv,as({},e,{ref:t,sideCar:nle}))});Qm.classNames=Xv.classNames;var l_=["Enter"," "],rle=["ArrowDown","PageUp","Home"],U5=["ArrowUp","PageDown","End"],ale=[...rle,...U5],ole={ltr:[...l_,"ArrowRight"],rtl:[...l_,"ArrowLeft"]},sle={ltr:["ArrowLeft"],rtl:["ArrowRight"]},eh="Menu",[im,ile,lle]=RN(eh),[Sc,z5]=qo(eh,[lle,hl,N5]),Jv=hl(),F5=N5(),[cle,_c]=Sc(eh),[ule,th]=Sc(eh),B5=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:a,onOpenChange:o,modal:i=!0}=e,l=Jv(t),[u,f]=b.useState(null),m=b.useRef(!1),h=ps(o),g=kN(a);return b.useEffect(()=>{const y=()=>{m.current=!0,document.addEventListener("pointerdown",E,{capture:!0,once:!0}),document.addEventListener("pointermove",E,{capture:!0,once:!0})},E=()=>m.current=!1;return document.addEventListener("keydown",y,{capture:!0}),()=>{document.removeEventListener("keydown",y,{capture:!0}),document.removeEventListener("pointerdown",E,{capture:!0}),document.removeEventListener("pointermove",E,{capture:!0})}},[]),d.jsx(Kv,{...l,children:d.jsx(cle,{scope:t,open:n,onOpenChange:h,content:u,onContentChange:f,children:d.jsx(ule,{scope:t,onClose:b.useCallback(()=>h(!1),[h]),isUsingKeyboardRef:m,dir:g,modal:i,children:r})})})};B5.displayName=eh;var dle="MenuAnchor",UN=b.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,a=Jv(n);return d.jsx(Xm,{...a,...r,ref:t})});UN.displayName=dle;var zN="MenuPortal",[fle,H5]=Sc(zN,{forceMount:void 0}),V5=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:a}=e,o=_c(zN,t);return d.jsx(fle,{scope:t,forceMount:n,children:d.jsx(ao,{present:n||o.open,children:d.jsx(of,{asChild:!0,container:a,children:r})})})};V5.displayName=zN;var Eo="MenuContent",[ple,FN]=Sc(Eo),G5=b.forwardRef((e,t)=>{const n=H5(Eo,e.__scopeMenu),{forceMount:r=n.forceMount,...a}=e,o=_c(Eo,e.__scopeMenu),i=th(Eo,e.__scopeMenu);return d.jsx(im.Provider,{scope:e.__scopeMenu,children:d.jsx(ao,{present:r||o.open,children:d.jsx(im.Slot,{scope:e.__scopeMenu,children:i.modal?d.jsx(mle,{...a,ref:t}):d.jsx(hle,{...a,ref:t})})})})}),mle=b.forwardRef((e,t)=>{const n=_c(Eo,e.__scopeMenu),r=b.useRef(null),a=gn(t,r);return b.useEffect(()=>{const o=r.current;if(o)return qv(o)},[]),d.jsx(BN,{...e,ref:a,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:ct(e.onFocusOutside,o=>o.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),hle=b.forwardRef((e,t)=>{const n=_c(Eo,e.__scopeMenu);return d.jsx(BN,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),gle=cc("MenuContent.ScrollLock"),BN=b.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:a,onOpenAutoFocus:o,onCloseAutoFocus:i,disableOutsidePointerEvents:l,onEntryFocus:u,onEscapeKeyDown:f,onPointerDownOutside:m,onFocusOutside:h,onInteractOutside:g,onDismiss:y,disableOutsideScroll:E,...x}=e,w=_c(Eo,n),S=th(Eo,n),_=Jv(n),T=F5(n),A=ile(n),[R,k]=b.useState(null),C=b.useRef(null),O=gn(t,C,w.onContentChange),M=b.useRef(0),L=b.useRef(""),$=b.useRef(0),H=b.useRef(null),V=b.useRef("right"),Z=b.useRef(0),ne=E?Qm:b.Fragment,G=E?{as:gle,allowPinchZoom:!0}:void 0,Y=re=>{const ee=L.current+re,j=A().filter(K=>!K.disabled),B=document.activeElement,z=j.find(K=>K.ref.current===B)?.textValue,D=j.map(K=>K.textValue),P=Rle(D,ee,z),W=j.find(K=>K.textValue===P)?.ref.current;(function K(ae){L.current=ae,window.clearTimeout(M.current),ae!==""&&(M.current=window.setTimeout(()=>K(""),1e3))})(ee),W&&setTimeout(()=>W.focus())};b.useEffect(()=>()=>window.clearTimeout(M.current),[]),Bv();const F=b.useCallback(re=>V.current===H.current?.side&&Ale(re,H.current?.area),[]);return d.jsx(ple,{scope:n,searchRef:L,onItemEnter:b.useCallback(re=>{F(re)&&re.preventDefault()},[F]),onItemLeave:b.useCallback(re=>{F(re)||(C.current?.focus(),k(null))},[F]),onTriggerLeave:b.useCallback(re=>{F(re)&&re.preventDefault()},[F]),pointerGraceTimerRef:$,onPointerGraceIntentChange:b.useCallback(re=>{H.current=re},[]),children:d.jsx(ne,{...G,children:d.jsx(Zm,{asChild:!0,trapped:a,onMountAutoFocus:ct(o,re=>{re.preventDefault(),C.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:d.jsx(nf,{asChild:!0,disableOutsidePointerEvents:l,onEscapeKeyDown:f,onPointerDownOutside:m,onFocusOutside:h,onInteractOutside:g,onDismiss:y,children:d.jsx(gie,{asChild:!0,...T,dir:S.dir,orientation:"vertical",loop:r,currentTabStopId:R,onCurrentTabStopIdChange:k,onEntryFocus:ct(u,re=>{S.isUsingKeyboardRef.current||re.preventDefault()}),preventScrollOnEntryFocus:!0,children:d.jsx(Yv,{role:"menu","aria-orientation":"vertical","data-state":iH(w.open),"data-radix-menu-content":"",dir:S.dir,..._,...x,ref:O,style:{outline:"none",...x.style},onKeyDown:ct(x.onKeyDown,re=>{const j=re.target.closest("[data-radix-menu-content]")===re.currentTarget,B=re.ctrlKey||re.altKey||re.metaKey,z=re.key.length===1;j&&(re.key==="Tab"&&re.preventDefault(),!B&&z&&Y(re.key));const D=C.current;if(re.target!==D||!ale.includes(re.key))return;re.preventDefault();const W=A().filter(K=>!K.disabled).map(K=>K.ref.current);U5.includes(re.key)&&W.reverse(),Nle(W)}),onBlur:ct(e.onBlur,re=>{re.currentTarget.contains(re.target)||(window.clearTimeout(M.current),L.current="")}),onPointerMove:ct(e.onPointerMove,lm(re=>{const ee=re.target,j=Z.current!==re.clientX;if(re.currentTarget.contains(ee)&&j){const B=re.clientX>Z.current?"right":"left";V.current=B,Z.current=re.clientX}}))})})})})})})});G5.displayName=Eo;var ble="MenuGroup",HN=b.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return d.jsx(Zt.div,{role:"group",...r,ref:t})});HN.displayName=ble;var yle="MenuLabel",W5=b.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return d.jsx(Zt.div,{...r,ref:t})});W5.displayName=yle;var Yy="MenuItem",gU="menu.itemSelect",Qv=b.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...a}=e,o=b.useRef(null),i=th(Yy,e.__scopeMenu),l=FN(Yy,e.__scopeMenu),u=gn(t,o),f=b.useRef(!1),m=()=>{const h=o.current;if(!n&&h){const g=new CustomEvent(gU,{bubbles:!0,cancelable:!0});h.addEventListener(gU,y=>r?.(y),{once:!0}),e5(h,g),g.defaultPrevented?f.current=!1:i.onClose()}};return d.jsx(K5,{...a,ref:u,disabled:n,onClick:ct(e.onClick,m),onPointerDown:h=>{e.onPointerDown?.(h),f.current=!0},onPointerUp:ct(e.onPointerUp,h=>{f.current||h.currentTarget?.click()}),onKeyDown:ct(e.onKeyDown,h=>{const g=l.searchRef.current!=="";n||g&&h.key===" "||l_.includes(h.key)&&(h.currentTarget.click(),h.preventDefault())})})});Qv.displayName=Yy;var K5=b.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:a,...o}=e,i=FN(Yy,n),l=F5(n),u=b.useRef(null),f=gn(t,u),[m,h]=b.useState(!1),[g,y]=b.useState("");return b.useEffect(()=>{const E=u.current;E&&y((E.textContent??"").trim())},[o.children]),d.jsx(im.ItemSlot,{scope:n,disabled:r,textValue:a??g,children:d.jsx(bie,{asChild:!0,...l,focusable:!r,children:d.jsx(Zt.div,{role:"menuitem","data-highlighted":m?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...o,ref:f,onPointerMove:ct(e.onPointerMove,lm(E=>{r?i.onItemLeave(E):(i.onItemEnter(E),E.defaultPrevented||E.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:ct(e.onPointerLeave,lm(E=>i.onItemLeave(E))),onFocus:ct(e.onFocus,()=>h(!0)),onBlur:ct(e.onBlur,()=>h(!1))})})})}),vle="MenuCheckboxItem",Y5=b.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...a}=e;return d.jsx(Q5,{scope:e.__scopeMenu,checked:n,children:d.jsx(Qv,{role:"menuitemcheckbox","aria-checked":Zy(n)?"mixed":n,...a,ref:t,"data-state":GN(n),onSelect:ct(a.onSelect,()=>r?.(Zy(n)?!0:!n),{checkForDefaultPrevented:!1})})})});Y5.displayName=vle;var Z5="MenuRadioGroup",[wle,xle]=Sc(Z5,{value:void 0,onValueChange:()=>{}}),q5=b.forwardRef((e,t)=>{const{value:n,onValueChange:r,...a}=e,o=ps(r);return d.jsx(wle,{scope:e.__scopeMenu,value:n,onValueChange:o,children:d.jsx(HN,{...a,ref:t})})});q5.displayName=Z5;var X5="MenuRadioItem",J5=b.forwardRef((e,t)=>{const{value:n,...r}=e,a=xle(X5,e.__scopeMenu),o=n===a.value;return d.jsx(Q5,{scope:e.__scopeMenu,checked:o,children:d.jsx(Qv,{role:"menuitemradio","aria-checked":o,...r,ref:t,"data-state":GN(o),onSelect:ct(r.onSelect,()=>a.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});J5.displayName=X5;var VN="MenuItemIndicator",[Q5,Ele]=Sc(VN,{checked:!1}),eH=b.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...a}=e,o=Ele(VN,n);return d.jsx(ao,{present:r||Zy(o.checked)||o.checked===!0,children:d.jsx(Zt.span,{...a,ref:t,"data-state":GN(o.checked)})})});eH.displayName=VN;var Sle="MenuSeparator",tH=b.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return d.jsx(Zt.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});tH.displayName=Sle;var _le="MenuArrow",nH=b.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,a=Jv(n);return d.jsx(Zv,{...a,...r,ref:t})});nH.displayName=_le;var Tle="MenuSub",[HTe,rH]=Sc(Tle),Rp="MenuSubTrigger",aH=b.forwardRef((e,t)=>{const n=_c(Rp,e.__scopeMenu),r=th(Rp,e.__scopeMenu),a=rH(Rp,e.__scopeMenu),o=FN(Rp,e.__scopeMenu),i=b.useRef(null),{pointerGraceTimerRef:l,onPointerGraceIntentChange:u}=o,f={__scopeMenu:e.__scopeMenu},m=b.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return b.useEffect(()=>m,[m]),b.useEffect(()=>{const h=l.current;return()=>{window.clearTimeout(h),u(null)}},[l,u]),d.jsx(UN,{asChild:!0,...f,children:d.jsx(K5,{id:a.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":a.contentId,"data-state":iH(n.open),...e,ref:fs(t,a.onTriggerChange),onClick:h=>{e.onClick?.(h),!(e.disabled||h.defaultPrevented)&&(h.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:ct(e.onPointerMove,lm(h=>{o.onItemEnter(h),!h.defaultPrevented&&!e.disabled&&!n.open&&!i.current&&(o.onPointerGraceIntentChange(null),i.current=window.setTimeout(()=>{n.onOpenChange(!0),m()},100))})),onPointerLeave:ct(e.onPointerLeave,lm(h=>{m();const g=n.content?.getBoundingClientRect();if(g){const y=n.content?.dataset.side,E=y==="right",x=E?-5:5,w=g[E?"left":"right"],S=g[E?"right":"left"];o.onPointerGraceIntentChange({area:[{x:h.clientX+x,y:h.clientY},{x:w,y:g.top},{x:S,y:g.top},{x:S,y:g.bottom},{x:w,y:g.bottom}],side:y}),window.clearTimeout(l.current),l.current=window.setTimeout(()=>o.onPointerGraceIntentChange(null),300)}else{if(o.onTriggerLeave(h),h.defaultPrevented)return;o.onPointerGraceIntentChange(null)}})),onKeyDown:ct(e.onKeyDown,h=>{const g=o.searchRef.current!=="";e.disabled||g&&h.key===" "||ole[r.dir].includes(h.key)&&(n.onOpenChange(!0),n.content?.focus(),h.preventDefault())})})})});aH.displayName=Rp;var oH="MenuSubContent",sH=b.forwardRef((e,t)=>{const n=H5(Eo,e.__scopeMenu),{forceMount:r=n.forceMount,...a}=e,o=_c(Eo,e.__scopeMenu),i=th(Eo,e.__scopeMenu),l=rH(oH,e.__scopeMenu),u=b.useRef(null),f=gn(t,u);return d.jsx(im.Provider,{scope:e.__scopeMenu,children:d.jsx(ao,{present:r||o.open,children:d.jsx(im.Slot,{scope:e.__scopeMenu,children:d.jsx(BN,{id:l.contentId,"aria-labelledby":l.triggerId,...a,ref:f,align:"start",side:i.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:m=>{i.isUsingKeyboardRef.current&&u.current?.focus(),m.preventDefault()},onCloseAutoFocus:m=>m.preventDefault(),onFocusOutside:ct(e.onFocusOutside,m=>{m.target!==l.trigger&&o.onOpenChange(!1)}),onEscapeKeyDown:ct(e.onEscapeKeyDown,m=>{i.onClose(),m.preventDefault()}),onKeyDown:ct(e.onKeyDown,m=>{const h=m.currentTarget.contains(m.target),g=sle[i.dir].includes(m.key);h&&g&&(o.onOpenChange(!1),l.trigger?.focus(),m.preventDefault())})})})})})});sH.displayName=oH;function iH(e){return e?"open":"closed"}function Zy(e){return e==="indeterminate"}function GN(e){return Zy(e)?"indeterminate":e?"checked":"unchecked"}function Nle(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function Cle(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function Rle(e,t,n){const a=t.length>1&&Array.from(t).every(f=>f===t[0])?t[0]:t,o=n?e.indexOf(n):-1;let i=Cle(e,Math.max(o,0));a.length===1&&(i=i.filter(f=>f!==n));const u=i.find(f=>f.toLowerCase().startsWith(a.toLowerCase()));return u!==n?u:void 0}function kle(e,t){const{x:n,y:r}=e;let a=!1;for(let o=0,i=t.length-1;o<t.length;i=o++){const l=t[o],u=t[i],f=l.x,m=l.y,h=u.x,g=u.y;m>r!=g>r&&n<(h-f)*(r-m)/(g-m)+f&&(a=!a)}return a}function Ale(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return kle(n,t)}function lm(e){return t=>t.pointerType==="mouse"?e(t):void 0}var Ile=B5,Ole=UN,Dle=V5,Lle=G5,Mle=HN,jle=W5,Ple=Qv,$le=Y5,Ule=q5,zle=J5,Fle=eH,Ble=tH,Hle=nH,Vle=aH,Gle=sH,ew="DropdownMenu",[Wle]=qo(ew,[z5]),Ra=z5(),[Kle,lH]=Wle(ew),cH=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:a,defaultOpen:o,onOpenChange:i,modal:l=!0}=e,u=Ra(t),f=b.useRef(null),[m,h]=Js({prop:a,defaultProp:o??!1,onChange:i,caller:ew});return d.jsx(Kle,{scope:t,triggerId:oa(),triggerRef:f,contentId:oa(),open:m,onOpenChange:h,onOpenToggle:b.useCallback(()=>h(g=>!g),[h]),modal:l,children:d.jsx(Ile,{...u,open:m,onOpenChange:h,dir:r,modal:l,children:n})})};cH.displayName=ew;var uH="DropdownMenuTrigger",dH=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...a}=e,o=lH(uH,n),i=Ra(n);return d.jsx(Ole,{asChild:!0,...i,children:d.jsx(Zt.button,{type:"button",id:o.triggerId,"aria-haspopup":"menu","aria-expanded":o.open,"aria-controls":o.open?o.contentId:void 0,"data-state":o.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...a,ref:fs(t,o.triggerRef),onPointerDown:ct(e.onPointerDown,l=>{!r&&l.button===0&&l.ctrlKey===!1&&(o.onOpenToggle(),o.open||l.preventDefault())}),onKeyDown:ct(e.onKeyDown,l=>{r||(["Enter"," "].includes(l.key)&&o.onOpenToggle(),l.key==="ArrowDown"&&o.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(l.key)&&l.preventDefault())})})})});dH.displayName=uH;var Yle="DropdownMenuPortal",fH=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Ra(t);return d.jsx(Dle,{...r,...n})};fH.displayName=Yle;var pH="DropdownMenuContent",mH=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=lH(pH,n),o=Ra(n),i=b.useRef(!1);return d.jsx(Lle,{id:a.contentId,"aria-labelledby":a.triggerId,...o,...r,ref:t,onCloseAutoFocus:ct(e.onCloseAutoFocus,l=>{i.current||a.triggerRef.current?.focus(),i.current=!1,l.preventDefault()}),onInteractOutside:ct(e.onInteractOutside,l=>{const u=l.detail.originalEvent,f=u.button===0&&u.ctrlKey===!0,m=u.button===2||f;(!a.modal||m)&&(i.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)"}})});mH.displayName=pH;var Zle="DropdownMenuGroup",qle=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=Ra(n);return d.jsx(Mle,{...a,...r,ref:t})});qle.displayName=Zle;var Xle="DropdownMenuLabel",hH=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=Ra(n);return d.jsx(jle,{...a,...r,ref:t})});hH.displayName=Xle;var Jle="DropdownMenuItem",gH=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=Ra(n);return d.jsx(Ple,{...a,...r,ref:t})});gH.displayName=Jle;var Qle="DropdownMenuCheckboxItem",bH=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=Ra(n);return d.jsx($le,{...a,...r,ref:t})});bH.displayName=Qle;var ece="DropdownMenuRadioGroup",yH=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=Ra(n);return d.jsx(Ule,{...a,...r,ref:t})});yH.displayName=ece;var tce="DropdownMenuRadioItem",vH=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=Ra(n);return d.jsx(zle,{...a,...r,ref:t})});vH.displayName=tce;var nce="DropdownMenuItemIndicator",rce=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=Ra(n);return d.jsx(Fle,{...a,...r,ref:t})});rce.displayName=nce;var ace="DropdownMenuSeparator",wH=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=Ra(n);return d.jsx(Ble,{...a,...r,ref:t})});wH.displayName=ace;var oce="DropdownMenuArrow",sce=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=Ra(n);return d.jsx(Hle,{...a,...r,ref:t})});sce.displayName=oce;var ice="DropdownMenuSubTrigger",xH=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=Ra(n);return d.jsx(Vle,{...a,...r,ref:t})});xH.displayName=ice;var lce="DropdownMenuSubContent",EH=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=Ra(n);return d.jsx(Gle,{...a,...r,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)"}})});EH.displayName=lce;var cce=cH,uce=dH,dce=fH,SH=mH,_H=hH,TH=gH,fce=bH,pce=yH,NH=vH,CH=wH,mce=xH,hce=EH;const cm=cce,um=uce,gce=pce;mce.displayName;hce.displayName;function Pd({ref:e,className:t,sideOffset:n=4,...r}){return d.jsx(dce,{children:d.jsx(SH,{ref:e,sideOffset:n,className:Fe("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),...r})})}Pd.displayName=SH.displayName;function Jr({ref:e,className:t,inset:n,...r}){return d.jsx(TH,{ref:e,className:Fe("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),...r})}Jr.displayName=TH.displayName;fce.displayName;function sy({ref:e,className:t,children:n,...r}){return d.jsx(NH,{ref:e,className:Fe("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...r,children:n})}sy.displayName=NH.displayName;function c_({ref:e,className:t,inset:n,...r}){return d.jsx(_H,{ref:e,className:Fe("px-2 py-1.5 text-sm font-semibold",n&&"pl-8",t),...r})}c_.displayName=_H.displayName;function Mu({ref:e,className:t,...n}){return d.jsx(CH,{ref:e,className:Fe("-mx-1 my-1 h-px bg-muted",t),...n})}Mu.displayName=CH.displayName;function sf({message:e,className:t="",vertical:n,noBorder:r}){return d.jsx("div",{className:Fe(`mt-2 rounded-md p-6 ${t}`,!r&&"border"),children:d.jsxs("p",{className:Fe("text-sm text-muted-foreground flex items-center gap-4",n&&"flex-col"),children:[d.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:d.jsx("g",{stroke:"none",strokeWidth:"1",fill:"none",fillRule:"evenodd",children:d.jsxs("g",{transform:"translate(5.320900, 5.320900)",fillRule:"nonzero",className:"stroke-black dark:stroke-white",strokeWidth:"4",children:[d.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"}),d.jsx("circle",{cx:"50",cy:"212.0001",r:"52.5"}),d.jsx("circle",{cx:"212.0001",cy:"50",r:"52.5"})]})})}),e]})})}function RH({className:e,color:t,children:n,grayscaled:r=!1}){const a=b.useMemo(()=>{if(t){const h=t.split("(")[1].split(")")[0].trim().split(/\s+/);return Number.parseFloat(h[1]||"0")}return r?0:.2},[t,r]),o=b.useMemo(()=>{if(t){const h=t.split("(")[1].split(")")[0].trim().split(/\s+/);return Number.parseFloat(h[0]||"0.5")}return r?.3:.4},[t,r]),i=b.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]),l=b.useMemo(()=>t||`oklch(${Math.min(o,1)} ${a} ${i})`,[i,a,o]),u=b.useMemo(()=>`oklch(${Math.min(o*2,1)} ${a} ${i})`,[i,a,o,t]),f=b.useMemo(()=>Math.floor(Math.random()*360),[i]),m=b.useMemo(()=>"1000%",[]);return d.jsx("section",{className:Fe("relative w-full h-full overflow-hidden",e),style:{background:`${u}`},children:d.jsxs("div",{className:"isolate relative w-full h-full",children:[d.jsx("div",{className:"noise w-full h-full",style:{background:`linear-gradient(${f}deg, ${l}, transparent), url(https://grainy-gradients.vercel.app/noise.svg)`,filter:`contrast(120%) brightness(${m})`}}),n&&d.jsx("div",{className:"relative z-10 w-full h-full",children:n})]})})}var kH=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"}),bce="VisuallyHidden",AH=b.forwardRef((e,t)=>d.jsx(Zt.span,{...e,ref:t,style:{...kH,...e.style}}));AH.displayName=bce;var yce=AH,[tw]=qo("Tooltip",[hl]),nw=hl(),IH="TooltipProvider",vce=700,u_="tooltip.open",[wce,WN]=tw(IH),OH=e=>{const{__scopeTooltip:t,delayDuration:n=vce,skipDelayDuration:r=300,disableHoverableContent:a=!1,children:o}=e,i=b.useRef(!0),l=b.useRef(!1),u=b.useRef(0);return b.useEffect(()=>{const f=u.current;return()=>window.clearTimeout(f)},[]),d.jsx(wce,{scope:t,isOpenDelayedRef:i,delayDuration:n,onOpen:b.useCallback(()=>{window.clearTimeout(u.current),i.current=!1},[]),onClose:b.useCallback(()=>{window.clearTimeout(u.current),u.current=window.setTimeout(()=>i.current=!0,r)},[r]),isPointerInTransitRef:l,onPointerInTransitChange:b.useCallback(f=>{l.current=f},[]),disableHoverableContent:a,children:o})};OH.displayName=IH;var dm="Tooltip",[xce,nh]=tw(dm),DH=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:a,onOpenChange:o,disableHoverableContent:i,delayDuration:l}=e,u=WN(dm,e.__scopeTooltip),f=nw(t),[m,h]=b.useState(null),g=oa(),y=b.useRef(0),E=i??u.disableHoverableContent,x=l??u.delayDuration,w=b.useRef(!1),[S,_]=Js({prop:r,defaultProp:a??!1,onChange:C=>{C?(u.onOpen(),document.dispatchEvent(new CustomEvent(u_))):u.onClose(),o?.(C)},caller:dm}),T=b.useMemo(()=>S?w.current?"delayed-open":"instant-open":"closed",[S]),A=b.useCallback(()=>{window.clearTimeout(y.current),y.current=0,w.current=!1,_(!0)},[_]),R=b.useCallback(()=>{window.clearTimeout(y.current),y.current=0,_(!1)},[_]),k=b.useCallback(()=>{window.clearTimeout(y.current),y.current=window.setTimeout(()=>{w.current=!0,_(!0),y.current=0},x)},[x,_]);return b.useEffect(()=>()=>{y.current&&(window.clearTimeout(y.current),y.current=0)},[]),d.jsx(Kv,{...f,children:d.jsx(xce,{scope:t,contentId:g,open:S,stateAttribute:T,trigger:m,onTriggerChange:h,onTriggerEnter:b.useCallback(()=>{u.isOpenDelayedRef.current?k():A()},[u.isOpenDelayedRef,k,A]),onTriggerLeave:b.useCallback(()=>{E?R():(window.clearTimeout(y.current),y.current=0)},[R,E]),onOpen:A,onClose:R,disableHoverableContent:E,children:n})})};DH.displayName=dm;var d_="TooltipTrigger",LH=b.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,a=nh(d_,n),o=WN(d_,n),i=nw(n),l=b.useRef(null),u=gn(t,l,a.onTriggerChange),f=b.useRef(!1),m=b.useRef(!1),h=b.useCallback(()=>f.current=!1,[]);return b.useEffect(()=>()=>document.removeEventListener("pointerup",h),[h]),d.jsx(Xm,{asChild:!0,...i,children:d.jsx(Zt.button,{"aria-describedby":a.open?a.contentId:void 0,"data-state":a.stateAttribute,...r,ref:u,onPointerMove:ct(e.onPointerMove,g=>{g.pointerType!=="touch"&&!m.current&&!o.isPointerInTransitRef.current&&(a.onTriggerEnter(),m.current=!0)}),onPointerLeave:ct(e.onPointerLeave,()=>{a.onTriggerLeave(),m.current=!1}),onPointerDown:ct(e.onPointerDown,()=>{a.open&&a.onClose(),f.current=!0,document.addEventListener("pointerup",h,{once:!0})}),onFocus:ct(e.onFocus,()=>{f.current||a.onOpen()}),onBlur:ct(e.onBlur,a.onClose),onClick:ct(e.onClick,a.onClose)})})});LH.displayName=d_;var KN="TooltipPortal",[Ece,Sce]=tw(KN,{forceMount:void 0}),MH=e=>{const{__scopeTooltip:t,forceMount:n,children:r,container:a}=e,o=nh(KN,t);return d.jsx(Ece,{scope:t,forceMount:n,children:d.jsx(ao,{present:n||o.open,children:d.jsx(of,{asChild:!0,container:a,children:r})})})};MH.displayName=KN;var $d="TooltipContent",jH=b.forwardRef((e,t)=>{const n=Sce($d,e.__scopeTooltip),{forceMount:r=n.forceMount,side:a="top",...o}=e,i=nh($d,e.__scopeTooltip);return d.jsx(ao,{present:r||i.open,children:i.disableHoverableContent?d.jsx(PH,{side:a,...o,ref:t}):d.jsx(_ce,{side:a,...o,ref:t})})}),_ce=b.forwardRef((e,t)=>{const n=nh($d,e.__scopeTooltip),r=WN($d,e.__scopeTooltip),a=b.useRef(null),o=gn(t,a),[i,l]=b.useState(null),{trigger:u,onClose:f}=n,m=a.current,{onPointerInTransitChange:h}=r,g=b.useCallback(()=>{l(null),h(!1)},[h]),y=b.useCallback((E,x)=>{const w=E.currentTarget,S={x:E.clientX,y:E.clientY},_=Rce(S,w.getBoundingClientRect()),T=kce(S,_),A=Ace(x.getBoundingClientRect()),R=Oce([...T,...A]);l(R),h(!0)},[h]);return b.useEffect(()=>()=>g(),[g]),b.useEffect(()=>{if(u&&m){const E=w=>y(w,m),x=w=>y(w,u);return u.addEventListener("pointerleave",E),m.addEventListener("pointerleave",x),()=>{u.removeEventListener("pointerleave",E),m.removeEventListener("pointerleave",x)}}},[u,m,y,g]),b.useEffect(()=>{if(i){const E=x=>{const w=x.target,S={x:x.clientX,y:x.clientY},_=u?.contains(w)||m?.contains(w),T=!Ice(S,i);_?g():T&&(g(),f())};return document.addEventListener("pointermove",E),()=>document.removeEventListener("pointermove",E)}},[u,m,i,f,g]),d.jsx(PH,{...e,ref:o})}),[Tce,Nce]=tw(dm,{isInside:!1}),Cce=hoe("TooltipContent"),PH=b.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":a,onEscapeKeyDown:o,onPointerDownOutside:i,...l}=e,u=nh($d,n),f=nw(n),{onClose:m}=u;return b.useEffect(()=>(document.addEventListener(u_,m),()=>document.removeEventListener(u_,m)),[m]),b.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]),d.jsx(nf,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:o,onPointerDownOutside:i,onFocusOutside:h=>h.preventDefault(),onDismiss:m,children:d.jsxs(Yv,{"data-state":u.stateAttribute,...f,...l,ref:t,style:{...l.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:[d.jsx(Cce,{children:r}),d.jsx(Tce,{scope:n,isInside:!0,children:d.jsx(yce,{id:u.contentId,role:"tooltip",children:a||r})})]})})});jH.displayName=$d;var $H="TooltipArrow",UH=b.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,a=nw(n);return Nce($H,n).isInside?null:d.jsx(Zv,{...a,...r,ref:t})});UH.displayName=$H;function Rce(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),a=Math.abs(t.right-e.x),o=Math.abs(t.left-e.x);switch(Math.min(n,r,a,o)){case o:return"left";case a:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function kce(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function Ace(e){const{top:t,right:n,bottom:r,left:a}=e;return[{x:a,y:t},{x:n,y:t},{x:n,y:r},{x:a,y:r}]}function Ice(e,t){const{x:n,y:r}=e;let a=!1;for(let o=0,i=t.length-1;o<t.length;i=o++){const l=t[o],u=t[i],f=l.x,m=l.y,h=u.x,g=u.y;m>r!=g>r&&n<(h-f)*(r-m)/(g-m)+f&&(a=!a)}return a}function Oce(e){const t=e.slice();return t.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),Dce(t)}function Dce(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const a=e[r];for(;t.length>=2;){const o=t[t.length-1],i=t[t.length-2];if((o.x-i.x)*(a.y-i.y)>=(o.y-i.y)*(a.x-i.x))t.pop();else break}t.push(a)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const a=e[r];for(;n.length>=2;){const o=n[n.length-1],i=n[n.length-2];if((o.x-i.x)*(a.y-i.y)>=(o.y-i.y)*(a.x-i.x))n.pop();else break}n.push(a)}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 Lce=OH,Mce=DH,jce=LH,Pce=MH,$ce=jH,Uce=UH;function YN({delayDuration:e=0,...t}){return d.jsx(Lce,{"data-slot":"tooltip-provider",delayDuration:e,...t})}function Wt({...e}){return d.jsx(YN,{children:d.jsx(Mce,{"data-slot":"tooltip",...e})})}function Kt({...e}){return d.jsx(jce,{"data-slot":"tooltip-trigger",...e})}function Yt({className:e,sideOffset:t=0,children:n,...r}){return d.jsx(Pce,{children:d.jsxs($ce,{"data-slot":"tooltip-content",sideOffset:t,className:Fe("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),...r,children:[n,d.jsx(Uce,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}class zce{name="mcp_inspector_open";properties;constructor(t){this.properties={server_url:t.serverUrl,connection_count:t.connectionCount}}}class bU{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 yU{name="mcp_resource_read";properties;constructor(t){this.properties={resource_uri:t.resourceUri,server_id:t.serverId,success:t.success,error:t.error}}}class vU{name="mcp_prompt_call";properties;constructor(t){this.properties={prompt_name:t.promptName,server_id:t.serverId,success:t.success,error:t.error}}}class wU{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 Fce{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 Bce{name="mcp_command_palette_open";properties;constructor(t){this.properties={trigger:t.trigger}}}class Hce{name="mcp_tool_saved";properties;constructor(t){this.properties={tool_name:t.toolName,server_id:t.serverId}}}function jE(){try{return"0.15.1"}catch{return"0.0.0"}}var Vce={};function PE(){try{return typeof window<"u"&&typeof document<"u"}catch{return!1}}class xU{endpoint;timeout;constructor(t,n=3e3){this.endpoint=t,this.timeout=n}async logEvent(t){try{const n=new AbortController,r=setTimeout(()=>n.abort(),this.timeout),a=await fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t),signal:n.signal});if(clearTimeout(r),!a.ok)throw new Error(`HTTP error! status: ${a.status}`)}catch{}}}function Pi(e){return`mcp_inspector_telemetry_${e}`}function yp(){return typeof localStorage<"u"&&typeof localStorage.getItem=="function"&&typeof localStorage.setItem=="function"}class ra{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=PE(),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 xU(this.POSTHOG_PROXY_URL,3e3)}catch{this._posthogClient=null}try{this._scarfClient=new xU(this.SCARF_PROXY_URL,3e3)}catch{this._scarfClient=null}}}isTelemetryDisabled(){return!!(yp()&&localStorage.getItem(Pi("disabled"))==="true"||typeof process<"u"&&Vce?.MCP_USE_ANONYMIZED_TELEMETRY==="false")}getStoredSource(){return yp()?localStorage.getItem(Pi("source")):null}static getInstance(){return ra.instance||(ra.instance=new ra),ra.instance}setSource(t){this._source=t,yp()&&localStorage.setItem(Pi("source"),t)}getSource(){return this._source}get userId(){if(this._currUserId)return this._currUserId;if(!PE())return this._currUserId=this.UNKNOWN_USER_ID,this._currUserId;try{if(!yp())throw new Error("localStorage is not available or not functional");const t=localStorage.getItem(Pi("user_id"));if(t)this._currUserId=t;else{const n=this.generateUserId();localStorage.setItem(Pi("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(){const t=window.crypto;if(t){const n=new Uint8Array(16);t.getRandomValues(n),n[6]=n[6]&15|64,n[8]=n[8]&63|128;const r=Array.from(n).map(a=>a.toString(16).padStart(2,"0")).join("");return r.slice(0,8)+"-"+r.slice(8,12)+"-"+r.slice(12,16)+"-"+r.slice(16,20)+"-"+r.slice(20,32)}else return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,n=>{const r=Math.random()*16|0;return(n==="x"?r:r&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:jE(),language:"typescript",source:this._source,package:"inspector"}};await this._posthogClient.logEvent(n)}catch{}if(this._scarfClient)try{const n={};n.mcp_use_version=jE(),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&&PE())try{if(!yp())throw new Error("localStorage is not available or not functional");const n=jE();let r=!1,a=!1;const o=localStorage.getItem(Pi("download_version"));if(o?n>o&&(r=!0,a=!1,localStorage.setItem(Pi("download_version"),n)):(r=!0,a=!0,localStorage.setItem(Pi("download_version"),n)),r){const i={...t||{}};i.mcp_use_version=n,i.user_id=this.userId,i.event="package_download",i.first_download=a,i.language="typescript",i.source=this._source,i.package="inspector",await this._scarfClient.logEvent(i)}}catch{}}async trackInspectorOpen(t){const n=new zce(t);await this.capture(n)}}const Gce=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Wce=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,r)=>r?r.toUpperCase():n.toLowerCase()),EU=e=>{const t=Wce(e);return t.charAt(0).toUpperCase()+t.slice(1)},zH=(...e)=>e.filter((t,n,r)=>!!t&&t.trim()!==""&&r.indexOf(t)===n).join(" ").trim(),Kce=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};var Yce={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 Zce=b.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:a="",children:o,iconNode:i,...l},u)=>b.createElement("svg",{ref:u,...Yce,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:zH("lucide",a),...!o&&!Kce(l)&&{"aria-hidden":"true"},...l},[...i.map(([f,m])=>b.createElement(f,m)),...Array.isArray(o)?o:[o]]));const ht=(e,t)=>{const n=b.forwardRef(({className:r,...a},o)=>b.createElement(Zce,{ref:o,iconNode:t,className:zH(`lucide-${Gce(EU(e))}`,`lucide-${e}`,r),...a}));return n.displayName=EU(e),n};const qce=[["path",{d:"M12 17V3",key:"1cwfxf"}],["path",{d:"m6 11 6 6 6-6",key:"12ii2o"}],["path",{d:"M19 21H5",key:"150jfl"}]],Xce=ht("arrow-down-to-line",qce);const Jce=[["path",{d:"m18 9-6-6-6 6",key:"kcunyi"}],["path",{d:"M12 3v14",key:"7cf3v8"}],["path",{d:"M5 21h14",key:"11awu3"}]],Qce=ht("arrow-up-from-line",Jce);const eue=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],tue=ht("arrow-up",eue);const nue=[["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"}]],ZN=ht("bell",nue);const rue=[["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"}]],FH=ht("brush",rue);const aue=[["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"}]],oue=ht("bug",aue);const sue=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Or=ht("check",sue);const iue=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],hs=ht("chevron-down",iue);const lue=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],rw=ht("chevron-left",lue);const cue=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],BH=ht("chevron-right",cue);const uue=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],due=ht("chevron-up",uue);const fue=[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]],pue=ht("chevrons-up-down",fue);const mue=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}]],SU=ht("circle-minus",mue);const hue=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],fm=ht("clock",hue);const gue=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],qN=ht("code",gue);const bue=[["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"}]],yue=ht("cog",bue);const vue=[["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"}]],wue=ht("command",vue);const xue=[["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"}]],wr=ht("copy",xue);const Eue=[["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"}]],aw=ht("database",Eue);const Sue=[["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"}]],rh=ht("download",Sue);const _ue=[["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"}]],Tue=ht("ellipsis-vertical",_ue);const Nue=[["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"}]],f_=ht("external-link",Nue);const Cue=[["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"}]],HH=ht("eye-off",Cue);const Rue=[["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"}]],p_=ht("eye",Rue);const kue=[["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"}]],Aue=ht("file-code",kue);const Iue=[["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"}]],Oue=ht("file-image",Iue);const Due=[["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"}]],XN=ht("file-text",Due);const Lue=[["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"}]],Mue=ht("file",Lue);const jue=[["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"}]],Pue=ht("folder-open",jue);const $ue=[["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"}]],Uue=ht("globe",$ue);const zue=[["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"}]],Fue=ht("grip-vertical",zue);const Bue=[["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"}]],VH=ht("hash",Bue);const Hue=[["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"}]],pm=ht("history",Hue);const Vue=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],Fp=ht("info",Vue);const Gue=[["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"}]],GH=ht("key",Gue);const Wue=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],cl=ht("loader-circle",Wue);const Kue=[["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"}]],JN=ht("maximize-2",Kue);const Yue=[["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"}]],mm=ht("maximize",Yue);const Zue=[["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"}]],que=ht("message-circle",Zue);const Xue=[["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"}]],hm=ht("message-square",Xue);const Jue=[["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"}]],WH=ht("minimize",Jue);const Que=[["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"}]],_U=ht("monitor",Que);const ede=[["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"}]],TU=ht("moon",ede);const tde=[["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"}]],nde=ht("picture-in-picture",tde);const rde=[["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"}]],KH=ht("play",rde);const ade=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],gm=ht("plus",ade);const ode=[["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"}]],NU=ht("rotate-ccw",ode);const sde=[["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"}]],QN=ht("save",sde);const ide=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],lf=ht("search",ide);const lde=[["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"}]],cde=ht("send",lde);const ude=[["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"}]],YH=ht("server",ude);const dde=[["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"}]],Ju=ht("settings",dde);const fde=[["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"}]],pde=ht("shield",fde);const mde=[["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"}]],hde=ht("sparkles",mde);const gde=[["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"}]],ZH=ht("square-check-big",gde);const bde=[["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"}]],yde=ht("square-pen",bde);const vde=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],wde=ht("square",vde);const xde=[["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"}]],CU=ht("sun-dim",xde);const Ede=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],$E=ht("terminal",Ede);const Sde=[["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"}]],ti=ht("trash-2",Sde);const _de=[["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"}]],Tde=ht("trash",_de);const Nde=[["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"}]],dc=ht("wrench",Nde);const Cde=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],ys=ht("x",Cde);const Rde=[["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"}]],bm=ht("zap",Rde);var qH=e=>{throw TypeError(e)},kde=(e,t,n)=>t.has(e)||qH("Cannot "+n),UE=(e,t,n)=>(kde(e,t,"read from private field"),n?n.call(e):t.get(e)),Ade=(e,t,n)=>t.has(e)?qH("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Ide=(e=>(e.Pop="POP",e.Push="PUSH",e.Replace="REPLACE",e))(Ide||{}),RU="popstate";function XH(e={}){let{initialEntries:t=["/"],initialIndex:n,v5Compat:r=!1}=e,a;a=t.map((y,E)=>m(y,typeof y=="string"?null:y.state,E===0?"default":void 0));let o=u(n??a.length-1),i="POP",l=null;function u(y){return Math.min(Math.max(y,0),a.length-1)}function f(){return a[o]}function m(y,E=null,x){let w=ni(a?f().pathname:"/",y,E,x);return Un(w.pathname.charAt(0)==="/",`relative pathnames are not supported in memory history: ${JSON.stringify(y)}`),w}function h(y){return typeof y=="string"?y:ga(y)}return{get index(){return o},get action(){return i},get location(){return f()},createHref:h,createURL(y){return new URL(h(y),"http://localhost")},encodeLocation(y){let E=typeof y=="string"?Ro(y):y;return{pathname:E.pathname||"",search:E.search||"",hash:E.hash||""}},push(y,E){i="PUSH";let x=m(y,E);o+=1,a.splice(o,a.length,x),r&&l&&l({action:i,location:x,delta:1})},replace(y,E){i="REPLACE";let x=m(y,E);a[o]=x,r&&l&&l({action:i,location:x,delta:0})},go(y){i="POP";let E=u(o+y),x=a[E];o=E,l&&l({action:i,location:x,delta:y})},listen(y){return l=y,()=>{l=null}}}}function JH(e={}){function t(r,a){let{pathname:o,search:i,hash:l}=r.location;return ni("",{pathname:o,search:i,hash:l},a.state&&a.state.usr||null,a.state&&a.state.key||"default")}function n(r,a){return typeof a=="string"?a:ga(a)}return eV(t,n,null,e)}function QH(e={}){function t(a,o){let{pathname:i="/",search:l="",hash:u=""}=Ro(a.location.hash.substring(1));return!i.startsWith("/")&&!i.startsWith(".")&&(i="/"+i),ni("",{pathname:i,search:l,hash:u},o.state&&o.state.usr||null,o.state&&o.state.key||"default")}function n(a,o){let i=a.document.querySelector("base"),l="";if(i&&i.getAttribute("href")){let u=a.location.href,f=u.indexOf("#");l=f===-1?u:u.slice(0,f)}return l+"#"+(typeof o=="string"?o:ga(o))}function r(a,o){Un(a.pathname.charAt(0)==="/",`relative pathnames are not supported in hash history.push(${JSON.stringify(o)})`)}return eV(t,n,r,e)}function Et(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function Un(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function Ode(){return Math.random().toString(36).substring(2,10)}function kU(e,t){return{usr:e.state,key:e.key,idx:t}}function ni(e,t,n=null,r){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?Ro(t):t,state:n,key:t&&t.key||r||Ode()}}function ga({pathname:e="/",search:t="",hash:n=""}){return t&&t!=="?"&&(e+=t.charAt(0)==="?"?t:"?"+t),n&&n!=="#"&&(e+=n.charAt(0)==="#"?n:"#"+n),e}function Ro(e){let t={};if(e){let n=e.indexOf("#");n>=0&&(t.hash=e.substring(n),e=e.substring(0,n));let r=e.indexOf("?");r>=0&&(t.search=e.substring(r),e=e.substring(0,r)),e&&(t.pathname=e)}return t}function eV(e,t,n,r={}){let{window:a=document.defaultView,v5Compat:o=!1}=r,i=a.history,l="POP",u=null,f=m();f==null&&(f=0,i.replaceState({...i.state,idx:f},""));function m(){return(i.state||{idx:null}).idx}function h(){l="POP";let w=m(),S=w==null?null:w-f;f=w,u&&u({action:l,location:x.location,delta:S})}function g(w,S){l="PUSH";let _=ni(x.location,w,S);n&&n(_,w),f=m()+1;let T=kU(_,f),A=x.createHref(_);try{i.pushState(T,"",A)}catch(R){if(R instanceof DOMException&&R.name==="DataCloneError")throw R;a.location.assign(A)}o&&u&&u({action:l,location:x.location,delta:1})}function y(w,S){l="REPLACE";let _=ni(x.location,w,S);n&&n(_,w),f=m();let T=kU(_,f),A=x.createHref(_);i.replaceState(T,"",A),o&&u&&u({action:l,location:x.location,delta:0})}function E(w){return tV(w)}let x={get action(){return l},get location(){return e(a,i)},listen(w){if(u)throw new Error("A history only accepts one active listener");return a.addEventListener(RU,h),u=w,()=>{a.removeEventListener(RU,h),u=null}},createHref(w){return t(a,w)},createURL:E,encodeLocation(w){let S=E(w);return{pathname:S.pathname,search:S.search,hash:S.hash}},push:g,replace:y,go(w){return i.go(w)}};return x}function tV(e,t=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),Et(n,"No window.location.(origin|href) available to create URL");let r=typeof e=="string"?e:ga(e);return r=r.replace(/ $/,"%20"),!t&&r.startsWith("//")&&(r=n+r),new URL(r,n)}function VTe(e){return{defaultValue:e}}var kp,ju=class{constructor(e){if(Ade(this,kp,new Map),e)for(let[t,n]of e)this.set(t,n)}get(e){if(UE(this,kp).has(e))return UE(this,kp).get(e);if(e.defaultValue!==void 0)return e.defaultValue;throw new Error("No value found for context")}set(e,t){UE(this,kp).set(e,t)}};kp=new WeakMap;var Dde=new Set(["lazy","caseSensitive","path","id","index","children"]);function Lde(e){return Dde.has(e)}var Mde=new Set(["lazy","caseSensitive","path","id","index","middleware","children"]);function jde(e){return Mde.has(e)}function Pde(e){return e.index===!0}function fc(e,t,n=[],r={},a=!1){return e.map((o,i)=>{let l=[...n,String(i)],u=typeof o.id=="string"?o.id:l.join("-");if(Et(o.index!==!0||!o.children,"Cannot specify children on an index route"),Et(a||!r[u],`Found a route id collision on id "${u}". Route id's must be globally unique within Data Router usages`),Pde(o)){let f={...o,id:u};return r[u]=AU(f,t(f)),f}else{let f={...o,id:u,children:void 0};return r[u]=AU(f,t(f)),o.children&&(f.children=fc(o.children,t,l,r,a)),f}})}function AU(e,t){return Object.assign(e,{...t,...typeof t.lazy=="object"&&t.lazy!=null?{lazy:{...e.lazy,...t.lazy}}:{}})}function Uo(e,t,n="/"){return Ap(e,t,n,!1)}function Ap(e,t,n,r){let a=typeof t=="string"?Ro(t):t,o=Na(a.pathname||"/",n);if(o==null)return null;let i=rV(e);$de(i);let l=null;for(let u=0;l==null&&u<i.length;++u){let f=sV(o);l=Kde(i[u],f,r)}return l}function nV(e,t){let{route:n,pathname:r,params:a}=e;return{id:n.id,pathname:r,params:a,data:t[n.id],loaderData:t[n.id],handle:n.handle}}function rV(e,t=[],n=[],r="",a=!1){let o=(i,l,u=a,f)=>{let m={relativePath:f===void 0?i.path||"":f,caseSensitive:i.caseSensitive===!0,childrenIndex:l,route:i};if(m.relativePath.startsWith("/")){if(!m.relativePath.startsWith(r)&&u)return;Et(m.relativePath.startsWith(r),`Absolute route path "${m.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),m.relativePath=m.relativePath.slice(r.length)}let h=is([r,m.relativePath]),g=n.concat(m);i.children&&i.children.length>0&&(Et(i.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${h}".`),rV(i.children,t,g,h,u)),!(i.path==null&&!i.index)&&t.push({path:h,score:Gde(h,i.index),routesMeta:g})};return e.forEach((i,l)=>{if(i.path===""||!i.path?.includes("?"))o(i,l);else for(let u of aV(i.path))o(i,l,!0,u)}),t}function aV(e){let t=e.split("/");if(t.length===0)return[];let[n,...r]=t,a=n.endsWith("?"),o=n.replace(/\?$/,"");if(r.length===0)return a?[o,""]:[o];let i=aV(r.join("/")),l=[];return l.push(...i.map(u=>u===""?o:[o,u].join("/"))),a&&l.push(...i),l.map(u=>e.startsWith("/")&&u===""?"/":u)}function $de(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:Wde(t.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}var Ude=/^:[\w-]+$/,zde=3,Fde=2,Bde=1,Hde=10,Vde=-2,IU=e=>e==="*";function Gde(e,t){let n=e.split("/"),r=n.length;return n.some(IU)&&(r+=Vde),t&&(r+=Fde),n.filter(a=>!IU(a)).reduce((a,o)=>a+(Ude.test(o)?zde:o===""?Bde:Hde),r)}function Wde(e,t){return e.length===t.length&&e.slice(0,-1).every((r,a)=>r===t[a])?e[e.length-1]-t[t.length-1]:0}function Kde(e,t,n=!1){let{routesMeta:r}=e,a={},o="/",i=[];for(let l=0;l<r.length;++l){let u=r[l],f=l===r.length-1,m=o==="/"?t:t.slice(o.length)||"/",h=ym({path:u.relativePath,caseSensitive:u.caseSensitive,end:f},m),g=u.route;if(!h&&f&&n&&!r[r.length-1].route.index&&(h=ym({path:u.relativePath,caseSensitive:u.caseSensitive,end:!1},m)),!h)return null;Object.assign(a,h.params),i.push({params:a,pathname:is([o,h.pathname]),pathnameBase:qde(is([o,h.pathnameBase])),route:g}),h.pathnameBase!=="/"&&(o=is([o,h.pathnameBase]))}return i}function GTe(e,t={}){let n=e;n.endsWith("*")&&n!=="*"&&!n.endsWith("/*")&&(Un(!1,`Route path "${n}" will be treated as if it were "${n.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${n.replace(/\*$/,"/*")}".`),n=n.replace(/\*$/,"/*"));const r=n.startsWith("/")?"/":"",a=i=>i==null?"":typeof i=="string"?i:String(i),o=n.split(/\/+/).map((i,l,u)=>{if(l===u.length-1&&i==="*")return a(t["*"]);const m=i.match(/^:([\w-]+)(\??)(.*)/);if(m){const[,h,g,y]=m;let E=t[h];return Et(g==="?"||E!=null,`Missing ":${h}" param`),encodeURIComponent(a(E))+y}return i.replace(/\?$/g,"")}).filter(i=>!!i);return r+o.join("/")}function ym(e,t){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[n,r]=oV(e.path,e.caseSensitive,e.end),a=t.match(n);if(!a)return null;let o=a[0],i=o.replace(/(.)\/+$/,"$1"),l=a.slice(1);return{params:r.reduce((f,{paramName:m,isOptional:h},g)=>{if(m==="*"){let E=l[g]||"";i=o.slice(0,o.length-E.length).replace(/(.)\/+$/,"$1")}const y=l[g];return h&&!y?f[m]=void 0:f[m]=(y||"").replace(/%2F/g,"/"),f},{}),pathname:o,pathnameBase:i,pattern:e}}function oV(e,t=!1,n=!0){Un(e==="*"||!e.endsWith("*")||e.endsWith("/*"),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,"/*")}".`);let r=[],a="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(i,l,u)=>(r.push({paramName:l,isOptional:u!=null}),u?"/?([^\\/]+)?":"/([^\\/]+)")).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return e.endsWith("*")?(r.push({paramName:"*"}),a+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?a+="\\/*$":e!==""&&e!=="/"&&(a+="(?:(?=\\/|$))"),[new RegExp(a,t?void 0:"i"),r]}function sV(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return Un(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`),e}}function Na(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith("/")?t.length-1:t.length,r=e.charAt(n);return r&&r!=="/"?null:e.slice(n)||"/"}function Yde({basename:e,pathname:t}){return t==="/"?e:is([e,t])}var iV=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,ow=e=>iV.test(e);function Zde(e,t="/"){let{pathname:n,search:r="",hash:a=""}=typeof e=="string"?Ro(e):e,o;if(n)if(ow(n))o=n;else{if(n.includes("//")){let i=n;n=n.replace(/\/\/+/g,"/"),Un(!1,`Pathnames cannot have embedded double slashes - normalizing ${i} -> ${n}`)}n.startsWith("/")?o=OU(n.substring(1),"/"):o=OU(n,t)}else o=t;return{pathname:o,search:Xde(r),hash:Jde(a)}}function OU(e,t){let n=t.replace(/\/+$/,"").split("/");return e.split("/").forEach(a=>{a===".."?n.length>1&&n.pop():a!=="."&&n.push(a)}),n.length>1?n.join("/"):"/"}function zE(e,t,n,r){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(r)}]. Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function lV(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function sw(e){let t=lV(e);return t.map((n,r)=>r===t.length-1?n.pathname:n.pathnameBase)}function iw(e,t,n,r=!1){let a;typeof e=="string"?a=Ro(e):(a={...e},Et(!a.pathname||!a.pathname.includes("?"),zE("?","pathname","search",a)),Et(!a.pathname||!a.pathname.includes("#"),zE("#","pathname","hash",a)),Et(!a.search||!a.search.includes("#"),zE("#","search","hash",a)));let o=e===""||a.pathname==="",i=o?"/":a.pathname,l;if(i==null)l=n;else{let h=t.length-1;if(!r&&i.startsWith("..")){let g=i.split("/");for(;g[0]==="..";)g.shift(),h-=1;a.pathname=g.join("/")}l=h>=0?t[h]:"/"}let u=Zde(a,l),f=i&&i!=="/"&&i.endsWith("/"),m=(o||i===".")&&n.endsWith("/");return!u.pathname.endsWith("/")&&(f||m)&&(u.pathname+="/"),u}var is=e=>e.join("/").replace(/\/\/+/g,"/"),qde=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),Xde=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,Jde=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e,Qde=class{constructor(e,t){this.type="DataWithResponseInit",this.data=e,this.init=t||null}};function efe(e,t){return new Qde(e,typeof t=="number"?{status:t}:t)}var eC=(e,t=302)=>{let n=t;typeof n=="number"?n={status:n}:typeof n.status>"u"&&(n.status=302);let r=new Headers(n.headers);return r.set("Location",e),new Response(null,{...n,headers:r})},WTe=(e,t)=>{let n=eC(e,t);return n.headers.set("X-Remix-Reload-Document","true"),n},KTe=(e,t)=>{let n=eC(e,t);return n.headers.set("X-Remix-Replace","true"),n},vs=class{constructor(e,t,n,r=!1){this.status=e,this.statusText=t||"",this.internal=r,n instanceof Error?(this.data=n.toString(),this.error=n):this.data=n}};function So(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function Ks(e){return e.map(t=>t.route.path).filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}var cV=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function uV(e,t){let n=e;if(typeof n!="string"||!iV.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,a=!1;if(cV)try{let o=new URL(window.location.href),i=n.startsWith("//")?new URL(o.protocol+n):new URL(n),l=Na(i.pathname,t);i.origin===o.origin&&l!=null?n=l+i.search+i.hash:a=!0}catch{Un(!1,`<Link to="${n}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:r,isExternal:a,to:n}}var qi=Symbol("Uninstrumented");function dV(e,t){let n={lazy:[],"lazy.loader":[],"lazy.action":[],"lazy.middleware":[],middleware:[],loader:[],action:[]};e.forEach(a=>a({id:t.id,index:t.index,path:t.path,instrument(o){let i=Object.keys(n);for(let l of i)o[l]&&n[l].push(o[l])}}));let r={};if(typeof t.lazy=="function"&&n.lazy.length>0){let a=Ql(n.lazy,t.lazy,()=>{});a&&(r.lazy=a)}if(typeof t.lazy=="object"){let a=t.lazy;["middleware","loader","action"].forEach(o=>{let i=a[o],l=n[`lazy.${o}`];if(typeof i=="function"&&l.length>0){let u=Ql(l,i,()=>{});u&&(r.lazy=Object.assign(r.lazy||{},{[o]:u}))}})}return["loader","action"].forEach(a=>{let o=t[a];if(typeof o=="function"&&n[a].length>0){let i=o[qi]??o,l=Ql(n[a],i,(...u)=>DU(u[0]));l&&(a==="loader"&&i.hydrate===!0&&(l.hydrate=!0),l[qi]=i,r[a]=l)}}),t.middleware&&t.middleware.length>0&&n.middleware.length>0&&(r.middleware=t.middleware.map(a=>{let o=a[qi]??a,i=Ql(n.middleware,o,(...l)=>DU(l[0]));return i?(i[qi]=o,i):a})),r}function tfe(e,t){let n={navigate:[],fetch:[]};if(t.forEach(r=>r({instrument(a){let o=Object.keys(a);for(let i of o)a[i]&&n[i].push(a[i])}})),n.navigate.length>0){let r=e.navigate[qi]??e.navigate,a=Ql(n.navigate,r,(...o)=>{let[i,l]=o;return{to:typeof i=="number"||typeof i=="string"?i:i?ga(i):".",...LU(e,l??{})}});a&&(a[qi]=r,e.navigate=a)}if(n.fetch.length>0){let r=e.fetch[qi]??e.fetch,a=Ql(n.fetch,r,(...o)=>{let[i,,l,u]=o;return{href:l??".",fetcherKey:i,...LU(e,u??{})}});a&&(a[qi]=r,e.fetch=a)}return e}function YTe(e,t){let n={request:[]};t.forEach(a=>a({instrument(o){let i=Object.keys(o);for(let l of i)o[l]&&n[l].push(o[l])}}));let r=e;return n.request.length>0&&(r=Ql(n.request,e,(...a)=>{let[o,i]=a;return{request:pV(o),context:i!=null?mV(i):i}})),r}function Ql(e,t,n){return e.length===0?null:async(...r)=>{let a=await fV(e,n(...r),()=>t(...r),e.length-1);if(a.type==="error")throw a.value;return a.value}}async function fV(e,t,n,r){let a=e[r],o;if(a){let i,l=async()=>(i?console.error("You cannot call instrumented handlers more than once"):i=fV(e,t,n,r-1),o=await i,Et(o,"Expected a result"),o.type==="error"&&o.value instanceof Error?{status:"error",error:o.value}:{status:"success",error:void 0});try{await a(l,t)}catch(u){console.error("An instrumentation function threw an error:",u)}i||await l(),await i}else try{o={type:"success",value:await n()}}catch(i){o={type:"error",value:i}}return o||{type:"error",value:new Error("No result assigned in instrumentation chain.")}}function DU(e){let{request:t,context:n,params:r,unstable_pattern:a}=e;return{request:pV(t),params:{...r},unstable_pattern:a,context:mV(n)}}function LU(e,t){return{currentUrl:ga(e.state.location),..."formMethod"in t?{formMethod:t.formMethod}:{},..."formEncType"in t?{formEncType:t.formEncType}:{},..."formData"in t?{formData:t.formData}:{},..."body"in t?{body:t.body}:{}}}function pV(e){return{method:e.method,url:e.url,headers:{get:(...t)=>e.headers.get(...t)}}}function mV(e){if(rfe(e)){let t={...e};return Object.freeze(t),t}else return{get:t=>e.get(t)}}var nfe=Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function rfe(e){if(e===null||typeof e!="object")return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||t===null||Object.getOwnPropertyNames(t).sort().join("\0")===nfe}var hV=["POST","PUT","PATCH","DELETE"],afe=new Set(hV),ofe=["GET",...hV],sfe=new Set(ofe),gV=new Set([301,302,303,307,308]),ife=new Set([307,308]),iy={state:"idle",location:void 0,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0},tC={state:"idle",data:void 0,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0},ql={state:"unblocked",proceed:void 0,reset:void 0,location:void 0},bV=e=>({hasErrorBoundary:!!e.hasErrorBoundary}),yV="remix-router-transitions",vV=Symbol("ResetLoaderData");function nC(e){const t=e.window?e.window:typeof window<"u"?window:void 0,n=typeof t<"u"&&typeof t.document<"u"&&typeof t.document.createElement<"u";Et(e.routes.length>0,"You must provide a non-empty routes array to createRouter");let r=e.hydrationRouteProperties||[],a=e.mapRouteProperties||bV,o=a;if(e.unstable_instrumentations){let se=e.unstable_instrumentations;o=de=>({...a(de),...dV(se.map(ye=>ye.route).filter(Boolean),de)})}let i={},l=fc(e.routes,o,void 0,i),u,f=e.basename||"/";f.startsWith("/")||(f=`/${f}`);let m=e.dataStrategy||hfe,h={...e.future},g=null,y=new Set,E=null,x=null,w=null,S=e.hydrationData!=null,_=Uo(l,e.history.location,f),T=!1,A=null,R;if(_==null&&!e.patchRoutesOnNavigation){let se=Ar(404,{pathname:e.history.location.pathname}),{matches:de,route:ye}=Pu(l);R=!0,_=de,A={[ye.id]:se}}else if(_&&!e.hydrationData&&zt(_,l,e.history.location.pathname).active&&(_=null),_)if(_.some(se=>se.route.lazy))R=!1;else if(!_.some(se=>rC(se.route)))R=!0;else{let se=e.hydrationData?e.hydrationData.loaderData:null,de=e.hydrationData?e.hydrationData.errors:null;if(de){let ye=_.findIndex(ke=>de[ke.route.id]!==void 0);R=_.slice(0,ye+1).every(ke=>!h_(ke.route,se,de))}else R=_.every(ye=>!h_(ye.route,se,de))}else{R=!1,_=[];let se=zt(null,l,e.history.location.pathname);se.active&&se.matches&&(T=!0,_=se.matches)}let k,C={historyAction:e.history.action,location:e.history.location,matches:_,initialized:R,navigation:iy,restoreScrollPosition:e.hydrationData!=null?!1:null,preventScrollReset:!1,revalidation:"idle",loaderData:e.hydrationData&&e.hydrationData.loaderData||{},actionData:e.hydrationData&&e.hydrationData.actionData||null,errors:e.hydrationData&&e.hydrationData.errors||A,fetchers:new Map,blockers:new Map},O="POP",M=null,L=!1,$,H=!1,V=new Map,Z=null,ne=!1,G=!1,Y=new Set,F=new Map,re=0,ee=-1,j=new Map,B=new Set,z=new Map,D=new Map,P=new Set,W=new Map,K,ae=null;function oe(){if(g=e.history.listen(({action:se,location:de,delta:ye})=>{if(K){K(),K=void 0;return}Un(W.size===0||ye!=null,"You are trying to use a blocker on a POP navigation to a location that was not created by @remix-run/router. This will fail silently in production. This can happen if you are navigating outside the router via `window.history.pushState`/`window.location.hash` instead of using router navigation APIs. This can also happen if you are using createHashRouter and the user manually changes the URL.");let ke=$t({currentLocation:C.location,nextLocation:de,historyAction:se});if(ke&&ye!=null){let ge=new Promise(Ce=>{K=Ce});e.history.go(ye*-1),Pt(ke,{state:"blocked",location:de,proceed(){Pt(ke,{state:"proceeding",proceed:void 0,reset:void 0,location:de}),ge.then(()=>e.history.go(ye))},reset(){let Ce=new Map(C.blockers);Ce.set(ke,ql),J({blockers:Ce})}}),M?.resolve(),M=null;return}return Ne(se,de)}),n){Efe(t,V);let se=()=>Sfe(t,V);t.addEventListener("pagehide",se),Z=()=>t.removeEventListener("pagehide",se)}return C.initialized||Ne("POP",C.location,{initialHydration:!0}),k}function le(){g&&g(),Z&&Z(),y.clear(),$&&$.abort(),C.fetchers.forEach((se,de)=>ot(de)),C.blockers.forEach((se,de)=>Ct(de))}function Q(se){return y.add(se),()=>y.delete(se)}function J(se,de={}){se.matches&&(se.matches=se.matches.map(ge=>{let Ce=i[ge.route.id],Te=ge.route;return Te.element!==Ce.element||Te.errorElement!==Ce.errorElement||Te.hydrateFallbackElement!==Ce.hydrateFallbackElement?{...ge,route:Ce}:ge})),C={...C,...se};let ye=[],ke=[];C.fetchers.forEach((ge,Ce)=>{ge.state==="idle"&&(P.has(Ce)?ye.push(Ce):ke.push(Ce))}),P.forEach(ge=>{!C.fetchers.has(ge)&&!F.has(ge)&&ye.push(ge)}),[...y].forEach(ge=>ge(C,{deletedFetchers:ye,newErrors:se.errors??null,viewTransitionOpts:de.viewTransitionOpts,flushSync:de.flushSync===!0})),ye.forEach(ge=>ot(ge)),ke.forEach(ge=>C.fetchers.delete(ge))}function q(se,de,{flushSync:ye}={}){let ke=C.actionData!=null&&C.navigation.formMethod!=null&&Zr(C.navigation.formMethod)&&C.navigation.state==="loading"&&se.state?._isRedirect!==!0,ge;de.actionData?Object.keys(de.actionData).length>0?ge=de.actionData:ge=null:ke?ge=C.actionData:ge=null;let Ce=de.loaderData?WU(C.loaderData,de.loaderData,de.matches||[],de.errors):C.loaderData,Te=C.blockers;Te.size>0&&(Te=new Map(Te),Te.forEach((Je,Qe)=>Te.set(Qe,ql)));let Ae=ne?!1:Ht(se,de.matches||C.matches),$e=L===!0||C.navigation.formMethod!=null&&Zr(C.navigation.formMethod)&&se.state?._isRedirect!==!0;u&&(l=u,u=void 0),ne||O==="POP"||(O==="PUSH"?e.history.push(se,se.state):O==="REPLACE"&&e.history.replace(se,se.state));let Xe;if(O==="POP"){let Je=V.get(C.location.pathname);Je&&Je.has(se.pathname)?Xe={currentLocation:C.location,nextLocation:se}:V.has(se.pathname)&&(Xe={currentLocation:se,nextLocation:C.location})}else if(H){let Je=V.get(C.location.pathname);Je?Je.add(se.pathname):(Je=new Set([se.pathname]),V.set(C.location.pathname,Je)),Xe={currentLocation:C.location,nextLocation:se}}J({...de,actionData:ge,loaderData:Ce,historyAction:O,location:se,initialized:!0,navigation:iy,revalidation:"idle",restoreScrollPosition:Ae,preventScrollReset:$e,blockers:Te},{viewTransitionOpts:Xe,flushSync:ye===!0}),O="POP",L=!1,H=!1,ne=!1,G=!1,M?.resolve(),M=null,ae?.resolve(),ae=null}async function ie(se,de){if(M?.resolve(),M=null,typeof se=="number"){M||(M=ZU());let tt=M.promise;return e.history.go(se),tt}let ye=m_(C.location,C.matches,f,se,de?.fromRouteId,de?.relative),{path:ke,submission:ge,error:Ce}=jU(!1,ye,de),Te=C.location,Ae=ni(C.location,ke,de&&de.state);Ae={...Ae,...e.history.encodeLocation(Ae)};let $e=de&&de.replace!=null?de.replace:void 0,Xe="PUSH";$e===!0?Xe="REPLACE":$e===!1||ge!=null&&Zr(ge.formMethod)&&ge.formAction===C.location.pathname+C.location.search&&(Xe="REPLACE");let Je=de&&"preventScrollReset"in de?de.preventScrollReset===!0:void 0,Qe=(de&&de.flushSync)===!0,Mt=$t({currentLocation:Te,nextLocation:Ae,historyAction:Xe});if(Mt){Pt(Mt,{state:"blocked",location:Ae,proceed(){Pt(Mt,{state:"proceeding",proceed:void 0,reset:void 0,location:Ae}),ie(se,de)},reset(){let tt=new Map(C.blockers);tt.set(Mt,ql),J({blockers:tt})}});return}await Ne(Xe,Ae,{submission:ge,pendingError:Ce,preventScrollReset:Je,replace:de&&de.replace,enableViewTransition:de&&de.viewTransition,flushSync:Qe,callSiteDefaultShouldRevalidate:de&&de.unstable_defaultShouldRevalidate})}function he(){ae||(ae=ZU()),it(),J({revalidation:"loading"});let se=ae.promise;return C.navigation.state==="submitting"?se:C.navigation.state==="idle"?(Ne(C.historyAction,C.location,{startUninterruptedRevalidation:!0}),se):(Ne(O||C.historyAction,C.navigation.location,{overrideNavigation:C.navigation,enableViewTransition:H===!0}),se)}async function Ne(se,de,ye){$&&$.abort(),$=null,O=se,ne=(ye&&ye.startUninterruptedRevalidation)===!0,Ut(C.location,C.matches),L=(ye&&ye.preventScrollReset)===!0,H=(ye&&ye.enableViewTransition)===!0;let ke=u||l,ge=ye&&ye.overrideNavigation,Ce=ye?.initialHydration&&C.matches&&C.matches.length>0&&!T?C.matches:Uo(ke,de,f),Te=(ye&&ye.flushSync)===!0;if(Ce&&C.initialized&&!G&&bfe(C.location,de)&&!(ye&&ye.submission&&Zr(ye.submission.formMethod))){q(de,{matches:Ce},{flushSync:Te});return}let Ae=zt(Ce,ke,de.pathname);if(Ae.active&&Ae.matches&&(Ce=Ae.matches),!Ce){let{error:Rt,notFoundMatches:et,route:Ke}=Xt(de.pathname);q(de,{matches:et,loaderData:{},errors:{[Ke.id]:Rt}},{flushSync:Te});return}$=new AbortController;let $e=Su(e.history,de,$.signal,ye&&ye.submission),Xe=e.getContext?await e.getContext():new ju,Je;if(ye&&ye.pendingError)Je=[wo(Ce).route.id,{type:"error",error:ye.pendingError}];else if(ye&&ye.submission&&Zr(ye.submission.formMethod)){let Rt=await Ye($e,de,ye.submission,Ce,Xe,Ae.active,ye&&ye.initialHydration===!0,{replace:ye.replace,flushSync:Te});if(Rt.shortCircuited)return;if(Rt.pendingActionResult){let[et,Ke]=Rt.pendingActionResult;if(zr(Ke)&&So(Ke.error)&&Ke.error.status===404){$=null,q(de,{matches:Rt.matches,loaderData:{},errors:{[et]:Ke.error}});return}}Ce=Rt.matches||Ce,Je=Rt.pendingActionResult,ge=FE(de,ye.submission),Te=!1,Ae.active=!1,$e=Su(e.history,$e.url,$e.signal)}let{shortCircuited:Qe,matches:Mt,loaderData:tt,errors:xt}=await Pe($e,de,Ce,Xe,Ae.active,ge,ye&&ye.submission,ye&&ye.fetcherSubmission,ye&&ye.replace,ye&&ye.initialHydration===!0,Te,Je,ye&&ye.callSiteDefaultShouldRevalidate);Qe||($=null,q(de,{matches:Mt||Ce,...KU(Je),loaderData:tt,errors:xt}))}async function Ye(se,de,ye,ke,ge,Ce,Te,Ae={}){it();let $e=wfe(de,ye);if(J({navigation:$e},{flushSync:Ae.flushSync===!0}),Ce){let Qe=await Ln(ke,de.pathname,se.signal);if(Qe.type==="aborted")return{shortCircuited:!0};if(Qe.type==="error"){if(Qe.partialMatches.length===0){let{matches:tt,route:xt}=Pu(l);return{matches:tt,pendingActionResult:[xt.id,{type:"error",error:Qe.error}]}}let Mt=wo(Qe.partialMatches).route.id;return{matches:Qe.partialMatches,pendingActionResult:[Mt,{type:"error",error:Qe.error}]}}else if(Qe.matches)ke=Qe.matches;else{let{notFoundMatches:Mt,error:tt,route:xt}=Xt(de.pathname);return{matches:Mt,pendingActionResult:[xt.id,{type:"error",error:tt}]}}}let Xe,Je=Qu(ke,de);if(!Je.route.action&&!Je.route.lazy)Xe={type:"error",error:Ar(405,{method:se.method,pathname:de.pathname,routeId:Je.route.id})};else{let Qe=el(o,i,se,ke,Je,Te?[]:r,ge),Mt=await _e(se,Qe,ge,null);if(Xe=Mt[Je.route.id],!Xe){for(let tt of ke)if(Mt[tt.route.id]){Xe=Mt[tt.route.id];break}}if(se.signal.aborted)return{shortCircuited:!0}}if(Xi(Xe)){let Qe;return Ae&&Ae.replace!=null?Qe=Ae.replace:Qe=HU(Xe.response.headers.get("Location"),new URL(se.url),f,e.history)===C.location.pathname+C.location.search,await Ee(se,Xe,!0,{submission:ye,replace:Qe}),{shortCircuited:!0}}if(zr(Xe)){let Qe=wo(ke,Je.route.id);return(Ae&&Ae.replace)!==!0&&(O="PUSH"),{matches:ke,pendingActionResult:[Qe.route.id,Xe,Je.route.id]}}return{matches:ke,pendingActionResult:[Je.route.id,Xe]}}async function Pe(se,de,ye,ke,ge,Ce,Te,Ae,$e,Xe,Je,Qe,Mt){let tt=Ce||FE(de,Te),xt=Te||Ae||YU(tt),Rt=!ne&&!Xe;if(ge){if(Rt){let kt=Ue(Qe);J({navigation:tt,...kt!==void 0?{actionData:kt}:{}},{flushSync:Je})}let Ft=await Ln(ye,de.pathname,se.signal);if(Ft.type==="aborted")return{shortCircuited:!0};if(Ft.type==="error"){if(Ft.partialMatches.length===0){let{matches:xr,route:Wn}=Pu(l);return{matches:xr,loaderData:{},errors:{[Wn.id]:Ft.error}}}let kt=wo(Ft.partialMatches).route.id;return{matches:Ft.partialMatches,loaderData:{},errors:{[kt]:Ft.error}}}else if(Ft.matches)ye=Ft.matches;else{let{error:kt,notFoundMatches:xr,route:Wn}=Xt(de.pathname);return{matches:xr,loaderData:{},errors:{[Wn.id]:kt}}}}let et=u||l,{dsMatches:Ke,revalidatingFetchers:St}=PU(se,ke,o,i,e.history,C,ye,xt,de,Xe?[]:r,Xe===!0,G,Y,P,z,B,et,f,e.patchRoutesOnNavigation!=null,Qe,Mt);if(ee=++re,!e.dataStrategy&&!Ke.some(Ft=>Ft.shouldLoad)&&!Ke.some(Ft=>Ft.route.middleware&&Ft.route.middleware.length>0)&&St.length===0){let Ft=We();return q(de,{matches:ye,loaderData:{},errors:Qe&&zr(Qe[1])?{[Qe[0]]:Qe[1].error}:null,...KU(Qe),...Ft?{fetchers:new Map(C.fetchers)}:{}},{flushSync:Je}),{shortCircuited:!0}}if(Rt){let Ft={};if(!ge){Ft.navigation=tt;let kt=Ue(Qe);kt!==void 0&&(Ft.actionData=kt)}St.length>0&&(Ft.fetchers=st(St)),J(Ft,{flushSync:Je})}St.forEach(Ft=>{qt(Ft.key),Ft.controller&&F.set(Ft.key,Ft.controller)});let En=()=>St.forEach(Ft=>qt(Ft.key));$&&$.signal.addEventListener("abort",En);let{loaderResults:gt,fetcherResults:Fn}=await Be(Ke,St,se,ke);if(se.signal.aborted)return{shortCircuited:!0};$&&$.signal.removeEventListener("abort",En),St.forEach(Ft=>F.delete(Ft.key));let _t=Ob(gt);if(_t)return await Ee(se,_t.result,!0,{replace:$e}),{shortCircuited:!0};if(_t=Ob(Fn),_t)return B.add(_t.key),await Ee(se,_t.result,!0,{replace:$e}),{shortCircuited:!0};let{loaderData:Cn,errors:en}=GU(C,ye,gt,Qe,St,Fn);Xe&&C.errors&&(en={...C.errors,...en});let bn=We(),Xn=fe(ee),cr=bn||Xn||St.length>0;return{matches:ye,loaderData:Cn,errors:en,...cr?{fetchers:new Map(C.fetchers)}:{}}}function Ue(se){if(se&&!zr(se[1]))return{[se[0]]:se[1].data};if(C.actionData)return Object.keys(C.actionData).length===0?null:C.actionData}function st(se){return se.forEach(de=>{let ye=C.fetchers.get(de.key),ke=vp(void 0,ye?ye.data:void 0);C.fetchers.set(de.key,ke)}),new Map(C.fetchers)}async function Ve(se,de,ye,ke){qt(se);let ge=(ke&&ke.flushSync)===!0,Ce=u||l,Te=m_(C.location,C.matches,f,ye,de,ke?.relative),Ae=Uo(Ce,Te,f),$e=zt(Ae,Ce,Te);if($e.active&&$e.matches&&(Ae=$e.matches),!Ae){lt(se,de,Ar(404,{pathname:Te}),{flushSync:ge});return}let{path:Xe,submission:Je,error:Qe}=jU(!0,Te,ke);if(Qe){lt(se,de,Qe,{flushSync:ge});return}let Mt=e.getContext?await e.getContext():new ju,tt=(ke&&ke.preventScrollReset)===!0;if(Je&&Zr(Je.formMethod)){await ut(se,de,Xe,Ae,Mt,$e.active,ge,tt,Je,ke&&ke.unstable_defaultShouldRevalidate);return}z.set(se,{routeId:de,path:Xe}),await rt(se,de,Xe,Ae,Mt,$e.active,ge,tt,Je)}async function ut(se,de,ye,ke,ge,Ce,Te,Ae,$e,Xe){it(),z.delete(se);let Je=C.fetchers.get(se);qe(se,xfe($e,Je),{flushSync:Te});let Qe=new AbortController,Mt=Su(e.history,ye,Qe.signal,$e);if(Ce){let nn=await Ln(ke,new URL(Mt.url).pathname,Mt.signal,se);if(nn.type==="aborted")return;if(nn.type==="error"){lt(se,de,nn.error,{flushSync:Te});return}else if(nn.matches)ke=nn.matches;else{lt(se,de,Ar(404,{pathname:ye}),{flushSync:Te});return}}let tt=Qu(ke,ye);if(!tt.route.action&&!tt.route.lazy){let nn=Ar(405,{method:$e.formMethod,pathname:ye,routeId:de});lt(se,de,nn,{flushSync:Te});return}F.set(se,Qe);let xt=re,Rt=el(o,i,Mt,ke,tt,r,ge),et=await _e(Mt,Rt,ge,se),Ke=et[tt.route.id];if(!Ke){for(let nn of Rt)if(et[nn.route.id]){Ke=et[nn.route.id];break}}if(Mt.signal.aborted){F.get(se)===Qe&&F.delete(se);return}if(P.has(se)){if(Xi(Ke)||zr(Ke)){qe(se,Vs(void 0));return}}else{if(Xi(Ke))if(F.delete(se),ee>xt){qe(se,Vs(void 0));return}else return B.add(se),qe(se,vp($e)),Ee(Mt,Ke,!1,{fetcherSubmission:$e,preventScrollReset:Ae});if(zr(Ke)){lt(se,de,Ke.error);return}}let St=C.navigation.location||C.location,En=Su(e.history,St,Qe.signal),gt=u||l,Fn=C.navigation.state!=="idle"?Uo(gt,C.navigation.location,f):C.matches;Et(Fn,"Didn't find any matches after fetcher action");let _t=++re;j.set(se,_t);let Cn=vp($e,Ke.data);C.fetchers.set(se,Cn);let{dsMatches:en,revalidatingFetchers:bn}=PU(En,ge,o,i,e.history,C,Fn,$e,St,r,!1,G,Y,P,z,B,gt,f,e.patchRoutesOnNavigation!=null,[tt.route.id,Ke],Xe);bn.filter(nn=>nn.key!==se).forEach(nn=>{let va=nn.key,Oc=C.fetchers.get(va),ui=vp(void 0,Oc?Oc.data:void 0);C.fetchers.set(va,ui),qt(va),nn.controller&&F.set(va,nn.controller)}),J({fetchers:new Map(C.fetchers)});let Xn=()=>bn.forEach(nn=>qt(nn.key));Qe.signal.addEventListener("abort",Xn);let{loaderResults:cr,fetcherResults:Ft}=await Be(en,bn,En,ge);if(Qe.signal.aborted)return;if(Qe.signal.removeEventListener("abort",Xn),j.delete(se),F.delete(se),bn.forEach(nn=>F.delete(nn.key)),C.fetchers.has(se)){let nn=Vs(Ke.data);C.fetchers.set(se,nn)}let kt=Ob(cr);if(kt)return Ee(En,kt.result,!1,{preventScrollReset:Ae});if(kt=Ob(Ft),kt)return B.add(kt.key),Ee(En,kt.result,!1,{preventScrollReset:Ae});let{loaderData:xr,errors:Wn}=GU(C,Fn,cr,void 0,bn,Ft);fe(_t),C.navigation.state==="loading"&&_t>ee?(Et(O,"Expected pending action"),$&&$.abort(),q(C.navigation.location,{matches:Fn,loaderData:xr,errors:Wn,fetchers:new Map(C.fetchers)})):(J({errors:Wn,loaderData:WU(C.loaderData,xr,Fn,Wn),fetchers:new Map(C.fetchers)}),G=!1)}async function rt(se,de,ye,ke,ge,Ce,Te,Ae,$e){let Xe=C.fetchers.get(se);qe(se,vp($e,Xe?Xe.data:void 0),{flushSync:Te});let Je=new AbortController,Qe=Su(e.history,ye,Je.signal);if(Ce){let Ke=await Ln(ke,new URL(Qe.url).pathname,Qe.signal,se);if(Ke.type==="aborted")return;if(Ke.type==="error"){lt(se,de,Ke.error,{flushSync:Te});return}else if(Ke.matches)ke=Ke.matches;else{lt(se,de,Ar(404,{pathname:ye}),{flushSync:Te});return}}let Mt=Qu(ke,ye);F.set(se,Je);let tt=re,xt=el(o,i,Qe,ke,Mt,r,ge),et=(await _e(Qe,xt,ge,se))[Mt.route.id];if(F.get(se)===Je&&F.delete(se),!Qe.signal.aborted){if(P.has(se)){qe(se,Vs(void 0));return}if(Xi(et))if(ee>tt){qe(se,Vs(void 0));return}else{B.add(se),await Ee(Qe,et,!1,{preventScrollReset:Ae});return}if(zr(et)){lt(se,de,et.error);return}qe(se,Vs(et.data))}}async function Ee(se,de,ye,{submission:ke,fetcherSubmission:ge,preventScrollReset:Ce,replace:Te}={}){ye||(M?.resolve(),M=null),de.response.headers.has("X-Remix-Revalidate")&&(G=!0);let Ae=de.response.headers.get("Location");Et(Ae,"Expected a Location header on the redirect Response"),Ae=HU(Ae,new URL(se.url),f,e.history);let $e=ni(C.location,Ae,{_isRedirect:!0});if(n){let xt=!1;if(de.response.headers.has("X-Remix-Reload-Document"))xt=!0;else if(ow(Ae)){const Rt=tV(Ae,!0);xt=Rt.origin!==t.location.origin||Na(Rt.pathname,f)==null}if(xt){Te?t.location.replace(Ae):t.location.assign(Ae);return}}$=null;let Xe=Te===!0||de.response.headers.has("X-Remix-Replace")?"REPLACE":"PUSH",{formMethod:Je,formAction:Qe,formEncType:Mt}=C.navigation;!ke&&!ge&&Je&&Qe&&Mt&&(ke=YU(C.navigation));let tt=ke||ge;if(ife.has(de.response.status)&&tt&&Zr(tt.formMethod))await Ne(Xe,$e,{submission:{...tt,formAction:Ae},preventScrollReset:Ce||L,enableViewTransition:ye?H:void 0});else{let xt=FE($e,ke);await Ne(Xe,$e,{overrideNavigation:xt,fetcherSubmission:ge,preventScrollReset:Ce||L,enableViewTransition:ye?H:void 0})}}async function _e(se,de,ye,ke){let ge,Ce={};try{ge=await TV(m,se,de,ke,ye,!1)}catch(Te){return de.filter(Ae=>Ae.shouldLoad).forEach(Ae=>{Ce[Ae.route.id]={type:"error",error:Te}}),Ce}if(se.signal.aborted)return Ce;if(!Zr(se.method))for(let Te of de){if(ge[Te.route.id]?.type==="error")break;!ge.hasOwnProperty(Te.route.id)&&!C.loaderData.hasOwnProperty(Te.route.id)&&(!C.errors||!C.errors.hasOwnProperty(Te.route.id))&&Te.shouldCallHandler()&&(ge[Te.route.id]={type:"error",result:new Error(`No result returned from dataStrategy for route ${Te.route.id}`)})}for(let[Te,Ae]of Object.entries(ge))if(DV(Ae)){let $e=Ae.result;Ce[Te]={type:"redirect",response:RV($e,se,Te,de,f)}}else Ce[Te]=await CV(Ae);return Ce}async function Be(se,de,ye,ke){let ge=_e(ye,se,ke,null),Ce=Promise.all(de.map(async $e=>{if($e.matches&&$e.match&&$e.request&&$e.controller){let Je=(await _e($e.request,$e.matches,ke,$e.key))[$e.match.route.id];return{[$e.key]:Je}}else return Promise.resolve({[$e.key]:{type:"error",error:Ar(404,{pathname:$e.path})}})})),Te=await ge,Ae=(await Ce).reduce(($e,Xe)=>Object.assign($e,Xe),{});return{loaderResults:Te,fetcherResults:Ae}}function it(){G=!0,z.forEach((se,de)=>{F.has(de)&&Y.add(de),qt(de)})}function qe(se,de,ye={}){C.fetchers.set(se,de),J({fetchers:new Map(C.fetchers)},{flushSync:(ye&&ye.flushSync)===!0})}function lt(se,de,ye,ke={}){let ge=wo(C.matches,de);ot(se),J({errors:{[ge.route.id]:ye},fetchers:new Map(C.fetchers)},{flushSync:(ke&&ke.flushSync)===!0})}function At(se){return D.set(se,(D.get(se)||0)+1),P.has(se)&&P.delete(se),C.fetchers.get(se)||tC}function Nn(se,de){qt(se,de?.reason),qe(se,Vs(null))}function ot(se){let de=C.fetchers.get(se);F.has(se)&&!(de&&de.state==="loading"&&j.has(se))&&qt(se),z.delete(se),j.delete(se),B.delete(se),P.delete(se),Y.delete(se),C.fetchers.delete(se)}function zn(se){let de=(D.get(se)||0)-1;de<=0?(D.delete(se),P.add(se)):D.set(se,de),J({fetchers:new Map(C.fetchers)})}function qt(se,de){let ye=F.get(se);ye&&(ye.abort(de),F.delete(se))}function Ge(se){for(let de of se){let ye=At(de),ke=Vs(ye.data);C.fetchers.set(de,ke)}}function We(){let se=[],de=!1;for(let ye of B){let ke=C.fetchers.get(ye);Et(ke,`Expected fetcher: ${ye}`),ke.state==="loading"&&(B.delete(ye),se.push(ye),de=!0)}return Ge(se),de}function fe(se){let de=[];for(let[ye,ke]of j)if(ke<se){let ge=C.fetchers.get(ye);Et(ge,`Expected fetcher: ${ye}`),ge.state==="loading"&&(qt(ye),j.delete(ye),de.push(ye))}return Ge(de),de.length>0}function It(se,de){let ye=C.blockers.get(se)||ql;return W.get(se)!==de&&W.set(se,de),ye}function Ct(se){C.blockers.delete(se),W.delete(se)}function Pt(se,de){let ye=C.blockers.get(se)||ql;Et(ye.state==="unblocked"&&de.state==="blocked"||ye.state==="blocked"&&de.state==="blocked"||ye.state==="blocked"&&de.state==="proceeding"||ye.state==="blocked"&&de.state==="unblocked"||ye.state==="proceeding"&&de.state==="unblocked",`Invalid blocker state transition: ${ye.state} -> ${de.state}`);let ke=new Map(C.blockers);ke.set(se,de),J({blockers:ke})}function $t({currentLocation:se,nextLocation:de,historyAction:ye}){if(W.size===0)return;W.size>1&&Un(!1,"A router only supports one blocker at a time");let ke=Array.from(W.entries()),[ge,Ce]=ke[ke.length-1],Te=C.blockers.get(ge);if(!(Te&&Te.state==="proceeding")&&Ce({currentLocation:se,nextLocation:de,historyAction:ye}))return ge}function Xt(se){let de=Ar(404,{pathname:se}),ye=u||l,{matches:ke,route:ge}=Pu(ye);return{notFoundMatches:ke,route:ge,error:de}}function xn(se,de,ye){if(E=se,w=de,x=ye||null,!S&&C.navigation===iy){S=!0;let ke=Ht(C.location,C.matches);ke!=null&&J({restoreScrollPosition:ke})}return()=>{E=null,w=null,x=null}}function dt(se,de){return x&&x(se,de.map(ke=>nV(ke,C.loaderData)))||se.key}function Ut(se,de){if(E&&w){let ye=dt(se,de);E[ye]=w()}}function Ht(se,de){if(E){let ye=dt(se,de),ke=E[ye];if(typeof ke=="number")return ke}return null}function zt(se,de,ye){if(e.patchRoutesOnNavigation)if(se){if(Object.keys(se[0].params).length>0)return{active:!0,matches:Ap(de,ye,f,!0)}}else return{active:!0,matches:Ap(de,ye,f,!0)||[]};return{active:!1,matches:null}}async function Ln(se,de,ye,ke){if(!e.patchRoutesOnNavigation)return{type:"success",matches:se};let ge=se;for(;;){let Ce=u==null,Te=u||l,Ae=i;try{await e.patchRoutesOnNavigation({signal:ye,path:de,matches:ge,fetcherKey:ke,patch:(Je,Qe)=>{ye.aborted||$U(Je,Qe,Te,Ae,o,!1)}})}catch(Je){return{type:"error",error:Je,partialMatches:ge}}finally{Ce&&!ye.aborted&&(l=[...l])}if(ye.aborted)return{type:"aborted"};let $e=Uo(Te,de,f),Xe=null;if($e){if(Object.keys($e[0].params).length===0)return{type:"success",matches:$e};if(Xe=Ap(Te,de,f,!0),!(Xe&&ge.length<Xe.length&&sn(ge,Xe.slice(0,ge.length))))return{type:"success",matches:$e}}if(Xe||(Xe=Ap(Te,de,f,!0)),!Xe||sn(ge,Xe))return{type:"success",matches:null};ge=Xe}}function sn(se,de){return se.length===de.length&&se.every((ye,ke)=>ye.route.id===de[ke].route.id)}function Mn(se){i={},u=fc(se,o,void 0,i)}function qn(se,de,ye=!1){let ke=u==null;$U(se,de,u||l,i,o,ye),ke&&(l=[...l],J({}))}return k={get basename(){return f},get future(){return h},get state(){return C},get routes(){return l},get window(){return t},initialize:oe,subscribe:Q,enableScrollRestoration:xn,navigate:ie,fetch:Ve,revalidate:he,createHref:se=>e.history.createHref(se),encodeLocation:se=>e.history.encodeLocation(se),getFetcher:At,resetFetcher:Nn,deleteFetcher:zn,dispose:le,getBlocker:It,deleteBlocker:Ct,patchRoutes:qn,_internalFetchControllers:F,_internalSetRoutes:Mn,_internalSetStateDoNotUseOrYouWillBreakYourApp(se){J(se)}},e.unstable_instrumentations&&(k=tfe(k,e.unstable_instrumentations.map(se=>se.router).filter(Boolean))),k}function lfe(e,t){Et(e.length>0,"You must provide a non-empty routes array to createStaticHandler");let n={},r=(t?t.basename:null)||"/",a=t?.mapRouteProperties||bV,o=a;if(t?.unstable_instrumentations){let y=t.unstable_instrumentations;o=E=>({...a(E),...dV(y.map(x=>x.route).filter(Boolean),E)})}let i=fc(e,o,void 0,n);async function l(y,{requestContext:E,filterMatchesToLoad:x,skipLoaderErrorBubbling:w,skipRevalidation:S,dataStrategy:_,generateMiddlewareResponse:T}={}){let A=new URL(y.url),R=y.method,k=ni("",ga(A),null,"default"),C=Uo(i,k,r);if(E=E??new ju,!w_(R)&&R!=="HEAD"){let M=Ar(405,{method:R}),{matches:L,route:$}=Pu(i),H={basename:r,location:k,matches:L,loaderData:{},actionData:null,errors:{[$.id]:M},statusCode:M.status,loaderHeaders:{},actionHeaders:{}};return T?T(()=>Promise.resolve(H)):H}else if(!C){let M=Ar(404,{pathname:k.pathname}),{matches:L,route:$}=Pu(i),H={basename:r,location:k,matches:L,loaderData:{},actionData:null,errors:{[$.id]:M},statusCode:M.status,loaderHeaders:{},actionHeaders:{}};return T?T(()=>Promise.resolve(H)):H}if(T){Et(E instanceof ju,"When using middleware in `staticHandler.query()`, any provided `requestContext` must be an instance of `RouterContextProvider`");try{await FU(C,n,o);let M,L=await BU({request:y,unstable_pattern:Ks(C),matches:C,params:C[0].params,context:E},async()=>await T(async(H,V={})=>{let Z=await f(H,k,C,E,_||null,w===!0,null,"filterMatchesToLoad"in V?V.filterMatchesToLoad??null:x??null,S===!0);return ua(Z)?Z:(M={location:k,basename:r,...Z},M)}),async($,H)=>{if(v_($))return $;if(ua($))try{$=new vs($.status,$.statusText,await NV($))}catch(V){$=V}if(ac($)&&($=IV($)),M){H in M.loaderData&&(M.loaderData[H]=void 0);let V=cfe(i,M,$,w?H:wo(C,H).route.id);return T(()=>Promise.resolve(V))}else{let V=w?H:wo(C,C.find(ne=>ne.route.id===H||ne.route.loader)?.route.id||H).route.id,Z={matches:C,location:k,basename:r,loaderData:{},actionData:null,errors:{[V]:$},statusCode:So($)?$.status:500,actionHeaders:{},loaderHeaders:{}};return T(()=>Promise.resolve(Z))}});return Et(ua(L),"Expected a response in query()"),L}catch(M){if(ua(M))return M;throw M}}let O=await f(y,k,C,E,_||null,w===!0,null,x||null,S===!0);return ua(O)?O:{location:k,basename:r,...O}}async function u(y,{routeId:E,requestContext:x,dataStrategy:w,generateMiddlewareResponse:S}={}){let _=new URL(y.url),T=y.method,A=ni("",ga(_),null,"default"),R=Uo(i,A,r);if(x=x??new ju,!w_(T)&&T!=="HEAD"&&T!=="OPTIONS")throw Ar(405,{method:T});if(!R)throw Ar(404,{pathname:A.pathname});let k=E?R.find(M=>M.route.id===E):Qu(R,A);if(E&&!k)throw Ar(403,{pathname:A.pathname,routeId:E});if(!k)throw Ar(404,{pathname:A.pathname});if(S)return Et(x instanceof ju,"When using middleware in `staticHandler.queryRoute()`, any provided `requestContext` must be an instance of `RouterContextProvider`"),await FU(R,n,o),await BU({request:y,unstable_pattern:Ks(R),matches:R,params:R[0].params,context:x},async()=>await S(async $=>{let H=await f($,A,R,x,w||null,!1,k,null,!1),V=O(H);return ua(V)?V:typeof V=="string"?new Response(V):Response.json(V)}),L=>{if(ac(L))return Promise.resolve(y_(L));if(ua(L))return Promise.resolve(L);throw L});let C=await f(y,A,R,x,w||null,!1,k,null,!1);return O(C);function O(M){if(ua(M))return M;let L=M.errors?Object.values(M.errors)[0]:void 0;if(L!==void 0)throw L;if(M.actionData)return Object.values(M.actionData)[0];if(M.loaderData)return Object.values(M.loaderData)[0]}}async function f(y,E,x,w,S,_,T,A,R){Et(y.signal,"query()/queryRoute() requests must contain an AbortController signal");try{if(Zr(y.method))return await m(y,x,T||Qu(x,E),w,S,_,T!=null,A,R);let k=await h(y,x,w,S,_,T,A);return ua(k)?k:{...k,actionData:null,actionHeaders:{}}}catch(k){if(OV(k)&&ua(k.result)){if(k.type==="error")throw k.result;return k.result}if(v_(k))return k;throw k}}async function m(y,E,x,w,S,_,T,A,R){let k;if(!x.route.action&&!x.route.lazy){let M=Ar(405,{method:y.method,pathname:new URL(y.url).pathname,routeId:x.route.id});if(T)throw M;k={type:"error",error:M}}else{let M=el(o,n,y,E,x,[],w);k=(await g(y,M,T,w,S))[x.route.id],y.signal.aborted&&MU(y,T)}if(Xi(k))throw new Response(null,{status:k.response.status,headers:{Location:k.response.headers.get("Location")}});if(T){if(zr(k))throw k.error;return{matches:[x],loaderData:{},actionData:{[x.route.id]:k.data},errors:null,statusCode:200,loaderHeaders:{},actionHeaders:{}}}if(R)if(zr(k)){let M=_?x:wo(E,x.route.id);return{statusCode:So(k.error)?k.error.status:k.statusCode!=null?k.statusCode:500,actionData:null,actionHeaders:{...k.headers?{[x.route.id]:k.headers}:{}},matches:E,loaderData:{},errors:{[M.route.id]:k.error},loaderHeaders:{}}}else return{actionData:{[x.route.id]:k.data},actionHeaders:k.headers?{[x.route.id]:k.headers}:{},matches:E,loaderData:{},errors:null,statusCode:k.statusCode||200,loaderHeaders:{}};let C=new Request(y.url,{headers:y.headers,redirect:y.redirect,signal:y.signal});if(zr(k)){let M=_?x:wo(E,x.route.id);return{...await h(C,E,w,S,_,null,A,[M.route.id,k]),statusCode:So(k.error)?k.error.status:k.statusCode!=null?k.statusCode:500,actionData:null,actionHeaders:{...k.headers?{[x.route.id]:k.headers}:{}}}}return{...await h(C,E,w,S,_,null,A),actionData:{[x.route.id]:k.data},...k.statusCode?{statusCode:k.statusCode}:{},actionHeaders:k.headers?{[x.route.id]:k.headers}:{}}}async function h(y,E,x,w,S,_,T,A){let R=_!=null;if(R&&!_?.route.loader&&!_?.route.lazy)throw Ar(400,{method:y.method,pathname:new URL(y.url).pathname,routeId:_?.route.id});let k;if(_)k=el(o,n,y,E,_,[],x);else{let M=A&&zr(A[1])?E.findIndex($=>$.route.id===A[0])-1:void 0,L=Ks(E);k=E.map(($,H)=>M!=null&&H>M?vm(o,n,y,L,$,[],x,!1):vm(o,n,y,L,$,[],x,($.route.loader||$.route.lazy)!=null&&(!T||T($))))}if(!w&&!k.some(M=>M.shouldLoad))return{matches:E,loaderData:{},errors:A&&zr(A[1])?{[A[0]]:A[1].error}:null,statusCode:200,loaderHeaders:{}};let C=await g(y,k,R,x,w);return y.signal.aborted&&MU(y,R),{...kV(E,C,A,!0,S),matches:E}}async function g(y,E,x,w,S){let _=await TV(S||g_,y,E,null,w,!0),T={};return await Promise.all(E.map(async A=>{if(!(A.route.id in _))return;let R=_[A.route.id];if(DV(R)){let k=R.result;throw RV(k,y,A.route.id,E,r)}if(x){if(ua(R.result))throw R;if(ac(R.result))throw y_(R.result)}T[A.route.id]=await CV(R)})),T}return{dataRoutes:i,query:l,queryRoute:u}}function cfe(e,t,n,r){let a=r||t._deepestRenderedBoundaryId||e[0].id;return{...t,statusCode:So(n)?n.status:500,errors:{[a]:n}}}function MU(e,t){if(e.signal.reason!==void 0)throw e.signal.reason;let n=t?"queryRoute":"query";throw new Error(`${n}() call aborted without an \`AbortSignal.reason\`: ${e.method} ${e.url}`)}function ufe(e){return e!=null&&("formData"in e&&e.formData!=null||"body"in e&&e.body!==void 0)}function m_(e,t,n,r,a,o){let i,l;if(a){i=[];for(let f of t)if(i.push(f),f.route.id===a){l=f;break}}else i=t,l=t[t.length-1];let u=iw(r||".",sw(i),Na(e.pathname,n)||e.pathname,o==="path");if(r==null&&(u.search=e.search,u.hash=e.hash),(r==null||r===""||r===".")&&l){let f=oC(u.search);if(l.route.index&&!f)u.search=u.search?u.search.replace(/^\?/,"?index&"):"?index";else if(!l.route.index&&f){let m=new URLSearchParams(u.search),h=m.getAll("index");m.delete("index"),h.filter(y=>y).forEach(y=>m.append("index",y));let g=m.toString();u.search=g?`?${g}`:""}}return n!=="/"&&(u.pathname=Yde({basename:n,pathname:u.pathname})),ga(u)}function jU(e,t,n){if(!n||!ufe(n))return{path:t};if(n.formMethod&&!w_(n.formMethod))return{path:t,error:Ar(405,{method:n.formMethod})};let r=()=>({path:t,error:Ar(400,{type:"invalid-body"})}),o=(n.formMethod||"get").toUpperCase(),i=AV(t);if(n.body!==void 0){if(n.formEncType==="text/plain"){if(!Zr(o))return r();let h=typeof n.body=="string"?n.body:n.body instanceof FormData||n.body instanceof URLSearchParams?Array.from(n.body.entries()).reduce((g,[y,E])=>`${g}${y}=${E}
92
92
  `,""):String(n.body);return{path:t,submission:{formMethod:o,formAction:i,formEncType:n.formEncType,formData:void 0,json:void 0,text:h}}}else if(n.formEncType==="application/json"){if(!Zr(o))return r();try{let h=typeof n.body=="string"?JSON.parse(n.body):n.body;return{path:t,submission:{formMethod:o,formAction:i,formEncType:n.formEncType,formData:void 0,json:h,text:void 0}}}catch{return r()}}}Et(typeof FormData=="function","FormData is not available in this environment");let l,u;if(n.formData)l=b_(n.formData),u=n.formData;else if(n.body instanceof FormData)l=b_(n.body),u=n.body;else if(n.body instanceof URLSearchParams)l=n.body,u=VU(l);else if(n.body==null)l=new URLSearchParams,u=new FormData;else try{l=new URLSearchParams(n.body),u=VU(l)}catch{return r()}let f={formMethod:o,formAction:i,formEncType:n&&n.formEncType||"application/x-www-form-urlencoded",formData:u,json:void 0,text:void 0};if(Zr(f.formMethod))return{path:t,submission:f};let m=Ro(t);return e&&m.search&&oC(m.search)&&l.append("index",""),m.search=`?${l}`,{path:ga(m),submission:f}}function PU(e,t,n,r,a,o,i,l,u,f,m,h,g,y,E,x,w,S,_,T,A){let R=T?zr(T[1])?T[1].error:T[1].data:void 0,k=a.createURL(o.location),C=a.createURL(u),O;if(m&&o.errors){let ne=Object.keys(o.errors)[0];O=i.findIndex(G=>G.route.id===ne)}else if(T&&zr(T[1])){let ne=T[0];O=i.findIndex(G=>G.route.id===ne)-1}let M=T?T[1].statusCode:void 0,L=M&&M>=400,$={currentUrl:k,currentParams:o.matches[0]?.params||{},nextUrl:C,nextParams:i[0].params,...l,actionResult:R,actionStatus:M},H=Ks(i),V=i.map((ne,G)=>{let{route:Y}=ne,F=null;if(O!=null&&G>O?F=!1:Y.lazy?F=!0:rC(Y)?m?F=h_(Y,o.loaderData,o.errors):dfe(o.loaderData,o.matches[G],ne)&&(F=!0):F=!1,F!==null)return vm(n,r,e,H,ne,f,t,F);let re=!1;typeof A=="boolean"?re=A:L?re=!1:(h||k.pathname+k.search===C.pathname+C.search||k.search!==C.search||ffe(o.matches[G],ne))&&(re=!0);let ee={...$,defaultShouldRevalidate:re},j=Bp(ne,ee);return vm(n,r,e,H,ne,f,t,j,ee,A)}),Z=[];return E.forEach((ne,G)=>{if(m||!i.some(D=>D.route.id===ne.routeId)||y.has(G))return;let Y=o.fetchers.get(G),F=Y&&Y.state!=="idle"&&Y.data===void 0,re=Uo(w,ne.path,S);if(!re){if(_&&F)return;Z.push({key:G,routeId:ne.routeId,path:ne.path,matches:null,match:null,request:null,controller:null});return}if(x.has(G))return;let ee=Qu(re,ne.path),j=new AbortController,B=Su(a,ne.path,j.signal),z=null;if(g.has(G))g.delete(G),z=el(n,r,B,re,ee,f,t);else if(F)h&&(z=el(n,r,B,re,ee,f,t));else{let D;typeof A=="boolean"?D=A:L?D=!1:D=h;let P={...$,defaultShouldRevalidate:D};Bp(ee,P)&&(z=el(n,r,B,re,ee,f,t,P))}z&&Z.push({key:G,routeId:ne.routeId,path:ne.path,matches:z,match:ee,request:B,controller:j})}),{dsMatches:V,revalidatingFetchers:Z}}function rC(e){return e.loader!=null||e.middleware!=null&&e.middleware.length>0}function h_(e,t,n){if(e.lazy)return!0;if(!rC(e))return!1;let r=t!=null&&e.id in t,a=n!=null&&n[e.id]!==void 0;return!r&&a?!1:typeof e.loader=="function"&&e.loader.hydrate===!0?!0:!r&&!a}function dfe(e,t,n){let r=!t||n.route.id!==t.route.id,a=!e.hasOwnProperty(n.route.id);return r||a}function ffe(e,t){let n=e.route.path;return e.pathname!==t.pathname||n!=null&&n.endsWith("*")&&e.params["*"]!==t.params["*"]}function Bp(e,t){if(e.route.shouldRevalidate){let n=e.route.shouldRevalidate(t);if(typeof n=="boolean")return n}return t.defaultShouldRevalidate}function $U(e,t,n,r,a,o){let i;if(e){let f=r[e];Et(f,`No route found to patch children into: routeId = ${e}`),f.children||(f.children=[]),i=f.children}else i=n;let l=[],u=[];if(t.forEach(f=>{let m=i.find(h=>wV(f,h));m?u.push({existingRoute:m,newRoute:f}):l.push(f)}),l.length>0){let f=fc(l,a,[e||"_","patch",String(i?.length||"0")],r);i.push(...f)}if(o&&u.length>0)for(let f=0;f<u.length;f++){let{existingRoute:m,newRoute:h}=u[f],g=m,[y]=fc([h],a,[],{},!0);Object.assign(g,{element:y.element?y.element:g.element,errorElement:y.errorElement?y.errorElement:g.errorElement,hydrateFallbackElement:y.hydrateFallbackElement?y.hydrateFallbackElement:g.hydrateFallbackElement})}}function wV(e,t){return"id"in e&&"id"in t&&e.id===t.id?!0:e.index===t.index&&e.path===t.path&&e.caseSensitive===t.caseSensitive?(!e.children||e.children.length===0)&&(!t.children||t.children.length===0)?!0:e.children.every((n,r)=>t.children?.some(a=>wV(n,a))):!1}var UU=new WeakMap,aC=({key:e,route:t,manifest:n,mapRouteProperties:r})=>{let a=n[t.id];if(Et(a,"No route found in manifest"),!a.lazy||typeof a.lazy!="object")return;let o=a.lazy[e];if(!o)return;let i=UU.get(a);i||(i={},UU.set(a,i));let l=i[e];if(l)return l;let u=(async()=>{let f=Lde(e),h=a[e]!==void 0&&e!=="hasErrorBoundary";if(f)Un(!f,"Route property "+e+" is not a supported lazy route property. This property will be ignored."),i[e]=Promise.resolve();else if(h)Un(!1,`Route "${a.id}" has a static property "${e}" defined. The lazy property will be ignored.`);else{let g=await o();g!=null&&(Object.assign(a,{[e]:g}),Object.assign(a,r(a)))}typeof a.lazy=="object"&&(a.lazy[e]=void 0,Object.values(a.lazy).every(g=>g===void 0)&&(a.lazy=void 0))})();return i[e]=u,u},zU=new WeakMap;function pfe(e,t,n,r,a){let o=n[e.id];if(Et(o,"No route found in manifest"),!e.lazy)return{lazyRoutePromise:void 0,lazyHandlerPromise:void 0};if(typeof e.lazy=="function"){let m=zU.get(o);if(m)return{lazyRoutePromise:m,lazyHandlerPromise:m};let h=(async()=>{Et(typeof e.lazy=="function","No lazy route function found");let g=await e.lazy(),y={};for(let E in g){let x=g[E];if(x===void 0)continue;let w=jde(E),_=o[E]!==void 0&&E!=="hasErrorBoundary";w?Un(!w,"Route property "+E+" is not a supported property to be returned from a lazy route function. This property will be ignored."):_?Un(!_,`Route "${o.id}" has a static property "${E}" defined but its lazy function is also returning a value for this property. The lazy route property "${E}" will be ignored.`):y[E]=x}Object.assign(o,y),Object.assign(o,{...r(o),lazy:void 0})})();return zU.set(o,h),h.catch(()=>{}),{lazyRoutePromise:h,lazyHandlerPromise:h}}let i=Object.keys(e.lazy),l=[],u;for(let m of i){if(a&&a.includes(m))continue;let h=aC({key:m,route:e,manifest:n,mapRouteProperties:r});h&&(l.push(h),m===t&&(u=h))}let f=l.length>0?Promise.all(l).then(()=>{}):void 0;return f?.catch(()=>{}),u?.catch(()=>{}),{lazyRoutePromise:f,lazyHandlerPromise:u}}function mfe(e){return e!==void 0}function FU(e,t,n){let r=e.map(({route:a})=>{if(!(typeof a.lazy!="object"||!a.lazy.middleware))return aC({key:"middleware",route:a,manifest:t,mapRouteProperties:n})}).filter(mfe);return r.length>0?Promise.all(r):void 0}async function g_(e){let t=e.matches.filter(a=>a.shouldLoad),n={};return(await Promise.all(t.map(a=>a.resolve()))).forEach((a,o)=>{n[t[o].route.id]=a}),n}async function hfe(e){return e.matches.some(t=>t.route.middleware)?xV(e,()=>g_(e)):g_(e)}function BU(e,t,n){return EV(e,t,r,ua,n);function r(a){return ac(a)?y_(a):a}}function xV(e,t){return EV(e,t,r=>{if(v_(r))throw r;return r},yfe,n);function n(r,a,o){if(o)return Promise.resolve(Object.assign(o.value,{[a]:{type:"error",result:r}}));{let{matches:i}=e,l=Math.min(Math.max(i.findIndex(f=>f.route.id===a),0),Math.max(i.findIndex(f=>f.shouldCallHandler()),0)),u=wo(i,i[l].route.id).route.id;return Promise.resolve({[u]:{type:"error",result:r}})}}}async function EV(e,t,n,r,a){let{matches:o,request:i,params:l,context:u,unstable_pattern:f}=e,m=o.flatMap(g=>g.route.middleware?g.route.middleware.map(y=>[g.route.id,y]):[]);return await SV({request:i,params:l,context:u,unstable_pattern:f},m,t,n,r,a)}async function SV(e,t,n,r,a,o,i=0){let{request:l}=e;if(l.signal.aborted)throw l.signal.reason??new Error(`Request aborted: ${l.method} ${l.url}`);let u=t[i];if(!u)return await n();let[f,m]=u,h,g=async()=>{if(h)throw new Error("You may only call `next()` once per middleware");try{return h={value:await SV(e,t,n,r,a,o,i+1)},h.value}catch(y){return h={value:await o(y,f,h)},h.value}};try{let y=await m(e,g),E=y!=null?r(y):void 0;return a(E)?E:h?E??h.value:(h={value:await g()},h.value)}catch(y){return await o(y,f,h)}}function _V(e,t,n,r,a){let o=aC({key:"middleware",route:r.route,manifest:t,mapRouteProperties:e}),i=pfe(r.route,Zr(n.method)?"action":"loader",t,e,a);return{middleware:o,route:i.lazyRoutePromise,handler:i.lazyHandlerPromise}}function vm(e,t,n,r,a,o,i,l,u=null,f){let m=!1,h=_V(e,t,n,a,o);return{...a,_lazyPromises:h,shouldLoad:l,shouldRevalidateArgs:u,shouldCallHandler(g){return m=!0,u?typeof f=="boolean"?Bp(a,{...u,defaultShouldRevalidate:f}):typeof g=="boolean"?Bp(a,{...u,defaultShouldRevalidate:g}):Bp(a,u):l},resolve(g){let{lazy:y,loader:E,middleware:x}=a.route,w=m||l||g&&!Zr(n.method)&&(y||E),S=x&&x.length>0&&!E&&!y;return w&&(Zr(n.method)||!S)?gfe({request:n,unstable_pattern:r,match:a,lazyHandlerPromise:h?.handler,lazyRoutePromise:h?.route,handlerOverride:g,scopedContext:i}):Promise.resolve({type:"data",result:void 0})}}}function el(e,t,n,r,a,o,i,l=null){return r.map(u=>u.route.id!==a.route.id?{...u,shouldLoad:!1,shouldRevalidateArgs:l,shouldCallHandler:()=>!1,_lazyPromises:_V(e,t,n,u,o),resolve:()=>Promise.resolve({type:"data",result:void 0})}:vm(e,t,n,Ks(r),u,o,i,!0,l))}async function TV(e,t,n,r,a,o){n.some(f=>f._lazyPromises?.middleware)&&await Promise.all(n.map(f=>f._lazyPromises?.middleware));let i={request:t,unstable_pattern:Ks(n),params:n[0].params,context:a,matches:n},u=await e({...i,fetcherKey:r,runClientMiddleware:o?()=>{throw new Error("You cannot call `runClientMiddleware()` from a static handler `dataStrategy`. Middleware is run outside of `dataStrategy` during SSR in order to bubble up the Response. You can enable middleware via the `respond` API in `query`/`queryRoute`")}:f=>{let m=i;return xV(m,()=>f({...m,fetcherKey:r,runClientMiddleware:()=>{throw new Error("Cannot call `runClientMiddleware()` from within an `runClientMiddleware` handler")}}))}});try{await Promise.all(n.flatMap(f=>[f._lazyPromises?.handler,f._lazyPromises?.route]))}catch{}return u}async function gfe({request:e,unstable_pattern:t,match:n,lazyHandlerPromise:r,lazyRoutePromise:a,handlerOverride:o,scopedContext:i}){let l,u,f=Zr(e.method),m=f?"action":"loader",h=g=>{let y,E=new Promise((S,_)=>y=_);u=()=>y(),e.signal.addEventListener("abort",u);let x=S=>typeof g!="function"?Promise.reject(new Error(`You cannot call the handler for a route which defines a boolean "${m}" [routeId: ${n.route.id}]`)):g({request:e,unstable_pattern:t,params:n.params,context:i},...S!==void 0?[S]:[]),w=(async()=>{try{return{type:"data",result:await(o?o(_=>x(_)):x())}}catch(S){return{type:"error",result:S}}})();return Promise.race([w,E])};try{let g=f?n.route.action:n.route.loader;if(r||a)if(g){let y,[E]=await Promise.all([h(g).catch(x=>{y=x}),r,a]);if(y!==void 0)throw y;l=E}else{await r;let y=f?n.route.action:n.route.loader;if(y)[l]=await Promise.all([h(y),a]);else if(m==="action"){let E=new URL(e.url),x=E.pathname+E.search;throw Ar(405,{method:e.method,pathname:x,routeId:n.route.id})}else return{type:"data",result:void 0}}else if(g)l=await h(g);else{let y=new URL(e.url),E=y.pathname+y.search;throw Ar(404,{pathname:E})}}catch(g){return{type:"error",result:g}}finally{u&&e.signal.removeEventListener("abort",u)}return l}async function NV(e){let t=e.headers.get("Content-Type");return t&&/\bapplication\/json\b/.test(t)?e.body==null?null:e.json():e.text()}async function CV(e){let{result:t,type:n}=e;if(ua(t)){let r;try{r=await NV(t)}catch(a){return{type:"error",error:a}}return n==="error"?{type:"error",error:new vs(t.status,t.statusText,r),statusCode:t.status,headers:t.headers}:{type:"data",data:r,statusCode:t.status,headers:t.headers}}return n==="error"?ac(t)?t.data instanceof Error?{type:"error",error:t.data,statusCode:t.init?.status,headers:t.init?.headers?new Headers(t.init.headers):void 0}:{type:"error",error:IV(t),statusCode:So(t)?t.status:void 0,headers:t.init?.headers?new Headers(t.init.headers):void 0}:{type:"error",error:t,statusCode:So(t)?t.status:void 0}:ac(t)?{type:"data",data:t.data,statusCode:t.init?.status,headers:t.init?.headers?new Headers(t.init.headers):void 0}:{type:"data",data:t}}function RV(e,t,n,r,a){let o=e.headers.get("Location");if(Et(o,"Redirects returned/thrown from loaders/actions must have a Location header"),!ow(o)){let i=r.slice(0,r.findIndex(l=>l.route.id===n)+1);o=m_(new URL(t.url),i,a,o),e.headers.set("Location",o)}return e}function HU(e,t,n,r){let a=["about:","blob:","chrome:","chrome-untrusted:","content:","data:","devtools:","file:","filesystem:","javascript:"];if(ow(e)){let o=e,i=o.startsWith("//")?new URL(t.protocol+o):new URL(o);if(a.includes(i.protocol))throw new Error("Invalid redirect location");let l=Na(i.pathname,n)!=null;if(i.origin===t.origin&&l)return i.pathname+i.search+i.hash}try{let o=r.createURL(e);if(a.includes(o.protocol))throw new Error("Invalid redirect location")}catch{}return e}function Su(e,t,n,r){let a=e.createURL(AV(t)).toString(),o={signal:n};if(r&&Zr(r.formMethod)){let{formMethod:i,formEncType:l}=r;o.method=i.toUpperCase(),l==="application/json"?(o.headers=new Headers({"Content-Type":l}),o.body=JSON.stringify(r.json)):l==="text/plain"?o.body=r.text:l==="application/x-www-form-urlencoded"&&r.formData?o.body=b_(r.formData):o.body=r.formData}return new Request(a,o)}function b_(e){let t=new URLSearchParams;for(let[n,r]of e.entries())t.append(n,typeof r=="string"?r:r.name);return t}function VU(e){let t=new FormData;for(let[n,r]of e.entries())t.append(n,r);return t}function kV(e,t,n,r=!1,a=!1){let o={},i=null,l,u=!1,f={},m=n&&zr(n[1])?n[1].error:void 0;return e.forEach(h=>{if(!(h.route.id in t))return;let g=h.route.id,y=t[g];if(Et(!Xi(y),"Cannot handle redirect results in processLoaderData"),zr(y)){let E=y.error;if(m!==void 0&&(E=m,m=void 0),i=i||{},a)i[g]=E;else{let x=wo(e,g);i[x.route.id]==null&&(i[x.route.id]=E)}r||(o[g]=vV),u||(u=!0,l=So(y.error)?y.error.status:500),y.headers&&(f[g]=y.headers)}else o[g]=y.data,y.statusCode&&y.statusCode!==200&&!u&&(l=y.statusCode),y.headers&&(f[g]=y.headers)}),m!==void 0&&n&&(i={[n[0]]:m},n[2]&&(o[n[2]]=void 0)),{loaderData:o,errors:i,statusCode:l||200,loaderHeaders:f}}function GU(e,t,n,r,a,o){let{loaderData:i,errors:l}=kV(t,n,r);return a.filter(u=>!u.matches||u.matches.some(f=>f.shouldLoad)).forEach(u=>{let{key:f,match:m,controller:h}=u;if(h&&h.signal.aborted)return;let g=o[f];if(Et(g,"Did not find corresponding fetcher result"),zr(g)){let y=wo(e.matches,m?.route.id);l&&l[y.route.id]||(l={...l,[y.route.id]:g.error}),e.fetchers.delete(f)}else if(Xi(g))Et(!1,"Unhandled fetcher revalidation redirect");else{let y=Vs(g.data);e.fetchers.set(f,y)}}),{loaderData:i,errors:l}}function WU(e,t,n,r){let a=Object.entries(t).filter(([,o])=>o!==vV).reduce((o,[i,l])=>(o[i]=l,o),{});for(let o of n){let i=o.route.id;if(!t.hasOwnProperty(i)&&e.hasOwnProperty(i)&&o.route.loader&&(a[i]=e[i]),r&&r.hasOwnProperty(i))break}return a}function KU(e){return e?zr(e[1])?{actionData:{}}:{actionData:{[e[0]]:e[1].data}}:{}}function wo(e,t){return(t?e.slice(0,e.findIndex(r=>r.route.id===t)+1):[...e]).reverse().find(r=>r.route.hasErrorBoundary===!0)||e[0]}function Pu(e){let t=e.length===1?e[0]:e.find(n=>n.index||!n.path||n.path==="/")||{id:"__shim-error-route__"};return{matches:[{params:{},pathname:"",pathnameBase:"",route:t}],route:t}}function Ar(e,{pathname:t,routeId:n,method:r,type:a,message:o}={}){let i="Unknown Server Error",l="Unknown @remix-run/router error";return e===400?(i="Bad Request",r&&t&&n?l=`You made a ${r} request to "${t}" but did not provide a \`loader\` for route "${n}", so there is no way to handle the request.`:a==="invalid-body"&&(l="Unable to encode submission body")):e===403?(i="Forbidden",l=`Route "${n}" does not match URL "${t}"`):e===404?(i="Not Found",l=`No route matches URL "${t}"`):e===405&&(i="Method Not Allowed",r&&t&&n?l=`You made a ${r.toUpperCase()} request to "${t}" but did not provide an \`action\` for route "${n}", so there is no way to handle the request.`:r&&(l=`Invalid request method "${r.toUpperCase()}"`)),new vs(e||500,i,new Error(l),!0)}function Ob(e){let t=Object.entries(e);for(let n=t.length-1;n>=0;n--){let[r,a]=t[n];if(Xi(a))return{key:r,result:a}}}function AV(e){let t=typeof e=="string"?Ro(e):e;return ga({...t,hash:""})}function bfe(e,t){return e.pathname!==t.pathname||e.search!==t.search?!1:e.hash===""?t.hash!=="":e.hash===t.hash?!0:t.hash!==""}function y_(e){return Response.json(e.data,e.init??void 0)}function IV(e){return new vs(e.init?.status??500,e.init?.statusText??"Internal Server Error",e.data)}function yfe(e){return e!=null&&typeof e=="object"&&Object.entries(e).every(([t,n])=>typeof t=="string"&&OV(n))}function OV(e){return e!=null&&typeof e=="object"&&"type"in e&&"result"in e&&(e.type==="data"||e.type==="error")}function DV(e){return ua(e.result)&&gV.has(e.result.status)}function zr(e){return e.type==="error"}function Xi(e){return(e&&e.type)==="redirect"}function ac(e){return typeof e=="object"&&e!=null&&"type"in e&&"data"in e&&"init"in e&&e.type==="DataWithResponseInit"}function ua(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.headers=="object"&&typeof e.body<"u"}function vfe(e){return gV.has(e)}function v_(e){return ua(e)&&vfe(e.status)&&e.headers.has("Location")}function w_(e){return sfe.has(e.toUpperCase())}function Zr(e){return afe.has(e.toUpperCase())}function oC(e){return new URLSearchParams(e).getAll("index").some(t=>t==="")}function Qu(e,t){let n=typeof t=="string"?Ro(t).search:t.search;if(e[e.length-1].route.index&&oC(n||""))return e[e.length-1];let r=lV(e);return r[r.length-1]}function YU(e){let{formMethod:t,formAction:n,formEncType:r,text:a,formData:o,json:i}=e;if(!(!t||!n||!r)){if(a!=null)return{formMethod:t,formAction:n,formEncType:r,formData:void 0,json:void 0,text:a};if(o!=null)return{formMethod:t,formAction:n,formEncType:r,formData:o,json:void 0,text:void 0};if(i!==void 0)return{formMethod:t,formAction:n,formEncType:r,formData:void 0,json:i,text:void 0}}}function FE(e,t){return t?{state:"loading",location:e,formMethod:t.formMethod,formAction:t.formAction,formEncType:t.formEncType,formData:t.formData,json:t.json,text:t.text}:{state:"loading",location:e,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0}}function wfe(e,t){return{state:"submitting",location:e,formMethod:t.formMethod,formAction:t.formAction,formEncType:t.formEncType,formData:t.formData,json:t.json,text:t.text}}function vp(e,t){return e?{state:"loading",formMethod:e.formMethod,formAction:e.formAction,formEncType:e.formEncType,formData:e.formData,json:e.json,text:e.text,data:t}:{state:"loading",formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0,data:t}}function xfe(e,t){return{state:"submitting",formMethod:e.formMethod,formAction:e.formAction,formEncType:e.formEncType,formData:e.formData,json:e.json,text:e.text,data:t?t.data:void 0}}function Vs(e){return{state:"idle",formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0,data:e}}function Efe(e,t){try{let n=e.sessionStorage.getItem(yV);if(n){let r=JSON.parse(n);for(let[a,o]of Object.entries(r||{}))o&&Array.isArray(o)&&t.set(a,new Set(o||[]))}}catch{}}function Sfe(e,t){if(t.size>0){let n={};for(let[r,a]of t)n[r]=[...a];try{e.sessionStorage.setItem(yV,JSON.stringify(n))}catch(r){Un(!1,`Failed to save applied view transitions in sessionStorage (${r}).`)}}}function ZU(){let e,t,n=new Promise((r,a)=>{e=async o=>{r(o);try{await n}catch{}},t=async o=>{a(o);try{await n}catch{}}});return{promise:n,resolve:e,reject:t}}var si=b.createContext(null);si.displayName="DataRouter";var gl=b.createContext(null);gl.displayName="DataRouterState";var LV=b.createContext(!1);function MV(){return b.useContext(LV)}var lw=b.createContext({isTransitioning:!1});lw.displayName="ViewTransition";var cw=b.createContext(new Map);cw.displayName="Fetchers";var Ud=b.createContext(null);Ud.displayName="Await";var ZTe=e=>b.createElement(Ud.Provider,e),ka=b.createContext(null);ka.displayName="Navigation";var cf=b.createContext(null);cf.displayName="Location";var oo=b.createContext({outlet:null,matches:[],isDataRoute:!1});oo.displayName="Route";var sC=b.createContext(null);sC.displayName="RouteError";var jV="REACT_ROUTER_ERROR",_fe="REDIRECT",Tfe="ROUTE_ERROR_RESPONSE";function Nfe(e){if(e.startsWith(`${jV}:${_fe}:{`))try{let t=JSON.parse(e.slice(28));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.location=="string"&&typeof t.reloadDocument=="boolean"&&typeof t.replace=="boolean")return t}catch{}}function Cfe(e){if(e.startsWith(`${jV}:${Tfe}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string")return new vs(t.status,t.statusText,t.data)}catch{}}function Rfe(e,{relative:t}={}){Et(Tc(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:r}=b.useContext(ka),{hash:a,pathname:o,search:i}=ah(e,{relative:t}),l=o;return n!=="/"&&(l=o==="/"?n:is([n,o])),r.createHref({pathname:l,search:i,hash:a})}function Tc(){return b.useContext(cf)!=null}function Aa(){return Et(Tc(),"useLocation() may be used only in the context of a <Router> component."),b.useContext(cf).location}function qTe(){return b.useContext(cf).navigationType}function XTe(e){Et(Tc(),"useMatch() may be used only in the context of a <Router> component.");let{pathname:t}=Aa();return b.useMemo(()=>ym(e,sV(t)),[t,e])}var PV="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function $V(e){b.useContext(ka).static||b.useLayoutEffect(e)}function bl(){let{isDataRoute:e}=b.useContext(oo);return e?Bfe():kfe()}function kfe(){Et(Tc(),"useNavigate() may be used only in the context of a <Router> component.");let e=b.useContext(si),{basename:t,navigator:n}=b.useContext(ka),{matches:r}=b.useContext(oo),{pathname:a}=Aa(),o=JSON.stringify(sw(r)),i=b.useRef(!1);return $V(()=>{i.current=!0}),b.useCallback((u,f={})=>{if(Un(i.current,PV),!i.current)return;if(typeof u=="number"){n.go(u);return}let m=iw(u,JSON.parse(o),a,f.relative==="path");e==null&&t!=="/"&&(m.pathname=m.pathname==="/"?t:is([t,m.pathname])),(f.replace?n.replace:n.push)(m,f.state,f)},[t,n,o,a,e])}var UV=b.createContext(null);function JTe(){return b.useContext(UV)}function Afe(e){let t=b.useContext(oo).outlet;return b.useMemo(()=>t&&b.createElement(UV.Provider,{value:e},t),[t,e])}function iC(){let{matches:e}=b.useContext(oo),t=e[e.length-1];return t?t.params:{}}function ah(e,{relative:t}={}){let{matches:n}=b.useContext(oo),{pathname:r}=Aa(),a=JSON.stringify(sw(n));return b.useMemo(()=>iw(e,JSON.parse(a),r,t==="path"),[e,a,r,t])}function Ife(e,t){return lC(e,t)}function lC(e,t,n,r,a){Et(Tc(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:o}=b.useContext(ka),{matches:i}=b.useContext(oo),l=i[i.length-1],u=l?l.params:{},f=l?l.pathname:"/",m=l?l.pathnameBase:"/",h=l&&l.route;{let _=h&&h.path||"";BV(f,!h||_.endsWith("*")||_.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${f}" (under <Route path="${_}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
93
93
 
94
94
  Please change the parent <Route path="${_}"> to <Route path="${_==="/"?"*":`${_}/*`}">.`)}let g=Aa(),y;if(t){let _=typeof t=="string"?Ro(t):t;Et(m==="/"||_.pathname?.startsWith(m),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${m}" but pathname "${_.pathname}" was given in the \`location\` prop.`),y=_}else y=g;let E=y.pathname||"/",x=E;if(m!=="/"){let _=m.replace(/^\//,"").split("/");x="/"+E.replace(/^\//,"").split("/").slice(_.length).join("/")}let w=Uo(e,{pathname:x});Un(h||w!=null,`No routes matched location "${y.pathname}${y.search}${y.hash}" `),Un(w==null||w[w.length-1].route.element!==void 0||w[w.length-1].route.Component!==void 0||w[w.length-1].route.lazy!==void 0,`Matched leaf route at location "${y.pathname}${y.search}${y.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let S=FV(w&&w.map(_=>Object.assign({},_,{params:Object.assign({},u,_.params),pathname:is([m,o.encodeLocation?o.encodeLocation(_.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:_.pathname]),pathnameBase:_.pathnameBase==="/"?m:is([m,o.encodeLocation?o.encodeLocation(_.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:_.pathnameBase])})),i,n,r,a);return t&&S?b.createElement(cf.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...y},navigationType:"POP"}},S):S}function Ofe(){let e=mC(),t=So(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,r="rgba(200,200,200, 0.5)",a={padding:"0.5rem",backgroundColor:r},o={padding:"2px 4px",backgroundColor:r},i=null;return console.error("Error handled by React Router default ErrorBoundary:",e),i=b.createElement(b.Fragment,null,b.createElement("p",null,"💿 Hey developer 👋"),b.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",b.createElement("code",{style:o},"ErrorBoundary")," or"," ",b.createElement("code",{style:o},"errorElement")," prop on your route.")),b.createElement(b.Fragment,null,b.createElement("h2",null,"Unexpected Application Error!"),b.createElement("h3",{style:{fontStyle:"italic"}},t),n?b.createElement("pre",{style:a},n):null,i)}var Dfe=b.createElement(Ofe,null),zV=class extends b.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location||t.revalidation!=="idle"&&e.revalidation==="idle"?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error!==void 0?e.error:t.error,location:t.location,revalidation:e.revalidation||t.revalidation}}componentDidCatch(e,t){this.props.onError?this.props.onError(e,t):console.error("React Router caught the following error during render",e)}render(){let e=this.state.error;if(this.context&&typeof e=="object"&&e&&"digest"in e&&typeof e.digest=="string"){const n=Cfe(e.digest);n&&(e=n)}let t=e!==void 0?b.createElement(oo.Provider,{value:this.props.routeContext},b.createElement(sC.Provider,{value:e,children:this.props.component})):this.props.children;return this.context?b.createElement(Lfe,{error:e},t):t}};zV.contextType=LV;var BE=new WeakMap;function Lfe({children:e,error:t}){let{basename:n}=b.useContext(ka);if(typeof t=="object"&&t&&"digest"in t&&typeof t.digest=="string"){let r=Nfe(t.digest);if(r){let a=BE.get(t);if(a)throw a;let o=uV(r.location,n);if(cV&&!BE.get(t))if(o.isExternal||r.reloadDocument)window.location.href=o.absoluteURL||o.to;else{const i=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(o.to,{replace:r.replace}));throw BE.set(t,i),i}return b.createElement("meta",{httpEquiv:"refresh",content:`0;url=${o.absoluteURL||o.to}`})}}return e}function Mfe({routeContext:e,match:t,children:n}){let r=b.useContext(si);return r&&r.static&&r.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=t.route.id),b.createElement(oo.Provider,{value:e},n)}function FV(e,t=[],n=null,r=null,a=null){if(e==null){if(!n)return null;if(n.errors)e=n.matches;else if(t.length===0&&!n.initialized&&n.matches.length>0)e=n.matches;else return null}let o=e,i=n?.errors;if(i!=null){let m=o.findIndex(h=>h.route.id&&i?.[h.route.id]!==void 0);Et(m>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(i).join(",")}`),o=o.slice(0,Math.min(o.length,m+1))}let l=!1,u=-1;if(n)for(let m=0;m<o.length;m++){let h=o[m];if((h.route.HydrateFallback||h.route.hydrateFallbackElement)&&(u=m),h.route.id){let{loaderData:g,errors:y}=n,E=h.route.loader&&!g.hasOwnProperty(h.route.id)&&(!y||y[h.route.id]===void 0);if(h.route.lazy||E){l=!0,u>=0?o=o.slice(0,u+1):o=[o[0]];break}}}let f=n&&r?(m,h)=>{r(m,{location:n.location,params:n.matches?.[0]?.params??{},unstable_pattern:Ks(n.matches),errorInfo:h})}:void 0;return o.reduceRight((m,h,g)=>{let y,E=!1,x=null,w=null;n&&(y=i&&h.route.id?i[h.route.id]:void 0,x=h.route.errorElement||Dfe,l&&(u<0&&g===0?(BV("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),E=!0,w=null):u===g&&(E=!0,w=h.route.hydrateFallbackElement||null)));let S=t.concat(o.slice(0,g+1)),_=()=>{let T;return y?T=x:E?T=w:h.route.Component?T=b.createElement(h.route.Component,null):h.route.element?T=h.route.element:T=m,b.createElement(Mfe,{match:h,routeContext:{outlet:m,matches:S,isDataRoute:n!=null},children:T})};return n&&(h.route.ErrorBoundary||h.route.errorElement||g===0)?b.createElement(zV,{location:n.location,revalidation:n.revalidation,component:x,error:y,children:_(),routeContext:{outlet:null,matches:S,isDataRoute:!0},onError:f}):_()},null)}function cC(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function uC(e){let t=b.useContext(si);return Et(t,cC(e)),t}function ii(e){let t=b.useContext(gl);return Et(t,cC(e)),t}function jfe(e){let t=b.useContext(oo);return Et(t,cC(e)),t}function uf(e){let t=jfe(e),n=t.matches[t.matches.length-1];return Et(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function Pfe(){return uf("useRouteId")}function $fe(){return ii("useNavigation").navigation}function QTe(){let e=uC("useRevalidator"),t=ii("useRevalidator"),n=b.useCallback(async()=>{await e.router.revalidate()},[e.router]);return b.useMemo(()=>({revalidate:n,state:t.revalidation}),[n,t.revalidation])}function dC(){let{matches:e,loaderData:t}=ii("useMatches");return b.useMemo(()=>e.map(n=>nV(n,t)),[e,t])}function fC(){let e=ii("useLoaderData"),t=uf("useLoaderData");return e.loaderData[t]}function eNe(e){return ii("useRouteLoaderData").loaderData[e]}function pC(){let e=ii("useActionData"),t=uf("useLoaderData");return e.actionData?e.actionData[t]:void 0}function mC(){let e=b.useContext(sC),t=ii("useRouteError"),n=uf("useRouteError");return e!==void 0?e:t.errors?.[n]}function Ufe(){return b.useContext(Ud)?._data}function tNe(){return b.useContext(Ud)?._error}var zfe=0;function Ffe(e){let{router:t,basename:n}=uC("useBlocker"),r=ii("useBlocker"),[a,o]=b.useState(""),i=b.useCallback(l=>{if(typeof e!="function")return!!e;if(n==="/")return e(l);let{currentLocation:u,nextLocation:f,historyAction:m}=l;return e({currentLocation:{...u,pathname:Na(u.pathname,n)||u.pathname},nextLocation:{...f,pathname:Na(f.pathname,n)||f.pathname},historyAction:m})},[n,e]);return b.useEffect(()=>{let l=String(++zfe);return o(l),()=>t.deleteBlocker(l)},[t]),b.useEffect(()=>{a!==""&&t.getBlocker(a,i)},[t,a,i]),a&&r.blockers.has(a)?r.blockers.get(a):ql}function Bfe(){let{router:e}=uC("useNavigate"),t=uf("useNavigate"),n=b.useRef(!1);return $V(()=>{n.current=!0}),b.useCallback(async(a,o={})=>{Un(n.current,PV),n.current&&(typeof a=="number"?await e.navigate(a):await e.navigate(a,{fromRouteId:t,...o}))},[e,t])}var qU={};function BV(e,t,n){!t&&!qU[e]&&(qU[e]=!0,Un(!1,n))}function nNe(...e){const t=uf("useRoute"),n=e[0]??t,r=ii("useRoute"),a=r.matches.find(({route:o})=>o.id===n);if(a!==void 0)return{handle:a.route.handle,loaderData:r.loaderData[n],actionData:r.actionData?.[n]}}var XU={};function x_(e,t){!e&&!XU[t]&&(XU[t]=!0,console.warn(t))}var Hfe="useOptimistic",JU=Ec[Hfe],Vfe=()=>{};function Gfe(e){return JU?JU(e):[e,Vfe]}function oh(e){let t={hasErrorBoundary:e.hasErrorBoundary||e.ErrorBoundary!=null||e.errorElement!=null};return e.Component&&(e.element&&Un(!1,"You should not include both `Component` and `element` on your route - `Component` will be used."),Object.assign(t,{element:b.createElement(e.Component),Component:void 0})),e.HydrateFallback&&(e.hydrateFallbackElement&&Un(!1,"You should not include both `HydrateFallback` and `hydrateFallbackElement` on your route - `HydrateFallback` will be used."),Object.assign(t,{hydrateFallbackElement:b.createElement(e.HydrateFallback),HydrateFallback:void 0})),e.ErrorBoundary&&(e.errorElement&&Un(!1,"You should not include both `ErrorBoundary` and `errorElement` on your route - `ErrorBoundary` will be used."),Object.assign(t,{errorElement:b.createElement(e.ErrorBoundary),ErrorBoundary:void 0})),t}var hC=["HydrateFallback","hydrateFallbackElement"];function rNe(e,t){return nC({basename:t?.basename,getContext:t?.getContext,future:t?.future,history:XH({initialEntries:t?.initialEntries,initialIndex:t?.initialIndex}),hydrationData:t?.hydrationData,routes:e,hydrationRouteProperties:hC,mapRouteProperties:oh,dataStrategy:t?.dataStrategy,patchRoutesOnNavigation:t?.patchRoutesOnNavigation,unstable_instrumentations:t?.unstable_instrumentations}).initialize()}var Wfe=class{constructor(){this.status="pending",this.promise=new Promise((e,t)=>{this.resolve=n=>{this.status==="pending"&&(this.status="resolved",e(n))},this.reject=n=>{this.status==="pending"&&(this.status="rejected",t(n))}})}};function aNe({router:e,flushSync:t,onError:n,unstable_useTransitions:r}){r=MV()||r;let[o,i]=b.useState(e.state),[l,u]=Gfe(o),[f,m]=b.useState(),[h,g]=b.useState({isTransitioning:!1}),[y,E]=b.useState(),[x,w]=b.useState(),[S,_]=b.useState(),T=b.useRef(new Map),A=b.useCallback((O,{deletedFetchers:M,newErrors:L,flushSync:$,viewTransitionOpts:H})=>{L&&n&&Object.values(L).forEach(Z=>n(Z,{location:O.location,params:O.matches[0]?.params??{},unstable_pattern:Ks(O.matches)})),O.fetchers.forEach((Z,ne)=>{Z.data!==void 0&&T.current.set(ne,Z.data)}),M.forEach(Z=>T.current.delete(Z)),x_($===!1||t!=null,'You provided the `flushSync` option to a router update, but you are not using the `<RouterProvider>` from `react-router/dom` so `ReactDOM.flushSync()` is unavailable. Please update your app to `import { RouterProvider } from "react-router/dom"` and ensure you have `react-dom` installed as a dependency to use the `flushSync` option.');let V=e.window!=null&&e.window.document!=null&&typeof e.window.document.startViewTransition=="function";if(x_(H==null||V,"You provided the `viewTransition` option to a router update, but you do not appear to be running in a DOM environment as `window.startViewTransition` is not available."),!H||!V){t&&$?t(()=>i(O)):r===!1?i(O):b.startTransition(()=>{r===!0&&u(Z=>QU(Z,O)),i(O)});return}if(t&&$){t(()=>{x&&(y?.resolve(),x.skipTransition()),g({isTransitioning:!0,flushSync:!0,currentLocation:H.currentLocation,nextLocation:H.nextLocation})});let Z=e.window.document.startViewTransition(()=>{t(()=>i(O))});Z.finished.finally(()=>{t(()=>{E(void 0),w(void 0),m(void 0),g({isTransitioning:!1})})}),t(()=>w(Z));return}x?(y?.resolve(),x.skipTransition(),_({state:O,currentLocation:H.currentLocation,nextLocation:H.nextLocation})):(m(O),g({isTransitioning:!0,flushSync:!1,currentLocation:H.currentLocation,nextLocation:H.nextLocation}))},[e.window,t,x,y,r,u,n]);b.useLayoutEffect(()=>e.subscribe(A),[e,A]),b.useEffect(()=>{h.isTransitioning&&!h.flushSync&&E(new Wfe)},[h]),b.useEffect(()=>{if(y&&f&&e.window){let O=f,M=y.promise,L=e.window.document.startViewTransition(async()=>{r===!1?i(O):b.startTransition(()=>{r===!0&&u($=>QU($,O)),i(O)}),await M});L.finished.finally(()=>{E(void 0),w(void 0),m(void 0),g({isTransitioning:!1})}),w(L)}},[f,y,e.window,r,u]),b.useEffect(()=>{y&&f&&l.location.key===f.location.key&&y.resolve()},[y,x,l.location,f]),b.useEffect(()=>{!h.isTransitioning&&S&&(m(S.state),g({isTransitioning:!0,flushSync:!1,currentLocation:S.currentLocation,nextLocation:S.nextLocation}),_(void 0))},[h.isTransitioning,S]);let R=b.useMemo(()=>({createHref:e.createHref,encodeLocation:e.encodeLocation,go:O=>e.navigate(O),push:(O,M,L)=>e.navigate(O,{state:M,preventScrollReset:L?.preventScrollReset}),replace:(O,M,L)=>e.navigate(O,{replace:!0,state:M,preventScrollReset:L?.preventScrollReset})}),[e]),k=e.basename||"/",C=b.useMemo(()=>({router:e,navigator:R,static:!1,basename:k,onError:n}),[e,R,k,n]);return b.createElement(b.Fragment,null,b.createElement(si.Provider,{value:C},b.createElement(gl.Provider,{value:l},b.createElement(cw.Provider,{value:T.current},b.createElement(lw.Provider,{value:h},b.createElement(Nc,{basename:k,location:l.location,navigationType:l.historyAction,navigator:R,unstable_useTransitions:r},b.createElement(Kfe,{routes:e.routes,future:e.future,state:l,onError:n})))))),null)}function QU(e,t){return{...e,navigation:t.navigation.state!=="idle"?t.navigation:e.navigation,revalidation:t.revalidation!=="idle"?t.revalidation:e.revalidation,actionData:t.navigation.state!=="submitting"?t.actionData:e.actionData,fetchers:t.fetchers}}var Kfe=b.memo(Yfe);function Yfe({routes:e,future:t,state:n,onError:r}){return lC(e,void 0,n,r,t)}function oNe({basename:e,children:t,initialEntries:n,initialIndex:r,unstable_useTransitions:a}){let o=b.useRef();o.current==null&&(o.current=XH({initialEntries:n,initialIndex:r,v5Compat:!0}));let i=o.current,[l,u]=b.useState({action:i.action,location:i.location}),f=b.useCallback(m=>{a===!1?u(m):b.startTransition(()=>u(m))},[a]);return b.useLayoutEffect(()=>i.listen(f),[i,f]),b.createElement(Nc,{basename:e,children:t,location:l.location,navigationType:l.action,navigator:i,unstable_useTransitions:a})}function sNe({to:e,replace:t,state:n,relative:r}){Et(Tc(),"<Navigate> may be used only in the context of a <Router> component.");let{static:a}=b.useContext(ka);Un(!a,"<Navigate> must not be used on the initial render in a <StaticRouter>. This is a no-op, but you should modify your code so the <Navigate> is only ever rendered in response to some user interaction or state change.");let{matches:o}=b.useContext(oo),{pathname:i}=Aa(),l=bl(),u=iw(e,sw(o),i,r==="path"),f=JSON.stringify(u);return b.useEffect(()=>{l(JSON.parse(f),{replace:t,state:n,relative:r})},[l,f,r,t,n]),null}function iNe(e){return Afe(e.context)}function E_(e){Et(!1,"A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.")}function Nc({basename:e="/",children:t=null,location:n,navigationType:r="POP",navigator:a,static:o=!1,unstable_useTransitions:i}){Et(!Tc(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let l=e.replace(/^\/*/,"/"),u=b.useMemo(()=>({basename:l,navigator:a,static:o,unstable_useTransitions:i,future:{}}),[l,a,o,i]);typeof n=="string"&&(n=Ro(n));let{pathname:f="/",search:m="",hash:h="",state:g=null,key:y="default"}=n,E=b.useMemo(()=>{let x=Na(f,l);return x==null?null:{location:{pathname:x,search:m,hash:h,state:g,key:y},navigationType:r}},[l,f,m,h,g,y,r]);return Un(E!=null,`<Router basename="${l}"> is not able to match the URL "${f}${m}${h}" because it does not start with the basename, so the <Router> won't render anything.`),E==null?null:b.createElement(ka.Provider,{value:u},b.createElement(cf.Provider,{children:t,value:E}))}function Zfe({children:e,location:t}){return Ife(qy(e),t)}function lNe({children:e,errorElement:t,resolve:n}){let r=b.useContext(si),a=b.useContext(gl),o=b.useCallback((i,l)=>{r&&r.onError&&a&&r.onError(i,{location:a.location,params:a.matches[0]?.params||{},unstable_pattern:Ks(a.matches),errorInfo:l})},[r,a]);return b.createElement(qfe,{resolve:n,errorElement:t,onError:o},b.createElement(Xfe,null,e))}var qfe=class extends b.Component{constructor(e){super(e),this.state={error:null}}static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){this.props.onError?this.props.onError(e,t):console.error("<Await> caught the following error during render",e,t)}render(){let{children:e,errorElement:t,resolve:n}=this.props,r=null,a=0;if(!(n instanceof Promise))a=1,r=Promise.resolve(),Object.defineProperty(r,"_tracked",{get:()=>!0}),Object.defineProperty(r,"_data",{get:()=>n});else if(this.state.error){a=2;let o=this.state.error;r=Promise.reject().catch(()=>{}),Object.defineProperty(r,"_tracked",{get:()=>!0}),Object.defineProperty(r,"_error",{get:()=>o})}else n._tracked?(r=n,a="_error"in r?2:"_data"in r?1:0):(a=0,Object.defineProperty(n,"_tracked",{get:()=>!0}),r=n.then(o=>Object.defineProperty(n,"_data",{get:()=>o}),o=>{this.props.onError?.(o),Object.defineProperty(n,"_error",{get:()=>o})}));if(a===2&&!t)throw r._error;if(a===2)return b.createElement(Ud.Provider,{value:r,children:t});if(a===1)return b.createElement(Ud.Provider,{value:r,children:e});throw r}};function Xfe({children:e}){let t=Ufe(),n=typeof e=="function"?e(t):e;return b.createElement(b.Fragment,null,n)}function qy(e,t=[]){let n=[];return b.Children.forEach(e,(r,a)=>{if(!b.isValidElement(r))return;let o=[...t,a];if(r.type===b.Fragment){n.push.apply(n,qy(r.props.children,o));return}Et(r.type===E_,`[${typeof r.type=="string"?r.type:r.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),Et(!r.props.index||!r.props.children,"An index route cannot have child routes.");let i={id:r.props.id||o.join("-"),caseSensitive:r.props.caseSensitive,element:r.props.element,Component:r.props.Component,index:r.props.index,path:r.props.path,middleware:r.props.middleware,loader:r.props.loader,action:r.props.action,hydrateFallbackElement:r.props.hydrateFallbackElement,HydrateFallback:r.props.HydrateFallback,errorElement:r.props.errorElement,ErrorBoundary:r.props.ErrorBoundary,hasErrorBoundary:r.props.hasErrorBoundary===!0||r.props.ErrorBoundary!=null||r.props.errorElement!=null,shouldRevalidate:r.props.shouldRevalidate,handle:r.props.handle,lazy:r.props.lazy};r.props.children&&(i.children=qy(r.props.children,o)),n.push(i)}),n}var cNe=qy;function uNe(e){return FV(e)}function HV(){return{params:iC(),loaderData:fC(),actionData:pC(),matches:dC()}}function dNe({children:e}){const t=HV();return b.cloneElement(e,t)}function fNe(e){return function(){const n=HV();return b.createElement(e,n)}}function VV(){return{params:iC(),loaderData:fC(),actionData:pC()}}function pNe({children:e}){const t=VV();return b.cloneElement(e,t)}function mNe(e){return function(){const n=VV();return b.createElement(e,n)}}function GV(){return{params:iC(),loaderData:fC(),actionData:pC(),error:mC()}}function hNe({children:e}){const t=GV();return b.cloneElement(e,t)}function gNe(e){return function(){const n=GV();return b.createElement(e,n)}}var ly="get",cy="application/x-www-form-urlencoded";function uw(e){return typeof HTMLElement<"u"&&e instanceof HTMLElement}function Jfe(e){return uw(e)&&e.tagName.toLowerCase()==="button"}function Qfe(e){return uw(e)&&e.tagName.toLowerCase()==="form"}function epe(e){return uw(e)&&e.tagName.toLowerCase()==="input"}function tpe(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function npe(e,t){return e.button===0&&(!t||t==="_self")&&!tpe(e)}function S_(e=""){return new URLSearchParams(typeof e=="string"||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((t,n)=>{let r=e[n];return t.concat(Array.isArray(r)?r.map(a=>[n,a]):[[n,r]])},[]))}function rpe(e,t){let n=S_(e);return t&&t.forEach((r,a)=>{n.has(a)||t.getAll(a).forEach(o=>{n.append(a,o)})}),n}var Db=null;function ape(){if(Db===null)try{new FormData(document.createElement("form"),0),Db=!1}catch{Db=!0}return Db}var ope=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function HE(e){return e!=null&&!ope.has(e)?(Un(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${cy}"`),null):e}function spe(e,t){let n,r,a,o,i;if(Qfe(e)){let l=e.getAttribute("action");r=l?Na(l,t):null,n=e.getAttribute("method")||ly,a=HE(e.getAttribute("enctype"))||cy,o=new FormData(e)}else if(Jfe(e)||epe(e)&&(e.type==="submit"||e.type==="image")){let l=e.form;if(l==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let u=e.getAttribute("formaction")||l.getAttribute("action");if(r=u?Na(u,t):null,n=e.getAttribute("formmethod")||l.getAttribute("method")||ly,a=HE(e.getAttribute("formenctype"))||HE(l.getAttribute("enctype"))||cy,o=new FormData(l,e),!ape()){let{name:f,type:m,value:h}=e;if(m==="image"){let g=f?`${f}.`:"";o.append(`${g}x`,"0"),o.append(`${g}y`,"0")}else f&&o.append(f,h)}}else{if(uw(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=ly,r=null,a=cy,i=e}return o&&a==="text/plain"&&(i=o,o=void 0),{action:r,method:n.toLowerCase(),encType:a,formData:o,body:i}}var WV=-1,KV=-2,YV=-3,ZV=-4,gC=-5,qV=-6,XV=-7,JV="B",QV="D",ed="E",__="M",e6="N",td="P",t6="R",T_="S",n6="Y",r6="U",N_="Z",a6=class{constructor(){this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}};function ipe(){const e=new TextDecoder;let t="";return new TransformStream({transform(n,r){const a=e.decode(n,{stream:!0}),o=(t+a).split(`
@@ -1750,7 +1750,7 @@ print(f"Available resources: {[resource.name for resource in resources]}")
1750
1750
  <\/script>
1751
1751
  </body>
1752
1752
  </html>`,aW=1,mF=2,oW=3,hF=4,sW=5,gF=Symbol.for("quilt.threads.serialize"),VSe=Symbol.for("quilt.threads.transferable");class GSe extends AbortController{constructor(...t){super();const n=t.find(r=>r.aborted);if(n)this.abort(n.reason);else{const r=o=>this.abort(o.target.reason),a={signal:this.signal};for(const o of t)o.addEventListener("abort",r,a)}}}class bF extends Error{constructor(){super("You attempted to call a function on a closed thread.")}}let WSe="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";function iW(e=21){let t="",n=crypto.getRandomValues(new Uint8Array(e));for(let r=0;r<e;r++)t+=WSe[63&n[r]];return t}var Lp,Cu,Mp,Ey,jT,lW;class KSe{constructor(){zo(this,jT),zo(this,Lp,new Map),zo(this,Cu,new Map),zo(this,Mp,new Map),zo(this,Ey,new WeakMap)}get(t){return sr(this,Cu).get(t)}release(t){const n=sr(this,Cu).get(t);return n&&(sr(this,Cu).delete(t),sr(this,Lp).delete(n)),!!n}serialize(t){let n=sr(this,Lp).get(t);return n==null&&(n=iW(),sr(this,Lp).set(t,n),sr(this,Cu).set(n,t)),n}deserialize(t,n){var r,a;let o=(r=sr(this,Mp).get(t))==null?void 0:r.deref();return o||(o=(...i)=>{if(!sr(this,Mp).has(t))throw new Error("You attempted to call a function that was already revoked.");return n.call((l,u,f)=>{n.messages.send([oW,l,t,u],f)},i)},(a=qr(this,jT,lW).call(this,n))==null||a.register(o,t),sr(this,Mp).set(t,new WeakRef(o)),o)}}Lp=new WeakMap,Cu=new WeakMap,Mp=new WeakMap,Ey=new WeakMap,jT=new WeakSet,lW=function(e){let t=sr(this,Ey).get(e);if(!(typeof FinalizationRegistry>"u"))return t||(t=new FinalizationRegistry(n=>{e.messages.send([sW,n])}),sr(this,Ey).set(e,t)),t};function YSe(e){return e!=null&&(Symbol.asyncIterator in e||Symbol.iterator in e)&&typeof e.next=="function"}function yF(e){if(e==null||typeof e!="object")return!1;const t=Object.getPrototypeOf(e);return t==null||t===Object.prototype}const xS="_@f",vF="_@i";var Qp,em,bo,Sy,Fi;class ZSe{constructor(t){zo(this,bo),zo(this,Qp),zo(this,em),LT(this,Qp,t?.serialize),LT(this,em,t?.deserialize)}serialize(t,n,r){return qr(this,bo,Sy).call(this,t,n,r)}deserialize(t,n){return qr(this,bo,Fi).call(this,t,n)}}Qp=new WeakMap,em=new WeakMap,bo=new WeakSet,Sy=function(e,t,n,r=new Map,a=!1){if(e==null)return e;if(r.has(e))return r.get(e);if(r.set(e,void 0),typeof e=="object"){if(sr(this,Qp)&&!a){const l=sr(this,Qp).call(this,e,u=>qr(this,bo,Sy).call(this,u,t,n,r,!0),t,n);if(l!==void 0)return r.set(e,l),l}if(e[VSe])return n?.push(e),r.set(e,e),e;const o=l=>qr(this,bo,Sy).call(this,l,t,n,r);if(typeof e[gF]=="function"){const l=e[gF]({serialize:o});return r.set(e,l),l}if(Array.isArray(e)){const l=e.map(u=>o(u));return r.set(e,l),l}if(e instanceof Map){const l=[...e.entries()].map(([f,m])=>[o(f),o(m)]),u=new Map(l);return r.set(e,u),u}if(e instanceof Set){const l=[...e].map(f=>o(f)),u=new Set(l);return r.set(e,u),u}const i=YSe(e);if(yF(e)||i){const l={};for(const u of Object.keys(e))l[u]=o(e[u]);return i&&(l.next??(l.next=o(e.next.bind(e))),l.return??(l.return=o(e.return.bind(e))),l.throw??(l.throw=o(e.throw.bind(e))),l[vF]=!0),r.set(e,l),l}}if(typeof e=="function"){const o=t.functions.serialize(e,t,n),i={[xS]:o};return r.set(e,i),i}return r.set(e,e),e},Fi=function(e,t,n=!1){if(e==null)return e;if(typeof e=="object"){if(sr(this,em)&&!n){const a=sr(this,em).call(this,e,o=>qr(this,bo,Fi).call(this,o,t,!0),t);if(a!==void 0)return a}if(e==null)return e;if(Array.isArray(e))return e.map(a=>qr(this,bo,Fi).call(this,a,t));if(e instanceof Map)return new Map([...e].map(([a,o])=>[qr(this,bo,Fi).call(this,a,t),qr(this,bo,Fi).call(this,o,t)]));if(e instanceof Set)return new Set([...e].map(a=>qr(this,bo,Fi).call(this,a,t)));if(xS in e)return t.functions.deserialize(e[xS],t);if(!yF(e))return e;const r={};for(const a of Object.keys(e))a===vF?r[Symbol.asyncIterator]=()=>r:r[a]=qr(this,bo,Fi).call(this,e[a],t);return r}return e};var Ru,rc,Bi,PT,cW,$T,uW;class qSe{constructor(t,{imports:n,exports:r,functions:a=new KSe,serialization:o=new ZSe,signal:i}={}){zo(this,Bi),zo(this,Ru),zo(this,rc,new Map);var l,u,f,m;this.messages=t,LT(this,Ru,i?new GSe(i):new AbortController),this.exports=r??{},this.imports=XSe(qr(this,Bi,cW).bind(this),n),this.functions=a,this.serialization=o,(u=(l=this.functions).start)==null||u.call(l,this),(m=(f=this.serialization).start)==null||m.call(f,this),this.signal.addEventListener("abort",()=>{for(const h of sr(this,rc).keys())qr(this,Bi,$T).call(this,h,void 0,new bF);sr(this,rc).clear()},{once:!0}),t.listen(async h=>{if(!(Array.isArray(h)&&typeof h[0]=="number"))return;const g=h;switch(g[0]){case aW:{const[,y,E,x]=g,w=this.exports[E]??(()=>{throw new Error(`No '${E}' method is exported from this thread`)});await qr(this,Bi,PT).call(this,w,x,(S,_,T)=>{this.messages.send([mF,y,S,_],T)});break}case oW:{const[,y,E,x]=g,w=this.functions.get(E,this)??JSe;await qr(this,Bi,PT).call(this,w,x,(S,_,T)=>{this.messages.send([hF,y,S,_],T)});break}case mF:case hF:{qr(this,Bi,$T).call(this,...g.slice(1));break}case sW:{const y=g[1];this.functions.release(y,this);break}}},{signal:this.signal})}get signal(){return sr(this,Ru).signal}get closed(){return sr(this,Ru).signal.aborted}close(){sr(this,Ru).abort()}call(t,n){if(this.closed)return Promise.reject(new bF);const r=[],a=this.serialization.serialize(n,this,r),o=iW(),i=qr(this,Bi,uW).call(this,o);return t(o,a,r),i}}Ru=new WeakMap,rc=new WeakMap,Bi=new WeakSet,PT=async function(e,t,n){try{const r=this.functions.call?await this.functions.call(e,t,this):await e(...this.serialization.deserialize(t,this)),a=[],o=this.serialization.serialize(r,this,a);n(o,void 0,a)}catch(r){n(void 0,this.serialization.serialize(r,this))}},cW=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,r,a)=>{this.messages.send([aW,n,e,r],a)},t)}catch(n){return Promise.reject(n)}}},$T=function(...e){const t=e[0],n=sr(this,rc).get(t);n&&(n(...e),sr(this,rc).delete(t))},uW=function(e){const t=new Promise((n,r)=>{sr(this,rc).set(e,(a,o,i)=>{i==null?n(this.serialization.deserialize(o,this)):r(this.serialization.deserialize(i,this))})});return Object.defineProperty(t,Symbol.asyncIterator,{async*value(){const n=await t;Object.defineProperty(n,Symbol.asyncIterator,{value:()=>n}),yield*n}}),t};function XSe(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 r=new Map;n=new Proxy({},{get(a,o){if(r.has(o))return r.get(o);const i=e(o);return r.set(o,i),i}})}else{n={};for(const r of t)Object.defineProperty(n,r,{value:e(r),writable:!1,configurable:!0,enumerable:!0})}return n}function JSe(){throw new Error("You attempted to call a function that is not stored. It may have already been released.")}const QSe="quilt.threads.ping",wF="quilt.threads.pong";function e_e(e,{targetOrigin:t="*"}={}){let n=!1;const r=function(o,i){e.postMessage(o,t,i)},a=new Promise(o=>{const i=new AbortController;globalThis.window.addEventListener("message",l=>{l.source===e&&l.data===wF&&(n=!0,i.abort(),o())},{signal:i.signal}),i.signal.addEventListener("abort",()=>o(),{once:!0}),r(QSe)});return{send(o,i){return n?r(o,i):a.then(()=>{if(n)return r(o,i)})},listen(o,{signal:i}){self.addEventListener("message",l=>{l.source===e&&l.data!==wF&&o(l.data)},{signal:i})}}}class t_e extends qSe{constructor(t,{targetOrigin:n="*",...r}={}){super(e_e(t.contentWindow,{targetOrigin:n}),r),this.iframe=t}}const dW=ue.forwardRef(({content:e,children:t,...n},r)=>d.jsx("span",{ref:r,...n,children:e||t}));dW.displayName="UIText";const fW=ue.forwardRef(({label:e,onPress:t,onClick:n,children:r,...a},o)=>d.jsx("button",{ref:o,onClick:i=>{t&&t(),n&&n(i)},style:{padding:"8px 16px",backgroundColor:"#007bff",color:"white",border:"none",borderRadius:"4px",cursor:"pointer"},...a,children:e||r}));fW.displayName="UIButton";const pW=ue.forwardRef(({direction:e="vertical",spacing:t="8",align:n="stretch",justify:r="flex-start",children:a,...o},i)=>d.jsx("div",{ref:i,style:{display:"flex",flexDirection:e==="horizontal"?"row":"column",gap:`${t}px`,alignItems:n,justifyContent:r},...o,children:a}));pW.displayName="UIStack";const mW=ue.forwardRef(({src:e,alt:t,width:n,height:r,children:a,...o},i)=>d.jsx("img",{ref:i,src:e,alt:t,width:n,height:r,style:{maxWidth:"100%",height:"auto",borderRadius:"8px",boxShadow:"0 2px 8px rgba(0, 0, 0, 0.1)"},...o}));mW.displayName="UIImage";const VO={name:"basic",elements:[{tagName:"ui-text",component:dW,propMapping:{content:"content"},eventMapping:{}},{tagName:"ui-button",component:fW,propMapping:{label:"label"},eventMapping:{press:"onPress"}},{tagName:"ui-stack",component:pW,propMapping:{direction:"direction",spacing:"spacing",align:"align",justify:"justify"},eventMapping:{}},{tagName:"ui-image",component:mW,propMapping:{src:"src",alt:"alt",width:"width",height:"height"},eventMapping:{}}]},n_e=({receiver:e})=>{const t=b.useRef(null);return b.useEffect(()=>{if(t.current)return e.connect(t.current),()=>{e.disconnect()}},[e]),d.jsx("div",{ref:t,"data-testid":"standard-dom-renderer-container"})},r_e=({resource:e,library:t,remoteElements:n=[],onUIAction:r})=>{const a=b.useRef(null),o=b.useRef(null),[i,l]=b.useState(null),u=b.useMemo(()=>(e.mimeType||"").includes("framework=react")?"react":"webcomponents",[e.mimeType]),f=`${t?.name}-${u}`,{receiver:m,components:h}=b.useMemo(()=>{switch(u){case"react":{const y=new LSe,E=t||VO,x=new Map;return E&&E.elements.forEach(w=>{const S=zSe(w.component);x.set(w.tagName,S)}),{receiver:y,components:x}}case"webcomponents":default:return{receiver:new MSe,components:null}}},[e,t,n]);b.useEffect(()=>{function y(E){var x;if(a.current&&E.source===a.current.contentWindow){const w=E.data;if(!w)return;(x=r?.(w))==null||x.catch(S=>{console.error("Error handling UI action result in RemoteDOMResourceRenderer:",S)})}}return window.addEventListener("message",y),()=>window.removeEventListener("message",y)},[r]),b.useEffect(()=>{const y=o.current;return o.current=null,()=>{y?.close()}},[f]);const g=()=>{const y=a.current;if(!y||o.current)return;const E=new t_e(y);o.current=E;const{code:x,error:w}=TSe(e);if(w){l(w);return}if(x&&m!=null&&m.connection){const S={code:x,remoteElements:n,useReactRenderer:u==="react",componentLibrary:t?.name};E.imports.render(S,m.connection).catch(_=>console.error("Error calling remote render:",_))}};return i?d.jsx("p",{className:"text-red-500",children:i}):d.jsxs(d.Fragment,{children:[d.jsx("iframe",{ref:a,srcDoc:HSe,sandbox:"allow-scripts",style:{display:"none"},title:"Remote DOM Sandbox",onLoad:g},f),u==="react"&&h?d.jsx(BSe,{receiver:m,components:h}):d.jsx(n_e,{receiver:m})]})};function a_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 GO=e=>{const{resource:t,onUIAction:n,supportedContentTypes:r,htmlProps:a,remoteDomProps:o}=e,i=a_e(t);if(r&&i&&!r.includes(i))return d.jsxs("p",{className:"text-red-500",children:["Unsupported content type: ",i,"."]});switch(i){case"rawHtml":case"externalUrl":return d.jsx(J7,{resource:t,onUIAction:n,...a});case"remoteDom":return d.jsx(r_e,{resource:t,onUIAction:n,library:o?.library||VO,...o});default:return d.jsx("p",{className:"text-red-500",children:"Unsupported resource type."})}};GO.displayName="UIResourceRenderer";const o_e={tagName:"ui-button",remoteAttributes:["label"],remoteEvents:["click","press"]},s_e={tagName:"ui-text",remoteAttributes:["content"]},i_e={tagName:"ui-stack",remoteAttributes:["direction","spacing","align","justify"]},l_e={tagName:"ui-image",remoteAttributes:["src","alt","width","height"]},c_e=b.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://")?d.jsx("div",{className:"my-4 p-0 border h-[350px] rounded-2xl border-zinc-200 overflow-hidden bg-card",children:d.jsx(GO,{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 xF({toolName:e,toolArgs:t,result:n,serverId:r,readResource:a,toolMeta:o}){const[i,l]=b.useState(null);b.useEffect(()=>{console.log("[ToolResultRenderer] Rendering:",{toolName:e,hasToolMeta:!!o,outputTemplate:o?.["openai/outputTemplate"],hasResult:!!n,hasServerId:!!r,hasReadResource:!!a})},[e,o,n,r,a]);const u=b.useMemo(()=>{if(typeof n=="string")try{return JSON.parse(n)}catch(y){return console.error("[ToolResultRenderer] Failed to parse result:",y),n}return n},[n]),f=b.useMemo(()=>!!o?.["openai/outputTemplate"],[o]),m=b.useMemo(()=>!!(u?.content&&Array.isArray(u.content)&&u.content.some(y=>y.type==="resource"&&y.resource?.uri?.startsWith("ui://")&&y.resource?.mimeType==="text/html+skybridge")),[u]),h=b.useMemo(()=>m&&u.content.find(E=>E.type==="resource"&&E.resource?.uri?.startsWith("ui://")&&E.resource?.mimeType==="text/html+skybridge")?.resource||null,[m,u]);if(b.useEffect(()=>{if(h){l(h);return}if(f&&o&&a){const y=o["openai/outputTemplate"];console.log("[ToolResultRenderer] Fetching resource for Apps SDK tool:",y),a(y).then(E=>{console.log("[ToolResultRenderer] Resource fetched:",E),E?.contents&&Array.isArray(E.contents)&&E.contents.length>0?l(E.contents[0]):console.warn("[ToolResultRenderer] No contents in fetched resource:",E)}).catch(E=>{console.error("[ToolResultRenderer] Failed to fetch resource:",E)})}},[h,f,o,a]),(f||m)&&i&&r&&a)return d.jsx(UO,{componentUrl:i.uri,toolName:e,toolArgs:t,toolResult:u,serverId:r,readResource:a,noWrapper:!0,className:"my-4",showConsole:!1});if((f||m)&&!i)return d.jsx("div",{className:"flex items-center justify-center w-full h-[200px] rounded border",children:d.jsx(oi,{className:"size-5"})});if(f&&(!r||!a))return console.error("[ToolResultRenderer] Apps SDK tool but missing serverId or readResource:",{toolName:e,hasServerId:!!r,hasReadResource:!!a}),d.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:d.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 y of u.content)y.type==="resource"&&y.resource?.uri?.startsWith("ui://")&&y.resource?.mimeType!=="text/html+skybridge"&&g.push(y.resource);return g.length>0?d.jsx(d.Fragment,{children:g.map(y=>d.jsx(c_e,{resource:y},`${e}-mcp-ui-${y.uri}`))}):(console.log("[ToolResultRenderer] Not rendering (no UI resources found):",{toolName:e,isAppsSdkTool:f,hasAppsSdkComponent:m,hasResourceData:!!i,contentLength:u?.content?.length}),null)}function u_e({content:e,timestamp:t}){return!e||e.length===0?null:d.jsx("div",{className:"flex items-start gap-3 justify-end group/user-message",children:d.jsxs("div",{className:"flex-1 min-w-0 flex flex-col items-end",children:[d.jsx("div",{className:"bg-zinc-200 dark:bg-zinc-800 text-primary rounded-3xl px-4 py-2 max-w-[80%] break-words",children:d.jsx("p",{className:"text-base leading-7 font-sans text-start break-words",children:e})}),t&&d.jsx("span",{className:"text-xs text-muted-foreground mt-1",children:new Date(t).toLocaleTimeString()})]})})}const d_e=b.memo(({messages:e,isLoading:t,serverId:n,readResource:r,tools:a})=>{const o=b.useRef(null),i=f=>a?.find(h=>h.name===f)?._meta;b.useEffect(()=>{e.length>0&&o.current&&o.current.scrollIntoView({behavior:t?"auto":"smooth",block:"start"})},[e.length,t]);const l=t&&(()=>{if(e.length===0)return!0;const f=e[e.length-1];if(f.role==="user")return!0;if(f.role==="assistant"){const m=typeof f.content=="string"?f.content:Array.isArray(f.content)?f.content.map(g=>typeof g=="string"?g:g.text||JSON.stringify(g)).join(""):JSON.stringify(f.content);return!(m&&m.trim().length>0)}return!1})(),u=f=>{if(!t)return!1;const m=e[e.length-1];return f.id===m.id&&m.role==="assistant"};return d.jsxs("div",{className:"space-y-6 max-w-3xl mx-auto px-2",children:[e.map(f=>{const m=typeof f.content=="string"?f.content:Array.isArray(f.content)?f.content.map(h=>typeof h=="string"?h:h.text||JSON.stringify(h)).join(""):JSON.stringify(f.content);return f.role==="user"?d.jsx(u_e,{content:m,timestamp:f.timestamp},f.id):f.role==="assistant"?d.jsx("div",{className:"space-y-4",children:f.parts&&f.parts.length>0?f.parts.map((h,g)=>{const y=h.type==="text"?`${f.id}-text-${g}-${h.text?.slice(0,20)}`:`${f.id}-tool-${h.toolInvocation?.toolName}-${g}`;return h.type==="text"?d.jsx(aF,{content:h.text||"",timestamp:g===f.parts.length-1?f.timestamp:void 0,_isStreaming:u(f)},y):h.type==="tool-invocation"&&h.toolInvocation?d.jsxs("div",{children:[d.jsx(oF,{toolName:h.toolInvocation.toolName,args:h.toolInvocation.args,result:h.toolInvocation.result,state:h.toolInvocation.state==="error"?"error":h.toolInvocation.state==="pending"?"call":"result"}),h.toolInvocation.result&&d.jsx(xF,{toolName:h.toolInvocation.toolName,toolArgs:h.toolInvocation.args,result:h.toolInvocation.result,serverId:n,readResource:r,toolMeta:i(h.toolInvocation.toolName)})]},y):null}):d.jsxs(d.Fragment,{children:[d.jsx(aF,{content:m,timestamp:f.timestamp,_isStreaming:u(f)}),f.toolCalls&&f.toolCalls.length>0&&d.jsx("div",{className:"space-y-2",children:f.toolCalls.map(h=>{const g=`${f.id}-${h.toolName}-${JSON.stringify(h.args).slice(0,50)}`;return d.jsxs("div",{children:[d.jsx(oF,{toolName:h.toolName,args:h.args,result:h.result,state:h.result?"result":"call"}),h.result&&d.jsx(xF,{toolName:h.toolName,toolArgs:h.args,result:h.result,serverId:n,readResource:r,toolMeta:i(h.toolName)})]},g)})})]})},f.id):null}),l&&d.jsx("div",{className:"flex items-start gap-3",children:d.jsx("div",{className:"flex-1",children:d.jsx("div",{className:"rounded-lg p-4 max-w-fit",children:d.jsx("div",{className:"flex items-center gap-2",children:d.jsx("span",{className:"text-sm",children:d.jsx(Vxe,{duration:2,spread:1,children:"Thinking..."})})})})})}),d.jsx("div",{ref:o})]})});function hW(e){let t=0;for(let n=0;n<e.length;n++){const r=e.charCodeAt(n);t=(t<<5)-t+r,t=t&t}return Math.abs(t).toString(16)}function f_e({mcpServerUrl:e,llmConfig:t,authConfig:n,isConnected:r}){const[a,o]=b.useState([]),[i,l]=b.useState(!1),u=b.useRef(null),f=b.useCallback(async g=>{if(!g.trim()||!t||!r)return;const y={id:`user-${Date.now()}`,role:"user",content:g.trim(),timestamp:Date.now()};o(E=>[...E,y]),l(!0),u.current=new AbortController;try{let E=n;if(n?.type==="oauth")try{const k="mcp:auth",C=hW(e),O=`${k}_${C}_tokens`,M=localStorage.getItem(O);if(M){const L=JSON.parse(M);E={...n,oauthTokens:L}}else console.warn("No OAuth tokens found in localStorage for key:",O)}catch(k){console.warn("Failed to retrieve OAuth tokens:",k)}const x=await fetch("/inspector/api/chat/stream",{method:"POST",headers:{"Content-Type":"application/json"},signal:u.current.signal,body:JSON.stringify({mcpServerUrl:e,llmConfig:t,authConfig:E,messages:[...a,y].map(k=>({role:k.role,content:k.content}))})});if(!x.ok)throw new Error(`HTTP error! status: ${x.status}`);const w=`assistant-${Date.now()}`;let S="";const _=[];o(k=>[...k,{id:w,role:"assistant",content:"",timestamp:Date.now(),parts:[]}]);const T=x.body?.getReader(),A=new TextDecoder;if(!T)throw new Error("No response body");let R="";for(;;){if(u.current?.signal.aborted){await T.cancel();break}const{done:k,value:C}=await T.read();if(k)break;R+=A.decode(C,{stream:!0});const O=R.split(`
1753
- `);R=O.pop()||"";for(const M of O)if(M.trim()&&M.startsWith("data: "))try{const L=JSON.parse(M.slice(6));if(console.log("[Client received event]",L.type,L.toolName||L.content?.slice?.(0,30)),L.type==="message")console.log("[Message started]",L.id);else if(L.type==="text"){S+=L.content;const $=_[_.length-1];$&&$.type==="text"?$.text=S:_.push({type:"text",text:S}),console.log("[Parts after text]",_.length,"parts, text length:",S.length),o(H=>H.map(V=>V.id===w?{...V,parts:[..._]}:V))}else if(L.type==="tool-call")S&&(S=""),_.push({type:"tool-invocation",toolInvocation:{toolName:L.toolName,args:L.args,state:"pending"}}),console.log("[Parts after tool-call]",_.length,"parts, tool:",L.toolName),o($=>$.map(H=>H.id===w?{...H,parts:[..._]}:H));else if(L.type==="tool-result"){const $=_.find(H=>H.type==="tool-invocation"&&H.toolInvocation?.toolName===L.toolName&&!H.toolInvocation?.result);$&&$.toolInvocation?($.toolInvocation.result=L.result,$.toolInvocation.state="result",console.log("[Parts after tool-result]",_.length,"parts, updated:",L.toolName),o(H=>H.map(V=>V.id===w?{...V,parts:[..._]}:V))):console.warn("[tool-result] Could not find matching tool part for",L.toolName)}else if(L.type==="done")console.log("[Done] Final parts:",_.length),o($=>$.map(H=>H.id===w?{...H,parts:[..._],content:""}:H));else if(L.type==="error")throw new Error(L.message||"Streaming error")}catch(L){console.error("Failed to parse streaming event:",L,M)}}if(u.current?.signal.aborted){for(const k of _)k.type==="tool-invocation"&&k.toolInvocation?.state==="pending"&&(k.toolInvocation.state="error",k.toolInvocation.result="Cancelled by user");o(k=>k.map(C=>C.id===w?{...C,parts:[..._],content:""}:C))}}catch(E){if(E instanceof DOMException&&E.name==="AbortError")return;let x="Unknown error occurred";if(E instanceof Error){x=E.message;const S=E;S.status&&(x=`HTTP ${S.status}: ${x}`),(S.code===401||x.includes("401")||x.includes("Unauthorized"))&&(x="Authentication failed (401). Check your Authorization header in the connection settings.")}const w={id:`error-${Date.now()}`,role:"assistant",content:`Error: ${x}`,timestamp:Date.now()};o(S=>[...S,w])}finally{l(!1),u.current=null}},[t,r,e,a,n]),m=b.useCallback(()=>{o([])},[]),h=b.useCallback(()=>{u.current&&u.current.abort()},[]);return{messages:a,isLoading:i,sendMessage:f,clearMessages:m,stop:h}}function p_e({connection:e,llmConfig:t,isConnected:n,readResource:r}){const[a,o]=b.useState([]),[i,l]=b.useState(!1),u=b.useRef(null),f=b.useRef(null),m=b.useRef(null),h=b.useCallback(async E=>{if(!E.trim()||!t||!n)return;const x={id:`user-${Date.now()}`,role:"user",content:E.trim(),timestamp:Date.now()};o(_=>[..._,x]),l(!0),u.current=new AbortController;const w=Date.now();let S=0;try{const _=`assistant-${Date.now()}`;let T="";const A=[];if(o(R=>[...R,{id:_,role:"assistant",content:"",timestamp:Date.now(),parts:[]}]),!m.current||m.current.provider!==t.provider||m.current.model!==t.model||m.current.apiKey!==t.apiKey){let R;if(t.provider==="openai"){const{ChatOpenAI:k}=await Ua(async()=>{const{ChatOpenAI:C}=await import("./index-CViqT8bM.js");return{ChatOpenAI:C}},__vite__mapDeps([0,1,2,3,4,5]));R=new k({model:t.model,apiKey:t.apiKey})}else if(t.provider==="anthropic"){const{ChatAnthropic:k}=await Ua(async()=>{const{ChatAnthropic:C}=await import("./index-B3BSS2WR.js");return{ChatAnthropic:C}},__vite__mapDeps([6,2,1,5]));R=new k({model:t.model,apiKey:t.apiKey})}else if(t.provider==="google"){const{ChatGoogleGenerativeAI:k}=await Ua(async()=>{const{ChatGoogleGenerativeAI:C}=await import("./index-oD85ijkM.js");return{ChatGoogleGenerativeAI:C}},__vite__mapDeps([7,2,1,4]));R=new k({model:t.model,apiKey:t.apiKey})}else throw new Error(`Unsupported LLM provider: ${t.provider}`);m.current={instance:R,provider:t.provider,model:t.model,apiKey:t.apiKey}}if(!f.current||f.current.llm!==m.current.instance){const{MCPAgent:R}=await Ua(async()=>{const{MCPAgent:k}=await import("./browser-CffKCGrT.js");return{MCPAgent:k}},__vite__mapDeps([8,5,1,2,4,3]));f.current=new R({llm:m.current.instance,client:e.client??void 0,memoryEnabled:!0,systemPrompt:"You are a helpful assistant with access to MCP tools, prompts, and resources. Help users interact with the MCP server."}),await f.current.initialize()}else console.log("[useChatMessagesClientSide] Reusing existing agent. History length:",f.current.conversationHistory?.length);for await(const R of f.current.streamEvents(E,10,!1,void 0,void 0,u.current?.signal)){if(u.current?.signal.aborted)break;if(R.event==="on_chat_model_stream"&&R.data?.chunk?.text){const k=R.data.chunk.text;if(typeof k=="string"&&k.length>0){T+=k;const C=A[A.length-1];C&&C.type==="text"?C.text=T:A.push({type:"text",text:T}),o(O=>O.map(M=>M.id===_?{...M,parts:[...A]}:M))}}else if(R.event==="on_tool_start"){T&&(T="");let k={};R.data?.input?k=R.data.input:R.data?.tool_input?k=R.data.tool_input:R.data&&(k=R.data),console.log("[useChatMessagesClientSide] on_tool_start:",{toolName:R.name,eventData:R.data,extractedArgs:k}),S++,A.push({type:"tool-invocation",toolInvocation:{toolName:R.name||"unknown",args:k,state:"pending"}}),o(C=>C.map(O=>O.id===_?{...O,parts:[...A]}:O))}else if(R.event==="on_tool_end"){const k=A.find(C=>C.type==="tool-invocation"&&C.toolInvocation?.toolName===R.name&&!C.toolInvocation?.result);if(console.log("[useChatMessagesClientSide] on_tool_end event:",{toolName:R.name,hasToolPart:!!k,output:R.data?.output}),k&&k.toolInvocation){let C=R.data?.output;if(C?.kwargs?.content&&typeof C.kwargs.content=="string")try{C=JSON.parse(C.kwargs.content)}catch(M){console.warn("[useChatMessagesClientSide] Failed to parse kwargs.content:",M),C=C.kwargs.content}else if(C?.content&&typeof C.content=="string")try{C=JSON.parse(C.content)}catch{C=C.content}k.toolInvocation.result=C,k.toolInvocation.state="result";const O=C?._meta?.["openai/outputTemplate"];if(console.log("[useChatMessagesClientSide] Tool result:",{toolName:R.name,hasMeta:!!C?._meta,hasStructuredContent:!!C?.structuredContent,appsSdkUri:O}),O&&typeof O=="string"&&r){console.log("[useChatMessagesClientSide] Detected Apps SDK component, fetching resource:",O);try{const M=await r(O);console.log("[useChatMessagesClientSide] Resource fetched:",M);const L=C?.structuredContent||null;if(M?.contents&&Array.isArray(M.contents)){const $=M.contents.map(V=>({type:"resource",resource:V}));console.log("[useChatMessagesClientSide] Created MCP resources:",$);const H={...C,content:[...C.content||[],...$],structuredContent:L};k.toolInvocation.result=H,console.log("[useChatMessagesClientSide] Updated result with resources")}else console.warn("[useChatMessagesClientSide] No contents in resourceData:",M)}catch(M){console.error("Failed to fetch Apps SDK resource:",M)}}o(M=>M.map(L=>L.id===_?{...L,parts:[...A]}:L))}}}if(u.current?.signal.aborted)for(const R of A)R.type==="tool-invocation"&&R.toolInvocation?.state==="pending"&&(R.toolInvocation.state="error",R.toolInvocation.result="Cancelled by user");o(R=>R.map(k=>k.id===_?{...k,parts:[...A],content:""}:k)),t&&ra.getInstance().capture(new wU({serverId:e.url,provider:t.provider,model:t.model,messageCount:a.length+1,toolCallsCount:S,success:!0,executionMode:"client-side",duration:Date.now()-w})).catch(()=>{})}catch(_){if(_ instanceof DOMException&&_.name==="AbortError")return;console.error("Client-side agent error:",_);let T="Unknown error occurred";if(_ instanceof Error){T=_.message;const R=_;R.status&&(T=`HTTP ${R.status}: ${T}`),(R.code===401||T.includes("401")||T.includes("Unauthorized"))&&(T="Authentication failed (401). Check your Authorization header in the connection settings.")}t&&ra.getInstance().capture(new wU({serverId:e.url,provider:t.provider,model:t.model,messageCount:a.length+1,toolCallsCount:S,success:!1,executionMode:"client-side",duration:Date.now()-w,error:T})).catch(()=>{});const A={id:`error-${Date.now()}`,role:"assistant",content:`Error: ${T}`,timestamp:Date.now()};o(R=>[...R,A])}finally{l(!1),u.current=null}},[e,t,n,a,r]),g=b.useCallback(()=>{o([]),f.current&&f.current.clearConversationHistory()},[]),y=b.useCallback(()=>{u.current&&u.current.abort()},[]);return{messages:a,isLoading:i,sendMessage:h,clearMessages:g,stop:y}}const EF={openai:"gpt-4o",anthropic:"claude-haiku-4-5-20251001",google:"gemini-2.5-flash"};function gW({mcpServerUrl:e}){const[t,n]=b.useState(null),[r,a]=b.useState(null),[o,i]=b.useState(!1),[l,u]=b.useState("openai"),[f,m]=b.useState(""),[h,g]=b.useState(EF.openai),y=b.useCallback(()=>{const M=localStorage.getItem("mcp-inspector-api-keys");if(M)try{return JSON.parse(M)}catch(L){return console.error("Failed to load API keys:",L),{}}return{}},[]),E=b.useCallback(M=>{localStorage.setItem("mcp-inspector-api-keys",JSON.stringify(M))},[]),[x,w]=b.useState("none"),[S,_]=b.useState(""),[T,A]=b.useState(""),[R,k]=b.useState("");b.useEffect(()=>{const M=localStorage.getItem("mcp-inspector-llm-config"),L=y();if(M)try{const $=JSON.parse(M);n($),u($.provider),m(L[$.provider]||$.apiKey||""),g($.model)}catch($){console.error("Failed to load LLM config:",$)}},[y]),b.useEffect(()=>{const M=localStorage.getItem("mcp-inspector-auth-config");if(M)try{const L=JSON.parse(M);a(L),w(L.type),L.username&&_(L.username),L.password&&A(L.password),L.token&&k(L.token)}catch(L){console.error("Failed to load auth config:",L)}else try{const L="mcp:auth",$=hW(e),H=`${L}_${$}_tokens`;localStorage.getItem(H)&&(a({type:"oauth"}),w("oauth"))}catch(L){console.error("Failed to check for OAuth tokens:",L)}},[e]),b.useEffect(()=>{g(EF[l]);const M=y();m(M[l]||"")},[l,y]);const C=b.useCallback(()=>{if(!f.trim())return;const M=y();M[l]=f,E(M);const L={provider:l,apiKey:f,model:h},$={type:x,...x==="basic"&&{username:S.trim(),password:T.trim()},...x==="bearer"&&{token:R.trim()}};n(L),a($),localStorage.setItem("mcp-inspector-llm-config",JSON.stringify(L)),localStorage.setItem("mcp-inspector-auth-config",JSON.stringify($)),i(!1)},[l,f,h,x,S,T,R,y,E]),O=b.useCallback(()=>{n(null),a(null);const M=y();delete M[l],E(M),m(""),_(""),A(""),k(""),w("none"),localStorage.removeItem("mcp-inspector-llm-config"),localStorage.removeItem("mcp-inspector-auth-config")},[l,y,E]);return{llmConfig:t,authConfig:r,configDialogOpen:o,setConfigDialogOpen:i,tempProvider:l,setTempProvider:u,tempApiKey:f,setTempApiKey:m,tempModel:h,setTempModel:g,tempAuthType:x,saveLLMConfig:C,clearConfig:O}}function m_e({connection:e,isConnected:t,useClientSide:n=!0,readResource:r}){const[a,o]=b.useState(""),i=b.useRef(null),{llmConfig:l,authConfig:u,configDialogOpen:f,setConfigDialogOpen:m,tempProvider:h,setTempProvider:g,tempApiKey:y,setTempApiKey:E,tempModel:x,setTempModel:w,saveLLMConfig:S,clearConfig:_}=gW({mcpServerUrl:e.url}),T={connection:e,llmConfig:l,isConnected:t,readResource:r},A=f_e({mcpServerUrl:e.url,llmConfig:l,authConfig:u,isConnected:t}),R=p_e(T),{messages:k,isLoading:C,sendMessage:O,clearMessages:M,stop:L}=n?R:A;RG({onNewChat:M}),b.useEffect(()=>{l&&k.length===0&&i.current&&i.current.focus()},[l,k.length]),b.useEffect(()=>{!C&&k.length>0&&i.current&&i.current.focus()},[C,k.length]);const $=b.useCallback(()=>{a.trim()&&(O(a),o(""))},[a,O]),H=b.useCallback(Z=>{Z.key==="Enter"&&!Z.shiftKey&&(Z.preventDefault(),$())},[$]),V=b.useCallback(()=>{_(),M()},[_,M]);return l&&k.length===0?d.jsxs("div",{className:"flex flex-col h-full",children:[d.jsx("div",{className:"absolute top-4 right-4 z-10",children:d.jsx(yT,{open:f,onOpenChange:m,tempProvider:h,tempModel:x,tempApiKey:y,onProviderChange:g,onModelChange:w,onApiKeyChange:E,onSave:S,onClear:V,showClearButton:!0,buttonLabel:"Change API Key"})}),d.jsx(Bxe,{mcpServerUrl:e.url,inputValue:a,isConnected:t,isLoading:C,textareaRef:i,llmConfig:l,onInputChange:o,onKeyDown:H,onSubmit:Z=>{Z.preventDefault(),$()},onConfigDialogOpenChange:m})]}):d.jsxs("div",{className:"flex flex-col h-full relative",children:[d.jsx(Uxe,{llmConfig:l,hasMessages:k.length>0,configDialogOpen:f,onConfigDialogOpenChange:m,onClearChat:M,tempProvider:h,tempModel:x,tempApiKey:y,onProviderChange:g,onModelChange:w,onApiKeyChange:E,onSaveConfig:S,onClearConfig:V}),d.jsx("div",{className:"flex-1 overflow-y-auto p-2 sm:p-4 pt-[80px] sm:pt-[100px]",children:l?d.jsx(d_e,{messages:k,isLoading:C,serverId:e.url,readResource:r,tools:e.tools}):d.jsx(Hxe,{onConfigureClick:()=>m(!0)})}),l&&d.jsx(zxe,{inputValue:a,isConnected:t,isLoading:C,textareaRef:i,onInputChange:o,onKeyDown:H,onSendMessage:$,onStopStreaming:L})]})}const Fw=b.createContext(null);Fw.displayName="PanelGroupContext";const br={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"},WO=10,ic=b.useLayoutEffect,SF=Ec.useId,h_e=typeof SF=="function"?SF:()=>null;let g_e=0;function KO(e=null){const t=h_e(),n=b.useRef(e||t||null);return n.current===null&&(n.current=""+g_e++),e??n.current}function bW({children:e,className:t="",collapsedSize:n,collapsible:r,defaultSize:a,forwardedRef:o,id:i,maxSize:l,minSize:u,onCollapse:f,onExpand:m,onResize:h,order:g,style:y,tagName:E="div",...x}){const w=b.useContext(Fw);if(w===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:S,expandPanel:_,getPanelSize:T,getPanelStyle:A,groupId:R,isPanelCollapsed:k,reevaluatePanelConstraints:C,registerPanel:O,resizePanel:M,unregisterPanel:L}=w,$=KO(i),H=b.useRef({callbacks:{onCollapse:f,onExpand:m,onResize:h},constraints:{collapsedSize:n,collapsible:r,defaultSize:a,maxSize:l,minSize:u},id:$,idIsFromProps:i!==void 0,order:g});b.useRef({didLogMissingDefaultSizeWarning:!1}),ic(()=>{const{callbacks:Z,constraints:ne}=H.current,G={...ne};H.current.id=$,H.current.idIsFromProps=i!==void 0,H.current.order=g,Z.onCollapse=f,Z.onExpand=m,Z.onResize=h,ne.collapsedSize=n,ne.collapsible=r,ne.defaultSize=a,ne.maxSize=l,ne.minSize=u,(G.collapsedSize!==ne.collapsedSize||G.collapsible!==ne.collapsible||G.maxSize!==ne.maxSize||G.minSize!==ne.minSize)&&C(H.current,G)}),ic(()=>{const Z=H.current;return O(Z),()=>{L(Z)}},[g,$,O,L]),b.useImperativeHandle(o,()=>({collapse:()=>{S(H.current)},expand:Z=>{_(H.current,Z)},getId(){return $},getSize(){return T(H.current)},isCollapsed(){return k(H.current)},isExpanded(){return!k(H.current)},resize:Z=>{M(H.current,Z)}}),[S,_,T,k,$,M]);const V=A(H.current,a);return b.createElement(E,{...x,children:e,className:t,id:$,style:{...V,...y},[br.groupId]:R,[br.panel]:"",[br.panelCollapsible]:r||void 0,[br.panelId]:$,[br.panelSize]:parseFloat(""+V.flexGrow).toFixed(1)})}const yW=b.forwardRef((e,t)=>b.createElement(bW,{...e,forwardedRef:t}));bW.displayName="Panel";yW.displayName="forwardRef(Panel)";let UT=null,_y=-1,Ki=null;function b_e(e,t,n){const r=(t&SW)!==0,a=(t&_W)!==0,o=(t&TW)!==0,i=(t&NW)!==0;if(t){if(r)return o?"se-resize":i?"ne-resize":"e-resize";if(a)return o?"sw-resize":i?"nw-resize":"w-resize";if(o)return"s-resize";if(i)return"n-resize"}switch(e){case"horizontal":return"ew-resize";case"intersection":return"move";case"vertical":return"ns-resize"}}function y_e(){Ki!==null&&(document.head.removeChild(Ki),UT=null,Ki=null,_y=-1)}function ES(e,t,n){var r,a;const o=b_e(e,t);if(UT!==o){if(UT=o,Ki===null&&(Ki=document.createElement("style"),document.head.appendChild(Ki)),_y>=0){var i;(i=Ki.sheet)===null||i===void 0||i.removeRule(_y)}_y=(r=(a=Ki.sheet)===null||a===void 0?void 0:a.insertRule(`*{cursor: ${o} !important;}`))!==null&&r!==void 0?r:-1}}function vW(e){return e.type==="keydown"}function wW(e){return e.type.startsWith("pointer")}function xW(e){return e.type.startsWith("mouse")}function Bw(e){if(wW(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(xW(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}function v_e(){if(typeof matchMedia=="function")return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}function w_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 x_e(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:NF(e),b:NF(t)};let r;for(;n.a.at(-1)===n.b.at(-1);)e=n.a.pop(),t=n.b.pop(),r=e;tn(r,"Stacking order can only be calculated for elements with a common ancestor");const a={a:TF(_F(n.a)),b:TF(_F(n.b))};if(a.a===a.b){const o=r.childNodes,i={a:n.a.at(-1),b:n.b.at(-1)};let l=o.length;for(;l--;){const u=o[l];if(u===i.a)return 1;if(u===i.b)return-1}}return Math.sign(a.a-a.b)}const E_e=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function S_e(e){var t;const n=getComputedStyle((t=EW(e))!==null&&t!==void 0?t:e).display;return n==="flex"||n==="inline-flex"}function __e(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||S_e(e))||+t.opacity<1||"transform"in t&&t.transform!=="none"||"webkitTransform"in t&&t.webkitTransform!=="none"||"mixBlendMode"in t&&t.mixBlendMode!=="normal"||"filter"in t&&t.filter!=="none"||"webkitFilter"in t&&t.webkitFilter!=="none"||"isolation"in t&&t.isolation==="isolate"||E_e.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function _F(e){let t=e.length;for(;t--;){const n=e[t];if(tn(n,"Missing node"),__e(n))return n}return null}function TF(e){return e&&Number(getComputedStyle(e).zIndex)||0}function NF(e){const t=[];for(;e;)t.push(e),e=EW(e);return t}function EW(e){const{parentNode:t}=e;return t&&t instanceof ShadowRoot?t.host:t}const SW=1,_W=2,TW=4,NW=8,T_e=v_e()==="coarse";let Bo=[],od=!1,Yi=new Map,Hw=new Map;const Um=new Set;function N_e(e,t,n,r,a){var o;const{ownerDocument:i}=t,l={direction:n,element:t,hitAreaMargins:r,setResizeHandlerState:a},u=(o=Yi.get(i))!==null&&o!==void 0?o:0;return Yi.set(i,u+1),Um.add(l),Ev(),function(){var m;Hw.delete(e),Um.delete(l);const h=(m=Yi.get(i))!==null&&m!==void 0?m:1;if(Yi.set(i,h-1),Ev(),h===1&&Yi.delete(i),Bo.includes(l)){const g=Bo.indexOf(l);g>=0&&Bo.splice(g,1),Vw(),a("up",!0,null)}}}function C_e(e){const{target:t}=e,{x:n,y:r}=Bw(e);od=!0,YO({target:t,x:n,y:r}),Ev(),Bo.length>0&&(Sv("down",e),Vw(),e.preventDefault(),CW(t)||e.stopImmediatePropagation())}function SS(e){const{x:t,y:n}=Bw(e);if(od&&e.type!=="pointerleave"&&e.buttons===0&&(od=!1,Sv("up",e)),!od){const{target:r}=e;YO({target:r,x:t,y:n})}Sv("move",e),Vw(),Bo.length>0&&e.preventDefault()}function _S(e){const{target:t}=e,{x:n,y:r}=Bw(e);Hw.clear(),od=!1,Bo.length>0&&(e.preventDefault(),CW(t)||e.stopImmediatePropagation()),Sv("up",e),YO({target:t,x:n,y:r}),Vw(),Ev()}function CW(e){let t=e;for(;t;){if(t.hasAttribute(br.resizeHandle))return!0;t=t.parentElement}return!1}function YO({target:e,x:t,y:n}){Bo.splice(0);let r=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(r=e),Um.forEach(a=>{const{element:o,hitAreaMargins:i}=a,l=o.getBoundingClientRect(),{bottom:u,left:f,right:m,top:h}=l,g=T_e?i.coarse:i.fine;if(t>=f-g&&t<=m+g&&n>=h-g&&n<=u+g){if(r!==null&&document.contains(r)&&o!==r&&!o.contains(r)&&!r.contains(o)&&x_e(r,o)>0){let E=r,x=!1;for(;E&&!E.contains(o);){if(w_e(E.getBoundingClientRect(),l)){x=!0;break}E=E.parentElement}if(x)return}Bo.push(a)}})}function TS(e,t){Hw.set(e,t)}function Vw(){let e=!1,t=!1;Bo.forEach(r=>{const{direction:a}=r;a==="horizontal"?e=!0:t=!0});let n=0;Hw.forEach(r=>{n|=r}),e&&t?ES("intersection",n):e?ES("horizontal",n):t?ES("vertical",n):y_e()}let NS;function Ev(){var e;(e=NS)===null||e===void 0||e.abort(),NS=new AbortController;const t={capture:!0,signal:NS.signal};Um.size&&(od?(Bo.length>0&&Yi.forEach((n,r)=>{const{body:a}=r;n>0&&(a.addEventListener("contextmenu",_S,t),a.addEventListener("pointerleave",SS,t),a.addEventListener("pointermove",SS,t))}),Yi.forEach((n,r)=>{const{body:a}=r;a.addEventListener("pointerup",_S,t),a.addEventListener("pointercancel",_S,t)})):Yi.forEach((n,r)=>{const{body:a}=r;n>0&&(a.addEventListener("pointerdown",C_e,t),a.addEventListener("pointermove",SS,t))}))}function Sv(e,t){Um.forEach(n=>{const{setResizeHandlerState:r}=n,a=Bo.includes(n);r(e,a,t)})}function R_e(){const[e,t]=b.useState(0);return b.useCallback(()=>t(n=>n+1),[])}function tn(e,t){if(!e)throw console.error(t),Error(t)}function vc(e,t,n=WO){return e.toFixed(n)===t.toFixed(n)?0:e>t?1:-1}function Gs(e,t,n=WO){return vc(e,t,n)===0}function Qa(e,t,n){return vc(e,t,n)===0}function k_e(e,t,n){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++){const a=e[r],o=t[r];if(!Qa(a,o,n))return!1}return!0}function Ku({panelConstraints:e,panelIndex:t,size:n}){const r=e[t];tn(r!=null,`Panel constraints not found for index ${t}`);let{collapsedSize:a=0,collapsible:o,maxSize:i=100,minSize:l=0}=r;if(vc(n,l)<0)if(o){const u=(a+l)/2;vc(n,u)<0?n=a:n=l}else n=l;return n=Math.min(i,n),n=parseFloat(n.toFixed(WO)),n}function jp({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:a,trigger:o}){if(Qa(e,0))return t;const i=[...t],[l,u]=r;tn(l!=null,"Invalid first pivot index"),tn(u!=null,"Invalid second pivot index");let f=0;if(o==="keyboard"){{const h=e<0?u:l,g=n[h];tn(g,`Panel constraints not found for index ${h}`);const{collapsedSize:y=0,collapsible:E,minSize:x=0}=g;if(E){const w=t[h];if(tn(w!=null,`Previous layout not found for panel index ${h}`),Qa(w,y)){const S=x-w;vc(S,Math.abs(e))>0&&(e=e<0?0-S:S)}}}{const h=e<0?l:u,g=n[h];tn(g,`No panel constraints found for index ${h}`);const{collapsedSize:y=0,collapsible:E,minSize:x=0}=g;if(E){const w=t[h];if(tn(w!=null,`Previous layout not found for panel index ${h}`),Qa(w,x)){const S=w-y;vc(S,Math.abs(e))>0&&(e=e<0?0-S:S)}}}}{const h=e<0?1:-1;let g=e<0?u:l,y=0;for(;;){const x=t[g];tn(x!=null,`Previous layout not found for panel index ${g}`);const S=Ku({panelConstraints:n,panelIndex:g,size:100})-x;if(y+=S,g+=h,g<0||g>=n.length)break}const E=Math.min(Math.abs(e),Math.abs(y));e=e<0?0-E:E}{let g=e<0?l:u;for(;g>=0&&g<n.length;){const y=Math.abs(e)-Math.abs(f),E=t[g];tn(E!=null,`Previous layout not found for panel index ${g}`);const x=E-y,w=Ku({panelConstraints:n,panelIndex:g,size:x});if(!Qa(E,w)&&(f+=E-w,i[g]=w,f.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?g--:g++}}if(k_e(a,i))return a;{const h=e<0?u:l,g=t[h];tn(g!=null,`Previous layout not found for panel index ${h}`);const y=g+f,E=Ku({panelConstraints:n,panelIndex:h,size:y});if(i[h]=E,!Qa(E,y)){let x=y-E,S=e<0?u:l;for(;S>=0&&S<n.length;){const _=i[S];tn(_!=null,`Previous layout not found for panel index ${S}`);const T=_+x,A=Ku({panelConstraints:n,panelIndex:S,size:T});if(Qa(_,A)||(x-=A-_,i[S]=A),Qa(x,0))break;e>0?S--:S++}}}const m=i.reduce((h,g)=>g+h,0);return Qa(m,100)?i:a}function A_e({layout:e,panelsArray:t,pivotIndices:n}){let r=0,a=100,o=0,i=0;const l=n[0];tn(l!=null,"No pivot index found"),t.forEach((h,g)=>{const{constraints:y}=h,{maxSize:E=100,minSize:x=0}=y;g===l?(r=x,a=E):(o+=x,i+=E)});const u=Math.min(a,100-o),f=Math.max(r,100-i),m=e[l];return{valueMax:u,valueMin:f,valueNow:m}}function zm(e,t=document){return Array.from(t.querySelectorAll(`[${br.resizeHandleId}][data-panel-group-id="${e}"]`))}function RW(e,t,n=document){const a=zm(e,n).findIndex(o=>o.getAttribute(br.resizeHandleId)===t);return a??null}function kW(e,t,n){const r=RW(e,t,n);return r!=null?[r,r+1]:[-1,-1]}function I_e(e){return e instanceof HTMLElement?!0:typeof e=="object"&&e!==null&&"tagName"in e&&"getAttribute"in e}function AW(e,t=document){if(I_e(t)&&t.dataset.panelGroupId==e)return t;const n=t.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return n||null}function Gw(e,t=document){const n=t.querySelector(`[${br.resizeHandleId}="${e}"]`);return n||null}function O_e(e,t,n,r=document){var a,o,i,l;const u=Gw(t,r),f=zm(e,r),m=u?f.indexOf(u):-1,h=(a=(o=n[m])===null||o===void 0?void 0:o.id)!==null&&a!==void 0?a:null,g=(i=(l=n[m+1])===null||l===void 0?void 0:l.id)!==null&&i!==void 0?i:null;return[h,g]}function D_e({committedValuesRef:e,eagerValuesRef:t,groupId:n,layout:r,panelDataArray:a,panelGroupElement:o,setLayout:i}){b.useRef({didWarnAboutMissingResizeHandle:!1}),ic(()=>{if(!o)return;const l=zm(n,o);for(let u=0;u<a.length-1;u++){const{valueMax:f,valueMin:m,valueNow:h}=A_e({layout:r,panelsArray:a,pivotIndices:[u,u+1]}),g=l[u];if(g!=null){const y=a[u];tn(y,`No panel data found for index "${u}"`),g.setAttribute("aria-controls",y.id),g.setAttribute("aria-valuemax",""+Math.round(f)),g.setAttribute("aria-valuemin",""+Math.round(m)),g.setAttribute("aria-valuenow",h!=null?""+Math.round(h):"")}}return()=>{l.forEach((u,f)=>{u.removeAttribute("aria-controls"),u.removeAttribute("aria-valuemax"),u.removeAttribute("aria-valuemin"),u.removeAttribute("aria-valuenow")})}},[n,r,a,o]),b.useEffect(()=>{if(!o)return;const l=t.current;tn(l,"Eager values not found");const{panelDataArray:u}=l,f=AW(n,o);tn(f!=null,`No group found for id "${n}"`);const m=zm(n,o);tn(m,`No resize handles found for group id "${n}"`);const h=m.map(g=>{const y=g.getAttribute(br.resizeHandleId);tn(y,"Resize handle element has no handle id attribute");const[E,x]=O_e(n,y,u,o);if(E==null||x==null)return()=>{};const w=S=>{if(!S.defaultPrevented)switch(S.key){case"Enter":{S.preventDefault();const _=u.findIndex(T=>T.id===E);if(_>=0){const T=u[_];tn(T,`No panel data found for index ${_}`);const A=r[_],{collapsedSize:R=0,collapsible:k,minSize:C=0}=T.constraints;if(A!=null&&k){const O=jp({delta:Qa(A,R)?C-R:R-A,initialLayout:r,panelConstraints:u.map(M=>M.constraints),pivotIndices:kW(n,y,o),prevLayout:r,trigger:"keyboard"});r!==O&&i(O)}}break}}};return g.addEventListener("keydown",w),()=>{g.removeEventListener("keydown",w)}});return()=>{h.forEach(g=>g())}},[o,e,t,n,r,a,i])}function CF(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 IW(e,t){const n=e==="horizontal",{x:r,y:a}=Bw(t);return n?r:a}function L_e(e,t,n,r,a){const o=n==="horizontal",i=Gw(t,a);tn(i,`No resize handle element found for id "${t}"`);const l=i.getAttribute(br.groupId);tn(l,"Resize handle element has no group id attribute");let{initialCursorPosition:u}=r;const f=IW(n,e),m=AW(l,a);tn(m,`No group element found for id "${l}"`);const h=m.getBoundingClientRect(),g=o?h.width:h.height;return(f-u)/g*100}function M_e(e,t,n,r,a,o){if(vW(e)){const i=n==="horizontal";let l=0;e.shiftKey?l=100:a!=null?l=a:l=10;let u=0;switch(e.key){case"ArrowDown":u=i?0:l;break;case"ArrowLeft":u=i?-l:0;break;case"ArrowRight":u=i?l:0;break;case"ArrowUp":u=i?0:-l;break;case"End":u=100;break;case"Home":u=-100;break}return u}else return r==null?0:L_e(e,t,n,r,o)}function j_e({panelDataArray:e}){const t=Array(e.length),n=e.map(o=>o.constraints);let r=0,a=100;for(let o=0;o<e.length;o++){const i=n[o];tn(i,`Panel constraints not found for index ${o}`);const{defaultSize:l}=i;l!=null&&(r++,t[o]=l,a-=l)}for(let o=0;o<e.length;o++){const i=n[o];tn(i,`Panel constraints not found for index ${o}`);const{defaultSize:l}=i;if(l!=null)continue;const u=e.length-r,f=a/u;r++,t[o]=f,a-=f}return t}function vu(e,t,n){t.forEach((r,a)=>{const o=e[a];tn(o,`Panel data not found for index ${a}`);const{callbacks:i,constraints:l,id:u}=o,{collapsedSize:f=0,collapsible:m}=l,h=n[u];if(h==null||r!==h){n[u]=r;const{onCollapse:g,onExpand:y,onResize:E}=i;E&&E(r,h),m&&(g||y)&&(y&&(h==null||Gs(h,f))&&!Gs(r,f)&&y(),g&&(h==null||!Gs(h,f))&&Gs(r,f)&&g())}})}function Yb(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 P_e({defaultSize:e,dragState:t,layout:n,panelData:r,panelIndex:a,precision:o=3}){const i=n[a];let l;return i==null?l=e!=null?e.toFixed(o):"1":r.length===1?l="1":l=i.toFixed(o),{flexBasis:0,flexGrow:l,flexShrink:1,overflow:"hidden",pointerEvents:t!==null?"none":void 0}}function $_e(e,t=10){let n=null;return(...a)=>{n!==null&&clearTimeout(n),n=setTimeout(()=>{e(...a)},t)}}function RF(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 OW(e){return`react-resizable-panels:${e}`}function DW(e){return e.map(t=>{const{constraints:n,id:r,idIsFromProps:a,order:o}=t;return a?r:o?`${o}:${JSON.stringify(n)}`:JSON.stringify(n)}).sort((t,n)=>t.localeCompare(n)).join(",")}function LW(e,t){try{const n=OW(e),r=t.getItem(n);if(r){const a=JSON.parse(r);if(typeof a=="object"&&a!=null)return a}}catch{}return null}function U_e(e,t,n){var r,a;const o=(r=LW(e,n))!==null&&r!==void 0?r:{},i=DW(t);return(a=o[i])!==null&&a!==void 0?a:null}function z_e(e,t,n,r,a){var o;const i=OW(e),l=DW(t),u=(o=LW(e,a))!==null&&o!==void 0?o:{};u[l]={expandToSizes:Object.fromEntries(n.entries()),layout:r};try{a.setItem(i,JSON.stringify(u))}catch(f){console.error(f)}}function kF({layout:e,panelConstraints:t}){const n=[...e],r=n.reduce((o,i)=>o+i,0);if(n.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${n.map(o=>`${o}%`).join(", ")}`);if(!Qa(r,100)&&n.length>0)for(let o=0;o<t.length;o++){const i=n[o];tn(i!=null,`No layout data found for index ${o}`);const l=100/r*i;n[o]=l}let a=0;for(let o=0;o<t.length;o++){const i=n[o];tn(i!=null,`No layout data found for index ${o}`);const l=Ku({panelConstraints:t,panelIndex:o,size:i});i!=l&&(a+=i-l,n[o]=l)}if(!Qa(a,0))for(let o=0;o<t.length;o++){const i=n[o];tn(i!=null,`No layout data found for index ${o}`);const l=i+a,u=Ku({panelConstraints:t,panelIndex:o,size:l});if(i!==u&&(a-=u-i,n[o]=u,Qa(a,0)))break}return n}const F_e=100,Pp={getItem:e=>(RF(Pp),Pp.getItem(e)),setItem:(e,t)=>{RF(Pp),Pp.setItem(e,t)}},AF={};function MW({autoSaveId:e=null,children:t,className:n="",direction:r,forwardedRef:a,id:o=null,onLayout:i=null,keyboardResizeBy:l=null,storage:u=Pp,style:f,tagName:m="div",...h}){const g=KO(o),y=b.useRef(null),[E,x]=b.useState(null),[w,S]=b.useState([]),_=R_e(),T=b.useRef({}),A=b.useRef(new Map),R=b.useRef(0),k=b.useRef({autoSaveId:e,direction:r,dragState:E,id:g,keyboardResizeBy:l,onLayout:i,storage:u}),C=b.useRef({layout:w,panelDataArray:[],panelDataArrayChanged:!1});b.useRef({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),b.useImperativeHandle(a,()=>({getId:()=>k.current.id,getLayout:()=>{const{layout:z}=C.current;return z},setLayout:z=>{const{onLayout:D}=k.current,{layout:P,panelDataArray:W}=C.current,K=kF({layout:z,panelConstraints:W.map(ae=>ae.constraints)});CF(P,K)||(S(K),C.current.layout=K,D&&D(K),vu(W,K,T.current))}}),[]),ic(()=>{k.current.autoSaveId=e,k.current.direction=r,k.current.dragState=E,k.current.id=g,k.current.onLayout=i,k.current.storage=u}),D_e({committedValuesRef:k,eagerValuesRef:C,groupId:g,layout:w,panelDataArray:C.current.panelDataArray,setLayout:S,panelGroupElement:y.current}),b.useEffect(()=>{const{panelDataArray:z}=C.current;if(e){if(w.length===0||w.length!==z.length)return;let D=AF[e];D==null&&(D=$_e(z_e,F_e),AF[e]=D);const P=[...z],W=new Map(A.current);D(e,P,W,w,u)}},[e,w,u]),b.useEffect(()=>{});const O=b.useCallback(z=>{const{onLayout:D}=k.current,{layout:P,panelDataArray:W}=C.current;if(z.constraints.collapsible){const K=W.map(Q=>Q.constraints),{collapsedSize:ae=0,panelSize:oe,pivotIndices:le}=Wl(W,z,P);if(tn(oe!=null,`Panel size not found for panel "${z.id}"`),!Gs(oe,ae)){A.current.set(z.id,oe);const J=ku(W,z)===W.length-1?oe-ae:ae-oe,q=jp({delta:J,initialLayout:P,panelConstraints:K,pivotIndices:le,prevLayout:P,trigger:"imperative-api"});Yb(P,q)||(S(q),C.current.layout=q,D&&D(q),vu(W,q,T.current))}}},[]),M=b.useCallback((z,D)=>{const{onLayout:P}=k.current,{layout:W,panelDataArray:K}=C.current;if(z.constraints.collapsible){const ae=K.map(ie=>ie.constraints),{collapsedSize:oe=0,panelSize:le=0,minSize:Q=0,pivotIndices:J}=Wl(K,z,W),q=D??Q;if(Gs(le,oe)){const ie=A.current.get(z.id),he=ie!=null&&ie>=q?ie:q,Ye=ku(K,z)===K.length-1?le-he:he-le,Pe=jp({delta:Ye,initialLayout:W,panelConstraints:ae,pivotIndices:J,prevLayout:W,trigger:"imperative-api"});Yb(W,Pe)||(S(Pe),C.current.layout=Pe,P&&P(Pe),vu(K,Pe,T.current))}}},[]),L=b.useCallback(z=>{const{layout:D,panelDataArray:P}=C.current,{panelSize:W}=Wl(P,z,D);return tn(W!=null,`Panel size not found for panel "${z.id}"`),W},[]),$=b.useCallback((z,D)=>{const{panelDataArray:P}=C.current,W=ku(P,z);return P_e({defaultSize:D,dragState:E,layout:w,panelData:P,panelIndex:W})},[E,w]),H=b.useCallback(z=>{const{layout:D,panelDataArray:P}=C.current,{collapsedSize:W=0,collapsible:K,panelSize:ae}=Wl(P,z,D);return tn(ae!=null,`Panel size not found for panel "${z.id}"`),K===!0&&Gs(ae,W)},[]),V=b.useCallback(z=>{const{layout:D,panelDataArray:P}=C.current,{collapsedSize:W=0,collapsible:K,panelSize:ae}=Wl(P,z,D);return tn(ae!=null,`Panel size not found for panel "${z.id}"`),!K||vc(ae,W)>0},[]),Z=b.useCallback(z=>{const{panelDataArray:D}=C.current;D.push(z),D.sort((P,W)=>{const K=P.order,ae=W.order;return K==null&&ae==null?0:K==null?-1:ae==null?1:K-ae}),C.current.panelDataArrayChanged=!0,_()},[_]);ic(()=>{if(C.current.panelDataArrayChanged){C.current.panelDataArrayChanged=!1;const{autoSaveId:z,onLayout:D,storage:P}=k.current,{layout:W,panelDataArray:K}=C.current;let ae=null;if(z){const le=U_e(z,K,P);le&&(A.current=new Map(Object.entries(le.expandToSizes)),ae=le.layout)}ae==null&&(ae=j_e({panelDataArray:K}));const oe=kF({layout:ae,panelConstraints:K.map(le=>le.constraints)});CF(W,oe)||(S(oe),C.current.layout=oe,D&&D(oe),vu(K,oe,T.current))}}),ic(()=>{const z=C.current;return()=>{z.layout=[]}},[]);const ne=b.useCallback(z=>{let D=!1;const P=y.current;return P&&window.getComputedStyle(P,null).getPropertyValue("direction")==="rtl"&&(D=!0),function(K){K.preventDefault();const ae=y.current;if(!ae)return()=>null;const{direction:oe,dragState:le,id:Q,keyboardResizeBy:J,onLayout:q}=k.current,{layout:ie,panelDataArray:he}=C.current,{initialLayout:Ne}=le??{},Ye=kW(Q,z,ae);let Pe=M_e(K,z,oe,le,J,ae);const Ue=oe==="horizontal";Ue&&D&&(Pe=-Pe);const st=he.map(rt=>rt.constraints),Ve=jp({delta:Pe,initialLayout:Ne??ie,panelConstraints:st,pivotIndices:Ye,prevLayout:ie,trigger:vW(K)?"keyboard":"mouse-or-touch"}),ut=!Yb(ie,Ve);(wW(K)||xW(K))&&R.current!=Pe&&(R.current=Pe,!ut&&Pe!==0?Ue?TS(z,Pe<0?SW:_W):TS(z,Pe<0?TW:NW):TS(z,0)),ut&&(S(Ve),C.current.layout=Ve,q&&q(Ve),vu(he,Ve,T.current))}},[]),G=b.useCallback((z,D)=>{const{onLayout:P}=k.current,{layout:W,panelDataArray:K}=C.current,ae=K.map(ie=>ie.constraints),{panelSize:oe,pivotIndices:le}=Wl(K,z,W);tn(oe!=null,`Panel size not found for panel "${z.id}"`);const J=ku(K,z)===K.length-1?oe-D:D-oe,q=jp({delta:J,initialLayout:W,panelConstraints:ae,pivotIndices:le,prevLayout:W,trigger:"imperative-api"});Yb(W,q)||(S(q),C.current.layout=q,P&&P(q),vu(K,q,T.current))},[]),Y=b.useCallback((z,D)=>{const{layout:P,panelDataArray:W}=C.current,{collapsedSize:K=0,collapsible:ae}=D,{collapsedSize:oe=0,collapsible:le,maxSize:Q=100,minSize:J=0}=z.constraints,{panelSize:q}=Wl(W,z,P);q!=null&&(ae&&le&&Gs(q,K)?Gs(K,oe)||G(z,oe):q<J?G(z,J):q>Q&&G(z,Q))},[G]),F=b.useCallback((z,D)=>{const{direction:P}=k.current,{layout:W}=C.current;if(!y.current)return;const K=Gw(z,y.current);tn(K,`Drag handle element not found for id "${z}"`);const ae=IW(P,D);x({dragHandleId:z,dragHandleRect:K.getBoundingClientRect(),initialCursorPosition:ae,initialLayout:W})},[]),re=b.useCallback(()=>{x(null)},[]),ee=b.useCallback(z=>{const{panelDataArray:D}=C.current,P=ku(D,z);P>=0&&(D.splice(P,1),delete T.current[z.id],C.current.panelDataArrayChanged=!0,_())},[_]),j=b.useMemo(()=>({collapsePanel:O,direction:r,dragState:E,expandPanel:M,getPanelSize:L,getPanelStyle:$,groupId:g,isPanelCollapsed:H,isPanelExpanded:V,reevaluatePanelConstraints:Y,registerPanel:Z,registerResizeHandle:ne,resizePanel:G,startDragging:F,stopDragging:re,unregisterPanel:ee,panelGroupElement:y.current}),[O,E,r,M,L,$,g,H,V,Y,Z,ne,G,F,re,ee]),B={display:"flex",flexDirection:r==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return b.createElement(Fw.Provider,{value:j},b.createElement(m,{...h,children:t,className:n,id:o,ref:y,style:{...B,...f},[br.group]:"",[br.groupDirection]:r,[br.groupId]:g}))}const jW=b.forwardRef((e,t)=>b.createElement(MW,{...e,forwardedRef:t}));MW.displayName="PanelGroup";jW.displayName="forwardRef(PanelGroup)";function ku(e,t){return e.findIndex(n=>n===t||n.id===t.id)}function Wl(e,t,n){const r=ku(e,t),o=r===e.length-1?[r-1,r]:[r,r+1],i=n[r];return{...t.constraints,panelSize:i,pivotIndices:o}}function B_e({disabled:e,handleId:t,resizeHandler:n,panelGroupElement:r}){b.useEffect(()=>{if(e||n==null||r==null)return;const a=Gw(t,r);if(a==null)return;const o=i=>{if(!i.defaultPrevented)switch(i.key){case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"End":case"Home":{i.preventDefault(),n(i);break}case"F6":{i.preventDefault();const l=a.getAttribute(br.groupId);tn(l,`No group element found for id "${l}"`);const u=zm(l,r),f=RW(l,t,r);tn(f!==null,`No resize element found for id "${t}"`);const m=i.shiftKey?f>0?f-1:u.length-1:f+1<u.length?f+1:0;u[m].focus();break}}};return a.addEventListener("keydown",o),()=>{a.removeEventListener("keydown",o)}},[r,e,t,n])}function PW({children:e=null,className:t="",disabled:n=!1,hitAreaMargins:r,id:a,onBlur:o,onClick:i,onDragging:l,onFocus:u,onPointerDown:f,onPointerUp:m,style:h={},tabIndex:g=0,tagName:y="div",...E}){var x,w;const S=b.useRef(null),_=b.useRef({onClick:i,onDragging:l,onPointerDown:f,onPointerUp:m});b.useEffect(()=>{_.current.onClick=i,_.current.onDragging=l,_.current.onPointerDown=f,_.current.onPointerUp=m});const T=b.useContext(Fw);if(T===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:A,groupId:R,registerResizeHandle:k,startDragging:C,stopDragging:O,panelGroupElement:M}=T,L=KO(a),[$,H]=b.useState("inactive"),[V,Z]=b.useState(!1),[ne,G]=b.useState(null),Y=b.useRef({state:$});ic(()=>{Y.current.state=$}),b.useEffect(()=>{if(n)G(null);else{const j=k(L);G(()=>j)}},[n,L,k]);const F=(x=r?.coarse)!==null&&x!==void 0?x:15,re=(w=r?.fine)!==null&&w!==void 0?w:5;b.useEffect(()=>{if(n||ne==null)return;const j=S.current;tn(j,"Element ref not attached");let B=!1;return N_e(L,j,A,{coarse:F,fine:re},(D,P,W)=>{if(!P){H("inactive");return}switch(D){case"down":{H("drag"),B=!1,tn(W,'Expected event to be defined for "down" action'),C(L,W);const{onDragging:K,onPointerDown:ae}=_.current;K?.(!0),ae?.();break}case"move":{const{state:K}=Y.current;B=!0,K!=="drag"&&H("hover"),tn(W,'Expected event to be defined for "move" action'),ne(W);break}case"up":{H("hover"),O();const{onClick:K,onDragging:ae,onPointerUp:oe}=_.current;ae?.(!1),oe?.(),B||K?.();break}}})},[F,A,n,re,k,L,ne,C,O]),B_e({disabled:n,handleId:L,resizeHandler:ne,panelGroupElement:M});const ee={touchAction:"none",userSelect:"none"};return b.createElement(y,{...E,children:e,className:t,id:a,onBlur:()=>{Z(!1),o?.()},onFocus:()=>{Z(!0),u?.()},ref:S,role:"separator",style:{...ee,...h},tabIndex:g,[br.groupDirection]:A,[br.groupId]:R,[br.resizeHandle]:"",[br.resizeHandleActive]:$==="drag"?"pointer":V?"keyboard":void 0,[br.resizeHandleEnabled]:!n,[br.resizeHandleId]:L,[br.resizeHandleState]:$})}PW.displayName="PanelResizeHandle";function Ta({className:e,...t}){return d.jsx(jW,{"data-slot":"resizable-panel-group",className:Fe("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...t})}function Yn({...e}){return d.jsx(yW,{"data-slot":"resizable-panel",...e})}function Ho({withHandle:e,className:t,...n}){return d.jsx(PW,{"data-slot":"resizable-handle",className:Fe("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&&d.jsx("div",{className:"bg-border z-10 flex h-4 w-3 items-center justify-center rounded-xs border",children:d.jsx(Fue,{className:"size-2.5"})})})}function Sh({className:e,...t}){return d.jsx("kbd",{"data-slot":"kbd",className:Fe("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 H_e({isSearchExpanded:e,searchQuery:t,filteredNotificationsCount:n,notificationsCount:r,onSearchExpand:a,onSearchChange:o,onSearchBlur:i,onClearAll:l,searchInputRef:u}){return d.jsxs("div",{className:"flex flex-row items-center justify-between p-4 sm:p-4 py-3 gap-2",children:[d.jsx("div",{className:"flex items-center gap-2 flex-1",children:e?d.jsx(Hn,{ref:u,placeholder:"Search notifications...",value:t,onChange:f=>o(f.target.value),onBlur:i,className:"h-8 border-gray-300 dark:border-zinc-600"}):d.jsxs(d.Fragment,{children:[d.jsx("h2",{className:"text-lg font-medium text-gray-900 dark:text-gray-100",children:"Notifications"}),d.jsx(Dr,{className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",variant:"outline",children:n}),d.jsxs(Wt,{children:[d.jsx(Kt,{asChild:!0,children:d.jsx(Le,{variant:"ghost",size:"sm",onClick:a,className:"h-8 w-8 p-0",children:d.jsx(lf,{className:"h-4 w-4"})})}),d.jsxs(Yt,{side:"bottom",className:"flex gap-2",children:["Search",d.jsx(Sh,{children:"F"})]})]})]})}),d.jsx("div",{className:"flex items-center gap-2",children:d.jsxs(Wt,{children:[d.jsx(Kt,{asChild:!0,children:d.jsx(Le,{variant:"ghost",size:"sm",onClick:l,disabled:r===0,className:"h-8 w-8 p-0",children:d.jsx(ti,{className:"h-4 w-4"})})}),d.jsx(Yt,{side:"bottom",children:"Clear all"})]})})]})}function El({id:e,isSelected:t,isFocused:n,icon:r,title:a,description:o,metadata:i,onClick:l,className:u}){return d.jsx("button",{id:e,type:"button",onClick:l,className:Fe("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:d.jsxs("div",{className:"flex items-start gap-2 sm:gap-3",children:[r&&d.jsx("div",{className:"flex-shrink-0 mt-1",children:d.jsx("div",{className:Fe("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:r})}),d.jsxs("div",{className:"flex-1 min-w-0",children:[d.jsx("div",{className:"flex items-center gap-2 mb-1",children:d.jsx("h3",{className:Fe("font-medium truncate font-mono text-sm"),children:a})}),o&&d.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 line-clamp-2",children:o})]})]})})}function V_e({notifications:e,selectedNotification:t,onNotificationSelect:n,focusedIndex:r,formatRelativeTime:a,listRef:o}){return e.length===0?d.jsx("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:d.jsx(sf,{vertical:!0,noBorder:!0,message:"No notifications yet"})}):d.jsx("div",{ref:o,className:"overflow-y-auto flex-1 overscroll-contain",children:e.map((i,l)=>d.jsx(El,{id:`notification-${i.id}`,isSelected:t?.id===i.id,isFocused:r===l,title:d.jsxs("span",{className:"flex items-center gap-3",children:[i.method,!i.read&&d.jsx("span",{className:"size-1.5 block rounded-full bg-orange-500"})]}),description:(()=>{const u=a(i.timestamp),f=i.params&&Object.keys(i.params).length>0?Object.keys(i.params).length:0,m=f>0?` | ${f} param${f>1?"s":""}`:"";return u+m})(),onClick:()=>n(i)},i.id))})}function G_e({notification:e,previewMode:t,onTogglePreview:n,onCopy:r,onDownload:a,onFullscreen:o,isCopied:i=!1,onClose:l}){return e?d.jsxs("div",{className:"flex flex-col h-full",children:[d.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:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsxs("div",{className:"flex items-center gap-1",children:[d.jsx(fm,{className:"h-3 w-3 text-gray-400"}),d.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:new Date(e.timestamp).toLocaleTimeString()})]}),d.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:e.formatRelativeTime(e.timestamp)})]}),d.jsxs("div",{className:"flex items-center gap-1",children:[d.jsxs(Le,{variant:"ghost",size:"sm",onClick:n,className:t?"":"text-purple-600 dark:text-purple-400",children:[t?d.jsx(qN,{className:"h-4 w-4 mr-1"}):d.jsx(FH,{className:"h-4 w-4 mr-1"}),t?"JSON":"Formatted"]}),d.jsx(Le,{variant:"ghost",size:"sm",onClick:r,children:i?d.jsx(Or,{className:"h-4 w-4"}):d.jsx(wr,{className:"h-4 w-4"})}),d.jsx(Le,{variant:"ghost",size:"sm",onClick:a,children:d.jsx(rh,{className:"h-4 w-4"})}),d.jsx(Le,{variant:"ghost",size:"sm",onClick:o,children:d.jsx(mm,{className:"h-4 w-4"})}),l&&d.jsx(Le,{variant:"ghost",size:"sm",onClick:l,children:d.jsx(ys,{className:"h-4 w-4"})})]})]}),d.jsx("div",{className:"flex-1 overflow-y-auto",children:d.jsx("div",{className:"px-4 pt-4",children:d.jsx(yr,{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`})})})]}):d.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[d.jsx(ZN,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),d.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"Select a notification to view details"})]})}function _v(e){const n=Date.now()-e,r=Math.floor(n/1e3),a=Math.floor(r/60),o=Math.floor(a/60),i=Math.floor(o/24);return r<60?"just now":a<60?`${a}m ago`:o<24?`${o}h ago`:i<7?`${i}d ago`:new Date(e).toLocaleDateString()}function W_e({notifications:e,unreadCount:t,markNotificationRead:n,markAllNotificationsRead:r,clearNotifications:a,serverId:o,isConnected:i}){const[l,u]=b.useState(null),[f,m]=b.useState(""),[h,g]=b.useState(-1),[y,E]=b.useState(!0),[x,w]=b.useState(!1),[S,_]=b.useState(!0),[T,A]=b.useState(!1),R=b.useRef(null),k=b.useRef(null),C=b.useRef(null),O=b.useRef(!1);b.useEffect(()=>{y&&e.length>0&&R.current&&!O.current&&(R.current.scrollTop=0)},[e.length,y]),b.useEffect(()=>{const Y=R.current;if(!Y)return;const F=()=>{Y.scrollTop>0&&(O.current=!0,E(!1))};return Y.addEventListener("scroll",F),()=>Y.removeEventListener("scroll",F)},[]),b.useEffect(()=>{e.length===0&&(O.current=!1,E(!0))},[e.length]),b.useEffect(()=>{l&&!l.read&&n(l.id)},[l,n]),b.useEffect(()=>{x&&C.current&&C.current.focus()},[x]);const M=b.useCallback(()=>{f.trim()||w(!1)},[f]),L=b.useMemo(()=>{if(!f.trim())return e;const Y=f.toLowerCase();return e.filter(F=>F.method.toLowerCase().includes(Y)||JSON.stringify(F.params||{}).toLowerCase().includes(Y))},[e,f]);b.useEffect(()=>{g(-1)},[f]),b.useEffect(()=>{const Y=F=>{const re=F.target;if(re.tagName==="INPUT"||re.tagName==="TEXTAREA"||re.contentEditable==="true"||F.metaKey||F.ctrlKey||F.altKey)return;const j=L;if(F.key==="ArrowDown")F.preventDefault(),g(B=>{const z=B+1;return z>=j.length?0:z});else if(F.key==="ArrowUp")F.preventDefault(),g(B=>{const z=B-1;return z<0?j.length-1:z});else if(F.key==="Enter"&&h>=0){F.preventDefault();const B=L[h];B&&$(B)}};return document.addEventListener("keydown",Y),()=>document.removeEventListener("keydown",Y)},[h,L]),b.useEffect(()=>{if(h>=0){const Y=`notification-${L[h]?.id}`,F=document.getElementById(Y);F&&F.scrollIntoView({behavior:"smooth",block:"nearest"})}},[h,L]);const $=b.useCallback(Y=>{u(Y)},[]),H=b.useCallback(()=>{window.confirm("Are you sure you want to clear all notifications? This cannot be undone.")&&(a(),u(null))},[a]),V=b.useCallback(async()=>{if(l)try{await navigator.clipboard.writeText(JSON.stringify({method:l.method,timestamp:l.timestamp,read:l.read,params:l.params},null,2)),A(!0),setTimeout(()=>A(!1),2e3)}catch(Y){console.error("[NotificationsTab] Failed to copy notification:",Y)}},[l]),Z=b.useCallback(()=>{if(l)try{const Y=new globalThis.Blob([JSON.stringify({method:l.method,timestamp:l.timestamp,read:l.read,params:l.params},null,2)],{type:"application/json"}),F=URL.createObjectURL(Y),re=document.createElement("a");re.href=F,re.download=`notification-${Date.now()}.json`,document.body.appendChild(re),re.click(),document.body.removeChild(re),URL.revokeObjectURL(F)}catch(Y){console.error("[NotificationsTab] Failed to download notification:",Y)}},[l]),ne=b.useCallback(async()=>{if(k.current)try{document.fullscreenElement?await document.exitFullscreen():await k.current.requestFullscreen()}catch(Y){console.error("[NotificationsTab] Failed to toggle fullscreen:",Y)}},[]),G=l?{method:l.method,params:l.params,timestamp:l.timestamp,read:l.read,formatRelativeTime:_v}:null;return i?d.jsxs(Ta,{direction:"horizontal",className:"h-full",children:[d.jsx(Yn,{defaultSize:40,minSize:30,children:d.jsx(Ta,{direction:"vertical",className:"h-full border-r dark:border-zinc-700",children:d.jsxs(Yn,{defaultSize:75,minSize:30,children:[d.jsx(H_e,{isSearchExpanded:x,searchQuery:f,filteredNotificationsCount:L.length,notificationsCount:e.length,onSearchExpand:()=>w(!0),onSearchChange:m,onSearchBlur:M,onClearAll:H,searchInputRef:C}),d.jsx("div",{className:"flex flex-col h-full",children:d.jsx(V_e,{notifications:L,selectedNotification:l,onNotificationSelect:$,focusedIndex:h,formatRelativeTime:_v,listRef:R})})]})})}),d.jsx(Ho,{}),d.jsx(Yn,{defaultSize:60,minSize:40,children:d.jsx("div",{ref:k,className:"h-full bg-white dark:bg-zinc-900",children:d.jsx(G_e,{notification:G,previewMode:S,onTogglePreview:()=>_(!S),onCopy:V,onDownload:Z,onFullscreen:ne,onClose:()=>u(null),isCopied:T})})})]}):d.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[d.jsx(ZN,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),d.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"Not connected to server"})]})}function ZO({serverIds:e,onCountChange:t,onClearRef:n}={}){const[r,a]=b.useState([]),o=b.useRef(null),[i,l]=b.useState(new Set),[u]=b.useState(""),f=y=>{l(E=>{const x=new Set(E);return x.has(y)?x.delete(y):x.add(y),x})},m=async()=>{a([]),l(new Set),t?.(0),e&&e.length>0?e.forEach(y=>Fy(y)):Fy()},h=b.useMemo(()=>!e||e.length===0?"":[...e].sort().join(","),[e]);b.useEffect(()=>(n&&(n.current=m),()=>{n&&(n.current=null)}),[n,m]),b.useEffect(()=>{t?.(r.length)},[r.length,t]),b.useEffect(()=>{console.log("[RPC Logger] Subscribing to RPC logs for servers:",e);const y=TN(),x=(e&&e.length>0?y.filter(S=>e.includes(S.serverId)):y).map(S=>{const _=S.message,T=typeof _?.method=="string"?_.method:_?.result!==void 0?"result":_?.error!==void 0?"error":"unknown";return{id:`${S.timestamp}-${Math.random().toString(36).slice(2)}`,serverId:S.serverId,direction:S.direction.toUpperCase(),method:T,timestamp:S.timestamp,payload:S.message}}).reverse();a(x),t?.(x.length);const w=NN(S=>{if(e&&e.length>0&&!e.includes(S.serverId))return;const _=S.message,T=typeof _?.method=="string"?_.method:_?.result!==void 0?"result":_?.error!==void 0?"error":"unknown",A={id:`${S.timestamp}-${Math.random().toString(36).slice(2)}`,serverId:S.serverId,direction:S.direction.toUpperCase(),method:T,timestamp:S.timestamp,payload:S.message};console.log("[RPC Logger] New RPC log:",{method:T,direction:S.direction,serverId:S.serverId}),a(R=>{const k=[A,...R].slice(0,1e3);return t?.(k.length),k})});return()=>{w(),console.log("[RPC Logger] Unsubscribed from RPC logs")}},[h,t]);const g=b.useMemo(()=>{let y=r;if(e&&e.length>0){const E=new Set(e);y=y.filter(x=>E.has(x.serverId))}if(u.trim()){const E=u.toLowerCase();y=y.filter(x=>x.serverId.toLowerCase().includes(E)||x.method.toLowerCase().includes(E)||x.direction.toLowerCase().includes(E)||JSON.stringify(x.payload).toLowerCase().includes(E))}return y=[...y].sort((E,x)=>new Date(x.timestamp).getTime()-new Date(E.timestamp).getTime()),y},[r,u,e]);return d.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:d.jsx("div",{ref:o,className:"flex-1 min-h-0 overflow-y-auto",children:g.length===0?d.jsxs("div",{className:"text-center py-8",children:[d.jsx("div",{className:"text-xs text-muted-foreground",children:"No messages yet"}),d.jsx("div",{className:"text-[10px] text-muted-foreground mt-1",children:"JSON-RPC messages will appear here"})]}):g.map(y=>{const E=i.has(y.id);return d.jsxs("div",{className:"group hover:bg-muted/50 transition-all duration-200 overflow-hidden",children:[d.jsxs("div",{className:"px-3 py-2 flex items-center gap-2 cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>f(y.id),children:[d.jsx("div",{className:"flex-shrink-0",children:E?d.jsx(hs,{className:"h-3 w-3 text-muted-foreground transition-transform"}):d.jsx(BH,{className:"h-3 w-3 text-muted-foreground transition-transform"})}),d.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[d.jsx("span",{className:"text-muted-foreground font-mono text-xs",children:new Date(y.timestamp).toLocaleTimeString()}),d.jsx("span",{className:`flex items-center justify-center px-1 py-0.5 rounded ${y.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:y.direction==="RECEIVE"?"Incoming":"Outgoing",children:y.direction==="RECEIVE"?d.jsx(Xce,{className:"h-3 w-3"}):d.jsx(Qce,{className:"h-3 w-3"})}),d.jsx("span",{className:"text-xs font-mono text-foreground truncate",children:y.method})]})]}),E&&d.jsx("div",{className:"border-t bg-muted/20",children:d.jsx("div",{className:"p-3",children:d.jsx("div",{className:"max-h-[40vh] overflow-auto rounded-sm bg-background/60 p-2",children:d.jsx(yr,{data:y.payload})})})})]},y.id)})})})}function $W({activeTab:e,isSearchExpanded:t,searchQuery:n,primaryTabTitle:r,secondaryTabTitle:a,primaryCount:o,secondaryCount:i,secondaryIcon:l,primaryIcon:u,searchPlaceholder:f="Search...",onSearchExpand:m,onSearchChange:h,onSearchBlur:g,onTabSwitch:y,searchInputRef:E,primaryTabName:x}){const w=e===x;return d.jsxs("div",{className:"flex flex-row items-center justify-between p-4 sm:p-4 py-3 gap-2",children:[d.jsx("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:t?d.jsx(Hn,{ref:E,placeholder:f,value:n,onChange:S=>h(S.target.value),onBlur:g,className:"h-8 border-gray-300 dark:border-zinc-600"}):d.jsxs(d.Fragment,{children:[d.jsx("h2",{className:"text-lg font-medium text-gray-900 dark:text-gray-100",children:w?r:a}),w&&d.jsxs(d.Fragment,{children:[d.jsx(Dr,{className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",variant:"outline",children:o}),d.jsxs(Wt,{children:[d.jsx(Kt,{asChild:!0,children:d.jsx(Le,{variant:"ghost",size:"sm",onClick:m,className:"h-8 w-8 p-0",children:d.jsx(lf,{className:"h-4 w-4"})})}),d.jsxs(Yt,{side:"bottom",className:"flex gap-2",children:["Search",d.jsx(Sh,{children:"F"})]})]})]})]})}),d.jsxs(Le,{variant:"ghost",size:"sm",onClick:y,className:"gap-2 flex-shrink-0",children:[w?d.jsx(l,{}):d.jsx(u,{}),d.jsx("span",{className:"hidden sm:inline",children:w?a:r}),w&&i>0&&d.jsx(Dr,{className:"bg-purple-500/20 text-purple-600 dark:text-purple-400 border-transparent",variant:"outline",children:i})]})]})}function IF({prompts:e,selectedPrompt:t,onPromptSelect:n,focusedIndex:r}){return e.length===0?d.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[d.jsx(hm,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),d.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"No prompts available"})]}):d.jsx("div",{className:"overflow-y-auto flex-1 border-r dark:border-zinc-700 overscroll-contain",children:e.map((a,o)=>d.jsx(El,{id:`prompt-${a.name}`,isSelected:t?.name===a.name,isFocused:r===o,icon:d.jsx(hm,{className:"h-4 w-4"}),title:a.name,description:a.description,metadata:a.arguments&&a.arguments.length>0&&d.jsxs(Dr,{variant:"outline",className:"text-xs border-gray-300 dark:border-zinc-600 text-gray-600 dark:text-gray-400",children:[a.arguments.length," args"]}),onClick:()=>n(a)},a.name))})}function OF({activeTab:e,isSearchExpanded:t,searchQuery:n,filteredPromptsCount:r,savedPromptsCount:a,onSearchExpand:o,onSearchChange:i,onSearchBlur:l,onTabSwitch:u,searchInputRef:f}){return d.jsx($W,{activeTab:e,isSearchExpanded:t,searchQuery:n,primaryTabName:"prompts",secondaryTabName:"saved",primaryTabTitle:"Prompts",secondaryTabTitle:"History",primaryCount:r,secondaryCount:a,primaryIcon:hm,secondaryIcon:fm,searchPlaceholder:"Search prompts...",onSearchExpand:o,onSearchChange:i,onSearchBlur:l,onTabSwitch:u,searchInputRef:f})}function DF({savedPrompts:e,selectedPrompt:t,onLoadPrompt:n,onDeletePrompt:r,focusedIndex:a}){return e.length===0?d.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[d.jsx(fm,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),d.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"No history"}),d.jsx("p",{className:"text-sm text-gray-400 dark:text-gray-500 mt-1",children:"Prompts you execute will appear here"})]}):d.jsx("div",{className:"overflow-y-auto flex-1 border-r dark:border-zinc-700 overscroll-contain",children:e.map((o,i)=>d.jsx(El,{id:`saved-prompt-${o.id}`,isSelected:t?.id===o.id,isFocused:a===i,icon:d.jsx(fm,{className:"h-4 w-4"}),title:o.name,description:`${o.promptName} - ${new Date(o.savedAt).toLocaleString()}`,onClick:()=>n(o)},o.id))})}function K_e({selectedPrompt:e,promptArgs:t,onArgChange:n}){const r=e?.arguments||[];if(!(r.length>0))return d.jsx("div",{className:"flex items-center justify-center h-32 text-gray-500 dark:text-gray-400 text-sm",children:"No arguments required"});const o=i=>{const l=i.name,u=t[l],f=typeof u=="string"?u:JSON.stringify(u);return i.type==="boolean"?d.jsxs("div",{className:"space-y-2",children:[d.jsxs(wn,{htmlFor:l,className:"text-sm font-medium",children:[l,i.required&&d.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),d.jsxs("div",{className:"flex items-center space-x-2",children:[d.jsx("input",{id:l,type:"checkbox",checked:!!u,onChange:m=>n(l,m.target.checked),className:"rounded","aria-label":`Toggle ${l}`}),d.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:i.description})]})]},l):i.type==="number"?d.jsxs("div",{className:"space-y-2",children:[d.jsxs(wn,{htmlFor:l,className:"text-sm font-medium",children:[l,i.required&&d.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),d.jsx(Hn,{id:l,type:"number",value:Number(u)||0,onChange:m=>n(l,Number(m.target.value)),placeholder:i.description||`Enter ${l}`}),i.description&&d.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:i.description})]},l):i.type==="array"||i.type==="object"?d.jsxs("div",{className:"space-y-2",children:[d.jsxs(wn,{htmlFor:l,className:"text-sm font-medium",children:[l,i.required&&d.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),d.jsx(bc,{id:l,value:f,onChange:m=>{try{const h=JSON.parse(m.target.value);n(l,h)}catch{n(l,m.target.value)}},placeholder:i.description||`Enter ${l} as JSON`,className:"font-mono text-sm min-h-[100px]"}),i.description&&d.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:i.description})]},l):d.jsxs("div",{className:"space-y-2",children:[d.jsxs(wn,{htmlFor:l,className:"text-sm font-medium",children:[l,i.required&&d.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),d.jsx(Hn,{id:l,value:f,onChange:m=>n(l,m.target.value),placeholder:i.description||`Enter ${l}`}),i.description&&d.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:i.description})]},l)};return d.jsx("div",{className:"space-y-4",children:r.map(i=>o(i))})}function LF({selectedPrompt:e,promptArgs:t,isExecuting:n,isConnected:r,onArgChange:a,onExecute:o,onSave:i}){return b.useEffect(()=>{const l=u=>{(u.metaKey||u.ctrlKey)&&u.key==="Enter"&&e&&!n&&r&&(u.preventDefault(),o())};return document.addEventListener("keydown",l),()=>document.removeEventListener("keydown",l)},[e,n,r,o]),e?d.jsxs("div",{className:"flex flex-col h-full",children:[d.jsx("div",{className:"flex-shrink-0 p-3 sm:p-6 pt-3 pb-4 pr-3",children:d.jsxs("div",{children:[d.jsxs("div",{className:"flex flex-row items-center justify-between mb-0 gap-2",children:[d.jsx("h3",{className:"text-base sm:text-lg font-semibold",children:e.name}),d.jsxs("div",{className:"flex gap-2 flex-shrink-0",children:[d.jsx(Le,{onClick:o,disabled:n||!r,size:"sm",className:"lg:size-default pr-1! gap-0",children:n?d.jsxs(d.Fragment,{children:[d.jsx(oi,{className:"mr-2"}),d.jsx("span",{className:"hidden sm:inline",children:"Executing..."})]}):d.jsxs(d.Fragment,{children:[d.jsx(KH,{className:"h-4 w-4 sm:mr-2"}),d.jsx("span",{className:"hidden sm:inline",children:"Execute"}),d.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:"⌘↵"})]})}),d.jsxs(Le,{variant:"outline",onClick:i,disabled:n,size:"sm",className:"lg:size-default gap-2",children:[d.jsx(QN,{className:"h-4 w-4"}),d.jsx("span",{className:"hidden sm:inline",children:"Save"})]})]})]}),e.description&&d.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 leading-relaxed mt-2",children:e.description})]})}),d.jsx("div",{className:"flex-1 overflow-y-auto px-3 sm:px-6 pb-4 pr-3",children:d.jsx(K_e,{selectedPrompt:e,promptArgs:t,onArgChange:a})})]}):d.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[d.jsx("p",{className:"text-gray-500 dark:text-gray-400 mb-2",children:"Select a prompt to get started"}),d.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 Y_e(e){switch(e){case"system":return"default";case"user":return"outline";case"assistant":return"secondary";default:return"outline"}}function Z_e(e){return e.charAt(0).toUpperCase()+e.slice(1)}function q_e(e){return typeof e=="string"?e:e.text?e.text:e.type==="resource"&&e.resource?.text?e.resource.text:e.type==="image"?`[Image: ${e.mimeType||"unknown type"}]`:JSON.stringify(e,null,2)}function X_e({message:e,index:t}){const[n,r]=b.useState(!1),a=async()=>{const i=q_e(e.content);await navigator.clipboard.writeText(i),r(!0),setTimeout(()=>r(!1),2e3)},o=()=>{const i=e.content;return typeof i=="string"?d.jsx(xy,{content:i}):i.type==="text"&&i.text?d.jsx(xy,{content:i.text}):i.type==="image"?d.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[d.jsxs("span",{className:"font-mono bg-muted px-2 py-1 rounded",children:["Image: ",i.mimeType||"unknown type"]}),i.data&&d.jsx("img",{src:`data:${i.mimeType};base64,${i.data}`,alt:"Prompt image",className:"max-w-full max-h-[300px] object-contain rounded-lg border border-border mt-2"})]}):i.type==="resource"&&i.resource?d.jsxs("div",{className:"space-y-2",children:[d.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[d.jsx("span",{className:"text-muted-foreground font-medium",children:"Resource:"}),d.jsx("code",{className:"bg-muted px-2 py-0.5 rounded text-xs font-mono",children:i.resource.uri})]}),i.resource.text&&d.jsx("div",{className:"mt-2",children:d.jsx(xy,{content:i.resource.text})})]}):d.jsx("pre",{className:"bg-muted p-3 rounded-lg text-sm overflow-x-auto",children:d.jsx("code",{children:JSON.stringify(i,null,2)})})};return d.jsxs("div",{className:"border border-border rounded-lg overflow-hidden bg-white dark:bg-zinc-900",children:[d.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-muted/30 border-b border-border",children:[d.jsx(Dr,{variant:Y_e(e.role),children:Z_e(e.role)}),d.jsx(Le,{variant:"ghost",size:"sm",onClick:a,className:"h-6 px-2",title:"Copy message content",children:n?d.jsx(Or,{className:"h-3.5 w-3.5"}):d.jsx(wr,{className:"h-3.5 w-3.5"})})]}),d.jsx("div",{className:"px-4 py-3",children:o()})]})}function J_e(e){const n=Date.now()-e,r=Math.floor(n/1e3),a=Math.floor(r/60),o=Math.floor(a/60),i=Math.floor(o/24);return r<10?"now":r<60?`${r}s ago`:a<60?`${a}m ago`:o<24?`${o}h ago`:`${i}d ago`}function Q_e(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 MF({results:e,copiedResult:t,previewMode:n=!0,onCopy:r,onDelete:a,onFullscreen:o,onTogglePreview:i,onMaximize:l,isMaximized:u=!1}){const[f,m]=b.useState(0),[h,g]=b.useState(""),[y,E]=b.useState(!0),x=e[0],w=x?e.filter(R=>R.promptName===x.promptName):[],S=w[f]||w[0],_=e.findIndex(R=>R===S);if(b.useEffect(()=>{w.length>0&&f>=w.length&&m(0)},[w.length,f]),b.useEffect(()=>{const R=()=>{S&&g(J_e(S.timestamp))};R();const k=setInterval(R,1e3);return()=>clearInterval(k)},[S]),e.length===0)return d.jsx("div",{className:"flex flex-col h-full bg-white dark:bg-black border-t dark:border-zinc-700",children:d.jsx("div",{className:"flex-1 overflow-y-auto h-full",children:d.jsx("div",{className:"flex items-center justify-center h-full",children:d.jsx("div",{className:"text-center",children:d.jsx(sf,{vertical:!0,noBorder:!0,message:"No Results yet"})})})})});const T=S.error||Q_e(S.result),A="messages"in S.result&&Array.isArray(S.result.messages);return d.jsx("div",{className:"flex flex-col h-full bg-white dark:bg-black border-t dark:border-zinc-700",children:d.jsx("div",{className:"flex-1 overflow-y-auto h-full",children:d.jsxs("div",{className:"space-y-0 flex-1 h-full flex flex-col",children:[d.jsxs("div",{className:"flex items-center gap-2 px-4 pt-2 border-b border-gray-200 dark:border-zinc-600 pb-2",children:[d.jsx("h3",{className:"text-sm font-medium hidden sm:block",children:"Response"}),S.duration!==void 0&&d.jsxs("div",{className:"hidden sm:flex items-center gap-1",children:[d.jsx(bm,{className:"h-3 w-3 text-gray-400"}),d.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:[S.duration,"ms"]})]}),A&&d.jsx("div",{className:"flex items-center gap-4 sm:ml-4",children:d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("button",{onClick:()=>E(!0),className:`text-xs font-medium ${y?"text-black dark:text-white":"text-zinc-500 dark:text-zinc-400"}`,children:"Formatted"}),d.jsx("span",{className:"text-xs text-zinc-400",children:"|"}),d.jsx("button",{onClick:()=>E(!1),className:`text-xs font-medium ${y?"text-zinc-500 dark:text-zinc-400":"text-black dark:text-white"}`,children:"Raw"})]})}),d.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[w.length>1&&d.jsxs("div",{className:"flex items-center gap-2 mr-2",children:[d.jsx(pm,{className:"h-3 w-3 text-gray-400"}),d.jsxs(Ys,{value:f.toString(),onValueChange:R=>m(parseInt(R)),children:[d.jsx(qs,{className:"h-7 w-[120px] text-xs",children:d.jsx(Zs,{})}),d.jsx(Xs,{children:w.map((R,k)=>d.jsx(fa,{value:k.toString(),children:k===0?"Latest":`${k+1} call ago`},k))})]})]}),d.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400 mr-2",children:h}),d.jsx(Le,{variant:"ghost",size:"sm",onClick:()=>r(_,S.result),className:"h-7 w-7 p-0",title:"Copy result",children:t===_?d.jsx(Or,{className:"h-4 w-4"}):d.jsx(wr,{className:"h-4 w-4"})}),a&&d.jsx(Le,{variant:"ghost",size:"sm",onClick:()=>a(_),className:"h-7 w-7 p-0",title:"Delete result",children:d.jsx(ti,{className:"h-4 w-4"})}),o&&d.jsx(Le,{variant:"ghost",size:"sm",onClick:()=>o(_),className:"h-7 w-7 p-0 sm:hidden",title:"Fullscreen",children:d.jsx(mm,{className:"h-4 w-4"})}),l&&d.jsx(Le,{variant:"ghost",size:"sm",onClick:l,className:"h-7 w-7 p-0 hidden sm:flex",title:u?"Restore":"Maximize",children:u?d.jsx(WH,{className:"h-4 w-4"}):d.jsx(mm,{className:"h-4 w-4"})})]})]}),d.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:T?d.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded p-3",children:[d.jsx("p",{className:"text-red-800 dark:text-red-300 font-medium",children:"Error:"}),d.jsx("p",{className:"text-red-700 dark:text-red-400 text-sm",children:T})]}):y&&A?d.jsx("div",{className:"space-y-3",children:S.result.messages.map((R,k)=>d.jsx(X_e,{message:R,index:k},k))}):d.jsx(yr,{data:S.result,filename:`prompt-result-${S.promptName}-${Date.now()}.json`})})]})})})}const jF="mcp-inspector-saved-prompts";function UW({ref:e,prompts:t,callPrompt:n,serverId:r,isConnected:a}){const[o,i]=b.useState(null),[l,u]=b.useState(null),{selectedPromptName:f,setSelectedPromptName:m}=kc(),[h,g]=b.useState({}),[y,E]=b.useState([]),[x,w]=b.useState(!1),[S,_]=b.useState(null),[T,A]=b.useState(""),[R,k]=b.useState("prompts"),[C,O]=b.useState([]),[M,L]=b.useState(!1),[$,H]=b.useState(""),[V,Z]=b.useState(!1),[ne,G]=b.useState(-1),Y=b.useRef(null),[F,re]=b.useState(!1),[ee,j]=b.useState("list"),[B,z]=b.useState(0),[D,P]=b.useState(!0),[W,K]=b.useState(!1),ae=b.useRef(null),oe=b.useRef(null),le=b.useRef(null),Q=b.useRef(null);b.useEffect(()=>{const _e=()=>{re(window.innerWidth<1024)};return _e(),window.addEventListener("resize",_e),()=>window.removeEventListener("resize",_e)},[]),b.useEffect(()=>{j(o?"detail":"list")},[o]),b.useEffect(()=>{F&&y.length>0&&!x&&j("response")},[y,x,F]),b.useImperativeHandle(e,()=>({focusSearch:()=>{Z(!0),setTimeout(()=>{Y.current&&Y.current.focus()},0)},blurSearch:()=>{A(""),Z(!1),Y.current&&Y.current.blur()}})),b.useEffect(()=>{try{const _e=localStorage.getItem(jF);if(_e){const Be=JSON.parse(_e);O(Be)}}catch(_e){console.error("[PromptsTab] Failed to load saved prompts:",_e)}},[]);const J=b.useCallback(_e=>{try{localStorage.setItem(jF,JSON.stringify(_e))}catch(Be){console.error("[PromptsTab] Failed to save prompts:",Be)}},[]);b.useEffect(()=>{V&&Y.current&&Y.current.focus()},[V]);const q=b.useCallback(()=>{T.trim()||Z(!1)},[T]),ie=b.useMemo(()=>{if(!T.trim())return t;const _e=T.toLowerCase();return t.filter(Be=>Be.name.toLowerCase().includes(_e)||Be.description?.toLowerCase().includes(_e))},[t,T]),he=b.useCallback(_e=>{i(_e);const Be={};_e.arguments&&_e.arguments.forEach(it=>{Be[it.name]=""}),g(Be)},[]),Ne=b.useCallback(_e=>{const Be=t.find(it=>it.name===_e.promptName);Be&&(i(Be),g(_e.args),u(_e))},[t]);b.useEffect(()=>{G(-1)},[T,R]),b.useEffect(()=>{const _e=Be=>{const it=Be.target;if(it.tagName==="INPUT"||it.tagName==="TEXTAREA"||it.contentEditable==="true"||Be.metaKey||Be.ctrlKey||Be.altKey)return;const lt=R==="prompts"?ie:C;if(Be.key==="ArrowDown")Be.preventDefault(),G(At=>{const Nn=At+1;return Nn>=lt.length?0:Nn});else if(Be.key==="ArrowUp")Be.preventDefault(),G(At=>{const Nn=At-1;return Nn<0?lt.length-1:Nn});else if(Be.key==="Enter"&&ne>=0)if(Be.preventDefault(),R==="prompts"){const At=ie[ne];At&&he(At)}else{const At=C[ne];At&&Ne(At)}};return document.addEventListener("keydown",_e),()=>document.removeEventListener("keydown",_e)},[ne,ie,C,R,he,Ne]),b.useEffect(()=>{if(ne>=0){const _e=R==="prompts"?`prompt-${ie[ne]?.name}`:`saved-prompt-${C[ne]?.id}`,Be=document.getElementById(_e);Be&&Be.scrollIntoView({behavior:"smooth",block:"nearest"})}},[ne,ie,C,R]),b.useEffect(()=>{if(console.warn("[PromptsTab] Auto-selection effect triggered:",{selectedPromptName:f,promptsCount:t.length,currentSelectedPrompt:o?.name}),f&&t.length>0){const _e=t.find(Be=>Be.name===f);if(console.warn("[PromptsTab] Prompt lookup result:",{selectedPromptName:f,promptFound:!!_e,promptName:_e?.name,shouldSelect:_e&&o?.name!==_e.name}),_e&&o?.name!==_e.name){console.warn("[PromptsTab] Selecting prompt:",_e.name),m(null);const Be=setTimeout(()=>{he(_e);const it=document.getElementById(`prompt-${_e.name}`);it&&(console.warn("[PromptsTab] Scrolling to prompt element"),it.scrollIntoView({behavior:"smooth",block:"nearest"}))},100);return()=>clearTimeout(Be)}}},[f,t,o,he,m]),b.useEffect(()=>{if(o){const _e=t.find(Be=>Be.name===o.name);_e&&_e!==o&&(JSON.stringify(_e.arguments)!==JSON.stringify(o.arguments)||_e.description!==o.description)&&i(_e)}},[t,o]);const Ye=b.useCallback((_e,Be)=>{g(it=>({...it,[_e]:Be}))},[]),Pe=b.useCallback(async()=>{if(!o||x)return;w(!0);const _e=Date.now();try{const Be=await n(o.name,h),it=Date.now()-_e;ra.getInstance().capture(new vU({promptName:o.name,serverId:r,success:!0})).catch(()=>{}),E(lt=>[{promptName:o.name,args:h,result:Be,timestamp:_e,duration:it},...lt])}catch(Be){ra.getInstance().capture(new vU({promptName:o.name,serverId:r,success:!1,error:Be instanceof Error?Be.message:"Unknown error"})).catch(()=>{});const qe={promptName:o.name,args:h,result:null,error:Be instanceof Error?Be.message:String(Be),timestamp:_e,duration:Date.now()-_e};E(lt=>[...lt,{...qe,result:{messages:[]}}])}finally{w(!1)}},[o,h,x,n,r]),Ue=b.useCallback(async(_e,Be)=>{try{await navigator.clipboard.writeText(JSON.stringify(Be,null,2)),_(_e),setTimeout(()=>_(null),2e3)}catch(it){console.error("[PromptsTab] Failed to copy result:",it)}},[]),st=b.useCallback(_e=>{E(Be=>Be.filter((it,qe)=>qe!==_e))},[]),Ve=b.useCallback(_e=>{if(F)j("response");else{const Be=y[_e];if(Be){const it=window.open("","_blank","width=800,height=600");if(it){const qe=Be.result;it.document.write(`
1753
+ `);R=O.pop()||"";for(const M of O)if(M.trim()&&M.startsWith("data: "))try{const L=JSON.parse(M.slice(6));if(console.log("[Client received event]",L.type,L.toolName||L.content?.slice?.(0,30)),L.type==="message")console.log("[Message started]",L.id);else if(L.type==="text"){S+=L.content;const $=_[_.length-1];$&&$.type==="text"?$.text=S:_.push({type:"text",text:S}),console.log("[Parts after text]",_.length,"parts, text length:",S.length),o(H=>H.map(V=>V.id===w?{...V,parts:[..._]}:V))}else if(L.type==="tool-call")S&&(S=""),_.push({type:"tool-invocation",toolInvocation:{toolName:L.toolName,args:L.args,state:"pending"}}),console.log("[Parts after tool-call]",_.length,"parts, tool:",L.toolName),o($=>$.map(H=>H.id===w?{...H,parts:[..._]}:H));else if(L.type==="tool-result"){const $=_.find(H=>H.type==="tool-invocation"&&H.toolInvocation?.toolName===L.toolName&&!H.toolInvocation?.result);$&&$.toolInvocation?($.toolInvocation.result=L.result,$.toolInvocation.state="result",console.log("[Parts after tool-result]",_.length,"parts, updated:",L.toolName),o(H=>H.map(V=>V.id===w?{...V,parts:[..._]}:V))):console.warn("[tool-result] Could not find matching tool part for",L.toolName)}else if(L.type==="done")console.log("[Done] Final parts:",_.length),o($=>$.map(H=>H.id===w?{...H,parts:[..._],content:""}:H));else if(L.type==="error")throw new Error(L.message||"Streaming error")}catch(L){console.error("Failed to parse streaming event:",L,M)}}if(u.current?.signal.aborted){for(const k of _)k.type==="tool-invocation"&&k.toolInvocation?.state==="pending"&&(k.toolInvocation.state="error",k.toolInvocation.result="Cancelled by user");o(k=>k.map(C=>C.id===w?{...C,parts:[..._],content:""}:C))}}catch(E){if(E instanceof DOMException&&E.name==="AbortError")return;let x="Unknown error occurred";if(E instanceof Error){x=E.message;const S=E;S.status&&(x=`HTTP ${S.status}: ${x}`),(S.code===401||x.includes("401")||x.includes("Unauthorized"))&&(x="Authentication failed (401). Check your Authorization header in the connection settings.")}const w={id:`error-${Date.now()}`,role:"assistant",content:`Error: ${x}`,timestamp:Date.now()};o(S=>[...S,w])}finally{l(!1),u.current=null}},[t,r,e,a,n]),m=b.useCallback(()=>{o([])},[]),h=b.useCallback(()=>{u.current&&u.current.abort()},[]);return{messages:a,isLoading:i,sendMessage:f,clearMessages:m,stop:h}}function p_e({connection:e,llmConfig:t,isConnected:n,readResource:r}){const[a,o]=b.useState([]),[i,l]=b.useState(!1),u=b.useRef(null),f=b.useRef(null),m=b.useRef(null),h=b.useCallback(async E=>{if(!E.trim()||!t||!n)return;const x={id:`user-${Date.now()}`,role:"user",content:E.trim(),timestamp:Date.now()};o(_=>[..._,x]),l(!0),u.current=new AbortController;const w=Date.now();let S=0;try{const _=`assistant-${Date.now()}`;let T="";const A=[];if(o(R=>[...R,{id:_,role:"assistant",content:"",timestamp:Date.now(),parts:[]}]),!m.current||m.current.provider!==t.provider||m.current.model!==t.model||m.current.apiKey!==t.apiKey){let R;if(t.provider==="openai"){const{ChatOpenAI:k}=await Ua(async()=>{const{ChatOpenAI:C}=await import("./index-DjyLCU4S.js");return{ChatOpenAI:C}},__vite__mapDeps([0,1,2,3,4,5]));R=new k({model:t.model,apiKey:t.apiKey})}else if(t.provider==="anthropic"){const{ChatAnthropic:k}=await Ua(async()=>{const{ChatAnthropic:C}=await import("./index-CdkiRJxS.js");return{ChatAnthropic:C}},__vite__mapDeps([6,2,1,5]));R=new k({model:t.model,apiKey:t.apiKey})}else if(t.provider==="google"){const{ChatGoogleGenerativeAI:k}=await Ua(async()=>{const{ChatGoogleGenerativeAI:C}=await import("./index-Dqcx9Dh4.js");return{ChatGoogleGenerativeAI:C}},__vite__mapDeps([7,2,1,4]));R=new k({model:t.model,apiKey:t.apiKey})}else throw new Error(`Unsupported LLM provider: ${t.provider}`);m.current={instance:R,provider:t.provider,model:t.model,apiKey:t.apiKey}}if(!f.current||f.current.llm!==m.current.instance){const{MCPAgent:R}=await Ua(async()=>{const{MCPAgent:k}=await import("./browser-CsjID3k2.js");return{MCPAgent:k}},__vite__mapDeps([8,5,1,2,4,3]));f.current=new R({llm:m.current.instance,client:e.client??void 0,memoryEnabled:!0,systemPrompt:"You are a helpful assistant with access to MCP tools, prompts, and resources. Help users interact with the MCP server."}),await f.current.initialize()}else console.log("[useChatMessagesClientSide] Reusing existing agent. History length:",f.current.conversationHistory?.length);for await(const R of f.current.streamEvents(E,10,!1,void 0,void 0,u.current?.signal)){if(u.current?.signal.aborted)break;if(R.event==="on_chat_model_stream"&&R.data?.chunk?.text){const k=R.data.chunk.text;if(typeof k=="string"&&k.length>0){T+=k;const C=A[A.length-1];C&&C.type==="text"?C.text=T:A.push({type:"text",text:T}),o(O=>O.map(M=>M.id===_?{...M,parts:[...A]}:M))}}else if(R.event==="on_tool_start"){T&&(T="");let k={};R.data?.input?k=R.data.input:R.data?.tool_input?k=R.data.tool_input:R.data&&(k=R.data),console.log("[useChatMessagesClientSide] on_tool_start:",{toolName:R.name,eventData:R.data,extractedArgs:k}),S++,A.push({type:"tool-invocation",toolInvocation:{toolName:R.name||"unknown",args:k,state:"pending"}}),o(C=>C.map(O=>O.id===_?{...O,parts:[...A]}:O))}else if(R.event==="on_tool_end"){const k=A.find(C=>C.type==="tool-invocation"&&C.toolInvocation?.toolName===R.name&&!C.toolInvocation?.result);if(console.log("[useChatMessagesClientSide] on_tool_end event:",{toolName:R.name,hasToolPart:!!k,output:R.data?.output}),k&&k.toolInvocation){let C=R.data?.output;if(C?.kwargs?.content&&typeof C.kwargs.content=="string")try{C=JSON.parse(C.kwargs.content)}catch(M){console.warn("[useChatMessagesClientSide] Failed to parse kwargs.content:",M),C=C.kwargs.content}else if(C?.content&&typeof C.content=="string")try{C=JSON.parse(C.content)}catch{C=C.content}k.toolInvocation.result=C,k.toolInvocation.state="result";const O=C?._meta?.["openai/outputTemplate"];if(console.log("[useChatMessagesClientSide] Tool result:",{toolName:R.name,hasMeta:!!C?._meta,hasStructuredContent:!!C?.structuredContent,appsSdkUri:O}),O&&typeof O=="string"&&r){console.log("[useChatMessagesClientSide] Detected Apps SDK component, fetching resource:",O);try{const M=await r(O);console.log("[useChatMessagesClientSide] Resource fetched:",M);const L=C?.structuredContent||null;if(M?.contents&&Array.isArray(M.contents)){const $=M.contents.map(V=>({type:"resource",resource:V}));console.log("[useChatMessagesClientSide] Created MCP resources:",$);const H={...C,content:[...C.content||[],...$],structuredContent:L};k.toolInvocation.result=H,console.log("[useChatMessagesClientSide] Updated result with resources")}else console.warn("[useChatMessagesClientSide] No contents in resourceData:",M)}catch(M){console.error("Failed to fetch Apps SDK resource:",M)}}o(M=>M.map(L=>L.id===_?{...L,parts:[...A]}:L))}}}if(u.current?.signal.aborted)for(const R of A)R.type==="tool-invocation"&&R.toolInvocation?.state==="pending"&&(R.toolInvocation.state="error",R.toolInvocation.result="Cancelled by user");o(R=>R.map(k=>k.id===_?{...k,parts:[...A],content:""}:k)),t&&ra.getInstance().capture(new wU({serverId:e.url,provider:t.provider,model:t.model,messageCount:a.length+1,toolCallsCount:S,success:!0,executionMode:"client-side",duration:Date.now()-w})).catch(()=>{})}catch(_){if(_ instanceof DOMException&&_.name==="AbortError")return;console.error("Client-side agent error:",_);let T="Unknown error occurred";if(_ instanceof Error){T=_.message;const R=_;R.status&&(T=`HTTP ${R.status}: ${T}`),(R.code===401||T.includes("401")||T.includes("Unauthorized"))&&(T="Authentication failed (401). Check your Authorization header in the connection settings.")}t&&ra.getInstance().capture(new wU({serverId:e.url,provider:t.provider,model:t.model,messageCount:a.length+1,toolCallsCount:S,success:!1,executionMode:"client-side",duration:Date.now()-w,error:T})).catch(()=>{});const A={id:`error-${Date.now()}`,role:"assistant",content:`Error: ${T}`,timestamp:Date.now()};o(R=>[...R,A])}finally{l(!1),u.current=null}},[e,t,n,a,r]),g=b.useCallback(()=>{o([]),f.current&&f.current.clearConversationHistory()},[]),y=b.useCallback(()=>{u.current&&u.current.abort()},[]);return{messages:a,isLoading:i,sendMessage:h,clearMessages:g,stop:y}}const EF={openai:"gpt-4o",anthropic:"claude-haiku-4-5-20251001",google:"gemini-2.5-flash"};function gW({mcpServerUrl:e}){const[t,n]=b.useState(null),[r,a]=b.useState(null),[o,i]=b.useState(!1),[l,u]=b.useState("openai"),[f,m]=b.useState(""),[h,g]=b.useState(EF.openai),y=b.useCallback(()=>{const M=localStorage.getItem("mcp-inspector-api-keys");if(M)try{return JSON.parse(M)}catch(L){return console.error("Failed to load API keys:",L),{}}return{}},[]),E=b.useCallback(M=>{localStorage.setItem("mcp-inspector-api-keys",JSON.stringify(M))},[]),[x,w]=b.useState("none"),[S,_]=b.useState(""),[T,A]=b.useState(""),[R,k]=b.useState("");b.useEffect(()=>{const M=localStorage.getItem("mcp-inspector-llm-config"),L=y();if(M)try{const $=JSON.parse(M);n($),u($.provider),m(L[$.provider]||$.apiKey||""),g($.model)}catch($){console.error("Failed to load LLM config:",$)}},[y]),b.useEffect(()=>{const M=localStorage.getItem("mcp-inspector-auth-config");if(M)try{const L=JSON.parse(M);a(L),w(L.type),L.username&&_(L.username),L.password&&A(L.password),L.token&&k(L.token)}catch(L){console.error("Failed to load auth config:",L)}else try{const L="mcp:auth",$=hW(e),H=`${L}_${$}_tokens`;localStorage.getItem(H)&&(a({type:"oauth"}),w("oauth"))}catch(L){console.error("Failed to check for OAuth tokens:",L)}},[e]),b.useEffect(()=>{g(EF[l]);const M=y();m(M[l]||"")},[l,y]);const C=b.useCallback(()=>{if(!f.trim())return;const M=y();M[l]=f,E(M);const L={provider:l,apiKey:f,model:h},$={type:x,...x==="basic"&&{username:S.trim(),password:T.trim()},...x==="bearer"&&{token:R.trim()}};n(L),a($),localStorage.setItem("mcp-inspector-llm-config",JSON.stringify(L)),localStorage.setItem("mcp-inspector-auth-config",JSON.stringify($)),i(!1)},[l,f,h,x,S,T,R,y,E]),O=b.useCallback(()=>{n(null),a(null);const M=y();delete M[l],E(M),m(""),_(""),A(""),k(""),w("none"),localStorage.removeItem("mcp-inspector-llm-config"),localStorage.removeItem("mcp-inspector-auth-config")},[l,y,E]);return{llmConfig:t,authConfig:r,configDialogOpen:o,setConfigDialogOpen:i,tempProvider:l,setTempProvider:u,tempApiKey:f,setTempApiKey:m,tempModel:h,setTempModel:g,tempAuthType:x,saveLLMConfig:C,clearConfig:O}}function m_e({connection:e,isConnected:t,useClientSide:n=!0,readResource:r}){const[a,o]=b.useState(""),i=b.useRef(null),{llmConfig:l,authConfig:u,configDialogOpen:f,setConfigDialogOpen:m,tempProvider:h,setTempProvider:g,tempApiKey:y,setTempApiKey:E,tempModel:x,setTempModel:w,saveLLMConfig:S,clearConfig:_}=gW({mcpServerUrl:e.url}),T={connection:e,llmConfig:l,isConnected:t,readResource:r},A=f_e({mcpServerUrl:e.url,llmConfig:l,authConfig:u,isConnected:t}),R=p_e(T),{messages:k,isLoading:C,sendMessage:O,clearMessages:M,stop:L}=n?R:A;RG({onNewChat:M}),b.useEffect(()=>{l&&k.length===0&&i.current&&i.current.focus()},[l,k.length]),b.useEffect(()=>{!C&&k.length>0&&i.current&&i.current.focus()},[C,k.length]);const $=b.useCallback(()=>{a.trim()&&(O(a),o(""))},[a,O]),H=b.useCallback(Z=>{Z.key==="Enter"&&!Z.shiftKey&&(Z.preventDefault(),$())},[$]),V=b.useCallback(()=>{_(),M()},[_,M]);return l&&k.length===0?d.jsxs("div",{className:"flex flex-col h-full",children:[d.jsx("div",{className:"absolute top-4 right-4 z-10",children:d.jsx(yT,{open:f,onOpenChange:m,tempProvider:h,tempModel:x,tempApiKey:y,onProviderChange:g,onModelChange:w,onApiKeyChange:E,onSave:S,onClear:V,showClearButton:!0,buttonLabel:"Change API Key"})}),d.jsx(Bxe,{mcpServerUrl:e.url,inputValue:a,isConnected:t,isLoading:C,textareaRef:i,llmConfig:l,onInputChange:o,onKeyDown:H,onSubmit:Z=>{Z.preventDefault(),$()},onConfigDialogOpenChange:m})]}):d.jsxs("div",{className:"flex flex-col h-full relative",children:[d.jsx(Uxe,{llmConfig:l,hasMessages:k.length>0,configDialogOpen:f,onConfigDialogOpenChange:m,onClearChat:M,tempProvider:h,tempModel:x,tempApiKey:y,onProviderChange:g,onModelChange:w,onApiKeyChange:E,onSaveConfig:S,onClearConfig:V}),d.jsx("div",{className:"flex-1 overflow-y-auto p-2 sm:p-4 pt-[80px] sm:pt-[100px]",children:l?d.jsx(d_e,{messages:k,isLoading:C,serverId:e.url,readResource:r,tools:e.tools}):d.jsx(Hxe,{onConfigureClick:()=>m(!0)})}),l&&d.jsx(zxe,{inputValue:a,isConnected:t,isLoading:C,textareaRef:i,onInputChange:o,onKeyDown:H,onSendMessage:$,onStopStreaming:L})]})}const Fw=b.createContext(null);Fw.displayName="PanelGroupContext";const br={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"},WO=10,ic=b.useLayoutEffect,SF=Ec.useId,h_e=typeof SF=="function"?SF:()=>null;let g_e=0;function KO(e=null){const t=h_e(),n=b.useRef(e||t||null);return n.current===null&&(n.current=""+g_e++),e??n.current}function bW({children:e,className:t="",collapsedSize:n,collapsible:r,defaultSize:a,forwardedRef:o,id:i,maxSize:l,minSize:u,onCollapse:f,onExpand:m,onResize:h,order:g,style:y,tagName:E="div",...x}){const w=b.useContext(Fw);if(w===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:S,expandPanel:_,getPanelSize:T,getPanelStyle:A,groupId:R,isPanelCollapsed:k,reevaluatePanelConstraints:C,registerPanel:O,resizePanel:M,unregisterPanel:L}=w,$=KO(i),H=b.useRef({callbacks:{onCollapse:f,onExpand:m,onResize:h},constraints:{collapsedSize:n,collapsible:r,defaultSize:a,maxSize:l,minSize:u},id:$,idIsFromProps:i!==void 0,order:g});b.useRef({didLogMissingDefaultSizeWarning:!1}),ic(()=>{const{callbacks:Z,constraints:ne}=H.current,G={...ne};H.current.id=$,H.current.idIsFromProps=i!==void 0,H.current.order=g,Z.onCollapse=f,Z.onExpand=m,Z.onResize=h,ne.collapsedSize=n,ne.collapsible=r,ne.defaultSize=a,ne.maxSize=l,ne.minSize=u,(G.collapsedSize!==ne.collapsedSize||G.collapsible!==ne.collapsible||G.maxSize!==ne.maxSize||G.minSize!==ne.minSize)&&C(H.current,G)}),ic(()=>{const Z=H.current;return O(Z),()=>{L(Z)}},[g,$,O,L]),b.useImperativeHandle(o,()=>({collapse:()=>{S(H.current)},expand:Z=>{_(H.current,Z)},getId(){return $},getSize(){return T(H.current)},isCollapsed(){return k(H.current)},isExpanded(){return!k(H.current)},resize:Z=>{M(H.current,Z)}}),[S,_,T,k,$,M]);const V=A(H.current,a);return b.createElement(E,{...x,children:e,className:t,id:$,style:{...V,...y},[br.groupId]:R,[br.panel]:"",[br.panelCollapsible]:r||void 0,[br.panelId]:$,[br.panelSize]:parseFloat(""+V.flexGrow).toFixed(1)})}const yW=b.forwardRef((e,t)=>b.createElement(bW,{...e,forwardedRef:t}));bW.displayName="Panel";yW.displayName="forwardRef(Panel)";let UT=null,_y=-1,Ki=null;function b_e(e,t,n){const r=(t&SW)!==0,a=(t&_W)!==0,o=(t&TW)!==0,i=(t&NW)!==0;if(t){if(r)return o?"se-resize":i?"ne-resize":"e-resize";if(a)return o?"sw-resize":i?"nw-resize":"w-resize";if(o)return"s-resize";if(i)return"n-resize"}switch(e){case"horizontal":return"ew-resize";case"intersection":return"move";case"vertical":return"ns-resize"}}function y_e(){Ki!==null&&(document.head.removeChild(Ki),UT=null,Ki=null,_y=-1)}function ES(e,t,n){var r,a;const o=b_e(e,t);if(UT!==o){if(UT=o,Ki===null&&(Ki=document.createElement("style"),document.head.appendChild(Ki)),_y>=0){var i;(i=Ki.sheet)===null||i===void 0||i.removeRule(_y)}_y=(r=(a=Ki.sheet)===null||a===void 0?void 0:a.insertRule(`*{cursor: ${o} !important;}`))!==null&&r!==void 0?r:-1}}function vW(e){return e.type==="keydown"}function wW(e){return e.type.startsWith("pointer")}function xW(e){return e.type.startsWith("mouse")}function Bw(e){if(wW(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(xW(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}function v_e(){if(typeof matchMedia=="function")return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}function w_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 x_e(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:NF(e),b:NF(t)};let r;for(;n.a.at(-1)===n.b.at(-1);)e=n.a.pop(),t=n.b.pop(),r=e;tn(r,"Stacking order can only be calculated for elements with a common ancestor");const a={a:TF(_F(n.a)),b:TF(_F(n.b))};if(a.a===a.b){const o=r.childNodes,i={a:n.a.at(-1),b:n.b.at(-1)};let l=o.length;for(;l--;){const u=o[l];if(u===i.a)return 1;if(u===i.b)return-1}}return Math.sign(a.a-a.b)}const E_e=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function S_e(e){var t;const n=getComputedStyle((t=EW(e))!==null&&t!==void 0?t:e).display;return n==="flex"||n==="inline-flex"}function __e(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||S_e(e))||+t.opacity<1||"transform"in t&&t.transform!=="none"||"webkitTransform"in t&&t.webkitTransform!=="none"||"mixBlendMode"in t&&t.mixBlendMode!=="normal"||"filter"in t&&t.filter!=="none"||"webkitFilter"in t&&t.webkitFilter!=="none"||"isolation"in t&&t.isolation==="isolate"||E_e.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function _F(e){let t=e.length;for(;t--;){const n=e[t];if(tn(n,"Missing node"),__e(n))return n}return null}function TF(e){return e&&Number(getComputedStyle(e).zIndex)||0}function NF(e){const t=[];for(;e;)t.push(e),e=EW(e);return t}function EW(e){const{parentNode:t}=e;return t&&t instanceof ShadowRoot?t.host:t}const SW=1,_W=2,TW=4,NW=8,T_e=v_e()==="coarse";let Bo=[],od=!1,Yi=new Map,Hw=new Map;const Um=new Set;function N_e(e,t,n,r,a){var o;const{ownerDocument:i}=t,l={direction:n,element:t,hitAreaMargins:r,setResizeHandlerState:a},u=(o=Yi.get(i))!==null&&o!==void 0?o:0;return Yi.set(i,u+1),Um.add(l),Ev(),function(){var m;Hw.delete(e),Um.delete(l);const h=(m=Yi.get(i))!==null&&m!==void 0?m:1;if(Yi.set(i,h-1),Ev(),h===1&&Yi.delete(i),Bo.includes(l)){const g=Bo.indexOf(l);g>=0&&Bo.splice(g,1),Vw(),a("up",!0,null)}}}function C_e(e){const{target:t}=e,{x:n,y:r}=Bw(e);od=!0,YO({target:t,x:n,y:r}),Ev(),Bo.length>0&&(Sv("down",e),Vw(),e.preventDefault(),CW(t)||e.stopImmediatePropagation())}function SS(e){const{x:t,y:n}=Bw(e);if(od&&e.type!=="pointerleave"&&e.buttons===0&&(od=!1,Sv("up",e)),!od){const{target:r}=e;YO({target:r,x:t,y:n})}Sv("move",e),Vw(),Bo.length>0&&e.preventDefault()}function _S(e){const{target:t}=e,{x:n,y:r}=Bw(e);Hw.clear(),od=!1,Bo.length>0&&(e.preventDefault(),CW(t)||e.stopImmediatePropagation()),Sv("up",e),YO({target:t,x:n,y:r}),Vw(),Ev()}function CW(e){let t=e;for(;t;){if(t.hasAttribute(br.resizeHandle))return!0;t=t.parentElement}return!1}function YO({target:e,x:t,y:n}){Bo.splice(0);let r=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(r=e),Um.forEach(a=>{const{element:o,hitAreaMargins:i}=a,l=o.getBoundingClientRect(),{bottom:u,left:f,right:m,top:h}=l,g=T_e?i.coarse:i.fine;if(t>=f-g&&t<=m+g&&n>=h-g&&n<=u+g){if(r!==null&&document.contains(r)&&o!==r&&!o.contains(r)&&!r.contains(o)&&x_e(r,o)>0){let E=r,x=!1;for(;E&&!E.contains(o);){if(w_e(E.getBoundingClientRect(),l)){x=!0;break}E=E.parentElement}if(x)return}Bo.push(a)}})}function TS(e,t){Hw.set(e,t)}function Vw(){let e=!1,t=!1;Bo.forEach(r=>{const{direction:a}=r;a==="horizontal"?e=!0:t=!0});let n=0;Hw.forEach(r=>{n|=r}),e&&t?ES("intersection",n):e?ES("horizontal",n):t?ES("vertical",n):y_e()}let NS;function Ev(){var e;(e=NS)===null||e===void 0||e.abort(),NS=new AbortController;const t={capture:!0,signal:NS.signal};Um.size&&(od?(Bo.length>0&&Yi.forEach((n,r)=>{const{body:a}=r;n>0&&(a.addEventListener("contextmenu",_S,t),a.addEventListener("pointerleave",SS,t),a.addEventListener("pointermove",SS,t))}),Yi.forEach((n,r)=>{const{body:a}=r;a.addEventListener("pointerup",_S,t),a.addEventListener("pointercancel",_S,t)})):Yi.forEach((n,r)=>{const{body:a}=r;n>0&&(a.addEventListener("pointerdown",C_e,t),a.addEventListener("pointermove",SS,t))}))}function Sv(e,t){Um.forEach(n=>{const{setResizeHandlerState:r}=n,a=Bo.includes(n);r(e,a,t)})}function R_e(){const[e,t]=b.useState(0);return b.useCallback(()=>t(n=>n+1),[])}function tn(e,t){if(!e)throw console.error(t),Error(t)}function vc(e,t,n=WO){return e.toFixed(n)===t.toFixed(n)?0:e>t?1:-1}function Gs(e,t,n=WO){return vc(e,t,n)===0}function Qa(e,t,n){return vc(e,t,n)===0}function k_e(e,t,n){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++){const a=e[r],o=t[r];if(!Qa(a,o,n))return!1}return!0}function Ku({panelConstraints:e,panelIndex:t,size:n}){const r=e[t];tn(r!=null,`Panel constraints not found for index ${t}`);let{collapsedSize:a=0,collapsible:o,maxSize:i=100,minSize:l=0}=r;if(vc(n,l)<0)if(o){const u=(a+l)/2;vc(n,u)<0?n=a:n=l}else n=l;return n=Math.min(i,n),n=parseFloat(n.toFixed(WO)),n}function jp({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:a,trigger:o}){if(Qa(e,0))return t;const i=[...t],[l,u]=r;tn(l!=null,"Invalid first pivot index"),tn(u!=null,"Invalid second pivot index");let f=0;if(o==="keyboard"){{const h=e<0?u:l,g=n[h];tn(g,`Panel constraints not found for index ${h}`);const{collapsedSize:y=0,collapsible:E,minSize:x=0}=g;if(E){const w=t[h];if(tn(w!=null,`Previous layout not found for panel index ${h}`),Qa(w,y)){const S=x-w;vc(S,Math.abs(e))>0&&(e=e<0?0-S:S)}}}{const h=e<0?l:u,g=n[h];tn(g,`No panel constraints found for index ${h}`);const{collapsedSize:y=0,collapsible:E,minSize:x=0}=g;if(E){const w=t[h];if(tn(w!=null,`Previous layout not found for panel index ${h}`),Qa(w,x)){const S=w-y;vc(S,Math.abs(e))>0&&(e=e<0?0-S:S)}}}}{const h=e<0?1:-1;let g=e<0?u:l,y=0;for(;;){const x=t[g];tn(x!=null,`Previous layout not found for panel index ${g}`);const S=Ku({panelConstraints:n,panelIndex:g,size:100})-x;if(y+=S,g+=h,g<0||g>=n.length)break}const E=Math.min(Math.abs(e),Math.abs(y));e=e<0?0-E:E}{let g=e<0?l:u;for(;g>=0&&g<n.length;){const y=Math.abs(e)-Math.abs(f),E=t[g];tn(E!=null,`Previous layout not found for panel index ${g}`);const x=E-y,w=Ku({panelConstraints:n,panelIndex:g,size:x});if(!Qa(E,w)&&(f+=E-w,i[g]=w,f.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?g--:g++}}if(k_e(a,i))return a;{const h=e<0?u:l,g=t[h];tn(g!=null,`Previous layout not found for panel index ${h}`);const y=g+f,E=Ku({panelConstraints:n,panelIndex:h,size:y});if(i[h]=E,!Qa(E,y)){let x=y-E,S=e<0?u:l;for(;S>=0&&S<n.length;){const _=i[S];tn(_!=null,`Previous layout not found for panel index ${S}`);const T=_+x,A=Ku({panelConstraints:n,panelIndex:S,size:T});if(Qa(_,A)||(x-=A-_,i[S]=A),Qa(x,0))break;e>0?S--:S++}}}const m=i.reduce((h,g)=>g+h,0);return Qa(m,100)?i:a}function A_e({layout:e,panelsArray:t,pivotIndices:n}){let r=0,a=100,o=0,i=0;const l=n[0];tn(l!=null,"No pivot index found"),t.forEach((h,g)=>{const{constraints:y}=h,{maxSize:E=100,minSize:x=0}=y;g===l?(r=x,a=E):(o+=x,i+=E)});const u=Math.min(a,100-o),f=Math.max(r,100-i),m=e[l];return{valueMax:u,valueMin:f,valueNow:m}}function zm(e,t=document){return Array.from(t.querySelectorAll(`[${br.resizeHandleId}][data-panel-group-id="${e}"]`))}function RW(e,t,n=document){const a=zm(e,n).findIndex(o=>o.getAttribute(br.resizeHandleId)===t);return a??null}function kW(e,t,n){const r=RW(e,t,n);return r!=null?[r,r+1]:[-1,-1]}function I_e(e){return e instanceof HTMLElement?!0:typeof e=="object"&&e!==null&&"tagName"in e&&"getAttribute"in e}function AW(e,t=document){if(I_e(t)&&t.dataset.panelGroupId==e)return t;const n=t.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return n||null}function Gw(e,t=document){const n=t.querySelector(`[${br.resizeHandleId}="${e}"]`);return n||null}function O_e(e,t,n,r=document){var a,o,i,l;const u=Gw(t,r),f=zm(e,r),m=u?f.indexOf(u):-1,h=(a=(o=n[m])===null||o===void 0?void 0:o.id)!==null&&a!==void 0?a:null,g=(i=(l=n[m+1])===null||l===void 0?void 0:l.id)!==null&&i!==void 0?i:null;return[h,g]}function D_e({committedValuesRef:e,eagerValuesRef:t,groupId:n,layout:r,panelDataArray:a,panelGroupElement:o,setLayout:i}){b.useRef({didWarnAboutMissingResizeHandle:!1}),ic(()=>{if(!o)return;const l=zm(n,o);for(let u=0;u<a.length-1;u++){const{valueMax:f,valueMin:m,valueNow:h}=A_e({layout:r,panelsArray:a,pivotIndices:[u,u+1]}),g=l[u];if(g!=null){const y=a[u];tn(y,`No panel data found for index "${u}"`),g.setAttribute("aria-controls",y.id),g.setAttribute("aria-valuemax",""+Math.round(f)),g.setAttribute("aria-valuemin",""+Math.round(m)),g.setAttribute("aria-valuenow",h!=null?""+Math.round(h):"")}}return()=>{l.forEach((u,f)=>{u.removeAttribute("aria-controls"),u.removeAttribute("aria-valuemax"),u.removeAttribute("aria-valuemin"),u.removeAttribute("aria-valuenow")})}},[n,r,a,o]),b.useEffect(()=>{if(!o)return;const l=t.current;tn(l,"Eager values not found");const{panelDataArray:u}=l,f=AW(n,o);tn(f!=null,`No group found for id "${n}"`);const m=zm(n,o);tn(m,`No resize handles found for group id "${n}"`);const h=m.map(g=>{const y=g.getAttribute(br.resizeHandleId);tn(y,"Resize handle element has no handle id attribute");const[E,x]=O_e(n,y,u,o);if(E==null||x==null)return()=>{};const w=S=>{if(!S.defaultPrevented)switch(S.key){case"Enter":{S.preventDefault();const _=u.findIndex(T=>T.id===E);if(_>=0){const T=u[_];tn(T,`No panel data found for index ${_}`);const A=r[_],{collapsedSize:R=0,collapsible:k,minSize:C=0}=T.constraints;if(A!=null&&k){const O=jp({delta:Qa(A,R)?C-R:R-A,initialLayout:r,panelConstraints:u.map(M=>M.constraints),pivotIndices:kW(n,y,o),prevLayout:r,trigger:"keyboard"});r!==O&&i(O)}}break}}};return g.addEventListener("keydown",w),()=>{g.removeEventListener("keydown",w)}});return()=>{h.forEach(g=>g())}},[o,e,t,n,r,a,i])}function CF(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 IW(e,t){const n=e==="horizontal",{x:r,y:a}=Bw(t);return n?r:a}function L_e(e,t,n,r,a){const o=n==="horizontal",i=Gw(t,a);tn(i,`No resize handle element found for id "${t}"`);const l=i.getAttribute(br.groupId);tn(l,"Resize handle element has no group id attribute");let{initialCursorPosition:u}=r;const f=IW(n,e),m=AW(l,a);tn(m,`No group element found for id "${l}"`);const h=m.getBoundingClientRect(),g=o?h.width:h.height;return(f-u)/g*100}function M_e(e,t,n,r,a,o){if(vW(e)){const i=n==="horizontal";let l=0;e.shiftKey?l=100:a!=null?l=a:l=10;let u=0;switch(e.key){case"ArrowDown":u=i?0:l;break;case"ArrowLeft":u=i?-l:0;break;case"ArrowRight":u=i?l:0;break;case"ArrowUp":u=i?0:-l;break;case"End":u=100;break;case"Home":u=-100;break}return u}else return r==null?0:L_e(e,t,n,r,o)}function j_e({panelDataArray:e}){const t=Array(e.length),n=e.map(o=>o.constraints);let r=0,a=100;for(let o=0;o<e.length;o++){const i=n[o];tn(i,`Panel constraints not found for index ${o}`);const{defaultSize:l}=i;l!=null&&(r++,t[o]=l,a-=l)}for(let o=0;o<e.length;o++){const i=n[o];tn(i,`Panel constraints not found for index ${o}`);const{defaultSize:l}=i;if(l!=null)continue;const u=e.length-r,f=a/u;r++,t[o]=f,a-=f}return t}function vu(e,t,n){t.forEach((r,a)=>{const o=e[a];tn(o,`Panel data not found for index ${a}`);const{callbacks:i,constraints:l,id:u}=o,{collapsedSize:f=0,collapsible:m}=l,h=n[u];if(h==null||r!==h){n[u]=r;const{onCollapse:g,onExpand:y,onResize:E}=i;E&&E(r,h),m&&(g||y)&&(y&&(h==null||Gs(h,f))&&!Gs(r,f)&&y(),g&&(h==null||!Gs(h,f))&&Gs(r,f)&&g())}})}function Yb(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 P_e({defaultSize:e,dragState:t,layout:n,panelData:r,panelIndex:a,precision:o=3}){const i=n[a];let l;return i==null?l=e!=null?e.toFixed(o):"1":r.length===1?l="1":l=i.toFixed(o),{flexBasis:0,flexGrow:l,flexShrink:1,overflow:"hidden",pointerEvents:t!==null?"none":void 0}}function $_e(e,t=10){let n=null;return(...a)=>{n!==null&&clearTimeout(n),n=setTimeout(()=>{e(...a)},t)}}function RF(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 OW(e){return`react-resizable-panels:${e}`}function DW(e){return e.map(t=>{const{constraints:n,id:r,idIsFromProps:a,order:o}=t;return a?r:o?`${o}:${JSON.stringify(n)}`:JSON.stringify(n)}).sort((t,n)=>t.localeCompare(n)).join(",")}function LW(e,t){try{const n=OW(e),r=t.getItem(n);if(r){const a=JSON.parse(r);if(typeof a=="object"&&a!=null)return a}}catch{}return null}function U_e(e,t,n){var r,a;const o=(r=LW(e,n))!==null&&r!==void 0?r:{},i=DW(t);return(a=o[i])!==null&&a!==void 0?a:null}function z_e(e,t,n,r,a){var o;const i=OW(e),l=DW(t),u=(o=LW(e,a))!==null&&o!==void 0?o:{};u[l]={expandToSizes:Object.fromEntries(n.entries()),layout:r};try{a.setItem(i,JSON.stringify(u))}catch(f){console.error(f)}}function kF({layout:e,panelConstraints:t}){const n=[...e],r=n.reduce((o,i)=>o+i,0);if(n.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${n.map(o=>`${o}%`).join(", ")}`);if(!Qa(r,100)&&n.length>0)for(let o=0;o<t.length;o++){const i=n[o];tn(i!=null,`No layout data found for index ${o}`);const l=100/r*i;n[o]=l}let a=0;for(let o=0;o<t.length;o++){const i=n[o];tn(i!=null,`No layout data found for index ${o}`);const l=Ku({panelConstraints:t,panelIndex:o,size:i});i!=l&&(a+=i-l,n[o]=l)}if(!Qa(a,0))for(let o=0;o<t.length;o++){const i=n[o];tn(i!=null,`No layout data found for index ${o}`);const l=i+a,u=Ku({panelConstraints:t,panelIndex:o,size:l});if(i!==u&&(a-=u-i,n[o]=u,Qa(a,0)))break}return n}const F_e=100,Pp={getItem:e=>(RF(Pp),Pp.getItem(e)),setItem:(e,t)=>{RF(Pp),Pp.setItem(e,t)}},AF={};function MW({autoSaveId:e=null,children:t,className:n="",direction:r,forwardedRef:a,id:o=null,onLayout:i=null,keyboardResizeBy:l=null,storage:u=Pp,style:f,tagName:m="div",...h}){const g=KO(o),y=b.useRef(null),[E,x]=b.useState(null),[w,S]=b.useState([]),_=R_e(),T=b.useRef({}),A=b.useRef(new Map),R=b.useRef(0),k=b.useRef({autoSaveId:e,direction:r,dragState:E,id:g,keyboardResizeBy:l,onLayout:i,storage:u}),C=b.useRef({layout:w,panelDataArray:[],panelDataArrayChanged:!1});b.useRef({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),b.useImperativeHandle(a,()=>({getId:()=>k.current.id,getLayout:()=>{const{layout:z}=C.current;return z},setLayout:z=>{const{onLayout:D}=k.current,{layout:P,panelDataArray:W}=C.current,K=kF({layout:z,panelConstraints:W.map(ae=>ae.constraints)});CF(P,K)||(S(K),C.current.layout=K,D&&D(K),vu(W,K,T.current))}}),[]),ic(()=>{k.current.autoSaveId=e,k.current.direction=r,k.current.dragState=E,k.current.id=g,k.current.onLayout=i,k.current.storage=u}),D_e({committedValuesRef:k,eagerValuesRef:C,groupId:g,layout:w,panelDataArray:C.current.panelDataArray,setLayout:S,panelGroupElement:y.current}),b.useEffect(()=>{const{panelDataArray:z}=C.current;if(e){if(w.length===0||w.length!==z.length)return;let D=AF[e];D==null&&(D=$_e(z_e,F_e),AF[e]=D);const P=[...z],W=new Map(A.current);D(e,P,W,w,u)}},[e,w,u]),b.useEffect(()=>{});const O=b.useCallback(z=>{const{onLayout:D}=k.current,{layout:P,panelDataArray:W}=C.current;if(z.constraints.collapsible){const K=W.map(Q=>Q.constraints),{collapsedSize:ae=0,panelSize:oe,pivotIndices:le}=Wl(W,z,P);if(tn(oe!=null,`Panel size not found for panel "${z.id}"`),!Gs(oe,ae)){A.current.set(z.id,oe);const J=ku(W,z)===W.length-1?oe-ae:ae-oe,q=jp({delta:J,initialLayout:P,panelConstraints:K,pivotIndices:le,prevLayout:P,trigger:"imperative-api"});Yb(P,q)||(S(q),C.current.layout=q,D&&D(q),vu(W,q,T.current))}}},[]),M=b.useCallback((z,D)=>{const{onLayout:P}=k.current,{layout:W,panelDataArray:K}=C.current;if(z.constraints.collapsible){const ae=K.map(ie=>ie.constraints),{collapsedSize:oe=0,panelSize:le=0,minSize:Q=0,pivotIndices:J}=Wl(K,z,W),q=D??Q;if(Gs(le,oe)){const ie=A.current.get(z.id),he=ie!=null&&ie>=q?ie:q,Ye=ku(K,z)===K.length-1?le-he:he-le,Pe=jp({delta:Ye,initialLayout:W,panelConstraints:ae,pivotIndices:J,prevLayout:W,trigger:"imperative-api"});Yb(W,Pe)||(S(Pe),C.current.layout=Pe,P&&P(Pe),vu(K,Pe,T.current))}}},[]),L=b.useCallback(z=>{const{layout:D,panelDataArray:P}=C.current,{panelSize:W}=Wl(P,z,D);return tn(W!=null,`Panel size not found for panel "${z.id}"`),W},[]),$=b.useCallback((z,D)=>{const{panelDataArray:P}=C.current,W=ku(P,z);return P_e({defaultSize:D,dragState:E,layout:w,panelData:P,panelIndex:W})},[E,w]),H=b.useCallback(z=>{const{layout:D,panelDataArray:P}=C.current,{collapsedSize:W=0,collapsible:K,panelSize:ae}=Wl(P,z,D);return tn(ae!=null,`Panel size not found for panel "${z.id}"`),K===!0&&Gs(ae,W)},[]),V=b.useCallback(z=>{const{layout:D,panelDataArray:P}=C.current,{collapsedSize:W=0,collapsible:K,panelSize:ae}=Wl(P,z,D);return tn(ae!=null,`Panel size not found for panel "${z.id}"`),!K||vc(ae,W)>0},[]),Z=b.useCallback(z=>{const{panelDataArray:D}=C.current;D.push(z),D.sort((P,W)=>{const K=P.order,ae=W.order;return K==null&&ae==null?0:K==null?-1:ae==null?1:K-ae}),C.current.panelDataArrayChanged=!0,_()},[_]);ic(()=>{if(C.current.panelDataArrayChanged){C.current.panelDataArrayChanged=!1;const{autoSaveId:z,onLayout:D,storage:P}=k.current,{layout:W,panelDataArray:K}=C.current;let ae=null;if(z){const le=U_e(z,K,P);le&&(A.current=new Map(Object.entries(le.expandToSizes)),ae=le.layout)}ae==null&&(ae=j_e({panelDataArray:K}));const oe=kF({layout:ae,panelConstraints:K.map(le=>le.constraints)});CF(W,oe)||(S(oe),C.current.layout=oe,D&&D(oe),vu(K,oe,T.current))}}),ic(()=>{const z=C.current;return()=>{z.layout=[]}},[]);const ne=b.useCallback(z=>{let D=!1;const P=y.current;return P&&window.getComputedStyle(P,null).getPropertyValue("direction")==="rtl"&&(D=!0),function(K){K.preventDefault();const ae=y.current;if(!ae)return()=>null;const{direction:oe,dragState:le,id:Q,keyboardResizeBy:J,onLayout:q}=k.current,{layout:ie,panelDataArray:he}=C.current,{initialLayout:Ne}=le??{},Ye=kW(Q,z,ae);let Pe=M_e(K,z,oe,le,J,ae);const Ue=oe==="horizontal";Ue&&D&&(Pe=-Pe);const st=he.map(rt=>rt.constraints),Ve=jp({delta:Pe,initialLayout:Ne??ie,panelConstraints:st,pivotIndices:Ye,prevLayout:ie,trigger:vW(K)?"keyboard":"mouse-or-touch"}),ut=!Yb(ie,Ve);(wW(K)||xW(K))&&R.current!=Pe&&(R.current=Pe,!ut&&Pe!==0?Ue?TS(z,Pe<0?SW:_W):TS(z,Pe<0?TW:NW):TS(z,0)),ut&&(S(Ve),C.current.layout=Ve,q&&q(Ve),vu(he,Ve,T.current))}},[]),G=b.useCallback((z,D)=>{const{onLayout:P}=k.current,{layout:W,panelDataArray:K}=C.current,ae=K.map(ie=>ie.constraints),{panelSize:oe,pivotIndices:le}=Wl(K,z,W);tn(oe!=null,`Panel size not found for panel "${z.id}"`);const J=ku(K,z)===K.length-1?oe-D:D-oe,q=jp({delta:J,initialLayout:W,panelConstraints:ae,pivotIndices:le,prevLayout:W,trigger:"imperative-api"});Yb(W,q)||(S(q),C.current.layout=q,P&&P(q),vu(K,q,T.current))},[]),Y=b.useCallback((z,D)=>{const{layout:P,panelDataArray:W}=C.current,{collapsedSize:K=0,collapsible:ae}=D,{collapsedSize:oe=0,collapsible:le,maxSize:Q=100,minSize:J=0}=z.constraints,{panelSize:q}=Wl(W,z,P);q!=null&&(ae&&le&&Gs(q,K)?Gs(K,oe)||G(z,oe):q<J?G(z,J):q>Q&&G(z,Q))},[G]),F=b.useCallback((z,D)=>{const{direction:P}=k.current,{layout:W}=C.current;if(!y.current)return;const K=Gw(z,y.current);tn(K,`Drag handle element not found for id "${z}"`);const ae=IW(P,D);x({dragHandleId:z,dragHandleRect:K.getBoundingClientRect(),initialCursorPosition:ae,initialLayout:W})},[]),re=b.useCallback(()=>{x(null)},[]),ee=b.useCallback(z=>{const{panelDataArray:D}=C.current,P=ku(D,z);P>=0&&(D.splice(P,1),delete T.current[z.id],C.current.panelDataArrayChanged=!0,_())},[_]),j=b.useMemo(()=>({collapsePanel:O,direction:r,dragState:E,expandPanel:M,getPanelSize:L,getPanelStyle:$,groupId:g,isPanelCollapsed:H,isPanelExpanded:V,reevaluatePanelConstraints:Y,registerPanel:Z,registerResizeHandle:ne,resizePanel:G,startDragging:F,stopDragging:re,unregisterPanel:ee,panelGroupElement:y.current}),[O,E,r,M,L,$,g,H,V,Y,Z,ne,G,F,re,ee]),B={display:"flex",flexDirection:r==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return b.createElement(Fw.Provider,{value:j},b.createElement(m,{...h,children:t,className:n,id:o,ref:y,style:{...B,...f},[br.group]:"",[br.groupDirection]:r,[br.groupId]:g}))}const jW=b.forwardRef((e,t)=>b.createElement(MW,{...e,forwardedRef:t}));MW.displayName="PanelGroup";jW.displayName="forwardRef(PanelGroup)";function ku(e,t){return e.findIndex(n=>n===t||n.id===t.id)}function Wl(e,t,n){const r=ku(e,t),o=r===e.length-1?[r-1,r]:[r,r+1],i=n[r];return{...t.constraints,panelSize:i,pivotIndices:o}}function B_e({disabled:e,handleId:t,resizeHandler:n,panelGroupElement:r}){b.useEffect(()=>{if(e||n==null||r==null)return;const a=Gw(t,r);if(a==null)return;const o=i=>{if(!i.defaultPrevented)switch(i.key){case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"End":case"Home":{i.preventDefault(),n(i);break}case"F6":{i.preventDefault();const l=a.getAttribute(br.groupId);tn(l,`No group element found for id "${l}"`);const u=zm(l,r),f=RW(l,t,r);tn(f!==null,`No resize element found for id "${t}"`);const m=i.shiftKey?f>0?f-1:u.length-1:f+1<u.length?f+1:0;u[m].focus();break}}};return a.addEventListener("keydown",o),()=>{a.removeEventListener("keydown",o)}},[r,e,t,n])}function PW({children:e=null,className:t="",disabled:n=!1,hitAreaMargins:r,id:a,onBlur:o,onClick:i,onDragging:l,onFocus:u,onPointerDown:f,onPointerUp:m,style:h={},tabIndex:g=0,tagName:y="div",...E}){var x,w;const S=b.useRef(null),_=b.useRef({onClick:i,onDragging:l,onPointerDown:f,onPointerUp:m});b.useEffect(()=>{_.current.onClick=i,_.current.onDragging=l,_.current.onPointerDown=f,_.current.onPointerUp=m});const T=b.useContext(Fw);if(T===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:A,groupId:R,registerResizeHandle:k,startDragging:C,stopDragging:O,panelGroupElement:M}=T,L=KO(a),[$,H]=b.useState("inactive"),[V,Z]=b.useState(!1),[ne,G]=b.useState(null),Y=b.useRef({state:$});ic(()=>{Y.current.state=$}),b.useEffect(()=>{if(n)G(null);else{const j=k(L);G(()=>j)}},[n,L,k]);const F=(x=r?.coarse)!==null&&x!==void 0?x:15,re=(w=r?.fine)!==null&&w!==void 0?w:5;b.useEffect(()=>{if(n||ne==null)return;const j=S.current;tn(j,"Element ref not attached");let B=!1;return N_e(L,j,A,{coarse:F,fine:re},(D,P,W)=>{if(!P){H("inactive");return}switch(D){case"down":{H("drag"),B=!1,tn(W,'Expected event to be defined for "down" action'),C(L,W);const{onDragging:K,onPointerDown:ae}=_.current;K?.(!0),ae?.();break}case"move":{const{state:K}=Y.current;B=!0,K!=="drag"&&H("hover"),tn(W,'Expected event to be defined for "move" action'),ne(W);break}case"up":{H("hover"),O();const{onClick:K,onDragging:ae,onPointerUp:oe}=_.current;ae?.(!1),oe?.(),B||K?.();break}}})},[F,A,n,re,k,L,ne,C,O]),B_e({disabled:n,handleId:L,resizeHandler:ne,panelGroupElement:M});const ee={touchAction:"none",userSelect:"none"};return b.createElement(y,{...E,children:e,className:t,id:a,onBlur:()=>{Z(!1),o?.()},onFocus:()=>{Z(!0),u?.()},ref:S,role:"separator",style:{...ee,...h},tabIndex:g,[br.groupDirection]:A,[br.groupId]:R,[br.resizeHandle]:"",[br.resizeHandleActive]:$==="drag"?"pointer":V?"keyboard":void 0,[br.resizeHandleEnabled]:!n,[br.resizeHandleId]:L,[br.resizeHandleState]:$})}PW.displayName="PanelResizeHandle";function Ta({className:e,...t}){return d.jsx(jW,{"data-slot":"resizable-panel-group",className:Fe("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...t})}function Yn({...e}){return d.jsx(yW,{"data-slot":"resizable-panel",...e})}function Ho({withHandle:e,className:t,...n}){return d.jsx(PW,{"data-slot":"resizable-handle",className:Fe("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&&d.jsx("div",{className:"bg-border z-10 flex h-4 w-3 items-center justify-center rounded-xs border",children:d.jsx(Fue,{className:"size-2.5"})})})}function Sh({className:e,...t}){return d.jsx("kbd",{"data-slot":"kbd",className:Fe("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 H_e({isSearchExpanded:e,searchQuery:t,filteredNotificationsCount:n,notificationsCount:r,onSearchExpand:a,onSearchChange:o,onSearchBlur:i,onClearAll:l,searchInputRef:u}){return d.jsxs("div",{className:"flex flex-row items-center justify-between p-4 sm:p-4 py-3 gap-2",children:[d.jsx("div",{className:"flex items-center gap-2 flex-1",children:e?d.jsx(Hn,{ref:u,placeholder:"Search notifications...",value:t,onChange:f=>o(f.target.value),onBlur:i,className:"h-8 border-gray-300 dark:border-zinc-600"}):d.jsxs(d.Fragment,{children:[d.jsx("h2",{className:"text-lg font-medium text-gray-900 dark:text-gray-100",children:"Notifications"}),d.jsx(Dr,{className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",variant:"outline",children:n}),d.jsxs(Wt,{children:[d.jsx(Kt,{asChild:!0,children:d.jsx(Le,{variant:"ghost",size:"sm",onClick:a,className:"h-8 w-8 p-0",children:d.jsx(lf,{className:"h-4 w-4"})})}),d.jsxs(Yt,{side:"bottom",className:"flex gap-2",children:["Search",d.jsx(Sh,{children:"F"})]})]})]})}),d.jsx("div",{className:"flex items-center gap-2",children:d.jsxs(Wt,{children:[d.jsx(Kt,{asChild:!0,children:d.jsx(Le,{variant:"ghost",size:"sm",onClick:l,disabled:r===0,className:"h-8 w-8 p-0",children:d.jsx(ti,{className:"h-4 w-4"})})}),d.jsx(Yt,{side:"bottom",children:"Clear all"})]})})]})}function El({id:e,isSelected:t,isFocused:n,icon:r,title:a,description:o,metadata:i,onClick:l,className:u}){return d.jsx("button",{id:e,type:"button",onClick:l,className:Fe("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:d.jsxs("div",{className:"flex items-start gap-2 sm:gap-3",children:[r&&d.jsx("div",{className:"flex-shrink-0 mt-1",children:d.jsx("div",{className:Fe("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:r})}),d.jsxs("div",{className:"flex-1 min-w-0",children:[d.jsx("div",{className:"flex items-center gap-2 mb-1",children:d.jsx("h3",{className:Fe("font-medium truncate font-mono text-sm"),children:a})}),o&&d.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 line-clamp-2",children:o})]})]})})}function V_e({notifications:e,selectedNotification:t,onNotificationSelect:n,focusedIndex:r,formatRelativeTime:a,listRef:o}){return e.length===0?d.jsx("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:d.jsx(sf,{vertical:!0,noBorder:!0,message:"No notifications yet"})}):d.jsx("div",{ref:o,className:"overflow-y-auto flex-1 overscroll-contain",children:e.map((i,l)=>d.jsx(El,{id:`notification-${i.id}`,isSelected:t?.id===i.id,isFocused:r===l,title:d.jsxs("span",{className:"flex items-center gap-3",children:[i.method,!i.read&&d.jsx("span",{className:"size-1.5 block rounded-full bg-orange-500"})]}),description:(()=>{const u=a(i.timestamp),f=i.params&&Object.keys(i.params).length>0?Object.keys(i.params).length:0,m=f>0?` | ${f} param${f>1?"s":""}`:"";return u+m})(),onClick:()=>n(i)},i.id))})}function G_e({notification:e,previewMode:t,onTogglePreview:n,onCopy:r,onDownload:a,onFullscreen:o,isCopied:i=!1,onClose:l}){return e?d.jsxs("div",{className:"flex flex-col h-full",children:[d.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:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsxs("div",{className:"flex items-center gap-1",children:[d.jsx(fm,{className:"h-3 w-3 text-gray-400"}),d.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:new Date(e.timestamp).toLocaleTimeString()})]}),d.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:e.formatRelativeTime(e.timestamp)})]}),d.jsxs("div",{className:"flex items-center gap-1",children:[d.jsxs(Le,{variant:"ghost",size:"sm",onClick:n,className:t?"":"text-purple-600 dark:text-purple-400",children:[t?d.jsx(qN,{className:"h-4 w-4 mr-1"}):d.jsx(FH,{className:"h-4 w-4 mr-1"}),t?"JSON":"Formatted"]}),d.jsx(Le,{variant:"ghost",size:"sm",onClick:r,children:i?d.jsx(Or,{className:"h-4 w-4"}):d.jsx(wr,{className:"h-4 w-4"})}),d.jsx(Le,{variant:"ghost",size:"sm",onClick:a,children:d.jsx(rh,{className:"h-4 w-4"})}),d.jsx(Le,{variant:"ghost",size:"sm",onClick:o,children:d.jsx(mm,{className:"h-4 w-4"})}),l&&d.jsx(Le,{variant:"ghost",size:"sm",onClick:l,children:d.jsx(ys,{className:"h-4 w-4"})})]})]}),d.jsx("div",{className:"flex-1 overflow-y-auto",children:d.jsx("div",{className:"px-4 pt-4",children:d.jsx(yr,{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`})})})]}):d.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[d.jsx(ZN,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),d.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"Select a notification to view details"})]})}function _v(e){const n=Date.now()-e,r=Math.floor(n/1e3),a=Math.floor(r/60),o=Math.floor(a/60),i=Math.floor(o/24);return r<60?"just now":a<60?`${a}m ago`:o<24?`${o}h ago`:i<7?`${i}d ago`:new Date(e).toLocaleDateString()}function W_e({notifications:e,unreadCount:t,markNotificationRead:n,markAllNotificationsRead:r,clearNotifications:a,serverId:o,isConnected:i}){const[l,u]=b.useState(null),[f,m]=b.useState(""),[h,g]=b.useState(-1),[y,E]=b.useState(!0),[x,w]=b.useState(!1),[S,_]=b.useState(!0),[T,A]=b.useState(!1),R=b.useRef(null),k=b.useRef(null),C=b.useRef(null),O=b.useRef(!1);b.useEffect(()=>{y&&e.length>0&&R.current&&!O.current&&(R.current.scrollTop=0)},[e.length,y]),b.useEffect(()=>{const Y=R.current;if(!Y)return;const F=()=>{Y.scrollTop>0&&(O.current=!0,E(!1))};return Y.addEventListener("scroll",F),()=>Y.removeEventListener("scroll",F)},[]),b.useEffect(()=>{e.length===0&&(O.current=!1,E(!0))},[e.length]),b.useEffect(()=>{l&&!l.read&&n(l.id)},[l,n]),b.useEffect(()=>{x&&C.current&&C.current.focus()},[x]);const M=b.useCallback(()=>{f.trim()||w(!1)},[f]),L=b.useMemo(()=>{if(!f.trim())return e;const Y=f.toLowerCase();return e.filter(F=>F.method.toLowerCase().includes(Y)||JSON.stringify(F.params||{}).toLowerCase().includes(Y))},[e,f]);b.useEffect(()=>{g(-1)},[f]),b.useEffect(()=>{const Y=F=>{const re=F.target;if(re.tagName==="INPUT"||re.tagName==="TEXTAREA"||re.contentEditable==="true"||F.metaKey||F.ctrlKey||F.altKey)return;const j=L;if(F.key==="ArrowDown")F.preventDefault(),g(B=>{const z=B+1;return z>=j.length?0:z});else if(F.key==="ArrowUp")F.preventDefault(),g(B=>{const z=B-1;return z<0?j.length-1:z});else if(F.key==="Enter"&&h>=0){F.preventDefault();const B=L[h];B&&$(B)}};return document.addEventListener("keydown",Y),()=>document.removeEventListener("keydown",Y)},[h,L]),b.useEffect(()=>{if(h>=0){const Y=`notification-${L[h]?.id}`,F=document.getElementById(Y);F&&F.scrollIntoView({behavior:"smooth",block:"nearest"})}},[h,L]);const $=b.useCallback(Y=>{u(Y)},[]),H=b.useCallback(()=>{window.confirm("Are you sure you want to clear all notifications? This cannot be undone.")&&(a(),u(null))},[a]),V=b.useCallback(async()=>{if(l)try{await navigator.clipboard.writeText(JSON.stringify({method:l.method,timestamp:l.timestamp,read:l.read,params:l.params},null,2)),A(!0),setTimeout(()=>A(!1),2e3)}catch(Y){console.error("[NotificationsTab] Failed to copy notification:",Y)}},[l]),Z=b.useCallback(()=>{if(l)try{const Y=new globalThis.Blob([JSON.stringify({method:l.method,timestamp:l.timestamp,read:l.read,params:l.params},null,2)],{type:"application/json"}),F=URL.createObjectURL(Y),re=document.createElement("a");re.href=F,re.download=`notification-${Date.now()}.json`,document.body.appendChild(re),re.click(),document.body.removeChild(re),URL.revokeObjectURL(F)}catch(Y){console.error("[NotificationsTab] Failed to download notification:",Y)}},[l]),ne=b.useCallback(async()=>{if(k.current)try{document.fullscreenElement?await document.exitFullscreen():await k.current.requestFullscreen()}catch(Y){console.error("[NotificationsTab] Failed to toggle fullscreen:",Y)}},[]),G=l?{method:l.method,params:l.params,timestamp:l.timestamp,read:l.read,formatRelativeTime:_v}:null;return i?d.jsxs(Ta,{direction:"horizontal",className:"h-full",children:[d.jsx(Yn,{defaultSize:40,minSize:30,children:d.jsx(Ta,{direction:"vertical",className:"h-full border-r dark:border-zinc-700",children:d.jsxs(Yn,{defaultSize:75,minSize:30,children:[d.jsx(H_e,{isSearchExpanded:x,searchQuery:f,filteredNotificationsCount:L.length,notificationsCount:e.length,onSearchExpand:()=>w(!0),onSearchChange:m,onSearchBlur:M,onClearAll:H,searchInputRef:C}),d.jsx("div",{className:"flex flex-col h-full",children:d.jsx(V_e,{notifications:L,selectedNotification:l,onNotificationSelect:$,focusedIndex:h,formatRelativeTime:_v,listRef:R})})]})})}),d.jsx(Ho,{}),d.jsx(Yn,{defaultSize:60,minSize:40,children:d.jsx("div",{ref:k,className:"h-full bg-white dark:bg-zinc-900",children:d.jsx(G_e,{notification:G,previewMode:S,onTogglePreview:()=>_(!S),onCopy:V,onDownload:Z,onFullscreen:ne,onClose:()=>u(null),isCopied:T})})})]}):d.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[d.jsx(ZN,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),d.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"Not connected to server"})]})}function ZO({serverIds:e,onCountChange:t,onClearRef:n}={}){const[r,a]=b.useState([]),o=b.useRef(null),[i,l]=b.useState(new Set),[u]=b.useState(""),f=y=>{l(E=>{const x=new Set(E);return x.has(y)?x.delete(y):x.add(y),x})},m=async()=>{a([]),l(new Set),t?.(0),e&&e.length>0?e.forEach(y=>Fy(y)):Fy()},h=b.useMemo(()=>!e||e.length===0?"":[...e].sort().join(","),[e]);b.useEffect(()=>(n&&(n.current=m),()=>{n&&(n.current=null)}),[n,m]),b.useEffect(()=>{t?.(r.length)},[r.length,t]),b.useEffect(()=>{console.log("[RPC Logger] Subscribing to RPC logs for servers:",e);const y=TN(),x=(e&&e.length>0?y.filter(S=>e.includes(S.serverId)):y).map(S=>{const _=S.message,T=typeof _?.method=="string"?_.method:_?.result!==void 0?"result":_?.error!==void 0?"error":"unknown";return{id:`${S.timestamp}-${Math.random().toString(36).slice(2)}`,serverId:S.serverId,direction:S.direction.toUpperCase(),method:T,timestamp:S.timestamp,payload:S.message}}).reverse();a(x),t?.(x.length);const w=NN(S=>{if(e&&e.length>0&&!e.includes(S.serverId))return;const _=S.message,T=typeof _?.method=="string"?_.method:_?.result!==void 0?"result":_?.error!==void 0?"error":"unknown",A={id:`${S.timestamp}-${Math.random().toString(36).slice(2)}`,serverId:S.serverId,direction:S.direction.toUpperCase(),method:T,timestamp:S.timestamp,payload:S.message};console.log("[RPC Logger] New RPC log:",{method:T,direction:S.direction,serverId:S.serverId}),a(R=>{const k=[A,...R].slice(0,1e3);return t?.(k.length),k})});return()=>{w(),console.log("[RPC Logger] Unsubscribed from RPC logs")}},[h,t]);const g=b.useMemo(()=>{let y=r;if(e&&e.length>0){const E=new Set(e);y=y.filter(x=>E.has(x.serverId))}if(u.trim()){const E=u.toLowerCase();y=y.filter(x=>x.serverId.toLowerCase().includes(E)||x.method.toLowerCase().includes(E)||x.direction.toLowerCase().includes(E)||JSON.stringify(x.payload).toLowerCase().includes(E))}return y=[...y].sort((E,x)=>new Date(x.timestamp).getTime()-new Date(E.timestamp).getTime()),y},[r,u,e]);return d.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:d.jsx("div",{ref:o,className:"flex-1 min-h-0 overflow-y-auto",children:g.length===0?d.jsxs("div",{className:"text-center py-8",children:[d.jsx("div",{className:"text-xs text-muted-foreground",children:"No messages yet"}),d.jsx("div",{className:"text-[10px] text-muted-foreground mt-1",children:"JSON-RPC messages will appear here"})]}):g.map(y=>{const E=i.has(y.id);return d.jsxs("div",{className:"group hover:bg-muted/50 transition-all duration-200 overflow-hidden",children:[d.jsxs("div",{className:"px-3 py-2 flex items-center gap-2 cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>f(y.id),children:[d.jsx("div",{className:"flex-shrink-0",children:E?d.jsx(hs,{className:"h-3 w-3 text-muted-foreground transition-transform"}):d.jsx(BH,{className:"h-3 w-3 text-muted-foreground transition-transform"})}),d.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[d.jsx("span",{className:"text-muted-foreground font-mono text-xs",children:new Date(y.timestamp).toLocaleTimeString()}),d.jsx("span",{className:`flex items-center justify-center px-1 py-0.5 rounded ${y.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:y.direction==="RECEIVE"?"Incoming":"Outgoing",children:y.direction==="RECEIVE"?d.jsx(Xce,{className:"h-3 w-3"}):d.jsx(Qce,{className:"h-3 w-3"})}),d.jsx("span",{className:"text-xs font-mono text-foreground truncate",children:y.method})]})]}),E&&d.jsx("div",{className:"border-t bg-muted/20",children:d.jsx("div",{className:"p-3",children:d.jsx("div",{className:"max-h-[40vh] overflow-auto rounded-sm bg-background/60 p-2",children:d.jsx(yr,{data:y.payload})})})})]},y.id)})})})}function $W({activeTab:e,isSearchExpanded:t,searchQuery:n,primaryTabTitle:r,secondaryTabTitle:a,primaryCount:o,secondaryCount:i,secondaryIcon:l,primaryIcon:u,searchPlaceholder:f="Search...",onSearchExpand:m,onSearchChange:h,onSearchBlur:g,onTabSwitch:y,searchInputRef:E,primaryTabName:x}){const w=e===x;return d.jsxs("div",{className:"flex flex-row items-center justify-between p-4 sm:p-4 py-3 gap-2",children:[d.jsx("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:t?d.jsx(Hn,{ref:E,placeholder:f,value:n,onChange:S=>h(S.target.value),onBlur:g,className:"h-8 border-gray-300 dark:border-zinc-600"}):d.jsxs(d.Fragment,{children:[d.jsx("h2",{className:"text-lg font-medium text-gray-900 dark:text-gray-100",children:w?r:a}),w&&d.jsxs(d.Fragment,{children:[d.jsx(Dr,{className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",variant:"outline",children:o}),d.jsxs(Wt,{children:[d.jsx(Kt,{asChild:!0,children:d.jsx(Le,{variant:"ghost",size:"sm",onClick:m,className:"h-8 w-8 p-0",children:d.jsx(lf,{className:"h-4 w-4"})})}),d.jsxs(Yt,{side:"bottom",className:"flex gap-2",children:["Search",d.jsx(Sh,{children:"F"})]})]})]})]})}),d.jsxs(Le,{variant:"ghost",size:"sm",onClick:y,className:"gap-2 flex-shrink-0",children:[w?d.jsx(l,{}):d.jsx(u,{}),d.jsx("span",{className:"hidden sm:inline",children:w?a:r}),w&&i>0&&d.jsx(Dr,{className:"bg-purple-500/20 text-purple-600 dark:text-purple-400 border-transparent",variant:"outline",children:i})]})]})}function IF({prompts:e,selectedPrompt:t,onPromptSelect:n,focusedIndex:r}){return e.length===0?d.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[d.jsx(hm,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),d.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"No prompts available"})]}):d.jsx("div",{className:"overflow-y-auto flex-1 border-r dark:border-zinc-700 overscroll-contain",children:e.map((a,o)=>d.jsx(El,{id:`prompt-${a.name}`,isSelected:t?.name===a.name,isFocused:r===o,icon:d.jsx(hm,{className:"h-4 w-4"}),title:a.name,description:a.description,metadata:a.arguments&&a.arguments.length>0&&d.jsxs(Dr,{variant:"outline",className:"text-xs border-gray-300 dark:border-zinc-600 text-gray-600 dark:text-gray-400",children:[a.arguments.length," args"]}),onClick:()=>n(a)},a.name))})}function OF({activeTab:e,isSearchExpanded:t,searchQuery:n,filteredPromptsCount:r,savedPromptsCount:a,onSearchExpand:o,onSearchChange:i,onSearchBlur:l,onTabSwitch:u,searchInputRef:f}){return d.jsx($W,{activeTab:e,isSearchExpanded:t,searchQuery:n,primaryTabName:"prompts",secondaryTabName:"saved",primaryTabTitle:"Prompts",secondaryTabTitle:"History",primaryCount:r,secondaryCount:a,primaryIcon:hm,secondaryIcon:fm,searchPlaceholder:"Search prompts...",onSearchExpand:o,onSearchChange:i,onSearchBlur:l,onTabSwitch:u,searchInputRef:f})}function DF({savedPrompts:e,selectedPrompt:t,onLoadPrompt:n,onDeletePrompt:r,focusedIndex:a}){return e.length===0?d.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[d.jsx(fm,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),d.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"No history"}),d.jsx("p",{className:"text-sm text-gray-400 dark:text-gray-500 mt-1",children:"Prompts you execute will appear here"})]}):d.jsx("div",{className:"overflow-y-auto flex-1 border-r dark:border-zinc-700 overscroll-contain",children:e.map((o,i)=>d.jsx(El,{id:`saved-prompt-${o.id}`,isSelected:t?.id===o.id,isFocused:a===i,icon:d.jsx(fm,{className:"h-4 w-4"}),title:o.name,description:`${o.promptName} - ${new Date(o.savedAt).toLocaleString()}`,onClick:()=>n(o)},o.id))})}function K_e({selectedPrompt:e,promptArgs:t,onArgChange:n}){const r=e?.arguments||[];if(!(r.length>0))return d.jsx("div",{className:"flex items-center justify-center h-32 text-gray-500 dark:text-gray-400 text-sm",children:"No arguments required"});const o=i=>{const l=i.name,u=t[l],f=typeof u=="string"?u:JSON.stringify(u);return i.type==="boolean"?d.jsxs("div",{className:"space-y-2",children:[d.jsxs(wn,{htmlFor:l,className:"text-sm font-medium",children:[l,i.required&&d.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),d.jsxs("div",{className:"flex items-center space-x-2",children:[d.jsx("input",{id:l,type:"checkbox",checked:!!u,onChange:m=>n(l,m.target.checked),className:"rounded","aria-label":`Toggle ${l}`}),d.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:i.description})]})]},l):i.type==="number"?d.jsxs("div",{className:"space-y-2",children:[d.jsxs(wn,{htmlFor:l,className:"text-sm font-medium",children:[l,i.required&&d.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),d.jsx(Hn,{id:l,type:"number",value:Number(u)||0,onChange:m=>n(l,Number(m.target.value)),placeholder:i.description||`Enter ${l}`}),i.description&&d.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:i.description})]},l):i.type==="array"||i.type==="object"?d.jsxs("div",{className:"space-y-2",children:[d.jsxs(wn,{htmlFor:l,className:"text-sm font-medium",children:[l,i.required&&d.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),d.jsx(bc,{id:l,value:f,onChange:m=>{try{const h=JSON.parse(m.target.value);n(l,h)}catch{n(l,m.target.value)}},placeholder:i.description||`Enter ${l} as JSON`,className:"font-mono text-sm min-h-[100px]"}),i.description&&d.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:i.description})]},l):d.jsxs("div",{className:"space-y-2",children:[d.jsxs(wn,{htmlFor:l,className:"text-sm font-medium",children:[l,i.required&&d.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),d.jsx(Hn,{id:l,value:f,onChange:m=>n(l,m.target.value),placeholder:i.description||`Enter ${l}`}),i.description&&d.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:i.description})]},l)};return d.jsx("div",{className:"space-y-4",children:r.map(i=>o(i))})}function LF({selectedPrompt:e,promptArgs:t,isExecuting:n,isConnected:r,onArgChange:a,onExecute:o,onSave:i}){return b.useEffect(()=>{const l=u=>{(u.metaKey||u.ctrlKey)&&u.key==="Enter"&&e&&!n&&r&&(u.preventDefault(),o())};return document.addEventListener("keydown",l),()=>document.removeEventListener("keydown",l)},[e,n,r,o]),e?d.jsxs("div",{className:"flex flex-col h-full",children:[d.jsx("div",{className:"flex-shrink-0 p-3 sm:p-6 pt-3 pb-4 pr-3",children:d.jsxs("div",{children:[d.jsxs("div",{className:"flex flex-row items-center justify-between mb-0 gap-2",children:[d.jsx("h3",{className:"text-base sm:text-lg font-semibold",children:e.name}),d.jsxs("div",{className:"flex gap-2 flex-shrink-0",children:[d.jsx(Le,{onClick:o,disabled:n||!r,size:"sm",className:"lg:size-default pr-1! gap-0",children:n?d.jsxs(d.Fragment,{children:[d.jsx(oi,{className:"mr-2"}),d.jsx("span",{className:"hidden sm:inline",children:"Executing..."})]}):d.jsxs(d.Fragment,{children:[d.jsx(KH,{className:"h-4 w-4 sm:mr-2"}),d.jsx("span",{className:"hidden sm:inline",children:"Execute"}),d.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:"⌘↵"})]})}),d.jsxs(Le,{variant:"outline",onClick:i,disabled:n,size:"sm",className:"lg:size-default gap-2",children:[d.jsx(QN,{className:"h-4 w-4"}),d.jsx("span",{className:"hidden sm:inline",children:"Save"})]})]})]}),e.description&&d.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 leading-relaxed mt-2",children:e.description})]})}),d.jsx("div",{className:"flex-1 overflow-y-auto px-3 sm:px-6 pb-4 pr-3",children:d.jsx(K_e,{selectedPrompt:e,promptArgs:t,onArgChange:a})})]}):d.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[d.jsx("p",{className:"text-gray-500 dark:text-gray-400 mb-2",children:"Select a prompt to get started"}),d.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 Y_e(e){switch(e){case"system":return"default";case"user":return"outline";case"assistant":return"secondary";default:return"outline"}}function Z_e(e){return e.charAt(0).toUpperCase()+e.slice(1)}function q_e(e){return typeof e=="string"?e:e.text?e.text:e.type==="resource"&&e.resource?.text?e.resource.text:e.type==="image"?`[Image: ${e.mimeType||"unknown type"}]`:JSON.stringify(e,null,2)}function X_e({message:e,index:t}){const[n,r]=b.useState(!1),a=async()=>{const i=q_e(e.content);await navigator.clipboard.writeText(i),r(!0),setTimeout(()=>r(!1),2e3)},o=()=>{const i=e.content;return typeof i=="string"?d.jsx(xy,{content:i}):i.type==="text"&&i.text?d.jsx(xy,{content:i.text}):i.type==="image"?d.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[d.jsxs("span",{className:"font-mono bg-muted px-2 py-1 rounded",children:["Image: ",i.mimeType||"unknown type"]}),i.data&&d.jsx("img",{src:`data:${i.mimeType};base64,${i.data}`,alt:"Prompt image",className:"max-w-full max-h-[300px] object-contain rounded-lg border border-border mt-2"})]}):i.type==="resource"&&i.resource?d.jsxs("div",{className:"space-y-2",children:[d.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[d.jsx("span",{className:"text-muted-foreground font-medium",children:"Resource:"}),d.jsx("code",{className:"bg-muted px-2 py-0.5 rounded text-xs font-mono",children:i.resource.uri})]}),i.resource.text&&d.jsx("div",{className:"mt-2",children:d.jsx(xy,{content:i.resource.text})})]}):d.jsx("pre",{className:"bg-muted p-3 rounded-lg text-sm overflow-x-auto",children:d.jsx("code",{children:JSON.stringify(i,null,2)})})};return d.jsxs("div",{className:"border border-border rounded-lg overflow-hidden bg-white dark:bg-zinc-900",children:[d.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-muted/30 border-b border-border",children:[d.jsx(Dr,{variant:Y_e(e.role),children:Z_e(e.role)}),d.jsx(Le,{variant:"ghost",size:"sm",onClick:a,className:"h-6 px-2",title:"Copy message content",children:n?d.jsx(Or,{className:"h-3.5 w-3.5"}):d.jsx(wr,{className:"h-3.5 w-3.5"})})]}),d.jsx("div",{className:"px-4 py-3",children:o()})]})}function J_e(e){const n=Date.now()-e,r=Math.floor(n/1e3),a=Math.floor(r/60),o=Math.floor(a/60),i=Math.floor(o/24);return r<10?"now":r<60?`${r}s ago`:a<60?`${a}m ago`:o<24?`${o}h ago`:`${i}d ago`}function Q_e(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 MF({results:e,copiedResult:t,previewMode:n=!0,onCopy:r,onDelete:a,onFullscreen:o,onTogglePreview:i,onMaximize:l,isMaximized:u=!1}){const[f,m]=b.useState(0),[h,g]=b.useState(""),[y,E]=b.useState(!0),x=e[0],w=x?e.filter(R=>R.promptName===x.promptName):[],S=w[f]||w[0],_=e.findIndex(R=>R===S);if(b.useEffect(()=>{w.length>0&&f>=w.length&&m(0)},[w.length,f]),b.useEffect(()=>{const R=()=>{S&&g(J_e(S.timestamp))};R();const k=setInterval(R,1e3);return()=>clearInterval(k)},[S]),e.length===0)return d.jsx("div",{className:"flex flex-col h-full bg-white dark:bg-black border-t dark:border-zinc-700",children:d.jsx("div",{className:"flex-1 overflow-y-auto h-full",children:d.jsx("div",{className:"flex items-center justify-center h-full",children:d.jsx("div",{className:"text-center",children:d.jsx(sf,{vertical:!0,noBorder:!0,message:"No Results yet"})})})})});const T=S.error||Q_e(S.result),A="messages"in S.result&&Array.isArray(S.result.messages);return d.jsx("div",{className:"flex flex-col h-full bg-white dark:bg-black border-t dark:border-zinc-700",children:d.jsx("div",{className:"flex-1 overflow-y-auto h-full",children:d.jsxs("div",{className:"space-y-0 flex-1 h-full flex flex-col",children:[d.jsxs("div",{className:"flex items-center gap-2 px-4 pt-2 border-b border-gray-200 dark:border-zinc-600 pb-2",children:[d.jsx("h3",{className:"text-sm font-medium hidden sm:block",children:"Response"}),S.duration!==void 0&&d.jsxs("div",{className:"hidden sm:flex items-center gap-1",children:[d.jsx(bm,{className:"h-3 w-3 text-gray-400"}),d.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:[S.duration,"ms"]})]}),A&&d.jsx("div",{className:"flex items-center gap-4 sm:ml-4",children:d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("button",{onClick:()=>E(!0),className:`text-xs font-medium ${y?"text-black dark:text-white":"text-zinc-500 dark:text-zinc-400"}`,children:"Formatted"}),d.jsx("span",{className:"text-xs text-zinc-400",children:"|"}),d.jsx("button",{onClick:()=>E(!1),className:`text-xs font-medium ${y?"text-zinc-500 dark:text-zinc-400":"text-black dark:text-white"}`,children:"Raw"})]})}),d.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[w.length>1&&d.jsxs("div",{className:"flex items-center gap-2 mr-2",children:[d.jsx(pm,{className:"h-3 w-3 text-gray-400"}),d.jsxs(Ys,{value:f.toString(),onValueChange:R=>m(parseInt(R)),children:[d.jsx(qs,{className:"h-7 w-[120px] text-xs",children:d.jsx(Zs,{})}),d.jsx(Xs,{children:w.map((R,k)=>d.jsx(fa,{value:k.toString(),children:k===0?"Latest":`${k+1} call ago`},k))})]})]}),d.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400 mr-2",children:h}),d.jsx(Le,{variant:"ghost",size:"sm",onClick:()=>r(_,S.result),className:"h-7 w-7 p-0",title:"Copy result",children:t===_?d.jsx(Or,{className:"h-4 w-4"}):d.jsx(wr,{className:"h-4 w-4"})}),a&&d.jsx(Le,{variant:"ghost",size:"sm",onClick:()=>a(_),className:"h-7 w-7 p-0",title:"Delete result",children:d.jsx(ti,{className:"h-4 w-4"})}),o&&d.jsx(Le,{variant:"ghost",size:"sm",onClick:()=>o(_),className:"h-7 w-7 p-0 sm:hidden",title:"Fullscreen",children:d.jsx(mm,{className:"h-4 w-4"})}),l&&d.jsx(Le,{variant:"ghost",size:"sm",onClick:l,className:"h-7 w-7 p-0 hidden sm:flex",title:u?"Restore":"Maximize",children:u?d.jsx(WH,{className:"h-4 w-4"}):d.jsx(mm,{className:"h-4 w-4"})})]})]}),d.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:T?d.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded p-3",children:[d.jsx("p",{className:"text-red-800 dark:text-red-300 font-medium",children:"Error:"}),d.jsx("p",{className:"text-red-700 dark:text-red-400 text-sm",children:T})]}):y&&A?d.jsx("div",{className:"space-y-3",children:S.result.messages.map((R,k)=>d.jsx(X_e,{message:R,index:k},k))}):d.jsx(yr,{data:S.result,filename:`prompt-result-${S.promptName}-${Date.now()}.json`})})]})})})}const jF="mcp-inspector-saved-prompts";function UW({ref:e,prompts:t,callPrompt:n,serverId:r,isConnected:a}){const[o,i]=b.useState(null),[l,u]=b.useState(null),{selectedPromptName:f,setSelectedPromptName:m}=kc(),[h,g]=b.useState({}),[y,E]=b.useState([]),[x,w]=b.useState(!1),[S,_]=b.useState(null),[T,A]=b.useState(""),[R,k]=b.useState("prompts"),[C,O]=b.useState([]),[M,L]=b.useState(!1),[$,H]=b.useState(""),[V,Z]=b.useState(!1),[ne,G]=b.useState(-1),Y=b.useRef(null),[F,re]=b.useState(!1),[ee,j]=b.useState("list"),[B,z]=b.useState(0),[D,P]=b.useState(!0),[W,K]=b.useState(!1),ae=b.useRef(null),oe=b.useRef(null),le=b.useRef(null),Q=b.useRef(null);b.useEffect(()=>{const _e=()=>{re(window.innerWidth<1024)};return _e(),window.addEventListener("resize",_e),()=>window.removeEventListener("resize",_e)},[]),b.useEffect(()=>{j(o?"detail":"list")},[o]),b.useEffect(()=>{F&&y.length>0&&!x&&j("response")},[y,x,F]),b.useImperativeHandle(e,()=>({focusSearch:()=>{Z(!0),setTimeout(()=>{Y.current&&Y.current.focus()},0)},blurSearch:()=>{A(""),Z(!1),Y.current&&Y.current.blur()}})),b.useEffect(()=>{try{const _e=localStorage.getItem(jF);if(_e){const Be=JSON.parse(_e);O(Be)}}catch(_e){console.error("[PromptsTab] Failed to load saved prompts:",_e)}},[]);const J=b.useCallback(_e=>{try{localStorage.setItem(jF,JSON.stringify(_e))}catch(Be){console.error("[PromptsTab] Failed to save prompts:",Be)}},[]);b.useEffect(()=>{V&&Y.current&&Y.current.focus()},[V]);const q=b.useCallback(()=>{T.trim()||Z(!1)},[T]),ie=b.useMemo(()=>{if(!T.trim())return t;const _e=T.toLowerCase();return t.filter(Be=>Be.name.toLowerCase().includes(_e)||Be.description?.toLowerCase().includes(_e))},[t,T]),he=b.useCallback(_e=>{i(_e);const Be={};_e.arguments&&_e.arguments.forEach(it=>{Be[it.name]=""}),g(Be)},[]),Ne=b.useCallback(_e=>{const Be=t.find(it=>it.name===_e.promptName);Be&&(i(Be),g(_e.args),u(_e))},[t]);b.useEffect(()=>{G(-1)},[T,R]),b.useEffect(()=>{const _e=Be=>{const it=Be.target;if(it.tagName==="INPUT"||it.tagName==="TEXTAREA"||it.contentEditable==="true"||Be.metaKey||Be.ctrlKey||Be.altKey)return;const lt=R==="prompts"?ie:C;if(Be.key==="ArrowDown")Be.preventDefault(),G(At=>{const Nn=At+1;return Nn>=lt.length?0:Nn});else if(Be.key==="ArrowUp")Be.preventDefault(),G(At=>{const Nn=At-1;return Nn<0?lt.length-1:Nn});else if(Be.key==="Enter"&&ne>=0)if(Be.preventDefault(),R==="prompts"){const At=ie[ne];At&&he(At)}else{const At=C[ne];At&&Ne(At)}};return document.addEventListener("keydown",_e),()=>document.removeEventListener("keydown",_e)},[ne,ie,C,R,he,Ne]),b.useEffect(()=>{if(ne>=0){const _e=R==="prompts"?`prompt-${ie[ne]?.name}`:`saved-prompt-${C[ne]?.id}`,Be=document.getElementById(_e);Be&&Be.scrollIntoView({behavior:"smooth",block:"nearest"})}},[ne,ie,C,R]),b.useEffect(()=>{if(console.warn("[PromptsTab] Auto-selection effect triggered:",{selectedPromptName:f,promptsCount:t.length,currentSelectedPrompt:o?.name}),f&&t.length>0){const _e=t.find(Be=>Be.name===f);if(console.warn("[PromptsTab] Prompt lookup result:",{selectedPromptName:f,promptFound:!!_e,promptName:_e?.name,shouldSelect:_e&&o?.name!==_e.name}),_e&&o?.name!==_e.name){console.warn("[PromptsTab] Selecting prompt:",_e.name),m(null);const Be=setTimeout(()=>{he(_e);const it=document.getElementById(`prompt-${_e.name}`);it&&(console.warn("[PromptsTab] Scrolling to prompt element"),it.scrollIntoView({behavior:"smooth",block:"nearest"}))},100);return()=>clearTimeout(Be)}}},[f,t,o,he,m]),b.useEffect(()=>{if(o){const _e=t.find(Be=>Be.name===o.name);_e&&_e!==o&&(JSON.stringify(_e.arguments)!==JSON.stringify(o.arguments)||_e.description!==o.description)&&i(_e)}},[t,o]);const Ye=b.useCallback((_e,Be)=>{g(it=>({...it,[_e]:Be}))},[]),Pe=b.useCallback(async()=>{if(!o||x)return;w(!0);const _e=Date.now();try{const Be=await n(o.name,h),it=Date.now()-_e;ra.getInstance().capture(new vU({promptName:o.name,serverId:r,success:!0})).catch(()=>{}),E(lt=>[{promptName:o.name,args:h,result:Be,timestamp:_e,duration:it},...lt])}catch(Be){ra.getInstance().capture(new vU({promptName:o.name,serverId:r,success:!1,error:Be instanceof Error?Be.message:"Unknown error"})).catch(()=>{});const qe={promptName:o.name,args:h,result:null,error:Be instanceof Error?Be.message:String(Be),timestamp:_e,duration:Date.now()-_e};E(lt=>[...lt,{...qe,result:{messages:[]}}])}finally{w(!1)}},[o,h,x,n,r]),Ue=b.useCallback(async(_e,Be)=>{try{await navigator.clipboard.writeText(JSON.stringify(Be,null,2)),_(_e),setTimeout(()=>_(null),2e3)}catch(it){console.error("[PromptsTab] Failed to copy result:",it)}},[]),st=b.useCallback(_e=>{E(Be=>Be.filter((it,qe)=>qe!==_e))},[]),Ve=b.useCallback(_e=>{if(F)j("response");else{const Be=y[_e];if(Be){const it=window.open("","_blank","width=800,height=600");if(it){const qe=Be.result;it.document.write(`
1754
1754
  <html>
1755
1755
  <head>
1756
1756
  <title>${Be.promptName} Result</title>
@@ -1780,4 +1780,4 @@ print(f"Available resources: {[resource.name for resource in resources]}")
1780
1780
  <pre>${JSON.stringify(We.result,null,2)}</pre>
1781
1781
  </body>
1782
1782
  </html>
1783
- `),fe.document.close())}},[E]),Nn=b.useCallback(()=>{K?(he.current&&he.current.expand(),Ne.current&&Ne.current.expand(),ae(!1)):(he.current&&he.current.collapse(),Ne.current&&Ne.current.collapse(),ae(!0))},[K]),ot=b.useCallback(()=>{i&&(ne(""),V(!0))},[i]),zn=b.useCallback(()=>{if(!i)return;const Ge={id:`${Date.now()}-${Math.random()}`,name:Z.trim()||`${i.name} - ${new Date().toLocaleString()}`,toolName:i.name,args:g,savedAt:Date.now(),serverId:i._serverId,serverName:i._serverName};st([...L,Ge]),ra.getInstance().capture(new Hce({toolName:i.name,serverId:a})).catch(()=>{}),V(!1),ne("")},[i,Z,g,L,st,a]),qt=b.useCallback(Ge=>{st(L.filter(We=>We.id!==Ge)),u?.id===Ge&&f(null)},[L,st,u]);return z?d.jsxs("div",{className:"h-full flex flex-col overflow-hidden relative bg-background",children:[P!=="list"&&d.jsxs("div",{className:"flex items-center gap-2 p-2 border-b shrink-0 bg-background z-10",children:[d.jsx(Le,{variant:"ghost",size:"sm",onClick:()=>{P==="response"?W("detail"):(l(null),W("list"))},className:"p-0 h-8 w-8",children:d.jsx(rw,{className:"h-4 w-4"})}),d.jsxs("div",{className:"flex items-center text-sm font-medium",children:[d.jsx("button",{onClick:()=>{l(null),W("list")},className:"text-muted-foreground hover:text-foreground hover:underline cursor-pointer",children:"Tools"}),P==="detail"&&d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"mx-2 text-muted-foreground",children:"/"}),d.jsx("button",{onClick:()=>{W("response")},className:P==="detail"?"text-foreground hover:underline":P==="response"?"text-muted-foreground hover:text-foreground hover:underline cursor-pointer":"text-muted-foreground",children:"Execute"})]}),P==="response"&&d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"mx-2 text-muted-foreground",children:"/"}),d.jsx("span",{className:"text-foreground",children:"Response"})]})]})]}),d.jsx("div",{className:"flex-1 relative overflow-hidden",children:d.jsxs(Aw,{initial:!1,mode:"popLayout",children:[P==="list"&&d.jsxs(Fa.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:[d.jsx(KF,{activeTab:O,isSearchExpanded:F,searchQuery:k,filteredToolsCount:Ve.length,savedRequestsCount:L.length,onSearchExpand:()=>re(!0),onSearchChange:C,onSearchBlur:Ee,onTabSwitch:()=>M(O==="tools"?"saved":"tools"),searchInputRef:B}),O==="tools"?d.jsx(WF,{tools:Ve,selectedTool:i,onToolSelect:ut,focusedIndex:ee}):d.jsx(zF,{savedRequests:L,selectedRequest:u,onLoadRequest:rt,onDeleteRequest:qt,focusedIndex:ee})]},"list"),P==="detail"&&d.jsx(Fa.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:d.jsx(HF,{selectedTool:i,toolArgs:g,isExecuting:w,isConnected:o,onArgChange:_e,onExecute:Be,onSave:ot})},"detail"),P==="response"&&d.jsx(Fa.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:d.jsx(GF,{results:lt,copiedResult:_,previewMode:G,serverId:a,readResource:r,onCopy:it,onDelete:qe,onFullscreen:At,onTogglePreview:()=>Y(!G)})},"response")]})}),d.jsx(FF,{isOpen:H,requestName:Z,defaultPlaceholder:`${i?.name} - ${new Date().toLocaleString()}`,onRequestNameChange:ne,onSave:zn,onCancel:()=>V(!1)})]}):d.jsxs(Ta,{direction:"horizontal",className:"h-full",children:[d.jsx(Yn,{ref:he,defaultSize:33,collapsible:!0,className:"flex flex-col h-full relative",children:d.jsxs(Ta,{direction:"vertical",className:"h-full border-r dark:border-zinc-700",children:[d.jsx(Yn,{defaultSize:75,minSize:30,children:d.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[d.jsx(KF,{activeTab:O,isSearchExpanded:F,searchQuery:k,filteredToolsCount:Ve.length,savedRequestsCount:L.length,onSearchExpand:()=>re(!0),onSearchChange:C,onSearchBlur:Ee,onTabSwitch:()=>M(O==="tools"?"saved":"tools"),searchInputRef:B}),O==="tools"?d.jsx(WF,{tools:Ve,selectedTool:i,onToolSelect:ut,focusedIndex:ee}):d.jsx(zF,{savedRequests:L,selectedRequest:u,onLoadRequest:rt,onDeleteRequest:qt,focusedIndex:ee})]})}),d.jsx(Ho,{withHandle:!0}),d.jsxs(Yn,{ref:Pe,defaultSize:0,collapsible:!0,minSize:5,collapsedSize:5,style:{minHeight:45},onCollapse:()=>{J(!0)},onExpand:()=>{J(!1)},className:"flex flex-col border-t dark:border-zinc-700",children:[d.jsxs("div",{className:"group flex items-center justify-between p-3 shrink-0 cursor-pointer hover:bg-muted/50 transition-colors",onClick:Ge=>{Ge.preventDefault(),Ge.stopPropagation(),Q?(Pe.current?.resize(25),J(!1)):(Pe.current?.resize(5),J(!0))},children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("h3",{className:"text-sm font-medium",children:"RPC Messages"}),oe>0&&d.jsx(Dr,{variant:"secondary",className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",children:oe}),oe>0&&!Q&&d.jsx(Le,{variant:"ghost",size:"sm",onClick:Ge=>{Ge.preventDefault(),Ge.stopPropagation(),Ue.current?.()},className:"h-6 w-6 p-0",title:"Clear all messages",children:d.jsx(ti,{className:"h-3.5 w-3.5"})})]}),d.jsx(hs,{className:`h-4 w-4 text-muted-foreground transition-transform ${Q?"":"rotate-180"}`})]}),d.jsx("div",{className:`flex-1 overflow-hidden min-h-0 ${Q?"hidden":""}`,children:d.jsx(ZO,{serverIds:[a],onCountChange:le,onClearRef:Ue})})]})]})}),d.jsx(Ho,{withHandle:!0}),d.jsx(Yn,{defaultSize:67,children:d.jsxs(Ta,{direction:"vertical",children:[d.jsx(Yn,{ref:Ne,defaultSize:40,collapsible:!0,children:d.jsx(HF,{selectedTool:i,toolArgs:g,isExecuting:w,isConnected:o,onArgChange:_e,onExecute:Be,onSave:ot,onCancel:()=>{A&&A.abort()}})}),d.jsx(Ho,{withHandle:!0}),d.jsx(Yn,{ref:Ye,defaultSize:60,children:d.jsx("div",{className:"flex flex-col h-full",children:d.jsx(GF,{results:lt,copiedResult:_,previewMode:G,serverId:a,readResource:r,onCopy:it,onDelete:qe,onFullscreen:At,onTogglePreview:()=>Y(!G),onMaximize:Nn,isMaximized:K})})})]})}),d.jsx(FF,{isOpen:H,requestName:Z,defaultPlaceholder:`${i?.name} - ${new Date().toLocaleString()}`,onRequestNameChange:ne,onSave:zn,onCancel:()=>V(!1)})]})}HW.displayName="ToolsTab";function lTe({isSearchExpanded:e,searchQuery:t,filteredRequestsCount:n,requestsCount:r,onSearchExpand:a,onSearchChange:o,onSearchBlur:i,onRejectAll:l,searchInputRef:u}){return d.jsxs("div",{className:"flex flex-row items-center justify-between p-4 sm:p-4 py-3 gap-2",children:[d.jsx("div",{className:"flex items-center gap-2 flex-1",children:e?d.jsx(Hn,{ref:u,placeholder:"Search requests...",value:t,onChange:f=>o(f.target.value),onBlur:i,className:"h-8 border-gray-300 dark:border-zinc-600"}):d.jsxs(d.Fragment,{children:[d.jsx("h2",{className:"text-lg font-medium text-gray-900 dark:text-gray-100",children:"Sampling"}),d.jsx(Dr,{className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",variant:"outline",children:n}),d.jsxs(Wt,{children:[d.jsx(Kt,{asChild:!0,children:d.jsx(Le,{variant:"ghost",size:"sm",onClick:a,className:"h-8 w-8 p-0",children:d.jsx(lf,{className:"h-4 w-4"})})}),d.jsxs(Yt,{side:"bottom",className:"flex gap-2",children:["Search",d.jsx(Sh,{children:"F"})]})]})]})}),d.jsx("div",{className:"flex items-center gap-2",children:d.jsxs(Wt,{children:[d.jsx(Kt,{asChild:!0,children:d.jsx(Le,{variant:"ghost",size:"sm",onClick:l,disabled:r===0,className:"h-8 w-8 p-0",children:d.jsx(ti,{className:"h-4 w-4"})})}),d.jsx(Yt,{side:"bottom",children:"Reject all"})]})})]})}function cTe({requests:e,selectedRequest:t,onRequestSelect:n,focusedIndex:r,formatRelativeTime:a,listRef:o}){return e.length===0?d.jsx("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:d.jsx(sf,{vertical:!0,noBorder:!0,message:"No sampling requests"})}):d.jsx("div",{ref:o,className:"overflow-y-auto flex-1 overscroll-contain",children:e.map((i,l)=>{const u=i.request.params?.messages?.length||0,f=i.request.params?.maxTokens;return d.jsx(El,{id:`sampling-request-${i.id}`,isSelected:t?.id===i.id,isFocused:r===l,title:d.jsxs("span",{className:"flex items-center gap-3",children:[i.serverName,d.jsx("span",{className:"size-1.5 block rounded-full bg-orange-500"})]}),description:(()=>{const m=a(i.timestamp),h=[];u>0&&h.push(`${u} message${u>1?"s":""}`),f&&h.push(`max ${f} tokens`);const g=h.length>0?` | ${h.join(", ")}`:"";return m+g})(),onClick:()=>n(i)},i.id)})})}function uTe({llmConfig:e}){const t=b.useRef(null);return{generateResponse:b.useCallback(async({request:r})=>{if(!e)throw new Error("LLM config is not available");const a=r.params||{},o=a.maxTokens,i=a.temperature;a.modelPreferences;const l=a.messages||[];if(console.log("[useSamplingLLM] Request structure:",{hasParams:!!a,messagesCount:l.length,messages:l,params:a}),l.length===0)throw new Error("No messages found in sampling request");const u=[],{HumanMessage:f,AIMessage:m}=await Ua(async()=>{const{HumanMessage:E,AIMessage:x}=await import("./index-VYwK-OPz.js").then(w=>w.bK);return{HumanMessage:E,AIMessage:x}},[]);for(const E of l){if(!E||!E.role){console.warn("Skipping invalid message:",E);continue}const x=Array.isArray(E.content)?E.content[0]:E.content;if(!x){console.warn("Skipping message with no content:",E);continue}x.type==="text"&&x.text?E.role==="user"?u.push(new f(x.text)):E.role==="assistant"&&u.push(new m(x.text)):console.warn("Skipping message with unsupported content type:",x)}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 E;const x={model:e.model,apiKey:e.apiKey};if(o!==void 0&&(x.maxTokens=o),i!==void 0?x.temperature=i:e.temperature!==void 0&&(x.temperature=e.temperature),e.provider==="openai"){const{ChatOpenAI:w}=await Ua(async()=>{const{ChatOpenAI:S}=await import("./index-CViqT8bM.js");return{ChatOpenAI:S}},__vite__mapDeps([0,1,2,3,4,5]));E=new w(x)}else if(e.provider==="anthropic"){const{ChatAnthropic:w}=await Ua(async()=>{const{ChatAnthropic:S}=await import("./index-B3BSS2WR.js");return{ChatAnthropic:S}},__vite__mapDeps([6,2,1,5]));E=new w(x)}else if(e.provider==="google"){const{ChatGoogleGenerativeAI:w}=await Ua(async()=>{const{ChatGoogleGenerativeAI:S}=await import("./index-oD85ijkM.js");return{ChatGoogleGenerativeAI:S}},__vite__mapDeps([7,2,1,4]));E=new w(x)}else throw new Error(`Unsupported LLM provider: ${e.provider}`);t.current={instance:E,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 dTe({request:e,onApprove:t,onReject:n,onClose:r,previewMode:a,onTogglePreview:o,isCopied:i,onCopy:l,onDownload:u,onFullscreen:f,llmConfig:m}){const[h,g]=b.useState("manual"),[y,E]=b.useState("stub-model"),[x,w]=b.useState("endTurn"),[S,_]=b.useState("assistant"),[T,A]=b.useState("text"),[R,k]=b.useState("positive"),[C,O]=b.useState(""),[M,L]=b.useState("image/png"),[$,H]=b.useState(!1),[V,Z]=b.useState(null),{generateResponse:ne,isAvailable:G}=uTe({llmConfig:m});b.useEffect(()=>{e&&(E("stub-model"),w("endTurn"),_("assistant"),A("text"),k("positive"),O(""),L("image/png"),Z(null))},[e?.id]);const Y=async()=>{if(!(!e||!G)){H(!0),Z(null);try{const j=await ne({request:e.request});E(j.model||m?.model||"stub-model"),w(j.stopReason||"endTurn"),_(j.role||"assistant");const B=Array.isArray(j.content)?j.content[0]:j.content;B.type==="text"?(A("text"),k(B.text||"")):B.type==="image"&&(A("image"),O(B.data||""),L(B.mimeType||"image/png"))}catch(j){const B=j instanceof Error?j.message:"Failed to generate response";Z(B),Nt.error("LLM Generation Failed",{description:B})}finally{H(!1)}}},F=b.useMemo(()=>{const j={model:y,stopReason:x,role:S,content:{type:T}};return T==="text"?j.content.text=R:T==="image"&&(j.content.data=C,j.content.mimeType=M),j},[y,x,S,T,R,C,M]),re=()=>{if(!e)return;const j=mN.safeParse(F);if(!j.success){Nt.error("Invalid response",{description:`Validation failed: ${j.error.message}`});return}t(e.id,j.data),r(),Ua(()=>Promise.resolve().then(()=>Ec),void 0).then(B=>{const z=Nt(B.createElement("div",{className:"space-y-3"},B.createElement("div",null,B.createElement("strong",null,"Sampling Response Sent"),B.createElement("p",{className:"text-sm text-muted-foreground mt-1"},"The tool will continue executing.")),B.createElement("div",{className:"flex gap-2"},B.createElement("button",{className:"px-3 py-1.5 text-xs font-medium rounded-md bg-primary text-primary-foreground hover:bg-primary/90",onClick:()=>{const D=new globalThis.CustomEvent("navigate-to-tool-result",{detail:{toolName:e.toolName}});window.dispatchEvent(D),Nt.dismiss(z)}},"View Tool Result"))),{duration:5e3})})},ee=()=>{e&&(n(e.id,"User rejected sampling request"),r())};return e?d.jsxs("div",{className:"flex flex-col h-full",children:[d.jsxs("div",{className:"flex items-center justify-between p-4 border-b dark:border-zinc-700",children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("h3",{className:"font-medium text-gray-900 dark:text-gray-100",children:e.serverName}),d.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:new Date(e.timestamp).toLocaleString()})]}),d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsxs(Wt,{children:[d.jsx(Kt,{asChild:!0,children:d.jsx(Le,{variant:"ghost",size:"sm",onClick:l,className:"h-8 w-8 p-0",children:i?d.jsx(Or,{className:"h-4 w-4 text-green-600"}):d.jsx(wr,{className:"h-4 w-4"})})}),d.jsx(Yt,{children:"Copy request"})]}),d.jsxs(Wt,{children:[d.jsx(Kt,{asChild:!0,children:d.jsx(Le,{variant:"ghost",size:"sm",onClick:u,className:"h-8 w-8 p-0",children:d.jsx(rh,{className:"h-4 w-4"})})}),d.jsx(Yt,{children:"Download request"})]}),d.jsxs(Wt,{children:[d.jsx(Kt,{asChild:!0,children:d.jsx(Le,{variant:"ghost",size:"sm",onClick:f,className:"h-8 w-8 p-0",children:d.jsx(JN,{className:"h-4 w-4"})})}),d.jsx(Yt,{children:"Fullscreen"})]}),d.jsx(Le,{variant:"ghost",size:"sm",onClick:r,className:"h-8 w-8 p-0",children:d.jsx(ys,{className:"h-4 w-4"})})]})]}),d.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-6",children:[d.jsxs("div",{className:"space-y-2",children:[d.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:"Request"}),d.jsx("div",{className:"bg-muted rounded-lg p-3 max-h-64 overflow-auto",children:d.jsx(yr,{data:e.request})})]}),d.jsxs("div",{className:"space-y-4",children:[d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:"Response"}),d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(wn,{htmlFor:`responseMode-${e.id}`,className:"text-xs text-gray-500 dark:text-gray-400",children:"Mode:"}),d.jsxs(Ys,{value:h,onValueChange:j=>g(j),children:[d.jsx(qs,{id:`responseMode-${e.id}`,className:"w-32 h-8 text-xs",children:d.jsx(Zs,{})}),d.jsxs(Xs,{children:[d.jsx(fa,{value:"manual",children:"Manual"}),d.jsx(fa,{value:"llm",children:"LLM"})]})]})]})]}),h==="llm"&&d.jsxs("div",{className:"space-y-2 p-3 bg-muted rounded-lg",children:[G?d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(Le,{onClick:Y,disabled:$,size:"sm",className:"flex items-center gap-2",children:$?d.jsxs(d.Fragment,{children:[d.jsx(cl,{className:"h-4 w-4 animate-spin"}),"Generating..."]}):d.jsxs(d.Fragment,{children:[d.jsx(hde,{className:"h-4 w-4"}),"Generate with LLM"]})}),d.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:["Using ",m?.provider," (",m?.model,")"]})]}):d.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:"LLM not configured. Please configure LLM in the Chat tab."}),V&&d.jsx("div",{className:"text-xs text-red-600 dark:text-red-400",children:V})]}),d.jsxs("div",{className:"space-y-2",children:[d.jsx(wn,{htmlFor:`model-${e.id}`,children:"Model"}),d.jsx(Hn,{id:`model-${e.id}`,value:y,onChange:j=>E(j.target.value),placeholder:"stub-model",disabled:h==="llm"&&$})]}),d.jsxs("div",{className:"space-y-2",children:[d.jsx(wn,{htmlFor:`stopReason-${e.id}`,children:"Stop Reason"}),d.jsx(Hn,{id:`stopReason-${e.id}`,value:x,onChange:j=>w(j.target.value),placeholder:"endTurn",disabled:h==="llm"&&$})]}),d.jsxs("div",{className:"space-y-2",children:[d.jsx(wn,{htmlFor:`role-${e.id}`,children:"Role"}),d.jsxs(Ys,{value:S,onValueChange:j=>_(j),disabled:h==="llm"&&$,children:[d.jsx(qs,{id:`role-${e.id}`,children:d.jsx(Zs,{})}),d.jsxs(Xs,{children:[d.jsx(fa,{value:"assistant",children:"assistant"}),d.jsx(fa,{value:"user",children:"user"})]})]})]}),d.jsxs("div",{className:"space-y-2",children:[d.jsx(wn,{htmlFor:`contentType-${e.id}`,children:"Content Type"}),d.jsxs(Ys,{value:T,onValueChange:j=>A(j),disabled:h==="llm"&&$,children:[d.jsx(qs,{id:`contentType-${e.id}`,children:d.jsx(Zs,{})}),d.jsxs(Xs,{children:[d.jsx(fa,{value:"text",children:"text"}),d.jsx(fa,{value:"image",children:"image"})]})]})]}),T==="text"&&d.jsxs("div",{className:"space-y-2",children:[d.jsx(wn,{htmlFor:`text-${e.id}`,children:"Text Content"}),d.jsx(bc,{id:`text-${e.id}`,value:R,onChange:j=>k(j.target.value),placeholder:"Enter response text...",rows:6,disabled:h==="llm"&&$})]}),T==="image"&&d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"space-y-2",children:[d.jsx(wn,{htmlFor:`imageData-${e.id}`,children:"Base64 Image Data"}),d.jsx(bc,{id:`imageData-${e.id}`,value:C,onChange:j=>O(j.target.value),placeholder:"Base64 encoded image data...",rows:4,disabled:h==="llm"&&$})]}),d.jsxs("div",{className:"space-y-2",children:[d.jsx(wn,{htmlFor:`mimeType-${e.id}`,children:"MIME Type"}),d.jsx(Hn,{id:`mimeType-${e.id}`,value:M,onChange:j=>L(j.target.value),placeholder:"image/png",disabled:h==="llm"&&$})]})]})]})]}),d.jsxs("div",{className:"flex gap-2 p-4 border-t dark:border-zinc-700",children:[d.jsx(Le,{onClick:re,className:"flex-1",disabled:h==="llm"&&$,children:"Approve"}),d.jsx(Le,{onClick:ee,variant:"outline",className:"flex-1",disabled:h==="llm"&&$,children:"Reject"})]})]}):d.jsx("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:d.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"Select a sampling request to view details"})})}const fTe={model:"stub-model",stopReason:"endTurn",role:"assistant",content:{type:"text",text:"positive"}};function pTe({requestId:e,serverName:t,onViewDetails:n,onApprove:r,onDeny:a}){return d.jsxs("div",{className:"space-y-3",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"Sampling Request Received"}),d.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:["New request from ",t]})]}),d.jsxs("div",{className:"flex gap-2",children:[d.jsx("button",{className:"px-3 py-1.5 text-xs font-medium rounded-md hover:bg-accent hover:text-accent-foreground",onClick:o=>{o.stopPropagation(),n()},children:"View Details"}),d.jsx("button",{className:"px-3 py-1.5 text-xs font-medium rounded-md hover:bg-accent hover:text-accent-foreground",onClick:o=>{o.stopPropagation(),r(fTe)},children:"Approve"}),d.jsx("button",{className:"px-3 py-1.5 text-xs font-medium rounded-md hover:bg-accent hover:text-accent-foreground",onClick:o=>{o.stopPropagation(),a()},children:"Deny"})]})]})}function mTe({pendingRequests:e,onApprove:t,onReject:n,serverId:r,isConnected:a,mcpServerUrl:o}){const{selectedSamplingRequestId:i,setSelectedSamplingRequestId:l}=kc(),{llmConfig:u}=gW({mcpServerUrl:o}),[f,m]=b.useState(null),[h,g]=b.useState(""),[y,E]=b.useState(-1),[x,w]=b.useState(!0),[S,_]=b.useState(!1),[T,A]=b.useState(!0),[R,k]=b.useState(!1),C=b.useRef(null),O=b.useRef(null),M=b.useRef(null),L=b.useRef(!1);b.useEffect(()=>{if(console.log("[SamplingTab] Auto-selection check:",{selectedSamplingRequestId:i,pendingRequestsCount:e.length,currentSelectedId:f?.id}),i&&e.length>0){const F=e.find(re=>re.id===i);console.log("[SamplingTab] Found request for auto-selection:",!!F,F?.id),F&&(console.log("[SamplingTab] Auto-selecting request:",F.id),l(null),m(F),setTimeout(()=>{const re=document.getElementById(`sampling-request-${F.id}`);console.log("[SamplingTab] Scrolling to element:",!!re),re&&re.scrollIntoView({behavior:"smooth",block:"nearest"})},100))}},[i,e,l]),b.useEffect(()=>{const F=re=>{const j=re.detail.requestId;console.log("[SamplingTab] Custom navigate event received:",j);const B=e.find(z=>z.id===j);B&&(console.log("[SamplingTab] Selecting request from event:",j),m(B),setTimeout(()=>{const z=document.getElementById(`sampling-request-${j}`);z&&z.scrollIntoView({behavior:"smooth",block:"nearest"})},200))};return window.addEventListener("navigate-to-sampling",F),()=>window.removeEventListener("navigate-to-sampling",F)},[e]),b.useEffect(()=>{x&&e.length>0&&C.current&&!L.current&&(C.current.scrollTop=0)},[e.length,x]),b.useEffect(()=>{const F=C.current;if(!F)return;const re=()=>{F.scrollTop>0&&(L.current=!0,w(!1))};return F.addEventListener("scroll",re),()=>F.removeEventListener("scroll",re)},[]),b.useEffect(()=>{e.length===0&&(L.current=!1,w(!0))},[e.length]),b.useEffect(()=>{S&&M.current&&M.current.focus()},[S]);const $=b.useCallback(()=>{h.trim()||_(!1)},[h]),H=b.useMemo(()=>{if(!h.trim())return e;const F=h.toLowerCase();return e.filter(re=>re.serverName.toLowerCase().includes(F)||JSON.stringify(re.request||{}).toLowerCase().includes(F))},[e,h]);b.useEffect(()=>{E(-1)},[h]),b.useEffect(()=>{const F=re=>{const ee=re.target;if(ee.tagName==="INPUT"||ee.tagName==="TEXTAREA"||ee.contentEditable==="true"||re.metaKey||re.ctrlKey||re.altKey)return;const B=H;if(re.key==="ArrowDown")re.preventDefault(),E(z=>{const D=z+1;return D>=B.length?0:D});else if(re.key==="ArrowUp")re.preventDefault(),E(z=>{const D=z-1;return D<0?B.length-1:D});else if(re.key==="Enter"&&y>=0){re.preventDefault();const z=H[y];z&&V(z)}};return document.addEventListener("keydown",F),()=>document.removeEventListener("keydown",F)},[y,H]),b.useEffect(()=>{if(y>=0){const F=`sampling-request-${H[y]?.id}`,re=document.getElementById(F);re&&re.scrollIntoView({behavior:"smooth",block:"nearest"})}},[y,H]);const V=b.useCallback(F=>{m(F)},[]),Z=b.useCallback(()=>{window.confirm("Are you sure you want to reject all sampling requests? This cannot be undone.")&&(e.forEach(F=>{n(F.id,"User rejected all requests")}),m(null))},[e,n]),ne=b.useCallback(async()=>{if(f)try{await navigator.clipboard.writeText(JSON.stringify({id:f.id,serverName:f.serverName,timestamp:f.timestamp,request:f.request},null,2)),k(!0),setTimeout(()=>k(!1),2e3)}catch(F){console.error("[SamplingTab] Failed to copy request:",F)}},[f]),G=b.useCallback(()=>{if(f)try{const F=new globalThis.Blob([JSON.stringify({id:f.id,serverName:f.serverName,timestamp:f.timestamp,request:f.request},null,2)],{type:"application/json"}),re=URL.createObjectURL(F),ee=document.createElement("a");ee.href=re,ee.download=`sampling-request-${Date.now()}.json`,document.body.appendChild(ee),ee.click(),document.body.removeChild(ee),URL.revokeObjectURL(re)}catch(F){console.error("[SamplingTab] Failed to download request:",F)}},[f]),Y=b.useCallback(async()=>{if(O.current)try{document.fullscreenElement?await document.exitFullscreen():await O.current.requestFullscreen()}catch(F){console.error("[SamplingTab] Failed to toggle fullscreen:",F)}},[]);return a?d.jsxs(Ta,{direction:"horizontal",className:"h-full",children:[d.jsx(Yn,{defaultSize:40,minSize:30,children:d.jsx(Ta,{direction:"vertical",className:"h-full border-r dark:border-zinc-700",children:d.jsxs(Yn,{defaultSize:75,minSize:30,children:[d.jsx(lTe,{isSearchExpanded:S,searchQuery:h,filteredRequestsCount:H.length,requestsCount:e.length,onSearchExpand:()=>_(!0),onSearchChange:g,onSearchBlur:$,onRejectAll:Z,searchInputRef:M}),d.jsx("div",{className:"flex flex-col h-full",children:d.jsx(cTe,{requests:H,selectedRequest:f,onRequestSelect:V,focusedIndex:y,formatRelativeTime:_v,listRef:C})})]})})}),d.jsx(Ho,{}),d.jsx(Yn,{defaultSize:60,minSize:40,children:d.jsx("div",{ref:O,className:"h-full bg-white dark:bg-zinc-900",children:d.jsx(dTe,{request:f,onApprove:t,onReject:n,onClose:()=>m(null),previewMode:T,onTogglePreview:()=>A(!T),isCopied:R,onCopy:ne,onDownload:G,onFullscreen:Y,llmConfig:u})})})]}):d.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[d.jsx(VH,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),d.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"Not connected to server"})]})}function hTe({isSearchExpanded:e,searchQuery:t,filteredRequestsCount:n,requestsCount:r,onSearchExpand:a,onSearchChange:o,onSearchBlur:i,onCancelAll:l,searchInputRef:u}){return d.jsxs("div",{className:"flex flex-row items-center justify-between p-4 sm:p-4 py-3 gap-2",children:[d.jsx("div",{className:"flex items-center gap-2 flex-1",children:e?d.jsx(Hn,{ref:u,placeholder:"Search requests...",value:t,onChange:f=>o(f.target.value),onBlur:i,className:"h-8 border-gray-300 dark:border-zinc-600"}):d.jsxs(d.Fragment,{children:[d.jsx("h2",{className:"text-lg font-medium text-gray-900 dark:text-gray-100",children:"Elicitation"}),d.jsx(Dr,{className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",variant:"outline",children:n}),d.jsxs(Wt,{children:[d.jsx(Kt,{asChild:!0,children:d.jsx(Le,{variant:"ghost",size:"sm",onClick:a,className:"h-8 w-8 p-0",children:d.jsx(lf,{className:"h-4 w-4"})})}),d.jsxs(Yt,{side:"bottom",className:"flex gap-2",children:["Search",d.jsx(Sh,{children:"F"})]})]})]})}),d.jsx("div",{className:"flex items-center gap-2",children:d.jsxs(Wt,{children:[d.jsx(Kt,{asChild:!0,children:d.jsx(Le,{variant:"ghost",size:"sm",onClick:l,disabled:r===0,className:"h-8 w-8 p-0",children:d.jsx(ys,{className:"h-4 w-4"})})}),d.jsx(Yt,{side:"bottom",children:"Cancel all"})]})})]})}function gTe({requests:e,selectedRequest:t,onRequestSelect:n,focusedIndex:r,formatRelativeTime:a,listRef:o}){return e.length===0?d.jsx("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:d.jsx(sf,{vertical:!0,noBorder:!0,message:"No elicitation requests"})}):d.jsx("div",{ref:o,className:"overflow-y-auto flex-1 overscroll-contain",children:e.map((i,l)=>{const u=i.request.mode||"form",f=u==="form"&&"requestedSchema"in i.request&&i.request.requestedSchema;return d.jsx(El,{id:`elicitation-request-${i.id}`,isSelected:t?.id===i.id,isFocused:r===l,title:d.jsxs("span",{className:"flex items-center gap-3",children:[i.serverName,d.jsx(Dr,{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=a(i.timestamp),h=[];f&&h.push("with schema"),u==="url"&&h.push("external action");const g=h.length>0?` | ${h.join(", ")}`:"";return m+g})(),onClick:()=>n(i)},i.id)})})}function bTe({request:e,onApprove:t,onReject:n,onClose:r,previewMode:a,onTogglePreview:o,isCopied:i,onCopy:l,onDownload:u,onFullscreen:f}){const[m,h]=b.useState({}),[g,y]=b.useState(!1),E=e?.request.mode||"form",x=E==="form",w=E==="url";b.useEffect(()=>{if(e&&x&&"requestedSchema"in e.request){const C=e.request.requestedSchema,O={};if(C?.type==="object"&&C.properties)for(const[M,L]of Object.entries(C.properties)){const $=L;$.default!==void 0?O[M]=$.default:$.type==="boolean"?O[M]=!1:$.type==="number"||$.type==="integer"?O[M]=0:O[M]=""}h(O)}y(!1)},[e?.id,x]);const S=(C,O)=>{h(M=>({...M,[C]:O}))},_=()=>{if(e){if(x){if("requestedSchema"in e.request){const C=e.request.requestedSchema;if(C?.required){const O=C.required.filter(M=>m[M]===void 0||m[M]===""||m[M]===null);if(O.length>0){Nt.error("Missing required fields",{description:`Please fill in: ${O.join(", ")}`});return}}}t(e.id,{action:"accept",data:m})}else w&&t(e.id,{action:"accept"});r(),Ua(()=>Promise.resolve().then(()=>Ec),void 0).then(C=>{const O=Nt(C.createElement("div",{className:"space-y-3"},C.createElement("div",null,C.createElement("strong",null,"Elicitation Response Sent"),C.createElement("p",{className:"text-sm text-muted-foreground mt-1"},"The tool will continue executing.")),C.createElement("div",{className:"flex gap-2"},C.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),Nt.dismiss(O)}},"View Tool Result"))),{duration:5e3})})}},T=()=>{e&&(t(e.id,{action:"decline"}),r())},A=()=>{e&&(n(e.id,"User cancelled elicitation request"),r())},R=()=>{e&&w&&"url"in e.request&&(window.open(e.request.url,"_blank"),y(!0))},k=b.useMemo(()=>{if(!e||!x||!("requestedSchema"in e.request))return null;const C=e.request.requestedSchema;if(!C||C.type!=="object"||!C.properties)return d.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:"No form schema available"});const O=C.properties,M=C.required||[];return d.jsx("div",{className:"space-y-4",children:Object.entries(O).map(([L,$])=>{const H=$,V=M.includes(L),Z=H.type||"string",ne=H.title||L,G=H.description;return d.jsxs("div",{className:"space-y-2",children:[d.jsxs(wn,{htmlFor:`field-${L}`,children:[ne,V&&d.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),G&&d.jsx("p",{className:"text-xs text-muted-foreground",children:G}),Z==="boolean"?d.jsxs("div",{className:"flex items-center space-x-2",children:[d.jsx(Pm,{id:`field-${L}`,checked:m[L]||!1,onCheckedChange:Y=>S(L,Y)}),d.jsx(wn,{htmlFor:`field-${L}`,className:"text-sm font-normal cursor-pointer",children:H.title||L})]}):Z==="number"||Z==="integer"?d.jsx(Hn,{id:`field-${L}`,type:"number",value:m[L]||"",onChange:Y=>S(L,Z==="integer"?parseInt(Y.target.value,10):parseFloat(Y.target.value)),placeholder:H.default?.toString()||""}):H.enum?d.jsxs("select",{id:`field-${L}`,value:m[L]||"",onChange:Y=>S(L,Y.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:[d.jsx("option",{value:"",children:"Select..."}),H.enum.map(Y=>d.jsx("option",{value:Y,children:Y},Y))]}):Z==="string"&&(H.format==="textarea"||H.maxLength>100)?d.jsx(bc,{id:`field-${L}`,value:m[L]||"",onChange:Y=>S(L,Y.target.value),placeholder:H.default||"",rows:4}):d.jsx(Hn,{id:`field-${L}`,type:"text",value:m[L]||"",onChange:Y=>S(L,Y.target.value),placeholder:H.default||""})]},L)})})},[e,m,x]);return e?d.jsxs("div",{className:"flex flex-col h-full",children:[d.jsxs("div",{className:"flex items-center justify-between p-4 border-b dark:border-zinc-700",children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("h3",{className:"font-medium text-gray-900 dark:text-gray-100",children:e.serverName}),d.jsx(Dr,{variant:"outline",className:w?"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:E}),d.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:new Date(e.timestamp).toLocaleString()})]}),d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsxs(Wt,{children:[d.jsx(Kt,{asChild:!0,children:d.jsx(Le,{variant:"ghost",size:"sm",onClick:l,className:"h-8 w-8 p-0",children:i?d.jsx(Or,{className:"h-4 w-4 text-green-600"}):d.jsx(wr,{className:"h-4 w-4"})})}),d.jsx(Yt,{children:"Copy request"})]}),d.jsxs(Wt,{children:[d.jsx(Kt,{asChild:!0,children:d.jsx(Le,{variant:"ghost",size:"sm",onClick:u,className:"h-8 w-8 p-0",children:d.jsx(rh,{className:"h-4 w-4"})})}),d.jsx(Yt,{children:"Download request"})]}),d.jsxs(Wt,{children:[d.jsx(Kt,{asChild:!0,children:d.jsx(Le,{variant:"ghost",size:"sm",onClick:f,className:"h-8 w-8 p-0",children:d.jsx(JN,{className:"h-4 w-4"})})}),d.jsx(Yt,{children:"Fullscreen"})]}),d.jsx(Le,{variant:"ghost",size:"sm",onClick:r,className:"h-8 w-8 p-0",children:d.jsx(ys,{className:"h-4 w-4"})})]})]}),d.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-6",children:[d.jsxs("div",{className:"space-y-2",children:[d.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:"Message"}),d.jsx("p",{className:"text-sm text-gray-700 dark:text-gray-300",children:e.request.message})]}),w&&"url"in e.request&&d.jsxs("div",{className:"space-y-2",children:[d.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:"External Action Required"}),d.jsxs("div",{className:"bg-muted rounded-lg p-4 space-y-3",children:[d.jsx("p",{className:"text-sm text-muted-foreground",children:"This request requires you to complete an action at an external URL:"}),d.jsxs("div",{className:"flex items-center gap-2 p-2 bg-background rounded border",children:[d.jsx("code",{className:"flex-1 text-xs font-mono break-all",children:e.request.url}),d.jsxs(Le,{size:"sm",variant:"outline",onClick:R,className:"flex items-center gap-2",children:[d.jsx(f_,{className:"h-4 w-4"}),"Open URL"]})]}),d.jsxs("div",{className:"flex items-center space-x-2 pt-2",children:[d.jsx(Pm,{id:"url-completed",checked:g,onCheckedChange:C=>y(!!C)}),d.jsx(wn,{htmlFor:"url-completed",className:"text-sm font-normal cursor-pointer",children:"I have completed the required action"})]})]})]}),x&&d.jsxs("div",{className:"space-y-2",children:[d.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:"Form Data"}),k]}),x&&"requestedSchema"in e.request&&e.request.requestedSchema&&d.jsxs("details",{className:"space-y-2",children:[d.jsx("summary",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100 cursor-pointer",children:"Schema (for reference)"}),d.jsx("div",{className:"bg-muted rounded-lg p-3 max-h-64 overflow-auto",children:d.jsx(yr,{data:e.request.requestedSchema})})]})]}),d.jsxs("div",{className:"flex gap-2 p-4 border-t dark:border-zinc-700",children:[d.jsx(Le,{onClick:_,className:"flex-1",children:"Accept"}),d.jsx(Le,{onClick:T,variant:"outline",className:"flex-1",children:"Decline"}),d.jsx(Le,{onClick:A,variant:"outline",className:"flex-1",children:"Cancel"})]})]}):d.jsx("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:d.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"Select an elicitation request to view details"})})}function yTe({pendingRequests:e=[],onApprove:t,onReject:n,serverId:r,isConnected:a}){const{selectedElicitationRequestId:o,setSelectedElicitationRequestId:i}=kc(),[l,u]=b.useState(null),[f,m]=b.useState(""),[h,g]=b.useState(-1),[y,E]=b.useState(!0),[x,w]=b.useState(!1),[S,_]=b.useState(!0),[T,A]=b.useState(!1),R=b.useRef(null),k=b.useRef(null),C=b.useRef(null),O=b.useRef(!1);b.useEffect(()=>{if(console.log("[ElicitationTab] Auto-selection check:",{selectedElicitationRequestId:o,pendingRequestsCount:e.length,currentSelectedId:l?.id}),o&&e.length>0){const G=e.find(Y=>Y.id===o);console.log("[ElicitationTab] Found request for auto-selection:",!!G,G?.id),G&&(console.log("[ElicitationTab] Auto-selecting request:",G.id),i(null),u(G),setTimeout(()=>{const Y=document.getElementById(`elicitation-request-${G.id}`);console.log("[ElicitationTab] Scrolling to element:",!!Y),Y&&Y.scrollIntoView({behavior:"smooth",block:"nearest"})},100))}},[o,e,i]),b.useEffect(()=>{const G=Y=>{const re=Y.detail.requestId;console.log("[ElicitationTab] Custom navigate event received:",re);const ee=e.find(j=>j.id===re);ee&&(console.log("[ElicitationTab] Selecting request from event:",re),u(ee),setTimeout(()=>{const j=document.getElementById(`elicitation-request-${re}`);j&&j.scrollIntoView({behavior:"smooth",block:"nearest"})},200))};return window.addEventListener("navigate-to-elicitation",G),()=>window.removeEventListener("navigate-to-elicitation",G)},[e]),b.useEffect(()=>{y&&e.length>0&&R.current&&!O.current&&(R.current.scrollTop=0)},[e.length,y]),b.useEffect(()=>{const G=R.current;if(!G)return;const Y=()=>{G.scrollTop>0&&(O.current=!0,E(!1))};return G.addEventListener("scroll",Y),()=>G.removeEventListener("scroll",Y)},[]),b.useEffect(()=>{e.length===0&&(O.current=!1,E(!0))},[e.length]),b.useEffect(()=>{x&&C.current&&C.current.focus()},[x]);const M=b.useCallback(()=>{f.trim()||w(!1)},[f]),L=b.useMemo(()=>{if(!f.trim())return e;const G=f.toLowerCase();return e.filter(Y=>Y.serverName.toLowerCase().includes(G)||Y.request.message.toLowerCase().includes(G)||JSON.stringify(Y.request||{}).toLowerCase().includes(G))},[e,f]);b.useEffect(()=>{g(-1)},[f]),b.useEffect(()=>{const G=Y=>{const F=Y.target;if(F.tagName==="INPUT"||F.tagName==="TEXTAREA"||F.contentEditable==="true"||Y.metaKey||Y.ctrlKey||Y.altKey)return;const ee=L;if(Y.key==="ArrowDown")Y.preventDefault(),g(j=>{const B=j+1;return B>=ee.length?0:B});else if(Y.key==="ArrowUp")Y.preventDefault(),g(j=>{const B=j-1;return B<0?ee.length-1:B});else if(Y.key==="Enter"&&h>=0){Y.preventDefault();const j=L[h];j&&$(j)}};return document.addEventListener("keydown",G),()=>document.removeEventListener("keydown",G)},[h,L]),b.useEffect(()=>{if(h>=0){const G=`elicitation-request-${L[h]?.id}`,Y=document.getElementById(G);Y&&Y.scrollIntoView({behavior:"smooth",block:"nearest"})}},[h,L]);const $=b.useCallback(G=>{u(G)},[]),H=b.useCallback(()=>{window.confirm("Are you sure you want to cancel all elicitation requests? This cannot be undone.")&&(e.forEach(G=>{n(G.id,"User cancelled all requests")}),u(null))},[e,n]),V=b.useCallback(async()=>{if(l)try{await navigator.clipboard.writeText(JSON.stringify({id:l.id,serverName:l.serverName,timestamp:l.timestamp,request:l.request},null,2)),A(!0),setTimeout(()=>A(!1),2e3)}catch(G){console.error("[ElicitationTab] Failed to copy request:",G)}},[l]),Z=b.useCallback(()=>{if(l)try{const G=new globalThis.Blob([JSON.stringify({id:l.id,serverName:l.serverName,timestamp:l.timestamp,request:l.request},null,2)],{type:"application/json"}),Y=URL.createObjectURL(G),F=document.createElement("a");F.href=Y,F.download=`elicitation-request-${Date.now()}.json`,document.body.appendChild(F),F.click(),document.body.removeChild(F),URL.revokeObjectURL(Y)}catch(G){console.error("[ElicitationTab] Failed to download request:",G)}},[l]),ne=b.useCallback(async()=>{if(k.current)try{document.fullscreenElement?await document.exitFullscreen():await k.current.requestFullscreen()}catch(G){console.error("[ElicitationTab] Failed to toggle fullscreen:",G)}},[]);return a?d.jsxs(Ta,{direction:"horizontal",className:"h-full",children:[d.jsx(Yn,{defaultSize:40,minSize:30,children:d.jsx(Ta,{direction:"vertical",className:"h-full border-r dark:border-zinc-700",children:d.jsxs(Yn,{defaultSize:75,minSize:30,children:[d.jsx(hTe,{isSearchExpanded:x,searchQuery:f,filteredRequestsCount:L.length,requestsCount:e.length,onSearchExpand:()=>w(!0),onSearchChange:m,onSearchBlur:M,onCancelAll:H,searchInputRef:C}),d.jsx("div",{className:"flex flex-col h-full",children:d.jsx(gTe,{requests:L,selectedRequest:l,onRequestSelect:$,focusedIndex:h,formatRelativeTime:_v,listRef:R})})]})})}),d.jsx(Ho,{}),d.jsx(Yn,{defaultSize:60,minSize:40,children:d.jsx("div",{ref:k,className:"h-full bg-white dark:bg-zinc-900",children:d.jsx(bTe,{request:l,onApprove:t,onReject:n,onClose:()=>u(null),previewMode:S,onTogglePreview:()=>_(!S),isCopied:T,onCopy:V,onDownload:Z,onFullscreen:ne})})})]}):d.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[d.jsx(ZH,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),d.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"Not connected to server"})]})}function vTe({selectedServer:e,activeTab:t,toolsSearchRef:n,promptsSearchRef:r,resourcesSearchRef:a,children:o}){return e?d.jsxs(d.Fragment,{children:[d.jsx("div",{style:{display:t==="tools"?"block":"none"},className:"h-full",children:d.jsx(HW,{ref:n,tools:e.tools,callTool:e.callTool,readResource:e.readResource,serverId:e.id,isConnected:e.state==="ready"})}),d.jsx("div",{style:{display:t==="prompts"?"block":"none"},className:"h-full",children:d.jsx(UW,{ref:r,prompts:e.prompts,callPrompt:e.getPrompt,serverId:e.id,isConnected:e.state==="ready"})}),d.jsx("div",{style:{display:t==="resources"?"block":"none"},className:"h-full",children:d.jsx(FW,{ref:a,resources:e.resources,readResource:e.readResource,serverId:e.id,isConnected:e.state==="ready"})}),d.jsx("div",{style:{display:t==="chat"?"block":"none"},className:"h-full",children:d.jsx(m_e,{connection:e,isConnected:e.state==="ready",readResource:e.readResource},e.id)}),d.jsx("div",{style:{display:t==="sampling"?"block":"none"},className:"h-full",children:d.jsx(mTe,{pendingRequests:e.pendingSamplingRequests,onApprove:e.approveSampling,onReject:e.rejectSampling,serverId:e.id,isConnected:e.state==="ready",mcpServerUrl:e.url})}),d.jsx("div",{style:{display:t==="elicitation"?"block":"none"},className:"h-full",children:d.jsx(yTe,{pendingRequests:e.pendingElicitationRequests,onApprove:e.approveElicitation,onReject:e.rejectElicitation,serverId:e.id,isConnected:e.state==="ready"})}),d.jsx("div",{style:{display:t==="notifications"?"block":"none"},className:"h-full",children:d.jsx(W_e,{notifications:e.notifications,unreadCount:e.unreadNotificationCount,markNotificationRead:e.markNotificationRead,markAllNotificationsRead:e.markAllNotificationsRead,clearNotifications:e.clearNotifications,serverId:e.id,isConnected:e.state==="ready"})}),t!=="tools"&&t!=="prompts"&&t!=="resources"&&t!=="chat"&&t!=="sampling"&&t!=="elicitation"&&t!=="notifications"&&d.jsx(d.Fragment,{children:o})]}):d.jsx(d.Fragment,{children:o})}function ZF({className:e}){return d.jsxs("svg",{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",className:e,children:[d.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"}),d.jsx("path",{d:"M9 18c-4.51 2-5-2-7-2"})]})}const VW=b.createContext(void 0);function GW(){const e=b.use(VW);if(!e)throw new Error("useTabs must be used within a TabsProvider");return e}const WW=b.createContext(void 0);function wTe(){return b.use(WW)}function zT({ref:e,children:t,defaultValue:n,value:r,onValueChange:a,className:o,collapsed:i,onCollapsedChange:l,...u}){const[f,m]=b.useState(n||""),h=r!==void 0,g=i!==void 0,[y,E]=b.useState(!1),x=b.useCallback(T=>{h||m(T),a?.(T)},[h,a]),w=h?r:f,S=g?i:y,_=b.useCallback(T=>{g||E(T),l?.(T)},[g,l]);return d.jsx(VW,{value:{activeValue:w,handleValueChange:x,collapsed:S,handleCollapsedChange:_},children:d.jsx("div",{ref:e,className:Fe("flex flex-col gap-2",o),...u,children:t})})}zT.displayName="Tabs";function FT({ref:e,children:t,className:n,variant:r="default",collapsible:a=!1,...o}){const{activeValue:i,collapsed:l,handleCollapsedChange:u}=GW(),[f,m]=b.useState({width:0,left:0}),h=b.useRef(null),g=b.useRef(null),y=b.useRef(null),E=b.useCallback(()=>{const S=h.current;if(!S)return;const _=S.querySelector("div:first-child");if(!_)return;const T=_.querySelector(`button[data-tab-value="${i}"]`);if(T&&i){const A=_.getBoundingClientRect(),R=T.getBoundingClientRect();m({width:R.width,left:R.left-A.left})}else m({width:0,left:0})},[i]),x=b.useCallback(()=>{y.current&&clearTimeout(y.current),y.current=setTimeout(E,16)},[E]);b.useEffect(()=>{const S=setTimeout(E,10);return()=>clearTimeout(S)},[E,l]),b.useEffect(()=>{const S=h.current;if(!S)return;g.current=new ResizeObserver(()=>{x()}),g.current.observe(S);const _=S.querySelector("div:first-child");return _&&_.querySelectorAll("button[data-tab-value]").forEach(A=>{g.current&&g.current.observe(A)}),()=>{g.current&&g.current.disconnect(),y.current&&clearTimeout(y.current)}},[x]),b.useEffect(()=>{const S=()=>{x()};return window.addEventListener("resize",S),()=>window.removeEventListener("resize",S)},[x]);const w=b.useRef(null);return b.useEffect(()=>{w.current&&(w.current.style.width=`${f.width}px`,w.current.style.left=`${f.left}px`)},[f]),d.jsx(WW,{value:{variant:r,collapsed:l,handleCollapsedChange:u},children:d.jsx("div",{ref:h,className:Fe("relative flex items-center bg-none gap-1",r==="default"&&"p-1 rounded-full border border-zinc-300 dark:border-zinc-600",r==="underline"&&"border-b border-zinc-200 dark:border-zinc-700",n),...o,children:d.jsxs("div",{role:"tablist",className:"flex-1 flex items-center relative",children:[t,d.jsx("span",{ref:w,className:Fe("absolute transition-all duration-500 ease-in-out z-0",r==="default"&&"bg-white dark:bg-zinc-700 rounded-full h-[calc(100%)] top-0 border border-zinc-300 dark:border-zinc-600",r==="underline"&&"bottom-0 h-0.5 bg-black dark:bg-white")})]})})})}FT.displayName="TabsList";const xTe=({children:e,title:t,collapsed:n})=>!t||!n?e:d.jsx(YN,{children:d.jsxs(Wt,{children:[d.jsx(Kt,{children:e}),d.jsx(Yt,{children:t})]})}),BT=b.forwardRef(({children:e,value:t,className:n,disabled:r,icon:a,title:o,showDot:i=!1,...l},u)=>{const{activeValue:f,handleValueChange:m,collapsed:h}=GW(),y=wTe()?.variant||"default",E=f===t,x=h&&o?o:void 0;return d.jsx(xTe,{title:o,collapsed:h,children:d.jsxs("button",{ref:u,disabled:r,onClick:()=>m(t),"data-tab-value":t,"data-tab-active":E,role:"tab","aria-selected":E?"true":"false",title:x,className:Fe("relative z-10 flex-1 inline-flex items-center justify-center whitespace-nowrap text-sm font-medium ring-offset-background transition-all duration-500 ease-in-out 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",y==="default"&&"py-2.5",y==="default"&&"rounded-md px-4",y==="underline"&&"px-6 py-3 border-b-2 border-transparent",E&&"text-foreground",!E&&"text-muted-foreground hover:text-foreground",n),...l,children:[a&&d.jsx(a,{className:Fe("h-4 w-4 transition-all duration-500 ease-in-out",!h&&"mr-2",h&&"mr-0!")}),i&&d.jsx("span",{className:"absolute top-1.5 right-1.5 w-2 h-2 bg-orange-500 dark:bg-orange-400 border-2 border-white dark:border-zinc-900 rounded-full transition-opacity duration-300 z-10 animate-status-pulse-orange"}),d.jsx("span",{className:Fe("transition-all duration-500 ease-in-out overflow-hidden",h?"w-0 opacity-0":"w-auto opacity-100"),children:e})]})})});BT.displayName="TabsTrigger";function qF({serverConfig:e,additionalItems:t=[],showClients:n={cursor:!0,vsCode:!0,claudeDesktop:!0,claudeCode:!0,geminiCli:!0,codexCli:!0},className:r="",onSuccess:a,onError:o,trigger:i}){const[l,u]=b.useState(!1),[f,m]=b.useState(null),[h,g]=b.useState(!1),{url:y,name:E,headers:x}=e,w=()=>{try{const L=$G(y,E,x);window.location.href=L,a?.("Cursor")}catch(L){console.error("Failed to generate Cursor deep link:",L),o?.(L)}},S=()=>{try{const L=UG(y,E,x);window.location.href=L,a?.("VS Code")}catch(L){console.error("Failed to generate VS Code deep link:",L),o?.(L)}},_=()=>{try{zG(y,E,x),a?.("Claude Desktop")}catch(L){console.error("Failed to download .mcpb file:",L),o?.(L)}},T=()=>{m("claude-code"),u(!0)},A=()=>{m("gemini-cli"),u(!0)},R=()=>{m("codex-cli"),u(!0)},k=async L=>{try{await navigator.clipboard.writeText(L),g(!0),setTimeout(()=>g(!1),2e3)}catch($){console.error("Failed to copy:",$),o?.($)}},C=()=>{if(f==="claude-code"){const{command:L,envVars:$}=FG(y,E,x),H=U2($);return d.jsxs(d.Fragment,{children:[d.jsxs(ls,{children:[d.jsx(cs,{children:"Add to Claude Code"}),d.jsx(Hp,{children:"Execute the following command in your shell to add this server to Claude Code."})]}),d.jsxs("div",{className:"space-y-4",children:[d.jsxs("div",{children:[d.jsx("h5",{className:"font-semibold text-sm mb-2",children:"Instructions"}),d.jsxs("ol",{className:"space-y-2 text-xs text-muted-foreground",children:[d.jsxs("li",{className:"flex gap-2",children:[d.jsx("span",{className:"font-semibold text-foreground",children:"1."}),d.jsx("span",{children:"Ensure the Claude Code executable is available in your path"})]}),d.jsxs("li",{className:"flex gap-2",children:[d.jsx("span",{className:"font-semibold text-foreground",children:"2."}),d.jsx("span",{children:"Execute the following snippet in your shell:"})]})]})]}),d.jsxs("div",{className:"relative",children:[d.jsx("div",{className:"absolute top-2 right-2 z-10",children:d.jsx(Le,{variant:"ghost",size:"sm",className:"h-7 px-2 bg-background hover:bg-accent border border-border",onClick:()=>k(L),children:h?d.jsx(Or,{className:"size-3.5 text-green-600"}):d.jsx(wr,{className:"size-3.5"})})}),d.jsx("pre",{className:"bg-muted p-3 pr-14 rounded-md text-xs overflow-x-auto",children:d.jsx("code",{children:L})})]}),H&&d.jsxs("div",{children:[d.jsx("h5",{className:"font-semibold text-sm mb-2",children:"Environment Variables"}),d.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:"After installation, set these environment variables in your shell:"}),d.jsx("pre",{className:"bg-muted p-3 rounded-md text-xs overflow-x-auto",children:d.jsx("code",{children:H})})]}),d.jsxs("p",{className:"text-xs text-muted-foreground",children:["The MCP configuration supports environment variable expansion using ",d.jsx("code",{className:"text-foreground",children:"${VAR}"})," ","syntax."]})]})]})}if(f==="gemini-cli"){const{command:L,envVars:$}=BG(y,E,x),H=U2($);return d.jsxs(d.Fragment,{children:[d.jsxs(ls,{children:[d.jsx(cs,{children:"Add to Gemini CLI"}),d.jsx(Hp,{children:"Execute the following command in your shell to add this server to Gemini CLI."})]}),d.jsxs("div",{className:"space-y-4",children:[d.jsxs("div",{children:[d.jsx("h5",{className:"font-semibold text-sm mb-2",children:"Instructions"}),d.jsxs("ol",{className:"space-y-2 text-xs text-muted-foreground",children:[d.jsxs("li",{className:"flex gap-2",children:[d.jsx("span",{className:"font-semibold text-foreground",children:"1."}),d.jsx("span",{children:"Ensure the Gemini CLI executable is available in your path"})]}),H&&d.jsxs("li",{className:"flex gap-2",children:[d.jsx("span",{className:"font-semibold text-foreground",children:"2."}),d.jsx("span",{children:"Set these environment variables in your shell before running the command:"})]}),d.jsxs("li",{className:"flex gap-2",children:[d.jsx("span",{className:"font-semibold text-foreground",children:H?"3.":"2."}),d.jsx("span",{children:"Execute the following snippet in your shell:"})]})]})]}),H&&d.jsxs("div",{children:[d.jsx("h5",{className:"font-semibold text-sm mb-2",children:"Environment Variables"}),d.jsx("pre",{className:"bg-muted p-3 rounded-md text-xs overflow-x-auto",children:d.jsx("code",{children:H})})]}),d.jsxs("div",{className:"relative",children:[d.jsx("div",{className:"absolute top-2 right-2 z-10",children:d.jsx(Le,{variant:"ghost",size:"sm",className:"h-7 px-2 bg-background hover:bg-accent border border-border",onClick:()=>k(L),children:h?d.jsx(Or,{className:"size-3.5 text-green-600"}):d.jsx(wr,{className:"size-3.5"})})}),d.jsx("pre",{className:"bg-muted p-3 pr-14 rounded-md text-xs overflow-x-auto",children:d.jsx("code",{children:L})})]}),d.jsx("p",{className:"text-xs text-muted-foreground",children:"Restart Gemini CLI to load the new configuration."})]})]})}if(f==="codex-cli"){const{config:L,envVars:$}=HG(y,E,x);return d.jsxs(d.Fragment,{children:[d.jsxs(ls,{children:[d.jsx(cs,{children:"Add to Codex CLI"}),d.jsxs(Hp,{children:["Add this configuration to your"," ",d.jsx("code",{className:"text-foreground",children:"~/.codex/config.toml"})," ","file."]})]}),d.jsxs("div",{className:"space-y-4",children:[d.jsxs("div",{children:[d.jsx("h5",{className:"font-semibold text-sm mb-2",children:"Instructions"}),d.jsxs("p",{className:"text-xs text-muted-foreground",children:["Add this configuration to your"," ",d.jsx("code",{className:"text-foreground",children:"~/.codex/config.toml"}),":"]})]}),d.jsxs("div",{className:"relative",children:[d.jsx("div",{className:"absolute top-2 right-2 z-10",children:d.jsx(Le,{variant:"ghost",size:"sm",className:"h-7 px-2 bg-background hover:bg-accent border border-border",onClick:()=>k(L),children:h?d.jsx(Or,{className:"size-3.5 text-green-600"}):d.jsx(wr,{className:"size-3.5"})})}),d.jsx("pre",{className:"bg-muted p-3 pr-14 rounded-md text-xs overflow-x-auto",children:d.jsx("code",{children:L})})]}),$.length>0&&d.jsx("div",{children:d.jsxs("p",{className:"text-xs text-muted-foreground",children:["(optional) If you would rather use variables from your system's environment, replace the"," ",d.jsx("code",{className:"text-foreground",children:"http_headers"})," key with the ",d.jsx("code",{className:"text-foreground",children:"env_http_headers"})," ","key as shown in the commented section above."]})}),d.jsx("p",{className:"text-xs text-muted-foreground",children:"Restart Codex CLI to load the new configuration."})]})]})}return null},O=d.jsxs(Le,{variant:"ghost",className:`bg-zinc-200 dark:bg-zinc-800 hover:bg-zinc-300 dark:hover:bg-zinc-700 rounded-full transition-colors px-3 flex items-center justify-center ${r}`,children:[d.jsxs("span",{className:"xl:hidden hidden sm:flex items-center gap-1",children:[d.jsx(gm,{className:"size-3"}),"Client"]}),d.jsxs("span",{className:"hidden xl:flex items-center gap-1",children:["Add to Client",d.jsx(hs,{className:"size-3"})]})]}),M=i?typeof i=="function"?i({isOpen:!1,onClick:()=>{}}):i:O;return d.jsxs(d.Fragment,{children:[d.jsxs(cm,{children:[d.jsx(um,{asChild:!0,children:M}),d.jsxs(Pd,{align:"end",className:"w-auto min-w-[300px]",children:[t.map(L=>d.jsxs(Jr,{onClick:async()=>{await L.onClick()},className:"flex items-center gap-2",children:[L.icon,d.jsx("span",{className:"min-w-0 max-w-full whitespace-nowrap",children:L.label})]},L.id)),t.length>0&&d.jsx(Mu,{}),n.cursor&&d.jsxs(Jr,{onClick:w,className:"flex items-center gap-2",children:[d.jsx("img",{src:"https://cdn.simpleicons.org/cursor",alt:"Cursor",className:"h-4 w-4"}),d.jsx("span",{className:"min-w-0 max-w-full whitespace-nowrap",children:"Cursor"})]}),n.claudeCode&&d.jsxs(Jr,{onClick:T,className:"flex items-center gap-2",children:[d.jsx("img",{src:"https://cdn.simpleicons.org/claude",alt:"Claude",className:"h-4 w-4"}),d.jsx("span",{className:"min-w-0 max-w-full whitespace-nowrap",children:"Claude Code"})]}),n.claudeDesktop&&d.jsxs(Jr,{onClick:_,className:"flex items-center gap-2",children:[d.jsx("img",{src:"https://cdn.simpleicons.org/claude",alt:"Claude",className:"h-4 w-4"}),d.jsx("span",{className:"min-w-0 max-w-full whitespace-nowrap",children:"Claude Desktop"})]}),n.vsCode&&d.jsxs(Jr,{onClick:S,className:"flex items-center gap-2",children:[d.jsx(PG,{className:"h-4 w-4"}),d.jsx("span",{className:"min-w-0 max-w-full whitespace-nowrap",children:"VS Code"})]}),n.geminiCli&&d.jsxs(Jr,{onClick:A,className:"flex items-center gap-2",children:[d.jsx("img",{src:"https://cdn.simpleicons.org/googlegemini",alt:"Gemini",className:"h-4 w-4"}),d.jsx("span",{className:"min-w-0 max-w-full whitespace-nowrap",children:"Gemini CLI"})]}),n.codexCli&&d.jsxs(Jr,{onClick:R,className:"flex items-center gap-2",children:[d.jsx("img",{src:"https://inspector-cdn.mcp-use.com/providers/openai.png",alt:"Codex",className:"h-4 w-4"}),d.jsx("span",{className:"min-w-0 max-w-full whitespace-nowrap",children:"Codex CLI"})]})]})]}),d.jsx(tl,{open:l,onOpenChange:u,children:d.jsx(nl,{className:"max-w-3xl max-h-[80vh] overflow-y-auto",children:C()})})]})}function XF({className:e,state:t="collapsed",href:n="https://mcp-use.com"}){const[r,a]=b.useState(!1),o=.2,i=.7,l=.6,u=4,f=o+i+l,m=0,h=o/f,g=(o+i)/f,y=1;return d.jsxs("a",{href:n,target:"_blank",rel:"noopener noreferrer",className:Fe("flex items-center transition-opacity -my-3",t==="expanded"?"space-x-2":"",e),onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),children:[d.jsx("div",{className:"relative",children:d.jsxs(Fa.svg,{viewBox:"0 0 303 303",initial:"rest",animate:r?"hover":"rest",className:Fe("text-foreground",t==="expanded"?"size-[40px]":"size-[20px]"),children:[d.jsxs(Fa.g,{variants:{rest:{opacity:1},hover:{opacity:[1,0,0,1],transition:{duration:f,times:[m,h,g,y],ease:"easeInOut"}}},fill:"currentColor",fillRule:"nonzero",stroke:"currentColor",strokeWidth:u,strokeLinecap:"round",strokeLinejoin:"round",children:[d.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"}),d.jsx("circle",{cx:"70.3",cy:"232.3",r:"50"}),d.jsx("circle",{cx:"232.3",cy:"70.3",r:"50"})]}),d.jsxs("g",{fill:"none",stroke:"currentColor",strokeWidth:u,strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx(ETe,{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:y},total:f}),d.jsx(JF,{cx:70.3,cy:232.3,r:50,times:{T0:m,T1:h,T2:g,T3:y},total:f}),d.jsx(JF,{cx:232.3,cy:70.3,r:50,times:{T0:m,T1:h,T2:g,T3:y},total:f})]})]})}),t==="expanded"&&d.jsxs("div",{className:"font-ubuntu flex-col items-start -space-y-1 mr-3 hidden xl:flex",children:[d.jsx("h1",{className:"text-xl font-medium",children:"mcp-use"}),d.jsx("span",{className:"text-lg text-muted-foreground tracking-wide font-sans font-light",children:"Inspector"})]})]})}function ETe({d:e,times:t,total:n}){const{T0:r,T1:a,T2:o,T3:i}=t;return d.jsx(Fa.path,{d:e,variants:{rest:{pathLength:0,opacity:0},hover:{pathLength:[0,0,1,1],opacity:[0,0,1,1],transition:{duration:n,times:[r,a,o,i],ease:"easeInOut"}}}})}function JF({cx:e,cy:t,r:n,times:r,total:a}){const{T0:o,T1:i,T2:l,T3:u}=r;return d.jsx(Fa.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:a,times:[o,i,l,u],ease:"easeInOut"}}}})}function Zb({open:e,onOpenChange:t,serverUrl:n,serverName:r,serverId:a,headers:o,language:i}){const{prismStyle:l}=jI(),[u,f]=b.useState(!1),m=i==="typescript"?gxe(n,r,a,o):bxe(n,r,a,o),h=async()=>{await navigator.clipboard.writeText(m),f(!0),setTimeout(()=>f(!1),2e3)},g=i==="typescript"?"TypeScript":"Python",y=i==="typescript"?"npm install mcp-use":"pip install mcp-use";return d.jsx(tl,{open:e,onOpenChange:t,children:d.jsxs(nl,{className:"max-w-[90vw] max-h-[90vh] overflow-hidden flex flex-col",children:[d.jsxs(ls,{children:[d.jsxs(cs,{children:["Add to ",g," SDK"]}),d.jsxs(Hp,{children:["Copy the following code to integrate this server into your"," ",g," application using the mcp-use SDK."]})]}),d.jsxs("div",{className:"space-y-4 overflow-y-auto flex-1 min-h-0",children:[d.jsxs("div",{children:[d.jsx("h5",{className:"font-semibold text-sm mb-2",children:"Instructions"}),d.jsxs("ol",{className:"space-y-2 text-xs text-muted-foreground",children:[d.jsxs("li",{className:"flex gap-2",children:[d.jsx("span",{className:"font-semibold text-foreground",children:"1."}),d.jsxs("span",{children:["Install the mcp-use package:"," ",d.jsx("code",{className:"text-foreground",children:y})]})]}),d.jsxs("li",{className:"flex gap-2",children:[d.jsx("span",{className:"font-semibold text-foreground",children:"2."}),d.jsxs("span",{children:["Copy the following code into your ",g," project:"]})]})]})]}),d.jsxs("div",{className:"relative w-full overflow-x-auto overflow-y-auto max-h-[60vh]",children:[d.jsx("div",{className:"absolute top-2 right-2 z-10",children:d.jsx(Le,{variant:"ghost",size:"sm",className:"h-7 px-2 bg-background hover:bg-accent border border-border",onClick:h,children:u?d.jsx(Or,{className:"size-3.5 text-green-600"}):d.jsx(wr,{className:"size-3.5"})})}),d.jsx(_m,{language:i,style:l,customStyle:{margin:0,padding:"1rem",paddingRight:"3rem",borderRadius:"0.5rem",fontSize:"0.75rem",background:"var(--muted)",width:"100%",maxWidth:"100%",overflow:"auto"},wrapLines:!0,wrapLongLines:!0,PreTag:"div",children:m})]})]})]})})}function KW({ref:e,shimmerColor:t,shimmerSize:n="0.05em",shimmerDuration:r="3s",borderRadius:a="100px",background:o,className:i,children:l,...u}){const{theme:f}=Rw(),m=f==="dark"?"#000000":"#ffffff",h=f==="dark"?"rgba(255, 255, 255, 1)":"rgba(0, 0, 0, 1)",g=t||m,y=o||h;return d.jsxs("button",{style:{"--spread":"90deg","--shimmer-color":g,"--radius":a,"--speed":r,"--cut":n,"--bg":y},className:Fe("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","dark:text-white text-black dark:border-white/10 border-black/10",i),ref:e,...u,children:[d.jsx("div",{className:Fe("-z-30 blur-[2px]","@container-[size] absolute inset-0 overflow-visible"),children:d.jsx("div",{className:"animate-shimmer-slide absolute inset-0 aspect-[1] h-[100cqh] rounded-none mask-none",children:d.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))]"})})}),l,d.jsx("div",{className:Fe("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","dark:shadow-[inset_0_-8px_10px_#0000001f] dark:group-hover:shadow-[inset_0_-6px_10px_#0000003f] dark: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]")}),d.jsx("div",{className:Fe("absolute [inset:var(--cut)] -z-20 [border-radius:var(--radius)] bg-black dark:bg-white")})]})}KW.displayName="ShimmerButton";function QF({status:e}){const t=o=>{switch(o){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:o}}},{color:n,ringColor:r,tooltip:a}=t(e);return d.jsxs(Wt,{children:[d.jsx(Kt,{asChild:!0,children:d.jsxs("div",{className:"relative",children:[d.jsx("div",{className:`absolute w-2 h-2 rounded-full ${r} animate-ping`}),d.jsx("div",{className:`relative w-2 h-2 rounded-full ${n}`})]})}),d.jsx(Yt,{children:d.jsx("p",{children:a})})]})}function e4({connections:e,selectedServer:t,onServerSelect:n,onOpenConnectionOptions:r,mobileMode:a=!1}){const o=bl(),[i,l]=b.useState(!1),[u,f]=b.useState(null),m=h=>{const g=e.find(y=>y.id===h);if(!g||g.state!=="ready"){Nt.error("Server is not connected and cannot be inspected");return}n(h)};return a?d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("div",{className:"relative",children:d.jsxs(cm,{children:[d.jsx(um,{asChild:!0,children:d.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?d.jsx(Vu,{server:t,size:"md"}):d.jsx(YH,{className:"h-5 w-5"}),d.jsx(hs,{className:"h-4 w-4"})]})}),d.jsxs(Pd,{className:"w-[calc(100vw-2rem)] sm:w-[300px]",align:"start",children:[d.jsx(c_,{className:"cursor-pointer hover:bg-zinc-100 dark:hover:bg-zinc-800",onClick:()=>o("/"),children:"MCP Servers"}),d.jsx(Mu,{}),e.length===0?d.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(h=>d.jsxs(Jr,{onClick:()=>m(h.id),className:"flex items-center gap-3",children:[d.jsx(Vu,{server:h,size:"sm"}),d.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[d.jsx("div",{className:"font-medium",children:h.name}),d.jsx(QF,{status:h.state})]}),d.jsxs("div",{className:"flex items-center gap-1",children:[d.jsx(Le,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 hover:bg-zinc-100 dark:hover:bg-zinc-800",onClick:g=>{g.stopPropagation(),f(h),l(!0)},children:d.jsx(Fp,{className:"h-3 w-3"})}),d.jsx(Le,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 hover:bg-zinc-100 dark:hover:bg-zinc-800",onClick:g=>{g.stopPropagation(),r(h.id)},children:d.jsx(Ju,{className:"h-3 w-3"})})]})]},h.id)),d.jsx(Mu,{}),d.jsx(Jr,{onClick:()=>o("/"),children:d.jsx("span",{className:"text-blue-600 dark:text-blue-400",children:"+ Add new server"})})]})]})}),d.jsx(W_,{open:i,onOpenChange:l,connection:u})]}):d.jsx("div",{className:"flex items-center gap-2",children:d.jsxs("div",{className:"relative",children:[d.jsxs(cm,{children:[d.jsx(um,{asChild:!0,children:d.jsxs(KW,{className:Fe("min-w-0 sm:min-w-[200px] p-0 px-1 text-sm h-11 justify-start 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-20"),children:[t&&d.jsx(Vu,{server:t,size:"md",className:"mr-2"}),d.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[d.jsx("span",{className:"truncate lg:max-w-[120px] xl:max-w-none",children:t?t.serverInfo?.title||t.serverInfo?.name||t.name:"Select server to inspect"}),t&&d.jsx("div",{className:"flex items-center gap-2",children:t.error&&t.state!=="ready"?d.jsxs(Wt,{children:[d.jsx(Kt,{asChild:!0,children:d.jsx("button",{onClick:h=>{h.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"})}),d.jsx(Yt,{children:d.jsx("p",{className:"max-w-xs",children:t.error})})]}):d.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&&d.jsxs("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 flex items-center gap-1",children:[d.jsxs(Wt,{children:[d.jsx(Kt,{asChild:!0,children:d.jsx("button",{type:"button",onClick:()=>{f(t),l(!0)},className:"p-1.5 hover:bg-white/10 dark:hover:bg-black/10 rounded-full transition-colors text-white dark:text-black","aria-label":"View server info",children:d.jsx(Fp,{className:"h-4 w-4"})})}),d.jsx(Yt,{children:d.jsx("p",{children:"View server info"})})]}),d.jsxs(Wt,{children:[d.jsx(Kt,{asChild:!0,children:d.jsx("button",{type:"button",onClick:()=>{r(t.id)},className:"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:d.jsx(Ju,{className:"h-4 w-4"})})}),d.jsx(Yt,{children:d.jsx("p",{children:"Edit connection settings"})})]})]}),d.jsxs(Pd,{className:"w-[calc(100vw-2rem)] sm:w-[300px]",align:"start",children:[d.jsx(c_,{className:"cursor-pointer hover:bg-zinc-100 dark:hover:bg-zinc-800",onClick:()=>o("/"),children:"MCP Servers"}),d.jsx(Mu,{}),e.length===0?d.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(h=>d.jsxs(Jr,{onClick:()=>m(h.id),className:"flex items-center gap-3",children:[d.jsx(Vu,{server:h,size:"sm"}),d.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[d.jsx("div",{className:"font-medium",children:h.serverInfo?.title||h.serverInfo?.name||h.name}),d.jsx(QF,{status:h.state})]}),d.jsxs("div",{className:"flex items-center gap-1",children:[d.jsx(Le,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 hover:bg-zinc-100 dark:hover:bg-zinc-800",onClick:g=>{g.stopPropagation(),f(h),l(!0)},children:d.jsx(Fp,{className:"h-3 w-3"})}),d.jsx(Le,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 hover:bg-zinc-100 dark:hover:bg-zinc-800",onClick:g=>{g.stopPropagation(),r(h.id)},children:d.jsx(Ju,{className:"h-3 w-3"})})]})]},h.id)),d.jsx(Mu,{}),d.jsx(Jr,{onClick:()=>o("/"),children:d.jsx("span",{className:"text-blue-600 dark:text-blue-400",children:"+ Add new server"})})]})]}),d.jsx(W_,{open:i,onOpenChange:l,connection:u})]})})}function t4({className:e}){const{theme:t,setTheme:n}=Rw(),r=b.useRef(null),a=()=>t==="system"?d.jsx(_U,{className:"size-4"}):t==="light"?d.jsx(CU,{className:"size-4"}):d.jsx(TU,{className:"size-4"}),o=async i=>{const l=r.current;if(!l){n(i);return}if(typeof document<"u"&&"startViewTransition"in document){await document.startViewTransition(()=>{tf.flushSync(()=>{n(i)})}).ready;const{top:u,left:f,width:m,height:h}=l.getBoundingClientRect(),g=u+h/2,y=f+m/2,E=window.innerWidth-f,x=window.innerHeight-u,w=Math.hypot(Math.max(f,E),Math.max(u,x));document.documentElement.animate({clipPath:[`circle(0px at ${y}px ${g}px)`,`circle(${w}px at ${y}px ${g}px)`]},{duration:700,easing:"ease-in-out",pseudoElement:"::view-transition-new(root)"})}else n(i)};return d.jsxs(cm,{children:[d.jsx(um,{asChild:!0,children:d.jsx(Le,{ref:r,variant:"ghost",size:"sm",className:Fe("p-2 hover:bg-zinc-200 dark:hover:bg-zinc-800 rounded-full transition-colors",e),"aria-label":"Toggle theme",children:a()})}),d.jsx(Pd,{align:"end",className:"min-w-0",children:d.jsxs(gce,{value:t,onValueChange:i=>o(i),children:[d.jsxs(sy,{value:"light",className:"pl-2 pr-0 flex items-center gap-2 justify-end",children:[d.jsx("span",{children:"Light"}),d.jsx(CU,{className:"mr-2 h-4 w-4"})]}),d.jsxs(sy,{value:"dark",className:"pl-2 pr-0 flex items-center gap-2 justify-end",children:[d.jsx("span",{children:"Dark"}),d.jsx(TU,{className:"mr-2 h-4 w-4"})]}),d.jsxs(sy,{value:"system",className:"pl-2 pr-0 flex items-center gap-2 justify-end",children:[d.jsx("span",{children:"System"}),d.jsx(_U,{className:"mr-2 h-4 w-4"})]})]})})]})}const n4=[{id:"tools",label:"Tools",icon:dc},{id:"prompts",label:"Prompts",icon:hm},{id:"resources",label:"Resources",icon:Pue},{id:"sampling",label:"Sampling",icon:VH},{id:"elicitation",label:"Elicitation",icon:ZH},{id:"notifications",label:"Notifications",icon:ZN},{id:"chat",label:"Chat",icon:que}];function r4(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 a4(e,t,n){const r=["sampling","elicitation","notifications"];return n&&t>0&&r.includes(e)}function STe({collapsed:e,onToggle:t}){return d.jsxs(Wt,{children:[d.jsx(Kt,{asChild:!0,children:d.jsx("button",{onClick:t,className:Fe("shrink-0 p-1.5 rounded-md transition-all duration-500 ease-in-out cursor-pointer","text-muted-foreground hover:text-foreground","hover:bg-zinc-100 dark:hover:bg-zinc-800","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"),"aria-label":e?"Expand tabs":"Collapse tabs",type:"button",children:e?d.jsx(BH,{className:"h-4 w-4 transition-transform duration-500 ease-in-out"}):d.jsx(rw,{className:"h-4 w-4 transition-transform duration-500 ease-in-out"})})}),d.jsx(Yt,{children:d.jsx("p",{children:e?"Expand tabs":"Collapse tabs"})})]})}function _Te({connections:e,selectedServer:t,activeTab:n,onServerSelect:r,onTabChange:a,onCommandPaletteOpen:o,onOpenConnectionOptions:i,embedded:l=!1}){const{tunnelUrl:u}=kc(),f=t&&u,[m,h]=b.useState(!1),[g,y]=b.useState(!1),[E,x]=b.useState(!1),[w,S]=b.useState(!0),_=async()=>{if(u)try{await navigator.clipboard.writeText(`${u}/mcp`),h(!0),Nt.success("Tunnel URL copied to clipboard"),setTimeout(()=>h(!1),2e3)}catch{Nt.error("Failed to copy URL")}};return d.jsxs("header",{className:"w-full mx-auto",children:[d.jsxs("div",{className:"flex lg:hidden flex-col gap-3",children:[d.jsxs("div",{className:"flex items-center justify-between w-full",children:[!l&&d.jsx("div",{className:"flex-1 flex justify-start",children:d.jsx(e4,{connections:e,selectedServer:t,onServerSelect:r,onOpenConnectionOptions:i,mobileMode:!0})}),!l&&d.jsx("div",{className:"flex-shrink-0 flex justify-center",children:d.jsx("div",{className:"scale-150",children:d.jsx(XF,{state:"collapsed"})})}),!l&&d.jsxs("div",{className:"flex-1 flex justify-end items-center gap-2",children:[t&&(()=>{const T=t.serverInfo?.title||t.serverInfo?.name||t.name;return d.jsxs(d.Fragment,{children:[d.jsx(qF,{serverConfig:{url:u?`${u}/mcp`:t.url,name:T,headers:t.customHeaders,serverId:t.id},onSuccess:A=>Nt.success(`Opening in ${A}...`),onError:A=>Nt.error(`Failed: ${A.message}`),additionalItems:[{id:"ts-sdk",label:"TypeScript SDK",icon:d.jsx("img",{src:"https://cdn.simpleicons.org/typescript",alt:"TypeScript",className:"h-4 w-4"}),onClick:()=>y(!0)},{id:"py-sdk",label:"Python SDK",icon:d.jsx("img",{src:"https://cdn.simpleicons.org/python",alt:"Python",className:"h-4 w-4"}),onClick:()=>x(!0)}],trigger:d.jsxs(Le,{variant:"ghost",className:"bg-zinc-200 dark:bg-zinc-800 hover:bg-zinc-300 dark:hover:bg-zinc-700 rounded-full transition-colors px-3 flex items-center justify-center p-2","aria-label":"Add to Client",children:[d.jsxs("span",{className:"xl:hidden hidden sm:flex items-center gap-1",children:[d.jsx(gm,{className:"size-3"}),"Client"]}),d.jsxs("span",{className:"hidden xl:flex items-center gap-1",children:["Add to Client",d.jsx(hs,{className:"size-3"})]})]})}),d.jsx(Zb,{open:g,onOpenChange:y,serverUrl:u?`${u}/mcp`:t.url,serverName:T,serverId:void 0,headers:t.customHeaders,language:"typescript"}),d.jsx(Zb,{open:E,onOpenChange:x,serverUrl:u?`${u}/mcp`:t.url,serverName:T,serverId:void 0,headers:t.customHeaders,language:"python"})]})})(),d.jsxs(Wt,{children:[d.jsx(Kt,{asChild:!0,children:d.jsx(Le,{variant:"ghost",size:"sm",asChild:!0,children:d.jsx("a",{href:"https://github.com/mcp-use/mcp-use",target:"_blank",rel:"noopener noreferrer",className:"p-2","aria-label":"GitHub",children:d.jsx(ZF,{className:"h-4 w-4"})})})}),d.jsx(Yt,{children:d.jsx("p",{children:"Give us a star ⭐"})})]}),d.jsx(t4,{})]})]}),t&&d.jsx("div",{className:"w-full",children:d.jsx(zT,{value:n,onValueChange:T=>a(T),collapsed:w,onCollapsedChange:S,children:d.jsx(FT,{className:"w-full justify-center",children:n4.map(T=>{const A=r4(T.id,t),R=a4(T.id,A,w);return d.jsxs(BT,{value:T.id,icon:T.icon,showDot:R,className:Fe("[&>svg]:mr-0 flex-1 flex-row gap-2 relative",w&&"pl-2"),children:[A>0&&!w&&d.jsx("span",{className:Fe(n===T.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:A}),d.jsx("span",{className:"sr-only",children:T.label})]},T.id)})})})})]}),d.jsxs("div",{className:"hidden lg:flex items-center justify-between gap-3",children:[d.jsxs("div",{className:"flex items-center flex-wrap gap-2 md:space-x-6 space-x-2",children:[!l&&d.jsx(e4,{connections:e,selectedServer:t,onServerSelect:r,onOpenConnectionOptions:i}),t&&d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(zT,{value:n,onValueChange:T=>a(T),collapsed:w,onCollapsedChange:S,children:d.jsx(FT,{className:"overflow-x-auto",collapsible:!0,children:n4.map(T=>{const A=r4(T.id,t),R=A>0?`${T.label} (${A})`:T.label,k=a4(T.id,A,w);return d.jsx(BT,{value:T.id,icon:T.icon,showDot:k,className:Fe("[&>svg]:mr-0 lg:[&>svg]:mr-2 relative",w&&"pl-4"),title:R,children:d.jsxs("div",{className:"items-center gap-2 hidden lg:flex",children:[T.label,A>0&&d.jsx("span",{className:Fe(n===T.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:A})]})})})})}),d.jsx(STe,{collapsed:w,onToggle:()=>S(!w)})]}),f&&d.jsxs(i7,{children:[d.jsx(l7,{asChild:!0,children:d.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:[d.jsx(bm,{className:"size-4 text-purple-600 dark:text-purple-400 animate-pulse"}),d.jsx("span",{className:"text-xs font-medium text-purple-700 dark:text-purple-300 hidden lg:inline",children:"Tunnel"})]})}),d.jsx(yO,{className:"w-[calc(100vw-2rem)] sm:w-96",align:"start",children:d.jsxs("div",{className:"space-y-4",children:[d.jsxs("div",{children:[d.jsxs("h4",{className:"font-semibold text-sm mb-2 flex items-center gap-2",children:[d.jsx(bm,{className:"size-4 text-purple-600 dark:text-purple-400"}),"Tunnel URL"]}),d.jsxs("div",{className:"flex items-center gap-2 p-2 py-0 bg-muted rounded-full",children:[d.jsxs("code",{className:"flex-1 text-[10px] font-mono",children:[u,"/mcp"]}),d.jsx(Le,{variant:"ghost",size:"sm",className:"h-7 px-2",onClick:_,children:m?d.jsx(Or,{className:"size-3.5 text-green-600"}):d.jsx(wr,{className:"size-3.5"})})]})]}),d.jsxs("div",{children:[d.jsx("h5",{className:"font-semibold text-sm mb-2",children:"Use in ChatGPT"}),d.jsxs("ol",{className:"space-y-2 text-xs text-muted-foreground",children:[d.jsxs("li",{className:"flex gap-2",children:[d.jsx("span",{className:"font-semibold text-foreground",children:"1."}),d.jsxs("span",{children:["Enable"," ",d.jsx("span",{className:"font-medium text-foreground",children:"dev mode"})," ","from settings"]})]}),d.jsxs("li",{className:"flex gap-2",children:[d.jsx("span",{className:"font-semibold text-foreground",children:"2."}),d.jsxs("span",{children:["In"," ",d.jsx("span",{className:"font-medium text-foreground",children:"App & Connectors"})," ","click on"," ",d.jsx("span",{className:"font-medium text-foreground",children:"create"})]})]}),d.jsxs("li",{className:"flex gap-2",children:[d.jsx("span",{className:"font-semibold text-foreground",children:"3."}),d.jsx("span",{children:"Use the tunnel URL in the input"})]})]})]})]})})]})]}),!l&&d.jsxs("div",{className:"flex items-center gap-2 sm:gap-4 flex-shrink-0",children:[t&&(()=>{const T=t.serverInfo?.title||t.serverInfo?.name||t.name;return d.jsxs(d.Fragment,{children:[d.jsx(qF,{serverConfig:{url:u?`${u}/mcp`:t.url,name:T,headers:t.customHeaders,serverId:t.id},onSuccess:A=>Nt.success(`Opening in ${A}...`),onError:A=>Nt.error(`Failed: ${A.message}`),additionalItems:[{id:"ts-sdk",label:"TypeScript SDK",icon:d.jsx("img",{src:"https://cdn.simpleicons.org/typescript",alt:"TypeScript",className:"h-4 w-4"}),onClick:()=>y(!0)},{id:"py-sdk",label:"Python SDK",icon:d.jsx("img",{src:"https://cdn.simpleicons.org/python",alt:"Python",className:"h-4 w-4"}),onClick:()=>x(!0)}],trigger:d.jsxs(Le,{variant:"ghost",className:"bg-zinc-200 dark:bg-zinc-800 hover:bg-zinc-300 dark:hover:bg-zinc-700 rounded-full transition-colors px-3 flex items-center justify-center","aria-label":"Add to Client",children:[d.jsxs("span",{className:"xl:hidden hidden sm:flex items-center gap-1",children:[d.jsx(gm,{className:"size-3"}),"Client"]}),d.jsxs("span",{className:"hidden xl:flex items-center gap-1",children:["Add to Client",d.jsx(hs,{className:"size-3"})]})]})}),d.jsx(Zb,{open:g,onOpenChange:y,serverUrl:u?`${u}/mcp`:t.url,serverName:T,serverId:void 0,headers:t.customHeaders,language:"typescript"}),d.jsx(Zb,{open:E,onOpenChange:x,serverUrl:u?`${u}/mcp`:t.url,serverName:T,serverId:void 0,headers:t.customHeaders,language:"python"})]})})(),d.jsx(t4,{}),d.jsxs(Wt,{children:[d.jsx(Kt,{asChild:!0,children:d.jsxs(Le,{variant:"ghost",className:"hover:bg-zinc-200 dark:hover:bg-zinc-800 rounded-full px-1 -mx-3 flex gap-1",onClick:o,children:[d.jsx(wue,{className:"size-4"}),d.jsx("span",{className:"text-base font-mono hidden sm:inline",children:"K"})]})}),d.jsx(Yt,{children:d.jsx("p",{children:"Command Palette"})})]}),d.jsxs(Wt,{children:[d.jsx(Kt,{asChild:!0,children:d.jsx(Le,{variant:"ghost",size:"sm",asChild:!0,children:d.jsxs("a",{href:"https://github.com/mcp-use/mcp-use",className:"flex items-center gap-2",target:"_blank",rel:"noopener noreferrer",children:[d.jsx(ZF,{className:"h-4 w-4"}),d.jsx("span",{className:"hidden xl:inline",children:"Github"})]})})}),d.jsx(Yt,{children:d.jsx("p",{children:"Give us a star ⭐"})})]}),d.jsx(XF,{state:"expanded"})]})]})]})}function TTe({children:e}){const t=bl(),n=Aa(),{servers:r,addServer:a,removeServer:o,updateServer:i,storageLoaded:l}=Ym(),u=b.useCallback((D,P,W,K)=>{a(D,{url:D,name:P,proxyConfig:W,transportType:K,preventAutoAuth:!0})},[a]),f=b.useCallback(async(D,P)=>{try{await i(D,P)}catch(W){console.error(`[Layout] Failed to update connection ${D}:`,W)}},[i]),{selectedServerId:m,setSelectedServerId:h,activeTab:g,setActiveTab:y,navigateToItem:E,setTunnelUrl:x,tunnelUrl:w,isEmbedded:S,embeddedConfig:_,setEmbeddedMode:T}=kc(),[A,R]=b.useState(!1),[k,C]=b.useState(null),O=H0e();b.useEffect(()=>{const D=new URLSearchParams(n.search),P=D.get("embedded")==="true",W=D.get("embeddedConfig");if(P){let K={};if(W)try{K=JSON.parse(W)}catch(ae){console.error("Failed to parse embeddedConfig:",ae)}T(!0,K)}},[]),b.useEffect(()=>{const P=new URLSearchParams(n.search).get("tunnelUrl");x(P)},[n.search,x]),b.useEffect(()=>{const P=new URLSearchParams(n.search).get("tab");P&&["tools","prompts","resources","chat","sampling","elicitation","notifications"].includes(P)&&y(P)},[n.search,y]),b.useEffect(()=>{const D=K=>{const oe=K.detail.requestId;m&&E(m,"sampling",oe)},P=K=>{const oe=K.detail.requestId;m&&E(m,"elicitation",oe)},W=K=>{const oe=K.detail.toolName;m&&oe?E(m,"tools",oe):m&&y("tools")};return window.addEventListener("navigate-to-sampling",D),window.addEventListener("navigate-to-elicitation",P),window.addEventListener("navigate-to-tool-result",W),()=>{window.removeEventListener("navigate-to-sampling",D),window.removeEventListener("navigate-to-elicitation",P),window.removeEventListener("navigate-to-tool-result",W)}},[m,y,E]);const M=b.useRef(null),L=b.useRef(null),$=b.useRef(null),{isAutoConnecting:H}=B0e({connections:r,addConnection:u,removeConnection:o,configLoaded:l,embedded:S}),V=b.useCallback(D=>{ra.getInstance().capture(new Bce({trigger:D})).catch(()=>{}),R(!0)},[]),Z=D=>{const P=r.find(le=>le.id===D);if(!P||P.state!=="ready"){Nt.error("Server is not connected and cannot be inspected");return}h(D);const W=new URLSearchParams(n.search),K=W.get("tunnelUrl"),ae=W.get("tab"),oe=new URLSearchParams;oe.set("server",D),K&&oe.set("tunnelUrl",K),ae&&oe.set("tab",ae),t(`/?${oe.toString()}`)},ne=b.useCallback(D=>{C(D)},[]),G=b.useCallback(D=>{k&&(D.url!==k?(o(k),u(D.url,D.name,D.proxyConfig,D.transportType)):f(k,{name:D.name,proxyConfig:D.proxyConfig,transportType:D.transportType}),C(null),Nt.success("Connection settings updated"))},[k,o,u,f]),Y=(D,P,W)=>{if(console.warn("[Layout] handleCommandPaletteNavigate called:",{tab:D,itemName:P,serverId:W}),W){const K=r.find(q=>q.id===W);if(console.warn("[Layout] Server lookup:",{serverId:W,serverFound:!!K,serverState:K?.state}),!K||K.state!=="ready"){console.warn("[Layout] Server not ready, showing error"),Nt.error("Server is not connected and cannot be inspected");return}console.warn("[Layout] Calling navigateToItem:",{serverId:W,tab:D,itemName:P}),E(W,D,P);const ae=new URLSearchParams(n.search),oe=ae.get("tunnelUrl"),le=ae.get("tab"),Q=new URLSearchParams;Q.set("server",W),oe&&Q.set("tunnelUrl",oe),D?Q.set("tab",D):le&&Q.set("tab",le);const J=`/?${Q.toString()}`;console.warn("[Layout] Navigating to:",J),t(J)}else console.warn("[Layout] No serverId, just updating tab to:",D),y(D)},F=r.find(D=>D.id===m),re=F?F.tools.map(D=>({...D,_serverId:F.id})):r.flatMap(D=>D.state==="ready"?D.tools.map(P=>({...P,_serverId:D.id,_serverName:D.name})):[]),ee=F?F.prompts.map(D=>({...D,_serverId:F.id})):r.flatMap(D=>D.state==="ready"?D.prompts.map(P=>({...P,_serverId:D.id,_serverName:D.name})):[]),j=F?F.resources.map(D=>({...D,_serverId:F.id})):r.flatMap(D=>D.state==="ready"?D.resources.map(P=>({...P,_serverId:D.id,_serverName:D.name})):[]);if(b.useEffect(()=>{const P=new URLSearchParams(n.search).get("server");P!==m&&h(P)},[n.search,m,h]),b.useEffect(()=>{const P=new URLSearchParams(n.search).get("server");if(!P)return;const W=r.find(K=>K.id===P);if(!W){const K=setTimeout(()=>t("/"),3e3);return()=>clearTimeout(K)}if(W.state==="failed"){const K=setTimeout(()=>t("/"),2e3);return()=>clearTimeout(K)}},[n.search,t,r]),RG({onCommandPalette:()=>V("keyboard"),onToolsTab:()=>{F&&y("tools")},onPromptsTab:()=>{F&&y("prompts")},onResourcesTab:()=>{F&&y("resources")},onChatTab:()=>{F&&y("chat")},onHome:()=>{t("/")},onFocusSearch:()=>{g==="tools"&&M.current?M.current.focusSearch():g==="prompts"&&L.current?L.current.focusSearch():g==="resources"&&$.current&&$.current.focusSearch()},onBlurSearch:()=>{g==="tools"&&M.current?M.current.blurSearch():g==="prompts"&&L.current?L.current.blurSearch():g==="resources"&&$.current&&$.current.blurSearch()}}),H)return d.jsx("div",{className:"h-screen bg-white dark:bg-zinc-900 flex items-center justify-center",children:d.jsxs("div",{className:"flex flex-col items-center gap-4",children:[d.jsx(oi,{className:"h-8 w-8 text-zinc-600 dark:text-zinc-400"}),d.jsx("p",{className:"text-sm text-zinc-600 dark:text-zinc-400",children:"Connecting to MCP server..."})]})});const B=S?{backgroundColor:_.backgroundColor||"#f3f3f3",padding:_.padding||"0.5rem"}:{},z=S?"h-screen flex flex-col gap-2 sm:gap-4":"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";return d.jsx(YN,{children:d.jsxs("div",{className:z,style:B,children:[d.jsx(_Te,{connections:r,selectedServer:F,activeTab:g,onServerSelect:Z,onTabChange:y,onCommandPaletteOpen:()=>V("button"),onOpenConnectionOptions:ne,embedded:S}),d.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:d.jsx(vTe,{selectedServer:F,activeTab:g,toolsSearchRef:M,promptsSearchRef:L,resourcesSearchRef:$,children:e})}),!S&&d.jsxs("div",{className:"text-xs text-zinc-500 dark:text-zinc-400 px-2",children:["Having trouble connecting?"," ",d.jsx("button",{onClick:()=>{const D=[];for(let P=0;P<localStorage.length;P++){const W=localStorage.key(P);W&&(W.startsWith("mcp:auth")||W.startsWith("mcp-inspector"))&&D.push(W)}D.forEach(P=>localStorage.removeItem(P)),Nt.success(`Cleared ${D.length} localStorage item(s). Refreshing page...`,{duration:2e3}),setTimeout(()=>{window.location.reload()},500)},className:"text-blue-600 dark:text-blue-400 hover:underline focus:outline-none focus:underline",children:"Clear localStorage"})]}),d.jsx(vxe,{isOpen:A,onOpenChange:R,tools:re,prompts:ee,resources:j,savedRequests:O,connections:r,selectedServer:F,tunnelUrl:w,onNavigate:Y,onServerSelect:Z}),d.jsx(W8,{connection:k&&r.find(D=>D.id===k)||null,open:k!==null,onOpenChange:D=>{D||C(null)},onConnect:G})]})})}function NTe(){const[e,t]=b.useState("processing"),[n,r]=b.useState("");return b.useEffect(()=>{console.log("[OAuthCallback] Component mounted, handling authorization..."),console.log("[OAuthCallback] Current URL:",window.location.href),SN().then(()=>{console.log("[OAuthCallback] Authorization successful"),t("success")}).catch(a=>{console.error("[OAuthCallback] Authorization failed:",a),t("error"),r(a instanceof Error?a.message:String(a))})},[]),e==="processing"?d.jsx("div",{className:"h-screen w-full flex items-center justify-center bg-white dark:bg-zinc-900",children:d.jsxs("div",{className:"flex flex-col items-center gap-4",children:[d.jsx(cl,{className:"h-8 w-8 animate-spin text-zinc-600 dark:text-zinc-400"}),d.jsx("p",{className:"text-sm text-zinc-600 dark:text-zinc-400",children:"Completing authentication..."})]})}):e==="error"?d.jsx("div",{className:"h-screen w-full flex items-center justify-center bg-white dark:bg-zinc-900",children:d.jsxs("div",{className:"max-w-md p-6",children:[d.jsx("h1",{className:"text-xl font-semibold text-red-600 dark:text-red-400 mb-2",children:"Authentication Error"}),d.jsx("p",{className:"text-sm text-zinc-600 dark:text-zinc-400 mb-4",children:n}),d.jsx("p",{className:"text-xs text-zinc-500 dark:text-zinc-500",children:"You can close this window and try again."})]})}):d.jsx("div",{className:"h-screen w-full flex items-center justify-center bg-white dark:bg-zinc-900",children:d.jsxs("div",{className:"max-w-md p-6",children:[d.jsx("h1",{className:"text-xl font-semibold text-green-600 dark:text-green-400 mb-2",children:"Authentication Successful!"}),d.jsx("p",{className:"text-sm text-zinc-600 dark:text-zinc-400",children:"Redirecting you back..."})]})})}var CTe=(e,t,n,r,a,o,i,l)=>{let u=document.documentElement,f=["light","dark"];function m(y){(Array.isArray(e)?e:[e]).forEach(E=>{let x=E==="class",w=x&&o?a.map(S=>o[S]||S):a;x?(u.classList.remove(...w),u.classList.add(o&&o[y]?o[y]:y)):u.setAttribute(E,y)}),h(y)}function h(y){l&&f.includes(y)&&(u.style.colorScheme=y)}function g(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}if(r)m(r);else try{let y=localStorage.getItem(t)||n,E=i&&y==="system"?g():y;m(E)}catch{}},RTe=b.createContext(void 0),kTe={setTheme:e=>{},themes:[]},ATe=()=>{var e;return(e=b.useContext(RTe))!=null?e:kTe};b.memo(({forcedTheme:e,storageKey:t,attribute:n,enableSystem:r,enableColorScheme:a,defaultTheme:o,value:i,themes:l,nonce:u,scriptProps:f})=>{let m=JSON.stringify([n,t,o,e,l,i,r,a]).slice(1,-1);return b.createElement("script",{...f,suppressHydrationWarning:!0,nonce:typeof window>"u"?u:"",dangerouslySetInnerHTML:{__html:`(${CTe.toString()})(${m})`}})});function ITe({...e}){const{theme:t="system"}=ATe();return d.jsx(Hme,{theme:t,className:"toaster group",style:{"--normal-bg":"var(--popover)","--normal-text":"var(--popover-foreground)","--normal-border":"var(--border)"},...e})}function OTe(){const t=new URLSearchParams(window.location.search).get("embedded")==="true",n=b.useMemo(()=>t?void 0:new nae("mcp-inspector-connections"),[t]);return d.jsx(tbe,{children:d.jsx(AB,{storageProvider:n,enableRpcLogging:!0,defaultAutoProxyFallback:{enabled:!0,proxyAddress:`${window.location.origin}/inspector/api/proxy`},clientInfo:{name:"mcp-use Inspector",version:window.__INSPECTOR_VERSION__,websiteUrl:"https://mcp-use.com",icons:[{src:"https://mcp-use.com/logo.png"}]},onServerAdded:(r,a)=>{console.log("[Inspector] Server added:",r,a.state)},onServerRemoved:r=>{console.log("[Inspector] Server removed:",r)},onServerStateChange:(r,a)=>{console.log("[Inspector] Server state changed:",r,a)},onSamplingRequest:(r,a,o,i,l)=>{const u=Nt(d.jsx(pTe,{requestId:r.id,serverName:o,onViewDetails:()=>{const f=new CustomEvent("navigate-to-sampling",{detail:{requestId:r.id}});window.dispatchEvent(f),Nt.dismiss(u)},onApprove:f=>{i(r.id,f),Nt.success("Sampling request approved"),Nt.dismiss(u)},onDeny:()=>{l(r.id,"User denied from toast"),Nt.dismiss(u)}}),{duration:1/0})},onElicitationRequest:(r,a,o,i,l)=>{const u=r.request.mode||"form",f=r.request.message,m=u==="url"&&"url"in r.request?r.request.url:void 0,h=Nt(d.jsx(dae,{requestId:r.id,serverName:o,mode:u,message:f,url:m,onViewDetails:()=>{const g=new CustomEvent("navigate-to-elicitation",{detail:{requestId:r.id}});window.dispatchEvent(g),Nt.dismiss(h)},onOpenUrl:u==="url"&&m?()=>{window.open(m,"_blank"),Nt.dismiss(h)}:void 0,onCancel:()=>{l(r.id,"User cancelled from toast"),Nt.dismiss(h)}}),{duration:1/0})},children:d.jsxs(F0e,{children:[d.jsx(rme,{basename:"/inspector",children:d.jsxs(Zfe,{children:[d.jsx(E_,{path:"/oauth/callback",element:d.jsx(NTe,{})}),d.jsx(E_,{path:"/",element:d.jsx(TTe,{children:d.jsx(z0e,{})})})]})}),d.jsx(ITe,{position:"top-center"})]})})})}const o4=new URLSearchParams(window.location.search);if(o4.has("code")||o4.has("error"))try{SN()}catch(e){console.error("[inspector] OAuth callback error:",e)}const s4=document.getElementById("root");s4?uae.createRoot(s4).render(d.jsx(OTe,{})):console.error("[inspector] Root element not found");const DTe=Object.freeze(Object.defineProperty({__proto__:null,clearRpcLogs:Fy,getAllRpcLogs:TN,getRpcLogs:IB,subscribeToRpcLogs:NN,wrapTransportForLogging:OB},Symbol.toStringTag,{value:"Module"}));export{iy as $,Ec as A,Rpe as B,R_ as C,WTe as D,vs as E,fw as F,KTe as G,eC as H,Na as I,Vpe as J,v_ as K,ac as L,vfe as M,ua as N,iNe as O,cfe as P,ype as Q,_Ne as R,LNe as S,bNe as T,lNe as U,rme as V,w6 as W,CNe as X,ql as Y,tC as Z,ze as _,Ua as a,Rfe as a$,v6 as a0,ENe as a1,oNe as a2,SNe as a3,ome as a4,sNe as a5,Ide as a6,h6 as a7,E_ as a8,Nc as a9,xNe as aA,dme as aB,TNe as aC,VTe as aD,NNe as aE,ga as aF,qy as aG,cNe as aH,S_ as aI,MNe as aJ,efe as aK,GTe as aL,ym as aM,Ro as aN,uNe as aO,Zde as aP,ame as aQ,ONe as aR,nNe as aS,pC as aT,tNe as aU,Ufe as aV,INe as aW,Ffe as aX,kNe as aY,ANe as aZ,ume as a_,Zfe as aa,Jpe as ab,sme as ac,DNe as ad,ZTe as ae,si as af,gl as ag,cw as ah,cf as ai,ka as aj,oo as ak,lw as al,dNe as am,hNe as an,pNe as ao,JH as ap,wC as aq,vNe as ar,QH as as,XH as at,nC as au,wNe as av,yNe as aw,hC as ax,Et as ay,oh as az,jNe as b,nr as b$,Tc as b0,ime as b1,fC as b2,Aa as b3,XTe as b4,dC as b5,bl as b6,$fe as b7,qTe as b8,Afe as b9,dr as bA,pe as bB,wt as bC,An as bD,v3 as bE,BTe as bF,no as bG,rr as bH,FTe as bI,UTe as bJ,fr as bK,_p as bL,zTe as bM,pl as bN,pJ as bO,pX as bP,_X as bQ,DZ as bR,jZ as bS,fJ as bT,fX as bU,PTe as bV,RZ as bW,ol as bX,LQ as bY,oee as bZ,g3 as b_,JTe as ba,iC as bb,ah as bc,QTe as bd,eNe as be,Ife as bf,RNe as bg,E6 as bh,pme as bi,Ute as bj,MTe as bk,Fm as bl,Jb as bm,Fre as bn,Tv as bo,rs as bp,He as bq,zre as br,Vre as bs,x$ as bt,jTe as bu,Bre as bv,at as bw,nt as bx,er as by,nee as bz,Ppe as c,DX as c0,w4 as c1,xZ as c2,ny as c3,lZ as c4,Gre as c5,cZ as c6,SN as c7,EZ as c8,vpe as d,ue as e,ju as f,fc as g,rNe as h,aNe as i,LV as j,bpe as k,Nfe as l,Uo as m,Cfe as n,wm as o,$Te as p,So as q,b as r,zpe as s,lfe as t,mC as u,YTe as v,x_ as w,gNe as x,mNe as y,fNe as z};
1783
+ `),fe.document.close())}},[E]),Nn=b.useCallback(()=>{K?(he.current&&he.current.expand(),Ne.current&&Ne.current.expand(),ae(!1)):(he.current&&he.current.collapse(),Ne.current&&Ne.current.collapse(),ae(!0))},[K]),ot=b.useCallback(()=>{i&&(ne(""),V(!0))},[i]),zn=b.useCallback(()=>{if(!i)return;const Ge={id:`${Date.now()}-${Math.random()}`,name:Z.trim()||`${i.name} - ${new Date().toLocaleString()}`,toolName:i.name,args:g,savedAt:Date.now(),serverId:i._serverId,serverName:i._serverName};st([...L,Ge]),ra.getInstance().capture(new Hce({toolName:i.name,serverId:a})).catch(()=>{}),V(!1),ne("")},[i,Z,g,L,st,a]),qt=b.useCallback(Ge=>{st(L.filter(We=>We.id!==Ge)),u?.id===Ge&&f(null)},[L,st,u]);return z?d.jsxs("div",{className:"h-full flex flex-col overflow-hidden relative bg-background",children:[P!=="list"&&d.jsxs("div",{className:"flex items-center gap-2 p-2 border-b shrink-0 bg-background z-10",children:[d.jsx(Le,{variant:"ghost",size:"sm",onClick:()=>{P==="response"?W("detail"):(l(null),W("list"))},className:"p-0 h-8 w-8",children:d.jsx(rw,{className:"h-4 w-4"})}),d.jsxs("div",{className:"flex items-center text-sm font-medium",children:[d.jsx("button",{onClick:()=>{l(null),W("list")},className:"text-muted-foreground hover:text-foreground hover:underline cursor-pointer",children:"Tools"}),P==="detail"&&d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"mx-2 text-muted-foreground",children:"/"}),d.jsx("button",{onClick:()=>{W("response")},className:P==="detail"?"text-foreground hover:underline":P==="response"?"text-muted-foreground hover:text-foreground hover:underline cursor-pointer":"text-muted-foreground",children:"Execute"})]}),P==="response"&&d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"mx-2 text-muted-foreground",children:"/"}),d.jsx("span",{className:"text-foreground",children:"Response"})]})]})]}),d.jsx("div",{className:"flex-1 relative overflow-hidden",children:d.jsxs(Aw,{initial:!1,mode:"popLayout",children:[P==="list"&&d.jsxs(Fa.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:[d.jsx(KF,{activeTab:O,isSearchExpanded:F,searchQuery:k,filteredToolsCount:Ve.length,savedRequestsCount:L.length,onSearchExpand:()=>re(!0),onSearchChange:C,onSearchBlur:Ee,onTabSwitch:()=>M(O==="tools"?"saved":"tools"),searchInputRef:B}),O==="tools"?d.jsx(WF,{tools:Ve,selectedTool:i,onToolSelect:ut,focusedIndex:ee}):d.jsx(zF,{savedRequests:L,selectedRequest:u,onLoadRequest:rt,onDeleteRequest:qt,focusedIndex:ee})]},"list"),P==="detail"&&d.jsx(Fa.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:d.jsx(HF,{selectedTool:i,toolArgs:g,isExecuting:w,isConnected:o,onArgChange:_e,onExecute:Be,onSave:ot})},"detail"),P==="response"&&d.jsx(Fa.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:d.jsx(GF,{results:lt,copiedResult:_,previewMode:G,serverId:a,readResource:r,onCopy:it,onDelete:qe,onFullscreen:At,onTogglePreview:()=>Y(!G)})},"response")]})}),d.jsx(FF,{isOpen:H,requestName:Z,defaultPlaceholder:`${i?.name} - ${new Date().toLocaleString()}`,onRequestNameChange:ne,onSave:zn,onCancel:()=>V(!1)})]}):d.jsxs(Ta,{direction:"horizontal",className:"h-full",children:[d.jsx(Yn,{ref:he,defaultSize:33,collapsible:!0,className:"flex flex-col h-full relative",children:d.jsxs(Ta,{direction:"vertical",className:"h-full border-r dark:border-zinc-700",children:[d.jsx(Yn,{defaultSize:75,minSize:30,children:d.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[d.jsx(KF,{activeTab:O,isSearchExpanded:F,searchQuery:k,filteredToolsCount:Ve.length,savedRequestsCount:L.length,onSearchExpand:()=>re(!0),onSearchChange:C,onSearchBlur:Ee,onTabSwitch:()=>M(O==="tools"?"saved":"tools"),searchInputRef:B}),O==="tools"?d.jsx(WF,{tools:Ve,selectedTool:i,onToolSelect:ut,focusedIndex:ee}):d.jsx(zF,{savedRequests:L,selectedRequest:u,onLoadRequest:rt,onDeleteRequest:qt,focusedIndex:ee})]})}),d.jsx(Ho,{withHandle:!0}),d.jsxs(Yn,{ref:Pe,defaultSize:0,collapsible:!0,minSize:5,collapsedSize:5,style:{minHeight:45},onCollapse:()=>{J(!0)},onExpand:()=>{J(!1)},className:"flex flex-col border-t dark:border-zinc-700",children:[d.jsxs("div",{className:"group flex items-center justify-between p-3 shrink-0 cursor-pointer hover:bg-muted/50 transition-colors",onClick:Ge=>{Ge.preventDefault(),Ge.stopPropagation(),Q?(Pe.current?.resize(25),J(!1)):(Pe.current?.resize(5),J(!0))},children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("h3",{className:"text-sm font-medium",children:"RPC Messages"}),oe>0&&d.jsx(Dr,{variant:"secondary",className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",children:oe}),oe>0&&!Q&&d.jsx(Le,{variant:"ghost",size:"sm",onClick:Ge=>{Ge.preventDefault(),Ge.stopPropagation(),Ue.current?.()},className:"h-6 w-6 p-0",title:"Clear all messages",children:d.jsx(ti,{className:"h-3.5 w-3.5"})})]}),d.jsx(hs,{className:`h-4 w-4 text-muted-foreground transition-transform ${Q?"":"rotate-180"}`})]}),d.jsx("div",{className:`flex-1 overflow-hidden min-h-0 ${Q?"hidden":""}`,children:d.jsx(ZO,{serverIds:[a],onCountChange:le,onClearRef:Ue})})]})]})}),d.jsx(Ho,{withHandle:!0}),d.jsx(Yn,{defaultSize:67,children:d.jsxs(Ta,{direction:"vertical",children:[d.jsx(Yn,{ref:Ne,defaultSize:40,collapsible:!0,children:d.jsx(HF,{selectedTool:i,toolArgs:g,isExecuting:w,isConnected:o,onArgChange:_e,onExecute:Be,onSave:ot,onCancel:()=>{A&&A.abort()}})}),d.jsx(Ho,{withHandle:!0}),d.jsx(Yn,{ref:Ye,defaultSize:60,children:d.jsx("div",{className:"flex flex-col h-full",children:d.jsx(GF,{results:lt,copiedResult:_,previewMode:G,serverId:a,readResource:r,onCopy:it,onDelete:qe,onFullscreen:At,onTogglePreview:()=>Y(!G),onMaximize:Nn,isMaximized:K})})})]})}),d.jsx(FF,{isOpen:H,requestName:Z,defaultPlaceholder:`${i?.name} - ${new Date().toLocaleString()}`,onRequestNameChange:ne,onSave:zn,onCancel:()=>V(!1)})]})}HW.displayName="ToolsTab";function lTe({isSearchExpanded:e,searchQuery:t,filteredRequestsCount:n,requestsCount:r,onSearchExpand:a,onSearchChange:o,onSearchBlur:i,onRejectAll:l,searchInputRef:u}){return d.jsxs("div",{className:"flex flex-row items-center justify-between p-4 sm:p-4 py-3 gap-2",children:[d.jsx("div",{className:"flex items-center gap-2 flex-1",children:e?d.jsx(Hn,{ref:u,placeholder:"Search requests...",value:t,onChange:f=>o(f.target.value),onBlur:i,className:"h-8 border-gray-300 dark:border-zinc-600"}):d.jsxs(d.Fragment,{children:[d.jsx("h2",{className:"text-lg font-medium text-gray-900 dark:text-gray-100",children:"Sampling"}),d.jsx(Dr,{className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",variant:"outline",children:n}),d.jsxs(Wt,{children:[d.jsx(Kt,{asChild:!0,children:d.jsx(Le,{variant:"ghost",size:"sm",onClick:a,className:"h-8 w-8 p-0",children:d.jsx(lf,{className:"h-4 w-4"})})}),d.jsxs(Yt,{side:"bottom",className:"flex gap-2",children:["Search",d.jsx(Sh,{children:"F"})]})]})]})}),d.jsx("div",{className:"flex items-center gap-2",children:d.jsxs(Wt,{children:[d.jsx(Kt,{asChild:!0,children:d.jsx(Le,{variant:"ghost",size:"sm",onClick:l,disabled:r===0,className:"h-8 w-8 p-0",children:d.jsx(ti,{className:"h-4 w-4"})})}),d.jsx(Yt,{side:"bottom",children:"Reject all"})]})})]})}function cTe({requests:e,selectedRequest:t,onRequestSelect:n,focusedIndex:r,formatRelativeTime:a,listRef:o}){return e.length===0?d.jsx("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:d.jsx(sf,{vertical:!0,noBorder:!0,message:"No sampling requests"})}):d.jsx("div",{ref:o,className:"overflow-y-auto flex-1 overscroll-contain",children:e.map((i,l)=>{const u=i.request.params?.messages?.length||0,f=i.request.params?.maxTokens;return d.jsx(El,{id:`sampling-request-${i.id}`,isSelected:t?.id===i.id,isFocused:r===l,title:d.jsxs("span",{className:"flex items-center gap-3",children:[i.serverName,d.jsx("span",{className:"size-1.5 block rounded-full bg-orange-500"})]}),description:(()=>{const m=a(i.timestamp),h=[];u>0&&h.push(`${u} message${u>1?"s":""}`),f&&h.push(`max ${f} tokens`);const g=h.length>0?` | ${h.join(", ")}`:"";return m+g})(),onClick:()=>n(i)},i.id)})})}function uTe({llmConfig:e}){const t=b.useRef(null);return{generateResponse:b.useCallback(async({request:r})=>{if(!e)throw new Error("LLM config is not available");const a=r.params||{},o=a.maxTokens,i=a.temperature;a.modelPreferences;const l=a.messages||[];if(console.log("[useSamplingLLM] Request structure:",{hasParams:!!a,messagesCount:l.length,messages:l,params:a}),l.length===0)throw new Error("No messages found in sampling request");const u=[],{HumanMessage:f,AIMessage:m}=await Ua(async()=>{const{HumanMessage:E,AIMessage:x}=await import("./index-D598FUk4.js").then(w=>w.bK);return{HumanMessage:E,AIMessage:x}},[]);for(const E of l){if(!E||!E.role){console.warn("Skipping invalid message:",E);continue}const x=Array.isArray(E.content)?E.content[0]:E.content;if(!x){console.warn("Skipping message with no content:",E);continue}x.type==="text"&&x.text?E.role==="user"?u.push(new f(x.text)):E.role==="assistant"&&u.push(new m(x.text)):console.warn("Skipping message with unsupported content type:",x)}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 E;const x={model:e.model,apiKey:e.apiKey};if(o!==void 0&&(x.maxTokens=o),i!==void 0?x.temperature=i:e.temperature!==void 0&&(x.temperature=e.temperature),e.provider==="openai"){const{ChatOpenAI:w}=await Ua(async()=>{const{ChatOpenAI:S}=await import("./index-DjyLCU4S.js");return{ChatOpenAI:S}},__vite__mapDeps([0,1,2,3,4,5]));E=new w(x)}else if(e.provider==="anthropic"){const{ChatAnthropic:w}=await Ua(async()=>{const{ChatAnthropic:S}=await import("./index-CdkiRJxS.js");return{ChatAnthropic:S}},__vite__mapDeps([6,2,1,5]));E=new w(x)}else if(e.provider==="google"){const{ChatGoogleGenerativeAI:w}=await Ua(async()=>{const{ChatGoogleGenerativeAI:S}=await import("./index-Dqcx9Dh4.js");return{ChatGoogleGenerativeAI:S}},__vite__mapDeps([7,2,1,4]));E=new w(x)}else throw new Error(`Unsupported LLM provider: ${e.provider}`);t.current={instance:E,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 dTe({request:e,onApprove:t,onReject:n,onClose:r,previewMode:a,onTogglePreview:o,isCopied:i,onCopy:l,onDownload:u,onFullscreen:f,llmConfig:m}){const[h,g]=b.useState("manual"),[y,E]=b.useState("stub-model"),[x,w]=b.useState("endTurn"),[S,_]=b.useState("assistant"),[T,A]=b.useState("text"),[R,k]=b.useState("positive"),[C,O]=b.useState(""),[M,L]=b.useState("image/png"),[$,H]=b.useState(!1),[V,Z]=b.useState(null),{generateResponse:ne,isAvailable:G}=uTe({llmConfig:m});b.useEffect(()=>{e&&(E("stub-model"),w("endTurn"),_("assistant"),A("text"),k("positive"),O(""),L("image/png"),Z(null))},[e?.id]);const Y=async()=>{if(!(!e||!G)){H(!0),Z(null);try{const j=await ne({request:e.request});E(j.model||m?.model||"stub-model"),w(j.stopReason||"endTurn"),_(j.role||"assistant");const B=Array.isArray(j.content)?j.content[0]:j.content;B.type==="text"?(A("text"),k(B.text||"")):B.type==="image"&&(A("image"),O(B.data||""),L(B.mimeType||"image/png"))}catch(j){const B=j instanceof Error?j.message:"Failed to generate response";Z(B),Nt.error("LLM Generation Failed",{description:B})}finally{H(!1)}}},F=b.useMemo(()=>{const j={model:y,stopReason:x,role:S,content:{type:T}};return T==="text"?j.content.text=R:T==="image"&&(j.content.data=C,j.content.mimeType=M),j},[y,x,S,T,R,C,M]),re=()=>{if(!e)return;const j=mN.safeParse(F);if(!j.success){Nt.error("Invalid response",{description:`Validation failed: ${j.error.message}`});return}t(e.id,j.data),r(),Ua(()=>Promise.resolve().then(()=>Ec),void 0).then(B=>{const z=Nt(B.createElement("div",{className:"space-y-3"},B.createElement("div",null,B.createElement("strong",null,"Sampling Response Sent"),B.createElement("p",{className:"text-sm text-muted-foreground mt-1"},"The tool will continue executing.")),B.createElement("div",{className:"flex gap-2"},B.createElement("button",{className:"px-3 py-1.5 text-xs font-medium rounded-md bg-primary text-primary-foreground hover:bg-primary/90",onClick:()=>{const D=new globalThis.CustomEvent("navigate-to-tool-result",{detail:{toolName:e.toolName}});window.dispatchEvent(D),Nt.dismiss(z)}},"View Tool Result"))),{duration:5e3})})},ee=()=>{e&&(n(e.id,"User rejected sampling request"),r())};return e?d.jsxs("div",{className:"flex flex-col h-full",children:[d.jsxs("div",{className:"flex items-center justify-between p-4 border-b dark:border-zinc-700",children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("h3",{className:"font-medium text-gray-900 dark:text-gray-100",children:e.serverName}),d.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:new Date(e.timestamp).toLocaleString()})]}),d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsxs(Wt,{children:[d.jsx(Kt,{asChild:!0,children:d.jsx(Le,{variant:"ghost",size:"sm",onClick:l,className:"h-8 w-8 p-0",children:i?d.jsx(Or,{className:"h-4 w-4 text-green-600"}):d.jsx(wr,{className:"h-4 w-4"})})}),d.jsx(Yt,{children:"Copy request"})]}),d.jsxs(Wt,{children:[d.jsx(Kt,{asChild:!0,children:d.jsx(Le,{variant:"ghost",size:"sm",onClick:u,className:"h-8 w-8 p-0",children:d.jsx(rh,{className:"h-4 w-4"})})}),d.jsx(Yt,{children:"Download request"})]}),d.jsxs(Wt,{children:[d.jsx(Kt,{asChild:!0,children:d.jsx(Le,{variant:"ghost",size:"sm",onClick:f,className:"h-8 w-8 p-0",children:d.jsx(JN,{className:"h-4 w-4"})})}),d.jsx(Yt,{children:"Fullscreen"})]}),d.jsx(Le,{variant:"ghost",size:"sm",onClick:r,className:"h-8 w-8 p-0",children:d.jsx(ys,{className:"h-4 w-4"})})]})]}),d.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-6",children:[d.jsxs("div",{className:"space-y-2",children:[d.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:"Request"}),d.jsx("div",{className:"bg-muted rounded-lg p-3 max-h-64 overflow-auto",children:d.jsx(yr,{data:e.request})})]}),d.jsxs("div",{className:"space-y-4",children:[d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:"Response"}),d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(wn,{htmlFor:`responseMode-${e.id}`,className:"text-xs text-gray-500 dark:text-gray-400",children:"Mode:"}),d.jsxs(Ys,{value:h,onValueChange:j=>g(j),children:[d.jsx(qs,{id:`responseMode-${e.id}`,className:"w-32 h-8 text-xs",children:d.jsx(Zs,{})}),d.jsxs(Xs,{children:[d.jsx(fa,{value:"manual",children:"Manual"}),d.jsx(fa,{value:"llm",children:"LLM"})]})]})]})]}),h==="llm"&&d.jsxs("div",{className:"space-y-2 p-3 bg-muted rounded-lg",children:[G?d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(Le,{onClick:Y,disabled:$,size:"sm",className:"flex items-center gap-2",children:$?d.jsxs(d.Fragment,{children:[d.jsx(cl,{className:"h-4 w-4 animate-spin"}),"Generating..."]}):d.jsxs(d.Fragment,{children:[d.jsx(hde,{className:"h-4 w-4"}),"Generate with LLM"]})}),d.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:["Using ",m?.provider," (",m?.model,")"]})]}):d.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:"LLM not configured. Please configure LLM in the Chat tab."}),V&&d.jsx("div",{className:"text-xs text-red-600 dark:text-red-400",children:V})]}),d.jsxs("div",{className:"space-y-2",children:[d.jsx(wn,{htmlFor:`model-${e.id}`,children:"Model"}),d.jsx(Hn,{id:`model-${e.id}`,value:y,onChange:j=>E(j.target.value),placeholder:"stub-model",disabled:h==="llm"&&$})]}),d.jsxs("div",{className:"space-y-2",children:[d.jsx(wn,{htmlFor:`stopReason-${e.id}`,children:"Stop Reason"}),d.jsx(Hn,{id:`stopReason-${e.id}`,value:x,onChange:j=>w(j.target.value),placeholder:"endTurn",disabled:h==="llm"&&$})]}),d.jsxs("div",{className:"space-y-2",children:[d.jsx(wn,{htmlFor:`role-${e.id}`,children:"Role"}),d.jsxs(Ys,{value:S,onValueChange:j=>_(j),disabled:h==="llm"&&$,children:[d.jsx(qs,{id:`role-${e.id}`,children:d.jsx(Zs,{})}),d.jsxs(Xs,{children:[d.jsx(fa,{value:"assistant",children:"assistant"}),d.jsx(fa,{value:"user",children:"user"})]})]})]}),d.jsxs("div",{className:"space-y-2",children:[d.jsx(wn,{htmlFor:`contentType-${e.id}`,children:"Content Type"}),d.jsxs(Ys,{value:T,onValueChange:j=>A(j),disabled:h==="llm"&&$,children:[d.jsx(qs,{id:`contentType-${e.id}`,children:d.jsx(Zs,{})}),d.jsxs(Xs,{children:[d.jsx(fa,{value:"text",children:"text"}),d.jsx(fa,{value:"image",children:"image"})]})]})]}),T==="text"&&d.jsxs("div",{className:"space-y-2",children:[d.jsx(wn,{htmlFor:`text-${e.id}`,children:"Text Content"}),d.jsx(bc,{id:`text-${e.id}`,value:R,onChange:j=>k(j.target.value),placeholder:"Enter response text...",rows:6,disabled:h==="llm"&&$})]}),T==="image"&&d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"space-y-2",children:[d.jsx(wn,{htmlFor:`imageData-${e.id}`,children:"Base64 Image Data"}),d.jsx(bc,{id:`imageData-${e.id}`,value:C,onChange:j=>O(j.target.value),placeholder:"Base64 encoded image data...",rows:4,disabled:h==="llm"&&$})]}),d.jsxs("div",{className:"space-y-2",children:[d.jsx(wn,{htmlFor:`mimeType-${e.id}`,children:"MIME Type"}),d.jsx(Hn,{id:`mimeType-${e.id}`,value:M,onChange:j=>L(j.target.value),placeholder:"image/png",disabled:h==="llm"&&$})]})]})]})]}),d.jsxs("div",{className:"flex gap-2 p-4 border-t dark:border-zinc-700",children:[d.jsx(Le,{onClick:re,className:"flex-1",disabled:h==="llm"&&$,children:"Approve"}),d.jsx(Le,{onClick:ee,variant:"outline",className:"flex-1",disabled:h==="llm"&&$,children:"Reject"})]})]}):d.jsx("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:d.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"Select a sampling request to view details"})})}const fTe={model:"stub-model",stopReason:"endTurn",role:"assistant",content:{type:"text",text:"positive"}};function pTe({requestId:e,serverName:t,onViewDetails:n,onApprove:r,onDeny:a}){return d.jsxs("div",{className:"space-y-3",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"Sampling Request Received"}),d.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:["New request from ",t]})]}),d.jsxs("div",{className:"flex gap-2",children:[d.jsx("button",{className:"px-3 py-1.5 text-xs font-medium rounded-md hover:bg-accent hover:text-accent-foreground",onClick:o=>{o.stopPropagation(),n()},children:"View Details"}),d.jsx("button",{className:"px-3 py-1.5 text-xs font-medium rounded-md hover:bg-accent hover:text-accent-foreground",onClick:o=>{o.stopPropagation(),r(fTe)},children:"Approve"}),d.jsx("button",{className:"px-3 py-1.5 text-xs font-medium rounded-md hover:bg-accent hover:text-accent-foreground",onClick:o=>{o.stopPropagation(),a()},children:"Deny"})]})]})}function mTe({pendingRequests:e,onApprove:t,onReject:n,serverId:r,isConnected:a,mcpServerUrl:o}){const{selectedSamplingRequestId:i,setSelectedSamplingRequestId:l}=kc(),{llmConfig:u}=gW({mcpServerUrl:o}),[f,m]=b.useState(null),[h,g]=b.useState(""),[y,E]=b.useState(-1),[x,w]=b.useState(!0),[S,_]=b.useState(!1),[T,A]=b.useState(!0),[R,k]=b.useState(!1),C=b.useRef(null),O=b.useRef(null),M=b.useRef(null),L=b.useRef(!1);b.useEffect(()=>{if(console.log("[SamplingTab] Auto-selection check:",{selectedSamplingRequestId:i,pendingRequestsCount:e.length,currentSelectedId:f?.id}),i&&e.length>0){const F=e.find(re=>re.id===i);console.log("[SamplingTab] Found request for auto-selection:",!!F,F?.id),F&&(console.log("[SamplingTab] Auto-selecting request:",F.id),l(null),m(F),setTimeout(()=>{const re=document.getElementById(`sampling-request-${F.id}`);console.log("[SamplingTab] Scrolling to element:",!!re),re&&re.scrollIntoView({behavior:"smooth",block:"nearest"})},100))}},[i,e,l]),b.useEffect(()=>{const F=re=>{const j=re.detail.requestId;console.log("[SamplingTab] Custom navigate event received:",j);const B=e.find(z=>z.id===j);B&&(console.log("[SamplingTab] Selecting request from event:",j),m(B),setTimeout(()=>{const z=document.getElementById(`sampling-request-${j}`);z&&z.scrollIntoView({behavior:"smooth",block:"nearest"})},200))};return window.addEventListener("navigate-to-sampling",F),()=>window.removeEventListener("navigate-to-sampling",F)},[e]),b.useEffect(()=>{x&&e.length>0&&C.current&&!L.current&&(C.current.scrollTop=0)},[e.length,x]),b.useEffect(()=>{const F=C.current;if(!F)return;const re=()=>{F.scrollTop>0&&(L.current=!0,w(!1))};return F.addEventListener("scroll",re),()=>F.removeEventListener("scroll",re)},[]),b.useEffect(()=>{e.length===0&&(L.current=!1,w(!0))},[e.length]),b.useEffect(()=>{S&&M.current&&M.current.focus()},[S]);const $=b.useCallback(()=>{h.trim()||_(!1)},[h]),H=b.useMemo(()=>{if(!h.trim())return e;const F=h.toLowerCase();return e.filter(re=>re.serverName.toLowerCase().includes(F)||JSON.stringify(re.request||{}).toLowerCase().includes(F))},[e,h]);b.useEffect(()=>{E(-1)},[h]),b.useEffect(()=>{const F=re=>{const ee=re.target;if(ee.tagName==="INPUT"||ee.tagName==="TEXTAREA"||ee.contentEditable==="true"||re.metaKey||re.ctrlKey||re.altKey)return;const B=H;if(re.key==="ArrowDown")re.preventDefault(),E(z=>{const D=z+1;return D>=B.length?0:D});else if(re.key==="ArrowUp")re.preventDefault(),E(z=>{const D=z-1;return D<0?B.length-1:D});else if(re.key==="Enter"&&y>=0){re.preventDefault();const z=H[y];z&&V(z)}};return document.addEventListener("keydown",F),()=>document.removeEventListener("keydown",F)},[y,H]),b.useEffect(()=>{if(y>=0){const F=`sampling-request-${H[y]?.id}`,re=document.getElementById(F);re&&re.scrollIntoView({behavior:"smooth",block:"nearest"})}},[y,H]);const V=b.useCallback(F=>{m(F)},[]),Z=b.useCallback(()=>{window.confirm("Are you sure you want to reject all sampling requests? This cannot be undone.")&&(e.forEach(F=>{n(F.id,"User rejected all requests")}),m(null))},[e,n]),ne=b.useCallback(async()=>{if(f)try{await navigator.clipboard.writeText(JSON.stringify({id:f.id,serverName:f.serverName,timestamp:f.timestamp,request:f.request},null,2)),k(!0),setTimeout(()=>k(!1),2e3)}catch(F){console.error("[SamplingTab] Failed to copy request:",F)}},[f]),G=b.useCallback(()=>{if(f)try{const F=new globalThis.Blob([JSON.stringify({id:f.id,serverName:f.serverName,timestamp:f.timestamp,request:f.request},null,2)],{type:"application/json"}),re=URL.createObjectURL(F),ee=document.createElement("a");ee.href=re,ee.download=`sampling-request-${Date.now()}.json`,document.body.appendChild(ee),ee.click(),document.body.removeChild(ee),URL.revokeObjectURL(re)}catch(F){console.error("[SamplingTab] Failed to download request:",F)}},[f]),Y=b.useCallback(async()=>{if(O.current)try{document.fullscreenElement?await document.exitFullscreen():await O.current.requestFullscreen()}catch(F){console.error("[SamplingTab] Failed to toggle fullscreen:",F)}},[]);return a?d.jsxs(Ta,{direction:"horizontal",className:"h-full",children:[d.jsx(Yn,{defaultSize:40,minSize:30,children:d.jsx(Ta,{direction:"vertical",className:"h-full border-r dark:border-zinc-700",children:d.jsxs(Yn,{defaultSize:75,minSize:30,children:[d.jsx(lTe,{isSearchExpanded:S,searchQuery:h,filteredRequestsCount:H.length,requestsCount:e.length,onSearchExpand:()=>_(!0),onSearchChange:g,onSearchBlur:$,onRejectAll:Z,searchInputRef:M}),d.jsx("div",{className:"flex flex-col h-full",children:d.jsx(cTe,{requests:H,selectedRequest:f,onRequestSelect:V,focusedIndex:y,formatRelativeTime:_v,listRef:C})})]})})}),d.jsx(Ho,{}),d.jsx(Yn,{defaultSize:60,minSize:40,children:d.jsx("div",{ref:O,className:"h-full bg-white dark:bg-zinc-900",children:d.jsx(dTe,{request:f,onApprove:t,onReject:n,onClose:()=>m(null),previewMode:T,onTogglePreview:()=>A(!T),isCopied:R,onCopy:ne,onDownload:G,onFullscreen:Y,llmConfig:u})})})]}):d.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[d.jsx(VH,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),d.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"Not connected to server"})]})}function hTe({isSearchExpanded:e,searchQuery:t,filteredRequestsCount:n,requestsCount:r,onSearchExpand:a,onSearchChange:o,onSearchBlur:i,onCancelAll:l,searchInputRef:u}){return d.jsxs("div",{className:"flex flex-row items-center justify-between p-4 sm:p-4 py-3 gap-2",children:[d.jsx("div",{className:"flex items-center gap-2 flex-1",children:e?d.jsx(Hn,{ref:u,placeholder:"Search requests...",value:t,onChange:f=>o(f.target.value),onBlur:i,className:"h-8 border-gray-300 dark:border-zinc-600"}):d.jsxs(d.Fragment,{children:[d.jsx("h2",{className:"text-lg font-medium text-gray-900 dark:text-gray-100",children:"Elicitation"}),d.jsx(Dr,{className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",variant:"outline",children:n}),d.jsxs(Wt,{children:[d.jsx(Kt,{asChild:!0,children:d.jsx(Le,{variant:"ghost",size:"sm",onClick:a,className:"h-8 w-8 p-0",children:d.jsx(lf,{className:"h-4 w-4"})})}),d.jsxs(Yt,{side:"bottom",className:"flex gap-2",children:["Search",d.jsx(Sh,{children:"F"})]})]})]})}),d.jsx("div",{className:"flex items-center gap-2",children:d.jsxs(Wt,{children:[d.jsx(Kt,{asChild:!0,children:d.jsx(Le,{variant:"ghost",size:"sm",onClick:l,disabled:r===0,className:"h-8 w-8 p-0",children:d.jsx(ys,{className:"h-4 w-4"})})}),d.jsx(Yt,{side:"bottom",children:"Cancel all"})]})})]})}function gTe({requests:e,selectedRequest:t,onRequestSelect:n,focusedIndex:r,formatRelativeTime:a,listRef:o}){return e.length===0?d.jsx("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:d.jsx(sf,{vertical:!0,noBorder:!0,message:"No elicitation requests"})}):d.jsx("div",{ref:o,className:"overflow-y-auto flex-1 overscroll-contain",children:e.map((i,l)=>{const u=i.request.mode||"form",f=u==="form"&&"requestedSchema"in i.request&&i.request.requestedSchema;return d.jsx(El,{id:`elicitation-request-${i.id}`,isSelected:t?.id===i.id,isFocused:r===l,title:d.jsxs("span",{className:"flex items-center gap-3",children:[i.serverName,d.jsx(Dr,{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=a(i.timestamp),h=[];f&&h.push("with schema"),u==="url"&&h.push("external action");const g=h.length>0?` | ${h.join(", ")}`:"";return m+g})(),onClick:()=>n(i)},i.id)})})}function bTe({request:e,onApprove:t,onReject:n,onClose:r,previewMode:a,onTogglePreview:o,isCopied:i,onCopy:l,onDownload:u,onFullscreen:f}){const[m,h]=b.useState({}),[g,y]=b.useState(!1),E=e?.request.mode||"form",x=E==="form",w=E==="url";b.useEffect(()=>{if(e&&x&&"requestedSchema"in e.request){const C=e.request.requestedSchema,O={};if(C?.type==="object"&&C.properties)for(const[M,L]of Object.entries(C.properties)){const $=L;$.default!==void 0?O[M]=$.default:$.type==="boolean"?O[M]=!1:$.type==="number"||$.type==="integer"?O[M]=0:O[M]=""}h(O)}y(!1)},[e?.id,x]);const S=(C,O)=>{h(M=>({...M,[C]:O}))},_=()=>{if(e){if(x){if("requestedSchema"in e.request){const C=e.request.requestedSchema;if(C?.required){const O=C.required.filter(M=>m[M]===void 0||m[M]===""||m[M]===null);if(O.length>0){Nt.error("Missing required fields",{description:`Please fill in: ${O.join(", ")}`});return}}}t(e.id,{action:"accept",data:m})}else w&&t(e.id,{action:"accept"});r(),Ua(()=>Promise.resolve().then(()=>Ec),void 0).then(C=>{const O=Nt(C.createElement("div",{className:"space-y-3"},C.createElement("div",null,C.createElement("strong",null,"Elicitation Response Sent"),C.createElement("p",{className:"text-sm text-muted-foreground mt-1"},"The tool will continue executing.")),C.createElement("div",{className:"flex gap-2"},C.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),Nt.dismiss(O)}},"View Tool Result"))),{duration:5e3})})}},T=()=>{e&&(t(e.id,{action:"decline"}),r())},A=()=>{e&&(n(e.id,"User cancelled elicitation request"),r())},R=()=>{e&&w&&"url"in e.request&&(window.open(e.request.url,"_blank"),y(!0))},k=b.useMemo(()=>{if(!e||!x||!("requestedSchema"in e.request))return null;const C=e.request.requestedSchema;if(!C||C.type!=="object"||!C.properties)return d.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:"No form schema available"});const O=C.properties,M=C.required||[];return d.jsx("div",{className:"space-y-4",children:Object.entries(O).map(([L,$])=>{const H=$,V=M.includes(L),Z=H.type||"string",ne=H.title||L,G=H.description;return d.jsxs("div",{className:"space-y-2",children:[d.jsxs(wn,{htmlFor:`field-${L}`,children:[ne,V&&d.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),G&&d.jsx("p",{className:"text-xs text-muted-foreground",children:G}),Z==="boolean"?d.jsxs("div",{className:"flex items-center space-x-2",children:[d.jsx(Pm,{id:`field-${L}`,checked:m[L]||!1,onCheckedChange:Y=>S(L,Y)}),d.jsx(wn,{htmlFor:`field-${L}`,className:"text-sm font-normal cursor-pointer",children:H.title||L})]}):Z==="number"||Z==="integer"?d.jsx(Hn,{id:`field-${L}`,type:"number",value:m[L]||"",onChange:Y=>S(L,Z==="integer"?parseInt(Y.target.value,10):parseFloat(Y.target.value)),placeholder:H.default?.toString()||""}):H.enum?d.jsxs("select",{id:`field-${L}`,value:m[L]||"",onChange:Y=>S(L,Y.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:[d.jsx("option",{value:"",children:"Select..."}),H.enum.map(Y=>d.jsx("option",{value:Y,children:Y},Y))]}):Z==="string"&&(H.format==="textarea"||H.maxLength>100)?d.jsx(bc,{id:`field-${L}`,value:m[L]||"",onChange:Y=>S(L,Y.target.value),placeholder:H.default||"",rows:4}):d.jsx(Hn,{id:`field-${L}`,type:"text",value:m[L]||"",onChange:Y=>S(L,Y.target.value),placeholder:H.default||""})]},L)})})},[e,m,x]);return e?d.jsxs("div",{className:"flex flex-col h-full",children:[d.jsxs("div",{className:"flex items-center justify-between p-4 border-b dark:border-zinc-700",children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("h3",{className:"font-medium text-gray-900 dark:text-gray-100",children:e.serverName}),d.jsx(Dr,{variant:"outline",className:w?"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:E}),d.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:new Date(e.timestamp).toLocaleString()})]}),d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsxs(Wt,{children:[d.jsx(Kt,{asChild:!0,children:d.jsx(Le,{variant:"ghost",size:"sm",onClick:l,className:"h-8 w-8 p-0",children:i?d.jsx(Or,{className:"h-4 w-4 text-green-600"}):d.jsx(wr,{className:"h-4 w-4"})})}),d.jsx(Yt,{children:"Copy request"})]}),d.jsxs(Wt,{children:[d.jsx(Kt,{asChild:!0,children:d.jsx(Le,{variant:"ghost",size:"sm",onClick:u,className:"h-8 w-8 p-0",children:d.jsx(rh,{className:"h-4 w-4"})})}),d.jsx(Yt,{children:"Download request"})]}),d.jsxs(Wt,{children:[d.jsx(Kt,{asChild:!0,children:d.jsx(Le,{variant:"ghost",size:"sm",onClick:f,className:"h-8 w-8 p-0",children:d.jsx(JN,{className:"h-4 w-4"})})}),d.jsx(Yt,{children:"Fullscreen"})]}),d.jsx(Le,{variant:"ghost",size:"sm",onClick:r,className:"h-8 w-8 p-0",children:d.jsx(ys,{className:"h-4 w-4"})})]})]}),d.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-6",children:[d.jsxs("div",{className:"space-y-2",children:[d.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:"Message"}),d.jsx("p",{className:"text-sm text-gray-700 dark:text-gray-300",children:e.request.message})]}),w&&"url"in e.request&&d.jsxs("div",{className:"space-y-2",children:[d.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:"External Action Required"}),d.jsxs("div",{className:"bg-muted rounded-lg p-4 space-y-3",children:[d.jsx("p",{className:"text-sm text-muted-foreground",children:"This request requires you to complete an action at an external URL:"}),d.jsxs("div",{className:"flex items-center gap-2 p-2 bg-background rounded border",children:[d.jsx("code",{className:"flex-1 text-xs font-mono break-all",children:e.request.url}),d.jsxs(Le,{size:"sm",variant:"outline",onClick:R,className:"flex items-center gap-2",children:[d.jsx(f_,{className:"h-4 w-4"}),"Open URL"]})]}),d.jsxs("div",{className:"flex items-center space-x-2 pt-2",children:[d.jsx(Pm,{id:"url-completed",checked:g,onCheckedChange:C=>y(!!C)}),d.jsx(wn,{htmlFor:"url-completed",className:"text-sm font-normal cursor-pointer",children:"I have completed the required action"})]})]})]}),x&&d.jsxs("div",{className:"space-y-2",children:[d.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:"Form Data"}),k]}),x&&"requestedSchema"in e.request&&e.request.requestedSchema&&d.jsxs("details",{className:"space-y-2",children:[d.jsx("summary",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100 cursor-pointer",children:"Schema (for reference)"}),d.jsx("div",{className:"bg-muted rounded-lg p-3 max-h-64 overflow-auto",children:d.jsx(yr,{data:e.request.requestedSchema})})]})]}),d.jsxs("div",{className:"flex gap-2 p-4 border-t dark:border-zinc-700",children:[d.jsx(Le,{onClick:_,className:"flex-1",children:"Accept"}),d.jsx(Le,{onClick:T,variant:"outline",className:"flex-1",children:"Decline"}),d.jsx(Le,{onClick:A,variant:"outline",className:"flex-1",children:"Cancel"})]})]}):d.jsx("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:d.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"Select an elicitation request to view details"})})}function yTe({pendingRequests:e=[],onApprove:t,onReject:n,serverId:r,isConnected:a}){const{selectedElicitationRequestId:o,setSelectedElicitationRequestId:i}=kc(),[l,u]=b.useState(null),[f,m]=b.useState(""),[h,g]=b.useState(-1),[y,E]=b.useState(!0),[x,w]=b.useState(!1),[S,_]=b.useState(!0),[T,A]=b.useState(!1),R=b.useRef(null),k=b.useRef(null),C=b.useRef(null),O=b.useRef(!1);b.useEffect(()=>{if(console.log("[ElicitationTab] Auto-selection check:",{selectedElicitationRequestId:o,pendingRequestsCount:e.length,currentSelectedId:l?.id}),o&&e.length>0){const G=e.find(Y=>Y.id===o);console.log("[ElicitationTab] Found request for auto-selection:",!!G,G?.id),G&&(console.log("[ElicitationTab] Auto-selecting request:",G.id),i(null),u(G),setTimeout(()=>{const Y=document.getElementById(`elicitation-request-${G.id}`);console.log("[ElicitationTab] Scrolling to element:",!!Y),Y&&Y.scrollIntoView({behavior:"smooth",block:"nearest"})},100))}},[o,e,i]),b.useEffect(()=>{const G=Y=>{const re=Y.detail.requestId;console.log("[ElicitationTab] Custom navigate event received:",re);const ee=e.find(j=>j.id===re);ee&&(console.log("[ElicitationTab] Selecting request from event:",re),u(ee),setTimeout(()=>{const j=document.getElementById(`elicitation-request-${re}`);j&&j.scrollIntoView({behavior:"smooth",block:"nearest"})},200))};return window.addEventListener("navigate-to-elicitation",G),()=>window.removeEventListener("navigate-to-elicitation",G)},[e]),b.useEffect(()=>{y&&e.length>0&&R.current&&!O.current&&(R.current.scrollTop=0)},[e.length,y]),b.useEffect(()=>{const G=R.current;if(!G)return;const Y=()=>{G.scrollTop>0&&(O.current=!0,E(!1))};return G.addEventListener("scroll",Y),()=>G.removeEventListener("scroll",Y)},[]),b.useEffect(()=>{e.length===0&&(O.current=!1,E(!0))},[e.length]),b.useEffect(()=>{x&&C.current&&C.current.focus()},[x]);const M=b.useCallback(()=>{f.trim()||w(!1)},[f]),L=b.useMemo(()=>{if(!f.trim())return e;const G=f.toLowerCase();return e.filter(Y=>Y.serverName.toLowerCase().includes(G)||Y.request.message.toLowerCase().includes(G)||JSON.stringify(Y.request||{}).toLowerCase().includes(G))},[e,f]);b.useEffect(()=>{g(-1)},[f]),b.useEffect(()=>{const G=Y=>{const F=Y.target;if(F.tagName==="INPUT"||F.tagName==="TEXTAREA"||F.contentEditable==="true"||Y.metaKey||Y.ctrlKey||Y.altKey)return;const ee=L;if(Y.key==="ArrowDown")Y.preventDefault(),g(j=>{const B=j+1;return B>=ee.length?0:B});else if(Y.key==="ArrowUp")Y.preventDefault(),g(j=>{const B=j-1;return B<0?ee.length-1:B});else if(Y.key==="Enter"&&h>=0){Y.preventDefault();const j=L[h];j&&$(j)}};return document.addEventListener("keydown",G),()=>document.removeEventListener("keydown",G)},[h,L]),b.useEffect(()=>{if(h>=0){const G=`elicitation-request-${L[h]?.id}`,Y=document.getElementById(G);Y&&Y.scrollIntoView({behavior:"smooth",block:"nearest"})}},[h,L]);const $=b.useCallback(G=>{u(G)},[]),H=b.useCallback(()=>{window.confirm("Are you sure you want to cancel all elicitation requests? This cannot be undone.")&&(e.forEach(G=>{n(G.id,"User cancelled all requests")}),u(null))},[e,n]),V=b.useCallback(async()=>{if(l)try{await navigator.clipboard.writeText(JSON.stringify({id:l.id,serverName:l.serverName,timestamp:l.timestamp,request:l.request},null,2)),A(!0),setTimeout(()=>A(!1),2e3)}catch(G){console.error("[ElicitationTab] Failed to copy request:",G)}},[l]),Z=b.useCallback(()=>{if(l)try{const G=new globalThis.Blob([JSON.stringify({id:l.id,serverName:l.serverName,timestamp:l.timestamp,request:l.request},null,2)],{type:"application/json"}),Y=URL.createObjectURL(G),F=document.createElement("a");F.href=Y,F.download=`elicitation-request-${Date.now()}.json`,document.body.appendChild(F),F.click(),document.body.removeChild(F),URL.revokeObjectURL(Y)}catch(G){console.error("[ElicitationTab] Failed to download request:",G)}},[l]),ne=b.useCallback(async()=>{if(k.current)try{document.fullscreenElement?await document.exitFullscreen():await k.current.requestFullscreen()}catch(G){console.error("[ElicitationTab] Failed to toggle fullscreen:",G)}},[]);return a?d.jsxs(Ta,{direction:"horizontal",className:"h-full",children:[d.jsx(Yn,{defaultSize:40,minSize:30,children:d.jsx(Ta,{direction:"vertical",className:"h-full border-r dark:border-zinc-700",children:d.jsxs(Yn,{defaultSize:75,minSize:30,children:[d.jsx(hTe,{isSearchExpanded:x,searchQuery:f,filteredRequestsCount:L.length,requestsCount:e.length,onSearchExpand:()=>w(!0),onSearchChange:m,onSearchBlur:M,onCancelAll:H,searchInputRef:C}),d.jsx("div",{className:"flex flex-col h-full",children:d.jsx(gTe,{requests:L,selectedRequest:l,onRequestSelect:$,focusedIndex:h,formatRelativeTime:_v,listRef:R})})]})})}),d.jsx(Ho,{}),d.jsx(Yn,{defaultSize:60,minSize:40,children:d.jsx("div",{ref:k,className:"h-full bg-white dark:bg-zinc-900",children:d.jsx(bTe,{request:l,onApprove:t,onReject:n,onClose:()=>u(null),previewMode:S,onTogglePreview:()=>_(!S),isCopied:T,onCopy:V,onDownload:Z,onFullscreen:ne})})})]}):d.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[d.jsx(ZH,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),d.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"Not connected to server"})]})}function vTe({selectedServer:e,activeTab:t,toolsSearchRef:n,promptsSearchRef:r,resourcesSearchRef:a,children:o}){return e?d.jsxs(d.Fragment,{children:[d.jsx("div",{style:{display:t==="tools"?"block":"none"},className:"h-full",children:d.jsx(HW,{ref:n,tools:e.tools,callTool:e.callTool,readResource:e.readResource,serverId:e.id,isConnected:e.state==="ready"})}),d.jsx("div",{style:{display:t==="prompts"?"block":"none"},className:"h-full",children:d.jsx(UW,{ref:r,prompts:e.prompts,callPrompt:e.getPrompt,serverId:e.id,isConnected:e.state==="ready"})}),d.jsx("div",{style:{display:t==="resources"?"block":"none"},className:"h-full",children:d.jsx(FW,{ref:a,resources:e.resources,readResource:e.readResource,serverId:e.id,isConnected:e.state==="ready"})}),d.jsx("div",{style:{display:t==="chat"?"block":"none"},className:"h-full",children:d.jsx(m_e,{connection:e,isConnected:e.state==="ready",readResource:e.readResource},e.id)}),d.jsx("div",{style:{display:t==="sampling"?"block":"none"},className:"h-full",children:d.jsx(mTe,{pendingRequests:e.pendingSamplingRequests,onApprove:e.approveSampling,onReject:e.rejectSampling,serverId:e.id,isConnected:e.state==="ready",mcpServerUrl:e.url})}),d.jsx("div",{style:{display:t==="elicitation"?"block":"none"},className:"h-full",children:d.jsx(yTe,{pendingRequests:e.pendingElicitationRequests,onApprove:e.approveElicitation,onReject:e.rejectElicitation,serverId:e.id,isConnected:e.state==="ready"})}),d.jsx("div",{style:{display:t==="notifications"?"block":"none"},className:"h-full",children:d.jsx(W_e,{notifications:e.notifications,unreadCount:e.unreadNotificationCount,markNotificationRead:e.markNotificationRead,markAllNotificationsRead:e.markAllNotificationsRead,clearNotifications:e.clearNotifications,serverId:e.id,isConnected:e.state==="ready"})}),t!=="tools"&&t!=="prompts"&&t!=="resources"&&t!=="chat"&&t!=="sampling"&&t!=="elicitation"&&t!=="notifications"&&d.jsx(d.Fragment,{children:o})]}):d.jsx(d.Fragment,{children:o})}function ZF({className:e}){return d.jsxs("svg",{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",className:e,children:[d.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"}),d.jsx("path",{d:"M9 18c-4.51 2-5-2-7-2"})]})}const VW=b.createContext(void 0);function GW(){const e=b.use(VW);if(!e)throw new Error("useTabs must be used within a TabsProvider");return e}const WW=b.createContext(void 0);function wTe(){return b.use(WW)}function zT({ref:e,children:t,defaultValue:n,value:r,onValueChange:a,className:o,collapsed:i,onCollapsedChange:l,...u}){const[f,m]=b.useState(n||""),h=r!==void 0,g=i!==void 0,[y,E]=b.useState(!1),x=b.useCallback(T=>{h||m(T),a?.(T)},[h,a]),w=h?r:f,S=g?i:y,_=b.useCallback(T=>{g||E(T),l?.(T)},[g,l]);return d.jsx(VW,{value:{activeValue:w,handleValueChange:x,collapsed:S,handleCollapsedChange:_},children:d.jsx("div",{ref:e,className:Fe("flex flex-col gap-2",o),...u,children:t})})}zT.displayName="Tabs";function FT({ref:e,children:t,className:n,variant:r="default",collapsible:a=!1,...o}){const{activeValue:i,collapsed:l,handleCollapsedChange:u}=GW(),[f,m]=b.useState({width:0,left:0}),h=b.useRef(null),g=b.useRef(null),y=b.useRef(null),E=b.useCallback(()=>{const S=h.current;if(!S)return;const _=S.querySelector("div:first-child");if(!_)return;const T=_.querySelector(`button[data-tab-value="${i}"]`);if(T&&i){const A=_.getBoundingClientRect(),R=T.getBoundingClientRect();m({width:R.width,left:R.left-A.left})}else m({width:0,left:0})},[i]),x=b.useCallback(()=>{y.current&&clearTimeout(y.current),y.current=setTimeout(E,16)},[E]);b.useEffect(()=>{const S=setTimeout(E,10);return()=>clearTimeout(S)},[E,l]),b.useEffect(()=>{const S=h.current;if(!S)return;g.current=new ResizeObserver(()=>{x()}),g.current.observe(S);const _=S.querySelector("div:first-child");return _&&_.querySelectorAll("button[data-tab-value]").forEach(A=>{g.current&&g.current.observe(A)}),()=>{g.current&&g.current.disconnect(),y.current&&clearTimeout(y.current)}},[x]),b.useEffect(()=>{const S=()=>{x()};return window.addEventListener("resize",S),()=>window.removeEventListener("resize",S)},[x]);const w=b.useRef(null);return b.useEffect(()=>{w.current&&(w.current.style.width=`${f.width}px`,w.current.style.left=`${f.left}px`)},[f]),d.jsx(WW,{value:{variant:r,collapsed:l,handleCollapsedChange:u},children:d.jsx("div",{ref:h,className:Fe("relative flex items-center bg-none gap-1",r==="default"&&"p-1 rounded-full border border-zinc-300 dark:border-zinc-600",r==="underline"&&"border-b border-zinc-200 dark:border-zinc-700",n),...o,children:d.jsxs("div",{role:"tablist",className:"flex-1 flex items-center relative",children:[t,d.jsx("span",{ref:w,className:Fe("absolute transition-all duration-500 ease-in-out z-0",r==="default"&&"bg-white dark:bg-zinc-700 rounded-full h-[calc(100%)] top-0 border border-zinc-300 dark:border-zinc-600",r==="underline"&&"bottom-0 h-0.5 bg-black dark:bg-white")})]})})})}FT.displayName="TabsList";const xTe=({children:e,title:t,collapsed:n})=>!t||!n?e:d.jsx(YN,{children:d.jsxs(Wt,{children:[d.jsx(Kt,{children:e}),d.jsx(Yt,{children:t})]})}),BT=b.forwardRef(({children:e,value:t,className:n,disabled:r,icon:a,title:o,showDot:i=!1,...l},u)=>{const{activeValue:f,handleValueChange:m,collapsed:h}=GW(),y=wTe()?.variant||"default",E=f===t,x=h&&o?o:void 0;return d.jsx(xTe,{title:o,collapsed:h,children:d.jsxs("button",{ref:u,disabled:r,onClick:()=>m(t),"data-tab-value":t,"data-tab-active":E,role:"tab","aria-selected":E?"true":"false",title:x,className:Fe("relative z-10 flex-1 inline-flex items-center justify-center whitespace-nowrap text-sm font-medium ring-offset-background transition-all duration-500 ease-in-out 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",y==="default"&&"py-2.5",y==="default"&&"rounded-md px-4",y==="underline"&&"px-6 py-3 border-b-2 border-transparent",E&&"text-foreground",!E&&"text-muted-foreground hover:text-foreground",n),...l,children:[a&&d.jsx(a,{className:Fe("h-4 w-4 transition-all duration-500 ease-in-out",!h&&"mr-2",h&&"mr-0!")}),i&&d.jsx("span",{className:"absolute top-1.5 right-1.5 w-2 h-2 bg-orange-500 dark:bg-orange-400 border-2 border-white dark:border-zinc-900 rounded-full transition-opacity duration-300 z-10 animate-status-pulse-orange"}),d.jsx("span",{className:Fe("transition-all duration-500 ease-in-out overflow-hidden",h?"w-0 opacity-0":"w-auto opacity-100"),children:e})]})})});BT.displayName="TabsTrigger";function qF({serverConfig:e,additionalItems:t=[],showClients:n={cursor:!0,vsCode:!0,claudeDesktop:!0,claudeCode:!0,geminiCli:!0,codexCli:!0},className:r="",onSuccess:a,onError:o,trigger:i}){const[l,u]=b.useState(!1),[f,m]=b.useState(null),[h,g]=b.useState(!1),{url:y,name:E,headers:x}=e,w=()=>{try{const L=$G(y,E,x);window.location.href=L,a?.("Cursor")}catch(L){console.error("Failed to generate Cursor deep link:",L),o?.(L)}},S=()=>{try{const L=UG(y,E,x);window.location.href=L,a?.("VS Code")}catch(L){console.error("Failed to generate VS Code deep link:",L),o?.(L)}},_=()=>{try{zG(y,E,x),a?.("Claude Desktop")}catch(L){console.error("Failed to download .mcpb file:",L),o?.(L)}},T=()=>{m("claude-code"),u(!0)},A=()=>{m("gemini-cli"),u(!0)},R=()=>{m("codex-cli"),u(!0)},k=async L=>{try{await navigator.clipboard.writeText(L),g(!0),setTimeout(()=>g(!1),2e3)}catch($){console.error("Failed to copy:",$),o?.($)}},C=()=>{if(f==="claude-code"){const{command:L,envVars:$}=FG(y,E,x),H=U2($);return d.jsxs(d.Fragment,{children:[d.jsxs(ls,{children:[d.jsx(cs,{children:"Add to Claude Code"}),d.jsx(Hp,{children:"Execute the following command in your shell to add this server to Claude Code."})]}),d.jsxs("div",{className:"space-y-4",children:[d.jsxs("div",{children:[d.jsx("h5",{className:"font-semibold text-sm mb-2",children:"Instructions"}),d.jsxs("ol",{className:"space-y-2 text-xs text-muted-foreground",children:[d.jsxs("li",{className:"flex gap-2",children:[d.jsx("span",{className:"font-semibold text-foreground",children:"1."}),d.jsx("span",{children:"Ensure the Claude Code executable is available in your path"})]}),d.jsxs("li",{className:"flex gap-2",children:[d.jsx("span",{className:"font-semibold text-foreground",children:"2."}),d.jsx("span",{children:"Execute the following snippet in your shell:"})]})]})]}),d.jsxs("div",{className:"relative",children:[d.jsx("div",{className:"absolute top-2 right-2 z-10",children:d.jsx(Le,{variant:"ghost",size:"sm",className:"h-7 px-2 bg-background hover:bg-accent border border-border",onClick:()=>k(L),children:h?d.jsx(Or,{className:"size-3.5 text-green-600"}):d.jsx(wr,{className:"size-3.5"})})}),d.jsx("pre",{className:"bg-muted p-3 pr-14 rounded-md text-xs overflow-x-auto",children:d.jsx("code",{children:L})})]}),H&&d.jsxs("div",{children:[d.jsx("h5",{className:"font-semibold text-sm mb-2",children:"Environment Variables"}),d.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:"After installation, set these environment variables in your shell:"}),d.jsx("pre",{className:"bg-muted p-3 rounded-md text-xs overflow-x-auto",children:d.jsx("code",{children:H})})]}),d.jsxs("p",{className:"text-xs text-muted-foreground",children:["The MCP configuration supports environment variable expansion using ",d.jsx("code",{className:"text-foreground",children:"${VAR}"})," ","syntax."]})]})]})}if(f==="gemini-cli"){const{command:L,envVars:$}=BG(y,E,x),H=U2($);return d.jsxs(d.Fragment,{children:[d.jsxs(ls,{children:[d.jsx(cs,{children:"Add to Gemini CLI"}),d.jsx(Hp,{children:"Execute the following command in your shell to add this server to Gemini CLI."})]}),d.jsxs("div",{className:"space-y-4",children:[d.jsxs("div",{children:[d.jsx("h5",{className:"font-semibold text-sm mb-2",children:"Instructions"}),d.jsxs("ol",{className:"space-y-2 text-xs text-muted-foreground",children:[d.jsxs("li",{className:"flex gap-2",children:[d.jsx("span",{className:"font-semibold text-foreground",children:"1."}),d.jsx("span",{children:"Ensure the Gemini CLI executable is available in your path"})]}),H&&d.jsxs("li",{className:"flex gap-2",children:[d.jsx("span",{className:"font-semibold text-foreground",children:"2."}),d.jsx("span",{children:"Set these environment variables in your shell before running the command:"})]}),d.jsxs("li",{className:"flex gap-2",children:[d.jsx("span",{className:"font-semibold text-foreground",children:H?"3.":"2."}),d.jsx("span",{children:"Execute the following snippet in your shell:"})]})]})]}),H&&d.jsxs("div",{children:[d.jsx("h5",{className:"font-semibold text-sm mb-2",children:"Environment Variables"}),d.jsx("pre",{className:"bg-muted p-3 rounded-md text-xs overflow-x-auto",children:d.jsx("code",{children:H})})]}),d.jsxs("div",{className:"relative",children:[d.jsx("div",{className:"absolute top-2 right-2 z-10",children:d.jsx(Le,{variant:"ghost",size:"sm",className:"h-7 px-2 bg-background hover:bg-accent border border-border",onClick:()=>k(L),children:h?d.jsx(Or,{className:"size-3.5 text-green-600"}):d.jsx(wr,{className:"size-3.5"})})}),d.jsx("pre",{className:"bg-muted p-3 pr-14 rounded-md text-xs overflow-x-auto",children:d.jsx("code",{children:L})})]}),d.jsx("p",{className:"text-xs text-muted-foreground",children:"Restart Gemini CLI to load the new configuration."})]})]})}if(f==="codex-cli"){const{config:L,envVars:$}=HG(y,E,x);return d.jsxs(d.Fragment,{children:[d.jsxs(ls,{children:[d.jsx(cs,{children:"Add to Codex CLI"}),d.jsxs(Hp,{children:["Add this configuration to your"," ",d.jsx("code",{className:"text-foreground",children:"~/.codex/config.toml"})," ","file."]})]}),d.jsxs("div",{className:"space-y-4",children:[d.jsxs("div",{children:[d.jsx("h5",{className:"font-semibold text-sm mb-2",children:"Instructions"}),d.jsxs("p",{className:"text-xs text-muted-foreground",children:["Add this configuration to your"," ",d.jsx("code",{className:"text-foreground",children:"~/.codex/config.toml"}),":"]})]}),d.jsxs("div",{className:"relative",children:[d.jsx("div",{className:"absolute top-2 right-2 z-10",children:d.jsx(Le,{variant:"ghost",size:"sm",className:"h-7 px-2 bg-background hover:bg-accent border border-border",onClick:()=>k(L),children:h?d.jsx(Or,{className:"size-3.5 text-green-600"}):d.jsx(wr,{className:"size-3.5"})})}),d.jsx("pre",{className:"bg-muted p-3 pr-14 rounded-md text-xs overflow-x-auto",children:d.jsx("code",{children:L})})]}),$.length>0&&d.jsx("div",{children:d.jsxs("p",{className:"text-xs text-muted-foreground",children:["(optional) If you would rather use variables from your system's environment, replace the"," ",d.jsx("code",{className:"text-foreground",children:"http_headers"})," key with the ",d.jsx("code",{className:"text-foreground",children:"env_http_headers"})," ","key as shown in the commented section above."]})}),d.jsx("p",{className:"text-xs text-muted-foreground",children:"Restart Codex CLI to load the new configuration."})]})]})}return null},O=d.jsxs(Le,{variant:"ghost",className:`bg-zinc-200 dark:bg-zinc-800 hover:bg-zinc-300 dark:hover:bg-zinc-700 rounded-full transition-colors px-3 flex items-center justify-center ${r}`,children:[d.jsxs("span",{className:"xl:hidden hidden sm:flex items-center gap-1",children:[d.jsx(gm,{className:"size-3"}),"Client"]}),d.jsxs("span",{className:"hidden xl:flex items-center gap-1",children:["Add to Client",d.jsx(hs,{className:"size-3"})]})]}),M=i?typeof i=="function"?i({isOpen:!1,onClick:()=>{}}):i:O;return d.jsxs(d.Fragment,{children:[d.jsxs(cm,{children:[d.jsx(um,{asChild:!0,children:M}),d.jsxs(Pd,{align:"end",className:"w-auto min-w-[300px]",children:[t.map(L=>d.jsxs(Jr,{onClick:async()=>{await L.onClick()},className:"flex items-center gap-2",children:[L.icon,d.jsx("span",{className:"min-w-0 max-w-full whitespace-nowrap",children:L.label})]},L.id)),t.length>0&&d.jsx(Mu,{}),n.cursor&&d.jsxs(Jr,{onClick:w,className:"flex items-center gap-2",children:[d.jsx("img",{src:"https://cdn.simpleicons.org/cursor",alt:"Cursor",className:"h-4 w-4"}),d.jsx("span",{className:"min-w-0 max-w-full whitespace-nowrap",children:"Cursor"})]}),n.claudeCode&&d.jsxs(Jr,{onClick:T,className:"flex items-center gap-2",children:[d.jsx("img",{src:"https://cdn.simpleicons.org/claude",alt:"Claude",className:"h-4 w-4"}),d.jsx("span",{className:"min-w-0 max-w-full whitespace-nowrap",children:"Claude Code"})]}),n.claudeDesktop&&d.jsxs(Jr,{onClick:_,className:"flex items-center gap-2",children:[d.jsx("img",{src:"https://cdn.simpleicons.org/claude",alt:"Claude",className:"h-4 w-4"}),d.jsx("span",{className:"min-w-0 max-w-full whitespace-nowrap",children:"Claude Desktop"})]}),n.vsCode&&d.jsxs(Jr,{onClick:S,className:"flex items-center gap-2",children:[d.jsx(PG,{className:"h-4 w-4"}),d.jsx("span",{className:"min-w-0 max-w-full whitespace-nowrap",children:"VS Code"})]}),n.geminiCli&&d.jsxs(Jr,{onClick:A,className:"flex items-center gap-2",children:[d.jsx("img",{src:"https://cdn.simpleicons.org/googlegemini",alt:"Gemini",className:"h-4 w-4"}),d.jsx("span",{className:"min-w-0 max-w-full whitespace-nowrap",children:"Gemini CLI"})]}),n.codexCli&&d.jsxs(Jr,{onClick:R,className:"flex items-center gap-2",children:[d.jsx("img",{src:"https://inspector-cdn.mcp-use.com/providers/openai.png",alt:"Codex",className:"h-4 w-4"}),d.jsx("span",{className:"min-w-0 max-w-full whitespace-nowrap",children:"Codex CLI"})]})]})]}),d.jsx(tl,{open:l,onOpenChange:u,children:d.jsx(nl,{className:"max-w-3xl max-h-[80vh] overflow-y-auto",children:C()})})]})}function XF({className:e,state:t="collapsed",href:n="https://mcp-use.com"}){const[r,a]=b.useState(!1),o=.2,i=.7,l=.6,u=4,f=o+i+l,m=0,h=o/f,g=(o+i)/f,y=1;return d.jsxs("a",{href:n,target:"_blank",rel:"noopener noreferrer",className:Fe("flex items-center transition-opacity -my-3",t==="expanded"?"space-x-2":"",e),onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),children:[d.jsx("div",{className:"relative",children:d.jsxs(Fa.svg,{viewBox:"0 0 303 303",initial:"rest",animate:r?"hover":"rest",className:Fe("text-foreground",t==="expanded"?"size-[40px]":"size-[20px]"),children:[d.jsxs(Fa.g,{variants:{rest:{opacity:1},hover:{opacity:[1,0,0,1],transition:{duration:f,times:[m,h,g,y],ease:"easeInOut"}}},fill:"currentColor",fillRule:"nonzero",stroke:"currentColor",strokeWidth:u,strokeLinecap:"round",strokeLinejoin:"round",children:[d.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"}),d.jsx("circle",{cx:"70.3",cy:"232.3",r:"50"}),d.jsx("circle",{cx:"232.3",cy:"70.3",r:"50"})]}),d.jsxs("g",{fill:"none",stroke:"currentColor",strokeWidth:u,strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx(ETe,{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:y},total:f}),d.jsx(JF,{cx:70.3,cy:232.3,r:50,times:{T0:m,T1:h,T2:g,T3:y},total:f}),d.jsx(JF,{cx:232.3,cy:70.3,r:50,times:{T0:m,T1:h,T2:g,T3:y},total:f})]})]})}),t==="expanded"&&d.jsxs("div",{className:"font-ubuntu flex-col items-start -space-y-1 mr-3 hidden xl:flex",children:[d.jsx("h1",{className:"text-xl font-medium",children:"mcp-use"}),d.jsx("span",{className:"text-lg text-muted-foreground tracking-wide font-sans font-light",children:"Inspector"})]})]})}function ETe({d:e,times:t,total:n}){const{T0:r,T1:a,T2:o,T3:i}=t;return d.jsx(Fa.path,{d:e,variants:{rest:{pathLength:0,opacity:0},hover:{pathLength:[0,0,1,1],opacity:[0,0,1,1],transition:{duration:n,times:[r,a,o,i],ease:"easeInOut"}}}})}function JF({cx:e,cy:t,r:n,times:r,total:a}){const{T0:o,T1:i,T2:l,T3:u}=r;return d.jsx(Fa.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:a,times:[o,i,l,u],ease:"easeInOut"}}}})}function Zb({open:e,onOpenChange:t,serverUrl:n,serverName:r,serverId:a,headers:o,language:i}){const{prismStyle:l}=jI(),[u,f]=b.useState(!1),m=i==="typescript"?gxe(n,r,a,o):bxe(n,r,a,o),h=async()=>{await navigator.clipboard.writeText(m),f(!0),setTimeout(()=>f(!1),2e3)},g=i==="typescript"?"TypeScript":"Python",y=i==="typescript"?"npm install mcp-use":"pip install mcp-use";return d.jsx(tl,{open:e,onOpenChange:t,children:d.jsxs(nl,{className:"max-w-[90vw] max-h-[90vh] overflow-hidden flex flex-col",children:[d.jsxs(ls,{children:[d.jsxs(cs,{children:["Add to ",g," SDK"]}),d.jsxs(Hp,{children:["Copy the following code to integrate this server into your"," ",g," application using the mcp-use SDK."]})]}),d.jsxs("div",{className:"space-y-4 overflow-y-auto flex-1 min-h-0",children:[d.jsxs("div",{children:[d.jsx("h5",{className:"font-semibold text-sm mb-2",children:"Instructions"}),d.jsxs("ol",{className:"space-y-2 text-xs text-muted-foreground",children:[d.jsxs("li",{className:"flex gap-2",children:[d.jsx("span",{className:"font-semibold text-foreground",children:"1."}),d.jsxs("span",{children:["Install the mcp-use package:"," ",d.jsx("code",{className:"text-foreground",children:y})]})]}),d.jsxs("li",{className:"flex gap-2",children:[d.jsx("span",{className:"font-semibold text-foreground",children:"2."}),d.jsxs("span",{children:["Copy the following code into your ",g," project:"]})]})]})]}),d.jsxs("div",{className:"relative w-full overflow-x-auto overflow-y-auto max-h-[60vh]",children:[d.jsx("div",{className:"absolute top-2 right-2 z-10",children:d.jsx(Le,{variant:"ghost",size:"sm",className:"h-7 px-2 bg-background hover:bg-accent border border-border",onClick:h,children:u?d.jsx(Or,{className:"size-3.5 text-green-600"}):d.jsx(wr,{className:"size-3.5"})})}),d.jsx(_m,{language:i,style:l,customStyle:{margin:0,padding:"1rem",paddingRight:"3rem",borderRadius:"0.5rem",fontSize:"0.75rem",background:"var(--muted)",width:"100%",maxWidth:"100%",overflow:"auto"},wrapLines:!0,wrapLongLines:!0,PreTag:"div",children:m})]})]})]})})}function KW({ref:e,shimmerColor:t,shimmerSize:n="0.05em",shimmerDuration:r="3s",borderRadius:a="100px",background:o,className:i,children:l,...u}){const{theme:f}=Rw(),m=f==="dark"?"#000000":"#ffffff",h=f==="dark"?"rgba(255, 255, 255, 1)":"rgba(0, 0, 0, 1)",g=t||m,y=o||h;return d.jsxs("button",{style:{"--spread":"90deg","--shimmer-color":g,"--radius":a,"--speed":r,"--cut":n,"--bg":y},className:Fe("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","dark:text-white text-black dark:border-white/10 border-black/10",i),ref:e,...u,children:[d.jsx("div",{className:Fe("-z-30 blur-[2px]","@container-[size] absolute inset-0 overflow-visible"),children:d.jsx("div",{className:"animate-shimmer-slide absolute inset-0 aspect-[1] h-[100cqh] rounded-none mask-none",children:d.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))]"})})}),l,d.jsx("div",{className:Fe("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","dark:shadow-[inset_0_-8px_10px_#0000001f] dark:group-hover:shadow-[inset_0_-6px_10px_#0000003f] dark: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]")}),d.jsx("div",{className:Fe("absolute [inset:var(--cut)] -z-20 [border-radius:var(--radius)] bg-black dark:bg-white")})]})}KW.displayName="ShimmerButton";function QF({status:e}){const t=o=>{switch(o){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:o}}},{color:n,ringColor:r,tooltip:a}=t(e);return d.jsxs(Wt,{children:[d.jsx(Kt,{asChild:!0,children:d.jsxs("div",{className:"relative",children:[d.jsx("div",{className:`absolute w-2 h-2 rounded-full ${r} animate-ping`}),d.jsx("div",{className:`relative w-2 h-2 rounded-full ${n}`})]})}),d.jsx(Yt,{children:d.jsx("p",{children:a})})]})}function e4({connections:e,selectedServer:t,onServerSelect:n,onOpenConnectionOptions:r,mobileMode:a=!1}){const o=bl(),[i,l]=b.useState(!1),[u,f]=b.useState(null),m=h=>{const g=e.find(y=>y.id===h);if(!g||g.state!=="ready"){Nt.error("Server is not connected and cannot be inspected");return}n(h)};return a?d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("div",{className:"relative",children:d.jsxs(cm,{children:[d.jsx(um,{asChild:!0,children:d.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?d.jsx(Vu,{server:t,size:"md"}):d.jsx(YH,{className:"h-5 w-5"}),d.jsx(hs,{className:"h-4 w-4"})]})}),d.jsxs(Pd,{className:"w-[calc(100vw-2rem)] sm:w-[300px]",align:"start",children:[d.jsx(c_,{className:"cursor-pointer hover:bg-zinc-100 dark:hover:bg-zinc-800",onClick:()=>o("/"),children:"MCP Servers"}),d.jsx(Mu,{}),e.length===0?d.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(h=>d.jsxs(Jr,{onClick:()=>m(h.id),className:"flex items-center gap-3",children:[d.jsx(Vu,{server:h,size:"sm"}),d.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[d.jsx("div",{className:"font-medium",children:h.name}),d.jsx(QF,{status:h.state})]}),d.jsxs("div",{className:"flex items-center gap-1",children:[d.jsx(Le,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 hover:bg-zinc-100 dark:hover:bg-zinc-800",onClick:g=>{g.stopPropagation(),f(h),l(!0)},children:d.jsx(Fp,{className:"h-3 w-3"})}),d.jsx(Le,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 hover:bg-zinc-100 dark:hover:bg-zinc-800",onClick:g=>{g.stopPropagation(),r(h.id)},children:d.jsx(Ju,{className:"h-3 w-3"})})]})]},h.id)),d.jsx(Mu,{}),d.jsx(Jr,{onClick:()=>o("/"),children:d.jsx("span",{className:"text-blue-600 dark:text-blue-400",children:"+ Add new server"})})]})]})}),d.jsx(W_,{open:i,onOpenChange:l,connection:u})]}):d.jsx("div",{className:"flex items-center gap-2",children:d.jsxs("div",{className:"relative",children:[d.jsxs(cm,{children:[d.jsx(um,{asChild:!0,children:d.jsxs(KW,{className:Fe("min-w-0 sm:min-w-[200px] p-0 px-1 text-sm h-11 justify-start 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-20"),children:[t&&d.jsx(Vu,{server:t,size:"md",className:"mr-2"}),d.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[d.jsx("span",{className:"truncate lg:max-w-[120px] xl:max-w-none",children:t?t.serverInfo?.title||t.serverInfo?.name||t.name:"Select server to inspect"}),t&&d.jsx("div",{className:"flex items-center gap-2",children:t.error&&t.state!=="ready"?d.jsxs(Wt,{children:[d.jsx(Kt,{asChild:!0,children:d.jsx("button",{onClick:h=>{h.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"})}),d.jsx(Yt,{children:d.jsx("p",{className:"max-w-xs",children:t.error})})]}):d.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&&d.jsxs("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 flex items-center gap-1",children:[d.jsxs(Wt,{children:[d.jsx(Kt,{asChild:!0,children:d.jsx("button",{type:"button",onClick:()=>{f(t),l(!0)},className:"p-1.5 hover:bg-white/10 dark:hover:bg-black/10 rounded-full transition-colors text-white dark:text-black","aria-label":"View server info",children:d.jsx(Fp,{className:"h-4 w-4"})})}),d.jsx(Yt,{children:d.jsx("p",{children:"View server info"})})]}),d.jsxs(Wt,{children:[d.jsx(Kt,{asChild:!0,children:d.jsx("button",{type:"button",onClick:()=>{r(t.id)},className:"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:d.jsx(Ju,{className:"h-4 w-4"})})}),d.jsx(Yt,{children:d.jsx("p",{children:"Edit connection settings"})})]})]}),d.jsxs(Pd,{className:"w-[calc(100vw-2rem)] sm:w-[300px]",align:"start",children:[d.jsx(c_,{className:"cursor-pointer hover:bg-zinc-100 dark:hover:bg-zinc-800",onClick:()=>o("/"),children:"MCP Servers"}),d.jsx(Mu,{}),e.length===0?d.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(h=>d.jsxs(Jr,{onClick:()=>m(h.id),className:"flex items-center gap-3",children:[d.jsx(Vu,{server:h,size:"sm"}),d.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[d.jsx("div",{className:"font-medium",children:h.serverInfo?.title||h.serverInfo?.name||h.name}),d.jsx(QF,{status:h.state})]}),d.jsxs("div",{className:"flex items-center gap-1",children:[d.jsx(Le,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 hover:bg-zinc-100 dark:hover:bg-zinc-800",onClick:g=>{g.stopPropagation(),f(h),l(!0)},children:d.jsx(Fp,{className:"h-3 w-3"})}),d.jsx(Le,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 hover:bg-zinc-100 dark:hover:bg-zinc-800",onClick:g=>{g.stopPropagation(),r(h.id)},children:d.jsx(Ju,{className:"h-3 w-3"})})]})]},h.id)),d.jsx(Mu,{}),d.jsx(Jr,{onClick:()=>o("/"),children:d.jsx("span",{className:"text-blue-600 dark:text-blue-400",children:"+ Add new server"})})]})]}),d.jsx(W_,{open:i,onOpenChange:l,connection:u})]})})}function t4({className:e}){const{theme:t,setTheme:n}=Rw(),r=b.useRef(null),a=()=>t==="system"?d.jsx(_U,{className:"size-4"}):t==="light"?d.jsx(CU,{className:"size-4"}):d.jsx(TU,{className:"size-4"}),o=async i=>{const l=r.current;if(!l){n(i);return}if(typeof document<"u"&&"startViewTransition"in document){await document.startViewTransition(()=>{tf.flushSync(()=>{n(i)})}).ready;const{top:u,left:f,width:m,height:h}=l.getBoundingClientRect(),g=u+h/2,y=f+m/2,E=window.innerWidth-f,x=window.innerHeight-u,w=Math.hypot(Math.max(f,E),Math.max(u,x));document.documentElement.animate({clipPath:[`circle(0px at ${y}px ${g}px)`,`circle(${w}px at ${y}px ${g}px)`]},{duration:700,easing:"ease-in-out",pseudoElement:"::view-transition-new(root)"})}else n(i)};return d.jsxs(cm,{children:[d.jsx(um,{asChild:!0,children:d.jsx(Le,{ref:r,variant:"ghost",size:"sm",className:Fe("p-2 hover:bg-zinc-200 dark:hover:bg-zinc-800 rounded-full transition-colors",e),"aria-label":"Toggle theme",children:a()})}),d.jsx(Pd,{align:"end",className:"min-w-0",children:d.jsxs(gce,{value:t,onValueChange:i=>o(i),children:[d.jsxs(sy,{value:"light",className:"pl-2 pr-0 flex items-center gap-2 justify-end",children:[d.jsx("span",{children:"Light"}),d.jsx(CU,{className:"mr-2 h-4 w-4"})]}),d.jsxs(sy,{value:"dark",className:"pl-2 pr-0 flex items-center gap-2 justify-end",children:[d.jsx("span",{children:"Dark"}),d.jsx(TU,{className:"mr-2 h-4 w-4"})]}),d.jsxs(sy,{value:"system",className:"pl-2 pr-0 flex items-center gap-2 justify-end",children:[d.jsx("span",{children:"System"}),d.jsx(_U,{className:"mr-2 h-4 w-4"})]})]})})]})}const n4=[{id:"tools",label:"Tools",icon:dc},{id:"prompts",label:"Prompts",icon:hm},{id:"resources",label:"Resources",icon:Pue},{id:"sampling",label:"Sampling",icon:VH},{id:"elicitation",label:"Elicitation",icon:ZH},{id:"notifications",label:"Notifications",icon:ZN},{id:"chat",label:"Chat",icon:que}];function r4(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 a4(e,t,n){const r=["sampling","elicitation","notifications"];return n&&t>0&&r.includes(e)}function STe({collapsed:e,onToggle:t}){return d.jsxs(Wt,{children:[d.jsx(Kt,{asChild:!0,children:d.jsx("button",{onClick:t,className:Fe("shrink-0 p-1.5 rounded-md transition-all duration-500 ease-in-out cursor-pointer","text-muted-foreground hover:text-foreground","hover:bg-zinc-100 dark:hover:bg-zinc-800","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"),"aria-label":e?"Expand tabs":"Collapse tabs",type:"button",children:e?d.jsx(BH,{className:"h-4 w-4 transition-transform duration-500 ease-in-out"}):d.jsx(rw,{className:"h-4 w-4 transition-transform duration-500 ease-in-out"})})}),d.jsx(Yt,{children:d.jsx("p",{children:e?"Expand tabs":"Collapse tabs"})})]})}function _Te({connections:e,selectedServer:t,activeTab:n,onServerSelect:r,onTabChange:a,onCommandPaletteOpen:o,onOpenConnectionOptions:i,embedded:l=!1}){const{tunnelUrl:u}=kc(),f=t&&u,[m,h]=b.useState(!1),[g,y]=b.useState(!1),[E,x]=b.useState(!1),[w,S]=b.useState(!0),_=async()=>{if(u)try{await navigator.clipboard.writeText(`${u}/mcp`),h(!0),Nt.success("Tunnel URL copied to clipboard"),setTimeout(()=>h(!1),2e3)}catch{Nt.error("Failed to copy URL")}};return d.jsxs("header",{className:"w-full mx-auto",children:[d.jsxs("div",{className:"flex lg:hidden flex-col gap-3",children:[d.jsxs("div",{className:"flex items-center justify-between w-full",children:[!l&&d.jsx("div",{className:"flex-1 flex justify-start",children:d.jsx(e4,{connections:e,selectedServer:t,onServerSelect:r,onOpenConnectionOptions:i,mobileMode:!0})}),!l&&d.jsx("div",{className:"flex-shrink-0 flex justify-center",children:d.jsx("div",{className:"scale-150",children:d.jsx(XF,{state:"collapsed"})})}),!l&&d.jsxs("div",{className:"flex-1 flex justify-end items-center gap-2",children:[t&&(()=>{const T=t.serverInfo?.title||t.serverInfo?.name||t.name;return d.jsxs(d.Fragment,{children:[d.jsx(qF,{serverConfig:{url:u?`${u}/mcp`:t.url,name:T,headers:t.customHeaders,serverId:t.id},onSuccess:A=>Nt.success(`Opening in ${A}...`),onError:A=>Nt.error(`Failed: ${A.message}`),additionalItems:[{id:"ts-sdk",label:"TypeScript SDK",icon:d.jsx("img",{src:"https://cdn.simpleicons.org/typescript",alt:"TypeScript",className:"h-4 w-4"}),onClick:()=>y(!0)},{id:"py-sdk",label:"Python SDK",icon:d.jsx("img",{src:"https://cdn.simpleicons.org/python",alt:"Python",className:"h-4 w-4"}),onClick:()=>x(!0)}],trigger:d.jsxs(Le,{variant:"ghost",className:"bg-zinc-200 dark:bg-zinc-800 hover:bg-zinc-300 dark:hover:bg-zinc-700 rounded-full transition-colors px-3 flex items-center justify-center p-2","aria-label":"Add to Client",children:[d.jsxs("span",{className:"xl:hidden hidden sm:flex items-center gap-1",children:[d.jsx(gm,{className:"size-3"}),"Client"]}),d.jsxs("span",{className:"hidden xl:flex items-center gap-1",children:["Add to Client",d.jsx(hs,{className:"size-3"})]})]})}),d.jsx(Zb,{open:g,onOpenChange:y,serverUrl:u?`${u}/mcp`:t.url,serverName:T,serverId:void 0,headers:t.customHeaders,language:"typescript"}),d.jsx(Zb,{open:E,onOpenChange:x,serverUrl:u?`${u}/mcp`:t.url,serverName:T,serverId:void 0,headers:t.customHeaders,language:"python"})]})})(),d.jsxs(Wt,{children:[d.jsx(Kt,{asChild:!0,children:d.jsx(Le,{variant:"ghost",size:"sm",asChild:!0,children:d.jsx("a",{href:"https://github.com/mcp-use/mcp-use",target:"_blank",rel:"noopener noreferrer",className:"p-2","aria-label":"GitHub",children:d.jsx(ZF,{className:"h-4 w-4"})})})}),d.jsx(Yt,{children:d.jsx("p",{children:"Give us a star ⭐"})})]}),d.jsx(t4,{})]})]}),t&&d.jsx("div",{className:"w-full",children:d.jsx(zT,{value:n,onValueChange:T=>a(T),collapsed:w,onCollapsedChange:S,children:d.jsx(FT,{className:"w-full justify-center",children:n4.map(T=>{const A=r4(T.id,t),R=a4(T.id,A,w);return d.jsxs(BT,{value:T.id,icon:T.icon,showDot:R,className:Fe("[&>svg]:mr-0 flex-1 flex-row gap-2 relative",w&&"pl-2"),children:[A>0&&!w&&d.jsx("span",{className:Fe(n===T.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:A}),d.jsx("span",{className:"sr-only",children:T.label})]},T.id)})})})})]}),d.jsxs("div",{className:"hidden lg:flex items-center justify-between gap-3",children:[d.jsxs("div",{className:"flex items-center flex-wrap gap-2 md:space-x-6 space-x-2",children:[!l&&d.jsx(e4,{connections:e,selectedServer:t,onServerSelect:r,onOpenConnectionOptions:i}),t&&d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(zT,{value:n,onValueChange:T=>a(T),collapsed:w,onCollapsedChange:S,children:d.jsx(FT,{className:"overflow-x-auto",collapsible:!0,children:n4.map(T=>{const A=r4(T.id,t),R=A>0?`${T.label} (${A})`:T.label,k=a4(T.id,A,w);return d.jsx(BT,{value:T.id,icon:T.icon,showDot:k,className:Fe("[&>svg]:mr-0 lg:[&>svg]:mr-2 relative",w&&"pl-4"),title:R,children:d.jsxs("div",{className:"items-center gap-2 hidden lg:flex",children:[T.label,A>0&&d.jsx("span",{className:Fe(n===T.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:A})]})})})})}),d.jsx(STe,{collapsed:w,onToggle:()=>S(!w)})]}),f&&d.jsxs(i7,{children:[d.jsx(l7,{asChild:!0,children:d.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:[d.jsx(bm,{className:"size-4 text-purple-600 dark:text-purple-400 animate-pulse"}),d.jsx("span",{className:"text-xs font-medium text-purple-700 dark:text-purple-300 hidden lg:inline",children:"Tunnel"})]})}),d.jsx(yO,{className:"w-[calc(100vw-2rem)] sm:w-96",align:"start",children:d.jsxs("div",{className:"space-y-4",children:[d.jsxs("div",{children:[d.jsxs("h4",{className:"font-semibold text-sm mb-2 flex items-center gap-2",children:[d.jsx(bm,{className:"size-4 text-purple-600 dark:text-purple-400"}),"Tunnel URL"]}),d.jsxs("div",{className:"flex items-center gap-2 p-2 py-0 bg-muted rounded-full",children:[d.jsxs("code",{className:"flex-1 text-[10px] font-mono",children:[u,"/mcp"]}),d.jsx(Le,{variant:"ghost",size:"sm",className:"h-7 px-2",onClick:_,children:m?d.jsx(Or,{className:"size-3.5 text-green-600"}):d.jsx(wr,{className:"size-3.5"})})]})]}),d.jsxs("div",{children:[d.jsx("h5",{className:"font-semibold text-sm mb-2",children:"Use in ChatGPT"}),d.jsxs("ol",{className:"space-y-2 text-xs text-muted-foreground",children:[d.jsxs("li",{className:"flex gap-2",children:[d.jsx("span",{className:"font-semibold text-foreground",children:"1."}),d.jsxs("span",{children:["Enable"," ",d.jsx("span",{className:"font-medium text-foreground",children:"dev mode"})," ","from settings"]})]}),d.jsxs("li",{className:"flex gap-2",children:[d.jsx("span",{className:"font-semibold text-foreground",children:"2."}),d.jsxs("span",{children:["In"," ",d.jsx("span",{className:"font-medium text-foreground",children:"App & Connectors"})," ","click on"," ",d.jsx("span",{className:"font-medium text-foreground",children:"create"})]})]}),d.jsxs("li",{className:"flex gap-2",children:[d.jsx("span",{className:"font-semibold text-foreground",children:"3."}),d.jsx("span",{children:"Use the tunnel URL in the input"})]})]})]})]})})]})]}),!l&&d.jsxs("div",{className:"flex items-center gap-2 sm:gap-4 flex-shrink-0",children:[t&&(()=>{const T=t.serverInfo?.title||t.serverInfo?.name||t.name;return d.jsxs(d.Fragment,{children:[d.jsx(qF,{serverConfig:{url:u?`${u}/mcp`:t.url,name:T,headers:t.customHeaders,serverId:t.id},onSuccess:A=>Nt.success(`Opening in ${A}...`),onError:A=>Nt.error(`Failed: ${A.message}`),additionalItems:[{id:"ts-sdk",label:"TypeScript SDK",icon:d.jsx("img",{src:"https://cdn.simpleicons.org/typescript",alt:"TypeScript",className:"h-4 w-4"}),onClick:()=>y(!0)},{id:"py-sdk",label:"Python SDK",icon:d.jsx("img",{src:"https://cdn.simpleicons.org/python",alt:"Python",className:"h-4 w-4"}),onClick:()=>x(!0)}],trigger:d.jsxs(Le,{variant:"ghost",className:"bg-zinc-200 dark:bg-zinc-800 hover:bg-zinc-300 dark:hover:bg-zinc-700 rounded-full transition-colors px-3 flex items-center justify-center","aria-label":"Add to Client",children:[d.jsxs("span",{className:"xl:hidden hidden sm:flex items-center gap-1",children:[d.jsx(gm,{className:"size-3"}),"Client"]}),d.jsxs("span",{className:"hidden xl:flex items-center gap-1",children:["Add to Client",d.jsx(hs,{className:"size-3"})]})]})}),d.jsx(Zb,{open:g,onOpenChange:y,serverUrl:u?`${u}/mcp`:t.url,serverName:T,serverId:void 0,headers:t.customHeaders,language:"typescript"}),d.jsx(Zb,{open:E,onOpenChange:x,serverUrl:u?`${u}/mcp`:t.url,serverName:T,serverId:void 0,headers:t.customHeaders,language:"python"})]})})(),d.jsx(t4,{}),d.jsxs(Wt,{children:[d.jsx(Kt,{asChild:!0,children:d.jsxs(Le,{variant:"ghost",className:"hover:bg-zinc-200 dark:hover:bg-zinc-800 rounded-full px-1 -mx-3 flex gap-1",onClick:o,children:[d.jsx(wue,{className:"size-4"}),d.jsx("span",{className:"text-base font-mono hidden sm:inline",children:"K"})]})}),d.jsx(Yt,{children:d.jsx("p",{children:"Command Palette"})})]}),d.jsxs(Wt,{children:[d.jsx(Kt,{asChild:!0,children:d.jsx(Le,{variant:"ghost",size:"sm",asChild:!0,children:d.jsxs("a",{href:"https://github.com/mcp-use/mcp-use",className:"flex items-center gap-2",target:"_blank",rel:"noopener noreferrer",children:[d.jsx(ZF,{className:"h-4 w-4"}),d.jsx("span",{className:"hidden xl:inline",children:"Github"})]})})}),d.jsx(Yt,{children:d.jsx("p",{children:"Give us a star ⭐"})})]}),d.jsx(XF,{state:"expanded"})]})]})]})}function TTe({children:e}){const t=bl(),n=Aa(),{servers:r,addServer:a,removeServer:o,updateServer:i,storageLoaded:l}=Ym(),u=b.useCallback((D,P,W,K)=>{a(D,{url:D,name:P,proxyConfig:W,transportType:K,preventAutoAuth:!0})},[a]),f=b.useCallback(async(D,P)=>{try{await i(D,P)}catch(W){console.error(`[Layout] Failed to update connection ${D}:`,W)}},[i]),{selectedServerId:m,setSelectedServerId:h,activeTab:g,setActiveTab:y,navigateToItem:E,setTunnelUrl:x,tunnelUrl:w,isEmbedded:S,embeddedConfig:_,setEmbeddedMode:T}=kc(),[A,R]=b.useState(!1),[k,C]=b.useState(null),O=H0e();b.useEffect(()=>{const D=new URLSearchParams(n.search),P=D.get("embedded")==="true",W=D.get("embeddedConfig");if(P){let K={};if(W)try{K=JSON.parse(W)}catch(ae){console.error("Failed to parse embeddedConfig:",ae)}T(!0,K)}},[]),b.useEffect(()=>{const P=new URLSearchParams(n.search).get("tunnelUrl");x(P)},[n.search,x]),b.useEffect(()=>{const P=new URLSearchParams(n.search).get("tab");P&&["tools","prompts","resources","chat","sampling","elicitation","notifications"].includes(P)&&y(P)},[n.search,y]),b.useEffect(()=>{const D=K=>{const oe=K.detail.requestId;m&&E(m,"sampling",oe)},P=K=>{const oe=K.detail.requestId;m&&E(m,"elicitation",oe)},W=K=>{const oe=K.detail.toolName;m&&oe?E(m,"tools",oe):m&&y("tools")};return window.addEventListener("navigate-to-sampling",D),window.addEventListener("navigate-to-elicitation",P),window.addEventListener("navigate-to-tool-result",W),()=>{window.removeEventListener("navigate-to-sampling",D),window.removeEventListener("navigate-to-elicitation",P),window.removeEventListener("navigate-to-tool-result",W)}},[m,y,E]);const M=b.useRef(null),L=b.useRef(null),$=b.useRef(null),{isAutoConnecting:H}=B0e({connections:r,addConnection:u,removeConnection:o,configLoaded:l,embedded:S}),V=b.useCallback(D=>{ra.getInstance().capture(new Bce({trigger:D})).catch(()=>{}),R(!0)},[]),Z=D=>{const P=r.find(le=>le.id===D);if(!P||P.state!=="ready"){Nt.error("Server is not connected and cannot be inspected");return}h(D);const W=new URLSearchParams(n.search),K=W.get("tunnelUrl"),ae=W.get("tab"),oe=new URLSearchParams;oe.set("server",D),K&&oe.set("tunnelUrl",K),ae&&oe.set("tab",ae),t(`/?${oe.toString()}`)},ne=b.useCallback(D=>{C(D)},[]),G=b.useCallback(D=>{k&&(D.url!==k?(o(k),u(D.url,D.name,D.proxyConfig,D.transportType)):f(k,{name:D.name,proxyConfig:D.proxyConfig,transportType:D.transportType}),C(null),Nt.success("Connection settings updated"))},[k,o,u,f]),Y=(D,P,W)=>{if(console.warn("[Layout] handleCommandPaletteNavigate called:",{tab:D,itemName:P,serverId:W}),W){const K=r.find(q=>q.id===W);if(console.warn("[Layout] Server lookup:",{serverId:W,serverFound:!!K,serverState:K?.state}),!K||K.state!=="ready"){console.warn("[Layout] Server not ready, showing error"),Nt.error("Server is not connected and cannot be inspected");return}console.warn("[Layout] Calling navigateToItem:",{serverId:W,tab:D,itemName:P}),E(W,D,P);const ae=new URLSearchParams(n.search),oe=ae.get("tunnelUrl"),le=ae.get("tab"),Q=new URLSearchParams;Q.set("server",W),oe&&Q.set("tunnelUrl",oe),D?Q.set("tab",D):le&&Q.set("tab",le);const J=`/?${Q.toString()}`;console.warn("[Layout] Navigating to:",J),t(J)}else console.warn("[Layout] No serverId, just updating tab to:",D),y(D)},F=r.find(D=>D.id===m),re=F?F.tools.map(D=>({...D,_serverId:F.id})):r.flatMap(D=>D.state==="ready"?D.tools.map(P=>({...P,_serverId:D.id,_serverName:D.name})):[]),ee=F?F.prompts.map(D=>({...D,_serverId:F.id})):r.flatMap(D=>D.state==="ready"?D.prompts.map(P=>({...P,_serverId:D.id,_serverName:D.name})):[]),j=F?F.resources.map(D=>({...D,_serverId:F.id})):r.flatMap(D=>D.state==="ready"?D.resources.map(P=>({...P,_serverId:D.id,_serverName:D.name})):[]);if(b.useEffect(()=>{const P=new URLSearchParams(n.search).get("server");P!==m&&h(P)},[n.search,m,h]),b.useEffect(()=>{const P=new URLSearchParams(n.search).get("server");if(!P)return;const W=r.find(K=>K.id===P);if(!W){const K=setTimeout(()=>t("/"),3e3);return()=>clearTimeout(K)}if(W.state==="failed"){const K=setTimeout(()=>t("/"),2e3);return()=>clearTimeout(K)}},[n.search,t,r]),RG({onCommandPalette:()=>V("keyboard"),onToolsTab:()=>{F&&y("tools")},onPromptsTab:()=>{F&&y("prompts")},onResourcesTab:()=>{F&&y("resources")},onChatTab:()=>{F&&y("chat")},onHome:()=>{t("/")},onFocusSearch:()=>{g==="tools"&&M.current?M.current.focusSearch():g==="prompts"&&L.current?L.current.focusSearch():g==="resources"&&$.current&&$.current.focusSearch()},onBlurSearch:()=>{g==="tools"&&M.current?M.current.blurSearch():g==="prompts"&&L.current?L.current.blurSearch():g==="resources"&&$.current&&$.current.blurSearch()}}),H)return d.jsx("div",{className:"h-screen bg-white dark:bg-zinc-900 flex items-center justify-center",children:d.jsxs("div",{className:"flex flex-col items-center gap-4",children:[d.jsx(oi,{className:"h-8 w-8 text-zinc-600 dark:text-zinc-400"}),d.jsx("p",{className:"text-sm text-zinc-600 dark:text-zinc-400",children:"Connecting to MCP server..."})]})});const B=S?{backgroundColor:_.backgroundColor||"#f3f3f3",padding:_.padding||"0.5rem"}:{},z=S?"h-screen flex flex-col gap-2 sm:gap-4":"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";return d.jsx(YN,{children:d.jsxs("div",{className:z,style:B,children:[d.jsx(_Te,{connections:r,selectedServer:F,activeTab:g,onServerSelect:Z,onTabChange:y,onCommandPaletteOpen:()=>V("button"),onOpenConnectionOptions:ne,embedded:S}),d.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:d.jsx(vTe,{selectedServer:F,activeTab:g,toolsSearchRef:M,promptsSearchRef:L,resourcesSearchRef:$,children:e})}),!S&&d.jsxs("div",{className:"text-xs text-zinc-500 dark:text-zinc-400 px-2",children:["Having trouble connecting?"," ",d.jsx("button",{onClick:()=>{const D=[];for(let P=0;P<localStorage.length;P++){const W=localStorage.key(P);W&&(W.startsWith("mcp:auth")||W.startsWith("mcp-inspector"))&&D.push(W)}D.forEach(P=>localStorage.removeItem(P)),Nt.success(`Cleared ${D.length} localStorage item(s). Refreshing page...`,{duration:2e3}),setTimeout(()=>{window.location.reload()},500)},className:"text-blue-600 dark:text-blue-400 hover:underline focus:outline-none focus:underline",children:"Clear localStorage"})]}),d.jsx(vxe,{isOpen:A,onOpenChange:R,tools:re,prompts:ee,resources:j,savedRequests:O,connections:r,selectedServer:F,tunnelUrl:w,onNavigate:Y,onServerSelect:Z}),d.jsx(W8,{connection:k&&r.find(D=>D.id===k)||null,open:k!==null,onOpenChange:D=>{D||C(null)},onConnect:G})]})})}function NTe(){const[e,t]=b.useState("processing"),[n,r]=b.useState("");return b.useEffect(()=>{console.log("[OAuthCallback] Component mounted, handling authorization..."),console.log("[OAuthCallback] Current URL:",window.location.href),SN().then(()=>{console.log("[OAuthCallback] Authorization successful"),t("success")}).catch(a=>{console.error("[OAuthCallback] Authorization failed:",a),t("error"),r(a instanceof Error?a.message:String(a))})},[]),e==="processing"?d.jsx("div",{className:"h-screen w-full flex items-center justify-center bg-white dark:bg-zinc-900",children:d.jsxs("div",{className:"flex flex-col items-center gap-4",children:[d.jsx(cl,{className:"h-8 w-8 animate-spin text-zinc-600 dark:text-zinc-400"}),d.jsx("p",{className:"text-sm text-zinc-600 dark:text-zinc-400",children:"Completing authentication..."})]})}):e==="error"?d.jsx("div",{className:"h-screen w-full flex items-center justify-center bg-white dark:bg-zinc-900",children:d.jsxs("div",{className:"max-w-md p-6",children:[d.jsx("h1",{className:"text-xl font-semibold text-red-600 dark:text-red-400 mb-2",children:"Authentication Error"}),d.jsx("p",{className:"text-sm text-zinc-600 dark:text-zinc-400 mb-4",children:n}),d.jsx("p",{className:"text-xs text-zinc-500 dark:text-zinc-500",children:"You can close this window and try again."})]})}):d.jsx("div",{className:"h-screen w-full flex items-center justify-center bg-white dark:bg-zinc-900",children:d.jsxs("div",{className:"max-w-md p-6",children:[d.jsx("h1",{className:"text-xl font-semibold text-green-600 dark:text-green-400 mb-2",children:"Authentication Successful!"}),d.jsx("p",{className:"text-sm text-zinc-600 dark:text-zinc-400",children:"Redirecting you back..."})]})})}var CTe=(e,t,n,r,a,o,i,l)=>{let u=document.documentElement,f=["light","dark"];function m(y){(Array.isArray(e)?e:[e]).forEach(E=>{let x=E==="class",w=x&&o?a.map(S=>o[S]||S):a;x?(u.classList.remove(...w),u.classList.add(o&&o[y]?o[y]:y)):u.setAttribute(E,y)}),h(y)}function h(y){l&&f.includes(y)&&(u.style.colorScheme=y)}function g(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}if(r)m(r);else try{let y=localStorage.getItem(t)||n,E=i&&y==="system"?g():y;m(E)}catch{}},RTe=b.createContext(void 0),kTe={setTheme:e=>{},themes:[]},ATe=()=>{var e;return(e=b.useContext(RTe))!=null?e:kTe};b.memo(({forcedTheme:e,storageKey:t,attribute:n,enableSystem:r,enableColorScheme:a,defaultTheme:o,value:i,themes:l,nonce:u,scriptProps:f})=>{let m=JSON.stringify([n,t,o,e,l,i,r,a]).slice(1,-1);return b.createElement("script",{...f,suppressHydrationWarning:!0,nonce:typeof window>"u"?u:"",dangerouslySetInnerHTML:{__html:`(${CTe.toString()})(${m})`}})});function ITe({...e}){const{theme:t="system"}=ATe();return d.jsx(Hme,{theme:t,className:"toaster group",style:{"--normal-bg":"var(--popover)","--normal-text":"var(--popover-foreground)","--normal-border":"var(--border)"},...e})}function OTe(){const t=new URLSearchParams(window.location.search).get("embedded")==="true",n=b.useMemo(()=>t?void 0:new nae("mcp-inspector-connections"),[t]);return d.jsx(tbe,{children:d.jsx(AB,{storageProvider:n,enableRpcLogging:!0,defaultAutoProxyFallback:{enabled:!0,proxyAddress:`${window.location.origin}/inspector/api/proxy`},clientInfo:{name:"mcp-use Inspector",version:window.__INSPECTOR_VERSION__,websiteUrl:"https://mcp-use.com",icons:[{src:"https://mcp-use.com/logo.png"}]},onServerAdded:(r,a)=>{console.log("[Inspector] Server added:",r,a.state)},onServerRemoved:r=>{console.log("[Inspector] Server removed:",r)},onServerStateChange:(r,a)=>{console.log("[Inspector] Server state changed:",r,a)},onSamplingRequest:(r,a,o,i,l)=>{const u=Nt(d.jsx(pTe,{requestId:r.id,serverName:o,onViewDetails:()=>{const f=new CustomEvent("navigate-to-sampling",{detail:{requestId:r.id}});window.dispatchEvent(f),Nt.dismiss(u)},onApprove:f=>{i(r.id,f),Nt.success("Sampling request approved"),Nt.dismiss(u)},onDeny:()=>{l(r.id,"User denied from toast"),Nt.dismiss(u)}}),{duration:1/0})},onElicitationRequest:(r,a,o,i,l)=>{const u=r.request.mode||"form",f=r.request.message,m=u==="url"&&"url"in r.request?r.request.url:void 0,h=Nt(d.jsx(dae,{requestId:r.id,serverName:o,mode:u,message:f,url:m,onViewDetails:()=>{const g=new CustomEvent("navigate-to-elicitation",{detail:{requestId:r.id}});window.dispatchEvent(g),Nt.dismiss(h)},onOpenUrl:u==="url"&&m?()=>{window.open(m,"_blank"),Nt.dismiss(h)}:void 0,onCancel:()=>{l(r.id,"User cancelled from toast"),Nt.dismiss(h)}}),{duration:1/0})},children:d.jsxs(F0e,{children:[d.jsx(rme,{basename:"/inspector",children:d.jsxs(Zfe,{children:[d.jsx(E_,{path:"/oauth/callback",element:d.jsx(NTe,{})}),d.jsx(E_,{path:"/",element:d.jsx(TTe,{children:d.jsx(z0e,{})})})]})}),d.jsx(ITe,{position:"top-center"})]})})})}const o4=new URLSearchParams(window.location.search);if(o4.has("code")||o4.has("error"))try{SN()}catch(e){console.error("[inspector] OAuth callback error:",e)}const s4=document.getElementById("root");s4?uae.createRoot(s4).render(d.jsx(OTe,{})):console.error("[inspector] Root element not found");const DTe=Object.freeze(Object.defineProperty({__proto__:null,clearRpcLogs:Fy,getAllRpcLogs:TN,getRpcLogs:IB,subscribeToRpcLogs:NN,wrapTransportForLogging:OB},Symbol.toStringTag,{value:"Module"}));export{iy as $,Ec as A,Rpe as B,R_ as C,WTe as D,vs as E,fw as F,KTe as G,eC as H,Na as I,Vpe as J,v_ as K,ac as L,vfe as M,ua as N,iNe as O,cfe as P,ype as Q,_Ne as R,LNe as S,bNe as T,lNe as U,rme as V,w6 as W,CNe as X,ql as Y,tC as Z,ze as _,Ua as a,Rfe as a$,v6 as a0,ENe as a1,oNe as a2,SNe as a3,ome as a4,sNe as a5,Ide as a6,h6 as a7,E_ as a8,Nc as a9,xNe as aA,dme as aB,TNe as aC,VTe as aD,NNe as aE,ga as aF,qy as aG,cNe as aH,S_ as aI,MNe as aJ,efe as aK,GTe as aL,ym as aM,Ro as aN,uNe as aO,Zde as aP,ame as aQ,ONe as aR,nNe as aS,pC as aT,tNe as aU,Ufe as aV,INe as aW,Ffe as aX,kNe as aY,ANe as aZ,ume as a_,Zfe as aa,Jpe as ab,sme as ac,DNe as ad,ZTe as ae,si as af,gl as ag,cw as ah,cf as ai,ka as aj,oo as ak,lw as al,dNe as am,hNe as an,pNe as ao,JH as ap,wC as aq,vNe as ar,QH as as,XH as at,nC as au,wNe as av,yNe as aw,hC as ax,Et as ay,oh as az,jNe as b,nr as b$,Tc as b0,ime as b1,fC as b2,Aa as b3,XTe as b4,dC as b5,bl as b6,$fe as b7,qTe as b8,Afe as b9,dr as bA,pe as bB,wt as bC,An as bD,v3 as bE,BTe as bF,no as bG,rr as bH,FTe as bI,UTe as bJ,fr as bK,_p as bL,zTe as bM,pl as bN,pJ as bO,pX as bP,_X as bQ,DZ as bR,jZ as bS,fJ as bT,fX as bU,PTe as bV,RZ as bW,ol as bX,LQ as bY,oee as bZ,g3 as b_,JTe as ba,iC as bb,ah as bc,QTe as bd,eNe as be,Ife as bf,RNe as bg,E6 as bh,pme as bi,Ute as bj,MTe as bk,Fm as bl,Jb as bm,Fre as bn,Tv as bo,rs as bp,He as bq,zre as br,Vre as bs,x$ as bt,jTe as bu,Bre as bv,at as bw,nt as bx,er as by,nee as bz,Ppe as c,DX as c0,w4 as c1,xZ as c2,ny as c3,lZ as c4,Gre as c5,cZ as c6,SN as c7,EZ as c8,vpe as d,ue as e,ju as f,fc as g,rNe as h,aNe as i,LV as j,bpe as k,Nfe as l,Uo as m,Cfe as n,wm as o,$Te as p,So as q,b as r,zpe as s,lfe as t,mC as u,YTe as v,x_ as w,gNe as x,mNe as y,fNe as z};